From bdfd24339fe858d55ed19e2b967823a5cc964a45 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 7 Jun 2022 08:22:29 +0000 Subject: [PATCH] Updated Rector to commit 2e977bd3aad21113e0bb7e2aa9b102f6f1e9246d https://github.com/rectorphp/rector-src/commit/2e977bd3aad21113e0bb7e2aa9b102f6f1e9246d deploy to original repository --- bin/rector.php | 25 +- config/config.php | 80 +-- ...ion-injection-to-constructor-injection.php | 4 +- config/set/code-quality.php | 6 +- config/set/coding-style.php | 6 +- config/set/dead-code.php | 94 +-- config/set/defluent.php | 2 +- config/set/downgrade-php53.php | 6 +- config/set/downgrade-php54.php | 18 +- config/set/downgrade-php55.php | 12 +- config/set/downgrade-php56.php | 14 +- config/set/downgrade-php70.php | 40 +- config/set/downgrade-php71.php | 26 +- config/set/downgrade-php72.php | 16 +- config/set/downgrade-php73.php | 18 +- config/set/downgrade-php74.php | 28 +- config/set/downgrade-php80.php | 66 +- config/set/downgrade-php81.php | 22 +- config/set/downgrade-php82.php | 6 +- config/set/early-return.php | 24 +- config/set/flysystem-20.php | 26 +- config/set/framework-extra-bundle-40.php | 6 +- config/set/framework-extra-bundle-50.php | 4 +- config/set/gmagick_to_imagick.php | 6 +- config/set/guzzle50.php | 10 +- config/set/level/down-to-php52.php | 4 +- config/set/level/down-to-php53.php | 4 +- config/set/level/down-to-php54.php | 4 +- config/set/level/down-to-php55.php | 4 +- config/set/level/down-to-php56.php | 4 +- config/set/level/down-to-php70.php | 4 +- config/set/level/down-to-php71.php | 4 +- config/set/level/down-to-php72.php | 4 +- config/set/level/down-to-php73.php | 4 +- config/set/level/down-to-php74.php | 4 +- config/set/level/down-to-php80.php | 4 +- config/set/level/down-to-php81.php | 4 +- config/set/level/up-to-php54.php | 6 +- config/set/level/up-to-php55.php | 6 +- config/set/level/up-to-php56.php | 6 +- config/set/level/up-to-php70.php | 6 +- config/set/level/up-to-php71.php | 6 +- config/set/level/up-to-php72.php | 6 +- config/set/level/up-to-php73.php | 6 +- config/set/level/up-to-php74.php | 6 +- config/set/level/up-to-php80.php | 6 +- config/set/level/up-to-php81.php | 6 +- config/set/level/up-to-php82.php | 6 +- config/set/monolog20.php | 4 +- config/set/mysql-to-mysqli.php | 18 +- config/set/naming.php | 14 +- config/set/php52.php | 10 +- config/set/php53.php | 8 +- config/set/php54.php | 8 +- config/set/php55.php | 12 +- config/set/php56.php | 8 +- config/set/php70.php | 40 +- config/set/php71.php | 18 +- config/set/php72.php | 24 +- config/set/php73.php | 24 +- config/set/php74.php | 30 +- config/set/php80.php | 44 +- config/set/php81.php | 22 +- config/set/php82.php | 4 +- config/set/privatization.php | 18 +- config/set/psr-4.php | 6 +- config/set/rector-config.php | 4 +- config/set/type-declaration-strict.php | 22 +- config/set/type-declaration.php | 26 +- config/set/unwrap-compat.php | 4 +- .../Attributes/AttributeMirrorer.php | 4 +- .../Comment/CommentsMerger.php | 28 +- .../BasePhpDocNodeVisitorInterface.php | 2 +- .../PhpDocNodeDecoratorInterface.php | 2 +- .../CurrentTokenIteratorProvider.php | 6 +- .../PhpDoc/DoctrineAnnotationTagValueNode.php | 6 +- .../PhpDoc/SpacelessPhpDocTagNode.php | 2 +- .../PhpDocInfo/PhpDocInfo.php | 76 +-- .../PhpDocInfo/PhpDocInfoFactory.php | 34 +- .../PhpDocInfo/TokenIteratorFactory.php | 12 +- .../PhpDocManipulator/PhpDocClassRenamer.php | 22 +- .../PhpDocManipulator/PhpDocTagRemover.php | 16 +- .../PhpDocManipulator/PhpDocTypeChanger.php | 56 +- .../PropertyDocBlockManipulator.php | 8 +- .../VarAnnotationManipulator.php | 16 +- .../PhpDocNodeByTypeFinder.php | 10 +- .../BetterPhpDocParser/PhpDocNodeMapper.php | 10 +- .../ArrayTypePhpDocNodeVisitor.php | 12 +- .../CallableTypePhpDocNodeVisitor.php | 12 +- .../ChangedPhpDocNodeVisitor.php | 8 +- .../IntersectionTypeNodePhpDocNodeVisitor.php | 12 +- .../TemplatePhpDocNodeVisitor.php | 22 +- .../UnionTypeNodePhpDocNodeVisitor.php | 32 +- .../PhpDocParser/BetterPhpDocParser.php | 48 +- .../PhpDocParser/BetterTypeParser.php | 10 +- .../PhpDocParser/ClassAnnotationMatcher.php | 18 +- .../ConstExprClassNameDecorator.php | 16 +- .../DoctrineAnnotationDecorator.php | 70 +- .../PhpDocFromTypeDeclarationDecorator.php | 32 +- .../StaticDoctrineAnnotationParser.php | 30 +- .../ArrayParser.php | 56 +- .../PlainValueParser.php | 36 +- .../Printer/DocBlockInliner.php | 4 +- .../Printer/EmptyPhpDocDetector.php | 4 +- .../Printer/PhpDocInfoPrinter.php | 56 +- .../RemoveNodesStartAndEndResolver.php | 12 +- .../ValueObject/NodeTypes.php | 2 +- .../Parser/BetterTokenIterator.php | 6 +- .../AbstractValuesAwareNode.php | 14 +- .../SpacingAwareTemplateTagValueNode.php | 4 +- .../ValueObject/PhpDocAttributeKey.php | 4 +- .../ValueObject/StartAndEnd.php | 2 +- .../BracketsAwareIntersectionTypeNode.php | 2 +- .../Type/BracketsAwareUnionTypeNode.php | 2 +- .../ValueObject/Type/EmptyGenericTypeNode.php | 4 +- .../Type/FullyQualifiedIdentifierTypeNode.php | 2 +- .../Type/ShortenedIdentifierTypeNode.php | 2 +- .../Type/SpacingAwareArrayTypeNode.php | 14 +- .../Type/SpacingAwareCallableTypeNode.php | 2 +- packages/Caching/Cache.php | 2 +- packages/Caching/CacheFactory.php | 16 +- packages/Caching/Config/FileHashComputer.php | 14 +- .../Caching/Detector/ChangedFilesDetector.php | 32 +- .../Caching/FileSystem/DependencyResolver.php | 4 +- packages/Caching/UnchangedFilesFilter.php | 6 +- .../ValueObject/Storage/FileCacheStorage.php | 24 +- .../Storage/MemoryCacheStorage.php | 4 +- .../Annotation/AnnotationExtractor.php | 4 +- .../Collector/AffectedFilesCollector.php | 6 +- .../Collector/RectorChangeCollector.php | 10 +- .../Output/OutputFormatterInterface.php | 2 +- .../Output/ConsoleOutputFormatter.php | 20 +- .../Output/JsonOutputFormatter.php | 10 +- .../ValueObject/RectorWithLineChange.php | 8 +- .../ValueObjectFactory/ErrorFactory.php | 8 +- .../ValueObjectFactory/FileDiffFactory.php | 6 +- packages/Comments/CommentRemover.php | 2 +- .../Comments/NodeDocBlock/DocBlockUpdater.php | 14 +- .../CommentRemovingNodeTraverser.php | 4 +- .../CommentRemovingNodeVisitor.php | 8 +- packages/Config/RectorConfig.php | 80 +-- .../FluentChainMethodCallNodeAnalyzer.php | 26 +- .../SameClassMethodCallAnalyzer.php | 4 +- .../NodeAnalyzer/ClassChildAnalyzer.php | 24 +- .../Reflection/FamilyRelationsAnalyzer.php | 50 +- .../FamilyTree/ValueObject/PropertyType.php | 4 +- .../Parser/FileInfoParser.php | 8 +- .../ValueObject/AddedFileWithContent.php | 6 +- .../ValueObject/AddedFileWithNodes.php | 2 +- .../BinaryOpConditionsCollector.php | 4 +- .../NodeCollector/BinaryOpTreeRootLocator.php | 6 +- .../ArrayCallableMethodMatcher.php | 62 +- .../ParentClassScopeResolver.php | 8 +- packages/NodeCollector/StaticAnalyzer.php | 8 +- .../ValueObject/ArrayCallable.php | 6 +- .../ArrayCallableDynamicMethod.php | 8 +- .../Contract/NodeNameResolverInterface.php | 2 +- .../Error/InvalidNameNodeReporter.php | 12 +- .../NodeNameResolver/NodeNameResolver.php | 36 +- .../ClassConstFetchNameResolver.php | 8 +- .../ClassConstNameResolver.php | 8 +- .../NodeNameResolver/ClassNameResolver.php | 10 +- .../NodeNameResolver/EmptyNameResolver.php | 6 +- .../NodeNameResolver/FuncCallNameResolver.php | 14 +- .../NodeNameResolver/FunctionNameResolver.php | 10 +- .../NodeNameResolver/NameNameResolver.php | 14 +- .../NodeNameResolver/ParamNameResolver.php | 8 +- .../NodeNameResolver/PropertyNameResolver.php | 8 +- .../NodeNameResolver/UseNameResolver.php | 8 +- .../NodeNameResolver/VariableNameResolver.php | 12 +- .../Regex/RegexPatternDetector.php | 2 +- packages/NodeNestingScope/ContextAnalyzer.php | 38 +- .../NodeNestingScope/FlowOfControlLocator.php | 12 +- .../NodeFinder/ScopeAwareNodeFinder.php | 8 +- .../NodeNestingScope/ParentScopeFinder.php | 6 +- .../ScopeNestingComparator.php | 30 +- .../ValueObject/ControlStructure.php | 8 +- packages/NodeRemoval/BreakingRemovalGuard.php | 34 +- packages/NodeRemoval/NodeRemover.php | 22 +- .../Contract/NodeTypeResolverInterface.php | 2 +- .../SourceLocatorProviderInterface.php | 2 +- .../PHPStanServicesFactory.php | 48 +- .../MethodParameterTypeResolver.php | 16 +- .../NodeScopeAndMetadataDecorator.php | 8 +- .../AccessoryNonEmptyStringTypeCorrector.php | 10 +- .../GenericClassStringTypeCorrector.php | 10 +- .../HasOffsetTypeCorrector.php | 10 +- .../PregMatchTypeCorrector.php | 24 +- .../NodeTypeResolver/NodeTypeResolver.php | 142 ++-- .../NodeTypeResolver/CastTypeResolver.php | 18 +- .../ClassAndInterfaceTypeResolver.php | 20 +- .../ClassMethodOrClassConstTypeResolver.php | 16 +- .../IdentifierTypeResolver.php | 12 +- .../NodeTypeResolver/NameTypeResolver.php | 44 +- .../NodeTypeResolver/NewTypeResolver.php | 38 +- .../NodeTypeResolver/ParamTypeResolver.php | 48 +- .../PropertyFetchTypeResolver.php | 42 +- .../NodeTypeResolver/PropertyTypeResolver.php | 12 +- .../NodeTypeResolver/ReturnTypeResolver.php | 10 +- .../NodeTypeResolver/ScalarTypeResolver.php | 28 +- .../StaticCallMethodCallTypeResolver.php | 36 +- .../NodeTypeResolver/TraitTypeResolver.php | 16 +- .../NodeTypeResolver/VariableTypeResolver.php | 34 +- ...unctionLikeParamArgPositionNodeVisitor.php | 12 +- .../RemoveDeepChainMethodCallNodeVisitor.php | 20 +- .../Scope/PHPStanNodeScopeResolver.php | 98 +-- .../PHPStan/Scope/ScopeFactory.php | 8 +- .../PHPStan/Type/StaticTypeAnalyzer.php | 30 +- .../PHPStan/Type/TypeFactory.php | 48 +- .../NodeTypeResolver/PHPStan/TypeHasher.php | 64 +- .../NodeAnalyzer/DocBlockClassRenamer.php | 6 +- .../NodeAnalyzer/DocBlockNameImporter.php | 6 +- .../NodeAnalyzer/DocBlockNamespaceRenamer.php | 14 +- .../NodeAnalyzer/DocBlockTagReplacer.php | 8 +- .../PhpDoc/PhpDocTypeRenamer.php | 8 +- .../ClassRenamePhpDocNodeVisitor.php | 44 +- .../NameImportingPhpDocNodeVisitor.php | 78 +-- .../UnderscoreRenamePhpDocNodeVisitor.php | 20 +- ...orBetterReflectionSourceLocatorFactory.php | 8 +- .../IntermediateSourceLocator.php | 8 +- .../DynamicSourceLocatorProvider.php | 20 +- .../TypeAnalyzer/ArrayTypeAnalyzer.php | 48 +- .../TypeAnalyzer/CountableTypeAnalyzer.php | 6 +- .../TypeAnalyzer/MethodTypeAnalyzer.php | 14 +- .../TypeAnalyzer/StringTypeAnalyzer.php | 10 +- .../TypeComparator/ArrayTypeComparator.php | 20 +- .../TypeComparator/ScalarTypeComparator.php | 30 +- .../TypeComparator/TypeComparator.php | 96 +-- .../ValueObject/OldToNewType.php | 6 +- .../Contract/TypeMapperInterface.php | 4 +- .../DoctrineTypeAnalyzer.php | 10 +- .../PHPStanStaticTypeMapper.php | 20 +- .../TypeAnalyzer/BoolUnionTypeAnalyzer.php | 10 +- .../TypeAnalyzer/UnionTypeAnalyzer.php | 48 +- .../UnionTypeCommonTypeNarrower.php | 34 +- .../AccessoryNonEmptyStringTypeMapper.php | 12 +- .../AccessoryNumericStringTypeMapper.php | 12 +- .../TypeMapper/ArrayShapeTypeMapper.php | 18 +- .../TypeMapper/ArrayTypeMapper.php | 88 +-- .../TypeMapper/BooleanTypeMapper.php | 30 +- .../TypeMapper/CallableTypeMapper.php | 16 +- .../TypeMapper/ClassStringTypeMapper.php | 30 +- .../TypeMapper/ClosureTypeMapper.php | 18 +- .../TypeMapper/FloatTypeMapper.php | 16 +- .../TypeMapper/HasMethodTypeMapper.php | 10 +- .../TypeMapper/HasOffsetTypeMapper.php | 12 +- .../TypeMapper/HasPropertyTypeMapper.php | 10 +- .../TypeMapper/IntegerTypeMapper.php | 16 +- .../TypeMapper/IntersectionTypeMapper.php | 26 +- .../TypeMapper/IterableTypeMapper.php | 26 +- .../TypeMapper/MixedTypeMapper.php | 16 +- .../TypeMapper/NeverTypeMapper.php | 14 +- .../TypeMapper/NonEmptyArrayTypeMapper.php | 12 +- .../TypeMapper/NullTypeMapper.php | 18 +- .../TypeMapper/ObjectTypeMapper.php | 70 +- .../ObjectWithoutClassTypeMapper.php | 26 +- .../TypeMapper/ParentStaticTypeMapper.php | 12 +- .../TypeMapper/ResourceTypeMapper.php | 10 +- .../TypeMapper/SelfObjectTypeMapper.php | 12 +- .../TypeMapper/StaticTypeMapper.php | 26 +- .../TypeMapper/StrictMixedTypeMapper.php | 12 +- .../TypeMapper/StringTypeMapper.php | 16 +- .../TypeMapper/ThisTypeMapper.php | 12 +- .../TypeWithClassNameTypeMapper.php | 16 +- .../TypeMapper/UnionTypeMapper.php | 120 ++-- .../TypeMapper/VoidTypeMapper.php | 18 +- .../Utils/TypeUnwrapper.php | 16 +- .../Application/ParallelFileProcessor.php | 62 +- .../Command/WorkerCommandLineFactory.php | 24 +- packages/Parallel/WorkerRunner.php | 34 +- .../AnnotationToAttributeMapper.php | 8 +- .../ArrayAnnotationToAttributeMapper.php | 18 +- ...sConstFetchAnnotationToAttributeMapper.php | 4 +- ...nstExprNodeAnnotationToAttributeMapper.php | 24 +- ...rlyListNodeAnnotationToAttributeMapper.php | 16 +- ...eAnnotationAnnotationToAttributeMapper.php | 20 +- .../StringAnnotationToAttributeMapper.php | 18 +- .../AttributeArrayNameInliner.php | 24 +- .../AnnotationToAttributeMapperInterface.php | 2 +- .../InvalidNestedAttributeException.php | 2 +- .../ExprParameterReflectionTypeCorrector.php | 20 +- .../NodeFactory/AttributeNameFactory.php | 14 +- .../NodeFactory/DoctrineAnnotationFactory.php | 12 +- .../NodeFactory/NamedArgsFactory.php | 24 +- .../NodeFactory/PhpAttributeGroupFactory.php | 32 +- .../RemovableAnnotationAnalyzer.php | 8 +- .../UnwrapableAnnotationAnalyzer.php | 10 +- packages/PhpAttribute/UseAliasNameMatcher.php | 8 +- .../ValueObject/UseAliasMetadata.php | 4 +- .../Application/PostFileProcessor.php | 10 +- .../Collector/NodesToAddCollector.php | 50 +- .../Collector/NodesToRemoveCollector.php | 36 +- .../Collector/PropertyToAddCollector.php | 16 +- .../Collector/UseNodesToAddCollector.php | 26 +- .../Contract/Rector/PostRectorInterface.php | 2 +- .../NodeAnalyzer/NetteInjectDetector.php | 12 +- .../PostRector/Rector/AbstractPostRector.php | 2 +- .../Rector/ClassRenamingPostRector.php | 12 +- .../Rector/NameImportingPostRector.php | 30 +- .../Rector/NodeAddingPostRector.php | 12 +- .../Rector/NodeRemovingPostRector.php | 36 +- .../Rector/PropertyAddingPostRector.php | 20 +- .../PostRector/Rector/UseAddingPostRector.php | 16 +- .../ValueObject/PropertyMetadata.php | 4 +- .../ParentNodeReadAnalyzerInterface.php | 2 +- .../Contract/ReadNodeAnalyzerInterface.php | 4 +- .../Guard/VariableToConstantGuard.php | 22 +- .../NodeAnalyzer/ReadExprAnalyzer.php | 4 +- .../ReadWritePropertyAnalyzer.php | 38 +- .../ReadWrite/NodeFinder/NodeUsageFinder.php | 14 +- .../ArgParentNodeReadAnalyzer.php | 8 +- .../ArrayDimFetchParentNodeReadAnalyzer.php | 16 +- .../IncDecParentNodeReadAnalyzer.php | 12 +- .../ReadNodeAnalyzer/JustReadExprAnalyzer.php | 16 +- .../LocalPropertyFetchReadNodeAnalyzer.php | 14 +- .../VariableReadNodeAnalyzer.php | 10 +- .../Set/ValueObject/DowngradeLevelSetList.php | 2 +- packages/Set/ValueObject/DowngradeSetList.php | 2 +- packages/Set/ValueObject/LevelSetList.php | 2 +- packages/Set/ValueObject/SetList.php | 2 +- .../PhpDocTypeMapperInterface.php | 2 +- .../PhpParserNodeMapperInterface.php | 2 +- .../Mapper/PhpParserNodeMapper.php | 12 +- .../Mapper/ScalarStringToTypeMapper.php | 18 +- .../Naming/NameScopeFactory.php | 28 +- .../PhpDoc/PhpDocTypeMapper.php | 4 +- .../PhpDocParser/IdentifierTypeMapper.php | 58 +- .../PhpDocParser/IntersectionTypeMapper.php | 10 +- .../PhpDocParser/NullableTypeMapper.php | 12 +- .../PhpDocParser/UnionTypeMapper.php | 10 +- .../PhpParser/ExprNodeMapper.php | 12 +- .../PhpParser/FullyQualifiedNodeMapper.php | 34 +- .../PhpParser/IdentifierNodeMapper.php | 8 +- .../PhpParser/IntersectionTypeNodeMapper.php | 10 +- .../PhpParser/NameNodeMapper.php | 48 +- .../PhpParser/NullableTypeNodeMapper.php | 12 +- .../PhpParser/StringNodeMapper.php | 8 +- .../PhpParser/UnionTypeNodeMapper.php | 10 +- .../StaticTypeMapper/StaticTypeMapper.php | 34 +- .../ValueObject/Type/AliasedObjectType.php | 26 +- .../Type/FullyQualifiedGenericObjectType.php | 2 +- .../Type/FullyQualifiedObjectType.php | 34 +- .../Type/NonExistingObjectType.php | 2 +- .../Type/ParentObjectWithoutClassType.php | 2 +- .../ValueObject/Type/ParentStaticType.php | 2 +- .../ValueObject/Type/SelfObjectType.php | 2 +- .../ValueObject/Type/SelfStaticType.php | 2 +- .../Type/ShortenedGenericObjectType.php | 6 +- .../ValueObject/Type/ShortenedObjectType.php | 6 +- .../ValueObject/Type/SimpleStaticType.php | 2 +- .../PHPUnit/AbstractRectorTestCase.php | 40 +- packages/Testing/PHPUnit/AbstractTestCase.php | 12 +- .../PHPUnit/Behavior/MovingFilesTrait.php | 18 +- .../Behavior/MultipleFilesChangedTrait.php | 16 +- .../Testing/TestingParser/TestingParser.php | 16 +- .../ClassMethodParamVendorLockResolver.php | 16 +- .../ClassMethodReturnTypeOverrideGuard.php | 40 +- .../ClassMethodReturnVendorLockResolver.php | 12 +- .../PropertyTypeVendorLockResolver.php | 18 +- .../ParentClassMethodTypeOverrideGuard.php | 26 +- packages/VendorLocker/VendorLockResolver.php | 10 +- .../VersionBonding/PhpVersionedFilter.php | 4 +- preload.php | 3 - .../ArgumentDefaultValueReplacer.php | 26 +- .../NodeAnalyzer/ArgumentAddingScope.php | 10 +- .../NodeAnalyzer/ChangedArgumentsDetector.php | 6 +- .../ClassMethod/ArgumentAdderRector.php | 70 +- .../ReplaceArgumentDefaultValueRector.php | 22 +- ...tionArgumentDefaultValueReplacerRector.php | 22 +- .../FuncCall/SwapFuncCallArgumentsRector.php | 22 +- .../RemoveMethodCallParamRector.php | 22 +- rules/Arguments/ValueObject/ArgumentAdder.php | 8 +- .../ValueObject/RemoveMethodCallParam.php | 4 +- .../ReplaceArgumentDefaultValue.php | 8 +- .../ReplaceFuncCallArgumentDefaultValue.php | 2 +- rules/CodeQuality/CompactConverter.php | 18 +- .../NodeAnalyzer/ArrayCompacter.php | 10 +- .../NodeAnalyzer/ArrayItemsAnalyzer.php | 10 +- .../NodeAnalyzer/ClassLikeAnalyzer.php | 4 +- ...ConstructorPropertyDefaultExprResolver.php | 12 +- .../CodeQuality/NodeAnalyzer/ForAnalyzer.php | 52 +- .../NodeAnalyzer/ForeachAnalyzer.php | 28 +- .../NodeAnalyzer/LocalPropertyAnalyzer.php | 48 +- .../NodeAnalyzer/ReturnAnalyzer.php | 8 +- .../VariableDimFetchAssignResolver.php | 16 +- .../NodeFactory/ArrayFilterFactory.php | 30 +- .../NodeFactory/ForeachFactory.php | 10 +- .../NodeFactory/MissingPropertiesFactory.php | 2 +- .../NodeFactory/PropertyTypeDecorator.php | 32 +- .../ClassMethodParameterTypeManipulator.php | 44 +- .../ClassMethodReturnTypeManipulator.php | 16 +- .../NodeManipulator/ExprBoolCaster.php | 22 +- rules/CodeQuality/NodeTypeGroup.php | 2 +- .../ArrayThisCallToThisMethodCallRector.php | 38 +- ...ableThisArrayToAnonymousFunctionRector.php | 20 +- .../Rector/Assign/CombinedAssignRector.php | 18 +- .../SplitListAssignToSeparateLineRector.php | 32 +- .../SimplifyEmptyArrayCheckRector.php | 26 +- .../ReplaceMultipleBooleanNotRector.php | 18 +- .../SimplifyDeMorganBinaryRector.php | 18 +- .../ThrowWithPreviousExceptionRector.php | 52 +- .../DateTimeToDateTimeInterfaceRector.php | 68 +- .../InlineArrayReturnAssignRector.php | 44 +- .../ClassMethod/NarrowUnionTypeDocRector.php | 28 +- .../OptionalParametersAfterRequiredRector.php | 36 +- .../CompleteDynamicPropertiesRector.php | 24 +- ...lineConstructorDefaultToPropertyRector.php | 22 +- .../Rector/Concat/JoinStringConcatRector.php | 36 +- .../Do_/DoWhileBreakFalseToIfElseRector.php | 30 +- ...seIdenticalOverEqualWithSameTypeRector.php | 30 +- .../Expression/InlineIfToExplicitIfRector.php | 34 +- .../ForRepeatedCountToOwnVariableRector.php | 26 +- .../Rector/For_/ForToForeachRector.php | 34 +- ...hItemsAssignToEmptyArrayToAssignRector.php | 38 +- .../Foreach_/ForeachToInArrayRector.php | 60 +- .../SimplifyForeachToArrayFilterRector.php | 56 +- .../SimplifyForeachToCoalescingRector.php | 48 +- .../UnusedForeachValueToArrayKeysRector.php | 36 +- .../FuncCall/AddPregQuoteDelimiterRector.php | 40 +- ...ayKeysAndInArrayToArrayKeyExistsRector.php | 40 +- ...rayMergeOfNonArraysToSimpleArrayRector.php | 22 +- ...serFuncWithArrowFunctionToInlineRector.php | 22 +- .../ChangeArrayPushToArrayAssignRector.php | 24 +- .../FuncCall/CompactToVariablesRector.php | 40 +- .../FuncCall/InlineIsAInstanceOfRector.php | 30 +- .../FuncCall/IntvalToTypeCastRector.php | 20 +- .../IsAWithStringWithThirdArgumentRector.php | 20 +- .../FuncCall/RemoveSoleValueSprintfRector.php | 20 +- .../Rector/FuncCall/SetTypeToCastRector.php | 28 +- .../SimplifyFuncGetArgsCountRector.php | 18 +- .../FuncCall/SimplifyInArrayValuesRector.php | 20 +- .../FuncCall/SimplifyRegexPatternRector.php | 18 +- .../FuncCall/SimplifyStrposLowerRector.php | 20 +- .../FuncCall/SingleInArrayToCompareRector.php | 26 +- .../UnwrapSprintfOneArgumentRector.php | 16 +- ...aysTrueConditionSetInConstructorRector.php | 60 +- .../SimplifyUselessVariableRector.php | 36 +- ...ooleanNotIdenticalToNotIdenticalRector.php | 34 +- ...lipTypeControlToUseExclusiveTypeRector.php | 50 +- .../Identical/GetClassToInstanceOfRector.php | 46 +- .../Identical/SimplifyArraySearchRector.php | 28 +- .../SimplifyBoolIdenticalTrueRector.php | 34 +- .../Identical/SimplifyConditionsRector.php | 42 +- ...StrlenZeroToIdenticalEmptyStringRector.php | 28 +- .../Rector/If_/CombineIfRector.php | 28 +- ...ompareReturnsToNullCoalesceQueueRector.php | 34 +- .../Rector/If_/ExplicitBoolCompareRector.php | 102 +-- .../Rector/If_/ShortenElseIfRector.php | 22 +- .../If_/SimplifyIfElseToTernaryRector.php | 54 +- .../SimplifyIfExactValueReturnValueRector.php | 22 +- .../SimplifyIfIssetToNullCoalescingRector.php | 46 +- .../If_/SimplifyIfNotNullReturnRector.php | 20 +- .../If_/SimplifyIfNullableReturnRector.php | 74 +-- .../Rector/If_/SimplifyIfReturnBoolRector.php | 62 +- .../AbsolutizeRequireAndIncludePathRector.php | 32 +- ...OnPropertyObjectToPropertyExistsRector.php | 38 +- .../AndAssignsToSeparateLinesRector.php | 24 +- .../LogicalAnd/LogicalToBooleanRector.php | 24 +- .../Rector/New_/NewStaticToNewSelfRector.php | 22 +- .../Rector/NotEqual/CommonNotEqualRector.php | 16 +- ...xplicitMethodCallOverMagicGetSetRector.php | 42 +- .../Switch_/SingularSwitchToIfRector.php | 18 +- ...istsTernaryThenValueToCoalescingRector.php | 26 +- .../SimplifyTautologyTernaryRector.php | 24 +- .../Ternary/SwitchNegatedTernaryRector.php | 22 +- .../UnnecessaryTernaryExpressionRector.php | 42 +- .../ArrayDimFetchTypeResolver.php | 18 +- .../AssignVariableTypeResolver.php | 6 +- .../ValueObject/DefaultPropertyExprAssign.php | 6 +- rules/CodeQuality/ValueObject/KeyAndExpr.php | 6 +- .../Application/UseImportsAdder.php | 24 +- .../Application/UseImportsRemover.php | 8 +- .../ClassNameImport/AliasUsesResolver.php | 12 +- .../AliasClassNameImportSkipVoter.php | 6 +- .../ClassLikeNameClassNameImportSkipVoter.php | 6 +- ...yQualifiedNameClassNameImportSkipVoter.php | 6 +- .../UsesClassNameImportSkipVoter.php | 6 +- .../ClassNameImportSkipper.php | 12 +- .../ClassNameImport/ShortNameResolver.php | 48 +- .../ClassNameImport/UseImportsTraverser.php | 16 +- .../ClassNameImport/UsedImportsResolver.php | 26 +- .../ClassNameImportSkipVoterInterface.php | 2 +- rules/CodingStyle/Naming/ClassNaming.php | 8 +- rules/CodingStyle/Node/NameImporter.php | 40 +- .../NodeAnalyzer/SpreadVariablesCollector.php | 8 +- .../NodeAnalyzer/UseImportNameMatcher.php | 26 +- .../ArrayCallableToMethodCallFactory.php | 16 +- .../Assign/PHPStormVarAnnotationRector.php | 46 +- .../Rector/Assign/SplitDoubleAssignRector.php | 32 +- .../CatchExceptionNameMatchingTypeRector.php | 56 +- .../ClassConst/RemoveFinalFromConstRector.php | 22 +- ...litGroupedConstantsAndPropertiesRector.php | 22 +- .../ClassConst/VarConstantCommentRector.php | 38 +- .../FuncGetArgsToVariadicParamRector.php | 56 +- ...itedMethodVisibilitySameAsParentRector.php | 22 +- .../NewlineBeforeNewAssignSetRector.php | 26 +- .../ClassMethod/OrderAttributesRector.php | 26 +- ...moveDoubleUnderscoreInMethodNameRector.php | 22 +- .../ReturnArrayClassMethodToYieldRector.php | 44 +- .../ClassMethod/UnSpreadOperatorRector.php | 42 +- .../AddArrayDefaultToArrayPropertyRector.php | 64 +- .../EncapsedStringsToSprintfRector.php | 40 +- ...rapEncapsedVariableInCurlyBracesRector.php | 22 +- .../CallUserFuncArrayToVariadicRector.php | 32 +- .../CallUserFuncToMethodCallRector.php | 22 +- .../FuncCall/ConsistentImplodeRector.php | 20 +- .../ConsistentPregDelimiterRector.php | 50 +- ...CountArrayToEmptyArrayComparisonRector.php | 60 +- .../FuncCall/StrictArraySearchRector.php | 14 +- ...VersionCompareFuncCallToConstantRector.php | 32 +- .../If_/NullableCompareToNullRector.php | 38 +- .../PreferThisOrSelfMethodCallRector.php | 48 +- .../Rector/Plus/UseIncrementAssignRector.php | 22 +- .../PostInc/PostIncDecToPreIncDecRector.php | 38 +- .../AddFalseDefaultToBoolPropertyRector.php | 24 +- .../InlineSimplePropertyAnnotationRector.php | 22 +- .../Stmt/NewlineAfterStatementRector.php | 30 +- .../String_/SymplifyQuoteEscapeRector.php | 36 +- ...assKeywordForClassNameResolutionRector.php | 28 +- .../Switch_/BinarySwitchToIfElseRector.php | 30 +- ...rnaryConditionVariableAssignmentRector.php | 28 +- .../Use_/SeparateMultiUseImportsRector.php | 24 +- .../Reflection/VendorLocationDetector.php | 4 +- .../TypeAnalyzer/IterableTypeAnalyzer.php | 8 +- .../ValueObject/ObjectMagicMethods.php | 2 +- .../ReturnArrayClassMethodToYield.php | 6 +- .../RequiredAnnotationPropertyAnalyzer.php | 12 +- .../ConstructorClassMethodFactory.php | 6 +- .../AttributeCompatibleAnnotationRector.php | 28 +- .../ValueObject/PropertyWithPhpDocInfo.php | 14 +- .../FileProcessor/ComposerFileProcessor.php | 18 +- .../Rector/ComposerRectorInterface.php | 6 +- rules/Composer/Guard/VersionGuard.php | 2 +- .../AddPackageToRequireComposerRector.php | 18 +- .../AddPackageToRequireDevComposerRector.php | 18 +- .../ChangePackageVersionComposerRector.php | 18 +- .../Rector/RemovePackageComposerRector.php | 14 +- .../Rector/RenamePackageComposerRector.php | 16 +- ...ReplacePackageAndVersionComposerRector.php | 18 +- .../ValueObject/PackageAndVersion.php | 2 +- .../ValueObject/ReplacePackageAndVersion.php | 4 +- .../CurrentAndParentClassMethodComparator.php | 26 +- .../Parameter/ParameterDefaultsComparator.php | 6 +- .../Parameter/ParameterTypeComparator.php | 4 +- rules/DeadCode/ConditionEvaluator.php | 22 +- rules/DeadCode/ConditionResolver.php | 30 +- .../FunctionSupportResolver.php | 4 +- .../NodeAnalyzer/CallCollectionAnalyzer.php | 8 +- .../ExprUsedInNextNodeAnalyzer.php | 6 +- .../NodeAnalyzer/ExprUsedInNodeAnalyzer.php | 12 +- .../InstanceOfUniqueKeyResolver.php | 6 +- .../IsClassMethodUsedAnalyzer.php | 42 +- ...JustPropertyFetchVariableAssignMatcher.php | 32 +- .../NodeAnalyzer/UsedVariableNameAnalyzer.php | 8 +- .../ModifiedVariableNamesCollector.php | 24 +- .../NodeByTypeAndPositionCollector.php | 12 +- .../NodeCollector/UnusedParameterResolver.php | 4 +- .../DeadCode/NodeFinder/VariableUseFinder.php | 12 +- .../ControllerClassMethodManipulator.php | 14 +- .../NodeManipulator/CountManipulator.php | 30 +- .../NodeManipulator/LivingCodeManipulator.php | 36 +- .../VariadicFunctionLikeDetector.php | 10 +- .../PhpDoc/DeadParamTagValueNodeAnalyzer.php | 40 +- .../PhpDoc/DeadReturnTagValueNodeAnalyzer.php | 16 +- .../PhpDoc/DeadVarTagValueNodeAnalyzer.php | 6 +- .../PhpDoc/TagRemover/ParamTagRemover.php | 14 +- .../PhpDoc/TagRemover/ReturnTagRemover.php | 8 +- .../PhpDoc/TagRemover/VarTagRemover.php | 16 +- .../Array_/RemoveDuplicatedArrayKeyRector.php | 20 +- .../Assign/RemoveDoubleAssignRector.php | 30 +- .../RemoveUnusedVariableAssignRector.php | 80 +-- .../RemoveDuplicatedInstanceOfRector.php | 20 +- .../Rector/BooleanAnd/RemoveAndTrueRector.php | 18 +- .../Rector/Cast/RecastingRemovalRector.php | 30 +- ...RemoveUnusedPrivateClassConstantRector.php | 20 +- .../ClassLike/RemoveAnnotationRector.php | 20 +- .../RemoveDeadConstructorRector.php | 26 +- .../RemoveDelegatingParentCallRector.php | 42 +- .../RemoveEmptyClassMethodRector.php | 32 +- .../ClassMethod/RemoveLastReturnRector.php | 22 +- .../RemoveUnusedConstructorParamRector.php | 24 +- ...oveUnusedParamInRequiredAutowireRector.php | 20 +- ...moveUnusedPrivateMethodParameterRector.php | 38 +- .../RemoveUnusedPrivateMethodRector.php | 36 +- .../RemoveUnusedPromotedPropertyRector.php | 28 +- .../RemoveUselessParamTagRector.php | 18 +- .../RemoveUselessReturnTagRector.php | 16 +- .../Concat/RemoveConcatAutocastRector.php | 20 +- .../RemovePhpVersionIdCheckRector.php | 66 +- .../Expression/RemoveDeadStmtRector.php | 28 +- .../Expression/SimplifyMirrorAssignRector.php | 16 +- .../Rector/For_/RemoveDeadContinueRector.php | 20 +- .../For_/RemoveDeadIfForeachForRector.php | 30 +- .../Rector/For_/RemoveDeadLoopRector.php | 14 +- .../Foreach_/RemoveUnusedForeachKeyRector.php | 16 +- .../FunctionLike/RemoveDeadReturnRector.php | 16 +- .../RemoveDuplicatedIfReturnRector.php | 42 +- .../RemoveOverriddenValuesRector.php | 48 +- .../If_/RemoveAlwaysTrueIfConditionRector.php | 16 +- .../Rector/If_/RemoveDeadInstanceOfRector.php | 56 +- ...UnusedNonEmptyArrayBeforeForeachRector.php | 30 +- .../SimplifyIfElseWithSameContentRector.php | 22 +- ...FutureCompatibleIfFunctionExistsRector.php | 26 +- ...wrapFutureCompatibleIfPhpVersionRector.php | 22 +- .../RemoveEmptyMethodCallRector.php | 60 +- .../RemoveNonExistingVarAnnotationRector.php | 42 +- .../RemoveDeadZeroAndOneOperationRector.php | 40 +- .../RemoveUnusedPrivatePropertyRector.php | 18 +- .../Property/RemoveUselessVarTagRector.php | 16 +- ...RemoveNullPropertyInitializationRector.php | 28 +- .../RemoveDeadConditionAboveReturnRector.php | 22 +- .../RemoveParentCallWithoutParentRector.php | 44 +- .../Stmt/RemoveUnreachableStatementRector.php | 38 +- ...RemoveJustPropertyFetchForAssignRector.php | 28 +- .../RemoveJustPropertyFetchRector.php | 62 +- .../RemoveDuplicatedCaseInSwitchRector.php | 22 +- ...naryToBooleanOrFalseToBooleanAndRector.php | 18 +- .../TryCatch/RemoveDeadTryCatchRector.php | 20 +- .../SideEffect/PureFunctionDetector.php | 10 +- .../SideEffect/SideEffectNodeDetector.php | 48 +- .../GenericTypeNodeAnalyzer.php | 4 +- .../MixedArrayTypeNodeAnalyzer.php | 6 +- .../UselessIfCondBeforeForeachDetector.php | 32 +- .../BinaryToVersionCompareCondition.php | 2 +- .../PropertyFetchToVariableAssign.php | 6 +- .../VariableAndPropertyFetchAssign.php | 6 +- .../DeadCode/ValueObject/VariableNodeUse.php | 14 +- .../ValueObject/VersionCompareCondition.php | 2 +- .../VariablesToPropertyFetchCollection.php | 2 +- ...ropertyConstructorInjectionManipulator.php | 12 +- .../ClassMethod/AddMethodParentCallRector.php | 42 +- ...nInjectionToConstructorInjectionRector.php | 34 +- .../ContainerConfiguratorCallAnalyzer.php | 12 +- ...ontainerConfiguratorEmptyAssignRemover.php | 12 +- .../ContainerConfiguratorImportsMerger.php | 14 +- .../Closure/UpgradeRectorConfigRector.php | 62 +- .../Rector/Dir/DirConstToFileConstRector.php | 16 +- .../Array_/ShortArrayToLongArrayRector.php | 22 +- .../Closure/DowngradeStaticClosureRector.php | 14 +- .../Closure/DowngradeThisInClosureRector.php | 40 +- .../DowngradeIndirectCallByArrayRector.php | 22 +- ...DowngradeCallableTypeDeclarationRector.php | 18 +- .../LNumber/DowngradeBinaryNotationRector.php | 22 +- .../DowngradeInstanceMethodCallRector.php | 24 +- .../DowngradeClassConstantToStringRector.php | 20 +- .../Foreach_/DowngradeForeachListRector.php | 20 +- .../FuncCall/DowngradeBoolvalRector.php | 54 +- ...aryExpressionArgsToEmptyAndIssetRector.php | 46 +- .../NodeManipulator/ArgManipulator.php | 2 +- .../NodeManipulator/UnpackedArgList.php | 16 +- .../DowngradeArgumentUnpackingRector.php | 82 +-- .../DowngradeArrayFilterUseConstantRector.php | 64 +- ...adeExponentialAssignmentOperatorRector.php | 16 +- .../DowngradeExponentialOperatorRector.php | 14 +- .../Use_/DowngradeUseFunctionRector.php | 30 +- .../NodeFactory/ClassFromAnonymousFactory.php | 4 +- .../DowngradeParentTypeDeclarationRector.php | 24 +- .../DowngradeSelfTypeDeclarationRector.php | 20 +- .../Coalesce/DowngradeNullCoalesceRector.php | 22 +- .../DowngradeStrictTypeDeclarationRector.php | 16 +- ...cessarilyParenthesizedExpressionRector.php | 36 +- .../DowngradeDefineArrayConstantRector.php | 28 +- .../FuncCall/DowngradeDirnameLevelsRector.php | 58 +- ...owngradeSessionStartArrayOptionsRector.php | 36 +- ...ncallableValueCallToCallUserFuncRector.php | 30 +- .../DowngradeScalarTypeDeclarationRector.php | 48 +- ...owngradeThrowableTypeDeclarationRector.php | 18 +- .../GroupUse/SplitGroupedUseImportsRector.php | 18 +- .../DowngradeInstanceofThrowableRector.php | 40 +- .../MethodCall/DowngradeClosureCallRector.php | 36 +- .../DowngradeMethodCallOnCloneRector.php | 32 +- .../New_/DowngradeAnonymousClassRector.php | 20 +- .../Spaceship/DowngradeSpaceshipRector.php | 44 +- .../DowngradeCatchThrowableRector.php | 20 +- .../WrappedInParenthesesAnalyzer.php | 2 +- ...ymmetricArrayDestructuringToListRector.php | 26 +- ...DowngradeClassConstantVisibilityRector.php | 16 +- .../DowngradePhp71JsonConstRector.php | 16 +- .../FuncCall/DowngradeIsIterableRector.php | 20 +- ...adeIterablePseudoTypeDeclarationRector.php | 18 +- ...DowngradeNullableTypeDeclarationRector.php | 24 +- .../DowngradeVoidTypeDeclarationRector.php | 18 +- .../List_/DowngradeKeysInListRector.php | 52 +- .../DowngradeClosureFromCallableRector.php | 30 +- ...radeNegativeStringOffsetToStrlenRector.php | 38 +- ...wngradePipeToMultiCatchExceptionRector.php | 16 +- .../NodeAnalyzer/BuiltInMethodAnalyzer.php | 4 +- .../FunctionExistsFunCallAnalyzer.php | 12 +- ...errideFromAnonymousClassMethodAnalyzer.php | 16 +- .../NodeAnalyzer/RegexFuncAnalyzer.php | 16 +- .../NodeAnalyzer/SealedClassAnalyzer.php | 2 +- .../NodeManipulator/BitwiseFlagCleaner.php | 28 +- .../NodeManipulator/JsonConstCleaner.php | 26 +- .../PhpDoc/NativeParamToPhpDocDecorator.php | 8 +- .../DowngradeParameterTypeWideningRector.php | 38 +- .../DowngradePhp72JsonConstRector.php | 16 +- ...radeJsonDecodeNullAssociativeArgRector.php | 26 +- ...gradePregUnmatchedAsNullConstantRector.php | 82 +-- .../FuncCall/DowngradeStreamIsattyRector.php | 30 +- .../DowngradeObjectTypeDeclarationRector.php | 18 +- .../DowngradePhp73JsonConstRector.php | 16 +- .../DowngradeArrayKeyFirstLastRector.php | 42 +- .../FuncCall/DowngradeIsCountableRector.php | 20 +- ...adeTrailingCommasInFunctionCallsRector.php | 20 +- ...SetCookieOptionsArrayToArgumentsRector.php | 32 +- ...DowngradeListReferenceAssignmentRector.php | 64 +- .../DowngradeFlexibleHeredocSyntaxRector.php | 24 +- .../Tokenizer/FollowedByCommaAnalyzer.php | 4 +- .../Array_/DowngradeArraySpreadRector.php | 20 +- ...ArrowFunctionToAnonymousFunctionRector.php | 18 +- ...wngradeContravariantArgumentTypeRector.php | 38 +- .../DowngradeCovariantReturnTypeRector.php | 56 +- .../DowngradeNullCoalescingOperatorRector.php | 16 +- ...deArrayMergeCallWithoutArgumentsRector.php | 18 +- .../DowngradeStripTagsCallWithArrayRector.php | 58 +- ...ngradeFreadFwriteFalsyToNegationRector.php | 28 +- ...dePreviouslyImplementedInterfaceRector.php | 18 +- ...DowngradeNumericLiteralSeparatorRector.php | 24 +- .../DowngradeReflectionGetTypeRector.php | 28 +- .../Property/DowngradeTypedPropertyRector.php | 18 +- .../NodeAnalyzer/EnumAnalyzer.php | 32 +- .../NodeAnalyzer/NamedToUnnamedArgs.php | 14 +- .../NodeAnalyzer/UnnamedArgumentResolver.php | 10 +- ...owngradeDereferenceableOperationRector.php | 26 +- .../DowngradeNonCapturingCatchesRector.php | 18 +- ...DowngradeClassOnObjectToGetClassRector.php | 18 +- ...radeAbstractPrivateMethodInTraitRector.php | 22 +- ...siveDirectoryIteratorHasChildrenRector.php | 20 +- .../DowngradeStaticTypeDeclarationRector.php | 20 +- ...ngradeStringReturnTypeOnToStringRector.php | 26 +- ...owngradeTrailingCommasInParamUseRector.php | 32 +- .../DowngradeAttributeToAnnotationRector.php | 26 +- .../DowngradePropertyPromotionRector.php | 62 +- ...DowngradeEnumToConstantListClassRector.php | 30 +- .../DowngradeMatchToSwitchRector.php | 98 +-- .../Expression/DowngradeThrowExprRector.php | 88 +-- ...gradeArrayFilterNullableCallbackRector.php | 50 +- ...DowngradeNumberFormatNoFourthArgRector.php | 22 +- .../FuncCall/DowngradeStrContainsRector.php | 30 +- .../FuncCall/DowngradeStrEndsWithRector.php | 34 +- .../FuncCall/DowngradeStrStartsWithRector.php | 38 +- .../DowngradeMixedTypeDeclarationRector.php | 18 +- .../DowngradeUnionTypeDeclarationRector.php | 20 +- ...gradePhp80ResourceReturnToObjectRector.php | 16 +- .../DowngradeNamedArgumentRector.php | 22 +- ...eflectionClassGetConstantsFilterRector.php | 74 +-- ...DowngradeReflectionGetAttributesRector.php | 24 +- ...eflectionPropertyGetDefaultValueRector.php | 26 +- ...gradeArbitraryExpressionsSupportRector.php | 32 +- ...wngradeNullsafeToTernaryOperatorRector.php | 24 +- .../DowngradeUnionTypeTypedPropertyRector.php | 20 +- .../StaticCall/DowngradePhpTokenRector.php | 46 +- .../DefaultParameterValueResolver.php | 30 +- .../SimplePhpParameterReflection.php | 18 +- .../NodeAnalyzer/ArraySpreadAnalyzer.php | 4 +- .../ArrayMergeFromArraySpreadFactory.php | 58 +- .../ObjectToResourceReturn.php | 22 +- .../DowngradeArraySpreadStringKeyRector.php | 24 +- ...gradeFinalizePublicClassConstantRector.php | 16 +- .../FuncCall/DowngradeArrayIsListRector.php | 32 +- ...owngradeFirstClassCallableSyntaxRector.php | 36 +- .../DowngradeNeverTypeDeclarationRector.php | 18 +- .../DowngradeNewInInitializerRector.php | 56 +- .../DowngradePureIntersectionTypeRector.php | 20 +- ...gradePhp81ResourceReturnToObjectRector.php | 16 +- .../DowngradeReadonlyPropertyRector.php | 22 +- .../Class_/DowngradeReadonlyClassRector.php | 24 +- .../NodeFactory/InvertedIfFactory.php | 26 +- .../NodeTransformer/ConditionInverter.php | 18 +- ...eNestedForeachIfsToEarlyContinueRector.php | 52 +- .../ReturnAfterToEarlyOnBreakRector.php | 50 +- .../If_/ChangeAndIfToEarlyReturnRector.php | 80 +-- ...geIfElseValueAssignToEarlyReturnRector.php | 28 +- .../ChangeNestedIfsToEarlyReturnRector.php | 30 +- ...hangeOrIfContinueToMultiContinueRector.php | 30 +- .../ChangeOrIfReturnToEarlyReturnRector.php | 42 +- .../Rector/If_/RemoveAlwaysElseRector.php | 22 +- .../PreparedValueToEarlyReturnRector.php | 54 +- .../ReturnBinaryAndToEarlyReturnRector.php | 34 +- .../ReturnBinaryOrToEarlyReturnRector.php | 38 +- .../Assign/MysqlAssignToMysqliRector.php | 72 +- .../FuncCall/MysqlFuncCallToMysqliRector.php | 46 +- .../MysqlPConnectToMysqliConnectRector.php | 26 +- .../MysqlQueryMysqlErrorWithLinkRector.php | 54 +- .../NewAssignVariableNameResolver.php | 12 +- ...ropertyFetchAssignVariableNameResolver.php | 14 +- .../AssignVariableNameResolverInterface.php | 4 +- .../Guard/ConflictingNameGuardInterface.php | 2 +- .../RenameParamValueObjectInterface.php | 2 +- .../RenamePropertyValueObjectInterface.php | 6 +- .../InflectorSingularResolver.php | 16 +- .../MatchParamTypeExpectedNameResolver.php | 6 +- .../MatchPropertyTypeExpectedNameResolver.php | 12 +- .../Guard/BreakingVariableRenameGuard.php | 44 +- .../Guard/DateTimeAtNamingConventionGuard.php | 14 +- rules/Naming/Guard/HasMagicGetSetGuard.php | 6 +- .../Naming/Guard/NotPrivatePropertyGuard.php | 4 +- .../MatchPropertyTypeConflictingNameGuard.php | 6 +- .../Naming/Guard/RamseyUuidInterfaceGuard.php | 8 +- rules/Naming/Matcher/CallMatcher.php | 8 +- rules/Naming/Matcher/ForeachMatcher.php | 12 +- .../Matcher/VariableAndCallAssignMatcher.php | 14 +- rules/Naming/NamespaceMatcher.php | 4 +- rules/Naming/Naming/AliasNameResolver.php | 6 +- .../Naming/Naming/ConflictingNameResolver.php | 6 +- rules/Naming/Naming/ExpectedNameResolver.php | 52 +- .../Naming/OverridenExistingNamesResolver.php | 8 +- rules/Naming/Naming/PropertyNaming.php | 62 +- rules/Naming/Naming/UseImportsResolver.php | 22 +- rules/Naming/Naming/VariableNaming.php | 46 +- .../NamingConventionAnalyzer.php | 4 +- rules/Naming/ParamRenamer/ParamRenamer.php | 4 +- .../Naming/PhpDoc/VarTagValueNodeRenamer.php | 6 +- .../MatchTypePropertyRenamer.php | 4 +- .../PropertyRenamer/PropertyFetchRenamer.php | 8 +- .../PropertyPromotionRenamer.php | 20 +- .../PropertyRenamer/PropertyRenamer.php | 8 +- ...iableToMatchMethodCallReturnTypeRector.php | 38 +- .../RenameParamToMatchTypeRector.php | 24 +- .../RenameVariableToMatchNewTypeRector.php | 26 +- .../RenamePropertyToMatchTypeRector.php | 22 +- ...ValueVariableToMatchExprVariableRector.php | 40 +- ...iableToMatchMethodCallReturnTypeRector.php | 22 +- rules/Naming/RectorNamingInflector.php | 4 +- .../RenameGuard/PropertyRenameGuard.php | 2 +- rules/Naming/ValueObject/ParamRename.php | 8 +- rules/Naming/ValueObject/PropertyRename.php | 10 +- .../ValueObject/VariableAndCallAssign.php | 6 +- .../ValueObject/VariableAndCallForeach.php | 4 +- .../ValueObjectFactory/ParamRenameFactory.php | 12 +- .../PropertyRenameFactory.php | 10 +- rules/Naming/VariableRenamer.php | 24 +- .../Composer/PSR4AutoloadPathsProvider.php | 4 +- rules/PSR4/Composer/PSR4NamespaceMatcher.php | 12 +- .../PSR4AutoloadNamespaceMatcherInterface.php | 2 +- .../FileInfoDeletionAnalyzer.php | 6 +- .../FullyQualifyStmtsAnalyzer.php | 22 +- .../NodeManipulator/NamespaceManipulator.php | 4 +- ...eNamespaceByPSR4ComposerAutoloadRector.php | 38 +- .../MultipleClassFileToPsr4ClassesRector.php | 36 +- .../Property/VarToPublicPropertyRector.php | 18 +- .../Switch_/ContinueToBreakInSwitchRector.php | 36 +- ...DirNameFileConstantToDirConstantRector.php | 22 +- .../Rector/Ternary/TernaryToElvisRector.php | 18 +- .../ReplaceHttpServerVarsByServerRector.php | 16 +- .../Break_/RemoveZeroBreakContinueRector.php | 28 +- .../RemoveReferenceFromCallRector.php | 18 +- .../Class_/ClassConstantToSelfClassRector.php | 16 +- .../GetCalledClassToSelfClassRector.php | 26 +- .../GetCalledClassToStaticClassRector.php | 26 +- .../FuncCall/PregReplaceEModifierRector.php | 24 +- .../StringClassNameToClassConstantRector.php | 40 +- rules/Php55/RegexMatcher.php | 24 +- .../UndefinedVariableResolver.php | 76 +-- .../Php56/Rector/FuncCall/PowToExpRector.php | 20 +- ...DefaultValueForUndefinedVariableRector.php | 28 +- rules/Php70/EregToPcreTransformer.php | 42 +- .../Php70/Exception/InvalidEregException.php | 2 +- .../Php4ConstructorClassMethodAnalyzer.php | 4 +- .../Rector/Assign/ListSplitStringRector.php | 20 +- .../Assign/ListSwapArrayOrderRector.php | 28 +- .../BreakNotInLoopOrSwitchToReturnRector.php | 20 +- .../ClassMethod/Php4ConstructorRector.php | 58 +- .../Rector/FuncCall/CallUserMethodRector.php | 18 +- .../Rector/FuncCall/EregToPregMatchRector.php | 56 +- .../Rector/FuncCall/MultiDirnameRector.php | 24 +- ...VariableToVariableOnFunctionCallRector.php | 54 +- .../Rector/FuncCall/RandomFunctionRector.php | 22 +- .../RenameMktimeWithoutArgsToTimeRector.php | 18 +- .../ExceptionHandlerTypehintRector.php | 26 +- .../Php70/Rector/If_/IfToSpaceshipRector.php | 58 +- rules/Php70/Rector/List_/EmptyListRector.php | 18 +- ...isCallOnStaticMethodToStaticCallRector.php | 44 +- ...ticCallOnNonStaticToInstanceCallRector.php | 42 +- .../ReduceMultipleDefaultSwitchRector.php | 22 +- .../Ternary/TernaryToNullCoalescingRector.php | 34 +- .../Ternary/TernaryToSpaceshipRector.php | 40 +- ...ariableVariableNameInCurlyBracesRector.php | 24 +- .../Php70/ValueObject/VariableAssignPair.php | 2 +- rules/Php71/IsArrayAndDualCheckToAble.php | 18 +- .../Php71/NodeAnalyzer/CountableAnalyzer.php | 34 +- .../Assign/AssignArrayToStringRector.php | 42 +- .../BinaryOpBetweenNumberAndStringRector.php | 36 +- .../Rector/BooleanOr/IsIterableRector.php | 22 +- .../PublicConstantVisibilityRector.php | 18 +- .../Rector/FuncCall/CountOnNullRector.php | 64 +- .../FuncCall/RemoveExtraParametersRector.php | 28 +- .../List_/ListToArrayDestructRector.php | 26 +- .../Rector/Name/ReservedObjectRector.php | 32 +- .../TryCatch/MultiExceptionCatchRector.php | 20 +- rules/Php71/ValueObject/TwoNodeMatch.php | 6 +- .../NodeFactory/AnonymousFunctionFactory.php | 116 ++-- rules/Php72/Rector/Assign/ListEachRector.php | 44 +- ...laceEachAssignmentWithKeyCurrentRector.php | 42 +- ...reateFunctionToAnonymousFunctionRector.php | 34 +- .../Rector/FuncCall/GetClassOnNullRector.php | 54 +- .../IsObjectOnIncompleteClassRector.php | 28 +- .../ParseStrWithResultArgumentRector.php | 28 +- .../Rector/FuncCall/StringifyDefineRector.php | 24 +- .../FuncCall/StringsAssertNakedRector.php | 26 +- rules/Php72/Rector/Unset_/UnsetCastRector.php | 24 +- .../While_/WhileEachToForeachRector.php | 26 +- .../NodeTypeAnalyzer/NodeTypeAnalyzer.php | 8 +- .../Rector/BooleanOr/IsCountableRector.php | 20 +- .../SensitiveConstantNameRector.php | 24 +- .../FuncCall/ArrayKeyFirstLastRector.php | 42 +- .../FuncCall/JsonThrowOnErrorRector.php | 44 +- .../Rector/FuncCall/RegexDashEscapeRector.php | 34 +- .../Rector/FuncCall/SensitiveDefineRector.php | 16 +- .../Php73/Rector/FuncCall/SetCookieRector.php | 32 +- .../FuncCall/StringifyStrNeedlesRector.php | 28 +- .../String_/SensitiveHereNowDocRector.php | 22 +- rules/Php74/Guard/MakePropertyTypedGuard.php | 8 +- .../ClosureArrowFunctionAnalyzer.php | 20 +- .../CurlyToSquareBracketArrayStringRector.php | 20 +- .../Assign/NullCoalescingOperatorRector.php | 20 +- .../Closure/ClosureToArrowFunctionRector.php | 26 +- .../Double/RealToFloatTypeCastRector.php | 24 +- .../ArrayKeyExistsOnPropertyRector.php | 22 +- .../ArraySpreadInsteadOfArrayMergeRector.php | 56 +- .../FuncCall/FilterVarToAddSlashesRector.php | 20 +- ...bStrrposEncodingArgumentPositionRector.php | 22 +- .../AddLiteralSeparatorToNumberRector.php | 28 +- ...eReflectionTypeToStringToGetNameRector.php | 68 +- ...efaultNullToNullableTypePropertyRector.php | 24 +- .../Rector/Property/TypedPropertyRector.php | 42 +- .../ExportToReflectionFunctionRector.php | 26 +- .../FollowedByCurlyBracketAnalyzer.php | 2 +- .../Php74/TypeAnalyzer/ObjectTypeAnalyzer.php | 8 +- .../StrStartWithMatchAndRefactorInterface.php | 4 +- .../StrncmpMatchAndRefactor.php | 24 +- .../StrposMatchAndRefactor.php | 24 +- .../SubstrMatchAndRefactor.php | 28 +- .../NodeAnalyzer/AnnotationTargetResolver.php | 2 +- .../Php80/NodeAnalyzer/EnumParamAnalyzer.php | 28 +- .../NodeAnalyzer/MatchSwitchAnalyzer.php | 32 +- .../NodeAnalyzer/PhpAttributeAnalyzer.php | 6 +- .../PromotedPropertyCandidateResolver.php | 50 +- .../NodeAnalyzer/PromotedPropertyResolver.php | 6 +- rules/Php80/NodeAnalyzer/SwitchAnalyzer.php | 28 +- rules/Php80/NodeFactory/AttrGroupsFactory.php | 2 +- .../NodeFactory/AttributeFlagFactory.php | 4 +- rules/Php80/NodeFactory/MatchArmsFactory.php | 4 +- rules/Php80/NodeFactory/MatchFactory.php | 4 +- .../StrStartsWithFuncCallFactory.php | 8 +- ...AttributeGroupNamedArgumentManipulator.php | 6 +- .../ResourceReturnToObject.php | 48 +- .../NodeManipulator/TokenManipulator.php | 98 +-- .../RequireOptionalParamResolver.php | 2 +- .../NodeResolver/SwitchExprsResolver.php | 38 +- rules/Php80/PhpDoc/PhpDocNodeFinder.php | 6 +- .../RemoveUnusedVariableInCatchRector.php | 28 +- ...AddParamBasedOnParentClassMethodRector.php | 46 +- .../FinalPrivateToPrivateVisibilityRector.php | 22 +- .../ClassMethod/SetStateToStaticRector.php | 22 +- .../Class_/AnnotationToAttributeRector.php | 54 +- ...ertyAssignToConstructorPromotionRector.php | 40 +- ...ctrineAnnotationClassToAttributeRector.php | 38 +- .../Class_/StringableForToStringRector.php | 46 +- .../Rector/FuncCall/ClassOnObjectRector.php | 22 +- .../Php8ResourceReturnToObjectRector.php | 18 +- .../FuncCall/TokenGetAllToObjectRector.php | 48 +- .../Rector/FunctionLike/UnionTypesRector.php | 60 +- .../Rector/Identical/StrEndsWithRector.php | 54 +- .../Rector/Identical/StrStartsWithRector.php | 18 +- .../Rector/NotIdentical/StrContainsRector.php | 30 +- .../Switch_/ChangeSwitchToMatchRector.php | 72 +- .../Rector/Ternary/GetDebugTypeRector.php | 34 +- .../ArrayDimFetchAndConstFetch.php | 6 +- rules/Php80/ValueObject/CondAndExpr.php | 4 +- .../DoctrineTagAndAnnotationToAttribute.php | 4 +- .../PropertyPromotionCandidate.php | 8 +- rules/Php80/ValueObject/StrStartsWith.php | 8 +- .../StrStartsWithFactory.php | 6 +- .../Php81/NodeAnalyzer/ComplexNewAnalyzer.php | 18 +- .../EnumConstListClassDetector.php | 6 +- .../NodeFactory/ClassFromEnumFactory.php | 16 +- rules/Php81/NodeFactory/EnumFactory.php | 26 +- .../FinalizePublicClassConstantRector.php | 24 +- .../ClassMethod/NewInInitializerRector.php | 52 +- .../Class_/ConstantListClassToEnumRector.php | 52 +- .../Class_/MyCLabsClassToEnumRector.php | 20 +- .../Class_/SpatieEnumClassToEnumRector.php | 20 +- .../NullToStrictStringFuncCallArgRector.php | 66 +- .../Php81ResourceReturnToObjectRector.php | 18 +- .../FunctionLike/IntersectionTypesRector.php | 30 +- .../MyCLabsMethodCallToEnumConstRector.php | 20 +- .../Property/ReadOnlyPropertyRector.php | 32 +- .../Rector/Class_/ReadOnlyClassRector.php | 34 +- .../Guard/ParentPropertyLookupGuard.php | 22 +- rules/Privatization/Naming/ConstantNaming.php | 6 +- .../PropertyFetchByMethodAnalyzer.php | 50 +- .../NodeFactory/ClassConstantFactory.php | 12 +- .../ClassConstantFetchValueFactory.php | 4 +- .../NodeManipulator/VisibilityManipulator.php | 40 +- .../PropertyFetchWithConstFetchReplacer.php | 6 +- .../PropertyFetchWithVariableReplacer.php | 12 +- .../PrivatizeFinalClassMethodRector.php | 20 +- ...hangeGlobalVariablesToPropertiesRector.php | 42 +- .../ChangeLocalPropertyToVariableRector.php | 16 +- ...riableWithDefaultValueToConstantRector.php | 56 +- .../FinalizeClassesWithoutChildrenRector.php | 24 +- .../RepeatedLiteralToClassConstantRector.php | 44 +- .../PrivatizeLocalGetterToPropertyRector.php | 28 +- .../ReplaceStringWithClassConstantRector.php | 30 +- ...opertyWithDefaultValueToConstantRector.php | 30 +- .../PrivatizeFinalClassPropertyRector.php | 22 +- .../Reflection/ClassConstantsResolver.php | 2 +- .../NormalizeTypeToRespectArrayScalarType.php | 30 +- .../TypeManipulator/TypeNormalizer.php | 8 +- .../ReplaceStringWithClassConstant.php | 6 +- .../ClassMethodVisibilityGuard.php | 8 +- .../NodeManipulator/ComplexNodeRemover.php | 38 +- .../ClassMethod/ArgumentRemoverRector.php | 28 +- .../Rector/Class_/RemoveInterfacesRector.php | 16 +- .../Rector/Class_/RemoveParentRector.php | 22 +- .../Rector/Class_/RemoveTraitUseRector.php | 18 +- .../FuncCall/RemoveFuncCallArgRector.php | 20 +- .../Rector/FuncCall/RemoveFuncCallRector.php | 28 +- .../Removing/ValueObject/ArgumentRemover.php | 6 +- ...llyCalledStaticMethodToNonStaticRector.php | 48 +- .../Contract/MethodCallRenameInterface.php | 2 +- .../RenameClassConstFetchInterface.php | 2 +- .../Renaming/NodeManipulator/ClassRenamer.php | 116 ++-- .../NodeManipulator/SwitchManipulator.php | 6 +- .../RenameClassConstFetchRector.php | 26 +- .../ClassMethod/RenameAnnotationRector.php | 26 +- .../ConstFetch/RenameConstantRector.php | 20 +- .../PseudoNamespaceToNamespaceRector.php | 56 +- .../Rector/FuncCall/RenameFunctionRector.php | 26 +- .../Rector/MethodCall/RenameMethodRector.php | 44 +- .../Rector/Name/RenameClassRector.php | 30 +- .../Namespace_/RenameNamespaceRector.php | 54 +- .../PropertyFetch/RenamePropertyRector.php | 40 +- .../StaticCall/RenameStaticMethodRector.php | 22 +- .../Rector/String_/RenameStringRector.php | 20 +- .../Renaming/ValueObject/MethodCallRename.php | 8 +- .../MethodCallRenameWithArrayKey.php | 8 +- .../Renaming/ValueObject/RenameAnnotation.php | 2 +- .../ValueObject/RenameAnnotationByType.php | 8 +- .../ValueObject/RenameClassAndConstFetch.php | 6 +- .../ValueObject/RenameClassConstFetch.php | 6 +- rules/Renaming/ValueObject/RenameProperty.php | 6 +- .../ValueObject/RenameStaticMethod.php | 4 +- ...ngClassConstantReferenceToStringRector.php | 18 +- ...ateFileNameByClassNameFileSystemRector.php | 16 +- .../Class_/RemoveFinalFromEntityRector.php | 16 +- ...mpleteImportForPartialAnnotationRector.php | 36 +- ...keTypedPropertyNullableIfCheckedRector.php | 48 +- .../NodeFactory/ExactCompareFactory.php | 98 +-- .../AbstractFalsyScalarRuleFixerRector.php | 4 +- .../BooleanInBooleanNotRuleFixerRector.php | 20 +- .../Empty_/DisallowedEmptyRuleFixerRector.php | 30 +- .../BooleanInIfConditionRuleFixerRector.php | 22 +- ...ooleanInTernaryOperatorRuleFixerRector.php | 22 +- .../DisallowedShortTernaryRuleFixerRector.php | 28 +- ...FuncCallStaticCallToMethodCallAnalyzer.php | 10 +- .../SingletonClassMethodAnalyzer.php | 30 +- .../NodeFactory/PropertyFetchFactory.php | 8 +- .../NodeFactory/UnwrapClosureFactory.php | 10 +- .../TypeProvidingExprFromClassResolver.php | 36 +- .../DimFetchAssignToMethodCallRector.php | 30 +- .../Assign/GetAndSetToMethodCallRector.php | 38 +- .../PropertyAssignToMethodCallRector.php | 20 +- .../PropertyFetchToMethodCallRector.php | 34 +- .../AttributeKeyToClassConstFetchRector.php | 20 +- .../ReturnTypeWillChangeRector.php | 30 +- .../Rector/ClassMethod/WrapReturnRector.php | 26 +- ...dAllowDynamicPropertiesAttributeRector.php | 36 +- .../Class_/AddInterfaceByTraitRector.php | 24 +- .../Class_/ChangeSingletonToServiceRector.php | 30 +- .../Rector/Class_/MergeInterfacesRector.php | 22 +- .../Class_/ParentClassToTraitsRector.php | 24 +- ...eAllowDynamicPropertiesAttributeRector.php | 22 +- .../ArgumentFuncCallToMethodCallRector.php | 66 +- .../FuncCall/FuncCallToConstFetchRector.php | 20 +- .../FuncCall/FuncCallToMethodCallRector.php | 28 +- .../Rector/FuncCall/FuncCallToNewRector.php | 18 +- .../FuncCall/FuncCallToStaticCallRector.php | 16 +- ...ontentsAndJsonDecodeToStaticCallRector.php | 42 +- .../UnsetAndIssetToMethodCallRector.php | 26 +- .../CallableInMethodCallToVariableRector.php | 26 +- ...ToAnotherMethodCallWithArgumentsRector.php | 20 +- .../MethodCallToMethodCallRector.php | 42 +- .../MethodCallToPropertyFetchRector.php | 16 +- .../MethodCallToStaticCallRector.php | 18 +- .../ReplaceParentCallByPropertyCallRector.php | 18 +- ...viceGetterToConstructorInjectionRector.php | 30 +- .../Rector/New_/NewArgToMethodCallRector.php | 22 +- .../New_/NewToConstructorInjectionRector.php | 48 +- .../Rector/New_/NewToMethodCallRector.php | 30 +- .../Rector/New_/NewToStaticCallRector.php | 18 +- .../StaticCall/StaticCallToFuncCallRector.php | 18 +- .../StaticCallToMethodCallRector.php | 38 +- .../StaticCall/StaticCallToNewRector.php | 20 +- .../String_/StringToClassConstantRector.php | 18 +- .../String_/ToStringToMethodCallRector.php | 30 +- .../ArgumentFuncCallToMethodCall.php | 4 +- .../ValueObject/ArrayFuncCallToMethodCall.php | 4 +- .../CallableInMethodCallToVariable.php | 4 +- .../DimFetchAssignToMethodCall.php | 8 +- .../ValueObject/FuncCallToMethodCall.php | 4 +- .../ValueObject/GetAndSetToMethodCall.php | 4 +- ...odCallToAnotherMethodCallWithArguments.php | 6 +- .../ValueObject/MethodCallToMethodCall.php | 4 +- .../ValueObject/MethodCallToPropertyFetch.php | 6 +- .../ValueObject/MethodCallToStaticCall.php | 4 +- .../ValueObject/NewArgToMethodCall.php | 6 +- .../Transform/ValueObject/NewToMethodCall.php | 8 +- .../Transform/ValueObject/NewToStaticCall.php | 8 +- .../PropertyAssignToMethodCall.php | 6 +- .../ValueObject/PropertyFetchToMethodCall.php | 6 +- .../ReplaceParentCallByPropertyCall.php | 6 +- .../ServiceGetterToConstructorInjection.php | 8 +- .../ValueObject/StaticCallToFuncCall.php | 6 +- .../ValueObject/StaticCallToMethodCall.php | 10 +- .../Transform/ValueObject/StaticCallToNew.php | 2 +- .../ValueObject/StringToClassConstant.php | 2 +- .../ValueObject/UnsetAndIssetToMethodCall.php | 6 +- rules/Transform/ValueObject/WrapReturn.php | 6 +- .../ConstructorAssignDetector.php | 32 +- .../NullTypeAssignDetector.php | 16 +- .../PropertyDefaultAssignDetector.php | 4 +- .../TypeWithClassTypeSpecifierInterface.php | 4 +- .../TypeInferer/ParamTypeInfererInterface.php | 2 +- .../ReturnTypeInfererInterface.php | 4 +- .../ConflictingPriorityException.php | 4 +- .../FunctionLikeReturnTypeResolver.php | 6 +- .../Guard/PhpDocNestedAnnotationGuard.php | 10 +- .../Guard/PropertyTypeOverrideGuard.php | 6 +- .../Helper/PhpDocNullableTypeHelper.php | 48 +- .../Matcher/PropertyAssignMatcher.php | 6 +- ...AutowiredClassMethodOrPropertyAnalyzer.php | 4 +- .../NodeAnalyzer/CallTypesResolver.php | 28 +- .../NodeAnalyzer/CallerParamMatcher.php | 22 +- .../ClassMethodAndPropertyAnalyzer.php | 8 +- .../ClassMethodParamTypeCompleter.php | 42 +- .../ControllerRenderMethodAnalyzer.php | 12 +- .../NodeAnalyzer/ReturnStrictTypeAnalyzer.php | 12 +- .../NodeAnalyzer/TypeNodeUnwrapper.php | 8 +- .../NodeTypeAnalyzer/CallTypeAnalyzer.php | 4 +- .../NodeTypeAnalyzer/DetailedTypeAnalyzer.php | 10 +- .../PropertyTypeDecorator.php | 12 +- .../NodeTypeAnalyzer/TraitTypeAnalyzer.php | 6 +- .../PHPStan/ObjectTypeSpecifier.php | 56 +- .../SameNamespacedTypeSpecifier.php | 10 +- .../SelfStaticParentTypeSpecifier.php | 28 +- .../NonInformativeReturnTagRemover.php | 56 +- .../PhpDocParser/ParamPhpDocNodeFactory.php | 6 +- .../TypeDeclaration/PhpParserTypeAnalyzer.php | 10 +- .../AddArrayParamDocTypeRector.php | 34 +- .../AddArrayReturnDocTypeRector.php | 54 +- ...ddMethodCallBasedStrictParamTypeRector.php | 16 +- .../AddParamTypeDeclarationRector.php | 44 +- .../AddReturnTypeDeclarationRector.php | 28 +- .../AddVoidReturnTypeWhereNoReturnRector.php | 34 +- ...rrayShapeFromConstantArrayReturnRector.php | 44 +- ...ParamAnnotationIncorrectNullableRector.php | 30 +- .../ParamTypeByMethodCallTypeRector.php | 40 +- .../ParamTypeByParentCallTypeRector.php | 34 +- ...eturnAnnotationIncorrectNullableRector.php | 24 +- .../ClassMethod/ReturnNeverTypeRector.php | 40 +- .../ReturnTypeFromReturnNewRector.php | 48 +- .../ReturnTypeFromStrictTypedCallRector.php | 66 +- ...eturnTypeFromStrictTypedPropertyRector.php | 34 +- .../Closure/AddClosureReturnTypeRector.php | 20 +- .../ParamTypeDeclarationRector.php | 44 +- .../ReturnTypeDeclarationRector.php | 58 +- ...merNullableArgumentToScalarTypedRector.php | 34 +- ...ParamTypeFromStrictTypedPropertyRector.php | 58 +- .../AddPropertyTypeDeclarationRector.php | 28 +- .../PropertyTypeDeclarationRector.php | 34 +- .../TypedPropertyFromAssignsRector.php | 34 +- ...pedPropertyFromStrictConstructorRector.php | 32 +- ...FromStrictGetterMethodReturnTypeRector.php | 38 +- .../VarAnnotationIncorrectNullableRector.php | 26 +- .../Sorter/PriorityAwareSorter.php | 4 +- .../ReturnTypeAlreadyAddedChecker.php | 38 +- .../TypeAnalyzer/AdvancedArrayAnalyzer.php | 34 +- .../GenericClassStringTypeNormalizer.php | 46 +- .../TypeAnalyzer/IterableTypeAnalyzer.php | 16 +- .../TypeAnalyzer/ObjectTypeComparator.php | 18 +- .../AssignToPropertyTypeInferer.php | 24 +- .../TypeInferer/ParamTypeInferer.php | 12 +- .../FunctionLikeDocParamTypeInferer.php | 20 +- .../GetterNodeParamTypeInferer.php | 30 +- .../KnownArrayParamTypeInferer.php | 18 +- .../PHPUnitDataProviderParamTypeInferer.php | 70 +- .../PropertyNodeParamTypeInferer.php | 24 +- .../SplFixedArrayParamTypeInferer.php | 8 +- .../AllAssignNodePropertyTypeInferer.php | 8 +- .../ConstructorPropertyTypeInferer.php | 64 +- .../DefaultValuePropertyTypeInferer.php | 6 +- ...tterTypeDeclarationPropertyTypeInferer.php | 14 +- .../TypeInferer/ReturnTypeInferer.php | 96 +-- .../ReturnTagReturnTypeInfererTypeInferer.php | 6 +- ...eclarationReturnTypeInfererTypeInferer.php | 10 +- ...urnedNodesReturnTypeInfererTypeInferer.php | 72 +- ...SetterNodeReturnTypeInfererTypeInferer.php | 24 +- ...YieldNodesReturnTypeInfererTypeInferer.php | 34 +- .../TypeInferer/SilentVoidResolver.php | 34 +- .../TypeInferer/SplArrayFixedTypeNarrower.php | 14 +- .../TypeInferer/VarDocPropertyTypeInferer.php | 58 +- rules/TypeDeclaration/TypeNormalizer.php | 68 +- .../ValueObject/AddParamTypeDeclaration.php | 10 +- .../AddPropertyTypeDeclaration.php | 6 +- .../ValueObject/AddReturnTypeDeclaration.php | 10 +- .../ValueObject/NestedArrayType.php | 10 +- .../ChangeConstantVisibilityRector.php | 20 +- .../ChangeMethodVisibilityRector.php | 20 +- .../ExplicitPublicClassMethodRector.php | 18 +- .../ValueObject/ChangeConstantVisibility.php | 6 +- .../ValueObject/ChangeMethodVisibility.php | 2 +- src/Application/ApplicationFileProcessor.php | 28 +- src/Application/ChangedNodeScopeRefresher.php | 30 +- .../FileDecorator/FileDiffFileDecorator.php | 4 +- src/Application/FileProcessor.php | 6 +- .../FileProcessor/PhpFileProcessor.php | 36 +- .../RemovedAndAddedFilesCollector.php | 20 +- .../RemovedAndAddedFilesProcessor.php | 12 +- src/Application/VersionResolver.php | 14 +- src/Autoloading/AdditionalAutoloader.php | 10 +- src/Autoloading/BootstrapFilesIncluder.php | 16 +- src/Bootstrap/ExtensionConfigResolver.php | 8 +- src/Bootstrap/RectorConfigsResolver.php | 16 +- .../ConfigureCallMergingLoaderFactory.php | 12 +- src/Configuration/ConfigurationFactory.php | 16 +- src/Configuration/CurrentNodeProvider.php | 4 +- src/Configuration/Option.php | 4 +- src/Configuration/RectorConfigProvider.php | 2 +- .../RenamedClassesDataCollector.php | 4 +- src/Configuration/ValueObjectInliner.php | 10 +- .../Command/AbstractProcessCommand.php | 26 +- src/Console/Command/InitCommand.php | 14 +- src/Console/Command/ProcessCommand.php | 32 +- src/Console/Command/WorkerCommand.php | 16 +- src/Console/ConsoleApplication.php | 28 +- .../Output/OutputFormatterCollector.php | 4 +- src/Console/Output/RectorOutputStyle.php | 4 +- .../Style/RectorConsoleOutputStyle.php | 14 +- .../Style/RectorConsoleOutputStyleFactory.php | 10 +- .../TypeToCallReflectionResolverInterface.php | 4 +- .../PhpParser/Node/StmtsAwareInterface.php | 2 +- .../Processor/FileProcessorInterface.php | 4 +- .../Rector/ConfigurableRectorInterface.php | 4 +- src/Contract/Rector/PhpRectorInterface.php | 4 +- src/Contract/Rector/RectorInterface.php | 4 +- .../Rector/ScopeAwarePhpRectorInterface.php | 2 +- .../ConfigureCallValuesCollector.php | 8 +- .../MakeRectorsPublicCompilerPass.php | 6 +- ...dRectorConfigureCallValuesCompilerPass.php | 8 +- .../RemoveSkippedRectorsCompilerPass.php | 10 +- ...rableCallValuesCollectingPhpFileLoader.php | 6 +- .../RectorServiceConfigurator.php | 12 +- .../RectorContainerFactory.php | 14 +- src/Differ/DefaultDiffer.php | 4 +- src/Error/ExceptionCorrector.php | 6 +- src/Exception/Cache/CachingException.php | 2 +- .../InvalidConfigurationException.php | 2 +- src/Exception/NotImplementedYetException.php | 2 +- src/Exception/ShouldNotHappenException.php | 4 +- src/Exception/VersionException.php | 2 +- src/Exclusion/ExclusionManager.php | 28 +- src/FileSystem/FilesFinder.php | 16 +- src/FileSystem/PhpFilesFinder.php | 8 +- src/Kernel/RectorKernel.php | 22 +- src/Logging/CurrentRectorProvider.php | 4 +- src/NodeAnalyzer/ArgsAnalyzer.php | 8 +- src/NodeAnalyzer/CallAnalyzer.php | 22 +- src/NodeAnalyzer/ClassAnalyzer.php | 12 +- src/NodeAnalyzer/CoalesceAnalyzer.php | 4 +- src/NodeAnalyzer/CompactFuncCallAnalyzer.php | 10 +- src/NodeAnalyzer/ConstFetchAnalyzer.php | 12 +- src/NodeAnalyzer/EnumAnalyzer.php | 10 +- src/NodeAnalyzer/ExprAnalyzer.php | 28 +- src/NodeAnalyzer/InlineHTMLAnalyzer.php | 10 +- src/NodeAnalyzer/ParamAnalyzer.php | 32 +- src/NodeAnalyzer/PropertyAnalyzer.php | 14 +- src/NodeAnalyzer/PropertyFetchAnalyzer.php | 70 +- src/NodeAnalyzer/PropertyPresenceChecker.php | 22 +- src/NodeAnalyzer/ScopeAnalyzer.php | 4 +- src/NodeAnalyzer/UnreachableStmtAnalyzer.php | 12 +- src/NodeAnalyzer/VariableAnalyzer.php | 34 +- src/NodeAnalyzer/VariadicAnalyzer.php | 10 +- src/NodeDecorator/CreatedByRuleDecorator.php | 10 +- src/NodeDecorator/NamespacedNameDecorator.php | 4 +- src/NodeDecorator/PropertyTypeDecorator.php | 10 +- .../ArrayDestructVariableFilter.php | 14 +- src/NodeManipulator/ArrayManipulator.php | 32 +- src/NodeManipulator/AssignManipulator.php | 38 +- src/NodeManipulator/BinaryOpManipulator.php | 40 +- src/NodeManipulator/ClassConstManipulator.php | 16 +- .../ClassDependencyManipulator.php | 66 +- .../ClassInsertManipulator.php | 40 +- src/NodeManipulator/ClassManipulator.php | 18 +- .../ClassMethodAssignManipulator.php | 70 +- .../ClassMethodManipulator.php | 28 +- .../ClassMethodPropertyFetchManipulator.php | 22 +- .../DependencyClassMethodDecorator.php | 16 +- src/NodeManipulator/ForeachManipulator.php | 4 +- src/NodeManipulator/FuncCallManipulator.php | 4 +- .../FunctionLikeManipulator.php | 12 +- src/NodeManipulator/IfManipulator.php | 60 +- .../MagicPropertyFetchAnalyzer.php | 18 +- src/NodeManipulator/MethodCallManipulator.php | 16 +- .../PropertyFetchAssignManipulator.php | 32 +- src/NodeManipulator/PropertyManipulator.php | 58 +- src/NodeManipulator/StmtsManipulator.php | 10 +- src/NodeManipulator/VariableManipulator.php | 54 +- src/NonPhpFile/NonPhpFileProcessor.php | 14 +- .../Rector/RenameClassNonPhpRector.php | 20 +- .../ClosureTypeToCallReflectionResolver.php | 10 +- ...stantArrayTypeToCallReflectionResolver.php | 36 +- ...tantStringTypeToCallReflectionResolver.php | 14 +- .../ObjectTypeToCallReflectionResolver.php | 14 +- .../TypeToCallReflectionResolverRegistry.php | 2 +- src/Php/PhpVersionProvider.php | 16 +- .../ProjectComposerJsonPhpVersionResolver.php | 2 +- .../Regex/RegexPatternArgumentManipulator.php | 42 +- src/PhpParser/AstResolver.php | 72 +- src/PhpParser/ClassLikeAstResolver.php | 6 +- src/PhpParser/Comparing/ConditionSearcher.php | 26 +- src/PhpParser/Comparing/NodeComparator.php | 6 +- src/PhpParser/Node/AssignAndBinaryMap.php | 28 +- src/PhpParser/Node/BetterNodeFinder.php | 150 ++--- .../Node/CustomNode/FileWithoutNamespace.php | 2 +- src/PhpParser/Node/NamedVariableFactory.php | 12 +- src/PhpParser/Node/NodeFactory.php | 246 +++---- src/PhpParser/Node/Value/ValueResolver.php | 78 +-- .../NodeFinder/LocalConstantFinder.php | 12 +- .../NodeFinder/LocalMethodCallFinder.php | 12 +- .../NodeFinder/PropertyFetchFinder.php | 28 +- src/PhpParser/NodeTransformer.php | 44 +- .../FileWithoutNamespaceNodeTraverser.php | 10 +- .../NodeTraverser/RectorNodeTraverser.php | 4 +- src/PhpParser/Parser/InlineCodeParser.php | 22 +- src/PhpParser/Parser/RectorParser.php | 10 +- src/PhpParser/Parser/SimplePhpParser.php | 10 +- .../Printer/BetterStandardPrinter.php | 98 +-- .../Printer/FormatPerservingPrinter.php | 14 +- .../NodesWithFileDestinationPrinter.php | 4 +- src/ProcessAnalyzer/RectifiedAnalyzer.php | 18 +- src/Provider/CurrentFileProvider.php | 4 +- src/Rector/AbstractRector.php | 62 +- src/Rector/AbstractScopeAwareRector.php | 14 +- src/Reflection/ReflectionResolver.php | 82 +-- src/Reporting/MissingRectorRulesReporter.php | 10 +- .../DynamicSourceLocatorDecorator.php | 2 +- .../ParentAttributeSourceLocator.php | 18 +- .../RenamedClassesSourceLocator.php | 18 +- src/Util/MemoryLimiter.php | 8 +- src/Util/StaticRectorStrings.php | 6 +- src/Util/StringUtils.php | 2 +- .../EmptyConfigurableRectorCollector.php | 10 +- .../EmptyConfigurableRectorChecker.php | 2 +- src/Validation/RectorAssert.php | 4 +- src/ValueObject/Application/File.php | 14 +- src/ValueObject/Application/MovedFile.php | 2 +- src/ValueObject/Configuration.php | 4 +- src/ValueObject/Error/SystemError.php | 8 +- src/ValueObject/ProcessResult.php | 8 +- src/ValueObject/RectifiedNode.php | 4 +- src/ValueObject/Reporting/FileDiff.php | 10 +- src/ValueObject/SprintfStringAndArgs.php | 2 +- src/ValueObject/Visibility.php | 14 +- .../Application/FileFactory.php | 12 +- .../ProcessResultFactory.php | 10 +- src/functions/node_helper.php | 12 +- vendor/autoload.php | 2 +- vendor/clue/ndjson-react/src/Decoder.php | 8 +- vendor/clue/ndjson-react/src/Encoder.php | 4 +- vendor/composer/InstalledVersions.php | 4 +- vendor/composer/autoload_classmap.php | 29 +- vendor/composer/autoload_psr4.php | 2 +- vendor/composer/autoload_real.php | 14 +- vendor/composer/autoload_static.php | 50 +- vendor/composer/installed.json | 564 ++++++++-------- vendor/composer/installed.php | 2 +- vendor/composer/pcre/src/PcreException.php | 2 +- vendor/composer/pcre/src/Preg.php | 20 +- vendor/composer/pcre/src/Regex.php | 44 +- vendor/composer/semver/src/Comparator.php | 4 +- .../composer/semver/src/CompilingMatcher.php | 6 +- .../composer/semver/src/Constraint/Bound.php | 6 +- .../semver/src/Constraint/Constraint.php | 34 +- .../src/Constraint/ConstraintInterface.php | 2 +- .../src/Constraint/MatchAllConstraint.php | 8 +- .../src/Constraint/MatchNoneConstraint.php | 8 +- .../semver/src/Constraint/MultiConstraint.php | 10 +- vendor/composer/semver/src/Interval.php | 6 +- vendor/composer/semver/src/Intervals.php | 90 +-- vendor/composer/semver/src/Semver.php | 10 +- vendor/composer/semver/src/VersionParser.php | 28 +- .../composer/xdebug-handler/src/PhpConfig.php | 4 +- .../composer/xdebug-handler/src/Process.php | 8 +- vendor/composer/xdebug-handler/src/Status.php | 12 +- .../xdebug-handler/src/XdebugHandler.php | 38 +- .../Inflector/CachedWordInflector.php | 4 +- .../GenericLanguageInflectorFactory.php | 22 +- .../lib/Doctrine/Inflector/Inflector.php | 56 +- .../Doctrine/Inflector/InflectorFactory.php | 32 +- .../Inflector/LanguageInflectorFactory.php | 6 +- .../Doctrine/Inflector/NoopWordInflector.php | 2 +- .../Inflector/Rules/English/Inflectible.php | 296 ++++----- .../Rules/English/InflectorFactory.php | 10 +- .../Inflector/Rules/English/Rules.php | 8 +- .../Inflector/Rules/English/Uninflected.php | 316 ++++----- .../Inflector/Rules/French/Inflectible.php | 32 +- .../Rules/French/InflectorFactory.php | 10 +- .../Doctrine/Inflector/Rules/French/Rules.php | 8 +- .../Inflector/Rules/French/Uninflected.php | 2 +- .../Rules/NorwegianBokmal/Inflectible.php | 12 +- .../NorwegianBokmal/InflectorFactory.php | 10 +- .../Inflector/Rules/NorwegianBokmal/Rules.php | 8 +- .../Rules/NorwegianBokmal/Uninflected.php | 6 +- .../lib/Doctrine/Inflector/Rules/Pattern.php | 2 +- .../lib/Doctrine/Inflector/Rules/Patterns.php | 8 +- .../Rules/Portuguese/Inflectible.php | 140 ++-- .../Rules/Portuguese/InflectorFactory.php | 10 +- .../Inflector/Rules/Portuguese/Rules.php | 8 +- .../Rules/Portuguese/Uninflected.php | 10 +- .../lib/Doctrine/Inflector/Rules/Ruleset.php | 8 +- .../Inflector/Rules/Spanish/Inflectible.php | 38 +- .../Rules/Spanish/InflectorFactory.php | 10 +- .../Inflector/Rules/Spanish/Rules.php | 8 +- .../Inflector/Rules/Spanish/Uninflected.php | 6 +- .../Doctrine/Inflector/Rules/Substitution.php | 6 +- .../Inflector/Rules/Substitutions.php | 14 +- .../Inflector/Rules/Transformation.php | 8 +- .../Inflector/Rules/Transformations.php | 4 +- .../Inflector/Rules/Turkish/Inflectible.php | 12 +- .../Rules/Turkish/InflectorFactory.php | 10 +- .../Inflector/Rules/Turkish/Rules.php | 8 +- .../Inflector/Rules/Turkish/Uninflected.php | 6 +- .../Doctrine/Inflector/RulesetInflector.php | 6 +- .../examples/benchmark-emit-no-arguments.php | 6 +- .../examples/benchmark-emit-once.php | 6 +- .../examples/benchmark-emit-one-argument.php | 6 +- .../evenement/examples/benchmark-emit.php | 6 +- .../benchmark-remove-listener-once.php | 8 +- .../evenement/src/Evenement/EventEmitter.php | 2 +- .../src/Evenement/EventEmitterTrait.php | 8 +- .../Evenement/Tests/EventEmitterTest.php | 22 +- vendor/nette/neon/bin/neon-lint | 8 +- vendor/nette/neon/src/Neon/Decoder.php | 6 +- vendor/nette/neon/src/Neon/Encoder.php | 26 +- vendor/nette/neon/src/Neon/Lexer.php | 24 +- vendor/nette/neon/src/Neon/Neon.php | 8 +- .../neon/src/Neon/Node/ArrayItemNode.php | 4 +- vendor/nette/neon/src/Neon/Node/ArrayNode.php | 4 +- .../neon/src/Neon/Node/BlockArrayNode.php | 4 +- .../neon/src/Neon/Node/EntityChainNode.php | 6 +- .../nette/neon/src/Neon/Node/EntityNode.php | 10 +- .../neon/src/Neon/Node/InlineArrayNode.php | 4 +- .../nette/neon/src/Neon/Node/LiteralNode.php | 2 +- .../nette/neon/src/Neon/Node/StringNode.php | 8 +- vendor/nette/neon/src/Neon/Parser.php | 72 +- vendor/nette/neon/src/Neon/TokenStream.php | 8 +- vendor/nette/neon/src/Neon/Traverser.php | 8 +- vendor/nette/utils/src/HtmlStringable.php | 2 +- .../utils/src/Iterators/CachingIterator.php | 4 +- vendor/nette/utils/src/SmartObject.php | 28 +- vendor/nette/utils/src/StaticClass.php | 2 +- vendor/nette/utils/src/Translator.php | 2 +- vendor/nette/utils/src/Utils/ArrayHash.php | 2 +- vendor/nette/utils/src/Utils/ArrayList.php | 10 +- vendor/nette/utils/src/Utils/Arrays.php | 46 +- vendor/nette/utils/src/Utils/Callback.php | 18 +- vendor/nette/utils/src/Utils/DateTime.php | 4 +- vendor/nette/utils/src/Utils/FileSystem.php | 30 +- vendor/nette/utils/src/Utils/Helpers.php | 4 +- vendor/nette/utils/src/Utils/Html.php | 26 +- vendor/nette/utils/src/Utils/Image.php | 40 +- vendor/nette/utils/src/Utils/Json.php | 4 +- .../nette/utils/src/Utils/ObjectHelpers.php | 12 +- vendor/nette/utils/src/Utils/ObjectMixin.php | 2 +- vendor/nette/utils/src/Utils/Random.php | 4 +- vendor/nette/utils/src/Utils/Reflection.php | 24 +- vendor/nette/utils/src/Utils/Strings.php | 52 +- vendor/nette/utils/src/Utils/Type.php | 24 +- vendor/nette/utils/src/Utils/Validators.php | 16 +- vendor/nette/utils/src/Utils/exceptions.php | 2 +- vendor/nette/utils/src/compatibility.php | 12 +- vendor/nette/utils/src/exceptions.php | 6 +- vendor/nikic/php-parser/bin/php-parse | 12 +- vendor/nikic/php-parser/grammar/phpyLang.php | 42 +- .../php-parser/grammar/rebuildParsers.php | 10 +- .../lib/PhpParser/Builder/ClassConst.php | 24 +- .../lib/PhpParser/Builder/Class_.php | 22 +- .../lib/PhpParser/Builder/Declaration.php | 6 +- .../lib/PhpParser/Builder/EnumCase.php | 14 +- .../lib/PhpParser/Builder/Enum_.php | 16 +- .../lib/PhpParser/Builder/FunctionLike.php | 6 +- .../lib/PhpParser/Builder/Function_.php | 10 +- .../lib/PhpParser/Builder/Interface_.php | 16 +- .../lib/PhpParser/Builder/Method.php | 22 +- .../lib/PhpParser/Builder/Namespace_.php | 10 +- .../lib/PhpParser/Builder/Param.php | 14 +- .../lib/PhpParser/Builder/Property.php | 26 +- .../lib/PhpParser/Builder/TraitUse.php | 12 +- .../PhpParser/Builder/TraitUseAdaptation.php | 20 +- .../lib/PhpParser/Builder/Trait_.php | 16 +- .../php-parser/lib/PhpParser/Builder/Use_.php | 8 +- .../lib/PhpParser/BuilderFactory.php | 56 +- .../lib/PhpParser/BuilderHelpers.php | 60 +- .../lib/PhpParser/ConstExprEvaluator.php | 40 +- .../lib/PhpParser/ErrorHandler/Collecting.php | 4 +- .../lib/PhpParser/ErrorHandler/Throwing.php | 4 +- .../Internal/PrintableNewAnonClassNode.php | 8 +- .../nikic/php-parser/lib/PhpParser/Lexer.php | 44 +- .../lib/PhpParser/Lexer/Emulative.php | 10 +- .../Lexer/TokenEmulator/AttributeEmulator.php | 2 +- .../CoaleseEqualTokenEmulator.php | 2 +- .../Lexer/TokenEmulator/EnumTokenEmulator.php | 2 +- .../TokenEmulator/ExplicitOctalEmulator.php | 2 +- .../FlexibleDocStringEmulator.php | 2 +- .../Lexer/TokenEmulator/FnTokenEmulator.php | 2 +- .../TokenEmulator/MatchTokenEmulator.php | 2 +- .../TokenEmulator/NullsafeTokenEmulator.php | 2 +- .../NumericLiteralSeparatorEmulator.php | 2 +- .../TokenEmulator/ReadonlyTokenEmulator.php | 2 +- .../php-parser/lib/PhpParser/NameContext.php | 62 +- .../php-parser/lib/PhpParser/Node/Arg.php | 2 +- .../lib/PhpParser/Node/Attribute.php | 2 +- .../lib/PhpParser/Node/AttributeGroup.php | 2 +- .../lib/PhpParser/Node/ComplexType.php | 2 +- .../php-parser/lib/PhpParser/Node/Const_.php | 2 +- .../php-parser/lib/PhpParser/Node/Expr.php | 2 +- .../lib/PhpParser/Node/Expr/ArrayDimFetch.php | 4 +- .../lib/PhpParser/Node/Expr/ArrayItem.php | 4 +- .../lib/PhpParser/Node/Expr/Array_.php | 2 +- .../lib/PhpParser/Node/Expr/ArrowFunction.php | 6 +- .../lib/PhpParser/Node/Expr/Assign.php | 4 +- .../lib/PhpParser/Node/Expr/AssignOp.php | 4 +- .../Node/Expr/AssignOp/BitwiseAnd.php | 2 +- .../Node/Expr/AssignOp/BitwiseOr.php | 2 +- .../Node/Expr/AssignOp/BitwiseXor.php | 2 +- .../PhpParser/Node/Expr/AssignOp/Coalesce.php | 2 +- .../PhpParser/Node/Expr/AssignOp/Concat.php | 2 +- .../lib/PhpParser/Node/Expr/AssignOp/Div.php | 2 +- .../PhpParser/Node/Expr/AssignOp/Minus.php | 2 +- .../lib/PhpParser/Node/Expr/AssignOp/Mod.php | 2 +- .../lib/PhpParser/Node/Expr/AssignOp/Mul.php | 2 +- .../lib/PhpParser/Node/Expr/AssignOp/Plus.php | 2 +- .../lib/PhpParser/Node/Expr/AssignOp/Pow.php | 2 +- .../Node/Expr/AssignOp/ShiftLeft.php | 2 +- .../Node/Expr/AssignOp/ShiftRight.php | 2 +- .../lib/PhpParser/Node/Expr/AssignRef.php | 4 +- .../lib/PhpParser/Node/Expr/BinaryOp.php | 4 +- .../Node/Expr/BinaryOp/BitwiseAnd.php | 2 +- .../Node/Expr/BinaryOp/BitwiseOr.php | 2 +- .../Node/Expr/BinaryOp/BitwiseXor.php | 2 +- .../Node/Expr/BinaryOp/BooleanAnd.php | 2 +- .../Node/Expr/BinaryOp/BooleanOr.php | 2 +- .../PhpParser/Node/Expr/BinaryOp/Coalesce.php | 2 +- .../PhpParser/Node/Expr/BinaryOp/Concat.php | 2 +- .../lib/PhpParser/Node/Expr/BinaryOp/Div.php | 2 +- .../PhpParser/Node/Expr/BinaryOp/Equal.php | 2 +- .../PhpParser/Node/Expr/BinaryOp/Greater.php | 2 +- .../Node/Expr/BinaryOp/GreaterOrEqual.php | 2 +- .../Node/Expr/BinaryOp/Identical.php | 2 +- .../Node/Expr/BinaryOp/LogicalAnd.php | 2 +- .../Node/Expr/BinaryOp/LogicalOr.php | 2 +- .../Node/Expr/BinaryOp/LogicalXor.php | 2 +- .../PhpParser/Node/Expr/BinaryOp/Minus.php | 2 +- .../lib/PhpParser/Node/Expr/BinaryOp/Mod.php | 2 +- .../lib/PhpParser/Node/Expr/BinaryOp/Mul.php | 2 +- .../PhpParser/Node/Expr/BinaryOp/NotEqual.php | 2 +- .../Node/Expr/BinaryOp/NotIdentical.php | 2 +- .../lib/PhpParser/Node/Expr/BinaryOp/Plus.php | 2 +- .../lib/PhpParser/Node/Expr/BinaryOp/Pow.php | 2 +- .../Node/Expr/BinaryOp/ShiftLeft.php | 2 +- .../Node/Expr/BinaryOp/ShiftRight.php | 2 +- .../PhpParser/Node/Expr/BinaryOp/Smaller.php | 2 +- .../Node/Expr/BinaryOp/SmallerOrEqual.php | 2 +- .../Node/Expr/BinaryOp/Spaceship.php | 2 +- .../lib/PhpParser/Node/Expr/BitwiseNot.php | 4 +- .../lib/PhpParser/Node/Expr/BooleanNot.php | 4 +- .../lib/PhpParser/Node/Expr/CallLike.php | 4 +- .../lib/PhpParser/Node/Expr/Cast.php | 4 +- .../lib/PhpParser/Node/Expr/Cast/Array_.php | 2 +- .../lib/PhpParser/Node/Expr/Cast/Bool_.php | 2 +- .../lib/PhpParser/Node/Expr/Cast/Double.php | 2 +- .../lib/PhpParser/Node/Expr/Cast/Int_.php | 2 +- .../lib/PhpParser/Node/Expr/Cast/Object_.php | 2 +- .../lib/PhpParser/Node/Expr/Cast/String_.php | 2 +- .../lib/PhpParser/Node/Expr/Cast/Unset_.php | 2 +- .../PhpParser/Node/Expr/ClassConstFetch.php | 4 +- .../lib/PhpParser/Node/Expr/Clone_.php | 4 +- .../lib/PhpParser/Node/Expr/Closure.php | 4 +- .../lib/PhpParser/Node/Expr/ClosureUse.php | 4 +- .../lib/PhpParser/Node/Expr/ConstFetch.php | 4 +- .../lib/PhpParser/Node/Expr/Empty_.php | 4 +- .../lib/PhpParser/Node/Expr/Error.php | 2 +- .../lib/PhpParser/Node/Expr/ErrorSuppress.php | 4 +- .../lib/PhpParser/Node/Expr/Eval_.php | 4 +- .../lib/PhpParser/Node/Expr/Exit_.php | 4 +- .../lib/PhpParser/Node/Expr/Include_.php | 4 +- .../lib/PhpParser/Node/Expr/Instanceof_.php | 4 +- .../lib/PhpParser/Node/Expr/Isset_.php | 2 +- .../lib/PhpParser/Node/Expr/List_.php | 2 +- .../lib/PhpParser/Node/Expr/Match_.php | 4 +- .../lib/PhpParser/Node/Expr/MethodCall.php | 4 +- .../Node/Expr/NullsafeMethodCall.php | 4 +- .../Node/Expr/NullsafePropertyFetch.php | 6 +- .../lib/PhpParser/Node/Expr/PostDec.php | 4 +- .../lib/PhpParser/Node/Expr/PostInc.php | 4 +- .../lib/PhpParser/Node/Expr/PreDec.php | 4 +- .../lib/PhpParser/Node/Expr/PreInc.php | 4 +- .../lib/PhpParser/Node/Expr/Print_.php | 4 +- .../lib/PhpParser/Node/Expr/PropertyFetch.php | 6 +- .../lib/PhpParser/Node/Expr/ShellExec.php | 2 +- .../lib/PhpParser/Node/Expr/StaticCall.php | 2 +- .../Node/Expr/StaticPropertyFetch.php | 4 +- .../lib/PhpParser/Node/Expr/Ternary.php | 4 +- .../lib/PhpParser/Node/Expr/Throw_.php | 4 +- .../lib/PhpParser/Node/Expr/UnaryMinus.php | 4 +- .../lib/PhpParser/Node/Expr/UnaryPlus.php | 4 +- .../lib/PhpParser/Node/Expr/Variable.php | 2 +- .../lib/PhpParser/Node/Expr/YieldFrom.php | 4 +- .../lib/PhpParser/Node/Expr/Yield_.php | 4 +- .../lib/PhpParser/Node/FunctionLike.php | 2 +- .../lib/PhpParser/Node/Identifier.php | 2 +- .../lib/PhpParser/Node/MatchArm.php | 4 +- .../php-parser/lib/PhpParser/Node/Name.php | 2 +- .../php-parser/lib/PhpParser/Node/Param.php | 2 +- .../lib/PhpParser/Node/Scalar/DNumber.php | 2 +- .../lib/PhpParser/Node/Scalar/Encapsed.php | 2 +- .../Node/Scalar/EncapsedStringPart.php | 2 +- .../lib/PhpParser/Node/Scalar/LNumber.php | 4 +- .../lib/PhpParser/Node/Scalar/MagicConst.php | 2 +- .../Node/Scalar/MagicConst/Class_.php | 2 +- .../PhpParser/Node/Scalar/MagicConst/Dir.php | 2 +- .../PhpParser/Node/Scalar/MagicConst/File.php | 2 +- .../Node/Scalar/MagicConst/Function_.php | 2 +- .../PhpParser/Node/Scalar/MagicConst/Line.php | 2 +- .../Node/Scalar/MagicConst/Method.php | 2 +- .../Node/Scalar/MagicConst/Namespace_.php | 2 +- .../Node/Scalar/MagicConst/Trait_.php | 2 +- .../lib/PhpParser/Node/Scalar/String_.php | 8 +- .../php-parser/lib/PhpParser/Node/Stmt.php | 2 +- .../lib/PhpParser/Node/Stmt/Break_.php | 4 +- .../lib/PhpParser/Node/Stmt/Case_.php | 2 +- .../lib/PhpParser/Node/Stmt/Catch_.php | 4 +- .../lib/PhpParser/Node/Stmt/ClassConst.php | 2 +- .../lib/PhpParser/Node/Stmt/ClassLike.php | 2 +- .../lib/PhpParser/Node/Stmt/ClassMethod.php | 6 +- .../lib/PhpParser/Node/Stmt/Class_.php | 22 +- .../lib/PhpParser/Node/Stmt/Const_.php | 2 +- .../lib/PhpParser/Node/Stmt/Continue_.php | 4 +- .../PhpParser/Node/Stmt/DeclareDeclare.php | 6 +- .../lib/PhpParser/Node/Stmt/Declare_.php | 2 +- .../lib/PhpParser/Node/Stmt/Do_.php | 4 +- .../lib/PhpParser/Node/Stmt/Echo_.php | 2 +- .../lib/PhpParser/Node/Stmt/ElseIf_.php | 4 +- .../lib/PhpParser/Node/Stmt/Else_.php | 2 +- .../lib/PhpParser/Node/Stmt/EnumCase.php | 6 +- .../lib/PhpParser/Node/Stmt/Enum_.php | 2 +- .../lib/PhpParser/Node/Stmt/Expression.php | 4 +- .../lib/PhpParser/Node/Stmt/Finally_.php | 2 +- .../lib/PhpParser/Node/Stmt/For_.php | 2 +- .../lib/PhpParser/Node/Stmt/Foreach_.php | 4 +- .../lib/PhpParser/Node/Stmt/Function_.php | 6 +- .../lib/PhpParser/Node/Stmt/Global_.php | 2 +- .../lib/PhpParser/Node/Stmt/Goto_.php | 4 +- .../lib/PhpParser/Node/Stmt/GroupUse.php | 4 +- .../lib/PhpParser/Node/Stmt/HaltCompiler.php | 2 +- .../lib/PhpParser/Node/Stmt/If_.php | 4 +- .../lib/PhpParser/Node/Stmt/InlineHTML.php | 2 +- .../lib/PhpParser/Node/Stmt/Interface_.php | 2 +- .../lib/PhpParser/Node/Stmt/Label.php | 4 +- .../lib/PhpParser/Node/Stmt/Namespace_.php | 4 +- .../lib/PhpParser/Node/Stmt/Nop.php | 2 +- .../lib/PhpParser/Node/Stmt/Property.php | 4 +- .../PhpParser/Node/Stmt/PropertyProperty.php | 6 +- .../lib/PhpParser/Node/Stmt/Return_.php | 4 +- .../lib/PhpParser/Node/Stmt/StaticVar.php | 4 +- .../lib/PhpParser/Node/Stmt/Static_.php | 2 +- .../lib/PhpParser/Node/Stmt/Switch_.php | 4 +- .../lib/PhpParser/Node/Stmt/Throw_.php | 4 +- .../lib/PhpParser/Node/Stmt/TraitUse.php | 2 +- .../Node/Stmt/TraitUseAdaptation.php | 2 +- .../Node/Stmt/TraitUseAdaptation/Alias.php | 6 +- .../Stmt/TraitUseAdaptation/Precedence.php | 6 +- .../lib/PhpParser/Node/Stmt/Trait_.php | 2 +- .../lib/PhpParser/Node/Stmt/TryCatch.php | 2 +- .../lib/PhpParser/Node/Stmt/Unset_.php | 2 +- .../lib/PhpParser/Node/Stmt/UseUse.php | 10 +- .../lib/PhpParser/Node/Stmt/Use_.php | 2 +- .../lib/PhpParser/Node/Stmt/While_.php | 4 +- .../PhpParser/Node/VariadicPlaceholder.php | 2 +- .../php-parser/lib/PhpParser/NodeDumper.php | 22 +- .../php-parser/lib/PhpParser/NodeFinder.php | 4 +- .../PhpParser/NodeVisitor/CloningVisitor.php | 4 +- .../PhpParser/NodeVisitor/FindingVisitor.php | 4 +- .../NodeVisitor/FirstFindingVisitor.php | 6 +- .../PhpParser/NodeVisitor/NameResolver.php | 82 +-- .../NodeVisitor/NodeConnectingVisitor.php | 6 +- .../NodeVisitor/ParentConnectingVisitor.php | 10 +- .../lib/PhpParser/Parser/Multiple.php | 10 +- .../php-parser/lib/PhpParser/Parser/Php5.php | 614 +++++++++--------- .../php-parser/lib/PhpParser/Parser/Php7.php | 582 ++++++++--------- .../lib/PhpParser/ParserAbstract.php | 86 +-- .../lib/PhpParser/PrettyPrinter/Standard.php | 526 +++++++-------- .../lib/PhpParser/PrettyPrinterAbstract.php | 202 +++--- .../ondram/ci-detector/src/Ci/AbstractCi.php | 4 +- vendor/ondram/ci-detector/src/Ci/AppVeyor.php | 10 +- .../ci-detector/src/Ci/AwsCodeBuild.php | 10 +- .../ci-detector/src/Ci/AzurePipelines.php | 10 +- vendor/ondram/ci-detector/src/Ci/Bamboo.php | 10 +- .../ci-detector/src/Ci/BitbucketPipelines.php | 10 +- vendor/ondram/ci-detector/src/Ci/Buddy.php | 10 +- .../ondram/ci-detector/src/Ci/CiInterface.php | 4 +- vendor/ondram/ci-detector/src/Ci/Circle.php | 10 +- vendor/ondram/ci-detector/src/Ci/Codeship.php | 10 +- .../ci-detector/src/Ci/Continuousphp.php | 10 +- vendor/ondram/ci-detector/src/Ci/Drone.php | 10 +- .../ci-detector/src/Ci/GitHubActions.php | 10 +- vendor/ondram/ci-detector/src/Ci/GitLab.php | 10 +- vendor/ondram/ci-detector/src/Ci/Jenkins.php | 10 +- .../ondram/ci-detector/src/Ci/SourceHut.php | 10 +- vendor/ondram/ci-detector/src/Ci/TeamCity.php | 10 +- vendor/ondram/ci-detector/src/Ci/Travis.php | 10 +- vendor/ondram/ci-detector/src/Ci/Wercker.php | 10 +- vendor/ondram/ci-detector/src/CiDetector.php | 14 +- .../ci-detector/src/CiDetectorInterface.php | 2 +- .../src/Ast/ConstExpr/ConstExprArrayNode.php | 2 +- .../src/Ast/ConstExpr/ConstExprNode.php | 2 +- .../phpdoc-parser/src/Ast/NodeAttributes.php | 2 +- .../src/Ast/PhpDoc/AssertTagValueNode.php | 4 +- .../src/Ast/PhpDoc/DeprecatedTagValueNode.php | 2 +- .../src/Ast/PhpDoc/ExtendsTagValueNode.php | 4 +- .../src/Ast/PhpDoc/ImplementsTagValueNode.php | 4 +- .../src/Ast/PhpDoc/InvalidTagValueNode.php | 6 +- .../src/Ast/PhpDoc/MethodTagValueNode.php | 4 +- .../PhpDoc/MethodTagValueParameterNode.php | 4 +- .../src/Ast/PhpDoc/MixinTagValueNode.php | 4 +- .../src/Ast/PhpDoc/ParamTagValueNode.php | 4 +- .../src/Ast/PhpDoc/PhpDocChildNode.php | 2 +- .../src/Ast/PhpDoc/PhpDocNode.php | 44 +- .../src/Ast/PhpDoc/PhpDocTagNode.php | 2 +- .../src/Ast/PhpDoc/PhpDocTagValueNode.php | 2 +- .../src/Ast/PhpDoc/PropertyTagValueNode.php | 4 +- .../src/Ast/PhpDoc/ReturnTagValueNode.php | 4 +- .../src/Ast/PhpDoc/TemplateTagValueNode.php | 4 +- .../src/Ast/PhpDoc/ThrowsTagValueNode.php | 4 +- .../PhpDoc/TypeAliasImportTagValueNode.php | 4 +- .../src/Ast/PhpDoc/TypeAliasTagValueNode.php | 4 +- .../src/Ast/PhpDoc/UsesTagValueNode.php | 4 +- .../src/Ast/PhpDoc/VarTagValueNode.php | 4 +- .../src/Ast/Type/ArrayShapeItemNode.php | 2 +- .../src/Ast/Type/ArrayShapeNode.php | 2 +- .../src/Ast/Type/CallableTypeNode.php | 2 +- .../Ast/Type/CallableTypeParameterNode.php | 2 +- .../Type/ConditionalTypeForParameterNode.php | 2 +- .../src/Ast/Type/ConditionalTypeNode.php | 2 +- .../src/Ast/Type/ConstTypeNode.php | 2 +- .../src/Ast/Type/GenericTypeNode.php | 2 +- .../src/Ast/Type/IntersectionTypeNode.php | 2 +- .../phpdoc-parser/src/Ast/Type/TypeNode.php | 2 +- .../src/Ast/Type/UnionTypeNode.php | 2 +- .../phpstan/phpdoc-parser/src/Lexer/Lexer.php | 12 +- .../src/Parser/ConstExprParser.php | 72 +- .../src/Parser/ParserException.php | 8 +- .../phpdoc-parser/src/Parser/PhpDocParser.php | 174 ++--- .../src/Parser/TokenIterator.php | 48 +- .../phpdoc-parser/src/Parser/TypeParser.php | 316 ++++----- .../MockObjectTypeNodeResolverExtension.php | 16 +- .../src/Rules/PHPUnit/AssertRuleHelper.php | 16 +- .../PHPUnit/AssertSameBooleanExpectedRule.php | 12 +- .../PHPUnit/AssertSameNullExpectedRule.php | 12 +- .../Rules/PHPUnit/AssertSameWithCountRule.php | 16 +- .../src/Rules/PHPUnit/MockMethodCallRule.php | 26 +- .../PHPUnit/ShouldCallParentMethodsRule.php | 30 +- .../AssertFunctionTypeSpecifyingExtension.php | 12 +- .../AssertMethodTypeSpecifyingExtension.php | 8 +- ...ertStaticMethodTypeSpecifyingExtension.php | 8 +- .../AssertTypeSpecifyingExtensionHelper.php | 110 ++-- ...cationMockerDynamicReturnTypeExtension.php | 8 +- .../MockBuilderDynamicReturnTypeExtension.php | 10 +- .../MockObjectDynamicReturnTypeExtension.php | 22 +- vendor/phpstan/phpstan/bootstrap.php | 2 +- .../psr/cache/src/CacheItemPoolInterface.php | 6 +- .../cache/src/InvalidArgumentException.php | 2 +- .../src/ContainerExceptionInterface.php | 2 +- .../src/NotFoundExceptionInterface.php | 2 +- vendor/psr/log/src/AbstractLogger.php | 2 +- vendor/psr/log/src/LoggerAwareInterface.php | 2 +- vendor/psr/log/src/LoggerAwareTrait.php | 2 +- vendor/psr/log/src/LoggerTrait.php | 16 +- vendor/psr/log/src/NullLogger.php | 2 +- vendor/react/cache/src/ArrayCache.php | 22 +- vendor/react/child-process/src/Process.php | 12 +- vendor/react/dns/src/Config/Config.php | 4 +- vendor/react/dns/src/Config/HostsFile.php | 2 +- vendor/react/dns/src/Model/Message.php | 10 +- .../react/dns/src/Protocol/BinaryDumper.php | 34 +- vendor/react/dns/src/Protocol/Parser.php | 36 +- .../react/dns/src/Query/CachingExecutor.php | 12 +- vendor/react/dns/src/Query/CoopExecutor.php | 10 +- .../react/dns/src/Query/ExecutorInterface.php | 2 +- .../react/dns/src/Query/FallbackExecutor.php | 8 +- .../react/dns/src/Query/HostsFileExecutor.php | 20 +- vendor/react/dns/src/Query/Query.php | 2 +- vendor/react/dns/src/Query/RetryExecutor.php | 14 +- .../src/Query/SelectiveTransportExecutor.php | 8 +- .../dns/src/Query/TcpTransportExecutor.php | 18 +- .../react/dns/src/Query/TimeoutExecutor.php | 14 +- .../dns/src/Query/UdpTransportExecutor.php | 18 +- vendor/react/dns/src/Resolver/Factory.php | 46 +- vendor/react/dns/src/Resolver/Resolver.php | 30 +- vendor/react/event-loop/src/ExtEvLoop.php | 24 +- vendor/react/event-loop/src/ExtEventLoop.php | 40 +- vendor/react/event-loop/src/ExtLibevLoop.php | 32 +- .../react/event-loop/src/ExtLibeventLoop.php | 20 +- vendor/react/event-loop/src/ExtUvLoop.php | 14 +- vendor/react/event-loop/src/Factory.php | 14 +- vendor/react/event-loop/src/Loop.php | 8 +- vendor/react/event-loop/src/LoopInterface.php | 2 +- .../react/event-loop/src/StreamSelectLoop.php | 14 +- .../event-loop/src/Tick/FutureTickQueue.php | 2 +- vendor/react/event-loop/src/Timer/Timer.php | 2 +- vendor/react/event-loop/src/Timer/Timers.php | 6 +- .../promise-timer/src/TimeoutException.php | 2 +- vendor/react/promise-timer/src/functions.php | 24 +- .../src/CancellablePromiseInterface.php | 2 +- vendor/react/promise/src/Deferred.php | 4 +- .../promise/src/ExtendedPromiseInterface.php | 2 +- vendor/react/promise/src/FulfilledPromise.php | 10 +- vendor/react/promise/src/LazyPromise.php | 6 +- vendor/react/promise/src/Promise.php | 16 +- vendor/react/promise/src/RejectedPromise.php | 16 +- vendor/react/promise/src/functions.php | 34 +- vendor/react/socket/src/Connection.php | 14 +- .../react/socket/src/ConnectionInterface.php | 2 +- vendor/react/socket/src/Connector.php | 32 +- vendor/react/socket/src/DnsConnector.php | 12 +- vendor/react/socket/src/FdServer.php | 12 +- vendor/react/socket/src/FixedUriConnector.php | 4 +- .../src/HappyEyeBallsConnectionBuilder.php | 32 +- .../socket/src/HappyEyeBallsConnector.php | 10 +- vendor/react/socket/src/LimitingServer.php | 8 +- vendor/react/socket/src/SecureConnector.php | 14 +- vendor/react/socket/src/SecureServer.php | 10 +- vendor/react/socket/src/Server.php | 16 +- vendor/react/socket/src/ServerInterface.php | 2 +- vendor/react/socket/src/SocketServer.php | 14 +- vendor/react/socket/src/StreamEncryption.php | 10 +- vendor/react/socket/src/TcpConnector.php | 18 +- vendor/react/socket/src/TcpServer.php | 14 +- vendor/react/socket/src/TimeoutConnector.php | 10 +- vendor/react/socket/src/UnixConnector.php | 14 +- vendor/react/socket/src/UnixServer.php | 12 +- vendor/react/stream/src/CompositeStream.php | 12 +- .../react/stream/src/DuplexResourceStream.php | 16 +- .../stream/src/DuplexStreamInterface.php | 2 +- .../stream/src/ReadableResourceStream.php | 14 +- .../stream/src/ReadableStreamInterface.php | 4 +- vendor/react/stream/src/ThroughStream.php | 8 +- vendor/react/stream/src/Util.php | 2 +- .../stream/src/WritableResourceStream.php | 6 +- .../stream/src/WritableStreamInterface.php | 2 +- vendor/rector/extension-installer/rector.php | 8 +- .../src/LocalFilesystem.php | 4 +- .../rector/extension-installer/src/Plugin.php | 12 +- .../src/PluginInstaller.php | 4 +- .../rector/rector-cakephp/config/config.php | 2 +- .../config/sets/cakephp-fluent-options.php | 8 +- .../rector-cakephp/config/sets/cakephp30.php | 6 +- .../rector-cakephp/config/sets/cakephp34.php | 296 ++++----- .../rector-cakephp/config/sets/cakephp35.php | 8 +- .../rector-cakephp/config/sets/cakephp36.php | 8 +- .../rector-cakephp/config/sets/cakephp37.php | 12 +- .../rector-cakephp/config/sets/cakephp38.php | 4 +- .../rector-cakephp/config/sets/cakephp40.php | 22 +- .../rector-cakephp/config/sets/cakephp41.php | 8 +- .../rector-cakephp/config/sets/cakephp42.php | 6 +- .../rector-cakephp/config/sets/cakephp43.php | 10 +- .../rector-cakephp/config/sets/cakephp44.php | 4 +- .../config/sets/level/up-to-cakephp-34.php | 4 +- .../config/sets/level/up-to-cakephp-35.php | 4 +- .../config/sets/level/up-to-cakephp-36.php | 4 +- .../config/sets/level/up-to-cakephp-37.php | 4 +- .../config/sets/level/up-to-cakephp-38.php | 4 +- .../config/sets/level/up-to-cakephp-40.php | 4 +- .../config/sets/level/up-to-cakephp-41.php | 4 +- .../config/sets/level/up-to-cakephp-42.php | 4 +- .../config/sets/level/up-to-cakephp-43.php | 4 +- .../config/sets/level/up-to-cakephp-44.php | 4 +- .../rector-cakephp/monorepo-builder.php | 8 +- vendor/rector/rector-cakephp/rector.php | 6 +- ...CakePHPFullyQualifiedClassNameResolver.php | 10 +- .../MethodCall/ArrayToFluentCallRector.php | 38 +- .../Rector/MethodCall/ModalToGetSetRector.php | 30 +- .../RemoveIntermediaryMethodRector.php | 34 +- ...RenameMethodCallBasedOnParameterRector.php | 26 +- .../AppUsesStaticCallToUseStatementRector.php | 40 +- .../ChangeSnakedFixtureNameToPascalRector.php | 30 +- .../src/Set/CakePHPLevelSetList.php | 2 +- .../rector-cakephp/src/Set/CakePHPSetList.php | 2 +- .../src/ValueObject/FactoryMethod.php | 4 +- .../src/ValueObject/ModalToGetSet.php | 4 +- .../RenameMethodCallBasedOnParameter.php | 4 +- .../rector/rector-doctrine/config/config.php | 2 +- .../doctrine-annotations-to-attributes.php | 76 +-- .../config/sets/doctrine-behaviors-20.php | 8 +- .../config/sets/doctrine-code-quality.php | 34 +- .../config/sets/doctrine-common-20.php | 4 +- .../config/sets/doctrine-dbal-210.php | 4 +- .../config/sets/doctrine-dbal-211.php | 36 +- .../config/sets/doctrine-dbal-30.php | 8 +- .../config/sets/doctrine-gedmo-to-knplabs.php | 16 +- .../config/sets/doctrine-odm-23.php | 4 +- .../config/sets/doctrine-orm-29.php | 2 +- .../sets/doctrine-repository-as-service.php | 20 +- .../config/sets/doctrine25.php | 6 +- .../rector-doctrine/monorepo-builder.php | 8 +- vendor/rector/rector-doctrine/rector.php | 6 +- .../AssignPropertyFetchAnalyzer.php | 10 +- .../src/NodeAnalyzer/AttributeCleaner.php | 6 +- .../src/NodeAnalyzer/AttributeFinder.php | 18 +- .../src/NodeAnalyzer/AttrinationFinder.php | 14 +- .../ConstructorAssignPropertyAnalyzer.php | 16 +- .../NodeAnalyzer/EntityObjectTypeResolver.php | 42 +- .../MethodCallNameOnTypeResolver.php | 8 +- .../SetterClassMethodAnalyzer.php | 32 +- .../src/NodeAnalyzer/TargetEntityResolver.php | 10 +- ...ranslatablePropertyCollectorAndRemover.php | 10 +- .../ArrayCollectionAssignFactory.php | 10 +- .../ConstructClassMethodFactory.php | 26 +- .../ConstructorClassMethodAssignFactory.php | 6 +- .../src/NodeFactory/EntityIdNodeFactory.php | 16 +- .../src/NodeFactory/ParamFactory.php | 16 +- .../NodeFactory/RepositoryAssignFactory.php | 10 +- .../src/NodeFactory/RepositoryNodeFactory.php | 12 +- .../TranslationClassNodeFactory.php | 14 +- .../src/NodeFactory/ValueAssignFactory.php | 26 +- .../ColumnPropertyTypeResolver.php | 80 +-- .../ConstructorManipulator.php | 12 +- .../src/NodeManipulator/DependencyRemover.php | 18 +- .../DoctrineItemDefaultValueManipulator.php | 10 +- .../NodeManipulator/IssetDimFetchCleaner.php | 34 +- .../NullabilityColumnPropertyTypeResolver.php | 12 +- .../PropertyTypeManipulator.php | 10 +- .../ToManyRelationPropertyTypeResolver.php | 18 +- .../ToOneRelationPropertyTypeResolver.php | 36 +- .../src/PhpDoc/ShortClassExpander.php | 14 +- .../PhpDocParser/DoctrineDocBlockResolver.php | 14 +- ...terNullabilityInSyncWithPropertyRector.php | 18 +- ...ceEntityRepositoryParentCallToDIRector.php | 40 +- .../Class_/AddEntityIdByConditionRector.php | 24 +- .../Rector/Class_/BlameableBehaviorRector.php | 24 +- ...tationToNamedArgumentConstructorRector.php | 38 +- ...nitializeDefaultEntityCollectionRector.php | 20 +- .../Rector/Class_/LoggableBehaviorRector.php | 40 +- ...egistryGetManagerToEntityManagerRector.php | 60 +- ...TimeDefaultInEntityToConstructorRector.php | 26 +- ...epositoryFromParentToConstructorRector.php | 22 +- ...dantDefaultClassAnnotationValuesRector.php | 22 +- ...veRepositoryFromEntityAnnotationRector.php | 16 +- .../Rector/Class_/SluggableBehaviorRector.php | 32 +- .../Class_/SoftDeletableBehaviorRector.php | 22 +- .../Class_/TimestampableBehaviorRector.php | 18 +- .../Class_/TranslationBehaviorRector.php | 38 +- .../src/Rector/Class_/TreeBehaviorRector.php | 24 +- ...ParametersArrayToArrayCollectionRector.php | 46 +- ...ityAliasToClassConstantReferenceRector.php | 24 +- ...ositoryCallsByRepositoryPropertyRector.php | 46 +- ...ngeBigIntEntityPropertyToIntTypeRector.php | 22 +- ...rectDefaultTypesOnEntityPropertyRector.php | 36 +- ...argetEntityStringToClassConstantRector.php | 30 +- ...octrineCollectionDocTypeInEntityRector.php | 52 +- ...ateTimePropertyDateTimeInterfaceRector.php | 24 +- ...tDefaultPropertyAnnotationValuesRector.php | 28 +- .../TypedPropertyFromColumnTypeRector.php | 28 +- ...edPropertyFromToManyRelationTypeRector.php | 24 +- ...pedPropertyFromToOneRelationTypeRector.php | 28 +- .../src/Set/DoctrineSetList.php | 2 +- .../src/Type/RepositoryTypeFactory.php | 10 +- .../TypeAnalyzer/CollectionTypeFactory.php | 12 +- .../TypeAnalyzer/CollectionTypeResolver.php | 18 +- .../CollectionVarTagValueNodeResolver.php | 4 +- .../src/TypeAnalyzer/TypeFinder.php | 16 +- .../src/ValueObject/AssignToPropertyFetch.php | 6 +- .../ValueObject/PropertyNameAndPhpDocInfo.php | 4 +- .../rector/rector-generator/config/config.php | 26 +- .../rector-generator/monorepo-builder.php | 8 +- .../src/Command/GenerateCommand.php | 16 +- .../src/Command/InitRecipeCommand.php | 6 +- .../src/Exception/ConfigurationException.php | 2 +- .../Exception/ShouldNotHappenException.php | 2 +- .../src/FileSystem/ConfigFilesystem.php | 6 +- .../src/FileSystem/TemplateFileSystem.php | 22 +- .../src/Finder/TemplateFinder.php | 8 +- .../src/Generator/FileGenerator.php | 16 +- .../src/Generator/RectorGenerator.php | 4 +- .../src/Guard/OverrideGuard.php | 8 +- .../NodeFactory/ConfigurationNodeFactory.php | 2 +- .../ConfigureClassMethodFactory.php | 14 +- .../src/NodeFactory/NodeFactory.php | 28 +- .../src/Provider/RectorRecipeProvider.php | 20 +- .../src/TemplateInitializer.php | 2 +- .../src/TemplateVariablesFactory.php | 18 +- .../src/ValueObject/RectorRecipe.php | 20 +- .../templates/rector-recipe.php | 18 +- .../config/__Configuredconfigured_rule.php | 4 +- .../__Name__/config/configured_rule.php | 2 +- .../Rector/__Category__/__Name__.php | 12 +- .../rector/rector-laravel/config/config.php | 4 +- ...vel-array-str-functions-to-static-call.php | 4 +- .../config/sets/laravel-code-quality.php | 4 +- .../laravel-legacy-factories-to-classes.php | 8 +- .../sets/laravel-static-to-injection.php | 68 +- .../rector-laravel/config/sets/laravel50.php | 6 +- .../rector-laravel/config/sets/laravel51.php | 4 +- .../rector-laravel/config/sets/laravel52.php | 6 +- .../rector-laravel/config/sets/laravel53.php | 4 +- .../rector-laravel/config/sets/laravel54.php | 46 +- .../rector-laravel/config/sets/laravel55.php | 8 +- .../rector-laravel/config/sets/laravel56.php | 6 +- .../rector-laravel/config/sets/laravel57.php | 18 +- .../rector-laravel/config/sets/laravel58.php | 10 +- .../rector-laravel/config/sets/laravel60.php | 28 +- .../rector-laravel/config/sets/laravel70.php | 16 +- .../rector-laravel/config/sets/laravel80.php | 32 +- .../rector-laravel/config/sets/laravel90.php | 34 +- .../config/sets/level/up-to-laravel-51.php | 4 +- .../config/sets/level/up-to-laravel-52.php | 4 +- .../config/sets/level/up-to-laravel-53.php | 4 +- .../config/sets/level/up-to-laravel-54.php | 4 +- .../config/sets/level/up-to-laravel-55.php | 4 +- .../config/sets/level/up-to-laravel-56.php | 4 +- .../config/sets/level/up-to-laravel-57.php | 4 +- .../config/sets/level/up-to-laravel-58.php | 4 +- .../config/sets/level/up-to-laravel-60.php | 4 +- .../config/sets/level/up-to-laravel-70.php | 4 +- .../config/sets/level/up-to-laravel-80.php | 4 +- .../config/sets/level/up-to-laravel-90.php | 4 +- .../rector-laravel/monorepo-builder.php | 8 +- vendor/rector/rector-laravel/rector.php | 6 +- .../src/NodeFactory/AppAssignFactory.php | 16 +- .../NodeFactory/ModelFactoryNodeFactory.php | 46 +- .../RouterRegisterNodeAnalyzer.php | 6 +- ...AppArrayAccessToStandaloneAssignRector.php | 28 +- .../AddArgumentDefaultValueRector.php | 22 +- .../AddGenericReturnTypeToRelationsRector.php | 50 +- .../AddParentBootToModelClassMethodRector.php | 26 +- ...ntRegisterToEventServiceProviderRector.php | 26 +- ...ConsoleOutputFalseToConsoleTestsRector.php | 38 +- .../Class_/AnonymousMigrationsRector.php | 20 +- ...pertyDeferToDeferrableProviderToRector.php | 22 +- .../Class_/UnifyModelDatesWithCastsRector.php | 34 +- .../FactoryFuncCallToStaticCallRector.php | 22 +- .../HelperFuncCallToFacadeClassRector.php | 14 +- .../FuncCall/RemoveDumpDataDeadCodeRector.php | 18 +- ...ngeQueryWhereDateValueWithCarbonRector.php | 54 +- .../FactoryApplyingStatesRector.php | 22 +- .../RedirectBackToBackHelperRector.php | 32 +- .../RedirectRouteToToRouteHelperRector.php | 32 +- ...ispatchingMethodsWithJobChainingRector.php | 26 +- .../Namespace_/FactoryDefinitionRector.php | 60 +- .../New_/AddGuardToLoginEventRector.php | 24 +- .../OptionalToNullsafeOperatorRector.php | 38 +- .../MinutesToSecondsInCacheRector.php | 28 +- .../Redirect301ToPermanentRedirectRector.php | 20 +- .../RequestStaticValidateToInjectRector.php | 32 +- .../StaticCall/RouteActionCallableRector.php | 36 +- .../src/Set/LaravelLevelSetList.php | 2 +- .../rector-laravel/src/Set/LaravelSetList.php | 2 +- .../ValueObject/AddArgumentDefaultValue.php | 4 +- .../TypeToTimeMethodAndPosition.php | 4 +- vendor/rector/rector-nette/config/config.php | 8 +- .../rector/rector-nette/config/packages.php | 2 +- .../sets/contributte/apitte-attributes.php | 2 +- ...events-to-contributte-event-dispatcher.php | 10 +- .../sets/kdyby/kdyby-rabbit-mq-to-symfony.php | 6 +- ...-translator-to-contributte-translation.php | 8 +- .../rector-nette/config/sets/nette-24.php | 4 +- .../rector-nette/config/sets/nette-30.php | 44 +- .../sets/nette-30/nette-30-composer.php | 56 +- .../nette-30-dependency-injection.php | 6 +- .../sets/nette-30/nette-30-param-types.php | 8 +- .../sets/nette-30/nette-30-return-types.php | 6 +- .../rector-nette/config/sets/nette-31.php | 84 +-- .../config/sets/nette-code-quality.php | 14 +- .../config/sets/nette-remove-inject.php | 4 +- .../rector-nette/config/sets/nette-strict.php | 4 +- .../config/sets/nette-utils-code-quality.php | 22 +- .../sets/nette/annotations-to-attributes.php | 10 +- .../rector/rector-nette/monorepo-builder.php | 8 +- .../Contract/NeonNodeVisitorInterface.php | 2 +- .../Exception/NotImplementedYetException.php | 2 +- .../UnusedVirtualMethodException.php | 2 +- .../packages/NeonParser/NeonNodeTraverser.php | 8 +- .../NeonParser/NeonNodeTraverserFactory.php | 2 +- .../AbstractServiceNeonNodeVisitor.php | 2 +- .../packages/NeonParser/NeonParser.php | 4 +- .../NeonParser/Node/AbstractVirtualNode.php | 6 +- .../packages/NeonParser/Node/Service_.php | 4 +- .../Node/Service_/SetupMethodCall.php | 4 +- .../NeonParser/NodeFactory/ServiceFactory.php | 30 +- .../Printer/FormatPreservingNeonPrinter.php | 8 +- .../Services/ServiceTypeResolver.php | 10 +- vendor/rector/rector-nette/rector.php | 6 +- .../FormControlTypeResolverInterface.php | 2 +- .../Contract/Rector/LatteRectorInterface.php | 2 +- .../Contract/Rector/NeonRectorInterface.php | 4 +- .../src/FileProcessor/LatteFileProcessor.php | 12 +- .../src/FileProcessor/NeonFileProcessor.php | 12 +- .../ArrayDimFetchControlTypeResolver.php | 16 +- .../AssignDimFetchFormTypeResolver.php | 14 +- ...edVariablesMethodCallsFormTypeResolver.php | 12 +- .../ClassMethodFormTypeResolver.php | 18 +- .../ConstructorFormControlTypeResolver.php | 14 +- ...onentMethodCallFormControlTypeResolver.php | 20 +- ...actoryInterfaceFormControlTypeResolver.php | 24 +- .../NewFormControlTypeResolver.php | 14 +- ...ableMethodCallsFormControlTypeResolver.php | 12 +- .../ReturnFormControlTypeResolver.php | 14 +- ...InAnotherMethodFormControlTypeResolver.php | 24 +- ...ableConstructorFormControlTypeResolver.php | 16 +- .../VariableWithTypesFactory.php | 12 +- .../Kdyby/ContributeEventClassResolver.php | 18 +- .../src/Kdyby/Naming/EventClassNaming.php | 10 +- ...GetSubscribedEventsClassMethodAnalyzer.php | 10 +- .../EventValueObjectClassFactory.php | 32 +- .../GetSubscribedEventsArrayManipulator.php | 12 +- ...isteningClassMethodArgumentManipulator.php | 18 +- .../ListeningMethodsCollector.php | 40 +- ...eEventNamesInGetSubscribedEventsRector.php | 38 +- ...eEventManagerWithEventSubscriberRector.php | 36 +- .../WrapTransParameterNameRector.php | 24 +- .../ValueObject/EventClassAndClassMethod.php | 4 +- .../Kdyby/ValueObject/VariableWithType.php | 6 +- .../src/Latte/Parser/TemplateTypeParser.php | 8 +- .../src/Latte/Parser/VarTypeParser.php | 4 +- .../src/Naming/NetteControlNaming.php | 4 +- .../NodeAnalyzer/ArrayDimFetchAnalyzer.php | 6 +- .../src/NodeAnalyzer/ArrayDimFetchRenamer.php | 14 +- .../src/NodeAnalyzer/AssignAnalyzer.php | 24 +- .../src/NodeAnalyzer/BinaryOpAnalyzer.php | 12 +- .../ConditionalTemplateAssignReplacer.php | 4 +- .../NodeAnalyzer/ControlDimFetchAnalyzer.php | 24 +- .../src/NodeAnalyzer/MethodCallArgMerger.php | 8 +- .../NodeAnalyzer/MethodCallManipulator.php | 14 +- .../src/NodeAnalyzer/NetteClassAnalyzer.php | 12 +- .../NetteInjectPropertyAnalyzer.php | 18 +- .../src/NodeAnalyzer/PregMatchAllAnalyzer.php | 8 +- .../NodeAnalyzer/PropertyUsageAnalyzer.php | 12 +- .../src/NodeAnalyzer/RenderMethodAnalyzer.php | 6 +- .../src/NodeAnalyzer/ReturnAnalyzer.php | 10 +- .../src/NodeAnalyzer/StaticCallAnalyzer.php | 10 +- .../NodeAnalyzer/StrlenEndsWithResolver.php | 18 +- .../NodeAnalyzer/StrlenStartsWithResolver.php | 16 +- .../TemplatePropertyAssignCollector.php | 54 +- .../TemplatePropertyParametersReplacer.php | 4 +- .../ThisTemplatePropertyFetchAnalyzer.php | 12 +- .../CheckRequirementsClassMethodFactory.php | 12 +- .../ClassWithPublicPropertiesFactory.php | 10 +- ...arentGetterStmtsToExternalStmtsFactory.php | 16 +- .../RenderParameterArrayFactory.php | 8 +- .../src/NodeFinder/FormFieldsFinder.php | 50 +- .../FormOnSuccessCallbackFinder.php | 16 +- ...FormOnSuccessCallbackValuesParamFinder.php | 14 +- .../src/NodeFinder/FormVariableFinder.php | 12 +- .../src/NodeFinder/ParamFinder.php | 10 +- .../MethodNamesByInputNamesResolver.php | 2 +- ...nnotateMagicalControlArrayAccessRector.php | 36 +- ...tControlToGetComponentMethodCallRector.php | 22 +- ...tControlToAddComponentMethodCallRector.php | 26 +- .../MakeGetComponentAssignAnnotatedRector.php | 84 +-- ...eTemplateSetFileToTemplateRenderRector.php | 26 +- ...tAndNameFromComponentConstructorRector.php | 50 +- ...nderMethodParamToTypeDeclarationRector.php | 24 +- ...gicAssignToExplicitVariableArrayRector.php | 40 +- .../TranslateClassMethodToVariadicsRector.php | 40 +- .../src/Rector/Class_/FormDataRector.php | 32 +- ...sedOnPresenterTemplateParametersRector.php | 30 +- ...erToCheckRequirementsClassMethodRector.php | 24 +- .../MoveInjectToExistingConstructorRector.php | 34 +- ...sedOnPresenterTemplateParametersRector.php | 38 +- ...FilePutContentsToFileSystemWriteRector.php | 14 +- ...codeToNetteUtilsJsonDecodeEncodeRector.php | 22 +- .../PregFunctionToNetteUtilsStringsRector.php | 56 +- ...MatchFunctionToNetteUtilsStringsRector.php | 46 +- ...trlenFunctionToNetteUtilsStringsRector.php | 14 +- ...sWithFunctionToNetteUtilsStringsRector.php | 22 +- ...sWithFunctionToNetteUtilsStringsRector.php | 22 +- .../SubstrMinusToStringEndsWithRector.php | 28 +- ...ceTimeNumberWithDateTimeConstantRector.php | 16 +- .../Rector/Latte/RenameMethodLatteRector.php | 12 +- ...ddNextrasDatePickerToDateControlRector.php | 56 +- .../BuilderExpandToHelperExpandRector.php | 24 +- ...tGetByTypeToConstructorInjectionRector.php | 18 +- ...hirdArgumentTrueToAddMultiUploadRector.php | 18 +- .../MagicHtmlCallToAppendAttributeRector.php | 20 +- ...ultsInGetConfigCompilerExtensionRector.php | 18 +- ...tCookieDefaultArgumentToCoalesceRector.php | 18 +- ...SetClassWithArgumentToSetFactoryRector.php | 18 +- .../Rector/Neon/RenameMethodNeonRector.php | 16 +- .../StrposToStringsContainsRector.php | 26 +- ...etteInjectToConstructorInjectionRector.php | 32 +- .../src/Set/ContributteSetList.php | 2 +- .../rector-nette/src/Set/KdybySetList.php | 2 +- .../rector-nette/src/Set/NetteSetList.php | 2 +- .../AlwaysTemplateParameterAssign.php | 8 +- .../ValueObject/ContentExprAndNeedleExpr.php | 6 +- .../src/ValueObject/FuncCallAndExpr.php | 6 +- .../src/ValueObject/ParameterAssign.php | 4 +- .../rector/rector-phpoffice/config/config.php | 2 +- .../sets/phpexcel-to-phpspreadsheet.php | 48 +- .../rector-phpoffice/monorepo-builder.php | 8 +- vendor/rector/rector-phpoffice/rector.php | 6 +- .../ChangeConditionalGetConditionRector.php | 22 +- .../ChangeConditionalReturnedCellRector.php | 28 +- .../ChangeConditionalSetConditionRector.php | 24 +- ...licateStyleArrayToApplyFromArrayRector.php | 20 +- .../GetDefaultStyleToGetParentRector.php | 18 +- .../MethodCall/IncreaseColumnIndexRector.php | 30 +- .../RemoveSetTempDirOnExcelWriterRector.php | 16 +- .../AddRemovedDefaultValuesRector.php | 24 +- .../CellStaticToCoordinateRector.php | 18 +- .../StaticCall/ChangeChartRendererRector.php | 18 +- .../ChangeDataTypeForValueRector.php | 18 +- .../ChangeIOFactoryArgumentRector.php | 18 +- .../StaticCall/ChangePdfWriterRector.php | 24 +- ...geSearchLocationToRegisterReaderRector.php | 20 +- .../src/Set/PHPOfficeSetList.php | 2 +- .../PHPExcelMethodDefaultValues.php | 2 +- .../rector/rector-phpunit/config/config.php | 2 +- .../config/sets/level/up-to-phpunit-100.php | 6 +- .../config/sets/level/up-to-phpunit-50.php | 4 +- .../config/sets/level/up-to-phpunit-60.php | 6 +- .../config/sets/level/up-to-phpunit-70.php | 6 +- .../config/sets/level/up-to-phpunit-80.php | 6 +- .../config/sets/level/up-to-phpunit-90.php | 6 +- .../config/sets/phpunit-code-quality.php | 18 +- .../config/sets/phpunit-exception.php | 8 +- .../config/sets/phpunit-specific-method.php | 26 +- .../sets/phpunit-yield-data-provider.php | 4 +- .../rector-phpunit/config/sets/phpunit40.php | 4 +- .../rector-phpunit/config/sets/phpunit50.php | 4 +- .../rector-phpunit/config/sets/phpunit60.php | 14 +- .../rector-phpunit/config/sets/phpunit70.php | 6 +- .../config/sets/phpunit80-dms.php | 4 +- .../rector-phpunit/config/sets/phpunit80.php | 16 +- .../rector-phpunit/config/sets/phpunit90.php | 12 +- .../rector-phpunit/config/sets/phpunit91.php | 24 +- .../config/sets/remove-mocks.php | 10 +- vendor/rector/rector-phpunit/easy-ci.php | 6 +- .../rector-phpunit/monorepo-builder.php | 8 +- vendor/rector/rector-phpunit/rector.php | 26 +- .../src/NodeAnalyzer/AssertCallAnalyzer.php | 26 +- .../NodeAnalyzer/IdentifierManipulator.php | 6 +- .../NodeAnalyzer/MockedVariableAnalyzer.php | 16 +- .../src/NodeAnalyzer/SetUpMethodDecorator.php | 10 +- .../src/NodeAnalyzer/TestsNodeAnalyzer.php | 28 +- .../NodeFactory/ArgumentShiftingFactory.php | 4 +- .../src/NodeFactory/AssertCallFactory.php | 6 +- .../DataProviderClassMethodFactory.php | 16 +- .../ExpectExceptionCodeFactory.php | 6 +- .../NodeFactory/ExpectExceptionFactory.php | 6 +- .../ExpectExceptionMessageFactory.php | 6 +- .../ExpectExceptionMessageRegExpFactory.php | 10 +- .../ExpectExceptionMethodCallFactory.php | 14 +- .../NodeFactory/SetUpClassMethodFactory.php | 12 +- .../ParamAndArgFromArrayResolver.php | 36 +- .../SetUpClassMethodNodeManipulator.php | 8 +- .../src/NodeManipulator/StmtManipulator.php | 4 +- .../src/PhpDoc/PhpDocValueToNodeMapper.php | 6 +- ...rformAssertionToNonAssertingTestRector.php | 22 +- .../ClassMethod/ExceptionAnnotationRector.php | 16 +- .../RemoveEmptyTestMethodRector.php | 16 +- ...stAnnotationWithPrefixedFunctionRector.php | 18 +- .../TryCatchToExpectExceptionRector.php | 32 +- .../Rector/Class_/AddProphecyTraitRector.php | 20 +- .../Class_/AddSeeTestAnnotationRector.php | 32 +- .../ArrayArgumentToDataProviderRector.php | 76 +-- ...structClassMethodToSetUpTestCaseRector.php | 26 +- .../RemoveDataProviderTestPrefixRector.php | 30 +- .../Class_/TestListenerToHooksRector.php | 22 +- .../SimplifyForeachInstanceOfRector.php | 28 +- .../AssertCompareToSpecificMethodRector.php | 32 +- ...AssertComparisonToSpecificMethodRector.php | 36 +- ...lsParameterToSpecificMethodsTypeRector.php | 16 +- .../MethodCall/AssertEqualsToSameRector.php | 20 +- .../AssertFalseStrposToContainsRector.php | 22 +- .../AssertInstanceOfComparisonRector.php | 22 +- .../AssertIssetToSpecificMethodRector.php | 42 +- .../MethodCall/AssertNotOperatorRector.php | 20 +- .../MethodCall/AssertPropertyExistsRector.php | 28 +- .../Rector/MethodCall/AssertRegExpRector.php | 30 +- .../AssertResourceToClosedResourceRector.php | 16 +- ...sertSameBoolNullToSpecificMethodRector.php | 22 +- ...rtSameTrueFalseToAssertTrueFalseRector.php | 20 +- ...alseInternalTypeToSpecificMethodRector.php | 22 +- .../AssertTrueFalseToSpecificMethodRector.php | 32 +- .../CreateMockToCreateStubRector.php | 24 +- .../DelegateExceptionArgumentsRector.php | 18 +- .../MethodCall/ExplicitPhpErrorApiRector.php | 22 +- ...etMockBuilderGetMockToCreateMockRector.php | 22 +- .../RemoveExpectAnyFromMockRector.php | 20 +- .../RemoveSetMethodsMethodCallRector.php | 18 +- ...AssertArraySubsetWithDmsPolyfillRector.php | 16 +- .../SpecificAssertContainsRector.php | 26 +- ...ficAssertContainsWithoutIdentityRector.php | 20 +- .../SpecificAssertInternalTypeRector.php | 20 +- .../UseSpecificWillMethodRector.php | 30 +- .../src/Rector/StaticCall/GetMockRector.php | 22 +- .../src/Set/PHPUnitLevelSetList.php | 2 +- .../rector-phpunit/src/Set/PHPUnitSetList.php | 2 +- .../ArrayArgumentToDataProvider.php | 4 +- .../src/ValueObject/ParamAndArg.php | 6 +- .../parse-missing-return-types-to-rules.php | 17 +- .../rector/rector-symfony/config/config.php | 6 +- .../sets/jms/annotations-to-attributes.php | 4 +- .../config/sets/jms/remove-jms-inject.php | 4 +- .../sets/sensiolabs/framework-extra-61.php | 4 +- .../swiftmailer-to-symfony-mailer.php | 6 +- .../config/sets/swiftmailer/swiftmailer60.php | 4 +- .../symfony/annotations-to-attributes.php | 12 +- .../sets/symfony/level/up-to-symfony-26.php | 4 +- .../sets/symfony/level/up-to-symfony-28.php | 4 +- .../sets/symfony/level/up-to-symfony-30.php | 4 +- .../sets/symfony/level/up-to-symfony-31.php | 4 +- .../sets/symfony/level/up-to-symfony-32.php | 4 +- .../sets/symfony/level/up-to-symfony-33.php | 4 +- .../sets/symfony/level/up-to-symfony-34.php | 4 +- .../sets/symfony/level/up-to-symfony-40.php | 4 +- .../sets/symfony/level/up-to-symfony-41.php | 4 +- .../sets/symfony/level/up-to-symfony-42.php | 4 +- .../sets/symfony/level/up-to-symfony-43.php | 4 +- .../sets/symfony/level/up-to-symfony-44.php | 4 +- .../sets/symfony/level/up-to-symfony-50.php | 4 +- .../sets/symfony/level/up-to-symfony-51.php | 4 +- .../sets/symfony/level/up-to-symfony-52.php | 4 +- .../sets/symfony/level/up-to-symfony-53.php | 4 +- .../sets/symfony/level/up-to-symfony-54.php | 4 +- .../sets/symfony/level/up-to-symfony-60.php | 4 +- .../sets/symfony/symfony-code-quality.php | 12 +- .../symfony/symfony-constructor-injection.php | 8 +- .../config/sets/symfony/symfony-strict.php | 4 +- .../config/sets/symfony/symfony26.php | 4 +- .../config/sets/symfony/symfony28.php | 14 +- .../config/sets/symfony/symfony30.php | 102 +-- .../config/sets/symfony/symfony31.php | 4 +- .../config/sets/symfony/symfony32.php | 4 +- .../config/sets/symfony/symfony33.php | 10 +- .../config/sets/symfony/symfony34.php | 6 +- .../config/sets/symfony/symfony40.php | 16 +- .../config/sets/symfony/symfony41.php | 22 +- .../config/sets/symfony/symfony42.php | 28 +- .../config/sets/symfony/symfony43.php | 22 +- .../config/sets/symfony/symfony44.php | 6 +- .../config/sets/symfony/symfony50-types.php | 192 +++--- .../config/sets/symfony/symfony50.php | 6 +- .../config/sets/symfony/symfony51.php | 24 +- .../symfony52-validator-attributes.php | 4 +- .../config/sets/symfony/symfony52.php | 30 +- .../config/sets/symfony/symfony53.php | 30 +- .../config/sets/symfony/symfony54.php | 22 +- .../symfony/symfony6/symfony-return-types.php | 272 ++++---- .../config/sets/symfony/symfony60.php | 20 +- .../twig/twig-underscore-to-namespace.php | 6 +- .../config/sets/twig/twig112.php | 4 +- .../config/sets/twig/twig127.php | 4 +- .../config/sets/twig/twig134.php | 4 +- .../config/sets/twig/twig140.php | 2 +- .../config/sets/twig/twig20.php | 4 +- .../config/sets/twig/twig240.php | 2 +- vendor/rector/rector-symfony/easy-ci.php | 6 +- vendor/rector/rector-symfony/rector.php | 10 +- .../ListenerServiceDefinitionProvider.php | 6 +- .../NodeAnalyzer/ControllerMethodAnalyzer.php | 6 +- .../Symfony/ContainerServiceProvider.php | 8 +- .../Symfony/Routing/SymfonyRoutesProvider.php | 8 +- .../src/BundleClassResolver.php | 12 +- .../EventReferenceToMethodNameInterface.php | 2 +- .../src/DataProvider/ServiceMapProvider.php | 6 +- .../InvalidConfigurationException.php | 2 +- .../XmlContainerNotExistsException.php | 2 +- .../FormTypeStringToTypeProvider.php | 6 +- .../src/Helper/TemplateGuesser.php | 24 +- .../ConstraintAnnotationResolver.php | 16 +- .../DependencyInjectionMethodCallAnalyzer.php | 16 +- .../FormAddMethodCallAnalyzer.php | 6 +- .../NodeAnalyzer/FormCollectionAnalyzer.php | 6 +- ...InstanceToFormClassConstFetchConverter.php | 22 +- .../NodeAnalyzer/FormOptionsArrayMatcher.php | 4 +- .../CreateFormTypeOptionsArgMover.php | 16 +- .../FormType/FormTypeClassResolver.php | 8 +- ...ActiveClassElementsClassMethodResolver.php | 24 +- .../LiteralCallLikeConstFetchReplacer.php | 6 +- .../RouteRequiredParamNameToTypesResolver.php | 26 +- .../ServiceTypeMethodCallResolver.php | 14 +- .../NodeAnalyzer/SymfonyControllerFilter.php | 4 +- .../NodeAnalyzer/SymfonyTestCaseAnalyzer.php | 6 +- .../DoctrineAnnotationFromNewFactory.php | 12 +- .../DoctrineAnnotationKeyToValuesResolver.php | 12 +- .../NodeFactory/ArrayFromCompactFactory.php | 8 +- .../BareLogoutClassMethodFactory.php | 16 +- .../src/NodeFactory/EventReferenceFactory.php | 6 +- .../BuildFormOptionAssignsFactory.php | 6 +- .../GetSubscribedEventsClassMethodFactory.php | 70 +- .../ActiveClassElementsFilter.php | 14 +- .../InvokableControllerClassFactory.php | 28 +- .../InvokableControllerNameFactory.php | 8 +- .../OnLogoutClassMethodFactory.php | 14 +- .../OnSuccessLogoutClassMethodFactory.php | 34 +- .../src/NodeFactory/ThisRenderFactory.php | 32 +- .../src/NodeFinder/EmptyReturnNodeFinder.php | 8 +- .../ConstructorDependencyRemover.php | 16 +- .../SymfonyRouteTagValueNodeFactory.php | 4 +- .../src/Printer/NeighbourClassLikePrinter.php | 16 +- .../BinaryOp/ResponseStatusCodeRector.php | 54 +- ...oleExceptionToErrorEventConstantRector.php | 20 +- .../ClassMethod/ActionSuffixRemoverRector.php | 22 +- .../ClassMethod/AddRouteAnnotationRector.php | 38 +- .../ConsoleExecuteReturnIntRector.php | 82 +-- .../ClassMethod/FormTypeGetParentRector.php | 36 +- .../Rector/ClassMethod/GetRequestRector.php | 58 +- ...ethodAnnotationToRouteAnnotationRector.php | 32 +- .../ParamTypeFromRouteRequiredRegexRector.php | 22 +- .../RemoveDefaultGetBlockPrefixRector.php | 38 +- .../RemoveServiceFromSensioRouteRector.php | 16 +- ...nderMethodParamToTypeDeclarationRector.php | 24 +- ...SensioRouteAnnotationWithSymfonyRector.php | 22 +- ...sponseReturnTypeControllerActionRector.php | 20 +- ...tionBuilderToRoutingConfiguratorRector.php | 36 +- .../TemplateAnnotationToThisRenderRector.php | 94 +-- ...geFileLoaderInExtensionAndKernelRector.php | 46 +- .../CommandPropertyToAttributeRector.php | 34 +- .../EventListenerToEventSubscriberRector.php | 48 +- .../FormTypeWithDependencyToOptionsRector.php | 34 +- .../Class_/InvokableControllerRector.php | 28 +- ...oadValidatorMetadataToAnnotationRector.php | 22 +- ...utHandlerToLogoutEventSubscriberRector.php | 28 +- ...ssHandlerToLogoutEventSubscriberRector.php | 28 +- .../Rector/Class_/MakeCommandLazyRector.php | 74 +-- .../ConstFetch/ConstraintUrlOptionRector.php | 26 +- .../FuncCall/ReplaceServiceArgumentRector.php | 22 +- ...izationCheckerIsGrantedExtractorRector.php | 38 +- .../CascadeValidationFormBuilderRector.php | 52 +- ...ypeOptionNameFromTypeToEntryTypeRector.php | 22 +- ...StringCollectionOptionToConstantRector.php | 22 +- ...ntainerBuilderCompileEnvArgumentRector.php | 16 +- ...ntainerGetToConstructorInjectionRector.php | 18 +- ...nitionAliasSetPrivateToSetPublicRector.php | 20 +- .../FormBuilderSetDataMapperRector.php | 22 +- .../Rector/MethodCall/FormIsValidRector.php | 30 +- .../FormTypeInstanceToClassConstRector.php | 24 +- .../GetHelperControllerToServiceRector.php | 42 +- ...tParameterToConstructorInjectionRector.php | 28 +- .../GetToConstructorInjectionRector.php | 16 +- ...LiteralGetToRequestClassConstantRector.php | 34 +- .../MakeDispatchFirstArgumentEventRector.php | 42 +- .../Rector/MethodCall/OptionNameRector.php | 22 +- .../ProcessBuilderGetProcessRector.php | 16 +- .../ReadOnlyOptionToAttributeRector.php | 22 +- .../MethodCall/RedirectToRouteRector.php | 26 +- ...xtractorEnableMagicCallExtractorRector.php | 44 +- .../StringFormTypeToClassRector.php | 20 +- .../SwiftCreateMessageToNewEmailRector.php | 30 +- ...wiftSetBodyToHtmlPlainMethodCallRector.php | 22 +- ...orBuilderEnableAnnotationMappingRector.php | 20 +- .../VarDumperTestTraitMethodArgsRector.php | 22 +- .../WebTestCaseAssertIsSuccessfulRector.php | 20 +- .../WebTestCaseAssertResponseCodeRector.php | 26 +- ...stCaseAssertSelectorTextContainsRector.php | 20 +- ...tyAccessorCreationBooleanToFlagsRector.php | 28 +- .../PropertyPathMapperToDataMapperRector.php | 24 +- .../Rector/New_/RootNodeTreeBuilderRector.php | 36 +- .../StringToArrayArgumentProcessRector.php | 60 +- ...ctPropertyToConstructorInjectionRector.php | 28 +- .../Return_/SimpleFunctionAndFilterRector.php | 50 +- .../AddMessageToEqualsResponseCodeRector.php | 34 +- ...yFileResponseCreateToNewInstanceRector.php | 18 +- .../src/Rector/StaticCall/ParseFileRector.php | 36 +- .../ProcessBuilderInstanceRector.php | 18 +- .../rector-symfony/src/Set/JMSSetList.php | 2 +- .../src/Set/SensiolabsSetList.php | 2 +- .../src/Set/SwiftmailerSetList.php | 2 +- .../src/Set/SymfonyLevelSetList.php | 2 +- .../rector-symfony/src/Set/SymfonySetList.php | 2 +- .../rector-symfony/src/Set/TwigSetList.php | 2 +- .../ArrayUnionResponseTypeAnalyzer.php | 12 +- .../TypeAnalyzer/ContainerAwareAnalyzer.php | 6 +- .../src/TypeAnalyzer/ControllerAnalyzer.php | 22 +- .../src/TypeAnalyzer/JMSDITypeResolver.php | 24 +- .../ReturnTypeDeclarationUpdater.php | 20 +- .../EventReferenceToMethodName.php | 6 +- ...EventReferenceToMethodNameWithPriority.php | 6 +- .../ValueObject/ReplaceServiceArgument.php | 4 +- .../src/ValueObject/ServiceDefinition.php | 2 +- .../src/ValueObject/ServiceMap/ServiceMap.php | 8 +- .../rector-symfony/src/ValueObject/Tag.php | 2 +- .../src/ValueObject/Tag/EventListenerTag.php | 2 +- .../ValueObjectFactory/ServiceMapFactory.php | 32 +- vendor/scoper-autoload.php | 170 +---- vendor/sebastian/diff/src/Chunk.php | 4 +- vendor/sebastian/diff/src/Differ.php | 88 +-- .../src/Exception/ConfigurationException.php | 6 +- .../diff/src/Exception/Exception.php | 2 +- .../Exception/InvalidArgumentException.php | 2 +- ...ientLongestCommonSubsequenceCalculator.php | 28 +- .../src/Output/AbstractChunkOutputBuilder.php | 4 +- .../diff/src/Output/DiffOnlyOutputBuilder.php | 30 +- .../Output/StrictUnifiedDiffOutputBuilder.php | 88 +-- .../src/Output/UnifiedDiffOutputBuilder.php | 72 +- vendor/sebastian/diff/src/Parser.php | 32 +- ...ientLongestCommonSubsequenceCalculator.php | 12 +- .../symfony/config/Builder/ClassBuilder.php | 6 +- .../config/Builder/ConfigBuilderGenerator.php | 86 +-- .../ConfigBuilderGeneratorInterface.php | 2 +- vendor/symfony/config/ConfigCache.php | 4 +- vendor/symfony/config/ConfigCacheFactory.php | 6 +- .../config/ConfigCacheFactoryInterface.php | 2 +- .../symfony/config/Definition/ArrayNode.php | 22 +- vendor/symfony/config/Definition/BaseNode.php | 18 +- .../symfony/config/Definition/BooleanNode.php | 4 +- .../Builder/ArrayNodeDefinition.php | 58 +- .../Builder/BooleanNodeDefinition.php | 8 +- .../Builder/BuilderAwareInterface.php | 2 +- .../Definition/Builder/EnumNodeDefinition.php | 4 +- .../config/Definition/Builder/ExprBuilder.php | 4 +- .../Builder/FloatNodeDefinition.php | 4 +- .../Builder/IntegerNodeDefinition.php | 4 +- .../Definition/Builder/MergeBuilder.php | 2 +- .../config/Definition/Builder/NodeBuilder.php | 26 +- .../Definition/Builder/NodeDefinition.php | 36 +- .../Builder/NormalizationBuilder.php | 4 +- .../Builder/NumericNodeDefinition.php | 4 +- .../Builder/ParentNodeDefinitionInterface.php | 6 +- .../Builder/ScalarNodeDefinition.php | 4 +- .../config/Definition/Builder/TreeBuilder.php | 8 +- .../Definition/Builder/ValidationBuilder.php | 4 +- .../Builder/VariableNodeDefinition.php | 8 +- .../Definition/ConfigurableInterface.php | 2 +- .../config/Definition/Configuration.php | 12 +- .../Configurator/DefinitionConfigurator.php | 2 +- .../Definition/Dumper/XmlReferenceDumper.php | 34 +- .../Definition/Dumper/YamlReferenceDumper.php | 52 +- vendor/symfony/config/Definition/EnumNode.php | 6 +- .../Exception/DuplicateKeyException.php | 2 +- .../Exception/ForbiddenOverwriteException.php | 2 +- .../InvalidConfigurationException.php | 2 +- .../Exception/InvalidDefinitionException.php | 2 +- .../Exception/InvalidTypeException.php | 2 +- .../Exception/UnsetKeyException.php | 2 +- .../symfony/config/Definition/FloatNode.php | 4 +- .../symfony/config/Definition/IntegerNode.php | 4 +- .../Loader/DefinitionFileLoader.php | 20 +- .../symfony/config/Definition/NumericNode.php | 6 +- .../symfony/config/Definition/Processor.php | 4 +- .../Definition/PrototypeNodeInterface.php | 2 +- .../config/Definition/PrototypedArrayNode.php | 32 +- .../symfony/config/Definition/ScalarNode.php | 4 +- .../config/Definition/VariableNode.php | 6 +- ...LoaderImportCircularReferenceException.php | 2 +- vendor/symfony/config/FileLocator.php | 6 +- .../config/Loader/DelegatingLoader.php | 6 +- vendor/symfony/config/Loader/FileLoader.php | 20 +- .../symfony/config/Loader/GlobFileLoader.php | 2 +- vendor/symfony/config/Loader/Loader.php | 10 +- .../symfony/config/Loader/LoaderInterface.php | 2 +- .../symfony/config/Loader/LoaderResolver.php | 4 +- .../Resource/ClassExistenceResource.php | 2 +- .../config/Resource/ComposerResource.php | 2 +- .../config/Resource/DirectoryResource.php | 2 +- .../config/Resource/FileExistenceResource.php | 2 +- .../symfony/config/Resource/FileResource.php | 2 +- .../symfony/config/Resource/GlobResource.php | 10 +- .../Resource/ReflectionClassResource.php | 14 +- .../Resource/SelfCheckingResourceChecker.php | 8 +- .../SelfCheckingResourceInterface.php | 2 +- .../config/ResourceCheckerConfigCache.php | 8 +- .../ResourceCheckerConfigCacheFactory.php | 6 +- .../config/ResourceCheckerInterface.php | 4 +- .../Util/Exception/InvalidXmlException.php | 2 +- vendor/symfony/config/Util/XmlUtils.php | 14 +- vendor/symfony/console/Application.php | 190 +++--- .../console/CI/GithubActionReporter.php | 2 +- vendor/symfony/console/Color.php | 10 +- vendor/symfony/console/Command/Command.php | 62 +- .../console/Command/CompleteCommand.php | 30 +- .../console/Command/DumpCompletionCommand.php | 14 +- .../symfony/console/Command/HelpCommand.php | 18 +- .../symfony/console/Command/LazyCommand.php | 14 +- .../symfony/console/Command/ListCommand.php | 16 +- .../symfony/console/Command/LockableTrait.php | 14 +- .../CommandLoader/CommandLoaderInterface.php | 2 +- .../CommandLoader/ContainerCommandLoader.php | 8 +- .../CommandLoader/FactoryCommandLoader.php | 6 +- .../console/Completion/CompletionInput.php | 8 +- .../Completion/CompletionSuggestions.php | 4 +- .../Output/BashCompletionOutput.php | 4 +- .../Output/CompletionOutputInterface.php | 2 +- .../Output/FishCompletionOutput.php | 4 +- vendor/symfony/console/ConsoleEvents.php | 2 +- vendor/symfony/console/Cursor.php | 34 +- .../AddConsoleCommandPass.php | 24 +- .../Descriptor/ApplicationDescription.php | 6 +- .../symfony/console/Descriptor/Descriptor.php | 28 +- .../Descriptor/DescriptorInterface.php | 2 +- .../console/Descriptor/JsonDescriptor.php | 22 +- .../console/Descriptor/MarkdownDescriptor.php | 26 +- .../console/Descriptor/TextDescriptor.php | 48 +- .../console/Descriptor/XmlDescriptor.php | 24 +- .../Exception/CommandNotFoundException.php | 2 +- .../Exception/InvalidArgumentException.php | 2 +- .../Exception/InvalidOptionException.php | 2 +- .../console/Exception/LogicException.php | 2 +- .../Exception/MissingInputException.php | 2 +- .../Exception/NamespaceNotFoundException.php | 2 +- .../console/Exception/RuntimeException.php | 2 +- .../console/Formatter/NullOutputFormatter.php | 8 +- .../Formatter/NullOutputFormatterStyle.php | 2 +- .../console/Formatter/OutputFormatter.php | 30 +- .../Formatter/OutputFormatterInterface.php | 4 +- .../Formatter/OutputFormatterStyle.php | 16 +- .../Formatter/OutputFormatterStyleStack.php | 18 +- .../WrappableOutputFormatterInterface.php | 2 +- .../console/Helper/DebugFormatterHelper.php | 2 +- .../console/Helper/DescriptorHelper.php | 10 +- vendor/symfony/console/Helper/Dumper.php | 8 +- .../console/Helper/FormatterHelper.php | 4 +- vendor/symfony/console/Helper/Helper.php | 14 +- .../console/Helper/HelperInterface.php | 4 +- vendor/symfony/console/Helper/HelperSet.php | 6 +- .../console/Helper/InputAwareHelper.php | 4 +- .../symfony/console/Helper/ProcessHelper.php | 24 +- vendor/symfony/console/Helper/ProgressBar.php | 40 +- .../console/Helper/ProgressIndicator.php | 24 +- .../symfony/console/Helper/QuestionHelper.php | 68 +- .../console/Helper/SymfonyQuestionHelper.php | 24 +- vendor/symfony/console/Helper/Table.php | 124 ++-- vendor/symfony/console/Helper/TableCell.php | 8 +- .../symfony/console/Helper/TableCellStyle.php | 4 +- .../symfony/console/Helper/TableSeparator.php | 2 +- vendor/symfony/console/Helper/TableStyle.php | 4 +- vendor/symfony/console/Input/ArgvInput.php | 18 +- vendor/symfony/console/Input/ArrayInput.php | 12 +- vendor/symfony/console/Input/Input.php | 18 +- .../symfony/console/Input/InputArgument.php | 10 +- .../console/Input/InputAwareInterface.php | 2 +- .../symfony/console/Input/InputDefinition.php | 34 +- .../symfony/console/Input/InputInterface.php | 2 +- vendor/symfony/console/Input/InputOption.php | 20 +- .../Input/StreamableInputInterface.php | 2 +- vendor/symfony/console/Input/StringInput.php | 4 +- .../symfony/console/Logger/ConsoleLogger.php | 12 +- .../symfony/console/Output/BufferedOutput.php | 2 +- .../symfony/console/Output/ConsoleOutput.php | 18 +- .../console/Output/ConsoleOutputInterface.php | 8 +- .../console/Output/ConsoleSectionOutput.php | 12 +- vendor/symfony/console/Output/NullOutput.php | 8 +- vendor/symfony/console/Output/Output.php | 16 +- .../console/Output/OutputInterface.php | 4 +- .../symfony/console/Output/StreamOutput.php | 6 +- .../console/Output/TrimmedBufferOutput.php | 6 +- .../console/Question/ChoiceQuestion.php | 8 +- .../console/Question/ConfirmationQuestion.php | 2 +- vendor/symfony/console/Question/Question.php | 6 +- .../console/SingleCommandApplication.php | 6 +- vendor/symfony/console/Style/OutputStyle.php | 14 +- vendor/symfony/console/Style/SymfonyStyle.php | 52 +- vendor/symfony/contracts/Cache/CacheTrait.php | 12 +- .../contracts/Cache/CallbackInterface.php | 2 +- .../Cache/TagAwareCacheInterface.php | 2 +- .../contracts/EventDispatcher/Event.php | 2 +- .../EventDispatcherInterface.php | 2 +- .../Exception/ClientExceptionInterface.php | 2 +- .../Exception/DecodingExceptionInterface.php | 2 +- .../Exception/HttpExceptionInterface.php | 4 +- .../RedirectionExceptionInterface.php | 2 +- .../Exception/ServerExceptionInterface.php | 2 +- .../Exception/TimeoutExceptionInterface.php | 2 +- .../Exception/TransportExceptionInterface.php | 2 +- .../HttpClient/HttpClientInterface.php | 4 +- .../HttpClient/ResponseStreamInterface.php | 4 +- .../HttpClient/Test/HttpClientTestCase.php | 114 ++-- .../HttpClient/Test/TestHttpServer.php | 6 +- .../contracts/Service/ServiceLocatorTrait.php | 12 +- .../Service/ServiceProviderInterface.php | 2 +- .../Service/ServiceSubscriberTrait.php | 8 +- .../Service/Test/ServiceLocatorTest.php | 8 +- .../contracts/Tests/Cache/CacheTraitTest.php | 34 +- .../Service/ServiceSubscriberTraitTest.php | 38 +- .../Translation/Test/TranslatorTest.php | 8 +- .../Translation/TranslatableInterface.php | 2 +- .../contracts/Translation/TranslatorTrait.php | 4 +- vendor/symfony/dependency-injection/Alias.php | 4 +- .../Argument/BoundArgument.php | 2 +- .../Argument/IteratorArgument.php | 2 +- .../Argument/ReferenceSetArgumentTrait.php | 6 +- .../Argument/ServiceClosureArgument.php | 4 +- .../Argument/ServiceLocator.php | 2 +- .../Argument/ServiceLocatorArgument.php | 6 +- .../Argument/TaggedIteratorArgument.php | 2 +- .../Attribute/AsDecorator.php | 4 +- .../Attribute/AutoconfigureTag.php | 2 +- .../Attribute/Autowire.php | 10 +- .../dependency-injection/Attribute/Target.php | 2 +- .../dependency-injection/ChildDefinition.php | 4 +- .../Compiler/AbstractRecursivePass.php | 70 +- .../AliasDeprecatedPublicServicesPass.php | 12 +- .../Compiler/AnalyzeServiceReferencesPass.php | 20 +- .../AttributeAutoconfigurationPass.php | 16 +- .../Compiler/AutoAliasServicePass.php | 8 +- .../Compiler/AutowireAsDecoratorPass.php | 10 +- .../Compiler/AutowirePass.php | 82 +-- .../Compiler/AutowireRequiredMethodsPass.php | 6 +- .../AutowireRequiredPropertiesPass.php | 8 +- .../Compiler/CheckArgumentsValidityPass.php | 16 +- .../Compiler/CheckCircularReferencesPass.php | 6 +- .../Compiler/CheckDefinitionValidityPass.php | 22 +- ...xceptionOnInvalidReferenceBehaviorPass.php | 14 +- .../Compiler/CheckReferenceValidityPass.php | 8 +- .../Compiler/CheckTypeDeclarationsPass.php | 50 +- .../Compiler/Compiler.php | 16 +- .../Compiler/CompilerPassInterface.php | 2 +- .../Compiler/DecoratorServicePass.php | 20 +- .../Compiler/DefinitionErrorExceptionPass.php | 8 +- .../Compiler/ExtensionCompilerPass.php | 6 +- .../Compiler/InlineServiceDefinitionsPass.php | 20 +- .../MergeExtensionConfigurationPass.php | 44 +- .../Compiler/PassConfig.php | 18 +- .../Compiler/PriorityTaggedServiceTrait.php | 26 +- .../RegisterAutoconfigureAttributesPass.php | 16 +- .../Compiler/RegisterEnvVarProcessorsPass.php | 22 +- .../Compiler/RegisterReverseContainerPass.php | 16 +- .../RegisterServiceSubscribersPass.php | 36 +- .../RemoveAbstractDefinitionsPass.php | 4 +- .../Compiler/RemovePrivateAliasesPass.php | 4 +- .../Compiler/RemoveUnusedDefinitionsPass.php | 8 +- .../ReplaceAliasByActualDefinitionPass.php | 12 +- .../Compiler/ResolveBindingsPass.php | 30 +- .../Compiler/ResolveChildDefinitionsPass.php | 24 +- .../Compiler/ResolveClassPass.php | 8 +- .../Compiler/ResolveDecoratorStackPass.php | 24 +- .../Compiler/ResolveEnvPlaceholdersPass.php | 4 +- .../Compiler/ResolveFactoryClassPass.php | 6 +- .../Compiler/ResolveHotPathPass.php | 10 +- .../ResolveInstanceofConditionalsPass.php | 16 +- .../Compiler/ResolveInvalidReferencesPass.php | 28 +- .../Compiler/ResolveNamedArgumentsPass.php | 22 +- .../Compiler/ResolveNoPreloadPass.php | 8 +- .../ResolveParameterPlaceHoldersPass.php | 10 +- .../ResolveReferencesToAliasesPass.php | 14 +- .../ResolveServiceSubscribersPass.php | 8 +- .../ResolveTaggedIteratorArgumentPass.php | 4 +- .../Compiler/ServiceLocatorTagPass.php | 36 +- .../Compiler/ServiceReferenceGraph.php | 12 +- .../Compiler/ServiceReferenceGraphEdge.php | 6 +- .../Compiler/ServiceReferenceGraphNode.php | 8 +- .../Compiler/ValidateEnvPlaceholdersPass.php | 18 +- .../Config/ContainerParametersResource.php | 2 +- .../ContainerParametersResourceChecker.php | 10 +- .../dependency-injection/Container.php | 42 +- .../ContainerAwareInterface.php | 2 +- .../ContainerAwareTrait.php | 2 +- .../dependency-injection/ContainerBuilder.php | 234 +++---- .../ContainerInterface.php | 2 +- .../dependency-injection/Definition.php | 28 +- .../dependency-injection/Dumper/Dumper.php | 4 +- .../Dumper/GraphvizDumper.php | 20 +- .../dependency-injection/Dumper/PhpDumper.php | 230 +++---- .../dependency-injection/Dumper/Preloader.php | 2 +- .../dependency-injection/Dumper/XmlDumper.php | 58 +- .../Dumper/YamlDumper.php | 68 +- .../dependency-injection/EnvVarProcessor.php | 46 +- .../Exception/AutowiringFailedException.php | 2 +- .../Exception/BadMethodCallException.php | 2 +- .../Exception/EnvNotFoundException.php | 2 +- .../Exception/EnvParameterException.php | 2 +- .../Exception/ExceptionInterface.php | 2 +- .../Exception/InvalidArgumentException.php | 2 +- .../InvalidParameterTypeException.php | 2 +- .../Exception/LogicException.php | 2 +- .../Exception/OutOfBoundsException.php | 2 +- .../ParameterCircularReferenceException.php | 2 +- .../Exception/ParameterNotFoundException.php | 2 +- .../Exception/RuntimeException.php | 2 +- .../ServiceCircularReferenceException.php | 2 +- .../Exception/ServiceNotFoundException.php | 2 +- .../Extension/AbstractExtension.php | 20 +- .../ConfigurableExtensionInterface.php | 6 +- .../ConfigurationExtensionInterface.php | 2 +- .../Extension/Extension.php | 22 +- .../Extension/ExtensionInterface.php | 2 +- .../Extension/ExtensionTrait.php | 14 +- .../Extension/PrependExtensionInterface.php | 2 +- .../Instantiator/InstantiatorInterface.php | 2 +- .../Instantiator/RealServiceInstantiator.php | 4 +- .../LazyProxy/PhpDumper/DumperInterface.php | 6 +- .../LazyProxy/PhpDumper/NullDumper.php | 8 +- .../LazyProxy/ProxyHelper.php | 2 +- .../Loader/ClosureLoader.php | 4 +- .../Configurator/AbstractConfigurator.php | 26 +- .../AbstractServiceConfigurator.php | 18 +- .../Loader/Configurator/AliasConfigurator.php | 4 +- .../ClosureReferenceConfigurator.php | 2 +- .../Configurator/ContainerConfigurator.php | 64 +- .../Configurator/DefaultsConfigurator.php | 10 +- .../Loader/Configurator/EnvConfigurator.php | 2 +- .../InlineServiceConfigurator.php | 4 +- .../Configurator/InstanceofConfigurator.php | 4 +- .../Configurator/ParametersConfigurator.php | 8 +- .../Configurator/PrototypeConfigurator.php | 6 +- .../Configurator/ReferenceConfigurator.php | 10 +- .../Configurator/ServiceConfigurator.php | 4 +- .../Configurator/ServicesConfigurator.php | 44 +- .../Loader/Configurator/Traits/BindTrait.php | 4 +- .../Configurator/Traits/DecorateTrait.php | 2 +- .../Configurator/Traits/FactoryTrait.php | 4 +- .../Configurator/Traits/ParentTrait.php | 4 +- .../Loader/Configurator/Traits/TagTrait.php | 4 +- .../Loader/DirectoryLoader.php | 2 +- .../Loader/FileLoader.php | 34 +- .../Loader/GlobFileLoader.php | 2 +- .../Loader/IniFileLoader.php | 6 +- .../Loader/PhpFileLoader.php | 46 +- .../Loader/XmlFileLoader.php | 134 ++-- .../Loader/YamlFileLoader.php | 202 +++--- .../ParameterBag/ContainerBag.php | 4 +- .../ParameterBag/ContainerBagInterface.php | 2 +- .../EnvPlaceholderParameterBag.php | 8 +- .../ParameterBag/FrozenParameterBag.php | 10 +- .../ParameterBag/ParameterBag.php | 14 +- .../dependency-injection/Reference.php | 2 +- .../dependency-injection/ReverseContainer.php | 6 +- .../dependency-injection/ServiceLocator.php | 20 +- .../TaggedContainerInterface.php | 2 +- .../dependency-injection/TypedReference.php | 4 +- .../Exception/FileNotFoundException.php | 2 +- .../filesystem/Exception/IOException.php | 2 +- .../Exception/IOExceptionInterface.php | 2 +- .../Exception/InvalidArgumentException.php | 2 +- .../filesystem/Exception/RuntimeException.php | 2 +- vendor/symfony/filesystem/Filesystem.php | 66 +- vendor/symfony/filesystem/Path.php | 10 +- .../finder/Comparator/DateComparator.php | 2 +- .../finder/Comparator/NumberComparator.php | 2 +- vendor/symfony/finder/Finder.php | 50 +- .../Iterator/FilecontentFilterIterator.php | 2 +- .../Iterator/FilenameFilterIterator.php | 4 +- .../finder/Iterator/PathFilterIterator.php | 2 +- .../Iterator/RecursiveDirectoryIterator.php | 6 +- .../Iterator/VcsIgnoredFilterIterator.php | 2 +- .../polyfill-intl-normalizer/Normalizer.php | 20 +- .../Resources/stubs/Normalizer.php | 5 +- .../polyfill-intl-normalizer/bootstrap.php | 10 +- .../polyfill-intl-normalizer/bootstrap80.php | 10 +- vendor/symfony/polyfill-mbstring/Mbstring.php | 8 +- .../symfony/polyfill-mbstring/bootstrap.php | 74 +-- .../symfony/polyfill-mbstring/bootstrap80.php | 74 +-- vendor/symfony/string/AbstractString.php | 32 +- .../symfony/string/AbstractUnicodeString.php | 54 +- vendor/symfony/string/ByteString.php | 56 +- vendor/symfony/string/CodePointString.php | 30 +- .../Exception/InvalidArgumentException.php | 2 +- .../string/Exception/RuntimeException.php | 2 +- .../string/Inflector/EnglishInflector.php | 2 +- .../string/Inflector/FrenchInflector.php | 2 +- vendor/symfony/string/Resources/functions.php | 18 +- .../symfony/string/Slugger/AsciiSlugger.php | 8 +- .../string/Slugger/SluggerInterface.php | 2 +- vendor/symfony/string/UnicodeString.php | 32 +- vendor/symplify/astral/composer.json | 44 +- vendor/symplify/astral/config/config.php | 20 +- .../Contract/NodeNameResolverInterface.php | 4 +- .../NodeValueResolverInterface.php | 2 +- .../Exception/ShouldNotHappenException.php | 2 +- .../astral/src/Naming/SimpleNameResolver.php | 28 +- .../src/NodeAnalyzer/NetteTypeAnalyzer.php | 14 +- .../src/NodeFinder/SimpleNodeFinder.php | 24 +- .../NodeNameResolver/ArgNodeNameResolver.php | 8 +- .../AttributeNodeNameResolver.php | 8 +- .../ClassLikeNodeNameResolver.php | 8 +- .../ClassMethodNodeNameResolver.php | 8 +- .../ConstFetchNodeNameResolver.php | 8 +- .../FuncCallNodeNameResolver.php | 10 +- .../IdentifierNodeNameResolver.php | 10 +- .../NamespaceNodeNameResolver.php | 8 +- .../ParamNodeNameResolver.php | 10 +- .../PropertyNodeNameResolver.php | 8 +- .../SimpleCallableNodeTraverser.php | 4 +- .../src/NodeValue/NodeValueResolver.php | 34 +- .../ClassConstFetchValueResolver.php | 14 +- .../ConstFetchValueResolver.php | 8 +- .../FuncCallValueResolver.php | 12 +- .../MagicConstValueResolver.php | 10 +- .../src/NodeValue/UnionTypeValueResolver.php | 4 +- .../src/NodeVisitor/CallableNodeVisitor.php | 8 +- .../Contract/PhpDocNodeVisitorInterface.php | 8 +- .../Exception/InvalidTraverseException.php | 2 +- .../src/PhpDocParser/PhpDocNodeTraverser.php | 26 +- .../AbstractPhpDocNodeVisitor.php | 10 +- .../CallablePhpDocNodeVisitor.php | 4 +- .../CloningPhpDocNodeVisitor.php | 6 +- .../ParentConnectingPhpDocNodeVisitor.php | 10 +- .../src/PhpDocParser/SimplePhpDocParser.php | 12 +- .../SimplePhpDocParserStaticFactory.php | 6 +- .../Ast/PhpDoc/SimplePhpDocNode.php | 8 +- .../astral/src/PhpParser/SmartPhpParser.php | 2 +- .../src/PhpParser/SmartPhpParserFactory.php | 20 +- .../src/Reflection/MethodCallParser.php | 10 +- .../src/Reflection/ReflectionParser.php | 22 +- .../NodeValueResolverStaticFactory.php | 8 +- .../SimpleNameResolverStaticFactory.php | 6 +- .../ClassMethodReturnTypeResolver.php | 16 +- .../src/TypeAnalyzer/ContainsTypeAnalyser.php | 26 +- .../ValueObject/NodeBuilder/ClassBuilder.php | 2 +- .../ValueObject/NodeBuilder/MethodBuilder.php | 2 +- .../NodeBuilder/NamespaceBuilder.php | 2 +- .../ValueObject/NodeBuilder/ParamBuilder.php | 2 +- .../NodeBuilder/PropertyBuilder.php | 2 +- .../NodeBuilder/TraitUseBuilder.php | 2 +- .../ValueObject/NodeBuilder/UseBuilder.php | 4 +- .../autowire-array-parameter/composer.json | 42 +- .../AutowireArrayParameterCompilerPass.php | 24 +- .../DependencyInjection/DefinitionFinder.php | 10 +- .../DocBlock/ParamTypeDocBlockResolver.php | 2 +- .../DefinitionForTypeNotFoundException.php | 2 +- .../src/Skipper/ParameterSkipper.php | 8 +- .../TypeResolver/ParameterTypeResolver.php | 6 +- .../composer-json-manipulator/composer.json | 42 +- .../config/config.php | 16 +- .../src/ComposerJsonFactory.php | 118 ++-- .../src/FileSystem/JsonFileManager.php | 16 +- .../src/Json/JsonInliner.php | 10 +- .../src/Printer/ComposerJsonPrinter.php | 8 +- .../src/Sorter/ComposerPackageSorter.php | 4 +- .../src/ValueObject/ComposerJson.php | 26 +- vendor/symplify/easy-parallel/composer.json | 42 +- .../symplify/easy-parallel/config/config.php | 4 +- .../CommandLine/WorkerCommandLineFactory.php | 12 +- .../src/Contract/SerializableInterface.php | 2 +- .../src/CpuCoreCountProvider.php | 2 +- .../ParallelShouldNotHappenException.php | 2 +- .../src/FileSystem/FilePathNormalizer.php | 2 +- .../CommandFromReflectionFactory.php | 12 +- .../easy-parallel/src/ScheduleFactory.php | 4 +- .../src/ValueObject/ParallelProcess.php | 24 +- .../src/ValueObject/ProcessPool.php | 8 +- .../easy-testing/bin/easy-testing.php | 2 +- vendor/symplify/easy-testing/composer.json | 42 +- .../symplify/easy-testing/config/config.php | 6 +- .../ValidateFixtureSkipNamingCommand.php | 10 +- .../src/DataProvider/StaticFixtureFinder.php | 32 +- .../src/DataProvider/StaticFixtureUpdater.php | 12 +- .../easy-testing/src/Finder/FixtureFinder.php | 6 +- .../FixtureSplitter/TrioFixtureSplitter.php | 12 +- .../src/Kernel/EasyTestingKernel.php | 6 +- .../src/MissplacedSkipPrefixResolver.php | 12 +- .../Behavior/DirectoryAssertableTrait.php | 10 +- .../src/PHPUnit/StaticPHPUnitEnvironment.php | 2 +- .../src/StaticFixtureSplitter.php | 28 +- .../ExpectedAndOutputFileInfoPair.php | 8 +- .../ValueObject/IncorrectAndMissingSkips.php | 2 +- .../ValueObject/InputFileInfoAndExpected.php | 6 +- .../InputFileInfoAndExpectedFileInfo.php | 8 +- vendor/symplify/package-builder/composer.json | 42 +- .../package-builder/config/config.php | 14 +- .../src/Composer/VendorDirProvider.php | 2 +- .../Command/AbstractSymplifyCommand.php | 6 +- .../src/Console/Command/CommandNaming.php | 6 +- .../Formatter/ColorConsoleDiffFormatter.php | 10 +- .../src/Console/Input/StaticInputDetector.php | 2 +- .../src/Console/Output/ConsoleDiffer.php | 2 +- .../src/Console/Style/SymfonyStyleFactory.php | 18 +- .../AutowireInterfacesCompilerPass.php | 4 +- .../ParameterMergingPhpFileLoader.php | 6 +- ...ompleteUnifiedDiffOutputBuilderFactory.php | 6 +- .../HttpKernel/MissingInterfaceException.php | 2 +- .../InvalidPrivatePropertyTypeException.php | 2 +- .../MissingPrivatePropertyException.php | 2 +- .../src/Parameter/ParameterProvider.php | 4 +- .../Reflection/ClassLikeExistenceChecker.php | 2 +- .../src/Reflection/PrivatesAccessor.php | 12 +- .../src/Reflection/PrivatesCaller.php | 8 +- .../src/Strings/StringFormatConverter.php | 2 +- .../src/Testing/AbstractKernelTestCase.php | 138 ++-- .../composer.json | 44 +- .../Category/CategoryInfererInterface.php | 6 +- .../src/Contract/CodeSampleInterface.php | 2 +- .../Contract/ConfigurableRuleInterface.php | 2 +- .../src/Contract/DocumentedRuleInterface.php | 6 +- .../RuleCodeSamplePrinterInterface.php | 6 +- .../Exception/PoorDocumentationException.php | 4 +- .../Exception/ShouldNotHappenException.php | 4 +- .../src/ValueObject/AbstractCodeSample.php | 14 +- .../src/ValueObject/CodeSample/CodeSample.php | 6 +- .../ComposerJsonAwareCodeSample.php | 6 +- .../CodeSample/ConfiguredCodeSample.php | 12 +- .../CodeSample/ExtraFileCodeSample.php | 6 +- .../src/ValueObject/RuleDefinition.php | 22 +- vendor/symplify/skipper/composer.json | 42 +- vendor/symplify/skipper/config/config.php | 12 +- .../src/Contract/SkipVoterInterface.php | 4 +- .../src/FileSystem/FnMatchPathNormalizer.php | 4 +- .../skipper/src/Matcher/FileInfoMatcher.php | 8 +- .../SkippedClassAndCodesResolver.php | 4 +- .../SkippedClassResolver.php | 4 +- .../SkippedMessagesResolver.php | 4 +- .../SkippedPathsResolver.php | 4 +- .../src/SkipVoter/ClassAndCodeSkipVoter.php | 8 +- .../skipper/src/SkipVoter/ClassSkipVoter.php | 10 +- .../src/SkipVoter/MessageSkipVoter.php | 8 +- .../skipper/src/SkipVoter/PathSkipVoter.php | 8 +- .../skipper/src/Skipper/OnlySkipper.php | 6 +- .../skipper/src/Skipper/SkipSkipper.php | 6 +- .../symplify/skipper/src/Skipper/Skipper.php | 8 +- .../symplify/smart-file-system/composer.json | 42 +- .../Exception/DirectoryNotFoundException.php | 2 +- .../src/Exception/FileNotFoundException.php | 2 +- .../smart-file-system/src/FileSystemGuard.php | 4 +- .../src/Finder/FinderSanitizer.php | 8 +- .../src/Finder/SmartFinder.php | 10 +- .../src/Json/JsonFileSystem.php | 8 +- .../src/Normalizer/PathNormalizer.php | 4 +- .../smart-file-system/src/SmartFileInfo.php | 14 +- .../smart-file-system/src/SmartFileSystem.php | 10 +- vendor/symplify/symplify-kernel/composer.json | 42 +- .../symplify-kernel/config/common-config.php | 22 +- .../Loader/ParameterMergingLoaderFactory.php | 12 +- .../src/ContainerBuilderFactory.php | 22 +- .../Config/LoaderFactoryInterface.php | 2 +- .../src/Contract/LightKernelInterface.php | 4 +- .../LoadExtensionConfigsCompilerPass.php | 4 +- .../src/Exception/BootException.php | 2 +- .../Exception/ShouldNotHappenException.php | 2 +- .../src/HttpKernel/AbstractSymplifyKernel.php | 14 +- .../KernelBootAndApplicationRun.php | 22 +- .../ContainerBuilderFactoryTest.php | 8 +- .../config/some_services.php | 6 +- .../tracy/src/Tracy/BlueScreen/BlueScreen.php | 50 +- .../tracy/src/Tracy/Debugger/Debugger.php | 62 +- .../src/Tracy/Debugger/DeferredContent.php | 12 +- .../Tracy/Debugger/DevelopmentStrategy.php | 28 +- .../src/Tracy/Debugger/ProductionStrategy.php | 20 +- .../tracy/src/Tracy/Dumper/Describer.php | 56 +- .../tracy/tracy/src/Tracy/Dumper/Dumper.php | 28 +- .../tracy/tracy/src/Tracy/Dumper/Exposer.php | 60 +- .../tracy/tracy/src/Tracy/Dumper/Renderer.php | 68 +- vendor/tracy/tracy/src/Tracy/Helpers.php | 16 +- .../tracy/src/Tracy/Logger/FireLogger.php | 20 +- .../tracy/tracy/src/Tracy/Logger/Logger.php | 18 +- .../Tracy/OutputDebugger/OutputDebugger.php | 2 +- vendor/tracy/tracy/src/Tracy/functions.php | 8 +- .../tracy/tools/create-phar/create-phar.php | 8 +- vendor/webmozart/assert/src/Assert.php | 20 +- 3052 files changed, 29920 insertions(+), 30047 deletions(-) diff --git a/bin/rector.php b/bin/rector.php index b04eede8669..65141bce52e 100755 --- a/bin/rector.php +++ b/bin/rector.php @@ -20,9 +20,9 @@ use RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller; \error_reporting(\E_ALL); \ini_set('display_errors', 'stderr'); \gc_disable(); -\define('__RECTOR_RUNNING__', \true); +\define('RectorPrefix20220607\\__RECTOR_RUNNING__', \true); // Require Composer autoload.php -$autoloadIncluder = new \RectorPrefix20220607\AutoloadIncluder(); +$autoloadIncluder = new AutoloadIncluder(); $autoloadIncluder->includeDependencyOrRepositoryVendorAutoloadIfExists(); final class AutoloadIncluder { @@ -33,7 +33,7 @@ final class AutoloadIncluder public function includeDependencyOrRepositoryVendorAutoloadIfExists() : void { // Rector's vendor is already loaded - if (\class_exists(\Rector\Core\Kernel\RectorKernel::class)) { + if (\class_exists(RectorKernel::class)) { return; } // in Rector develop repository @@ -95,7 +95,6 @@ final class AutoloadIncluder require_once $filePath; } } -\class_alias('RectorPrefix20220607\\AutoloadIncluder', 'AutoloadIncluder', \false); if (\file_exists(__DIR__ . '/../preload.php') && \is_dir(__DIR__ . '/../vendor')) { require_once __DIR__ . '/../preload.php'; } @@ -104,26 +103,26 @@ $autoloadIncluder->loadIfExistsAndNotLoadedYet(__DIR__ . '/../vendor/scoper-auto $autoloadIncluder->autoloadProjectAutoloaderFile(); $autoloadIncluder->autoloadRectorInstalledAsGlobalDependency(); $autoloadIncluder->autoloadFromCommandLine(); -$rectorConfigsResolver = new \Rector\Core\Bootstrap\RectorConfigsResolver(); +$rectorConfigsResolver = new RectorConfigsResolver(); try { $bootstrapConfigs = $rectorConfigsResolver->provide(); - $rectorContainerFactory = new \Rector\Core\DependencyInjection\RectorContainerFactory(); + $rectorContainerFactory = new RectorContainerFactory(); $container = $rectorContainerFactory->createFromBootstrapConfigs($bootstrapConfigs); } catch (\Throwable $throwable) { // for json output - $argvInput = new \RectorPrefix20220607\Symfony\Component\Console\Input\ArgvInput(); - $outputFormat = $argvInput->getParameterOption('--' . \Rector\Core\Configuration\Option::OUTPUT_FORMAT); + $argvInput = new ArgvInput(); + $outputFormat = $argvInput->getParameterOption('--' . Option::OUTPUT_FORMAT); // report fatal error in json format - if ($outputFormat === \Rector\ChangesReporting\Output\JsonOutputFormatter::NAME) { - echo \RectorPrefix20220607\Nette\Utils\Json::encode(['fatal_errors' => [$throwable->getMessage()]]); + if ($outputFormat === JsonOutputFormatter::NAME) { + echo Json::encode(['fatal_errors' => [$throwable->getMessage()]]); } else { // report fatal errors in console format - $rectorConsoleOutputStyleFactory = new \Rector\Core\Console\Style\RectorConsoleOutputStyleFactory(new \RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller()); + $rectorConsoleOutputStyleFactory = new RectorConsoleOutputStyleFactory(new PrivatesCaller()); $rectorConsoleOutputStyle = $rectorConsoleOutputStyleFactory->create(); $rectorConsoleOutputStyle->error($throwable->getMessage()); } - exit(\RectorPrefix20220607\Symfony\Component\Console\Command\Command::FAILURE); + exit(Command::FAILURE); } /** @var ConsoleApplication $application */ -$application = $container->get(\Rector\Core\Console\ConsoleApplication::class); +$application = $container->get(ConsoleApplication::class); exit($application->run()); diff --git a/config/config.php b/config/config.php index 060f00fd241..a6126386b1c 100644 --- a/config/config.php +++ b/config/config.php @@ -51,9 +51,9 @@ use RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemGuard; use RectorPrefix20220607\Symplify\SmartFileSystem\Finder\FinderSanitizer; use RectorPrefix20220607\Symplify\SmartFileSystem\Json\JsonFileSystem; use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { // make use of https://github.com/symplify/easy-parallel - $rectorConfig->import(\RectorPrefix20220607\Symplify\EasyParallel\ValueObject\EasyParallelConfig::FILE_PATH); + $rectorConfig->import(EasyParallelConfig::FILE_PATH); $rectorConfig->paths([]); $rectorConfig->skip([]); $rectorConfig->autoloadPaths([]); @@ -81,17 +81,17 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { __DIR__ . '/../packages/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php', ]); // psr-4 - $services->alias(\Rector\PSR4\Contract\PSR4AutoloadNamespaceMatcherInterface::class, \Rector\PSR4\Composer\PSR4NamespaceMatcher::class); + $services->alias(PSR4AutoloadNamespaceMatcherInterface::class, PSR4NamespaceMatcher::class); $services->load('Rector\\', __DIR__ . '/../rules')->exclude([__DIR__ . '/../rules/*/ValueObject/*', __DIR__ . '/../rules/*/Rector/*', __DIR__ . '/../rules/*/Contract/*', __DIR__ . '/../rules/*/Exception/*', __DIR__ . '/../rules/*/Enum/*', __DIR__ . '/../rules/DowngradePhp80/Reflection/SimplePhpParameterReflection.php']); // parallel - $services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Yaml\ParametersMerger::class); + $services->set(ParametersMerger::class); // use faster in-memory cache in CI. // CI always starts from scratch, therefore IO intensive caching is not worth it - $ciDetector = new \RectorPrefix20220607\OndraM\CiDetector\CiDetector(); + $ciDetector = new CiDetector(); if ($ciDetector->isCiDetected()) { - $rectorConfig->cacheClass(\Rector\Caching\ValueObject\Storage\MemoryCacheStorage::class); + $rectorConfig->cacheClass(MemoryCacheStorage::class); } - $extensionConfigResolver = new \Rector\Core\Bootstrap\ExtensionConfigResolver(); + $extensionConfigResolver = new ExtensionConfigResolver(); $extensionConfigFiles = $extensionConfigResolver->provide(); foreach ($extensionConfigFiles as $extensionConfigFile) { $rectorConfig->import($extensionConfigFile->getRealPath()); @@ -99,43 +99,43 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { // require only in dev $rectorConfig->import(__DIR__ . '/../utils/compiler/config/config.php', null, 'not_found'); $services->load('Rector\\Core\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/Rector', __DIR__ . '/../src/Console/Style/RectorConsoleOutputStyle.php', __DIR__ . '/../src/Exception', __DIR__ . '/../src/DependencyInjection/CompilerPass', __DIR__ . '/../src/DependencyInjection/Loader', __DIR__ . '/../src/Kernel', __DIR__ . '/../src/ValueObject', __DIR__ . '/../src/Bootstrap', __DIR__ . '/../src/Enum', __DIR__ . '/../src/PhpParser/Node/CustomNode', __DIR__ . '/../src/PhpParser/ValueObject', __DIR__ . '/../src/functions', __DIR__ . '/../src/constants.php']); - $services->alias(\RectorPrefix20220607\Symfony\Component\Console\Application::class, \Rector\Core\Console\ConsoleApplication::class); - $services->set(\Rector\Core\Validation\Collector\EmptyConfigurableRectorCollector::class)->arg('$containerBuilder', \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service('service_container')); - $services->set(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser::class); - $services->set(\PhpParser\BuilderFactory::class); - $services->set(\PhpParser\NodeVisitor\CloningVisitor::class); - $services->set(\PhpParser\NodeVisitor\NodeConnectingVisitor::class); - $services->set(\PhpParser\NodeFinder::class); - $services->set(\Rector\Core\Console\Style\RectorConsoleOutputStyle::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\Core\Console\Style\RectorConsoleOutputStyleFactory::class), 'create']); - $services->set(\PHPStan\Parser\Parser::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createPHPStanParser']); - $services->set(\PhpParser\Lexer::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createEmulativeLexer']); + $services->alias(Application::class, ConsoleApplication::class); + $services->set(EmptyConfigurableRectorCollector::class)->arg('$containerBuilder', service('service_container')); + $services->set(SimpleCallableNodeTraverser::class); + $services->set(BuilderFactory::class); + $services->set(CloningVisitor::class); + $services->set(NodeConnectingVisitor::class); + $services->set(NodeFinder::class); + $services->set(RectorConsoleOutputStyle::class)->factory([service(RectorConsoleOutputStyleFactory::class), 'create']); + $services->set(Parser::class)->factory([service(PHPStanServicesFactory::class), 'createPHPStanParser']); + $services->set(Lexer::class)->factory([service(PHPStanServicesFactory::class), 'createEmulativeLexer']); // symplify/package-builder - $services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemGuard::class); - $services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor::class); - $services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller::class); - $services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\Finder\FinderSanitizer::class); - $services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemFilter::class); - $services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider::class)->arg('$container', \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service('service_container')); - $services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem::class); - $services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\Json\JsonFileSystem::class); - $services->set(\RectorPrefix20220607\Doctrine\Inflector\Rules\English\InflectorFactory::class); - $services->set(\RectorPrefix20220607\Doctrine\Inflector\Inflector::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\RectorPrefix20220607\Doctrine\Inflector\Rules\English\InflectorFactory::class), 'build']); - $services->set(\RectorPrefix20220607\Composer\Semver\VersionParser::class); - $services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Php\TypeChecker::class); + $services->set(FileSystemGuard::class); + $services->set(PrivatesAccessor::class); + $services->set(PrivatesCaller::class); + $services->set(FinderSanitizer::class); + $services->set(FileSystemFilter::class); + $services->set(ParameterProvider::class)->arg('$container', service('service_container')); + $services->set(SmartFileSystem::class); + $services->set(JsonFileSystem::class); + $services->set(InflectorFactory::class); + $services->set(Inflector::class)->factory([service(InflectorFactory::class), 'build']); + $services->set(VersionParser::class); + $services->set(TypeChecker::class); // phpdoc parser $services->set(\PHPStan\PhpDocParser\Lexer\Lexer::class); - $services->alias(\PHPStan\PhpDocParser\Parser\PhpDocParser::class, \Rector\BetterPhpDocParser\PhpDocParser\BetterPhpDocParser::class); + $services->alias(PhpDocParser::class, BetterPhpDocParser::class); // cache - $services->set(\PHPStan\Dependency\DependencyResolver::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createDependencyResolver']); - $services->set(\PHPStan\File\FileHelper::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createFileHelper']); - $services->set(\Rector\Caching\Cache::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\Caching\CacheFactory::class), 'create']); + $services->set(DependencyResolver::class)->factory([service(PHPStanServicesFactory::class), 'createDependencyResolver']); + $services->set(FileHelper::class)->factory([service(PHPStanServicesFactory::class), 'createFileHelper']); + $services->set(Cache::class)->factory([service(CacheFactory::class), 'create']); // type resolving - $services->set(\Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocator\IntermediateSourceLocator::class); - $services->alias(\PHPStan\PhpDocParser\Parser\TypeParser::class, \Rector\BetterPhpDocParser\PhpDocParser\BetterTypeParser::class); + $services->set(IntermediateSourceLocator::class); + $services->alias(TypeParser::class, BetterTypeParser::class); // PHPStan services - $services->set(\PHPStan\Reflection\ReflectionProvider::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createReflectionProvider']); - $services->set(\PHPStan\Analyser\NodeScopeResolver::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createNodeScopeResolver']); - $services->set(\PHPStan\Analyser\ScopeFactory::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createScopeFactory']); - $services->set(\PHPStan\PhpDoc\TypeNodeResolver::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createTypeNodeResolver']); - $services->set(\Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createDynamicSourceLocatorProvider']); + $services->set(ReflectionProvider::class)->factory([service(PHPStanServicesFactory::class), 'createReflectionProvider']); + $services->set(NodeScopeResolver::class)->factory([service(PHPStanServicesFactory::class), 'createNodeScopeResolver']); + $services->set(ScopeFactory::class)->factory([service(PHPStanServicesFactory::class), 'createScopeFactory']); + $services->set(TypeNodeResolver::class)->factory([service(PHPStanServicesFactory::class), 'createTypeNodeResolver']); + $services->set(DynamicSourceLocatorProvider::class)->factory([service(PHPStanServicesFactory::class), 'createDynamicSourceLocatorProvider']); }; diff --git a/config/set/action-injection-to-constructor-injection.php b/config/set/action-injection-to-constructor-injection.php index 5b158bb1d0b..9ecf81b14fc 100644 --- a/config/set/action-injection-to-constructor-injection.php +++ b/config/set/action-injection-to-constructor-injection.php @@ -5,6 +5,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\DependencyInjection\Rector\Class_\ActionInjectionToConstructorInjectionRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\DependencyInjection\Rector\Class_\ActionInjectionToConstructorInjectionRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(ActionInjectionToConstructorInjectionRector::class); }; diff --git a/config/set/code-quality.php b/config/set/code-quality.php index 798593ca76a..6292839e20e 100644 --- a/config/set/code-quality.php +++ b/config/set/code-quality.php @@ -80,8 +80,8 @@ use Rector\Config\RectorConfig; use Rector\Php52\Rector\Property\VarToPublicPropertyRector; use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, [ 'split' => 'explode', 'join' => 'implode', 'sizeof' => 'count', @@ -106,5 +106,5 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { 'mbstrrpos' => 'mb_strrpos', 'mbsubstr' => 'mb_substr', ]); - $rectorConfig->rules([\Rector\CodeQuality\Rector\Assign\CombinedAssignRector::class, \Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector::class, \Rector\CodeQuality\Rector\BooleanNot\ReplaceMultipleBooleanNotRector::class, \Rector\CodeQuality\Rector\Foreach_\ForeachToInArrayRector::class, \Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToCoalescingRector::class, \Rector\CodeQuality\Rector\FuncCall\SimplifyFuncGetArgsCountRector::class, \Rector\CodeQuality\Rector\FuncCall\SimplifyInArrayValuesRector::class, \Rector\CodeQuality\Rector\FuncCall\SimplifyStrposLowerRector::class, \Rector\CodeQuality\Rector\Identical\GetClassToInstanceOfRector::class, \Rector\CodeQuality\Rector\Identical\SimplifyArraySearchRector::class, \Rector\CodeQuality\Rector\Identical\SimplifyConditionsRector::class, \Rector\CodeQuality\Rector\If_\SimplifyIfNotNullReturnRector::class, \Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector::class, \Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector::class, \Rector\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector::class, \Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector::class, \Rector\CodeQuality\Rector\BooleanNot\SimplifyDeMorganBinaryRector::class, \Rector\CodeQuality\Rector\Ternary\SimplifyTautologyTernaryRector::class, \Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToArrayFilterRector::class, \Rector\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector::class, \Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector::class, \Rector\CodeQuality\Rector\Concat\JoinStringConcatRector::class, \Rector\CodeQuality\Rector\If_\ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class, \Rector\CodeQuality\Rector\If_\SimplifyIfIssetToNullCoalescingRector::class, \Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector::class, \Rector\CodeQuality\Rector\If_\CombineIfRector::class, \Rector\CodeQuality\Rector\Equal\UseIdenticalOverEqualWithSameTypeRector::class, \Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector::class, \Rector\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector::class, \Rector\CodeQuality\Rector\Identical\BooleanNotIdenticalToNotIdenticalRector::class, \Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector::class, \Rector\CodeQuality\Rector\LogicalAnd\AndAssignsToSeparateLinesRector::class, \Rector\CodeQuality\Rector\For_\ForToForeachRector::class, \Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector::class, \Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector::class, \Rector\CodeQuality\Rector\FuncCall\IsAWithStringWithThirdArgumentRector::class, \Rector\CodeQuality\Rector\Identical\StrlenZeroToIdenticalEmptyStringRector::class, \Rector\CodeQuality\Rector\FunctionLike\RemoveAlwaysTrueConditionSetInConstructorRector::class, \Rector\CodeQuality\Rector\Catch_\ThrowWithPreviousExceptionRector::class, \Rector\CodeQuality\Rector\FuncCall\RemoveSoleValueSprintfRector::class, \Rector\CodeQuality\Rector\If_\ShortenElseIfRector::class, \Rector\CodeQuality\Rector\FuncCall\AddPregQuoteDelimiterRector::class, \Rector\CodeQuality\Rector\FuncCall\ArrayMergeOfNonArraysToSimpleArrayRector::class, \Rector\CodeQuality\Rector\FuncCall\IntvalToTypeCastRector::class, \Rector\CodeQuality\Rector\Ternary\ArrayKeyExistsTernaryThenValueToCoalescingRector::class, \Rector\CodeQuality\Rector\Include_\AbsolutizeRequireAndIncludePathRector::class, \Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector::class, \Rector\CodeQuality\Rector\For_\ForRepeatedCountToOwnVariableRector::class, \Rector\CodeQuality\Rector\Foreach_\ForeachItemsAssignToEmptyArrayToAssignRector::class, \Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector::class, \Rector\CodeQuality\Rector\FuncCall\ArrayKeysAndInArrayToArrayKeyExistsRector::class, \Rector\CodeQuality\Rector\Assign\SplitListAssignToSeparateLineRector::class, \Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector::class, \Rector\CodeQuality\Rector\Array_\ArrayThisCallToThisMethodCallRector::class, \Rector\CodeQuality\Rector\NotEqual\CommonNotEqualRector::class, \Rector\CodeQuality\Rector\FuncCall\SetTypeToCastRector::class, \Rector\CodeQuality\Rector\LogicalAnd\LogicalToBooleanRector::class, \Rector\Php52\Rector\Property\VarToPublicPropertyRector::class, \Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector::class, \Rector\CodeQuality\Rector\New_\NewStaticToNewSelfRector::class, \Rector\CodeQuality\Rector\ClassMethod\DateTimeToDateTimeInterfaceRector::class, \Rector\CodeQuality\Rector\FuncCall\UnwrapSprintfOneArgumentRector::class, \Rector\CodeQuality\Rector\Ternary\SwitchNegatedTernaryRector::class, \Rector\CodeQuality\Rector\Switch_\SingularSwitchToIfRector::class, \Rector\CodeQuality\Rector\If_\SimplifyIfNullableReturnRector::class, \Rector\CodeQuality\Rector\ClassMethod\NarrowUnionTypeDocRector::class, \Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector::class, \Rector\CodingStyle\Rector\FuncCall\CallUserFuncToMethodCallRector::class, \Rector\CodeQuality\Rector\FuncCall\CallUserFuncWithArrowFunctionToInlineRector::class, \Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector::class, \Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector::class, \Rector\CodeQuality\Rector\PropertyFetch\ExplicitMethodCallOverMagicGetSetRector::class, \Rector\CodeQuality\Rector\Do_\DoWhileBreakFalseToIfElseRector::class, \Rector\CodeQuality\Rector\ClassMethod\InlineArrayReturnAssignRector::class, \Rector\CodeQuality\Rector\FuncCall\InlineIsAInstanceOfRector::class]); + $rectorConfig->rules([CombinedAssignRector::class, SimplifyEmptyArrayCheckRector::class, ReplaceMultipleBooleanNotRector::class, ForeachToInArrayRector::class, SimplifyForeachToCoalescingRector::class, SimplifyFuncGetArgsCountRector::class, SimplifyInArrayValuesRector::class, SimplifyStrposLowerRector::class, GetClassToInstanceOfRector::class, SimplifyArraySearchRector::class, SimplifyConditionsRector::class, SimplifyIfNotNullReturnRector::class, SimplifyIfReturnBoolRector::class, SimplifyUselessVariableRector::class, UnnecessaryTernaryExpressionRector::class, RemoveExtraParametersRector::class, SimplifyDeMorganBinaryRector::class, SimplifyTautologyTernaryRector::class, SimplifyForeachToArrayFilterRector::class, SingleInArrayToCompareRector::class, SimplifyIfElseToTernaryRector::class, JoinStringConcatRector::class, ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class, SimplifyIfIssetToNullCoalescingRector::class, ExplicitBoolCompareRector::class, CombineIfRector::class, UseIdenticalOverEqualWithSameTypeRector::class, SimplifyBoolIdenticalTrueRector::class, SimplifyRegexPatternRector::class, BooleanNotIdenticalToNotIdenticalRector::class, CallableThisArrayToAnonymousFunctionRector::class, AndAssignsToSeparateLinesRector::class, ForToForeachRector::class, CompactToVariablesRector::class, CompleteDynamicPropertiesRector::class, IsAWithStringWithThirdArgumentRector::class, StrlenZeroToIdenticalEmptyStringRector::class, RemoveAlwaysTrueConditionSetInConstructorRector::class, ThrowWithPreviousExceptionRector::class, RemoveSoleValueSprintfRector::class, ShortenElseIfRector::class, AddPregQuoteDelimiterRector::class, ArrayMergeOfNonArraysToSimpleArrayRector::class, IntvalToTypeCastRector::class, ArrayKeyExistsTernaryThenValueToCoalescingRector::class, AbsolutizeRequireAndIncludePathRector::class, ChangeArrayPushToArrayAssignRector::class, ForRepeatedCountToOwnVariableRector::class, ForeachItemsAssignToEmptyArrayToAssignRector::class, InlineIfToExplicitIfRector::class, ArrayKeysAndInArrayToArrayKeyExistsRector::class, SplitListAssignToSeparateLineRector::class, UnusedForeachValueToArrayKeysRector::class, ArrayThisCallToThisMethodCallRector::class, CommonNotEqualRector::class, SetTypeToCastRector::class, LogicalToBooleanRector::class, VarToPublicPropertyRector::class, IssetOnPropertyObjectToPropertyExistsRector::class, NewStaticToNewSelfRector::class, DateTimeToDateTimeInterfaceRector::class, UnwrapSprintfOneArgumentRector::class, SwitchNegatedTernaryRector::class, SingularSwitchToIfRector::class, SimplifyIfNullableReturnRector::class, NarrowUnionTypeDocRector::class, FuncGetArgsToVariadicParamRector::class, CallUserFuncToMethodCallRector::class, CallUserFuncWithArrowFunctionToInlineRector::class, CountArrayToEmptyArrayComparisonRector::class, FlipTypeControlToUseExclusiveTypeRector::class, ExplicitMethodCallOverMagicGetSetRector::class, DoWhileBreakFalseToIfElseRector::class, InlineArrayReturnAssignRector::class, InlineIsAInstanceOfRector::class]); }; diff --git a/config/set/coding-style.php b/config/set/coding-style.php index 2604480fef9..d6bb3f94683 100644 --- a/config/set/coding-style.php +++ b/config/set/coding-style.php @@ -32,7 +32,7 @@ use Rector\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector; use Rector\Config\RectorConfig; use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; use Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector::class, ['php_sapi_name' => 'PHP_SAPI', 'pi' => 'M_PI']); - $rectorConfig->rules([\Rector\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector::class, \Rector\CodingStyle\Rector\ClassMethod\RemoveDoubleUnderscoreInMethodNameRector::class, \Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector::class, \Rector\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector::class, \Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector::class, \Rector\CodingStyle\Rector\ClassConst\RemoveFinalFromConstRector::class, \Rector\CodingStyle\Rector\Assign\PHPStormVarAnnotationRector::class, \Rector\CodingStyle\Rector\If_\NullableCompareToNullRector::class, \Rector\CodingStyle\Rector\Switch_\BinarySwitchToIfElseRector::class, \Rector\CodingStyle\Rector\FuncCall\ConsistentImplodeRector::class, \Rector\CodingStyle\Rector\Ternary\TernaryConditionVariableAssignmentRector::class, \Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector::class, \Rector\CodingStyle\Rector\ClassConst\SplitGroupedConstantsAndPropertiesRector::class, \Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class, \Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector::class, \Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector::class, \Rector\CodingStyle\Rector\Plus\UseIncrementAssignRector::class, \Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector::class, \Rector\CodingStyle\Rector\ClassConst\VarConstantCommentRector::class, \Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector::class, \Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector::class, \Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector::class, \Rector\CodingStyle\Rector\Class_\AddArrayDefaultToArrayPropertyRector::class, \Rector\CodingStyle\Rector\Property\AddFalseDefaultToBoolPropertyRector::class, \Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector::class, \Rector\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector::class, \Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector::class]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(FuncCallToConstFetchRector::class, ['php_sapi_name' => 'PHP_SAPI', 'pi' => 'M_PI']); + $rectorConfig->rules([SeparateMultiUseImportsRector::class, RemoveDoubleUnderscoreInMethodNameRector::class, PostIncDecToPreIncDecRector::class, UnSpreadOperatorRector::class, NewlineAfterStatementRector::class, RemoveFinalFromConstRector::class, PHPStormVarAnnotationRector::class, NullableCompareToNullRector::class, BinarySwitchToIfElseRector::class, ConsistentImplodeRector::class, TernaryConditionVariableAssignmentRector::class, SymplifyQuoteEscapeRector::class, SplitGroupedConstantsAndPropertiesRector::class, StringClassNameToClassConstantRector::class, ConsistentPregDelimiterRector::class, CatchExceptionNameMatchingTypeRector::class, UseIncrementAssignRector::class, SplitDoubleAssignRector::class, VarConstantCommentRector::class, EncapsedStringsToSprintfRector::class, WrapEncapsedVariableInCurlyBracesRector::class, NewlineBeforeNewAssignSetRector::class, AddArrayDefaultToArrayPropertyRector::class, AddFalseDefaultToBoolPropertyRector::class, MakeInheritedMethodVisibilitySameAsParentRector::class, CallUserFuncArrayToVariadicRector::class, VersionCompareFuncCallToConstantRector::class]); }; diff --git a/config/set/dead-code.php b/config/set/dead-code.php index 12f94c99aa4..57ebf328d67 100644 --- a/config/set/dead-code.php +++ b/config/set/dead-code.php @@ -50,54 +50,54 @@ use Rector\DeadCode\Rector\Switch_\RemoveDuplicatedCaseInSwitchRector; use Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector; use Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector; use Rector\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $rectorConfig->rules([ - \Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector::class, - \Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector::class, - \Rector\DeadCode\Rector\Cast\RecastingRemovalRector::class, - \Rector\DeadCode\Rector\Expression\RemoveDeadStmtRector::class, - \Rector\DeadCode\Rector\Array_\RemoveDuplicatedArrayKeyRector::class, - \Rector\DeadCode\Rector\Foreach_\RemoveUnusedForeachKeyRector::class, - \Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector::class, - \Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector::class, - \Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector::class, - \Rector\DeadCode\Rector\Expression\SimplifyMirrorAssignRector::class, - \Rector\DeadCode\Rector\FunctionLike\RemoveOverriddenValuesRector::class, - \Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector::class, - \Rector\DeadCode\Rector\ClassConst\RemoveUnusedPrivateClassConstantRector::class, - \Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector::class, - \Rector\DeadCode\Rector\ClassMethod\RemoveDeadConstructorRector::class, - \Rector\DeadCode\Rector\FunctionLike\RemoveDeadReturnRector::class, - \Rector\DeadCode\Rector\For_\RemoveDeadContinueRector::class, - \Rector\DeadCode\Rector\For_\RemoveDeadIfForeachForRector::class, - \Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector::class, - \Rector\DeadCode\Rector\Concat\RemoveConcatAutocastRector::class, - \Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector::class, - \Rector\DeadCode\Rector\ClassMethod\RemoveDelegatingParentCallRector::class, - \Rector\DeadCode\Rector\BinaryOp\RemoveDuplicatedInstanceOfRector::class, - \Rector\DeadCode\Rector\Switch_\RemoveDuplicatedCaseInSwitchRector::class, - \Rector\DeadCode\Rector\PropertyProperty\RemoveNullPropertyInitializationRector::class, - \Rector\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector::class, - \Rector\DeadCode\Rector\If_\SimplifyIfElseWithSameContentRector::class, - \Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector::class, - \Rector\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector::class, - \Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector::class, - \Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector::class, - \Rector\DeadCode\Rector\FunctionLike\RemoveDuplicatedIfReturnRector::class, - \Rector\DeadCode\Rector\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector::class, - \Rector\DeadCode\Rector\MethodCall\RemoveEmptyMethodCallRector::class, - \Rector\DeadCode\Rector\Return_\RemoveDeadConditionAboveReturnRector::class, - \Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector::class, - \Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector::class, - \Rector\DeadCode\Rector\For_\RemoveDeadLoopRector::class, - \Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodParameterRector::class, - \Rector\DeadCode\Rector\ClassMethod\RemoveUnusedParamInRequiredAutowireRector::class, + UnwrapFutureCompatibleIfFunctionExistsRector::class, + UnwrapFutureCompatibleIfPhpVersionRector::class, + RecastingRemovalRector::class, + RemoveDeadStmtRector::class, + RemoveDuplicatedArrayKeyRector::class, + RemoveUnusedForeachKeyRector::class, + RemoveParentCallWithoutParentRector::class, + RemoveEmptyClassMethodRector::class, + RemoveDoubleAssignRector::class, + SimplifyMirrorAssignRector::class, + RemoveOverriddenValuesRector::class, + RemoveUnusedPrivatePropertyRector::class, + RemoveUnusedPrivateClassConstantRector::class, + RemoveUnusedPrivateMethodRector::class, + RemoveDeadConstructorRector::class, + RemoveDeadReturnRector::class, + RemoveDeadContinueRector::class, + RemoveDeadIfForeachForRector::class, + RemoveAndTrueRector::class, + RemoveConcatAutocastRector::class, + SimplifyUselessVariableRector::class, + RemoveDelegatingParentCallRector::class, + RemoveDuplicatedInstanceOfRector::class, + RemoveDuplicatedCaseInSwitchRector::class, + RemoveNullPropertyInitializationRector::class, + RemoveUnreachableStatementRector::class, + SimplifyIfElseWithSameContentRector::class, + TernaryToBooleanOrFalseToBooleanAndRector::class, + RemoveEmptyTestMethodRector::class, + RemoveDeadTryCatchRector::class, + RemoveUnusedVariableAssignRector::class, + RemoveDuplicatedIfReturnRector::class, + RemoveUnusedNonEmptyArrayBeforeForeachRector::class, + RemoveEmptyMethodCallRector::class, + RemoveDeadConditionAboveReturnRector::class, + RemoveUnusedConstructorParamRector::class, + RemoveDeadInstanceOfRector::class, + RemoveDeadLoopRector::class, + RemoveUnusedPrivateMethodParameterRector::class, + RemoveUnusedParamInRequiredAutowireRector::class, // docblock - \Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector::class, - \Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector::class, - \Rector\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector::class, - \Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector::class, - \Rector\DeadCode\Rector\ClassMethod\RemoveLastReturnRector::class, - \Rector\DeadCode\Rector\StmtsAwareInterface\RemoveJustPropertyFetchForAssignRector::class, + RemoveUselessParamTagRector::class, + RemoveUselessReturnTagRector::class, + RemoveNonExistingVarAnnotationRector::class, + RemoveUnusedPromotedPropertyRector::class, + RemoveLastReturnRector::class, + RemoveJustPropertyFetchForAssignRector::class, ]); }; diff --git a/config/set/defluent.php b/config/set/defluent.php index 2925230565f..08800648925 100644 --- a/config/set/defluent.php +++ b/config/set/defluent.php @@ -6,7 +6,7 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; // @see https://ocramius.github.io/blog/fluent-interfaces-are-evil/ // @see https://www.yegor256.com/2018/03/13/fluent-interfaces.html -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $deprecatedMessage = \sprintf('The DEFLUENT set is deprecated for high number of assumptions and reported bugs. Better use PHPStan rule "%s" to warn about these cases and refactor manually.', 'https://github.com/symplify/phpstan-rules/blob/main/docs/rules_overview.md#nochainmethodcallrule'); \trigger_error($deprecatedMessage); \sleep(3); diff --git a/config/set/downgrade-php53.php b/config/set/downgrade-php53.php index 299c3be3839..cf66a9e8382 100644 --- a/config/set/downgrade-php53.php +++ b/config/set/downgrade-php53.php @@ -6,7 +6,7 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Core\ValueObject\PhpVersion; use Rector\DowngradePhp53\Rector\Dir\DirConstToFileConstRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_52); - $rectorConfig->rule(\Rector\DowngradePhp53\Rector\Dir\DirConstToFileConstRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->phpVersion(PhpVersion::PHP_52); + $rectorConfig->rule(DirConstToFileConstRector::class); }; diff --git a/config/set/downgrade-php54.php b/config/set/downgrade-php54.php index 731634671af..0606cdf83ff 100644 --- a/config/set/downgrade-php54.php +++ b/config/set/downgrade-php54.php @@ -12,13 +12,13 @@ use Rector\DowngradePhp54\Rector\FuncCall\DowngradeIndirectCallByArrayRector; use Rector\DowngradePhp54\Rector\FunctionLike\DowngradeCallableTypeDeclarationRector; use Rector\DowngradePhp54\Rector\LNumber\DowngradeBinaryNotationRector; use Rector\DowngradePhp54\Rector\MethodCall\DowngradeInstanceMethodCallRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_53); - $rectorConfig->rule(\Rector\DowngradePhp54\Rector\Array_\ShortArrayToLongArrayRector::class); - $rectorConfig->rule(\Rector\DowngradePhp54\Rector\Closure\DowngradeStaticClosureRector::class); - $rectorConfig->rule(\Rector\DowngradePhp54\Rector\FuncCall\DowngradeIndirectCallByArrayRector::class); - $rectorConfig->rule(\Rector\DowngradePhp54\Rector\FunctionLike\DowngradeCallableTypeDeclarationRector::class); - $rectorConfig->rule(\Rector\DowngradePhp54\Rector\LNumber\DowngradeBinaryNotationRector::class); - $rectorConfig->rule(\Rector\DowngradePhp54\Rector\MethodCall\DowngradeInstanceMethodCallRector::class); - $rectorConfig->rule(\Rector\DowngradePhp54\Rector\Closure\DowngradeThisInClosureRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->phpVersion(PhpVersion::PHP_53); + $rectorConfig->rule(ShortArrayToLongArrayRector::class); + $rectorConfig->rule(DowngradeStaticClosureRector::class); + $rectorConfig->rule(DowngradeIndirectCallByArrayRector::class); + $rectorConfig->rule(DowngradeCallableTypeDeclarationRector::class); + $rectorConfig->rule(DowngradeBinaryNotationRector::class); + $rectorConfig->rule(DowngradeInstanceMethodCallRector::class); + $rectorConfig->rule(DowngradeThisInClosureRector::class); }; diff --git a/config/set/downgrade-php55.php b/config/set/downgrade-php55.php index 13dd4701be1..69980f9604b 100644 --- a/config/set/downgrade-php55.php +++ b/config/set/downgrade-php55.php @@ -9,10 +9,10 @@ use Rector\DowngradePhp55\Rector\ClassConstFetch\DowngradeClassConstantToStringR use Rector\DowngradePhp55\Rector\Foreach_\DowngradeForeachListRector; use Rector\DowngradePhp55\Rector\FuncCall\DowngradeBoolvalRector; use Rector\DowngradePhp55\Rector\Isset_\DowngradeArbitraryExpressionArgsToEmptyAndIssetRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_54); - $rectorConfig->rule(\Rector\DowngradePhp55\Rector\ClassConstFetch\DowngradeClassConstantToStringRector::class); - $rectorConfig->rule(\Rector\DowngradePhp55\Rector\Foreach_\DowngradeForeachListRector::class); - $rectorConfig->rule(\Rector\DowngradePhp55\Rector\FuncCall\DowngradeBoolvalRector::class); - $rectorConfig->rule(\Rector\DowngradePhp55\Rector\Isset_\DowngradeArbitraryExpressionArgsToEmptyAndIssetRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->phpVersion(PhpVersion::PHP_54); + $rectorConfig->rule(DowngradeClassConstantToStringRector::class); + $rectorConfig->rule(DowngradeForeachListRector::class); + $rectorConfig->rule(DowngradeBoolvalRector::class); + $rectorConfig->rule(DowngradeArbitraryExpressionArgsToEmptyAndIssetRector::class); }; diff --git a/config/set/downgrade-php56.php b/config/set/downgrade-php56.php index 96c3f9b2278..68cc1f52a92 100644 --- a/config/set/downgrade-php56.php +++ b/config/set/downgrade-php56.php @@ -10,11 +10,11 @@ use Rector\DowngradePhp56\Rector\FuncCall\DowngradeArrayFilterUseConstantRector; use Rector\DowngradePhp56\Rector\Pow\DowngradeExponentialAssignmentOperatorRector; use Rector\DowngradePhp56\Rector\Pow\DowngradeExponentialOperatorRector; use Rector\DowngradePhp56\Rector\Use_\DowngradeUseFunctionRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_55); - $rectorConfig->rule(\Rector\DowngradePhp56\Rector\CallLike\DowngradeArgumentUnpackingRector::class); - $rectorConfig->rule(\Rector\DowngradePhp56\Rector\Use_\DowngradeUseFunctionRector::class); - $rectorConfig->rule(\Rector\DowngradePhp56\Rector\Pow\DowngradeExponentialAssignmentOperatorRector::class); - $rectorConfig->rule(\Rector\DowngradePhp56\Rector\Pow\DowngradeExponentialOperatorRector::class); - $rectorConfig->rule(\Rector\DowngradePhp56\Rector\FuncCall\DowngradeArrayFilterUseConstantRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->phpVersion(PhpVersion::PHP_55); + $rectorConfig->rule(DowngradeArgumentUnpackingRector::class); + $rectorConfig->rule(DowngradeUseFunctionRector::class); + $rectorConfig->rule(DowngradeExponentialAssignmentOperatorRector::class); + $rectorConfig->rule(DowngradeExponentialOperatorRector::class); + $rectorConfig->rule(DowngradeArrayFilterUseConstantRector::class); }; diff --git a/config/set/downgrade-php70.php b/config/set/downgrade-php70.php index d2fb71f2fde..1ddbd2ad484 100644 --- a/config/set/downgrade-php70.php +++ b/config/set/downgrade-php70.php @@ -23,24 +23,24 @@ use Rector\DowngradePhp70\Rector\MethodCall\DowngradeMethodCallOnCloneRector; use Rector\DowngradePhp70\Rector\New_\DowngradeAnonymousClassRector; use Rector\DowngradePhp70\Rector\Spaceship\DowngradeSpaceshipRector; use Rector\DowngradePhp70\Rector\TryCatch\DowngradeCatchThrowableRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_56); - $rectorConfig->rule(\Rector\DowngradePhp70\Rector\TryCatch\DowngradeCatchThrowableRector::class); - $rectorConfig->rule(\Rector\DowngradePhp70\Rector\Instanceof_\DowngradeInstanceofThrowableRector::class); - $rectorConfig->rule(\Rector\DowngradePhp70\Rector\FunctionLike\DowngradeScalarTypeDeclarationRector::class); - $rectorConfig->rule(\Rector\DowngradePhp70\Rector\FunctionLike\DowngradeThrowableTypeDeclarationRector::class); - $rectorConfig->rule(\Rector\DowngradePhp70\Rector\Declare_\DowngradeStrictTypeDeclarationRector::class); - $rectorConfig->rule(\Rector\DowngradePhp70\Rector\ClassMethod\DowngradeSelfTypeDeclarationRector::class); - $rectorConfig->rule(\Rector\DowngradePhp70\Rector\New_\DowngradeAnonymousClassRector::class); - $rectorConfig->rule(\Rector\DowngradePhp70\Rector\Coalesce\DowngradeNullCoalesceRector::class); - $rectorConfig->rule(\Rector\DowngradePhp70\Rector\Spaceship\DowngradeSpaceshipRector::class); - $rectorConfig->rule(\Rector\DowngradePhp70\Rector\Expression\DowngradeDefineArrayConstantRector::class); - $rectorConfig->rule(\Rector\DowngradePhp70\Rector\FuncCall\DowngradeDirnameLevelsRector::class); - $rectorConfig->rule(\Rector\DowngradePhp70\Rector\FuncCall\DowngradeSessionStartArrayOptionsRector::class); - $rectorConfig->rule(\Rector\DowngradePhp70\Rector\FuncCall\DowngradeUncallableValueCallToCallUserFuncRector::class); - $rectorConfig->rule(\Rector\DowngradePhp70\Rector\GroupUse\SplitGroupedUseImportsRector::class); - $rectorConfig->rule(\Rector\DowngradePhp70\Rector\MethodCall\DowngradeClosureCallRector::class); - $rectorConfig->rule(\Rector\DowngradePhp70\Rector\ClassMethod\DowngradeParentTypeDeclarationRector::class); - $rectorConfig->rule(\Rector\DowngradePhp70\Rector\MethodCall\DowngradeMethodCallOnCloneRector::class); - $rectorConfig->rule(\Rector\DowngradePhp70\Rector\Expr\DowngradeUnnecessarilyParenthesizedExpressionRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->phpVersion(PhpVersion::PHP_56); + $rectorConfig->rule(DowngradeCatchThrowableRector::class); + $rectorConfig->rule(DowngradeInstanceofThrowableRector::class); + $rectorConfig->rule(DowngradeScalarTypeDeclarationRector::class); + $rectorConfig->rule(DowngradeThrowableTypeDeclarationRector::class); + $rectorConfig->rule(DowngradeStrictTypeDeclarationRector::class); + $rectorConfig->rule(DowngradeSelfTypeDeclarationRector::class); + $rectorConfig->rule(DowngradeAnonymousClassRector::class); + $rectorConfig->rule(DowngradeNullCoalesceRector::class); + $rectorConfig->rule(DowngradeSpaceshipRector::class); + $rectorConfig->rule(DowngradeDefineArrayConstantRector::class); + $rectorConfig->rule(DowngradeDirnameLevelsRector::class); + $rectorConfig->rule(DowngradeSessionStartArrayOptionsRector::class); + $rectorConfig->rule(DowngradeUncallableValueCallToCallUserFuncRector::class); + $rectorConfig->rule(SplitGroupedUseImportsRector::class); + $rectorConfig->rule(DowngradeClosureCallRector::class); + $rectorConfig->rule(DowngradeParentTypeDeclarationRector::class); + $rectorConfig->rule(DowngradeMethodCallOnCloneRector::class); + $rectorConfig->rule(DowngradeUnnecessarilyParenthesizedExpressionRector::class); }; diff --git a/config/set/downgrade-php71.php b/config/set/downgrade-php71.php index cb147982c1e..35ea6e23186 100644 --- a/config/set/downgrade-php71.php +++ b/config/set/downgrade-php71.php @@ -16,17 +16,17 @@ use Rector\DowngradePhp71\Rector\List_\DowngradeKeysInListRector; use Rector\DowngradePhp71\Rector\StaticCall\DowngradeClosureFromCallableRector; use Rector\DowngradePhp71\Rector\String_\DowngradeNegativeStringOffsetToStrlenRector; use Rector\DowngradePhp71\Rector\TryCatch\DowngradePipeToMultiCatchExceptionRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_70); - $rectorConfig->rule(\Rector\DowngradePhp71\Rector\FunctionLike\DowngradeNullableTypeDeclarationRector::class); - $rectorConfig->rule(\Rector\DowngradePhp71\Rector\FunctionLike\DowngradeVoidTypeDeclarationRector::class); - $rectorConfig->rule(\Rector\DowngradePhp71\Rector\ClassConst\DowngradeClassConstantVisibilityRector::class); - $rectorConfig->rule(\Rector\DowngradePhp71\Rector\TryCatch\DowngradePipeToMultiCatchExceptionRector::class); - $rectorConfig->rule(\Rector\DowngradePhp71\Rector\Array_\SymmetricArrayDestructuringToListRector::class); - $rectorConfig->rule(\Rector\DowngradePhp71\Rector\String_\DowngradeNegativeStringOffsetToStrlenRector::class); - $rectorConfig->rule(\Rector\DowngradePhp71\Rector\List_\DowngradeKeysInListRector::class); - $rectorConfig->rule(\Rector\DowngradePhp71\Rector\FunctionLike\DowngradeIterablePseudoTypeDeclarationRector::class); - $rectorConfig->rule(\Rector\DowngradePhp71\Rector\FuncCall\DowngradeIsIterableRector::class); - $rectorConfig->rule(\Rector\DowngradePhp71\Rector\StaticCall\DowngradeClosureFromCallableRector::class); - $rectorConfig->rule(\Rector\DowngradePhp71\Rector\ConstFetch\DowngradePhp71JsonConstRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->phpVersion(PhpVersion::PHP_70); + $rectorConfig->rule(DowngradeNullableTypeDeclarationRector::class); + $rectorConfig->rule(DowngradeVoidTypeDeclarationRector::class); + $rectorConfig->rule(DowngradeClassConstantVisibilityRector::class); + $rectorConfig->rule(DowngradePipeToMultiCatchExceptionRector::class); + $rectorConfig->rule(SymmetricArrayDestructuringToListRector::class); + $rectorConfig->rule(DowngradeNegativeStringOffsetToStrlenRector::class); + $rectorConfig->rule(DowngradeKeysInListRector::class); + $rectorConfig->rule(DowngradeIterablePseudoTypeDeclarationRector::class); + $rectorConfig->rule(DowngradeIsIterableRector::class); + $rectorConfig->rule(DowngradeClosureFromCallableRector::class); + $rectorConfig->rule(DowngradePhp71JsonConstRector::class); }; diff --git a/config/set/downgrade-php72.php b/config/set/downgrade-php72.php index 3a0eab78a50..e1fda617a17 100644 --- a/config/set/downgrade-php72.php +++ b/config/set/downgrade-php72.php @@ -11,12 +11,12 @@ use Rector\DowngradePhp72\Rector\FuncCall\DowngradeJsonDecodeNullAssociativeArgR use Rector\DowngradePhp72\Rector\FuncCall\DowngradePregUnmatchedAsNullConstantRector; use Rector\DowngradePhp72\Rector\FuncCall\DowngradeStreamIsattyRector; use Rector\DowngradePhp72\Rector\FunctionLike\DowngradeObjectTypeDeclarationRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_71); - $rectorConfig->rule(\Rector\DowngradePhp72\Rector\FunctionLike\DowngradeObjectTypeDeclarationRector::class); - $rectorConfig->rule(\Rector\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector::class); - $rectorConfig->rule(\Rector\DowngradePhp72\Rector\FuncCall\DowngradePregUnmatchedAsNullConstantRector::class); - $rectorConfig->rule(\Rector\DowngradePhp72\Rector\FuncCall\DowngradeStreamIsattyRector::class); - $rectorConfig->rule(\Rector\DowngradePhp72\Rector\FuncCall\DowngradeJsonDecodeNullAssociativeArgRector::class); - $rectorConfig->rule(\Rector\DowngradePhp72\Rector\ConstFetch\DowngradePhp72JsonConstRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->phpVersion(PhpVersion::PHP_71); + $rectorConfig->rule(DowngradeObjectTypeDeclarationRector::class); + $rectorConfig->rule(DowngradeParameterTypeWideningRector::class); + $rectorConfig->rule(DowngradePregUnmatchedAsNullConstantRector::class); + $rectorConfig->rule(DowngradeStreamIsattyRector::class); + $rectorConfig->rule(DowngradeJsonDecodeNullAssociativeArgRector::class); + $rectorConfig->rule(DowngradePhp72JsonConstRector::class); }; diff --git a/config/set/downgrade-php73.php b/config/set/downgrade-php73.php index 4b88206b664..724b6a38467 100644 --- a/config/set/downgrade-php73.php +++ b/config/set/downgrade-php73.php @@ -12,13 +12,13 @@ use Rector\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCalls use Rector\DowngradePhp73\Rector\FuncCall\SetCookieOptionsArrayToArgumentsRector; use Rector\DowngradePhp73\Rector\List_\DowngradeListReferenceAssignmentRector; use Rector\DowngradePhp73\Rector\String_\DowngradeFlexibleHeredocSyntaxRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_72); - $rectorConfig->rule(\Rector\DowngradePhp73\Rector\String_\DowngradeFlexibleHeredocSyntaxRector::class); - $rectorConfig->rule(\Rector\DowngradePhp73\Rector\List_\DowngradeListReferenceAssignmentRector::class); - $rectorConfig->rule(\Rector\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCallsRector::class); - $rectorConfig->rule(\Rector\DowngradePhp73\Rector\FuncCall\DowngradeArrayKeyFirstLastRector::class); - $rectorConfig->rule(\Rector\DowngradePhp73\Rector\FuncCall\SetCookieOptionsArrayToArgumentsRector::class); - $rectorConfig->rule(\Rector\DowngradePhp73\Rector\FuncCall\DowngradeIsCountableRector::class); - $rectorConfig->rule(\Rector\DowngradePhp73\Rector\ConstFetch\DowngradePhp73JsonConstRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->phpVersion(PhpVersion::PHP_72); + $rectorConfig->rule(DowngradeFlexibleHeredocSyntaxRector::class); + $rectorConfig->rule(DowngradeListReferenceAssignmentRector::class); + $rectorConfig->rule(DowngradeTrailingCommasInFunctionCallsRector::class); + $rectorConfig->rule(DowngradeArrayKeyFirstLastRector::class); + $rectorConfig->rule(SetCookieOptionsArrayToArgumentsRector::class); + $rectorConfig->rule(DowngradeIsCountableRector::class); + $rectorConfig->rule(DowngradePhp73JsonConstRector::class); }; diff --git a/config/set/downgrade-php74.php b/config/set/downgrade-php74.php index 295add72a7e..e61f7956aeb 100644 --- a/config/set/downgrade-php74.php +++ b/config/set/downgrade-php74.php @@ -17,18 +17,18 @@ use Rector\DowngradePhp74\Rector\Interface_\DowngradePreviouslyImplementedInterf use Rector\DowngradePhp74\Rector\LNumber\DowngradeNumericLiteralSeparatorRector; use Rector\DowngradePhp74\Rector\MethodCall\DowngradeReflectionGetTypeRector; use Rector\DowngradePhp74\Rector\Property\DowngradeTypedPropertyRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_73); - $rectorConfig->rule(\Rector\DowngradePhp74\Rector\Property\DowngradeTypedPropertyRector::class); - $rectorConfig->rule(\Rector\DowngradePhp74\Rector\ArrowFunction\ArrowFunctionToAnonymousFunctionRector::class); - $rectorConfig->rule(\Rector\DowngradePhp74\Rector\ClassMethod\DowngradeCovariantReturnTypeRector::class); - $rectorConfig->rule(\Rector\DowngradePhp74\Rector\ClassMethod\DowngradeContravariantArgumentTypeRector::class); - $rectorConfig->rule(\Rector\DowngradePhp74\Rector\Coalesce\DowngradeNullCoalescingOperatorRector::class); - $rectorConfig->rule(\Rector\DowngradePhp74\Rector\LNumber\DowngradeNumericLiteralSeparatorRector::class); - $rectorConfig->rule(\Rector\DowngradePhp74\Rector\FuncCall\DowngradeStripTagsCallWithArrayRector::class); - $rectorConfig->rule(\Rector\DowngradePhp74\Rector\Array_\DowngradeArraySpreadRector::class); - $rectorConfig->rule(\Rector\DowngradePhp74\Rector\FuncCall\DowngradeArrayMergeCallWithoutArgumentsRector::class); - $rectorConfig->rule(\Rector\DowngradePhp74\Rector\Identical\DowngradeFreadFwriteFalsyToNegationRector::class); - $rectorConfig->rule(\Rector\DowngradePhp74\Rector\Interface_\DowngradePreviouslyImplementedInterfaceRector::class); - $rectorConfig->rule(\Rector\DowngradePhp74\Rector\MethodCall\DowngradeReflectionGetTypeRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->phpVersion(PhpVersion::PHP_73); + $rectorConfig->rule(DowngradeTypedPropertyRector::class); + $rectorConfig->rule(ArrowFunctionToAnonymousFunctionRector::class); + $rectorConfig->rule(DowngradeCovariantReturnTypeRector::class); + $rectorConfig->rule(DowngradeContravariantArgumentTypeRector::class); + $rectorConfig->rule(DowngradeNullCoalescingOperatorRector::class); + $rectorConfig->rule(DowngradeNumericLiteralSeparatorRector::class); + $rectorConfig->rule(DowngradeStripTagsCallWithArrayRector::class); + $rectorConfig->rule(DowngradeArraySpreadRector::class); + $rectorConfig->rule(DowngradeArrayMergeCallWithoutArgumentsRector::class); + $rectorConfig->rule(DowngradeFreadFwriteFalsyToNegationRector::class); + $rectorConfig->rule(DowngradePreviouslyImplementedInterfaceRector::class); + $rectorConfig->rule(DowngradeReflectionGetTypeRector::class); }; diff --git a/config/set/downgrade-php80.php b/config/set/downgrade-php80.php index a1602695ef0..f555671d6c7 100644 --- a/config/set/downgrade-php80.php +++ b/config/set/downgrade-php80.php @@ -35,43 +35,43 @@ use Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector; use Rector\DowngradePhp80\Rector\StaticCall\DowngradePhpTokenRector; use Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation; use Rector\Removing\Rector\Class_\RemoveInterfacesRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_74); - $rectorConfig->ruleWithConfiguration(\Rector\Removing\Rector\Class_\RemoveInterfacesRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->phpVersion(PhpVersion::PHP_74); + $rectorConfig->ruleWithConfiguration(RemoveInterfacesRector::class, [ // @see https://wiki.php.net/rfc/stringable 'Stringable', ]); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\DowngradePhp80\Rector\Class_\DowngradeAttributeToAnnotationRector::class, [ + $rectorConfig->rule(DowngradeNamedArgumentRector::class); + $rectorConfig->ruleWithConfiguration(DowngradeAttributeToAnnotationRector::class, [ // Symfony - new \Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation('Symfony\\Contracts\\Service\\Attribute\\Required', 'required'), + new DowngradeAttributeToAnnotation('Symfony\\Contracts\\Service\\Attribute\\Required', 'required'), // Nette - new \Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation('Nette\\DI\\Attributes\\Inject', 'inject'), + new DowngradeAttributeToAnnotation('Nette\\DI\\Attributes\\Inject', 'inject'), ]); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\ArrayDimFetch\DowngradeDereferenceableOperationRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeStaticTypeDeclarationRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeAbstractPrivateMethodInTraitRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\Class_\DowngradePropertyPromotionRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\Catch_\DowngradeNonCapturingCatchesRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\FuncCall\DowngradeStrContainsRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\ClassConstFetch\DowngradeClassOnObjectToGetClassRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\New_\DowngradeArbitraryExpressionsSupportRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\NullsafeMethodCall\DowngradeNullsafeToTernaryOperatorRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeTrailingCommasInParamUseRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\FuncCall\DowngradeStrStartsWithRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\FuncCall\DowngradeStrEndsWithRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\StaticCall\DowngradePhpTokenRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\Expression\DowngradeThrowExprRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\Instanceof_\DowngradePhp80ResourceReturnToObjectRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\MethodCall\DowngradeReflectionGetAttributesRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeRecursiveDirectoryIteratorHasChildrenRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\MethodCall\DowngradeReflectionPropertyGetDefaultValueRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\MethodCall\DowngradeReflectionClassGetConstantsFilterRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\FuncCall\DowngradeArrayFilterNullableCallbackRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\FuncCall\DowngradeNumberFormatNoFourthArgRector::class); - $rectorConfig->rule(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeStringReturnTypeOnToStringRector::class); + $rectorConfig->rule(DowngradeDereferenceableOperationRector::class); + $rectorConfig->rule(DowngradeUnionTypeTypedPropertyRector::class); + $rectorConfig->rule(DowngradeUnionTypeDeclarationRector::class); + $rectorConfig->rule(DowngradeMixedTypeDeclarationRector::class); + $rectorConfig->rule(DowngradeStaticTypeDeclarationRector::class); + $rectorConfig->rule(DowngradeAbstractPrivateMethodInTraitRector::class); + $rectorConfig->rule(DowngradePropertyPromotionRector::class); + $rectorConfig->rule(DowngradeNonCapturingCatchesRector::class); + $rectorConfig->rule(DowngradeStrContainsRector::class); + $rectorConfig->rule(DowngradeMatchToSwitchRector::class); + $rectorConfig->rule(DowngradeClassOnObjectToGetClassRector::class); + $rectorConfig->rule(DowngradeArbitraryExpressionsSupportRector::class); + $rectorConfig->rule(DowngradeNullsafeToTernaryOperatorRector::class); + $rectorConfig->rule(DowngradeTrailingCommasInParamUseRector::class); + $rectorConfig->rule(DowngradeStrStartsWithRector::class); + $rectorConfig->rule(DowngradeStrEndsWithRector::class); + $rectorConfig->rule(DowngradePhpTokenRector::class); + $rectorConfig->rule(DowngradeThrowExprRector::class); + $rectorConfig->rule(DowngradePhp80ResourceReturnToObjectRector::class); + $rectorConfig->rule(DowngradeReflectionGetAttributesRector::class); + $rectorConfig->rule(DowngradeRecursiveDirectoryIteratorHasChildrenRector::class); + $rectorConfig->rule(DowngradeReflectionPropertyGetDefaultValueRector::class); + $rectorConfig->rule(DowngradeReflectionClassGetConstantsFilterRector::class); + $rectorConfig->rule(DowngradeArrayFilterNullableCallbackRector::class); + $rectorConfig->rule(DowngradeNumberFormatNoFourthArgRector::class); + $rectorConfig->rule(DowngradeStringReturnTypeOnToStringRector::class); }; diff --git a/config/set/downgrade-php81.php b/config/set/downgrade-php81.php index 338b7b85ce3..2266404e332 100644 --- a/config/set/downgrade-php81.php +++ b/config/set/downgrade-php81.php @@ -14,15 +14,15 @@ use Rector\DowngradePhp81\Rector\FunctionLike\DowngradeNewInInitializerRector; use Rector\DowngradePhp81\Rector\FunctionLike\DowngradePureIntersectionTypeRector; use Rector\DowngradePhp81\Rector\Instanceof_\DowngradePhp81ResourceReturnToObjectRector; use Rector\DowngradePhp81\Rector\Property\DowngradeReadonlyPropertyRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_80); - $rectorConfig->rule(\Rector\DowngradePhp81\Rector\ClassConst\DowngradeFinalizePublicClassConstantRector::class); - $rectorConfig->rule(\Rector\DowngradePhp81\Rector\FuncCall\DowngradeFirstClassCallableSyntaxRector::class); - $rectorConfig->rule(\Rector\DowngradePhp81\Rector\FunctionLike\DowngradeNeverTypeDeclarationRector::class); - $rectorConfig->rule(\Rector\DowngradePhp81\Rector\FunctionLike\DowngradePureIntersectionTypeRector::class); - $rectorConfig->rule(\Rector\DowngradePhp81\Rector\FunctionLike\DowngradeNewInInitializerRector::class); - $rectorConfig->rule(\Rector\DowngradePhp81\Rector\Instanceof_\DowngradePhp81ResourceReturnToObjectRector::class); - $rectorConfig->rule(\Rector\DowngradePhp81\Rector\Property\DowngradeReadonlyPropertyRector::class); - $rectorConfig->rule(\Rector\DowngradePhp81\Rector\Array_\DowngradeArraySpreadStringKeyRector::class); - $rectorConfig->rule(\Rector\DowngradePhp81\Rector\FuncCall\DowngradeArrayIsListRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->phpVersion(PhpVersion::PHP_80); + $rectorConfig->rule(DowngradeFinalizePublicClassConstantRector::class); + $rectorConfig->rule(DowngradeFirstClassCallableSyntaxRector::class); + $rectorConfig->rule(DowngradeNeverTypeDeclarationRector::class); + $rectorConfig->rule(DowngradePureIntersectionTypeRector::class); + $rectorConfig->rule(DowngradeNewInInitializerRector::class); + $rectorConfig->rule(DowngradePhp81ResourceReturnToObjectRector::class); + $rectorConfig->rule(DowngradeReadonlyPropertyRector::class); + $rectorConfig->rule(DowngradeArraySpreadStringKeyRector::class); + $rectorConfig->rule(DowngradeArrayIsListRector::class); }; diff --git a/config/set/downgrade-php82.php b/config/set/downgrade-php82.php index 7600372ee63..63faf66ec55 100644 --- a/config/set/downgrade-php82.php +++ b/config/set/downgrade-php82.php @@ -6,7 +6,7 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Core\ValueObject\PhpVersion; use Rector\DowngradePhp82\Rector\Class_\DowngradeReadonlyClassRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_81); - $rectorConfig->rule(\Rector\DowngradePhp82\Rector\Class_\DowngradeReadonlyClassRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->phpVersion(PhpVersion::PHP_81); + $rectorConfig->rule(DowngradeReadonlyClassRector::class); }; diff --git a/config/set/early-return.php b/config/set/early-return.php index 71a89d78527..2a0eb0f6fa3 100644 --- a/config/set/early-return.php +++ b/config/set/early-return.php @@ -15,16 +15,16 @@ use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector; use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector; use Rector\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector; use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector::class); - $rectorConfig->rule(\Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector::class); - $rectorConfig->rule(\Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector::class); - $rectorConfig->rule(\Rector\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector::class); - $rectorConfig->rule(\Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector::class); - $rectorConfig->rule(\Rector\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector::class); - $rectorConfig->rule(\Rector\EarlyReturn\Rector\If_\ChangeOrIfReturnToEarlyReturnRector::class); - $rectorConfig->rule(\Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector::class); - $rectorConfig->rule(\Rector\EarlyReturn\Rector\Foreach_\ReturnAfterToEarlyOnBreakRector::class); - $rectorConfig->rule(\Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector::class); - $rectorConfig->rule(\Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(ChangeNestedForeachIfsToEarlyContinueRector::class); + $rectorConfig->rule(ChangeAndIfToEarlyReturnRector::class); + $rectorConfig->rule(ChangeIfElseValueAssignToEarlyReturnRector::class); + $rectorConfig->rule(ChangeNestedIfsToEarlyReturnRector::class); + $rectorConfig->rule(RemoveAlwaysElseRector::class); + $rectorConfig->rule(ReturnBinaryAndToEarlyReturnRector::class); + $rectorConfig->rule(ChangeOrIfReturnToEarlyReturnRector::class); + $rectorConfig->rule(ChangeOrIfContinueToMultiContinueRector::class); + $rectorConfig->rule(ReturnAfterToEarlyOnBreakRector::class); + $rectorConfig->rule(PreparedValueToEarlyReturnRector::class); + $rectorConfig->rule(ReturnBinaryOrToEarlyReturnRector::class); }; diff --git a/config/set/flysystem-20.php b/config/set/flysystem-20.php index 1e2e1783578..670a0569057 100644 --- a/config/set/flysystem-20.php +++ b/config/set/flysystem-20.php @@ -6,22 +6,22 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\ValueObject\MethodCallRename; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ // Rename is now move, specific for files. - new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'rename', 'move'), + new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'rename', 'move'), // No arbitrary abbreviations - new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'createDir', 'createDirectory'), + new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'createDir', 'createDirectory'), // Writes are now deterministic - new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'update', 'write'), - new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'updateStream', 'writeStream'), - new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'put', 'write'), - new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'putStream', 'writeStream'), + new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'update', 'write'), + new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'updateStream', 'writeStream'), + new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'put', 'write'), + new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'putStream', 'writeStream'), // Metadata getters are renamed - new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getTimestamp', 'lastModified'), - new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'has', 'fileExists'), - new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getMimetype', 'mimeType'), - new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getSize', 'fileSize'), - new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getVisibility', 'visibility'), + new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getTimestamp', 'lastModified'), + new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'has', 'fileExists'), + new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getMimetype', 'mimeType'), + new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getSize', 'fileSize'), + new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getVisibility', 'visibility'), ]); }; diff --git a/config/set/framework-extra-bundle-40.php b/config/set/framework-extra-bundle-40.php index d0c52370af8..e5f1a0a669a 100644 --- a/config/set/framework-extra-bundle-40.php +++ b/config/set/framework-extra-bundle-40.php @@ -6,7 +6,7 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Rector\ClassMethod\RemoveServiceFromSensioRouteRector; use Rector\Symfony\Rector\ClassMethod\ReplaceSensioRouteAnnotationWithSymfonyRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Symfony\Rector\ClassMethod\ReplaceSensioRouteAnnotationWithSymfonyRector::class); - $rectorConfig->rule(\Rector\Symfony\Rector\ClassMethod\RemoveServiceFromSensioRouteRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(ReplaceSensioRouteAnnotationWithSymfonyRector::class); + $rectorConfig->rule(RemoveServiceFromSensioRouteRector::class); }; diff --git a/config/set/framework-extra-bundle-50.php b/config/set/framework-extra-bundle-50.php index 6954801d240..0c6eca4574a 100644 --- a/config/set/framework-extra-bundle-50.php +++ b/config/set/framework-extra-bundle-50.php @@ -5,6 +5,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Rector\ClassMethod\TemplateAnnotationToThisRenderRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Symfony\Rector\ClassMethod\TemplateAnnotationToThisRenderRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(TemplateAnnotationToThisRenderRector::class); }; diff --git a/config/set/gmagick_to_imagick.php b/config/set/gmagick_to_imagick.php index 733f22316f3..7d0cf614b45 100644 --- a/config/set/gmagick_to_imagick.php +++ b/config/set/gmagick_to_imagick.php @@ -8,7 +8,7 @@ use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Renaming\ValueObject\MethodCallRename; # https://www.php.net/manual/en/book.gmagick.php → https://www.php.net/manual/en/book.imagick.php -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Gmagick' => 'Imagick', 'GmagickPixel' => 'ImagickPixel']); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'addimage', 'addImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'addnoiseimage', 'addNoiseImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'annotateimage', 'annotateImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'blurimage', 'blurImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'borderimage', 'borderImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'charcoalimage', 'charcoalImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'chopimage', 'chopImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'commentimage', 'commentImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'compositeimage', 'compositeImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'cropimage', 'cropImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'cropthumbnailimage', 'cropThumbnailImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'cyclecolormapimage', 'cycleColormapImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'deconstructimages', 'deconstructImages'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'despeckleimage', 'despeckleImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'drawimage', 'drawImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'edgeimage', 'edgeImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'embossimage', 'embossImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'enhanceimage', 'enhanceImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'equalizeimage', 'equalizeImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'flipimage', 'flipImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'flopimage', 'flopImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'frameimage', 'frameImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'gammaimage', 'gammaImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getcopyright', 'getCopyright'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getfilename', 'getFilename'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagebackgroundcolor', 'getImageBackgroundColor'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimageblueprimary', 'getImageBluePrimary'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagebordercolor', 'getImageBorderColor'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagechanneldepth', 'getImageChannelDepth'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagecolors', 'getImageColors'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagecolorspace', 'getImageColorspace'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagecompose', 'getImageCompose'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagedelay', 'getImageDelay'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagedepth', 'getImageDepth'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagedispose', 'getImageDispose'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimageextrema', 'getImageExtrema'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagefilename', 'getImageFilename'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimageformat', 'getImageFormat'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagegamma', 'getImageGamma'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagegreenprimary', 'getImageGreenPrimary'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimageheight', 'getImageHeight'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagehistogram', 'getImageHistogram'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimageindex', 'getImageIndex'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimageinterlacescheme', 'getImageInterlaceScheme'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimageiterations', 'getImageIterations'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagematte', 'getImageMatte'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagemattecolor', 'getImageMatteColor'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimageprofile', 'getImageProfile'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimageredprimary', 'getImageRedPrimary'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagerenderingintent', 'getImageRenderingIntent'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimageresolution', 'getImageResolution'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagescene', 'getImageScene'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagesignature', 'getImageSignature'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagetype', 'getImageType'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimageunits', 'getImageUnits'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagewhitepoint', 'getImageWhitePoint'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getimagewidth', 'getImageWidth'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getpackagename', 'getPackageName'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getquantumdepth', 'getQuantumDepth'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getreleasedate', 'getReleaseDate'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getsamplingfactors', 'getSamplingFactors'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getsize', 'getSize'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'getversion', 'getVersion'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'hasnextimage', 'hasNextImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'haspreviousimage', 'hasPreviousImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'implodeimage', 'implodeImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'labelimage', 'labelImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'levelimage', 'levelImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'magnifyimage', 'magnifyImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'mapimage', 'mapImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'medianfilterimage', 'medianFilterImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'minifyimage', 'minifyImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'modulateimage', 'modulateImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'motionblurimage', 'motionBlurImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'newimage', 'newImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'nextimage', 'nextImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'normalizeimage', 'normalizeImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'oilpaintimage', 'oilPaintImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'previousimage', 'previousImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'profileimage', 'profileImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'quantizeimage', 'quantizeImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'quantizeimages', 'quantizeImages'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'queryfontmetrics', 'queryFontMetrics'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'queryfonts', 'queryFonts'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'queryformats', 'queryFormats'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'radialblurimage', 'radialBlurImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'raiseimage', 'raiseImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'readimage', 'readimages'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'readimageblob', 'readImageBlob'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'readimagefile', 'readImageFile'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'reducenoiseimage', 'reduceNoiseImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'removeimage', 'removeImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'removeimageprofile', 'removeImageProfile'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'resampleimage', 'resampleImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'resizeimage', 'resizeImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'rollimage', 'rollImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'rotateimage', 'rotateImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'scaleimage', 'scaleImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'separateimagechannel', 'separateImageChannel'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setCompressionQuality', 'getCompressionQuality'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setfilename', 'setFilename'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimagebackgroundcolor', 'setImageBackgroundColor'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimageblueprimary', 'setImageBluePrimary'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimagebordercolor', 'setImageBorderColor'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimagechanneldepth', 'setImageChannelDepth'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimagecolorspace', 'setImageColorspace'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimagecompose', 'setImageCompose'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimagedelay', 'setImageDelay'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimagedepth', 'setImageDepth'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimagedispose', 'setImageDispose'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimagefilename', 'setImageFilename'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimageformat', 'setImageFormat'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimagegamma', 'setImageGamma'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimagegreenprimary', 'setImageGreenPrimary'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimageindex', 'setImageIndex'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimageinterlacescheme', 'setImageInterlaceScheme'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimageiterations', 'setImageIterations'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimageprofile', 'setImageProfile'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimageredprimary', 'setImageRedPrimary'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimagerenderingintent', 'setImageRenderingIntent'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimageresolution', 'setImageResolution'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimagescene', 'setImageScene'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimagetype', 'setImageType'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimageunits', 'setImageUnits'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setimagewhitepoint', 'setImageWhitePoint'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setsamplingfactors', 'setSamplingFactors'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'setsize', 'setSize'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'shearimage', 'shearImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'solarizeimage', 'solarizeImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'spreadimage', 'spreadImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'stripimage', 'stripImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'swirlimage', 'swirlImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'thumbnailimage', 'thumbnailImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'trimimage', 'trimImage'), new \Rector\Renaming\ValueObject\MethodCallRename('Gmagick', 'writeimage', 'writeImage'), new \Rector\Renaming\ValueObject\MethodCallRename('GmagickPixel', 'getcolor', 'getColor'), new \Rector\Renaming\ValueObject\MethodCallRename('GmagickPixel', 'getcolorcount', 'getColorCount'), new \Rector\Renaming\ValueObject\MethodCallRename('GmagickPixel', 'getcolorvalue', 'getColorValue'), new \Rector\Renaming\ValueObject\MethodCallRename('GmagickPixel', 'setcolor', 'setColor'), new \Rector\Renaming\ValueObject\MethodCallRename('GmagickPixel', 'setcolorvalue', 'setColorValue')]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Gmagick' => 'Imagick', 'GmagickPixel' => 'ImagickPixel']); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Gmagick', 'addimage', 'addImage'), new MethodCallRename('Gmagick', 'addnoiseimage', 'addNoiseImage'), new MethodCallRename('Gmagick', 'annotateimage', 'annotateImage'), new MethodCallRename('Gmagick', 'blurimage', 'blurImage'), new MethodCallRename('Gmagick', 'borderimage', 'borderImage'), new MethodCallRename('Gmagick', 'charcoalimage', 'charcoalImage'), new MethodCallRename('Gmagick', 'chopimage', 'chopImage'), new MethodCallRename('Gmagick', 'commentimage', 'commentImage'), new MethodCallRename('Gmagick', 'compositeimage', 'compositeImage'), new MethodCallRename('Gmagick', 'cropimage', 'cropImage'), new MethodCallRename('Gmagick', 'cropthumbnailimage', 'cropThumbnailImage'), new MethodCallRename('Gmagick', 'cyclecolormapimage', 'cycleColormapImage'), new MethodCallRename('Gmagick', 'deconstructimages', 'deconstructImages'), new MethodCallRename('Gmagick', 'despeckleimage', 'despeckleImage'), new MethodCallRename('Gmagick', 'drawimage', 'drawImage'), new MethodCallRename('Gmagick', 'edgeimage', 'edgeImage'), new MethodCallRename('Gmagick', 'embossimage', 'embossImage'), new MethodCallRename('Gmagick', 'enhanceimage', 'enhanceImage'), new MethodCallRename('Gmagick', 'equalizeimage', 'equalizeImage'), new MethodCallRename('Gmagick', 'flipimage', 'flipImage'), new MethodCallRename('Gmagick', 'flopimage', 'flopImage'), new MethodCallRename('Gmagick', 'frameimage', 'frameImage'), new MethodCallRename('Gmagick', 'gammaimage', 'gammaImage'), new MethodCallRename('Gmagick', 'getcopyright', 'getCopyright'), new MethodCallRename('Gmagick', 'getfilename', 'getFilename'), new MethodCallRename('Gmagick', 'getimagebackgroundcolor', 'getImageBackgroundColor'), new MethodCallRename('Gmagick', 'getimageblueprimary', 'getImageBluePrimary'), new MethodCallRename('Gmagick', 'getimagebordercolor', 'getImageBorderColor'), new MethodCallRename('Gmagick', 'getimagechanneldepth', 'getImageChannelDepth'), new MethodCallRename('Gmagick', 'getimagecolors', 'getImageColors'), new MethodCallRename('Gmagick', 'getimagecolorspace', 'getImageColorspace'), new MethodCallRename('Gmagick', 'getimagecompose', 'getImageCompose'), new MethodCallRename('Gmagick', 'getimagedelay', 'getImageDelay'), new MethodCallRename('Gmagick', 'getimagedepth', 'getImageDepth'), new MethodCallRename('Gmagick', 'getimagedispose', 'getImageDispose'), new MethodCallRename('Gmagick', 'getimageextrema', 'getImageExtrema'), new MethodCallRename('Gmagick', 'getimagefilename', 'getImageFilename'), new MethodCallRename('Gmagick', 'getimageformat', 'getImageFormat'), new MethodCallRename('Gmagick', 'getimagegamma', 'getImageGamma'), new MethodCallRename('Gmagick', 'getimagegreenprimary', 'getImageGreenPrimary'), new MethodCallRename('Gmagick', 'getimageheight', 'getImageHeight'), new MethodCallRename('Gmagick', 'getimagehistogram', 'getImageHistogram'), new MethodCallRename('Gmagick', 'getimageindex', 'getImageIndex'), new MethodCallRename('Gmagick', 'getimageinterlacescheme', 'getImageInterlaceScheme'), new MethodCallRename('Gmagick', 'getimageiterations', 'getImageIterations'), new MethodCallRename('Gmagick', 'getimagematte', 'getImageMatte'), new MethodCallRename('Gmagick', 'getimagemattecolor', 'getImageMatteColor'), new MethodCallRename('Gmagick', 'getimageprofile', 'getImageProfile'), new MethodCallRename('Gmagick', 'getimageredprimary', 'getImageRedPrimary'), new MethodCallRename('Gmagick', 'getimagerenderingintent', 'getImageRenderingIntent'), new MethodCallRename('Gmagick', 'getimageresolution', 'getImageResolution'), new MethodCallRename('Gmagick', 'getimagescene', 'getImageScene'), new MethodCallRename('Gmagick', 'getimagesignature', 'getImageSignature'), new MethodCallRename('Gmagick', 'getimagetype', 'getImageType'), new MethodCallRename('Gmagick', 'getimageunits', 'getImageUnits'), new MethodCallRename('Gmagick', 'getimagewhitepoint', 'getImageWhitePoint'), new MethodCallRename('Gmagick', 'getimagewidth', 'getImageWidth'), new MethodCallRename('Gmagick', 'getpackagename', 'getPackageName'), new MethodCallRename('Gmagick', 'getquantumdepth', 'getQuantumDepth'), new MethodCallRename('Gmagick', 'getreleasedate', 'getReleaseDate'), new MethodCallRename('Gmagick', 'getsamplingfactors', 'getSamplingFactors'), new MethodCallRename('Gmagick', 'getsize', 'getSize'), new MethodCallRename('Gmagick', 'getversion', 'getVersion'), new MethodCallRename('Gmagick', 'hasnextimage', 'hasNextImage'), new MethodCallRename('Gmagick', 'haspreviousimage', 'hasPreviousImage'), new MethodCallRename('Gmagick', 'implodeimage', 'implodeImage'), new MethodCallRename('Gmagick', 'labelimage', 'labelImage'), new MethodCallRename('Gmagick', 'levelimage', 'levelImage'), new MethodCallRename('Gmagick', 'magnifyimage', 'magnifyImage'), new MethodCallRename('Gmagick', 'mapimage', 'mapImage'), new MethodCallRename('Gmagick', 'medianfilterimage', 'medianFilterImage'), new MethodCallRename('Gmagick', 'minifyimage', 'minifyImage'), new MethodCallRename('Gmagick', 'modulateimage', 'modulateImage'), new MethodCallRename('Gmagick', 'motionblurimage', 'motionBlurImage'), new MethodCallRename('Gmagick', 'newimage', 'newImage'), new MethodCallRename('Gmagick', 'nextimage', 'nextImage'), new MethodCallRename('Gmagick', 'normalizeimage', 'normalizeImage'), new MethodCallRename('Gmagick', 'oilpaintimage', 'oilPaintImage'), new MethodCallRename('Gmagick', 'previousimage', 'previousImage'), new MethodCallRename('Gmagick', 'profileimage', 'profileImage'), new MethodCallRename('Gmagick', 'quantizeimage', 'quantizeImage'), new MethodCallRename('Gmagick', 'quantizeimages', 'quantizeImages'), new MethodCallRename('Gmagick', 'queryfontmetrics', 'queryFontMetrics'), new MethodCallRename('Gmagick', 'queryfonts', 'queryFonts'), new MethodCallRename('Gmagick', 'queryformats', 'queryFormats'), new MethodCallRename('Gmagick', 'radialblurimage', 'radialBlurImage'), new MethodCallRename('Gmagick', 'raiseimage', 'raiseImage'), new MethodCallRename('Gmagick', 'readimage', 'readimages'), new MethodCallRename('Gmagick', 'readimageblob', 'readImageBlob'), new MethodCallRename('Gmagick', 'readimagefile', 'readImageFile'), new MethodCallRename('Gmagick', 'reducenoiseimage', 'reduceNoiseImage'), new MethodCallRename('Gmagick', 'removeimage', 'removeImage'), new MethodCallRename('Gmagick', 'removeimageprofile', 'removeImageProfile'), new MethodCallRename('Gmagick', 'resampleimage', 'resampleImage'), new MethodCallRename('Gmagick', 'resizeimage', 'resizeImage'), new MethodCallRename('Gmagick', 'rollimage', 'rollImage'), new MethodCallRename('Gmagick', 'rotateimage', 'rotateImage'), new MethodCallRename('Gmagick', 'scaleimage', 'scaleImage'), new MethodCallRename('Gmagick', 'separateimagechannel', 'separateImageChannel'), new MethodCallRename('Gmagick', 'setCompressionQuality', 'getCompressionQuality'), new MethodCallRename('Gmagick', 'setfilename', 'setFilename'), new MethodCallRename('Gmagick', 'setimagebackgroundcolor', 'setImageBackgroundColor'), new MethodCallRename('Gmagick', 'setimageblueprimary', 'setImageBluePrimary'), new MethodCallRename('Gmagick', 'setimagebordercolor', 'setImageBorderColor'), new MethodCallRename('Gmagick', 'setimagechanneldepth', 'setImageChannelDepth'), new MethodCallRename('Gmagick', 'setimagecolorspace', 'setImageColorspace'), new MethodCallRename('Gmagick', 'setimagecompose', 'setImageCompose'), new MethodCallRename('Gmagick', 'setimagedelay', 'setImageDelay'), new MethodCallRename('Gmagick', 'setimagedepth', 'setImageDepth'), new MethodCallRename('Gmagick', 'setimagedispose', 'setImageDispose'), new MethodCallRename('Gmagick', 'setimagefilename', 'setImageFilename'), new MethodCallRename('Gmagick', 'setimageformat', 'setImageFormat'), new MethodCallRename('Gmagick', 'setimagegamma', 'setImageGamma'), new MethodCallRename('Gmagick', 'setimagegreenprimary', 'setImageGreenPrimary'), new MethodCallRename('Gmagick', 'setimageindex', 'setImageIndex'), new MethodCallRename('Gmagick', 'setimageinterlacescheme', 'setImageInterlaceScheme'), new MethodCallRename('Gmagick', 'setimageiterations', 'setImageIterations'), new MethodCallRename('Gmagick', 'setimageprofile', 'setImageProfile'), new MethodCallRename('Gmagick', 'setimageredprimary', 'setImageRedPrimary'), new MethodCallRename('Gmagick', 'setimagerenderingintent', 'setImageRenderingIntent'), new MethodCallRename('Gmagick', 'setimageresolution', 'setImageResolution'), new MethodCallRename('Gmagick', 'setimagescene', 'setImageScene'), new MethodCallRename('Gmagick', 'setimagetype', 'setImageType'), new MethodCallRename('Gmagick', 'setimageunits', 'setImageUnits'), new MethodCallRename('Gmagick', 'setimagewhitepoint', 'setImageWhitePoint'), new MethodCallRename('Gmagick', 'setsamplingfactors', 'setSamplingFactors'), new MethodCallRename('Gmagick', 'setsize', 'setSize'), new MethodCallRename('Gmagick', 'shearimage', 'shearImage'), new MethodCallRename('Gmagick', 'solarizeimage', 'solarizeImage'), new MethodCallRename('Gmagick', 'spreadimage', 'spreadImage'), new MethodCallRename('Gmagick', 'stripimage', 'stripImage'), new MethodCallRename('Gmagick', 'swirlimage', 'swirlImage'), new MethodCallRename('Gmagick', 'thumbnailimage', 'thumbnailImage'), new MethodCallRename('Gmagick', 'trimimage', 'trimImage'), new MethodCallRename('Gmagick', 'writeimage', 'writeImage'), new MethodCallRename('GmagickPixel', 'getcolor', 'getColor'), new MethodCallRename('GmagickPixel', 'getcolorcount', 'getColorCount'), new MethodCallRename('GmagickPixel', 'getcolorvalue', 'getColorValue'), new MethodCallRename('GmagickPixel', 'setcolor', 'setColor'), new MethodCallRename('GmagickPixel', 'setcolorvalue', 'setColorValue')]); }; diff --git a/config/set/guzzle50.php b/config/set/guzzle50.php index 232517da185..09e79de6931 100644 --- a/config/set/guzzle50.php +++ b/config/set/guzzle50.php @@ -10,9 +10,9 @@ use Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector; use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector; use Rector\Transform\ValueObject\FuncCallToMethodCall; use Rector\Transform\ValueObject\StaticCallToFuncCall; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $configuration = [new \Rector\Transform\ValueObject\FuncCallToMethodCall('GuzzleHttp\\json_decode', 'GuzzleHttp\\Utils', 'jsonDecode'), new \Rector\Transform\ValueObject\FuncCallToMethodCall('GuzzleHttp\\get_path', 'GuzzleHttp\\Utils', 'getPath')]; - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector::class, $configuration); - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::class, [new \Rector\Transform\ValueObject\StaticCallToFuncCall('GuzzleHttp\\Utils', 'setPath', 'GuzzleHttp\\set_path'), new \Rector\Transform\ValueObject\StaticCallToFuncCall('GuzzleHttp\\Pool', 'batch', 'GuzzleHttp\\Pool\\batch')]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('GuzzleHttp\\Message\\MessageInterface', 'getHeaderLines', 'getHeaderAsArray')]); +return static function (RectorConfig $rectorConfig) : void { + $configuration = [new FuncCallToMethodCall('GuzzleHttp\\json_decode', 'GuzzleHttp\\Utils', 'jsonDecode'), new FuncCallToMethodCall('GuzzleHttp\\get_path', 'GuzzleHttp\\Utils', 'getPath')]; + $rectorConfig->ruleWithConfiguration(FuncCallToMethodCallRector::class, $configuration); + $rectorConfig->ruleWithConfiguration(StaticCallToFuncCallRector::class, [new StaticCallToFuncCall('GuzzleHttp\\Utils', 'setPath', 'GuzzleHttp\\set_path'), new StaticCallToFuncCall('GuzzleHttp\\Pool', 'batch', 'GuzzleHttp\\Pool\\batch')]); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('GuzzleHttp\\Message\\MessageInterface', 'getHeaderLines', 'getHeaderAsArray')]); }; diff --git a/config/set/level/down-to-php52.php b/config/set/level/down-to-php52.php index 4f299d0828e..3cb187e1c84 100644 --- a/config/set/level/down-to-php52.php +++ b/config/set/level/down-to-php52.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Set\ValueObject\DowngradeLevelSetList; use Rector\Set\ValueObject\DowngradeSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_53, \Rector\Set\ValueObject\DowngradeSetList::PHP_53]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_53, DowngradeSetList::PHP_53]); }; diff --git a/config/set/level/down-to-php53.php b/config/set/level/down-to-php53.php index 7414b031536..390b8ebeb35 100644 --- a/config/set/level/down-to-php53.php +++ b/config/set/level/down-to-php53.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Set\ValueObject\DowngradeLevelSetList; use Rector\Set\ValueObject\DowngradeSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_54, \Rector\Set\ValueObject\DowngradeSetList::PHP_54]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_54, DowngradeSetList::PHP_54]); }; diff --git a/config/set/level/down-to-php54.php b/config/set/level/down-to-php54.php index d9d374f6367..54f91d3f44e 100644 --- a/config/set/level/down-to-php54.php +++ b/config/set/level/down-to-php54.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Set\ValueObject\DowngradeLevelSetList; use Rector\Set\ValueObject\DowngradeSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_55, \Rector\Set\ValueObject\DowngradeSetList::PHP_55]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_55, DowngradeSetList::PHP_55]); }; diff --git a/config/set/level/down-to-php55.php b/config/set/level/down-to-php55.php index 7f1773702b9..26987f2bcdb 100644 --- a/config/set/level/down-to-php55.php +++ b/config/set/level/down-to-php55.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Set\ValueObject\DowngradeLevelSetList; use Rector\Set\ValueObject\DowngradeSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_56, \Rector\Set\ValueObject\DowngradeSetList::PHP_56]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_56, DowngradeSetList::PHP_56]); }; diff --git a/config/set/level/down-to-php56.php b/config/set/level/down-to-php56.php index b0ec4f3902e..7f1601c952c 100644 --- a/config/set/level/down-to-php56.php +++ b/config/set/level/down-to-php56.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Set\ValueObject\DowngradeLevelSetList; use Rector\Set\ValueObject\DowngradeSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_70, \Rector\Set\ValueObject\DowngradeSetList::PHP_70]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_70, DowngradeSetList::PHP_70]); }; diff --git a/config/set/level/down-to-php70.php b/config/set/level/down-to-php70.php index b633322243e..5624fe6e84c 100644 --- a/config/set/level/down-to-php70.php +++ b/config/set/level/down-to-php70.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Set\ValueObject\DowngradeLevelSetList; use Rector\Set\ValueObject\DowngradeSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_71, \Rector\Set\ValueObject\DowngradeSetList::PHP_71]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_71, DowngradeSetList::PHP_71]); }; diff --git a/config/set/level/down-to-php71.php b/config/set/level/down-to-php71.php index aa12f169c17..e5697344f22 100644 --- a/config/set/level/down-to-php71.php +++ b/config/set/level/down-to-php71.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Set\ValueObject\DowngradeLevelSetList; use Rector\Set\ValueObject\DowngradeSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_72, \Rector\Set\ValueObject\DowngradeSetList::PHP_72]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_72, DowngradeSetList::PHP_72]); }; diff --git a/config/set/level/down-to-php72.php b/config/set/level/down-to-php72.php index c842be0241b..65bea364a0c 100644 --- a/config/set/level/down-to-php72.php +++ b/config/set/level/down-to-php72.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Set\ValueObject\DowngradeLevelSetList; use Rector\Set\ValueObject\DowngradeSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_73, \Rector\Set\ValueObject\DowngradeSetList::PHP_73]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_73, DowngradeSetList::PHP_73]); }; diff --git a/config/set/level/down-to-php73.php b/config/set/level/down-to-php73.php index f281a6f1438..03daceea991 100644 --- a/config/set/level/down-to-php73.php +++ b/config/set/level/down-to-php73.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Set\ValueObject\DowngradeLevelSetList; use Rector\Set\ValueObject\DowngradeSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_74, \Rector\Set\ValueObject\DowngradeSetList::PHP_74]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_74, DowngradeSetList::PHP_74]); }; diff --git a/config/set/level/down-to-php74.php b/config/set/level/down-to-php74.php index 05a73438a48..9a5402f696e 100644 --- a/config/set/level/down-to-php74.php +++ b/config/set/level/down-to-php74.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Set\ValueObject\DowngradeLevelSetList; use Rector\Set\ValueObject\DowngradeSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_80, \Rector\Set\ValueObject\DowngradeSetList::PHP_80]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_80, DowngradeSetList::PHP_80]); }; diff --git a/config/set/level/down-to-php80.php b/config/set/level/down-to-php80.php index edcc5c332ce..46db9bdab6a 100644 --- a/config/set/level/down-to-php80.php +++ b/config/set/level/down-to-php80.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Set\ValueObject\DowngradeLevelSetList; use Rector\Set\ValueObject\DowngradeSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_81, \Rector\Set\ValueObject\DowngradeSetList::PHP_81]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_81, DowngradeSetList::PHP_81]); }; diff --git a/config/set/level/down-to-php81.php b/config/set/level/down-to-php81.php index 4f026d42728..102280c815c 100644 --- a/config/set/level/down-to-php81.php +++ b/config/set/level/down-to-php81.php @@ -5,6 +5,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Set\ValueObject\DowngradeSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\DowngradeSetList::PHP_82]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([DowngradeSetList::PHP_82]); }; diff --git a/config/set/level/up-to-php54.php b/config/set/level/up-to-php54.php index 41dee9f4db4..70acf5a86e6 100644 --- a/config/set/level/up-to-php54.php +++ b/config/set/level/up-to-php54.php @@ -6,8 +6,8 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Core\ValueObject\PhpVersion; use Rector\Set\ValueObject\SetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_54, \Rector\Set\ValueObject\SetList::PHP_53]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SetList::PHP_54, SetList::PHP_53]); // parameter must be defined after import, to override imported param version - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_54); + $rectorConfig->phpVersion(PhpVersion::PHP_54); }; diff --git a/config/set/level/up-to-php55.php b/config/set/level/up-to-php55.php index 75633ca594c..6d9395bdbf7 100644 --- a/config/set/level/up-to-php55.php +++ b/config/set/level/up-to-php55.php @@ -7,8 +7,8 @@ use Rector\Config\RectorConfig; use Rector\Core\ValueObject\PhpVersion; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_55, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_54]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SetList::PHP_55, LevelSetList::UP_TO_PHP_54]); // parameter must be defined after import, to override imported param version - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_55); + $rectorConfig->phpVersion(PhpVersion::PHP_55); }; diff --git a/config/set/level/up-to-php56.php b/config/set/level/up-to-php56.php index 416a6d207f0..2f3ca8c90d0 100644 --- a/config/set/level/up-to-php56.php +++ b/config/set/level/up-to-php56.php @@ -7,8 +7,8 @@ use Rector\Config\RectorConfig; use Rector\Core\ValueObject\PhpVersion; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_56, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_55]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SetList::PHP_56, LevelSetList::UP_TO_PHP_55]); // parameter must be defined after import, to override imported param version - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_56); + $rectorConfig->phpVersion(PhpVersion::PHP_56); }; diff --git a/config/set/level/up-to-php70.php b/config/set/level/up-to-php70.php index 6ca6fbb3703..fd0de047844 100644 --- a/config/set/level/up-to-php70.php +++ b/config/set/level/up-to-php70.php @@ -7,8 +7,8 @@ use Rector\Config\RectorConfig; use Rector\Core\ValueObject\PhpVersion; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_70, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_56]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SetList::PHP_70, LevelSetList::UP_TO_PHP_56]); // parameter must be defined after import, to override imported param version - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_70); + $rectorConfig->phpVersion(PhpVersion::PHP_70); }; diff --git a/config/set/level/up-to-php71.php b/config/set/level/up-to-php71.php index cf40f117bfe..df42a40f0d5 100644 --- a/config/set/level/up-to-php71.php +++ b/config/set/level/up-to-php71.php @@ -7,8 +7,8 @@ use Rector\Config\RectorConfig; use Rector\Core\ValueObject\PhpVersion; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_71, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_70]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SetList::PHP_71, LevelSetList::UP_TO_PHP_70]); // parameter must be defined after import, to override imported param version - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_71); + $rectorConfig->phpVersion(PhpVersion::PHP_71); }; diff --git a/config/set/level/up-to-php72.php b/config/set/level/up-to-php72.php index 30796942b82..2287c765ff4 100644 --- a/config/set/level/up-to-php72.php +++ b/config/set/level/up-to-php72.php @@ -7,8 +7,8 @@ use Rector\Config\RectorConfig; use Rector\Core\ValueObject\PhpVersion; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_72, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_71]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SetList::PHP_72, LevelSetList::UP_TO_PHP_71]); // parameter must be defined after import, to override imported param version - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_72); + $rectorConfig->phpVersion(PhpVersion::PHP_72); }; diff --git a/config/set/level/up-to-php73.php b/config/set/level/up-to-php73.php index 43cd524453e..09e3db6e364 100644 --- a/config/set/level/up-to-php73.php +++ b/config/set/level/up-to-php73.php @@ -7,8 +7,8 @@ use Rector\Config\RectorConfig; use Rector\Core\ValueObject\PhpVersion; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_73, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_72]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SetList::PHP_73, LevelSetList::UP_TO_PHP_72]); // parameter must be defined after import, to override imported param version - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_73); + $rectorConfig->phpVersion(PhpVersion::PHP_73); }; diff --git a/config/set/level/up-to-php74.php b/config/set/level/up-to-php74.php index 87df74db147..c45a65cc486 100644 --- a/config/set/level/up-to-php74.php +++ b/config/set/level/up-to-php74.php @@ -7,8 +7,8 @@ use Rector\Config\RectorConfig; use Rector\Core\ValueObject\PhpVersion; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_74, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_73]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SetList::PHP_74, LevelSetList::UP_TO_PHP_73]); // parameter must be defined after import, to override imported param version - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_74); + $rectorConfig->phpVersion(PhpVersion::PHP_74); }; diff --git a/config/set/level/up-to-php80.php b/config/set/level/up-to-php80.php index 37027f74c2e..dfa3e95c45b 100644 --- a/config/set/level/up-to-php80.php +++ b/config/set/level/up-to-php80.php @@ -7,8 +7,8 @@ use Rector\Config\RectorConfig; use Rector\Core\ValueObject\PhpVersion; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_80, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_74]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SetList::PHP_80, LevelSetList::UP_TO_PHP_74]); // parameter must be defined after import, to override imported param version - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_80); + $rectorConfig->phpVersion(PhpVersion::PHP_80); }; diff --git a/config/set/level/up-to-php81.php b/config/set/level/up-to-php81.php index 6635017e7d5..ab4770e4893 100644 --- a/config/set/level/up-to-php81.php +++ b/config/set/level/up-to-php81.php @@ -7,8 +7,8 @@ use Rector\Config\RectorConfig; use Rector\Core\ValueObject\PhpVersion; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_81, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_80]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SetList::PHP_81, LevelSetList::UP_TO_PHP_80]); // parameter must be defined after import, to override imported param version - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_81); + $rectorConfig->phpVersion(PhpVersion::PHP_81); }; diff --git a/config/set/level/up-to-php82.php b/config/set/level/up-to-php82.php index 451cfcb754f..54b4d7cac12 100644 --- a/config/set/level/up-to-php82.php +++ b/config/set/level/up-to-php82.php @@ -7,8 +7,8 @@ use Rector\Config\RectorConfig; use Rector\Core\ValueObject\PhpVersion; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_82, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_81]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SetList::PHP_82, LevelSetList::UP_TO_PHP_81]); // parameter must be defined after import, to override imported param version - $rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_82); + $rectorConfig->phpVersion(PhpVersion::PHP_82); }; diff --git a/config/set/monolog20.php b/config/set/monolog20.php index ce073b2692e..3362c71c257 100644 --- a/config/set/monolog20.php +++ b/config/set/monolog20.php @@ -7,6 +7,6 @@ use Rector\Config\RectorConfig; use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\ValueObject\MethodCallRename; # https://github.com/Seldaek/monolog/commit/39f8a20e6dadc0194e846b254c5f23d1c732290b#diff-dce565f403e044caa5e6a0d988339430 -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addDebug', 'debug'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addInfo', 'info'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addNotice', 'notice'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addWarning', 'warning'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addError', 'error'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addCritical', 'critical'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addAlert', 'alert'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addEmergency', 'emergency'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'warn', 'warning'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'err', 'error'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'crit', 'critical'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'emerg', 'emergency')]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Monolog\\Logger', 'addDebug', 'debug'), new MethodCallRename('Monolog\\Logger', 'addInfo', 'info'), new MethodCallRename('Monolog\\Logger', 'addNotice', 'notice'), new MethodCallRename('Monolog\\Logger', 'addWarning', 'warning'), new MethodCallRename('Monolog\\Logger', 'addError', 'error'), new MethodCallRename('Monolog\\Logger', 'addCritical', 'critical'), new MethodCallRename('Monolog\\Logger', 'addAlert', 'alert'), new MethodCallRename('Monolog\\Logger', 'addEmergency', 'emergency'), new MethodCallRename('Monolog\\Logger', 'warn', 'warning'), new MethodCallRename('Monolog\\Logger', 'err', 'error'), new MethodCallRename('Monolog\\Logger', 'crit', 'critical'), new MethodCallRename('Monolog\\Logger', 'emerg', 'emergency')]); }; diff --git a/config/set/mysql-to-mysqli.php b/config/set/mysql-to-mysqli.php index 1792d324a8e..54d9dbb3bec 100644 --- a/config/set/mysql-to-mysqli.php +++ b/config/set/mysql-to-mysqli.php @@ -14,18 +14,18 @@ use Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector; use Rector\Removing\ValueObject\RemoveFuncCallArg; use Rector\Renaming\Rector\ConstFetch\RenameConstantRector; use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { # https://stackoverflow.com/a/1390625/1348344 # https://github.com/philip/MySQLConverterTool/blob/master/Converter.php # https://www.phpclasses.org/blog/package/9199/post/3-Smoothly-Migrate-your-PHP-Code-using-the-Old-MySQL-extension-to-MySQLi.html - $rectorConfig->rule(\Rector\MysqlToMysqli\Rector\Assign\MysqlAssignToMysqliRector::class); - $rectorConfig->rule(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlFuncCallToMysqliRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::class, [new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_pconnect', 3), new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_connect', 3), new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_connect', 4)]); - $rectorConfig->rule(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlPConnectToMysqliConnectRector::class); + $rectorConfig->rule(MysqlAssignToMysqliRector::class); + $rectorConfig->rule(MysqlFuncCallToMysqliRector::class); + $rectorConfig->ruleWithConfiguration(RemoveFuncCallArgRector::class, [new RemoveFuncCallArg('mysql_pconnect', 3), new RemoveFuncCallArg('mysql_connect', 3), new RemoveFuncCallArg('mysql_connect', 4)]); + $rectorConfig->rule(MysqlPConnectToMysqliConnectRector::class); # first swap arguments, then rename - $rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\FuncCall\SwapFuncCallArgumentsRector::class, [new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_query', [1, 0]), new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_real_escape_string', [1, 0]), new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_select_db', [1, 0]), new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_set_charset', [1, 0])]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class, ['mysql_connect' => 'mysqli_connect', 'mysql_data_seek' => 'mysqli_data_seek', 'mysql_fetch_array' => 'mysqli_fetch_array', 'mysql_fetch_assoc' => 'mysqli_fetch_assoc', 'mysql_fetch_lengths' => 'mysqli_fetch_lengths', 'mysql_fetch_object' => 'mysqli_fetch_object', 'mysql_fetch_row' => 'mysqli_fetch_row', 'mysql_field_seek' => 'mysqli_field_seek', 'mysql_free_result' => 'mysqli_free_result', 'mysql_get_client_info' => 'mysqli_get_client_info', 'mysql_num_fields' => 'mysqli_num_fields', 'mysql_numfields' => 'mysqli_num_fields', 'mysql_num_rows' => 'mysqli_num_rows', 'mysql_numrows' => 'mysqli_num_rows']); + $rectorConfig->ruleWithConfiguration(SwapFuncCallArgumentsRector::class, [new SwapFuncCallArguments('mysql_query', [1, 0]), new SwapFuncCallArguments('mysql_real_escape_string', [1, 0]), new SwapFuncCallArguments('mysql_select_db', [1, 0]), new SwapFuncCallArguments('mysql_set_charset', [1, 0])]); + $rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, ['mysql_connect' => 'mysqli_connect', 'mysql_data_seek' => 'mysqli_data_seek', 'mysql_fetch_array' => 'mysqli_fetch_array', 'mysql_fetch_assoc' => 'mysqli_fetch_assoc', 'mysql_fetch_lengths' => 'mysqli_fetch_lengths', 'mysql_fetch_object' => 'mysqli_fetch_object', 'mysql_fetch_row' => 'mysqli_fetch_row', 'mysql_field_seek' => 'mysqli_field_seek', 'mysql_free_result' => 'mysqli_free_result', 'mysql_get_client_info' => 'mysqli_get_client_info', 'mysql_num_fields' => 'mysqli_num_fields', 'mysql_numfields' => 'mysqli_num_fields', 'mysql_num_rows' => 'mysqli_num_rows', 'mysql_numrows' => 'mysqli_num_rows']); # http://php.net/manual/en/mysql.constants.php → http://php.net/manual/en/mysqli.constants.php - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\ConstFetch\RenameConstantRector::class, ['MYSQL_ASSOC' => 'MYSQLI_ASSOC', 'MYSQL_BOTH' => 'MYSQLI_BOTH', 'MYSQL_CLIENT_COMPRESS' => 'MYSQLI_CLIENT_COMPRESS', 'MYSQL_CLIENT_IGNORE_SPACE' => 'MYSQLI_CLIENT_IGNORE_SPACE', 'MYSQL_CLIENT_INTERACTIVE' => 'MYSQLI_CLIENT_INTERACTIVE', 'MYSQL_CLIENT_SSL' => 'MYSQLI_CLIENT_SSL', 'MYSQL_NUM' => 'MYSQLI_NUM', 'MYSQL_PRIMARY_KEY_FLAG' => 'MYSQLI_PRI_KEY_FLAG']); - $rectorConfig->rule(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlQueryMysqlErrorWithLinkRector::class); + $rectorConfig->ruleWithConfiguration(RenameConstantRector::class, ['MYSQL_ASSOC' => 'MYSQLI_ASSOC', 'MYSQL_BOTH' => 'MYSQLI_BOTH', 'MYSQL_CLIENT_COMPRESS' => 'MYSQLI_CLIENT_COMPRESS', 'MYSQL_CLIENT_IGNORE_SPACE' => 'MYSQLI_CLIENT_IGNORE_SPACE', 'MYSQL_CLIENT_INTERACTIVE' => 'MYSQLI_CLIENT_INTERACTIVE', 'MYSQL_CLIENT_SSL' => 'MYSQLI_CLIENT_SSL', 'MYSQL_NUM' => 'MYSQLI_NUM', 'MYSQL_PRIMARY_KEY_FLAG' => 'MYSQLI_PRI_KEY_FLAG']); + $rectorConfig->rule(MysqlQueryMysqlErrorWithLinkRector::class); }; diff --git a/config/set/naming.php b/config/set/naming.php index 7bcd864ad06..77ca28710e8 100644 --- a/config/set/naming.php +++ b/config/set/naming.php @@ -10,11 +10,11 @@ use Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector; use Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector; use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector; use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector::class); - $rectorConfig->rule(\Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector::class); - $rectorConfig->rule(\Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector::class); - $rectorConfig->rule(\Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector::class); - $rectorConfig->rule(\Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class); - $rectorConfig->rule(\Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(RenameParamToMatchTypeRector::class); + $rectorConfig->rule(RenamePropertyToMatchTypeRector::class); + $rectorConfig->rule(RenameVariableToMatchNewTypeRector::class); + $rectorConfig->rule(RenameVariableToMatchMethodCallReturnTypeRector::class); + $rectorConfig->rule(RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class); + $rectorConfig->rule(RenameForeachValueVariableToMatchExprVariableRector::class); }; diff --git a/config/set/php52.php b/config/set/php52.php index 45f9af5f0e2..8d621df5cf4 100644 --- a/config/set/php52.php +++ b/config/set/php52.php @@ -8,11 +8,11 @@ use Rector\Php52\Rector\Property\VarToPublicPropertyRector; use Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector; use Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector; use Rector\Removing\ValueObject\RemoveFuncCallArg; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Php52\Rector\Property\VarToPublicPropertyRector::class); - $rectorConfig->rule(\Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(VarToPublicPropertyRector::class); + $rectorConfig->rule(ContinueToBreakInSwitchRector::class); + $rectorConfig->ruleWithConfiguration(RemoveFuncCallArgRector::class, [ // see https://www.php.net/manual/en/function.ldap-first-attribute.php - new \Rector\Removing\ValueObject\RemoveFuncCallArg('ldap_first_attribute', 2), + new RemoveFuncCallArg('ldap_first_attribute', 2), ]); }; diff --git a/config/set/php53.php b/config/set/php53.php index 8de6c170538..d860234f237 100644 --- a/config/set/php53.php +++ b/config/set/php53.php @@ -7,8 +7,8 @@ use Rector\Config\RectorConfig; use Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector; use Rector\Php53\Rector\Ternary\TernaryToElvisRector; use Rector\Php53\Rector\Variable\ReplaceHttpServerVarsByServerRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Php53\Rector\Ternary\TernaryToElvisRector::class); - $rectorConfig->rule(\Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector::class); - $rectorConfig->rule(\Rector\Php53\Rector\Variable\ReplaceHttpServerVarsByServerRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(TernaryToElvisRector::class); + $rectorConfig->rule(DirNameFileConstantToDirConstantRector::class); + $rectorConfig->rule(ReplaceHttpServerVarsByServerRector::class); }; diff --git a/config/set/php54.php b/config/set/php54.php index 6ed2854a872..2bb68d354f5 100644 --- a/config/set/php54.php +++ b/config/set/php54.php @@ -7,8 +7,8 @@ use Rector\Config\RectorConfig; use Rector\Php54\Rector\Break_\RemoveZeroBreakContinueRector; use Rector\Php54\Rector\FuncCall\RemoveReferenceFromCallRector; use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class, ['mysqli_param_count' => 'mysqli_stmt_param_count']); - $rectorConfig->rule(\Rector\Php54\Rector\FuncCall\RemoveReferenceFromCallRector::class); - $rectorConfig->rule(\Rector\Php54\Rector\Break_\RemoveZeroBreakContinueRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, ['mysqli_param_count' => 'mysqli_stmt_param_count']); + $rectorConfig->rule(RemoveReferenceFromCallRector::class); + $rectorConfig->rule(RemoveZeroBreakContinueRector::class); }; diff --git a/config/set/php55.php b/config/set/php55.php index a63985980ac..16cb534bdcb 100644 --- a/config/set/php55.php +++ b/config/set/php55.php @@ -9,10 +9,10 @@ use Rector\Php55\Rector\FuncCall\GetCalledClassToSelfClassRector; use Rector\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector; use Rector\Php55\Rector\FuncCall\PregReplaceEModifierRector; use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class); - $rectorConfig->rule(\Rector\Php55\Rector\Class_\ClassConstantToSelfClassRector::class); - $rectorConfig->rule(\Rector\Php55\Rector\FuncCall\PregReplaceEModifierRector::class); - $rectorConfig->rule(\Rector\Php55\Rector\FuncCall\GetCalledClassToSelfClassRector::class); - $rectorConfig->rule(\Rector\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(StringClassNameToClassConstantRector::class); + $rectorConfig->rule(ClassConstantToSelfClassRector::class); + $rectorConfig->rule(PregReplaceEModifierRector::class); + $rectorConfig->rule(GetCalledClassToSelfClassRector::class); + $rectorConfig->rule(GetCalledClassToStaticClassRector::class); }; diff --git a/config/set/php56.php b/config/set/php56.php index 9d03d282008..b7d5010575b 100644 --- a/config/set/php56.php +++ b/config/set/php56.php @@ -7,9 +7,9 @@ use Rector\Config\RectorConfig; use Rector\Php56\Rector\FuncCall\PowToExpRector; use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector; use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Php56\Rector\FuncCall\PowToExpRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class, ['mcrypt_generic_end' => 'mcrypt_generic_deinit', 'set_socket_blocking' => 'stream_set_blocking', 'ocibindbyname' => 'oci_bind_by_name', 'ocicancel' => 'oci_cancel', 'ocicolumnisnull' => 'oci_field_is_null', 'ocicolumnname' => 'oci_field_name', 'ocicolumnprecision' => 'oci_field_precision', 'ocicolumnscale' => 'oci_field_scale', 'ocicolumnsize' => 'oci_field_size', 'ocicolumntype' => 'oci_field_type', 'ocicolumntyperaw' => 'oci_field_type_raw', 'ocicommit' => 'oci_commit', 'ocidefinebyname' => 'oci_define_by_name', 'ocierror' => 'oci_error', 'ociexecute' => 'oci_execute', 'ocifetch' => 'oci_fetch', 'ocifetchstatement' => 'oci_fetch_all', 'ocifreecursor' => 'oci_free_statement', 'ocifreestatement' => 'oci_free_statement', 'ociinternaldebug' => 'oci_internal_debug', 'ocilogoff' => 'oci_close', 'ocilogon' => 'oci_connect', 'ocinewcollection' => 'oci_new_collection', 'ocinewcursor' => 'oci_new_cursor', 'ocinewdescriptor' => 'oci_new_descriptor', 'ocinlogon' => 'oci_new_connect', 'ocinumcols' => 'oci_num_fields', 'ociparse' => 'oci_parse', 'ociplogon' => 'oci_pconnect', 'ociresult' => 'oci_result', 'ocirollback' => 'oci_rollback', 'ocirowcount' => 'oci_num_rows', 'ociserverversion' => 'oci_server_version', 'ocisetprefetch' => 'oci_set_prefetch', 'ocistatementtype' => 'oci_statement_type']); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(PowToExpRector::class); + $rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, ['mcrypt_generic_end' => 'mcrypt_generic_deinit', 'set_socket_blocking' => 'stream_set_blocking', 'ocibindbyname' => 'oci_bind_by_name', 'ocicancel' => 'oci_cancel', 'ocicolumnisnull' => 'oci_field_is_null', 'ocicolumnname' => 'oci_field_name', 'ocicolumnprecision' => 'oci_field_precision', 'ocicolumnscale' => 'oci_field_scale', 'ocicolumnsize' => 'oci_field_size', 'ocicolumntype' => 'oci_field_type', 'ocicolumntyperaw' => 'oci_field_type_raw', 'ocicommit' => 'oci_commit', 'ocidefinebyname' => 'oci_define_by_name', 'ocierror' => 'oci_error', 'ociexecute' => 'oci_execute', 'ocifetch' => 'oci_fetch', 'ocifetchstatement' => 'oci_fetch_all', 'ocifreecursor' => 'oci_free_statement', 'ocifreestatement' => 'oci_free_statement', 'ociinternaldebug' => 'oci_internal_debug', 'ocilogoff' => 'oci_close', 'ocilogon' => 'oci_connect', 'ocinewcollection' => 'oci_new_collection', 'ocinewcursor' => 'oci_new_cursor', 'ocinewdescriptor' => 'oci_new_descriptor', 'ocinlogon' => 'oci_new_connect', 'ocinumcols' => 'oci_num_fields', 'ociparse' => 'oci_parse', 'ociplogon' => 'oci_pconnect', 'ociresult' => 'oci_result', 'ocirollback' => 'oci_rollback', 'ocirowcount' => 'oci_num_rows', 'ociserverversion' => 'oci_server_version', 'ocisetprefetch' => 'oci_set_prefetch', 'ocistatementtype' => 'oci_statement_type']); # inspired by level in psalm - https://github.com/vimeo/psalm/blob/82e0bcafac723fdf5007a31a7ae74af1736c9f6f/tests/FileManipulationTest.php#L1063 - $rectorConfig->rule(\Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector::class); + $rectorConfig->rule(AddDefaultValueForUndefinedVariableRector::class); }; diff --git a/config/set/php70.php b/config/set/php70.php index bd39b862adf..665649b93c0 100644 --- a/config/set/php70.php +++ b/config/set/php70.php @@ -23,25 +23,25 @@ use Rector\Php70\Rector\Switch_\ReduceMultipleDefaultSwitchRector; use Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector; use Rector\Php70\Rector\Ternary\TernaryToSpaceshipRector; use Rector\Php70\Rector\Variable\WrapVariableVariableNameInCurlyBracesRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Php70\Rector\ClassMethod\Php4ConstructorRector::class); - $rectorConfig->rule(\Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector::class); - $rectorConfig->rule(\Rector\Php70\Rector\FuncCall\RandomFunctionRector::class); - $rectorConfig->rule(\Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector::class); - $rectorConfig->rule(\Rector\Php70\Rector\FuncCall\MultiDirnameRector::class); - $rectorConfig->rule(\Rector\Php70\Rector\Assign\ListSplitStringRector::class); - $rectorConfig->rule(\Rector\Php70\Rector\List_\EmptyListRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(Php4ConstructorRector::class); + $rectorConfig->rule(TernaryToNullCoalescingRector::class); + $rectorConfig->rule(RandomFunctionRector::class); + $rectorConfig->rule(ExceptionHandlerTypehintRector::class); + $rectorConfig->rule(MultiDirnameRector::class); + $rectorConfig->rule(ListSplitStringRector::class); + $rectorConfig->rule(EmptyListRector::class); # be careful, run this just once, since it can keep swapping order back and forth - $rectorConfig->rule(\Rector\Php70\Rector\Assign\ListSwapArrayOrderRector::class); - $rectorConfig->rule(\Rector\Php70\Rector\FuncCall\CallUserMethodRector::class); - $rectorConfig->rule(\Rector\Php70\Rector\FuncCall\EregToPregMatchRector::class); - $rectorConfig->rule(\Rector\Php70\Rector\Switch_\ReduceMultipleDefaultSwitchRector::class); - $rectorConfig->rule(\Rector\Php70\Rector\Ternary\TernaryToSpaceshipRector::class); - $rectorConfig->rule(\Rector\Php70\Rector\Variable\WrapVariableVariableNameInCurlyBracesRector::class); - $rectorConfig->rule(\Rector\Php70\Rector\If_\IfToSpaceshipRector::class); - $rectorConfig->rule(\Rector\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector::class); - $rectorConfig->rule(\Rector\Php70\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector::class); - $rectorConfig->rule(\Rector\Php70\Rector\Break_\BreakNotInLoopOrSwitchToReturnRector::class); - $rectorConfig->rule(\Rector\Php70\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector::class); - $rectorConfig->rule(\Rector\Php70\Rector\FuncCall\NonVariableToVariableOnFunctionCallRector::class); + $rectorConfig->rule(ListSwapArrayOrderRector::class); + $rectorConfig->rule(CallUserMethodRector::class); + $rectorConfig->rule(EregToPregMatchRector::class); + $rectorConfig->rule(ReduceMultipleDefaultSwitchRector::class); + $rectorConfig->rule(TernaryToSpaceshipRector::class); + $rectorConfig->rule(WrapVariableVariableNameInCurlyBracesRector::class); + $rectorConfig->rule(IfToSpaceshipRector::class); + $rectorConfig->rule(StaticCallOnNonStaticToInstanceCallRector::class); + $rectorConfig->rule(ThisCallOnStaticMethodToStaticCallRector::class); + $rectorConfig->rule(BreakNotInLoopOrSwitchToReturnRector::class); + $rectorConfig->rule(RenameMktimeWithoutArgsToTimeRector::class); + $rectorConfig->rule(NonVariableToVariableOnFunctionCallRector::class); }; diff --git a/config/set/php71.php b/config/set/php71.php index bb55c74bb4d..22667d0b4dc 100644 --- a/config/set/php71.php +++ b/config/set/php71.php @@ -12,13 +12,13 @@ use Rector\Php71\Rector\FuncCall\CountOnNullRector; use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; use Rector\Php71\Rector\List_\ListToArrayDestructRector; use Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Php71\Rector\BooleanOr\IsIterableRector::class); - $rectorConfig->rule(\Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector::class); - $rectorConfig->rule(\Rector\Php71\Rector\Assign\AssignArrayToStringRector::class); - $rectorConfig->rule(\Rector\Php71\Rector\FuncCall\CountOnNullRector::class); - $rectorConfig->rule(\Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector::class); - $rectorConfig->rule(\Rector\Php71\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector::class); - $rectorConfig->rule(\Rector\Php71\Rector\List_\ListToArrayDestructRector::class); - $rectorConfig->rule(\Rector\Php71\Rector\ClassConst\PublicConstantVisibilityRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(IsIterableRector::class); + $rectorConfig->rule(MultiExceptionCatchRector::class); + $rectorConfig->rule(AssignArrayToStringRector::class); + $rectorConfig->rule(CountOnNullRector::class); + $rectorConfig->rule(RemoveExtraParametersRector::class); + $rectorConfig->rule(BinaryOpBetweenNumberAndStringRector::class); + $rectorConfig->rule(ListToArrayDestructRector::class); + $rectorConfig->rule(PublicConstantVisibilityRector::class); }; diff --git a/config/set/php72.php b/config/set/php72.php index c7b148588d7..b74610f6fb5 100644 --- a/config/set/php72.php +++ b/config/set/php72.php @@ -15,12 +15,12 @@ use Rector\Php72\Rector\FuncCall\StringsAssertNakedRector; use Rector\Php72\Rector\Unset_\UnsetCastRector; use Rector\Php72\Rector\While_\WhileEachToForeachRector; use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Php72\Rector\While_\WhileEachToForeachRector::class); - $rectorConfig->rule(\Rector\Php72\Rector\Assign\ListEachRector::class); - $rectorConfig->rule(\Rector\Php72\Rector\Assign\ReplaceEachAssignmentWithKeyCurrentRector::class); - $rectorConfig->rule(\Rector\Php72\Rector\Unset_\UnsetCastRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(WhileEachToForeachRector::class); + $rectorConfig->rule(ListEachRector::class); + $rectorConfig->rule(ReplaceEachAssignmentWithKeyCurrentRector::class); + $rectorConfig->rule(UnsetCastRector::class); + $rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, [ # and imagewbmp 'jpeg2wbmp' => 'imagecreatefromjpeg', # or imagewbmp @@ -31,10 +31,10 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { 'gmp_random' => 'gmp_random_bits', 'read_exif_data' => 'exif_read_data', ]); - $rectorConfig->rule(\Rector\Php72\Rector\FuncCall\GetClassOnNullRector::class); - $rectorConfig->rule(\Rector\Php72\Rector\FuncCall\IsObjectOnIncompleteClassRector::class); - $rectorConfig->rule(\Rector\Php72\Rector\FuncCall\ParseStrWithResultArgumentRector::class); - $rectorConfig->rule(\Rector\Php72\Rector\FuncCall\StringsAssertNakedRector::class); - $rectorConfig->rule(\Rector\Php72\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector::class); - $rectorConfig->rule(\Rector\Php72\Rector\FuncCall\StringifyDefineRector::class); + $rectorConfig->rule(GetClassOnNullRector::class); + $rectorConfig->rule(IsObjectOnIncompleteClassRector::class); + $rectorConfig->rule(ParseStrWithResultArgumentRector::class); + $rectorConfig->rule(StringsAssertNakedRector::class); + $rectorConfig->rule(CreateFunctionToAnonymousFunctionRector::class); + $rectorConfig->rule(StringifyDefineRector::class); }; diff --git a/config/set/php73.php b/config/set/php73.php index 039b59badf9..361703a9768 100644 --- a/config/set/php73.php +++ b/config/set/php73.php @@ -15,13 +15,13 @@ use Rector\Php73\Rector\FuncCall\SetCookieRector; use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector; use Rector\Php73\Rector\String_\SensitiveHereNowDocRector; use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Php73\Rector\BooleanOr\IsCountableRector::class); - $rectorConfig->rule(\Rector\Php73\Rector\FuncCall\ArrayKeyFirstLastRector::class); - $rectorConfig->rule(\Rector\Php73\Rector\FuncCall\SensitiveDefineRector::class); - $rectorConfig->rule(\Rector\Php73\Rector\ConstFetch\SensitiveConstantNameRector::class); - $rectorConfig->rule(\Rector\Php73\Rector\String_\SensitiveHereNowDocRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(IsCountableRector::class); + $rectorConfig->rule(ArrayKeyFirstLastRector::class); + $rectorConfig->rule(SensitiveDefineRector::class); + $rectorConfig->rule(SensitiveConstantNameRector::class); + $rectorConfig->rule(SensitiveHereNowDocRector::class); + $rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, [ # https://wiki.php.net/rfc/deprecations_php_7_3 'image2wbmp' => 'imagewbmp', 'mbregex_encoding' => 'mb_regex_encoding', @@ -38,9 +38,9 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { 'mbereg_search_getregs' => 'mb_ereg_search_getregs', 'mbereg_search_getpos' => 'mb_ereg_search_getpos', ]); - $rectorConfig->rule(\Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector::class); - $rectorConfig->rule(\Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector::class); - $rectorConfig->rule(\Rector\Php73\Rector\FuncCall\RegexDashEscapeRector::class); - $rectorConfig->rule(\Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector::class); - $rectorConfig->rule(\Rector\Php73\Rector\FuncCall\SetCookieRector::class); + $rectorConfig->rule(StringifyStrNeedlesRector::class); + $rectorConfig->rule(JsonThrowOnErrorRector::class); + $rectorConfig->rule(RegexDashEscapeRector::class); + $rectorConfig->rule(ContinueToBreakInSwitchRector::class); + $rectorConfig->rule(SetCookieRector::class); }; diff --git a/config/set/php74.php b/config/set/php74.php index 44e5b27bbf2..01be4e7a89c 100644 --- a/config/set/php74.php +++ b/config/set/php74.php @@ -18,9 +18,9 @@ use Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector; use Rector\Php74\Rector\Property\TypedPropertyRector; use Rector\Php74\Rector\StaticCall\ExportToReflectionFunctionRector; use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Php74\Rector\Property\TypedPropertyRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(TypedPropertyRector::class); + $rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, [ #the_real_type # https://wiki.php.net/rfc/deprecations_php_7_4 'is_real' => 'is_float', @@ -28,16 +28,16 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { # https://wiki.php.net/rfc/deprecations_php_7_4 'apache_request_headers' => 'getallheaders', ]); - $rectorConfig->rule(\Rector\Php74\Rector\FuncCall\ArrayKeyExistsOnPropertyRector::class); - $rectorConfig->rule(\Rector\Php74\Rector\FuncCall\FilterVarToAddSlashesRector::class); - $rectorConfig->rule(\Rector\Php74\Rector\StaticCall\ExportToReflectionFunctionRector::class); - $rectorConfig->rule(\Rector\Php74\Rector\FuncCall\MbStrrposEncodingArgumentPositionRector::class); - $rectorConfig->rule(\Rector\Php74\Rector\Double\RealToFloatTypeCastRector::class); - $rectorConfig->rule(\Rector\Php74\Rector\Assign\NullCoalescingOperatorRector::class); - $rectorConfig->rule(\Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector::class); - $rectorConfig->rule(\Rector\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector::class); - $rectorConfig->rule(\Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector::class); - $rectorConfig->rule(\Rector\Php74\Rector\MethodCall\ChangeReflectionTypeToStringToGetNameRector::class); - $rectorConfig->rule(\Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector::class); - $rectorConfig->rule(\Rector\Php74\Rector\ArrayDimFetch\CurlyToSquareBracketArrayStringRector::class); + $rectorConfig->rule(ArrayKeyExistsOnPropertyRector::class); + $rectorConfig->rule(FilterVarToAddSlashesRector::class); + $rectorConfig->rule(ExportToReflectionFunctionRector::class); + $rectorConfig->rule(MbStrrposEncodingArgumentPositionRector::class); + $rectorConfig->rule(RealToFloatTypeCastRector::class); + $rectorConfig->rule(NullCoalescingOperatorRector::class); + $rectorConfig->rule(ClosureToArrowFunctionRector::class); + $rectorConfig->rule(ArraySpreadInsteadOfArrayMergeRector::class); + $rectorConfig->rule(AddLiteralSeparatorToNumberRector::class); + $rectorConfig->rule(ChangeReflectionTypeToStringToGetNameRector::class); + $rectorConfig->rule(RestoreDefaultNullToNullableTypePropertyRector::class); + $rectorConfig->rule(CurlyToSquareBracketArrayStringRector::class); }; diff --git a/config/set/php80.php b/config/set/php80.php index c1d06538e5c..220ee877dee 100644 --- a/config/set/php80.php +++ b/config/set/php80.php @@ -28,28 +28,28 @@ use Rector\Php80\Rector\Ternary\GetDebugTypeRector; use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector; use Rector\Transform\ValueObject\StaticCallToFuncCall; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Php80\Rector\FunctionLike\UnionTypesRector::class); - $rectorConfig->rule(\Rector\Php80\Rector\NotIdentical\StrContainsRector::class); - $rectorConfig->rule(\Rector\Php80\Rector\Identical\StrStartsWithRector::class); - $rectorConfig->rule(\Rector\Php80\Rector\Identical\StrEndsWithRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::class, [new \Rector\Transform\ValueObject\StaticCallToFuncCall('Nette\\Utils\\Strings', 'startsWith', 'str_starts_with'), new \Rector\Transform\ValueObject\StaticCallToFuncCall('Nette\\Utils\\Strings', 'endsWith', 'str_ends_with'), new \Rector\Transform\ValueObject\StaticCallToFuncCall('Nette\\Utils\\Strings', 'contains', 'str_contains')]); - $rectorConfig->rule(\Rector\Php80\Rector\Class_\StringableForToStringRector::class); - $rectorConfig->rule(\Rector\Php80\Rector\FuncCall\ClassOnObjectRector::class); - $rectorConfig->rule(\Rector\Php80\Rector\Ternary\GetDebugTypeRector::class); - $rectorConfig->rule(\Rector\Php80\Rector\FuncCall\TokenGetAllToObjectRector::class); - $rectorConfig->rule(\Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector::class); - $rectorConfig->rule(\Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector::class); - $rectorConfig->rule(\Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(UnionTypesRector::class); + $rectorConfig->rule(StrContainsRector::class); + $rectorConfig->rule(StrStartsWithRector::class); + $rectorConfig->rule(StrEndsWithRector::class); + $rectorConfig->ruleWithConfiguration(StaticCallToFuncCallRector::class, [new StaticCallToFuncCall('Nette\\Utils\\Strings', 'startsWith', 'str_starts_with'), new StaticCallToFuncCall('Nette\\Utils\\Strings', 'endsWith', 'str_ends_with'), new StaticCallToFuncCall('Nette\\Utils\\Strings', 'contains', 'str_contains')]); + $rectorConfig->rule(StringableForToStringRector::class); + $rectorConfig->rule(ClassOnObjectRector::class); + $rectorConfig->rule(GetDebugTypeRector::class); + $rectorConfig->rule(TokenGetAllToObjectRector::class); + $rectorConfig->rule(RemoveUnusedVariableInCatchRector::class); + $rectorConfig->rule(ClassPropertyAssignToConstructorPromotionRector::class); + $rectorConfig->rule(ChangeSwitchToMatchRector::class); // nette\utils and Strings::replace() - $rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class, [new \Rector\Arguments\ValueObject\ArgumentAdder('Nette\\Utils\\Strings', 'replace', 2, 'replacement', '')]); - $rectorConfig->rule(\Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector::class); - $rectorConfig->rule(\Rector\Php80\Rector\ClassMethod\SetStateToStaticRector::class); - $rectorConfig->rule(\Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector::class); + $rectorConfig->ruleWithConfiguration(ArgumentAdderRector::class, [new ArgumentAdder('Nette\\Utils\\Strings', 'replace', 2, 'replacement', '')]); + $rectorConfig->rule(RemoveParentCallWithoutParentRector::class); + $rectorConfig->rule(SetStateToStaticRector::class); + $rectorConfig->rule(FinalPrivateToPrivateVisibilityRector::class); // @see https://php.watch/versions/8.0/pgsql-aliases-deprecated - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class, ['pg_clientencoding' => 'pg_client_encoding', 'pg_cmdtuples' => 'pg_affected_rows', 'pg_errormessage' => 'pg_last_error', 'pg_fieldisnull' => 'pg_field_is_null', 'pg_fieldname' => 'pg_field_name', 'pg_fieldnum' => 'pg_field_num', 'pg_fieldprtlen' => 'pg_field_prtlen', 'pg_fieldsize' => 'pg_field_size', 'pg_fieldtype' => 'pg_field_type', 'pg_freeresult' => 'pg_free_result', 'pg_getlastoid' => 'pg_last_oid', 'pg_loclose' => 'pg_lo_close', 'pg_locreate' => 'pg_lo_create', 'pg_loexport' => 'pg_lo_export', 'pg_loimport' => 'pg_lo_import', 'pg_loopen' => 'pg_lo_open', 'pg_loread' => 'pg_lo_read', 'pg_loreadall' => 'pg_lo_read_all', 'pg_lounlink' => 'pg_lo_unlink', 'pg_lowrite' => 'pg_lo_write', 'pg_numfields' => 'pg_num_fields', 'pg_numrows' => 'pg_num_rows', 'pg_result' => 'pg_fetch_result', 'pg_setclientencoding' => 'pg_set_client_encoding']); - $rectorConfig->rule(\Rector\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\FuncCall\FunctionArgumentDefaultValueReplacerRector::class, [new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'lte', 'le'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, '', '!='), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, '!', '!='), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'g', 'gt'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'l', 'lt'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'lte', 'le'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'n', 'ne')]); - $rectorConfig->rule(\Rector\Php80\Rector\FuncCall\Php8ResourceReturnToObjectRector::class); - $rectorConfig->rule(\Rector\Php80\Rector\ClassMethod\AddParamBasedOnParentClassMethodRector::class); + $rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, ['pg_clientencoding' => 'pg_client_encoding', 'pg_cmdtuples' => 'pg_affected_rows', 'pg_errormessage' => 'pg_last_error', 'pg_fieldisnull' => 'pg_field_is_null', 'pg_fieldname' => 'pg_field_name', 'pg_fieldnum' => 'pg_field_num', 'pg_fieldprtlen' => 'pg_field_prtlen', 'pg_fieldsize' => 'pg_field_size', 'pg_fieldtype' => 'pg_field_type', 'pg_freeresult' => 'pg_free_result', 'pg_getlastoid' => 'pg_last_oid', 'pg_loclose' => 'pg_lo_close', 'pg_locreate' => 'pg_lo_create', 'pg_loexport' => 'pg_lo_export', 'pg_loimport' => 'pg_lo_import', 'pg_loopen' => 'pg_lo_open', 'pg_loread' => 'pg_lo_read', 'pg_loreadall' => 'pg_lo_read_all', 'pg_lounlink' => 'pg_lo_unlink', 'pg_lowrite' => 'pg_lo_write', 'pg_numfields' => 'pg_num_fields', 'pg_numrows' => 'pg_num_rows', 'pg_result' => 'pg_fetch_result', 'pg_setclientencoding' => 'pg_set_client_encoding']); + $rectorConfig->rule(OptionalParametersAfterRequiredRector::class); + $rectorConfig->ruleWithConfiguration(FunctionArgumentDefaultValueReplacerRector::class, [new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge'), new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'lte', 'le'), new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, '', '!='), new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, '!', '!='), new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'g', 'gt'), new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'l', 'lt'), new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge'), new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'lte', 'le'), new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'n', 'ne')]); + $rectorConfig->rule(Php8ResourceReturnToObjectRector::class); + $rectorConfig->rule(AddParamBasedOnParentClassMethodRector::class); }; diff --git a/config/set/php81.php b/config/set/php81.php index b90ee038db1..9bd7a1fe449 100644 --- a/config/set/php81.php +++ b/config/set/php81.php @@ -14,15 +14,15 @@ use Rector\Php81\Rector\FunctionLike\IntersectionTypesRector; use Rector\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector; use Rector\Php81\Rector\Property\ReadOnlyPropertyRector; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector::class); - $rectorConfig->rule(\Rector\Php81\Rector\Class_\MyCLabsClassToEnumRector::class); - $rectorConfig->rule(\Rector\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector::class); - $rectorConfig->rule(\Rector\Php81\Rector\ClassConst\FinalizePublicClassConstantRector::class); - $rectorConfig->rule(\Rector\Php81\Rector\Property\ReadOnlyPropertyRector::class); - $rectorConfig->rule(\Rector\Php81\Rector\Class_\SpatieEnumClassToEnumRector::class); - $rectorConfig->rule(\Rector\Php81\Rector\FuncCall\Php81ResourceReturnToObjectRector::class); - $rectorConfig->rule(\Rector\Php81\Rector\ClassMethod\NewInInitializerRector::class); - $rectorConfig->rule(\Rector\Php81\Rector\FunctionLike\IntersectionTypesRector::class); - $rectorConfig->rule(\Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(ReturnNeverTypeRector::class); + $rectorConfig->rule(MyCLabsClassToEnumRector::class); + $rectorConfig->rule(MyCLabsMethodCallToEnumConstRector::class); + $rectorConfig->rule(FinalizePublicClassConstantRector::class); + $rectorConfig->rule(ReadOnlyPropertyRector::class); + $rectorConfig->rule(SpatieEnumClassToEnumRector::class); + $rectorConfig->rule(Php81ResourceReturnToObjectRector::class); + $rectorConfig->rule(NewInInitializerRector::class); + $rectorConfig->rule(IntersectionTypesRector::class); + $rectorConfig->rule(NullToStrictStringFuncCallArgRector::class); }; diff --git a/config/set/php82.php b/config/set/php82.php index 2bd3ab8971e..0f2d07842bc 100644 --- a/config/set/php82.php +++ b/config/set/php82.php @@ -5,6 +5,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Php82\Rector\Class_\ReadOnlyClassRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Php82\Rector\Class_\ReadOnlyClassRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(ReadOnlyClassRector::class); }; diff --git a/config/set/privatization.php b/config/set/privatization.php index 5c5179751bc..7e6c3d35e82 100644 --- a/config/set/privatization.php +++ b/config/set/privatization.php @@ -13,15 +13,15 @@ use Rector\Privatization\Rector\ClassMethod\PrivatizeFinalClassMethodRector; use Rector\Privatization\Rector\MethodCall\PrivatizeLocalGetterToPropertyRector; use Rector\Privatization\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector; use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector::class); - $rectorConfig->rule(\Rector\Privatization\Rector\Class_\ChangeGlobalVariablesToPropertiesRector::class); - $rectorConfig->rule(\Rector\Privatization\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector::class); - $rectorConfig->rule(\Rector\Privatization\Rector\Class_\ChangeReadOnlyVariableWithDefaultValueToConstantRector::class); - $rectorConfig->rule(\Rector\Privatization\Rector\Class_\RepeatedLiteralToClassConstantRector::class); - $rectorConfig->rule(\Rector\Privatization\Rector\MethodCall\PrivatizeLocalGetterToPropertyRector::class); - $rectorConfig->rule(\Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector::class); - $rectorConfig->rule(\Rector\Privatization\Rector\ClassMethod\PrivatizeFinalClassMethodRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(FinalizeClassesWithoutChildrenRector::class); + $rectorConfig->rule(ChangeGlobalVariablesToPropertiesRector::class); + $rectorConfig->rule(ChangeReadOnlyPropertyWithDefaultValueToConstantRector::class); + $rectorConfig->rule(ChangeReadOnlyVariableWithDefaultValueToConstantRector::class); + $rectorConfig->rule(RepeatedLiteralToClassConstantRector::class); + $rectorConfig->rule(PrivatizeLocalGetterToPropertyRector::class); + $rectorConfig->rule(PrivatizeFinalClassPropertyRector::class); + $rectorConfig->rule(PrivatizeFinalClassMethodRector::class); // buggy, requires more work // $services->set(ChangeLocalPropertyToVariableRector::class); }; diff --git a/config/set/psr-4.php b/config/set/psr-4.php index c78e3475f73..60dacaf2929 100644 --- a/config/set/psr-4.php +++ b/config/set/psr-4.php @@ -6,7 +6,7 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector; use Rector\PSR4\Rector\Namespace_\MultipleClassFileToPsr4ClassesRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector::class); - $rectorConfig->rule(\Rector\PSR4\Rector\Namespace_\MultipleClassFileToPsr4ClassesRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(NormalizeNamespaceByPSR4ComposerAutoloadRector::class); + $rectorConfig->rule(MultipleClassFileToPsr4ClassesRector::class); }; diff --git a/config/set/rector-config.php b/config/set/rector-config.php index 8f29644ac97..5eb2da3cd29 100644 --- a/config/set/rector-config.php +++ b/config/set/rector-config.php @@ -5,6 +5,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\DogFood\Rector\Closure\UpgradeRectorConfigRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\DogFood\Rector\Closure\UpgradeRectorConfigRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(UpgradeRectorConfigRector::class); }; diff --git a/config/set/type-declaration-strict.php b/config/set/type-declaration-strict.php index 7e30be8af66..956d26f72c4 100644 --- a/config/set/type-declaration-strict.php +++ b/config/set/type-declaration-strict.php @@ -14,15 +14,15 @@ use Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector; use Rector\TypeDeclaration\Rector\Param\ParamTypeFromStrictTypedPropertyRector; use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector; use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector::class); - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector::class); - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector::class); - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\Param\ParamTypeFromStrictTypedPropertyRector::class); - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector::class); - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector::class); - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector::class); - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector::class); - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector::class); - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ArrayShapeFromConstantArrayReturnRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(AddClosureReturnTypeRector::class); + $rectorConfig->rule(ReturnTypeFromStrictTypedPropertyRector::class); + $rectorConfig->rule(TypedPropertyFromStrictConstructorRector::class); + $rectorConfig->rule(ParamTypeFromStrictTypedPropertyRector::class); + $rectorConfig->rule(ReturnTypeFromStrictTypedCallRector::class); + $rectorConfig->rule(AddVoidReturnTypeWhereNoReturnRector::class); + $rectorConfig->rule(ReturnTypeFromReturnNewRector::class); + $rectorConfig->rule(TypedPropertyFromStrictGetterMethodReturnTypeRector::class); + $rectorConfig->rule(AddMethodCallBasedStrictParamTypeRector::class); + $rectorConfig->rule(ArrayShapeFromConstantArrayReturnRector::class); }; diff --git a/config/set/type-declaration.php b/config/set/type-declaration.php index fca09fd1ee2..6e1849589e0 100644 --- a/config/set/type-declaration.php +++ b/config/set/type-declaration.php @@ -16,17 +16,17 @@ use Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector; use Rector\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector; use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector; use Rector\TypeDeclaration\Rector\Property\VarAnnotationIncorrectNullableRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector::class); - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector::class); - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector::class); - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector::class); - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\AddArrayParamDocTypeRector::class); - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector::class); - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByParentCallTypeRector::class); - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByMethodCallTypeRector::class); - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector::class); - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnAnnotationIncorrectNullableRector::class); - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\Property\VarAnnotationIncorrectNullableRector::class); - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ParamAnnotationIncorrectNullableRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(ParamTypeDeclarationRector::class); + $rectorConfig->rule(ReturnTypeDeclarationRector::class); + $rectorConfig->rule(PropertyTypeDeclarationRector::class); + $rectorConfig->rule(AddClosureReturnTypeRector::class); + $rectorConfig->rule(AddArrayParamDocTypeRector::class); + $rectorConfig->rule(AddArrayReturnDocTypeRector::class); + $rectorConfig->rule(ParamTypeByParentCallTypeRector::class); + $rectorConfig->rule(ParamTypeByMethodCallTypeRector::class); + $rectorConfig->rule(TypedPropertyFromAssignsRector::class); + $rectorConfig->rule(ReturnAnnotationIncorrectNullableRector::class); + $rectorConfig->rule(VarAnnotationIncorrectNullableRector::class); + $rectorConfig->rule(ParamAnnotationIncorrectNullableRector::class); }; diff --git a/config/set/unwrap-compat.php b/config/set/unwrap-compat.php index 933aa6a2983..d905719c01c 100644 --- a/config/set/unwrap-compat.php +++ b/config/set/unwrap-compat.php @@ -5,6 +5,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(UnwrapFutureCompatibleIfFunctionExistsRector::class); }; diff --git a/packages/BetterPhpDocParser/Attributes/AttributeMirrorer.php b/packages/BetterPhpDocParser/Attributes/AttributeMirrorer.php index 0c1b633bf91..a0df6824ca5 100644 --- a/packages/BetterPhpDocParser/Attributes/AttributeMirrorer.php +++ b/packages/BetterPhpDocParser/Attributes/AttributeMirrorer.php @@ -10,8 +10,8 @@ final class AttributeMirrorer /** * @var string[] */ - private const ATTRIBUTES_TO_MIRROR = [\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::PARENT, \Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, \Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE]; - public function mirror(\PHPStan\PhpDocParser\Ast\Node $oldNode, \PHPStan\PhpDocParser\Ast\Node $newNode) : void + private const ATTRIBUTES_TO_MIRROR = [PhpDocAttributeKey::PARENT, PhpDocAttributeKey::START_AND_END, PhpDocAttributeKey::ORIG_NODE]; + public function mirror(Node $oldNode, Node $newNode) : void { foreach (self::ATTRIBUTES_TO_MIRROR as $attributeToMirror) { if (!$oldNode->hasAttribute($attributeToMirror)) { diff --git a/packages/BetterPhpDocParser/Comment/CommentsMerger.php b/packages/BetterPhpDocParser/Comment/CommentsMerger.php index e4dd9b48b2b..899dcdc914c 100644 --- a/packages/BetterPhpDocParser/Comment/CommentsMerger.php +++ b/packages/BetterPhpDocParser/Comment/CommentsMerger.php @@ -14,14 +14,14 @@ final class CommentsMerger * @var \Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser */ private $simpleCallableNodeTraverser; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; } /** * @param Node[] $mergedNodes */ - public function keepComments(\PhpParser\Node $newNode, array $mergedNodes) : void + public function keepComments(Node $newNode, array $mergedNodes) : void { $comments = $newNode->getComments(); foreach ($mergedNodes as $mergedNode) { @@ -30,25 +30,25 @@ final class CommentsMerger if ($comments === []) { return; } - $newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $comments); + $newNode->setAttribute(AttributeKey::COMMENTS, $comments); // remove so comments "win" - $newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, null); + $newNode->setAttribute(AttributeKey::PHP_DOC_INFO, null); } - public function keepParent(\PhpParser\Node $newNode, \PhpParser\Node $oldNode) : void + public function keepParent(Node $newNode, Node $oldNode) : void { - $parent = $oldNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node) { + $parent = $oldNode->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Node) { return; } - $phpDocInfo = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO); + $phpDocInfo = $parent->getAttribute(AttributeKey::PHP_DOC_INFO); $comments = $parent->getComments(); if ($phpDocInfo === null && $comments === []) { return; } - $newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $phpDocInfo); - $newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $comments); + $newNode->setAttribute(AttributeKey::PHP_DOC_INFO, $phpDocInfo); + $newNode->setAttribute(AttributeKey::COMMENTS, $comments); } - public function keepChildren(\PhpParser\Node $newNode, \PhpParser\Node $oldNode) : void + public function keepChildren(Node $newNode, Node $oldNode) : void { $childrenComments = $this->collectChildrenComments($oldNode); if ($childrenComments === []) { @@ -58,15 +58,15 @@ final class CommentsMerger foreach ($childrenComments as $childComment) { $commentContent .= $childComment->getText() . \PHP_EOL; } - $newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, [new \PhpParser\Comment($commentContent)]); + $newNode->setAttribute(AttributeKey::COMMENTS, [new Comment($commentContent)]); } /** * @return Comment[] */ - private function collectChildrenComments(\PhpParser\Node $node) : array + private function collectChildrenComments(Node $node) : array { $childrenComments = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($node, function (\PhpParser\Node $node) use(&$childrenComments) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($node, function (Node $node) use(&$childrenComments) { $comments = $node->getComments(); if ($comments !== []) { $childrenComments = \array_merge($childrenComments, $comments); diff --git a/packages/BetterPhpDocParser/Contract/BasePhpDocNodeVisitorInterface.php b/packages/BetterPhpDocParser/Contract/BasePhpDocNodeVisitorInterface.php index 2e3302781f6..2291d21ddf9 100644 --- a/packages/BetterPhpDocParser/Contract/BasePhpDocNodeVisitorInterface.php +++ b/packages/BetterPhpDocParser/Contract/BasePhpDocNodeVisitorInterface.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace Rector\BetterPhpDocParser\Contract; use RectorPrefix20220607\Symplify\Astral\PhpDocParser\Contract\PhpDocNodeVisitorInterface; -interface BasePhpDocNodeVisitorInterface extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\Contract\PhpDocNodeVisitorInterface +interface BasePhpDocNodeVisitorInterface extends PhpDocNodeVisitorInterface { } diff --git a/packages/BetterPhpDocParser/Contract/PhpDocParser/PhpDocNodeDecoratorInterface.php b/packages/BetterPhpDocParser/Contract/PhpDocParser/PhpDocNodeDecoratorInterface.php index 17f54b93e04..9e3bd2d4e28 100644 --- a/packages/BetterPhpDocParser/Contract/PhpDocParser/PhpDocNodeDecoratorInterface.php +++ b/packages/BetterPhpDocParser/Contract/PhpDocParser/PhpDocNodeDecoratorInterface.php @@ -7,5 +7,5 @@ use PhpParser\Node; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode; interface PhpDocNodeDecoratorInterface { - public function decorate(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \PhpParser\Node $phpNode) : void; + public function decorate(PhpDocNode $phpDocNode, Node $phpNode) : void; } diff --git a/packages/BetterPhpDocParser/DataProvider/CurrentTokenIteratorProvider.php b/packages/BetterPhpDocParser/DataProvider/CurrentTokenIteratorProvider.php index 19bf1cf196e..9d4e48a2efb 100644 --- a/packages/BetterPhpDocParser/DataProvider/CurrentTokenIteratorProvider.php +++ b/packages/BetterPhpDocParser/DataProvider/CurrentTokenIteratorProvider.php @@ -11,14 +11,14 @@ final class CurrentTokenIteratorProvider * @var \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator|null */ private $betterTokenIterator; - public function setBetterTokenIterator(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator) : void + public function setBetterTokenIterator(BetterTokenIterator $betterTokenIterator) : void { $this->betterTokenIterator = $betterTokenIterator; } - public function provide() : \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator + public function provide() : BetterTokenIterator { if ($this->betterTokenIterator === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } return $this->betterTokenIterator; } diff --git a/packages/BetterPhpDocParser/PhpDoc/DoctrineAnnotationTagValueNode.php b/packages/BetterPhpDocParser/PhpDoc/DoctrineAnnotationTagValueNode.php index 875f67726e7..379e409527c 100644 --- a/packages/BetterPhpDocParser/PhpDoc/DoctrineAnnotationTagValueNode.php +++ b/packages/BetterPhpDocParser/PhpDoc/DoctrineAnnotationTagValueNode.php @@ -7,7 +7,7 @@ use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\AbstractValuesAwareNode; use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey; use Stringable; -final class DoctrineAnnotationTagValueNode extends \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\AbstractValuesAwareNode +final class DoctrineAnnotationTagValueNode extends AbstractValuesAwareNode { /** * @var \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode @@ -16,7 +16,7 @@ final class DoctrineAnnotationTagValueNode extends \Rector\BetterPhpDocParser\Va /** * @param array $values */ - public function __construct(\PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode $identifierTypeNode, ?string $originalContent = null, array $values = [], ?string $silentKey = null) + public function __construct(IdentifierTypeNode $identifierTypeNode, ?string $originalContent = null, array $values = [], ?string $silentKey = null) { $this->identifierTypeNode = $identifierTypeNode; $this->hasChanged = \true; @@ -59,7 +59,7 @@ final class DoctrineAnnotationTagValueNode extends \Rector\BetterPhpDocParser\Va return \true; } // the name is not fully qualified in the original name, look for resolved class attribute - $resolvedClass = $this->identifierTypeNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::RESOLVED_CLASS); + $resolvedClass = $this->identifierTypeNode->getAttribute(PhpDocAttributeKey::RESOLVED_CLASS); return $resolvedClass === $className; } } diff --git a/packages/BetterPhpDocParser/PhpDoc/SpacelessPhpDocTagNode.php b/packages/BetterPhpDocParser/PhpDoc/SpacelessPhpDocTagNode.php index 3464b0c34fa..47fc504bdbf 100644 --- a/packages/BetterPhpDocParser/PhpDoc/SpacelessPhpDocTagNode.php +++ b/packages/BetterPhpDocParser/PhpDoc/SpacelessPhpDocTagNode.php @@ -9,7 +9,7 @@ use Stringable; * Useful for annotation class based annotation, e.g. @ORM\Entity to prevent space * between the @ORM\Entity and (someContent) */ -final class SpacelessPhpDocTagNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode +final class SpacelessPhpDocTagNode extends PhpDocTagNode { public function __toString() : string { diff --git a/packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php b/packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php index 6e85e9a5b94..72578b270f7 100644 --- a/packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php +++ b/packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php @@ -39,7 +39,7 @@ final class PhpDocInfo /** * @var array, string> */ - private const TAGS_TYPES_TO_NAMES = [\PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode::class => '@return', \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode::class => '@param', \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode::class => '@var', \PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueNode::class => '@method', \PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode::class => '@property']; + private const TAGS_TYPES_TO_NAMES = [ReturnTagValueNode::class => '@return', ParamTagValueNode::class => '@param', VarTagValueNode::class => '@var', MethodTagValueNode::class => '@method', PropertyTagValueNode::class => '@property']; /** * @var bool */ @@ -93,7 +93,7 @@ final class PhpDocInfo * @var \Rector\BetterPhpDocParser\PhpDocNodeFinder\PhpDocNodeByTypeFinder */ private $phpDocNodeByTypeFinder; - public function __construct(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \PhpParser\Node $node, \Rector\BetterPhpDocParser\Annotation\AnnotationNaming $annotationNaming, \Rector\Core\Configuration\CurrentNodeProvider $currentNodeProvider, \Rector\ChangesReporting\Collector\RectorChangeCollector $rectorChangeCollector, \Rector\BetterPhpDocParser\PhpDocNodeFinder\PhpDocNodeByTypeFinder $phpDocNodeByTypeFinder) + public function __construct(PhpDocNode $phpDocNode, BetterTokenIterator $betterTokenIterator, StaticTypeMapper $staticTypeMapper, \PhpParser\Node $node, AnnotationNaming $annotationNaming, CurrentNodeProvider $currentNodeProvider, RectorChangeCollector $rectorChangeCollector, PhpDocNodeByTypeFinder $phpDocNodeByTypeFinder) { $this->phpDocNode = $phpDocNode; $this->betterTokenIterator = $betterTokenIterator; @@ -104,22 +104,22 @@ final class PhpDocInfo $this->rectorChangeCollector = $rectorChangeCollector; $this->phpDocNodeByTypeFinder = $phpDocNodeByTypeFinder; $this->originalPhpDocNode = clone $phpDocNode; - if (!$betterTokenIterator->containsTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL)) { + if (!$betterTokenIterator->containsTokenType(Lexer::TOKEN_PHPDOC_EOL)) { $this->isSingleLine = \true; } } - public function addPhpDocTagNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $phpDocChildNode) : void + public function addPhpDocTagNode(PhpDocChildNode $phpDocChildNode) : void { $this->phpDocNode->children[] = $phpDocChildNode; // to give node more space $this->makeMultiLined(); $this->markAsChanged(); } - public function getPhpDocNode() : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode + public function getPhpDocNode() : PhpDocNode { return $this->phpDocNode; } - public function getOriginalPhpDocNode() : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode + public function getOriginalPhpDocNode() : PhpDocNode { return $this->originalPhpDocNode; } @@ -134,7 +134,7 @@ final class PhpDocInfo { return $this->betterTokenIterator->count(); } - public function getVarTagValueNode(string $tagName = '@var') : ?\PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode + public function getVarTagValueNode(string $tagName = '@var') : ?VarTagValueNode { return $this->phpDocNode->getVarTagValues($tagName)[0] ?? null; } @@ -149,13 +149,13 @@ final class PhpDocInfo } $tags = $this->phpDocNode->getTags(); $name = $this->annotationNaming->normalizeName($name); - $tags = \array_filter($tags, function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode $tag) use($name) : bool { + $tags = \array_filter($tags, function (PhpDocTagNode $tag) use($name) : bool { return $tag->name === $name; }); $tags = \array_values($tags); return \array_values($tags); } - public function getParamType(string $name) : \PHPStan\Type\Type + public function getParamType(string $name) : Type { $paramTagValueNodes = $this->getParamTagValueByName($name); return $this->getTypeOrMixed($paramTagValueNodes); @@ -167,7 +167,7 @@ final class PhpDocInfo { return $this->phpDocNode->getParamTagValues(); } - public function getParamTagValueNodeByName(string $parameterName) : ?\PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode + public function getParamTagValueNodeByName(string $parameterName) : ?ParamTagValueNode { foreach ($this->phpDocNode->getParamTagValues() as $paramTagValueNode) { if ($paramTagValueNode->parameterName !== '$' . $parameterName) { @@ -177,11 +177,11 @@ final class PhpDocInfo } return null; } - public function getVarType(string $tagName = '@var') : \PHPStan\Type\Type + public function getVarType(string $tagName = '@var') : Type { return $this->getTypeOrMixed($this->getVarTagValueNode($tagName)); } - public function getReturnType() : \PHPStan\Type\Type + public function getReturnType() : Type { return $this->getTypeOrMixed($this->getReturnTagValue()); } @@ -228,14 +228,14 @@ final class PhpDocInfo { return (bool) $this->getTagsByName($name); } - public function getByName(string $name) : ?\PHPStan\PhpDocParser\Ast\Node + public function getByName(string $name) : ?Node { return $this->getTagsByName($name)[0] ?? null; } /** * @param class-string[] $classes */ - public function getByAnnotationClasses(array $classes) : ?\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode + public function getByAnnotationClasses(array $classes) : ?DoctrineAnnotationTagValueNode { $doctrineAnnotationTagValueNodes = $this->phpDocNodeByTypeFinder->findDoctrineAnnotationsByClasses($this->phpDocNode, $classes); return $doctrineAnnotationTagValueNodes[0] ?? null; @@ -243,7 +243,7 @@ final class PhpDocInfo /** * @param class-string $class */ - public function getByAnnotationClass(string $class) : ?\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode + public function getByAnnotationClass(string $class) : ?DoctrineAnnotationTagValueNode { $doctrineAnnotationTagValueNodes = $this->phpDocNodeByTypeFinder->findDoctrineAnnotationsByClass($this->phpDocNode, $class); return $doctrineAnnotationTagValueNodes[0] ?? null; @@ -265,11 +265,11 @@ final class PhpDocInfo /** * @param string[] $desiredClasses */ - public function findOneByAnnotationClasses(array $desiredClasses) : ?\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode + public function findOneByAnnotationClasses(array $desiredClasses) : ?DoctrineAnnotationTagValueNode { foreach ($desiredClasses as $desiredClass) { $doctrineAnnotationTagValueNode = $this->findOneByAnnotationClass($desiredClass); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { continue; } return $doctrineAnnotationTagValueNode; @@ -279,7 +279,7 @@ final class PhpDocInfo /** * @param class-string $desiredClass */ - public function findOneByAnnotationClass(string $desiredClass) : ?\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode + public function findOneByAnnotationClass(string $desiredClass) : ?DoctrineAnnotationTagValueNode { $foundTagValueNodes = $this->findByAnnotationClass($desiredClass); return $foundTagValueNodes[0] ?? null; @@ -298,9 +298,9 @@ final class PhpDocInfo */ public function removeByType(string $typeToRemove) : void { - $phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser(); - $phpDocNodeTraverser->traverseWithCallable($this->phpDocNode, '', function (\PHPStan\PhpDocParser\Ast\Node $node) use($typeToRemove) : ?int { - if ($node instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode && \is_a($node->value, $typeToRemove, \true)) { + $phpDocNodeTraverser = new PhpDocNodeTraverser(); + $phpDocNodeTraverser->traverseWithCallable($this->phpDocNode, '', function (Node $node) use($typeToRemove) : ?int { + if ($node instanceof PhpDocTagNode && \is_a($node->value, $typeToRemove, \true)) { // keep special annotation for tools if (\strncmp($node->name, '@psalm-', \strlen('@psalm-')) === 0) { return null; @@ -309,13 +309,13 @@ final class PhpDocInfo return null; } $this->markAsChanged(); - return \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser::NODE_REMOVE; + return PhpDocNodeTraverser::NODE_REMOVE; } if (!\is_a($node, $typeToRemove, \true)) { return null; } $this->markAsChanged(); - return \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser::NODE_REMOVE; + return PhpDocNodeTraverser::NODE_REMOVE; }); } /** @@ -330,15 +330,15 @@ final class PhpDocInfo } return $paramTypesByName; } - public function addTagValueNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $phpDocTagValueNode) : void + public function addTagValueNode(PhpDocTagValueNode $phpDocTagValueNode) : void { - if ($phpDocTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { - if ($phpDocTagValueNode->identifierTypeNode instanceof \Rector\BetterPhpDocParser\ValueObject\Type\ShortenedIdentifierTypeNode) { + if ($phpDocTagValueNode instanceof DoctrineAnnotationTagValueNode) { + if ($phpDocTagValueNode->identifierTypeNode instanceof ShortenedIdentifierTypeNode) { $name = '@' . $phpDocTagValueNode->identifierTypeNode; } else { $name = '@\\' . $phpDocTagValueNode->identifierTypeNode; } - $spacelessPhpDocTagNode = new \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode($name, $phpDocTagValueNode); + $spacelessPhpDocTagNode = new SpacelessPhpDocTagNode($name, $phpDocTagValueNode); $this->addPhpDocTagNode($spacelessPhpDocTagNode); return; } @@ -346,7 +346,7 @@ final class PhpDocInfo if (!\is_string($name)) { return; } - $phpDocTagNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode($name, $phpDocTagValueNode); + $phpDocTagNode = new PhpDocTagNode($name, $phpDocTagValueNode); $this->addPhpDocTagNode($phpDocTagNode); } public function isNewNode() : bool @@ -368,25 +368,25 @@ final class PhpDocInfo { // fallback for invalid tag value node foreach ($this->phpDocNode->children as $phpDocChildNode) { - if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) { + if (!$phpDocChildNode instanceof PhpDocTagNode) { continue; } if ($phpDocChildNode->name !== $name) { continue; } - if (!$phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\InvalidTagValueNode) { + if (!$phpDocChildNode->value instanceof InvalidTagValueNode) { continue; } return \true; } return \false; } - public function getReturnTagValue() : ?\PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode + public function getReturnTagValue() : ?ReturnTagValueNode { $returnTagValueNodes = $this->phpDocNode->getReturnTagValues(); return $returnTagValueNodes[0] ?? null; } - public function getParamTagValueByName(string $name) : ?\PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode + public function getParamTagValueByName(string $name) : ?ParamTagValueNode { $desiredParamNameWithDollar = '$' . \ltrim($name, '$'); foreach ($this->getParamTagValueNodes() as $paramTagValueNode) { @@ -410,7 +410,7 @@ final class PhpDocInfo return \true; } foreach ($this->phpDocNode->children as $children) { - if (!$children instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode) { + if (!$children instanceof PhpDocTextNode) { continue; } if (\in_array($children->text, ['{@inheritdoc}', '{@inheritDoc}'], \true)) { @@ -441,8 +441,8 @@ final class PhpDocInfo return \true; } // has a single node with missing start_end - $phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser(); - $changedPhpDocNodeVisitor = new \Rector\BetterPhpDocParser\PhpDocNodeVisitor\ChangedPhpDocNodeVisitor(); + $phpDocNodeTraverser = new PhpDocNodeTraverser(); + $changedPhpDocNodeVisitor = new ChangedPhpDocNodeVisitor(); $phpDocNodeTraverser->addPhpDocNodeVisitor($changedPhpDocNodeVisitor); $phpDocNodeTraverser->traverse($this->phpDocNode); return $changedPhpDocNodeVisitor->hasChanged(); @@ -466,7 +466,7 @@ final class PhpDocInfo { return $this->node; } - public function resolveNameForPhpDocTagValueNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $phpDocTagValueNode) : ?string + public function resolveNameForPhpDocTagValueNode(PhpDocTagValueNode $phpDocTagValueNode) : ?string { foreach (self::TAGS_TYPES_TO_NAMES as $tagValueNodeType => $name) { /** @var class-string $tagValueNodeType */ @@ -479,10 +479,10 @@ final class PhpDocInfo /** * @return \PHPStan\Type\MixedType|\PHPStan\Type\Type */ - private function getTypeOrMixed(?\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $phpDocTagValueNode) + private function getTypeOrMixed(?PhpDocTagValueNode $phpDocTagValueNode) { if ($phpDocTagValueNode === null) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } return $this->staticTypeMapper->mapPHPStanPhpDocTypeToPHPStanType($phpDocTagValueNode, $this->node); } diff --git a/packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfoFactory.php b/packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfoFactory.php index 78ce1c8bfca..9d618da9e72 100644 --- a/packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfoFactory.php +++ b/packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfoFactory.php @@ -64,7 +64,7 @@ final class PhpDocInfoFactory * @var \Rector\BetterPhpDocParser\PhpDocNodeFinder\PhpDocNodeByTypeFinder */ private $phpDocNodeByTypeFinder; - public function __construct(\Rector\BetterPhpDocParser\PhpDocNodeMapper $phpDocNodeMapper, \Rector\Core\Configuration\CurrentNodeProvider $currentNodeProvider, \PHPStan\PhpDocParser\Lexer\Lexer $lexer, \Rector\BetterPhpDocParser\PhpDocParser\BetterPhpDocParser $betterPhpDocParser, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\BetterPhpDocParser\Annotation\AnnotationNaming $annotationNaming, \Rector\ChangesReporting\Collector\RectorChangeCollector $rectorChangeCollector, \Rector\BetterPhpDocParser\PhpDocNodeFinder\PhpDocNodeByTypeFinder $phpDocNodeByTypeFinder) + public function __construct(PhpDocNodeMapper $phpDocNodeMapper, CurrentNodeProvider $currentNodeProvider, Lexer $lexer, BetterPhpDocParser $betterPhpDocParser, StaticTypeMapper $staticTypeMapper, AnnotationNaming $annotationNaming, RectorChangeCollector $rectorChangeCollector, PhpDocNodeByTypeFinder $phpDocNodeByTypeFinder) { $this->phpDocNodeMapper = $phpDocNodeMapper; $this->currentNodeProvider = $currentNodeProvider; @@ -75,10 +75,10 @@ final class PhpDocInfoFactory $this->rectorChangeCollector = $rectorChangeCollector; $this->phpDocNodeByTypeFinder = $phpDocNodeByTypeFinder; } - public function createFromNodeOrEmpty(\PhpParser\Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo + public function createFromNodeOrEmpty(Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo { // already added - $phpDocInfo = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO); + $phpDocInfo = $node->getAttribute(AttributeKey::PHP_DOC_INFO); if ($phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { return $phpDocInfo; } @@ -88,7 +88,7 @@ final class PhpDocInfoFactory } return $this->createEmpty($node); } - public function createFromNode(\PhpParser\Node $node) : ?\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo + public function createFromNode(Node $node) : ?\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo { $objectHash = \spl_object_hash($node); if (isset($this->phpDocInfosByObjectHash[$objectHash])) { @@ -97,17 +97,17 @@ final class PhpDocInfoFactory /** @see \Rector\BetterPhpDocParser\PhpDocParser\DoctrineAnnotationDecorator::decorate() */ $this->currentNodeProvider->setNode($node); $docComment = $node->getDocComment(); - if (!$docComment instanceof \PhpParser\Comment\Doc) { + if (!$docComment instanceof Doc) { if ($node->getComments() !== []) { return null; } // create empty node - $tokenIterator = new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator([]); - $phpDocNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode([]); + $tokenIterator = new BetterTokenIterator([]); + $phpDocNode = new PhpDocNode([]); } else { $text = $docComment->getText(); $tokens = $this->lexer->tokenize($text); - $tokenIterator = new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator($tokens); + $tokenIterator = new BetterTokenIterator($tokens); $phpDocNode = $this->betterPhpDocParser->parse($tokenIterator); $this->setPositionOfLastToken($phpDocNode); } @@ -115,12 +115,12 @@ final class PhpDocInfoFactory $this->phpDocInfosByObjectHash[$objectHash] = $phpDocInfo; return $phpDocInfo; } - public function createEmpty(\PhpParser\Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo + public function createEmpty(Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo { /** @see \Rector\BetterPhpDocParser\PhpDocParser\DoctrineAnnotationDecorator::decorate() */ $this->currentNodeProvider->setNode($node); - $phpDocNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode([]); - $phpDocInfo = $this->createFromPhpDocNode($phpDocNode, new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator([]), $node); + $phpDocNode = new PhpDocNode([]); + $phpDocInfo = $this->createFromPhpDocNode($phpDocNode, new BetterTokenIterator([]), $node); // multiline by default $phpDocInfo->makeMultiLined(); return $phpDocInfo; @@ -128,23 +128,23 @@ final class PhpDocInfoFactory /** * Needed for printing */ - private function setPositionOfLastToken(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode) : void + private function setPositionOfLastToken(PhpDocNode $phpDocNode) : void { if ($phpDocNode->children === []) { return; } $phpDocChildNodes = $phpDocNode->children; $phpDocChildNode = \array_pop($phpDocChildNodes); - $startAndEnd = $phpDocChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END); - if ($startAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) { - $phpDocNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::LAST_PHP_DOC_TOKEN_POSITION, $startAndEnd->getEnd()); + $startAndEnd = $phpDocChildNode->getAttribute(PhpDocAttributeKey::START_AND_END); + if ($startAndEnd instanceof StartAndEnd) { + $phpDocNode->setAttribute(PhpDocAttributeKey::LAST_PHP_DOC_TOKEN_POSITION, $startAndEnd->getEnd()); } } - private function createFromPhpDocNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator, \PhpParser\Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo + private function createFromPhpDocNode(PhpDocNode $phpDocNode, BetterTokenIterator $betterTokenIterator, Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo { $this->phpDocNodeMapper->transform($phpDocNode, $betterTokenIterator); $phpDocInfo = new \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo($phpDocNode, $betterTokenIterator, $this->staticTypeMapper, $node, $this->annotationNaming, $this->currentNodeProvider, $this->rectorChangeCollector, $this->phpDocNodeByTypeFinder); - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $phpDocInfo); + $node->setAttribute(AttributeKey::PHP_DOC_INFO, $phpDocInfo); return $phpDocInfo; } } diff --git a/packages/BetterPhpDocParser/PhpDocInfo/TokenIteratorFactory.php b/packages/BetterPhpDocParser/PhpDocInfo/TokenIteratorFactory.php index a4d2946578a..eeae79e72de 100644 --- a/packages/BetterPhpDocParser/PhpDocInfo/TokenIteratorFactory.php +++ b/packages/BetterPhpDocParser/PhpDocInfo/TokenIteratorFactory.php @@ -23,23 +23,23 @@ final class TokenIteratorFactory * @var \Symplify\PackageBuilder\Reflection\PrivatesAccessor */ private $privatesAccessor; - public function __construct(\PHPStan\PhpDocParser\Lexer\Lexer $lexer, \RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor $privatesAccessor) + public function __construct(Lexer $lexer, PrivatesAccessor $privatesAccessor) { $this->lexer = $lexer; $this->privatesAccessor = $privatesAccessor; } - public function create(string $content) : \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator + public function create(string $content) : BetterTokenIterator { $tokens = $this->lexer->tokenize($content); - return new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator($tokens); + return new BetterTokenIterator($tokens); } - public function createFromTokenIterator(\PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator) : \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator + public function createFromTokenIterator(TokenIterator $tokenIterator) : BetterTokenIterator { - if ($tokenIterator instanceof \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator) { + if ($tokenIterator instanceof BetterTokenIterator) { return $tokenIterator; } $tokens = $this->privatesAccessor->getPrivateProperty($tokenIterator, 'tokens'); - $betterTokenIterator = new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator($tokens); + $betterTokenIterator = new BetterTokenIterator($tokens); // keep original position $currentIndex = $this->privatesAccessor->getPrivateProperty($tokenIterator, self::INDEX); $this->privatesAccessor->setPrivateProperty($betterTokenIterator, self::INDEX, $currentIndex); diff --git a/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocClassRenamer.php b/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocClassRenamer.php index 2b9de5e9fe3..35254796453 100644 --- a/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocClassRenamer.php +++ b/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocClassRenamer.php @@ -16,7 +16,7 @@ final class PhpDocClassRenamer * @var \Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher */ private $classAnnotationMatcher; - public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher $classAnnotationMatcher) + public function __construct(ClassAnnotationMatcher $classAnnotationMatcher) { $this->classAnnotationMatcher = $classAnnotationMatcher; } @@ -26,7 +26,7 @@ final class PhpDocClassRenamer * * @param string[] $oldToNewClasses */ - public function changeTypeInAnnotationTypes(\PhpParser\Node $node, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, array $oldToNewClasses) : void + public function changeTypeInAnnotationTypes(Node $node, PhpDocInfo $phpDocInfo, array $oldToNewClasses) : void { $this->processAssertChoiceTagValueNode($oldToNewClasses, $phpDocInfo); $this->processDoctrineRelationTagValueNode($node, $oldToNewClasses, $phpDocInfo); @@ -35,14 +35,14 @@ final class PhpDocClassRenamer /** * @param array $oldToNewClasses */ - private function processAssertChoiceTagValueNode(array $oldToNewClasses, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void + private function processAssertChoiceTagValueNode(array $oldToNewClasses, PhpDocInfo $phpDocInfo) : void { $assertChoiceTagValueNode = $phpDocInfo->findOneByAnnotationClass('Symfony\\Component\\Validator\\Constraints\\Choice'); - if (!$assertChoiceTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$assertChoiceTagValueNode instanceof DoctrineAnnotationTagValueNode) { return; } $callback = $assertChoiceTagValueNode->getValueWithoutQuotes('callback'); - if (!$callback instanceof \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode) { + if (!$callback instanceof CurlyListNode) { return; } $callbackClass = $callback->getValueWithoutQuotes(0); @@ -58,10 +58,10 @@ final class PhpDocClassRenamer /** * @param array $oldToNewClasses */ - private function processDoctrineRelationTagValueNode(\PhpParser\Node $node, array $oldToNewClasses, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void + private function processDoctrineRelationTagValueNode(Node $node, array $oldToNewClasses, PhpDocInfo $phpDocInfo) : void { $doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClasses(['Doctrine\\ORM\\Mapping\\OneToMany', 'Doctrine\\ORM\\Mapping\\ManyToMany', 'Doctrine\\ORM\\Mapping\\Embedded']); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return; } $this->processDoctrineToMany($doctrineAnnotationTagValueNode, $node, $oldToNewClasses); @@ -69,10 +69,10 @@ final class PhpDocClassRenamer /** * @param array $oldToNewClasses */ - private function processSerializerTypeTagValueNode(array $oldToNewClasses, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void + private function processSerializerTypeTagValueNode(array $oldToNewClasses, PhpDocInfo $phpDocInfo) : void { $doctrineAnnotationTagValueNode = $phpDocInfo->findOneByAnnotationClass('JMS\\Serializer\\Annotation\\Type'); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return; } foreach ($oldToNewClasses as $oldClass => $newClass) { @@ -82,7 +82,7 @@ final class PhpDocClassRenamer $doctrineAnnotationTagValueNode->changeSilentValue($newClass); continue; } - $newContent = \RectorPrefix20220607\Nette\Utils\Strings::replace($className, '#\\b' . \preg_quote($oldClass, '#') . '\\b#', $newClass); + $newContent = Strings::replace($className, '#\\b' . \preg_quote($oldClass, '#') . '\\b#', $newClass); if ($newContent === $className) { continue; } @@ -99,7 +99,7 @@ final class PhpDocClassRenamer /** * @param array $oldToNewClasses */ - private function processDoctrineToMany(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, \PhpParser\Node $node, array $oldToNewClasses) : void + private function processDoctrineToMany(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, Node $node, array $oldToNewClasses) : void { $classKey = $doctrineAnnotationTagValueNode->hasClassName('Doctrine\\ORM\\Mapping\\Embedded') ? 'class' : 'targetEntity'; $targetEntity = $doctrineAnnotationTagValueNode->getValueWithoutQuotes($classKey); diff --git a/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTagRemover.php b/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTagRemover.php index c27751f6d1d..66706532ca4 100644 --- a/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTagRemover.php +++ b/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTagRemover.php @@ -10,37 +10,37 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser; final class PhpDocTagRemover { - public function removeByName(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, string $name) : void + public function removeByName(PhpDocInfo $phpDocInfo, string $name) : void { $phpDocNode = $phpDocInfo->getPhpDocNode(); foreach ($phpDocNode->children as $key => $phpDocChildNode) { - if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) { + if (!$phpDocChildNode instanceof PhpDocTagNode) { continue; } if ($this->areAnnotationNamesEqual($name, $phpDocChildNode->name)) { unset($phpDocNode->children[$key]); $phpDocInfo->markAsChanged(); } - if ($phpDocChildNode->value instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode && $phpDocChildNode->value->hasClassName($name)) { + if ($phpDocChildNode->value instanceof DoctrineAnnotationTagValueNode && $phpDocChildNode->value->hasClassName($name)) { unset($phpDocNode->children[$key]); $phpDocInfo->markAsChanged(); } } } - public function removeTagValueFromNode(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PHPStan\PhpDocParser\Ast\Node $desiredNode) : void + public function removeTagValueFromNode(PhpDocInfo $phpDocInfo, Node $desiredNode) : void { $phpDocNode = $phpDocInfo->getPhpDocNode(); - $phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser(); + $phpDocNodeTraverser = new PhpDocNodeTraverser(); $phpDocNodeTraverser->traverseWithCallable($phpDocNode, '', function ($node) use($desiredNode, $phpDocInfo) : ?int { - if ($node instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode && $node->value === $desiredNode) { + if ($node instanceof PhpDocTagNode && $node->value === $desiredNode) { $phpDocInfo->markAsChanged(); - return \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser::NODE_REMOVE; + return PhpDocNodeTraverser::NODE_REMOVE; } if ($node !== $desiredNode) { return null; } $phpDocInfo->markAsChanged(); - return \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser::NODE_REMOVE; + return PhpDocNodeTraverser::NODE_REMOVE; }); } private function areAnnotationNamesEqual(string $firstAnnotationName, string $secondAnnotationName) : bool diff --git a/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTypeChanger.php b/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTypeChanger.php index ff722678d23..69466e9a6c6 100644 --- a/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTypeChanger.php +++ b/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTypeChanger.php @@ -34,7 +34,7 @@ final class PhpDocTypeChanger /** * @var array> */ - public const ALLOWED_TYPES = [\PHPStan\PhpDocParser\Ast\Type\GenericTypeNode::class, \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode::class, \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode::class, \PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode::class]; + public const ALLOWED_TYPES = [GenericTypeNode::class, SpacingAwareArrayTypeNode::class, SpacingAwareCallableTypeNode::class, ArrayShapeNode::class]; /** * @var string[] */ @@ -69,7 +69,7 @@ final class PhpDocTypeChanger * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory */ private $phpDocInfoFactory; - public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\NodeTypeResolver\TypeComparator\TypeComparator $typeComparator, \Rector\TypeDeclaration\PhpDocParser\ParamPhpDocNodeFactory $paramPhpDocNodeFactory, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\BetterPhpDocParser\Comment\CommentsMerger $commentsMerger, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory) + public function __construct(StaticTypeMapper $staticTypeMapper, TypeComparator $typeComparator, ParamPhpDocNodeFactory $paramPhpDocNodeFactory, NodeNameResolver $nodeNameResolver, CommentsMerger $commentsMerger, PhpDocInfoFactory $phpDocInfoFactory) { $this->staticTypeMapper = $staticTypeMapper; $this->typeComparator = $typeComparator; @@ -78,7 +78,7 @@ final class PhpDocTypeChanger $this->commentsMerger = $commentsMerger; $this->phpDocInfoFactory = $phpDocInfoFactory; } - public function changeVarType(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PHPStan\Type\Type $newType) : void + public function changeVarType(PhpDocInfo $phpDocInfo, Type $newType) : void { // better skip, could crash hard if ($phpDocInfo->hasInvalidTag('@var')) { @@ -89,22 +89,22 @@ final class PhpDocTypeChanger return; } // prevent existing type override by mixed - if (!$phpDocInfo->getVarType() instanceof \PHPStan\Type\MixedType && $newType instanceof \PHPStan\Type\Constant\ConstantArrayType && $newType->getItemType() instanceof \PHPStan\Type\NeverType) { + if (!$phpDocInfo->getVarType() instanceof MixedType && $newType instanceof ConstantArrayType && $newType->getItemType() instanceof NeverType) { return; } // override existing type - $newPHPStanPhpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY); + $newPHPStanPhpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, TypeKind::PROPERTY); $currentVarTagValueNode = $phpDocInfo->getVarTagValueNode(); if ($currentVarTagValueNode !== null) { // only change type $currentVarTagValueNode->type = $newPHPStanPhpDocType; } else { // add completely new one - $varTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode($newPHPStanPhpDocType, '', ''); + $varTagValueNode = new VarTagValueNode($newPHPStanPhpDocType, '', ''); $phpDocInfo->addTagValueNode($varTagValueNode); } } - public function changeReturnType(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PHPStan\Type\Type $newType) : bool + public function changeReturnType(PhpDocInfo $phpDocInfo, Type $newType) : bool { // better not touch this, can crash if ($phpDocInfo->hasInvalidTag('@return')) { @@ -115,25 +115,25 @@ final class PhpDocTypeChanger return \false; } // override existing type - $newPHPStanPhpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN); + $newPHPStanPhpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, TypeKind::RETURN); $currentReturnTagValueNode = $phpDocInfo->getReturnTagValue(); if ($currentReturnTagValueNode !== null) { // only change type $currentReturnTagValueNode->type = $newPHPStanPhpDocType; } else { // add completely new one - $returnTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode($newPHPStanPhpDocType, ''); + $returnTagValueNode = new ReturnTagValueNode($newPHPStanPhpDocType, ''); $phpDocInfo->addTagValueNode($returnTagValueNode); } return \true; } - public function changeParamType(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PHPStan\Type\Type $newType, \PhpParser\Node\Param $param, string $paramName) : void + public function changeParamType(PhpDocInfo $phpDocInfo, Type $newType, Param $param, string $paramName) : void { // better skip, could crash hard if ($phpDocInfo->hasInvalidTag('@param')) { return; } - $phpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM); + $phpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, TypeKind::PARAM); $paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramName); // override existing type if ($paramTagValueNode !== null) { @@ -152,9 +152,9 @@ final class PhpDocTypeChanger $phpDocInfo->addTagValueNode($paramTagValueNode); } } - public function isAllowed(\PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode) : bool + public function isAllowed(TypeNode $typeNode) : bool { - if ($typeNode instanceof \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode) { + if ($typeNode instanceof BracketsAwareUnionTypeNode) { foreach ($typeNode->types as $type) { if ($this->isAllowed($type)) { return \true; @@ -164,28 +164,28 @@ final class PhpDocTypeChanger if (\in_array(\get_class($typeNode), self::ALLOWED_TYPES, \true)) { return \true; } - if (!$typeNode instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode) { + if (!$typeNode instanceof IdentifierTypeNode) { return \false; } return \in_array((string) $typeNode, self::ALLOWED_IDENTIFIER_TYPENODE_TYPES, \true); } - public function copyPropertyDocToParam(\PhpParser\Node\Stmt\Property $property, \PhpParser\Node\Param $param) : void + public function copyPropertyDocToParam(Property $property, Param $param) : void { $phpDocInfo = $this->phpDocInfoFactory->createFromNode($property); - if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$phpDocInfo instanceof PhpDocInfo) { return; } $varTag = $phpDocInfo->getVarTagValueNode(); - if (!$varTag instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) { + if (!$varTag instanceof VarTagValueNode) { $this->processKeepComments($property, $param); return; } if ($varTag->description !== '') { return; } - $functionLike = $param->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $functionLike = $param->getAttribute(AttributeKey::PARENT_NODE); $paramVarName = $this->nodeNameResolver->getName($param->var); - if (!$functionLike instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$functionLike instanceof ClassMethod) { return; } if (!$this->isAllowed($varTag->type)) { @@ -194,36 +194,36 @@ final class PhpDocTypeChanger if (!\is_string($paramVarName)) { return; } - $phpDocInfo->removeByType(\PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode::class); - $param->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $phpDocInfo); - $phpDocInfo = $functionLike->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO); + $phpDocInfo->removeByType(VarTagValueNode::class); + $param->setAttribute(AttributeKey::PHP_DOC_INFO, $phpDocInfo); + $phpDocInfo = $functionLike->getAttribute(AttributeKey::PHP_DOC_INFO); $paramType = $this->staticTypeMapper->mapPHPStanPhpDocTypeToPHPStanType($varTag, $property); $this->changeParamType($phpDocInfo, $paramType, $param, $paramVarName); $this->processKeepComments($property, $param); } - public function changeVarTypeNode(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode) : void + public function changeVarTypeNode(PhpDocInfo $phpDocInfo, TypeNode $typeNode) : void { // add completely new one - $varTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode($typeNode, '', ''); + $varTagValueNode = new VarTagValueNode($typeNode, '', ''); $phpDocInfo->addTagValueNode($varTagValueNode); } - private function processKeepComments(\PhpParser\Node\Stmt\Property $property, \PhpParser\Node\Param $param) : void + private function processKeepComments(Property $property, Param $param) : void { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($param); $varTag = $phpDocInfo->getVarTagValueNode(); - $toBeRemoved = !$varTag instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode; + $toBeRemoved = !$varTag instanceof VarTagValueNode; $this->commentsMerger->keepComments($param, [$property]); $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($param); $varTag = $phpDocInfo->getVarTagValueNode(); if (!$toBeRemoved) { return; } - if (!$varTag instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) { + if (!$varTag instanceof VarTagValueNode) { return; } if ($varTag->description !== '') { return; } - $phpDocInfo->removeByType(\PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode::class); + $phpDocInfo->removeByType(VarTagValueNode::class); } } diff --git a/packages/BetterPhpDocParser/PhpDocManipulator/PropertyDocBlockManipulator.php b/packages/BetterPhpDocParser/PhpDocManipulator/PropertyDocBlockManipulator.php index 49962e09b2d..c4fb3b53ad2 100644 --- a/packages/BetterPhpDocParser/PhpDocManipulator/PropertyDocBlockManipulator.php +++ b/packages/BetterPhpDocParser/PhpDocManipulator/PropertyDocBlockManipulator.php @@ -15,22 +15,22 @@ final class PropertyDocBlockManipulator * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory */ private $phpDocInfoFactory; - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory) { $this->phpDocInfoFactory = $phpDocInfoFactory; } /** * @param ParamRename $renameValueObject */ - public function renameParameterNameInDocBlock(\Rector\Naming\Contract\RenameValueObjectInterface $renameValueObject) : void + public function renameParameterNameInDocBlock(RenameValueObjectInterface $renameValueObject) : void { $functionLike = $renameValueObject->getFunctionLike(); $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike); $paramTagValueNode = $phpDocInfo->getParamTagValueNodeByName($renameValueObject->getCurrentName()); - if (!$paramTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode) { + if (!$paramTagValueNode instanceof ParamTagValueNode) { return; } $paramTagValueNode->parameterName = '$' . $renameValueObject->getExpectedName(); - $paramTagValueNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE, null); + $paramTagValueNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null); } } diff --git a/packages/BetterPhpDocParser/PhpDocManipulator/VarAnnotationManipulator.php b/packages/BetterPhpDocParser/PhpDocManipulator/VarAnnotationManipulator.php index 05e21c1d3d7..2b0bf17bbaf 100644 --- a/packages/BetterPhpDocParser/PhpDocManipulator/VarAnnotationManipulator.php +++ b/packages/BetterPhpDocParser/PhpDocManipulator/VarAnnotationManipulator.php @@ -30,36 +30,36 @@ final class VarAnnotationManipulator * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, BetterNodeFinder $betterNodeFinder) { $this->phpDocInfoFactory = $phpDocInfoFactory; $this->phpDocTypeChanger = $phpDocTypeChanger; $this->betterNodeFinder = $betterNodeFinder; } - public function decorateNodeWithInlineVarType(\PhpParser\Node $node, \PHPStan\Type\TypeWithClassName $typeWithClassName, string $variableName) : void + public function decorateNodeWithInlineVarType(Node $node, TypeWithClassName $typeWithClassName, string $variableName) : void { $phpDocInfo = $this->resolvePhpDocInfo($node); // already done if ($phpDocInfo->getVarTagValueNode() !== null) { return; } - $fullyQualifiedIdentifierTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\FullyQualifiedIdentifierTypeNode($typeWithClassName->getClassName()); - $varTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode($fullyQualifiedIdentifierTypeNode, '$' . $variableName, ''); + $fullyQualifiedIdentifierTypeNode = new FullyQualifiedIdentifierTypeNode($typeWithClassName->getClassName()); + $varTagValueNode = new VarTagValueNode($fullyQualifiedIdentifierTypeNode, '$' . $variableName, ''); $phpDocInfo->addTagValueNode($varTagValueNode); $phpDocInfo->makeSingleLined(); } - public function decorateNodeWithType(\PhpParser\Node $node, \PHPStan\Type\Type $staticType) : void + public function decorateNodeWithType(Node $node, Type $staticType) : void { - if ($staticType instanceof \PHPStan\Type\MixedType) { + if ($staticType instanceof MixedType) { return; } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $this->phpDocTypeChanger->changeVarType($phpDocInfo, $staticType); } - private function resolvePhpDocInfo(\PhpParser\Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo + private function resolvePhpDocInfo(Node $node) : PhpDocInfo { $currentStmt = $this->betterNodeFinder->resolveCurrentStatement($node); - if ($currentStmt instanceof \PhpParser\Node\Stmt\Expression) { + if ($currentStmt instanceof Expression) { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($currentStmt); } else { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); diff --git a/packages/BetterPhpDocParser/PhpDocNodeFinder/PhpDocNodeByTypeFinder.php b/packages/BetterPhpDocParser/PhpDocNodeFinder/PhpDocNodeByTypeFinder.php index 5b940d47b3a..6a1e14d3e12 100644 --- a/packages/BetterPhpDocParser/PhpDocNodeFinder/PhpDocNodeByTypeFinder.php +++ b/packages/BetterPhpDocParser/PhpDocNodeFinder/PhpDocNodeByTypeFinder.php @@ -16,9 +16,9 @@ final class PhpDocNodeByTypeFinder * @param class-string $desiredType * @return array */ - public function findByType(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, string $desiredType) : array + public function findByType(PhpDocNode $phpDocNode, string $desiredType) : array { - $phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser(); + $phpDocNodeTraverser = new PhpDocNodeTraverser(); $foundNodes = []; $phpDocNodeTraverser->traverseWithCallable($phpDocNode, '', function ($node) use(&$foundNodes, $desiredType) : Node { if (!\is_a($node, $desiredType, \true)) { @@ -34,7 +34,7 @@ final class PhpDocNodeByTypeFinder * @param class-string[] $classes * @return DoctrineAnnotationTagValueNode[] */ - public function findDoctrineAnnotationsByClasses(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, array $classes) : array + public function findDoctrineAnnotationsByClasses(PhpDocNode $phpDocNode, array $classes) : array { $doctrineAnnotationTagValueNodes = []; foreach ($classes as $class) { @@ -47,11 +47,11 @@ final class PhpDocNodeByTypeFinder * @param class-string $desiredClass * @return DoctrineAnnotationTagValueNode[] */ - public function findDoctrineAnnotationsByClass(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, string $desiredClass) : array + public function findDoctrineAnnotationsByClass(PhpDocNode $phpDocNode, string $desiredClass) : array { $desiredDoctrineTagValueNodes = []; /** @var DoctrineAnnotationTagValueNode[] $doctrineTagValueNodes */ - $doctrineTagValueNodes = $this->findByType($phpDocNode, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode::class); + $doctrineTagValueNodes = $this->findByType($phpDocNode, DoctrineAnnotationTagValueNode::class); foreach ($doctrineTagValueNodes as $doctrineTagValueNode) { if ($doctrineTagValueNode->hasClassName($desiredClass)) { $desiredDoctrineTagValueNodes[] = $doctrineTagValueNode; diff --git a/packages/BetterPhpDocParser/PhpDocNodeMapper.php b/packages/BetterPhpDocParser/PhpDocNodeMapper.php index 895efca2a76..ac1ac41eb3e 100644 --- a/packages/BetterPhpDocParser/PhpDocNodeMapper.php +++ b/packages/BetterPhpDocParser/PhpDocNodeMapper.php @@ -38,23 +38,23 @@ final class PhpDocNodeMapper /** * @param BasePhpDocNodeVisitorInterface[] $phpDocNodeVisitors */ - public function __construct(\Rector\BetterPhpDocParser\DataProvider\CurrentTokenIteratorProvider $currentTokenIteratorProvider, \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\ParentConnectingPhpDocNodeVisitor $parentConnectingPhpDocNodeVisitor, \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\CloningPhpDocNodeVisitor $cloningPhpDocNodeVisitor, array $phpDocNodeVisitors) + public function __construct(CurrentTokenIteratorProvider $currentTokenIteratorProvider, ParentConnectingPhpDocNodeVisitor $parentConnectingPhpDocNodeVisitor, CloningPhpDocNodeVisitor $cloningPhpDocNodeVisitor, array $phpDocNodeVisitors) { $this->currentTokenIteratorProvider = $currentTokenIteratorProvider; $this->parentConnectingPhpDocNodeVisitor = $parentConnectingPhpDocNodeVisitor; $this->cloningPhpDocNodeVisitor = $cloningPhpDocNodeVisitor; $this->phpDocNodeVisitors = $phpDocNodeVisitors; } - public function transform(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator) : void + public function transform(PhpDocNode $phpDocNode, BetterTokenIterator $betterTokenIterator) : void { $this->currentTokenIteratorProvider->setBetterTokenIterator($betterTokenIterator); - $parentPhpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser(); + $parentPhpDocNodeTraverser = new PhpDocNodeTraverser(); $parentPhpDocNodeTraverser->addPhpDocNodeVisitor($this->parentConnectingPhpDocNodeVisitor); $parentPhpDocNodeTraverser->traverse($phpDocNode); - $cloningPhpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser(); + $cloningPhpDocNodeTraverser = new PhpDocNodeTraverser(); $cloningPhpDocNodeTraverser->addPhpDocNodeVisitor($this->cloningPhpDocNodeVisitor); $cloningPhpDocNodeTraverser->traverse($phpDocNode); - $phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser(); + $phpDocNodeTraverser = new PhpDocNodeTraverser(); foreach ($this->phpDocNodeVisitors as $phpDocNodeVisitor) { $phpDocNodeTraverser->addPhpDocNodeVisitor($phpDocNodeVisitor); } diff --git a/packages/BetterPhpDocParser/PhpDocNodeVisitor/ArrayTypePhpDocNodeVisitor.php b/packages/BetterPhpDocParser/PhpDocNodeVisitor/ArrayTypePhpDocNodeVisitor.php index ceb1737af5e..7aeb802f67e 100644 --- a/packages/BetterPhpDocParser/PhpDocNodeVisitor/ArrayTypePhpDocNodeVisitor.php +++ b/packages/BetterPhpDocParser/PhpDocNodeVisitor/ArrayTypePhpDocNodeVisitor.php @@ -9,26 +9,26 @@ use Rector\BetterPhpDocParser\Attributes\AttributeMirrorer; use Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface; use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode; use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor; -final class ArrayTypePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor implements \Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface +final class ArrayTypePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor implements BasePhpDocNodeVisitorInterface { /** * @readonly * @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer */ private $attributeMirrorer; - public function __construct(\Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer) + public function __construct(AttributeMirrorer $attributeMirrorer) { $this->attributeMirrorer = $attributeMirrorer; } - public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node + public function enterNode(Node $node) : ?Node { - if (!$node instanceof \PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode) { + if (!$node instanceof ArrayTypeNode) { return null; } - if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode) { + if ($node instanceof SpacingAwareArrayTypeNode) { return null; } - $spacingAwareArrayTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode($node->type); + $spacingAwareArrayTypeNode = new SpacingAwareArrayTypeNode($node->type); $this->attributeMirrorer->mirror($node, $spacingAwareArrayTypeNode); return $spacingAwareArrayTypeNode; } diff --git a/packages/BetterPhpDocParser/PhpDocNodeVisitor/CallableTypePhpDocNodeVisitor.php b/packages/BetterPhpDocParser/PhpDocNodeVisitor/CallableTypePhpDocNodeVisitor.php index 845a7bd595a..26940bad9a4 100644 --- a/packages/BetterPhpDocParser/PhpDocNodeVisitor/CallableTypePhpDocNodeVisitor.php +++ b/packages/BetterPhpDocParser/PhpDocNodeVisitor/CallableTypePhpDocNodeVisitor.php @@ -9,26 +9,26 @@ use Rector\BetterPhpDocParser\Attributes\AttributeMirrorer; use Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface; use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode; use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor; -final class CallableTypePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor implements \Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface +final class CallableTypePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor implements BasePhpDocNodeVisitorInterface { /** * @readonly * @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer */ private $attributeMirrorer; - public function __construct(\Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer) + public function __construct(AttributeMirrorer $attributeMirrorer) { $this->attributeMirrorer = $attributeMirrorer; } - public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node + public function enterNode(Node $node) : ?Node { - if (!$node instanceof \PHPStan\PhpDocParser\Ast\Type\CallableTypeNode) { + if (!$node instanceof CallableTypeNode) { return null; } - if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode) { + if ($node instanceof SpacingAwareCallableTypeNode) { return null; } - $spacingAwareCallableTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode($node->identifier, $node->parameters, $node->returnType); + $spacingAwareCallableTypeNode = new SpacingAwareCallableTypeNode($node->identifier, $node->parameters, $node->returnType); $this->attributeMirrorer->mirror($node, $spacingAwareCallableTypeNode); return $spacingAwareCallableTypeNode; } diff --git a/packages/BetterPhpDocParser/PhpDocNodeVisitor/ChangedPhpDocNodeVisitor.php b/packages/BetterPhpDocParser/PhpDocNodeVisitor/ChangedPhpDocNodeVisitor.php index 8b0878b0123..ecd55ff3688 100644 --- a/packages/BetterPhpDocParser/PhpDocNodeVisitor/ChangedPhpDocNodeVisitor.php +++ b/packages/BetterPhpDocParser/PhpDocNodeVisitor/ChangedPhpDocNodeVisitor.php @@ -6,19 +6,19 @@ namespace Rector\BetterPhpDocParser\PhpDocNodeVisitor; use PHPStan\PhpDocParser\Ast\Node; use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey; use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor; -final class ChangedPhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor +final class ChangedPhpDocNodeVisitor extends AbstractPhpDocNodeVisitor { /** * @var bool */ private $hasChanged = \false; - public function beforeTraverse(\PHPStan\PhpDocParser\Ast\Node $node) : void + public function beforeTraverse(Node $node) : void { $this->hasChanged = \false; } - public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node + public function enterNode(Node $node) : ?Node { - $origNode = $node->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE); + $origNode = $node->getAttribute(PhpDocAttributeKey::ORIG_NODE); if ($origNode === null) { $this->hasChanged = \true; } diff --git a/packages/BetterPhpDocParser/PhpDocNodeVisitor/IntersectionTypeNodePhpDocNodeVisitor.php b/packages/BetterPhpDocParser/PhpDocNodeVisitor/IntersectionTypeNodePhpDocNodeVisitor.php index 2892da7afb2..ddfdc218f7e 100644 --- a/packages/BetterPhpDocParser/PhpDocNodeVisitor/IntersectionTypeNodePhpDocNodeVisitor.php +++ b/packages/BetterPhpDocParser/PhpDocNodeVisitor/IntersectionTypeNodePhpDocNodeVisitor.php @@ -9,26 +9,26 @@ use Rector\BetterPhpDocParser\Attributes\AttributeMirrorer; use Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface; use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareIntersectionTypeNode; use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor; -final class IntersectionTypeNodePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor implements \Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface +final class IntersectionTypeNodePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor implements BasePhpDocNodeVisitorInterface { /** * @readonly * @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer */ private $attributeMirrorer; - public function __construct(\Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer) + public function __construct(AttributeMirrorer $attributeMirrorer) { $this->attributeMirrorer = $attributeMirrorer; } - public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node + public function enterNode(Node $node) : ?Node { - if (!$node instanceof \PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode) { + if (!$node instanceof IntersectionTypeNode) { return null; } - if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareIntersectionTypeNode) { + if ($node instanceof BracketsAwareIntersectionTypeNode) { return null; } - $bracketsAwareIntersectionTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareIntersectionTypeNode($node->types); + $bracketsAwareIntersectionTypeNode = new BracketsAwareIntersectionTypeNode($node->types); $this->attributeMirrorer->mirror($node, $bracketsAwareIntersectionTypeNode); return $bracketsAwareIntersectionTypeNode; } diff --git a/packages/BetterPhpDocParser/PhpDocNodeVisitor/TemplatePhpDocNodeVisitor.php b/packages/BetterPhpDocParser/PhpDocNodeVisitor/TemplatePhpDocNodeVisitor.php index 3c8b2051e3f..4d57a50e11a 100644 --- a/packages/BetterPhpDocParser/PhpDocNodeVisitor/TemplatePhpDocNodeVisitor.php +++ b/packages/BetterPhpDocParser/PhpDocNodeVisitor/TemplatePhpDocNodeVisitor.php @@ -15,7 +15,7 @@ use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey; use Rector\BetterPhpDocParser\ValueObject\StartAndEnd; use Rector\Core\Exception\ShouldNotHappenException; use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor; -final class TemplatePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor implements \Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface +final class TemplatePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor implements BasePhpDocNodeVisitorInterface { /** * @readonly @@ -27,34 +27,34 @@ final class TemplatePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Ast * @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer */ private $attributeMirrorer; - public function __construct(\Rector\BetterPhpDocParser\DataProvider\CurrentTokenIteratorProvider $currentTokenIteratorProvider, \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer) + public function __construct(CurrentTokenIteratorProvider $currentTokenIteratorProvider, AttributeMirrorer $attributeMirrorer) { $this->currentTokenIteratorProvider = $currentTokenIteratorProvider; $this->attributeMirrorer = $attributeMirrorer; } - public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node + public function enterNode(Node $node) : ?Node { - if (!$node instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode) { + if (!$node instanceof TemplateTagValueNode) { return null; } - if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\PhpDoc\SpacingAwareTemplateTagValueNode) { + if ($node instanceof SpacingAwareTemplateTagValueNode) { return null; } $betterTokenIterator = $this->currentTokenIteratorProvider->provide(); - $startAndEnd = $node->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END); - if (!$startAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $startAndEnd = $node->getAttribute(PhpDocAttributeKey::START_AND_END); + if (!$startAndEnd instanceof StartAndEnd) { + throw new ShouldNotHappenException(); } $prepositions = $this->resolvePreposition($betterTokenIterator, $startAndEnd); - $spacingAwareTemplateTagValueNode = new \Rector\BetterPhpDocParser\ValueObject\PhpDoc\SpacingAwareTemplateTagValueNode($node->name, $node->bound, $node->description, $prepositions); + $spacingAwareTemplateTagValueNode = new SpacingAwareTemplateTagValueNode($node->name, $node->bound, $node->description, $prepositions); $this->attributeMirrorer->mirror($node, $spacingAwareTemplateTagValueNode); return $spacingAwareTemplateTagValueNode; } - private function resolvePreposition(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator, \Rector\BetterPhpDocParser\ValueObject\StartAndEnd $startAndEnd) : string + private function resolvePreposition(BetterTokenIterator $betterTokenIterator, StartAndEnd $startAndEnd) : string { $partialTokens = $betterTokenIterator->partialTokens($startAndEnd->getStart(), $startAndEnd->getEnd()); foreach ($partialTokens as $partialToken) { - if ($partialToken[1] !== \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER) { + if ($partialToken[1] !== Lexer::TOKEN_IDENTIFIER) { continue; } if (!\in_array($partialToken[0], ['as', 'of'], \true)) { diff --git a/packages/BetterPhpDocParser/PhpDocNodeVisitor/UnionTypeNodePhpDocNodeVisitor.php b/packages/BetterPhpDocParser/PhpDocNodeVisitor/UnionTypeNodePhpDocNodeVisitor.php index 0b3dfb2c31c..fca82e2d745 100644 --- a/packages/BetterPhpDocParser/PhpDocNodeVisitor/UnionTypeNodePhpDocNodeVisitor.php +++ b/packages/BetterPhpDocParser/PhpDocNodeVisitor/UnionTypeNodePhpDocNodeVisitor.php @@ -14,7 +14,7 @@ use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey; use Rector\BetterPhpDocParser\ValueObject\StartAndEnd; use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode; use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor; -final class UnionTypeNodePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor implements \Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface +final class UnionTypeNodePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor implements BasePhpDocNodeVisitorInterface { /** * @readonly @@ -26,49 +26,49 @@ final class UnionTypeNodePhpDocNodeVisitor extends \RectorPrefix20220607\Symplif * @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer */ private $attributeMirrorer; - public function __construct(\Rector\BetterPhpDocParser\DataProvider\CurrentTokenIteratorProvider $currentTokenIteratorProvider, \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer) + public function __construct(CurrentTokenIteratorProvider $currentTokenIteratorProvider, AttributeMirrorer $attributeMirrorer) { $this->currentTokenIteratorProvider = $currentTokenIteratorProvider; $this->attributeMirrorer = $attributeMirrorer; } - public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node + public function enterNode(Node $node) : ?Node { - if (!$node instanceof \PHPStan\PhpDocParser\Ast\Type\UnionTypeNode) { + if (!$node instanceof UnionTypeNode) { return null; } - if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode) { + if ($node instanceof BracketsAwareUnionTypeNode) { return null; } $startAndEnd = $this->resolveStardAndEnd($node); - if (!$startAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) { + if (!$startAndEnd instanceof StartAndEnd) { return null; } $betterTokenProvider = $this->currentTokenIteratorProvider->provide(); $isWrappedInCurlyBrackets = $this->isWrappedInCurlyBrackets($betterTokenProvider, $startAndEnd); - $bracketsAwareUnionTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode($node->types, $isWrappedInCurlyBrackets); + $bracketsAwareUnionTypeNode = new BracketsAwareUnionTypeNode($node->types, $isWrappedInCurlyBrackets); $this->attributeMirrorer->mirror($node, $bracketsAwareUnionTypeNode); return $bracketsAwareUnionTypeNode; } - private function isWrappedInCurlyBrackets(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenProvider, \Rector\BetterPhpDocParser\ValueObject\StartAndEnd $startAndEnd) : bool + private function isWrappedInCurlyBrackets(BetterTokenIterator $betterTokenProvider, StartAndEnd $startAndEnd) : bool { $previousPosition = $startAndEnd->getStart() - 1; - if ($betterTokenProvider->isTokenTypeOnPosition(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES, $previousPosition)) { + if ($betterTokenProvider->isTokenTypeOnPosition(Lexer::TOKEN_OPEN_PARENTHESES, $previousPosition)) { return \true; } // there is no + 1, as end is right at the next token - return $betterTokenProvider->isTokenTypeOnPosition(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES, $startAndEnd->getEnd()); + return $betterTokenProvider->isTokenTypeOnPosition(Lexer::TOKEN_CLOSE_PARENTHESES, $startAndEnd->getEnd()); } - private function resolveStardAndEnd(\PHPStan\PhpDocParser\Ast\Type\UnionTypeNode $unionTypeNode) : ?\Rector\BetterPhpDocParser\ValueObject\StartAndEnd + private function resolveStardAndEnd(UnionTypeNode $unionTypeNode) : ?StartAndEnd { - $starAndEnd = $unionTypeNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END); - if ($starAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) { + $starAndEnd = $unionTypeNode->getAttribute(PhpDocAttributeKey::START_AND_END); + if ($starAndEnd instanceof StartAndEnd) { return $starAndEnd; } // unwrap with parent array type... - $parent = $unionTypeNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::PARENT); - if (!$parent instanceof \PHPStan\PhpDocParser\Ast\Node) { + $parent = $unionTypeNode->getAttribute(PhpDocAttributeKey::PARENT); + if (!$parent instanceof Node) { return null; } - return $parent->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END); + return $parent->getAttribute(PhpDocAttributeKey::START_AND_END); } } diff --git a/packages/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php b/packages/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php index 5995f7aa54b..1adad1a8aeb 100644 --- a/packages/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php +++ b/packages/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php @@ -25,7 +25,7 @@ use RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller; /** * @see \Rector\Tests\BetterPhpDocParser\PhpDocParser\TagValueNodeReprint\TagValueNodeReprintTest */ -final class BetterPhpDocParser extends \PHPStan\PhpDocParser\Parser\PhpDocParser +final class BetterPhpDocParser extends PhpDocParser { /** * @readonly @@ -50,76 +50,76 @@ final class BetterPhpDocParser extends \PHPStan\PhpDocParser\Parser\PhpDocParser /** * @param PhpDocNodeDecoratorInterface[] $phpDocNodeDecorators */ - public function __construct(\PHPStan\PhpDocParser\Parser\TypeParser $typeParser, \PHPStan\PhpDocParser\Parser\ConstExprParser $constExprParser, \Rector\Core\Configuration\CurrentNodeProvider $currentNodeProvider, \Rector\BetterPhpDocParser\PhpDocInfo\TokenIteratorFactory $tokenIteratorFactory, array $phpDocNodeDecorators, \RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller $privatesCaller = null) + public function __construct(TypeParser $typeParser, ConstExprParser $constExprParser, CurrentNodeProvider $currentNodeProvider, TokenIteratorFactory $tokenIteratorFactory, array $phpDocNodeDecorators, PrivatesCaller $privatesCaller = null) { - $privatesCaller = $privatesCaller ?? new \RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller(); + $privatesCaller = $privatesCaller ?? new PrivatesCaller(); $this->currentNodeProvider = $currentNodeProvider; $this->tokenIteratorFactory = $tokenIteratorFactory; $this->phpDocNodeDecorators = $phpDocNodeDecorators; $this->privatesCaller = $privatesCaller; parent::__construct($typeParser, $constExprParser); } - public function parse(\PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator) : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode + public function parse(TokenIterator $tokenIterator) : PhpDocNode { - $tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PHPDOC); - $tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + $tokenIterator->consumeTokenType(Lexer::TOKEN_OPEN_PHPDOC); + $tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); $children = []; - if (!$tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PHPDOC)) { + if (!$tokenIterator->isCurrentTokenType(Lexer::TOKEN_CLOSE_PHPDOC)) { $children[] = $this->parseChildAndStoreItsPositions($tokenIterator); - while ($tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL) && !$tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PHPDOC)) { + while ($tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL) && !$tokenIterator->isCurrentTokenType(Lexer::TOKEN_CLOSE_PHPDOC)) { $children[] = $this->parseChildAndStoreItsPositions($tokenIterator); } } // might be in the middle of annotations - $tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PHPDOC); - $phpDocNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode($children); + $tokenIterator->tryConsumeTokenType(Lexer::TOKEN_CLOSE_PHPDOC); + $phpDocNode = new PhpDocNode($children); // decorate FQN classes etc. $node = $this->currentNodeProvider->getNode(); - if (!$node instanceof \PhpParser\Node) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$node instanceof Node) { + throw new ShouldNotHappenException(); } foreach ($this->phpDocNodeDecorators as $phpDocNodeDecorator) { $phpDocNodeDecorator->decorate($phpDocNode, $node); } return $phpDocNode; } - public function parseTag(\PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator) : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode + public function parseTag(TokenIterator $tokenIterator) : PhpDocTagNode { // replace generic nodes with DoctrineAnnotations - if (!$tokenIterator instanceof \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$tokenIterator instanceof BetterTokenIterator) { + throw new ShouldNotHappenException(); } $tag = $this->resolveTag($tokenIterator); $phpDocTagValueNode = $this->parseTagValue($tokenIterator, $tag); - return new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode($tag, $phpDocTagValueNode); + return new PhpDocTagNode($tag, $phpDocTagValueNode); } /** * @param BetterTokenIterator $tokenIterator */ - public function parseTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator, string $tag) : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode + public function parseTagValue(TokenIterator $tokenIterator, string $tag) : PhpDocTagValueNode { $startPosition = $tokenIterator->currentPosition(); $tagValueNode = parent::parseTagValue($tokenIterator, $tag); $endPosition = $tokenIterator->currentPosition(); - $startAndEnd = new \Rector\BetterPhpDocParser\ValueObject\StartAndEnd($startPosition, $endPosition); - $tagValueNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $startAndEnd); + $startAndEnd = new StartAndEnd($startPosition, $endPosition); + $tagValueNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd); return $tagValueNode; } /** * @return PhpDocTextNode|PhpDocTagNode */ - private function parseChildAndStoreItsPositions(\PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator) : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode + private function parseChildAndStoreItsPositions(TokenIterator $tokenIterator) : PhpDocChildNode { $betterTokenIterator = $this->tokenIteratorFactory->createFromTokenIterator($tokenIterator); $startPosition = $betterTokenIterator->currentPosition(); /** @var PhpDocChildNode $phpDocNode */ $phpDocNode = $this->privatesCaller->callPrivateMethod($this, 'parseChild', [$betterTokenIterator]); $endPosition = $betterTokenIterator->currentPosition(); - $startAndEnd = new \Rector\BetterPhpDocParser\ValueObject\StartAndEnd($startPosition, $endPosition); - $phpDocNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $startAndEnd); + $startAndEnd = new StartAndEnd($startPosition, $endPosition); + $phpDocNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd); return $phpDocNode; } - private function resolveTag(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) : string + private function resolveTag(BetterTokenIterator $tokenIterator) : string { $tag = $tokenIterator->currentTokenValue(); $tokenIterator->next(); @@ -129,7 +129,7 @@ final class BetterPhpDocParser extends \PHPStan\PhpDocParser\Parser\PhpDocParser } // is not e.g "@var " // join tags like "@ORM\Column" etc. - if (!$tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER)) { + if (!$tokenIterator->isCurrentTokenType(Lexer::TOKEN_IDENTIFIER)) { return $tag; } // @todo use joinUntil("(")? diff --git a/packages/BetterPhpDocParser/PhpDocParser/BetterTypeParser.php b/packages/BetterPhpDocParser/PhpDocParser/BetterTypeParser.php index 04d3f48335f..b6c0cdc71e0 100644 --- a/packages/BetterPhpDocParser/PhpDocParser/BetterTypeParser.php +++ b/packages/BetterPhpDocParser/PhpDocParser/BetterTypeParser.php @@ -10,26 +10,26 @@ use PHPStan\PhpDocParser\Parser\TypeParser; use Rector\BetterPhpDocParser\PhpDocInfo\TokenIteratorFactory; use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey; use Rector\BetterPhpDocParser\ValueObject\StartAndEnd; -final class BetterTypeParser extends \PHPStan\PhpDocParser\Parser\TypeParser +final class BetterTypeParser extends TypeParser { /** * @readonly * @var \Rector\BetterPhpDocParser\PhpDocInfo\TokenIteratorFactory */ private $tokenIteratorFactory; - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\TokenIteratorFactory $tokenIteratorFactory, ?\PHPStan\PhpDocParser\Parser\ConstExprParser $constExprParser = null) + public function __construct(TokenIteratorFactory $tokenIteratorFactory, ?ConstExprParser $constExprParser = null) { $this->tokenIteratorFactory = $tokenIteratorFactory; parent::__construct($constExprParser); } - public function parse(\PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function parse(TokenIterator $tokenIterator) : TypeNode { $betterTokenIterator = $this->tokenIteratorFactory->createFromTokenIterator($tokenIterator); $startPosition = $betterTokenIterator->currentPosition(); $typeNode = parent::parse($betterTokenIterator); $endPosition = $betterTokenIterator->currentPosition(); - $startAndEnd = new \Rector\BetterPhpDocParser\ValueObject\StartAndEnd($startPosition, $endPosition); - $typeNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $startAndEnd); + $startAndEnd = new StartAndEnd($startPosition, $endPosition); + $typeNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd); return $typeNode; } } diff --git a/packages/BetterPhpDocParser/PhpDocParser/ClassAnnotationMatcher.php b/packages/BetterPhpDocParser/PhpDocParser/ClassAnnotationMatcher.php index 567eccd81e9..d9ab3e4b6d5 100644 --- a/packages/BetterPhpDocParser/PhpDocParser/ClassAnnotationMatcher.php +++ b/packages/BetterPhpDocParser/PhpDocParser/ClassAnnotationMatcher.php @@ -36,21 +36,21 @@ final class ClassAnnotationMatcher * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\CodingStyle\NodeAnalyzer\UseImportNameMatcher $useImportNameMatcher, \Rector\Naming\Naming\UseImportsResolver $useImportsResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(UseImportNameMatcher $useImportNameMatcher, UseImportsResolver $useImportsResolver, ReflectionProvider $reflectionProvider) { $this->useImportNameMatcher = $useImportNameMatcher; $this->useImportsResolver = $useImportsResolver; $this->reflectionProvider = $reflectionProvider; } - public function resolveTagToKnownFullyQualifiedName(string $tag, \PhpParser\Node $node) : ?string + public function resolveTagToKnownFullyQualifiedName(string $tag, Node $node) : ?string { return $this->_resolveTagFullyQualifiedName($tag, $node, \true); } - public function resolveTagFullyQualifiedName(string $tag, \PhpParser\Node $node) : ?string + public function resolveTagFullyQualifiedName(string $tag, Node $node) : ?string { return $this->_resolveTagFullyQualifiedName($tag, $node, \false); } - private function _resolveTagFullyQualifiedName(string $tag, \PhpParser\Node $node, bool $returnNullOnUnknownClass) : ?string + private function _resolveTagFullyQualifiedName(string $tag, Node $node, bool $returnNullOnUnknownClass) : ?string { $uniqueHash = $tag . \spl_object_hash($node); if (isset($this->fullyQualifiedNameByHash[$uniqueHash])) { @@ -71,10 +71,10 @@ final class ClassAnnotationMatcher /** * @param Use_[]|GroupUse[] $uses */ - private function resolveFullyQualifiedClass(array $uses, \PhpParser\Node $node, string $tag, bool $returnNullOnUnknownClass) : ?string + private function resolveFullyQualifiedClass(array $uses, Node $node, string $tag, bool $returnNullOnUnknownClass) : ?string { - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if ($scope instanceof \PHPStan\Analyser\Scope) { + $scope = $node->getAttribute(AttributeKey::SCOPE); + if ($scope instanceof Scope) { $namespace = $scope->getNamespace(); if ($namespace !== null) { $namespacedTag = $namespace . '\\' . $tag; @@ -99,9 +99,9 @@ final class ClassAnnotationMatcher private function resolveAsAliased(array $uses, string $tag, bool $returnNullOnUnknownClass) : ?string { foreach ($uses as $use) { - $prefix = $use instanceof \PhpParser\Node\Stmt\GroupUse ? $use->prefix . '\\' : ''; + $prefix = $use instanceof GroupUse ? $use->prefix . '\\' : ''; foreach ($use->uses as $useUse) { - if (!$useUse->alias instanceof \PhpParser\Node\Identifier) { + if (!$useUse->alias instanceof Identifier) { continue; } if ($useUse->alias->toString() === $tag) { diff --git a/packages/BetterPhpDocParser/PhpDocParser/ConstExprClassNameDecorator.php b/packages/BetterPhpDocParser/PhpDocParser/ConstExprClassNameDecorator.php index 17ceac6ee0a..ea3d1ba5069 100644 --- a/packages/BetterPhpDocParser/PhpDocParser/ConstExprClassNameDecorator.php +++ b/packages/BetterPhpDocParser/PhpDocParser/ConstExprClassNameDecorator.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser; * Decorate node with fully qualified class name for const epxr, * e.g. Direction::* */ -final class ConstExprClassNameDecorator implements \Rector\BetterPhpDocParser\Contract\PhpDocParser\PhpDocNodeDecoratorInterface +final class ConstExprClassNameDecorator implements PhpDocNodeDecoratorInterface { /** * @readonly @@ -28,28 +28,28 @@ final class ConstExprClassNameDecorator implements \Rector\BetterPhpDocParser\Co * @var \Symplify\Astral\PhpDocParser\PhpDocNodeTraverser */ private $phpDocNodeTraverser; - public function __construct(\Rector\StaticTypeMapper\Naming\NameScopeFactory $nameScopeFactory, \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser $phpDocNodeTraverser) + public function __construct(NameScopeFactory $nameScopeFactory, PhpDocNodeTraverser $phpDocNodeTraverser) { $this->nameScopeFactory = $nameScopeFactory; $this->phpDocNodeTraverser = $phpDocNodeTraverser; } - public function decorate(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \PhpParser\Node $phpNode) : void + public function decorate(PhpDocNode $phpDocNode, PhpNode $phpNode) : void { - $this->phpDocNodeTraverser->traverseWithCallable($phpDocNode, '', function (\PHPStan\PhpDocParser\Ast\Node $node) use($phpNode) { - if (!$node instanceof \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode) { + $this->phpDocNodeTraverser->traverseWithCallable($phpDocNode, '', function (Node $node) use($phpNode) { + if (!$node instanceof ConstExprNode) { return null; } $className = $this->resolveFullyQualifiedClass($node, $phpNode); if ($className === null) { return null; } - $node->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::RESOLVED_CLASS, $className); + $node->setAttribute(PhpDocAttributeKey::RESOLVED_CLASS, $className); return $node; }); } - private function resolveFullyQualifiedClass(\PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode $constExprNode, \PhpParser\Node $phpNode) : ?string + private function resolveFullyQualifiedClass(ConstExprNode $constExprNode, PhpNode $phpNode) : ?string { - if (!$constExprNode instanceof \PHPStan\PhpDocParser\Ast\ConstExpr\ConstFetchNode) { + if (!$constExprNode instanceof ConstFetchNode) { return null; } $nameScope = $this->nameScopeFactory->createNameScopeFromNodeWithoutTemplateTypes($phpNode); diff --git a/packages/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php b/packages/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php index 8c2494e8317..849f8a63193 100644 --- a/packages/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php +++ b/packages/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php @@ -21,7 +21,7 @@ use Rector\BetterPhpDocParser\ValueObject\DoctrineAnnotation\SilentKeyMap; use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey; use Rector\BetterPhpDocParser\ValueObject\StartAndEnd; use Rector\Core\Util\StringUtils; -final class DoctrineAnnotationDecorator implements \Rector\BetterPhpDocParser\Contract\PhpDocParser\PhpDocNodeDecoratorInterface +final class DoctrineAnnotationDecorator implements PhpDocNodeDecoratorInterface { /** * Special short annotations, that are resolved as FQN by Doctrine annotation parser @@ -58,14 +58,14 @@ final class DoctrineAnnotationDecorator implements \Rector\BetterPhpDocParser\Co * @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer */ private $attributeMirrorer; - public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher $classAnnotationMatcher, \Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser $staticDoctrineAnnotationParser, \Rector\BetterPhpDocParser\PhpDocInfo\TokenIteratorFactory $tokenIteratorFactory, \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer) + public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher $classAnnotationMatcher, \Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser $staticDoctrineAnnotationParser, TokenIteratorFactory $tokenIteratorFactory, AttributeMirrorer $attributeMirrorer) { $this->classAnnotationMatcher = $classAnnotationMatcher; $this->staticDoctrineAnnotationParser = $staticDoctrineAnnotationParser; $this->tokenIteratorFactory = $tokenIteratorFactory; $this->attributeMirrorer = $attributeMirrorer; } - public function decorate(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \PhpParser\Node $phpNode) : void + public function decorate(PhpDocNode $phpDocNode, Node $phpNode) : void { // merge split doctrine nested tags $this->mergeNestedDoctrineAnnotations($phpDocNode); @@ -74,17 +74,17 @@ final class DoctrineAnnotationDecorator implements \Rector\BetterPhpDocParser\Co /** * Join token iterator with all the following nodes if nested */ - private function mergeNestedDoctrineAnnotations(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode) : void + private function mergeNestedDoctrineAnnotations(PhpDocNode $phpDocNode) : void { $removedKeys = []; foreach ($phpDocNode->children as $key => $phpDocChildNode) { if (\in_array($key, $removedKeys, \true)) { continue; } - if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) { + if (!$phpDocChildNode instanceof PhpDocTagNode) { continue; } - if (!$phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) { + if (!$phpDocChildNode->value instanceof GenericTagValueNode) { continue; } $genericTagValueNode = $phpDocChildNode->value; @@ -95,21 +95,21 @@ final class DoctrineAnnotationDecorator implements \Rector\BetterPhpDocParser\Co break; } $nextPhpDocChildNode = $phpDocNode->children[$key]; - if ($nextPhpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode && \Rector\Core\Util\StringUtils::isMatch($nextPhpDocChildNode->text, self::NESTED_ANNOTATION_END_REGEX)) { + if ($nextPhpDocChildNode instanceof PhpDocTextNode && StringUtils::isMatch($nextPhpDocChildNode->text, self::NESTED_ANNOTATION_END_REGEX)) { // @todo how to detect previously opened brackets? // probably local property with holding count of opened brackets $composedContent = $genericTagValueNode->value . \PHP_EOL . $nextPhpDocChildNode->text; $genericTagValueNode->value = $composedContent; $startAndEnd = $this->combineStartAndEnd($phpDocChildNode, $nextPhpDocChildNode); - $phpDocChildNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $startAndEnd); + $phpDocChildNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd); $removedKeys[] = $key; $removedKeys[] = $key + 1; continue; } - if (!$nextPhpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) { + if (!$nextPhpDocChildNode instanceof PhpDocTagNode) { continue; } - if (!$nextPhpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) { + if (!$nextPhpDocChildNode->value instanceof GenericTagValueNode) { continue; } if ($this->isClosedContent($genericTagValueNode->value)) { @@ -119,13 +119,13 @@ final class DoctrineAnnotationDecorator implements \Rector\BetterPhpDocParser\Co // cleanup the next from closing $genericTagValueNode->value = $composedContent; $startAndEnd = $this->combineStartAndEnd($phpDocChildNode, $nextPhpDocChildNode); - $phpDocChildNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $startAndEnd); + $phpDocChildNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd); $currentChildValueNode = $phpDocNode->children[$key]; - if (!$currentChildValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) { + if (!$currentChildValueNode instanceof PhpDocTagNode) { continue; } $currentGenericTagValueNode = $currentChildValueNode->value; - if (!$currentGenericTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) { + if (!$currentGenericTagValueNode instanceof GenericTagValueNode) { continue; } $removedKeys[] = $key; @@ -138,22 +138,22 @@ final class DoctrineAnnotationDecorator implements \Rector\BetterPhpDocParser\Co unset($phpDocNode->children[$key]); } } - private function transformGenericTagValueNodesToDoctrineAnnotationTagValueNodes(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \PhpParser\Node $currentPhpNode) : void + private function transformGenericTagValueNodesToDoctrineAnnotationTagValueNodes(PhpDocNode $phpDocNode, Node $currentPhpNode) : void { foreach ($phpDocNode->children as $key => $phpDocChildNode) { // the @\FQN use case - if ($phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode) { + if ($phpDocChildNode instanceof PhpDocTextNode) { $spacelessPhpDocTagNode = $this->resolveFqnAnnotationSpacelessPhpDocTagNode($phpDocChildNode); - if (!$spacelessPhpDocTagNode instanceof \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode) { + if (!$spacelessPhpDocTagNode instanceof SpacelessPhpDocTagNode) { continue; } $phpDocNode->children[$key] = $spacelessPhpDocTagNode; continue; } - if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) { + if (!$phpDocChildNode instanceof PhpDocTagNode) { continue; } - if (!$phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) { + if (!$phpDocChildNode->value instanceof GenericTagValueNode) { continue; } // known doc tag to annotation class @@ -181,51 +181,51 @@ final class DoctrineAnnotationDecorator implements \Rector\BetterPhpDocParser\Co return \true; } do { - if ($composedTokenIterator->isCurrentTokenTypes([\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_CURLY_BRACKET, \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES]) || \strpos($composedTokenIterator->currentTokenValue(), '(') !== \false) { + if ($composedTokenIterator->isCurrentTokenTypes([Lexer::TOKEN_OPEN_CURLY_BRACKET, Lexer::TOKEN_OPEN_PARENTHESES]) || \strpos($composedTokenIterator->currentTokenValue(), '(') !== \false) { ++$openBracketCount; } - if ($composedTokenIterator->isCurrentTokenTypes([\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_CURLY_BRACKET, \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES]) || \strpos($composedTokenIterator->currentTokenValue(), ')') !== \false) { + if ($composedTokenIterator->isCurrentTokenTypes([Lexer::TOKEN_CLOSE_CURLY_BRACKET, Lexer::TOKEN_CLOSE_PARENTHESES]) || \strpos($composedTokenIterator->currentTokenValue(), ')') !== \false) { ++$closeBracketCount; } $composedTokenIterator->next(); } while ($composedTokenIterator->currentPosition() < $tokenCount - 1); return $openBracketCount === $closeBracketCount; } - private function createSpacelessPhpDocTagNode(string $tagName, \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode $genericTagValueNode, string $fullyQualifiedAnnotationClass) : \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode + private function createSpacelessPhpDocTagNode(string $tagName, GenericTagValueNode $genericTagValueNode, string $fullyQualifiedAnnotationClass) : SpacelessPhpDocTagNode { - $formerStartEnd = $genericTagValueNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END); + $formerStartEnd = $genericTagValueNode->getAttribute(PhpDocAttributeKey::START_AND_END); return $this->createDoctrineSpacelessPhpDocTagNode($genericTagValueNode->value, $tagName, $fullyQualifiedAnnotationClass, $formerStartEnd); } - private function createDoctrineSpacelessPhpDocTagNode(string $annotationContent, string $tagName, string $fullyQualifiedAnnotationClass, \Rector\BetterPhpDocParser\ValueObject\StartAndEnd $startAndEnd) : \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode + private function createDoctrineSpacelessPhpDocTagNode(string $annotationContent, string $tagName, string $fullyQualifiedAnnotationClass, StartAndEnd $startAndEnd) : SpacelessPhpDocTagNode { $nestedTokenIterator = $this->tokenIteratorFactory->create($annotationContent); // mimics doctrine behavior just in phpdoc-parser syntax :) // https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L742 $values = $this->staticDoctrineAnnotationParser->resolveAnnotationMethodCall($nestedTokenIterator); - $identifierTypeNode = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($tagName); - $identifierTypeNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::RESOLVED_CLASS, $fullyQualifiedAnnotationClass); - $doctrineAnnotationTagValueNode = new \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode($identifierTypeNode, $annotationContent, $values, \Rector\BetterPhpDocParser\ValueObject\DoctrineAnnotation\SilentKeyMap::CLASS_NAMES_TO_SILENT_KEYS[$fullyQualifiedAnnotationClass] ?? null); - $doctrineAnnotationTagValueNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $startAndEnd); - return new \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode($tagName, $doctrineAnnotationTagValueNode); + $identifierTypeNode = new IdentifierTypeNode($tagName); + $identifierTypeNode->setAttribute(PhpDocAttributeKey::RESOLVED_CLASS, $fullyQualifiedAnnotationClass); + $doctrineAnnotationTagValueNode = new DoctrineAnnotationTagValueNode($identifierTypeNode, $annotationContent, $values, SilentKeyMap::CLASS_NAMES_TO_SILENT_KEYS[$fullyQualifiedAnnotationClass] ?? null); + $doctrineAnnotationTagValueNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd); + return new SpacelessPhpDocTagNode($tagName, $doctrineAnnotationTagValueNode); } - private function combineStartAndEnd(\PHPStan\PhpDocParser\Ast\Node $startPhpDocChildNode, \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $endPhpDocChildNode) : \Rector\BetterPhpDocParser\ValueObject\StartAndEnd + private function combineStartAndEnd(\PHPStan\PhpDocParser\Ast\Node $startPhpDocChildNode, PhpDocChildNode $endPhpDocChildNode) : StartAndEnd { /** @var StartAndEnd $currentStartAndEnd */ - $currentStartAndEnd = $startPhpDocChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END); + $currentStartAndEnd = $startPhpDocChildNode->getAttribute(PhpDocAttributeKey::START_AND_END); /** @var StartAndEnd $nextStartAndEnd */ - $nextStartAndEnd = $endPhpDocChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END); - return new \Rector\BetterPhpDocParser\ValueObject\StartAndEnd($currentStartAndEnd->getStart(), $nextStartAndEnd->getEnd()); + $nextStartAndEnd = $endPhpDocChildNode->getAttribute(PhpDocAttributeKey::START_AND_END); + return new StartAndEnd($currentStartAndEnd->getStart(), $nextStartAndEnd->getEnd()); } - private function resolveFqnAnnotationSpacelessPhpDocTagNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode $phpDocTextNode) : ?\Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode + private function resolveFqnAnnotationSpacelessPhpDocTagNode(PhpDocTextNode $phpDocTextNode) : ?SpacelessPhpDocTagNode { - $match = \RectorPrefix20220607\Nette\Utils\Strings::match($phpDocTextNode->text, self::LONG_ANNOTATION_REGEX); + $match = Strings::match($phpDocTextNode->text, self::LONG_ANNOTATION_REGEX); $fullyQualifiedAnnotationClass = $match['class_name'] ?? null; if ($fullyQualifiedAnnotationClass === null) { return null; } $annotationContent = $match['annotation_content'] ?? null; $tagName = '@\\' . $fullyQualifiedAnnotationClass; - $formerStartEnd = $phpDocTextNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END); + $formerStartEnd = $phpDocTextNode->getAttribute(PhpDocAttributeKey::START_AND_END); return $this->createDoctrineSpacelessPhpDocTagNode($annotationContent, $tagName, $fullyQualifiedAnnotationClass, $formerStartEnd); } } diff --git a/packages/BetterPhpDocParser/PhpDocParser/PhpDocFromTypeDeclarationDecorator.php b/packages/BetterPhpDocParser/PhpDocParser/PhpDocFromTypeDeclarationDecorator.php index 494b6038da4..f713010e8fb 100644 --- a/packages/BetterPhpDocParser/PhpDocParser/PhpDocFromTypeDeclarationDecorator.php +++ b/packages/BetterPhpDocParser/PhpDocParser/PhpDocFromTypeDeclarationDecorator.php @@ -25,7 +25,7 @@ use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer; use Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory; use Rector\PHPStanStaticTypeMapper\Utils\TypeUnwrapper; use Rector\StaticTypeMapper\StaticTypeMapper; -use RectorPrefix20220607\ReturnTypeWillChange; +use ReturnTypeWillChange; /** * @see https://wiki.php.net/rfc/internal_method_return_types#proposal */ @@ -79,7 +79,7 @@ final class PhpDocFromTypeDeclarationDecorator * @var \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer */ private $phpAttributeAnalyzer; - public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\PHPStanStaticTypeMapper\Utils\TypeUnwrapper $typeUnwrapper, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory $phpAttributeGroupFactory, \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer $phpAttributeAnalyzer) + public function __construct(StaticTypeMapper $staticTypeMapper, PhpDocInfoFactory $phpDocInfoFactory, NodeNameResolver $nodeNameResolver, PhpDocTypeChanger $phpDocTypeChanger, TypeUnwrapper $typeUnwrapper, BetterNodeFinder $betterNodeFinder, PhpAttributeGroupFactory $phpAttributeGroupFactory, PhpAttributeAnalyzer $phpAttributeAnalyzer) { $this->staticTypeMapper = $staticTypeMapper; $this->phpDocInfoFactory = $phpDocInfoFactory; @@ -102,11 +102,11 @@ final class PhpDocFromTypeDeclarationDecorator $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike); $this->phpDocTypeChanger->changeReturnType($phpDocInfo, $type); $functionLike->returnType = null; - if (!$functionLike instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$functionLike instanceof ClassMethod) { return; } - $classLike = $this->betterNodeFinder->findParentByTypes($functionLike, [\PhpParser\Node\Stmt\Class_::class, \PhpParser\Node\Stmt\Interface_::class]); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentByTypes($functionLike, [Class_::class, Interface_::class]); + if (!$classLike instanceof ClassLike) { return; } if (!$this->isRequireReturnTypeWillChange(\get_class($type), $classLike, $functionLike)) { @@ -119,7 +119,7 @@ final class PhpDocFromTypeDeclarationDecorator * @param array> $requiredTypes * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure|\PhpParser\Node\Expr\ArrowFunction $functionLike */ - public function decorateParam(\PhpParser\Node\Param $param, $functionLike, array $requiredTypes) : void + public function decorateParam(Param $param, $functionLike, array $requiredTypes) : void { if ($param->type === null) { return; @@ -133,7 +133,7 @@ final class PhpDocFromTypeDeclarationDecorator /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure|\PhpParser\Node\Expr\ArrowFunction $functionLike */ - public function decorateParamWithSpecificType(\PhpParser\Node\Param $param, $functionLike, \PHPStan\Type\Type $requireType) : void + public function decorateParamWithSpecificType(Param $param, $functionLike, Type $requireType) : void { if ($param->type === null) { return; @@ -148,7 +148,7 @@ final class PhpDocFromTypeDeclarationDecorator * @return bool True if node was changed * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure|\PhpParser\Node\Expr\ArrowFunction $functionLike */ - public function decorateReturnWithSpecificType($functionLike, \PHPStan\Type\Type $requireType) : bool + public function decorateReturnWithSpecificType($functionLike, Type $requireType) : bool { if ($functionLike->returnType === null) { return \false; @@ -159,16 +159,16 @@ final class PhpDocFromTypeDeclarationDecorator $this->decorate($functionLike); return \true; } - private function isRequireReturnTypeWillChange(string $type, \PhpParser\Node\Stmt\ClassLike $classLike, \PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function isRequireReturnTypeWillChange(string $type, ClassLike $classLike, ClassMethod $classMethod) : bool { if (!\array_key_exists($type, self::ADD_RETURN_TYPE_WILL_CHANGE)) { return \false; } $className = (string) $this->nodeNameResolver->getName($classLike); - $objectClass = new \PHPStan\Type\ObjectType($className); + $objectClass = new ObjectType($className); $methodName = $this->nodeNameResolver->getName($classMethod); foreach (self::ADD_RETURN_TYPE_WILL_CHANGE[$type] as $class => $methods) { - $objectClassConfig = new \PHPStan\Type\ObjectType($class); + $objectClassConfig = new ObjectType($class); if (!$objectClassConfig->isSuperTypeOf($objectClass)->yes()) { continue; } @@ -185,14 +185,14 @@ final class PhpDocFromTypeDeclarationDecorator /** * @param \PhpParser\Node\ComplexType|\PhpParser\Node\Identifier|\PhpParser\Node\Name $typeNode */ - private function isTypeMatch($typeNode, \PHPStan\Type\Type $requireType) : bool + private function isTypeMatch($typeNode, Type $requireType) : bool { $returnType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($typeNode); // cover nullable union types - if ($returnType instanceof \PHPStan\Type\UnionType) { + if ($returnType instanceof UnionType) { $returnType = $this->typeUnwrapper->unwrapNullableType($returnType); } - if ($returnType instanceof \PHPStan\Type\ObjectType) { + if ($returnType instanceof ObjectType) { return $returnType->equals($requireType); } return \get_class($returnType) === \get_class($requireType); @@ -200,7 +200,7 @@ final class PhpDocFromTypeDeclarationDecorator /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure|\PhpParser\Node\Expr\ArrowFunction $functionLike */ - private function moveParamTypeToParamDoc($functionLike, \PhpParser\Node\Param $param, \PHPStan\Type\Type $type) : void + private function moveParamTypeToParamDoc($functionLike, Param $param, Type $type) : void { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike); $paramName = $this->nodeNameResolver->getName($param); @@ -210,7 +210,7 @@ final class PhpDocFromTypeDeclarationDecorator /** * @param array> $requiredTypes */ - private function isMatchingType(\PHPStan\Type\Type $type, array $requiredTypes) : bool + private function isMatchingType(Type $type, array $requiredTypes) : bool { return \in_array(\get_class($type), $requiredTypes, \true); } diff --git a/packages/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser.php b/packages/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser.php index 6369a9887d2..99267ee271f 100644 --- a/packages/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser.php +++ b/packages/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser.php @@ -26,7 +26,7 @@ final class StaticDoctrineAnnotationParser * @var \Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\ArrayParser */ private $arrayParser; - public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\PlainValueParser $plainValueParser, \Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\ArrayParser $arrayParser) + public function __construct(PlainValueParser $plainValueParser, ArrayParser $arrayParser) { $this->plainValueParser = $plainValueParser; $this->arrayParser = $arrayParser; @@ -35,14 +35,14 @@ final class StaticDoctrineAnnotationParser * mimics: https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1024-L1041 * @return array */ - public function resolveAnnotationMethodCall(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) : array + public function resolveAnnotationMethodCall(BetterTokenIterator $tokenIterator) : array { - if (!$tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES)) { + if (!$tokenIterator->isCurrentTokenType(Lexer::TOKEN_OPEN_PARENTHESES)) { return []; } - $tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES); + $tokenIterator->consumeTokenType(Lexer::TOKEN_OPEN_PARENTHESES); // empty () - if ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES)) { + if ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_CLOSE_PARENTHESES)) { return []; } return $this->resolveAnnotationValues($tokenIterator); @@ -51,19 +51,19 @@ final class StaticDoctrineAnnotationParser * @see https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1215-L1224 * @return \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode|string|mixed[]|\PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode|\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode */ - public function resolveAnnotationValue(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) + public function resolveAnnotationValue(BetterTokenIterator $tokenIterator) { // skips dummy tokens like newlines - $tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + $tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); // no assign - if (!$tokenIterator->isNextTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_EQUAL)) { + if (!$tokenIterator->isNextTokenType(Lexer::TOKEN_EQUAL)) { // 1. plain value - mimics https://github.com/doctrine/annotations/blob/0cb0cd2950a5c6cdbf22adbe2bfd5fd1ea68588f/lib/Doctrine/Common/Annotations/DocParser.php#L1234-L1282 return $this->parseValue($tokenIterator); } // 2. assign key = value - mimics FieldAssignment() https://github.com/doctrine/annotations/blob/0cb0cd2950a5c6cdbf22adbe2bfd5fd1ea68588f/lib/Doctrine/Common/Annotations/DocParser.php#L1291-L1303 /** @var int $key */ $key = $this->parseValue($tokenIterator); - $tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_EQUAL); + $tokenIterator->consumeTokenType(Lexer::TOKEN_EQUAL); // mimics https://github.com/doctrine/annotations/blob/1.13.x/lib/Doctrine/Common/Annotations/DocParser.php#L1236-L1238 $value = $this->parseValue($tokenIterator); return [ @@ -75,7 +75,7 @@ final class StaticDoctrineAnnotationParser * @see https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1051-L1079 * @return array */ - private function resolveAnnotationValues(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) : array + private function resolveAnnotationValues(BetterTokenIterator $tokenIterator) : array { $values = []; $resolvedValue = $this->resolveAnnotationValue($tokenIterator); @@ -84,10 +84,10 @@ final class StaticDoctrineAnnotationParser } else { $values[] = $resolvedValue; } - while ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COMMA)) { + while ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_COMMA)) { $tokenIterator->next(); // if is next item just closing brackets - if ($tokenIterator->isNextTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES)) { + if ($tokenIterator->isNextTokenType(Lexer::TOKEN_CLOSE_PARENTHESES)) { continue; } $nestedValues = $this->resolveAnnotationValue($tokenIterator); @@ -102,11 +102,11 @@ final class StaticDoctrineAnnotationParser /** * @return \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode|string|mixed[]|\PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode|\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode */ - private function parseValue(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) + private function parseValue(BetterTokenIterator $tokenIterator) { - if ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_CURLY_BRACKET)) { + if ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_OPEN_CURLY_BRACKET)) { $items = $this->arrayParser->parseCurlyArray($tokenIterator); - return new \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode($items); + return new CurlyListNode($items); } return $this->plainValueParser->parseValue($tokenIterator); } diff --git a/packages/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser/ArrayParser.php b/packages/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser/ArrayParser.php index d3d3eaf1045..4276f6db3c3 100644 --- a/packages/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser/ArrayParser.php +++ b/packages/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser/ArrayParser.php @@ -24,40 +24,40 @@ final class ArrayParser * Mimics https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1305-L1352 * @return mixed[] */ - public function parseCurlyArray(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) : array + public function parseCurlyArray(BetterTokenIterator $tokenIterator) : array { $values = []; // nothing - if ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_CURLY_BRACKET)) { + if ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET)) { return []; } - $tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_CURLY_BRACKET); + $tokenIterator->consumeTokenType(Lexer::TOKEN_OPEN_CURLY_BRACKET); // If the array is empty, stop parsing and return. - if ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_CURLY_BRACKET)) { - $tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_CURLY_BRACKET); + if ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET)) { + $tokenIterator->consumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET); return []; } // first item $values[] = $this->resolveArrayItem($tokenIterator); // 2nd+ item - while ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COMMA)) { + while ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_COMMA)) { // optional trailing comma - $tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COMMA); - $tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); - if ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_CURLY_BRACKET)) { + $tokenIterator->consumeTokenType(Lexer::TOKEN_COMMA); + $tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); + if ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET)) { break; } $values[] = $this->resolveArrayItem($tokenIterator); - if ($tokenIterator->isNextTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_CURLY_BRACKET)) { + if ($tokenIterator->isNextTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET)) { break; } // skip newlines - $tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + $tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); } - $tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + $tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); // special case for nested doctrine annotations - if (!$tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES)) { - $tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_CURLY_BRACKET); + if (!$tokenIterator->isCurrentTokenType(Lexer::TOKEN_CLOSE_PARENTHESES)) { + $tokenIterator->tryConsumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET); } return $this->createArrayFromValues($values); } @@ -65,39 +65,39 @@ final class ArrayParser * Mimics https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1354-L1385 * @return array */ - private function resolveArrayItem(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) : array + private function resolveArrayItem(BetterTokenIterator $tokenIterator) : array { // skip newlines - $tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + $tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); $key = null; // join "ClassName::CONSTANT_REFERENCE" to identifier - if ($tokenIterator->isNextTokenTypes([\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_DOUBLE_COLON])) { + if ($tokenIterator->isNextTokenTypes([Lexer::TOKEN_DOUBLE_COLON])) { $key = $tokenIterator->currentTokenValue(); // "::" $tokenIterator->next(); $key .= $tokenIterator->currentTokenValue(); - $tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_DOUBLE_COLON); + $tokenIterator->consumeTokenType(Lexer::TOKEN_DOUBLE_COLON); $key .= $tokenIterator->currentTokenValue(); $tokenIterator->next(); } - $tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); - if ($tokenIterator->isCurrentTokenTypes([\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_CURLY_BRACKET, \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COMMA])) { + $tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); + if ($tokenIterator->isCurrentTokenTypes([Lexer::TOKEN_CLOSE_CURLY_BRACKET, Lexer::TOKEN_COMMA])) { // it's a value, not a key return [null, $key]; } - if ($tokenIterator->isCurrentTokenTypes([\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_EQUAL, \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COLON]) || $tokenIterator->isNextTokenTypes([\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_EQUAL, \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COLON])) { - $tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_EQUAL); - $tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COLON); + if ($tokenIterator->isCurrentTokenTypes([Lexer::TOKEN_EQUAL, Lexer::TOKEN_COLON]) || $tokenIterator->isNextTokenTypes([Lexer::TOKEN_EQUAL, Lexer::TOKEN_COLON])) { + $tokenIterator->tryConsumeTokenType(Lexer::TOKEN_EQUAL); + $tokenIterator->tryConsumeTokenType(Lexer::TOKEN_COLON); if ($key === null) { - if ($tokenIterator->isNextTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER)) { + if ($tokenIterator->isNextTokenType(Lexer::TOKEN_IDENTIFIER)) { $key = $this->plainValueParser->parseValue($tokenIterator); } else { - $tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COMMA); + $tokenIterator->tryConsumeTokenType(Lexer::TOKEN_COMMA); $key = $this->plainValueParser->parseValue($tokenIterator); } } - $tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_EQUAL); - $tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COLON); + $tokenIterator->tryConsumeTokenType(Lexer::TOKEN_EQUAL); + $tokenIterator->tryConsumeTokenType(Lexer::TOKEN_COLON); return [$key, $this->plainValueParser->parseValue($tokenIterator)]; } return [$key, $this->plainValueParser->parseValue($tokenIterator)]; @@ -111,7 +111,7 @@ final class ArrayParser $array = []; foreach ($values as $value) { [$key, $val] = $value; - if ($key instanceof \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode) { + if ($key instanceof ConstExprIntegerNode) { $key = $key->value; } if ($key !== null) { diff --git a/packages/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser/PlainValueParser.php b/packages/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser/PlainValueParser.php index 56daa84e018..97839a200a2 100644 --- a/packages/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser/PlainValueParser.php +++ b/packages/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser/PlainValueParser.php @@ -38,7 +38,7 @@ final class PlainValueParser * @var \Rector\Core\Configuration\CurrentNodeProvider */ private $currentNodeProvider; - public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher $classAnnotationMatcher, \Rector\Core\Configuration\CurrentNodeProvider $currentNodeProvider) + public function __construct(ClassAnnotationMatcher $classAnnotationMatcher, CurrentNodeProvider $currentNodeProvider) { $this->classAnnotationMatcher = $classAnnotationMatcher; $this->currentNodeProvider = $currentNodeProvider; @@ -46,7 +46,7 @@ final class PlainValueParser /** * @required */ - public function autowire(\Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser $staticDoctrineAnnotationParser, \Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\ArrayParser $arrayParser) : void + public function autowire(StaticDoctrineAnnotationParser $staticDoctrineAnnotationParser, \Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\ArrayParser $arrayParser) : void { $this->staticDoctrineAnnotationParser = $staticDoctrineAnnotationParser; $this->arrayParser = $arrayParser; @@ -54,15 +54,15 @@ final class PlainValueParser /** * @return string|mixed[]|\PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode|\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode */ - public function parseValue(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) + public function parseValue(BetterTokenIterator $tokenIterator) { $currentTokenValue = $tokenIterator->currentTokenValue(); // temporary hackaround multi-line doctrine annotations - if ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_END)) { + if ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_END)) { return $currentTokenValue; } // consume the token - $isOpenCurlyArray = $tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_CURLY_BRACKET); + $isOpenCurlyArray = $tokenIterator->isCurrentTokenType(Lexer::TOKEN_OPEN_CURLY_BRACKET); if ($isOpenCurlyArray) { return $this->arrayParser->parseCurlyArray($tokenIterator); } @@ -72,12 +72,12 @@ final class PlainValueParser if ($constantValue !== null) { return $constantValue; } - while ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_DOUBLE_COLON) || $tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER)) { + while ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_DOUBLE_COLON) || $tokenIterator->isCurrentTokenType(Lexer::TOKEN_IDENTIFIER)) { $currentTokenValue .= $tokenIterator->currentTokenValue(); $tokenIterator->next(); } // nested entity! - if ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES)) { + if ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_OPEN_PARENTHESES)) { return $this->parseNestedDoctrineAnnotationTagValueNode($currentTokenValue, $tokenIterator); } $start = $tokenIterator->currentPosition(); @@ -93,25 +93,25 @@ final class PlainValueParser } return $currentTokenValue; } - private function parseNestedDoctrineAnnotationTagValueNode(string $currentTokenValue, \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) : \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode + private function parseNestedDoctrineAnnotationTagValueNode(string $currentTokenValue, BetterTokenIterator $tokenIterator) : DoctrineAnnotationTagValueNode { // @todo $annotationShortName = $currentTokenValue; $values = $this->staticDoctrineAnnotationParser->resolveAnnotationMethodCall($tokenIterator); $currentNode = $this->currentNodeProvider->getNode(); - if (!$currentNode instanceof \PhpParser\Node) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$currentNode instanceof Node) { + throw new ShouldNotHappenException(); } $fullyQualifiedAnnotationClass = $this->classAnnotationMatcher->resolveTagFullyQualifiedName($annotationShortName, $currentNode); // keep the last ")" - $tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + $tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); if ($tokenIterator->currentTokenValue() === ')') { - $tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES); + $tokenIterator->consumeTokenType(Lexer::TOKEN_CLOSE_PARENTHESES); } // keep original name to differentiate between short and FQN class - $identifierTypeNode = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($annotationShortName); - $identifierTypeNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::RESOLVED_CLASS, $fullyQualifiedAnnotationClass); - return new \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode($identifierTypeNode, $annotationShortName, $values); + $identifierTypeNode = new IdentifierTypeNode($annotationShortName); + $identifierTypeNode->setAttribute(PhpDocAttributeKey::RESOLVED_CLASS, $fullyQualifiedAnnotationClass); + return new DoctrineAnnotationTagValueNode($identifierTypeNode, $annotationShortName, $values); } /** * @return \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode|null @@ -119,10 +119,10 @@ final class PlainValueParser private function matchConstantValue(string $currentTokenValue) { if (\strtolower($currentTokenValue) === 'false') { - return new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprFalseNode(); + return new ConstExprFalseNode(); } if (\strtolower($currentTokenValue) === 'true') { - return new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprTrueNode(); + return new ConstExprTrueNode(); } if (!\is_numeric($currentTokenValue)) { return null; @@ -130,6 +130,6 @@ final class PlainValueParser if ((string) (int) $currentTokenValue !== $currentTokenValue) { return null; } - return new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode($currentTokenValue); + return new ConstExprIntegerNode($currentTokenValue); } } diff --git a/packages/BetterPhpDocParser/Printer/DocBlockInliner.php b/packages/BetterPhpDocParser/Printer/DocBlockInliner.php index 38acfb2bc1f..f3d44dbb436 100644 --- a/packages/BetterPhpDocParser/Printer/DocBlockInliner.php +++ b/packages/BetterPhpDocParser/Printer/DocBlockInliner.php @@ -18,7 +18,7 @@ final class DocBlockInliner private const NEWLINE_MIDDLE_DOC_REGEX = "#\n \\* #"; public function inline(string $docContent) : string { - $docContent = \RectorPrefix20220607\Nette\Utils\Strings::replace($docContent, self::NEWLINE_MIDDLE_DOC_REGEX, ' '); - return \RectorPrefix20220607\Nette\Utils\Strings::replace($docContent, self::NEWLINE_CLOSING_DOC_REGEX, ' */'); + $docContent = Strings::replace($docContent, self::NEWLINE_MIDDLE_DOC_REGEX, ' '); + return Strings::replace($docContent, self::NEWLINE_CLOSING_DOC_REGEX, ' */'); } } diff --git a/packages/BetterPhpDocParser/Printer/EmptyPhpDocDetector.php b/packages/BetterPhpDocParser/Printer/EmptyPhpDocDetector.php index 7d98ac00f2e..465fa9a4510 100644 --- a/packages/BetterPhpDocParser/Printer/EmptyPhpDocDetector.php +++ b/packages/BetterPhpDocParser/Printer/EmptyPhpDocDetector.php @@ -7,13 +7,13 @@ use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode; final class EmptyPhpDocDetector { - public function isPhpDocNodeEmpty(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode) : bool + public function isPhpDocNodeEmpty(PhpDocNode $phpDocNode) : bool { if ($phpDocNode->children === []) { return \true; } foreach ($phpDocNode->children as $phpDocChildNode) { - if ($phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode) { + if ($phpDocChildNode instanceof PhpDocTextNode) { if ($phpDocChildNode->text !== '') { return \false; } diff --git a/packages/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php b/packages/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php index 89bf4eba983..4d7367b8eea 100644 --- a/packages/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php +++ b/packages/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php @@ -97,23 +97,23 @@ final class PhpDocInfoPrinter * @var \Rector\BetterPhpDocParser\PhpDocNodeVisitor\ChangedPhpDocNodeVisitor */ private $changedPhpDocNodeVisitor; - public function __construct(\Rector\BetterPhpDocParser\Printer\EmptyPhpDocDetector $emptyPhpDocDetector, \Rector\BetterPhpDocParser\Printer\DocBlockInliner $docBlockInliner, \Rector\BetterPhpDocParser\Printer\RemoveNodesStartAndEndResolver $removeNodesStartAndEndResolver, \Rector\BetterPhpDocParser\PhpDocNodeVisitor\ChangedPhpDocNodeVisitor $changedPhpDocNodeVisitor) + public function __construct(\Rector\BetterPhpDocParser\Printer\EmptyPhpDocDetector $emptyPhpDocDetector, \Rector\BetterPhpDocParser\Printer\DocBlockInliner $docBlockInliner, \Rector\BetterPhpDocParser\Printer\RemoveNodesStartAndEndResolver $removeNodesStartAndEndResolver, ChangedPhpDocNodeVisitor $changedPhpDocNodeVisitor) { $this->emptyPhpDocDetector = $emptyPhpDocDetector; $this->docBlockInliner = $docBlockInliner; $this->removeNodesStartAndEndResolver = $removeNodesStartAndEndResolver; $this->changedPhpDocNodeVisitor = $changedPhpDocNodeVisitor; - $changedPhpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser(); + $changedPhpDocNodeTraverser = new PhpDocNodeTraverser(); $changedPhpDocNodeTraverser->addPhpDocNodeVisitor($this->changedPhpDocNodeVisitor); $this->changedPhpDocNodeTraverser = $changedPhpDocNodeTraverser; } - public function printNew(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : string + public function printNew(PhpDocInfo $phpDocInfo) : string { $docContent = (string) $phpDocInfo->getPhpDocNode(); if ($phpDocInfo->isSingleLine()) { return $this->docBlockInliner->inline($docContent); } - if ($phpDocInfo->getNode() instanceof \PhpParser\Node\Stmt\InlineHTML) { + if ($phpDocInfo->getNode() instanceof InlineHTML) { return ''; } return $docContent; @@ -128,14 +128,14 @@ final class PhpDocInfoPrinter * - Print(subnode2) * - Tokens[subnode2.endPos .. node.endPos] */ - public function printFormatPreserving(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : string + public function printFormatPreserving(PhpDocInfo $phpDocInfo) : string { if ($phpDocInfo->getTokens() === []) { // completely new one, just print string version of it if ($phpDocInfo->getPhpDocNode()->children === []) { return ''; } - if ($phpDocInfo->getNode() instanceof \PhpParser\Node\Stmt\InlineHTML) { + if ($phpDocInfo->getNode() instanceof InlineHTML) { return 'getPhpDocNode() . \PHP_EOL . '?>'; } return (string) $phpDocInfo->getPhpDocNode(); @@ -147,16 +147,16 @@ final class PhpDocInfoPrinter $this->currentTokenPosition = 0; $phpDocString = $this->printPhpDocNode($phpDocNode); // hotfix of extra space with callable () - return \RectorPrefix20220607\Nette\Utils\Strings::replace($phpDocString, self::CALLABLE_REGEX, 'callable('); + return Strings::replace($phpDocString, self::CALLABLE_REGEX, 'callable('); } - public function getCurrentPhpDocInfo() : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo + public function getCurrentPhpDocInfo() : PhpDocInfo { if ($this->phpDocInfo === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } return $this->phpDocInfo; } - private function printPhpDocNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode) : string + private function printPhpDocNode(PhpDocNode $phpDocNode) : string { // no nodes were, so empty doc if ($this->emptyPhpDocDetector->isPhpDocNodeEmpty($phpDocNode)) { @@ -170,42 +170,42 @@ final class PhpDocInfoPrinter } $output = $this->printEnd($output); // fix missing start - if (!\Rector\Core\Util\StringUtils::isMatch($output, self::DOCBLOCK_START_REGEX) && $output !== '') { + if (!StringUtils::isMatch($output, self::DOCBLOCK_START_REGEX) && $output !== '') { $output = '/**' . $output; } // fix missing end - if (\Rector\Core\Util\StringUtils::isMatch($output, self::OPENING_DOCBLOCK_REGEX) && !\Rector\Core\Util\StringUtils::isMatch($output, self::CLOSING_DOCBLOCK_REGEX)) { + if (StringUtils::isMatch($output, self::OPENING_DOCBLOCK_REGEX) && !StringUtils::isMatch($output, self::CLOSING_DOCBLOCK_REGEX)) { $output .= ' */'; } return $output; } - private function printDocChildNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $phpDocChildNode, int $key = 0, int $nodeCount = 0) : string + private function printDocChildNode(PhpDocChildNode $phpDocChildNode, int $key = 0, int $nodeCount = 0) : string { $output = ''; $shouldReprintChildNode = $this->shouldReprint($phpDocChildNode); - if ($phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) { - if ($shouldReprintChildNode && ($phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode || $phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode || $phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode || $phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode || $phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode)) { + if ($phpDocChildNode instanceof PhpDocTagNode) { + if ($shouldReprintChildNode && ($phpDocChildNode->value instanceof ParamTagValueNode || $phpDocChildNode->value instanceof ThrowsTagValueNode || $phpDocChildNode->value instanceof VarTagValueNode || $phpDocChildNode->value instanceof ReturnTagValueNode || $phpDocChildNode->value instanceof PropertyTagValueNode)) { // the type has changed → reprint - $phpDocChildNodeStartEnd = $phpDocChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END); + $phpDocChildNodeStartEnd = $phpDocChildNode->getAttribute(PhpDocAttributeKey::START_AND_END); // bump the last position of token after just printed node - if ($phpDocChildNodeStartEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) { + if ($phpDocChildNodeStartEnd instanceof StartAndEnd) { $this->currentTokenPosition = $phpDocChildNodeStartEnd->getEnd(); } return $this->standardPrintPhpDocChildNode($phpDocChildNode); } - if ($phpDocChildNode->value instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode && $shouldReprintChildNode) { + if ($phpDocChildNode->value instanceof DoctrineAnnotationTagValueNode && $shouldReprintChildNode) { $silentValue = $phpDocChildNode->value->getSilentValue(); if ($silentValue === null) { $printedNode = (string) $phpDocChildNode; // remove extra space between tags - $printedNode = \RectorPrefix20220607\Nette\Utils\Strings::replace($printedNode, self::TAG_AND_SPACE_REGEX, '$1('); + $printedNode = Strings::replace($printedNode, self::TAG_AND_SPACE_REGEX, '$1('); return self::NEWLINE_WITH_ASTERISK . ($printedNode === '' ? '' : ' ' . $printedNode); } } } /** @var StartAndEnd|null $startAndEnd */ - $startAndEnd = $phpDocChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END); - if ($startAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd && !$shouldReprintChildNode) { + $startAndEnd = $phpDocChildNode->getAttribute(PhpDocAttributeKey::START_AND_END); + if ($startAndEnd instanceof StartAndEnd && !$shouldReprintChildNode) { $isLastToken = $nodeCount === $key; // correct previously changed node $this->correctPreviouslyReprintedFirstNode($key, $startAndEnd); @@ -213,7 +213,7 @@ final class PhpDocInfoPrinter $this->currentTokenPosition = $startAndEnd->getEnd(); return \rtrim($output); } - if ($startAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) { + if ($startAndEnd instanceof StartAndEnd) { $this->currentTokenPosition = $startAndEnd->getEnd(); } $standardPrintedPhpDocChildNode = $this->standardPrintPhpDocChildNode($phpDocChildNode); @@ -221,7 +221,7 @@ final class PhpDocInfoPrinter } private function printEnd(string $output) : string { - $lastTokenPosition = $this->getCurrentPhpDocInfo()->getPhpDocNode()->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::LAST_PHP_DOC_TOKEN_POSITION); + $lastTokenPosition = $this->getCurrentPhpDocInfo()->getPhpDocNode()->getAttribute(PhpDocAttributeKey::LAST_PHP_DOC_TOKEN_POSITION); if ($lastTokenPosition === null) { $lastTokenPosition = $this->currentTokenPosition; } @@ -239,7 +239,7 @@ final class PhpDocInfoPrinter $positionJumpSet[$removedStartAndEnd->getStart()] = $removedStartAndEnd->getEnd(); } // include also space before, in case of inlined docs - if (isset($this->tokens[$from - 1]) && $this->tokens[$from - 1][1] === \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_HORIZONTAL_WS) { + if (isset($this->tokens[$from - 1]) && $this->tokens[$from - 1][1] === Lexer::TOKEN_HORIZONTAL_WS) { --$from; } // skip extra empty lines above if this is the last one @@ -261,7 +261,7 @@ final class PhpDocInfoPrinter } return $output; } - private function correctPreviouslyReprintedFirstNode(int $key, \Rector\BetterPhpDocParser\ValueObject\StartAndEnd $startAndEnd) : void + private function correctPreviouslyReprintedFirstNode(int $key, StartAndEnd $startAndEnd) : void { if ($this->currentTokenPosition !== 0) { return; @@ -275,17 +275,17 @@ final class PhpDocInfoPrinter return; } $previousToken = $tokens[$startTokenPosition - 1]; - if ($previousToken[1] === \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL) { + if ($previousToken[1] === Lexer::TOKEN_PHPDOC_EOL) { --$startTokenPosition; } $this->currentTokenPosition = $startTokenPosition; } - private function shouldReprint(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $phpDocChildNode) : bool + private function shouldReprint(PhpDocChildNode $phpDocChildNode) : bool { $this->changedPhpDocNodeTraverser->traverse($phpDocChildNode); return $this->changedPhpDocNodeVisitor->hasChanged(); } - private function standardPrintPhpDocChildNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $phpDocChildNode) : string + private function standardPrintPhpDocChildNode(PhpDocChildNode $phpDocChildNode) : string { $printedNode = (string) $phpDocChildNode; if ($this->getCurrentPhpDocInfo()->isSingleLine()) { diff --git a/packages/BetterPhpDocParser/Printer/RemoveNodesStartAndEndResolver.php b/packages/BetterPhpDocParser/Printer/RemoveNodesStartAndEndResolver.php index 13ead05d36c..ffd5c26e23e 100644 --- a/packages/BetterPhpDocParser/Printer/RemoveNodesStartAndEndResolver.php +++ b/packages/BetterPhpDocParser/Printer/RemoveNodesStartAndEndResolver.php @@ -14,7 +14,7 @@ final class RemoveNodesStartAndEndResolver * @param mixed[] $tokens * @return StartAndEnd[] */ - public function resolve(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $originalPhpDocNode, \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $currentPhpDocNode, array $tokens) : array + public function resolve(PhpDocNode $originalPhpDocNode, PhpDocNode $currentPhpDocNode, array $tokens) : array { $removedNodePositions = []; /** @var PhpDocChildNode[] $removedChildNodes */ @@ -22,15 +22,15 @@ final class RemoveNodesStartAndEndResolver $lastEndPosition = null; foreach ($removedChildNodes as $removedChildNode) { /** @var StartAndEnd|null $removedPhpDocNodeInfo */ - $removedPhpDocNodeInfo = $removedChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END); + $removedPhpDocNodeInfo = $removedChildNode->getAttribute(PhpDocAttributeKey::START_AND_END); // it's not there when comment block has empty row "\s\*\n" - if (!$removedPhpDocNodeInfo instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) { + if (!$removedPhpDocNodeInfo instanceof StartAndEnd) { continue; } // change start position to start of the line, so the whole line is removed $seekPosition = $removedPhpDocNodeInfo->getStart(); - while ($seekPosition >= 0 && $tokens[$seekPosition][1] !== \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_HORIZONTAL_WS) { - if ($tokens[$seekPosition][1] === \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL) { + while ($seekPosition >= 0 && $tokens[$seekPosition][1] !== Lexer::TOKEN_HORIZONTAL_WS) { + if ($tokens[$seekPosition][1] === Lexer::TOKEN_PHPDOC_EOL) { break; } // do not colide @@ -40,7 +40,7 @@ final class RemoveNodesStartAndEndResolver --$seekPosition; } $lastEndPosition = $removedPhpDocNodeInfo->getEnd(); - $removedNodePositions[] = new \Rector\BetterPhpDocParser\ValueObject\StartAndEnd(\max(0, $seekPosition - 1), $removedPhpDocNodeInfo->getEnd()); + $removedNodePositions[] = new StartAndEnd(\max(0, $seekPosition - 1), $removedPhpDocNodeInfo->getEnd()); } return $removedNodePositions; } diff --git a/packages/BetterPhpDocParser/ValueObject/NodeTypes.php b/packages/BetterPhpDocParser/ValueObject/NodeTypes.php index 50ec0d70c3a..f85a49634a8 100644 --- a/packages/BetterPhpDocParser/ValueObject/NodeTypes.php +++ b/packages/BetterPhpDocParser/ValueObject/NodeTypes.php @@ -15,7 +15,7 @@ final class NodeTypes /** * @var array> */ - public const TYPE_AWARE_NODES = [\PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode::class, \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode::class, \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode::class, \PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode::class, \PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode::class, \PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode::class]; + public const TYPE_AWARE_NODES = [VarTagValueNode::class, ParamTagValueNode::class, ReturnTagValueNode::class, ThrowsTagValueNode::class, PropertyTagValueNode::class, TemplateTagValueNode::class]; /** * @var string[] */ diff --git a/packages/BetterPhpDocParser/ValueObject/Parser/BetterTokenIterator.php b/packages/BetterPhpDocParser/ValueObject/Parser/BetterTokenIterator.php index 9d2c385aa7b..0c9f0eedbc0 100644 --- a/packages/BetterPhpDocParser/ValueObject/Parser/BetterTokenIterator.php +++ b/packages/BetterPhpDocParser/ValueObject/Parser/BetterTokenIterator.php @@ -6,7 +6,7 @@ namespace Rector\BetterPhpDocParser\ValueObject\Parser; use PHPStan\PhpDocParser\Parser\TokenIterator; use Rector\Core\Exception\ShouldNotHappenException; use RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor; -final class BetterTokenIterator extends \PHPStan\PhpDocParser\Parser\TokenIterator +final class BetterTokenIterator extends TokenIterator { /** * @var string @@ -26,7 +26,7 @@ final class BetterTokenIterator extends \PHPStan\PhpDocParser\Parser\TokenIterat */ public function __construct(array $tokens, int $index = 0) { - $this->privatesAccessor = new \RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor(); + $this->privatesAccessor = new PrivatesAccessor(); if ($tokens === []) { $this->privatesAccessor->setPrivateProperty($this, self::TOKENS, []); $this->privatesAccessor->setPrivateProperty($this, self::INDEX, 0); @@ -77,7 +77,7 @@ final class BetterTokenIterator extends \PHPStan\PhpDocParser\Parser\TokenIterat public function printFromTo(int $from, int $to) : string { if ($to < $from) { - throw new \Rector\Core\Exception\ShouldNotHappenException('Arguments are flipped'); + throw new ShouldNotHappenException('Arguments are flipped'); } $tokens = $this->getTokens(); $content = ''; diff --git a/packages/BetterPhpDocParser/ValueObject/PhpDoc/DoctrineAnnotation/AbstractValuesAwareNode.php b/packages/BetterPhpDocParser/ValueObject/PhpDoc/DoctrineAnnotation/AbstractValuesAwareNode.php index ffeb460a567..f585caeef73 100644 --- a/packages/BetterPhpDocParser/ValueObject/PhpDoc/DoctrineAnnotation/AbstractValuesAwareNode.php +++ b/packages/BetterPhpDocParser/ValueObject/PhpDoc/DoctrineAnnotation/AbstractValuesAwareNode.php @@ -9,7 +9,7 @@ use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode; use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey; use Rector\Core\Util\StringUtils; -abstract class AbstractValuesAwareNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode +abstract class AbstractValuesAwareNode implements PhpDocTagValueNode { use NodeAttributes; /** @@ -57,7 +57,7 @@ abstract class AbstractValuesAwareNode implements \PHPStan\PhpDocParser\Ast\PhpD unset($this->values[$key]); unset($this->values[$quotedKey]); // invoke reprint - $this->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE, null); + $this->setAttribute(PhpDocAttributeKey::ORIG_NODE, null); } /** * @return mixed[] @@ -84,12 +84,12 @@ abstract class AbstractValuesAwareNode implements \PHPStan\PhpDocParser\Ast\PhpD public function changeValue(string $key, $value) : void { // is quoted? - if (isset($this->values[$key]) && \is_string($this->values[$key]) && \Rector\Core\Util\StringUtils::isMatch($this->values[$key], self::UNQUOTED_VALUE_REGEX)) { + if (isset($this->values[$key]) && \is_string($this->values[$key]) && StringUtils::isMatch($this->values[$key], self::UNQUOTED_VALUE_REGEX)) { $value = '"' . $value . '"'; } $this->values[$key] = $value; // invoke reprint - $this->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE, null); + $this->setAttribute(PhpDocAttributeKey::ORIG_NODE, null); } /** * @return mixed|null @@ -109,13 +109,13 @@ abstract class AbstractValuesAwareNode implements \PHPStan\PhpDocParser\Ast\PhpD public function changeSilentValue($value) : void { // is quoted? - if (\Rector\Core\Util\StringUtils::isMatch($this->values[0], self::UNQUOTED_VALUE_REGEX)) { + if (StringUtils::isMatch($this->values[0], self::UNQUOTED_VALUE_REGEX)) { $value = '"' . $value . '"'; } $this->values[0] = $value; $this->hasChanged = \true; // invoke reprint - $this->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE, null); + $this->setAttribute(PhpDocAttributeKey::ORIG_NODE, null); } /** * @return mixed|null @@ -168,7 +168,7 @@ abstract class AbstractValuesAwareNode implements \PHPStan\PhpDocParser\Ast\PhpD if (!\is_string($value)) { return $value; } - $matches = \RectorPrefix20220607\Nette\Utils\Strings::match($value, self::UNQUOTED_VALUE_REGEX); + $matches = Strings::match($value, self::UNQUOTED_VALUE_REGEX); if ($matches === null) { return $value; } diff --git a/packages/BetterPhpDocParser/ValueObject/PhpDoc/SpacingAwareTemplateTagValueNode.php b/packages/BetterPhpDocParser/ValueObject/PhpDoc/SpacingAwareTemplateTagValueNode.php index bbf91ea44bb..b01663fbd63 100644 --- a/packages/BetterPhpDocParser/ValueObject/PhpDoc/SpacingAwareTemplateTagValueNode.php +++ b/packages/BetterPhpDocParser/ValueObject/PhpDoc/SpacingAwareTemplateTagValueNode.php @@ -6,14 +6,14 @@ namespace Rector\BetterPhpDocParser\ValueObject\PhpDoc; use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use Stringable; -final class SpacingAwareTemplateTagValueNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode +final class SpacingAwareTemplateTagValueNode extends TemplateTagValueNode { /** * @readonly * @var string */ private $preposition; - public function __construct(string $name, ?\PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode, string $description, string $preposition) + public function __construct(string $name, ?TypeNode $typeNode, string $description, string $preposition) { $this->preposition = $preposition; parent::__construct($name, $typeNode, $description); diff --git a/packages/BetterPhpDocParser/ValueObject/PhpDocAttributeKey.php b/packages/BetterPhpDocParser/ValueObject/PhpDocAttributeKey.php index e24bae848ed..d4449287f46 100644 --- a/packages/BetterPhpDocParser/ValueObject/PhpDocAttributeKey.php +++ b/packages/BetterPhpDocParser/ValueObject/PhpDocAttributeKey.php @@ -18,7 +18,7 @@ final class PhpDocAttributeKey /** * @var string */ - public const PARENT = \RectorPrefix20220607\Symplify\Astral\PhpDocParser\ValueObject\PhpDocAttributeKey::PARENT; + public const PARENT = NativePhpDocAttributeKey::PARENT; /** * @var string */ @@ -26,5 +26,5 @@ final class PhpDocAttributeKey /** * @var string */ - public const ORIG_NODE = \RectorPrefix20220607\Symplify\Astral\PhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE; + public const ORIG_NODE = NativePhpDocAttributeKey::ORIG_NODE; } diff --git a/packages/BetterPhpDocParser/ValueObject/StartAndEnd.php b/packages/BetterPhpDocParser/ValueObject/StartAndEnd.php index e4b193ca0fc..8cbac8e7ed8 100644 --- a/packages/BetterPhpDocParser/ValueObject/StartAndEnd.php +++ b/packages/BetterPhpDocParser/ValueObject/StartAndEnd.php @@ -21,7 +21,7 @@ final class StartAndEnd $this->start = $start; $this->end = $end; if ($end < $start) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } } public function getStart() : int diff --git a/packages/BetterPhpDocParser/ValueObject/Type/BracketsAwareIntersectionTypeNode.php b/packages/BetterPhpDocParser/ValueObject/Type/BracketsAwareIntersectionTypeNode.php index 97d9fa5bddb..a4e3a762fab 100644 --- a/packages/BetterPhpDocParser/ValueObject/Type/BracketsAwareIntersectionTypeNode.php +++ b/packages/BetterPhpDocParser/ValueObject/Type/BracketsAwareIntersectionTypeNode.php @@ -5,7 +5,7 @@ namespace Rector\BetterPhpDocParser\ValueObject\Type; use PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode; use Stringable; -final class BracketsAwareIntersectionTypeNode extends \PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode +final class BracketsAwareIntersectionTypeNode extends IntersectionTypeNode { public function __toString() : string { diff --git a/packages/BetterPhpDocParser/ValueObject/Type/BracketsAwareUnionTypeNode.php b/packages/BetterPhpDocParser/ValueObject/Type/BracketsAwareUnionTypeNode.php index f7e2c375b1f..d566e953b81 100644 --- a/packages/BetterPhpDocParser/ValueObject/Type/BracketsAwareUnionTypeNode.php +++ b/packages/BetterPhpDocParser/ValueObject/Type/BracketsAwareUnionTypeNode.php @@ -6,7 +6,7 @@ namespace Rector\BetterPhpDocParser\ValueObject\Type; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode; use Stringable; -final class BracketsAwareUnionTypeNode extends \PHPStan\PhpDocParser\Ast\Type\UnionTypeNode +final class BracketsAwareUnionTypeNode extends UnionTypeNode { /** * @readonly diff --git a/packages/BetterPhpDocParser/ValueObject/Type/EmptyGenericTypeNode.php b/packages/BetterPhpDocParser/ValueObject/Type/EmptyGenericTypeNode.php index 2f458d54928..a766d549c7c 100644 --- a/packages/BetterPhpDocParser/ValueObject/Type/EmptyGenericTypeNode.php +++ b/packages/BetterPhpDocParser/ValueObject/Type/EmptyGenericTypeNode.php @@ -6,9 +6,9 @@ namespace Rector\BetterPhpDocParser\ValueObject\Type; use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; use Stringable; -final class EmptyGenericTypeNode extends \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode +final class EmptyGenericTypeNode extends GenericTypeNode { - public function __construct(\PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode $identifierTypeNode) + public function __construct(IdentifierTypeNode $identifierTypeNode) { parent::__construct($identifierTypeNode, []); } diff --git a/packages/BetterPhpDocParser/ValueObject/Type/FullyQualifiedIdentifierTypeNode.php b/packages/BetterPhpDocParser/ValueObject/Type/FullyQualifiedIdentifierTypeNode.php index 51a932ecf76..cd973330a34 100644 --- a/packages/BetterPhpDocParser/ValueObject/Type/FullyQualifiedIdentifierTypeNode.php +++ b/packages/BetterPhpDocParser/ValueObject/Type/FullyQualifiedIdentifierTypeNode.php @@ -5,7 +5,7 @@ namespace Rector\BetterPhpDocParser\ValueObject\Type; use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; use Stringable; -final class FullyQualifiedIdentifierTypeNode extends \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode +final class FullyQualifiedIdentifierTypeNode extends IdentifierTypeNode { public function __toString() : string { diff --git a/packages/BetterPhpDocParser/ValueObject/Type/ShortenedIdentifierTypeNode.php b/packages/BetterPhpDocParser/ValueObject/Type/ShortenedIdentifierTypeNode.php index 2e76fac8727..9150d6261d7 100644 --- a/packages/BetterPhpDocParser/ValueObject/Type/ShortenedIdentifierTypeNode.php +++ b/packages/BetterPhpDocParser/ValueObject/Type/ShortenedIdentifierTypeNode.php @@ -5,6 +5,6 @@ namespace Rector\BetterPhpDocParser\ValueObject\Type; use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; use Stringable; -final class ShortenedIdentifierTypeNode extends \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode +final class ShortenedIdentifierTypeNode extends IdentifierTypeNode { } diff --git a/packages/BetterPhpDocParser/ValueObject/Type/SpacingAwareArrayTypeNode.php b/packages/BetterPhpDocParser/ValueObject/Type/SpacingAwareArrayTypeNode.php index c412a8000ad..28defa2f873 100644 --- a/packages/BetterPhpDocParser/ValueObject/Type/SpacingAwareArrayTypeNode.php +++ b/packages/BetterPhpDocParser/ValueObject/Type/SpacingAwareArrayTypeNode.php @@ -9,18 +9,18 @@ use PHPStan\PhpDocParser\Ast\Type\TypeNode; use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode; use Rector\PHPStanStaticTypeMapper\TypeMapper\ArrayTypeMapper; use Stringable; -final class SpacingAwareArrayTypeNode extends \PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode +final class SpacingAwareArrayTypeNode extends ArrayTypeNode { public function __toString() : string { - if ($this->type instanceof \PHPStan\PhpDocParser\Ast\Type\CallableTypeNode) { + if ($this->type instanceof CallableTypeNode) { return \sprintf('(%s)[]', (string) $this->type); } $typeAsString = (string) $this->type; if ($this->isGenericArrayCandidate($this->type)) { return \sprintf('array<%s>', $typeAsString); } - if ($this->type instanceof \PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode) { + if ($this->type instanceof ArrayTypeNode) { return $this->printArrayType($this->type); } if ($this->type instanceof \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode) { @@ -28,15 +28,15 @@ final class SpacingAwareArrayTypeNode extends \PHPStan\PhpDocParser\Ast\Type\Arr } return $typeAsString . '[]'; } - private function isGenericArrayCandidate(\PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode) : bool + private function isGenericArrayCandidate(TypeNode $typeNode) : bool { - $hasGenericTypeParent = (bool) $this->getAttribute(\Rector\PHPStanStaticTypeMapper\TypeMapper\ArrayTypeMapper::HAS_GENERIC_TYPE_PARENT); + $hasGenericTypeParent = (bool) $this->getAttribute(ArrayTypeMapper::HAS_GENERIC_TYPE_PARENT); if (!$hasGenericTypeParent) { return \false; } - return $typeNode instanceof \PHPStan\PhpDocParser\Ast\Type\UnionTypeNode || $typeNode instanceof \PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode; + return $typeNode instanceof UnionTypeNode || $typeNode instanceof ArrayTypeNode; } - private function printArrayType(\PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode $arrayTypeNode) : string + private function printArrayType(ArrayTypeNode $arrayTypeNode) : string { $typeAsString = (string) $arrayTypeNode; $singleTypesAsString = \explode('|', $typeAsString); diff --git a/packages/BetterPhpDocParser/ValueObject/Type/SpacingAwareCallableTypeNode.php b/packages/BetterPhpDocParser/ValueObject/Type/SpacingAwareCallableTypeNode.php index 2c184de5779..e28d41bee7b 100644 --- a/packages/BetterPhpDocParser/ValueObject/Type/SpacingAwareCallableTypeNode.php +++ b/packages/BetterPhpDocParser/ValueObject/Type/SpacingAwareCallableTypeNode.php @@ -7,7 +7,7 @@ use PHPStan\PhpDocParser\Ast\Type\CallableTypeNode; use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; use Stringable; -final class SpacingAwareCallableTypeNode extends \PHPStan\PhpDocParser\Ast\Type\CallableTypeNode +final class SpacingAwareCallableTypeNode extends CallableTypeNode { public function __toString() : string { diff --git a/packages/Caching/Cache.php b/packages/Caching/Cache.php index e19dc12af68..1bebddbb3e0 100644 --- a/packages/Caching/Cache.php +++ b/packages/Caching/Cache.php @@ -11,7 +11,7 @@ final class Cache * @var \Rector\Caching\Contract\ValueObject\Storage\CacheStorageInterface */ private $cacheStorage; - public function __construct(\Rector\Caching\Contract\ValueObject\Storage\CacheStorageInterface $cacheStorage) + public function __construct(CacheStorageInterface $cacheStorage) { $this->cacheStorage = $cacheStorage; } diff --git a/packages/Caching/CacheFactory.php b/packages/Caching/CacheFactory.php index 941640fd279..6cec2f2a869 100644 --- a/packages/Caching/CacheFactory.php +++ b/packages/Caching/CacheFactory.php @@ -20,26 +20,26 @@ final class CacheFactory * @var \Symplify\SmartFileSystem\SmartFileSystem */ private $smartFileSystem; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem) + public function __construct(ParameterProvider $parameterProvider, SmartFileSystem $smartFileSystem) { $this->parameterProvider = $parameterProvider; $this->smartFileSystem = $smartFileSystem; } public function create() : \Rector\Caching\Cache { - $cacheDirectory = $this->parameterProvider->provideStringParameter(\Rector\Core\Configuration\Option::CACHE_DIR); - $cacheClass = \Rector\Caching\ValueObject\Storage\FileCacheStorage::class; - if ($this->parameterProvider->hasParameter(\Rector\Core\Configuration\Option::CACHE_CLASS)) { - $cacheClass = $this->parameterProvider->provideStringParameter(\Rector\Core\Configuration\Option::CACHE_CLASS); + $cacheDirectory = $this->parameterProvider->provideStringParameter(Option::CACHE_DIR); + $cacheClass = FileCacheStorage::class; + if ($this->parameterProvider->hasParameter(Option::CACHE_CLASS)) { + $cacheClass = $this->parameterProvider->provideStringParameter(Option::CACHE_CLASS); } - if ($cacheClass === \Rector\Caching\ValueObject\Storage\FileCacheStorage::class) { + if ($cacheClass === FileCacheStorage::class) { // ensure cache directory exists if (!$this->smartFileSystem->exists($cacheDirectory)) { $this->smartFileSystem->mkdir($cacheDirectory); } - $fileCacheStorage = new \Rector\Caching\ValueObject\Storage\FileCacheStorage($cacheDirectory, $this->smartFileSystem); + $fileCacheStorage = new FileCacheStorage($cacheDirectory, $this->smartFileSystem); return new \Rector\Caching\Cache($fileCacheStorage); } - return new \Rector\Caching\Cache(new \Rector\Caching\ValueObject\Storage\MemoryCacheStorage()); + return new \Rector\Caching\Cache(new MemoryCacheStorage()); } } diff --git a/packages/Caching/Config/FileHashComputer.php b/packages/Caching/Config/FileHashComputer.php index bcabb21c32b..58df93b89e9 100644 --- a/packages/Caching/Config/FileHashComputer.php +++ b/packages/Caching/Config/FileHashComputer.php @@ -18,7 +18,7 @@ final class FileHashComputer public function compute(string $filePath) : string { $this->ensureIsPhp($filePath); - $containerBuilder = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder(); + $containerBuilder = new ContainerBuilder(); $fileLoader = $this->createFileLoader($filePath, $containerBuilder); $fileLoader->load($filePath); $parameterBag = $containerBuilder->getParameterBag(); @@ -30,20 +30,20 @@ final class FileHashComputer if ($fileExtension === 'php') { return; } - throw new \Rector\Core\Exception\ShouldNotHappenException(\sprintf( + throw new ShouldNotHappenException(\sprintf( // getRealPath() cannot be used, as it breaks in phar 'Provide only PHP file, ready for Symfony Dependency Injection. "%s" given', $filePath )); } - private function createFileLoader(string $filePath, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder) : \RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderInterface + private function createFileLoader(string $filePath, ContainerBuilder $containerBuilder) : LoaderInterface { - $fileLocator = new \RectorPrefix20220607\Symfony\Component\Config\FileLocator([$filePath]); - $fileLoaders = [new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\GlobFileLoader($containerBuilder, $fileLocator), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\PhpFileLoader($containerBuilder, $fileLocator)]; - $loaderResolver = new \RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderResolver($fileLoaders); + $fileLocator = new FileLocator([$filePath]); + $fileLoaders = [new GlobFileLoader($containerBuilder, $fileLocator), new PhpFileLoader($containerBuilder, $fileLocator)]; + $loaderResolver = new LoaderResolver($fileLoaders); $loader = $loaderResolver->resolve($filePath); if ($loader === \false) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } return $loader; } diff --git a/packages/Caching/Detector/ChangedFilesDetector.php b/packages/Caching/Detector/ChangedFilesDetector.php index e82ee74f004..35c90e7f79c 100644 --- a/packages/Caching/Detector/ChangedFilesDetector.php +++ b/packages/Caching/Detector/ChangedFilesDetector.php @@ -7,7 +7,7 @@ use RectorPrefix20220607\Nette\Utils\Strings; use Rector\Caching\Cache; use Rector\Caching\Config\FileHashComputer; use Rector\Caching\Enum\CacheKey; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; /** * Inspired by https://github.com/symplify/symplify/pull/90/files#diff-72041b2e1029a08930e13d79d298ef11 * @@ -25,7 +25,7 @@ final class ChangedFilesDetector * @var \Rector\Caching\Cache */ private $cache; - public function __construct(\Rector\Caching\Config\FileHashComputer $fileHashComputer, \Rector\Caching\Cache $cache) + public function __construct(FileHashComputer $fileHashComputer, Cache $cache) { $this->fileHashComputer = $fileHashComputer; $this->cache = $cache; @@ -33,21 +33,21 @@ final class ChangedFilesDetector /** * @param string[] $dependentFiles */ - public function addFileWithDependencies(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo, array $dependentFiles) : void + public function addFileWithDependencies(SmartFileInfo $smartFileInfo, array $dependentFiles) : void { $fileInfoCacheKey = $this->getFileInfoCacheKey($smartFileInfo); $hash = $this->hashFile($smartFileInfo); - $this->cache->save($fileInfoCacheKey, \Rector\Caching\Enum\CacheKey::FILE_HASH_KEY, $hash); - $this->cache->save($fileInfoCacheKey . '_files', \Rector\Caching\Enum\CacheKey::DEPENDENT_FILES_KEY, $dependentFiles); + $this->cache->save($fileInfoCacheKey, CacheKey::FILE_HASH_KEY, $hash); + $this->cache->save($fileInfoCacheKey . '_files', CacheKey::DEPENDENT_FILES_KEY, $dependentFiles); } - public function hasFileChanged(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : bool + public function hasFileChanged(SmartFileInfo $smartFileInfo) : bool { $currentFileHash = $this->hashFile($smartFileInfo); $fileInfoCacheKey = $this->getFileInfoCacheKey($smartFileInfo); - $cachedValue = $this->cache->load($fileInfoCacheKey, \Rector\Caching\Enum\CacheKey::FILE_HASH_KEY); + $cachedValue = $this->cache->load($fileInfoCacheKey, CacheKey::FILE_HASH_KEY); return $currentFileHash !== $cachedValue; } - public function invalidateFile(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : void + public function invalidateFile(SmartFileInfo $smartFileInfo) : void { $fileInfoCacheKey = $this->getFileInfoCacheKey($smartFileInfo); $this->cache->clean($fileInfoCacheKey); @@ -59,10 +59,10 @@ final class ChangedFilesDetector /** * @return SmartFileInfo[] */ - public function getDependentFileInfos(\Symplify\SmartFileSystem\SmartFileInfo $fileInfo) : array + public function getDependentFileInfos(SmartFileInfo $fileInfo) : array { $fileInfoCacheKey = $this->getFileInfoCacheKey($fileInfo); - $cacheValue = $this->cache->load($fileInfoCacheKey . '_files', \Rector\Caching\Enum\CacheKey::DEPENDENT_FILES_KEY); + $cacheValue = $this->cache->load($fileInfoCacheKey . '_files', CacheKey::DEPENDENT_FILES_KEY); if ($cacheValue === null) { return []; } @@ -72,7 +72,7 @@ final class ChangedFilesDetector if (!\file_exists($dependentFile)) { continue; } - $dependentFileInfos[] = new \Symplify\SmartFileSystem\SmartFileInfo($dependentFile); + $dependentFileInfos[] = new SmartFileInfo($dependentFile); } return $dependentFileInfos; } @@ -85,23 +85,23 @@ final class ChangedFilesDetector $configHash = $this->fileHashComputer->compute($filePath); $this->storeConfigurationDataHash($filePath, $configHash); } - private function getFileInfoCacheKey(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : string + private function getFileInfoCacheKey(SmartFileInfo $smartFileInfo) : string { return \sha1($smartFileInfo->getRealPath()); } - private function hashFile(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : string + private function hashFile(SmartFileInfo $smartFileInfo) : string { return (string) \sha1_file($smartFileInfo->getRealPath()); } private function storeConfigurationDataHash(string $filePath, string $configurationHash) : void { - $key = \Rector\Caching\Enum\CacheKey::CONFIGURATION_HASH_KEY . '_' . \RectorPrefix20220607\Nette\Utils\Strings::webalize($filePath); + $key = CacheKey::CONFIGURATION_HASH_KEY . '_' . Strings::webalize($filePath); $this->invalidateCacheIfConfigurationChanged($key, $configurationHash); - $this->cache->save($key, \Rector\Caching\Enum\CacheKey::CONFIGURATION_HASH_KEY, $configurationHash); + $this->cache->save($key, CacheKey::CONFIGURATION_HASH_KEY, $configurationHash); } private function invalidateCacheIfConfigurationChanged(string $key, string $configurationHash) : void { - $oldCachedValue = $this->cache->load($key, \Rector\Caching\Enum\CacheKey::CONFIGURATION_HASH_KEY); + $oldCachedValue = $this->cache->load($key, CacheKey::CONFIGURATION_HASH_KEY); if ($oldCachedValue === null) { return; } diff --git a/packages/Caching/FileSystem/DependencyResolver.php b/packages/Caching/FileSystem/DependencyResolver.php index 52c55477f6d..ffbec8b77f2 100644 --- a/packages/Caching/FileSystem/DependencyResolver.php +++ b/packages/Caching/FileSystem/DependencyResolver.php @@ -25,7 +25,7 @@ final class DependencyResolver * @var \Symplify\PackageBuilder\Reflection\PrivatesAccessor */ private $privatesAccessor; - public function __construct(\PHPStan\Analyser\NodeScopeResolver $nodeScopeResolver, \PHPStan\Dependency\DependencyResolver $phpStanDependencyResolver, \RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor $privatesAccessor) + public function __construct(NodeScopeResolver $nodeScopeResolver, PHPStanDependencyResolver $phpStanDependencyResolver, PrivatesAccessor $privatesAccessor) { $this->nodeScopeResolver = $nodeScopeResolver; $this->phpStanDependencyResolver = $phpStanDependencyResolver; @@ -34,7 +34,7 @@ final class DependencyResolver /** * @return string[] */ - public function resolveDependencies(\PhpParser\Node $node, \PHPStan\Analyser\MutatingScope $mutatingScope) : array + public function resolveDependencies(Node $node, MutatingScope $mutatingScope) : array { $analysedFileAbsolutesPaths = $this->privatesAccessor->getPrivateProperty($this->nodeScopeResolver, 'analysedFiles'); $nodeDependencies = $this->phpStanDependencyResolver->resolveDependencies($node, $mutatingScope); diff --git a/packages/Caching/UnchangedFilesFilter.php b/packages/Caching/UnchangedFilesFilter.php index c6d5bef1621..626689507f8 100644 --- a/packages/Caching/UnchangedFilesFilter.php +++ b/packages/Caching/UnchangedFilesFilter.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Caching; use Rector\Caching\Detector\ChangedFilesDetector; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class UnchangedFilesFilter { /** @@ -12,7 +12,7 @@ final class UnchangedFilesFilter * @var \Rector\Caching\Detector\ChangedFilesDetector */ private $changedFilesDetector; - public function __construct(\Rector\Caching\Detector\ChangedFilesDetector $changedFilesDetector) + public function __construct(ChangedFilesDetector $changedFilesDetector) { $this->changedFilesDetector = $changedFilesDetector; } @@ -26,7 +26,7 @@ final class UnchangedFilesFilter $dependentFileInfos = []; foreach ($fileInfos as $fileInfo) { if (\is_string($fileInfo)) { - $fileInfo = new \Symplify\SmartFileSystem\SmartFileInfo($fileInfo); + $fileInfo = new SmartFileInfo($fileInfo); } if (!$this->changedFilesDetector->hasFileChanged($fileInfo)) { continue; diff --git a/packages/Caching/ValueObject/Storage/FileCacheStorage.php b/packages/Caching/ValueObject/Storage/FileCacheStorage.php index 8cb56ad8d59..6e7cf4a9175 100644 --- a/packages/Caching/ValueObject/Storage/FileCacheStorage.php +++ b/packages/Caching/ValueObject/Storage/FileCacheStorage.php @@ -15,7 +15,7 @@ use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem; * Inspired by https://github.com/phpstan/phpstan-src/blob/1e7ceae933f07e5a250b61ed94799e6c2ea8daa2/src/Cache/FileCacheStorage.php * @see \Rector\Tests\Caching\ValueObject\Storage\FileCacheStorageTest */ -final class FileCacheStorage implements \Rector\Caching\Contract\ValueObject\Storage\CacheStorageInterface +final class FileCacheStorage implements CacheStorageInterface { /** * @var string @@ -25,7 +25,7 @@ final class FileCacheStorage implements \Rector\Caching\Contract\ValueObject\Sto * @var \Symplify\SmartFileSystem\SmartFileSystem */ private $smartFileSystem; - public function __construct(string $directory, \RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem) + public function __construct(string $directory, SmartFileSystem $smartFileSystem) { $this->directory = $directory; $this->smartFileSystem = $smartFileSystem; @@ -39,7 +39,7 @@ final class FileCacheStorage implements \Rector\Caching\Contract\ValueObject\Sto return null; } $cacheItem = (require $filePath); - if (!$cacheItem instanceof \Rector\Caching\ValueObject\CacheItem) { + if (!$cacheItem instanceof CacheItem) { return null; } if (!$cacheItem->isVariableKeyValid($variableKey)) { @@ -54,22 +54,22 @@ final class FileCacheStorage implements \Rector\Caching\Contract\ValueObject\Sto $this->smartFileSystem->mkdir($cacheFilePaths->getFirstDirectory()); $this->smartFileSystem->mkdir($cacheFilePaths->getSecondDirectory()); $path = $cacheFilePaths->getFilePath(); - $tmpPath = \sprintf('%s/%s.tmp', $this->directory, \RectorPrefix20220607\Nette\Utils\Random::generate()); + $tmpPath = \sprintf('%s/%s.tmp', $this->directory, Random::generate()); $errorBefore = \error_get_last(); - $exported = @\var_export(new \Rector\Caching\ValueObject\CacheItem($variableKey, $data), \true); + $exported = @\var_export(new CacheItem($variableKey, $data), \true); $errorAfter = \error_get_last(); if ($errorAfter !== null && $errorBefore !== $errorAfter) { - throw new \Rector\Core\Exception\Cache\CachingException(\sprintf('Error occurred while saving item %s (%s) to cache: %s', $key, $variableKey, $errorAfter['message'])); + throw new CachingException(\sprintf('Error occurred while saving item %s (%s) to cache: %s', $key, $variableKey, $errorAfter['message'])); } // for performance reasons we don't use SmartFileSystem - \RectorPrefix20220607\Nette\Utils\FileSystem::write($tmpPath, \sprintf("smartFileSystem->remove($this->directory); } - private function processRemoveCacheFilePath(\Rector\Caching\ValueObject\CacheFilePaths $cacheFilePaths) : void + private function processRemoveCacheFilePath(CacheFilePaths $cacheFilePaths) : void { $filePath = $cacheFilePaths->getFilePath(); if (!$this->smartFileSystem->exists($filePath)) { @@ -104,15 +104,15 @@ final class FileCacheStorage implements \Rector\Caching\Contract\ValueObject\Sto private function isNotEmptyDirectory(string $directory) : bool { // FilesystemIterator will initially point to the first file in the folder - if there are no files in the folder, valid() will return false - $filesystemIterator = new \FilesystemIterator($directory); + $filesystemIterator = new FilesystemIterator($directory); return $filesystemIterator->valid(); } - private function getCacheFilePaths(string $key) : \Rector\Caching\ValueObject\CacheFilePaths + private function getCacheFilePaths(string $key) : CacheFilePaths { $keyHash = \sha1($key); $firstDirectory = \sprintf('%s/%s', $this->directory, \substr($keyHash, 0, 2)); $secondDirectory = \sprintf('%s/%s', $firstDirectory, \substr($keyHash, 2, 2)); $filePath = \sprintf('%s/%s.php', $secondDirectory, $keyHash); - return new \Rector\Caching\ValueObject\CacheFilePaths($firstDirectory, $secondDirectory, $filePath); + return new CacheFilePaths($firstDirectory, $secondDirectory, $filePath); } } diff --git a/packages/Caching/ValueObject/Storage/MemoryCacheStorage.php b/packages/Caching/ValueObject/Storage/MemoryCacheStorage.php index 7c1ebaf2693..36bac56a8e6 100644 --- a/packages/Caching/ValueObject/Storage/MemoryCacheStorage.php +++ b/packages/Caching/ValueObject/Storage/MemoryCacheStorage.php @@ -8,7 +8,7 @@ use Rector\Caching\ValueObject\CacheItem; /** * inspired by https://github.com/phpstan/phpstan-src/blob/560652088406d7461c2c4ad4897784e33f8ab312/src/Cache/MemoryCacheStorage.php */ -final class MemoryCacheStorage implements \Rector\Caching\Contract\ValueObject\Storage\CacheStorageInterface +final class MemoryCacheStorage implements CacheStorageInterface { /** * @var array @@ -30,7 +30,7 @@ final class MemoryCacheStorage implements \Rector\Caching\Contract\ValueObject\S } public function save(string $key, string $variableKey, $data) : void { - $this->storage[$key] = new \Rector\Caching\ValueObject\CacheItem($variableKey, $data); + $this->storage[$key] = new CacheItem($variableKey, $data); } public function clean(string $key) : void { diff --git a/packages/ChangesReporting/Annotation/AnnotationExtractor.php b/packages/ChangesReporting/Annotation/AnnotationExtractor.php index a430f6476af..d7d98364079 100644 --- a/packages/ChangesReporting/Annotation/AnnotationExtractor.php +++ b/packages/ChangesReporting/Annotation/AnnotationExtractor.php @@ -16,7 +16,7 @@ final class AnnotationExtractor */ public function extractAnnotationFromClass(string $className, string $annotation) : ?string { - $reflectionClass = new \ReflectionClass($className); + $reflectionClass = new ReflectionClass($className); $docComment = $reflectionClass->getDocComment(); if (!\is_string($docComment)) { return null; @@ -24,7 +24,7 @@ final class AnnotationExtractor // @see https://3v4l.org/ouYfB // uses 'r?\n' instead of '$' because windows compat $pattern = '#' . \preg_quote($annotation, '#') . '\\s+(?.*?)\\r?\\n#m'; - $matches = \RectorPrefix20220607\Nette\Utils\Strings::match($docComment, $pattern); + $matches = Strings::match($docComment, $pattern); return $matches['content'] ?? null; } } diff --git a/packages/ChangesReporting/Collector/AffectedFilesCollector.php b/packages/ChangesReporting/Collector/AffectedFilesCollector.php index 418dcc9d30c..8d64cdb7d26 100644 --- a/packages/ChangesReporting/Collector/AffectedFilesCollector.php +++ b/packages/ChangesReporting/Collector/AffectedFilesCollector.php @@ -10,19 +10,19 @@ final class AffectedFilesCollector * @var array */ private $affectedFiles = []; - public function addFile(\Rector\Core\ValueObject\Application\File $file) : void + public function addFile(File $file) : void { $smartFileInfo = $file->getSmartFileInfo(); $this->affectedFiles[$smartFileInfo->getRealPath()] = $file; } - public function getNext() : ?\Rector\Core\ValueObject\Application\File + public function getNext() : ?File { if ($this->affectedFiles !== []) { return \current($this->affectedFiles); } return null; } - public function removeFromList(\Rector\Core\ValueObject\Application\File $file) : void + public function removeFromList(File $file) : void { $smartFileInfo = $file->getSmartFileInfo(); unset($this->affectedFiles[$smartFileInfo->getRealPath()]); diff --git a/packages/ChangesReporting/Collector/RectorChangeCollector.php b/packages/ChangesReporting/Collector/RectorChangeCollector.php index 688bd527fb5..b1232aa7ebe 100644 --- a/packages/ChangesReporting/Collector/RectorChangeCollector.php +++ b/packages/ChangesReporting/Collector/RectorChangeCollector.php @@ -21,7 +21,7 @@ final class RectorChangeCollector * @var \Rector\Core\Provider\CurrentFileProvider */ private $currentFileProvider; - public function __construct(\Rector\Core\Logging\CurrentRectorProvider $currentRectorProvider, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider) + public function __construct(CurrentRectorProvider $currentRectorProvider, CurrentFileProvider $currentFileProvider) { $this->currentRectorProvider = $currentRectorProvider; $this->currentFileProvider = $currentFileProvider; @@ -29,19 +29,19 @@ final class RectorChangeCollector /** * @deprecated Use file-> method instead */ - public function notifyNodeFileInfo(\PhpParser\Node $node) : void + public function notifyNodeFileInfo(Node $node) : void { $file = $this->currentFileProvider->getFile(); - if (!$file instanceof \Rector\Core\ValueObject\Application\File) { + if (!$file instanceof File) { // this file was changed before and this is a sub-new node // array Traverse to all new nodes would have to be used, but it's not worth the performance return; } $currentRector = $this->currentRectorProvider->getCurrentRector(); - if (!$currentRector instanceof \Rector\Core\Contract\Rector\RectorInterface) { + if (!$currentRector instanceof RectorInterface) { return; } - $rectorWithLineChange = new \Rector\ChangesReporting\ValueObject\RectorWithLineChange(\get_class($currentRector), $node->getLine()); + $rectorWithLineChange = new RectorWithLineChange(\get_class($currentRector), $node->getLine()); $file->addRectorClassWithLine($rectorWithLineChange); } } diff --git a/packages/ChangesReporting/Contract/Output/OutputFormatterInterface.php b/packages/ChangesReporting/Contract/Output/OutputFormatterInterface.php index 31437d6f43e..045b1c6bb3c 100644 --- a/packages/ChangesReporting/Contract/Output/OutputFormatterInterface.php +++ b/packages/ChangesReporting/Contract/Output/OutputFormatterInterface.php @@ -8,5 +8,5 @@ use Rector\Core\ValueObject\ProcessResult; interface OutputFormatterInterface { public function getName() : string; - public function report(\Rector\Core\ValueObject\ProcessResult $processResult, \Rector\Core\ValueObject\Configuration $configuration) : void; + public function report(ProcessResult $processResult, Configuration $configuration) : void; } diff --git a/packages/ChangesReporting/Output/ConsoleOutputFormatter.php b/packages/ChangesReporting/Output/ConsoleOutputFormatter.php index 51b62d4a20c..1d722397a1c 100644 --- a/packages/ChangesReporting/Output/ConsoleOutputFormatter.php +++ b/packages/ChangesReporting/Output/ConsoleOutputFormatter.php @@ -11,7 +11,7 @@ use Rector\Core\ValueObject\Configuration; use Rector\Core\ValueObject\Error\SystemError; use Rector\Core\ValueObject\ProcessResult; use Rector\Core\ValueObject\Reporting\FileDiff; -final class ConsoleOutputFormatter implements \Rector\ChangesReporting\Contract\Output\OutputFormatterInterface +final class ConsoleOutputFormatter implements OutputFormatterInterface { /** * @var string @@ -32,12 +32,12 @@ final class ConsoleOutputFormatter implements \Rector\ChangesReporting\Contract\ * @var \Rector\ChangesReporting\Annotation\RectorsChangelogResolver */ private $rectorsChangelogResolver; - public function __construct(\Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle, \Rector\ChangesReporting\Annotation\RectorsChangelogResolver $rectorsChangelogResolver) + public function __construct(OutputStyleInterface $rectorOutputStyle, RectorsChangelogResolver $rectorsChangelogResolver) { $this->rectorOutputStyle = $rectorOutputStyle; $this->rectorsChangelogResolver = $rectorsChangelogResolver; } - public function report(\Rector\Core\ValueObject\ProcessResult $processResult, \Rector\Core\ValueObject\Configuration $configuration) : void + public function report(ProcessResult $processResult, Configuration $configuration) : void { if ($configuration->shouldShowDiffs()) { $this->reportFileDiffs($processResult->getFileDiffs()); @@ -105,7 +105,7 @@ final class ConsoleOutputFormatter implements \Rector\ChangesReporting\Contract\ $this->rectorOutputStyle->error($message); } } - private function reportRemovedFilesAndNodes(\Rector\Core\ValueObject\ProcessResult $processResult) : void + private function reportRemovedFilesAndNodes(ProcessResult $processResult) : void { if ($processResult->getAddedFilesCount() !== 0) { $message = \sprintf('%d files were added', $processResult->getAddedFilesCount()); @@ -120,10 +120,10 @@ final class ConsoleOutputFormatter implements \Rector\ChangesReporting\Contract\ private function normalizePathsToRelativeWithLine(string $errorMessage) : string { $regex = '#' . \preg_quote(\getcwd(), '#') . '/#'; - $errorMessage = \RectorPrefix20220607\Nette\Utils\Strings::replace($errorMessage, $regex, ''); - return \RectorPrefix20220607\Nette\Utils\Strings::replace($errorMessage, self::ON_LINE_REGEX, ':'); + $errorMessage = Strings::replace($errorMessage, $regex, ''); + return Strings::replace($errorMessage, self::ON_LINE_REGEX, ':'); } - private function reportRemovedNodes(\Rector\Core\ValueObject\ProcessResult $processResult) : void + private function reportRemovedNodes(ProcessResult $processResult) : void { if ($processResult->getRemovedNodeCount() === 0) { return; @@ -131,7 +131,7 @@ final class ConsoleOutputFormatter implements \Rector\ChangesReporting\Contract\ $message = \sprintf('%d nodes were removed', $processResult->getRemovedNodeCount()); $this->rectorOutputStyle->warning($message); } - private function createSuccessMessage(\Rector\Core\ValueObject\ProcessResult $processResult, \Rector\Core\ValueObject\Configuration $configuration) : string + private function createSuccessMessage(ProcessResult $processResult, Configuration $configuration) : string { $changeCount = \count($processResult->getFileDiffs()) + $processResult->getRemovedAndAddedFilesCount(); if ($changeCount === 0) { @@ -142,12 +142,12 @@ final class ConsoleOutputFormatter implements \Rector\ChangesReporting\Contract\ /** * @return string[] */ - private function createRectorChangelogLines(\Rector\Core\ValueObject\Reporting\FileDiff $fileDiff) : array + private function createRectorChangelogLines(FileDiff $fileDiff) : array { $rectorsChangelogs = $this->rectorsChangelogResolver->resolveIncludingMissing($fileDiff->getRectorClasses()); $rectorsChangelogsLines = []; foreach ($rectorsChangelogs as $rectorClass => $changelog) { - $rectorShortClass = (string) \RectorPrefix20220607\Nette\Utils\Strings::after($rectorClass, '\\', -1); + $rectorShortClass = (string) Strings::after($rectorClass, '\\', -1); $rectorsChangelogsLines[] = $changelog === null ? $rectorShortClass : $rectorShortClass . ' (' . $changelog . ')'; } return $rectorsChangelogsLines; diff --git a/packages/ChangesReporting/Output/JsonOutputFormatter.php b/packages/ChangesReporting/Output/JsonOutputFormatter.php index a37f9fe36ed..57ad177c54f 100644 --- a/packages/ChangesReporting/Output/JsonOutputFormatter.php +++ b/packages/ChangesReporting/Output/JsonOutputFormatter.php @@ -10,7 +10,7 @@ use Rector\Core\ValueObject\Configuration; use Rector\Core\ValueObject\Error\SystemError; use Rector\Core\ValueObject\ProcessResult; use Rector\Parallel\ValueObject\Bridge; -final class JsonOutputFormatter implements \Rector\ChangesReporting\Contract\Output\OutputFormatterInterface +final class JsonOutputFormatter implements OutputFormatterInterface { /** * @var string @@ -21,7 +21,7 @@ final class JsonOutputFormatter implements \Rector\ChangesReporting\Contract\Out * @var \Rector\ChangesReporting\Annotation\RectorsChangelogResolver */ private $rectorsChangelogResolver; - public function __construct(\Rector\ChangesReporting\Annotation\RectorsChangelogResolver $rectorsChangelogResolver) + public function __construct(RectorsChangelogResolver $rectorsChangelogResolver) { $this->rectorsChangelogResolver = $rectorsChangelogResolver; } @@ -29,7 +29,7 @@ final class JsonOutputFormatter implements \Rector\ChangesReporting\Contract\Out { return self::NAME; } - public function report(\Rector\Core\ValueObject\ProcessResult $processResult, \Rector\Core\ValueObject\Configuration $configuration) : void + public function report(ProcessResult $processResult, Configuration $configuration) : void { $errorsJson = ['totals' => ['changed_files' => \count($processResult->getFileDiffs()), 'removed_and_added_files_count' => $processResult->getRemovedAndAddedFilesCount(), 'removed_node_count' => $processResult->getRemovedNodeCount()]]; $fileDiffs = $processResult->getFileDiffs(); @@ -37,7 +37,7 @@ final class JsonOutputFormatter implements \Rector\ChangesReporting\Contract\Out foreach ($fileDiffs as $fileDiff) { $relativeFilePath = $fileDiff->getRelativeFilePath(); $appliedRectorsWithChangelog = $this->rectorsChangelogResolver->resolve($fileDiff->getRectorClasses()); - $errorsJson[\Rector\Parallel\ValueObject\Bridge::FILE_DIFFS][] = ['file' => $relativeFilePath, 'diff' => $fileDiff->getDiff(), 'applied_rectors' => $fileDiff->getRectorClasses(), 'applied_rectors_with_changelog' => $appliedRectorsWithChangelog]; + $errorsJson[Bridge::FILE_DIFFS][] = ['file' => $relativeFilePath, 'diff' => $fileDiff->getDiff(), 'applied_rectors' => $fileDiff->getRectorClasses(), 'applied_rectors_with_changelog' => $appliedRectorsWithChangelog]; // for Rector CI $errorsJson['changed_files'][] = $relativeFilePath; } @@ -47,7 +47,7 @@ final class JsonOutputFormatter implements \Rector\ChangesReporting\Contract\Out if ($errorsData !== []) { $errorsJson['errors'] = $errorsData; } - $json = \RectorPrefix20220607\Nette\Utils\Json::encode($errorsJson, \RectorPrefix20220607\Nette\Utils\Json::PRETTY); + $json = Json::encode($errorsJson, Json::PRETTY); echo $json . \PHP_EOL; } /** diff --git a/packages/ChangesReporting/ValueObject/RectorWithLineChange.php b/packages/ChangesReporting/ValueObject/RectorWithLineChange.php index d95bfec2d00..5622d850eef 100644 --- a/packages/ChangesReporting/ValueObject/RectorWithLineChange.php +++ b/packages/ChangesReporting/ValueObject/RectorWithLineChange.php @@ -6,7 +6,7 @@ namespace Rector\ChangesReporting\ValueObject; use Rector\Core\Contract\Rector\RectorInterface; use RectorPrefix20220607\Symplify\EasyParallel\Contract\SerializableInterface; use RectorPrefix20220607\Webmozart\Assert\Assert; -final class RectorWithLineChange implements \RectorPrefix20220607\Symplify\EasyParallel\Contract\SerializableInterface +final class RectorWithLineChange implements SerializableInterface { /** * @var string @@ -32,7 +32,7 @@ final class RectorWithLineChange implements \RectorPrefix20220607\Symplify\EasyP public function __construct($rectorClass, int $line) { $this->line = $line; - if ($rectorClass instanceof \Rector\Core\Contract\Rector\RectorInterface) { + if ($rectorClass instanceof RectorInterface) { $rectorClass = \get_class($rectorClass); } $this->rectorClass = $rectorClass; @@ -55,9 +55,9 @@ final class RectorWithLineChange implements \RectorPrefix20220607\Symplify\EasyP public static function decode(array $json) : \RectorPrefix20220607\Symplify\EasyParallel\Contract\SerializableInterface { $rectorClass = $json[self::KEY_RECTOR_CLASS]; - \RectorPrefix20220607\Webmozart\Assert\Assert::string($rectorClass); + Assert::string($rectorClass); $line = $json[self::KEY_LINE]; - \RectorPrefix20220607\Webmozart\Assert\Assert::integer($line); + Assert::integer($line); return new self($rectorClass, $line); } /** diff --git a/packages/ChangesReporting/ValueObjectFactory/ErrorFactory.php b/packages/ChangesReporting/ValueObjectFactory/ErrorFactory.php index 850147c5d7d..af6ac5fec0f 100644 --- a/packages/ChangesReporting/ValueObjectFactory/ErrorFactory.php +++ b/packages/ChangesReporting/ValueObjectFactory/ErrorFactory.php @@ -6,7 +6,7 @@ namespace Rector\ChangesReporting\ValueObjectFactory; use PHPStan\AnalysedCodeException; use Rector\Core\Error\ExceptionCorrector; use Rector\Core\ValueObject\Error\SystemError; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class ErrorFactory { /** @@ -14,13 +14,13 @@ final class ErrorFactory * @var \Rector\Core\Error\ExceptionCorrector */ private $exceptionCorrector; - public function __construct(\Rector\Core\Error\ExceptionCorrector $exceptionCorrector) + public function __construct(ExceptionCorrector $exceptionCorrector) { $this->exceptionCorrector = $exceptionCorrector; } - public function createAutoloadError(\PHPStan\AnalysedCodeException $analysedCodeException, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : \Rector\Core\ValueObject\Error\SystemError + public function createAutoloadError(AnalysedCodeException $analysedCodeException, SmartFileInfo $smartFileInfo) : SystemError { $message = $this->exceptionCorrector->getAutoloadExceptionMessageAndAddLocation($analysedCodeException); - return new \Rector\Core\ValueObject\Error\SystemError($message, $smartFileInfo->getRelativeFilePathFromCwd()); + return new SystemError($message, $smartFileInfo->getRelativeFilePathFromCwd()); } } diff --git a/packages/ChangesReporting/ValueObjectFactory/FileDiffFactory.php b/packages/ChangesReporting/ValueObjectFactory/FileDiffFactory.php index 279adddafb7..9db3da5305f 100644 --- a/packages/ChangesReporting/ValueObjectFactory/FileDiffFactory.php +++ b/packages/ChangesReporting/ValueObjectFactory/FileDiffFactory.php @@ -19,14 +19,14 @@ final class FileDiffFactory * @var \Symplify\PackageBuilder\Console\Output\ConsoleDiffer */ private $consoleDiffer; - public function __construct(\Rector\Core\Differ\DefaultDiffer $defaultDiffer, \RectorPrefix20220607\Symplify\PackageBuilder\Console\Output\ConsoleDiffer $consoleDiffer) + public function __construct(DefaultDiffer $defaultDiffer, ConsoleDiffer $consoleDiffer) { $this->defaultDiffer = $defaultDiffer; $this->consoleDiffer = $consoleDiffer; } - public function createFileDiff(\Rector\Core\ValueObject\Application\File $file, string $oldContent, string $newContent) : \Rector\Core\ValueObject\Reporting\FileDiff + public function createFileDiff(File $file, string $oldContent, string $newContent) : FileDiff { // always keep the most recent diff - return new \Rector\Core\ValueObject\Reporting\FileDiff($file->getRelativeFilePath(), $this->defaultDiffer->diff($oldContent, $newContent), $this->consoleDiffer->diff($oldContent, $newContent), $file->getRectorWithLineChanges()); + return new FileDiff($file->getRelativeFilePath(), $this->defaultDiffer->diff($oldContent, $newContent), $this->consoleDiffer->diff($oldContent, $newContent), $file->getRectorWithLineChanges()); } } diff --git a/packages/Comments/CommentRemover.php b/packages/Comments/CommentRemover.php index a4ad8e8ffbc..853bc925eed 100644 --- a/packages/Comments/CommentRemover.php +++ b/packages/Comments/CommentRemover.php @@ -15,7 +15,7 @@ final class CommentRemover * @var \Rector\Comments\NodeTraverser\CommentRemovingNodeTraverser */ private $commentRemovingNodeTraverser; - public function __construct(\Rector\Comments\NodeTraverser\CommentRemovingNodeTraverser $commentRemovingNodeTraverser) + public function __construct(CommentRemovingNodeTraverser $commentRemovingNodeTraverser) { $this->commentRemovingNodeTraverser = $commentRemovingNodeTraverser; } diff --git a/packages/Comments/NodeDocBlock/DocBlockUpdater.php b/packages/Comments/NodeDocBlock/DocBlockUpdater.php index e84cf6c8dd9..9b07d2ab883 100644 --- a/packages/Comments/NodeDocBlock/DocBlockUpdater.php +++ b/packages/Comments/NodeDocBlock/DocBlockUpdater.php @@ -20,15 +20,15 @@ final class DocBlockUpdater * @var \Rector\BetterPhpDocParser\Printer\PhpDocInfoPrinter */ private $phpDocInfoPrinter; - public function __construct(\Rector\BetterPhpDocParser\Printer\PhpDocInfoPrinter $phpDocInfoPrinter) + public function __construct(PhpDocInfoPrinter $phpDocInfoPrinter) { $this->phpDocInfoPrinter = $phpDocInfoPrinter; } - public function updateNodeWithPhpDocInfo(\PhpParser\Node $node) : void + public function updateNodeWithPhpDocInfo(Node $node) : void { // nothing to change? don't save it - $phpDocInfo = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO); - if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + $phpDocInfo = $node->getAttribute(AttributeKey::PHP_DOC_INFO); + if (!$phpDocInfo instanceof PhpDocInfo) { return; } if (!$phpDocInfo->hasChanged()) { @@ -44,14 +44,14 @@ final class DocBlockUpdater } if ($phpDocInfo->getOriginalPhpDocNode()->children !== []) { // all comments were removed → null - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, null); + $node->setAttribute(AttributeKey::COMMENTS, null); } return; } // this is needed to remove duplicated // commentsAsText - $node->setDocComment(new \PhpParser\Comment\Doc($phpDoc)); + $node->setDocComment(new Doc($phpDoc)); } - private function printPhpDocInfoToString(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : string + private function printPhpDocInfoToString(PhpDocInfo $phpDocInfo) : string { if ($phpDocInfo->isNewNode()) { return $this->phpDocInfoPrinter->printNew($phpDocInfo); diff --git a/packages/Comments/NodeTraverser/CommentRemovingNodeTraverser.php b/packages/Comments/NodeTraverser/CommentRemovingNodeTraverser.php index e4aa38323cd..868e8b47d06 100644 --- a/packages/Comments/NodeTraverser/CommentRemovingNodeTraverser.php +++ b/packages/Comments/NodeTraverser/CommentRemovingNodeTraverser.php @@ -5,9 +5,9 @@ namespace Rector\Comments\NodeTraverser; use PhpParser\NodeTraverser; use Rector\Comments\NodeVisitor\CommentRemovingNodeVisitor; -final class CommentRemovingNodeTraverser extends \PhpParser\NodeTraverser +final class CommentRemovingNodeTraverser extends NodeTraverser { - public function __construct(\Rector\Comments\NodeVisitor\CommentRemovingNodeVisitor $commentRemovingNodeVisitor) + public function __construct(CommentRemovingNodeVisitor $commentRemovingNodeVisitor) { $this->addVisitor($commentRemovingNodeVisitor); } diff --git a/packages/Comments/NodeVisitor/CommentRemovingNodeVisitor.php b/packages/Comments/NodeVisitor/CommentRemovingNodeVisitor.php index 623b178008b..58aeb381937 100644 --- a/packages/Comments/NodeVisitor/CommentRemovingNodeVisitor.php +++ b/packages/Comments/NodeVisitor/CommentRemovingNodeVisitor.php @@ -6,14 +6,14 @@ namespace Rector\Comments\NodeVisitor; use PhpParser\Node; use PhpParser\NodeVisitorAbstract; use Rector\NodeTypeResolver\Node\AttributeKey; -final class CommentRemovingNodeVisitor extends \PhpParser\NodeVisitorAbstract +final class CommentRemovingNodeVisitor extends NodeVisitorAbstract { - public function enterNode(\PhpParser\Node $node) : \PhpParser\Node + public function enterNode(Node $node) : Node { // the node must be cloned, so original node is not touched in final print $clonedNode = clone $node; - $clonedNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, []); - $clonedNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, null); + $clonedNode->setAttribute(AttributeKey::COMMENTS, []); + $clonedNode->setAttribute(AttributeKey::PHP_DOC_INFO, null); return $clonedNode; } } diff --git a/packages/Config/RectorConfig.php b/packages/Config/RectorConfig.php index 5e5e9b5a59a..f6a8f2a55fb 100644 --- a/packages/Config/RectorConfig.php +++ b/packages/Config/RectorConfig.php @@ -9,47 +9,47 @@ use Rector\Core\Configuration\ValueObjectInliner; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Contract\Rector\RectorInterface; use Rector\Core\ValueObject\PhpVersion; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @api * Same as Symfony container configurator, with patched return type for "set()" method for easier DX. * It is an alias for internal class that is prefixed during build, so it's basically for keeping stable public API. */ -final class RectorConfig extends \Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator +final class RectorConfig extends ContainerConfigurator { /** * @param string[] $paths */ public function paths(array $paths) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($paths); + Assert::allString($paths); $parameters = $this->parameters(); - $parameters->set(\Rector\Core\Configuration\Option::PATHS, $paths); + $parameters->set(Option::PATHS, $paths); } /** * @param string[] $sets */ public function sets(array $sets) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($sets); + Assert::allString($sets); foreach ($sets as $set) { - \RectorPrefix20220607\Webmozart\Assert\Assert::fileExists($set); + Assert::fileExists($set); $this->import($set); } } public function disableParallel() : void { $parameters = $this->parameters(); - $parameters->set(\Rector\Core\Configuration\Option::PARALLEL, \false); + $parameters->set(Option::PARALLEL, \false); } public function parallel(int $seconds = 120, int $maxNumberOfProcess = 16, int $jobSize = 20) : void { $parameters = $this->parameters(); - $parameters->set(\Rector\Core\Configuration\Option::PARALLEL, \true); - $parameters->set(\Rector\Core\Configuration\Option::PARALLEL_TIMEOUT_IN_SECONDS, $seconds); - $parameters->set(\Rector\Core\Configuration\Option::PARALLEL_MAX_NUMBER_OF_PROCESSES, $maxNumberOfProcess); - $parameters->set(\Rector\Core\Configuration\Option::PARALLEL_JOB_SIZE, $jobSize); + $parameters->set(Option::PARALLEL, \true); + $parameters->set(Option::PARALLEL_TIMEOUT_IN_SECONDS, $seconds); + $parameters->set(Option::PARALLEL_MAX_NUMBER_OF_PROCESSES, $maxNumberOfProcess); + $parameters->set(Option::PARALLEL_JOB_SIZE, $jobSize); } /** * @param array $criteria @@ -57,27 +57,27 @@ final class RectorConfig extends \Symfony\Component\DependencyInjection\Loader\C public function skip(array $criteria) : void { $parameters = $this->parameters(); - $parameters->set(\Rector\Core\Configuration\Option::SKIP, $criteria); + $parameters->set(Option::SKIP, $criteria); } public function importNames() : void { $parameters = $this->parameters(); - $parameters->set(\Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES, \true); + $parameters->set(Option::AUTO_IMPORT_NAMES, \true); } public function importShortClasses() : void { $parameters = $this->parameters(); - $parameters->set(\Rector\Core\Configuration\Option::IMPORT_SHORT_CLASSES, \true); + $parameters->set(Option::IMPORT_SHORT_CLASSES, \true); } public function disableImportShortClasses() : void { $parameters = $this->parameters(); - $parameters->set(\Rector\Core\Configuration\Option::IMPORT_SHORT_CLASSES, \false); + $parameters->set(Option::IMPORT_SHORT_CLASSES, \false); } public function disableImportNames() : void { $parameters = $this->parameters(); - $parameters->set(\Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES, \false); + $parameters->set(Option::AUTO_IMPORT_NAMES, \false); } /** * Set PHPStan custom config to load extensions and custom configuration to Rector. @@ -85,9 +85,9 @@ final class RectorConfig extends \Symfony\Component\DependencyInjection\Loader\C */ public function phpstanConfig(string $filePath) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::fileExists($filePath); + Assert::fileExists($filePath); $parameters = $this->parameters(); - $parameters->set(\Rector\Core\Configuration\Option::PHPSTAN_FOR_RECTOR_PATH, $filePath); + $parameters->set(Option::PHPSTAN_FOR_RECTOR_PATH, $filePath); } /** * @param class-string $rectorClass @@ -95,14 +95,14 @@ final class RectorConfig extends \Symfony\Component\DependencyInjection\Loader\C */ public function ruleWithConfiguration(string $rectorClass, array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::classExists($rectorClass); - \RectorPrefix20220607\Webmozart\Assert\Assert::isAOf($rectorClass, \Rector\Core\Contract\Rector\RectorInterface::class); - \RectorPrefix20220607\Webmozart\Assert\Assert::isAOf($rectorClass, \Rector\Core\Contract\Rector\ConfigurableRectorInterface::class); + Assert::classExists($rectorClass); + Assert::isAOf($rectorClass, RectorInterface::class); + Assert::isAOf($rectorClass, ConfigurableRectorInterface::class); $services = $this->services(); // decorate with value object inliner so Symfony understands, see https://getrector.org/blog/2020/09/07/how-to-inline-value-object-in-symfony-php-config \array_walk_recursive($configuration, function (&$value) { if (\is_object($value)) { - $value = \Rector\Core\Configuration\ValueObjectInliner::inline($value); + $value = ValueObjectInliner::inline($value); } return $value; }); @@ -113,8 +113,8 @@ final class RectorConfig extends \Symfony\Component\DependencyInjection\Loader\C */ public function rule(string $rectorClass) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::classExists($rectorClass); - \RectorPrefix20220607\Webmozart\Assert\Assert::isAOf($rectorClass, \Rector\Core\Contract\Rector\RectorInterface::class); + Assert::classExists($rectorClass); + Assert::isAOf($rectorClass, RectorInterface::class); $services = $this->services(); $services->set($rectorClass); } @@ -123,7 +123,7 @@ final class RectorConfig extends \Symfony\Component\DependencyInjection\Loader\C */ public function rules(array $rectorClasses) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($rectorClasses); + Assert::allString($rectorClasses); foreach ($rectorClasses as $rectorClass) { $this->rule($rectorClass); } @@ -134,63 +134,63 @@ final class RectorConfig extends \Symfony\Component\DependencyInjection\Loader\C public function phpVersion(int $phpVersion) : void { $parameters = $this->parameters(); - $parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, $phpVersion); + $parameters->set(Option::PHP_VERSION_FEATURES, $phpVersion); } /** * @param string[] $autoloadPaths */ public function autoloadPaths(array $autoloadPaths) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($autoloadPaths); + Assert::allString($autoloadPaths); $parameters = $this->parameters(); - $parameters->set(\Rector\Core\Configuration\Option::AUTOLOAD_PATHS, $autoloadPaths); + $parameters->set(Option::AUTOLOAD_PATHS, $autoloadPaths); } /** * @param string[] $bootstrapFiles */ public function bootstrapFiles(array $bootstrapFiles) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($bootstrapFiles); + Assert::allString($bootstrapFiles); $parameters = $this->parameters(); - $parameters->set(\Rector\Core\Configuration\Option::BOOTSTRAP_FILES, $bootstrapFiles); + $parameters->set(Option::BOOTSTRAP_FILES, $bootstrapFiles); } public function symfonyContainerXml(string $filePath) : void { $parameters = $this->parameters(); - $parameters->set(\Rector\Core\Configuration\Option::SYMFONY_CONTAINER_XML_PATH_PARAMETER, $filePath); + $parameters->set(Option::SYMFONY_CONTAINER_XML_PATH_PARAMETER, $filePath); } public function symfonyContainerPhp(string $filePath) : void { $parameters = $this->parameters(); - $parameters->set(\Rector\Core\Configuration\Option::SYMFONY_CONTAINER_PHP_PATH_PARAMETER, $filePath); + $parameters->set(Option::SYMFONY_CONTAINER_PHP_PATH_PARAMETER, $filePath); } /** * @param string[] $extensions */ public function fileExtensions(array $extensions) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($extensions); + Assert::allString($extensions); $parameters = $this->parameters(); - $parameters->set(\Rector\Core\Configuration\Option::FILE_EXTENSIONS, $extensions); + $parameters->set(Option::FILE_EXTENSIONS, $extensions); } public function nestedChainMethodCallLimit(int $limit) : void { $parameters = $this->parameters(); - $parameters->set(\Rector\Core\Configuration\Option::NESTED_CHAIN_METHOD_CALL_LIMIT, $limit); + $parameters->set(Option::NESTED_CHAIN_METHOD_CALL_LIMIT, $limit); } public function cacheDirectory(string $directoryPath) : void { $parameters = $this->parameters(); - $parameters->set(\Rector\Core\Configuration\Option::CACHE_DIR, $directoryPath); + $parameters->set(Option::CACHE_DIR, $directoryPath); } /** * @param class-string $cacheClass */ public function cacheClass(string $cacheClass) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::isAOf($cacheClass, \Rector\Caching\Contract\ValueObject\Storage\CacheStorageInterface::class); + Assert::isAOf($cacheClass, CacheStorageInterface::class); $parameters = $this->parameters(); - $parameters->set(\Rector\Core\Configuration\Option::CACHE_CLASS, $cacheClass); + $parameters->set(Option::CACHE_CLASS, $cacheClass); } /** * @see https://github.com/nikic/PHP-Parser/issues/723#issuecomment-712401963 @@ -198,7 +198,7 @@ final class RectorConfig extends \Symfony\Component\DependencyInjection\Loader\C public function indent(string $character, int $count) : void { $parameters = $this->parameters(); - $parameters->set(\Rector\Core\Configuration\Option::INDENT_CHAR, $character); - $parameters->set(\Rector\Core\Configuration\Option::INDENT_SIZE, $count); + $parameters->set(Option::INDENT_CHAR, $character); + $parameters->set(Option::INDENT_SIZE, $count); } } diff --git a/packages/Defluent/NodeAnalyzer/FluentChainMethodCallNodeAnalyzer.php b/packages/Defluent/NodeAnalyzer/FluentChainMethodCallNodeAnalyzer.php index ad942af0605..c6dc1eb989c 100644 --- a/packages/Defluent/NodeAnalyzer/FluentChainMethodCallNodeAnalyzer.php +++ b/packages/Defluent/NodeAnalyzer/FluentChainMethodCallNodeAnalyzer.php @@ -21,14 +21,14 @@ final class FluentChainMethodCallNodeAnalyzer * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } /** * @return string[] */ - public function collectMethodCallNamesInChain(\PhpParser\Node\Expr\MethodCall $desiredMethodCall) : array + public function collectMethodCallNamesInChain(MethodCall $desiredMethodCall) : array { $methodCalls = $this->collectAllMethodCallsInChain($desiredMethodCall); $methodNames = []; @@ -44,21 +44,21 @@ final class FluentChainMethodCallNodeAnalyzer /** * @return MethodCall[] */ - public function collectAllMethodCallsInChain(\PhpParser\Node\Expr\MethodCall $methodCall) : array + public function collectAllMethodCallsInChain(MethodCall $methodCall) : array { $chainMethodCalls = [$methodCall]; // traverse up $currentNode = $methodCall->var; - while ($currentNode instanceof \PhpParser\Node\Expr\MethodCall) { + while ($currentNode instanceof MethodCall) { $chainMethodCalls[] = $currentNode; $currentNode = $currentNode->var; } // traverse down if (\count($chainMethodCalls) === 1) { - $currentNode = $methodCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - while ($currentNode instanceof \PhpParser\Node\Expr\MethodCall) { + $currentNode = $methodCall->getAttribute(AttributeKey::PARENT_NODE); + while ($currentNode instanceof MethodCall) { $chainMethodCalls[] = $currentNode; - $currentNode = $currentNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $currentNode = $currentNode->getAttribute(AttributeKey::PARENT_NODE); } } return $chainMethodCalls; @@ -66,21 +66,21 @@ final class FluentChainMethodCallNodeAnalyzer /** * @return \PhpParser\Node\Expr|\PhpParser\Node\Name */ - public function resolveRootExpr(\PhpParser\Node\Expr\MethodCall $methodCall) + public function resolveRootExpr(MethodCall $methodCall) { $callerNode = $methodCall->var; - while ($callerNode instanceof \PhpParser\Node\Expr\MethodCall || $callerNode instanceof \PhpParser\Node\Expr\StaticCall) { - $callerNode = $callerNode instanceof \PhpParser\Node\Expr\StaticCall ? $callerNode->class : $callerNode->var; + while ($callerNode instanceof MethodCall || $callerNode instanceof StaticCall) { + $callerNode = $callerNode instanceof StaticCall ? $callerNode->class : $callerNode->var; } return $callerNode; } - public function resolveRootMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node\Expr\MethodCall + public function resolveRootMethodCall(MethodCall $methodCall) : ?MethodCall { $callerNode = $methodCall->var; - while ($callerNode instanceof \PhpParser\Node\Expr\MethodCall && $callerNode->var instanceof \PhpParser\Node\Expr\MethodCall) { + while ($callerNode instanceof MethodCall && $callerNode->var instanceof MethodCall) { $callerNode = $callerNode->var; } - if ($callerNode instanceof \PhpParser\Node\Expr\MethodCall) { + if ($callerNode instanceof MethodCall) { return $callerNode; } return null; diff --git a/packages/Defluent/NodeAnalyzer/SameClassMethodCallAnalyzer.php b/packages/Defluent/NodeAnalyzer/SameClassMethodCallAnalyzer.php index b53f087a5ae..fa40b5a0109 100644 --- a/packages/Defluent/NodeAnalyzer/SameClassMethodCallAnalyzer.php +++ b/packages/Defluent/NodeAnalyzer/SameClassMethodCallAnalyzer.php @@ -13,7 +13,7 @@ final class SameClassMethodCallAnalyzer * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(ReflectionResolver $reflectionResolver) { $this->reflectionResolver = $reflectionResolver; } @@ -26,7 +26,7 @@ final class SameClassMethodCallAnalyzer $classOfClassMethod = []; foreach ($chainMethodCalls as $chainMethodCall) { $methodReflection = $this->reflectionResolver->resolveMethodReflectionFromMethodCall($chainMethodCall); - if ($methodReflection instanceof \PHPStan\Reflection\MethodReflection) { + if ($methodReflection instanceof MethodReflection) { $declaringClass = $methodReflection->getDeclaringClass(); $classOfClassMethod[] = $declaringClass->getName(); } else { diff --git a/packages/FamilyTree/NodeAnalyzer/ClassChildAnalyzer.php b/packages/FamilyTree/NodeAnalyzer/ClassChildAnalyzer.php index 9611531f59e..7a84a572843 100644 --- a/packages/FamilyTree/NodeAnalyzer/ClassChildAnalyzer.php +++ b/packages/FamilyTree/NodeAnalyzer/ClassChildAnalyzer.php @@ -16,11 +16,11 @@ final class ClassChildAnalyzer * @var \Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer */ private $familyRelationsAnalyzer; - public function __construct(\Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer $familyRelationsAnalyzer) + public function __construct(FamilyRelationsAnalyzer $familyRelationsAnalyzer) { $this->familyRelationsAnalyzer = $familyRelationsAnalyzer; } - public function hasChildClassMethod(\PHPStan\Reflection\ClassReflection $classReflection, string $methodName) : bool + public function hasChildClassMethod(ClassReflection $classReflection, string $methodName) : bool { $childrenClassReflections = $this->familyRelationsAnalyzer->getChildrenOfClassReflection($classReflection); foreach ($childrenClassReflections as $childClassReflection) { @@ -28,7 +28,7 @@ final class ClassChildAnalyzer continue; } $constructorReflectionMethod = $childClassReflection->getNativeMethod($methodName); - if (!$constructorReflectionMethod instanceof \PHPStan\Reflection\Php\PhpMethodReflection) { + if (!$constructorReflectionMethod instanceof PhpMethodReflection) { continue; } $methodDeclaringClassReflection = $constructorReflectionMethod->getDeclaringClass(); @@ -38,14 +38,14 @@ final class ClassChildAnalyzer } return \false; } - public function hasParentClassMethod(\PHPStan\Reflection\ClassReflection $classReflection, string $methodName) : bool + public function hasParentClassMethod(ClassReflection $classReflection, string $methodName) : bool { return $this->resolveParentClassMethods($classReflection, $methodName) !== []; } /** * Look both parent class and interface, yes, all PHP interface methods are abstract */ - public function hasAbstractParentClassMethod(\PHPStan\Reflection\ClassReflection $classReflection, string $methodName) : bool + public function hasAbstractParentClassMethod(ClassReflection $classReflection, string $methodName) : bool { $parentClassMethods = $this->resolveParentClassMethods($classReflection, $methodName); if ($parentClassMethods === []) { @@ -58,25 +58,25 @@ final class ClassChildAnalyzer } return \false; } - public function resolveParentClassMethodReturnType(\PHPStan\Reflection\ClassReflection $classReflection, string $methodName) : \PHPStan\Type\Type + public function resolveParentClassMethodReturnType(ClassReflection $classReflection, string $methodName) : Type { $parentClassMethods = $this->resolveParentClassMethods($classReflection, $methodName); if ($parentClassMethods === []) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } foreach ($parentClassMethods as $parentClassMethod) { - $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($parentClassMethod->getVariants()); + $parametersAcceptor = ParametersAcceptorSelector::selectSingle($parentClassMethod->getVariants()); $nativeReturnType = $parametersAcceptor->getNativeReturnType(); - if (!$nativeReturnType instanceof \PHPStan\Type\MixedType) { + if (!$nativeReturnType instanceof MixedType) { return $nativeReturnType; } } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } /** * @return PhpMethodReflection[] */ - public function resolveParentClassMethods(\PHPStan\Reflection\ClassReflection $classReflection, string $methodName) : array + public function resolveParentClassMethods(ClassReflection $classReflection, string $methodName) : array { $parentClassMethods = []; $parents = \array_merge($classReflection->getParents(), $classReflection->getInterfaces()); @@ -85,7 +85,7 @@ final class ClassChildAnalyzer continue; } $methodReflection = $parent->getNativeMethod($methodName); - if (!$methodReflection instanceof \PHPStan\Reflection\Php\PhpMethodReflection) { + if (!$methodReflection instanceof PhpMethodReflection) { continue; } $methodDeclaringMethodClass = $methodReflection->getDeclaringClass(); diff --git a/packages/FamilyTree/Reflection/FamilyRelationsAnalyzer.php b/packages/FamilyTree/Reflection/FamilyRelationsAnalyzer.php index 338a19049e9..20a0ce24cf5 100644 --- a/packages/FamilyTree/Reflection/FamilyRelationsAnalyzer.php +++ b/packages/FamilyTree/Reflection/FamilyRelationsAnalyzer.php @@ -60,7 +60,7 @@ final class FamilyRelationsAnalyzer * @var \Rector\Core\PhpParser\AstResolver */ private $astResolver; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider, \RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor $privatesAccessor, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\Core\PhpParser\AstResolver $astResolver) + public function __construct(ReflectionProvider $reflectionProvider, PrivatesAccessor $privatesAccessor, NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder, StaticTypeMapper $staticTypeMapper, AstResolver $astResolver) { $this->reflectionProvider = $reflectionProvider; $this->privatesAccessor = $privatesAccessor; @@ -72,7 +72,7 @@ final class FamilyRelationsAnalyzer /** * @return ClassReflection[] */ - public function getChildrenOfClassReflection(\PHPStan\Reflection\ClassReflection $desiredClassReflection) : array + public function getChildrenOfClassReflection(ClassReflection $desiredClassReflection) : array { /** @var ClassReflection[] $classReflections */ $classReflections = $this->privatesAccessor->getPrivateProperty($this->reflectionProvider, 'classes'); @@ -88,17 +88,17 @@ final class FamilyRelationsAnalyzer /** * @param \PhpParser\Node\Name|\PhpParser\Node\ComplexType|null $propertyTypeNode */ - public function getPossibleUnionPropertyType(\PhpParser\Node\Stmt\Property $property, \PHPStan\Type\Type $varType, ?\PHPStan\Analyser\Scope $scope, $propertyTypeNode) : \Rector\FamilyTree\ValueObject\PropertyType + public function getPossibleUnionPropertyType(Property $property, Type $varType, ?Scope $scope, $propertyTypeNode) : PropertyType { - if ($varType instanceof \PHPStan\Type\UnionType) { - return new \Rector\FamilyTree\ValueObject\PropertyType($varType, $propertyTypeNode); + if ($varType instanceof UnionType) { + return new PropertyType($varType, $propertyTypeNode); } - if (!$scope instanceof \PHPStan\Analyser\Scope) { - return new \Rector\FamilyTree\ValueObject\PropertyType($varType, $propertyTypeNode); + if (!$scope instanceof Scope) { + return new PropertyType($varType, $propertyTypeNode); } $classReflection = $scope->getClassReflection(); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$classReflection instanceof ClassReflection) { + throw new ShouldNotHappenException(); } $ancestorClassReflections = \array_merge($classReflection->getParents(), $classReflection->getInterfaces()); $propertyName = $this->nodeNameResolver->getName($property); @@ -109,17 +109,17 @@ final class FamilyRelationsAnalyzer continue; } $class = $this->astResolver->resolveClassFromClassReflection($ancestorClassReflection, $ancestorClassName); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + if (!$class instanceof Class_) { continue; } if (!$this->isPropertyWritten($class->stmts, $propertyName, $kindPropertyFetch)) { continue; } - $varType = new \PHPStan\Type\UnionType([$varType, new \PHPStan\Type\NullType()]); - $propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($varType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY); - return new \Rector\FamilyTree\ValueObject\PropertyType($varType, $propertyTypeNode); + $varType = new UnionType([$varType, new NullType()]); + $propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($varType, TypeKind::PROPERTY); + return new PropertyType($varType, $propertyTypeNode); } - return new \Rector\FamilyTree\ValueObject\PropertyType($varType, $propertyTypeNode); + return new PropertyType($varType, $propertyTypeNode); } /** * @return string[] @@ -128,20 +128,20 @@ final class FamilyRelationsAnalyzer public function getClassLikeAncestorNames($classOrName) : array { $ancestorNames = []; - if ($classOrName instanceof \PhpParser\Node\Name) { + if ($classOrName instanceof Name) { $fullName = $this->nodeNameResolver->getName($classOrName); $classLike = $this->astResolver->resolveClassFromName($fullName); } else { $classLike = $classOrName; } - if ($classLike instanceof \PhpParser\Node\Stmt\Interface_) { + if ($classLike instanceof Interface_) { foreach ($classLike->extends as $extendInterfaceName) { $ancestorNames[] = $this->nodeNameResolver->getName($extendInterfaceName); $ancestorNames = \array_merge($ancestorNames, $this->getClassLikeAncestorNames($extendInterfaceName)); } } - if ($classLike instanceof \PhpParser\Node\Stmt\Class_) { - if ($classLike->extends instanceof \PhpParser\Node\Name) { + if ($classLike instanceof Class_) { + if ($classLike->extends instanceof Name) { $ancestorNames[] = $this->nodeNameResolver->getName($classLike->extends); $ancestorNames = \array_merge($ancestorNames, $this->getClassLikeAncestorNames($classLike->extends)); } @@ -153,17 +153,17 @@ final class FamilyRelationsAnalyzer /** @var string[] $ancestorNames */ return $ancestorNames; } - private function getKindPropertyFetch(\PhpParser\Node\Stmt\Property $property) : string + private function getKindPropertyFetch(Property $property) : string { - return $property->isStatic() ? \PhpParser\Node\Expr\StaticPropertyFetch::class : \PhpParser\Node\Expr\PropertyFetch::class; + return $property->isStatic() ? StaticPropertyFetch::class : PropertyFetch::class; } /** * @param Stmt[] $stmts */ private function isPropertyWritten(array $stmts, string $propertyName, string $kindPropertyFetch) : bool { - return (bool) $this->betterNodeFinder->findFirst($stmts, function (\PhpParser\Node $node) use($propertyName, $kindPropertyFetch) : bool { - if (!$node instanceof \PhpParser\Node\Stmt\ClassMethod) { + return (bool) $this->betterNodeFinder->findFirst($stmts, function (Node $node) use($propertyName, $kindPropertyFetch) : bool { + if (!$node instanceof ClassMethod) { return \false; } if ($this->nodeNameResolver->isName($node->name, 'autowire')) { @@ -172,13 +172,13 @@ final class FamilyRelationsAnalyzer return $this->isPropertyAssignedInClassMethod($node, $propertyName, $kindPropertyFetch); }); } - private function isPropertyAssignedInClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $propertyName, string $kindPropertyFetch) : bool + private function isPropertyAssignedInClassMethod(ClassMethod $classMethod, string $propertyName, string $kindPropertyFetch) : bool { if ($classMethod->stmts === null) { return \false; } - return (bool) $this->betterNodeFinder->findFirst($classMethod->stmts, function (\PhpParser\Node $node) use($propertyName, $kindPropertyFetch) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + return (bool) $this->betterNodeFinder->findFirst($classMethod->stmts, function (Node $node) use($propertyName, $kindPropertyFetch) : bool { + if (!$node instanceof Assign) { return \false; } return $kindPropertyFetch === \get_class($node->var) && $this->nodeNameResolver->isName($node->var, $propertyName); diff --git a/packages/FamilyTree/ValueObject/PropertyType.php b/packages/FamilyTree/ValueObject/PropertyType.php index 70d124969b8..e7fb76c8888 100644 --- a/packages/FamilyTree/ValueObject/PropertyType.php +++ b/packages/FamilyTree/ValueObject/PropertyType.php @@ -21,12 +21,12 @@ final class PropertyType /** * @param \PhpParser\Node\Name|\PhpParser\Node\ComplexType|null $propertyTypeNode */ - public function __construct(\PHPStan\Type\Type $varType, $propertyTypeNode) + public function __construct(Type $varType, $propertyTypeNode) { $this->varType = $varType; $this->propertyTypeNode = $propertyTypeNode; } - public function getVarType() : \PHPStan\Type\Type + public function getVarType() : Type { return $this->varType; } diff --git a/packages/FileSystemRector/Parser/FileInfoParser.php b/packages/FileSystemRector/Parser/FileInfoParser.php index fa59b316be7..15564be660b 100644 --- a/packages/FileSystemRector/Parser/FileInfoParser.php +++ b/packages/FileSystemRector/Parser/FileInfoParser.php @@ -8,7 +8,7 @@ use Rector\Core\PhpParser\NodeTraverser\FileWithoutNamespaceNodeTraverser; use Rector\Core\PhpParser\Parser\RectorParser; use Rector\Core\ValueObject\Application\File; use Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class FileInfoParser { /** @@ -26,7 +26,7 @@ final class FileInfoParser * @var \Rector\Core\PhpParser\Parser\RectorParser */ private $rectorParser; - public function __construct(\Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator, \Rector\Core\PhpParser\NodeTraverser\FileWithoutNamespaceNodeTraverser $fileWithoutNamespaceNodeTraverser, \Rector\Core\PhpParser\Parser\RectorParser $rectorParser) + public function __construct(NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator, FileWithoutNamespaceNodeTraverser $fileWithoutNamespaceNodeTraverser, RectorParser $rectorParser) { $this->nodeScopeAndMetadataDecorator = $nodeScopeAndMetadataDecorator; $this->fileWithoutNamespaceNodeTraverser = $fileWithoutNamespaceNodeTraverser; @@ -35,11 +35,11 @@ final class FileInfoParser /** * @return Stmt[] */ - public function parseFileInfoToNodesAndDecorate(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : array + public function parseFileInfoToNodesAndDecorate(SmartFileInfo $smartFileInfo) : array { $stmts = $this->rectorParser->parseFile($smartFileInfo); $stmts = $this->fileWithoutNamespaceNodeTraverser->traverse($stmts); - $file = new \Rector\Core\ValueObject\Application\File($smartFileInfo, $smartFileInfo->getContents()); + $file = new File($smartFileInfo, $smartFileInfo->getContents()); return $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($file, $stmts); } } diff --git a/packages/FileSystemRector/ValueObject/AddedFileWithContent.php b/packages/FileSystemRector/ValueObject/AddedFileWithContent.php index b24acc47ae1..beef8262055 100644 --- a/packages/FileSystemRector/ValueObject/AddedFileWithContent.php +++ b/packages/FileSystemRector/ValueObject/AddedFileWithContent.php @@ -5,7 +5,7 @@ namespace Rector\FileSystemRector\ValueObject; use Rector\Core\Exception\ShouldNotHappenException; use Rector\FileSystemRector\Contract\AddedFileInterface; -final class AddedFileWithContent implements \Rector\FileSystemRector\Contract\AddedFileInterface +final class AddedFileWithContent implements AddedFileInterface { /** * @readonly @@ -22,14 +22,14 @@ final class AddedFileWithContent implements \Rector\FileSystemRector\Contract\Ad $this->filePath = $filePath; $this->fileContent = $fileContent; if ($filePath === $fileContent) { - throw new \Rector\Core\Exception\ShouldNotHappenException('File path and content are the same, probably a bug'); + throw new ShouldNotHappenException('File path and content are the same, probably a bug'); } } public function getRealPath() : string { $realpath = \realpath($this->filePath); if ($realpath === \false) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } return $realpath; } diff --git a/packages/FileSystemRector/ValueObject/AddedFileWithNodes.php b/packages/FileSystemRector/ValueObject/AddedFileWithNodes.php index ef85d11b1fb..78c8039037e 100644 --- a/packages/FileSystemRector/ValueObject/AddedFileWithNodes.php +++ b/packages/FileSystemRector/ValueObject/AddedFileWithNodes.php @@ -6,7 +6,7 @@ namespace Rector\FileSystemRector\ValueObject; use PhpParser\Node; use Rector\FileSystemRector\Contract\AddedFileInterface; use Rector\FileSystemRector\Contract\FileWithNodesInterface; -final class AddedFileWithNodes implements \Rector\FileSystemRector\Contract\AddedFileInterface, \Rector\FileSystemRector\Contract\FileWithNodesInterface +final class AddedFileWithNodes implements AddedFileInterface, FileWithNodesInterface { /** * @readonly diff --git a/packages/NodeCollector/BinaryOpConditionsCollector.php b/packages/NodeCollector/BinaryOpConditionsCollector.php index 1b39ae5a630..36d85e0b734 100644 --- a/packages/NodeCollector/BinaryOpConditionsCollector.php +++ b/packages/NodeCollector/BinaryOpConditionsCollector.php @@ -22,7 +22,7 @@ final class BinaryOpConditionsCollector * @param class-string $binaryOpClass * @return array */ - public function findConditions(\PhpParser\Node\Expr $expr, string $binaryOpClass) : array + public function findConditions(Expr $expr, string $binaryOpClass) : array { if (\get_class($expr) !== $binaryOpClass) { // Different binary operators, as well as non-BinaryOp expressions @@ -31,7 +31,7 @@ final class BinaryOpConditionsCollector } $conditions = []; /** @var BinaryOp|Expr $expr */ - while ($expr instanceof \PhpParser\Node\Expr\BinaryOp) { + while ($expr instanceof BinaryOp) { $conditions[] = $expr->right; $expr = $expr->left; if ($binaryOpClass !== \get_class($expr)) { diff --git a/packages/NodeCollector/BinaryOpTreeRootLocator.php b/packages/NodeCollector/BinaryOpTreeRootLocator.php index 9b81246dc09..810f3845341 100644 --- a/packages/NodeCollector/BinaryOpTreeRootLocator.php +++ b/packages/NodeCollector/BinaryOpTreeRootLocator.php @@ -20,10 +20,10 @@ final class BinaryOpTreeRootLocator * * @param class-string $binaryOpClass */ - public function findOperationRoot(\PhpParser\Node\Expr $expr, string $binaryOpClass) : \PhpParser\Node\Expr + public function findOperationRoot(Expr $expr, string $binaryOpClass) : Expr { - $parentNode = $expr->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node) { + $parentNode = $expr->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof Node) { // No more parents so the Expr node must be root. return $expr; } diff --git a/packages/NodeCollector/NodeAnalyzer/ArrayCallableMethodMatcher.php b/packages/NodeCollector/NodeAnalyzer/ArrayCallableMethodMatcher.php index f11354639b6..d72f3c08922 100644 --- a/packages/NodeCollector/NodeAnalyzer/ArrayCallableMethodMatcher.php +++ b/packages/NodeCollector/NodeAnalyzer/ArrayCallableMethodMatcher.php @@ -54,7 +54,7 @@ final class ArrayCallableMethodMatcher * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver, ValueResolver $valueResolver, ReflectionProvider $reflectionProvider, BetterNodeFinder $betterNodeFinder) { $this->nodeNameResolver = $nodeNameResolver; $this->nodeTypeResolver = $nodeTypeResolver; @@ -69,7 +69,7 @@ final class ArrayCallableMethodMatcher * @see https://github.com/rectorphp/rector-src/pull/909 * @return null|\Rector\NodeCollector\ValueObject\ArrayCallableDynamicMethod|\Rector\NodeCollector\ValueObject\ArrayCallable */ - public function match(\PhpParser\Node\Expr\Array_ $array) + public function match(Array_ $array) { if (\count($array->items) !== 2) { return null; @@ -81,11 +81,11 @@ final class ArrayCallableMethodMatcher $items = $array->items; // $this, self, static, FQN $firstItemValue = $items[0]->value; - $calleeType = $firstItemValue instanceof \PhpParser\Node\Expr\ClassConstFetch ? $this->resolveClassConstFetchType($firstItemValue) : $this->nodeTypeResolver->getType($firstItemValue); - if (!$calleeType instanceof \PHPStan\Type\TypeWithClassName) { + $calleeType = $firstItemValue instanceof ClassConstFetch ? $this->resolveClassConstFetchType($firstItemValue) : $this->nodeTypeResolver->getType($firstItemValue); + if (!$calleeType instanceof TypeWithClassName) { return null; } - $isInAttribute = (bool) $this->betterNodeFinder->findParentType($array, \PhpParser\Node\Attribute::class); + $isInAttribute = (bool) $this->betterNodeFinder->findParentType($array, Attribute::class); if ($isInAttribute) { return null; } @@ -93,24 +93,24 @@ final class ArrayCallableMethodMatcher $className = $calleeType->getClassName(); $secondItemValue = $items[1]->value; if ($values === null) { - return new \Rector\NodeCollector\ValueObject\ArrayCallableDynamicMethod($firstItemValue, $className, $secondItemValue); + return new ArrayCallableDynamicMethod($firstItemValue, $className, $secondItemValue); } if ($this->shouldSkipAssociativeArray($values)) { return null; } - if (!$secondItemValue instanceof \PhpParser\Node\Scalar\String_) { + if (!$secondItemValue instanceof String_) { return null; } if ($this->isCallbackAtFunctionNames($array, ['register_shutdown_function', 'forward_static_call'])) { return null; } $methodName = $secondItemValue->value; - if ($methodName === \Rector\Core\ValueObject\MethodName::CONSTRUCT) { + if ($methodName === MethodName::CONSTRUCT) { return null; } - return new \Rector\NodeCollector\ValueObject\ArrayCallable($firstItemValue, $className, $methodName); + return new ArrayCallable($firstItemValue, $className, $methodName); } - private function shouldSkipNullItems(\PhpParser\Node\Expr\Array_ $array) : bool + private function shouldSkipNullItems(Array_ $array) : bool { if ($array->items[0] === null) { return \true; @@ -131,14 +131,14 @@ final class ArrayCallableMethodMatcher /** * @param string[] $functionNames */ - private function isCallbackAtFunctionNames(\PhpParser\Node\Expr\Array_ $array, array $functionNames) : bool + private function isCallbackAtFunctionNames(Array_ $array, array $functionNames) : bool { - $parentNode = $array->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node\Arg) { + $parentNode = $array->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof Arg) { return \false; } - $parentParentNode = $parentNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentParentNode instanceof \PhpParser\Node\Expr\FuncCall) { + $parentParentNode = $parentNode->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentParentNode instanceof FuncCall) { return \false; } return $this->nodeNameResolver->isNames($parentParentNode, $functionNames); @@ -146,39 +146,39 @@ final class ArrayCallableMethodMatcher /** * @return \PHPStan\Type\MixedType|\PHPStan\Type\ObjectType */ - private function resolveClassConstFetchType(\PhpParser\Node\Expr\ClassConstFetch $classConstFetch) + private function resolveClassConstFetchType(ClassConstFetch $classConstFetch) { $classConstantReference = $this->valueResolver->getValue($classConstFetch); - if ($classConstantReference === \Rector\Core\Enum\ObjectReference::STATIC) { - $classLike = $this->betterNodeFinder->findParentType($classConstFetch, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { - return new \PHPStan\Type\MixedType(); + if ($classConstantReference === ObjectReference::STATIC) { + $classLike = $this->betterNodeFinder->findParentType($classConstFetch, Class_::class); + if (!$classLike instanceof ClassLike) { + return new MixedType(); } $classConstantReference = (string) $this->nodeNameResolver->getName($classLike); } // non-class value if (!\is_string($classConstantReference)) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } if (!$this->reflectionProvider->hasClass($classConstantReference)) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } - $scope = $classConstFetch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { - return new \PHPStan\Type\MixedType(); + $scope = $classConstFetch->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { + return new MixedType(); } $classReflection = $this->reflectionProvider->getClass($classConstantReference); - $hasConstruct = $classReflection->hasMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); + $hasConstruct = $classReflection->hasMethod(MethodName::CONSTRUCT); if (!$hasConstruct) { - return new \PHPStan\Type\ObjectType($classConstantReference, null, $classReflection); + return new ObjectType($classConstantReference, null, $classReflection); } - $methodReflection = $classReflection->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT, $scope); - $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); + $methodReflection = $classReflection->getMethod(MethodName::CONSTRUCT, $scope); + $parametersAcceptor = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); foreach ($parametersAcceptor->getParameters() as $parameterReflection) { if ($parameterReflection->getDefaultValue() === null) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } } - return new \PHPStan\Type\ObjectType($classConstantReference, null, $classReflection); + return new ObjectType($classConstantReference, null, $classReflection); } } diff --git a/packages/NodeCollector/ScopeResolver/ParentClassScopeResolver.php b/packages/NodeCollector/ScopeResolver/ParentClassScopeResolver.php index 6349d9af4e0..97c684384e2 100644 --- a/packages/NodeCollector/ScopeResolver/ParentClassScopeResolver.php +++ b/packages/NodeCollector/ScopeResolver/ParentClassScopeResolver.php @@ -7,18 +7,18 @@ use PHPStan\Analyser\Scope; use PHPStan\Reflection\ClassReflection; final class ParentClassScopeResolver { - public function resolveParentClassName(\PHPStan\Analyser\Scope $scope) : ?string + public function resolveParentClassName(Scope $scope) : ?string { $parentClassReflection = $this->resolveParentClassReflection($scope); - if (!$parentClassReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$parentClassReflection instanceof ClassReflection) { return null; } return $parentClassReflection->getName(); } - public function resolveParentClassReflection(\PHPStan\Analyser\Scope $scope) : ?\PHPStan\Reflection\ClassReflection + public function resolveParentClassReflection(Scope $scope) : ?ClassReflection { $classReflection = $scope->getClassReflection(); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return null; } return $classReflection->getParentClass(); diff --git a/packages/NodeCollector/StaticAnalyzer.php b/packages/NodeCollector/StaticAnalyzer.php index c11bdcb9f35..5480522c61f 100644 --- a/packages/NodeCollector/StaticAnalyzer.php +++ b/packages/NodeCollector/StaticAnalyzer.php @@ -14,7 +14,7 @@ final class StaticAnalyzer * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ReflectionProvider $reflectionProvider) { $this->reflectionProvider = $reflectionProvider; } @@ -34,13 +34,13 @@ final class StaticAnalyzer // @see https://regex101.com/r/tlvfTB/1 return $this->hasStaticAnnotation($methodName, $classReflection); } - private function hasStaticAnnotation(string $methodName, \PHPStan\Reflection\ClassReflection $classReflection) : bool + private function hasStaticAnnotation(string $methodName, ClassReflection $classReflection) : bool { $resolvedPhpDocBlock = $classReflection->getResolvedPhpDoc(); - if (!$resolvedPhpDocBlock instanceof \PHPStan\PhpDoc\ResolvedPhpDocBlock) { + if (!$resolvedPhpDocBlock instanceof ResolvedPhpDocBlock) { return \false; } // @see https://regex101.com/r/7Zkej2/1 - return \Rector\Core\Util\StringUtils::isMatch($resolvedPhpDocBlock->getPhpDocString(), '#@method\\s*static\\s*((([\\w\\|\\\\]+)|\\$this)*+(\\[\\])*)*\\s+\\b' . $methodName . '\\b#'); + return StringUtils::isMatch($resolvedPhpDocBlock->getPhpDocString(), '#@method\\s*static\\s*((([\\w\\|\\\\]+)|\\$this)*+(\\[\\])*)*\\s+\\b' . $methodName . '\\b#'); } } diff --git a/packages/NodeCollector/ValueObject/ArrayCallable.php b/packages/NodeCollector/ValueObject/ArrayCallable.php index bbe91d894ab..69543507809 100644 --- a/packages/NodeCollector/ValueObject/ArrayCallable.php +++ b/packages/NodeCollector/ValueObject/ArrayCallable.php @@ -22,12 +22,12 @@ final class ArrayCallable * @var string */ private $method; - public function __construct(\PhpParser\Node\Expr $callerExpr, string $class, string $method) + public function __construct(Expr $callerExpr, string $class, string $method) { $this->callerExpr = $callerExpr; $this->class = $class; $this->method = $method; - \Rector\Core\Validation\RectorAssert::className($class); + RectorAssert::className($class); } public function getClass() : string { @@ -37,7 +37,7 @@ final class ArrayCallable { return $this->method; } - public function getCallerExpr() : \PhpParser\Node\Expr + public function getCallerExpr() : Expr { return $this->callerExpr; } diff --git a/packages/NodeCollector/ValueObject/ArrayCallableDynamicMethod.php b/packages/NodeCollector/ValueObject/ArrayCallableDynamicMethod.php index 4adba109939..da19a67b32d 100644 --- a/packages/NodeCollector/ValueObject/ArrayCallableDynamicMethod.php +++ b/packages/NodeCollector/ValueObject/ArrayCallableDynamicMethod.php @@ -22,22 +22,22 @@ final class ArrayCallableDynamicMethod * @var \PhpParser\Node\Expr */ private $method; - public function __construct(\PhpParser\Node\Expr $callerExpr, string $class, \PhpParser\Node\Expr $method) + public function __construct(Expr $callerExpr, string $class, Expr $method) { $this->callerExpr = $callerExpr; $this->class = $class; $this->method = $method; - \Rector\Core\Validation\RectorAssert::className($class); + RectorAssert::className($class); } public function getClass() : string { return $this->class; } - public function getMethod() : \PhpParser\Node\Expr + public function getMethod() : Expr { return $this->method; } - public function getCallerExpr() : \PhpParser\Node\Expr + public function getCallerExpr() : Expr { return $this->callerExpr; } diff --git a/packages/NodeNameResolver/Contract/NodeNameResolverInterface.php b/packages/NodeNameResolver/Contract/NodeNameResolverInterface.php index be74a1fc7d9..43e4fb1dd53 100644 --- a/packages/NodeNameResolver/Contract/NodeNameResolverInterface.php +++ b/packages/NodeNameResolver/Contract/NodeNameResolverInterface.php @@ -16,5 +16,5 @@ interface NodeNameResolverInterface /** * @param TNode $node */ - public function resolve(\PhpParser\Node $node) : ?string; + public function resolve(Node $node) : ?string; } diff --git a/packages/NodeNameResolver/Error/InvalidNameNodeReporter.php b/packages/NodeNameResolver/Error/InvalidNameNodeReporter.php index 8ea711ae8ce..c541c2b2958 100644 --- a/packages/NodeNameResolver/Error/InvalidNameNodeReporter.php +++ b/packages/NodeNameResolver/Error/InvalidNameNodeReporter.php @@ -10,7 +10,7 @@ use Rector\Core\Contract\Rector\RectorInterface; use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Provider\CurrentFileProvider; use Rector\Core\ValueObject\Application\File; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class InvalidNameNodeReporter { /** @@ -27,7 +27,7 @@ final class InvalidNameNodeReporter * @var \Rector\Core\Contract\PhpParser\NodePrinterInterface */ private $nodePrinter; - public function __construct(\Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter) + public function __construct(CurrentFileProvider $currentFileProvider, NodePrinterInterface $nodePrinter) { $this->currentFileProvider = $currentFileProvider; $this->nodePrinter = $nodePrinter; @@ -39,7 +39,7 @@ final class InvalidNameNodeReporter { $message = \sprintf('Pick more specific node than "%s", e.g. "$node->name"', \get_class($node)); $file = $this->currentFileProvider->getFile(); - if ($file instanceof \Rector\Core\ValueObject\Application\File) { + if ($file instanceof File) { $smartFileInfo = $file->getSmartFileInfo(); $message .= \PHP_EOL . \PHP_EOL; $message .= \sprintf('Caused in "%s" file on line %d on code "%s"', $smartFileInfo->getRelativeFilePathFromCwd(), $node->getStartLine(), $this->nodePrinter->print($node)); @@ -49,7 +49,7 @@ final class InvalidNameNodeReporter if ($rectorBacktrace !== null) { // issues to find the file in prefixed if (\file_exists($rectorBacktrace[self::FILE])) { - $smartFileInfo = new \Symplify\SmartFileSystem\SmartFileInfo($rectorBacktrace[self::FILE]); + $smartFileInfo = new SmartFileInfo($rectorBacktrace[self::FILE]); $fileAndLine = $smartFileInfo->getRelativeFilePathFromCwd() . ':' . $rectorBacktrace['line']; } else { $fileAndLine = $rectorBacktrace[self::FILE] . ':' . $rectorBacktrace['line']; @@ -57,7 +57,7 @@ final class InvalidNameNodeReporter $message .= \PHP_EOL . \PHP_EOL; $message .= \sprintf('Look at "%s"', $fileAndLine); } - throw new \Rector\Core\Exception\ShouldNotHappenException($message); + throw new ShouldNotHappenException($message); } /** * @param mixed[] $backtrace @@ -70,7 +70,7 @@ final class InvalidNameNodeReporter continue; } // match a Rector class - if (!\is_a($singleBacktrace['object'], \Rector\Core\Contract\Rector\RectorInterface::class)) { + if (!\is_a($singleBacktrace['object'], RectorInterface::class)) { continue; } return $singleBacktrace; diff --git a/packages/NodeNameResolver/NodeNameResolver.php b/packages/NodeNameResolver/NodeNameResolver.php index 8a027690c02..cdf8951106d 100644 --- a/packages/NodeNameResolver/NodeNameResolver.php +++ b/packages/NodeNameResolver/NodeNameResolver.php @@ -48,7 +48,7 @@ final class NodeNameResolver /** * @param NodeNameResolverInterface[] $nodeNameResolvers */ - public function __construct(\Rector\NodeNameResolver\Regex\RegexPatternDetector $regexPatternDetector, \Rector\CodingStyle\Naming\ClassNaming $classNaming, \Rector\NodeNameResolver\Error\InvalidNameNodeReporter $invalidNameNodeReporter, \Rector\Core\NodeAnalyzer\CallAnalyzer $callAnalyzer, array $nodeNameResolvers = []) + public function __construct(RegexPatternDetector $regexPatternDetector, ClassNaming $classNaming, InvalidNameNodeReporter $invalidNameNodeReporter, CallAnalyzer $callAnalyzer, array $nodeNameResolvers = []) { $this->regexPatternDetector = $regexPatternDetector; $this->classNaming = $classNaming; @@ -59,7 +59,7 @@ final class NodeNameResolver /** * @param string[] $names */ - public function isNames(\PhpParser\Node $node, array $names) : bool + public function isNames(Node $node, array $names) : bool { foreach ($names as $name) { if ($this->isName($node, $name)) { @@ -73,10 +73,10 @@ final class NodeNameResolver */ public function isName($node, string $name) : bool { - if ($node instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node instanceof MethodCall) { return \false; } - if ($node instanceof \PhpParser\Node\Expr\StaticCall) { + if ($node instanceof StaticCall) { return \false; } $nodes = \is_array($node) ? $node : [$node]; @@ -87,15 +87,15 @@ final class NodeNameResolver } return \false; } - public function isCaseSensitiveName(\PhpParser\Node $node, string $name) : bool + public function isCaseSensitiveName(Node $node, string $name) : bool { if ($name === '') { return \false; } - if ($node instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node instanceof MethodCall) { return \false; } - if ($node instanceof \PhpParser\Node\Expr\StaticCall) { + if ($node instanceof StaticCall) { return \false; } $resolvedName = $this->getName($node); @@ -113,11 +113,11 @@ final class NodeNameResolver return $node; } // useful for looped imported names - $namespacedName = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NAMESPACED_NAME); + $namespacedName = $node->getAttribute(AttributeKey::NAMESPACED_NAME); if (\is_string($namespacedName)) { return $namespacedName; } - if ($node instanceof \PhpParser\Node\Expr\MethodCall || $node instanceof \PhpParser\Node\Expr\StaticCall) { + if ($node instanceof MethodCall || $node instanceof StaticCall) { if ($this->isCallOrIdentifier($node->name)) { return null; } @@ -134,12 +134,12 @@ final class NodeNameResolver return null; } // unable to resolve - if ($node->name instanceof \PhpParser\Node\Expr) { + if ($node->name instanceof Expr) { return null; } return (string) $node->name; } - public function areNamesEqual(\PhpParser\Node $firstNode, \PhpParser\Node $secondNode) : bool + public function areNamesEqual(Node $firstNode, Node $secondNode) : bool { $secondResolvedName = $this->getName($secondNode); if ($secondResolvedName === null) { @@ -157,7 +157,7 @@ final class NodeNameResolver foreach ($nodes as $node) { $name = $this->getName($node); if (!\is_string($name)) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $names[] = $name; } @@ -170,7 +170,7 @@ final class NodeNameResolver public function endsWith(string $currentName, string $expectedName) : bool { $suffixNamePattern = '#\\w+' . \ucfirst($expectedName) . '#'; - return \Rector\Core\Util\StringUtils::isMatch($currentName, $suffixNamePattern); + return StringUtils::isMatch($currentName, $suffixNamePattern); } /** * @param string|\PhpParser\Node\Name|\PhpParser\Node\Identifier|\PhpParser\Node\Stmt\ClassLike $name @@ -182,7 +182,7 @@ final class NodeNameResolver /** * @param array $renameMap */ - public function matchNameFromMap(\PhpParser\Node $node, array $renameMap) : ?string + public function matchNameFromMap(Node $node, array $renameMap) : ?string { $name = $this->getName($node); return $renameMap[$name] ?? null; @@ -194,7 +194,7 @@ final class NodeNameResolver } // is probably regex pattern if ($this->regexPatternDetector->isRegexPattern($desiredName)) { - return \Rector\Core\Util\StringUtils::isMatch($resolvedName, $desiredName); + return StringUtils::isMatch($resolvedName, $desiredName); } // is probably fnmatch if (\strpos($desiredName, '*') !== \false) { @@ -211,14 +211,14 @@ final class NodeNameResolver */ private function isCallOrIdentifier($node) : bool { - if ($node instanceof \PhpParser\Node\Expr) { + if ($node instanceof Expr) { return $this->callAnalyzer->isObjectCall($node); } return \true; } - private function isSingleName(\PhpParser\Node $node, string $desiredName) : bool + private function isSingleName(Node $node, string $desiredName) : bool { - if ($node instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node instanceof MethodCall) { // method call cannot have a name, only the variable or method name return \false; } diff --git a/packages/NodeNameResolver/NodeNameResolver/ClassConstFetchNameResolver.php b/packages/NodeNameResolver/NodeNameResolver/ClassConstFetchNameResolver.php index 7f301ca04b0..f32effcaf4a 100644 --- a/packages/NodeNameResolver/NodeNameResolver/ClassConstFetchNameResolver.php +++ b/packages/NodeNameResolver/NodeNameResolver/ClassConstFetchNameResolver.php @@ -11,7 +11,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements NodeNameResolverInterface */ -final class ClassConstFetchNameResolver implements \Rector\NodeNameResolver\Contract\NodeNameResolverInterface +final class ClassConstFetchNameResolver implements NodeNameResolverInterface { /** * @var \Rector\NodeNameResolver\NodeNameResolver @@ -20,18 +20,18 @@ final class ClassConstFetchNameResolver implements \Rector\NodeNameResolver\Cont /** * @required */ - public function autowire(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) : void + public function autowire(NodeNameResolver $nodeNameResolver) : void { $this->nodeNameResolver = $nodeNameResolver; } public function getNode() : string { - return \PhpParser\Node\Expr\ClassConstFetch::class; + return ClassConstFetch::class; } /** * @param ClassConstFetch $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { $class = $this->nodeNameResolver->getName($node->class); $name = $this->nodeNameResolver->getName($node->name); diff --git a/packages/NodeNameResolver/NodeNameResolver/ClassConstNameResolver.php b/packages/NodeNameResolver/NodeNameResolver/ClassConstNameResolver.php index c594518f96c..3464d5b6927 100644 --- a/packages/NodeNameResolver/NodeNameResolver/ClassConstNameResolver.php +++ b/packages/NodeNameResolver/NodeNameResolver/ClassConstNameResolver.php @@ -11,7 +11,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements NodeNameResolverInterface */ -final class ClassConstNameResolver implements \Rector\NodeNameResolver\Contract\NodeNameResolverInterface +final class ClassConstNameResolver implements NodeNameResolverInterface { /** * @var \Rector\NodeNameResolver\NodeNameResolver @@ -20,18 +20,18 @@ final class ClassConstNameResolver implements \Rector\NodeNameResolver\Contract\ /** * @required */ - public function autowire(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) : void + public function autowire(NodeNameResolver $nodeNameResolver) : void { $this->nodeNameResolver = $nodeNameResolver; } public function getNode() : string { - return \PhpParser\Node\Stmt\ClassConst::class; + return ClassConst::class; } /** * @param ClassConst $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { if ($node->consts === []) { return null; diff --git a/packages/NodeNameResolver/NodeNameResolver/ClassNameResolver.php b/packages/NodeNameResolver/NodeNameResolver/ClassNameResolver.php index 68aae194954..729ea9199eb 100644 --- a/packages/NodeNameResolver/NodeNameResolver/ClassNameResolver.php +++ b/packages/NodeNameResolver/NodeNameResolver/ClassNameResolver.php @@ -12,7 +12,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements NodeNameResolverInterface */ -final class ClassNameResolver implements \Rector\NodeNameResolver\Contract\NodeNameResolverInterface +final class ClassNameResolver implements NodeNameResolverInterface { /** * @var \Rector\NodeNameResolver\NodeNameResolver @@ -21,20 +21,20 @@ final class ClassNameResolver implements \Rector\NodeNameResolver\Contract\NodeN /** * @required */ - public function autowire(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) : void + public function autowire(NodeNameResolver $nodeNameResolver) : void { $this->nodeNameResolver = $nodeNameResolver; } public function getNode() : string { - return \PhpParser\Node\Stmt\ClassLike::class; + return ClassLike::class; } /** * @param ClassLike $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { - if ($node->namespacedName instanceof \PhpParser\Node\Name) { + if ($node->namespacedName instanceof Name) { return $node->namespacedName->toString(); } if ($node->name === null) { diff --git a/packages/NodeNameResolver/NodeNameResolver/EmptyNameResolver.php b/packages/NodeNameResolver/NodeNameResolver/EmptyNameResolver.php index 67c86276ab9..952276f582f 100644 --- a/packages/NodeNameResolver/NodeNameResolver/EmptyNameResolver.php +++ b/packages/NodeNameResolver/NodeNameResolver/EmptyNameResolver.php @@ -9,16 +9,16 @@ use Rector\NodeNameResolver\Contract\NodeNameResolverInterface; /** * @implements NodeNameResolverInterface */ -final class EmptyNameResolver implements \Rector\NodeNameResolver\Contract\NodeNameResolverInterface +final class EmptyNameResolver implements NodeNameResolverInterface { public function getNode() : string { - return \PhpParser\Node\Expr\Empty_::class; + return Empty_::class; } /** * @param Empty_ $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { return 'empty'; } diff --git a/packages/NodeNameResolver/NodeNameResolver/FuncCallNameResolver.php b/packages/NodeNameResolver/NodeNameResolver/FuncCallNameResolver.php index 6cf734e272e..ee0958e60fa 100644 --- a/packages/NodeNameResolver/NodeNameResolver/FuncCallNameResolver.php +++ b/packages/NodeNameResolver/NodeNameResolver/FuncCallNameResolver.php @@ -13,20 +13,20 @@ use Rector\NodeTypeResolver\Node\AttributeKey; /** * @implements NodeNameResolverInterface */ -final class FuncCallNameResolver implements \Rector\NodeNameResolver\Contract\NodeNameResolverInterface +final class FuncCallNameResolver implements NodeNameResolverInterface { /** * @readonly * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ReflectionProvider $reflectionProvider) { $this->reflectionProvider = $reflectionProvider; } public function getNode() : string { - return \PhpParser\Node\Expr\FuncCall::class; + return FuncCall::class; } /** * If some function is namespaced, it will be used over global one. @@ -34,13 +34,13 @@ final class FuncCallNameResolver implements \Rector\NodeNameResolver\Contract\No * * @param FuncCall $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { - if ($node->name instanceof \PhpParser\Node\Expr) { + if ($node->name instanceof Expr) { return null; } - $namespaceName = $node->name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NAMESPACED_NAME); - if ($namespaceName instanceof \PhpParser\Node\Name\FullyQualified) { + $namespaceName = $node->name->getAttribute(AttributeKey::NAMESPACED_NAME); + if ($namespaceName instanceof FullyQualified) { $functionFqnName = $namespaceName->toString(); if ($this->reflectionProvider->hasFunction($namespaceName, null)) { return $functionFqnName; diff --git a/packages/NodeNameResolver/NodeNameResolver/FunctionNameResolver.php b/packages/NodeNameResolver/NodeNameResolver/FunctionNameResolver.php index d26b2c79842..5a727699bfc 100644 --- a/packages/NodeNameResolver/NodeNameResolver/FunctionNameResolver.php +++ b/packages/NodeNameResolver/NodeNameResolver/FunctionNameResolver.php @@ -11,20 +11,20 @@ use Rector\NodeTypeResolver\Node\AttributeKey; /** * @implements NodeNameResolverInterface */ -final class FunctionNameResolver implements \Rector\NodeNameResolver\Contract\NodeNameResolverInterface +final class FunctionNameResolver implements NodeNameResolverInterface { public function getNode() : string { - return \PhpParser\Node\Stmt\Function_::class; + return Function_::class; } /** * @param Function_ $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { $bareName = (string) $node->name; - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { + $scope = $node->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { return $bareName; } $namespaceName = $scope->getNamespace(); diff --git a/packages/NodeNameResolver/NodeNameResolver/NameNameResolver.php b/packages/NodeNameResolver/NodeNameResolver/NameNameResolver.php index 16a5d336e02..921b0af49a7 100644 --- a/packages/NodeNameResolver/NodeNameResolver/NameNameResolver.php +++ b/packages/NodeNameResolver/NodeNameResolver/NameNameResolver.php @@ -12,7 +12,7 @@ use Rector\NodeTypeResolver\Node\AttributeKey; /** * @implements NodeNameResolverInterface */ -final class NameNameResolver implements \Rector\NodeNameResolver\Contract\NodeNameResolverInterface +final class NameNameResolver implements NodeNameResolverInterface { /** * @readonly @@ -25,20 +25,20 @@ final class NameNameResolver implements \Rector\NodeNameResolver\Contract\NodeNa } public function getNode() : string { - return \PhpParser\Node\Name::class; + return Name::class; } /** * @param Name $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { // possible function parent - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\Expr\FuncCall) { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof FuncCall) { return $this->funcCallNameResolver->resolve($parent); } - $resolvedName = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::RESOLVED_NAME); - if ($resolvedName instanceof \PhpParser\Node\Name\FullyQualified) { + $resolvedName = $node->getAttribute(AttributeKey::RESOLVED_NAME); + if ($resolvedName instanceof FullyQualified) { return $resolvedName->toString(); } return $node->toString(); diff --git a/packages/NodeNameResolver/NodeNameResolver/ParamNameResolver.php b/packages/NodeNameResolver/NodeNameResolver/ParamNameResolver.php index f469ee01cdf..48de3afe3f6 100644 --- a/packages/NodeNameResolver/NodeNameResolver/ParamNameResolver.php +++ b/packages/NodeNameResolver/NodeNameResolver/ParamNameResolver.php @@ -11,7 +11,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements NodeNameResolverInterface */ -final class ParamNameResolver implements \Rector\NodeNameResolver\Contract\NodeNameResolverInterface +final class ParamNameResolver implements NodeNameResolverInterface { /** * @var \Rector\NodeNameResolver\NodeNameResolver @@ -20,18 +20,18 @@ final class ParamNameResolver implements \Rector\NodeNameResolver\Contract\NodeN /** * @required */ - public function autowire(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) : void + public function autowire(NodeNameResolver $nodeNameResolver) : void { $this->nodeNameResolver = $nodeNameResolver; } public function getNode() : string { - return \PhpParser\Node\Param::class; + return Param::class; } /** * @param Param $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { return $this->nodeNameResolver->getName($node->var); } diff --git a/packages/NodeNameResolver/NodeNameResolver/PropertyNameResolver.php b/packages/NodeNameResolver/NodeNameResolver/PropertyNameResolver.php index c9e188af591..5fd3d3ba094 100644 --- a/packages/NodeNameResolver/NodeNameResolver/PropertyNameResolver.php +++ b/packages/NodeNameResolver/NodeNameResolver/PropertyNameResolver.php @@ -11,7 +11,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements NodeNameResolverInterface */ -final class PropertyNameResolver implements \Rector\NodeNameResolver\Contract\NodeNameResolverInterface +final class PropertyNameResolver implements NodeNameResolverInterface { /** * @var \Rector\NodeNameResolver\NodeNameResolver @@ -20,18 +20,18 @@ final class PropertyNameResolver implements \Rector\NodeNameResolver\Contract\No /** * @required */ - public function autowire(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) : void + public function autowire(NodeNameResolver $nodeNameResolver) : void { $this->nodeNameResolver = $nodeNameResolver; } public function getNode() : string { - return \PhpParser\Node\Stmt\Property::class; + return Property::class; } /** * @param Property $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { if ($node->props === []) { return null; diff --git a/packages/NodeNameResolver/NodeNameResolver/UseNameResolver.php b/packages/NodeNameResolver/NodeNameResolver/UseNameResolver.php index 9f18a975687..968be79c410 100644 --- a/packages/NodeNameResolver/NodeNameResolver/UseNameResolver.php +++ b/packages/NodeNameResolver/NodeNameResolver/UseNameResolver.php @@ -11,7 +11,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements NodeNameResolverInterface */ -final class UseNameResolver implements \Rector\NodeNameResolver\Contract\NodeNameResolverInterface +final class UseNameResolver implements NodeNameResolverInterface { /** * @var \Rector\NodeNameResolver\NodeNameResolver @@ -20,18 +20,18 @@ final class UseNameResolver implements \Rector\NodeNameResolver\Contract\NodeNam /** * @required */ - public function autowire(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) : void + public function autowire(NodeNameResolver $nodeNameResolver) : void { $this->nodeNameResolver = $nodeNameResolver; } public function getNode() : string { - return \PhpParser\Node\Stmt\Use_::class; + return Use_::class; } /** * @param Use_ $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { if ($node->uses === []) { return null; diff --git a/packages/NodeNameResolver/NodeNameResolver/VariableNameResolver.php b/packages/NodeNameResolver/NodeNameResolver/VariableNameResolver.php index 1e185f6a2a7..527d11204d3 100644 --- a/packages/NodeNameResolver/NodeNameResolver/VariableNameResolver.php +++ b/packages/NodeNameResolver/NodeNameResolver/VariableNameResolver.php @@ -12,23 +12,23 @@ use Rector\NodeTypeResolver\Node\AttributeKey; /** * @implements NodeNameResolverInterface */ -final class VariableNameResolver implements \Rector\NodeNameResolver\Contract\NodeNameResolverInterface +final class VariableNameResolver implements NodeNameResolverInterface { public function getNode() : string { - return \PhpParser\Node\Expr\Variable::class; + return Variable::class; } /** * @param Variable $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); // skip $some->$dynamicMethodName() - if ($parentNode instanceof \PhpParser\Node\Expr\MethodCall && $node === $parentNode->name) { + if ($parentNode instanceof MethodCall && $node === $parentNode->name) { return null; } - if ($node->name instanceof \PhpParser\Node\Expr) { + if ($node->name instanceof Expr) { return null; } return $node->name; diff --git a/packages/NodeNameResolver/Regex/RegexPatternDetector.php b/packages/NodeNameResolver/Regex/RegexPatternDetector.php index 363e9ce75ee..131772d87e2 100644 --- a/packages/NodeNameResolver/Regex/RegexPatternDetector.php +++ b/packages/NodeNameResolver/Regex/RegexPatternDetector.php @@ -14,7 +14,7 @@ final class RegexPatternDetector private const POSSIBLE_DELIMITERS = ['#', '~', '/']; public function isRegexPattern(string $name) : bool { - if (\RectorPrefix20220607\Nette\Utils\Strings::length($name) <= 2) { + if (Strings::length($name) <= 2) { return \false; } $firstChar = $name[0]; diff --git a/packages/NodeNestingScope/ContextAnalyzer.php b/packages/NodeNestingScope/ContextAnalyzer.php index 31db10de922..bd45d437fa8 100644 --- a/packages/NodeNestingScope/ContextAnalyzer.php +++ b/packages/NodeNestingScope/ContextAnalyzer.php @@ -21,7 +21,7 @@ final class ContextAnalyzer * Nodes that break the scope they way up, e.g. class method * @var array> */ - private const BREAK_NODES = [\PhpParser\Node\FunctionLike::class, \PhpParser\Node\Stmt\ClassMethod::class]; + private const BREAK_NODES = [FunctionLike::class, ClassMethod::class]; /** * @readonly * @var \Rector\Core\PhpParser\Node\BetterNodeFinder @@ -32,54 +32,54 @@ final class ContextAnalyzer * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeTypeResolver $nodeTypeResolver) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeTypeResolver = $nodeTypeResolver; } - public function isInLoop(\PhpParser\Node $node) : bool + public function isInLoop(Node $node) : bool { - $stopNodes = \array_merge(\Rector\NodeNestingScope\ValueObject\ControlStructure::LOOP_NODES, self::BREAK_NODES); + $stopNodes = \array_merge(ControlStructure::LOOP_NODES, self::BREAK_NODES); $firstParent = $this->betterNodeFinder->findParentByTypes($node, $stopNodes); - if (!$firstParent instanceof \PhpParser\Node) { + if (!$firstParent instanceof Node) { return \false; } - foreach (\Rector\NodeNestingScope\ValueObject\ControlStructure::LOOP_NODES as $type) { + foreach (ControlStructure::LOOP_NODES as $type) { if (\is_a($firstParent, $type, \true)) { return \true; } } return \false; } - public function isInSwitch(\PhpParser\Node $node) : bool + public function isInSwitch(Node $node) : bool { - return (bool) $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Switch_::class); + return (bool) $this->betterNodeFinder->findParentType($node, Switch_::class); } - public function isInIf(\PhpParser\Node $node) : bool + public function isInIf(Node $node) : bool { - $breakNodes = \array_merge([\PhpParser\Node\Stmt\If_::class], self::BREAK_NODES); + $breakNodes = \array_merge([If_::class], self::BREAK_NODES); $previousNode = $this->betterNodeFinder->findParentByTypes($node, $breakNodes); - if (!$previousNode instanceof \PhpParser\Node) { + if (!$previousNode instanceof Node) { return \false; } - return $previousNode instanceof \PhpParser\Node\Stmt\If_; + return $previousNode instanceof If_; } - public function isHasAssignWithIndirectReturn(\PhpParser\Node $node, \PhpParser\Node\Stmt\If_ $if) : bool + public function isHasAssignWithIndirectReturn(Node $node, If_ $if) : bool { - foreach (\Rector\NodeNestingScope\ValueObject\ControlStructure::LOOP_NODES as $loopNode) { - $loopObjectType = new \PHPStan\Type\ObjectType($loopNode); + foreach (ControlStructure::LOOP_NODES as $loopNode) { + $loopObjectType = new ObjectType($loopNode); $parentType = $this->nodeTypeResolver->getType($node); $superType = $parentType->isSuperTypeOf($loopObjectType); $isLoopType = $superType->yes(); if (!$isLoopType) { continue; } - $next = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if ($next instanceof \PhpParser\Node) { - if ($next instanceof \PhpParser\Node\Stmt\Return_ && $next->expr === null) { + $next = $node->getAttribute(AttributeKey::NEXT_NODE); + if ($next instanceof Node) { + if ($next instanceof Return_ && $next->expr === null) { continue; } - $hasAssign = (bool) $this->betterNodeFinder->findInstanceOf($if->stmts, \PhpParser\Node\Expr\Assign::class); + $hasAssign = (bool) $this->betterNodeFinder->findInstanceOf($if->stmts, Assign::class); if (!$hasAssign) { continue; } diff --git a/packages/NodeNestingScope/FlowOfControlLocator.php b/packages/NodeNestingScope/FlowOfControlLocator.php index 071d150675c..f5fd6a4475b 100644 --- a/packages/NodeNestingScope/FlowOfControlLocator.php +++ b/packages/NodeNestingScope/FlowOfControlLocator.php @@ -10,16 +10,16 @@ use PhpParser\Node\Stmt\Expression; use Rector\NodeTypeResolver\Node\AttributeKey; final class FlowOfControlLocator { - public function resolveNestingHashFromFunctionLike(\PhpParser\Node\FunctionLike $functionLike, \PhpParser\Node $checkedNode) : string + public function resolveNestingHashFromFunctionLike(FunctionLike $functionLike, Node $checkedNode) : string { $nestingHash = \spl_object_hash($functionLike) . '__'; $currentNode = $checkedNode; $previous = $currentNode; - while ($currentNode = $currentNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE)) { - if ($currentNode instanceof \PhpParser\Node\Stmt\Expression) { + while ($currentNode = $currentNode->getAttribute(AttributeKey::PARENT_NODE)) { + if ($currentNode instanceof Expression) { continue; } - if (!$currentNode instanceof \PhpParser\Node) { + if (!$currentNode instanceof Node) { break; } if ($functionLike === $currentNode) { @@ -32,9 +32,9 @@ final class FlowOfControlLocator } return $nestingHash; } - private function resolveBinaryOpNestingHash(\PhpParser\Node $currentNode, \PhpParser\Node $previous) : string + private function resolveBinaryOpNestingHash(Node $currentNode, Node $previous) : string { - if (!$currentNode instanceof \PhpParser\Node\Expr\BinaryOp) { + if (!$currentNode instanceof BinaryOp) { return ''; } // left && right have differnt nesting diff --git a/packages/NodeNestingScope/NodeFinder/ScopeAwareNodeFinder.php b/packages/NodeNestingScope/NodeFinder/ScopeAwareNodeFinder.php index 2a924a2db90..66c40f353e6 100644 --- a/packages/NodeNestingScope/NodeFinder/ScopeAwareNodeFinder.php +++ b/packages/NodeNestingScope/NodeFinder/ScopeAwareNodeFinder.php @@ -17,7 +17,7 @@ final class ScopeAwareNodeFinder * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(BetterNodeFinder $betterNodeFinder) { $this->betterNodeFinder = $betterNodeFinder; } @@ -26,12 +26,12 @@ final class ScopeAwareNodeFinder * @param callable(Node $node): bool $callable * @param array> $allowedTypes */ - public function findParent(\PhpParser\Node $node, callable $callable, array $allowedTypes) : ?\PhpParser\Node + public function findParent(Node $node, callable $callable, array $allowedTypes) : ?Node { /** @var array> $parentNestingBreakTypes */ - $parentNestingBreakTypes = \array_diff(\Rector\NodeNestingScope\ValueObject\ControlStructure::BREAKING_SCOPE_NODE_TYPES, $allowedTypes); + $parentNestingBreakTypes = \array_diff(ControlStructure::BREAKING_SCOPE_NODE_TYPES, $allowedTypes); $this->isBreakingNodeFoundFirst = \false; - $foundNode = $this->betterNodeFinder->findFirstPrevious($node, function (\PhpParser\Node $node) use($callable, $parentNestingBreakTypes) : bool { + $foundNode = $this->betterNodeFinder->findFirstPrevious($node, function (Node $node) use($callable, $parentNestingBreakTypes) : bool { if ($callable($node)) { return \true; } diff --git a/packages/NodeNestingScope/ParentScopeFinder.php b/packages/NodeNestingScope/ParentScopeFinder.php index 483347a9853..3f40028619a 100644 --- a/packages/NodeNestingScope/ParentScopeFinder.php +++ b/packages/NodeNestingScope/ParentScopeFinder.php @@ -17,15 +17,15 @@ final class ParentScopeFinder * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(BetterNodeFinder $betterNodeFinder) { $this->betterNodeFinder = $betterNodeFinder; } /** * @return \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Namespace_|\PhpParser\Node\Expr\Closure|null */ - public function find(\PhpParser\Node $node) + public function find(Node $node) { - return $this->betterNodeFinder->findParentByTypes($node, [\PhpParser\Node\Expr\Closure::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Class_::class, \PhpParser\Node\Stmt\Namespace_::class]); + return $this->betterNodeFinder->findParentByTypes($node, [Closure::class, Function_::class, ClassMethod::class, Class_::class, Namespace_::class]); } } diff --git a/packages/NodeNestingScope/ScopeNestingComparator.php b/packages/NodeNestingScope/ScopeNestingComparator.php index be2d6778013..1d41695e0d6 100644 --- a/packages/NodeNestingScope/ScopeNestingComparator.php +++ b/packages/NodeNestingScope/ScopeNestingComparator.php @@ -28,46 +28,46 @@ final class ScopeNestingComparator * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeComparator $nodeComparator) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeComparator = $nodeComparator; } - public function areReturnScopeNested(\PhpParser\Node\Stmt\Return_ $return, \PhpParser\Node $secondNodeScopeNode) : bool + public function areReturnScopeNested(Return_ $return, Node $secondNodeScopeNode) : bool { - $firstNodeScopeNode = $this->betterNodeFinder->findParentByTypes($return, \Rector\NodeNestingScope\ValueObject\ControlStructure::RETURN_ISOLATING_SCOPE_NODE_TYPES); + $firstNodeScopeNode = $this->betterNodeFinder->findParentByTypes($return, ControlStructure::RETURN_ISOLATING_SCOPE_NODE_TYPES); return $this->nodeComparator->areNodesEqual($firstNodeScopeNode, $secondNodeScopeNode); } - public function areScopeNestingEqual(\PhpParser\Node $firstNode, \PhpParser\Node $secondNode) : bool + public function areScopeNestingEqual(Node $firstNode, Node $secondNode) : bool { $firstNodeScopeNode = $this->findParentControlStructure($firstNode); $secondNodeScopeNode = $this->findParentControlStructure($secondNode); return $this->nodeComparator->areNodesEqual($firstNodeScopeNode, $secondNodeScopeNode); } - public function isNodeConditionallyScoped(\PhpParser\Node\Expr $expr) : bool + public function isNodeConditionallyScoped(Expr $expr) : bool { - $foundParent = $this->betterNodeFinder->findParentByTypes($expr, \Rector\NodeNestingScope\ValueObject\ControlStructure::CONDITIONAL_NODE_SCOPE_TYPES + [\PhpParser\Node\FunctionLike::class]); - if (!$foundParent instanceof \PhpParser\Node) { + $foundParent = $this->betterNodeFinder->findParentByTypes($expr, ControlStructure::CONDITIONAL_NODE_SCOPE_TYPES + [FunctionLike::class]); + if (!$foundParent instanceof Node) { return \false; } // is in both if/else branches if ($this->isInBothIfElseBranch($foundParent, $expr)) { return \false; } - if (!$foundParent instanceof \PhpParser\Node\Stmt\Else_) { - return !$foundParent instanceof \PhpParser\Node\FunctionLike; + if (!$foundParent instanceof Else_) { + return !$foundParent instanceof FunctionLike; } if (!$this->nodeComparator->areNodesEqual($expr, $this->doubleIfBranchExprs)) { - return !$foundParent instanceof \PhpParser\Node\FunctionLike; + return !$foundParent instanceof FunctionLike; } return \false; } - public function isInBothIfElseBranch(\PhpParser\Node $foundParentNode, \PhpParser\Node\Expr $seekedExpr) : bool + public function isInBothIfElseBranch(Node $foundParentNode, Expr $seekedExpr) : bool { - if ($foundParentNode instanceof \PhpParser\Node\Stmt\Else_) { + if ($foundParentNode instanceof Else_) { return $this->nodeComparator->isNodeEqual($seekedExpr, $this->doubleIfBranchExprs); } - if (!$foundParentNode instanceof \PhpParser\Node\Stmt\If_) { + if (!$foundParentNode instanceof If_) { return \false; } $foundIfNode = (bool) $this->betterNodeFinder->findFirst($foundParentNode->stmts, function ($node) use($seekedExpr) : bool { @@ -85,8 +85,8 @@ final class ScopeNestingComparator } return \false; } - private function findParentControlStructure(\PhpParser\Node $node) : ?\PhpParser\Node + private function findParentControlStructure(Node $node) : ?Node { - return $this->betterNodeFinder->findParentByTypes($node, \Rector\NodeNestingScope\ValueObject\ControlStructure::BREAKING_SCOPE_NODE_TYPES); + return $this->betterNodeFinder->findParentByTypes($node, ControlStructure::BREAKING_SCOPE_NODE_TYPES); } } diff --git a/packages/NodeNestingScope/ValueObject/ControlStructure.php b/packages/NodeNestingScope/ValueObject/ControlStructure.php index 3a0450805f3..5b75c6dcbe9 100644 --- a/packages/NodeNestingScope/ValueObject/ControlStructure.php +++ b/packages/NodeNestingScope/ValueObject/ControlStructure.php @@ -25,18 +25,18 @@ final class ControlStructure /** * @var array> */ - public const RETURN_ISOLATING_SCOPE_NODE_TYPES = [\PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Expr\Closure::class, \PhpParser\Node\Expr\ArrowFunction::class]; + public const RETURN_ISOLATING_SCOPE_NODE_TYPES = [Function_::class, ClassMethod::class, Closure::class, ArrowFunction::class]; /** * @var array> */ - public const BREAKING_SCOPE_NODE_TYPES = [\PhpParser\Node\Stmt\For_::class, \PhpParser\Node\Stmt\Foreach_::class, \PhpParser\Node\Stmt\If_::class, \PhpParser\Node\Stmt\While_::class, \PhpParser\Node\Stmt\Do_::class, \PhpParser\Node\Stmt\Else_::class, \PhpParser\Node\Stmt\ElseIf_::class, \PhpParser\Node\Stmt\Catch_::class, \PhpParser\Node\Stmt\Case_::class, \PhpParser\Node\FunctionLike::class]; + public const BREAKING_SCOPE_NODE_TYPES = [For_::class, Foreach_::class, If_::class, While_::class, Do_::class, Else_::class, ElseIf_::class, Catch_::class, Case_::class, FunctionLike::class]; /** * These situations happens only if condition is met * @var array> */ - public const CONDITIONAL_NODE_SCOPE_TYPES = [\PhpParser\Node\Stmt\If_::class, \PhpParser\Node\Stmt\While_::class, \PhpParser\Node\Stmt\Do_::class, \PhpParser\Node\Stmt\Else_::class, \PhpParser\Node\Stmt\ElseIf_::class, \PhpParser\Node\Stmt\Catch_::class, \PhpParser\Node\Stmt\Case_::class, \PhpParser\Node\Expr\Match_::class, \PhpParser\Node\Stmt\Switch_::class, \PhpParser\Node\Stmt\Foreach_::class]; + public const CONDITIONAL_NODE_SCOPE_TYPES = [If_::class, While_::class, Do_::class, Else_::class, ElseIf_::class, Catch_::class, Case_::class, Match_::class, Switch_::class, Foreach_::class]; /** * @var array> */ - public const LOOP_NODES = [\PhpParser\Node\Stmt\For_::class, \PhpParser\Node\Stmt\Foreach_::class, \PhpParser\Node\Stmt\While_::class, \PhpParser\Node\Stmt\Do_::class]; + public const LOOP_NODES = [For_::class, Foreach_::class, While_::class, Do_::class]; } diff --git a/packages/NodeRemoval/BreakingRemovalGuard.php b/packages/NodeRemoval/BreakingRemovalGuard.php index d5a366c6f6f..011cbc65ef2 100644 --- a/packages/NodeRemoval/BreakingRemovalGuard.php +++ b/packages/NodeRemoval/BreakingRemovalGuard.php @@ -12,28 +12,28 @@ use Rector\Core\Exception\ShouldNotHappenException; use Rector\NodeTypeResolver\Node\AttributeKey; final class BreakingRemovalGuard { - public function ensureNodeCanBeRemove(\PhpParser\Node $node) : void + public function ensureNodeCanBeRemove(Node $node) : void { if ($this->isLegalNodeRemoval($node)) { return; } // validate the node can be removed - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof Node) { + throw new ShouldNotHappenException(); } - throw new \Rector\Core\Exception\ShouldNotHappenException(\sprintf('Node "%s" on line %d is child of "%s", so it cannot be removed as it would break PHP code. Change or remove the parent node instead.', \get_class($node), $node->getLine(), \get_class($parentNode))); + throw new ShouldNotHappenException(\sprintf('Node "%s" on line %d is child of "%s", so it cannot be removed as it would break PHP code. Change or remove the parent node instead.', \get_class($node), $node->getLine(), \get_class($parentNode))); } - public function isLegalNodeRemoval(\PhpParser\Node $node) : bool + public function isLegalNodeRemoval(Node $node) : bool { - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\Stmt\If_ && $parent->cond === $node) { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof If_ && $parent->cond === $node) { return \false; } - if ($parent instanceof \PhpParser\Node\Expr\BooleanNot) { - $parent = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + if ($parent instanceof BooleanNot) { + $parent = $parent->getAttribute(AttributeKey::PARENT_NODE); } - if ($parent instanceof \PhpParser\Node\Expr\Assign) { + if ($parent instanceof Assign) { return \false; } if ($this->isIfCondition($node)) { @@ -41,18 +41,18 @@ final class BreakingRemovalGuard } return !$this->isWhileCondition($node); } - private function isIfCondition(\PhpParser\Node $node) : bool + private function isIfCondition(Node $node) : bool { - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node\Stmt\If_) { + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof If_) { return \false; } return $parentNode->cond === $node; } - private function isWhileCondition(\PhpParser\Node $node) : bool + private function isWhileCondition(Node $node) : bool { - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node\Stmt\While_) { + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof While_) { return \false; } return $parentNode->cond === $node; diff --git a/packages/NodeRemoval/NodeRemover.php b/packages/NodeRemoval/NodeRemover.php index 3713b96cee0..aff71b373b8 100644 --- a/packages/NodeRemoval/NodeRemover.php +++ b/packages/NodeRemoval/NodeRemover.php @@ -28,16 +28,16 @@ final class NodeRemover * @var \Rector\ChangesReporting\Collector\RectorChangeCollector */ private $rectorChangeCollector; - public function __construct(\Rector\PostRector\Collector\NodesToRemoveCollector $nodesToRemoveCollector, \Rector\ChangesReporting\Collector\RectorChangeCollector $rectorChangeCollector) + public function __construct(NodesToRemoveCollector $nodesToRemoveCollector, RectorChangeCollector $rectorChangeCollector) { $this->nodesToRemoveCollector = $nodesToRemoveCollector; $this->rectorChangeCollector = $rectorChangeCollector; } - public function removeNode(\PhpParser\Node $node) : void + public function removeNode(Node $node) : void { // this make sure to keep just added nodes, e.g. added class constant, that doesn't have analysis of full code in this run // if this is missing, there are false positive e.g. for unused private constant - $isJustAddedNode = !(bool) $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE); + $isJustAddedNode = !(bool) $node->getAttribute(AttributeKey::ORIGINAL_NODE); if ($isJustAddedNode) { return; } @@ -47,7 +47,7 @@ final class NodeRemover /** * @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $nodeWithStatements */ - public function removeNodeFromStatements($nodeWithStatements, \PhpParser\Node $toBeRemovedNode) : void + public function removeNodeFromStatements($nodeWithStatements, Node $toBeRemovedNode) : void { foreach ((array) $nodeWithStatements->stmts as $key => $stmt) { if ($toBeRemovedNode !== $stmt) { @@ -72,7 +72,7 @@ final class NodeRemover public function removeStmt($functionLike, int $key) : void { if ($functionLike->stmts === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } // notify about remove node $this->rectorChangeCollector->notifyNodeFileInfo($functionLike->stmts[$key]); @@ -81,11 +81,11 @@ final class NodeRemover /** * @param int|\PhpParser\Node\Param $keyOrParam */ - public function removeParam(\PhpParser\Node\Stmt\ClassMethod $classMethod, $keyOrParam) : void + public function removeParam(ClassMethod $classMethod, $keyOrParam) : void { - $key = $keyOrParam instanceof \PhpParser\Node\Param ? $keyOrParam->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARAMETER_POSITION) : $keyOrParam; + $key = $keyOrParam instanceof Param ? $keyOrParam->getAttribute(AttributeKey::PARAMETER_POSITION) : $keyOrParam; if ($classMethod->params === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } // already removed if (!isset($classMethod->params[$key])) { @@ -101,7 +101,7 @@ final class NodeRemover public function removeArg($node, int $key) : void { if ($node->args === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } // already removed if (!isset($node->args[$key])) { @@ -111,10 +111,10 @@ final class NodeRemover $this->rectorChangeCollector->notifyNodeFileInfo($node->args[$key]); unset($node->args[$key]); } - public function removeImplements(\PhpParser\Node\Stmt\Class_ $class, int $key) : void + public function removeImplements(Class_ $class, int $key) : void { if ($class->implements === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } // notify about remove node $this->rectorChangeCollector->notifyNodeFileInfo($class->implements[$key]); diff --git a/packages/NodeTypeResolver/Contract/NodeTypeResolverInterface.php b/packages/NodeTypeResolver/Contract/NodeTypeResolverInterface.php index a4e9eb019f6..0c2f4e76207 100644 --- a/packages/NodeTypeResolver/Contract/NodeTypeResolverInterface.php +++ b/packages/NodeTypeResolver/Contract/NodeTypeResolverInterface.php @@ -17,5 +17,5 @@ interface NodeTypeResolverInterface /** * @param TNode $node */ - public function resolve(\PhpParser\Node $node) : \PHPStan\Type\Type; + public function resolve(Node $node) : Type; } diff --git a/packages/NodeTypeResolver/Contract/SourceLocatorProviderInterface.php b/packages/NodeTypeResolver/Contract/SourceLocatorProviderInterface.php index 16d92e81495..2d75644ab51 100644 --- a/packages/NodeTypeResolver/Contract/SourceLocatorProviderInterface.php +++ b/packages/NodeTypeResolver/Contract/SourceLocatorProviderInterface.php @@ -6,5 +6,5 @@ namespace Rector\NodeTypeResolver\Contract; use PHPStan\BetterReflection\SourceLocator\Type\SourceLocator; interface SourceLocatorProviderInterface { - public function provide() : \PHPStan\BetterReflection\SourceLocator\Type\SourceLocator; + public function provide() : SourceLocator; } diff --git a/packages/NodeTypeResolver/DependencyInjection/PHPStanServicesFactory.php b/packages/NodeTypeResolver/DependencyInjection/PHPStanServicesFactory.php index 421799cde4d..888d9436a62 100644 --- a/packages/NodeTypeResolver/DependencyInjection/PHPStanServicesFactory.php +++ b/packages/NodeTypeResolver/DependencyInjection/PHPStanServicesFactory.php @@ -29,12 +29,12 @@ final class PHPStanServicesFactory * @var \PHPStan\DependencyInjection\Container */ private $container; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider) + public function __construct(ParameterProvider $parameterProvider) { - $containerFactory = new \PHPStan\DependencyInjection\ContainerFactory(\getcwd()); + $containerFactory = new ContainerFactory(\getcwd()); $additionalConfigFiles = []; - if ($parameterProvider->hasParameter(\Rector\Core\Configuration\Option::PHPSTAN_FOR_RECTOR_PATH)) { - $additionalConfigFiles[] = $parameterProvider->provideStringParameter(\Rector\Core\Configuration\Option::PHPSTAN_FOR_RECTOR_PATH); + if ($parameterProvider->hasParameter(Option::PHPSTAN_FOR_RECTOR_PATH)) { + $additionalConfigFiles[] = $parameterProvider->provideStringParameter(Option::PHPSTAN_FOR_RECTOR_PATH); } $additionalConfigFiles[] = __DIR__ . '/../../../config/phpstan/static-reflection.neon'; $additionalConfigFiles[] = __DIR__ . '/../../../config/phpstan/better-infer.neon'; @@ -47,65 +47,65 @@ final class PHPStanServicesFactory /** * @api */ - public function createReflectionProvider() : \PHPStan\Reflection\ReflectionProvider + public function createReflectionProvider() : ReflectionProvider { - return $this->container->getByType(\PHPStan\Reflection\ReflectionProvider::class); + return $this->container->getByType(ReflectionProvider::class); } /** * @api */ - public function createEmulativeLexer() : \PhpParser\Lexer + public function createEmulativeLexer() : Lexer { return $this->container->getService('currentPhpVersionLexer'); } /** * @api */ - public function createPHPStanParser() : \PHPStan\Parser\Parser + public function createPHPStanParser() : Parser { return $this->container->getService('currentPhpVersionRichParser'); } /** * @api */ - public function createNodeScopeResolver() : \PHPStan\Analyser\NodeScopeResolver + public function createNodeScopeResolver() : NodeScopeResolver { - return $this->container->getByType(\PHPStan\Analyser\NodeScopeResolver::class); + return $this->container->getByType(NodeScopeResolver::class); } /** * @api */ - public function createScopeFactory() : \PHPStan\Analyser\ScopeFactory + public function createScopeFactory() : ScopeFactory { - return $this->container->getByType(\PHPStan\Analyser\ScopeFactory::class); + return $this->container->getByType(ScopeFactory::class); } /** * @api */ - public function createDependencyResolver() : \PHPStan\Dependency\DependencyResolver + public function createDependencyResolver() : DependencyResolver { - return $this->container->getByType(\PHPStan\Dependency\DependencyResolver::class); + return $this->container->getByType(DependencyResolver::class); } /** * @api */ - public function createFileHelper() : \PHPStan\File\FileHelper + public function createFileHelper() : FileHelper { - return $this->container->getByType(\PHPStan\File\FileHelper::class); + return $this->container->getByType(FileHelper::class); } /** * @api */ - public function createTypeNodeResolver() : \PHPStan\PhpDoc\TypeNodeResolver + public function createTypeNodeResolver() : TypeNodeResolver { - return $this->container->getByType(\PHPStan\PhpDoc\TypeNodeResolver::class); + return $this->container->getByType(TypeNodeResolver::class); } /** * @api */ - public function createDynamicSourceLocatorProvider() : \Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider + public function createDynamicSourceLocatorProvider() : DynamicSourceLocatorProvider { - return $this->container->getByType(\Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider::class); + return $this->container->getByType(DynamicSourceLocatorProvider::class); } /** * @return string[] @@ -113,17 +113,17 @@ final class PHPStanServicesFactory private function resolveExtensionConfigs() : array { // same logic as in PHPStan for extension installed - https://github.com/phpstan/phpstan-src/blob/5956ec4f6cd09c8d7db9466ed4e7f25706f37a43/src/Command/CommandHelper.php#L195-L222 - if (!\class_exists(\PHPStan\ExtensionInstaller\GeneratedConfig::class)) { + if (!\class_exists(GeneratedConfig::class)) { return []; } - $reflectionClass = new \ReflectionClass(\PHPStan\ExtensionInstaller\GeneratedConfig::class); + $reflectionClass = new ReflectionClass(GeneratedConfig::class); $generatedConfigClassFileName = $reflectionClass->getFileName(); if ($generatedConfigClassFileName === \false) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $generatedConfigDirectory = \dirname($generatedConfigClassFileName); $extensionConfigFiles = []; - foreach (\PHPStan\ExtensionInstaller\GeneratedConfig::EXTENSIONS as $extension) { + foreach (GeneratedConfig::EXTENSIONS as $extension) { $fileNames = $extension['extra']['includes'] ?? []; foreach ($fileNames as $fileName) { $configFilePath = $generatedConfigDirectory . '/' . $extension['relative_install_path'] . '/' . $fileName; diff --git a/packages/NodeTypeResolver/MethodParameterTypeResolver.php b/packages/NodeTypeResolver/MethodParameterTypeResolver.php index 8be30a5ccc4..27a9f408fc5 100644 --- a/packages/NodeTypeResolver/MethodParameterTypeResolver.php +++ b/packages/NodeTypeResolver/MethodParameterTypeResolver.php @@ -17,17 +17,17 @@ final class MethodParameterTypeResolver * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(ReflectionResolver $reflectionResolver) { $this->reflectionResolver = $reflectionResolver; } /** * @return Type[] */ - public function provideParameterTypesByStaticCall(\PhpParser\Node\Expr\StaticCall $staticCall) : array + public function provideParameterTypesByStaticCall(StaticCall $staticCall) : array { $methodReflection = $this->reflectionResolver->resolveMethodReflectionFromStaticCall($staticCall); - if (!$methodReflection instanceof \PHPStan\Reflection\MethodReflection) { + if (!$methodReflection instanceof MethodReflection) { return []; } return $this->provideParameterTypesFromMethodReflection($methodReflection); @@ -35,10 +35,10 @@ final class MethodParameterTypeResolver /** * @return Type[] */ - public function provideParameterTypesByClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : array + public function provideParameterTypesByClassMethod(ClassMethod $classMethod) : array { $methodReflection = $this->reflectionResolver->resolveMethodReflectionFromClassMethod($classMethod); - if (!$methodReflection instanceof \PHPStan\Reflection\MethodReflection) { + if (!$methodReflection instanceof MethodReflection) { return []; } return $this->provideParameterTypesFromMethodReflection($methodReflection); @@ -46,14 +46,14 @@ final class MethodParameterTypeResolver /** * @return Type[] */ - private function provideParameterTypesFromMethodReflection(\PHPStan\Reflection\MethodReflection $methodReflection) : array + private function provideParameterTypesFromMethodReflection(MethodReflection $methodReflection) : array { - if ($methodReflection instanceof \PHPStan\Reflection\Native\NativeMethodReflection) { + if ($methodReflection instanceof NativeMethodReflection) { // method "getParameters()" does not exist there return []; } $parameterTypes = []; - $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); + $parametersAcceptor = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); foreach ($parametersAcceptor->getParameters() as $parameterReflection) { $parameterTypes[] = $parameterReflection->getType(); } diff --git a/packages/NodeTypeResolver/NodeScopeAndMetadataDecorator.php b/packages/NodeTypeResolver/NodeScopeAndMetadataDecorator.php index 09eb115230e..b12cc74a38b 100644 --- a/packages/NodeTypeResolver/NodeScopeAndMetadataDecorator.php +++ b/packages/NodeTypeResolver/NodeScopeAndMetadataDecorator.php @@ -32,7 +32,7 @@ final class NodeScopeAndMetadataDecorator * @var \Rector\NodeTypeResolver\NodeVisitor\FunctionLikeParamArgPositionNodeVisitor */ private $functionLikeParamArgPositionNodeVisitor; - public function __construct(\PhpParser\NodeVisitor\CloningVisitor $cloningVisitor, \Rector\NodeTypeResolver\PHPStan\Scope\PHPStanNodeScopeResolver $phpStanNodeScopeResolver, \PhpParser\NodeVisitor\NodeConnectingVisitor $nodeConnectingVisitor, \Rector\NodeTypeResolver\NodeVisitor\FunctionLikeParamArgPositionNodeVisitor $functionLikeParamArgPositionNodeVisitor) + public function __construct(CloningVisitor $cloningVisitor, PHPStanNodeScopeResolver $phpStanNodeScopeResolver, NodeConnectingVisitor $nodeConnectingVisitor, FunctionLikeParamArgPositionNodeVisitor $functionLikeParamArgPositionNodeVisitor) { $this->cloningVisitor = $cloningVisitor; $this->phpStanNodeScopeResolver = $phpStanNodeScopeResolver; @@ -43,11 +43,11 @@ final class NodeScopeAndMetadataDecorator * @param Stmt[] $stmts * @return Stmt[] */ - public function decorateNodesFromFile(\Rector\Core\ValueObject\Application\File $file, array $stmts) : array + public function decorateNodesFromFile(File $file, array $stmts) : array { $smartFileInfo = $file->getSmartFileInfo(); $stmts = $this->phpStanNodeScopeResolver->processNodes($stmts, $smartFileInfo); - $nodeTraverser = new \PhpParser\NodeTraverser(); + $nodeTraverser = new NodeTraverser(); // needed also for format preserving printing $nodeTraverser->addVisitor($this->cloningVisitor); // this one has to be run again to re-connect nodes with new attributes @@ -61,7 +61,7 @@ final class NodeScopeAndMetadataDecorator */ public function decorateStmtsFromString(array $stmts) : array { - $nodeTraverser = new \PhpParser\NodeTraverser(); + $nodeTraverser = new NodeTraverser(); $nodeTraverser->addVisitor($this->nodeConnectingVisitor); return $nodeTraverser->traverse($stmts); } diff --git a/packages/NodeTypeResolver/NodeTypeCorrector/AccessoryNonEmptyStringTypeCorrector.php b/packages/NodeTypeResolver/NodeTypeCorrector/AccessoryNonEmptyStringTypeCorrector.php index d415f0db2ec..2fc787bcf36 100644 --- a/packages/NodeTypeResolver/NodeTypeCorrector/AccessoryNonEmptyStringTypeCorrector.php +++ b/packages/NodeTypeResolver/NodeTypeCorrector/AccessoryNonEmptyStringTypeCorrector.php @@ -11,17 +11,17 @@ final class AccessoryNonEmptyStringTypeCorrector /** * @return \PHPStan\Type\Type|\PHPStan\Type\IntersectionType */ - public function correct(\PHPStan\Type\Type $mainType) + public function correct(Type $mainType) { - if (!$mainType instanceof \PHPStan\Type\IntersectionType) { + if (!$mainType instanceof IntersectionType) { return $mainType; } - if (!$mainType->isSubTypeOf(new \PHPStan\Type\Accessory\AccessoryNonEmptyStringType())->yes()) { + if (!$mainType->isSubTypeOf(new AccessoryNonEmptyStringType())->yes()) { return $mainType; } $clearIntersectionedTypes = []; foreach ($mainType->getTypes() as $intersectionedType) { - if ($intersectionedType instanceof \PHPStan\Type\Accessory\AccessoryNonEmptyStringType) { + if ($intersectionedType instanceof AccessoryNonEmptyStringType) { continue; } $clearIntersectionedTypes[] = $intersectionedType; @@ -29,6 +29,6 @@ final class AccessoryNonEmptyStringTypeCorrector if (\count($clearIntersectionedTypes) === 1) { return $clearIntersectionedTypes[0]; } - return new \PHPStan\Type\IntersectionType($clearIntersectionedTypes); + return new IntersectionType($clearIntersectionedTypes); } } diff --git a/packages/NodeTypeResolver/NodeTypeCorrector/GenericClassStringTypeCorrector.php b/packages/NodeTypeResolver/NodeTypeCorrector/GenericClassStringTypeCorrector.php index 514b2406411..815304597df 100644 --- a/packages/NodeTypeResolver/NodeTypeCorrector/GenericClassStringTypeCorrector.php +++ b/packages/NodeTypeResolver/NodeTypeCorrector/GenericClassStringTypeCorrector.php @@ -16,21 +16,21 @@ final class GenericClassStringTypeCorrector * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ReflectionProvider $reflectionProvider) { $this->reflectionProvider = $reflectionProvider; } - public function correct(\PHPStan\Type\Type $mainType) : \PHPStan\Type\Type + public function correct(Type $mainType) : Type { // inspired from https://github.com/phpstan/phpstan-src/blob/94e3443b2d21404a821e05b901dd4b57fcbd4e7f/src/Type/Generic/TemplateTypeHelper.php#L18 - return \PHPStan\Type\TypeTraverser::map($mainType, function (\PHPStan\Type\Type $traversedType, callable $traverseCallback) : Type { - if (!$traversedType instanceof \PHPStan\Type\Constant\ConstantStringType) { + return TypeTraverser::map($mainType, function (Type $traversedType, callable $traverseCallback) : Type { + if (!$traversedType instanceof ConstantStringType) { return $traverseCallback($traversedType); } if (!$this->reflectionProvider->hasClass($traversedType->getValue())) { return $traverseCallback($traversedType); } - return new \PHPStan\Type\Generic\GenericClassStringType(new \PHPStan\Type\ObjectType($traversedType->getValue())); + return new GenericClassStringType(new ObjectType($traversedType->getValue())); }); } } diff --git a/packages/NodeTypeResolver/NodeTypeCorrector/HasOffsetTypeCorrector.php b/packages/NodeTypeResolver/NodeTypeCorrector/HasOffsetTypeCorrector.php index 1ce99ef4377..eddcb70593f 100644 --- a/packages/NodeTypeResolver/NodeTypeCorrector/HasOffsetTypeCorrector.php +++ b/packages/NodeTypeResolver/NodeTypeCorrector/HasOffsetTypeCorrector.php @@ -12,17 +12,17 @@ final class HasOffsetTypeCorrector /** * HasOffsetType breaks array mixed type, so we better get rid of it */ - public function correct(\PHPStan\Type\Type $type) : \PHPStan\Type\Type + public function correct(Type $type) : Type { - if (!$type instanceof \PHPStan\Type\IntersectionType) { + if (!$type instanceof IntersectionType) { return $type; } $clearTypes = []; foreach ($type->getTypes() as $intersectionedType) { - if ($intersectionedType instanceof \PHPStan\Type\Accessory\HasOffsetType) { + if ($intersectionedType instanceof HasOffsetType) { continue; } - if ($intersectionedType instanceof \PHPStan\Type\Accessory\NonEmptyArrayType) { + if ($intersectionedType instanceof NonEmptyArrayType) { continue; } $clearTypes[] = $intersectionedType; @@ -30,6 +30,6 @@ final class HasOffsetTypeCorrector if (\count($clearTypes) === 1) { return $clearTypes[0]; } - return new \PHPStan\Type\IntersectionType($clearTypes); + return new IntersectionType($clearTypes); } } diff --git a/packages/NodeTypeResolver/NodeTypeCorrector/PregMatchTypeCorrector.php b/packages/NodeTypeResolver/NodeTypeCorrector/PregMatchTypeCorrector.php index 23d54fe55bd..d9c8437cf62 100644 --- a/packages/NodeTypeResolver/NodeTypeCorrector/PregMatchTypeCorrector.php +++ b/packages/NodeTypeResolver/NodeTypeCorrector/PregMatchTypeCorrector.php @@ -43,7 +43,7 @@ final class PregMatchTypeCorrector * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeNestingScope\ParentScopeFinder $parentScopeFinder, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver, ParentScopeFinder $parentScopeFinder, NodeComparator $nodeComparator, ArgsAnalyzer $argsAnalyzer) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeNameResolver = $nodeNameResolver; @@ -55,22 +55,22 @@ final class PregMatchTypeCorrector * Special case for "preg_match(), preg_match_all()" - with 3rd argument * @see https://github.com/rectorphp/rector/issues/786 */ - public function correct(\PhpParser\Node $node, \PHPStan\Type\Type $originalType) : \PHPStan\Type\Type + public function correct(Node $node, Type $originalType) : Type { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + if (!$node instanceof Variable) { return $originalType; } - if ($originalType instanceof \PHPStan\Type\ArrayType) { + if ($originalType instanceof ArrayType) { return $originalType; } $variableUsages = $this->getVariableUsages($node); foreach ($variableUsages as $variableUsage) { - $possiblyArg = $variableUsage->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$possiblyArg instanceof \PhpParser\Node\Arg) { + $possiblyArg = $variableUsage->getAttribute(AttributeKey::PARENT_NODE); + if (!$possiblyArg instanceof Arg) { continue; } - $funcCallNode = $possiblyArg->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$funcCallNode instanceof \PhpParser\Node\Expr\FuncCall) { + $funcCallNode = $possiblyArg->getAttribute(AttributeKey::PARENT_NODE); + if (!$funcCallNode instanceof FuncCall) { continue; } if (!$this->nodeNameResolver->isNames($funcCallNode, ['preg_match', 'preg_match_all'])) { @@ -85,21 +85,21 @@ final class PregMatchTypeCorrector if (!$this->nodeComparator->areNodesEqual($thirdArg->value, $node)) { continue; } - return new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); + return new ArrayType(new MixedType(), new MixedType()); } return $originalType; } /** * @return Node[] */ - private function getVariableUsages(\PhpParser\Node\Expr\Variable $variable) : array + private function getVariableUsages(Variable $variable) : array { $scope = $this->parentScopeFinder->find($variable); if ($scope === null) { return []; } - return $this->betterNodeFinder->find((array) $scope->stmts, function (\PhpParser\Node $node) use($variable) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + return $this->betterNodeFinder->find((array) $scope->stmts, function (Node $node) use($variable) : bool { + if (!$node instanceof Variable) { return \false; } return $node->name === $variable->name; diff --git a/packages/NodeTypeResolver/NodeTypeResolver.php b/packages/NodeTypeResolver/NodeTypeResolver.php index 55849f786cf..548383c38e5 100644 --- a/packages/NodeTypeResolver/NodeTypeResolver.php +++ b/packages/NodeTypeResolver/NodeTypeResolver.php @@ -93,7 +93,7 @@ final class NodeTypeResolver /** * @param NodeTypeResolverInterface[] $nodeTypeResolvers */ - public function __construct(\Rector\TypeDeclaration\PHPStan\ObjectTypeSpecifier $objectTypeSpecifier, \Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer, \Rector\NodeTypeResolver\NodeTypeCorrector\GenericClassStringTypeCorrector $genericClassStringTypeCorrector, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\NodeTypeResolver\NodeTypeCorrector\HasOffsetTypeCorrector $hasOffsetTypeCorrector, \Rector\NodeTypeResolver\NodeTypeCorrector\AccessoryNonEmptyStringTypeCorrector $accessoryNonEmptyStringTypeCorrector, \Rector\NodeTypeResolver\NodeTypeResolver\IdentifierTypeResolver $identifierTypeResolver, \Rector\Core\Configuration\RenamedClassesDataCollector $renamedClassesDataCollector, array $nodeTypeResolvers) + public function __construct(ObjectTypeSpecifier $objectTypeSpecifier, ClassAnalyzer $classAnalyzer, GenericClassStringTypeCorrector $genericClassStringTypeCorrector, ReflectionProvider $reflectionProvider, HasOffsetTypeCorrector $hasOffsetTypeCorrector, AccessoryNonEmptyStringTypeCorrector $accessoryNonEmptyStringTypeCorrector, IdentifierTypeResolver $identifierTypeResolver, RenamedClassesDataCollector $renamedClassesDataCollector, array $nodeTypeResolvers) { $this->objectTypeSpecifier = $objectTypeSpecifier; $this->classAnalyzer = $classAnalyzer; @@ -112,7 +112,7 @@ final class NodeTypeResolver /** * @param ObjectType[] $requiredTypes */ - public function isObjectTypes(\PhpParser\Node $node, array $requiredTypes) : bool + public function isObjectTypes(Node $node, array $requiredTypes) : bool { foreach ($requiredTypes as $requiredType) { if ($this->isObjectType($node, $requiredType)) { @@ -121,97 +121,97 @@ final class NodeTypeResolver } return \false; } - public function isObjectType(\PhpParser\Node $node, \PHPStan\Type\ObjectType $requiredObjectType) : bool + public function isObjectType(Node $node, ObjectType $requiredObjectType) : bool { - if ($node instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if ($node instanceof ClassConstFetch) { return \false; } $resolvedType = $this->getType($node); - if ($resolvedType instanceof \PHPStan\Type\MixedType) { + if ($resolvedType instanceof MixedType) { return \false; } - if ($resolvedType instanceof \PHPStan\Type\ThisType) { + if ($resolvedType instanceof ThisType) { $resolvedType = $resolvedType->getStaticObjectType(); } - if ($resolvedType instanceof \PHPStan\Type\ObjectType) { + if ($resolvedType instanceof ObjectType) { try { return $this->resolveObjectType($resolvedType, $requiredObjectType); - } catch (\PHPStan\Broker\ClassAutoloadingException $exception) { + } catch (ClassAutoloadingException $exception) { // in some type checks, the provided type in rector.php configuration does not have to exists return \false; } } return $this->isMatchingUnionType($resolvedType, $requiredObjectType); } - public function getType(\PhpParser\Node $node) : \PHPStan\Type\Type + public function getType(Node $node) : Type { - if ($node instanceof \PhpParser\Node\Stmt\Property && $node->type instanceof \PhpParser\Node\NullableType) { + if ($node instanceof Property && $node->type instanceof NullableType) { return $this->getType($node->type); } - if ($node instanceof \PhpParser\Node\NullableType) { - if ($node->type instanceof \PhpParser\Node\Name && $node->type->hasAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NAMESPACED_NAME)) { - $node->type = new \PhpParser\Node\Name\FullyQualified($node->type->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NAMESPACED_NAME)); + if ($node instanceof NullableType) { + if ($node->type instanceof Name && $node->type->hasAttribute(AttributeKey::NAMESPACED_NAME)) { + $node->type = new FullyQualified($node->type->getAttribute(AttributeKey::NAMESPACED_NAME)); } $type = $this->getType($node->type); - if (!$type instanceof \PHPStan\Type\MixedType) { - return new \PHPStan\Type\UnionType([$type, new \PHPStan\Type\NullType()]); + if (!$type instanceof MixedType) { + return new UnionType([$type, new NullType()]); } } - if ($node instanceof \PhpParser\Node\Expr\Ternary) { + if ($node instanceof Ternary) { $ternaryType = $this->resolveTernaryType($node); - if (!$ternaryType instanceof \PHPStan\Type\MixedType) { + if (!$ternaryType instanceof MixedType) { return $ternaryType; } } - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\Coalesce) { + if ($node instanceof Coalesce) { $first = $this->getType($node->left); $second = $this->getType($node->right); if ($this->isUnionTypeable($first, $second)) { - return new \PHPStan\Type\UnionType([$first, $second]); + return new UnionType([$first, $second]); } } $type = $this->resolveByNodeTypeResolvers($node); if ($type !== null) { $type = $this->accessoryNonEmptyStringTypeCorrector->correct($type); $type = $this->genericClassStringTypeCorrector->correct($type); - if ($type instanceof \PHPStan\Type\ObjectType) { - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + if ($type instanceof ObjectType) { + $scope = $node->getAttribute(AttributeKey::SCOPE); $type = $this->objectTypeSpecifier->narrowToFullyQualifiedOrAliasedObjectType($node, $type, $scope); } return $this->hasOffsetTypeCorrector->correct($type); } - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { - if ($node instanceof \PhpParser\Node\Expr\ConstFetch) { + $scope = $node->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { + if ($node instanceof ConstFetch) { $name = $node->name->toString(); if (\strtolower($name) === 'null') { - return new \PHPStan\Type\NullType(); + return new NullType(); } } - if ($node instanceof \PhpParser\Node\Identifier) { + if ($node instanceof Identifier) { return $this->identifierTypeResolver->resolve($node); } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } - if (!$node instanceof \PhpParser\Node\Expr) { + if (!$node instanceof Expr) { // scalar type, e.g. from param type name - if ($node instanceof \PhpParser\Node\Identifier) { + if ($node instanceof Identifier) { return $this->identifierTypeResolver->resolve($node); } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } // skip anonymous classes, ref https://github.com/rectorphp/rector/issues/1574 - if ($node instanceof \PhpParser\Node\Expr\New_ && $this->classAnalyzer->isAnonymousClass($node->class)) { - return new \PHPStan\Type\ObjectWithoutClassType(); + if ($node instanceof New_ && $this->classAnalyzer->isAnonymousClass($node->class)) { + return new ObjectWithoutClassType(); } $type = $scope->getType($node); $type = $this->accessoryNonEmptyStringTypeCorrector->correct($type); $type = $this->genericClassStringTypeCorrector->correct($type); // hot fix for phpstan not resolving chain method calls - if (!$node instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$node instanceof MethodCall) { return $type; } - if (!$type instanceof \PHPStan\Type\MixedType) { + if (!$type instanceof MixedType) { return $type; } return $this->getType($node->var); @@ -219,71 +219,71 @@ final class NodeTypeResolver /** * e.g. string|null, ObjectNull|null */ - public function isNullableType(\PhpParser\Node $node) : bool + public function isNullableType(Node $node) : bool { $nodeType = $this->getType($node); - return \PHPStan\Type\TypeCombinator::containsNull($nodeType); + return TypeCombinator::containsNull($nodeType); } - public function getNativeType(\PhpParser\Node\Expr $expr) : \PHPStan\Type\Type + public function getNativeType(Expr $expr) : Type { - $scope = $expr->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { - return new \PHPStan\Type\MixedType(); + $scope = $expr->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { + return new MixedType(); } $type = $scope->getNativeType($expr); return $this->accessoryNonEmptyStringTypeCorrector->correct($type); } - public function isNumberType(\PhpParser\Node $node) : bool + public function isNumberType(Node $node) : bool { $nodeType = $this->getType($node); - if ($nodeType instanceof \PHPStan\Type\IntegerType) { + if ($nodeType instanceof IntegerType) { return \true; } - return $nodeType instanceof \PHPStan\Type\FloatType; + return $nodeType instanceof FloatType; } /** * @param class-string $desiredType */ - public function isNullableTypeOfSpecificType(\PhpParser\Node $node, string $desiredType) : bool + public function isNullableTypeOfSpecificType(Node $node, string $desiredType) : bool { $nodeType = $this->getType($node); - if (!$nodeType instanceof \PHPStan\Type\UnionType) { + if (!$nodeType instanceof UnionType) { return \false; } - if (!\PHPStan\Type\TypeCombinator::containsNull($nodeType)) { + if (!TypeCombinator::containsNull($nodeType)) { return \false; } - $bareType = \PHPStan\Type\TypeCombinator::removeNull($nodeType); + $bareType = TypeCombinator::removeNull($nodeType); return \is_a($bareType, $desiredType, \true); } /** * @return class-string */ - public function getFullyQualifiedClassName(\PHPStan\Type\TypeWithClassName $typeWithClassName) : string + public function getFullyQualifiedClassName(TypeWithClassName $typeWithClassName) : string { - if ($typeWithClassName instanceof \Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType) { + if ($typeWithClassName instanceof ShortenedObjectType) { return $typeWithClassName->getFullyQualifiedName(); } - if ($typeWithClassName instanceof \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType) { + if ($typeWithClassName instanceof AliasedObjectType) { return $typeWithClassName->getFullyQualifiedName(); } return $typeWithClassName->getClassName(); } - public function isMethodStaticCallOrClassMethodObjectType(\PhpParser\Node $node, \PHPStan\Type\ObjectType $objectType) : bool + public function isMethodStaticCallOrClassMethodObjectType(Node $node, ObjectType $objectType) : bool { - if ($node instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node instanceof MethodCall) { // method call is variable return return $this->isObjectType($node->var, $objectType); } - if ($node instanceof \PhpParser\Node\Expr\StaticCall) { + if ($node instanceof StaticCall) { return $this->isObjectType($node->class, $objectType); } - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { + $scope = $node->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { return \false; } $classReflection = $scope->getClassReflection(); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } if ($classReflection->getName() === $objectType->getClassName()) { @@ -291,21 +291,21 @@ final class NodeTypeResolver } return $classReflection->isSubclassOf($objectType->getClassName()); } - private function isUnionTypeable(\PHPStan\Type\Type $first, \PHPStan\Type\Type $second) : bool + private function isUnionTypeable(Type $first, Type $second) : bool { - return !$first instanceof \PHPStan\Type\UnionType && !$second instanceof \PHPStan\Type\UnionType && !$second instanceof \PHPStan\Type\NullType; + return !$first instanceof UnionType && !$second instanceof UnionType && !$second instanceof NullType; } - private function isMatchingUnionType(\PHPStan\Type\Type $resolvedType, \PHPStan\Type\ObjectType $requiredObjectType) : bool + private function isMatchingUnionType(Type $resolvedType, ObjectType $requiredObjectType) : bool { - $type = \PHPStan\Type\TypeCombinator::removeNull($resolvedType); + $type = TypeCombinator::removeNull($resolvedType); // for falsy nullables - $type = \PHPStan\Type\TypeCombinator::remove($type, new \PHPStan\Type\Constant\ConstantBooleanType(\false)); - if (!$type instanceof \PHPStan\Type\ObjectType) { + $type = TypeCombinator::remove($type, new ConstantBooleanType(\false)); + if (!$type instanceof ObjectType) { return \false; } return $type->isInstanceOf($requiredObjectType->getClassName())->yes(); } - private function resolveByNodeTypeResolvers(\PhpParser\Node $node) : ?\PHPStan\Type\Type + private function resolveByNodeTypeResolvers(Node $node) : ?Type { foreach ($this->nodeTypeResolvers as $nodeClass => $nodeTypeResolver) { if (!\is_a($node, $nodeClass, \true)) { @@ -315,7 +315,7 @@ final class NodeTypeResolver } return null; } - private function isObjectTypeOfObjectType(\PHPStan\Type\ObjectType $resolvedObjectType, \PHPStan\Type\ObjectType $requiredObjectType) : bool + private function isObjectTypeOfObjectType(ObjectType $resolvedObjectType, ObjectType $requiredObjectType) : bool { if ($resolvedObjectType->isInstanceOf($requiredObjectType->getClassName())->yes()) { return \true; @@ -334,10 +334,10 @@ final class NodeTypeResolver } return $classReflection->isSubclassOf($requiredObjectType->getClassName()); } - private function resolveObjectType(\PHPStan\Type\ObjectType $resolvedObjectType, \PHPStan\Type\ObjectType $requiredObjectType) : bool + private function resolveObjectType(ObjectType $resolvedObjectType, ObjectType $requiredObjectType) : bool { $renamedObjectType = $this->renamedClassesDataCollector->matchClassName($resolvedObjectType); - if (!$renamedObjectType instanceof \PHPStan\Type\ObjectType) { + if (!$renamedObjectType instanceof ObjectType) { return $this->isObjectTypeOfObjectType($resolvedObjectType, $requiredObjectType); } if (!$this->isObjectTypeOfObjectType($renamedObjectType, $requiredObjectType)) { @@ -348,23 +348,23 @@ final class NodeTypeResolver /** * @return \PHPStan\Type\MixedType|\PHPStan\Type\UnionType */ - private function resolveTernaryType(\PhpParser\Node\Expr\Ternary $ternary) + private function resolveTernaryType(Ternary $ternary) { if ($ternary->if !== null) { $first = $this->getType($ternary->if); $second = $this->getType($ternary->else); if ($this->isUnionTypeable($first, $second)) { - return new \PHPStan\Type\UnionType([$first, $second]); + return new UnionType([$first, $second]); } } $condType = $this->getType($ternary->cond); - if ($this->isNullableType($ternary->cond) && $condType instanceof \PHPStan\Type\UnionType) { + if ($this->isNullableType($ternary->cond) && $condType instanceof UnionType) { $first = $condType->getTypes()[0]; $second = $this->getType($ternary->else); if ($this->isUnionTypeable($first, $second)) { - return new \PHPStan\Type\UnionType([$first, $second]); + return new UnionType([$first, $second]); } } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } } diff --git a/packages/NodeTypeResolver/NodeTypeResolver/CastTypeResolver.php b/packages/NodeTypeResolver/NodeTypeResolver/CastTypeResolver.php index 53726298481..4d9b52a8d5d 100644 --- a/packages/NodeTypeResolver/NodeTypeResolver/CastTypeResolver.php +++ b/packages/NodeTypeResolver/NodeTypeResolver/CastTypeResolver.php @@ -24,35 +24,35 @@ use Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface; /** * @implements NodeTypeResolverInterface */ -final class CastTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface +final class CastTypeResolver implements NodeTypeResolverInterface { /** * @var array, class-string> */ - private const CAST_CLASS_TO_TYPE_MAP = [\PhpParser\Node\Expr\Cast\Bool_::class => \PHPStan\Type\BooleanType::class, \PhpParser\Node\Expr\Cast\String_::class => \PHPStan\Type\StringType::class, \PhpParser\Node\Expr\Cast\Int_::class => \PHPStan\Type\IntegerType::class, \PhpParser\Node\Expr\Cast\Double::class => \PHPStan\Type\FloatType::class]; + private const CAST_CLASS_TO_TYPE_MAP = [Bool_::class => BooleanType::class, String_::class => StringType::class, Int_::class => IntegerType::class, Double::class => FloatType::class]; /** * @return array> */ public function getNodeClasses() : array { - return [\PhpParser\Node\Expr\Cast::class]; + return [Cast::class]; } /** * @param Cast $node */ - public function resolve(\PhpParser\Node $node) : \PHPStan\Type\Type + public function resolve(Node $node) : Type { foreach (self::CAST_CLASS_TO_TYPE_MAP as $castClass => $typeClass) { if (\is_a($node, $castClass, \true)) { return new $typeClass(); } } - if ($node instanceof \PhpParser\Node\Expr\Cast\Array_) { - return new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); + if ($node instanceof Array_) { + return new ArrayType(new MixedType(), new MixedType()); } - if ($node instanceof \PhpParser\Node\Expr\Cast\Object_) { - return new \PHPStan\Type\ObjectType('stdClass'); + if ($node instanceof Object_) { + return new ObjectType('stdClass'); } - throw new \Rector\Core\Exception\NotImplementedYetException(\get_class($node)); + throw new NotImplementedYetException(\get_class($node)); } } diff --git a/packages/NodeTypeResolver/NodeTypeResolver/ClassAndInterfaceTypeResolver.php b/packages/NodeTypeResolver/NodeTypeResolver/ClassAndInterfaceTypeResolver.php index cec1ac7d709..44c681e0058 100644 --- a/packages/NodeTypeResolver/NodeTypeResolver/ClassAndInterfaceTypeResolver.php +++ b/packages/NodeTypeResolver/NodeTypeResolver/ClassAndInterfaceTypeResolver.php @@ -20,14 +20,14 @@ use Rector\NodeTypeResolver\Node\AttributeKey; * * @implements NodeTypeResolverInterface */ -final class ClassAndInterfaceTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface +final class ClassAndInterfaceTypeResolver implements NodeTypeResolverInterface { /** * @readonly * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } @@ -36,22 +36,22 @@ final class ClassAndInterfaceTypeResolver implements \Rector\NodeTypeResolver\Co */ public function getNodeClasses() : array { - return [\PhpParser\Node\Stmt\Class_::class, \PhpParser\Node\Stmt\Interface_::class]; + return [Class_::class, Interface_::class]; } /** * @param Class_|Interface_ $node */ - public function resolve(\PhpParser\Node $node) : \PHPStan\Type\Type + public function resolve(Node $node) : Type { - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { + $scope = $node->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { // new node probably - return new \PHPStan\Type\MixedType(); + return new MixedType(); } $classReflection = $scope->getClassReflection(); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { - return new \PHPStan\Type\ObjectType((string) $this->nodeNameResolver->getName($node)); + if (!$classReflection instanceof ClassReflection) { + return new ObjectType((string) $this->nodeNameResolver->getName($node)); } - return new \PHPStan\Type\ObjectType($classReflection->getName(), null, $classReflection); + return new ObjectType($classReflection->getName(), null, $classReflection); } } diff --git a/packages/NodeTypeResolver/NodeTypeResolver/ClassMethodOrClassConstTypeResolver.php b/packages/NodeTypeResolver/NodeTypeResolver/ClassMethodOrClassConstTypeResolver.php index 143c8875c5e..09b1d8606e0 100644 --- a/packages/NodeTypeResolver/NodeTypeResolver/ClassMethodOrClassConstTypeResolver.php +++ b/packages/NodeTypeResolver/NodeTypeResolver/ClassMethodOrClassConstTypeResolver.php @@ -17,7 +17,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements NodeTypeResolverInterface */ -final class ClassMethodOrClassConstTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface +final class ClassMethodOrClassConstTypeResolver implements NodeTypeResolverInterface { /** * @var \Rector\NodeTypeResolver\NodeTypeResolver @@ -28,14 +28,14 @@ final class ClassMethodOrClassConstTypeResolver implements \Rector\NodeTypeResol * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(BetterNodeFinder $betterNodeFinder) { $this->betterNodeFinder = $betterNodeFinder; } /** * @required */ - public function autowire(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) : void + public function autowire(NodeTypeResolver $nodeTypeResolver) : void { $this->nodeTypeResolver = $nodeTypeResolver; } @@ -44,17 +44,17 @@ final class ClassMethodOrClassConstTypeResolver implements \Rector\NodeTypeResol */ public function getNodeClasses() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\ClassConst::class]; + return [ClassMethod::class, ClassConst::class]; } /** * @param ClassMethod|ClassConst $node */ - public function resolve(\PhpParser\Node $node) : \PHPStan\Type\Type + public function resolve(Node $node) : Type { - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($node, ClassLike::class); + if (!$classLike instanceof ClassLike) { // anonymous class - return new \PHPStan\Type\ObjectWithoutClassType(); + return new ObjectWithoutClassType(); } return $this->nodeTypeResolver->getType($classLike); } diff --git a/packages/NodeTypeResolver/NodeTypeResolver/IdentifierTypeResolver.php b/packages/NodeTypeResolver/NodeTypeResolver/IdentifierTypeResolver.php index 20991e6a142..d29ed46c5bc 100644 --- a/packages/NodeTypeResolver/NodeTypeResolver/IdentifierTypeResolver.php +++ b/packages/NodeTypeResolver/NodeTypeResolver/IdentifierTypeResolver.php @@ -14,20 +14,20 @@ final class IdentifierTypeResolver /** * @return \PHPStan\Type\StringType|\PHPStan\Type\BooleanType|\PHPStan\Type\IntegerType|\PHPStan\Type\FloatType|\PHPStan\Type\MixedType */ - public function resolve(\PhpParser\Node\Identifier $identifier) + public function resolve(Identifier $identifier) { if ($identifier->toLowerString() === 'string') { - return new \PHPStan\Type\StringType(); + return new StringType(); } if ($identifier->toLowerString() === 'bool') { - return new \PHPStan\Type\BooleanType(); + return new BooleanType(); } if ($identifier->toLowerString() === 'int') { - return new \PHPStan\Type\IntegerType(); + return new IntegerType(); } if ($identifier->toLowerString() === 'float') { - return new \PHPStan\Type\FloatType(); + return new FloatType(); } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } } diff --git a/packages/NodeTypeResolver/NodeTypeResolver/NameTypeResolver.php b/packages/NodeTypeResolver/NodeTypeResolver/NameTypeResolver.php index b2c14d277b3..9506973eb1f 100644 --- a/packages/NodeTypeResolver/NodeTypeResolver/NameTypeResolver.php +++ b/packages/NodeTypeResolver/NodeTypeResolver/NameTypeResolver.php @@ -24,7 +24,7 @@ use Rector\NodeTypeResolver\Node\AttributeKey; * * @implements NodeTypeResolverInterface */ -final class NameTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface +final class NameTypeResolver implements NodeTypeResolverInterface { /** * @readonly @@ -41,7 +41,7 @@ final class NameTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeTy * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(ReflectionProvider $reflectionProvider, BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver) { $this->reflectionProvider = $reflectionProvider; $this->betterNodeFinder = $betterNodeFinder; @@ -52,64 +52,64 @@ final class NameTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeTy */ public function getNodeClasses() : array { - return [\PhpParser\Node\Name::class, \PhpParser\Node\Name\FullyQualified::class]; + return [Name::class, FullyQualified::class]; } /** * @param Name $node */ - public function resolve(\PhpParser\Node $node) : \PHPStan\Type\Type + public function resolve(Node $node) : Type { - if ($node->toString() === \Rector\Core\Enum\ObjectReference::PARENT) { + if ($node->toString() === ObjectReference::PARENT) { return $this->resolveParent($node); } $fullyQualifiedName = $this->resolveFullyQualifiedName($node); if ($node->toString() === 'array') { - return new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); + return new ArrayType(new MixedType(), new MixedType()); } - return new \PHPStan\Type\ObjectType($fullyQualifiedName); + return new ObjectType($fullyQualifiedName); } /** * @return \PHPStan\Type\MixedType|\PHPStan\Type\ObjectType|\PHPStan\Type\UnionType */ - private function resolveParent(\PhpParser\Node\Name $name) + private function resolveParent(Name $name) { - $class = $this->betterNodeFinder->findParentType($name, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { - return new \PHPStan\Type\MixedType(); + $class = $this->betterNodeFinder->findParentType($name, Class_::class); + if (!$class instanceof Class_) { + return new MixedType(); } $className = $this->nodeNameResolver->getName($class); if (!\is_string($className)) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } if (!$this->reflectionProvider->hasClass($className)) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } $classReflection = $this->reflectionProvider->getClass($className); $parentClassObjectTypes = []; foreach ($classReflection->getParents() as $parentClassReflection) { - $parentClassObjectTypes[] = new \PHPStan\Type\ObjectType($parentClassReflection->getName()); + $parentClassObjectTypes[] = new ObjectType($parentClassReflection->getName()); } if ($parentClassObjectTypes === []) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } if (\count($parentClassObjectTypes) === 1) { return $parentClassObjectTypes[0]; } - return new \PHPStan\Type\UnionType($parentClassObjectTypes); + return new UnionType($parentClassObjectTypes); } - private function resolveFullyQualifiedName(\PhpParser\Node\Name $name) : string + private function resolveFullyQualifiedName(Name $name) : string { $nameValue = $name->toString(); - if (\in_array($nameValue, [\Rector\Core\Enum\ObjectReference::SELF, \Rector\Core\Enum\ObjectReference::STATIC, 'this'], \true)) { - $classLike = $this->betterNodeFinder->findParentType($name, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + if (\in_array($nameValue, [ObjectReference::SELF, ObjectReference::STATIC, 'this'], \true)) { + $classLike = $this->betterNodeFinder->findParentType($name, ClassLike::class); + if (!$classLike instanceof ClassLike) { return $name->toString(); } return (string) $this->nodeNameResolver->getName($classLike); } /** @var Name|null $resolvedNameNode */ - $resolvedNameNode = $name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::RESOLVED_NAME); - if ($resolvedNameNode instanceof \PhpParser\Node\Name) { + $resolvedNameNode = $name->getAttribute(AttributeKey::RESOLVED_NAME); + if ($resolvedNameNode instanceof Name) { return $resolvedNameNode->toString(); } return $nameValue; diff --git a/packages/NodeTypeResolver/NodeTypeResolver/NewTypeResolver.php b/packages/NodeTypeResolver/NodeTypeResolver/NewTypeResolver.php index ec38b2e7eda..e97e880f91b 100644 --- a/packages/NodeTypeResolver/NodeTypeResolver/NewTypeResolver.php +++ b/packages/NodeTypeResolver/NodeTypeResolver/NewTypeResolver.php @@ -22,7 +22,7 @@ use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; /** * @implements NodeTypeResolverInterface */ -final class NewTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface +final class NewTypeResolver implements NodeTypeResolverInterface { /** * @readonly @@ -34,7 +34,7 @@ final class NewTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeTyp * @var \Rector\Core\NodeAnalyzer\ClassAnalyzer */ private $classAnalyzer; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer) + public function __construct(NodeNameResolver $nodeNameResolver, ClassAnalyzer $classAnalyzer) { $this->nodeNameResolver = $nodeNameResolver; $this->classAnalyzer = $classAnalyzer; @@ -44,53 +44,53 @@ final class NewTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeTyp */ public function getNodeClasses() : array { - return [\PhpParser\Node\Expr\New_::class]; + return [New_::class]; } /** * @param New_ $node */ - public function resolve(\PhpParser\Node $node) : \PHPStan\Type\Type + public function resolve(Node $node) : Type { - if ($node->class instanceof \PhpParser\Node\Name) { + if ($node->class instanceof Name) { $className = $this->nodeNameResolver->getName($node->class); - if (!\in_array($className, [\Rector\Core\Enum\ObjectReference::SELF, \Rector\Core\Enum\ObjectReference::PARENT], \true)) { - return new \PHPStan\Type\ObjectType($className); + if (!\in_array($className, [ObjectReference::SELF, ObjectReference::PARENT], \true)) { + return new ObjectType($className); } } $isAnonymousClass = $this->classAnalyzer->isAnonymousClass($node->class); if ($isAnonymousClass) { return $this->resolveAnonymousClassType($node); } - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { + $scope = $node->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { // new node probably - return new \PHPStan\Type\MixedType(); + return new MixedType(); } return $scope->getType($node); } - private function resolveAnonymousClassType(\PhpParser\Node\Expr\New_ $new) : \PHPStan\Type\ObjectWithoutClassType + private function resolveAnonymousClassType(New_ $new) : ObjectWithoutClassType { - if (!$new->class instanceof \PhpParser\Node\Stmt\Class_) { - return new \PHPStan\Type\ObjectWithoutClassType(); + if (!$new->class instanceof Class_) { + return new ObjectWithoutClassType(); } $types = []; /** @var Class_ $class */ $class = $new->class; if ($class->extends !== null) { $parentClass = (string) $class->extends; - $types[] = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($parentClass); + $types[] = new FullyQualifiedObjectType($parentClass); } foreach ($class->implements as $implement) { $parentClass = (string) $implement; - $types[] = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($parentClass); + $types[] = new FullyQualifiedObjectType($parentClass); } if (\count($types) > 1) { - $unionType = new \PHPStan\Type\UnionType($types); - return new \PHPStan\Type\ObjectWithoutClassType($unionType); + $unionType = new UnionType($types); + return new ObjectWithoutClassType($unionType); } if (\count($types) === 1) { - return new \PHPStan\Type\ObjectWithoutClassType($types[0]); + return new ObjectWithoutClassType($types[0]); } - return new \PHPStan\Type\ObjectWithoutClassType(); + return new ObjectWithoutClassType(); } } diff --git a/packages/NodeTypeResolver/NodeTypeResolver/ParamTypeResolver.php b/packages/NodeTypeResolver/NodeTypeResolver/ParamTypeResolver.php index 4bf6fc2dca3..ce43312e7d6 100644 --- a/packages/NodeTypeResolver/NodeTypeResolver/ParamTypeResolver.php +++ b/packages/NodeTypeResolver/NodeTypeResolver/ParamTypeResolver.php @@ -28,7 +28,7 @@ use RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTravers * * @implements NodeTypeResolverInterface */ -final class ParamTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface +final class ParamTypeResolver implements NodeTypeResolverInterface { /** * @var \Rector\NodeTypeResolver\NodeTypeResolver @@ -58,7 +58,7 @@ final class ParamTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeT * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver, PhpDocInfoFactory $phpDocInfoFactory, BetterNodeFinder $betterNodeFinder) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->nodeNameResolver = $nodeNameResolver; @@ -68,7 +68,7 @@ final class ParamTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeT /** * @required */ - public function autowire(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper) : void + public function autowire(NodeTypeResolver $nodeTypeResolver, StaticTypeMapper $staticTypeMapper) : void { $this->nodeTypeResolver = $nodeTypeResolver; $this->staticTypeMapper = $staticTypeMapper; @@ -78,65 +78,65 @@ final class ParamTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeT */ public function getNodeClasses() : array { - return [\PhpParser\Node\Param::class]; + return [Param::class]; } /** * @param Param $node */ - public function resolve(\PhpParser\Node $node) : \PHPStan\Type\Type + public function resolve(Node $node) : Type { $paramType = $this->resolveFromParamType($node); - if (!$paramType instanceof \PHPStan\Type\MixedType) { + if (!$paramType instanceof MixedType) { return $paramType; } $firstVariableUseType = $this->resolveFromFirstVariableUse($node); - if (!$firstVariableUseType instanceof \PHPStan\Type\MixedType) { + if (!$firstVariableUseType instanceof MixedType) { return $firstVariableUseType; } return $this->resolveFromFunctionDocBlock($node); } - private function resolveFromParamType(\PhpParser\Node\Param $param) : \PHPStan\Type\Type + private function resolveFromParamType(Param $param) : Type { if ($param->type === null) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } - if ($param->type instanceof \PhpParser\Node\Identifier) { - return new \PHPStan\Type\MixedType(); + if ($param->type instanceof Identifier) { + return new MixedType(); } return $this->staticTypeMapper->mapPhpParserNodePHPStanType($param->type); } - private function resolveFromFirstVariableUse(\PhpParser\Node\Param $param) : \PHPStan\Type\Type + private function resolveFromFirstVariableUse(Param $param) : Type { - $classMethod = $this->betterNodeFinder->findParentType($param, \PhpParser\Node\Stmt\ClassMethod::class); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { - return new \PHPStan\Type\MixedType(); + $classMethod = $this->betterNodeFinder->findParentType($param, ClassMethod::class); + if (!$classMethod instanceof ClassMethod) { + return new MixedType(); } $paramName = $this->nodeNameResolver->getName($param); - $paramStaticType = new \PHPStan\Type\MixedType(); + $paramStaticType = new MixedType(); // special case for param inside method/function - $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (\PhpParser\Node $node) use($paramName, &$paramStaticType) : ?int { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) use($paramName, &$paramStaticType) : ?int { + if (!$node instanceof Variable) { return null; } if (!$this->nodeNameResolver->isName($node, $paramName)) { return null; } $paramStaticType = $this->nodeTypeResolver->getType($node); - return \PhpParser\NodeTraverser::STOP_TRAVERSAL; + return NodeTraverser::STOP_TRAVERSAL; }); return $paramStaticType; } - private function resolveFromFunctionDocBlock(\PhpParser\Node\Param $param) : \PHPStan\Type\Type + private function resolveFromFunctionDocBlock(Param $param) : Type { $phpDocInfo = $this->getFunctionLikePhpDocInfo($param); $paramName = $this->nodeNameResolver->getName($param); return $phpDocInfo->getParamType($paramName); } - private function getFunctionLikePhpDocInfo(\PhpParser\Node\Param $param) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo + private function getFunctionLikePhpDocInfo(Param $param) : PhpDocInfo { - $parentNode = $param->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node\FunctionLike) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $parentNode = $param->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof FunctionLike) { + throw new ShouldNotHappenException(); } return $this->phpDocInfoFactory->createFromNodeOrEmpty($parentNode); } diff --git a/packages/NodeTypeResolver/NodeTypeResolver/PropertyFetchTypeResolver.php b/packages/NodeTypeResolver/NodeTypeResolver/PropertyFetchTypeResolver.php index dbb66cef997..0d6ebed1f18 100644 --- a/packages/NodeTypeResolver/NodeTypeResolver/PropertyFetchTypeResolver.php +++ b/packages/NodeTypeResolver/NodeTypeResolver/PropertyFetchTypeResolver.php @@ -22,7 +22,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; * * @implements NodeTypeResolverInterface */ -final class PropertyFetchTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface +final class PropertyFetchTypeResolver implements NodeTypeResolverInterface { /** * @var \Rector\NodeTypeResolver\NodeTypeResolver @@ -43,7 +43,7 @@ final class PropertyFetchTypeResolver implements \Rector\NodeTypeResolver\Contra * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider, BetterNodeFinder $betterNodeFinder) { $this->nodeNameResolver = $nodeNameResolver; $this->reflectionProvider = $reflectionProvider; @@ -52,7 +52,7 @@ final class PropertyFetchTypeResolver implements \Rector\NodeTypeResolver\Contra /** * @required */ - public function autowire(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) : void + public function autowire(NodeTypeResolver $nodeTypeResolver) : void { $this->nodeTypeResolver = $nodeTypeResolver; } @@ -61,52 +61,52 @@ final class PropertyFetchTypeResolver implements \Rector\NodeTypeResolver\Contra */ public function getNodeClasses() : array { - return [\PhpParser\Node\Expr\PropertyFetch::class]; + return [PropertyFetch::class]; } /** * @param PropertyFetch $node */ - public function resolve(\PhpParser\Node $node) : \PHPStan\Type\Type + public function resolve(Node $node) : Type { // compensate 3rd party non-analysed property reflection $vendorPropertyType = $this->getVendorPropertyFetchType($node); - if (!$vendorPropertyType instanceof \PHPStan\Type\MixedType) { + if (!$vendorPropertyType instanceof MixedType) { return $vendorPropertyType; } - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassLike::class); + $scope = $node->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { + $classLike = $this->betterNodeFinder->findParentType($node, ClassLike::class); // fallback to class, since property fetches are not scoped by PHPStan - if ($classLike instanceof \PhpParser\Node\Stmt\ClassLike) { - $scope = $classLike->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + if ($classLike instanceof ClassLike) { + $scope = $classLike->getAttribute(AttributeKey::SCOPE); } - if (!$scope instanceof \PHPStan\Analyser\Scope) { - return new \PHPStan\Type\MixedType(); + if (!$scope instanceof Scope) { + return new MixedType(); } } return $scope->getType($node); } - private function getVendorPropertyFetchType(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : \PHPStan\Type\Type + private function getVendorPropertyFetchType(PropertyFetch $propertyFetch) : Type { // 3rd party code $propertyName = $this->nodeNameResolver->getName($propertyFetch->name); if ($propertyName === null) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } $varType = $this->nodeTypeResolver->getType($propertyFetch->var); - if (!$varType instanceof \PHPStan\Type\ObjectType) { - return new \PHPStan\Type\MixedType(); + if (!$varType instanceof ObjectType) { + return new MixedType(); } if (!$this->reflectionProvider->hasClass($varType->getClassName())) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } $classReflection = $this->reflectionProvider->getClass($varType->getClassName()); if (!$classReflection->hasProperty($propertyName)) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } - $propertyFetchScope = $propertyFetch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $propertyFetchScope = $propertyFetch->getAttribute(AttributeKey::SCOPE); if ($propertyFetchScope === null) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } $propertyReflection = $classReflection->getProperty($propertyName, $propertyFetchScope); return $propertyReflection->getReadableType(); diff --git a/packages/NodeTypeResolver/NodeTypeResolver/PropertyTypeResolver.php b/packages/NodeTypeResolver/NodeTypeResolver/PropertyTypeResolver.php index 868a7af7746..df882dd9ebb 100644 --- a/packages/NodeTypeResolver/NodeTypeResolver/PropertyTypeResolver.php +++ b/packages/NodeTypeResolver/NodeTypeResolver/PropertyTypeResolver.php @@ -17,7 +17,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; * * @implements NodeTypeResolverInterface */ -final class PropertyTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface +final class PropertyTypeResolver implements NodeTypeResolverInterface { /** * @var \Rector\NodeTypeResolver\NodeTypeResolver @@ -26,7 +26,7 @@ final class PropertyTypeResolver implements \Rector\NodeTypeResolver\Contract\No /** * @required */ - public function autowire(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) : void + public function autowire(NodeTypeResolver $nodeTypeResolver) : void { $this->nodeTypeResolver = $nodeTypeResolver; } @@ -35,16 +35,16 @@ final class PropertyTypeResolver implements \Rector\NodeTypeResolver\Contract\No */ public function getNodeClasses() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function resolve(\PhpParser\Node $node) : \PHPStan\Type\Type + public function resolve(Node $node) : Type { // fake property to local PropertyFetch → PHPStan understands that - $propertyFetch = new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable('this'), (string) $node->props[0]->name); - $propertyFetch->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE)); + $propertyFetch = new PropertyFetch(new Variable('this'), (string) $node->props[0]->name); + $propertyFetch->setAttribute(AttributeKey::SCOPE, $node->getAttribute(AttributeKey::SCOPE)); return $this->nodeTypeResolver->getType($propertyFetch); } } diff --git a/packages/NodeTypeResolver/NodeTypeResolver/ReturnTypeResolver.php b/packages/NodeTypeResolver/NodeTypeResolver/ReturnTypeResolver.php index 5b15156e1f7..fffec0ff1be 100644 --- a/packages/NodeTypeResolver/NodeTypeResolver/ReturnTypeResolver.php +++ b/packages/NodeTypeResolver/NodeTypeResolver/ReturnTypeResolver.php @@ -13,7 +13,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements NodeTypeResolverInterface */ -final class ReturnTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface +final class ReturnTypeResolver implements NodeTypeResolverInterface { /** * @var \Rector\NodeTypeResolver\NodeTypeResolver @@ -22,7 +22,7 @@ final class ReturnTypeResolver implements \Rector\NodeTypeResolver\Contract\Node /** * @required */ - public function autowire(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) : void + public function autowire(NodeTypeResolver $nodeTypeResolver) : void { $this->nodeTypeResolver = $nodeTypeResolver; } @@ -31,15 +31,15 @@ final class ReturnTypeResolver implements \Rector\NodeTypeResolver\Contract\Node */ public function getNodeClasses() : array { - return [\PhpParser\Node\Stmt\Return_::class]; + return [Return_::class]; } /** * @param Return_ $node */ - public function resolve(\PhpParser\Node $node) : \PHPStan\Type\Type + public function resolve(Node $node) : Type { if ($node->expr === null) { - return new \PHPStan\Type\VoidType(); + return new VoidType(); } return $this->nodeTypeResolver->getType($node->expr); } diff --git a/packages/NodeTypeResolver/NodeTypeResolver/ScalarTypeResolver.php b/packages/NodeTypeResolver/NodeTypeResolver/ScalarTypeResolver.php index 5cfffe1ec24..7dc6d0da8ab 100644 --- a/packages/NodeTypeResolver/NodeTypeResolver/ScalarTypeResolver.php +++ b/packages/NodeTypeResolver/NodeTypeResolver/ScalarTypeResolver.php @@ -20,32 +20,32 @@ use Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface; /** * @implements NodeTypeResolverInterface */ -final class ScalarTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface +final class ScalarTypeResolver implements NodeTypeResolverInterface { /** * @return array> */ public function getNodeClasses() : array { - return [\PhpParser\Node\Scalar::class]; + return [Scalar::class]; } - public function resolve(\PhpParser\Node $node) : \PHPStan\Type\Type + public function resolve(Node $node) : Type { - if ($node instanceof \PhpParser\Node\Scalar\DNumber) { - return new \PHPStan\Type\Constant\ConstantFloatType((float) $node->value); + if ($node instanceof DNumber) { + return new ConstantFloatType((float) $node->value); } - if ($node instanceof \PhpParser\Node\Scalar\String_) { - return new \PHPStan\Type\Constant\ConstantStringType((string) $node->value); + if ($node instanceof String_) { + return new ConstantStringType((string) $node->value); } - if ($node instanceof \PhpParser\Node\Scalar\LNumber) { - return new \PHPStan\Type\Constant\ConstantIntegerType((int) $node->value); + if ($node instanceof LNumber) { + return new ConstantIntegerType((int) $node->value); } - if ($node instanceof \PhpParser\Node\Scalar\MagicConst) { - return new \PHPStan\Type\Constant\ConstantStringType($node->getName()); + if ($node instanceof MagicConst) { + return new ConstantStringType($node->getName()); } - if ($node instanceof \PhpParser\Node\Scalar\Encapsed) { - return new \PHPStan\Type\MixedType(); + if ($node instanceof Encapsed) { + return new MixedType(); } - throw new \Rector\Core\Exception\NotImplementedYetException(); + throw new NotImplementedYetException(); } } diff --git a/packages/NodeTypeResolver/NodeTypeResolver/StaticCallMethodCallTypeResolver.php b/packages/NodeTypeResolver/NodeTypeResolver/StaticCallMethodCallTypeResolver.php index fd52237d57f..b7d6496011a 100644 --- a/packages/NodeTypeResolver/NodeTypeResolver/StaticCallMethodCallTypeResolver.php +++ b/packages/NodeTypeResolver/NodeTypeResolver/StaticCallMethodCallTypeResolver.php @@ -20,7 +20,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements NodeTypeResolverInterface */ -final class StaticCallMethodCallTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface +final class StaticCallMethodCallTypeResolver implements NodeTypeResolverInterface { /** * @var \Rector\NodeTypeResolver\NodeTypeResolver @@ -36,7 +36,7 @@ final class StaticCallMethodCallTypeResolver implements \Rector\NodeTypeResolver * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider) { $this->nodeNameResolver = $nodeNameResolver; $this->reflectionProvider = $reflectionProvider; @@ -44,7 +44,7 @@ final class StaticCallMethodCallTypeResolver implements \Rector\NodeTypeResolver /** * @required */ - public function autowire(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) : void + public function autowire(NodeTypeResolver $nodeTypeResolver) : void { $this->nodeTypeResolver = $nodeTypeResolver; } @@ -53,43 +53,43 @@ final class StaticCallMethodCallTypeResolver implements \Rector\NodeTypeResolver */ public function getNodeClasses() : array { - return [\PhpParser\Node\Expr\StaticCall::class, \PhpParser\Node\Expr\MethodCall::class]; + return [StaticCall::class, MethodCall::class]; } /** * @param StaticCall|MethodCall $node */ - public function resolve(\PhpParser\Node $node) : \PHPStan\Type\Type + public function resolve(Node $node) : Type { $methodName = $this->nodeNameResolver->getName($node->name); // no specific method found, return class types, e.g. ::$method() if (!\is_string($methodName)) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { - return new \PHPStan\Type\MixedType(); + $scope = $node->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { + return new MixedType(); } $nodeReturnType = $scope->getType($node); - if (!$nodeReturnType instanceof \PHPStan\Type\MixedType) { + if (!$nodeReturnType instanceof MixedType) { return $nodeReturnType; } - if ($node instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node instanceof MethodCall) { $callerType = $this->nodeTypeResolver->getType($node->var); } else { $callerType = $this->nodeTypeResolver->getType($node->class); } foreach ($callerType->getReferencedClasses() as $referencedClass) { $classMethodReturnType = $this->resolveClassMethodReturnType($referencedClass, $methodName, $scope); - if (!$classMethodReturnType instanceof \PHPStan\Type\MixedType) { + if (!$classMethodReturnType instanceof MixedType) { return $classMethodReturnType; } } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } - private function resolveClassMethodReturnType(string $referencedClass, string $methodName, \PHPStan\Analyser\Scope $scope) : \PHPStan\Type\Type + private function resolveClassMethodReturnType(string $referencedClass, string $methodName, Scope $scope) : Type { if (!$this->reflectionProvider->hasClass($referencedClass)) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } $classReflection = $this->reflectionProvider->getClass($referencedClass); foreach ($classReflection->getAncestors() as $ancestorClassReflection) { @@ -97,11 +97,11 @@ final class StaticCallMethodCallTypeResolver implements \Rector\NodeTypeResolver continue; } $methodReflection = $ancestorClassReflection->getMethod($methodName, $scope); - if ($methodReflection instanceof \PHPStan\Reflection\Php\PhpMethodReflection) { - $parametersAcceptorWithPhpDocs = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); + if ($methodReflection instanceof PhpMethodReflection) { + $parametersAcceptorWithPhpDocs = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); return $parametersAcceptorWithPhpDocs->getReturnType(); } } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } } diff --git a/packages/NodeTypeResolver/NodeTypeResolver/TraitTypeResolver.php b/packages/NodeTypeResolver/NodeTypeResolver/TraitTypeResolver.php index c6d03131ca4..0dfff4cc837 100644 --- a/packages/NodeTypeResolver/NodeTypeResolver/TraitTypeResolver.php +++ b/packages/NodeTypeResolver/NodeTypeResolver/TraitTypeResolver.php @@ -16,14 +16,14 @@ use Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface; * * @implements NodeTypeResolverInterface */ -final class TraitTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface +final class TraitTypeResolver implements NodeTypeResolverInterface { /** * @readonly * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ReflectionProvider $reflectionProvider) { $this->reflectionProvider = $reflectionProvider; } @@ -32,26 +32,26 @@ final class TraitTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeT */ public function getNodeClasses() : array { - return [\PhpParser\Node\Stmt\Trait_::class]; + return [Trait_::class]; } /** * @param Trait_ $node */ - public function resolve(\PhpParser\Node $node) : \PHPStan\Type\Type + public function resolve(Node $node) : Type { $traitName = (string) $node->namespacedName; if (!$this->reflectionProvider->hasClass($traitName)) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } $classReflection = $this->reflectionProvider->getClass($traitName); $types = []; - $types[] = new \PHPStan\Type\ObjectType($traitName); + $types[] = new ObjectType($traitName); foreach ($classReflection->getTraits() as $usedTraitReflection) { - $types[] = new \PHPStan\Type\ObjectType($usedTraitReflection->getName()); + $types[] = new ObjectType($usedTraitReflection->getName()); } if (\count($types) === 1) { return $types[0]; } - return new \PHPStan\Type\UnionType($types); + return new UnionType($types); } } diff --git a/packages/NodeTypeResolver/NodeTypeResolver/VariableTypeResolver.php b/packages/NodeTypeResolver/NodeTypeResolver/VariableTypeResolver.php index 437bbfbef6f..dd9aafa8b2e 100644 --- a/packages/NodeTypeResolver/NodeTypeResolver/VariableTypeResolver.php +++ b/packages/NodeTypeResolver/NodeTypeResolver/VariableTypeResolver.php @@ -18,7 +18,7 @@ use Rector\NodeTypeResolver\Node\AttributeKey; * * @implements NodeTypeResolverInterface */ -final class VariableTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface +final class VariableTypeResolver implements NodeTypeResolverInterface { /** * @readonly @@ -30,7 +30,7 @@ final class VariableTypeResolver implements \Rector\NodeTypeResolver\Contract\No * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory */ private $phpDocInfoFactory; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory) + public function __construct(NodeNameResolver $nodeNameResolver, PhpDocInfoFactory $phpDocInfoFactory) { $this->nodeNameResolver = $nodeNameResolver; $this->phpDocInfoFactory = $phpDocInfoFactory; @@ -40,51 +40,51 @@ final class VariableTypeResolver implements \Rector\NodeTypeResolver\Contract\No */ public function getNodeClasses() : array { - return [\PhpParser\Node\Expr\Variable::class]; + return [Variable::class]; } /** * @param Variable $node */ - public function resolve(\PhpParser\Node $node) : \PHPStan\Type\Type + public function resolve(Node $node) : Type { $variableName = $this->nodeNameResolver->getName($node); if ($variableName === null) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } $scopeType = $this->resolveTypesFromScope($node, $variableName); - if (!$scopeType instanceof \PHPStan\Type\MixedType) { + if (!$scopeType instanceof MixedType) { return $scopeType; } // get from annotation $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); return $phpDocInfo->getVarType(); } - private function resolveTypesFromScope(\PhpParser\Node\Expr\Variable $variable, string $variableName) : \PHPStan\Type\Type + private function resolveTypesFromScope(Variable $variable, string $variableName) : Type { $scope = $this->resolveNodeScope($variable); - if (!$scope instanceof \PHPStan\Analyser\Scope) { - return new \PHPStan\Type\MixedType(); + if (!$scope instanceof Scope) { + return new MixedType(); } if (!$scope->hasVariableType($variableName)->yes()) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } // this → object type is easier to work with and consistent with the rest of the code return $scope->getVariableType($variableName); } - private function resolveNodeScope(\PhpParser\Node\Expr\Variable $variable) : ?\PHPStan\Analyser\Scope + private function resolveNodeScope(Variable $variable) : ?Scope { - $scope = $variable->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if ($scope instanceof \PHPStan\Analyser\Scope) { + $scope = $variable->getAttribute(AttributeKey::SCOPE); + if ($scope instanceof Scope) { return $scope; } return $this->resolveFromParentNodes($variable); } - private function resolveFromParentNodes(\PhpParser\Node\Expr\Variable $variable) : ?\PHPStan\Analyser\Scope + private function resolveFromParentNodes(Variable $variable) : ?Scope { - $parent = $variable->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node) { + $parent = $variable->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Node) { return null; } - return $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + return $parent->getAttribute(AttributeKey::SCOPE); } } diff --git a/packages/NodeTypeResolver/NodeVisitor/FunctionLikeParamArgPositionNodeVisitor.php b/packages/NodeTypeResolver/NodeVisitor/FunctionLikeParamArgPositionNodeVisitor.php index fe144a08f3f..b4b12231afd 100644 --- a/packages/NodeTypeResolver/NodeVisitor/FunctionLikeParamArgPositionNodeVisitor.php +++ b/packages/NodeTypeResolver/NodeVisitor/FunctionLikeParamArgPositionNodeVisitor.php @@ -11,21 +11,21 @@ use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\FunctionLike; use PhpParser\NodeVisitorAbstract; use Rector\NodeTypeResolver\Node\AttributeKey; -final class FunctionLikeParamArgPositionNodeVisitor extends \PhpParser\NodeVisitorAbstract +final class FunctionLikeParamArgPositionNodeVisitor extends NodeVisitorAbstract { /** * @return Node */ - public function enterNode(\PhpParser\Node $node) : ?\PhpParser\Node + public function enterNode(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\FunctionLike) { + if ($node instanceof FunctionLike) { foreach ($node->getParams() as $position => $param) { - $param->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARAMETER_POSITION, $position); + $param->setAttribute(AttributeKey::PARAMETER_POSITION, $position); } } - if ($node instanceof \PhpParser\Node\Expr\MethodCall || $node instanceof \PhpParser\Node\Expr\StaticCall || $node instanceof \PhpParser\Node\Expr\FuncCall || $node instanceof \PhpParser\Node\Expr\New_) { + if ($node instanceof MethodCall || $node instanceof StaticCall || $node instanceof FuncCall || $node instanceof New_) { foreach ($node->args as $position => $arg) { - $arg->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ARGUMENT_POSITION, $position); + $arg->setAttribute(AttributeKey::ARGUMENT_POSITION, $position); } } return $node; diff --git a/packages/NodeTypeResolver/PHPStan/Scope/NodeVisitor/RemoveDeepChainMethodCallNodeVisitor.php b/packages/NodeTypeResolver/PHPStan/Scope/NodeVisitor/RemoveDeepChainMethodCallNodeVisitor.php index 521821e6527..f15068ad7e2 100644 --- a/packages/NodeTypeResolver/PHPStan/Scope/NodeVisitor/RemoveDeepChainMethodCallNodeVisitor.php +++ b/packages/NodeTypeResolver/PHPStan/Scope/NodeVisitor/RemoveDeepChainMethodCallNodeVisitor.php @@ -15,7 +15,7 @@ use RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider; /** * Skips performance trap in PHPStan: https://github.com/phpstan/phpstan/issues/254 */ -final class RemoveDeepChainMethodCallNodeVisitor extends \PhpParser\NodeVisitorAbstract +final class RemoveDeepChainMethodCallNodeVisitor extends NodeVisitorAbstract { /** * @readonly @@ -31,21 +31,21 @@ final class RemoveDeepChainMethodCallNodeVisitor extends \PhpParser\NodeVisitorA * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider) + public function __construct(BetterNodeFinder $betterNodeFinder, ParameterProvider $parameterProvider) { $this->betterNodeFinder = $betterNodeFinder; - $this->nestedChainMethodCallLimit = (int) $parameterProvider->provideParameter(\Rector\Core\Configuration\Option::NESTED_CHAIN_METHOD_CALL_LIMIT); + $this->nestedChainMethodCallLimit = (int) $parameterProvider->provideParameter(Option::NESTED_CHAIN_METHOD_CALL_LIMIT); } - public function enterNode(\PhpParser\Node $node) : ?int + public function enterNode(Node $node) : ?int { - if (!$node instanceof \PhpParser\Node\Stmt\Expression) { + if (!$node instanceof Expression) { return null; } - if ($node->expr instanceof \PhpParser\Node\Expr\MethodCall && $node->expr->var instanceof \PhpParser\Node\Expr\MethodCall) { - $nestedChainMethodCalls = $this->betterNodeFinder->findInstanceOf([$node->expr], \PhpParser\Node\Expr\MethodCall::class); + if ($node->expr instanceof MethodCall && $node->expr->var instanceof MethodCall) { + $nestedChainMethodCalls = $this->betterNodeFinder->findInstanceOf([$node->expr], MethodCall::class); if (\count($nestedChainMethodCalls) > $this->nestedChainMethodCallLimit) { $this->removingExpression = $node; - return \PhpParser\NodeTraverser::DONT_TRAVERSE_CHILDREN; + return NodeTraverser::DONT_TRAVERSE_CHILDREN; } } return null; @@ -53,11 +53,11 @@ final class RemoveDeepChainMethodCallNodeVisitor extends \PhpParser\NodeVisitorA /** * @return \PhpParser\Node\Stmt\Nop|\PhpParser\Node */ - public function leaveNode(\PhpParser\Node $node) + public function leaveNode(Node $node) { if ($node === $this->removingExpression) { // keep any node, so we don't remove it permanently - $nop = new \PhpParser\Node\Stmt\Nop(); + $nop = new Nop(); $nop->setAttributes($node->getAttributes()); return $nop; } diff --git a/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php b/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php index 0473722d7bf..49a92d64dab 100644 --- a/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php +++ b/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php @@ -40,7 +40,7 @@ use Rector\Core\Util\StringUtils; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor\RemoveDeepChainMethodCallNodeVisitor; use RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @inspired by https://github.com/silverstripe/silverstripe-upgrader/blob/532182b23e854d02e0b27e68ebc394f436de0682/src/UpgradeRule/PHP/Visitor/PHPStanScopeVisitor.php @@ -102,7 +102,7 @@ final class PHPStanNodeScopeResolver * @var \Rector\Core\StaticReflection\SourceLocator\ParentAttributeSourceLocator */ private $parentAttributeSourceLocator; - public function __construct(\Rector\Caching\Detector\ChangedFilesDetector $changedFilesDetector, \Rector\Caching\FileSystem\DependencyResolver $dependencyResolver, \PHPStan\Analyser\NodeScopeResolver $nodeScopeResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor\RemoveDeepChainMethodCallNodeVisitor $removeDeepChainMethodCallNodeVisitor, \Rector\NodeTypeResolver\PHPStan\Scope\ScopeFactory $scopeFactory, \RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor $privatesAccessor, \Rector\Core\StaticReflection\SourceLocator\RenamedClassesSourceLocator $renamedClassesSourceLocator, \Rector\Core\StaticReflection\SourceLocator\ParentAttributeSourceLocator $parentAttributeSourceLocator) + public function __construct(ChangedFilesDetector $changedFilesDetector, DependencyResolver $dependencyResolver, NodeScopeResolver $nodeScopeResolver, ReflectionProvider $reflectionProvider, RemoveDeepChainMethodCallNodeVisitor $removeDeepChainMethodCallNodeVisitor, \Rector\NodeTypeResolver\PHPStan\Scope\ScopeFactory $scopeFactory, PrivatesAccessor $privatesAccessor, RenamedClassesSourceLocator $renamedClassesSourceLocator, ParentAttributeSourceLocator $parentAttributeSourceLocator) { $this->changedFilesDetector = $changedFilesDetector; $this->dependencyResolver = $dependencyResolver; @@ -118,86 +118,86 @@ final class PHPStanNodeScopeResolver * @param Stmt[] $stmts * @return Stmt[] */ - public function processNodes(array $stmts, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo, ?\PHPStan\Analyser\MutatingScope $formerMutatingScope = null) : array + public function processNodes(array $stmts, SmartFileInfo $smartFileInfo, ?MutatingScope $formerMutatingScope = null) : array { - $isScopeRefreshing = $formerMutatingScope instanceof \PHPStan\Analyser\MutatingScope; + $isScopeRefreshing = $formerMutatingScope instanceof MutatingScope; /** * The stmts must be array of Stmt, or it will be silently skipped by PHPStan * @see vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:282 */ - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsInstanceOf($stmts, \PhpParser\Node\Stmt::class); + Assert::allIsInstanceOf($stmts, Stmt::class); $this->removeDeepChainMethodCallNodes($stmts); $scope = $formerMutatingScope ?? $this->scopeFactory->createFromFile($smartFileInfo); // skip chain method calls, performance issue: https://github.com/phpstan/phpstan/issues/254 - $nodeCallback = function (\PhpParser\Node $node, \PHPStan\Analyser\MutatingScope $mutatingScope) use(&$nodeCallback, $isScopeRefreshing) : void { - if ($node instanceof \PhpParser\Node\Arg) { - $node->value->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, $mutatingScope); + $nodeCallback = function (Node $node, MutatingScope $mutatingScope) use(&$nodeCallback, $isScopeRefreshing) : void { + if ($node instanceof Arg) { + $node->value->setAttribute(AttributeKey::SCOPE, $mutatingScope); } - if ($node instanceof \PhpParser\Node\Stmt\Foreach_) { + if ($node instanceof Foreach_) { // decorate value as well - $node->valueVar->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, $mutatingScope); + $node->valueVar->setAttribute(AttributeKey::SCOPE, $mutatingScope); } - if ($node instanceof \PhpParser\Node\Stmt\Property) { + if ($node instanceof Property) { foreach ($node->props as $propertyProperty) { - $propertyProperty->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, $mutatingScope); - if ($propertyProperty->default instanceof \PhpParser\Node\Expr) { - $propertyProperty->default->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, $mutatingScope); + $propertyProperty->setAttribute(AttributeKey::SCOPE, $mutatingScope); + if ($propertyProperty->default instanceof Expr) { + $propertyProperty->default->setAttribute(AttributeKey::SCOPE, $mutatingScope); } } } - if ($node instanceof \PhpParser\Node\Stmt\Switch_) { + if ($node instanceof Switch_) { // decorate value as well foreach ($node->cases as $case) { - $case->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, $mutatingScope); + $case->setAttribute(AttributeKey::SCOPE, $mutatingScope); } } - if ($node instanceof \PhpParser\Node\Stmt\TryCatch && $node->finally instanceof \PhpParser\Node\Stmt\Finally_) { - $node->finally->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, $mutatingScope); + if ($node instanceof TryCatch && $node->finally instanceof Finally_) { + $node->finally->setAttribute(AttributeKey::SCOPE, $mutatingScope); } - if ($node instanceof \PhpParser\Node\Expr\Assign) { + if ($node instanceof Assign) { // decorate value as well - $node->expr->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, $mutatingScope); - $node->var->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, $mutatingScope); + $node->expr->setAttribute(AttributeKey::SCOPE, $mutatingScope); + $node->var->setAttribute(AttributeKey::SCOPE, $mutatingScope); } // decorate value as well - if ($node instanceof \PhpParser\Node\Stmt\Return_ && $node->expr instanceof \PhpParser\Node\Expr) { - $node->expr->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, $mutatingScope); + if ($node instanceof Return_ && $node->expr instanceof Expr) { + $node->expr->setAttribute(AttributeKey::SCOPE, $mutatingScope); } // scope is missing on attributes // @todo decorate parent nodes too - if ($node instanceof \PhpParser\Node\Stmt\Property) { + if ($node instanceof Property) { foreach ($node->attrGroups as $attrGroup) { foreach ($attrGroup->attrs as $attribute) { - $attribute->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, $mutatingScope); + $attribute->setAttribute(AttributeKey::SCOPE, $mutatingScope); } } } - if ($node instanceof \PhpParser\Node\Stmt\Trait_) { + if ($node instanceof Trait_) { $traitName = $this->resolveClassName($node); $traitReflectionClass = $this->reflectionProvider->getClass($traitName); $traitScope = clone $mutatingScope; - $scopeContext = $this->privatesAccessor->getPrivatePropertyOfClass($traitScope, self::CONTEXT, \PHPStan\Analyser\ScopeContext::class); + $scopeContext = $this->privatesAccessor->getPrivatePropertyOfClass($traitScope, self::CONTEXT, ScopeContext::class); $traitContext = clone $scopeContext; // before entering the class/trait again, we have to tell scope no class was set, otherwise it crashes - $this->privatesAccessor->setPrivatePropertyOfClass($traitContext, 'classReflection', $traitReflectionClass, \PHPStan\Reflection\ClassReflection::class); - $this->privatesAccessor->setPrivatePropertyOfClass($traitScope, self::CONTEXT, $traitContext, \PHPStan\Analyser\ScopeContext::class); - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, $traitScope); + $this->privatesAccessor->setPrivatePropertyOfClass($traitContext, 'classReflection', $traitReflectionClass, ClassReflection::class); + $this->privatesAccessor->setPrivatePropertyOfClass($traitScope, self::CONTEXT, $traitContext, ScopeContext::class); + $node->setAttribute(AttributeKey::SCOPE, $traitScope); $this->nodeScopeResolver->processNodes($node->stmts, $traitScope, $nodeCallback); return; } // the class reflection is resolved AFTER entering to class node // so we need to get it from the first after this one - if ($node instanceof \PhpParser\Node\Stmt\Class_ || $node instanceof \PhpParser\Node\Stmt\Interface_ || $node instanceof \PhpParser\Node\Stmt\Enum_) { + if ($node instanceof Class_ || $node instanceof Interface_ || $node instanceof Enum_) { /** @var MutatingScope $mutatingScope */ $mutatingScope = $this->resolveClassOrInterfaceScope($node, $mutatingScope, $isScopeRefreshing); } // special case for unreachable nodes - if ($node instanceof \PHPStan\Node\UnreachableStatementNode) { + if ($node instanceof UnreachableStatementNode) { $originalStmt = $node->getOriginalStatement(); - $originalStmt->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::IS_UNREACHABLE, \true); - $originalStmt->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, $mutatingScope); + $originalStmt->setAttribute(AttributeKey::IS_UNREACHABLE, \true); + $originalStmt->setAttribute(AttributeKey::SCOPE, $mutatingScope); } else { - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, $mutatingScope); + $node->setAttribute(AttributeKey::SCOPE, $mutatingScope); } }; $this->decoratePHPStanNodeScopeResolverWithRenamedClassSourceLocator($this->nodeScopeResolver); @@ -208,7 +208,7 @@ final class PHPStanNodeScopeResolver * @param callable(Node $node, MutatingScope $scope): void $nodeCallback * @return Stmt[] */ - private function processNodesWithDependentFiles(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo, array $stmts, \PHPStan\Analyser\MutatingScope $mutatingScope, callable $nodeCallback) : array + private function processNodesWithDependentFiles(SmartFileInfo $smartFileInfo, array $stmts, MutatingScope $mutatingScope, callable $nodeCallback) : array { $this->nodeScopeResolver->processNodes($stmts, $mutatingScope, $nodeCallback); $this->resolveAndSaveDependentFiles($stmts, $mutatingScope, $smartFileInfo); @@ -219,18 +219,18 @@ final class PHPStanNodeScopeResolver */ private function removeDeepChainMethodCallNodes(array $nodes) : void { - $nodeTraverser = new \PhpParser\NodeTraverser(); + $nodeTraverser = new NodeTraverser(); $nodeTraverser->addVisitor($this->removeDeepChainMethodCallNodeVisitor); $nodeTraverser->traverse($nodes); } /** * @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Interface_|\PhpParser\Node\Stmt\Enum_ $classLike */ - private function resolveClassOrInterfaceScope($classLike, \PHPStan\Analyser\MutatingScope $mutatingScope, bool $isScopeRefreshing) : \PHPStan\Analyser\MutatingScope + private function resolveClassOrInterfaceScope($classLike, MutatingScope $mutatingScope, bool $isScopeRefreshing) : MutatingScope { $className = $this->resolveClassName($classLike); // is anonymous class? - not possible to enter it since PHPStan 0.12.33, see https://github.com/phpstan/phpstan-src/commit/e87fb0ec26f9c8552bbeef26a868b1e5d8185e91 - if ($classLike instanceof \PhpParser\Node\Stmt\Class_ && \Rector\Core\Util\StringUtils::isMatch($className, self::ANONYMOUS_CLASS_START_REGEX)) { + if ($classLike instanceof Class_ && StringUtils::isMatch($className, self::ANONYMOUS_CLASS_START_REGEX)) { $classReflection = $this->reflectionProvider->getAnonymousClassReflection($classLike, $mutatingScope); } elseif (!$this->reflectionProvider->hasClass($className)) { return $mutatingScope; @@ -249,25 +249,25 @@ final class PHPStanNodeScopeResolver */ private function resolveClassName($classLike) : string { - if ($classLike->namespacedName instanceof \PhpParser\Node\Name) { + if ($classLike->namespacedName instanceof Name) { return (string) $classLike->namespacedName; } if ($classLike->name === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } return $classLike->name->toString(); } /** * @param Stmt[] $stmts */ - private function resolveAndSaveDependentFiles(array $stmts, \PHPStan\Analyser\MutatingScope $mutatingScope, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : void + private function resolveAndSaveDependentFiles(array $stmts, MutatingScope $mutatingScope, SmartFileInfo $smartFileInfo) : void { $dependentFiles = []; foreach ($stmts as $stmt) { try { $nodeDependentFiles = $this->dependencyResolver->resolveDependencies($stmt, $mutatingScope); $dependentFiles = \array_merge($dependentFiles, $nodeDependentFiles); - } catch (\PHPStan\AnalysedCodeException $exception) { + } catch (AnalysedCodeException $exception) { // @ignoreException } } @@ -280,16 +280,16 @@ final class PHPStanNodeScopeResolver * That's why we have to skip fatal errors of PHPStan caused by missing class, * so Rector can fix it first. Then run Rector again to refactor code with new classes. */ - private function decoratePHPStanNodeScopeResolverWithRenamedClassSourceLocator(\PHPStan\Analyser\NodeScopeResolver $nodeScopeResolver) : void + private function decoratePHPStanNodeScopeResolverWithRenamedClassSourceLocator(NodeScopeResolver $nodeScopeResolver) : void { // 1. get PHPStan locator /** @var MemoizingReflector $classReflector */ - $classReflector = $this->privatesAccessor->getPrivatePropertyOfClass($nodeScopeResolver, 'reflector', \PHPStan\BetterReflection\Reflector\Reflector::class); - $reflector = $this->privatesAccessor->getPrivatePropertyOfClass($classReflector, 'reflector', \PHPStan\BetterReflection\Reflector\Reflector::class); + $classReflector = $this->privatesAccessor->getPrivatePropertyOfClass($nodeScopeResolver, 'reflector', Reflector::class); + $reflector = $this->privatesAccessor->getPrivatePropertyOfClass($classReflector, 'reflector', Reflector::class); /** @var SourceLocator $sourceLocator */ - $sourceLocator = $this->privatesAccessor->getPrivatePropertyOfClass($reflector, 'sourceLocator', \PHPStan\BetterReflection\SourceLocator\Type\SourceLocator::class); + $sourceLocator = $this->privatesAccessor->getPrivatePropertyOfClass($reflector, 'sourceLocator', SourceLocator::class); // 2. get Rector locator - $aggregateSourceLocator = new \PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator([$sourceLocator, $this->renamedClassesSourceLocator, $this->parentAttributeSourceLocator]); - $this->privatesAccessor->setPrivatePropertyOfClass($reflector, 'sourceLocator', $aggregateSourceLocator, \PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator::class); + $aggregateSourceLocator = new AggregateSourceLocator([$sourceLocator, $this->renamedClassesSourceLocator, $this->parentAttributeSourceLocator]); + $this->privatesAccessor->setPrivatePropertyOfClass($reflector, 'sourceLocator', $aggregateSourceLocator, AggregateSourceLocator::class); } } diff --git a/packages/NodeTypeResolver/PHPStan/Scope/ScopeFactory.php b/packages/NodeTypeResolver/PHPStan/Scope/ScopeFactory.php index fb0a3636398..b7d2ed10a68 100644 --- a/packages/NodeTypeResolver/PHPStan/Scope/ScopeFactory.php +++ b/packages/NodeTypeResolver/PHPStan/Scope/ScopeFactory.php @@ -6,7 +6,7 @@ namespace Rector\NodeTypeResolver\PHPStan\Scope; use PHPStan\Analyser\MutatingScope; use PHPStan\Analyser\ScopeContext; use PHPStan\Analyser\ScopeFactory as PHPStanScopeFactory; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class ScopeFactory { /** @@ -14,13 +14,13 @@ final class ScopeFactory * @var PHPStanScopeFactory */ private $phpStanScopeFactory; - public function __construct(\PHPStan\Analyser\ScopeFactory $phpStanScopeFactory) + public function __construct(PHPStanScopeFactory $phpStanScopeFactory) { $this->phpStanScopeFactory = $phpStanScopeFactory; } - public function createFromFile(\Symplify\SmartFileSystem\SmartFileInfo $fileInfo) : \PHPStan\Analyser\MutatingScope + public function createFromFile(SmartFileInfo $fileInfo) : MutatingScope { - $scopeContext = \PHPStan\Analyser\ScopeContext::create($fileInfo->getRealPath()); + $scopeContext = ScopeContext::create($fileInfo->getRealPath()); return $this->phpStanScopeFactory->create($scopeContext); } } diff --git a/packages/NodeTypeResolver/PHPStan/Type/StaticTypeAnalyzer.php b/packages/NodeTypeResolver/PHPStan/Type/StaticTypeAnalyzer.php index c05aa883cbb..d9d6e8119bc 100644 --- a/packages/NodeTypeResolver/PHPStan/Type/StaticTypeAnalyzer.php +++ b/packages/NodeTypeResolver/PHPStan/Type/StaticTypeAnalyzer.php @@ -23,29 +23,29 @@ final class StaticTypeAnalyzer * @var \Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer */ private $unionTypeAnalyzer; - public function __construct(\Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer $unionTypeAnalyzer) + public function __construct(UnionTypeAnalyzer $unionTypeAnalyzer) { $this->unionTypeAnalyzer = $unionTypeAnalyzer; } - public function isAlwaysTruableType(\PHPStan\Type\Type $type) : bool + public function isAlwaysTruableType(Type $type) : bool { - if ($type instanceof \PHPStan\Type\MixedType) { + if ($type instanceof MixedType) { return \false; } - if ($type instanceof \PHPStan\Type\Constant\ConstantArrayType) { + if ($type instanceof ConstantArrayType) { return \true; } - if ($type instanceof \PHPStan\Type\ArrayType) { + if ($type instanceof ArrayType) { return $this->isAlwaysTruableArrayType($type); } - if ($type instanceof \PHPStan\Type\UnionType && $this->unionTypeAnalyzer->isNullable($type)) { + if ($type instanceof UnionType && $this->unionTypeAnalyzer->isNullable($type)) { return \false; } // always trueish - if ($type instanceof \PHPStan\Type\ObjectType) { + if ($type instanceof ObjectType) { return \true; } - if ($type instanceof \PHPStan\Type\ConstantScalarType && !$type instanceof \PHPStan\Type\NullType) { + if ($type instanceof ConstantScalarType && !$type instanceof NullType) { return (bool) $type->getValue(); } if ($this->isScalarType($type)) { @@ -53,16 +53,16 @@ final class StaticTypeAnalyzer } return $this->isAlwaysTruableUnionType($type); } - private function isScalarType(\PHPStan\Type\Type $type) : bool + private function isScalarType(Type $type) : bool { - if ($type instanceof \PHPStan\Type\NullType) { + if ($type instanceof NullType) { return \true; } - return $type instanceof \PHPStan\Type\BooleanType || $type instanceof \PHPStan\Type\StringType || $type instanceof \PHPStan\Type\IntegerType || $type instanceof \PHPStan\Type\FloatType; + return $type instanceof BooleanType || $type instanceof StringType || $type instanceof IntegerType || $type instanceof FloatType; } - private function isAlwaysTruableUnionType(\PHPStan\Type\Type $type) : bool + private function isAlwaysTruableUnionType(Type $type) : bool { - if (!$type instanceof \PHPStan\Type\UnionType) { + if (!$type instanceof UnionType) { return \false; } foreach ($type->getTypes() as $unionedType) { @@ -72,10 +72,10 @@ final class StaticTypeAnalyzer } return \true; } - private function isAlwaysTruableArrayType(\PHPStan\Type\ArrayType $arrayType) : bool + private function isAlwaysTruableArrayType(ArrayType $arrayType) : bool { $itemType = $arrayType->getItemType(); - if (!$itemType instanceof \PHPStan\Type\ConstantScalarType) { + if (!$itemType instanceof ConstantScalarType) { return \false; } return (bool) $itemType->getValue(); diff --git a/packages/NodeTypeResolver/PHPStan/Type/TypeFactory.php b/packages/NodeTypeResolver/PHPStan/Type/TypeFactory.php index c2c707ed32b..2c593fcb52c 100644 --- a/packages/NodeTypeResolver/PHPStan/Type/TypeFactory.php +++ b/packages/NodeTypeResolver/PHPStan/Type/TypeFactory.php @@ -25,14 +25,14 @@ final class TypeFactory * @var \Rector\NodeTypeResolver\PHPStan\TypeHasher */ private $typeHasher; - public function __construct(\Rector\NodeTypeResolver\PHPStan\TypeHasher $typeHasher) + public function __construct(TypeHasher $typeHasher) { $this->typeHasher = $typeHasher; } /** * @param Type[] $types */ - public function createMixedPassedOrUnionTypeAndKeepConstant(array $types) : \PHPStan\Type\Type + public function createMixedPassedOrUnionTypeAndKeepConstant(array $types) : Type { $types = $this->unwrapUnionedTypes($types); $types = $this->uniquateTypes($types, \true); @@ -41,7 +41,7 @@ final class TypeFactory /** * @param Type[] $types */ - public function createMixedPassedOrUnionType(array $types, bool $keepConstantTypes = \false) : \PHPStan\Type\Type + public function createMixedPassedOrUnionType(array $types, bool $keepConstantTypes = \false) : Type { $types = $this->unwrapUnionedTypes($types); $types = $this->uniquateTypes($types, $keepConstantTypes); @@ -74,9 +74,9 @@ final class TypeFactory // unwrap union types $unwrappedTypes = []; foreach ($types as $type) { - $flattenTypes = \PHPStan\Type\TypeUtils::flattenTypes($type); + $flattenTypes = TypeUtils::flattenTypes($type); foreach ($flattenTypes as $flattenType) { - if ($flattenType instanceof \PHPStan\Type\Constant\ConstantArrayType) { + if ($flattenType instanceof ConstantArrayType) { $unwrappedTypes = \array_merge($unwrappedTypes, $this->unwrapConstantArrayTypes($flattenType)); } else { $unwrappedTypes = $this->resolveNonConstantArrayType($flattenType, $unwrappedTypes); @@ -89,7 +89,7 @@ final class TypeFactory * @param Type[] $unwrappedTypes * @return Type[] */ - private function resolveNonConstantArrayType(\PHPStan\Type\Type $type, array $unwrappedTypes) : array + private function resolveNonConstantArrayType(Type $type, array $unwrappedTypes) : array { $unwrappedTypes[] = $type; return $unwrappedTypes; @@ -97,47 +97,47 @@ final class TypeFactory /** * @param Type[] $types */ - private function createUnionOrSingleType(array $types) : \PHPStan\Type\Type + private function createUnionOrSingleType(array $types) : Type { if ($types === []) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } if (\count($types) === 1) { return $types[0]; } - return new \PHPStan\Type\UnionType($types); + return new UnionType($types); } - private function removeValueFromConstantType(\PHPStan\Type\Type $type) : \PHPStan\Type\Type + private function removeValueFromConstantType(Type $type) : Type { // remove values from constant types - if ($type instanceof \PHPStan\Type\Constant\ConstantFloatType) { - return new \PHPStan\Type\FloatType(); + if ($type instanceof ConstantFloatType) { + return new FloatType(); } - if ($type instanceof \PHPStan\Type\Constant\ConstantStringType) { - return new \PHPStan\Type\StringType(); + if ($type instanceof ConstantStringType) { + return new StringType(); } - if ($type instanceof \PHPStan\Type\Constant\ConstantIntegerType) { - return new \PHPStan\Type\IntegerType(); + if ($type instanceof ConstantIntegerType) { + return new IntegerType(); } - if ($type instanceof \PHPStan\Type\Constant\ConstantBooleanType) { - return new \PHPStan\Type\BooleanType(); + if ($type instanceof ConstantBooleanType) { + return new BooleanType(); } return $type; } /** * @return Type[] */ - private function unwrapConstantArrayTypes(\PHPStan\Type\Constant\ConstantArrayType $constantArrayType) : array + private function unwrapConstantArrayTypes(ConstantArrayType $constantArrayType) : array { $unwrappedTypes = []; - $flattenKeyTypes = \PHPStan\Type\TypeUtils::flattenTypes($constantArrayType->getKeyType()); - $flattenItemTypes = \PHPStan\Type\TypeUtils::flattenTypes($constantArrayType->getItemType()); + $flattenKeyTypes = TypeUtils::flattenTypes($constantArrayType->getKeyType()); + $flattenItemTypes = TypeUtils::flattenTypes($constantArrayType->getItemType()); foreach ($flattenItemTypes as $position => $nestedFlattenItemType) { $nestedFlattenKeyType = $flattenKeyTypes[$position] ?? null; - if (!$nestedFlattenKeyType instanceof \PHPStan\Type\Type) { - $nestedFlattenKeyType = new \PHPStan\Type\MixedType(); + if (!$nestedFlattenKeyType instanceof Type) { + $nestedFlattenKeyType = new MixedType(); } - $unwrappedTypes[] = new \PHPStan\Type\ArrayType($nestedFlattenKeyType, $nestedFlattenItemType); + $unwrappedTypes[] = new ArrayType($nestedFlattenKeyType, $nestedFlattenItemType); } return $unwrappedTypes; } diff --git a/packages/NodeTypeResolver/PHPStan/TypeHasher.php b/packages/NodeTypeResolver/PHPStan/TypeHasher.php index aa07c36acc8..500816ef93a 100644 --- a/packages/NodeTypeResolver/PHPStan/TypeHasher.php +++ b/packages/NodeTypeResolver/PHPStan/TypeHasher.php @@ -20,80 +20,80 @@ use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType; final class TypeHasher { - public function areTypesEqual(\PHPStan\Type\Type $firstType, \PHPStan\Type\Type $secondType) : bool + public function areTypesEqual(Type $firstType, Type $secondType) : bool { return $this->createTypeHash($firstType) === $this->createTypeHash($secondType); } - public function createTypeHash(\PHPStan\Type\Type $type) : string + public function createTypeHash(Type $type) : string { - if ($type instanceof \PHPStan\Type\MixedType) { - return $type->describe(\PHPStan\Type\VerbosityLevel::precise()) . $type->isExplicitMixed(); + if ($type instanceof MixedType) { + return $type->describe(VerbosityLevel::precise()) . $type->isExplicitMixed(); } - if ($type instanceof \PHPStan\Type\ArrayType) { + if ($type instanceof ArrayType) { return $this->createTypeHash($type->getItemType()) . $this->createTypeHash($type->getKeyType()) . '[]'; } - if ($type instanceof \PHPStan\Type\Generic\GenericObjectType) { - return $type->describe(\PHPStan\Type\VerbosityLevel::precise()); + if ($type instanceof GenericObjectType) { + return $type->describe(VerbosityLevel::precise()); } - if ($type instanceof \PHPStan\Type\TypeWithClassName) { + if ($type instanceof TypeWithClassName) { return $this->resolveUniqueTypeWithClassNameHash($type); } - if ($type instanceof \PHPStan\Type\ConstantType) { + if ($type instanceof ConstantType) { return \get_class($type) . $type->getValue(); } - if ($type instanceof \PHPStan\Type\UnionType) { + if ($type instanceof UnionType) { return $this->createUnionTypeHash($type); } $type = $this->normalizeObjectType($type); // normalize iterable - $type = \PHPStan\Type\TypeTraverser::map($type, function (\PHPStan\Type\Type $currentType, callable $traverseCallback) : Type { - if (!$currentType instanceof \PHPStan\Type\ObjectType) { + $type = TypeTraverser::map($type, function (Type $currentType, callable $traverseCallback) : Type { + if (!$currentType instanceof ObjectType) { return $traverseCallback($currentType); } if ($currentType->getClassName() === 'iterable') { - return new \PHPStan\Type\IterableType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); + return new IterableType(new MixedType(), new MixedType()); } return $traverseCallback($currentType); }); - return $type->describe(\PHPStan\Type\VerbosityLevel::value()); + return $type->describe(VerbosityLevel::value()); } - private function resolveUniqueTypeWithClassNameHash(\PHPStan\Type\TypeWithClassName $typeWithClassName) : string + private function resolveUniqueTypeWithClassNameHash(TypeWithClassName $typeWithClassName) : string { - if ($typeWithClassName instanceof \Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType) { + if ($typeWithClassName instanceof ShortenedObjectType) { return $typeWithClassName->getFullyQualifiedName(); } - if ($typeWithClassName instanceof \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType) { + if ($typeWithClassName instanceof AliasedObjectType) { return $typeWithClassName->getFullyQualifiedName(); } return $typeWithClassName->getClassName(); } - private function createUnionTypeHash(\PHPStan\Type\UnionType $unionType) : string + private function createUnionTypeHash(UnionType $unionType) : string { - $booleanType = new \PHPStan\Type\BooleanType(); + $booleanType = new BooleanType(); if ($booleanType->isSuperTypeOf($unionType)->yes()) { - return $booleanType->describe(\PHPStan\Type\VerbosityLevel::precise()); + return $booleanType->describe(VerbosityLevel::precise()); } $normalizedUnionType = clone $unionType; // change alias to non-alias - $normalizedUnionType = \PHPStan\Type\TypeTraverser::map($normalizedUnionType, function (\PHPStan\Type\Type $type, callable $callable) : Type { - if (!$type instanceof \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType && !$type instanceof \Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType) { + $normalizedUnionType = TypeTraverser::map($normalizedUnionType, function (Type $type, callable $callable) : Type { + if (!$type instanceof AliasedObjectType && !$type instanceof ShortenedObjectType) { return $callable($type); } - return new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($type->getFullyQualifiedName()); + return new FullyQualifiedObjectType($type->getFullyQualifiedName()); }); - return $normalizedUnionType->describe(\PHPStan\Type\VerbosityLevel::precise()); + return $normalizedUnionType->describe(VerbosityLevel::precise()); } - private function normalizeObjectType(\PHPStan\Type\Type $type) : \PHPStan\Type\Type + private function normalizeObjectType(Type $type) : Type { - return \PHPStan\Type\TypeTraverser::map($type, function (\PHPStan\Type\Type $currentType, callable $traverseCallback) : Type { - if ($currentType instanceof \Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType) { - return new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($currentType->getFullyQualifiedName()); + return TypeTraverser::map($type, function (Type $currentType, callable $traverseCallback) : Type { + if ($currentType instanceof ShortenedObjectType) { + return new FullyQualifiedObjectType($currentType->getFullyQualifiedName()); } - if ($currentType instanceof \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType) { - return new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($currentType->getFullyQualifiedName()); + if ($currentType instanceof AliasedObjectType) { + return new FullyQualifiedObjectType($currentType->getFullyQualifiedName()); } - if ($currentType instanceof \PHPStan\Type\ObjectType && !$currentType instanceof \PHPStan\Type\Generic\GenericObjectType && !$currentType instanceof \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType && $currentType->getClassName() !== 'Iterator' && $currentType->getClassName() !== 'iterable') { - return new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($currentType->getClassName()); + if ($currentType instanceof ObjectType && !$currentType instanceof GenericObjectType && !$currentType instanceof AliasedObjectType && $currentType->getClassName() !== 'Iterator' && $currentType->getClassName() !== 'iterable') { + return new FullyQualifiedObjectType($currentType->getClassName()); } return $traverseCallback($currentType); }); diff --git a/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockClassRenamer.php b/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockClassRenamer.php index 2345108435a..fba8d5051ee 100644 --- a/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockClassRenamer.php +++ b/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockClassRenamer.php @@ -14,19 +14,19 @@ final class DocBlockClassRenamer * @var \Rector\NodeTypeResolver\PhpDocNodeVisitor\ClassRenamePhpDocNodeVisitor */ private $classRenamePhpDocNodeVisitor; - public function __construct(\Rector\NodeTypeResolver\PhpDocNodeVisitor\ClassRenamePhpDocNodeVisitor $classRenamePhpDocNodeVisitor) + public function __construct(ClassRenamePhpDocNodeVisitor $classRenamePhpDocNodeVisitor) { $this->classRenamePhpDocNodeVisitor = $classRenamePhpDocNodeVisitor; } /** * @param OldToNewType[] $oldToNewTypes */ - public function renamePhpDocType(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, array $oldToNewTypes) : void + public function renamePhpDocType(PhpDocInfo $phpDocInfo, array $oldToNewTypes) : void { if ($oldToNewTypes === []) { return; } - $phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser(); + $phpDocNodeTraverser = new PhpDocNodeTraverser(); $phpDocNodeTraverser->addPhpDocNodeVisitor($this->classRenamePhpDocNodeVisitor); $this->classRenamePhpDocNodeVisitor->setOldToNewTypes($oldToNewTypes); $phpDocNodeTraverser->traverse($phpDocInfo->getPhpDocNode()); diff --git a/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockNameImporter.php b/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockNameImporter.php index e656e5d5aaf..5f911e7b784 100644 --- a/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockNameImporter.php +++ b/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockNameImporter.php @@ -14,17 +14,17 @@ final class DocBlockNameImporter * @var \Rector\NodeTypeResolver\PhpDocNodeVisitor\NameImportingPhpDocNodeVisitor */ private $nameImportingPhpDocNodeVisitor; - public function __construct(\Rector\NodeTypeResolver\PhpDocNodeVisitor\NameImportingPhpDocNodeVisitor $nameImportingPhpDocNodeVisitor) + public function __construct(NameImportingPhpDocNodeVisitor $nameImportingPhpDocNodeVisitor) { $this->nameImportingPhpDocNodeVisitor = $nameImportingPhpDocNodeVisitor; } - public function importNames(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \PhpParser\Node $node) : void + public function importNames(PhpDocNode $phpDocNode, Node $node) : void { if ($phpDocNode->children === []) { return; } $this->nameImportingPhpDocNodeVisitor->setCurrentNode($node); - $phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser(); + $phpDocNodeTraverser = new PhpDocNodeTraverser(); $phpDocNodeTraverser->addPhpDocNodeVisitor($this->nameImportingPhpDocNodeVisitor); $phpDocNodeTraverser->traverse($phpDocNode); } diff --git a/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockNamespaceRenamer.php b/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockNamespaceRenamer.php index 19457bda2b1..ccf24b15300 100644 --- a/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockNamespaceRenamer.php +++ b/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockNamespaceRenamer.php @@ -28,7 +28,7 @@ final class DocBlockNamespaceRenamer * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory */ private $phpDocInfoFactory; - public function __construct(\Rector\Naming\NamespaceMatcher $namespaceMatcher, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory) + public function __construct(NamespaceMatcher $namespaceMatcher, PhpDocInfoFactory $phpDocInfoFactory) { $this->namespaceMatcher = $namespaceMatcher; $this->phpDocInfoFactory = $phpDocInfoFactory; @@ -37,12 +37,12 @@ final class DocBlockNamespaceRenamer * @param array $oldToNewNamespaces * @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Stmt\Expression|\PhpParser\Node\Stmt\ClassLike|\Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace $node */ - public function renameFullyQualifiedNamespace($node, array $oldToNewNamespaces) : ?\PhpParser\Node + public function renameFullyQualifiedNamespace($node, array $oldToNewNamespaces) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); - $phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser(); - $phpDocNodeTraverser->traverseWithCallable($phpDocInfo->getPhpDocNode(), '', function (\PHPStan\PhpDocParser\Ast\Node $docNode) use($oldToNewNamespaces) : ?DocNode { - if (!$docNode instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode) { + $phpDocNodeTraverser = new PhpDocNodeTraverser(); + $phpDocNodeTraverser->traverseWithCallable($phpDocInfo->getPhpDocNode(), '', function (DocNode $docNode) use($oldToNewNamespaces) : ?DocNode { + if (!$docNode instanceof IdentifierTypeNode) { return null; } $trimmedName = \ltrim($docNode->name, '\\'); @@ -50,10 +50,10 @@ final class DocBlockNamespaceRenamer return null; } $renamedNamespaceValueObject = $this->namespaceMatcher->matchRenamedNamespace($trimmedName, $oldToNewNamespaces); - if (!$renamedNamespaceValueObject instanceof \Rector\Renaming\ValueObject\RenamedNamespace) { + if (!$renamedNamespaceValueObject instanceof RenamedNamespace) { return null; } - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('\\' . $renamedNamespaceValueObject->getNameInNewNamespace()); + return new IdentifierTypeNode('\\' . $renamedNamespaceValueObject->getNameInNewNamespace()); }); if (!$phpDocInfo->hasChanged()) { return null; diff --git a/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockTagReplacer.php b/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockTagReplacer.php index d6d87bce5a8..9a27127b15c 100644 --- a/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockTagReplacer.php +++ b/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockTagReplacer.php @@ -14,25 +14,25 @@ final class DocBlockTagReplacer * @var \Rector\BetterPhpDocParser\Annotation\AnnotationNaming */ private $annotationNaming; - public function __construct(\Rector\BetterPhpDocParser\Annotation\AnnotationNaming $annotationNaming) + public function __construct(AnnotationNaming $annotationNaming) { $this->annotationNaming = $annotationNaming; } - public function replaceTagByAnother(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, string $oldTag, string $newTag) : bool + public function replaceTagByAnother(PhpDocInfo $phpDocInfo, string $oldTag, string $newTag) : bool { $hasChanged = \false; $oldTag = $this->annotationNaming->normalizeName($oldTag); $newTag = $this->annotationNaming->normalizeName($newTag); $phpDocNode = $phpDocInfo->getPhpDocNode(); foreach ($phpDocNode->children as $key => $phpDocChildNode) { - if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) { + if (!$phpDocChildNode instanceof PhpDocTagNode) { continue; } if ($phpDocChildNode->name !== $oldTag) { continue; } unset($phpDocNode->children[$key]); - $phpDocNode->children[] = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode($newTag, new \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode('')); + $phpDocNode->children[] = new PhpDocTagNode($newTag, new GenericTagValueNode('')); $hasChanged = \true; } return $hasChanged; diff --git a/packages/NodeTypeResolver/PhpDoc/PhpDocTypeRenamer.php b/packages/NodeTypeResolver/PhpDoc/PhpDocTypeRenamer.php index 5a6075fc6d3..f2892a83a9f 100644 --- a/packages/NodeTypeResolver/PhpDoc/PhpDocTypeRenamer.php +++ b/packages/NodeTypeResolver/PhpDoc/PhpDocTypeRenamer.php @@ -16,15 +16,15 @@ final class PhpDocTypeRenamer * @var \Rector\StaticTypeMapper\StaticTypeMapper */ private $staticTypeMapper; - public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper) + public function __construct(StaticTypeMapper $staticTypeMapper) { $this->staticTypeMapper = $staticTypeMapper; } - public function changeUnderscoreType(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node $node, \Rector\Renaming\ValueObject\PseudoNamespaceToNamespace $pseudoNamespaceToNamespace) : bool + public function changeUnderscoreType(PhpDocInfo $phpDocInfo, Node $node, PseudoNamespaceToNamespace $pseudoNamespaceToNamespace) : bool { $phpDocNode = $phpDocInfo->getPhpDocNode(); - $underscoreRenamePhpDocNodeVisitor = new \Rector\NodeTypeResolver\PhpDocNodeVisitor\UnderscoreRenamePhpDocNodeVisitor($this->staticTypeMapper, $pseudoNamespaceToNamespace, $node); - $phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser(); + $underscoreRenamePhpDocNodeVisitor = new UnderscoreRenamePhpDocNodeVisitor($this->staticTypeMapper, $pseudoNamespaceToNamespace, $node); + $phpDocNodeTraverser = new PhpDocNodeTraverser(); $phpDocNodeTraverser->addPhpDocNodeVisitor($underscoreRenamePhpDocNodeVisitor); $phpDocNodeTraverser->traverse($phpDocNode); // has changed? diff --git a/packages/NodeTypeResolver/PhpDocNodeVisitor/ClassRenamePhpDocNodeVisitor.php b/packages/NodeTypeResolver/PhpDocNodeVisitor/ClassRenamePhpDocNodeVisitor.php index 66d55dcbe1f..330cf7fefcf 100644 --- a/packages/NodeTypeResolver/PhpDocNodeVisitor/ClassRenamePhpDocNodeVisitor.php +++ b/packages/NodeTypeResolver/PhpDocNodeVisitor/ClassRenamePhpDocNodeVisitor.php @@ -24,7 +24,7 @@ use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\StaticTypeMapper\StaticTypeMapper; use Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType; use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor; -final class ClassRenamePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor +final class ClassRenamePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor { /** * @var OldToNewType[] @@ -55,7 +55,7 @@ final class ClassRenamePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\ * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\Core\Configuration\CurrentNodeProvider $currentNodeProvider, \Rector\Naming\Naming\UseImportsResolver $useImportsResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(StaticTypeMapper $staticTypeMapper, CurrentNodeProvider $currentNodeProvider, UseImportsResolver $useImportsResolver, BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver) { $this->staticTypeMapper = $staticTypeMapper; $this->currentNodeProvider = $currentNodeProvider; @@ -63,22 +63,22 @@ final class ClassRenamePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\ $this->betterNodeFinder = $betterNodeFinder; $this->nodeNameResolver = $nodeNameResolver; } - public function beforeTraverse(\PHPStan\PhpDocParser\Ast\Node $node) : void + public function beforeTraverse(Node $node) : void { if ($this->oldToNewTypes === []) { - throw new \Rector\Core\Exception\ShouldNotHappenException('Configure "$oldToNewClasses" first'); + throw new ShouldNotHappenException('Configure "$oldToNewClasses" first'); } } - public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node + public function enterNode(Node $node) : ?Node { - if (!$node instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode) { + if (!$node instanceof IdentifierTypeNode) { return null; } $phpParserNode = $this->currentNodeProvider->getNode(); - if (!$phpParserNode instanceof \PhpParser\Node) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$phpParserNode instanceof PhpParserNode) { + throw new ShouldNotHappenException(); } - $virtualNode = $phpParserNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::VIRTUAL_NODE); + $virtualNode = $phpParserNode->getAttribute(AttributeKey::VIRTUAL_NODE); if ($virtualNode === \true) { return null; } @@ -87,18 +87,18 @@ final class ClassRenamePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\ $identifier->name = $namespacedName; $staticType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($identifier, $phpParserNode); // make sure to compare FQNs - if ($staticType instanceof \Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType) { - $staticType = new \PHPStan\Type\ObjectType($staticType->getFullyQualifiedName()); + if ($staticType instanceof ShortenedObjectType) { + $staticType = new ObjectType($staticType->getFullyQualifiedName()); } foreach ($this->oldToNewTypes as $oldToNewType) { if (!$staticType->equals($oldToNewType->getOldType())) { continue; } - $newTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($oldToNewType->getNewType(), \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::ANY); - $parentType = $node->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::PARENT); - if ($parentType instanceof \PHPStan\PhpDocParser\Ast\Type\TypeNode) { + $newTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($oldToNewType->getNewType(), TypeKind::ANY); + $parentType = $node->getAttribute(PhpDocAttributeKey::PARENT); + if ($parentType instanceof TypeNode) { // mirror attributes - $newTypeNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::PARENT, $parentType); + $newTypeNode->setAttribute(PhpDocAttributeKey::PARENT, $parentType); } return $newTypeNode; } @@ -111,7 +111,7 @@ final class ClassRenamePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\ { $this->oldToNewTypes = $oldToNewTypes; } - private function resolveNamespacedName(\PhpParser\Node $phpParserNode, string $name) : string + private function resolveNamespacedName(PhpParserNode $phpParserNode, string $name) : string { if (\strncmp($name, '\\', \strlen('\\')) === 0) { return $name; @@ -119,14 +119,14 @@ final class ClassRenamePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\ if (\strpos($name, '\\') !== \false) { return $name; } - $namespace = $this->betterNodeFinder->findParentType($phpParserNode, \PhpParser\Node\Stmt\Namespace_::class); + $namespace = $this->betterNodeFinder->findParentType($phpParserNode, Namespace_::class); $uses = $this->useImportsResolver->resolveForNode($phpParserNode); - if (!$namespace instanceof \PhpParser\Node\Stmt\Namespace_) { + if (!$namespace instanceof Namespace_) { return $this->resolveNamefromUse($uses, $name); } - $originalNode = $namespace->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE); + $originalNode = $namespace->getAttribute(AttributeKey::ORIGINAL_NODE); $namespaceName = (string) $this->nodeNameResolver->getName($namespace); - if ($originalNode instanceof \PhpParser\Node\Stmt\Namespace_ && !$this->nodeNameResolver->isName($originalNode, $namespaceName)) { + if ($originalNode instanceof Namespace_ && !$this->nodeNameResolver->isName($originalNode, $namespaceName)) { return $name; } if ($uses === []) { @@ -140,9 +140,9 @@ final class ClassRenamePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\ private function resolveNamefromUse(array $uses, string $name) : string { foreach ($uses as $use) { - $prefix = $use instanceof \PhpParser\Node\Stmt\GroupUse ? $use->prefix . '\\' : ''; + $prefix = $use instanceof GroupUse ? $use->prefix . '\\' : ''; foreach ($use->uses as $useUse) { - if ($useUse->alias instanceof \PhpParser\Node\Identifier) { + if ($useUse->alias instanceof Identifier) { continue; } $lastName = $useUse->name->getLast(); diff --git a/packages/NodeTypeResolver/PhpDocNodeVisitor/NameImportingPhpDocNodeVisitor.php b/packages/NodeTypeResolver/PhpDocNodeVisitor/NameImportingPhpDocNodeVisitor.php index 2a33c1f02e2..fa16995a512 100644 --- a/packages/NodeTypeResolver/PhpDocNodeVisitor/NameImportingPhpDocNodeVisitor.php +++ b/packages/NodeTypeResolver/PhpDocNodeVisitor/NameImportingPhpDocNodeVisitor.php @@ -23,7 +23,7 @@ use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor; use RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider; use RectorPrefix20220607\Symplify\PackageBuilder\Reflection\ClassLikeExistenceChecker; -final class NameImportingPhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor +final class NameImportingPhpDocNodeVisitor extends AbstractPhpDocNodeVisitor { /** * @var PhpParserNode|null @@ -59,7 +59,7 @@ final class NameImportingPhpDocNodeVisitor extends \RectorPrefix20220607\Symplif * @var \Symplify\PackageBuilder\Reflection\ClassLikeExistenceChecker */ private $classLikeExistenceChecker; - public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \Rector\CodingStyle\ClassNameImport\ClassNameImportSkipper $classNameImportSkipper, \Rector\PostRector\Collector\UseNodesToAddCollector $useNodesToAddCollector, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \RectorPrefix20220607\Symplify\PackageBuilder\Reflection\ClassLikeExistenceChecker $classLikeExistenceChecker) + public function __construct(StaticTypeMapper $staticTypeMapper, ParameterProvider $parameterProvider, ClassNameImportSkipper $classNameImportSkipper, UseNodesToAddCollector $useNodesToAddCollector, CurrentFileProvider $currentFileProvider, ClassLikeExistenceChecker $classLikeExistenceChecker) { $this->staticTypeMapper = $staticTypeMapper; $this->parameterProvider = $parameterProvider; @@ -68,26 +68,26 @@ final class NameImportingPhpDocNodeVisitor extends \RectorPrefix20220607\Symplif $this->currentFileProvider = $currentFileProvider; $this->classLikeExistenceChecker = $classLikeExistenceChecker; } - public function beforeTraverse(\PHPStan\PhpDocParser\Ast\Node $node) : void + public function beforeTraverse(Node $node) : void { if ($this->currentPhpParserNode === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException('Set "$currentPhpParserNode" first'); + throw new ShouldNotHappenException('Set "$currentPhpParserNode" first'); } } - public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node + public function enterNode(Node $node) : ?Node { - if ($node instanceof \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode) { + if ($node instanceof SpacelessPhpDocTagNode) { return $this->enterSpacelessPhpDocTagNode($node); } - if ($node instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if ($node instanceof DoctrineAnnotationTagValueNode) { $this->processDoctrineAnnotationTagValueNode($node); return $node; } - if (!$node instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode) { + if (!$node instanceof IdentifierTypeNode) { return null; } $staticType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($node, $this->currentPhpParserNode); - if (!$staticType instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) { + if (!$staticType instanceof FullyQualifiedObjectType) { return null; } // Importing root namespace classes (like \DateTime) is optional @@ -95,32 +95,32 @@ final class NameImportingPhpDocNodeVisitor extends \RectorPrefix20220607\Symplif return null; } $file = $this->currentFileProvider->getFile(); - if (!$file instanceof \Rector\Core\ValueObject\Application\File) { + if (!$file instanceof File) { return null; } if ($this->currentPhpParserNode === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } return $this->processFqnNameImport($this->currentPhpParserNode, $node, $staticType, $file); } - public function setCurrentNode(\PhpParser\Node $phpParserNode) : void + public function setCurrentNode(PhpParserNode $phpParserNode) : void { $this->currentPhpParserNode = $phpParserNode; } - private function processFqnNameImport(\PhpParser\Node $phpParserNode, \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode $identifierTypeNode, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType, \Rector\Core\ValueObject\Application\File $file) : ?\PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode + private function processFqnNameImport(PhpParserNode $phpParserNode, IdentifierTypeNode $identifierTypeNode, FullyQualifiedObjectType $fullyQualifiedObjectType, File $file) : ?IdentifierTypeNode { if (\strncmp($fullyQualifiedObjectType->getClassName(), '@', \strlen('@')) === 0) { - $fullyQualifiedObjectType = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType(\ltrim($fullyQualifiedObjectType->getClassName(), '@')); + $fullyQualifiedObjectType = new FullyQualifiedObjectType(\ltrim($fullyQualifiedObjectType->getClassName(), '@')); } if ($this->classNameImportSkipper->shouldSkipNameForFullyQualifiedObjectType($file, $phpParserNode, $fullyQualifiedObjectType)) { return null; } - $parent = $identifierTypeNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::PARENT); - if ($parent instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode) { + $parent = $identifierTypeNode->getAttribute(PhpDocAttributeKey::PARENT); + if ($parent instanceof TemplateTagValueNode) { // might break return null; } - $newNode = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($fullyQualifiedObjectType->getShortName()); + $newNode = new IdentifierTypeNode($fullyQualifiedObjectType->getShortName()); // should skip because its already used if ($this->useNodesToAddCollector->isShortImported($file, $fullyQualifiedObjectType)) { if (!$this->useNodesToAddCollector->isImportShortable($file, $fullyQualifiedObjectType)) { @@ -138,7 +138,7 @@ final class NameImportingPhpDocNodeVisitor extends \RectorPrefix20220607\Symplif } return null; } - private function shouldImport(\PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode $newNode, \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode $identifierTypeNode, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : bool + private function shouldImport(IdentifierTypeNode $newNode, IdentifierTypeNode $identifierTypeNode, FullyQualifiedObjectType $fullyQualifiedObjectType) : bool { if ($newNode->name === $identifierTypeNode->name) { return \false; @@ -150,7 +150,7 @@ final class NameImportingPhpDocNodeVisitor extends \RectorPrefix20220607\Symplif if (!$this->classLikeExistenceChecker->doesClassLikeInsensitiveExists($className)) { return \false; } - $firstPath = \RectorPrefix20220607\Nette\Utils\Strings::before($identifierTypeNode->name, '\\' . $newNode->name); + $firstPath = Strings::before($identifierTypeNode->name, '\\' . $newNode->name); if ($firstPath === null) { return \true; } @@ -160,34 +160,34 @@ final class NameImportingPhpDocNodeVisitor extends \RectorPrefix20220607\Symplif $namespaceParts = \explode('\\', \ltrim($firstPath, '\\')); return \count($namespaceParts) > 1; } - private function shouldSkipShortClassName(\Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : bool + private function shouldSkipShortClassName(FullyQualifiedObjectType $fullyQualifiedObjectType) : bool { - $importShortClasses = $this->parameterProvider->provideBoolParameter(\Rector\Core\Configuration\Option::IMPORT_SHORT_CLASSES); + $importShortClasses = $this->parameterProvider->provideBoolParameter(Option::IMPORT_SHORT_CLASSES); if ($importShortClasses) { return \false; } return \substr_count($fullyQualifiedObjectType->getClassName(), '\\') === 0; } - private function processDoctrineAnnotationTagValueNode(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : void + private function processDoctrineAnnotationTagValueNode(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : void { $currentPhpParserNode = $this->currentPhpParserNode; - if (!$currentPhpParserNode instanceof \PhpParser\Node) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$currentPhpParserNode instanceof PhpParserNode) { + throw new ShouldNotHappenException(); } $identifierTypeNode = $doctrineAnnotationTagValueNode->identifierTypeNode; $staticType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($identifierTypeNode, $currentPhpParserNode); - if (!$staticType instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) { - if (!$staticType instanceof \PHPStan\Type\ObjectType) { + if (!$staticType instanceof FullyQualifiedObjectType) { + if (!$staticType instanceof ObjectType) { return; } - $staticType = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($staticType->getClassName()); + $staticType = new FullyQualifiedObjectType($staticType->getClassName()); } $file = $this->currentFileProvider->getFile(); - if (!$file instanceof \Rector\Core\ValueObject\Application\File) { + if (!$file instanceof File) { return; } $shortentedIdentifierTypeNode = $this->processFqnNameImport($currentPhpParserNode, $identifierTypeNode, $staticType, $file); - if (!$shortentedIdentifierTypeNode instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode) { + if (!$shortentedIdentifierTypeNode instanceof IdentifierTypeNode) { return; } $doctrineAnnotationTagValueNode->identifierTypeNode = $shortentedIdentifierTypeNode; @@ -196,9 +196,9 @@ final class NameImportingPhpDocNodeVisitor extends \RectorPrefix20220607\Symplif /** * @return \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode|null */ - private function enterSpacelessPhpDocTagNode(\Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode $spacelessPhpDocTagNode) + private function enterSpacelessPhpDocTagNode(SpacelessPhpDocTagNode $spacelessPhpDocTagNode) { - if (!$spacelessPhpDocTagNode->value instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$spacelessPhpDocTagNode->value instanceof DoctrineAnnotationTagValueNode) { return null; } // special case for doctrine annotation @@ -206,20 +206,20 @@ final class NameImportingPhpDocNodeVisitor extends \RectorPrefix20220607\Symplif return null; } $attributeClass = \ltrim($spacelessPhpDocTagNode->name, '@\\'); - $identifierTypeNode = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($attributeClass); + $identifierTypeNode = new IdentifierTypeNode($attributeClass); $currentPhpParserNode = $this->currentPhpParserNode; - if (!$currentPhpParserNode instanceof \PhpParser\Node) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$currentPhpParserNode instanceof PhpParserNode) { + throw new ShouldNotHappenException(); } - $staticType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType(new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($attributeClass), $currentPhpParserNode); - if (!$staticType instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) { - if (!$staticType instanceof \PHPStan\Type\ObjectType) { + $staticType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType(new IdentifierTypeNode($attributeClass), $currentPhpParserNode); + if (!$staticType instanceof FullyQualifiedObjectType) { + if (!$staticType instanceof ObjectType) { return null; } - $staticType = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($staticType->getClassName()); + $staticType = new FullyQualifiedObjectType($staticType->getClassName()); } $file = $this->currentFileProvider->getFile(); - if (!$file instanceof \Rector\Core\ValueObject\Application\File) { + if (!$file instanceof File) { return null; } $importedName = $this->processFqnNameImport($currentPhpParserNode, $identifierTypeNode, $staticType, $file); diff --git a/packages/NodeTypeResolver/PhpDocNodeVisitor/UnderscoreRenamePhpDocNodeVisitor.php b/packages/NodeTypeResolver/PhpDocNodeVisitor/UnderscoreRenamePhpDocNodeVisitor.php index a23f1b91707..e59ffd2160c 100644 --- a/packages/NodeTypeResolver/PhpDocNodeVisitor/UnderscoreRenamePhpDocNodeVisitor.php +++ b/packages/NodeTypeResolver/PhpDocNodeVisitor/UnderscoreRenamePhpDocNodeVisitor.php @@ -10,7 +10,7 @@ use PHPStan\Type\ObjectType; use Rector\Renaming\ValueObject\PseudoNamespaceToNamespace; use Rector\StaticTypeMapper\StaticTypeMapper; use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor; -final class UnderscoreRenamePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor +final class UnderscoreRenamePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor { /** * @var bool @@ -31,19 +31,19 @@ final class UnderscoreRenamePhpDocNodeVisitor extends \RectorPrefix20220607\Symp * @var \PhpParser\Node */ private $phpNode; - public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\Renaming\ValueObject\PseudoNamespaceToNamespace $pseudoNamespaceToNamespace, \PhpParser\Node $phpNode) + public function __construct(StaticTypeMapper $staticTypeMapper, PseudoNamespaceToNamespace $pseudoNamespaceToNamespace, \PhpParser\Node $phpNode) { $this->staticTypeMapper = $staticTypeMapper; $this->pseudoNamespaceToNamespace = $pseudoNamespaceToNamespace; $this->phpNode = $phpNode; } - public function beforeTraverse(\PHPStan\PhpDocParser\Ast\Node $node) : void + public function beforeTraverse(Node $node) : void { $this->hasChanged = \false; } - public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node + public function enterNode(Node $node) : ?Node { - if (!$node instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode) { + if (!$node instanceof IdentifierTypeNode) { return null; } if ($this->shouldSkip($node, $this->phpNode, $this->pseudoNamespaceToNamespace)) { @@ -51,22 +51,22 @@ final class UnderscoreRenamePhpDocNodeVisitor extends \RectorPrefix20220607\Symp } /** @var IdentifierTypeNode $node */ $staticType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($node, $this->phpNode); - if (!$staticType instanceof \PHPStan\Type\ObjectType) { + if (!$staticType instanceof ObjectType) { return null; } $this->hasChanged = \true; // change underscore to \\ - $slashedName = '\\' . \RectorPrefix20220607\Nette\Utils\Strings::replace($staticType->getClassName(), '#_#', '\\'); - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($slashedName); + $slashedName = '\\' . Strings::replace($staticType->getClassName(), '#_#', '\\'); + return new IdentifierTypeNode($slashedName); } public function hasChanged() : bool { return $this->hasChanged; } - private function shouldSkip(\PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode $identifierTypeNode, \PhpParser\Node $phpParserNode, \Rector\Renaming\ValueObject\PseudoNamespaceToNamespace $pseudoNamespaceToNamespace) : bool + private function shouldSkip(IdentifierTypeNode $identifierTypeNode, \PhpParser\Node $phpParserNode, PseudoNamespaceToNamespace $pseudoNamespaceToNamespace) : bool { $staticType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($identifierTypeNode, $phpParserNode); - if (!$staticType instanceof \PHPStan\Type\ObjectType) { + if (!$staticType instanceof ObjectType) { return \true; } if (\strncmp($staticType->getClassName(), $pseudoNamespaceToNamespace->getNamespacePrefix(), \strlen($pseudoNamespaceToNamespace->getNamespacePrefix())) !== 0) { diff --git a/packages/NodeTypeResolver/Reflection/BetterReflection/RectorBetterReflectionSourceLocatorFactory.php b/packages/NodeTypeResolver/Reflection/BetterReflection/RectorBetterReflectionSourceLocatorFactory.php index d898d2e5806..e2f4bd49dc8 100644 --- a/packages/NodeTypeResolver/Reflection/BetterReflection/RectorBetterReflectionSourceLocatorFactory.php +++ b/packages/NodeTypeResolver/Reflection/BetterReflection/RectorBetterReflectionSourceLocatorFactory.php @@ -19,17 +19,17 @@ final class RectorBetterReflectionSourceLocatorFactory * @var \Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocator\IntermediateSourceLocator */ private $intermediateSourceLocator; - public function __construct(\PHPStan\Reflection\BetterReflection\BetterReflectionSourceLocatorFactory $betterReflectionSourceLocatorFactory, \Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocator\IntermediateSourceLocator $intermediateSourceLocator) + public function __construct(BetterReflectionSourceLocatorFactory $betterReflectionSourceLocatorFactory, IntermediateSourceLocator $intermediateSourceLocator) { $this->betterReflectionSourceLocatorFactory = $betterReflectionSourceLocatorFactory; $this->intermediateSourceLocator = $intermediateSourceLocator; } - public function create() : \PHPStan\BetterReflection\SourceLocator\Type\MemoizingSourceLocator + public function create() : MemoizingSourceLocator { $phpStanSourceLocator = $this->betterReflectionSourceLocatorFactory->create(); // make PHPStan first source locator, so we avoid parsing every single file - huge performance hit! - $aggregateSourceLocator = new \PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator([$phpStanSourceLocator, $this->intermediateSourceLocator]); + $aggregateSourceLocator = new AggregateSourceLocator([$phpStanSourceLocator, $this->intermediateSourceLocator]); // important for cache - return new \PHPStan\BetterReflection\SourceLocator\Type\MemoizingSourceLocator($aggregateSourceLocator); + return new MemoizingSourceLocator($aggregateSourceLocator); } } diff --git a/packages/NodeTypeResolver/Reflection/BetterReflection/SourceLocator/IntermediateSourceLocator.php b/packages/NodeTypeResolver/Reflection/BetterReflection/SourceLocator/IntermediateSourceLocator.php index 31fd3dd763b..9e15776e3ca 100644 --- a/packages/NodeTypeResolver/Reflection/BetterReflection/SourceLocator/IntermediateSourceLocator.php +++ b/packages/NodeTypeResolver/Reflection/BetterReflection/SourceLocator/IntermediateSourceLocator.php @@ -9,7 +9,7 @@ use PHPStan\BetterReflection\Reflection\Reflection; use PHPStan\BetterReflection\Reflector\Reflector; use PHPStan\BetterReflection\SourceLocator\Type\SourceLocator; use Rector\NodeTypeResolver\Contract\SourceLocatorProviderInterface; -final class IntermediateSourceLocator implements \PHPStan\BetterReflection\SourceLocator\Type\SourceLocator +final class IntermediateSourceLocator implements SourceLocator { /** * @var SourceLocatorProviderInterface[] @@ -23,12 +23,12 @@ final class IntermediateSourceLocator implements \PHPStan\BetterReflection\Sourc { $this->sourceLocatorProviders = $sourceLocatorProviders; } - public function locateIdentifier(\PHPStan\BetterReflection\Reflector\Reflector $reflector, \PHPStan\BetterReflection\Identifier\Identifier $identifier) : ?\PHPStan\BetterReflection\Reflection\Reflection + public function locateIdentifier(Reflector $reflector, Identifier $identifier) : ?Reflection { foreach ($this->sourceLocatorProviders as $sourceLocatorProvider) { $sourceLocator = $sourceLocatorProvider->provide(); $reflection = $sourceLocator->locateIdentifier($reflector, $identifier); - if ($reflection instanceof \PHPStan\BetterReflection\Reflection\Reflection) { + if ($reflection instanceof Reflection) { return $reflection; } } @@ -38,7 +38,7 @@ final class IntermediateSourceLocator implements \PHPStan\BetterReflection\Sourc * Find all identifiers of a type * @return array */ - public function locateIdentifiersByType(\PHPStan\BetterReflection\Reflector\Reflector $reflector, \PHPStan\BetterReflection\Identifier\IdentifierType $identifierType) : array + public function locateIdentifiersByType(Reflector $reflector, IdentifierType $identifierType) : array { foreach ($this->sourceLocatorProviders as $sourceLocatorProvider) { $sourceLocator = $sourceLocatorProvider->provide(); diff --git a/packages/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php b/packages/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php index 0fbd5df8d09..1c996d9a5be 100644 --- a/packages/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php +++ b/packages/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php @@ -11,8 +11,8 @@ use PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedDirectorySourceLo use PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedSingleFileSourceLocator; use Rector\NodeTypeResolver\Contract\SourceLocatorProviderInterface; use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment; -use Symplify\SmartFileSystem\SmartFileInfo; -final class DynamicSourceLocatorProvider implements \Rector\NodeTypeResolver\Contract\SourceLocatorProviderInterface +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; +final class DynamicSourceLocatorProvider implements SourceLocatorProviderInterface { /** * @var string[] @@ -36,12 +36,12 @@ final class DynamicSourceLocatorProvider implements \Rector\NodeTypeResolver\Con * @var \PHPStan\Php\PhpVersion */ private $phpVersion; - public function __construct(\PHPStan\Reflection\BetterReflection\SourceLocator\FileNodesFetcher $fileNodesFetcher, \PHPStan\Php\PhpVersion $phpVersion) + public function __construct(FileNodesFetcher $fileNodesFetcher, PhpVersion $phpVersion) { $this->fileNodesFetcher = $fileNodesFetcher; $this->phpVersion = $phpVersion; } - public function setFileInfo(\Symplify\SmartFileSystem\SmartFileInfo $fileInfo) : void + public function setFileInfo(SmartFileInfo $fileInfo) : void { $this->files = [$fileInfo->getRealPath()]; } @@ -52,21 +52,21 @@ final class DynamicSourceLocatorProvider implements \Rector\NodeTypeResolver\Con { $this->files = \array_merge($this->files, $files); } - public function provide() : \PHPStan\BetterReflection\SourceLocator\Type\SourceLocator + public function provide() : SourceLocator { // do not cache for PHPUnit, as in test every fixture is different - $isPHPUnitRun = \Rector\Testing\PHPUnit\StaticPHPUnitEnvironment::isPHPUnitRun(); - if ($this->aggregateSourceLocator instanceof \PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator && !$isPHPUnitRun) { + $isPHPUnitRun = StaticPHPUnitEnvironment::isPHPUnitRun(); + if ($this->aggregateSourceLocator instanceof AggregateSourceLocator && !$isPHPUnitRun) { return $this->aggregateSourceLocator; } $sourceLocators = []; foreach ($this->files as $file) { - $sourceLocators[] = new \PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedSingleFileSourceLocator($this->fileNodesFetcher, $file); + $sourceLocators[] = new OptimizedSingleFileSourceLocator($this->fileNodesFetcher, $file); } foreach ($this->filesByDirectory as $files) { - $sourceLocators[] = new \PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedDirectorySourceLocator($this->fileNodesFetcher, $this->phpVersion, $files); + $sourceLocators[] = new OptimizedDirectorySourceLocator($this->fileNodesFetcher, $this->phpVersion, $files); } - $this->aggregateSourceLocator = new \PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator($sourceLocators); + $this->aggregateSourceLocator = new AggregateSourceLocator($sourceLocators); return $this->aggregateSourceLocator; } /** diff --git a/packages/NodeTypeResolver/TypeAnalyzer/ArrayTypeAnalyzer.php b/packages/NodeTypeResolver/TypeAnalyzer/ArrayTypeAnalyzer.php index bc6a0de3988..1c608bf48b9 100644 --- a/packages/NodeTypeResolver/TypeAnalyzer/ArrayTypeAnalyzer.php +++ b/packages/NodeTypeResolver/TypeAnalyzer/ArrayTypeAnalyzer.php @@ -57,7 +57,7 @@ final class ArrayTypeAnalyzer * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeTypeResolver\NodeTypeCorrector\PregMatchTypeCorrector $pregMatchTypeCorrector, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver, PregMatchTypeCorrector $pregMatchTypeCorrector, BetterNodeFinder $betterNodeFinder, PhpDocInfoFactory $phpDocInfoFactory, ReflectionResolver $reflectionResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->nodeTypeResolver = $nodeTypeResolver; @@ -66,7 +66,7 @@ final class ArrayTypeAnalyzer $this->phpDocInfoFactory = $phpDocInfoFactory; $this->reflectionResolver = $reflectionResolver; } - public function isArrayType(\PhpParser\Node $node) : bool + public function isArrayType(Node $node) : bool { $nodeType = $this->nodeTypeResolver->getType($node); $nodeType = $this->pregMatchTypeCorrector->correct($node, $nodeType); @@ -74,7 +74,7 @@ final class ArrayTypeAnalyzer return \true; } // PHPStan false positive, when variable has type[] docblock, but default array is missing - if ($node instanceof \PhpParser\Node\Expr\PropertyFetch || $node instanceof \PhpParser\Node\Expr\StaticPropertyFetch) { + if ($node instanceof PropertyFetch || $node instanceof StaticPropertyFetch) { if ($this->isPropertyFetchWithArrayDefault($node)) { return \true; } @@ -82,7 +82,7 @@ final class ArrayTypeAnalyzer return \false; } } - if ($nodeType instanceof \PHPStan\Type\MixedType) { + if ($nodeType instanceof MixedType) { if ($nodeType->isExplicitMixed()) { return \false; } @@ -90,34 +90,34 @@ final class ArrayTypeAnalyzer return \true; } } - return $nodeType instanceof \PHPStan\Type\ArrayType; + return $nodeType instanceof ArrayType; } - private function isIntersectionArrayType(\PHPStan\Type\Type $nodeType) : bool + private function isIntersectionArrayType(Type $nodeType) : bool { - if (!$nodeType instanceof \PHPStan\Type\IntersectionType) { + if (!$nodeType instanceof IntersectionType) { return \false; } foreach ($nodeType->getTypes() as $intersectionNodeType) { - if ($intersectionNodeType instanceof \PHPStan\Type\ArrayType) { + if ($intersectionNodeType instanceof ArrayType) { continue; } - if ($intersectionNodeType instanceof \PHPStan\Type\Accessory\HasOffsetType) { + if ($intersectionNodeType instanceof HasOffsetType) { continue; } - if ($intersectionNodeType instanceof \PHPStan\Type\Accessory\NonEmptyArrayType) { + if ($intersectionNodeType instanceof NonEmptyArrayType) { continue; } return \false; } return \true; } - private function isPropertyFetchWithArrayDocblockWithoutDefault(\PhpParser\Node $node) : bool + private function isPropertyFetchWithArrayDocblockWithoutDefault(Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Expr\PropertyFetch && !$node instanceof \PhpParser\Node\Expr\StaticPropertyFetch) { + if (!$node instanceof PropertyFetch && !$node instanceof StaticPropertyFetch) { return \false; } - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($node, ClassLike::class); + if (!$classLike instanceof ClassLike) { return \false; } $propertyName = $this->nodeNameResolver->getName($node->name); @@ -125,30 +125,30 @@ final class ArrayTypeAnalyzer return \false; } $property = $classLike->getProperty($propertyName); - if (!$property instanceof \PhpParser\Node\Stmt\Property) { + if (!$property instanceof Property) { return \false; } $propertyProperty = $property->props[0]; - if ($propertyProperty->default instanceof \PhpParser\Node\Expr\Array_) { + if ($propertyProperty->default instanceof Array_) { return \false; } $propertyPhpDocInfo = $this->phpDocInfoFactory->createFromNode($property); - if (!$propertyPhpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$propertyPhpDocInfo instanceof PhpDocInfo) { return \false; } $varType = $propertyPhpDocInfo->getVarType(); - return $varType instanceof \PHPStan\Type\ArrayType || $varType instanceof \PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode || $varType instanceof \PHPStan\Type\IterableType; + return $varType instanceof ArrayType || $varType instanceof ArrayShapeNode || $varType instanceof IterableType; } /** * phpstan bug workaround - https://phpstan.org/r/0443f283-244c-42b8-8373-85e7deb3504c */ - private function isPropertyFetchWithArrayDefault(\PhpParser\Node $node) : bool + private function isPropertyFetchWithArrayDefault(Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Expr\PropertyFetch && !$node instanceof \PhpParser\Node\Expr\StaticPropertyFetch) { + if (!$node instanceof PropertyFetch && !$node instanceof StaticPropertyFetch) { return \false; } - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($node, ClassLike::class); + if (!$classLike instanceof ClassLike) { return \false; } $propertyName = $this->nodeNameResolver->getName($node->name); @@ -159,11 +159,11 @@ final class ArrayTypeAnalyzer $property = $classLike->getProperty($propertyName); if ($property !== null) { $propertyProperty = $property->props[0]; - return $propertyProperty->default instanceof \PhpParser\Node\Expr\Array_; + return $propertyProperty->default instanceof Array_; } // B. another object property $phpPropertyReflection = $this->reflectionResolver->resolvePropertyReflectionFromPropertyFetch($node); - if ($phpPropertyReflection instanceof \PHPStan\Reflection\Php\PhpPropertyReflection) { + if ($phpPropertyReflection instanceof PhpPropertyReflection) { $reflectionProperty = $phpPropertyReflection->getNativeReflection(); return \is_array($reflectionProperty->getDefaultValue()); } diff --git a/packages/NodeTypeResolver/TypeAnalyzer/CountableTypeAnalyzer.php b/packages/NodeTypeResolver/TypeAnalyzer/CountableTypeAnalyzer.php index a2469c67ccd..8cf04547534 100644 --- a/packages/NodeTypeResolver/TypeAnalyzer/CountableTypeAnalyzer.php +++ b/packages/NodeTypeResolver/TypeAnalyzer/CountableTypeAnalyzer.php @@ -28,14 +28,14 @@ final class CountableTypeAnalyzer * @var \Rector\NodeTypeResolver\NodeTypeCorrector\PregMatchTypeCorrector */ private $pregMatchTypeCorrector; - public function __construct(\Rector\NodeTypeResolver\TypeAnalyzer\ArrayTypeAnalyzer $arrayTypeAnalyzer, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeTypeResolver\NodeTypeCorrector\PregMatchTypeCorrector $pregMatchTypeCorrector) + public function __construct(\Rector\NodeTypeResolver\TypeAnalyzer\ArrayTypeAnalyzer $arrayTypeAnalyzer, NodeTypeResolver $nodeTypeResolver, PregMatchTypeCorrector $pregMatchTypeCorrector) { $this->arrayTypeAnalyzer = $arrayTypeAnalyzer; $this->nodeTypeResolver = $nodeTypeResolver; $this->pregMatchTypeCorrector = $pregMatchTypeCorrector; - $this->countableObjectTypes = [new \PHPStan\Type\ObjectType('Countable'), new \PHPStan\Type\ObjectType('SimpleXMLElement'), new \PHPStan\Type\ObjectType('ResourceBundle')]; + $this->countableObjectTypes = [new ObjectType('Countable'), new ObjectType('SimpleXMLElement'), new ObjectType('ResourceBundle')]; } - public function isCountableType(\PhpParser\Node $node) : bool + public function isCountableType(Node $node) : bool { $nodeType = $this->nodeTypeResolver->getType($node); $nodeType = $this->pregMatchTypeCorrector->correct($node, $nodeType); diff --git a/packages/NodeTypeResolver/TypeAnalyzer/MethodTypeAnalyzer.php b/packages/NodeTypeResolver/TypeAnalyzer/MethodTypeAnalyzer.php index 2e242dd9d2a..c80c4106882 100644 --- a/packages/NodeTypeResolver/TypeAnalyzer/MethodTypeAnalyzer.php +++ b/packages/NodeTypeResolver/TypeAnalyzer/MethodTypeAnalyzer.php @@ -16,7 +16,7 @@ final class MethodTypeAnalyzer * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(NodeTypeResolver $nodeTypeResolver) { $this->nodeTypeResolver = $nodeTypeResolver; } @@ -24,7 +24,7 @@ final class MethodTypeAnalyzer * @param class-string $expectedClass * @param non-empty-string $expectedMethod */ - public function isCallTo(\PhpParser\Node\Expr\MethodCall $methodCall, string $expectedClass, string $expectedMethod) : bool + public function isCallTo(MethodCall $methodCall, string $expectedClass, string $expectedMethod) : bool { if (!$this->isMethodName($methodCall, $expectedMethod)) { return \false; @@ -34,13 +34,13 @@ final class MethodTypeAnalyzer /** * @param non-empty-string $expectedName */ - private function isMethodName(\PhpParser\Node\Expr\MethodCall $methodCall, string $expectedName) : bool + private function isMethodName(MethodCall $methodCall, string $expectedName) : bool { - if ($methodCall->name instanceof \PhpParser\Node\Identifier && $this->areMethodNamesEqual($methodCall->name->toString(), $expectedName)) { + if ($methodCall->name instanceof Identifier && $this->areMethodNamesEqual($methodCall->name->toString(), $expectedName)) { return \true; } $type = $this->nodeTypeResolver->getType($methodCall->name); - return $type instanceof \PHPStan\Type\Constant\ConstantStringType && $this->areMethodNamesEqual($type->getValue(), $expectedName); + return $type instanceof ConstantStringType && $this->areMethodNamesEqual($type->getValue(), $expectedName); } private function areMethodNamesEqual(string $left, string $right) : bool { @@ -50,10 +50,10 @@ final class MethodTypeAnalyzer /** * @param class-string $expectedClass */ - private function isInstanceOf(\PhpParser\Node\Expr $expr, string $expectedClass) : bool + private function isInstanceOf(Expr $expr, string $expectedClass) : bool { $type = $this->nodeTypeResolver->getType($expr); - if (!$type instanceof \PHPStan\Type\TypeWithClassName) { + if (!$type instanceof TypeWithClassName) { return \false; } if ($this->areClassNamesEqual($expectedClass, $type->getClassName())) { diff --git a/packages/NodeTypeResolver/TypeAnalyzer/StringTypeAnalyzer.php b/packages/NodeTypeResolver/TypeAnalyzer/StringTypeAnalyzer.php index 106357e61aa..46629f108b3 100644 --- a/packages/NodeTypeResolver/TypeAnalyzer/StringTypeAnalyzer.php +++ b/packages/NodeTypeResolver/TypeAnalyzer/StringTypeAnalyzer.php @@ -14,19 +14,19 @@ final class StringTypeAnalyzer * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(NodeTypeResolver $nodeTypeResolver) { $this->nodeTypeResolver = $nodeTypeResolver; } - public function isStringOrUnionStringOnlyType(\PhpParser\Node $node) : bool + public function isStringOrUnionStringOnlyType(Node $node) : bool { $nodeType = $this->nodeTypeResolver->getType($node); - if ($nodeType instanceof \PHPStan\Type\StringType) { + if ($nodeType instanceof StringType) { return \true; } - if ($nodeType instanceof \PHPStan\Type\UnionType) { + if ($nodeType instanceof UnionType) { foreach ($nodeType->getTypes() as $singleType) { - if ($singleType->isSuperTypeOf(new \PHPStan\Type\StringType())->no()) { + if ($singleType->isSuperTypeOf(new StringType())->no()) { return \false; } } diff --git a/packages/NodeTypeResolver/TypeComparator/ArrayTypeComparator.php b/packages/NodeTypeResolver/TypeComparator/ArrayTypeComparator.php index 74500c77442..01e082f029e 100644 --- a/packages/NodeTypeResolver/TypeComparator/ArrayTypeComparator.php +++ b/packages/NodeTypeResolver/TypeComparator/ArrayTypeComparator.php @@ -20,28 +20,28 @@ final class ArrayTypeComparator * @var \Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeCommonTypeNarrower */ private $unionTypeCommonTypeNarrower; - public function __construct(\Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeCommonTypeNarrower $unionTypeCommonTypeNarrower) + public function __construct(UnionTypeCommonTypeNarrower $unionTypeCommonTypeNarrower) { $this->unionTypeCommonTypeNarrower = $unionTypeCommonTypeNarrower; } - public function isSubtype(\PHPStan\Type\ArrayType $checkedType, \PHPStan\Type\ArrayType $mainType) : bool + public function isSubtype(ArrayType $checkedType, ArrayType $mainType) : bool { - if (!$checkedType instanceof \PHPStan\Type\Constant\ConstantArrayType && !$mainType instanceof \PHPStan\Type\Constant\ConstantArrayType) { + if (!$checkedType instanceof ConstantArrayType && !$mainType instanceof ConstantArrayType) { return $mainType->isSuperTypeOf($checkedType)->yes(); } $checkedKeyType = $checkedType->getKeyType(); $mainKeyType = $mainType->getKeyType(); $mainKeyType = $this->narrowArrayKeysUnionType($mainKeyType); $checkedKeyType = $this->narrowArrayKeysUnionType($checkedKeyType); - if (!$mainKeyType instanceof \PHPStan\Type\MixedType && $mainKeyType->isSuperTypeOf($checkedKeyType)->yes()) { + if (!$mainKeyType instanceof MixedType && $mainKeyType->isSuperTypeOf($checkedKeyType)->yes()) { return \true; } $checkedItemType = $checkedType->getItemType(); - if ($checkedItemType instanceof \PHPStan\Type\UnionType) { + if ($checkedItemType instanceof UnionType) { $checkedItemType = $this->unionTypeCommonTypeNarrower->narrowToGenericClassStringType($checkedItemType); } $mainItemType = $mainType->getItemType(); - if ($mainItemType instanceof \PHPStan\Type\UnionType) { + if ($mainItemType instanceof UnionType) { $mainItemType = $this->unionTypeCommonTypeNarrower->narrowToGenericClassStringType($mainItemType); } return $checkedItemType->isSuperTypeOf($mainItemType)->yes(); @@ -49,13 +49,13 @@ final class ArrayTypeComparator /** * Native array order can be treated as mixed type */ - private function narrowArrayKeysUnionType(\PHPStan\Type\Type $type) : \PHPStan\Type\Type + private function narrowArrayKeysUnionType(Type $type) : Type { - if (!$type instanceof \PHPStan\Type\UnionType) { + if (!$type instanceof UnionType) { return $type; } foreach ($type->getTypes() as $key => $unionedType) { - if (!$unionedType instanceof \PHPStan\Type\Constant\ConstantIntegerType) { + if (!$unionedType instanceof ConstantIntegerType) { return $type; } if ($key === $unionedType->getValue()) { @@ -63,6 +63,6 @@ final class ArrayTypeComparator } return $type; } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } } diff --git a/packages/NodeTypeResolver/TypeComparator/ScalarTypeComparator.php b/packages/NodeTypeResolver/TypeComparator/ScalarTypeComparator.php index 96d702d0019..c23c852444d 100644 --- a/packages/NodeTypeResolver/TypeComparator/ScalarTypeComparator.php +++ b/packages/NodeTypeResolver/TypeComparator/ScalarTypeComparator.php @@ -14,29 +14,29 @@ use PHPStan\Type\Type; */ final class ScalarTypeComparator { - public function areEqualScalar(\PHPStan\Type\Type $firstType, \PHPStan\Type\Type $secondType) : bool + public function areEqualScalar(Type $firstType, Type $secondType) : bool { - if ($firstType instanceof \PHPStan\Type\StringType && $secondType instanceof \PHPStan\Type\StringType) { + if ($firstType instanceof StringType && $secondType instanceof StringType) { // prevents "class-string" vs "string" $firstTypeClass = \get_class($firstType); $secondTypeClass = \get_class($secondType); return $firstTypeClass === $secondTypeClass; } - if ($firstType instanceof \PHPStan\Type\IntegerType && $secondType instanceof \PHPStan\Type\IntegerType) { + if ($firstType instanceof IntegerType && $secondType instanceof IntegerType) { return \true; } - if ($firstType instanceof \PHPStan\Type\FloatType && $secondType instanceof \PHPStan\Type\FloatType) { + if ($firstType instanceof FloatType && $secondType instanceof FloatType) { return \true; } - if (!$firstType instanceof \PHPStan\Type\BooleanType) { + if (!$firstType instanceof BooleanType) { return \false; } - return $secondType instanceof \PHPStan\Type\BooleanType; + return $secondType instanceof BooleanType; } /** * E.g. first is string, second is bool */ - public function areDifferentScalarTypes(\PHPStan\Type\Type $firstType, \PHPStan\Type\Type $secondType) : bool + public function areDifferentScalarTypes(Type $firstType, Type $secondType) : bool { if (!$this->isScalarType($firstType)) { return \false; @@ -45,28 +45,28 @@ final class ScalarTypeComparator return \false; } // treat class-string and string the same - if ($firstType instanceof \PHPStan\Type\ClassStringType && $secondType instanceof \PHPStan\Type\StringType) { + if ($firstType instanceof ClassStringType && $secondType instanceof StringType) { return \false; } - if (!$firstType instanceof \PHPStan\Type\StringType) { + if (!$firstType instanceof StringType) { return \get_class($firstType) !== \get_class($secondType); } - if (!$secondType instanceof \PHPStan\Type\ClassStringType) { + if (!$secondType instanceof ClassStringType) { return \get_class($firstType) !== \get_class($secondType); } return \false; } - private function isScalarType(\PHPStan\Type\Type $type) : bool + private function isScalarType(Type $type) : bool { - if ($type instanceof \PHPStan\Type\StringType) { + if ($type instanceof StringType) { return \true; } - if ($type instanceof \PHPStan\Type\FloatType) { + if ($type instanceof FloatType) { return \true; } - if ($type instanceof \PHPStan\Type\IntegerType) { + if ($type instanceof IntegerType) { return \true; } - return $type instanceof \PHPStan\Type\BooleanType; + return $type instanceof BooleanType; } } diff --git a/packages/NodeTypeResolver/TypeComparator/TypeComparator.php b/packages/NodeTypeResolver/TypeComparator/TypeComparator.php index 78fab085374..d8162cc374e 100644 --- a/packages/NodeTypeResolver/TypeComparator/TypeComparator.php +++ b/packages/NodeTypeResolver/TypeComparator/TypeComparator.php @@ -71,7 +71,7 @@ final class TypeComparator * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeTypeResolver\PHPStan\TypeHasher $typeHasher, \Rector\TypeDeclaration\TypeNormalizer $typeNormalizer, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\NodeTypeResolver\TypeComparator\ArrayTypeComparator $arrayTypeComparator, \Rector\NodeTypeResolver\TypeComparator\ScalarTypeComparator $scalarTypeComparator, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer $unionTypeAnalyzer, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(TypeHasher $typeHasher, TypeNormalizer $typeNormalizer, StaticTypeMapper $staticTypeMapper, \Rector\NodeTypeResolver\TypeComparator\ArrayTypeComparator $arrayTypeComparator, \Rector\NodeTypeResolver\TypeComparator\ScalarTypeComparator $scalarTypeComparator, TypeFactory $typeFactory, UnionTypeAnalyzer $unionTypeAnalyzer, BetterNodeFinder $betterNodeFinder) { $this->typeHasher = $typeHasher; $this->typeNormalizer = $typeNormalizer; @@ -82,7 +82,7 @@ final class TypeComparator $this->unionTypeAnalyzer = $unionTypeAnalyzer; $this->betterNodeFinder = $betterNodeFinder; } - public function areTypesEqual(\PHPStan\Type\Type $firstType, \PHPStan\Type\Type $secondType) : bool + public function areTypesEqual(Type $firstType, Type $secondType) : bool { $firstTypeHash = $this->typeHasher->createTypeHash($firstType); $secondTypeHash = $this->typeHasher->createTypeHash($secondType); @@ -107,7 +107,7 @@ final class TypeComparator // is template of return $this->areArrayTypeWithSingleObjectChildToParent($firstType, $secondType); } - public function arePhpParserAndPhpStanPhpDocTypesEqual(\PhpParser\Node $phpParserNode, \PHPStan\PhpDocParser\Ast\Type\TypeNode $phpStanDocTypeNode, \PhpParser\Node $node) : bool + public function arePhpParserAndPhpStanPhpDocTypesEqual(Node $phpParserNode, TypeNode $phpStanDocTypeNode, Node $node) : bool { $phpParserNodeType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($phpParserNode); $phpStanDocType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($phpStanDocTypeNode, $node); @@ -127,34 +127,34 @@ final class TypeComparator } return $this->isThisTypeInFinalClass($phpStanDocType, $phpParserNodeType, $phpParserNode); } - public function isSubtype(\PHPStan\Type\Type $checkedType, \PHPStan\Type\Type $mainType) : bool + public function isSubtype(Type $checkedType, Type $mainType) : bool { - if ($mainType instanceof \PHPStan\Type\MixedType) { + if ($mainType instanceof MixedType) { return \false; } - if (!$mainType instanceof \PHPStan\Type\ArrayType) { + if (!$mainType instanceof ArrayType) { return $mainType->isSuperTypeOf($checkedType)->yes(); } - if (!$checkedType instanceof \PHPStan\Type\ArrayType) { + if (!$checkedType instanceof ArrayType) { return $mainType->isSuperTypeOf($checkedType)->yes(); } return $this->arrayTypeComparator->isSubtype($checkedType, $mainType); } - public function areTypesPossiblyIncluded(?\PHPStan\Type\Type $assumptionType, ?\PHPStan\Type\Type $exactType) : bool + public function areTypesPossiblyIncluded(?Type $assumptionType, ?Type $exactType) : bool { - if (!$assumptionType instanceof \PHPStan\Type\Type) { + if (!$assumptionType instanceof Type) { return \true; } - if (!$exactType instanceof \PHPStan\Type\Type) { + if (!$exactType instanceof Type) { return \true; } if ($this->areTypesEqual($assumptionType, $exactType)) { return \true; } - if (!$assumptionType instanceof \PHPStan\Type\UnionType) { + if (!$assumptionType instanceof UnionType) { return \true; } - if (!$exactType instanceof \PHPStan\Type\UnionType) { + if (!$exactType instanceof UnionType) { return \true; } $countAssumpionTypeTypes = \count($assumptionType->getTypes()); @@ -165,15 +165,15 @@ final class TypeComparator } return $countAssumpionTypeTypes > $countExactTypeTypes; } - private function areAliasedObjectMatchingFqnObject(\PHPStan\Type\Type $firstType, \PHPStan\Type\Type $secondType) : bool + private function areAliasedObjectMatchingFqnObject(Type $firstType, Type $secondType) : bool { - if ($firstType instanceof \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType && $secondType instanceof \PHPStan\Type\ObjectType) { + if ($firstType instanceof AliasedObjectType && $secondType instanceof ObjectType) { return $firstType->getFullyQualifiedName() === $secondType->getClassName(); } - if (!$firstType instanceof \PHPStan\Type\ObjectType) { + if (!$firstType instanceof ObjectType) { return \false; } - if (!$secondType instanceof \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType) { + if (!$secondType instanceof AliasedObjectType) { return \false; } return $secondType->getFullyQualifiedName() === $firstType->getClassName(); @@ -181,12 +181,12 @@ final class TypeComparator /** * E.g. class A extends B, class B → A[] is subtype of B[] → keep A[] */ - private function areArrayTypeWithSingleObjectChildToParent(\PHPStan\Type\Type $firstType, \PHPStan\Type\Type $secondType) : bool + private function areArrayTypeWithSingleObjectChildToParent(Type $firstType, Type $secondType) : bool { - if (!$firstType instanceof \PHPStan\Type\ArrayType) { + if (!$firstType instanceof ArrayType) { return \false; } - if (!$secondType instanceof \PHPStan\Type\ArrayType) { + if (!$secondType instanceof ArrayType) { return \false; } $firstArrayItemType = $firstType->getItemType(); @@ -194,21 +194,21 @@ final class TypeComparator if ($this->isMutualObjectSubtypes($firstArrayItemType, $secondArrayItemType)) { return \true; } - if (!$firstArrayItemType instanceof \PHPStan\Type\Generic\GenericClassStringType) { + if (!$firstArrayItemType instanceof GenericClassStringType) { return \false; } - if (!$secondArrayItemType instanceof \PHPStan\Type\Generic\GenericClassStringType) { + if (!$secondArrayItemType instanceof GenericClassStringType) { return \false; } // @todo resolve later better with template map, @see https://github.com/symplify/symplify/pull/3034/commits/4f6be8b87e52117b1aa1613b9b689ae958a9d6f4 - return $firstArrayItemType->getGenericType() instanceof \PHPStan\Type\ObjectType && $secondArrayItemType->getGenericType() instanceof \PHPStan\Type\ObjectType; + return $firstArrayItemType->getGenericType() instanceof ObjectType && $secondArrayItemType->getGenericType() instanceof ObjectType; } - private function isMutualObjectSubtypes(\PHPStan\Type\Type $firstArrayItemType, \PHPStan\Type\Type $secondArrayItemType) : bool + private function isMutualObjectSubtypes(Type $firstArrayItemType, Type $secondArrayItemType) : bool { - if (!$firstArrayItemType instanceof \PHPStan\Type\ObjectType) { + if (!$firstArrayItemType instanceof ObjectType) { return \false; } - if (!$secondArrayItemType instanceof \PHPStan\Type\ObjectType) { + if (!$secondArrayItemType instanceof ObjectType) { return \false; } if ($firstArrayItemType->isSuperTypeOf($secondArrayItemType)->yes()) { @@ -216,9 +216,9 @@ final class TypeComparator } return $secondArrayItemType->isSuperTypeOf($firstArrayItemType)->yes(); } - private function normalizeSingleUnionType(\PHPStan\Type\Type $type) : \PHPStan\Type\Type + private function normalizeSingleUnionType(Type $type) : Type { - if (!$type instanceof \PHPStan\Type\UnionType) { + if (!$type instanceof UnionType) { return $type; } $uniqueTypes = $this->typeFactory->uniquateTypes($type->getTypes()); @@ -227,25 +227,25 @@ final class TypeComparator } return $uniqueTypes[0]; } - private function areArrayUnionConstantEqualTypes(\PHPStan\Type\Type $firstType, \PHPStan\Type\Type $secondType) : bool + private function areArrayUnionConstantEqualTypes(Type $firstType, Type $secondType) : bool { - if (!$firstType instanceof \PHPStan\Type\ArrayType) { + if (!$firstType instanceof ArrayType) { return \false; } - if (!$secondType instanceof \PHPStan\Type\ArrayType) { + if (!$secondType instanceof ArrayType) { return \false; } - if ($firstType instanceof \PHPStan\Type\Constant\ConstantArrayType || $secondType instanceof \PHPStan\Type\Constant\ConstantArrayType) { + if ($firstType instanceof ConstantArrayType || $secondType instanceof ConstantArrayType) { return \false; } $firstKeyType = $this->normalizeSingleUnionType($firstType->getKeyType()); $secondKeyType = $this->normalizeSingleUnionType($secondType->getKeyType()); // mixed and integer type are mutual replaceable in practise - if ($firstKeyType instanceof \PHPStan\Type\MixedType) { - $firstKeyType = new \PHPStan\Type\IntegerType(); + if ($firstKeyType instanceof MixedType) { + $firstKeyType = new IntegerType(); } - if ($secondKeyType instanceof \PHPStan\Type\MixedType) { - $secondKeyType = new \PHPStan\Type\IntegerType(); + if ($secondKeyType instanceof MixedType) { + $secondKeyType = new IntegerType(); } if (!$this->areTypesEqual($firstKeyType, $secondKeyType)) { return \false; @@ -254,24 +254,24 @@ final class TypeComparator $secondArrayType = $this->normalizeSingleUnionType($secondType->getItemType()); return $this->areTypesEqual($firstArrayType, $secondArrayType); } - private function normalizeConstantBooleanType(\PHPStan\Type\Type $type) : \PHPStan\Type\Type + private function normalizeConstantBooleanType(Type $type) : Type { - return \PHPStan\Type\TypeTraverser::map($type, function (\PHPStan\Type\Type $type, callable $callable) : Type { - if ($type instanceof \PHPStan\Type\Constant\ConstantBooleanType) { - return new \PHPStan\Type\BooleanType(); + return TypeTraverser::map($type, function (Type $type, callable $callable) : Type { + if ($type instanceof ConstantBooleanType) { + return new BooleanType(); } return $callable($type); }); } - private function isTypeSelfAndDocParamTypeStatic(\PHPStan\Type\Type $phpStanDocType, \PHPStan\Type\Type $phpParserNodeType, \PHPStan\PhpDocParser\Ast\Type\TypeNode $phpStanDocTypeNode) : bool + private function isTypeSelfAndDocParamTypeStatic(Type $phpStanDocType, Type $phpParserNodeType, TypeNode $phpStanDocTypeNode) : bool { - return $phpStanDocType instanceof \PHPStan\Type\StaticType && $phpParserNodeType instanceof \PHPStan\Type\ThisType && $phpStanDocTypeNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::PARENT) instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode; + return $phpStanDocType instanceof StaticType && $phpParserNodeType instanceof ThisType && $phpStanDocTypeNode->getAttribute(PhpDocAttributeKey::PARENT) instanceof ParamTagValueNode; } - private function areTypesSameWithLiteralTypeInPhpDoc(bool $areDifferentScalarTypes, \PHPStan\Type\Type $phpStanDocType, \PHPStan\Type\Type $phpParserNodeType) : bool + private function areTypesSameWithLiteralTypeInPhpDoc(bool $areDifferentScalarTypes, Type $phpStanDocType, Type $phpParserNodeType) : bool { - return $areDifferentScalarTypes && $phpStanDocType instanceof \PHPStan\Type\ConstantScalarType && $phpParserNodeType->isSuperTypeOf($phpStanDocType)->yes(); + return $areDifferentScalarTypes && $phpStanDocType instanceof ConstantScalarType && $phpParserNodeType->isSuperTypeOf($phpStanDocType)->yes(); } - private function isThisTypeInFinalClass(\PHPStan\Type\Type $phpStanDocType, \PHPStan\Type\Type $phpParserNodeType, \PhpParser\Node $node) : bool + private function isThisTypeInFinalClass(Type $phpStanDocType, Type $phpParserNodeType, Node $node) : bool { /** * Special case for $this/(self|static) compare @@ -279,15 +279,15 @@ final class TypeComparator * $this refers to the exact object identity, not just the same type. Therefore, it's valid and should not be removed * @see https://wiki.php.net/rfc/this_return_type for more context */ - if ($phpStanDocType instanceof \PHPStan\Type\ThisType && $phpParserNodeType instanceof \PHPStan\Type\StaticType) { + if ($phpStanDocType instanceof ThisType && $phpParserNodeType instanceof StaticType) { return \false; } - $isStaticReturnDocTypeWithThisType = $phpStanDocType instanceof \PHPStan\Type\StaticType && $phpParserNodeType instanceof \PHPStan\Type\ThisType; + $isStaticReturnDocTypeWithThisType = $phpStanDocType instanceof StaticType && $phpParserNodeType instanceof ThisType; if (!$isStaticReturnDocTypeWithThisType) { return \true; } - $class = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$class instanceof Class_) { return \false; } return $class->isFinal(); diff --git a/packages/NodeTypeResolver/ValueObject/OldToNewType.php b/packages/NodeTypeResolver/ValueObject/OldToNewType.php index d3ce8b33893..c22f1040a14 100644 --- a/packages/NodeTypeResolver/ValueObject/OldToNewType.php +++ b/packages/NodeTypeResolver/ValueObject/OldToNewType.php @@ -16,16 +16,16 @@ final class OldToNewType * @var \PHPStan\Type\Type */ private $newType; - public function __construct(\PHPStan\Type\Type $oldType, \PHPStan\Type\Type $newType) + public function __construct(Type $oldType, Type $newType) { $this->oldType = $oldType; $this->newType = $newType; } - public function getOldType() : \PHPStan\Type\Type + public function getOldType() : Type { return $this->oldType; } - public function getNewType() : \PHPStan\Type\Type + public function getNewType() : Type { return $this->newType; } diff --git a/packages/PHPStanStaticTypeMapper/Contract/TypeMapperInterface.php b/packages/PHPStanStaticTypeMapper/Contract/TypeMapperInterface.php index a80922602ab..036f9333d9c 100644 --- a/packages/PHPStanStaticTypeMapper/Contract/TypeMapperInterface.php +++ b/packages/PHPStanStaticTypeMapper/Contract/TypeMapperInterface.php @@ -22,11 +22,11 @@ interface TypeMapperInterface * @param TType $type * @param TypeKind::* $typeKind */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode; + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode; /** * @param TType $type * @param TypeKind::* $typeKind * @return Name|ComplexType|null */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node; + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node; } diff --git a/packages/PHPStanStaticTypeMapper/DoctrineTypeAnalyzer.php b/packages/PHPStanStaticTypeMapper/DoctrineTypeAnalyzer.php index 945e99ebd92..f528fcebaaa 100644 --- a/packages/PHPStanStaticTypeMapper/DoctrineTypeAnalyzer.php +++ b/packages/PHPStanStaticTypeMapper/DoctrineTypeAnalyzer.php @@ -9,9 +9,9 @@ use PHPStan\Type\TypeWithClassName; use PHPStan\Type\UnionType; final class DoctrineTypeAnalyzer { - public function isDoctrineCollectionWithIterableUnionType(\PHPStan\Type\Type $type) : bool + public function isDoctrineCollectionWithIterableUnionType(Type $type) : bool { - if (!$type instanceof \PHPStan\Type\UnionType) { + if (!$type instanceof UnionType) { return \false; } $arrayType = null; @@ -20,7 +20,7 @@ final class DoctrineTypeAnalyzer if ($this->isCollectionObjectType($unionedType)) { $hasDoctrineCollectionType = \true; } - if ($unionedType instanceof \PHPStan\Type\ArrayType) { + if ($unionedType instanceof ArrayType) { $arrayType = $unionedType; } } @@ -29,9 +29,9 @@ final class DoctrineTypeAnalyzer } return $arrayType !== null; } - private function isCollectionObjectType(\PHPStan\Type\Type $type) : bool + private function isCollectionObjectType(Type $type) : bool { - if (!$type instanceof \PHPStan\Type\TypeWithClassName) { + if (!$type instanceof TypeWithClassName) { return \false; } return $type->getClassName() === 'Doctrine\\Common\\Collections\\Collection'; diff --git a/packages/PHPStanStaticTypeMapper/PHPStanStaticTypeMapper.php b/packages/PHPStanStaticTypeMapper/PHPStanStaticTypeMapper.php index fc48ffba4ce..843767535d3 100644 --- a/packages/PHPStanStaticTypeMapper/PHPStanStaticTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/PHPStanStaticTypeMapper.php @@ -31,7 +31,7 @@ final class PHPStanStaticTypeMapper /** * @param TypeKind::* $typeKind */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { foreach ($this->typeMappers as $typeMapper) { if (!\is_a($type, $typeMapper->getNodeClass(), \true)) { @@ -39,22 +39,22 @@ final class PHPStanStaticTypeMapper } return $typeMapper->mapToPHPStanPhpDocTypeNode($type, $typeKind); } - if ($type instanceof \PHPStan\Type\Accessory\AccessoryNumericStringType) { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('string'); + if ($type instanceof AccessoryNumericStringType) { + return new IdentifierTypeNode('string'); } - if ($type instanceof \PHPStan\Type\Accessory\HasMethodType) { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('object'); + if ($type instanceof HasMethodType) { + return new IdentifierTypeNode('object'); } - if ($type instanceof \PHPStan\Type\Accessory\AccessoryLiteralStringType) { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('string'); + if ($type instanceof AccessoryLiteralStringType) { + return new IdentifierTypeNode('string'); } - throw new \Rector\Core\Exception\NotImplementedYetException(__METHOD__ . ' for ' . \get_class($type)); + throw new NotImplementedYetException(__METHOD__ . ' for ' . \get_class($type)); } /** * @param TypeKind::* $typeKind * @return \PhpParser\Node\Name|\PhpParser\Node\ComplexType|null */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) + public function mapToPhpParserNode(Type $type, string $typeKind) { foreach ($this->typeMappers as $typeMapper) { if (!\is_a($type, $typeMapper->getNodeClass(), \true)) { @@ -62,6 +62,6 @@ final class PHPStanStaticTypeMapper } return $typeMapper->mapToPhpParserNode($type, $typeKind); } - throw new \Rector\Core\Exception\NotImplementedYetException(__METHOD__ . ' for ' . \get_class($type)); + throw new NotImplementedYetException(__METHOD__ . ' for ' . \get_class($type)); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeAnalyzer/BoolUnionTypeAnalyzer.php b/packages/PHPStanStaticTypeMapper/TypeAnalyzer/BoolUnionTypeAnalyzer.php index 38324e1897e..a76665b1ba7 100644 --- a/packages/PHPStanStaticTypeMapper/TypeAnalyzer/BoolUnionTypeAnalyzer.php +++ b/packages/PHPStanStaticTypeMapper/TypeAnalyzer/BoolUnionTypeAnalyzer.php @@ -8,24 +8,24 @@ use PHPStan\Type\NullType; use PHPStan\Type\UnionType; final class BoolUnionTypeAnalyzer { - public function isBoolUnionType(\PHPStan\Type\UnionType $unionType) : bool + public function isBoolUnionType(UnionType $unionType) : bool { foreach ($unionType->getTypes() as $unionedType) { - if (!$unionedType instanceof \PHPStan\Type\BooleanType) { + if (!$unionedType instanceof BooleanType) { return \false; } } return \true; } - public function isNullableBoolUnionType(\PHPStan\Type\UnionType $unionType) : bool + public function isNullableBoolUnionType(UnionType $unionType) : bool { $hasNullable = \false; foreach ($unionType->getTypes() as $unionedType) { - if ($unionedType instanceof \PHPStan\Type\NullType) { + if ($unionedType instanceof NullType) { $hasNullable = \true; continue; } - if ($unionedType instanceof \PHPStan\Type\BooleanType) { + if ($unionedType instanceof BooleanType) { continue; } return \false; diff --git a/packages/PHPStanStaticTypeMapper/TypeAnalyzer/UnionTypeAnalyzer.php b/packages/PHPStanStaticTypeMapper/TypeAnalyzer/UnionTypeAnalyzer.php index 0f7c45f9df9..4b70c75420a 100644 --- a/packages/PHPStanStaticTypeMapper/TypeAnalyzer/UnionTypeAnalyzer.php +++ b/packages/PHPStanStaticTypeMapper/TypeAnalyzer/UnionTypeAnalyzer.php @@ -22,113 +22,113 @@ use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use Traversable; final class UnionTypeAnalyzer { - public function analyseForNullableAndIterable(\PHPStan\Type\UnionType $unionType) : ?\Rector\PHPStanStaticTypeMapper\ValueObject\UnionTypeAnalysis + public function analyseForNullableAndIterable(UnionType $unionType) : ?UnionTypeAnalysis { $isNullableType = \false; $hasIterable = \false; $hasArray = \false; foreach ($unionType->getTypes() as $unionedType) { - if ($unionedType instanceof \PHPStan\Type\IterableType) { + if ($unionedType instanceof IterableType) { $hasIterable = \true; continue; } - if ($unionedType instanceof \PHPStan\Type\ArrayType) { + if ($unionedType instanceof ArrayType) { $hasArray = \true; continue; } - if ($unionedType instanceof \PHPStan\Type\NullType) { + if ($unionedType instanceof NullType) { $isNullableType = \true; continue; } - if ($unionedType instanceof \PHPStan\Type\ObjectType && $unionedType->getClassName() === \Traversable::class) { + if ($unionedType instanceof ObjectType && $unionedType->getClassName() === Traversable::class) { $hasIterable = \true; continue; } return null; } - return new \Rector\PHPStanStaticTypeMapper\ValueObject\UnionTypeAnalysis($isNullableType, $hasIterable, $hasArray); + return new UnionTypeAnalysis($isNullableType, $hasIterable, $hasArray); } /** * @return TypeWithClassName[] */ - public function matchExclusiveTypesWithClassNames(\PHPStan\Type\UnionType $unionType) : array + public function matchExclusiveTypesWithClassNames(UnionType $unionType) : array { $typesWithClassNames = []; foreach ($unionType->getTypes() as $unionedType) { - if (!$unionedType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$unionedType instanceof TypeWithClassName) { return []; } $typesWithClassNames[] = $unionedType; } return $typesWithClassNames; } - public function hasObjectWithoutClassType(\PHPStan\Type\UnionType $unionType) : bool + public function hasObjectWithoutClassType(UnionType $unionType) : bool { $types = $unionType->getTypes(); foreach ($types as $type) { - if ($type instanceof \PHPStan\Type\ObjectWithoutClassType) { + if ($type instanceof ObjectWithoutClassType) { return \true; } } return \false; } - public function hasObjectWithoutClassTypeWithOnlyFullyQualifiedObjectType(\PHPStan\Type\UnionType $unionType) : bool + public function hasObjectWithoutClassTypeWithOnlyFullyQualifiedObjectType(UnionType $unionType) : bool { $types = $unionType->getTypes(); foreach ($types as $type) { - if ($type instanceof \PHPStan\Type\ObjectWithoutClassType) { + if ($type instanceof ObjectWithoutClassType) { continue; } - if (!$type instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) { + if (!$type instanceof FullyQualifiedObjectType) { return \false; } } return \true; } - public function isScalar(\PHPStan\Type\UnionType $unionType) : bool + public function isScalar(UnionType $unionType) : bool { $types = $unionType->getTypes(); if (\count($types) !== 4) { return \false; } foreach ($types as $type) { - if ($type instanceof \PHPStan\Type\StringType && !$type instanceof \PHPStan\Type\Constant\ConstantStringType) { + if ($type instanceof StringType && !$type instanceof ConstantStringType) { continue; } - if ($type instanceof \PHPStan\Type\FloatType) { + if ($type instanceof FloatType) { continue; } - if ($type instanceof \PHPStan\Type\IntegerType) { + if ($type instanceof IntegerType) { continue; } - if ($type instanceof \PHPStan\Type\BooleanType) { + if ($type instanceof BooleanType) { continue; } return \false; } return \true; } - public function isNullable(\PHPStan\Type\UnionType $unionType, bool $checkTwoTypes = \false) : bool + public function isNullable(UnionType $unionType, bool $checkTwoTypes = \false) : bool { $types = $unionType->getTypes(); if ($checkTwoTypes && \count($types) > 2) { return \false; } foreach ($types as $type) { - if ($type instanceof \PHPStan\Type\NullType) { + if ($type instanceof NullType) { return \true; } } return \false; } - public function mapGenericToClassStringType(\PHPStan\Type\UnionType $unionType) : \PHPStan\Type\UnionType + public function mapGenericToClassStringType(UnionType $unionType) : UnionType { $types = $unionType->getTypes(); foreach ($types as $key => $type) { - if ($type instanceof \PHPStan\Type\Generic\GenericClassStringType) { - $types[$key] = new \PHPStan\Type\ClassStringType(); + if ($type instanceof GenericClassStringType) { + $types[$key] = new ClassStringType(); } } - return new \PHPStan\Type\UnionType($types); + return new UnionType($types); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeAnalyzer/UnionTypeCommonTypeNarrower.php b/packages/PHPStanStaticTypeMapper/TypeAnalyzer/UnionTypeCommonTypeNarrower.php index f9ae55c3446..8863c7ebea8 100644 --- a/packages/PHPStanStaticTypeMapper/TypeAnalyzer/UnionTypeCommonTypeNarrower.php +++ b/packages/PHPStanStaticTypeMapper/TypeAnalyzer/UnionTypeCommonTypeNarrower.php @@ -25,7 +25,7 @@ final class UnionTypeCommonTypeNarrower * * @var array|class-string<\PHPStan\PhpDocParser\Ast\Node>|class-string>> */ - private const PRIORITY_TYPES = [\PhpParser\Node\Stmt\ClassLike::class => [\PhpParser\Node\Stmt\ClassLike::class], \PhpParser\Node\FunctionLike::class => [\PhpParser\Node\FunctionLike::class], \PhpParser\Node\Expr\BinaryOp::class => [\PhpParser\Node\Expr\BinaryOp::class, \PhpParser\Node\Expr::class], \PhpParser\Node\Expr::class => [\PhpParser\Node::class, \PhpParser\Node\Expr::class], \PhpParser\Node\Stmt::class => [\PhpParser\Node::class, \PhpParser\Node\Stmt::class], \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode::class => [\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode::class, \PHPStan\PhpDocParser\Ast\Node::class], \PhpParser\Node::class => [\PhpParser\Node::class], \Rector\Core\Contract\Rector\RectorInterface::class => [\Rector\Core\Contract\Rector\RectorInterface::class]]; + private const PRIORITY_TYPES = [ClassLike::class => [ClassLike::class], FunctionLike::class => [FunctionLike::class], BinaryOp::class => [BinaryOp::class, Expr::class], Expr::class => [Node::class, Expr::class], Stmt::class => [Node::class, Stmt::class], PhpDocTagValueNode::class => [PhpDocTagValueNode::class, \PHPStan\PhpDocParser\Ast\Node::class], Node::class => [Node::class], RectorInterface::class => [RectorInterface::class]]; /** * @readonly * @var \Rector\NodeTypeResolver\NodeTypeCorrector\GenericClassStringTypeCorrector @@ -36,41 +36,41 @@ final class UnionTypeCommonTypeNarrower * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\NodeTypeResolver\NodeTypeCorrector\GenericClassStringTypeCorrector $genericClassStringTypeCorrector, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(GenericClassStringTypeCorrector $genericClassStringTypeCorrector, ReflectionProvider $reflectionProvider) { $this->genericClassStringTypeCorrector = $genericClassStringTypeCorrector; $this->reflectionProvider = $reflectionProvider; } - public function narrowToSharedObjectType(\PHPStan\Type\UnionType $unionType) : ?\PHPStan\Type\ObjectType + public function narrowToSharedObjectType(UnionType $unionType) : ?ObjectType { $sharedTypes = $this->narrowToSharedTypes($unionType); if ($sharedTypes !== []) { foreach (self::PRIORITY_TYPES as $winningType => $groupTypes) { $intersectedGroupTypes = \array_intersect($groupTypes, $sharedTypes); if ($intersectedGroupTypes === $groupTypes) { - return new \PHPStan\Type\ObjectType($winningType); + return new ObjectType($winningType); } } $firstSharedType = $sharedTypes[0]; - return new \PHPStan\Type\ObjectType($firstSharedType); + return new ObjectType($firstSharedType); } return null; } /** * @return \PHPStan\Type\UnionType|\PHPStan\Type\Generic\GenericClassStringType */ - public function narrowToGenericClassStringType(\PHPStan\Type\UnionType $unionType) + public function narrowToGenericClassStringType(UnionType $unionType) { $availableTypes = []; foreach ($unionType->getTypes() as $unionedType) { - if ($unionedType instanceof \PHPStan\Type\Constant\ConstantStringType) { + if ($unionedType instanceof ConstantStringType) { $unionedType = $this->genericClassStringTypeCorrector->correct($unionedType); } - if (!$unionedType instanceof \PHPStan\Type\Generic\GenericClassStringType) { + if (!$unionedType instanceof GenericClassStringType) { return $unionType; } $genericClassStrings = []; - if ($unionedType->getGenericType() instanceof \PHPStan\Type\ObjectType) { + if ($unionedType->getGenericType() instanceof ObjectType) { $parentClassReflections = $this->resolveClassParentClassesAndInterfaces($unionedType->getGenericType()); foreach ($parentClassReflections as $parentClassReflection) { $genericClassStrings[] = $parentClassReflection->getName(); @@ -79,7 +79,7 @@ final class UnionTypeCommonTypeNarrower $availableTypes[] = $genericClassStrings; } $genericClassStringType = $this->createGenericClassStringType($availableTypes); - if ($genericClassStringType instanceof \PHPStan\Type\Generic\GenericClassStringType) { + if ($genericClassStringType instanceof GenericClassStringType) { return $genericClassStringType; } return $unionType; @@ -87,11 +87,11 @@ final class UnionTypeCommonTypeNarrower /** * @return string[] */ - private function narrowToSharedTypes(\PHPStan\Type\UnionType $unionType) : array + private function narrowToSharedTypes(UnionType $unionType) : array { $availableTypes = []; foreach ($unionType->getTypes() as $unionedType) { - if (!$unionedType instanceof \PHPStan\Type\ObjectType) { + if (!$unionedType instanceof ObjectType) { return []; } $typeClassReflections = $this->resolveClassParentClassesAndInterfaces($unionedType); @@ -109,7 +109,7 @@ final class UnionTypeCommonTypeNarrower /** * @return ClassReflection[] */ - private function resolveClassParentClassesAndInterfaces(\PHPStan\Type\ObjectType $objectType) : array + private function resolveClassParentClassesAndInterfaces(ObjectType $objectType) : array { if (!$this->reflectionProvider->hasClass($objectType->getClassName())) { return []; @@ -137,18 +137,18 @@ final class UnionTypeCommonTypeNarrower /** * @param string[][] $availableTypes */ - private function createGenericClassStringType(array $availableTypes) : ?\PHPStan\Type\Generic\GenericClassStringType + private function createGenericClassStringType(array $availableTypes) : ?GenericClassStringType { $sharedTypes = $this->narrowAvailableTypes($availableTypes); if ($sharedTypes !== []) { foreach (self::PRIORITY_TYPES as $winningType => $groupTypes) { $intersectedGroupTypes = \array_intersect($groupTypes, $sharedTypes); if ($intersectedGroupTypes === $groupTypes) { - return new \PHPStan\Type\Generic\GenericClassStringType(new \PHPStan\Type\ObjectType($winningType)); + return new GenericClassStringType(new ObjectType($winningType)); } } $firstSharedType = $sharedTypes[0]; - return new \PHPStan\Type\Generic\GenericClassStringType(new \PHPStan\Type\ObjectType($firstSharedType)); + return new GenericClassStringType(new ObjectType($firstSharedType)); } return null; } @@ -158,7 +158,7 @@ final class UnionTypeCommonTypeNarrower */ private function filterOutNativeClassReflections(array $classReflections) : array { - return \array_filter($classReflections, function (\PHPStan\Reflection\ClassReflection $classReflection) : bool { + return \array_filter($classReflections, function (ClassReflection $classReflection) : bool { return !$classReflection->isBuiltin(); }); } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/AccessoryNonEmptyStringTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/AccessoryNonEmptyStringTypeMapper.php index 856767fe898..d4c437a2c44 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/AccessoryNonEmptyStringTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/AccessoryNonEmptyStringTypeMapper.php @@ -13,27 +13,27 @@ use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface; /** * @implements TypeMapperInterface */ -final class AccessoryNonEmptyStringTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class AccessoryNonEmptyStringTypeMapper implements TypeMapperInterface { /** * @return class-string */ public function getNodeClass() : string { - return \PHPStan\Type\Accessory\AccessoryNonEmptyStringType::class; + return AccessoryNonEmptyStringType::class; } /** * @param AccessoryNonEmptyStringType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('string'); + return new IdentifierTypeNode('string'); } /** * @param AccessoryNonEmptyStringType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - return new \PhpParser\Node\Name('string'); + return new Name('string'); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/AccessoryNumericStringTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/AccessoryNumericStringTypeMapper.php index 9bbcfbe6238..2503d2fef67 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/AccessoryNumericStringTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/AccessoryNumericStringTypeMapper.php @@ -13,27 +13,27 @@ use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface; /** * @implements TypeMapperInterface */ -final class AccessoryNumericStringTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class AccessoryNumericStringTypeMapper implements TypeMapperInterface { /** * @return class-string */ public function getNodeClass() : string { - return \PHPStan\Type\Accessory\AccessoryNumericStringType::class; + return AccessoryNumericStringType::class; } /** * @param AccessoryNumericStringType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('string'); + return new IdentifierTypeNode('string'); } /** * @param AccessoryNumericStringType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - return new \PhpParser\Node\Name('string'); + return new Name('string'); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/ArrayShapeTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/ArrayShapeTypeMapper.php index 61a0ff09a09..f3c5d90a816 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/ArrayShapeTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/ArrayShapeTypeMapper.php @@ -26,7 +26,7 @@ final class ArrayShapeTypeMapper * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper $phpStanStaticTypeMapper, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(PHPStanStaticTypeMapper $phpStanStaticTypeMapper, ReflectionProvider $reflectionProvider) { $this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper; $this->reflectionProvider = $reflectionProvider; @@ -34,27 +34,27 @@ final class ArrayShapeTypeMapper /** * @return \PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode|\PHPStan\Type\ArrayType|null */ - public function mapConstantArrayType(\PHPStan\Type\Constant\ConstantArrayType $constantArrayType) + public function mapConstantArrayType(ConstantArrayType $constantArrayType) { // empty array - if ($constantArrayType->getKeyType() instanceof \PHPStan\Type\NeverType) { - return new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); + if ($constantArrayType->getKeyType() instanceof NeverType) { + return new ArrayType(new MixedType(), new MixedType()); } $arrayShapeItemNodes = []; foreach ($constantArrayType->getKeyTypes() as $index => $keyType) { // not real array shape - if (!$keyType instanceof \PHPStan\Type\Constant\ConstantStringType) { + if (!$keyType instanceof ConstantStringType) { return null; } $keyValue = $keyType->getValue(); if ($this->reflectionProvider->hasClass($keyValue)) { return null; } - $keyDocTypeNode = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($keyValue); + $keyDocTypeNode = new IdentifierTypeNode($keyValue); $valueType = $constantArrayType->getValueTypes()[$index]; - $valueDocTypeNode = $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($valueType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN); - $arrayShapeItemNodes[] = new \PHPStan\PhpDocParser\Ast\Type\ArrayShapeItemNode($keyDocTypeNode, $constantArrayType->isOptionalKey($index), $valueDocTypeNode); + $valueDocTypeNode = $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($valueType, TypeKind::RETURN); + $arrayShapeItemNodes[] = new ArrayShapeItemNode($keyDocTypeNode, $constantArrayType->isOptionalKey($index), $valueDocTypeNode); } - return new \PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode($arrayShapeItemNodes); + return new ArrayShapeNode($arrayShapeItemNodes); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapper.php index 6378c6e045d..b704a0f6133 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapper.php @@ -34,7 +34,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; * * @implements TypeMapperInterface */ -final class ArrayTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class ArrayTypeMapper implements TypeMapperInterface { /** * @var string @@ -68,7 +68,7 @@ final class ArrayTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\ /** * @required */ - public function autowire(\Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper $phpStanStaticTypeMapper, \Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeCommonTypeNarrower $unionTypeCommonTypeNarrower, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\TypeDeclaration\TypeAnalyzer\GenericClassStringTypeNormalizer $genericClassStringTypeNormalizer, \Rector\TypeDeclaration\NodeTypeAnalyzer\DetailedTypeAnalyzer $detailedTypeAnalyzer, \Rector\PHPStanStaticTypeMapper\TypeMapper\ArrayShapeTypeMapper $arrayShapeTypeMapper) : void + public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper, UnionTypeCommonTypeNarrower $unionTypeCommonTypeNarrower, ReflectionProvider $reflectionProvider, GenericClassStringTypeNormalizer $genericClassStringTypeNormalizer, DetailedTypeAnalyzer $detailedTypeAnalyzer, \Rector\PHPStanStaticTypeMapper\TypeMapper\ArrayShapeTypeMapper $arrayShapeTypeMapper) : void { $this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper; $this->unionTypeCommonTypeNarrower = $unionTypeCommonTypeNarrower; @@ -82,48 +82,48 @@ final class ArrayTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\ */ public function getNodeClass() : string { - return \PHPStan\Type\ArrayType::class; + return ArrayType::class; } /** * @param TypeKind::* $typeKind * @param ArrayType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { $itemType = $type->getItemType(); - if ($itemType instanceof \PHPStan\Type\UnionType && !$type instanceof \PHPStan\Type\Constant\ConstantArrayType) { + if ($itemType instanceof UnionType && !$type instanceof ConstantArrayType) { return $this->createArrayTypeNodeFromUnionType($itemType, $typeKind); } - if ($type instanceof \PHPStan\Type\Constant\ConstantArrayType && $typeKind === \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN) { + if ($type instanceof ConstantArrayType && $typeKind === TypeKind::RETURN) { $arrayShapeNode = $this->arrayShapeTypeMapper->mapConstantArrayType($type); - if ($arrayShapeNode instanceof \PHPStan\PhpDocParser\Ast\Type\TypeNode) { + if ($arrayShapeNode instanceof TypeNode) { return $arrayShapeNode; } } - if ($itemType instanceof \PHPStan\Type\ArrayType && $this->isGenericArrayCandidate($itemType)) { + if ($itemType instanceof ArrayType && $this->isGenericArrayCandidate($itemType)) { return $this->createGenericArrayType($type, $typeKind, \true); } if ($this->isGenericArrayCandidate($type)) { return $this->createGenericArrayType($type, $typeKind, \true); } $narrowedTypeNode = $this->narrowConstantArrayTypeOfUnionType($type, $itemType, $typeKind); - if ($narrowedTypeNode instanceof \PHPStan\PhpDocParser\Ast\Type\TypeNode) { + if ($narrowedTypeNode instanceof TypeNode) { return $narrowedTypeNode; } $itemTypeNode = $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($itemType, $typeKind); - return new \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode($itemTypeNode); + return new SpacingAwareArrayTypeNode($itemTypeNode); } /** * @param ArrayType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - return new \PhpParser\Node\Name('array'); + return new Name('array'); } /** * @param TypeKind::* $typeKind */ - private function createArrayTypeNodeFromUnionType(\PHPStan\Type\UnionType $unionType, string $typeKind) : \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode + private function createArrayTypeNodeFromUnionType(UnionType $unionType, string $typeKind) : SpacingAwareArrayTypeNode { $unionedArrayType = []; foreach ($unionType->getTypes() as $unionedType) { @@ -131,15 +131,15 @@ final class ArrayTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\ $unionedArrayType[(string) $typeNode] = $typeNode; } if (\count($unionedArrayType) > 1) { - return new \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode(new \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode($unionedArrayType)); + return new SpacingAwareArrayTypeNode(new BracketsAwareUnionTypeNode($unionedArrayType)); } /** @var TypeNode $arrayType */ $arrayType = \array_shift($unionedArrayType); - return new \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode($arrayType); + return new SpacingAwareArrayTypeNode($arrayType); } - private function isGenericArrayCandidate(\PHPStan\Type\ArrayType $arrayType) : bool + private function isGenericArrayCandidate(ArrayType $arrayType) : bool { - if ($arrayType->getKeyType() instanceof \PHPStan\Type\MixedType) { + if ($arrayType->getKeyType() instanceof MixedType) { return \false; } if ($this->isClassStringArrayType($arrayType)) { @@ -149,16 +149,16 @@ final class ArrayTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\ if ($this->isIntegerKeyAndNonNestedArray($arrayType)) { return \false; } - if ($arrayType->getKeyType() instanceof \PHPStan\Type\NeverType) { + if ($arrayType->getKeyType() instanceof NeverType) { return \false; } // make sure the integer key type is not natural/implicit array int keys $keysArrayType = $arrayType->getKeysArray(); - if (!$keysArrayType instanceof \PHPStan\Type\Constant\ConstantArrayType) { + if (!$keysArrayType instanceof ConstantArrayType) { return \true; } foreach ($keysArrayType->getValueTypes() as $key => $keyType) { - if (!$keyType instanceof \PHPStan\Type\Constant\ConstantIntegerType) { + if (!$keyType instanceof ConstantIntegerType) { return \true; } if ($key !== $keyType->getValue()) { @@ -170,19 +170,19 @@ final class ArrayTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\ /** * @param TypeKind::* $typeKind */ - private function createGenericArrayType(\PHPStan\Type\ArrayType $arrayType, string $typeKind, bool $withKey = \false) : \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode + private function createGenericArrayType(ArrayType $arrayType, string $typeKind, bool $withKey = \false) : GenericTypeNode { $itemType = $arrayType->getItemType(); $itemTypeNode = $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($itemType, $typeKind); - $identifierTypeNode = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('array'); + $identifierTypeNode = new IdentifierTypeNode('array'); // is class-string[] list only if ($this->isClassStringArrayType($arrayType)) { $withKey = \false; } if ($withKey) { $keyTypeNode = $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($arrayType->getKeyType(), $typeKind); - if ($itemTypeNode instanceof \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode && $this->isPairClassTooDetailed($itemType)) { - $genericTypes = [$keyTypeNode, $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode(new \PHPStan\Type\ClassStringType(), $typeKind)]; + if ($itemTypeNode instanceof BracketsAwareUnionTypeNode && $this->isPairClassTooDetailed($itemType)) { + $genericTypes = [$keyTypeNode, $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode(new ClassStringType(), $typeKind)]; } else { $genericTypes = [$keyTypeNode, $itemTypeNode]; } @@ -195,11 +195,11 @@ final class ArrayTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\ $genericType->setAttribute(self::HAS_GENERIC_TYPE_PARENT, $withKey); } $identifierTypeNode->setAttribute(self::HAS_GENERIC_TYPE_PARENT, $withKey); - return new \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode($identifierTypeNode, $genericTypes); + return new GenericTypeNode($identifierTypeNode, $genericTypes); } - private function isPairClassTooDetailed(\PHPStan\Type\Type $itemType) : bool + private function isPairClassTooDetailed(Type $itemType) : bool { - if (!$itemType instanceof \PHPStan\Type\UnionType) { + if (!$itemType instanceof UnionType) { return \false; } if (!$this->genericClassStringTypeNormalizer->isAllGenericClassStringType($itemType)) { @@ -207,26 +207,26 @@ final class ArrayTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\ } return $this->detailedTypeAnalyzer->isTooDetailed($itemType); } - private function isIntegerKeyAndNonNestedArray(\PHPStan\Type\ArrayType $arrayType) : bool + private function isIntegerKeyAndNonNestedArray(ArrayType $arrayType) : bool { - if (!$arrayType->getKeyType() instanceof \PHPStan\Type\IntegerType) { + if (!$arrayType->getKeyType() instanceof IntegerType) { return \false; } - return !$arrayType->getItemType() instanceof \PHPStan\Type\ArrayType; + return !$arrayType->getItemType() instanceof ArrayType; } /** * @param TypeKind::* $typeKind */ - private function narrowConstantArrayTypeOfUnionType(\PHPStan\Type\ArrayType $arrayType, \PHPStan\Type\Type $itemType, string $typeKind) : ?\PHPStan\PhpDocParser\Ast\Type\TypeNode + private function narrowConstantArrayTypeOfUnionType(ArrayType $arrayType, Type $itemType, string $typeKind) : ?TypeNode { - if ($arrayType instanceof \PHPStan\Type\Constant\ConstantArrayType && $itemType instanceof \PHPStan\Type\UnionType) { + if ($arrayType instanceof ConstantArrayType && $itemType instanceof UnionType) { $narrowedItemType = $this->unionTypeCommonTypeNarrower->narrowToSharedObjectType($itemType); - if ($narrowedItemType instanceof \PHPStan\Type\ObjectType) { + if ($narrowedItemType instanceof ObjectType) { $itemTypeNode = $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($narrowedItemType, $typeKind); - return new \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode($itemTypeNode); + return new SpacingAwareArrayTypeNode($itemTypeNode); } $narrowedItemType = $this->unionTypeCommonTypeNarrower->narrowToGenericClassStringType($itemType); - if ($narrowedItemType instanceof \PHPStan\Type\Generic\GenericClassStringType) { + if ($narrowedItemType instanceof GenericClassStringType) { return $this->createTypeNodeFromGenericClassStringType($narrowedItemType, $typeKind); } } @@ -236,22 +236,22 @@ final class ArrayTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\ * @param TypeKind::* $typeKind * @return \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode|\PHPStan\PhpDocParser\Ast\Type\GenericTypeNode */ - private function createTypeNodeFromGenericClassStringType(\PHPStan\Type\Generic\GenericClassStringType $genericClassStringType, string $typeKind) + private function createTypeNodeFromGenericClassStringType(GenericClassStringType $genericClassStringType, string $typeKind) { $genericType = $genericClassStringType->getGenericType(); - if ($genericType instanceof \PHPStan\Type\ObjectType && !$this->reflectionProvider->hasClass($genericType->getClassName())) { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($genericType->getClassName()); + if ($genericType instanceof ObjectType && !$this->reflectionProvider->hasClass($genericType->getClassName())) { + return new IdentifierTypeNode($genericType->getClassName()); } $itemTypeNode = $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($genericClassStringType, $typeKind); - return new \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode(new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('array'), [$itemTypeNode]); + return new GenericTypeNode(new IdentifierTypeNode('array'), [$itemTypeNode]); } - private function isClassStringArrayType(\PHPStan\Type\ArrayType $arrayType) : bool + private function isClassStringArrayType(ArrayType $arrayType) : bool { - if ($arrayType->getKeyType() instanceof \PHPStan\Type\MixedType) { - return $arrayType->getItemType() instanceof \PHPStan\Type\Generic\GenericClassStringType; + if ($arrayType->getKeyType() instanceof MixedType) { + return $arrayType->getItemType() instanceof GenericClassStringType; } - if ($arrayType->getKeyType() instanceof \PHPStan\Type\Constant\ConstantIntegerType) { - return $arrayType->getItemType() instanceof \PHPStan\Type\Generic\GenericClassStringType; + if ($arrayType->getKeyType() instanceof ConstantIntegerType) { + return $arrayType->getItemType() instanceof GenericClassStringType; } return \false; } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/BooleanTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/BooleanTypeMapper.php index 933ad676208..8144cda79ae 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/BooleanTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/BooleanTypeMapper.php @@ -16,14 +16,14 @@ use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface; /** * @implements TypeMapperInterface */ -final class BooleanTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class BooleanTypeMapper implements TypeMapperInterface { /** * @readonly * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PhpVersionProvider $phpVersionProvider) { $this->phpVersionProvider = $phpVersionProvider; } @@ -32,43 +32,43 @@ final class BooleanTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contrac */ public function getNodeClass() : string { - return \PHPStan\Type\BooleanType::class; + return BooleanType::class; } /** * @param BooleanType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { if ($this->isFalseBooleanTypeWithUnion($type)) { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('false'); + return new IdentifierTypeNode('false'); } - if ($type instanceof \PHPStan\Type\Constant\ConstantBooleanType) { + if ($type instanceof ConstantBooleanType) { // cannot be parent of union - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('true'); + return new IdentifierTypeNode('true'); } - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('bool'); + return new IdentifierTypeNode('bool'); } /** * @param BooleanType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::SCALAR_TYPES)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::SCALAR_TYPES)) { return null; } if ($this->isFalseBooleanTypeWithUnion($type)) { - return new \PhpParser\Node\Name('false'); + return new Name('false'); } - return new \PhpParser\Node\Name('bool'); + return new Name('bool'); } - private function isFalseBooleanTypeWithUnion(\PHPStan\Type\Type $type) : bool + private function isFalseBooleanTypeWithUnion(Type $type) : bool { - if (!$type instanceof \PHPStan\Type\Constant\ConstantBooleanType) { + if (!$type instanceof ConstantBooleanType) { return \false; } if ($type->getValue()) { return \false; } - return $this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::UNION_TYPES); + return $this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::UNION_TYPES); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/CallableTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/CallableTypeMapper.php index da957ab3c2c..ae66ab1c10a 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/CallableTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/CallableTypeMapper.php @@ -18,7 +18,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements TypeMapperInterface */ -final class CallableTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class CallableTypeMapper implements TypeMapperInterface { /** * @var \Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper @@ -27,7 +27,7 @@ final class CallableTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contra /** * @required */ - public function autowire(\Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper $phpStanStaticTypeMapper) : void + public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper) : void { $this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper; } @@ -36,26 +36,26 @@ final class CallableTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contra */ public function getNodeClass() : string { - return \PHPStan\Type\CallableType::class; + return CallableType::class; } /** * @param TypeKind::* $typeKind * @param CallableType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { $returnTypeNode = $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($type->getReturnType(), $typeKind); - return new \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode(new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('callable'), [], $returnTypeNode); + return new SpacingAwareCallableTypeNode(new IdentifierTypeNode('callable'), [], $returnTypeNode); } /** * @param TypeKind::* $typeKind * @param CallableType|ClosureType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - if ($typeKind === \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY) { + if ($typeKind === TypeKind::PROPERTY) { return null; } - return new \PhpParser\Node\Name('callable'); + return new Name('callable'); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/ClassStringTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/ClassStringTypeMapper.php index c83bc475de9..05783b2f481 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/ClassStringTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/ClassStringTypeMapper.php @@ -19,7 +19,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements TypeMapperInterface */ -final class ClassStringTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class ClassStringTypeMapper implements TypeMapperInterface { /** * @var \Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper @@ -30,47 +30,47 @@ final class ClassStringTypeMapper implements \Rector\PHPStanStaticTypeMapper\Con */ public function getNodeClass() : string { - return \PHPStan\Type\ClassStringType::class; + return ClassStringType::class; } /** * @param ClassStringType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - $attributeAwareIdentifierTypeNode = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('class-string'); - if ($type instanceof \PHPStan\Type\Generic\GenericClassStringType) { + $attributeAwareIdentifierTypeNode = new IdentifierTypeNode('class-string'); + if ($type instanceof GenericClassStringType) { $genericType = $type->getGenericType(); - if ($genericType instanceof \PHPStan\Type\ObjectType) { + if ($genericType instanceof ObjectType) { $className = $genericType->getClassName(); $className = $this->normalizeType($className); - $genericType = new \PHPStan\Type\ObjectType($className); + $genericType = new ObjectType($className); } $genericTypeNode = $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($genericType, $typeKind); - return new \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode($attributeAwareIdentifierTypeNode, [$genericTypeNode]); + return new GenericTypeNode($attributeAwareIdentifierTypeNode, [$genericTypeNode]); } return $attributeAwareIdentifierTypeNode; } /** * @param ClassStringType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - return new \PhpParser\Node\Name('string'); + return new Name('string'); } /** * @required */ - public function autowire(\Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper $phpStanStaticTypeMapper) : void + public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper) : void { $this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper; } private function normalizeType(string $classType) : string { - if (\is_a($classType, \PhpParser\Node\Expr::class, \true)) { - return \PhpParser\Node\Expr::class; + if (\is_a($classType, Expr::class, \true)) { + return Expr::class; } - if (\is_a($classType, \PhpParser\Node::class, \true)) { - return \PhpParser\Node::class; + if (\is_a($classType, Node::class, \true)) { + return Node::class; } return $classType; } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/ClosureTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/ClosureTypeMapper.php index 5c5cf5bcaf5..8091a0c7c2b 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/ClosureTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/ClosureTypeMapper.php @@ -17,7 +17,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements TypeMapperInterface */ -final class ClosureTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class ClosureTypeMapper implements TypeMapperInterface { /** * @var \Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper @@ -28,32 +28,32 @@ final class ClosureTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contrac */ public function getNodeClass() : string { - return \PHPStan\Type\ClosureType::class; + return ClosureType::class; } /** * @param ClosureType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - $identifierTypeNode = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($type->getClassName()); + $identifierTypeNode = new IdentifierTypeNode($type->getClassName()); $returnDocTypeNode = $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($type->getReturnType(), $typeKind); - return new \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode($identifierTypeNode, [], $returnDocTypeNode); + return new SpacingAwareCallableTypeNode($identifierTypeNode, [], $returnDocTypeNode); } /** * @param TypeKind::* $typeKind * @param ClosureType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - if ($typeKind === \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY) { + if ($typeKind === TypeKind::PROPERTY) { return null; } - return new \PhpParser\Node\Name\FullyQualified('Closure'); + return new FullyQualified('Closure'); } /** * @required */ - public function autowire(\Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper $phpStanStaticTypeMapper) : void + public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper) : void { $this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper; } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/FloatTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/FloatTypeMapper.php index 6a0821161e0..4e468222357 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/FloatTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/FloatTypeMapper.php @@ -15,14 +15,14 @@ use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface; /** * @implements TypeMapperInterface */ -final class FloatTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class FloatTypeMapper implements TypeMapperInterface { /** * @readonly * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PhpVersionProvider $phpVersionProvider) { $this->phpVersionProvider = $phpVersionProvider; } @@ -31,23 +31,23 @@ final class FloatTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\ */ public function getNodeClass() : string { - return \PHPStan\Type\FloatType::class; + return FloatType::class; } /** * @param FloatType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('float'); + return new IdentifierTypeNode('float'); } /** * @param FloatType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::SCALAR_TYPES)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::SCALAR_TYPES)) { return null; } - return new \PhpParser\Node\Name('float'); + return new Name('float'); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/HasMethodTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/HasMethodTypeMapper.php index 77b284ac9fd..ed2aa5a3d35 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/HasMethodTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/HasMethodTypeMapper.php @@ -12,7 +12,7 @@ use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface; /** * @implements TypeMapperInterface */ -final class HasMethodTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class HasMethodTypeMapper implements TypeMapperInterface { /** * @readonly @@ -28,19 +28,19 @@ final class HasMethodTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contr */ public function getNodeClass() : string { - return \PHPStan\Type\Accessory\HasMethodType::class; + return HasMethodType::class; } /** * @param HasMethodType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('object'); + return new IdentifierTypeNode('object'); } /** * @param HasMethodType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { return $this->objectWithoutClassTypeMapper->mapToPhpParserNode($type, $typeKind); } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/HasOffsetTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/HasOffsetTypeMapper.php index e41a404ea38..e6812917457 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/HasOffsetTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/HasOffsetTypeMapper.php @@ -14,27 +14,27 @@ use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface; /** * @implements TypeMapperInterface */ -final class HasOffsetTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class HasOffsetTypeMapper implements TypeMapperInterface { /** * @return class-string */ public function getNodeClass() : string { - return \PHPStan\Type\Accessory\HasOffsetType::class; + return HasOffsetType::class; } /** * @param HasOffsetType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - return new \PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode(new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('mixed')); + return new ArrayTypeNode(new IdentifierTypeNode('mixed')); } /** * @param HasOffsetType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - return new \PhpParser\Node\Name('array'); + return new Name('array'); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/HasPropertyTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/HasPropertyTypeMapper.php index 84718fecf50..8b53ebc92b0 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/HasPropertyTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/HasPropertyTypeMapper.php @@ -12,7 +12,7 @@ use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface; /** * @implements TypeMapperInterface */ -final class HasPropertyTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class HasPropertyTypeMapper implements TypeMapperInterface { /** * @readonly @@ -28,19 +28,19 @@ final class HasPropertyTypeMapper implements \Rector\PHPStanStaticTypeMapper\Con */ public function getNodeClass() : string { - return \PHPStan\Type\Accessory\HasPropertyType::class; + return HasPropertyType::class; } /** * @param HasPropertyType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('object'); + return new IdentifierTypeNode('object'); } /** * @param HasPropertyType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { return $this->objectWithoutClassTypeMapper->mapToPhpParserNode($type, $typeKind); } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/IntegerTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/IntegerTypeMapper.php index 60794e9a2df..41ebe0c6bef 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/IntegerTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/IntegerTypeMapper.php @@ -15,14 +15,14 @@ use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface; /** * @implements TypeMapperInterface */ -final class IntegerTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class IntegerTypeMapper implements TypeMapperInterface { /** * @readonly * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PhpVersionProvider $phpVersionProvider) { $this->phpVersionProvider = $phpVersionProvider; } @@ -31,23 +31,23 @@ final class IntegerTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contrac */ public function getNodeClass() : string { - return \PHPStan\Type\IntegerType::class; + return IntegerType::class; } /** * @param IntegerType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('int'); + return new IdentifierTypeNode('int'); } /** * @param IntegerType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::SCALAR_TYPES)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::SCALAR_TYPES)) { return null; } - return new \PhpParser\Node\Name('int'); + return new Name('int'); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/IntersectionTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/IntersectionTypeMapper.php index dd44fecc7ad..0d57a6df94d 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/IntersectionTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/IntersectionTypeMapper.php @@ -19,7 +19,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements TypeMapperInterface */ -final class IntersectionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class IntersectionTypeMapper implements TypeMapperInterface { /** * @var string @@ -34,14 +34,14 @@ final class IntersectionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Co * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PhpVersionProvider $phpVersionProvider) { $this->phpVersionProvider = $phpVersionProvider; } /** * @required */ - public function autowire(\Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper $phpStanStaticTypeMapper) : void + public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper) : void { $this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper; } @@ -50,12 +50,12 @@ final class IntersectionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Co */ public function getNodeClass() : string { - return \PHPStan\Type\IntersectionType::class; + return IntersectionType::class; } /** * @param IntersectionType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { $intersectionTypesNodes = []; foreach ($type->getTypes() as $intersectionedType) { @@ -65,24 +65,24 @@ final class IntersectionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Co if (\count($intersectionTypesNodes) === 1) { return $intersectionTypesNodes[0]; } - return new \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareIntersectionTypeNode($intersectionTypesNodes); + return new BracketsAwareIntersectionTypeNode($intersectionTypesNodes); } /** * @param IntersectionType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::INTERSECTION_TYPES)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::INTERSECTION_TYPES)) { return null; } $intersectionedTypeNodes = []; foreach ($type->getTypes() as $intersectionedType) { $resolvedType = $this->phpStanStaticTypeMapper->mapToPhpParserNode($intersectionedType, $typeKind); - if ($intersectionedType instanceof \PHPStan\Type\Generic\GenericClassStringType) { + if ($intersectionedType instanceof GenericClassStringType) { $resolvedTypeName = self::STRING; - $resolvedType = new \PhpParser\Node\Name(self::STRING); - } elseif (!$resolvedType instanceof \PhpParser\Node\Name) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $resolvedType = new Name(self::STRING); + } elseif (!$resolvedType instanceof Name) { + throw new ShouldNotHappenException(); } else { $resolvedTypeName = (string) $resolvedType; } @@ -91,6 +91,6 @@ final class IntersectionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Co } $intersectionedTypeNodes[] = $resolvedType; } - return new \PhpParser\Node\IntersectionType($intersectionedTypeNodes); + return new Node\IntersectionType($intersectionedTypeNodes); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/IterableTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/IterableTypeMapper.php index 10206a57576..37df48d8f82 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/IterableTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/IterableTypeMapper.php @@ -18,7 +18,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements TypeMapperInterface */ -final class IterableTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class IterableTypeMapper implements TypeMapperInterface { /** * @var \Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper @@ -27,7 +27,7 @@ final class IterableTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contra /** * @required */ - public function autowire(\Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper $phpStanStaticTypeMapper) : void + public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper) : void { $this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper; } @@ -36,39 +36,39 @@ final class IterableTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contra */ public function getNodeClass() : string { - return \PHPStan\Type\IterableType::class; + return IterableType::class; } /** * @param IterableType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { $itemTypeNode = $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($type->getItemType(), $typeKind); - if ($itemTypeNode instanceof \PHPStan\PhpDocParser\Ast\Type\UnionTypeNode) { + if ($itemTypeNode instanceof UnionTypeNode) { return $this->convertUnionArrayTypeNodesToArrayTypeOfUnionTypeNodes($itemTypeNode); } - return new \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode($itemTypeNode); + return new SpacingAwareArrayTypeNode($itemTypeNode); } /** * @param IterableType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - return new \PhpParser\Node\Name('iterable'); + return new Name('iterable'); } - private function convertUnionArrayTypeNodesToArrayTypeOfUnionTypeNodes(\PHPStan\PhpDocParser\Ast\Type\UnionTypeNode $unionTypeNode) : \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode + private function convertUnionArrayTypeNodesToArrayTypeOfUnionTypeNodes(UnionTypeNode $unionTypeNode) : BracketsAwareUnionTypeNode { $unionedArrayType = []; foreach ($unionTypeNode->types as $unionedType) { - if ($unionedType instanceof \PHPStan\PhpDocParser\Ast\Type\UnionTypeNode) { + if ($unionedType instanceof UnionTypeNode) { foreach ($unionedType->types as $key => $subUnionedType) { - $unionedType->types[$key] = new \PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode($subUnionedType); + $unionedType->types[$key] = new ArrayTypeNode($subUnionedType); } $unionedArrayType[] = $unionedType; continue; } - $unionedArrayType[] = new \PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode($unionedType); + $unionedArrayType[] = new ArrayTypeNode($unionedType); } - return new \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode($unionedArrayType); + return new BracketsAwareUnionTypeNode($unionedArrayType); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/MixedTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/MixedTypeMapper.php index 8d20ab123c2..c59e1a39f0e 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/MixedTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/MixedTypeMapper.php @@ -15,14 +15,14 @@ use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface; /** * @implements TypeMapperInterface */ -final class MixedTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class MixedTypeMapper implements TypeMapperInterface { /** * @readonly * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PhpVersionProvider $phpVersionProvider) { $this->phpVersionProvider = $phpVersionProvider; } @@ -31,26 +31,26 @@ final class MixedTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\ */ public function getNodeClass() : string { - return \PHPStan\Type\MixedType::class; + return MixedType::class; } /** * @param MixedType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('mixed'); + return new IdentifierTypeNode('mixed'); } /** * @param MixedType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::MIXED_TYPE)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::MIXED_TYPE)) { return null; } if (!$type->isExplicitMixed()) { return null; } - return new \PhpParser\Node\Name('mixed'); + return new Name('mixed'); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/NeverTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/NeverTypeMapper.php index 6f902c0b589..4ca0a2516ab 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/NeverTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/NeverTypeMapper.php @@ -13,30 +13,30 @@ use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; /** * @implements TypeMapperInterface */ -final class NeverTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class NeverTypeMapper implements TypeMapperInterface { /** * @return class-string */ public function getNodeClass() : string { - return \PHPStan\Type\NeverType::class; + return NeverType::class; } /** * @param TypeKind::* $typeKind * @param NeverType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - if ($typeKind === \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN) { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('never'); + if ($typeKind === TypeKind::RETURN) { + return new IdentifierTypeNode('never'); } - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('mixed'); + return new IdentifierTypeNode('mixed'); } /** * @param NeverType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { return null; } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/NonEmptyArrayTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/NonEmptyArrayTypeMapper.php index 53bcc554fa3..705efa7ac0f 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/NonEmptyArrayTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/NonEmptyArrayTypeMapper.php @@ -14,27 +14,27 @@ use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface; /** * @implements TypeMapperInterface */ -final class NonEmptyArrayTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class NonEmptyArrayTypeMapper implements TypeMapperInterface { /** * @return class-string */ public function getNodeClass() : string { - return \PHPStan\Type\Accessory\NonEmptyArrayType::class; + return NonEmptyArrayType::class; } /** * @param NonEmptyArrayType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - return new \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode(new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('mixed')); + return new SpacingAwareArrayTypeNode(new IdentifierTypeNode('mixed')); } /** * @param NonEmptyArrayType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - return new \PhpParser\Node\Name('array'); + return new Name('array'); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/NullTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/NullTypeMapper.php index 634e5edcc32..500e17bb667 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/NullTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/NullTypeMapper.php @@ -14,38 +14,38 @@ use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; /** * @implements TypeMapperInterface */ -final class NullTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class NullTypeMapper implements TypeMapperInterface { /** * @return class-string */ public function getNodeClass() : string { - return \PHPStan\Type\NullType::class; + return NullType::class; } /** * @param NullType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('null'); + return new IdentifierTypeNode('null'); } /** * @param TypeKind::* $typeKind * @param NullType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - if ($typeKind === \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY) { + if ($typeKind === TypeKind::PROPERTY) { return null; } - if ($typeKind === \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM) { + if ($typeKind === TypeKind::PARAM) { return null; } // return type cannot be only null - if ($typeKind === \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN) { + if ($typeKind === TypeKind::RETURN) { return null; } - return new \PhpParser\Node\Name('null'); + return new Name('null'); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/ObjectTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/ObjectTypeMapper.php index e0e4e21deca..59513a9c7f6 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/ObjectTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/ObjectTypeMapper.php @@ -27,7 +27,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements TypeMapperInterface */ -final class ObjectTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class ObjectTypeMapper implements TypeMapperInterface { /** * @var \Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper @@ -38,85 +38,85 @@ final class ObjectTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract */ public function getNodeClass() : string { - return \PHPStan\Type\ObjectType::class; + return ObjectType::class; } /** * @param ObjectType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - if ($type instanceof \Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType) { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($type->getClassName()); + if ($type instanceof ShortenedObjectType) { + return new IdentifierTypeNode($type->getClassName()); } - if ($type instanceof \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType) { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($type->getClassName()); + if ($type instanceof AliasedObjectType) { + return new IdentifierTypeNode($type->getClassName()); } - if ($type instanceof \PHPStan\Type\Generic\GenericObjectType) { + if ($type instanceof GenericObjectType) { return $this->mapGenericObjectType($type, $typeKind); } - if ($type instanceof \Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType) { + if ($type instanceof NonExistingObjectType) { // possibly generic type - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($type->getClassName()); + return new IdentifierTypeNode($type->getClassName()); } - if ($type instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType && \strncmp($type->getClassName(), '\\', \strlen('\\')) === 0) { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($type->getClassName()); + if ($type instanceof FullyQualifiedObjectType && \strncmp($type->getClassName(), '\\', \strlen('\\')) === 0) { + return new IdentifierTypeNode($type->getClassName()); } - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('\\' . $type->getClassName()); + return new IdentifierTypeNode('\\' . $type->getClassName()); } /** * @param ObjectType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - if ($type instanceof \Rector\StaticTypeMapper\ValueObject\Type\SelfObjectType) { - return new \PhpParser\Node\Name('self'); + if ($type instanceof SelfObjectType) { + return new Name('self'); } - if ($type instanceof \Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType) { - return new \PhpParser\Node\Name\FullyQualified($type->getFullyQualifiedName()); + if ($type instanceof ShortenedObjectType) { + return new FullyQualified($type->getFullyQualifiedName()); } - if ($type instanceof \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType) { - return new \PhpParser\Node\Name($type->getClassName()); + if ($type instanceof AliasedObjectType) { + return new Name($type->getClassName()); } - if ($type instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) { + if ($type instanceof FullyQualifiedObjectType) { $className = $type->getClassName(); if (\strncmp($className, '\\', \strlen('\\')) === 0) { // skip leading \ - return new \PhpParser\Node\Name\FullyQualified(\RectorPrefix20220607\Nette\Utils\Strings::substring($className, 1)); + return new FullyQualified(Strings::substring($className, 1)); } - return new \PhpParser\Node\Name\FullyQualified($className); + return new FullyQualified($className); } - if (!$type instanceof \PHPStan\Type\Generic\GenericObjectType) { + if (!$type instanceof GenericObjectType) { // fallback - return new \PhpParser\Node\Name\FullyQualified($type->getClassName()); + return new FullyQualified($type->getClassName()); } if ($type->getClassName() === 'iterable') { // fallback - return new \PhpParser\Node\Name('iterable'); + return new Name('iterable'); } if ($type->getClassName() !== 'object') { // fallback - return new \PhpParser\Node\Name\FullyQualified($type->getClassName()); + return new FullyQualified($type->getClassName()); } - return new \PhpParser\Node\Name('object'); + return new Name('object'); } /** * @required */ - public function autowire(\Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper $phpStanStaticTypeMapper) : void + public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper) : void { $this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper; } /** * @param TypeKind::* $typeKind */ - private function mapGenericObjectType(\PHPStan\Type\Generic\GenericObjectType $genericObjectType, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + private function mapGenericObjectType(GenericObjectType $genericObjectType, string $typeKind) : TypeNode { $name = $this->resolveGenericObjectTypeName($genericObjectType); - $identifierTypeNode = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($name); + $identifierTypeNode = new IdentifierTypeNode($name); $genericTypeNodes = []; foreach ($genericObjectType->getTypes() as $key => $genericType) { // mixed type on 1st item in iterator has no value - if ($name === 'Iterator' && $genericType instanceof \PHPStan\Type\MixedType && $key === 0) { + if ($name === 'Iterator' && $genericType instanceof MixedType && $key === 0) { continue; } $typeNode = $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($genericType, $typeKind); @@ -125,11 +125,11 @@ final class ObjectTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract if ($genericTypeNodes === []) { return $identifierTypeNode; } - return new \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode($identifierTypeNode, $genericTypeNodes); + return new GenericTypeNode($identifierTypeNode, $genericTypeNodes); } - private function resolveGenericObjectTypeName(\PHPStan\Type\Generic\GenericObjectType $genericObjectType) : string + private function resolveGenericObjectTypeName(GenericObjectType $genericObjectType) : string { - if ($genericObjectType instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedGenericObjectType) { + if ($genericObjectType instanceof FullyQualifiedGenericObjectType) { return '\\' . $genericObjectType->getClassName(); } if (\strpos($genericObjectType->getClassName(), '\\') !== \false) { diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/ObjectWithoutClassTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/ObjectWithoutClassTypeMapper.php index 04383548d3d..325a81b64ad 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/ObjectWithoutClassTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/ObjectWithoutClassTypeMapper.php @@ -18,14 +18,14 @@ use Rector\StaticTypeMapper\ValueObject\Type\ParentObjectWithoutClassType; /** * @implements TypeMapperInterface */ -final class ObjectWithoutClassTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class ObjectWithoutClassTypeMapper implements TypeMapperInterface { /** * @readonly * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PhpVersionProvider $phpVersionProvider) { $this->phpVersionProvider = $phpVersionProvider; } @@ -34,30 +34,30 @@ final class ObjectWithoutClassTypeMapper implements \Rector\PHPStanStaticTypeMap */ public function getNodeClass() : string { - return \PHPStan\Type\ObjectWithoutClassType::class; + return ObjectWithoutClassType::class; } /** * @param ObjectWithoutClassType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - if ($type instanceof \Rector\StaticTypeMapper\ValueObject\Type\ParentObjectWithoutClassType) { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('parent'); + if ($type instanceof ParentObjectWithoutClassType) { + return new IdentifierTypeNode('parent'); } - if ($type instanceof \PHPStan\Type\Generic\TemplateObjectWithoutClassType) { - $attributeAwareIdentifierTypeNode = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($type->getName()); - return new \Rector\BetterPhpDocParser\ValueObject\Type\EmptyGenericTypeNode($attributeAwareIdentifierTypeNode); + if ($type instanceof TemplateObjectWithoutClassType) { + $attributeAwareIdentifierTypeNode = new IdentifierTypeNode($type->getName()); + return new EmptyGenericTypeNode($attributeAwareIdentifierTypeNode); } - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('object'); + return new IdentifierTypeNode('object'); } /** * @param ObjectWithoutClassType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::OBJECT_TYPE)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::OBJECT_TYPE)) { return null; } - return new \PhpParser\Node\Name('object'); + return new Name('object'); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/ParentStaticTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/ParentStaticTypeMapper.php index 2c845fd16df..cf8dbcb062b 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/ParentStaticTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/ParentStaticTypeMapper.php @@ -14,27 +14,27 @@ use Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType; /** * @implements TypeMapperInterface */ -final class ParentStaticTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class ParentStaticTypeMapper implements TypeMapperInterface { /** * @return class-string */ public function getNodeClass() : string { - return \Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType::class; + return ParentStaticType::class; } /** * @param ParentStaticType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode(\Rector\Core\Enum\ObjectReference::PARENT); + return new IdentifierTypeNode(ObjectReference::PARENT); } /** * @param ParentStaticType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - return new \PhpParser\Node\Name(\Rector\Core\Enum\ObjectReference::PARENT); + return new Name(ObjectReference::PARENT); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/ResourceTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/ResourceTypeMapper.php index 5677c972654..f145bbcb3a0 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/ResourceTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/ResourceTypeMapper.php @@ -12,26 +12,26 @@ use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface; /** * @implements TypeMapperInterface */ -final class ResourceTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class ResourceTypeMapper implements TypeMapperInterface { /** * @return class-string */ public function getNodeClass() : string { - return \PHPStan\Type\ResourceType::class; + return ResourceType::class; } /** * @param ResourceType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('resource'); + return new IdentifierTypeNode('resource'); } /** * @param ResourceType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { return null; } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/SelfObjectTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/SelfObjectTypeMapper.php index 94fbc908d1b..ad1ab9d7dd9 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/SelfObjectTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/SelfObjectTypeMapper.php @@ -13,27 +13,27 @@ use Rector\StaticTypeMapper\ValueObject\Type\SelfObjectType; /** * @implements TypeMapperInterface */ -final class SelfObjectTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class SelfObjectTypeMapper implements TypeMapperInterface { /** * @return class-string */ public function getNodeClass() : string { - return \Rector\StaticTypeMapper\ValueObject\Type\SelfObjectType::class; + return SelfObjectType::class; } /** * @param SelfObjectType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('self'); + return new IdentifierTypeNode('self'); } /** * @param SelfObjectType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - return new \PhpParser\Node\Name('self'); + return new Name('self'); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/StaticTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/StaticTypeMapper.php index 3576c7727a4..fd8051b90d0 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/StaticTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/StaticTypeMapper.php @@ -20,14 +20,14 @@ use Rector\StaticTypeMapper\ValueObject\Type\SimpleStaticType; * * @implements TypeMapperInterface */ -final class StaticTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class StaticTypeMapper implements TypeMapperInterface { /** * @readonly * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PhpVersionProvider $phpVersionProvider) { $this->phpVersionProvider = $phpVersionProvider; } @@ -36,30 +36,30 @@ final class StaticTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract */ public function getNodeClass() : string { - return \PHPStan\Type\StaticType::class; + return StaticType::class; } /** * @param StaticType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - return new \PHPStan\PhpDocParser\Ast\Type\ThisTypeNode(); + return new ThisTypeNode(); } /** * @param StaticType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { // special case, for autocomplete of return type - if ($type instanceof \Rector\StaticTypeMapper\ValueObject\Type\SimpleStaticType) { - return new \PhpParser\Node\Name(\Rector\Core\Enum\ObjectReference::STATIC); + if ($type instanceof SimpleStaticType) { + return new Name(ObjectReference::STATIC); } - if ($type instanceof \Rector\StaticTypeMapper\ValueObject\Type\SelfStaticType) { - return new \PhpParser\Node\Name(\Rector\Core\Enum\ObjectReference::SELF); + if ($type instanceof SelfStaticType) { + return new Name(ObjectReference::SELF); } - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::STATIC_RETURN_TYPE)) { - return new \PhpParser\Node\Name(\Rector\Core\Enum\ObjectReference::STATIC); + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::STATIC_RETURN_TYPE)) { + return new Name(ObjectReference::STATIC); } - return new \PhpParser\Node\Name(\Rector\Core\Enum\ObjectReference::SELF); + return new Name(ObjectReference::SELF); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/StrictMixedTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/StrictMixedTypeMapper.php index 301ac23c00e..c215244544b 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/StrictMixedTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/StrictMixedTypeMapper.php @@ -13,7 +13,7 @@ use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface; /** * @implements TypeMapperInterface */ -final class StrictMixedTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class StrictMixedTypeMapper implements TypeMapperInterface { /** * @var string @@ -24,20 +24,20 @@ final class StrictMixedTypeMapper implements \Rector\PHPStanStaticTypeMapper\Con */ public function getNodeClass() : string { - return \PHPStan\Type\StrictMixedType::class; + return StrictMixedType::class; } /** * @param StrictMixedType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode(self::MIXED); + return new IdentifierTypeNode(self::MIXED); } /** * @param StrictMixedType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - return new \PhpParser\Node\Name(self::MIXED); + return new Name(self::MIXED); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/StringTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/StringTypeMapper.php index 734a2862ef5..c9bd794057e 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/StringTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/StringTypeMapper.php @@ -15,14 +15,14 @@ use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface; /** * @implements TypeMapperInterface */ -final class StringTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class StringTypeMapper implements TypeMapperInterface { /** * @readonly * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PhpVersionProvider $phpVersionProvider) { $this->phpVersionProvider = $phpVersionProvider; } @@ -31,20 +31,20 @@ final class StringTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract */ public function getNodeClass() : string { - return \PHPStan\Type\StringType::class; + return StringType::class; } /** * @param StringType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('string'); + return new IdentifierTypeNode('string'); } - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::SCALAR_TYPES)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::SCALAR_TYPES)) { return null; } - return new \PhpParser\Node\Name('string'); + return new Name('string'); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/ThisTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/ThisTypeMapper.php index 1c245aee49b..e1ebf123b4a 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/ThisTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/ThisTypeMapper.php @@ -13,27 +13,27 @@ use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface; /** * @implements TypeMapperInterface */ -final class ThisTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class ThisTypeMapper implements TypeMapperInterface { /** * @return class-string */ public function getNodeClass() : string { - return \PHPStan\Type\ThisType::class; + return ThisType::class; } /** * @param ThisType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - return new \PHPStan\PhpDocParser\Ast\Type\ThisTypeNode(); + return new ThisTypeNode(); } /** * @param ThisType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - return new \PhpParser\Node\Name('self'); + return new Name('self'); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/TypeWithClassNameTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/TypeWithClassNameTypeMapper.php index 7f5678851a1..e8bac895100 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/TypeWithClassNameTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/TypeWithClassNameTypeMapper.php @@ -15,14 +15,14 @@ use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface; /** * @implements TypeMapperInterface */ -final class TypeWithClassNameTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class TypeWithClassNameTypeMapper implements TypeMapperInterface { /** * @readonly * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PhpVersionProvider $phpVersionProvider) { $this->phpVersionProvider = $phpVersionProvider; } @@ -31,23 +31,23 @@ final class TypeWithClassNameTypeMapper implements \Rector\PHPStanStaticTypeMapp */ public function getNodeClass() : string { - return \PHPStan\Type\TypeWithClassName::class; + return TypeWithClassName::class; } /** * @param TypeWithClassName $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('string-class'); + return new IdentifierTypeNode('string-class'); } /** * @param TypeWithClassName $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::SCALAR_TYPES)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::SCALAR_TYPES)) { return null; } - return new \PhpParser\Node\Name('string'); + return new Name('string'); } } diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/UnionTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/UnionTypeMapper.php index 1c395a852ce..952460f1640 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/UnionTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/UnionTypeMapper.php @@ -41,7 +41,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements TypeMapperInterface */ -final class UnionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class UnionTypeMapper implements TypeMapperInterface { /** * @var \Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper @@ -77,7 +77,7 @@ final class UnionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\ * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\PHPStanStaticTypeMapper\DoctrineTypeAnalyzer $doctrineTypeAnalyzer, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider, \Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer $unionTypeAnalyzer, \Rector\PHPStanStaticTypeMapper\TypeAnalyzer\BoolUnionTypeAnalyzer $boolUnionTypeAnalyzer, \Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeCommonTypeNarrower $unionTypeCommonTypeNarrower, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(DoctrineTypeAnalyzer $doctrineTypeAnalyzer, PhpVersionProvider $phpVersionProvider, UnionTypeAnalyzer $unionTypeAnalyzer, BoolUnionTypeAnalyzer $boolUnionTypeAnalyzer, UnionTypeCommonTypeNarrower $unionTypeCommonTypeNarrower, NodeNameResolver $nodeNameResolver) { $this->doctrineTypeAnalyzer = $doctrineTypeAnalyzer; $this->phpVersionProvider = $phpVersionProvider; @@ -89,7 +89,7 @@ final class UnionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\ /** * @required */ - public function autowire(\Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper $phpStanStaticTypeMapper) : void + public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper) : void { $this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper; } @@ -98,67 +98,67 @@ final class UnionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\ */ public function getNodeClass() : string { - return \PHPStan\Type\UnionType::class; + return UnionType::class; } /** * @param UnionType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { $unionTypesNodes = []; $skipIterable = $this->shouldSkipIterable($type); foreach ($type->getTypes() as $unionedType) { - if ($unionedType instanceof \PHPStan\Type\IterableType && $skipIterable) { + if ($unionedType instanceof IterableType && $skipIterable) { continue; } $unionTypesNodes[] = $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($unionedType, $typeKind); } $unionTypesNodes = \array_unique($unionTypesNodes); - return new \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode($unionTypesNodes); + return new BracketsAwareUnionTypeNode($unionTypesNodes); } /** * @param UnionType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { $arrayNode = $this->matchArrayTypes($type); if ($arrayNode !== null) { return $arrayNode; } - if ($this->boolUnionTypeAnalyzer->isNullableBoolUnionType($type) && !$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::UNION_TYPES)) { - return new \PhpParser\Node\NullableType(new \PhpParser\Node\Name('bool')); + if ($this->boolUnionTypeAnalyzer->isNullableBoolUnionType($type) && !$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::UNION_TYPES)) { + return new NullableType(new Name('bool')); } - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::UNION_TYPES) && $this->isFalseBoolUnion($type)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::UNION_TYPES) && $this->isFalseBoolUnion($type)) { // return new Bool - return new \PhpParser\Node\Name('bool'); + return new Name('bool'); } // special case for nullable $nullabledType = $this->matchTypeForNullableUnionType($type); - if (!$nullabledType instanceof \PHPStan\Type\Type) { + if (!$nullabledType instanceof Type) { // use first unioned type in case of unioned object types return $this->matchTypeForUnionedObjectTypes($type, $typeKind); } // void cannot be nullable - if ($nullabledType instanceof \PHPStan\Type\VoidType) { + if ($nullabledType instanceof VoidType) { return null; } $nullabledTypeNode = $this->phpStanStaticTypeMapper->mapToPhpParserNode($nullabledType, $typeKind); - if (!$nullabledTypeNode instanceof \PhpParser\Node) { + if (!$nullabledTypeNode instanceof Node) { return null; } - if (\in_array(\get_class($nullabledTypeNode), [\PhpParser\Node\NullableType::class, \PhpParser\Node\ComplexType::class], \true)) { + if (\in_array(\get_class($nullabledTypeNode), [NullableType::class, ComplexType::class], \true)) { return $nullabledTypeNode; } /** @var Name $nullabledTypeNode */ if (!$this->nodeNameResolver->isName($nullabledTypeNode, 'false')) { - return new \PhpParser\Node\NullableType($nullabledTypeNode); + return new NullableType($nullabledTypeNode); } return null; } - private function shouldSkipIterable(\PHPStan\Type\UnionType $unionType) : bool + private function shouldSkipIterable(UnionType $unionType) : bool { $unionTypeAnalysis = $this->unionTypeAnalyzer->analyseForNullableAndIterable($unionType); - if (!$unionTypeAnalysis instanceof \Rector\PHPStanStaticTypeMapper\ValueObject\UnionTypeAnalysis) { + if (!$unionTypeAnalysis instanceof UnionTypeAnalysis) { return \false; } if (!$unionTypeAnalysis->hasIterable()) { @@ -169,51 +169,51 @@ final class UnionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\ /** * @return \PhpParser\Node\Name|\PhpParser\Node\NullableType|null */ - private function matchArrayTypes(\PHPStan\Type\UnionType $unionType) + private function matchArrayTypes(UnionType $unionType) { $unionTypeAnalysis = $this->unionTypeAnalyzer->analyseForNullableAndIterable($unionType); - if (!$unionTypeAnalysis instanceof \Rector\PHPStanStaticTypeMapper\ValueObject\UnionTypeAnalysis) { + if (!$unionTypeAnalysis instanceof UnionTypeAnalysis) { return null; } $type = $unionTypeAnalysis->hasIterable() ? 'iterable' : 'array'; if ($unionTypeAnalysis->isNullableType()) { - return new \PhpParser\Node\NullableType($type); + return new NullableType($type); } - return new \PhpParser\Node\Name($type); + return new Name($type); } - private function matchTypeForNullableUnionType(\PHPStan\Type\UnionType $unionType) : ?\PHPStan\Type\Type + private function matchTypeForNullableUnionType(UnionType $unionType) : ?Type { if (\count($unionType->getTypes()) !== 2) { return null; } $firstType = $unionType->getTypes()[0]; $secondType = $unionType->getTypes()[1]; - if ($firstType instanceof \PHPStan\Type\NullType) { + if ($firstType instanceof NullType) { return $secondType; } - if ($secondType instanceof \PHPStan\Type\NullType) { + if ($secondType instanceof NullType) { return $firstType; } return null; } - private function hasObjectAndStaticType(\PhpParser\Node\UnionType $phpParserUnionType) : bool + private function hasObjectAndStaticType(PhpParserUnionType $phpParserUnionType) : bool { $typeNames = $this->nodeNameResolver->getNames($phpParserUnionType->types); - $diff = \array_diff(['object', \Rector\Core\Enum\ObjectReference::STATIC], $typeNames); + $diff = \array_diff(['object', ObjectReference::STATIC], $typeNames); return $diff === []; } /** * @param TypeKind::* $typeKind * @return Name|FullyQualified|PhpParserUnionType|NullableType|null */ - private function matchTypeForUnionedObjectTypes(\PHPStan\Type\UnionType $unionType, string $typeKind) : ?\PhpParser\Node + private function matchTypeForUnionedObjectTypes(UnionType $unionType, string $typeKind) : ?Node { $phpParserUnionType = $this->matchPhpParserUnionType($unionType, $typeKind); if ($phpParserUnionType !== null) { - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::UNION_TYPES)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::UNION_TYPES)) { // maybe all one type? if ($this->boolUnionTypeAnalyzer->isBoolUnionType($unionType)) { - return new \PhpParser\Node\Name('bool'); + return new Name('bool'); } return null; } @@ -223,50 +223,50 @@ final class UnionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\ return $phpParserUnionType; } if ($this->boolUnionTypeAnalyzer->isBoolUnionType($unionType)) { - return new \PhpParser\Node\Name('bool'); + return new Name('bool'); } $compatibleObjectType = $this->processResolveCompatibleObjectCandidates($unionType); - if ($compatibleObjectType instanceof \PhpParser\Node\NullableType || $compatibleObjectType instanceof \PhpParser\Node\Name\FullyQualified) { + if ($compatibleObjectType instanceof NullableType || $compatibleObjectType instanceof FullyQualified) { return $compatibleObjectType; } return $this->processResolveCompatibleStringCandidates($unionType); } - private function processResolveCompatibleStringCandidates(\PHPStan\Type\UnionType $unionType) : ?\PhpParser\Node\Name + private function processResolveCompatibleStringCandidates(UnionType $unionType) : ?Name { foreach ($unionType->getTypes() as $type) { - if (!\in_array(\get_class($type), [\PHPStan\Type\ClassStringType::class, \PHPStan\Type\Generic\GenericClassStringType::class], \true)) { + if (!\in_array(\get_class($type), [ClassStringType::class, GenericClassStringType::class], \true)) { return null; } } - return new \PhpParser\Node\Name('string'); + return new Name('string'); } - private function processResolveCompatibleObjectCandidates(\PHPStan\Type\UnionType $unionType) : ?\PhpParser\Node + private function processResolveCompatibleObjectCandidates(UnionType $unionType) : ?Node { // the type should be compatible with all other types, e.g. A extends B, B $compatibleObjectType = $this->resolveCompatibleObjectCandidate($unionType); - if ($compatibleObjectType instanceof \PHPStan\Type\UnionType) { + if ($compatibleObjectType instanceof UnionType) { $type = $this->matchTypeForNullableUnionType($compatibleObjectType); - if ($type instanceof \PHPStan\Type\ObjectType) { - return new \PhpParser\Node\NullableType(new \PhpParser\Node\Name\FullyQualified($type->getClassName())); + if ($type instanceof ObjectType) { + return new NullableType(new FullyQualified($type->getClassName())); } } - if (!$compatibleObjectType instanceof \PHPStan\Type\ObjectType) { + if (!$compatibleObjectType instanceof ObjectType) { return null; } - return new \PhpParser\Node\Name\FullyQualified($compatibleObjectType->getClassName()); + return new FullyQualified($compatibleObjectType->getClassName()); } /** * @param TypeKind::* $typeKind */ - private function matchPhpParserUnionType(\PHPStan\Type\UnionType $unionType, string $typeKind) : ?\PhpParser\Node\UnionType + private function matchPhpParserUnionType(UnionType $unionType, string $typeKind) : ?PhpParserUnionType { - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::UNION_TYPES)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::UNION_TYPES)) { return null; } $phpParserUnionedTypes = []; foreach ($unionType->getTypes() as $unionedType) { // void type and mixed type are not allowed in union - if (\in_array(\get_class($unionedType), [\PHPStan\Type\MixedType::class, \PHPStan\Type\VoidType::class], \true)) { + if (\in_array(\get_class($unionedType), [MixedType::class, VoidType::class], \true)) { return null; } /** @@ -275,7 +275,7 @@ final class UnionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\ * * @var Identifier|Name|null $phpParserNode */ - $phpParserNode = $unionedType instanceof \PHPStan\Type\NullType && $typeKind === \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY ? new \PhpParser\Node\Name('null') : $this->phpStanStaticTypeMapper->mapToPhpParserNode($unionedType, $typeKind); + $phpParserNode = $unionedType instanceof NullType && $typeKind === TypeKind::PROPERTY ? new Name('null') : $this->phpStanStaticTypeMapper->mapToPhpParserNode($unionedType, $typeKind); if ($phpParserNode === null) { return null; } @@ -285,23 +285,23 @@ final class UnionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\ if (\count($phpParserUnionedTypes) < 2) { return null; } - return new \PhpParser\Node\UnionType($phpParserUnionedTypes); + return new PhpParserUnionType($phpParserUnionedTypes); } /** * @return \PHPStan\Type\UnionType|\PHPStan\Type\TypeWithClassName|null */ - private function resolveCompatibleObjectCandidate(\PHPStan\Type\UnionType $unionType) + private function resolveCompatibleObjectCandidate(UnionType $unionType) { if ($this->doctrineTypeAnalyzer->isDoctrineCollectionWithIterableUnionType($unionType)) { - $objectType = new \PHPStan\Type\ObjectType('Doctrine\\Common\\Collections\\Collection'); - return $this->unionTypeAnalyzer->isNullable($unionType) ? new \PHPStan\Type\UnionType([new \PHPStan\Type\NullType(), $objectType]) : $objectType; + $objectType = new ObjectType('Doctrine\\Common\\Collections\\Collection'); + return $this->unionTypeAnalyzer->isNullable($unionType) ? new UnionType([new NullType(), $objectType]) : $objectType; } $typesWithClassNames = $this->unionTypeAnalyzer->matchExclusiveTypesWithClassNames($unionType); if ($typesWithClassNames === []) { return null; } $sharedTypeWithClassName = $this->matchTwoObjectTypes($typesWithClassNames); - if ($sharedTypeWithClassName instanceof \PHPStan\Type\TypeWithClassName) { + if ($sharedTypeWithClassName instanceof TypeWithClassName) { return $this->correctObjectType($sharedTypeWithClassName); } // find least common denominator @@ -310,7 +310,7 @@ final class UnionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\ /** * @param TypeWithClassName[] $typesWithClassNames */ - private function matchTwoObjectTypes(array $typesWithClassNames) : ?\PHPStan\Type\TypeWithClassName + private function matchTwoObjectTypes(array $typesWithClassNames) : ?TypeWithClassName { foreach ($typesWithClassNames as $typeWithClassName) { foreach ($typesWithClassNames as $nestedTypeWithClassName) { @@ -322,27 +322,27 @@ final class UnionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\ } return null; } - private function areTypeWithClassNamesRelated(\PHPStan\Type\TypeWithClassName $firstType, \PHPStan\Type\TypeWithClassName $secondType) : bool + private function areTypeWithClassNamesRelated(TypeWithClassName $firstType, TypeWithClassName $secondType) : bool { return $firstType->accepts($secondType, \false)->yes(); } - private function correctObjectType(\PHPStan\Type\TypeWithClassName $typeWithClassName) : \PHPStan\Type\TypeWithClassName + private function correctObjectType(TypeWithClassName $typeWithClassName) : TypeWithClassName { - if ($typeWithClassName->getClassName() === \PhpParser\NodeAbstract::class) { - return new \PHPStan\Type\ObjectType('PhpParser\\Node'); + if ($typeWithClassName->getClassName() === NodeAbstract::class) { + return new ObjectType('PhpParser\\Node'); } - if ($typeWithClassName->getClassName() === \Rector\Core\Rector\AbstractRector::class) { - return new \PHPStan\Type\ObjectType('Rector\\Core\\Contract\\Rector\\RectorInterface'); + if ($typeWithClassName->getClassName() === AbstractRector::class) { + return new ObjectType('Rector\\Core\\Contract\\Rector\\RectorInterface'); } return $typeWithClassName; } - private function isFalseBoolUnion(\PHPStan\Type\UnionType $unionType) : bool + private function isFalseBoolUnion(UnionType $unionType) : bool { if (\count($unionType->getTypes()) !== 2) { return \false; } foreach ($unionType->getTypes() as $unionedType) { - if ($unionedType instanceof \PHPStan\Type\Constant\ConstantBooleanType) { + if ($unionedType instanceof ConstantBooleanType) { continue; } return \false; diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/VoidTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/VoidTypeMapper.php index 0fc2cebe7b0..b1c4b037ce2 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/VoidTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/VoidTypeMapper.php @@ -16,7 +16,7 @@ use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; /** * @implements TypeMapperInterface */ -final class VoidTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface +final class VoidTypeMapper implements TypeMapperInterface { /** * @var string @@ -27,7 +27,7 @@ final class VoidTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\T * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PhpVersionProvider $phpVersionProvider) { $this->phpVersionProvider = $phpVersionProvider; } @@ -36,27 +36,27 @@ final class VoidTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\T */ public function getNodeClass() : string { - return \PHPStan\Type\VoidType::class; + return VoidType::class; } /** * @param VoidType $type */ - public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode(self::VOID); + return new IdentifierTypeNode(self::VOID); } /** * @param TypeKind::* $typeKind * @param VoidType $type */ - public function mapToPhpParserNode(\PHPStan\Type\Type $type, string $typeKind) : ?\PhpParser\Node + public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::VOID_TYPE)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::VOID_TYPE)) { return null; } - if (\in_array($typeKind, [\Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY], \true)) { + if (\in_array($typeKind, [TypeKind::PARAM, TypeKind::PROPERTY], \true)) { return null; } - return new \PhpParser\Node\Name(self::VOID); + return new Name(self::VOID); } } diff --git a/packages/PHPStanStaticTypeMapper/Utils/TypeUnwrapper.php b/packages/PHPStanStaticTypeMapper/Utils/TypeUnwrapper.php index 35f3629a9d2..5593c6dd9f3 100644 --- a/packages/PHPStanStaticTypeMapper/Utils/TypeUnwrapper.php +++ b/packages/PHPStanStaticTypeMapper/Utils/TypeUnwrapper.php @@ -12,32 +12,32 @@ final class TypeUnwrapper /** * E.g. null|ClassType → ClassType */ - public function unwrapNullableType(\PHPStan\Type\Type $type) : \PHPStan\Type\Type + public function unwrapNullableType(Type $type) : Type { - return \PHPStan\Type\TypeCombinator::removeNull($type); + return TypeCombinator::removeNull($type); } - public function unwrapFirstObjectTypeFromUnionType(\PHPStan\Type\Type $type) : \PHPStan\Type\Type + public function unwrapFirstObjectTypeFromUnionType(Type $type) : Type { - if (!$type instanceof \PHPStan\Type\UnionType) { + if (!$type instanceof UnionType) { return $type; } foreach ($type->getTypes() as $unionedType) { - if (!$unionedType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$unionedType instanceof TypeWithClassName) { continue; } return $unionedType; } return $type; } - public function removeNullTypeFromUnionType(\PHPStan\Type\UnionType $unionType) : \PHPStan\Type\UnionType + public function removeNullTypeFromUnionType(UnionType $unionType) : UnionType { $unionedTypesWithoutNullType = []; foreach ($unionType->getTypes() as $type) { - if ($type instanceof \PHPStan\Type\UnionType) { + if ($type instanceof UnionType) { continue; } $unionedTypesWithoutNullType[] = $type; } - return new \PHPStan\Type\UnionType($unionedTypesWithoutNullType); + return new UnionType($unionedTypesWithoutNullType); } } diff --git a/packages/Parallel/Application/ParallelFileProcessor.php b/packages/Parallel/Application/ParallelFileProcessor.php index 9337b8cbcd2..51f1f4e48b6 100644 --- a/packages/Parallel/Application/ParallelFileProcessor.php +++ b/packages/Parallel/Application/ParallelFileProcessor.php @@ -53,7 +53,7 @@ final class ParallelFileProcessor * @var \Symplify\PackageBuilder\Parameter\ParameterProvider */ private $parameterProvider; - public function __construct(\Rector\Parallel\Command\WorkerCommandLineFactory $workerCommandLineFactory, \RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider) + public function __construct(WorkerCommandLineFactory $workerCommandLineFactory, ParameterProvider $parameterProvider) { $this->workerCommandLineFactory = $workerCommandLineFactory; $this->parameterProvider = $parameterProvider; @@ -62,27 +62,27 @@ final class ParallelFileProcessor * @param callable(int $stepCount): void $postFileCallback Used for progress bar jump * @return array{file_diffs: SerializableInterface[], system_errors: SerializableInterface[], system_errors_count: int} */ - public function process(\RectorPrefix20220607\Symplify\EasyParallel\ValueObject\Schedule $schedule, string $mainScript, callable $postFileCallback, \RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input) : array + public function process(Schedule $schedule, string $mainScript, callable $postFileCallback, InputInterface $input) : array { $jobs = \array_reverse($schedule->getJobs()); - $streamSelectLoop = new \RectorPrefix20220607\React\EventLoop\StreamSelectLoop(); + $streamSelectLoop = new StreamSelectLoop(); // basic properties setup $numberOfProcesses = $schedule->getNumberOfProcesses(); // initial counters $fileDiffs = []; /** @var SystemError[] $systemErrors */ $systemErrors = []; - $tcpServer = new \RectorPrefix20220607\React\Socket\TcpServer('127.0.0.1:0', $streamSelectLoop); - $this->processPool = new \RectorPrefix20220607\Symplify\EasyParallel\ValueObject\ProcessPool($tcpServer); - $tcpServer->on(\RectorPrefix20220607\Symplify\EasyParallel\Enum\ReactEvent::CONNECTION, function (\RectorPrefix20220607\React\Socket\ConnectionInterface $connection) use(&$jobs) : void { - $inDecoder = new \RectorPrefix20220607\Clue\React\NDJson\Decoder($connection, \true, 512, 0, 4 * 1024 * 1024); - $outEncoder = new \RectorPrefix20220607\Clue\React\NDJson\Encoder($connection); - $inDecoder->on(\RectorPrefix20220607\Symplify\EasyParallel\Enum\ReactEvent::DATA, function (array $data) use(&$jobs, $inDecoder, $outEncoder) : void { - $action = $data[\RectorPrefix20220607\Symplify\EasyParallel\Enum\ReactCommand::ACTION]; - if ($action !== \RectorPrefix20220607\Symplify\EasyParallel\Enum\Action::HELLO) { + $tcpServer = new TcpServer('127.0.0.1:0', $streamSelectLoop); + $this->processPool = new ProcessPool($tcpServer); + $tcpServer->on(ReactEvent::CONNECTION, function (ConnectionInterface $connection) use(&$jobs) : void { + $inDecoder = new Decoder($connection, \true, 512, 0, 4 * 1024 * 1024); + $outEncoder = new Encoder($connection); + $inDecoder->on(ReactEvent::DATA, function (array $data) use(&$jobs, $inDecoder, $outEncoder) : void { + $action = $data[ReactCommand::ACTION]; + if ($action !== Action::HELLO) { return; } - $processIdentifier = $data[\Rector\Core\Configuration\Option::PARALLEL_IDENTIFIER]; + $processIdentifier = $data[Option::PARALLEL_IDENTIFIER]; $parallelProcess = $this->processPool->getProcess($processIdentifier); $parallelProcess->bindConnection($inDecoder, $outEncoder); if ($jobs === []) { @@ -90,7 +90,7 @@ final class ParallelFileProcessor return; } $job = \array_pop($jobs); - $parallelProcess->request([\RectorPrefix20220607\Symplify\EasyParallel\Enum\ReactCommand::ACTION => \RectorPrefix20220607\Symplify\EasyParallel\Enum\Action::MAIN, \RectorPrefix20220607\Symplify\EasyParallel\Enum\Content::FILES => $job]); + $parallelProcess->request([ReactCommand::ACTION => Action::MAIN, Content::FILES => $job]); }); }); /** @var string $serverAddress */ @@ -99,37 +99,37 @@ final class ParallelFileProcessor $serverPort = \parse_url($serverAddress, \PHP_URL_PORT); $systemErrorsCount = 0; $reachedSystemErrorsCountLimit = \false; - $handleErrorCallable = function (\Throwable $throwable) use(&$systemErrors, &$systemErrorsCount, &$reachedSystemErrorsCountLimit) : void { - $systemErrors[] = new \Rector\Core\ValueObject\Error\SystemError($throwable->getMessage(), $throwable->getFile(), $throwable->getLine()); + $handleErrorCallable = function (Throwable $throwable) use(&$systemErrors, &$systemErrorsCount, &$reachedSystemErrorsCountLimit) : void { + $systemErrors[] = new SystemError($throwable->getMessage(), $throwable->getFile(), $throwable->getLine()); ++$systemErrorsCount; $reachedSystemErrorsCountLimit = \true; $this->processPool->quitAll(); }; - $timeoutInSeconds = $this->parameterProvider->provideIntParameter(\Rector\Core\Configuration\Option::PARALLEL_TIMEOUT_IN_SECONDS); + $timeoutInSeconds = $this->parameterProvider->provideIntParameter(Option::PARALLEL_TIMEOUT_IN_SECONDS); for ($i = 0; $i < $numberOfProcesses; ++$i) { // nothing else to process, stop now if ($jobs === []) { break; } - $processIdentifier = \RectorPrefix20220607\Nette\Utils\Random::generate(); - $workerCommandLine = $this->workerCommandLineFactory->create($mainScript, \Rector\Core\Console\Command\ProcessCommand::class, 'worker', $input, $processIdentifier, $serverPort); - $parallelProcess = new \RectorPrefix20220607\Symplify\EasyParallel\ValueObject\ParallelProcess($workerCommandLine, $streamSelectLoop, $timeoutInSeconds); + $processIdentifier = Random::generate(); + $workerCommandLine = $this->workerCommandLineFactory->create($mainScript, ProcessCommand::class, 'worker', $input, $processIdentifier, $serverPort); + $parallelProcess = new ParallelProcess($workerCommandLine, $streamSelectLoop, $timeoutInSeconds); $parallelProcess->start( // 1. callable on data function (array $json) use($parallelProcess, &$systemErrors, &$fileDiffs, &$jobs, $postFileCallback, &$systemErrorsCount, &$reachedInternalErrorsCountLimit, $processIdentifier) : void { // decode arrays to objects - foreach ($json[\Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS] as $jsonError) { + foreach ($json[Bridge::SYSTEM_ERRORS] as $jsonError) { if (\is_string($jsonError)) { - $systemErrors[] = new \Rector\Core\ValueObject\Error\SystemError('System error: ' . $jsonError); + $systemErrors[] = new SystemError('System error: ' . $jsonError); continue; } - $systemErrors[] = \Rector\Core\ValueObject\Error\SystemError::decode($jsonError); + $systemErrors[] = SystemError::decode($jsonError); } - foreach ($json[\Rector\Parallel\ValueObject\Bridge::FILE_DIFFS] as $jsonError) { - $fileDiffs[] = \Rector\Core\ValueObject\Reporting\FileDiff::decode($jsonError); + foreach ($json[Bridge::FILE_DIFFS] as $jsonError) { + $fileDiffs[] = FileDiff::decode($jsonError); } - $postFileCallback($json[\Rector\Parallel\ValueObject\Bridge::FILES_COUNT]); - $systemErrorsCount += $json[\Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS_COUNT]; + $postFileCallback($json[Bridge::FILES_COUNT]); + $systemErrorsCount += $json[Bridge::SYSTEM_ERRORS_COUNT]; if ($systemErrorsCount >= self::SYSTEM_ERROR_LIMIT) { $reachedInternalErrorsCountLimit = \true; $this->processPool->quitAll(); @@ -139,28 +139,28 @@ final class ParallelFileProcessor return; } $job = \array_pop($jobs); - $parallelProcess->request([\RectorPrefix20220607\Symplify\EasyParallel\Enum\ReactCommand::ACTION => \RectorPrefix20220607\Symplify\EasyParallel\Enum\Action::MAIN, \RectorPrefix20220607\Symplify\EasyParallel\Enum\Content::FILES => $job]); + $parallelProcess->request([ReactCommand::ACTION => Action::MAIN, Content::FILES => $job]); }, // 2. callable on error $handleErrorCallable, // 3. callable on exit function ($exitCode, string $stdErr) use(&$systemErrors, $processIdentifier) : void { $this->processPool->tryQuitProcess($processIdentifier); - if ($exitCode === \RectorPrefix20220607\Symfony\Component\Console\Command\Command::SUCCESS) { + if ($exitCode === Command::SUCCESS) { return; } if ($exitCode === null) { return; } - $systemErrors[] = new \Rector\Core\ValueObject\Error\SystemError('Child process error: ' . $stdErr); + $systemErrors[] = new SystemError('Child process error: ' . $stdErr); } ); $this->processPool->attachProcess($processIdentifier, $parallelProcess); } $streamSelectLoop->run(); if ($reachedSystemErrorsCountLimit) { - $systemErrors[] = new \Rector\Core\ValueObject\Error\SystemError(\sprintf('Reached system errors count limit of %d, exiting...', self::SYSTEM_ERROR_LIMIT)); + $systemErrors[] = new SystemError(\sprintf('Reached system errors count limit of %d, exiting...', self::SYSTEM_ERROR_LIMIT)); } - return [\Rector\Parallel\ValueObject\Bridge::FILE_DIFFS => $fileDiffs, \Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS => $systemErrors, \Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS_COUNT => \count($systemErrors)]; + return [Bridge::FILE_DIFFS => $fileDiffs, Bridge::SYSTEM_ERRORS => $systemErrors, Bridge::SYSTEM_ERRORS_COUNT => \count($systemErrors)]; } } diff --git a/packages/Parallel/Command/WorkerCommandLineFactory.php b/packages/Parallel/Command/WorkerCommandLineFactory.php index 09207d69571..af5dfaab6fd 100644 --- a/packages/Parallel/Command/WorkerCommandLineFactory.php +++ b/packages/Parallel/Command/WorkerCommandLineFactory.php @@ -26,12 +26,12 @@ final class WorkerCommandLineFactory private $commandFromReflectionFactory; public function __construct() { - $this->commandFromReflectionFactory = new \RectorPrefix20220607\Symplify\EasyParallel\Reflection\CommandFromReflectionFactory(); + $this->commandFromReflectionFactory = new CommandFromReflectionFactory(); } /** * @param class-string $mainCommandClass */ - public function create(string $mainScript, string $mainCommandClass, string $workerCommandName, \RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, string $identifier, int $port) : string + public function create(string $mainScript, string $mainCommandClass, string $workerCommandName, InputInterface $input, string $identifier, int $port) : string { $commandArguments = \array_slice($_SERVER['argv'], 1); $args = \array_merge([\PHP_BINARY, $mainScript], $commandArguments); @@ -39,7 +39,7 @@ final class WorkerCommandLineFactory $mainCommand = $this->commandFromReflectionFactory->create($mainCommandClass); if ($mainCommand->getName() === null) { $errorMessage = \sprintf('The command name for "%s" is missing', \get_class($mainCommand)); - throw new \RectorPrefix20220607\Symplify\EasyParallel\Exception\ParallelShouldNotHappenException($errorMessage); + throw new ParallelShouldNotHappenException($errorMessage); } $mainCommandName = $mainCommand->getName(); $mainCommandNames = [$mainCommandName, $mainCommandName[0]]; @@ -60,17 +60,17 @@ final class WorkerCommandLineFactory $workerCommandArray[] = '--identifier'; $workerCommandArray[] = \escapeshellarg($identifier); /** @var string[] $paths */ - $paths = $input->getArgument(\Rector\Core\Configuration\Option::SOURCE); + $paths = $input->getArgument(Option::SOURCE); foreach ($paths as $path) { $workerCommandArray[] = \escapeshellarg($path); } // set json output - $workerCommandArray[] = self::OPTION_DASHES . \Rector\Core\Configuration\Option::OUTPUT_FORMAT; - $workerCommandArray[] = \escapeshellarg(\Rector\ChangesReporting\Output\JsonOutputFormatter::NAME); + $workerCommandArray[] = self::OPTION_DASHES . Option::OUTPUT_FORMAT; + $workerCommandArray[] = \escapeshellarg(JsonOutputFormatter::NAME); // disable colors, breaks json_decode() otherwise // @see https://github.com/symfony/symfony/issues/1238 $workerCommandArray[] = '--no-ansi'; - if ($input->hasOption(\Rector\Core\Configuration\Option::CONFIG)) { + if ($input->hasOption(Option::CONFIG)) { $workerCommandArray[] = '--config'; /** * On parallel, the command is generated with `--config` addition @@ -89,22 +89,22 @@ final class WorkerCommandLineFactory * * tested in macOS and Ubuntu (github action) */ - $workerCommandArray[] = \escapeshellarg($input->getOption(\Rector\Core\Configuration\Option::CONFIG)); + $workerCommandArray[] = \escapeshellarg($input->getOption(Option::CONFIG)); } return \implode(' ', $workerCommandArray); } - private function shouldSkipOption(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, string $optionName) : bool + private function shouldSkipOption(InputInterface $input, string $optionName) : bool { if (!$input->hasOption($optionName)) { return \true; } // skip output format, not relevant in parallel worker command - return $optionName === \Rector\Core\Configuration\Option::OUTPUT_FORMAT; + return $optionName === Option::OUTPUT_FORMAT; } /** * @return string[] */ - private function getCommandOptionNames(\RectorPrefix20220607\Symfony\Component\Console\Command\Command $command) : array + private function getCommandOptionNames(Command $command) : array { $inputDefinition = $command->getDefinition(); $optionNames = []; @@ -119,7 +119,7 @@ final class WorkerCommandLineFactory * @param string[] $mainCommandOptionNames * @return string[] */ - private function mirrorCommandOptions(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, array $mainCommandOptionNames) : array + private function mirrorCommandOptions(InputInterface $input, array $mainCommandOptionNames) : array { $workerCommandOptions = []; foreach ($mainCommandOptionNames as $mainCommandOptionName) { diff --git a/packages/Parallel/WorkerRunner.php b/packages/Parallel/WorkerRunner.php index 25ef0cd15ff..c343dddd914 100644 --- a/packages/Parallel/WorkerRunner.php +++ b/packages/Parallel/WorkerRunner.php @@ -17,7 +17,7 @@ use RectorPrefix20220607\Symplify\EasyParallel\Enum\Action; use RectorPrefix20220607\Symplify\EasyParallel\Enum\ReactCommand; use RectorPrefix20220607\Symplify\EasyParallel\Enum\ReactEvent; use RectorPrefix20220607\Symplify\PackageBuilder\Yaml\ParametersMerger; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; use Throwable; final class WorkerRunner { @@ -50,7 +50,7 @@ final class WorkerRunner * @var \Rector\Core\StaticReflection\DynamicSourceLocatorDecorator */ private $dynamicSourceLocatorDecorator; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Yaml\ParametersMerger $parametersMerger, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \Rector\Core\Application\FileProcessor\PhpFileProcessor $phpFileProcessor, \PHPStan\Analyser\NodeScopeResolver $nodeScopeResolver, \Rector\Core\StaticReflection\DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator) + public function __construct(ParametersMerger $parametersMerger, CurrentFileProvider $currentFileProvider, PhpFileProcessor $phpFileProcessor, NodeScopeResolver $nodeScopeResolver, DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator) { $this->parametersMerger = $parametersMerger; $this->currentFileProvider = $currentFileProvider; @@ -58,51 +58,51 @@ final class WorkerRunner $this->nodeScopeResolver = $nodeScopeResolver; $this->dynamicSourceLocatorDecorator = $dynamicSourceLocatorDecorator; } - public function run(\RectorPrefix20220607\Clue\React\NDJson\Encoder $encoder, \RectorPrefix20220607\Clue\React\NDJson\Decoder $decoder, \Rector\Core\ValueObject\Configuration $configuration) : void + public function run(Encoder $encoder, Decoder $decoder, Configuration $configuration) : void { $this->dynamicSourceLocatorDecorator->addPaths($configuration->getPaths()); // 1. handle system error - $handleErrorCallback = static function (\Throwable $throwable) use($encoder) : void { - $systemErrors = new \Rector\Core\ValueObject\Error\SystemError($throwable->getMessage(), $throwable->getFile(), $throwable->getLine()); - $encoder->write([\RectorPrefix20220607\Symplify\EasyParallel\Enum\ReactCommand::ACTION => \RectorPrefix20220607\Symplify\EasyParallel\Enum\Action::RESULT, self::RESULT => [\Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS => [$systemErrors], \Rector\Parallel\ValueObject\Bridge::FILES_COUNT => 0, \Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS_COUNT => 1]]); + $handleErrorCallback = static function (Throwable $throwable) use($encoder) : void { + $systemErrors = new SystemError($throwable->getMessage(), $throwable->getFile(), $throwable->getLine()); + $encoder->write([ReactCommand::ACTION => Action::RESULT, self::RESULT => [Bridge::SYSTEM_ERRORS => [$systemErrors], Bridge::FILES_COUNT => 0, Bridge::SYSTEM_ERRORS_COUNT => 1]]); $encoder->end(); }; - $encoder->on(\RectorPrefix20220607\Symplify\EasyParallel\Enum\ReactEvent::ERROR, $handleErrorCallback); + $encoder->on(ReactEvent::ERROR, $handleErrorCallback); // 2. collect diffs + errors from file processor - $decoder->on(\RectorPrefix20220607\Symplify\EasyParallel\Enum\ReactEvent::DATA, function (array $json) use($encoder, $configuration) : void { - $action = $json[\RectorPrefix20220607\Symplify\EasyParallel\Enum\ReactCommand::ACTION]; - if ($action !== \RectorPrefix20220607\Symplify\EasyParallel\Enum\Action::MAIN) { + $decoder->on(ReactEvent::DATA, function (array $json) use($encoder, $configuration) : void { + $action = $json[ReactCommand::ACTION]; + if ($action !== Action::MAIN) { return; } $systemErrorsCount = 0; /** @var string[] $filePaths */ - $filePaths = $json[\Rector\Parallel\ValueObject\Bridge::FILES] ?? []; + $filePaths = $json[Bridge::FILES] ?? []; $errorAndFileDiffs = []; $systemErrors = []; // 1. allow PHPStan to work with static reflection on provided files $this->nodeScopeResolver->setAnalysedFiles($filePaths); foreach ($filePaths as $filePath) { try { - $smartFileInfo = new \Symplify\SmartFileSystem\SmartFileInfo($filePath); - $file = new \Rector\Core\ValueObject\Application\File($smartFileInfo, $smartFileInfo->getContents()); + $smartFileInfo = new SmartFileInfo($filePath); + $file = new File($smartFileInfo, $smartFileInfo->getContents()); $this->currentFileProvider->setFile($file); if (!$this->phpFileProcessor->supports($file, $configuration)) { continue; } $currentErrorsAndFileDiffs = $this->phpFileProcessor->process($file, $configuration); $errorAndFileDiffs = $this->parametersMerger->merge($errorAndFileDiffs, $currentErrorsAndFileDiffs); - } catch (\Throwable $throwable) { + } catch (Throwable $throwable) { ++$systemErrorsCount; $errorMessage = \sprintf('System error: "%s"', $throwable->getMessage()) . \PHP_EOL; $errorMessage .= 'Run Rector with "--debug" option and post the report here: https://github.com/rectorphp/rector/issues/new'; - $systemErrors[] = new \Rector\Core\ValueObject\Error\SystemError($errorMessage, $filePath, $throwable->getLine()); + $systemErrors[] = new SystemError($errorMessage, $filePath, $throwable->getLine()); } } /** * this invokes all listeners listening $decoder->on(...) @see \Symplify\EasyParallel\Enum\ReactEvent::DATA */ - $encoder->write([\RectorPrefix20220607\Symplify\EasyParallel\Enum\ReactCommand::ACTION => \RectorPrefix20220607\Symplify\EasyParallel\Enum\Action::RESULT, self::RESULT => [\Rector\Parallel\ValueObject\Bridge::FILE_DIFFS => $errorAndFileDiffs[\Rector\Parallel\ValueObject\Bridge::FILE_DIFFS] ?? [], \Rector\Parallel\ValueObject\Bridge::FILES_COUNT => \count($filePaths), \Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS => $systemErrors, \Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS_COUNT => $systemErrorsCount]]); + $encoder->write([ReactCommand::ACTION => Action::RESULT, self::RESULT => [Bridge::FILE_DIFFS => $errorAndFileDiffs[Bridge::FILE_DIFFS] ?? [], Bridge::FILES_COUNT => \count($filePaths), Bridge::SYSTEM_ERRORS => $systemErrors, Bridge::SYSTEM_ERRORS_COUNT => $systemErrorsCount]]); }); - $decoder->on(\RectorPrefix20220607\Symplify\EasyParallel\Enum\ReactEvent::ERROR, $handleErrorCallback); + $decoder->on(ReactEvent::ERROR, $handleErrorCallback); } } diff --git a/packages/PhpAttribute/AnnotationToAttributeMapper.php b/packages/PhpAttribute/AnnotationToAttributeMapper.php index 2980f6a3c44..cb893e6b387 100644 --- a/packages/PhpAttribute/AnnotationToAttributeMapper.php +++ b/packages/PhpAttribute/AnnotationToAttributeMapper.php @@ -36,14 +36,14 @@ final class AnnotationToAttributeMapper return $annotationToAttributeMapper->map($value); } } - if ($value instanceof \PhpParser\Node\Expr) { + if ($value instanceof Expr) { return $value; } // remove node, as handled elsewhere - if ($value instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { - return \Rector\PhpAttribute\Enum\DocTagNodeState::REMOVE_ARRAY; + if ($value instanceof DoctrineAnnotationTagValueNode) { + return DocTagNodeState::REMOVE_ARRAY; } // fallback - return \PhpParser\BuilderHelpers::normalizeValue($value); + return BuilderHelpers::normalizeValue($value); } } diff --git a/packages/PhpAttribute/AnnotationToAttributeMapper/ArrayAnnotationToAttributeMapper.php b/packages/PhpAttribute/AnnotationToAttributeMapper/ArrayAnnotationToAttributeMapper.php index b4ff576eb49..c423ccf115e 100644 --- a/packages/PhpAttribute/AnnotationToAttributeMapper/ArrayAnnotationToAttributeMapper.php +++ b/packages/PhpAttribute/AnnotationToAttributeMapper/ArrayAnnotationToAttributeMapper.php @@ -14,7 +14,7 @@ use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @implements AnnotationToAttributeMapperInterface */ -final class ArrayAnnotationToAttributeMapper implements \Rector\PhpAttribute\Contract\AnnotationToAttributeMapperInterface +final class ArrayAnnotationToAttributeMapper implements AnnotationToAttributeMapperInterface { /** * @var \Rector\PhpAttribute\AnnotationToAttributeMapper @@ -24,7 +24,7 @@ final class ArrayAnnotationToAttributeMapper implements \Rector\PhpAttribute\Con * Avoid circular reference * @required */ - public function autowire(\Rector\PhpAttribute\AnnotationToAttributeMapper $annotationToAttributeMapper) : void + public function autowire(AnnotationToAttributeMapper $annotationToAttributeMapper) : void { $this->annotationToAttributeMapper = $annotationToAttributeMapper; } @@ -38,16 +38,16 @@ final class ArrayAnnotationToAttributeMapper implements \Rector\PhpAttribute\Con /** * @param mixed[] $value */ - public function map($value) : \PhpParser\Node\Expr + public function map($value) : Expr { $arrayItems = []; foreach ($value as $key => $singleValue) { $valueExpr = $this->annotationToAttributeMapper->map($singleValue); // remove node - if ($valueExpr === \Rector\PhpAttribute\Enum\DocTagNodeState::REMOVE_ARRAY) { + if ($valueExpr === DocTagNodeState::REMOVE_ARRAY) { continue; } - \RectorPrefix20220607\Webmozart\Assert\Assert::isInstanceOf($valueExpr, \PhpParser\Node\Expr::class); + Assert::isInstanceOf($valueExpr, Expr::class); // remove value if ($this->isRemoveArrayPlaceholder($singleValue)) { continue; @@ -55,11 +55,11 @@ final class ArrayAnnotationToAttributeMapper implements \Rector\PhpAttribute\Con $keyExpr = null; if (!\is_int($key)) { $keyExpr = $this->annotationToAttributeMapper->map($key); - \RectorPrefix20220607\Webmozart\Assert\Assert::isInstanceOf($keyExpr, \PhpParser\Node\Expr::class); + Assert::isInstanceOf($keyExpr, Expr::class); } - $arrayItems[] = new \PhpParser\Node\Expr\ArrayItem($valueExpr, $keyExpr); + $arrayItems[] = new ArrayItem($valueExpr, $keyExpr); } - return new \PhpParser\Node\Expr\Array_($arrayItems); + return new Array_($arrayItems); } /** * @param mixed $value @@ -69,6 +69,6 @@ final class ArrayAnnotationToAttributeMapper implements \Rector\PhpAttribute\Con if (!\is_array($value)) { return \false; } - return \in_array(\Rector\PhpAttribute\Enum\DocTagNodeState::REMOVE_ARRAY, $value, \true); + return \in_array(DocTagNodeState::REMOVE_ARRAY, $value, \true); } } diff --git a/packages/PhpAttribute/AnnotationToAttributeMapper/ClassConstFetchAnnotationToAttributeMapper.php b/packages/PhpAttribute/AnnotationToAttributeMapper/ClassConstFetchAnnotationToAttributeMapper.php index 9e19f13c4f8..ba47cec0b93 100644 --- a/packages/PhpAttribute/AnnotationToAttributeMapper/ClassConstFetchAnnotationToAttributeMapper.php +++ b/packages/PhpAttribute/AnnotationToAttributeMapper/ClassConstFetchAnnotationToAttributeMapper.php @@ -9,7 +9,7 @@ use Rector\PhpAttribute\Contract\AnnotationToAttributeMapperInterface; /** * @implements AnnotationToAttributeMapperInterface */ -final class ClassConstFetchAnnotationToAttributeMapper implements \Rector\PhpAttribute\Contract\AnnotationToAttributeMapperInterface +final class ClassConstFetchAnnotationToAttributeMapper implements AnnotationToAttributeMapperInterface { /** * @param mixed $value @@ -27,6 +27,6 @@ final class ClassConstFetchAnnotationToAttributeMapper implements \Rector\PhpAtt public function map($value) : \PhpParser\Node\Expr { [$class, $constant] = \explode('::', $value); - return new \PhpParser\Node\Expr\ClassConstFetch(new \PhpParser\Node\Name($class), $constant); + return new ClassConstFetch(new Name($class), $constant); } } diff --git a/packages/PhpAttribute/AnnotationToAttributeMapper/ConstExprNodeAnnotationToAttributeMapper.php b/packages/PhpAttribute/AnnotationToAttributeMapper/ConstExprNodeAnnotationToAttributeMapper.php index c7aef19d11d..ca9a7c421c9 100644 --- a/packages/PhpAttribute/AnnotationToAttributeMapper/ConstExprNodeAnnotationToAttributeMapper.php +++ b/packages/PhpAttribute/AnnotationToAttributeMapper/ConstExprNodeAnnotationToAttributeMapper.php @@ -16,32 +16,32 @@ use Rector\PhpAttribute\Contract\AnnotationToAttributeMapperInterface; /** * @implements AnnotationToAttributeMapperInterface */ -final class ConstExprNodeAnnotationToAttributeMapper implements \Rector\PhpAttribute\Contract\AnnotationToAttributeMapperInterface +final class ConstExprNodeAnnotationToAttributeMapper implements AnnotationToAttributeMapperInterface { /** * @param mixed $value */ public function isCandidate($value) : bool { - return $value instanceof \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode; + return $value instanceof ConstExprNode; } /** * @param ConstExprNode $value */ - public function map($value) : \PhpParser\Node\Expr + public function map($value) : Expr { - if ($value instanceof \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode) { - return \PhpParser\BuilderHelpers::normalizeValue((int) $value->value); + if ($value instanceof ConstExprIntegerNode) { + return BuilderHelpers::normalizeValue((int) $value->value); } - if ($value instanceof \PHPStan\Type\Constant\ConstantFloatType || $value instanceof \PHPStan\Type\Constant\ConstantBooleanType) { - return \PhpParser\BuilderHelpers::normalizeValue($value->getValue()); + if ($value instanceof ConstantFloatType || $value instanceof ConstantBooleanType) { + return BuilderHelpers::normalizeValue($value->getValue()); } - if ($value instanceof \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprTrueNode) { - return \PhpParser\BuilderHelpers::normalizeValue(\true); + if ($value instanceof ConstExprTrueNode) { + return BuilderHelpers::normalizeValue(\true); } - if ($value instanceof \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprFalseNode) { - return \PhpParser\BuilderHelpers::normalizeValue(\false); + if ($value instanceof ConstExprFalseNode) { + return BuilderHelpers::normalizeValue(\false); } - throw new \Rector\Core\Exception\NotImplementedYetException(); + throw new NotImplementedYetException(); } } diff --git a/packages/PhpAttribute/AnnotationToAttributeMapper/CurlyListNodeAnnotationToAttributeMapper.php b/packages/PhpAttribute/AnnotationToAttributeMapper/CurlyListNodeAnnotationToAttributeMapper.php index afd3ec4d26d..d56f2c3115f 100644 --- a/packages/PhpAttribute/AnnotationToAttributeMapper/CurlyListNodeAnnotationToAttributeMapper.php +++ b/packages/PhpAttribute/AnnotationToAttributeMapper/CurlyListNodeAnnotationToAttributeMapper.php @@ -15,7 +15,7 @@ use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @implements AnnotationToAttributeMapperInterface */ -final class CurlyListNodeAnnotationToAttributeMapper implements \Rector\PhpAttribute\Contract\AnnotationToAttributeMapperInterface +final class CurlyListNodeAnnotationToAttributeMapper implements AnnotationToAttributeMapperInterface { /** * @var \Rector\PhpAttribute\AnnotationToAttributeMapper @@ -25,7 +25,7 @@ final class CurlyListNodeAnnotationToAttributeMapper implements \Rector\PhpAttri * Avoid circular reference * @required */ - public function autowire(\Rector\PhpAttribute\AnnotationToAttributeMapper $annotationToAttributeMapper) : void + public function autowire(AnnotationToAttributeMapper $annotationToAttributeMapper) : void { $this->annotationToAttributeMapper = $annotationToAttributeMapper; } @@ -34,7 +34,7 @@ final class CurlyListNodeAnnotationToAttributeMapper implements \Rector\PhpAttri */ public function isCandidate($value) : bool { - return $value instanceof \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode; + return $value instanceof CurlyListNode; } /** * @param CurlyListNode $value @@ -45,17 +45,17 @@ final class CurlyListNodeAnnotationToAttributeMapper implements \Rector\PhpAttri foreach ($value->getValuesWithExplicitSilentAndWithoutQuotes() as $key => $singleValue) { $valueExpr = $this->annotationToAttributeMapper->map($singleValue); // remove node - if ($valueExpr === \Rector\PhpAttribute\Enum\DocTagNodeState::REMOVE_ARRAY) { + if ($valueExpr === DocTagNodeState::REMOVE_ARRAY) { continue; } - \RectorPrefix20220607\Webmozart\Assert\Assert::isInstanceOf($valueExpr, \PhpParser\Node\Expr::class); + Assert::isInstanceOf($valueExpr, Expr::class); $keyExpr = null; if (!\is_int($key)) { $keyExpr = $this->annotationToAttributeMapper->map($key); - \RectorPrefix20220607\Webmozart\Assert\Assert::isInstanceOf($keyExpr, \PhpParser\Node\Expr::class); + Assert::isInstanceOf($keyExpr, Expr::class); } - $arrayItems[] = new \PhpParser\Node\Expr\ArrayItem($valueExpr, $keyExpr); + $arrayItems[] = new ArrayItem($valueExpr, $keyExpr); } - return new \PhpParser\Node\Expr\Array_($arrayItems); + return new Array_($arrayItems); } } diff --git a/packages/PhpAttribute/AnnotationToAttributeMapper/DoctrineAnnotationAnnotationToAttributeMapper.php b/packages/PhpAttribute/AnnotationToAttributeMapper/DoctrineAnnotationAnnotationToAttributeMapper.php index d8a9ffa72b1..5e6c8ec6929 100644 --- a/packages/PhpAttribute/AnnotationToAttributeMapper/DoctrineAnnotationAnnotationToAttributeMapper.php +++ b/packages/PhpAttribute/AnnotationToAttributeMapper/DoctrineAnnotationAnnotationToAttributeMapper.php @@ -19,7 +19,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements AnnotationToAttributeMapperInterface */ -final class DoctrineAnnotationAnnotationToAttributeMapper implements \Rector\PhpAttribute\Contract\AnnotationToAttributeMapperInterface +final class DoctrineAnnotationAnnotationToAttributeMapper implements AnnotationToAttributeMapperInterface { /** * @var \Rector\PhpAttribute\AnnotationToAttributeMapper @@ -40,7 +40,7 @@ final class DoctrineAnnotationAnnotationToAttributeMapper implements \Rector\Php * @var \Rector\PhpAttribute\AttributeArrayNameInliner */ private $attributeArrayNameInliner; - public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider, \Rector\PhpAttribute\UnwrapableAnnotationAnalyzer $unwrapableAnnotationAnalyzer, \Rector\PhpAttribute\AttributeArrayNameInliner $attributeArrayNameInliner) + public function __construct(PhpVersionProvider $phpVersionProvider, UnwrapableAnnotationAnalyzer $unwrapableAnnotationAnalyzer, AttributeArrayNameInliner $attributeArrayNameInliner) { $this->phpVersionProvider = $phpVersionProvider; $this->unwrapableAnnotationAnalyzer = $unwrapableAnnotationAnalyzer; @@ -50,7 +50,7 @@ final class DoctrineAnnotationAnnotationToAttributeMapper implements \Rector\Php * Avoid circular reference * @required */ - public function autowire(\Rector\PhpAttribute\AnnotationToAttributeMapper $annotationToAttributeMapper) : void + public function autowire(AnnotationToAttributeMapper $annotationToAttributeMapper) : void { $this->annotationToAttributeMapper = $annotationToAttributeMapper; } @@ -59,7 +59,7 @@ final class DoctrineAnnotationAnnotationToAttributeMapper implements \Rector\Php */ public function isCandidate($value) : bool { - if (!$value instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$value instanceof DoctrineAnnotationTagValueNode) { return \false; } return !$this->unwrapableAnnotationAnalyzer->areUnwrappable([$value]); @@ -70,25 +70,25 @@ final class DoctrineAnnotationAnnotationToAttributeMapper implements \Rector\Php public function map($value) : \PhpParser\Node\Expr { // if PHP 8.0- throw exception - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::NEW_INITIALIZERS)) { - throw new \Rector\PhpAttribute\Exception\InvalidNestedAttributeException(); + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::NEW_INITIALIZERS)) { + throw new InvalidNestedAttributeException(); } $annotationShortName = $this->resolveAnnotationName($value); $values = $value->getValues(); if ($values !== []) { $argValues = $this->annotationToAttributeMapper->map($value->getValuesWithExplicitSilentAndWithoutQuotes()); - if ($argValues instanceof \PhpParser\Node\Expr\Array_) { + if ($argValues instanceof Array_) { // create named args $args = $this->attributeArrayNameInliner->inlineArrayToArgs($argValues); } else { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } } else { $args = []; } - return new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name($annotationShortName), $args); + return new New_(new Name($annotationShortName), $args); } - private function resolveAnnotationName(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : string + private function resolveAnnotationName(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : string { $annotationShortName = $doctrineAnnotationTagValueNode->identifierTypeNode->name; return \ltrim($annotationShortName, '@'); diff --git a/packages/PhpAttribute/AnnotationToAttributeMapper/StringAnnotationToAttributeMapper.php b/packages/PhpAttribute/AnnotationToAttributeMapper/StringAnnotationToAttributeMapper.php index d85848fc078..b8908107f16 100644 --- a/packages/PhpAttribute/AnnotationToAttributeMapper/StringAnnotationToAttributeMapper.php +++ b/packages/PhpAttribute/AnnotationToAttributeMapper/StringAnnotationToAttributeMapper.php @@ -13,7 +13,7 @@ use Rector\PhpAttribute\Contract\AnnotationToAttributeMapperInterface; /** * @implements AnnotationToAttributeMapperInterface */ -final class StringAnnotationToAttributeMapper implements \Rector\PhpAttribute\Contract\AnnotationToAttributeMapperInterface +final class StringAnnotationToAttributeMapper implements AnnotationToAttributeMapperInterface { /** * @param mixed $value @@ -25,26 +25,26 @@ final class StringAnnotationToAttributeMapper implements \Rector\PhpAttribute\Co /** * @param string $value */ - public function map($value) : \PhpParser\Node\Expr + public function map($value) : Expr { if (\strtolower($value) === 'true') { - return new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('true')); + return new ConstFetch(new Name('true')); } if (\strtolower($value) === 'false') { - return new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('false')); + return new ConstFetch(new Name('false')); } if (\strtolower($value) === 'null') { - return new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('null')); + return new ConstFetch(new Name('null')); } // number as string to number if (\is_numeric($value) && \strlen((string) (int) $value) === \strlen($value)) { - return \PhpParser\Node\Scalar\LNumber::fromString($value); + return LNumber::fromString($value); } if (\strpos($value, "'") !== \false && \strpos($value, "\n") === \false) { - $kind = \PhpParser\Node\Scalar\String_::KIND_DOUBLE_QUOTED; + $kind = String_::KIND_DOUBLE_QUOTED; } else { - $kind = \PhpParser\Node\Scalar\String_::KIND_SINGLE_QUOTED; + $kind = String_::KIND_SINGLE_QUOTED; } - return new \PhpParser\Node\Scalar\String_($value, [\Rector\NodeTypeResolver\Node\AttributeKey::KIND => $kind]); + return new String_($value, [AttributeKey::KIND => $kind]); } } diff --git a/packages/PhpAttribute/AttributeArrayNameInliner.php b/packages/PhpAttribute/AttributeArrayNameInliner.php index 3a172e6c283..37ea3d0e4ad 100644 --- a/packages/PhpAttribute/AttributeArrayNameInliner.php +++ b/packages/PhpAttribute/AttributeArrayNameInliner.php @@ -26,19 +26,19 @@ final class AttributeArrayNameInliner /** * @return Arg[] */ - private function inlineArrayNode(\PhpParser\Node\Expr\Array_ $array) : array + private function inlineArrayNode(Array_ $array) : array { $args = []; foreach ($array->items as $arrayItem) { - if (!$arrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$arrayItem instanceof ArrayItem) { continue; } - if ($arrayItem->key instanceof \PhpParser\Node\Scalar\String_) { + if ($arrayItem->key instanceof String_) { $string = $arrayItem->key; - $argumentName = new \PhpParser\Node\Identifier($string->value); - $args[] = new \PhpParser\Node\Arg($arrayItem->value, \false, \false, [], $argumentName); + $argumentName = new Identifier($string->value); + $args[] = new Arg($arrayItem->value, \false, \false, [], $argumentName); } else { - $args[] = new \PhpParser\Node\Arg($arrayItem->value); + $args[] = new Arg($arrayItem->value); } } return $args; @@ -49,20 +49,20 @@ final class AttributeArrayNameInliner */ private function inlineArray(array $args) : array { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($args, \PhpParser\Node\Arg::class); + Assert::allIsAOf($args, Arg::class); $newArgs = []; foreach ($args as $arg) { // matching top root array key - if ($arg->value instanceof \PhpParser\Node\Expr\ArrayItem) { + if ($arg->value instanceof ArrayItem) { $arrayItem = $arg->value; - if ($arrayItem->key instanceof \PhpParser\Node\Scalar\String_) { + if ($arrayItem->key instanceof String_) { $arrayItemString = $arrayItem->key; - $newArgs[] = new \PhpParser\Node\Arg($arrayItem->value, \false, \false, [], new \PhpParser\Node\Identifier($arrayItemString->value)); + $newArgs[] = new Arg($arrayItem->value, \false, \false, [], new Identifier($arrayItemString->value)); } elseif ($arrayItem->key === null) { // silent key - $newArgs[] = new \PhpParser\Node\Arg($arrayItem->value); + $newArgs[] = new Arg($arrayItem->value); } else { - throw new \Rector\Core\Exception\NotImplementedYetException(\get_debug_type($arrayItem->key)); + throw new NotImplementedYetException(\get_debug_type($arrayItem->key)); } } } diff --git a/packages/PhpAttribute/Contract/AnnotationToAttributeMapperInterface.php b/packages/PhpAttribute/Contract/AnnotationToAttributeMapperInterface.php index 83f65057ffd..6d337187c6e 100644 --- a/packages/PhpAttribute/Contract/AnnotationToAttributeMapperInterface.php +++ b/packages/PhpAttribute/Contract/AnnotationToAttributeMapperInterface.php @@ -16,5 +16,5 @@ interface AnnotationToAttributeMapperInterface /** * @param T $value */ - public function map($value) : \PhpParser\Node\Expr; + public function map($value) : Expr; } diff --git a/packages/PhpAttribute/Exception/InvalidNestedAttributeException.php b/packages/PhpAttribute/Exception/InvalidNestedAttributeException.php index 50e051adaa4..99aea44b36d 100644 --- a/packages/PhpAttribute/Exception/InvalidNestedAttributeException.php +++ b/packages/PhpAttribute/Exception/InvalidNestedAttributeException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace Rector\PhpAttribute\Exception; use Exception; -final class InvalidNestedAttributeException extends \Exception +final class InvalidNestedAttributeException extends Exception { } diff --git a/packages/PhpAttribute/NodeAnalyzer/ExprParameterReflectionTypeCorrector.php b/packages/PhpAttribute/NodeAnalyzer/ExprParameterReflectionTypeCorrector.php index 0b880a907d5..7e47d25aefb 100644 --- a/packages/PhpAttribute/NodeAnalyzer/ExprParameterReflectionTypeCorrector.php +++ b/packages/PhpAttribute/NodeAnalyzer/ExprParameterReflectionTypeCorrector.php @@ -32,7 +32,7 @@ final class ExprParameterReflectionTypeCorrector * @var \Rector\Core\PhpParser\Node\NodeFactory */ private $nodeFactory; - public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory) + public function __construct(StaticTypeMapper $staticTypeMapper, ReflectionProvider $reflectionProvider, NodeFactory $nodeFactory) { $this->staticTypeMapper = $staticTypeMapper; $this->reflectionProvider = $reflectionProvider; @@ -44,7 +44,7 @@ final class ExprParameterReflectionTypeCorrector */ public function correctItemsByAttributeClass($items, string $attributeClass) : array { - if ($items instanceof \PhpParser\Node\Expr\Array_) { + if ($items instanceof Array_) { $items = $items->items; } if (!$this->reflectionProvider->hasClass($attributeClass)) { @@ -56,11 +56,11 @@ final class ExprParameterReflectionTypeCorrector return $items; } $constructorClassMethodReflection = $attributeClassReflection->getConstructor(); - $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($constructorClassMethodReflection->getVariants()); + $parametersAcceptor = ParametersAcceptorSelector::selectSingle($constructorClassMethodReflection->getVariants()); foreach ($items as $name => $item) { foreach ($parametersAcceptor->getParameters() as $parameterReflection) { $correctedItem = $this->correctItemByParameterReflection($name, $item, $parameterReflection); - if (!$correctedItem instanceof \PhpParser\Node\Expr) { + if (!$correctedItem instanceof Expr) { continue; } $items[$name] = $correctedItem; @@ -74,9 +74,9 @@ final class ExprParameterReflectionTypeCorrector * @return \PhpParser\Node\Expr|null * @param mixed $item */ - private function correctItemByParameterReflection($name, $item, \PHPStan\Reflection\ParameterReflection $parameterReflection) + private function correctItemByParameterReflection($name, $item, ParameterReflection $parameterReflection) { - if (!$item instanceof \PhpParser\Node\Expr) { + if (!$item instanceof Expr) { return null; } if ($name !== $parameterReflection->getName()) { @@ -88,12 +88,12 @@ final class ExprParameterReflectionTypeCorrector if ($parameterType->accepts($currentType, \false)->yes()) { return null; } - $clearParameterType = \PHPStan\Type\TypeCombinator::removeNull($parameterType); + $clearParameterType = TypeCombinator::removeNull($parameterType); // correct type - if ($clearParameterType instanceof \PHPStan\Type\IntegerType && $item instanceof \PhpParser\Node\Scalar\String_) { - return new \PhpParser\Node\Scalar\LNumber((int) $item->value); + if ($clearParameterType instanceof IntegerType && $item instanceof String_) { + return new LNumber((int) $item->value); } - if ($clearParameterType instanceof \PHPStan\Type\BooleanType && $item instanceof \PhpParser\Node\Scalar\String_) { + if ($clearParameterType instanceof BooleanType && $item instanceof String_) { if (\strtolower($item->value) === 'true') { return $this->nodeFactory->createTrue(); } diff --git a/packages/PhpAttribute/NodeFactory/AttributeNameFactory.php b/packages/PhpAttribute/NodeFactory/AttributeNameFactory.php index f996bce91c7..fce4201b022 100644 --- a/packages/PhpAttribute/NodeFactory/AttributeNameFactory.php +++ b/packages/PhpAttribute/NodeFactory/AttributeNameFactory.php @@ -17,7 +17,7 @@ final class AttributeNameFactory * @var \Rector\PhpAttribute\UseAliasNameMatcher */ private $useAliasNameMatcher; - public function __construct(\Rector\PhpAttribute\UseAliasNameMatcher $useAliasNameMatcher) + public function __construct(UseAliasNameMatcher $useAliasNameMatcher) { $this->useAliasNameMatcher = $useAliasNameMatcher; } @@ -25,27 +25,27 @@ final class AttributeNameFactory * @param Use_[] $uses * @return \PhpParser\Node\Name\FullyQualified|\PhpParser\Node\Name */ - public function create(\Rector\Php80\ValueObject\AnnotationToAttribute $annotationToAttribute, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, array $uses) + public function create(AnnotationToAttribute $annotationToAttribute, DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, array $uses) { // A. attribute and class name are the same, so we re-use the short form to keep code compatible with previous one if ($annotationToAttribute->getAttributeClass() === $annotationToAttribute->getTag()) { $attributeName = $doctrineAnnotationTagValueNode->identifierTypeNode->name; $attributeName = \ltrim($attributeName, '@'); - return new \PhpParser\Node\Name($attributeName); + return new Name($attributeName); } // B. different name $useAliasMetadata = $this->useAliasNameMatcher->match($uses, $doctrineAnnotationTagValueNode->identifierTypeNode->name, $annotationToAttribute); - if ($useAliasMetadata instanceof \Rector\PhpAttribute\ValueObject\UseAliasMetadata) { + if ($useAliasMetadata instanceof UseAliasMetadata) { $useUse = $useAliasMetadata->getUseUse(); // is same as name? $useImportName = $useAliasMetadata->getUseImportName(); if ($useUse->name->toString() !== $useImportName) { // no? rename - $useUse->name = new \PhpParser\Node\Name($useImportName); + $useUse->name = new Name($useImportName); } - return new \PhpParser\Node\Name($useAliasMetadata->getShortAttributeName()); + return new Name($useAliasMetadata->getShortAttributeName()); } // 3. the class is not aliased and is compeltelly new... return the FQN version - return new \PhpParser\Node\Name\FullyQualified($annotationToAttribute->getAttributeClass()); + return new FullyQualified($annotationToAttribute->getAttributeClass()); } } diff --git a/packages/PhpAttribute/NodeFactory/DoctrineAnnotationFactory.php b/packages/PhpAttribute/NodeFactory/DoctrineAnnotationFactory.php index 9335b3426b2..94f1189ad3d 100644 --- a/packages/PhpAttribute/NodeFactory/DoctrineAnnotationFactory.php +++ b/packages/PhpAttribute/NodeFactory/DoctrineAnnotationFactory.php @@ -17,15 +17,15 @@ final class DoctrineAnnotationFactory * @var \Rector\Core\Contract\PhpParser\NodePrinterInterface */ private $nodePrinter; - public function __construct(\Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter) + public function __construct(NodePrinterInterface $nodePrinter) { $this->nodePrinter = $nodePrinter; } - public function createFromAttribute(\PhpParser\Node\Attribute $attribute, string $className) : \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode + public function createFromAttribute(Attribute $attribute, string $className) : DoctrineAnnotationTagValueNode { $items = $this->createItemsFromArgs($attribute->args); - $identifierTypeNode = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($className); - return new \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode($identifierTypeNode, null, $items); + $identifierTypeNode = new IdentifierTypeNode($className); + return new DoctrineAnnotationTagValueNode($identifierTypeNode, null, $items); } /** * @param Arg[] $args @@ -35,9 +35,9 @@ final class DoctrineAnnotationFactory { $items = []; foreach ($args as $arg) { - if ($arg->value instanceof \PhpParser\Node\Scalar\String_) { + if ($arg->value instanceof String_) { // standardize double quotes for annotations - $arg->value->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND, \PhpParser\Node\Scalar\String_::KIND_DOUBLE_QUOTED); + $arg->value->setAttribute(AttributeKey::KIND, String_::KIND_DOUBLE_QUOTED); } $itemValue = $this->nodePrinter->print($arg->value); if ($arg->name !== null) { diff --git a/packages/PhpAttribute/NodeFactory/NamedArgsFactory.php b/packages/PhpAttribute/NodeFactory/NamedArgsFactory.php index 15e4150b8f1..d37e1289979 100644 --- a/packages/PhpAttribute/NodeFactory/NamedArgsFactory.php +++ b/packages/PhpAttribute/NodeFactory/NamedArgsFactory.php @@ -29,21 +29,21 @@ final class NamedArgsFactory { $args = []; foreach ($values as $key => $argValue) { - $expr = \PhpParser\BuilderHelpers::normalizeValue($argValue); + $expr = BuilderHelpers::normalizeValue($argValue); $this->normalizeArrayWithConstFetchKey($expr); $name = null; // for named arguments if (\is_string($key)) { - $name = new \PhpParser\Node\Identifier($key); + $name = new Identifier($key); } $this->normalizeStringDoubleQuote($expr); - $args[] = new \PhpParser\Node\Arg($expr, \false, \false, [], $name); + $args[] = new Arg($expr, \false, \false, [], $name); } return $args; } - private function normalizeStringDoubleQuote(\PhpParser\Node\Expr $expr) : void + private function normalizeStringDoubleQuote(Expr $expr) : void { - if (!$expr instanceof \PhpParser\Node\Scalar\String_) { + if (!$expr instanceof String_) { return; } // avoid escaping quotes + preserve newlines @@ -53,22 +53,22 @@ final class NamedArgsFactory if (\strpos($expr->value, "\n") !== \false) { return; } - $expr->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND, \PhpParser\Node\Scalar\String_::KIND_DOUBLE_QUOTED); + $expr->setAttribute(AttributeKey::KIND, String_::KIND_DOUBLE_QUOTED); } - private function normalizeArrayWithConstFetchKey(\PhpParser\Node\Expr $expr) : void + private function normalizeArrayWithConstFetchKey(Expr $expr) : void { - if (!$expr instanceof \PhpParser\Node\Expr\Array_) { + if (!$expr instanceof Array_) { return; } foreach ($expr->items as $arrayItem) { - if (!$arrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$arrayItem instanceof ArrayItem) { continue; } - if (!$arrayItem->key instanceof \PhpParser\Node\Scalar\String_) { + if (!$arrayItem->key instanceof String_) { continue; } $string = $arrayItem->key; - $match = \RectorPrefix20220607\Nette\Utils\Strings::match($string->value, self::CLASS_CONST_REGEX); + $match = Strings::match($string->value, self::CLASS_CONST_REGEX); if ($match === null) { continue; } @@ -76,7 +76,7 @@ final class NamedArgsFactory $class = $match['class']; /** @var string $constant */ $constant = $match['constant']; - $arrayItem->key = new \PhpParser\Node\Expr\ClassConstFetch(new \PhpParser\Node\Name($class), $constant); + $arrayItem->key = new ClassConstFetch(new Name($class), $constant); } } } diff --git a/packages/PhpAttribute/NodeFactory/PhpAttributeGroupFactory.php b/packages/PhpAttribute/NodeFactory/PhpAttributeGroupFactory.php index ca6fba0ab6e..7fa2f6dc736 100644 --- a/packages/PhpAttribute/NodeFactory/PhpAttributeGroupFactory.php +++ b/packages/PhpAttribute/NodeFactory/PhpAttributeGroupFactory.php @@ -52,7 +52,7 @@ final class PhpAttributeGroupFactory * @var \Rector\PhpAttribute\AttributeArrayNameInliner */ private $attributeArrayNameInliner; - public function __construct(\Rector\PhpAttribute\AnnotationToAttributeMapper $annotationToAttributeMapper, \Rector\PhpAttribute\NodeFactory\AttributeNameFactory $attributeNameFactory, \Rector\PhpAttribute\NodeFactory\NamedArgsFactory $namedArgsFactory, \Rector\PhpAttribute\NodeAnalyzer\ExprParameterReflectionTypeCorrector $exprParameterReflectionTypeCorrector, \Rector\PhpAttribute\AttributeArrayNameInliner $attributeArrayNameInliner, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(AnnotationToAttributeMapper $annotationToAttributeMapper, \Rector\PhpAttribute\NodeFactory\AttributeNameFactory $attributeNameFactory, \Rector\PhpAttribute\NodeFactory\NamedArgsFactory $namedArgsFactory, ExprParameterReflectionTypeCorrector $exprParameterReflectionTypeCorrector, AttributeArrayNameInliner $attributeArrayNameInliner, PhpVersionProvider $phpVersionProvider) { $this->annotationToAttributeMapper = $annotationToAttributeMapper; $this->attributeNameFactory = $attributeNameFactory; @@ -60,42 +60,42 @@ final class PhpAttributeGroupFactory $this->exprParameterReflectionTypeCorrector = $exprParameterReflectionTypeCorrector; $this->attributeArrayNameInliner = $attributeArrayNameInliner; // nested indexes supported only since PHP 8.1 - if (!$phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::NEW_INITIALIZERS)) { + if (!$phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::NEW_INITIALIZERS)) { $this->unwrappedAnnotations['Doctrine\\ORM\\Mapping\\Table'] = ['indexes', 'uniqueConstraints']; $this->unwrappedAnnotations['Doctrine\\ORM\\Mapping\\Entity'][] = 'uniqueConstraints'; } } - public function createFromSimpleTag(\Rector\Php80\ValueObject\AnnotationToAttribute $annotationToAttribute) : \PhpParser\Node\AttributeGroup + public function createFromSimpleTag(AnnotationToAttribute $annotationToAttribute) : AttributeGroup { return $this->createFromClass($annotationToAttribute->getAttributeClass()); } - public function createFromClass(string $attributeClass) : \PhpParser\Node\AttributeGroup + public function createFromClass(string $attributeClass) : AttributeGroup { - $fullyQualified = new \PhpParser\Node\Name\FullyQualified($attributeClass); - $attribute = new \PhpParser\Node\Attribute($fullyQualified); - return new \PhpParser\Node\AttributeGroup([$attribute]); + $fullyQualified = new FullyQualified($attributeClass); + $attribute = new Attribute($fullyQualified); + return new AttributeGroup([$attribute]); } /** * @param mixed[] $items */ - public function createFromClassWithItems(string $attributeClass, array $items) : \PhpParser\Node\AttributeGroup + public function createFromClassWithItems(string $attributeClass, array $items) : AttributeGroup { - $fullyQualified = new \PhpParser\Node\Name\FullyQualified($attributeClass); + $fullyQualified = new FullyQualified($attributeClass); $args = $this->createArgsFromItems($items, $attributeClass); - $attribute = new \PhpParser\Node\Attribute($fullyQualified, $args); - return new \PhpParser\Node\AttributeGroup([$attribute]); + $attribute = new Attribute($fullyQualified, $args); + return new AttributeGroup([$attribute]); } /** * @param Use_[] $uses */ - public function create(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, \Rector\Php80\ValueObject\AnnotationToAttribute $annotationToAttribute, array $uses) : \PhpParser\Node\AttributeGroup + public function create(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, AnnotationToAttribute $annotationToAttribute, array $uses) : AttributeGroup { $values = $doctrineAnnotationTagValueNode->getValuesWithExplicitSilentAndWithoutQuotes(); $args = $this->createArgsFromItems($values, $annotationToAttribute->getAttributeClass()); $args = $this->attributeArrayNameInliner->inlineArrayToArgs($args); $attributeName = $this->attributeNameFactory->create($annotationToAttribute, $doctrineAnnotationTagValueNode, $uses); - $attribute = new \PhpParser\Node\Attribute($attributeName, $args); - return new \PhpParser\Node\AttributeGroup([$attribute]); + $attribute = new Attribute($attributeName, $args); + return new AttributeGroup([$attribute]); } /** * @param mixed[] $items @@ -121,10 +121,10 @@ final class PhpAttributeGroupFactory return $items; } foreach ($items as $key => $item) { - if (!$item instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$item instanceof ArrayItem) { continue; } - if (!$item->key instanceof \PhpParser\Node\Scalar\String_) { + if (!$item->key instanceof String_) { continue; } $stringItemKey = $item->key; diff --git a/packages/PhpAttribute/RemovableAnnotationAnalyzer.php b/packages/PhpAttribute/RemovableAnnotationAnalyzer.php index 1a46327b6e1..edf39d14d6d 100644 --- a/packages/PhpAttribute/RemovableAnnotationAnalyzer.php +++ b/packages/PhpAttribute/RemovableAnnotationAnalyzer.php @@ -26,12 +26,12 @@ final class RemovableAnnotationAnalyzer { $this->annotationsToAttributes = $annotationsToAttributes; } - public function isRemovable(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : bool + public function isRemovable(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : bool { - $annotationClassName = $doctrineAnnotationTagValueNode->identifierTypeNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::RESOLVED_CLASS); + $annotationClassName = $doctrineAnnotationTagValueNode->identifierTypeNode->getAttribute(PhpDocAttributeKey::RESOLVED_CLASS); $annotationToAttribute = $this->matchAnnotationToAttribute($doctrineAnnotationTagValueNode); // the nested annotation should be convertable - if (!$annotationToAttribute instanceof \Rector\Php80\ValueObject\AnnotationToAttribute) { + if (!$annotationToAttribute instanceof AnnotationToAttribute) { return \false; } return \in_array($annotationClassName, self::REMOVABLE_ANNOTATION_CLASSES, \true); @@ -39,7 +39,7 @@ final class RemovableAnnotationAnalyzer /** * @return \Rector\Php80\ValueObject\AnnotationToAttribute|null */ - private function matchAnnotationToAttribute(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) + private function matchAnnotationToAttribute(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) { foreach ($this->annotationsToAttributes as $annotationToAttribute) { if (!$doctrineAnnotationTagValueNode->hasClassName($annotationToAttribute->getTag())) { diff --git a/packages/PhpAttribute/UnwrapableAnnotationAnalyzer.php b/packages/PhpAttribute/UnwrapableAnnotationAnalyzer.php index b84084397d8..7b9a78ce99b 100644 --- a/packages/PhpAttribute/UnwrapableAnnotationAnalyzer.php +++ b/packages/PhpAttribute/UnwrapableAnnotationAnalyzer.php @@ -25,7 +25,7 @@ final class UnwrapableAnnotationAnalyzer * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PhpVersionProvider $phpVersionProvider) { $this->phpVersionProvider = $phpVersionProvider; } @@ -42,14 +42,14 @@ final class UnwrapableAnnotationAnalyzer public function areUnwrappable(array $doctrineAnnotationTagValueNodes) : bool { // the new in initilazers is handled directly - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::NEW_INITIALIZERS)) { + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::NEW_INITIALIZERS)) { return \false; } foreach ($doctrineAnnotationTagValueNodes as $doctrineAnnotationTagValueNode) { - $annotationClassName = $doctrineAnnotationTagValueNode->identifierTypeNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::RESOLVED_CLASS); + $annotationClassName = $doctrineAnnotationTagValueNode->identifierTypeNode->getAttribute(PhpDocAttributeKey::RESOLVED_CLASS); $nestedAnnotationToAttribute = $this->matchAnnotationToAttribute($doctrineAnnotationTagValueNode); // the nested annotation should be convertable - if (!$nestedAnnotationToAttribute instanceof \Rector\Php80\ValueObject\AnnotationToAttribute) { + if (!$nestedAnnotationToAttribute instanceof AnnotationToAttribute) { return \false; } if (!\in_array($annotationClassName, self::UNWRAPEABLE_ANNOTATION_CLASSES, \true)) { @@ -61,7 +61,7 @@ final class UnwrapableAnnotationAnalyzer /** * @return \Rector\Php80\ValueObject\AnnotationToAttribute|null */ - private function matchAnnotationToAttribute(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) + private function matchAnnotationToAttribute(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) { foreach ($this->annotationsToAttributes as $annotationToAttribute) { if (!$doctrineAnnotationTagValueNode->hasClassName($annotationToAttribute->getTag())) { diff --git a/packages/PhpAttribute/UseAliasNameMatcher.php b/packages/PhpAttribute/UseAliasNameMatcher.php index 6c46ce5ca9a..094f0676cb5 100644 --- a/packages/PhpAttribute/UseAliasNameMatcher.php +++ b/packages/PhpAttribute/UseAliasNameMatcher.php @@ -16,14 +16,14 @@ final class UseAliasNameMatcher /** * @param Use_[] $uses */ - public function match(array $uses, string $shortAnnotationName, \Rector\Php80\ValueObject\AnnotationToAttribute $annotationToAttribute) : ?\Rector\PhpAttribute\ValueObject\UseAliasMetadata + public function match(array $uses, string $shortAnnotationName, AnnotationToAttribute $annotationToAttribute) : ?UseAliasMetadata { $shortAnnotationName = \trim($shortAnnotationName, '@'); foreach ($uses as $use) { foreach ($use->uses as $useUse) { // we need to use original use statement - $originalUseUse = $useUse->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE); - if (!$originalUseUse instanceof \PhpParser\Node\Stmt\UseUse) { + $originalUseUse = $useUse->getAttribute(AttributeKey::ORIGINAL_NODE); + if (!$originalUseUse instanceof UseUse) { continue; } if ($originalUseUse->alias === null) { @@ -51,7 +51,7 @@ final class UseAliasNameMatcher // +1, to remove the alias part $attributeParts = \array_slice($attributeParts, -$shortNamePartCount); $shortAttributeName = $alias . '\\' . \implode('\\', $attributeParts); - return new \Rector\PhpAttribute\ValueObject\UseAliasMetadata($shortAttributeName, $newAttributeImport, $useUse); + return new UseAliasMetadata($shortAttributeName, $newAttributeImport, $useUse); } } return null; diff --git a/packages/PhpAttribute/ValueObject/UseAliasMetadata.php b/packages/PhpAttribute/ValueObject/UseAliasMetadata.php index 2a0e0791c97..8f020147c71 100644 --- a/packages/PhpAttribute/ValueObject/UseAliasMetadata.php +++ b/packages/PhpAttribute/ValueObject/UseAliasMetadata.php @@ -21,7 +21,7 @@ final class UseAliasMetadata * @var \PhpParser\Node\Stmt\UseUse */ private $useUse; - public function __construct(string $shortAttributeName, string $useImportName, \PhpParser\Node\Stmt\UseUse $useUse) + public function __construct(string $shortAttributeName, string $useImportName, UseUse $useUse) { $this->shortAttributeName = $shortAttributeName; $this->useImportName = $useImportName; @@ -35,7 +35,7 @@ final class UseAliasMetadata { return $this->useImportName; } - public function getUseUse() : \PhpParser\Node\Stmt\UseUse + public function getUseUse() : UseUse { return $this->useUse; } diff --git a/packages/PostRector/Application/PostFileProcessor.php b/packages/PostRector/Application/PostFileProcessor.php index 57f7b1ff7a4..636cf855b1d 100644 --- a/packages/PostRector/Application/PostFileProcessor.php +++ b/packages/PostRector/Application/PostFileProcessor.php @@ -35,7 +35,7 @@ final class PostFileProcessor /** * @param PostRectorInterface[] $postRectors */ - public function __construct(\RectorPrefix20220607\Symplify\Skipper\Skipper\Skipper $skipper, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \Rector\Core\Logging\CurrentRectorProvider $currentRectorProvider, array $postRectors) + public function __construct(Skipper $skipper, CurrentFileProvider $currentFileProvider, CurrentRectorProvider $currentRectorProvider, array $postRectors) { $this->skipper = $skipper; $this->currentFileProvider = $currentFileProvider; @@ -53,7 +53,7 @@ final class PostFileProcessor continue; } $this->currentRectorProvider->changeCurrentRector($postRector); - $nodeTraverser = new \PhpParser\NodeTraverser(); + $nodeTraverser = new NodeTraverser(); $nodeTraverser->addVisitor($postRector); $stmts = $nodeTraverser->traverse($stmts); } @@ -68,17 +68,17 @@ final class PostFileProcessor $postRectorsByPriority = []; foreach ($postRectors as $postRector) { if (isset($postRectorsByPriority[$postRector->getPriority()])) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $postRectorsByPriority[$postRector->getPriority()] = $postRector; } \krsort($postRectorsByPriority); return $postRectorsByPriority; } - private function shouldSkipPostRector(\Rector\PostRector\Contract\Rector\PostRectorInterface $postRector) : bool + private function shouldSkipPostRector(PostRectorInterface $postRector) : bool { $file = $this->currentFileProvider->getFile(); - if (!$file instanceof \Rector\Core\ValueObject\Application\File) { + if (!$file instanceof File) { return \false; } $smartFileInfo = $file->getSmartFileInfo(); diff --git a/packages/PostRector/Collector/NodesToAddCollector.php b/packages/PostRector/Collector/NodesToAddCollector.php index ac5763cead2..9fe0ca4d473 100644 --- a/packages/PostRector/Collector/NodesToAddCollector.php +++ b/packages/PostRector/Collector/NodesToAddCollector.php @@ -15,8 +15,8 @@ use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\PhpParser\Node\BetterNodeFinder; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\PostRector\Contract\Collector\NodeCollectorInterface; -use Symplify\SmartFileSystem\SmartFileInfo; -final class NodesToAddCollector implements \Rector\PostRector\Contract\Collector\NodeCollectorInterface +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; +final class NodesToAddCollector implements NodeCollectorInterface { /** * @var Stmt[][] @@ -46,7 +46,7 @@ final class NodesToAddCollector implements \Rector\PostRector\Contract\Collector * @var \Rector\Core\Application\ChangedNodeScopeRefresher */ private $changedNodeScopeRefresher; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\ChangesReporting\Collector\RectorChangeCollector $rectorChangeCollector, \Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter, \Rector\Core\Application\ChangedNodeScopeRefresher $changedNodeScopeRefresher) + public function __construct(BetterNodeFinder $betterNodeFinder, RectorChangeCollector $rectorChangeCollector, NodePrinterInterface $nodePrinter, ChangedNodeScopeRefresher $changedNodeScopeRefresher) { $this->betterNodeFinder = $betterNodeFinder; $this->rectorChangeCollector = $rectorChangeCollector; @@ -60,16 +60,16 @@ final class NodesToAddCollector implements \Rector\PostRector\Contract\Collector /** * @deprecated Return created nodes right in refactor() method to keep context instead. */ - public function addNodeBeforeNode(\PhpParser\Node $addedNode, \PhpParser\Node $positionNode, ?\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo = null) : void + public function addNodeBeforeNode(Node $addedNode, Node $positionNode, ?SmartFileInfo $smartFileInfo = null) : void { if ($positionNode->getAttributes() === []) { $message = \sprintf('Switch arguments in "%s()" method', __METHOD__); - throw new \Rector\Core\Exception\ShouldNotHappenException($message); + throw new ShouldNotHappenException($message); } // @todo the node must be returned here, so traverser can refresh it // this is nasty hack to verify it works - if ($smartFileInfo instanceof \Symplify\SmartFileSystem\SmartFileInfo) { - $currentScope = $positionNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + if ($smartFileInfo instanceof SmartFileInfo) { + $currentScope = $positionNode->getAttribute(AttributeKey::SCOPE); $this->changedNodeScopeRefresher->refresh($addedNode, $smartFileInfo, $currentScope); } $position = $this->resolveNearestStmtPosition($positionNode); @@ -80,12 +80,12 @@ final class NodesToAddCollector implements \Rector\PostRector\Contract\Collector * @param Node[] $addedNodes * @deprecated Return created nodes right in refactor() method to keep context instead. */ - public function addNodesAfterNode(array $addedNodes, \PhpParser\Node $positionNode) : void + public function addNodesAfterNode(array $addedNodes, Node $positionNode) : void { $position = $this->resolveNearestStmtPosition($positionNode); foreach ($addedNodes as $addedNode) { // prevent fluent method weird indent - $addedNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $addedNode->setAttribute(AttributeKey::ORIGINAL_NODE, null); $this->nodesToAddAfter[$position][] = $this->wrapToExpression($addedNode); } $this->rectorChangeCollector->notifyNodeFileInfo($positionNode); @@ -94,7 +94,7 @@ final class NodesToAddCollector implements \Rector\PostRector\Contract\Collector * Better return created nodes right in refactor() method to keep context * @deprecated */ - public function addNodeAfterNode(\PhpParser\Node $addedNode, \PhpParser\Node $positionNode) : void + public function addNodeAfterNode(Node $addedNode, Node $positionNode) : void { $position = $this->resolveNearestStmtPosition($positionNode); $this->nodesToAddAfter[$position][] = $this->wrapToExpression($addedNode); @@ -103,7 +103,7 @@ final class NodesToAddCollector implements \Rector\PostRector\Contract\Collector /** * @return Stmt[] */ - public function getNodesToAddAfterNode(\PhpParser\Node $node) : array + public function getNodesToAddAfterNode(Node $node) : array { $position = \spl_object_hash($node); return $this->nodesToAddAfter[$position] ?? []; @@ -111,17 +111,17 @@ final class NodesToAddCollector implements \Rector\PostRector\Contract\Collector /** * @return Stmt[] */ - public function getNodesToAddBeforeNode(\PhpParser\Node $node) : array + public function getNodesToAddBeforeNode(Node $node) : array { $position = \spl_object_hash($node); return $this->nodesToAddBefore[$position] ?? []; } - public function clearNodesToAddAfter(\PhpParser\Node $node) : void + public function clearNodesToAddAfter(Node $node) : void { $objectHash = \spl_object_hash($node); unset($this->nodesToAddAfter[$objectHash]); } - public function clearNodesToAddBefore(\PhpParser\Node $node) : void + public function clearNodesToAddBefore(Node $node) : void { $objectHash = \spl_object_hash($node); unset($this->nodesToAddBefore[$objectHash]); @@ -130,39 +130,39 @@ final class NodesToAddCollector implements \Rector\PostRector\Contract\Collector * @deprecated Return created nodes right in refactor() method to keep context instead. * @param Node[] $newNodes */ - public function addNodesBeforeNode(array $newNodes, \PhpParser\Node $positionNode) : void + public function addNodesBeforeNode(array $newNodes, Node $positionNode) : void { foreach ($newNodes as $newNode) { $this->addNodeBeforeNode($newNode, $positionNode, null); } $this->rectorChangeCollector->notifyNodeFileInfo($positionNode); } - private function resolveNearestStmtPosition(\PhpParser\Node $node) : string + private function resolveNearestStmtPosition(Node $node) : string { - if ($node instanceof \PhpParser\Node\Stmt) { + if ($node instanceof Stmt) { return \spl_object_hash($node); } $currentStmt = $this->betterNodeFinder->resolveCurrentStatement($node); - if ($currentStmt instanceof \PhpParser\Node\Stmt) { + if ($currentStmt instanceof Stmt) { return \spl_object_hash($currentStmt); } - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\Stmt\Return_) { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof Return_) { return \spl_object_hash($parent); } - $foundNode = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt::class); - if (!$foundNode instanceof \PhpParser\Node\Stmt) { + $foundNode = $this->betterNodeFinder->findParentType($node, Stmt::class); + if (!$foundNode instanceof Stmt) { $printedNode = $this->nodePrinter->print($node); $errorMessage = \sprintf('Could not find parent Stmt of "%s" node', $printedNode); - throw new \Rector\Core\Exception\ShouldNotHappenException($errorMessage); + throw new ShouldNotHappenException($errorMessage); } return \spl_object_hash($foundNode); } /** * @param \PhpParser\Node\Expr|\PhpParser\Node\Stmt $node */ - private function wrapToExpression($node) : \PhpParser\Node\Stmt + private function wrapToExpression($node) : Stmt { - return $node instanceof \PhpParser\Node\Stmt ? $node : new \PhpParser\Node\Stmt\Expression($node); + return $node instanceof Stmt ? $node : new Expression($node); } } diff --git a/packages/PostRector/Collector/NodesToRemoveCollector.php b/packages/PostRector/Collector/NodesToRemoveCollector.php index 0720a509e6f..3e49bd23a88 100644 --- a/packages/PostRector/Collector/NodesToRemoveCollector.php +++ b/packages/PostRector/Collector/NodesToRemoveCollector.php @@ -20,8 +20,8 @@ use Rector\Core\Provider\CurrentFileProvider; use Rector\NodeRemoval\BreakingRemovalGuard; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\PostRector\Contract\Collector\NodeCollectorInterface; -use Symplify\SmartFileSystem\SmartFileInfo; -final class NodesToRemoveCollector implements \Rector\PostRector\Contract\Collector\NodeCollectorInterface +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; +final class NodesToRemoveCollector implements NodeCollectorInterface { /** * @var Stmt[]|Node[] @@ -52,7 +52,7 @@ final class NodesToRemoveCollector implements \Rector\PostRector\Contract\Collec * @var \Rector\Core\Provider\CurrentFileProvider */ private $currentFileProvider; - public function __construct(\Rector\ChangesReporting\Collector\AffectedFilesCollector $affectedFilesCollector, \Rector\NodeRemoval\BreakingRemovalGuard $breakingRemovalGuard, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider) + public function __construct(AffectedFilesCollector $affectedFilesCollector, BreakingRemovalGuard $breakingRemovalGuard, BetterNodeFinder $betterNodeFinder, NodeComparator $nodeComparator, CurrentFileProvider $currentFileProvider) { $this->affectedFilesCollector = $affectedFilesCollector; $this->breakingRemovalGuard = $breakingRemovalGuard; @@ -60,16 +60,16 @@ final class NodesToRemoveCollector implements \Rector\PostRector\Contract\Collec $this->nodeComparator = $nodeComparator; $this->currentFileProvider = $currentFileProvider; } - public function addNodeToRemove(\PhpParser\Node $node) : void + public function addNodeToRemove(Node $node) : void { /** Node|null $parentNode */ - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); if ($parentNode !== null && $this->isUsedInArg($node, $parentNode)) { return; } // chain call: "->method()->another()" $this->ensureIsNotPartOfChainMethodCall($node); - if (!$node instanceof \PhpParser\Node\Stmt\Expression && $parentNode instanceof \PhpParser\Node\Stmt\Expression) { + if (!$node instanceof Expression && $parentNode instanceof Expression) { // only expressions can be removed $node = $parentNode; } else { @@ -83,7 +83,7 @@ final class NodesToRemoveCollector implements \Rector\PostRector\Contract\Collec /** @var Stmt $node */ $this->nodesToRemove[] = $node; } - public function isNodeRemoved(\PhpParser\Node $node) : bool + public function isNodeRemoved(Node $node) : bool { return \in_array($node, $this->nodesToRemove, \true); } @@ -106,37 +106,37 @@ final class NodesToRemoveCollector implements \Rector\PostRector\Contract\Collec { unset($this->nodesToRemove[$key]); } - private function isUsedInArg(\PhpParser\Node $node, \PhpParser\Node $parentNode) : bool + private function isUsedInArg(Node $node, Node $parentNode) : bool { - if (!$node instanceof \PhpParser\Node\Param) { + if (!$node instanceof Param) { return \false; } - if (!$parentNode instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$parentNode instanceof ClassMethod) { return \false; } $paramVariable = $node->var; - if ($paramVariable instanceof \PhpParser\Node\Expr\Variable) { - return (bool) $this->betterNodeFinder->findFirst((array) $parentNode->stmts, function (\PhpParser\Node $node) use($paramVariable) : bool { + if ($paramVariable instanceof Variable) { + return (bool) $this->betterNodeFinder->findFirst((array) $parentNode->stmts, function (Node $node) use($paramVariable) : bool { if (!$this->nodeComparator->areNodesEqual($node, $paramVariable)) { return \false; } - $hasArgParent = (bool) $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Arg::class); + $hasArgParent = (bool) $this->betterNodeFinder->findParentType($node, Arg::class); if (!$hasArgParent) { return \false; } - return !(bool) $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Expr\StaticCall::class); + return !(bool) $this->betterNodeFinder->findParentType($node, StaticCall::class); }); } return \false; } - private function ensureIsNotPartOfChainMethodCall(\PhpParser\Node $node) : void + private function ensureIsNotPartOfChainMethodCall(Node $node) : void { - if (!$node instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$node instanceof MethodCall) { return; } - if (!$node->var instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$node->var instanceof MethodCall) { return; } - throw new \Rector\Core\Exception\ShouldNotHappenException('Chain method calls cannot be removed this way. It would remove the whole tree of calls. Remove them manually by creating new parent node with no following method.'); + throw new ShouldNotHappenException('Chain method calls cannot be removed this way. It would remove the whole tree of calls. Remove them manually by creating new parent node with no following method.'); } } diff --git a/packages/PostRector/Collector/PropertyToAddCollector.php b/packages/PostRector/Collector/PropertyToAddCollector.php index 5340d635056..e355fa2bcd8 100644 --- a/packages/PostRector/Collector/PropertyToAddCollector.php +++ b/packages/PostRector/Collector/PropertyToAddCollector.php @@ -10,7 +10,7 @@ use Rector\ChangesReporting\Collector\RectorChangeCollector; use Rector\NodeNameResolver\NodeNameResolver; use Rector\PostRector\Contract\Collector\NodeCollectorInterface; use Rector\PostRector\ValueObject\PropertyMetadata; -final class PropertyToAddCollector implements \Rector\PostRector\Contract\Collector\NodeCollectorInterface +final class PropertyToAddCollector implements NodeCollectorInterface { /** * @var array> @@ -34,7 +34,7 @@ final class PropertyToAddCollector implements \Rector\PostRector\Contract\Collec * @var \Rector\ChangesReporting\Collector\RectorChangeCollector */ private $rectorChangeCollector; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\ChangesReporting\Collector\RectorChangeCollector $rectorChangeCollector) + public function __construct(NodeNameResolver $nodeNameResolver, RectorChangeCollector $rectorChangeCollector) { $this->nodeNameResolver = $nodeNameResolver; $this->rectorChangeCollector = $rectorChangeCollector; @@ -49,19 +49,19 @@ final class PropertyToAddCollector implements \Rector\PostRector\Contract\Collec } return $this->constantsByClass !== []; } - public function addPropertyToClass(\PhpParser\Node\Stmt\Class_ $class, \Rector\PostRector\ValueObject\PropertyMetadata $propertyMetadata) : void + public function addPropertyToClass(Class_ $class, PropertyMetadata $propertyMetadata) : void { $uniqueHash = \spl_object_hash($class); $this->propertiesByClass[$uniqueHash][] = $propertyMetadata; $this->rectorChangeCollector->notifyNodeFileInfo($class); } - public function addConstantToClass(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\ClassConst $classConst) : void + public function addConstantToClass(Class_ $class, ClassConst $classConst) : void { $constantName = $this->nodeNameResolver->getName($classConst); $this->constantsByClass[\spl_object_hash($class)][$constantName] = $classConst; $this->rectorChangeCollector->notifyNodeFileInfo($class); } - public function addPropertyWithoutConstructorToClass(string $propertyName, ?\PHPStan\Type\Type $propertyType, \PhpParser\Node\Stmt\Class_ $class) : void + public function addPropertyWithoutConstructorToClass(string $propertyName, ?Type $propertyType, Class_ $class) : void { $this->propertiesWithoutConstructorByClass[\spl_object_hash($class)][$propertyName] = $propertyType; $this->rectorChangeCollector->notifyNodeFileInfo($class); @@ -69,7 +69,7 @@ final class PropertyToAddCollector implements \Rector\PostRector\Contract\Collec /** * @return ClassConst[] */ - public function getConstantsByClass(\PhpParser\Node\Stmt\Class_ $class) : array + public function getConstantsByClass(Class_ $class) : array { $classHash = \spl_object_hash($class); return $this->constantsByClass[$classHash] ?? []; @@ -77,7 +77,7 @@ final class PropertyToAddCollector implements \Rector\PostRector\Contract\Collec /** * @return PropertyMetadata[] */ - public function getPropertiesByClass(\PhpParser\Node\Stmt\Class_ $class) : array + public function getPropertiesByClass(Class_ $class) : array { $classHash = \spl_object_hash($class); return $this->propertiesByClass[$classHash] ?? []; @@ -85,7 +85,7 @@ final class PropertyToAddCollector implements \Rector\PostRector\Contract\Collec /** * @return array */ - public function getPropertiesWithoutConstructorByClass(\PhpParser\Node\Stmt\Class_ $class) : array + public function getPropertiesWithoutConstructorByClass(Class_ $class) : array { $classHash = \spl_object_hash($class); return $this->propertiesWithoutConstructorByClass[$classHash] ?? []; diff --git a/packages/PostRector/Collector/UseNodesToAddCollector.php b/packages/PostRector/Collector/UseNodesToAddCollector.php index 8c0bac37230..3b4110be77c 100644 --- a/packages/PostRector/Collector/UseNodesToAddCollector.php +++ b/packages/PostRector/Collector/UseNodesToAddCollector.php @@ -11,8 +11,8 @@ use Rector\Naming\Naming\UseImportsResolver; use Rector\PostRector\Contract\Collector\NodeCollectorInterface; use Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; -use Symplify\SmartFileSystem\SmartFileInfo; -final class UseNodesToAddCollector implements \Rector\PostRector\Contract\Collector\NodeCollectorInterface +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; +final class UseNodesToAddCollector implements NodeCollectorInterface { /** * @var array @@ -32,7 +32,7 @@ final class UseNodesToAddCollector implements \Rector\PostRector\Contract\Collec * @var \Rector\Naming\Naming\UseImportsResolver */ private $useImportsResolver; - public function __construct(\Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \Rector\Naming\Naming\UseImportsResolver $useImportsResolver) + public function __construct(CurrentFileProvider $currentFileProvider, UseImportsResolver $useImportsResolver) { $this->currentFileProvider = $currentFileProvider; $this->useImportsResolver = $useImportsResolver; @@ -50,7 +50,7 @@ final class UseNodesToAddCollector implements \Rector\PostRector\Contract\Collec $file = $this->currentFileProvider->getFile(); $this->useImportTypesInFilePath[$file->getFilePath()][] = $objectType; } - public function addFunctionUseImport(\Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : void + public function addFunctionUseImport(FullyQualifiedObjectType $fullyQualifiedObjectType) : void { /** @var File $file */ $file = $this->currentFileProvider->getFile(); @@ -59,24 +59,24 @@ final class UseNodesToAddCollector implements \Rector\PostRector\Contract\Collec /** * @return AliasedObjectType[]|FullyQualifiedObjectType[] */ - public function getUseImportTypesByNode(\Rector\Core\ValueObject\Application\File $file, \PhpParser\Node $node) : array + public function getUseImportTypesByNode(File $file, Node $node) : array { $filePath = $file->getFilePath(); $objectTypes = $this->useImportTypesInFilePath[$filePath] ?? []; $uses = $this->useImportsResolver->resolveForNode($node); foreach ($uses as $use) { - $prefix = $use instanceof \PhpParser\Node\Stmt\GroupUse ? $use->prefix . '\\' : ''; + $prefix = $use instanceof GroupUse ? $use->prefix . '\\' : ''; foreach ($use->uses as $useUse) { if ($useUse->alias !== null) { - $objectTypes[] = new \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType($useUse->alias->toString(), $prefix . $useUse->name); + $objectTypes[] = new AliasedObjectType($useUse->alias->toString(), $prefix . $useUse->name); } else { - $objectTypes[] = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($prefix . $useUse->name); + $objectTypes[] = new FullyQualifiedObjectType($prefix . $useUse->name); } } } return $objectTypes; } - public function hasImport(\Rector\Core\ValueObject\Application\File $file, \PhpParser\Node $node, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : bool + public function hasImport(File $file, Node $node, FullyQualifiedObjectType $fullyQualifiedObjectType) : bool { $useImports = $this->getUseImportTypesByNode($file, $node); foreach ($useImports as $useImport) { @@ -86,7 +86,7 @@ final class UseNodesToAddCollector implements \Rector\PostRector\Contract\Collec } return \false; } - public function isShortImported(\Rector\Core\ValueObject\Application\File $file, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : bool + public function isShortImported(File $file, FullyQualifiedObjectType $fullyQualifiedObjectType) : bool { $shortName = $fullyQualifiedObjectType->getShortName(); $filePath = $file->getFilePath(); @@ -101,7 +101,7 @@ final class UseNodesToAddCollector implements \Rector\PostRector\Contract\Collec } return \false; } - public function isImportShortable(\Rector\Core\ValueObject\Application\File $file, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : bool + public function isImportShortable(File $file, FullyQualifiedObjectType $fullyQualifiedObjectType) : bool { $filePath = $file->getFilePath(); $fileUseImportTypes = $this->useImportTypesInFilePath[$filePath] ?? []; @@ -121,14 +121,14 @@ final class UseNodesToAddCollector implements \Rector\PostRector\Contract\Collec /** * @return AliasedObjectType[]|FullyQualifiedObjectType[] */ - public function getObjectImportsByFileInfo(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : array + public function getObjectImportsByFileInfo(SmartFileInfo $smartFileInfo) : array { return $this->useImportTypesInFilePath[$smartFileInfo->getRealPath()] ?? []; } /** * @return FullyQualifiedObjectType[] */ - public function getFunctionImportsByFileInfo(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : array + public function getFunctionImportsByFileInfo(SmartFileInfo $smartFileInfo) : array { return $this->functionUseImportTypesInFilePath[$smartFileInfo->getRealPath()] ?? []; } diff --git a/packages/PostRector/Contract/Rector/PostRectorInterface.php b/packages/PostRector/Contract/Rector/PostRectorInterface.php index 3a9b0dcee09..d4d1aae0970 100644 --- a/packages/PostRector/Contract/Rector/PostRectorInterface.php +++ b/packages/PostRector/Contract/Rector/PostRectorInterface.php @@ -5,7 +5,7 @@ namespace Rector\PostRector\Contract\Rector; use PhpParser\NodeVisitor; use Rector\Core\Contract\Rector\RectorInterface; -interface PostRectorInterface extends \PhpParser\NodeVisitor, \Rector\Core\Contract\Rector\RectorInterface +interface PostRectorInterface extends NodeVisitor, RectorInterface { /** * Higher values are executed first diff --git a/packages/PostRector/NodeAnalyzer/NetteInjectDetector.php b/packages/PostRector/NodeAnalyzer/NetteInjectDetector.php index cc6ecb28b0d..444482d898b 100644 --- a/packages/PostRector/NodeAnalyzer/NetteInjectDetector.php +++ b/packages/PostRector/NodeAnalyzer/NetteInjectDetector.php @@ -25,20 +25,20 @@ final class NetteInjectDetector * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(NodeNameResolver $nodeNameResolver, PhpDocInfoFactory $phpDocInfoFactory, ReflectionProvider $reflectionProvider) { $this->nodeNameResolver = $nodeNameResolver; $this->phpDocInfoFactory = $phpDocInfoFactory; $this->reflectionProvider = $reflectionProvider; } - public function isNetteInjectPreferred(\PhpParser\Node\Stmt\Class_ $class) : bool + public function isNetteInjectPreferred(Class_ $class) : bool { if ($this->isInjectPropertyAlreadyInTheClass($class)) { return \true; } return $this->hasParentClassConstructor($class); } - private function isInjectPropertyAlreadyInTheClass(\PhpParser\Node\Stmt\Class_ $class) : bool + private function isInjectPropertyAlreadyInTheClass(Class_ $class) : bool { foreach ($class->getProperties() as $property) { if (!$property->isPublic()) { @@ -51,7 +51,7 @@ final class NetteInjectDetector } return \false; } - private function hasParentClassConstructor(\PhpParser\Node\Stmt\Class_ $class) : bool + private function hasParentClassConstructor(Class_ $class) : bool { $className = (string) $this->nodeNameResolver->getName($class); if (!$this->reflectionProvider->hasClass($className)) { @@ -72,7 +72,7 @@ final class NetteInjectDetector } // prefer local constructor $classReflection = $this->reflectionProvider->getClass($className); - if ($classReflection->hasMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if ($classReflection->hasMethod(MethodName::CONSTRUCT)) { $methodReflection = $classReflection->getConstructor(); $declaringClass = $methodReflection->getDeclaringClass(); // be sure its local constructor @@ -81,6 +81,6 @@ final class NetteInjectDetector } } $classReflection = $this->reflectionProvider->getClass($parentClass); - return $classReflection->hasMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); + return $classReflection->hasMethod(MethodName::CONSTRUCT); } } diff --git a/packages/PostRector/Rector/AbstractPostRector.php b/packages/PostRector/Rector/AbstractPostRector.php index 43524dc88a2..00d95112ff7 100644 --- a/packages/PostRector/Rector/AbstractPostRector.php +++ b/packages/PostRector/Rector/AbstractPostRector.php @@ -5,6 +5,6 @@ namespace Rector\PostRector\Rector; use PhpParser\NodeVisitorAbstract; use Rector\PostRector\Contract\Rector\PostRectorInterface; -abstract class AbstractPostRector extends \PhpParser\NodeVisitorAbstract implements \Rector\PostRector\Contract\Rector\PostRectorInterface +abstract class AbstractPostRector extends NodeVisitorAbstract implements PostRectorInterface { } diff --git a/packages/PostRector/Rector/ClassRenamingPostRector.php b/packages/PostRector/Rector/ClassRenamingPostRector.php index 7e77e544129..23f1245a879 100644 --- a/packages/PostRector/Rector/ClassRenamingPostRector.php +++ b/packages/PostRector/Rector/ClassRenamingPostRector.php @@ -6,8 +6,8 @@ namespace Rector\PostRector\Rector; use PhpParser\Node; use Rector\Core\Configuration\RenamedClassesDataCollector; use Rector\Renaming\NodeManipulator\ClassRenamer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class ClassRenamingPostRector extends \Rector\PostRector\Rector\AbstractPostRector { /** @@ -20,7 +20,7 @@ final class ClassRenamingPostRector extends \Rector\PostRector\Rector\AbstractPo * @var \Rector\Core\Configuration\RenamedClassesDataCollector */ private $renamedClassesDataCollector; - public function __construct(\Rector\Renaming\NodeManipulator\ClassRenamer $classRenamer, \Rector\Core\Configuration\RenamedClassesDataCollector $renamedClassesDataCollector) + public function __construct(ClassRenamer $classRenamer, RenamedClassesDataCollector $renamedClassesDataCollector) { $this->classRenamer = $classRenamer; $this->renamedClassesDataCollector = $renamedClassesDataCollector; @@ -30,7 +30,7 @@ final class ClassRenamingPostRector extends \Rector\PostRector\Rector\AbstractPo // must be run before name importing, so new names are imported return 650; } - public function enterNode(\PhpParser\Node $node) : ?\PhpParser\Node + public function enterNode(Node $node) : ?Node { $oldToNewClasses = $this->renamedClassesDataCollector->getOldToNewClasses(); if ($oldToNewClasses === []) { @@ -38,9 +38,9 @@ final class ClassRenamingPostRector extends \Rector\PostRector\Rector\AbstractPo } return $this->classRenamer->renameNode($node, $oldToNewClasses); } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Rename references for classes that were renamed during Rector run', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Rename references for classes that were renamed during Rector run', [new CodeSample(<<<'CODE_SAMPLE' function (OriginalClass $someClass) { } diff --git a/packages/PostRector/Rector/NameImportingPostRector.php b/packages/PostRector/Rector/NameImportingPostRector.php index 9ada850f271..6024cbcbbf6 100644 --- a/packages/PostRector/Rector/NameImportingPostRector.php +++ b/packages/PostRector/Rector/NameImportingPostRector.php @@ -16,8 +16,8 @@ use Rector\Core\Provider\CurrentFileProvider; use Rector\Core\ValueObject\Application\File; use Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockNameImporter; use RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class NameImportingPostRector extends \Rector\PostRector\Rector\AbstractPostRector { /** @@ -60,7 +60,7 @@ final class NameImportingPostRector extends \Rector\PostRector\Rector\AbstractPo * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \Rector\CodingStyle\Node\NameImporter $nameImporter, \Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockNameImporter $docBlockNameImporter, \Rector\CodingStyle\ClassNameImport\ClassNameImportSkipper $classNameImportSkipper, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(ParameterProvider $parameterProvider, NameImporter $nameImporter, DocBlockNameImporter $docBlockNameImporter, ClassNameImportSkipper $classNameImportSkipper, PhpDocInfoFactory $phpDocInfoFactory, ReflectionProvider $reflectionProvider, CurrentFileProvider $currentFileProvider, BetterNodeFinder $betterNodeFinder) { $this->parameterProvider = $parameterProvider; $this->nameImporter = $nameImporter; @@ -71,19 +71,19 @@ final class NameImportingPostRector extends \Rector\PostRector\Rector\AbstractPo $this->currentFileProvider = $currentFileProvider; $this->betterNodeFinder = $betterNodeFinder; } - public function enterNode(\PhpParser\Node $node) : ?\PhpParser\Node + public function enterNode(Node $node) : ?Node { - if (!$this->parameterProvider->provideBoolParameter(\Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES)) { + if (!$this->parameterProvider->provideBoolParameter(Option::AUTO_IMPORT_NAMES)) { return null; } $file = $this->currentFileProvider->getFile(); - if (!$file instanceof \Rector\Core\ValueObject\Application\File) { + if (!$file instanceof File) { return null; } if (!$this->shouldApply($file)) { return null; } - if ($node instanceof \PhpParser\Node\Name) { + if ($node instanceof Name) { return $this->processNodeName($node, $file); } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); @@ -95,9 +95,9 @@ final class NameImportingPostRector extends \Rector\PostRector\Rector\AbstractPo // this must run after NodeRemovingPostRector, sine renamed use imports can block next import return 600; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Imports fully qualified names', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Imports fully qualified names', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(App\AnotherClass $anotherClass) @@ -117,14 +117,14 @@ class SomeClass CODE_SAMPLE )]); } - private function processNodeName(\PhpParser\Node\Name $name, \Rector\Core\ValueObject\Application\File $file) : ?\PhpParser\Node + private function processNodeName(Name $name, File $file) : ?Node { if ($name->isSpecialClassName()) { return $name; } // @todo test if old stmts or new stmts! or both? :) /** @var Use_[] $currentUses */ - $currentUses = $this->betterNodeFinder->findInstanceOf($file->getNewStmts(), \PhpParser\Node\Stmt\Use_::class); + $currentUses = $this->betterNodeFinder->findInstanceOf($file->getNewStmts(), Use_::class); if ($this->shouldImportName($name, $currentUses)) { return $this->nameImporter->importName($name, $file, $currentUses); } @@ -133,7 +133,7 @@ CODE_SAMPLE /** * @param Use_[] $currentUses */ - private function shouldImportName(\PhpParser\Node\Name $name, array $currentUses) : bool + private function shouldImportName(Name $name, array $currentUses) : bool { if (\substr_count($name->toCodeString(), '\\') <= 1) { return \true; @@ -144,11 +144,11 @@ CODE_SAMPLE if ($this->classNameImportSkipper->isAlreadyImported($name, $currentUses)) { return \true; } - return $this->reflectionProvider->hasFunction(new \PhpParser\Node\Name($name->getLast()), null); + return $this->reflectionProvider->hasFunction(new Name($name->getLast()), null); } - private function shouldApply(\Rector\Core\ValueObject\Application\File $file) : bool + private function shouldApply(File $file) : bool { - if (!$this->parameterProvider->provideBoolParameter(\Rector\Core\Configuration\Option::APPLY_AUTO_IMPORT_NAMES_ON_CHANGED_FILES_ONLY)) { + if (!$this->parameterProvider->provideBoolParameter(Option::APPLY_AUTO_IMPORT_NAMES_ON_CHANGED_FILES_ONLY)) { return \true; } return $file->hasContentChanged(); diff --git a/packages/PostRector/Rector/NodeAddingPostRector.php b/packages/PostRector/Rector/NodeAddingPostRector.php index 0d0d15dc9a4..ade2e8adb90 100644 --- a/packages/PostRector/Rector/NodeAddingPostRector.php +++ b/packages/PostRector/Rector/NodeAddingPostRector.php @@ -5,8 +5,8 @@ namespace Rector\PostRector\Rector; use PhpParser\Node; use Rector\PostRector\Collector\NodesToAddCollector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * This class collects all to-be-added expresssions (= 1 line in code) * and then adds new expressions to list of $nodes @@ -25,7 +25,7 @@ final class NodeAddingPostRector extends \Rector\PostRector\Rector\AbstractPostR * @var \Rector\PostRector\Collector\NodesToAddCollector */ private $nodesToAddCollector; - public function __construct(\Rector\PostRector\Collector\NodesToAddCollector $nodesToAddCollector) + public function __construct(NodesToAddCollector $nodesToAddCollector) { $this->nodesToAddCollector = $nodesToAddCollector; } @@ -36,7 +36,7 @@ final class NodeAddingPostRector extends \Rector\PostRector\Rector\AbstractPostR /** * @return mixed[]|\PhpParser\Node */ - public function leaveNode(\PhpParser\Node $node) + public function leaveNode(Node $node) { $newNodes = [$node]; $nodesToAddAfter = $this->nodesToAddCollector->getNodesToAddAfterNode($node); @@ -54,9 +54,9 @@ final class NodeAddingPostRector extends \Rector\PostRector\Rector\AbstractPostR } return $newNodes; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add nodes on weird positions', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add nodes on weird positions', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($value) diff --git a/packages/PostRector/Rector/NodeRemovingPostRector.php b/packages/PostRector/Rector/NodeRemovingPostRector.php index 343dcf36b0d..c666fa47021 100644 --- a/packages/PostRector/Rector/NodeRemovingPostRector.php +++ b/packages/PostRector/Rector/NodeRemovingPostRector.php @@ -11,8 +11,8 @@ use Rector\Core\PhpParser\Node\NodeFactory; use Rector\NodeNameResolver\NodeNameResolver; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\PostRector\Collector\NodesToRemoveCollector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class NodeRemovingPostRector extends \Rector\PostRector\Rector\AbstractPostRector { /** @@ -30,7 +30,7 @@ final class NodeRemovingPostRector extends \Rector\PostRector\Rector\AbstractPos * @var \Rector\PostRector\Collector\NodesToRemoveCollector */ private $nodesToRemoveCollector; - public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\PostRector\Collector\NodesToRemoveCollector $nodesToRemoveCollector) + public function __construct(NodeFactory $nodeFactory, NodeNameResolver $nodeNameResolver, NodesToRemoveCollector $nodesToRemoveCollector) { $this->nodeFactory = $nodeFactory; $this->nodeNameResolver = $nodeNameResolver; @@ -40,17 +40,17 @@ final class NodeRemovingPostRector extends \Rector\PostRector\Rector\AbstractPos { return 800; } - public function enterNode(\PhpParser\Node $node) : ?\PhpParser\Node + public function enterNode(Node $node) : ?Node { if (!$this->nodesToRemoveCollector->isActive()) { return null; } // special case for fluent methods foreach ($this->nodesToRemoveCollector->getNodesToRemove() as $key => $nodeToRemove) { - if (!$node instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$node instanceof MethodCall) { continue; } - if (!$nodeToRemove instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$nodeToRemove instanceof MethodCall) { continue; } // replace chain method call by non-chain method call @@ -64,7 +64,7 @@ final class NodeRemovingPostRector extends \Rector\PostRector\Rector\AbstractPos /** @var string $methodName */ return $this->nodeFactory->createMethodCall($nestedMethodCall->var, $methodName, $node->args); } - if (!$node instanceof \PhpParser\Node\Expr\BinaryOp) { + if (!$node instanceof BinaryOp) { return null; } return $this->removePartOfBinaryOp($node); @@ -72,23 +72,23 @@ final class NodeRemovingPostRector extends \Rector\PostRector\Rector\AbstractPos /** * @return int|\PhpParser\Node */ - public function leaveNode(\PhpParser\Node $node) + public function leaveNode(Node $node) { foreach ($this->nodesToRemoveCollector->getNodesToRemove() as $key => $nodeToRemove) { - $nodeToRemoveParent = $nodeToRemove->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($nodeToRemoveParent instanceof \PhpParser\Node\Expr\BinaryOp) { + $nodeToRemoveParent = $nodeToRemove->getAttribute(AttributeKey::PARENT_NODE); + if ($nodeToRemoveParent instanceof BinaryOp) { continue; } if ($node === $nodeToRemove) { $this->nodesToRemoveCollector->unset($key); - return \PhpParser\NodeTraverser::REMOVE_NODE; + return NodeTraverser::REMOVE_NODE; } } return $node; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove nodes from weird positions', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove nodes from weird positions', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($value) @@ -110,9 +110,9 @@ class SomeClass CODE_SAMPLE )]); } - private function isChainMethodCallNodeToBeRemoved(\PhpParser\Node\Expr\MethodCall $mainMethodCall, \PhpParser\Node\Expr\MethodCall $toBeRemovedMethodCall) : bool + private function isChainMethodCallNodeToBeRemoved(MethodCall $mainMethodCall, MethodCall $toBeRemovedMethodCall) : bool { - if (!$mainMethodCall->var instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$mainMethodCall->var instanceof MethodCall) { return \false; } if ($toBeRemovedMethodCall !== $mainMethodCall->var) { @@ -121,13 +121,13 @@ CODE_SAMPLE $methodName = $this->nodeNameResolver->getName($mainMethodCall->name); return $methodName !== null; } - private function removePartOfBinaryOp(\PhpParser\Node\Expr\BinaryOp $binaryOp) : ?\PhpParser\Node + private function removePartOfBinaryOp(BinaryOp $binaryOp) : ?Node { // handle left/right binary remove, e.g. "true && false" → remove false → "true" foreach ($this->nodesToRemoveCollector->getNodesToRemove() as $key => $nodeToRemove) { // remove node - $nodeToRemoveParentNode = $nodeToRemove->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$nodeToRemoveParentNode instanceof \PhpParser\Node\Expr\BinaryOp) { + $nodeToRemoveParentNode = $nodeToRemove->getAttribute(AttributeKey::PARENT_NODE); + if (!$nodeToRemoveParentNode instanceof BinaryOp) { continue; } if ($binaryOp->left === $nodeToRemove) { diff --git a/packages/PostRector/Rector/PropertyAddingPostRector.php b/packages/PostRector/Rector/PropertyAddingPostRector.php index 2da552d0354..4fbefb0314e 100644 --- a/packages/PostRector/Rector/PropertyAddingPostRector.php +++ b/packages/PostRector/Rector/PropertyAddingPostRector.php @@ -10,8 +10,8 @@ use Rector\Core\NodeManipulator\ClassDependencyManipulator; use Rector\Core\NodeManipulator\ClassInsertManipulator; use Rector\PostRector\Collector\PropertyToAddCollector; use Rector\PostRector\NodeAnalyzer\NetteInjectDetector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * Adds new private properties to class + to constructor */ @@ -42,7 +42,7 @@ final class PropertyAddingPostRector extends \Rector\PostRector\Rector\AbstractP * @var \Rector\Core\NodeAnalyzer\ClassAnalyzer */ private $classAnalyzer; - public function __construct(\Rector\Core\NodeManipulator\ClassDependencyManipulator $classDependencyManipulator, \Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator, \Rector\PostRector\NodeAnalyzer\NetteInjectDetector $netteInjectDetector, \Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector, \Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer) + public function __construct(ClassDependencyManipulator $classDependencyManipulator, ClassInsertManipulator $classInsertManipulator, NetteInjectDetector $netteInjectDetector, PropertyToAddCollector $propertyToAddCollector, ClassAnalyzer $classAnalyzer) { $this->classDependencyManipulator = $classDependencyManipulator; $this->classInsertManipulator = $classInsertManipulator; @@ -54,9 +54,9 @@ final class PropertyAddingPostRector extends \Rector\PostRector\Rector\AbstractP { return 900; } - public function enterNode(\PhpParser\Node $node) : ?\PhpParser\Node + public function enterNode(Node $node) : ?Node { - if (!$node instanceof \PhpParser\Node\Stmt\Class_) { + if (!$node instanceof Class_) { return null; } if ($this->classAnalyzer->isAnonymousClass($node)) { @@ -67,9 +67,9 @@ final class PropertyAddingPostRector extends \Rector\PostRector\Rector\AbstractP $this->addPropertiesWithoutConstructor($node); return $node; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add dependency properties', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add dependency properties', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -90,14 +90,14 @@ class SomeClass CODE_SAMPLE )]); } - private function addConstants(\PhpParser\Node\Stmt\Class_ $class) : void + private function addConstants(Class_ $class) : void { $constants = $this->propertyToAddCollector->getConstantsByClass($class); foreach ($constants as $constantName => $nodeConst) { $this->classInsertManipulator->addConstantToClass($class, $constantName, $nodeConst); } } - private function addProperties(\PhpParser\Node\Stmt\Class_ $class) : void + private function addProperties(Class_ $class) : void { $propertiesMetadatas = $this->propertyToAddCollector->getPropertiesByClass($class); $isNetteInjectPreferred = $this->netteInjectDetector->isNetteInjectPreferred($class); @@ -109,7 +109,7 @@ CODE_SAMPLE } } } - private function addPropertiesWithoutConstructor(\PhpParser\Node\Stmt\Class_ $class) : void + private function addPropertiesWithoutConstructor(Class_ $class) : void { $propertiesWithoutConstructor = $this->propertyToAddCollector->getPropertiesWithoutConstructorByClass($class); foreach ($propertiesWithoutConstructor as $propertyName => $propertyType) { diff --git a/packages/PostRector/Rector/UseAddingPostRector.php b/packages/PostRector/Rector/UseAddingPostRector.php index a62ccac4a01..66413d05da3 100644 --- a/packages/PostRector/Rector/UseAddingPostRector.php +++ b/packages/PostRector/Rector/UseAddingPostRector.php @@ -14,8 +14,8 @@ use Rector\Core\Provider\CurrentFileProvider; use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory; use Rector\PostRector\Collector\UseNodesToAddCollector; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; final class UseAddingPostRector extends \Rector\PostRector\Rector\AbstractPostRector { /** @@ -53,7 +53,7 @@ final class UseAddingPostRector extends \Rector\PostRector\Rector\AbstractPostRe * @var \Rector\Core\Configuration\RenamedClassesDataCollector */ private $renamedClassesDataCollector; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \Rector\CodingStyle\Application\UseImportsAdder $useImportsAdder, \Rector\CodingStyle\Application\UseImportsRemover $useImportsRemover, \Rector\PostRector\Collector\UseNodesToAddCollector $useNodesToAddCollector, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \Rector\Core\Configuration\RenamedClassesDataCollector $renamedClassesDataCollector) + public function __construct(BetterNodeFinder $betterNodeFinder, TypeFactory $typeFactory, UseImportsAdder $useImportsAdder, UseImportsRemover $useImportsRemover, UseNodesToAddCollector $useNodesToAddCollector, CurrentFileProvider $currentFileProvider, RenamedClassesDataCollector $renamedClassesDataCollector) { $this->betterNodeFinder = $betterNodeFinder; $this->typeFactory = $typeFactory; @@ -85,8 +85,8 @@ final class UseAddingPostRector extends \Rector\PostRector\Rector\AbstractPostRe /** @var FullyQualifiedObjectType[] $useImportTypes */ $useImportTypes = $this->typeFactory->uniquateTypes($useImportTypes); // A. has namespace? add under it - $namespace = $this->betterNodeFinder->findFirstInstanceOf($nodes, \PhpParser\Node\Stmt\Namespace_::class); - if ($namespace instanceof \PhpParser\Node\Stmt\Namespace_) { + $namespace = $this->betterNodeFinder->findFirstInstanceOf($nodes, Namespace_::class); + if ($namespace instanceof Namespace_) { // first clean //$this->useImportsRemover->removeImportsFromNamespace($namespace, $removedShortUses); // then add, to prevent adding + removing false positive of same short use @@ -94,7 +94,7 @@ final class UseAddingPostRector extends \Rector\PostRector\Rector\AbstractPostRe return $nodes; } $firstNode = $nodes[0]; - if ($firstNode instanceof \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace) { + if ($firstNode instanceof FileWithoutNamespace) { $nodes = $firstNode->stmts; } $removedShortUses = $this->renamedClassesDataCollector->getOldClasses(); @@ -110,9 +110,9 @@ final class UseAddingPostRector extends \Rector\PostRector\Rector\AbstractPostRe // must be after name importing return 500; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add unique use imports collected during Rector run', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add unique use imports collected during Rector run', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(AnotherClass $anotherClass) diff --git a/packages/PostRector/ValueObject/PropertyMetadata.php b/packages/PostRector/ValueObject/PropertyMetadata.php index 754eda36423..ad7aaee0c72 100644 --- a/packages/PostRector/ValueObject/PropertyMetadata.php +++ b/packages/PostRector/ValueObject/PropertyMetadata.php @@ -21,7 +21,7 @@ final class PropertyMetadata * @var int */ private $flags; - public function __construct(string $name, ?\PHPStan\Type\Type $type, int $flags) + public function __construct(string $name, ?Type $type, int $flags) { $this->name = $name; $this->type = $type; @@ -31,7 +31,7 @@ final class PropertyMetadata { return $this->name; } - public function getType() : ?\PHPStan\Type\Type + public function getType() : ?Type { return $this->type; } diff --git a/packages/ReadWrite/Contract/ParentNodeReadAnalyzerInterface.php b/packages/ReadWrite/Contract/ParentNodeReadAnalyzerInterface.php index e4014a80a0e..9957b1b3acb 100644 --- a/packages/ReadWrite/Contract/ParentNodeReadAnalyzerInterface.php +++ b/packages/ReadWrite/Contract/ParentNodeReadAnalyzerInterface.php @@ -7,5 +7,5 @@ use PhpParser\Node; use PhpParser\Node\Expr; interface ParentNodeReadAnalyzerInterface { - public function isRead(\PhpParser\Node\Expr $expr, \PhpParser\Node $parentNode) : bool; + public function isRead(Expr $expr, Node $parentNode) : bool; } diff --git a/packages/ReadWrite/Contract/ReadNodeAnalyzerInterface.php b/packages/ReadWrite/Contract/ReadNodeAnalyzerInterface.php index eef896b728e..7e57993b737 100644 --- a/packages/ReadWrite/Contract/ReadNodeAnalyzerInterface.php +++ b/packages/ReadWrite/Contract/ReadNodeAnalyzerInterface.php @@ -9,9 +9,9 @@ use PhpParser\Node\Expr; */ interface ReadNodeAnalyzerInterface { - public function supports(\PhpParser\Node\Expr $expr) : bool; + public function supports(Expr $expr) : bool; /** * @param TExpr $expr */ - public function isRead(\PhpParser\Node\Expr $expr) : bool; + public function isRead(Expr $expr) : bool; } diff --git a/packages/ReadWrite/Guard/VariableToConstantGuard.php b/packages/ReadWrite/Guard/VariableToConstantGuard.php index 5e2f897bfb4..7b9a1730da5 100644 --- a/packages/ReadWrite/Guard/VariableToConstantGuard.php +++ b/packages/ReadWrite/Guard/VariableToConstantGuard.php @@ -30,29 +30,29 @@ final class VariableToConstantGuard * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider) { $this->nodeNameResolver = $nodeNameResolver; $this->reflectionProvider = $reflectionProvider; } - public function isReadArg(\PhpParser\Node\Arg $arg) : bool + public function isReadArg(Arg $arg) : bool { - $parentParent = $arg->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentParent instanceof \PhpParser\Node\Expr\FuncCall) { + $parentParent = $arg->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentParent instanceof FuncCall) { return \true; } $functionNameString = $this->nodeNameResolver->getName($parentParent); if ($functionNameString === null) { return \true; } - $functionName = new \PhpParser\Node\Name($functionNameString); - $argScope = $arg->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $functionName = new Name($functionNameString); + $argScope = $arg->getAttribute(AttributeKey::SCOPE); if (!$this->reflectionProvider->hasFunction($functionName, $argScope)) { // we don't know return \true; } $functionReflection = $this->reflectionProvider->getFunction($functionName, $argScope); - if (!$argScope instanceof \PHPStan\Analyser\Scope) { + if (!$argScope instanceof Scope) { return \true; } $referenceParametersPositions = $this->resolveFunctionReferencePositions($functionReflection, [$arg], $argScope); @@ -67,13 +67,13 @@ final class VariableToConstantGuard * @param Arg[] $args * @return int[] */ - private function resolveFunctionReferencePositions(\PHPStan\Reflection\FunctionReflection $functionReflection, array $args, \PHPStan\Analyser\Scope $scope) : array + private function resolveFunctionReferencePositions(FunctionReflection $functionReflection, array $args, Scope $scope) : array { if (isset($this->referencePositionsByFunctionName[$functionReflection->getName()])) { return $this->referencePositionsByFunctionName[$functionReflection->getName()]; } $referencePositions = []; - $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectFromArgs($scope, $args, $functionReflection->getVariants()); + $parametersAcceptor = ParametersAcceptorSelector::selectFromArgs($scope, $args, $functionReflection->getVariants()); foreach ($parametersAcceptor->getParameters() as $position => $parameterReflection) { /** @var ParameterReflection $parameterReflection */ if (!$parameterReflection->passedByReference()->yes()) { @@ -84,7 +84,7 @@ final class VariableToConstantGuard $this->referencePositionsByFunctionName[$functionReflection->getName()] = $referencePositions; return $referencePositions; } - private function getArgumentPosition(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Arg $desiredArg) : int + private function getArgumentPosition(FuncCall $funcCall, Arg $desiredArg) : int { foreach ($funcCall->args as $position => $arg) { if ($arg !== $desiredArg) { @@ -92,6 +92,6 @@ final class VariableToConstantGuard } return $position; } - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } } diff --git a/packages/ReadWrite/NodeAnalyzer/ReadExprAnalyzer.php b/packages/ReadWrite/NodeAnalyzer/ReadExprAnalyzer.php index 1bf47593152..4f062876f03 100644 --- a/packages/ReadWrite/NodeAnalyzer/ReadExprAnalyzer.php +++ b/packages/ReadWrite/NodeAnalyzer/ReadExprAnalyzer.php @@ -23,7 +23,7 @@ final class ReadExprAnalyzer /** * Is the value read or used for read purpose (at least, not only) */ - public function isExprRead(\PhpParser\Node\Expr $expr) : bool + public function isExprRead(Expr $expr) : bool { foreach ($this->readNodeAnalyzers as $readNodeAnalyzer) { if (!$readNodeAnalyzer->supports($expr)) { @@ -31,6 +31,6 @@ final class ReadExprAnalyzer } return $readNodeAnalyzer->isRead($expr); } - throw new \Rector\Core\Exception\NotImplementedYetException(\get_class($expr)); + throw new NotImplementedYetException(\get_class($expr)); } } diff --git a/packages/ReadWrite/NodeAnalyzer/ReadWritePropertyAnalyzer.php b/packages/ReadWrite/NodeAnalyzer/ReadWritePropertyAnalyzer.php index 1e3cd81bbe0..66a4be0d67d 100644 --- a/packages/ReadWrite/NodeAnalyzer/ReadWritePropertyAnalyzer.php +++ b/packages/ReadWrite/NodeAnalyzer/ReadWritePropertyAnalyzer.php @@ -52,7 +52,7 @@ final class ReadWritePropertyAnalyzer /** * @param ParentNodeReadAnalyzerInterface[] $parentNodeReadAnalyzers */ - public function __construct(\Rector\Core\NodeManipulator\AssignManipulator $assignManipulator, \Rector\ReadWrite\NodeAnalyzer\ReadExprAnalyzer $readExprAnalyzer, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\DeadCode\SideEffect\PureFunctionDetector $pureFunctionDetector, array $parentNodeReadAnalyzers) + public function __construct(AssignManipulator $assignManipulator, \Rector\ReadWrite\NodeAnalyzer\ReadExprAnalyzer $readExprAnalyzer, BetterNodeFinder $betterNodeFinder, PureFunctionDetector $pureFunctionDetector, array $parentNodeReadAnalyzers) { $this->assignManipulator = $assignManipulator; $this->readExprAnalyzer = $readExprAnalyzer; @@ -65,22 +65,22 @@ final class ReadWritePropertyAnalyzer */ public function isRead($node) : bool { - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Node) { + throw new ShouldNotHappenException(); } foreach ($this->parentNodeReadAnalyzers as $parentNodeReadAnalyzer) { if ($parentNodeReadAnalyzer->isRead($node, $parent)) { return \true; } } - if ($parent instanceof \PhpParser\Node\Expr\AssignOp) { + if ($parent instanceof AssignOp) { return \true; } - if ($parent instanceof \PhpParser\Node\Expr\ArrayDimFetch && $parent->dim === $node && $this->isNotInsideIssetUnset($parent)) { + if ($parent instanceof ArrayDimFetch && $parent->dim === $node && $this->isNotInsideIssetUnset($parent)) { return $this->isArrayDimFetchRead($parent); } - if (!$parent instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$parent instanceof ArrayDimFetch) { return !$this->assignManipulator->isLeftPartOfAssign($node); } if ($this->assignManipulator->isLeftPartOfAssign($parent)) { @@ -88,13 +88,13 @@ final class ReadWritePropertyAnalyzer } return !$this->isArrayDimFetchInImpureFunction($parent, $node); } - private function isArrayDimFetchInImpureFunction(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch, \PhpParser\Node $node) : bool + private function isArrayDimFetchInImpureFunction(ArrayDimFetch $arrayDimFetch, Node $node) : bool { if ($arrayDimFetch->var === $node) { - $arg = $this->betterNodeFinder->findParentType($arrayDimFetch, \PhpParser\Node\Arg::class); - if ($arg instanceof \PhpParser\Node\Arg) { - $parentArg = $arg->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentArg instanceof \PhpParser\Node\Expr\FuncCall) { + $arg = $this->betterNodeFinder->findParentType($arrayDimFetch, Arg::class); + if ($arg instanceof Arg) { + $parentArg = $arg->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentArg instanceof FuncCall) { return \false; } return !$this->pureFunctionDetector->detect($parentArg); @@ -102,20 +102,20 @@ final class ReadWritePropertyAnalyzer } return \false; } - private function isNotInsideIssetUnset(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch) : bool + private function isNotInsideIssetUnset(ArrayDimFetch $arrayDimFetch) : bool { - return !(bool) $this->betterNodeFinder->findParentByTypes($arrayDimFetch, [\PhpParser\Node\Expr\Isset_::class, \PhpParser\Node\Stmt\Unset_::class]); + return !(bool) $this->betterNodeFinder->findParentByTypes($arrayDimFetch, [Isset_::class, Unset_::class]); } - private function isArrayDimFetchRead(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch) : bool + private function isArrayDimFetchRead(ArrayDimFetch $arrayDimFetch) : bool { - $parentParent = $arrayDimFetch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentParent instanceof \PhpParser\Node) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $parentParent = $arrayDimFetch->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentParent instanceof Node) { + throw new ShouldNotHappenException(); } if (!$this->assignManipulator->isLeftPartOfAssign($arrayDimFetch)) { return \false; } - if ($arrayDimFetch->var instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if ($arrayDimFetch->var instanceof ArrayDimFetch) { return \true; } // the array dim fetch is assing here only; but the variable might be used later diff --git a/packages/ReadWrite/NodeFinder/NodeUsageFinder.php b/packages/ReadWrite/NodeFinder/NodeUsageFinder.php index fa87312c82b..f398185b8a5 100644 --- a/packages/ReadWrite/NodeFinder/NodeUsageFinder.php +++ b/packages/ReadWrite/NodeFinder/NodeUsageFinder.php @@ -33,7 +33,7 @@ final class NodeUsageFinder * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNestingScope\NodeFinder\ScopeAwareNodeFinder $scopeAwareNodeFinder, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder, ScopeAwareNodeFinder $scopeAwareNodeFinder, NodeComparator $nodeComparator) { $this->nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; @@ -44,14 +44,14 @@ final class NodeUsageFinder * @param Node[] $nodes * @return Variable[] */ - public function findVariableUsages(array $nodes, \PhpParser\Node\Expr\Variable $variable) : array + public function findVariableUsages(array $nodes, Variable $variable) : array { $variableName = $this->nodeNameResolver->getName($variable); if ($variableName === null) { return []; } - return $this->betterNodeFinder->find($nodes, function (\PhpParser\Node $node) use($variable, $variableName) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + return $this->betterNodeFinder->find($nodes, function (Node $node) use($variable, $variableName) : bool { + if (!$node instanceof Variable) { return \false; } if ($node === $variable) { @@ -60,14 +60,14 @@ final class NodeUsageFinder return $this->nodeNameResolver->isName($node, $variableName); }); } - public function findPreviousForeachNodeUsage(\PhpParser\Node\Stmt\Foreach_ $foreach, \PhpParser\Node\Expr $expr) : ?\PhpParser\Node + public function findPreviousForeachNodeUsage(Foreach_ $foreach, Expr $expr) : ?Node { - return $this->scopeAwareNodeFinder->findParent($foreach, function (\PhpParser\Node $node) use($expr) : bool { + return $this->scopeAwareNodeFinder->findParent($foreach, function (Node $node) use($expr) : bool { // skip itself if ($node === $expr) { return \false; } return $this->nodeComparator->areNodesEqual($node, $expr); - }, [\PhpParser\Node\Stmt\Foreach_::class]); + }, [Foreach_::class]); } } diff --git a/packages/ReadWrite/ParentNodeReadAnalyzer/ArgParentNodeReadAnalyzer.php b/packages/ReadWrite/ParentNodeReadAnalyzer/ArgParentNodeReadAnalyzer.php index f11873b4625..6264c949e8d 100644 --- a/packages/ReadWrite/ParentNodeReadAnalyzer/ArgParentNodeReadAnalyzer.php +++ b/packages/ReadWrite/ParentNodeReadAnalyzer/ArgParentNodeReadAnalyzer.php @@ -8,20 +8,20 @@ use PhpParser\Node\Arg; use PhpParser\Node\Expr; use Rector\ReadWrite\Contract\ParentNodeReadAnalyzerInterface; use Rector\ReadWrite\Guard\VariableToConstantGuard; -final class ArgParentNodeReadAnalyzer implements \Rector\ReadWrite\Contract\ParentNodeReadAnalyzerInterface +final class ArgParentNodeReadAnalyzer implements ParentNodeReadAnalyzerInterface { /** * @readonly * @var \Rector\ReadWrite\Guard\VariableToConstantGuard */ private $variableToConstantGuard; - public function __construct(\Rector\ReadWrite\Guard\VariableToConstantGuard $variableToConstantGuard) + public function __construct(VariableToConstantGuard $variableToConstantGuard) { $this->variableToConstantGuard = $variableToConstantGuard; } - public function isRead(\PhpParser\Node\Expr $expr, \PhpParser\Node $parentNode) : bool + public function isRead(Expr $expr, Node $parentNode) : bool { - if (!$parentNode instanceof \PhpParser\Node\Arg) { + if (!$parentNode instanceof Arg) { return \false; } return $this->variableToConstantGuard->isReadArg($parentNode); diff --git a/packages/ReadWrite/ParentNodeReadAnalyzer/ArrayDimFetchParentNodeReadAnalyzer.php b/packages/ReadWrite/ParentNodeReadAnalyzer/ArrayDimFetchParentNodeReadAnalyzer.php index 9271475dc96..1aa267fb4e0 100644 --- a/packages/ReadWrite/ParentNodeReadAnalyzer/ArrayDimFetchParentNodeReadAnalyzer.php +++ b/packages/ReadWrite/ParentNodeReadAnalyzer/ArrayDimFetchParentNodeReadAnalyzer.php @@ -9,20 +9,20 @@ use PhpParser\Node\Expr\ArrayDimFetch; use PhpParser\Node\Expr\Assign; use Rector\Core\PhpParser\Node\BetterNodeFinder; use Rector\ReadWrite\Contract\ParentNodeReadAnalyzerInterface; -final class ArrayDimFetchParentNodeReadAnalyzer implements \Rector\ReadWrite\Contract\ParentNodeReadAnalyzerInterface +final class ArrayDimFetchParentNodeReadAnalyzer implements ParentNodeReadAnalyzerInterface { /** * @readonly * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(BetterNodeFinder $betterNodeFinder) { $this->betterNodeFinder = $betterNodeFinder; } - public function isRead(\PhpParser\Node\Expr $expr, \PhpParser\Node $parentNode) : bool + public function isRead(Expr $expr, Node $parentNode) : bool { - if (!$parentNode instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$parentNode instanceof ArrayDimFetch) { return \false; } if ($parentNode->dim !== $expr) { @@ -31,13 +31,13 @@ final class ArrayDimFetchParentNodeReadAnalyzer implements \Rector\ReadWrite\Con // is left part of assign return $this->isLeftPartOfAssign($expr); } - private function isLeftPartOfAssign(\PhpParser\Node\Expr $expr) : bool + private function isLeftPartOfAssign(Expr $expr) : bool { - $parentAssign = $this->betterNodeFinder->findParentType($expr, \PhpParser\Node\Expr\Assign::class); - if (!$parentAssign instanceof \PhpParser\Node\Expr\Assign) { + $parentAssign = $this->betterNodeFinder->findParentType($expr, Assign::class); + if (!$parentAssign instanceof Assign) { return \true; } - return !(bool) $this->betterNodeFinder->findFirst($parentAssign->var, function (\PhpParser\Node $node) use($expr) : bool { + return !(bool) $this->betterNodeFinder->findFirst($parentAssign->var, function (Node $node) use($expr) : bool { return $node === $expr; }); } diff --git a/packages/ReadWrite/ParentNodeReadAnalyzer/IncDecParentNodeReadAnalyzer.php b/packages/ReadWrite/ParentNodeReadAnalyzer/IncDecParentNodeReadAnalyzer.php index 77ad1a8b62b..9b7402b7a88 100644 --- a/packages/ReadWrite/ParentNodeReadAnalyzer/IncDecParentNodeReadAnalyzer.php +++ b/packages/ReadWrite/ParentNodeReadAnalyzer/IncDecParentNodeReadAnalyzer.php @@ -10,19 +10,19 @@ use PhpParser\Node\Expr\PostInc; use PhpParser\Node\Expr\PreDec; use PhpParser\Node\Expr\PreInc; use Rector\ReadWrite\Contract\ParentNodeReadAnalyzerInterface; -final class IncDecParentNodeReadAnalyzer implements \Rector\ReadWrite\Contract\ParentNodeReadAnalyzerInterface +final class IncDecParentNodeReadAnalyzer implements ParentNodeReadAnalyzerInterface { - public function isRead(\PhpParser\Node\Expr $expr, \PhpParser\Node $parentNode) : bool + public function isRead(Expr $expr, Node $parentNode) : bool { - if ($parentNode instanceof \PhpParser\Node\Expr\PostDec) { + if ($parentNode instanceof PostDec) { return \true; } - if ($parentNode instanceof \PhpParser\Node\Expr\PostInc) { + if ($parentNode instanceof PostInc) { return \true; } - if ($parentNode instanceof \PhpParser\Node\Expr\PreInc) { + if ($parentNode instanceof PreInc) { return \true; } - return $parentNode instanceof \PhpParser\Node\Expr\PreDec; + return $parentNode instanceof PreDec; } } diff --git a/packages/ReadWrite/ReadNodeAnalyzer/JustReadExprAnalyzer.php b/packages/ReadWrite/ReadNodeAnalyzer/JustReadExprAnalyzer.php index 4507b9b6703..3ffe84b94e4 100644 --- a/packages/ReadWrite/ReadNodeAnalyzer/JustReadExprAnalyzer.php +++ b/packages/ReadWrite/ReadNodeAnalyzer/JustReadExprAnalyzer.php @@ -12,23 +12,23 @@ use PhpParser\Node\Stmt\Return_; use Rector\NodeTypeResolver\Node\AttributeKey; final class JustReadExprAnalyzer { - public function isReadContext(\PhpParser\Node\Expr $expr) : bool + public function isReadContext(Expr $expr) : bool { - $parent = $expr->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\Stmt\Return_) { + $parent = $expr->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof Return_) { return \true; } - if ($parent instanceof \PhpParser\Node\Arg) { + if ($parent instanceof Arg) { return \true; } - if ($parent instanceof \PhpParser\Node\Expr\ArrayDimFetch) { - $parentParent = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentParent instanceof \PhpParser\Node\Expr\Assign) { + if ($parent instanceof ArrayDimFetch) { + $parentParent = $parent->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentParent instanceof Assign) { return \true; } return $parentParent->var !== $parent; } // assume it's used by default - return !$parent instanceof \PhpParser\Node\Stmt\Expression; + return !$parent instanceof Expression; } } diff --git a/packages/ReadWrite/ReadNodeAnalyzer/LocalPropertyFetchReadNodeAnalyzer.php b/packages/ReadWrite/ReadNodeAnalyzer/LocalPropertyFetchReadNodeAnalyzer.php index 9e0c131d49b..6c0b967be69 100644 --- a/packages/ReadWrite/ReadNodeAnalyzer/LocalPropertyFetchReadNodeAnalyzer.php +++ b/packages/ReadWrite/ReadNodeAnalyzer/LocalPropertyFetchReadNodeAnalyzer.php @@ -15,7 +15,7 @@ use Rector\ReadWrite\Contract\ReadNodeAnalyzerInterface; /** * @implements ReadNodeAnalyzerInterface */ -final class LocalPropertyFetchReadNodeAnalyzer implements \Rector\ReadWrite\Contract\ReadNodeAnalyzerInterface +final class LocalPropertyFetchReadNodeAnalyzer implements ReadNodeAnalyzerInterface { /** * @readonly @@ -37,21 +37,21 @@ final class LocalPropertyFetchReadNodeAnalyzer implements \Rector\ReadWrite\Cont * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\ReadWrite\ReadNodeAnalyzer\JustReadExprAnalyzer $justReadExprAnalyzer, \Rector\Core\PhpParser\NodeFinder\PropertyFetchFinder $propertyFetchFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(\Rector\ReadWrite\ReadNodeAnalyzer\JustReadExprAnalyzer $justReadExprAnalyzer, PropertyFetchFinder $propertyFetchFinder, NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder) { $this->justReadExprAnalyzer = $justReadExprAnalyzer; $this->propertyFetchFinder = $propertyFetchFinder; $this->nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; } - public function supports(\PhpParser\Node\Expr $expr) : bool + public function supports(Expr $expr) : bool { - return $expr instanceof \PhpParser\Node\Expr\PropertyFetch || $expr instanceof \PhpParser\Node\Expr\StaticPropertyFetch; + return $expr instanceof PropertyFetch || $expr instanceof StaticPropertyFetch; } - public function isRead(\PhpParser\Node\Expr $expr) : bool + public function isRead(Expr $expr) : bool { - $class = $this->betterNodeFinder->findParentType($expr, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($expr, Class_::class); + if (!$class instanceof Class_) { // assume worse to keep node protected return \true; } diff --git a/packages/ReadWrite/ReadNodeAnalyzer/VariableReadNodeAnalyzer.php b/packages/ReadWrite/ReadNodeAnalyzer/VariableReadNodeAnalyzer.php index 4e1b326c189..2e86b0dd27e 100644 --- a/packages/ReadWrite/ReadNodeAnalyzer/VariableReadNodeAnalyzer.php +++ b/packages/ReadWrite/ReadNodeAnalyzer/VariableReadNodeAnalyzer.php @@ -11,7 +11,7 @@ use Rector\ReadWrite\NodeFinder\NodeUsageFinder; /** * @implements ReadNodeAnalyzerInterface */ -final class VariableReadNodeAnalyzer implements \Rector\ReadWrite\Contract\ReadNodeAnalyzerInterface +final class VariableReadNodeAnalyzer implements ReadNodeAnalyzerInterface { /** * @readonly @@ -28,20 +28,20 @@ final class VariableReadNodeAnalyzer implements \Rector\ReadWrite\Contract\ReadN * @var \Rector\ReadWrite\ReadNodeAnalyzer\JustReadExprAnalyzer */ private $justReadExprAnalyzer; - public function __construct(\Rector\NodeNestingScope\ParentScopeFinder $parentScopeFinder, \Rector\ReadWrite\NodeFinder\NodeUsageFinder $nodeUsageFinder, \Rector\ReadWrite\ReadNodeAnalyzer\JustReadExprAnalyzer $justReadExprAnalyzer) + public function __construct(ParentScopeFinder $parentScopeFinder, NodeUsageFinder $nodeUsageFinder, \Rector\ReadWrite\ReadNodeAnalyzer\JustReadExprAnalyzer $justReadExprAnalyzer) { $this->parentScopeFinder = $parentScopeFinder; $this->nodeUsageFinder = $nodeUsageFinder; $this->justReadExprAnalyzer = $justReadExprAnalyzer; } - public function supports(\PhpParser\Node\Expr $expr) : bool + public function supports(Expr $expr) : bool { - return $expr instanceof \PhpParser\Node\Expr\Variable; + return $expr instanceof Variable; } /** * @param Variable $expr */ - public function isRead(\PhpParser\Node\Expr $expr) : bool + public function isRead(Expr $expr) : bool { $parentScope = $this->parentScopeFinder->find($expr); if ($parentScope === null) { diff --git a/packages/Set/ValueObject/DowngradeLevelSetList.php b/packages/Set/ValueObject/DowngradeLevelSetList.php index 3220aa823be..ebbb47c9bbe 100644 --- a/packages/Set/ValueObject/DowngradeLevelSetList.php +++ b/packages/Set/ValueObject/DowngradeLevelSetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Set\ValueObject; use Rector\Set\Contract\SetListInterface; -final class DowngradeLevelSetList implements \Rector\Set\Contract\SetListInterface +final class DowngradeLevelSetList implements SetListInterface { /** * @var string diff --git a/packages/Set/ValueObject/DowngradeSetList.php b/packages/Set/ValueObject/DowngradeSetList.php index 008eda4867d..8cda7fb7c58 100644 --- a/packages/Set/ValueObject/DowngradeSetList.php +++ b/packages/Set/ValueObject/DowngradeSetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Set\ValueObject; use Rector\Set\Contract\SetListInterface; -final class DowngradeSetList implements \Rector\Set\Contract\SetListInterface +final class DowngradeSetList implements SetListInterface { /** * @var string diff --git a/packages/Set/ValueObject/LevelSetList.php b/packages/Set/ValueObject/LevelSetList.php index d06d0215c20..ca4e6678de8 100644 --- a/packages/Set/ValueObject/LevelSetList.php +++ b/packages/Set/ValueObject/LevelSetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Set\ValueObject; use Rector\Set\Contract\SetListInterface; -final class LevelSetList implements \Rector\Set\Contract\SetListInterface +final class LevelSetList implements SetListInterface { /** * @var string diff --git a/packages/Set/ValueObject/SetList.php b/packages/Set/ValueObject/SetList.php index 0df59e6af08..6fc680d49e2 100644 --- a/packages/Set/ValueObject/SetList.php +++ b/packages/Set/ValueObject/SetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Set\ValueObject; use Rector\Set\Contract\SetListInterface; -final class SetList implements \Rector\Set\Contract\SetListInterface +final class SetList implements SetListInterface { /** * @var string diff --git a/packages/StaticTypeMapper/Contract/PhpDocParser/PhpDocTypeMapperInterface.php b/packages/StaticTypeMapper/Contract/PhpDocParser/PhpDocTypeMapperInterface.php index 6a0a9c01322..28324f5ade4 100644 --- a/packages/StaticTypeMapper/Contract/PhpDocParser/PhpDocTypeMapperInterface.php +++ b/packages/StaticTypeMapper/Contract/PhpDocParser/PhpDocTypeMapperInterface.php @@ -19,5 +19,5 @@ interface PhpDocTypeMapperInterface /** * @param TTypeNode $typeNode */ - public function mapToPHPStanType(\PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode, \PhpParser\Node $node, \PHPStan\Analyser\NameScope $nameScope) : \PHPStan\Type\Type; + public function mapToPHPStanType(TypeNode $typeNode, Node $node, NameScope $nameScope) : Type; } diff --git a/packages/StaticTypeMapper/Contract/PhpParser/PhpParserNodeMapperInterface.php b/packages/StaticTypeMapper/Contract/PhpParser/PhpParserNodeMapperInterface.php index da9c48efcfd..f3a090872e4 100644 --- a/packages/StaticTypeMapper/Contract/PhpParser/PhpParserNodeMapperInterface.php +++ b/packages/StaticTypeMapper/Contract/PhpParser/PhpParserNodeMapperInterface.php @@ -17,5 +17,5 @@ interface PhpParserNodeMapperInterface /** * @param TNode $node */ - public function mapToPHPStan(\PhpParser\Node $node) : \PHPStan\Type\Type; + public function mapToPHPStan(Node $node) : Type; } diff --git a/packages/StaticTypeMapper/Mapper/PhpParserNodeMapper.php b/packages/StaticTypeMapper/Mapper/PhpParserNodeMapper.php index 962ec280bcc..036e139d8dd 100644 --- a/packages/StaticTypeMapper/Mapper/PhpParserNodeMapper.php +++ b/packages/StaticTypeMapper/Mapper/PhpParserNodeMapper.php @@ -26,10 +26,10 @@ final class PhpParserNodeMapper { $this->phpParserNodeMappers = $phpParserNodeMappers; } - public function mapToPHPStanType(\PhpParser\Node $node) : \PHPStan\Type\Type + public function mapToPHPStanType(Node $node) : Type { - if (\get_class($node) === \PhpParser\Node\Name::class && $node->hasAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NAMESPACED_NAME)) { - $node = new \PhpParser\Node\Name\FullyQualified($node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NAMESPACED_NAME)); + if (\get_class($node) === Name::class && $node->hasAttribute(AttributeKey::NAMESPACED_NAME)) { + $node = new FullyQualified($node->getAttribute(AttributeKey::NAMESPACED_NAME)); } foreach ($this->phpParserNodeMappers as $phpParserNodeMapper) { if (!\is_a($node, $phpParserNodeMapper->getNodeType())) { @@ -37,13 +37,13 @@ final class PhpParserNodeMapper } // do not let Expr collect all the types // note: can be solve later with priorities on mapper interface, making this last - if ($phpParserNodeMapper->getNodeType() !== \PhpParser\Node\Expr::class) { + if ($phpParserNodeMapper->getNodeType() !== Expr::class) { return $phpParserNodeMapper->mapToPHPStan($node); } - if (!$node instanceof \PhpParser\Node\Scalar\String_) { + if (!$node instanceof String_) { return $phpParserNodeMapper->mapToPHPStan($node); } } - throw new \Rector\Core\Exception\NotImplementedYetException(\get_class($node)); + throw new NotImplementedYetException(\get_class($node)); } } diff --git a/packages/StaticTypeMapper/Mapper/ScalarStringToTypeMapper.php b/packages/StaticTypeMapper/Mapper/ScalarStringToTypeMapper.php index 6b3ea75e57e..f0d79ef8bdc 100644 --- a/packages/StaticTypeMapper/Mapper/ScalarStringToTypeMapper.php +++ b/packages/StaticTypeMapper/Mapper/ScalarStringToTypeMapper.php @@ -25,15 +25,15 @@ final class ScalarStringToTypeMapper /** * @var array, string[]> */ - private const SCALAR_NAME_BY_TYPE = [\PHPStan\Type\StringType::class => ['string'], \PHPStan\Type\ClassStringType::class => ['class-string'], \PHPStan\Type\FloatType::class => ['float', 'real', 'double'], \PHPStan\Type\IntegerType::class => ['int', 'integer'], \PHPStan\Type\BooleanType::class => ['bool', 'boolean'], \PHPStan\Type\NullType::class => ['null'], \PHPStan\Type\VoidType::class => ['void'], \PHPStan\Type\ResourceType::class => ['resource'], \PHPStan\Type\CallableType::class => ['callback', 'callable'], \PHPStan\Type\ObjectWithoutClassType::class => ['object'], \PHPStan\Type\NeverType::class => ['never', 'never-return', 'never-returns', 'no-return']]; - public function mapScalarStringToType(string $scalarName) : \PHPStan\Type\Type + private const SCALAR_NAME_BY_TYPE = [StringType::class => ['string'], ClassStringType::class => ['class-string'], FloatType::class => ['float', 'real', 'double'], IntegerType::class => ['int', 'integer'], BooleanType::class => ['bool', 'boolean'], NullType::class => ['null'], VoidType::class => ['void'], ResourceType::class => ['resource'], CallableType::class => ['callback', 'callable'], ObjectWithoutClassType::class => ['object'], NeverType::class => ['never', 'never-return', 'never-returns', 'no-return']]; + public function mapScalarStringToType(string $scalarName) : Type { - $loweredScalarName = \RectorPrefix20220607\Nette\Utils\Strings::lower($scalarName); + $loweredScalarName = Strings::lower($scalarName); if ($loweredScalarName === 'false') { - return new \PHPStan\Type\Constant\ConstantBooleanType(\false); + return new ConstantBooleanType(\false); } if ($loweredScalarName === 'true') { - return new \PHPStan\Type\Constant\ConstantBooleanType(\true); + return new ConstantBooleanType(\true); } foreach (self::SCALAR_NAME_BY_TYPE as $objectType => $scalarNames) { if (!\in_array($loweredScalarName, $scalarNames, \true)) { @@ -42,14 +42,14 @@ final class ScalarStringToTypeMapper return new $objectType(); } if ($loweredScalarName === 'array') { - return new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); + return new ArrayType(new MixedType(), new MixedType()); } if ($loweredScalarName === 'iterable') { - return new \PHPStan\Type\IterableType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); + return new IterableType(new MixedType(), new MixedType()); } if ($loweredScalarName === 'mixed') { - return new \PHPStan\Type\MixedType(\true); + return new MixedType(\true); } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } } diff --git a/packages/StaticTypeMapper/Naming/NameScopeFactory.php b/packages/StaticTypeMapper/Naming/NameScopeFactory.php index 70f8a85c356..44a799c8ba0 100644 --- a/packages/StaticTypeMapper/Naming/NameScopeFactory.php +++ b/packages/StaticTypeMapper/Naming/NameScopeFactory.php @@ -44,32 +44,32 @@ final class NameScopeFactory /** * @required */ - public function autowire(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Naming\Naming\UseImportsResolver $useImportsResolver) : void + public function autowire(PhpDocInfoFactory $phpDocInfoFactory, StaticTypeMapper $staticTypeMapper, BetterNodeFinder $betterNodeFinder, UseImportsResolver $useImportsResolver) : void { $this->phpDocInfoFactory = $phpDocInfoFactory; $this->staticTypeMapper = $staticTypeMapper; $this->betterNodeFinder = $betterNodeFinder; $this->useImportsResolver = $useImportsResolver; } - public function createNameScopeFromNodeWithoutTemplateTypes(\PhpParser\Node $node) : \PHPStan\Analyser\NameScope + public function createNameScopeFromNodeWithoutTemplateTypes(Node $node) : NameScope { - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - $namespace = $scope instanceof \PHPStan\Analyser\Scope ? $scope->getNamespace() : null; + $scope = $node->getAttribute(AttributeKey::SCOPE); + $namespace = $scope instanceof Scope ? $scope->getNamespace() : null; $uses = $this->useImportsResolver->resolveForNode($node); $usesAliasesToNames = $this->resolveUseNamesByAlias($uses); - if ($scope instanceof \PHPStan\Analyser\Scope && $scope->getClassReflection() instanceof \PHPStan\Reflection\ClassReflection) { + if ($scope instanceof Scope && $scope->getClassReflection() instanceof ClassReflection) { $classReflection = $scope->getClassReflection(); $className = $classReflection->getName(); } else { $className = null; } - return new \PHPStan\Analyser\NameScope($namespace, $usesAliasesToNames, $className); + return new NameScope($namespace, $usesAliasesToNames, $className); } - public function createNameScopeFromNode(\PhpParser\Node $node) : \PHPStan\Analyser\NameScope + public function createNameScopeFromNode(Node $node) : NameScope { $nameScope = $this->createNameScopeFromNodeWithoutTemplateTypes($node); $templateTypeMap = $this->templateTemplateTypeMap($node); - return new \PHPStan\Analyser\NameScope($nameScope->getNamespace(), $nameScope->getUses(), $nameScope->getClassName(), null, $templateTypeMap); + return new NameScope($nameScope->getNamespace(), $nameScope->getUses(), $nameScope->getClassName(), null, $templateTypeMap); } /** * @param Use_[]|GroupUse[] $useNodes @@ -79,7 +79,7 @@ final class NameScopeFactory { $useNamesByAlias = []; foreach ($useNodes as $useNode) { - $prefix = $useNode instanceof \PhpParser\Node\Stmt\GroupUse ? $useNode->prefix . '\\' : ''; + $prefix = $useNode instanceof GroupUse ? $useNode->prefix . '\\' : ''; foreach ($useNode->uses as $useUse) { /** @var UseUse $useUse */ $aliasName = $useUse->getAlias()->name; @@ -90,21 +90,21 @@ final class NameScopeFactory } return $useNamesByAlias; } - private function templateTemplateTypeMap(\PhpParser\Node $node) : \PHPStan\Type\Generic\TemplateTypeMap + private function templateTemplateTypeMap(Node $node) : TemplateTypeMap { $nodeTemplateTypes = $this->resolveTemplateTypesFromNode($node); - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassLike::class); + $classLike = $this->betterNodeFinder->findParentType($node, ClassLike::class); $classTemplateTypes = []; - if ($classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + if ($classLike instanceof ClassLike) { $classTemplateTypes = $this->resolveTemplateTypesFromNode($classLike); } $templateTypes = \array_merge($nodeTemplateTypes, $classTemplateTypes); - return new \PHPStan\Type\Generic\TemplateTypeMap($templateTypes); + return new TemplateTypeMap($templateTypes); } /** * @return Type[] */ - private function resolveTemplateTypesFromNode(\PhpParser\Node $node) : array + private function resolveTemplateTypesFromNode(Node $node) : array { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $templateTypes = []; diff --git a/packages/StaticTypeMapper/PhpDoc/PhpDocTypeMapper.php b/packages/StaticTypeMapper/PhpDoc/PhpDocTypeMapper.php index 7050330dfa1..97b9319ea7c 100644 --- a/packages/StaticTypeMapper/PhpDoc/PhpDocTypeMapper.php +++ b/packages/StaticTypeMapper/PhpDoc/PhpDocTypeMapper.php @@ -27,12 +27,12 @@ final class PhpDocTypeMapper /** * @param PhpDocTypeMapperInterface[] $phpDocTypeMappers */ - public function __construct(array $phpDocTypeMappers, \PHPStan\PhpDoc\TypeNodeResolver $typeNodeResolver) + public function __construct(array $phpDocTypeMappers, TypeNodeResolver $typeNodeResolver) { $this->phpDocTypeMappers = $phpDocTypeMappers; $this->typeNodeResolver = $typeNodeResolver; } - public function mapToPHPStanType(\PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode, \PhpParser\Node $node, \PHPStan\Analyser\NameScope $nameScope) : \PHPStan\Type\Type + public function mapToPHPStanType(TypeNode $typeNode, Node $node, NameScope $nameScope) : Type { foreach ($this->phpDocTypeMappers as $phpDocTypeMapper) { if (!\is_a($typeNode, $phpDocTypeMapper->getNodeType())) { diff --git a/packages/StaticTypeMapper/PhpDocParser/IdentifierTypeMapper.php b/packages/StaticTypeMapper/PhpDocParser/IdentifierTypeMapper.php index 1e098205575..f38d445189a 100644 --- a/packages/StaticTypeMapper/PhpDocParser/IdentifierTypeMapper.php +++ b/packages/StaticTypeMapper/PhpDocParser/IdentifierTypeMapper.php @@ -34,7 +34,7 @@ use Rector\TypeDeclaration\PHPStan\ObjectTypeSpecifier; /** * @implements PhpDocTypeMapperInterface */ -final class IdentifierTypeMapper implements \Rector\StaticTypeMapper\Contract\PhpDocParser\PhpDocTypeMapperInterface +final class IdentifierTypeMapper implements PhpDocTypeMapperInterface { /** * @readonly @@ -61,7 +61,7 @@ final class IdentifierTypeMapper implements \Rector\StaticTypeMapper\Contract\Ph * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\TypeDeclaration\PHPStan\ObjectTypeSpecifier $objectTypeSpecifier, \Rector\StaticTypeMapper\Mapper\ScalarStringToTypeMapper $scalarStringToTypeMapper, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ObjectTypeSpecifier $objectTypeSpecifier, ScalarStringToTypeMapper $scalarStringToTypeMapper, BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider) { $this->objectTypeSpecifier = $objectTypeSpecifier; $this->scalarStringToTypeMapper = $scalarStringToTypeMapper; @@ -71,96 +71,96 @@ final class IdentifierTypeMapper implements \Rector\StaticTypeMapper\Contract\Ph } public function getNodeType() : string { - return \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode::class; + return IdentifierTypeNode::class; } /** * @param IdentifierTypeNode $typeNode */ - public function mapToPHPStanType(\PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode, \PhpParser\Node $node, \PHPStan\Analyser\NameScope $nameScope) : \PHPStan\Type\Type + public function mapToPHPStanType(TypeNode $typeNode, Node $node, NameScope $nameScope) : Type { $type = $this->scalarStringToTypeMapper->mapScalarStringToType($typeNode->name); - if (!$type instanceof \PHPStan\Type\MixedType) { + if (!$type instanceof MixedType) { return $type; } if ($type->isExplicitMixed()) { return $type; } $loweredName = \strtolower($typeNode->name); - if ($loweredName === \Rector\Core\Enum\ObjectReference::SELF) { + if ($loweredName === ObjectReference::SELF) { return $this->mapSelf($node); } - if ($loweredName === \Rector\Core\Enum\ObjectReference::PARENT) { + if ($loweredName === ObjectReference::PARENT) { return $this->mapParent($node); } - if ($loweredName === \Rector\Core\Enum\ObjectReference::STATIC) { + if ($loweredName === ObjectReference::STATIC) { return $this->mapStatic($node); } if ($loweredName === 'iterable') { - return new \PHPStan\Type\IterableType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); + return new IterableType(new MixedType(), new MixedType()); } if (\strncmp($typeNode->name, '\\', \strlen('\\')) === 0) { - $typeWithoutPreslash = \RectorPrefix20220607\Nette\Utils\Strings::substring($typeNode->name, 1); - $objectType = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($typeWithoutPreslash); + $typeWithoutPreslash = Strings::substring($typeNode->name, 1); + $objectType = new FullyQualifiedObjectType($typeWithoutPreslash); } else { if ($typeNode->name === 'scalar') { // pseudo type, see https://www.php.net/manual/en/language.types.intro.php - $scalarTypes = [new \PHPStan\Type\BooleanType(), new \PHPStan\Type\StringType(), new \PHPStan\Type\IntegerType(), new \PHPStan\Type\FloatType()]; - return new \PHPStan\Type\UnionType($scalarTypes); + $scalarTypes = [new BooleanType(), new StringType(), new IntegerType(), new FloatType()]; + return new UnionType($scalarTypes); } - $objectType = new \PHPStan\Type\ObjectType($typeNode->name); + $objectType = new ObjectType($typeNode->name); } - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $node->getAttribute(AttributeKey::SCOPE); return $this->objectTypeSpecifier->narrowToFullyQualifiedOrAliasedObjectType($node, $objectType, $scope); } /** * @return \PHPStan\Type\MixedType|\Rector\StaticTypeMapper\ValueObject\Type\SelfObjectType */ - private function mapSelf(\PhpParser\Node $node) + private function mapSelf(Node $node) { // @todo check FQN $className = $this->resolveClassName($node); if (!\is_string($className)) { // self outside the class, e.g. in a function - return new \PHPStan\Type\MixedType(); + return new MixedType(); } - return new \Rector\StaticTypeMapper\ValueObject\Type\SelfObjectType($className); + return new SelfObjectType($className); } /** * @return \Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType|\PHPStan\Type\MixedType */ - private function mapParent(\PhpParser\Node $node) + private function mapParent(Node $node) { $className = $this->resolveClassName($node); if (!\is_string($className)) { // parent outside the class, e.g. in a function - return new \PHPStan\Type\MixedType(); + return new MixedType(); } /** @var ClassReflection $classReflection */ $classReflection = $this->reflectionProvider->getClass($className); $parentClassReflection = $classReflection->getParentClass(); - if (!$parentClassReflection instanceof \PHPStan\Reflection\ClassReflection) { - return new \PHPStan\Type\MixedType(); + if (!$parentClassReflection instanceof ClassReflection) { + return new MixedType(); } - return new \Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType($parentClassReflection); + return new ParentStaticType($parentClassReflection); } /** * @return \PHPStan\Type\MixedType|\PHPStan\Type\StaticType */ - private function mapStatic(\PhpParser\Node $node) + private function mapStatic(Node $node) { $className = $this->resolveClassName($node); if (!\is_string($className)) { // static outside the class, e.g. in a function - return new \PHPStan\Type\MixedType(); + return new MixedType(); } /** @var ClassReflection $classReflection */ $classReflection = $this->reflectionProvider->getClass($className); - return new \PHPStan\Type\StaticType($classReflection); + return new StaticType($classReflection); } - private function resolveClassName(\PhpParser\Node $node) : ?string + private function resolveClassName(Node $node) : ?string { - $classLike = $node instanceof \PhpParser\Node\Stmt\ClassLike ? $node : $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $node instanceof ClassLike ? $node : $this->betterNodeFinder->findParentType($node, ClassLike::class); + if (!$classLike instanceof ClassLike) { return null; } $className = $this->nodeNameResolver->getName($classLike); diff --git a/packages/StaticTypeMapper/PhpDocParser/IntersectionTypeMapper.php b/packages/StaticTypeMapper/PhpDocParser/IntersectionTypeMapper.php index bc1a8d0f915..410a92acfd9 100644 --- a/packages/StaticTypeMapper/PhpDocParser/IntersectionTypeMapper.php +++ b/packages/StaticTypeMapper/PhpDocParser/IntersectionTypeMapper.php @@ -15,7 +15,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements PhpDocTypeMapperInterface */ -final class IntersectionTypeMapper implements \Rector\StaticTypeMapper\Contract\PhpDocParser\PhpDocTypeMapperInterface +final class IntersectionTypeMapper implements PhpDocTypeMapperInterface { /** * @var \Rector\StaticTypeMapper\PhpDoc\PhpDocTypeMapper @@ -23,24 +23,24 @@ final class IntersectionTypeMapper implements \Rector\StaticTypeMapper\Contract\ private $phpDocTypeMapper; public function getNodeType() : string { - return \PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode::class; + return IntersectionTypeNode::class; } /** * @required */ - public function autowire(\Rector\StaticTypeMapper\PhpDoc\PhpDocTypeMapper $phpDocTypeMapper) : void + public function autowire(PhpDocTypeMapper $phpDocTypeMapper) : void { $this->phpDocTypeMapper = $phpDocTypeMapper; } /** * @param IntersectionTypeNode $typeNode */ - public function mapToPHPStanType(\PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode, \PhpParser\Node $node, \PHPStan\Analyser\NameScope $nameScope) : \PHPStan\Type\Type + public function mapToPHPStanType(TypeNode $typeNode, Node $node, NameScope $nameScope) : Type { $intersectionedTypes = []; foreach ($typeNode->types as $intersectionedTypeNode) { $intersectionedTypes[] = $this->phpDocTypeMapper->mapToPHPStanType($intersectionedTypeNode, $node, $nameScope); } - return new \PHPStan\Type\IntersectionType($intersectionedTypes); + return new IntersectionType($intersectionedTypes); } } diff --git a/packages/StaticTypeMapper/PhpDocParser/NullableTypeMapper.php b/packages/StaticTypeMapper/PhpDocParser/NullableTypeMapper.php index db37f09b70f..7447027951a 100644 --- a/packages/StaticTypeMapper/PhpDocParser/NullableTypeMapper.php +++ b/packages/StaticTypeMapper/PhpDocParser/NullableTypeMapper.php @@ -16,7 +16,7 @@ use Rector\StaticTypeMapper\Contract\PhpDocParser\PhpDocTypeMapperInterface; /** * @implements PhpDocTypeMapperInterface */ -final class NullableTypeMapper implements \Rector\StaticTypeMapper\Contract\PhpDocParser\PhpDocTypeMapperInterface +final class NullableTypeMapper implements PhpDocTypeMapperInterface { /** * @readonly @@ -28,23 +28,23 @@ final class NullableTypeMapper implements \Rector\StaticTypeMapper\Contract\PhpD * @var \PHPStan\PhpDoc\TypeNodeResolver */ private $typeNodeResolver; - public function __construct(\Rector\StaticTypeMapper\PhpDocParser\IdentifierTypeMapper $identifierTypeMapper, \PHPStan\PhpDoc\TypeNodeResolver $typeNodeResolver) + public function __construct(\Rector\StaticTypeMapper\PhpDocParser\IdentifierTypeMapper $identifierTypeMapper, TypeNodeResolver $typeNodeResolver) { $this->identifierTypeMapper = $identifierTypeMapper; $this->typeNodeResolver = $typeNodeResolver; } public function getNodeType() : string { - return \PHPStan\PhpDocParser\Ast\Type\NullableTypeNode::class; + return NullableTypeNode::class; } /** * @param NullableTypeNode $typeNode */ - public function mapToPHPStanType(\PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode, \PhpParser\Node $node, \PHPStan\Analyser\NameScope $nameScope) : \PHPStan\Type\Type + public function mapToPHPStanType(TypeNode $typeNode, Node $node, NameScope $nameScope) : Type { - if ($typeNode->type instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode) { + if ($typeNode->type instanceof IdentifierTypeNode) { $type = $this->identifierTypeMapper->mapToPHPStanType($typeNode->type, $node, $nameScope); - return new \PHPStan\Type\UnionType([new \PHPStan\Type\NullType(), $type]); + return new UnionType([new NullType(), $type]); } // fallback to PHPStan resolver return $this->typeNodeResolver->resolve($typeNode, $nameScope); diff --git a/packages/StaticTypeMapper/PhpDocParser/UnionTypeMapper.php b/packages/StaticTypeMapper/PhpDocParser/UnionTypeMapper.php index 575cd916b76..5e2939130a3 100644 --- a/packages/StaticTypeMapper/PhpDocParser/UnionTypeMapper.php +++ b/packages/StaticTypeMapper/PhpDocParser/UnionTypeMapper.php @@ -15,7 +15,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements PhpDocTypeMapperInterface */ -final class UnionTypeMapper implements \Rector\StaticTypeMapper\Contract\PhpDocParser\PhpDocTypeMapperInterface +final class UnionTypeMapper implements PhpDocTypeMapperInterface { /** * @var \Rector\StaticTypeMapper\PhpDoc\PhpDocTypeMapper @@ -26,25 +26,25 @@ final class UnionTypeMapper implements \Rector\StaticTypeMapper\Contract\PhpDocP * @var \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory */ private $typeFactory; - public function __construct(\Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory) + public function __construct(TypeFactory $typeFactory) { $this->typeFactory = $typeFactory; } public function getNodeType() : string { - return \PHPStan\PhpDocParser\Ast\Type\UnionTypeNode::class; + return UnionTypeNode::class; } /** * @required */ - public function autowire(\Rector\StaticTypeMapper\PhpDoc\PhpDocTypeMapper $phpDocTypeMapper) : void + public function autowire(PhpDocTypeMapper $phpDocTypeMapper) : void { $this->phpDocTypeMapper = $phpDocTypeMapper; } /** * @param UnionTypeNode $typeNode */ - public function mapToPHPStanType(\PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode, \PhpParser\Node $node, \PHPStan\Analyser\NameScope $nameScope) : \PHPStan\Type\Type + public function mapToPHPStanType(TypeNode $typeNode, Node $node, NameScope $nameScope) : Type { $unionedTypes = []; foreach ($typeNode->types as $unionedTypeNode) { diff --git a/packages/StaticTypeMapper/PhpParser/ExprNodeMapper.php b/packages/StaticTypeMapper/PhpParser/ExprNodeMapper.php index 014ad3b6e12..3258d711134 100644 --- a/packages/StaticTypeMapper/PhpParser/ExprNodeMapper.php +++ b/packages/StaticTypeMapper/PhpParser/ExprNodeMapper.php @@ -13,20 +13,20 @@ use Rector\StaticTypeMapper\Contract\PhpParser\PhpParserNodeMapperInterface; /** * @implements PhpParserNodeMapperInterface */ -final class ExprNodeMapper implements \Rector\StaticTypeMapper\Contract\PhpParser\PhpParserNodeMapperInterface +final class ExprNodeMapper implements PhpParserNodeMapperInterface { public function getNodeType() : string { - return \PhpParser\Node\Expr::class; + return Expr::class; } /** * @param Expr $node */ - public function mapToPHPStan(\PhpParser\Node $node) : \PHPStan\Type\Type + public function mapToPHPStan(Node $node) : Type { - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { - return new \PHPStan\Type\MixedType(); + $scope = $node->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { + return new MixedType(); } return $scope->getType($node); } diff --git a/packages/StaticTypeMapper/PhpParser/FullyQualifiedNodeMapper.php b/packages/StaticTypeMapper/PhpParser/FullyQualifiedNodeMapper.php index 2e2d5329d09..3190926f574 100644 --- a/packages/StaticTypeMapper/PhpParser/FullyQualifiedNodeMapper.php +++ b/packages/StaticTypeMapper/PhpParser/FullyQualifiedNodeMapper.php @@ -18,7 +18,7 @@ use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; /** * @implements PhpParserNodeMapperInterface */ -final class FullyQualifiedNodeMapper implements \Rector\StaticTypeMapper\Contract\PhpParser\PhpParserNodeMapperInterface +final class FullyQualifiedNodeMapper implements PhpParserNodeMapperInterface { /** * @readonly @@ -30,53 +30,53 @@ final class FullyQualifiedNodeMapper implements \Rector\StaticTypeMapper\Contrac * @var \Rector\CodingStyle\ClassNameImport\UsedImportsResolver */ private $usedImportsResolver; - public function __construct(\Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \Rector\CodingStyle\ClassNameImport\UsedImportsResolver $usedImportsResolver) + public function __construct(CurrentFileProvider $currentFileProvider, UsedImportsResolver $usedImportsResolver) { $this->currentFileProvider = $currentFileProvider; $this->usedImportsResolver = $usedImportsResolver; } public function getNodeType() : string { - return \PhpParser\Node\Name\FullyQualified::class; + return FullyQualified::class; } /** * @param FullyQualified $node */ - public function mapToPHPStan(\PhpParser\Node $node) : \PHPStan\Type\Type + public function mapToPHPStan(Node $node) : Type { - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); if ($this->isParamTyped($node, $parent)) { $possibleAliasedObjectType = $this->resolvePossibleAliasedObjectType($node); - if ($possibleAliasedObjectType instanceof \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType) { + if ($possibleAliasedObjectType instanceof AliasedObjectType) { return $possibleAliasedObjectType; } } - $originalName = (string) $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NAME); + $originalName = (string) $node->getAttribute(AttributeKey::ORIGINAL_NAME); $fullyQualifiedName = $node->toString(); // is aliased? if ($this->isAliasedName($originalName, $fullyQualifiedName) && $originalName !== $fullyQualifiedName) { - return new \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType($originalName, $fullyQualifiedName); + return new AliasedObjectType($originalName, $fullyQualifiedName); } - return new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($fullyQualifiedName); + return new FullyQualifiedObjectType($fullyQualifiedName); } - private function isParamTyped(\PhpParser\Node\Name\FullyQualified $fullyQualified, ?\PhpParser\Node $node) : bool + private function isParamTyped(FullyQualified $fullyQualified, ?Node $node) : bool { - if ($node instanceof \PhpParser\Node\Param && $node->type === $fullyQualified) { + if ($node instanceof Param && $node->type === $fullyQualified) { return \true; } - if (!$node instanceof \PhpParser\Node\NullableType) { + if (!$node instanceof NullableType) { return \false; } - $parentOfParent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentOfParent instanceof \PhpParser\Node\Param) { + $parentOfParent = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentOfParent instanceof Param) { return \false; } return $node->type === $fullyQualified; } - private function resolvePossibleAliasedObjectType(\PhpParser\Node\Name\FullyQualified $fullyQualified) : ?\Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType + private function resolvePossibleAliasedObjectType(FullyQualified $fullyQualified) : ?AliasedObjectType { $file = $this->currentFileProvider->getFile(); - if (!$file instanceof \Rector\Core\ValueObject\Application\File) { + if (!$file instanceof File) { return null; } $oldTokens = $file->getOldTokens(); @@ -90,7 +90,7 @@ final class FullyQualifiedNodeMapper implements \Rector\StaticTypeMapper\Contrac } $objectTypes = $this->usedImportsResolver->resolveForNode($fullyQualified); foreach ($objectTypes as $objectType) { - if (!$objectType instanceof \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType) { + if (!$objectType instanceof AliasedObjectType) { continue; } if ($objectType->getClassName() !== $type) { diff --git a/packages/StaticTypeMapper/PhpParser/IdentifierNodeMapper.php b/packages/StaticTypeMapper/PhpParser/IdentifierNodeMapper.php index ccb6fa81e01..a753c58920e 100644 --- a/packages/StaticTypeMapper/PhpParser/IdentifierNodeMapper.php +++ b/packages/StaticTypeMapper/PhpParser/IdentifierNodeMapper.php @@ -11,25 +11,25 @@ use Rector\StaticTypeMapper\Mapper\ScalarStringToTypeMapper; /** * @implements PhpParserNodeMapperInterface */ -final class IdentifierNodeMapper implements \Rector\StaticTypeMapper\Contract\PhpParser\PhpParserNodeMapperInterface +final class IdentifierNodeMapper implements PhpParserNodeMapperInterface { /** * @readonly * @var \Rector\StaticTypeMapper\Mapper\ScalarStringToTypeMapper */ private $scalarStringToTypeMapper; - public function __construct(\Rector\StaticTypeMapper\Mapper\ScalarStringToTypeMapper $scalarStringToTypeMapper) + public function __construct(ScalarStringToTypeMapper $scalarStringToTypeMapper) { $this->scalarStringToTypeMapper = $scalarStringToTypeMapper; } public function getNodeType() : string { - return \PhpParser\Node\Identifier::class; + return Identifier::class; } /** * @param Identifier $node */ - public function mapToPHPStan(\PhpParser\Node $node) : \PHPStan\Type\Type + public function mapToPHPStan(Node $node) : Type { return $this->scalarStringToTypeMapper->mapScalarStringToType($node->name); } diff --git a/packages/StaticTypeMapper/PhpParser/IntersectionTypeNodeMapper.php b/packages/StaticTypeMapper/PhpParser/IntersectionTypeNodeMapper.php index 68287915627..d0ea0071831 100644 --- a/packages/StaticTypeMapper/PhpParser/IntersectionTypeNodeMapper.php +++ b/packages/StaticTypeMapper/PhpParser/IntersectionTypeNodeMapper.php @@ -12,7 +12,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements PhpParserNodeMapperInterface */ -final class IntersectionTypeNodeMapper implements \Rector\StaticTypeMapper\Contract\PhpParser\PhpParserNodeMapperInterface +final class IntersectionTypeNodeMapper implements PhpParserNodeMapperInterface { /** * @var \Rector\StaticTypeMapper\Mapper\PhpParserNodeMapper @@ -21,23 +21,23 @@ final class IntersectionTypeNodeMapper implements \Rector\StaticTypeMapper\Contr /** * @required */ - public function autowire(\Rector\StaticTypeMapper\Mapper\PhpParserNodeMapper $phpParserNodeMapper) : void + public function autowire(PhpParserNodeMapper $phpParserNodeMapper) : void { $this->phpParserNodeMapper = $phpParserNodeMapper; } public function getNodeType() : string { - return \PhpParser\Node\IntersectionType::class; + return Node\IntersectionType::class; } /** * @param Node\IntersectionType $node */ - public function mapToPHPStan(\PhpParser\Node $node) : \PHPStan\Type\Type + public function mapToPHPStan(Node $node) : Type { $types = []; foreach ($node->types as $intersectionedType) { $types[] = $this->phpParserNodeMapper->mapToPHPStanType($intersectionedType); } - return new \PHPStan\Type\IntersectionType($types); + return new IntersectionType($types); } } diff --git a/packages/StaticTypeMapper/PhpParser/NameNodeMapper.php b/packages/StaticTypeMapper/PhpParser/NameNodeMapper.php index 2f0a0d147df..ac65c7489ad 100644 --- a/packages/StaticTypeMapper/PhpParser/NameNodeMapper.php +++ b/packages/StaticTypeMapper/PhpParser/NameNodeMapper.php @@ -30,7 +30,7 @@ use Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType; /** * @implements PhpParserNodeMapperInterface */ -final class NameNodeMapper implements \Rector\StaticTypeMapper\Contract\PhpParser\PhpParserNodeMapperInterface +final class NameNodeMapper implements PhpParserNodeMapperInterface { /** * @readonly @@ -52,7 +52,7 @@ final class NameNodeMapper implements \Rector\StaticTypeMapper\Contract\PhpParse * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\Core\Configuration\RenamedClassesDataCollector $renamedClassesDataCollector, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(RenamedClassesDataCollector $renamedClassesDataCollector, ReflectionProvider $reflectionProvider, BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver) { $this->renamedClassesDataCollector = $renamedClassesDataCollector; $this->reflectionProvider = $reflectionProvider; @@ -61,18 +61,18 @@ final class NameNodeMapper implements \Rector\StaticTypeMapper\Contract\PhpParse } public function getNodeType() : string { - return \PhpParser\Node\Name::class; + return Name::class; } /** * @param Name $node */ - public function mapToPHPStan(\PhpParser\Node $node) : \PHPStan\Type\Type + public function mapToPHPStan(Node $node) : Type { $name = $node->toString(); if ($this->isExistingClass($name)) { - return new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($name); + return new FullyQualifiedObjectType($name); } - if (\in_array($name, [\Rector\Core\Enum\ObjectReference::STATIC, \Rector\Core\Enum\ObjectReference::SELF, \Rector\Core\Enum\ObjectReference::PARENT], \true)) { + if (\in_array($name, [ObjectReference::STATIC, ObjectReference::SELF, ObjectReference::PARENT], \true)) { return $this->createClassReferenceType($node, $name); } return $this->createScalarType($name); @@ -89,25 +89,25 @@ final class NameNodeMapper implements \Rector\StaticTypeMapper\Contract\PhpParse /** * @return \PHPStan\Type\MixedType|\PHPStan\Type\StaticType|\PHPStan\Type\ObjectWithoutClassType */ - private function createClassReferenceType(\PhpParser\Node\Name $name, string $reference) + private function createClassReferenceType(Name $name, string $reference) { - $classLike = $this->betterNodeFinder->findParentType($name, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { - return new \PHPStan\Type\MixedType(); + $classLike = $this->betterNodeFinder->findParentType($name, ClassLike::class); + if (!$classLike instanceof ClassLike) { + return new MixedType(); } $className = (string) $this->nodeNameResolver->getName($classLike); $classReflection = $this->reflectionProvider->getClass($className); - if ($reference === \Rector\Core\Enum\ObjectReference::STATIC) { - return new \PHPStan\Type\StaticType($classReflection); + if ($reference === ObjectReference::STATIC) { + return new StaticType($classReflection); } - if ($reference === \Rector\Core\Enum\ObjectReference::PARENT) { + if ($reference === ObjectReference::PARENT) { $parentClassReflection = $classReflection->getParentClass(); - if ($parentClassReflection instanceof \PHPStan\Reflection\ClassReflection) { - return new \Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType($parentClassReflection); + if ($parentClassReflection instanceof ClassReflection) { + return new ParentStaticType($parentClassReflection); } - return new \Rector\StaticTypeMapper\ValueObject\Type\ParentObjectWithoutClassType(); + return new ParentObjectWithoutClassType(); } - return new \PHPStan\Type\ThisType($classReflection); + return new ThisType($classReflection); } /** * @return \PHPStan\Type\ArrayType|\PHPStan\Type\IntegerType|\PHPStan\Type\FloatType|\PHPStan\Type\StringType|\PHPStan\Type\Constant\ConstantBooleanType|\PHPStan\Type\BooleanType|\PHPStan\Type\MixedType @@ -115,23 +115,23 @@ final class NameNodeMapper implements \Rector\StaticTypeMapper\Contract\PhpParse private function createScalarType(string $name) { if ($name === 'array') { - return new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); + return new ArrayType(new MixedType(), new MixedType()); } if ($name === 'int') { - return new \PHPStan\Type\IntegerType(); + return new IntegerType(); } if ($name === 'float') { - return new \PHPStan\Type\FloatType(); + return new FloatType(); } if ($name === 'string') { - return new \PHPStan\Type\StringType(); + return new StringType(); } if ($name === 'false') { - return new \PHPStan\Type\Constant\ConstantBooleanType(\false); + return new ConstantBooleanType(\false); } if ($name === 'bool') { - return new \PHPStan\Type\BooleanType(); + return new BooleanType(); } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } } diff --git a/packages/StaticTypeMapper/PhpParser/NullableTypeNodeMapper.php b/packages/StaticTypeMapper/PhpParser/NullableTypeNodeMapper.php index d0e71e87dcd..b18fc33ead1 100644 --- a/packages/StaticTypeMapper/PhpParser/NullableTypeNodeMapper.php +++ b/packages/StaticTypeMapper/PhpParser/NullableTypeNodeMapper.php @@ -14,7 +14,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements PhpParserNodeMapperInterface */ -final class NullableTypeNodeMapper implements \Rector\StaticTypeMapper\Contract\PhpParser\PhpParserNodeMapperInterface +final class NullableTypeNodeMapper implements PhpParserNodeMapperInterface { /** * @var \Rector\StaticTypeMapper\Mapper\PhpParserNodeMapper @@ -25,29 +25,29 @@ final class NullableTypeNodeMapper implements \Rector\StaticTypeMapper\Contract\ * @var \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory */ private $typeFactory; - public function __construct(\Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory) + public function __construct(TypeFactory $typeFactory) { $this->typeFactory = $typeFactory; } /** * @required */ - public function autowire(\Rector\StaticTypeMapper\Mapper\PhpParserNodeMapper $phpParserNodeMapper) : void + public function autowire(PhpParserNodeMapper $phpParserNodeMapper) : void { $this->phpParserNodeMapper = $phpParserNodeMapper; } public function getNodeType() : string { - return \PhpParser\Node\NullableType::class; + return NullableType::class; } /** * @param NullableType $node */ - public function mapToPHPStan(\PhpParser\Node $node) : \PHPStan\Type\Type + public function mapToPHPStan(Node $node) : Type { $types = []; $types[] = $this->phpParserNodeMapper->mapToPHPStanType($node->type); - $types[] = new \PHPStan\Type\NullType(); + $types[] = new NullType(); return $this->typeFactory->createMixedPassedOrUnionType($types); } } diff --git a/packages/StaticTypeMapper/PhpParser/StringNodeMapper.php b/packages/StaticTypeMapper/PhpParser/StringNodeMapper.php index 82757345970..f6372424433 100644 --- a/packages/StaticTypeMapper/PhpParser/StringNodeMapper.php +++ b/packages/StaticTypeMapper/PhpParser/StringNodeMapper.php @@ -11,17 +11,17 @@ use Rector\StaticTypeMapper\Contract\PhpParser\PhpParserNodeMapperInterface; /** * @implements PhpParserNodeMapperInterface */ -final class StringNodeMapper implements \Rector\StaticTypeMapper\Contract\PhpParser\PhpParserNodeMapperInterface +final class StringNodeMapper implements PhpParserNodeMapperInterface { public function getNodeType() : string { - return \PhpParser\Node\Scalar\String_::class; + return String_::class; } /** * @param String_ $node */ - public function mapToPHPStan(\PhpParser\Node $node) : \PHPStan\Type\Type + public function mapToPHPStan(Node $node) : Type { - return new \PHPStan\Type\StringType(); + return new StringType(); } } diff --git a/packages/StaticTypeMapper/PhpParser/UnionTypeNodeMapper.php b/packages/StaticTypeMapper/PhpParser/UnionTypeNodeMapper.php index a24d6575d7c..e7e28c7517d 100644 --- a/packages/StaticTypeMapper/PhpParser/UnionTypeNodeMapper.php +++ b/packages/StaticTypeMapper/PhpParser/UnionTypeNodeMapper.php @@ -13,7 +13,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; /** * @implements PhpParserNodeMapperInterface */ -final class UnionTypeNodeMapper implements \Rector\StaticTypeMapper\Contract\PhpParser\PhpParserNodeMapperInterface +final class UnionTypeNodeMapper implements PhpParserNodeMapperInterface { /** * @var \Rector\StaticTypeMapper\Mapper\PhpParserNodeMapper @@ -24,25 +24,25 @@ final class UnionTypeNodeMapper implements \Rector\StaticTypeMapper\Contract\Php * @var \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory */ private $typeFactory; - public function __construct(\Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory) + public function __construct(TypeFactory $typeFactory) { $this->typeFactory = $typeFactory; } /** * @required */ - public function autowire(\Rector\StaticTypeMapper\Mapper\PhpParserNodeMapper $phpParserNodeMapper) : void + public function autowire(PhpParserNodeMapper $phpParserNodeMapper) : void { $this->phpParserNodeMapper = $phpParserNodeMapper; } public function getNodeType() : string { - return \PhpParser\Node\UnionType::class; + return UnionType::class; } /** * @param UnionType $node */ - public function mapToPHPStan(\PhpParser\Node $node) : \PHPStan\Type\Type + public function mapToPHPStan(Node $node) : Type { $types = []; foreach ($node->types as $unionedType) { diff --git a/packages/StaticTypeMapper/StaticTypeMapper.php b/packages/StaticTypeMapper/StaticTypeMapper.php index 9317b704bbc..39ab78c6d44 100644 --- a/packages/StaticTypeMapper/StaticTypeMapper.php +++ b/packages/StaticTypeMapper/StaticTypeMapper.php @@ -61,7 +61,7 @@ final class StaticTypeMapper * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\StaticTypeMapper\Naming\NameScopeFactory $nameScopeFactory, \Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper $phpStanStaticTypeMapper, \Rector\StaticTypeMapper\PhpDoc\PhpDocTypeMapper $phpDocTypeMapper, \Rector\StaticTypeMapper\Mapper\PhpParserNodeMapper $phpParserNodeMapper, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NameScopeFactory $nameScopeFactory, PHPStanStaticTypeMapper $phpStanStaticTypeMapper, PhpDocTypeMapper $phpDocTypeMapper, PhpParserNodeMapper $phpParserNodeMapper, NodeNameResolver $nodeNameResolver) { $this->nameScopeFactory = $nameScopeFactory; $this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper; @@ -72,7 +72,7 @@ final class StaticTypeMapper /** * @param TypeKind::* $typeKind */ - public function mapPHPStanTypeToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $phpStanType, string $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function mapPHPStanTypeToPHPStanPhpDocTypeNode(Type $phpStanType, string $typeKind) : TypeNode { return $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($phpStanType, $typeKind); } @@ -80,50 +80,50 @@ final class StaticTypeMapper * @param TypeKind::* $typeKind * @return Name|ComplexType|null */ - public function mapPHPStanTypeToPhpParserNode(\PHPStan\Type\Type $phpStanType, string $typeKind) : ?\PhpParser\Node + public function mapPHPStanTypeToPhpParserNode(Type $phpStanType, string $typeKind) : ?Node { $node = $this->phpStanStaticTypeMapper->mapToPhpParserNode($phpStanType, $typeKind); - if (!$node instanceof \PhpParser\Node) { + if (!$node instanceof Node) { return null; } - if ($node instanceof \PhpParser\Node\UnionType) { + if ($node instanceof UnionType) { return $node; } - if (!$node instanceof \PhpParser\Node\Name) { + if (!$node instanceof Name) { return $node; } $nodeName = $this->nodeNameResolver->getName($node); foreach (self::STANDALONE_MAPS as $key => $type) { if ($nodeName === $key) { - return new \PhpParser\Node\Name($type); + return new Name($type); } } return $node; } - public function mapPhpParserNodePHPStanType(\PhpParser\Node $node) : \PHPStan\Type\Type + public function mapPhpParserNodePHPStanType(Node $node) : Type { return $this->phpParserNodeMapper->mapToPHPStanType($node); } - public function mapPHPStanPhpDocTypeToPHPStanType(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $phpDocTagValueNode, \PhpParser\Node $node) : \PHPStan\Type\Type + public function mapPHPStanPhpDocTypeToPHPStanType(PhpDocTagValueNode $phpDocTagValueNode, Node $node) : Type { - if ($phpDocTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode) { + if ($phpDocTagValueNode instanceof TemplateTagValueNode) { // special case $nameScope = $this->nameScopeFactory->createNameScopeFromNodeWithoutTemplateTypes($node); if ($phpDocTagValueNode->bound === null) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } return $this->phpDocTypeMapper->mapToPHPStanType($phpDocTagValueNode->bound, $node, $nameScope); } - if ($phpDocTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode || $phpDocTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode || $phpDocTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode || $phpDocTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode) { + if ($phpDocTagValueNode instanceof ReturnTagValueNode || $phpDocTagValueNode instanceof ParamTagValueNode || $phpDocTagValueNode instanceof VarTagValueNode || $phpDocTagValueNode instanceof ThrowsTagValueNode) { return $this->mapPHPStanPhpDocTypeNodeToPHPStanType($phpDocTagValueNode->type, $node); } - throw new \Rector\Core\Exception\NotImplementedYetException(__METHOD__ . ' for ' . \get_class($phpDocTagValueNode)); + throw new NotImplementedYetException(__METHOD__ . ' for ' . \get_class($phpDocTagValueNode)); } - public function mapPHPStanPhpDocTypeNodeToPHPStanType(\PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode, \PhpParser\Node $node) : \PHPStan\Type\Type + public function mapPHPStanPhpDocTypeNodeToPHPStanType(TypeNode $typeNode, Node $node) : Type { - if ($node instanceof \PhpParser\Node\Param) { - $classMethod = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if ($node instanceof Param) { + $classMethod = $node->getAttribute(AttributeKey::PARENT_NODE); + if ($classMethod instanceof ClassMethod) { // param does not hany any clue about template map, but class method has $node = $classMethod; } diff --git a/packages/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php b/packages/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php index 0ea5d679219..dfc2fc6d575 100644 --- a/packages/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php +++ b/packages/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php @@ -10,7 +10,7 @@ use PHPStan\Type\ObjectType; use PHPStan\Type\Type; use PHPStan\Type\TypeWithClassName; use Rector\NodeTypeResolver\Node\AttributeKey; -final class AliasedObjectType extends \PHPStan\Type\ObjectType +final class AliasedObjectType extends ObjectType { /** * @readonly @@ -26,11 +26,11 @@ final class AliasedObjectType extends \PHPStan\Type\ObjectType { return $this->fullyQualifiedClass; } - public function getUseNode() : \PhpParser\Node\Stmt\Use_ + public function getUseNode() : Use_ { - $name = new \PhpParser\Node\Name($this->fullyQualifiedClass); - $useUse = new \PhpParser\Node\Stmt\UseUse($name, $this->getClassName()); - return new \PhpParser\Node\Stmt\Use_([$useUse]); + $name = new Name($this->fullyQualifiedClass); + $useUse = new UseUse($name, $this->getClassName()); + return new Use_([$useUse]); } public function getShortName() : string { @@ -43,19 +43,19 @@ final class AliasedObjectType extends \PHPStan\Type\ObjectType { return $this->getShortName() === $comparedObjectType->getShortName(); } - public function getFunctionUseNode() : \PhpParser\Node\Stmt\Use_ + public function getFunctionUseNode() : Use_ { - $name = new \PhpParser\Node\Name($this->fullyQualifiedClass); - $useUse = new \PhpParser\Node\Stmt\UseUse($name, $this->getClassName()); - $name->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE, $useUse); - $use = new \PhpParser\Node\Stmt\Use_([$useUse]); - $use->type = \PhpParser\Node\Stmt\Use_::TYPE_FUNCTION; + $name = new Name($this->fullyQualifiedClass); + $useUse = new UseUse($name, $this->getClassName()); + $name->setAttribute(AttributeKey::PARENT_NODE, $useUse); + $use = new Use_([$useUse]); + $use->type = Use_::TYPE_FUNCTION; return $use; } - public function equals(\PHPStan\Type\Type $type) : bool + public function equals(Type $type) : bool { // compare with FQN classes - if ($type instanceof \PHPStan\Type\TypeWithClassName) { + if ($type instanceof TypeWithClassName) { if ($type instanceof self && $this->fullyQualifiedClass === $type->getFullyQualifiedName()) { return \true; } diff --git a/packages/StaticTypeMapper/ValueObject/Type/FullyQualifiedGenericObjectType.php b/packages/StaticTypeMapper/ValueObject/Type/FullyQualifiedGenericObjectType.php index b0a2e69f682..c718a04da58 100644 --- a/packages/StaticTypeMapper/ValueObject/Type/FullyQualifiedGenericObjectType.php +++ b/packages/StaticTypeMapper/ValueObject/Type/FullyQualifiedGenericObjectType.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace Rector\StaticTypeMapper\ValueObject\Type; use PHPStan\Type\Generic\GenericObjectType; -final class FullyQualifiedGenericObjectType extends \PHPStan\Type\Generic\GenericObjectType +final class FullyQualifiedGenericObjectType extends GenericObjectType { } diff --git a/packages/StaticTypeMapper/ValueObject/Type/FullyQualifiedObjectType.php b/packages/StaticTypeMapper/ValueObject/Type/FullyQualifiedObjectType.php index 31642992e79..afc7f51733c 100644 --- a/packages/StaticTypeMapper/ValueObject/Type/FullyQualifiedObjectType.php +++ b/packages/StaticTypeMapper/ValueObject/Type/FullyQualifiedObjectType.php @@ -9,7 +9,7 @@ use PhpParser\Node\Stmt\Use_; use PhpParser\Node\Stmt\UseUse; use PHPStan\Type\ObjectType; use Rector\NodeTypeResolver\Node\AttributeKey; -final class FullyQualifiedObjectType extends \PHPStan\Type\ObjectType +final class FullyQualifiedObjectType extends ObjectType { public function getShortNameType() : \Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType { @@ -28,31 +28,31 @@ final class FullyQualifiedObjectType extends \PHPStan\Type\ObjectType if (\strpos($className, '\\') === \false) { return $className; } - return (string) \RectorPrefix20220607\Nette\Utils\Strings::after($className, '\\', -1); + return (string) Strings::after($className, '\\', -1); } - public function getShortNameNode() : \PhpParser\Node\Name + public function getShortNameNode() : Name { - $name = new \PhpParser\Node\Name($this->getShortName()); + $name = new Name($this->getShortName()); // to avoid processing short name twice - $name->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::VIRTUAL_NODE, \true); + $name->setAttribute(AttributeKey::VIRTUAL_NODE, \true); // keep original to avoid loss on while importing - $name->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NAMESPACED_NAME, $this->getClassName()); + $name->setAttribute(AttributeKey::NAMESPACED_NAME, $this->getClassName()); return $name; } - public function getUseNode() : \PhpParser\Node\Stmt\Use_ + public function getUseNode() : Use_ { - $name = new \PhpParser\Node\Name($this->getClassName()); - $useUse = new \PhpParser\Node\Stmt\UseUse($name); - $name->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE, $useUse); - return new \PhpParser\Node\Stmt\Use_([$useUse]); + $name = new Name($this->getClassName()); + $useUse = new UseUse($name); + $name->setAttribute(AttributeKey::PARENT_NODE, $useUse); + return new Use_([$useUse]); } - public function getFunctionUseNode() : \PhpParser\Node\Stmt\Use_ + public function getFunctionUseNode() : Use_ { - $name = new \PhpParser\Node\Name($this->getClassName()); - $useUse = new \PhpParser\Node\Stmt\UseUse($name, null); - $name->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE, $useUse); - $use = new \PhpParser\Node\Stmt\Use_([$useUse]); - $use->type = \PhpParser\Node\Stmt\Use_::TYPE_FUNCTION; + $name = new Name($this->getClassName()); + $useUse = new UseUse($name, null); + $name->setAttribute(AttributeKey::PARENT_NODE, $useUse); + $use = new Use_([$useUse]); + $use->type = Use_::TYPE_FUNCTION; return $use; } public function getShortNameLowered() : string diff --git a/packages/StaticTypeMapper/ValueObject/Type/NonExistingObjectType.php b/packages/StaticTypeMapper/ValueObject/Type/NonExistingObjectType.php index 371daf2240b..e0fef07abcf 100644 --- a/packages/StaticTypeMapper/ValueObject/Type/NonExistingObjectType.php +++ b/packages/StaticTypeMapper/ValueObject/Type/NonExistingObjectType.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace Rector\StaticTypeMapper\ValueObject\Type; use PHPStan\Type\ObjectType; -final class NonExistingObjectType extends \PHPStan\Type\ObjectType +final class NonExistingObjectType extends ObjectType { } diff --git a/packages/StaticTypeMapper/ValueObject/Type/ParentObjectWithoutClassType.php b/packages/StaticTypeMapper/ValueObject/Type/ParentObjectWithoutClassType.php index 8c60ae9b131..1a676cf9e43 100644 --- a/packages/StaticTypeMapper/ValueObject/Type/ParentObjectWithoutClassType.php +++ b/packages/StaticTypeMapper/ValueObject/Type/ParentObjectWithoutClassType.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace Rector\StaticTypeMapper\ValueObject\Type; use PHPStan\Type\ObjectWithoutClassType; -final class ParentObjectWithoutClassType extends \PHPStan\Type\ObjectWithoutClassType +final class ParentObjectWithoutClassType extends ObjectWithoutClassType { } diff --git a/packages/StaticTypeMapper/ValueObject/Type/ParentStaticType.php b/packages/StaticTypeMapper/ValueObject/Type/ParentStaticType.php index 0a8157e3be1..c8ffbd607e2 100644 --- a/packages/StaticTypeMapper/ValueObject/Type/ParentStaticType.php +++ b/packages/StaticTypeMapper/ValueObject/Type/ParentStaticType.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace Rector\StaticTypeMapper\ValueObject\Type; use PHPStan\Type\StaticType; -final class ParentStaticType extends \PHPStan\Type\StaticType +final class ParentStaticType extends StaticType { } diff --git a/packages/StaticTypeMapper/ValueObject/Type/SelfObjectType.php b/packages/StaticTypeMapper/ValueObject/Type/SelfObjectType.php index 30758df2c48..99895665075 100644 --- a/packages/StaticTypeMapper/ValueObject/Type/SelfObjectType.php +++ b/packages/StaticTypeMapper/ValueObject/Type/SelfObjectType.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace Rector\StaticTypeMapper\ValueObject\Type; use PHPStan\Type\ObjectType; -final class SelfObjectType extends \PHPStan\Type\ObjectType +final class SelfObjectType extends ObjectType { } diff --git a/packages/StaticTypeMapper/ValueObject/Type/SelfStaticType.php b/packages/StaticTypeMapper/ValueObject/Type/SelfStaticType.php index 413e6130248..4c17950ea81 100644 --- a/packages/StaticTypeMapper/ValueObject/Type/SelfStaticType.php +++ b/packages/StaticTypeMapper/ValueObject/Type/SelfStaticType.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace Rector\StaticTypeMapper\ValueObject\Type; use PHPStan\Type\ThisType; -final class SelfStaticType extends \PHPStan\Type\ThisType +final class SelfStaticType extends ThisType { } diff --git a/packages/StaticTypeMapper/ValueObject/Type/ShortenedGenericObjectType.php b/packages/StaticTypeMapper/ValueObject/Type/ShortenedGenericObjectType.php index 4f71b1cf612..e843fbae0ef 100644 --- a/packages/StaticTypeMapper/ValueObject/Type/ShortenedGenericObjectType.php +++ b/packages/StaticTypeMapper/ValueObject/Type/ShortenedGenericObjectType.php @@ -6,7 +6,7 @@ namespace Rector\StaticTypeMapper\ValueObject\Type; use PHPStan\TrinaryLogic; use PHPStan\Type\Generic\GenericObjectType; use PHPStan\Type\Type; -final class ShortenedGenericObjectType extends \PHPStan\Type\Generic\GenericObjectType +final class ShortenedGenericObjectType extends GenericObjectType { /** * @var class-string @@ -21,9 +21,9 @@ final class ShortenedGenericObjectType extends \PHPStan\Type\Generic\GenericObje $this->fullyQualifiedName = $fullyQualifiedName; parent::__construct($shortName, $types); } - public function isSuperTypeOf(\PHPStan\Type\Type $type) : \PHPStan\TrinaryLogic + public function isSuperTypeOf(Type $type) : TrinaryLogic { - $genericObjectType = new \PHPStan\Type\Generic\GenericObjectType($this->fullyQualifiedName, $this->getTypes()); + $genericObjectType = new GenericObjectType($this->fullyQualifiedName, $this->getTypes()); return $genericObjectType->isSuperTypeOf($type); } public function getShortName() : string diff --git a/packages/StaticTypeMapper/ValueObject/Type/ShortenedObjectType.php b/packages/StaticTypeMapper/ValueObject/Type/ShortenedObjectType.php index 6d6eb3382a7..bd2df3d52a1 100644 --- a/packages/StaticTypeMapper/ValueObject/Type/ShortenedObjectType.php +++ b/packages/StaticTypeMapper/ValueObject/Type/ShortenedObjectType.php @@ -6,7 +6,7 @@ namespace Rector\StaticTypeMapper\ValueObject\Type; use PHPStan\TrinaryLogic; use PHPStan\Type\ObjectType; use PHPStan\Type\Type; -final class ShortenedObjectType extends \PHPStan\Type\ObjectType +final class ShortenedObjectType extends ObjectType { /** * @var class-string @@ -21,9 +21,9 @@ final class ShortenedObjectType extends \PHPStan\Type\ObjectType $this->fullyQualifiedName = $fullyQualifiedName; parent::__construct($shortName); } - public function isSuperTypeOf(\PHPStan\Type\Type $type) : \PHPStan\TrinaryLogic + public function isSuperTypeOf(Type $type) : TrinaryLogic { - $fullyQualifiedObjectType = new \PHPStan\Type\ObjectType($this->fullyQualifiedName); + $fullyQualifiedObjectType = new ObjectType($this->fullyQualifiedName); return $fullyQualifiedObjectType->isSuperTypeOf($type); } public function getShortName() : string diff --git a/packages/StaticTypeMapper/ValueObject/Type/SimpleStaticType.php b/packages/StaticTypeMapper/ValueObject/Type/SimpleStaticType.php index 600aa930954..f6b934369a7 100644 --- a/packages/StaticTypeMapper/ValueObject/Type/SimpleStaticType.php +++ b/packages/StaticTypeMapper/ValueObject/Type/SimpleStaticType.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\StaticTypeMapper\ValueObject\Type; use PHPStan\Type\StaticType; -final class SimpleStaticType extends \PHPStan\Type\StaticType +final class SimpleStaticType extends StaticType { /** * @readonly diff --git a/packages/Testing/PHPUnit/AbstractRectorTestCase.php b/packages/Testing/PHPUnit/AbstractRectorTestCase.php index 22d5ccd9a72..136ad479443 100644 --- a/packages/Testing/PHPUnit/AbstractRectorTestCase.php +++ b/packages/Testing/PHPUnit/AbstractRectorTestCase.php @@ -22,8 +22,8 @@ use RectorPrefix20220607\Symplify\EasyTesting\DataProvider\StaticFixtureFinder; use RectorPrefix20220607\Symplify\EasyTesting\DataProvider\StaticFixtureUpdater; use RectorPrefix20220607\Symplify\EasyTesting\StaticFixtureSplitter; use RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider; -use Symplify\SmartFileSystem\SmartFileInfo; -abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractTestCase implements \Rector\Testing\Contract\RectorTestInterface +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; +abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractTestCase implements RectorTestInterface { use MovingFilesTrait; use MultipleFilesChangedTrait; @@ -64,16 +64,16 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractTe } $configFile = $this->provideConfigFilePath(); $this->bootFromConfigFiles([$configFile]); - $this->applicationFileProcessor = $this->getService(\Rector\Core\Application\ApplicationFileProcessor::class); - $this->parameterProvider = $this->getService(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider::class); - $this->dynamicSourceLocatorProvider = $this->getService(\Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider::class); - $this->removedAndAddedFilesCollector = $this->getService(\Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector::class); + $this->applicationFileProcessor = $this->getService(ApplicationFileProcessor::class); + $this->parameterProvider = $this->getService(ParameterProvider::class); + $this->dynamicSourceLocatorProvider = $this->getService(DynamicSourceLocatorProvider::class); + $this->removedAndAddedFilesCollector = $this->getService(RemovedAndAddedFilesCollector::class); $this->removedAndAddedFilesCollector->reset(); /** @var AdditionalAutoloader $additionalAutoloader */ - $additionalAutoloader = $this->getService(\Rector\Core\Autoloading\AdditionalAutoloader::class); + $additionalAutoloader = $this->getService(AdditionalAutoloader::class); $additionalAutoloader->autoloadPaths(); /** @var BootstrapFilesIncluder $bootstrapFilesIncluder */ - $bootstrapFilesIncluder = $this->getService(\Rector\Core\Autoloading\BootstrapFilesIncluder::class); + $bootstrapFilesIncluder = $this->getService(BootstrapFilesIncluder::class); $bootstrapFilesIncluder->includeBootstrapFiles(); } protected function tearDown() : void @@ -85,17 +85,17 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractTe /** * @return Iterator */ - protected function yieldFilesFromDirectory(string $directory, string $suffix = '*.php.inc') : \Iterator + protected function yieldFilesFromDirectory(string $directory, string $suffix = '*.php.inc') : Iterator { - return \RectorPrefix20220607\Symplify\EasyTesting\DataProvider\StaticFixtureFinder::yieldDirectoryExclusively($directory, $suffix); + return StaticFixtureFinder::yieldDirectoryExclusively($directory, $suffix); } protected function isWindows() : bool { return \strncasecmp(\PHP_OS, 'WIN', 3) === 0; } - protected function doTestFileInfo(\Symplify\SmartFileSystem\SmartFileInfo $fixtureFileInfo, bool $allowMatches = \true) : void + protected function doTestFileInfo(SmartFileInfo $fixtureFileInfo, bool $allowMatches = \true) : void { - $inputFileInfoAndExpectedFileInfo = \RectorPrefix20220607\Symplify\EasyTesting\StaticFixtureSplitter::splitFileInfoToLocalInputAndExpectedFileInfos($fixtureFileInfo); + $inputFileInfoAndExpectedFileInfo = StaticFixtureSplitter::splitFileInfoToLocalInputAndExpectedFileInfos($fixtureFileInfo); $inputFileInfo = $inputFileInfoAndExpectedFileInfo->getInputFileInfo(); $this->originalTempFileInfo = $inputFileInfo; $expectedFileInfo = $inputFileInfoAndExpectedFileInfo->getExpectedFileInfo(); @@ -105,9 +105,9 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractTe { return \sys_get_temp_dir() . '/_temp_fixture_easy_testing'; } - private function doTestFileMatchesExpectedContent(\Symplify\SmartFileSystem\SmartFileInfo $originalFileInfo, \Symplify\SmartFileSystem\SmartFileInfo $expectedFileInfo, \Symplify\SmartFileSystem\SmartFileInfo $fixtureFileInfo, bool $allowMatches = \true) : void + private function doTestFileMatchesExpectedContent(SmartFileInfo $originalFileInfo, SmartFileInfo $expectedFileInfo, SmartFileInfo $fixtureFileInfo, bool $allowMatches = \true) : void { - $this->parameterProvider->changeParameter(\Rector\Core\Configuration\Option::SOURCE, [$originalFileInfo->getRealPath()]); + $this->parameterProvider->changeParameter(Option::SOURCE, [$originalFileInfo->getRealPath()]); $changedContent = $this->processFileInfo($originalFileInfo); // file is removed, we cannot compare it if ($this->removedAndAddedFilesCollector->isFileRemoved($originalFileInfo)) { @@ -116,11 +116,11 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractTe $relativeFilePathFromCwd = $fixtureFileInfo->getRelativeFilePathFromCwd(); try { $this->assertStringEqualsFile($expectedFileInfo->getRealPath(), $changedContent, $relativeFilePathFromCwd); - } catch (\PHPUnit\Framework\ExpectationFailedException $expectationFailedException) { + } catch (ExpectationFailedException $expectationFailedException) { if (!$allowMatches) { throw $expectationFailedException; } - \RectorPrefix20220607\Symplify\EasyTesting\DataProvider\StaticFixtureUpdater::updateFixtureContent($originalFileInfo, $changedContent, $fixtureFileInfo); + StaticFixtureUpdater::updateFixtureContent($originalFileInfo, $changedContent, $fixtureFileInfo); $contents = $expectedFileInfo->getContents(); // make sure we don't get a diff in which every line is different (because of differences in EOL) $contents = $this->normalizeNewlines($contents); @@ -132,17 +132,17 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractTe { return \str_replace("\r\n", "\n", $string); } - private function processFileInfo(\Symplify\SmartFileSystem\SmartFileInfo $fileInfo) : string + private function processFileInfo(SmartFileInfo $fileInfo) : string { $this->dynamicSourceLocatorProvider->setFileInfo($fileInfo); // needed for PHPStan, because the analyzed file is just created in /temp - need for trait and similar deps /** @var NodeScopeResolver $nodeScopeResolver */ - $nodeScopeResolver = $this->getService(\PHPStan\Analyser\NodeScopeResolver::class); + $nodeScopeResolver = $this->getService(NodeScopeResolver::class); $nodeScopeResolver->setAnalysedFiles([$fileInfo->getRealPath()]); /** @var ConfigurationFactory $configurationFactory */ - $configurationFactory = $this->getService(\Rector\Core\Configuration\ConfigurationFactory::class); + $configurationFactory = $this->getService(ConfigurationFactory::class); $configuration = $configurationFactory->createForTests([$fileInfo->getRealPath()]); - $file = new \Rector\Core\ValueObject\Application\File($fileInfo, $fileInfo->getContents()); + $file = new File($fileInfo, $fileInfo->getContents()); $this->applicationFileProcessor->processFiles([$file], $configuration); return $file->getFileContent(); } diff --git a/packages/Testing/PHPUnit/AbstractTestCase.php b/packages/Testing/PHPUnit/AbstractTestCase.php index ac95734df69..b566b8909f0 100644 --- a/packages/Testing/PHPUnit/AbstractTestCase.php +++ b/packages/Testing/PHPUnit/AbstractTestCase.php @@ -8,7 +8,7 @@ use RectorPrefix20220607\Psr\Container\ContainerInterface; use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Kernel\RectorKernel; use RectorPrefix20220607\Webmozart\Assert\Assert; -abstract class AbstractTestCase extends \PHPUnit\Framework\TestCase +abstract class AbstractTestCase extends TestCase { /** * @var array @@ -32,7 +32,7 @@ abstract class AbstractTestCase extends \PHPUnit\Framework\TestCase $rectorKernel = self::$kernelsByHash[$configsHash]; self::$currentContainer = $rectorKernel->getContainer(); } else { - $rectorKernel = new \Rector\Core\Kernel\RectorKernel(); + $rectorKernel = new RectorKernel(); $container = $rectorKernel->createFromConfigs($configFiles); self::$kernelsByHash[$configsHash] = $rectorKernel; self::$currentContainer = $container; @@ -48,12 +48,12 @@ abstract class AbstractTestCase extends \PHPUnit\Framework\TestCase protected function getService(string $type) : object { if (self::$currentContainer === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException('First, create container with "bootWithConfigFileInfos([...])"'); + throw new ShouldNotHappenException('First, create container with "bootWithConfigFileInfos([...])"'); } $object = self::$currentContainer->get($type); if ($object === null) { $message = \sprintf('Service "%s" was not found', $type); - throw new \Rector\Core\Exception\ShouldNotHappenException($message); + throw new ShouldNotHappenException($message); } return $object; } @@ -62,8 +62,8 @@ abstract class AbstractTestCase extends \PHPUnit\Framework\TestCase */ private function createConfigsHash(array $configFiles) : string { - \RectorPrefix20220607\Webmozart\Assert\Assert::allFile($configFiles); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configFiles); + Assert::allFile($configFiles); + Assert::allString($configFiles); $configHash = ''; foreach ($configFiles as $configFile) { $configHash .= \md5_file($configFile); diff --git a/packages/Testing/PHPUnit/Behavior/MovingFilesTrait.php b/packages/Testing/PHPUnit/Behavior/MovingFilesTrait.php index d7dcd0d4ecc..e890d2e5752 100644 --- a/packages/Testing/PHPUnit/Behavior/MovingFilesTrait.php +++ b/packages/Testing/PHPUnit/Behavior/MovingFilesTrait.php @@ -6,23 +6,23 @@ namespace Rector\Testing\PHPUnit\Behavior; use Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector; use Rector\Core\PhpParser\Printer\NodesWithFileDestinationPrinter; use Rector\FileSystemRector\ValueObject\AddedFileWithContent; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @property-read RemovedAndAddedFilesCollector $removedAndAddedFilesCollector */ trait MovingFilesTrait { - protected function assertFileWasNotChanged(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : void + protected function assertFileWasNotChanged(SmartFileInfo $smartFileInfo) : void { $hasFileInfo = $this->removedAndAddedFilesCollector->isFileRemoved($smartFileInfo); $this->assertFalse($hasFileInfo); } - protected function assertFileWasAdded(\Rector\FileSystemRector\ValueObject\AddedFileWithContent $addedFileWithContent) : void + protected function assertFileWasAdded(AddedFileWithContent $addedFileWithContent) : void { $this->assertFilesWereAdded([$addedFileWithContent]); } - protected function assertFileWasRemoved(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : void + protected function assertFileWasRemoved(SmartFileInfo $smartFileInfo) : void { $isFileRemoved = $this->removedAndAddedFilesCollector->isFileRemoved($smartFileInfo); $this->assertTrue($isFileRemoved); @@ -32,12 +32,12 @@ trait MovingFilesTrait */ protected function assertFilesWereAdded(array $expectedAddedFileWithContents) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($expectedAddedFileWithContents, \Rector\FileSystemRector\ValueObject\AddedFileWithContent::class); + Assert::allIsAOf($expectedAddedFileWithContents, AddedFileWithContent::class); \sort($expectedAddedFileWithContents); $addedFilePathsWithContents = $this->resolveAddedFilePathsWithContents(); \sort($addedFilePathsWithContents); // there should be at least some added files - \RectorPrefix20220607\Webmozart\Assert\Assert::notEmpty($addedFilePathsWithContents); + Assert::notEmpty($addedFilePathsWithContents); foreach ($addedFilePathsWithContents as $key => $addedFilePathWithContent) { $expectedFilePathWithContent = $expectedAddedFileWithContents[$key]; /** @@ -57,11 +57,11 @@ trait MovingFilesTrait private function resolveAddedFilePathsWithContents() : array { $addedFilePathsWithContents = $this->removedAndAddedFilesCollector->getAddedFilesWithContent(); - $nodesWithFileDestinationPrinter = $this->getService(\Rector\Core\PhpParser\Printer\NodesWithFileDestinationPrinter::class); + $nodesWithFileDestinationPrinter = $this->getService(NodesWithFileDestinationPrinter::class); $movedFiles = $this->removedAndAddedFilesCollector->getMovedFiles(); foreach ($movedFiles as $movedFile) { $fileContent = $nodesWithFileDestinationPrinter->printNodesWithFileDestination($movedFile); - $addedFilePathsWithContents[] = new \Rector\FileSystemRector\ValueObject\AddedFileWithContent($movedFile->getNewFilePath(), $fileContent); + $addedFilePathsWithContents[] = new AddedFileWithContent($movedFile->getNewFilePath(), $fileContent); } $addedFilesWithNodes = $this->removedAndAddedFilesCollector->getAddedFilesWithNodes(); if ($addedFilesWithNodes === []) { @@ -69,7 +69,7 @@ trait MovingFilesTrait } foreach ($addedFilesWithNodes as $addedFileWithNode) { $fileContent = $nodesWithFileDestinationPrinter->printNodesWithFileDestination($addedFileWithNode); - $addedFilePathsWithContents[] = new \Rector\FileSystemRector\ValueObject\AddedFileWithContent($addedFileWithNode->getFilePath(), $fileContent); + $addedFilePathsWithContents[] = new AddedFileWithContent($addedFileWithNode->getFilePath(), $fileContent); } return $addedFilePathsWithContents; } diff --git a/packages/Testing/PHPUnit/Behavior/MultipleFilesChangedTrait.php b/packages/Testing/PHPUnit/Behavior/MultipleFilesChangedTrait.php index 0506c88cc7b..e1900f6521c 100644 --- a/packages/Testing/PHPUnit/Behavior/MultipleFilesChangedTrait.php +++ b/packages/Testing/PHPUnit/Behavior/MultipleFilesChangedTrait.php @@ -5,10 +5,10 @@ namespace Rector\Testing\PHPUnit\Behavior; use RectorPrefix20220607\Nette\Utils\FileSystem; use Rector\Core\Exception\ShouldNotHappenException; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; trait MultipleFilesChangedTrait { - protected function doTestFileInfoWithAdditionalChanges(\Symplify\SmartFileSystem\SmartFileInfo $fixtureFileInfo, bool $allowMatches = \true) : void + protected function doTestFileInfoWithAdditionalChanges(SmartFileInfo $fixtureFileInfo, bool $allowMatches = \true) : void { $separator = '-----'; [$originalContent, $expectedContent, $additionalInfo] = \explode($separator, $fixtureFileInfo->getContents(), 3); @@ -24,12 +24,12 @@ trait MultipleFilesChangedTrait if ($trimmedExpectedContent !== '') { $fixtureContent .= $separator . $expectedContent; } - \RectorPrefix20220607\Nette\Utils\FileSystem::write($fixturePath, $fixtureContent); - $newFileInfo = new \Symplify\SmartFileSystem\SmartFileInfo($fixturePath); + FileSystem::write($fixturePath, $fixtureContent); + $newFileInfo = new SmartFileInfo($fixturePath); $this->doTestFileInfo($newFileInfo, $allowMatches); $this->checkAdditionalChanges($expectedFileChanges); if (\file_exists($fixturePath)) { - \RectorPrefix20220607\Nette\Utils\FileSystem::delete($fixturePath); + FileSystem::delete($fixturePath); } } /** @@ -42,13 +42,13 @@ trait MultipleFilesChangedTrait foreach ($additionalFileChanges as $additionalFileChange) { $path = isset($additionalFileChange[0]) ? \trim($additionalFileChange[0]) : null; if ($path === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException('Path for additional change must be set'); + throw new ShouldNotHappenException('Path for additional change must be set'); } $fullPath = $this->getFixtureTempDirectory() . '/' . $path; $input = isset($additionalFileChange[1]) ? \trim($additionalFileChange[1]) : null; if ($input) { $this->createFixtureDir($fullPath); - \RectorPrefix20220607\Nette\Utils\FileSystem::write($fullPath, $input); + FileSystem::write($fullPath, $input); } $expectedFileChanges[$fullPath] = isset($additionalFileChange[2]) ? \trim($additionalFileChange[2]) : ''; } @@ -73,7 +73,7 @@ trait MultipleFilesChangedTrait $realFileContent = $addedFile ? \trim($addedFile->getFileContent()) : null; $this->assertSame($expectedFileChange, $realFileContent); if (\file_exists($path)) { - \RectorPrefix20220607\Nette\Utils\FileSystem::delete($path); + FileSystem::delete($path); } } } diff --git a/packages/Testing/TestingParser/TestingParser.php b/packages/Testing/TestingParser/TestingParser.php index 949dd04b353..9ba125163b8 100644 --- a/packages/Testing/TestingParser/TestingParser.php +++ b/packages/Testing/TestingParser/TestingParser.php @@ -9,7 +9,7 @@ use Rector\Core\PhpParser\Parser\RectorParser; use Rector\Core\ValueObject\Application\File; use Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator; use RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; /** * @api */ @@ -30,16 +30,16 @@ final class TestingParser * @var \Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator */ private $nodeScopeAndMetadataDecorator; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \Rector\Core\PhpParser\Parser\RectorParser $rectorParser, \Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator) + public function __construct(ParameterProvider $parameterProvider, RectorParser $rectorParser, NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator) { $this->parameterProvider = $parameterProvider; $this->rectorParser = $rectorParser; $this->nodeScopeAndMetadataDecorator = $nodeScopeAndMetadataDecorator; } - public function parseFilePathToFile(string $filePath) : \Rector\Core\ValueObject\Application\File + public function parseFilePathToFile(string $filePath) : File { - $smartFileInfo = new \Symplify\SmartFileSystem\SmartFileInfo($filePath); - $file = new \Rector\Core\ValueObject\Application\File($smartFileInfo, $smartFileInfo->getContents()); + $smartFileInfo = new SmartFileInfo($filePath); + $file = new File($smartFileInfo, $smartFileInfo->getContents()); $stmts = $this->rectorParser->parseFile($smartFileInfo); $file->hydrateStmtsAndTokens($stmts, $stmts, []); return $file; @@ -51,10 +51,10 @@ final class TestingParser { // autoload file require_once $file; - $smartFileInfo = new \Symplify\SmartFileSystem\SmartFileInfo($file); - $this->parameterProvider->changeParameter(\Rector\Core\Configuration\Option::SOURCE, [$file]); + $smartFileInfo = new SmartFileInfo($file); + $this->parameterProvider->changeParameter(Option::SOURCE, [$file]); $nodes = $this->rectorParser->parseFile($smartFileInfo); - $file = new \Rector\Core\ValueObject\Application\File($smartFileInfo, $smartFileInfo->getContents()); + $file = new File($smartFileInfo, $smartFileInfo->getContents()); return $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($file, $nodes); } } diff --git a/packages/VendorLocker/NodeVendorLocker/ClassMethodParamVendorLockResolver.php b/packages/VendorLocker/NodeVendorLocker/ClassMethodParamVendorLockResolver.php index b97d9a707f5..a30e5208303 100644 --- a/packages/VendorLocker/NodeVendorLocker/ClassMethodParamVendorLockResolver.php +++ b/packages/VendorLocker/NodeVendorLocker/ClassMethodParamVendorLockResolver.php @@ -31,7 +31,7 @@ final class ClassMethodParamVendorLockResolver * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \RectorPrefix20220607\Symplify\SmartFileSystem\Normalizer\PathNormalizer $pathNormalizer, \Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer $familyRelationsAnalyzer, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(NodeNameResolver $nodeNameResolver, PathNormalizer $pathNormalizer, FamilyRelationsAnalyzer $familyRelationsAnalyzer, ReflectionResolver $reflectionResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->pathNormalizer = $pathNormalizer; @@ -41,26 +41,26 @@ final class ClassMethodParamVendorLockResolver /** * Includes non-vendor classes */ - public function isSoftLocked(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + public function isSoftLocked(ClassMethod $classMethod) : bool { if ($this->isVendorLocked($classMethod)) { return \true; } $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } /** @var string $methodName */ $methodName = $this->nodeNameResolver->getName($classMethod); return $this->hasClassMethodLockMatchingFileName($classReflection, $methodName, ''); } - public function isVendorLocked(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + public function isVendorLocked(ClassMethod $classMethod) : bool { if ($classMethod->isMagic()) { return \true; } $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } /** @var string $methodName */ @@ -76,7 +76,7 @@ final class ClassMethodParamVendorLockResolver $methodName = $this->nodeNameResolver->getName($classMethod); return $this->hasClassMethodLockMatchingFileName($classReflection, $methodName, '/vendor/'); } - private function hasTraitMethodVendorLock(\PHPStan\Reflection\ClassReflection $classReflection, string $methodName) : bool + private function hasTraitMethodVendorLock(ClassReflection $classReflection, string $methodName) : bool { $relatedReflectionClasses = $this->familyRelationsAnalyzer->getChildrenOfClassReflection($classReflection); foreach ($relatedReflectionClasses as $relatedReflectionClass) { @@ -94,7 +94,7 @@ final class ClassMethodParamVendorLockResolver * Better skip it, as PHPStan has access only to just analyzed classes. * This might change type, that works for current class, but breaks another implementer. */ - private function hasParentInterfaceMethod(\PHPStan\Reflection\ClassReflection $classReflection, string $methodName) : bool + private function hasParentInterfaceMethod(ClassReflection $classReflection, string $methodName) : bool { foreach ($classReflection->getInterfaces() as $interfaceClassReflection) { if ($interfaceClassReflection->hasMethod($methodName)) { @@ -103,7 +103,7 @@ final class ClassMethodParamVendorLockResolver } return \false; } - private function hasClassMethodLockMatchingFileName(\PHPStan\Reflection\ClassReflection $classReflection, string $methodName, string $filePathPartName) : bool + private function hasClassMethodLockMatchingFileName(ClassReflection $classReflection, string $methodName, string $filePathPartName) : bool { $ancestorClassReflections = \array_merge($classReflection->getParents(), $classReflection->getInterfaces()); foreach ($ancestorClassReflections as $ancestorClassReflection) { diff --git a/packages/VendorLocker/NodeVendorLocker/ClassMethodReturnTypeOverrideGuard.php b/packages/VendorLocker/NodeVendorLocker/ClassMethodReturnTypeOverrideGuard.php index 608fed52a38..650392c2547 100644 --- a/packages/VendorLocker/NodeVendorLocker/ClassMethodReturnTypeOverrideGuard.php +++ b/packages/VendorLocker/NodeVendorLocker/ClassMethodReturnTypeOverrideGuard.php @@ -56,7 +56,7 @@ final class ClassMethodReturnTypeOverrideGuard * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer $familyRelationsAnalyzer, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\AstResolver $astResolver, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider, FamilyRelationsAnalyzer $familyRelationsAnalyzer, BetterNodeFinder $betterNodeFinder, AstResolver $astResolver, ReflectionResolver $reflectionResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->reflectionProvider = $reflectionProvider; @@ -65,7 +65,7 @@ final class ClassMethodReturnTypeOverrideGuard $this->astResolver = $astResolver; $this->reflectionResolver = $reflectionResolver; } - public function shouldSkipClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + public function shouldSkipClassMethod(ClassMethod $classMethod) : bool { // 1. skip magic methods if ($classMethod->isMagic()) { @@ -76,14 +76,14 @@ final class ClassMethodReturnTypeOverrideGuard return \true; } $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \true; } $childrenClassReflections = $this->familyRelationsAnalyzer->getChildrenOfClassReflection($classReflection); if ($childrenClassReflections === []) { return \false; } - if ($classMethod->returnType instanceof \PhpParser\Node) { + if ($classMethod->returnType instanceof Node) { return \true; } if ($this->shouldSkipHasChildNoReturn($childrenClassReflections, $classMethod)) { @@ -91,9 +91,9 @@ final class ClassMethodReturnTypeOverrideGuard } return $this->hasClassMethodExprReturn($classMethod); } - public function shouldSkipClassMethodOldTypeWithNewType(\PHPStan\Type\Type $oldType, \PHPStan\Type\Type $newType) : bool + public function shouldSkipClassMethodOldTypeWithNewType(Type $oldType, Type $newType) : bool { - if ($oldType instanceof \PHPStan\Type\MixedType) { + if ($oldType instanceof MixedType) { return \false; } // new generic string type is more advanced than old array type @@ -105,17 +105,17 @@ final class ClassMethodReturnTypeOverrideGuard /** * @param ClassReflection[] $childrenClassReflections */ - private function shouldSkipHasChildNoReturn(array $childrenClassReflections, \PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkipHasChildNoReturn(array $childrenClassReflections, ClassMethod $classMethod) : bool { $methodName = $this->nodeNameResolver->getName($classMethod); - $scope = $classMethod->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $classMethod->getAttribute(AttributeKey::SCOPE); foreach ($childrenClassReflections as $childClassReflection) { if (!$childClassReflection->hasMethod($methodName)) { continue; } $methodReflection = $childClassReflection->getMethod($methodName, $scope); $method = $this->astResolver->resolveClassMethodFromMethodReflection($methodReflection); - if (!$method instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$method instanceof ClassMethod) { continue; } if ($method->returnType === null) { @@ -124,10 +124,10 @@ final class ClassMethodReturnTypeOverrideGuard } return \false; } - private function shouldSkipChaoticClassMethods(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkipChaoticClassMethods(ClassMethod $classMethod) : bool { $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \true; } foreach (self::CHAOTIC_CLASS_METHOD_NAMES as $chaoticClass => $chaoticMethodNames) { @@ -142,26 +142,26 @@ final class ClassMethodReturnTypeOverrideGuard } return \false; } - private function hasClassMethodExprReturn(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function hasClassMethodExprReturn(ClassMethod $classMethod) : bool { - return (bool) $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (\PhpParser\Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Stmt\Return_) { + return (bool) $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (Node $node) : bool { + if (!$node instanceof Return_) { return \false; } - return $node->expr instanceof \PhpParser\Node\Expr; + return $node->expr instanceof Expr; }); } - private function isFirstArrayTypeMoreAdvanced(\PHPStan\Type\Type $oldType, \PHPStan\Type\Type $newType) : bool + private function isFirstArrayTypeMoreAdvanced(Type $oldType, Type $newType) : bool { - if (!$oldType instanceof \PHPStan\Type\ArrayType) { + if (!$oldType instanceof ArrayType) { return \false; } - if (!$newType instanceof \PHPStan\Type\ArrayType) { + if (!$newType instanceof ArrayType) { return \false; } - if (!$oldType->getItemType() instanceof \PHPStan\Type\StringType) { + if (!$oldType->getItemType() instanceof StringType) { return \false; } - return $newType->getItemType() instanceof \PHPStan\Type\Generic\GenericClassStringType; + return $newType->getItemType() instanceof GenericClassStringType; } } diff --git a/packages/VendorLocker/NodeVendorLocker/ClassMethodReturnVendorLockResolver.php b/packages/VendorLocker/NodeVendorLocker/ClassMethodReturnVendorLockResolver.php index 1c072477661..39d176c8164 100644 --- a/packages/VendorLocker/NodeVendorLocker/ClassMethodReturnVendorLockResolver.php +++ b/packages/VendorLocker/NodeVendorLocker/ClassMethodReturnVendorLockResolver.php @@ -21,21 +21,21 @@ final class ClassMethodReturnVendorLockResolver * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(NodeNameResolver $nodeNameResolver, ReflectionResolver $reflectionResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->reflectionResolver = $reflectionResolver; } - public function isVendorLocked(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + public function isVendorLocked(ClassMethod $classMethod) : bool { $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } $methodName = $this->nodeNameResolver->getName($classMethod); return $this->isVendorLockedByAncestors($classReflection, $methodName); } - private function isVendorLockedByAncestors(\PHPStan\Reflection\ClassReflection $classReflection, string $methodName) : bool + private function isVendorLockedByAncestors(ClassReflection $classReflection, string $methodName) : bool { foreach ($classReflection->getAncestors() as $ancestorClassReflections) { if ($ancestorClassReflections === $classReflection) { @@ -48,11 +48,11 @@ final class ClassMethodReturnVendorLockResolver } $parentClassMethodReflection = $ancestorClassReflections->getNativeMethod($methodName); $parametersAcceptor = $parentClassMethodReflection->getVariants()[0]; - if (!$parametersAcceptor instanceof \PHPStan\Reflection\FunctionVariantWithPhpDocs) { + if (!$parametersAcceptor instanceof FunctionVariantWithPhpDocs) { continue; } // here we count only on strict types, not on docs - return !$parametersAcceptor->getNativeReturnType() instanceof \PHPStan\Type\MixedType; + return !$parametersAcceptor->getNativeReturnType() instanceof MixedType; } return \false; } diff --git a/packages/VendorLocker/NodeVendorLocker/PropertyTypeVendorLockResolver.php b/packages/VendorLocker/NodeVendorLocker/PropertyTypeVendorLockResolver.php index c8221afff80..1b8fb70e33c 100644 --- a/packages/VendorLocker/NodeVendorLocker/PropertyTypeVendorLockResolver.php +++ b/packages/VendorLocker/NodeVendorLocker/PropertyTypeVendorLockResolver.php @@ -23,20 +23,20 @@ final class PropertyTypeVendorLockResolver * @var \Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer */ private $familyRelationsAnalyzer; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer $familyRelationsAnalyzer) + public function __construct(NodeNameResolver $nodeNameResolver, FamilyRelationsAnalyzer $familyRelationsAnalyzer) { $this->nodeNameResolver = $nodeNameResolver; $this->familyRelationsAnalyzer = $familyRelationsAnalyzer; } - public function isVendorLocked(\PhpParser\Node\Stmt\Property $property) : bool + public function isVendorLocked(Property $property) : bool { - $scope = $property->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $property->getAttribute(AttributeKey::SCOPE); // possibly trait - if (!$scope instanceof \PHPStan\Analyser\Scope) { + if (!$scope instanceof Scope) { return \true; } $classReflection = $scope->getClassReflection(); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } if (\count($classReflection->getAncestors()) === 1) { @@ -49,7 +49,7 @@ final class PropertyTypeVendorLockResolver } return $this->isChildClassLocked($property, $classReflection, $propertyName); } - private function isParentClassLocked(\PHPStan\Reflection\ClassReflection $classReflection, string $propertyName, \PHPStan\Analyser\Scope $scope) : bool + private function isParentClassLocked(ClassReflection $classReflection, string $propertyName, Scope $scope) : bool { $fileName = $classReflection->getFileName(); // extract to some "inherited parent method" service @@ -61,19 +61,19 @@ final class PropertyTypeVendorLockResolver continue; } $property = $parentClassReflection->getProperty($propertyName, $scope); - if (!$property instanceof \PHPStan\Reflection\Php\PhpPropertyReflection) { + if (!$property instanceof PhpPropertyReflection) { // validate type is conflicting // parent class property in external scope → it's not ok return \true; } - if ($property->getNativeType() instanceof \PHPStan\Type\MixedType) { + if ($property->getNativeType() instanceof MixedType) { // validate parent not typed yet → it's not ok return \true; } } return \false; } - private function isChildClassLocked(\PhpParser\Node\Stmt\Property $property, \PHPStan\Reflection\ClassReflection $classReflection, string $propertyName) : bool + private function isChildClassLocked(Property $property, ClassReflection $classReflection, string $propertyName) : bool { if (!$classReflection->isClass()) { return \false; diff --git a/packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php b/packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php index 93828a6eb80..2e257713717 100644 --- a/packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php +++ b/packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php @@ -43,7 +43,7 @@ final class ParentClassMethodTypeOverrideGuard * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \RectorPrefix20220607\Symplify\SmartFileSystem\Normalizer\PathNormalizer $pathNormalizer, \Rector\Core\PhpParser\AstResolver $astResolver, \Rector\TypeDeclaration\TypeInferer\ParamTypeInferer $paramTypeInferer, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(NodeNameResolver $nodeNameResolver, PathNormalizer $pathNormalizer, AstResolver $astResolver, ParamTypeInferer $paramTypeInferer, ReflectionResolver $reflectionResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->pathNormalizer = $pathNormalizer; @@ -51,21 +51,21 @@ final class ParentClassMethodTypeOverrideGuard $this->paramTypeInferer = $paramTypeInferer; $this->reflectionResolver = $reflectionResolver; } - public function isReturnTypeChangeAllowed(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + public function isReturnTypeChangeAllowed(ClassMethod $classMethod) : bool { // __construct cannot declare a return type // so the return type change is not allowed - if ($this->nodeNameResolver->isName($classMethod, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if ($this->nodeNameResolver->isName($classMethod, MethodName::CONSTRUCT)) { return \false; } // make sure return type is not protected by parent contract $parentClassMethodReflection = $this->getParentClassMethod($classMethod); // nothing to check - if (!$parentClassMethodReflection instanceof \PHPStan\Reflection\MethodReflection) { + if (!$parentClassMethodReflection instanceof MethodReflection) { return \true; } - $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($parentClassMethodReflection->getVariants()); - if ($parametersAcceptor instanceof \PHPStan\Reflection\FunctionVariantWithPhpDocs && !$parametersAcceptor->getNativeReturnType() instanceof \PHPStan\Type\MixedType) { + $parametersAcceptor = ParametersAcceptorSelector::selectSingle($parentClassMethodReflection->getVariants()); + if ($parametersAcceptor instanceof FunctionVariantWithPhpDocs && !$parametersAcceptor->getNativeReturnType() instanceof MixedType) { return \false; } $classReflection = $parentClassMethodReflection->getDeclaringClass(); @@ -96,21 +96,21 @@ final class ParentClassMethodTypeOverrideGuard $isParentInVendor = \strpos($normalizedFileName, '/vendor/') !== \false; return $isCurrentInVendor && $isParentInVendor || !$isCurrentInVendor && !$isParentInVendor; } - public function hasParentClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + public function hasParentClassMethod(ClassMethod $classMethod) : bool { - return $this->getParentClassMethod($classMethod) instanceof \PHPStan\Reflection\MethodReflection; + return $this->getParentClassMethod($classMethod) instanceof MethodReflection; } - public function hasParentClassMethodDifferentType(\PhpParser\Node\Stmt\ClassMethod $classMethod, int $position, \PHPStan\Type\Type $currentType) : bool + public function hasParentClassMethodDifferentType(ClassMethod $classMethod, int $position, Type $currentType) : bool { if ($classMethod->isPrivate()) { return \false; } $methodReflection = $this->getParentClassMethod($classMethod); - if (!$methodReflection instanceof \PHPStan\Reflection\MethodReflection) { + if (!$methodReflection instanceof MethodReflection) { return \false; } $classMethod = $this->astResolver->resolveClassMethodFromMethodReflection($methodReflection); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$classMethod instanceof ClassMethod) { return \false; } if ($classMethod->isPrivate()) { @@ -122,10 +122,10 @@ final class ParentClassMethodTypeOverrideGuard $inferedType = $this->paramTypeInferer->inferParam($classMethod->params[$position]); return \get_class($inferedType) !== \get_class($currentType); } - public function getParentClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PHPStan\Reflection\MethodReflection + public function getParentClassMethod(ClassMethod $classMethod) : ?MethodReflection { $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return null; } /** @var string $methodName */ diff --git a/packages/VendorLocker/VendorLockResolver.php b/packages/VendorLocker/VendorLockResolver.php index 6fd031c96de..4ea1415dc82 100644 --- a/packages/VendorLocker/VendorLockResolver.php +++ b/packages/VendorLocker/VendorLockResolver.php @@ -26,24 +26,24 @@ final class VendorLockResolver * @var \Rector\VendorLocker\NodeVendorLocker\PropertyTypeVendorLockResolver */ private $propertyTypeVendorLockResolver; - public function __construct(\Rector\VendorLocker\NodeVendorLocker\ClassMethodParamVendorLockResolver $classMethodParamVendorLockResolver, \Rector\VendorLocker\NodeVendorLocker\ClassMethodReturnVendorLockResolver $classMethodReturnVendorLockResolver, \Rector\VendorLocker\NodeVendorLocker\PropertyTypeVendorLockResolver $propertyTypeVendorLockResolver) + public function __construct(ClassMethodParamVendorLockResolver $classMethodParamVendorLockResolver, ClassMethodReturnVendorLockResolver $classMethodReturnVendorLockResolver, PropertyTypeVendorLockResolver $propertyTypeVendorLockResolver) { $this->classMethodParamVendorLockResolver = $classMethodParamVendorLockResolver; $this->classMethodReturnVendorLockResolver = $classMethodReturnVendorLockResolver; $this->propertyTypeVendorLockResolver = $propertyTypeVendorLockResolver; } - public function isClassMethodParamLockedIn(\PhpParser\Node $node) : bool + public function isClassMethodParamLockedIn(Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$node instanceof ClassMethod) { return \false; } return $this->classMethodParamVendorLockResolver->isVendorLocked($node); } - public function isReturnChangeVendorLockedIn(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + public function isReturnChangeVendorLockedIn(ClassMethod $classMethod) : bool { return $this->classMethodReturnVendorLockResolver->isVendorLocked($classMethod); } - public function isPropertyTypeChangeVendorLockedIn(\PhpParser\Node\Stmt\Property $property) : bool + public function isPropertyTypeChangeVendorLockedIn(Property $property) : bool { return $this->propertyTypeVendorLockResolver->isVendorLocked($property); } diff --git a/packages/VersionBonding/PhpVersionedFilter.php b/packages/VersionBonding/PhpVersionedFilter.php index 0f967b1fc09..64d4d9c32b1 100644 --- a/packages/VersionBonding/PhpVersionedFilter.php +++ b/packages/VersionBonding/PhpVersionedFilter.php @@ -13,7 +13,7 @@ final class PhpVersionedFilter * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PhpVersionProvider $phpVersionProvider) { $this->phpVersionProvider = $phpVersionProvider; } @@ -27,7 +27,7 @@ final class PhpVersionedFilter $minProjectPhpVersion = $this->phpVersionProvider->provide(); $activeRectors = []; foreach ($rectors as $rector) { - if (!$rector instanceof \Rector\VersionBonding\Contract\MinPhpVersionInterface) { + if (!$rector instanceof MinPhpVersionInterface) { $activeRectors[] = $rector; continue; } diff --git a/preload.php b/preload.php index c5524e6c8d1..ca17dca1735 100644 --- a/preload.php +++ b/preload.php @@ -252,6 +252,3 @@ require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php'; require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/Parser/Tokens.php'; require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/ParserFactory.php'; require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php'; -require_once __DIR__ . '/vendor/symfony/dependency-injection/Loader/Configurator/AbstractConfigurator.php'; -require_once __DIR__ . '/vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php'; -require_once __DIR__ . '/vendor/symfony/contracts/Deprecation/function.php'; diff --git a/rules/Arguments/ArgumentDefaultValueReplacer.php b/rules/Arguments/ArgumentDefaultValueReplacer.php index 77c5398aee7..5cde9429d85 100644 --- a/rules/Arguments/ArgumentDefaultValueReplacer.php +++ b/rules/Arguments/ArgumentDefaultValueReplacer.php @@ -28,7 +28,7 @@ final class ArgumentDefaultValueReplacer * @var \Rector\Core\PhpParser\Node\Value\ValueResolver */ private $valueResolver; - public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver) + public function __construct(NodeFactory $nodeFactory, ValueResolver $valueResolver) { $this->nodeFactory = $nodeFactory; $this->valueResolver = $valueResolver; @@ -36,9 +36,9 @@ final class ArgumentDefaultValueReplacer /** * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Expr\FuncCall $node */ - public function processReplaces($node, \Rector\Arguments\Contract\ReplaceArgumentDefaultValueInterface $replaceArgumentDefaultValue) : ?\PhpParser\Node + public function processReplaces($node, ReplaceArgumentDefaultValueInterface $replaceArgumentDefaultValue) : ?Node { - if ($node instanceof \PhpParser\Node\Stmt\ClassMethod) { + if ($node instanceof ClassMethod) { if (!isset($node->params[$replaceArgumentDefaultValue->getPosition()])) { return null; } @@ -52,10 +52,10 @@ final class ArgumentDefaultValueReplacer /** * @param mixed $value */ - public function isDefaultValueMatched(?\PhpParser\Node\Expr $expr, $value) : bool + public function isDefaultValueMatched(?Expr $expr, $value) : bool { // allow any values before, also allow param without default value - if ($value === \Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue::ANY_VALUE_BEFORE) { + if ($value === ReplaceArgumentDefaultValue::ANY_VALUE_BEFORE) { return \true; } if ($expr === null) { @@ -67,7 +67,7 @@ final class ArgumentDefaultValueReplacer // ValueResolver::isValue returns false when default value is `null` return $value === null && $this->valueResolver->isNull($expr); } - private function processParams(\PhpParser\Node\Stmt\ClassMethod $classMethod, \Rector\Arguments\Contract\ReplaceArgumentDefaultValueInterface $replaceArgumentDefaultValue) : ?\PhpParser\Node\Stmt\ClassMethod + private function processParams(ClassMethod $classMethod, ReplaceArgumentDefaultValueInterface $replaceArgumentDefaultValue) : ?ClassMethod { $position = $replaceArgumentDefaultValue->getPosition(); if (!$this->isDefaultValueMatched($classMethod->params[$position]->default, $replaceArgumentDefaultValue->getValueBefore())) { @@ -79,10 +79,10 @@ final class ArgumentDefaultValueReplacer /** * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\FuncCall $expr */ - private function processArgs($expr, \Rector\Arguments\Contract\ReplaceArgumentDefaultValueInterface $replaceArgumentDefaultValue) : ?\PhpParser\Node\Expr + private function processArgs($expr, ReplaceArgumentDefaultValueInterface $replaceArgumentDefaultValue) : ?Expr { $position = $replaceArgumentDefaultValue->getPosition(); - if (!$expr->args[$position] instanceof \PhpParser\Node\Arg) { + if (!$expr->args[$position] instanceof Arg) { return null; } $argValue = $this->valueResolver->getValue($expr->args[$position]->value); @@ -99,9 +99,9 @@ final class ArgumentDefaultValueReplacer /** * @param mixed $value */ - private function normalizeValueToArgument($value) : \PhpParser\Node\Arg + private function normalizeValueToArgument($value) : Arg { - return new \PhpParser\Node\Arg($this->normalizeValue($value)); + return new Arg($this->normalizeValue($value)); } /** * @param mixed $value @@ -114,13 +114,13 @@ final class ArgumentDefaultValueReplacer [$class, $constant] = \explode('::', $value); return $this->nodeFactory->createClassConstFetch($class, $constant); } - return \PhpParser\BuilderHelpers::normalizeValue($value); + return BuilderHelpers::normalizeValue($value); } /** * @param array $args * @return array|null */ - private function processArrayReplacement(array $args, \Rector\Arguments\Contract\ReplaceArgumentDefaultValueInterface $replaceArgumentDefaultValue) : ?array + private function processArrayReplacement(array $args, ReplaceArgumentDefaultValueInterface $replaceArgumentDefaultValue) : ?array { $argumentValues = $this->resolveArgumentValuesToBeforeRecipe($args, $replaceArgumentDefaultValue); if ($argumentValues !== $replaceArgumentDefaultValue->getValueBefore()) { @@ -140,7 +140,7 @@ final class ArgumentDefaultValueReplacer * @param Arg[] $argumentNodes * @return mixed[] */ - private function resolveArgumentValuesToBeforeRecipe(array $argumentNodes, \Rector\Arguments\Contract\ReplaceArgumentDefaultValueInterface $replaceArgumentDefaultValue) : array + private function resolveArgumentValuesToBeforeRecipe(array $argumentNodes, ReplaceArgumentDefaultValueInterface $replaceArgumentDefaultValue) : array { $argumentValues = []; $valueBefore = $replaceArgumentDefaultValue->getValueBefore(); diff --git a/rules/Arguments/NodeAnalyzer/ArgumentAddingScope.php b/rules/Arguments/NodeAnalyzer/ArgumentAddingScope.php index c3b0e59934c..b8c5baebe6f 100644 --- a/rules/Arguments/NodeAnalyzer/ArgumentAddingScope.php +++ b/rules/Arguments/NodeAnalyzer/ArgumentAddingScope.php @@ -28,24 +28,24 @@ final class ArgumentAddingScope * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } /** * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $expr */ - public function isInCorrectScope($expr, \Rector\Arguments\ValueObject\ArgumentAdder $argumentAdder) : bool + public function isInCorrectScope($expr, ArgumentAdder $argumentAdder) : bool { if ($argumentAdder->getScope() === null) { return \true; } $scope = $argumentAdder->getScope(); - if ($expr instanceof \PhpParser\Node\Expr\StaticCall) { - if (!$expr->class instanceof \PhpParser\Node\Name) { + if ($expr instanceof StaticCall) { + if (!$expr->class instanceof Name) { return \false; } - if ($this->nodeNameResolver->isName($expr->class, \Rector\Core\Enum\ObjectReference::PARENT)) { + if ($this->nodeNameResolver->isName($expr->class, ObjectReference::PARENT)) { return $scope === self::SCOPE_PARENT_CALL; } return $scope === self::SCOPE_METHOD_CALL; diff --git a/rules/Arguments/NodeAnalyzer/ChangedArgumentsDetector.php b/rules/Arguments/NodeAnalyzer/ChangedArgumentsDetector.php index 5caef33e30e..83852906a89 100644 --- a/rules/Arguments/NodeAnalyzer/ChangedArgumentsDetector.php +++ b/rules/Arguments/NodeAnalyzer/ChangedArgumentsDetector.php @@ -25,7 +25,7 @@ final class ChangedArgumentsDetector * @var \Rector\NodeTypeResolver\TypeComparator\TypeComparator */ private $typeComparator; - public function __construct(\Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\NodeTypeResolver\TypeComparator\TypeComparator $typeComparator) + public function __construct(ValueResolver $valueResolver, StaticTypeMapper $staticTypeMapper, TypeComparator $typeComparator) { $this->valueResolver = $valueResolver; $this->staticTypeMapper = $staticTypeMapper; @@ -34,14 +34,14 @@ final class ChangedArgumentsDetector /** * @param mixed $value */ - public function isDefaultValueChanged(\PhpParser\Node\Param $param, $value) : bool + public function isDefaultValueChanged(Param $param, $value) : bool { if ($param->default === null) { return \false; } return !$this->valueResolver->isValue($param->default, $value); } - public function isTypeChanged(\PhpParser\Node\Param $param, ?\PHPStan\Type\Type $newType) : bool + public function isTypeChanged(Param $param, ?Type $newType) : bool { if ($param->type === null) { return \false; diff --git a/rules/Arguments/Rector/ClassMethod/ArgumentAdderRector.php b/rules/Arguments/Rector/ClassMethod/ArgumentAdderRector.php index d02ea7fe207..47febc9debf 100644 --- a/rules/Arguments/Rector/ClassMethod/ArgumentAdderRector.php +++ b/rules/Arguments/Rector/ClassMethod/ArgumentAdderRector.php @@ -27,13 +27,13 @@ use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\PhpParser\AstResolver; use Rector\Core\Rector\AbstractRector; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Arguments\Rector\ClassMethod\ArgumentAdderRector\ArgumentAdderRectorTest */ -final class ArgumentAdderRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class ArgumentAdderRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var ArgumentAdder[] @@ -63,16 +63,16 @@ final class ArgumentAdderRector extends \Rector\Core\Rector\AbstractRector imple * @var \Rector\Core\Contract\PhpParser\NodePrinterInterface */ private $nodePrinter; - public function __construct(\Rector\Arguments\NodeAnalyzer\ArgumentAddingScope $argumentAddingScope, \Rector\Arguments\NodeAnalyzer\ChangedArgumentsDetector $changedArgumentsDetector, \Rector\Core\PhpParser\AstResolver $astResolver, \Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter) + public function __construct(ArgumentAddingScope $argumentAddingScope, ChangedArgumentsDetector $changedArgumentsDetector, AstResolver $astResolver, NodePrinterInterface $nodePrinter) { $this->argumentAddingScope = $argumentAddingScope; $this->changedArgumentsDetector = $changedArgumentsDetector; $this->astResolver = $astResolver; $this->nodePrinter = $nodePrinter; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('This Rector adds new default arguments in calls of defined methods and class types.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('This Rector adds new default arguments in calls of defined methods and class types.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' $someObject = new SomeExampleClass; $someObject->someMethod(); @@ -94,20 +94,20 @@ class MyCustomClass extends SomeExampleClass } } CODE_SAMPLE -, [new \Rector\Arguments\ValueObject\ArgumentAdder('SomeExampleClass', 'someMethod', 0, 'someArgument', \true, new \PHPStan\Type\ObjectType('SomeType'))])]); +, [new ArgumentAdder('SomeExampleClass', 'someMethod', 0, 'someArgument', \true, new ObjectType('SomeType'))])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class, \PhpParser\Node\Stmt\ClassMethod::class]; + 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(\PhpParser\Node $node) + public function refactor(Node $node) { $this->haveArgumentsChanged = \false; foreach ($this->addedArguments as $addedArgument) { @@ -129,22 +129,22 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Arguments\ValueObject\ArgumentAdder::class); + Assert::allIsAOf($configuration, ArgumentAdder::class); $this->addedArguments = $configuration; } /** * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Stmt\ClassMethod $node */ - private function isObjectTypeMatch($node, \PHPStan\Type\ObjectType $objectType) : bool + private function isObjectTypeMatch($node, ObjectType $objectType) : bool { - if ($node instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node instanceof MethodCall) { return $this->isObjectType($node->var, $objectType); } - if ($node instanceof \PhpParser\Node\Expr\StaticCall) { + if ($node instanceof StaticCall) { return $this->isObjectType($node->class, $objectType); } - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLike = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$classLike instanceof Class_) { return \false; } return $this->isObjectType($classLike, $objectType); @@ -152,7 +152,7 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node */ - private function processPositionWithDefaultValues($node, \Rector\Arguments\ValueObject\ArgumentAdder $argumentAdder) : void + private function processPositionWithDefaultValues($node, ArgumentAdder $argumentAdder) : void { if ($this->shouldSkipParameter($node, $argumentAdder)) { return; @@ -160,11 +160,11 @@ CODE_SAMPLE $defaultValue = $argumentAdder->getArgumentDefaultValue(); $argumentType = $argumentAdder->getArgumentType(); $position = $argumentAdder->getPosition(); - if ($node instanceof \PhpParser\Node\Stmt\ClassMethod) { + if ($node instanceof ClassMethod) { $this->addClassMethodParam($node, $argumentAdder, $defaultValue, $argumentType, $position); return; } - if ($node instanceof \PhpParser\Node\Expr\StaticCall) { + if ($node instanceof StaticCall) { $this->processStaticCall($node, $position, $argumentAdder); return; } @@ -173,9 +173,9 @@ CODE_SAMPLE /** * @param mixed $defaultValue */ - private function processMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall, $defaultValue, int $position) : void + private function processMethodCall(MethodCall $methodCall, $defaultValue, int $position) : void { - $arg = new \PhpParser\Node\Arg(\PhpParser\BuilderHelpers::normalizeValue($defaultValue)); + $arg = new Arg(BuilderHelpers::normalizeValue($defaultValue)); if (isset($methodCall->args[$position])) { return; } @@ -196,29 +196,29 @@ CODE_SAMPLE return; } $classMethod = $this->astResolver->resolveClassMethodFromCall($node); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$classMethod instanceof ClassMethod) { return; } for ($index = $lastPosition + 1; $index < $position; ++$index) { $param = $classMethod->params[$index]; - if (!$param->default instanceof \PhpParser\Node\Expr) { - throw new \Rector\Core\Exception\ShouldNotHappenException('Previous position does not has default value'); + if (!$param->default instanceof Expr) { + throw new ShouldNotHappenException('Previous position does not has default value'); } $default = $this->nodePrinter->print($param->default); - $node->args[$index] = new \PhpParser\Node\Arg(new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name($default))); + $node->args[$index] = new Arg(new ConstFetch(new Name($default))); } } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node */ - private function shouldSkipParameter($node, \Rector\Arguments\ValueObject\ArgumentAdder $argumentAdder) : bool + private function shouldSkipParameter($node, ArgumentAdder $argumentAdder) : bool { $position = $argumentAdder->getPosition(); $argumentName = $argumentAdder->getArgumentName(); if ($argumentName === null) { return \true; } - if ($node instanceof \PhpParser\Node\Stmt\ClassMethod) { + if ($node instanceof ClassMethod) { // already added? if (!isset($node->params[$position])) { return \false; @@ -244,34 +244,34 @@ CODE_SAMPLE /** * @param mixed $defaultValue */ - private function addClassMethodParam(\PhpParser\Node\Stmt\ClassMethod $classMethod, \Rector\Arguments\ValueObject\ArgumentAdder $argumentAdder, $defaultValue, ?\PHPStan\Type\Type $type, int $position) : void + private function addClassMethodParam(ClassMethod $classMethod, ArgumentAdder $argumentAdder, $defaultValue, ?Type $type, int $position) : void { $argumentName = $argumentAdder->getArgumentName(); if ($argumentName === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } - $param = new \PhpParser\Node\Param(new \PhpParser\Node\Expr\Variable($argumentName), \PhpParser\BuilderHelpers::normalizeValue($defaultValue)); + $param = new Param(new Variable($argumentName), BuilderHelpers::normalizeValue($defaultValue)); if ($type !== null) { - $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM); + $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, TypeKind::PARAM); $param->type = $typeNode; } $classMethod->params[$position] = $param; $this->haveArgumentsChanged = \true; } - private function processStaticCall(\PhpParser\Node\Expr\StaticCall $staticCall, int $position, \Rector\Arguments\ValueObject\ArgumentAdder $argumentAdder) : void + private function processStaticCall(StaticCall $staticCall, int $position, ArgumentAdder $argumentAdder) : void { $argumentName = $argumentAdder->getArgumentName(); if ($argumentName === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } - if (!$staticCall->class instanceof \PhpParser\Node\Name) { + if (!$staticCall->class instanceof Name) { return; } - if (!$this->isName($staticCall->class, \Rector\Core\Enum\ObjectReference::PARENT)) { + if (!$this->isName($staticCall->class, ObjectReference::PARENT)) { return; } $this->fillGapBetweenWithDefaultValue($staticCall, $position); - $staticCall->args[$position] = new \PhpParser\Node\Arg(new \PhpParser\Node\Expr\Variable($argumentName)); + $staticCall->args[$position] = new Arg(new Variable($argumentName)); $this->haveArgumentsChanged = \true; } } diff --git a/rules/Arguments/Rector/ClassMethod/ReplaceArgumentDefaultValueRector.php b/rules/Arguments/Rector/ClassMethod/ReplaceArgumentDefaultValueRector.php index f08af7af2ec..fe2bfe54f39 100644 --- a/rules/Arguments/Rector/ClassMethod/ReplaceArgumentDefaultValueRector.php +++ b/rules/Arguments/Rector/ClassMethod/ReplaceArgumentDefaultValueRector.php @@ -11,13 +11,13 @@ use Rector\Arguments\ArgumentDefaultValueReplacer; use Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Arguments\Rector\ClassMethod\ReplaceArgumentDefaultValueRector\ReplaceArgumentDefaultValueRectorTest */ -final class ReplaceArgumentDefaultValueRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class ReplaceArgumentDefaultValueRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var ReplaceArgumentDefaultValue[] @@ -28,13 +28,13 @@ final class ReplaceArgumentDefaultValueRector extends \Rector\Core\Rector\Abstra * @var \Rector\Arguments\ArgumentDefaultValueReplacer */ private $argumentDefaultValueReplacer; - public function __construct(\Rector\Arguments\ArgumentDefaultValueReplacer $argumentDefaultValueReplacer) + public function __construct(ArgumentDefaultValueReplacer $argumentDefaultValueReplacer) { $this->argumentDefaultValueReplacer = $argumentDefaultValueReplacer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replaces defined map of arguments in defined methods and their calls.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replaces defined map of arguments in defined methods and their calls.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' $someObject = new SomeClass; $someObject->someMethod(SomeClass::OLD_CONSTANT); CODE_SAMPLE @@ -42,20 +42,20 @@ CODE_SAMPLE $someObject = new SomeClass; $someObject->someMethod(false); CODE_SAMPLE -, [new \Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue('SomeClass', 'someMethod', 0, 'SomeClass::OLD_CONSTANT', \false)])]); +, [new ReplaceArgumentDefaultValue('SomeClass', 'someMethod', 0, 'SomeClass::OLD_CONSTANT', \false)])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class, \PhpParser\Node\Stmt\ClassMethod::class]; + 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(\PhpParser\Node $node) + public function refactor(Node $node) { $hasChanged = \false; foreach ($this->replacedArguments as $replacedArgument) { @@ -66,7 +66,7 @@ CODE_SAMPLE continue; } $replacedNode = $this->argumentDefaultValueReplacer->processReplaces($node, $replacedArgument); - if ($replacedNode instanceof \PhpParser\Node) { + if ($replacedNode instanceof Node) { $hasChanged = \true; } } @@ -80,7 +80,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue::class); + Assert::allIsAOf($configuration, ReplaceArgumentDefaultValue::class); $this->replacedArguments = $configuration; } } diff --git a/rules/Arguments/Rector/FuncCall/FunctionArgumentDefaultValueReplacerRector.php b/rules/Arguments/Rector/FuncCall/FunctionArgumentDefaultValueReplacerRector.php index 2632ca44afd..67f924203c4 100644 --- a/rules/Arguments/Rector/FuncCall/FunctionArgumentDefaultValueReplacerRector.php +++ b/rules/Arguments/Rector/FuncCall/FunctionArgumentDefaultValueReplacerRector.php @@ -9,8 +9,8 @@ use Rector\Arguments\ArgumentDefaultValueReplacer; use Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @changelog https://php.watch/versions/8.1/version_compare-operator-restrictions @@ -18,7 +18,7 @@ use RectorPrefix20220607\Webmozart\Assert\Assert; * * @see \Rector\Tests\Arguments\Rector\FuncCall\FunctionArgumentDefaultValueReplacerRector\FunctionArgumentDefaultValueReplacerRectorTest */ -final class FunctionArgumentDefaultValueReplacerRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class FunctionArgumentDefaultValueReplacerRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var ReplaceFuncCallArgumentDefaultValue[] @@ -29,32 +29,32 @@ final class FunctionArgumentDefaultValueReplacerRector extends \Rector\Core\Rect * @var \Rector\Arguments\ArgumentDefaultValueReplacer */ private $argumentDefaultValueReplacer; - public function __construct(\Rector\Arguments\ArgumentDefaultValueReplacer $argumentDefaultValueReplacer) + public function __construct(ArgumentDefaultValueReplacer $argumentDefaultValueReplacer) { $this->argumentDefaultValueReplacer = $argumentDefaultValueReplacer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Streamline the operator arguments of version_compare function', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Streamline the operator arguments of version_compare function', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' version_compare(PHP_VERSION, '5.6', 'gte'); CODE_SAMPLE , <<<'CODE_SAMPLE' version_compare(PHP_VERSION, '5.6', 'ge'); CODE_SAMPLE -, [new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge')])]); +, [new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node * @return \PhpParser\Node\Expr\FuncCall|null */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { $hasChanged = \false; foreach ($this->replacedArguments as $replacedArgument) { @@ -62,7 +62,7 @@ CODE_SAMPLE continue; } $changedNode = $this->argumentDefaultValueReplacer->processReplaces($node, $replacedArgument); - if ($changedNode instanceof \PhpParser\Node) { + if ($changedNode instanceof Node) { $hasChanged = \true; } } @@ -76,7 +76,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue::class); + Assert::allIsAOf($configuration, ReplaceFuncCallArgumentDefaultValue::class); $this->replacedArguments = $configuration; } } diff --git a/rules/Arguments/Rector/FuncCall/SwapFuncCallArgumentsRector.php b/rules/Arguments/Rector/FuncCall/SwapFuncCallArgumentsRector.php index b2779cd272a..6db8c769067 100644 --- a/rules/Arguments/Rector/FuncCall/SwapFuncCallArgumentsRector.php +++ b/rules/Arguments/Rector/FuncCall/SwapFuncCallArgumentsRector.php @@ -9,13 +9,13 @@ use PhpParser\Node\Expr\FuncCall; use Rector\Arguments\ValueObject\SwapFuncCallArguments; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Arguments\Rector\FuncCall\SwapFuncCallArgumentsRector\SwapFuncCallArgumentsRectorTest */ -final class SwapFuncCallArgumentsRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class SwapFuncCallArgumentsRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var string @@ -25,9 +25,9 @@ final class SwapFuncCallArgumentsRector extends \Rector\Core\Rector\AbstractRect * @var SwapFuncCallArguments[] */ private $functionArgumentSwaps = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Swap arguments in function calls', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Swap arguments in function calls', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run($one, $two) @@ -45,19 +45,19 @@ final class SomeClass } } CODE_SAMPLE -, [new \Rector\Arguments\ValueObject\SwapFuncCallArguments('some_function', [1, 0])])]); +, [new SwapFuncCallArguments('some_function', [1, 0])])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Expr\FuncCall + public function refactor(Node $node) : ?FuncCall { $isJustSwapped = (bool) $node->getAttribute(self::JUST_SWAPPED, \false); if ($isJustSwapped) { @@ -84,13 +84,13 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Arguments\ValueObject\SwapFuncCallArguments::class); + Assert::allIsAOf($configuration, SwapFuncCallArguments::class); $this->functionArgumentSwaps = $configuration; } /** * @return array */ - private function resolveNewArguments(\Rector\Arguments\ValueObject\SwapFuncCallArguments $swapFuncCallArguments, \PhpParser\Node\Expr\FuncCall $funcCall) : array + private function resolveNewArguments(SwapFuncCallArguments $swapFuncCallArguments, FuncCall $funcCall) : array { $newArguments = []; foreach ($swapFuncCallArguments->getOrder() as $oldPosition => $newPosition) { @@ -100,7 +100,7 @@ CODE_SAMPLE if (!isset($funcCall->args[$newPosition])) { continue; } - if (!$funcCall->args[$oldPosition] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[$oldPosition] instanceof Arg) { continue; } $newArguments[$newPosition] = $funcCall->args[$oldPosition]; diff --git a/rules/Arguments/Rector/MethodCall/RemoveMethodCallParamRector.php b/rules/Arguments/Rector/MethodCall/RemoveMethodCallParamRector.php index ac16de3f708..28b5babada4 100644 --- a/rules/Arguments/Rector/MethodCall/RemoveMethodCallParamRector.php +++ b/rules/Arguments/Rector/MethodCall/RemoveMethodCallParamRector.php @@ -9,21 +9,21 @@ use PhpParser\Node\Expr\StaticCall; use Rector\Arguments\ValueObject\RemoveMethodCallParam; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Arguments\Rector\MethodCall\RemoveMethodCallParamRector\RemoveMethodCallParamRectorTest */ -final class RemoveMethodCallParamRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RemoveMethodCallParamRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var RemoveMethodCallParam[] */ private $removeMethodCallParams = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove parameter of method call', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove parameter of method call', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run(Caller $caller) @@ -41,19 +41,19 @@ final class SomeClass } } CODE_SAMPLE -, [new \Rector\Arguments\ValueObject\RemoveMethodCallParam('Caller', 'process', 1)])]); +, [new RemoveMethodCallParam('Caller', 'process', 1)])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $hasChanged = \false; foreach ($this->removeMethodCallParams as $removeMethodCallParam) { @@ -80,15 +80,15 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsInstanceOf($configuration, \Rector\Arguments\ValueObject\RemoveMethodCallParam::class); + Assert::allIsInstanceOf($configuration, RemoveMethodCallParam::class); $this->removeMethodCallParams = $configuration; } /** * @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $call */ - private function isCallerObjectType($call, \Rector\Arguments\ValueObject\RemoveMethodCallParam $removeMethodCallParam) : bool + private function isCallerObjectType($call, RemoveMethodCallParam $removeMethodCallParam) : bool { - if ($call instanceof \PhpParser\Node\Expr\MethodCall) { + if ($call instanceof MethodCall) { return $this->isObjectType($call->var, $removeMethodCallParam->getObjectType()); } return $this->isObjectType($call->class, $removeMethodCallParam->getObjectType()); diff --git a/rules/Arguments/ValueObject/ArgumentAdder.php b/rules/Arguments/ValueObject/ArgumentAdder.php index a703be5edc5..e8e33dc246d 100644 --- a/rules/Arguments/ValueObject/ArgumentAdder.php +++ b/rules/Arguments/ValueObject/ArgumentAdder.php @@ -55,11 +55,11 @@ final class ArgumentAdder $this->argumentDefaultValue = $argumentDefaultValue; $this->argumentType = $argumentType; $this->scope = $scope; - \Rector\Core\Validation\RectorAssert::className($class); + RectorAssert::className($class); } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->class); + return new ObjectType($this->class); } public function getMethod() : string { @@ -80,7 +80,7 @@ final class ArgumentAdder { return $this->argumentDefaultValue; } - public function getArgumentType() : ?\PHPStan\Type\Type + public function getArgumentType() : ?Type { return $this->argumentType; } diff --git a/rules/Arguments/ValueObject/RemoveMethodCallParam.php b/rules/Arguments/ValueObject/RemoveMethodCallParam.php index e150d4caa0f..dc3e0928204 100644 --- a/rules/Arguments/ValueObject/RemoveMethodCallParam.php +++ b/rules/Arguments/ValueObject/RemoveMethodCallParam.php @@ -27,9 +27,9 @@ final class RemoveMethodCallParam $this->methodName = $methodName; $this->paramPosition = $paramPosition; } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->class); + return new ObjectType($this->class); } public function getMethodName() : string { diff --git a/rules/Arguments/ValueObject/ReplaceArgumentDefaultValue.php b/rules/Arguments/ValueObject/ReplaceArgumentDefaultValue.php index d6c01482d44..e669d2f4826 100644 --- a/rules/Arguments/ValueObject/ReplaceArgumentDefaultValue.php +++ b/rules/Arguments/ValueObject/ReplaceArgumentDefaultValue.php @@ -6,7 +6,7 @@ namespace Rector\Arguments\ValueObject; use PHPStan\Type\ObjectType; use Rector\Arguments\Contract\ReplaceArgumentDefaultValueInterface; use Rector\Core\Validation\RectorAssert; -final class ReplaceArgumentDefaultValue implements \Rector\Arguments\Contract\ReplaceArgumentDefaultValueInterface +final class ReplaceArgumentDefaultValue implements ReplaceArgumentDefaultValueInterface { /** * @var string @@ -47,11 +47,11 @@ final class ReplaceArgumentDefaultValue implements \Rector\Arguments\Contract\Re $this->position = $position; $this->valueBefore = $valueBefore; $this->valueAfter = $valueAfter; - \Rector\Core\Validation\RectorAssert::className($class); + RectorAssert::className($class); } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->class); + return new ObjectType($this->class); } public function getMethod() : string { diff --git a/rules/Arguments/ValueObject/ReplaceFuncCallArgumentDefaultValue.php b/rules/Arguments/ValueObject/ReplaceFuncCallArgumentDefaultValue.php index 250c3f0bb7d..bb9a0d25abf 100644 --- a/rules/Arguments/ValueObject/ReplaceFuncCallArgumentDefaultValue.php +++ b/rules/Arguments/ValueObject/ReplaceFuncCallArgumentDefaultValue.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Arguments\ValueObject; use Rector\Arguments\Contract\ReplaceArgumentDefaultValueInterface; -final class ReplaceFuncCallArgumentDefaultValue implements \Rector\Arguments\Contract\ReplaceArgumentDefaultValueInterface +final class ReplaceFuncCallArgumentDefaultValue implements ReplaceArgumentDefaultValueInterface { /** * @readonly diff --git a/rules/CodeQuality/CompactConverter.php b/rules/CodeQuality/CompactConverter.php index 79bea399694..49689fd87ad 100644 --- a/rules/CodeQuality/CompactConverter.php +++ b/rules/CodeQuality/CompactConverter.php @@ -18,15 +18,15 @@ final class CompactConverter * @var \Rector\Core\PhpParser\Node\Value\ValueResolver */ private $valueResolver; - public function __construct(\Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver) + public function __construct(ValueResolver $valueResolver) { $this->valueResolver = $valueResolver; } - public function hasAllArgumentsNamed(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + public function hasAllArgumentsNamed(FuncCall $funcCall) : bool { foreach ($funcCall->args as $arg) { // VariadicPlaceholder doesn't has name, so it return false directly - if (!$arg instanceof \PhpParser\Node\Arg) { + if (!$arg instanceof Arg) { return \false; } /** @var string|null $variableName */ @@ -37,19 +37,19 @@ final class CompactConverter } return \true; } - public function convertToArray(\PhpParser\Node\Expr\FuncCall $funcCall) : \PhpParser\Node\Expr\Array_ + public function convertToArray(FuncCall $funcCall) : Array_ { - $array = new \PhpParser\Node\Expr\Array_(); + $array = new Array_(); foreach ($funcCall->args as $arg) { - if (!$arg instanceof \PhpParser\Node\Arg) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$arg instanceof Arg) { + throw new ShouldNotHappenException(); } /** @var string|null $variableName */ $variableName = $this->valueResolver->getValue($arg->value); if (!\is_string($variableName)) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } - $array->items[] = new \PhpParser\Node\Expr\ArrayItem(new \PhpParser\Node\Expr\Variable($variableName), new \PhpParser\Node\Scalar\String_($variableName)); + $array->items[] = new ArrayItem(new Variable($variableName), new String_($variableName)); } return $array; } diff --git a/rules/CodeQuality/NodeAnalyzer/ArrayCompacter.php b/rules/CodeQuality/NodeAnalyzer/ArrayCompacter.php index eec88b2d1f0..9d7be959791 100644 --- a/rules/CodeQuality/NodeAnalyzer/ArrayCompacter.php +++ b/rules/CodeQuality/NodeAnalyzer/ArrayCompacter.php @@ -9,21 +9,21 @@ use PhpParser\Node\Expr\Variable; use PhpParser\Node\Scalar\String_; final class ArrayCompacter { - public function compactStringToVariableArray(\PhpParser\Node\Expr\Array_ $array) : void + public function compactStringToVariableArray(Array_ $array) : void { foreach ($array->items as $arrayItem) { - if (!$arrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$arrayItem instanceof ArrayItem) { continue; } if ($arrayItem->key !== null) { continue; } - if (!$arrayItem->value instanceof \PhpParser\Node\Scalar\String_) { + if (!$arrayItem->value instanceof String_) { continue; } $variableName = $arrayItem->value->value; - $arrayItem->key = new \PhpParser\Node\Scalar\String_($variableName); - $arrayItem->value = new \PhpParser\Node\Expr\Variable($variableName); + $arrayItem->key = new String_($variableName); + $arrayItem->value = new Variable($variableName); } } } diff --git a/rules/CodeQuality/NodeAnalyzer/ArrayItemsAnalyzer.php b/rules/CodeQuality/NodeAnalyzer/ArrayItemsAnalyzer.php index 1cfd322853b..71fe87359f3 100644 --- a/rules/CodeQuality/NodeAnalyzer/ArrayItemsAnalyzer.php +++ b/rules/CodeQuality/NodeAnalyzer/ArrayItemsAnalyzer.php @@ -9,7 +9,7 @@ use PhpParser\Node\Scalar\String_; use PHPStan\Analyser\Scope; final class ArrayItemsAnalyzer { - public function hasArrayExclusiveDefinedVariableNames(\PhpParser\Node\Expr\Array_ $array, \PHPStan\Analyser\Scope $scope) : bool + public function hasArrayExclusiveDefinedVariableNames(Array_ $array, Scope $scope) : bool { foreach ($array->items as $arrayItem) { $variableName = $this->resolveStringValue($arrayItem); @@ -23,7 +23,7 @@ final class ArrayItemsAnalyzer } return \true; } - public function hasArrayExclusiveUndefinedVariableNames(\PhpParser\Node\Expr\Array_ $array, \PHPStan\Analyser\Scope $scope) : bool + public function hasArrayExclusiveUndefinedVariableNames(Array_ $array, Scope $scope) : bool { foreach ($array->items as $arrayItem) { $variableName = $this->resolveStringValue($arrayItem); @@ -37,12 +37,12 @@ final class ArrayItemsAnalyzer } return \true; } - private function resolveStringValue(?\PhpParser\Node\Expr\ArrayItem $arrayItem) : ?string + private function resolveStringValue(?ArrayItem $arrayItem) : ?string { - if (!$arrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$arrayItem instanceof ArrayItem) { return null; } - if (!$arrayItem->value instanceof \PhpParser\Node\Scalar\String_) { + if (!$arrayItem->value instanceof String_) { return null; } return $arrayItem->value->value; diff --git a/rules/CodeQuality/NodeAnalyzer/ClassLikeAnalyzer.php b/rules/CodeQuality/NodeAnalyzer/ClassLikeAnalyzer.php index 8360f2e12b3..db7ae7580b7 100644 --- a/rules/CodeQuality/NodeAnalyzer/ClassLikeAnalyzer.php +++ b/rules/CodeQuality/NodeAnalyzer/ClassLikeAnalyzer.php @@ -12,14 +12,14 @@ final class ClassLikeAnalyzer * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } /** * @return string[] */ - public function resolvePropertyNames(\PhpParser\Node\Stmt\Class_ $class) : array + public function resolvePropertyNames(Class_ $class) : array { $propertyNames = []; foreach ($class->getProperties() as $property) { diff --git a/rules/CodeQuality/NodeAnalyzer/ConstructorPropertyDefaultExprResolver.php b/rules/CodeQuality/NodeAnalyzer/ConstructorPropertyDefaultExprResolver.php index 8ed20818525..a7418bb4dbb 100644 --- a/rules/CodeQuality/NodeAnalyzer/ConstructorPropertyDefaultExprResolver.php +++ b/rules/CodeQuality/NodeAnalyzer/ConstructorPropertyDefaultExprResolver.php @@ -22,7 +22,7 @@ final class ConstructorPropertyDefaultExprResolver * @var \Rector\Core\NodeAnalyzer\ExprAnalyzer */ private $exprAnalyzer; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\NodeAnalyzer\ExprAnalyzer $exprAnalyzer) + public function __construct(NodeNameResolver $nodeNameResolver, ExprAnalyzer $exprAnalyzer) { $this->nodeNameResolver = $nodeNameResolver; $this->exprAnalyzer = $exprAnalyzer; @@ -30,7 +30,7 @@ final class ConstructorPropertyDefaultExprResolver /** * @return DefaultPropertyExprAssign[] */ - public function resolve(\PhpParser\Node\Stmt\ClassMethod $classMethod) : array + public function resolve(ClassMethod $classMethod) : array { $stmts = $classMethod->getStmts(); if ($stmts === null) { @@ -38,15 +38,15 @@ final class ConstructorPropertyDefaultExprResolver } $defaultPropertyExprAssigns = []; foreach ($stmts as $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { continue; } $nestedStmt = $stmt->expr; - if (!$nestedStmt instanceof \PhpParser\Node\Expr\Assign) { + if (!$nestedStmt instanceof Assign) { continue; } $assign = $nestedStmt; - if (!$assign->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$assign->var instanceof PropertyFetch) { continue; } $propertyFetch = $assign->var; @@ -61,7 +61,7 @@ final class ConstructorPropertyDefaultExprResolver if ($this->exprAnalyzer->isDynamicExpr($expr)) { continue; } - $defaultPropertyExprAssigns[] = new \Rector\CodeQuality\ValueObject\DefaultPropertyExprAssign($stmt, $propertyName, $expr); + $defaultPropertyExprAssigns[] = new DefaultPropertyExprAssign($stmt, $propertyName, $expr); } return $defaultPropertyExprAssigns; } diff --git a/rules/CodeQuality/NodeAnalyzer/ForAnalyzer.php b/rules/CodeQuality/NodeAnalyzer/ForAnalyzer.php index 2bd15544c26..bdd67d605a4 100644 --- a/rules/CodeQuality/NodeAnalyzer/ForAnalyzer.php +++ b/rules/CodeQuality/NodeAnalyzer/ForAnalyzer.php @@ -47,7 +47,7 @@ final class ForAnalyzer * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\NodeManipulator\AssignManipulator $assignManipulator, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder, AssignManipulator $assignManipulator, NodeComparator $nodeComparator) { $this->nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; @@ -60,14 +60,14 @@ final class ForAnalyzer public function isCondExprSmallerOrGreater(array $condExprs, string $keyValueName, string $countValueName) : bool { // $i < $count - if ($condExprs[0] instanceof \PhpParser\Node\Expr\BinaryOp\Smaller) { + if ($condExprs[0] instanceof Smaller) { if (!$this->nodeNameResolver->isName($condExprs[0]->left, $keyValueName)) { return \false; } return $this->nodeNameResolver->isName($condExprs[0]->right, $countValueName); } // $i > $count - if ($condExprs[0] instanceof \PhpParser\Node\Expr\BinaryOp\Greater) { + if ($condExprs[0] instanceof Greater) { if (!$this->nodeNameResolver->isName($condExprs[0]->left, $countValueName)) { return \false; } @@ -88,51 +88,51 @@ final class ForAnalyzer return \false; } $prePostInc = $loopExprs[0]; - if ($prePostInc instanceof \PhpParser\Node\Expr\PreInc || $prePostInc instanceof \PhpParser\Node\Expr\PostInc) { + if ($prePostInc instanceof PreInc || $prePostInc instanceof PostInc) { return $this->nodeNameResolver->isName($prePostInc->var, $keyValueName); } return \false; } - public function isCountValueVariableUsedInsideForStatements(\PhpParser\Node\Stmt\For_ $for, ?\PhpParser\Node\Expr $expr) : bool + public function isCountValueVariableUsedInsideForStatements(For_ $for, ?Expr $expr) : bool { - return (bool) $this->betterNodeFinder->findFirst($for->stmts, function (\PhpParser\Node $node) use($expr) : bool { + return (bool) $this->betterNodeFinder->findFirst($for->stmts, function (Node $node) use($expr) : bool { return $this->nodeComparator->areNodesEqual($node, $expr); }); } - public function isArrayWithKeyValueNameUnsetted(\PhpParser\Node\Stmt\For_ $for) : bool + public function isArrayWithKeyValueNameUnsetted(For_ $for) : bool { - return (bool) $this->betterNodeFinder->findFirst($for->stmts, function (\PhpParser\Node $node) : bool { + return (bool) $this->betterNodeFinder->findFirst($for->stmts, function (Node $node) : bool { /** @var Node $parent */ - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\Stmt\Unset_) { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Unset_) { return \false; } - return $node instanceof \PhpParser\Node\Expr\ArrayDimFetch; + return $node instanceof ArrayDimFetch; }); } - public function isAssignmentWithArrayDimFetchAsVariableInsideForStatements(\PhpParser\Node\Stmt\For_ $for, string $keyValueName) : bool + public function isAssignmentWithArrayDimFetchAsVariableInsideForStatements(For_ $for, string $keyValueName) : bool { - return (bool) $this->betterNodeFinder->findFirst($for->stmts, function (\PhpParser\Node $node) use($keyValueName) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + return (bool) $this->betterNodeFinder->findFirst($for->stmts, function (Node $node) use($keyValueName) : bool { + if (!$node instanceof Assign) { return \false; } - if (!$node->var instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$node->var instanceof ArrayDimFetch) { return \false; } $arrayDimFetch = $node->var; if ($arrayDimFetch->dim === null) { return \false; } - if (!$arrayDimFetch->dim instanceof \PhpParser\Node\Expr\Variable) { + if (!$arrayDimFetch->dim instanceof Variable) { return \false; } return $this->nodeNameResolver->isName($arrayDimFetch->dim, $keyValueName); }); } - public function isValueVarUsedNext(\PhpParser\Node\Stmt\For_ $for, string $iteratedVariableSingle) : bool + public function isValueVarUsedNext(For_ $for, string $iteratedVariableSingle) : bool { - return (bool) $this->betterNodeFinder->findFirstNext($for, function (\PhpParser\Node $node) use($iteratedVariableSingle) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + return (bool) $this->betterNodeFinder->findFirstNext($for, function (Node $node) use($iteratedVariableSingle) : bool { + if (!$node instanceof Variable) { return \false; } return $this->nodeNameResolver->isName($node, $iteratedVariableSingle); @@ -148,10 +148,10 @@ final class ForAnalyzer } return $keyValueName === null; } - public function isArrayDimFetchPartOfAssignOrArgParentCount(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch) : bool + public function isArrayDimFetchPartOfAssignOrArgParentCount(ArrayDimFetch $arrayDimFetch) : bool { - $parentNode = $arrayDimFetch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node) { + $parentNode = $arrayDimFetch->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof Node) { return \false; } if ($this->assignManipulator->isNodePartOfAssign($parentNode)) { @@ -159,13 +159,13 @@ final class ForAnalyzer } return $this->isArgParentCount($parentNode); } - private function isArgParentCount(\PhpParser\Node $node) : bool + private function isArgParentCount(Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Arg) { + if (!$node instanceof Arg) { return \false; } - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\Expr\FuncCall) { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof FuncCall) { return \false; } return $this->nodeNameResolver->isName($parent, self::COUNT); diff --git a/rules/CodeQuality/NodeAnalyzer/ForeachAnalyzer.php b/rules/CodeQuality/NodeAnalyzer/ForeachAnalyzer.php index 76611f9c41c..28bb52b39c5 100644 --- a/rules/CodeQuality/NodeAnalyzer/ForeachAnalyzer.php +++ b/rules/CodeQuality/NodeAnalyzer/ForeachAnalyzer.php @@ -42,7 +42,7 @@ final class ForeachAnalyzer * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\CodeQuality\NodeAnalyzer\ForAnalyzer $forAnalyzer, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeComparator $nodeComparator, \Rector\CodeQuality\NodeAnalyzer\ForAnalyzer $forAnalyzer, NodeNameResolver $nodeNameResolver, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, BetterNodeFinder $betterNodeFinder) { $this->nodeComparator = $nodeComparator; $this->forAnalyzer = $forAnalyzer; @@ -56,19 +56,19 @@ final class ForeachAnalyzer * <$assigns[]> = $value; * } */ - public function matchAssignItemsOnlyForeachArrayVariable(\PhpParser\Node\Stmt\Foreach_ $foreach) : ?\PhpParser\Node\Expr + public function matchAssignItemsOnlyForeachArrayVariable(Foreach_ $foreach) : ?Expr { if (\count($foreach->stmts) !== 1) { return null; } $onlyStatement = $foreach->stmts[0]; - if ($onlyStatement instanceof \PhpParser\Node\Stmt\Expression) { + if ($onlyStatement instanceof Expression) { $onlyStatement = $onlyStatement->expr; } - if (!$onlyStatement instanceof \PhpParser\Node\Expr\Assign) { + if (!$onlyStatement instanceof Assign) { return null; } - if (!$onlyStatement->var instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$onlyStatement->var instanceof ArrayDimFetch) { return null; } if ($onlyStatement->var->dim !== null) { @@ -82,10 +82,10 @@ final class ForeachAnalyzer /** * @param Stmt[] $stmts */ - public function useForeachVariableInStmts(\PhpParser\Node\Expr $foreachedValue, \PhpParser\Node\Expr $singleValue, array $stmts, string $keyValueName) : void + public function useForeachVariableInStmts(Expr $foreachedValue, Expr $singleValue, array $stmts, string $keyValueName) : void { - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmts, function (\PhpParser\Node $node) use($foreachedValue, $singleValue, $keyValueName) : ?Expr { - if (!$node instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmts, function (Node $node) use($foreachedValue, $singleValue, $keyValueName) : ?Expr { + if (!$node instanceof ArrayDimFetch) { return null; } // must be the same as foreach value @@ -96,7 +96,7 @@ final class ForeachAnalyzer return null; } // is dim same as key value name, ...[$i] - if (!$node->dim instanceof \PhpParser\Node\Expr\Variable) { + if (!$node->dim instanceof Variable) { return null; } if (!$this->nodeNameResolver->isName($node->dim, $keyValueName)) { @@ -105,10 +105,10 @@ final class ForeachAnalyzer return $singleValue; }); } - public function isValueVarUsed(\PhpParser\Node\Stmt\Foreach_ $foreach, string $singularValueVarName) : bool + public function isValueVarUsed(Foreach_ $foreach, string $singularValueVarName) : bool { - $isUsedInStmts = (bool) $this->betterNodeFinder->findFirst($foreach->stmts, function (\PhpParser\Node $node) use($singularValueVarName) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + $isUsedInStmts = (bool) $this->betterNodeFinder->findFirst($foreach->stmts, function (Node $node) use($singularValueVarName) : bool { + if (!$node instanceof Variable) { return \false; } return $this->nodeNameResolver->isName($node, $singularValueVarName); @@ -116,8 +116,8 @@ final class ForeachAnalyzer if ($isUsedInStmts) { return \true; } - return (bool) $this->betterNodeFinder->findFirstNext($foreach, function (\PhpParser\Node $node) use($singularValueVarName) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + return (bool) $this->betterNodeFinder->findFirstNext($foreach, function (Node $node) use($singularValueVarName) : bool { + if (!$node instanceof Variable) { return \false; } return $this->nodeNameResolver->isName($node, $singularValueVarName); diff --git a/rules/CodeQuality/NodeAnalyzer/LocalPropertyAnalyzer.php b/rules/CodeQuality/NodeAnalyzer/LocalPropertyAnalyzer.php index e949474a2fb..4c0c20f3372 100644 --- a/rules/CodeQuality/NodeAnalyzer/LocalPropertyAnalyzer.php +++ b/rules/CodeQuality/NodeAnalyzer/LocalPropertyAnalyzer.php @@ -72,7 +72,7 @@ final class LocalPropertyAnalyzer * @var \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory */ private $typeFactory; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\CodeQuality\TypeResolver\ArrayDimFetchTypeResolver $arrayDimFetchTypeResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, ClassAnalyzer $classAnalyzer, NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder, ArrayDimFetchTypeResolver $arrayDimFetchTypeResolver, NodeTypeResolver $nodeTypeResolver, PropertyFetchAnalyzer $propertyFetchAnalyzer, TypeFactory $typeFactory) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->classAnalyzer = $classAnalyzer; @@ -86,16 +86,16 @@ final class LocalPropertyAnalyzer /** * @return array */ - public function resolveFetchedPropertiesToTypesFromClass(\PhpParser\Node\Stmt\Class_ $class) : array + public function resolveFetchedPropertiesToTypesFromClass(Class_ $class) : array { $fetchedLocalPropertyNameToTypes = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($class->stmts, function (\PhpParser\Node $node) use(&$fetchedLocalPropertyNameToTypes) : ?int { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($class->stmts, function (Node $node) use(&$fetchedLocalPropertyNameToTypes) : ?int { // skip anonymous class scope $isAnonymousClass = $this->classAnalyzer->isAnonymousClass($node); if ($isAnonymousClass) { - return \PhpParser\NodeTraverser::DONT_TRAVERSE_CHILDREN; + return NodeTraverser::DONT_TRAVERSE_CHILDREN; } - if (!$node instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$node instanceof PropertyFetch) { return null; } if (!$this->propertyFetchAnalyzer->isLocalPropertyFetch($node)) { @@ -108,8 +108,8 @@ final class LocalPropertyAnalyzer if ($propertyName === null) { return null; } - $parentFunctionLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\FunctionLike::class); - if (!$parentFunctionLike instanceof \PhpParser\Node\Stmt\ClassMethod) { + $parentFunctionLike = $this->betterNodeFinder->findParentType($node, FunctionLike::class); + if (!$parentFunctionLike instanceof ClassMethod) { return null; } $propertyFetchType = $this->resolvePropertyFetchType($node); @@ -118,7 +118,7 @@ final class LocalPropertyAnalyzer }); return $this->normalizeToSingleType($fetchedLocalPropertyNameToTypes); } - private function shouldSkipPropertyFetch(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : bool + private function shouldSkipPropertyFetch(PropertyFetch $propertyFetch) : bool { // special Laravel collection scope if ($this->shouldSkipForLaravelCollection($propertyFetch)) { @@ -127,22 +127,22 @@ final class LocalPropertyAnalyzer if ($this->isPartOfClosureBind($propertyFetch)) { return \true; } - if ($propertyFetch->name instanceof \PhpParser\Node\Expr\Variable) { + if ($propertyFetch->name instanceof Variable) { return \true; } return $this->isPartOfClosureBindTo($propertyFetch); } - private function resolvePropertyFetchType(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : \PHPStan\Type\Type + private function resolvePropertyFetchType(PropertyFetch $propertyFetch) : Type { - $parentNode = $propertyFetch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $propertyFetch->getAttribute(AttributeKey::PARENT_NODE); // possible get type - if ($parentNode instanceof \PhpParser\Node\Expr\Assign) { + if ($parentNode instanceof Assign) { return $this->nodeTypeResolver->getType($parentNode->expr); } - if ($parentNode instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if ($parentNode instanceof ArrayDimFetch) { return $this->arrayDimFetchTypeResolver->resolve($parentNode); } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } /** * @param array $propertyNameToTypes @@ -157,10 +157,10 @@ final class LocalPropertyAnalyzer } return $propertyNameToType; } - private function shouldSkipForLaravelCollection(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : bool + private function shouldSkipForLaravelCollection(PropertyFetch $propertyFetch) : bool { - $staticCallOrClassMethod = $this->betterNodeFinder->findParentByTypes($propertyFetch, [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Expr\StaticCall::class]); - if (!$staticCallOrClassMethod instanceof \PhpParser\Node\Expr\StaticCall) { + $staticCallOrClassMethod = $this->betterNodeFinder->findParentByTypes($propertyFetch, [ClassMethod::class, StaticCall::class]); + if (!$staticCallOrClassMethod instanceof StaticCall) { return \false; } return $this->nodeNameResolver->isName($staticCallOrClassMethod->class, self::LARAVEL_COLLECTION_CLASS); @@ -169,10 +169,10 @@ final class LocalPropertyAnalyzer * Local property is actually not local one, but belongs to passed object * See https://ocramius.github.io/blog/accessing-private-php-class-members-without-reflection/ */ - private function isPartOfClosureBind(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : bool + private function isPartOfClosureBind(PropertyFetch $propertyFetch) : bool { - $parentStaticCall = $this->betterNodeFinder->findParentType($propertyFetch, \PhpParser\Node\Expr\StaticCall::class); - if (!$parentStaticCall instanceof \PhpParser\Node\Expr\StaticCall) { + $parentStaticCall = $this->betterNodeFinder->findParentType($propertyFetch, StaticCall::class); + if (!$parentStaticCall instanceof StaticCall) { return \false; } if (!$this->nodeNameResolver->isName($parentStaticCall->class, 'Closure')) { @@ -180,13 +180,13 @@ final class LocalPropertyAnalyzer } return $this->nodeNameResolver->isName($parentStaticCall->name, 'bind'); } - private function isPartOfClosureBindTo(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : bool + private function isPartOfClosureBindTo(PropertyFetch $propertyFetch) : bool { - $parentMethodCall = $this->betterNodeFinder->findParentType($propertyFetch, \PhpParser\Node\Expr\MethodCall::class); - if (!$parentMethodCall instanceof \PhpParser\Node\Expr\MethodCall) { + $parentMethodCall = $this->betterNodeFinder->findParentType($propertyFetch, MethodCall::class); + if (!$parentMethodCall instanceof MethodCall) { return \false; } - if (!$parentMethodCall->var instanceof \PhpParser\Node\Expr\Closure) { + if (!$parentMethodCall->var instanceof Closure) { return \false; } return $this->nodeNameResolver->isName($parentMethodCall->name, 'bindTo'); diff --git a/rules/CodeQuality/NodeAnalyzer/ReturnAnalyzer.php b/rules/CodeQuality/NodeAnalyzer/ReturnAnalyzer.php index b6b75934a38..85506456735 100644 --- a/rules/CodeQuality/NodeAnalyzer/ReturnAnalyzer.php +++ b/rules/CodeQuality/NodeAnalyzer/ReturnAnalyzer.php @@ -13,14 +13,14 @@ final class ReturnAnalyzer * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(BetterNodeFinder $betterNodeFinder) { $this->betterNodeFinder = $betterNodeFinder; } - public function hasByRefReturn(\PhpParser\Node\Stmt\Return_ $return) : bool + public function hasByRefReturn(Return_ $return) : bool { - $parentFunctionLike = $this->betterNodeFinder->findParentType($return, \PhpParser\Node\FunctionLike::class); - if ($parentFunctionLike instanceof \PhpParser\Node\FunctionLike) { + $parentFunctionLike = $this->betterNodeFinder->findParentType($return, FunctionLike::class); + if ($parentFunctionLike instanceof FunctionLike) { return $parentFunctionLike->returnsByRef(); } return \false; diff --git a/rules/CodeQuality/NodeAnalyzer/VariableDimFetchAssignResolver.php b/rules/CodeQuality/NodeAnalyzer/VariableDimFetchAssignResolver.php index 3c2e13c1df3..1decac80d21 100644 --- a/rules/CodeQuality/NodeAnalyzer/VariableDimFetchAssignResolver.php +++ b/rules/CodeQuality/NodeAnalyzer/VariableDimFetchAssignResolver.php @@ -25,7 +25,7 @@ final class VariableDimFetchAssignResolver * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeComparator $nodeComparator, BetterNodeFinder $betterNodeFinder) { $this->nodeComparator = $nodeComparator; $this->betterNodeFinder = $betterNodeFinder; @@ -34,20 +34,20 @@ final class VariableDimFetchAssignResolver * @param Stmt[] $stmts * @return KeyAndExpr[] */ - public function resolveFromStmtsAndVariable(array $stmts, \PhpParser\Node\Expr\Variable $variable) : array + public function resolveFromStmtsAndVariable(array $stmts, Variable $variable) : array { $keysAndExprs = []; foreach ($stmts as $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { return []; } $stmtExpr = $stmt->expr; - if (!$stmtExpr instanceof \PhpParser\Node\Expr\Assign) { + if (!$stmtExpr instanceof Assign) { return []; } $assign = $stmtExpr; $keyExpr = $this->matchKeyOnArrayDimFetchOfVariable($assign, $variable); - $keysAndExprs[] = new \Rector\CodeQuality\ValueObject\KeyAndExpr($keyExpr, $assign->expr, $stmt->getComments()); + $keysAndExprs[] = new KeyAndExpr($keyExpr, $assign->expr, $stmt->getComments()); } // we can only work with same variable // and exclusively various keys or empty keys @@ -56,16 +56,16 @@ final class VariableDimFetchAssignResolver } return $keysAndExprs; } - private function matchKeyOnArrayDimFetchOfVariable(\PhpParser\Node\Expr\Assign $assign, \PhpParser\Node\Expr\Variable $variable) : ?\PhpParser\Node\Expr + private function matchKeyOnArrayDimFetchOfVariable(Assign $assign, Variable $variable) : ?Expr { - if (!$assign->var instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$assign->var instanceof ArrayDimFetch) { return null; } $arrayDimFetch = $assign->var; if (!$this->nodeComparator->areNodesEqual($arrayDimFetch->var, $variable)) { return null; } - $isFoundInExpr = (bool) $this->betterNodeFinder->findFirst($assign->expr, function (\PhpParser\Node $subNode) use($variable) : bool { + $isFoundInExpr = (bool) $this->betterNodeFinder->findFirst($assign->expr, function (Node $subNode) use($variable) : bool { return $this->nodeComparator->areNodesEqual($subNode, $variable); }); if ($isFoundInExpr) { diff --git a/rules/CodeQuality/NodeFactory/ArrayFilterFactory.php b/rules/CodeQuality/NodeFactory/ArrayFilterFactory.php index 85e204f56c7..aafe7593ced 100644 --- a/rules/CodeQuality/NodeFactory/ArrayFilterFactory.php +++ b/rules/CodeQuality/NodeFactory/ArrayFilterFactory.php @@ -25,33 +25,33 @@ final class ArrayFilterFactory * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PhpVersionProvider $phpVersionProvider) { $this->phpVersionProvider = $phpVersionProvider; } - public function createSimpleFuncCallAssign(\PhpParser\Node\Stmt\Foreach_ $foreach, string $funcName, \PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch) : \PhpParser\Node\Expr\Assign + public function createSimpleFuncCallAssign(Foreach_ $foreach, string $funcName, ArrayDimFetch $arrayDimFetch) : Assign { - $string = new \PhpParser\Node\Scalar\String_($funcName); - $args = [new \PhpParser\Node\Arg($foreach->expr), new \PhpParser\Node\Arg($string)]; - $arrayFilterFuncCall = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('array_filter'), $args); - return new \PhpParser\Node\Expr\Assign($arrayDimFetch->var, $arrayFilterFuncCall); + $string = new String_($funcName); + $args = [new Arg($foreach->expr), new Arg($string)]; + $arrayFilterFuncCall = new FuncCall(new Name('array_filter'), $args); + return new Assign($arrayDimFetch->var, $arrayFilterFuncCall); } - public function createWithClosure(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch, \PhpParser\Node\Expr\Variable $valueVariable, \PhpParser\Node\Expr $condExpr, \PhpParser\Node\Stmt\Foreach_ $foreach) : \PhpParser\Node\Expr\Assign + public function createWithClosure(ArrayDimFetch $arrayDimFetch, Variable $valueVariable, Expr $condExpr, Foreach_ $foreach) : Assign { $filterFunction = $this->createClosure($valueVariable, $condExpr); - $args = [new \PhpParser\Node\Arg($foreach->expr), new \PhpParser\Node\Arg($filterFunction)]; - $arrayFilterFuncCall = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('array_filter'), $args); - return new \PhpParser\Node\Expr\Assign($arrayDimFetch->var, $arrayFilterFuncCall); + $args = [new Arg($foreach->expr), new Arg($filterFunction)]; + $arrayFilterFuncCall = new FuncCall(new Name('array_filter'), $args); + return new Assign($arrayDimFetch->var, $arrayFilterFuncCall); } /** * @return \PhpParser\Node\Expr\ArrowFunction|\PhpParser\Node\Expr\Closure */ - private function createClosure(\PhpParser\Node\Expr\Variable $valueVariable, \PhpParser\Node\Expr $condExpr) + private function createClosure(Variable $valueVariable, Expr $condExpr) { - $params = [new \PhpParser\Node\Param($valueVariable)]; - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::ARROW_FUNCTION)) { - return new \PhpParser\Node\Expr\ArrowFunction(['params' => $params, 'expr' => $condExpr]); + $params = [new Param($valueVariable)]; + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::ARROW_FUNCTION)) { + return new ArrowFunction(['params' => $params, 'expr' => $condExpr]); } - return new \PhpParser\Node\Expr\Closure(['params' => $params, 'stmts' => [new \PhpParser\Node\Stmt\Return_($condExpr)]]); + return new Closure(['params' => $params, 'stmts' => [new Return_($condExpr)]]); } } diff --git a/rules/CodeQuality/NodeFactory/ForeachFactory.php b/rules/CodeQuality/NodeFactory/ForeachFactory.php index cf85264dbe5..4bc939b1bfc 100644 --- a/rules/CodeQuality/NodeFactory/ForeachFactory.php +++ b/rules/CodeQuality/NodeFactory/ForeachFactory.php @@ -10,17 +10,17 @@ use PhpParser\Node\Stmt\Foreach_; use Rector\Core\Exception\ShouldNotHappenException; final class ForeachFactory { - public function createFromFor(\PhpParser\Node\Stmt\For_ $for, string $iteratedVariableName, ?\PhpParser\Node\Expr $iteratedExpr, ?string $keyValueName) : \PhpParser\Node\Stmt\Foreach_ + public function createFromFor(For_ $for, string $iteratedVariableName, ?Expr $iteratedExpr, ?string $keyValueName) : Foreach_ { if ($iteratedExpr === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } if ($keyValueName === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } - $foreach = new \PhpParser\Node\Stmt\Foreach_($iteratedExpr, new \PhpParser\Node\Expr\Variable($iteratedVariableName)); + $foreach = new Foreach_($iteratedExpr, new Variable($iteratedVariableName)); $foreach->stmts = $for->stmts; - $foreach->keyVar = new \PhpParser\Node\Expr\Variable($keyValueName); + $foreach->keyVar = new Variable($keyValueName); return $foreach; } } diff --git a/rules/CodeQuality/NodeFactory/MissingPropertiesFactory.php b/rules/CodeQuality/NodeFactory/MissingPropertiesFactory.php index 86735980e8d..ad893fdedc7 100644 --- a/rules/CodeQuality/NodeFactory/MissingPropertiesFactory.php +++ b/rules/CodeQuality/NodeFactory/MissingPropertiesFactory.php @@ -18,7 +18,7 @@ final class MissingPropertiesFactory * @var \Rector\CodeQuality\NodeFactory\PropertyTypeDecorator */ private $propertyTypeDecorator; - public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\CodeQuality\NodeFactory\PropertyTypeDecorator $propertyTypeDecorator) + public function __construct(NodeFactory $nodeFactory, \Rector\CodeQuality\NodeFactory\PropertyTypeDecorator $propertyTypeDecorator) { $this->nodeFactory = $nodeFactory; $this->propertyTypeDecorator = $propertyTypeDecorator; diff --git a/rules/CodeQuality/NodeFactory/PropertyTypeDecorator.php b/rules/CodeQuality/NodeFactory/PropertyTypeDecorator.php index eeed2a8ce41..a6d9c487f37 100644 --- a/rules/CodeQuality/NodeFactory/PropertyTypeDecorator.php +++ b/rules/CodeQuality/NodeFactory/PropertyTypeDecorator.php @@ -45,7 +45,7 @@ final class PropertyTypeDecorator * @var \Rector\Privatization\TypeManipulator\TypeNormalizer */ private $typeNormalizer; - public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Privatization\TypeManipulator\TypeNormalizer $typeNormalizer) + public function __construct(PhpVersionProvider $phpVersionProvider, StaticTypeMapper $staticTypeMapper, PhpDocTypeChanger $phpDocTypeChanger, PhpDocInfoFactory $phpDocInfoFactory, TypeNormalizer $typeNormalizer) { $this->phpVersionProvider = $phpVersionProvider; $this->staticTypeMapper = $staticTypeMapper; @@ -53,7 +53,7 @@ final class PropertyTypeDecorator $this->phpDocInfoFactory = $phpDocInfoFactory; $this->typeNormalizer = $typeNormalizer; } - public function decorateProperty(\PhpParser\Node\Stmt\Property $property, \PHPStan\Type\Type $propertyType) : void + public function decorateProperty(Property $property, Type $propertyType) : void { // generalize false/true type to bool, as mostly default value but accepts both $propertyType = $this->typeNormalizer->generalizeConstantBoolTypes($propertyType); @@ -63,7 +63,7 @@ final class PropertyTypeDecorator /** * @param \PhpParser\Node\ComplexType|\PhpParser\Node\Identifier|\PhpParser\Node\Name $typeNode */ - public function decoratePropertyWithDocBlock(\PhpParser\Node\Stmt\Property $property, $typeNode) : void + public function decoratePropertyWithDocBlock(Property $property, $typeNode) : void { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); if ($phpDocInfo->getVarTagValueNode() !== null) { @@ -72,18 +72,18 @@ final class PropertyTypeDecorator $newType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($typeNode); $this->phpDocTypeChanger->changeVarType($phpDocInfo, $newType); } - private function decoratePropertyWithVarDoc(\PhpParser\Node\Stmt\Property $property, \PHPStan\Type\Type $propertyType) : void + private function decoratePropertyWithVarDoc(Property $property, Type $propertyType) : void { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); $phpDocInfo->makeMultiLined(); if ($this->isNonMixedArrayType($propertyType)) { $this->phpDocTypeChanger->changeVarType($phpDocInfo, $propertyType); - $property->type = new \PhpParser\Node\Identifier('array'); + $property->type = new Identifier('array'); return; } - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES)) { - $phpParserNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY); - if (!$phpParserNode instanceof \PhpParser\Node) { + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::TYPED_PROPERTIES)) { + $phpParserNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, TypeKind::PROPERTY); + if (!$phpParserNode instanceof Node) { // fallback to doc type in PHP 7.4 $this->phpDocTypeChanger->changeVarType($phpDocInfo, $propertyType); } @@ -91,25 +91,25 @@ final class PropertyTypeDecorator $this->phpDocTypeChanger->changeVarType($phpDocInfo, $propertyType); } } - private function decoratePropertyWithType(\PhpParser\Node\Stmt\Property $property, \PHPStan\Type\Type $propertyType) : void + private function decoratePropertyWithType(Property $property, Type $propertyType) : void { - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::TYPED_PROPERTIES)) { return; } - $phpParserNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY); - if (!$phpParserNode instanceof \PhpParser\Node) { + $phpParserNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, TypeKind::PROPERTY); + if (!$phpParserNode instanceof Node) { return; } $property->type = $phpParserNode; } - private function isNonMixedArrayType(\PHPStan\Type\Type $type) : bool + private function isNonMixedArrayType(Type $type) : bool { - if (!$type instanceof \PHPStan\Type\ArrayType) { + if (!$type instanceof ArrayType) { return \false; } - if ($type->getKeyType() instanceof \PHPStan\Type\MixedType) { + if ($type->getKeyType() instanceof MixedType) { return \false; } - return !$type->getItemType() instanceof \PHPStan\Type\MixedType; + return !$type->getItemType() instanceof MixedType; } } diff --git a/rules/CodeQuality/NodeManipulator/ClassMethodParameterTypeManipulator.php b/rules/CodeQuality/NodeManipulator/ClassMethodParameterTypeManipulator.php index d5a725d5248..71a550cec8d 100644 --- a/rules/CodeQuality/NodeManipulator/ClassMethodParameterTypeManipulator.php +++ b/rules/CodeQuality/NodeManipulator/ClassMethodParameterTypeManipulator.php @@ -58,7 +58,7 @@ final class ClassMethodParameterTypeManipulator * @var \Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser */ private $simpleCallableNodeTraverser; - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\Core\NodeAnalyzer\ParamAnalyzer $paramAnalyzer, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory, PhpDocTypeChanger $phpDocTypeChanger, NodeTypeResolver $nodeTypeResolver, ParamAnalyzer $paramAnalyzer, NodeNameResolver $nodeNameResolver, SimpleCallableNodeTraverser $simpleCallableNodeTraverser) { $this->phpDocInfoFactory = $phpDocInfoFactory; $this->phpDocTypeChanger = $phpDocTypeChanger; @@ -71,7 +71,7 @@ final class ClassMethodParameterTypeManipulator * @param string[] $methodsReturningClassInstance * @param \PhpParser\Node\Identifier|\PhpParser\Node\Name|\PhpParser\Node\NullableType $replaceIntoType */ - public function refactorFunctionParameters(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PHPStan\Type\ObjectType $objectType, $replaceIntoType, \PHPStan\Type\Type $phpDocType, array $methodsReturningClassInstance) : void + public function refactorFunctionParameters(ClassMethod $classMethod, ObjectType $objectType, $replaceIntoType, Type $phpDocType, array $methodsReturningClassInstance) : void { foreach ($classMethod->getParams() as $param) { if (!$this->nodeTypeResolver->isObjectType($param, $objectType)) { @@ -89,26 +89,26 @@ final class ClassMethodParameterTypeManipulator /** * @param \PhpParser\Node\Identifier|\PhpParser\Node\Name|\PhpParser\Node\NullableType $replaceIntoType */ - private function refactorParamTypeHint(\PhpParser\Node\Param $param, $replaceIntoType) : void + private function refactorParamTypeHint(Param $param, $replaceIntoType) : void { - if ($this->paramAnalyzer->isNullable($param) && !$replaceIntoType instanceof \PhpParser\Node\NullableType) { - $replaceIntoType = new \PhpParser\Node\NullableType($replaceIntoType); + if ($this->paramAnalyzer->isNullable($param) && !$replaceIntoType instanceof NullableType) { + $replaceIntoType = new NullableType($replaceIntoType); } $param->type = $replaceIntoType; } - private function refactorParamDocBlock(\PhpParser\Node\Param $param, \PhpParser\Node\Stmt\ClassMethod $classMethod, \PHPStan\Type\Type $phpDocType) : void + private function refactorParamDocBlock(Param $param, ClassMethod $classMethod, Type $phpDocType) : void { $paramName = $this->nodeNameResolver->getName($param->var); if ($paramName === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } if ($this->paramAnalyzer->isNullable($param)) { - if ($phpDocType instanceof \PHPStan\Type\UnionType) { + if ($phpDocType instanceof UnionType) { $item0Unpacked = $phpDocType->getTypes(); // Adding a UnionType into a new UnionType throws an exception so we need to "unpack" the types - $phpDocType = new \PHPStan\Type\UnionType(\array_merge($item0Unpacked, [new \PHPStan\Type\NullType()])); + $phpDocType = new UnionType(\array_merge($item0Unpacked, [new NullType()])); } else { - $phpDocType = new \PHPStan\Type\UnionType([$phpDocType, new \PHPStan\Type\NullType()]); + $phpDocType = new UnionType([$phpDocType, new NullType()]); } } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); @@ -117,13 +117,13 @@ final class ClassMethodParameterTypeManipulator /** * @param string[] $methodsReturningClassInstance */ - private function refactorMethodCalls(\PhpParser\Node\Param $param, \PhpParser\Node\Stmt\ClassMethod $classMethod, array $methodsReturningClassInstance) : void + private function refactorMethodCalls(Param $param, ClassMethod $classMethod, array $methodsReturningClassInstance) : void { if ($classMethod->stmts === null) { return; } - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classMethod->stmts, function (\PhpParser\Node $node) use($param, $methodsReturningClassInstance) { - if (!$node instanceof \PhpParser\Node\Expr\MethodCall) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classMethod->stmts, function (Node $node) use($param, $methodsReturningClassInstance) { + if (!$node instanceof MethodCall) { return null; } $this->refactorMethodCall($param, $node, $methodsReturningClassInstance); @@ -133,7 +133,7 @@ final class ClassMethodParameterTypeManipulator /** * @param string[] $methodsReturningClassInstance */ - private function refactorMethodCall(\PhpParser\Node\Param $param, \PhpParser\Node\Expr\MethodCall $methodCall, array $methodsReturningClassInstance) : void + private function refactorMethodCall(Param $param, MethodCall $methodCall, array $methodsReturningClassInstance) : void { $paramName = $this->nodeNameResolver->getName($param->var); if ($paramName === null) { @@ -142,14 +142,14 @@ final class ClassMethodParameterTypeManipulator if ($this->shouldSkipMethodCallRefactor($paramName, $methodCall, $methodsReturningClassInstance)) { return; } - $assign = new \PhpParser\Node\Expr\Assign(new \PhpParser\Node\Expr\Variable($paramName), $methodCall); + $assign = new Assign(new Variable($paramName), $methodCall); /** @var Node $parent */ - $parent = $methodCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\Arg) { + $parent = $methodCall->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof Arg) { $parent->value = $assign; return; } - if (!$parent instanceof \PhpParser\Node\Stmt\Expression) { + if (!$parent instanceof Expression) { return; } $parent->expr = $assign; @@ -157,7 +157,7 @@ final class ClassMethodParameterTypeManipulator /** * @param string[] $methodsReturningClassInstance */ - private function shouldSkipMethodCallRefactor(string $paramName, \PhpParser\Node\Expr\MethodCall $methodCall, array $methodsReturningClassInstance) : bool + private function shouldSkipMethodCallRefactor(string $paramName, MethodCall $methodCall, array $methodsReturningClassInstance) : bool { if (!$this->nodeNameResolver->isName($methodCall->var, $paramName)) { return \true; @@ -165,10 +165,10 @@ final class ClassMethodParameterTypeManipulator if (!$this->nodeNameResolver->isNames($methodCall->name, $methodsReturningClassInstance)) { return \true; } - $parentNode = $methodCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node) { + $parentNode = $methodCall->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof Node) { return \true; } - return $parentNode instanceof \PhpParser\Node\Expr\Assign; + return $parentNode instanceof Assign; } } diff --git a/rules/CodeQuality/NodeManipulator/ClassMethodReturnTypeManipulator.php b/rules/CodeQuality/NodeManipulator/ClassMethodReturnTypeManipulator.php index 6f5fd522dad..f29f2300fb7 100644 --- a/rules/CodeQuality/NodeManipulator/ClassMethodReturnTypeManipulator.php +++ b/rules/CodeQuality/NodeManipulator/ClassMethodReturnTypeManipulator.php @@ -31,7 +31,7 @@ final class ClassMethodReturnTypeManipulator * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory, PhpDocTypeChanger $phpDocTypeChanger, NodeTypeResolver $nodeTypeResolver) { $this->phpDocInfoFactory = $phpDocInfoFactory; $this->phpDocTypeChanger = $phpDocTypeChanger; @@ -40,14 +40,14 @@ final class ClassMethodReturnTypeManipulator /** * @param \PhpParser\Node\Identifier|\PhpParser\Node\Name|\PhpParser\Node\NullableType $replaceIntoType */ - public function refactorFunctionReturnType(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PHPStan\Type\ObjectType $objectType, $replaceIntoType, \PHPStan\Type\Type $phpDocType) : ?\PhpParser\Node\Stmt\ClassMethod + public function refactorFunctionReturnType(ClassMethod $classMethod, ObjectType $objectType, $replaceIntoType, Type $phpDocType) : ?ClassMethod { $returnType = $classMethod->returnType; if ($returnType === null) { return null; } $isNullable = \false; - if ($returnType instanceof \PhpParser\Node\NullableType) { + if ($returnType instanceof NullableType) { $isNullable = \true; $returnType = $returnType->type; } @@ -59,15 +59,15 @@ final class ClassMethodReturnTypeManipulator return null; } if ($isNullable) { - if ($phpDocType instanceof \PHPStan\Type\UnionType) { + if ($phpDocType instanceof UnionType) { $item0Unpacked = $phpDocType->getTypes(); // Adding a UnionType into a new UnionType throws an exception so we need to "unpack" the types - $phpDocType = new \PHPStan\Type\UnionType(\array_merge($item0Unpacked, [new \PHPStan\Type\NullType()])); + $phpDocType = new UnionType(\array_merge($item0Unpacked, [new NullType()])); } else { - $phpDocType = new \PHPStan\Type\UnionType([$phpDocType, new \PHPStan\Type\NullType()]); + $phpDocType = new UnionType([$phpDocType, new NullType()]); } - if (!$replaceIntoType instanceof \PhpParser\Node\NullableType) { - $replaceIntoType = new \PhpParser\Node\NullableType($replaceIntoType); + if (!$replaceIntoType instanceof NullableType) { + $replaceIntoType = new NullableType($replaceIntoType); } } $classMethod->returnType = $replaceIntoType; diff --git a/rules/CodeQuality/NodeManipulator/ExprBoolCaster.php b/rules/CodeQuality/NodeManipulator/ExprBoolCaster.php index 5e4059342ea..1b8976a1632 100644 --- a/rules/CodeQuality/NodeManipulator/ExprBoolCaster.php +++ b/rules/CodeQuality/NodeManipulator/ExprBoolCaster.php @@ -36,45 +36,45 @@ final class ExprBoolCaster * @var \Rector\Core\PhpParser\Node\NodeFactory */ private $nodeFactory; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\PHPStanStaticTypeMapper\Utils\TypeUnwrapper $typeUnwrapper, \Rector\NodeTypeResolver\PHPStan\Type\StaticTypeAnalyzer $staticTypeAnalyzer, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory) + public function __construct(NodeTypeResolver $nodeTypeResolver, TypeUnwrapper $typeUnwrapper, StaticTypeAnalyzer $staticTypeAnalyzer, NodeFactory $nodeFactory) { $this->nodeTypeResolver = $nodeTypeResolver; $this->typeUnwrapper = $typeUnwrapper; $this->staticTypeAnalyzer = $staticTypeAnalyzer; $this->nodeFactory = $nodeFactory; } - public function boolCastOrNullCompareIfNeeded(\PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr + public function boolCastOrNullCompareIfNeeded(Expr $expr) : Expr { if (!$this->nodeTypeResolver->isNullableType($expr)) { if (!$this->isBoolCastNeeded($expr)) { return $expr; } - return new \PhpParser\Node\Expr\Cast\Bool_($expr); + return new Bool_($expr); } $exprStaticType = $this->nodeTypeResolver->getType($expr); // if we remove null type, still has to be trueable - if ($exprStaticType instanceof \PHPStan\Type\UnionType) { + if ($exprStaticType instanceof UnionType) { $unionTypeWithoutNullType = $this->typeUnwrapper->removeNullTypeFromUnionType($exprStaticType); if ($this->staticTypeAnalyzer->isAlwaysTruableType($unionTypeWithoutNullType)) { - return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, $this->nodeFactory->createNull()); + return new NotIdentical($expr, $this->nodeFactory->createNull()); } } elseif ($this->staticTypeAnalyzer->isAlwaysTruableType($exprStaticType)) { - return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, $this->nodeFactory->createNull()); + return new NotIdentical($expr, $this->nodeFactory->createNull()); } if (!$this->isBoolCastNeeded($expr)) { return $expr; } - return new \PhpParser\Node\Expr\Cast\Bool_($expr); + return new Bool_($expr); } - private function isBoolCastNeeded(\PhpParser\Node\Expr $expr) : bool + private function isBoolCastNeeded(Expr $expr) : bool { - if ($expr instanceof \PhpParser\Node\Expr\BooleanNot) { + if ($expr instanceof BooleanNot) { return \false; } $exprType = $this->nodeTypeResolver->getType($expr); - if ($exprType instanceof \PHPStan\Type\BooleanType) { + if ($exprType instanceof BooleanType) { return \false; } - return !$expr instanceof \PhpParser\Node\Expr\BinaryOp; + return !$expr instanceof BinaryOp; } } diff --git a/rules/CodeQuality/NodeTypeGroup.php b/rules/CodeQuality/NodeTypeGroup.php index 782598399ff..431d1bfe59c 100644 --- a/rules/CodeQuality/NodeTypeGroup.php +++ b/rules/CodeQuality/NodeTypeGroup.php @@ -25,5 +25,5 @@ final class NodeTypeGroup * @var array> * @api */ - public const STMTS_AWARE = [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Stmt\If_::class, \PhpParser\Node\Stmt\Else_::class, \PhpParser\Node\Stmt\ElseIf_::class, \PhpParser\Node\Stmt\Do_::class, \PhpParser\Node\Stmt\Foreach_::class, \PhpParser\Node\Stmt\TryCatch::class, \PhpParser\Node\Stmt\While_::class, \PhpParser\Node\Stmt\For_::class, \PhpParser\Node\Expr\Closure::class, \PhpParser\Node\Stmt\Finally_::class, \PhpParser\Node\Stmt\Case_::class, \PhpParser\Node\Stmt\Catch_::class]; + public const STMTS_AWARE = [ClassMethod::class, Function_::class, If_::class, Else_::class, ElseIf_::class, Do_::class, Foreach_::class, TryCatch::class, While_::class, For_::class, Closure::class, Finally_::class, Case_::class, Catch_::class]; } diff --git a/rules/CodeQuality/Rector/Array_/ArrayThisCallToThisMethodCallRector.php b/rules/CodeQuality/Rector/Array_/ArrayThisCallToThisMethodCallRector.php index def8e97c947..f9d65766bcb 100644 --- a/rules/CodeQuality/Rector/Array_/ArrayThisCallToThisMethodCallRector.php +++ b/rules/CodeQuality/Rector/Array_/ArrayThisCallToThisMethodCallRector.php @@ -17,12 +17,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\NodeCollector\NodeAnalyzer\ArrayCallableMethodMatcher; use Rector\NodeCollector\ValueObject\ArrayCallable; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Array_\ArrayThisCallToThisMethodCallRector\ArrayThisCallToThisMethodCallRectorTest */ -final class ArrayThisCallToThisMethodCallRector extends \Rector\Core\Rector\AbstractRector +final class ArrayThisCallToThisMethodCallRector extends AbstractRector { /** * @readonly @@ -34,14 +34,14 @@ final class ArrayThisCallToThisMethodCallRector extends \Rector\Core\Rector\Abst * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\NodeCollector\NodeAnalyzer\ArrayCallableMethodMatcher $arrayCallableMethodMatcher, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ArrayCallableMethodMatcher $arrayCallableMethodMatcher, ReflectionProvider $reflectionProvider) { $this->arrayCallableMethodMatcher = $arrayCallableMethodMatcher; $this->reflectionProvider = $reflectionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change `[$this, someMethod]` without any args to $this->someMethod()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change `[$this, someMethod]` without any args to $this->someMethod()', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -76,15 +76,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Array_::class]; + return [Array_::class]; } /** * @param Array_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $arrayCallable = $this->arrayCallableMethodMatcher->match($node); - if (!$arrayCallable instanceof \Rector\NodeCollector\ValueObject\ArrayCallable) { + if (!$arrayCallable instanceof ArrayCallable) { return null; } if ($this->isAssignedToNetteMagicOnProperty($node)) { @@ -93,9 +93,9 @@ CODE_SAMPLE if ($this->isInsideProperty($node)) { return null; } - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); // skip if part of method - if ($parentNode instanceof \PhpParser\Node\Arg) { + if ($parentNode instanceof Arg) { return null; } if (!$this->reflectionProvider->hasClass($arrayCallable->getClass())) { @@ -108,30 +108,30 @@ CODE_SAMPLE $nativeReflectionClass = $classReflection->getNativeReflection(); $nativeReflectionMethod = $nativeReflectionClass->getMethod($arrayCallable->getMethod()); if ($nativeReflectionMethod->getNumberOfParameters() === 0) { - return new \PhpParser\Node\Expr\MethodCall(new \PhpParser\Node\Expr\Variable('this'), $arrayCallable->getMethod()); + return new MethodCall(new Variable('this'), $arrayCallable->getMethod()); } $methodReflection = $classReflection->getNativeMethod($arrayCallable->getMethod()); return $this->nodeFactory->createClosureFromMethodReflection($methodReflection); } - private function isAssignedToNetteMagicOnProperty(\PhpParser\Node\Expr\Array_ $array) : bool + private function isAssignedToNetteMagicOnProperty(Array_ $array) : bool { - $parent = $array->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\Expr\Assign) { + $parent = $array->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Assign) { return \false; } - if (!$parent->var instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$parent->var instanceof ArrayDimFetch) { return \false; } - if (!$parent->var->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$parent->var->var instanceof PropertyFetch) { return \false; } /** @var PropertyFetch $propertyFetch */ $propertyFetch = $parent->var->var; return $this->isName($propertyFetch->name, 'on*'); } - private function isInsideProperty(\PhpParser\Node\Expr\Array_ $array) : bool + private function isInsideProperty(Array_ $array) : bool { - $parentProperty = $this->betterNodeFinder->findParentType($array, \PhpParser\Node\Stmt\Property::class); + $parentProperty = $this->betterNodeFinder->findParentType($array, Property::class); return $parentProperty !== null; } } diff --git a/rules/CodeQuality/Rector/Array_/CallableThisArrayToAnonymousFunctionRector.php b/rules/CodeQuality/Rector/Array_/CallableThisArrayToAnonymousFunctionRector.php index 3064dbae5e6..e943f69bc16 100644 --- a/rules/CodeQuality/Rector/Array_/CallableThisArrayToAnonymousFunctionRector.php +++ b/rules/CodeQuality/Rector/Array_/CallableThisArrayToAnonymousFunctionRector.php @@ -12,8 +12,8 @@ use Rector\Core\Reflection\ReflectionResolver; use Rector\NodeCollector\NodeAnalyzer\ArrayCallableMethodMatcher; use Rector\NodeCollector\ValueObject\ArrayCallable; use Rector\Php72\NodeFactory\AnonymousFunctionFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/language.types.callable.php#117260 * @changelog https://3v4l.org/MsMbQ @@ -21,7 +21,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @see \Rector\Tests\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector\CallableThisArrayToAnonymousFunctionRectorTest */ -final class CallableThisArrayToAnonymousFunctionRector extends \Rector\Core\Rector\AbstractScopeAwareRector +final class CallableThisArrayToAnonymousFunctionRector extends AbstractScopeAwareRector { /** * @readonly @@ -38,15 +38,15 @@ final class CallableThisArrayToAnonymousFunctionRector extends \Rector\Core\Rect * @var \Rector\NodeCollector\NodeAnalyzer\ArrayCallableMethodMatcher */ private $arrayCallableMethodMatcher; - public function __construct(\Rector\Php72\NodeFactory\AnonymousFunctionFactory $anonymousFunctionFactory, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\NodeCollector\NodeAnalyzer\ArrayCallableMethodMatcher $arrayCallableMethodMatcher) + public function __construct(AnonymousFunctionFactory $anonymousFunctionFactory, ReflectionResolver $reflectionResolver, ArrayCallableMethodMatcher $arrayCallableMethodMatcher) { $this->anonymousFunctionFactory = $anonymousFunctionFactory; $this->reflectionResolver = $reflectionResolver; $this->arrayCallableMethodMatcher = $arrayCallableMethodMatcher; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Convert [$this, "method"] to proper anonymous function', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Convert [$this, "method"] to proper anonymous function', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -89,19 +89,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Array_::class]; + return [Array_::class]; } /** * @param Array_ $node */ - public function refactorWithScope(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : ?\PhpParser\Node + public function refactorWithScope(Node $node, Scope $scope) : ?Node { $arrayCallable = $this->arrayCallableMethodMatcher->match($node); - if (!$arrayCallable instanceof \Rector\NodeCollector\ValueObject\ArrayCallable) { + if (!$arrayCallable instanceof ArrayCallable) { return null; } $phpMethodReflection = $this->reflectionResolver->resolveMethodReflection($arrayCallable->getClass(), $arrayCallable->getMethod(), $scope); - if (!$phpMethodReflection instanceof \PHPStan\Reflection\Php\PhpMethodReflection) { + if (!$phpMethodReflection instanceof PhpMethodReflection) { return null; } return $this->anonymousFunctionFactory->createFromPhpMethodReflection($phpMethodReflection, $arrayCallable->getCallerExpr()); diff --git a/rules/CodeQuality/Rector/Assign/CombinedAssignRector.php b/rules/CodeQuality/Rector/Assign/CombinedAssignRector.php index 95f7b3b5636..2039b0202c4 100644 --- a/rules/CodeQuality/Rector/Assign/CombinedAssignRector.php +++ b/rules/CodeQuality/Rector/Assign/CombinedAssignRector.php @@ -8,39 +8,39 @@ use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\BinaryOp; use Rector\Core\PhpParser\Node\AssignAndBinaryMap; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Assign\CombinedAssignRector\CombinedAssignRectorTest */ -final class CombinedAssignRector extends \Rector\Core\Rector\AbstractRector +final class CombinedAssignRector extends AbstractRector { /** * @readonly * @var \Rector\Core\PhpParser\Node\AssignAndBinaryMap */ private $assignAndBinaryMap; - public function __construct(\Rector\Core\PhpParser\Node\AssignAndBinaryMap $assignAndBinaryMap) + public function __construct(AssignAndBinaryMap $assignAndBinaryMap) { $this->assignAndBinaryMap = $assignAndBinaryMap; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Simplify $value = $value + 5; assignments to shorter ones', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$value = $value + 5;', '$value += 5;')]); + return new RuleDefinition('Simplify $value = $value + 5; assignments to shorter ones', [new CodeSample('$value = $value + 5;', '$value += 5;')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Assign::class]; + return [Assign::class]; } /** * @param Assign $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->expr instanceof \PhpParser\Node\Expr\BinaryOp) { + if (!$node->expr instanceof BinaryOp) { return null; } /** @var BinaryOp $binaryNode */ diff --git a/rules/CodeQuality/Rector/Assign/SplitListAssignToSeparateLineRector.php b/rules/CodeQuality/Rector/Assign/SplitListAssignToSeparateLineRector.php index c0b3f35f41a..891cb6da986 100644 --- a/rules/CodeQuality/Rector/Assign/SplitListAssignToSeparateLineRector.php +++ b/rules/CodeQuality/Rector/Assign/SplitListAssignToSeparateLineRector.php @@ -10,18 +10,18 @@ use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\List_; use PhpParser\Node\Stmt\Expression; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://mobile.twitter.com/ivanhoe011/status/1246376872931401728 * * @see \Rector\Tests\CodeQuality\Rector\Assign\SplitListAssignToSeparateLineRector\SplitListAssignToSeparateLineRectorTest */ -final class SplitListAssignToSeparateLineRector extends \Rector\Core\Rector\AbstractRector +final class SplitListAssignToSeparateLineRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Splits `[$a, $b] = [5, 10]` scalar assign to standalone lines', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Splits `[$a, $b] = [5, 10]` scalar assign to standalone lines', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run(): void @@ -47,15 +47,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Expression::class]; + return [Expression::class]; } /** * @param Expression $node * @return Expression[]|null */ - public function refactor(\PhpParser\Node $node) : ?array + public function refactor(Node $node) : ?array { - if (!$node->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$node->expr instanceof Assign) { return null; } $assign = $node->expr; @@ -68,13 +68,13 @@ CODE_SAMPLE $rightArray = $assign->expr; return $this->createStandaloneAssignExpressions($leftArray, $rightArray); } - private function shouldSkipAssign(\PhpParser\Node\Expr\Assign $assign) : bool + private function shouldSkipAssign(Assign $assign) : bool { - if (!$assign->var instanceof \PhpParser\Node\Expr\Array_ && !$assign->var instanceof \PhpParser\Node\Expr\List_) { + if (!$assign->var instanceof Array_ && !$assign->var instanceof List_) { return \true; } $assignExpr = $assign->expr; - if (!$assignExpr instanceof \PhpParser\Node\Expr\Array_) { + if (!$assignExpr instanceof Array_) { return \true; } if (\count($assign->var->items) !== \count($assignExpr->items)) { @@ -87,7 +87,7 @@ CODE_SAMPLE * @return Expression[] * @param \PhpParser\Node\Expr\Array_|\PhpParser\Node\Expr\List_ $expr */ - private function createStandaloneAssignExpressions($expr, \PhpParser\Node\Expr\Array_ $rightArray) : array + private function createStandaloneAssignExpressions($expr, Array_ $rightArray) : array { $standaloneAssignExpresssions = []; foreach ($expr->items as $key => $leftArrayItem) { @@ -95,18 +95,18 @@ CODE_SAMPLE continue; } $rightArrayItem = $rightArray->items[$key]; - if (!$rightArrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$rightArrayItem instanceof ArrayItem) { continue; } - $assign = new \PhpParser\Node\Expr\Assign($leftArrayItem->value, $rightArrayItem); - $standaloneAssignExpresssions[] = new \PhpParser\Node\Stmt\Expression($assign); + $assign = new Assign($leftArrayItem->value, $rightArrayItem); + $standaloneAssignExpresssions[] = new Expression($assign); } return $standaloneAssignExpresssions; } /** * @param \PhpParser\Node\Expr\Array_|\PhpParser\Node\Expr\List_ $expr */ - private function isValueSwap($expr, \PhpParser\Node\Expr\Array_ $secondArray) : bool + private function isValueSwap($expr, Array_ $secondArray) : bool { $firstArrayItemsHash = $this->getArrayItemsHash($expr); $secondArrayItemsHash = $this->getArrayItemsHash($secondArray); diff --git a/rules/CodeQuality/Rector/BooleanAnd/SimplifyEmptyArrayCheckRector.php b/rules/CodeQuality/Rector/BooleanAnd/SimplifyEmptyArrayCheckRector.php index 786d39bd9d1..511066aaf1c 100644 --- a/rules/CodeQuality/Rector/BooleanAnd/SimplifyEmptyArrayCheckRector.php +++ b/rules/CodeQuality/Rector/BooleanAnd/SimplifyEmptyArrayCheckRector.php @@ -12,56 +12,56 @@ use PhpParser\Node\Expr\FuncCall; use Rector\Core\NodeManipulator\BinaryOpManipulator; use Rector\Core\Rector\AbstractRector; use Rector\Php71\ValueObject\TwoNodeMatch; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/EZ2P4 * @changelog https://3v4l.org/egtb5 * @see \Rector\Tests\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector\SimplifyEmptyArrayCheckRectorTest */ -final class SimplifyEmptyArrayCheckRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyEmptyArrayCheckRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeManipulator\BinaryOpManipulator */ private $binaryOpManipulator; - public function __construct(\Rector\Core\NodeManipulator\BinaryOpManipulator $binaryOpManipulator) + public function __construct(BinaryOpManipulator $binaryOpManipulator) { $this->binaryOpManipulator = $binaryOpManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Simplify `is_array` and `empty` functions combination into a simple identical check for an empty array', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('is_array($values) && empty($values)', '$values === []')]); + return new RuleDefinition('Simplify `is_array` and `empty` functions combination into a simple identical check for an empty array', [new CodeSample('is_array($values) && empty($values)', '$values === []')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\BooleanAnd::class]; + return [BooleanAnd::class]; } /** * @param BooleanAnd $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $twoNodeMatch = $this->binaryOpManipulator->matchFirstAndSecondConditionNode( $node, // is_array(...) - function (\PhpParser\Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Expr\FuncCall) { + function (Node $node) : bool { + if (!$node instanceof FuncCall) { return \false; } return $this->isName($node, 'is_array'); }, - \PhpParser\Node\Expr\Empty_::class + Empty_::class ); - if (!$twoNodeMatch instanceof \Rector\Php71\ValueObject\TwoNodeMatch) { + if (!$twoNodeMatch instanceof TwoNodeMatch) { return null; } /** @var Empty_ $emptyOrNotIdenticalNode */ $emptyOrNotIdenticalNode = $twoNodeMatch->getSecondExpr(); - return new \PhpParser\Node\Expr\BinaryOp\Identical($emptyOrNotIdenticalNode->expr, new \PhpParser\Node\Expr\Array_()); + return new Identical($emptyOrNotIdenticalNode->expr, new Array_()); } } diff --git a/rules/CodeQuality/Rector/BooleanNot/ReplaceMultipleBooleanNotRector.php b/rules/CodeQuality/Rector/BooleanNot/ReplaceMultipleBooleanNotRector.php index eac235a4dbb..5de39246d0b 100644 --- a/rules/CodeQuality/Rector/BooleanNot/ReplaceMultipleBooleanNotRector.php +++ b/rules/CodeQuality/Rector/BooleanNot/ReplaceMultipleBooleanNotRector.php @@ -7,16 +7,16 @@ use PhpParser\Node; use PhpParser\Node\Expr\BooleanNot; use PhpParser\Node\Expr\Cast\Bool_; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\BooleanNot\ReplaceMultipleBooleanNotRector\ReplaceMultipleBooleanNotRectorTest */ -final class ReplaceMultipleBooleanNotRector extends \Rector\Core\Rector\AbstractRector +final class ReplaceMultipleBooleanNotRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace the Double not operator (!!) by type-casting to boolean', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace the Double not operator (!!) by type-casting to boolean', [new CodeSample(<<<'CODE_SAMPLE' $bool = !!$var; CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -29,16 +29,16 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BooleanNot::class]; + return [BooleanNot::class]; } /** * @param BooleanNot $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $depth = 0; $expr = $node->expr; - while ($expr instanceof \PhpParser\Node\Expr\BooleanNot) { + while ($expr instanceof BooleanNot) { ++$depth; $expr = $expr->expr; } @@ -49,6 +49,6 @@ CODE_SAMPLE $node->expr = $expr; return $node; } - return new \PhpParser\Node\Expr\Cast\Bool_($expr); + return new Bool_($expr); } } diff --git a/rules/CodeQuality/Rector/BooleanNot/SimplifyDeMorganBinaryRector.php b/rules/CodeQuality/Rector/BooleanNot/SimplifyDeMorganBinaryRector.php index d7296b5cc0f..05d7642e5a5 100644 --- a/rules/CodeQuality/Rector/BooleanNot/SimplifyDeMorganBinaryRector.php +++ b/rules/CodeQuality/Rector/BooleanNot/SimplifyDeMorganBinaryRector.php @@ -9,26 +9,26 @@ use PhpParser\Node\Expr\BinaryOp\BooleanOr; use PhpParser\Node\Expr\BooleanNot; use Rector\Core\NodeManipulator\BinaryOpManipulator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://stackoverflow.com/questions/20043664/de-morgans-law * @see \Rector\Tests\CodeQuality\Rector\BooleanNot\SimplifyDeMorganBinaryRector\SimplifyDeMorganBinaryRectorTest */ -final class SimplifyDeMorganBinaryRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyDeMorganBinaryRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeManipulator\BinaryOpManipulator */ private $binaryOpManipulator; - public function __construct(\Rector\Core\NodeManipulator\BinaryOpManipulator $binaryOpManipulator) + public function __construct(BinaryOpManipulator $binaryOpManipulator) { $this->binaryOpManipulator = $binaryOpManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Simplify negated conditions with de Morgan theorem', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Simplify negated conditions with de Morgan theorem', [new CodeSample(<<<'CODE_SAMPLE' $a = 5; $b = 10; $result = !($a > 20 || $b <= 50); @@ -45,14 +45,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BooleanNot::class]; + return [BooleanNot::class]; } /** * @param BooleanNot $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Expr\BinaryOp + public function refactor(Node $node) : ?BinaryOp { - if (!$node->expr instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { + if (!$node->expr instanceof BooleanOr) { return null; } return $this->binaryOpManipulator->inverseBinaryOp($node->expr); diff --git a/rules/CodeQuality/Rector/Catch_/ThrowWithPreviousExceptionRector.php b/rules/CodeQuality/Rector/Catch_/ThrowWithPreviousExceptionRector.php index bf39297ff12..ea6d3c89a2f 100644 --- a/rules/CodeQuality/Rector/Catch_/ThrowWithPreviousExceptionRector.php +++ b/rules/CodeQuality/Rector/Catch_/ThrowWithPreviousExceptionRector.php @@ -20,13 +20,13 @@ use PHPStan\Type\TypeWithClassName; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\MethodName; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/thecodingmachine/phpstan-strict-rules/blob/e3d746a61d38993ca2bc2e2fcda7012150de120c/src/Rules/Exceptions/ThrowMustBundlePreviousExceptionRule.php#L83 * @see \Rector\Tests\CodeQuality\Rector\Catch_\ThrowWithPreviousExceptionRector\ThrowWithPreviousExceptionRectorTest */ -final class ThrowWithPreviousExceptionRector extends \Rector\Core\Rector\AbstractRector +final class ThrowWithPreviousExceptionRector extends AbstractRector { /** * @var int @@ -37,13 +37,13 @@ final class ThrowWithPreviousExceptionRector extends \Rector\Core\Rector\Abstrac * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ReflectionProvider $reflectionProvider) { $this->reflectionProvider = $reflectionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('When throwing into a catch block, checks that the previous exception is passed to the new throw clause', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('When throwing into a catch block, checks that the previous exception is passed to the new throw clause', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -76,20 +76,20 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Catch_::class]; + return [Catch_::class]; } /** * @param Catch_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $caughtThrowableVariable = $node->var; - if (!$caughtThrowableVariable instanceof \PhpParser\Node\Expr\Variable) { + if (!$caughtThrowableVariable instanceof Variable) { return null; } $isChanged = \false; - $this->traverseNodesWithCallable($node->stmts, function (\PhpParser\Node $node) use($caughtThrowableVariable, &$isChanged) : ?int { - if (!$node instanceof \PhpParser\Node\Stmt\Throw_) { + $this->traverseNodesWithCallable($node->stmts, function (Node $node) use($caughtThrowableVariable, &$isChanged) : ?int { + if (!$node instanceof Throw_) { return null; } $isChanged = $this->refactorThrow($node, $caughtThrowableVariable); @@ -100,13 +100,13 @@ CODE_SAMPLE } return $node; } - private function refactorThrow(\PhpParser\Node\Stmt\Throw_ $throw, \PhpParser\Node\Expr\Variable $catchedThrowableVariable) : ?int + private function refactorThrow(Throw_ $throw, Variable $catchedThrowableVariable) : ?int { - if (!$throw->expr instanceof \PhpParser\Node\Expr\New_) { + if (!$throw->expr instanceof New_) { return null; } $new = $throw->expr; - if (!$new->class instanceof \PhpParser\Node\Name) { + if (!$new->class instanceof Name) { return null; } $exceptionArgumentPosition = $this->resolveExceptionArgumentPosition($new->class); @@ -119,26 +119,26 @@ CODE_SAMPLE } if (!isset($new->args[0])) { // get previous message - $new->args[0] = new \PhpParser\Node\Arg(new \PhpParser\Node\Expr\MethodCall($catchedThrowableVariable, 'getMessage')); + $new->args[0] = new Arg(new MethodCall($catchedThrowableVariable, 'getMessage')); } if (!isset($new->args[1])) { // get previous code - $new->args[1] = new \PhpParser\Node\Arg(new \PhpParser\Node\Expr\MethodCall($catchedThrowableVariable, 'getCode')); + $new->args[1] = new Arg(new MethodCall($catchedThrowableVariable, 'getCode')); } /** @var Arg $arg1 */ $arg1 = $new->args[1]; - if ($arg1->name instanceof \PhpParser\Node\Identifier && $arg1->name->toString() === 'previous') { - $new->args[1] = new \PhpParser\Node\Arg(new \PhpParser\Node\Expr\MethodCall($catchedThrowableVariable, 'getCode')); + if ($arg1->name instanceof Identifier && $arg1->name->toString() === 'previous') { + $new->args[1] = new Arg(new MethodCall($catchedThrowableVariable, 'getCode')); $new->args[$exceptionArgumentPosition] = $arg1; } else { - $new->args[$exceptionArgumentPosition] = new \PhpParser\Node\Arg($catchedThrowableVariable); + $new->args[$exceptionArgumentPosition] = new Arg($catchedThrowableVariable); } // null the node, to fix broken format preserving printers, see https://github.com/rectorphp/rector/issues/5576 - $new->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $new->setAttribute(AttributeKey::ORIGINAL_NODE, null); // nothing more to add - return \PhpParser\NodeTraverser::DONT_TRAVERSE_CHILDREN; + return NodeTraverser::DONT_TRAVERSE_CHILDREN; } - private function resolveExceptionArgumentPosition(\PhpParser\Node\Name $exceptionName) : ?int + private function resolveExceptionArgumentPosition(Name $exceptionName) : ?int { $className = $this->getName($exceptionName); // is native exception? @@ -149,18 +149,18 @@ CODE_SAMPLE return self::DEFAULT_EXCEPTION_ARGUMENT_POSITION; } $classReflection = $this->reflectionProvider->getClass($className); - $construct = $classReflection->hasMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); + $construct = $classReflection->hasMethod(MethodName::CONSTRUCT); if (!$construct) { return self::DEFAULT_EXCEPTION_ARGUMENT_POSITION; } $methodReflection = $classReflection->getConstructor(); - $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); + $parametersAcceptor = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); foreach ($parametersAcceptor->getParameters() as $position => $parameterReflection) { $parameterType = $parameterReflection->getType(); - if (!$parameterType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$parameterType instanceof TypeWithClassName) { continue; } - $objectType = new \PHPStan\Type\ObjectType('Throwable'); + $objectType = new ObjectType('Throwable'); if ($objectType->isSuperTypeOf($parameterType)->no()) { continue; } diff --git a/rules/CodeQuality/Rector/ClassMethod/DateTimeToDateTimeInterfaceRector.php b/rules/CodeQuality/Rector/ClassMethod/DateTimeToDateTimeInterfaceRector.php index 4e58db2764a..4d2c5d37e10 100644 --- a/rules/CodeQuality/Rector/ClassMethod/DateTimeToDateTimeInterfaceRector.php +++ b/rules/CodeQuality/Rector/ClassMethod/DateTimeToDateTimeInterfaceRector.php @@ -24,17 +24,17 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\MethodName; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\ClassMethod\DateTimeToDateTimeInterfaceRector\DateTimeToDateTimeInterfaceRectorTest */ -final class DateTimeToDateTimeInterfaceRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class DateTimeToDateTimeInterfaceRector extends AbstractRector implements MinPhpVersionInterface { /** * @var string[] */ - private const METHODS_RETURNING_CLASS_INSTANCE_MAP = ['add', 'modify', \Rector\Core\ValueObject\MethodName::SET_STATE, 'setDate', 'setISODate', 'setTime', 'setTimestamp', 'setTimezone', 'sub']; + private const METHODS_RETURNING_CLASS_INSTANCE_MAP = ['add', 'modify', MethodName::SET_STATE, 'setDate', 'setISODate', 'setTime', 'setTimestamp', 'setTimezone', 'sub']; /** * @var string */ @@ -64,7 +64,7 @@ final class DateTimeToDateTimeInterfaceRector extends \Rector\Core\Rector\Abstra * @var \Rector\Core\NodeAnalyzer\CallAnalyzer */ private $callAnalyzer; - public function __construct(\Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\Core\NodeAnalyzer\ParamAnalyzer $paramAnalyzer, \Rector\CodeQuality\NodeManipulator\ClassMethodReturnTypeManipulator $classMethodReturnTypeManipulator, \Rector\CodeQuality\NodeManipulator\ClassMethodParameterTypeManipulator $classMethodParameterTypeManipulator, \Rector\Core\NodeAnalyzer\CallAnalyzer $callAnalyzer) + public function __construct(PhpDocTypeChanger $phpDocTypeChanger, ParamAnalyzer $paramAnalyzer, ClassMethodReturnTypeManipulator $classMethodReturnTypeManipulator, ClassMethodParameterTypeManipulator $classMethodParameterTypeManipulator, CallAnalyzer $callAnalyzer) { $this->phpDocTypeChanger = $phpDocTypeChanger; $this->paramAnalyzer = $paramAnalyzer; @@ -72,9 +72,9 @@ final class DateTimeToDateTimeInterfaceRector extends \Rector\Core\Rector\Abstra $this->classMethodParameterTypeManipulator = $classMethodParameterTypeManipulator; $this->callAnalyzer = $callAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes DateTime type-hint to DateTimeInterface', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes DateTime type-hint to DateTimeInterface', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function methodWithDateTime(\DateTime $dateTime) { @@ -100,92 +100,92 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Property::class]; + return [ClassMethod::class, Property::class]; } /** * @param ClassMethod|Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Stmt\ClassMethod) { + if ($node instanceof ClassMethod) { return $this->refactorClassMethod($node); } return $this->refactorProperty($node); } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::DATE_TIME_INTERFACE; + return PhpVersionFeature::DATE_TIME_INTERFACE; } - private function refactorProperty(\PhpParser\Node\Stmt\Property $property) : ?\PhpParser\Node + private function refactorProperty(Property $property) : ?Node { $type = $property->type; if ($type === null) { return null; } $isNullable = \false; - if ($type instanceof \PhpParser\Node\NullableType) { + if ($type instanceof NullableType) { $isNullable = \true; $type = $type->type; } - if (!$this->isObjectType($type, new \PHPStan\Type\ObjectType(self::DATE_TIME))) { + if (!$this->isObjectType($type, new ObjectType(self::DATE_TIME))) { return null; } $types = $this->determinePhpDocTypes($property->type); $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); - $this->phpDocTypeChanger->changeVarType($phpDocInfo, new \PHPStan\Type\UnionType($types)); - $property->type = new \PhpParser\Node\Name\FullyQualified('DateTimeInterface'); + $this->phpDocTypeChanger->changeVarType($phpDocInfo, new UnionType($types)); + $property->type = new FullyQualified('DateTimeInterface'); if ($isNullable) { - $property->type = new \PhpParser\Node\NullableType($property->type); + $property->type = new NullableType($property->type); } return $property; } /** * @return Type[] */ - private function determinePhpDocTypes(?\PhpParser\Node $node) : array + private function determinePhpDocTypes(?Node $node) : array { - $types = [new \PHPStan\Type\ObjectType(self::DATE_TIME), new \PHPStan\Type\ObjectType('DateTimeImmutable')]; + $types = [new ObjectType(self::DATE_TIME), new ObjectType('DateTimeImmutable')]; if ($this->canHaveNullType($node)) { - $types[] = new \PHPStan\Type\NullType(); + $types[] = new NullType(); } return $types; } - private function canHaveNullType(?\PhpParser\Node $node) : bool + private function canHaveNullType(?Node $node) : bool { - if ($node instanceof \PhpParser\Node\Param) { + if ($node instanceof Param) { return $this->paramAnalyzer->isNullable($node); } - return $node instanceof \PhpParser\Node\NullableType; + return $node instanceof NullableType; } - private function refactorClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Stmt\ClassMethod + private function refactorClassMethod(ClassMethod $classMethod) : ?ClassMethod { if ($this->shouldSkipExactlyReturnDateTime($classMethod)) { return null; } - $fromObjectType = new \PHPStan\Type\ObjectType(self::DATE_TIME); - $fullyQualified = new \PhpParser\Node\Name\FullyQualified('DateTimeInterface'); - $unionType = new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType(self::DATE_TIME), new \PHPStan\Type\ObjectType('DateTimeImmutable')]); + $fromObjectType = new ObjectType(self::DATE_TIME); + $fullyQualified = new FullyQualified('DateTimeInterface'); + $unionType = new UnionType([new ObjectType(self::DATE_TIME), new ObjectType('DateTimeImmutable')]); $this->classMethodParameterTypeManipulator->refactorFunctionParameters($classMethod, $fromObjectType, $fullyQualified, $unionType, self::METHODS_RETURNING_CLASS_INSTANCE_MAP); - if (!$classMethod->returnType instanceof \PhpParser\Node) { + if (!$classMethod->returnType instanceof Node) { return null; } return $this->classMethodReturnTypeManipulator->refactorFunctionReturnType($classMethod, $fromObjectType, $fullyQualified, $unionType); } - private function shouldSkipExactlyReturnDateTime(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkipExactlyReturnDateTime(ClassMethod $classMethod) : bool { - $return = $this->betterNodeFinder->findFirstInFunctionLikeScoped($classMethod, function (\PhpParser\Node $node) : bool { - return $node instanceof \PhpParser\Node\Stmt\Return_; + $return = $this->betterNodeFinder->findFirstInFunctionLikeScoped($classMethod, function (Node $node) : bool { + return $node instanceof Return_; }); - if (!$return instanceof \PhpParser\Node\Stmt\Return_) { + if (!$return instanceof Return_) { return \false; } - if (!$return->expr instanceof \PhpParser\Node\Expr) { + if (!$return->expr instanceof Expr) { return \false; } if (!$this->callAnalyzer->isNewInstance($return->expr)) { return \false; } $type = $this->nodeTypeResolver->getType($return->expr); - return $type instanceof \PHPStan\Type\ObjectType && $type->getClassName() === self::DATE_TIME; + return $type instanceof ObjectType && $type->getClassName() === self::DATE_TIME; } } diff --git a/rules/CodeQuality/Rector/ClassMethod/InlineArrayReturnAssignRector.php b/rules/CodeQuality/Rector/ClassMethod/InlineArrayReturnAssignRector.php index cb9c8ba4bd6..ee2591c2595 100644 --- a/rules/CodeQuality/Rector/ClassMethod/InlineArrayReturnAssignRector.php +++ b/rules/CodeQuality/Rector/ClassMethod/InlineArrayReturnAssignRector.php @@ -16,25 +16,25 @@ use Rector\CodeQuality\ValueObject\KeyAndExpr; use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\ClassMethod\InlineArrayReturnAssignRector\InlineArrayReturnAssignRectorTest */ -final class InlineArrayReturnAssignRector extends \Rector\Core\Rector\AbstractRector +final class InlineArrayReturnAssignRector extends AbstractRector { /** * @readonly * @var \Rector\CodeQuality\NodeAnalyzer\VariableDimFetchAssignResolver */ private $variableDimFetchAssignResolver; - public function __construct(\Rector\CodeQuality\NodeAnalyzer\VariableDimFetchAssignResolver $variableDimFetchAssignResolver) + public function __construct(VariableDimFetchAssignResolver $variableDimFetchAssignResolver) { $this->variableDimFetchAssignResolver = $variableDimFetchAssignResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Inline just in time array dim fetch assigns to direct return', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Inline just in time array dim fetch assigns to direct return', [new CodeSample(<<<'CODE_SAMPLE' function getPerson() { $person = []; @@ -60,12 +60,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface::class]; + return [StmtsAwareInterface::class]; } /** * @param StmtsAwareInterface $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $stmts = $node->stmts; if ($stmts === null) { @@ -76,11 +76,11 @@ CODE_SAMPLE } $firstStmt = \array_shift($stmts); $variable = $this->matchVariableAssignOfEmptyArray($firstStmt); - if (!$variable instanceof \PhpParser\Node\Expr\Variable) { + if (!$variable instanceof Variable) { return null; } $lastStmt = \array_pop($stmts); - if (!$lastStmt instanceof \PhpParser\Node\Stmt) { + if (!$lastStmt instanceof Stmt) { return null; } if (!$this->isReturnOfVariable($lastStmt, $variable)) { @@ -91,32 +91,32 @@ CODE_SAMPLE return null; } $array = $this->createArray($keysAndExprs); - $node->stmts = [new \PhpParser\Node\Stmt\Return_($array)]; + $node->stmts = [new Return_($array)]; return $node; } - private function matchVariableAssignOfEmptyArray(\PhpParser\Node\Stmt $stmt) : ?\PhpParser\Node\Expr\Variable + private function matchVariableAssignOfEmptyArray(Stmt $stmt) : ?Variable { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { return null; } - if (!$stmt->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$stmt->expr instanceof Assign) { return null; } $assign = $stmt->expr; if (!$this->valueResolver->isValue($assign->expr, [])) { return null; } - if (!$assign->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$assign->var instanceof Variable) { return null; } return $assign->var; } - private function isReturnOfVariable(\PhpParser\Node\Stmt $stmt, \PhpParser\Node\Expr\Variable $variable) : bool + private function isReturnOfVariable(Stmt $stmt, Variable $variable) : bool { - if (!$stmt instanceof \PhpParser\Node\Stmt\Return_) { + if (!$stmt instanceof Return_) { return \false; } - if (!$stmt->expr instanceof \PhpParser\Node\Expr\Variable) { + if (!$stmt->expr instanceof Variable) { return \false; } return $this->nodeComparator->areNodesEqual($stmt->expr, $variable); @@ -124,14 +124,14 @@ CODE_SAMPLE /** * @param KeyAndExpr[] $keysAndExprs */ - private function createArray(array $keysAndExprs) : \PhpParser\Node\Expr\Array_ + private function createArray(array $keysAndExprs) : Array_ { $arrayItems = []; foreach ($keysAndExprs as $keyAndExpr) { - $arrayItem = new \PhpParser\Node\Expr\ArrayItem($keyAndExpr->getExpr(), $keyAndExpr->getKeyExpr()); - $arrayItem->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $keyAndExpr->getComments()); + $arrayItem = new ArrayItem($keyAndExpr->getExpr(), $keyAndExpr->getKeyExpr()); + $arrayItem->setAttribute(AttributeKey::COMMENTS, $keyAndExpr->getComments()); $arrayItems[] = $arrayItem; } - return new \PhpParser\Node\Expr\Array_($arrayItems); + return new Array_($arrayItems); } } diff --git a/rules/CodeQuality/Rector/ClassMethod/NarrowUnionTypeDocRector.php b/rules/CodeQuality/Rector/ClassMethod/NarrowUnionTypeDocRector.php index ca8a6c8600f..270be5b5560 100644 --- a/rules/CodeQuality/Rector/ClassMethod/NarrowUnionTypeDocRector.php +++ b/rules/CodeQuality/Rector/ClassMethod/NarrowUnionTypeDocRector.php @@ -11,12 +11,12 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\Core\Rector\AbstractRector; use Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\ClassMethod\NarrowUnionTypeDocRector\NarrowUnionTypeDocRectorTest */ -final class NarrowUnionTypeDocRector extends \Rector\Core\Rector\AbstractRector +final class NarrowUnionTypeDocRector extends AbstractRector { /** * @var bool @@ -27,13 +27,13 @@ final class NarrowUnionTypeDocRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer */ private $unionTypeAnalyzer; - public function __construct(\Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer $unionTypeAnalyzer) + public function __construct(UnionTypeAnalyzer $unionTypeAnalyzer) { $this->unionTypeAnalyzer = $unionTypeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes docblock by narrowing type', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes docblock by narrowing type', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { /** * @param object|DateTime $message @@ -60,12 +60,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $params = $node->getParams(); @@ -74,7 +74,7 @@ CODE_SAMPLE /** @var string $paramName */ $paramName = $this->getName($param->var); $paramType = $phpDocInfo->getParamType($paramName); - if (!$paramType instanceof \PHPStan\Type\UnionType) { + if (!$paramType instanceof UnionType) { continue; } if ($this->unionTypeAnalyzer->isScalar($paramType)) { @@ -92,7 +92,7 @@ CODE_SAMPLE } return null; } - private function changeDocObjectWithoutClassType(\PHPStan\Type\UnionType $unionType, int $key, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void + private function changeDocObjectWithoutClassType(UnionType $unionType, int $key, PhpDocInfo $phpDocInfo) : void { if (!$this->unionTypeAnalyzer->hasObjectWithoutClassTypeWithOnlyFullyQualifiedObjectType($unionType)) { return; @@ -100,21 +100,21 @@ CODE_SAMPLE $types = $unionType->getTypes(); $resultType = ''; foreach ($types as $type) { - if ($type instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) { + if ($type instanceof FullyQualifiedObjectType) { $resultType .= $type->getClassName() . '|'; } } $resultType = \rtrim($resultType, '|'); $paramTagValueNodes = $phpDocInfo->getParamTagValueNodes(); if (isset($paramTagValueNodes[$key])) { - $paramTagValueNodes[$key]->type = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($resultType); + $paramTagValueNodes[$key]->type = new IdentifierTypeNode($resultType); } } - private function changeDocObjectScalar(int $key, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void + private function changeDocObjectScalar(int $key, PhpDocInfo $phpDocInfo) : void { $paramTagValueNodes = $phpDocInfo->getParamTagValueNodes(); if (isset($paramTagValueNodes[$key])) { - $paramTagValueNodes[$key]->type = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('scalar'); + $paramTagValueNodes[$key]->type = new IdentifierTypeNode('scalar'); } } } diff --git a/rules/CodeQuality/Rector/ClassMethod/OptionalParametersAfterRequiredRector.php b/rules/CodeQuality/Rector/ClassMethod/OptionalParametersAfterRequiredRector.php index c58494b67e6..d459c572a71 100644 --- a/rules/CodeQuality/Rector/ClassMethod/OptionalParametersAfterRequiredRector.php +++ b/rules/CodeQuality/Rector/ClassMethod/OptionalParametersAfterRequiredRector.php @@ -14,14 +14,14 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; use Rector\Php80\NodeResolver\ArgumentSorter; use Rector\Php80\NodeResolver\RequireOptionalParamResolver; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://php.watch/versions/8.0#deprecate-required-param-after-optional * * @see \Rector\Tests\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector\OptionalParametersAfterRequiredRectorTest */ -final class OptionalParametersAfterRequiredRector extends \Rector\Core\Rector\AbstractRector +final class OptionalParametersAfterRequiredRector extends AbstractRector { /** * @readonly @@ -43,16 +43,16 @@ final class OptionalParametersAfterRequiredRector extends \Rector\Core\Rector\Ab * @var \Rector\CodingStyle\Reflection\VendorLocationDetector */ private $vendorLocationDetector; - public function __construct(\Rector\Php80\NodeResolver\RequireOptionalParamResolver $requireOptionalParamResolver, \Rector\Php80\NodeResolver\ArgumentSorter $argumentSorter, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\CodingStyle\Reflection\VendorLocationDetector $vendorLocationDetector) + public function __construct(RequireOptionalParamResolver $requireOptionalParamResolver, ArgumentSorter $argumentSorter, ReflectionResolver $reflectionResolver, VendorLocationDetector $vendorLocationDetector) { $this->requireOptionalParamResolver = $requireOptionalParamResolver; $this->argumentSorter = $argumentSorter; $this->reflectionResolver = $reflectionResolver; $this->vendorLocationDetector = $vendorLocationDetector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Move required parameters after optional ones', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Move required parameters after optional ones', [new CodeSample(<<<'CODE_SAMPLE' class SomeObject { public function run($optional = 1, $required) @@ -75,28 +75,28 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Expr\New_::class, \PhpParser\Node\Expr\MethodCall::class]; + return [ClassMethod::class, New_::class, MethodCall::class]; } /** * @param ClassMethod|New_|MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Stmt\ClassMethod) { + if ($node instanceof ClassMethod) { return $this->refactorClassMethod($node); } - if ($node instanceof \PhpParser\Node\Expr\New_) { + if ($node instanceof New_) { return $this->refactorNew($node); } return $this->refactorMethodCall($node); } - private function refactorClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Stmt\ClassMethod + private function refactorClassMethod(ClassMethod $classMethod) : ?ClassMethod { if ($classMethod->params === []) { return null; } $classMethodReflection = $this->reflectionResolver->resolveMethodReflectionFromClassMethod($classMethod); - if (!$classMethodReflection instanceof \PHPStan\Reflection\MethodReflection) { + if (!$classMethodReflection instanceof MethodReflection) { return null; } $expectedArgOrParamOrder = $this->resolveExpectedArgParamOrderIfDifferent($classMethodReflection); @@ -107,13 +107,13 @@ CODE_SAMPLE $classMethod->params = $newParams; return $classMethod; } - private function refactorNew(\PhpParser\Node\Expr\New_ $new) : ?\PhpParser\Node\Expr\New_ + private function refactorNew(New_ $new) : ?New_ { if ($new->args === []) { return null; } $methodReflection = $this->reflectionResolver->resolveMethodReflectionFromNew($new); - if (!$methodReflection instanceof \PHPStan\Reflection\MethodReflection) { + if (!$methodReflection instanceof MethodReflection) { return null; } $expectedArgOrParamOrder = $this->resolveExpectedArgParamOrderIfDifferent($methodReflection); @@ -123,10 +123,10 @@ CODE_SAMPLE $new->args = $this->argumentSorter->sortArgsByExpectedParamOrder($new->getArgs(), $expectedArgOrParamOrder); return $new; } - private function refactorMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node\Expr\MethodCall + private function refactorMethodCall(MethodCall $methodCall) : ?MethodCall { $methodReflection = $this->reflectionResolver->resolveFunctionLikeReflectionFromCall($methodCall); - if (!$methodReflection instanceof \PHPStan\Reflection\MethodReflection) { + if (!$methodReflection instanceof MethodReflection) { return null; } $expectedArgOrParamOrder = $this->resolveExpectedArgParamOrderIfDifferent($methodReflection); @@ -143,12 +143,12 @@ CODE_SAMPLE /** * @return int[]|null */ - private function resolveExpectedArgParamOrderIfDifferent(\PHPStan\Reflection\MethodReflection $methodReflection) : ?array + private function resolveExpectedArgParamOrderIfDifferent(MethodReflection $methodReflection) : ?array { if ($this->vendorLocationDetector->detectMethodReflection($methodReflection)) { return null; } - $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); + $parametersAcceptor = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); $expectedParameterReflections = $this->requireOptionalParamResolver->resolveFromReflection($methodReflection); if ($expectedParameterReflections === $parametersAcceptor->getParameters()) { return null; diff --git a/rules/CodeQuality/Rector/Class_/CompleteDynamicPropertiesRector.php b/rules/CodeQuality/Rector/Class_/CompleteDynamicPropertiesRector.php index 16da0f64741..4173332b0d5 100644 --- a/rules/CodeQuality/Rector/Class_/CompleteDynamicPropertiesRector.php +++ b/rules/CodeQuality/Rector/Class_/CompleteDynamicPropertiesRector.php @@ -16,8 +16,8 @@ use Rector\Core\NodeAnalyzer\ClassAnalyzer; use Rector\Core\NodeAnalyzer\PropertyPresenceChecker; use Rector\Core\Rector\AbstractRector; use Rector\PostRector\ValueObject\PropertyMetadata; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/GL6II * @changelog https://3v4l.org/eTrhZ @@ -25,7 +25,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @see \Rector\Tests\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector\CompleteDynamicPropertiesRectorTest */ -final class CompleteDynamicPropertiesRector extends \Rector\Core\Rector\AbstractRector +final class CompleteDynamicPropertiesRector extends AbstractRector { /** * @readonly @@ -57,7 +57,7 @@ final class CompleteDynamicPropertiesRector extends \Rector\Core\Rector\Abstract * @var \Rector\Core\NodeAnalyzer\PropertyPresenceChecker */ private $propertyPresenceChecker; - public function __construct(\Rector\CodeQuality\NodeFactory\MissingPropertiesFactory $missingPropertiesFactory, \Rector\CodeQuality\NodeAnalyzer\LocalPropertyAnalyzer $localPropertyAnalyzer, \Rector\CodeQuality\NodeAnalyzer\ClassLikeAnalyzer $classLikeAnalyzer, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer, \Rector\Core\NodeAnalyzer\PropertyPresenceChecker $propertyPresenceChecker) + public function __construct(MissingPropertiesFactory $missingPropertiesFactory, LocalPropertyAnalyzer $localPropertyAnalyzer, ClassLikeAnalyzer $classLikeAnalyzer, ReflectionProvider $reflectionProvider, ClassAnalyzer $classAnalyzer, PropertyPresenceChecker $propertyPresenceChecker) { $this->missingPropertiesFactory = $missingPropertiesFactory; $this->localPropertyAnalyzer = $localPropertyAnalyzer; @@ -66,9 +66,9 @@ final class CompleteDynamicPropertiesRector extends \Rector\Core\Rector\Abstract $this->classAnalyzer = $classAnalyzer; $this->propertyPresenceChecker = $propertyPresenceChecker; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add missing dynamic properties', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add missing dynamic properties', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function set() @@ -98,12 +98,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkipClass($node)) { return null; @@ -130,7 +130,7 @@ CODE_SAMPLE $node->stmts = \array_merge($newProperties, $node->stmts); return $node; } - private function shouldSkipClass(\PhpParser\Node\Stmt\Class_ $class) : bool + private function shouldSkipClass(Class_ $class) : bool { if ($this->classAnalyzer->isAnonymousClass($class)) { return \true; @@ -150,7 +150,7 @@ CODE_SAMPLE * @param array $fetchedLocalPropertyNameToTypes * @return string[] */ - private function resolvePropertiesToComplete(\PhpParser\Node\Stmt\Class_ $class, array $fetchedLocalPropertyNameToTypes) : array + private function resolvePropertiesToComplete(Class_ $class, array $fetchedLocalPropertyNameToTypes) : array { $propertyNames = $this->classLikeAnalyzer->resolvePropertyNames($class); /** @var string[] $fetchedLocalPropertyNames */ @@ -161,7 +161,7 @@ CODE_SAMPLE * @param string[] $propertiesToComplete * @return string[] */ - private function filterOutExistingProperties(\PhpParser\Node\Stmt\Class_ $class, \PHPStan\Reflection\ClassReflection $classReflection, array $propertiesToComplete) : array + private function filterOutExistingProperties(Class_ $class, ClassReflection $classReflection, array $propertiesToComplete) : array { $missingPropertyNames = []; $className = $classReflection->getName(); @@ -170,7 +170,7 @@ CODE_SAMPLE if ($classReflection->hasProperty($propertyToComplete)) { continue; } - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($propertyToComplete, new \PHPStan\Type\ObjectType($className), \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $propertyMetadata = new PropertyMetadata($propertyToComplete, new ObjectType($className), Class_::MODIFIER_PRIVATE); $hasClassContextProperty = $this->propertyPresenceChecker->hasClassContextProperty($class, $propertyMetadata); if ($hasClassContextProperty) { continue; diff --git a/rules/CodeQuality/Rector/Class_/InlineConstructorDefaultToPropertyRector.php b/rules/CodeQuality/Rector/Class_/InlineConstructorDefaultToPropertyRector.php index 6bb0e938555..26c37756b10 100644 --- a/rules/CodeQuality/Rector/Class_/InlineConstructorDefaultToPropertyRector.php +++ b/rules/CodeQuality/Rector/Class_/InlineConstructorDefaultToPropertyRector.php @@ -10,25 +10,25 @@ use PhpParser\Node\Stmt\Property; use Rector\CodeQuality\NodeAnalyzer\ConstructorPropertyDefaultExprResolver; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\MethodName; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector\InlineConstructorDefaultToPropertyRectorTest */ -final class InlineConstructorDefaultToPropertyRector extends \Rector\Core\Rector\AbstractRector +final class InlineConstructorDefaultToPropertyRector extends AbstractRector { /** * @readonly * @var \Rector\CodeQuality\NodeAnalyzer\ConstructorPropertyDefaultExprResolver */ private $constructorPropertyDefaultExprResolver; - public function __construct(\Rector\CodeQuality\NodeAnalyzer\ConstructorPropertyDefaultExprResolver $constructorPropertyDefaultExprResolver) + public function __construct(ConstructorPropertyDefaultExprResolver $constructorPropertyDefaultExprResolver) { $this->constructorPropertyDefaultExprResolver = $constructorPropertyDefaultExprResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Move property default from constructor to property default', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Move property default from constructor to property default', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { private $name; @@ -52,15 +52,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $constructClassMethod = $node->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$constructClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $constructClassMethod = $node->getMethod(MethodName::CONSTRUCT); + if (!$constructClassMethod instanceof ClassMethod) { return null; } // resolve property defaults @@ -71,7 +71,7 @@ CODE_SAMPLE $hasChanged = \false; foreach ($defaultPropertyExprAssigns as $defaultPropertyExprAssign) { $property = $node->getProperty($defaultPropertyExprAssign->getPropertyName()); - if (!$property instanceof \PhpParser\Node\Stmt\Property) { + if (!$property instanceof Property) { continue; } $propertyProperty = $property->props[0]; diff --git a/rules/CodeQuality/Rector/Concat/JoinStringConcatRector.php b/rules/CodeQuality/Rector/Concat/JoinStringConcatRector.php index 42e23d6e10d..f4051db8f97 100644 --- a/rules/CodeQuality/Rector/Concat/JoinStringConcatRector.php +++ b/rules/CodeQuality/Rector/Concat/JoinStringConcatRector.php @@ -9,12 +9,12 @@ use PhpParser\Node\Expr\BinaryOp\Concat; use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Concat\JoinStringConcatRector\JoinStringConcatRectorTest */ -final class JoinStringConcatRector extends \Rector\Core\Rector\AbstractRector +final class JoinStringConcatRector extends AbstractRector { /** * @var int @@ -24,9 +24,9 @@ final class JoinStringConcatRector extends \Rector\Core\Rector\AbstractRector * @var bool */ private $nodeReplacementIsRestricted = \false; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Joins concat of 2 strings, unless the length is too long', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Joins concat of 2 strings, unless the length is too long', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -51,19 +51,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\Concat::class]; + return [Concat::class]; } /** * @param Concat $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $this->nodeReplacementIsRestricted = \false; if (!$this->isTopMostConcatNode($node)) { return null; } $joinedNode = $this->joinConcatIfStrings($node); - if (!$joinedNode instanceof \PhpParser\Node\Scalar\String_) { + if (!$joinedNode instanceof String_) { return null; } if ($this->nodeReplacementIsRestricted) { @@ -71,27 +71,27 @@ CODE_SAMPLE } return $joinedNode; } - private function isTopMostConcatNode(\PhpParser\Node\Expr\BinaryOp\Concat $concat) : bool + private function isTopMostConcatNode(Concat $concat) : bool { - $parent = $concat->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - return !$parent instanceof \PhpParser\Node\Expr\BinaryOp\Concat; + $parent = $concat->getAttribute(AttributeKey::PARENT_NODE); + return !$parent instanceof Concat; } /** * @return \PhpParser\Node\Expr\BinaryOp\Concat|\PhpParser\Node\Scalar\String_ */ - private function joinConcatIfStrings(\PhpParser\Node\Expr\BinaryOp\Concat $node) + private function joinConcatIfStrings(Concat $node) { $concat = clone $node; - if ($concat->left instanceof \PhpParser\Node\Expr\BinaryOp\Concat) { + if ($concat->left instanceof Concat) { $concat->left = $this->joinConcatIfStrings($concat->left); } - if ($concat->right instanceof \PhpParser\Node\Expr\BinaryOp\Concat) { + if ($concat->right instanceof Concat) { $concat->right = $this->joinConcatIfStrings($concat->right); } - if (!$concat->left instanceof \PhpParser\Node\Scalar\String_) { + if (!$concat->left instanceof String_) { return $node; } - if (!$concat->right instanceof \PhpParser\Node\Scalar\String_) { + if (!$concat->right instanceof String_) { return $node; } $leftValue = $concat->left->value; @@ -104,8 +104,8 @@ CODE_SAMPLE $this->nodeReplacementIsRestricted = \true; return $node; } - $resultString = new \PhpParser\Node\Scalar\String_($leftValue . $rightValue); - if (\RectorPrefix20220607\Nette\Utils\Strings::length($resultString->value) >= self::LINE_BREAK_POINT) { + $resultString = new String_($leftValue . $rightValue); + if (Strings::length($resultString->value) >= self::LINE_BREAK_POINT) { $this->nodeReplacementIsRestricted = \true; return $node; } diff --git a/rules/CodeQuality/Rector/Do_/DoWhileBreakFalseToIfElseRector.php b/rules/CodeQuality/Rector/Do_/DoWhileBreakFalseToIfElseRector.php index c4beba3995e..19f41d28ce6 100644 --- a/rules/CodeQuality/Rector/Do_/DoWhileBreakFalseToIfElseRector.php +++ b/rules/CodeQuality/Rector/Do_/DoWhileBreakFalseToIfElseRector.php @@ -11,16 +11,16 @@ use PhpParser\Node\Stmt\Else_; use PhpParser\Node\Stmt\If_; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Do_\DoWhileBreakFalseToIfElseRector\DoWhileBreakFalseToIfElseRectorTest */ -final class DoWhileBreakFalseToIfElseRector extends \Rector\Core\Rector\AbstractRector +final class DoWhileBreakFalseToIfElseRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace do (...} while (false); with more readable if/else conditions', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace do (...} while (false); with more readable if/else conditions', [new CodeSample(<<<'CODE_SAMPLE' do { if (mt_rand(0, 1)) { $value = 5; @@ -44,13 +44,13 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Do_::class]; + return [Do_::class]; } /** * @param Do_ $node * @return mixed[]|null */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { if (!$this->valueResolver->isFalse($node->cond)) { return null; @@ -64,28 +64,28 @@ CODE_SAMPLE */ private function resolveNewStmts(array $currentStmts) : array { - $foundBreak = $this->betterNodeFinder->findFirstInstanceOf($currentStmts, \PhpParser\Node\Stmt\Break_::class); - if (!$foundBreak instanceof \PhpParser\Node\Stmt\Break_) { + $foundBreak = $this->betterNodeFinder->findFirstInstanceOf($currentStmts, Break_::class); + if (!$foundBreak instanceof Break_) { return $currentStmts; } $newStmts = []; foreach ($currentStmts as $key => $currentStmt) { - $foundBreak = $this->betterNodeFinder->findFirstInstanceOf($currentStmt, \PhpParser\Node\Stmt\Break_::class); - if (!$foundBreak instanceof \PhpParser\Node\Stmt\Break_) { + $foundBreak = $this->betterNodeFinder->findFirstInstanceOf($currentStmt, Break_::class); + if (!$foundBreak instanceof Break_) { continue; } $this->removeNode($foundBreak); // collect rest of nodes $restOfStmts = \array_slice($currentStmts, $key + 1, \count($currentStmts)); - $currentIf = $currentStmt instanceof \PhpParser\Node\Stmt\If_ ? $currentStmt : $this->betterNodeFinder->findInstanceOf($currentStmt, \PhpParser\Node\Stmt\If_::class); - if (!$currentIf instanceof \PhpParser\Node\Stmt\If_) { + $currentIf = $currentStmt instanceof If_ ? $currentStmt : $this->betterNodeFinder->findInstanceOf($currentStmt, If_::class); + if (!$currentIf instanceof If_) { continue; } // reprint new tokens - $currentIf->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $currentIf->setAttribute(AttributeKey::ORIGINAL_NODE, null); if ($restOfStmts !== []) { $restOfStmts = $this->resolveNewStmts($restOfStmts); - $currentIf->else = new \PhpParser\Node\Stmt\Else_($restOfStmts); + $currentIf->else = new Else_($restOfStmts); } $newStmts[] = $currentStmt; break; diff --git a/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php b/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php index 97e2f3e95b1..467c39d007a 100644 --- a/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php +++ b/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php @@ -13,25 +13,25 @@ use PHPStan\Type\MixedType; use PHPStan\Type\ObjectType; use Rector\Core\NodeAnalyzer\ExprAnalyzer; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Equal\UseIdenticalOverEqualWithSameTypeRector\UseIdenticalOverEqualWithSameTypeRectorTest */ -final class UseIdenticalOverEqualWithSameTypeRector extends \Rector\Core\Rector\AbstractRector +final class UseIdenticalOverEqualWithSameTypeRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeAnalyzer\ExprAnalyzer */ private $exprAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ExprAnalyzer $exprAnalyzer) + public function __construct(ExprAnalyzer $exprAnalyzer) { $this->exprAnalyzer = $exprAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Use ===/!== over ==/!=, it values have the same type', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Use ===/!== over ==/!=, it values have the same type', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(int $firstValue, int $secondValue) @@ -58,23 +58,23 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\Equal::class, \PhpParser\Node\Expr\BinaryOp\NotEqual::class]; + return [Equal::class, NotEqual::class]; } /** * @param Equal|NotEqual $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $leftStaticType = $this->getType($node->left); $rightStaticType = $this->getType($node->right); // objects can be different by content - if ($leftStaticType instanceof \PHPStan\Type\ObjectType) { + if ($leftStaticType instanceof ObjectType) { return null; } - if ($leftStaticType instanceof \PHPStan\Type\MixedType) { + if ($leftStaticType instanceof MixedType) { return null; } - if ($rightStaticType instanceof \PHPStan\Type\MixedType) { + if ($rightStaticType instanceof MixedType) { return null; } // different types @@ -84,12 +84,12 @@ CODE_SAMPLE if ($this->areNonTypedFromParam($node->left, $node->right)) { return null; } - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\Equal) { - return new \PhpParser\Node\Expr\BinaryOp\Identical($node->left, $node->right); + if ($node instanceof Equal) { + return new Identical($node->left, $node->right); } - return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($node->left, $node->right); + return new NotIdentical($node->left, $node->right); } - private function areNonTypedFromParam(\PhpParser\Node\Expr $left, \PhpParser\Node\Expr $right) : bool + private function areNonTypedFromParam(Expr $left, Expr $right) : bool { if ($this->exprAnalyzer->isNonTypedFromParam($left)) { return \true; diff --git a/rules/CodeQuality/Rector/Expression/InlineIfToExplicitIfRector.php b/rules/CodeQuality/Rector/Expression/InlineIfToExplicitIfRector.php index 6663415bb2a..a9d3bcc37e8 100644 --- a/rules/CodeQuality/Rector/Expression/InlineIfToExplicitIfRector.php +++ b/rules/CodeQuality/Rector/Expression/InlineIfToExplicitIfRector.php @@ -14,27 +14,27 @@ use PhpParser\Node\Stmt\If_; use PHPStan\Type\BooleanType; use Rector\Core\NodeManipulator\BinaryOpManipulator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/dmHCC * * @see \Rector\Tests\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector\InlineIfToExplicitIfRectorTest */ -final class InlineIfToExplicitIfRector extends \Rector\Core\Rector\AbstractRector +final class InlineIfToExplicitIfRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeManipulator\BinaryOpManipulator */ private $binaryOpManipulator; - public function __construct(\Rector\Core\NodeManipulator\BinaryOpManipulator $binaryOpManipulator) + public function __construct(BinaryOpManipulator $binaryOpManipulator) { $this->binaryOpManipulator = $binaryOpManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change inline if to explicit if', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change inline if to explicit if', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -65,37 +65,37 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Expression::class]; + return [Expression::class]; } /** * @param Expression $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node->expr instanceof \PhpParser\Node\Expr\BinaryOp\BooleanAnd) { + if ($node->expr instanceof BooleanAnd) { return $this->processExplicitIf($node); } - if ($node->expr instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { + if ($node->expr instanceof BooleanOr) { return $this->processExplicitIf($node); } return null; } - private function processExplicitIf(\PhpParser\Node\Stmt\Expression $expression) : ?\PhpParser\Node + private function processExplicitIf(Expression $expression) : ?Node { /** @var BooleanAnd|BooleanOr $booleanExpr */ $booleanExpr = $expression->expr; $leftStaticType = $this->getType($booleanExpr->left); - if (!$leftStaticType instanceof \PHPStan\Type\BooleanType) { + if (!$leftStaticType instanceof BooleanType) { return null; } - $exprLeft = $booleanExpr->left instanceof \PhpParser\Node\Expr\BooleanNot ? $booleanExpr->left->expr : $booleanExpr->left; - if ($exprLeft instanceof \PhpParser\Node\Expr\FuncCall && $this->isName($exprLeft, 'defined')) { + $exprLeft = $booleanExpr->left instanceof BooleanNot ? $booleanExpr->left->expr : $booleanExpr->left; + if ($exprLeft instanceof FuncCall && $this->isName($exprLeft, 'defined')) { return null; } /** @var Expr $expr */ - $expr = $booleanExpr instanceof \PhpParser\Node\Expr\BinaryOp\BooleanAnd ? $booleanExpr->left : $this->binaryOpManipulator->inverseNode($booleanExpr->left); - $if = new \PhpParser\Node\Stmt\If_($expr); - $if->stmts[] = new \PhpParser\Node\Stmt\Expression($booleanExpr->right); + $expr = $booleanExpr instanceof BooleanAnd ? $booleanExpr->left : $this->binaryOpManipulator->inverseNode($booleanExpr->left); + $if = new If_($expr); + $if->stmts[] = new Expression($booleanExpr->right); $this->mirrorComments($if, $expression); return $if; } diff --git a/rules/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector.php b/rules/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector.php index bf8108c9ebd..81f2a381b71 100644 --- a/rules/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector.php +++ b/rules/CodeQuality/Rector/For_/ForRepeatedCountToOwnVariableRector.php @@ -13,25 +13,25 @@ use PhpParser\Node\Stmt\For_; use PHPStan\Analyser\Scope; use Rector\Core\Rector\AbstractScopeAwareRector; use Rector\Naming\Naming\VariableNaming; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\For_\ForRepeatedCountToOwnVariableRector\ForRepeatedCountToOwnVariableRectorTest */ -final class ForRepeatedCountToOwnVariableRector extends \Rector\Core\Rector\AbstractScopeAwareRector +final class ForRepeatedCountToOwnVariableRector extends AbstractScopeAwareRector { /** * @readonly * @var \Rector\Naming\Naming\VariableNaming */ private $variableNaming; - public function __construct(\Rector\Naming\Naming\VariableNaming $variableNaming) + public function __construct(VariableNaming $variableNaming) { $this->variableNaming = $variableNaming; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change count() in for function to own variable', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change count() in for function to own variable', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($items) @@ -61,18 +61,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\For_::class]; + return [For_::class]; } /** * @param For_ $node * @return Stmt[]|null */ - public function refactorWithScope(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : ?array + public function refactorWithScope(Node $node, Scope $scope) : ?array { $countInCond = null; $variableName = null; - $this->traverseNodesWithCallable($node->cond, function (\PhpParser\Node $node) use(&$countInCond, &$variableName, $scope) : ?Variable { - if (!$node instanceof \PhpParser\Node\Expr\FuncCall) { + $this->traverseNodesWithCallable($node->cond, function (Node $node) use(&$countInCond, &$variableName, $scope) : ?Variable { + if (!$node instanceof FuncCall) { return null; } if (!$this->isName($node, 'count')) { @@ -80,7 +80,7 @@ CODE_SAMPLE } $countInCond = $node; $variableName = $this->variableNaming->resolveFromFuncCallFirstArgumentWithSuffix($node, 'Count', 'itemsCount', $scope); - return new \PhpParser\Node\Expr\Variable($variableName); + return new Variable($variableName); }); if ($countInCond === null) { return null; @@ -88,7 +88,7 @@ CODE_SAMPLE if ($variableName === null) { return null; } - $countAssign = new \PhpParser\Node\Expr\Assign(new \PhpParser\Node\Expr\Variable($variableName), $countInCond); - return [new \PhpParser\Node\Stmt\Expression($countAssign), $node]; + $countAssign = new Assign(new Variable($variableName), $countInCond); + return [new Expression($countAssign), $node]; } } diff --git a/rules/CodeQuality/Rector/For_/ForToForeachRector.php b/rules/CodeQuality/Rector/For_/ForToForeachRector.php index 0db53422fb7..d639f6da2a6 100644 --- a/rules/CodeQuality/Rector/For_/ForToForeachRector.php +++ b/rules/CodeQuality/Rector/For_/ForToForeachRector.php @@ -17,12 +17,12 @@ use Rector\CodeQuality\NodeAnalyzer\ForeachAnalyzer; use Rector\CodeQuality\NodeFactory\ForeachFactory; use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\For_\ForToForeachRector\ForToForeachRectorTest */ -final class ForToForeachRector extends \Rector\Core\Rector\AbstractRector +final class ForToForeachRector extends AbstractRector { /** * @var string @@ -64,16 +64,16 @@ final class ForToForeachRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\CodeQuality\NodeAnalyzer\ForeachAnalyzer */ private $foreachAnalyzer; - public function __construct(\RectorPrefix20220607\Doctrine\Inflector\Inflector $inflector, \Rector\CodeQuality\NodeAnalyzer\ForAnalyzer $forAnalyzer, \Rector\CodeQuality\NodeFactory\ForeachFactory $foreachFactory, \Rector\CodeQuality\NodeAnalyzer\ForeachAnalyzer $foreachAnalyzer) + public function __construct(Inflector $inflector, ForAnalyzer $forAnalyzer, ForeachFactory $foreachFactory, ForeachAnalyzer $foreachAnalyzer) { $this->inflector = $inflector; $this->forAnalyzer = $forAnalyzer; $this->foreachFactory = $foreachFactory; $this->foreachAnalyzer = $foreachAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change for() to foreach() where useful', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change for() to foreach() where useful', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($tokens) @@ -106,12 +106,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\For_::class]; + return [For_::class]; } /** * @param For_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $this->reset(); $this->matchInit($node->init); @@ -146,7 +146,7 @@ CODE_SAMPLE } return $this->processForToForeach($node, $iteratedVariable); } - private function processForToForeach(\PhpParser\Node\Stmt\For_ $for, string $iteratedVariable) : ?\PhpParser\Node\Stmt\Foreach_ + private function processForToForeach(For_ $for, string $iteratedVariable) : ?Foreach_ { $originalVariableSingle = $this->inflector->singularize($iteratedVariable); $iteratedVariableSingle = $originalVariableSingle; @@ -164,12 +164,12 @@ CODE_SAMPLE } return null; } - private function createForeachFromForWithIteratedVariableSingle(\PhpParser\Node\Stmt\For_ $for, string $iteratedVariableSingle) : \PhpParser\Node\Stmt\Foreach_ + private function createForeachFromForWithIteratedVariableSingle(For_ $for, string $iteratedVariableSingle) : Foreach_ { $foreach = $this->foreachFactory->createFromFor($for, $iteratedVariableSingle, $this->iteratedExpr, $this->keyValueName); $this->mirrorComments($foreach, $for); if ($this->keyValueName === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $this->foreachAnalyzer->useForeachVariableInStmts($foreach->expr, $foreach->valueVar, $foreach->stmts, $this->keyValueName); return $foreach; @@ -187,17 +187,17 @@ CODE_SAMPLE private function matchInit(array $initExprs) : void { foreach ($initExprs as $initExpr) { - if (!$initExpr instanceof \PhpParser\Node\Expr\Assign) { + if (!$initExpr instanceof Assign) { continue; } if ($this->valueResolver->isValue($initExpr->expr, 0)) { $this->keyValueName = $this->getName($initExpr->var); } - if (!$initExpr->expr instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$initExpr->expr instanceof FuncCall) { continue; } $funcCall = $initExpr->expr; - if ($this->nodeNameResolver->isName($funcCall, self::COUNT) && $funcCall->args[0] instanceof \PhpParser\Node\Arg) { + if ($this->nodeNameResolver->isName($funcCall, self::COUNT) && $funcCall->args[0] instanceof Arg) { $this->countValueVariableExpr = $initExpr->var; $this->countValueName = $this->getName($initExpr->var); $this->iteratedExpr = $funcCall->args[0]->value; @@ -217,14 +217,14 @@ CODE_SAMPLE if ($this->countValueName !== null) { return $this->forAnalyzer->isCondExprSmallerOrGreater($condExprs, $keyValueName, $this->countValueName); } - if (!$condExprs[0] instanceof \PhpParser\Node\Expr\BinaryOp) { + if (!$condExprs[0] instanceof BinaryOp) { return \false; } $funcCall = $condExprs[0]->right; - if (!$funcCall instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$funcCall instanceof FuncCall) { return \false; } - if ($this->nodeNameResolver->isName($funcCall, self::COUNT) && $funcCall->args[0] instanceof \PhpParser\Node\Arg) { + if ($this->nodeNameResolver->isName($funcCall, self::COUNT) && $funcCall->args[0] instanceof Arg) { $this->iteratedExpr = $funcCall->args[0]->value; return \true; } diff --git a/rules/CodeQuality/Rector/Foreach_/ForeachItemsAssignToEmptyArrayToAssignRector.php b/rules/CodeQuality/Rector/Foreach_/ForeachItemsAssignToEmptyArrayToAssignRector.php index 938be12677b..7e111cc742e 100644 --- a/rules/CodeQuality/Rector/Foreach_/ForeachItemsAssignToEmptyArrayToAssignRector.php +++ b/rules/CodeQuality/Rector/Foreach_/ForeachItemsAssignToEmptyArrayToAssignRector.php @@ -15,12 +15,12 @@ use Rector\Core\Rector\AbstractScopeAwareRector; use Rector\NodeNestingScope\ValueObject\ControlStructure; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\ReadWrite\NodeFinder\NodeUsageFinder; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Foreach_\ForeachItemsAssignToEmptyArrayToAssignRector\ForeachItemsAssignToEmptyArrayToAssignRectorTest */ -final class ForeachItemsAssignToEmptyArrayToAssignRector extends \Rector\Core\Rector\AbstractScopeAwareRector +final class ForeachItemsAssignToEmptyArrayToAssignRector extends AbstractScopeAwareRector { /** * @readonly @@ -32,14 +32,14 @@ final class ForeachItemsAssignToEmptyArrayToAssignRector extends \Rector\Core\Re * @var \Rector\CodeQuality\NodeAnalyzer\ForeachAnalyzer */ private $foreachAnalyzer; - public function __construct(\Rector\ReadWrite\NodeFinder\NodeUsageFinder $nodeUsageFinder, \Rector\CodeQuality\NodeAnalyzer\ForeachAnalyzer $foreachAnalyzer) + public function __construct(NodeUsageFinder $nodeUsageFinder, ForeachAnalyzer $foreachAnalyzer) { $this->nodeUsageFinder = $nodeUsageFinder; $this->foreachAnalyzer = $foreachAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change foreach() items assign to empty array to direct assign', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change foreach() items assign to empty array to direct assign', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($items) @@ -70,35 +70,35 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Foreach_::class]; + return [Foreach_::class]; } /** * @param Foreach_ $node */ - public function refactorWithScope(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : ?\PhpParser\Node + public function refactorWithScope(Node $node, Scope $scope) : ?Node { if ($this->shouldSkip($node, $scope)) { return null; } /** @var Expr $assignVariable */ $assignVariable = $this->foreachAnalyzer->matchAssignItemsOnlyForeachArrayVariable($node); - return new \PhpParser\Node\Expr\Assign($assignVariable, $node->expr); + return new Assign($assignVariable, $node->expr); } - private function shouldSkip(\PhpParser\Node\Stmt\Foreach_ $foreach, \PHPStan\Analyser\Scope $scope) : bool + private function shouldSkip(Foreach_ $foreach, Scope $scope) : bool { $assignVariable = $this->foreachAnalyzer->matchAssignItemsOnlyForeachArrayVariable($foreach); - if (!$assignVariable instanceof \PhpParser\Node\Expr) { + if (!$assignVariable instanceof Expr) { return \true; } if ($this->shouldSkipAsPartOfOtherLoop($foreach)) { return \true; } $previousDeclaration = $this->nodeUsageFinder->findPreviousForeachNodeUsage($foreach, $assignVariable); - if (!$previousDeclaration instanceof \PhpParser\Node) { + if (!$previousDeclaration instanceof Node) { return \true; } - $previousDeclarationParentNode = $previousDeclaration->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$previousDeclarationParentNode instanceof \PhpParser\Node\Expr\Assign) { + $previousDeclarationParentNode = $previousDeclaration->getAttribute(AttributeKey::PARENT_NODE); + if (!$previousDeclarationParentNode instanceof Assign) { return \true; } // must be empty array, otherwise it will false override @@ -107,17 +107,17 @@ CODE_SAMPLE return \true; } $type = $scope->getType($foreach->expr); - if ($type instanceof \PHPStan\Type\ObjectType) { + if ($type instanceof ObjectType) { return $type->isIterable()->yes(); } - if ($type instanceof \PHPStan\Type\ThisType) { + if ($type instanceof ThisType) { return $type->isIterable()->yes(); } return \false; } - private function shouldSkipAsPartOfOtherLoop(\PhpParser\Node\Stmt\Foreach_ $foreach) : bool + private function shouldSkipAsPartOfOtherLoop(Foreach_ $foreach) : bool { - $foreachParent = $this->betterNodeFinder->findParentByTypes($foreach, \Rector\NodeNestingScope\ValueObject\ControlStructure::LOOP_NODES); - return $foreachParent instanceof \PhpParser\Node; + $foreachParent = $this->betterNodeFinder->findParentByTypes($foreach, ControlStructure::LOOP_NODES); + return $foreachParent instanceof Node; } } diff --git a/rules/CodeQuality/Rector/Foreach_/ForeachToInArrayRector.php b/rules/CodeQuality/Rector/Foreach_/ForeachToInArrayRector.php index 8c5638a2f81..1b4b41da511 100644 --- a/rules/CodeQuality/Rector/Foreach_/ForeachToInArrayRector.php +++ b/rules/CodeQuality/Rector/Foreach_/ForeachToInArrayRector.php @@ -19,12 +19,12 @@ use Rector\Core\NodeManipulator\BinaryOpManipulator; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Php71\ValueObject\TwoNodeMatch; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Foreach_\ForeachToInArrayRector\ForeachToInArrayRectorTest */ -final class ForeachToInArrayRector extends \Rector\Core\Rector\AbstractRector +final class ForeachToInArrayRector extends AbstractRector { /** * @readonly @@ -36,14 +36,14 @@ final class ForeachToInArrayRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\BetterPhpDocParser\Comment\CommentsMerger */ private $commentsMerger; - public function __construct(\Rector\Core\NodeManipulator\BinaryOpManipulator $binaryOpManipulator, \Rector\BetterPhpDocParser\Comment\CommentsMerger $commentsMerger) + public function __construct(BinaryOpManipulator $binaryOpManipulator, CommentsMerger $commentsMerger) { $this->binaryOpManipulator = $binaryOpManipulator; $this->commentsMerger = $commentsMerger; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Simplify `foreach` loops into `in_array` when possible', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Simplify `foreach` loops into `in_array` when possible', [new CodeSample(<<<'CODE_SAMPLE' foreach ($items as $item) { if ($item === 'something') { return true; @@ -62,12 +62,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Foreach_::class]; + return [Foreach_::class]; } /** * @param Foreach_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkipForeach($node)) { return null; @@ -81,7 +81,7 @@ CODE_SAMPLE $ifCondition = $firstNodeInsideForeach->cond; $foreachValueVar = $node->valueVar; $twoNodeMatch = $this->matchNodes($ifCondition, $foreachValueVar); - if (!$twoNodeMatch instanceof \Rector\Php71\ValueObject\TwoNodeMatch) { + if (!$twoNodeMatch instanceof TwoNodeMatch) { return null; } $comparedNode = $twoNodeMatch->getSecondExpr(); @@ -90,7 +90,7 @@ CODE_SAMPLE } $funcCall = $this->createInArrayFunction($comparedNode, $ifCondition, $node); /** @var Return_ $returnToRemove */ - $returnToRemove = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); + $returnToRemove = $node->getAttribute(AttributeKey::NEXT_NODE); /** @var Return_ $return */ $return = $firstNodeInsideForeach->stmts[0]; if ($returnToRemove->expr === null) { @@ -100,7 +100,7 @@ CODE_SAMPLE return null; } $returnedExpr = $return->expr; - if (!$returnedExpr instanceof \PhpParser\Node\Expr) { + if (!$returnedExpr instanceof Expr) { return null; } // cannot be "return true;" + "return true;" @@ -112,7 +112,7 @@ CODE_SAMPLE $this->commentsMerger->keepChildren($return, $node); return $return; } - private function shouldSkipForeach(\PhpParser\Node\Stmt\Foreach_ $foreach) : bool + private function shouldSkipForeach(Foreach_ $foreach) : bool { if ($foreach->keyVar !== null) { return \true; @@ -120,47 +120,47 @@ CODE_SAMPLE if (\count($foreach->stmts) > 1) { return \true; } - $nextNode = $foreach->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if (!$nextNode instanceof \PhpParser\Node) { + $nextNode = $foreach->getAttribute(AttributeKey::NEXT_NODE); + if (!$nextNode instanceof Node) { return \true; } - if (!$nextNode instanceof \PhpParser\Node\Stmt\Return_) { + if (!$nextNode instanceof Return_) { return \true; } $returnExpression = $nextNode->expr; - if (!$returnExpression instanceof \PhpParser\Node\Expr) { + if (!$returnExpression instanceof Expr) { return \true; } if (!$this->valueResolver->isTrueOrFalse($returnExpression)) { return \true; } $foreachValueStaticType = $this->getType($foreach->expr); - if ($foreachValueStaticType instanceof \PHPStan\Type\ObjectType) { + if ($foreachValueStaticType instanceof ObjectType) { return \true; } - return !$foreach->stmts[0] instanceof \PhpParser\Node\Stmt\If_; + return !$foreach->stmts[0] instanceof If_; } - private function shouldSkipIf(\PhpParser\Node\Stmt\If_ $if) : bool + private function shouldSkipIf(If_ $if) : bool { $ifCondition = $if->cond; - if ($ifCondition instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { + if ($ifCondition instanceof Identical) { return \false; } - return !$ifCondition instanceof \PhpParser\Node\Expr\BinaryOp\Equal; + return !$ifCondition instanceof Equal; } /** * @param \PhpParser\Node\Expr\BinaryOp\Equal|\PhpParser\Node\Expr\BinaryOp\Identical $binaryOp */ - private function matchNodes($binaryOp, \PhpParser\Node\Expr $expr) : ?\Rector\Php71\ValueObject\TwoNodeMatch + private function matchNodes($binaryOp, Expr $expr) : ?TwoNodeMatch { - return $this->binaryOpManipulator->matchFirstAndSecondConditionNode($binaryOp, \PhpParser\Node\Expr\Variable::class, function (\PhpParser\Node $node, \PhpParser\Node $otherNode) use($expr) : bool { + return $this->binaryOpManipulator->matchFirstAndSecondConditionNode($binaryOp, Variable::class, function (Node $node, Node $otherNode) use($expr) : bool { return $this->nodeComparator->areNodesEqual($otherNode, $expr); }); } - private function isIfBodyABoolReturnNode(\PhpParser\Node\Stmt\If_ $if) : bool + private function isIfBodyABoolReturnNode(If_ $if) : bool { $ifStatment = $if->stmts[0]; - if (!$ifStatment instanceof \PhpParser\Node\Stmt\Return_) { + if (!$ifStatment instanceof Return_) { return \false; } if ($ifStatment->expr === null) { @@ -171,17 +171,17 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\Equal $binaryOp */ - private function createInArrayFunction(\PhpParser\Node\Expr $expr, $binaryOp, \PhpParser\Node\Stmt\Foreach_ $foreach) : \PhpParser\Node\Expr\FuncCall + private function createInArrayFunction(Expr $expr, $binaryOp, Foreach_ $foreach) : FuncCall { $arguments = $this->nodeFactory->createArgs([$expr, $foreach->expr]); - if ($binaryOp instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { + if ($binaryOp instanceof Identical) { $arguments[] = $this->nodeFactory->createArg($this->nodeFactory->createTrue()); } return $this->nodeFactory->createFuncCall('in_array', $arguments); } - private function createReturn(\PhpParser\Node\Expr $expr, \PhpParser\Node\Expr\FuncCall $funcCall) : \PhpParser\Node\Stmt\Return_ + private function createReturn(Expr $expr, FuncCall $funcCall) : Return_ { - $expr = $this->valueResolver->isFalse($expr) ? new \PhpParser\Node\Expr\BooleanNot($funcCall) : $funcCall; - return new \PhpParser\Node\Stmt\Return_($expr); + $expr = $this->valueResolver->isFalse($expr) ? new BooleanNot($funcCall) : $funcCall; + return new Return_($expr); } } diff --git a/rules/CodeQuality/Rector/Foreach_/SimplifyForeachToArrayFilterRector.php b/rules/CodeQuality/Rector/Foreach_/SimplifyForeachToArrayFilterRector.php index c84c426c81b..8be351d9236 100644 --- a/rules/CodeQuality/Rector/Foreach_/SimplifyForeachToArrayFilterRector.php +++ b/rules/CodeQuality/Rector/Foreach_/SimplifyForeachToArrayFilterRector.php @@ -18,25 +18,25 @@ use PHPStan\Type\MixedType; use PHPStan\Type\UnionType; use Rector\CodeQuality\NodeFactory\ArrayFilterFactory; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Foreach_\SimplifyForeachToArrayFilterRector\SimplifyForeachToArrayFilterRectorTest */ -final class SimplifyForeachToArrayFilterRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyForeachToArrayFilterRector extends AbstractRector { /** * @readonly * @var \Rector\CodeQuality\NodeFactory\ArrayFilterFactory */ private $arrayFilterFactory; - public function __construct(\Rector\CodeQuality\NodeFactory\ArrayFilterFactory $arrayFilterFactory) + public function __construct(ArrayFilterFactory $arrayFilterFactory) { $this->arrayFilterFactory = $arrayFilterFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Simplify foreach with function filtering to array filter', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Simplify foreach with function filtering to array filter', [new CodeSample(<<<'CODE_SAMPLE' $directories = []; $possibleDirectories = []; @@ -57,39 +57,39 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Foreach_::class]; + return [Foreach_::class]; } /** * @param Foreach_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } $foreachValueVar = $node->valueVar; - if (!$foreachValueVar instanceof \PhpParser\Node\Expr\Variable) { + if (!$foreachValueVar instanceof Variable) { return null; } /** @var If_ $ifNode */ $ifNode = $node->stmts[0]; $condExpr = $ifNode->cond; - if ($condExpr instanceof \PhpParser\Node\Expr\FuncCall) { + if ($condExpr instanceof FuncCall) { return $this->refactorFuncCall($ifNode, $condExpr, $node, $foreachValueVar); } $onlyStmt = $ifNode->stmts[0]; - if ($onlyStmt instanceof \PhpParser\Node\Stmt\Expression) { + if ($onlyStmt instanceof Expression) { return $this->refactorAssign($onlyStmt, $foreachValueVar, $node, $condExpr); } // another condition - not supported yet return null; } - private function shouldSkip(\PhpParser\Node\Stmt\Foreach_ $foreach) : bool + private function shouldSkip(Foreach_ $foreach) : bool { if (\count($foreach->stmts) !== 1) { return \true; } - if (!$foreach->stmts[0] instanceof \PhpParser\Node\Stmt\If_) { + if (!$foreach->stmts[0] instanceof If_) { return \true; } /** @var If_ $ifNode */ @@ -99,26 +99,26 @@ CODE_SAMPLE } return $ifNode->elseifs !== []; } - private function isArrayDimFetchInForLoop(\PhpParser\Node\Stmt\Foreach_ $foreach, \PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch) : bool + private function isArrayDimFetchInForLoop(Foreach_ $foreach, ArrayDimFetch $arrayDimFetch) : bool { $loopVar = $foreach->expr; - if (!$loopVar instanceof \PhpParser\Node\Expr\Variable) { + if (!$loopVar instanceof Variable) { return \false; } $varThatIsModified = $arrayDimFetch->var; - if (!$varThatIsModified instanceof \PhpParser\Node\Expr\Variable) { + if (!$varThatIsModified instanceof Variable) { return \false; } return $loopVar->name !== $varThatIsModified->name; } - private function isSimpleFuncCallOnForeachedVariables(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr\Variable $foreachVariable) : bool + private function isSimpleFuncCallOnForeachedVariables(FuncCall $funcCall, Variable $foreachVariable) : bool { if (\count($funcCall->args) !== 1) { return \false; } return $this->nodeComparator->areNodesEqual($funcCall->args[0], $foreachVariable); } - private function refactorFuncCall(\PhpParser\Node\Stmt\If_ $if, \PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Stmt\Foreach_ $foreach, \PhpParser\Node\Expr\Variable $foreachVariable) : ?\PhpParser\Node\Expr\Assign + private function refactorFuncCall(If_ $if, FuncCall $funcCall, Foreach_ $foreach, Variable $foreachVariable) : ?Assign { if (\count($if->stmts) !== 1) { return null; @@ -126,15 +126,15 @@ CODE_SAMPLE if (!$this->isSimpleFuncCallOnForeachedVariables($funcCall, $foreachVariable)) { return null; } - if (!$if->stmts[0] instanceof \PhpParser\Node\Stmt\Expression) { + if (!$if->stmts[0] instanceof Expression) { return null; } $onlyNodeInIf = $if->stmts[0]->expr; - if (!$onlyNodeInIf instanceof \PhpParser\Node\Expr\Assign) { + if (!$onlyNodeInIf instanceof Assign) { return null; } $arrayDimFetch = $onlyNodeInIf->var; - if (!$arrayDimFetch instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$arrayDimFetch instanceof ArrayDimFetch) { return null; } if (!$this->nodeComparator->areNodesEqual($onlyNodeInIf->expr, $foreachVariable)) { @@ -149,35 +149,35 @@ CODE_SAMPLE } return $this->arrayFilterFactory->createSimpleFuncCallAssign($foreach, $funcName, $arrayDimFetch); } - private function refactorAssign(\PhpParser\Node\Stmt\Expression $expression, \PhpParser\Node\Expr\Variable $variable, \PhpParser\Node\Stmt\Foreach_ $foreach, \PhpParser\Node\Expr $condExpr) : ?\PhpParser\Node\Expr\Assign + private function refactorAssign(Expression $expression, Variable $variable, Foreach_ $foreach, Expr $condExpr) : ?Assign { - if (!$expression->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$expression->expr instanceof Assign) { return null; } $assign = $expression->expr; // only the array dim fetch with key is allowed - if (!$assign->var instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$assign->var instanceof ArrayDimFetch) { return null; } $arrayDimFetch = $assign->var; $arrayDimVariableType = $this->getType($arrayDimFetch->var); - $arrayType = new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); + $arrayType = new ArrayType(new MixedType(), new MixedType()); if ($arrayType->isSuperTypeOf($arrayDimVariableType)->no()) { return null; } // must be array type - if (!$arrayDimVariableType instanceof \PHPStan\Type\ArrayType) { + if (!$arrayDimVariableType instanceof ArrayType) { return null; } // two different types, probably not empty array - if ($arrayDimVariableType->getItemType() instanceof \PHPStan\Type\UnionType) { + if ($arrayDimVariableType->getItemType() instanceof UnionType) { return null; } if (!$this->nodeComparator->areNodesEqual($variable, $assign->expr)) { return null; } // the keyvar must be variable in array dim fetch - if (!$foreach->keyVar instanceof \PhpParser\Node\Expr) { + if (!$foreach->keyVar instanceof Expr) { return null; } if (!$this->nodeComparator->areNodesEqual($arrayDimFetch->dim, $foreach->keyVar)) { diff --git a/rules/CodeQuality/Rector/Foreach_/SimplifyForeachToCoalescingRector.php b/rules/CodeQuality/Rector/Foreach_/SimplifyForeachToCoalescingRector.php index 2d72f9905bf..53d40056849 100644 --- a/rules/CodeQuality/Rector/Foreach_/SimplifyForeachToCoalescingRector.php +++ b/rules/CodeQuality/Rector/Foreach_/SimplifyForeachToCoalescingRector.php @@ -17,14 +17,14 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/bfsdY * * @see \Rector\Tests\CodeQuality\Rector\Foreach_\SimplifyForeachToCoalescingRector\SimplifyForeachToCoalescingRectorTest */ -final class SimplifyForeachToCoalescingRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class SimplifyForeachToCoalescingRector extends AbstractRector implements MinPhpVersionInterface { /** * @var \PhpParser\Node\Stmt\Return_|null @@ -35,13 +35,13 @@ final class SimplifyForeachToCoalescingRector extends \Rector\Core\Rector\Abstra * @var \Rector\Core\NodeManipulator\ForeachManipulator */ private $foreachManipulator; - public function __construct(\Rector\Core\NodeManipulator\ForeachManipulator $foreachManipulator) + public function __construct(ForeachManipulator $foreachManipulator) { $this->foreachManipulator = $foreachManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes foreach that returns set value to ??', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes foreach that returns set value to ??', [new CodeSample(<<<'CODE_SAMPLE' foreach ($this->oldToNewFunctions as $oldFunction => $newFunction) { if ($currentFunction === $oldFunction) { return $newFunction; @@ -60,12 +60,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Foreach_::class]; + return [Foreach_::class]; } /** * @param Foreach_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $this->return = null; if ($node->keyVar === null) { @@ -81,32 +81,32 @@ CODE_SAMPLE if (!$this->nodeComparator->areNodesEqual($node->valueVar, $returnOrAssignNode->expr)) { return null; } - if ($returnOrAssignNode instanceof \PhpParser\Node\Stmt\Return_) { + if ($returnOrAssignNode instanceof Return_) { return $this->processForeachNodeWithReturnInside($node, $returnOrAssignNode); } return $this->processForeachNodeWithAssignInside($node, $returnOrAssignNode); } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NULL_COALESCE; + return PhpVersionFeature::NULL_COALESCE; } /** * @return Assign|Return_|null */ - private function matchReturnOrAssignNode(\PhpParser\Node\Stmt\Foreach_ $foreach) : ?\PhpParser\Node + private function matchReturnOrAssignNode(Foreach_ $foreach) : ?Node { - return $this->foreachManipulator->matchOnlyStmt($foreach, function (\PhpParser\Node $node) : ?Node { - if (!$node instanceof \PhpParser\Node\Stmt\If_) { + return $this->foreachManipulator->matchOnlyStmt($foreach, function (Node $node) : ?Node { + if (!$node instanceof If_) { return null; } - if (!$node->cond instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { + if (!$node->cond instanceof Identical) { return null; } if (\count($node->stmts) !== 1) { return null; } - $innerNode = $node->stmts[0] instanceof \PhpParser\Node\Stmt\Expression ? $node->stmts[0]->expr : $node->stmts[0]; - if ($innerNode instanceof \PhpParser\Node\Expr\Assign || $innerNode instanceof \PhpParser\Node\Stmt\Return_) { + $innerNode = $node->stmts[0] instanceof Expression ? $node->stmts[0]->expr : $node->stmts[0]; + if ($innerNode instanceof Assign || $innerNode instanceof Return_) { return $innerNode; } return null; @@ -115,7 +115,7 @@ CODE_SAMPLE /** * @return \PhpParser\Node\Stmt\Return_|null */ - private function processForeachNodeWithReturnInside(\PhpParser\Node\Stmt\Foreach_ $foreach, \PhpParser\Node\Stmt\Return_ $return) + private function processForeachNodeWithReturnInside(Foreach_ $foreach, Return_ $return) { if (!$this->nodeComparator->areNodesEqual($foreach->valueVar, $return->expr)) { return null; @@ -131,19 +131,19 @@ CODE_SAMPLE } else { return null; } - $nextNode = $foreach->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); + $nextNode = $foreach->getAttribute(AttributeKey::NEXT_NODE); // is next node Return? - if ($nextNode instanceof \PhpParser\Node\Stmt\Return_) { + if ($nextNode instanceof Return_) { $this->return = $nextNode; $this->removeNode($this->return); } - $coalesce = new \PhpParser\Node\Expr\BinaryOp\Coalesce(new \PhpParser\Node\Expr\ArrayDimFetch($foreach->expr, $checkedNode), $this->return instanceof \PhpParser\Node\Stmt\Return_ && $this->return->expr !== null ? $this->return->expr : $checkedNode); + $coalesce = new Coalesce(new ArrayDimFetch($foreach->expr, $checkedNode), $this->return instanceof Return_ && $this->return->expr !== null ? $this->return->expr : $checkedNode); if ($this->return !== null) { - return new \PhpParser\Node\Stmt\Return_($coalesce); + return new Return_($coalesce); } return null; } - private function processForeachNodeWithAssignInside(\PhpParser\Node\Stmt\Foreach_ $foreach, \PhpParser\Node\Expr\Assign $assign) : ?\PhpParser\Node + private function processForeachNodeWithAssignInside(Foreach_ $foreach, Assign $assign) : ?Node { /** @var If_ $ifNode */ $ifNode = $foreach->stmts[0]; @@ -158,7 +158,7 @@ CODE_SAMPLE } else { return null; } - $arrayDimFetch = new \PhpParser\Node\Expr\ArrayDimFetch($foreach->expr, $keyNode); - return new \PhpParser\Node\Expr\Assign($checkedNode, new \PhpParser\Node\Expr\BinaryOp\Coalesce($arrayDimFetch, $checkedNode)); + $arrayDimFetch = new ArrayDimFetch($foreach->expr, $keyNode); + return new Assign($checkedNode, new Coalesce($arrayDimFetch, $checkedNode)); } } diff --git a/rules/CodeQuality/Rector/Foreach_/UnusedForeachValueToArrayKeysRector.php b/rules/CodeQuality/Rector/Foreach_/UnusedForeachValueToArrayKeysRector.php index d84eeef6397..743a3584238 100644 --- a/rules/CodeQuality/Rector/Foreach_/UnusedForeachValueToArrayKeysRector.php +++ b/rules/CodeQuality/Rector/Foreach_/UnusedForeachValueToArrayKeysRector.php @@ -12,25 +12,25 @@ use PhpParser\Node\Stmt\Foreach_; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\DeadCode\NodeAnalyzer\ExprUsedInNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector\UnusedForeachValueToArrayKeysRectorTest */ -final class UnusedForeachValueToArrayKeysRector extends \Rector\Core\Rector\AbstractRector +final class UnusedForeachValueToArrayKeysRector extends AbstractRector { /** * @readonly * @var \Rector\DeadCode\NodeAnalyzer\ExprUsedInNodeAnalyzer */ private $exprUsedInNodeAnalyzer; - public function __construct(\Rector\DeadCode\NodeAnalyzer\ExprUsedInNodeAnalyzer $exprUsedInNodeAnalyzer) + public function __construct(ExprUsedInNodeAnalyzer $exprUsedInNodeAnalyzer) { $this->exprUsedInNodeAnalyzer = $exprUsedInNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change foreach with unused $value but only $key, to array_keys()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change foreach with unused $value but only $key, to array_keys()', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -61,23 +61,23 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Foreach_::class]; + return [Foreach_::class]; } /** * @param Foreach_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->keyVar === null) { return null; } // special case of nested array items - if ($node->valueVar instanceof \PhpParser\Node\Expr\Array_) { + if ($node->valueVar instanceof Array_) { $node->valueVar = $this->refactorArrayForeachValue($node->valueVar, $node); if ($node->valueVar->items !== []) { return null; } - } elseif ($node->valueVar instanceof \PhpParser\Node\Expr\Variable) { + } elseif ($node->valueVar instanceof Variable) { if ($this->isVariableUsedInForeach($node->valueVar, $node)) { return null; } @@ -90,14 +90,14 @@ CODE_SAMPLE $this->removeForeachValueAndUseArrayKeys($node); return $node; } - private function refactorArrayForeachValue(\PhpParser\Node\Expr\Array_ $array, \PhpParser\Node\Stmt\Foreach_ $foreach) : \PhpParser\Node\Expr\Array_ + private function refactorArrayForeachValue(Array_ $array, Foreach_ $foreach) : Array_ { foreach ($array->items as $key => $arrayItem) { - if (!$arrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$arrayItem instanceof ArrayItem) { continue; } $value = $arrayItem->value; - if (!$value instanceof \PhpParser\Node\Expr\Variable) { + if (!$value instanceof Variable) { return $array; } if ($this->isVariableUsedInForeach($value, $foreach)) { @@ -107,23 +107,23 @@ CODE_SAMPLE } return $array; } - private function isVariableUsedInForeach(\PhpParser\Node\Expr\Variable $variable, \PhpParser\Node\Stmt\Foreach_ $foreach) : bool + private function isVariableUsedInForeach(Variable $variable, Foreach_ $foreach) : bool { - return (bool) $this->betterNodeFinder->findFirst($foreach->stmts, function (\PhpParser\Node $node) use($variable) : bool { + return (bool) $this->betterNodeFinder->findFirst($foreach->stmts, function (Node $node) use($variable) : bool { return $this->exprUsedInNodeAnalyzer->isUsed($node, $variable); }); } - private function removeForeachValueAndUseArrayKeys(\PhpParser\Node\Stmt\Foreach_ $foreach) : void + private function removeForeachValueAndUseArrayKeys(Foreach_ $foreach) : void { // remove key value $foreach->valueVar = $foreach->keyVar; $foreach->keyVar = null; $foreach->expr = $this->nodeFactory->createFuncCall('array_keys', [$foreach->expr]); } - private function isArrayType(\PhpParser\Node\Expr $expr) : bool + private function isArrayType(Expr $expr) : bool { $exprType = $this->getType($expr); - if ($exprType instanceof \PHPStan\Type\ObjectType) { + if ($exprType instanceof ObjectType) { return \false; } return $exprType->isArray()->yes(); diff --git a/rules/CodeQuality/Rector/FuncCall/AddPregQuoteDelimiterRector.php b/rules/CodeQuality/Rector/FuncCall/AddPregQuoteDelimiterRector.php index 2bcca545b30..eeb206e50b7 100644 --- a/rules/CodeQuality/Rector/FuncCall/AddPregQuoteDelimiterRector.php +++ b/rules/CodeQuality/Rector/FuncCall/AddPregQuoteDelimiterRector.php @@ -11,21 +11,21 @@ use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\FuncCall\AddPregQuoteDelimiterRector\AddPregQuoteDelimiterRectorTest */ -final class AddPregQuoteDelimiterRector extends \Rector\Core\Rector\AbstractRector +final class AddPregQuoteDelimiterRector extends AbstractRector { /** * @var string * @see https://www.php.net/manual/en/reference.pcre.pattern.modifiers.php */ private const ALL_MODIFIERS = 'imsxeADSUXJu'; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add preg_quote delimiter when missing', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add preg_quote delimiter when missing', [new CodeSample(<<<'CODE_SAMPLE' '#' . preg_quote('name') . '#'; CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -38,12 +38,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'preg_quote')) { return null; @@ -56,43 +56,43 @@ CODE_SAMPLE if ($delimiter === null) { return null; } - $node->args[1] = new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\String_($delimiter)); + $node->args[1] = new Arg(new String_($delimiter)); return $node; } - private function determineDelimiter(\PhpParser\Node\Expr\FuncCall $funcCall) : ?string + private function determineDelimiter(FuncCall $funcCall) : ?string { $concat = $this->getUppermostConcat($funcCall); - if (!$concat instanceof \PhpParser\Node\Expr\BinaryOp\Concat) { + if (!$concat instanceof Concat) { return null; } $leftMostConcatNode = $concat->left; - while ($leftMostConcatNode instanceof \PhpParser\Node\Expr\BinaryOp\Concat) { + while ($leftMostConcatNode instanceof Concat) { $leftMostConcatNode = $leftMostConcatNode->left; } $rightMostConcatNode = $concat->right; - while ($rightMostConcatNode instanceof \PhpParser\Node\Expr\BinaryOp\Concat) { + while ($rightMostConcatNode instanceof Concat) { $rightMostConcatNode = $rightMostConcatNode->right; } - if (!$leftMostConcatNode instanceof \PhpParser\Node\Scalar\String_) { + if (!$leftMostConcatNode instanceof String_) { return null; } - $possibleLeftDelimiter = \RectorPrefix20220607\Nette\Utils\Strings::substring($leftMostConcatNode->value, 0, 1); - if (!$rightMostConcatNode instanceof \PhpParser\Node\Scalar\String_) { + $possibleLeftDelimiter = Strings::substring($leftMostConcatNode->value, 0, 1); + if (!$rightMostConcatNode instanceof String_) { return null; } - $possibleRightDelimiter = \RectorPrefix20220607\Nette\Utils\Strings::substring(\rtrim($rightMostConcatNode->value, self::ALL_MODIFIERS), -1, 1); + $possibleRightDelimiter = Strings::substring(\rtrim($rightMostConcatNode->value, self::ALL_MODIFIERS), -1, 1); if ($possibleLeftDelimiter === $possibleRightDelimiter) { return $possibleLeftDelimiter; } return null; } - private function getUppermostConcat(\PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Expr\BinaryOp\Concat + private function getUppermostConcat(FuncCall $funcCall) : ?Concat { $upperMostConcat = null; - $parent = $funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - while ($parent instanceof \PhpParser\Node\Expr\BinaryOp\Concat) { + $parent = $funcCall->getAttribute(AttributeKey::PARENT_NODE); + while ($parent instanceof Concat) { $upperMostConcat = $parent; - $parent = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parent = $parent->getAttribute(AttributeKey::PARENT_NODE); } return $upperMostConcat; } diff --git a/rules/CodeQuality/Rector/FuncCall/ArrayKeysAndInArrayToArrayKeyExistsRector.php b/rules/CodeQuality/Rector/FuncCall/ArrayKeysAndInArrayToArrayKeyExistsRector.php index 595bc4210a0..bb8c1a8775c 100644 --- a/rules/CodeQuality/Rector/FuncCall/ArrayKeysAndInArrayToArrayKeyExistsRector.php +++ b/rules/CodeQuality/Rector/FuncCall/ArrayKeysAndInArrayToArrayKeyExistsRector.php @@ -11,16 +11,16 @@ use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\FunctionLike; use PhpParser\Node\Name; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\FuncCall\ArrayKeysAndInArrayToArrayKeyExistsRector\ArrayKeysAndInArrayToArrayKeyExistsRectorTest */ -final class ArrayKeysAndInArrayToArrayKeyExistsRector extends \Rector\Core\Rector\AbstractRector +final class ArrayKeysAndInArrayToArrayKeyExistsRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace array_keys() and in_array() to array_key_exists()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace array_keys() and in_array() to array_key_exists()', [new CodeSample(<<<'CODE_SAMPLE' function run($packageName, $values) { $keys = array_keys($values); @@ -40,12 +40,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->nodeNameResolver->isName($node, 'in_array')) { return null; @@ -54,61 +54,61 @@ CODE_SAMPLE $secondArg = $args[1]; $arrayVariable = $secondArg->value; $previousAssignArraysKeysFuncCall = $this->findPreviousAssignToArrayKeys($node, $arrayVariable); - if ($previousAssignArraysKeysFuncCall instanceof \PhpParser\Node\Expr\Assign) { + if ($previousAssignArraysKeysFuncCall instanceof Assign) { /** @var FuncCall $arrayKeysFuncCall */ $arrayKeysFuncCall = $previousAssignArraysKeysFuncCall->expr; $this->removeNode($previousAssignArraysKeysFuncCall); return $this->createArrayKeyExists($node, $arrayKeysFuncCall); } - if ($arrayVariable instanceof \PhpParser\Node\Expr\FuncCall && $this->isName($arrayVariable, 'array_keys')) { + if ($arrayVariable instanceof FuncCall && $this->isName($arrayVariable, 'array_keys')) { $arrayKeysFuncCallArgs = $arrayVariable->getArgs(); if (\count($arrayKeysFuncCallArgs) > 1) { return null; } // unwrap array func call $secondArg->value = $arrayKeysFuncCallArgs[0]->value; - $node->name = new \PhpParser\Node\Name('array_key_exists'); + $node->name = new Name('array_key_exists'); unset($node->args[2]); return $node; } return null; } - private function createArrayKeyExists(\PhpParser\Node\Expr\FuncCall $inArrayFuncCall, \PhpParser\Node\Expr\FuncCall $arrayKeysFuncCall) : ?\PhpParser\Node\Expr\FuncCall + private function createArrayKeyExists(FuncCall $inArrayFuncCall, FuncCall $arrayKeysFuncCall) : ?FuncCall { if (!isset($inArrayFuncCall->args[0])) { return null; } - if (!$inArrayFuncCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$inArrayFuncCall->args[0] instanceof Arg) { return null; } if (!isset($arrayKeysFuncCall->args[0])) { return null; } - if (!$arrayKeysFuncCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$arrayKeysFuncCall->args[0] instanceof Arg) { return null; } $arguments = [$inArrayFuncCall->args[0], $arrayKeysFuncCall->args[0]]; - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('array_key_exists'), $arguments); + return new FuncCall(new Name('array_key_exists'), $arguments); } /** * @return null|\PhpParser\Node|\PhpParser\Node\FunctionLike */ - private function findPreviousAssignToArrayKeys(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr $expr) + private function findPreviousAssignToArrayKeys(FuncCall $funcCall, Expr $expr) { - return $this->betterNodeFinder->findFirstPrevious($funcCall, function (\PhpParser\Node $node) use($expr) : bool { + return $this->betterNodeFinder->findFirstPrevious($funcCall, function (Node $node) use($expr) : bool { // breaking out of scope - if ($node instanceof \PhpParser\Node\FunctionLike) { + if ($node instanceof FunctionLike) { return \true; } - if (!$node instanceof \PhpParser\Node\Expr\Assign) { - return !(bool) $this->betterNodeFinder->find($node, function (\PhpParser\Node $subNode) use($expr) : bool { + if (!$node instanceof Assign) { + return !(bool) $this->betterNodeFinder->find($node, function (Node $subNode) use($expr) : bool { return $this->nodeComparator->areNodesEqual($expr, $subNode); }); } if (!$this->nodeComparator->areNodesEqual($expr, $node->var)) { return \false; } - if (!$node->expr instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$node->expr instanceof FuncCall) { return \false; } return $this->nodeNameResolver->isName($node->expr, 'array_keys'); diff --git a/rules/CodeQuality/Rector/FuncCall/ArrayMergeOfNonArraysToSimpleArrayRector.php b/rules/CodeQuality/Rector/FuncCall/ArrayMergeOfNonArraysToSimpleArrayRector.php index 491413d3bee..d21f0222ae1 100644 --- a/rules/CodeQuality/Rector/FuncCall/ArrayMergeOfNonArraysToSimpleArrayRector.php +++ b/rules/CodeQuality/Rector/FuncCall/ArrayMergeOfNonArraysToSimpleArrayRector.php @@ -9,8 +9,8 @@ use PhpParser\Node\Expr\Array_; use PhpParser\Node\Expr\ArrayItem; use PhpParser\Node\Expr\FuncCall; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/aLf96 * @changelog https://3v4l.org/2r26K @@ -18,11 +18,11 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @see \Rector\Tests\CodeQuality\Rector\FuncCall\ArrayMergeOfNonArraysToSimpleArrayRector\ArrayMergeOfNonArraysToSimpleArrayRectorTest */ -final class ArrayMergeOfNonArraysToSimpleArrayRector extends \Rector\Core\Rector\AbstractRector +final class ArrayMergeOfNonArraysToSimpleArrayRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change array_merge of non arrays to array directly', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change array_merge of non arrays to array directly', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function go() @@ -53,32 +53,32 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'array_merge')) { return null; } - $array = new \PhpParser\Node\Expr\Array_(); + $array = new Array_(); $isAssigned = \false; foreach ($node->args as $arg) { // found non Arg? return early - if (!$arg instanceof \PhpParser\Node\Arg) { + if (!$arg instanceof Arg) { return null; } $nestedArrayItem = $arg->value; - if (!$nestedArrayItem instanceof \PhpParser\Node\Expr\Array_) { + if (!$nestedArrayItem instanceof Array_) { return null; } foreach ($nestedArrayItem->items as $nestedArrayItemItem) { if ($nestedArrayItemItem === null) { continue; } - $array->items[] = new \PhpParser\Node\Expr\ArrayItem($nestedArrayItemItem->value, $nestedArrayItemItem->key); + $array->items[] = new ArrayItem($nestedArrayItemItem->value, $nestedArrayItemItem->key); $isAssigned = \true; } } diff --git a/rules/CodeQuality/Rector/FuncCall/CallUserFuncWithArrowFunctionToInlineRector.php b/rules/CodeQuality/Rector/FuncCall/CallUserFuncWithArrowFunctionToInlineRector.php index 7cea5554cb0..2cab815b4fa 100644 --- a/rules/CodeQuality/Rector/FuncCall/CallUserFuncWithArrowFunctionToInlineRector.php +++ b/rules/CodeQuality/Rector/FuncCall/CallUserFuncWithArrowFunctionToInlineRector.php @@ -10,27 +10,27 @@ use PhpParser\Node\Expr\Closure; use PhpParser\Node\Expr\FuncCall; use Rector\Core\Rector\AbstractRector; use Rector\Php74\NodeAnalyzer\ClosureArrowFunctionAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/fuuEF * * @see \Rector\Tests\CodeQuality\Rector\FuncCall\CallUserFuncWithArrowFunctionToInlineRector\CallUserFuncWithArrowFunctionToInlineRectorTest */ -final class CallUserFuncWithArrowFunctionToInlineRector extends \Rector\Core\Rector\AbstractRector +final class CallUserFuncWithArrowFunctionToInlineRector extends AbstractRector { /** * @readonly * @var \Rector\Php74\NodeAnalyzer\ClosureArrowFunctionAnalyzer */ private $closureArrowFunctionAnalyzer; - public function __construct(\Rector\Php74\NodeAnalyzer\ClosureArrowFunctionAnalyzer $closureArrowFunctionAnalyzer) + public function __construct(ClosureArrowFunctionAnalyzer $closureArrowFunctionAnalyzer) { $this->closureArrowFunctionAnalyzer = $closureArrowFunctionAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Refactor call_user_func() with arrow function to direct call', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Refactor call_user_func() with arrow function to direct call', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run() @@ -55,12 +55,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'call_user_func')) { return null; @@ -73,14 +73,14 @@ CODE_SAMPLE return null; } $firstArg = $node->args[0]; - if (!$firstArg instanceof \PhpParser\Node\Arg) { + if (!$firstArg instanceof Arg) { return null; } $firstArgValue = $firstArg->value; - if ($firstArgValue instanceof \PhpParser\Node\Expr\ArrowFunction) { + if ($firstArgValue instanceof ArrowFunction) { return $firstArgValue->expr; } - if ($firstArgValue instanceof \PhpParser\Node\Expr\Closure) { + if ($firstArgValue instanceof Closure) { return $this->closureArrowFunctionAnalyzer->matchArrowFunctionExpr($firstArgValue); } return null; diff --git a/rules/CodeQuality/Rector/FuncCall/ChangeArrayPushToArrayAssignRector.php b/rules/CodeQuality/Rector/FuncCall/ChangeArrayPushToArrayAssignRector.php index 6824bc4b6c2..f3901b21827 100644 --- a/rules/CodeQuality/Rector/FuncCall/ChangeArrayPushToArrayAssignRector.php +++ b/rules/CodeQuality/Rector/FuncCall/ChangeArrayPushToArrayAssignRector.php @@ -10,18 +10,18 @@ use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Stmt\Expression; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://stackoverflow.com/questions/559844/whats-better-to-use-in-php-array-value-or-array-pusharray-value * * @see \Rector\Tests\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector\ChangeArrayPushToArrayAssignRectorTest */ -final class ChangeArrayPushToArrayAssignRector extends \Rector\Core\Rector\AbstractRector +final class ChangeArrayPushToArrayAssignRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change array_push() to direct variable assign', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change array_push() to direct variable assign', [new CodeSample(<<<'CODE_SAMPLE' $items = []; array_push($items, $item); CODE_SAMPLE @@ -36,15 +36,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Expression::class]; + return [Expression::class]; } /** * @param Expression[] $node * @param Expression[]|null $node */ - public function refactor(\PhpParser\Node $node) : ?array + public function refactor(Node $node) : ?array { - if (!$node->expr instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$node->expr instanceof FuncCall) { return null; } $funcCall = $node->expr; @@ -63,11 +63,11 @@ CODE_SAMPLE if ($args === []) { return null; } - $arrayDimFetch = new \PhpParser\Node\Expr\ArrayDimFetch($firstArg->value); + $arrayDimFetch = new ArrayDimFetch($firstArg->value); $newStmts = []; foreach ($args as $key => $arg) { - $assign = new \PhpParser\Node\Expr\Assign($arrayDimFetch, $arg->value); - $assignExpression = new \PhpParser\Node\Stmt\Expression($assign); + $assign = new Assign($arrayDimFetch, $arg->value); + $assignExpression = new Expression($assign); $newStmts[] = $assignExpression; // keep comments of first line if ($key === 0) { @@ -76,7 +76,7 @@ CODE_SAMPLE } return $newStmts; } - private function hasArraySpread(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function hasArraySpread(FuncCall $funcCall) : bool { foreach ($funcCall->getArgs() as $arg) { if ($arg->unpack) { diff --git a/rules/CodeQuality/Rector/FuncCall/CompactToVariablesRector.php b/rules/CodeQuality/Rector/FuncCall/CompactToVariablesRector.php index ffd21d71cb4..a485b5bfd3a 100644 --- a/rules/CodeQuality/Rector/FuncCall/CompactToVariablesRector.php +++ b/rules/CodeQuality/Rector/FuncCall/CompactToVariablesRector.php @@ -18,14 +18,14 @@ use Rector\CodeQuality\NodeAnalyzer\ArrayCompacter; use Rector\CodeQuality\NodeAnalyzer\ArrayItemsAnalyzer; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://stackoverflow.com/a/16319909/1348344 * @changelog https://3v4l.org/8GJEs * @see \Rector\Tests\CodeQuality\Rector\FuncCall\CompactToVariablesRector\CompactToVariablesRectorTest */ -final class CompactToVariablesRector extends \Rector\Core\Rector\AbstractRector +final class CompactToVariablesRector extends AbstractRector { /** * @readonly @@ -42,15 +42,15 @@ final class CompactToVariablesRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\CodeQuality\NodeAnalyzer\ArrayCompacter */ private $arrayCompacter; - public function __construct(\Rector\CodeQuality\CompactConverter $compactConverter, \Rector\CodeQuality\NodeAnalyzer\ArrayItemsAnalyzer $arrayItemsAnalyzer, \Rector\CodeQuality\NodeAnalyzer\ArrayCompacter $arrayCompacter) + public function __construct(CompactConverter $compactConverter, ArrayItemsAnalyzer $arrayItemsAnalyzer, ArrayCompacter $arrayCompacter) { $this->compactConverter = $compactConverter; $this->arrayItemsAnalyzer = $arrayItemsAnalyzer; $this->arrayCompacter = $arrayCompacter; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change compact() call to own array', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change compact() call to own array', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -81,12 +81,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'compact')) { return null; @@ -98,32 +98,32 @@ CODE_SAMPLE $firstArg = $node->args[0]; $firstValue = $firstArg->value; $firstValueStaticType = $this->getType($firstValue); - if (!$firstValueStaticType instanceof \PHPStan\Type\Constant\ConstantArrayType) { + if (!$firstValueStaticType instanceof ConstantArrayType) { return null; } - if ($firstValueStaticType->getItemType() instanceof \PHPStan\Type\MixedType) { + if ($firstValueStaticType->getItemType() instanceof MixedType) { return null; } return $this->refactorAssignArray($firstValue, $node); } - private function refactorAssignedArray(\PhpParser\Node\Expr\Assign $assign, \PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr $expr) : ?\PhpParser\Node\Expr + private function refactorAssignedArray(Assign $assign, FuncCall $funcCall, Expr $expr) : ?Expr { - if (!$assign->expr instanceof \PhpParser\Node\Expr\Array_) { + if (!$assign->expr instanceof Array_) { return null; } $array = $assign->expr; - $assignScope = $assign->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$assignScope instanceof \PHPStan\Analyser\Scope) { + $assignScope = $assign->getAttribute(AttributeKey::SCOPE); + if (!$assignScope instanceof Scope) { return null; } $currentStmt = $this->betterNodeFinder->resolveCurrentStatement($funcCall); - if (!$currentStmt instanceof \PhpParser\Node\Stmt) { + if (!$currentStmt instanceof Stmt) { return null; } $isCompactOfUndefinedVariables = $this->arrayItemsAnalyzer->hasArrayExclusiveDefinedVariableNames($array, $assignScope); if ($isCompactOfUndefinedVariables) { - $funcCallScope = $funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$funcCallScope instanceof \PHPStan\Analyser\Scope) { + $funcCallScope = $funcCall->getAttribute(AttributeKey::SCOPE); + if (!$funcCallScope instanceof Scope) { return null; } $isCompactOfDefinedVariables = $this->arrayItemsAnalyzer->hasArrayExclusiveUndefinedVariableNames($array, $funcCallScope); @@ -137,14 +137,14 @@ CODE_SAMPLE /** @var Arg $firstArg */ $firstArg = $funcCall->args[0]; $assignVariable = $firstArg->value; - $preAssign = new \PhpParser\Node\Expr\Assign($assignVariable, $array); + $preAssign = new Assign($assignVariable, $array); $this->nodesToAddCollector->addNodeBeforeNode($preAssign, $currentStmt, $this->file->getSmartFileInfo()); return $expr; } - private function refactorAssignArray(\PhpParser\Node\Expr $expr, \PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Expr + private function refactorAssignArray(Expr $expr, FuncCall $funcCall) : ?Expr { $previousAssign = $this->betterNodeFinder->findPreviousAssignToExpr($expr); - if (!$previousAssign instanceof \PhpParser\Node\Expr\Assign) { + if (!$previousAssign instanceof Assign) { return null; } return $this->refactorAssignedArray($previousAssign, $funcCall, $expr); diff --git a/rules/CodeQuality/Rector/FuncCall/InlineIsAInstanceOfRector.php b/rules/CodeQuality/Rector/FuncCall/InlineIsAInstanceOfRector.php index 7ff41184b6e..ce0e4bd2bf0 100644 --- a/rules/CodeQuality/Rector/FuncCall/InlineIsAInstanceOfRector.php +++ b/rules/CodeQuality/Rector/FuncCall/InlineIsAInstanceOfRector.php @@ -14,16 +14,16 @@ use PHPStan\Type\ObjectType; use PHPStan\Type\ObjectWithoutClassType; use PHPStan\Type\TypeWithClassName; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\FuncCall\InlineIsAInstanceOfRector\InlineIsAInstanceOfRectorTest */ -final class InlineIsAInstanceOfRector extends \Rector\Core\Rector\AbstractRector +final class InlineIsAInstanceOfRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change is_a() with object and class name check to instanceof', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change is_a() with object and class name check to instanceof', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(object $object) @@ -48,12 +48,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node->name, 'is_a')) { return null; @@ -67,28 +67,28 @@ CODE_SAMPLE if ($className === null) { return null; } - return new \PhpParser\Node\Expr\Instanceof_($firstArgValue, new \PhpParser\Node\Name\FullyQualified($className)); + return new Instanceof_($firstArgValue, new FullyQualified($className)); } - private function resolveClassName(\PhpParser\Node\Expr $expr) : ?string + private function resolveClassName(Expr $expr) : ?string { - if (!$expr instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if (!$expr instanceof ClassConstFetch) { return null; } $type = $this->getType($expr); - if ($type instanceof \PHPStan\Type\Generic\GenericClassStringType) { + if ($type instanceof GenericClassStringType) { $type = $type->getGenericType(); } - if (!$type instanceof \PHPStan\Type\TypeWithClassName) { + if (!$type instanceof TypeWithClassName) { return null; } return $type->getClassName(); } - private function isFirstObjectType(\PhpParser\Node\Expr $expr) : bool + private function isFirstObjectType(Expr $expr) : bool { $exprType = $this->getType($expr); - if ($exprType instanceof \PHPStan\Type\ObjectWithoutClassType) { + if ($exprType instanceof ObjectWithoutClassType) { return \true; } - return $exprType instanceof \PHPStan\Type\ObjectType; + return $exprType instanceof ObjectType; } } diff --git a/rules/CodeQuality/Rector/FuncCall/IntvalToTypeCastRector.php b/rules/CodeQuality/Rector/FuncCall/IntvalToTypeCastRector.php index 269f9802b54..e596130b5a4 100644 --- a/rules/CodeQuality/Rector/FuncCall/IntvalToTypeCastRector.php +++ b/rules/CodeQuality/Rector/FuncCall/IntvalToTypeCastRector.php @@ -8,18 +8,18 @@ use PhpParser\Node\Arg; use PhpParser\Node\Expr\Cast\Int_; use PhpParser\Node\Expr\FuncCall; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://tonyshowoff.com/articles/casting-int-faster-than-intval-in-php/ * * @see \Rector\Tests\CodeQuality\Rector\FuncCall\IntvalToTypeCastRector\IntvalToTypeCastRectorTest */ -final class IntvalToTypeCastRector extends \Rector\Core\Rector\AbstractRector +final class IntvalToTypeCastRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change intval() to faster and readable (int) $value', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change intval() to faster and readable (int) $value', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($value) @@ -44,17 +44,17 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'intval')) { return null; } - if (isset($node->args[1]) && $node->args[1] instanceof \PhpParser\Node\Arg) { + if (isset($node->args[1]) && $node->args[1] instanceof Arg) { $secondArgumentValue = $this->valueResolver->getValue($node->args[1]->value); // default value if ($secondArgumentValue !== 10) { @@ -64,9 +64,9 @@ CODE_SAMPLE if (!isset($node->args[0])) { return null; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } - return new \PhpParser\Node\Expr\Cast\Int_($node->args[0]->value); + return new Int_($node->args[0]->value); } } diff --git a/rules/CodeQuality/Rector/FuncCall/IsAWithStringWithThirdArgumentRector.php b/rules/CodeQuality/Rector/FuncCall/IsAWithStringWithThirdArgumentRector.php index 33e520cad01..be11a5ab631 100644 --- a/rules/CodeQuality/Rector/FuncCall/IsAWithStringWithThirdArgumentRector.php +++ b/rules/CodeQuality/Rector/FuncCall/IsAWithStringWithThirdArgumentRector.php @@ -8,16 +8,16 @@ use PhpParser\Node\Arg; use PhpParser\Node\Expr\FuncCall; use PHPStan\Type\StringType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\FuncCall\IsAWithStringWithThirdArgumentRector\IsAWithStringWithThirdArgumentRectorTest */ -final class IsAWithStringWithThirdArgumentRector extends \Rector\Core\Rector\AbstractRector +final class IsAWithStringWithThirdArgumentRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Complete missing 3rd argument in case is_a() function in case of strings', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Complete missing 3rd argument in case is_a() function in case of strings', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function __construct(string $value) @@ -42,12 +42,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'is_a')) { return null; @@ -55,14 +55,14 @@ CODE_SAMPLE if (isset($node->args[2])) { return null; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } $firstArgumentStaticType = $this->getType($node->args[0]->value); - if (!$firstArgumentStaticType instanceof \PHPStan\Type\StringType) { + if (!$firstArgumentStaticType instanceof StringType) { return null; } - $node->args[2] = new \PhpParser\Node\Arg($this->nodeFactory->createTrue()); + $node->args[2] = new Arg($this->nodeFactory->createTrue()); return $node; } } diff --git a/rules/CodeQuality/Rector/FuncCall/RemoveSoleValueSprintfRector.php b/rules/CodeQuality/Rector/FuncCall/RemoveSoleValueSprintfRector.php index f758823aa0c..f48580eeabf 100644 --- a/rules/CodeQuality/Rector/FuncCall/RemoveSoleValueSprintfRector.php +++ b/rules/CodeQuality/Rector/FuncCall/RemoveSoleValueSprintfRector.php @@ -10,25 +10,25 @@ use PhpParser\Node\Scalar\String_; use PHPStan\Type\StringType; use Rector\Core\NodeAnalyzer\ArgsAnalyzer; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\FuncCall\RemoveSoleValueSprintfRector\RemoveSoleValueSprintfRectorTest */ -final class RemoveSoleValueSprintfRector extends \Rector\Core\Rector\AbstractRector +final class RemoveSoleValueSprintfRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(ArgsAnalyzer $argsAnalyzer) { $this->argsAnalyzer = $argsAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove sprintf() wrapper if not needed', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove sprintf() wrapper if not needed', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -59,12 +59,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'sprintf')) { return null; @@ -78,7 +78,7 @@ CODE_SAMPLE /** @var Arg $firstArg */ $firstArg = $node->args[0]; $maskArgument = $firstArg->value; - if (!$maskArgument instanceof \PhpParser\Node\Scalar\String_) { + if (!$maskArgument instanceof String_) { return null; } if ($maskArgument->value !== '%s') { @@ -88,7 +88,7 @@ CODE_SAMPLE $secondArg = $node->args[1]; $valueArgument = $secondArg->value; $valueType = $this->getType($valueArgument); - if (!$valueType instanceof \PHPStan\Type\StringType) { + if (!$valueType instanceof StringType) { return null; } return $valueArgument; diff --git a/rules/CodeQuality/Rector/FuncCall/SetTypeToCastRector.php b/rules/CodeQuality/Rector/FuncCall/SetTypeToCastRector.php index 776354bae77..56c99f1c337 100644 --- a/rules/CodeQuality/Rector/FuncCall/SetTypeToCastRector.php +++ b/rules/CodeQuality/Rector/FuncCall/SetTypeToCastRector.php @@ -19,31 +19,31 @@ use PhpParser\Node\Stmt\Expression; use Rector\Core\NodeAnalyzer\ArgsAnalyzer; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://stackoverflow.com/questions/5577003/using-settype-in-php-instead-of-typecasting-using-brackets-what-is-the-differen/5577068#5577068 * * @see \Rector\Tests\CodeQuality\Rector\FuncCall\SetTypeToCastRector\SetTypeToCastRectorTest */ -final class SetTypeToCastRector extends \Rector\Core\Rector\AbstractRector +final class SetTypeToCastRector extends AbstractRector { /** * @var array> */ - private const TYPE_TO_CAST = ['array' => \PhpParser\Node\Expr\Cast\Array_::class, 'bool' => \PhpParser\Node\Expr\Cast\Bool_::class, 'boolean' => \PhpParser\Node\Expr\Cast\Bool_::class, 'double' => \PhpParser\Node\Expr\Cast\Double::class, 'float' => \PhpParser\Node\Expr\Cast\Double::class, 'int' => \PhpParser\Node\Expr\Cast\Int_::class, 'integer' => \PhpParser\Node\Expr\Cast\Int_::class, 'object' => \PhpParser\Node\Expr\Cast\Object_::class, 'string' => \PhpParser\Node\Expr\Cast\String_::class]; + private const TYPE_TO_CAST = ['array' => Array_::class, 'bool' => Bool_::class, 'boolean' => Bool_::class, 'double' => Double::class, 'float' => Double::class, 'int' => Int_::class, 'integer' => Int_::class, 'object' => Object_::class, 'string' => String_::class]; /** * @readonly * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(ArgsAnalyzer $argsAnalyzer) { $this->argsAnalyzer = $argsAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes settype() to (type) where possible', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes settype() to (type) where possible', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($foo) @@ -72,12 +72,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'settype')) { return null; @@ -98,22 +98,22 @@ CODE_SAMPLE /** @var Arg $firstArg */ $firstArg = $node->args[0]; $varNode = $firstArg->value; - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); // result of function or probably used - if ($parentNode instanceof \PhpParser\Node\Expr || $parentNode instanceof \PhpParser\Node\Arg) { + if ($parentNode instanceof Expr || $parentNode instanceof Arg) { return null; } if (isset(self::TYPE_TO_CAST[$typeNode])) { $castClass = self::TYPE_TO_CAST[$typeNode]; $castNode = new $castClass($varNode); - if ($parentNode instanceof \PhpParser\Node\Stmt\Expression) { + if ($parentNode instanceof Expression) { // bare expression? → assign - return new \PhpParser\Node\Expr\Assign($varNode, $castNode); + return new Assign($varNode, $castNode); } return $castNode; } if ($typeNode === 'null') { - return new \PhpParser\Node\Expr\Assign($varNode, $this->nodeFactory->createNull()); + return new Assign($varNode, $this->nodeFactory->createNull()); } return $node; } diff --git a/rules/CodeQuality/Rector/FuncCall/SimplifyFuncGetArgsCountRector.php b/rules/CodeQuality/Rector/FuncCall/SimplifyFuncGetArgsCountRector.php index 667601f7ceb..7051ca1e362 100644 --- a/rules/CodeQuality/Rector/FuncCall/SimplifyFuncGetArgsCountRector.php +++ b/rules/CodeQuality/Rector/FuncCall/SimplifyFuncGetArgsCountRector.php @@ -7,36 +7,36 @@ use PhpParser\Node; use PhpParser\Node\Arg; use PhpParser\Node\Expr\FuncCall; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\FuncCall\SimplifyFuncGetArgsCountRector\SimplifyFuncGetArgsCountRectorTest */ -final class SimplifyFuncGetArgsCountRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyFuncGetArgsCountRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Simplify count of func_get_args() to func_num_args()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('count(func_get_args());', 'func_num_args();')]); + return new RuleDefinition('Simplify count of func_get_args() to func_num_args()', [new CodeSample('count(func_get_args());', 'func_num_args();')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'count')) { return null; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } - if (!$node->args[0]->value instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$node->args[0]->value instanceof FuncCall) { return null; } /** @var FuncCall $innerFuncCall */ diff --git a/rules/CodeQuality/Rector/FuncCall/SimplifyInArrayValuesRector.php b/rules/CodeQuality/Rector/FuncCall/SimplifyInArrayValuesRector.php index a3c42e308af..ef971672842 100644 --- a/rules/CodeQuality/Rector/FuncCall/SimplifyInArrayValuesRector.php +++ b/rules/CodeQuality/Rector/FuncCall/SimplifyInArrayValuesRector.php @@ -7,28 +7,28 @@ use PhpParser\Node; use PhpParser\Node\Arg; use PhpParser\Node\Expr\FuncCall; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\FuncCall\SimplifyInArrayValuesRector\SimplifyInArrayValuesRectorTest */ -final class SimplifyInArrayValuesRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyInArrayValuesRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Removes unneeded array_values() in in_array() call', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('in_array("key", array_values($array), true);', 'in_array("key", $array, true);')]); + return new RuleDefinition('Removes unneeded array_values() in in_array() call', [new CodeSample('in_array("key", array_values($array), true);', 'in_array("key", $array, true);')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'in_array')) { return null; @@ -36,10 +36,10 @@ final class SimplifyInArrayValuesRector extends \Rector\Core\Rector\AbstractRect if (!isset($node->args[1])) { return null; } - if (!$node->args[1] instanceof \PhpParser\Node\Arg) { + if (!$node->args[1] instanceof Arg) { return null; } - if (!$node->args[1]->value instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$node->args[1]->value instanceof FuncCall) { return null; } /** @var FuncCall $innerFunCall */ @@ -50,7 +50,7 @@ final class SimplifyInArrayValuesRector extends \Rector\Core\Rector\AbstractRect if (!isset($node->args[0])) { return null; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } $node->args[1] = $innerFunCall->args[0]; diff --git a/rules/CodeQuality/Rector/FuncCall/SimplifyRegexPatternRector.php b/rules/CodeQuality/Rector/FuncCall/SimplifyRegexPatternRector.php index f89585738d0..77a5380a116 100644 --- a/rules/CodeQuality/Rector/FuncCall/SimplifyRegexPatternRector.php +++ b/rules/CodeQuality/Rector/FuncCall/SimplifyRegexPatternRector.php @@ -9,14 +9,14 @@ use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\StaticCall; use Rector\Core\Php\Regex\RegexPatternArgumentManipulator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog http://php.net/manual/en/function.preg-match.php#105924 * * @see \Rector\Tests\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector\SimplifyRegexPatternRectorTest */ -final class SimplifyRegexPatternRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyRegexPatternRector extends AbstractRector { /** * @var array @@ -27,13 +27,13 @@ final class SimplifyRegexPatternRector extends \Rector\Core\Rector\AbstractRecto * @var \Rector\Core\Php\Regex\RegexPatternArgumentManipulator */ private $regexPatternArgumentManipulator; - public function __construct(\Rector\Core\Php\Regex\RegexPatternArgumentManipulator $regexPatternArgumentManipulator) + public function __construct(RegexPatternArgumentManipulator $regexPatternArgumentManipulator) { $this->regexPatternArgumentManipulator = $regexPatternArgumentManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Simplify regex pattern to known ranges', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Simplify regex pattern to known ranges', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($value) @@ -58,12 +58,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [FuncCall::class, StaticCall::class]; } /** * @param FuncCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $patterns = $this->regexPatternArgumentManipulator->matchCallArgumentWithRegexPattern($node); if ($patterns === []) { @@ -73,7 +73,7 @@ CODE_SAMPLE foreach ($patterns as $pattern) { foreach (self::COMPLEX_PATTERN_TO_SIMPLE as $complexPattern => $simple) { $originalValue = $pattern->value; - $simplifiedValue = \RectorPrefix20220607\Nette\Utils\Strings::replace($pattern->value, '#' . \preg_quote($complexPattern, '#') . '#', $simple); + $simplifiedValue = Strings::replace($pattern->value, '#' . \preg_quote($complexPattern, '#') . '#', $simple); if ($originalValue === $simplifiedValue) { continue; } diff --git a/rules/CodeQuality/Rector/FuncCall/SimplifyStrposLowerRector.php b/rules/CodeQuality/Rector/FuncCall/SimplifyStrposLowerRector.php index 6201d730742..6926cf5bc27 100644 --- a/rules/CodeQuality/Rector/FuncCall/SimplifyStrposLowerRector.php +++ b/rules/CodeQuality/Rector/FuncCall/SimplifyStrposLowerRector.php @@ -8,28 +8,28 @@ use PhpParser\Node\Arg; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Name; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\FuncCall\SimplifyStrposLowerRector\SimplifyStrposLowerRectorTest */ -final class SimplifyStrposLowerRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyStrposLowerRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Simplify strpos(strtolower(), "...") calls', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('strpos(strtolower($var), "...")', 'stripos($var, "...")')]); + return new RuleDefinition('Simplify strpos(strtolower(), "...") calls', [new CodeSample('strpos(strtolower($var), "...")', 'stripos($var, "...")')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'strpos')) { return null; @@ -37,10 +37,10 @@ final class SimplifyStrposLowerRector extends \Rector\Core\Rector\AbstractRector if (!isset($node->args[0])) { return null; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } - if (!$node->args[0]->value instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$node->args[0]->value instanceof FuncCall) { return null; } /** @var FuncCall $innerFuncCall */ @@ -50,7 +50,7 @@ final class SimplifyStrposLowerRector extends \Rector\Core\Rector\AbstractRector } // pop 1 level up $node->args[0] = $innerFuncCall->args[0]; - $node->name = new \PhpParser\Node\Name('stripos'); + $node->name = new Name('stripos'); return $node; } } diff --git a/rules/CodeQuality/Rector/FuncCall/SingleInArrayToCompareRector.php b/rules/CodeQuality/Rector/FuncCall/SingleInArrayToCompareRector.php index 7d67f79ccff..fb00aa65dbd 100644 --- a/rules/CodeQuality/Rector/FuncCall/SingleInArrayToCompareRector.php +++ b/rules/CodeQuality/Rector/FuncCall/SingleInArrayToCompareRector.php @@ -11,16 +11,16 @@ use PhpParser\Node\Expr\BinaryOp\Equal; use PhpParser\Node\Expr\BinaryOp\Identical; use PhpParser\Node\Expr\FuncCall; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector\SingleInArrayToCompareRectorTest */ -final class SingleInArrayToCompareRector extends \Rector\Core\Rector\AbstractRector +final class SingleInArrayToCompareRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes in_array() with single element to ===', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes in_array() with single element to ===', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -49,12 +49,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'in_array')) { return null; @@ -62,10 +62,10 @@ CODE_SAMPLE if (!isset($node->args[1])) { return null; } - if (!$node->args[1] instanceof \PhpParser\Node\Arg) { + if (!$node->args[1] instanceof Arg) { return null; } - if (!$node->args[1]->value instanceof \PhpParser\Node\Expr\Array_) { + if (!$node->args[1]->value instanceof Array_) { return null; } /** @var Array_ $arrayNode */ @@ -74,20 +74,20 @@ CODE_SAMPLE return null; } $firstArrayItem = $arrayNode->items[0]; - if (!$firstArrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$firstArrayItem instanceof ArrayItem) { return null; } if (!isset($node->args[0])) { return null; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } $firstArrayItemValue = $firstArrayItem->value; // strict if (isset($node->args[2])) { - return new \PhpParser\Node\Expr\BinaryOp\Identical($node->args[0]->value, $firstArrayItemValue); + return new Identical($node->args[0]->value, $firstArrayItemValue); } - return new \PhpParser\Node\Expr\BinaryOp\Equal($node->args[0]->value, $firstArrayItemValue); + return new Equal($node->args[0]->value, $firstArrayItemValue); } } diff --git a/rules/CodeQuality/Rector/FuncCall/UnwrapSprintfOneArgumentRector.php b/rules/CodeQuality/Rector/FuncCall/UnwrapSprintfOneArgumentRector.php index 7ab863b7048..355045b4c86 100644 --- a/rules/CodeQuality/Rector/FuncCall/UnwrapSprintfOneArgumentRector.php +++ b/rules/CodeQuality/Rector/FuncCall/UnwrapSprintfOneArgumentRector.php @@ -8,26 +8,26 @@ use PhpParser\Node\Arg; use PhpParser\Node\Expr\FuncCall; use Rector\Core\NodeAnalyzer\ArgsAnalyzer; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/5280 * @see \Rector\Tests\CodeQuality\Rector\FuncCall\UnwrapSprintfOneArgumentRector\UnwrapSprintfOneArgumentRectorTest */ -final class UnwrapSprintfOneArgumentRector extends \Rector\Core\Rector\AbstractRector +final class UnwrapSprintfOneArgumentRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(ArgsAnalyzer $argsAnalyzer) { $this->argsAnalyzer = $argsAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('unwrap sprintf() with one argument', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('unwrap sprintf() with one argument', [new CodeSample(<<<'CODE_SAMPLE' echo sprintf('value'); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -40,12 +40,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'sprintf')) { return null; diff --git a/rules/CodeQuality/Rector/FunctionLike/RemoveAlwaysTrueConditionSetInConstructorRector.php b/rules/CodeQuality/Rector/FunctionLike/RemoveAlwaysTrueConditionSetInConstructorRector.php index 65a10cd8a16..572c8360184 100644 --- a/rules/CodeQuality/Rector/FunctionLike/RemoveAlwaysTrueConditionSetInConstructorRector.php +++ b/rules/CodeQuality/Rector/FunctionLike/RemoveAlwaysTrueConditionSetInConstructorRector.php @@ -19,14 +19,14 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\MethodName; use Rector\NodeTypeResolver\PHPStan\Type\StaticTypeAnalyzer; use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://phpstan.org/r/e909844a-084e-427e-92ac-fed3c2aeabab * * @see \Rector\Tests\CodeQuality\Rector\FunctionLike\RemoveAlwaysTrueConditionSetInConstructorRector\RemoveAlwaysTrueConditionSetInConstructorRectorTest */ -final class RemoveAlwaysTrueConditionSetInConstructorRector extends \Rector\Core\Rector\AbstractRector +final class RemoveAlwaysTrueConditionSetInConstructorRector extends AbstractRector { /** * @readonly @@ -38,14 +38,14 @@ final class RemoveAlwaysTrueConditionSetInConstructorRector extends \Rector\Core * @var \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory */ private $typeFactory; - public function __construct(\Rector\NodeTypeResolver\PHPStan\Type\StaticTypeAnalyzer $staticTypeAnalyzer, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory) + public function __construct(StaticTypeAnalyzer $staticTypeAnalyzer, TypeFactory $typeFactory) { $this->staticTypeAnalyzer = $staticTypeAnalyzer; $this->typeFactory = $typeFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('If conditions is always true, perform the content right away', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('If conditions is always true, perform the content right away', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { private $value; @@ -86,16 +86,16 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node * @return null|\PhpParser\Node\Stmt\If_|mixed[] */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { $ifStmt = $this->matchTruableIf($node); - if (!$ifStmt instanceof \PhpParser\Node\Stmt\If_) { + if (!$ifStmt instanceof If_) { return null; } if ($ifStmt->stmts === []) { @@ -107,7 +107,7 @@ CODE_SAMPLE /** * @return \PhpParser\Node\Stmt\If_|null */ - private function matchTruableIf(\PhpParser\Node\Stmt\If_ $if) + private function matchTruableIf(If_ $if) { // just one if if ($if->elseifs !== []) { @@ -118,7 +118,7 @@ CODE_SAMPLE return null; } // only property fetch, because of constructor set - if (!$if->cond instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$if->cond instanceof PropertyFetch) { return null; } $propertyFetchType = $this->resolvePropertyFetchType($if->cond); @@ -127,23 +127,23 @@ CODE_SAMPLE } return $if; } - private function resolvePropertyFetchType(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : \PHPStan\Type\Type + private function resolvePropertyFetchType(PropertyFetch $propertyFetch) : Type { - $classLike = $this->betterNodeFinder->findParentType($propertyFetch, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { - return new \PHPStan\Type\MixedType(); + $classLike = $this->betterNodeFinder->findParentType($propertyFetch, Class_::class); + if (!$classLike instanceof Class_) { + return new MixedType(); } $propertyName = $this->getName($propertyFetch); if ($propertyName === null) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } $property = $classLike->getProperty($propertyName); - if (!$property instanceof \PhpParser\Node\Stmt\Property) { - return new \PHPStan\Type\MixedType(); + if (!$property instanceof Property) { + return new MixedType(); } // anything but private can be changed from outer scope if (!$property->isPrivate()) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } // set in constructor + changed in class $propertyTypeFromConstructor = $this->resolvePropertyTypeAfterConstructor($classLike, $propertyName); @@ -159,10 +159,10 @@ CODE_SAMPLE } return $this->typeFactory->createMixedPassedOrUnionTypeAndKeepConstant($resolvedTypes); } - private function resolvePropertyTypeAfterConstructor(\PhpParser\Node\Stmt\Class_ $class, string $propertyName) : \PHPStan\Type\Type + private function resolvePropertyTypeAfterConstructor(Class_ $class, string $propertyName) : Type { $propertyTypeFromConstructor = null; - $constructClassMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); + $constructClassMethod = $class->getMethod(MethodName::CONSTRUCT); if ($constructClassMethod !== null) { $propertyTypeFromConstructor = $this->resolveAssignedTypeInStmtsByPropertyName((array) $constructClassMethod->stmts, $propertyName); } @@ -170,22 +170,22 @@ CODE_SAMPLE return $propertyTypeFromConstructor; } // undefined property is null by default - return new \PHPStan\Type\NullType(); + return new NullType(); } /** * @param Stmt[] $stmts */ - private function resolveAssignedTypeInStmtsByPropertyName(array $stmts, string $propertyName) : ?\PHPStan\Type\Type + private function resolveAssignedTypeInStmtsByPropertyName(array $stmts, string $propertyName) : ?Type { $resolvedTypes = []; - $this->traverseNodesWithCallable($stmts, function (\PhpParser\Node $node) use($propertyName, &$resolvedTypes) : ?int { - if ($node instanceof \PhpParser\Node\Stmt\ClassMethod && $this->isName($node, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { - return \PhpParser\NodeTraverser::DONT_TRAVERSE_CHILDREN; + $this->traverseNodesWithCallable($stmts, function (Node $node) use($propertyName, &$resolvedTypes) : ?int { + if ($node instanceof ClassMethod && $this->isName($node, MethodName::CONSTRUCT)) { + return NodeTraverser::DONT_TRAVERSE_CHILDREN; } if (!$this->isPropertyFetchAssignOfPropertyName($node, $propertyName)) { return null; } - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + if (!$node instanceof Assign) { return null; } $resolvedTypes[] = $this->getType($node->expr); @@ -199,12 +199,12 @@ CODE_SAMPLE /** * E.g. $this->{value} = x */ - private function isPropertyFetchAssignOfPropertyName(\PhpParser\Node $node, string $propertyName) : bool + private function isPropertyFetchAssignOfPropertyName(Node $node, string $propertyName) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + if (!$node instanceof Assign) { return \false; } - if (!$node->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$node->var instanceof PropertyFetch) { return \false; } return $this->isName($node->var, $propertyName); diff --git a/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php b/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php index 9190334c664..3789143b4d2 100644 --- a/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php +++ b/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php @@ -17,13 +17,13 @@ use Rector\Core\NodeAnalyzer\CallAnalyzer; use Rector\Core\NodeAnalyzer\VariableAnalyzer; use Rector\Core\PhpParser\Node\AssignAndBinaryMap; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see Based on https://github.com/slevomat/coding-standard/blob/master/SlevomatCodingStandard/Sniffs/Variables/UselessVariableSniff.php * @see \Rector\Tests\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector\SimplifyUselessVariableRectorTest */ -final class SimplifyUselessVariableRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyUselessVariableRector extends AbstractRector { /** * @readonly @@ -45,16 +45,16 @@ final class SimplifyUselessVariableRector extends \Rector\Core\Rector\AbstractRe * @var \Rector\CodeQuality\NodeAnalyzer\ReturnAnalyzer */ private $returnAnalyzer; - public function __construct(\Rector\Core\PhpParser\Node\AssignAndBinaryMap $assignAndBinaryMap, \Rector\Core\NodeAnalyzer\VariableAnalyzer $variableAnalyzer, \Rector\Core\NodeAnalyzer\CallAnalyzer $callAnalyzer, \Rector\CodeQuality\NodeAnalyzer\ReturnAnalyzer $returnAnalyzer) + public function __construct(AssignAndBinaryMap $assignAndBinaryMap, VariableAnalyzer $variableAnalyzer, CallAnalyzer $callAnalyzer, ReturnAnalyzer $returnAnalyzer) { $this->assignAndBinaryMap = $assignAndBinaryMap; $this->variableAnalyzer = $variableAnalyzer; $this->callAnalyzer = $callAnalyzer; $this->returnAnalyzer = $returnAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Removes useless variable assigns', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Removes useless variable assigns', [new CodeSample(<<<'CODE_SAMPLE' function () { $a = true; return $a; @@ -72,12 +72,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface::class]; + return [StmtsAwareInterface::class]; } /** * @param StmtsAwareInterface $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $stmts = $node->stmts; if ($stmts === null) { @@ -87,7 +87,7 @@ CODE_SAMPLE if (!isset($stmts[$key - 1])) { continue; } - if (!$stmt instanceof \PhpParser\Node\Stmt\Return_) { + if (!$stmt instanceof Return_) { continue; } $previousStmt = $stmts[$key - 1]; @@ -109,9 +109,9 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Expr\Assign|\PhpParser\Node\Expr\AssignOp $assign */ - private function processSimplifyUselessVariable(\Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface $stmtsAware, \PhpParser\Node\Stmt\Return_ $return, $assign, int $key) : ?\Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface + private function processSimplifyUselessVariable(StmtsAwareInterface $stmtsAware, Return_ $return, $assign, int $key) : ?StmtsAwareInterface { - if (!$assign instanceof \PhpParser\Node\Expr\Assign) { + if (!$assign instanceof Assign) { $binaryClass = $this->assignAndBinaryMap->getAlternative($assign); if ($binaryClass === null) { return null; @@ -123,12 +123,12 @@ CODE_SAMPLE unset($stmtsAware->stmts[$key - 1]); return $stmtsAware; } - private function shouldSkipStmt(\PhpParser\Node\Stmt\Return_ $return, \PhpParser\Node\Stmt $previousStmt) : bool + private function shouldSkipStmt(Return_ $return, Stmt $previousStmt) : bool { if ($this->hasSomeComment($previousStmt)) { return \true; } - if (!$return->expr instanceof \PhpParser\Node\Expr\Variable) { + if (!$return->expr instanceof Variable) { return \true; } if ($this->returnAnalyzer->hasByRefReturn($return)) { @@ -136,12 +136,12 @@ CODE_SAMPLE } /** @var Variable $variable */ $variable = $return->expr; - if (!$previousStmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$previousStmt instanceof Expression) { return \true; } // is variable part of single assign $previousNode = $previousStmt->expr; - if (!$previousNode instanceof \PhpParser\Node\Expr\AssignOp && !$previousNode instanceof \PhpParser\Node\Expr\Assign) { + if (!$previousNode instanceof AssignOp && !$previousNode instanceof Assign) { return \true; } // is the same variable @@ -156,16 +156,16 @@ CODE_SAMPLE } return $this->variableAnalyzer->isUsedByReference($variable); } - private function hasSomeComment(\PhpParser\Node\Stmt $stmt) : bool + private function hasSomeComment(Stmt $stmt) : bool { if ($stmt->getComments() !== []) { return \true; } return $stmt->getDocComment() !== null; } - private function isReturnWithVarAnnotation(\PhpParser\Node\Stmt\Return_ $return) : bool + private function isReturnWithVarAnnotation(Return_ $return) : bool { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($return); - return !$phpDocInfo->getVarType() instanceof \PHPStan\Type\MixedType; + return !$phpDocInfo->getVarType() instanceof MixedType; } } diff --git a/rules/CodeQuality/Rector/Identical/BooleanNotIdenticalToNotIdenticalRector.php b/rules/CodeQuality/Rector/Identical/BooleanNotIdenticalToNotIdenticalRector.php index a6924ad7284..a93bc9f2a1d 100644 --- a/rules/CodeQuality/Rector/Identical/BooleanNotIdenticalToNotIdenticalRector.php +++ b/rules/CodeQuality/Rector/Identical/BooleanNotIdenticalToNotIdenticalRector.php @@ -9,17 +9,17 @@ use PhpParser\Node\Expr\BinaryOp\NotIdentical; use PhpParser\Node\Expr\BooleanNot; use PHPStan\Type\BooleanType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/GoEPq * @see \Rector\Tests\CodeQuality\Rector\Identical\BooleanNotIdenticalToNotIdenticalRector\BooleanNotIdenticalToNotIdenticalRectorTest */ -final class BooleanNotIdenticalToNotIdenticalRector extends \Rector\Core\Rector\AbstractRector +final class BooleanNotIdenticalToNotIdenticalRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Negated identical boolean compare to not identical compare (does not apply to non-bool values)', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Negated identical boolean compare to not identical compare (does not apply to non-bool values)', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -54,42 +54,42 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\Identical::class, \PhpParser\Node\Expr\BooleanNot::class]; + return [Identical::class, BooleanNot::class]; } /** * @param Identical|BooleanNot $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { + if ($node instanceof Identical) { return $this->processIdentical($node); } - if ($node->expr instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { + if ($node->expr instanceof Identical) { $identical = $node->expr; $leftType = $this->getType($identical->left); - if (!$leftType instanceof \PHPStan\Type\BooleanType) { + if (!$leftType instanceof BooleanType) { return null; } $rightType = $this->getType($identical->right); - if (!$rightType instanceof \PHPStan\Type\BooleanType) { + if (!$rightType instanceof BooleanType) { return null; } - return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($identical->left, $identical->right); + return new NotIdentical($identical->left, $identical->right); } return null; } - private function processIdentical(\PhpParser\Node\Expr\BinaryOp\Identical $identical) : ?\PhpParser\Node\Expr\BinaryOp\NotIdentical + private function processIdentical(Identical $identical) : ?NotIdentical { $leftType = $this->getType($identical->left); - if (!$leftType instanceof \PHPStan\Type\BooleanType) { + if (!$leftType instanceof BooleanType) { return null; } $rightType = $this->getType($identical->right); - if (!$rightType instanceof \PHPStan\Type\BooleanType) { + if (!$rightType instanceof BooleanType) { return null; } - if ($identical->left instanceof \PhpParser\Node\Expr\BooleanNot) { - return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($identical->left->expr, $identical->right); + if ($identical->left instanceof BooleanNot) { + return new NotIdentical($identical->left->expr, $identical->right); } return null; } diff --git a/rules/CodeQuality/Rector/Identical/FlipTypeControlToUseExclusiveTypeRector.php b/rules/CodeQuality/Rector/Identical/FlipTypeControlToUseExclusiveTypeRector.php index d73d256a806..e4baa352773 100644 --- a/rules/CodeQuality/Rector/Identical/FlipTypeControlToUseExclusiveTypeRector.php +++ b/rules/CodeQuality/Rector/Identical/FlipTypeControlToUseExclusiveTypeRector.php @@ -22,25 +22,25 @@ use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector\FlipTypeControlToUseExclusiveTypeRectorTest */ -final class FlipTypeControlToUseExclusiveTypeRector extends \Rector\Core\Rector\AbstractRector +final class FlipTypeControlToUseExclusiveTypeRector extends AbstractRector { /** * @readonly * @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover */ private $phpDocTagRemover; - public function __construct(\Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover $phpDocTagRemover) + public function __construct(PhpDocTagRemover $phpDocTagRemover) { $this->phpDocTagRemover = $phpDocTagRemover; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Flip type control to use exclusive type', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Flip type control to use exclusive type', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function __construct(array $values) @@ -72,31 +72,31 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\Identical::class]; + return [Identical::class]; } /** * @param Identical $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->valueResolver->isNull($node->left) && !$this->valueResolver->isNull($node->right)) { return null; } $variable = $this->valueResolver->isNull($node->left) ? $node->right : $node->left; $assign = $this->getVariableAssign($node, $variable); - if (!$assign instanceof \PhpParser\Node\Expr\Assign) { + if (!$assign instanceof Assign) { return null; } - $expression = $assign->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$expression instanceof \PhpParser\Node\Stmt\Expression) { + $expression = $assign->getAttribute(AttributeKey::PARENT_NODE); + if (!$expression instanceof Expression) { return null; } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($expression); $type = $phpDocInfo->getVarType(); - if (!$type instanceof \PHPStan\Type\UnionType) { + if (!$type instanceof UnionType) { $type = $this->getType($assign->expr); } - if (!$type instanceof \PHPStan\Type\UnionType) { + if (!$type instanceof UnionType) { return null; } /** @var Type[] $types */ @@ -106,10 +106,10 @@ CODE_SAMPLE } return $this->processConvertToExclusiveType($types, $variable, $phpDocInfo); } - private function getVariableAssign(\PhpParser\Node\Expr\BinaryOp\Identical $identical, \PhpParser\Node\Expr $expr) : ?\PhpParser\Node + private function getVariableAssign(Identical $identical, Expr $expr) : ?Node { - return $this->betterNodeFinder->findFirstPrevious($identical, function (\PhpParser\Node $node) use($expr) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + return $this->betterNodeFinder->findFirstPrevious($identical, function (Node $node) use($expr) : bool { + if (!$node instanceof Assign) { return \false; } return $this->nodeComparator->areNodesEqual($node->var, $expr); @@ -118,7 +118,7 @@ CODE_SAMPLE /** * @return Type[] */ - private function getTypes(\PHPStan\Type\UnionType $unionType) : array + private function getTypes(UnionType $unionType) : array { $types = $unionType->getTypes(); if (\count($types) > 2) { @@ -137,25 +137,25 @@ CODE_SAMPLE if ($types[0] === $types[1]) { return \true; } - if ($types[0] instanceof \PHPStan\Type\NullType) { + if ($types[0] instanceof NullType) { return \false; } - return !$types[1] instanceof \PHPStan\Type\NullType; + return !$types[1] instanceof NullType; } /** * @param Type[] $types */ - private function processConvertToExclusiveType(array $types, \PhpParser\Node\Expr $expr, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : ?\PhpParser\Node\Expr\BooleanNot + private function processConvertToExclusiveType(array $types, Expr $expr, PhpDocInfo $phpDocInfo) : ?BooleanNot { - $type = $types[0] instanceof \PHPStan\Type\NullType ? $types[1] : $types[0]; - if (!$type instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType && !$type instanceof \PHPStan\Type\ObjectType) { + $type = $types[0] instanceof NullType ? $types[1] : $types[0]; + if (!$type instanceof FullyQualifiedObjectType && !$type instanceof ObjectType) { return null; } $varTagValueNode = $phpDocInfo->getVarTagValueNode(); - if ($varTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) { + if ($varTagValueNode instanceof VarTagValueNode) { $this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $varTagValueNode); } - $fullyQualifiedType = $type instanceof \Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType ? $type->getFullyQualifiedName() : $type->getClassName(); - return new \PhpParser\Node\Expr\BooleanNot(new \PhpParser\Node\Expr\Instanceof_($expr, new \PhpParser\Node\Name\FullyQualified($fullyQualifiedType))); + $fullyQualifiedType = $type instanceof ShortenedObjectType ? $type->getFullyQualifiedName() : $type->getClassName(); + return new BooleanNot(new Instanceof_($expr, new FullyQualified($fullyQualifiedType))); } } diff --git a/rules/CodeQuality/Rector/Identical/GetClassToInstanceOfRector.php b/rules/CodeQuality/Rector/Identical/GetClassToInstanceOfRector.php index 9ab37324ba2..b01297e3df4 100644 --- a/rules/CodeQuality/Rector/Identical/GetClassToInstanceOfRector.php +++ b/rules/CodeQuality/Rector/Identical/GetClassToInstanceOfRector.php @@ -18,12 +18,12 @@ use Rector\Core\Enum\ObjectReference; use Rector\Core\NodeManipulator\BinaryOpManipulator; use Rector\Core\Rector\AbstractRector; use Rector\Php71\ValueObject\TwoNodeMatch; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Identical\GetClassToInstanceOfRector\GetClassToInstanceOfRectorTest */ -final class GetClassToInstanceOfRector extends \Rector\Core\Rector\AbstractRector +final class GetClassToInstanceOfRector extends AbstractRector { /** * @var string[] @@ -34,32 +34,32 @@ final class GetClassToInstanceOfRector extends \Rector\Core\Rector\AbstractRecto * @var \Rector\Core\NodeManipulator\BinaryOpManipulator */ private $binaryOpManipulator; - public function __construct(\Rector\Core\NodeManipulator\BinaryOpManipulator $binaryOpManipulator) + public function __construct(BinaryOpManipulator $binaryOpManipulator) { $this->binaryOpManipulator = $binaryOpManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes comparison with get_class to instanceof', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('if (EventsListener::class === get_class($event->job)) { }', 'if ($event->job instanceof EventsListener) { }')]); + return new RuleDefinition('Changes comparison with get_class to instanceof', [new CodeSample('if (EventsListener::class === get_class($event->job)) { }', 'if ($event->job instanceof EventsListener) { }')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\Identical::class, \PhpParser\Node\Expr\BinaryOp\NotIdentical::class]; + return [Identical::class, NotIdentical::class]; } /** * @param Identical|NotIdentical $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $twoNodeMatch = $this->binaryOpManipulator->matchFirstAndSecondConditionNode($node, function (\PhpParser\Node $node) : bool { + $twoNodeMatch = $this->binaryOpManipulator->matchFirstAndSecondConditionNode($node, function (Node $node) : bool { return $this->isClassReference($node); - }, function (\PhpParser\Node $node) : bool { + }, function (Node $node) : bool { return $this->isGetClassFuncCallNode($node); }); - if (!$twoNodeMatch instanceof \Rector\Php71\ValueObject\TwoNodeMatch) { + if (!$twoNodeMatch instanceof TwoNodeMatch) { return null; } /** @var ClassConstFetch|String_ $firstExpr */ @@ -69,11 +69,11 @@ final class GetClassToInstanceOfRector extends \Rector\Core\Rector\AbstractRecto if (!isset($funcCall->args[0])) { return null; } - if (!$funcCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[0] instanceof Arg) { return null; } $varNode = $funcCall->args[0]->value; - if ($firstExpr instanceof \PhpParser\Node\Scalar\String_) { + if ($firstExpr instanceof String_) { $className = $this->valueResolver->getValue($firstExpr); } else { $className = $this->getName($firstExpr->class); @@ -81,27 +81,27 @@ final class GetClassToInstanceOfRector extends \Rector\Core\Rector\AbstractRecto if ($className === null) { return null; } - if ($className === \Rector\Core\Enum\ObjectReference::PARENT) { + if ($className === ObjectReference::PARENT) { return null; } - $class = \in_array($className, self::NO_NAMESPACED_CLASSNAMES, \true) ? new \PhpParser\Node\Name($className) : new \PhpParser\Node\Name\FullyQualified($className); - $instanceof = new \PhpParser\Node\Expr\Instanceof_($varNode, $class); - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\NotIdentical) { - return new \PhpParser\Node\Expr\BooleanNot($instanceof); + $class = \in_array($className, self::NO_NAMESPACED_CLASSNAMES, \true) ? new Name($className) : new FullyQualified($className); + $instanceof = new Instanceof_($varNode, $class); + if ($node instanceof NotIdentical) { + return new BooleanNot($instanceof); } return $instanceof; } - private function isClassReference(\PhpParser\Node $node) : bool + private function isClassReference(Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if (!$node instanceof ClassConstFetch) { // might be - return $node instanceof \PhpParser\Node\Scalar\String_; + return $node instanceof String_; } return $this->isName($node->name, 'class'); } - private function isGetClassFuncCallNode(\PhpParser\Node $node) : bool + private function isGetClassFuncCallNode(Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$node instanceof FuncCall) { return \false; } return $this->isName($node, 'get_class'); diff --git a/rules/CodeQuality/Rector/Identical/SimplifyArraySearchRector.php b/rules/CodeQuality/Rector/Identical/SimplifyArraySearchRector.php index 0e151ab06da..47c6cd85e41 100644 --- a/rules/CodeQuality/Rector/Identical/SimplifyArraySearchRector.php +++ b/rules/CodeQuality/Rector/Identical/SimplifyArraySearchRector.php @@ -11,54 +11,54 @@ use PhpParser\Node\Expr\FuncCall; use Rector\Core\NodeManipulator\BinaryOpManipulator; use Rector\Core\Rector\AbstractRector; use Rector\Php71\ValueObject\TwoNodeMatch; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Identical\SimplifyArraySearchRector\SimplifyArraySearchRectorTest */ -final class SimplifyArraySearchRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyArraySearchRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeManipulator\BinaryOpManipulator */ private $binaryOpManipulator; - public function __construct(\Rector\Core\NodeManipulator\BinaryOpManipulator $binaryOpManipulator) + public function __construct(BinaryOpManipulator $binaryOpManipulator) { $this->binaryOpManipulator = $binaryOpManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Simplify array_search to in_array', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('array_search("searching", $array) !== false;', 'in_array("searching", $array);'), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('array_search("searching", $array, true) !== false;', 'in_array("searching", $array, true);')]); + return new RuleDefinition('Simplify array_search to in_array', [new CodeSample('array_search("searching", $array) !== false;', 'in_array("searching", $array);'), new CodeSample('array_search("searching", $array, true) !== false;', 'in_array("searching", $array, true);')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\Identical::class, \PhpParser\Node\Expr\BinaryOp\NotIdentical::class]; + return [Identical::class, NotIdentical::class]; } /** * @param Identical|NotIdentical $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $twoNodeMatch = $this->binaryOpManipulator->matchFirstAndSecondConditionNode($node, function (\PhpParser\Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Expr\FuncCall) { + $twoNodeMatch = $this->binaryOpManipulator->matchFirstAndSecondConditionNode($node, function (Node $node) : bool { + if (!$node instanceof FuncCall) { return \false; } return $this->nodeNameResolver->isName($node, 'array_search'); - }, function (\PhpParser\Node $node) : bool { + }, function (Node $node) : bool { return $this->valueResolver->isFalse($node); }); - if (!$twoNodeMatch instanceof \Rector\Php71\ValueObject\TwoNodeMatch) { + if (!$twoNodeMatch instanceof TwoNodeMatch) { return null; } /** @var FuncCall $arraySearchFuncCall */ $arraySearchFuncCall = $twoNodeMatch->getFirstExpr(); $inArrayFuncCall = $this->nodeFactory->createFuncCall('in_array', $arraySearchFuncCall->args); - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { - return new \PhpParser\Node\Expr\BooleanNot($inArrayFuncCall); + if ($node instanceof Identical) { + return new BooleanNot($inArrayFuncCall); } return $inArrayFuncCall; } diff --git a/rules/CodeQuality/Rector/Identical/SimplifyBoolIdenticalTrueRector.php b/rules/CodeQuality/Rector/Identical/SimplifyBoolIdenticalTrueRector.php index d6722726789..d6a1dcb7ae5 100644 --- a/rules/CodeQuality/Rector/Identical/SimplifyBoolIdenticalTrueRector.php +++ b/rules/CodeQuality/Rector/Identical/SimplifyBoolIdenticalTrueRector.php @@ -10,16 +10,16 @@ use PhpParser\Node\Expr\BinaryOp\NotIdentical; use PhpParser\Node\Expr\BooleanNot; use PHPStan\Type\BooleanType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector\SimplifyBoolIdenticalTrueRectorTest */ -final class SimplifyBoolIdenticalTrueRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyBoolIdenticalTrueRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Simplify bool value compare to true or false', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Simplify bool value compare to true or false', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(bool $value, string $items) @@ -46,19 +46,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\Identical::class, \PhpParser\Node\Expr\BinaryOp\NotIdentical::class]; + return [Identical::class, NotIdentical::class]; } /** * @param Identical|NotIdentical $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $leftType = $this->getType($node->left); - if ($leftType instanceof \PHPStan\Type\BooleanType && !$this->valueResolver->isTrueOrFalse($node->left)) { + if ($leftType instanceof BooleanType && !$this->valueResolver->isTrueOrFalse($node->left)) { return $this->processBoolTypeToNotBool($node, $node->left, $node->right); } $rightType = $this->getType($node->right); - if (!$rightType instanceof \PHPStan\Type\BooleanType) { + if (!$rightType instanceof BooleanType) { return null; } if ($this->valueResolver->isTrueOrFalse($node->right)) { @@ -66,37 +66,37 @@ CODE_SAMPLE } return $this->processBoolTypeToNotBool($node, $node->right, $node->left); } - private function processBoolTypeToNotBool(\PhpParser\Node $node, \PhpParser\Node\Expr $leftExpr, \PhpParser\Node\Expr $rightExpr) : ?\PhpParser\Node\Expr + private function processBoolTypeToNotBool(Node $node, Expr $leftExpr, Expr $rightExpr) : ?Expr { - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { + if ($node instanceof Identical) { return $this->refactorIdentical($leftExpr, $rightExpr); } - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\NotIdentical) { + if ($node instanceof NotIdentical) { return $this->refactorNotIdentical($leftExpr, $rightExpr); } return null; } - private function refactorIdentical(\PhpParser\Node\Expr $leftExpr, \PhpParser\Node\Expr $rightExpr) : ?\PhpParser\Node\Expr + private function refactorIdentical(Expr $leftExpr, Expr $rightExpr) : ?Expr { if ($this->valueResolver->isTrue($rightExpr)) { return $leftExpr; } if ($this->valueResolver->isFalse($rightExpr)) { // prevent !! - if ($leftExpr instanceof \PhpParser\Node\Expr\BooleanNot) { + if ($leftExpr instanceof BooleanNot) { return $leftExpr->expr; } - return new \PhpParser\Node\Expr\BooleanNot($leftExpr); + return new BooleanNot($leftExpr); } return null; } - private function refactorNotIdentical(\PhpParser\Node\Expr $leftExpr, \PhpParser\Node\Expr $rightExpr) : ?\PhpParser\Node\Expr + private function refactorNotIdentical(Expr $leftExpr, Expr $rightExpr) : ?Expr { if ($this->valueResolver->isFalse($rightExpr)) { return $leftExpr; } if ($this->valueResolver->isTrue($rightExpr)) { - return new \PhpParser\Node\Expr\BooleanNot($leftExpr); + return new BooleanNot($leftExpr); } return null; } diff --git a/rules/CodeQuality/Rector/Identical/SimplifyConditionsRector.php b/rules/CodeQuality/Rector/Identical/SimplifyConditionsRector.php index d0a8bfb52e7..f83b33d65ce 100644 --- a/rules/CodeQuality/Rector/Identical/SimplifyConditionsRector.php +++ b/rules/CodeQuality/Rector/Identical/SimplifyConditionsRector.php @@ -13,12 +13,12 @@ use Rector\Core\NodeManipulator\BinaryOpManipulator; use Rector\Core\PhpParser\Node\AssignAndBinaryMap; use Rector\Core\Rector\AbstractRector; use Rector\Php71\ValueObject\TwoNodeMatch; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Identical\SimplifyConditionsRector\SimplifyConditionsRectorTest */ -final class SimplifyConditionsRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyConditionsRector extends AbstractRector { /** * @readonly @@ -30,35 +30,35 @@ final class SimplifyConditionsRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Core\NodeManipulator\BinaryOpManipulator */ private $binaryOpManipulator; - public function __construct(\Rector\Core\PhpParser\Node\AssignAndBinaryMap $assignAndBinaryMap, \Rector\Core\NodeManipulator\BinaryOpManipulator $binaryOpManipulator) + public function __construct(AssignAndBinaryMap $assignAndBinaryMap, BinaryOpManipulator $binaryOpManipulator) { $this->assignAndBinaryMap = $assignAndBinaryMap; $this->binaryOpManipulator = $binaryOpManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Simplify conditions', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample("if (! (\$foo !== 'bar')) {...", "if (\$foo === 'bar') {...")]); + return new RuleDefinition('Simplify conditions', [new CodeSample("if (! (\$foo !== 'bar')) {...", "if (\$foo === 'bar') {...")]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BooleanNot::class, \PhpParser\Node\Expr\BinaryOp\Identical::class]; + return [BooleanNot::class, Identical::class]; } /** * @param BooleanNot|Identical $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\BooleanNot) { + if ($node instanceof BooleanNot) { return $this->processBooleanNot($node); } return $this->processIdenticalAndNotIdentical($node); } - private function processBooleanNot(\PhpParser\Node\Expr\BooleanNot $booleanNot) : ?\PhpParser\Node + private function processBooleanNot(BooleanNot $booleanNot) : ?Node { - if (!$booleanNot->expr instanceof \PhpParser\Node\Expr\BinaryOp) { + if (!$booleanNot->expr instanceof BinaryOp) { return null; } if ($this->shouldSkip($booleanNot->expr)) { @@ -66,14 +66,14 @@ final class SimplifyConditionsRector extends \Rector\Core\Rector\AbstractRector } return $this->createInversedBooleanOp($booleanNot->expr); } - private function processIdenticalAndNotIdentical(\PhpParser\Node\Expr\BinaryOp\Identical $identical) : ?\PhpParser\Node + private function processIdenticalAndNotIdentical(Identical $identical) : ?Node { - $twoNodeMatch = $this->binaryOpManipulator->matchFirstAndSecondConditionNode($identical, function (\PhpParser\Node $binaryOp) : bool { - return $binaryOp instanceof \PhpParser\Node\Expr\BinaryOp\Identical || $binaryOp instanceof \PhpParser\Node\Expr\BinaryOp\NotIdentical; - }, function (\PhpParser\Node $binaryOp) : bool { + $twoNodeMatch = $this->binaryOpManipulator->matchFirstAndSecondConditionNode($identical, function (Node $binaryOp) : bool { + return $binaryOp instanceof Identical || $binaryOp instanceof NotIdentical; + }, function (Node $binaryOp) : bool { return $this->valueResolver->isTrueOrFalse($binaryOp); }); - if (!$twoNodeMatch instanceof \Rector\Php71\ValueObject\TwoNodeMatch) { + if (!$twoNodeMatch instanceof TwoNodeMatch) { return $twoNodeMatch; } /** @var Identical|NotIdentical $subBinaryOp */ @@ -87,17 +87,17 @@ final class SimplifyConditionsRector extends \Rector\Core\Rector\AbstractRector /** * Skip too nested binary || binary > binary combinations */ - private function shouldSkip(\PhpParser\Node\Expr\BinaryOp $binaryOp) : bool + private function shouldSkip(BinaryOp $binaryOp) : bool { - if ($binaryOp instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { + if ($binaryOp instanceof BooleanOr) { return \true; } - if ($binaryOp->left instanceof \PhpParser\Node\Expr\BinaryOp) { + if ($binaryOp->left instanceof BinaryOp) { return \true; } - return $binaryOp->right instanceof \PhpParser\Node\Expr\BinaryOp; + return $binaryOp->right instanceof BinaryOp; } - private function createInversedBooleanOp(\PhpParser\Node\Expr\BinaryOp $binaryOp) : ?\PhpParser\Node\Expr\BinaryOp + private function createInversedBooleanOp(BinaryOp $binaryOp) : ?BinaryOp { $inversedBinaryClass = $this->assignAndBinaryMap->getInversed($binaryOp); if ($inversedBinaryClass === null) { diff --git a/rules/CodeQuality/Rector/Identical/StrlenZeroToIdenticalEmptyStringRector.php b/rules/CodeQuality/Rector/Identical/StrlenZeroToIdenticalEmptyStringRector.php index a96c23af00a..7a95ca26b4c 100644 --- a/rules/CodeQuality/Rector/Identical/StrlenZeroToIdenticalEmptyStringRector.php +++ b/rules/CodeQuality/Rector/Identical/StrlenZeroToIdenticalEmptyStringRector.php @@ -12,25 +12,25 @@ use PhpParser\Node\Scalar\String_; use PHPStan\Type\StringType; use Rector\Core\NodeAnalyzer\ArgsAnalyzer; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Identical\StrlenZeroToIdenticalEmptyStringRector\StrlenZeroToIdenticalEmptyStringRectorTest */ -final class StrlenZeroToIdenticalEmptyStringRector extends \Rector\Core\Rector\AbstractRector +final class StrlenZeroToIdenticalEmptyStringRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(ArgsAnalyzer $argsAnalyzer) { $this->argsAnalyzer = $argsAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes strlen comparison to 0 to direct empty string compare', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes strlen comparison to 0 to direct empty string compare', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(string $value) @@ -55,22 +55,22 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\Identical::class]; + return [Identical::class]; } /** * @param Identical $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node->left instanceof \PhpParser\Node\Expr\FuncCall) { + if ($node->left instanceof FuncCall) { return $this->processIdentical($node->right, $node->left); } - if ($node->right instanceof \PhpParser\Node\Expr\FuncCall) { + if ($node->right instanceof FuncCall) { return $this->processIdentical($node->left, $node->right); } return null; } - private function processIdentical(\PhpParser\Node\Expr $expr, \PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Expr\BinaryOp\Identical + private function processIdentical(Expr $expr, FuncCall $funcCall) : ?Identical { if (!$this->isName($funcCall, 'strlen')) { return null; @@ -87,10 +87,10 @@ CODE_SAMPLE $variable = $firstArg->value; // Needs string cast if variable type is not string // see https://github.com/rectorphp/rector/issues/6700 - $isStringType = $this->nodeTypeResolver->getNativeType($variable) instanceof \PHPStan\Type\StringType; + $isStringType = $this->nodeTypeResolver->getNativeType($variable) instanceof StringType; if (!$isStringType) { - return new \PhpParser\Node\Expr\BinaryOp\Identical(new \PhpParser\Node\Expr\Cast\String_($variable), new \PhpParser\Node\Scalar\String_('')); + return new Identical(new Expr\Cast\String_($variable), new String_('')); } - return new \PhpParser\Node\Expr\BinaryOp\Identical($variable, new \PhpParser\Node\Scalar\String_('')); + return new Identical($variable, new String_('')); } } diff --git a/rules/CodeQuality/Rector/If_/CombineIfRector.php b/rules/CodeQuality/Rector/If_/CombineIfRector.php index 5fc417244fd..2cd12749cdb 100644 --- a/rules/CodeQuality/Rector/If_/CombineIfRector.php +++ b/rules/CodeQuality/Rector/If_/CombineIfRector.php @@ -10,25 +10,25 @@ use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode; use Rector\BetterPhpDocParser\Comment\CommentsMerger; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\If_\CombineIfRector\CombineIfRectorTest */ -final class CombineIfRector extends \Rector\Core\Rector\AbstractRector +final class CombineIfRector extends AbstractRector { /** * @readonly * @var \Rector\BetterPhpDocParser\Comment\CommentsMerger */ private $commentsMerger; - public function __construct(\Rector\BetterPhpDocParser\Comment\CommentsMerger $commentsMerger) + public function __construct(CommentsMerger $commentsMerger) { $this->commentsMerger = $commentsMerger; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Merges nested if statements', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Merges nested if statements', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -59,12 +59,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -74,12 +74,12 @@ CODE_SAMPLE if ($this->hasVarTag($subIf)) { return null; } - $node->cond = new \PhpParser\Node\Expr\BinaryOp\BooleanAnd($node->cond, $subIf->cond); + $node->cond = new BooleanAnd($node->cond, $subIf->cond); $node->stmts = $subIf->stmts; $this->commentsMerger->keepComments($node, [$subIf]); return $node; } - private function shouldSkip(\PhpParser\Node\Stmt\If_ $if) : bool + private function shouldSkip(If_ $if) : bool { if ($if->else !== null) { return \true; @@ -90,7 +90,7 @@ CODE_SAMPLE if ($if->elseifs !== []) { return \true; } - if (!$if->stmts[0] instanceof \PhpParser\Node\Stmt\If_) { + if (!$if->stmts[0] instanceof If_) { return \true; } if ($if->stmts[0]->else !== null) { @@ -98,12 +98,12 @@ CODE_SAMPLE } return (bool) $if->stmts[0]->elseifs; } - private function hasVarTag(\PhpParser\Node\Stmt\If_ $if) : bool + private function hasVarTag(If_ $if) : bool { $subIfPhpDocInfo = $this->phpDocInfoFactory->createFromNode($if); - if (!$subIfPhpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$subIfPhpDocInfo instanceof PhpDocInfo) { return \false; } - return $subIfPhpDocInfo->getVarTagValueNode() instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode; + return $subIfPhpDocInfo->getVarTagValueNode() instanceof VarTagValueNode; } } diff --git a/rules/CodeQuality/Rector/If_/ConsecutiveNullCompareReturnsToNullCoalesceQueueRector.php b/rules/CodeQuality/Rector/If_/ConsecutiveNullCompareReturnsToNullCoalesceQueueRector.php index bcc13dac22e..21f31abd0c6 100644 --- a/rules/CodeQuality/Rector/If_/ConsecutiveNullCompareReturnsToNullCoalesceQueueRector.php +++ b/rules/CodeQuality/Rector/If_/ConsecutiveNullCompareReturnsToNullCoalesceQueueRector.php @@ -13,12 +13,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\If_\ConsecutiveNullCompareReturnsToNullCoalesceQueueRector\ConsecutiveNullCompareReturnsToNullCoalesceQueueRectorTest */ -final class ConsecutiveNullCompareReturnsToNullCoalesceQueueRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ConsecutiveNullCompareReturnsToNullCoalesceQueueRector extends AbstractRector implements MinPhpVersionInterface { /** * @var Node[] @@ -33,13 +33,13 @@ final class ConsecutiveNullCompareReturnsToNullCoalesceQueueRector extends \Rect * @var \Rector\Core\NodeManipulator\IfManipulator */ private $ifManipulator; - public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator) + public function __construct(IfManipulator $ifManipulator) { $this->ifManipulator = $ifManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change multiple null compares to ?? queue', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change multiple null compares to ?? queue', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -72,22 +72,22 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $this->reset(); $currentNode = $node; while ($currentNode !== null) { - if ($currentNode instanceof \PhpParser\Node\Stmt\If_) { + if ($currentNode instanceof If_) { $comparedNode = $this->ifManipulator->matchIfNotNullReturnValue($currentNode); if ($comparedNode !== null) { $this->coalescingNodes[] = $comparedNode; $this->nodesToRemove[] = $currentNode; - $currentNode = $currentNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); + $currentNode = $currentNode->getAttribute(AttributeKey::NEXT_NODE); continue; } return null; @@ -107,16 +107,16 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NULL_COALESCE; + return PhpVersionFeature::NULL_COALESCE; } private function reset() : void { $this->coalescingNodes = []; $this->nodesToRemove = []; } - private function isReturnNull(\PhpParser\Node $node) : bool + private function isReturnNull(Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Stmt\Return_) { + if (!$node instanceof Return_) { return \false; } if ($node->expr === null) { @@ -127,16 +127,16 @@ CODE_SAMPLE /** * @param Expr[] $coalescingNodes */ - private function createReturnCoalesceNode(array $coalescingNodes) : \PhpParser\Node\Stmt\Return_ + private function createReturnCoalesceNode(array $coalescingNodes) : Return_ { /** @var Expr $left */ $left = \array_shift($coalescingNodes); /** @var Expr $right */ $right = \array_shift($coalescingNodes); - $coalesceNode = new \PhpParser\Node\Expr\BinaryOp\Coalesce($left, $right); + $coalesceNode = new Coalesce($left, $right); foreach ($coalescingNodes as $coalescingNode) { - $coalesceNode = new \PhpParser\Node\Expr\BinaryOp\Coalesce($coalesceNode, $coalescingNode); + $coalesceNode = new Coalesce($coalesceNode, $coalescingNode); } - return new \PhpParser\Node\Stmt\Return_($coalesceNode); + return new Return_($coalesceNode); } } diff --git a/rules/CodeQuality/Rector/If_/ExplicitBoolCompareRector.php b/rules/CodeQuality/Rector/If_/ExplicitBoolCompareRector.php index 9d712e40fa9..bb34c28220d 100644 --- a/rules/CodeQuality/Rector/If_/ExplicitBoolCompareRector.php +++ b/rules/CodeQuality/Rector/If_/ExplicitBoolCompareRector.php @@ -33,15 +33,15 @@ use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\NodeTypeResolver\TypeAnalyzer\ArrayTypeAnalyzer; use Rector\NodeTypeResolver\TypeAnalyzer\StringTypeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.reddit.com/r/PHP/comments/aqk01p/is_there_a_situation_in_which_if_countarray_0/ * @changelog https://3v4l.org/UCd1b * * @see \Rector\Tests\CodeQuality\Rector\If_\ExplicitBoolCompareRector\ExplicitBoolCompareRectorTest */ -final class ExplicitBoolCompareRector extends \Rector\Core\Rector\AbstractRector +final class ExplicitBoolCompareRector extends AbstractRector { /** * @readonly @@ -53,14 +53,14 @@ final class ExplicitBoolCompareRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\NodeTypeResolver\TypeAnalyzer\ArrayTypeAnalyzer */ private $arrayTypeAnalyzer; - public function __construct(\Rector\NodeTypeResolver\TypeAnalyzer\StringTypeAnalyzer $stringTypeAnalyzer, \Rector\NodeTypeResolver\TypeAnalyzer\ArrayTypeAnalyzer $arrayTypeAnalyzer) + public function __construct(StringTypeAnalyzer $stringTypeAnalyzer, ArrayTypeAnalyzer $arrayTypeAnalyzer) { $this->stringTypeAnalyzer = $stringTypeAnalyzer; $this->arrayTypeAnalyzer = $arrayTypeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Make if conditions more explicit', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Make if conditions more explicit', [new CodeSample(<<<'CODE_SAMPLE' final class SomeController { public function run($items) @@ -89,36 +89,36 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class, \PhpParser\Node\Stmt\ElseIf_::class, \PhpParser\Node\Expr\Ternary::class]; + return [If_::class, ElseIf_::class, Ternary::class]; } /** * @param If_|ElseIf_|Ternary $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { // skip short ternary - if ($node instanceof \PhpParser\Node\Expr\Ternary && $node->if === null) { + if ($node instanceof Ternary && $node->if === null) { return null; } - if ($node->cond instanceof \PhpParser\Node\Expr\BooleanNot) { + if ($node->cond instanceof BooleanNot) { $conditionNode = $node->cond->expr; $isNegated = \true; } else { $conditionNode = $node->cond; $isNegated = \false; } - if ($conditionNode instanceof \PhpParser\Node\Expr\Cast\Bool_) { + if ($conditionNode instanceof Bool_) { return null; } $conditionStaticType = $this->getType($conditionNode); - if ($conditionStaticType instanceof \PHPStan\Type\BooleanType) { + if ($conditionStaticType instanceof BooleanType) { return null; } $newConditionNode = $this->resolveNewConditionNode($conditionNode, $isNegated); - if (!$newConditionNode instanceof \PhpParser\Node\Expr\BinaryOp) { + if (!$newConditionNode instanceof BinaryOp) { return null; } - $nextNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); + $nextNode = $node->getAttribute(AttributeKey::NEXT_NODE); // avoid duplicated ifs when combined with ChangeOrIfReturnToEarlyReturnRector if ($this->shouldSkip($conditionStaticType, $newConditionNode, $nextNode)) { return null; @@ -126,13 +126,13 @@ CODE_SAMPLE $node->cond = $newConditionNode; return $node; } - private function shouldSkip(\PHPStan\Type\Type $conditionStaticType, \PhpParser\Node\Expr\BinaryOp $binaryOp, ?\PhpParser\Node $nextNode) : bool + private function shouldSkip(Type $conditionStaticType, BinaryOp $binaryOp, ?Node $nextNode) : bool { - return $conditionStaticType instanceof \PHPStan\Type\StringType && $binaryOp instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr && !$nextNode instanceof \PhpParser\Node; + return $conditionStaticType instanceof StringType && $binaryOp instanceof BooleanOr && !$nextNode instanceof Node; } - private function resolveNewConditionNode(\PhpParser\Node\Expr $expr, bool $isNegated) : ?\PhpParser\Node\Expr\BinaryOp + private function resolveNewConditionNode(Expr $expr, bool $isNegated) : ?BinaryOp { - if ($expr instanceof \PhpParser\Node\Expr\FuncCall && $this->nodeNameResolver->isName($expr, 'count')) { + if ($expr instanceof FuncCall && $this->nodeNameResolver->isName($expr, 'count')) { return $this->resolveCount($isNegated, $expr); } if ($this->arrayTypeAnalyzer->isArrayType($expr)) { @@ -142,13 +142,13 @@ CODE_SAMPLE return $this->resolveString($isNegated, $expr); } $exprType = $this->getType($expr); - if ($exprType instanceof \PHPStan\Type\IntegerType) { + if ($exprType instanceof IntegerType) { return $this->resolveInteger($isNegated, $expr); } - if ($exprType instanceof \PHPStan\Type\FloatType) { + if ($exprType instanceof FloatType) { return $this->resolveFloat($isNegated, $expr); } - if ($this->nodeTypeResolver->isNullableTypeOfSpecificType($expr, \PHPStan\Type\ObjectType::class)) { + if ($this->nodeTypeResolver->isNullableTypeOfSpecificType($expr, ObjectType::class)) { return $this->resolveNullable($isNegated, $expr); } return null; @@ -156,40 +156,40 @@ CODE_SAMPLE /** * @return \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\Greater|null */ - private function resolveCount(bool $isNegated, \PhpParser\Node\Expr\FuncCall $funcCall) + private function resolveCount(bool $isNegated, FuncCall $funcCall) { $countedType = $this->getType($funcCall->args[0]->value); - if ($countedType instanceof \PHPStan\Type\ArrayType) { + if ($countedType instanceof ArrayType) { return null; } - $lNumber = new \PhpParser\Node\Scalar\LNumber(0); + $lNumber = new LNumber(0); // compare === 0, assumption if ($isNegated) { - return new \PhpParser\Node\Expr\BinaryOp\Identical($funcCall, $lNumber); + return new Identical($funcCall, $lNumber); } - return new \PhpParser\Node\Expr\BinaryOp\Greater($funcCall, $lNumber); + return new Greater($funcCall, $lNumber); } /** * @return Identical|NotIdentical|null */ - private function resolveArray(bool $isNegated, \PhpParser\Node\Expr $expr) : ?\PhpParser\Node\Expr\BinaryOp + private function resolveArray(bool $isNegated, Expr $expr) : ?BinaryOp { - if (!$expr instanceof \PhpParser\Node\Expr\Variable) { + if (!$expr instanceof Variable) { return null; } - $array = new \PhpParser\Node\Expr\Array_([]); + $array = new Array_([]); // compare === [] if ($isNegated) { - return new \PhpParser\Node\Expr\BinaryOp\Identical($expr, $array); + return new Identical($expr, $array); } - return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, $array); + return new NotIdentical($expr, $array); } /** * @return \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical|\PhpParser\Node\Expr\BinaryOp\BooleanAnd|\PhpParser\Node\Expr\BinaryOp\BooleanOr */ - private function resolveString(bool $isNegated, \PhpParser\Node\Expr $expr) + private function resolveString(bool $isNegated, Expr $expr) { - $string = new \PhpParser\Node\Scalar\String_(''); + $string = new String_(''); $identical = $this->resolveIdentical($expr, $isNegated, $string); $value = $this->valueResolver->getValue($expr); // unknown value. may be from parameter @@ -198,7 +198,7 @@ CODE_SAMPLE } $length = \strlen((string) $value); if ($length === 1) { - $string = new \PhpParser\Node\Scalar\String_('0'); + $string = new String_('0'); return $this->resolveIdentical($expr, $isNegated, $string); } return $identical; @@ -206,57 +206,57 @@ CODE_SAMPLE /** * @return \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical */ - private function resolveIdentical(\PhpParser\Node\Expr $expr, bool $isNegated, \PhpParser\Node\Scalar\String_ $string) + private function resolveIdentical(Expr $expr, bool $isNegated, String_ $string) { /** * // compare === '' * * @var Identical|NotIdentical $identical */ - $identical = $isNegated ? new \PhpParser\Node\Expr\BinaryOp\Identical($expr, $string) : new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, $string); + $identical = $isNegated ? new Identical($expr, $string) : new NotIdentical($expr, $string); return $identical; } /** * @param \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical $identical * @return \PhpParser\Node\Expr\BinaryOp\BooleanAnd|\PhpParser\Node\Expr\BinaryOp\BooleanOr */ - private function resolveZeroIdenticalstring($identical, bool $isNegated, \PhpParser\Node\Expr $expr) + private function resolveZeroIdenticalstring($identical, bool $isNegated, Expr $expr) { - $string = new \PhpParser\Node\Scalar\String_('0'); - $zeroIdentical = $isNegated ? new \PhpParser\Node\Expr\BinaryOp\Identical($expr, $string) : new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, $string); - return $isNegated ? new \PhpParser\Node\Expr\BinaryOp\BooleanOr($identical, $zeroIdentical) : new \PhpParser\Node\Expr\BinaryOp\BooleanAnd($identical, $zeroIdentical); + $string = new String_('0'); + $zeroIdentical = $isNegated ? new Identical($expr, $string) : new NotIdentical($expr, $string); + return $isNegated ? new BooleanOr($identical, $zeroIdentical) : new BooleanAnd($identical, $zeroIdentical); } /** * @return \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical */ - private function resolveInteger(bool $isNegated, \PhpParser\Node\Expr $expr) + private function resolveInteger(bool $isNegated, Expr $expr) { - $lNumber = new \PhpParser\Node\Scalar\LNumber(0); + $lNumber = new LNumber(0); if ($isNegated) { - return new \PhpParser\Node\Expr\BinaryOp\Identical($expr, $lNumber); + return new Identical($expr, $lNumber); } - return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, $lNumber); + return new NotIdentical($expr, $lNumber); } /** * @return \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical */ - private function resolveFloat(bool $isNegated, \PhpParser\Node\Expr $expr) + private function resolveFloat(bool $isNegated, Expr $expr) { - $dNumber = new \PhpParser\Node\Scalar\DNumber(0.0); + $dNumber = new DNumber(0.0); if ($isNegated) { - return new \PhpParser\Node\Expr\BinaryOp\Identical($expr, $dNumber); + return new Identical($expr, $dNumber); } - return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, $dNumber); + return new NotIdentical($expr, $dNumber); } /** * @return \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical */ - private function resolveNullable(bool $isNegated, \PhpParser\Node\Expr $expr) + private function resolveNullable(bool $isNegated, Expr $expr) { $constFetch = $this->nodeFactory->createNull(); if ($isNegated) { - return new \PhpParser\Node\Expr\BinaryOp\Identical($expr, $constFetch); + return new Identical($expr, $constFetch); } - return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, $constFetch); + return new NotIdentical($expr, $constFetch); } } diff --git a/rules/CodeQuality/Rector/If_/ShortenElseIfRector.php b/rules/CodeQuality/Rector/If_/ShortenElseIfRector.php index 773cde3a849..a65a0f0e7ce 100644 --- a/rules/CodeQuality/Rector/If_/ShortenElseIfRector.php +++ b/rules/CodeQuality/Rector/If_/ShortenElseIfRector.php @@ -8,16 +8,16 @@ use PhpParser\Node\Stmt\Else_; use PhpParser\Node\Stmt\ElseIf_; use PhpParser\Node\Stmt\If_; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\If_\ShortenElseIfRector\ShortenElseIfRectorTest */ -final class ShortenElseIfRector extends \Rector\Core\Rector\AbstractRector +final class ShortenElseIfRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Shortens else/if to elseif', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Shortens else/if to elseif', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -52,18 +52,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { return $this->shortenElseIf($node); } - private function shortenElseIf(\PhpParser\Node\Stmt\If_ $node) : ?\PhpParser\Node\Stmt\If_ + private function shortenElseIf(If_ $node) : ?If_ { - if (!$node->else instanceof \PhpParser\Node\Stmt\Else_) { + if (!$node->else instanceof Else_) { return null; } $else = $node->else; @@ -71,7 +71,7 @@ CODE_SAMPLE return null; } $if = $else->stmts[0]; - if (!$if instanceof \PhpParser\Node\Stmt\If_) { + if (!$if instanceof If_) { return null; } // Try to shorten the nested if before transforming it to elseif @@ -79,7 +79,7 @@ CODE_SAMPLE if ($refactored !== null) { $if = $refactored; } - $node->elseifs[] = new \PhpParser\Node\Stmt\ElseIf_($if->cond, $if->stmts); + $node->elseifs[] = new ElseIf_($if->cond, $if->stmts); $node->else = $if->else; $node->elseifs = \array_merge($node->elseifs, $if->elseifs); return $node; diff --git a/rules/CodeQuality/Rector/If_/SimplifyIfElseToTernaryRector.php b/rules/CodeQuality/Rector/If_/SimplifyIfElseToTernaryRector.php index 57619238593..fba6b57b626 100644 --- a/rules/CodeQuality/Rector/If_/SimplifyIfElseToTernaryRector.php +++ b/rules/CodeQuality/Rector/If_/SimplifyIfElseToTernaryRector.php @@ -15,12 +15,12 @@ use PhpParser\Node\Stmt\Return_; use Rector\Core\Contract\PhpParser\NodePrinterInterface; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector\SimplifyIfElseToTernaryRectorTest */ -final class SimplifyIfElseToTernaryRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyIfElseToTernaryRector extends AbstractRector { /** * @var int @@ -31,13 +31,13 @@ final class SimplifyIfElseToTernaryRector extends \Rector\Core\Rector\AbstractRe * @var \Rector\Core\Contract\PhpParser\NodePrinterInterface */ private $nodePrinter; - public function __construct(\Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter) + public function __construct(NodePrinterInterface $nodePrinter) { $this->nodePrinter = $nodePrinter; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes if/else for same value as assign to ternary', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes if/else for same value as assign to ternary', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -66,12 +66,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->else === null) { return null; @@ -80,11 +80,11 @@ CODE_SAMPLE return null; } $ifAssignVar = $this->resolveOnlyStmtAssignVar($node->stmts); - if (!$ifAssignVar instanceof \PhpParser\Node\Expr) { + if (!$ifAssignVar instanceof Expr) { return null; } $elseAssignVar = $this->resolveOnlyStmtAssignVar($node->else->stmts); - if (!$elseAssignVar instanceof \PhpParser\Node\Expr) { + if (!$elseAssignVar instanceof Expr) { return null; } if (!$this->nodeComparator->areNodesEqual($ifAssignVar, $elseAssignVar)) { @@ -92,18 +92,18 @@ CODE_SAMPLE } $ternaryIf = $this->resolveOnlyStmtAssignExpr($node->stmts); $ternaryElse = $this->resolveOnlyStmtAssignExpr($node->else->stmts); - if (!$ternaryIf instanceof \PhpParser\Node\Expr) { + if (!$ternaryIf instanceof Expr) { return null; } - if (!$ternaryElse instanceof \PhpParser\Node\Expr) { + if (!$ternaryElse instanceof Expr) { return null; } // has nested ternary → skip, it's super hard to read if ($this->haveNestedTernary([$node->cond, $ternaryIf, $ternaryElse])) { return null; } - $ternary = new \PhpParser\Node\Expr\Ternary($node->cond, $ternaryIf, $ternaryElse); - $assign = new \PhpParser\Node\Expr\Assign($ifAssignVar, $ternary); + $ternary = new Ternary($node->cond, $ternaryIf, $ternaryElse); + $assign = new Assign($ifAssignVar, $ternary); // do not create super long lines if ($this->isNodeTooLong($assign)) { return null; @@ -111,17 +111,17 @@ CODE_SAMPLE if ($this->isNextReturnRemoved($node, $ifAssignVar)) { return null; } - $expression = new \PhpParser\Node\Stmt\Expression($assign); + $expression = new Expression($assign); $this->mirrorComments($expression, $node); return $expression; } - private function isNextReturnRemoved(\PhpParser\Node\Stmt\If_ $if, \PhpParser\Node\Expr $expr) : bool + private function isNextReturnRemoved(If_ $if, Expr $expr) : bool { if (!$this->nodesToRemoveCollector->isActive()) { return \false; } - $next = $if->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if ($next instanceof \PhpParser\Node\Stmt\Return_ && $next->expr instanceof \PhpParser\Node\Expr && $this->nodeComparator->areNodesEqual($next->expr, $expr)) { + $next = $if->getAttribute(AttributeKey::NEXT_NODE); + if ($next instanceof Return_ && $next->expr instanceof Expr && $this->nodeComparator->areNodesEqual($next->expr, $expr)) { $nodesToRemove = $this->nodesToRemoveCollector->getNodesToRemove(); foreach ($nodesToRemove as $nodeToRemove) { if ($this->nodeComparator->areNodesEqual($next, $nodeToRemove)) { @@ -134,17 +134,17 @@ CODE_SAMPLE /** * @param Stmt[] $stmts */ - private function resolveOnlyStmtAssignVar(array $stmts) : ?\PhpParser\Node\Expr + private function resolveOnlyStmtAssignVar(array $stmts) : ?Expr { if (\count($stmts) !== 1) { return null; } $stmt = $stmts[0]; - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { return null; } $stmtExpr = $stmt->expr; - if (!$stmtExpr instanceof \PhpParser\Node\Expr\Assign) { + if (!$stmtExpr instanceof Assign) { return null; } return $stmtExpr->var; @@ -152,17 +152,17 @@ CODE_SAMPLE /** * @param Stmt[] $stmts */ - private function resolveOnlyStmtAssignExpr(array $stmts) : ?\PhpParser\Node\Expr + private function resolveOnlyStmtAssignExpr(array $stmts) : ?Expr { if (\count($stmts) !== 1) { return null; } $stmt = $stmts[0]; - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { return null; } $stmtExpr = $stmt->expr; - if (!$stmtExpr instanceof \PhpParser\Node\Expr\Assign) { + if (!$stmtExpr instanceof Assign) { return null; } return $stmtExpr->expr; @@ -173,16 +173,16 @@ CODE_SAMPLE private function haveNestedTernary(array $nodes) : bool { foreach ($nodes as $node) { - $betterNodeFinderFindInstanceOf = $this->betterNodeFinder->findInstanceOf($node, \PhpParser\Node\Expr\Ternary::class); + $betterNodeFinderFindInstanceOf = $this->betterNodeFinder->findInstanceOf($node, Ternary::class); if ($betterNodeFinderFindInstanceOf !== []) { return \true; } } return \false; } - private function isNodeTooLong(\PhpParser\Node\Expr\Assign $assign) : bool + private function isNodeTooLong(Assign $assign) : bool { $assignContent = $this->nodePrinter->print($assign); - return \RectorPrefix20220607\Nette\Utils\Strings::length($assignContent) > self::LINE_LENGTH_LIMIT; + return Strings::length($assignContent) > self::LINE_LENGTH_LIMIT; } } diff --git a/rules/CodeQuality/Rector/If_/SimplifyIfExactValueReturnValueRector.php b/rules/CodeQuality/Rector/If_/SimplifyIfExactValueReturnValueRector.php index b0c9048d5c5..7a0cebbc119 100644 --- a/rules/CodeQuality/Rector/If_/SimplifyIfExactValueReturnValueRector.php +++ b/rules/CodeQuality/Rector/If_/SimplifyIfExactValueReturnValueRector.php @@ -10,25 +10,25 @@ use PhpParser\Node\Stmt\Return_; use Rector\Core\NodeManipulator\IfManipulator; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\If_\SimplifyIfNullableReturnRector\SimplifyIfNullableReturnRectorTest */ -final class SimplifyIfExactValueReturnValueRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyIfExactValueReturnValueRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeManipulator\IfManipulator */ private $ifManipulator; - public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator) + public function __construct(IfManipulator $ifManipulator) { $this->ifManipulator = $ifManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes compared to value and return of expr to direct return', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes compared to value and return of expr to direct return', [new CodeSample(<<<'CODE_SAMPLE' $value = 'something'; if ($value === 52) { return 52; @@ -47,19 +47,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Stmt\Return_ + public function refactor(Node $node) : ?Return_ { - $nextNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if (!$nextNode instanceof \PhpParser\Node\Stmt\Return_) { + $nextNode = $node->getAttribute(AttributeKey::NEXT_NODE); + if (!$nextNode instanceof Return_) { return null; } $comparedNode = $this->ifManipulator->matchIfValueReturnValue($node); - if (!$comparedNode instanceof \PhpParser\Node\Expr) { + if (!$comparedNode instanceof Expr) { return null; } if (!$this->nodeComparator->areNodesEqual($comparedNode, $nextNode->expr)) { diff --git a/rules/CodeQuality/Rector/If_/SimplifyIfIssetToNullCoalescingRector.php b/rules/CodeQuality/Rector/If_/SimplifyIfIssetToNullCoalescingRector.php index 7b18b7936d8..6ff667a7b3a 100644 --- a/rules/CodeQuality/Rector/If_/SimplifyIfIssetToNullCoalescingRector.php +++ b/rules/CodeQuality/Rector/If_/SimplifyIfIssetToNullCoalescingRector.php @@ -16,25 +16,25 @@ use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\If_; use Rector\Core\NodeAnalyzer\ArgsAnalyzer; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\If_\SimplifyIfIssetToNullCoalescingRector\SimplifyIfIssetToNullCoalescingRectorTest */ -final class SimplifyIfIssetToNullCoalescingRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyIfIssetToNullCoalescingRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(ArgsAnalyzer $argsAnalyzer) { $this->argsAnalyzer = $argsAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Simplify binary if to null coalesce', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Simplify binary if to null coalesce', [new CodeSample(<<<'CODE_SAMPLE' final class SomeController { public function run($possibleStatieYamlFile) @@ -63,12 +63,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -78,15 +78,15 @@ CODE_SAMPLE $valueNode = $issetNode->vars[0]; // various scenarios $ifFirstStmt = $node->stmts[0]; - if (!$ifFirstStmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$ifFirstStmt instanceof Expression) { return null; } $else = $node->else; - if (!$else instanceof \PhpParser\Node\Stmt\Else_) { + if (!$else instanceof Else_) { return null; } $elseFirstStmt = $else->stmts[0]; - if (!$elseFirstStmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$elseFirstStmt instanceof Expression) { return null; } /** @var Assign $firstAssign */ @@ -94,7 +94,7 @@ CODE_SAMPLE /** @var Assign $secondAssign */ $secondAssign = $elseFirstStmt->expr; // 1. array_merge - if (!$firstAssign->expr instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$firstAssign->expr instanceof FuncCall) { return null; } if (!$this->isName($firstAssign->expr, 'array_merge')) { @@ -113,11 +113,11 @@ CODE_SAMPLE if (!$this->nodeComparator->areNodesEqual($secondAssign->expr, $secondArg->value)) { return null; } - $args = [new \PhpParser\Node\Arg(new \PhpParser\Node\Expr\BinaryOp\Coalesce($valueNode, new \PhpParser\Node\Expr\Array_([]))), new \PhpParser\Node\Arg($secondAssign->expr)]; - $funcCall = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('array_merge'), $args); - return new \PhpParser\Node\Expr\Assign($valueNode, $funcCall); + $args = [new Arg(new Coalesce($valueNode, new Array_([]))), new Arg($secondAssign->expr)]; + $funcCall = new FuncCall(new Name('array_merge'), $args); + return new Assign($valueNode, $funcCall); } - private function shouldSkip(\PhpParser\Node\Stmt\If_ $if) : bool + private function shouldSkip(If_ $if) : bool { if ($if->else === null) { return \true; @@ -125,7 +125,7 @@ CODE_SAMPLE if (\count($if->elseifs) > 1) { return \true; } - if (!$if->cond instanceof \PhpParser\Node\Expr\Isset_) { + if (!$if->cond instanceof Isset_) { return \true; } if (!$this->hasOnlyStatementAssign($if)) { @@ -135,20 +135,20 @@ CODE_SAMPLE return \true; } $ifStmt = $if->stmts[0]; - if (!$ifStmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$ifStmt instanceof Expression) { return \true; } - if (!$ifStmt->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$ifStmt->expr instanceof Assign) { return \true; } if (!$this->nodeComparator->areNodesEqual($if->cond->vars[0], $ifStmt->expr->var)) { return \true; } $firstElseStmt = $if->else->stmts[0]; - if (!$firstElseStmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$firstElseStmt instanceof Expression) { return \false; } - if (!$firstElseStmt->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$firstElseStmt->expr instanceof Assign) { return \false; } return !$this->nodeComparator->areNodesEqual($if->cond->vars[0], $firstElseStmt->expr->var); @@ -161,9 +161,9 @@ CODE_SAMPLE if (\count($node->stmts) !== 1) { return \false; } - if (!$node->stmts[0] instanceof \PhpParser\Node\Stmt\Expression) { + if (!$node->stmts[0] instanceof Expression) { return \false; } - return $node->stmts[0]->expr instanceof \PhpParser\Node\Expr\Assign; + return $node->stmts[0]->expr instanceof Assign; } } diff --git a/rules/CodeQuality/Rector/If_/SimplifyIfNotNullReturnRector.php b/rules/CodeQuality/Rector/If_/SimplifyIfNotNullReturnRector.php index af770b01b79..84ac231c6c0 100644 --- a/rules/CodeQuality/Rector/If_/SimplifyIfNotNullReturnRector.php +++ b/rules/CodeQuality/Rector/If_/SimplifyIfNotNullReturnRector.php @@ -10,25 +10,25 @@ use PhpParser\Node\Stmt\Return_; use Rector\Core\NodeManipulator\IfManipulator; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\If_\SimplifyIfNotNullReturnRector\SimplifyIfNotNullReturnRectorTest */ -final class SimplifyIfNotNullReturnRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyIfNotNullReturnRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeManipulator\IfManipulator */ private $ifManipulator; - public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator) + public function __construct(IfManipulator $ifManipulator) { $this->ifManipulator = $ifManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes redundant null check to instant return', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes redundant null check to instant return', [new CodeSample(<<<'CODE_SAMPLE' $newNode = 'something'; if ($newNode !== null) { return $newNode; @@ -47,18 +47,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Stmt + public function refactor(Node $node) : ?Stmt { $comparedNode = $this->ifManipulator->matchIfNotNullReturnValue($node); if ($comparedNode !== null) { $insideIfNode = $node->stmts[0]; - $nextNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if (!$nextNode instanceof \PhpParser\Node\Stmt\Return_) { + $nextNode = $node->getAttribute(AttributeKey::NEXT_NODE); + if (!$nextNode instanceof Return_) { return null; } if ($nextNode->expr === null) { diff --git a/rules/CodeQuality/Rector/If_/SimplifyIfNullableReturnRector.php b/rules/CodeQuality/Rector/If_/SimplifyIfNullableReturnRector.php index 398633768fa..af6e4a9667a 100644 --- a/rules/CodeQuality/Rector/If_/SimplifyIfNullableReturnRector.php +++ b/rules/CodeQuality/Rector/If_/SimplifyIfNullableReturnRector.php @@ -22,12 +22,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\If_\SimplifyIfNullableReturnRector\SimplifyIfNullableReturnRectorTest */ -final class SimplifyIfNullableReturnRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyIfNullableReturnRector extends AbstractRector { /** * @readonly @@ -44,15 +44,15 @@ final class SimplifyIfNullableReturnRector extends \Rector\Core\Rector\AbstractR * @var \Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover */ private $varTagRemover; - public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator, \Rector\CodeQuality\TypeResolver\AssignVariableTypeResolver $assignVariableTypeResolver, \Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover $varTagRemover) + public function __construct(IfManipulator $ifManipulator, AssignVariableTypeResolver $assignVariableTypeResolver, VarTagRemover $varTagRemover) { $this->ifManipulator = $ifManipulator; $this->assignVariableTypeResolver = $assignVariableTypeResolver; $this->varTagRemover = $varTagRemover; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Direct return on if nullable check before return', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Direct return on if nullable check before return', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -83,12 +83,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -96,10 +96,10 @@ CODE_SAMPLE /** @var BooleanNot|Instanceof_ $cond */ $cond = $node->cond; /** @var Instanceof_ $instanceof */ - $instanceof = $cond instanceof \PhpParser\Node\Expr\BooleanNot ? $cond->expr : $cond; + $instanceof = $cond instanceof BooleanNot ? $cond->expr : $cond; $variable = $instanceof->expr; $class = $instanceof->class; - if (!$class instanceof \PhpParser\Node\Name) { + if (!$class instanceof Name) { return null; } /** @var Return_ $returnIfStmt */ @@ -107,24 +107,24 @@ CODE_SAMPLE if ($this->isIfStmtReturnIncorrect($cond, $variable, $returnIfStmt)) { return null; } - $previous = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_NODE); - if (!$previous instanceof \PhpParser\Node\Stmt\Expression) { + $previous = $node->getAttribute(AttributeKey::PREVIOUS_NODE); + if (!$previous instanceof Expression) { return null; } $previousAssign = $previous->expr; - if (!$previousAssign instanceof \PhpParser\Node\Expr\Assign) { + if (!$previousAssign instanceof Assign) { return null; } if (!$this->nodeComparator->areNodesEqual($previousAssign->var, $variable)) { return null; } /** @var Return_ $next */ - $next = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); + $next = $node->getAttribute(AttributeKey::NEXT_NODE); if ($this->isNextReturnIncorrect($cond, $variable, $next)) { return null; } $variableType = $this->assignVariableTypeResolver->resolve($previousAssign); - if (!$variableType instanceof \PHPStan\Type\UnionType) { + if (!$variableType instanceof UnionType) { return null; } $className = $class->toString(); @@ -134,41 +134,41 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Expr\BooleanNot|\PhpParser\Node\Expr\Instanceof_ $expr */ - private function isIfStmtReturnIncorrect($expr, \PhpParser\Node\Expr $variable, \PhpParser\Node\Stmt\Return_ $return) : bool + private function isIfStmtReturnIncorrect($expr, Expr $variable, Return_ $return) : bool { - if (!$return->expr instanceof \PhpParser\Node\Expr) { + if (!$return->expr instanceof Expr) { return \true; } - if ($expr instanceof \PhpParser\Node\Expr\BooleanNot && !$this->valueResolver->isNull($return->expr)) { + if ($expr instanceof BooleanNot && !$this->valueResolver->isNull($return->expr)) { return \true; } - return $expr instanceof \PhpParser\Node\Expr\Instanceof_ && !$this->nodeComparator->areNodesEqual($variable, $return->expr); + return $expr instanceof Instanceof_ && !$this->nodeComparator->areNodesEqual($variable, $return->expr); } /** * @param \PhpParser\Node\Expr\BooleanNot|\PhpParser\Node\Expr\Instanceof_ $expr */ - private function isNextReturnIncorrect($expr, \PhpParser\Node\Expr $variable, \PhpParser\Node\Stmt\Return_ $return) : bool + private function isNextReturnIncorrect($expr, Expr $variable, Return_ $return) : bool { - if (!$return->expr instanceof \PhpParser\Node\Expr) { + if (!$return->expr instanceof Expr) { return \true; } - if ($expr instanceof \PhpParser\Node\Expr\BooleanNot && !$this->nodeComparator->areNodesEqual($return->expr, $variable)) { + if ($expr instanceof BooleanNot && !$this->nodeComparator->areNodesEqual($return->expr, $variable)) { return \true; } - return $expr instanceof \PhpParser\Node\Expr\Instanceof_ && !$this->valueResolver->isNull($return->expr); + return $expr instanceof Instanceof_ && !$this->valueResolver->isNull($return->expr); } /** * @param Type[] $types */ - private function processSimplifyNullableReturn(\PHPStan\Type\UnionType $unionType, array $types, string $className, \PhpParser\Node\Stmt\Return_ $return, \PhpParser\Node\Stmt\Expression $expression, \PhpParser\Node\Expr $expr) : ?\PhpParser\Node\Stmt\Return_ + private function processSimplifyNullableReturn(UnionType $unionType, array $types, string $className, Return_ $return, Expression $expression, Expr $expr) : ?Return_ { if (\count($types) > 2) { return null; } - if ($types[0] instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType && $types[1] instanceof \PHPStan\Type\NullType && $className === $types[0]->getClassName()) { + if ($types[0] instanceof FullyQualifiedObjectType && $types[1] instanceof NullType && $className === $types[0]->getClassName()) { return $this->removeAndReturn($return, $expression, $expr, $unionType); } - if ($types[0] instanceof \PHPStan\Type\NullType && $types[1] instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType && $className === $types[1]->getClassName()) { + if ($types[0] instanceof NullType && $types[1] instanceof FullyQualifiedObjectType && $className === $types[1]->getClassName()) { return $this->removeAndReturn($return, $expression, $expr, $unionType); } if ($this->isNotTypedNullable($types, $className)) { @@ -181,36 +181,36 @@ CODE_SAMPLE */ private function isNotTypedNullable(array $types, string $className) : bool { - if (!$types[0] instanceof \PHPStan\Type\ObjectType) { + if (!$types[0] instanceof ObjectType) { return \true; } - if (!$types[1] instanceof \PHPStan\Type\NullType) { + if (!$types[1] instanceof NullType) { return \true; } return $className !== $types[0]->getClassName(); } - private function removeAndReturn(\PhpParser\Node\Stmt\Return_ $return, \PhpParser\Node\Stmt\Expression $expression, \PhpParser\Node\Expr $expr, \PHPStan\Type\UnionType $unionType) : \PhpParser\Node\Stmt\Return_ + private function removeAndReturn(Return_ $return, Expression $expression, Expr $expr, UnionType $unionType) : Return_ { $this->removeNode($return); $this->removeNode($expression); - $return = new \PhpParser\Node\Stmt\Return_($expr); + $return = new Return_($expr); $this->varTagRemover->removeVarPhpTagValueNodeIfNotComment($expression, $unionType); $this->mirrorComments($return, $expression); return $return; } - private function shouldSkip(\PhpParser\Node\Stmt\If_ $if) : bool + private function shouldSkip(If_ $if) : bool { - if (!$this->ifManipulator->isIfWithOnly($if, \PhpParser\Node\Stmt\Return_::class)) { + if (!$this->ifManipulator->isIfWithOnly($if, Return_::class)) { return \true; } - $next = $if->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if (!$next instanceof \PhpParser\Node\Stmt\Return_) { + $next = $if->getAttribute(AttributeKey::NEXT_NODE); + if (!$next instanceof Return_) { return \true; } $cond = $if->cond; - if (!$cond instanceof \PhpParser\Node\Expr\BooleanNot) { - return !$cond instanceof \PhpParser\Node\Expr\Instanceof_; + if (!$cond instanceof BooleanNot) { + return !$cond instanceof Instanceof_; } - return !$cond->expr instanceof \PhpParser\Node\Expr\Instanceof_; + return !$cond->expr instanceof Instanceof_; } } diff --git a/rules/CodeQuality/Rector/If_/SimplifyIfReturnBoolRector.php b/rules/CodeQuality/Rector/If_/SimplifyIfReturnBoolRector.php index cbd9a84bbc2..c53ed058b6f 100644 --- a/rules/CodeQuality/Rector/If_/SimplifyIfReturnBoolRector.php +++ b/rules/CodeQuality/Rector/If_/SimplifyIfReturnBoolRector.php @@ -15,12 +15,12 @@ use Rector\CodeQuality\NodeManipulator\ExprBoolCaster; use Rector\Core\Contract\PhpParser\NodePrinterInterface; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector\SimplifyIfReturnBoolRectorTest */ -final class SimplifyIfReturnBoolRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyIfReturnBoolRector extends AbstractRector { /** * @readonly @@ -37,15 +37,15 @@ final class SimplifyIfReturnBoolRector extends \Rector\Core\Rector\AbstractRecto * @var \Rector\Core\Contract\PhpParser\NodePrinterInterface */ private $nodePrinter; - public function __construct(\Rector\BetterPhpDocParser\Comment\CommentsMerger $commentsMerger, \Rector\CodeQuality\NodeManipulator\ExprBoolCaster $exprBoolCaster, \Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter) + public function __construct(CommentsMerger $commentsMerger, ExprBoolCaster $exprBoolCaster, NodePrinterInterface $nodePrinter) { $this->commentsMerger = $commentsMerger; $this->exprBoolCaster = $exprBoolCaster; $this->nodePrinter = $nodePrinter; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Shortens if return false/true to direct return', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Shortens if return false/true to direct return', [new CodeSample(<<<'CODE_SAMPLE' if (strpos($docToken->getContent(), "\n") === false) { return true; } @@ -59,12 +59,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -72,7 +72,7 @@ CODE_SAMPLE /** @var Return_ $ifInnerNode */ $ifInnerNode = $node->stmts[0]; /** @var Return_ $nextNode */ - $nextNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); + $nextNode = $node->getAttribute(AttributeKey::NEXT_NODE); /** @var Node $innerIfInnerNode */ $innerIfInnerNode = $ifInnerNode->expr; if ($this->valueResolver->isTrue($innerIfInnerNode)) { @@ -80,8 +80,8 @@ CODE_SAMPLE } elseif ($this->valueResolver->isFalse($innerIfInnerNode)) { /** @var Expr $expr */ $expr = $nextNode->expr; - if ($node->cond instanceof \PhpParser\Node\Expr\BinaryOp\NotIdentical && $this->valueResolver->isTrue($expr)) { - $node->cond = new \PhpParser\Node\Expr\BinaryOp\Identical($node->cond->left, $node->cond->right); + if ($node->cond instanceof NotIdentical && $this->valueResolver->isTrue($expr)) { + $node->cond = new Identical($node->cond->left, $node->cond->right); $newReturnNode = $this->processReturnTrue($node, $nextNode); } else { $newReturnNode = $this->processReturnFalse($node, $nextNode); @@ -96,7 +96,7 @@ CODE_SAMPLE $this->removeNode($nextNode); return $newReturnNode; } - private function shouldSkip(\PhpParser\Node\Stmt\If_ $if) : bool + private function shouldSkip(If_ $if) : bool { if ($if->elseifs !== []) { return \true; @@ -114,11 +114,11 @@ CODE_SAMPLE if (!$this->valueResolver->isTrueOrFalse($returnedExpr)) { return \true; } - $nextNode = $if->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if (!$nextNode instanceof \PhpParser\Node\Stmt\Return_) { + $nextNode = $if->getAttribute(AttributeKey::NEXT_NODE); + if (!$nextNode instanceof Return_) { return \true; } - if (!$nextNode->expr instanceof \PhpParser\Node\Expr) { + if (!$nextNode->expr instanceof Expr) { return \true; } // negate + negate → skip for now @@ -129,20 +129,20 @@ CODE_SAMPLE if (\strpos($condString, '!=') === \false) { return !$this->valueResolver->isTrueOrFalse($nextNode->expr); } - return !$if->cond instanceof \PhpParser\Node\Expr\BinaryOp\NotIdentical; + return !$if->cond instanceof NotIdentical; } - private function processReturnTrue(\PhpParser\Node\Stmt\If_ $if, \PhpParser\Node\Stmt\Return_ $nextReturnNode) : \PhpParser\Node\Stmt\Return_ + private function processReturnTrue(If_ $if, Return_ $nextReturnNode) : Return_ { - if ($if->cond instanceof \PhpParser\Node\Expr\BooleanNot && $nextReturnNode->expr !== null && $this->valueResolver->isTrue($nextReturnNode->expr)) { - return new \PhpParser\Node\Stmt\Return_($this->exprBoolCaster->boolCastOrNullCompareIfNeeded($if->cond->expr)); + if ($if->cond instanceof BooleanNot && $nextReturnNode->expr !== null && $this->valueResolver->isTrue($nextReturnNode->expr)) { + return new Return_($this->exprBoolCaster->boolCastOrNullCompareIfNeeded($if->cond->expr)); } - return new \PhpParser\Node\Stmt\Return_($this->exprBoolCaster->boolCastOrNullCompareIfNeeded($if->cond)); + return new Return_($this->exprBoolCaster->boolCastOrNullCompareIfNeeded($if->cond)); } - private function processReturnFalse(\PhpParser\Node\Stmt\If_ $if, \PhpParser\Node\Stmt\Return_ $nextReturnNode) : ?\PhpParser\Node\Stmt\Return_ + private function processReturnFalse(If_ $if, Return_ $nextReturnNode) : ?Return_ { - if ($if->cond instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { - $notIdentical = new \PhpParser\Node\Expr\BinaryOp\NotIdentical($if->cond->left, $if->cond->right); - return new \PhpParser\Node\Stmt\Return_($this->exprBoolCaster->boolCastOrNullCompareIfNeeded($notIdentical)); + if ($if->cond instanceof Identical) { + $notIdentical = new NotIdentical($if->cond->left, $if->cond->right); + return new Return_($this->exprBoolCaster->boolCastOrNullCompareIfNeeded($notIdentical)); } if ($nextReturnNode->expr === null) { return null; @@ -150,15 +150,15 @@ CODE_SAMPLE if (!$this->valueResolver->isTrue($nextReturnNode->expr)) { return null; } - if ($if->cond instanceof \PhpParser\Node\Expr\BooleanNot) { - return new \PhpParser\Node\Stmt\Return_($this->exprBoolCaster->boolCastOrNullCompareIfNeeded($if->cond->expr)); + if ($if->cond instanceof BooleanNot) { + return new Return_($this->exprBoolCaster->boolCastOrNullCompareIfNeeded($if->cond->expr)); } - return new \PhpParser\Node\Stmt\Return_($this->exprBoolCaster->boolCastOrNullCompareIfNeeded(new \PhpParser\Node\Expr\BooleanNot($if->cond))); + return new Return_($this->exprBoolCaster->boolCastOrNullCompareIfNeeded(new BooleanNot($if->cond))); } /** * Matches: "else if" */ - private function isElseSeparatedThenIf(\PhpParser\Node\Stmt\If_ $if) : bool + private function isElseSeparatedThenIf(If_ $if) : bool { if ($if->else === null) { return \false; @@ -167,9 +167,9 @@ CODE_SAMPLE return \false; } $onlyStmt = $if->else->stmts[0]; - return $onlyStmt instanceof \PhpParser\Node\Stmt\If_; + return $onlyStmt instanceof If_; } - private function isIfWithSingleReturnExpr(\PhpParser\Node\Stmt\If_ $if) : bool + private function isIfWithSingleReturnExpr(If_ $if) : bool { if (\count($if->stmts) !== 1) { return \false; @@ -178,7 +178,7 @@ CODE_SAMPLE return \false; } $ifInnerNode = $if->stmts[0]; - if (!$ifInnerNode instanceof \PhpParser\Node\Stmt\Return_) { + if (!$ifInnerNode instanceof Return_) { return \false; } // return must have value diff --git a/rules/CodeQuality/Rector/Include_/AbsolutizeRequireAndIncludePathRector.php b/rules/CodeQuality/Rector/Include_/AbsolutizeRequireAndIncludePathRector.php index 6bd6f35787b..db5b731a3b3 100644 --- a/rules/CodeQuality/Rector/Include_/AbsolutizeRequireAndIncludePathRector.php +++ b/rules/CodeQuality/Rector/Include_/AbsolutizeRequireAndIncludePathRector.php @@ -10,18 +10,18 @@ use PhpParser\Node\Expr\Include_; use PhpParser\Node\Scalar\MagicConst\Dir; use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/symplify/CodingStandard#includerequire-should-be-followed-by-absolute-path * * @see \Rector\Tests\CodeQuality\Rector\Include_\AbsolutizeRequireAndIncludePathRector\AbsolutizeRequireAndIncludePathRectorTest */ -final class AbsolutizeRequireAndIncludePathRector extends \Rector\Core\Rector\AbstractRector +final class AbsolutizeRequireAndIncludePathRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('include/require to absolute path. This Rector might introduce backwards incompatible code, when the include/require being changed depends on the current working directory.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('include/require to absolute path. This Rector might introduce backwards incompatible code, when the include/require being changed depends on the current working directory.', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -50,18 +50,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Include_::class]; + return [Include_::class]; } /** * @param Include_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node->expr instanceof \PhpParser\Node\Expr\BinaryOp\Concat && $node->expr->left instanceof \PhpParser\Node\Scalar\String_ && $this->isRefactorableStringPath($node->expr->left)) { + if ($node->expr instanceof Concat && $node->expr->left instanceof String_ && $this->isRefactorableStringPath($node->expr->left)) { $node->expr->left = $this->prefixWithDirConstant($node->expr->left); return $node; } - if (!$node->expr instanceof \PhpParser\Node\Scalar\String_) { + if (!$node->expr instanceof String_) { return null; } if (!$this->isRefactorableStringPath($node->expr)) { @@ -82,34 +82,34 @@ CODE_SAMPLE } // add preslash to string if (\strncmp($includeValue, './', \strlen('./')) === 0) { - $node->expr->value = \RectorPrefix20220607\Nette\Utils\Strings::substring($includeValue, 1); + $node->expr->value = Strings::substring($includeValue, 1); } else { $node->expr->value = '/' . $includeValue; } $node->expr = $this->prefixWithDirConstant($node->expr); return $node; } - private function isRefactorableStringPath(\PhpParser\Node\Scalar\String_ $string) : bool + private function isRefactorableStringPath(String_ $string) : bool { return \strncmp($string->value, 'phar://', \strlen('phar://')) !== 0; } - private function prefixWithDirConstant(\PhpParser\Node\Scalar\String_ $string) : \PhpParser\Node\Expr\BinaryOp\Concat + private function prefixWithDirConstant(String_ $string) : Concat { $this->removeExtraDotSlash($string); $this->prependSlashIfMissing($string); - return new \PhpParser\Node\Expr\BinaryOp\Concat(new \PhpParser\Node\Scalar\MagicConst\Dir(), $string); + return new Concat(new Dir(), $string); } /** * Remove "./" which would break the path */ - private function removeExtraDotSlash(\PhpParser\Node\Scalar\String_ $string) : void + private function removeExtraDotSlash(String_ $string) : void { if (\strncmp($string->value, './', \strlen('./')) !== 0) { return; } - $string->value = \RectorPrefix20220607\Nette\Utils\Strings::replace($string->value, '#^\\.\\/#', '/'); + $string->value = Strings::replace($string->value, '#^\\.\\/#', '/'); } - private function prependSlashIfMissing(\PhpParser\Node\Scalar\String_ $string) : void + private function prependSlashIfMissing(String_ $string) : void { if (\strncmp($string->value, '/', \strlen('/')) === 0) { return; diff --git a/rules/CodeQuality/Rector/Isset_/IssetOnPropertyObjectToPropertyExistsRector.php b/rules/CodeQuality/Rector/Isset_/IssetOnPropertyObjectToPropertyExistsRector.php index 2887b522ccf..b91e5844b81 100644 --- a/rules/CodeQuality/Rector/Isset_/IssetOnPropertyObjectToPropertyExistsRector.php +++ b/rules/CodeQuality/Rector/Isset_/IssetOnPropertyObjectToPropertyExistsRector.php @@ -18,14 +18,14 @@ use PHPStan\Type\MixedType; use PHPStan\Type\TypeWithClassName; use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector\IssetOnPropertyObjectToPropertyExistsRectorTest * * @changelog https://3v4l.org/TI8XL Change isset on property object to property_exists() with not null check */ -final class IssetOnPropertyObjectToPropertyExistsRector extends \Rector\Core\Rector\AbstractRector +final class IssetOnPropertyObjectToPropertyExistsRector extends AbstractRector { /** * @readonly @@ -37,14 +37,14 @@ final class IssetOnPropertyObjectToPropertyExistsRector extends \Rector\Core\Rec * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(ReflectionProvider $reflectionProvider, ReflectionResolver $reflectionResolver) { $this->reflectionProvider = $reflectionProvider; $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change isset on property object to property_exists() and not null check', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change isset on property object to property_exists() and not null check', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { private $x; @@ -73,20 +73,20 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Isset_::class]; + return [Isset_::class]; } /** * @param Isset_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $newNodes = []; foreach ($node->vars as $issetVar) { - if (!$issetVar instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$issetVar instanceof PropertyFetch) { continue; } // Ignore dynamically accessed properties ($o->$p) - if ($issetVar->name instanceof \PhpParser\Node\Expr\Variable) { + if ($issetVar->name instanceof Variable) { continue; } // has property PHP 7.4 type? @@ -98,7 +98,7 @@ CODE_SAMPLE continue; } $propertyFetchVarType = $this->getType($issetVar->var); - if ($propertyFetchVarType instanceof \PHPStan\Type\TypeWithClassName) { + if ($propertyFetchVarType instanceof TypeWithClassName) { if (!$this->reflectionProvider->hasClass($propertyFetchVarType->getClassName())) { continue; } @@ -114,22 +114,22 @@ CODE_SAMPLE } return $this->nodeFactory->createReturnBooleanAnd($newNodes); } - private function replaceToPropertyExistsWithNullCheck(\PhpParser\Node\Expr $expr, string $property, \PhpParser\Node\Expr\PropertyFetch $propertyFetch) : \PhpParser\Node\Expr\BinaryOp\BooleanAnd + private function replaceToPropertyExistsWithNullCheck(Expr $expr, string $property, PropertyFetch $propertyFetch) : BooleanAnd { - $args = [new \PhpParser\Node\Arg($expr), new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\String_($property))]; + $args = [new Arg($expr), new Arg(new String_($property))]; $propertyExistsFuncCall = $this->nodeFactory->createFuncCall('property_exists', $args); - return new \PhpParser\Node\Expr\BinaryOp\BooleanAnd($propertyExistsFuncCall, $this->createNotIdenticalToNull($propertyFetch)); + return new BooleanAnd($propertyExistsFuncCall, $this->createNotIdenticalToNull($propertyFetch)); } - private function createNotIdenticalToNull(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : \PhpParser\Node\Expr\BinaryOp\NotIdentical + private function createNotIdenticalToNull(PropertyFetch $propertyFetch) : NotIdentical { - return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($propertyFetch, $this->nodeFactory->createNull()); + return new NotIdentical($propertyFetch, $this->nodeFactory->createNull()); } - private function hasPropertyTypeDeclaration(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : bool + private function hasPropertyTypeDeclaration(PropertyFetch $propertyFetch) : bool { $phpPropertyReflection = $this->reflectionResolver->resolvePropertyReflectionFromPropertyFetch($propertyFetch); - if (!$phpPropertyReflection instanceof \PHPStan\Reflection\Php\PhpPropertyReflection) { + if (!$phpPropertyReflection instanceof PhpPropertyReflection) { return \false; } - return !$phpPropertyReflection->getNativeType() instanceof \PHPStan\Type\MixedType; + return !$phpPropertyReflection->getNativeType() instanceof MixedType; } } diff --git a/rules/CodeQuality/Rector/LogicalAnd/AndAssignsToSeparateLinesRector.php b/rules/CodeQuality/Rector/LogicalAnd/AndAssignsToSeparateLinesRector.php index 7178cad47b7..ed8413e75ed 100644 --- a/rules/CodeQuality/Rector/LogicalAnd/AndAssignsToSeparateLinesRector.php +++ b/rules/CodeQuality/Rector/LogicalAnd/AndAssignsToSeparateLinesRector.php @@ -8,17 +8,17 @@ use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\BinaryOp\LogicalAnd; use PhpParser\Node\Stmt\Expression; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/ji8bX * @see \Rector\Tests\CodeQuality\Rector\LogicalAnd\AndAssignsToSeparateLinesRector\AndAssignsToSeparateLinesRectorTest */ -final class AndAssignsToSeparateLinesRector extends \Rector\Core\Rector\AbstractRector +final class AndAssignsToSeparateLinesRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Split 2 assigns ands to separate line', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Split 2 assigns ands to separate line', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -46,26 +46,26 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Expression::class]; + return [Expression::class]; } /** * @param Expression $node * @return Expression[]|null */ - public function refactor(\PhpParser\Node $node) : ?array + public function refactor(Node $node) : ?array { - if (!$node->expr instanceof \PhpParser\Node\Expr\BinaryOp\LogicalAnd) { + if (!$node->expr instanceof LogicalAnd) { return null; } $logicalAnd = $node->expr; - if (!$logicalAnd->left instanceof \PhpParser\Node\Expr\Assign) { + if (!$logicalAnd->left instanceof Assign) { return null; } - if (!$logicalAnd->right instanceof \PhpParser\Node\Expr\Assign) { + if (!$logicalAnd->right instanceof Assign) { return null; } - $leftAssignExpression = new \PhpParser\Node\Stmt\Expression($logicalAnd->left); - $rightAssignExpression = new \PhpParser\Node\Stmt\Expression($logicalAnd->right); + $leftAssignExpression = new Expression($logicalAnd->left); + $rightAssignExpression = new Expression($logicalAnd->right); return [$leftAssignExpression, $rightAssignExpression]; } } diff --git a/rules/CodeQuality/Rector/LogicalAnd/LogicalToBooleanRector.php b/rules/CodeQuality/Rector/LogicalAnd/LogicalToBooleanRector.php index 52c62239470..44c1d451e6e 100644 --- a/rules/CodeQuality/Rector/LogicalAnd/LogicalToBooleanRector.php +++ b/rules/CodeQuality/Rector/LogicalAnd/LogicalToBooleanRector.php @@ -9,18 +9,18 @@ use PhpParser\Node\Expr\BinaryOp\BooleanOr; use PhpParser\Node\Expr\BinaryOp\LogicalAnd; use PhpParser\Node\Expr\BinaryOp\LogicalOr; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://stackoverflow.com/a/5998330/1348344 * * @see \Rector\Tests\CodeQuality\Rector\LogicalAnd\LogicalToBooleanRector\LogicalToBooleanRectorTest */ -final class LogicalToBooleanRector extends \Rector\Core\Rector\AbstractRector +final class LogicalToBooleanRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change OR, AND to ||, && with more common understanding', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change OR, AND to ||, && with more common understanding', [new CodeSample(<<<'CODE_SAMPLE' if ($f = false or true) { return $f; } @@ -37,12 +37,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\LogicalOr::class, \PhpParser\Node\Expr\BinaryOp\LogicalAnd::class]; + return [LogicalOr::class, LogicalAnd::class]; } /** * @param LogicalOr|LogicalAnd $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { return $this->refactorLogicalToBoolean($node); } @@ -52,15 +52,15 @@ CODE_SAMPLE */ private function refactorLogicalToBoolean($node) { - if ($node->left instanceof \PhpParser\Node\Expr\BinaryOp\LogicalOr || $node->left instanceof \PhpParser\Node\Expr\BinaryOp\LogicalAnd) { + if ($node->left instanceof LogicalOr || $node->left instanceof LogicalAnd) { $node->left = $this->refactorLogicalToBoolean($node->left); } - if ($node->right instanceof \PhpParser\Node\Expr\BinaryOp\LogicalOr || $node->right instanceof \PhpParser\Node\Expr\BinaryOp\LogicalAnd) { + if ($node->right instanceof LogicalOr || $node->right instanceof LogicalAnd) { $node->right = $this->refactorLogicalToBoolean($node->right); } - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\LogicalOr) { - return new \PhpParser\Node\Expr\BinaryOp\BooleanOr($node->left, $node->right); + if ($node instanceof LogicalOr) { + return new BooleanOr($node->left, $node->right); } - return new \PhpParser\Node\Expr\BinaryOp\BooleanAnd($node->left, $node->right); + return new BooleanAnd($node->left, $node->right); } } diff --git a/rules/CodeQuality/Rector/New_/NewStaticToNewSelfRector.php b/rules/CodeQuality/Rector/New_/NewStaticToNewSelfRector.php index 7dd32979ba7..3aa86207e2f 100644 --- a/rules/CodeQuality/Rector/New_/NewStaticToNewSelfRector.php +++ b/rules/CodeQuality/Rector/New_/NewStaticToNewSelfRector.php @@ -9,18 +9,18 @@ use PhpParser\Node\Name; use PhpParser\Node\Stmt\Class_; use Rector\Core\Enum\ObjectReference; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/phpstan/phpstan-src/blob/699c420f8193da66927e54494a0afa0c323c6458/src/Rules/Classes/NewStaticRule.php * * @see \Rector\Tests\CodeQuality\Rector\New_\NewStaticToNewSelfRector\NewStaticToNewSelfRectorTest */ -final class NewStaticToNewSelfRector extends \Rector\Core\Rector\AbstractRector +final class NewStaticToNewSelfRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change unsafe new static() to new self()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change unsafe new static() to new self()', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function build() @@ -45,24 +45,24 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\New_::class]; + return [New_::class]; } /** * @param New_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $class = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$class instanceof Class_) { return null; } if (!$class->isFinal()) { return null; } - if (!$this->isName($node->class, \Rector\Core\Enum\ObjectReference::STATIC)) { + if (!$this->isName($node->class, ObjectReference::STATIC)) { return null; } - $node->class = new \PhpParser\Node\Name(\Rector\Core\Enum\ObjectReference::SELF); + $node->class = new Name(ObjectReference::SELF); return $node; } } diff --git a/rules/CodeQuality/Rector/NotEqual/CommonNotEqualRector.php b/rules/CodeQuality/Rector/NotEqual/CommonNotEqualRector.php index bb35ea7d81e..d0c70be3037 100644 --- a/rules/CodeQuality/Rector/NotEqual/CommonNotEqualRector.php +++ b/rules/CodeQuality/Rector/NotEqual/CommonNotEqualRector.php @@ -7,17 +7,17 @@ use PhpParser\Node; use PhpParser\Node\Expr\BinaryOp\NotEqual; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://stackoverflow.com/a/4294663/1348344 * @see \Rector\Tests\CodeQuality\Rector\NotEqual\CommonNotEqualRector\CommonNotEqualRectorTest */ -final class CommonNotEqualRector extends \Rector\Core\Rector\AbstractRector +final class CommonNotEqualRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Use common != instead of less known <> with same meaning', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Use common != instead of less known <> with same meaning', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run($one, $two) @@ -42,15 +42,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\NotEqual::class]; + return [NotEqual::class]; } /** * @param NotEqual $node */ - public function refactor(\PhpParser\Node $node) : \PhpParser\Node\Expr\BinaryOp\NotEqual + public function refactor(Node $node) : NotEqual { // invoke override to default "!=" - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); return $node; } } diff --git a/rules/CodeQuality/Rector/PropertyFetch/ExplicitMethodCallOverMagicGetSetRector.php b/rules/CodeQuality/Rector/PropertyFetch/ExplicitMethodCallOverMagicGetSetRector.php index de4d3dd0927..6c67108a5fe 100644 --- a/rules/CodeQuality/Rector/PropertyFetch/ExplicitMethodCallOverMagicGetSetRector.php +++ b/rules/CodeQuality/Rector/PropertyFetch/ExplicitMethodCallOverMagicGetSetRector.php @@ -15,8 +15,8 @@ use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractScopeAwareRector; use Rector\Core\ValueObject\MethodName; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/symplify/phpstan-rules/blob/main/docs/rules_overview.md#explicitmethodcallovermagicgetsetrule * @@ -25,11 +25,11 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @see \Rector\Tests\CodeQuality\Rector\PropertyFetch\ExplicitMethodCallOverMagicGetSetRector\ExplicitMethodCallOverMagicGetSetRectorTest */ -final class ExplicitMethodCallOverMagicGetSetRector extends \Rector\Core\Rector\AbstractScopeAwareRector +final class ExplicitMethodCallOverMagicGetSetRector extends AbstractScopeAwareRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace magic property fetch using __get() and __set() with existing method get*()/set*() calls', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace magic property fetch using __get() and __set() with existing method get*()/set*() calls', [new CodeSample(<<<'CODE_SAMPLE' class MagicCallsObject { // adds magic __get() and __set() methods @@ -80,15 +80,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\PropertyFetch::class, \PhpParser\Node\Expr\Assign::class]; + return [PropertyFetch::class, Assign::class]; } /** * @param PropertyFetch|Assign $node */ - public function refactorWithScope(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : ?\PhpParser\Node + public function refactorWithScope(Node $node, Scope $scope) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\Assign) { - if ($node->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if ($node instanceof Assign) { + if ($node->var instanceof PropertyFetch) { return $this->refactorMagicSet($node->expr, $node->var, $scope); } return null; @@ -105,10 +105,10 @@ CODE_SAMPLE { return ['get' . \ucfirst($propertyName), 'has' . \ucfirst($propertyName), 'is' . \ucfirst($propertyName)]; } - private function shouldSkipPropertyFetch(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : bool + private function shouldSkipPropertyFetch(PropertyFetch $propertyFetch) : bool { - $parent = $propertyFetch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\Expr\Assign) { + $parent = $propertyFetch->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Assign) { return \false; } return $parent->var === $propertyFetch; @@ -116,14 +116,14 @@ CODE_SAMPLE /** * @return \PhpParser\Node\Expr\MethodCall|null */ - private function refactorPropertyFetch(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) + private function refactorPropertyFetch(PropertyFetch $propertyFetch) { $callerType = $this->getType($propertyFetch->var); - if (!$callerType instanceof \PHPStan\Type\ObjectType) { + if (!$callerType instanceof ObjectType) { return null; } // has magic methods? - if (!$callerType->hasMethod(\Rector\Core\ValueObject\MethodName::__GET)->yes()) { + if (!$callerType->hasMethod(MethodName::__GET)->yes()) { return null; } $propertyName = $this->getName($propertyFetch->name); @@ -142,13 +142,13 @@ CODE_SAMPLE /** * @return \PhpParser\Node\Expr\MethodCall|null */ - private function refactorMagicSet(\PhpParser\Node\Expr $expr, \PhpParser\Node\Expr\PropertyFetch $propertyFetch, \PHPStan\Analyser\Scope $scope) + private function refactorMagicSet(Expr $expr, PropertyFetch $propertyFetch, Scope $scope) { $propertyCallerType = $this->getType($propertyFetch->var); - if (!$propertyCallerType instanceof \PHPStan\Type\ObjectType) { + if (!$propertyCallerType instanceof ObjectType) { return null; } - if (!$propertyCallerType->hasMethod(\Rector\Core\ValueObject\MethodName::__SET)->yes()) { + if (!$propertyCallerType->hasMethod(MethodName::__SET)->yes()) { return null; } $propertyName = $this->getName($propertyFetch->name); @@ -164,13 +164,13 @@ CODE_SAMPLE } return $this->nodeFactory->createMethodCall($propertyFetch->var, $setterMethodName, [$expr]); } - private function hasNoParamOrVariadic(\PHPStan\Type\ObjectType $objectType, string $setterMethodName, \PHPStan\Analyser\Scope $scope) : bool + private function hasNoParamOrVariadic(ObjectType $objectType, string $setterMethodName, Scope $scope) : bool { $methodReflection = $objectType->getMethod($setterMethodName, $scope); - if (!$methodReflection instanceof \PHPStan\Reflection\ResolvedMethodReflection) { + if (!$methodReflection instanceof ResolvedMethodReflection) { return \false; } - $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); + $parametersAcceptor = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); $parameters = $parametersAcceptor->getParameters(); if (\count($parameters) !== 1) { return \true; diff --git a/rules/CodeQuality/Rector/Switch_/SingularSwitchToIfRector.php b/rules/CodeQuality/Rector/Switch_/SingularSwitchToIfRector.php index 381e1c84b39..a194ecbd4f2 100644 --- a/rules/CodeQuality/Rector/Switch_/SingularSwitchToIfRector.php +++ b/rules/CodeQuality/Rector/Switch_/SingularSwitchToIfRector.php @@ -9,25 +9,25 @@ use PhpParser\Node\Stmt\If_; use PhpParser\Node\Stmt\Switch_; use Rector\Core\Rector\AbstractRector; use Rector\Renaming\NodeManipulator\SwitchManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Switch_\SingularSwitchToIfRector\SingularSwitchToIfRectorTest */ -final class SingularSwitchToIfRector extends \Rector\Core\Rector\AbstractRector +final class SingularSwitchToIfRector extends AbstractRector { /** * @readonly * @var \Rector\Renaming\NodeManipulator\SwitchManipulator */ private $switchManipulator; - public function __construct(\Rector\Renaming\NodeManipulator\SwitchManipulator $switchManipulator) + public function __construct(SwitchManipulator $switchManipulator) { $this->switchManipulator = $switchManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change switch with only 1 check to if', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change switch with only 1 check to if', [new CodeSample(<<<'CODE_SAMPLE' class SomeObject { public function run($value) @@ -63,13 +63,13 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Switch_::class]; + return [Switch_::class]; } /** * @param Switch_ $node * @return Node\Stmt[]|If_|null */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { if (\count($node->cases) !== 1) { return null; @@ -79,7 +79,7 @@ CODE_SAMPLE if ($onlyCase->cond === null) { return $onlyCase->stmts; } - $if = new \PhpParser\Node\Stmt\If_(new \PhpParser\Node\Expr\BinaryOp\Identical($node->cond, $onlyCase->cond)); + $if = new If_(new Identical($node->cond, $onlyCase->cond)); $if->stmts = $this->switchManipulator->removeBreakNodes($onlyCase->stmts); return $if; } diff --git a/rules/CodeQuality/Rector/Ternary/ArrayKeyExistsTernaryThenValueToCoalescingRector.php b/rules/CodeQuality/Rector/Ternary/ArrayKeyExistsTernaryThenValueToCoalescingRector.php index 3a96249f688..0efb0dfd469 100644 --- a/rules/CodeQuality/Rector/Ternary/ArrayKeyExistsTernaryThenValueToCoalescingRector.php +++ b/rules/CodeQuality/Rector/Ternary/ArrayKeyExistsTernaryThenValueToCoalescingRector.php @@ -10,18 +10,18 @@ use PhpParser\Node\Expr\BinaryOp\Coalesce; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\Ternary; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/f7itn * * @see \Rector\Tests\CodeQuality\Rector\Ternary\ArrayKeyExistsTernaryThenValueToCoalescingRector\ArrayKeyExistsTernaryThenValueToCoalescingRectorTest */ -final class ArrayKeyExistsTernaryThenValueToCoalescingRector extends \Rector\Core\Rector\AbstractRector +final class ArrayKeyExistsTernaryThenValueToCoalescingRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change array_key_exists() ternary to coalescing', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change array_key_exists() ternary to coalescing', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($values, $keyToMatch) @@ -46,20 +46,20 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Ternary::class]; + return [Ternary::class]; } /** * @param Ternary $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->cond instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$node->cond instanceof FuncCall) { return null; } if (!$this->isName($node->cond, 'array_key_exists')) { return null; } - if (!$node->if instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$node->if instanceof ArrayDimFetch) { return null; } if (!$this->areArrayKeysExistsArgsMatchingDimFetch($node->cond, $node->if)) { @@ -68,7 +68,7 @@ CODE_SAMPLE if (!$this->valueResolver->isNull($node->else)) { return null; } - return new \PhpParser\Node\Expr\BinaryOp\Coalesce($node->if, $node->else); + return new Coalesce($node->if, $node->else); } /** * Equals if: @@ -77,15 +77,15 @@ CODE_SAMPLE * = * $values[$key] */ - private function areArrayKeysExistsArgsMatchingDimFetch(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch) : bool + private function areArrayKeysExistsArgsMatchingDimFetch(FuncCall $funcCall, ArrayDimFetch $arrayDimFetch) : bool { $firstArg = $funcCall->args[0]; - if (!$firstArg instanceof \PhpParser\Node\Arg) { + if (!$firstArg instanceof Arg) { return \false; } $keyExpr = $firstArg->value; $secondArg = $funcCall->args[1]; - if (!$secondArg instanceof \PhpParser\Node\Arg) { + if (!$secondArg instanceof Arg) { return \false; } $valuesExpr = $secondArg->value; diff --git a/rules/CodeQuality/Rector/Ternary/SimplifyTautologyTernaryRector.php b/rules/CodeQuality/Rector/Ternary/SimplifyTautologyTernaryRector.php index 8e2c49f36a4..869e9d4a36c 100644 --- a/rules/CodeQuality/Rector/Ternary/SimplifyTautologyTernaryRector.php +++ b/rules/CodeQuality/Rector/Ternary/SimplifyTautologyTernaryRector.php @@ -10,47 +10,47 @@ use PhpParser\Node\Expr\Ternary; use Rector\Core\NodeManipulator\BinaryOpManipulator; use Rector\Core\Rector\AbstractRector; use Rector\Php71\ValueObject\TwoNodeMatch; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Ternary\SimplifyTautologyTernaryRector\SimplifyTautologyTernaryRectorTest */ -final class SimplifyTautologyTernaryRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyTautologyTernaryRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeManipulator\BinaryOpManipulator */ private $binaryOpManipulator; - public function __construct(\Rector\Core\NodeManipulator\BinaryOpManipulator $binaryOpManipulator) + public function __construct(BinaryOpManipulator $binaryOpManipulator) { $this->binaryOpManipulator = $binaryOpManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Simplify tautology ternary to value', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$value = ($fullyQualifiedTypeHint !== $typeHint) ? $fullyQualifiedTypeHint : $typeHint;', '$value = $fullyQualifiedTypeHint;')]); + return new RuleDefinition('Simplify tautology ternary to value', [new CodeSample('$value = ($fullyQualifiedTypeHint !== $typeHint) ? $fullyQualifiedTypeHint : $typeHint;', '$value = $fullyQualifiedTypeHint;')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Ternary::class]; + return [Ternary::class]; } /** * @param Ternary $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->cond instanceof \PhpParser\Node\Expr\BinaryOp\NotIdentical && !$node->cond instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { + if (!$node->cond instanceof NotIdentical && !$node->cond instanceof Identical) { return null; } - $twoNodeMatch = $this->binaryOpManipulator->matchFirstAndSecondConditionNode($node->cond, function (\PhpParser\Node $leftNode) use($node) : bool { + $twoNodeMatch = $this->binaryOpManipulator->matchFirstAndSecondConditionNode($node->cond, function (Node $leftNode) use($node) : bool { return $this->nodeComparator->areNodesEqual($leftNode, $node->if); - }, function (\PhpParser\Node $leftNode) use($node) : bool { + }, function (Node $leftNode) use($node) : bool { return $this->nodeComparator->areNodesEqual($leftNode, $node->else); }); - if (!$twoNodeMatch instanceof \Rector\Php71\ValueObject\TwoNodeMatch) { + if (!$twoNodeMatch instanceof TwoNodeMatch) { return null; } return $node->if; diff --git a/rules/CodeQuality/Rector/Ternary/SwitchNegatedTernaryRector.php b/rules/CodeQuality/Rector/Ternary/SwitchNegatedTernaryRector.php index 5b232c55637..6dd4460392f 100644 --- a/rules/CodeQuality/Rector/Ternary/SwitchNegatedTernaryRector.php +++ b/rules/CodeQuality/Rector/Ternary/SwitchNegatedTernaryRector.php @@ -8,16 +8,16 @@ use PhpParser\Node\Expr\BooleanNot; use PhpParser\Node\Expr\Ternary; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Ternary\SwitchNegatedTernaryRector\SwitchNegatedTernaryRectorTest */ -final class SwitchNegatedTernaryRector extends \Rector\Core\Rector\AbstractRector +final class SwitchNegatedTernaryRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Switch negated ternary condition rector', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Switch negated ternary condition rector', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(bool $upper, string $name) @@ -46,14 +46,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Ternary::class]; + return [Ternary::class]; } /** * @param Ternary $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->cond instanceof \PhpParser\Node\Expr\BooleanNot) { + if (!$node->cond instanceof BooleanNot) { return null; } if ($node->if === null) { @@ -61,10 +61,10 @@ CODE_SAMPLE } $node->cond = $node->cond->expr; [$node->if, $node->else] = [$node->else, $node->if]; - if ($node->if instanceof \PhpParser\Node\Expr\Ternary) { + if ($node->if instanceof Ternary) { $ternary = $node->if; - $ternary->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND, 'wrapped_with_brackets'); - $ternary->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $ternary->setAttribute(AttributeKey::KIND, 'wrapped_with_brackets'); + $ternary->setAttribute(AttributeKey::ORIGINAL_NODE, null); } return $node; } diff --git a/rules/CodeQuality/Rector/Ternary/UnnecessaryTernaryExpressionRector.php b/rules/CodeQuality/Rector/Ternary/UnnecessaryTernaryExpressionRector.php index 9e4ec30cf9b..ab9ce8c70bc 100644 --- a/rules/CodeQuality/Rector/Ternary/UnnecessaryTernaryExpressionRector.php +++ b/rules/CodeQuality/Rector/Ternary/UnnecessaryTernaryExpressionRector.php @@ -12,41 +12,41 @@ use PhpParser\Node\Expr\Ternary; use PHPStan\Type\BooleanType; use Rector\Core\PhpParser\Node\AssignAndBinaryMap; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector\UnnecessaryTernaryExpressionRectorTest */ -final class UnnecessaryTernaryExpressionRector extends \Rector\Core\Rector\AbstractRector +final class UnnecessaryTernaryExpressionRector extends AbstractRector { /** * @readonly * @var \Rector\Core\PhpParser\Node\AssignAndBinaryMap */ private $assignAndBinaryMap; - public function __construct(\Rector\Core\PhpParser\Node\AssignAndBinaryMap $assignAndBinaryMap) + public function __construct(AssignAndBinaryMap $assignAndBinaryMap) { $this->assignAndBinaryMap = $assignAndBinaryMap; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove unnecessary ternary expressions', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$foo === $bar ? true : false;', '$foo === $bar;')]); + return new RuleDefinition('Remove unnecessary ternary expressions', [new CodeSample('$foo === $bar ? true : false;', '$foo === $bar;')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Ternary::class]; + return [Ternary::class]; } /** * @param Ternary $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { /** @var Ternary $ternaryExpression */ $ternaryExpression = $node; - if (!$ternaryExpression->if instanceof \PhpParser\Node\Expr) { + if (!$ternaryExpression->if instanceof Expr) { return null; } $ifExpression = $ternaryExpression->if; @@ -58,7 +58,7 @@ final class UnnecessaryTernaryExpressionRector extends \Rector\Core\Rector\Abstr return null; } $condition = $ternaryExpression->cond; - if (!$condition instanceof \PhpParser\Node\Expr\BinaryOp) { + if (!$condition instanceof BinaryOp) { return $this->processNonBinaryCondition($ifExpression, $elseExpression, $condition); } if ($this->valueResolver->isNull($ifExpression)) { @@ -78,7 +78,7 @@ final class UnnecessaryTernaryExpressionRector extends \Rector\Core\Rector\Abstr } return new $inversedBinaryClass($binaryOperation->left, $binaryOperation->right); } - private function processNonBinaryCondition(\PhpParser\Node\Expr $ifExpression, \PhpParser\Node\Expr $elseExpression, \PhpParser\Node\Expr $condition) : ?\PhpParser\Node + private function processNonBinaryCondition(Expr $ifExpression, Expr $elseExpression, Expr $condition) : ?Node { if ($this->valueResolver->isTrue($ifExpression) && $this->valueResolver->isFalse($elseExpression)) { return $this->processTrueIfExpressionWithFalseElseExpression($condition); @@ -91,27 +91,27 @@ final class UnnecessaryTernaryExpressionRector extends \Rector\Core\Rector\Abstr } return $this->processFalseIfExpressionWithTrueElseExpression($condition); } - private function processTrueIfExpressionWithFalseElseExpression(\PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr + private function processTrueIfExpressionWithFalseElseExpression(Expr $expr) : Expr { $exprType = $this->getType($expr); - if ($exprType instanceof \PHPStan\Type\BooleanType) { + if ($exprType instanceof BooleanType) { return $expr; } - return new \PhpParser\Node\Expr\Cast\Bool_($expr); + return new Bool_($expr); } - private function processFalseIfExpressionWithTrueElseExpression(\PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr + private function processFalseIfExpressionWithTrueElseExpression(Expr $expr) : Expr { - if ($expr instanceof \PhpParser\Node\Expr\BooleanNot) { + if ($expr instanceof BooleanNot) { $negatedExprType = $this->getType($expr->expr); - if ($negatedExprType instanceof \PHPStan\Type\BooleanType) { + if ($negatedExprType instanceof BooleanType) { return $expr->expr; } - return new \PhpParser\Node\Expr\Cast\Bool_($expr->expr); + return new Bool_($expr->expr); } $exprType = $this->getType($expr); - if ($exprType instanceof \PHPStan\Type\BooleanType) { - return new \PhpParser\Node\Expr\BooleanNot($expr); + if ($exprType instanceof BooleanType) { + return new BooleanNot($expr); } - return new \PhpParser\Node\Expr\BooleanNot(new \PhpParser\Node\Expr\Cast\Bool_($expr)); + return new BooleanNot(new Bool_($expr)); } } diff --git a/rules/CodeQuality/TypeResolver/ArrayDimFetchTypeResolver.php b/rules/CodeQuality/TypeResolver/ArrayDimFetchTypeResolver.php index 5543a62e207..a2257a0ef28 100644 --- a/rules/CodeQuality/TypeResolver/ArrayDimFetchTypeResolver.php +++ b/rules/CodeQuality/TypeResolver/ArrayDimFetchTypeResolver.php @@ -17,29 +17,29 @@ final class ArrayDimFetchTypeResolver * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(NodeTypeResolver $nodeTypeResolver) { $this->nodeTypeResolver = $nodeTypeResolver; } - public function resolve(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch) : \PHPStan\Type\ArrayType + public function resolve(ArrayDimFetch $arrayDimFetch) : ArrayType { $keyStaticType = $this->resolveDimType($arrayDimFetch); $valueStaticType = $this->resolveValueStaticType($arrayDimFetch); - return new \PHPStan\Type\ArrayType($keyStaticType, $valueStaticType); + return new ArrayType($keyStaticType, $valueStaticType); } - private function resolveDimType(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch) : \PHPStan\Type\Type + private function resolveDimType(ArrayDimFetch $arrayDimFetch) : Type { if ($arrayDimFetch->dim !== null) { return $this->nodeTypeResolver->getType($arrayDimFetch->dim); } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } - private function resolveValueStaticType(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch) : \PHPStan\Type\Type + private function resolveValueStaticType(ArrayDimFetch $arrayDimFetch) : Type { - $parentParent = $arrayDimFetch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentParent instanceof \PhpParser\Node\Expr\Assign) { + $parentParent = $arrayDimFetch->getAttribute(AttributeKey::PARENT_NODE); + if ($parentParent instanceof Assign) { return $this->nodeTypeResolver->getType($parentParent->expr); } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } } diff --git a/rules/CodeQuality/TypeResolver/AssignVariableTypeResolver.php b/rules/CodeQuality/TypeResolver/AssignVariableTypeResolver.php index 3ebb1d5461c..8209da3f7fd 100644 --- a/rules/CodeQuality/TypeResolver/AssignVariableTypeResolver.php +++ b/rules/CodeQuality/TypeResolver/AssignVariableTypeResolver.php @@ -14,15 +14,15 @@ final class AssignVariableTypeResolver * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(NodeTypeResolver $nodeTypeResolver) { $this->nodeTypeResolver = $nodeTypeResolver; } - public function resolve(\PhpParser\Node\Expr\Assign $assign) : \PHPStan\Type\Type + public function resolve(Assign $assign) : Type { $variableType = $this->nodeTypeResolver->getType($assign->var); $exprType = $this->nodeTypeResolver->getType($assign->expr); - if ($exprType instanceof \PHPStan\Type\UnionType) { + if ($exprType instanceof UnionType) { $variableType = $exprType; } return $variableType; diff --git a/rules/CodeQuality/ValueObject/DefaultPropertyExprAssign.php b/rules/CodeQuality/ValueObject/DefaultPropertyExprAssign.php index 8bfa63c0452..ac54352f84a 100644 --- a/rules/CodeQuality/ValueObject/DefaultPropertyExprAssign.php +++ b/rules/CodeQuality/ValueObject/DefaultPropertyExprAssign.php @@ -22,13 +22,13 @@ final class DefaultPropertyExprAssign * @var \PhpParser\Node\Expr */ private $defaultExpr; - public function __construct(\PhpParser\Node\Stmt\Expression $assignExpression, string $propertyName, \PhpParser\Node\Expr $defaultExpr) + public function __construct(Expression $assignExpression, string $propertyName, Expr $defaultExpr) { $this->assignExpression = $assignExpression; $this->propertyName = $propertyName; $this->defaultExpr = $defaultExpr; } - public function getAssignExpression() : \PhpParser\Node\Stmt\Expression + public function getAssignExpression() : Expression { return $this->assignExpression; } @@ -36,7 +36,7 @@ final class DefaultPropertyExprAssign { return $this->propertyName; } - public function getDefaultExpr() : \PhpParser\Node\Expr + public function getDefaultExpr() : Expr { return $this->defaultExpr; } diff --git a/rules/CodeQuality/ValueObject/KeyAndExpr.php b/rules/CodeQuality/ValueObject/KeyAndExpr.php index f5a034b1ada..41542b65f84 100644 --- a/rules/CodeQuality/ValueObject/KeyAndExpr.php +++ b/rules/CodeQuality/ValueObject/KeyAndExpr.php @@ -25,17 +25,17 @@ final class KeyAndExpr /** * @param Comment[] $comments */ - public function __construct(?\PhpParser\Node\Expr $keyExpr, \PhpParser\Node\Expr $expr, array $comments) + public function __construct(?Expr $keyExpr, Expr $expr, array $comments) { $this->keyExpr = $keyExpr; $this->expr = $expr; $this->comments = $comments; } - public function getKeyExpr() : ?\PhpParser\Node\Expr + public function getKeyExpr() : ?Expr { return $this->keyExpr; } - public function getExpr() : \PhpParser\Node\Expr + public function getExpr() : Expr { return $this->expr; } diff --git a/rules/CodingStyle/Application/UseImportsAdder.php b/rules/CodingStyle/Application/UseImportsAdder.php index 9fb43bc58f7..e5d891c609b 100644 --- a/rules/CodingStyle/Application/UseImportsAdder.php +++ b/rules/CodingStyle/Application/UseImportsAdder.php @@ -27,7 +27,7 @@ final class UseImportsAdder * @var \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory */ private $typeFactory; - public function __construct(\Rector\CodingStyle\ClassNameImport\UsedImportsResolver $usedImportsResolver, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory) + public function __construct(UsedImportsResolver $usedImportsResolver, TypeFactory $typeFactory) { $this->usedImportsResolver = $usedImportsResolver; $this->typeFactory = $typeFactory; @@ -50,12 +50,12 @@ final class UseImportsAdder } // place after declare strict_types foreach ($stmts as $key => $stmt) { - if ($stmt instanceof \PhpParser\Node\Stmt\Declare_) { - if (isset($stmts[$key + 1]) && $stmts[$key + 1] instanceof \PhpParser\Node\Stmt\Use_) { + if ($stmt instanceof Declare_) { + if (isset($stmts[$key + 1]) && $stmts[$key + 1] instanceof Use_) { $nodesToAdd = $newUses; } else { // add extra space, if there are no new use imports to be added - $nodesToAdd = \array_merge([new \PhpParser\Node\Stmt\Nop()], $newUses); + $nodesToAdd = \array_merge([new Nop()], $newUses); } \array_splice($stmts, $key + 1, 0, $nodesToAdd); return $stmts; @@ -68,7 +68,7 @@ final class UseImportsAdder * @param FullyQualifiedObjectType[] $useImportTypes * @param FullyQualifiedObjectType[] $functionUseImportTypes */ - public function addImportsToNamespace(\PhpParser\Node\Stmt\Namespace_ $namespace, array $useImportTypes, array $functionUseImportTypes) : void + public function addImportsToNamespace(Namespace_ $namespace, array $useImportTypes, array $functionUseImportTypes) : void { $namespaceName = $this->getNamespaceName($namespace); $existingUseImportTypes = $this->usedImportsResolver->resolveForNode($namespace); @@ -77,11 +77,11 @@ final class UseImportsAdder $useImportTypes = $this->diffFullyQualifiedObjectTypes($useImportTypes, $existingUseImportTypes); $functionUseImportTypes = $this->diffFullyQualifiedObjectTypes($functionUseImportTypes, $existingFunctionUseImportTypes); $newUses = $this->createUses($useImportTypes, $functionUseImportTypes, $namespaceName); - if ($namespace->stmts[0] instanceof \PhpParser\Node\Stmt\Use_ && $newUses !== []) { - $comments = (array) $namespace->stmts[0]->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS); + if ($namespace->stmts[0] instanceof Use_ && $newUses !== []) { + $comments = (array) $namespace->stmts[0]->getAttribute(AttributeKey::COMMENTS); if ($comments !== []) { - $newUses[0]->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $namespace->stmts[0]->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS)); - $namespace->stmts[0]->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, null); + $newUses[0]->setAttribute(AttributeKey::COMMENTS, $namespace->stmts[0]->getAttribute(AttributeKey::COMMENTS)); + $namespace->stmts[0]->setAttribute(AttributeKey::COMMENTS, null); } } $namespace->stmts = \array_merge($newUses, $namespace->stmts); @@ -126,16 +126,16 @@ final class UseImportsAdder } return $newUses; } - private function getNamespaceName(\PhpParser\Node\Stmt\Namespace_ $namespace) : ?string + private function getNamespaceName(Namespace_ $namespace) : ?string { if ($namespace->name === null) { return null; } return $namespace->name->toString(); } - private function isCurrentNamespace(string $namespaceName, \PHPStan\Type\ObjectType $objectType) : bool + private function isCurrentNamespace(string $namespaceName, ObjectType $objectType) : bool { - $afterCurrentNamespace = \RectorPrefix20220607\Nette\Utils\Strings::after($objectType->getClassName(), $namespaceName . '\\'); + $afterCurrentNamespace = Strings::after($objectType->getClassName(), $namespaceName . '\\'); if ($afterCurrentNamespace === null) { return \false; } diff --git a/rules/CodingStyle/Application/UseImportsRemover.php b/rules/CodingStyle/Application/UseImportsRemover.php index 191d6bbff19..86ace032b02 100644 --- a/rules/CodingStyle/Application/UseImportsRemover.php +++ b/rules/CodingStyle/Application/UseImportsRemover.php @@ -16,7 +16,7 @@ final class UseImportsRemover public function removeImportsFromStmts(array $stmts, array $removedShortUses) : array { foreach ($stmts as $stmtKey => $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Use_) { + if (!$stmt instanceof Use_) { continue; } $this->removeUseFromUse($removedShortUses, $stmt); @@ -30,10 +30,10 @@ final class UseImportsRemover /** * @param string[] $removedShortUses */ - public function removeImportsFromNamespace(\PhpParser\Node\Stmt\Namespace_ $namespace, array $removedShortUses) : void + public function removeImportsFromNamespace(Namespace_ $namespace, array $removedShortUses) : void { foreach ($namespace->stmts as $namespaceKey => $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Use_) { + if (!$stmt instanceof Use_) { continue; } $this->removeUseFromUse($removedShortUses, $stmt); @@ -46,7 +46,7 @@ final class UseImportsRemover /** * @param string[] $removedShortUses */ - private function removeUseFromUse(array $removedShortUses, \PhpParser\Node\Stmt\Use_ $use) : void + private function removeUseFromUse(array $removedShortUses, Use_ $use) : void { foreach ($use->uses as $usesKey => $useUse) { foreach ($removedShortUses as $removedShortUse) { diff --git a/rules/CodingStyle/ClassNameImport/AliasUsesResolver.php b/rules/CodingStyle/ClassNameImport/AliasUsesResolver.php index 628c62d678b..40bbb2f97ec 100644 --- a/rules/CodingStyle/ClassNameImport/AliasUsesResolver.php +++ b/rules/CodingStyle/ClassNameImport/AliasUsesResolver.php @@ -20,7 +20,7 @@ final class AliasUsesResolver * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\CodingStyle\ClassNameImport\UseImportsTraverser $useImportsTraverser, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(\Rector\CodingStyle\ClassNameImport\UseImportsTraverser $useImportsTraverser, BetterNodeFinder $betterNodeFinder) { $this->useImportsTraverser = $useImportsTraverser; $this->betterNodeFinder = $betterNodeFinder; @@ -28,12 +28,12 @@ final class AliasUsesResolver /** * @return string[] */ - public function resolveFromNode(\PhpParser\Node $node) : array + public function resolveFromNode(Node $node) : array { - if (!$node instanceof \PhpParser\Node\Stmt\Namespace_) { - $node = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Namespace_::class); + if (!$node instanceof Namespace_) { + $node = $this->betterNodeFinder->findParentType($node, Namespace_::class); } - if ($node instanceof \PhpParser\Node\Stmt\Namespace_) { + if ($node instanceof Namespace_) { return $this->resolveFromStmts($node->stmts); } return []; @@ -45,7 +45,7 @@ final class AliasUsesResolver public function resolveFromStmts(array $stmts) : array { $aliasedUses = []; - $this->useImportsTraverser->traverserStmts($stmts, function (\PhpParser\Node\Stmt\UseUse $useUse, string $name) use(&$aliasedUses) : void { + $this->useImportsTraverser->traverserStmts($stmts, function (UseUse $useUse, string $name) use(&$aliasedUses) : void { if ($useUse->alias === null) { return; } diff --git a/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/AliasClassNameImportSkipVoter.php b/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/AliasClassNameImportSkipVoter.php index 018d518ba58..180e28df7a8 100644 --- a/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/AliasClassNameImportSkipVoter.php +++ b/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/AliasClassNameImportSkipVoter.php @@ -17,18 +17,18 @@ use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; * * use App\Something as SomeClass; */ -final class AliasClassNameImportSkipVoter implements \Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface +final class AliasClassNameImportSkipVoter implements ClassNameImportSkipVoterInterface { /** * @readonly * @var \Rector\CodingStyle\ClassNameImport\AliasUsesResolver */ private $aliasUsesResolver; - public function __construct(\Rector\CodingStyle\ClassNameImport\AliasUsesResolver $aliasUsesResolver) + public function __construct(AliasUsesResolver $aliasUsesResolver) { $this->aliasUsesResolver = $aliasUsesResolver; } - public function shouldSkip(\Rector\Core\ValueObject\Application\File $file, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType, \PhpParser\Node $node) : bool + public function shouldSkip(File $file, FullyQualifiedObjectType $fullyQualifiedObjectType, Node $node) : bool { $aliasedUses = $this->aliasUsesResolver->resolveFromNode($node); $shortNameLowered = $fullyQualifiedObjectType->getShortNameLowered(); diff --git a/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/ClassLikeNameClassNameImportSkipVoter.php b/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/ClassLikeNameClassNameImportSkipVoter.php index c8d3abb1064..ba112e7b54d 100644 --- a/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/ClassLikeNameClassNameImportSkipVoter.php +++ b/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/ClassLikeNameClassNameImportSkipVoter.php @@ -17,18 +17,18 @@ use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; * * class SomeClass {} */ -final class ClassLikeNameClassNameImportSkipVoter implements \Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface +final class ClassLikeNameClassNameImportSkipVoter implements ClassNameImportSkipVoterInterface { /** * @readonly * @var \Rector\CodingStyle\ClassNameImport\ShortNameResolver */ private $shortNameResolver; - public function __construct(\Rector\CodingStyle\ClassNameImport\ShortNameResolver $shortNameResolver) + public function __construct(ShortNameResolver $shortNameResolver) { $this->shortNameResolver = $shortNameResolver; } - public function shouldSkip(\Rector\Core\ValueObject\Application\File $file, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType, \PhpParser\Node $node) : bool + public function shouldSkip(File $file, FullyQualifiedObjectType $fullyQualifiedObjectType, Node $node) : bool { $classLikeNames = $this->shortNameResolver->resolveShortClassLikeNamesForNode($node); if ($classLikeNames === []) { diff --git a/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/FullyQualifiedNameClassNameImportSkipVoter.php b/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/FullyQualifiedNameClassNameImportSkipVoter.php index 12ccda5831d..bc4ed53e5b0 100644 --- a/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/FullyQualifiedNameClassNameImportSkipVoter.php +++ b/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/FullyQualifiedNameClassNameImportSkipVoter.php @@ -17,18 +17,18 @@ use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; * * SomeClass::callThis(); */ -final class FullyQualifiedNameClassNameImportSkipVoter implements \Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface +final class FullyQualifiedNameClassNameImportSkipVoter implements ClassNameImportSkipVoterInterface { /** * @readonly * @var \Rector\CodingStyle\ClassNameImport\ShortNameResolver */ private $shortNameResolver; - public function __construct(\Rector\CodingStyle\ClassNameImport\ShortNameResolver $shortNameResolver) + public function __construct(ShortNameResolver $shortNameResolver) { $this->shortNameResolver = $shortNameResolver; } - public function shouldSkip(\Rector\Core\ValueObject\Application\File $file, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType, \PhpParser\Node $node) : bool + public function shouldSkip(File $file, FullyQualifiedObjectType $fullyQualifiedObjectType, Node $node) : bool { // "new X" or "X::static()" /** @var array $shortNamesToFullyQualifiedNames */ diff --git a/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/UsesClassNameImportSkipVoter.php b/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/UsesClassNameImportSkipVoter.php index 187b3ee89b9..adc36022c3f 100644 --- a/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/UsesClassNameImportSkipVoter.php +++ b/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/UsesClassNameImportSkipVoter.php @@ -16,7 +16,7 @@ use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; * if there is already: * - use App\Another\Product */ -final class UsesClassNameImportSkipVoter implements \Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface +final class UsesClassNameImportSkipVoter implements ClassNameImportSkipVoterInterface { /** * @readonly @@ -28,12 +28,12 @@ final class UsesClassNameImportSkipVoter implements \Rector\CodingStyle\Contract * @var \Rector\Core\Configuration\RenamedClassesDataCollector */ private $renamedClassesDataCollector; - public function __construct(\Rector\PostRector\Collector\UseNodesToAddCollector $useNodesToAddCollector, \Rector\Core\Configuration\RenamedClassesDataCollector $renamedClassesDataCollector) + public function __construct(UseNodesToAddCollector $useNodesToAddCollector, RenamedClassesDataCollector $renamedClassesDataCollector) { $this->useNodesToAddCollector = $useNodesToAddCollector; $this->renamedClassesDataCollector = $renamedClassesDataCollector; } - public function shouldSkip(\Rector\Core\ValueObject\Application\File $file, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType, \PhpParser\Node $node) : bool + public function shouldSkip(File $file, FullyQualifiedObjectType $fullyQualifiedObjectType, Node $node) : bool { $useImportTypes = $this->useNodesToAddCollector->getUseImportTypesByNode($file, $node); foreach ($useImportTypes as $useImportType) { diff --git a/rules/CodingStyle/ClassNameImport/ClassNameImportSkipper.php b/rules/CodingStyle/ClassNameImport/ClassNameImportSkipper.php index f96f147ed54..7266a928261 100644 --- a/rules/CodingStyle/ClassNameImport/ClassNameImportSkipper.php +++ b/rules/CodingStyle/ClassNameImport/ClassNameImportSkipper.php @@ -26,12 +26,12 @@ final class ClassNameImportSkipper /** * @param ClassNameImportSkipVoterInterface[] $classNameImportSkipVoters */ - public function __construct(array $classNameImportSkipVoters, \Rector\Core\Configuration\RenamedClassesDataCollector $renamedClassesDataCollector) + public function __construct(array $classNameImportSkipVoters, RenamedClassesDataCollector $renamedClassesDataCollector) { $this->classNameImportSkipVoters = $classNameImportSkipVoters; $this->renamedClassesDataCollector = $renamedClassesDataCollector; } - public function shouldSkipNameForFullyQualifiedObjectType(\Rector\Core\ValueObject\Application\File $file, \PhpParser\Node $node, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : bool + public function shouldSkipNameForFullyQualifiedObjectType(File $file, Node $node, FullyQualifiedObjectType $fullyQualifiedObjectType) : bool { foreach ($this->classNameImportSkipVoters as $classNameImportSkipVoter) { if ($classNameImportSkipVoter->shouldSkip($file, $fullyQualifiedObjectType, $node)) { @@ -43,7 +43,7 @@ final class ClassNameImportSkipper /** * @param Use_[] $existingUses */ - public function isShortNameInUseStatement(\PhpParser\Node\Name $name, array $existingUses) : bool + public function isShortNameInUseStatement(Name $name, array $existingUses) : bool { $longName = $name->toString(); if (\strpos($longName, '\\') !== \false) { @@ -54,7 +54,7 @@ final class ClassNameImportSkipper /** * @param Use_[] $uses */ - public function isAlreadyImported(\PhpParser\Node\Name $name, array $uses) : bool + public function isAlreadyImported(Name $name, array $uses) : bool { $stringName = $name->toString(); foreach ($uses as $use) { @@ -69,7 +69,7 @@ final class ClassNameImportSkipper /** * @param Use_[] $uses */ - public function isFoundInUse(\PhpParser\Node\Name $name, array $uses) : bool + public function isFoundInUse(Name $name, array $uses) : bool { $stringName = $name->toString(); $nameLastName = \strtolower($name->getLast()); @@ -87,7 +87,7 @@ final class ClassNameImportSkipper } return \false; } - private function isJustRenamedClass(string $stringName, \PhpParser\Node\Stmt\UseUse $useUse) : bool + private function isJustRenamedClass(string $stringName, UseUse $useUse) : bool { $useUseNameString = $useUse->name->toString(); // is in renamed classes? skip it diff --git a/rules/CodingStyle/ClassNameImport/ShortNameResolver.php b/rules/CodingStyle/ClassNameImport/ShortNameResolver.php index 7990752cf7b..5e87cc217c8 100644 --- a/rules/CodingStyle/ClassNameImport/ShortNameResolver.php +++ b/rules/CodingStyle/ClassNameImport/ShortNameResolver.php @@ -68,7 +68,7 @@ final class ShortNameResolver * @var \Rector\CodingStyle\NodeAnalyzer\UseImportNameMatcher */ private $useImportNameMatcher; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\CodingStyle\NodeAnalyzer\UseImportNameMatcher $useImportNameMatcher) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider, BetterNodeFinder $betterNodeFinder, UseImportNameMatcher $useImportNameMatcher) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->nodeNameResolver = $nodeNameResolver; @@ -80,14 +80,14 @@ final class ShortNameResolver /** * @required */ - public function autowire(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory) : void + public function autowire(PhpDocInfoFactory $phpDocInfoFactory) : void { $this->phpDocInfoFactory = $phpDocInfoFactory; } /** * @return array */ - public function resolveFromFile(\Rector\Core\ValueObject\Application\File $file) : array + public function resolveFromFile(File $file) : array { $filePath = $file->getFilePath(); if (isset($this->shortNamesByFilePath[$filePath])) { @@ -101,15 +101,15 @@ final class ShortNameResolver * Collects all "class ", "trait " and "interface " * @return string[] */ - public function resolveShortClassLikeNamesForNode(\PhpParser\Node $node) : array + public function resolveShortClassLikeNamesForNode(Node $node) : array { - $namespace = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Namespace_::class); - if (!$namespace instanceof \PhpParser\Node\Stmt\Namespace_) { + $namespace = $this->betterNodeFinder->findParentType($node, Namespace_::class); + if (!$namespace instanceof Namespace_) { // only handle namespace nodes return []; } /** @var ClassLike[] $classLikes */ - $classLikes = $this->betterNodeFinder->findInstanceOf($namespace, \PhpParser\Node\Stmt\ClassLike::class); + $classLikes = $this->betterNodeFinder->findInstanceOf($namespace, ClassLike::class); $shortClassLikeNames = []; foreach ($classLikes as $classLike) { $shortClassLikeNames[] = $this->nodeNameResolver->getShortName($classLike); @@ -123,9 +123,9 @@ final class ShortNameResolver private function resolveForStmts(array $stmts) : array { $shortNamesToFullyQualifiedNames = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmts, function (\PhpParser\Node $node) use(&$shortNamesToFullyQualifiedNames) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmts, function (Node $node) use(&$shortNamesToFullyQualifiedNames) { // class name is used! - if ($node instanceof \PhpParser\Node\Stmt\ClassLike && $node->name instanceof \PhpParser\Node\Identifier) { + if ($node instanceof ClassLike && $node->name instanceof Identifier) { $fullyQualifiedName = $this->nodeNameResolver->getName($node); if ($fullyQualifiedName === null) { return null; @@ -133,11 +133,11 @@ final class ShortNameResolver $shortNamesToFullyQualifiedNames[$node->name->toString()] = $fullyQualifiedName; return null; } - if (!$node instanceof \PhpParser\Node\Name) { + if (!$node instanceof Name) { return null; } - $originalName = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NAME); - if (!$originalName instanceof \PhpParser\Node\Name) { + $originalName = $node->getAttribute(AttributeKey::ORIGINAL_NAME); + if (!$originalName instanceof Name) { return null; } // already short @@ -161,22 +161,22 @@ final class ShortNameResolver { $reflectionClass = $this->resolveNativeClassReflection($stmts); $shortNames = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmts, function (\PhpParser\Node $node) use(&$shortNames) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmts, function (Node $node) use(&$shortNames) { // speed up for nodes that are $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); - if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$phpDocInfo instanceof PhpDocInfo) { return null; } - $phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser(); + $phpDocNodeTraverser = new PhpDocNodeTraverser(); $phpDocNodeTraverser->traverseWithCallable($phpDocInfo->getPhpDocNode(), '', function ($node) use(&$shortNames) { - if ($node instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) { + if ($node instanceof PhpDocTagNode) { $shortName = \trim($node->name, '@'); - if (\Rector\Core\Util\StringUtils::isMatch($shortName, self::BIG_LETTER_START_REGEX)) { + if (StringUtils::isMatch($shortName, self::BIG_LETTER_START_REGEX)) { $shortNames[] = $shortName; } return null; } - if ($node instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode) { + if ($node instanceof IdentifierTypeNode) { $shortNames[] = $node->name; } return null; @@ -188,10 +188,10 @@ final class ShortNameResolver /** * @param Node[] $stmts */ - private function resolveNativeClassReflection(array $stmts) : ?\ReflectionClass + private function resolveNativeClassReflection(array $stmts) : ?ReflectionClass { - $firstClassLike = $this->betterNodeFinder->findFirstInstanceOf($stmts, \PhpParser\Node\Stmt\ClassLike::class); - if (!$firstClassLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $firstClassLike = $this->betterNodeFinder->findFirstInstanceOf($stmts, ClassLike::class); + if (!$firstClassLike instanceof ClassLike) { return null; } $className = (string) $this->nodeNameResolver->getName($firstClassLike); @@ -206,13 +206,13 @@ final class ShortNameResolver * @param Stmt[] $stmts * @return array */ - private function fqnizeShortNames(array $shortNames, ?\ReflectionClass $reflectionClass, array $stmts) : array + private function fqnizeShortNames(array $shortNames, ?ReflectionClass $reflectionClass, array $stmts) : array { $shortNamesToFullyQualifiedNames = []; foreach ($shortNames as $shortName) { $stmtsMatchedName = $this->useImportNameMatcher->matchNameWithStmts($shortName, $stmts); - if ($reflectionClass instanceof \ReflectionClass) { - $fullyQualifiedName = \RectorPrefix20220607\Nette\Utils\Reflection::expandClassName($shortName, $reflectionClass); + if ($reflectionClass instanceof ReflectionClass) { + $fullyQualifiedName = Reflection::expandClassName($shortName, $reflectionClass); } elseif (\is_string($stmtsMatchedName)) { $fullyQualifiedName = $stmtsMatchedName; } else { diff --git a/rules/CodingStyle/ClassNameImport/UseImportsTraverser.php b/rules/CodingStyle/ClassNameImport/UseImportsTraverser.php index bb9697f0734..a10ab2719de 100644 --- a/rules/CodingStyle/ClassNameImport/UseImportsTraverser.php +++ b/rules/CodingStyle/ClassNameImport/UseImportsTraverser.php @@ -22,7 +22,7 @@ final class UseImportsTraverser * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->nodeNameResolver = $nodeNameResolver; @@ -33,7 +33,7 @@ final class UseImportsTraverser */ public function traverserStmts(array $stmts, callable $callable) : void { - $this->traverseForType($stmts, $callable, \PhpParser\Node\Stmt\Use_::TYPE_NORMAL); + $this->traverseForType($stmts, $callable, Use_::TYPE_NORMAL); } /** * @param Stmt[] $stmts @@ -41,7 +41,7 @@ final class UseImportsTraverser */ public function traverserStmtsForFunctions(array $stmts, callable $callable) : void { - $this->traverseForType($stmts, $callable, \PhpParser\Node\Stmt\Use_::TYPE_FUNCTION); + $this->traverseForType($stmts, $callable, Use_::TYPE_FUNCTION); } /** * @param callable(UseUse $useUse, string $name): void $callable @@ -49,8 +49,8 @@ final class UseImportsTraverser */ private function traverseForType(array $stmts, callable $callable, int $desiredType) : void { - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmts, function (\PhpParser\Node $node) use($callable, $desiredType) { - if ($node instanceof \PhpParser\Node\Stmt\Use_) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmts, function (Node $node) use($callable, $desiredType) { + if ($node instanceof Use_) { // only import uses if ($node->type !== $desiredType) { return null; @@ -63,7 +63,7 @@ final class UseImportsTraverser $callable($useUse, $name); } } - if ($node instanceof \PhpParser\Node\Stmt\GroupUse) { + if ($node instanceof GroupUse) { $this->processGroupUse($node, $desiredType, $callable); } return null; @@ -72,9 +72,9 @@ final class UseImportsTraverser /** * @param callable(UseUse $useUse, string $name): void $callable */ - private function processGroupUse(\PhpParser\Node\Stmt\GroupUse $groupUse, int $desiredType, callable $callable) : void + private function processGroupUse(GroupUse $groupUse, int $desiredType, callable $callable) : void { - if ($groupUse->type !== \PhpParser\Node\Stmt\Use_::TYPE_UNKNOWN) { + if ($groupUse->type !== Use_::TYPE_UNKNOWN) { return; } $prefixName = $groupUse->prefix->toString(); diff --git a/rules/CodingStyle/ClassNameImport/UsedImportsResolver.php b/rules/CodingStyle/ClassNameImport/UsedImportsResolver.php index 51029c55ac5..e6e0b3c5ed0 100644 --- a/rules/CodingStyle/ClassNameImport/UsedImportsResolver.php +++ b/rules/CodingStyle/ClassNameImport/UsedImportsResolver.php @@ -29,7 +29,7 @@ final class UsedImportsResolver * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\CodingStyle\ClassNameImport\UseImportsTraverser $useImportsTraverser, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(BetterNodeFinder $betterNodeFinder, \Rector\CodingStyle\ClassNameImport\UseImportsTraverser $useImportsTraverser, NodeNameResolver $nodeNameResolver) { $this->betterNodeFinder = $betterNodeFinder; $this->useImportsTraverser = $useImportsTraverser; @@ -38,10 +38,10 @@ final class UsedImportsResolver /** * @return array */ - public function resolveForNode(\PhpParser\Node $node) : array + public function resolveForNode(Node $node) : array { - $namespace = $node instanceof \PhpParser\Node\Stmt\Namespace_ ? $node : $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Namespace_::class); - if ($namespace instanceof \PhpParser\Node\Stmt\Namespace_) { + $namespace = $node instanceof Namespace_ ? $node : $this->betterNodeFinder->findParentType($node, Namespace_::class); + if ($namespace instanceof Namespace_) { return $this->resolveForNamespace($namespace); } return []; @@ -54,18 +54,18 @@ final class UsedImportsResolver { $usedImports = []; /** @var Class_|null $class */ - $class = $this->betterNodeFinder->findFirstInstanceOf($stmts, \PhpParser\Node\Stmt\Class_::class); + $class = $this->betterNodeFinder->findFirstInstanceOf($stmts, Class_::class); // add class itself // is not anonymous class - if ($class instanceof \PhpParser\Node\Stmt\Class_) { + if ($class instanceof Class_) { $className = (string) $this->nodeNameResolver->getName($class); - $usedImports[] = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($className); + $usedImports[] = new FullyQualifiedObjectType($className); } - $this->useImportsTraverser->traverserStmts($stmts, function (\PhpParser\Node\Stmt\UseUse $useUse, string $name) use(&$usedImports) : void { + $this->useImportsTraverser->traverserStmts($stmts, function (UseUse $useUse, string $name) use(&$usedImports) : void { if ($useUse->alias !== null) { - $usedImports[] = new \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType($useUse->alias->toString(), $name); + $usedImports[] = new AliasedObjectType($useUse->alias->toString(), $name); } else { - $usedImports[] = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($name); + $usedImports[] = new FullyQualifiedObjectType($name); } }); return $usedImports; @@ -77,15 +77,15 @@ final class UsedImportsResolver public function resolveFunctionImportsForStmts(array $stmts) : array { $usedFunctionImports = []; - $this->useImportsTraverser->traverserStmtsForFunctions($stmts, function (\PhpParser\Node\Stmt\UseUse $useUse, string $name) use(&$usedFunctionImports) : void { - $usedFunctionImports[] = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($name); + $this->useImportsTraverser->traverserStmtsForFunctions($stmts, function (UseUse $useUse, string $name) use(&$usedFunctionImports) : void { + $usedFunctionImports[] = new FullyQualifiedObjectType($name); }); return $usedFunctionImports; } /** * @return array */ - private function resolveForNamespace(\PhpParser\Node\Stmt\Namespace_ $namespace) : array + private function resolveForNamespace(Namespace_ $namespace) : array { return $this->resolveForStmts($namespace->stmts); } diff --git a/rules/CodingStyle/Contract/ClassNameImport/ClassNameImportSkipVoterInterface.php b/rules/CodingStyle/Contract/ClassNameImport/ClassNameImportSkipVoterInterface.php index f176fb119a4..0fbceffaf09 100644 --- a/rules/CodingStyle/Contract/ClassNameImport/ClassNameImportSkipVoterInterface.php +++ b/rules/CodingStyle/Contract/ClassNameImport/ClassNameImportSkipVoterInterface.php @@ -8,5 +8,5 @@ use Rector\Core\ValueObject\Application\File; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; interface ClassNameImportSkipVoterInterface { - public function shouldSkip(\Rector\Core\ValueObject\Application\File $file, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType, \PhpParser\Node $node) : bool; + public function shouldSkip(File $file, FullyQualifiedObjectType $fullyQualifiedObjectType, Node $node) : bool; } diff --git a/rules/CodingStyle/Naming/ClassNaming.php b/rules/CodingStyle/Naming/ClassNaming.php index a078805496f..d90cf77170f 100644 --- a/rules/CodingStyle/Naming/ClassNaming.php +++ b/rules/CodingStyle/Naming/ClassNaming.php @@ -22,17 +22,17 @@ final class ClassNaming */ public function getShortName($name) : string { - if ($name instanceof \PhpParser\Node\Stmt\ClassLike) { + if ($name instanceof ClassLike) { if ($name->name === null) { return ''; } return $this->getShortName($name->name); } - if ($name instanceof \PhpParser\Node\Name || $name instanceof \PhpParser\Node\Identifier) { + if ($name instanceof Name || $name instanceof Identifier) { $name = $name->toString(); } $name = \trim($name, '\\'); - $shortName = \RectorPrefix20220607\Nette\Utils\Strings::after($name, '\\', -1); + $shortName = Strings::after($name, '\\', -1); if (\is_string($shortName)) { return $shortName; } @@ -41,6 +41,6 @@ final class ClassNaming public function getNamespace(string $fullyQualifiedName) : ?string { $fullyQualifiedName = \trim($fullyQualifiedName, '\\'); - return \RectorPrefix20220607\Nette\Utils\Strings::before($fullyQualifiedName, '\\', -1); + return Strings::before($fullyQualifiedName, '\\', -1); } } diff --git a/rules/CodingStyle/Node/NameImporter.php b/rules/CodingStyle/Node/NameImporter.php index db96a7e66e5..591c7e827da 100644 --- a/rules/CodingStyle/Node/NameImporter.php +++ b/rules/CodingStyle/Node/NameImporter.php @@ -56,7 +56,7 @@ final class NameImporter * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\CodingStyle\ClassNameImport\AliasUsesResolver $aliasUsesResolver, \Rector\CodingStyle\ClassNameImport\ClassNameImportSkipper $classNameImportSkipper, \RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\PostRector\Collector\UseNodesToAddCollector $useNodesToAddCollector, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(AliasUsesResolver $aliasUsesResolver, ClassNameImportSkipper $classNameImportSkipper, ParameterProvider $parameterProvider, StaticTypeMapper $staticTypeMapper, UseNodesToAddCollector $useNodesToAddCollector, ReflectionProvider $reflectionProvider) { $this->aliasUsesResolver = $aliasUsesResolver; $this->classNameImportSkipper = $classNameImportSkipper; @@ -68,7 +68,7 @@ final class NameImporter /** * @param Use_[] $uses */ - public function importName(\PhpParser\Node\Name $name, \Rector\Core\ValueObject\Application\File $file, array $uses) : ?\PhpParser\Node\Name + public function importName(Name $name, File $file, array $uses) : ?Name { if ($this->shouldSkipName($name)) { return null; @@ -77,7 +77,7 @@ final class NameImporter return null; } $staticType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($name); - if (!$staticType instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) { + if (!$staticType instanceof FullyQualifiedObjectType) { return null; } $className = $staticType->getClassName(); @@ -85,9 +85,9 @@ final class NameImporter $this->aliasedUses = \strpos($className, '\\') !== \false ? [] : $this->aliasUsesResolver->resolveFromStmts($uses); return $this->importNameAndCollectNewUseStatement($file, $name, $staticType, $className); } - private function shouldSkipName(\PhpParser\Node\Name $name) : bool + private function shouldSkipName(Name $name) : bool { - $virtualNode = (bool) $name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::VIRTUAL_NODE); + $virtualNode = (bool) $name->getAttribute(AttributeKey::VIRTUAL_NODE); if ($virtualNode) { return \true; } @@ -104,7 +104,7 @@ final class NameImporter return \true; } // Importing root namespace classes (like \DateTime) is optional - if (!$this->parameterProvider->provideBoolParameter(\Rector\Core\Configuration\Option::IMPORT_SHORT_CLASSES)) { + if (!$this->parameterProvider->provideBoolParameter(Option::IMPORT_SHORT_CLASSES)) { $stringName = $name->toString(); if (\substr_count($stringName, '\\') === 0) { return \true; @@ -112,7 +112,7 @@ final class NameImporter } return \false; } - private function importNameAndCollectNewUseStatement(\Rector\Core\ValueObject\Application\File $file, \PhpParser\Node\Name $name, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType, string $className) : ?\PhpParser\Node\Name + private function importNameAndCollectNewUseStatement(File $file, Name $name, FullyQualifiedObjectType $fullyQualifiedObjectType, string $className) : ?Name { // the same end is already imported → skip if ($this->classNameImportSkipper->shouldSkipNameForFullyQualifiedObjectType($file, $name, $fullyQualifiedObjectType)) { @@ -141,37 +141,37 @@ final class NameImporter * - namespace name * - use import name */ - private function isNamespaceOrUseImportName(\PhpParser\Node\Name $name) : bool + private function isNamespaceOrUseImportName(Name $name) : bool { - $parentNode = $name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentNode instanceof \PhpParser\Node\Stmt\Namespace_) { + $parentNode = $name->getAttribute(AttributeKey::PARENT_NODE); + if ($parentNode instanceof Namespace_) { return \true; } - return $parentNode instanceof \PhpParser\Node\Stmt\UseUse; + return $parentNode instanceof UseUse; } - private function isFunctionOrConstantImportWithSingleName(\PhpParser\Node\Name $name) : bool + private function isFunctionOrConstantImportWithSingleName(Name $name) : bool { - $parentNode = $name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $name->getAttribute(AttributeKey::PARENT_NODE); $fullName = $name->toString(); - $autoImportNames = $this->parameterProvider->provideBoolParameter(\Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES); - if ($autoImportNames && !$parentNode instanceof \PhpParser\Node && \strpos($fullName, '\\') === \false && $this->reflectionProvider->hasFunction(new \PhpParser\Node\Name($fullName), null)) { + $autoImportNames = $this->parameterProvider->provideBoolParameter(Option::AUTO_IMPORT_NAMES); + if ($autoImportNames && !$parentNode instanceof Node && \strpos($fullName, '\\') === \false && $this->reflectionProvider->hasFunction(new Name($fullName), null)) { return \true; } - if ($parentNode instanceof \PhpParser\Node\Expr\ConstFetch) { + if ($parentNode instanceof ConstFetch) { return \count($name->parts) === 1; } - if ($parentNode instanceof \PhpParser\Node\Expr\FuncCall) { + if ($parentNode instanceof FuncCall) { return \count($name->parts) === 1; } return \false; } - private function addUseImport(\Rector\Core\ValueObject\Application\File $file, \PhpParser\Node\Name $name, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : void + private function addUseImport(File $file, Name $name, FullyQualifiedObjectType $fullyQualifiedObjectType) : void { if ($this->useNodesToAddCollector->hasImport($file, $name, $fullyQualifiedObjectType)) { return; } - $parentNode = $name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentNode instanceof \PhpParser\Node\Expr\FuncCall) { + $parentNode = $name->getAttribute(AttributeKey::PARENT_NODE); + if ($parentNode instanceof FuncCall) { $this->useNodesToAddCollector->addFunctionUseImport($fullyQualifiedObjectType); } else { $this->useNodesToAddCollector->addUseImport($fullyQualifiedObjectType); diff --git a/rules/CodingStyle/NodeAnalyzer/SpreadVariablesCollector.php b/rules/CodingStyle/NodeAnalyzer/SpreadVariablesCollector.php index 66861a88c8f..7c134fabf1a 100644 --- a/rules/CodingStyle/NodeAnalyzer/SpreadVariablesCollector.php +++ b/rules/CodingStyle/NodeAnalyzer/SpreadVariablesCollector.php @@ -19,7 +19,7 @@ final class SpreadVariablesCollector public function resolveFromMethodReflection($functionLikeReflection) : array { $spreadParameterReflections = []; - $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($functionLikeReflection->getVariants()); + $parametersAcceptor = ParametersAcceptorSelector::selectSingle($functionLikeReflection->getVariants()); foreach ($parametersAcceptor->getParameters() as $key => $parameterReflection) { if (!$parameterReflection->isVariadic()) { continue; @@ -31,14 +31,14 @@ final class SpreadVariablesCollector /** * @return array */ - public function resolveFromClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : array + public function resolveFromClassMethod(ClassMethod $classMethod) : array { /** @var array $spreadParams */ $spreadParams = []; foreach ($classMethod->params as $key => $param) { // prevent race-condition removal on class method - $originalParam = $param->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE); - if (!$originalParam instanceof \PhpParser\Node\Param) { + $originalParam = $param->getAttribute(AttributeKey::ORIGINAL_NODE); + if (!$originalParam instanceof Param) { continue; } if (!$originalParam->variadic) { diff --git a/rules/CodingStyle/NodeAnalyzer/UseImportNameMatcher.php b/rules/CodingStyle/NodeAnalyzer/UseImportNameMatcher.php index bd1c1e9d25e..27c9bc00b01 100644 --- a/rules/CodingStyle/NodeAnalyzer/UseImportNameMatcher.php +++ b/rules/CodingStyle/NodeAnalyzer/UseImportNameMatcher.php @@ -27,7 +27,7 @@ final class UseImportNameMatcher * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(BetterNodeFinder $betterNodeFinder) { $this->betterNodeFinder = $betterNodeFinder; } @@ -37,7 +37,7 @@ final class UseImportNameMatcher public function matchNameWithStmts(string $tag, array $stmts) : ?string { /** @var Use_[] $uses */ - $uses = $this->betterNodeFinder->findInstanceOf($stmts, \PhpParser\Node\Stmt\Use_::class); + $uses = $this->betterNodeFinder->findInstanceOf($stmts, Use_::class); return $this->matchNameWithUses($tag, $uses); } /** @@ -46,7 +46,7 @@ final class UseImportNameMatcher public function matchNameWithUses(string $tag, array $uses) : ?string { foreach ($uses as $use) { - $prefix = $use instanceof \PhpParser\Node\Stmt\GroupUse ? $use->prefix . '\\' : ''; + $prefix = $use instanceof GroupUse ? $use->prefix . '\\' : ''; foreach ($use->uses as $useUse) { if (!$this->isUseMatchingName($tag, $useUse)) { continue; @@ -56,32 +56,32 @@ final class UseImportNameMatcher } return null; } - public function resolveName(string $prefix, string $tag, \PhpParser\Node\Stmt\UseUse $useUse) : string + public function resolveName(string $prefix, string $tag, UseUse $useUse) : string { // useuse can be renamed on the fly, so just in case, use the original one - $originalUseUse = $useUse->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE); - if (!$originalUseUse instanceof \PhpParser\Node\Stmt\UseUse) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $originalUseUse = $useUse->getAttribute(AttributeKey::ORIGINAL_NODE); + if (!$originalUseUse instanceof UseUse) { + throw new ShouldNotHappenException(); } if ($originalUseUse->alias === null) { return $prefix . $originalUseUse->name->toString(); } - $unaliasedShortClass = \RectorPrefix20220607\Nette\Utils\Strings::substring($tag, \RectorPrefix20220607\Nette\Utils\Strings::length($originalUseUse->alias->toString())); + $unaliasedShortClass = Strings::substring($tag, Strings::length($originalUseUse->alias->toString())); if (\strncmp($unaliasedShortClass, '\\', \strlen('\\')) === 0) { return $prefix . $originalUseUse->name . $unaliasedShortClass; } return $prefix . $originalUseUse->name . '\\' . $unaliasedShortClass; } - private function isUseMatchingName(string $tag, \PhpParser\Node\Stmt\UseUse $useUse) : bool + private function isUseMatchingName(string $tag, UseUse $useUse) : bool { // useuse can be renamed on the fly, so just in case, use the original one - $originalUseUse = $useUse->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE); - if (!$originalUseUse instanceof \PhpParser\Node\Stmt\UseUse) { + $originalUseUse = $useUse->getAttribute(AttributeKey::ORIGINAL_NODE); + if (!$originalUseUse instanceof UseUse) { return \false; } - $shortName = $originalUseUse->alias instanceof \PhpParser\Node\Identifier ? $originalUseUse->alias->name : $originalUseUse->name->getLast(); + $shortName = $originalUseUse->alias instanceof Identifier ? $originalUseUse->alias->name : $originalUseUse->name->getLast(); $shortNamePattern = \preg_quote($shortName, '#'); $pattern = \sprintf(self::SHORT_NAME_REGEX, $shortNamePattern); - return \Rector\Core\Util\StringUtils::isMatch($tag, $pattern); + return StringUtils::isMatch($tag, $pattern); } } diff --git a/rules/CodingStyle/NodeFactory/ArrayCallableToMethodCallFactory.php b/rules/CodingStyle/NodeFactory/ArrayCallableToMethodCallFactory.php index 62fd2533b13..0b276fa7b8d 100644 --- a/rules/CodingStyle/NodeFactory/ArrayCallableToMethodCallFactory.php +++ b/rules/CodingStyle/NodeFactory/ArrayCallableToMethodCallFactory.php @@ -18,35 +18,35 @@ final class ArrayCallableToMethodCallFactory * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(NodeTypeResolver $nodeTypeResolver) { $this->nodeTypeResolver = $nodeTypeResolver; } - public function create(\PhpParser\Node\Expr\Array_ $array) : ?\PhpParser\Node\Expr\MethodCall + public function create(Array_ $array) : ?MethodCall { if (\count($array->items) !== 2) { return null; } $firstItem = $array->items[0]; $secondItem = $array->items[1]; - if (!$firstItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$firstItem instanceof ArrayItem) { return null; } - if (!$secondItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$secondItem instanceof ArrayItem) { return null; } - if (!$secondItem->value instanceof \PhpParser\Node\Scalar\String_) { + if (!$secondItem->value instanceof String_) { return null; } - if (!$firstItem->value instanceof \PhpParser\Node\Expr\PropertyFetch && !$firstItem->value instanceof \PhpParser\Node\Expr\Variable) { + if (!$firstItem->value instanceof PropertyFetch && !$firstItem->value instanceof Variable) { return null; } $firstItemType = $this->nodeTypeResolver->getType($firstItem->value); - if (!$firstItemType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$firstItemType instanceof TypeWithClassName) { return null; } $string = $secondItem->value; $methodName = $string->value; - return new \PhpParser\Node\Expr\MethodCall($firstItem->value, $methodName); + return new MethodCall($firstItem->value, $methodName); } } diff --git a/rules/CodingStyle/Rector/Assign/PHPStormVarAnnotationRector.php b/rules/CodingStyle/Rector/Assign/PHPStormVarAnnotationRector.php index b25183070d3..eb84344d7b3 100644 --- a/rules/CodingStyle/Rector/Assign/PHPStormVarAnnotationRector.php +++ b/rules/CodingStyle/Rector/Assign/PHPStormVarAnnotationRector.php @@ -13,13 +13,13 @@ use PhpParser\Node\Stmt\Nop; use Rector\Core\Rector\AbstractRector; use Rector\Core\Util\StringUtils; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/shopsys/shopsys/pull/524 * @see \Rector\Tests\CodingStyle\Rector\Assign\PHPStormVarAnnotationRector\PHPStormVarAnnotationRectorTest */ -final class PHPStormVarAnnotationRector extends \Rector\Core\Rector\AbstractRector +final class PHPStormVarAnnotationRector extends AbstractRector { /** * @var string @@ -36,9 +36,9 @@ final class PHPStormVarAnnotationRector extends \Rector\Core\Rector\AbstractRect * @see https://regex101.com/r/yz2AZ7/1 */ private const VARIABLE_NAME_AND_TYPE_MATCH_REGEX = '#(?\\$\\w+)(?\\s+)(?[\\\\\\w]+)#'; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change various @var annotation formats to one PHPStorm understands', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change various @var annotation formats to one PHPStorm understands', [new CodeSample(<<<'CODE_SAMPLE' $config = 5; /** @var \Shopsys\FrameworkBundle\Model\Product\Filter\ProductFilterConfig $config */ CODE_SAMPLE @@ -53,20 +53,20 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Assign::class]; + return [Assign::class]; } /** * @param Assign $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $expression = $this->betterNodeFinder->resolveCurrentStatement($node); // unable to analyze - if (!$expression instanceof \PhpParser\Node\Stmt\Expression) { + if (!$expression instanceof Expression) { return null; } - $nextNode = $expression->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if (!$nextNode instanceof \PhpParser\Node) { + $nextNode = $expression->getAttribute(AttributeKey::NEXT_NODE); + if (!$nextNode instanceof Node) { return null; } $docContent = $this->getDocContent($nextNode); @@ -76,31 +76,31 @@ CODE_SAMPLE if (\strpos($docContent, '@var') === \false) { return null; } - if (!$node->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$node->var instanceof Variable) { return null; } $varName = '$' . $this->getName($node->var); $varPattern = '# ' . \preg_quote($varName, '#') . ' #'; - if (!\Rector\Core\Util\StringUtils::isMatch($docContent, $varPattern)) { + if (!StringUtils::isMatch($docContent, $varPattern)) { return null; } // switch docs $expression->setDocComment($this->createDocComment($nextNode)); $expressionPhpDocInfo = $this->phpDocInfoFactory->createFromNode($expression); - $expression->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $expressionPhpDocInfo); + $expression->setAttribute(AttributeKey::PHP_DOC_INFO, $expressionPhpDocInfo); // invoke override - $expression->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $expression->setAttribute(AttributeKey::ORIGINAL_NODE, null); // remove otherwise empty node - if ($nextNode instanceof \PhpParser\Node\Stmt\Nop) { + if ($nextNode instanceof Nop) { $this->removeNode($nextNode); return null; } // remove commnets - $nextNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, null); - $nextNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, null); + $nextNode->setAttribute(AttributeKey::PHP_DOC_INFO, null); + $nextNode->setAttribute(AttributeKey::COMMENTS, null); return $node; } - private function getDocContent(\PhpParser\Node $node) : string + private function getDocContent(Node $node) : string { $docComment = $node->getDocComment(); if ($docComment !== null) { @@ -115,7 +115,7 @@ CODE_SAMPLE } return ''; } - private function createDocComment(\PhpParser\Node $node) : \PhpParser\Comment\Doc + private function createDocComment(Node $node) : Doc { if ($node->getDocComment() !== null) { return $node->getDocComment(); @@ -124,12 +124,12 @@ CODE_SAMPLE // normalize content // starts with "/*", instead of "/**" if (\strncmp($docContent, '/* ', \strlen('/* ')) === 0) { - $docContent = \RectorPrefix20220607\Nette\Utils\Strings::replace($docContent, self::SINGLE_ASTERISK_COMMENT_START_REGEX, '/** '); + $docContent = Strings::replace($docContent, self::SINGLE_ASTERISK_COMMENT_START_REGEX, '/** '); } // $value is first, instead of type is first - if (\Rector\Core\Util\StringUtils::isMatch($docContent, self::VAR_ANNOTATION_REGEX)) { - $docContent = \RectorPrefix20220607\Nette\Utils\Strings::replace($docContent, self::VARIABLE_NAME_AND_TYPE_MATCH_REGEX, '$3$2$1'); + if (StringUtils::isMatch($docContent, self::VAR_ANNOTATION_REGEX)) { + $docContent = Strings::replace($docContent, self::VARIABLE_NAME_AND_TYPE_MATCH_REGEX, '$3$2$1'); } - return new \PhpParser\Comment\Doc($docContent); + return new Doc($docContent); } } diff --git a/rules/CodingStyle/Rector/Assign/SplitDoubleAssignRector.php b/rules/CodingStyle/Rector/Assign/SplitDoubleAssignRector.php index 13535bad7e0..31fc964401e 100644 --- a/rules/CodingStyle/Rector/Assign/SplitDoubleAssignRector.php +++ b/rules/CodingStyle/Rector/Assign/SplitDoubleAssignRector.php @@ -8,16 +8,16 @@ use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\CallLike; use PhpParser\Node\Stmt\Expression; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\Assign\SplitDoubleAssignRector\SplitDoubleAssignRectorTest */ -final class SplitDoubleAssignRector extends \Rector\Core\Rector\AbstractRector +final class SplitDoubleAssignRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Split multiple inline assigns to each own lines default value, to prevent undefined array issues', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Split multiple inline assigns to each own lines default value, to prevent undefined array issues', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -43,30 +43,30 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Expression::class]; + return [Expression::class]; } /** * @param Expression $node * @return Expression[]|null */ - public function refactor(\PhpParser\Node $node) : ?array + public function refactor(Node $node) : ?array { - if (!$node->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$node->expr instanceof Assign) { return null; } $firstAssign = $node->expr; - if (!$firstAssign->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$firstAssign->expr instanceof Assign) { return null; } $nestedAssign = $firstAssign->expr; - $newAssign = new \PhpParser\Node\Expr\Assign($firstAssign->var, $nestedAssign->expr); - $newAssignExpression = new \PhpParser\Node\Stmt\Expression($newAssign); + $newAssign = new Assign($firstAssign->var, $nestedAssign->expr); + $newAssignExpression = new Expression($newAssign); // avoid calling the same method/funtion/new twice - if (!$nestedAssign->expr instanceof \PhpParser\Node\Expr\CallLike) { - $varAssign = new \PhpParser\Node\Expr\Assign($nestedAssign->var, $nestedAssign->expr); - return [$newAssignExpression, new \PhpParser\Node\Stmt\Expression($varAssign)]; + if (!$nestedAssign->expr instanceof CallLike) { + $varAssign = new Assign($nestedAssign->var, $nestedAssign->expr); + return [$newAssignExpression, new Expression($varAssign)]; } - $varAssign = new \PhpParser\Node\Expr\Assign($nestedAssign->var, $firstAssign->var); - return [$newAssignExpression, new \PhpParser\Node\Stmt\Expression($varAssign)]; + $varAssign = new Assign($nestedAssign->var, $firstAssign->var); + return [$newAssignExpression, new Expression($varAssign)]; } } diff --git a/rules/CodingStyle/Rector/Catch_/CatchExceptionNameMatchingTypeRector.php b/rules/CodingStyle/Rector/Catch_/CatchExceptionNameMatchingTypeRector.php index 917339d26e5..11ee393dfaa 100644 --- a/rules/CodingStyle/Rector/Catch_/CatchExceptionNameMatchingTypeRector.php +++ b/rules/CodingStyle/Rector/Catch_/CatchExceptionNameMatchingTypeRector.php @@ -15,12 +15,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\Naming\Naming\AliasNameResolver; use Rector\Naming\Naming\PropertyNaming; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector\CatchExceptionNameMatchingTypeRectorTest */ -final class CatchExceptionNameMatchingTypeRector extends \Rector\Core\Rector\AbstractRector +final class CatchExceptionNameMatchingTypeRector extends AbstractRector { /** * @var string @@ -37,14 +37,14 @@ final class CatchExceptionNameMatchingTypeRector extends \Rector\Core\Rector\Abs * @var \Rector\Naming\Naming\AliasNameResolver */ private $aliasNameResolver; - public function __construct(\Rector\Naming\Naming\PropertyNaming $propertyNaming, \Rector\Naming\Naming\AliasNameResolver $aliasNameResolver) + public function __construct(PropertyNaming $propertyNaming, AliasNameResolver $aliasNameResolver) { $this->propertyNaming = $propertyNaming; $this->aliasNameResolver = $aliasNameResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Type and name of catch exception should match', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Type and name of catch exception should match', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -77,12 +77,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Catch_::class]; + return [Catch_::class]; } /** * @param Catch_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (\count($node->types) !== 1) { return null; @@ -100,19 +100,19 @@ CODE_SAMPLE if (\is_string($aliasName)) { $typeShortName = $aliasName; } - $newVariableName = \RectorPrefix20220607\Nette\Utils\Strings::replace(\lcfirst($typeShortName), self::STARTS_WITH_ABBREVIATION_REGEX, function (array $matches) : string { + $newVariableName = Strings::replace(\lcfirst($typeShortName), self::STARTS_WITH_ABBREVIATION_REGEX, function (array $matches) : string { $output = ''; $output .= isset($matches[1]) ? \strtolower((string) $matches[1]) : ''; $output .= $matches[2] ?? ''; return $output . ($matches[3] ?? ''); }); - $objectType = new \PHPStan\Type\ObjectType($newVariableName); + $objectType = new ObjectType($newVariableName); $newVariableName = $this->propertyNaming->fqnToVariableName($objectType); if ($oldVariableName === $newVariableName) { return null; } - $newVariable = new \PhpParser\Node\Expr\Variable($newVariableName); - $isFoundInPrevious = (bool) $this->betterNodeFinder->findFirstPrevious($node, function (\PhpParser\Node $subNode) use($newVariable) : bool { + $newVariable = new Variable($newVariableName); + $isFoundInPrevious = (bool) $this->betterNodeFinder->findFirstPrevious($node, function (Node $subNode) use($newVariable) : bool { return $this->nodeComparator->areNodesEqual($subNode, $newVariable); }); if ($isFoundInPrevious) { @@ -122,10 +122,10 @@ CODE_SAMPLE $this->renameVariableInStmts($node, $oldVariableName, $newVariableName); return $node; } - private function renameVariableInStmts(\PhpParser\Node\Stmt\Catch_ $catch, string $oldVariableName, string $newVariableName) : void + private function renameVariableInStmts(Catch_ $catch, string $oldVariableName, string $newVariableName) : void { - $this->traverseNodesWithCallable($catch->stmts, function (\PhpParser\Node $node) use($oldVariableName, $newVariableName) { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + $this->traverseNodesWithCallable($catch->stmts, function (Node $node) use($oldVariableName, $newVariableName) { + if (!$node instanceof Variable) { return null; } if (!$this->nodeNameResolver->isName($node, $oldVariableName)) { @@ -135,27 +135,27 @@ CODE_SAMPLE return null; }); /** @var TryCatch $tryCatch */ - $tryCatch = $catch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - $next = $tryCatch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); + $tryCatch = $catch->getAttribute(AttributeKey::PARENT_NODE); + $next = $tryCatch->getAttribute(AttributeKey::NEXT_NODE); $this->replaceNextUsageVariable($tryCatch, $next, $oldVariableName, $newVariableName); } - private function replaceNextUsageVariable(\PhpParser\Node $currentNode, ?\PhpParser\Node $nextNode, string $oldVariableName, string $newVariableName) : void + private function replaceNextUsageVariable(Node $currentNode, ?Node $nextNode, string $oldVariableName, string $newVariableName) : void { - if (!$nextNode instanceof \PhpParser\Node) { - $parent = $currentNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node) { + if (!$nextNode instanceof Node) { + $parent = $currentNode->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Node) { return; } - if ($parent instanceof \PhpParser\Node\FunctionLike) { + if ($parent instanceof FunctionLike) { return; } - $nextNode = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); + $nextNode = $parent->getAttribute(AttributeKey::NEXT_NODE); $this->replaceNextUsageVariable($parent, $nextNode, $oldVariableName, $newVariableName); return; } /** @var Variable[] $variables */ - $variables = $this->betterNodeFinder->find($nextNode, function (\PhpParser\Node $node) use($oldVariableName) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + $variables = $this->betterNodeFinder->find($nextNode, function (Node $node) use($oldVariableName) : bool { + if (!$node instanceof Variable) { return \false; } return $this->nodeNameResolver->isName($node, $oldVariableName); @@ -165,7 +165,7 @@ CODE_SAMPLE return; } $currentNode = $nextNode; - $nextNode = $nextNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); + $nextNode = $nextNode->getAttribute(AttributeKey::NEXT_NODE); $this->replaceNextUsageVariable($currentNode, $nextNode, $oldVariableName, $newVariableName); } /** @@ -174,8 +174,8 @@ CODE_SAMPLE private function processRenameVariable(array $variables, string $oldVariableName, string $newVariableName) : bool { foreach ($variables as $variable) { - $parent = $variable->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\Expr\Assign && $this->nodeComparator->areNodesEqual($parent->var, $variable) && $this->nodeNameResolver->isName($parent->var, $oldVariableName) && !$this->nodeComparator->areNodesEqual($parent->expr, $variable)) { + $parent = $variable->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof Assign && $this->nodeComparator->areNodesEqual($parent->var, $variable) && $this->nodeNameResolver->isName($parent->var, $oldVariableName) && !$this->nodeComparator->areNodesEqual($parent->expr, $variable)) { return \false; } $variable->name = $newVariableName; diff --git a/rules/CodingStyle/Rector/ClassConst/RemoveFinalFromConstRector.php b/rules/CodingStyle/Rector/ClassConst/RemoveFinalFromConstRector.php index 85648ca4654..941e463bc96 100644 --- a/rules/CodingStyle/Rector/ClassConst/RemoveFinalFromConstRector.php +++ b/rules/CodingStyle/Rector/ClassConst/RemoveFinalFromConstRector.php @@ -10,27 +10,27 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Privatization\NodeManipulator\VisibilityManipulator; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://php.watch/versions/8.1/final-class-const * * @see \Rector\Tests\CodingStyle\Rector\ClassConst\RemoveFinalFromConstRector\RemoveFinalFromConstRectorTest */ -final class RemoveFinalFromConstRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class RemoveFinalFromConstRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\Privatization\NodeManipulator\VisibilityManipulator */ private $visibilityManipulator; - public function __construct(\Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator) + public function __construct(VisibilityManipulator $visibilityManipulator) { $this->visibilityManipulator = $visibilityManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove final from constants in classes defined as final', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove final from constants in classes defined as final', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { final public const NAME = 'value'; @@ -49,15 +49,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassConst::class]; + return [ClassConst::class]; } /** * @param ClassConst $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $parentClass = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$parentClass instanceof \PhpParser\Node\Stmt\Class_) { + $parentClass = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$parentClass instanceof Class_) { return null; } if ($parentClass->isFinal() && $node->isFinal()) { @@ -68,6 +68,6 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::FINAL_CLASS_CONSTANTS; + return PhpVersionFeature::FINAL_CLASS_CONSTANTS; } } diff --git a/rules/CodingStyle/Rector/ClassConst/SplitGroupedConstantsAndPropertiesRector.php b/rules/CodingStyle/Rector/ClassConst/SplitGroupedConstantsAndPropertiesRector.php index e1b22423235..92f8159f678 100644 --- a/rules/CodingStyle/Rector/ClassConst/SplitGroupedConstantsAndPropertiesRector.php +++ b/rules/CodingStyle/Rector/ClassConst/SplitGroupedConstantsAndPropertiesRector.php @@ -9,16 +9,16 @@ use PhpParser\Node\Stmt\ClassConst; use PhpParser\Node\Stmt\Property; use PhpParser\Node\Stmt\PropertyProperty; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\ClassConst\SplitGroupedConstantsAndPropertiesRector\SplitGroupedConstantsAndPropertiesRectorTest */ -final class SplitGroupedConstantsAndPropertiesRector extends \Rector\Core\Rector\AbstractRector +final class SplitGroupedConstantsAndPropertiesRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Separate constant and properties to own lines', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Separate constant and properties to own lines', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { const HI = true, AHOJ = 'true'; @@ -53,15 +53,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassConst::class, \PhpParser\Node\Stmt\Property::class]; + return [ClassConst::class, Property::class]; } /** * @param ClassConst|Property $node * @return Node[]|null */ - public function refactor(\PhpParser\Node $node) : ?array + public function refactor(Node $node) : ?array { - if ($node instanceof \PhpParser\Node\Stmt\ClassConst) { + if ($node instanceof ClassConst) { if (\count($node->consts) < 2) { return null; } @@ -82,7 +82,7 @@ CODE_SAMPLE $node->props = [$firstPropertyProperty]; $nextProperties = []; foreach ($allProperties as $allProperty) { - $nextProperties[] = new \PhpParser\Node\Stmt\Property($node->flags, [$allProperty], $node->getAttributes()); + $nextProperties[] = new Property($node->flags, [$allProperty], $node->getAttributes()); } $item0Unpacked = [$node]; return \array_merge($item0Unpacked, $nextProperties); @@ -91,11 +91,11 @@ CODE_SAMPLE * @param Const_[] $consts * @return ClassConst[] */ - private function createNextClassConsts(array $consts, \PhpParser\Node\Stmt\ClassConst $classConst) : array + private function createNextClassConsts(array $consts, ClassConst $classConst) : array { $decoratedConsts = []; foreach ($consts as $const) { - $decoratedConsts[] = new \PhpParser\Node\Stmt\ClassConst([$const], $classConst->flags, $classConst->getAttributes()); + $decoratedConsts[] = new ClassConst([$const], $classConst->flags, $classConst->getAttributes()); } return $decoratedConsts; } diff --git a/rules/CodingStyle/Rector/ClassConst/VarConstantCommentRector.php b/rules/CodingStyle/Rector/ClassConst/VarConstantCommentRector.php index 2d6b3b84aaa..df20197005b 100644 --- a/rules/CodingStyle/Rector/ClassConst/VarConstantCommentRector.php +++ b/rules/CodingStyle/Rector/ClassConst/VarConstantCommentRector.php @@ -18,12 +18,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\TypeComparator\TypeComparator; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\Privatization\TypeManipulator\TypeNormalizer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\ClassConst\VarConstantCommentRector\VarConstantCommentRectorTest */ -final class VarConstantCommentRector extends \Rector\Core\Rector\AbstractRector +final class VarConstantCommentRector extends AbstractRector { /** * @readonly @@ -40,15 +40,15 @@ final class VarConstantCommentRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Privatization\TypeManipulator\TypeNormalizer */ private $typeNormalizer; - public function __construct(\Rector\NodeTypeResolver\TypeComparator\TypeComparator $typeComparator, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\Privatization\TypeManipulator\TypeNormalizer $typeNormalizer) + public function __construct(TypeComparator $typeComparator, PhpDocTypeChanger $phpDocTypeChanger, TypeNormalizer $typeNormalizer) { $this->typeComparator = $typeComparator; $this->phpDocTypeChanger = $phpDocTypeChanger; $this->typeNormalizer = $typeNormalizer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Constant should have a @var comment with type', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Constant should have a @var comment with type', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { const HI = 'hi'; @@ -70,18 +70,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassConst::class]; + return [ClassConst::class]; } /** * @param ClassConst $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (\count($node->consts) > 1) { return null; } $constType = $this->getType($node->consts[0]->value); - if ($constType instanceof \PHPStan\Type\MixedType) { + if ($constType instanceof MixedType) { return null; } // generalize false/true type to bool, as mostly default value but accepts both @@ -99,18 +99,18 @@ CODE_SAMPLE } return $node; } - private function hasTwoAndMoreGenericClassStringTypes(\PHPStan\Type\Constant\ConstantArrayType $constantArrayType) : bool + private function hasTwoAndMoreGenericClassStringTypes(ConstantArrayType $constantArrayType) : bool { - $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($constantArrayType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN); - if (!$typeNode instanceof \PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode) { + $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($constantArrayType, TypeKind::RETURN); + if (!$typeNode instanceof ArrayTypeNode) { return \false; } - if (!$typeNode->type instanceof \PHPStan\PhpDocParser\Ast\Type\UnionTypeNode) { + if (!$typeNode->type instanceof UnionTypeNode) { return \false; } $genericTypeNodeCount = 0; foreach ($typeNode->type->types as $unionedTypeNode) { - if ($unionedTypeNode instanceof \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode) { + if ($unionedTypeNode instanceof GenericTypeNode) { ++$genericTypeNodeCount; } } @@ -119,13 +119,13 @@ CODE_SAMPLE /** * Skip big arrays and mixed[] constants */ - private function shouldSkipConstantArrayType(\PHPStan\Type\Type $constType, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : bool + private function shouldSkipConstantArrayType(Type $constType, PhpDocInfo $phpDocInfo) : bool { - if (!$constType instanceof \PHPStan\Type\Constant\ConstantArrayType) { + if (!$constType instanceof ConstantArrayType) { return \false; } $currentVarType = $phpDocInfo->getVarType(); - if ($currentVarType instanceof \PHPStan\Type\ArrayType && $currentVarType->getItemType() instanceof \PHPStan\Type\MixedType) { + if ($currentVarType instanceof ArrayType && $currentVarType->getItemType() instanceof MixedType) { return \true; } if ($this->hasTwoAndMoreGenericClassStringTypes($constType)) { @@ -133,13 +133,13 @@ CODE_SAMPLE } return $this->isHugeNestedConstantArrayTyp($constType); } - private function isHugeNestedConstantArrayTyp(\PHPStan\Type\Constant\ConstantArrayType $constantArrayType) : bool + private function isHugeNestedConstantArrayTyp(ConstantArrayType $constantArrayType) : bool { if (\count($constantArrayType->getValueTypes()) <= 3) { return \false; } foreach ($constantArrayType->getValueTypes() as $constValueType) { - if ($constValueType instanceof \PHPStan\Type\Constant\ConstantArrayType) { + if ($constValueType instanceof ConstantArrayType) { return \true; } } diff --git a/rules/CodingStyle/Rector/ClassMethod/FuncGetArgsToVariadicParamRector.php b/rules/CodingStyle/Rector/ClassMethod/FuncGetArgsToVariadicParamRector.php index 0f2b270c025..18bc1b44a03 100644 --- a/rules/CodingStyle/Rector/ClassMethod/FuncGetArgsToVariadicParamRector.php +++ b/rules/CodingStyle/Rector/ClassMethod/FuncGetArgsToVariadicParamRector.php @@ -20,18 +20,18 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/d4tBd * * @see \Rector\Tests\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector\FuncGetArgsToVariadicParamRectorTest */ -final class FuncGetArgsToVariadicParamRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class FuncGetArgsToVariadicParamRector extends AbstractRector implements MinPhpVersionInterface { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Refactor func_get_args() in to a variadic param', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Refactor func_get_args() in to a variadic param', [new CodeSample(<<<'CODE_SAMPLE' function run() { $args = \func_get_args(); @@ -49,21 +49,21 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\Closure::class]; + return [ClassMethod::class, Function_::class, Closure::class]; } /** * @param ClassMethod|Function_|Closure $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->params !== []) { return null; } $assign = $this->matchFuncGetArgsVariableAssign($node); - if (!$assign instanceof \PhpParser\Node\Expr\Assign) { + if (!$assign instanceof Assign) { return null; } - if ($assign->var instanceof \PhpParser\Node\Expr\Variable) { + if ($assign->var instanceof Variable) { $variableName = $this->getName($assign->var); if ($variableName === null) { return null; @@ -71,12 +71,12 @@ CODE_SAMPLE return $this->removeOrChangeAssignToVariable($node, $assign, $variableName); } $variableName = 'args'; - $assign->expr = new \PhpParser\Node\Expr\Variable('args'); + $assign->expr = new Variable('args'); return $this->applyVariadicParams($node, $variableName); } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::VARIADIC_PARAM; + return PhpVersionFeature::VARIADIC_PARAM; } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $node @@ -86,7 +86,7 @@ CODE_SAMPLE { $param = $this->createVariadicParam($variableName); $variableParam = $param->var; - if ($variableParam instanceof \PhpParser\Node\Expr\Variable && $this->hasFunctionOrClosureInside($node, $variableParam)) { + if ($variableParam instanceof Variable && $this->hasFunctionOrClosureInside($node, $variableParam)) { return null; } $node->params[] = $param; @@ -96,23 +96,23 @@ CODE_SAMPLE * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $node * @return \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure|null */ - private function removeOrChangeAssignToVariable($node, \PhpParser\Node\Expr\Assign $assign, string $variableName) + private function removeOrChangeAssignToVariable($node, Assign $assign, string $variableName) { - $parent = $assign->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\Stmt\Expression) { + $parent = $assign->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof Expression) { $this->removeNode($assign); return $this->applyVariadicParams($node, $variableName); } $variable = $assign->var; /** @var ClassMethod|Function_|Closure $functionLike */ - $functionLike = $this->betterNodeFinder->findParentType($parent, \PhpParser\Node\FunctionLike::class); + $functionLike = $this->betterNodeFinder->findParentType($parent, FunctionLike::class); /** @var Stmt[] $stmts */ $stmts = $functionLike->getStmts(); - $this->traverseNodesWithCallable($stmts, function (\PhpParser\Node $node) use($assign, $variable) : ?Expr { + $this->traverseNodesWithCallable($stmts, function (Node $node) use($assign, $variable) : ?Expr { if (!$this->nodeComparator->areNodesEqual($node, $assign)) { return null; } - if ($node instanceof \PhpParser\Node\Arg) { + if ($node instanceof Arg) { return null; } return $variable; @@ -123,20 +123,20 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $functionLike */ - private function hasFunctionOrClosureInside($functionLike, \PhpParser\Node\Expr\Variable $variable) : bool + private function hasFunctionOrClosureInside($functionLike, Variable $variable) : bool { if ($functionLike->stmts === null) { return \false; } - return (bool) $this->betterNodeFinder->findFirst($functionLike->stmts, function (\PhpParser\Node $node) use($variable) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Closure && !$node instanceof \PhpParser\Node\Stmt\Function_) { + return (bool) $this->betterNodeFinder->findFirst($functionLike->stmts, function (Node $node) use($variable) : bool { + if (!$node instanceof Closure && !$node instanceof Function_) { return \false; } if ($node->params !== []) { return \false; } $assign = $this->matchFuncGetArgsVariableAssign($node); - if (!$assign instanceof \PhpParser\Node\Expr\Assign) { + if (!$assign instanceof Assign) { return \false; } return $this->nodeComparator->areNodesEqual($assign->var, $variable); @@ -145,12 +145,12 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $functionLike */ - private function matchFuncGetArgsVariableAssign($functionLike) : ?\PhpParser\Node\Expr\Assign + private function matchFuncGetArgsVariableAssign($functionLike) : ?Assign { /** @var Assign[] $assigns */ - $assigns = $this->betterNodeFinder->findInstanceOf((array) $functionLike->stmts, \PhpParser\Node\Expr\Assign::class); + $assigns = $this->betterNodeFinder->findInstanceOf((array) $functionLike->stmts, Assign::class); foreach ($assigns as $assign) { - if (!$assign->expr instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$assign->expr instanceof FuncCall) { continue; } if (!$this->isName($assign->expr, 'func_get_args')) { @@ -160,9 +160,9 @@ CODE_SAMPLE } return null; } - private function createVariadicParam(string $variableName) : \PhpParser\Node\Param + private function createVariadicParam(string $variableName) : Param { - $variable = new \PhpParser\Node\Expr\Variable($variableName); - return new \PhpParser\Node\Param($variable, null, null, \false, \true); + $variable = new Variable($variableName); + return new Param($variable, null, null, \false, \true); } } diff --git a/rules/CodingStyle/Rector/ClassMethod/MakeInheritedMethodVisibilitySameAsParentRector.php b/rules/CodingStyle/Rector/ClassMethod/MakeInheritedMethodVisibilitySameAsParentRector.php index 5d78557f5db..550d00d9310 100644 --- a/rules/CodingStyle/Rector/ClassMethod/MakeInheritedMethodVisibilitySameAsParentRector.php +++ b/rules/CodingStyle/Rector/ClassMethod/MakeInheritedMethodVisibilitySameAsParentRector.php @@ -11,14 +11,14 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; use Rector\Privatization\NodeManipulator\VisibilityManipulator; use ReflectionMethod; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/RFYmn * * @see \Rector\Tests\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector\MakeInheritedMethodVisibilitySameAsParentRectorTest */ -final class MakeInheritedMethodVisibilitySameAsParentRector extends \Rector\Core\Rector\AbstractRector +final class MakeInheritedMethodVisibilitySameAsParentRector extends AbstractRector { /** * @readonly @@ -30,14 +30,14 @@ final class MakeInheritedMethodVisibilitySameAsParentRector extends \Rector\Core * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(VisibilityManipulator $visibilityManipulator, ReflectionResolver $reflectionResolver) { $this->visibilityManipulator = $visibilityManipulator; $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Make method visibility same as parent one', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Make method visibility same as parent one', [new CodeSample(<<<'CODE_SAMPLE' class ChildClass extends ParentClass { public function run() @@ -74,15 +74,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $classReflection = $this->reflectionResolver->resolveClassReflection($node); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return null; } $parentClassReflections = $classReflection->getParents(); @@ -116,7 +116,7 @@ CODE_SAMPLE } return null; } - private function isClassMethodCompatibleWithParentReflectionMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod, \ReflectionMethod $reflectionMethod) : bool + private function isClassMethodCompatibleWithParentReflectionMethod(ClassMethod $classMethod, ReflectionMethod $reflectionMethod) : bool { if ($reflectionMethod->isPublic() && $classMethod->isPublic()) { return \true; @@ -129,7 +129,7 @@ CODE_SAMPLE } return $classMethod->isPrivate(); } - private function changeClassMethodVisibilityBasedOnReflectionMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod, \ReflectionMethod $reflectionMethod) : void + private function changeClassMethodVisibilityBasedOnReflectionMethod(ClassMethod $classMethod, ReflectionMethod $reflectionMethod) : void { if ($reflectionMethod->isPublic()) { $this->visibilityManipulator->makePublic($classMethod); diff --git a/rules/CodingStyle/Rector/ClassMethod/NewlineBeforeNewAssignSetRector.php b/rules/CodingStyle/Rector/ClassMethod/NewlineBeforeNewAssignSetRector.php index 36dc5a3be7f..4a33dbc780f 100644 --- a/rules/CodingStyle/Rector/ClassMethod/NewlineBeforeNewAssignSetRector.php +++ b/rules/CodingStyle/Rector/ClassMethod/NewlineBeforeNewAssignSetRector.php @@ -15,12 +15,12 @@ use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\Function_; use PhpParser\Node\Stmt\Nop; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector\NewlineBeforeNewAssignSetRectorTest */ -final class NewlineBeforeNewAssignSetRector extends \Rector\Core\Rector\AbstractRector +final class NewlineBeforeNewAssignSetRector extends AbstractRector { /** * @var string|null @@ -30,9 +30,9 @@ final class NewlineBeforeNewAssignSetRector extends \Rector\Core\Rector\Abstract * @var string|null */ private $previousPreviousStmtVariableName; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add extra space before new assign set', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add extra space before new assign set', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run() @@ -64,12 +64,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\Closure::class]; + return [ClassMethod::class, Function_::class, Closure::class]; } /** * @param ClassMethod|Function_|Closure $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { // skip methods with no bodies (e.g interface methods) if ($node->stmts === null) { @@ -83,7 +83,7 @@ CODE_SAMPLE if ($this->shouldAddEmptyLine($currentStmtVariableName, $node, $key)) { $hasChanged = \true; // insert newline before stmt - $newStmts[] = new \PhpParser\Node\Stmt\Nop(); + $newStmts[] = new Nop(); } $newStmts[] = $stmt; $this->previousPreviousStmtVariableName = $this->previousStmtVariableName; @@ -97,17 +97,17 @@ CODE_SAMPLE $this->previousStmtVariableName = null; $this->previousPreviousStmtVariableName = null; } - private function resolveCurrentStmtVariableName(\PhpParser\Node\Stmt $stmt) : ?string + private function resolveCurrentStmtVariableName(Stmt $stmt) : ?string { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { return null; } $stmtExpr = $stmt->expr; - if ($stmtExpr instanceof \PhpParser\Node\Expr\Assign || $stmtExpr instanceof \PhpParser\Node\Expr\MethodCall) { + if ($stmtExpr instanceof Assign || $stmtExpr instanceof MethodCall) { if ($this->shouldSkipLeftVariable($stmtExpr)) { return null; } - if (!$stmtExpr->var instanceof \PhpParser\Node\Expr\MethodCall && !$stmtExpr->var instanceof \PhpParser\Node\Expr\StaticCall) { + if (!$stmtExpr->var instanceof MethodCall && !$stmtExpr->var instanceof StaticCall) { return $this->getName($stmtExpr->var); } } @@ -129,7 +129,7 @@ CODE_SAMPLE */ private function shouldSkipLeftVariable($node) : bool { - if (!$node->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$node->var instanceof Variable) { return \false; } // local method call diff --git a/rules/CodingStyle/Rector/ClassMethod/OrderAttributesRector.php b/rules/CodingStyle/Rector/ClassMethod/OrderAttributesRector.php index 7c438c4f2bd..cccfd493672 100644 --- a/rules/CodingStyle/Rector/ClassMethod/OrderAttributesRector.php +++ b/rules/CodingStyle/Rector/ClassMethod/OrderAttributesRector.php @@ -14,13 +14,13 @@ use PhpParser\Node\Stmt\Function_; use PhpParser\Node\Stmt\Property; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\CodingStyle\Rector\ClassMethod\OrderAttributesRector\SpecificOrder\OrderAttributesRectorTest */ -final class OrderAttributesRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class OrderAttributesRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var string @@ -30,9 +30,9 @@ final class OrderAttributesRector extends \Rector\Core\Rector\AbstractRector imp * @var array|array */ private $configuration = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Order attributes by desired names', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Order attributes by desired names', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' #[Second] #[First] class Someclass @@ -46,7 +46,7 @@ class Someclass { } CODE_SAMPLE -, ['First', 'Second']), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' +, ['First', 'Second']), new ConfiguredCodeSample(<<<'CODE_SAMPLE' #[BAttribute] #[AAttribute] class Someclass @@ -67,12 +67,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class, \PhpParser\Node\Stmt\Property::class, \PhpParser\Node\Param::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\Closure::class, \PhpParser\Node\Expr\ArrowFunction::class]; + return [Class_::class, Property::class, Param::class, ClassMethod::class, Function_::class, Closure::class, ArrowFunction::class]; } /** * @param ClassMethod|Property|Function_|Closure|Param|Class_|ArrowFunction $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->attrGroups === []) { return null; @@ -94,8 +94,8 @@ CODE_SAMPLE */ public function configure(array $configuration = [self::ALPHABETICALLY]) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configuration); - \RectorPrefix20220607\Webmozart\Assert\Assert::minCount($configuration, 1); + Assert::allString($configuration); + Assert::minCount($configuration, 1); $this->configuration = $this->isAlphabetically($configuration) ? $configuration : \array_flip($configuration); } /** @@ -104,7 +104,7 @@ CODE_SAMPLE */ private function sortAlphabetically(array $originalAttrGroups) : array { - \usort($originalAttrGroups, function (\PhpParser\Node\AttributeGroup $firstAttributeGroup, \PhpParser\Node\AttributeGroup $secondAttributeGroup) : int { + \usort($originalAttrGroups, function (AttributeGroup $firstAttributeGroup, AttributeGroup $secondAttributeGroup) : int { $currentNamespace = $this->getName($firstAttributeGroup->attrs[0]->name); $nextNamespace = $this->getName($secondAttributeGroup->attrs[0]->name); return \strcmp($currentNamespace, $nextNamespace); @@ -117,14 +117,14 @@ CODE_SAMPLE */ private function sortBySpecificOrder(array $originalAttrGroups) : array { - \usort($originalAttrGroups, function (\PhpParser\Node\AttributeGroup $firstAttributeGroup, \PhpParser\Node\AttributeGroup $secondAttributeGroup) : int { + \usort($originalAttrGroups, function (AttributeGroup $firstAttributeGroup, AttributeGroup $secondAttributeGroup) : int { $firstAttributePosition = $this->resolveAttributeGroupPosition($firstAttributeGroup); $secondAttributePosition = $this->resolveAttributeGroupPosition($secondAttributeGroup); return $firstAttributePosition <=> $secondAttributePosition; }); return $originalAttrGroups; } - private function resolveAttributeGroupPosition(\PhpParser\Node\AttributeGroup $attributeGroup) : int + private function resolveAttributeGroupPosition(AttributeGroup $attributeGroup) : int { $attrName = $this->getName($attributeGroup->attrs[0]->name); return (int) ($this->configuration[$attrName] ?? \count($this->configuration)); diff --git a/rules/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector.php b/rules/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector.php index 097ccd2ab4d..42f8d371276 100644 --- a/rules/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector.php +++ b/rules/CodingStyle/Rector/ClassMethod/RemoveDoubleUnderscoreInMethodNameRector.php @@ -12,21 +12,21 @@ use PhpParser\Node\Stmt\ClassMethod; use Rector\CodingStyle\ValueObject\ObjectMagicMethods; use Rector\Core\Rector\AbstractRector; use Rector\Core\Util\StringUtils; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\ClassMethod\RemoveDoubleUnderscoreInMethodNameRector\RemoveDoubleUnderscoreInMethodNameRectorTest */ -final class RemoveDoubleUnderscoreInMethodNameRector extends \Rector\Core\Rector\AbstractRector +final class RemoveDoubleUnderscoreInMethodNameRector extends AbstractRector { /** * @var string * @see https://regex101.com/r/oRrhDJ/3 */ private const DOUBLE_UNDERSCORE_START_REGEX = '#^__(.+)#'; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Non-magic PHP object methods cannot start with "__"', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Non-magic PHP object methods cannot start with "__"', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function __getName($anotherObject) @@ -51,28 +51,28 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [ClassMethod::class, MethodCall::class, StaticCall::class]; } /** * @param ClassMethod|MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $methodName = $this->getName($node->name); if ($methodName === null) { return null; } - if (\in_array($methodName, \Rector\CodingStyle\ValueObject\ObjectMagicMethods::METHOD_NAMES, \true)) { + if (\in_array($methodName, ObjectMagicMethods::METHOD_NAMES, \true)) { return null; } - if (!\Rector\Core\Util\StringUtils::isMatch($methodName, self::DOUBLE_UNDERSCORE_START_REGEX)) { + if (!StringUtils::isMatch($methodName, self::DOUBLE_UNDERSCORE_START_REGEX)) { return null; } - $newName = \RectorPrefix20220607\Nette\Utils\Strings::substring($methodName, 2); + $newName = Strings::substring($methodName, 2); if (\is_numeric($newName[0])) { return null; } - $node->name = new \PhpParser\Node\Identifier($newName); + $node->name = new Identifier($newName); return $node; } } diff --git a/rules/CodingStyle/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector.php b/rules/CodingStyle/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector.php index 25457923028..075cb5d4915 100644 --- a/rules/CodingStyle/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector.php +++ b/rules/CodingStyle/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector.php @@ -16,8 +16,8 @@ use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\PhpParser\NodeTransformer; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @changelog https://medium.com/tech-tajawal/use-memory-gently-with-yield-in-php-7e62e2480b8d @@ -25,7 +25,7 @@ use RectorPrefix20220607\Webmozart\Assert\Assert; * * @see \Rector\Tests\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector\ReturnArrayClassMethodToYieldRectorTest */ -final class ReturnArrayClassMethodToYieldRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class ReturnArrayClassMethodToYieldRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var ReturnArrayClassMethodToyield[] @@ -41,14 +41,14 @@ final class ReturnArrayClassMethodToYieldRector extends \Rector\Core\Rector\Abst * @var \Rector\BetterPhpDocParser\Comment\CommentsMerger */ private $commentsMerger; - public function __construct(\Rector\Core\PhpParser\NodeTransformer $nodeTransformer, \Rector\BetterPhpDocParser\Comment\CommentsMerger $commentsMerger) + public function __construct(NodeTransformer $nodeTransformer, CommentsMerger $commentsMerger) { $this->nodeTransformer = $nodeTransformer; $this->commentsMerger = $commentsMerger; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns array return to yield return in specific type and method', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns array return to yield return in specific type and method', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' use PHPUnit\Framework\TestCase; final class SomeTest implements TestCase @@ -70,19 +70,19 @@ final class SomeTest implements TestCase } } CODE_SAMPLE -, [new \Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield('PHPUnit\\Framework\\TestCase', '*provide*')])]); +, [new ReturnArrayClassMethodToYield('PHPUnit\\Framework\\TestCase', '*provide*')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $hasChanged = \false; foreach ($this->methodsToYields as $methodToYield) { @@ -93,7 +93,7 @@ CODE_SAMPLE continue; } $arrayNode = $this->collectReturnArrayNodesFromClassMethod($node); - if (!$arrayNode instanceof \PhpParser\Node\Expr\Array_) { + if (!$arrayNode instanceof Array_) { continue; } $this->transformArrayToYieldsOnMethodNode($node, $arrayNode); @@ -110,18 +110,18 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield::class); + Assert::allIsAOf($configuration, ReturnArrayClassMethodToYield::class); $this->methodsToYields = $configuration; } - private function collectReturnArrayNodesFromClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Expr\Array_ + private function collectReturnArrayNodesFromClassMethod(ClassMethod $classMethod) : ?Array_ { if ($classMethod->stmts === null) { return null; } foreach ($classMethod->stmts as $statement) { - if ($statement instanceof \PhpParser\Node\Stmt\Return_) { + if ($statement instanceof Return_) { $returnedExpr = $statement->expr; - if (!$returnedExpr instanceof \PhpParser\Node\Expr\Array_) { + if (!$returnedExpr instanceof Array_) { continue; } return $returnedExpr; @@ -129,28 +129,28 @@ CODE_SAMPLE } return null; } - private function transformArrayToYieldsOnMethodNode(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Expr\Array_ $array) : void + private function transformArrayToYieldsOnMethodNode(ClassMethod $classMethod, Array_ $array) : void { $yieldNodes = $this->nodeTransformer->transformArrayToYields($array); // remove whole return node - $parentNode = $array->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $parentNode = $array->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof Node) { + throw new ShouldNotHappenException(); } $this->removeReturnTag($classMethod); // change return typehint - $classMethod->returnType = new \PhpParser\Node\Name\FullyQualified('Iterator'); + $classMethod->returnType = new FullyQualified('Iterator'); foreach ((array) $classMethod->stmts as $key => $classMethodStmt) { - if (!$classMethodStmt instanceof \PhpParser\Node\Stmt\Return_) { + if (!$classMethodStmt instanceof Return_) { continue; } unset($classMethod->stmts[$key]); } $classMethod->stmts = \array_merge((array) $classMethod->stmts, $yieldNodes); } - private function removeReturnTag(\PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function removeReturnTag(ClassMethod $classMethod) : void { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); - $phpDocInfo->removeByType(\PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode::class); + $phpDocInfo->removeByType(ReturnTagValueNode::class); } } diff --git a/rules/CodingStyle/Rector/ClassMethod/UnSpreadOperatorRector.php b/rules/CodingStyle/Rector/ClassMethod/UnSpreadOperatorRector.php index ab26f5288b8..b4468d2ad29 100644 --- a/rules/CodingStyle/Rector/ClassMethod/UnSpreadOperatorRector.php +++ b/rules/CodingStyle/Rector/ClassMethod/UnSpreadOperatorRector.php @@ -16,12 +16,12 @@ use Rector\CodingStyle\Reflection\VendorLocationDetector; use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; use Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector\UnSpreadOperatorRectorTest */ -final class UnSpreadOperatorRector extends \Rector\Core\Rector\AbstractRector +final class UnSpreadOperatorRector extends AbstractRector { /** * @readonly @@ -43,16 +43,16 @@ final class UnSpreadOperatorRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer */ private $classChildAnalyzer; - public function __construct(\Rector\CodingStyle\NodeAnalyzer\SpreadVariablesCollector $spreadVariablesCollector, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\CodingStyle\Reflection\VendorLocationDetector $vendorLocationDetector, \Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer $classChildAnalyzer) + public function __construct(SpreadVariablesCollector $spreadVariablesCollector, ReflectionResolver $reflectionResolver, VendorLocationDetector $vendorLocationDetector, ClassChildAnalyzer $classChildAnalyzer) { $this->spreadVariablesCollector = $spreadVariablesCollector; $this->reflectionResolver = $reflectionResolver; $this->vendorLocationDetector = $vendorLocationDetector; $this->classChildAnalyzer = $classChildAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove spread operator', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove spread operator', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(...$array) @@ -85,22 +85,22 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Expr\MethodCall::class]; + return [ClassMethod::class, MethodCall::class]; } /** * @param ClassMethod|MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Stmt\ClassMethod) { + if ($node instanceof ClassMethod) { return $this->refactorClassMethod($node); } return $this->refactorMethodCall($node); } - private function refactorClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Stmt\ClassMethod + private function refactorClassMethod(ClassMethod $classMethod) : ?ClassMethod { $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return null; } if ($this->isInPHPUnitTestCase($classReflection, $classMethod)) { @@ -116,15 +116,15 @@ CODE_SAMPLE } foreach ($spreadParams as $spreadParam) { $spreadParam->variadic = \false; - $spreadParam->type = new \PhpParser\Node\Identifier('array'); + $spreadParam->type = new Identifier('array'); $spreadParam->default = $this->nodeFactory->createArray([]); } return $classMethod; } - private function refactorMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node\Expr\MethodCall + private function refactorMethodCall(MethodCall $methodCall) : ?MethodCall { $methodReflection = $this->reflectionResolver->resolveMethodReflectionFromMethodCall($methodCall); - if (!$methodReflection instanceof \PHPStan\Reflection\MethodReflection) { + if (!$methodReflection instanceof MethodReflection) { return null; } // skip those in vendor @@ -146,13 +146,13 @@ CODE_SAMPLE $array = $this->nodeFactory->createArray($variadicArgs); $spreadArg = $methodCall->args[$firstSpreadParamPosition] ?? null; // already set value - if ($spreadArg instanceof \PhpParser\Node\Arg && $spreadArg->value instanceof \PhpParser\Node\Expr\Array_) { + if ($spreadArg instanceof Arg && $spreadArg->value instanceof Array_) { return null; } if (\count($variadicArgs) === 1) { return null; } - $methodCall->args[$firstSpreadParamPosition] = new \PhpParser\Node\Arg($array); + $methodCall->args[$firstSpreadParamPosition] = new Arg($array); $this->removeLaterArguments($methodCall, $firstSpreadParamPosition); return $methodCall; } @@ -161,21 +161,21 @@ CODE_SAMPLE /** * @return Arg[] */ - private function resolveVariadicArgsByVariadicParams(\PhpParser\Node\Expr\MethodCall $methodCall, int $firstSpreadParamPosition) : array + private function resolveVariadicArgsByVariadicParams(MethodCall $methodCall, int $firstSpreadParamPosition) : array { $variadicArgs = []; foreach ($methodCall->args as $position => $arg) { if ($position < $firstSpreadParamPosition) { continue; } - if (!$arg instanceof \PhpParser\Node\Arg) { + if (!$arg instanceof Arg) { continue; } $variadicArgs[] = $arg; } return $variadicArgs; } - private function removeLaterArguments(\PhpParser\Node\Expr\MethodCall $methodCall, int $argumentPosition) : void + private function removeLaterArguments(MethodCall $methodCall, int $argumentPosition) : void { $argCount = \count($methodCall->args); for ($i = $argumentPosition + 1; $i < $argCount; ++$i) { @@ -185,7 +185,7 @@ CODE_SAMPLE /** * @param Arg[] $variadicArgs */ - private function changeArgToPacked(array $variadicArgs, \PhpParser\Node\Expr\MethodCall $methodCall) : void + private function changeArgToPacked(array $variadicArgs, MethodCall $methodCall) : void { foreach ($variadicArgs as $position => $variadicArg) { if ($variadicArg->unpack) { @@ -206,7 +206,7 @@ CODE_SAMPLE } return \false; } - private function isInPHPUnitTestCase(\PHPStan\Reflection\ClassReflection $classReflection, \PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function isInPHPUnitTestCase(ClassReflection $classReflection, ClassMethod $classMethod) : bool { if (!$classMethod->isPublic()) { return \false; diff --git a/rules/CodingStyle/Rector/Class_/AddArrayDefaultToArrayPropertyRector.php b/rules/CodingStyle/Rector/Class_/AddArrayDefaultToArrayPropertyRector.php index 3ce21f5e186..4f18301a402 100644 --- a/rules/CodingStyle/Rector/Class_/AddArrayDefaultToArrayPropertyRector.php +++ b/rules/CodingStyle/Rector/Class_/AddArrayDefaultToArrayPropertyRector.php @@ -22,13 +22,13 @@ use Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Privatization\NodeManipulator\VisibilityManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\Class_\AddArrayDefaultToArrayPropertyRector\AddArrayDefaultToArrayPropertyRectorTest * @changelog https://3v4l.org/dPlUg */ -final class AddArrayDefaultToArrayPropertyRector extends \Rector\Core\Rector\AbstractRector +final class AddArrayDefaultToArrayPropertyRector extends AbstractRector { /** * @readonly @@ -50,16 +50,16 @@ final class AddArrayDefaultToArrayPropertyRector extends \Rector\Core\Rector\Abs * @var \Rector\Privatization\NodeManipulator\VisibilityManipulator */ private $visibilityManipulator; - public function __construct(\Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \Rector\CodingStyle\TypeAnalyzer\IterableTypeAnalyzer $iterableTypeAnalyzer, \Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer, \Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator) + public function __construct(PropertyFetchAnalyzer $propertyFetchAnalyzer, IterableTypeAnalyzer $iterableTypeAnalyzer, ArgsAnalyzer $argsAnalyzer, VisibilityManipulator $visibilityManipulator) { $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; $this->iterableTypeAnalyzer = $iterableTypeAnalyzer; $this->argsAnalyzer = $argsAnalyzer; $this->visibilityManipulator = $visibilityManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Adds array default value to property to prevent foreach over null error', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Adds array default value to property to prevent foreach over null error', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { /** @@ -94,12 +94,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $changedProperties = $this->collectPropertyNamesWithMissingDefaultArray($node); if ($changedProperties === []) { @@ -115,11 +115,11 @@ CODE_SAMPLE /** * @return string[] */ - private function collectPropertyNamesWithMissingDefaultArray(\PhpParser\Node\Stmt\Class_ $class) : array + private function collectPropertyNamesWithMissingDefaultArray(Class_ $class) : array { $propertyNames = []; - $this->traverseNodesWithCallable($class, function (\PhpParser\Node $node) use(&$propertyNames) { - if (!$node instanceof \PhpParser\Node\Stmt\PropertyProperty) { + $this->traverseNodesWithCallable($class, function (Node $node) use(&$propertyNames) { + if (!$node instanceof PropertyProperty) { return null; } if ($node->default !== null) { @@ -129,8 +129,8 @@ CODE_SAMPLE if (!$this->iterableTypeAnalyzer->detect($varType)) { return null; } - $property = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$property instanceof \PhpParser\Node\Stmt\Property) { + $property = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$property instanceof Property) { return null; } if ($this->visibilityManipulator->isReadonly($property)) { @@ -144,33 +144,33 @@ CODE_SAMPLE /** * @param string[] $propertyNames */ - private function completeDefaultArrayToPropertyNames(\PhpParser\Node\Stmt\Class_ $class, array $propertyNames) : void + private function completeDefaultArrayToPropertyNames(Class_ $class, array $propertyNames) : void { - $this->traverseNodesWithCallable($class, function (\PhpParser\Node $node) use($propertyNames) : ?PropertyProperty { - if (!$node instanceof \PhpParser\Node\Stmt\PropertyProperty) { + $this->traverseNodesWithCallable($class, function (Node $node) use($propertyNames) : ?PropertyProperty { + if (!$node instanceof PropertyProperty) { return null; } if (!$this->isNames($node, $propertyNames)) { return null; } - $node->default = new \PhpParser\Node\Expr\Array_(); + $node->default = new Array_(); return $node; }); } /** * @param string[] $propertyNames */ - private function clearNotNullBeforeCount(\PhpParser\Node\Stmt\Class_ $class, array $propertyNames) : void + private function clearNotNullBeforeCount(Class_ $class, array $propertyNames) : void { - $this->traverseNodesWithCallable($class, function (\PhpParser\Node $node) use($propertyNames) : ?Expr { - if (!$node instanceof \PhpParser\Node\Expr\BinaryOp\BooleanAnd) { + $this->traverseNodesWithCallable($class, function (Node $node) use($propertyNames) : ?Expr { + if (!$node instanceof BooleanAnd) { return null; } if (!$this->isLocalPropertyOfNamesNotIdenticalToNull($node->left, $propertyNames)) { return null; } - $isNextNodeCountingProperty = (bool) $this->betterNodeFinder->findFirst($node->right, function (\PhpParser\Node $node) use($propertyNames) : bool { - if (!$node instanceof \PhpParser\Node\Expr\FuncCall) { + $isNextNodeCountingProperty = (bool) $this->betterNodeFinder->findFirst($node->right, function (Node $node) use($propertyNames) : bool { + if (!$node instanceof FuncCall) { return \false; } if (!$this->isName($node, 'count')) { @@ -182,7 +182,7 @@ CODE_SAMPLE /** @var Arg $firstArg */ $firstArg = $node->args[0]; $countedArgument = $firstArg->value; - if (!$countedArgument instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$countedArgument instanceof PropertyFetch) { return \false; } return $this->isNames($countedArgument, $propertyNames); @@ -196,35 +196,35 @@ CODE_SAMPLE /** * @param string[] $propertyNames */ - private function replaceNullComparisonOfArrayPropertiesWithArrayComparison(\PhpParser\Node\Stmt\Class_ $class, array $propertyNames) : void + private function replaceNullComparisonOfArrayPropertiesWithArrayComparison(Class_ $class, array $propertyNames) : void { // replace comparison to "null" with "[]" - $this->traverseNodesWithCallable($class, function (\PhpParser\Node $node) use($propertyNames) : ?BinaryOp { - if (!$node instanceof \PhpParser\Node\Expr\BinaryOp) { + $this->traverseNodesWithCallable($class, function (Node $node) use($propertyNames) : ?BinaryOp { + if (!$node instanceof BinaryOp) { return null; } if ($this->propertyFetchAnalyzer->isLocalPropertyOfNames($node->left, $propertyNames) && $this->valueResolver->isNull($node->right)) { - $node->right = new \PhpParser\Node\Expr\Array_(); + $node->right = new Array_(); } if ($this->propertyFetchAnalyzer->isLocalPropertyOfNames($node->right, $propertyNames) && $this->valueResolver->isNull($node->left)) { - $node->left = new \PhpParser\Node\Expr\Array_(); + $node->left = new Array_(); } return $node; }); } - private function resolveVarType(\PhpParser\Node\Stmt\PropertyProperty $propertyProperty) : \PHPStan\Type\Type + private function resolveVarType(PropertyProperty $propertyProperty) : Type { /** @var Property $property */ - $property = $propertyProperty->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $property = $propertyProperty->getAttribute(AttributeKey::PARENT_NODE); $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); return $phpDocInfo->getVarType(); } /** * @param string[] $propertyNames */ - private function isLocalPropertyOfNamesNotIdenticalToNull(\PhpParser\Node\Expr $expr, array $propertyNames) : bool + private function isLocalPropertyOfNamesNotIdenticalToNull(Expr $expr, array $propertyNames) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\BinaryOp\NotIdentical) { + if (!$expr instanceof NotIdentical) { return \false; } if ($this->propertyFetchAnalyzer->isLocalPropertyOfNames($expr->left, $propertyNames) && $this->valueResolver->isNull($expr->right)) { diff --git a/rules/CodingStyle/Rector/Encapsed/EncapsedStringsToSprintfRector.php b/rules/CodingStyle/Rector/Encapsed/EncapsedStringsToSprintfRector.php index fd519094fd6..70de2e62a11 100644 --- a/rules/CodingStyle/Rector/Encapsed/EncapsedStringsToSprintfRector.php +++ b/rules/CodingStyle/Rector/Encapsed/EncapsedStringsToSprintfRector.php @@ -19,12 +19,12 @@ use PhpParser\Node\Scalar\String_; use PHPStan\Type\Type; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector\EncapsedStringsToSprintfRectorTest */ -final class EncapsedStringsToSprintfRector extends \Rector\Core\Rector\AbstractRector +final class EncapsedStringsToSprintfRector extends AbstractRector { /** * @var array>> @@ -38,9 +38,9 @@ final class EncapsedStringsToSprintfRector extends \Rector\Core\Rector\AbstractR * @var Expr[] */ private $argumentVariables = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Convert enscaped {$string} to more readable sprintf', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Convert enscaped {$string} to more readable sprintf', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run(string $format) @@ -65,17 +65,17 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Scalar\Encapsed::class]; + return [Encapsed::class]; } /** * @param Encapsed $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $this->sprintfFormat = ''; $this->argumentVariables = []; foreach ($node->parts as $part) { - if ($part instanceof \PhpParser\Node\Scalar\EncapsedStringPart) { + if ($part instanceof EncapsedStringPart) { $this->collectEncapsedStringPart($part); } else { $this->collectExpr($part); @@ -83,17 +83,17 @@ CODE_SAMPLE } return $this->createSprintfFuncCallOrConcat($this->sprintfFormat, $this->argumentVariables); } - private function collectEncapsedStringPart(\PhpParser\Node\Scalar\EncapsedStringPart $encapsedStringPart) : void + private function collectEncapsedStringPart(EncapsedStringPart $encapsedStringPart) : void { $stringValue = $encapsedStringPart->value; if ($stringValue === "\n") { - $this->argumentVariables[] = new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('PHP_EOL')); + $this->argumentVariables[] = new ConstFetch(new Name('PHP_EOL')); $this->sprintfFormat .= '%s'; return; } - $this->sprintfFormat .= \RectorPrefix20220607\Nette\Utils\Strings::replace($stringValue, '#%#', '%%'); + $this->sprintfFormat .= Strings::replace($stringValue, '#%#', '%%'); } - private function collectExpr(\PhpParser\Node\Expr $expr) : void + private function collectExpr(Expr $expr) : void { $type = $this->nodeTypeResolver->getType($expr); $found = \false; @@ -108,8 +108,8 @@ CODE_SAMPLE $this->sprintfFormat .= '%s'; } // remove: ${wrap} → $wrap - if ($expr instanceof \PhpParser\Node\Expr\Variable) { - $expr->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + if ($expr instanceof Variable) { + $expr->setAttribute(AttributeKey::ORIGINAL_NODE, null); } $this->argumentVariables[] = $expr; } @@ -117,21 +117,21 @@ CODE_SAMPLE * @param Expr[] $argumentVariables * @return Concat|FuncCall|null */ - private function createSprintfFuncCallOrConcat(string $string, array $argumentVariables) : ?\PhpParser\Node + private function createSprintfFuncCallOrConcat(string $string, array $argumentVariables) : ?Node { // special case for variable with PHP_EOL if ($string === '%s%s' && \count($argumentVariables) === 2 && $this->hasEndOfLine($argumentVariables)) { - return new \PhpParser\Node\Expr\BinaryOp\Concat($argumentVariables[0], $argumentVariables[1]); + return new Concat($argumentVariables[0], $argumentVariables[1]); } // checks for windows or linux line ending. \n is contained in both. if (\strpos($string, "\n") !== \false) { return null; } - $arguments = [new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\String_($string))]; + $arguments = [new Arg(new String_($string))]; foreach ($argumentVariables as $argumentVariable) { - $arguments[] = new \PhpParser\Node\Arg($argumentVariable); + $arguments[] = new Arg($argumentVariable); } - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('sprintf'), $arguments); + return new FuncCall(new Name('sprintf'), $arguments); } /** * @param Expr[] $argumentVariables @@ -139,7 +139,7 @@ CODE_SAMPLE private function hasEndOfLine(array $argumentVariables) : bool { foreach ($argumentVariables as $argumentVariable) { - if (!$argumentVariable instanceof \PhpParser\Node\Expr\ConstFetch) { + if (!$argumentVariable instanceof ConstFetch) { continue; } if ($this->isName($argumentVariable, 'PHP_EOL')) { diff --git a/rules/CodingStyle/Rector/Encapsed/WrapEncapsedVariableInCurlyBracesRector.php b/rules/CodingStyle/Rector/Encapsed/WrapEncapsedVariableInCurlyBracesRector.php index 23411b95aff..478e41fbe09 100644 --- a/rules/CodingStyle/Rector/Encapsed/WrapEncapsedVariableInCurlyBracesRector.php +++ b/rules/CodingStyle/Rector/Encapsed/WrapEncapsedVariableInCurlyBracesRector.php @@ -8,16 +8,16 @@ use PhpParser\Node\Expr\Variable; use PhpParser\Node\Scalar\Encapsed; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector\WrapEncapsedVariableInCurlyBracesRectorTest */ -final class WrapEncapsedVariableInCurlyBracesRector extends \Rector\Core\Rector\AbstractRector +final class WrapEncapsedVariableInCurlyBracesRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Wrap encapsed variables in curly braces', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Wrap encapsed variables in curly braces', [new CodeSample(<<<'CODE_SAMPLE' function run($world) { echo "Hello $world!"; @@ -36,22 +36,22 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Scalar\Encapsed::class]; + return [Encapsed::class]; } /** * @param Encapsed $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $startTokenPos = $node->getStartTokenPos(); $hasVariableBeenWrapped = \false; foreach ($node->parts as $index => $nodePart) { - if ($nodePart instanceof \PhpParser\Node\Expr\Variable) { - $previousNode = $nodePart->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_NODE); - $previousNodeEndTokenPosition = $previousNode instanceof \PhpParser\Node ? $previousNode->getEndTokenPos() : $startTokenPos; + if ($nodePart instanceof Variable) { + $previousNode = $nodePart->getAttribute(AttributeKey::PREVIOUS_NODE); + $previousNodeEndTokenPosition = $previousNode instanceof Node ? $previousNode->getEndTokenPos() : $startTokenPos; if ($previousNodeEndTokenPosition + 1 === $nodePart->getStartTokenPos()) { $hasVariableBeenWrapped = \true; - $node->parts[$index] = new \PhpParser\Node\Expr\Variable($nodePart->name); + $node->parts[$index] = new Variable($nodePart->name); } } } diff --git a/rules/CodingStyle/Rector/FuncCall/CallUserFuncArrayToVariadicRector.php b/rules/CodingStyle/Rector/FuncCall/CallUserFuncArrayToVariadicRector.php index 12c3c27d3f3..fe154090174 100644 --- a/rules/CodingStyle/Rector/FuncCall/CallUserFuncArrayToVariadicRector.php +++ b/rules/CodingStyle/Rector/FuncCall/CallUserFuncArrayToVariadicRector.php @@ -15,15 +15,15 @@ use Rector\Core\NodeAnalyzer\ArgsAnalyzer; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/function.call-user-func-array.php#117655 * @changelog https://3v4l.org/CBWt9 * * @see \Rector\Tests\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector\CallUserFuncArrayToVariadicRectorTest */ -final class CallUserFuncArrayToVariadicRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class CallUserFuncArrayToVariadicRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -35,14 +35,14 @@ final class CallUserFuncArrayToVariadicRector extends \Rector\Core\Rector\Abstra * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\CodingStyle\NodeFactory\ArrayCallableToMethodCallFactory $arrayCallableToMethodCallFactory, \Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(ArrayCallableToMethodCallFactory $arrayCallableToMethodCallFactory, ArgsAnalyzer $argsAnalyzer) { $this->arrayCallableToMethodCallFactory = $arrayCallableToMethodCallFactory; $this->argsAnalyzer = $argsAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace call_user_func_array() with variadic', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace call_user_func_array() with variadic', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -67,12 +67,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'call_user_func_array')) { return null; @@ -86,37 +86,37 @@ CODE_SAMPLE /** @var Arg $secondArg */ $secondArg = $node->getArgs()[1]; $secondArgValue = $secondArg->value; - if ($firstArgValue instanceof \PhpParser\Node\Scalar\String_) { + if ($firstArgValue instanceof String_) { $functionName = $this->valueResolver->getValue($firstArgValue); return $this->createFuncCall($secondArgValue, $functionName); } // method call - if ($firstArgValue instanceof \PhpParser\Node\Expr\Array_) { + if ($firstArgValue instanceof Array_) { return $this->createMethodCall($firstArgValue, $secondArgValue); } return null; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::ARRAY_SPREAD; + return PhpVersionFeature::ARRAY_SPREAD; } - private function createFuncCall(\PhpParser\Node\Expr $expr, string $functionName) : \PhpParser\Node\Expr\FuncCall + private function createFuncCall(Expr $expr, string $functionName) : FuncCall { $args = []; $args[] = $this->createUnpackedArg($expr); return $this->nodeFactory->createFuncCall($functionName, $args); } - private function createMethodCall(\PhpParser\Node\Expr\Array_ $array, \PhpParser\Node\Expr $secondExpr) : ?\PhpParser\Node\Expr\MethodCall + private function createMethodCall(Array_ $array, Expr $secondExpr) : ?MethodCall { $methodCall = $this->arrayCallableToMethodCallFactory->create($array); - if (!$methodCall instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$methodCall instanceof MethodCall) { return null; } $methodCall->args[] = $this->createUnpackedArg($secondExpr); return $methodCall; } - private function createUnpackedArg(\PhpParser\Node\Expr $expr) : \PhpParser\Node\Arg + private function createUnpackedArg(Expr $expr) : Arg { - return new \PhpParser\Node\Arg($expr, \false, \true); + return new Arg($expr, \false, \true); } } diff --git a/rules/CodingStyle/Rector/FuncCall/CallUserFuncToMethodCallRector.php b/rules/CodingStyle/Rector/FuncCall/CallUserFuncToMethodCallRector.php index c1683e3c084..9a80d7e44b8 100644 --- a/rules/CodingStyle/Rector/FuncCall/CallUserFuncToMethodCallRector.php +++ b/rules/CodingStyle/Rector/FuncCall/CallUserFuncToMethodCallRector.php @@ -10,27 +10,27 @@ use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\MethodCall; use Rector\CodingStyle\NodeFactory\ArrayCallableToMethodCallFactory; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://stackoverflow.com/a/1596250/1348344 * * @see \Rector\Tests\CodingStyle\Rector\FuncCall\CallUserFuncToMethodCallRector\CallUserFuncToMethodCallRectorTest */ -final class CallUserFuncToMethodCallRector extends \Rector\Core\Rector\AbstractRector +final class CallUserFuncToMethodCallRector extends AbstractRector { /** * @readonly * @var \Rector\CodingStyle\NodeFactory\ArrayCallableToMethodCallFactory */ private $arrayCallableToMethodCallFactory; - public function __construct(\Rector\CodingStyle\NodeFactory\ArrayCallableToMethodCallFactory $arrayCallableToMethodCallFactory) + public function __construct(ArrayCallableToMethodCallFactory $arrayCallableToMethodCallFactory) { $this->arrayCallableToMethodCallFactory = $arrayCallableToMethodCallFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Refactor call_user_func() on known class method to a method call', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Refactor call_user_func() on known class method to a method call', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run() @@ -55,12 +55,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'call_user_func')) { return null; @@ -68,15 +68,15 @@ CODE_SAMPLE if (!isset($node->args[0])) { return null; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } $firstArgValue = $node->args[0]->value; - if (!$firstArgValue instanceof \PhpParser\Node\Expr\Array_) { + if (!$firstArgValue instanceof Array_) { return null; } $methodCall = $this->arrayCallableToMethodCallFactory->create($firstArgValue); - if (!$methodCall instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$methodCall instanceof MethodCall) { return null; } $originalArgs = $node->args; diff --git a/rules/CodingStyle/Rector/FuncCall/ConsistentImplodeRector.php b/rules/CodingStyle/Rector/FuncCall/ConsistentImplodeRector.php index 75b325023fe..8115054d5ea 100644 --- a/rules/CodingStyle/Rector/FuncCall/ConsistentImplodeRector.php +++ b/rules/CodingStyle/Rector/FuncCall/ConsistentImplodeRector.php @@ -10,14 +10,14 @@ use PhpParser\Node\Scalar\String_; use Rector\Core\NodeAnalyzer\ArgsAnalyzer; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\TypeAnalyzer\StringTypeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog http://php.net/manual/en/function.implode.php#refsect1-function.implode-description * @changelog https://3v4l.org/iYTgh * @see \Rector\Tests\CodingStyle\Rector\FuncCall\ConsistentImplodeRector\ConsistentImplodeRectorTest */ -final class ConsistentImplodeRector extends \Rector\Core\Rector\AbstractRector +final class ConsistentImplodeRector extends AbstractRector { /** * @readonly @@ -29,14 +29,14 @@ final class ConsistentImplodeRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\NodeTypeResolver\TypeAnalyzer\StringTypeAnalyzer $stringTypeAnalyzer, \Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(StringTypeAnalyzer $stringTypeAnalyzer, ArgsAnalyzer $argsAnalyzer) { $this->stringTypeAnalyzer = $stringTypeAnalyzer; $this->argsAnalyzer = $argsAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes various implode forms to consistent one', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes various implode forms to consistent one', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(array $items) @@ -67,12 +67,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'implode')) { return null; @@ -80,7 +80,7 @@ CODE_SAMPLE if (\count($node->args) === 1) { // complete default value '' $node->args[1] = $node->args[0]; - $node->args[0] = new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\String_('')); + $node->args[0] = new Arg(new String_('')); return $node; } if (!$this->argsAnalyzer->isArgInstanceInArgsPosition($node->args, 0)) { @@ -89,7 +89,7 @@ CODE_SAMPLE /** @var Arg $arg0 */ $arg0 = $node->args[0]; $firstArgumentValue = $arg0->value; - if ($firstArgumentValue instanceof \PhpParser\Node\Scalar\String_) { + if ($firstArgumentValue instanceof String_) { return null; } if (\count($node->args) !== 2) { diff --git a/rules/CodingStyle/Rector/FuncCall/ConsistentPregDelimiterRector.php b/rules/CodingStyle/Rector/FuncCall/ConsistentPregDelimiterRector.php index f5303b64ca5..af245ffd116 100644 --- a/rules/CodingStyle/Rector/FuncCall/ConsistentPregDelimiterRector.php +++ b/rules/CodingStyle/Rector/FuncCall/ConsistentPregDelimiterRector.php @@ -15,12 +15,12 @@ use Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Core\Util\StringUtils; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector\ConsistentPregDelimiterRectorTest */ -final class ConsistentPregDelimiterRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface +final class ConsistentPregDelimiterRector extends AbstractRector implements AllowEmptyConfigurableRectorInterface { /** * @api @@ -70,13 +70,13 @@ final class ConsistentPregDelimiterRector extends \Rector\Core\Rector\AbstractRe * @var \Rector\Core\Contract\PhpParser\NodePrinterInterface */ private $nodePrinter; - public function __construct(\Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter) + public function __construct(NodePrinterInterface $nodePrinter) { $this->nodePrinter = $nodePrinter; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace PREG delimiter with configured one', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace PREG delimiter with configured one', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -103,25 +103,25 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [FuncCall::class, StaticCall::class]; } /** * @param FuncCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\FuncCall) { + if ($node instanceof FuncCall) { return $this->refactorFuncCall($node); } foreach (self::STATIC_METHODS_WITH_REGEX_PATTERN as $type => $methodsToPositions) { - if (!$this->isObjectType($node->class, new \PHPStan\Type\ObjectType($type))) { + if (!$this->isObjectType($node->class, new ObjectType($type))) { continue; } foreach ($methodsToPositions as $method => $position) { if (!$this->isName($node->name, $method)) { continue; } - if (!$node->args[$position] instanceof \PhpParser\Node\Arg) { + if (!$node->args[$position] instanceof Arg) { continue; } return $this->refactorArgument($node, $node->args[$position]); @@ -133,13 +133,13 @@ CODE_SAMPLE { $this->delimiter = $configuration[self::DELIMITER] ?? (string) \current($configuration); } - private function refactorFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Expr\FuncCall + private function refactorFuncCall(FuncCall $funcCall) : ?FuncCall { foreach (self::FUNCTIONS_WITH_REGEX_PATTERN as $function => $position) { if (!$this->isName($funcCall, $function)) { continue; } - if (!$funcCall->args[$position] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[$position] instanceof Arg) { continue; } return $this->refactorArgument($funcCall, $funcCall->args[$position]); @@ -148,8 +148,8 @@ CODE_SAMPLE } private function hasNewLineWithUnicodeModifier(string $string) : bool { - $matchInnerRegex = \RectorPrefix20220607\Nette\Utils\Strings::match($string, self::INNER_REGEX); - $matchInnerUnionRegex = \RectorPrefix20220607\Nette\Utils\Strings::match($string, self::INNER_UNICODE_REGEX); + $matchInnerRegex = Strings::match($string, self::INNER_REGEX); + $matchInnerUnionRegex = Strings::match($string, self::INNER_UNICODE_REGEX); if (!\is_array($matchInnerRegex)) { return \false; } @@ -159,23 +159,23 @@ CODE_SAMPLE if ($matchInnerRegex === $matchInnerUnionRegex) { return \false; } - return \Rector\Core\Util\StringUtils::isMatch($matchInnerUnionRegex['content'], self::NEW_LINE_REGEX); + return StringUtils::isMatch($matchInnerUnionRegex['content'], self::NEW_LINE_REGEX); } - private function hasEscapedQuote(\PhpParser\Node\Scalar\String_ $string) : bool + private function hasEscapedQuote(String_ $string) : bool { - $kind = $string->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND); - if ($kind === \PhpParser\Node\Scalar\String_::KIND_DOUBLE_QUOTED && \strpos($string->value, '"') !== \false) { + $kind = $string->getAttribute(AttributeKey::KIND); + if ($kind === String_::KIND_DOUBLE_QUOTED && \strpos($string->value, '"') !== \false) { return \true; } - return $kind === \PhpParser\Node\Scalar\String_::KIND_SINGLE_QUOTED && \strpos($string->value, "'") !== \false; + return $kind === String_::KIND_SINGLE_QUOTED && \strpos($string->value, "'") !== \false; } /** * @param \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\StaticCall $node * @return \PhpParser\Node|null */ - private function refactorArgument($node, \PhpParser\Node\Arg $arg) + private function refactorArgument($node, Arg $arg) { - if (!$arg->value instanceof \PhpParser\Node\Scalar\String_) { + if (!$arg->value instanceof String_) { return null; } /** @var String_ $string */ @@ -186,10 +186,10 @@ CODE_SAMPLE if ($this->hasNewLineWithUnicodeModifier($string->value)) { return null; } - $string->value = \RectorPrefix20220607\Nette\Utils\Strings::replace($string->value, self::INNER_REGEX, function (array $match) use(&$string) : string { + $string->value = Strings::replace($string->value, self::INNER_REGEX, function (array $match) use(&$string) : string { $printedString = $this->nodePrinter->print($string); - if (\Rector\Core\Util\StringUtils::isMatch($printedString, self::DOUBLE_QUOTED_REGEX)) { - $string->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::IS_REGULAR_PATTERN, \true); + if (StringUtils::isMatch($printedString, self::DOUBLE_QUOTED_REGEX)) { + $string->setAttribute(AttributeKey::IS_REGULAR_PATTERN, \true); } $innerPattern = $match['content']; $positionDelimiter = \strpos($innerPattern, $this->delimiter); diff --git a/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php b/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php index f2ad9266065..a4ba99c77c1 100644 --- a/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php +++ b/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php @@ -19,16 +19,16 @@ use PhpParser\Node\Stmt\If_; use PHPStan\Type\ArrayType; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector\CountArrayToEmptyArrayComparisonRectorTest */ -final class CountArrayToEmptyArrayComparisonRector extends \Rector\Core\Rector\AbstractRector +final class CountArrayToEmptyArrayComparisonRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change count array comparison to empty array comparison to improve performance', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change count array comparison to empty array comparison to improve performance', [new CodeSample(<<<'CODE_SAMPLE' count($array) === 0; count($array) > 0; ! count($array); @@ -45,14 +45,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Expr\BooleanNot::class]; + return [FuncCall::class, BooleanNot::class]; } /** * @param FuncCall|BooleanNot $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\BooleanNot) { + if ($node instanceof BooleanNot) { return $this->processMarkTruthyNegation($node); } if (!$this->isName($node, 'count')) { @@ -61,7 +61,7 @@ CODE_SAMPLE if (!isset($node->args[0])) { return null; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } /** @var Expr $expr */ @@ -70,8 +70,8 @@ CODE_SAMPLE if (!$this->isArray($expr)) { return null; } - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node) { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Node) { return null; } $processIdentical = $this->processIdenticalOrNotIdentical($parent, $node, $expr); @@ -84,9 +84,9 @@ CODE_SAMPLE } return $this->processMarkTruthy($parent, $node, $expr); } - private function processMarkTruthyNegation(\PhpParser\Node\Expr\BooleanNot $booleanNot) : ?\PhpParser\Node\Expr\BinaryOp\Identical + private function processMarkTruthyNegation(BooleanNot $booleanNot) : ?Identical { - if (!$booleanNot->expr instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$booleanNot->expr instanceof FuncCall) { return null; } if (!$this->isName($booleanNot->expr, 'count')) { @@ -95,7 +95,7 @@ CODE_SAMPLE if (!isset($booleanNot->expr->args[0])) { return null; } - if (!$booleanNot->expr->args[0] instanceof \PhpParser\Node\Arg) { + if (!$booleanNot->expr->args[0] instanceof Arg) { return null; } /** @var Expr $expr */ @@ -104,47 +104,47 @@ CODE_SAMPLE if (!$this->isArray($expr)) { return null; } - return new \PhpParser\Node\Expr\BinaryOp\Identical($expr, new \PhpParser\Node\Expr\Array_([])); + return new Identical($expr, new Array_([])); } - private function isArray(\PhpParser\Node\Expr $expr) : bool + private function isArray(Expr $expr) : bool { - return $this->getType($expr) instanceof \PHPStan\Type\ArrayType; + return $this->getType($expr) instanceof ArrayType; } - private function processIdenticalOrNotIdentical(\PhpParser\Node $node, \PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr $expr) : ?\PhpParser\Node\Expr + private function processIdenticalOrNotIdentical(Node $node, FuncCall $funcCall, Expr $expr) : ?Expr { - if (($node instanceof \PhpParser\Node\Expr\BinaryOp\Identical || $node instanceof \PhpParser\Node\Expr\BinaryOp\NotIdentical) && $node->right instanceof \PhpParser\Node\Scalar\LNumber && $node->right->value === 0) { + if (($node instanceof Identical || $node instanceof NotIdentical) && $node->right instanceof LNumber && $node->right->value === 0) { $this->removeNode($funcCall); - $node->right = new \PhpParser\Node\Expr\Array_([]); + $node->right = new Array_([]); return $expr; } - if (($node instanceof \PhpParser\Node\Expr\BinaryOp\Identical || $node instanceof \PhpParser\Node\Expr\BinaryOp\NotIdentical) && $node->left instanceof \PhpParser\Node\Scalar\LNumber && $node->left->value === 0) { + if (($node instanceof Identical || $node instanceof NotIdentical) && $node->left instanceof LNumber && $node->left->value === 0) { $this->removeNode($funcCall); - $node->left = new \PhpParser\Node\Expr\Array_([]); + $node->left = new Array_([]); return $expr; } return null; } - private function processGreaterOrSmaller(\PhpParser\Node $node, \PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr $expr) : ?\PhpParser\Node\Expr\BinaryOp\NotIdentical + private function processGreaterOrSmaller(Node $node, FuncCall $funcCall, Expr $expr) : ?NotIdentical { - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\Greater && $node->right instanceof \PhpParser\Node\Scalar\LNumber && $node->right->value === 0) { + if ($node instanceof Greater && $node->right instanceof LNumber && $node->right->value === 0) { $this->removeNode($funcCall); $this->removeNode($node->right); - return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, new \PhpParser\Node\Expr\Array_([])); + return new NotIdentical($expr, new Array_([])); } - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\Smaller && $node->left instanceof \PhpParser\Node\Scalar\LNumber && $node->left->value === 0) { + if ($node instanceof Smaller && $node->left instanceof LNumber && $node->left->value === 0) { $this->removeNode($funcCall); $this->removeNode($node->left); - return new \PhpParser\Node\Expr\BinaryOp\NotIdentical(new \PhpParser\Node\Expr\Array_([]), $expr); + return new NotIdentical(new Array_([]), $expr); } return null; } - private function processMarkTruthy(\PhpParser\Node $node, \PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr $expr) : ?\PhpParser\Node\Expr + private function processMarkTruthy(Node $node, FuncCall $funcCall, Expr $expr) : ?Expr { - if (!$node instanceof \PhpParser\Node\Stmt\If_ && !$node instanceof \PhpParser\Node\Stmt\ElseIf_) { + if (!$node instanceof If_ && !$node instanceof ElseIf_) { return null; } if ($node->cond === $funcCall) { - $node->cond = new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, new \PhpParser\Node\Expr\Array_([])); + $node->cond = new NotIdentical($expr, new Array_([])); return $node->cond; } return null; diff --git a/rules/CodingStyle/Rector/FuncCall/StrictArraySearchRector.php b/rules/CodingStyle/Rector/FuncCall/StrictArraySearchRector.php index ca2dbb3be07..87126fe3c1c 100644 --- a/rules/CodingStyle/Rector/FuncCall/StrictArraySearchRector.php +++ b/rules/CodingStyle/Rector/FuncCall/StrictArraySearchRector.php @@ -6,28 +6,28 @@ namespace Rector\CodingStyle\Rector\FuncCall; use PhpParser\Node; use PhpParser\Node\Expr\FuncCall; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\FuncCall\StrictArraySearchRector\StrictArraySearchRectorTest */ -final class StrictArraySearchRector extends \Rector\Core\Rector\AbstractRector +final class StrictArraySearchRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Makes array_search search for identical elements', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('array_search($value, $items);', 'array_search($value, $items, true);')]); + return new RuleDefinition('Makes array_search search for identical elements', [new CodeSample('array_search($value, $items);', 'array_search($value, $items, true);')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'array_search')) { return null; diff --git a/rules/CodingStyle/Rector/FuncCall/VersionCompareFuncCallToConstantRector.php b/rules/CodingStyle/Rector/FuncCall/VersionCompareFuncCallToConstantRector.php index fe1f786f785..4626e8635cf 100644 --- a/rules/CodingStyle/Rector/FuncCall/VersionCompareFuncCallToConstantRector.php +++ b/rules/CodingStyle/Rector/FuncCall/VersionCompareFuncCallToConstantRector.php @@ -21,17 +21,17 @@ use PhpParser\Node\Scalar\String_; use Rector\Core\NodeAnalyzer\ArgsAnalyzer; use Rector\Core\Rector\AbstractRector; use Rector\Core\Util\PhpVersionFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector\VersionCompareFuncCallToConstantRectorTest */ -final class VersionCompareFuncCallToConstantRector extends \Rector\Core\Rector\AbstractRector +final class VersionCompareFuncCallToConstantRector extends AbstractRector { /** * @var array> */ - private const OPERATOR_TO_COMPARISON = ['=' => \PhpParser\Node\Expr\BinaryOp\Identical::class, '==' => \PhpParser\Node\Expr\BinaryOp\Identical::class, 'eq' => \PhpParser\Node\Expr\BinaryOp\Identical::class, '!=' => \PhpParser\Node\Expr\BinaryOp\NotIdentical::class, '<>' => \PhpParser\Node\Expr\BinaryOp\NotIdentical::class, 'ne' => \PhpParser\Node\Expr\BinaryOp\NotIdentical::class, '>' => \PhpParser\Node\Expr\BinaryOp\Greater::class, 'gt' => \PhpParser\Node\Expr\BinaryOp\Greater::class, '<' => \PhpParser\Node\Expr\BinaryOp\Smaller::class, 'lt' => \PhpParser\Node\Expr\BinaryOp\Smaller::class, '>=' => \PhpParser\Node\Expr\BinaryOp\GreaterOrEqual::class, 'ge' => \PhpParser\Node\Expr\BinaryOp\GreaterOrEqual::class, '<=' => \PhpParser\Node\Expr\BinaryOp\SmallerOrEqual::class, 'le' => \PhpParser\Node\Expr\BinaryOp\SmallerOrEqual::class]; + private const OPERATOR_TO_COMPARISON = ['=' => Identical::class, '==' => Identical::class, 'eq' => Identical::class, '!=' => NotIdentical::class, '<>' => NotIdentical::class, 'ne' => NotIdentical::class, '>' => Greater::class, 'gt' => Greater::class, '<' => Smaller::class, 'lt' => Smaller::class, '>=' => GreaterOrEqual::class, 'ge' => GreaterOrEqual::class, '<=' => SmallerOrEqual::class, 'le' => SmallerOrEqual::class]; /** * @readonly * @var \Rector\Core\Util\PhpVersionFactory @@ -42,14 +42,14 @@ final class VersionCompareFuncCallToConstantRector extends \Rector\Core\Rector\A * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Core\Util\PhpVersionFactory $phpVersionFactory, \Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(PhpVersionFactory $phpVersionFactory, ArgsAnalyzer $argsAnalyzer) { $this->phpVersionFactory = $phpVersionFactory; $this->argsAnalyzer = $argsAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes use of call to version compare function to use of PHP version constant', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes use of call to version compare function to use of PHP version constant', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -74,12 +74,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'version_compare')) { return null; @@ -108,9 +108,9 @@ CODE_SAMPLE $comparisonClass = self::OPERATOR_TO_COMPARISON[$operator->value]; return new $comparisonClass($left, $right); } - private function isPhpVersionConstant(\PhpParser\Node\Expr $expr) : bool + private function isPhpVersionConstant(Expr $expr) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\ConstFetch) { + if (!$expr instanceof ConstFetch) { return \false; } return $expr->name->toString() === 'PHP_VERSION'; @@ -118,19 +118,19 @@ CODE_SAMPLE /** * @return \PhpParser\Node\Expr\ConstFetch|\PhpParser\Node\Scalar\LNumber|null */ - private function getNewNodeForArg(\PhpParser\Node\Expr $expr) + private function getNewNodeForArg(Expr $expr) { if ($this->isPhpVersionConstant($expr)) { - return new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('PHP_VERSION_ID')); + return new ConstFetch(new Name('PHP_VERSION_ID')); } return $this->getVersionNumberFormVersionString($expr); } - private function getVersionNumberFormVersionString(\PhpParser\Node\Expr $expr) : ?\PhpParser\Node\Scalar\LNumber + private function getVersionNumberFormVersionString(Expr $expr) : ?LNumber { - if (!$expr instanceof \PhpParser\Node\Scalar\String_) { + if (!$expr instanceof String_) { return null; } $value = $this->phpVersionFactory->createIntVersion($expr->value); - return new \PhpParser\Node\Scalar\LNumber($value); + return new LNumber($value); } } diff --git a/rules/CodingStyle/Rector/If_/NullableCompareToNullRector.php b/rules/CodingStyle/Rector/If_/NullableCompareToNullRector.php index 455f2f7c035..615374283ae 100644 --- a/rules/CodingStyle/Rector/If_/NullableCompareToNullRector.php +++ b/rules/CodingStyle/Rector/If_/NullableCompareToNullRector.php @@ -18,16 +18,16 @@ use PHPStan\Type\NullType; use PHPStan\Type\StringType; use PHPStan\Type\UnionType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\If_\NullableCompareToNullRector\NullableCompareToNullRectorTest */ -final class NullableCompareToNullRector extends \Rector\Core\Rector\AbstractRector +final class NullableCompareToNullRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes negate of empty comparison of nullable value to explicit === or !== compare', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes negate of empty comparison of nullable value to explicit === or !== compare', [new CodeSample(<<<'CODE_SAMPLE' /** @var stdClass|null $value */ if ($value) { } @@ -50,54 +50,54 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node->cond instanceof \PhpParser\Node\Expr\BooleanNot && $this->isNullableNonScalarType($node->cond->expr)) { - $node->cond = new \PhpParser\Node\Expr\BinaryOp\Identical($node->cond->expr, $this->nodeFactory->createNull()); + if ($node->cond instanceof BooleanNot && $this->isNullableNonScalarType($node->cond->expr)) { + $node->cond = new Identical($node->cond->expr, $this->nodeFactory->createNull()); return $node; } if ($this->isNullableNonScalarType($node->cond)) { - $node->cond = new \PhpParser\Node\Expr\BinaryOp\NotIdentical($node->cond, $this->nodeFactory->createNull()); + $node->cond = new NotIdentical($node->cond, $this->nodeFactory->createNull()); return $node; } return null; } - private function isNullableNonScalarType(\PhpParser\Node\Expr $expr) : bool + private function isNullableNonScalarType(Expr $expr) : bool { $staticType = $this->getType($expr); - if ($staticType instanceof \PHPStan\Type\MixedType) { + if ($staticType instanceof MixedType) { return \false; } - if (!$staticType instanceof \PHPStan\Type\UnionType) { + if (!$staticType instanceof UnionType) { return \false; } // is non-nullable? - if ($staticType->isSuperTypeOf(new \PHPStan\Type\NullType())->no()) { + if ($staticType->isSuperTypeOf(new NullType())->no()) { return \false; } // is array? foreach ($staticType->getTypes() as $subType) { - if ($subType instanceof \PHPStan\Type\ArrayType) { + if ($subType instanceof ArrayType) { return \false; } } // is string? - if ($staticType->isSuperTypeOf(new \PHPStan\Type\StringType())->yes()) { + if ($staticType->isSuperTypeOf(new StringType())->yes()) { return \false; } // is number? - if ($staticType->isSuperTypeOf(new \PHPStan\Type\IntegerType())->yes()) { + if ($staticType->isSuperTypeOf(new IntegerType())->yes()) { return \false; } // is bool? - if ($staticType->isSuperTypeOf(new \PHPStan\Type\BooleanType())->yes()) { + if ($staticType->isSuperTypeOf(new BooleanType())->yes()) { return \false; } - return !$staticType->isSuperTypeOf(new \PHPStan\Type\FloatType())->yes(); + return !$staticType->isSuperTypeOf(new FloatType())->yes(); } } diff --git a/rules/CodingStyle/Rector/MethodCall/PreferThisOrSelfMethodCallRector.php b/rules/CodingStyle/Rector/MethodCall/PreferThisOrSelfMethodCallRector.php index 46b08a03284..e84806af223 100644 --- a/rules/CodingStyle/Rector/MethodCall/PreferThisOrSelfMethodCallRector.php +++ b/rules/CodingStyle/Rector/MethodCall/PreferThisOrSelfMethodCallRector.php @@ -13,13 +13,13 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Enum\ObjectReference; use Rector\Core\PhpParser\AstResolver; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector\PreferThisOrSelfMethodCallRectorTest */ -final class PreferThisOrSelfMethodCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class PreferThisOrSelfMethodCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var string @@ -34,13 +34,13 @@ final class PreferThisOrSelfMethodCallRector extends \Rector\Core\Rector\Abstrac * @var \Rector\Core\PhpParser\AstResolver */ private $astResolver; - public function __construct(\Rector\Core\PhpParser\AstResolver $astResolver) + public function __construct(AstResolver $astResolver) { $this->astResolver = $astResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes $this->... and static:: to self:: or vise versa for given types', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes $this->... and static:: to self:: or vise versa for given types', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' use PHPUnit\Framework\TestCase; final class SomeClass extends TestCase @@ -62,25 +62,25 @@ final class SomeClass extends TestCase } } CODE_SAMPLE -, ['PHPUnit\\Framework\\TestCase' => \Rector\CodingStyle\Enum\PreferenceSelfThis::PREFER_SELF])]); +, ['PHPUnit\\Framework\\TestCase' => PreferenceSelfThis::PREFER_SELF])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->typeToPreference as $type => $preference) { - if (!$this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, new \PHPStan\Type\ObjectType($type))) { + if (!$this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, new ObjectType($type))) { continue; } - if ($preference === \Rector\CodingStyle\Enum\PreferenceSelfThis::PREFER_SELF) { + if ($preference === PreferenceSelfThis::PREFER_SELF) { return $this->processToSelf($node); } return $this->processToThis($node); @@ -92,41 +92,41 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString(\array_keys($configuration)); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configuration); - \RectorPrefix20220607\Webmozart\Assert\Assert::allOneOf($configuration, [\Rector\CodingStyle\Enum\PreferenceSelfThis::PREFER_THIS, \Rector\CodingStyle\Enum\PreferenceSelfThis::PREFER_SELF]); + Assert::allString(\array_keys($configuration)); + Assert::allString($configuration); + Assert::allOneOf($configuration, [PreferenceSelfThis::PREFER_THIS, PreferenceSelfThis::PREFER_SELF]); $this->typeToPreference = $configuration; } /** * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node */ - private function processToSelf($node) : ?\PhpParser\Node\Expr\StaticCall + private function processToSelf($node) : ?StaticCall { - if ($node instanceof \PhpParser\Node\Expr\StaticCall && !$this->isNames($node->class, [\Rector\Core\Enum\ObjectReference::SELF, \Rector\Core\Enum\ObjectReference::STATIC])) { + if ($node instanceof StaticCall && !$this->isNames($node->class, [ObjectReference::SELF, ObjectReference::STATIC])) { return null; } - if ($node instanceof \PhpParser\Node\Expr\MethodCall && !$this->isName($node->var, self::THIS)) { + if ($node instanceof MethodCall && !$this->isName($node->var, self::THIS)) { return null; } $classMethod = $this->astResolver->resolveClassMethodFromCall($node); - if ($classMethod instanceof \PhpParser\Node\Stmt\ClassMethod && !$classMethod->isStatic()) { + if ($classMethod instanceof ClassMethod && !$classMethod->isStatic()) { return null; } $name = $this->getName($node->name); if ($name === null) { return null; } - return $this->nodeFactory->createStaticCall(\Rector\Core\Enum\ObjectReference::SELF, $name, $node->args); + return $this->nodeFactory->createStaticCall(ObjectReference::SELF, $name, $node->args); } /** * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node */ - private function processToThis($node) : ?\PhpParser\Node\Expr\MethodCall + private function processToThis($node) : ?MethodCall { - if ($node instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node instanceof MethodCall) { return null; } - if (!$this->isNames($node->class, [\Rector\Core\Enum\ObjectReference::SELF, \Rector\Core\Enum\ObjectReference::STATIC])) { + if (!$this->isNames($node->class, [ObjectReference::SELF, ObjectReference::STATIC])) { return null; } $name = $this->getName($node->name); @@ -134,8 +134,8 @@ CODE_SAMPLE return null; } // avoid adding dynamic method call to static method - $classMethod = $this->betterNodeFinder->findParentByTypes($node, [\PhpParser\Node\Stmt\ClassMethod::class]); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $this->betterNodeFinder->findParentByTypes($node, [ClassMethod::class]); + if (!$classMethod instanceof ClassMethod) { return $this->nodeFactory->createMethodCall(self::THIS, $name, $node->args); } if (!$classMethod->isStatic()) { diff --git a/rules/CodingStyle/Rector/Plus/UseIncrementAssignRector.php b/rules/CodingStyle/Rector/Plus/UseIncrementAssignRector.php index 3dd3a46ed41..536f962961b 100644 --- a/rules/CodingStyle/Rector/Plus/UseIncrementAssignRector.php +++ b/rules/CodingStyle/Rector/Plus/UseIncrementAssignRector.php @@ -10,16 +10,16 @@ use PhpParser\Node\Expr\PreDec; use PhpParser\Node\Expr\PreInc; use PhpParser\Node\Scalar\LNumber; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\Plus\UseIncrementAssignRector\UseIncrementAssignRectorTest */ -final class UseIncrementAssignRector extends \Rector\Core\Rector\AbstractRector +final class UseIncrementAssignRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Use ++ increment instead of `$var += 1`', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Use ++ increment instead of `$var += 1`', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -44,22 +44,22 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\AssignOp\Plus::class, \PhpParser\Node\Expr\AssignOp\Minus::class]; + return [Plus::class, Minus::class]; } /** * @param Plus|Minus $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->expr instanceof \PhpParser\Node\Scalar\LNumber) { + if (!$node->expr instanceof LNumber) { return null; } if ($node->expr->value !== 1) { return null; } - if ($node instanceof \PhpParser\Node\Expr\AssignOp\Plus) { - return new \PhpParser\Node\Expr\PreInc($node->var); + if ($node instanceof Plus) { + return new PreInc($node->var); } - return new \PhpParser\Node\Expr\PreDec($node->var); + return new PreDec($node->var); } } diff --git a/rules/CodingStyle/Rector/PostInc/PostIncDecToPreIncDecRector.php b/rules/CodingStyle/Rector/PostInc/PostIncDecToPreIncDecRector.php index a850913da76..09bdc1efeba 100644 --- a/rules/CodingStyle/Rector/PostInc/PostIncDecToPreIncDecRector.php +++ b/rules/CodingStyle/Rector/PostInc/PostIncDecToPreIncDecRector.php @@ -14,16 +14,16 @@ use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\For_; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector\PostIncDecToPreIncDecRectorTest */ -final class PostIncDecToPreIncDecRector extends \Rector\Core\Rector\AbstractRector +final class PostIncDecToPreIncDecRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Use ++$value or --$value instead of `$value++` or `$value--`', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Use ++$value or --$value instead of `$value++` or `$value--`', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($value = 1) @@ -50,21 +50,21 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\PostInc::class, \PhpParser\Node\Expr\PostDec::class]; + return [PostInc::class, PostDec::class]; } /** * @param PostInc|PostDec $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); if ($this->isAnExpression($parentNode)) { return $this->processPrePost($node); } - if ($parentNode instanceof \PhpParser\Node\Expr\ArrayDimFetch && $this->nodeComparator->areNodesEqual($parentNode->dim, $node)) { + if ($parentNode instanceof ArrayDimFetch && $this->nodeComparator->areNodesEqual($parentNode->dim, $node)) { return $this->processPreArray($node, $parentNode); } - if (!$parentNode instanceof \PhpParser\Node\Stmt\For_) { + if (!$parentNode instanceof For_) { return null; } if (\count($parentNode->loop) !== 1) { @@ -75,12 +75,12 @@ CODE_SAMPLE } return $this->processPreFor($node, $parentNode); } - private function isAnExpression(?\PhpParser\Node $node = null) : bool + private function isAnExpression(?Node $node = null) : bool { - if (!$node instanceof \PhpParser\Node) { + if (!$node instanceof Node) { return \false; } - return $node instanceof \PhpParser\Node\Stmt\Expression; + return $node instanceof Expression; } /** * @param \PhpParser\Node\Expr\PostInc|\PhpParser\Node\Expr\PostDec $node @@ -88,17 +88,17 @@ CODE_SAMPLE */ private function processPrePost($node) { - if ($node instanceof \PhpParser\Node\Expr\PostInc) { - return new \PhpParser\Node\Expr\PreInc($node->var); + if ($node instanceof PostInc) { + return new PreInc($node->var); } - return new \PhpParser\Node\Expr\PreDec($node->var); + return new PreDec($node->var); } /** * @param \PhpParser\Node\Expr\PostInc|\PhpParser\Node\Expr\PostDec $node */ - private function processPreArray($node, \PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch) : ?\PhpParser\Node\Expr + private function processPreArray($node, ArrayDimFetch $arrayDimFetch) : ?Expr { - $parentOfArrayDimFetch = $arrayDimFetch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentOfArrayDimFetch = $arrayDimFetch->getAttribute(AttributeKey::PARENT_NODE); if (!$this->isAnExpression($parentOfArrayDimFetch)) { return null; } @@ -110,7 +110,7 @@ CODE_SAMPLE * @param \PhpParser\Node\Expr\PostInc|\PhpParser\Node\Expr\PostDec $node * @return \PhpParser\Node\Expr\PreDec|\PhpParser\Node\Expr\PreInc */ - private function processPreFor($node, \PhpParser\Node\Stmt\For_ $for) + private function processPreFor($node, For_ $for) { $for->loop = [$this->processPrePost($node)]; return $for->loop[0]; diff --git a/rules/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector.php b/rules/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector.php index a9e6f0fe133..71d69a8bd02 100644 --- a/rules/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector.php +++ b/rules/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector.php @@ -11,25 +11,25 @@ use PhpParser\Node\Stmt\Trait_; use PHPStan\Type\BooleanType; use Rector\Core\Rector\AbstractRector; use Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\Property\AddFalseDefaultToBoolPropertyRector\AddFalseDefaultToBoolPropertyRectorTest */ -final class AddFalseDefaultToBoolPropertyRector extends \Rector\Core\Rector\AbstractRector +final class AddFalseDefaultToBoolPropertyRector extends AbstractRector { /** * @readonly * @var \Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector */ private $constructorAssignDetector; - public function __construct(\Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector $constructorAssignDetector) + public function __construct(ConstructorAssignDetector $constructorAssignDetector) { $this->constructorAssignDetector = $constructorAssignDetector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add false default to bool properties, to prevent null compare errors', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add false default to bool properties, to prevent null compare errors', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { /** @@ -54,12 +54,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (\count($node->props) !== 1) { return null; @@ -71,8 +71,8 @@ CODE_SAMPLE if (!$this->isBoolDocType($node)) { return null; } - $classLike = $this->betterNodeFinder->findParentByTypes($node, [\PhpParser\Node\Stmt\Class_::class, \PhpParser\Node\Stmt\Trait_::class]); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentByTypes($node, [Class_::class, Trait_::class]); + if (!$classLike instanceof ClassLike) { return null; } $propertyName = $this->nodeNameResolver->getName($onlyProperty); @@ -82,9 +82,9 @@ CODE_SAMPLE $onlyProperty->default = $this->nodeFactory->createFalse(); return $node; } - private function isBoolDocType(\PhpParser\Node\Stmt\Property $property) : bool + private function isBoolDocType(Property $property) : bool { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); - return $phpDocInfo->getVarType() instanceof \PHPStan\Type\BooleanType; + return $phpDocInfo->getVarType() instanceof BooleanType; } } diff --git a/rules/CodingStyle/Rector/Property/InlineSimplePropertyAnnotationRector.php b/rules/CodingStyle/Rector/Property/InlineSimplePropertyAnnotationRector.php index db436fbaa83..c2c72588080 100644 --- a/rules/CodingStyle/Rector/Property/InlineSimplePropertyAnnotationRector.php +++ b/rules/CodingStyle/Rector/Property/InlineSimplePropertyAnnotationRector.php @@ -10,8 +10,8 @@ use PhpParser\Node\Stmt\Property; use Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\CodingStyle\Rector\Property\InlineSimplePropertyAnnotationRector\InlineSimplePropertyAnnotationRectorTest @@ -22,15 +22,15 @@ use RectorPrefix20220607\Webmozart\Assert\Assert; * as it will always conflict with ECS use of \PhpCsFixer\Fixer\Phpdoc\PhpdocLineSpanFixer * so rectify CI will always rolled back the change */ -final class InlineSimplePropertyAnnotationRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface +final class InlineSimplePropertyAnnotationRector extends AbstractRector implements AllowEmptyConfigurableRectorInterface { /** * @var string[] */ private $annotationsToConsiderForInlining = ['@var', '@phpstan-var', '@psalm-var']; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Inline simple @var annotations (or other annotations) when they are the only thing in the phpdoc', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Inline simple @var annotations (or other annotations) when they are the only thing in the phpdoc', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' final class SomeClass { /** @@ -61,14 +61,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class, \PhpParser\Node\Stmt\ClassConst::class]; + return [Property::class, ClassConst::class]; } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configuration); + Assert::allString($configuration); $this->annotationsToConsiderForInlining = \array_map(function (string $annotation) : string { return '@' . \ltrim($annotation, '@'); }, $configuration); @@ -76,12 +76,12 @@ CODE_SAMPLE /** * @param Property|ClassConst $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkipNode($node)) { return null; } - $comments = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, []); + $comments = $node->getAttribute(AttributeKey::COMMENTS, []); if ((\is_array($comments) || $comments instanceof \Countable ? \count($comments) : 0) !== 1) { return null; } @@ -120,9 +120,9 @@ CODE_SAMPLE */ private function shouldSkipNode($node) : bool { - if ($node instanceof \PhpParser\Node\Stmt\Property && \count($node->props) !== 1) { + if ($node instanceof Property && \count($node->props) !== 1) { return \true; } - return $node instanceof \PhpParser\Node\Stmt\ClassConst && \count($node->consts) !== 1; + return $node instanceof ClassConst && \count($node->consts) !== 1; } } diff --git a/rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php b/rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php index b20c569985b..b6d9f6e7bf0 100644 --- a/rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php +++ b/rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php @@ -28,20 +28,20 @@ use PhpParser\Node\Stmt\TryCatch; use PhpParser\Node\Stmt\While_; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\Stmt\NewlineAfterStatementRector\NewlineAfterStatementRectorTest */ -final class NewlineAfterStatementRector extends \Rector\Core\Rector\AbstractRector +final class NewlineAfterStatementRector extends AbstractRector { /** * @var array> */ - private const STMTS_TO_HAVE_NEXT_NEWLINE = [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Stmt\Property::class, \PhpParser\Node\Stmt\If_::class, \PhpParser\Node\Stmt\Foreach_::class, \PhpParser\Node\Stmt\Do_::class, \PhpParser\Node\Stmt\While_::class, \PhpParser\Node\Stmt\For_::class, \PhpParser\Node\Stmt\ClassConst::class, \PhpParser\Node\Stmt\Namespace_::class, \PhpParser\Node\Stmt\TryCatch::class, \PhpParser\Node\Stmt\Class_::class, \PhpParser\Node\Stmt\Trait_::class, \PhpParser\Node\Stmt\Interface_::class, \PhpParser\Node\Stmt\Switch_::class]; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + private const STMTS_TO_HAVE_NEXT_NEWLINE = [ClassMethod::class, Function_::class, Property::class, If_::class, Foreach_::class, Do_::class, While_::class, For_::class, ClassConst::class, Namespace_::class, TryCatch::class, Class_::class, Trait_::class, Interface_::class, Switch_::class]; + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add new line after statements to tidify code', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add new line after statements to tidify code', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function test() @@ -71,18 +71,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt::class]; + return [Stmt::class]; } /** * @param Stmt $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!\in_array(\get_class($node), self::STMTS_TO_HAVE_NEXT_NEWLINE, \true)) { return null; } - $nextNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if (!$nextNode instanceof \PhpParser\Node) { + $nextNode = $node->getAttribute(AttributeKey::NEXT_NODE); + if (!$nextNode instanceof Node) { return null; } if ($this->shouldSkip($nextNode)) { @@ -93,7 +93,7 @@ CODE_SAMPLE $rangeLine = $line - $endLine; if ($rangeLine > 1) { /** @var Comment[]|null $comments */ - $comments = $nextNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS); + $comments = $nextNode->getAttribute(AttributeKey::COMMENTS); if ($this->hasNoComment($comments)) { return null; } @@ -109,7 +109,7 @@ CODE_SAMPLE } } // @todo refactor to direct return of array - $this->nodesToAddCollector->addNodeAfterNode(new \PhpParser\Node\Stmt\Nop(), $node); + $this->nodesToAddCollector->addNodeAfterNode(new Nop(), $node); return $node; } /** @@ -122,11 +122,11 @@ CODE_SAMPLE } return !isset($comments[0]); } - private function shouldSkip(?\PhpParser\Node $nextNode) : bool + private function shouldSkip(?Node $nextNode) : bool { - if (!$nextNode instanceof \PhpParser\Node\Stmt) { + if (!$nextNode instanceof Stmt) { return \true; } - return \in_array(\get_class($nextNode), [\PhpParser\Node\Stmt\Else_::class, \PhpParser\Node\Stmt\ElseIf_::class, \PhpParser\Node\Stmt\Catch_::class, \PhpParser\Node\Stmt\Finally_::class], \true); + return \in_array(\get_class($nextNode), [Else_::class, ElseIf_::class, Catch_::class, Finally_::class], \true); } } diff --git a/rules/CodingStyle/Rector/String_/SymplifyQuoteEscapeRector.php b/rules/CodingStyle/Rector/String_/SymplifyQuoteEscapeRector.php index 632d087f8b8..6b2e139b7eb 100644 --- a/rules/CodingStyle/Rector/String_/SymplifyQuoteEscapeRector.php +++ b/rules/CodingStyle/Rector/String_/SymplifyQuoteEscapeRector.php @@ -8,12 +8,12 @@ use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; use Rector\Core\Util\StringUtils; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector\SymplifyQuoteEscapeRectorTest */ -final class SymplifyQuoteEscapeRector extends \Rector\Core\Rector\AbstractRector +final class SymplifyQuoteEscapeRector extends AbstractRector { /** * @var string @@ -24,9 +24,9 @@ final class SymplifyQuoteEscapeRector extends \Rector\Core\Rector\AbstractRector * @var bool */ private $hasChanged = \false; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Prefer quote that are not inside the string', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Prefer quote that are not inside the string', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -53,21 +53,21 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Scalar\String_::class]; + return [String_::class]; } /** * @param String_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Scalar\String_ + public function refactor(Node $node) : ?String_ { $doubleQuoteCount = \substr_count($node->value, '"'); $singleQuoteCount = \substr_count($node->value, "'"); - $kind = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND); - if ($kind === \PhpParser\Node\Scalar\String_::KIND_SINGLE_QUOTED) { + $kind = $node->getAttribute(AttributeKey::KIND); + if ($kind === String_::KIND_SINGLE_QUOTED) { $this->processSingleQuoted($node, $doubleQuoteCount, $singleQuoteCount); } - $quoteKind = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND); - if ($quoteKind === \PhpParser\Node\Scalar\String_::KIND_DOUBLE_QUOTED) { + $quoteKind = $node->getAttribute(AttributeKey::KIND); + if ($quoteKind === String_::KIND_DOUBLE_QUOTED) { $this->processDoubleQuoted($node, $singleQuoteCount, $doubleQuoteCount); } if (!$this->hasChanged) { @@ -75,34 +75,34 @@ CODE_SAMPLE } return $node; } - private function processSingleQuoted(\PhpParser\Node\Scalar\String_ $string, int $doubleQuoteCount, int $singleQuoteCount) : void + private function processSingleQuoted(String_ $string, int $doubleQuoteCount, int $singleQuoteCount) : void { if ($doubleQuoteCount === 0 && $singleQuoteCount > 0) { // contains chars that will be newly escaped if ($this->isMatchEscapedChars($string->value)) { return; } - $string->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND, \PhpParser\Node\Scalar\String_::KIND_DOUBLE_QUOTED); + $string->setAttribute(AttributeKey::KIND, String_::KIND_DOUBLE_QUOTED); // invoke override - $string->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $string->setAttribute(AttributeKey::ORIGINAL_NODE, null); $this->hasChanged = \true; } } - private function processDoubleQuoted(\PhpParser\Node\Scalar\String_ $string, int $singleQuoteCount, int $doubleQuoteCount) : void + private function processDoubleQuoted(String_ $string, int $singleQuoteCount, int $doubleQuoteCount) : void { if ($singleQuoteCount === 0 && $doubleQuoteCount > 0) { // contains chars that will be newly escaped if ($this->isMatchEscapedChars($string->value)) { return; } - $string->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND, \PhpParser\Node\Scalar\String_::KIND_SINGLE_QUOTED); + $string->setAttribute(AttributeKey::KIND, String_::KIND_SINGLE_QUOTED); // invoke override - $string->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $string->setAttribute(AttributeKey::ORIGINAL_NODE, null); $this->hasChanged = \true; } } private function isMatchEscapedChars(string $string) : bool { - return \Rector\Core\Util\StringUtils::isMatch($string, self::ESCAPED_CHAR_REGEX); + return StringUtils::isMatch($string, self::ESCAPED_CHAR_REGEX); } } diff --git a/rules/CodingStyle/Rector/String_/UseClassKeywordForClassNameResolutionRector.php b/rules/CodingStyle/Rector/String_/UseClassKeywordForClassNameResolutionRector.php index c2fee117a2f..d406d9a3f31 100644 --- a/rules/CodingStyle/Rector/String_/UseClassKeywordForClassNameResolutionRector.php +++ b/rules/CodingStyle/Rector/String_/UseClassKeywordForClassNameResolutionRector.php @@ -10,12 +10,12 @@ use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\Scalar\String_; use PHPStan\Reflection\ReflectionProvider; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\String_\UseClassKeywordForClassNameResolutionRector\UseClassKeywordForClassNameResolutionRectorTest */ -final class UseClassKeywordForClassNameResolutionRector extends \Rector\Core\Rector\AbstractRector +final class UseClassKeywordForClassNameResolutionRector extends AbstractRector { /** * @var string @@ -27,13 +27,13 @@ final class UseClassKeywordForClassNameResolutionRector extends \Rector\Core\Rec * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ReflectionProvider $reflectionProvider) { $this->reflectionProvider = $reflectionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Use `class` keyword for class name resolution in string instead of hardcoded string reference', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Use `class` keyword for class name resolution in string instead of hardcoded string reference', [new CodeSample(<<<'CODE_SAMPLE' $value = 'App\SomeClass::someMethod()'; CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -46,12 +46,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Scalar\String_::class]; + return [String_::class]; } /** * @param String_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $classNames = $this->getExistingClasses($node); if ($classNames === []) { @@ -67,10 +67,10 @@ CODE_SAMPLE /** * @return string[] */ - public function getExistingClasses(\PhpParser\Node\Scalar\String_ $string) : array + public function getExistingClasses(String_ $string) : array { /** @var mixed[] $matches */ - $matches = \RectorPrefix20220607\Nette\Utils\Strings::matchAll($string->value, self::CLASS_BEFORE_STATIC_ACCESS_REGEX, \PREG_PATTERN_ORDER); + $matches = Strings::matchAll($string->value, self::CLASS_BEFORE_STATIC_ACCESS_REGEX, \PREG_PATTERN_ORDER); if (!isset($matches['class_name'])) { return []; } @@ -87,11 +87,11 @@ CODE_SAMPLE * @param string[] $classNames * @return mixed[] */ - public function getParts(\PhpParser\Node\Scalar\String_ $string, array $classNames) : array + public function getParts(String_ $string, array $classNames) : array { $quotedClassNames = \array_map('preg_quote', $classNames); // @see https://regex101.com/r/8nGS0F/1 - $parts = \RectorPrefix20220607\Nette\Utils\Strings::split($string->value, '#(' . \implode('|', $quotedClassNames) . ')#'); + $parts = Strings::split($string->value, '#(' . \implode('|', $quotedClassNames) . ')#'); return \array_filter($parts, function (string $className) : bool { return $className !== ''; }); @@ -105,9 +105,9 @@ CODE_SAMPLE $exprsToConcat = []; foreach ($parts as $part) { if ($this->reflectionProvider->hasClass($part)) { - $exprsToConcat[] = new \PhpParser\Node\Expr\ClassConstFetch(new \PhpParser\Node\Name\FullyQualified(\ltrim($part, '\\')), 'class'); + $exprsToConcat[] = new ClassConstFetch(new FullyQualified(\ltrim($part, '\\')), 'class'); } else { - $exprsToConcat[] = new \PhpParser\Node\Scalar\String_($part); + $exprsToConcat[] = new String_($part); } } return $exprsToConcat; diff --git a/rules/CodingStyle/Rector/Switch_/BinarySwitchToIfElseRector.php b/rules/CodingStyle/Rector/Switch_/BinarySwitchToIfElseRector.php index 06dd1335b53..d9e09df1b11 100644 --- a/rules/CodingStyle/Rector/Switch_/BinarySwitchToIfElseRector.php +++ b/rules/CodingStyle/Rector/Switch_/BinarySwitchToIfElseRector.php @@ -13,25 +13,25 @@ use PhpParser\Node\Stmt\If_; use PhpParser\Node\Stmt\Switch_; use Rector\Core\Rector\AbstractRector; use Rector\Renaming\NodeManipulator\SwitchManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\Switch_\BinarySwitchToIfElseRector\BinarySwitchToIfElseRectorTest */ -final class BinarySwitchToIfElseRector extends \Rector\Core\Rector\AbstractRector +final class BinarySwitchToIfElseRector extends AbstractRector { /** * @readonly * @var \Rector\Renaming\NodeManipulator\SwitchManipulator */ private $switchManipulator; - public function __construct(\Rector\Renaming\NodeManipulator\SwitchManipulator $switchManipulator) + public function __construct(SwitchManipulator $switchManipulator) { $this->switchManipulator = $switchManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes switch with 2 options to if-else', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes switch with 2 options to if-else', [new CodeSample(<<<'CODE_SAMPLE' switch ($foo) { case 'my string': $result = 'ok'; @@ -55,12 +55,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Switch_::class]; + return [Switch_::class]; } /** * @param Switch_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (\count($node->cases) > 2) { return null; @@ -74,24 +74,24 @@ CODE_SAMPLE // special case with empty first case → || $isFirstCaseEmpty = $firstCase->stmts === []; if ($isFirstCaseEmpty && $secondCase !== null && $secondCase->cond !== null) { - $else = new \PhpParser\Node\Expr\BinaryOp\BooleanOr(new \PhpParser\Node\Expr\BinaryOp\Equal($node->cond, $firstCase->cond), new \PhpParser\Node\Expr\BinaryOp\Equal($node->cond, $secondCase->cond)); - $ifNode = new \PhpParser\Node\Stmt\If_($else); + $else = new BooleanOr(new Equal($node->cond, $firstCase->cond), new Equal($node->cond, $secondCase->cond)); + $ifNode = new If_($else); $ifNode->stmts = $this->switchManipulator->removeBreakNodes($secondCase->stmts); return $ifNode; } - $ifNode = new \PhpParser\Node\Stmt\If_(new \PhpParser\Node\Expr\BinaryOp\Equal($node->cond, $firstCase->cond)); + $ifNode = new If_(new Equal($node->cond, $firstCase->cond)); $ifNode->stmts = $this->switchManipulator->removeBreakNodes($firstCase->stmts); // just one condition - if (!$secondCase instanceof \PhpParser\Node\Stmt\Case_) { + if (!$secondCase instanceof Case_) { return $ifNode; } if ($secondCase->cond !== null) { // has condition - $equal = new \PhpParser\Node\Expr\BinaryOp\Equal($node->cond, $secondCase->cond); - $ifNode->elseifs[] = new \PhpParser\Node\Stmt\ElseIf_($equal, $this->switchManipulator->removeBreakNodes($secondCase->stmts)); + $equal = new Equal($node->cond, $secondCase->cond); + $ifNode->elseifs[] = new ElseIf_($equal, $this->switchManipulator->removeBreakNodes($secondCase->stmts)); } else { // defaults - $ifNode->else = new \PhpParser\Node\Stmt\Else_($this->switchManipulator->removeBreakNodes($secondCase->stmts)); + $ifNode->else = new Else_($this->switchManipulator->removeBreakNodes($secondCase->stmts)); } return $ifNode; } diff --git a/rules/CodingStyle/Rector/Ternary/TernaryConditionVariableAssignmentRector.php b/rules/CodingStyle/Rector/Ternary/TernaryConditionVariableAssignmentRector.php index 2f9763dad0e..b95a79d2487 100644 --- a/rules/CodingStyle/Rector/Ternary/TernaryConditionVariableAssignmentRector.php +++ b/rules/CodingStyle/Rector/Ternary/TernaryConditionVariableAssignmentRector.php @@ -9,16 +9,16 @@ use PhpParser\Node\Expr\Ternary; use PhpParser\Node\Expr\Variable; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\Ternary\TernaryConditionVariableAssignmentRector\TernaryConditionVariableAssignmentRectorTest */ -final class TernaryConditionVariableAssignmentRector extends \Rector\Core\Rector\AbstractRector +final class TernaryConditionVariableAssignmentRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Assign outcome of ternary condition to variable, where applicable', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Assign outcome of ternary condition to variable, where applicable', [new CodeSample(<<<'CODE_SAMPLE' function ternary($value) { $value ? $a = 1 : $a = 0; @@ -37,39 +37,39 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Ternary::class]; + return [Ternary::class]; } /** * @param Ternary $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $nodeIf = $node->if; $nodeElse = $node->else; - if (!$nodeIf instanceof \PhpParser\Node\Expr\Assign) { + if (!$nodeIf instanceof Assign) { return null; } - if (!$nodeElse instanceof \PhpParser\Node\Expr\Assign) { + if (!$nodeElse instanceof Assign) { return null; } $nodeIfVar = $nodeIf->var; $nodeElseVar = $nodeElse->var; - if (!$nodeIfVar instanceof \PhpParser\Node\Expr\Variable) { + if (!$nodeIfVar instanceof Variable) { return null; } - if (!$nodeElseVar instanceof \PhpParser\Node\Expr\Variable) { + if (!$nodeElseVar instanceof Variable) { return null; } if ($nodeIfVar->name !== $nodeElseVar->name) { return null; } - $previousNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_NODE); + $previousNode = $node->getAttribute(AttributeKey::PREVIOUS_NODE); if ($previousNode !== null) { return null; } $node->if = $nodeIf->expr; $node->else = $nodeElse->expr; - $variable = new \PhpParser\Node\Expr\Variable($nodeIfVar->name); - return new \PhpParser\Node\Expr\Assign($variable, $node); + $variable = new Variable($nodeIfVar->name); + return new Assign($variable, $node); } } diff --git a/rules/CodingStyle/Rector/Use_/SeparateMultiUseImportsRector.php b/rules/CodingStyle/Rector/Use_/SeparateMultiUseImportsRector.php index 89aa4cf0c63..7f7936c6532 100644 --- a/rules/CodingStyle/Rector/Use_/SeparateMultiUseImportsRector.php +++ b/rules/CodingStyle/Rector/Use_/SeparateMultiUseImportsRector.php @@ -7,16 +7,16 @@ use PhpParser\Node; use PhpParser\Node\Stmt\TraitUse; use PhpParser\Node\Stmt\Use_; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector\SeparateMultiUseImportsRectorTest */ -final class SeparateMultiUseImportsRector extends \Rector\Core\Rector\AbstractRector +final class SeparateMultiUseImportsRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Split multi use imports and trait statements to standalone lines', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Split multi use imports and trait statements to standalone lines', [new CodeSample(<<<'CODE_SAMPLE' use A, B; class SomeClass @@ -41,15 +41,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Use_::class, \PhpParser\Node\Stmt\TraitUse::class]; + return [Use_::class, TraitUse::class]; } /** * @param Use_|TraitUse $node * @return Use_[]|TraitUse[]|null */ - public function refactor(\PhpParser\Node $node) : ?array + public function refactor(Node $node) : ?array { - if ($node instanceof \PhpParser\Node\Stmt\Use_) { + if ($node instanceof Use_) { return $this->refactorUseImport($node); } return $this->refactorTraitUse($node); @@ -57,28 +57,28 @@ CODE_SAMPLE /** * @return Use_[]|null $use */ - private function refactorUseImport(\PhpParser\Node\Stmt\Use_ $use) : ?array + private function refactorUseImport(Use_ $use) : ?array { if (\count($use->uses) < 2) { return null; } $uses = []; foreach ($use->uses as $singleUse) { - $uses[] = new \PhpParser\Node\Stmt\Use_([$singleUse]); + $uses[] = new Use_([$singleUse]); } return $uses; } /** * @return TraitUse[]|null */ - private function refactorTraitUse(\PhpParser\Node\Stmt\TraitUse $traitUse) : ?array + private function refactorTraitUse(TraitUse $traitUse) : ?array { if (\count($traitUse->traits) < 2) { return null; } $traitUses = []; foreach ($traitUse->traits as $singleTraitUse) { - $traitUses[] = new \PhpParser\Node\Stmt\TraitUse([$singleTraitUse]); + $traitUses[] = new TraitUse([$singleTraitUse]); } return $traitUses; } diff --git a/rules/CodingStyle/Reflection/VendorLocationDetector.php b/rules/CodingStyle/Reflection/VendorLocationDetector.php index 0c0f83d42cd..cab97a1c39d 100644 --- a/rules/CodingStyle/Reflection/VendorLocationDetector.php +++ b/rules/CodingStyle/Reflection/VendorLocationDetector.php @@ -12,11 +12,11 @@ final class VendorLocationDetector * @var \Symplify\SmartFileSystem\Normalizer\PathNormalizer */ private $pathNormalizer; - public function __construct(\RectorPrefix20220607\Symplify\SmartFileSystem\Normalizer\PathNormalizer $pathNormalizer) + public function __construct(PathNormalizer $pathNormalizer) { $this->pathNormalizer = $pathNormalizer; } - public function detectMethodReflection(\PHPStan\Reflection\MethodReflection $methodReflection) : bool + public function detectMethodReflection(MethodReflection $methodReflection) : bool { $declaringClassReflection = $methodReflection->getDeclaringClass(); $fileName = $declaringClassReflection->getFileName(); diff --git a/rules/CodingStyle/TypeAnalyzer/IterableTypeAnalyzer.php b/rules/CodingStyle/TypeAnalyzer/IterableTypeAnalyzer.php index cf431d135df..ac4e6d64b41 100644 --- a/rules/CodingStyle/TypeAnalyzer/IterableTypeAnalyzer.php +++ b/rules/CodingStyle/TypeAnalyzer/IterableTypeAnalyzer.php @@ -9,15 +9,15 @@ use PHPStan\Type\Type; use PHPStan\Type\UnionType; final class IterableTypeAnalyzer { - public function detect(\PHPStan\Type\Type $type) : bool + public function detect(Type $type) : bool { - if ($type instanceof \PHPStan\Type\ArrayType) { + if ($type instanceof ArrayType) { return \true; } - if ($type instanceof \PHPStan\Type\IterableType) { + if ($type instanceof IterableType) { return \true; } - if ($type instanceof \PHPStan\Type\UnionType) { + if ($type instanceof UnionType) { foreach ($type->getTypes() as $unionedType) { if (!$this->detect($unionedType)) { return \false; diff --git a/rules/CodingStyle/ValueObject/ObjectMagicMethods.php b/rules/CodingStyle/ValueObject/ObjectMagicMethods.php index acb6ed44541..0e519108af5 100644 --- a/rules/CodingStyle/ValueObject/ObjectMagicMethods.php +++ b/rules/CodingStyle/ValueObject/ObjectMagicMethods.php @@ -9,5 +9,5 @@ final class ObjectMagicMethods /** * @var string[] */ - public const METHOD_NAMES = ['__call', '__callStatic', \Rector\Core\ValueObject\MethodName::CLONE, \Rector\Core\ValueObject\MethodName::CONSTRUCT, '__debugInfo', \Rector\Core\ValueObject\MethodName::DESCTRUCT, '__get', \Rector\Core\ValueObject\MethodName::INVOKE, '__isset', '__serialize', '__set', \Rector\Core\ValueObject\MethodName::SET_STATE, '__sleep', '__toString', '__unserialize', '__unset', '__wakeup']; + public const METHOD_NAMES = ['__call', '__callStatic', MethodName::CLONE, MethodName::CONSTRUCT, '__debugInfo', MethodName::DESCTRUCT, '__get', MethodName::INVOKE, '__isset', '__serialize', '__set', MethodName::SET_STATE, '__sleep', '__toString', '__unserialize', '__unset', '__wakeup']; } diff --git a/rules/CodingStyle/ValueObject/ReturnArrayClassMethodToYield.php b/rules/CodingStyle/ValueObject/ReturnArrayClassMethodToYield.php index eed5d57e5c5..e82320c3f12 100644 --- a/rules/CodingStyle/ValueObject/ReturnArrayClassMethodToYield.php +++ b/rules/CodingStyle/ValueObject/ReturnArrayClassMethodToYield.php @@ -21,11 +21,11 @@ final class ReturnArrayClassMethodToYield { $this->type = $type; $this->method = $method; - \Rector\Core\Validation\RectorAssert::className($type); + RectorAssert::className($type); } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->type); + return new ObjectType($this->type); } public function getMethod() : string { diff --git a/rules/Compatibility/NodeAnalyzer/RequiredAnnotationPropertyAnalyzer.php b/rules/Compatibility/NodeAnalyzer/RequiredAnnotationPropertyAnalyzer.php index a0c52dddb93..127e0c94079 100644 --- a/rules/Compatibility/NodeAnalyzer/RequiredAnnotationPropertyAnalyzer.php +++ b/rules/Compatibility/NodeAnalyzer/RequiredAnnotationPropertyAnalyzer.php @@ -17,11 +17,11 @@ final class RequiredAnnotationPropertyAnalyzer * @var \Rector\Core\PhpParser\Node\Value\ValueResolver */ private $valueResolver; - public function __construct(\Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver) + public function __construct(ValueResolver $valueResolver) { $this->valueResolver = $valueResolver; } - public function isRequiredProperty(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\Stmt\Property $property) : bool + public function isRequiredProperty(PhpDocInfo $phpDocInfo, Property $property) : bool { if ($phpDocInfo->hasByAnnotationClass('Doctrine\\Common\\Annotations\\Annotation\\Required')) { return \true; @@ -29,19 +29,19 @@ final class RequiredAnnotationPropertyAnalyzer // sometimes property has default null, but @var says its not null - that's due to nullability of typed properties // in that case, we should treat property as required $firstProperty = $property->props[0]; - if (!$firstProperty->default instanceof \PhpParser\Node\Expr) { + if (!$firstProperty->default instanceof Expr) { return \false; } if (!$this->valueResolver->isNull($firstProperty->default)) { return \false; } $varTagValueNode = $phpDocInfo->getVarTagValueNode(); - if (!$varTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) { + if (!$varTagValueNode instanceof VarTagValueNode) { return \false; } - if ($varTagValueNode->type instanceof \PHPStan\PhpDocParser\Ast\Type\NullableTypeNode) { + if ($varTagValueNode->type instanceof NullableTypeNode) { return \false; } - return $property->type instanceof \PhpParser\Node\NullableType; + return $property->type instanceof NullableType; } } diff --git a/rules/Compatibility/NodeFactory/ConstructorClassMethodFactory.php b/rules/Compatibility/NodeFactory/ConstructorClassMethodFactory.php index 6175835efbf..083bee203e8 100644 --- a/rules/Compatibility/NodeFactory/ConstructorClassMethodFactory.php +++ b/rules/Compatibility/NodeFactory/ConstructorClassMethodFactory.php @@ -22,7 +22,7 @@ final class ConstructorClassMethodFactory * @var \Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover */ private $paramTagRemover; - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover $paramTagRemover) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory, ParamTagRemover $paramTagRemover) { $this->phpDocInfoFactory = $phpDocInfoFactory; $this->paramTagRemover = $paramTagRemover; @@ -31,9 +31,9 @@ final class ConstructorClassMethodFactory * @param PropertyWithPhpDocInfo[] $requiredPropertiesWithPhpDocInfos * @param Param[] $params */ - public function createConstructorClassMethod(array $requiredPropertiesWithPhpDocInfos, array $params) : \PhpParser\Node\Stmt\ClassMethod + public function createConstructorClassMethod(array $requiredPropertiesWithPhpDocInfos, array $params) : ClassMethod { - $classMethod = new \PhpParser\Node\Stmt\ClassMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT, ['flags' => \PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC, 'params' => $params]); + $classMethod = new ClassMethod(MethodName::CONSTRUCT, ['flags' => Class_::MODIFIER_PUBLIC, 'params' => $params]); $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); foreach ($requiredPropertiesWithPhpDocInfos as $requiredPropertyWithPhpDocInfo) { $paramTagValueNode = $requiredPropertyWithPhpDocInfo->getParamTagValueNode(); diff --git a/rules/Compatibility/Rector/Class_/AttributeCompatibleAnnotationRector.php b/rules/Compatibility/Rector/Class_/AttributeCompatibleAnnotationRector.php index 1084f76e8ee..49a827601a6 100644 --- a/rules/Compatibility/Rector/Class_/AttributeCompatibleAnnotationRector.php +++ b/rules/Compatibility/Rector/Class_/AttributeCompatibleAnnotationRector.php @@ -17,12 +17,12 @@ use Rector\Compatibility\NodeFactory\ConstructorClassMethodFactory; use Rector\Compatibility\ValueObject\PropertyWithPhpDocInfo; use Rector\Core\Rector\AbstractRector; use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Compatibility\Rector\Class_\AttributeCompatibleAnnotationRector\AttributeCompatibleAnnotationRectorTest */ -final class AttributeCompatibleAnnotationRector extends \Rector\Core\Rector\AbstractRector +final class AttributeCompatibleAnnotationRector extends AbstractRector { /** * @var string @@ -48,16 +48,16 @@ final class AttributeCompatibleAnnotationRector extends \Rector\Core\Rector\Abst * @var \Rector\Compatibility\NodeFactory\ConstructorClassMethodFactory */ private $constructorClassMethodFactory; - public function __construct(\Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer $phpAttributeAnalyzer, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover $phpDocTagRemover, \Rector\Compatibility\NodeAnalyzer\RequiredAnnotationPropertyAnalyzer $requiredAnnotationPropertyAnalyzer, \Rector\Compatibility\NodeFactory\ConstructorClassMethodFactory $constructorClassMethodFactory) + public function __construct(PhpAttributeAnalyzer $phpAttributeAnalyzer, PhpDocTagRemover $phpDocTagRemover, RequiredAnnotationPropertyAnalyzer $requiredAnnotationPropertyAnalyzer, ConstructorClassMethodFactory $constructorClassMethodFactory) { $this->phpAttributeAnalyzer = $phpAttributeAnalyzer; $this->phpDocTagRemover = $phpDocTagRemover; $this->requiredAnnotationPropertyAnalyzer = $requiredAnnotationPropertyAnalyzer; $this->constructorClassMethodFactory = $constructorClassMethodFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change annotation to attribute compatible form, see https://tomasvotruba.com/blog/doctrine-annotations-and-attributes-living-together-in-peace/', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change annotation to attribute compatible form, see https://tomasvotruba.com/blog/doctrine-annotations-and-attributes-living-together-in-peace/', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\Common\Annotations\Annotation\Required; /** @@ -97,22 +97,22 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); - if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$phpDocInfo instanceof PhpDocInfo) { return null; } if ($this->shouldSkipClass($phpDocInfo, $node)) { return null; } // add "NamedArgumentConstructor" - $phpDocInfo->addTagValueNode(new \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode(new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('Doctrine\\Common\\Annotations\\Annotation\\NamedArgumentConstructor'))); + $phpDocInfo->addTagValueNode(new DoctrineAnnotationTagValueNode(new IdentifierTypeNode('Doctrine\\Common\\Annotations\\Annotation\\NamedArgumentConstructor'))); // resolve required properties $requiredPropertiesWithPhpDocInfos = []; foreach ($node->getProperties() as $property) { @@ -124,14 +124,14 @@ CODE_SAMPLE continue; } $propertyName = $this->getName($property); - $requiredPropertiesWithPhpDocInfos[] = new \Rector\Compatibility\ValueObject\PropertyWithPhpDocInfo($propertyName, $property, $propertyPhpDocInfo); + $requiredPropertiesWithPhpDocInfos[] = new PropertyWithPhpDocInfo($propertyName, $property, $propertyPhpDocInfo); } $params = $this->createConstructParams($requiredPropertiesWithPhpDocInfos); $constructorClassMethod = $this->constructorClassMethodFactory->createConstructorClassMethod($requiredPropertiesWithPhpDocInfos, $params); $node->stmts = \array_merge($node->stmts, [$constructorClassMethod]); return $node; } - private function shouldSkipClass(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\Stmt\Class_ $class) : bool + private function shouldSkipClass(PhpDocInfo $phpDocInfo, Class_ $class) : bool { if (!$phpDocInfo->hasByNames(['Annotation', 'annotation'])) { return \true; @@ -154,10 +154,10 @@ CODE_SAMPLE $propertyName = $this->getName($property); // unwrap nullable type, as variable is required $propertyType = $property->type; - if ($propertyType instanceof \PhpParser\Node\NullableType) { + if ($propertyType instanceof NullableType) { $propertyType = $propertyType->type; } - $param = new \PhpParser\Node\Param(new \PhpParser\Node\Expr\Variable($propertyName), null, $propertyType, \false, \false, [], $property->flags); + $param = new Param(new Variable($propertyName), null, $propertyType, \false, \false, [], $property->flags); $params[] = $param; $propertyPhpDocInfo = $requiredPropertyWithPhpDocInfo->getPhpDocInfo(); // remove required diff --git a/rules/Compatibility/ValueObject/PropertyWithPhpDocInfo.php b/rules/Compatibility/ValueObject/PropertyWithPhpDocInfo.php index 0ef3268f3d1..a9d712845bb 100644 --- a/rules/Compatibility/ValueObject/PropertyWithPhpDocInfo.php +++ b/rules/Compatibility/ValueObject/PropertyWithPhpDocInfo.php @@ -25,17 +25,17 @@ final class PropertyWithPhpDocInfo * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo */ private $phpDocInfo; - public function __construct(string $propertyName, \PhpParser\Node\Stmt\Property $property, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) + public function __construct(string $propertyName, Property $property, PhpDocInfo $phpDocInfo) { $this->propertyName = $propertyName; $this->property = $property; $this->phpDocInfo = $phpDocInfo; } - public function getProperty() : \PhpParser\Node\Stmt\Property + public function getProperty() : Property { return $this->property; } - public function getPhpDocInfo() : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo + public function getPhpDocInfo() : PhpDocInfo { return $this->phpDocInfo; } @@ -43,12 +43,12 @@ final class PropertyWithPhpDocInfo { return $this->propertyName; } - public function getParamTagValueNode() : \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode + public function getParamTagValueNode() : ParamTagValueNode { $varTagValueNode = $this->phpDocInfo->getVarTagValueNode(); - if (!$varTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$varTagValueNode instanceof VarTagValueNode) { + throw new ShouldNotHappenException(); } - return new \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode($varTagValueNode->type, \false, '$' . $this->propertyName, ''); + return new ParamTagValueNode($varTagValueNode->type, \false, '$' . $this->propertyName, ''); } } diff --git a/rules/Composer/Application/FileProcessor/ComposerFileProcessor.php b/rules/Composer/Application/FileProcessor/ComposerFileProcessor.php index 3931a42b300..5216bd1e3c9 100644 --- a/rules/Composer/Application/FileProcessor/ComposerFileProcessor.php +++ b/rules/Composer/Application/FileProcessor/ComposerFileProcessor.php @@ -14,8 +14,8 @@ use Rector\Parallel\ValueObject\Bridge; use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment; use RectorPrefix20220607\Symplify\ComposerJsonManipulator\ComposerJsonFactory; use RectorPrefix20220607\Symplify\ComposerJsonManipulator\Printer\ComposerJsonPrinter; -use Symplify\SmartFileSystem\SmartFileInfo; -final class ComposerFileProcessor implements \Rector\Core\Contract\Processor\FileProcessorInterface +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; +final class ComposerFileProcessor implements FileProcessorInterface { /** * @readonly @@ -40,7 +40,7 @@ final class ComposerFileProcessor implements \Rector\Core\Contract\Processor\Fil /** * @param ComposerRectorInterface[] $composerRectors */ - public function __construct(\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ComposerJsonFactory $composerJsonFactory, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\Printer\ComposerJsonPrinter $composerJsonPrinter, \Rector\ChangesReporting\ValueObjectFactory\FileDiffFactory $fileDiffFactory, array $composerRectors) + public function __construct(ComposerJsonFactory $composerJsonFactory, ComposerJsonPrinter $composerJsonPrinter, FileDiffFactory $fileDiffFactory, array $composerRectors) { $this->composerJsonFactory = $composerJsonFactory; $this->composerJsonPrinter = $composerJsonPrinter; @@ -50,9 +50,9 @@ final class ComposerFileProcessor implements \Rector\Core\Contract\Processor\Fil /** * @return array{system_errors: SystemError[], file_diffs: FileDiff[]} */ - public function process(\Rector\Core\ValueObject\Application\File $file, \Rector\Core\ValueObject\Configuration $configuration) : array + public function process(File $file, Configuration $configuration) : array { - $systemErrorsAndFileDiffs = [\Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS => [], \Rector\Parallel\ValueObject\Bridge::FILE_DIFFS => []]; + $systemErrorsAndFileDiffs = [Bridge::SYSTEM_ERRORS => [], Bridge::FILE_DIFFS => []]; if ($this->composerRectors === []) { return $systemErrorsAndFileDiffs; } @@ -71,10 +71,10 @@ final class ComposerFileProcessor implements \Rector\Core\Contract\Processor\Fil $changedFileContent = $this->composerJsonPrinter->printToString($composerJson); $file->changeFileContent($changedFileContent); $fileDiff = $this->fileDiffFactory->createFileDiff($file, $oldFileContents, $changedFileContent); - $systemErrorsAndFileDiffs[\Rector\Parallel\ValueObject\Bridge::FILE_DIFFS] = [$fileDiff]; + $systemErrorsAndFileDiffs[Bridge::FILE_DIFFS] = [$fileDiff]; return $systemErrorsAndFileDiffs; } - public function supports(\Rector\Core\ValueObject\Application\File $file, \Rector\Core\ValueObject\Configuration $configuration) : bool + public function supports(File $file, Configuration $configuration) : bool { $smartFileInfo = $file->getSmartFileInfo(); if ($this->isJsonInTests($smartFileInfo)) { @@ -89,9 +89,9 @@ final class ComposerFileProcessor implements \Rector\Core\Contract\Processor\Fil { return ['json']; } - private function isJsonInTests(\Symplify\SmartFileSystem\SmartFileInfo $fileInfo) : bool + private function isJsonInTests(SmartFileInfo $fileInfo) : bool { - if (!\Rector\Testing\PHPUnit\StaticPHPUnitEnvironment::isPHPUnitRun()) { + if (!StaticPHPUnitEnvironment::isPHPUnitRun()) { return \false; } return $fileInfo->hasSuffixes(['json']); diff --git a/rules/Composer/Contract/Rector/ComposerRectorInterface.php b/rules/Composer/Contract/Rector/ComposerRectorInterface.php index b7788d64163..843e52202fc 100644 --- a/rules/Composer/Contract/Rector/ComposerRectorInterface.php +++ b/rules/Composer/Contract/Rector/ComposerRectorInterface.php @@ -5,8 +5,8 @@ namespace Rector\Composer\Contract\Rector; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Contract\Rector\RectorInterface; -use Symplify\ComposerJsonManipulator\ValueObject\ComposerJson; -interface ComposerRectorInterface extends \Rector\Core\Contract\Rector\RectorInterface, \Rector\Core\Contract\Rector\ConfigurableRectorInterface +use RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson; +interface ComposerRectorInterface extends RectorInterface, ConfigurableRectorInterface { - public function refactor(\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson $composerJson) : void; + public function refactor(ComposerJson $composerJson) : void; } diff --git a/rules/Composer/Guard/VersionGuard.php b/rules/Composer/Guard/VersionGuard.php index 5f920b29057..308610e3955 100644 --- a/rules/Composer/Guard/VersionGuard.php +++ b/rules/Composer/Guard/VersionGuard.php @@ -12,7 +12,7 @@ final class VersionGuard * @var \Composer\Semver\VersionParser */ private $versionParser; - public function __construct(\RectorPrefix20220607\Composer\Semver\VersionParser $versionParser) + public function __construct(VersionParser $versionParser) { $this->versionParser = $versionParser; } diff --git a/rules/Composer/Rector/AddPackageToRequireComposerRector.php b/rules/Composer/Rector/AddPackageToRequireComposerRector.php index 5eb6f8d75e0..94d08bff927 100644 --- a/rules/Composer/Rector/AddPackageToRequireComposerRector.php +++ b/rules/Composer/Rector/AddPackageToRequireComposerRector.php @@ -7,13 +7,13 @@ use Rector\Composer\Contract\Rector\ComposerRectorInterface; use Rector\Composer\Guard\VersionGuard; use Rector\Composer\ValueObject\PackageAndVersion; use RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Composer\Rector\AddPackageToRequireComposerRector\AddPackageToRequireComposerRectorTest */ -final class AddPackageToRequireComposerRector implements \Rector\Composer\Contract\Rector\ComposerRectorInterface +final class AddPackageToRequireComposerRector implements ComposerRectorInterface { /** * @var PackageAndVersion[] @@ -24,19 +24,19 @@ final class AddPackageToRequireComposerRector implements \Rector\Composer\Contra * @var \Rector\Composer\Guard\VersionGuard */ private $versionGuard; - public function __construct(\Rector\Composer\Guard\VersionGuard $versionGuard) + public function __construct(VersionGuard $versionGuard) { $this->versionGuard = $versionGuard; } - public function refactor(\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson $composerJson) : void + public function refactor(ComposerJson $composerJson) : void { foreach ($this->packagesAndVersions as $packageAndVersion) { $composerJson->addRequiredPackage($packageAndVersion->getPackageName(), $packageAndVersion->getVersion()); } } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add package to "require" in `composer.json`', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add package to "require" in `composer.json`', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' { } CODE_SAMPLE @@ -47,14 +47,14 @@ CODE_SAMPLE } } CODE_SAMPLE -, [new \Rector\Composer\ValueObject\PackageAndVersion('symfony/console', '^3.4')])]); +, [new PackageAndVersion('symfony/console', '^3.4')])]); } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Composer\ValueObject\PackageAndVersion::class); + Assert::allIsAOf($configuration, PackageAndVersion::class); $this->versionGuard->validate($configuration); $this->packagesAndVersions = $configuration; } diff --git a/rules/Composer/Rector/AddPackageToRequireDevComposerRector.php b/rules/Composer/Rector/AddPackageToRequireDevComposerRector.php index ab492b4fa03..7af42ccea14 100644 --- a/rules/Composer/Rector/AddPackageToRequireDevComposerRector.php +++ b/rules/Composer/Rector/AddPackageToRequireDevComposerRector.php @@ -7,13 +7,13 @@ use Rector\Composer\Contract\Rector\ComposerRectorInterface; use Rector\Composer\Guard\VersionGuard; use Rector\Composer\ValueObject\PackageAndVersion; use RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Composer\Rector\AddPackageToRequireDevComposerRector\AddPackageToRequireDevComposerRectorTest */ -final class AddPackageToRequireDevComposerRector implements \Rector\Composer\Contract\Rector\ComposerRectorInterface +final class AddPackageToRequireDevComposerRector implements ComposerRectorInterface { /** * @var PackageAndVersion[] @@ -24,19 +24,19 @@ final class AddPackageToRequireDevComposerRector implements \Rector\Composer\Con * @var \Rector\Composer\Guard\VersionGuard */ private $versionGuard; - public function __construct(\Rector\Composer\Guard\VersionGuard $versionGuard) + public function __construct(VersionGuard $versionGuard) { $this->versionGuard = $versionGuard; } - public function refactor(\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson $composerJson) : void + public function refactor(ComposerJson $composerJson) : void { foreach ($this->packageAndVersions as $packageAndVersion) { $composerJson->addRequiredDevPackage($packageAndVersion->getPackageName(), $packageAndVersion->getVersion()); } } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add package to "require-dev" in `composer.json`', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add package to "require-dev" in `composer.json`', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' { } CODE_SAMPLE @@ -47,14 +47,14 @@ CODE_SAMPLE } } CODE_SAMPLE -, [new \Rector\Composer\ValueObject\PackageAndVersion('symfony/console', '^3.4')])]); +, [new PackageAndVersion('symfony/console', '^3.4')])]); } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Composer\ValueObject\PackageAndVersion::class); + Assert::allIsAOf($configuration, PackageAndVersion::class); $this->versionGuard->validate($configuration); $this->packageAndVersions = $configuration; } diff --git a/rules/Composer/Rector/ChangePackageVersionComposerRector.php b/rules/Composer/Rector/ChangePackageVersionComposerRector.php index bd589271c81..e2945f13a87 100644 --- a/rules/Composer/Rector/ChangePackageVersionComposerRector.php +++ b/rules/Composer/Rector/ChangePackageVersionComposerRector.php @@ -7,13 +7,13 @@ use Rector\Composer\Contract\Rector\ComposerRectorInterface; use Rector\Composer\Guard\VersionGuard; use Rector\Composer\ValueObject\PackageAndVersion; use RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Composer\Rector\ChangePackageVersionComposerRector\ChangePackageVersionComposerRectorTest */ -final class ChangePackageVersionComposerRector implements \Rector\Composer\Contract\Rector\ComposerRectorInterface +final class ChangePackageVersionComposerRector implements ComposerRectorInterface { /** * @var PackageAndVersion[] @@ -24,19 +24,19 @@ final class ChangePackageVersionComposerRector implements \Rector\Composer\Contr * @var \Rector\Composer\Guard\VersionGuard */ private $versionGuard; - public function __construct(\Rector\Composer\Guard\VersionGuard $versionGuard) + public function __construct(VersionGuard $versionGuard) { $this->versionGuard = $versionGuard; } - public function refactor(\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson $composerJson) : void + public function refactor(ComposerJson $composerJson) : void { foreach ($this->packagesAndVersions as $packageAndVersion) { $composerJson->changePackageVersion($packageAndVersion->getPackageName(), $packageAndVersion->getVersion()); } } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change package version `composer.json`', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change package version `composer.json`', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' { "require": { "symfony/console": "^3.4" @@ -50,14 +50,14 @@ CODE_SAMPLE } } CODE_SAMPLE -, [new \Rector\Composer\ValueObject\PackageAndVersion('symfony/console', '^4.4')])]); +, [new PackageAndVersion('symfony/console', '^4.4')])]); } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Composer\ValueObject\PackageAndVersion::class); + Assert::allIsAOf($configuration, PackageAndVersion::class); $this->versionGuard->validate($configuration); $this->packagesAndVersions = $configuration; } diff --git a/rules/Composer/Rector/RemovePackageComposerRector.php b/rules/Composer/Rector/RemovePackageComposerRector.php index 0c7c05deeb2..2648d890698 100644 --- a/rules/Composer/Rector/RemovePackageComposerRector.php +++ b/rules/Composer/Rector/RemovePackageComposerRector.php @@ -5,27 +5,27 @@ namespace Rector\Composer\Rector; use Rector\Composer\Contract\Rector\ComposerRectorInterface; use RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Composer\Rector\RemovePackageComposerRector\RemovePackageComposerRectorTest */ -final class RemovePackageComposerRector implements \Rector\Composer\Contract\Rector\ComposerRectorInterface +final class RemovePackageComposerRector implements ComposerRectorInterface { /** * @var string[] */ private $packageNames = []; - public function refactor(\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson $composerJson) : void + public function refactor(ComposerJson $composerJson) : void { foreach ($this->packageNames as $packageName) { $composerJson->removePackage($packageName); } } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove package from "require" and "require-dev" in `composer.json`', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove package from "require" and "require-dev" in `composer.json`', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' { "require": { "symfony/console": "^3.4" @@ -43,7 +43,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configuration); + Assert::allString($configuration); $this->packageNames = $configuration; } } diff --git a/rules/Composer/Rector/RenamePackageComposerRector.php b/rules/Composer/Rector/RenamePackageComposerRector.php index 7cfa836139e..d10b1b85244 100644 --- a/rules/Composer/Rector/RenamePackageComposerRector.php +++ b/rules/Composer/Rector/RenamePackageComposerRector.php @@ -6,19 +6,19 @@ namespace Rector\Composer\Rector; use Rector\Composer\Contract\Rector\ComposerRectorInterface; use Rector\Composer\ValueObject\RenamePackage; use RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Composer\Rector\RenamePackageComposerRector\RenamePackageComposerRectorTest */ -final class RenamePackageComposerRector implements \Rector\Composer\Contract\Rector\ComposerRectorInterface +final class RenamePackageComposerRector implements ComposerRectorInterface { /** * @var RenamePackage[] */ private $renamePackages = []; - public function refactor(\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson $composerJson) : void + public function refactor(ComposerJson $composerJson) : void { foreach ($this->renamePackages as $renamePackage) { if ($composerJson->hasRequiredPackage($renamePackage->getOldPackageName())) { @@ -31,9 +31,9 @@ final class RenamePackageComposerRector implements \Rector\Composer\Contract\Rec } } } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change package name in `composer.json`', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change package name in `composer.json`', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' { "require": { "rector/rector": "dev-main" @@ -47,14 +47,14 @@ CODE_SAMPLE } } CODE_SAMPLE -, [new \Rector\Composer\ValueObject\RenamePackage('rector/rector', 'rector/rector-src')])]); +, [new RenamePackage('rector/rector', 'rector/rector-src')])]); } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Composer\ValueObject\RenamePackage::class); + Assert::allIsAOf($configuration, RenamePackage::class); $this->renamePackages = $configuration; } } diff --git a/rules/Composer/Rector/ReplacePackageAndVersionComposerRector.php b/rules/Composer/Rector/ReplacePackageAndVersionComposerRector.php index d74c74247b6..5cd3a261a97 100644 --- a/rules/Composer/Rector/ReplacePackageAndVersionComposerRector.php +++ b/rules/Composer/Rector/ReplacePackageAndVersionComposerRector.php @@ -7,13 +7,13 @@ use Rector\Composer\Contract\Rector\ComposerRectorInterface; use Rector\Composer\Guard\VersionGuard; use Rector\Composer\ValueObject\ReplacePackageAndVersion; use RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Composer\Rector\ReplacePackageAndVersionComposerRector\ReplacePackageAndVersionComposerRectorTest */ -final class ReplacePackageAndVersionComposerRector implements \Rector\Composer\Contract\Rector\ComposerRectorInterface +final class ReplacePackageAndVersionComposerRector implements ComposerRectorInterface { /** * @var ReplacePackageAndVersion[] @@ -24,19 +24,19 @@ final class ReplacePackageAndVersionComposerRector implements \Rector\Composer\C * @var \Rector\Composer\Guard\VersionGuard */ private $versionGuard; - public function __construct(\Rector\Composer\Guard\VersionGuard $versionGuard) + public function __construct(VersionGuard $versionGuard) { $this->versionGuard = $versionGuard; } - public function refactor(\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson $composerJson) : void + public function refactor(ComposerJson $composerJson) : void { foreach ($this->replacePackagesAndVersions as $replacePackageAndVersion) { $composerJson->replacePackage($replacePackageAndVersion->getOldPackageName(), $replacePackageAndVersion->getNewPackageName(), $replacePackageAndVersion->getVersion()); } } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change package name and version `composer.json`', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change package name and version `composer.json`', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' { "require-dev": { "symfony/console": "^3.4" @@ -50,14 +50,14 @@ CODE_SAMPLE } } CODE_SAMPLE -, [new \Rector\Composer\ValueObject\ReplacePackageAndVersion('symfony/console', 'symfony/http-kernel', '^4.4')])]); +, [new ReplacePackageAndVersion('symfony/console', 'symfony/http-kernel', '^4.4')])]); } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Composer\ValueObject\ReplacePackageAndVersion::class); + Assert::allIsAOf($configuration, ReplacePackageAndVersion::class); $this->versionGuard->validate($configuration); $this->replacePackagesAndVersions = $configuration; } diff --git a/rules/Composer/ValueObject/PackageAndVersion.php b/rules/Composer/ValueObject/PackageAndVersion.php index bedbb644c68..9da3af351d9 100644 --- a/rules/Composer/ValueObject/PackageAndVersion.php +++ b/rules/Composer/ValueObject/PackageAndVersion.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Composer\ValueObject; use Rector\Composer\Contract\VersionAwareInterface; -final class PackageAndVersion implements \Rector\Composer\Contract\VersionAwareInterface +final class PackageAndVersion implements VersionAwareInterface { /** * @readonly diff --git a/rules/Composer/ValueObject/ReplacePackageAndVersion.php b/rules/Composer/ValueObject/ReplacePackageAndVersion.php index 2eacf1268a4..bab86a8c5b0 100644 --- a/rules/Composer/ValueObject/ReplacePackageAndVersion.php +++ b/rules/Composer/ValueObject/ReplacePackageAndVersion.php @@ -6,7 +6,7 @@ namespace Rector\Composer\ValueObject; use Rector\Composer\Contract\VersionAwareInterface; use Rector\Composer\Rector\ChangePackageVersionComposerRector; use RectorPrefix20220607\Webmozart\Assert\Assert; -final class ReplacePackageAndVersion implements \Rector\Composer\Contract\VersionAwareInterface +final class ReplacePackageAndVersion implements VersionAwareInterface { /** * @readonly @@ -26,7 +26,7 @@ final class ReplacePackageAndVersion implements \Rector\Composer\Contract\Versio public function __construct(string $oldPackageName, string $newPackageName, string $version) { $this->version = $version; - \RectorPrefix20220607\Webmozart\Assert\Assert::notSame($oldPackageName, $newPackageName, 'Old and new package have to be different. If you want to only change package version, use ' . \Rector\Composer\Rector\ChangePackageVersionComposerRector::class); + Assert::notSame($oldPackageName, $newPackageName, 'Old and new package have to be different. If you want to only change package version, use ' . ChangePackageVersionComposerRector::class); $this->oldPackageName = $oldPackageName; $this->newPackageName = $newPackageName; } diff --git a/rules/DeadCode/Comparator/CurrentAndParentClassMethodComparator.php b/rules/DeadCode/Comparator/CurrentAndParentClassMethodComparator.php index 7f2d5a138be..83df9630f9c 100644 --- a/rules/DeadCode/Comparator/CurrentAndParentClassMethodComparator.php +++ b/rules/DeadCode/Comparator/CurrentAndParentClassMethodComparator.php @@ -47,7 +47,7 @@ final class CurrentAndParentClassMethodComparator * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\DeadCode\Comparator\Parameter\ParameterDefaultsComparator $parameterDefaultsComparator, \Rector\DeadCode\Comparator\Parameter\ParameterTypeComparator $parameterTypeComparator, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(NodeNameResolver $nodeNameResolver, ParameterDefaultsComparator $parameterDefaultsComparator, ParameterTypeComparator $parameterTypeComparator, NodeComparator $nodeComparator, ReflectionResolver $reflectionResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->parameterDefaultsComparator = $parameterDefaultsComparator; @@ -55,7 +55,7 @@ final class CurrentAndParentClassMethodComparator $this->nodeComparator = $nodeComparator; $this->reflectionResolver = $reflectionResolver; } - public function isParentCallMatching(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Expr\StaticCall $staticCall) : bool + public function isParentCallMatching(ClassMethod $classMethod, StaticCall $staticCall) : bool { if (!$this->isSameMethodParentCall($classMethod, $staticCall)) { return \false; @@ -68,12 +68,12 @@ final class CurrentAndParentClassMethodComparator } return !$this->isParentClassMethodVisibilityOrDefaultOverride($classMethod, $staticCall); } - private function isSameMethodParentCall(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Expr\StaticCall $staticCall) : bool + private function isSameMethodParentCall(ClassMethod $classMethod, StaticCall $staticCall) : bool { if (!$this->nodeNameResolver->areNamesEqual($staticCall->name, $classMethod->name)) { return \false; } - return $this->nodeNameResolver->isName($staticCall->class, \Rector\Core\Enum\ObjectReference::PARENT); + return $this->nodeNameResolver->isName($staticCall->class, ObjectReference::PARENT); } /** * @param Arg[]|VariadicPlaceholder[] $parentStaticCallArgs @@ -91,7 +91,7 @@ final class CurrentAndParentClassMethodComparator if (!isset($currentClassMethodParams[$key])) { return \false; } - if (!$arg instanceof \PhpParser\Node\Arg) { + if (!$arg instanceof Arg) { continue; } // this only compares variable name, but those can be differnt, so its kinda useless @@ -102,10 +102,10 @@ final class CurrentAndParentClassMethodComparator } return \true; } - private function isParentClassMethodVisibilityOrDefaultOverride(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Expr\StaticCall $staticCall) : bool + private function isParentClassMethodVisibilityOrDefaultOverride(ClassMethod $classMethod, StaticCall $staticCall) : bool { $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } $methodName = $this->nodeNameResolver->getName($staticCall->name); @@ -128,11 +128,11 @@ final class CurrentAndParentClassMethodComparator } return \false; } - private function isOverridingParentParameters(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PHPStan\Reflection\ClassReflection $classReflection, string $methodName) : bool + private function isOverridingParentParameters(ClassMethod $classMethod, ClassReflection $classReflection, string $methodName) : bool { - $scope = $classMethod->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $scope = $classMethod->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { + throw new ShouldNotHappenException(); } $parentMethodReflection = $classReflection->getMethod($methodName, $scope); // 3rd party code @@ -145,9 +145,9 @@ final class CurrentAndParentClassMethodComparator } return $this->areParameterDefaultsDifferent($classMethod, $parentMethodReflection); } - private function areParameterDefaultsDifferent(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PHPStan\Reflection\MethodReflection $methodReflection) : bool + private function areParameterDefaultsDifferent(ClassMethod $classMethod, MethodReflection $methodReflection) : bool { - $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); + $parametersAcceptor = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); foreach ($parametersAcceptor->getParameters() as $key => $parameterReflection) { if (!isset($classMethod->params[$key])) { if ($parameterReflection->getDefaultValue() !== null) { diff --git a/rules/DeadCode/Comparator/Parameter/ParameterDefaultsComparator.php b/rules/DeadCode/Comparator/Parameter/ParameterDefaultsComparator.php index ab491746c4e..c0a75c4088e 100644 --- a/rules/DeadCode/Comparator/Parameter/ParameterDefaultsComparator.php +++ b/rules/DeadCode/Comparator/Parameter/ParameterDefaultsComparator.php @@ -20,12 +20,12 @@ final class ParameterDefaultsComparator * @var \Rector\DowngradePhp80\Reflection\DefaultParameterValueResolver */ private $defaultParameterValueResolver; - public function __construct(\Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\DowngradePhp80\Reflection\DefaultParameterValueResolver $defaultParameterValueResolver) + public function __construct(NodeComparator $nodeComparator, DefaultParameterValueResolver $defaultParameterValueResolver) { $this->nodeComparator = $nodeComparator; $this->defaultParameterValueResolver = $defaultParameterValueResolver; } - public function areDefaultValuesDifferent(\PHPStan\Reflection\ParameterReflection $parameterReflection, \PhpParser\Node\Param $param) : bool + public function areDefaultValuesDifferent(ParameterReflection $parameterReflection, Param $param) : bool { if ($parameterReflection->getDefaultValue() === null && $param->default === null) { return \false; @@ -38,7 +38,7 @@ final class ParameterDefaultsComparator $firstParameterValue = $this->defaultParameterValueResolver->resolveFromParameterReflection($parameterReflection); return !$this->nodeComparator->areNodesEqual($paramDefault, $firstParameterValue); } - private function isMutuallyExclusiveNull(\PHPStan\Reflection\ParameterReflection $parameterReflection, \PhpParser\Node\Param $param) : bool + private function isMutuallyExclusiveNull(ParameterReflection $parameterReflection, Param $param) : bool { if ($parameterReflection->getDefaultValue() === null && $param->default !== null) { return \true; diff --git a/rules/DeadCode/Comparator/Parameter/ParameterTypeComparator.php b/rules/DeadCode/Comparator/Parameter/ParameterTypeComparator.php index 6711a365926..b2c395d42e9 100644 --- a/rules/DeadCode/Comparator/Parameter/ParameterTypeComparator.php +++ b/rules/DeadCode/Comparator/Parameter/ParameterTypeComparator.php @@ -13,11 +13,11 @@ final class ParameterTypeComparator * @var \Rector\NodeTypeResolver\MethodParameterTypeResolver */ private $methodParameterTypeResolver; - public function __construct(\Rector\NodeTypeResolver\MethodParameterTypeResolver $methodParameterTypeResolver) + public function __construct(MethodParameterTypeResolver $methodParameterTypeResolver) { $this->methodParameterTypeResolver = $methodParameterTypeResolver; } - public function isClassMethodIdenticalToParentStaticCall(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Expr\StaticCall $staticCall) : bool + public function isClassMethodIdenticalToParentStaticCall(ClassMethod $classMethod, StaticCall $staticCall) : bool { $currentParameterTypes = $this->methodParameterTypeResolver->provideParameterTypesByClassMethod($classMethod); $parentParameterTypes = $this->methodParameterTypeResolver->provideParameterTypesByStaticCall($staticCall); diff --git a/rules/DeadCode/ConditionEvaluator.php b/rules/DeadCode/ConditionEvaluator.php index 3d385a95e9d..53cd3f0c9a8 100644 --- a/rules/DeadCode/ConditionEvaluator.php +++ b/rules/DeadCode/ConditionEvaluator.php @@ -19,19 +19,19 @@ final class ConditionEvaluator * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PhpVersionProvider $phpVersionProvider) { $this->phpVersionProvider = $phpVersionProvider; } /** * @return bool|int|null */ - public function evaluate(\Rector\DeadCode\Contract\ConditionInterface $condition) + public function evaluate(ConditionInterface $condition) { - if ($condition instanceof \Rector\DeadCode\ValueObject\VersionCompareCondition) { + if ($condition instanceof VersionCompareCondition) { return $this->evaluateVersionCompareCondition($condition); } - if ($condition instanceof \Rector\DeadCode\ValueObject\BinaryToVersionCompareCondition) { + if ($condition instanceof BinaryToVersionCompareCondition) { return $this->isEvaluedAsTrue($condition); } return null; @@ -39,7 +39,7 @@ final class ConditionEvaluator /** * @return bool|int|null */ - private function evaluateVersionCompareCondition(\Rector\DeadCode\ValueObject\VersionCompareCondition $versionCompareCondition) + private function evaluateVersionCompareCondition(VersionCompareCondition $versionCompareCondition) { $compareSign = $versionCompareCondition->getCompareSign(); if ($compareSign !== null) { @@ -50,23 +50,23 @@ final class ConditionEvaluator } return \version_compare((string) $versionCompareCondition->getFirstVersion(), (string) $versionCompareCondition->getSecondVersion()); } - private function isEvaluedAsTrue(\Rector\DeadCode\ValueObject\BinaryToVersionCompareCondition $binaryToVersionCompareCondition) : bool + private function isEvaluedAsTrue(BinaryToVersionCompareCondition $binaryToVersionCompareCondition) : bool { $versionCompareResult = $this->evaluateVersionCompareCondition($binaryToVersionCompareCondition->getVersionCompareCondition()); - if ($binaryToVersionCompareCondition->getBinaryClass() === \PhpParser\Node\Expr\BinaryOp\Identical::class) { + if ($binaryToVersionCompareCondition->getBinaryClass() === Identical::class) { return $binaryToVersionCompareCondition->getExpectedValue() === $versionCompareResult; } - if ($binaryToVersionCompareCondition->getBinaryClass() === \PhpParser\Node\Expr\BinaryOp\NotIdentical::class) { + if ($binaryToVersionCompareCondition->getBinaryClass() === NotIdentical::class) { return $binaryToVersionCompareCondition->getExpectedValue() !== $versionCompareResult; } - if ($binaryToVersionCompareCondition->getBinaryClass() === \PhpParser\Node\Expr\BinaryOp\Equal::class) { + if ($binaryToVersionCompareCondition->getBinaryClass() === Equal::class) { // weak comparison on purpose return $binaryToVersionCompareCondition->getExpectedValue() === $versionCompareResult; } - if ($binaryToVersionCompareCondition->getBinaryClass() === \PhpParser\Node\Expr\BinaryOp\NotEqual::class) { + if ($binaryToVersionCompareCondition->getBinaryClass() === NotEqual::class) { // weak comparison on purpose return $binaryToVersionCompareCondition->getExpectedValue() !== $versionCompareResult; } - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } } diff --git a/rules/DeadCode/ConditionResolver.php b/rules/DeadCode/ConditionResolver.php index de0999aeace..aac069fb36f 100644 --- a/rules/DeadCode/ConditionResolver.php +++ b/rules/DeadCode/ConditionResolver.php @@ -39,20 +39,20 @@ final class ConditionResolver * @var \Rector\Core\Util\PhpVersionFactory */ private $phpVersionFactory; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\Core\Util\PhpVersionFactory $phpVersionFactory) + public function __construct(NodeNameResolver $nodeNameResolver, PhpVersionProvider $phpVersionProvider, ValueResolver $valueResolver, PhpVersionFactory $phpVersionFactory) { $this->nodeNameResolver = $nodeNameResolver; $this->phpVersionProvider = $phpVersionProvider; $this->valueResolver = $valueResolver; $this->phpVersionFactory = $phpVersionFactory; } - public function resolveFromExpr(\PhpParser\Node\Expr $expr) : ?\Rector\DeadCode\Contract\ConditionInterface + public function resolveFromExpr(Expr $expr) : ?ConditionInterface { if ($this->isVersionCompareFuncCall($expr)) { /** @var FuncCall $expr */ return $this->resolveVersionCompareConditionForFuncCall($expr); } - if (!$expr instanceof \PhpParser\Node\Expr\BinaryOp\Identical && !$expr instanceof \PhpParser\Node\Expr\BinaryOp\Equal && !$expr instanceof \PhpParser\Node\Expr\BinaryOp\NotIdentical && !$expr instanceof \PhpParser\Node\Expr\BinaryOp\NotEqual) { + if (!$expr instanceof Identical && !$expr instanceof Equal && !$expr instanceof NotIdentical && !$expr instanceof NotEqual) { return null; } $binaryClass = \get_class($expr); @@ -65,22 +65,22 @@ final class ConditionResolver /** @var FuncCall $funcCall */ $funcCall = $expr->right; $versionCompareCondition = $this->resolveVersionCompareConditionForFuncCall($funcCall); - if (!$versionCompareCondition instanceof \Rector\DeadCode\ValueObject\VersionCompareCondition) { + if (!$versionCompareCondition instanceof VersionCompareCondition) { return null; } $expectedValue = $this->valueResolver->getValue($expr->left); - return new \Rector\DeadCode\ValueObject\BinaryToVersionCompareCondition($versionCompareCondition, $binaryClass, $expectedValue); + return new BinaryToVersionCompareCondition($versionCompareCondition, $binaryClass, $expectedValue); } return null; } - private function isVersionCompareFuncCall(\PhpParser\Node\Expr $expr) : bool + private function isVersionCompareFuncCall(Expr $expr) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$expr instanceof FuncCall) { return \false; } return $this->nodeNameResolver->isName($expr, 'version_compare'); } - private function resolveVersionCompareConditionForFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall) : ?\Rector\DeadCode\ValueObject\VersionCompareCondition + private function resolveVersionCompareConditionForFuncCall(FuncCall $funcCall) : ?VersionCompareCondition { $firstVersion = $this->resolveArgumentValue($funcCall, 0); if ($firstVersion === null) { @@ -92,26 +92,26 @@ final class ConditionResolver } // includes compare sign as 3rd argument $versionCompareSign = null; - if (isset($funcCall->args[2]) && $funcCall->args[2] instanceof \PhpParser\Node\Arg) { + if (isset($funcCall->args[2]) && $funcCall->args[2] instanceof Arg) { $versionCompareSign = $this->valueResolver->getValue($funcCall->args[2]->value); } - return new \Rector\DeadCode\ValueObject\VersionCompareCondition($firstVersion, $secondVersion, $versionCompareSign); + return new VersionCompareCondition($firstVersion, $secondVersion, $versionCompareSign); } - private function resolveFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr $expr, string $binaryClass) : ?\Rector\DeadCode\ValueObject\BinaryToVersionCompareCondition + private function resolveFuncCall(FuncCall $funcCall, Expr $expr, string $binaryClass) : ?BinaryToVersionCompareCondition { $versionCompareCondition = $this->resolveVersionCompareConditionForFuncCall($funcCall); - if (!$versionCompareCondition instanceof \Rector\DeadCode\ValueObject\VersionCompareCondition) { + if (!$versionCompareCondition instanceof VersionCompareCondition) { return null; } $expectedValue = $this->valueResolver->getValue($expr); - return new \Rector\DeadCode\ValueObject\BinaryToVersionCompareCondition($versionCompareCondition, $binaryClass, $expectedValue); + return new BinaryToVersionCompareCondition($versionCompareCondition, $binaryClass, $expectedValue); } - private function resolveArgumentValue(\PhpParser\Node\Expr\FuncCall $funcCall, int $argumentPosition) : ?int + private function resolveArgumentValue(FuncCall $funcCall, int $argumentPosition) : ?int { if (!isset($funcCall->args[$argumentPosition])) { return null; } - if (!$funcCall->args[$argumentPosition] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[$argumentPosition] instanceof Arg) { return null; } $firstArgValue = $funcCall->args[$argumentPosition]->value; diff --git a/rules/DeadCode/FeatureSupport/FunctionSupportResolver.php b/rules/DeadCode/FeatureSupport/FunctionSupportResolver.php index 5d981a984da..1d0f19dbd56 100644 --- a/rules/DeadCode/FeatureSupport/FunctionSupportResolver.php +++ b/rules/DeadCode/FeatureSupport/FunctionSupportResolver.php @@ -10,13 +10,13 @@ final class FunctionSupportResolver /** * @var array */ - private const FUNCTIONS_BY_VERSION = [\Rector\Core\ValueObject\PhpVersion::PHP_56 => ['session_abort', 'hash_equals', 'ldap_escape'], \Rector\Core\ValueObject\PhpVersion::PHP_70 => ['random_int', 'random_bytes', 'intdiv', 'preg_replace_callback_array', 'error_clear_last'], \Rector\Core\ValueObject\PhpVersion::PHP_71 => ['is_iterable'], \Rector\Core\ValueObject\PhpVersion::PHP_72 => ['spl_object_id', 'stream_isatty'], \Rector\Core\ValueObject\PhpVersion::PHP_73 => ['array_key_first', 'array_key_last', 'hrtime', 'is_countable'], \Rector\Core\ValueObject\PhpVersion::PHP_74 => ['get_mangled_object_vars', 'mb_str_split', 'password_algos']]; + private const FUNCTIONS_BY_VERSION = [PhpVersion::PHP_56 => ['session_abort', 'hash_equals', 'ldap_escape'], PhpVersion::PHP_70 => ['random_int', 'random_bytes', 'intdiv', 'preg_replace_callback_array', 'error_clear_last'], PhpVersion::PHP_71 => ['is_iterable'], PhpVersion::PHP_72 => ['spl_object_id', 'stream_isatty'], PhpVersion::PHP_73 => ['array_key_first', 'array_key_last', 'hrtime', 'is_countable'], PhpVersion::PHP_74 => ['get_mangled_object_vars', 'mb_str_split', 'password_algos']]; /** * @readonly * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PhpVersionProvider $phpVersionProvider) { $this->phpVersionProvider = $phpVersionProvider; } diff --git a/rules/DeadCode/NodeAnalyzer/CallCollectionAnalyzer.php b/rules/DeadCode/NodeAnalyzer/CallCollectionAnalyzer.php index 467f3cb9229..133c3b74fa7 100644 --- a/rules/DeadCode/NodeAnalyzer/CallCollectionAnalyzer.php +++ b/rules/DeadCode/NodeAnalyzer/CallCollectionAnalyzer.php @@ -21,7 +21,7 @@ final class CallCollectionAnalyzer * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeTypeResolver $nodeTypeResolver, NodeNameResolver $nodeNameResolver) { $this->nodeTypeResolver = $nodeTypeResolver; $this->nodeNameResolver = $nodeNameResolver; @@ -32,15 +32,15 @@ final class CallCollectionAnalyzer public function isExists(array $calls, string $classMethodName, ?string $className) : bool { foreach ($calls as $call) { - $callerRoot = $call instanceof \PhpParser\Node\Expr\StaticCall ? $call->class : $call->var; + $callerRoot = $call instanceof StaticCall ? $call->class : $call->var; $callerType = $this->nodeTypeResolver->getType($callerRoot); - if (!$callerType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$callerType instanceof TypeWithClassName) { continue; } if ($callerType->getClassName() !== $className) { continue; } - if (!$call->name instanceof \PhpParser\Node\Identifier) { + if (!$call->name instanceof Identifier) { return \true; } // the method is used diff --git a/rules/DeadCode/NodeAnalyzer/ExprUsedInNextNodeAnalyzer.php b/rules/DeadCode/NodeAnalyzer/ExprUsedInNextNodeAnalyzer.php index 585d00fb8b7..08817eb9fe1 100644 --- a/rules/DeadCode/NodeAnalyzer/ExprUsedInNextNodeAnalyzer.php +++ b/rules/DeadCode/NodeAnalyzer/ExprUsedInNextNodeAnalyzer.php @@ -18,14 +18,14 @@ final class ExprUsedInNextNodeAnalyzer * @var \Rector\DeadCode\NodeAnalyzer\ExprUsedInNodeAnalyzer */ private $exprUsedInNodeAnalyzer; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\DeadCode\NodeAnalyzer\ExprUsedInNodeAnalyzer $exprUsedInNodeAnalyzer) + public function __construct(BetterNodeFinder $betterNodeFinder, \Rector\DeadCode\NodeAnalyzer\ExprUsedInNodeAnalyzer $exprUsedInNodeAnalyzer) { $this->betterNodeFinder = $betterNodeFinder; $this->exprUsedInNodeAnalyzer = $exprUsedInNodeAnalyzer; } - public function isUsed(\PhpParser\Node\Expr $expr) : bool + public function isUsed(Expr $expr) : bool { - return (bool) $this->betterNodeFinder->findFirstNext($expr, function (\PhpParser\Node $node) use($expr) : bool { + return (bool) $this->betterNodeFinder->findFirstNext($expr, function (Node $node) use($expr) : bool { return $this->exprUsedInNodeAnalyzer->isUsed($node, $expr); }); } diff --git a/rules/DeadCode/NodeAnalyzer/ExprUsedInNodeAnalyzer.php b/rules/DeadCode/NodeAnalyzer/ExprUsedInNodeAnalyzer.php index ab984e57f77..2bc1439ad8c 100644 --- a/rules/DeadCode/NodeAnalyzer/ExprUsedInNodeAnalyzer.php +++ b/rules/DeadCode/NodeAnalyzer/ExprUsedInNodeAnalyzer.php @@ -33,29 +33,29 @@ final class ExprUsedInNodeAnalyzer * @var \Rector\Core\Contract\PhpParser\NodePrinterInterface */ private $nodePrinter; - public function __construct(\Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\DeadCode\NodeAnalyzer\UsedVariableNameAnalyzer $usedVariableNameAnalyzer, \Rector\Core\NodeAnalyzer\CompactFuncCallAnalyzer $compactFuncCallAnalyzer, \Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter) + public function __construct(NodeComparator $nodeComparator, \Rector\DeadCode\NodeAnalyzer\UsedVariableNameAnalyzer $usedVariableNameAnalyzer, CompactFuncCallAnalyzer $compactFuncCallAnalyzer, NodePrinterInterface $nodePrinter) { $this->nodeComparator = $nodeComparator; $this->usedVariableNameAnalyzer = $usedVariableNameAnalyzer; $this->compactFuncCallAnalyzer = $compactFuncCallAnalyzer; $this->nodePrinter = $nodePrinter; } - public function isUsed(\PhpParser\Node $node, \PhpParser\Node\Expr $expr) : bool + public function isUsed(Node $node, Expr $expr) : bool { - if ($node instanceof \PhpParser\Node\Expr\Include_) { + if ($node instanceof Include_) { return \true; } // variable as variable variable need mark as used - if ($node instanceof \PhpParser\Node\Expr\Variable && $expr instanceof \PhpParser\Node\Expr\Variable) { + if ($node instanceof Variable && $expr instanceof Variable) { $print = $this->nodePrinter->print($node); if (\strncmp($print, '${$', \strlen('${$')) === 0) { return \true; } } - if ($node instanceof \PhpParser\Node\Expr\FuncCall && $expr instanceof \PhpParser\Node\Expr\Variable) { + if ($node instanceof FuncCall && $expr instanceof Variable) { return $this->compactFuncCallAnalyzer->isInCompact($node, $expr); } - if ($expr instanceof \PhpParser\Node\Expr\Variable) { + if ($expr instanceof Variable) { return $this->usedVariableNameAnalyzer->isVariableNamed($node, $expr); } return $this->nodeComparator->areNodesEqual($node, $expr); diff --git a/rules/DeadCode/NodeAnalyzer/InstanceOfUniqueKeyResolver.php b/rules/DeadCode/NodeAnalyzer/InstanceOfUniqueKeyResolver.php index 94aba7bd4d6..80d7f42f4da 100644 --- a/rules/DeadCode/NodeAnalyzer/InstanceOfUniqueKeyResolver.php +++ b/rules/DeadCode/NodeAnalyzer/InstanceOfUniqueKeyResolver.php @@ -13,13 +13,13 @@ final class InstanceOfUniqueKeyResolver * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } - public function resolve(\PhpParser\Node\Expr\Instanceof_ $instanceof) : ?string + public function resolve(Instanceof_ $instanceof) : ?string { - if (!$instanceof->expr instanceof \PhpParser\Node\Expr\Variable) { + if (!$instanceof->expr instanceof Variable) { return null; } $variableName = $this->nodeNameResolver->getName($instanceof->expr); diff --git a/rules/DeadCode/NodeAnalyzer/IsClassMethodUsedAnalyzer.php b/rules/DeadCode/NodeAnalyzer/IsClassMethodUsedAnalyzer.php index 947693940b7..58a98d12751 100644 --- a/rules/DeadCode/NodeAnalyzer/IsClassMethodUsedAnalyzer.php +++ b/rules/DeadCode/NodeAnalyzer/IsClassMethodUsedAnalyzer.php @@ -56,7 +56,7 @@ final class IsClassMethodUsedAnalyzer * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\AstResolver $astResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\NodeCollector\NodeAnalyzer\ArrayCallableMethodMatcher $arrayCallableMethodMatcher, \Rector\DeadCode\NodeAnalyzer\CallCollectionAnalyzer $callCollectionAnalyzer, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(NodeNameResolver $nodeNameResolver, AstResolver $astResolver, BetterNodeFinder $betterNodeFinder, ValueResolver $valueResolver, ArrayCallableMethodMatcher $arrayCallableMethodMatcher, \Rector\DeadCode\NodeAnalyzer\CallCollectionAnalyzer $callCollectionAnalyzer, ReflectionResolver $reflectionResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->astResolver = $astResolver; @@ -66,10 +66,10 @@ final class IsClassMethodUsedAnalyzer $this->callCollectionAnalyzer = $callCollectionAnalyzer; $this->reflectionResolver = $reflectionResolver; } - public function isClassMethodUsed(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + public function isClassMethodUsed(ClassMethod $classMethod) : bool { - $class = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($classMethod, Class_::class); + if (!$class instanceof Class_) { return \true; } $classMethodName = $this->nodeNameResolver->getName($classMethod); @@ -88,24 +88,24 @@ final class IsClassMethodUsedAnalyzer // 4. private method exists in trait and is overwritten by the class return $this->doesMethodExistInTrait($classMethod, $classMethodName); } - private function isClassMethodUsedInLocalStaticCall(\PhpParser\Node\Stmt\Class_ $class, string $classMethodName) : bool + private function isClassMethodUsedInLocalStaticCall(Class_ $class, string $classMethodName) : bool { $className = (string) $this->nodeNameResolver->getName($class); /** @var StaticCall[] $staticCalls */ - $staticCalls = $this->betterNodeFinder->findInstanceOf($class, \PhpParser\Node\Expr\StaticCall::class); + $staticCalls = $this->betterNodeFinder->findInstanceOf($class, StaticCall::class); return $this->callCollectionAnalyzer->isExists($staticCalls, $classMethodName, $className); } - private function isClassMethodCalledInLocalMethodCall(\PhpParser\Node\Stmt\Class_ $class, string $classMethodName) : bool + private function isClassMethodCalledInLocalMethodCall(Class_ $class, string $classMethodName) : bool { $className = (string) $this->nodeNameResolver->getName($class); /** @var MethodCall[] $methodCalls */ - $methodCalls = $this->betterNodeFinder->findInstanceOf($class, \PhpParser\Node\Expr\MethodCall::class); + $methodCalls = $this->betterNodeFinder->findInstanceOf($class, MethodCall::class); return $this->callCollectionAnalyzer->isExists($methodCalls, $classMethodName, $className); } - private function isInArrayMap(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Expr\Array_ $array) : bool + private function isInArrayMap(Class_ $class, Array_ $array) : bool { - $parentFuncCall = $this->betterNodeFinder->findParentType($array, \PhpParser\Node\Expr\FuncCall::class); - if (!$parentFuncCall instanceof \PhpParser\Node\Expr\FuncCall) { + $parentFuncCall = $this->betterNodeFinder->findParentType($array, FuncCall::class); + if (!$parentFuncCall instanceof FuncCall) { return \false; } if (!$this->nodeNameResolver->isName($parentFuncCall->name, 'array_map')) { @@ -114,25 +114,25 @@ final class IsClassMethodUsedAnalyzer if (\count($array->items) !== 2) { return \false; } - if (!$array->items[1] instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$array->items[1] instanceof ArrayItem) { return \false; } $value = $this->valueResolver->getValue($array->items[1]->value); if (!\is_string($value)) { return \false; } - return $class->getMethod($value) instanceof \PhpParser\Node\Stmt\ClassMethod; + return $class->getMethod($value) instanceof ClassMethod; } - private function isClassMethodCalledInLocalArrayCall(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function isClassMethodCalledInLocalArrayCall(Class_ $class, ClassMethod $classMethod) : bool { /** @var Array_[] $arrays */ - $arrays = $this->betterNodeFinder->findInstanceOf($class, \PhpParser\Node\Expr\Array_::class); + $arrays = $this->betterNodeFinder->findInstanceOf($class, Array_::class); foreach ($arrays as $array) { if ($this->isInArrayMap($class, $array)) { return \true; } $arrayCallable = $this->arrayCallableMethodMatcher->match($array); - if ($arrayCallable instanceof \Rector\NodeCollector\ValueObject\ArrayCallableDynamicMethod) { + if ($arrayCallable instanceof ArrayCallableDynamicMethod) { return \true; } if ($this->shouldSkipArrayCallable($class, $arrayCallable)) { @@ -149,24 +149,24 @@ final class IsClassMethodUsedAnalyzer /** * @param null|\Rector\NodeCollector\ValueObject\ArrayCallable $arrayCallable */ - private function shouldSkipArrayCallable(\PhpParser\Node\Stmt\Class_ $class, $arrayCallable) : bool + private function shouldSkipArrayCallable(Class_ $class, $arrayCallable) : bool { - if (!$arrayCallable instanceof \Rector\NodeCollector\ValueObject\ArrayCallable) { + if (!$arrayCallable instanceof ArrayCallable) { return \true; } // is current class method? return !$this->nodeNameResolver->isName($class, $arrayCallable->getClass()); } - private function doesMethodExistInTrait(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $classMethodName) : bool + private function doesMethodExistInTrait(ClassMethod $classMethod, string $classMethodName) : bool { $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } $traits = $this->astResolver->parseClassReflectionTraits($classReflection); foreach ($traits as $trait) { $method = $trait->getMethod($classMethodName); - if (!$method instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$method instanceof ClassMethod) { continue; } return \true; diff --git a/rules/DeadCode/NodeAnalyzer/JustPropertyFetchVariableAssignMatcher.php b/rules/DeadCode/NodeAnalyzer/JustPropertyFetchVariableAssignMatcher.php index 21eafb790f1..45b613d57b0 100644 --- a/rules/DeadCode/NodeAnalyzer/JustPropertyFetchVariableAssignMatcher.php +++ b/rules/DeadCode/NodeAnalyzer/JustPropertyFetchVariableAssignMatcher.php @@ -18,11 +18,11 @@ final class JustPropertyFetchVariableAssignMatcher * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(NodeComparator $nodeComparator) { $this->nodeComparator = $nodeComparator; } - public function match(\Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface $stmtsAware) : ?\Rector\DeadCode\ValueObject\VariableAndPropertyFetchAssign + public function match(StmtsAwareInterface $stmtsAware) : ?VariableAndPropertyFetchAssign { $stmts = (array) $stmtsAware->stmts; $stmtCount = \count($stmts); @@ -31,11 +31,11 @@ final class JustPropertyFetchVariableAssignMatcher return null; } $firstVariableAndPropertyFetchAssign = $this->matchVariableAndPropertyFetchAssign($stmts[0]); - if (!$firstVariableAndPropertyFetchAssign instanceof \Rector\DeadCode\ValueObject\VariableAndPropertyFetchAssign) { + if (!$firstVariableAndPropertyFetchAssign instanceof VariableAndPropertyFetchAssign) { return null; } $thirdVariableAndPropertyFetchAssign = $this->matchRevertedVariableAndPropertyFetchAssign($stmts[2]); - if (!$thirdVariableAndPropertyFetchAssign instanceof \Rector\DeadCode\ValueObject\VariableAndPropertyFetchAssign) { + if (!$thirdVariableAndPropertyFetchAssign instanceof VariableAndPropertyFetchAssign) { return null; } // property fetch are the same @@ -48,38 +48,38 @@ final class JustPropertyFetchVariableAssignMatcher } return $firstVariableAndPropertyFetchAssign; } - private function matchVariableAndPropertyFetchAssign(\PhpParser\Node\Stmt $stmt) : ?\Rector\DeadCode\ValueObject\VariableAndPropertyFetchAssign + private function matchVariableAndPropertyFetchAssign(Stmt $stmt) : ?VariableAndPropertyFetchAssign { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { return null; } - if (!$stmt->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$stmt->expr instanceof Assign) { return null; } $assign = $stmt->expr; - if (!$assign->expr instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$assign->expr instanceof PropertyFetch) { return null; } - if (!$assign->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$assign->var instanceof Variable) { return null; } - return new \Rector\DeadCode\ValueObject\VariableAndPropertyFetchAssign($assign->var, $assign->expr); + return new VariableAndPropertyFetchAssign($assign->var, $assign->expr); } - private function matchRevertedVariableAndPropertyFetchAssign(\PhpParser\Node\Stmt $stmt) : ?\Rector\DeadCode\ValueObject\VariableAndPropertyFetchAssign + private function matchRevertedVariableAndPropertyFetchAssign(Stmt $stmt) : ?VariableAndPropertyFetchAssign { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { return null; } - if (!$stmt->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$stmt->expr instanceof Assign) { return null; } $assign = $stmt->expr; - if (!$assign->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$assign->var instanceof PropertyFetch) { return null; } - if (!$assign->expr instanceof \PhpParser\Node\Expr\Variable) { + if (!$assign->expr instanceof Variable) { return null; } - return new \Rector\DeadCode\ValueObject\VariableAndPropertyFetchAssign($assign->expr, $assign->var); + return new VariableAndPropertyFetchAssign($assign->expr, $assign->var); } } diff --git a/rules/DeadCode/NodeAnalyzer/UsedVariableNameAnalyzer.php b/rules/DeadCode/NodeAnalyzer/UsedVariableNameAnalyzer.php index 512c12a6578..03b93495362 100644 --- a/rules/DeadCode/NodeAnalyzer/UsedVariableNameAnalyzer.php +++ b/rules/DeadCode/NodeAnalyzer/UsedVariableNameAnalyzer.php @@ -15,16 +15,16 @@ final class UsedVariableNameAnalyzer * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } - public function isVariableNamed(\PhpParser\Node $node, \PhpParser\Node\Expr\Variable $variable) : bool + public function isVariableNamed(Node $node, Variable $variable) : bool { - if (($node instanceof \PhpParser\Node\Expr\MethodCall || $node instanceof \PhpParser\Node\Expr\PropertyFetch) && ($node->name instanceof \PhpParser\Node\Expr\Variable && \is_string($node->name->name))) { + if (($node instanceof MethodCall || $node instanceof PropertyFetch) && ($node->name instanceof Variable && \is_string($node->name->name))) { return $this->nodeNameResolver->isName($variable, $node->name->name); } - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + if (!$node instanceof Variable) { return \false; } return $this->nodeNameResolver->areNamesEqual($variable, $node); diff --git a/rules/DeadCode/NodeCollector/ModifiedVariableNamesCollector.php b/rules/DeadCode/NodeCollector/ModifiedVariableNamesCollector.php index 4558f5f8e99..51db4a32487 100644 --- a/rules/DeadCode/NodeCollector/ModifiedVariableNamesCollector.php +++ b/rules/DeadCode/NodeCollector/ModifiedVariableNamesCollector.php @@ -24,7 +24,7 @@ final class ModifiedVariableNamesCollector * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->nodeNameResolver = $nodeNameResolver; @@ -32,7 +32,7 @@ final class ModifiedVariableNamesCollector /** * @return string[] */ - public function collectModifiedVariableNames(\PhpParser\Node\Stmt $stmt) : array + public function collectModifiedVariableNames(Stmt $stmt) : array { $argNames = $this->collectFromArgs($stmt); $assignNames = $this->collectFromAssigns($stmt); @@ -41,11 +41,11 @@ final class ModifiedVariableNamesCollector /** * @return string[] */ - private function collectFromArgs(\PhpParser\Node\Stmt $stmt) : array + private function collectFromArgs(Stmt $stmt) : array { $variableNames = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmt, function (\PhpParser\Node $node) use(&$variableNames) { - if (!$node instanceof \PhpParser\Node\Arg) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmt, function (Node $node) use(&$variableNames) { + if (!$node instanceof Arg) { return null; } if (!$this->isVariableChangedInReference($node)) { @@ -62,14 +62,14 @@ final class ModifiedVariableNamesCollector /** * @return string[] */ - private function collectFromAssigns(\PhpParser\Node\Stmt $stmt) : array + private function collectFromAssigns(Stmt $stmt) : array { $modifiedVariableNames = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmt, function (\PhpParser\Node $node) use(&$modifiedVariableNames) { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmt, function (Node $node) use(&$modifiedVariableNames) { + if (!$node instanceof Assign) { return null; } - if (!$node->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$node->var instanceof Variable) { return null; } $variableName = $this->nodeNameResolver->getName($node->var); @@ -80,10 +80,10 @@ final class ModifiedVariableNamesCollector }); return $modifiedVariableNames; } - private function isVariableChangedInReference(\PhpParser\Node\Arg $arg) : bool + private function isVariableChangedInReference(Arg $arg) : bool { - $parentNode = $arg->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node\Expr\FuncCall) { + $parentNode = $arg->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof FuncCall) { return \false; } return $this->nodeNameResolver->isNames($parentNode, ['array_shift', 'array_pop']); diff --git a/rules/DeadCode/NodeCollector/NodeByTypeAndPositionCollector.php b/rules/DeadCode/NodeCollector/NodeByTypeAndPositionCollector.php index 60676655489..a9745f57f39 100644 --- a/rules/DeadCode/NodeCollector/NodeByTypeAndPositionCollector.php +++ b/rules/DeadCode/NodeCollector/NodeByTypeAndPositionCollector.php @@ -22,7 +22,7 @@ final class NodeByTypeAndPositionCollector * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNestingScope\FlowOfControlLocator $flowOfControlLocator, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(FlowOfControlLocator $flowOfControlLocator, NodeNameResolver $nodeNameResolver) { $this->flowOfControlLocator = $flowOfControlLocator; $this->nodeNameResolver = $nodeNameResolver; @@ -32,7 +32,7 @@ final class NodeByTypeAndPositionCollector * @param Variable[] $assignedVariablesUse * @return VariableNodeUse[] */ - public function collectNodesByTypeAndPosition(array $assignedVariables, array $assignedVariablesUse, \PhpParser\Node\FunctionLike $functionLike) : array + public function collectNodesByTypeAndPosition(array $assignedVariables, array $assignedVariablesUse, FunctionLike $functionLike) : array { $nodesByTypeAndPosition = []; foreach ($assignedVariables as $assignedVariable) { @@ -44,11 +44,11 @@ final class NodeByTypeAndPositionCollector // not in different scope, than previous one - e.g. if/while/else... // get nesting level to $classMethodNode /** @var Assign $assign */ - $assign = $assignedVariable->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $assign = $assignedVariable->getAttribute(AttributeKey::PARENT_NODE); $nestingHash = $this->flowOfControlLocator->resolveNestingHashFromFunctionLike($functionLike, $assign); /** @var string $variableName */ $variableName = $this->nodeNameResolver->getName($assignedVariable); - $nodesByTypeAndPosition[] = new \Rector\DeadCode\ValueObject\VariableNodeUse($startTokenPos, $variableName, \Rector\DeadCode\ValueObject\VariableNodeUse::TYPE_ASSIGN, $assignedVariable, $nestingHash); + $nodesByTypeAndPosition[] = new VariableNodeUse($startTokenPos, $variableName, VariableNodeUse::TYPE_ASSIGN, $assignedVariable, $nestingHash); } foreach ($assignedVariablesUse as $assignedVariableUse) { $startTokenPos = $assignedVariableUse->getStartTokenPos(); @@ -58,7 +58,7 @@ final class NodeByTypeAndPositionCollector } /** @var string $variableName */ $variableName = $this->nodeNameResolver->getName($assignedVariableUse); - $nodesByTypeAndPosition[] = new \Rector\DeadCode\ValueObject\VariableNodeUse($startTokenPos, $variableName, \Rector\DeadCode\ValueObject\VariableNodeUse::TYPE_USE, $assignedVariableUse); + $nodesByTypeAndPosition[] = new VariableNodeUse($startTokenPos, $variableName, VariableNodeUse::TYPE_USE, $assignedVariableUse); } return $this->sortByStart($nodesByTypeAndPosition); } @@ -68,7 +68,7 @@ final class NodeByTypeAndPositionCollector */ private function sortByStart(array $nodesByTypeAndPosition) : array { - \usort($nodesByTypeAndPosition, function (\Rector\DeadCode\ValueObject\VariableNodeUse $firstVariableNodeUse, \Rector\DeadCode\ValueObject\VariableNodeUse $secondVariableNodeUse) : int { + \usort($nodesByTypeAndPosition, function (VariableNodeUse $firstVariableNodeUse, VariableNodeUse $secondVariableNodeUse) : int { return $firstVariableNodeUse->getStartTokenPosition() <=> $secondVariableNodeUse->getStartTokenPosition(); }); return $nodesByTypeAndPosition; diff --git a/rules/DeadCode/NodeCollector/UnusedParameterResolver.php b/rules/DeadCode/NodeCollector/UnusedParameterResolver.php index 4d788eca5c7..252828b7ab2 100644 --- a/rules/DeadCode/NodeCollector/UnusedParameterResolver.php +++ b/rules/DeadCode/NodeCollector/UnusedParameterResolver.php @@ -13,14 +13,14 @@ final class UnusedParameterResolver * @var \Rector\Core\NodeAnalyzer\ParamAnalyzer */ private $paramAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ParamAnalyzer $paramAnalyzer) + public function __construct(ParamAnalyzer $paramAnalyzer) { $this->paramAnalyzer = $paramAnalyzer; } /** * @return Param[] */ - public function resolve(\PhpParser\Node\Stmt\ClassMethod $classMethod) : array + public function resolve(ClassMethod $classMethod) : array { /** @var array $unusedParameters */ $unusedParameters = []; diff --git a/rules/DeadCode/NodeFinder/VariableUseFinder.php b/rules/DeadCode/NodeFinder/VariableUseFinder.php index 54eb7ab846a..5d15bedefe7 100644 --- a/rules/DeadCode/NodeFinder/VariableUseFinder.php +++ b/rules/DeadCode/NodeFinder/VariableUseFinder.php @@ -27,7 +27,7 @@ final class VariableUseFinder * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver, NodeComparator $nodeComparator) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeNameResolver = $nodeNameResolver; @@ -37,15 +37,15 @@ final class VariableUseFinder * @param Variable[] $assignedVariables * @return Variable[] */ - public function resolveUsedVariables(\PhpParser\Node $node, array $assignedVariables) : array + public function resolveUsedVariables(Node $node, array $assignedVariables) : array { - return $this->betterNodeFinder->find($node, function (\PhpParser\Node $node) use($assignedVariables) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + return $this->betterNodeFinder->find($node, function (Node $node) use($assignedVariables) : bool { + if (!$node instanceof Variable) { return \false; } - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); // is the left assign - not use of one - if ($parentNode instanceof \PhpParser\Node\Expr\Assign && ($parentNode->var instanceof \PhpParser\Node\Expr\Variable && $parentNode->var === $node)) { + if ($parentNode instanceof Assign && ($parentNode->var instanceof Variable && $parentNode->var === $node)) { return \false; } $nodeNameResolverGetName = $this->nodeNameResolver->getName($node); diff --git a/rules/DeadCode/NodeManipulator/ControllerClassMethodManipulator.php b/rules/DeadCode/NodeManipulator/ControllerClassMethodManipulator.php index 1770537c95a..908ecab5d0b 100644 --- a/rules/DeadCode/NodeManipulator/ControllerClassMethodManipulator.php +++ b/rules/DeadCode/NodeManipulator/ControllerClassMethodManipulator.php @@ -26,32 +26,32 @@ final class ControllerClassMethodManipulator * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeNameResolver $nodeNameResolver, PhpDocInfoFactory $phpDocInfoFactory, BetterNodeFinder $betterNodeFinder) { $this->nodeNameResolver = $nodeNameResolver; $this->phpDocInfoFactory = $phpDocInfoFactory; $this->betterNodeFinder = $betterNodeFinder; } - public function isControllerClassMethodWithBehaviorAnnotation(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + public function isControllerClassMethodWithBehaviorAnnotation(ClassMethod $classMethod) : bool { if (!$this->isControllerClassMethod($classMethod)) { return \false; } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); - return $phpDocInfo->hasByType(\PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode::class); + return $phpDocInfo->hasByType(GenericTagValueNode::class); } - private function isControllerClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function isControllerClassMethod(ClassMethod $classMethod) : bool { if (!$classMethod->isPublic()) { return \false; } - $class = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($classMethod, Class_::class); + if (!$class instanceof Class_) { return \false; } return $this->hasParentClassController($class); } - private function hasParentClassController(\PhpParser\Node\Stmt\Class_ $class) : bool + private function hasParentClassController(Class_ $class) : bool { if ($class->extends === null) { return \false; diff --git a/rules/DeadCode/NodeManipulator/CountManipulator.php b/rules/DeadCode/NodeManipulator/CountManipulator.php index fa61c795ef2..b92a195f1a3 100644 --- a/rules/DeadCode/NodeManipulator/CountManipulator.php +++ b/rules/DeadCode/NodeManipulator/CountManipulator.php @@ -26,69 +26,69 @@ final class CountManipulator * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(NodeNameResolver $nodeNameResolver, NodeComparator $nodeComparator) { $this->nodeNameResolver = $nodeNameResolver; $this->nodeComparator = $nodeComparator; } - public function isCounterHigherThanOne(\PhpParser\Node $node, \PhpParser\Node\Expr $expr) : bool + public function isCounterHigherThanOne(Node $node, Expr $expr) : bool { // e.g. count($values) > 0 - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\Greater) { + if ($node instanceof Greater) { return $this->isGreater($node, $expr); } // e.g. count($values) >= 1 - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\GreaterOrEqual) { + if ($node instanceof GreaterOrEqual) { return $this->isGreaterOrEqual($node, $expr); } // e.g. 0 < count($values) - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\Smaller) { + if ($node instanceof Smaller) { return $this->isSmaller($node, $expr); } // e.g. 1 <= count($values) - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\SmallerOrEqual) { + if ($node instanceof SmallerOrEqual) { return $this->isSmallerOrEqual($node, $expr); } return \false; } - private function isGreater(\PhpParser\Node\Expr\BinaryOp\Greater $greater, \PhpParser\Node\Expr $expr) : bool + private function isGreater(Greater $greater, Expr $expr) : bool { if (!$this->isNumber($greater->right, 0)) { return \false; } return $this->isCountWithExpression($greater->left, $expr); } - private function isGreaterOrEqual(\PhpParser\Node\Expr\BinaryOp\GreaterOrEqual $greaterOrEqual, \PhpParser\Node\Expr $expr) : bool + private function isGreaterOrEqual(GreaterOrEqual $greaterOrEqual, Expr $expr) : bool { if (!$this->isNumber($greaterOrEqual->right, 1)) { return \false; } return $this->isCountWithExpression($greaterOrEqual->left, $expr); } - private function isSmaller(\PhpParser\Node\Expr\BinaryOp\Smaller $smaller, \PhpParser\Node\Expr $expr) : bool + private function isSmaller(Smaller $smaller, Expr $expr) : bool { if (!$this->isNumber($smaller->left, 0)) { return \false; } return $this->isCountWithExpression($smaller->right, $expr); } - private function isSmallerOrEqual(\PhpParser\Node\Expr\BinaryOp\SmallerOrEqual $smallerOrEqual, \PhpParser\Node\Expr $expr) : bool + private function isSmallerOrEqual(SmallerOrEqual $smallerOrEqual, Expr $expr) : bool { if (!$this->isNumber($smallerOrEqual->left, 1)) { return \false; } return $this->isCountWithExpression($smallerOrEqual->right, $expr); } - private function isNumber(\PhpParser\Node\Expr $expr, int $value) : bool + private function isNumber(Expr $expr, int $value) : bool { - if (!$expr instanceof \PhpParser\Node\Scalar\LNumber) { + if (!$expr instanceof LNumber) { return \false; } return $expr->value === $value; } - private function isCountWithExpression(\PhpParser\Node\Expr $node, \PhpParser\Node\Expr $expr) : bool + private function isCountWithExpression(Expr $node, Expr $expr) : bool { - if (!$node instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$node instanceof FuncCall) { return \false; } if (!$this->nodeNameResolver->isName($node, 'count')) { @@ -97,7 +97,7 @@ final class CountManipulator if (!isset($node->args[0])) { return \false; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return \false; } $countedExpr = $node->args[0]->value; diff --git a/rules/DeadCode/NodeManipulator/LivingCodeManipulator.php b/rules/DeadCode/NodeManipulator/LivingCodeManipulator.php index 96149c1a107..4cbba9db6d5 100644 --- a/rules/DeadCode/NodeManipulator/LivingCodeManipulator.php +++ b/rules/DeadCode/NodeManipulator/LivingCodeManipulator.php @@ -37,7 +37,7 @@ final class LivingCodeManipulator * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(NodeTypeResolver $nodeTypeResolver) { $this->nodeTypeResolver = $nodeTypeResolver; } @@ -47,32 +47,32 @@ final class LivingCodeManipulator */ public function keepLivingCodeFromExpr($expr) : array { - if (!$expr instanceof \PhpParser\Node\Expr) { + if (!$expr instanceof Expr) { return []; } - if ($expr instanceof \PhpParser\Node\Expr\Closure || $expr instanceof \PhpParser\Node\Scalar || $expr instanceof \PhpParser\Node\Expr\ConstFetch) { + if ($expr instanceof Closure || $expr instanceof Scalar || $expr instanceof ConstFetch) { return []; } if ($this->isNestedExpr($expr)) { return $this->keepLivingCodeFromExpr($expr->expr); } - if ($expr instanceof \PhpParser\Node\Expr\Variable) { + if ($expr instanceof Variable) { return $this->keepLivingCodeFromExpr($expr->name); } - if ($expr instanceof \PhpParser\Node\Expr\PropertyFetch) { + if ($expr instanceof PropertyFetch) { return \array_merge($this->keepLivingCodeFromExpr($expr->var), $this->keepLivingCodeFromExpr($expr->name)); } - if ($expr instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if ($expr instanceof ArrayDimFetch) { $type = $this->nodeTypeResolver->getType($expr->var); - if ($type instanceof \PHPStan\Type\ObjectType) { - $objectType = new \PHPStan\Type\ObjectType('ArrayAccess'); + if ($type instanceof ObjectType) { + $objectType = new ObjectType('ArrayAccess'); if ($objectType->isSuperTypeOf($type)->yes()) { return [$expr]; } } return \array_merge($this->keepLivingCodeFromExpr($expr->var), $this->keepLivingCodeFromExpr($expr->dim)); } - if ($expr instanceof \PhpParser\Node\Expr\ClassConstFetch || $expr instanceof \PhpParser\Node\Expr\StaticPropertyFetch) { + if ($expr instanceof ClassConstFetch || $expr instanceof StaticPropertyFetch) { return \array_merge($this->keepLivingCodeFromExpr($expr->class), $this->keepLivingCodeFromExpr($expr->name)); } if ($this->isBinaryOpWithoutChange($expr)) { @@ -80,36 +80,36 @@ final class LivingCodeManipulator $binaryOp = $expr; return $this->processBinary($binaryOp); } - if ($expr instanceof \PhpParser\Node\Expr\Instanceof_) { + if ($expr instanceof Instanceof_) { return \array_merge($this->keepLivingCodeFromExpr($expr->expr), $this->keepLivingCodeFromExpr($expr->class)); } - if ($expr instanceof \PhpParser\Node\Expr\Isset_) { + if ($expr instanceof Isset_) { return $this->processIsset($expr); } return [$expr]; } - private function isNestedExpr(\PhpParser\Node\Expr $expr) : bool + private function isNestedExpr(Expr $expr) : bool { - return $expr instanceof \PhpParser\Node\Expr\Cast || $expr instanceof \PhpParser\Node\Expr\Empty_ || $expr instanceof \PhpParser\Node\Expr\UnaryMinus || $expr instanceof \PhpParser\Node\Expr\UnaryPlus || $expr instanceof \PhpParser\Node\Expr\BitwiseNot || $expr instanceof \PhpParser\Node\Expr\BooleanNot || $expr instanceof \PhpParser\Node\Expr\Clone_; + return $expr instanceof Cast || $expr instanceof Empty_ || $expr instanceof UnaryMinus || $expr instanceof UnaryPlus || $expr instanceof BitwiseNot || $expr instanceof BooleanNot || $expr instanceof Clone_; } - private function isBinaryOpWithoutChange(\PhpParser\Node\Expr $expr) : bool + private function isBinaryOpWithoutChange(Expr $expr) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\BinaryOp) { + if (!$expr instanceof BinaryOp) { return \false; } - return !($expr instanceof \PhpParser\Node\Expr\BinaryOp\LogicalAnd || $expr instanceof \PhpParser\Node\Expr\BinaryOp\BooleanAnd || $expr instanceof \PhpParser\Node\Expr\BinaryOp\LogicalOr || $expr instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr || $expr instanceof \PhpParser\Node\Expr\BinaryOp\Coalesce); + return !($expr instanceof LogicalAnd || $expr instanceof BooleanAnd || $expr instanceof LogicalOr || $expr instanceof BooleanOr || $expr instanceof Coalesce); } /** * @return Expr[] */ - private function processBinary(\PhpParser\Node\Expr\BinaryOp $binaryOp) : array + private function processBinary(BinaryOp $binaryOp) : array { return \array_merge($this->keepLivingCodeFromExpr($binaryOp->left), $this->keepLivingCodeFromExpr($binaryOp->right)); } /** * @return mixed[] */ - private function processIsset(\PhpParser\Node\Expr\Isset_ $isset) : array + private function processIsset(Isset_ $isset) : array { $livingExprs = []; foreach ($isset->vars as $expr) { diff --git a/rules/DeadCode/NodeManipulator/VariadicFunctionLikeDetector.php b/rules/DeadCode/NodeManipulator/VariadicFunctionLikeDetector.php index 904fbd3a39d..3ae1b1b7b5b 100644 --- a/rules/DeadCode/NodeManipulator/VariadicFunctionLikeDetector.php +++ b/rules/DeadCode/NodeManipulator/VariadicFunctionLikeDetector.php @@ -25,23 +25,23 @@ final class VariadicFunctionLikeDetector * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->nodeNameResolver = $nodeNameResolver; } - public function isVariadic(\PhpParser\Node\FunctionLike $functionLike) : bool + public function isVariadic(FunctionLike $functionLike) : bool { $isVariadic = \false; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $functionLike->getStmts(), function (\PhpParser\Node $node) use(&$isVariadic) : ?int { - if (!$node instanceof \PhpParser\Node\Expr\FuncCall) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $functionLike->getStmts(), function (Node $node) use(&$isVariadic) : ?int { + if (!$node instanceof FuncCall) { return null; } if (!$this->nodeNameResolver->isNames($node, self::VARIADIC_FUNCTION_NAMES)) { return null; } $isVariadic = \true; - return \PhpParser\NodeTraverser::STOP_TRAVERSAL; + return NodeTraverser::STOP_TRAVERSAL; }); return $isVariadic; } diff --git a/rules/DeadCode/PhpDoc/DeadParamTagValueNodeAnalyzer.php b/rules/DeadCode/PhpDoc/DeadParamTagValueNodeAnalyzer.php index 2759b0ccf3e..0ad3106ef40 100644 --- a/rules/DeadCode/PhpDoc/DeadParamTagValueNodeAnalyzer.php +++ b/rules/DeadCode/PhpDoc/DeadParamTagValueNodeAnalyzer.php @@ -43,32 +43,32 @@ final class DeadParamTagValueNodeAnalyzer * @var \Rector\DeadCode\TypeNodeAnalyzer\MixedArrayTypeNodeAnalyzer */ private $mixedArrayTypeNodeAnalyzer; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\TypeComparator\TypeComparator $typeComparator, \Rector\DeadCode\TypeNodeAnalyzer\GenericTypeNodeAnalyzer $genericTypeNodeAnalyzer, \Rector\DeadCode\TypeNodeAnalyzer\MixedArrayTypeNodeAnalyzer $mixedArrayTypeNodeAnalyzer) + public function __construct(NodeNameResolver $nodeNameResolver, TypeComparator $typeComparator, GenericTypeNodeAnalyzer $genericTypeNodeAnalyzer, MixedArrayTypeNodeAnalyzer $mixedArrayTypeNodeAnalyzer) { $this->nodeNameResolver = $nodeNameResolver; $this->typeComparator = $typeComparator; $this->genericTypeNodeAnalyzer = $genericTypeNodeAnalyzer; $this->mixedArrayTypeNodeAnalyzer = $mixedArrayTypeNodeAnalyzer; } - public function isDead(\PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode $paramTagValueNode, \PhpParser\Node\FunctionLike $functionLike) : bool + public function isDead(ParamTagValueNode $paramTagValueNode, FunctionLike $functionLike) : bool { $param = $this->matchParamByName($paramTagValueNode->parameterName, $functionLike); - if (!$param instanceof \PhpParser\Node\Param) { + if (!$param instanceof Param) { return \false; } if ($param->type === null) { return \false; } - if ($param->type instanceof \PhpParser\Node\Name && $this->nodeNameResolver->isName($param->type, 'object')) { - return $paramTagValueNode->type instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode && (string) $paramTagValueNode->type === 'object'; + if ($param->type instanceof Name && $this->nodeNameResolver->isName($param->type, 'object')) { + return $paramTagValueNode->type instanceof IdentifierTypeNode && (string) $paramTagValueNode->type === 'object'; } if (!$this->typeComparator->arePhpParserAndPhpStanPhpDocTypesEqual($param->type, $paramTagValueNode->type, $functionLike)) { return \false; } - if (\in_array(\get_class($paramTagValueNode->type), \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger::ALLOWED_TYPES, \true)) { + if (\in_array(\get_class($paramTagValueNode->type), PhpDocTypeChanger::ALLOWED_TYPES, \true)) { return \false; } - if (!$paramTagValueNode->type instanceof \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode) { + if (!$paramTagValueNode->type instanceof BracketsAwareUnionTypeNode) { return $this->isEmptyDescription($paramTagValueNode, $param->type); } if ($this->mixedArrayTypeNodeAnalyzer->hasMixedArrayType($paramTagValueNode->type)) { @@ -79,22 +79,22 @@ final class DeadParamTagValueNodeAnalyzer } return \false; } - private function isEmptyDescription(\PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode $paramTagValueNode, \PhpParser\Node $node) : bool + private function isEmptyDescription(ParamTagValueNode $paramTagValueNode, Node $node) : bool { if ($paramTagValueNode->description !== '') { return \false; } - $parent = $paramTagValueNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::PARENT); - if (!$parent instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) { + $parent = $paramTagValueNode->getAttribute(PhpDocAttributeKey::PARENT); + if (!$parent instanceof PhpDocTagNode) { return \true; } - $parent = $parent->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::PARENT); - if (!$parent instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode) { + $parent = $parent->getAttribute(PhpDocAttributeKey::PARENT); + if (!$parent instanceof PhpDocNode) { return \true; } $children = $parent->children; foreach ($children as $key => $child) { - if ($child instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode && $node instanceof \PhpParser\Node\Name\FullyQualified) { + if ($child instanceof PhpDocTagNode && $node instanceof FullyQualified) { return $this->isUnionIdentifier($child); } if (!$this->isTextNextline($key, $child)) { @@ -103,33 +103,33 @@ final class DeadParamTagValueNodeAnalyzer } return \true; } - private function isTextNextline(int $key, \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $phpDocChildNode) : bool + private function isTextNextline(int $key, PhpDocChildNode $phpDocChildNode) : bool { if ($key < 1) { return \true; } - if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode) { + if (!$phpDocChildNode instanceof PhpDocTextNode) { return \true; } return (string) $phpDocChildNode === ''; } - private function isUnionIdentifier(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode $phpDocTagNode) : bool + private function isUnionIdentifier(PhpDocTagNode $phpDocTagNode) : bool { - if (!$phpDocTagNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode) { + if (!$phpDocTagNode->value instanceof ParamTagValueNode) { return \true; } - if (!$phpDocTagNode->value->type instanceof \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode) { + if (!$phpDocTagNode->value->type instanceof BracketsAwareUnionTypeNode) { return \true; } $types = $phpDocTagNode->value->type->types; foreach ($types as $type) { - if ($type instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode) { + if ($type instanceof IdentifierTypeNode) { return \false; } } return \true; } - private function matchParamByName(string $desiredParamName, \PhpParser\Node\FunctionLike $functionLike) : ?\PhpParser\Node\Param + private function matchParamByName(string $desiredParamName, FunctionLike $functionLike) : ?Param { foreach ($functionLike->getParams() as $param) { $paramName = $this->nodeNameResolver->getName($param); diff --git a/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php b/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php index 1965e5fb9f7..6c0617e8bd2 100644 --- a/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php +++ b/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php @@ -37,30 +37,30 @@ final class DeadReturnTagValueNodeAnalyzer * @var \Rector\DeadCode\TypeNodeAnalyzer\MixedArrayTypeNodeAnalyzer */ private $mixedArrayTypeNodeAnalyzer; - public function __construct(\Rector\NodeTypeResolver\TypeComparator\TypeComparator $typeComparator, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\DeadCode\TypeNodeAnalyzer\GenericTypeNodeAnalyzer $genericTypeNodeAnalyzer, \Rector\DeadCode\TypeNodeAnalyzer\MixedArrayTypeNodeAnalyzer $mixedArrayTypeNodeAnalyzer) + public function __construct(TypeComparator $typeComparator, BetterNodeFinder $betterNodeFinder, GenericTypeNodeAnalyzer $genericTypeNodeAnalyzer, MixedArrayTypeNodeAnalyzer $mixedArrayTypeNodeAnalyzer) { $this->typeComparator = $typeComparator; $this->betterNodeFinder = $betterNodeFinder; $this->genericTypeNodeAnalyzer = $genericTypeNodeAnalyzer; $this->mixedArrayTypeNodeAnalyzer = $mixedArrayTypeNodeAnalyzer; } - public function isDead(\PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode $returnTagValueNode, \PhpParser\Node\FunctionLike $functionLike) : bool + public function isDead(ReturnTagValueNode $returnTagValueNode, FunctionLike $functionLike) : bool { $returnType = $functionLike->getReturnType(); if ($returnType === null) { return \false; } - $classLike = $this->betterNodeFinder->findParentType($functionLike, \PhpParser\Node\Stmt\ClassLike::class); - if ($classLike instanceof \PhpParser\Node\Stmt\Trait_ && $returnTagValueNode->type instanceof \PHPStan\PhpDocParser\Ast\Type\ThisTypeNode) { + $classLike = $this->betterNodeFinder->findParentType($functionLike, ClassLike::class); + if ($classLike instanceof Trait_ && $returnTagValueNode->type instanceof ThisTypeNode) { return \false; } if (!$this->typeComparator->arePhpParserAndPhpStanPhpDocTypesEqual($returnType, $returnTagValueNode->type, $functionLike)) { return \false; } - if (\in_array(\get_class($returnTagValueNode->type), \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger::ALLOWED_TYPES, \true)) { + if (\in_array(\get_class($returnTagValueNode->type), PhpDocTypeChanger::ALLOWED_TYPES, \true)) { return \false; } - if (!$returnTagValueNode->type instanceof \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode) { + if (!$returnTagValueNode->type instanceof BracketsAwareUnionTypeNode) { return $returnTagValueNode->description === ''; } if ($this->genericTypeNodeAnalyzer->hasGenericType($returnTagValueNode->type)) { @@ -74,11 +74,11 @@ final class DeadReturnTagValueNodeAnalyzer } return $returnTagValueNode->description === ''; } - private function hasTruePseudoType(\Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode $bracketsAwareUnionTypeNode) : bool + private function hasTruePseudoType(BracketsAwareUnionTypeNode $bracketsAwareUnionTypeNode) : bool { $unionTypes = $bracketsAwareUnionTypeNode->types; foreach ($unionTypes as $unionType) { - if (!$unionType instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode) { + if (!$unionType instanceof IdentifierTypeNode) { continue; } $name = \strtolower((string) $unionType); diff --git a/rules/DeadCode/PhpDoc/DeadVarTagValueNodeAnalyzer.php b/rules/DeadCode/PhpDoc/DeadVarTagValueNodeAnalyzer.php index 1c2f14bb8a8..ba828596ab4 100644 --- a/rules/DeadCode/PhpDoc/DeadVarTagValueNodeAnalyzer.php +++ b/rules/DeadCode/PhpDoc/DeadVarTagValueNodeAnalyzer.php @@ -20,12 +20,12 @@ final class DeadVarTagValueNodeAnalyzer * @var \Rector\StaticTypeMapper\StaticTypeMapper */ private $staticTypeMapper; - public function __construct(\Rector\NodeTypeResolver\TypeComparator\TypeComparator $typeComparator, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper) + public function __construct(TypeComparator $typeComparator, StaticTypeMapper $staticTypeMapper) { $this->typeComparator = $typeComparator; $this->staticTypeMapper = $staticTypeMapper; } - public function isDead(\PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode $varTagValueNode, \PhpParser\Node\Stmt\Property $property) : bool + public function isDead(VarTagValueNode $varTagValueNode, Property $property) : bool { if ($property->type === null) { return \false; @@ -33,7 +33,7 @@ final class DeadVarTagValueNodeAnalyzer // is strict type superior to doc type? keep strict type only $propertyType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($property->type); $docType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($varTagValueNode->type, $property); - if ($propertyType instanceof \PHPStan\Type\UnionType && !$docType instanceof \PHPStan\Type\UnionType) { + if ($propertyType instanceof UnionType && !$docType instanceof UnionType) { return \true; } if (!$this->typeComparator->arePhpParserAndPhpStanPhpDocTypesEqual($property->type, $varTagValueNode->type, $property)) { diff --git a/rules/DeadCode/PhpDoc/TagRemover/ParamTagRemover.php b/rules/DeadCode/PhpDoc/TagRemover/ParamTagRemover.php index 66c9786e7b2..755aedcb0d2 100644 --- a/rules/DeadCode/PhpDoc/TagRemover/ParamTagRemover.php +++ b/rules/DeadCode/PhpDoc/TagRemover/ParamTagRemover.php @@ -17,19 +17,19 @@ final class ParamTagRemover * @var \Rector\DeadCode\PhpDoc\DeadParamTagValueNodeAnalyzer */ private $deadParamTagValueNodeAnalyzer; - public function __construct(\Rector\DeadCode\PhpDoc\DeadParamTagValueNodeAnalyzer $deadParamTagValueNodeAnalyzer) + public function __construct(DeadParamTagValueNodeAnalyzer $deadParamTagValueNodeAnalyzer) { $this->deadParamTagValueNodeAnalyzer = $deadParamTagValueNodeAnalyzer; } - public function removeParamTagsIfUseless(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\FunctionLike $functionLike) : bool + public function removeParamTagsIfUseless(PhpDocInfo $phpDocInfo, FunctionLike $functionLike) : bool { $hasChanged = \false; - $phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser(); - $phpDocNodeTraverser->traverseWithCallable($phpDocInfo->getPhpDocNode(), '', function (\PHPStan\PhpDocParser\Ast\Node $docNode) use($functionLike, $phpDocInfo, &$hasChanged) : ?int { - if (!$docNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) { + $phpDocNodeTraverser = new PhpDocNodeTraverser(); + $phpDocNodeTraverser->traverseWithCallable($phpDocInfo->getPhpDocNode(), '', function (Node $docNode) use($functionLike, $phpDocInfo, &$hasChanged) : ?int { + if (!$docNode instanceof PhpDocTagNode) { return null; } - if (!$docNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode) { + if (!$docNode->value instanceof ParamTagValueNode) { return null; } // handle only basic types, keep phpstan/psalm helper ones @@ -41,7 +41,7 @@ final class ParamTagRemover } $phpDocInfo->markAsChanged(); $hasChanged = \true; - return \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser::NODE_REMOVE; + return PhpDocNodeTraverser::NODE_REMOVE; }); return $hasChanged; } diff --git a/rules/DeadCode/PhpDoc/TagRemover/ReturnTagRemover.php b/rules/DeadCode/PhpDoc/TagRemover/ReturnTagRemover.php index cfb64a39fc0..5220d886d0f 100644 --- a/rules/DeadCode/PhpDoc/TagRemover/ReturnTagRemover.php +++ b/rules/DeadCode/PhpDoc/TagRemover/ReturnTagRemover.php @@ -15,22 +15,22 @@ final class ReturnTagRemover * @var \Rector\DeadCode\PhpDoc\DeadReturnTagValueNodeAnalyzer */ private $deadReturnTagValueNodeAnalyzer; - public function __construct(\Rector\DeadCode\PhpDoc\DeadReturnTagValueNodeAnalyzer $deadReturnTagValueNodeAnalyzer) + public function __construct(DeadReturnTagValueNodeAnalyzer $deadReturnTagValueNodeAnalyzer) { $this->deadReturnTagValueNodeAnalyzer = $deadReturnTagValueNodeAnalyzer; } - public function removeReturnTagIfUseless(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\FunctionLike $functionLike) : bool + public function removeReturnTagIfUseless(PhpDocInfo $phpDocInfo, FunctionLike $functionLike) : bool { // remove existing type $returnTagValueNode = $phpDocInfo->getReturnTagValue(); - if (!$returnTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode) { + if (!$returnTagValueNode instanceof ReturnTagValueNode) { return \false; } $isReturnTagValueDead = $this->deadReturnTagValueNodeAnalyzer->isDead($returnTagValueNode, $functionLike); if (!$isReturnTagValueDead) { return \false; } - $phpDocInfo->removeByType(\PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode::class); + $phpDocInfo->removeByType(ReturnTagValueNode::class); return \true; } } diff --git a/rules/DeadCode/PhpDoc/TagRemover/VarTagRemover.php b/rules/DeadCode/PhpDoc/TagRemover/VarTagRemover.php index 51be7c3febd..60ff4725bf1 100644 --- a/rules/DeadCode/PhpDoc/TagRemover/VarTagRemover.php +++ b/rules/DeadCode/PhpDoc/TagRemover/VarTagRemover.php @@ -36,17 +36,17 @@ final class VarTagRemover * @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger */ private $phpDocTypeChanger; - public function __construct(\Rector\PHPStanStaticTypeMapper\DoctrineTypeAnalyzer $doctrineTypeAnalyzer, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\DeadCode\PhpDoc\DeadVarTagValueNodeAnalyzer $deadVarTagValueNodeAnalyzer, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger) + public function __construct(DoctrineTypeAnalyzer $doctrineTypeAnalyzer, PhpDocInfoFactory $phpDocInfoFactory, DeadVarTagValueNodeAnalyzer $deadVarTagValueNodeAnalyzer, PhpDocTypeChanger $phpDocTypeChanger) { $this->doctrineTypeAnalyzer = $doctrineTypeAnalyzer; $this->phpDocInfoFactory = $phpDocInfoFactory; $this->deadVarTagValueNodeAnalyzer = $deadVarTagValueNodeAnalyzer; $this->phpDocTypeChanger = $phpDocTypeChanger; } - public function removeVarTagIfUseless(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\Stmt\Property $property) : void + public function removeVarTagIfUseless(PhpDocInfo $phpDocInfo, Property $property) : void { $varTagValueNode = $phpDocInfo->getVarTagValueNode(); - if (!$varTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) { + if (!$varTagValueNode instanceof VarTagValueNode) { return; } $isVarTagValueDead = $this->deadVarTagValueNodeAnalyzer->isDead($varTagValueNode, $property); @@ -56,14 +56,14 @@ final class VarTagRemover if ($this->phpDocTypeChanger->isAllowed($varTagValueNode->type)) { return; } - $phpDocInfo->removeByType(\PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode::class); + $phpDocInfo->removeByType(VarTagValueNode::class); } /** * @param \PhpParser\Node\Stmt\Expression|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $node */ - public function removeVarPhpTagValueNodeIfNotComment($node, \PHPStan\Type\Type $type) : void + public function removeVarPhpTagValueNodeIfNotComment($node, Type $type) : void { - if ($type instanceof \PHPStan\Type\Generic\TemplateObjectWithoutClassType) { + if ($type instanceof TemplateObjectWithoutClassType) { return; } // keep doctrine collection narrow type @@ -72,7 +72,7 @@ final class VarTagRemover } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $varTagValueNode = $phpDocInfo->getVarTagValueNode(); - if (!$varTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) { + if (!$varTagValueNode instanceof VarTagValueNode) { return; } // has description? keep it @@ -83,6 +83,6 @@ final class VarTagRemover if ($this->phpDocTypeChanger->isAllowed($varTagValueNode->type)) { return; } - $phpDocInfo->removeByType(\PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode::class); + $phpDocInfo->removeByType(VarTagValueNode::class); } } diff --git a/rules/DeadCode/Rector/Array_/RemoveDuplicatedArrayKeyRector.php b/rules/DeadCode/Rector/Array_/RemoveDuplicatedArrayKeyRector.php index 7d0f8a28053..3d8666e1d22 100644 --- a/rules/DeadCode/Rector/Array_/RemoveDuplicatedArrayKeyRector.php +++ b/rules/DeadCode/Rector/Array_/RemoveDuplicatedArrayKeyRector.php @@ -8,26 +8,26 @@ use PhpParser\Node\Expr\Array_; use PhpParser\Node\Expr\ArrayItem; use Rector\Core\Contract\PhpParser\NodePrinterInterface; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/SG0Wu * @see \Rector\Tests\DeadCode\Rector\Array_\RemoveDuplicatedArrayKeyRector\RemoveDuplicatedArrayKeyRectorTest */ -final class RemoveDuplicatedArrayKeyRector extends \Rector\Core\Rector\AbstractRector +final class RemoveDuplicatedArrayKeyRector extends AbstractRector { /** * @readonly * @var \Rector\Core\Contract\PhpParser\NodePrinterInterface */ private $nodePrinter; - public function __construct(\Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter) + public function __construct(NodePrinterInterface $nodePrinter) { $this->nodePrinter = $nodePrinter; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove duplicated key in defined arrays.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove duplicated key in defined arrays.', [new CodeSample(<<<'CODE_SAMPLE' $item = [ 1 => 'A', 1 => 'B' @@ -45,12 +45,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Array_::class]; + return [Array_::class]; } /** * @param Array_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $arrayItemsWithDuplicatedKey = $this->getArrayItemsWithDuplicatedKey($node); if ($arrayItemsWithDuplicatedKey === []) { @@ -66,11 +66,11 @@ CODE_SAMPLE /** * @return ArrayItem[][] */ - private function getArrayItemsWithDuplicatedKey(\PhpParser\Node\Expr\Array_ $array) : array + private function getArrayItemsWithDuplicatedKey(Array_ $array) : array { $arrayItemsByKeys = []; foreach ($array->items as $arrayItem) { - if (!$arrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$arrayItem instanceof ArrayItem) { continue; } if ($arrayItem->key === null) { diff --git a/rules/DeadCode/Rector/Assign/RemoveDoubleAssignRector.php b/rules/DeadCode/Rector/Assign/RemoveDoubleAssignRector.php index fdeb704db83..e7539d24ec6 100644 --- a/rules/DeadCode/Rector/Assign/RemoveDoubleAssignRector.php +++ b/rules/DeadCode/Rector/Assign/RemoveDoubleAssignRector.php @@ -18,25 +18,25 @@ use PhpParser\Node\Stmt\Namespace_; use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace; use Rector\Core\Rector\AbstractRector; use Rector\DeadCode\SideEffect\SideEffectNodeDetector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\Assign\RemoveDoubleAssignRector\RemoveDoubleAssignRectorTest */ -final class RemoveDoubleAssignRector extends \Rector\Core\Rector\AbstractRector +final class RemoveDoubleAssignRector extends AbstractRector { /** * @readonly * @var \Rector\DeadCode\SideEffect\SideEffectNodeDetector */ private $sideEffectNodeDetector; - public function __construct(\Rector\DeadCode\SideEffect\SideEffectNodeDetector $sideEffectNodeDetector) + public function __construct(SideEffectNodeDetector $sideEffectNodeDetector) { $this->sideEffectNodeDetector = $sideEffectNodeDetector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Simplify useless double assigns', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Simplify useless double assigns', [new CodeSample(<<<'CODE_SAMPLE' $value = 1; $value = 1; CODE_SAMPLE @@ -47,12 +47,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Foreach_::class, \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\Closure::class, \PhpParser\Node\Stmt\If_::class, \PhpParser\Node\Stmt\Namespace_::class]; + return [Foreach_::class, FileWithoutNamespace::class, ClassMethod::class, Function_::class, Closure::class, If_::class, Namespace_::class]; } /** * @param Foreach_|FileWithoutNamespace|If_|Namespace_|ClassMethod|Function_|Closure $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $stmts = $node->stmts; if ($stmts === null) { @@ -63,17 +63,17 @@ CODE_SAMPLE if (!isset($stmts[$key + 1])) { continue; } - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { continue; } $nextStmt = $stmts[$key + 1]; - if (!$nextStmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$nextStmt instanceof Expression) { continue; } - if (!$stmt->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$stmt->expr instanceof Assign) { continue; } - if (!$nextStmt->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$nextStmt->expr instanceof Assign) { continue; } $nextAssign = $nextStmt->expr; @@ -89,7 +89,7 @@ CODE_SAMPLE if ($this->sideEffectNodeDetector->detectCallExpr($stmt->expr->expr)) { continue; } - if (!$stmt->expr->var instanceof \PhpParser\Node\Expr\Variable && !$stmt->expr->var instanceof \PhpParser\Node\Expr\PropertyFetch && !$stmt->expr->var instanceof \PhpParser\Node\Expr\StaticPropertyFetch) { + if (!$stmt->expr->var instanceof Variable && !$stmt->expr->var instanceof PropertyFetch && !$stmt->expr->var instanceof StaticPropertyFetch) { continue; } // remove current Stmt if will be overriden in next stmt @@ -101,9 +101,9 @@ CODE_SAMPLE } return $node; } - private function isSelfReferencing(\PhpParser\Node\Expr\Assign $assign) : bool + private function isSelfReferencing(Assign $assign) : bool { - return (bool) $this->betterNodeFinder->findFirst($assign->expr, function (\PhpParser\Node $subNode) use($assign) : bool { + return (bool) $this->betterNodeFinder->findFirst($assign->expr, function (Node $subNode) use($assign) : bool { return $this->nodeComparator->areNodesEqual($assign->var, $subNode); }); } diff --git a/rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php b/rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php index 8523d099887..95ee1272164 100644 --- a/rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php +++ b/rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php @@ -26,12 +26,12 @@ use Rector\DeadCode\NodeAnalyzer\UsedVariableNameAnalyzer; use Rector\DeadCode\SideEffect\SideEffectNodeDetector; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Php74\Tokenizer\FollowedByCurlyBracketAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector\RemoveUnusedVariableAssignRectorTest */ -final class RemoveUnusedVariableAssignRector extends \Rector\Core\Rector\AbstractRector +final class RemoveUnusedVariableAssignRector extends AbstractRector { /** * @readonly @@ -63,7 +63,7 @@ final class RemoveUnusedVariableAssignRector extends \Rector\Core\Rector\Abstrac * @var \Rector\Php74\Tokenizer\FollowedByCurlyBracketAnalyzer */ private $followedByCurlyBracketAnalyzer; - public function __construct(\Rector\Core\Php\ReservedKeywordAnalyzer $reservedKeywordAnalyzer, \Rector\Core\PhpParser\Comparing\ConditionSearcher $conditionSearcher, \Rector\DeadCode\NodeAnalyzer\UsedVariableNameAnalyzer $usedVariableNameAnalyzer, \Rector\DeadCode\SideEffect\SideEffectNodeDetector $sideEffectNodeDetector, \Rector\DeadCode\NodeAnalyzer\ExprUsedInNextNodeAnalyzer $exprUsedInNextNodeAnalyzer, \Rector\Php74\Tokenizer\FollowedByCurlyBracketAnalyzer $followedByCurlyBracketAnalyzer) + public function __construct(ReservedKeywordAnalyzer $reservedKeywordAnalyzer, ConditionSearcher $conditionSearcher, UsedVariableNameAnalyzer $usedVariableNameAnalyzer, SideEffectNodeDetector $sideEffectNodeDetector, ExprUsedInNextNodeAnalyzer $exprUsedInNextNodeAnalyzer, FollowedByCurlyBracketAnalyzer $followedByCurlyBracketAnalyzer) { $this->reservedKeywordAnalyzer = $reservedKeywordAnalyzer; $this->conditionSearcher = $conditionSearcher; @@ -72,9 +72,9 @@ final class RemoveUnusedVariableAssignRector extends \Rector\Core\Rector\Abstrac $this->exprUsedInNextNodeAnalyzer = $exprUsedInNextNodeAnalyzer; $this->followedByCurlyBracketAnalyzer = $followedByCurlyBracketAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove unused assigns to variables', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove unused assigns to variables', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -98,18 +98,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Assign::class]; + return [Assign::class]; } /** * @param Assign $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } $variable = $node->var; - if (!$variable instanceof \PhpParser\Node\Expr\Variable) { + if (!$variable instanceof Variable) { return null; } $variableName = $this->getName($variable); @@ -127,46 +127,46 @@ CODE_SAMPLE $this->removeNode($node); return $node; } - private function cleanCastedExpr(\PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr + private function cleanCastedExpr(Expr $expr) : Expr { - if (!$expr instanceof \PhpParser\Node\Expr\Cast) { + if (!$expr instanceof Cast) { return $expr; } $castedExpr = $expr->expr; return $this->cleanCastedExpr($castedExpr); } - private function hasCallLikeInAssignExpr(\PhpParser\Node\Expr $expr) : bool + private function hasCallLikeInAssignExpr(Expr $expr) : bool { - return (bool) $this->betterNodeFinder->findFirst($expr, function (\PhpParser\Node $subNode) : bool { + return (bool) $this->betterNodeFinder->findFirst($expr, function (Node $subNode) : bool { return $this->sideEffectNodeDetector->detectCallExpr($subNode); }); } - private function shouldSkip(\PhpParser\Node\Expr\Assign $assign) : bool + private function shouldSkip(Assign $assign) : bool { - $classMethod = $this->betterNodeFinder->findParentType($assign, \PhpParser\Node\Stmt\ClassMethod::class); - if (!$classMethod instanceof \PhpParser\Node\FunctionLike) { + $classMethod = $this->betterNodeFinder->findParentType($assign, ClassMethod::class); + if (!$classMethod instanceof FunctionLike) { return \true; } $variable = $assign->var; - if (!$variable instanceof \PhpParser\Node\Expr\Variable) { + if (!$variable instanceof Variable) { return \true; } - $parentNode = $assign->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node\Stmt\Expression) { + $parentNode = $assign->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof Expression) { return \true; } - $originalNode = $parentNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE); - if (!$originalNode instanceof \PhpParser\Node) { + $originalNode = $parentNode->getAttribute(AttributeKey::ORIGINAL_NODE); + if (!$originalNode instanceof Node) { return \true; } - if (!$variable->name instanceof \PhpParser\Node\Expr\Variable) { + if (!$variable->name instanceof Variable) { return $this->followedByCurlyBracketAnalyzer->isFollowed($this->file, $variable); } - return (bool) $this->betterNodeFinder->findFirstNext($assign, function (\PhpParser\Node $node) : bool { - return $node instanceof \PhpParser\Node\Expr\Variable; + return (bool) $this->betterNodeFinder->findFirstNext($assign, function (Node $node) : bool { + return $node instanceof Variable; }); } - private function isUsed(\PhpParser\Node\Expr\Assign $assign, \PhpParser\Node\Expr\Variable $variable) : bool + private function isUsed(Assign $assign, Variable $variable) : bool { $isUsedPrev = $this->isUsedInPreviousNode($variable); if ($isUsedPrev) { @@ -182,18 +182,18 @@ CODE_SAMPLE } return $this->isUsedInAssignExpr($expr, $assign); } - private function isUsedInPreviousNode(\PhpParser\Node\Expr\Variable $variable) : bool + private function isUsedInPreviousNode(Variable $variable) : bool { - return (bool) $this->betterNodeFinder->findFirstPrevious($variable, function (\PhpParser\Node $node) use($variable) : bool { + return (bool) $this->betterNodeFinder->findFirstPrevious($variable, function (Node $node) use($variable) : bool { return $this->usedVariableNameAnalyzer->isVariableNamed($node, $variable); }); } /** * @param \PhpParser\Node\Expr\CallLike|\PhpParser\Node\Expr $expr */ - private function isUsedInAssignExpr($expr, \PhpParser\Node\Expr\Assign $assign) : bool + private function isUsedInAssignExpr($expr, Assign $assign) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\CallLike) { + if (!$expr instanceof CallLike) { return $this->isUsedInPreviousAssign($assign, $expr); } foreach ($expr->getArgs() as $arg) { @@ -204,15 +204,15 @@ CODE_SAMPLE } return \false; } - private function isUsedInPreviousAssign(\PhpParser\Node\Expr\Assign $assign, \PhpParser\Node\Expr $expr) : bool + private function isUsedInPreviousAssign(Assign $assign, Expr $expr) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\Variable) { + if (!$expr instanceof Variable) { return \false; } - $previousAssign = $this->betterNodeFinder->findFirstPrevious($assign, function (\PhpParser\Node $node) use($expr) : bool { - return $node instanceof \PhpParser\Node\Expr\Assign && $this->usedVariableNameAnalyzer->isVariableNamed($node->var, $expr); + $previousAssign = $this->betterNodeFinder->findFirstPrevious($assign, function (Node $node) use($expr) : bool { + return $node instanceof Assign && $this->usedVariableNameAnalyzer->isVariableNamed($node->var, $expr); }); - if ($previousAssign instanceof \PhpParser\Node\Expr\Assign) { + if ($previousAssign instanceof Assign) { return $this->isUsed($assign, $expr); } return \false; @@ -220,16 +220,16 @@ CODE_SAMPLE /** * @return null|\PhpParser\Node\Expr */ - private function refactorUsedVariable(\PhpParser\Node\Expr\Assign $assign) + private function refactorUsedVariable(Assign $assign) { - $parentNode = $assign->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node\Stmt\Expression) { + $parentNode = $assign->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof Expression) { return null; } - $if = $parentNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); + $if = $parentNode->getAttribute(AttributeKey::NEXT_NODE); // check if next node is if - if (!$if instanceof \PhpParser\Node\Stmt\If_) { - if ($assign->var instanceof \PhpParser\Node\Expr\Variable && !$this->isUsedInPreviousNode($assign->var) && !$this->exprUsedInNextNodeAnalyzer->isUsed($assign->var)) { + if (!$if instanceof If_) { + if ($assign->var instanceof Variable && !$this->isUsedInPreviousNode($assign->var) && !$this->exprUsedInNextNodeAnalyzer->isUsed($assign->var)) { return $this->cleanCastedExpr($assign->expr); } return null; diff --git a/rules/DeadCode/Rector/BinaryOp/RemoveDuplicatedInstanceOfRector.php b/rules/DeadCode/Rector/BinaryOp/RemoveDuplicatedInstanceOfRector.php index 028def9de8c..707d838510c 100644 --- a/rules/DeadCode/Rector/BinaryOp/RemoveDuplicatedInstanceOfRector.php +++ b/rules/DeadCode/Rector/BinaryOp/RemoveDuplicatedInstanceOfRector.php @@ -8,25 +8,25 @@ use PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\Instanceof_; use Rector\Core\Rector\AbstractRector; use Rector\DeadCode\NodeAnalyzer\InstanceOfUniqueKeyResolver; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\BinaryOp\RemoveDuplicatedInstanceOfRector\RemoveDuplicatedInstanceOfRectorTest */ -final class RemoveDuplicatedInstanceOfRector extends \Rector\Core\Rector\AbstractRector +final class RemoveDuplicatedInstanceOfRector extends AbstractRector { /** * @readonly * @var \Rector\DeadCode\NodeAnalyzer\InstanceOfUniqueKeyResolver */ private $instanceOfUniqueKeyResolver; - public function __construct(\Rector\DeadCode\NodeAnalyzer\InstanceOfUniqueKeyResolver $instanceOfUniqueKeyResolver) + public function __construct(InstanceOfUniqueKeyResolver $instanceOfUniqueKeyResolver) { $this->instanceOfUniqueKeyResolver = $instanceOfUniqueKeyResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove duplicated instanceof in one call', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove duplicated instanceof in one call', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($value) @@ -53,12 +53,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp::class]; + return [BinaryOp::class]; } /** * @param BinaryOp $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $duplicatedInstanceOfs = $this->resolveDuplicatedInstancesOf($node); if ($duplicatedInstanceOfs === []) { @@ -70,11 +70,11 @@ CODE_SAMPLE /** * @return Instanceof_[] */ - private function resolveDuplicatedInstancesOf(\PhpParser\Node\Expr\BinaryOp $binaryOp) : array + private function resolveDuplicatedInstancesOf(BinaryOp $binaryOp) : array { $duplicatedInstanceOfs = []; /** @var Instanceof_[] $instanceOfs */ - $instanceOfs = $this->betterNodeFinder->findInstanceOf($binaryOp, \PhpParser\Node\Expr\Instanceof_::class); + $instanceOfs = $this->betterNodeFinder->findInstanceOf($binaryOp, Instanceof_::class); $uniqueInstanceOfKeys = []; foreach ($instanceOfs as $instanceOf) { $uniqueKey = $this->instanceOfUniqueKeyResolver->resolve($instanceOf); diff --git a/rules/DeadCode/Rector/BooleanAnd/RemoveAndTrueRector.php b/rules/DeadCode/Rector/BooleanAnd/RemoveAndTrueRector.php index d0f41ea7c1d..32cc5bb705c 100644 --- a/rules/DeadCode/Rector/BooleanAnd/RemoveAndTrueRector.php +++ b/rules/DeadCode/Rector/BooleanAnd/RemoveAndTrueRector.php @@ -7,16 +7,16 @@ use PhpParser\Node; use PhpParser\Node\Expr; use PhpParser\Node\Expr\BinaryOp\BooleanAnd; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector\RemoveAndTrueRectorTest */ -final class RemoveAndTrueRector extends \Rector\Core\Rector\AbstractRector +final class RemoveAndTrueRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove and true that has no added value', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove and true that has no added value', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -41,12 +41,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\BooleanAnd::class]; + return [BooleanAnd::class]; } /** * @param BooleanAnd $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->isTrueOrBooleanAndTrues($node->left)) { return $node->right; @@ -56,12 +56,12 @@ CODE_SAMPLE } return null; } - private function isTrueOrBooleanAndTrues(\PhpParser\Node\Expr $expr) : bool + private function isTrueOrBooleanAndTrues(Expr $expr) : bool { if ($this->valueResolver->isTrue($expr)) { return \true; } - if (!$expr instanceof \PhpParser\Node\Expr\BinaryOp\BooleanAnd) { + if (!$expr instanceof BooleanAnd) { return \false; } if (!$this->isTrueOrBooleanAndTrues($expr->left)) { diff --git a/rules/DeadCode/Rector/Cast/RecastingRemovalRector.php b/rules/DeadCode/Rector/Cast/RecastingRemovalRector.php index be7f7ce297c..1da732ebbc6 100644 --- a/rules/DeadCode/Rector/Cast/RecastingRemovalRector.php +++ b/rules/DeadCode/Rector/Cast/RecastingRemovalRector.php @@ -28,17 +28,17 @@ use Rector\Core\NodeAnalyzer\ExprAnalyzer; use Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer; use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\Cast\RecastingRemovalRector\RecastingRemovalRectorTest */ -final class RecastingRemovalRector extends \Rector\Core\Rector\AbstractRector +final class RecastingRemovalRector extends AbstractRector { /** * @var array, class-string> */ - private const CAST_CLASS_TO_NODE_TYPE = [\PhpParser\Node\Expr\Cast\String_::class => \PHPStan\Type\StringType::class, \PhpParser\Node\Expr\Cast\Bool_::class => \PHPStan\Type\BooleanType::class, \PhpParser\Node\Expr\Cast\Array_::class => \PHPStan\Type\ArrayType::class, \PhpParser\Node\Expr\Cast\Int_::class => \PHPStan\Type\IntegerType::class, \PhpParser\Node\Expr\Cast\Object_::class => \PHPStan\Type\ObjectType::class, \PhpParser\Node\Expr\Cast\Double::class => \PHPStan\Type\FloatType::class]; + private const CAST_CLASS_TO_NODE_TYPE = [String_::class => StringType::class, Bool_::class => BooleanType::class, Array_::class => ArrayType::class, Int_::class => IntegerType::class, Object_::class => ObjectType::class, Double::class => FloatType::class]; /** * @readonly * @var \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer @@ -54,15 +54,15 @@ final class RecastingRemovalRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Core\NodeAnalyzer\ExprAnalyzer */ private $exprAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\Core\NodeAnalyzer\ExprAnalyzer $exprAnalyzer) + public function __construct(PropertyFetchAnalyzer $propertyFetchAnalyzer, ReflectionResolver $reflectionResolver, ExprAnalyzer $exprAnalyzer) { $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; $this->reflectionResolver = $reflectionResolver; $this->exprAnalyzer = $exprAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Removes recasting of the same type', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Removes recasting of the same type', [new CodeSample(<<<'CODE_SAMPLE' $string = ''; $string = (string) $string; @@ -83,19 +83,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Cast::class]; + return [Cast::class]; } /** * @param Cast $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $nodeClass = \get_class($node); if (!isset(self::CAST_CLASS_TO_NODE_TYPE[$nodeClass])) { return null; } $nodeType = $this->getType($node->expr); - if ($nodeType instanceof \PHPStan\Type\MixedType) { + if ($nodeType instanceof MixedType) { return null; } $sameNodeType = self::CAST_CLASS_TO_NODE_TYPE[$nodeClass]; @@ -107,21 +107,21 @@ CODE_SAMPLE } return $node->expr; } - private function shouldSkip(\PhpParser\Node\Expr $expr) : bool + private function shouldSkip(Expr $expr) : bool { if (!$this->propertyFetchAnalyzer->isPropertyFetch($expr)) { return $this->exprAnalyzer->isNonTypedFromParam($expr); } /** @var PropertyFetch|StaticPropertyFetch $expr */ $phpPropertyReflection = $this->reflectionResolver->resolvePropertyReflectionFromPropertyFetch($expr); - if (!$phpPropertyReflection instanceof \PHPStan\Reflection\Php\PhpPropertyReflection) { - $propertyType = $expr instanceof \PhpParser\Node\Expr\StaticPropertyFetch ? $this->nodeTypeResolver->getType($expr->class) : $this->nodeTypeResolver->getType($expr->var); + if (!$phpPropertyReflection instanceof PhpPropertyReflection) { + $propertyType = $expr instanceof StaticPropertyFetch ? $this->nodeTypeResolver->getType($expr->class) : $this->nodeTypeResolver->getType($expr->var); // need to UnionType check due rectify with RecastingRemovalRector + CountOnNullRector // cause add (array) cast on $node->args // on union $node types FuncCall|MethodCall|StaticCall - return !$propertyType instanceof \PHPStan\Type\UnionType; + return !$propertyType instanceof UnionType; } $nativeType = $phpPropertyReflection->getNativeType(); - return $nativeType instanceof \PHPStan\Type\MixedType; + return $nativeType instanceof MixedType; } } diff --git a/rules/DeadCode/Rector/ClassConst/RemoveUnusedPrivateClassConstantRector.php b/rules/DeadCode/Rector/ClassConst/RemoveUnusedPrivateClassConstantRector.php index 5227fe5d0ba..1729d3dc95a 100644 --- a/rules/DeadCode/Rector/ClassConst/RemoveUnusedPrivateClassConstantRector.php +++ b/rules/DeadCode/Rector/ClassConst/RemoveUnusedPrivateClassConstantRector.php @@ -10,12 +10,12 @@ use Rector\Core\NodeAnalyzer\EnumAnalyzer; use Rector\Core\NodeManipulator\ClassConstManipulator; use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\ClassConst\RemoveUnusedPrivateClassConstantRector\RemoveUnusedPrivateClassConstantRectorTest */ -final class RemoveUnusedPrivateClassConstantRector extends \Rector\Core\Rector\AbstractRector +final class RemoveUnusedPrivateClassConstantRector extends AbstractRector { /** * @readonly @@ -32,15 +32,15 @@ final class RemoveUnusedPrivateClassConstantRector extends \Rector\Core\Rector\A * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Core\NodeManipulator\ClassConstManipulator $classConstManipulator, \Rector\Core\NodeAnalyzer\EnumAnalyzer $enumAnalyzer, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(ClassConstManipulator $classConstManipulator, EnumAnalyzer $enumAnalyzer, ReflectionResolver $reflectionResolver) { $this->classConstManipulator = $classConstManipulator; $this->enumAnalyzer = $enumAnalyzer; $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove unused class constants', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove unused class constants', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { private const SOME_CONST = 'dead'; @@ -65,18 +65,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassConst::class]; + return [ClassConst::class]; } /** * @param ClassConst $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkipClassConst($node)) { return null; } $classReflection = $this->reflectionResolver->resolveClassReflection($node); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return null; } if ($this->classConstManipulator->hasClassConstFetch($node, $classReflection)) { @@ -85,7 +85,7 @@ CODE_SAMPLE $this->removeNode($node); return null; } - private function shouldSkipClassConst(\PhpParser\Node\Stmt\ClassConst $classConst) : bool + private function shouldSkipClassConst(ClassConst $classConst) : bool { if (!$classConst->isPrivate()) { return \true; diff --git a/rules/DeadCode/Rector/ClassLike/RemoveAnnotationRector.php b/rules/DeadCode/Rector/ClassLike/RemoveAnnotationRector.php index 06b6f998e84..dd16940cf13 100644 --- a/rules/DeadCode/Rector/ClassLike/RemoveAnnotationRector.php +++ b/rules/DeadCode/Rector/ClassLike/RemoveAnnotationRector.php @@ -12,13 +12,13 @@ use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode; use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\DeadCode\Rector\ClassLike\RemoveAnnotationRector\RemoveAnnotationRectorTest */ -final class RemoveAnnotationRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RemoveAnnotationRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var string[] @@ -29,13 +29,13 @@ final class RemoveAnnotationRector extends \Rector\Core\Rector\AbstractRector im * @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover */ private $phpDocTagRemover; - public function __construct(\Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover $phpDocTagRemover) + public function __construct(PhpDocTagRemover $phpDocTagRemover) { $this->phpDocTagRemover = $phpDocTagRemover; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove annotation by names', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove annotation by names', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' /** * @method getName() */ @@ -55,12 +55,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassLike::class, \PhpParser\Node\FunctionLike::class, \PhpParser\Node\Stmt\Property::class, \PhpParser\Node\Stmt\ClassConst::class]; + return [ClassLike::class, FunctionLike::class, Property::class, ClassConst::class]; } /** * @param ClassLike|FunctionLike|Property|ClassConst $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->annotationsToRemove === []) { return null; @@ -68,7 +68,7 @@ CODE_SAMPLE $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); foreach ($this->annotationsToRemove as $annotationToRemove) { $this->phpDocTagRemover->removeByName($phpDocInfo, $annotationToRemove); - if (!\is_a($annotationToRemove, \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode::class, \true)) { + if (!\is_a($annotationToRemove, PhpDocTagValueNode::class, \true)) { continue; } $phpDocInfo->removeByType($annotationToRemove); @@ -83,7 +83,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configuration); + Assert::allString($configuration); $this->annotationsToRemove = $configuration; } } diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveDeadConstructorRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveDeadConstructorRector.php index ded560d3f8e..4610f7cf35f 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveDeadConstructorRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveDeadConstructorRector.php @@ -11,12 +11,12 @@ use Rector\Core\NodeAnalyzer\ParamAnalyzer; use Rector\Core\NodeManipulator\ClassMethodManipulator; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\MethodName; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\ClassMethod\RemoveDeadConstructorRector\RemoveDeadConstructorRectorTest */ -final class RemoveDeadConstructorRector extends \Rector\Core\Rector\AbstractRector +final class RemoveDeadConstructorRector extends AbstractRector { /** * @readonly @@ -28,14 +28,14 @@ final class RemoveDeadConstructorRector extends \Rector\Core\Rector\AbstractRect * @var \Rector\Core\NodeAnalyzer\ParamAnalyzer */ private $paramAnalyzer; - public function __construct(\Rector\Core\NodeManipulator\ClassMethodManipulator $classMethodManipulator, \Rector\Core\NodeAnalyzer\ParamAnalyzer $paramAnalyzer) + public function __construct(ClassMethodManipulator $classMethodManipulator, ParamAnalyzer $paramAnalyzer) { $this->classMethodManipulator = $classMethodManipulator; $this->paramAnalyzer = $paramAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove empty constructor', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove empty constructor', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function __construct() @@ -55,29 +55,29 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLike = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$classLike instanceof Class_) { return null; } if ($this->shouldSkipPropertyPromotion($node)) { return null; } - if ($classLike->extends instanceof \PhpParser\Node\Name\FullyQualified) { + if ($classLike->extends instanceof FullyQualified) { return null; } $this->removeNode($node); return null; } - private function shouldSkipPropertyPromotion(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkipPropertyPromotion(ClassMethod $classMethod) : bool { - if (!$this->isName($classMethod, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if (!$this->isName($classMethod, MethodName::CONSTRUCT)) { return \true; } if ($classMethod->stmts === null) { diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveDelegatingParentCallRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveDelegatingParentCallRector.php index d7bd21f2544..5141e2cb734 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveDelegatingParentCallRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveDelegatingParentCallRector.php @@ -15,12 +15,12 @@ use PhpParser\Node\Stmt\Return_; use Rector\Core\Rector\AbstractRector; use Rector\DeadCode\Comparator\CurrentAndParentClassMethodComparator; use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\ClassMethod\RemoveDelegatingParentCallRector\RemoveDelegatingParentCallRectorTest */ -final class RemoveDelegatingParentCallRector extends \Rector\Core\Rector\AbstractRector +final class RemoveDelegatingParentCallRector extends AbstractRector { /** * @var string[] @@ -40,14 +40,14 @@ final class RemoveDelegatingParentCallRector extends \Rector\Core\Rector\Abstrac * @var \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer */ private $phpAttributeAnalyzer; - public function __construct(\Rector\DeadCode\Comparator\CurrentAndParentClassMethodComparator $currentAndParentClassMethodComparator, \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer $phpAttributeAnalyzer) + public function __construct(CurrentAndParentClassMethodComparator $currentAndParentClassMethodComparator, PhpAttributeAnalyzer $phpAttributeAnalyzer) { $this->currentAndParentClassMethodComparator = $currentAndParentClassMethodComparator; $this->phpAttributeAnalyzer = $phpAttributeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Removed dead parent call, that does not change anything', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Removed dead parent call, that does not change anything', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function prettyPrint(array $stmts): string @@ -68,14 +68,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); + $classLike = $this->betterNodeFinder->findParentType($node, Class_::class); if ($this->shouldSkipClass($classLike)) { return null; } @@ -84,11 +84,11 @@ CODE_SAMPLE return null; } // are both return? - if ($this->isMethodReturnType($node, 'void') && !$onlyStmt instanceof \PhpParser\Node\Stmt\Return_) { + if ($this->isMethodReturnType($node, 'void') && !$onlyStmt instanceof Return_) { return null; } $staticCall = $this->matchStaticCall($onlyStmt); - if (!$staticCall instanceof \PhpParser\Node\Expr\StaticCall) { + if (!$staticCall instanceof StaticCall) { return null; } if (!$this->currentAndParentClassMethodComparator->isParentCallMatching($node, $staticCall)) { @@ -101,14 +101,14 @@ CODE_SAMPLE $this->removeNode($node); return null; } - private function shouldSkipClass(?\PhpParser\Node\Stmt\ClassLike $classLike) : bool + private function shouldSkipClass(?ClassLike $classLike) : bool { - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + if (!$classLike instanceof Class_) { return \true; } return $classLike->extends === null; } - private function isMethodReturnType(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $type) : bool + private function isMethodReturnType(ClassMethod $classMethod, string $type) : bool { if ($classMethod->returnType === null) { return \false; @@ -118,21 +118,21 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Expr|\PhpParser\Node\Stmt $node */ - private function matchStaticCall($node) : ?\PhpParser\Node\Expr\StaticCall + private function matchStaticCall($node) : ?StaticCall { // must be static call - if ($node instanceof \PhpParser\Node\Stmt\Return_) { - if ($node->expr instanceof \PhpParser\Node\Expr\StaticCall) { + if ($node instanceof Return_) { + if ($node->expr instanceof StaticCall) { return $node->expr; } return null; } - if ($node instanceof \PhpParser\Node\Expr\StaticCall) { + if ($node instanceof StaticCall) { return $node; } return null; } - private function shouldSkipWithAnnotationsOrAttributes(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkipWithAnnotationsOrAttributes(ClassMethod $classMethod) : bool { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); if ($phpDocInfo->hasByNames(self::ALLOWED_ANNOTATIONS)) { @@ -143,7 +143,7 @@ CODE_SAMPLE /** * @return null|\PhpParser\Node\Stmt|\PhpParser\Node\Expr */ - private function matchClassMethodOnlyStmt(\PhpParser\Node\Stmt\ClassMethod $classMethod) + private function matchClassMethodOnlyStmt(ClassMethod $classMethod) { $classMethodStmts = $classMethod->stmts; if ($classMethodStmts === null) { @@ -155,7 +155,7 @@ CODE_SAMPLE // recount empty notes $stmtsValues = \array_values($classMethodStmts); $stmtValue = $stmtsValues[0]; - if ($stmtValue instanceof \PhpParser\Node\Stmt\Expression) { + if ($stmtValue instanceof Expression) { return $stmtValue->expr; } return $stmtValue; diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveEmptyClassMethodRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveEmptyClassMethodRector.php index 7263ea4c0a3..86d1bbe4880 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveEmptyClassMethodRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveEmptyClassMethodRector.php @@ -12,12 +12,12 @@ use Rector\Core\NodeManipulator\ClassMethodManipulator; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\MethodName; use Rector\DeadCode\NodeManipulator\ControllerClassMethodManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector\RemoveEmptyClassMethodRectorTest */ -final class RemoveEmptyClassMethodRector extends \Rector\Core\Rector\AbstractRector +final class RemoveEmptyClassMethodRector extends AbstractRector { /** * @readonly @@ -34,15 +34,15 @@ final class RemoveEmptyClassMethodRector extends \Rector\Core\Rector\AbstractRec * @var \Rector\Core\NodeAnalyzer\ParamAnalyzer */ private $paramAnalyzer; - public function __construct(\Rector\Core\NodeManipulator\ClassMethodManipulator $classMethodManipulator, \Rector\DeadCode\NodeManipulator\ControllerClassMethodManipulator $controllerClassMethodManipulator, \Rector\Core\NodeAnalyzer\ParamAnalyzer $paramAnalyzer) + public function __construct(ClassMethodManipulator $classMethodManipulator, ControllerClassMethodManipulator $controllerClassMethodManipulator, ParamAnalyzer $paramAnalyzer) { $this->classMethodManipulator = $classMethodManipulator; $this->controllerClassMethodManipulator = $controllerClassMethodManipulator; $this->paramAnalyzer = $paramAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove empty class methods not required by parents', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove empty class methods not required by parents', [new CodeSample(<<<'CODE_SAMPLE' class OrphanClass { public function __construct() @@ -62,15 +62,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLike = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$classLike instanceof Class_) { return null; } if ($node->stmts !== null && $node->stmts !== []) { @@ -91,7 +91,7 @@ CODE_SAMPLE $this->removeNode($node); return $node; } - private function shouldSkipNonFinalNonPrivateClassMethod(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkipNonFinalNonPrivateClassMethod(Class_ $class, ClassMethod $classMethod) : bool { if ($class->isFinal()) { return \false; @@ -104,7 +104,7 @@ CODE_SAMPLE } return $classMethod->isPublic(); } - private function shouldSkipClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkipClassMethod(ClassMethod $classMethod) : bool { if ($this->classMethodManipulator->isNamedConstructor($classMethod)) { return \true; @@ -118,10 +118,10 @@ CODE_SAMPLE if ($this->controllerClassMethodManipulator->isControllerClassMethodWithBehaviorAnnotation($classMethod)) { return \true; } - if ($this->nodeNameResolver->isName($classMethod, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { - $class = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\Class_::class); - return $class instanceof \PhpParser\Node\Stmt\Class_ && $class->extends instanceof \PhpParser\Node\Name\FullyQualified; + if ($this->nodeNameResolver->isName($classMethod, MethodName::CONSTRUCT)) { + $class = $this->betterNodeFinder->findParentType($classMethod, Class_::class); + return $class instanceof Class_ && $class->extends instanceof FullyQualified; } - return $this->nodeNameResolver->isName($classMethod, \Rector\Core\ValueObject\MethodName::INVOKE); + return $this->nodeNameResolver->isName($classMethod, MethodName::INVOKE); } } diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveLastReturnRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveLastReturnRector.php index 2118405a802..227badb1252 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveLastReturnRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveLastReturnRector.php @@ -10,25 +10,25 @@ use PhpParser\Node\Stmt\Function_; use PhpParser\Node\Stmt\Return_; use Rector\Core\Rector\AbstractRector; use Rector\NodeNestingScope\ContextAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\ClassMethod\RemoveLastReturnRector\RemoveLastReturnRectorTest */ -final class RemoveLastReturnRector extends \Rector\Core\Rector\AbstractRector +final class RemoveLastReturnRector extends AbstractRector { /** * @readonly * @var \Rector\NodeNestingScope\ContextAnalyzer */ private $contextAnalyzer; - public function __construct(\Rector\NodeNestingScope\ContextAnalyzer $contextAnalyzer) + public function __construct(ContextAnalyzer $contextAnalyzer) { $this->contextAnalyzer = $contextAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove very last `return` that has no meaning', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove very last `return` that has no meaning', [new CodeSample(<<<'CODE_SAMPLE' function some_function($value) { if ($value === 1000) { @@ -58,17 +58,17 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\Closure::class]; + return [ClassMethod::class, Function_::class, Closure::class]; } /** * @param ClassMethod|Function_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { // last node and last return - $lastNode = $this->betterNodeFinder->findLastInstanceOf((array) $node->stmts, \PhpParser\Node::class); - $lastReturn = $this->betterNodeFinder->findLastInstanceOf((array) $node->stmts, \PhpParser\Node\Stmt\Return_::class); - if (!$lastReturn instanceof \PhpParser\Node\Stmt\Return_) { + $lastNode = $this->betterNodeFinder->findLastInstanceOf((array) $node->stmts, Node::class); + $lastReturn = $this->betterNodeFinder->findLastInstanceOf((array) $node->stmts, Return_::class); + if (!$lastReturn instanceof Return_) { return null; } if ($lastNode !== $lastReturn) { diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveUnusedConstructorParamRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveUnusedConstructorParamRector.php index 6cf0eeab4ee..2af2d99b370 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveUnusedConstructorParamRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveUnusedConstructorParamRector.php @@ -10,12 +10,12 @@ use Rector\Core\NodeAnalyzer\ParamAnalyzer; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\MethodName; use Rector\Removing\NodeManipulator\ComplexNodeRemover; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector\RemoveUnusedConstructorParamRectorTest */ -final class RemoveUnusedConstructorParamRector extends \Rector\Core\Rector\AbstractRector +final class RemoveUnusedConstructorParamRector extends AbstractRector { /** * @readonly @@ -27,14 +27,14 @@ final class RemoveUnusedConstructorParamRector extends \Rector\Core\Rector\Abstr * @var \Rector\Removing\NodeManipulator\ComplexNodeRemover */ private $complexNodeRemover; - public function __construct(\Rector\Core\NodeAnalyzer\ParamAnalyzer $paramAnalyzer, \Rector\Removing\NodeManipulator\ComplexNodeRemover $complexNodeRemover) + public function __construct(ParamAnalyzer $paramAnalyzer, ComplexNodeRemover $complexNodeRemover) { $this->paramAnalyzer = $paramAnalyzer; $this->complexNodeRemover = $complexNodeRemover; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove unused parameter in constructor', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove unused parameter in constructor', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { private $hey; @@ -63,14 +63,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isName($node, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if (!$this->isName($node, MethodName::CONSTRUCT)) { return null; } if ($node->params === []) { @@ -79,8 +79,8 @@ CODE_SAMPLE if ($this->paramAnalyzer->hasPropertyPromotion($node->params)) { return null; } - $class = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$class instanceof Class_) { return null; } if ($node->isAbstract()) { @@ -88,7 +88,7 @@ CODE_SAMPLE } return $this->processRemoveParams($node); } - private function processRemoveParams(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Stmt\ClassMethod + private function processRemoveParams(ClassMethod $classMethod) : ?ClassMethod { $paramKeysToBeRemoved = []; foreach ($classMethod->params as $key => $param) { diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveUnusedParamInRequiredAutowireRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveUnusedParamInRequiredAutowireRector.php index 83a1acac9f4..fc30e0ea28a 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveUnusedParamInRequiredAutowireRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveUnusedParamInRequiredAutowireRector.php @@ -8,25 +8,25 @@ use PhpParser\Node\Expr\Variable; use PhpParser\Node\Stmt\ClassMethod; use Rector\Core\Rector\AbstractRector; use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\ClassMethod\RemoveUnusedParamInRequiredAutowireRector\RemoveUnusedParamInRequiredAutowireRectorTest */ -final class RemoveUnusedParamInRequiredAutowireRector extends \Rector\Core\Rector\AbstractRector +final class RemoveUnusedParamInRequiredAutowireRector extends AbstractRector { /** * @readonly * @var \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer */ private $phpAttributeAnalyzer; - public function __construct(\Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer $phpAttributeAnalyzer) + public function __construct(PhpAttributeAnalyzer $phpAttributeAnalyzer) { $this->phpAttributeAnalyzer = $phpAttributeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove unused parameter in required autowire method', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove unused parameter in required autowire method', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Contracts\Service\Attribute\Required; final class SomeService @@ -59,12 +59,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -74,7 +74,7 @@ CODE_SAMPLE return null; } /** @var Variable[] $variables */ - $variables = $this->betterNodeFinder->findInstanceOf((array) $node->getStmts(), \PhpParser\Node\Expr\Variable::class); + $variables = $this->betterNodeFinder->findInstanceOf((array) $node->getStmts(), Variable::class); $hasRemovedParam = \false; foreach ($params as $param) { $paramVar = $param->var; @@ -91,7 +91,7 @@ CODE_SAMPLE } return $node; } - private function shouldSkip(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkip(ClassMethod $classMethod) : bool { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); $hasRequiredAnnotation = $phpDocInfo->hasByName('required'); diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveUnusedPrivateMethodParameterRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveUnusedPrivateMethodParameterRector.php index eadc980881d..8d2d4373d67 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveUnusedPrivateMethodParameterRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveUnusedPrivateMethodParameterRector.php @@ -14,12 +14,12 @@ use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover; use Rector\Core\Rector\AbstractRector; use Rector\DeadCode\NodeCollector\UnusedParameterResolver; use Rector\DeadCode\NodeManipulator\VariadicFunctionLikeDetector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodParameterRector\RemoveUnusedPrivateMethodParameterRectorTest */ -final class RemoveUnusedPrivateMethodParameterRector extends \Rector\Core\Rector\AbstractRector +final class RemoveUnusedPrivateMethodParameterRector extends AbstractRector { /** * @readonly @@ -36,15 +36,15 @@ final class RemoveUnusedPrivateMethodParameterRector extends \Rector\Core\Rector * @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover */ private $phpDocTagRemover; - public function __construct(\Rector\DeadCode\NodeManipulator\VariadicFunctionLikeDetector $variadicFunctionLikeDetector, \Rector\DeadCode\NodeCollector\UnusedParameterResolver $unusedParameterResolver, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover $phpDocTagRemover) + public function __construct(VariadicFunctionLikeDetector $variadicFunctionLikeDetector, UnusedParameterResolver $unusedParameterResolver, PhpDocTagRemover $phpDocTagRemover) { $this->variadicFunctionLikeDetector = $variadicFunctionLikeDetector; $this->unusedParameterResolver = $unusedParameterResolver; $this->phpDocTagRemover = $phpDocTagRemover; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove unused parameter, if not required by interface or parent class', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove unused parameter, if not required by interface or parent class', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { private function run($value, $value2) @@ -69,12 +69,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -91,10 +91,10 @@ CODE_SAMPLE /** * @param Param[] $unusedParameters */ - private function removeCallerArgs(\PhpParser\Node\Stmt\ClassMethod $classMethod, array $unusedParameters) : void + private function removeCallerArgs(ClassMethod $classMethod, array $unusedParameters) : void { - $classLike = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($classMethod, ClassLike::class); + if (!$classLike instanceof ClassLike) { return; } $methods = $classLike->getMethods(); @@ -117,7 +117,7 @@ CODE_SAMPLE /** * @param int[] $keysArg */ - private function cleanupArgs(\PhpParser\Node\Expr\MethodCall $methodCall, array $keysArg) : void + private function cleanupArgs(MethodCall $methodCall, array $keysArg) : void { $args = $methodCall->getArgs(); foreach (\array_keys($args) as $key) { @@ -130,13 +130,13 @@ CODE_SAMPLE /** * @return MethodCall[] */ - private function resolveCallers(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $methodName) : array + private function resolveCallers(ClassMethod $classMethod, string $methodName) : array { - return $this->betterNodeFinder->find($classMethod, function (\PhpParser\Node $subNode) use($methodName) : bool { - if (!$subNode instanceof \PhpParser\Node\Expr\MethodCall) { + return $this->betterNodeFinder->find($classMethod, function (Node $subNode) use($methodName) : bool { + if (!$subNode instanceof MethodCall) { return \false; } - if (!$subNode->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$subNode->var instanceof Variable) { return \false; } if (!$this->nodeNameResolver->isName($subNode->var, 'this')) { @@ -145,7 +145,7 @@ CODE_SAMPLE return $this->nodeNameResolver->isName($subNode->name, $methodName); }); } - private function shouldSkip(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkip(ClassMethod $classMethod) : bool { if (!$classMethod->isPrivate()) { return \true; @@ -158,7 +158,7 @@ CODE_SAMPLE /** * @param Param[] $unusedParameters */ - private function clearPhpDocInfo(\PhpParser\Node\Stmt\ClassMethod $classMethod, array $unusedParameters) : void + private function clearPhpDocInfo(ClassMethod $classMethod, array $unusedParameters) : void { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); foreach ($unusedParameters as $unusedParameter) { @@ -167,7 +167,7 @@ CODE_SAMPLE continue; } $paramTagValueNode = $phpDocInfo->getParamTagValueByName($parameterName); - if (!$paramTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode) { + if (!$paramTagValueNode instanceof ParamTagValueNode) { continue; } if ($paramTagValueNode->parameterName !== '$' . $parameterName) { diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveUnusedPrivateMethodRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveUnusedPrivateMethodRector.php index 45e9798ded2..96b557a2141 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveUnusedPrivateMethodRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveUnusedPrivateMethodRector.php @@ -13,12 +13,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; use Rector\Core\ValueObject\MethodName; use Rector\DeadCode\NodeAnalyzer\IsClassMethodUsedAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector\RemoveUnusedPrivateMethodRectorTest */ -final class RemoveUnusedPrivateMethodRector extends \Rector\Core\Rector\AbstractRector +final class RemoveUnusedPrivateMethodRector extends AbstractRector { /** * @readonly @@ -30,14 +30,14 @@ final class RemoveUnusedPrivateMethodRector extends \Rector\Core\Rector\Abstract * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\DeadCode\NodeAnalyzer\IsClassMethodUsedAnalyzer $isClassMethodUsedAnalyzer, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(IsClassMethodUsedAnalyzer $isClassMethodUsedAnalyzer, ReflectionResolver $reflectionResolver) { $this->isClassMethodUsedAnalyzer = $isClassMethodUsedAnalyzer; $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove unused private method', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove unused private method', [new CodeSample(<<<'CODE_SAMPLE' final class SomeController { public function run() @@ -67,12 +67,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -86,10 +86,10 @@ CODE_SAMPLE $this->removeNode($node); return $node; } - private function shouldSkip(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkip(ClassMethod $classMethod) : bool { $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \true; } // unreliable to detect trait, interface doesn't make sense @@ -110,26 +110,26 @@ CODE_SAMPLE if ($classMethod->isMagic()) { return \true; } - return $classReflection->hasMethod(\Rector\Core\ValueObject\MethodName::CALL); + return $classReflection->hasMethod(MethodName::CALL); } - private function hasDynamicMethodCallOnFetchThis(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function hasDynamicMethodCallOnFetchThis(ClassMethod $classMethod) : bool { - $class = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($classMethod, Class_::class); + if (!$class instanceof Class_) { return \false; } foreach ($class->getMethods() as $method) { - $isFound = (bool) $this->betterNodeFinder->findFirst((array) $method->getStmts(), function (\PhpParser\Node $subNode) : bool { - if (!$subNode instanceof \PhpParser\Node\Expr\MethodCall) { + $isFound = (bool) $this->betterNodeFinder->findFirst((array) $method->getStmts(), function (Node $subNode) : bool { + if (!$subNode instanceof MethodCall) { return \false; } - if (!$subNode->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$subNode->var instanceof Variable) { return \false; } if (!$this->nodeNameResolver->isName($subNode->var, 'this')) { return \false; } - return $subNode->name instanceof \PhpParser\Node\Expr\Variable; + return $subNode->name instanceof Variable; }); if ($isFound) { return \true; diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveUnusedPromotedPropertyRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveUnusedPromotedPropertyRector.php index 77f14297272..2ca1cb6358c 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveUnusedPromotedPropertyRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveUnusedPromotedPropertyRector.php @@ -15,12 +15,12 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Core\ValueObject\Visibility; use Rector\Privatization\NodeManipulator\VisibilityManipulator; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector\RemoveUnusedPromotedPropertyRectorTest */ -final class RemoveUnusedPromotedPropertyRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class RemoveUnusedPromotedPropertyRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -37,15 +37,15 @@ final class RemoveUnusedPromotedPropertyRector extends \Rector\Core\Rector\Abstr * @var \Rector\Privatization\NodeManipulator\VisibilityManipulator */ private $visibilityManipulator; - public function __construct(\Rector\Core\PhpParser\NodeFinder\PropertyFetchFinder $propertyFetchFinder, \Rector\Core\NodeManipulator\PropertyManipulator $propertyManipulator, \Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator) + public function __construct(PropertyFetchFinder $propertyFetchFinder, PropertyManipulator $propertyManipulator, VisibilityManipulator $visibilityManipulator) { $this->propertyFetchFinder = $propertyFetchFinder; $this->propertyManipulator = $propertyManipulator; $this->visibilityManipulator = $visibilityManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove unused promoted property', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove unused promoted property', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function __construct( @@ -81,24 +81,24 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $hasRemovedProperty = \false; - if (!$this->isName($node, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if (!$this->isName($node, MethodName::CONSTRUCT)) { return null; } - $class = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$class instanceof Class_) { return null; } foreach ($node->getParams() as $param) { // only private local scope; removing public property might be dangerous - if (!$this->visibilityManipulator->hasVisibility($param, \Rector\Core\ValueObject\Visibility::PRIVATE)) { + if (!$this->visibilityManipulator->hasVisibility($param, Visibility::PRIVATE)) { continue; } if ($this->propertyManipulator->isPropertyUsedInReadContext($class, $param)) { @@ -111,7 +111,7 @@ CODE_SAMPLE } // is variable used? only remove property, keep param $variable = $this->betterNodeFinder->findVariableOfName((array) $node->stmts, $paramName); - if ($variable instanceof \PhpParser\Node\Expr\Variable) { + if ($variable instanceof Variable) { $param->flags = 0; continue; } @@ -126,6 +126,6 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::PROPERTY_PROMOTION; + return PhpVersionFeature::PROPERTY_PROMOTION; } } diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveUselessParamTagRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveUselessParamTagRector.php index 0c3dfa01028..7bcd818350c 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveUselessParamTagRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveUselessParamTagRector.php @@ -8,25 +8,25 @@ use PhpParser\Node\Stmt\ClassMethod; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\Core\Rector\AbstractRector; use Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector\RemoveUselessParamTagRectorTest */ -final class RemoveUselessParamTagRector extends \Rector\Core\Rector\AbstractRector +final class RemoveUselessParamTagRector extends AbstractRector { /** * @readonly * @var \Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover */ private $paramTagRemover; - public function __construct(\Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover $paramTagRemover) + public function __construct(ParamTagRemover $paramTagRemover) { $this->paramTagRemover = $paramTagRemover; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove @param docblock with same type as parameter type', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove @param docblock with same type as parameter type', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { /** @@ -56,15 +56,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); - if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$phpDocInfo instanceof PhpDocInfo) { return null; } $hasChanged = $this->paramTagRemover->removeParamTagsIfUseless($phpDocInfo, $node); diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveUselessReturnTagRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveUselessReturnTagRector.php index 148d637cac3..6f7a142a6a9 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveUselessReturnTagRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveUselessReturnTagRector.php @@ -7,25 +7,25 @@ use PhpParser\Node; use PhpParser\Node\Stmt\ClassMethod; use Rector\Core\Rector\AbstractRector; use Rector\DeadCode\PhpDoc\TagRemover\ReturnTagRemover; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector\RemoveUselessReturnTagRectorTest */ -final class RemoveUselessReturnTagRector extends \Rector\Core\Rector\AbstractRector +final class RemoveUselessReturnTagRector extends AbstractRector { /** * @readonly * @var \Rector\DeadCode\PhpDoc\TagRemover\ReturnTagRemover */ private $returnTagRemover; - public function __construct(\Rector\DeadCode\PhpDoc\TagRemover\ReturnTagRemover $returnTagRemover) + public function __construct(ReturnTagRemover $returnTagRemover) { $this->returnTagRemover = $returnTagRemover; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove @return docblock with same type as defined in PHP', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove @return docblock with same type as defined in PHP', [new CodeSample(<<<'CODE_SAMPLE' use stdClass; class SomeClass @@ -55,12 +55,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $hasChanged = $this->returnTagRemover->removeReturnTagIfUseless($phpDocInfo, $node); diff --git a/rules/DeadCode/Rector/Concat/RemoveConcatAutocastRector.php b/rules/DeadCode/Rector/Concat/RemoveConcatAutocastRector.php index 43b22348ad1..06f51f720c3 100644 --- a/rules/DeadCode/Rector/Concat/RemoveConcatAutocastRector.php +++ b/rules/DeadCode/Rector/Concat/RemoveConcatAutocastRector.php @@ -8,16 +8,16 @@ use PhpParser\Node\Expr; use PhpParser\Node\Expr\BinaryOp\Concat; use PhpParser\Node\Expr\Cast\String_; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\Concat\RemoveConcatAutocastRector\RemoveConcatAutocastRectorTest */ -final class RemoveConcatAutocastRector extends \Rector\Core\Rector\AbstractRector +final class RemoveConcatAutocastRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove (string) casting when it comes to concat, that does this by default', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove (string) casting when it comes to concat, that does this by default', [new CodeSample(<<<'CODE_SAMPLE' class SomeConcatingClass { public function run($value) @@ -42,22 +42,22 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\Concat::class]; + return [Concat::class]; } /** * @param Concat $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->left instanceof \PhpParser\Node\Expr\Cast\String_ && !$node->right instanceof \PhpParser\Node\Expr\Cast\String_) { + if (!$node->left instanceof String_ && !$node->right instanceof String_) { return null; } $node->left = $this->removeStringCast($node->left); $node->right = $this->removeStringCast($node->right); return $node; } - private function removeStringCast(\PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr + private function removeStringCast(Expr $expr) : Expr { - return $expr instanceof \PhpParser\Node\Expr\Cast\String_ ? $expr->expr : $expr; + return $expr instanceof String_ ? $expr->expr : $expr; } } diff --git a/rules/DeadCode/Rector/ConstFetch/RemovePhpVersionIdCheckRector.php b/rules/DeadCode/Rector/ConstFetch/RemovePhpVersionIdCheckRector.php index e1e55cb875c..ba7387d986d 100644 --- a/rules/DeadCode/Rector/ConstFetch/RemovePhpVersionIdCheckRector.php +++ b/rules/DeadCode/Rector/ConstFetch/RemovePhpVersionIdCheckRector.php @@ -17,13 +17,13 @@ use Rector\Core\Php\PhpVersionProvider; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersion; use ReflectionClass; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\DeadCode\Rector\ConstFetch\RemovePhpVersionIdCheckRector\RemovePhpVersionIdCheckRectorTest */ -final class RemovePhpVersionIdCheckRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RemovePhpVersionIdCheckRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var PhpVersion::*|null @@ -34,7 +34,7 @@ final class RemovePhpVersionIdCheckRector extends \Rector\Core\Rector\AbstractRe * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PhpVersionProvider $phpVersionProvider) { $this->phpVersionProvider = $phpVersionProvider; } @@ -44,9 +44,9 @@ final class RemovePhpVersionIdCheckRector extends \Rector\Core\Rector\AbstractRe public function configure(array $configuration) : void { $phpVersion = $configuration[0]; - \RectorPrefix20220607\Webmozart\Assert\Assert::integer($phpVersion); + Assert::integer($phpVersion); // get all constants - $phpVersionReflectionClass = new \ReflectionClass(\Rector\Core\ValueObject\PhpVersion::class); + $phpVersionReflectionClass = new ReflectionClass(PhpVersion::class); // @todo check if (\in_array($phpVersion, $phpVersionReflectionClass->getConstants(), \true)) { return; @@ -55,9 +55,9 @@ final class RemovePhpVersionIdCheckRector extends \Rector\Core\Rector\AbstractRe /** @var PhpVersion::* $phpVersion */ $this->phpVersion = $phpVersion; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove unneeded PHP_VERSION_ID conditional checks', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove unneeded PHP_VERSION_ID conditional checks', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -79,20 +79,20 @@ class SomeClass } } CODE_SAMPLE -, [\Rector\Core\ValueObject\PhpVersion::PHP_80])]); +, [PhpVersion::PHP_80])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node * @return null|\PhpParser\Node\Stmt\If_|mixed[] */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { /** * $this->phpVersionProvider->provide() fallback is here as $currentFileProvider must be accessed after initialization @@ -100,14 +100,14 @@ CODE_SAMPLE if ($this->phpVersion === null) { $this->phpVersion = $this->phpVersionProvider->provide(); } - if (!$node->cond instanceof \PhpParser\Node\Expr\BinaryOp) { + if (!$node->cond instanceof BinaryOp) { return null; } $binaryOp = $node->cond; - if ($binaryOp->left instanceof \PhpParser\Node\Expr\ConstFetch && $this->isName($binaryOp->left->name, 'PHP_VERSION_ID')) { + if ($binaryOp->left instanceof ConstFetch && $this->isName($binaryOp->left->name, 'PHP_VERSION_ID')) { return $this->refactorConstFetch($binaryOp->left, $node, $binaryOp); } - if (!$binaryOp->right instanceof \PhpParser\Node\Expr\ConstFetch) { + if (!$binaryOp->right instanceof ConstFetch) { return null; } if (!$this->isName($binaryOp->right->name, 'PHP_VERSION_ID')) { @@ -118,7 +118,7 @@ CODE_SAMPLE /** * @return null|\PhpParser\Node\Stmt\If_|mixed[] */ - private function processSmaller(\PhpParser\Node\Expr\ConstFetch $constFetch, \PhpParser\Node\Expr\BinaryOp\Smaller $smaller, \PhpParser\Node\Stmt\If_ $if) + private function processSmaller(ConstFetch $constFetch, Smaller $smaller, If_ $if) { if ($smaller->left === $constFetch) { return $this->processSmallerLeft($smaller, $if); @@ -131,7 +131,7 @@ CODE_SAMPLE /** * @return null|\PhpParser\Node\Stmt\If_|mixed[] */ - private function processGreaterOrEqual(\PhpParser\Node\Expr\ConstFetch $constFetch, \PhpParser\Node\Expr\BinaryOp\GreaterOrEqual $greaterOrEqual, \PhpParser\Node\Stmt\If_ $if) + private function processGreaterOrEqual(ConstFetch $constFetch, GreaterOrEqual $greaterOrEqual, If_ $if) { if ($greaterOrEqual->left === $constFetch) { return $this->processGreaterOrEqualLeft($greaterOrEqual, $if); @@ -141,10 +141,10 @@ CODE_SAMPLE } return null; } - private function processSmallerLeft(\PhpParser\Node\Expr\BinaryOp\Smaller $smaller, \PhpParser\Node\Stmt\If_ $if) : ?\PhpParser\Node\Stmt\If_ + private function processSmallerLeft(Smaller $smaller, If_ $if) : ?If_ { $value = $smaller->right; - if (!$value instanceof \PhpParser\Node\Scalar\LNumber) { + if (!$value instanceof LNumber) { return null; } if ($this->phpVersion >= $value->value) { @@ -156,10 +156,10 @@ CODE_SAMPLE /** * @return null|\PhpParser\Node\Stmt\If_|mixed[] */ - private function processSmallerRight(\PhpParser\Node\Expr\BinaryOp\Smaller $smaller, \PhpParser\Node\Stmt\If_ $if) + private function processSmallerRight(Smaller $smaller, If_ $if) { $value = $smaller->left; - if (!$value instanceof \PhpParser\Node\Scalar\LNumber) { + if (!$value instanceof LNumber) { return null; } if ($this->phpVersion < $value->value) { @@ -174,10 +174,10 @@ CODE_SAMPLE /** * @return null|\PhpParser\Node\Stmt\If_|mixed[] */ - private function processGreaterOrEqualLeft(\PhpParser\Node\Expr\BinaryOp\GreaterOrEqual $greaterOrEqual, \PhpParser\Node\Stmt\If_ $if) + private function processGreaterOrEqualLeft(GreaterOrEqual $greaterOrEqual, If_ $if) { $value = $greaterOrEqual->right; - if (!$value instanceof \PhpParser\Node\Scalar\LNumber) { + if (!$value instanceof LNumber) { return null; } if ($this->phpVersion < $value->value) { @@ -189,10 +189,10 @@ CODE_SAMPLE } return $if->stmts; } - private function processGreaterOrEqualRight(\PhpParser\Node\Expr\BinaryOp\GreaterOrEqual $greaterOrEqual, \PhpParser\Node\Stmt\If_ $if) : ?\PhpParser\Node\Stmt\If_ + private function processGreaterOrEqualRight(GreaterOrEqual $greaterOrEqual, If_ $if) : ?If_ { $value = $greaterOrEqual->left; - if (!$value instanceof \PhpParser\Node\Scalar\LNumber) { + if (!$value instanceof LNumber) { return null; } if ($this->phpVersion >= $value->value) { @@ -204,7 +204,7 @@ CODE_SAMPLE /** * @return null|\PhpParser\Node\Stmt\If_|mixed[] */ - private function processGreater(\PhpParser\Node\Expr\ConstFetch $constFetch, \PhpParser\Node\Expr\BinaryOp\Greater $greater, \PhpParser\Node\Stmt\If_ $if) + private function processGreater(ConstFetch $constFetch, Greater $greater, If_ $if) { if ($greater->left === $constFetch) { return $this->processGreaterLeft($greater, $if); @@ -217,10 +217,10 @@ CODE_SAMPLE /** * @return null|\PhpParser\Node\Stmt\If_|mixed[] */ - private function processGreaterLeft(\PhpParser\Node\Expr\BinaryOp\Greater $greater, \PhpParser\Node\Stmt\If_ $if) + private function processGreaterLeft(Greater $greater, If_ $if) { $value = $greater->right; - if (!$value instanceof \PhpParser\Node\Scalar\LNumber) { + if (!$value instanceof LNumber) { return null; } if ($this->phpVersion < $value->value) { @@ -232,10 +232,10 @@ CODE_SAMPLE } return $if->stmts; } - private function processGreaterRight(\PhpParser\Node\Expr\BinaryOp\Greater $greater, \PhpParser\Node\Stmt\If_ $if) : ?\PhpParser\Node\Stmt\If_ + private function processGreaterRight(Greater $greater, If_ $if) : ?If_ { $value = $greater->left; - if (!$value instanceof \PhpParser\Node\Scalar\LNumber) { + if (!$value instanceof LNumber) { return null; } if ($this->phpVersion >= $value->value) { @@ -247,15 +247,15 @@ CODE_SAMPLE /** * @return null|\PhpParser\Node\Stmt\If_|mixed[] */ - private function refactorConstFetch(\PhpParser\Node\Expr\ConstFetch $constFetch, \PhpParser\Node\Stmt\If_ $if, \PhpParser\Node\Expr\BinaryOp $binaryOp) + private function refactorConstFetch(ConstFetch $constFetch, If_ $if, BinaryOp $binaryOp) { - if ($binaryOp instanceof \PhpParser\Node\Expr\BinaryOp\Smaller) { + if ($binaryOp instanceof Smaller) { return $this->processSmaller($constFetch, $binaryOp, $if); } - if ($binaryOp instanceof \PhpParser\Node\Expr\BinaryOp\GreaterOrEqual) { + if ($binaryOp instanceof GreaterOrEqual) { return $this->processGreaterOrEqual($constFetch, $binaryOp, $if); } - if ($binaryOp instanceof \PhpParser\Node\Expr\BinaryOp\Greater) { + if ($binaryOp instanceof Greater) { return $this->processGreater($constFetch, $binaryOp, $if); } return null; diff --git a/rules/DeadCode/Rector/Expression/RemoveDeadStmtRector.php b/rules/DeadCode/Rector/Expression/RemoveDeadStmtRector.php index 84cfe921954..98f32eb30d8 100644 --- a/rules/DeadCode/Rector/Expression/RemoveDeadStmtRector.php +++ b/rules/DeadCode/Rector/Expression/RemoveDeadStmtRector.php @@ -14,12 +14,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; use Rector\DeadCode\NodeManipulator\LivingCodeManipulator; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\Expression\RemoveDeadStmtRector\RemoveDeadStmtRectorTest */ -final class RemoveDeadStmtRector extends \Rector\Core\Rector\AbstractRector +final class RemoveDeadStmtRector extends AbstractRector { /** * @readonly @@ -36,15 +36,15 @@ final class RemoveDeadStmtRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\DeadCode\NodeManipulator\LivingCodeManipulator $livingCodeManipulator, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(LivingCodeManipulator $livingCodeManipulator, PropertyFetchAnalyzer $propertyFetchAnalyzer, ReflectionResolver $reflectionResolver) { $this->livingCodeManipulator = $livingCodeManipulator; $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Removes dead code statements', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Removes dead code statements', [new CodeSample(<<<'CODE_SAMPLE' $value = 5; $value; CODE_SAMPLE @@ -58,13 +58,13 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Expression::class]; + return [Expression::class]; } /** * @param Expression $node * @return Node[]|Node|null */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { if ($this->hasGetMagic($node)) { return null; @@ -80,12 +80,12 @@ CODE_SAMPLE $node->expr = $firstExpr; $newNodes = []; foreach ($livingCode as $singleLivingCode) { - $newNodes[] = new \PhpParser\Node\Stmt\Expression($singleLivingCode); + $newNodes[] = new Expression($singleLivingCode); } $newNodes[] = $node; return $newNodes; } - private function hasGetMagic(\PhpParser\Node\Stmt\Expression $expression) : bool + private function hasGetMagic(Expression $expression) : bool { if (!$this->propertyFetchAnalyzer->isPropertyFetch($expression->expr)) { return \false; @@ -97,14 +97,14 @@ CODE_SAMPLE * property not found assume has class has __get method * that can call non-defined property, that can have some special handling, eg: throw on special case */ - return !$phpPropertyReflection instanceof \PHPStan\Reflection\Php\PhpPropertyReflection; + return !$phpPropertyReflection instanceof PhpPropertyReflection; } - private function removeNodeAndKeepComments(\PhpParser\Node\Stmt\Expression $expression) : ?\PhpParser\Node + private function removeNodeAndKeepComments(Expression $expression) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($expression); if ($expression->getComments() !== []) { - $nop = new \PhpParser\Node\Stmt\Nop(); - $nop->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $phpDocInfo); + $nop = new Nop(); + $nop->setAttribute(AttributeKey::PHP_DOC_INFO, $phpDocInfo); $this->phpDocInfoFactory->createFromNode($nop); return $nop; } diff --git a/rules/DeadCode/Rector/Expression/SimplifyMirrorAssignRector.php b/rules/DeadCode/Rector/Expression/SimplifyMirrorAssignRector.php index 16fb423a03f..3fbd61f1369 100644 --- a/rules/DeadCode/Rector/Expression/SimplifyMirrorAssignRector.php +++ b/rules/DeadCode/Rector/Expression/SimplifyMirrorAssignRector.php @@ -7,16 +7,16 @@ use PhpParser\Node; use PhpParser\Node\Expr\Assign; use PhpParser\Node\Stmt\Expression; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\Expression\SimplifyMirrorAssignRector\SimplifyMirrorAssignRectorTest */ -final class SimplifyMirrorAssignRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyMirrorAssignRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Removes unneeded $a = $a assigns', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('function run() { + return new RuleDefinition('Removes unneeded $a = $a assigns', [new CodeSample('function run() { $a = $a; }', 'function run() { }')]); @@ -26,14 +26,14 @@ final class SimplifyMirrorAssignRector extends \Rector\Core\Rector\AbstractRecto */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Expression::class]; + return [Expression::class]; } /** * @param Expression $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$node->expr instanceof Assign) { return null; } /** @var Assign $assignNode */ diff --git a/rules/DeadCode/Rector/For_/RemoveDeadContinueRector.php b/rules/DeadCode/Rector/For_/RemoveDeadContinueRector.php index 5ae69e67611..adb5bc96c56 100644 --- a/rules/DeadCode/Rector/For_/RemoveDeadContinueRector.php +++ b/rules/DeadCode/Rector/For_/RemoveDeadContinueRector.php @@ -12,16 +12,16 @@ use PhpParser\Node\Stmt\For_; use PhpParser\Node\Stmt\Foreach_; use PhpParser\Node\Stmt\While_; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\For_\RemoveDeadContinueRector\RemoveDeadContinueRectorTest */ -final class RemoveDeadContinueRector extends \Rector\Core\Rector\AbstractRector +final class RemoveDeadContinueRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove useless continue at the end of loops', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove useless continue at the end of loops', [new CodeSample(<<<'CODE_SAMPLE' while ($i < 10) { ++$i; continue; @@ -39,12 +39,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Do_::class, \PhpParser\Node\Stmt\For_::class, \PhpParser\Node\Stmt\Foreach_::class, \PhpParser\Node\Stmt\While_::class]; + return [Do_::class, For_::class, Foreach_::class, While_::class]; } /** * @param Do_|For_|Foreach_|While_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $modified = \false; while ($this->canRemoveLastStatement($node->stmts)) { @@ -66,12 +66,12 @@ CODE_SAMPLE $lastStmt = $stmts[$lastKey]; return $this->isRemovable($lastStmt); } - private function isRemovable(\PhpParser\Node\Stmt $stmt) : bool + private function isRemovable(Stmt $stmt) : bool { - if (!$stmt instanceof \PhpParser\Node\Stmt\Continue_) { + if (!$stmt instanceof Continue_) { return \false; } - if ($stmt->num instanceof \PhpParser\Node\Scalar\LNumber) { + if ($stmt->num instanceof LNumber) { return $stmt->num->value < 2; } return \true; diff --git a/rules/DeadCode/Rector/For_/RemoveDeadIfForeachForRector.php b/rules/DeadCode/Rector/For_/RemoveDeadIfForeachForRector.php index aa574ae84f4..1353de42d2e 100644 --- a/rules/DeadCode/Rector/For_/RemoveDeadIfForeachForRector.php +++ b/rules/DeadCode/Rector/For_/RemoveDeadIfForeachForRector.php @@ -12,25 +12,25 @@ use PhpParser\Node\Stmt\Foreach_; use PhpParser\Node\Stmt\If_; use Rector\Core\Rector\AbstractRector; use Rector\EarlyReturn\NodeTransformer\ConditionInverter; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\For_\RemoveDeadIfForeachForRector\RemoveDeadIfForeachForRectorTest */ -final class RemoveDeadIfForeachForRector extends \Rector\Core\Rector\AbstractRector +final class RemoveDeadIfForeachForRector extends AbstractRector { /** * @readonly * @var \Rector\EarlyReturn\NodeTransformer\ConditionInverter */ private $conditionInverter; - public function __construct(\Rector\EarlyReturn\NodeTransformer\ConditionInverter $conditionInverter) + public function __construct(ConditionInverter $conditionInverter) { $this->conditionInverter = $conditionInverter; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove if, foreach and for that does not do anything', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove if, foreach and for that does not do anything', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($someObject) @@ -69,18 +69,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\For_::class, \PhpParser\Node\Stmt\If_::class, \PhpParser\Node\Stmt\Foreach_::class]; + return [For_::class, If_::class, Foreach_::class]; } /** * @param For_|If_|Foreach_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Stmt\If_) { + if ($node instanceof If_) { $this->processIf($node); return null; } - if ($node instanceof \PhpParser\Node\Stmt\Foreach_) { + if ($node instanceof Foreach_) { $this->processForeach($node); return null; } @@ -91,7 +91,7 @@ CODE_SAMPLE $this->removeNode($node); return null; } - private function processIf(\PhpParser\Node\Stmt\If_ $if) : void + private function processIf(If_ $if) : void { if ($if->stmts !== []) { return; @@ -110,7 +110,7 @@ CODE_SAMPLE } $this->removeNode($if); } - private function processForeach(\PhpParser\Node\Stmt\Foreach_ $foreach) : void + private function processForeach(Foreach_ $foreach) : void { if ($foreach->stmts !== []) { return; @@ -120,12 +120,12 @@ CODE_SAMPLE } $this->removeNode($foreach); } - private function isNodeWithSideEffect(\PhpParser\Node\Expr $expr) : bool + private function isNodeWithSideEffect(Expr $expr) : bool { - if ($expr instanceof \PhpParser\Node\Expr\Variable) { + if ($expr instanceof Variable) { return \false; } - if ($expr instanceof \PhpParser\Node\Scalar) { + if ($expr instanceof Scalar) { return \false; } return !$this->valueResolver->isTrueOrFalse($expr); diff --git a/rules/DeadCode/Rector/For_/RemoveDeadLoopRector.php b/rules/DeadCode/Rector/For_/RemoveDeadLoopRector.php index c97d6e98490..af9e6aa5185 100644 --- a/rules/DeadCode/Rector/For_/RemoveDeadLoopRector.php +++ b/rules/DeadCode/Rector/For_/RemoveDeadLoopRector.php @@ -9,16 +9,16 @@ use PhpParser\Node\Stmt\For_; use PhpParser\Node\Stmt\Foreach_; use PhpParser\Node\Stmt\While_; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\For_\RemoveDeadLoopRector\RemoveDeadLoopRectorTest */ -final class RemoveDeadLoopRector extends \Rector\Core\Rector\AbstractRector +final class RemoveDeadLoopRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove loop with no body', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove loop with no body', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($values) @@ -43,12 +43,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Do_::class, \PhpParser\Node\Stmt\For_::class, \PhpParser\Node\Stmt\Foreach_::class, \PhpParser\Node\Stmt\While_::class]; + return [Do_::class, For_::class, Foreach_::class, While_::class]; } /** * @param Do_|For_|Foreach_|While_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->stmts !== []) { return null; diff --git a/rules/DeadCode/Rector/Foreach_/RemoveUnusedForeachKeyRector.php b/rules/DeadCode/Rector/Foreach_/RemoveUnusedForeachKeyRector.php index c24f5e872fe..ea1d3cb9313 100644 --- a/rules/DeadCode/Rector/Foreach_/RemoveUnusedForeachKeyRector.php +++ b/rules/DeadCode/Rector/Foreach_/RemoveUnusedForeachKeyRector.php @@ -6,16 +6,16 @@ namespace Rector\DeadCode\Rector\Foreach_; use PhpParser\Node; use PhpParser\Node\Stmt\Foreach_; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\Foreach_\RemoveUnusedForeachKeyRector\RemoveUnusedForeachKeyRectorTest */ -final class RemoveUnusedForeachKeyRector extends \Rector\Core\Rector\AbstractRector +final class RemoveUnusedForeachKeyRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove unused key in foreach', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove unused key in foreach', [new CodeSample(<<<'CODE_SAMPLE' $items = []; foreach ($items as $key => $value) { $result = $value; @@ -34,18 +34,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Foreach_::class]; + return [Foreach_::class]; } /** * @param Foreach_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->keyVar === null) { return null; } $keyVar = $node->keyVar; - $isNodeUsed = (bool) $this->betterNodeFinder->findFirst($node->stmts, function (\PhpParser\Node $node) use($keyVar) : bool { + $isNodeUsed = (bool) $this->betterNodeFinder->findFirst($node->stmts, function (Node $node) use($keyVar) : bool { return $this->nodeComparator->areNodesEqual($node, $keyVar); }); if ($isNodeUsed) { diff --git a/rules/DeadCode/Rector/FunctionLike/RemoveDeadReturnRector.php b/rules/DeadCode/Rector/FunctionLike/RemoveDeadReturnRector.php index acd536635a5..3e4e482fae7 100644 --- a/rules/DeadCode/Rector/FunctionLike/RemoveDeadReturnRector.php +++ b/rules/DeadCode/Rector/FunctionLike/RemoveDeadReturnRector.php @@ -9,16 +9,16 @@ use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Function_; use PhpParser\Node\Stmt\Return_; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\FunctionLike\RemoveDeadReturnRector\RemoveDeadReturnRectorTest */ -final class RemoveDeadReturnRector extends \Rector\Core\Rector\AbstractRector +final class RemoveDeadReturnRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove last return in the functions, since does not do anything', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove last return in the functions, since does not do anything', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -53,12 +53,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\Closure::class]; + return [ClassMethod::class, Function_::class, Closure::class]; } /** * @param ClassMethod|Function_|Closure $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->stmts === []) { return null; @@ -68,7 +68,7 @@ CODE_SAMPLE } $stmtValues = \array_values($node->stmts); $lastStmt = \end($stmtValues); - if (!$lastStmt instanceof \PhpParser\Node\Stmt\Return_) { + if (!$lastStmt instanceof Return_) { return null; } if ($lastStmt->expr !== null) { diff --git a/rules/DeadCode/Rector/FunctionLike/RemoveDuplicatedIfReturnRector.php b/rules/DeadCode/Rector/FunctionLike/RemoveDuplicatedIfReturnRector.php index 2c9bb67550e..8e763a081c9 100644 --- a/rules/DeadCode/Rector/FunctionLike/RemoveDuplicatedIfReturnRector.php +++ b/rules/DeadCode/Rector/FunctionLike/RemoveDuplicatedIfReturnRector.php @@ -20,14 +20,14 @@ use Rector\Core\PhpParser\Comparing\NodeComparator; use Rector\Core\Rector\AbstractRector; use Rector\DeadCode\NodeCollector\ModifiedVariableNamesCollector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/rectorphp/rector/issues/2945 * * @see \Rector\Tests\DeadCode\Rector\FunctionLike\RemoveDuplicatedIfReturnRector\RemoveDuplicatedIfReturnRectorTest */ -final class RemoveDuplicatedIfReturnRector extends \Rector\Core\Rector\AbstractRector +final class RemoveDuplicatedIfReturnRector extends AbstractRector { /** * @readonly @@ -44,16 +44,16 @@ final class RemoveDuplicatedIfReturnRector extends \Rector\Core\Rector\AbstractR * @var \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer */ private $propertyFetchAnalyzer; - public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator, \Rector\DeadCode\NodeCollector\ModifiedVariableNamesCollector $modifiedVariableNamesCollector, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(IfManipulator $ifManipulator, ModifiedVariableNamesCollector $modifiedVariableNamesCollector, PropertyFetchAnalyzer $propertyFetchAnalyzer, NodeComparator $nodeComparator) { $this->ifManipulator = $ifManipulator; $this->modifiedVariableNamesCollector = $modifiedVariableNamesCollector; $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; $this->nodeComparator = $nodeComparator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove duplicated if stmt with return in function/method body', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove duplicated if stmt with return in function/method body', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($value) @@ -90,12 +90,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\FunctionLike::class]; + return [FunctionLike::class]; } /** * @param FunctionLike $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $ifWithOnlyReturnsByHash = $this->collectDuplicatedIfWithOnlyReturnByHash($node); if ($ifWithOnlyReturnsByHash === []) { @@ -131,19 +131,19 @@ CODE_SAMPLE } /** @var Expr $cond */ $cond = $ifWithOnlyReturns[0]->cond; - if (!\in_array(\get_class($cond), [\PhpParser\Node\Expr\Variable::class, \PhpParser\Node\Expr\PropertyFetch::class, \PhpParser\Node\Expr\StaticPropertyFetch::class], \true)) { + if (!\in_array(\get_class($cond), [Variable::class, PropertyFetch::class, StaticPropertyFetch::class], \true)) { return \false; } $type = $this->nodeTypeResolver->getType($cond); - if (!$type instanceof \PHPStan\Type\BooleanType) { + if (!$type instanceof BooleanType) { return \false; } - $next = $ifWithOnlyReturns[0]->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if (!$next instanceof \PhpParser\Node\Stmt\Return_) { + $next = $ifWithOnlyReturns[0]->getAttribute(AttributeKey::NEXT_NODE); + if (!$next instanceof Return_) { return \false; } $expr = $next->expr; - if (!$expr instanceof \PhpParser\Node\Expr) { + if (!$expr instanceof Expr) { return \false; } if (!$this->nodeComparator->areNodesEqual($expr, $cond)) { @@ -151,7 +151,7 @@ CODE_SAMPLE } /** @var Return_ $returnStmt */ $returnStmt = $ifWithOnlyReturns[0]->stmts[0]; - if (!$returnStmt->expr instanceof \PhpParser\Node\Expr) { + if (!$returnStmt->expr instanceof Expr) { return \false; } return $this->valueResolver->isValue($returnStmt->expr, \true); @@ -159,12 +159,12 @@ CODE_SAMPLE /** * @return If_[][] */ - private function collectDuplicatedIfWithOnlyReturnByHash(\PhpParser\Node\FunctionLike $functionLike) : array + private function collectDuplicatedIfWithOnlyReturnByHash(FunctionLike $functionLike) : array { $ifWithOnlyReturnsByHash = []; $modifiedVariableNames = []; foreach ((array) $functionLike->getStmts() as $stmt) { - if (!$this->ifManipulator->isIfWithOnly($stmt, \PhpParser\Node\Stmt\Return_::class)) { + if (!$this->ifManipulator->isIfWithOnly($stmt, Return_::class)) { // variable modification $modifiedVariableNames = \array_merge($modifiedVariableNames, $this->modifiedVariableNamesCollector->collectModifiedVariableNames($stmt)); continue; @@ -173,7 +173,7 @@ CODE_SAMPLE continue; } /** @var If_ $stmt */ - $isFoundPropertyFetch = (bool) $this->betterNodeFinder->findFirst($stmt->cond, function (\PhpParser\Node $node) : bool { + $isFoundPropertyFetch = (bool) $this->betterNodeFinder->findFirst($stmt->cond, function (Node $node) : bool { return $this->propertyFetchAnalyzer->isPropertyFetch($node); }); if ($isFoundPropertyFetch) { @@ -187,21 +187,21 @@ CODE_SAMPLE /** * @param string[] $modifiedVariableNames */ - private function containsVariableNames(\PhpParser\Node\Stmt $stmt, array $modifiedVariableNames) : bool + private function containsVariableNames(Stmt $stmt, array $modifiedVariableNames) : bool { if ($modifiedVariableNames === []) { return \false; } $containsVariableNames = \false; - $this->traverseNodesWithCallable($stmt, function (\PhpParser\Node $node) use($modifiedVariableNames, &$containsVariableNames) : ?int { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + $this->traverseNodesWithCallable($stmt, function (Node $node) use($modifiedVariableNames, &$containsVariableNames) : ?int { + if (!$node instanceof Variable) { return null; } if (!$this->isNames($node, $modifiedVariableNames)) { return null; } $containsVariableNames = \true; - return \PhpParser\NodeTraverser::STOP_TRAVERSAL; + return NodeTraverser::STOP_TRAVERSAL; }); return $containsVariableNames; } diff --git a/rules/DeadCode/Rector/FunctionLike/RemoveOverriddenValuesRector.php b/rules/DeadCode/Rector/FunctionLike/RemoveOverriddenValuesRector.php index 0802eda7eef..7045a4e85fe 100644 --- a/rules/DeadCode/Rector/FunctionLike/RemoveOverriddenValuesRector.php +++ b/rules/DeadCode/Rector/FunctionLike/RemoveOverriddenValuesRector.php @@ -15,12 +15,12 @@ use Rector\DeadCode\SideEffect\SideEffectNodeDetector; use Rector\DeadCode\ValueObject\VariableNodeUse; use Rector\NodeNestingScope\ContextAnalyzer; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\FunctionLike\RemoveOverriddenValuesRector\RemoveOverriddenValuesRectorTest */ -final class RemoveOverriddenValuesRector extends \Rector\Core\Rector\AbstractRector +final class RemoveOverriddenValuesRector extends AbstractRector { /** * @readonly @@ -47,7 +47,7 @@ final class RemoveOverriddenValuesRector extends \Rector\Core\Rector\AbstractRec * @var \Rector\DeadCode\SideEffect\SideEffectNodeDetector */ private $sideEffectNodeDetector; - public function __construct(\Rector\NodeNestingScope\ContextAnalyzer $contextAnalyzer, \Rector\DeadCode\NodeCollector\NodeByTypeAndPositionCollector $nodeByTypeAndPositionCollector, \Rector\DeadCode\NodeFinder\VariableUseFinder $variableUseFinder, \Rector\Core\Php\ReservedKeywordAnalyzer $reservedKeywordAnalyzer, \Rector\DeadCode\SideEffect\SideEffectNodeDetector $sideEffectNodeDetector) + public function __construct(ContextAnalyzer $contextAnalyzer, NodeByTypeAndPositionCollector $nodeByTypeAndPositionCollector, VariableUseFinder $variableUseFinder, ReservedKeywordAnalyzer $reservedKeywordAnalyzer, SideEffectNodeDetector $sideEffectNodeDetector) { $this->contextAnalyzer = $contextAnalyzer; $this->nodeByTypeAndPositionCollector = $nodeByTypeAndPositionCollector; @@ -55,9 +55,9 @@ final class RemoveOverriddenValuesRector extends \Rector\Core\Rector\AbstractRec $this->reservedKeywordAnalyzer = $reservedKeywordAnalyzer; $this->sideEffectNodeDetector = $sideEffectNodeDetector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove initial assigns of overridden values', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove initial assigns of overridden values', [new CodeSample(<<<'CODE_SAMPLE' final class SomeController { public function run() @@ -85,12 +85,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\FunctionLike::class]; + return [FunctionLike::class]; } /** * @param FunctionLike $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { // 1. collect assigns $assignedVariables = $this->resolveAssignedVariables($node); @@ -108,14 +108,14 @@ CODE_SAMPLE /** * @return Variable[] */ - private function resolveAssignedVariables(\PhpParser\Node\FunctionLike $functionLike) : array + private function resolveAssignedVariables(FunctionLike $functionLike) : array { - return $this->betterNodeFinder->find($functionLike, function (\PhpParser\Node $node) use($functionLike) : bool { - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node\Expr\Assign) { + return $this->betterNodeFinder->find($functionLike, function (Node $node) use($functionLike) : bool { + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof Assign) { return \false; } - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + if (!$node instanceof Variable) { return \false; } // skin in if @@ -124,7 +124,7 @@ CODE_SAMPLE } // is variable on the left /** @var Assign $assignNode */ - $assignNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $assignNode = $node->getAttribute(AttributeKey::PARENT_NODE); if ($assignNode->var !== $node) { return \false; } @@ -135,7 +135,7 @@ CODE_SAMPLE if (!\is_string($node->name)) { return \false; } - $parentFunctionLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\FunctionLike::class); + $parentFunctionLike = $this->betterNodeFinder->findParentType($node, FunctionLike::class); if ($parentFunctionLike !== $functionLike) { return \false; } @@ -169,7 +169,7 @@ CODE_SAMPLE $previousNode = null; foreach ($nodesByTypeAndPosition as $nodes) { $variableNode = $nodes->getVariableNode(); - $comments = $variableNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS); + $comments = $variableNode->getAttribute(AttributeKey::COMMENTS); if ($comments !== null) { continue; } @@ -189,26 +189,26 @@ CODE_SAMPLE } return $nodesToRemove; } - private function isAssignNodeUsed(?\Rector\DeadCode\ValueObject\VariableNodeUse $previousNode, \Rector\DeadCode\ValueObject\VariableNodeUse $nodeByTypeAndPosition) : bool + private function isAssignNodeUsed(?VariableNodeUse $previousNode, VariableNodeUse $nodeByTypeAndPosition) : bool { // this node was just used, skip to next one - if (!$previousNode instanceof \Rector\DeadCode\ValueObject\VariableNodeUse) { + if (!$previousNode instanceof VariableNodeUse) { return \false; } - if (!$previousNode->isType(\Rector\DeadCode\ValueObject\VariableNodeUse::TYPE_ASSIGN)) { + if (!$previousNode->isType(VariableNodeUse::TYPE_ASSIGN)) { return \false; } - return $nodeByTypeAndPosition->isType(\Rector\DeadCode\ValueObject\VariableNodeUse::TYPE_USE); + return $nodeByTypeAndPosition->isType(VariableNodeUse::TYPE_USE); } - private function shouldRemoveAssignNode(?\Rector\DeadCode\ValueObject\VariableNodeUse $previousNode, \Rector\DeadCode\ValueObject\VariableNodeUse $nodeByTypeAndPosition) : bool + private function shouldRemoveAssignNode(?VariableNodeUse $previousNode, VariableNodeUse $nodeByTypeAndPosition) : bool { if ($previousNode === null) { return \false; } - if (!$previousNode->isType(\Rector\DeadCode\ValueObject\VariableNodeUse::TYPE_ASSIGN)) { + if (!$previousNode->isType(VariableNodeUse::TYPE_ASSIGN)) { return \false; } - if (!$nodeByTypeAndPosition->isType(\Rector\DeadCode\ValueObject\VariableNodeUse::TYPE_ASSIGN)) { + if (!$nodeByTypeAndPosition->isType(VariableNodeUse::TYPE_ASSIGN)) { return \false; } // check the nesting level, e.g. call in if/while/else etc. @@ -220,7 +220,7 @@ CODE_SAMPLE // $someNode = $someNode ?: 1; /** @var Assign $assignNode */ $assignNode = $nodeByTypeAndPosition->getParentNode(); - $isVariableAssigned = (bool) $this->betterNodeFinder->findFirst($assignNode->expr, function (\PhpParser\Node $node) use($nodeByTypeAndPosition) : bool { + $isVariableAssigned = (bool) $this->betterNodeFinder->findFirst($assignNode->expr, function (Node $node) use($nodeByTypeAndPosition) : bool { return $this->nodeComparator->areNodesEqual($node, $nodeByTypeAndPosition->getVariableNode()); }); return !$isVariableAssigned; diff --git a/rules/DeadCode/Rector/If_/RemoveAlwaysTrueIfConditionRector.php b/rules/DeadCode/Rector/If_/RemoveAlwaysTrueIfConditionRector.php index 4f456a7f6c0..2b6edd2b847 100644 --- a/rules/DeadCode/Rector/If_/RemoveAlwaysTrueIfConditionRector.php +++ b/rules/DeadCode/Rector/If_/RemoveAlwaysTrueIfConditionRector.php @@ -8,16 +8,16 @@ use PhpParser\Node\Stmt; use PhpParser\Node\Stmt\If_; use PHPStan\Type\Constant\ConstantBooleanType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector\RemoveAlwaysTrueIfConditionRectorTest */ -final class RemoveAlwaysTrueIfConditionRector extends \Rector\Core\Rector\AbstractRector +final class RemoveAlwaysTrueIfConditionRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove if condition that is always true', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove if condition that is always true', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function go() @@ -48,13 +48,13 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node * @return \PhpParser\Node\Stmt\If_|null|mixed[] */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { if ($node->else !== null) { return null; @@ -64,7 +64,7 @@ CODE_SAMPLE return null; } $conditionStaticType = $this->getType($node->cond); - if (!$conditionStaticType instanceof \PHPStan\Type\Constant\ConstantBooleanType) { + if (!$conditionStaticType instanceof ConstantBooleanType) { return null; } if (!$conditionStaticType->getValue()) { diff --git a/rules/DeadCode/Rector/If_/RemoveDeadInstanceOfRector.php b/rules/DeadCode/Rector/If_/RemoveDeadInstanceOfRector.php index eac972b1ce8..c65cff6086a 100644 --- a/rules/DeadCode/Rector/If_/RemoveDeadInstanceOfRector.php +++ b/rules/DeadCode/Rector/If_/RemoveDeadInstanceOfRector.php @@ -24,12 +24,12 @@ use Rector\NodeNestingScope\ContextAnalyzer; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Php80\NodeAnalyzer\PromotedPropertyResolver; use Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\If_\RemoveDeadInstanceOfRector\RemoveDeadInstanceOfRectorTest */ -final class RemoveDeadInstanceOfRector extends \Rector\Core\Rector\AbstractRector +final class RemoveDeadInstanceOfRector extends AbstractRector { /** * @readonly @@ -56,7 +56,7 @@ final class RemoveDeadInstanceOfRector extends \Rector\Core\Rector\AbstractRecto * @var \Rector\NodeNestingScope\ContextAnalyzer */ private $contextAnalyzer; - public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector $constructorAssignDetector, \Rector\Php80\NodeAnalyzer\PromotedPropertyResolver $promotedPropertyResolver, \Rector\NodeNestingScope\ContextAnalyzer $contextAnalyzer) + public function __construct(IfManipulator $ifManipulator, PropertyFetchAnalyzer $propertyFetchAnalyzer, ConstructorAssignDetector $constructorAssignDetector, PromotedPropertyResolver $promotedPropertyResolver, ContextAnalyzer $contextAnalyzer) { $this->ifManipulator = $ifManipulator; $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; @@ -64,9 +64,9 @@ final class RemoveDeadInstanceOfRector extends \Rector\Core\Rector\AbstractRecto $this->promotedPropertyResolver = $promotedPropertyResolver; $this->contextAnalyzer = $contextAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove dead instanceof check on type hinted variable', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove dead instanceof check on type hinted variable', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function go(stdClass $stdClass) @@ -95,13 +95,13 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node * @return \PhpParser\Node\Stmt\If_|mixed[]|null */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { if (!$this->ifManipulator->isIfWithoutElseAndElseIfs($node)) { return null; @@ -109,14 +109,14 @@ CODE_SAMPLE if ($this->contextAnalyzer->isInLoop($node)) { return null; } - $originalCondNode = $node->cond->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE); - if (!$originalCondNode instanceof \PhpParser\Node) { + $originalCondNode = $node->cond->getAttribute(AttributeKey::ORIGINAL_NODE); + if (!$originalCondNode instanceof Node) { return null; } - if ($node->cond instanceof \PhpParser\Node\Expr\BooleanNot && $node->cond->expr instanceof \PhpParser\Node\Expr\Instanceof_) { + if ($node->cond instanceof BooleanNot && $node->cond->expr instanceof Instanceof_) { return $this->processMayDeadInstanceOf($node, $node->cond->expr); } - if ($node->cond instanceof \PhpParser\Node\Expr\Instanceof_) { + if ($node->cond instanceof Instanceof_) { return $this->processMayDeadInstanceOf($node, $node->cond); } return null; @@ -124,9 +124,9 @@ CODE_SAMPLE /** * @return null|mixed[]|\PhpParser\Node\Stmt\If_ */ - private function processMayDeadInstanceOf(\PhpParser\Node\Stmt\If_ $if, \PhpParser\Node\Expr\Instanceof_ $instanceof) + private function processMayDeadInstanceOf(If_ $if, Instanceof_ $instanceof) { - if (!$instanceof->class instanceof \PhpParser\Node\Name) { + if (!$instanceof->class instanceof Name) { return null; } $classType = $this->nodeTypeResolver->getType($instanceof->class); @@ -135,7 +135,7 @@ CODE_SAMPLE if (!$isSameStaticTypeOrSubtype) { return null; } - if (!$instanceof->expr instanceof \PhpParser\Node\Expr\Variable && !$this->isInPropertyPromotedParams($instanceof->expr) && $this->isSkippedPropertyFetch($instanceof->expr)) { + if (!$instanceof->expr instanceof Variable && !$this->isInPropertyPromotedParams($instanceof->expr) && $this->isSkippedPropertyFetch($instanceof->expr)) { return null; } if ($this->shouldSkipFromNotTypedParam($instanceof)) { @@ -147,15 +147,15 @@ CODE_SAMPLE $this->removeNode($if); return $if; } - private function shouldSkipFromNotTypedParam(\PhpParser\Node\Expr\Instanceof_ $instanceof) : bool + private function shouldSkipFromNotTypedParam(Instanceof_ $instanceof) : bool { - $functionLike = $this->betterNodeFinder->findParentType($instanceof, \PhpParser\Node\FunctionLike::class); - if (!$functionLike instanceof \PhpParser\Node\FunctionLike) { + $functionLike = $this->betterNodeFinder->findParentType($instanceof, FunctionLike::class); + if (!$functionLike instanceof FunctionLike) { return \false; } $variable = $instanceof->expr; - $isReassign = (bool) $this->betterNodeFinder->findFirstPrevious($instanceof, function (\PhpParser\Node $subNode) use($variable) : bool { - return $subNode instanceof \PhpParser\Node\Expr\Assign && $this->nodeComparator->areNodesEqual($subNode->var, $variable); + $isReassign = (bool) $this->betterNodeFinder->findFirstPrevious($instanceof, function (Node $subNode) use($variable) : bool { + return $subNode instanceof Assign && $this->nodeComparator->areNodesEqual($subNode->var, $variable); }); if ($isReassign) { return \false; @@ -168,33 +168,33 @@ CODE_SAMPLE } return \false; } - private function isSkippedPropertyFetch(\PhpParser\Node\Expr $expr) : bool + private function isSkippedPropertyFetch(Expr $expr) : bool { if (!$this->propertyFetchAnalyzer->isPropertyFetch($expr)) { return \true; } /** @var PropertyFetch|StaticPropertyFetch $propertyFetch */ $propertyFetch = $expr; - $classLike = $this->betterNodeFinder->findParentType($propertyFetch, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLike = $this->betterNodeFinder->findParentType($propertyFetch, Class_::class); + if (!$classLike instanceof Class_) { return \true; } /** @var string $propertyName */ $propertyName = $this->nodeNameResolver->getName($propertyFetch); $property = $classLike->getProperty($propertyName); - if (!$property instanceof \PhpParser\Node\Stmt\Property) { + if (!$property instanceof Property) { return \true; } $isPropertyAssignedInConstuctor = $this->constructorAssignDetector->isPropertyAssigned($classLike, $propertyName); return $property->type === null && !$isPropertyAssignedInConstuctor; } - private function isInPropertyPromotedParams(\PhpParser\Node\Expr $expr) : bool + private function isInPropertyPromotedParams(Expr $expr) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$expr instanceof PropertyFetch) { return \false; } - $classLike = $this->betterNodeFinder->findParentType($expr, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLike = $this->betterNodeFinder->findParentType($expr, Class_::class); + if (!$classLike instanceof Class_) { return \false; } /** @var string $propertyName */ diff --git a/rules/DeadCode/Rector/If_/RemoveUnusedNonEmptyArrayBeforeForeachRector.php b/rules/DeadCode/Rector/If_/RemoveUnusedNonEmptyArrayBeforeForeachRector.php index 0376b8bd9c0..cb86669e8b2 100644 --- a/rules/DeadCode/Rector/If_/RemoveUnusedNonEmptyArrayBeforeForeachRector.php +++ b/rules/DeadCode/Rector/If_/RemoveUnusedNonEmptyArrayBeforeForeachRector.php @@ -14,12 +14,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\DeadCode\NodeManipulator\CountManipulator; use Rector\DeadCode\UselessIfCondBeforeForeachDetector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector\RemoveUnusedNonEmptyArrayBeforeForeachRectorTest */ -final class RemoveUnusedNonEmptyArrayBeforeForeachRector extends \Rector\Core\Rector\AbstractRector +final class RemoveUnusedNonEmptyArrayBeforeForeachRector extends AbstractRector { /** * @readonly @@ -41,16 +41,16 @@ final class RemoveUnusedNonEmptyArrayBeforeForeachRector extends \Rector\Core\Re * @var \Rector\Core\Php\ReservedKeywordAnalyzer */ private $reservedKeywordAnalyzer; - public function __construct(\Rector\DeadCode\NodeManipulator\CountManipulator $countManipulator, \Rector\Core\NodeManipulator\IfManipulator $ifManipulator, \Rector\DeadCode\UselessIfCondBeforeForeachDetector $uselessIfCondBeforeForeachDetector, \Rector\Core\Php\ReservedKeywordAnalyzer $reservedKeywordAnalyzer) + public function __construct(CountManipulator $countManipulator, IfManipulator $ifManipulator, UselessIfCondBeforeForeachDetector $uselessIfCondBeforeForeachDetector, ReservedKeywordAnalyzer $reservedKeywordAnalyzer) { $this->countManipulator = $countManipulator; $this->ifManipulator = $ifManipulator; $this->uselessIfCondBeforeForeachDetector = $uselessIfCondBeforeForeachDetector; $this->reservedKeywordAnalyzer = $reservedKeywordAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove unused if check to non-empty array before foreach of the array', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove unused if check to non-empty array before foreach of the array', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -83,32 +83,32 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isUselessBeforeForeachCheck($node)) { return null; } $stmt = $node->stmts[0]; - $ifComments = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS) ?? []; - $stmtComments = $stmt->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS) ?? []; + $ifComments = $node->getAttribute(AttributeKey::COMMENTS) ?? []; + $stmtComments = $stmt->getAttribute(AttributeKey::COMMENTS) ?? []; $comments = \array_merge($ifComments, $stmtComments); - $stmt->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $comments); + $stmt->setAttribute(AttributeKey::COMMENTS, $comments); return $stmt; } - private function isUselessBeforeForeachCheck(\PhpParser\Node\Stmt\If_ $if) : bool + private function isUselessBeforeForeachCheck(If_ $if) : bool { - if (!$this->ifManipulator->isIfWithOnly($if, \PhpParser\Node\Stmt\Foreach_::class)) { + if (!$this->ifManipulator->isIfWithOnly($if, Foreach_::class)) { return \false; } /** @var Foreach_ $foreach */ $foreach = $if->stmts[0]; $foreachExpr = $foreach->expr; - if ($foreachExpr instanceof \PhpParser\Node\Expr\Variable) { + if ($foreachExpr instanceof Variable) { $variableName = $this->nodeNameResolver->getName($foreachExpr); if (\is_string($variableName) && $this->reservedKeywordAnalyzer->isNativeVariable($variableName)) { return \false; @@ -122,7 +122,7 @@ CODE_SAMPLE } // we know it's an array $condType = $this->getType($if->cond); - if ($condType instanceof \PHPStan\Type\ArrayType) { + if ($condType instanceof ArrayType) { return \true; } return $this->countManipulator->isCounterHigherThanOne($if->cond, $foreachExpr); diff --git a/rules/DeadCode/Rector/If_/SimplifyIfElseWithSameContentRector.php b/rules/DeadCode/Rector/If_/SimplifyIfElseWithSameContentRector.php index 7dc77cf2a3c..eea649edb31 100644 --- a/rules/DeadCode/Rector/If_/SimplifyIfElseWithSameContentRector.php +++ b/rules/DeadCode/Rector/If_/SimplifyIfElseWithSameContentRector.php @@ -10,25 +10,25 @@ use PhpParser\Node\Stmt\If_; use Rector\Core\Contract\PhpParser\NodePrinterInterface; use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\If_\SimplifyIfElseWithSameContentRector\SimplifyIfElseWithSameContentRectorTest */ -final class SimplifyIfElseWithSameContentRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyIfElseWithSameContentRector extends AbstractRector { /** * @readonly * @var \Rector\Core\Contract\PhpParser\NodePrinterInterface */ private $nodePrinter; - public function __construct(\Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter) + public function __construct(NodePrinterInterface $nodePrinter) { $this->nodePrinter = $nodePrinter; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove if/else if they have same content', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove if/else if they have same content', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -57,13 +57,13 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node * @return Stmt[]|null */ - public function refactor(\PhpParser\Node $node) : ?array + public function refactor(Node $node) : ?array { if ($node->else === null) { return null; @@ -73,7 +73,7 @@ CODE_SAMPLE } return $node->stmts; } - private function isIfWithConstantReturns(\PhpParser\Node\Stmt\If_ $if) : bool + private function isIfWithConstantReturns(If_ $if) : bool { $possibleContents = []; $possibleContents[] = $this->nodePrinter->print($if->stmts); @@ -81,8 +81,8 @@ CODE_SAMPLE $possibleContents[] = $this->nodePrinter->print($elseif->stmts); } $else = $if->else; - if (!$else instanceof \PhpParser\Node\Stmt\Else_) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$else instanceof Else_) { + throw new ShouldNotHappenException(); } $possibleContents[] = $this->nodePrinter->print($else->stmts); $uniqueContents = \array_unique($possibleContents); diff --git a/rules/DeadCode/Rector/If_/UnwrapFutureCompatibleIfFunctionExistsRector.php b/rules/DeadCode/Rector/If_/UnwrapFutureCompatibleIfFunctionExistsRector.php index a66a4e87770..45057c70b41 100644 --- a/rules/DeadCode/Rector/If_/UnwrapFutureCompatibleIfFunctionExistsRector.php +++ b/rules/DeadCode/Rector/If_/UnwrapFutureCompatibleIfFunctionExistsRector.php @@ -13,12 +13,12 @@ use PHPStan\Type\ObjectType; use Rector\Core\NodeManipulator\IfManipulator; use Rector\Core\Rector\AbstractRector; use Rector\DeadCode\FeatureSupport\FunctionSupportResolver; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector\UnwrapFutureCompatibleIfFunctionExistsRectorTest */ -final class UnwrapFutureCompatibleIfFunctionExistsRector extends \Rector\Core\Rector\AbstractRector +final class UnwrapFutureCompatibleIfFunctionExistsRector extends AbstractRector { /** * @readonly @@ -30,14 +30,14 @@ final class UnwrapFutureCompatibleIfFunctionExistsRector extends \Rector\Core\Re * @var \Rector\Core\NodeManipulator\IfManipulator */ private $ifManipulator; - public function __construct(\Rector\DeadCode\FeatureSupport\FunctionSupportResolver $functionSupportResolver, \Rector\Core\NodeManipulator\IfManipulator $ifManipulator) + public function __construct(FunctionSupportResolver $functionSupportResolver, IfManipulator $ifManipulator) { $this->functionSupportResolver = $functionSupportResolver; $this->ifManipulator = $ifManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove functions exists if with else for always existing', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove functions exists if with else for always existing', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -68,13 +68,13 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node * @return null|Stmt[] */ - public function refactor(\PhpParser\Node $node) : ?array + public function refactor(Node $node) : ?array { if ($this->shouldSkip($node)) { return null; @@ -88,7 +88,7 @@ CODE_SAMPLE if (!isset($funcCall->args[0])) { return null; } - if (!$funcCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[0] instanceof Arg) { return null; } $functionToExistName = $this->valueResolver->getValue($funcCall->args[0]->value); @@ -100,13 +100,13 @@ CODE_SAMPLE } return $node->stmts; } - private function shouldSkip(\PhpParser\Node\Stmt\If_ $if) : bool + private function shouldSkip(If_ $if) : bool { - $classLike = $this->betterNodeFinder->findParentType($if, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($if, ClassLike::class); + if (!$classLike instanceof ClassLike) { return \false; } // skip rector rules, as they decided if function exists in that particular projects - return $this->isObjectType($classLike, new \PHPStan\Type\ObjectType('Rector\\Core\\Contract\\Rector\\RectorInterface')); + return $this->isObjectType($classLike, new ObjectType('Rector\\Core\\Contract\\Rector\\RectorInterface')); } } diff --git a/rules/DeadCode/Rector/If_/UnwrapFutureCompatibleIfPhpVersionRector.php b/rules/DeadCode/Rector/If_/UnwrapFutureCompatibleIfPhpVersionRector.php index d3577ed4093..21c9c2b2088 100644 --- a/rules/DeadCode/Rector/If_/UnwrapFutureCompatibleIfPhpVersionRector.php +++ b/rules/DeadCode/Rector/If_/UnwrapFutureCompatibleIfPhpVersionRector.php @@ -10,14 +10,14 @@ use Rector\Core\Rector\AbstractRector; use Rector\DeadCode\ConditionEvaluator; use Rector\DeadCode\ConditionResolver; use Rector\DeadCode\Contract\ConditionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/function.version-compare.php * * @see \Rector\Tests\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector\UnwrapFutureCompatibleIfPhpVersionRectorTest */ -final class UnwrapFutureCompatibleIfPhpVersionRector extends \Rector\Core\Rector\AbstractRector +final class UnwrapFutureCompatibleIfPhpVersionRector extends AbstractRector { /** * @readonly @@ -29,14 +29,14 @@ final class UnwrapFutureCompatibleIfPhpVersionRector extends \Rector\Core\Rector * @var \Rector\DeadCode\ConditionResolver */ private $conditionResolver; - public function __construct(\Rector\DeadCode\ConditionEvaluator $conditionEvaluator, \Rector\DeadCode\ConditionResolver $conditionResolver) + public function __construct(ConditionEvaluator $conditionEvaluator, ConditionResolver $conditionResolver) { $this->conditionEvaluator = $conditionEvaluator; $this->conditionResolver = $conditionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove php version checks if they are passed', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove php version checks if they are passed', [new CodeSample(<<<'CODE_SAMPLE' // current PHP: 7.2 if (version_compare(PHP_VERSION, '7.2', '<')) { return 'is PHP 7.1-'; @@ -55,19 +55,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node * @return Stmt[]|null */ - public function refactor(\PhpParser\Node $node) : ?array + public function refactor(Node $node) : ?array { if ($node->elseifs !== []) { return null; } $condition = $this->conditionResolver->resolveFromExpr($node->cond); - if (!$condition instanceof \Rector\DeadCode\Contract\ConditionInterface) { + if (!$condition instanceof ConditionInterface) { return null; } $result = $this->conditionEvaluator->evaluate($condition); @@ -86,7 +86,7 @@ CODE_SAMPLE /** * @return Stmt[]|null */ - private function refactorIsMatch(\PhpParser\Node\Stmt\If_ $if) : ?array + private function refactorIsMatch(If_ $if) : ?array { if ($if->elseifs !== []) { return null; @@ -96,7 +96,7 @@ CODE_SAMPLE /** * @return Stmt[]|null */ - private function refactorIsNotMatch(\PhpParser\Node\Stmt\If_ $if) : ?array + private function refactorIsNotMatch(If_ $if) : ?array { // no else → just remove the node if ($if->else === null) { diff --git a/rules/DeadCode/Rector/MethodCall/RemoveEmptyMethodCallRector.php b/rules/DeadCode/Rector/MethodCall/RemoveEmptyMethodCallRector.php index c7cd42bd714..9cfabbe6489 100644 --- a/rules/DeadCode/Rector/MethodCall/RemoveEmptyMethodCallRector.php +++ b/rules/DeadCode/Rector/MethodCall/RemoveEmptyMethodCallRector.php @@ -24,12 +24,12 @@ use Rector\Core\NodeAnalyzer\CallAnalyzer; use Rector\Core\PhpParser\AstResolver; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\MethodCall\RemoveEmptyMethodCallRector\RemoveEmptyMethodCallRectorTest */ -final class RemoveEmptyMethodCallRector extends \Rector\Core\Rector\AbstractRector +final class RemoveEmptyMethodCallRector extends AbstractRector { /** * @readonly @@ -41,14 +41,14 @@ final class RemoveEmptyMethodCallRector extends \Rector\Core\Rector\AbstractRect * @var \Rector\Core\NodeAnalyzer\CallAnalyzer */ private $callAnalyzer; - public function __construct(\Rector\Core\PhpParser\AstResolver $reflectionAstResolver, \Rector\Core\NodeAnalyzer\CallAnalyzer $callAnalyzer) + public function __construct(AstResolver $reflectionAstResolver, CallAnalyzer $callAnalyzer) { $this->reflectionAstResolver = $reflectionAstResolver; $this->callAnalyzer = $callAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove empty method call', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove empty method call', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function callThis() @@ -76,56 +76,56 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $scope = $this->getScope($node); - if (!$scope instanceof \PHPStan\Analyser\Scope) { + if (!$scope instanceof Scope) { return null; } $type = $scope->getType($node->var); - if (!$type instanceof \PHPStan\Type\TypeWithClassName) { + if (!$type instanceof TypeWithClassName) { return null; } $classLike = $this->reflectionAstResolver->resolveClassFromObjectType($type); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + if (!$classLike instanceof ClassLike) { return null; } if ($this->shouldSkipClassMethod($classLike, $node, $type)) { return null; } // if->cond cannot removed, it has to be replaced with false, see https://3v4l.org/U9S9i - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\Stmt\If_ && $parent->cond === $node) { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof If_ && $parent->cond === $node) { return $this->nodeFactory->createFalse(); } - if ($parent instanceof \PhpParser\Node\Expr\Assign) { + if ($parent instanceof Assign) { return $this->nodeFactory->createFalse(); } - if ($parent instanceof \PhpParser\Node\Expr\ArrowFunction && $this->nodeComparator->areNodesEqual($parent->expr, $node)) { + if ($parent instanceof ArrowFunction && $this->nodeComparator->areNodesEqual($parent->expr, $node)) { return $this->processArrowFunction($parent, $node); } - if (!$parent instanceof \PhpParser\Node\Stmt\Expression) { + if (!$parent instanceof Expression) { return null; } $this->removeNode($node); return $node; } - private function getScope(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PHPStan\Analyser\Scope + private function getScope(MethodCall $methodCall) : ?Scope { if ($this->callAnalyzer->isObjectCall($methodCall->var)) { return null; } - $parentArg = $this->betterNodeFinder->findParentType($methodCall, \PhpParser\Node\Arg::class); - if ($parentArg instanceof \PhpParser\Node\Arg) { + $parentArg = $this->betterNodeFinder->findParentType($methodCall, Arg::class); + if ($parentArg instanceof Arg) { return null; } - $scope = $methodCall->var->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { + $scope = $methodCall->var->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { return null; } return $scope; @@ -133,9 +133,9 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Trait_|\PhpParser\Node\Stmt\Interface_|\PhpParser\Node\Stmt\Enum_ $classLike */ - private function shouldSkipClassMethod($classLike, \PhpParser\Node\Expr\MethodCall $methodCall, \PHPStan\Type\TypeWithClassName $typeWithClassName) : bool + private function shouldSkipClassMethod($classLike, MethodCall $methodCall, TypeWithClassName $typeWithClassName) : bool { - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + if (!$classLike instanceof Class_) { return \true; } $methodName = $this->getName($methodCall->name); @@ -143,7 +143,7 @@ CODE_SAMPLE return \true; } $classMethod = $classLike->getMethod($methodName); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$classMethod instanceof ClassMethod) { return \true; } if ($classMethod->isAbstract()) { @@ -152,11 +152,11 @@ CODE_SAMPLE if ((array) $classMethod->stmts !== []) { return \true; } - $class = $this->betterNodeFinder->findParentType($methodCall, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($methodCall, Class_::class); + if (!$class instanceof Class_) { return \false; } - if (!$typeWithClassName instanceof \PHPStan\Type\ThisType) { + if (!$typeWithClassName instanceof ThisType) { return \false; } if ($class->isFinal()) { @@ -167,10 +167,10 @@ CODE_SAMPLE /** * @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\ConstFetch */ - private function processArrowFunction(\PhpParser\Node\Expr\ArrowFunction $arrowFunction, \PhpParser\Node\Expr\MethodCall $methodCall) + private function processArrowFunction(ArrowFunction $arrowFunction, MethodCall $methodCall) { - $parentOfParent = $arrowFunction->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentOfParent instanceof \PhpParser\Node\Stmt\Expression) { + $parentOfParent = $arrowFunction->getAttribute(AttributeKey::PARENT_NODE); + if ($parentOfParent instanceof Expression) { $this->removeNode($arrowFunction); return $methodCall; } diff --git a/rules/DeadCode/Rector/Node/RemoveNonExistingVarAnnotationRector.php b/rules/DeadCode/Rector/Node/RemoveNonExistingVarAnnotationRector.php index c61aa20c10d..a0919be08d0 100644 --- a/rules/DeadCode/Rector/Node/RemoveNonExistingVarAnnotationRector.php +++ b/rules/DeadCode/Rector/Node/RemoveNonExistingVarAnnotationRector.php @@ -22,19 +22,19 @@ use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode; use Rector\Core\Rector\AbstractRector; use Rector\DeadCode\NodeAnalyzer\ExprUsedInNodeAnalyzer; use RectorPrefix20220607\Symplify\PackageBuilder\Php\TypeChecker; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector\RemoveNonExistingVarAnnotationRectorTest * * @changelog https://github.com/phpstan/phpstan/commit/d17e459fd9b45129c5deafe12bca56f30ea5ee99#diff-9f3541876405623b0d18631259763dc1 */ -final class RemoveNonExistingVarAnnotationRector extends \Rector\Core\Rector\AbstractRector +final class RemoveNonExistingVarAnnotationRector extends AbstractRector { /** * @var array> */ - private const NODES_TO_MATCH = [\PhpParser\Node\Expr\Assign::class, \PhpParser\Node\Expr\AssignRef::class, \PhpParser\Node\Stmt\Foreach_::class, \PhpParser\Node\Stmt\Static_::class, \PhpParser\Node\Stmt\Echo_::class, \PhpParser\Node\Stmt\Return_::class, \PhpParser\Node\Stmt\Expression::class, \PhpParser\Node\Stmt\Throw_::class, \PhpParser\Node\Stmt\If_::class, \PhpParser\Node\Stmt\While_::class, \PhpParser\Node\Stmt\Switch_::class, \PhpParser\Node\Stmt\Nop::class]; + private const NODES_TO_MATCH = [Assign::class, AssignRef::class, Foreach_::class, Static_::class, Echo_::class, Return_::class, Expression::class, Throw_::class, If_::class, While_::class, Switch_::class, Nop::class]; /** * @readonly * @var \Symplify\PackageBuilder\Php\TypeChecker @@ -45,14 +45,14 @@ final class RemoveNonExistingVarAnnotationRector extends \Rector\Core\Rector\Abs * @var \Rector\DeadCode\NodeAnalyzer\ExprUsedInNodeAnalyzer */ private $exprUsedInNodeAnalyzer; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Php\TypeChecker $typeChecker, \Rector\DeadCode\NodeAnalyzer\ExprUsedInNodeAnalyzer $exprUsedInNodeAnalyzer) + public function __construct(TypeChecker $typeChecker, ExprUsedInNodeAnalyzer $exprUsedInNodeAnalyzer) { $this->typeChecker = $typeChecker; $this->exprUsedInNodeAnalyzer = $exprUsedInNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Removes non-existing @var annotations above the code', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Removes non-existing @var annotations above the code', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function get() @@ -78,16 +78,16 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node::class]; + return [Node::class]; } - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $varTagValueNode = $phpDocInfo->getVarTagValueNode(); - if (!$varTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) { + if (!$varTagValueNode instanceof VarTagValueNode) { return null; } $variableName = \ltrim($varTagValueNode->variableName, '$'); @@ -102,28 +102,28 @@ CODE_SAMPLE // skip edge case with double comment, as impossible to resolve by PHPStan doc parser return null; } - $phpDocInfo->removeByType(\PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode::class); + $phpDocInfo->removeByType(VarTagValueNode::class); return $node; } - private function isUsedInNextNodeWithExtractPreviouslyCalled(\PhpParser\Node $node, string $variableName) : bool + private function isUsedInNextNodeWithExtractPreviouslyCalled(Node $node, string $variableName) : bool { - $variable = new \PhpParser\Node\Expr\Variable($variableName); - $isUsedInNextNode = (bool) $this->betterNodeFinder->findFirstNext($node, function (\PhpParser\Node $node) use($variable) : bool { + $variable = new Variable($variableName); + $isUsedInNextNode = (bool) $this->betterNodeFinder->findFirstNext($node, function (Node $node) use($variable) : bool { return $this->exprUsedInNodeAnalyzer->isUsed($node, $variable); }); if (!$isUsedInNextNode) { return \false; } - return (bool) $this->betterNodeFinder->findFirstPrevious($node, function (\PhpParser\Node $subNode) : bool { - if (!$subNode instanceof \PhpParser\Node\Expr\FuncCall) { + return (bool) $this->betterNodeFinder->findFirstPrevious($node, function (Node $subNode) : bool { + if (!$subNode instanceof FuncCall) { return \false; } return $this->nodeNameResolver->isName($subNode, 'extract'); }); } - private function shouldSkip(\PhpParser\Node $node) : bool + private function shouldSkip(Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Stmt\Nop) { + if (!$node instanceof Nop) { return !$this->typeChecker->isInstanceOf($node, self::NODES_TO_MATCH); } if (\count($node->getComments()) <= 1) { @@ -131,10 +131,10 @@ CODE_SAMPLE } return \true; } - private function hasVariableName(\PhpParser\Node $node, string $variableName) : bool + private function hasVariableName(Node $node, string $variableName) : bool { - return (bool) $this->betterNodeFinder->findFirst($node, function (\PhpParser\Node $node) use($variableName) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + return (bool) $this->betterNodeFinder->findFirst($node, function (Node $node) use($variableName) : bool { + if (!$node instanceof Variable) { return \false; } return $this->isName($node, $variableName); diff --git a/rules/DeadCode/Rector/Plus/RemoveDeadZeroAndOneOperationRector.php b/rules/DeadCode/Rector/Plus/RemoveDeadZeroAndOneOperationRector.php index 8ba154738da..63e92efe37d 100644 --- a/rules/DeadCode/Rector/Plus/RemoveDeadZeroAndOneOperationRector.php +++ b/rules/DeadCode/Rector/Plus/RemoveDeadZeroAndOneOperationRector.php @@ -16,18 +16,18 @@ use PhpParser\Node\Expr\BinaryOp\Mul; use PhpParser\Node\Expr\BinaryOp\Plus; use PhpParser\Node\Expr\UnaryMinus; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/I0BGs * * @see \Rector\Tests\DeadCode\Rector\Plus\RemoveDeadZeroAndOneOperationRector\RemoveDeadZeroAndOneOperationRectorTest */ -final class RemoveDeadZeroAndOneOperationRector extends \Rector\Core\Rector\AbstractRector +final class RemoveDeadZeroAndOneOperationRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove operation with 1 and 0, that have no effect on the value', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove operation with 1 and 0, that have no effect on the value', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -54,23 +54,23 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\Plus::class, \PhpParser\Node\Expr\BinaryOp\Minus::class, \PhpParser\Node\Expr\BinaryOp\Mul::class, \PhpParser\Node\Expr\BinaryOp\Div::class, \PhpParser\Node\Expr\AssignOp\Plus::class, \PhpParser\Node\Expr\AssignOp\Minus::class, \PhpParser\Node\Expr\AssignOp\Mul::class, \PhpParser\Node\Expr\AssignOp\Div::class]; + return [Plus::class, Minus::class, Mul::class, Div::class, AssignPlus::class, AssignMinus::class, AssignMul::class, AssignDiv::class]; } /** * @param Plus|Minus|Mul|Div|AssignPlus|AssignMinus|AssignMul|AssignDiv $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\AssignOp) { + if ($node instanceof AssignOp) { return $this->processAssignOp($node); } // -, + return $this->processBinaryOp($node); } - private function processAssignOp(\PhpParser\Node\Expr\AssignOp $assignOp) : ?\PhpParser\Node\Expr + private function processAssignOp(AssignOp $assignOp) : ?Expr { // +=, -= - if ($assignOp instanceof \PhpParser\Node\Expr\AssignOp\Plus || $assignOp instanceof \PhpParser\Node\Expr\AssignOp\Minus) { + if ($assignOp instanceof AssignPlus || $assignOp instanceof AssignMinus) { if (!$this->valueResolver->isValue($assignOp->expr, 0)) { return null; } @@ -79,7 +79,7 @@ CODE_SAMPLE } } // *, / - if ($assignOp instanceof \PhpParser\Node\Expr\AssignOp\Mul || $assignOp instanceof \PhpParser\Node\Expr\AssignOp\Div) { + if ($assignOp instanceof AssignMul || $assignOp instanceof AssignDiv) { if (!$this->valueResolver->isValue($assignOp->expr, 1)) { return null; } @@ -89,16 +89,16 @@ CODE_SAMPLE } return null; } - private function processBinaryOp(\PhpParser\Node $node) : ?\PhpParser\Node\Expr + private function processBinaryOp(Node $node) : ?Expr { - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\Plus || $node instanceof \PhpParser\Node\Expr\BinaryOp\Minus) { + if ($node instanceof Plus || $node instanceof Minus) { return $this->processBinaryPlusAndMinus($node); } // *, / - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\Mul) { + if ($node instanceof Mul) { return $this->processBinaryMulAndDiv($node); } - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\Div) { + if ($node instanceof Div) { return $this->processBinaryMulAndDiv($node); } return null; @@ -106,11 +106,11 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Expr\BinaryOp\Plus|\PhpParser\Node\Expr\BinaryOp\Minus $binaryOp */ - private function processBinaryPlusAndMinus($binaryOp) : ?\PhpParser\Node\Expr + private function processBinaryPlusAndMinus($binaryOp) : ?Expr { if ($this->valueResolver->isValue($binaryOp->left, 0) && $this->nodeTypeResolver->isNumberType($binaryOp->right)) { - if ($binaryOp instanceof \PhpParser\Node\Expr\BinaryOp\Minus) { - return new \PhpParser\Node\Expr\UnaryMinus($binaryOp->right); + if ($binaryOp instanceof Minus) { + return new UnaryMinus($binaryOp->right); } return $binaryOp->right; } @@ -125,9 +125,9 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Expr\BinaryOp\Mul|\PhpParser\Node\Expr\BinaryOp\Div $binaryOp */ - private function processBinaryMulAndDiv($binaryOp) : ?\PhpParser\Node\Expr + private function processBinaryMulAndDiv($binaryOp) : ?Expr { - if ($binaryOp instanceof \PhpParser\Node\Expr\BinaryOp\Mul && $this->valueResolver->isValue($binaryOp->left, 1) && $this->nodeTypeResolver->isNumberType($binaryOp->right)) { + if ($binaryOp instanceof Mul && $this->valueResolver->isValue($binaryOp->left, 1) && $this->nodeTypeResolver->isNumberType($binaryOp->right)) { return $binaryOp->right; } if (!$this->valueResolver->isValue($binaryOp->right, 1)) { diff --git a/rules/DeadCode/Rector/Property/RemoveUnusedPrivatePropertyRector.php b/rules/DeadCode/Rector/Property/RemoveUnusedPrivatePropertyRector.php index c728356327b..7f0bb0c5290 100644 --- a/rules/DeadCode/Rector/Property/RemoveUnusedPrivatePropertyRector.php +++ b/rules/DeadCode/Rector/Property/RemoveUnusedPrivatePropertyRector.php @@ -10,12 +10,12 @@ use Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface; use Rector\Core\NodeManipulator\PropertyManipulator; use Rector\Core\Rector\AbstractRector; use Rector\Removing\NodeManipulator\ComplexNodeRemover; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector\RemoveUnusedPrivatePropertyRectorTest */ -final class RemoveUnusedPrivatePropertyRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface +final class RemoveUnusedPrivatePropertyRector extends AbstractRector implements AllowEmptyConfigurableRectorInterface { /** * @var string @@ -37,7 +37,7 @@ final class RemoveUnusedPrivatePropertyRector extends \Rector\Core\Rector\Abstra * @var \Rector\Removing\NodeManipulator\ComplexNodeRemover */ private $complexNodeRemover; - public function __construct(\Rector\Core\NodeManipulator\PropertyManipulator $propertyManipulator, \Rector\Removing\NodeManipulator\ComplexNodeRemover $complexNodeRemover) + public function __construct(PropertyManipulator $propertyManipulator, ComplexNodeRemover $complexNodeRemover) { $this->propertyManipulator = $propertyManipulator; $this->complexNodeRemover = $complexNodeRemover; @@ -49,9 +49,9 @@ final class RemoveUnusedPrivatePropertyRector extends \Rector\Core\Rector\Abstra { $this->removeAssignSideEffect = $configuration[self::REMOVE_ASSIGN_SIDE_EFFECT] ?? (bool) \current($configuration); } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove unused private properties', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove unused private properties', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { private $property; @@ -69,12 +69,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $hasChanged = \false; foreach ($node->getProperties() as $property) { @@ -89,7 +89,7 @@ CODE_SAMPLE } return $hasChanged ? $node : null; } - private function shouldSkipProperty(\PhpParser\Node\Stmt\Property $property) : bool + private function shouldSkipProperty(Property $property) : bool { if (\count($property->props) !== 1) { return \true; diff --git a/rules/DeadCode/Rector/Property/RemoveUselessVarTagRector.php b/rules/DeadCode/Rector/Property/RemoveUselessVarTagRector.php index fc9b276b297..7d50c1a7eac 100644 --- a/rules/DeadCode/Rector/Property/RemoveUselessVarTagRector.php +++ b/rules/DeadCode/Rector/Property/RemoveUselessVarTagRector.php @@ -7,25 +7,25 @@ use PhpParser\Node; use PhpParser\Node\Stmt\Property; use Rector\Core\Rector\AbstractRector; use Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\Property\RemoveUselessVarTagRector\RemoveUselessVarTagRectorTest */ -final class RemoveUselessVarTagRector extends \Rector\Core\Rector\AbstractRector +final class RemoveUselessVarTagRector extends AbstractRector { /** * @readonly * @var \Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover */ private $varTagRemover; - public function __construct(\Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover $varTagRemover) + public function __construct(VarTagRemover $varTagRemover) { $this->varTagRemover = $varTagRemover; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove unused @var annotation for properties', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove unused @var annotation for properties', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { /** @@ -47,12 +47,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $this->varTagRemover->removeVarTagIfUseless($phpDocInfo, $node); diff --git a/rules/DeadCode/Rector/PropertyProperty/RemoveNullPropertyInitializationRector.php b/rules/DeadCode/Rector/PropertyProperty/RemoveNullPropertyInitializationRector.php index 1efb50de7e5..9a9517d34c4 100644 --- a/rules/DeadCode/Rector/PropertyProperty/RemoveNullPropertyInitializationRector.php +++ b/rules/DeadCode/Rector/PropertyProperty/RemoveNullPropertyInitializationRector.php @@ -12,16 +12,16 @@ use PhpParser\Node\Stmt\PropertyProperty; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; use function strtolower; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\PropertyProperty\RemoveNullPropertyInitializationRector\RemoveNullPropertyInitializationRectorTest */ -final class RemoveNullPropertyInitializationRector extends \Rector\Core\Rector\AbstractRector +final class RemoveNullPropertyInitializationRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove initialization with null value from property declarations', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove initialization with null value from property declarations', [new CodeSample(<<<'CODE_SAMPLE' class SunshineCommand extends ParentClassWithNewConstructor { private $myVar = null; @@ -40,30 +40,30 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\PropertyProperty::class]; + return [PropertyProperty::class]; } /** * @param PropertyProperty $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); // skip typed properties - if ($parent instanceof \PhpParser\Node\Stmt\Property && $parent->type !== null) { + if ($parent instanceof Property && $parent->type !== null) { return null; } $defaultValueNode = $node->default; - if (!$defaultValueNode instanceof \PhpParser\Node\Expr) { + if (!$defaultValueNode instanceof Expr) { return null; } - if (!$defaultValueNode instanceof \PhpParser\Node\Expr\ConstFetch) { + if (!$defaultValueNode instanceof ConstFetch) { return null; } - if (\strtolower((string) $defaultValueNode->name) !== 'null') { + if (strtolower((string) $defaultValueNode->name) !== 'null') { return null; } - $nodeNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_NODE); - if ($nodeNode instanceof \PhpParser\Node\NullableType) { + $nodeNode = $node->getAttribute(AttributeKey::PREVIOUS_NODE); + if ($nodeNode instanceof NullableType) { return null; } $node->default = null; diff --git a/rules/DeadCode/Rector/Return_/RemoveDeadConditionAboveReturnRector.php b/rules/DeadCode/Rector/Return_/RemoveDeadConditionAboveReturnRector.php index 5c666172878..c1687a968cf 100644 --- a/rules/DeadCode/Rector/Return_/RemoveDeadConditionAboveReturnRector.php +++ b/rules/DeadCode/Rector/Return_/RemoveDeadConditionAboveReturnRector.php @@ -9,16 +9,16 @@ use PhpParser\Node\Stmt\If_; use PhpParser\Node\Stmt\Return_; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\Return_\RemoveDeadConditionAboveReturnRector\RemoveDeadConditionAboveReturnRectorTest */ -final class RemoveDeadConditionAboveReturnRector extends \Rector\Core\Rector\AbstractRector +final class RemoveDeadConditionAboveReturnRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove dead condition above return', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove dead condition above return', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function go() @@ -47,21 +47,21 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Return_::class]; + return [Return_::class]; } /** * @param Return_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $previousNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_NODE); - if (!$previousNode instanceof \PhpParser\Node\Stmt\If_) { + $previousNode = $node->getAttribute(AttributeKey::PREVIOUS_NODE); + if (!$previousNode instanceof If_) { return null; } if ($previousNode->elseifs !== []) { return null; } - if ($previousNode->else instanceof \PhpParser\Node\Stmt\Else_) { + if ($previousNode->else instanceof Else_) { return null; } $countStmt = \count($previousNode->stmts); @@ -73,7 +73,7 @@ CODE_SAMPLE return null; } $stmt = $previousNode->stmts[0]; - if (!$stmt instanceof \PhpParser\Node\Stmt\Return_) { + if (!$stmt instanceof Return_) { return null; } if (!$this->nodeComparator->areNodesEqual($stmt, $node)) { diff --git a/rules/DeadCode/Rector/StaticCall/RemoveParentCallWithoutParentRector.php b/rules/DeadCode/Rector/StaticCall/RemoveParentCallWithoutParentRector.php index 12511d60122..de8dc40b9df 100644 --- a/rules/DeadCode/Rector/StaticCall/RemoveParentCallWithoutParentRector.php +++ b/rules/DeadCode/Rector/StaticCall/RemoveParentCallWithoutParentRector.php @@ -20,12 +20,12 @@ use Rector\Core\NodeManipulator\ClassMethodManipulator; use Rector\Core\Rector\AbstractScopeAwareRector; use Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector\RemoveParentCallWithoutParentRectorTest */ -final class RemoveParentCallWithoutParentRector extends \Rector\Core\Rector\AbstractScopeAwareRector +final class RemoveParentCallWithoutParentRector extends AbstractScopeAwareRector { /** * @readonly @@ -47,16 +47,16 @@ final class RemoveParentCallWithoutParentRector extends \Rector\Core\Rector\Abst * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\Core\NodeManipulator\ClassMethodManipulator $classMethodManipulator, \Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver $parentClassScopeResolver, \Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ClassMethodManipulator $classMethodManipulator, ParentClassScopeResolver $parentClassScopeResolver, ClassAnalyzer $classAnalyzer, ReflectionProvider $reflectionProvider) { $this->classMethodManipulator = $classMethodManipulator; $this->parentClassScopeResolver = $parentClassScopeResolver; $this->classAnalyzer = $classAnalyzer; $this->reflectionProvider = $reflectionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove unused parent call with no parent class', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove unused parent call with no parent class', [new CodeSample(<<<'CODE_SAMPLE' class OrphanClass { public function __construct() @@ -80,26 +80,26 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class]; + return [StaticCall::class]; } /** * @param StaticCall $node */ - public function refactorWithScope(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : ?\PhpParser\Node + public function refactorWithScope(Node $node, Scope $scope) : ?Node { - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLike = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$classLike instanceof Class_) { return null; } if ($this->shouldSkip($node, $classLike)) { return null; } $parentClassReflection = $this->parentClassScopeResolver->resolveParentClassReflection($scope); - if (!$parentClassReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$parentClassReflection instanceof ClassReflection) { return $this->processNoParentReflection($node); } - $classMethod = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassMethod::class); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $this->betterNodeFinder->findParentType($node, ClassMethod::class); + if (!$classMethod instanceof ClassMethod) { return null; } if ($this->classAnalyzer->isAnonymousClass($classLike)) { @@ -110,27 +110,27 @@ CODE_SAMPLE if ($this->classMethodManipulator->hasParentMethodOrInterfaceMethod($classMethod, $calledMethodName)) { return null; } - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\Stmt\Expression) { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Expression) { return null; } $this->removeNode($node); return null; } - private function shouldSkip(\PhpParser\Node\Expr\StaticCall $staticCall, \PhpParser\Node\Stmt\Class_ $class) : bool + private function shouldSkip(StaticCall $staticCall, Class_ $class) : bool { - if (!$staticCall->class instanceof \PhpParser\Node\Name) { + if (!$staticCall->class instanceof Name) { return \true; } - if (!$this->isName($staticCall->class, \Rector\Core\Enum\ObjectReference::PARENT)) { + if (!$this->isName($staticCall->class, ObjectReference::PARENT)) { return \true; } - return $class->extends instanceof \PhpParser\Node\Name\FullyQualified && !$this->reflectionProvider->hasClass($class->extends->toString()); + return $class->extends instanceof FullyQualified && !$this->reflectionProvider->hasClass($class->extends->toString()); } - private function processNoParentReflection(\PhpParser\Node\Expr\StaticCall $staticCall) : ?\PhpParser\Node\Expr\ConstFetch + private function processNoParentReflection(StaticCall $staticCall) : ?ConstFetch { - $parent = $staticCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\Stmt\Expression) { + $parent = $staticCall->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Expression) { return $this->nodeFactory->createNull(); } $this->removeNode($staticCall); diff --git a/rules/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector.php b/rules/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector.php index 6119c626021..a913ff56543 100644 --- a/rules/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector.php +++ b/rules/DeadCode/Rector/Stmt/RemoveUnreachableStatementRector.php @@ -20,18 +20,18 @@ use PhpParser\Node\Stmt\TryCatch; use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/phpstan/phpstan/blob/83078fe308a383c618b8c1caec299e5765d9ac82/src/Node/UnreachableStatementNode.php * * @see \Rector\Tests\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector\RemoveUnreachableStatementRectorTest */ -final class RemoveUnreachableStatementRector extends \Rector\Core\Rector\AbstractRector +final class RemoveUnreachableStatementRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove unreachable statements', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove unreachable statements', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -58,12 +58,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface::class]; + return [StmtsAwareInterface::class]; } /** * @param StmtsAwareInterface $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->stmts === null) { return null; @@ -86,7 +86,7 @@ CODE_SAMPLE if (!isset($stmts[$key - 1])) { continue; } - if ($stmt instanceof \PhpParser\Node\Stmt\Nop) { + if ($stmt instanceof Nop) { continue; } $previousStmt = $stmts[$key - 1]; @@ -98,31 +98,31 @@ CODE_SAMPLE } return $stmts; } - private function shouldRemove(\PhpParser\Node\Stmt $previousStmt, \PhpParser\Node\Stmt $currentStmt) : bool + private function shouldRemove(Stmt $previousStmt, Stmt $currentStmt) : bool { - if ($currentStmt instanceof \PhpParser\Node\Stmt\InlineHTML) { + if ($currentStmt instanceof InlineHTML) { return \false; } - if ($previousStmt instanceof \PhpParser\Node\Stmt\Throw_) { + if ($previousStmt instanceof Throw_) { return \true; } - if ($previousStmt instanceof \PhpParser\Node\Stmt\Expression && $previousStmt->expr instanceof \PhpParser\Node\Expr\Exit_) { + if ($previousStmt instanceof Expression && $previousStmt->expr instanceof Exit_) { return \true; } - if ($previousStmt instanceof \PhpParser\Node\Stmt\Goto_ && $currentStmt instanceof \PhpParser\Node\Stmt\Label) { + if ($previousStmt instanceof Goto_ && $currentStmt instanceof Label) { return \false; } - if (\in_array(\get_class($previousStmt), [\PhpParser\Node\Stmt\Return_::class, \PhpParser\Node\Stmt\Break_::class, \PhpParser\Node\Stmt\Continue_::class, \PhpParser\Node\Stmt\Goto_::class], \true)) { + if (\in_array(\get_class($previousStmt), [Return_::class, Break_::class, Continue_::class, Goto_::class], \true)) { return \true; } - if (!$previousStmt instanceof \PhpParser\Node\Stmt\TryCatch) { + if (!$previousStmt instanceof TryCatch) { return \false; } - $isUnreachable = $currentStmt->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::IS_UNREACHABLE); + $isUnreachable = $currentStmt->getAttribute(AttributeKey::IS_UNREACHABLE); if ($isUnreachable !== \true) { return \false; } - if (!$previousStmt->finally instanceof \PhpParser\Node\Stmt\Finally_) { + if (!$previousStmt->finally instanceof Finally_) { return \false; } return $this->cleanNop($previousStmt->finally->stmts) !== []; @@ -133,8 +133,8 @@ CODE_SAMPLE */ private function cleanNop(array $stmts) : array { - return \array_filter($stmts, function (\PhpParser\Node\Stmt $stmt) : bool { - return !$stmt instanceof \PhpParser\Node\Stmt\Nop; + return \array_filter($stmts, function (Stmt $stmt) : bool { + return !$stmt instanceof Nop; }); } } diff --git a/rules/DeadCode/Rector/StmtsAwareInterface/RemoveJustPropertyFetchForAssignRector.php b/rules/DeadCode/Rector/StmtsAwareInterface/RemoveJustPropertyFetchForAssignRector.php index 714154f583e..546d7d73ecf 100644 --- a/rules/DeadCode/Rector/StmtsAwareInterface/RemoveJustPropertyFetchForAssignRector.php +++ b/rules/DeadCode/Rector/StmtsAwareInterface/RemoveJustPropertyFetchForAssignRector.php @@ -12,25 +12,25 @@ use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; use Rector\Core\Rector\AbstractRector; use Rector\DeadCode\NodeAnalyzer\JustPropertyFetchVariableAssignMatcher; use Rector\DeadCode\ValueObject\VariableAndPropertyFetchAssign; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\StmtsAwareInterface\RemoveJustPropertyFetchForAssignRector\RemoveJustPropertyFetchForAssignRectorTest */ -final class RemoveJustPropertyFetchForAssignRector extends \Rector\Core\Rector\AbstractRector +final class RemoveJustPropertyFetchForAssignRector extends AbstractRector { /** * @readonly * @var \Rector\DeadCode\NodeAnalyzer\JustPropertyFetchVariableAssignMatcher */ private $justPropertyFetchVariableAssignMatcher; - public function __construct(\Rector\DeadCode\NodeAnalyzer\JustPropertyFetchVariableAssignMatcher $justPropertyFetchVariableAssignMatcher) + public function __construct(JustPropertyFetchVariableAssignMatcher $justPropertyFetchVariableAssignMatcher) { $this->justPropertyFetchVariableAssignMatcher = $justPropertyFetchVariableAssignMatcher; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove assign of property, just for value assign', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove assign of property, just for value assign', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { private $items = []; @@ -61,39 +61,39 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface::class]; + return [StmtsAwareInterface::class]; } /** * @param StmtsAwareInterface $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $variableAndPropertyFetchAssign = $this->justPropertyFetchVariableAssignMatcher->match($node); - if (!$variableAndPropertyFetchAssign instanceof \Rector\DeadCode\ValueObject\VariableAndPropertyFetchAssign) { + if (!$variableAndPropertyFetchAssign instanceof VariableAndPropertyFetchAssign) { return null; } $secondStmt = $node->stmts[1]; - if (!$secondStmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$secondStmt instanceof Expression) { return null; } - if (!$secondStmt->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$secondStmt->expr instanceof Assign) { return null; } $middleAssign = $secondStmt->expr; $assignVar = $middleAssign->var; // unwrap all array dim fetch nesting $lastArrayDimFetch = null; - while ($assignVar instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + while ($assignVar instanceof ArrayDimFetch) { $lastArrayDimFetch = $assignVar; $assignVar = $assignVar->var; } - if (!$assignVar instanceof \PhpParser\Node\Expr\Variable) { + if (!$assignVar instanceof Variable) { return null; } if (!$this->nodeComparator->areNodesEqual($assignVar, $variableAndPropertyFetchAssign->getVariable())) { return null; } - if ($lastArrayDimFetch instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if ($lastArrayDimFetch instanceof ArrayDimFetch) { $lastArrayDimFetch->var = $variableAndPropertyFetchAssign->getPropertyFetch(); } else { $middleAssign->var = $variableAndPropertyFetchAssign->getPropertyFetch(); diff --git a/rules/DeadCode/Rector/StmtsAwareInterface/RemoveJustPropertyFetchRector.php b/rules/DeadCode/Rector/StmtsAwareInterface/RemoveJustPropertyFetchRector.php index a5498b587ab..ce227b5a97c 100644 --- a/rules/DeadCode/Rector/StmtsAwareInterface/RemoveJustPropertyFetchRector.php +++ b/rules/DeadCode/Rector/StmtsAwareInterface/RemoveJustPropertyFetchRector.php @@ -19,25 +19,25 @@ use Rector\Core\Rector\AbstractRector; use Rector\DeadCode\ValueObject\PropertyFetchToVariableAssign; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\ReadWrite\NodeFinder\NodeUsageFinder; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\StmtsAwareInterface\RemoveJustPropertyFetchRector\RemoveJustPropertyFetchRectorTest */ -final class RemoveJustPropertyFetchRector extends \Rector\Core\Rector\AbstractRector +final class RemoveJustPropertyFetchRector extends AbstractRector { /** * @readonly * @var \Rector\ReadWrite\NodeFinder\NodeUsageFinder */ private $nodeUsageFinder; - public function __construct(\Rector\ReadWrite\NodeFinder\NodeUsageFinder $nodeUsageFinder) + public function __construct(NodeUsageFinder $nodeUsageFinder) { $this->nodeUsageFinder = $nodeUsageFinder; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Inline property fetch assign to a variable, that has no added value', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Inline property fetch assign to a variable, that has no added value', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { private $name; @@ -68,12 +68,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface::class]; + return [StmtsAwareInterface::class]; } /** * @param StmtsAwareInterface $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $stmts = (array) $node->stmts; if ($stmts === []) { @@ -84,12 +84,12 @@ CODE_SAMPLE $variableToPropertyAssign = null; foreach ($stmts as $key => $stmt) { $variableToPropertyAssign = $this->matchVariableToPropertyAssign($stmt); - if (!$variableToPropertyAssign instanceof \Rector\DeadCode\ValueObject\PropertyFetchToVariableAssign) { + if (!$variableToPropertyAssign instanceof PropertyFetchToVariableAssign) { continue; } $assignPhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($stmt); // there is a @var tag on purpose, keep the assign - if ($assignPhpDocInfo->getVarTagValueNode() instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) { + if ($assignPhpDocInfo->getVarTagValueNode() instanceof VarTagValueNode) { continue; } $followingStmts = \array_slice($stmts, $key + 1); @@ -100,7 +100,7 @@ CODE_SAMPLE } // filter out variable usages that are part of nested property fetch, or change variable $variableUsages = $this->filterOutReferencedVariableUsages($variableUsages); - if (!$variableToPropertyAssign instanceof \Rector\DeadCode\ValueObject\PropertyFetchToVariableAssign) { + if (!$variableToPropertyAssign instanceof PropertyFetchToVariableAssign) { return null; } if ($variableUsages === []) { @@ -112,11 +112,11 @@ CODE_SAMPLE /** * @param Variable[] $variableUsages */ - private function replaceVariablesWithPropertyFetch(\Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface $stmtsAware, int $currentStmtsKey, array $variableUsages, \PhpParser\Node\Expr\PropertyFetch $propertyFetch) : \Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface + private function replaceVariablesWithPropertyFetch(StmtsAwareInterface $stmtsAware, int $currentStmtsKey, array $variableUsages, PropertyFetch $propertyFetch) : StmtsAwareInterface { // remove assign node unset($stmtsAware->stmts[$currentStmtsKey]); - $this->traverseNodesWithCallable($stmtsAware, function (\PhpParser\Node $node) use($variableUsages, $propertyFetch) : ?PropertyFetch { + $this->traverseNodesWithCallable($stmtsAware, function (Node $node) use($variableUsages, $propertyFetch) : ?PropertyFetch { if (!\in_array($node, $variableUsages, \true)) { return null; } @@ -130,58 +130,58 @@ CODE_SAMPLE */ private function filterOutReferencedVariableUsages(array $variableUsages) : array { - return \array_filter($variableUsages, function (\PhpParser\Node\Expr\Variable $variable) : bool { - $variableUsageParent = $variable->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($variableUsageParent instanceof \PhpParser\Node\Arg) { - $variableUsageParent = $variableUsageParent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + return \array_filter($variableUsages, function (Variable $variable) : bool { + $variableUsageParent = $variable->getAttribute(AttributeKey::PARENT_NODE); + if ($variableUsageParent instanceof Arg) { + $variableUsageParent = $variableUsageParent->getAttribute(AttributeKey::PARENT_NODE); } // skip nested property fetch, the assign is for purpose of named variable - if ($variableUsageParent instanceof \PhpParser\Node\Expr\PropertyFetch) { + if ($variableUsageParent instanceof PropertyFetch) { return \false; } // skip, as assign can be used in a loop - $parentWhile = $this->betterNodeFinder->findParentType($variable, \PhpParser\Node\Stmt\While_::class); - if ($parentWhile instanceof \PhpParser\Node\Stmt\While_) { + $parentWhile = $this->betterNodeFinder->findParentType($variable, While_::class); + if ($parentWhile instanceof While_) { return \false; } - if (!$variableUsageParent instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$variableUsageParent instanceof FuncCall) { return \true; } return !$this->isName($variableUsageParent, 'array_pop'); }); } - private function matchVariableToPropertyAssign(\PhpParser\Node\Stmt $stmt) : ?\Rector\DeadCode\ValueObject\PropertyFetchToVariableAssign + private function matchVariableToPropertyAssign(Stmt $stmt) : ?PropertyFetchToVariableAssign { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { return null; } - if (!$stmt->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$stmt->expr instanceof Assign) { return null; } $assign = $stmt->expr; - if (!$assign->expr instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$assign->expr instanceof PropertyFetch) { return null; } if ($this->isPropertyFetchCallerNode($assign->expr)) { return null; } // keep property fetch nesting - if ($assign->expr->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if ($assign->expr->var instanceof PropertyFetch) { return null; } - if (!$assign->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$assign->var instanceof Variable) { return null; } - return new \Rector\DeadCode\ValueObject\PropertyFetchToVariableAssign($assign->var, $assign->expr); + return new PropertyFetchToVariableAssign($assign->var, $assign->expr); } - private function isPropertyFetchCallerNode(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : bool + private function isPropertyFetchCallerNode(PropertyFetch $propertyFetch) : bool { // skip nodes as mostly used with public property fetches $propertyFetchCallerType = $this->getType($propertyFetch->var); - if (!$propertyFetchCallerType instanceof \PHPStan\Type\ObjectType) { + if (!$propertyFetchCallerType instanceof ObjectType) { return \false; } - $nodeObjectType = new \PHPStan\Type\ObjectType('PhpParser\\Node'); + $nodeObjectType = new ObjectType('PhpParser\\Node'); return $nodeObjectType->isSuperTypeOf($propertyFetchCallerType)->yes(); } } diff --git a/rules/DeadCode/Rector/Switch_/RemoveDuplicatedCaseInSwitchRector.php b/rules/DeadCode/Rector/Switch_/RemoveDuplicatedCaseInSwitchRector.php index 3e5689a2c86..9d5ad753462 100644 --- a/rules/DeadCode/Rector/Switch_/RemoveDuplicatedCaseInSwitchRector.php +++ b/rules/DeadCode/Rector/Switch_/RemoveDuplicatedCaseInSwitchRector.php @@ -9,16 +9,16 @@ use PhpParser\Node\Stmt\Case_; use PhpParser\Node\Stmt\Return_; use PhpParser\Node\Stmt\Switch_; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\Switch_\RemoveDuplicatedCaseInSwitchRector\RemoveDuplicatedCaseInSwitchRectorTest */ -final class RemoveDuplicatedCaseInSwitchRector extends \Rector\Core\Rector\AbstractRector +final class RemoveDuplicatedCaseInSwitchRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('2 following switch keys with identical will be reduced to one result', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('2 following switch keys with identical will be reduced to one result', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -60,12 +60,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Switch_::class]; + return [Switch_::class]; } /** * @param Switch_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (\count($node->cases) < 2) { return null; @@ -73,23 +73,23 @@ CODE_SAMPLE /** @var Case_|null $previousCase */ $previousCase = null; foreach ($node->cases as $case) { - if ($previousCase instanceof \PhpParser\Node\Stmt\Case_ && $this->areSwitchStmtsEqualsAndWithBreak($case, $previousCase)) { + if ($previousCase instanceof Case_ && $this->areSwitchStmtsEqualsAndWithBreak($case, $previousCase)) { $previousCase->stmts = []; } $previousCase = $case; } return $node; } - private function areSwitchStmtsEqualsAndWithBreak(\PhpParser\Node\Stmt\Case_ $currentCase, \PhpParser\Node\Stmt\Case_ $previousCase) : bool + private function areSwitchStmtsEqualsAndWithBreak(Case_ $currentCase, Case_ $previousCase) : bool { if (!$this->nodeComparator->areNodesEqual($currentCase->stmts, $previousCase->stmts)) { return \false; } foreach ($currentCase->stmts as $stmt) { - if ($stmt instanceof \PhpParser\Node\Stmt\Break_) { + if ($stmt instanceof Break_) { return \true; } - if ($stmt instanceof \PhpParser\Node\Stmt\Return_) { + if ($stmt instanceof Return_) { return \true; } } diff --git a/rules/DeadCode/Rector/Ternary/TernaryToBooleanOrFalseToBooleanAndRector.php b/rules/DeadCode/Rector/Ternary/TernaryToBooleanOrFalseToBooleanAndRector.php index fd4e11e57bd..3e6ea1c1220 100644 --- a/rules/DeadCode/Rector/Ternary/TernaryToBooleanOrFalseToBooleanAndRector.php +++ b/rules/DeadCode/Rector/Ternary/TernaryToBooleanOrFalseToBooleanAndRector.php @@ -8,16 +8,16 @@ use PhpParser\Node\Expr\BinaryOp\BooleanAnd; use PhpParser\Node\Expr\Ternary; use PHPStan\Type\BooleanType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector\TernaryToBooleanOrFalseToBooleanAndRectorTest */ -final class TernaryToBooleanOrFalseToBooleanAndRector extends \Rector\Core\Rector\AbstractRector +final class TernaryToBooleanOrFalseToBooleanAndRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change ternary of bool : false to && bool', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change ternary of bool : false to && bool', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function go() @@ -52,12 +52,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Ternary::class]; + return [Ternary::class]; } /** * @param Ternary $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->if === null) { return null; @@ -69,9 +69,9 @@ CODE_SAMPLE return null; } $ifType = $this->getType($node->if); - if (!$ifType instanceof \PHPStan\Type\BooleanType) { + if (!$ifType instanceof BooleanType) { return null; } - return new \PhpParser\Node\Expr\BinaryOp\BooleanAnd($node->cond, $node->if); + return new BooleanAnd($node->cond, $node->if); } } diff --git a/rules/DeadCode/Rector/TryCatch/RemoveDeadTryCatchRector.php b/rules/DeadCode/Rector/TryCatch/RemoveDeadTryCatchRector.php index 83586e201db..d7e250ed431 100644 --- a/rules/DeadCode/Rector/TryCatch/RemoveDeadTryCatchRector.php +++ b/rules/DeadCode/Rector/TryCatch/RemoveDeadTryCatchRector.php @@ -10,16 +10,16 @@ use PhpParser\Node\Stmt\Nop; use PhpParser\Node\Stmt\Throw_; use PhpParser\Node\Stmt\TryCatch; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector\RemoveDeadTryCatchRectorTest */ -final class RemoveDeadTryCatchRector extends \Rector\Core\Rector\AbstractRector +final class RemoveDeadTryCatchRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove dead try/catch', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove dead try/catch', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -48,15 +48,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\TryCatch::class]; + return [TryCatch::class]; } /** * @param TryCatch $node * @return mixed[]|null|\PhpParser\Node\Stmt\TryCatch */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { - $isEmptyFinallyStmts = !$node->finally instanceof \PhpParser\Node\Stmt\Finally_ || $this->isEmpty($node->finally->stmts); + $isEmptyFinallyStmts = !$node->finally instanceof Finally_ || $this->isEmpty($node->finally->stmts); // not empty stmts on finally always executed if (!$isEmptyFinallyStmts) { return null; @@ -73,7 +73,7 @@ CODE_SAMPLE return null; } $onlyCatchStmt = $onlyCatch->stmts[0]; - if (!$onlyCatchStmt instanceof \PhpParser\Node\Stmt\Throw_) { + if (!$onlyCatchStmt instanceof Throw_) { return null; } if (!$this->nodeComparator->areNodesEqual($onlyCatch->var, $onlyCatchStmt->expr)) { @@ -92,6 +92,6 @@ CODE_SAMPLE if (\count($stmts) > 1) { return \false; } - return $stmts[0] instanceof \PhpParser\Node\Stmt\Nop; + return $stmts[0] instanceof Nop; } } diff --git a/rules/DeadCode/SideEffect/PureFunctionDetector.php b/rules/DeadCode/SideEffect/PureFunctionDetector.php index b1b060c8e13..b42745db541 100644 --- a/rules/DeadCode/SideEffect/PureFunctionDetector.php +++ b/rules/DeadCode/SideEffect/PureFunctionDetector.php @@ -235,25 +235,25 @@ final class PureFunctionDetector * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider) { $this->nodeNameResolver = $nodeNameResolver; $this->reflectionProvider = $reflectionProvider; } - public function detect(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + public function detect(FuncCall $funcCall) : bool { $funcCallName = $this->nodeNameResolver->getName($funcCall); if ($funcCallName === null) { return \false; } - $scope = $funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - $name = new \PhpParser\Node\Name($funcCallName); + $scope = $funcCall->getAttribute(AttributeKey::SCOPE); + $name = new Name($funcCallName); $hasFunction = $this->reflectionProvider->hasFunction($name, $scope); if (!$hasFunction) { return \false; } $function = $this->reflectionProvider->getFunction($name, $scope); - if (!$function instanceof \PHPStan\Reflection\Native\NativeFunctionReflection) { + if (!$function instanceof NativeFunctionReflection) { return \false; } return !$this->nodeNameResolver->isNames($funcCall, self::IMPURE_FUNCTIONS); diff --git a/rules/DeadCode/SideEffect/SideEffectNodeDetector.php b/rules/DeadCode/SideEffect/SideEffectNodeDetector.php index bb2211cbf5c..1a11de6d9d0 100644 --- a/rules/DeadCode/SideEffect/SideEffectNodeDetector.php +++ b/rules/DeadCode/SideEffect/SideEffectNodeDetector.php @@ -27,11 +27,11 @@ final class SideEffectNodeDetector /** * @var array> */ - private const SIDE_EFFECT_NODE_TYPES = [\PhpParser\Node\Scalar\Encapsed::class, \PhpParser\Node\Expr\New_::class, \PhpParser\Node\Expr\BinaryOp\Concat::class, \PhpParser\Node\Expr\PropertyFetch::class]; + private const SIDE_EFFECT_NODE_TYPES = [Encapsed::class, New_::class, Concat::class, PropertyFetch::class]; /** * @var array> */ - private const CALL_EXPR_SIDE_EFFECT_NODE_TYPES = [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\New_::class, \PhpParser\Node\Expr\NullsafeMethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + private const CALL_EXPR_SIDE_EFFECT_NODE_TYPES = [MethodCall::class, New_::class, NullsafeMethodCall::class, StaticCall::class]; /** * @readonly * @var \Rector\NodeTypeResolver\NodeTypeResolver @@ -42,18 +42,18 @@ final class SideEffectNodeDetector * @var \Rector\DeadCode\SideEffect\PureFunctionDetector */ private $pureFunctionDetector; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\DeadCode\SideEffect\PureFunctionDetector $pureFunctionDetector) + public function __construct(NodeTypeResolver $nodeTypeResolver, \Rector\DeadCode\SideEffect\PureFunctionDetector $pureFunctionDetector) { $this->nodeTypeResolver = $nodeTypeResolver; $this->pureFunctionDetector = $pureFunctionDetector; } - public function detect(\PhpParser\Node\Expr $expr) : bool + public function detect(Expr $expr) : bool { - if ($expr instanceof \PhpParser\Node\Expr\Assign) { + if ($expr instanceof Assign) { return \true; } $exprStaticType = $this->nodeTypeResolver->getType($expr); - if ($exprStaticType instanceof \PHPStan\Type\ConstantType) { + if ($exprStaticType instanceof ConstantType) { return \false; } foreach (self::SIDE_EFFECT_NODE_TYPES as $sideEffectNodeType) { @@ -61,64 +61,64 @@ final class SideEffectNodeDetector return \false; } } - if ($expr instanceof \PhpParser\Node\Expr\FuncCall) { + if ($expr instanceof FuncCall) { return !$this->pureFunctionDetector->detect($expr); } - if ($expr instanceof \PhpParser\Node\Expr\Variable || $expr instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if ($expr instanceof Variable || $expr instanceof ArrayDimFetch) { $variable = $this->resolveVariable($expr); // variables don't have side effects - return !$variable instanceof \PhpParser\Node\Expr\Variable; + return !$variable instanceof Variable; } return \true; } - public function detectCallExpr(\PhpParser\Node $node) : bool + public function detectCallExpr(Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Expr) { + if (!$node instanceof Expr) { return \false; } - if ($node instanceof \PhpParser\Node\Expr\StaticCall && $this->isClassCallerThrowable($node)) { + if ($node instanceof StaticCall && $this->isClassCallerThrowable($node)) { return \false; } - if ($node instanceof \PhpParser\Node\Expr\New_ && $this->isPhpParser($node)) { + if ($node instanceof New_ && $this->isPhpParser($node)) { return \false; } $exprClass = \get_class($node); if (\in_array($exprClass, self::CALL_EXPR_SIDE_EFFECT_NODE_TYPES, \true)) { return \true; } - if ($node instanceof \PhpParser\Node\Expr\FuncCall) { + if ($node instanceof FuncCall) { return !$this->pureFunctionDetector->detect($node); } return \false; } - private function isPhpParser(\PhpParser\Node\Expr\New_ $new) : bool + private function isPhpParser(New_ $new) : bool { - if (!$new->class instanceof \PhpParser\Node\Name\FullyQualified) { + if (!$new->class instanceof FullyQualified) { return \false; } $className = $new->class->toString(); - $namespace = \RectorPrefix20220607\Nette\Utils\Strings::before($className, '\\', 1); + $namespace = Strings::before($className, '\\', 1); return $namespace === 'PhpParser'; } - private function isClassCallerThrowable(\PhpParser\Node\Expr\StaticCall $staticCall) : bool + private function isClassCallerThrowable(StaticCall $staticCall) : bool { $class = $staticCall->class; - if (!$class instanceof \PhpParser\Node\Name) { + if (!$class instanceof Name) { return \false; } - $throwableType = new \PHPStan\Type\ObjectType('Throwable'); - $type = new \PHPStan\Type\ObjectType($class->toString()); + $throwableType = new ObjectType('Throwable'); + $type = new ObjectType($class->toString()); return $throwableType->isSuperTypeOf($type)->yes(); } /** * @param \PhpParser\Node\Expr\ArrayDimFetch|\PhpParser\Node\Expr\Variable $expr */ - private function resolveVariable($expr) : ?\PhpParser\Node\Expr\Variable + private function resolveVariable($expr) : ?Variable { - while ($expr instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + while ($expr instanceof ArrayDimFetch) { $expr = $expr->var; } - if (!$expr instanceof \PhpParser\Node\Expr\Variable) { + if (!$expr instanceof Variable) { return null; } return $expr; diff --git a/rules/DeadCode/TypeNodeAnalyzer/GenericTypeNodeAnalyzer.php b/rules/DeadCode/TypeNodeAnalyzer/GenericTypeNodeAnalyzer.php index ad123a5d410..71aa5f1a04e 100644 --- a/rules/DeadCode/TypeNodeAnalyzer/GenericTypeNodeAnalyzer.php +++ b/rules/DeadCode/TypeNodeAnalyzer/GenericTypeNodeAnalyzer.php @@ -7,11 +7,11 @@ use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode; final class GenericTypeNodeAnalyzer { - public function hasGenericType(\PHPStan\PhpDocParser\Ast\Type\UnionTypeNode $unionTypeNode) : bool + public function hasGenericType(UnionTypeNode $unionTypeNode) : bool { $types = $unionTypeNode->types; foreach ($types as $type) { - if ($type instanceof \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode) { + if ($type instanceof GenericTypeNode) { return \true; } } diff --git a/rules/DeadCode/TypeNodeAnalyzer/MixedArrayTypeNodeAnalyzer.php b/rules/DeadCode/TypeNodeAnalyzer/MixedArrayTypeNodeAnalyzer.php index 17e78a64ebc..6df39274f84 100644 --- a/rules/DeadCode/TypeNodeAnalyzer/MixedArrayTypeNodeAnalyzer.php +++ b/rules/DeadCode/TypeNodeAnalyzer/MixedArrayTypeNodeAnalyzer.php @@ -8,13 +8,13 @@ use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode; use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode; final class MixedArrayTypeNodeAnalyzer { - public function hasMixedArrayType(\PHPStan\PhpDocParser\Ast\Type\UnionTypeNode $unionTypeNode) : bool + public function hasMixedArrayType(UnionTypeNode $unionTypeNode) : bool { $types = $unionTypeNode->types; foreach ($types as $type) { - if ($type instanceof \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode) { + if ($type instanceof SpacingAwareArrayTypeNode) { $typeNode = $type->type; - if (!$typeNode instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode) { + if (!$typeNode instanceof IdentifierTypeNode) { continue; } if ($typeNode->name === 'mixed') { diff --git a/rules/DeadCode/UselessIfCondBeforeForeachDetector.php b/rules/DeadCode/UselessIfCondBeforeForeachDetector.php index 969798c494b..378337232c5 100644 --- a/rules/DeadCode/UselessIfCondBeforeForeachDetector.php +++ b/rules/DeadCode/UselessIfCondBeforeForeachDetector.php @@ -40,7 +40,7 @@ final class UselessIfCondBeforeForeachDetector * @var \Rector\Core\NodeAnalyzer\ParamAnalyzer */ private $paramAnalyzer; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\NodeAnalyzer\ParamAnalyzer $paramAnalyzer) + public function __construct(NodeTypeResolver $nodeTypeResolver, NodeComparator $nodeComparator, BetterNodeFinder $betterNodeFinder, ParamAnalyzer $paramAnalyzer) { $this->nodeTypeResolver = $nodeTypeResolver; $this->nodeComparator = $nodeComparator; @@ -51,13 +51,13 @@ final class UselessIfCondBeforeForeachDetector * Matches: * !empty($values) */ - public function isMatchingNotEmpty(\PhpParser\Node\Stmt\If_ $if, \PhpParser\Node\Expr $foreachExpr) : bool + public function isMatchingNotEmpty(If_ $if, Expr $foreachExpr) : bool { $cond = $if->cond; - if (!$cond instanceof \PhpParser\Node\Expr\BooleanNot) { + if (!$cond instanceof BooleanNot) { return \false; } - if (!$cond->expr instanceof \PhpParser\Node\Expr\Empty_) { + if (!$cond->expr instanceof Empty_) { return \false; } /** @var Empty_ $empty */ @@ -67,11 +67,11 @@ final class UselessIfCondBeforeForeachDetector } // is array though? $arrayType = $this->nodeTypeResolver->getType($empty->expr); - if (!$arrayType instanceof \PHPStan\Type\ArrayType) { + if (!$arrayType instanceof ArrayType) { return \false; } $previousParam = $this->fromPreviousParam($foreachExpr); - if (!$previousParam instanceof \PhpParser\Node\Param) { + if (!$previousParam instanceof Param) { return \true; } if ($this->paramAnalyzer->isNullable($previousParam)) { @@ -86,22 +86,22 @@ final class UselessIfCondBeforeForeachDetector * [] !== $values * [] != $values */ - public function isMatchingNotIdenticalEmptyArray(\PhpParser\Node\Stmt\If_ $if, \PhpParser\Node\Expr $foreachExpr) : bool + public function isMatchingNotIdenticalEmptyArray(If_ $if, Expr $foreachExpr) : bool { - if (!$if->cond instanceof \PhpParser\Node\Expr\BinaryOp\NotIdentical && !$if->cond instanceof \PhpParser\Node\Expr\BinaryOp\NotEqual) { + if (!$if->cond instanceof NotIdentical && !$if->cond instanceof NotEqual) { return \false; } /** @var NotIdentical|NotEqual $notIdentical */ $notIdentical = $if->cond; return $this->isMatchingNotBinaryOp($notIdentical, $foreachExpr); } - private function fromPreviousParam(\PhpParser\Node\Expr $expr) : ?\PhpParser\Node + private function fromPreviousParam(Expr $expr) : ?Node { - return $this->betterNodeFinder->findFirstPrevious($expr, function (\PhpParser\Node $node) use($expr) : bool { - if (!$node instanceof \PhpParser\Node\Param) { + return $this->betterNodeFinder->findFirstPrevious($expr, function (Node $node) use($expr) : bool { + if (!$node instanceof Param) { return \false; } - if (!$node->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$node->var instanceof Variable) { return \false; } return $this->nodeComparator->areNodesEqual($node->var, $expr); @@ -110,23 +110,23 @@ final class UselessIfCondBeforeForeachDetector /** * @param \PhpParser\Node\Expr\BinaryOp\NotIdentical|\PhpParser\Node\Expr\BinaryOp\NotEqual $binaryOp */ - private function isMatchingNotBinaryOp($binaryOp, \PhpParser\Node\Expr $foreachExpr) : bool + private function isMatchingNotBinaryOp($binaryOp, Expr $foreachExpr) : bool { if ($this->isEmptyArrayAndForeachedVariable($binaryOp->left, $binaryOp->right, $foreachExpr)) { return \true; } return $this->isEmptyArrayAndForeachedVariable($binaryOp->right, $binaryOp->left, $foreachExpr); } - private function isEmptyArrayAndForeachedVariable(\PhpParser\Node\Expr $leftExpr, \PhpParser\Node\Expr $rightExpr, \PhpParser\Node\Expr $foreachExpr) : bool + private function isEmptyArrayAndForeachedVariable(Expr $leftExpr, Expr $rightExpr, Expr $foreachExpr) : bool { if (!$this->isEmptyArray($leftExpr)) { return \false; } return $this->nodeComparator->areNodesEqual($foreachExpr, $rightExpr); } - private function isEmptyArray(\PhpParser\Node\Expr $expr) : bool + private function isEmptyArray(Expr $expr) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\Array_) { + if (!$expr instanceof Array_) { return \false; } return $expr->items === []; diff --git a/rules/DeadCode/ValueObject/BinaryToVersionCompareCondition.php b/rules/DeadCode/ValueObject/BinaryToVersionCompareCondition.php index 6e01fe01768..3bfb74c7208 100644 --- a/rules/DeadCode/ValueObject/BinaryToVersionCompareCondition.php +++ b/rules/DeadCode/ValueObject/BinaryToVersionCompareCondition.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\DeadCode\ValueObject; use Rector\DeadCode\Contract\ConditionInterface; -final class BinaryToVersionCompareCondition implements \Rector\DeadCode\Contract\ConditionInterface +final class BinaryToVersionCompareCondition implements ConditionInterface { /** * @readonly diff --git a/rules/DeadCode/ValueObject/PropertyFetchToVariableAssign.php b/rules/DeadCode/ValueObject/PropertyFetchToVariableAssign.php index 04989733d47..0369cb505ce 100644 --- a/rules/DeadCode/ValueObject/PropertyFetchToVariableAssign.php +++ b/rules/DeadCode/ValueObject/PropertyFetchToVariableAssign.php @@ -17,16 +17,16 @@ final class PropertyFetchToVariableAssign * @var \PhpParser\Node\Expr\PropertyFetch */ private $propertyFetch; - public function __construct(\PhpParser\Node\Expr\Variable $variable, \PhpParser\Node\Expr\PropertyFetch $propertyFetch) + public function __construct(Variable $variable, PropertyFetch $propertyFetch) { $this->variable = $variable; $this->propertyFetch = $propertyFetch; } - public function getVariable() : \PhpParser\Node\Expr\Variable + public function getVariable() : Variable { return $this->variable; } - public function getPropertyFetch() : \PhpParser\Node\Expr\PropertyFetch + public function getPropertyFetch() : PropertyFetch { return $this->propertyFetch; } diff --git a/rules/DeadCode/ValueObject/VariableAndPropertyFetchAssign.php b/rules/DeadCode/ValueObject/VariableAndPropertyFetchAssign.php index 72d2cf86202..a7482327cf4 100644 --- a/rules/DeadCode/ValueObject/VariableAndPropertyFetchAssign.php +++ b/rules/DeadCode/ValueObject/VariableAndPropertyFetchAssign.php @@ -17,16 +17,16 @@ final class VariableAndPropertyFetchAssign * @var \PhpParser\Node\Expr\PropertyFetch */ private $propertyFetch; - public function __construct(\PhpParser\Node\Expr\Variable $variable, \PhpParser\Node\Expr\PropertyFetch $propertyFetch) + public function __construct(Variable $variable, PropertyFetch $propertyFetch) { $this->variable = $variable; $this->propertyFetch = $propertyFetch; } - public function getVariable() : \PhpParser\Node\Expr\Variable + public function getVariable() : Variable { return $this->variable; } - public function getPropertyFetch() : \PhpParser\Node\Expr\PropertyFetch + public function getPropertyFetch() : PropertyFetch { return $this->propertyFetch; } diff --git a/rules/DeadCode/ValueObject/VariableNodeUse.php b/rules/DeadCode/ValueObject/VariableNodeUse.php index 5442a36fd2c..2090e28f767 100644 --- a/rules/DeadCode/ValueObject/VariableNodeUse.php +++ b/rules/DeadCode/ValueObject/VariableNodeUse.php @@ -43,14 +43,14 @@ final class VariableNodeUse * @var string|null */ private $nestingHash; - public function __construct(int $startTokenPosition, string $variableName, string $type, \PhpParser\Node\Expr\Variable $variable, ?string $nestingHash = null) + public function __construct(int $startTokenPosition, string $variableName, string $type, Variable $variable, ?string $nestingHash = null) { $this->startTokenPosition = $startTokenPosition; $this->variableName = $variableName; $this->type = $type; $this->variable = $variable; $this->nestingHash = $nestingHash; - \Rector\Core\Validation\RectorAssert::className($type); + RectorAssert::className($type); } public function isName(string $name) : bool { @@ -64,15 +64,15 @@ final class VariableNodeUse { return $this->type === $type; } - public function getVariableNode() : \PhpParser\Node\Expr\Variable + public function getVariableNode() : Variable { return $this->variable; } - public function getParentNode() : \PhpParser\Node + public function getParentNode() : Node { - $parentNode = $this->variable->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $parentNode = $this->variable->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof Node) { + throw new ShouldNotHappenException(); } return $parentNode; } diff --git a/rules/DeadCode/ValueObject/VersionCompareCondition.php b/rules/DeadCode/ValueObject/VersionCompareCondition.php index 8b1f19b42d9..bb876afbe3c 100644 --- a/rules/DeadCode/ValueObject/VersionCompareCondition.php +++ b/rules/DeadCode/ValueObject/VersionCompareCondition.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\DeadCode\ValueObject; use Rector\DeadCode\Contract\ConditionInterface; -final class VersionCompareCondition implements \Rector\DeadCode\Contract\ConditionInterface +final class VersionCompareCondition implements ConditionInterface { /** * @readonly diff --git a/rules/DependencyInjection/Collector/VariablesToPropertyFetchCollection.php b/rules/DependencyInjection/Collector/VariablesToPropertyFetchCollection.php index 6d7ea5c92d7..8f5fa022909 100644 --- a/rules/DependencyInjection/Collector/VariablesToPropertyFetchCollection.php +++ b/rules/DependencyInjection/Collector/VariablesToPropertyFetchCollection.php @@ -10,7 +10,7 @@ final class VariablesToPropertyFetchCollection * @var array */ private $variableNameAndType = []; - public function addVariableNameAndType(string $name, \PHPStan\Type\ObjectType $objectType) : void + public function addVariableNameAndType(string $name, ObjectType $objectType) : void { $this->variableNameAndType[$name] = $objectType; } diff --git a/rules/DependencyInjection/NodeManipulator/PropertyConstructorInjectionManipulator.php b/rules/DependencyInjection/NodeManipulator/PropertyConstructorInjectionManipulator.php index 7647183da04..ee9ed294dba 100644 --- a/rules/DependencyInjection/NodeManipulator/PropertyConstructorInjectionManipulator.php +++ b/rules/DependencyInjection/NodeManipulator/PropertyConstructorInjectionManipulator.php @@ -47,7 +47,7 @@ final class PropertyConstructorInjectionManipulator * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover $phpDocTagRemover, \Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeNameResolver $nodeNameResolver, PhpDocInfoFactory $phpDocInfoFactory, PhpDocTypeChanger $phpDocTypeChanger, PhpDocTagRemover $phpDocTagRemover, PropertyToAddCollector $propertyToAddCollector, BetterNodeFinder $betterNodeFinder) { $this->nodeNameResolver = $nodeNameResolver; $this->phpDocInfoFactory = $phpDocInfoFactory; @@ -56,17 +56,17 @@ final class PropertyConstructorInjectionManipulator $this->propertyToAddCollector = $propertyToAddCollector; $this->betterNodeFinder = $betterNodeFinder; } - public function refactor(\PhpParser\Node\Stmt\Property $property, \PHPStan\Type\Type $type, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : void + public function refactor(Property $property, Type $type, DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : void { $propertyName = $this->nodeNameResolver->getName($property); $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); $this->phpDocTypeChanger->changeVarType($phpDocInfo, $type); $this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $doctrineAnnotationTagValueNode); - $class = $this->betterNodeFinder->findParentType($property, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $class = $this->betterNodeFinder->findParentType($property, Class_::class); + if (!$class instanceof Class_) { + throw new ShouldNotHappenException(); } - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($propertyName, $type, $property->flags); + $propertyMetadata = new PropertyMetadata($propertyName, $type, $property->flags); $this->propertyToAddCollector->addPropertyToClass($class, $propertyMetadata); } } diff --git a/rules/DependencyInjection/Rector/ClassMethod/AddMethodParentCallRector.php b/rules/DependencyInjection/Rector/ClassMethod/AddMethodParentCallRector.php index 99c8bb2ee1b..cc9550501d9 100644 --- a/rules/DependencyInjection/Rector/ClassMethod/AddMethodParentCallRector.php +++ b/rules/DependencyInjection/Rector/ClassMethod/AddMethodParentCallRector.php @@ -13,21 +13,21 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Enum\ObjectReference; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\MethodName; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\DependencyInjection\Rector\ClassMethod\AddMethodParentCallRector\AddMethodParentCallRectorTest */ -final class AddMethodParentCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class AddMethodParentCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var array */ private $methodByParentTypes = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add method parent call, in case new parent method is added', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add method parent call, in case new parent method is added', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SunshineCommand extends ParentClassWithNewConstructor { public function __construct() @@ -47,27 +47,27 @@ class SunshineCommand extends ParentClassWithNewConstructor } } CODE_SAMPLE -, ['ParentClassWithNewConstructor' => \Rector\Core\ValueObject\MethodName::CONSTRUCT])]); +, ['ParentClassWithNewConstructor' => MethodName::CONSTRUCT])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($node, ClassLike::class); + if (!$classLike instanceof ClassLike) { return null; } $className = (string) $this->nodeNameResolver->getName($classLike); foreach ($this->methodByParentTypes as $type => $method) { - if (!$this->isObjectType($classLike, new \PHPStan\Type\ObjectType($type))) { + if (!$this->isObjectType($classLike, new ObjectType($type))) { continue; } // not itself @@ -87,33 +87,33 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString(\array_keys($configuration)); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configuration); + Assert::allString(\array_keys($configuration)); + Assert::allString($configuration); /** @var array $configuration */ $this->methodByParentTypes = $configuration; } - private function shouldSkipMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $method) : bool + private function shouldSkipMethod(ClassMethod $classMethod, string $method) : bool { if (!$this->isName($classMethod, $method)) { return \true; } return $this->hasParentCallOfMethod($classMethod, $method); } - private function createParentStaticCall(string $method) : \PhpParser\Node\Stmt\Expression + private function createParentStaticCall(string $method) : Expression { - $staticCall = $this->nodeFactory->createStaticCall(\Rector\Core\Enum\ObjectReference::PARENT, $method); - return new \PhpParser\Node\Stmt\Expression($staticCall); + $staticCall = $this->nodeFactory->createStaticCall(ObjectReference::PARENT, $method); + return new Expression($staticCall); } /** * Looks for "parent:: */ - private function hasParentCallOfMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $method) : bool + private function hasParentCallOfMethod(ClassMethod $classMethod, string $method) : bool { - return (bool) $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (\PhpParser\Node $node) use($method) : bool { - if (!$node instanceof \PhpParser\Node\Expr\StaticCall) { + return (bool) $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (Node $node) use($method) : bool { + if (!$node instanceof StaticCall) { return \false; } - if (!$this->isName($node->class, \Rector\Core\Enum\ObjectReference::PARENT)) { + if (!$this->isName($node->class, ObjectReference::PARENT)) { return \false; } return $this->isName($node->name, $method); diff --git a/rules/DependencyInjection/Rector/Class_/ActionInjectionToConstructorInjectionRector.php b/rules/DependencyInjection/Rector/Class_/ActionInjectionToConstructorInjectionRector.php index 6e89557e48c..065b0789090 100644 --- a/rules/DependencyInjection/Rector/Class_/ActionInjectionToConstructorInjectionRector.php +++ b/rules/DependencyInjection/Rector/Class_/ActionInjectionToConstructorInjectionRector.php @@ -16,12 +16,12 @@ use Rector\DependencyInjection\Collector\VariablesToPropertyFetchCollection; use Rector\PostRector\Collector\PropertyToAddCollector; use Rector\PostRector\ValueObject\PropertyMetadata; use Rector\Symfony\DataProvider\ServiceMapProvider; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DependencyInjection\Rector\Class_\ActionInjectionToConstructorInjectionRector\ActionInjectionToConstructorInjectionRectorTest */ -final class ActionInjectionToConstructorInjectionRector extends \Rector\Core\Rector\AbstractRector +final class ActionInjectionToConstructorInjectionRector extends AbstractRector { /** * @readonly @@ -38,15 +38,15 @@ final class ActionInjectionToConstructorInjectionRector extends \Rector\Core\Rec * @var \Rector\PostRector\Collector\PropertyToAddCollector */ private $propertyToAddCollector; - public function __construct(\Rector\Symfony\DataProvider\ServiceMapProvider $applicationServiceMapProvider, \Rector\DependencyInjection\Collector\VariablesToPropertyFetchCollection $variablesToPropertyFetchCollection, \Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector) + public function __construct(ServiceMapProvider $applicationServiceMapProvider, VariablesToPropertyFetchCollection $variablesToPropertyFetchCollection, PropertyToAddCollector $propertyToAddCollector) { $this->applicationServiceMapProvider = $applicationServiceMapProvider; $this->variablesToPropertyFetchCollection = $variablesToPropertyFetchCollection; $this->propertyToAddCollector = $propertyToAddCollector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns action injection in Controllers to constructor injection', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns action injection in Controllers to constructor injection', [new CodeSample(<<<'CODE_SAMPLE' final class SomeController { public function default(ProductRepository $productRepository) @@ -76,12 +76,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, '*Controller')) { return null; @@ -94,13 +94,13 @@ CODE_SAMPLE } return $node; } - private function refactorVariablesToPropertyFetches(\PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function refactorVariablesToPropertyFetches(ClassMethod $classMethod) : void { if (!$classMethod->isPublic()) { return; } - $this->traverseNodesWithCallable((array) $classMethod->stmts, function (\PhpParser\Node $node) : ?PropertyFetch { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + $this->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) : ?PropertyFetch { + if (!$node instanceof Variable) { return null; } foreach ($this->variablesToPropertyFetchCollection->getVariableNamesAndTypes() as $name => $objectType) { @@ -115,25 +115,25 @@ CODE_SAMPLE return null; }); } - private function processClassMethod(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function processClassMethod(Class_ $class, ClassMethod $classMethod) : void { foreach ($classMethod->params as $key => $paramNode) { if (!$this->isActionInjectedParamNode($paramNode)) { continue; } $paramType = $this->getType($paramNode); - if (!$paramType instanceof \PHPStan\Type\ObjectType) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$paramType instanceof ObjectType) { + throw new ShouldNotHappenException(); } /** @var string $paramName */ $paramName = $this->getName($paramNode->var); - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($paramName, $paramType, \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $propertyMetadata = new PropertyMetadata($paramName, $paramType, Class_::MODIFIER_PRIVATE); $this->propertyToAddCollector->addPropertyToClass($class, $propertyMetadata); $this->nodeRemover->removeParam($classMethod, $key); $this->variablesToPropertyFetchCollection->addVariableNameAndType($paramName, $paramType); } } - private function isActionInjectedParamNode(\PhpParser\Node\Param $param) : bool + private function isActionInjectedParamNode(Param $param) : bool { if ($param->type === null) { return \false; @@ -143,7 +143,7 @@ CODE_SAMPLE return \false; } $paramStaticType = $this->getType($param); - if (!$paramStaticType instanceof \PHPStan\Type\ObjectType) { + if (!$paramStaticType instanceof ObjectType) { return \false; } $serviceMap = $this->applicationServiceMapProvider->provide(); diff --git a/rules/DogFood/NodeAnalyzer/ContainerConfiguratorCallAnalyzer.php b/rules/DogFood/NodeAnalyzer/ContainerConfiguratorCallAnalyzer.php index 984ab7c2f16..6f3d178b453 100644 --- a/rules/DogFood/NodeAnalyzer/ContainerConfiguratorCallAnalyzer.php +++ b/rules/DogFood/NodeAnalyzer/ContainerConfiguratorCallAnalyzer.php @@ -20,16 +20,16 @@ final class ContainerConfiguratorCallAnalyzer * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(ValueResolver $valueResolver, NodeNameResolver $nodeNameResolver) { $this->valueResolver = $valueResolver; $this->nodeNameResolver = $nodeNameResolver; } - public function isMethodCallWithServicesSetConfiguredRectorRule(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + public function isMethodCallWithServicesSetConfiguredRectorRule(MethodCall $methodCall) : bool { return $this->nodeNameResolver->isName($methodCall->name, 'configure'); } - public function isMethodCallWithServicesSetRectorRule(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + public function isMethodCallWithServicesSetRectorRule(MethodCall $methodCall) : bool { if (!$this->isMethodCallNamed($methodCall, 'services', 'set')) { return \false; @@ -39,11 +39,11 @@ final class ContainerConfiguratorCallAnalyzer if (!\is_string($serviceClass)) { return \false; } - return \is_a($serviceClass, \Rector\Core\Contract\Rector\RectorInterface::class, \true); + return \is_a($serviceClass, RectorInterface::class, \true); } - public function isMethodCallNamed(\PhpParser\Node\Expr $expr, string $variableName, string $methodName) : bool + public function isMethodCallNamed(Expr $expr, string $variableName, string $methodName) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$expr instanceof MethodCall) { return \false; } if (!$this->nodeNameResolver->isName($expr->var, $variableName)) { diff --git a/rules/DogFood/NodeManipulator/ContainerConfiguratorEmptyAssignRemover.php b/rules/DogFood/NodeManipulator/ContainerConfiguratorEmptyAssignRemover.php index 57d5ef79885..9085542c761 100644 --- a/rules/DogFood/NodeManipulator/ContainerConfiguratorEmptyAssignRemover.php +++ b/rules/DogFood/NodeManipulator/ContainerConfiguratorEmptyAssignRemover.php @@ -23,12 +23,12 @@ final class ContainerConfiguratorEmptyAssignRemover * @var \Rector\DeadCode\NodeAnalyzer\ExprUsedInNextNodeAnalyzer */ private $exprUsedInNextNodeAnalyzer; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\DeadCode\NodeAnalyzer\ExprUsedInNextNodeAnalyzer $exprUsedInNextNodeAnalyzer) + public function __construct(NodeNameResolver $nodeNameResolver, ExprUsedInNextNodeAnalyzer $exprUsedInNextNodeAnalyzer) { $this->nodeNameResolver = $nodeNameResolver; $this->exprUsedInNextNodeAnalyzer = $exprUsedInNextNodeAnalyzer; } - public function removeFromClosure(\PhpParser\Node\Expr\Closure $closure) : void + public function removeFromClosure(Closure $closure) : void { foreach ($closure->getStmts() as $key => $stmt) { if (!$this->isHelperAssign($stmt)) { @@ -51,16 +51,16 @@ final class ContainerConfiguratorEmptyAssignRemover * $services = $containerConfigurator->services(); * $parameters = $containerConfigurator->parameters(); */ - private function isHelperAssign(\PhpParser\Node\Stmt $stmt) : bool + private function isHelperAssign(Stmt $stmt) : bool { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { return \false; } $expression = $stmt->expr; - if (!$expression instanceof \PhpParser\Node\Expr\Assign) { + if (!$expression instanceof Assign) { return \false; } - if (!$expression->expr instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$expression->expr instanceof MethodCall) { return \false; } $methodCall = $expression->expr; diff --git a/rules/DogFood/NodeManipulator/ContainerConfiguratorImportsMerger.php b/rules/DogFood/NodeManipulator/ContainerConfiguratorImportsMerger.php index 9f10fca1ce6..9f93280998a 100644 --- a/rules/DogFood/NodeManipulator/ContainerConfiguratorImportsMerger.php +++ b/rules/DogFood/NodeManipulator/ContainerConfiguratorImportsMerger.php @@ -26,21 +26,21 @@ final class ContainerConfiguratorImportsMerger * @var \Rector\Core\PhpParser\Node\NodeFactory */ private $nodeFactory; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory) + public function __construct(NodeNameResolver $nodeNameResolver, NodeFactory $nodeFactory) { $this->nodeNameResolver = $nodeNameResolver; $this->nodeFactory = $nodeFactory; } - public function merge(\PhpParser\Node\Expr\Closure $closure) : void + public function merge(Closure $closure) : void { $setConstantFetches = []; $lastImportKey = null; foreach ($closure->getStmts() as $key => $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { continue; } $expr = $stmt->expr; - if (!$expr instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$expr instanceof MethodCall) { continue; } if (!$this->nodeNameResolver->isName($expr->name, 'import')) { @@ -48,7 +48,7 @@ final class ContainerConfiguratorImportsMerger } $importArg = $expr->getArgs(); $argValue = $importArg[0]->value; - if (!$argValue instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if (!$argValue instanceof ClassConstFetch) { continue; } $setConstantFetches[] = $argValue; @@ -59,8 +59,8 @@ final class ContainerConfiguratorImportsMerger return; } $args = $this->nodeFactory->createArgs([$setConstantFetches]); - $setsMethodCall = new \PhpParser\Node\Expr\MethodCall(new \PhpParser\Node\Expr\Variable(self::RECTOR_CONFIG_VARIABLE), 'sets', $args); - $closure->stmts[$lastImportKey] = new \PhpParser\Node\Stmt\Expression($setsMethodCall); + $setsMethodCall = new MethodCall(new Variable(self::RECTOR_CONFIG_VARIABLE), 'sets', $args); + $closure->stmts[$lastImportKey] = new Expression($setsMethodCall); \ksort($closure->stmts); } } diff --git a/rules/DogFood/Rector/Closure/UpgradeRectorConfigRector.php b/rules/DogFood/Rector/Closure/UpgradeRectorConfigRector.php index f42ff67f3bf..89279d4d570 100644 --- a/rules/DogFood/Rector/Closure/UpgradeRectorConfigRector.php +++ b/rules/DogFood/Rector/Closure/UpgradeRectorConfigRector.php @@ -19,17 +19,17 @@ use Rector\DogFood\NodeAnalyzer\ContainerConfiguratorCallAnalyzer; use Rector\DogFood\NodeManipulator\ContainerConfiguratorEmptyAssignRemover; use Rector\DogFood\NodeManipulator\ContainerConfiguratorImportsMerger; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DogFood\Rector\Closure\UpgradeRectorConfigRector\UpgradeRectorConfigRectorTest */ -final class UpgradeRectorConfigRector extends \Rector\Core\Rector\AbstractRector +final class UpgradeRectorConfigRector extends AbstractRector { /** * @var array */ - private const PARAMETER_NAME_TO_METHOD_CALL_MAP = [\Rector\Core\Configuration\Option::PATHS => 'paths', \Rector\Core\Configuration\Option::SKIP => 'skip', \Rector\Core\Configuration\Option::AUTOLOAD_PATHS => 'autoloadPaths', \Rector\Core\Configuration\Option::BOOTSTRAP_FILES => 'bootstrapFiles', \Rector\Core\Configuration\Option::IMPORT_SHORT_CLASSES => 'importShortClasses', \Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES => 'importNames', \Rector\Core\Configuration\Option::PARALLEL => 'parallel', \Rector\Core\Configuration\Option::PHPSTAN_FOR_RECTOR_PATH => 'phpstanConfig', \Rector\Core\Configuration\Option::PHP_VERSION_FEATURES => 'phpVersion', \Rector\Core\Configuration\Option::CACHE_CLASS => 'cacheClass', \Rector\Core\Configuration\Option::CACHE_DIR => 'cacheDirectory', \Rector\Core\Configuration\Option::NESTED_CHAIN_METHOD_CALL_LIMIT => 'nestedChainMethodCallLimit', \Rector\Core\Configuration\Option::FILE_EXTENSIONS => 'fileExtensions', \Rector\Core\Configuration\Option::SYMFONY_CONTAINER_PHP_PATH_PARAMETER => 'symfonyContainerPhp', \Rector\Core\Configuration\Option::SYMFONY_CONTAINER_XML_PATH_PARAMETER => 'symfonyContainerXml']; + private const PARAMETER_NAME_TO_METHOD_CALL_MAP = [Option::PATHS => 'paths', Option::SKIP => 'skip', Option::AUTOLOAD_PATHS => 'autoloadPaths', Option::BOOTSTRAP_FILES => 'bootstrapFiles', Option::IMPORT_SHORT_CLASSES => 'importShortClasses', Option::AUTO_IMPORT_NAMES => 'importNames', Option::PARALLEL => 'parallel', Option::PHPSTAN_FOR_RECTOR_PATH => 'phpstanConfig', Option::PHP_VERSION_FEATURES => 'phpVersion', Option::CACHE_CLASS => 'cacheClass', Option::CACHE_DIR => 'cacheDirectory', Option::NESTED_CHAIN_METHOD_CALL_LIMIT => 'nestedChainMethodCallLimit', Option::FILE_EXTENSIONS => 'fileExtensions', Option::SYMFONY_CONTAINER_PHP_PATH_PARAMETER => 'symfonyContainerPhp', Option::SYMFONY_CONTAINER_XML_PATH_PARAMETER => 'symfonyContainerXml']; /** * @var string */ @@ -70,16 +70,16 @@ final class UpgradeRectorConfigRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer */ private $fluentChainMethodCallNodeAnalyzer; - public function __construct(\Rector\DogFood\NodeAnalyzer\ContainerConfiguratorCallAnalyzer $containerConfiguratorCallAnalyzer, \Rector\DogFood\NodeManipulator\ContainerConfiguratorEmptyAssignRemover $containerConfiguratorEmptyAssignRemover, \Rector\DogFood\NodeManipulator\ContainerConfiguratorImportsMerger $containerConfiguratorImportsMerger, \Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer $fluentChainMethodCallNodeAnalyzer) + public function __construct(ContainerConfiguratorCallAnalyzer $containerConfiguratorCallAnalyzer, ContainerConfiguratorEmptyAssignRemover $containerConfiguratorEmptyAssignRemover, ContainerConfiguratorImportsMerger $containerConfiguratorImportsMerger, FluentChainMethodCallNodeAnalyzer $fluentChainMethodCallNodeAnalyzer) { $this->containerConfiguratorCallAnalyzer = $containerConfiguratorCallAnalyzer; $this->containerConfiguratorEmptyAssignRemover = $containerConfiguratorEmptyAssignRemover; $this->containerConfiguratorImportsMerger = $containerConfiguratorImportsMerger; $this->fluentChainMethodCallNodeAnalyzer = $fluentChainMethodCallNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Upgrade rector.php config to use of RectorConfig', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Upgrade rector.php config to use of RectorConfig', [new CodeSample(<<<'CODE_SAMPLE' use Rector\Core\Configuration\Option; use Rector\Php74\Rector\Property\TypedPropertyRector; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; @@ -111,12 +111,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Closure::class]; + return [Closure::class]; } /** * @param Closure $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isConfigClosure($node)) { return null; @@ -124,18 +124,18 @@ CODE_SAMPLE $this->updateClosureParam($node); // 1. change import of sets to single sets() method call $this->containerConfiguratorImportsMerger->merge($node); - $this->traverseNodesWithCallable($node->getStmts(), function (\PhpParser\Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\Variable && $this->isName($node, 'containerConfigurator')) { - return new \PhpParser\Node\Expr\Variable(self::RECTOR_CONFIG_VARIABLE); + $this->traverseNodesWithCallable($node->getStmts(), function (Node $node) : ?Node { + if ($node instanceof Variable && $this->isName($node, 'containerConfigurator')) { + return new Variable(self::RECTOR_CONFIG_VARIABLE); } // 2. call on rule - if ($node instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node instanceof MethodCall) { $nodeVarType = $this->nodeTypeResolver->getType($node->var); - if ($nodeVarType instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType && $nodeVarType->getClassName() === self::SERVICE_CONFIGURATOR_CLASS) { + if ($nodeVarType instanceof FullyQualifiedObjectType && $nodeVarType->getClassName() === self::SERVICE_CONFIGURATOR_CLASS) { if ($this->isFoundFluentServiceCall($node)) { return null; } - $isPossiblyServiceDefinition = (bool) $this->betterNodeFinder->findFirstPrevious($node, function (\PhpParser\Node $node) : bool { + $isPossiblyServiceDefinition = (bool) $this->betterNodeFinder->findFirstPrevious($node, function (Node $node) : bool { return $this->isFoundFluentServiceCall($node); }); if ($isPossiblyServiceDefinition) { @@ -147,8 +147,8 @@ CODE_SAMPLE } // look for "$services->set(SomeRector::Class)" if ($this->containerConfiguratorCallAnalyzer->isMethodCallWithServicesSetRectorRule($node)) { - $node->var = new \PhpParser\Node\Expr\Variable(self::RECTOR_CONFIG_VARIABLE); - $node->name = new \PhpParser\Node\Identifier('rule'); + $node->var = new Variable(self::RECTOR_CONFIG_VARIABLE); + $node->name = new Identifier('rule'); return $node; } if ($this->containerConfiguratorCallAnalyzer->isMethodCallNamed($node, self::PARAMETERS_VARIABLE, 'set')) { @@ -160,21 +160,21 @@ CODE_SAMPLE $this->containerConfiguratorEmptyAssignRemover->removeFromClosure($node); return $node; } - public function updateClosureParam(\PhpParser\Node\Expr\Closure $closure) : void + public function updateClosureParam(Closure $closure) : void { $param = $closure->params[0]; - if (!$param->type instanceof \PhpParser\Node\Name) { + if (!$param->type instanceof Name) { return; } // update closure params if (!$this->nodeNameResolver->isName($param->type, self::RECTOR_CONFIG_CLASS)) { - $param->type = new \PhpParser\Node\Name\FullyQualified(self::RECTOR_CONFIG_CLASS); + $param->type = new FullyQualified(self::RECTOR_CONFIG_CLASS); } if (!$this->nodeNameResolver->isName($param->var, self::RECTOR_CONFIG_VARIABLE)) { - $param->var = new \PhpParser\Node\Expr\Variable(self::RECTOR_CONFIG_VARIABLE); + $param->var = new Variable(self::RECTOR_CONFIG_VARIABLE); } } - public function isConfigClosure(\PhpParser\Node\Expr\Closure $closure) : bool + public function isConfigClosure(Closure $closure) : bool { $params = $closure->getParams(); if (\count($params) !== 1) { @@ -182,14 +182,14 @@ CODE_SAMPLE } $onlyParam = $params[0]; $paramType = $onlyParam->type; - if (!$paramType instanceof \PhpParser\Node\Name) { + if (!$paramType instanceof Name) { return \false; } return $this->isNames($paramType, [self::CONTAINER_CONFIGURATOR_CLASS, self::RECTOR_CONFIG_CLASS]); } - private function isFoundFluentServiceCall(\PhpParser\Node $node) : bool + private function isFoundFluentServiceCall(Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$node instanceof MethodCall) { return \false; } $chains = $this->fluentChainMethodCallNodeAnalyzer->collectMethodCallNamesInChain($node); @@ -208,21 +208,21 @@ CODE_SAMPLE /** * @return null|\PhpParser\Node\Expr\MethodCall */ - private function refactorConfigureRuleMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) + private function refactorConfigureRuleMethodCall(MethodCall $methodCall) { $caller = $methodCall->var; - if (!$caller instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$caller instanceof MethodCall) { return null; } if (!$this->containerConfiguratorCallAnalyzer->isMethodCallWithServicesSetRectorRule($caller)) { return null; } - $methodCall->var = new \PhpParser\Node\Expr\Variable(self::RECTOR_CONFIG_VARIABLE); - $methodCall->name = new \PhpParser\Node\Identifier('ruleWithConfiguration'); + $methodCall->var = new Variable(self::RECTOR_CONFIG_VARIABLE); + $methodCall->name = new Identifier('ruleWithConfiguration'); $methodCall->args = \array_merge($caller->getArgs(), $methodCall->getArgs()); return $methodCall; } - private function refactorParameterName(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node\Expr\MethodCall + private function refactorParameterName(MethodCall $methodCall) : ?MethodCall { $args = $methodCall->getArgs(); foreach (self::PARAMETER_NAME_TO_METHOD_CALL_MAP as $parameterName => $methodName) { @@ -230,7 +230,7 @@ CODE_SAMPLE continue; } $args = $this->valueResolver->isTrueOrFalse($args[1]->value) ? [] : [$args[1]]; - return new \PhpParser\Node\Expr\MethodCall(new \PhpParser\Node\Expr\Variable(self::RECTOR_CONFIG_VARIABLE), $methodName, $args); + return new MethodCall(new Variable(self::RECTOR_CONFIG_VARIABLE), $methodName, $args); } return null; } diff --git a/rules/DowngradePhp53/Rector/Dir/DirConstToFileConstRector.php b/rules/DowngradePhp53/Rector/Dir/DirConstToFileConstRector.php index f089313dafa..026983c0030 100644 --- a/rules/DowngradePhp53/Rector/Dir/DirConstToFileConstRector.php +++ b/rules/DowngradePhp53/Rector/Dir/DirConstToFileConstRector.php @@ -8,18 +8,18 @@ use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Scalar\MagicConst\Dir; use PhpParser\Node\Scalar\MagicConst\File; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/nikic/PHP-Backporter/blob/master/lib/PHPBackporter/Converter/Dir.php * * @see \Rector\Tests\DowngradePhp53\Rector\Dir\DirConstToFileConstRector\DirConstToFileConstRectorTest */ -final class DirConstToFileConstRector extends \Rector\Core\Rector\AbstractRector +final class DirConstToFileConstRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Refactor __DIR__ to dirname(__FILE__)', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Refactor __DIR__ to dirname(__FILE__)', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run() @@ -44,13 +44,13 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Scalar\MagicConst\Dir::class]; + return [Dir::class]; } /** * @param Dir $node */ - public function refactor(\PhpParser\Node $node) : \PhpParser\Node\Expr\FuncCall + public function refactor(Node $node) : FuncCall { - return $this->nodeFactory->createFuncCall('dirname', [new \PhpParser\Node\Scalar\MagicConst\File()]); + return $this->nodeFactory->createFuncCall('dirname', [new File()]); } } diff --git a/rules/DowngradePhp54/Rector/Array_/ShortArrayToLongArrayRector.php b/rules/DowngradePhp54/Rector/Array_/ShortArrayToLongArrayRector.php index 328d4610d63..d6a6193b6e4 100644 --- a/rules/DowngradePhp54/Rector/Array_/ShortArrayToLongArrayRector.php +++ b/rules/DowngradePhp54/Rector/Array_/ShortArrayToLongArrayRector.php @@ -7,18 +7,18 @@ use PhpParser\Node; use PhpParser\Node\Expr\Array_; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/shortsyntaxforarrays * * @see \Rector\Tests\DowngradePhp54\Rector\Array_\ShortArrayToLongArrayRector\ShortArrayToLongArrayRectorTest */ -final class ShortArrayToLongArrayRector extends \Rector\Core\Rector\AbstractRector +final class ShortArrayToLongArrayRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace short arrays by long arrays', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace short arrays by long arrays', [new CodeSample(<<<'CODE_SAMPLE' $a = [1, 2, 3]; CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -31,20 +31,20 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Array_::class]; + return [Array_::class]; } /** * @param Array_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Expr\Array_ + public function refactor(Node $node) : ?Array_ { - $kind = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND); - if ($kind === \PhpParser\Node\Expr\Array_::KIND_LONG) { + $kind = $node->getAttribute(AttributeKey::KIND); + if ($kind === Array_::KIND_LONG) { return null; } - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND, \PhpParser\Node\Expr\Array_::KIND_LONG); + $node->setAttribute(AttributeKey::KIND, Array_::KIND_LONG); // force php-parser to re-print: https://github.com/rectorphp/rector/issues/6618#issuecomment-893226087 - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); return $node; } } diff --git a/rules/DowngradePhp54/Rector/Closure/DowngradeStaticClosureRector.php b/rules/DowngradePhp54/Rector/Closure/DowngradeStaticClosureRector.php index 7a8c28e0f0c..47a62d36297 100644 --- a/rules/DowngradePhp54/Rector/Closure/DowngradeStaticClosureRector.php +++ b/rules/DowngradePhp54/Rector/Closure/DowngradeStaticClosureRector.php @@ -6,16 +6,16 @@ namespace Rector\DowngradePhp54\Rector\Closure; use PhpParser\Node; use PhpParser\Node\Expr\Closure; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp54\Rector\Closure\DowngradeStaticClosureRector\DowngradeStaticClosureRectorTest */ -final class DowngradeStaticClosureRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeStaticClosureRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove static from closure', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove static from closure', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run() @@ -44,12 +44,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Closure::class]; + return [Closure::class]; } /** * @param Closure $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$node->static) { return null; diff --git a/rules/DowngradePhp54/Rector/Closure/DowngradeThisInClosureRector.php b/rules/DowngradePhp54/Rector/Closure/DowngradeThisInClosureRector.php index 966da65f8f7..358021e31b1 100644 --- a/rules/DowngradePhp54/Rector/Closure/DowngradeThisInClosureRector.php +++ b/rules/DowngradePhp54/Rector/Closure/DowngradeThisInClosureRector.php @@ -17,14 +17,14 @@ use PHPStan\Reflection\Php\PhpPropertyReflection; use Rector\Core\PhpParser\Node\NamedVariableFactory; use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/closures/object-extension * * @see \Rector\Tests\DowngradePhp54\Rector\Closure\DowngradeThisInClosureRector\DowngradeThisInClosureRectorTest */ -final class DowngradeThisInClosureRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeThisInClosureRector extends AbstractRector { /** * @readonly @@ -36,14 +36,14 @@ final class DowngradeThisInClosureRector extends \Rector\Core\Rector\AbstractRec * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Core\PhpParser\Node\NamedVariableFactory $namedVariableFactory, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(NamedVariableFactory $namedVariableFactory, ReflectionResolver $reflectionResolver) { $this->namedVariableFactory = $namedVariableFactory; $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade $this-> inside Closure to use assigned $self = $this before Closure', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade $this-> inside Closure to use assigned $self = $this before Closure', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public $property = 'test'; @@ -81,27 +81,27 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Closure::class]; + return [Closure::class]; } /** * @param Closure $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $closureParentFunctionLike = $this->betterNodeFinder->findParentByTypes($node, [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class]); + $closureParentFunctionLike = $this->betterNodeFinder->findParentByTypes($node, [ClassMethod::class, Function_::class]); /** @var PropertyFetch[] $propertyFetches */ $propertyFetches = $this->resolvePropertyFetches($node, $closureParentFunctionLike); if ($propertyFetches === []) { return null; } $selfVariable = $this->namedVariableFactory->createVariable($node, 'self'); - $expression = new \PhpParser\Node\Stmt\Expression(new \PhpParser\Node\Expr\Assign($selfVariable, new \PhpParser\Node\Expr\Variable('this'))); + $expression = new Expression(new Assign($selfVariable, new Variable('this'))); $this->nodesToAddCollector->addNodeBeforeNode($expression, $node, $this->file->getSmartFileInfo()); - $this->traverseNodesWithCallable($node, function (\PhpParser\Node $subNode) use($selfVariable) : ?Closure { - if (!$subNode instanceof \PhpParser\Node\Expr\Closure) { + $this->traverseNodesWithCallable($node, function (Node $subNode) use($selfVariable) : ?Closure { + if (!$subNode instanceof Closure) { return null; } - $subNode->uses = \array_merge($subNode->uses, [new \PhpParser\Node\Expr\ClosureUse($selfVariable)]); + $subNode->uses = \array_merge($subNode->uses, [new ClosureUse($selfVariable)]); return $subNode; }); foreach ($propertyFetches as $propertyFetch) { @@ -112,26 +112,26 @@ CODE_SAMPLE /** * @return PropertyFetch[] */ - private function resolvePropertyFetches(\PhpParser\Node\Expr\Closure $node, ?\PhpParser\Node\FunctionLike $closureParentFunctionLike) : array + private function resolvePropertyFetches(Closure $node, ?FunctionLike $closureParentFunctionLike) : array { /** @var PropertyFetch[] $propertyFetches */ - $propertyFetches = $this->betterNodeFinder->find($node->stmts, function (\PhpParser\Node $subNode) use($closureParentFunctionLike) : bool { + $propertyFetches = $this->betterNodeFinder->find($node->stmts, function (Node $subNode) use($closureParentFunctionLike) : bool { // multiple deep Closure may access $this, unless its parent is not Closure - $parent = $this->betterNodeFinder->findParentByTypes($subNode, [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class]); - if ($parent instanceof \PhpParser\Node\FunctionLike && $parent !== $closureParentFunctionLike) { + $parent = $this->betterNodeFinder->findParentByTypes($subNode, [ClassMethod::class, Function_::class]); + if ($parent instanceof FunctionLike && $parent !== $closureParentFunctionLike) { return \false; } - if (!$subNode instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$subNode instanceof PropertyFetch) { return \false; } - if (!$subNode->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$subNode->var instanceof Variable) { return \false; } if (!$this->nodeNameResolver->isName($subNode->var, 'this')) { return \false; } $phpPropertyReflection = $this->reflectionResolver->resolvePropertyReflectionFromPropertyFetch($subNode); - if (!$phpPropertyReflection instanceof \PHPStan\Reflection\Php\PhpPropertyReflection) { + if (!$phpPropertyReflection instanceof PhpPropertyReflection) { return \false; } return $phpPropertyReflection->isPublic(); diff --git a/rules/DowngradePhp54/Rector/FuncCall/DowngradeIndirectCallByArrayRector.php b/rules/DowngradePhp54/Rector/FuncCall/DowngradeIndirectCallByArrayRector.php index a4d93a7a10f..a6e4c63a455 100644 --- a/rules/DowngradePhp54/Rector/FuncCall/DowngradeIndirectCallByArrayRector.php +++ b/rules/DowngradePhp54/Rector/FuncCall/DowngradeIndirectCallByArrayRector.php @@ -10,27 +10,27 @@ use PhpParser\Node\Expr\Variable; use PhpParser\Node\Name; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\TypeAnalyzer\StringTypeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/indirect-method-call-by-array-var * * @see \Rector\Tests\DowngradePhp54\Rector\FuncCall\DowngradeIndirectCallByArrayRector\DowngradeIndirectCallByArrayRectorTest */ -final class DowngradeIndirectCallByArrayRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeIndirectCallByArrayRector extends AbstractRector { /** * @readonly * @var \Rector\NodeTypeResolver\TypeAnalyzer\StringTypeAnalyzer */ private $stringTypeAnalyzer; - public function __construct(\Rector\NodeTypeResolver\TypeAnalyzer\StringTypeAnalyzer $stringTypeAnalyzer) + public function __construct(StringTypeAnalyzer $stringTypeAnalyzer) { $this->stringTypeAnalyzer = $stringTypeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade indirect method call by array variable', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade indirect method call by array variable', [new CodeSample(<<<'CODE_SAMPLE' class Hello { public static function world($x) { echo "Hello, $x\n"; @@ -57,20 +57,20 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Expr\FuncCall + public function refactor(Node $node) : ?FuncCall { - if (!$node->name instanceof \PhpParser\Node\Expr\Variable) { + if (!$node->name instanceof Variable) { return null; } if ($this->stringTypeAnalyzer->isStringOrUnionStringOnlyType($node->name)) { return null; } - $args = \array_merge([new \PhpParser\Node\Arg($node->name)], $node->args); - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('call_user_func'), $args); + $args = \array_merge([new Arg($node->name)], $node->args); + return new FuncCall(new Name('call_user_func'), $args); } } diff --git a/rules/DowngradePhp54/Rector/FunctionLike/DowngradeCallableTypeDeclarationRector.php b/rules/DowngradePhp54/Rector/FunctionLike/DowngradeCallableTypeDeclarationRector.php index 036bf8ab218..2b13ab9baa8 100644 --- a/rules/DowngradePhp54/Rector/FunctionLike/DowngradeCallableTypeDeclarationRector.php +++ b/rules/DowngradePhp54/Rector/FunctionLike/DowngradeCallableTypeDeclarationRector.php @@ -10,21 +10,21 @@ use PhpParser\Node\Stmt\Function_; use PHPStan\Type\CallableType; use Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/callable * * @see \Rector\Tests\DowngradePhp54\Rector\FunctionLike\DowngradeCallableTypeDeclarationRector\DowngradeCallableTypeDeclarationRectorTest */ -final class DowngradeCallableTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeCallableTypeDeclarationRector extends AbstractRector { /** * @readonly * @var \Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator */ private $phpDocFromTypeDeclarationDecorator; - public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator) + public function __construct(PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator) { $this->phpDocFromTypeDeclarationDecorator = $phpDocFromTypeDeclarationDecorator; } @@ -33,11 +33,11 @@ final class DowngradeCallableTypeDeclarationRector extends \Rector\Core\Rector\A */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Expr\Closure::class]; + return [Function_::class, ClassMethod::class, Closure::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove the "callable" param type, add a @param tag instead', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove the "callable" param type, add a @param tag instead', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function someFunction(callable $callback) @@ -61,9 +61,9 @@ CODE_SAMPLE /** * @param ClassMethod|Closure|Function_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $callableType = new \PHPStan\Type\CallableType(); + $callableType = new CallableType(); foreach ($node->getParams() as $param) { $this->phpDocFromTypeDeclarationDecorator->decorateParamWithSpecificType($param, $node, $callableType); } diff --git a/rules/DowngradePhp54/Rector/LNumber/DowngradeBinaryNotationRector.php b/rules/DowngradePhp54/Rector/LNumber/DowngradeBinaryNotationRector.php index aeb71265dde..e149580ac49 100644 --- a/rules/DowngradePhp54/Rector/LNumber/DowngradeBinaryNotationRector.php +++ b/rules/DowngradePhp54/Rector/LNumber/DowngradeBinaryNotationRector.php @@ -7,18 +7,18 @@ use PhpParser\Node; use PhpParser\Node\Scalar\LNumber; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/binnotation4ints * * @see \Rector\Tests\DowngradePhp54\Rector\LNumber\DowngradeBinaryNotationRector\DowngradeBinaryNotationRectorTest */ -final class DowngradeBinaryNotationRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeBinaryNotationRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade binary notation for integers', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade binary notation for integers', [new CodeSample(<<<'CODE_SAMPLE' $a = 0b11111100101; CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -31,20 +31,20 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Scalar\LNumber::class]; + return [LNumber::class]; } /** * @param LNumber $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Scalar\LNumber + public function refactor(Node $node) : ?LNumber { - $kind = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND); - if ($kind !== \PhpParser\Node\Scalar\LNumber::KIND_BIN) { + $kind = $node->getAttribute(AttributeKey::KIND); + if ($kind !== LNumber::KIND_BIN) { return null; } - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND, \PhpParser\Node\Scalar\LNumber::KIND_DEC); + $node->setAttribute(AttributeKey::KIND, LNumber::KIND_DEC); // force php-parser to re-print: https://github.com/rectorphp/rector/issues/6618#issuecomment-893226087 - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); return $node; } } diff --git a/rules/DowngradePhp54/Rector/MethodCall/DowngradeInstanceMethodCallRector.php b/rules/DowngradePhp54/Rector/MethodCall/DowngradeInstanceMethodCallRector.php index 41f207761a8..992085286ac 100644 --- a/rules/DowngradePhp54/Rector/MethodCall/DowngradeInstanceMethodCallRector.php +++ b/rules/DowngradePhp54/Rector/MethodCall/DowngradeInstanceMethodCallRector.php @@ -14,27 +14,27 @@ use PhpParser\Node\Stmt\Expression; use Rector\Core\PhpParser\Node\NamedVariableFactory; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/instance-method-call * * @see \Rector\Tests\DowngradePhp54\Rector\MethodCall\DowngradeInstanceMethodCallRector\DowngradeInstanceMethodCallRectorTest */ -final class DowngradeInstanceMethodCallRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeInstanceMethodCallRector extends AbstractRector { /** * @readonly * @var \Rector\Core\PhpParser\Node\NamedVariableFactory */ private $namedVariableFactory; - public function __construct(\Rector\Core\PhpParser\Node\NamedVariableFactory $namedVariableFactory) + public function __construct(NamedVariableFactory $namedVariableFactory) { $this->namedVariableFactory = $namedVariableFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade instance and method call/property access', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade instance and method call/property access', [new CodeSample(<<<'CODE_SAMPLE' echo (new \ReflectionClass('\\stdClass'))->getName(); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -48,22 +48,22 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\PropertyFetch::class, \PhpParser\Node\Expr\ArrayDimFetch::class]; + return [MethodCall::class, PropertyFetch::class, ArrayDimFetch::class]; } /** * @param ArrayDimFetch|MethodCall|PropertyFetch $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } $variable = $this->namedVariableFactory->createVariable($node, 'object'); - $expression = new \PhpParser\Node\Stmt\Expression(new \PhpParser\Node\Expr\Assign($variable, $node->var)); + $expression = new Expression(new Assign($variable, $node->var)); $this->nodesToAddCollector->addNodeBeforeNode($expression, $node, $this->file->getSmartFileInfo()); $node->var = $variable; // necessary to remove useless parentheses - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); return $node; } /** @@ -71,9 +71,9 @@ CODE_SAMPLE */ private function shouldSkip($node) : bool { - if ($node->var instanceof \PhpParser\Node\Expr\New_) { + if ($node->var instanceof New_) { return \false; } - return !$node->var instanceof \PhpParser\Node\Expr\Clone_; + return !$node->var instanceof Clone_; } } diff --git a/rules/DowngradePhp55/Rector/ClassConstFetch/DowngradeClassConstantToStringRector.php b/rules/DowngradePhp55/Rector/ClassConstFetch/DowngradeClassConstantToStringRector.php index af73bbe67e2..584efa75928 100644 --- a/rules/DowngradePhp55/Rector/ClassConstFetch/DowngradeClassConstantToStringRector.php +++ b/rules/DowngradePhp55/Rector/ClassConstFetch/DowngradeClassConstantToStringRector.php @@ -9,18 +9,18 @@ use PhpParser\Node\Identifier; use PhpParser\Node\Name; use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/class_name_scalars * * @see Rector\Tests\DowngradePhp55\Rector\ClassConstFetch\DowngradeClassConstantToStringRector\DowngradeClassConstantToStringRectorTest */ -final class DowngradeClassConstantToStringRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeClassConstantToStringRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace ::class constant by string class names', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace ::class constant by string class names', [new CodeSample(<<<'CODE_SAMPLE' class AnotherClass { } @@ -51,20 +51,20 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\ClassConstFetch::class]; + return [ClassConstFetch::class]; } /** * @param ClassConstFetch $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->name instanceof \PhpParser\Node\Identifier) { + if (!$node->name instanceof Identifier) { return null; } if (\strtolower($node->name->name) !== 'class') { return null; } - if (!$node->class instanceof \PhpParser\Node\Name) { + if (!$node->class instanceof Name) { return null; } $className = $node->class->toString(); @@ -85,6 +85,6 @@ CODE_SAMPLE if ($func !== null) { return $this->nodeFactory->createFuncCall($func); } - return new \PhpParser\Node\Scalar\String_($className); + return new String_($className); } } diff --git a/rules/DowngradePhp55/Rector/Foreach_/DowngradeForeachListRector.php b/rules/DowngradePhp55/Rector/Foreach_/DowngradeForeachListRector.php index e716bb185fe..eb7d6353e9c 100644 --- a/rules/DowngradePhp55/Rector/Foreach_/DowngradeForeachListRector.php +++ b/rules/DowngradePhp55/Rector/Foreach_/DowngradeForeachListRector.php @@ -10,27 +10,27 @@ use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\Foreach_; use Rector\Core\PhpParser\Node\NamedVariableFactory; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/foreachlist * * @see \Rector\Tests\DowngradePhp55\Rector\Foreach_\DowngradeForeachListRector\DowngradeForeachListRectorTest */ -final class DowngradeForeachListRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeForeachListRector extends AbstractRector { /** * @readonly * @var \Rector\Core\PhpParser\Node\NamedVariableFactory */ private $namedVariableFactory; - public function __construct(\Rector\Core\PhpParser\Node\NamedVariableFactory $namedVariableFactory) + public function __construct(NamedVariableFactory $namedVariableFactory) { $this->namedVariableFactory = $namedVariableFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade list() support in foreach constructs', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade list() support in foreach constructs', [new CodeSample(<<<'CODE_SAMPLE' foreach ($array as $key => list($item1, $item2)) { var_dump($item1, $item2); } @@ -48,18 +48,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Foreach_::class]; + return [Foreach_::class]; } /** * @param Foreach_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->valueVar instanceof \PhpParser\Node\Expr\List_) { + if (!$node->valueVar instanceof List_) { return null; } $variable = $this->namedVariableFactory->createVariable($node, 'arrayItem'); - $expression = new \PhpParser\Node\Stmt\Expression(new \PhpParser\Node\Expr\Assign($node->valueVar, $variable)); + $expression = new Expression(new Assign($node->valueVar, $variable)); $node->valueVar = $variable; $node->stmts = \array_merge([$expression], $node->stmts); return $node; diff --git a/rules/DowngradePhp55/Rector/FuncCall/DowngradeBoolvalRector.php b/rules/DowngradePhp55/Rector/FuncCall/DowngradeBoolvalRector.php index 76a546fa31b..eb05871ac21 100644 --- a/rules/DowngradePhp55/Rector/FuncCall/DowngradeBoolvalRector.php +++ b/rules/DowngradePhp55/Rector/FuncCall/DowngradeBoolvalRector.php @@ -20,14 +20,14 @@ use PHPStan\Type\Type; use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://externals.io/message/60337 https://www.php.net/manual/en/function.boolval.php * * @see \Rector\Tests\DowngradePhp55\Rector\FuncCall\DowngradeBoolvalRector\DowngradeBoolvalRectorTest */ -final class DowngradeBoolvalRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeBoolvalRector extends AbstractRector { /** * @var string @@ -38,13 +38,13 @@ final class DowngradeBoolvalRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(ReflectionResolver $reflectionResolver) { $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace boolval() by type casting to boolean', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace boolval() by type casting to boolean', [new CodeSample(<<<'CODE_SAMPLE' $bool = boolval($value); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -57,34 +57,34 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->isName($node, self::BOOLVAL)) { return $this->refactorBoolval($node); } return $this->refactorAsCallback($node); } - private function refactorBoolval(\PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Expr\Cast\Bool_ + private function refactorBoolval(FuncCall $funcCall) : ?Bool_ { if (!isset($funcCall->args[0])) { return null; } - if (!$funcCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[0] instanceof Arg) { return null; } - return new \PhpParser\Node\Expr\Cast\Bool_($funcCall->args[0]->value); + return new Bool_($funcCall->args[0]->value); } - private function refactorAsCallback(\PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Expr\FuncCall + private function refactorAsCallback(FuncCall $funcCall) : ?FuncCall { $functionLikeReflection = null; $refactored = \false; foreach ($funcCall->args as $position => $arg) { - if (!$arg instanceof \PhpParser\Node\Arg) { + if (!$arg instanceof Arg) { continue; } if (!$this->isBoolvalReference($arg)) { @@ -92,7 +92,7 @@ CODE_SAMPLE } if ($functionLikeReflection === null) { $functionLikeReflection = $this->reflectionResolver->resolveFunctionLikeReflectionFromCall($funcCall); - if (!$functionLikeReflection instanceof \PHPStan\Reflection\FunctionReflection) { + if (!$functionLikeReflection instanceof FunctionReflection) { break; } } @@ -104,18 +104,18 @@ CODE_SAMPLE } return $refactored ? $funcCall : null; } - private function isBoolvalReference(\PhpParser\Node\Arg $arg) : bool + private function isBoolvalReference(Arg $arg) : bool { - if (!$arg->value instanceof \PhpParser\Node\Scalar\String_) { + if (!$arg->value instanceof String_) { return \false; } return \strtolower($arg->value->value) === self::BOOLVAL; } - private function getParameterType(\PHPStan\Reflection\FunctionReflection $functionReflection, \PhpParser\Node\Expr\FuncCall $funcCall, int $position) : ?\PHPStan\Type\Type + private function getParameterType(FunctionReflection $functionReflection, FuncCall $funcCall, int $position) : ?Type { try { - $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectFromArgs($funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE), $funcCall->args, $functionReflection->getVariants()); - } catch (\PHPStan\ShouldNotHappenException $exception) { + $parametersAcceptor = ParametersAcceptorSelector::selectFromArgs($funcCall->getAttribute(AttributeKey::SCOPE), $funcCall->args, $functionReflection->getVariants()); + } catch (ShouldNotHappenException $exception) { return null; } $parameters = $parametersAcceptor->getParameters(); @@ -124,20 +124,20 @@ CODE_SAMPLE } return $parameters[$position]->getType(); } - private function isCallable(?\PHPStan\Type\Type $type) : bool + private function isCallable(?Type $type) : bool { - if (!$type instanceof \PHPStan\Type\Type) { + if (!$type instanceof Type) { return \false; } - $trinaryLogic = $type->accepts(new \PHPStan\Type\CallableType(), \false); + $trinaryLogic = $type->accepts(new CallableType(), \false); return $trinaryLogic->yes(); } - private function createBoolCastClosure() : \PhpParser\Node\Expr\Closure + private function createBoolCastClosure() : Closure { - $variable = new \PhpParser\Node\Expr\Variable('value'); - $closure = new \PhpParser\Node\Expr\Closure(); - $closure->params[] = new \PhpParser\Node\Param($variable); - $closure->stmts[] = new \PhpParser\Node\Stmt\Return_(new \PhpParser\Node\Expr\Cast\Bool_($variable)); + $variable = new Variable('value'); + $closure = new Closure(); + $closure->params[] = new Param($variable); + $closure->stmts[] = new Return_(new Bool_($variable)); return $closure; } } diff --git a/rules/DowngradePhp55/Rector/Isset_/DowngradeArbitraryExpressionArgsToEmptyAndIssetRector.php b/rules/DowngradePhp55/Rector/Isset_/DowngradeArbitraryExpressionArgsToEmptyAndIssetRector.php index 8ef017f31fb..43acddd1f90 100644 --- a/rules/DowngradePhp55/Rector/Isset_/DowngradeArbitraryExpressionArgsToEmptyAndIssetRector.php +++ b/rules/DowngradePhp55/Rector/Isset_/DowngradeArbitraryExpressionArgsToEmptyAndIssetRector.php @@ -15,19 +15,19 @@ use PhpParser\Node\Expr\PropertyFetch; use PhpParser\Node\Expr\StaticPropertyFetch; use PhpParser\Node\Expr\Variable; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @changelog https://wiki.php.net/rfc/empty_isset_exprs * * @see Rector\Tests\DowngradePhp55\Rector\Isset_\DowngradeArbitraryExpressionArgsToEmptyAndIssetRector\DowngradeArbitraryExpressionArgsToEmptyAndIssetRectorTest */ -final class DowngradeArbitraryExpressionArgsToEmptyAndIssetRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeArbitraryExpressionArgsToEmptyAndIssetRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade arbitrary expression arguments to empty() and isset()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade arbitrary expression arguments to empty() and isset()', [new CodeSample(<<<'CODE_SAMPLE' if (isset(some_function())) { // ... } @@ -44,24 +44,24 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Isset_::class, \PhpParser\Node\Expr\Empty_::class]; + return [Isset_::class, Empty_::class]; } /** * @param Isset_|Empty_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } - return $node instanceof \PhpParser\Node\Expr\Empty_ ? $this->refactorEmpty($node) : $this->refactorIsset($node); + return $node instanceof Empty_ ? $this->refactorEmpty($node) : $this->refactorIsset($node); } /** * @param \PhpParser\Node\Expr\Isset_|\PhpParser\Node\Expr\Empty_ $node */ private function shouldSkip($node) : bool { - if ($node instanceof \PhpParser\Node\Expr\Empty_) { + if ($node instanceof Empty_) { return $this->isAcceptable($node->expr); } foreach ($node->vars as $var) { @@ -74,51 +74,51 @@ CODE_SAMPLE /** * Check whether an expression can be passed to empty/isset before PHP 5.5 */ - private function isAcceptable(\PhpParser\Node\Expr $expr) : bool + private function isAcceptable(Expr $expr) : bool { - if ($expr instanceof \PhpParser\Node\Expr\Variable) { + if ($expr instanceof Variable) { return \true; } - if ($expr instanceof \PhpParser\Node\Expr\PropertyFetch) { + if ($expr instanceof PropertyFetch) { return \true; } - if ($expr instanceof \PhpParser\Node\Expr\StaticPropertyFetch) { + if ($expr instanceof StaticPropertyFetch) { return \true; } - return $expr instanceof \PhpParser\Node\Expr\ArrayDimFetch; + return $expr instanceof ArrayDimFetch; } - private function refactorEmpty(\PhpParser\Node\Expr\Empty_ $empty) : \PhpParser\Node\Expr\BooleanNot + private function refactorEmpty(Empty_ $empty) : BooleanNot { - return new \PhpParser\Node\Expr\BooleanNot($empty->expr); + return new BooleanNot($empty->expr); } - private function refactorIsset(\PhpParser\Node\Expr\Isset_ $isset) : \PhpParser\Node\Expr + private function refactorIsset(Isset_ $isset) : Expr { $exprs = []; $currentExpr = null; foreach ($isset->vars as $var) { if (!$this->isAcceptable($var)) { - $currentExpr = new \PhpParser\Node\Expr\BinaryOp\NotIdentical($var, $this->nodeFactory->createNull()); + $currentExpr = new NotIdentical($var, $this->nodeFactory->createNull()); $exprs[] = $currentExpr; continue; } - if (!$currentExpr instanceof \PhpParser\Node\Expr\Isset_) { - $currentExpr = new \PhpParser\Node\Expr\Isset_([]); + if (!$currentExpr instanceof Isset_) { + $currentExpr = new Isset_([]); $exprs[] = $currentExpr; } $currentExpr->vars[] = $var; } - \RectorPrefix20220607\Webmozart\Assert\Assert::minCount($exprs, 1); + Assert::minCount($exprs, 1); return $this->joinWithBooleanAnd($exprs); } /** * @param non-empty-array $exprs */ - private function joinWithBooleanAnd(array $exprs) : \PhpParser\Node\Expr + private function joinWithBooleanAnd(array $exprs) : Expr { $expr = $exprs[0]; $nbExprs = \count($exprs); for ($i = 1; $i < $nbExprs; ++$i) { - $expr = new \PhpParser\Node\Expr\BinaryOp\BooleanAnd($expr, $exprs[$i]); + $expr = new BooleanAnd($expr, $exprs[$i]); } return $expr; } diff --git a/rules/DowngradePhp56/NodeManipulator/ArgManipulator.php b/rules/DowngradePhp56/NodeManipulator/ArgManipulator.php index 171d0302ade..bc6d0b665ec 100644 --- a/rules/DowngradePhp56/NodeManipulator/ArgManipulator.php +++ b/rules/DowngradePhp56/NodeManipulator/ArgManipulator.php @@ -37,7 +37,7 @@ final class ArgManipulator if (!$arg->unpack) { continue; } - if ($arg->value instanceof \PhpParser\Node\Expr\Array_) { + if ($arg->value instanceof Array_) { continue; } return \false; diff --git a/rules/DowngradePhp56/NodeManipulator/UnpackedArgList.php b/rules/DowngradePhp56/NodeManipulator/UnpackedArgList.php index dd3988f1bb8..74f3664d7dc 100644 --- a/rules/DowngradePhp56/NodeManipulator/UnpackedArgList.php +++ b/rules/DowngradePhp56/NodeManipulator/UnpackedArgList.php @@ -32,9 +32,9 @@ final class UnpackedArgList { return $this->args; } - public function addArg(\PhpParser\Node\Arg $arg) : void + public function addArg(Arg $arg) : void { - $this->args[$this->pointer] = $this->args[$this->pointer] ?? new \PhpParser\Node\Arg(new \PhpParser\Node\Expr\Array_()); + $this->args[$this->pointer] = $this->args[$this->pointer] ?? new Arg(new Array_()); if ($arg->unpack) { $arg->unpack = \false; $this->unpack($arg); @@ -42,9 +42,9 @@ final class UnpackedArgList } $this->addAsItem($arg); } - private function unpack(\PhpParser\Node\Arg $arg) : void + private function unpack(Arg $arg) : void { - if ($arg->value instanceof \PhpParser\Node\Expr\Array_) { + if ($arg->value instanceof Array_) { foreach ($arg->value->items as $arrayItem) { if ($arrayItem === null) { continue; @@ -55,17 +55,17 @@ final class UnpackedArgList } $this->addNextArg($arg); } - private function addAsItem(\PhpParser\Node\Arg $arg) : void + private function addAsItem(Arg $arg) : void { - $this->addArrayItem(new \PhpParser\Node\Expr\ArrayItem($arg->value)); + $this->addArrayItem(new ArrayItem($arg->value)); } - private function addArrayItem(\PhpParser\Node\Expr\ArrayItem $arrayItem) : void + private function addArrayItem(ArrayItem $arrayItem) : void { /** @var Array_ $array */ $array = $this->args[$this->pointer]->value; $array->items[] = $arrayItem; } - private function addNextArg(\PhpParser\Node\Arg $arg) : void + private function addNextArg(Arg $arg) : void { $this->next(); $this->args[$this->pointer] = $arg; diff --git a/rules/DowngradePhp56/Rector/CallLike/DowngradeArgumentUnpackingRector.php b/rules/DowngradePhp56/Rector/CallLike/DowngradeArgumentUnpackingRector.php index 82ced3dfc2c..05c68d4bd35 100644 --- a/rules/DowngradePhp56/Rector/CallLike/DowngradeArgumentUnpackingRector.php +++ b/rules/DowngradePhp56/Rector/CallLike/DowngradeArgumentUnpackingRector.php @@ -20,28 +20,28 @@ use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; use Rector\DowngradePhp56\NodeManipulator\ArgManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @changelog https://wiki.php.net/rfc/argument_unpacking * * @see \Rector\Tests\DowngradePhp56\Rector\CallLike\DowngradeArgumentUnpackingRector\DowngradeArgumentUnpackingRectorTest */ -final class DowngradeArgumentUnpackingRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeArgumentUnpackingRector extends AbstractRector { /** * @readonly * @var \Rector\DowngradePhp56\NodeManipulator\ArgManipulator */ private $argManipulator; - public function __construct(\Rector\DowngradePhp56\NodeManipulator\ArgManipulator $argManipulator) + public function __construct(ArgManipulator $argManipulator) { $this->argManipulator = $argManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace argument unpacking by call_user_func_array()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace argument unpacking by call_user_func_array()', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(array $items) @@ -66,27 +66,27 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\CallLike::class]; + return [CallLike::class]; } /** * @param CallLike $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $args = $node->getArgs(); if ($this->shouldSkip($args)) { return null; } - if ($node instanceof \PhpParser\Node\Expr\FuncCall) { + if ($node instanceof FuncCall) { return $this->createCallUserFuncArrayFuncCall($this->funcCallToCallbackArg($node), $args); } - if ($node instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node instanceof MethodCall) { return $this->createCallUserFuncArrayFuncCall($this->methodCallToCallbackArg($node), $args); } - if ($node instanceof \PhpParser\Node\Expr\New_) { + if ($node instanceof New_) { return $this->createReflectionInstantiation($node, $args); } - if ($node instanceof \PhpParser\Node\Expr\StaticCall) { + if ($node instanceof StaticCall) { return $this->createCallUserFuncArrayFuncCall($this->staticCallToCallbackArg($node), $args); } return null; @@ -98,84 +98,84 @@ CODE_SAMPLE { return !$this->argManipulator->hasUnpackedArg($args); } - private function funcCallToCallbackArg(\PhpParser\Node\Expr\FuncCall $funcCall) : \PhpParser\Node\Arg + private function funcCallToCallbackArg(FuncCall $funcCall) : Arg { - $callback = $funcCall->name instanceof \PhpParser\Node\Name ? new \PhpParser\Node\Scalar\String_($funcCall->name->toString()) : $funcCall->name; - return new \PhpParser\Node\Arg($callback); + $callback = $funcCall->name instanceof Name ? new String_($funcCall->name->toString()) : $funcCall->name; + return new Arg($callback); } - private function methodCallToCallbackArg(\PhpParser\Node\Expr\MethodCall $methodCall) : \PhpParser\Node\Arg + private function methodCallToCallbackArg(MethodCall $methodCall) : Arg { $object = $methodCall->var; - $method = $methodCall->name instanceof \PhpParser\Node\Identifier ? new \PhpParser\Node\Scalar\String_($methodCall->name->toString()) : $methodCall->name; - $array = new \PhpParser\Node\Expr\Array_([new \PhpParser\Node\Expr\ArrayItem($object), new \PhpParser\Node\Expr\ArrayItem($method)]); - return new \PhpParser\Node\Arg($array); + $method = $methodCall->name instanceof Identifier ? new String_($methodCall->name->toString()) : $methodCall->name; + $array = new Array_([new ArrayItem($object), new ArrayItem($method)]); + return new Arg($array); } - private function staticCallToCallbackArg(\PhpParser\Node\Expr\StaticCall $staticCall) : \PhpParser\Node\Arg + private function staticCallToCallbackArg(StaticCall $staticCall) : Arg { - if ($staticCall->class instanceof \PhpParser\Node\Name) { - $class = $staticCall->class->isSpecialClassName() ? new \PhpParser\Node\Scalar\String_($staticCall->class->toString()) : new \PhpParser\Node\Expr\ClassConstFetch($staticCall->class, 'class'); + if ($staticCall->class instanceof Name) { + $class = $staticCall->class->isSpecialClassName() ? new String_($staticCall->class->toString()) : new ClassConstFetch($staticCall->class, 'class'); } else { $class = $staticCall->class; } - $method = $staticCall->name instanceof \PhpParser\Node\Identifier ? new \PhpParser\Node\Scalar\String_($staticCall->name->toString()) : $staticCall->name; - $array = new \PhpParser\Node\Expr\Array_([new \PhpParser\Node\Expr\ArrayItem($class), new \PhpParser\Node\Expr\ArrayItem($method)]); - return new \PhpParser\Node\Arg($array); + $method = $staticCall->name instanceof Identifier ? new String_($staticCall->name->toString()) : $staticCall->name; + $array = new Array_([new ArrayItem($class), new ArrayItem($method)]); + return new Arg($array); } /** * @param Arg[] $args */ - private function createCallUserFuncArrayFuncCall(\PhpParser\Node\Arg $arg, array $args) : \PhpParser\Node\Expr\FuncCall + private function createCallUserFuncArrayFuncCall(Arg $arg, array $args) : FuncCall { - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('call_user_func_array'), [$arg, $this->mergeArgs($args)]); + return new FuncCall(new Name('call_user_func_array'), [$arg, $this->mergeArgs($args)]); } /** * @param Arg[] $args */ - private function mergeArgs(array $args) : \PhpParser\Node\Arg + private function mergeArgs(array $args) : Arg { $unpackedArgs = $this->argManipulator->unpack($args); if (\count($unpackedArgs) === 1) { return $unpackedArgs[0]; } - return new \PhpParser\Node\Arg(new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('array_merge'), $unpackedArgs)); + return new Arg(new FuncCall(new Name('array_merge'), $unpackedArgs)); } /** * @param Arg[] $args */ - private function createReflectionInstantiation(\PhpParser\Node\Expr\New_ $new, array $args) : ?\PhpParser\Node\Expr + private function createReflectionInstantiation(New_ $new, array $args) : ?Expr { if ($this->argManipulator->canBeInlined($args)) { $unpackedArgs = $this->argManipulator->unpack($args); - \RectorPrefix20220607\Webmozart\Assert\Assert::minCount($unpackedArgs, 1); + Assert::minCount($unpackedArgs, 1); /** @var Array_ $array */ $array = $unpackedArgs[0]->value; $arrayItems = \array_filter($array->items); - $new->args = \array_map(function (\PhpParser\Node\Expr\ArrayItem $item) : Arg { - return new \PhpParser\Node\Arg($item->value); + $new->args = \array_map(function (ArrayItem $item) : Arg { + return new Arg($item->value); }, $arrayItems); return $new; } - if ($new->class instanceof \PhpParser\Node\Name) { + if ($new->class instanceof Name) { switch (\strtolower($new->class->toString())) { case 'self': - $class = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('get_class')); + $class = new FuncCall(new Name('get_class')); break; case 'static': - $class = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('get_called_class')); + $class = new FuncCall(new Name('get_called_class')); break; case 'parent': - $class = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('get_parent_class')); + $class = new FuncCall(new Name('get_parent_class')); break; default: - $class = new \PhpParser\Node\Expr\ClassConstFetch($new->class, 'class'); + $class = new ClassConstFetch($new->class, 'class'); break; } - } elseif ($new->class instanceof \PhpParser\Node\Expr) { + } elseif ($new->class instanceof Expr) { $class = $new->class; } else { return null; } - $newReflection = new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name\FullyQualified('ReflectionClass'), [new \PhpParser\Node\Arg($class)]); - return new \PhpParser\Node\Expr\MethodCall($newReflection, 'newInstanceArgs', [$this->mergeArgs($args)]); + $newReflection = new New_(new FullyQualified('ReflectionClass'), [new Arg($class)]); + return new MethodCall($newReflection, 'newInstanceArgs', [$this->mergeArgs($args)]); } } diff --git a/rules/DowngradePhp56/Rector/FuncCall/DowngradeArrayFilterUseConstantRector.php b/rules/DowngradePhp56/Rector/FuncCall/DowngradeArrayFilterUseConstantRector.php index 44f7aa7fe66..6ead00233ff 100644 --- a/rules/DowngradePhp56/Rector/FuncCall/DowngradeArrayFilterUseConstantRector.php +++ b/rules/DowngradePhp56/Rector/FuncCall/DowngradeArrayFilterUseConstantRector.php @@ -22,14 +22,14 @@ use Rector\Core\Rector\AbstractRector; use Rector\Naming\Naming\VariableNaming; use Rector\NodeTypeResolver\Node\AttributeKey; use RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/function.array-filter.php * * @see \Rector\Tests\DowngradePhp56\Rector\FuncCall\DowngradeArrayFilterUseConstantRector\DowngradeArrayFilterUseConstantRectorTest */ -final class DowngradeArrayFilterUseConstantRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeArrayFilterUseConstantRector extends AbstractRector { /** * @readonly @@ -41,14 +41,14 @@ final class DowngradeArrayFilterUseConstantRector extends \Rector\Core\Rector\Ab * @var \Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser */ private $simpleCallableNodeTraverser; - public function __construct(\Rector\Naming\Naming\VariableNaming $variableNaming, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser) + public function __construct(VariableNaming $variableNaming, SimpleCallableNodeTraverser $simpleCallableNodeTraverser) { $this->variableNaming = $variableNaming; $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace use ARRAY_FILTER_USE_BOTH and ARRAY_FILTER_USE_KEY to loop to filter it', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace use ARRAY_FILTER_USE_BOTH and ARRAY_FILTER_USE_KEY to loop to filter it', [new CodeSample(<<<'CODE_SAMPLE' $arr = ['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4]; var_dump(array_filter($arr, function($v, $k) { @@ -74,18 +74,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $args = $node->getArgs(); if ($this->shouldSkip($node, $args)) { return null; } - if ($args[1]->value instanceof \PhpParser\Node\Expr\Closure) { + if ($args[1]->value instanceof Closure) { return $this->processClosure($node, $args); } return null; @@ -93,18 +93,18 @@ CODE_SAMPLE /** * @param Arg[] $args */ - private function processClosure(\PhpParser\Node\Expr\FuncCall $funcCall, array $args) : ?\PhpParser\Node\Expr\Variable + private function processClosure(FuncCall $funcCall, array $args) : ?Variable { /** @var Closure $closure */ $closure = $args[1]->value; /** @var Return_[] $returns */ - $returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($closure, \PhpParser\Node\Stmt\Return_::class); + $returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($closure, Return_::class); if ($returns === []) { return null; } - $scope = $funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - $variable = new \PhpParser\Node\Expr\Variable($this->variableNaming->createCountedValueName('result', $scope)); - $this->nodesToAddCollector->addNodeBeforeNode(new \PhpParser\Node\Stmt\Expression(new \PhpParser\Node\Expr\Assign($variable, new \PhpParser\Node\Expr\Array_([]))), $funcCall, $this->file->getSmartFileInfo()); + $scope = $funcCall->getAttribute(AttributeKey::SCOPE); + $variable = new Variable($this->variableNaming->createCountedValueName('result', $scope)); + $this->nodesToAddCollector->addNodeBeforeNode(new Expression(new Assign($variable, new Array_([]))), $funcCall, $this->file->getSmartFileInfo()); /** @var ConstFetch $constant */ $constant = $args[2]->value; $foreach = $this->nodeNameResolver->isName($constant, 'ARRAY_FILTER_USE_KEY') ? $this->applyArrayFilterUseKey($args, $closure, $variable) : $this->applyArrayFilterUseBoth($args, $closure, $variable); @@ -114,27 +114,27 @@ CODE_SAMPLE /** * @param Arg[] $args */ - private function applyArrayFilterUseBoth(array $args, \PhpParser\Node\Expr\Closure $closure, \PhpParser\Node\Expr\Variable $variable) : \PhpParser\Node\Stmt\Foreach_ + private function applyArrayFilterUseBoth(array $args, Closure $closure, Variable $variable) : Foreach_ { $arrayValue = $args[0]->value; $value = $closure->params[0]->var; $key = $closure->params[1]->var; - $foreach = new \PhpParser\Node\Stmt\Foreach_($arrayValue, $value, ['keyVar' => $key]); + $foreach = new Foreach_($arrayValue, $value, ['keyVar' => $key]); $stmts = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($closure->stmts, function (\PhpParser\Node $subNode) use($variable, $key, $value, &$stmts) { - if (!$subNode instanceof \PhpParser\Node\Stmt) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($closure->stmts, function (Node $subNode) use($variable, $key, $value, &$stmts) { + if (!$subNode instanceof Stmt) { return null; } - if (!$subNode instanceof \PhpParser\Node\Stmt\Return_) { + if (!$subNode instanceof Return_) { $stmts[] = $subNode; return null; } - if (!$subNode->expr instanceof \PhpParser\Node\Expr) { + if (!$subNode->expr instanceof Expr) { $stmts[] = $subNode; return null; } - $assign = new \PhpParser\Node\Expr\Assign(new \PhpParser\Node\Expr\ArrayDimFetch($variable, $key), $value); - $stmts[] = new \PhpParser\Node\Stmt\If_($subNode->expr, ['stmts' => [new \PhpParser\Node\Stmt\Expression($assign)]]); + $assign = new Assign(new ArrayDimFetch($variable, $key), $value); + $stmts[] = new If_($subNode->expr, ['stmts' => [new Expression($assign)]]); return null; }); $foreach->stmts = $stmts; @@ -143,27 +143,27 @@ CODE_SAMPLE /** * @param Arg[] $args */ - private function applyArrayFilterUseKey(array $args, \PhpParser\Node\Expr\Closure $closure, \PhpParser\Node\Expr\Variable $variable) : \PhpParser\Node\Stmt\Foreach_ + private function applyArrayFilterUseKey(array $args, Closure $closure, Variable $variable) : Foreach_ { $arrayValue = $args[0]->value; $funcCall = $this->nodeFactory->createFuncCall('array_keys', [$arrayValue]); $key = $closure->params[0]->var; - $foreach = new \PhpParser\Node\Stmt\Foreach_($funcCall, $key); + $foreach = new Foreach_($funcCall, $key); $stmts = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($closure->stmts, function (\PhpParser\Node $subNode) use($variable, $key, $arrayValue, &$stmts) { - if (!$subNode instanceof \PhpParser\Node\Stmt) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($closure->stmts, function (Node $subNode) use($variable, $key, $arrayValue, &$stmts) { + if (!$subNode instanceof Stmt) { return null; } - if (!$subNode instanceof \PhpParser\Node\Stmt\Return_) { + if (!$subNode instanceof Return_) { $stmts[] = $subNode; return null; } - if (!$subNode->expr instanceof \PhpParser\Node\Expr) { + if (!$subNode->expr instanceof Expr) { $stmts[] = $subNode; return null; } - $assign = new \PhpParser\Node\Expr\Assign(new \PhpParser\Node\Expr\ArrayDimFetch($variable, $key), new \PhpParser\Node\Expr\ArrayDimFetch($arrayValue, $key)); - $stmts[] = new \PhpParser\Node\Stmt\If_($subNode->expr, ['stmts' => [new \PhpParser\Node\Stmt\Expression($assign)]]); + $assign = new Assign(new ArrayDimFetch($variable, $key), new ArrayDimFetch($arrayValue, $key)); + $stmts[] = new If_($subNode->expr, ['stmts' => [new Expression($assign)]]); return null; }); $foreach->stmts = $stmts; @@ -172,7 +172,7 @@ CODE_SAMPLE /** * @param Arg[] $args */ - private function shouldSkip(\PhpParser\Node\Expr\FuncCall $funcCall, array $args) : bool + private function shouldSkip(FuncCall $funcCall, array $args) : bool { if (!$this->nodeNameResolver->isName($funcCall, 'array_filter')) { return \true; @@ -180,7 +180,7 @@ CODE_SAMPLE if (!isset($args[2])) { return \true; } - if (!$args[2]->value instanceof \PhpParser\Node\Expr\ConstFetch) { + if (!$args[2]->value instanceof ConstFetch) { return \true; } return !$this->nodeNameResolver->isNames($args[2]->value, ['ARRAY_FILTER_USE_KEY', 'ARRAY_FILTER_USE_BOTH']); diff --git a/rules/DowngradePhp56/Rector/Pow/DowngradeExponentialAssignmentOperatorRector.php b/rules/DowngradePhp56/Rector/Pow/DowngradeExponentialAssignmentOperatorRector.php index 24f2ee92371..283a9517e9f 100644 --- a/rules/DowngradePhp56/Rector/Pow/DowngradeExponentialAssignmentOperatorRector.php +++ b/rules/DowngradePhp56/Rector/Pow/DowngradeExponentialAssignmentOperatorRector.php @@ -7,32 +7,32 @@ use PhpParser\Node; use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\AssignOp\Pow; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/pow-operator * * @see \Rector\Tests\DowngradePhp56\Rector\Pow\DowngradeExponentialAssignmentOperatorRector\DowngradeExponentialAssignmentOperatorRectorTest */ -final class DowngradeExponentialAssignmentOperatorRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeExponentialAssignmentOperatorRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove exponential assignment operator **=', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$a **= 3;', '$a = pow($a, 3);')]); + return new RuleDefinition('Remove exponential assignment operator **=', [new CodeSample('$a **= 3;', '$a = pow($a, 3);')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\AssignOp\Pow::class]; + return [Pow::class]; } /** * @param Pow $node */ - public function refactor(\PhpParser\Node $node) : \PhpParser\Node\Expr\Assign + public function refactor(Node $node) : Assign { $powFuncCall = $this->nodeFactory->createFuncCall('pow', [$node->var, $node->expr]); - return new \PhpParser\Node\Expr\Assign($node->var, $powFuncCall); + return new Assign($node->var, $powFuncCall); } } diff --git a/rules/DowngradePhp56/Rector/Pow/DowngradeExponentialOperatorRector.php b/rules/DowngradePhp56/Rector/Pow/DowngradeExponentialOperatorRector.php index fbef2e0b945..9f93af0ec20 100644 --- a/rules/DowngradePhp56/Rector/Pow/DowngradeExponentialOperatorRector.php +++ b/rules/DowngradePhp56/Rector/Pow/DowngradeExponentialOperatorRector.php @@ -7,30 +7,30 @@ use PhpParser\Node; use PhpParser\Node\Expr\BinaryOp\Pow; use PhpParser\Node\Expr\FuncCall; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/pow-operator * * @see \Rector\Tests\DowngradePhp56\Rector\Pow\DowngradeExponentialOperatorRector\DowngradeExponentialOperatorRectorTest */ -final class DowngradeExponentialOperatorRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeExponentialOperatorRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes ** (exp) operator to pow(val, val2)', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('1**2;', 'pow(1, 2);')]); + return new RuleDefinition('Changes ** (exp) operator to pow(val, val2)', [new CodeSample('1**2;', 'pow(1, 2);')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\Pow::class]; + return [Pow::class]; } /** * @param Pow $node */ - public function refactor(\PhpParser\Node $node) : \PhpParser\Node\Expr\FuncCall + public function refactor(Node $node) : FuncCall { return $this->nodeFactory->createFuncCall('pow', [$node->left, $node->right]); } diff --git a/rules/DowngradePhp56/Rector/Use_/DowngradeUseFunctionRector.php b/rules/DowngradePhp56/Rector/Use_/DowngradeUseFunctionRector.php index bcb4bd307f1..a1008b76293 100644 --- a/rules/DowngradePhp56/Rector/Use_/DowngradeUseFunctionRector.php +++ b/rules/DowngradePhp56/Rector/Use_/DowngradeUseFunctionRector.php @@ -12,27 +12,27 @@ use PhpParser\Node\Stmt\GroupUse; use PhpParser\Node\Stmt\Use_; use Rector\Core\Rector\AbstractRector; use Rector\Naming\Naming\UseImportsResolver; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/use_function * * @see \Rector\Tests\DowngradePhp56\Rector\Use_\DowngradeUseFunctionRector\DowngradeUseFunctionRectorTest */ -final class DowngradeUseFunctionRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeUseFunctionRector extends AbstractRector { /** * @readonly * @var \Rector\Naming\Naming\UseImportsResolver */ private $useImportsResolver; - public function __construct(\Rector\Naming\Naming\UseImportsResolver $useImportsResolver) + public function __construct(UseImportsResolver $useImportsResolver) { $this->useImportsResolver = $useImportsResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace imports of functions and constants', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace imports of functions and constants', [new CodeSample(<<<'CODE_SAMPLE' use function Foo\Bar\baz; $var = baz(); @@ -47,14 +47,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Use_::class, \PhpParser\Node\Expr\ConstFetch::class, \PhpParser\Node\Expr\FuncCall::class]; + return [Use_::class, ConstFetch::class, FuncCall::class]; } /** * @param Use_|ConstFetch|FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Stmt\Use_) { + if ($node instanceof Use_) { $this->refactorUse($node); return null; } @@ -66,12 +66,12 @@ CODE_SAMPLE if ($name === null) { return null; } - $node->name = new \PhpParser\Node\Name\FullyQualified($name); + $node->name = new FullyQualified($name); return $node; } - private function refactorUse(\PhpParser\Node\Stmt\Use_ $use) : void + private function refactorUse(Use_ $use) : void { - if ($use->type === \PhpParser\Node\Stmt\Use_::TYPE_FUNCTION || $use->type === \PhpParser\Node\Stmt\Use_::TYPE_CONSTANT) { + if ($use->type === Use_::TYPE_FUNCTION || $use->type === Use_::TYPE_CONSTANT) { $this->removeNode($use); } } @@ -94,11 +94,11 @@ CODE_SAMPLE */ private function getFullyQualifiedName(array $useNodes, $node) : ?string { - if (!$node->name instanceof \PhpParser\Node\Name) { + if (!$node->name instanceof Name) { return null; } $name = $node->name->toLowerString(); - $typeFilter = $node instanceof \PhpParser\Node\Expr\ConstFetch ? \PhpParser\Node\Stmt\Use_::TYPE_CONSTANT : \PhpParser\Node\Stmt\Use_::TYPE_FUNCTION; + $typeFilter = $node instanceof ConstFetch ? Use_::TYPE_CONSTANT : Use_::TYPE_FUNCTION; foreach ($useNodes as $useNode) { $prefix = $this->resolvePrefix($useNode); if ($useNode->type !== $typeFilter) { @@ -121,6 +121,6 @@ CODE_SAMPLE */ private function resolvePrefix($useNode) : string { - return $useNode instanceof \PhpParser\Node\Stmt\GroupUse ? $useNode->prefix . '\\' : ''; + return $useNode instanceof GroupUse ? $useNode->prefix . '\\' : ''; } } diff --git a/rules/DowngradePhp70/NodeFactory/ClassFromAnonymousFactory.php b/rules/DowngradePhp70/NodeFactory/ClassFromAnonymousFactory.php index b4c94842477..6e36e349bec 100644 --- a/rules/DowngradePhp70/NodeFactory/ClassFromAnonymousFactory.php +++ b/rules/DowngradePhp70/NodeFactory/ClassFromAnonymousFactory.php @@ -6,8 +6,8 @@ namespace Rector\DowngradePhp70\NodeFactory; use PhpParser\Node\Stmt\Class_; final class ClassFromAnonymousFactory { - public function create(string $className, \PhpParser\Node\Stmt\Class_ $newClass) : \PhpParser\Node\Stmt\Class_ + public function create(string $className, Class_ $newClass) : Class_ { - return new \PhpParser\Node\Stmt\Class_($className, ['flags' => $newClass->flags, 'extends' => $newClass->extends, 'implements' => $newClass->implements, 'stmts' => $newClass->stmts, 'attrGroups' => $newClass->attrGroups]); + return new Class_($className, ['flags' => $newClass->flags, 'extends' => $newClass->extends, 'implements' => $newClass->implements, 'stmts' => $newClass->stmts, 'attrGroups' => $newClass->attrGroups]); } } diff --git a/rules/DowngradePhp70/Rector/ClassMethod/DowngradeParentTypeDeclarationRector.php b/rules/DowngradePhp70/Rector/ClassMethod/DowngradeParentTypeDeclarationRector.php index 8d0a46c9d35..a26b6424b33 100644 --- a/rules/DowngradePhp70/Rector/ClassMethod/DowngradeParentTypeDeclarationRector.php +++ b/rules/DowngradePhp70/Rector/ClassMethod/DowngradeParentTypeDeclarationRector.php @@ -11,12 +11,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; use Rector\StaticTypeMapper\ValueObject\Type\ParentObjectWithoutClassType; use Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp70\Rector\ClassMethod\DowngradeParentTypeDeclarationRector\DowngradeParentTypeDeclarationRectorTest */ -final class DowngradeParentTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeParentTypeDeclarationRector extends AbstractRector { /** * @readonly @@ -28,7 +28,7 @@ final class DowngradeParentTypeDeclarationRector extends \Rector\Core\Rector\Abs * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator, ReflectionResolver $reflectionResolver) { $this->phpDocFromTypeDeclarationDecorator = $phpDocFromTypeDeclarationDecorator; $this->reflectionResolver = $reflectionResolver; @@ -38,11 +38,11 @@ final class DowngradeParentTypeDeclarationRector extends \Rector\Core\Rector\Abs */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove "parent" return type, add a "@return parent" tag instead', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove "parent" return type, add a "@return parent" tag instead', [new CodeSample(<<<'CODE_SAMPLE' class ParentClass { } @@ -76,17 +76,17 @@ CODE_SAMPLE /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $classReflection = $this->reflectionResolver->resolveClassReflection($node); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return null; } $parentClassReflection = $classReflection->getParentClass(); - if ($parentClassReflection instanceof \PHPStan\Reflection\ClassReflection) { - $staticType = new \Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType($parentClassReflection); + if ($parentClassReflection instanceof ClassReflection) { + $staticType = new ParentStaticType($parentClassReflection); } else { - $staticType = new \Rector\StaticTypeMapper\ValueObject\Type\ParentObjectWithoutClassType(); + $staticType = new ParentObjectWithoutClassType(); } if (!$this->phpDocFromTypeDeclarationDecorator->decorateReturnWithSpecificType($node, $staticType)) { return null; diff --git a/rules/DowngradePhp70/Rector/ClassMethod/DowngradeSelfTypeDeclarationRector.php b/rules/DowngradePhp70/Rector/ClassMethod/DowngradeSelfTypeDeclarationRector.php index a1d475ecf75..7d9d94e3e98 100644 --- a/rules/DowngradePhp70/Rector/ClassMethod/DowngradeSelfTypeDeclarationRector.php +++ b/rules/DowngradePhp70/Rector/ClassMethod/DowngradeSelfTypeDeclarationRector.php @@ -10,12 +10,12 @@ use PHPStan\Type\ThisType; use Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator; use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp70\Rector\ClassMethod\DowngradeSelfTypeDeclarationRector\DowngradeSelfTypeDeclarationRectorTest */ -final class DowngradeSelfTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeSelfTypeDeclarationRector extends AbstractRector { /** * @readonly @@ -27,7 +27,7 @@ final class DowngradeSelfTypeDeclarationRector extends \Rector\Core\Rector\Abstr * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator, ReflectionResolver $reflectionResolver) { $this->phpDocFromTypeDeclarationDecorator = $phpDocFromTypeDeclarationDecorator; $this->reflectionResolver = $reflectionResolver; @@ -37,11 +37,11 @@ final class DowngradeSelfTypeDeclarationRector extends \Rector\Core\Rector\Abstr */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove "self" return type, add a "@return $this" tag instead', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove "self" return type, add a "@return $this" tag instead', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function foo(): self @@ -67,13 +67,13 @@ CODE_SAMPLE /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $classReflection = $this->reflectionResolver->resolveClassReflection($node); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return null; } - $thisType = new \PHPStan\Type\ThisType($classReflection); + $thisType = new ThisType($classReflection); if (!$this->phpDocFromTypeDeclarationDecorator->decorateReturnWithSpecificType($node, $thisType)) { return null; } diff --git a/rules/DowngradePhp70/Rector/Coalesce/DowngradeNullCoalesceRector.php b/rules/DowngradePhp70/Rector/Coalesce/DowngradeNullCoalesceRector.php index 9866729967f..6b8c46a084c 100644 --- a/rules/DowngradePhp70/Rector/Coalesce/DowngradeNullCoalesceRector.php +++ b/rules/DowngradePhp70/Rector/Coalesce/DowngradeNullCoalesceRector.php @@ -10,21 +10,21 @@ use PhpParser\Node\Expr\Isset_; use PhpParser\Node\Expr\Ternary; use Rector\Core\NodeAnalyzer\CoalesceAnalyzer; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/isset_ternary * * @see \Rector\Tests\DowngradePhp70\Rector\Coalesce\DowngradeNullCoalesceRector\DowngradeNullCoalesceRectorTest */ -final class DowngradeNullCoalesceRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeNullCoalesceRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeAnalyzer\CoalesceAnalyzer */ private $coalesceAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\CoalesceAnalyzer $coalesceAnalyzer) + public function __construct(CoalesceAnalyzer $coalesceAnalyzer) { $this->coalesceAnalyzer = $coalesceAnalyzer; } @@ -33,11 +33,11 @@ final class DowngradeNullCoalesceRector extends \Rector\Core\Rector\AbstractRect */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\Coalesce::class]; + return [Coalesce::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change null coalesce to isset ternary check', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change null coalesce to isset ternary check', [new CodeSample(<<<'CODE_SAMPLE' $username = $_GET['user'] ?? 'nobody'; CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -48,15 +48,15 @@ CODE_SAMPLE /** * @param Coalesce $node */ - public function refactor(\PhpParser\Node $node) : \PhpParser\Node\Expr\Ternary + public function refactor(Node $node) : Ternary { $if = $node->left; $else = $node->right; if ($this->coalesceAnalyzer->hasIssetableLeft($node)) { - $cond = new \PhpParser\Node\Expr\Isset_([$if]); + $cond = new Isset_([$if]); } else { - $cond = new \PhpParser\Node\Expr\BinaryOp\NotIdentical($if, $this->nodeFactory->createNull()); + $cond = new NotIdentical($if, $this->nodeFactory->createNull()); } - return new \PhpParser\Node\Expr\Ternary($cond, $if, $else); + return new Ternary($cond, $if, $else); } } diff --git a/rules/DowngradePhp70/Rector/Declare_/DowngradeStrictTypeDeclarationRector.php b/rules/DowngradePhp70/Rector/Declare_/DowngradeStrictTypeDeclarationRector.php index c5393053054..a209d8e4dc2 100644 --- a/rules/DowngradePhp70/Rector/Declare_/DowngradeStrictTypeDeclarationRector.php +++ b/rules/DowngradePhp70/Rector/Declare_/DowngradeStrictTypeDeclarationRector.php @@ -6,23 +6,23 @@ namespace Rector\DowngradePhp70\Rector\Declare_; use PhpParser\Node; use PhpParser\Node\Stmt\Declare_; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp70\Rector\Declare_\DowngradeStrictTypeDeclarationRector\DowngradeStrictTypeDeclarationRectorTest */ -final class DowngradeStrictTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeStrictTypeDeclarationRector extends AbstractRector { /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Declare_::class]; + return [Declare_::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove the declare(strict_types=1)', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove the declare(strict_types=1)', [new CodeSample(<<<'CODE_SAMPLE' declare(strict_types=1); echo 'something'; CODE_SAMPLE @@ -34,7 +34,7 @@ CODE_SAMPLE /** * @param Declare_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -42,7 +42,7 @@ CODE_SAMPLE $this->removeNode($node); return $node; } - private function shouldSkip(\PhpParser\Node\Stmt\Declare_ $declare) : bool + private function shouldSkip(Declare_ $declare) : bool { $declares = $declare->declares; foreach ($declares as $declare) { diff --git a/rules/DowngradePhp70/Rector/Expr/DowngradeUnnecessarilyParenthesizedExpressionRector.php b/rules/DowngradePhp70/Rector/Expr/DowngradeUnnecessarilyParenthesizedExpressionRector.php index 657b2ce1672..e944b9c06cd 100644 --- a/rules/DowngradePhp70/Rector/Expr/DowngradeUnnecessarilyParenthesizedExpressionRector.php +++ b/rules/DowngradePhp70/Rector/Expr/DowngradeUnnecessarilyParenthesizedExpressionRector.php @@ -14,31 +14,31 @@ use PhpParser\Node\Expr\StaticPropertyFetch; use Rector\Core\Rector\AbstractRector; use Rector\DowngradePhp70\Tokenizer\WrappedInParenthesesAnalyzer; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/uniform_variable_syntax * * @see \Rector\Tests\DowngradePhp70\Rector\Expr\DowngradeUnnecessarilyParenthesizedExpressionRector\DowngradeUnnecessarilyParenthesizedExpressionRectorTest */ -final class DowngradeUnnecessarilyParenthesizedExpressionRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeUnnecessarilyParenthesizedExpressionRector extends AbstractRector { /** * @var array> */ - private const PARENTHESIZABLE_NODES = [\PhpParser\Node\Expr\ArrayDimFetch::class, \PhpParser\Node\Expr\PropertyFetch::class, \PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticPropertyFetch::class, \PhpParser\Node\Expr\StaticCall::class, \PhpParser\Node\Expr\FuncCall::class]; + private const PARENTHESIZABLE_NODES = [ArrayDimFetch::class, PropertyFetch::class, MethodCall::class, StaticPropertyFetch::class, StaticCall::class, FuncCall::class]; /** * @readonly * @var \Rector\DowngradePhp70\Tokenizer\WrappedInParenthesesAnalyzer */ private $wrappedInParenthesesAnalyzer; - public function __construct(\Rector\DowngradePhp70\Tokenizer\WrappedInParenthesesAnalyzer $wrappedInParenthesesAnalyzer) + public function __construct(WrappedInParenthesesAnalyzer $wrappedInParenthesesAnalyzer) { $this->wrappedInParenthesesAnalyzer = $wrappedInParenthesesAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove parentheses around expressions allowed by Uniform variable syntax RFC where they are not necessary to prevent parse errors on PHP 5.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove parentheses around expressions allowed by Uniform variable syntax RFC where they are not necessary to prevent parse errors on PHP 5.', [new CodeSample(<<<'CODE_SAMPLE' ($f)['foo']; ($f)->foo; ($f)->foo(); @@ -63,19 +63,19 @@ CODE_SAMPLE { return [ // TODO: Make PHPStan rules allow Expr namespace for its subclasses. - \PhpParser\Node\Expr::class, + Expr::class, ]; } /** * @param ArrayDimFetch|PropertyFetch|MethodCall|StaticPropertyFetch|StaticCall|FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Expr + public function refactor(Node $node) : ?Expr { if (!\in_array(\get_class($node), self::PARENTHESIZABLE_NODES, \true)) { return null; } $leftSubNode = $this->getLeftSubNode($node); - if (!$leftSubNode instanceof \PhpParser\Node) { + if (!$leftSubNode instanceof Node) { return null; } if (!$this->wrappedInParenthesesAnalyzer->isParenthesized($this->file, $leftSubNode)) { @@ -84,23 +84,23 @@ CODE_SAMPLE // Parenthesization is not part of the AST and Rector only re-generates code for AST nodes that changed. // Let’s remove the original node reference forcing the re-generation of the corresponding code. // The code generator will only put parentheses where strictly necessary, which other rules should handle. - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); return $node; } - private function getLeftSubNode(\PhpParser\Node $node) : ?\PhpParser\Node + private function getLeftSubNode(Node $node) : ?Node { switch (\true) { - case $node instanceof \PhpParser\Node\Expr\ArrayDimFetch: + case $node instanceof ArrayDimFetch: return $node->var; - case $node instanceof \PhpParser\Node\Expr\PropertyFetch: + case $node instanceof PropertyFetch: return $node->var; - case $node instanceof \PhpParser\Node\Expr\MethodCall: + case $node instanceof MethodCall: return $node->var; - case $node instanceof \PhpParser\Node\Expr\StaticPropertyFetch: + case $node instanceof StaticPropertyFetch: return $node->class; - case $node instanceof \PhpParser\Node\Expr\StaticCall: + case $node instanceof StaticCall: return $node->class; - case $node instanceof \PhpParser\Node\Expr\FuncCall: + case $node instanceof FuncCall: return $node->name; default: return null; diff --git a/rules/DowngradePhp70/Rector/Expression/DowngradeDefineArrayConstantRector.php b/rules/DowngradePhp70/Rector/Expression/DowngradeDefineArrayConstantRector.php index 6d3e5538804..85308449b27 100644 --- a/rules/DowngradePhp70/Rector/Expression/DowngradeDefineArrayConstantRector.php +++ b/rules/DowngradePhp70/Rector/Expression/DowngradeDefineArrayConstantRector.php @@ -14,19 +14,19 @@ use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\Function_; use Rector\Core\NodeAnalyzer\ArgsAnalyzer; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp70\Rector\Expression\DowngradeDefineArrayConstantRector\DowngradeDefineArrayConstantRectorTest */ -final class DowngradeDefineArrayConstantRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeDefineArrayConstantRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(ArgsAnalyzer $argsAnalyzer) { $this->argsAnalyzer = $argsAnalyzer; } @@ -35,11 +35,11 @@ final class DowngradeDefineArrayConstantRector extends \Rector\Core\Rector\Abstr */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Expression::class]; + return [Expression::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change array contant definition via define to const', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change array contant definition via define to const', [new CodeSample(<<<'CODE_SAMPLE' define('ANIMALS', [ 'dog', 'cat', @@ -58,9 +58,9 @@ CODE_SAMPLE /** * @param Expression $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->expr instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$node->expr instanceof FuncCall) { return null; } $funcCall = $node->expr; @@ -74,9 +74,9 @@ CODE_SAMPLE $arg0Value = $arg0->value; /** @var Array_ $arg1Value */ $arg1Value = $args[1]->value; - return new \PhpParser\Node\Stmt\Const_([new \PhpParser\Node\Const_($arg0Value, $arg1Value)]); + return new Node\Stmt\Const_([new Const_($arg0Value, $arg1Value)]); } - private function shouldSkip(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function shouldSkip(FuncCall $funcCall) : bool { if (!$this->isName($funcCall, 'define')) { return \true; @@ -86,12 +86,12 @@ CODE_SAMPLE return \true; } /** @var Arg[] $args */ - if (!$args[0]->value instanceof \PhpParser\Node\Scalar\String_) { + if (!$args[0]->value instanceof String_) { return \true; } - if (!$args[1]->value instanceof \PhpParser\Node\Expr\Array_) { + if (!$args[1]->value instanceof Array_) { return \true; } - return (bool) $this->betterNodeFinder->findParentByTypes($funcCall, [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class]); + return (bool) $this->betterNodeFinder->findParentByTypes($funcCall, [ClassMethod::class, Function_::class]); } } diff --git a/rules/DowngradePhp70/Rector/FuncCall/DowngradeDirnameLevelsRector.php b/rules/DowngradePhp70/Rector/FuncCall/DowngradeDirnameLevelsRector.php index f5b0f9b2582..81d5ee5a89c 100644 --- a/rules/DowngradePhp70/Rector/FuncCall/DowngradeDirnameLevelsRector.php +++ b/rules/DowngradePhp70/Rector/FuncCall/DowngradeDirnameLevelsRector.php @@ -21,14 +21,14 @@ use PhpParser\Node\Stmt\Return_; use PhpParser\Node\Stmt\While_; use Rector\Core\PhpParser\Node\NamedVariableFactory; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://bugs.php.net/bug.php?id=70112 * * @see \Rector\Tests\DowngradePhp70\Rector\FuncCall\DowngradeDirnameLevelsRector\DowngradeDirnameLevelsRectorTest */ -final class DowngradeDirnameLevelsRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeDirnameLevelsRector extends AbstractRector { /** * @var string @@ -39,13 +39,13 @@ final class DowngradeDirnameLevelsRector extends \Rector\Core\Rector\AbstractRec * @var \Rector\Core\PhpParser\Node\NamedVariableFactory */ private $namedVariableFactory; - public function __construct(\Rector\Core\PhpParser\Node\NamedVariableFactory $namedVariableFactory) + public function __construct(NamedVariableFactory $namedVariableFactory) { $this->namedVariableFactory = $namedVariableFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace the 2nd argument of dirname()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace the 2nd argument of dirname()', [new CodeSample(<<<'CODE_SAMPLE' return dirname($path, 2); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -58,15 +58,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $levelsArg = $this->getLevelsArg($node); - if (!$levelsArg instanceof \PhpParser\Node\Arg) { + if (!$levelsArg instanceof Arg) { return null; } $levels = $this->getLevelsRealValue($levelsArg); @@ -75,7 +75,7 @@ CODE_SAMPLE } return $this->refactorForVariableLevels($node); } - private function getLevelsArg(\PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Arg + private function getLevelsArg(FuncCall $funcCall) : ?Arg { if (!$this->isName($funcCall, self::DIRNAME)) { return null; @@ -83,28 +83,28 @@ CODE_SAMPLE if (!isset($funcCall->args[1])) { return null; } - if (!$funcCall->args[1] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[1] instanceof Arg) { return null; } return $funcCall->args[1]; } - private function getLevelsRealValue(\PhpParser\Node\Arg $levelsArg) : ?int + private function getLevelsRealValue(Arg $levelsArg) : ?int { - if ($levelsArg->value instanceof \PhpParser\Node\Scalar\LNumber) { + if ($levelsArg->value instanceof LNumber) { return $levelsArg->value->value; } return null; } - private function refactorForFixedLevels(\PhpParser\Node\Expr\FuncCall $funcCall, int $levels) : \PhpParser\Node\Expr\FuncCall + private function refactorForFixedLevels(FuncCall $funcCall, int $levels) : FuncCall { // keep only the 1st argument $funcCall->args = [$funcCall->args[0]]; for ($i = 1; $i < $levels; ++$i) { - $funcCall = $this->createDirnameFuncCall(new \PhpParser\Node\Arg($funcCall)); + $funcCall = $this->createDirnameFuncCall(new Arg($funcCall)); } return $funcCall; } - private function refactorForVariableLevels(\PhpParser\Node\Expr\FuncCall $funcCall) : \PhpParser\Node\Expr\FuncCall + private function refactorForVariableLevels(FuncCall $funcCall) : FuncCall { $funcVariable = $this->namedVariableFactory->createVariable($funcCall, 'dirnameFunc'); $closure = $this->createClosure(); @@ -113,25 +113,25 @@ CODE_SAMPLE $funcCall->name = $funcVariable; return $funcCall; } - private function createExprAssign(\PhpParser\Node\Expr\Variable $variable, \PhpParser\Node\Expr $expr) : \PhpParser\Node\Stmt\Expression + private function createExprAssign(Variable $variable, Expr $expr) : Expression { - return new \PhpParser\Node\Stmt\Expression(new \PhpParser\Node\Expr\Assign($variable, $expr)); + return new Expression(new Assign($variable, $expr)); } - private function createClosure() : \PhpParser\Node\Expr\Closure + private function createClosure() : Closure { - $dirVariable = new \PhpParser\Node\Expr\Variable('dir'); - $pathVariable = new \PhpParser\Node\Expr\Variable('path'); - $levelsVariable = new \PhpParser\Node\Expr\Variable('levels'); - $closure = new \PhpParser\Node\Expr\Closure(); - $closure->params = [new \PhpParser\Node\Param($pathVariable), new \PhpParser\Node\Param($levelsVariable)]; + $dirVariable = new Variable('dir'); + $pathVariable = new Variable('path'); + $levelsVariable = new Variable('levels'); + $closure = new Closure(); + $closure->params = [new Param($pathVariable), new Param($levelsVariable)]; $closure->stmts[] = $this->createExprAssign($dirVariable, $this->nodeFactory->createNull()); - $greaterOrEqual = new \PhpParser\Node\Expr\BinaryOp\GreaterOrEqual(new \PhpParser\Node\Expr\PreDec($levelsVariable), new \PhpParser\Node\Scalar\LNumber(0)); - $closure->stmts[] = new \PhpParser\Node\Stmt\While_($greaterOrEqual, [$this->createExprAssign($dirVariable, $this->createDirnameFuncCall(new \PhpParser\Node\Arg(new \PhpParser\Node\Expr\Ternary($dirVariable, null, $pathVariable))))]); - $closure->stmts[] = new \PhpParser\Node\Stmt\Return_($dirVariable); + $greaterOrEqual = new GreaterOrEqual(new PreDec($levelsVariable), new LNumber(0)); + $closure->stmts[] = new While_($greaterOrEqual, [$this->createExprAssign($dirVariable, $this->createDirnameFuncCall(new Arg(new Ternary($dirVariable, null, $pathVariable))))]); + $closure->stmts[] = new Return_($dirVariable); return $closure; } - private function createDirnameFuncCall(\PhpParser\Node\Arg $pathArg) : \PhpParser\Node\Expr\FuncCall + private function createDirnameFuncCall(Arg $pathArg) : FuncCall { - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name(self::DIRNAME), [$pathArg]); + return new FuncCall(new Name(self::DIRNAME), [$pathArg]); } } diff --git a/rules/DowngradePhp70/Rector/FuncCall/DowngradeSessionStartArrayOptionsRector.php b/rules/DowngradePhp70/Rector/FuncCall/DowngradeSessionStartArrayOptionsRector.php index 0e68951f655..4368d9856d7 100644 --- a/rules/DowngradePhp70/Rector/FuncCall/DowngradeSessionStartArrayOptionsRector.php +++ b/rules/DowngradePhp70/Rector/FuncCall/DowngradeSessionStartArrayOptionsRector.php @@ -12,23 +12,23 @@ use PhpParser\Node\Name; use PhpParser\Node\Scalar\String_; use PhpParser\Node\Stmt\Expression; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp70\Rector\FuncCall\DowngradeSessionStartArrayOptionsRector\DowngradeSessionStartArrayOptionsRectorTest */ -final class DowngradeSessionStartArrayOptionsRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeSessionStartArrayOptionsRector extends AbstractRector { /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Move array option of session_start($options) to before statement\'s ini_set()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Move array option of session_start($options) to before statement\'s ini_set()', [new CodeSample(<<<'CODE_SAMPLE' session_start([ 'cache_limiter' => 'private', ]); @@ -42,7 +42,7 @@ CODE_SAMPLE /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -50,30 +50,30 @@ CODE_SAMPLE if (!isset($node->args[0])) { return null; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } /** @var Array_ $options */ $options = $node->args[0]->value; foreach ($options->items as $option) { - if (!$option instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$option instanceof ArrayItem) { return null; } - if (!$option->key instanceof \PhpParser\Node\Scalar\String_) { + if (!$option->key instanceof String_) { return null; } - if (!$this->valueResolver->isTrueOrFalse($option->value) && !$option->value instanceof \PhpParser\Node\Scalar\String_) { + if (!$this->valueResolver->isTrueOrFalse($option->value) && !$option->value instanceof String_) { return null; } - $sessionKey = new \PhpParser\Node\Scalar\String_('session.' . $option->key->value); - $funcName = new \PhpParser\Node\Name('ini_set'); - $iniSet = new \PhpParser\Node\Expr\FuncCall($funcName, [new \PhpParser\Node\Arg($sessionKey), new \PhpParser\Node\Arg($option->value)]); - $this->nodesToAddCollector->addNodeBeforeNode(new \PhpParser\Node\Stmt\Expression($iniSet), $node, $this->file->getSmartFileInfo()); + $sessionKey = new String_('session.' . $option->key->value); + $funcName = new Name('ini_set'); + $iniSet = new FuncCall($funcName, [new Arg($sessionKey), new Arg($option->value)]); + $this->nodesToAddCollector->addNodeBeforeNode(new Expression($iniSet), $node, $this->file->getSmartFileInfo()); } unset($node->args[0]); return $node; } - private function shouldSkip(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function shouldSkip(FuncCall $funcCall) : bool { if (!$this->isName($funcCall, 'session_start')) { return \true; @@ -81,9 +81,9 @@ CODE_SAMPLE if (!isset($funcCall->args[0])) { return \true; } - if (!$funcCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[0] instanceof Arg) { return \true; } - return !$funcCall->args[0]->value instanceof \PhpParser\Node\Expr\Array_; + return !$funcCall->args[0]->value instanceof Array_; } } diff --git a/rules/DowngradePhp70/Rector/FuncCall/DowngradeUncallableValueCallToCallUserFuncRector.php b/rules/DowngradePhp70/Rector/FuncCall/DowngradeUncallableValueCallToCallUserFuncRector.php index 2975393e01c..22a941b062a 100644 --- a/rules/DowngradePhp70/Rector/FuncCall/DowngradeUncallableValueCallToCallUserFuncRector.php +++ b/rules/DowngradePhp70/Rector/FuncCall/DowngradeUncallableValueCallToCallUserFuncRector.php @@ -12,31 +12,31 @@ use PhpParser\Node\Expr\PropertyFetch; use PhpParser\Node\Expr\StaticPropertyFetch; use PhpParser\Node\Name; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/uniform_variable_syntax * * @see \Rector\Tests\DowngradePhp70\Rector\FuncCall\DowngradeUncallableValueCallToCallUserFuncRector\DowngradeUncallableValueCallToCallUserFuncRectorTest */ -final class DowngradeUncallableValueCallToCallUserFuncRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeUncallableValueCallToCallUserFuncRector extends AbstractRector { /** * @var array> */ private const INDIRECT_CALLABLE_EXPR = [ // Interpreted as MethodCall without parentheses. - \PhpParser\Node\Expr\PropertyFetch::class, + PropertyFetch::class, // Interpreted as StaticCall without parentheses. - \PhpParser\Node\Expr\StaticPropertyFetch::class, - \PhpParser\Node\Expr\Closure::class, + StaticPropertyFetch::class, + Closure::class, // The first function call does not even need to be wrapped in parentheses // but PHP 5 still does not like curried functions like `f($args)($moreArgs)`. - \PhpParser\Node\Expr\FuncCall::class, + FuncCall::class, ]; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade calling a value that is not directly callable in PHP 5 (property, static property, closure, …) to call_user_func.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade calling a value that is not directly callable in PHP 5 (property, static property, closure, …) to call_user_func.', [new CodeSample(<<<'CODE_SAMPLE' final class Foo { /** @var callable */ @@ -73,23 +73,23 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Expr\FuncCall + public function refactor(Node $node) : ?FuncCall { - if ($node->name instanceof \PhpParser\Node\Name) { + if ($node->name instanceof Name) { return null; } if (!$this->isNotDirectlyCallableInPhp5($node->name)) { return null; } - $args = \array_merge([new \PhpParser\Node\Arg($node->name)], $node->args); - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('call_user_func'), $args); + $args = \array_merge([new Arg($node->name)], $node->args); + return new FuncCall(new Name('call_user_func'), $args); } - private function isNotDirectlyCallableInPhp5(\PhpParser\Node\Expr $expr) : bool + private function isNotDirectlyCallableInPhp5(Expr $expr) : bool { return \in_array(\get_class($expr), self::INDIRECT_CALLABLE_EXPR, \true); } diff --git a/rules/DowngradePhp70/Rector/FunctionLike/DowngradeScalarTypeDeclarationRector.php b/rules/DowngradePhp70/Rector/FunctionLike/DowngradeScalarTypeDeclarationRector.php index 683511b6bc5..4d216e4f217 100644 --- a/rules/DowngradePhp70/Rector/FunctionLike/DowngradeScalarTypeDeclarationRector.php +++ b/rules/DowngradePhp70/Rector/FunctionLike/DowngradeScalarTypeDeclarationRector.php @@ -23,21 +23,21 @@ use PHPStan\Type\StringType; use PHPStan\Type\Type; use Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/scalar_type_hints * * @see \Rector\Tests\DowngradePhp70\Rector\FunctionLike\DowngradeScalarTypeDeclarationRector\DowngradeScalarTypeDeclarationRectorTest */ -final class DowngradeScalarTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeScalarTypeDeclarationRector extends AbstractRector { /** * @readonly * @var \Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator */ private $phpDocFromTypeDeclarationDecorator; - public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator) + public function __construct(PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator) { $this->phpDocFromTypeDeclarationDecorator = $phpDocFromTypeDeclarationDecorator; } @@ -46,11 +46,11 @@ final class DowngradeScalarTypeDeclarationRector extends \Rector\Core\Rector\Abs */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Expr\Closure::class]; + return [Function_::class, ClassMethod::class, Closure::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove the type params and return type, add @param and @return tags instead', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove the type params and return type, add @param and @return tags instead', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(string $input): string @@ -75,16 +75,16 @@ CODE_SAMPLE /** * @param Function_|ClassMethod|Closure $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $recastAssigns = []; foreach ($node->params as $param) { if ($param->type === null) { continue; } - $this->phpDocFromTypeDeclarationDecorator->decorateParam($param, $node, [\PHPStan\Type\StringType::class, \PHPStan\Type\IntegerType::class, \PHPStan\Type\BooleanType::class, \PHPStan\Type\FloatType::class]); + $this->phpDocFromTypeDeclarationDecorator->decorateParam($param, $node, [StringType::class, IntegerType::class, BooleanType::class, FloatType::class]); $recastAssign = $this->resolveRecastAssign($param, $node); - if ($recastAssign instanceof \PhpParser\Node\Stmt\Expression) { + if ($recastAssign instanceof Expression) { $recastAssigns[] = $recastAssign; } } @@ -100,7 +100,7 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Stmt\Function_|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Expr\Closure $functionLike */ - private function resolveRecastAssign(\PhpParser\Node\Param $param, $functionLike) : ?\PhpParser\Node\Stmt\Expression + private function resolveRecastAssign(Param $param, $functionLike) : ?Expression { if ($functionLike->stmts === null) { return null; @@ -112,28 +112,28 @@ CODE_SAMPLE // @see https://twitter.com/VotrubaT/status/1390974218108538887 /** @var string $paramName */ $paramName = $this->getName($param->var); - $variable = new \PhpParser\Node\Expr\Variable($paramName); + $variable = new Variable($paramName); $paramType = $this->getType($param); $recastedVariable = $this->recastVariabletIfScalarType($variable, $paramType); - if (!$recastedVariable instanceof \PhpParser\Node\Expr\Cast) { + if (!$recastedVariable instanceof Cast) { return null; } - $assign = new \PhpParser\Node\Expr\Assign($variable, $recastedVariable); - return new \PhpParser\Node\Stmt\Expression($assign); + $assign = new Assign($variable, $recastedVariable); + return new Expression($assign); } - private function recastVariabletIfScalarType(\PhpParser\Node\Expr\Variable $variable, \PHPStan\Type\Type $type) : ?\PhpParser\Node\Expr\Cast + private function recastVariabletIfScalarType(Variable $variable, Type $type) : ?Cast { - if ($type instanceof \PHPStan\Type\StringType) { - return new \PhpParser\Node\Expr\Cast\String_($variable); + if ($type instanceof StringType) { + return new String_($variable); } - if ($type instanceof \PHPStan\Type\IntegerType) { - return new \PhpParser\Node\Expr\Cast\Int_($variable); + if ($type instanceof IntegerType) { + return new Int_($variable); } - if ($type instanceof \PHPStan\Type\FloatType) { - return new \PhpParser\Node\Expr\Cast\Double($variable); + if ($type instanceof FloatType) { + return new Double($variable); } - if ($type instanceof \PHPStan\Type\BooleanType) { - return new \PhpParser\Node\Expr\Cast\Bool_($variable); + if ($type instanceof BooleanType) { + return new Bool_($variable); } return null; } diff --git a/rules/DowngradePhp70/Rector/FunctionLike/DowngradeThrowableTypeDeclarationRector.php b/rules/DowngradePhp70/Rector/FunctionLike/DowngradeThrowableTypeDeclarationRector.php index 9ee6c25cda2..eaa6d23cca6 100644 --- a/rules/DowngradePhp70/Rector/FunctionLike/DowngradeThrowableTypeDeclarationRector.php +++ b/rules/DowngradePhp70/Rector/FunctionLike/DowngradeThrowableTypeDeclarationRector.php @@ -10,19 +10,19 @@ use PhpParser\Node\Stmt\Function_; use PHPStan\Type\ObjectType; use Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp70\Rector\FunctionLike\DowngradeThrowableTypeDeclarationRector\DowngradeThrowableTypeDeclarationRectorTest */ -final class DowngradeThrowableTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeThrowableTypeDeclarationRector extends AbstractRector { /** * @readonly * @var \Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator */ private $phpDocFromTypeDeclarationDecorator; - public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator) + public function __construct(PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator) { $this->phpDocFromTypeDeclarationDecorator = $phpDocFromTypeDeclarationDecorator; } @@ -31,11 +31,11 @@ final class DowngradeThrowableTypeDeclarationRector extends \Rector\Core\Rector\ */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Expr\Closure::class]; + return [Function_::class, ClassMethod::class, Closure::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace `Throwable` type hints by PHPDoc tags', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace `Throwable` type hints by PHPDoc tags', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function foo(\Throwable $e): ?\Throwable @@ -62,9 +62,9 @@ CODE_SAMPLE /** * @param ClassMethod|Function_|Closure $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $objectType = new \PHPStan\Type\ObjectType('Throwable'); + $objectType = new ObjectType('Throwable'); foreach ($node->getParams() as $param) { $this->phpDocFromTypeDeclarationDecorator->decorateParamWithSpecificType($param, $node, $objectType); } diff --git a/rules/DowngradePhp70/Rector/GroupUse/SplitGroupedUseImportsRector.php b/rules/DowngradePhp70/Rector/GroupUse/SplitGroupedUseImportsRector.php index 2d244acdcd6..f1bc86fa95d 100644 --- a/rules/DowngradePhp70/Rector/GroupUse/SplitGroupedUseImportsRector.php +++ b/rules/DowngradePhp70/Rector/GroupUse/SplitGroupedUseImportsRector.php @@ -8,18 +8,18 @@ use PhpParser\Node\Name; use PhpParser\Node\Stmt\GroupUse; use PhpParser\Node\Stmt\Use_; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/group_use_declarations * * @see \Rector\Tests\DowngradePhp70\Rector\GroupUse\SplitGroupedUseImportsRector\SplitGroupedUseImportsRectorTest */ -final class SplitGroupedUseImportsRector extends \Rector\Core\Rector\AbstractRector +final class SplitGroupedUseImportsRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Refactor grouped use imports to standalone lines', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Refactor grouped use imports to standalone lines', [new CodeSample(<<<'CODE_SAMPLE' use SomeNamespace\{ First, Second @@ -36,19 +36,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\GroupUse::class]; + return [GroupUse::class]; } /** * @param GroupUse $node * @return Use_[] */ - public function refactor(\PhpParser\Node $node) : array + public function refactor(Node $node) : array { $prefix = $this->getName($node->prefix); $uses = []; foreach ($node->uses as $useUse) { - $useUse->name = new \PhpParser\Node\Name($prefix . '\\' . $this->getName($useUse->name)); - $uses[] = new \PhpParser\Node\Stmt\Use_([$useUse], $node->type); + $useUse->name = new Name($prefix . '\\' . $this->getName($useUse->name)); + $uses[] = new Use_([$useUse], $node->type); } return $uses; } diff --git a/rules/DowngradePhp70/Rector/Instanceof_/DowngradeInstanceofThrowableRector.php b/rules/DowngradePhp70/Rector/Instanceof_/DowngradeInstanceofThrowableRector.php index 4148ae38093..7ebf976cc68 100644 --- a/rules/DowngradePhp70/Rector/Instanceof_/DowngradeInstanceofThrowableRector.php +++ b/rules/DowngradePhp70/Rector/Instanceof_/DowngradeInstanceofThrowableRector.php @@ -15,14 +15,14 @@ use Rector\Core\Rector\AbstractRector; use Rector\NodeCollector\BinaryOpConditionsCollector; use Rector\NodeCollector\BinaryOpTreeRootLocator; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * Throwable was introduced in PHP 7.0 so to support older versions we need to also check for Exception. * @changelog https://www.php.net/manual/en/class.throwable.php * @see \Rector\Tests\DowngradePhp70\Rector\Instanceof_\DowngradeInstanceofThrowableRector\DowngradeInstanceofThrowableRectorTest */ -final class DowngradeInstanceofThrowableRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeInstanceofThrowableRector extends AbstractRector { /** * @readonly @@ -39,15 +39,15 @@ final class DowngradeInstanceofThrowableRector extends \Rector\Core\Rector\Abstr * @var \Rector\Core\PhpParser\Node\NamedVariableFactory */ private $namedVariableFactory; - public function __construct(\Rector\NodeCollector\BinaryOpConditionsCollector $binaryOpConditionsCollector, \Rector\NodeCollector\BinaryOpTreeRootLocator $binaryOpTreeRootLocator, \Rector\Core\PhpParser\Node\NamedVariableFactory $namedVariableFactory) + public function __construct(BinaryOpConditionsCollector $binaryOpConditionsCollector, BinaryOpTreeRootLocator $binaryOpTreeRootLocator, NamedVariableFactory $namedVariableFactory) { $this->binaryOpConditionsCollector = $binaryOpConditionsCollector; $this->binaryOpTreeRootLocator = $binaryOpTreeRootLocator; $this->namedVariableFactory = $namedVariableFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add `instanceof Exception` check as a fallback to `instanceof Throwable` to support exception hierarchies in PHP 5', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add `instanceof Exception` check as a fallback to `instanceof Throwable` to support exception hierarchies in PHP 5', [new CodeSample(<<<'CODE_SAMPLE' return $e instanceof \Throwable; CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -60,14 +60,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Instanceof_::class]; + return [Instanceof_::class]; } /** * @param Instanceof_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!($node->class instanceof \PhpParser\Node\Name && $this->nodeNameResolver->isName($node->class, 'Throwable'))) { + if (!($node->class instanceof Name && $this->nodeNameResolver->isName($node->class, 'Throwable'))) { return null; } // Ensure the refactoring is idempotent. @@ -77,29 +77,29 @@ CODE_SAMPLE // Store the value into a temporary variable to prevent running possible side-effects twice // when the expression is e.g. function. $variable = $this->namedVariableFactory->createVariable($node, 'throwable'); - $instanceof = new \PhpParser\Node\Expr\Instanceof_(new \PhpParser\Node\Expr\Assign($variable, $node->expr), $node->class); + $instanceof = new Instanceof_(new Assign($variable, $node->expr), $node->class); $exceptionFallbackCheck = $this->createFallbackCheck($variable); - return new \PhpParser\Node\Expr\BinaryOp\BooleanOr($instanceof, $exceptionFallbackCheck); + return new BooleanOr($instanceof, $exceptionFallbackCheck); } /** * Also checks similar manual transformations. */ - private function isAlreadyTransformed(\PhpParser\Node\Expr\Instanceof_ $instanceof) : bool + private function isAlreadyTransformed(Instanceof_ $instanceof) : bool { /** @var Node $parentNode */ - $parentNode = $instanceof->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { + $parentNode = $instanceof->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof BooleanOr) { return \false; } - $hasVariableToFindInDisjunction = ($var = $instanceof->expr) instanceof \PhpParser\Node\Expr\Variable || $instanceof->expr instanceof \PhpParser\Node\Expr\Assign && ($var = $instanceof->expr->var) instanceof \PhpParser\Node\Expr\Variable; + $hasVariableToFindInDisjunction = ($var = $instanceof->expr) instanceof Variable || $instanceof->expr instanceof Assign && ($var = $instanceof->expr->var) instanceof Variable; if (!$hasVariableToFindInDisjunction) { return \false; } - $disjunctionTree = $this->binaryOpTreeRootLocator->findOperationRoot($instanceof, \PhpParser\Node\Expr\BinaryOp\BooleanOr::class); - $disjuncts = $this->binaryOpConditionsCollector->findConditions($disjunctionTree, \PhpParser\Node\Expr\BinaryOp\BooleanOr::class); + $disjunctionTree = $this->binaryOpTreeRootLocator->findOperationRoot($instanceof, BooleanOr::class); + $disjuncts = $this->binaryOpConditionsCollector->findConditions($disjunctionTree, BooleanOr::class); // If we transformed it ourselves, the second check can only be to the right // since it uses the assigned variable. - if ($instanceof->expr instanceof \PhpParser\Node\Expr\Assign) { + if ($instanceof->expr instanceof Assign) { $index = \array_search($instanceof, $disjuncts, \true); if ($index !== \false) { $disjuncts = \array_slice($disjuncts, $index); @@ -108,8 +108,8 @@ CODE_SAMPLE $expectedDisjunct = $this->createFallbackCheck($var); return $this->nodeComparator->isNodeEqual($expectedDisjunct, $disjuncts); } - private function createFallbackCheck(\PhpParser\Node\Expr\Variable $variable) : \PhpParser\Node\Expr\Instanceof_ + private function createFallbackCheck(Variable $variable) : Instanceof_ { - return new \PhpParser\Node\Expr\Instanceof_($variable, new \PhpParser\Node\Name\FullyQualified('Exception')); + return new Instanceof_($variable, new FullyQualified('Exception')); } } diff --git a/rules/DowngradePhp70/Rector/MethodCall/DowngradeClosureCallRector.php b/rules/DowngradePhp70/Rector/MethodCall/DowngradeClosureCallRector.php index 548688c4657..1751772ad1d 100644 --- a/rules/DowngradePhp70/Rector/MethodCall/DowngradeClosureCallRector.php +++ b/rules/DowngradePhp70/Rector/MethodCall/DowngradeClosureCallRector.php @@ -14,27 +14,27 @@ use PhpParser\Node\Param; use PhpParser\Node\Scalar\LNumber; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\TypeAnalyzer\MethodTypeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/closure_apply * * @see \Rector\Tests\DowngradePhp70\Rector\MethodCall\DowngradeClosureCallRector\DowngradeClosureCallRectorTest */ -final class DowngradeClosureCallRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeClosureCallRector extends AbstractRector { /** * @readonly * @var \Rector\NodeTypeResolver\TypeAnalyzer\MethodTypeAnalyzer */ private $methodTypeAnalyzer; - public function __construct(\Rector\NodeTypeResolver\TypeAnalyzer\MethodTypeAnalyzer $methodTypeAnalyzer) + public function __construct(MethodTypeAnalyzer $methodTypeAnalyzer) { $this->methodTypeAnalyzer = $methodTypeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace Closure::call() by Closure::bindTo()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace Closure::call() by Closure::bindTo()', [new CodeSample(<<<'CODE_SAMPLE' $closure->call($newObj, ...$args); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -47,39 +47,39 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Expr\FuncCall + public function refactor(Node $node) : ?FuncCall { if ($this->shouldSkip($node)) { return null; } $methodCall = $this->createBindToCall($node); $item1Unpacked = \array_slice($node->args, 1); - $args = \array_merge([new \PhpParser\Node\Arg($methodCall)], $item1Unpacked); - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('call_user_func'), $args); + $args = \array_merge([new Arg($methodCall)], $item1Unpacked); + return new FuncCall(new Name('call_user_func'), $args); } - private function shouldSkip(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + private function shouldSkip(MethodCall $methodCall) : bool { if ($methodCall->args === []) { return \true; } - return !$this->methodTypeAnalyzer->isCallTo($methodCall, \Closure::class, 'call'); + return !$this->methodTypeAnalyzer->isCallTo($methodCall, Closure::class, 'call'); } - private function createBindToCall(\PhpParser\Node\Expr\MethodCall $methodCall) : \PhpParser\Node\Expr\MethodCall + private function createBindToCall(MethodCall $methodCall) : MethodCall { $newObj = $methodCall->args[0]; - if ($newObj->value instanceof \PhpParser\Node\Expr\Variable) { + if ($newObj->value instanceof Variable) { $args = [$newObj, $newObj]; } else { // we don't want the expression to be executed twice so we use array_fill() as a trick - $args = [new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\LNumber(0)), new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\LNumber(2)), $newObj]; - $funcCall = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('array_fill'), $args); - $args = [new \PhpParser\Node\Arg($funcCall, \false, \true)]; + $args = [new Arg(new LNumber(0)), new Arg(new LNumber(2)), $newObj]; + $funcCall = new FuncCall(new Name('array_fill'), $args); + $args = [new Arg($funcCall, \false, \true)]; } - return new \PhpParser\Node\Expr\MethodCall($methodCall->var, 'bindTo', $args); + return new MethodCall($methodCall->var, 'bindTo', $args); } } diff --git a/rules/DowngradePhp70/Rector/MethodCall/DowngradeMethodCallOnCloneRector.php b/rules/DowngradePhp70/Rector/MethodCall/DowngradeMethodCallOnCloneRector.php index 8e0a7e9f3fe..d69b16c9c0c 100644 --- a/rules/DowngradePhp70/Rector/MethodCall/DowngradeMethodCallOnCloneRector.php +++ b/rules/DowngradePhp70/Rector/MethodCall/DowngradeMethodCallOnCloneRector.php @@ -12,27 +12,27 @@ use PhpParser\Node\Stmt\Expression; use Rector\Core\Rector\AbstractRector; use Rector\Naming\Naming\VariableNaming; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/migration70.new-features.php#migration70.new-features.others * * @see \Rector\Tests\DowngradePhp70\Rector\MethodCall\DowngradeMethodCallOnCloneRector\DowngradeMethodCallOnCloneRectorTest */ -final class DowngradeMethodCallOnCloneRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeMethodCallOnCloneRector extends AbstractRector { /** * @readonly * @var \Rector\Naming\Naming\VariableNaming */ private $variableNaming; - public function __construct(\Rector\Naming\Naming\VariableNaming $variableNaming) + public function __construct(VariableNaming $variableNaming) { $this->variableNaming = $variableNaming; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace (clone $obj)->call() to object assign and call', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace (clone $obj)->call() to object assign and call', [new CodeSample(<<<'CODE_SAMPLE' (clone $this)->execute(); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -46,19 +46,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Expr\MethodCall + public function refactor(Node $node) : ?MethodCall { $isFoundCloneInAssign = \false; - if (!$node->var instanceof \PhpParser\Node\Expr\Clone_) { - if (!$node->var instanceof \PhpParser\Node\Expr\Assign) { + if (!$node->var instanceof Clone_) { + if (!$node->var instanceof Assign) { return null; } - $isFoundCloneInAssign = (bool) $this->betterNodeFinder->findFirstInstanceOf($node->var->expr, \PhpParser\Node\Expr\Clone_::class); + $isFoundCloneInAssign = (bool) $this->betterNodeFinder->findFirstInstanceOf($node->var->expr, Clone_::class); if (!$isFoundCloneInAssign) { return null; } @@ -68,14 +68,14 @@ CODE_SAMPLE $assign = $node->var; $variable = $assign->var; } else { - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $node->getAttribute(AttributeKey::SCOPE); $newVariableName = $this->variableNaming->createCountedValueName('object', $scope); - $variable = new \PhpParser\Node\Expr\Variable($newVariableName); - $assign = new \PhpParser\Node\Expr\Assign($variable, $node->var); + $variable = new Variable($newVariableName); + $assign = new Assign($variable, $node->var); } - $this->nodesToAddCollector->addNodeBeforeNode(new \PhpParser\Node\Stmt\Expression($assign), $node, $this->file->getSmartFileInfo()); + $this->nodesToAddCollector->addNodeBeforeNode(new Expression($assign), $node, $this->file->getSmartFileInfo()); $node->var = $variable; - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); return $node; } } diff --git a/rules/DowngradePhp70/Rector/New_/DowngradeAnonymousClassRector.php b/rules/DowngradePhp70/Rector/New_/DowngradeAnonymousClassRector.php index 85be41c21a6..0196dd069bc 100644 --- a/rules/DowngradePhp70/Rector/New_/DowngradeAnonymousClassRector.php +++ b/rules/DowngradePhp70/Rector/New_/DowngradeAnonymousClassRector.php @@ -11,12 +11,12 @@ use Rector\Core\NodeAnalyzer\ClassAnalyzer; use Rector\Core\NodeDecorator\NamespacedNameDecorator; use Rector\Core\Rector\AbstractRector; use Rector\DowngradePhp70\NodeFactory\ClassFromAnonymousFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp70\Rector\New_\DowngradeAnonymousClassRector\DowngradeAnonymousClassRectorTest */ -final class DowngradeAnonymousClassRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeAnonymousClassRector extends AbstractRector { /** * @var string @@ -41,7 +41,7 @@ final class DowngradeAnonymousClassRector extends \Rector\Core\Rector\AbstractRe * @var \Rector\Core\NodeDecorator\NamespacedNameDecorator */ private $namespacedNameDecorator; - public function __construct(\Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer, \Rector\DowngradePhp70\NodeFactory\ClassFromAnonymousFactory $classFromAnonymousFactory, \Rector\Core\NodeDecorator\NamespacedNameDecorator $namespacedNameDecorator) + public function __construct(ClassAnalyzer $classAnalyzer, ClassFromAnonymousFactory $classFromAnonymousFactory, NamespacedNameDecorator $namespacedNameDecorator) { $this->classAnalyzer = $classAnalyzer; $this->classFromAnonymousFactory = $classFromAnonymousFactory; @@ -52,11 +52,11 @@ final class DowngradeAnonymousClassRector extends \Rector\Core\Rector\AbstractRe */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\New_::class]; + return [New_::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove anonymous class', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove anonymous class', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -109,19 +109,19 @@ CODE_SAMPLE /** * @param New_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->classAnalyzer->isAnonymousClass($node->class)) { return null; } - if (!$node->class instanceof \PhpParser\Node\Stmt\Class_) { + if (!$node->class instanceof Class_) { return null; } $className = $this->createAnonymousClassName(); $class = $this->classFromAnonymousFactory->create($className, $node->class); $this->classes[] = $class; $this->namespacedNameDecorator->decorate($class); - return new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name($className), $node->args); + return new New_(new Name($className), $node->args); } private function createAnonymousClassName() : string { diff --git a/rules/DowngradePhp70/Rector/Spaceship/DowngradeSpaceshipRector.php b/rules/DowngradePhp70/Rector/Spaceship/DowngradeSpaceshipRector.php index e65e97837e2..86e68e7e101 100644 --- a/rules/DowngradePhp70/Rector/Spaceship/DowngradeSpaceshipRector.php +++ b/rules/DowngradePhp70/Rector/Spaceship/DowngradeSpaceshipRector.php @@ -20,12 +20,12 @@ use PhpParser\Node\Stmt\Return_; use Rector\Core\NodeManipulator\IfManipulator; use Rector\Core\PhpParser\Node\NamedVariableFactory; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp70\Rector\Spaceship\DowngradeSpaceshipRector\DowngradeSpaceshipRectorTest */ -final class DowngradeSpaceshipRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeSpaceshipRector extends AbstractRector { /** * @readonly @@ -37,7 +37,7 @@ final class DowngradeSpaceshipRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Core\PhpParser\Node\NamedVariableFactory */ private $namedVariableFactory; - public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator, \Rector\Core\PhpParser\Node\NamedVariableFactory $namedVariableFactory) + public function __construct(IfManipulator $ifManipulator, NamedVariableFactory $namedVariableFactory) { $this->ifManipulator = $ifManipulator; $this->namedVariableFactory = $namedVariableFactory; @@ -47,11 +47,11 @@ final class DowngradeSpaceshipRector extends \Rector\Core\Rector\AbstractRector */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\Spaceship::class]; + return [Spaceship::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change spaceship with check equal, and ternary to result 0, -1, 1', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change spaceship with check equal, and ternary to result 0, -1, 1', [new CodeSample(<<<'CODE_SAMPLE' return $a <=> $b; CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -68,28 +68,28 @@ CODE_SAMPLE /** * @param Spaceship $node */ - public function refactor(\PhpParser\Node $node) : \PhpParser\Node\Expr\FuncCall + public function refactor(Node $node) : FuncCall { - $leftVariableParam = new \PhpParser\Node\Expr\Variable('left'); - $rightVariableParam = new \PhpParser\Node\Expr\Variable('right'); - $anonymousFunction = new \PhpParser\Node\Expr\Closure(); - $leftParam = new \PhpParser\Node\Param($leftVariableParam); - $rightParam = new \PhpParser\Node\Param($rightVariableParam); + $leftVariableParam = new Variable('left'); + $rightVariableParam = new Variable('right'); + $anonymousFunction = new Closure(); + $leftParam = new Param($leftVariableParam); + $rightParam = new Param($rightVariableParam); $anonymousFunction->params = [$leftParam, $rightParam]; - $if = $this->ifManipulator->createIfStmt(new \PhpParser\Node\Expr\BinaryOp\Identical($leftVariableParam, $rightVariableParam), new \PhpParser\Node\Stmt\Return_(new \PhpParser\Node\Scalar\LNumber(0))); + $if = $this->ifManipulator->createIfStmt(new Identical($leftVariableParam, $rightVariableParam), new Return_(new LNumber(0))); $anonymousFunction->stmts[0] = $if; - $smaller = new \PhpParser\Node\Expr\BinaryOp\Smaller($leftVariableParam, $rightVariableParam); - $ternaryIf = new \PhpParser\Node\Scalar\LNumber(-1); - $ternaryElse = new \PhpParser\Node\Scalar\LNumber(1); - $ternary = new \PhpParser\Node\Expr\Ternary($smaller, $ternaryIf, $ternaryElse); - $anonymousFunction->stmts[1] = new \PhpParser\Node\Stmt\Return_($ternary); + $smaller = new Smaller($leftVariableParam, $rightVariableParam); + $ternaryIf = new LNumber(-1); + $ternaryElse = new LNumber(1); + $ternary = new Ternary($smaller, $ternaryIf, $ternaryElse); + $anonymousFunction->stmts[1] = new Return_($ternary); $assignVariable = $this->namedVariableFactory->createVariable($node, 'battleShipcompare'); $assignExpression = $this->getAssignExpression($anonymousFunction, $assignVariable); $this->nodesToAddCollector->addNodeBeforeNode($assignExpression, $node, $this->file->getSmartFileInfo()); - return new \PhpParser\Node\Expr\FuncCall($assignVariable, [new \PhpParser\Node\Arg($node->left), new \PhpParser\Node\Arg($node->right)]); + return new FuncCall($assignVariable, [new Arg($node->left), new Arg($node->right)]); } - private function getAssignExpression(\PhpParser\Node\Expr\Closure $closure, \PhpParser\Node\Expr\Variable $variable) : \PhpParser\Node\Stmt\Expression + private function getAssignExpression(Closure $closure, Variable $variable) : Expression { - return new \PhpParser\Node\Stmt\Expression(new \PhpParser\Node\Expr\Assign($variable, $closure)); + return new Expression(new Assign($variable, $closure)); } } diff --git a/rules/DowngradePhp70/Rector/TryCatch/DowngradeCatchThrowableRector.php b/rules/DowngradePhp70/Rector/TryCatch/DowngradeCatchThrowableRector.php index 150ccf0af45..88362cdf1d8 100644 --- a/rules/DowngradePhp70/Rector/TryCatch/DowngradeCatchThrowableRector.php +++ b/rules/DowngradePhp70/Rector/TryCatch/DowngradeCatchThrowableRector.php @@ -10,22 +10,22 @@ use PhpParser\Node\Stmt; use PhpParser\Node\Stmt\Catch_; use PhpParser\Node\Stmt\TryCatch; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * Throwable was introduced in PHP 7.0 so to support older versions we need to also check for Exception. * @changelog https://www.php.net/manual/en/class.throwable.php * @see \Rector\Tests\DowngradePhp70\Rector\TryCatch\DowngradeCatchThrowableRector\DowngradeCatchThrowableRectorTest */ -final class DowngradeCatchThrowableRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeCatchThrowableRector extends AbstractRector { /** * @var string */ private const EXCEPTION = 'Exception'; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Make catch clauses catching `Throwable` also catch `Exception` to support exception hierarchies in PHP 5.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Make catch clauses catching `Throwable` also catch `Exception` to support exception hierarchies in PHP 5.', [new CodeSample(<<<'CODE_SAMPLE' try { // Some code... } catch (\Throwable $exception) { @@ -48,12 +48,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\TryCatch::class]; + return [TryCatch::class]; } /** * @param TryCatch $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $originalCatches = $node->catches; $hasChanged = \false; @@ -61,8 +61,8 @@ CODE_SAMPLE if (!$this->shouldAddExceptionFallback($catch, $node)) { continue; } - $catchType = new \PhpParser\Node\Name\FullyQualified(self::EXCEPTION); - $exceptionCatch = new \PhpParser\Node\Stmt\Catch_([$catchType], $catch->var, $catch->stmts); + $catchType = new FullyQualified(self::EXCEPTION); + $exceptionCatch = new Catch_([$catchType], $catch->var, $catch->stmts); $originalCatches[] = $exceptionCatch; $hasChanged = \true; } @@ -98,7 +98,7 @@ CODE_SAMPLE } return \false; } - private function shouldAddExceptionFallback(\PhpParser\Node\Stmt\Catch_ $catch, \PhpParser\Node\Stmt\TryCatch $tryCatch) : bool + private function shouldAddExceptionFallback(Catch_ $catch, TryCatch $tryCatch) : bool { if (!$this->isCatchingType($catch->types, 'Throwable')) { return \false; diff --git a/rules/DowngradePhp70/Tokenizer/WrappedInParenthesesAnalyzer.php b/rules/DowngradePhp70/Tokenizer/WrappedInParenthesesAnalyzer.php index 91d9f7b639c..0589bdbc883 100644 --- a/rules/DowngradePhp70/Tokenizer/WrappedInParenthesesAnalyzer.php +++ b/rules/DowngradePhp70/Tokenizer/WrappedInParenthesesAnalyzer.php @@ -7,7 +7,7 @@ use PhpParser\Node; use Rector\Core\ValueObject\Application\File; final class WrappedInParenthesesAnalyzer { - public function isParenthesized(\Rector\Core\ValueObject\Application\File $file, \PhpParser\Node $node) : bool + public function isParenthesized(File $file, Node $node) : bool { $oldTokens = $file->getOldTokens(); $startTokenPos = $node->getStartTokenPos(); diff --git a/rules/DowngradePhp71/Rector/Array_/SymmetricArrayDestructuringToListRector.php b/rules/DowngradePhp71/Rector/Array_/SymmetricArrayDestructuringToListRector.php index 9e3b8f724fd..9701246c338 100644 --- a/rules/DowngradePhp71/Rector/Array_/SymmetricArrayDestructuringToListRector.php +++ b/rules/DowngradePhp71/Rector/Array_/SymmetricArrayDestructuringToListRector.php @@ -12,16 +12,16 @@ use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Name; use PhpParser\Node\Stmt\Foreach_; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp71\Rector\Array_\SymmetricArrayDestructuringToListRector\SymmetricArrayDestructuringToListRectorTest */ -final class SymmetricArrayDestructuringToListRector extends \Rector\Core\Rector\AbstractRector +final class SymmetricArrayDestructuringToListRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade Symmetric array destructuring to list() function', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade Symmetric array destructuring to list() function', [new CodeSample(<<<'CODE_SAMPLE' [$id1, $name1] = $data; CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -34,32 +34,32 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Array_::class, \PhpParser\Node\Expr\Assign::class, \PhpParser\Node\Stmt\Foreach_::class]; + return [Array_::class, Assign::class, Foreach_::class]; } /** * @param Array_|Assign|Foreach_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\Assign) { - if ($node->var instanceof \PhpParser\Node\Expr\Array_) { + if ($node instanceof Assign) { + if ($node->var instanceof Array_) { $node->var = $this->processToList($node->var); return $node; } return null; } - if ($node instanceof \PhpParser\Node\Stmt\Foreach_ && $node->valueVar instanceof \PhpParser\Node\Expr\Array_) { + if ($node instanceof Foreach_ && $node->valueVar instanceof Array_) { $node->valueVar = $this->processToList($node->valueVar); return $node; } return null; } - private function processToList(\PhpParser\Node\Expr\Array_ $array) : \PhpParser\Node\Expr\FuncCall + private function processToList(Array_ $array) : FuncCall { $args = []; foreach ($array->items as $arrayItem) { - $args[] = $arrayItem instanceof \PhpParser\Node\Expr\ArrayItem ? new \PhpParser\Node\Arg($arrayItem->value) : null; + $args[] = $arrayItem instanceof ArrayItem ? new Arg($arrayItem->value) : null; } - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('list'), $args); + return new FuncCall(new Name('list'), $args); } } diff --git a/rules/DowngradePhp71/Rector/ClassConst/DowngradeClassConstantVisibilityRector.php b/rules/DowngradePhp71/Rector/ClassConst/DowngradeClassConstantVisibilityRector.php index 05afc7f2025..e20ca261a1d 100644 --- a/rules/DowngradePhp71/Rector/ClassConst/DowngradeClassConstantVisibilityRector.php +++ b/rules/DowngradePhp71/Rector/ClassConst/DowngradeClassConstantVisibilityRector.php @@ -7,27 +7,27 @@ use PhpParser\Node; use PhpParser\Node\Stmt\ClassConst; use Rector\Core\Rector\AbstractRector; use Rector\Privatization\NodeManipulator\VisibilityManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/class_const_visibility * * @see \Rector\Tests\DowngradePhp71\Rector\ClassConst\DowngradeClassConstantVisibilityRectorTest */ -final class DowngradeClassConstantVisibilityRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeClassConstantVisibilityRector extends AbstractRector { /** * @readonly * @var \Rector\Privatization\NodeManipulator\VisibilityManipulator */ private $visibilityManipulator; - public function __construct(\Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator) + public function __construct(VisibilityManipulator $visibilityManipulator) { $this->visibilityManipulator = $visibilityManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade class constant visibility', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade class constant visibility', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public const PUBLIC_CONST_B = 2; @@ -50,12 +50,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassConst::class]; + return [ClassConst::class]; } /** * @param ClassConst $node */ - public function refactor(\PhpParser\Node $node) : \PhpParser\Node\Stmt\ClassConst + public function refactor(Node $node) : ClassConst { $this->visibilityManipulator->removeVisibility($node); return $node; diff --git a/rules/DowngradePhp71/Rector/ConstFetch/DowngradePhp71JsonConstRector.php b/rules/DowngradePhp71/Rector/ConstFetch/DowngradePhp71JsonConstRector.php index c782280cc33..4378af56c60 100644 --- a/rules/DowngradePhp71/Rector/ConstFetch/DowngradePhp71JsonConstRector.php +++ b/rules/DowngradePhp71/Rector/ConstFetch/DowngradePhp71JsonConstRector.php @@ -8,14 +8,14 @@ use PhpParser\Node\Expr\BinaryOp\BitwiseOr; use PhpParser\Node\Expr\ConstFetch; use Rector\Core\Rector\AbstractRector; use Rector\DowngradePhp72\NodeManipulator\JsonConstCleaner; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/function.json-encode.php#refsect1-function.json-encode-changelog * * @see \Rector\Tests\DowngradePhp71\Rector\ConstFetch\DowngradePhp71JsonConstRector\DowngradePhp71JsonConstRectorTest */ -final class DowngradePhp71JsonConstRector extends \Rector\Core\Rector\AbstractRector +final class DowngradePhp71JsonConstRector extends AbstractRector { /** * @var string[] @@ -26,13 +26,13 @@ final class DowngradePhp71JsonConstRector extends \Rector\Core\Rector\AbstractRe * @var \Rector\DowngradePhp72\NodeManipulator\JsonConstCleaner */ private $jsonConstCleaner; - public function __construct(\Rector\DowngradePhp72\NodeManipulator\JsonConstCleaner $jsonConstCleaner) + public function __construct(JsonConstCleaner $jsonConstCleaner) { $this->jsonConstCleaner = $jsonConstCleaner; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove Json constant that available only in php 7.1', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove Json constant that available only in php 7.1', [new CodeSample(<<<'CODE_SAMPLE' json_encode($content, JSON_UNESCAPED_LINE_TERMINATORS); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -45,12 +45,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\ConstFetch::class, \PhpParser\Node\Expr\BinaryOp\BitwiseOr::class]; + return [ConstFetch::class, BitwiseOr::class]; } /** * @param ConstFetch|BitwiseOr $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { return $this->jsonConstCleaner->clean($node, self::CONSTANTS); } diff --git a/rules/DowngradePhp71/Rector/FuncCall/DowngradeIsIterableRector.php b/rules/DowngradePhp71/Rector/FuncCall/DowngradeIsIterableRector.php index 3e470f8fa49..6036a7c5ebc 100644 --- a/rules/DowngradePhp71/Rector/FuncCall/DowngradeIsIterableRector.php +++ b/rules/DowngradePhp71/Rector/FuncCall/DowngradeIsIterableRector.php @@ -10,25 +10,25 @@ use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\Instanceof_; use PhpParser\Node\Name\FullyQualified; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/iterable * * @see \Rector\Tests\DowngradePhp71\Rector\FuncCall\DowngradeIsIterableRector\DowngradeIsIterableRectorTest */ -final class DowngradeIsIterableRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeIsIterableRector extends AbstractRector { /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change is_iterable with array and Traversable object type check', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change is_iterable with array and Traversable object type check', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($obj) @@ -51,7 +51,7 @@ CODE_SAMPLE /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'is_iterable')) { return null; @@ -59,13 +59,13 @@ CODE_SAMPLE if (!isset($node->args[0])) { return null; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } /** @var mixed $arg */ $arg = $node->args[0]->value; $funcCall = $this->nodeFactory->createFuncCall('is_array', [$arg]); - $instanceOf = new \PhpParser\Node\Expr\Instanceof_($arg, new \PhpParser\Node\Name\FullyQualified('Traversable')); - return new \PhpParser\Node\Expr\BinaryOp\BooleanOr($funcCall, $instanceOf); + $instanceOf = new Instanceof_($arg, new FullyQualified('Traversable')); + return new BooleanOr($funcCall, $instanceOf); } } diff --git a/rules/DowngradePhp71/Rector/FunctionLike/DowngradeIterablePseudoTypeDeclarationRector.php b/rules/DowngradePhp71/Rector/FunctionLike/DowngradeIterablePseudoTypeDeclarationRector.php index 7950329eaf5..da1b0ec002a 100644 --- a/rules/DowngradePhp71/Rector/FunctionLike/DowngradeIterablePseudoTypeDeclarationRector.php +++ b/rules/DowngradePhp71/Rector/FunctionLike/DowngradeIterablePseudoTypeDeclarationRector.php @@ -11,21 +11,21 @@ use PHPStan\Type\IterableType; use PHPStan\Type\MixedType; use Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/iterable * * @see \Rector\Tests\DowngradePhp71\Rector\FunctionLike\DowngradeIterablePseudoTypeDeclarationRector\DowngradeIterablePseudoTypeDeclarationRectorTest */ -final class DowngradeIterablePseudoTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeIterablePseudoTypeDeclarationRector extends AbstractRector { /** * @readonly * @var \Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator */ private $phpDocFromTypeDeclarationDecorator; - public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator) + public function __construct(PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator) { $this->phpDocFromTypeDeclarationDecorator = $phpDocFromTypeDeclarationDecorator; } @@ -34,11 +34,11 @@ final class DowngradeIterablePseudoTypeDeclarationRector extends \Rector\Core\Re */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Expr\Closure::class]; + return [Function_::class, ClassMethod::class, Closure::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove the iterable pseudo type params and returns, add @param and @return tags instead', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove the iterable pseudo type params and returns, add @param and @return tags instead', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(iterable $iterator): iterable @@ -65,9 +65,9 @@ CODE_SAMPLE /** * @param Function_|ClassMethod|Closure $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $iterableType = new \PHPStan\Type\IterableType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); + $iterableType = new IterableType(new MixedType(), new MixedType()); foreach ($node->params as $param) { $this->phpDocFromTypeDeclarationDecorator->decorateParamWithSpecificType($param, $node, $iterableType); } diff --git a/rules/DowngradePhp71/Rector/FunctionLike/DowngradeNullableTypeDeclarationRector.php b/rules/DowngradePhp71/Rector/FunctionLike/DowngradeNullableTypeDeclarationRector.php index 39364a6f462..f6e21280675 100644 --- a/rules/DowngradePhp71/Rector/FunctionLike/DowngradeNullableTypeDeclarationRector.php +++ b/rules/DowngradePhp71/Rector/FunctionLike/DowngradeNullableTypeDeclarationRector.php @@ -14,12 +14,12 @@ use Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator; use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\NodeAnalyzer\ParamAnalyzer; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp71\Rector\FunctionLike\DowngradeNullableTypeDeclarationRector\DowngradeNullableTypeDeclarationRectorTest */ -final class DowngradeNullableTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeNullableTypeDeclarationRector extends AbstractRector { /** * @readonly @@ -36,7 +36,7 @@ final class DowngradeNullableTypeDeclarationRector extends \Rector\Core\Rector\A * @var \Rector\Core\NodeAnalyzer\ParamAnalyzer */ private $paramAnalyzer; - public function __construct(\Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator, \Rector\Core\NodeAnalyzer\ParamAnalyzer $paramAnalyzer) + public function __construct(PhpDocTypeChanger $phpDocTypeChanger, PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator, ParamAnalyzer $paramAnalyzer) { $this->phpDocTypeChanger = $phpDocTypeChanger; $this->phpDocFromTypeDeclarationDecorator = $phpDocFromTypeDeclarationDecorator; @@ -47,11 +47,11 @@ final class DowngradeNullableTypeDeclarationRector extends \Rector\Core\Rector\A */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Expr\Closure::class]; + return [Function_::class, ClassMethod::class, Closure::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove the nullable type params, add @param tags instead', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove the nullable type params, add @param tags instead', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(?string $input): ?string @@ -76,7 +76,7 @@ CODE_SAMPLE /** * @param ClassMethod|Function_|Closure $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $hasChanged = \false; foreach ($node->params as $param) { @@ -84,7 +84,7 @@ CODE_SAMPLE $hasChanged = \true; } } - if ($node->returnType instanceof \PhpParser\Node\NullableType) { + if ($node->returnType instanceof NullableType) { $this->phpDocFromTypeDeclarationDecorator->decorate($node); $hasChanged = \true; } @@ -96,7 +96,7 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $functionLike */ - private function refactorParamType(\PhpParser\Node\Param $param, $functionLike) : bool + private function refactorParamType(Param $param, $functionLike) : bool { if (!$this->paramAnalyzer->isNullable($param)) { return \false; @@ -108,7 +108,7 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $functionLike */ - private function decorateWithDocBlock($functionLike, \PhpParser\Node\Param $param) : void + private function decorateWithDocBlock($functionLike, Param $param) : void { if ($param->type === null) { return; @@ -116,7 +116,7 @@ CODE_SAMPLE $type = $this->staticTypeMapper->mapPhpParserNodePHPStanType($param->type); $paramName = $this->getName($param->var); if ($paramName === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike); $this->phpDocTypeChanger->changeParamType($phpDocInfo, $type, $param, $paramName); diff --git a/rules/DowngradePhp71/Rector/FunctionLike/DowngradeVoidTypeDeclarationRector.php b/rules/DowngradePhp71/Rector/FunctionLike/DowngradeVoidTypeDeclarationRector.php index 94cddce2a7b..0b87ef0030f 100644 --- a/rules/DowngradePhp71/Rector/FunctionLike/DowngradeVoidTypeDeclarationRector.php +++ b/rules/DowngradePhp71/Rector/FunctionLike/DowngradeVoidTypeDeclarationRector.php @@ -10,21 +10,21 @@ use PhpParser\Node\Stmt\Function_; use PHPStan\Type\VoidType; use Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/void_return_type * * @see \Rector\Tests\DowngradePhp71\Rector\FunctionLike\DowngradeVoidTypeDeclarationRector\DowngradeVoidTypeDeclarationRectorTest */ -final class DowngradeVoidTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeVoidTypeDeclarationRector extends AbstractRector { /** * @readonly * @var \Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator */ private $phpDocFromTypeDeclarationDecorator; - public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator) + public function __construct(PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator) { $this->phpDocFromTypeDeclarationDecorator = $phpDocFromTypeDeclarationDecorator; } @@ -33,11 +33,11 @@ final class DowngradeVoidTypeDeclarationRector extends \Rector\Core\Rector\Abstr */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Expr\Closure::class]; + return [Function_::class, ClassMethod::class, Closure::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove "void" return type, add a "@return void" tag instead', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove "void" return type, add a "@return void" tag instead', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(): void @@ -61,9 +61,9 @@ CODE_SAMPLE /** * @param ClassMethod|Function_|Closure $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $voidType = new \PHPStan\Type\VoidType(); + $voidType = new VoidType(); if (!$this->phpDocFromTypeDeclarationDecorator->decorateReturnWithSpecificType($node, $voidType)) { return null; } diff --git a/rules/DowngradePhp71/Rector/List_/DowngradeKeysInListRector.php b/rules/DowngradePhp71/Rector/List_/DowngradeKeysInListRector.php index 2824ea19421..c0a0b4b6ad9 100644 --- a/rules/DowngradePhp71/Rector/List_/DowngradeKeysInListRector.php +++ b/rules/DowngradePhp71/Rector/List_/DowngradeKeysInListRector.php @@ -17,12 +17,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\Naming\ExpectedNameResolver\InflectorSingularResolver; use Rector\Naming\Naming\VariableNaming; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp71\Rector\List_\DowngradeKeysInListRector\DowngradeKeysInListRectorTest */ -final class DowngradeKeysInListRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeKeysInListRector extends AbstractRector { /** * @readonly @@ -34,7 +34,7 @@ final class DowngradeKeysInListRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Naming\Naming\VariableNaming */ private $variableNaming; - public function __construct(\Rector\Naming\ExpectedNameResolver\InflectorSingularResolver $inflectorSingularResolver, \Rector\Naming\Naming\VariableNaming $variableNaming) + public function __construct(InflectorSingularResolver $inflectorSingularResolver, VariableNaming $variableNaming) { $this->inflectorSingularResolver = $inflectorSingularResolver; $this->variableNaming = $variableNaming; @@ -44,11 +44,11 @@ final class DowngradeKeysInListRector extends \Rector\Core\Rector\AbstractRector */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\List_::class, \PhpParser\Node\Expr\Array_::class]; + return [List_::class, Array_::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Extract keys in list to its own variable assignment', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Extract keys in list to its own variable assignment', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(): void @@ -80,31 +80,31 @@ CODE_SAMPLE /** * @param List_|Array_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node) { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Node) { return null; } - $parentExpression = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentExpression instanceof \PhpParser\Node) { + $parentExpression = $parent->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentExpression instanceof Node) { return null; } $assignExpressions = $this->processExtractToItsOwnVariable($node, $parent, $parentExpression); if ($assignExpressions === []) { return null; } - if ($parent instanceof \PhpParser\Node\Expr\Assign) { + if ($parent instanceof Assign) { $this->mirrorComments($assignExpressions[0], $parentExpression); $this->nodesToAddCollector->addNodesBeforeNode($assignExpressions, $node); $this->removeNode($parentExpression); return $node; } - if ($parent instanceof \PhpParser\Node\Stmt\Foreach_) { + if ($parent instanceof Foreach_) { $defaultValueVar = $this->inflectorSingularResolver->resolve((string) $this->getName($parent->expr)); - $scope = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $parent->getAttribute(AttributeKey::SCOPE); $newValueVar = $this->variableNaming->createCountedValueName($defaultValueVar, $scope); - $parent->valueVar = new \PhpParser\Node\Expr\Variable($newValueVar); + $parent->valueVar = new Variable($newValueVar); $stmts = $parent->stmts; if ($stmts === []) { $parent->stmts = $assignExpressions; @@ -119,22 +119,22 @@ CODE_SAMPLE * @return Expression[] * @param \PhpParser\Node\Expr\List_|\PhpParser\Node\Expr\Array_ $node */ - private function processExtractToItsOwnVariable($node, \PhpParser\Node $parent, \PhpParser\Node $parentExpression) : array + private function processExtractToItsOwnVariable($node, Node $parent, Node $parentExpression) : array { $items = $node->items; $assignExpressions = []; foreach ($items as $item) { - if (!$item instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$item instanceof ArrayItem) { return []; } /** keyed and not keyed cannot be mixed, return early */ - if (!$item->key instanceof \PhpParser\Node\Expr) { + if (!$item->key instanceof Expr) { return []; } - if ($parentExpression instanceof \PhpParser\Node\Stmt\Expression && $parent instanceof \PhpParser\Node\Expr\Assign && $parent->var === $node) { - $assignExpressions[] = new \PhpParser\Node\Stmt\Expression(new \PhpParser\Node\Expr\Assign($item->value, new \PhpParser\Node\Expr\ArrayDimFetch($parent->expr, $item->key))); + if ($parentExpression instanceof Expression && $parent instanceof Assign && $parent->var === $node) { + $assignExpressions[] = new Expression(new Assign($item->value, new ArrayDimFetch($parent->expr, $item->key))); } - if (!$parent instanceof \PhpParser\Node\Stmt\Foreach_) { + if (!$parent instanceof Foreach_) { continue; } if ($parent->valueVar !== $node) { @@ -144,12 +144,12 @@ CODE_SAMPLE } return $assignExpressions; } - private function getExpressionFromForeachValue(\PhpParser\Node\Stmt\Foreach_ $foreach, \PhpParser\Node\Expr\ArrayItem $arrayItem) : \PhpParser\Node\Stmt\Expression + private function getExpressionFromForeachValue(Foreach_ $foreach, ArrayItem $arrayItem) : Expression { $defaultValueVar = $this->inflectorSingularResolver->resolve((string) $this->getName($foreach->expr)); - $scope = $foreach->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $foreach->getAttribute(AttributeKey::SCOPE); $newValueVar = $this->variableNaming->createCountedValueName($defaultValueVar, $scope); - $assign = new \PhpParser\Node\Expr\Assign($arrayItem->value, new \PhpParser\Node\Expr\ArrayDimFetch(new \PhpParser\Node\Expr\Variable($newValueVar), $arrayItem->key)); - return new \PhpParser\Node\Stmt\Expression($assign); + $assign = new Assign($arrayItem->value, new ArrayDimFetch(new Variable($newValueVar), $arrayItem->key)); + return new Expression($assign); } } diff --git a/rules/DowngradePhp71/Rector/StaticCall/DowngradeClosureFromCallableRector.php b/rules/DowngradePhp71/Rector/StaticCall/DowngradeClosureFromCallableRector.php index 87bcbade7b3..5bc4814da25 100644 --- a/rules/DowngradePhp71/Rector/StaticCall/DowngradeClosureFromCallableRector.php +++ b/rules/DowngradePhp71/Rector/StaticCall/DowngradeClosureFromCallableRector.php @@ -14,21 +14,21 @@ use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\Return_; use Rector\Core\PhpParser\Node\NamedVariableFactory; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/closurefromcallable * * @see \Rector\Tests\DowngradePhp71\Rector\StaticCall\DowngradeClosureFromCallableRector\DowngradeClosureFromCallableRectorTest */ -final class DowngradeClosureFromCallableRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeClosureFromCallableRector extends AbstractRector { /** * @readonly * @var \Rector\Core\PhpParser\Node\NamedVariableFactory */ private $namedVariableFactory; - public function __construct(\Rector\Core\PhpParser\Node\NamedVariableFactory $namedVariableFactory) + public function __construct(NamedVariableFactory $namedVariableFactory) { $this->namedVariableFactory = $namedVariableFactory; } @@ -37,11 +37,11 @@ final class DowngradeClosureFromCallableRector extends \Rector\Core\Rector\Abstr */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class]; + return [StaticCall::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Converts Closure::fromCallable() to compatible alternative.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Converts Closure::fromCallable() to compatible alternative.', [new CodeSample(<<<'CODE_SAMPLE' \Closure::fromCallable('callable'); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -55,7 +55,7 @@ CODE_SAMPLE /** * @param StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -63,19 +63,19 @@ CODE_SAMPLE if (!isset($node->args[0])) { return null; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } $tempVariable = $this->namedVariableFactory->createVariable($node, 'callable'); - $expression = new \PhpParser\Node\Stmt\Expression(new \PhpParser\Node\Expr\Assign($tempVariable, $node->args[0]->value)); + $expression = new Expression(new Assign($tempVariable, $node->args[0]->value)); $this->nodesToAddCollector->addNodeBeforeNode($expression, $node, $this->file->getSmartFileInfo()); - $closure = new \PhpParser\Node\Expr\Closure(); - $closure->uses[] = new \PhpParser\Node\Expr\ClosureUse($tempVariable); - $innerFuncCall = new \PhpParser\Node\Expr\FuncCall($tempVariable, [new \PhpParser\Node\Arg($this->nodeFactory->createFuncCall('func_get_args'), \false, \true)]); - $closure->stmts[] = new \PhpParser\Node\Stmt\Return_($innerFuncCall); + $closure = new Closure(); + $closure->uses[] = new ClosureUse($tempVariable); + $innerFuncCall = new FuncCall($tempVariable, [new Arg($this->nodeFactory->createFuncCall('func_get_args'), \false, \true)]); + $closure->stmts[] = new Return_($innerFuncCall); return $closure; } - private function shouldSkip(\PhpParser\Node\Expr\StaticCall $staticCall) : bool + private function shouldSkip(StaticCall $staticCall) : bool { if (!$this->nodeNameResolver->isName($staticCall->class, 'Closure')) { return \true; diff --git a/rules/DowngradePhp71/Rector/String_/DowngradeNegativeStringOffsetToStrlenRector.php b/rules/DowngradePhp71/Rector/String_/DowngradeNegativeStringOffsetToStrlenRector.php index 7ab20ec7879..8e7cf9ef090 100644 --- a/rules/DowngradePhp71/Rector/String_/DowngradeNegativeStringOffsetToStrlenRector.php +++ b/rules/DowngradePhp71/Rector/String_/DowngradeNegativeStringOffsetToStrlenRector.php @@ -16,16 +16,16 @@ use PhpParser\Node\Expr\Variable; use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp71\Rector\String_\DowngradeNegativeStringOffsetToStrlenRector\DowngradeNegativeStringOffsetToStrlenRectorTest */ -final class DowngradeNegativeStringOffsetToStrlenRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeNegativeStringOffsetToStrlenRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade negative string offset to strlen', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade negative string offset to strlen', [new CodeSample(<<<'CODE_SAMPLE' echo 'abcdef'[-2]; echo strpos('aabbcc', 'b', -3); echo strpos($var, 'b', -3); @@ -42,14 +42,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Scalar\String_::class, \PhpParser\Node\Expr\Variable::class, \PhpParser\Node\Expr\PropertyFetch::class, \PhpParser\Node\Expr\StaticPropertyFetch::class]; + return [FuncCall::class, String_::class, Variable::class, PropertyFetch::class, StaticPropertyFetch::class]; } /** * @param FuncCall|String_|Variable|PropertyFetch|StaticPropertyFetch $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\FuncCall) { + if ($node instanceof FuncCall) { return $this->processForFuncCall($node); } return $this->processForStringOrVariableOrProperty($node); @@ -57,14 +57,14 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Scalar\String_|\PhpParser\Node\Expr\Variable|\PhpParser\Node\Expr\PropertyFetch|\PhpParser\Node\Expr\StaticPropertyFetch $expr */ - private function processForStringOrVariableOrProperty($expr) : ?\PhpParser\Node\Expr + private function processForStringOrVariableOrProperty($expr) : ?Expr { - $nextNode = $expr->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if (!$nextNode instanceof \PhpParser\Node\Expr\UnaryMinus) { + $nextNode = $expr->getAttribute(AttributeKey::NEXT_NODE); + if (!$nextNode instanceof UnaryMinus) { return null; } - $parentOfNextNode = $nextNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentOfNextNode instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + $parentOfNextNode = $nextNode->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentOfNextNode instanceof ArrayDimFetch) { return null; } if (!$this->nodeComparator->areNodesEqual($parentOfNextNode->dim, $nextNode)) { @@ -73,10 +73,10 @@ CODE_SAMPLE /** @var UnaryMinus $dim */ $dim = $parentOfNextNode->dim; $strlenFuncCall = $this->nodeFactory->createFuncCall('strlen', [$expr]); - $parentOfNextNode->dim = new \PhpParser\Node\Expr\BinaryOp\Minus($strlenFuncCall, $dim->expr); + $parentOfNextNode->dim = new Minus($strlenFuncCall, $dim->expr); return $expr; } - private function processForFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Expr\FuncCall + private function processForFuncCall(FuncCall $funcCall) : ?FuncCall { $name = $this->getName($funcCall); if ($name !== 'strpos') { @@ -86,17 +86,17 @@ CODE_SAMPLE if (!isset($args[2])) { return null; } - if ($args[2] instanceof \PhpParser\Node\Arg && !$args[2]->value instanceof \PhpParser\Node\Expr\UnaryMinus) { + if ($args[2] instanceof Arg && !$args[2]->value instanceof UnaryMinus) { return null; } - if (!$args[0] instanceof \PhpParser\Node\Arg) { + if (!$args[0] instanceof Arg) { return null; } - if (!$funcCall->args[2] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[2] instanceof Arg) { return null; } $strlenFuncCall = $this->nodeFactory->createFuncCall('strlen', [$args[0]]); - $funcCall->args[2]->value = new \PhpParser\Node\Expr\BinaryOp\Minus($strlenFuncCall, $funcCall->args[2]->value->expr); + $funcCall->args[2]->value = new Minus($strlenFuncCall, $funcCall->args[2]->value->expr); return $funcCall; } } diff --git a/rules/DowngradePhp71/Rector/TryCatch/DowngradePipeToMultiCatchExceptionRector.php b/rules/DowngradePhp71/Rector/TryCatch/DowngradePipeToMultiCatchExceptionRector.php index fc0c287de31..cfe2a86bf8c 100644 --- a/rules/DowngradePhp71/Rector/TryCatch/DowngradePipeToMultiCatchExceptionRector.php +++ b/rules/DowngradePhp71/Rector/TryCatch/DowngradePipeToMultiCatchExceptionRector.php @@ -7,16 +7,16 @@ use PhpParser\Node; use PhpParser\Node\Stmt\Catch_; use PhpParser\Node\Stmt\TryCatch; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp71\Rector\TryCatch\DowngradePipeToMultiCatchExceptionRector\DowngradePipeToMultiCatchExceptionRectorTest */ -final class DowngradePipeToMultiCatchExceptionRector extends \Rector\Core\Rector\AbstractRector +final class DowngradePipeToMultiCatchExceptionRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade single one | separated to multi catch exception', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade single one | separated to multi catch exception', [new CodeSample(<<<'CODE_SAMPLE' try { // Some code... } catch (ExceptionType1 | ExceptionType2 $exception) { @@ -39,12 +39,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\TryCatch::class]; + return [TryCatch::class]; } /** * @param TryCatch $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $hasChanged = \false; foreach ($node->catches as $key => $catch) { @@ -56,7 +56,7 @@ CODE_SAMPLE $firstType = \array_shift($catchTypes); $catch->types = [$firstType]; foreach ($catchTypes as $catchType) { - $newCatch = new \PhpParser\Node\Stmt\Catch_([$catchType], $catch->var, $catch->stmts); + $newCatch = new Catch_([$catchType], $catch->var, $catch->stmts); \array_splice($node->catches, $key + 1, 0, [$newCatch]); $hasChanged = \true; } diff --git a/rules/DowngradePhp72/NodeAnalyzer/BuiltInMethodAnalyzer.php b/rules/DowngradePhp72/NodeAnalyzer/BuiltInMethodAnalyzer.php index 2ae4e9a5d0e..774b5aef966 100644 --- a/rules/DowngradePhp72/NodeAnalyzer/BuiltInMethodAnalyzer.php +++ b/rules/DowngradePhp72/NodeAnalyzer/BuiltInMethodAnalyzer.php @@ -19,12 +19,12 @@ final class BuiltInMethodAnalyzer * @var \Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer */ private $classChildAnalyzer; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer $classChildAnalyzer) + public function __construct(NodeNameResolver $nodeNameResolver, ClassChildAnalyzer $classChildAnalyzer) { $this->nodeNameResolver = $nodeNameResolver; $this->classChildAnalyzer = $classChildAnalyzer; } - public function isImplementsBuiltInInterface(\PHPStan\Reflection\ClassReflection $classReflection, \PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + public function isImplementsBuiltInInterface(ClassReflection $classReflection, ClassMethod $classMethod) : bool { if (!$classReflection->isClass()) { return \false; diff --git a/rules/DowngradePhp72/NodeAnalyzer/FunctionExistsFunCallAnalyzer.php b/rules/DowngradePhp72/NodeAnalyzer/FunctionExistsFunCallAnalyzer.php index dddc464ac94..102d2607969 100644 --- a/rules/DowngradePhp72/NodeAnalyzer/FunctionExistsFunCallAnalyzer.php +++ b/rules/DowngradePhp72/NodeAnalyzer/FunctionExistsFunCallAnalyzer.php @@ -27,20 +27,20 @@ final class FunctionExistsFunCallAnalyzer * @var \Rector\Core\PhpParser\Node\Value\ValueResolver */ private $valueResolver; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver, ValueResolver $valueResolver) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeNameResolver = $nodeNameResolver; $this->valueResolver = $valueResolver; } - public function detect(\PhpParser\Node\Expr $expr, string $functionName) : bool + public function detect(Expr $expr, string $functionName) : bool { /** @var If_|null $firstParentIf */ - $firstParentIf = $this->betterNodeFinder->findParentType($expr, \PhpParser\Node\Stmt\If_::class); - if (!$firstParentIf instanceof \PhpParser\Node\Stmt\If_) { + $firstParentIf = $this->betterNodeFinder->findParentType($expr, If_::class); + if (!$firstParentIf instanceof If_) { return \false; } - if (!$firstParentIf->cond instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$firstParentIf->cond instanceof FuncCall) { return \false; } if (!$this->nodeNameResolver->isName($firstParentIf->cond, 'function_exists')) { @@ -51,7 +51,7 @@ final class FunctionExistsFunCallAnalyzer if (!isset($functionExists->args[0])) { return \false; } - if (!$functionExists->args[0] instanceof \PhpParser\Node\Arg) { + if (!$functionExists->args[0] instanceof Arg) { return \false; } return $this->valueResolver->isValue($functionExists->args[0]->value, $functionName); diff --git a/rules/DowngradePhp72/NodeAnalyzer/OverrideFromAnonymousClassMethodAnalyzer.php b/rules/DowngradePhp72/NodeAnalyzer/OverrideFromAnonymousClassMethodAnalyzer.php index a92a12e7089..b9bb1ffde3c 100644 --- a/rules/DowngradePhp72/NodeAnalyzer/OverrideFromAnonymousClassMethodAnalyzer.php +++ b/rules/DowngradePhp72/NodeAnalyzer/OverrideFromAnonymousClassMethodAnalyzer.php @@ -30,13 +30,13 @@ final class OverrideFromAnonymousClassMethodAnalyzer * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ClassAnalyzer $classAnalyzer, NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider) { $this->classAnalyzer = $classAnalyzer; $this->nodeNameResolver = $nodeNameResolver; $this->reflectionProvider = $reflectionProvider; } - public function matchAncestorClassReflectionOverrideable(\PhpParser\Node\Stmt\ClassLike $classLike, \PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PHPStan\Reflection\ClassReflection + public function matchAncestorClassReflectionOverrideable(ClassLike $classLike, ClassMethod $classMethod) : ?ClassReflection { if (!$this->classAnalyzer->isAnonymousClass($classLike)) { return null; @@ -44,21 +44,21 @@ final class OverrideFromAnonymousClassMethodAnalyzer /** @var Class_ $classLike */ $interfaces = $classLike->implements; foreach ($interfaces as $interface) { - if (!$interface instanceof \PhpParser\Node\Name\FullyQualified) { + if (!$interface instanceof FullyQualified) { continue; } $resolve = $this->resolveClassReflectionWithNotPrivateMethod($interface, $classMethod); - if ($resolve instanceof \PHPStan\Reflection\ClassReflection) { + if ($resolve instanceof ClassReflection) { return $resolve; } } /** @var Class_ $classLike */ - if (!$classLike->extends instanceof \PhpParser\Node\Name\FullyQualified) { + if (!$classLike->extends instanceof FullyQualified) { return null; } return $this->resolveClassReflectionWithNotPrivateMethod($classLike->extends, $classMethod); } - private function resolveClassReflectionWithNotPrivateMethod(\PhpParser\Node\Name\FullyQualified $fullyQualified, \PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PHPStan\Reflection\ClassReflection + private function resolveClassReflectionWithNotPrivateMethod(FullyQualified $fullyQualified, ClassMethod $classMethod) : ?ClassReflection { $ancestorClassLike = $fullyQualified->toString(); if (!$this->reflectionProvider->hasClass($ancestorClassLike)) { @@ -69,9 +69,9 @@ final class OverrideFromAnonymousClassMethodAnalyzer if (!$classReflection->hasMethod($methodName)) { return null; } - $scope = $classMethod->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $classMethod->getAttribute(AttributeKey::SCOPE); $method = $classReflection->getMethod($methodName, $scope); - if (!$method instanceof \PHPStan\Reflection\Php\PhpMethodReflection) { + if (!$method instanceof PhpMethodReflection) { return null; } if ($method->isPrivate()) { diff --git a/rules/DowngradePhp72/NodeAnalyzer/RegexFuncAnalyzer.php b/rules/DowngradePhp72/NodeAnalyzer/RegexFuncAnalyzer.php index 7580d6f209c..cb6abc3c2b0 100644 --- a/rules/DowngradePhp72/NodeAnalyzer/RegexFuncAnalyzer.php +++ b/rules/DowngradePhp72/NodeAnalyzer/RegexFuncAnalyzer.php @@ -39,37 +39,37 @@ final class RegexFuncAnalyzer * @var \Rector\Core\PhpParser\Node\Value\ValueResolver */ private $valueResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver) + public function __construct(NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder, NodeComparator $nodeComparator, ValueResolver $valueResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; $this->nodeComparator = $nodeComparator; $this->valueResolver = $valueResolver; } - public function isRegexFunctionNames(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + public function isRegexFunctionNames(FuncCall $funcCall) : bool { if ($this->nodeNameResolver->isNames($funcCall, self::REGEX_FUNCTION_NAMES)) { return \true; } $variable = $funcCall->name; - if (!$variable instanceof \PhpParser\Node\Expr\Variable) { + if (!$variable instanceof Variable) { return \false; } /** @var Assign|null $assignExprVariable */ - $assignExprVariable = $this->betterNodeFinder->findFirstPrevious($funcCall, function (\PhpParser\Node $node) use($variable) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + $assignExprVariable = $this->betterNodeFinder->findFirstPrevious($funcCall, function (Node $node) use($variable) : bool { + if (!$node instanceof Assign) { return \false; } return $this->nodeComparator->areNodesEqual($node->var, $variable); }); - if (!$assignExprVariable instanceof \PhpParser\Node\Expr\Assign) { + if (!$assignExprVariable instanceof Assign) { return \false; } $expr = $assignExprVariable->expr; - if (!$expr instanceof \PhpParser\Node\Expr\Ternary) { + if (!$expr instanceof Ternary) { return \false; } - if (!$expr->if instanceof \PhpParser\Node\Expr) { + if (!$expr->if instanceof Expr) { return \false; } if (!$this->valueResolver->isValues($expr->if, self::REGEX_FUNCTION_NAMES)) { diff --git a/rules/DowngradePhp72/NodeAnalyzer/SealedClassAnalyzer.php b/rules/DowngradePhp72/NodeAnalyzer/SealedClassAnalyzer.php index 90870868f66..e9ce954b263 100644 --- a/rules/DowngradePhp72/NodeAnalyzer/SealedClassAnalyzer.php +++ b/rules/DowngradePhp72/NodeAnalyzer/SealedClassAnalyzer.php @@ -9,7 +9,7 @@ final class SealedClassAnalyzer /** * This method is perfectly sealed, nothing to downgrade here */ - public function isSealedClass(\PHPStan\Reflection\ClassReflection $classReflection) : bool + public function isSealedClass(ClassReflection $classReflection) : bool { if (!$classReflection->isClass()) { return \false; diff --git a/rules/DowngradePhp72/NodeManipulator/BitwiseFlagCleaner.php b/rules/DowngradePhp72/NodeManipulator/BitwiseFlagCleaner.php index 7fdf1bf7de8..02a38994f45 100644 --- a/rules/DowngradePhp72/NodeManipulator/BitwiseFlagCleaner.php +++ b/rules/DowngradePhp72/NodeManipulator/BitwiseFlagCleaner.php @@ -16,41 +16,41 @@ final class BitwiseFlagCleaner * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } - public function cleanFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr\BinaryOp\BitwiseOr $bitwiseOr, string $flag, \PhpParser\Node\Expr $expr = null) : void + public function cleanFuncCall(FuncCall $funcCall, BitwiseOr $bitwiseOr, string $flag, Expr $expr = null) : void { - if ($bitwiseOr->left instanceof \PhpParser\Node\Expr\BinaryOp\BitwiseOr) { + if ($bitwiseOr->left instanceof BitwiseOr) { /** @var BitwiseOr $leftLeft */ $leftLeft = $bitwiseOr->left; - if ($leftLeft->left instanceof \PhpParser\Node\Expr\ConstFetch && $this->nodeNameResolver->isName($leftLeft->left, $flag)) { - $bitwiseOr = new \PhpParser\Node\Expr\BinaryOp\BitwiseOr($leftLeft->right, $bitwiseOr->right); + if ($leftLeft->left instanceof ConstFetch && $this->nodeNameResolver->isName($leftLeft->left, $flag)) { + $bitwiseOr = new BitwiseOr($leftLeft->right, $bitwiseOr->right); } /** @var BitwiseOr $leftRight */ $leftRight = $bitwiseOr->left; - if ($leftRight->right instanceof \PhpParser\Node\Expr\ConstFetch && $this->nodeNameResolver->isName($leftRight->right, $flag)) { - $bitwiseOr = new \PhpParser\Node\Expr\BinaryOp\BitwiseOr($leftRight->left, $bitwiseOr->right); + if ($leftRight->right instanceof ConstFetch && $this->nodeNameResolver->isName($leftRight->right, $flag)) { + $bitwiseOr = new BitwiseOr($leftRight->left, $bitwiseOr->right); } - if ($bitwiseOr->left instanceof \PhpParser\Node\Expr\BinaryOp\BitwiseOr) { + if ($bitwiseOr->left instanceof BitwiseOr) { $this->cleanFuncCall($funcCall, $bitwiseOr->left, $flag, $bitwiseOr->right); return; } } - if ($expr instanceof \PhpParser\Node\Expr) { - $bitwiseOr = new \PhpParser\Node\Expr\BinaryOp\BitwiseOr($bitwiseOr, $expr); + if ($expr instanceof Expr) { + $bitwiseOr = new BitwiseOr($bitwiseOr, $expr); } $this->assignThirdArgsValue($funcCall, $bitwiseOr, $flag); } - private function assignThirdArgsValue(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr\BinaryOp\BitwiseOr $bitwiseOr, string $flag) : void + private function assignThirdArgsValue(FuncCall $funcCall, BitwiseOr $bitwiseOr, string $flag) : void { - if ($bitwiseOr->right instanceof \PhpParser\Node\Expr\ConstFetch && $this->nodeNameResolver->isName($bitwiseOr->right, $flag)) { + if ($bitwiseOr->right instanceof ConstFetch && $this->nodeNameResolver->isName($bitwiseOr->right, $flag)) { $bitwiseOr = $bitwiseOr->left; - } elseif ($bitwiseOr->left instanceof \PhpParser\Node\Expr\ConstFetch && $this->nodeNameResolver->isName($bitwiseOr->left, $flag)) { + } elseif ($bitwiseOr->left instanceof ConstFetch && $this->nodeNameResolver->isName($bitwiseOr->left, $flag)) { $bitwiseOr = $bitwiseOr->right; } - if (!$funcCall->args[3] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[3] instanceof Arg) { return; } $funcCall->args[3]->value = $bitwiseOr; diff --git a/rules/DowngradePhp72/NodeManipulator/JsonConstCleaner.php b/rules/DowngradePhp72/NodeManipulator/JsonConstCleaner.php index 0d35654e62c..880b53b17c0 100644 --- a/rules/DowngradePhp72/NodeManipulator/JsonConstCleaner.php +++ b/rules/DowngradePhp72/NodeManipulator/JsonConstCleaner.php @@ -25,7 +25,7 @@ final class JsonConstCleaner * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder) { $this->nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; @@ -37,7 +37,7 @@ final class JsonConstCleaner */ public function clean($node, array $constants) { - if ($node instanceof \PhpParser\Node\Expr\ConstFetch) { + if ($node instanceof ConstFetch) { return $this->cleanByConstFetch($node, $constants); } return $this->cleanByBitwiseOr($node, $constants); @@ -48,8 +48,8 @@ final class JsonConstCleaner */ private function hasDefinedCheck($node, array $constants) : bool { - return (bool) $this->betterNodeFinder->findFirstPrevious($node, function (\PhpParser\Node $subNode) use($constants) : bool { - if (!$subNode instanceof \PhpParser\Node\Expr\FuncCall) { + return (bool) $this->betterNodeFinder->findFirstPrevious($node, function (Node $subNode) use($constants) : bool { + if (!$subNode instanceof FuncCall) { return \false; } if (!$this->nodeNameResolver->isName($subNode, 'defined')) { @@ -59,7 +59,7 @@ final class JsonConstCleaner if (!isset($args[0])) { return \false; } - if (!$args[0]->value instanceof \PhpParser\Node\Scalar\String_) { + if (!$args[0]->value instanceof String_) { return \false; } return \in_array($args[0]->value->value, $constants, \true); @@ -68,24 +68,24 @@ final class JsonConstCleaner /** * @param string[] $constants */ - private function cleanByConstFetch(\PhpParser\Node\Expr\ConstFetch $constFetch, array $constants) : ?\PhpParser\Node\Expr\ConstFetch + private function cleanByConstFetch(ConstFetch $constFetch, array $constants) : ?ConstFetch { if (!$this->nodeNameResolver->isNames($constFetch, $constants)) { return null; } - $parent = $constFetch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\Expr\BinaryOp\BitwiseOr) { + $parent = $constFetch->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof BitwiseOr) { return null; } if ($this->hasDefinedCheck($constFetch, $constants)) { return null; } - return new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('0')); + return new ConstFetch(new Name('0')); } /** * @param string[] $constants */ - private function cleanByBitwiseOr(\PhpParser\Node\Expr\BinaryOp\BitwiseOr $bitwiseOr, array $constants) : ?\PhpParser\Node\Expr + private function cleanByBitwiseOr(BitwiseOr $bitwiseOr, array $constants) : ?Expr { $isLeftTransformed = $this->isTransformed($bitwiseOr->left, $constants); $isRightTransformed = $this->isTransformed($bitwiseOr->right, $constants); @@ -101,13 +101,13 @@ final class JsonConstCleaner if (!$isRightTransformed) { return $bitwiseOr->right; } - return new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('0')); + return new ConstFetch(new Name('0')); } /** * @param string[] $constants */ - private function isTransformed(\PhpParser\Node\Expr $expr, array $constants) : bool + private function isTransformed(Expr $expr, array $constants) : bool { - return $expr instanceof \PhpParser\Node\Expr\ConstFetch && $this->nodeNameResolver->isNames($expr, $constants); + return $expr instanceof ConstFetch && $this->nodeNameResolver->isNames($expr, $constants); } } diff --git a/rules/DowngradePhp72/PhpDoc/NativeParamToPhpDocDecorator.php b/rules/DowngradePhp72/PhpDoc/NativeParamToPhpDocDecorator.php index 88d5d8d75a4..26024348046 100644 --- a/rules/DowngradePhp72/PhpDoc/NativeParamToPhpDocDecorator.php +++ b/rules/DowngradePhp72/PhpDoc/NativeParamToPhpDocDecorator.php @@ -40,7 +40,7 @@ final class NativeParamToPhpDocDecorator * @var \Rector\Core\PhpParser\Node\Value\ValueResolver */ private $valueResolver; - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory, NodeNameResolver $nodeNameResolver, StaticTypeMapper $staticTypeMapper, PhpDocTypeChanger $phpDocTypeChanger, ValueResolver $valueResolver) { $this->phpDocInfoFactory = $phpDocInfoFactory; $this->nodeNameResolver = $nodeNameResolver; @@ -48,7 +48,7 @@ final class NativeParamToPhpDocDecorator $this->phpDocTypeChanger = $phpDocTypeChanger; $this->valueResolver = $valueResolver; } - public function decorate(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Param $param) : void + public function decorate(ClassMethod $classMethod, Param $param) : void { if ($param->type === null) { return; @@ -57,8 +57,8 @@ final class NativeParamToPhpDocDecorator $paramName = $this->nodeNameResolver->getName($param); $mappedCurrentParamType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($param->type); // add default null type - if ($param->default !== null && $this->valueResolver->isNull($param->default) && !\PHPStan\Type\TypeCombinator::containsNull($mappedCurrentParamType)) { - $mappedCurrentParamType = new \PHPStan\Type\UnionType([$mappedCurrentParamType, new \PHPStan\Type\NullType()]); + if ($param->default !== null && $this->valueResolver->isNull($param->default) && !TypeCombinator::containsNull($mappedCurrentParamType)) { + $mappedCurrentParamType = new UnionType([$mappedCurrentParamType, new NullType()]); } $this->phpDocTypeChanger->changeParamType($phpDocInfo, $mappedCurrentParamType, $param, $paramName); } diff --git a/rules/DowngradePhp72/Rector/ClassMethod/DowngradeParameterTypeWideningRector.php b/rules/DowngradePhp72/Rector/ClassMethod/DowngradeParameterTypeWideningRector.php index 9d7be08a6cf..0671812d582 100644 --- a/rules/DowngradePhp72/Rector/ClassMethod/DowngradeParameterTypeWideningRector.php +++ b/rules/DowngradePhp72/Rector/ClassMethod/DowngradeParameterTypeWideningRector.php @@ -16,8 +16,8 @@ use Rector\DowngradePhp72\NodeAnalyzer\OverrideFromAnonymousClassMethodAnalyzer; use Rector\DowngradePhp72\NodeAnalyzer\SealedClassAnalyzer; use Rector\DowngradePhp72\PhpDoc\NativeParamToPhpDocDecorator; use Rector\TypeDeclaration\NodeAnalyzer\AutowiredClassMethodOrPropertyAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @changelog https://www.php.net/manual/en/migration72.new-features.php#migration72.new-features.param-type-widening @@ -25,7 +25,7 @@ use RectorPrefix20220607\Webmozart\Assert\Assert; * * @see \Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\DowngradeParameterTypeWideningRectorTest */ -final class DowngradeParameterTypeWideningRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface +final class DowngradeParameterTypeWideningRector extends AbstractRector implements AllowEmptyConfigurableRectorInterface { /** * @var array @@ -61,7 +61,7 @@ final class DowngradeParameterTypeWideningRector extends \Rector\Core\Rector\Abs * @var \Rector\DowngradePhp72\NodeAnalyzer\SealedClassAnalyzer */ private $sealedClassAnalyzer; - public function __construct(\Rector\DowngradePhp72\PhpDoc\NativeParamToPhpDocDecorator $nativeParamToPhpDocDecorator, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\TypeDeclaration\NodeAnalyzer\AutowiredClassMethodOrPropertyAnalyzer $autowiredClassMethodOrPropertyAnalyzer, \Rector\DowngradePhp72\NodeAnalyzer\BuiltInMethodAnalyzer $builtInMethodAnalyzer, \Rector\DowngradePhp72\NodeAnalyzer\OverrideFromAnonymousClassMethodAnalyzer $overrideFromAnonymousClassMethodAnalyzer, \Rector\DowngradePhp72\NodeAnalyzer\SealedClassAnalyzer $sealedClassAnalyzer) + public function __construct(NativeParamToPhpDocDecorator $nativeParamToPhpDocDecorator, ReflectionResolver $reflectionResolver, AutowiredClassMethodOrPropertyAnalyzer $autowiredClassMethodOrPropertyAnalyzer, BuiltInMethodAnalyzer $builtInMethodAnalyzer, OverrideFromAnonymousClassMethodAnalyzer $overrideFromAnonymousClassMethodAnalyzer, SealedClassAnalyzer $sealedClassAnalyzer) { $this->nativeParamToPhpDocDecorator = $nativeParamToPhpDocDecorator; $this->reflectionResolver = $reflectionResolver; @@ -70,9 +70,9 @@ final class DowngradeParameterTypeWideningRector extends \Rector\Core\Rector\Abs $this->overrideFromAnonymousClassMethodAnalyzer = $overrideFromAnonymousClassMethodAnalyzer; $this->sealedClassAnalyzer = $sealedClassAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change param type to match the lowest type in whole family tree', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change param type to match the lowest type in whole family tree', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' interface SomeInterface { public function test(array $input); @@ -108,19 +108,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($node, ClassLike::class); + if (!$classLike instanceof ClassLike) { return null; } $ancestorOverridableAnonymousClass = $this->overrideFromAnonymousClassMethodAnalyzer->matchAncestorClassReflectionOverrideable($classLike, $node); - if ($ancestorOverridableAnonymousClass instanceof \PHPStan\Reflection\ClassReflection) { + if ($ancestorOverridableAnonymousClass instanceof ClassReflection) { return $this->processRemoveParamTypeFromMethod($ancestorOverridableAnonymousClass, $node); } $classReflection = $this->reflectionResolver->resolveClassAndAnonymousClass($classLike); @@ -133,12 +133,12 @@ CODE_SAMPLE { $unsafeTypesToMethods = $configuration; foreach ($unsafeTypesToMethods as $key => $value) { - \RectorPrefix20220607\Webmozart\Assert\Assert::string($key); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($value); + Assert::string($key); + Assert::allString($value); } $this->unsafeTypesToMethods = $unsafeTypesToMethods; } - private function shouldSkip(\PHPStan\Reflection\ClassReflection $classReflection, \PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkip(ClassReflection $classReflection, ClassMethod $classMethod) : bool { if ($classMethod->params === []) { return \true; @@ -160,7 +160,7 @@ CODE_SAMPLE } return $this->isSafeType($classReflection, $classMethod); } - private function processRemoveParamTypeFromMethod(\PHPStan\Reflection\ClassReflection $classReflection, \PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Stmt\ClassMethod + private function processRemoveParamTypeFromMethod(ClassReflection $classReflection, ClassMethod $classMethod) : ?ClassMethod { if ($this->shouldSkip($classReflection, $classMethod)) { return null; @@ -174,17 +174,17 @@ CODE_SAMPLE } return $classMethod; } - private function removeParamTypeFromMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod, int $paramPosition) : void + private function removeParamTypeFromMethod(ClassMethod $classMethod, int $paramPosition) : void { $param = $classMethod->params[$paramPosition] ?? null; - if (!$param instanceof \PhpParser\Node\Param) { + if (!$param instanceof Param) { return; } // Add the current type in the PHPDoc $this->nativeParamToPhpDocDecorator->decorate($classMethod, $param); $param->type = null; } - private function hasParamAlreadyNonTyped(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function hasParamAlreadyNonTyped(ClassMethod $classMethod) : bool { foreach ($classMethod->params as $param) { if ($param->type !== null) { @@ -193,7 +193,7 @@ CODE_SAMPLE } return \true; } - private function isSafeType(\PHPStan\Reflection\ClassReflection $classReflection, \PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function isSafeType(ClassReflection $classReflection, ClassMethod $classMethod) : bool { if ($this->unsafeTypesToMethods === []) { return \false; diff --git a/rules/DowngradePhp72/Rector/ConstFetch/DowngradePhp72JsonConstRector.php b/rules/DowngradePhp72/Rector/ConstFetch/DowngradePhp72JsonConstRector.php index 358933b4955..b35d3d9e64f 100644 --- a/rules/DowngradePhp72/Rector/ConstFetch/DowngradePhp72JsonConstRector.php +++ b/rules/DowngradePhp72/Rector/ConstFetch/DowngradePhp72JsonConstRector.php @@ -8,14 +8,14 @@ use PhpParser\Node\Expr\BinaryOp\BitwiseOr; use PhpParser\Node\Expr\ConstFetch; use Rector\Core\Rector\AbstractRector; use Rector\DowngradePhp72\NodeManipulator\JsonConstCleaner; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/function.json-encode.php#refsect1-function.json-encode-changelog * * @see \Rector\Tests\DowngradePhp72\Rector\ConstFetch\DowngradePhp72JsonConstRector\DowngradePhp72JsonConstRectorTest */ -final class DowngradePhp72JsonConstRector extends \Rector\Core\Rector\AbstractRector +final class DowngradePhp72JsonConstRector extends AbstractRector { /** * @var string[] @@ -26,13 +26,13 @@ final class DowngradePhp72JsonConstRector extends \Rector\Core\Rector\AbstractRe * @var \Rector\DowngradePhp72\NodeManipulator\JsonConstCleaner */ private $jsonConstCleaner; - public function __construct(\Rector\DowngradePhp72\NodeManipulator\JsonConstCleaner $jsonConstCleaner) + public function __construct(JsonConstCleaner $jsonConstCleaner) { $this->jsonConstCleaner = $jsonConstCleaner; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove Json constant that available only in php 7.2', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove Json constant that available only in php 7.2', [new CodeSample(<<<'CODE_SAMPLE' $inDecoder = new Decoder($connection, true, 512, \JSON_INVALID_UTF8_IGNORE); $inDecoder = new Decoder($connection, true, 512, \JSON_INVALID_UTF8_SUBSTITUTE); CODE_SAMPLE @@ -47,12 +47,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\ConstFetch::class, \PhpParser\Node\Expr\BinaryOp\BitwiseOr::class]; + return [ConstFetch::class, BitwiseOr::class]; } /** * @param ConstFetch|BitwiseOr $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { return $this->jsonConstCleaner->clean($node, self::CONSTANTS); } diff --git a/rules/DowngradePhp72/Rector/FuncCall/DowngradeJsonDecodeNullAssociativeArgRector.php b/rules/DowngradePhp72/Rector/FuncCall/DowngradeJsonDecodeNullAssociativeArgRector.php index 9be8f21b091..c2d205dd2bf 100644 --- a/rules/DowngradePhp72/Rector/FuncCall/DowngradeJsonDecodeNullAssociativeArgRector.php +++ b/rules/DowngradePhp72/Rector/FuncCall/DowngradeJsonDecodeNullAssociativeArgRector.php @@ -11,27 +11,27 @@ use PhpParser\Node\Expr\Ternary; use PHPStan\Type\BooleanType; use Rector\Core\NodeAnalyzer\ArgsAnalyzer; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp72\Rector\FuncCall\DowngradeJsonDecodeNullAssociativeArgRector\DowngradeJsonDecodeNullAssociativeArgRectorTest * * @changelog https://3v4l.org/b1mA6 */ -final class DowngradeJsonDecodeNullAssociativeArgRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeJsonDecodeNullAssociativeArgRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(ArgsAnalyzer $argsAnalyzer) { $this->argsAnalyzer = $argsAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade json_decode() with null associative argument function', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade json_decode() with null associative argument function', [new CodeSample(<<<'CODE_SAMPLE' function exactlyNull(string $json) { $value = json_decode($json, null); @@ -60,12 +60,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'json_decode')) { return null; @@ -79,20 +79,20 @@ CODE_SAMPLE } $associativeValue = $args[1]->value; // already converted - if ($associativeValue instanceof \PhpParser\Node\Expr\Ternary && $associativeValue->if === null) { + if ($associativeValue instanceof Ternary && $associativeValue->if === null) { return null; } $associativeValueType = $this->nodeTypeResolver->getType($associativeValue); - if ($associativeValueType instanceof \PHPStan\Type\BooleanType) { + if ($associativeValueType instanceof BooleanType) { return null; } - if ($associativeValue instanceof \PhpParser\Node\Expr\ConstFetch && $this->valueResolver->isNull($associativeValue)) { + if ($associativeValue instanceof ConstFetch && $this->valueResolver->isNull($associativeValue)) { $args[1]->value = $this->nodeFactory->createTrue(); return $node; } // add conditional ternary - $nullIdentical = new \PhpParser\Node\Expr\BinaryOp\Identical($associativeValue, $this->nodeFactory->createNull()); - $ternary = new \PhpParser\Node\Expr\Ternary($nullIdentical, null, $associativeValue); + $nullIdentical = new Identical($associativeValue, $this->nodeFactory->createNull()); + $ternary = new Ternary($nullIdentical, null, $associativeValue); $args[1]->value = $ternary; return $node; } diff --git a/rules/DowngradePhp72/Rector/FuncCall/DowngradePregUnmatchedAsNullConstantRector.php b/rules/DowngradePhp72/Rector/FuncCall/DowngradePregUnmatchedAsNullConstantRector.php index 6b72d0508b5..c4957defaf2 100644 --- a/rules/DowngradePhp72/Rector/FuncCall/DowngradePregUnmatchedAsNullConstantRector.php +++ b/rules/DowngradePhp72/Rector/FuncCall/DowngradePregUnmatchedAsNullConstantRector.php @@ -25,12 +25,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\DowngradePhp72\NodeAnalyzer\RegexFuncAnalyzer; use Rector\DowngradePhp72\NodeManipulator\BitwiseFlagCleaner; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp72\Rector\FuncCall\DowngradePregUnmatchedAsNullConstantRector\DowngradePregUnmatchedAsNullConstantRectorTest */ -final class DowngradePregUnmatchedAsNullConstantRector extends \Rector\Core\Rector\AbstractRector +final class DowngradePregUnmatchedAsNullConstantRector extends AbstractRector { /** * @see https://www.php.net/manual/en/function.preg-match.php @@ -52,7 +52,7 @@ final class DowngradePregUnmatchedAsNullConstantRector extends \Rector\Core\Rect * @var \Rector\DowngradePhp72\NodeAnalyzer\RegexFuncAnalyzer */ private $regexFuncAnalyzer; - public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator, \Rector\DowngradePhp72\NodeManipulator\BitwiseFlagCleaner $bitwiseFlagCleaner, \Rector\DowngradePhp72\NodeAnalyzer\RegexFuncAnalyzer $regexFuncAnalyzer) + public function __construct(IfManipulator $ifManipulator, BitwiseFlagCleaner $bitwiseFlagCleaner, RegexFuncAnalyzer $regexFuncAnalyzer) { $this->ifManipulator = $ifManipulator; $this->bitwiseFlagCleaner = $bitwiseFlagCleaner; @@ -63,14 +63,14 @@ final class DowngradePregUnmatchedAsNullConstantRector extends \Rector\Core\Rect */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Stmt\ClassConst::class]; + return [FuncCall::class, ClassConst::class]; } /** * @param FuncCall|ClassConst $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Stmt\ClassConst) { + if ($node instanceof ClassConst) { return $this->refactorClassConst($node); } if (!$this->regexFuncAnalyzer->isRegexFunctionNames($node)) { @@ -83,14 +83,14 @@ final class DowngradePregUnmatchedAsNullConstantRector extends \Rector\Core\Rect $flags = $args[3]->value; /** @var Variable $variable */ $variable = $args[2]->value; - if ($flags instanceof \PhpParser\Node\Expr\BinaryOp\BitwiseOr) { + if ($flags instanceof BitwiseOr) { $this->bitwiseFlagCleaner->cleanFuncCall($node, $flags, self::UNMATCHED_NULL_FLAG, null); if (!$this->nodeComparator->areNodesEqual($flags, $args[3]->value)) { return $this->handleEmptyStringToNullMatch($node, $variable); } return null; } - if (!$flags instanceof \PhpParser\Node\Expr\ConstFetch) { + if (!$flags instanceof ConstFetch) { return null; } if (!$this->isName($flags, self::UNMATCHED_NULL_FLAG)) { @@ -100,9 +100,9 @@ final class DowngradePregUnmatchedAsNullConstantRector extends \Rector\Core\Rect unset($node->args[3]); return $node; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove PREG_UNMATCHED_AS_NULL from preg_match and set null value on empty string matched on each match', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove PREG_UNMATCHED_AS_NULL from preg_match and set null value on empty string matched on each match', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -127,91 +127,91 @@ class SomeClass CODE_SAMPLE )]); } - private function refactorClassConst(\PhpParser\Node\Stmt\ClassConst $classConst) : ?\PhpParser\Node\Stmt\ClassConst + private function refactorClassConst(ClassConst $classConst) : ?ClassConst { foreach ($classConst->consts as $key => $singleClassConst) { - if (!$singleClassConst->value instanceof \PhpParser\Node\Expr\ConstFetch) { + if (!$singleClassConst->value instanceof ConstFetch) { continue; } if (!$this->isName($singleClassConst->value, self::UNMATCHED_NULL_FLAG)) { continue; } - $classConst->consts[$key]->value = new \PhpParser\Node\Scalar\LNumber(512); + $classConst->consts[$key]->value = new LNumber(512); return $classConst; } return null; } - private function handleEmptyStringToNullMatch(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr\Variable $variable) : \PhpParser\Node\Expr\FuncCall + private function handleEmptyStringToNullMatch(FuncCall $funcCall, Variable $variable) : FuncCall { - $closure = new \PhpParser\Node\Expr\Closure(); - $variablePass = new \PhpParser\Node\Expr\Variable('value'); - $param = new \PhpParser\Node\Param($variablePass); + $closure = new Closure(); + $variablePass = new Variable('value'); + $param = new Param($variablePass); $param->byRef = \true; $closure->params = [$param]; - $assign = new \PhpParser\Node\Expr\Assign($variablePass, $this->nodeFactory->createNull()); - $if = $this->ifManipulator->createIfStmt(new \PhpParser\Node\Expr\BinaryOp\Identical($variablePass, new \PhpParser\Node\Scalar\String_('')), new \PhpParser\Node\Stmt\Expression($assign)); + $assign = new Assign($variablePass, $this->nodeFactory->createNull()); + $if = $this->ifManipulator->createIfStmt(new Identical($variablePass, new String_('')), new Expression($assign)); $closure->stmts[0] = $if; $arguments = $this->nodeFactory->createArgs([$variable, $closure]); $replaceEmptyStringToNull = $this->nodeFactory->createFuncCall('array_walk_recursive', $arguments); return $this->processReplace($funcCall, $replaceEmptyStringToNull); } - private function processReplace(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr\FuncCall $replaceEmptystringToNull) : \PhpParser\Node\Expr\FuncCall + private function processReplace(FuncCall $funcCall, FuncCall $replaceEmptystringToNull) : FuncCall { - $parent = $funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\Stmt\Expression) { + $parent = $funcCall->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof Expression) { $this->nodesToAddCollector->addNodeAfterNode($replaceEmptystringToNull, $funcCall); return $funcCall; } - if ($parent instanceof \PhpParser\Node\Stmt\If_ && $parent->cond === $funcCall) { + if ($parent instanceof If_ && $parent->cond === $funcCall) { return $this->processInIf($parent, $funcCall, $replaceEmptystringToNull); } - if (!$parent instanceof \PhpParser\Node) { - throw new \RectorPrefix20220607\Nette\NotImplementedException(); + if (!$parent instanceof Node) { + throw new NotImplementedException(); } - $if = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\Expr\BooleanNot) { + $if = $parent->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof BooleanNot) { return $this->processInIf($if, $funcCall, $replaceEmptystringToNull); } - if ($parent instanceof \PhpParser\Node\Expr\Assign && $parent->expr === $funcCall) { + if ($parent instanceof Assign && $parent->expr === $funcCall) { return $this->processInAssign($parent, $funcCall, $replaceEmptystringToNull); } - if (!$parent instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { - throw new \Rector\Core\Exception\NotImplementedYetException(); + if (!$parent instanceof Identical) { + throw new NotImplementedYetException(); } - if (!$if instanceof \PhpParser\Node\Stmt\If_) { - throw new \Rector\Core\Exception\NotImplementedYetException(); + if (!$if instanceof If_) { + throw new NotImplementedYetException(); } return $this->processInIf($if, $funcCall, $replaceEmptystringToNull); } - private function processInAssign(\PhpParser\Node\Expr\Assign $assign, \PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr\FuncCall $replaceEmptyStringToNull) : \PhpParser\Node\Expr\FuncCall + private function processInAssign(Assign $assign, FuncCall $funcCall, FuncCall $replaceEmptyStringToNull) : FuncCall { - $this->nodesToAddCollector->addNodeAfterNode(new \PhpParser\Node\Stmt\Expression($replaceEmptyStringToNull), $assign); + $this->nodesToAddCollector->addNodeAfterNode(new Expression($replaceEmptyStringToNull), $assign); return $funcCall; } - private function processInIf(\PhpParser\Node\Stmt\If_ $if, \PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr\FuncCall $replaceEmptyStringToNull) : \PhpParser\Node\Expr\FuncCall + private function processInIf(If_ $if, FuncCall $funcCall, FuncCall $replaceEmptyStringToNull) : FuncCall { $cond = $if->cond; - if (!$cond instanceof \PhpParser\Node\Expr\BinaryOp\Identical && !$cond instanceof \PhpParser\Node\Expr\BooleanNot) { + if (!$cond instanceof Identical && !$cond instanceof BooleanNot) { $this->handleNotInIdenticalAndBooleanNot($if, $replaceEmptyStringToNull); } - if ($cond instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { + if ($cond instanceof Identical) { $valueCompare = $cond->left === $funcCall ? $cond->right : $cond->left; if ($this->valueResolver->isFalse($valueCompare)) { $this->nodesToAddCollector->addNodeAfterNode($replaceEmptyStringToNull, $if); } } - if ($cond instanceof \PhpParser\Node\Expr\BooleanNot) { + if ($cond instanceof BooleanNot) { $this->nodesToAddCollector->addNodeAfterNode($replaceEmptyStringToNull, $if); } return $funcCall; } - private function handleNotInIdenticalAndBooleanNot(\PhpParser\Node\Stmt\If_ $if, \PhpParser\Node\Expr\FuncCall $funcCall) : void + private function handleNotInIdenticalAndBooleanNot(If_ $if, FuncCall $funcCall) : void { if ($if->stmts !== []) { $firstStmt = $if->stmts[0]; $this->nodesToAddCollector->addNodeBeforeNode($funcCall, $firstStmt, $this->file->getSmartFileInfo()); return; } - $if->stmts[0] = new \PhpParser\Node\Stmt\Expression($funcCall); + $if->stmts[0] = new Expression($funcCall); } } diff --git a/rules/DowngradePhp72/Rector/FuncCall/DowngradeStreamIsattyRector.php b/rules/DowngradePhp72/Rector/FuncCall/DowngradeStreamIsattyRector.php index b8ded55aa58..d52db9b7d4e 100644 --- a/rules/DowngradePhp72/Rector/FuncCall/DowngradeStreamIsattyRector.php +++ b/rules/DowngradePhp72/Rector/FuncCall/DowngradeStreamIsattyRector.php @@ -15,14 +15,14 @@ use Rector\Core\PhpParser\Parser\InlineCodeParser; use Rector\Core\Rector\AbstractScopeAwareRector; use Rector\DowngradePhp72\NodeAnalyzer\FunctionExistsFunCallAnalyzer; use Rector\Naming\Naming\VariableNaming; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/symfony/polyfill/commit/cc2bf55accd32b989348e2039e8c91cde46aebed * * @see \Rector\Tests\DowngradePhp72\Rector\FuncCall\DowngradeStreamIsattyRector\DowngradeStreamIsattyRectorTest */ -final class DowngradeStreamIsattyRector extends \Rector\Core\Rector\AbstractScopeAwareRector +final class DowngradeStreamIsattyRector extends AbstractScopeAwareRector { /** * @var \PhpParser\Node\Expr\Closure|null @@ -43,15 +43,15 @@ final class DowngradeStreamIsattyRector extends \Rector\Core\Rector\AbstractScop * @var \Rector\Naming\Naming\VariableNaming */ private $variableNaming; - public function __construct(\Rector\Core\PhpParser\Parser\InlineCodeParser $inlineCodeParser, \Rector\DowngradePhp72\NodeAnalyzer\FunctionExistsFunCallAnalyzer $functionExistsFunCallAnalyzer, \Rector\Naming\Naming\VariableNaming $variableNaming) + public function __construct(InlineCodeParser $inlineCodeParser, FunctionExistsFunCallAnalyzer $functionExistsFunCallAnalyzer, VariableNaming $variableNaming) { $this->inlineCodeParser = $inlineCodeParser; $this->functionExistsFunCallAnalyzer = $functionExistsFunCallAnalyzer; $this->variableNaming = $variableNaming; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade stream_isatty() function', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade stream_isatty() function', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($stream) @@ -95,12 +95,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactorWithScope(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : ?\PhpParser\Node + public function refactorWithScope(Node $node, Scope $scope) : ?Node { if (!$this->isName($node, 'stream_isatty')) { return null; @@ -109,22 +109,22 @@ CODE_SAMPLE return null; } $function = $this->createClosure(); - $variable = new \PhpParser\Node\Expr\Variable($this->variableNaming->createCountedValueName('streamIsatty', $scope)); - $assign = new \PhpParser\Node\Expr\Assign($variable, $function); + $variable = new Variable($this->variableNaming->createCountedValueName('streamIsatty', $scope)); + $assign = new Assign($variable, $function); $this->nodesToAddCollector->addNodeBeforeNode($assign, $node, $this->file->getSmartFileInfo()); - return new \PhpParser\Node\Expr\FuncCall($variable, $node->args); + return new FuncCall($variable, $node->args); } - private function createClosure() : \PhpParser\Node\Expr\Closure + private function createClosure() : Closure { - if ($this->cachedClosure instanceof \PhpParser\Node\Expr\Closure) { + if ($this->cachedClosure instanceof Closure) { return clone $this->cachedClosure; } $stmts = $this->inlineCodeParser->parse(__DIR__ . '/../../snippet/isatty_closure.php.inc'); /** @var Expression $expression */ $expression = $stmts[0]; $expr = $expression->expr; - if (!$expr instanceof \PhpParser\Node\Expr\Closure) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$expr instanceof Closure) { + throw new ShouldNotHappenException(); } $this->cachedClosure = $expr; return $expr; diff --git a/rules/DowngradePhp72/Rector/FunctionLike/DowngradeObjectTypeDeclarationRector.php b/rules/DowngradePhp72/Rector/FunctionLike/DowngradeObjectTypeDeclarationRector.php index 1c437abbd6a..01363a14d54 100644 --- a/rules/DowngradePhp72/Rector/FunctionLike/DowngradeObjectTypeDeclarationRector.php +++ b/rules/DowngradePhp72/Rector/FunctionLike/DowngradeObjectTypeDeclarationRector.php @@ -10,19 +10,19 @@ use PhpParser\Node\Stmt\Function_; use PHPStan\Type\ObjectWithoutClassType; use Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp72\Rector\FunctionLike\DowngradeObjectTypeDeclarationRector\DowngradeObjectTypeDeclarationRectorTest */ -final class DowngradeObjectTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeObjectTypeDeclarationRector extends AbstractRector { /** * @readonly * @var \Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator */ private $phpDocFromTypeDeclarationDecorator; - public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator) + public function __construct(PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator) { $this->phpDocFromTypeDeclarationDecorator = $phpDocFromTypeDeclarationDecorator; } @@ -31,14 +31,14 @@ final class DowngradeObjectTypeDeclarationRector extends \Rector\Core\Rector\Abs */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Expr\Closure::class]; + return [Function_::class, ClassMethod::class, Closure::class]; } /** * @param Function_|ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $objectWithoutClassType = new \PHPStan\Type\ObjectWithoutClassType(); + $objectWithoutClassType = new ObjectWithoutClassType(); foreach ($node->params as $param) { $this->phpDocFromTypeDeclarationDecorator->decorateParamWithSpecificType($param, $node, $objectWithoutClassType); } @@ -47,9 +47,9 @@ final class DowngradeObjectTypeDeclarationRector extends \Rector\Core\Rector\Abs } return $node; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove the "object" param and return type, add a @param and @return tags instead', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove the "object" param and return type, add a @param and @return tags instead', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function someFunction(object $someObject): object diff --git a/rules/DowngradePhp73/Rector/ConstFetch/DowngradePhp73JsonConstRector.php b/rules/DowngradePhp73/Rector/ConstFetch/DowngradePhp73JsonConstRector.php index d5ee4a72e6d..cd7fdac8b46 100644 --- a/rules/DowngradePhp73/Rector/ConstFetch/DowngradePhp73JsonConstRector.php +++ b/rules/DowngradePhp73/Rector/ConstFetch/DowngradePhp73JsonConstRector.php @@ -8,14 +8,14 @@ use PhpParser\Node\Expr\BinaryOp\BitwiseOr; use PhpParser\Node\Expr\ConstFetch; use Rector\Core\Rector\AbstractRector; use Rector\DowngradePhp72\NodeManipulator\JsonConstCleaner; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/function.json-encode.php#refsect1-function.json-encode-changelog * * @see \Rector\Tests\DowngradePhp73\Rector\ConstFetch\DowngradePhp73JsonConstRector\DowngradePhp73JsonConstRectorTest */ -final class DowngradePhp73JsonConstRector extends \Rector\Core\Rector\AbstractRector +final class DowngradePhp73JsonConstRector extends AbstractRector { /** * @var string[] @@ -26,13 +26,13 @@ final class DowngradePhp73JsonConstRector extends \Rector\Core\Rector\AbstractRe * @var \Rector\DowngradePhp72\NodeManipulator\JsonConstCleaner */ private $jsonConstCleaner; - public function __construct(\Rector\DowngradePhp72\NodeManipulator\JsonConstCleaner $jsonConstCleaner) + public function __construct(JsonConstCleaner $jsonConstCleaner) { $this->jsonConstCleaner = $jsonConstCleaner; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove Json constant that available only in php 7.3', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove Json constant that available only in php 7.3', [new CodeSample(<<<'CODE_SAMPLE' json_encode($content, JSON_THROW_ON_ERROR); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -45,12 +45,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\ConstFetch::class, \PhpParser\Node\Expr\BinaryOp\BitwiseOr::class]; + return [ConstFetch::class, BitwiseOr::class]; } /** * @param ConstFetch|BitwiseOr $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { return $this->jsonConstCleaner->clean($node, self::CONSTANTS); } diff --git a/rules/DowngradePhp73/Rector/FuncCall/DowngradeArrayKeyFirstLastRector.php b/rules/DowngradePhp73/Rector/FuncCall/DowngradeArrayKeyFirstLastRector.php index 3a553b33119..d5630d02797 100644 --- a/rules/DowngradePhp73/Rector/FuncCall/DowngradeArrayKeyFirstLastRector.php +++ b/rules/DowngradePhp73/Rector/FuncCall/DowngradeArrayKeyFirstLastRector.php @@ -15,27 +15,27 @@ use PhpParser\Node\Stmt\Expression; use Rector\Core\Rector\AbstractRector; use Rector\Naming\Naming\VariableNaming; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/array_key_first_last * * @see \Rector\Tests\DowngradePhp73\Rector\FuncCall\DowngradeArrayKeyFirstLastRector\DowngradeArrayKeyFirstLastRectorTest */ -final class DowngradeArrayKeyFirstLastRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeArrayKeyFirstLastRector extends AbstractRector { /** * @readonly * @var \Rector\Naming\Naming\VariableNaming */ private $variableNaming; - public function __construct(\Rector\Naming\Naming\VariableNaming $variableNaming) + public function __construct(VariableNaming $variableNaming) { $this->variableNaming = $variableNaming; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade array_key_first() and array_key_last() functions', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade array_key_first() and array_key_last() functions', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($items) @@ -61,12 +61,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->isName($node, 'array_key_first')) { return $this->refactorArrayKeyFirst($node); @@ -76,12 +76,12 @@ CODE_SAMPLE } return null; } - private function refactorArrayKeyFirst(\PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Expr\FuncCall + private function refactorArrayKeyFirst(FuncCall $funcCall) : ?FuncCall { if (!isset($funcCall->args[0])) { return null; } - if (!$funcCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[0] instanceof Arg) { return null; } $originalArray = $funcCall->args[0]->value; @@ -91,18 +91,18 @@ CODE_SAMPLE } $resetFuncCall = $this->nodeFactory->createFuncCall('reset', [$array]); $this->nodesToAddCollector->addNodeBeforeNode($resetFuncCall, $funcCall, $this->file->getSmartFileInfo()); - $funcCall->name = new \PhpParser\Node\Name('key'); + $funcCall->name = new Name('key'); if ($originalArray !== $array) { $funcCall->args[0]->value = $array; } return $funcCall; } - private function refactorArrayKeyLast(\PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Expr\FuncCall + private function refactorArrayKeyLast(FuncCall $funcCall) : ?FuncCall { if (!isset($funcCall->args[0])) { return null; } - if (!$funcCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[0] instanceof Arg) { return null; } $originalArray = $funcCall->args[0]->value; @@ -112,7 +112,7 @@ CODE_SAMPLE } $resetFuncCall = $this->nodeFactory->createFuncCall('end', [$array]); $this->nodesToAddCollector->addNodeBeforeNode($resetFuncCall, $funcCall, $this->file->getSmartFileInfo()); - $funcCall->name = new \PhpParser\Node\Name('key'); + $funcCall->name = new Name('key'); if ($originalArray !== $array) { $funcCall->args[0]->value = $array; } @@ -121,23 +121,23 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Expr|\PhpParser\Node\Expr\Variable $variable */ - private function addAssignNewVariable(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr $expr, $variable) : void + private function addAssignNewVariable(FuncCall $funcCall, Expr $expr, $variable) : void { - $this->nodesToAddCollector->addNodeBeforeNode(new \PhpParser\Node\Stmt\Expression(new \PhpParser\Node\Expr\Assign($variable, $expr)), $funcCall, $this->file->getSmartFileInfo()); + $this->nodesToAddCollector->addNodeBeforeNode(new Expression(new Assign($variable, $expr)), $funcCall, $this->file->getSmartFileInfo()); } /** * @return \PhpParser\Node\Expr|\PhpParser\Node\Expr\Variable */ - private function resolveCastedArray(\PhpParser\Node\Expr $expr) + private function resolveCastedArray(Expr $expr) { - if (!$expr instanceof \PhpParser\Node\Expr\Cast\Array_) { + if (!$expr instanceof Array_) { return $expr; } - if ($expr->expr instanceof \PhpParser\Node\Expr\Cast\Array_) { + if ($expr->expr instanceof Array_) { return $this->resolveCastedArray($expr->expr); } - $scope = $expr->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $expr->getAttribute(AttributeKey::SCOPE); $variableName = $this->variableNaming->createCountedValueName((string) $this->nodeNameResolver->getName($expr->expr), $scope); - return new \PhpParser\Node\Expr\Variable($variableName); + return new Variable($variableName); } } diff --git a/rules/DowngradePhp73/Rector/FuncCall/DowngradeIsCountableRector.php b/rules/DowngradePhp73/Rector/FuncCall/DowngradeIsCountableRector.php index d39f4e9bd48..38615476d39 100644 --- a/rules/DowngradePhp73/Rector/FuncCall/DowngradeIsCountableRector.php +++ b/rules/DowngradePhp73/Rector/FuncCall/DowngradeIsCountableRector.php @@ -10,18 +10,18 @@ use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\Instanceof_; use PhpParser\Node\Name\FullyQualified; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/is-countable * * @see \Rector\Tests\DowngradePhp73\Rector\FuncCall\DowngradeIsCountableRector\DowngradeIsCountableRectorTest */ -final class DowngradeIsCountableRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeIsCountableRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade is_countable() to former version', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade is_countable() to former version', [new CodeSample(<<<'CODE_SAMPLE' $items = []; return is_countable($items); CODE_SAMPLE @@ -36,12 +36,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'is_countable')) { return null; @@ -49,11 +49,11 @@ CODE_SAMPLE if (!isset($node->args[0])) { return null; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } $isArrayFuncCall = $this->nodeFactory->createFuncCall('is_array', $node->args); - $instanceof = new \PhpParser\Node\Expr\Instanceof_($node->args[0]->value, new \PhpParser\Node\Name\FullyQualified('Countable')); - return new \PhpParser\Node\Expr\BinaryOp\BooleanOr($isArrayFuncCall, $instanceof); + $instanceof = new Instanceof_($node->args[0]->value, new FullyQualified('Countable')); + return new BooleanOr($isArrayFuncCall, $instanceof); } } diff --git a/rules/DowngradePhp73/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector.php b/rules/DowngradePhp73/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector.php index caa2e68ffcd..da88282b4c4 100644 --- a/rules/DowngradePhp73/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector.php +++ b/rules/DowngradePhp73/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector.php @@ -11,25 +11,25 @@ use PhpParser\Node\Expr\StaticCall; use Rector\Core\Rector\AbstractRector; use Rector\DowngradePhp73\Tokenizer\FollowedByCommaAnalyzer; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCallsRector\DowngradeTrailingCommasInFunctionCallsRectorTest */ -final class DowngradeTrailingCommasInFunctionCallsRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeTrailingCommasInFunctionCallsRector extends AbstractRector { /** * @readonly * @var \Rector\DowngradePhp73\Tokenizer\FollowedByCommaAnalyzer */ private $followedByCommaAnalyzer; - public function __construct(\Rector\DowngradePhp73\Tokenizer\FollowedByCommaAnalyzer $followedByCommaAnalyzer) + public function __construct(FollowedByCommaAnalyzer $followedByCommaAnalyzer) { $this->followedByCommaAnalyzer = $followedByCommaAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove trailing commas in function calls', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove trailing commas in function calls', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function __construct(string $value) @@ -60,12 +60,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class, \PhpParser\Node\Expr\New_::class]; + return [FuncCall::class, MethodCall::class, StaticCall::class, New_::class]; } /** * @param FuncCall|MethodCall|StaticCall|New_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->args) { \end($node->args); @@ -75,8 +75,8 @@ CODE_SAMPLE return null; } // remove comma - $last->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::FUNC_ARGS_TRAILING_COMMA, \false); - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $last->setAttribute(AttributeKey::FUNC_ARGS_TRAILING_COMMA, \false); + $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); return $node; } return null; diff --git a/rules/DowngradePhp73/Rector/FuncCall/SetCookieOptionsArrayToArgumentsRector.php b/rules/DowngradePhp73/Rector/FuncCall/SetCookieOptionsArrayToArgumentsRector.php index e91a62561ad..ab9420a5ec7 100644 --- a/rules/DowngradePhp73/Rector/FuncCall/SetCookieOptionsArrayToArgumentsRector.php +++ b/rules/DowngradePhp73/Rector/FuncCall/SetCookieOptionsArrayToArgumentsRector.php @@ -13,12 +13,12 @@ use PhpParser\Node\Scalar\String_; use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\NodeAnalyzer\ArgsAnalyzer; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp73\Rector\FuncCall\SetCookieOptionsArrayToArgumentsRector\SetCookieOptionsArrayToArgumentsRectorTest */ -final class SetCookieOptionsArrayToArgumentsRector extends \Rector\Core\Rector\AbstractRector +final class SetCookieOptionsArrayToArgumentsRector extends AbstractRector { /** * Conversion table from argument index to options name @@ -39,13 +39,13 @@ final class SetCookieOptionsArrayToArgumentsRector extends \Rector\Core\Rector\A * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(ArgsAnalyzer $argsAnalyzer) { $this->argsAnalyzer = $argsAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Convert setcookie option array to arguments', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Convert setcookie option array to arguments', [new CodeSample(<<<'CODE_SAMPLE' setcookie('name', $value, ['expires' => 360]); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -58,12 +58,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -71,7 +71,7 @@ CODE_SAMPLE $node->args = $this->composeNewArgs($node); return $node; } - private function shouldSkip(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function shouldSkip(FuncCall $funcCall) : bool { if (!$this->isNames($funcCall, ['setcookie', 'setrawcookie'])) { return \true; @@ -83,12 +83,12 @@ CODE_SAMPLE if (!isset($funcCall->args[2])) { return \true; } - return !($funcCall->args[2] instanceof \PhpParser\Node\Arg && $funcCall->args[2]->value instanceof \PhpParser\Node\Expr\Array_); + return !($funcCall->args[2] instanceof Arg && $funcCall->args[2]->value instanceof Array_); } /** * @return Arg[] */ - private function composeNewArgs(\PhpParser\Node\Expr\FuncCall $funcCall) : array + private function composeNewArgs(FuncCall $funcCall) : array { $this->highestIndex = 1; if (!$this->argsAnalyzer->isArgsInstanceInArgsPositions($funcCall->args, [0, 1, 2])) { @@ -119,7 +119,7 @@ CODE_SAMPLE if ($order > $this->highestIndex) { $this->highestIndex = $order; } - $newArgs[$order] = new \PhpParser\Node\Arg($value); + $newArgs[$order] = new Arg($value); } $newArgs = $this->fillMissingArgumentsWithDefaultValues($newArgs); \ksort($newArgs); @@ -143,13 +143,13 @@ CODE_SAMPLE } return $args; } - private function createDefaultValueArg(int $argumentIndex) : \PhpParser\Node\Arg + private function createDefaultValueArg(int $argumentIndex) : Arg { if (!\array_key_exists($argumentIndex, self::ARGUMENT_DEFAULT_VALUES)) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $argumentDefaultValue = self::ARGUMENT_DEFAULT_VALUES[$argumentIndex]; - $expr = \PhpParser\BuilderHelpers::normalizeValue($argumentDefaultValue); - return new \PhpParser\Node\Arg($expr); + $expr = BuilderHelpers::normalizeValue($argumentDefaultValue); + return new Arg($expr); } } diff --git a/rules/DowngradePhp73/Rector/List_/DowngradeListReferenceAssignmentRector.php b/rules/DowngradePhp73/Rector/List_/DowngradeListReferenceAssignmentRector.php index 05487f09c67..7f601909719 100644 --- a/rules/DowngradePhp73/Rector/List_/DowngradeListReferenceAssignmentRector.php +++ b/rules/DowngradePhp73/Rector/List_/DowngradeListReferenceAssignmentRector.php @@ -16,13 +16,13 @@ use PhpParser\Node\Scalar\LNumber; use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/list_reference_assignment * @see \Rector\Tests\DowngradePhp73\Rector\List_\DowngradeListReferenceAssignmentRector\DowngradeListReferenceAssignmentRectorTest */ -final class DowngradeListReferenceAssignmentRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeListReferenceAssignmentRector extends AbstractRector { /** * @var int @@ -32,9 +32,9 @@ final class DowngradeListReferenceAssignmentRector extends \Rector\Core\Rector\A * @var int */ private const ANY = 1; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Convert the list reference assignment to its equivalent PHP 7.2 code', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Convert the list reference assignment to its equivalent PHP 7.2 code', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($string) @@ -73,19 +73,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\List_::class, \PhpParser\Node\Expr\Array_::class]; + return [List_::class, Array_::class]; } /** * @param List_|Array_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->shouldRefactor($node)) { return null; } // Get all the params passed by reference /** @var Assign $parentNode */ - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); /** @var Variable $exprVariable */ $exprVariable = $parentNode->expr; // Count number of params by ref on the right side, to remove them later on @@ -103,13 +103,13 @@ CODE_SAMPLE * @return List_|Array_|null * @param \PhpParser\Node\Expr\List_|\PhpParser\Node\Expr\Array_ $node */ - public function removeStaleParams($node, int $rightSideRemovableParamsCount) : ?\PhpParser\Node + public function removeStaleParams($node, int $rightSideRemovableParamsCount) : ?Node { $nodeItemsCount = \count($node->items); if ($rightSideRemovableParamsCount === $nodeItemsCount) { // Remove the parent Assign node /** @var Assign $parentNode */ - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); $this->removeNode($parentNode); return null; } @@ -123,15 +123,15 @@ CODE_SAMPLE */ private function shouldRefactor($node) : bool { - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); // Check it follows `list(...) = $foo` - if (!$parentNode instanceof \PhpParser\Node\Expr\Assign) { + if (!$parentNode instanceof Assign) { return \false; } if ($parentNode->var !== $node) { return \false; } - if (!$parentNode->expr instanceof \PhpParser\Node\Expr\Variable) { + if (!$parentNode->expr instanceof Variable) { return \false; } return $this->hasAnyItemByRef($node->items); @@ -150,12 +150,12 @@ CODE_SAMPLE for ($i = $listItemsCount - 1; $i >= 0; --$i) { $listItem = $listItems[$i]; // Also include null items, since they can be removed - if (!$listItem instanceof \PhpParser\Node\Expr\ArrayItem || $listItem->byRef) { + if (!$listItem instanceof ArrayItem || $listItem->byRef) { ++$count; continue; } // If it is a nested list, check if all its items are by reference - $isNested = $listItem->value instanceof \PhpParser\Node\Expr\List_ || $listItem->value instanceof \PhpParser\Node\Expr\Array_; + $isNested = $listItem->value instanceof List_ || $listItem->value instanceof Array_; if ($isNested) { /** @var List_|Array_ $nestedList */ $nestedList = $listItem->value; @@ -174,27 +174,27 @@ CODE_SAMPLE * @param (int|string)[] $nestedArrayIndexes * @return AssignRef[] */ - private function createAssignRefArrayFromListReferences(array $listItems, \PhpParser\Node\Expr\Variable $exprVariable, array $nestedArrayIndexes) : array + private function createAssignRefArrayFromListReferences(array $listItems, Variable $exprVariable, array $nestedArrayIndexes) : array { // After filtering, their original position is kept in the array $newNodes = []; foreach ($listItems as $position => $listItem) { - if (!$listItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$listItem instanceof ArrayItem) { continue; } - if ($listItem->value instanceof \PhpParser\Node\Expr\Variable && !$listItem->byRef) { + if ($listItem->value instanceof Variable && !$listItem->byRef) { continue; } // Access the key, if provided, or the position otherwise $key = $this->getArrayItemKey($listItem, $position); // Either the item is a variable, or a nested list - if ($listItem->value instanceof \PhpParser\Node\Expr\Variable) { + if ($listItem->value instanceof Variable) { /** @var Variable $itemVariable */ $itemVariable = $listItem->value; // Remove the reference in the present node $listItem->byRef = \false; // In its place, assign the value by reference on a new node - $assignVariable = new \PhpParser\Node\Expr\Variable($itemVariable->name); + $assignVariable = new Variable($itemVariable->name); $newNodes[] = $this->createAssignRefWithArrayDimFetch($assignVariable, $exprVariable, $nestedArrayIndexes, $key); continue; } @@ -233,12 +233,12 @@ CODE_SAMPLE * @param int|string $position * @return int|string */ - private function getArrayItemKey(\PhpParser\Node\Expr\ArrayItem $arrayItem, $position) + private function getArrayItemKey(ArrayItem $arrayItem, $position) { - if ($arrayItem->key instanceof \PhpParser\Node\Scalar\String_) { + if ($arrayItem->key instanceof String_) { return $arrayItem->key->value; } - if ($arrayItem->key instanceof \PhpParser\Node\Scalar\LNumber) { + if ($arrayItem->key instanceof LNumber) { return $arrayItem->key->value; } return $position; @@ -248,16 +248,16 @@ CODE_SAMPLE * @param (string|int)[] $nestedArrayIndexes The path to build nested lists * @param string|int $arrayIndex */ - private function createAssignRefWithArrayDimFetch(\PhpParser\Node\Expr\Variable $assignVariable, \PhpParser\Node\Expr\Variable $exprVariable, array $nestedArrayIndexes, $arrayIndex) : \PhpParser\Node\Expr\AssignRef + private function createAssignRefWithArrayDimFetch(Variable $assignVariable, Variable $exprVariable, array $nestedArrayIndexes, $arrayIndex) : AssignRef { $nestedExprVariable = $exprVariable; foreach ($nestedArrayIndexes as $nestedArrayIndex) { - $nestedArrayIndexDim = \PhpParser\BuilderHelpers::normalizeValue($nestedArrayIndex); - $nestedExprVariable = new \PhpParser\Node\Expr\ArrayDimFetch($nestedExprVariable, $nestedArrayIndexDim); + $nestedArrayIndexDim = BuilderHelpers::normalizeValue($nestedArrayIndex); + $nestedExprVariable = new ArrayDimFetch($nestedExprVariable, $nestedArrayIndexDim); } - $dim = \PhpParser\BuilderHelpers::normalizeValue($arrayIndex); - $arrayDimFetch = new \PhpParser\Node\Expr\ArrayDimFetch($nestedExprVariable, $dim); - return new \PhpParser\Node\Expr\AssignRef($assignVariable, $arrayDimFetch); + $dim = BuilderHelpers::normalizeValue($arrayIndex); + $arrayDimFetch = new ArrayDimFetch($nestedExprVariable, $dim); + return new AssignRef($assignVariable, $arrayDimFetch); } /** * @param array $arrayItems @@ -281,10 +281,10 @@ CODE_SAMPLE * Indicate if the item is a variable by reference, * or a nested list containing variables by reference */ - private function isItemByRef(\PhpParser\Node\Expr\ArrayItem $arrayItem, int $condition) : bool + private function isItemByRef(ArrayItem $arrayItem, int $condition) : bool { // Check if the item is a nested list/nested array destructuring - $isNested = $arrayItem->value instanceof \PhpParser\Node\Expr\List_ || $arrayItem->value instanceof \PhpParser\Node\Expr\Array_; + $isNested = $arrayItem->value instanceof List_ || $arrayItem->value instanceof Array_; if ($isNested) { // Recursive call /** @var List_|Array_ $nestedList */ @@ -295,7 +295,7 @@ CODE_SAMPLE // $condition === self::ANY return $this->hasAnyItemByRef($nestedList->items); } - if (!$arrayItem->value instanceof \PhpParser\Node\Expr\Variable) { + if (!$arrayItem->value instanceof Variable) { return \false; } return $arrayItem->byRef; diff --git a/rules/DowngradePhp73/Rector/String_/DowngradeFlexibleHeredocSyntaxRector.php b/rules/DowngradePhp73/Rector/String_/DowngradeFlexibleHeredocSyntaxRector.php index 9588f00b9a2..23a900f8971 100644 --- a/rules/DowngradePhp73/Rector/String_/DowngradeFlexibleHeredocSyntaxRector.php +++ b/rules/DowngradePhp73/Rector/String_/DowngradeFlexibleHeredocSyntaxRector.php @@ -8,20 +8,20 @@ use PhpParser\Node\Scalar\Encapsed; use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp73\Rector\String_\DowngradeFlexibleHeredocSyntaxRector\DowngradeFlexibleHeredocSyntaxRectorTest */ -final class DowngradeFlexibleHeredocSyntaxRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeFlexibleHeredocSyntaxRector extends AbstractRector { /** * @var int[] */ - private const HERENOW_DOC_KINDS = [\PhpParser\Node\Scalar\String_::KIND_HEREDOC, \PhpParser\Node\Scalar\String_::KIND_NOWDOC]; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + private const HERENOW_DOC_KINDS = [String_::KIND_HEREDOC, String_::KIND_NOWDOC]; + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove indentation from heredoc/nowdoc', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove indentation from heredoc/nowdoc', [new CodeSample(<<<'CODE_SAMPLE' $query = <<getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND); + $stringKind = $node->getAttribute(AttributeKey::KIND); if (!\in_array($stringKind, self::HERENOW_DOC_KINDS, \true)) { return null; } // skip correctly indented - $docIndentation = (string) $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::DOC_INDENTATION); + $docIndentation = (string) $node->getAttribute(AttributeKey::DOC_INDENTATION); if ($docIndentation === '') { return null; } - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::DOC_INDENTATION, ''); - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $node->setAttribute(AttributeKey::DOC_INDENTATION, ''); + $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); return $node; } } diff --git a/rules/DowngradePhp73/Tokenizer/FollowedByCommaAnalyzer.php b/rules/DowngradePhp73/Tokenizer/FollowedByCommaAnalyzer.php index 73e2b139ee3..eab4ff2eb9c 100644 --- a/rules/DowngradePhp73/Tokenizer/FollowedByCommaAnalyzer.php +++ b/rules/DowngradePhp73/Tokenizer/FollowedByCommaAnalyzer.php @@ -8,14 +8,14 @@ use Rector\Core\Util\StringUtils; use Rector\Core\ValueObject\Application\File; final class FollowedByCommaAnalyzer { - public function isFollowed(\Rector\Core\ValueObject\Application\File $file, \PhpParser\Node $node) : bool + public function isFollowed(File $file, Node $node) : bool { $oldTokens = $file->getOldTokens(); $nextTokenPosition = $node->getEndTokenPos() + 1; while (isset($oldTokens[$nextTokenPosition])) { $currentToken = $oldTokens[$nextTokenPosition]; // only space - if (\is_array($currentToken) || \Rector\Core\Util\StringUtils::isMatch($currentToken, '#\\s+#')) { + if (\is_array($currentToken) || StringUtils::isMatch($currentToken, '#\\s+#')) { ++$nextTokenPosition; continue; } diff --git a/rules/DowngradePhp74/Rector/Array_/DowngradeArraySpreadRector.php b/rules/DowngradePhp74/Rector/Array_/DowngradeArraySpreadRector.php index 1e0a1478d3b..5ed6560bb6f 100644 --- a/rules/DowngradePhp74/Rector/Array_/DowngradeArraySpreadRector.php +++ b/rules/DowngradePhp74/Rector/Array_/DowngradeArraySpreadRector.php @@ -9,14 +9,14 @@ use PHPStan\Analyser\Scope; use Rector\Core\Rector\AbstractScopeAwareRector; use Rector\DowngradePhp81\NodeAnalyzer\ArraySpreadAnalyzer; use Rector\DowngradePhp81\NodeFactory\ArrayMergeFromArraySpreadFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/spread_operator_for_array * * @see \Rector\Tests\DowngradePhp74\Rector\Array_\DowngradeArraySpreadRector\DowngradeArraySpreadRectorTest */ -final class DowngradeArraySpreadRector extends \Rector\Core\Rector\AbstractScopeAwareRector +final class DowngradeArraySpreadRector extends AbstractScopeAwareRector { /** * @readonly @@ -28,14 +28,14 @@ final class DowngradeArraySpreadRector extends \Rector\Core\Rector\AbstractScope * @var \Rector\DowngradePhp81\NodeAnalyzer\ArraySpreadAnalyzer */ private $arraySpreadAnalyzer; - public function __construct(\Rector\DowngradePhp81\NodeFactory\ArrayMergeFromArraySpreadFactory $arrayMergeFromArraySpreadFactory, \Rector\DowngradePhp81\NodeAnalyzer\ArraySpreadAnalyzer $arraySpreadAnalyzer) + public function __construct(ArrayMergeFromArraySpreadFactory $arrayMergeFromArraySpreadFactory, ArraySpreadAnalyzer $arraySpreadAnalyzer) { $this->arrayMergeFromArraySpreadFactory = $arrayMergeFromArraySpreadFactory; $this->arraySpreadAnalyzer = $arraySpreadAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace array spread with array_merge function', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace array spread with array_merge function', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -73,18 +73,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Array_::class]; + return [Array_::class]; } /** * @param Array_ $node */ - public function refactorWithScope(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : ?\PhpParser\Node + public function refactorWithScope(Node $node, Scope $scope) : ?Node { if (!$this->arraySpreadAnalyzer->isArrayWithUnpack($node)) { return null; } - $shouldIncrement = (bool) $this->betterNodeFinder->findFirstNext($node, function (\PhpParser\Node $subNode) : bool { - if (!$subNode instanceof \PhpParser\Node\Expr\Array_) { + $shouldIncrement = (bool) $this->betterNodeFinder->findFirstNext($node, function (Node $subNode) : bool { + if (!$subNode instanceof Array_) { return \false; } return $this->arraySpreadAnalyzer->isArrayWithUnpack($subNode); diff --git a/rules/DowngradePhp74/Rector/ArrowFunction/ArrowFunctionToAnonymousFunctionRector.php b/rules/DowngradePhp74/Rector/ArrowFunction/ArrowFunctionToAnonymousFunctionRector.php index 9b36475f73b..b462685d603 100644 --- a/rules/DowngradePhp74/Rector/ArrowFunction/ArrowFunctionToAnonymousFunctionRector.php +++ b/rules/DowngradePhp74/Rector/ArrowFunction/ArrowFunctionToAnonymousFunctionRector.php @@ -9,27 +9,27 @@ use PhpParser\Node\Expr\Closure; use PhpParser\Node\Stmt\Return_; use Rector\Core\Rector\AbstractRector; use Rector\Php72\NodeFactory\AnonymousFunctionFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/functions.arrow.php * * @see \Rector\Tests\DowngradePhp74\Rector\ArrowFunction\ArrowFunctionToAnonymousFunctionRector\ArrowFunctionToAnonymousFunctionRectorTest */ -final class ArrowFunctionToAnonymousFunctionRector extends \Rector\Core\Rector\AbstractRector +final class ArrowFunctionToAnonymousFunctionRector extends AbstractRector { /** * @readonly * @var \Rector\Php72\NodeFactory\AnonymousFunctionFactory */ private $anonymousFunctionFactory; - public function __construct(\Rector\Php72\NodeFactory\AnonymousFunctionFactory $anonymousFunctionFactory) + public function __construct(AnonymousFunctionFactory $anonymousFunctionFactory) { $this->anonymousFunctionFactory = $anonymousFunctionFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace arrow functions with anonymous functions', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace arrow functions with anonymous functions', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -58,14 +58,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\ArrowFunction::class]; + return [ArrowFunction::class]; } /** * @param ArrowFunction $node */ - public function refactor(\PhpParser\Node $node) : \PhpParser\Node\Expr\Closure + public function refactor(Node $node) : Closure { - $stmts = [new \PhpParser\Node\Stmt\Return_($node->expr)]; + $stmts = [new Return_($node->expr)]; return $this->anonymousFunctionFactory->create($node->params, $stmts, $node->returnType, $node->static); } } diff --git a/rules/DowngradePhp74/Rector/ClassMethod/DowngradeContravariantArgumentTypeRector.php b/rules/DowngradePhp74/Rector/ClassMethod/DowngradeContravariantArgumentTypeRector.php index a192661b4a2..376167ff14b 100644 --- a/rules/DowngradePhp74/Rector/ClassMethod/DowngradeContravariantArgumentTypeRector.php +++ b/rules/DowngradePhp74/Rector/ClassMethod/DowngradeContravariantArgumentTypeRector.php @@ -18,14 +18,14 @@ use Rector\Core\ValueObject\MethodName; use ReflectionMethod; use ReflectionNamedType; use ReflectionParameter; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/language.oop5.variance.php#language.oop5.variance.contravariance * * @see \Rector\Tests\DowngradePhp74\Rector\ClassMethod\DowngradeContravariantArgumentTypeRector\DowngradeContravariantArgumentTypeRectorTest */ -final class DowngradeContravariantArgumentTypeRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeContravariantArgumentTypeRector extends AbstractRector { /** * @readonly @@ -42,7 +42,7 @@ final class DowngradeContravariantArgumentTypeRector extends \Rector\Core\Rector * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\Core\NodeAnalyzer\ParamAnalyzer $paramAnalyzer, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(PhpDocTypeChanger $phpDocTypeChanger, ParamAnalyzer $paramAnalyzer, ReflectionResolver $reflectionResolver) { $this->phpDocTypeChanger = $phpDocTypeChanger; $this->paramAnalyzer = $paramAnalyzer; @@ -53,11 +53,11 @@ final class DowngradeContravariantArgumentTypeRector extends \Rector\Core\Rector */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class]; + return [ClassMethod::class, Function_::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove contravariant argument type declarations', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove contravariant argument type declarations', [new CodeSample(<<<'CODE_SAMPLE' class ParentType {} class ChildType extends ParentType {} @@ -101,7 +101,7 @@ CODE_SAMPLE /** * @param ClassMethod|Function_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->params === []) { return null; @@ -114,7 +114,7 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike */ - private function isNullableParam(\PhpParser\Node\Param $param, $functionLike) : bool + private function isNullableParam(Param $param, $functionLike) : bool { if ($param->variadic) { return \false; @@ -123,11 +123,11 @@ CODE_SAMPLE return \false; } // Don't consider for Union types - if ($param->type instanceof \PhpParser\Node\UnionType) { + if ($param->type instanceof UnionType) { return \false; } // Contravariant arguments are supported for __construct - if ($this->isName($functionLike, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if ($this->isName($functionLike, MethodName::CONSTRUCT)) { return \false; } // Check if the type is different from the one declared in some ancestor @@ -136,10 +136,10 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike */ - private function getDifferentParamTypeFromAncestorClass(\PhpParser\Node\Param $param, $functionLike) : ?string + private function getDifferentParamTypeFromAncestorClass(Param $param, $functionLike) : ?string { $classReflection = $this->reflectionResolver->resolveClassReflection($functionLike); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return null; } $paramName = $this->getName($param); @@ -163,7 +163,7 @@ CODE_SAMPLE $parentClassReflections = \array_merge($classReflection->getParents(), $classReflection->getInterfaces()); foreach ($parentClassReflections as $parentClassReflection) { $parentReflectionMethod = $this->resolveParentReflectionMethod($parentClassReflection, $methodName); - if (!$parentReflectionMethod instanceof \ReflectionMethod) { + if (!$parentReflectionMethod instanceof ReflectionMethod) { continue; } $differentAncestorParamTypeName = $this->getDifferentParamTypeFromReflectionMethod($parentReflectionMethod, $paramName, $paramTypeName); @@ -173,7 +173,7 @@ CODE_SAMPLE } return null; } - private function resolveParentReflectionMethod(\PHPStan\Reflection\ClassReflection $classReflection, string $methodName) : ?\ReflectionMethod + private function resolveParentReflectionMethod(ClassReflection $classReflection, string $methodName) : ?ReflectionMethod { if (!$classReflection->hasMethod($methodName)) { return null; @@ -185,7 +185,7 @@ CODE_SAMPLE // Find the param we're looking for return $nativeReflection->getMethod($methodName); } - private function getDifferentParamTypeFromReflectionMethod(\ReflectionMethod $reflectionMethod, string $paramName, string $paramTypeName) : ?string + private function getDifferentParamTypeFromReflectionMethod(ReflectionMethod $reflectionMethod, string $paramName, string $paramTypeName) : ?string { /** @var ReflectionParameter[] $parentReflectionMethodParams */ $parentReflectionMethodParams = $reflectionMethod->getParameters(); @@ -200,7 +200,7 @@ CODE_SAMPLE * If the type is null, we don't have enough information * to check if they are different. Then do nothing */ - if (!$reflectionParamType instanceof \ReflectionNamedType) { + if (!$reflectionParamType instanceof ReflectionNamedType) { continue; } if ($reflectionParamType->getName() !== $paramTypeName) { @@ -214,7 +214,7 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike */ - private function refactorParam(\PhpParser\Node\Param $param, $functionLike) : void + private function refactorParam(Param $param, $functionLike) : void { if (!$this->isNullableParam($param, $functionLike)) { return; @@ -225,7 +225,7 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike */ - private function decorateWithDocBlock($functionLike, \PhpParser\Node\Param $param) : void + private function decorateWithDocBlock($functionLike, Param $param) : void { if ($param->type === null) { return; diff --git a/rules/DowngradePhp74/Rector/ClassMethod/DowngradeCovariantReturnTypeRector.php b/rules/DowngradePhp74/Rector/ClassMethod/DowngradeCovariantReturnTypeRector.php index 67cf71b5d5d..beda0a4b50d 100644 --- a/rules/DowngradePhp74/Rector/ClassMethod/DowngradeCovariantReturnTypeRector.php +++ b/rules/DowngradePhp74/Rector/ClassMethod/DowngradeCovariantReturnTypeRector.php @@ -24,14 +24,14 @@ use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType; use RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/migration74.new-features.php#migration74.new-features.core.type-variance * * @see \Rector\Tests\DowngradePhp74\Rector\ClassMethod\DowngradeCovariantReturnTypeRector\DowngradeCovariantReturnTypeRectorTest */ -final class DowngradeCovariantReturnTypeRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeCovariantReturnTypeRector extends AbstractRector { /** * @readonly @@ -53,16 +53,16 @@ final class DowngradeCovariantReturnTypeRector extends \Rector\Core\Rector\Abstr * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller $privatesCaller, \Rector\DeadCode\PhpDoc\TagRemover\ReturnTagRemover $returnTagRemover, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(PhpDocTypeChanger $phpDocTypeChanger, PrivatesCaller $privatesCaller, ReturnTagRemover $returnTagRemover, ReflectionResolver $reflectionResolver) { $this->phpDocTypeChanger = $phpDocTypeChanger; $this->privatesCaller = $privatesCaller; $this->returnTagRemover = $returnTagRemover; $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Make method return same type as parent', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Make method return same type as parent', [new CodeSample(<<<'CODE_SAMPLE' class ParentType {} class ChildType extends ParentType {} @@ -108,36 +108,36 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->returnType === null) { return null; } $parentReturnType = $this->resolveDifferentAncestorReturnType($node, $node->returnType); - if ($parentReturnType instanceof \PHPStan\Type\MixedType) { + if ($parentReturnType instanceof MixedType) { return null; } // The return type name could either be a classname, without the leading "\", // or one among the reserved identifiers ("static", "self", "iterable", etc) // To find out which is the case, check if this name exists as a class - $parentReturnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($parentReturnType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN); - if (!$parentReturnTypeNode instanceof \PhpParser\Node) { + $parentReturnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($parentReturnType, TypeKind::RETURN); + if (!$parentReturnTypeNode instanceof Node) { return null; } // Make it nullable? - if ($node->returnType instanceof \PhpParser\Node\NullableType && !$parentReturnTypeNode instanceof \PhpParser\Node\ComplexType) { - $parentReturnTypeNode = new \PhpParser\Node\NullableType($parentReturnTypeNode); + if ($node->returnType instanceof NullableType && !$parentReturnTypeNode instanceof ComplexType) { + $parentReturnTypeNode = new NullableType($parentReturnTypeNode); } // skip if type is already set if ($this->nodeComparator->areNodesEqual($parentReturnTypeNode, $node->returnType)) { return null; } - if ($parentReturnType instanceof \PHPStan\Type\ThisType) { + if ($parentReturnType instanceof ThisType) { return null; } // Add the docblock before changing the type @@ -148,27 +148,27 @@ CODE_SAMPLE /** * @param \PhpParser\Node\UnionType|\PhpParser\Node\NullableType|\PhpParser\Node\Name|\PhpParser\Node\Identifier|\PhpParser\Node\ComplexType $returnTypeNode */ - private function resolveDifferentAncestorReturnType(\PhpParser\Node\Stmt\ClassMethod $classMethod, $returnTypeNode) : \PHPStan\Type\Type + private function resolveDifferentAncestorReturnType(ClassMethod $classMethod, $returnTypeNode) : Type { $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { - return new \PHPStan\Type\MixedType(); + if (!$classReflection instanceof ClassReflection) { + return new MixedType(); } - if ($returnTypeNode instanceof \PhpParser\Node\UnionType) { - return new \PHPStan\Type\MixedType(); + if ($returnTypeNode instanceof UnionType) { + return new MixedType(); } - $bareReturnType = $returnTypeNode instanceof \PhpParser\Node\NullableType ? $returnTypeNode->type : $returnTypeNode; + $bareReturnType = $returnTypeNode instanceof NullableType ? $returnTypeNode->type : $returnTypeNode; $returnType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($bareReturnType); $methodName = $this->getName($classMethod); /** @var ClassReflection[] $parentClassesAndInterfaces */ $parentClassesAndInterfaces = \array_merge($classReflection->getParents(), $classReflection->getInterfaces()); return $this->resolveMatchingReturnType($parentClassesAndInterfaces, $methodName, $classMethod, $returnType); } - private function addDocBlockReturn(\PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function addDocBlockReturn(ClassMethod $classMethod) : void { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); // keep return type if already set one - if (!$phpDocInfo->getReturnType() instanceof \PHPStan\Type\MixedType) { + if (!$phpDocInfo->getReturnType() instanceof MixedType) { return; } /** @var Node $returnType */ @@ -180,25 +180,25 @@ CODE_SAMPLE /** * @param ClassReflection[] $parentClassesAndInterfaces */ - private function resolveMatchingReturnType(array $parentClassesAndInterfaces, string $methodName, \PhpParser\Node\Stmt\ClassMethod $classMethod, \PHPStan\Type\Type $returnType) : \PHPStan\Type\Type + private function resolveMatchingReturnType(array $parentClassesAndInterfaces, string $methodName, ClassMethod $classMethod, Type $returnType) : Type { foreach ($parentClassesAndInterfaces as $parentClassAndInterface) { $parentClassAndInterfaceHasMethod = $parentClassAndInterface->hasMethod($methodName); if (!$parentClassAndInterfaceHasMethod) { continue; } - $classMethodScope = $classMethod->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $classMethodScope = $classMethod->getAttribute(AttributeKey::SCOPE); $parameterMethodReflection = $parentClassAndInterface->getMethod($methodName, $classMethodScope); - if (!$parameterMethodReflection instanceof \PHPStan\Reflection\Php\PhpMethodReflection) { + if (!$parameterMethodReflection instanceof PhpMethodReflection) { continue; } /** @var Type $parentReturnType */ $parentReturnType = $this->privatesCaller->callPrivateMethod($parameterMethodReflection, 'getReturnType', []); // skip "parent" reference if correct - if ($returnType instanceof \Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType && $parentReturnType->accepts($returnType, \true)->yes()) { + if ($returnType instanceof ParentStaticType && $parentReturnType->accepts($returnType, \true)->yes()) { continue; } - if ($parentReturnType instanceof \PHPStan\Type\StaticType && $returnType->accepts($parentReturnType, \true)->yes()) { + if ($parentReturnType instanceof StaticType && $returnType->accepts($parentReturnType, \true)->yes()) { continue; } if ($parentReturnType->equals($returnType)) { @@ -207,6 +207,6 @@ CODE_SAMPLE // This is an ancestor class with a different return type return $parentReturnType; } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } } diff --git a/rules/DowngradePhp74/Rector/Coalesce/DowngradeNullCoalescingOperatorRector.php b/rules/DowngradePhp74/Rector/Coalesce/DowngradeNullCoalescingOperatorRector.php index 42903bb797c..a82d1757c3a 100644 --- a/rules/DowngradePhp74/Rector/Coalesce/DowngradeNullCoalescingOperatorRector.php +++ b/rules/DowngradePhp74/Rector/Coalesce/DowngradeNullCoalescingOperatorRector.php @@ -8,17 +8,17 @@ use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\AssignOp\Coalesce as AssignCoalesce; use PhpParser\Node\Expr\BinaryOp\Coalesce; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/null_coalesce_equal_operator * @see \Rector\Tests\DowngradePhp74\Rector\Coalesce\DowngradeNullCoalescingOperatorRector\DowngradeNullCoalescingOperatorRectorTest */ -final class DowngradeNullCoalescingOperatorRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeNullCoalescingOperatorRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove null coalescing operator ??=', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove null coalescing operator ??=', [new CodeSample(<<<'CODE_SAMPLE' $array = []; $array['user_id'] ??= 'value'; CODE_SAMPLE @@ -33,13 +33,13 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\AssignOp\Coalesce::class]; + return [AssignCoalesce::class]; } /** * @param AssignCoalesce $node */ - public function refactor(\PhpParser\Node $node) : \PhpParser\Node\Expr\Assign + public function refactor(Node $node) : Assign { - return new \PhpParser\Node\Expr\Assign($node->var, new \PhpParser\Node\Expr\BinaryOp\Coalesce($node->var, $node->expr)); + return new Assign($node->var, new Coalesce($node->var, $node->expr)); } } diff --git a/rules/DowngradePhp74/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector.php b/rules/DowngradePhp74/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector.php index 604b5b8e6aa..030e3367de4 100644 --- a/rules/DowngradePhp74/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector.php +++ b/rules/DowngradePhp74/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector.php @@ -8,16 +8,16 @@ use PhpParser\Node\Arg; use PhpParser\Node\Expr\Array_; use PhpParser\Node\Expr\FuncCall; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp74\Rector\FuncCall\DowngradeArrayMergeCallWithoutArgumentsRector\DowngradeArrayMergeCallWithoutArgumentsRectorTest */ -final class DowngradeArrayMergeCallWithoutArgumentsRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeArrayMergeCallWithoutArgumentsRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add missing param to `array_merge` and `array_merge_recursive`', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add missing param to `array_merge` and `array_merge_recursive`', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -44,20 +44,20 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->shouldRefactor($node)) { return null; } - $node->args = [new \PhpParser\Node\Arg(new \PhpParser\Node\Expr\Array_())]; + $node->args = [new Arg(new Array_())]; return $node; } - private function shouldRefactor(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function shouldRefactor(FuncCall $funcCall) : bool { if (!$this->isNames($funcCall, ['array_merge', 'array_merge_recursive'])) { return \false; diff --git a/rules/DowngradePhp74/Rector/FuncCall/DowngradeStripTagsCallWithArrayRector.php b/rules/DowngradePhp74/Rector/FuncCall/DowngradeStripTagsCallWithArrayRector.php index 8c3781c7d8a..817058b6027 100644 --- a/rules/DowngradePhp74/Rector/FuncCall/DowngradeStripTagsCallWithArrayRector.php +++ b/rules/DowngradePhp74/Rector/FuncCall/DowngradeStripTagsCallWithArrayRector.php @@ -21,25 +21,25 @@ use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; use Rector\Naming\Naming\VariableNaming; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp74\Rector\FuncCall\DowngradeStripTagsCallWithArrayRector\DowngradeStripTagsCallWithArrayRectorTest */ -final class DowngradeStripTagsCallWithArrayRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeStripTagsCallWithArrayRector extends AbstractRector { /** * @readonly * @var \Rector\Naming\Naming\VariableNaming */ private $variableNaming; - public function __construct(\Rector\Naming\Naming\VariableNaming $variableNaming) + public function __construct(VariableNaming $variableNaming) { $this->variableNaming = $variableNaming; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Convert 2nd param to `strip_tags` from array to string', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Convert 2nd param to `strip_tags` from array to string', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($string) @@ -81,12 +81,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkipFuncCall($node)) { return null; @@ -94,28 +94,28 @@ CODE_SAMPLE /** @var Arg $secondArg */ $secondArg = $node->args[1]; $allowableTagsParam = $secondArg->value; - if ($allowableTagsParam instanceof \PhpParser\Node\Expr\Array_) { + if ($allowableTagsParam instanceof Array_) { // If it is an array, convert it to string $newExpr = $this->createArrayFromString($allowableTagsParam); - } elseif ($allowableTagsParam instanceof \PhpParser\Node\Expr\Variable || $allowableTagsParam instanceof \PhpParser\Node\Expr\PropertyFetch || $allowableTagsParam instanceof \PhpParser\Node\Expr\ConstFetch || $allowableTagsParam instanceof \PhpParser\Node\Expr\ClassConstFetch) { + } elseif ($allowableTagsParam instanceof Variable || $allowableTagsParam instanceof PropertyFetch || $allowableTagsParam instanceof ConstFetch || $allowableTagsParam instanceof ClassConstFetch) { // If it is a variable or a const (other than null), add logic to maybe convert to string $newExpr = $this->createIsArrayTernaryFromExpression($allowableTagsParam); } else { // It is a function or method call, ternary or coalesce, or any other: // Assign the value to a variable // First obtain a variable name that does not exist in the node (to not override its value) - $variableName = $this->variableNaming->resolveFromFuncCallFirstArgumentWithSuffix($node, 'AllowableTags', 'allowableTags', $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE)); + $variableName = $this->variableNaming->resolveFromFuncCallFirstArgumentWithSuffix($node, 'AllowableTags', 'allowableTags', $node->getAttribute(AttributeKey::SCOPE)); // Assign the value to the variable - $newVariable = new \PhpParser\Node\Expr\Variable($variableName); - $this->nodesToAddCollector->addNodeBeforeNode(new \PhpParser\Node\Expr\Assign($newVariable, $allowableTagsParam), $node, $this->file->getSmartFileInfo()); + $newVariable = new Variable($variableName); + $this->nodesToAddCollector->addNodeBeforeNode(new Assign($newVariable, $allowableTagsParam), $node, $this->file->getSmartFileInfo()); // Apply refactor on the variable $newExpr = $this->createIsArrayTernaryFromExpression($newVariable); } // Replace the arg with a new one - \array_splice($node->args, 1, 1, [new \PhpParser\Node\Arg($newExpr)]); + \array_splice($node->args, 1, 1, [new Arg($newExpr)]); return $node; } - private function shouldSkipFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function shouldSkipFuncCall(FuncCall $funcCall) : bool { if (!$this->isName($funcCall, 'strip_tags')) { return \true; @@ -127,20 +127,20 @@ CODE_SAMPLE if (!isset($funcCall->args[1])) { return \true; } - if (!$funcCall->args[1] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[1] instanceof Arg) { return \true; } // Process anything other than String and null (eg: variables, function calls) $allowableTagsParam = $funcCall->args[1]->value; // Skip for string - if ($allowableTagsParam instanceof \PhpParser\Node\Scalar\String_) { + if ($allowableTagsParam instanceof String_) { return \true; } // already refactored - if ($allowableTagsParam instanceof \PhpParser\Node\Expr\Ternary && $allowableTagsParam->if !== null) { + if ($allowableTagsParam instanceof Ternary && $allowableTagsParam->if !== null) { return \true; } - if ($allowableTagsParam instanceof \PhpParser\Node\Expr\BinaryOp\Concat) { + if ($allowableTagsParam instanceof Concat) { return \true; } // Skip for null @@ -150,21 +150,21 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Expr\Array_|\PhpParser\Node\Expr\Variable|\PhpParser\Node\Expr\PropertyFetch|\PhpParser\Node\Expr\ConstFetch|\PhpParser\Node\Expr\ClassConstFetch $expr */ - private function createArrayFromString($expr) : \PhpParser\Node\Expr\BinaryOp\Concat + private function createArrayFromString($expr) : Concat { - $args = [new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\String_('><')), new \PhpParser\Node\Arg($expr)]; - $implodeFuncCall = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('implode'), $args); - $concat = new \PhpParser\Node\Expr\BinaryOp\Concat(new \PhpParser\Node\Scalar\String_('<'), $implodeFuncCall); - return new \PhpParser\Node\Expr\BinaryOp\Concat($concat, new \PhpParser\Node\Scalar\String_('>')); + $args = [new Arg(new String_('><')), new Arg($expr)]; + $implodeFuncCall = new FuncCall(new Name('implode'), $args); + $concat = new Concat(new String_('<'), $implodeFuncCall); + return new Concat($concat, new String_('>')); } /** * @param \PhpParser\Node\Expr\Variable|\PhpParser\Node\Expr\PropertyFetch|\PhpParser\Node\Expr\ConstFetch|\PhpParser\Node\Expr\ClassConstFetch $expr */ - private function createIsArrayTernaryFromExpression($expr) : \PhpParser\Node\Expr\Ternary + private function createIsArrayTernaryFromExpression($expr) : Ternary { - $isArrayFuncCall = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('is_array'), [new \PhpParser\Node\Arg($expr)]); - $nullNotIdentical = new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, $this->nodeFactory->createNull()); - $booleanAnd = new \PhpParser\Node\Expr\BinaryOp\BooleanAnd($nullNotIdentical, $isArrayFuncCall); - return new \PhpParser\Node\Expr\Ternary($booleanAnd, $this->createArrayFromString($expr), $expr); + $isArrayFuncCall = new FuncCall(new Name('is_array'), [new Arg($expr)]); + $nullNotIdentical = new NotIdentical($expr, $this->nodeFactory->createNull()); + $booleanAnd = new BooleanAnd($nullNotIdentical, $isArrayFuncCall); + return new Ternary($booleanAnd, $this->createArrayFromString($expr), $expr); } } diff --git a/rules/DowngradePhp74/Rector/Identical/DowngradeFreadFwriteFalsyToNegationRector.php b/rules/DowngradePhp74/Rector/Identical/DowngradeFreadFwriteFalsyToNegationRector.php index c25b633d828..d738c38fba7 100644 --- a/rules/DowngradePhp74/Rector/Identical/DowngradeFreadFwriteFalsyToNegationRector.php +++ b/rules/DowngradePhp74/Rector/Identical/DowngradeFreadFwriteFalsyToNegationRector.php @@ -9,20 +9,20 @@ use PhpParser\Node\Expr\BinaryOp\Identical; use PhpParser\Node\Expr\BooleanNot; use PhpParser\Node\Expr\FuncCall; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp74\Rector\Identical\DowngradeFreadFwriteFalsyToNegationRector\DowngradeFreadFwriteFalsyToNegationRectorTest */ -final class DowngradeFreadFwriteFalsyToNegationRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeFreadFwriteFalsyToNegationRector extends AbstractRector { /** * @var string[] */ private const FUNC_FREAD_FWRITE = ['fread', 'fwrite']; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes fread() or fwrite() compare to false to negation check', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes fread() or fwrite() compare to false to negation check', [new CodeSample(<<<'CODE_SAMPLE' fread($handle, $length) === false; fwrite($fp, '1') === false; CODE_SAMPLE @@ -37,28 +37,28 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\Identical::class]; + return [Identical::class]; } /** * @param Identical $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $compareValue = $this->getCompareValue($node); - if (!$compareValue instanceof \PhpParser\Node\Expr) { + if (!$compareValue instanceof Expr) { return null; } if (!$this->valueResolver->isFalse($compareValue)) { return null; } - return new \PhpParser\Node\Expr\BooleanNot($this->getFunction($node)); + return new BooleanNot($this->getFunction($node)); } - private function getCompareValue(\PhpParser\Node\Expr\BinaryOp\Identical $identical) : ?\PhpParser\Node\Expr + private function getCompareValue(Identical $identical) : ?Expr { - if ($identical->left instanceof \PhpParser\Node\Expr\FuncCall && $this->isNames($identical->left, self::FUNC_FREAD_FWRITE)) { + if ($identical->left instanceof FuncCall && $this->isNames($identical->left, self::FUNC_FREAD_FWRITE)) { return $identical->right; } - if (!$identical->right instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$identical->right instanceof FuncCall) { return null; } if (!$this->isNames($identical->right, self::FUNC_FREAD_FWRITE)) { @@ -66,10 +66,10 @@ CODE_SAMPLE } return $identical->left; } - private function getFunction(\PhpParser\Node\Expr\BinaryOp\Identical $identical) : \PhpParser\Node\Expr\FuncCall + private function getFunction(Identical $identical) : FuncCall { /** @var FuncCall $funcCall */ - $funcCall = $identical->left instanceof \PhpParser\Node\Expr\FuncCall ? $identical->left : $identical->right; + $funcCall = $identical->left instanceof FuncCall ? $identical->left : $identical->right; return $funcCall; } } diff --git a/rules/DowngradePhp74/Rector/Interface_/DowngradePreviouslyImplementedInterfaceRector.php b/rules/DowngradePhp74/Rector/Interface_/DowngradePreviouslyImplementedInterfaceRector.php index fa0b6d20f58..ccd4d725713 100644 --- a/rules/DowngradePhp74/Rector/Interface_/DowngradePreviouslyImplementedInterfaceRector.php +++ b/rules/DowngradePhp74/Rector/Interface_/DowngradePreviouslyImplementedInterfaceRector.php @@ -8,25 +8,25 @@ use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\Stmt\Interface_; use Rector\Core\Rector\AbstractRector; use Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp74\Rector\Interface_\DowngradePreviouslyImplementedInterfaceRector\DowngradePreviouslyImplementedInterfaceRectorTest */ -final class DowngradePreviouslyImplementedInterfaceRector extends \Rector\Core\Rector\AbstractRector +final class DowngradePreviouslyImplementedInterfaceRector extends AbstractRector { /** * @readonly * @var \Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer */ private $familyRelationsAnalyzer; - public function __construct(\Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer $familyRelationsAnalyzer) + public function __construct(FamilyRelationsAnalyzer $familyRelationsAnalyzer) { $this->familyRelationsAnalyzer = $familyRelationsAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade previously implemented interface', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade previously implemented interface', [new CodeSample(<<<'CODE_SAMPLE' interface ContainerExceptionInterface extends Throwable { } @@ -51,12 +51,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Interface_::class]; + return [Interface_::class]; } /** * @param Interface_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $extends = $node->extends; if ($extends === []) { @@ -68,7 +68,7 @@ CODE_SAMPLE $collectInterfaces = []; $isCleaned = \false; foreach ($extends as $key => $extend) { - if (!$extend instanceof \PhpParser\Node\Name\FullyQualified) { + if (!$extend instanceof FullyQualified) { continue; } if (\in_array($extend->toString(), $collectInterfaces, \true)) { diff --git a/rules/DowngradePhp74/Rector/LNumber/DowngradeNumericLiteralSeparatorRector.php b/rules/DowngradePhp74/Rector/LNumber/DowngradeNumericLiteralSeparatorRector.php index 5abf8ade895..70184368f53 100644 --- a/rules/DowngradePhp74/Rector/LNumber/DowngradeNumericLiteralSeparatorRector.php +++ b/rules/DowngradePhp74/Rector/LNumber/DowngradeNumericLiteralSeparatorRector.php @@ -8,18 +8,18 @@ use PhpParser\Node\Scalar\DNumber; use PhpParser\Node\Scalar\LNumber; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/numeric_literal_separator * * @see \Rector\Tests\DowngradePhp74\Rector\LNumber\DowngradeNumericLiteralSeparatorRector\DowngradeNumericLiteralSeparatorRectorTest */ -final class DowngradeNumericLiteralSeparatorRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeNumericLiteralSeparatorRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove "_" as thousands separator in numbers', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove "_" as thousands separator in numbers', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -46,14 +46,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Scalar\LNumber::class, \PhpParser\Node\Scalar\DNumber::class]; + return [LNumber::class, DNumber::class]; } /** * @param LNumber|DNumber $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $rawValue = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::RAW_VALUE); + $rawValue = $node->getAttribute(AttributeKey::RAW_VALUE); if ($this->shouldSkip($node, $rawValue)) { return null; } @@ -61,7 +61,7 @@ CODE_SAMPLE return null; } // trigger reprint - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); return $node; } /** @@ -74,9 +74,9 @@ CODE_SAMPLE return \true; } // "_" notation can be applied to decimal numbers only - if ($node instanceof \PhpParser\Node\Scalar\LNumber) { - $numberKind = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND); - if ($numberKind !== \PhpParser\Node\Scalar\LNumber::KIND_DEC) { + if ($node instanceof LNumber) { + $numberKind = $node->getAttribute(AttributeKey::KIND); + if ($numberKind !== LNumber::KIND_DEC) { return \true; } } diff --git a/rules/DowngradePhp74/Rector/MethodCall/DowngradeReflectionGetTypeRector.php b/rules/DowngradePhp74/Rector/MethodCall/DowngradeReflectionGetTypeRector.php index 51236970b87..23ce26d73c9 100644 --- a/rules/DowngradePhp74/Rector/MethodCall/DowngradeReflectionGetTypeRector.php +++ b/rules/DowngradePhp74/Rector/MethodCall/DowngradeReflectionGetTypeRector.php @@ -12,16 +12,16 @@ use PhpParser\Node\Scalar\String_; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp74\Rector\MethodCall\DowngradeReflectionGetTypeRector\DowngradeReflectionGetTypeRectorTest */ -final class DowngradeReflectionGetTypeRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeReflectionGetTypeRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade reflection $refleciton->getType() method call', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade reflection $refleciton->getType() method call', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(ReflectionProperty $reflectionProperty) @@ -54,27 +54,27 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node->name, 'getType')) { return null; } - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('ReflectionProperty'))) { + if (!$this->isObjectType($node->var, new ObjectType('ReflectionProperty'))) { return null; } - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\Expr\Instanceof_) { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof Instanceof_) { return null; } - $args = [new \PhpParser\Node\Arg($node->var), new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\String_('getType'))]; - $ternary = new \PhpParser\Node\Expr\Ternary($this->nodeFactory->createFuncCall('method_exists', $args), $node, $this->nodeFactory->createNull()); - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\Expr\Ternary) { + $args = [new Arg($node->var), new Arg(new String_('getType'))]; + $ternary = new Ternary($this->nodeFactory->createFuncCall('method_exists', $args), $node, $this->nodeFactory->createNull()); + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Ternary) { return $ternary; } if (!$this->nodeComparator->areNodesEqual($parent, $ternary)) { diff --git a/rules/DowngradePhp74/Rector/Property/DowngradeTypedPropertyRector.php b/rules/DowngradePhp74/Rector/Property/DowngradeTypedPropertyRector.php index d8cfc07eb65..14777d6079b 100644 --- a/rules/DowngradePhp74/Rector/Property/DowngradeTypedPropertyRector.php +++ b/rules/DowngradePhp74/Rector/Property/DowngradeTypedPropertyRector.php @@ -9,19 +9,19 @@ use PhpParser\Node\NullableType; use PhpParser\Node\Stmt\Property; use Rector\CodeQuality\NodeFactory\PropertyTypeDecorator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp74\Rector\Property\DowngradeTypedPropertyRector\DowngradeTypedPropertyRectorTest */ -final class DowngradeTypedPropertyRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeTypedPropertyRector extends AbstractRector { /** * @readonly * @var \Rector\CodeQuality\NodeFactory\PropertyTypeDecorator */ private $propertyTypeDecorator; - public function __construct(\Rector\CodeQuality\NodeFactory\PropertyTypeDecorator $propertyTypeDecorator) + public function __construct(PropertyTypeDecorator $propertyTypeDecorator) { $this->propertyTypeDecorator = $propertyTypeDecorator; } @@ -30,11 +30,11 @@ final class DowngradeTypedPropertyRector extends \Rector\Core\Rector\AbstractRec */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes property type definition from type definitions to `@var` annotations.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes property type definition from type definitions to `@var` annotations.', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { private string $property; @@ -54,13 +54,13 @@ CODE_SAMPLE /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->type === null) { return null; } $default = $node->props[0]->default; - if ($node->type instanceof \PhpParser\Node\NullableType && $default instanceof \PhpParser\Node\Expr && $this->valueResolver->isNull($default)) { + if ($node->type instanceof NullableType && $default instanceof Expr && $this->valueResolver->isNull($default)) { $node->props[0]->default = null; } $this->propertyTypeDecorator->decoratePropertyWithDocBlock($node, $node->type); diff --git a/rules/DowngradePhp80/NodeAnalyzer/EnumAnalyzer.php b/rules/DowngradePhp80/NodeAnalyzer/EnumAnalyzer.php index 6d8bca03201..c822b66b4ed 100644 --- a/rules/DowngradePhp80/NodeAnalyzer/EnumAnalyzer.php +++ b/rules/DowngradePhp80/NodeAnalyzer/EnumAnalyzer.php @@ -27,19 +27,19 @@ final class EnumAnalyzer * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\Core\PhpParser\AstResolver $astResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(AstResolver $astResolver, NodeTypeResolver $nodeTypeResolver) { $this->astResolver = $astResolver; $this->nodeTypeResolver = $nodeTypeResolver; } - public function resolveType(\PHPStan\Reflection\ClassReflection $classReflection) : ?\PhpParser\Node\Identifier + public function resolveType(ClassReflection $classReflection) : ?Identifier { $class = $this->astResolver->resolveClassFromClassReflection($classReflection, $classReflection->getName()); - if (!$class instanceof \PhpParser\Node\Stmt\Enum_) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$class instanceof Enum_) { + throw new ShouldNotHappenException(); } $scalarType = $class->scalarType; - if ($scalarType instanceof \PhpParser\Node\Identifier) { + if ($scalarType instanceof Identifier) { // can be only int or string return $scalarType; } @@ -51,14 +51,14 @@ final class EnumAnalyzer $uniqueEnumExprTypeClasses = \array_unique($enumExprTypeClasses); if (\count($uniqueEnumExprTypeClasses) === 1) { $uniqueEnumExprTypeClass = $uniqueEnumExprTypeClasses[0]; - if (\is_a($uniqueEnumExprTypeClass, \PHPStan\Type\StringType::class, \true)) { - return new \PhpParser\Node\Identifier('string'); + if (\is_a($uniqueEnumExprTypeClass, StringType::class, \true)) { + return new Identifier('string'); } - if (\is_a($uniqueEnumExprTypeClass, \PHPStan\Type\IntegerType::class, \true)) { - return new \PhpParser\Node\Identifier('int'); + if (\is_a($uniqueEnumExprTypeClass, IntegerType::class, \true)) { + return new Identifier('int'); } - if (\is_a($uniqueEnumExprTypeClass, \PHPStan\Type\FloatType::class, \true)) { - return new \PhpParser\Node\Identifier('float'); + if (\is_a($uniqueEnumExprTypeClass, FloatType::class, \true)) { + return new Identifier('float'); } } // unknown or multiple types @@ -67,24 +67,24 @@ final class EnumAnalyzer /** * @return Type[] */ - private function resolveEnumExprTypes(\PhpParser\Node\Stmt\Enum_ $enum) : array + private function resolveEnumExprTypes(Enum_ $enum) : array { $enumExprTypes = []; foreach ($enum->stmts as $classStmt) { - if (!$classStmt instanceof \PhpParser\Node\Stmt\EnumCase) { + if (!$classStmt instanceof EnumCase) { continue; } $enumExprTypes[] = $this->resolveEnumCaseType($classStmt); } return $enumExprTypes; } - private function resolveEnumCaseType(\PhpParser\Node\Stmt\EnumCase $enumCase) : \PHPStan\Type\Type + private function resolveEnumCaseType(EnumCase $enumCase) : Type { $classExpr = $enumCase->expr; - if ($classExpr instanceof \PhpParser\Node\Expr) { + if ($classExpr instanceof Expr) { return $this->nodeTypeResolver->getType($classExpr); } // in case of no value, fallback to string type - return new \PHPStan\Type\StringType(); + return new StringType(); } } diff --git a/rules/DowngradePhp80/NodeAnalyzer/NamedToUnnamedArgs.php b/rules/DowngradePhp80/NodeAnalyzer/NamedToUnnamedArgs.php index 6a0ef540c35..a33ca22de5b 100644 --- a/rules/DowngradePhp80/NodeAnalyzer/NamedToUnnamedArgs.php +++ b/rules/DowngradePhp80/NodeAnalyzer/NamedToUnnamedArgs.php @@ -26,7 +26,7 @@ final class NamedToUnnamedArgs * @var \Rector\DowngradePhp80\Reflection\DefaultParameterValueResolver */ private $defaultParameterValueResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\DowngradePhp80\Reflection\DefaultParameterValueResolver $defaultParameterValueResolver) + public function __construct(NodeNameResolver $nodeNameResolver, DefaultParameterValueResolver $defaultParameterValueResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->defaultParameterValueResolver = $defaultParameterValueResolver; @@ -46,13 +46,13 @@ final class NamedToUnnamedArgs continue; } foreach ($currentArgs as $currentArg) { - if (!$currentArg->name instanceof \PhpParser\Node\Identifier) { + if (!$currentArg->name instanceof Identifier) { continue; } if (!$this->nodeNameResolver->isName($currentArg->name, $parameterReflectionName)) { continue; } - $unnamedArgs[$paramPosition] = new \PhpParser\Node\Arg($currentArg->value, $currentArg->byRef, $currentArg->unpack, $currentArg->getAttributes(), null); + $unnamedArgs[$paramPosition] = new Arg($currentArg->value, $currentArg->byRef, $currentArg->unpack, $currentArg->getAttributes(), null); } } return $unnamedArgs; @@ -79,16 +79,16 @@ final class NamedToUnnamedArgs continue; } /** @var ParameterReflection|PhpParameterReflection $parameterReflection */ - if ($functionLikeReflection instanceof \ReflectionFunction) { - $parameterReflection = new \Rector\DowngradePhp80\Reflection\SimplePhpParameterReflection($functionLikeReflection, $i); + if ($functionLikeReflection instanceof ReflectionFunction) { + $parameterReflection = new SimplePhpParameterReflection($functionLikeReflection, $i); } else { $parameterReflection = $parameters[$i]; } $defaultValue = $this->defaultParameterValueResolver->resolveFromParameterReflection($parameterReflection); - if (!$defaultValue instanceof \PhpParser\Node\Expr) { + if (!$defaultValue instanceof Expr) { continue; } - $unnamedArgs[$i] = new \PhpParser\Node\Arg($defaultValue, $parameterReflection->passedByReference()->yes(), $parameterReflection->isVariadic(), [], null); + $unnamedArgs[$i] = new Arg($defaultValue, $parameterReflection->passedByReference()->yes(), $parameterReflection->isVariadic(), [], null); } return $unnamedArgs; } diff --git a/rules/DowngradePhp80/NodeAnalyzer/UnnamedArgumentResolver.php b/rules/DowngradePhp80/NodeAnalyzer/UnnamedArgumentResolver.php index d22d179c84e..54eedebb7a4 100644 --- a/rules/DowngradePhp80/NodeAnalyzer/UnnamedArgumentResolver.php +++ b/rules/DowngradePhp80/NodeAnalyzer/UnnamedArgumentResolver.php @@ -22,7 +22,7 @@ final class UnnamedArgumentResolver * @var \Rector\DowngradePhp80\NodeAnalyzer\NamedToUnnamedArgs */ private $namedToUnnamedArgs; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\DowngradePhp80\NodeAnalyzer\NamedToUnnamedArgs $namedToUnnamedArgs) + public function __construct(NodeNameResolver $nodeNameResolver, \Rector\DowngradePhp80\NodeAnalyzer\NamedToUnnamedArgs $namedToUnnamedArgs) { $this->nodeNameResolver = $nodeNameResolver; $this->namedToUnnamedArgs = $namedToUnnamedArgs; @@ -34,17 +34,17 @@ final class UnnamedArgumentResolver */ public function resolveFromReflection($functionLikeReflection, array $currentArgs) : array { - $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($functionLikeReflection->getVariants()); + $parametersAcceptor = ParametersAcceptorSelector::selectSingle($functionLikeReflection->getVariants()); $parameters = $parametersAcceptor->getParameters(); - if ($functionLikeReflection instanceof \PHPStan\Reflection\Native\NativeFunctionReflection) { - $functionLikeReflection = new \ReflectionFunction($functionLikeReflection->getName()); + if ($functionLikeReflection instanceof NativeFunctionReflection) { + $functionLikeReflection = new ReflectionFunction($functionLikeReflection->getName()); } /** @var Arg[] $unnamedArgs */ $unnamedArgs = []; $toFillArgs = []; foreach ($currentArgs as $key => $arg) { if ($arg->name === null) { - $unnamedArgs[$key] = new \PhpParser\Node\Arg($arg->value, $arg->byRef, $arg->unpack, $arg->getAttributes(), null); + $unnamedArgs[$key] = new Arg($arg->value, $arg->byRef, $arg->unpack, $arg->getAttributes(), null); continue; } /** @var string $argName */ diff --git a/rules/DowngradePhp80/Rector/ArrayDimFetch/DowngradeDereferenceableOperationRector.php b/rules/DowngradePhp80/Rector/ArrayDimFetch/DowngradeDereferenceableOperationRector.php index ee8da235e78..aa57536cfe9 100644 --- a/rules/DowngradePhp80/Rector/ArrayDimFetch/DowngradeDereferenceableOperationRector.php +++ b/rules/DowngradePhp80/Rector/ArrayDimFetch/DowngradeDereferenceableOperationRector.php @@ -9,18 +9,18 @@ use PhpParser\Node\Scalar\Encapsed; use PhpParser\Node\Scalar\MagicConst; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/variable_syntax_tweaks * * @see \Rector\Tests\DowngradePhp80\Rector\ArrayDimFetch\DowngradeDereferenceableOperationRector\DowngradeDereferenceableOperationRectorTest */ -final class DowngradeDereferenceableOperationRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeDereferenceableOperationRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add parentheses around non-dereferenceable expressions.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add parentheses around non-dereferenceable expressions.', [new CodeSample(<<<'CODE_SAMPLE' function getFirstChar(string $str, string $suffix = '') { return "$str$suffix"[0]; @@ -39,35 +39,35 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\ArrayDimFetch::class]; + return [ArrayDimFetch::class]; } /** * @param ArrayDimFetch $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } - $node->var->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::WRAPPED_IN_PARENTHESES, \true); + $node->var->setAttribute(AttributeKey::WRAPPED_IN_PARENTHESES, \true); return $node; } - private function shouldSkip(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch) : bool + private function shouldSkip(ArrayDimFetch $arrayDimFetch) : bool { if ($arrayDimFetch->dim === null) { return \true; } - if ($arrayDimFetch->var instanceof \PhpParser\Node\Scalar\Encapsed) { + if ($arrayDimFetch->var instanceof Encapsed) { return $this->hasParentheses($arrayDimFetch); } - if ($arrayDimFetch->var instanceof \PhpParser\Node\Scalar\MagicConst) { + if ($arrayDimFetch->var instanceof MagicConst) { return $this->hasParentheses($arrayDimFetch); } return \true; } - private function hasParentheses(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch) : bool + private function hasParentheses(ArrayDimFetch $arrayDimFetch) : bool { - $wrappedInParentheses = $arrayDimFetch->var->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::WRAPPED_IN_PARENTHESES); + $wrappedInParentheses = $arrayDimFetch->var->getAttribute(AttributeKey::WRAPPED_IN_PARENTHESES); if ($wrappedInParentheses === \true) { return \true; } diff --git a/rules/DowngradePhp80/Rector/Catch_/DowngradeNonCapturingCatchesRector.php b/rules/DowngradePhp80/Rector/Catch_/DowngradeNonCapturingCatchesRector.php index c18f2eb6391..90c0f2debb1 100644 --- a/rules/DowngradePhp80/Rector/Catch_/DowngradeNonCapturingCatchesRector.php +++ b/rules/DowngradePhp80/Rector/Catch_/DowngradeNonCapturingCatchesRector.php @@ -9,27 +9,27 @@ use PhpParser\Node\Stmt\Catch_; use PHPStan\Analyser\Scope; use Rector\Core\Rector\AbstractScopeAwareRector; use Rector\Naming\Naming\VariableNaming; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/non-capturing_catches * * @see \Rector\Tests\DowngradePhp80\Rector\Catch_\DowngradeNonCapturingCatchesRector\DowngradeNonCapturingCatchesRectorTest */ -final class DowngradeNonCapturingCatchesRector extends \Rector\Core\Rector\AbstractScopeAwareRector +final class DowngradeNonCapturingCatchesRector extends AbstractScopeAwareRector { /** * @readonly * @var \Rector\Naming\Naming\VariableNaming */ private $variableNaming; - public function __construct(\Rector\Naming\Naming\VariableNaming $variableNaming) + public function __construct(VariableNaming $variableNaming) { $this->variableNaming = $variableNaming; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade catch () without variable to one', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade catch () without variable to one', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -62,18 +62,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Catch_::class]; + return [Catch_::class]; } /** * @param Catch_ $node */ - public function refactorWithScope(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : ?\PhpParser\Node + public function refactorWithScope(Node $node, Scope $scope) : ?Node { if ($node->var !== null) { return null; } $exceptionVarName = $this->variableNaming->createCountedValueName('exception', $scope); - $node->var = new \PhpParser\Node\Expr\Variable($exceptionVarName); + $node->var = new Variable($exceptionVarName); return $node; } } diff --git a/rules/DowngradePhp80/Rector/ClassConstFetch/DowngradeClassOnObjectToGetClassRector.php b/rules/DowngradePhp80/Rector/ClassConstFetch/DowngradeClassOnObjectToGetClassRector.php index 5ba25f28114..0d4c8bbd2cc 100644 --- a/rules/DowngradePhp80/Rector/ClassConstFetch/DowngradeClassOnObjectToGetClassRector.php +++ b/rules/DowngradePhp80/Rector/ClassConstFetch/DowngradeClassOnObjectToGetClassRector.php @@ -10,16 +10,16 @@ use PhpParser\Node\Expr\ClassConstFetch; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Name; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp80\Rector\ClassConstFetch\DowngradeClassOnObjectToGetClassRector\DowngradeClassOnObjectToGetClassRectorTest */ -final class DowngradeClassOnObjectToGetClassRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeClassOnObjectToGetClassRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change $object::class to get_class($object)', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change $object::class to get_class($object)', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($object) @@ -44,19 +44,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\ClassConstFetch::class]; + return [ClassConstFetch::class]; } /** * @param ClassConstFetch $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node->name, 'class')) { return null; } - if (!$node->class instanceof \PhpParser\Node\Expr) { + if (!$node->class instanceof Expr) { return null; } - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('get_class'), [new \PhpParser\Node\Arg($node->class)]); + return new FuncCall(new Name('get_class'), [new Arg($node->class)]); } } diff --git a/rules/DowngradePhp80/Rector/ClassMethod/DowngradeAbstractPrivateMethodInTraitRector.php b/rules/DowngradePhp80/Rector/ClassMethod/DowngradeAbstractPrivateMethodInTraitRector.php index 6538c76bd8e..462b1e20ec1 100644 --- a/rules/DowngradePhp80/Rector/ClassMethod/DowngradeAbstractPrivateMethodInTraitRector.php +++ b/rules/DowngradePhp80/Rector/ClassMethod/DowngradeAbstractPrivateMethodInTraitRector.php @@ -9,25 +9,25 @@ use PhpParser\Node\Stmt\Trait_; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Privatization\NodeManipulator\VisibilityManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp80\Rector\ClassMethod\DowngradeAbstractPrivateMethodInTraitRector\DowngradeAbstractPrivateMethodInTraitRectorTest */ -final class DowngradeAbstractPrivateMethodInTraitRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeAbstractPrivateMethodInTraitRector extends AbstractRector { /** * @readonly * @var \Rector\Privatization\NodeManipulator\VisibilityManipulator */ private $visibilityManipulator; - public function __construct(\Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator) + public function __construct(VisibilityManipulator $visibilityManipulator) { $this->visibilityManipulator = $visibilityManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove "abstract" from private methods in traits and adds an empty function body', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove "abstract" from private methods in traits and adds an empty function body', [new CodeSample(<<<'CODE_SAMPLE' trait SomeTrait { abstract private function someAbstractPrivateFunction(); @@ -46,12 +46,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -61,7 +61,7 @@ CODE_SAMPLE $node->stmts = []; return $node; } - private function shouldSkip(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkip(ClassMethod $classMethod) : bool { if (!$classMethod->isAbstract()) { return \true; @@ -69,7 +69,7 @@ CODE_SAMPLE if (!$classMethod->isPrivate()) { return \true; } - $parent = $classMethod->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - return !$parent instanceof \PhpParser\Node\Stmt\Trait_; + $parent = $classMethod->getAttribute(AttributeKey::PARENT_NODE); + return !$parent instanceof Trait_; } } diff --git a/rules/DowngradePhp80/Rector/ClassMethod/DowngradeRecursiveDirectoryIteratorHasChildrenRector.php b/rules/DowngradePhp80/Rector/ClassMethod/DowngradeRecursiveDirectoryIteratorHasChildrenRector.php index f665676b881..e0af06da15d 100644 --- a/rules/DowngradePhp80/Rector/ClassMethod/DowngradeRecursiveDirectoryIteratorHasChildrenRector.php +++ b/rules/DowngradePhp80/Rector/ClassMethod/DowngradeRecursiveDirectoryIteratorHasChildrenRector.php @@ -8,19 +8,19 @@ use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassMethod; use Rector\Core\Rector\AbstractRector; use Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp80\Rector\ClassMethod\DowngradeRecursiveDirectoryIteratorHasChildrenRector\DowngradeRecursiveDirectoryIteratorHasChildrenRectorTest */ -final class DowngradeRecursiveDirectoryIteratorHasChildrenRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeRecursiveDirectoryIteratorHasChildrenRector extends AbstractRector { /** * @readonly * @var \Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer */ private $familyRelationsAnalyzer; - public function __construct(\Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer $familyRelationsAnalyzer) + public function __construct(FamilyRelationsAnalyzer $familyRelationsAnalyzer) { $this->familyRelationsAnalyzer = $familyRelationsAnalyzer; } @@ -29,11 +29,11 @@ final class DowngradeRecursiveDirectoryIteratorHasChildrenRector extends \Rector */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove bool type hint on child of RecursiveDirectoryIterator hasChildren allowLinks parameter', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove bool type hint on child of RecursiveDirectoryIterator hasChildren allowLinks parameter', [new CodeSample(<<<'CODE_SAMPLE' class RecursiveDirectoryIteratorChild extends \RecursiveDirectoryIterator { public function hasChildren(bool $allowLinks = false): bool @@ -56,7 +56,7 @@ CODE_SAMPLE /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->nodeNameResolver->isName($node, 'hasChildren')) { return null; @@ -64,8 +64,8 @@ CODE_SAMPLE if (!isset($node->params[0])) { return null; } - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLike = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$classLike instanceof Class_) { return null; } $ancestorClassNames = $this->familyRelationsAnalyzer->getClassLikeAncestorNames($classLike); diff --git a/rules/DowngradePhp80/Rector/ClassMethod/DowngradeStaticTypeDeclarationRector.php b/rules/DowngradePhp80/Rector/ClassMethod/DowngradeStaticTypeDeclarationRector.php index 46bd98ff196..f3b0f6e7d95 100644 --- a/rules/DowngradePhp80/Rector/ClassMethod/DowngradeStaticTypeDeclarationRector.php +++ b/rules/DowngradePhp80/Rector/ClassMethod/DowngradeStaticTypeDeclarationRector.php @@ -10,12 +10,12 @@ use PHPStan\Type\StaticType; use Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator; use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp80\Rector\ClassMethod\DowngradeStaticTypeDeclarationRector\DowngradeStaticTypeDeclarationRectorTest */ -final class DowngradeStaticTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeStaticTypeDeclarationRector extends AbstractRector { /** * @readonly @@ -27,7 +27,7 @@ final class DowngradeStaticTypeDeclarationRector extends \Rector\Core\Rector\Abs * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator, ReflectionResolver $reflectionResolver) { $this->phpDocFromTypeDeclarationDecorator = $phpDocFromTypeDeclarationDecorator; $this->reflectionResolver = $reflectionResolver; @@ -37,11 +37,11 @@ final class DowngradeStaticTypeDeclarationRector extends \Rector\Core\Rector\Abs */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove "static" return and param type, add a "@param $this" and "@return $this" tag instead', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove "static" return and param type, add a "@param $this" and "@return $this" tag instead', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function getStatic(): static @@ -67,13 +67,13 @@ CODE_SAMPLE /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $classReflection = $this->reflectionResolver->resolveClassReflection($node); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return null; } - $staticType = new \PHPStan\Type\StaticType($classReflection); + $staticType = new StaticType($classReflection); foreach ($node->getParams() as $param) { $this->phpDocFromTypeDeclarationDecorator->decorateParamWithSpecificType($param, $node, $staticType); } diff --git a/rules/DowngradePhp80/Rector/ClassMethod/DowngradeStringReturnTypeOnToStringRector.php b/rules/DowngradePhp80/Rector/ClassMethod/DowngradeStringReturnTypeOnToStringRector.php index 9acb144e8d3..5ad1fee8ec7 100644 --- a/rules/DowngradePhp80/Rector/ClassMethod/DowngradeStringReturnTypeOnToStringRector.php +++ b/rules/DowngradePhp80/Rector/ClassMethod/DowngradeStringReturnTypeOnToStringRector.php @@ -11,12 +11,12 @@ use PHPStan\Type\MixedType; use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; use Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp80\Rector\ClassMethod\DowngradeStringReturnTypeOnToStringRector\DowngradeStringReturnTypeOnToStringRectorTest */ -final class DowngradeStringReturnTypeOnToStringRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeStringReturnTypeOnToStringRector extends AbstractRector { /** * @readonly @@ -28,7 +28,7 @@ final class DowngradeStringReturnTypeOnToStringRector extends \Rector\Core\Recto * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer $classChildAnalyzer, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(ClassChildAnalyzer $classChildAnalyzer, ReflectionResolver $reflectionResolver) { $this->classChildAnalyzer = $classChildAnalyzer; $this->reflectionResolver = $reflectionResolver; @@ -38,11 +38,11 @@ final class DowngradeStringReturnTypeOnToStringRector extends \Rector\Core\Recto */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add "string" return on current __toString() method when parent method has string return on __toString() method', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add "string" return on current __toString() method when parent method has string return on __toString() method', [new CodeSample(<<<'CODE_SAMPLE' abstract class ParentClass { public function __toString(): string @@ -81,27 +81,27 @@ CODE_SAMPLE /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } - $node->returnType = new \PhpParser\Node\Name('string'); + $node->returnType = new Name('string'); return $node; } - private function shouldSkip(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkip(ClassMethod $classMethod) : bool { if (!$this->nodeNameResolver->isName($classMethod, '__toString')) { return \true; } - if ($classMethod->returnType instanceof \PhpParser\Node) { + if ($classMethod->returnType instanceof Node) { return \true; } $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \true; } $type = $this->classChildAnalyzer->resolveParentClassMethodReturnType($classReflection, '__toString'); - return $type instanceof \PHPStan\Type\MixedType; + return $type instanceof MixedType; } } diff --git a/rules/DowngradePhp80/Rector/ClassMethod/DowngradeTrailingCommasInParamUseRector.php b/rules/DowngradePhp80/Rector/ClassMethod/DowngradeTrailingCommasInParamUseRector.php index f5f9a838884..d59fe2e1fee 100644 --- a/rules/DowngradePhp80/Rector/ClassMethod/DowngradeTrailingCommasInParamUseRector.php +++ b/rules/DowngradePhp80/Rector/ClassMethod/DowngradeTrailingCommasInParamUseRector.php @@ -17,25 +17,25 @@ use PhpParser\Node\Stmt\Function_; use Rector\Core\Rector\AbstractRector; use Rector\DowngradePhp73\Tokenizer\FollowedByCommaAnalyzer; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp80\Rector\ClassMethod\DowngradeTrailingCommasInParamUseRector\DowngradeTrailingCommasInParamUseRectorTest */ -final class DowngradeTrailingCommasInParamUseRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeTrailingCommasInParamUseRector extends AbstractRector { /** * @readonly * @var \Rector\DowngradePhp73\Tokenizer\FollowedByCommaAnalyzer */ private $followedByCommaAnalyzer; - public function __construct(\Rector\DowngradePhp73\Tokenizer\FollowedByCommaAnalyzer $followedByCommaAnalyzer) + public function __construct(FollowedByCommaAnalyzer $followedByCommaAnalyzer) { $this->followedByCommaAnalyzer = $followedByCommaAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove trailing commas in param or use list', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove trailing commas in param or use list', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function __construct(string $value1, string $value2,) @@ -76,18 +76,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\Closure::class, \PhpParser\Node\Expr\StaticCall::class, \PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\New_::class]; + return [ClassMethod::class, Function_::class, Closure::class, StaticCall::class, FuncCall::class, MethodCall::class, New_::class]; } /** * @param ClassMethod|Function_|Closure|FuncCall|MethodCall|StaticCall|New_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\MethodCall || $node instanceof \PhpParser\Node\Expr\FuncCall || $node instanceof \PhpParser\Node\Expr\StaticCall || $node instanceof \PhpParser\Node\Expr\New_) { + if ($node instanceof MethodCall || $node instanceof FuncCall || $node instanceof StaticCall || $node instanceof New_) { /** @var MethodCall|FuncCall|StaticCall|New_ $node */ return $this->processArgs($node); } - if ($node instanceof \PhpParser\Node\Expr\Closure) { + if ($node instanceof Closure) { $this->processUses($node); } return $this->processParams($node); @@ -95,7 +95,7 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\New_ $node */ - private function processArgs($node) : ?\PhpParser\Node + private function processArgs($node) : ?Node { $args = $node->args; if ($args === []) { @@ -103,7 +103,7 @@ CODE_SAMPLE } return $this->cleanTrailingComma($node, $args); } - private function processUses(\PhpParser\Node\Expr\Closure $node) : void + private function processUses(Closure $node) : void { if ($node->uses === []) { return; @@ -113,7 +113,7 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $node */ - private function processParams($node) : ?\PhpParser\Node + private function processParams($node) : ?Node { if ($node->params === []) { return null; @@ -124,7 +124,7 @@ CODE_SAMPLE * @param ClosureUse[]|Param[]|Arg[] $array * @param \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\New_|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\Closure|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $node */ - private function cleanTrailingComma($node, array $array) : ?\PhpParser\Node + private function cleanTrailingComma($node, array $array) : ?Node { \end($array); $lastPosition = \key($array); @@ -132,8 +132,8 @@ CODE_SAMPLE if (!$this->followedByCommaAnalyzer->isFollowed($this->file, $last)) { return null; } - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); - $last->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::FUNC_ARGS_TRAILING_COMMA, \false); + $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); + $last->setAttribute(AttributeKey::FUNC_ARGS_TRAILING_COMMA, \false); return $node; } } diff --git a/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php b/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php index 6231b97cfad..5a42b6ba72d 100644 --- a/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php +++ b/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php @@ -17,15 +17,15 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation; use Rector\PhpAttribute\NodeFactory\DoctrineAnnotationFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @changelog https://php.watch/articles/php-attributes#syntax * * @see \Rector\Tests\DowngradePhp80\Rector\Class_\DowngradeAttributeToAnnotationRector\DowngradeAttributeToAnnotationRectorTest */ -final class DowngradeAttributeToAnnotationRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class DowngradeAttributeToAnnotationRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var DowngradeAttributeToAnnotation[] @@ -40,13 +40,13 @@ final class DowngradeAttributeToAnnotationRector extends \Rector\Core\Rector\Abs * @var \Rector\PhpAttribute\NodeFactory\DoctrineAnnotationFactory */ private $doctrineAnnotationFactory; - public function __construct(\Rector\PhpAttribute\NodeFactory\DoctrineAnnotationFactory $doctrineAnnotationFactory) + public function __construct(DoctrineAnnotationFactory $doctrineAnnotationFactory) { $this->doctrineAnnotationFactory = $doctrineAnnotationFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Refactor PHP attribute markers to annotations notation', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Refactor PHP attribute markers to annotations notation', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Routing\Annotation\Route; class SymfonyRoute @@ -70,31 +70,31 @@ class SymfonyRoute } } CODE_SAMPLE -, [new \Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation('Symfony\\Component\\Routing\\Annotation\\Route')])]); +, [new DowngradeAttributeToAnnotation('Symfony\\Component\\Routing\\Annotation\\Route')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Property::class, \PhpParser\Node\Stmt\Interface_::class, \PhpParser\Node\Param::class, \PhpParser\Node\Stmt\Function_::class]; + return [Class_::class, ClassMethod::class, Property::class, Interface_::class, Param::class, Function_::class]; } /** * @param Class_|ClassMethod|Property|Interface_|Param|Function_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $this->isDowngraded = \false; $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); foreach ($node->attrGroups as $attrGroup) { foreach ($attrGroup->attrs as $key => $attribute) { $attributeToAnnotation = $this->matchAttributeToAnnotation($attribute, $this->attributesToAnnotations); - if (!$attributeToAnnotation instanceof \Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation) { + if (!$attributeToAnnotation instanceof DowngradeAttributeToAnnotation) { continue; } unset($attrGroup->attrs[$key]); if (\strpos($attributeToAnnotation->getTag(), '\\') === \false) { - $phpDocInfo->addPhpDocTagNode(new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode('@' . $attributeToAnnotation->getTag(), new \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode(''))); + $phpDocInfo->addPhpDocTagNode(new PhpDocTagNode('@' . $attributeToAnnotation->getTag(), new GenericTagValueNode(''))); } else { $doctrineAnnotation = $this->doctrineAnnotationFactory->createFromAttribute($attribute, $attributeToAnnotation->getTag()); $phpDocInfo->addTagValueNode($doctrineAnnotation); @@ -114,7 +114,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation::class); + Assert::allIsAOf($configuration, DowngradeAttributeToAnnotation::class); $this->attributesToAnnotations = $configuration; } /** @@ -133,7 +133,7 @@ CODE_SAMPLE /** * @param DowngradeAttributeToAnnotation[] $attributesToAnnotations */ - private function matchAttributeToAnnotation(\PhpParser\Node\Attribute $attribute, array $attributesToAnnotations) : ?\Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation + private function matchAttributeToAnnotation(Attribute $attribute, array $attributesToAnnotations) : ?DowngradeAttributeToAnnotation { foreach ($attributesToAnnotations as $attributeToAnnotation) { if (!$this->isName($attribute->name, $attributeToAnnotation->getAttributeClass())) { diff --git a/rules/DowngradePhp80/Rector/Class_/DowngradePropertyPromotionRector.php b/rules/DowngradePhp80/Rector/Class_/DowngradePropertyPromotionRector.php index f2ee529063b..33b43e24e39 100644 --- a/rules/DowngradePhp80/Rector/Class_/DowngradePropertyPromotionRector.php +++ b/rules/DowngradePhp80/Rector/Class_/DowngradePropertyPromotionRector.php @@ -20,14 +20,14 @@ use Rector\Core\NodeManipulator\ClassInsertManipulator; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\MethodName; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/constructor_promotion * * @see \Rector\Tests\DowngradePhp80\Rector\Class_\DowngradePropertyPromotionRector\DowngradePropertyPromotionRectorTest */ -final class DowngradePropertyPromotionRector extends \Rector\Core\Rector\AbstractRector +final class DowngradePropertyPromotionRector extends AbstractRector { /** * @readonly @@ -44,15 +44,15 @@ final class DowngradePropertyPromotionRector extends \Rector\Core\Rector\Abstrac * @var \Rector\Core\Contract\PhpParser\NodePrinterInterface */ private $nodePrinter; - public function __construct(\Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter) + public function __construct(ClassInsertManipulator $classInsertManipulator, PhpDocTypeChanger $phpDocTypeChanger, NodePrinterInterface $nodePrinter) { $this->classInsertManipulator = $classInsertManipulator; $this->phpDocTypeChanger = $phpDocTypeChanger; $this->nodePrinter = $nodePrinter; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change constructor property promotion to property assign', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change constructor property promotion to property assign', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function __construct(public float $value = 0.0) @@ -78,12 +78,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $oldComments = $this->getOldComments($node); $promotedParams = $this->resolvePromotedParams($node); @@ -100,25 +100,25 @@ CODE_SAMPLE /** * @return array */ - private function getOldComments(\PhpParser\Node\Stmt\Class_ $class) : array + private function getOldComments(Class_ $class) : array { - $constructorClassMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$constructorClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $constructorClassMethod = $class->getMethod(MethodName::CONSTRUCT); + if (!$constructorClassMethod instanceof ClassMethod) { return []; } $oldComments = []; foreach ($constructorClassMethod->params as $param) { - $oldComments[$this->getName($param->var)] = $param->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS); + $oldComments[$this->getName($param->var)] = $param->getAttribute(AttributeKey::COMMENTS); } return $oldComments; } /** * @return Param[] */ - private function resolvePromotedParams(\PhpParser\Node\Stmt\Class_ $class) : array + private function resolvePromotedParams(Class_ $class) : array { - $constructorClassMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$constructorClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $constructorClassMethod = $class->getMethod(MethodName::CONSTRUCT); + if (!$constructorClassMethod instanceof ClassMethod) { return []; } $promotedParams = []; @@ -131,25 +131,25 @@ CODE_SAMPLE } return $promotedParams; } - private function setParamAttrGroupAsComment(\PhpParser\Node\Param $param) : void + private function setParamAttrGroupAsComment(Param $param) : void { $attrGroupsPrint = $this->nodePrinter->print($param->attrGroups); - $comments = $param->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS); + $comments = $param->getAttribute(AttributeKey::COMMENTS); if (\is_array($comments)) { /** @var Comment[] $comments */ foreach ($comments as $comment) { $attrGroupsPrint = \str_replace($comment->getText(), '', $attrGroupsPrint); } } - $comments = $param->attrGroups !== [] ? [new \PhpParser\Comment($attrGroupsPrint)] : null; + $comments = $param->attrGroups !== [] ? [new Comment($attrGroupsPrint)] : null; $param->attrGroups = []; - $param->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $comments); + $param->setAttribute(AttributeKey::COMMENTS, $comments); } /** * @param Param[] $promotedParams * @return Property[] */ - private function resolvePropertiesFromPromotedParams(array $promotedParams, \PhpParser\Node\Stmt\Class_ $class) : array + private function resolvePropertiesFromPromotedParams(array $promotedParams, Class_ $class) : array { $properties = $this->createPropertiesFromParams($promotedParams); $this->classInsertManipulator->addPropertiesToClass($class, $properties); @@ -159,18 +159,18 @@ CODE_SAMPLE * @param Property[] $properties * @param array $oldComments */ - private function addPropertyAssignsToConstructorClassMethod(array $properties, \PhpParser\Node\Stmt\Class_ $class, array $oldComments) : void + private function addPropertyAssignsToConstructorClassMethod(array $properties, Class_ $class, array $oldComments) : void { $assigns = []; foreach ($properties as $property) { $propertyName = $this->getName($property); $assign = $this->nodeFactory->createPropertyAssignment($propertyName); - $expression = new \PhpParser\Node\Stmt\Expression($assign); - $expression->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $oldComments[$propertyName]); + $expression = new Expression($assign); + $expression->setAttribute(AttributeKey::COMMENTS, $oldComments[$propertyName]); $assigns[] = $expression; } /** @var ClassMethod $constructorClassMethod */ - $constructorClassMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); + $constructorClassMethod = $class->getMethod(MethodName::CONSTRUCT); $constructorClassMethod->stmts = \array_merge($assigns, (array) $constructorClassMethod->stmts); } /** @@ -187,7 +187,7 @@ CODE_SAMPLE $property->flags = $param->flags; $property->type = $param->type; $this->decoratePropertyWithParamDocInfo($param, $property); - $hasNew = $param->default === null ? \false : (bool) $this->betterNodeFinder->findFirstInstanceOf($param->default, \PhpParser\Node\Expr\New_::class); + $hasNew = $param->default === null ? \false : (bool) $this->betterNodeFinder->findFirstInstanceOf($param->default, New_::class); if ($param->default !== null && !$hasNew) { $property->props[0]->default = $param->default; } @@ -195,14 +195,14 @@ CODE_SAMPLE } return $properties; } - private function decoratePropertyWithParamDocInfo(\PhpParser\Node\Param $param, \PhpParser\Node\Stmt\Property $property) : void + private function decoratePropertyWithParamDocInfo(Param $param, Property $property) : void { - $constructorClassMethod = $this->betterNodeFinder->findParentType($param, \PhpParser\Node\Stmt\ClassMethod::class); - if (!$constructorClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $constructorClassMethod = $this->betterNodeFinder->findParentType($param, ClassMethod::class); + if (!$constructorClassMethod instanceof ClassMethod) { + throw new ShouldNotHappenException(); } $phpDocInfo = $this->phpDocInfoFactory->createFromNode($constructorClassMethod); - if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$phpDocInfo instanceof PhpDocInfo) { return; } $name = $this->getName($param->var); @@ -210,7 +210,7 @@ CODE_SAMPLE return; } $paramTagValueNode = $phpDocInfo->getParamTagValueByName($name); - if (!$paramTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode) { + if (!$paramTagValueNode instanceof ParamTagValueNode) { return; } $propertyDocInfo = $this->phpDocInfoFactory->createEmpty($property); diff --git a/rules/DowngradePhp80/Rector/Enum_/DowngradeEnumToConstantListClassRector.php b/rules/DowngradePhp80/Rector/Enum_/DowngradeEnumToConstantListClassRector.php index 0831275f5fc..1cc4c934da3 100644 --- a/rules/DowngradePhp80/Rector/Enum_/DowngradeEnumToConstantListClassRector.php +++ b/rules/DowngradePhp80/Rector/Enum_/DowngradeEnumToConstantListClassRector.php @@ -19,12 +19,12 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\Core\Rector\AbstractRector; use Rector\DowngradePhp80\NodeAnalyzer\EnumAnalyzer; use Rector\Php81\NodeFactory\ClassFromEnumFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp80\Rector\Enum_\DowngradeEnumToConstantListClassRector\DowngradeEnumToConstantListClassRectorTest */ -final class DowngradeEnumToConstantListClassRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeEnumToConstantListClassRector extends AbstractRector { /** * @readonly @@ -41,15 +41,15 @@ final class DowngradeEnumToConstantListClassRector extends \Rector\Core\Rector\A * @var \Rector\DowngradePhp80\NodeAnalyzer\EnumAnalyzer */ private $enumAnalyzer; - public function __construct(\Rector\Php81\NodeFactory\ClassFromEnumFactory $classFromEnumFactory, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\DowngradePhp80\NodeAnalyzer\EnumAnalyzer $enumAnalyzer) + public function __construct(ClassFromEnumFactory $classFromEnumFactory, ReflectionProvider $reflectionProvider, EnumAnalyzer $enumAnalyzer) { $this->classFromEnumFactory = $classFromEnumFactory; $this->reflectionProvider = $reflectionProvider; $this->enumAnalyzer = $enumAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade enum to constant list class', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade enum to constant list class', [new CodeSample(<<<'CODE_SAMPLE' enum Direction { case LEFT; @@ -72,21 +72,21 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Enum_::class, \PhpParser\Node\Stmt\ClassMethod::class]; + return [Enum_::class, ClassMethod::class]; } /** * @param Enum_|ClassMethod $node * @return \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\ClassMethod|null */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { - if ($node instanceof \PhpParser\Node\Stmt\Enum_) { + if ($node instanceof Enum_) { return $this->classFromEnumFactory->createFromEnum($node); } $hasChanged = \false; $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); foreach ($node->params as $param) { - if (!$param->type instanceof \PhpParser\Node\Name) { + if (!$param->type instanceof Name) { continue; } // is enum type? @@ -107,16 +107,16 @@ CODE_SAMPLE } return null; } - public function resolveParamType(\PHPStan\Reflection\ClassReflection $classReflection) : ?\PhpParser\Node\Identifier + public function resolveParamType(ClassReflection $classReflection) : ?Identifier { return $this->enumAnalyzer->resolveType($classReflection); } - private function decorateParamDocType(\PHPStan\Reflection\ClassReflection $classReflection, \PhpParser\Node\Param $param, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void + private function decorateParamDocType(ClassReflection $classReflection, Param $param, PhpDocInfo $phpDocInfo) : void { - $constFetchNode = new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstFetchNode('\\' . $classReflection->getName(), '*'); - $constTypeNode = new \PHPStan\PhpDocParser\Ast\Type\ConstTypeNode($constFetchNode); + $constFetchNode = new ConstFetchNode('\\' . $classReflection->getName(), '*'); + $constTypeNode = new ConstTypeNode($constFetchNode); $paramName = '$' . $this->getName($param); - $paramTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode($constTypeNode, \false, $paramName, ''); + $paramTagValueNode = new ParamTagValueNode($constTypeNode, \false, $paramName, ''); $phpDocInfo->addTagValueNode($paramTagValueNode); } } diff --git a/rules/DowngradePhp80/Rector/Expression/DowngradeMatchToSwitchRector.php b/rules/DowngradePhp80/Rector/Expression/DowngradeMatchToSwitchRector.php index 0af1461f4e9..3978faa29b5 100644 --- a/rules/DowngradePhp80/Rector/Expression/DowngradeMatchToSwitchRector.php +++ b/rules/DowngradePhp80/Rector/Expression/DowngradeMatchToSwitchRector.php @@ -28,27 +28,27 @@ use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Php72\NodeFactory\AnonymousFunctionFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/match_expression_v2 * * @see \Rector\Tests\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector\DowngradeMatchToSwitchRectorTest */ -final class DowngradeMatchToSwitchRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeMatchToSwitchRector extends AbstractRector { /** * @readonly * @var \Rector\Php72\NodeFactory\AnonymousFunctionFactory */ private $anonymousFunctionFactory; - public function __construct(\Rector\Php72\NodeFactory\AnonymousFunctionFactory $anonymousFunctionFactory) + public function __construct(AnonymousFunctionFactory $anonymousFunctionFactory) { $this->anonymousFunctionFactory = $anonymousFunctionFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade match() to switch()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade match() to switch()', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -88,17 +88,17 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Echo_::class, \PhpParser\Node\Stmt\Expression::class, \PhpParser\Node\Stmt\Return_::class]; + return [Echo_::class, Expression::class, Return_::class]; } /** * @param Echo_|Expression|Return_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $match = $this->betterNodeFinder->findFirst($node, function (\PhpParser\Node $subNode) : bool { - return $subNode instanceof \PhpParser\Node\Expr\Match_; + $match = $this->betterNodeFinder->findFirst($node, function (Node $subNode) : bool { + return $subNode instanceof Match_; }); - if (!$match instanceof \PhpParser\Node\Expr\Match_) { + if (!$match instanceof Match_) { return null; } $currentStmt = $this->betterNodeFinder->resolveCurrentStatement($match); @@ -106,13 +106,13 @@ CODE_SAMPLE return null; } $switchCases = $this->createSwitchCasesFromMatchArms($node, $match); - $switch = new \PhpParser\Node\Stmt\Switch_($match->cond, $switchCases); - $parentMatch = $match->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentMatch instanceof \PhpParser\Node\Expr\ArrowFunction) { + $switch = new Switch_($match->cond, $switchCases); + $parentMatch = $match->getAttribute(AttributeKey::PARENT_NODE); + if ($parentMatch instanceof ArrowFunction) { return $this->refactorInArrowFunction($parentMatch, $match, $node); } - if ($parentMatch instanceof \PhpParser\Node\Expr\ArrayItem) { - $parentMatch->value = new \PhpParser\Node\Expr\FuncCall($this->anonymousFunctionFactory->create([], [$switch], null)); + if ($parentMatch instanceof ArrayItem) { + $parentMatch->value = new FuncCall($this->anonymousFunctionFactory->create([], [$switch], null)); return $node; } return $switch; @@ -121,27 +121,27 @@ CODE_SAMPLE * @param \PhpParser\Node\Stmt\Echo_|\PhpParser\Node\Stmt\Expression|\PhpParser\Node\Stmt\Return_ $node * @return \PhpParser\Node\Stmt\Echo_|\PhpParser\Node\Stmt\Expression|\PhpParser\Node\Stmt\Return_|null */ - private function refactorInArrowFunction(\PhpParser\Node\Expr\ArrowFunction $arrowFunction, \PhpParser\Node\Expr\Match_ $match, $node) + private function refactorInArrowFunction(ArrowFunction $arrowFunction, Match_ $match, $node) { - $parentOfParentMatch = $arrowFunction->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentOfParentMatch instanceof \PhpParser\Node) { + $parentOfParentMatch = $arrowFunction->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentOfParentMatch instanceof Node) { return null; } /** * Yes, Pass Match_ object itself to Return_ * Let the Rule revisit the Match_ after the ArrowFunction converted to Closure_ */ - $stmts = [new \PhpParser\Node\Stmt\Return_($match)]; + $stmts = [new Return_($match)]; $closure = $this->anonymousFunctionFactory->create($arrowFunction->params, $stmts, $arrowFunction->returnType, $arrowFunction->static); - if ($parentOfParentMatch instanceof \PhpParser\Node\Arg && $parentOfParentMatch->value === $arrowFunction) { + if ($parentOfParentMatch instanceof Arg && $parentOfParentMatch->value === $arrowFunction) { $parentOfParentMatch->value = $closure; return $node; } - if (($parentOfParentMatch instanceof \PhpParser\Node\Expr\Assign || $parentOfParentMatch instanceof \PhpParser\Node\Stmt\Expression || $parentOfParentMatch instanceof \PhpParser\Node\Stmt\Return_) && $parentOfParentMatch->expr === $arrowFunction) { + if (($parentOfParentMatch instanceof Assign || $parentOfParentMatch instanceof Expression || $parentOfParentMatch instanceof Return_) && $parentOfParentMatch->expr === $arrowFunction) { $parentOfParentMatch->expr = $closure; return $node; } - if ($parentOfParentMatch instanceof \PhpParser\Node\Expr\FuncCall && $parentOfParentMatch->name === $arrowFunction) { + if ($parentOfParentMatch instanceof FuncCall && $parentOfParentMatch->name === $arrowFunction) { $parentOfParentMatch->name = $closure; return $node; } @@ -151,24 +151,24 @@ CODE_SAMPLE * @return Case_[] * @param \PhpParser\Node\Stmt\Echo_|\PhpParser\Node\Stmt\Expression|\PhpParser\Node\Stmt\Return_ $node */ - private function createSwitchCasesFromMatchArms($node, \PhpParser\Node\Expr\Match_ $match) : array + private function createSwitchCasesFromMatchArms($node, Match_ $match) : array { $switchCases = []; - $parentNode = $match->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $match->getAttribute(AttributeKey::PARENT_NODE); foreach ($match->arms as $matchArm) { if (\count((array) $matchArm->conds) > 1) { $lastCase = null; foreach ((array) $matchArm->conds as $matchArmCond) { - $lastCase = new \PhpParser\Node\Stmt\Case_($matchArmCond); + $lastCase = new Case_($matchArmCond); $switchCases[] = $lastCase; } - if (!$lastCase instanceof \PhpParser\Node\Stmt\Case_) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$lastCase instanceof Case_) { + throw new ShouldNotHappenException(); } $lastCase->stmts = $this->createSwitchStmts($node, $matchArm, $parentNode); } else { $stmts = $this->createSwitchStmts($node, $matchArm, $parentNode); - $switchCases[] = new \PhpParser\Node\Stmt\Case_($matchArm->conds[0] ?? null, $stmts); + $switchCases[] = new Case_($matchArm->conds[0] ?? null, $stmts); } } return $switchCases; @@ -177,30 +177,30 @@ CODE_SAMPLE * @return Stmt[] * @param \PhpParser\Node\Stmt\Echo_|\PhpParser\Node\Stmt\Expression|\PhpParser\Node\Stmt\Return_ $node */ - private function createSwitchStmts($node, \PhpParser\Node\MatchArm $matchArm, ?\PhpParser\Node $parentNode) : array + private function createSwitchStmts($node, MatchArm $matchArm, ?Node $parentNode) : array { $stmts = []; - if ($parentNode instanceof \PhpParser\Node\Expr\ArrayItem) { - $stmts[] = new \PhpParser\Node\Stmt\Return_($matchArm->body); - } elseif ($matchArm->body instanceof \PhpParser\Node\Expr\Throw_) { - $stmts[] = new \PhpParser\Node\Stmt\Expression($matchArm->body); - } elseif ($node instanceof \PhpParser\Node\Stmt\Return_) { - $stmts[] = new \PhpParser\Node\Stmt\Return_($matchArm->body); - } elseif ($node instanceof \PhpParser\Node\Stmt\Echo_) { - $stmts[] = new \PhpParser\Node\Stmt\Echo_([$matchArm->body]); - $stmts[] = new \PhpParser\Node\Stmt\Break_(); - } elseif ($node->expr instanceof \PhpParser\Node\Expr\Assign) { - $stmts[] = new \PhpParser\Node\Stmt\Expression(new \PhpParser\Node\Expr\Assign($node->expr->var, $matchArm->body)); - $stmts[] = new \PhpParser\Node\Stmt\Break_(); - } elseif ($node->expr instanceof \PhpParser\Node\Expr\Match_) { - $stmts[] = new \PhpParser\Node\Stmt\Expression($matchArm->body); - $stmts[] = new \PhpParser\Node\Stmt\Break_(); - } elseif ($node->expr instanceof \PhpParser\Node\Expr\CallLike) { + if ($parentNode instanceof ArrayItem) { + $stmts[] = new Return_($matchArm->body); + } elseif ($matchArm->body instanceof Throw_) { + $stmts[] = new Expression($matchArm->body); + } elseif ($node instanceof Return_) { + $stmts[] = new Return_($matchArm->body); + } elseif ($node instanceof Echo_) { + $stmts[] = new Echo_([$matchArm->body]); + $stmts[] = new Break_(); + } elseif ($node->expr instanceof Assign) { + $stmts[] = new Expression(new Assign($node->expr->var, $matchArm->body)); + $stmts[] = new Break_(); + } elseif ($node->expr instanceof Match_) { + $stmts[] = new Expression($matchArm->body); + $stmts[] = new Break_(); + } elseif ($node->expr instanceof CallLike) { /** @var FuncCall|MethodCall|New_|NullsafeMethodCall|StaticCall $call */ $call = clone $node->expr; - $call->args = [new \PhpParser\Node\Arg($matchArm->body)]; - $stmts[] = new \PhpParser\Node\Stmt\Expression($call); - $stmts[] = new \PhpParser\Node\Stmt\Break_(); + $call->args = [new Arg($matchArm->body)]; + $stmts[] = new Expression($call); + $stmts[] = new Break_(); } return $stmts; } diff --git a/rules/DowngradePhp80/Rector/Expression/DowngradeThrowExprRector.php b/rules/DowngradePhp80/Rector/Expression/DowngradeThrowExprRector.php index 31f2ea26253..aa1c841d171 100644 --- a/rules/DowngradePhp80/Rector/Expression/DowngradeThrowExprRector.php +++ b/rules/DowngradePhp80/Rector/Expression/DowngradeThrowExprRector.php @@ -21,14 +21,14 @@ use Rector\Core\NodeAnalyzer\CoalesceAnalyzer; use Rector\Core\NodeManipulator\BinaryOpManipulator; use Rector\Core\NodeManipulator\IfManipulator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/throw_expression * * @see \Rector\Tests\DowngradePhp80\Rector\Expression\DowngradeThrowExprRector\DowngradeThrowExprRectorTest */ -final class DowngradeThrowExprRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeThrowExprRector extends AbstractRector { /** * @readonly @@ -45,15 +45,15 @@ final class DowngradeThrowExprRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Core\NodeManipulator\BinaryOpManipulator */ private $binaryOpManipulator; - public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator, \Rector\Core\NodeAnalyzer\CoalesceAnalyzer $coalesceAnalyzer, \Rector\Core\NodeManipulator\BinaryOpManipulator $binaryOpManipulator) + public function __construct(IfManipulator $ifManipulator, CoalesceAnalyzer $coalesceAnalyzer, BinaryOpManipulator $binaryOpManipulator) { $this->ifManipulator = $ifManipulator; $this->coalesceAnalyzer = $coalesceAnalyzer; $this->binaryOpManipulator = $binaryOpManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade throw expression', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade throw expression', [new CodeSample(<<<'CODE_SAMPLE' echo $variable ?? throw new RuntimeException(); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -70,27 +70,27 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Expression::class, \PhpParser\Node\Stmt\Return_::class]; + return [Expression::class, Return_::class]; } /** * @param Expression|Return_ $node * @return Node|Node[]|null */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { - if ($node instanceof \PhpParser\Node\Stmt\Return_) { + if ($node instanceof Return_) { return $this->refactorReturn($node); } - if ($node->expr instanceof \PhpParser\Node\Expr\Throw_) { + if ($node->expr instanceof Throw_) { return null; } - if ($node->expr instanceof \PhpParser\Node\Expr\Assign) { + if ($node->expr instanceof Assign) { return $this->refactorAssign($node, $node->expr); } - if ($node->expr instanceof \PhpParser\Node\Expr\BinaryOp\Coalesce) { + if ($node->expr instanceof Coalesce) { return $this->refactorCoalesce($node->expr, null); } - if ($node->expr instanceof \PhpParser\Node\Expr\Ternary) { + if ($node->expr instanceof Ternary) { return $this->refactorTernary($node->expr, null); } return null; @@ -98,18 +98,18 @@ CODE_SAMPLE /** * @return \PhpParser\Node\Stmt\If_|\PhpParser\Node\Stmt\Expression|null|mixed[] */ - private function refactorAssign(\PhpParser\Node\Stmt\Expression $expression, \PhpParser\Node\Expr\Assign $assign) + private function refactorAssign(Expression $expression, Assign $assign) { if (!$this->hasThrowInAssignExpr($assign)) { return null; } - if ($assign->expr instanceof \PhpParser\Node\Expr\BinaryOp\Coalesce) { + if ($assign->expr instanceof Coalesce) { return $this->refactorCoalesce($assign->expr, $assign); } - if ($assign->expr instanceof \PhpParser\Node\Expr\Throw_) { - return new \PhpParser\Node\Stmt\Expression($assign->expr); + if ($assign->expr instanceof Throw_) { + return new Expression($assign->expr); } - if ($assign->expr instanceof \PhpParser\Node\Expr\Ternary) { + if ($assign->expr instanceof Ternary) { return $this->refactorTernary($assign->expr, $assign); } return $expression; @@ -117,76 +117,76 @@ CODE_SAMPLE /** * @return \PhpParser\Node\Stmt\If_|null|mixed[] */ - private function refactorTernary(\PhpParser\Node\Expr\Ternary $ternary, ?\PhpParser\Node\Expr\Assign $assign) + private function refactorTernary(Ternary $ternary, ?Assign $assign) { - if (!$ternary->else instanceof \PhpParser\Node\Expr\Throw_) { + if (!$ternary->else instanceof Throw_) { return null; } $inversedTernaryCond = $this->binaryOpManipulator->inverseNode($ternary->cond); - $if = $this->ifManipulator->createIfStmt($inversedTernaryCond, new \PhpParser\Node\Stmt\Expression($ternary->else)); - if (!$assign instanceof \PhpParser\Node\Expr\Assign) { + $if = $this->ifManipulator->createIfStmt($inversedTernaryCond, new Expression($ternary->else)); + if (!$assign instanceof Assign) { return $if; } $assign->expr = $ternary->if ?? $ternary->cond; - return [$if, new \PhpParser\Node\Stmt\Expression($assign)]; + return [$if, new Expression($assign)]; } /** * @return \PhpParser\Node\Stmt\If_|null|mixed[] */ - private function refactorCoalesce(\PhpParser\Node\Expr\BinaryOp\Coalesce $coalesce, ?\PhpParser\Node\Expr\Assign $assign) + private function refactorCoalesce(Coalesce $coalesce, ?Assign $assign) { - if (!$coalesce->right instanceof \PhpParser\Node\Expr\Throw_) { + if (!$coalesce->right instanceof Throw_) { return null; } if (!$this->coalesceAnalyzer->hasIssetableLeft($coalesce)) { return null; } $condExpr = $this->createCondExpr($coalesce); - $if = $this->ifManipulator->createIfStmt($condExpr, new \PhpParser\Node\Stmt\Expression($coalesce->right)); - if (!$assign instanceof \PhpParser\Node\Expr\Assign) { + $if = $this->ifManipulator->createIfStmt($condExpr, new Expression($coalesce->right)); + if (!$assign instanceof Assign) { return $if; } $assign->expr = $coalesce->left; - return [$if, new \PhpParser\Node\Stmt\Expression($assign)]; + return [$if, new Expression($assign)]; } - private function hasThrowInAssignExpr(\PhpParser\Node\Expr\Assign $assign) : bool + private function hasThrowInAssignExpr(Assign $assign) : bool { - return (bool) $this->betterNodeFinder->findFirst($assign->expr, function (\PhpParser\Node $node) : bool { - return $node instanceof \PhpParser\Node\Expr\Throw_; + return (bool) $this->betterNodeFinder->findFirst($assign->expr, function (Node $node) : bool { + return $node instanceof Throw_; }); } /** * @return Node[]|null */ - private function refactorReturn(\PhpParser\Node\Stmt\Return_ $return) : ?array + private function refactorReturn(Return_ $return) : ?array { - $throwExpr = $this->betterNodeFinder->findFirstInstanceOf($return, \PhpParser\Node\Expr\Throw_::class); - if (!$throwExpr instanceof \PhpParser\Node\Expr\Throw_) { + $throwExpr = $this->betterNodeFinder->findFirstInstanceOf($return, Throw_::class); + if (!$throwExpr instanceof Throw_) { return null; } - if ($return->expr instanceof \PhpParser\Node\Expr\BinaryOp\Coalesce) { + if ($return->expr instanceof Coalesce) { $coalesce = $return->expr; - if (!$coalesce->right instanceof \PhpParser\Node\Expr\Throw_) { + if (!$coalesce->right instanceof Throw_) { return null; } $if = $this->createIf($coalesce, $coalesce->right); - return [$if, new \PhpParser\Node\Stmt\Return_($coalesce->left)]; + return [$if, new Return_($coalesce->left)]; } return null; } - private function createIf(\PhpParser\Node\Expr\BinaryOp\Coalesce $coalesce, \PhpParser\Node\Expr\Throw_ $throw) : \PhpParser\Node\Stmt\If_ + private function createIf(Coalesce $coalesce, Throw_ $throw) : If_ { - $booleanNot = new \PhpParser\Node\Expr\BooleanNot(new \PhpParser\Node\Expr\Isset_([$coalesce->left])); - return new \PhpParser\Node\Stmt\If_($booleanNot, ['stmts' => [new \PhpParser\Node\Stmt\Expression($throw)]]); + $booleanNot = new BooleanNot(new Isset_([$coalesce->left])); + return new If_($booleanNot, ['stmts' => [new Expression($throw)]]); } /** * @return \PhpParser\Node\Expr\BooleanNot|\PhpParser\Node\Expr\BinaryOp\Identical */ - private function createCondExpr(\PhpParser\Node\Expr\BinaryOp\Coalesce $coalesce) + private function createCondExpr(Coalesce $coalesce) { - if ($coalesce->left instanceof \PhpParser\Node\Expr\Variable || $coalesce->left instanceof \PhpParser\Node\Expr\ArrayDimFetch) { - return new \PhpParser\Node\Expr\BooleanNot(new \PhpParser\Node\Expr\Isset_([$coalesce->left])); + if ($coalesce->left instanceof Variable || $coalesce->left instanceof ArrayDimFetch) { + return new BooleanNot(new Isset_([$coalesce->left])); } - return new \PhpParser\Node\Expr\BinaryOp\Identical($coalesce->left, $this->nodeFactory->createNull()); + return new Identical($coalesce->left, $this->nodeFactory->createNull()); } } diff --git a/rules/DowngradePhp80/Rector/FuncCall/DowngradeArrayFilterNullableCallbackRector.php b/rules/DowngradePhp80/Rector/FuncCall/DowngradeArrayFilterNullableCallbackRector.php index 93ef50bc987..edad670c851 100644 --- a/rules/DowngradePhp80/Rector/FuncCall/DowngradeArrayFilterNullableCallbackRector.php +++ b/rules/DowngradePhp80/Rector/FuncCall/DowngradeArrayFilterNullableCallbackRector.php @@ -27,27 +27,27 @@ use PHPStan\Type\Constant\ConstantStringType; use PHPStan\Type\StringType; use Rector\Core\NodeAnalyzer\ArgsAnalyzer; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/function.array-filter.php#refsect1-function.array-filter-changelog * * @see \Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeArrayFilterNullableCallbackRector\DowngradeArrayFilterNullableCallbackRectorTest */ -final class DowngradeArrayFilterNullableCallbackRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeArrayFilterNullableCallbackRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(ArgsAnalyzer $argsAnalyzer) { $this->argsAnalyzer = $argsAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Unset nullable callback on array_filter', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Unset nullable callback on array_filter', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($callback = null) @@ -74,13 +74,13 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node * @return \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\Ternary|null */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { if (!$this->isName($node, 'array_filter')) { return null; @@ -93,7 +93,7 @@ CODE_SAMPLE return null; } // direct null check ConstFetch - if ($args[1]->value instanceof \PhpParser\Node\Expr\ConstFetch && $this->valueResolver->isNull($args[1]->value)) { + if ($args[1]->value instanceof ConstFetch && $this->valueResolver->isNull($args[1]->value)) { $args = [$args[0]]; $node->args = $args; return $node; @@ -101,37 +101,37 @@ CODE_SAMPLE if ($this->shouldSkipSecondArg($args[1]->value)) { return null; } - $node->args[1] = new \PhpParser\Node\Arg($this->createNewArgFirstTernary($args)); - $node->args[2] = new \PhpParser\Node\Arg($this->createNewArgSecondTernary($args)); + $node->args[1] = new Arg($this->createNewArgFirstTernary($args)); + $node->args[2] = new Arg($this->createNewArgSecondTernary($args)); return $node; } - private function shouldSkipSecondArg(\PhpParser\Node\Expr $expr) : bool + private function shouldSkipSecondArg(Expr $expr) : bool { - if (\in_array(\get_class($expr), [\PhpParser\Node\Scalar\String_::class, \PhpParser\Node\Expr\Closure::class, \PhpParser\Node\Expr\ArrowFunction::class, \PhpParser\Node\Expr\Array_::class], \true)) { + if (\in_array(\get_class($expr), [String_::class, Closure::class, ArrowFunction::class, Array_::class], \true)) { return \true; } $type = $this->nodeTypeResolver->getType($expr); - return \in_array(\get_class($type), [\PHPStan\Type\StringType::class, \PHPStan\Type\Constant\ConstantStringType::class, \PHPStan\Type\ArrayType::class, \PHPStan\Type\ClosureType::class], \true); + return \in_array(\get_class($type), [StringType::class, ConstantStringType::class, ArrayType::class, ClosureType::class], \true); } /** * @param Arg[] $args */ - private function createNewArgFirstTernary(array $args) : \PhpParser\Node\Expr\Ternary + private function createNewArgFirstTernary(array $args) : Ternary { - $identical = new \PhpParser\Node\Expr\BinaryOp\Identical($args[1]->value, $this->nodeFactory->createNull()); - $vVariable = new \PhpParser\Node\Expr\Variable('v'); - $arrowFunction = new \PhpParser\Node\Expr\ArrowFunction(['expr' => new \PhpParser\Node\Expr\BooleanNot(new \PhpParser\Node\Expr\Empty_($vVariable))]); - $arrowFunction->params = [new \PhpParser\Node\Param($vVariable), new \PhpParser\Node\Param(new \PhpParser\Node\Expr\Variable('k'))]; - $arrowFunction->returnType = new \PhpParser\Node\Identifier('bool'); - return new \PhpParser\Node\Expr\Ternary($identical, $arrowFunction, $args[1]->value); + $identical = new Identical($args[1]->value, $this->nodeFactory->createNull()); + $vVariable = new Variable('v'); + $arrowFunction = new ArrowFunction(['expr' => new BooleanNot(new Empty_($vVariable))]); + $arrowFunction->params = [new Param($vVariable), new Param(new Variable('k'))]; + $arrowFunction->returnType = new Identifier('bool'); + return new Ternary($identical, $arrowFunction, $args[1]->value); } /** * @param Arg[] $args */ - private function createNewArgSecondTernary(array $args) : \PhpParser\Node\Expr\Ternary + private function createNewArgSecondTernary(array $args) : Ternary { - $identical = new \PhpParser\Node\Expr\BinaryOp\Identical($args[1]->value, $this->nodeFactory->createNull()); - $constFetch = new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('ARRAY_FILTER_USE_BOTH')); - return new \PhpParser\Node\Expr\Ternary($identical, $constFetch, isset($args[2]) ? $args[2]->value : new \PhpParser\Node\Scalar\LNumber(0)); + $identical = new Identical($args[1]->value, $this->nodeFactory->createNull()); + $constFetch = new ConstFetch(new Name('ARRAY_FILTER_USE_BOTH')); + return new Ternary($identical, $constFetch, isset($args[2]) ? $args[2]->value : new LNumber(0)); } } diff --git a/rules/DowngradePhp80/Rector/FuncCall/DowngradeNumberFormatNoFourthArgRector.php b/rules/DowngradePhp80/Rector/FuncCall/DowngradeNumberFormatNoFourthArgRector.php index 326597cee48..52d65a03d83 100644 --- a/rules/DowngradePhp80/Rector/FuncCall/DowngradeNumberFormatNoFourthArgRector.php +++ b/rules/DowngradePhp80/Rector/FuncCall/DowngradeNumberFormatNoFourthArgRector.php @@ -10,27 +10,27 @@ use PhpParser\Node\Scalar\String_; use Rector\Core\NodeAnalyzer\ArgsAnalyzer; use Rector\Core\Rector\AbstractRector; use ReflectionFunction; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/function.number-format.php#refsect1-function.number-format-changelog * * @see Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeNumberFormatNoFourthArgRector\DowngradeNumberFormatNoFourthArgRectorTest */ -final class DowngradeNumberFormatNoFourthArgRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeNumberFormatNoFourthArgRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(ArgsAnalyzer $argsAnalyzer) { $this->argsAnalyzer = $argsAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade number_format arg to fill 4th arg when only 3rd arg filled', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade number_format arg to fill 4th arg when only 3rd arg filled', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -55,21 +55,21 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } - $reflectionFunction = new \ReflectionFunction('number_format'); - $node->args[3] = new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\String_($reflectionFunction->getParameters()[3]->getDefaultValue())); + $reflectionFunction = new ReflectionFunction('number_format'); + $node->args[3] = new Arg(new String_($reflectionFunction->getParameters()[3]->getDefaultValue())); return $node; } - private function shouldSkip(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function shouldSkip(FuncCall $funcCall) : bool { if (!$this->nodeNameResolver->isName($funcCall, 'number_format')) { return \true; diff --git a/rules/DowngradePhp80/Rector/FuncCall/DowngradeStrContainsRector.php b/rules/DowngradePhp80/Rector/FuncCall/DowngradeStrContainsRector.php index 716145a58bf..259b21593b2 100644 --- a/rules/DowngradePhp80/Rector/FuncCall/DowngradeStrContainsRector.php +++ b/rules/DowngradePhp80/Rector/FuncCall/DowngradeStrContainsRector.php @@ -11,27 +11,27 @@ use PhpParser\Node\Expr\BooleanNot; use PhpParser\Node\Expr\FuncCall; use Rector\Core\NodeAnalyzer\ArgsAnalyzer; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/str_contains * * @see Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeStrContainsRector\DowngradeStrContainsRectorTest */ -final class DowngradeStrContainsRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeStrContainsRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(ArgsAnalyzer $argsAnalyzer) { $this->argsAnalyzer = $argsAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace str_contains() with strpos() !== false', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace str_contains() with strpos() !== false', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -56,16 +56,16 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Expr\BooleanNot::class]; + return [FuncCall::class, BooleanNot::class]; } /** * @param FuncCall|BooleanNot $node * @return Identical|NotIdentical|null The refactored node. */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { $funcCall = $this->matchStrContainsOrNotStrContains($node); - if (!$funcCall instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$funcCall instanceof FuncCall) { return null; } if (!$this->argsAnalyzer->isArgsInstanceInArgsPositions($funcCall->args, [0, 1])) { @@ -78,18 +78,18 @@ CODE_SAMPLE $secondArg = $funcCall->args[1]; $needle = $secondArg->value; $funcCall = $this->nodeFactory->createFuncCall('strpos', [$haystack, $needle]); - if ($node instanceof \PhpParser\Node\Expr\BooleanNot) { - return new \PhpParser\Node\Expr\BinaryOp\Identical($funcCall, $this->nodeFactory->createFalse()); + if ($node instanceof BooleanNot) { + return new Identical($funcCall, $this->nodeFactory->createFalse()); } - return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($funcCall, $this->nodeFactory->createFalse()); + return new NotIdentical($funcCall, $this->nodeFactory->createFalse()); } /** * @param \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\BooleanNot $expr */ - private function matchStrContainsOrNotStrContains($expr) : ?\PhpParser\Node\Expr\FuncCall + private function matchStrContainsOrNotStrContains($expr) : ?FuncCall { - $expr = $expr instanceof \PhpParser\Node\Expr\BooleanNot ? $expr->expr : $expr; - if (!$expr instanceof \PhpParser\Node\Expr\FuncCall) { + $expr = $expr instanceof BooleanNot ? $expr->expr : $expr; + if (!$expr instanceof FuncCall) { return null; } if (!$this->isName($expr, 'str_contains')) { diff --git a/rules/DowngradePhp80/Rector/FuncCall/DowngradeStrEndsWithRector.php b/rules/DowngradePhp80/Rector/FuncCall/DowngradeStrEndsWithRector.php index a310c7f0298..0d201e397f4 100644 --- a/rules/DowngradePhp80/Rector/FuncCall/DowngradeStrEndsWithRector.php +++ b/rules/DowngradePhp80/Rector/FuncCall/DowngradeStrEndsWithRector.php @@ -14,51 +14,51 @@ use PhpParser\Node\Expr\UnaryMinus; use PhpParser\Node\Name; use PhpParser\Node\Scalar\LNumber; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions * * @see \Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeStrEndsWithRector\DowngradeStrEndsWithRectorTest */ -final class DowngradeStrEndsWithRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeStrEndsWithRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade str_ends_with() to strncmp() version', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('str_ends_with($haystack, $needle);', '"" === $needle || ("" !== $haystack && 0 === substr_compare($haystack, $needle, -\\strlen($needle)));')]); + return new RuleDefinition('Downgrade str_ends_with() to strncmp() version', [new CodeSample('str_ends_with($haystack, $needle);', '"" === $needle || ("" !== $haystack && 0 === substr_compare($haystack, $needle, -\\strlen($needle)));')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Expr\BooleanNot::class]; + return [FuncCall::class, BooleanNot::class]; } /** * @param FuncCall|BooleanNot $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\FuncCall && $this->isName($node->name, 'str_ends_with')) { - return new \PhpParser\Node\Expr\BinaryOp\Identical($this->createSubstrCompareFuncCall($node), new \PhpParser\Node\Scalar\LNumber(0)); + if ($node instanceof FuncCall && $this->isName($node->name, 'str_ends_with')) { + return new Identical($this->createSubstrCompareFuncCall($node), new LNumber(0)); } - if ($node instanceof \PhpParser\Node\Expr\BooleanNot) { + if ($node instanceof BooleanNot) { $funcCall = $node->expr; - if ($funcCall instanceof \PhpParser\Node\Expr\FuncCall && $this->isName($funcCall->name, 'str_ends_with')) { - return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($this->createSubstrCompareFuncCall($funcCall), new \PhpParser\Node\Scalar\LNumber(0)); + if ($funcCall instanceof FuncCall && $this->isName($funcCall->name, 'str_ends_with')) { + return new NotIdentical($this->createSubstrCompareFuncCall($funcCall), new LNumber(0)); } } return null; } - private function createSubstrCompareFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall) : \PhpParser\Node\Expr\FuncCall + private function createSubstrCompareFuncCall(FuncCall $funcCall) : FuncCall { $args = $funcCall->args; $strlenFuncCall = $this->createStrlenFuncCall($args[1]->value); - $args[] = new \PhpParser\Node\Arg(new \PhpParser\Node\Expr\UnaryMinus($strlenFuncCall)); - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('substr_compare'), $args); + $args[] = new Arg(new UnaryMinus($strlenFuncCall)); + return new FuncCall(new Name('substr_compare'), $args); } - private function createStrlenFuncCall(\PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr\FuncCall + private function createStrlenFuncCall(Expr $expr) : FuncCall { - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('strlen'), [new \PhpParser\Node\Arg($expr)]); + return new FuncCall(new Name('strlen'), [new Arg($expr)]); } } diff --git a/rules/DowngradePhp80/Rector/FuncCall/DowngradeStrStartsWithRector.php b/rules/DowngradePhp80/Rector/FuncCall/DowngradeStrStartsWithRector.php index 1e3004d08dd..cc3c8da936a 100644 --- a/rules/DowngradePhp80/Rector/FuncCall/DowngradeStrStartsWithRector.php +++ b/rules/DowngradePhp80/Rector/FuncCall/DowngradeStrStartsWithRector.php @@ -12,62 +12,62 @@ use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Name; use PhpParser\Node\Scalar\LNumber; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions * * @see \Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeStrStartsWithRector\DowngradeStrStartsWithRectorTest */ -final class DowngradeStrStartsWithRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeStrStartsWithRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade str_starts_with() to strncmp() version', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('str_starts_with($haystack, $needle);', 'strncmp($haystack, $needle, strlen($needle)) === 0;')]); + return new RuleDefinition('Downgrade str_starts_with() to strncmp() version', [new CodeSample('str_starts_with($haystack, $needle);', 'strncmp($haystack, $needle, strlen($needle)) === 0;')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Expr\BooleanNot::class]; + return [FuncCall::class, BooleanNot::class]; } /** * @param FuncCall|BooleanNot $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\FuncCall && $this->isName($node, 'str_starts_with')) { + if ($node instanceof FuncCall && $this->isName($node, 'str_starts_with')) { return $this->createIdentical($node); } - if ($node instanceof \PhpParser\Node\Expr\BooleanNot) { + if ($node instanceof BooleanNot) { $negatedCall = $node->expr; - if ($negatedCall instanceof \PhpParser\Node\Expr\FuncCall && $this->isName($negatedCall, 'str_starts_with')) { + if ($negatedCall instanceof FuncCall && $this->isName($negatedCall, 'str_starts_with')) { return $this->createNotIdenticalStrncmpFuncCall($negatedCall); } } return null; } - private function createIdentical(\PhpParser\Node\Expr\FuncCall $funcCall) : \PhpParser\Node\Expr\BinaryOp\Identical + private function createIdentical(FuncCall $funcCall) : Identical { $strlenFuncCall = $this->createStrlenFuncCall($funcCall); $strncmpFuncCall = $this->createStrncmpFuncCall($funcCall, $strlenFuncCall); - return new \PhpParser\Node\Expr\BinaryOp\Identical($strncmpFuncCall, new \PhpParser\Node\Scalar\LNumber(0)); + return new Identical($strncmpFuncCall, new LNumber(0)); } - private function createNotIdenticalStrncmpFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall) : \PhpParser\Node\Expr\BinaryOp\NotIdentical + private function createNotIdenticalStrncmpFuncCall(FuncCall $funcCall) : NotIdentical { $strlenFuncCall = $this->createStrlenFuncCall($funcCall); $strncmpFuncCall = $this->createStrncmpFuncCall($funcCall, $strlenFuncCall); - return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($strncmpFuncCall, new \PhpParser\Node\Scalar\LNumber(0)); + return new NotIdentical($strncmpFuncCall, new LNumber(0)); } - private function createStrlenFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall) : \PhpParser\Node\Expr\FuncCall + private function createStrlenFuncCall(FuncCall $funcCall) : FuncCall { - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('strlen'), [$funcCall->args[1]]); + return new FuncCall(new Name('strlen'), [$funcCall->args[1]]); } - private function createStrncmpFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr\FuncCall $strlenFuncCall) : \PhpParser\Node\Expr\FuncCall + private function createStrncmpFuncCall(FuncCall $funcCall, FuncCall $strlenFuncCall) : FuncCall { $newArgs = $funcCall->args; - $newArgs[] = new \PhpParser\Node\Arg($strlenFuncCall); - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('strncmp'), $newArgs); + $newArgs[] = new Arg($strlenFuncCall); + return new FuncCall(new Name('strncmp'), $newArgs); } } diff --git a/rules/DowngradePhp80/Rector/FunctionLike/DowngradeMixedTypeDeclarationRector.php b/rules/DowngradePhp80/Rector/FunctionLike/DowngradeMixedTypeDeclarationRector.php index afaec992e3e..2d8b091cf46 100644 --- a/rules/DowngradePhp80/Rector/FunctionLike/DowngradeMixedTypeDeclarationRector.php +++ b/rules/DowngradePhp80/Rector/FunctionLike/DowngradeMixedTypeDeclarationRector.php @@ -11,19 +11,19 @@ use PhpParser\Node\Stmt\Function_; use PHPStan\Type\MixedType; use Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRector\DowngradeMixedTypeDeclarationRectorTest */ -final class DowngradeMixedTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeMixedTypeDeclarationRector extends AbstractRector { /** * @readonly * @var \Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator */ private $phpDocFromTypeDeclarationDecorator; - public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator) + public function __construct(PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator) { $this->phpDocFromTypeDeclarationDecorator = $phpDocFromTypeDeclarationDecorator; } @@ -32,11 +32,11 @@ final class DowngradeMixedTypeDeclarationRector extends \Rector\Core\Rector\Abst */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Expr\Closure::class, \PhpParser\Node\Expr\ArrowFunction::class]; + return [Function_::class, ClassMethod::class, Closure::class, ArrowFunction::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove the "mixed" param and return type, add a @param and @return tag instead', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove the "mixed" param and return type, add a @param and @return tag instead', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function someFunction(mixed $anything): mixed @@ -61,9 +61,9 @@ CODE_SAMPLE /** * @param ClassMethod|Function_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $mixedType = new \PHPStan\Type\MixedType(); + $mixedType = new MixedType(); foreach ($node->getParams() as $param) { $this->phpDocFromTypeDeclarationDecorator->decorateParamWithSpecificType($param, $node, $mixedType); } diff --git a/rules/DowngradePhp80/Rector/FunctionLike/DowngradeUnionTypeDeclarationRector.php b/rules/DowngradePhp80/Rector/FunctionLike/DowngradeUnionTypeDeclarationRector.php index b048f5a3ce1..d227d007d8d 100644 --- a/rules/DowngradePhp80/Rector/FunctionLike/DowngradeUnionTypeDeclarationRector.php +++ b/rules/DowngradePhp80/Rector/FunctionLike/DowngradeUnionTypeDeclarationRector.php @@ -11,21 +11,21 @@ use PhpParser\Node\Stmt\Function_; use PhpParser\Node\UnionType; use Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector\DowngradeUnionTypeDeclarationRectorTest * * @requires PHP 8.0 */ -final class DowngradeUnionTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeUnionTypeDeclarationRector extends AbstractRector { /** * @readonly * @var \Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator */ private $phpDocFromTypeDeclarationDecorator; - public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator) + public function __construct(PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator) { $this->phpDocFromTypeDeclarationDecorator = $phpDocFromTypeDeclarationDecorator; } @@ -34,11 +34,11 @@ final class DowngradeUnionTypeDeclarationRector extends \Rector\Core\Rector\Abst */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Expr\Closure::class, \PhpParser\Node\Expr\ArrowFunction::class]; + return [Function_::class, ClassMethod::class, Closure::class, ArrowFunction::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove the union type params and returns, add @param/@return tags instead', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove the union type params and returns, add @param/@return tags instead', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function echoInput(string|int $input): int|bool @@ -65,17 +65,17 @@ CODE_SAMPLE /** * @param ClassMethod|Closure|Function_|ArrowFunction $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $paramDecorated = \false; foreach ($node->getParams() as $param) { - if (!$param->type instanceof \PhpParser\Node\UnionType) { + if (!$param->type instanceof UnionType) { continue; } $this->phpDocFromTypeDeclarationDecorator->decorateParam($param, $node, [\PHPStan\Type\UnionType::class]); $paramDecorated = \true; } - if (!$node->returnType instanceof \PhpParser\Node\UnionType) { + if (!$node->returnType instanceof UnionType) { if ($paramDecorated) { return $node; } diff --git a/rules/DowngradePhp80/Rector/Instanceof_/DowngradePhp80ResourceReturnToObjectRector.php b/rules/DowngradePhp80/Rector/Instanceof_/DowngradePhp80ResourceReturnToObjectRector.php index 1b938ee5d6b..1c3d2203266 100644 --- a/rules/DowngradePhp80/Rector/Instanceof_/DowngradePhp80ResourceReturnToObjectRector.php +++ b/rules/DowngradePhp80/Rector/Instanceof_/DowngradePhp80ResourceReturnToObjectRector.php @@ -7,14 +7,14 @@ use PhpParser\Node; use PhpParser\Node\Expr\Instanceof_; use Rector\Core\Rector\AbstractRector; use Rector\DowngradePhp81\NodeManipulator\ObjectToResourceReturn; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/migration80.incompatible.php#migration80.incompatible.resource2object * * @see \Rector\Tests\DowngradePhp80\Rector\Instanceof_\DowngradePhp80ResourceReturnToObjectRector\DowngradePhp80ResourceReturnToObjectRectorTest */ -final class DowngradePhp80ResourceReturnToObjectRector extends \Rector\Core\Rector\AbstractRector +final class DowngradePhp80ResourceReturnToObjectRector extends AbstractRector { /** * @var string[] @@ -53,13 +53,13 @@ final class DowngradePhp80ResourceReturnToObjectRector extends \Rector\Core\Rect * @var \Rector\DowngradePhp81\NodeManipulator\ObjectToResourceReturn */ private $objectToResourceReturn; - public function __construct(\Rector\DowngradePhp81\NodeManipulator\ObjectToResourceReturn $objectToResourceReturn) + public function __construct(ObjectToResourceReturn $objectToResourceReturn) { $this->objectToResourceReturn = $objectToResourceReturn; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('change instanceof Object to is_resource', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('change instanceof Object to is_resource', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($obj) @@ -84,12 +84,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Instanceof_::class]; + return [Instanceof_::class]; } /** * @param Instanceof_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { return $this->objectToResourceReturn->refactor($node, self::COLLECTION_OBJECT_TO_RESOURCE); } diff --git a/rules/DowngradePhp80/Rector/MethodCall/DowngradeNamedArgumentRector.php b/rules/DowngradePhp80/Rector/MethodCall/DowngradeNamedArgumentRector.php index 3c045f534fd..5ad5ac16442 100644 --- a/rules/DowngradePhp80/Rector/MethodCall/DowngradeNamedArgumentRector.php +++ b/rules/DowngradePhp80/Rector/MethodCall/DowngradeNamedArgumentRector.php @@ -15,12 +15,12 @@ use Rector\Core\NodeAnalyzer\ArgsAnalyzer; use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; use Rector\DowngradePhp80\NodeAnalyzer\UnnamedArgumentResolver; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector\DowngradeNamedArgumentRectorTest */ -final class DowngradeNamedArgumentRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeNamedArgumentRector extends AbstractRector { /** * @readonly @@ -37,7 +37,7 @@ final class DowngradeNamedArgumentRector extends \Rector\Core\Rector\AbstractRec * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\DowngradePhp80\NodeAnalyzer\UnnamedArgumentResolver $unnamedArgumentResolver, \Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(ReflectionResolver $reflectionResolver, UnnamedArgumentResolver $unnamedArgumentResolver, ArgsAnalyzer $argsAnalyzer) { $this->reflectionResolver = $reflectionResolver; $this->unnamedArgumentResolver = $unnamedArgumentResolver; @@ -48,11 +48,11 @@ final class DowngradeNamedArgumentRector extends \Rector\Core\Rector\AbstractRec */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class, \PhpParser\Node\Expr\New_::class, \PhpParser\Node\Expr\FuncCall::class]; + return [MethodCall::class, StaticCall::class, New_::class, FuncCall::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove named argument', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove named argument', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -83,7 +83,7 @@ CODE_SAMPLE /** * @param MethodCall|StaticCall|New_|FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $args = $node->args; if ($this->shouldSkip($args)) { @@ -96,14 +96,14 @@ CODE_SAMPLE * @param Arg[] $args * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\New_|\PhpParser\Node\Expr\FuncCall $node */ - private function removeNamedArguments($node, array $args) : ?\PhpParser\Node + private function removeNamedArguments($node, array $args) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\New_) { + if ($node instanceof New_) { $functionLikeReflection = $this->reflectionResolver->resolveMethodReflectionFromNew($node); } else { $functionLikeReflection = $this->reflectionResolver->resolveFunctionLikeReflectionFromCall($node); } - if (!$functionLikeReflection instanceof \PHPStan\Reflection\MethodReflection && !$functionLikeReflection instanceof \PHPStan\Reflection\FunctionReflection) { + if (!$functionLikeReflection instanceof MethodReflection && !$functionLikeReflection instanceof FunctionReflection) { return null; } $unnamedArgs = $this->unnamedArgumentResolver->resolveFromReflection($functionLikeReflection, $args); diff --git a/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionClassGetConstantsFilterRector.php b/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionClassGetConstantsFilterRector.php index 2024f5bcd47..7322d8a0bc5 100644 --- a/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionClassGetConstantsFilterRector.php +++ b/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionClassGetConstantsFilterRector.php @@ -23,12 +23,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\Naming\Naming\VariableNaming; use Rector\NodeCollector\BinaryOpConditionsCollector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeReflectionClassGetConstantsFilterRector\DowngradeReflectionClassGetConstantsFilterRectorTest */ -final class DowngradeReflectionClassGetConstantsFilterRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeReflectionClassGetConstantsFilterRector extends AbstractRector { /** * @var array @@ -49,7 +49,7 @@ final class DowngradeReflectionClassGetConstantsFilterRector extends \Rector\Cor * @var \Rector\NodeCollector\BinaryOpConditionsCollector */ private $binaryOpConditionsCollector; - public function __construct(\Rector\Naming\Naming\VariableNaming $variableNaming, \Rector\Core\NodeManipulator\IfManipulator $ifManipulator, \Rector\NodeCollector\BinaryOpConditionsCollector $binaryOpConditionsCollector) + public function __construct(VariableNaming $variableNaming, IfManipulator $ifManipulator, BinaryOpConditionsCollector $binaryOpConditionsCollector) { $this->variableNaming = $variableNaming; $this->ifManipulator = $ifManipulator; @@ -60,11 +60,11 @@ final class DowngradeReflectionClassGetConstantsFilterRector extends \Rector\Cor */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade ReflectionClass->getConstants(ReflectionClassConstant::IS_*)', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade ReflectionClass->getConstants(ReflectionClassConstant::IS_*)', [new CodeSample(<<<'CODE_SAMPLE' $reflectionClass = new ReflectionClass('SomeClass'); $constants = $reflectionClass->getConstants(ReflectionClassConstant::IS_PUBLIC)); CODE_SAMPLE @@ -84,24 +84,24 @@ CODE_SAMPLE /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } $args = $node->getArgs(); $value = $args[0]->value; - if (!\in_array(\get_class($value), [\PhpParser\Node\Expr\ClassConstFetch::class, \PhpParser\Node\Expr\BinaryOp\BitwiseOr::class], \true)) { + if (!\in_array(\get_class($value), [ClassConstFetch::class, BitwiseOr::class], \true)) { return null; } $classConstFetchNames = []; - if ($value instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if ($value instanceof ClassConstFetch) { $classConstFetchName = $this->resolveClassConstFetchName($value); if (\is_string($classConstFetchName)) { $classConstFetchNames = [$classConstFetchName]; } } - if ($value instanceof \PhpParser\Node\Expr\BinaryOp\BitwiseOr) { + if ($value instanceof BitwiseOr) { $classConstFetchNames = $this->resolveClassConstFetchNames($value); } if ($classConstFetchNames !== []) { @@ -112,36 +112,36 @@ CODE_SAMPLE /** * @param string[] $classConstFetchNames */ - private function processClassConstFetches(\PhpParser\Node\Expr\MethodCall $methodCall, array $classConstFetchNames) : \PhpParser\Node\Expr\Variable + private function processClassConstFetches(MethodCall $methodCall, array $classConstFetchNames) : Variable { - $scope = $methodCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $methodCall->getAttribute(AttributeKey::SCOPE); $reflectionClassConstants = $this->variableNaming->createCountedValueName('reflectionClassConstants', $scope); - $variableReflectionClassConstants = new \PhpParser\Node\Expr\Variable($this->variableNaming->createCountedValueName($reflectionClassConstants, $scope)); - $assign = new \PhpParser\Node\Expr\Assign($variableReflectionClassConstants, new \PhpParser\Node\Expr\MethodCall($methodCall->var, 'getReflectionConstants')); - $this->nodesToAddCollector->addNodeBeforeNode(new \PhpParser\Node\Stmt\Expression($assign), $methodCall, $this->file->getSmartFileInfo()); + $variableReflectionClassConstants = new Variable($this->variableNaming->createCountedValueName($reflectionClassConstants, $scope)); + $assign = new Assign($variableReflectionClassConstants, new MethodCall($methodCall->var, 'getReflectionConstants')); + $this->nodesToAddCollector->addNodeBeforeNode(new Expression($assign), $methodCall, $this->file->getSmartFileInfo()); $result = $this->variableNaming->createCountedValueName('result', $scope); - $variableResult = new \PhpParser\Node\Expr\Variable($result); - $assignVariableResult = new \PhpParser\Node\Expr\Assign($variableResult, new \PhpParser\Node\Expr\Array_()); - $this->nodesToAddCollector->addNodeBeforeNode(new \PhpParser\Node\Stmt\Expression($assignVariableResult), $methodCall, $this->file->getSmartFileInfo()); + $variableResult = new Variable($result); + $assignVariableResult = new Assign($variableResult, new Array_()); + $this->nodesToAddCollector->addNodeBeforeNode(new Expression($assignVariableResult), $methodCall, $this->file->getSmartFileInfo()); $ifs = []; - $valueVariable = new \PhpParser\Node\Expr\Variable('value'); - $key = new \PhpParser\Node\Expr\MethodCall($valueVariable, 'getName'); - $value = new \PhpParser\Node\Expr\MethodCall($valueVariable, 'getValue'); - $arrayDimFetch = new \PhpParser\Node\Expr\ArrayDimFetch($variableResult, $key); + $valueVariable = new Variable('value'); + $key = new MethodCall($valueVariable, 'getName'); + $value = new MethodCall($valueVariable, 'getValue'); + $arrayDimFetch = new ArrayDimFetch($variableResult, $key); $assignValue = $value; foreach ($classConstFetchNames as $classConstFetchName) { $methodCallName = self::MAP_CONSTANT_TO_METHOD[$classConstFetchName]; - $ifs[] = $this->ifManipulator->createIfStmt(new \PhpParser\Node\Expr\MethodCall($valueVariable, $methodCallName), new \PhpParser\Node\Stmt\Expression(new \PhpParser\Node\Expr\Assign($arrayDimFetch, $assignValue))); + $ifs[] = $this->ifManipulator->createIfStmt(new MethodCall($valueVariable, $methodCallName), new Expression(new Assign($arrayDimFetch, $assignValue))); } - $closure = new \PhpParser\Node\Expr\Closure(); - $closure->params = [new \PhpParser\Node\Param(new \PhpParser\Node\Expr\Variable('value'))]; - $closure->uses = [new \PhpParser\Node\Expr\ClosureUse($variableResult, \true)]; + $closure = new Closure(); + $closure->params = [new Param(new Variable('value'))]; + $closure->uses = [new ClosureUse($variableResult, \true)]; $closure->stmts = $ifs; $funcCall = $this->nodeFactory->createFuncCall('array_walk', [$variableReflectionClassConstants, $closure]); - $this->nodesToAddCollector->addNodeBeforeNode(new \PhpParser\Node\Stmt\Expression($funcCall), $methodCall, $this->file->getSmartFileInfo()); + $this->nodesToAddCollector->addNodeBeforeNode(new Expression($funcCall), $methodCall, $this->file->getSmartFileInfo()); return $variableResult; } - private function resolveClassConstFetchName(\PhpParser\Node\Expr\ClassConstFetch $classConstFetch) : ?string + private function resolveClassConstFetchName(ClassConstFetch $classConstFetch) : ?string { if ($this->shouldSkipClassConstFetch($classConstFetch)) { return null; @@ -153,9 +153,9 @@ CODE_SAMPLE /** * @return string[] */ - private function resolveClassConstFetchNames(\PhpParser\Node\Expr\BinaryOp\BitwiseOr $bitwiseOr) : array + private function resolveClassConstFetchNames(BitwiseOr $bitwiseOr) : array { - $values = $this->binaryOpConditionsCollector->findConditions($bitwiseOr, \PhpParser\Node\Expr\BinaryOp\BitwiseOr::class); + $values = $this->binaryOpConditionsCollector->findConditions($bitwiseOr, BitwiseOr::class); if ($this->shouldSkipBitwiseOrValues($values)) { return []; } @@ -174,7 +174,7 @@ CODE_SAMPLE private function shouldSkipBitwiseOrValues(array $values) : bool { foreach ($values as $value) { - if (!$value instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if (!$value instanceof ClassConstFetch) { return \true; } if ($this->shouldSkipClassConstFetch($value)) { @@ -183,27 +183,27 @@ CODE_SAMPLE } return \false; } - private function shouldSkipClassConstFetch(\PhpParser\Node\Expr\ClassConstFetch $classConstFetch) : bool + private function shouldSkipClassConstFetch(ClassConstFetch $classConstFetch) : bool { - if (!$classConstFetch->class instanceof \PhpParser\Node\Name\FullyQualified) { + if (!$classConstFetch->class instanceof FullyQualified) { return \true; } if ($classConstFetch->class->toString() !== 'ReflectionClassConstant') { return \true; } - if (!$classConstFetch->name instanceof \PhpParser\Node\Identifier) { + if (!$classConstFetch->name instanceof Identifier) { return \true; } $constants = \array_keys(self::MAP_CONSTANT_TO_METHOD); return !$this->nodeNameResolver->isNames($classConstFetch->name, $constants); } - private function shouldSkip(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + private function shouldSkip(MethodCall $methodCall) : bool { if (!$this->nodeNameResolver->isName($methodCall->name, 'getConstants')) { return \true; } $varType = $this->nodeTypeResolver->getType($methodCall->var); - if (!$varType instanceof \PHPStan\Type\ObjectType) { + if (!$varType instanceof ObjectType) { return \true; } if ($varType->getClassName() !== 'ReflectionClass') { diff --git a/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionGetAttributesRector.php b/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionGetAttributesRector.php index 7d46ea1a58f..d7cb8489ba3 100644 --- a/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionGetAttributesRector.php +++ b/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionGetAttributesRector.php @@ -12,16 +12,16 @@ use PhpParser\Node\Scalar\String_; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeReflectionGetAttributesRector\DowngradeReflectionGetAttributesRectorTest */ -final class DowngradeReflectionGetAttributesRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeReflectionGetAttributesRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove reflection getAttributes() class method code', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove reflection getAttributes() class method code', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(ReflectionClass $reflectionClass) @@ -54,23 +54,23 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node->name, 'getAttributes')) { return null; } - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Reflector'))) { + if (!$this->isObjectType($node->var, new ObjectType('Reflector'))) { return null; } - $args = [new \PhpParser\Node\Arg($node->var), new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\String_('getAttributes'))]; - $ternary = new \PhpParser\Node\Expr\Ternary($this->nodeFactory->createFuncCall('method_exists', $args), $node, new \PhpParser\Node\Expr\Array_([])); - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\Expr\Ternary) { + $args = [new Arg($node->var), new Arg(new String_('getAttributes'))]; + $ternary = new Ternary($this->nodeFactory->createFuncCall('method_exists', $args), $node, new Array_([])); + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Ternary) { return $ternary; } if (!$this->nodeComparator->areNodesEqual($parent, $ternary)) { diff --git a/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionPropertyGetDefaultValueRector.php b/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionPropertyGetDefaultValueRector.php index a038e0270c2..9212f743835 100644 --- a/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionPropertyGetDefaultValueRector.php +++ b/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionPropertyGetDefaultValueRector.php @@ -9,16 +9,16 @@ use PhpParser\Node\Expr\BinaryOp\Coalesce; use PhpParser\Node\Expr\MethodCall; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeReflectionPropertyGetDefaultValueRector\DowngradeReflectionPropertyGetDefaultValueRectorTest */ -final class DowngradeReflectionPropertyGetDefaultValueRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeReflectionPropertyGetDefaultValueRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade ReflectionProperty->getDefaultValue()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Downgrade ReflectionProperty->getDefaultValue()', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(ReflectionProperty $reflectionProperty) @@ -43,27 +43,27 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->nodeNameResolver->isName($node->name, 'getDefaultValue')) { return null; } $objectType = $this->nodeTypeResolver->getType($node->var); - if (!$objectType instanceof \PHPStan\Type\ObjectType) { + if (!$objectType instanceof ObjectType) { return null; } if ($objectType->getClassName() !== 'ReflectionProperty') { return null; } - $getName = new \PhpParser\Node\Expr\MethodCall($node->var, 'getName'); - $node = new \PhpParser\Node\Expr\MethodCall($node->var, 'getDeclaringClass'); - $node = new \PhpParser\Node\Expr\MethodCall($node, 'getDefaultProperties'); - $node = new \PhpParser\Node\Expr\ArrayDimFetch($node, $getName); - return new \PhpParser\Node\Expr\BinaryOp\Coalesce($node, $this->nodeFactory->createNull()); + $getName = new MethodCall($node->var, 'getName'); + $node = new MethodCall($node->var, 'getDeclaringClass'); + $node = new MethodCall($node, 'getDefaultProperties'); + $node = new ArrayDimFetch($node, $getName); + return new Coalesce($node, $this->nodeFactory->createNull()); } } diff --git a/rules/DowngradePhp80/Rector/New_/DowngradeArbitraryExpressionsSupportRector.php b/rules/DowngradePhp80/Rector/New_/DowngradeArbitraryExpressionsSupportRector.php index a336d15aab2..19f875ef0a3 100644 --- a/rules/DowngradePhp80/Rector/New_/DowngradeArbitraryExpressionsSupportRector.php +++ b/rules/DowngradePhp80/Rector/New_/DowngradeArbitraryExpressionsSupportRector.php @@ -17,27 +17,27 @@ use PhpParser\Node\Expr\Variable; use Rector\Core\PhpParser\Node\NamedVariableFactory; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/variable_syntax_tweaks#arbitrary_expression_support_for_new_and_instanceof * * @see \Rector\Tests\DowngradePhp80\Rector\New_\DowngradeArbitraryExpressionsSupportRector\DowngradeArbitraryExpressionsSupportRectorTest */ -final class DowngradeArbitraryExpressionsSupportRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeArbitraryExpressionsSupportRector extends AbstractRector { /** * @readonly * @var \Rector\Core\PhpParser\Node\NamedVariableFactory */ private $namedVariableFactory; - public function __construct(\Rector\Core\PhpParser\Node\NamedVariableFactory $namedVariableFactory) + public function __construct(NamedVariableFactory $namedVariableFactory) { $this->namedVariableFactory = $namedVariableFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace arbitrary expressions used with new or instanceof.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace arbitrary expressions used with new or instanceof.', [new CodeSample(<<<'CODE_SAMPLE' function getObjectClassName() { return stdClass::class; } @@ -59,14 +59,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Instanceof_::class, \PhpParser\Node\Expr\New_::class]; + return [Instanceof_::class, New_::class]; } /** * @param Instanceof_|New_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->class instanceof \PhpParser\Node\Expr) { + if (!$node->class instanceof Expr) { return null; } $isAllowed = $this->isAllowed($node->class); @@ -75,7 +75,7 @@ CODE_SAMPLE return null; } // mandatory to remove parentheses - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); if ($isAllowed) { return $node; } @@ -85,21 +85,21 @@ CODE_SAMPLE $variable = $assign->var; } else { $variable = $this->namedVariableFactory->createVariable($node, 'className'); - $assign = new \PhpParser\Node\Expr\Assign($variable, $node->class); + $assign = new Assign($variable, $node->class); } $this->nodesToAddCollector->addNodeBeforeNode($assign, $node, $this->file->getSmartFileInfo()); $node->class = $variable; return $node; } - private function isAllowed(\PhpParser\Node\Expr $expr) : bool + private function isAllowed(Expr $expr) : bool { - return $expr instanceof \PhpParser\Node\Expr\Variable || $expr instanceof \PhpParser\Node\Expr\ArrayDimFetch || $expr instanceof \PhpParser\Node\Expr\PropertyFetch || $expr instanceof \PhpParser\Node\Expr\StaticPropertyFetch; + return $expr instanceof Variable || $expr instanceof ArrayDimFetch || $expr instanceof PropertyFetch || $expr instanceof StaticPropertyFetch; } - private function isAssign(\PhpParser\Node\Expr $expr) : bool + private function isAssign(Expr $expr) : bool { - return $expr instanceof \PhpParser\Node\Expr\Assign || $expr instanceof \PhpParser\Node\Expr\AssignRef || $expr instanceof \PhpParser\Node\Expr\AssignOp; + return $expr instanceof Assign || $expr instanceof AssignRef || $expr instanceof AssignOp; } - private function isBetweenParentheses(\PhpParser\Node $node) : bool + private function isBetweenParentheses(Node $node) : bool { $oldTokens = $this->file->getOldTokens(); $previousTokenPos = $node->getStartTokenPos() - 1; diff --git a/rules/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector.php b/rules/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector.php index 2b0c709c559..a037f2feef2 100644 --- a/rules/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector.php +++ b/rules/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector.php @@ -14,25 +14,25 @@ use PhpParser\Node\Expr\Variable; use PHPStan\Analyser\Scope; use Rector\Core\Rector\AbstractScopeAwareRector; use Rector\Naming\Naming\VariableNaming; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp80\Rector\NullsafeMethodCall\DowngradeNullsafeToTernaryOperatorRector\DowngradeNullsafeToTernaryOperatorRectorTest */ -final class DowngradeNullsafeToTernaryOperatorRector extends \Rector\Core\Rector\AbstractScopeAwareRector +final class DowngradeNullsafeToTernaryOperatorRector extends AbstractScopeAwareRector { /** * @readonly * @var \Rector\Naming\Naming\VariableNaming */ private $variableNaming; - public function __construct(\Rector\Naming\Naming\VariableNaming $variableNaming) + public function __construct(VariableNaming $variableNaming) { $this->variableNaming = $variableNaming; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change nullsafe operator to ternary operator rector', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change nullsafe operator to ternary operator rector', [new CodeSample(<<<'CODE_SAMPLE' $dateAsString = $booking->getStartDate()?->asDateTimeString(); $dateAsString = $booking->startDate?->dateTimeString; CODE_SAMPLE @@ -47,17 +47,17 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\NullsafeMethodCall::class, \PhpParser\Node\Expr\NullsafePropertyFetch::class]; + return [NullsafeMethodCall::class, NullsafePropertyFetch::class]; } /** * @param NullsafeMethodCall|NullsafePropertyFetch $node */ - public function refactorWithScope(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : \PhpParser\Node\Expr\Ternary + public function refactorWithScope(Node $node, Scope $scope) : Ternary { $tempVarName = $this->variableNaming->resolveFromNodeWithScopeCountAndFallbackName($node->var, $scope, '_'); - $variable = new \PhpParser\Node\Expr\Variable($tempVarName); - $called = $node instanceof \PhpParser\Node\Expr\NullsafeMethodCall ? new \PhpParser\Node\Expr\MethodCall($variable, $node->name, $node->args) : new \PhpParser\Node\Expr\PropertyFetch($variable, $node->name); - $assign = new \PhpParser\Node\Expr\Assign($variable, $node->var); - return new \PhpParser\Node\Expr\Ternary($assign, $called, $this->nodeFactory->createNull()); + $variable = new Variable($tempVarName); + $called = $node instanceof NullsafeMethodCall ? new MethodCall($variable, $node->name, $node->args) : new PropertyFetch($variable, $node->name); + $assign = new Assign($variable, $node->var); + return new Ternary($assign, $called, $this->nodeFactory->createNull()); } } diff --git a/rules/DowngradePhp80/Rector/Property/DowngradeUnionTypeTypedPropertyRector.php b/rules/DowngradePhp80/Rector/Property/DowngradeUnionTypeTypedPropertyRector.php index ffddf025582..aecc2dfb17e 100644 --- a/rules/DowngradePhp80/Rector/Property/DowngradeUnionTypeTypedPropertyRector.php +++ b/rules/DowngradePhp80/Rector/Property/DowngradeUnionTypeTypedPropertyRector.php @@ -8,19 +8,19 @@ use PhpParser\Node\Stmt\Property; use PhpParser\Node\UnionType; use Rector\CodeQuality\NodeFactory\PropertyTypeDecorator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector\DowngradeUnionTypeTypedPropertyRectorTest */ -final class DowngradeUnionTypeTypedPropertyRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeUnionTypeTypedPropertyRector extends AbstractRector { /** * @readonly * @var \Rector\CodeQuality\NodeFactory\PropertyTypeDecorator */ private $propertyTypeDecorator; - public function __construct(\Rector\CodeQuality\NodeFactory\PropertyTypeDecorator $propertyTypeDecorator) + public function __construct(PropertyTypeDecorator $propertyTypeDecorator) { $this->propertyTypeDecorator = $propertyTypeDecorator; } @@ -29,11 +29,11 @@ final class DowngradeUnionTypeTypedPropertyRector extends \Rector\Core\Rector\Ab */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Removes union type property type definition, adding `@var` annotations instead.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Removes union type property type definition, adding `@var` annotations instead.', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { private string|int $property; @@ -53,7 +53,7 @@ CODE_SAMPLE /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->type === null) { return null; @@ -65,12 +65,12 @@ CODE_SAMPLE $node->type = null; return $node; } - private function shouldRemoveProperty(\PhpParser\Node\Stmt\Property $property) : bool + private function shouldRemoveProperty(Property $property) : bool { if ($property->type === null) { return \false; } // Check it is the union type - return $property->type instanceof \PhpParser\Node\UnionType; + return $property->type instanceof UnionType; } } diff --git a/rules/DowngradePhp80/Rector/StaticCall/DowngradePhpTokenRector.php b/rules/DowngradePhp80/Rector/StaticCall/DowngradePhpTokenRector.php index 57d41182741..9f3cbb50ca3 100644 --- a/rules/DowngradePhp80/Rector/StaticCall/DowngradePhpTokenRector.php +++ b/rules/DowngradePhp80/Rector/StaticCall/DowngradePhpTokenRector.php @@ -15,20 +15,20 @@ use PhpParser\Node\Name; use PhpParser\Node\Scalar\LNumber; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\DowngradePhp80\Rector\StaticCall\DowngradePhpTokenRector\DowngradePhpTokenRectorTest */ -final class DowngradePhpTokenRector extends \Rector\Core\Rector\AbstractRector +final class DowngradePhpTokenRector extends AbstractRector { /** * @var string */ private const PHP_TOKEN = 'PhpToken'; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('"something()" will be renamed to "somethingElse()"', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('"something()" will be renamed to "somethingElse()"', [new CodeSample(<<<'CODE_SAMPLE' $tokens = \PhpToken::tokenize($code); foreach ($tokens as $phpToken) { @@ -51,54 +51,54 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class, \PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\PropertyFetch::class]; + return [StaticCall::class, MethodCall::class, PropertyFetch::class]; } /** * @param StaticCall|MethodCall|PropertyFetch $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\StaticCall) { + if ($node instanceof StaticCall) { return $this->refactorStaticCall($node); } - if ($node instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node instanceof MethodCall) { return $this->refactorMethodCall($node); } return $this->refactorPropertyFetch($node); } - private function refactorStaticCall(\PhpParser\Node\Expr\StaticCall $staticCall) : ?\PhpParser\Node\Expr\FuncCall + private function refactorStaticCall(StaticCall $staticCall) : ?FuncCall { - if (!$this->isObjectType($staticCall->class, new \PHPStan\Type\ObjectType(self::PHP_TOKEN))) { + if (!$this->isObjectType($staticCall->class, new ObjectType(self::PHP_TOKEN))) { return null; } if (!$this->isName($staticCall->name, 'tokenize')) { return null; } - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('token_get_all'), $staticCall->args); + return new FuncCall(new Name('token_get_all'), $staticCall->args); } - private function refactorMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node\Expr\Ternary + private function refactorMethodCall(MethodCall $methodCall) : ?Ternary { - if (!$this->isObjectType($methodCall->var, new \PHPStan\Type\ObjectType(self::PHP_TOKEN))) { + if (!$this->isObjectType($methodCall->var, new ObjectType(self::PHP_TOKEN))) { return null; } if (!$this->isName($methodCall->name, 'getTokenName')) { return null; } - $isArrayFuncCall = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('is_array'), [new \PhpParser\Node\Arg($methodCall->var)]); - $arrayDimFetch = new \PhpParser\Node\Expr\ArrayDimFetch($methodCall->var, new \PhpParser\Node\Scalar\LNumber(0)); - $tokenGetNameFuncCall = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('token_name'), [new \PhpParser\Node\Arg($arrayDimFetch)]); - return new \PhpParser\Node\Expr\Ternary($isArrayFuncCall, $tokenGetNameFuncCall, $this->nodeFactory->createNull()); + $isArrayFuncCall = new FuncCall(new Name('is_array'), [new Arg($methodCall->var)]); + $arrayDimFetch = new ArrayDimFetch($methodCall->var, new LNumber(0)); + $tokenGetNameFuncCall = new FuncCall(new Name('token_name'), [new Arg($arrayDimFetch)]); + return new Ternary($isArrayFuncCall, $tokenGetNameFuncCall, $this->nodeFactory->createNull()); } - private function refactorPropertyFetch(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : ?\PhpParser\Node\Expr\Ternary + private function refactorPropertyFetch(PropertyFetch $propertyFetch) : ?Ternary { - if (!$this->isObjectType($propertyFetch->var, new \PHPStan\Type\ObjectType(self::PHP_TOKEN))) { + if (!$this->isObjectType($propertyFetch->var, new ObjectType(self::PHP_TOKEN))) { return null; } if (!$this->isName($propertyFetch->name, 'text')) { return null; } - $isArrayFuncCall = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('is_array'), [new \PhpParser\Node\Arg($propertyFetch->var)]); - $arrayDimFetch = new \PhpParser\Node\Expr\ArrayDimFetch($propertyFetch->var, new \PhpParser\Node\Scalar\LNumber(1)); - return new \PhpParser\Node\Expr\Ternary($isArrayFuncCall, $arrayDimFetch, $propertyFetch->var); + $isArrayFuncCall = new FuncCall(new Name('is_array'), [new Arg($propertyFetch->var)]); + $arrayDimFetch = new ArrayDimFetch($propertyFetch->var, new LNumber(1)); + return new Ternary($isArrayFuncCall, $arrayDimFetch, $propertyFetch->var); } } diff --git a/rules/DowngradePhp80/Reflection/DefaultParameterValueResolver.php b/rules/DowngradePhp80/Reflection/DefaultParameterValueResolver.php index 0d146e6bce8..cdba600b4f7 100644 --- a/rules/DowngradePhp80/Reflection/DefaultParameterValueResolver.php +++ b/rules/DowngradePhp80/Reflection/DefaultParameterValueResolver.php @@ -19,41 +19,41 @@ final class DefaultParameterValueResolver /** * @return \PhpParser\Node\Expr|null */ - public function resolveFromParameterReflection(\PHPStan\Reflection\ParameterReflection $parameterReflection) + public function resolveFromParameterReflection(ParameterReflection $parameterReflection) { $defaultValue = $parameterReflection->getDefaultValue(); - if (!$defaultValue instanceof \PHPStan\Type\Type) { + if (!$defaultValue instanceof Type) { return null; } - if (!$defaultValue instanceof \PHPStan\Type\ConstantType) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$defaultValue instanceof ConstantType) { + throw new ShouldNotHappenException(); } return $this->resolveValueFromType($defaultValue); } /** * @return \PhpParser\Node\Expr\ConstFetch|\PhpParser\Node\Expr */ - private function resolveValueFromType(\PHPStan\Type\ConstantType $constantType) + private function resolveValueFromType(ConstantType $constantType) { - if ($constantType instanceof \PHPStan\Type\Constant\ConstantBooleanType) { + if ($constantType instanceof ConstantBooleanType) { return $this->resolveConstantBooleanType($constantType); } - if ($constantType instanceof \PHPStan\Type\Constant\ConstantArrayType) { + if ($constantType instanceof ConstantArrayType) { $values = []; foreach ($constantType->getValueTypes() as $valueType) { - if (!$valueType instanceof \PHPStan\Type\ConstantType) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$valueType instanceof ConstantType) { + throw new ShouldNotHappenException(); } $values[] = $this->resolveValueFromType($valueType); } - return \PhpParser\BuilderHelpers::normalizeValue($values); + return BuilderHelpers::normalizeValue($values); } - return \PhpParser\BuilderHelpers::normalizeValue($constantType->getValue()); + return BuilderHelpers::normalizeValue($constantType->getValue()); } - private function resolveConstantBooleanType(\PHPStan\Type\Constant\ConstantBooleanType $constantBooleanType) : \PhpParser\Node\Expr\ConstFetch + private function resolveConstantBooleanType(ConstantBooleanType $constantBooleanType) : ConstFetch { - $value = $constantBooleanType->describe(\PHPStan\Type\VerbosityLevel::value()); - $name = new \PhpParser\Node\Name($value); - return new \PhpParser\Node\Expr\ConstFetch($name); + $value = $constantBooleanType->describe(VerbosityLevel::value()); + $name = new Name($value); + return new ConstFetch($name); } } diff --git a/rules/DowngradePhp80/Reflection/SimplePhpParameterReflection.php b/rules/DowngradePhp80/Reflection/SimplePhpParameterReflection.php index 4fa3b4c8c42..e2e40bf9e63 100644 --- a/rules/DowngradePhp80/Reflection/SimplePhpParameterReflection.php +++ b/rules/DowngradePhp80/Reflection/SimplePhpParameterReflection.php @@ -11,14 +11,14 @@ use Rector\Core\Exception\NotImplementedYetException; use ReflectionFunction; use ReflectionParameter; use Throwable; -final class SimplePhpParameterReflection implements \PHPStan\Reflection\ParameterReflection +final class SimplePhpParameterReflection implements ParameterReflection { /** * @readonly * @var \ReflectionParameter */ private $parameter; - public function __construct(\ReflectionFunction $reflectionFunction, int $position) + public function __construct(ReflectionFunction $reflectionFunction, int $position) { $this->parameter = $reflectionFunction->getParameters()[$position]; } @@ -34,26 +34,26 @@ final class SimplePhpParameterReflection implements \PHPStan\Reflection\Paramete * getType() is never used yet on manual object creation, and the implementation require PHPStan $phpDocType services injection * @see https://github.com/phpstan/phpstan-src/blob/92420cd4b190b57d1ba8bf9e800eb97c8c0ee2f2/src/Reflection/Php/PhpParameterReflection.php#L24 */ - public function getType() : \PHPStan\Type\Type + public function getType() : Type { - throw new \Rector\Core\Exception\NotImplementedYetException(); + throw new NotImplementedYetException(); } - public function passedByReference() : \PHPStan\Reflection\PassedByReference + public function passedByReference() : PassedByReference { - return $this->parameter->isPassedByReference() ? \PHPStan\Reflection\PassedByReference::createCreatesNewVariable() : \PHPStan\Reflection\PassedByReference::createNo(); + return $this->parameter->isPassedByReference() ? PassedByReference::createCreatesNewVariable() : PassedByReference::createNo(); } public function isVariadic() : bool { return $this->parameter->isVariadic(); } - public function getDefaultValue() : ?\PHPStan\Type\Type + public function getDefaultValue() : ?Type { try { if ($this->parameter->isDefaultValueAvailable()) { $defaultValue = $this->parameter->getDefaultValue(); - return \PHPStan\Type\ConstantTypeHelper::getTypeFromValue($defaultValue); + return ConstantTypeHelper::getTypeFromValue($defaultValue); } - } catch (\Throwable $exception) { + } catch (Throwable $exception) { return null; } return null; diff --git a/rules/DowngradePhp81/NodeAnalyzer/ArraySpreadAnalyzer.php b/rules/DowngradePhp81/NodeAnalyzer/ArraySpreadAnalyzer.php index cb164cddfe9..53af84a5661 100644 --- a/rules/DowngradePhp81/NodeAnalyzer/ArraySpreadAnalyzer.php +++ b/rules/DowngradePhp81/NodeAnalyzer/ArraySpreadAnalyzer.php @@ -7,11 +7,11 @@ use PhpParser\Node\Expr\Array_; use PhpParser\Node\Expr\ArrayItem; final class ArraySpreadAnalyzer { - public function isArrayWithUnpack(\PhpParser\Node\Expr\Array_ $array) : bool + public function isArrayWithUnpack(Array_ $array) : bool { // Check that any item in the array is the spread foreach ($array->items as $item) { - if (!$item instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$item instanceof ArrayItem) { continue; } if ($item->unpack) { diff --git a/rules/DowngradePhp81/NodeFactory/ArrayMergeFromArraySpreadFactory.php b/rules/DowngradePhp81/NodeFactory/ArrayMergeFromArraySpreadFactory.php index 38939367eaf..4571bc83b51 100644 --- a/rules/DowngradePhp81/NodeFactory/ArrayMergeFromArraySpreadFactory.php +++ b/rules/DowngradePhp81/NodeFactory/ArrayMergeFromArraySpreadFactory.php @@ -62,7 +62,7 @@ final class ArrayMergeFromArraySpreadFactory * @var \Rector\DowngradePhp81\NodeAnalyzer\ArraySpreadAnalyzer */ private $arraySpreadAnalyzer; - public function __construct(\Rector\Naming\Naming\VariableNaming $variableNaming, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\PostRector\Collector\NodesToAddCollector $nodesToAddCollector, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\DowngradePhp81\NodeAnalyzer\ArraySpreadAnalyzer $arraySpreadAnalyzer) + public function __construct(VariableNaming $variableNaming, BetterNodeFinder $betterNodeFinder, NodesToAddCollector $nodesToAddCollector, NodeNameResolver $nodeNameResolver, ArraySpreadAnalyzer $arraySpreadAnalyzer) { $this->variableNaming = $variableNaming; $this->betterNodeFinder = $betterNodeFinder; @@ -70,7 +70,7 @@ final class ArrayMergeFromArraySpreadFactory $this->nodeNameResolver = $nodeNameResolver; $this->arraySpreadAnalyzer = $arraySpreadAnalyzer; } - public function createFromArray(\PhpParser\Node\Expr\Array_ $array, \PHPStan\Analyser\Scope $scope, \Rector\Core\ValueObject\Application\File $file, ?bool $shouldIncrement = null) : ?\PhpParser\Node + public function createFromArray(Array_ $array, Scope $scope, File $file, ?bool $shouldIncrement = null) : ?Node { if (!$this->arraySpreadAnalyzer->isArrayWithUnpack($array)) { return null; @@ -78,8 +78,8 @@ final class ArrayMergeFromArraySpreadFactory if ($shouldIncrement !== null) { $this->shouldIncrement = $shouldIncrement; } else { - $this->shouldIncrement = (bool) $this->betterNodeFinder->findFirstNext($array, function (\PhpParser\Node $subNode) : bool { - if (!$subNode instanceof \PhpParser\Node\Expr\Array_) { + $this->shouldIncrement = (bool) $this->betterNodeFinder->findFirstNext($array, function (Node $subNode) : bool { + if (!$subNode instanceof Array_) { return \false; } return $this->arraySpreadAnalyzer->isArrayWithUnpack($subNode); @@ -96,14 +96,14 @@ final class ArrayMergeFromArraySpreadFactory * to be added once the next spread is found, or at the end * @return ArrayItem[] */ - private function disolveArrayItems(\PhpParser\Node\Expr\Array_ $array, \PHPStan\Analyser\Scope $scope, \Rector\Core\ValueObject\Application\File $file) : array + private function disolveArrayItems(Array_ $array, Scope $scope, File $file) : array { $newItems = []; $accumulatedItems = []; foreach ($array->items as $position => $item) { if ($item !== null && $item->unpack) { // Spread operator found - if (!$item->value instanceof \PhpParser\Node\Expr\Variable) { + if (!$item->value instanceof Variable) { // If it is a not variable, transform it to a variable $item->value = $this->createVariableFromNonVariable($array, $item, $position, $scope, $file); } @@ -129,17 +129,17 @@ final class ArrayMergeFromArraySpreadFactory /** * @param ArrayItem[] $arrayItems */ - private function createArrayMergeFuncCall(array $arrayItems, \PHPStan\Analyser\Scope $scope) : \PhpParser\Node\Expr\FuncCall + private function createArrayMergeFuncCall(array $arrayItems, Scope $scope) : FuncCall { - $args = \array_map(function (\PhpParser\Node\Expr\ArrayItem $arrayItem) use($scope) : Arg { + $args = \array_map(function (ArrayItem $arrayItem) use($scope) : Arg { if ($arrayItem->unpack) { // Do not unpack anymore $arrayItem->unpack = \false; return $this->createArgFromSpreadArrayItem($scope, $arrayItem); } - return new \PhpParser\Node\Arg($arrayItem); + return new Arg($arrayItem); }, $arrayItems); - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('array_merge'), $args); + return new FuncCall(new Name('array_merge'), $args); } /** * If it is a variable, we add it directly @@ -148,7 +148,7 @@ final class ArrayMergeFromArraySpreadFactory * as to invoke it only once and avoid potential bugs, * such as a method executing some side-effect */ - private function createVariableFromNonVariable(\PhpParser\Node\Expr\Array_ $array, \PhpParser\Node\Expr\ArrayItem $arrayItem, int $position, \PHPStan\Analyser\Scope $scope, \Rector\Core\ValueObject\Application\File $file) : \PhpParser\Node\Expr\Variable + private function createVariableFromNonVariable(Array_ $array, ArrayItem $arrayItem, int $position, Scope $scope, File $file) : Variable { // The variable name will be item0Unpacked, item1Unpacked, etc, // depending on their position. @@ -162,20 +162,20 @@ final class ArrayMergeFromArraySpreadFactory $this->lastPositionCurrentFile[$realPath] = ++$position; } // Assign the value to the variable, and replace the element with the variable - $newVariable = new \PhpParser\Node\Expr\Variable($variableName); - $newVariableAssign = new \PhpParser\Node\Expr\Assign($newVariable, $arrayItem->value); + $newVariable = new Variable($variableName); + $newVariableAssign = new Assign($newVariable, $arrayItem->value); $this->nodesToAddCollector->addNodeBeforeNode($newVariableAssign, $array, $file->getSmartFileInfo()); return $newVariable; } /** * @param array $items */ - private function createArrayItemFromArray(array $items) : \PhpParser\Node\Expr\ArrayItem + private function createArrayItemFromArray(array $items) : ArrayItem { - $array = new \PhpParser\Node\Expr\Array_($items); - return new \PhpParser\Node\Expr\ArrayItem($array); + $array = new Array_($items); + return new ArrayItem($array); } - private function createArgFromSpreadArrayItem(\PHPStan\Analyser\Scope $nodeScope, \PhpParser\Node\Expr\ArrayItem $arrayItem) : \PhpParser\Node\Arg + private function createArgFromSpreadArrayItem(Scope $nodeScope, ArrayItem $arrayItem) : Arg { // By now every item is a variable /** @var Variable $variable */ @@ -186,38 +186,38 @@ final class ArrayMergeFromArraySpreadFactory if ($nodeScope->hasVariableType($variableName)->yes()) { $type = $nodeScope->getVariableType($variableName); } else { - $originalNode = $arrayItem->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE); - if ($originalNode instanceof \PhpParser\Node\Expr\ArrayItem) { + $originalNode = $arrayItem->getAttribute(AttributeKey::ORIGINAL_NODE); + if ($originalNode instanceof ArrayItem) { $type = $nodeScope->getType($originalNode->value); } else { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } } - $iteratorToArrayFuncCall = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('iterator_to_array'), [new \PhpParser\Node\Arg($arrayItem)]); + $iteratorToArrayFuncCall = new FuncCall(new Name('iterator_to_array'), [new Arg($arrayItem)]); // If we know it is an array, then print it directly // Otherwise PHPStan throws an error: // "Else branch is unreachable because ternary operator condition is always true." - if ($type instanceof \PHPStan\Type\ArrayType) { - return new \PhpParser\Node\Arg($arrayItem); + if ($type instanceof ArrayType) { + return new Arg($arrayItem); } // If it is iterable, then directly return `iterator_to_array` if ($this->isIterableType($type)) { - return new \PhpParser\Node\Arg($iteratorToArrayFuncCall); + return new Arg($iteratorToArrayFuncCall); } // Print a ternary, handling either an array or an iterator - $inArrayFuncCall = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('is_array'), [new \PhpParser\Node\Arg($arrayItem)]); - return new \PhpParser\Node\Arg(new \PhpParser\Node\Expr\Ternary($inArrayFuncCall, $arrayItem, $iteratorToArrayFuncCall)); + $inArrayFuncCall = new FuncCall(new Name('is_array'), [new Arg($arrayItem)]); + return new Arg(new Ternary($inArrayFuncCall, $arrayItem, $iteratorToArrayFuncCall)); } /** * Iterables: objects declaring the interface Traversable, * For "iterable" type, it can be array */ - private function isIterableType(\PHPStan\Type\Type $type) : bool + private function isIterableType(Type $type) : bool { - if ($type instanceof \PHPStan\Type\IterableType) { + if ($type instanceof IterableType) { return \false; } - $traversableObjectType = new \PHPStan\Type\ObjectType('Traversable'); + $traversableObjectType = new ObjectType('Traversable'); return $traversableObjectType->isSuperTypeOf($type)->yes(); } } diff --git a/rules/DowngradePhp81/NodeManipulator/ObjectToResourceReturn.php b/rules/DowngradePhp81/NodeManipulator/ObjectToResourceReturn.php index 54cc35d5988..f5991a71ae7 100644 --- a/rules/DowngradePhp81/NodeManipulator/ObjectToResourceReturn.php +++ b/rules/DowngradePhp81/NodeManipulator/ObjectToResourceReturn.php @@ -38,7 +38,7 @@ final class ObjectToResourceReturn * @var \Rector\Core\PhpParser\Node\NodeFactory */ private $nodeFactory; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver, NodeComparator $nodeComparator, NodeFactory $nodeFactory) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeNameResolver = $nodeNameResolver; @@ -48,9 +48,9 @@ final class ObjectToResourceReturn /** * @param string[] $collectionObjectToResource */ - public function refactor(\PhpParser\Node\Expr\Instanceof_ $instanceof, array $collectionObjectToResource) : ?\PhpParser\Node\Expr\BinaryOp\BooleanOr + public function refactor(Instanceof_ $instanceof, array $collectionObjectToResource) : ?BooleanOr { - if (!$instanceof->class instanceof \PhpParser\Node\Name\FullyQualified) { + if (!$instanceof->class instanceof FullyQualified) { return null; } $className = $instanceof->class->toString(); @@ -58,22 +58,22 @@ final class ObjectToResourceReturn if ($singleCollectionObjectToResource !== $className) { continue; } - $binaryOp = $this->betterNodeFinder->findParentType($instanceof, \PhpParser\Node\Expr\BinaryOp::class); + $binaryOp = $this->betterNodeFinder->findParentType($instanceof, BinaryOp::class); if ($this->hasIsResourceCheck($instanceof->expr, $binaryOp)) { continue; } - return new \PhpParser\Node\Expr\BinaryOp\BooleanOr($this->nodeFactory->createFuncCall('is_resource', [$instanceof->expr]), $instanceof); + return new BooleanOr($this->nodeFactory->createFuncCall('is_resource', [$instanceof->expr]), $instanceof); } return null; } - private function hasIsResourceCheck(\PhpParser\Node\Expr $expr, ?\PhpParser\Node\Expr\BinaryOp $binaryOp) : bool + private function hasIsResourceCheck(Expr $expr, ?BinaryOp $binaryOp) : bool { - if ($binaryOp instanceof \PhpParser\Node\Expr\BinaryOp) { - return (bool) $this->betterNodeFinder->findFirst($binaryOp, function (\PhpParser\Node $subNode) use($expr) : bool { - if (!$subNode instanceof \PhpParser\Node\Expr\FuncCall) { + if ($binaryOp instanceof BinaryOp) { + return (bool) $this->betterNodeFinder->findFirst($binaryOp, function (Node $subNode) use($expr) : bool { + if (!$subNode instanceof FuncCall) { return \false; } - if (!$subNode->name instanceof \PhpParser\Node\Name) { + if (!$subNode->name instanceof Name) { return \false; } if (!$this->nodeNameResolver->isName($subNode->name, 'is_resource')) { @@ -82,7 +82,7 @@ final class ObjectToResourceReturn if (!isset($subNode->args[0])) { return \false; } - if (!$subNode->args[0] instanceof \PhpParser\Node\Arg) { + if (!$subNode->args[0] instanceof Arg) { return \false; } return $this->nodeComparator->areNodesEqual($subNode->args[0], $expr); diff --git a/rules/DowngradePhp81/Rector/Array_/DowngradeArraySpreadStringKeyRector.php b/rules/DowngradePhp81/Rector/Array_/DowngradeArraySpreadStringKeyRector.php index 584896ac42d..f1ab5e620fb 100644 --- a/rules/DowngradePhp81/Rector/Array_/DowngradeArraySpreadStringKeyRector.php +++ b/rules/DowngradePhp81/Rector/Array_/DowngradeArraySpreadStringKeyRector.php @@ -12,14 +12,14 @@ use PHPStan\Type\IntegerType; use Rector\Core\Rector\AbstractScopeAwareRector; use Rector\DowngradePhp81\NodeAnalyzer\ArraySpreadAnalyzer; use Rector\DowngradePhp81\NodeFactory\ArrayMergeFromArraySpreadFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/array_unpacking_string_keys * * @see \Rector\Tests\DowngradePhp81\Rector\Array_\DowngradeArraySpreadStringKeyRector\DowngradeArraySpreadStringKeyRectorTest */ -final class DowngradeArraySpreadStringKeyRector extends \Rector\Core\Rector\AbstractScopeAwareRector +final class DowngradeArraySpreadStringKeyRector extends AbstractScopeAwareRector { /** * @readonly @@ -31,14 +31,14 @@ final class DowngradeArraySpreadStringKeyRector extends \Rector\Core\Rector\Abst * @var \Rector\DowngradePhp81\NodeAnalyzer\ArraySpreadAnalyzer */ private $arraySpreadAnalyzer; - public function __construct(\Rector\DowngradePhp81\NodeFactory\ArrayMergeFromArraySpreadFactory $arrayMergeFromArraySpreadFactory, \Rector\DowngradePhp81\NodeAnalyzer\ArraySpreadAnalyzer $arraySpreadAnalyzer) + public function __construct(ArrayMergeFromArraySpreadFactory $arrayMergeFromArraySpreadFactory, ArraySpreadAnalyzer $arraySpreadAnalyzer) { $this->arrayMergeFromArraySpreadFactory = $arrayMergeFromArraySpreadFactory; $this->arraySpreadAnalyzer = $arraySpreadAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace array spread with string key to array_merge function', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace array spread with string key to array_merge function', [new CodeSample(<<<'CODE_SAMPLE' $parts = ['a' => 'b']; $parts2 = ['c' => 'd']; @@ -57,33 +57,33 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Array_::class]; + return [Array_::class]; } /** * @param Array_ $node */ - public function refactorWithScope(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : ?\PhpParser\Node + public function refactorWithScope(Node $node, Scope $scope) : ?Node { if ($this->shouldSkipArray($node)) { return null; } return $this->arrayMergeFromArraySpreadFactory->createFromArray($node, $scope, $this->file); } - private function shouldSkipArray(\PhpParser\Node\Expr\Array_ $array) : bool + private function shouldSkipArray(Array_ $array) : bool { if (!$this->arraySpreadAnalyzer->isArrayWithUnpack($array)) { return \true; } foreach ($array->items as $item) { - if (!$item instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$item instanceof ArrayItem) { continue; } $type = $this->nodeTypeResolver->getType($item->value); - if (!$type instanceof \PHPStan\Type\ArrayType) { + if (!$type instanceof ArrayType) { continue; } $keyType = $type->getKeyType(); - if ($keyType instanceof \PHPStan\Type\IntegerType) { + if ($keyType instanceof IntegerType) { return \true; } } diff --git a/rules/DowngradePhp81/Rector/ClassConst/DowngradeFinalizePublicClassConstantRector.php b/rules/DowngradePhp81/Rector/ClassConst/DowngradeFinalizePublicClassConstantRector.php index 9377655beaf..7408607b9d4 100644 --- a/rules/DowngradePhp81/Rector/ClassConst/DowngradeFinalizePublicClassConstantRector.php +++ b/rules/DowngradePhp81/Rector/ClassConst/DowngradeFinalizePublicClassConstantRector.php @@ -7,27 +7,27 @@ use PhpParser\Node; use PhpParser\Node\Stmt\ClassConst; use Rector\Core\Rector\AbstractRector; use Rector\Privatization\NodeManipulator\VisibilityManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://php.watch/versions/8.1/final-class-const * * @see \Rector\Tests\DowngradePhp81\Rector\ClassConst\DowngradeFinalizePublicClassConstantRector\DowngradeFinalizePublicClassConstantRectorTest */ -final class DowngradeFinalizePublicClassConstantRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeFinalizePublicClassConstantRector extends AbstractRector { /** * @readonly * @var \Rector\Privatization\NodeManipulator\VisibilityManipulator */ private $visibilityManipulator; - public function __construct(\Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator) + public function __construct(VisibilityManipulator $visibilityManipulator) { $this->visibilityManipulator = $visibilityManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove final from class constants', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove final from class constants', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { final public const NAME = 'value'; @@ -46,12 +46,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassConst::class]; + return [ClassConst::class]; } /** * @param ClassConst $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$node->isFinal()) { return null; diff --git a/rules/DowngradePhp81/Rector/FuncCall/DowngradeArrayIsListRector.php b/rules/DowngradePhp81/Rector/FuncCall/DowngradeArrayIsListRector.php index 7a76e548835..e310bd56723 100644 --- a/rules/DowngradePhp81/Rector/FuncCall/DowngradeArrayIsListRector.php +++ b/rules/DowngradePhp81/Rector/FuncCall/DowngradeArrayIsListRector.php @@ -15,14 +15,14 @@ use Rector\Core\PhpParser\Parser\InlineCodeParser; use Rector\Core\Rector\AbstractScopeAwareRector; use Rector\DowngradePhp72\NodeAnalyzer\FunctionExistsFunCallAnalyzer; use Rector\Naming\Naming\VariableNaming; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/is_list * * @see \Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeArrayIsListRector\DowngradeArrayIsListRectorTest */ -final class DowngradeArrayIsListRector extends \Rector\Core\Rector\AbstractScopeAwareRector +final class DowngradeArrayIsListRector extends AbstractScopeAwareRector { /** * @var \PhpParser\Node\Expr\Closure|null @@ -43,15 +43,15 @@ final class DowngradeArrayIsListRector extends \Rector\Core\Rector\AbstractScope * @var \Rector\Naming\Naming\VariableNaming */ private $variableNaming; - public function __construct(\Rector\Core\PhpParser\Parser\InlineCodeParser $inlineCodeParser, \Rector\DowngradePhp72\NodeAnalyzer\FunctionExistsFunCallAnalyzer $functionExistsFunCallAnalyzer, \Rector\Naming\Naming\VariableNaming $variableNaming) + public function __construct(InlineCodeParser $inlineCodeParser, FunctionExistsFunCallAnalyzer $functionExistsFunCallAnalyzer, VariableNaming $variableNaming) { $this->inlineCodeParser = $inlineCodeParser; $this->functionExistsFunCallAnalyzer = $functionExistsFunCallAnalyzer; $this->variableNaming = $variableNaming; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace array_is_list() function', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace array_is_list() function', [new CodeSample(<<<'CODE_SAMPLE' array_is_list([1 => 'apple', 'orange']); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -80,38 +80,38 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactorWithScope(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : ?\PhpParser\Node\Expr\FuncCall + public function refactorWithScope(Node $node, Scope $scope) : ?FuncCall { if ($this->shouldSkip($node)) { return null; } - $variable = new \PhpParser\Node\Expr\Variable($this->variableNaming->createCountedValueName('arrayIsList', $scope)); + $variable = new Variable($this->variableNaming->createCountedValueName('arrayIsList', $scope)); $function = $this->createClosure(); - $expression = new \PhpParser\Node\Stmt\Expression(new \PhpParser\Node\Expr\Assign($variable, $function)); + $expression = new Expression(new Assign($variable, $function)); $this->nodesToAddCollector->addNodeBeforeNode($expression, $node, $this->file->getSmartFileInfo()); - return new \PhpParser\Node\Expr\FuncCall($variable, $node->args); + return new FuncCall($variable, $node->args); } - private function createClosure() : \PhpParser\Node\Expr\Closure + private function createClosure() : Closure { - if ($this->cachedClosure instanceof \PhpParser\Node\Expr\Closure) { + if ($this->cachedClosure instanceof Closure) { return clone $this->cachedClosure; } $stmts = $this->inlineCodeParser->parse(__DIR__ . '/../../snippet/array_is_list_closure.php.inc'); /** @var Expression $expression */ $expression = $stmts[0]; $expr = $expression->expr; - if (!$expr instanceof \PhpParser\Node\Expr\Closure) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$expr instanceof Closure) { + throw new ShouldNotHappenException(); } $this->cachedClosure = $expr; return $expr; } - private function shouldSkip(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function shouldSkip(FuncCall $funcCall) : bool { if (!$this->nodeNameResolver->isName($funcCall, 'array_is_list')) { return \true; diff --git a/rules/DowngradePhp81/Rector/FuncCall/DowngradeFirstClassCallableSyntaxRector.php b/rules/DowngradePhp81/Rector/FuncCall/DowngradeFirstClassCallableSyntaxRector.php index c875e41b760..a92c60f7afd 100644 --- a/rules/DowngradePhp81/Rector/FuncCall/DowngradeFirstClassCallableSyntaxRector.php +++ b/rules/DowngradePhp81/Rector/FuncCall/DowngradeFirstClassCallableSyntaxRector.php @@ -18,18 +18,18 @@ use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\Scalar\String_; use PhpParser\Node\VariadicPlaceholder; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/first_class_callable_syntax * * @see \Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeFirstClassCallableSyntaxRector\DowngradeFirstClassCallableSyntaxRectorTest */ -final class DowngradeFirstClassCallableSyntaxRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeFirstClassCallableSyntaxRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace variadic placeholders usage by Closure::fromCallable()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace variadic placeholders usage by Closure::fromCallable()', [new CodeSample(<<<'CODE_SAMPLE' $cb = strlen(...); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -42,12 +42,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [FuncCall::class, MethodCall::class, StaticCall::class]; } /** * @param FuncCall|MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Expr\StaticCall + public function refactor(Node $node) : ?StaticCall { if ($this->shouldSkip($node)) { return null; @@ -63,28 +63,28 @@ CODE_SAMPLE if (\count($node->getRawArgs()) !== 1) { return \true; } - return !$node->args[0] instanceof \PhpParser\Node\VariadicPlaceholder; + return !$node->args[0] instanceof VariadicPlaceholder; } /** * @param \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node */ - private function createCallback($node) : \PhpParser\Node\Expr + private function createCallback($node) : Expr { - if ($node instanceof \PhpParser\Node\Expr\FuncCall) { - return $node->name instanceof \PhpParser\Node\Name ? new \PhpParser\Node\Scalar\String_($node->name->toString()) : $node->name; + if ($node instanceof FuncCall) { + return $node->name instanceof Name ? new String_($node->name->toString()) : $node->name; } - if ($node instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node instanceof MethodCall) { $object = $node->var; - $method = $node->name instanceof \PhpParser\Node\Identifier ? new \PhpParser\Node\Scalar\String_($node->name->toString()) : $node->name; - return new \PhpParser\Node\Expr\Array_([new \PhpParser\Node\Expr\ArrayItem($object), new \PhpParser\Node\Expr\ArrayItem($method)]); + $method = $node->name instanceof Identifier ? new String_($node->name->toString()) : $node->name; + return new Array_([new ArrayItem($object), new ArrayItem($method)]); } // StaticCall - $class = $node->class instanceof \PhpParser\Node\Name ? new \PhpParser\Node\Expr\ClassConstFetch($node->class, 'class') : $node->class; - $method = $node->name instanceof \PhpParser\Node\Identifier ? new \PhpParser\Node\Scalar\String_($node->name->toString()) : $node->name; + $class = $node->class instanceof Name ? new ClassConstFetch($node->class, 'class') : $node->class; + $method = $node->name instanceof Identifier ? new String_($node->name->toString()) : $node->name; return $this->nodeFactory->createArray([$class, $method]); } - private function createClosureFromCallableCall(\PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr\StaticCall + private function createClosureFromCallableCall(Expr $expr) : StaticCall { - return new \PhpParser\Node\Expr\StaticCall(new \PhpParser\Node\Name\FullyQualified('Closure'), 'fromCallable', [new \PhpParser\Node\Arg($expr)]); + return new StaticCall(new FullyQualified('Closure'), 'fromCallable', [new Arg($expr)]); } } diff --git a/rules/DowngradePhp81/Rector/FunctionLike/DowngradeNeverTypeDeclarationRector.php b/rules/DowngradePhp81/Rector/FunctionLike/DowngradeNeverTypeDeclarationRector.php index 08914494c74..71a6d23fdde 100644 --- a/rules/DowngradePhp81/Rector/FunctionLike/DowngradeNeverTypeDeclarationRector.php +++ b/rules/DowngradePhp81/Rector/FunctionLike/DowngradeNeverTypeDeclarationRector.php @@ -10,21 +10,21 @@ use PhpParser\Node\Stmt\Function_; use PHPStan\Type\NeverType; use Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/noreturn_type * * @see \Rector\Tests\DowngradePhp81\Rector\FunctionLike\DowngradeNeverTypeDeclarationRector\DowngradeNeverTypeDeclarationRectorTest */ -final class DowngradeNeverTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeNeverTypeDeclarationRector extends AbstractRector { /** * @readonly * @var \Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator */ private $phpDocFromTypeDeclarationDecorator; - public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator) + public function __construct(PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator) { $this->phpDocFromTypeDeclarationDecorator = $phpDocFromTypeDeclarationDecorator; } @@ -33,11 +33,11 @@ final class DowngradeNeverTypeDeclarationRector extends \Rector\Core\Rector\Abst */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Expr\Closure::class]; + return [Function_::class, ClassMethod::class, Closure::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove "never" return type, add a "@return never" tag instead', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove "never" return type, add a "@return never" tag instead', [new CodeSample(<<<'CODE_SAMPLE' function someFunction(): never { } @@ -55,9 +55,9 @@ CODE_SAMPLE /** * @param ClassMethod|Closure|Function_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $neverType = new \PHPStan\Type\NeverType(); + $neverType = new NeverType(); if (!$this->phpDocFromTypeDeclarationDecorator->decorateReturnWithSpecificType($node, $neverType)) { return null; } diff --git a/rules/DowngradePhp81/Rector/FunctionLike/DowngradeNewInInitializerRector.php b/rules/DowngradePhp81/Rector/FunctionLike/DowngradeNewInInitializerRector.php index 74f69b9553f..ff268dca8ea 100644 --- a/rules/DowngradePhp81/Rector/FunctionLike/DowngradeNewInInitializerRector.php +++ b/rules/DowngradePhp81/Rector/FunctionLike/DowngradeNewInInitializerRector.php @@ -29,27 +29,27 @@ use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\MethodName; use Rector\Php72\NodeFactory\AnonymousFunctionFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/new_in_initializers * * @see \Rector\Tests\DowngradePhp81\Rector\FunctionLike\DowngradeNewInInitializerRector\DowngradeNewInInitializerRectorTest */ -final class DowngradeNewInInitializerRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeNewInInitializerRector extends AbstractRector { /** * @readonly * @var \Rector\Php72\NodeFactory\AnonymousFunctionFactory */ private $anonymousFunctionFactory; - public function __construct(\Rector\Php72\NodeFactory\AnonymousFunctionFactory $anonymousFunctionFactory) + public function __construct(AnonymousFunctionFactory $anonymousFunctionFactory) { $this->anonymousFunctionFactory = $anonymousFunctionFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace New in initializers', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace New in initializers', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function __construct( @@ -75,12 +75,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\FunctionLike::class]; + return [FunctionLike::class]; } /** * @param FunctionLike $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\FunctionLike + public function refactor(Node $node) : ?FunctionLike { if ($this->shouldSkip($node)) { return null; @@ -89,7 +89,7 @@ CODE_SAMPLE $node = $this->convertArrowFunctionToClosure($node); return $this->replaceNewInParams($node); } - private function shouldSkip(\PhpParser\Node\FunctionLike $functionLike) : bool + private function shouldSkip(FunctionLike $functionLike) : bool { foreach ($functionLike->getParams() as $param) { if ($this->isParamSkipped($param)) { @@ -99,24 +99,24 @@ CODE_SAMPLE } return \true; } - private function convertArrowFunctionToClosure(\PhpParser\Node\FunctionLike $functionLike) : \PhpParser\Node\FunctionLike + private function convertArrowFunctionToClosure(FunctionLike $functionLike) : FunctionLike { - if (!$functionLike instanceof \PhpParser\Node\Expr\ArrowFunction) { + if (!$functionLike instanceof ArrowFunction) { return $functionLike; } - $stmts = [new \PhpParser\Node\Stmt\Return_($functionLike->expr)]; + $stmts = [new Return_($functionLike->expr)]; return $this->anonymousFunctionFactory->create($functionLike->params, $stmts, $functionLike->returnType, $functionLike->static); } - private function isParamSkipped(\PhpParser\Node\Param $param) : bool + private function isParamSkipped(Param $param) : bool { if ($param->default === null) { return \true; } - $hasNew = (bool) $this->betterNodeFinder->findFirstInstanceOf($param->default, \PhpParser\Node\Expr\New_::class); + $hasNew = (bool) $this->betterNodeFinder->findFirstInstanceOf($param->default, New_::class); if (!$hasNew) { return \true; } - return $param->type instanceof \PhpParser\Node\IntersectionType; + return $param->type instanceof IntersectionType; } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Expr\Closure|\PhpParser\Node\Stmt\Function_ $functionLike @@ -124,7 +124,7 @@ CODE_SAMPLE */ private function replaceNewInParams($functionLike) { - $isConstructor = $functionLike instanceof \PhpParser\Node\Stmt\ClassMethod && $this->isName($functionLike, \Rector\Core\ValueObject\MethodName::CONSTRUCT); + $isConstructor = $functionLike instanceof ClassMethod && $this->isName($functionLike, MethodName::CONSTRUCT); $stmts = []; foreach ($functionLike->getParams() as $param) { if ($this->isParamSkipped($param)) { @@ -134,16 +134,16 @@ CODE_SAMPLE $default = $param->default; // check for property promotion if ($isConstructor && $param->flags > 0) { - $propertyFetch = new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable('this'), $param->var->name); - $coalesce = new \PhpParser\Node\Expr\BinaryOp\Coalesce($param->var, $default); - $assign = new \PhpParser\Node\Expr\Assign($propertyFetch, $coalesce); + $propertyFetch = new PropertyFetch(new Variable('this'), $param->var->name); + $coalesce = new Coalesce($param->var, $default); + $assign = new Assign($propertyFetch, $coalesce); if ($param->type !== null) { $param->type = $this->ensureNullableType($param->type); } } else { - $assign = new \PhpParser\Node\Expr\AssignOp\Coalesce($param->var, $default); + $assign = new AssignCoalesce($param->var, $default); } - $stmts[] = new \PhpParser\Node\Stmt\Expression($assign); + $stmts[] = new Expression($assign); $param->default = $this->nodeFactory->createNull(); } $functionLike->stmts = $functionLike->stmts ?? []; @@ -156,21 +156,21 @@ CODE_SAMPLE */ private function ensureNullableType($type) { - if ($type instanceof \PhpParser\Node\NullableType) { + if ($type instanceof NullableType) { return $type; } - if (!$type instanceof \PhpParser\Node\ComplexType) { - return new \PhpParser\Node\NullableType($type); + if (!$type instanceof ComplexType) { + return new NullableType($type); } - if ($type instanceof \PhpParser\Node\UnionType) { + if ($type instanceof UnionType) { if (!$this->hasNull($type)) { - $type->types[] = new \PhpParser\Node\Name('null'); + $type->types[] = new Name('null'); } return $type; } - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } - private function hasNull(\PhpParser\Node\UnionType $unionType) : bool + private function hasNull(UnionType $unionType) : bool { foreach ($unionType->types as $type) { if ($type->toLowerString() === 'null') { diff --git a/rules/DowngradePhp81/Rector/FunctionLike/DowngradePureIntersectionTypeRector.php b/rules/DowngradePhp81/Rector/FunctionLike/DowngradePureIntersectionTypeRector.php index 47182376a52..36e061a2f08 100644 --- a/rules/DowngradePhp81/Rector/FunctionLike/DowngradePureIntersectionTypeRector.php +++ b/rules/DowngradePhp81/Rector/FunctionLike/DowngradePureIntersectionTypeRector.php @@ -11,21 +11,21 @@ use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Function_; use Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/pure-intersection-types * * @see \Rector\Tests\DowngradePhp81\Rector\FunctionLike\DowngradePureIntersectionTypeRector\DowngradePureIntersectionTypeRectorTest */ -final class DowngradePureIntersectionTypeRector extends \Rector\Core\Rector\AbstractRector +final class DowngradePureIntersectionTypeRector extends AbstractRector { /** * @readonly * @var \Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator */ private $phpDocFromTypeDeclarationDecorator; - public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator) + public function __construct(PhpDocFromTypeDeclarationDecorator $phpDocFromTypeDeclarationDecorator) { $this->phpDocFromTypeDeclarationDecorator = $phpDocFromTypeDeclarationDecorator; } @@ -34,11 +34,11 @@ final class DowngradePureIntersectionTypeRector extends \Rector\Core\Rector\Abst */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\ArrowFunction::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Expr\Closure::class, \PhpParser\Node\Stmt\Function_::class]; + return [ArrowFunction::class, ClassMethod::class, Closure::class, Function_::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove the intersection type params and returns, add @param/@return tags instead', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove the intersection type params and returns, add @param/@return tags instead', [new CodeSample(<<<'CODE_SAMPLE' function someFunction(): Foo&Bar { } @@ -56,17 +56,17 @@ CODE_SAMPLE /** * @param ArrowFunction|ClassMethod|Closure|Function_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $paramDecorated = \false; foreach ($node->getParams() as $param) { - if (!$param->type instanceof \PhpParser\Node\IntersectionType) { + if (!$param->type instanceof IntersectionType) { continue; } $this->phpDocFromTypeDeclarationDecorator->decorateParam($param, $node, [\PHPStan\Type\IntersectionType::class]); $paramDecorated = \true; } - if (!$node->returnType instanceof \PhpParser\Node\IntersectionType) { + if (!$node->returnType instanceof IntersectionType) { if ($paramDecorated) { return $node; } diff --git a/rules/DowngradePhp81/Rector/Instanceof_/DowngradePhp81ResourceReturnToObjectRector.php b/rules/DowngradePhp81/Rector/Instanceof_/DowngradePhp81ResourceReturnToObjectRector.php index 8ae5736731f..431f780eef7 100644 --- a/rules/DowngradePhp81/Rector/Instanceof_/DowngradePhp81ResourceReturnToObjectRector.php +++ b/rules/DowngradePhp81/Rector/Instanceof_/DowngradePhp81ResourceReturnToObjectRector.php @@ -8,14 +8,14 @@ use PhpParser\Node; use PhpParser\Node\Expr\Instanceof_; use Rector\Core\Rector\AbstractRector; use Rector\DowngradePhp81\NodeManipulator\ObjectToResourceReturn; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/migration81.incompatible.php#migration81.incompatible.resource2object * * @see \Rector\Tests\DowngradePhp81\Rector\Instanceof_\DowngradePhp81ResourceReturnToObjectRector\DowngradePhp81ResourceReturnToObjectRectorTest */ -final class DowngradePhp81ResourceReturnToObjectRector extends \Rector\Core\Rector\AbstractRector +final class DowngradePhp81ResourceReturnToObjectRector extends AbstractRector { /** * @var string[]|class-string[] @@ -44,13 +44,13 @@ final class DowngradePhp81ResourceReturnToObjectRector extends \Rector\Core\Rect * @var \Rector\DowngradePhp81\NodeManipulator\ObjectToResourceReturn */ private $objectToResourceReturn; - public function __construct(\Rector\DowngradePhp81\NodeManipulator\ObjectToResourceReturn $objectToResourceReturn) + public function __construct(ObjectToResourceReturn $objectToResourceReturn) { $this->objectToResourceReturn = $objectToResourceReturn; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('change instanceof Object to is_resource', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('change instanceof Object to is_resource', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($obj) @@ -75,12 +75,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Instanceof_::class]; + return [Instanceof_::class]; } /** * @param Instanceof_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { return $this->objectToResourceReturn->refactor($node, self::COLLECTION_OBJECT_TO_RESOURCE); } diff --git a/rules/DowngradePhp81/Rector/Property/DowngradeReadonlyPropertyRector.php b/rules/DowngradePhp81/Rector/Property/DowngradeReadonlyPropertyRector.php index 49b0ab7f316..f172fe953b7 100644 --- a/rules/DowngradePhp81/Rector/Property/DowngradeReadonlyPropertyRector.php +++ b/rules/DowngradePhp81/Rector/Property/DowngradeReadonlyPropertyRector.php @@ -10,14 +10,14 @@ use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode; use Rector\Core\Rector\AbstractRector; use Rector\Privatization\NodeManipulator\VisibilityManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/readonly_properties_v2 * * @see \Rector\Tests\DowngradePhp81\Rector\Property\DowngradeReadonlyPropertyRector\DowngradeReadonlyPropertyRectorTest */ -final class DowngradeReadonlyPropertyRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeReadonlyPropertyRector extends AbstractRector { /** * @var string @@ -28,7 +28,7 @@ final class DowngradeReadonlyPropertyRector extends \Rector\Core\Rector\Abstract * @var \Rector\Privatization\NodeManipulator\VisibilityManipulator */ private $visibilityManipulator; - public function __construct(\Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator) + public function __construct(VisibilityManipulator $visibilityManipulator) { $this->visibilityManipulator = $visibilityManipulator; } @@ -37,11 +37,11 @@ final class DowngradeReadonlyPropertyRector extends \Rector\Core\Rector\Abstract */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class, \PhpParser\Node\Param::class]; + return [Property::class, Param::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove "readonly" property type, add a "@readonly" tag instead', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove "readonly" property type, add a "@readonly" tag instead', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public readonly string $foo; @@ -71,23 +71,23 @@ CODE_SAMPLE /** * @param Property|Param $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->visibilityManipulator->isReadonly($node)) { return null; } - if ($node instanceof \PhpParser\Node\Stmt\Property) { + if ($node instanceof Property) { $this->addPhpDocTag($node); } $this->visibilityManipulator->removeReadonly($node); return $node; } - private function addPhpDocTag(\PhpParser\Node\Stmt\Property $property) : void + private function addPhpDocTag(Property $property) : void { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); if ($phpDocInfo->hasByName(self::TAGNAME)) { return; } - $phpDocInfo->addPhpDocTagNode(new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode('@' . self::TAGNAME, new \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode(''))); + $phpDocInfo->addPhpDocTagNode(new PhpDocTagNode('@' . self::TAGNAME, new GenericTagValueNode(''))); } } diff --git a/rules/DowngradePhp82/Rector/Class_/DowngradeReadonlyClassRector.php b/rules/DowngradePhp82/Rector/Class_/DowngradeReadonlyClassRector.php index d61a1a688ba..19db58f3c17 100644 --- a/rules/DowngradePhp82/Rector/Class_/DowngradeReadonlyClassRector.php +++ b/rules/DowngradePhp82/Rector/Class_/DowngradeReadonlyClassRector.php @@ -9,21 +9,21 @@ use PhpParser\Node\Stmt\ClassMethod; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\MethodName; use Rector\Privatization\NodeManipulator\VisibilityManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/readonly_classes * * @see \Rector\Tests\DowngradePhp82\Rector\Class_\DowngradeReadonlyClassRector\DowngradeReadonlyClassRectorTest */ -final class DowngradeReadonlyClassRector extends \Rector\Core\Rector\AbstractRector +final class DowngradeReadonlyClassRector extends AbstractRector { /** * @readonly * @var \Rector\Privatization\NodeManipulator\VisibilityManipulator */ private $visibilityManipulator; - public function __construct(\Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator) + public function __construct(VisibilityManipulator $visibilityManipulator) { $this->visibilityManipulator = $visibilityManipulator; } @@ -32,11 +32,11 @@ final class DowngradeReadonlyClassRector extends \Rector\Core\Rector\AbstractRec */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove "readonly" class type, decorate all properties to "readonly"', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove "readonly" class type, decorate all properties to "readonly"', [new CodeSample(<<<'CODE_SAMPLE' final readonly class SomeClass { public string $foo; @@ -63,7 +63,7 @@ CODE_SAMPLE /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->visibilityManipulator->isReadonly($node)) { return null; @@ -73,7 +73,7 @@ CODE_SAMPLE $this->makePromotedPropertiesReadonly($node); return $node; } - private function makePropertiesReadonly(\PhpParser\Node\Stmt\Class_ $class) : void + private function makePropertiesReadonly(Class_ $class) : void { foreach ($class->getProperties() as $property) { if ($property->isReadonly()) { @@ -96,10 +96,10 @@ CODE_SAMPLE $this->visibilityManipulator->makeReadonly($property); } } - private function makePromotedPropertiesReadonly(\PhpParser\Node\Stmt\Class_ $class) : void + private function makePromotedPropertiesReadonly(Class_ $class) : void { - $classMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $class->getMethod(MethodName::CONSTRUCT); + if (!$classMethod instanceof ClassMethod) { return; } foreach ($classMethod->getParams() as $param) { diff --git a/rules/EarlyReturn/NodeFactory/InvertedIfFactory.php b/rules/EarlyReturn/NodeFactory/InvertedIfFactory.php index 622fb729b38..c5389b5f5bb 100644 --- a/rules/EarlyReturn/NodeFactory/InvertedIfFactory.php +++ b/rules/EarlyReturn/NodeFactory/InvertedIfFactory.php @@ -29,7 +29,7 @@ final class InvertedIfFactory * @var \Rector\NodeNestingScope\ContextAnalyzer */ private $contextAnalyzer; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\EarlyReturn\NodeTransformer\ConditionInverter $conditionInverter, \Rector\NodeNestingScope\ContextAnalyzer $contextAnalyzer) + public function __construct(BetterNodeFinder $betterNodeFinder, ConditionInverter $conditionInverter, ContextAnalyzer $contextAnalyzer) { $this->betterNodeFinder = $betterNodeFinder; $this->conditionInverter = $conditionInverter; @@ -39,36 +39,36 @@ final class InvertedIfFactory * @param Expr[] $conditions * @return If_[] */ - public function createFromConditions(\PhpParser\Node\Stmt\If_ $if, array $conditions, \PhpParser\Node\Stmt\Return_ $return) : array + public function createFromConditions(If_ $if, array $conditions, Return_ $return) : array { $ifs = []; $ifNextReturn = $this->getIfNextReturn($if); - $stmt = $this->contextAnalyzer->isInLoop($if) && !$ifNextReturn instanceof \PhpParser\Node\Stmt\Return_ ? [new \PhpParser\Node\Stmt\Continue_()] : [$return]; - if ($ifNextReturn instanceof \PhpParser\Node\Stmt\Return_) { - $stmt[0]->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $ifNextReturn->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS)); + $stmt = $this->contextAnalyzer->isInLoop($if) && !$ifNextReturn instanceof Return_ ? [new Continue_()] : [$return]; + if ($ifNextReturn instanceof Return_) { + $stmt[0]->setAttribute(AttributeKey::COMMENTS, $ifNextReturn->getAttribute(AttributeKey::COMMENTS)); } $getNextReturnExpr = $this->getNextReturnExpr($if); - if ($getNextReturnExpr instanceof \PhpParser\Node\Stmt\Return_) { + if ($getNextReturnExpr instanceof Return_) { $return->expr = $getNextReturnExpr->expr; } foreach ($conditions as $condition) { $invertedCondition = $this->conditionInverter->createInvertedCondition($condition); - $if = new \PhpParser\Node\Stmt\If_($invertedCondition); + $if = new If_($invertedCondition); $if->stmts = $stmt; $ifs[] = $if; } return $ifs; } - private function getNextReturnExpr(\PhpParser\Node\Stmt\If_ $if) : ?\PhpParser\Node + private function getNextReturnExpr(If_ $if) : ?Node { - return $this->betterNodeFinder->findFirstNext($if, function (\PhpParser\Node $node) : bool { - return $node instanceof \PhpParser\Node\Stmt\Return_ && $node->expr instanceof \PhpParser\Node\Expr; + return $this->betterNodeFinder->findFirstNext($if, function (Node $node) : bool { + return $node instanceof Return_ && $node->expr instanceof Expr; }); } - private function getIfNextReturn(\PhpParser\Node\Stmt\If_ $if) : ?\PhpParser\Node\Stmt\Return_ + private function getIfNextReturn(If_ $if) : ?Return_ { - $nextNode = $if->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if (!$nextNode instanceof \PhpParser\Node\Stmt\Return_) { + $nextNode = $if->getAttribute(AttributeKey::NEXT_NODE); + if (!$nextNode instanceof Return_) { return null; } return $nextNode; diff --git a/rules/EarlyReturn/NodeTransformer/ConditionInverter.php b/rules/EarlyReturn/NodeTransformer/ConditionInverter.php index b0d2518bd35..d7c21ed08c9 100644 --- a/rules/EarlyReturn/NodeTransformer/ConditionInverter.php +++ b/rules/EarlyReturn/NodeTransformer/ConditionInverter.php @@ -15,26 +15,26 @@ final class ConditionInverter * @var \Rector\Core\NodeManipulator\BinaryOpManipulator */ private $binaryOpManipulator; - public function __construct(\Rector\Core\NodeManipulator\BinaryOpManipulator $binaryOpManipulator) + public function __construct(BinaryOpManipulator $binaryOpManipulator) { $this->binaryOpManipulator = $binaryOpManipulator; } - public function createInvertedCondition(\PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr + public function createInvertedCondition(Expr $expr) : Expr { // inverse condition - if ($expr instanceof \PhpParser\Node\Expr\BinaryOp) { + if ($expr instanceof BinaryOp) { $inversedCondition = $this->binaryOpManipulator->invertCondition($expr); - if (!$inversedCondition instanceof \PhpParser\Node\Expr\BinaryOp) { - return new \PhpParser\Node\Expr\BooleanNot($expr); + if (!$inversedCondition instanceof BinaryOp) { + return new BooleanNot($expr); } - if ($inversedCondition instanceof \PhpParser\Node\Expr\BinaryOp\BooleanAnd) { - return new \PhpParser\Node\Expr\BooleanNot($expr); + if ($inversedCondition instanceof BooleanAnd) { + return new BooleanNot($expr); } return $inversedCondition; } - if ($expr instanceof \PhpParser\Node\Expr\BooleanNot) { + if ($expr instanceof BooleanNot) { return $expr->expr; } - return new \PhpParser\Node\Expr\BooleanNot($expr); + return new BooleanNot($expr); } } diff --git a/rules/EarlyReturn/Rector/Foreach_/ChangeNestedForeachIfsToEarlyContinueRector.php b/rules/EarlyReturn/Rector/Foreach_/ChangeNestedForeachIfsToEarlyContinueRector.php index ec6c48f896f..21378f1d7cf 100644 --- a/rules/EarlyReturn/Rector/Foreach_/ChangeNestedForeachIfsToEarlyContinueRector.php +++ b/rules/EarlyReturn/Rector/Foreach_/ChangeNestedForeachIfsToEarlyContinueRector.php @@ -17,12 +17,12 @@ use Rector\Core\NodeManipulator\IfManipulator; use Rector\Core\Rector\AbstractRector; use Rector\EarlyReturn\NodeTransformer\ConditionInverter; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector\ChangeNestedForeachIfsToEarlyContinueRectorTest */ -final class ChangeNestedForeachIfsToEarlyContinueRector extends \Rector\Core\Rector\AbstractRector +final class ChangeNestedForeachIfsToEarlyContinueRector extends AbstractRector { /** * @readonly @@ -34,14 +34,14 @@ final class ChangeNestedForeachIfsToEarlyContinueRector extends \Rector\Core\Rec * @var \Rector\Core\NodeManipulator\IfManipulator */ private $ifManipulator; - public function __construct(\Rector\EarlyReturn\NodeTransformer\ConditionInverter $conditionInverter, \Rector\Core\NodeManipulator\IfManipulator $ifManipulator) + public function __construct(ConditionInverter $conditionInverter, IfManipulator $ifManipulator) { $this->conditionInverter = $conditionInverter; $this->ifManipulator = $ifManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change nested ifs to foreach with continue', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change nested ifs to foreach with continue', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -85,12 +85,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Foreach_::class]; + return [Foreach_::class]; } /** * @param Foreach_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $nestedIfsWithOnlyNonReturn = $this->ifManipulator->collectNestedIfsWithNonBreaking($node); if (\count($nestedIfsWithOnlyNonReturn) < 2) { @@ -101,7 +101,7 @@ CODE_SAMPLE /** * @param If_[] $nestedIfsWithOnlyReturn */ - private function processNestedIfsWithNonBreaking(\PhpParser\Node\Stmt\Foreach_ $foreach, array $nestedIfsWithOnlyReturn) : \PhpParser\Node\Stmt\Foreach_ + private function processNestedIfsWithNonBreaking(Foreach_ $foreach, array $nestedIfsWithOnlyReturn) : Foreach_ { // add nested if openly after this $nestedIfsWithOnlyReturnCount = \count($nestedIfsWithOnlyReturn); @@ -123,18 +123,18 @@ CODE_SAMPLE } return $foreach; } - private function addInvertedIfStmtWithContinue(\PhpParser\Node\Stmt\If_ $nestedIfWithOnlyReturn, \PhpParser\Node\Stmt\Foreach_ $foreach) : void + private function addInvertedIfStmtWithContinue(If_ $nestedIfWithOnlyReturn, Foreach_ $foreach) : void { $invertedCondition = $this->conditionInverter->createInvertedCondition($nestedIfWithOnlyReturn->cond); // special case - if ($invertedCondition instanceof \PhpParser\Node\Expr\BooleanNot && $invertedCondition->expr instanceof \PhpParser\Node\Expr\BinaryOp\BooleanAnd) { + if ($invertedCondition instanceof BooleanNot && $invertedCondition->expr instanceof BooleanAnd) { $leftExpr = $this->negateOrDeNegate($invertedCondition->expr->left); - $if = new \PhpParser\Node\Stmt\If_($leftExpr); - $if->stmts[] = new \PhpParser\Node\Stmt\Continue_(); + $if = new If_($leftExpr); + $if->stmts[] = new Continue_(); $foreach->stmts[] = $if; $rightExpr = $this->negateOrDeNegate($invertedCondition->expr->right); - $if = new \PhpParser\Node\Stmt\If_($rightExpr); - $if->stmts[] = new \PhpParser\Node\Stmt\Continue_(); + $if = new If_($rightExpr); + $if->stmts[] = new Continue_(); $foreach->stmts[] = $if; return; } @@ -143,9 +143,9 @@ CODE_SAMPLE $foreach->stmts[] = $nestedIfWithOnlyReturn; return; } - $nestedIfWithOnlyReturn->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $nestedIfWithOnlyReturn->setAttribute(AttributeKey::ORIGINAL_NODE, null); $nestedIfWithOnlyReturn->cond = $invertedCondition; - $nestedIfWithOnlyReturn->stmts = [new \PhpParser\Node\Stmt\Continue_()]; + $nestedIfWithOnlyReturn->stmts = [new Continue_()]; $foreach->stmts[] = $nestedIfWithOnlyReturn; } /** @@ -155,27 +155,27 @@ CODE_SAMPLE * Skips: * $a === 1 || $b === 2 */ - private function isBooleanOrWithWeakComparison(\PhpParser\Node\Expr $expr) : bool + private function isBooleanOrWithWeakComparison(Expr $expr) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { + if (!$expr instanceof BooleanOr) { return \false; } - if ($expr->left instanceof \PhpParser\Node\Expr\BinaryOp\Equal) { + if ($expr->left instanceof Equal) { return \true; } - if ($expr->left instanceof \PhpParser\Node\Expr\BinaryOp\NotEqual) { + if ($expr->left instanceof NotEqual) { return \true; } - if ($expr->right instanceof \PhpParser\Node\Expr\BinaryOp\Equal) { + if ($expr->right instanceof Equal) { return \true; } - return $expr->right instanceof \PhpParser\Node\Expr\BinaryOp\NotEqual; + return $expr->right instanceof NotEqual; } - private function negateOrDeNegate(\PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr + private function negateOrDeNegate(Expr $expr) : Expr { - if ($expr instanceof \PhpParser\Node\Expr\BooleanNot) { + if ($expr instanceof BooleanNot) { return $expr->expr; } - return new \PhpParser\Node\Expr\BooleanNot($expr); + return new BooleanNot($expr); } } diff --git a/rules/EarlyReturn/Rector/Foreach_/ReturnAfterToEarlyOnBreakRector.php b/rules/EarlyReturn/Rector/Foreach_/ReturnAfterToEarlyOnBreakRector.php index ba77cbb1595..cf1942062d1 100644 --- a/rules/EarlyReturn/Rector/Foreach_/ReturnAfterToEarlyOnBreakRector.php +++ b/rules/EarlyReturn/Rector/Foreach_/ReturnAfterToEarlyOnBreakRector.php @@ -12,16 +12,16 @@ use PhpParser\Node\Stmt\Foreach_; use PhpParser\Node\Stmt\Return_; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\EarlyReturn\Rector\Foreach_\ReturnAfterToEarlyOnBreakRector\ReturnAfterToEarlyOnBreakRectorTest */ -final class ReturnAfterToEarlyOnBreakRector extends \Rector\Core\Rector\AbstractRector +final class ReturnAfterToEarlyOnBreakRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change return after foreach to early return in foreach on break', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change return after foreach to early return in foreach on break', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(array $pathConstants, string $allowedPath) @@ -61,35 +61,35 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Foreach_::class]; + return [Foreach_::class]; } /** * @param Foreach_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { /** @var Break_[] $breaks */ - $breaks = $this->betterNodeFinder->findInstanceOf($node->stmts, \PhpParser\Node\Stmt\Break_::class); + $breaks = $this->betterNodeFinder->findInstanceOf($node->stmts, Break_::class); if (\count($breaks) !== 1) { return null; } - $beforeBreak = $breaks[0]->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_NODE); - if (!$beforeBreak instanceof \PhpParser\Node\Stmt\Expression) { + $beforeBreak = $breaks[0]->getAttribute(AttributeKey::PREVIOUS_NODE); + if (!$beforeBreak instanceof Expression) { return null; } $assign = $beforeBreak->expr; - if (!$assign instanceof \PhpParser\Node\Expr\Assign) { + if (!$assign instanceof Assign) { return null; } - $nextForeach = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if (!$nextForeach instanceof \PhpParser\Node\Stmt\Return_) { + $nextForeach = $node->getAttribute(AttributeKey::NEXT_NODE); + if (!$nextForeach instanceof Return_) { return null; } $assignVariable = $assign->var; /** @var Expr $variablePrevious */ - $variablePrevious = $this->betterNodeFinder->findFirstPrevious($node, function (\PhpParser\Node $node) use($assignVariable) : bool { - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\Expr\Assign) { + $variablePrevious = $this->betterNodeFinder->findFirstPrevious($node, function (Node $node) use($assignVariable) : bool { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Assign) { return \false; } return $this->nodeComparator->areNodesEqual($node, $assignVariable); @@ -98,12 +98,12 @@ CODE_SAMPLE return null; } /** @var Assign $assignPreviousVariable */ - $assignPreviousVariable = $variablePrevious->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - $parent = $assignPreviousVariable->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\Stmt\Expression) { + $assignPreviousVariable = $variablePrevious->getAttribute(AttributeKey::PARENT_NODE); + $parent = $assignPreviousVariable->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Expression) { return null; } - $nextParent = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); + $nextParent = $parent->getAttribute(AttributeKey::NEXT_NODE); if ($nextParent !== $node) { return null; } @@ -112,25 +112,25 @@ CODE_SAMPLE /** * @param Break_[] $breaks */ - private function processEarlyReturn(\PhpParser\Node\Stmt\Expression $expression, \PhpParser\Node\Expr\Assign $assign, array $breaks, \PhpParser\Node\Stmt\Return_ $return, \PhpParser\Node\Expr\Assign $assignPreviousVariable, \PhpParser\Node\Stmt\Foreach_ $foreach) : \PhpParser\Node\Stmt\Foreach_ + private function processEarlyReturn(Expression $expression, Assign $assign, array $breaks, Return_ $return, Assign $assignPreviousVariable, Foreach_ $foreach) : Foreach_ { $this->removeNode($expression); - $this->nodesToAddCollector->addNodeBeforeNode(new \PhpParser\Node\Stmt\Return_($assign->expr), $breaks[0], $this->file->getSmartFileInfo()); + $this->nodesToAddCollector->addNodeBeforeNode(new Return_($assign->expr), $breaks[0], $this->file->getSmartFileInfo()); $this->removeNode($breaks[0]); $return->expr = $assignPreviousVariable->expr; $this->removeNode($assignPreviousVariable); return $foreach; } - private function shouldSkip(\PhpParser\Node\Stmt\Return_ $return, \PhpParser\Node\Stmt\Foreach_ $foreach, \PhpParser\Node\Expr $assignVariable, \PhpParser\Node\Expr $expr = null) : bool + private function shouldSkip(Return_ $return, Foreach_ $foreach, Expr $assignVariable, Expr $expr = null) : bool { - if (!$expr instanceof \PhpParser\Node\Expr) { + if (!$expr instanceof Expr) { return \true; } if (!$this->nodeComparator->areNodesEqual($return->expr, $expr)) { return \true; } // ensure the variable only used once in foreach - $usedVariable = $this->betterNodeFinder->find($foreach->stmts, function (\PhpParser\Node $node) use($assignVariable) : bool { + $usedVariable = $this->betterNodeFinder->find($foreach->stmts, function (Node $node) use($assignVariable) : bool { return $this->nodeComparator->areNodesEqual($node, $assignVariable); }); return \count($usedVariable) > 1; diff --git a/rules/EarlyReturn/Rector/If_/ChangeAndIfToEarlyReturnRector.php b/rules/EarlyReturn/Rector/If_/ChangeAndIfToEarlyReturnRector.php index 8cf12c4e5e9..e0fdd1083f5 100644 --- a/rules/EarlyReturn/Rector/If_/ChangeAndIfToEarlyReturnRector.php +++ b/rules/EarlyReturn/Rector/If_/ChangeAndIfToEarlyReturnRector.php @@ -20,12 +20,12 @@ use Rector\EarlyReturn\NodeFactory\InvertedIfFactory; use Rector\NodeCollector\BinaryOpConditionsCollector; use Rector\NodeNestingScope\ContextAnalyzer; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector\ChangeAndIfToEarlyReturnRectorTest */ -final class ChangeAndIfToEarlyReturnRector extends \Rector\Core\Rector\AbstractRector +final class ChangeAndIfToEarlyReturnRector extends AbstractRector { /** * @readonly @@ -47,16 +47,16 @@ final class ChangeAndIfToEarlyReturnRector extends \Rector\Core\Rector\AbstractR * @var \Rector\NodeCollector\BinaryOpConditionsCollector */ private $binaryOpConditionsCollector; - public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator, \Rector\EarlyReturn\NodeFactory\InvertedIfFactory $invertedIfFactory, \Rector\NodeNestingScope\ContextAnalyzer $contextAnalyzer, \Rector\NodeCollector\BinaryOpConditionsCollector $binaryOpConditionsCollector) + public function __construct(IfManipulator $ifManipulator, InvertedIfFactory $invertedIfFactory, ContextAnalyzer $contextAnalyzer, BinaryOpConditionsCollector $binaryOpConditionsCollector) { $this->ifManipulator = $ifManipulator; $this->invertedIfFactory = $invertedIfFactory; $this->contextAnalyzer = $contextAnalyzer; $this->binaryOpConditionsCollector = $binaryOpConditionsCollector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes if && to early return', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes if && to early return', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function canDrive(Car $car) @@ -93,12 +93,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface::class]; + return [StmtsAwareInterface::class]; } /** * @param StmtsAwareInterface $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $stmts = (array) $node->stmts; if ($stmts === []) { @@ -106,7 +106,7 @@ CODE_SAMPLE } $newStmts = []; foreach ($stmts as $key => $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\If_) { + if (!$stmt instanceof If_) { $newStmts[] = $stmt; continue; } @@ -115,30 +115,30 @@ CODE_SAMPLE $newStmts[] = $stmt; continue; } - if ($nextStmt instanceof \PhpParser\Node\Stmt\Return_) { + if ($nextStmt instanceof Return_) { if ($this->isIfStmtExprUsedInNextReturn($stmt, $nextStmt)) { continue; } - if ($nextStmt->expr instanceof \PhpParser\Node\Expr\BinaryOp\BooleanAnd) { + if ($nextStmt->expr instanceof BooleanAnd) { continue; } } /** @var BooleanAnd $expr */ $expr = $stmt->cond; - $booleanAndConditions = $this->binaryOpConditionsCollector->findConditions($expr, \PhpParser\Node\Expr\BinaryOp\BooleanAnd::class); + $booleanAndConditions = $this->binaryOpConditionsCollector->findConditions($expr, BooleanAnd::class); $afterStmts = []; - if (!$nextStmt instanceof \PhpParser\Node\Stmt\Return_) { + if (!$nextStmt instanceof Return_) { $afterStmts[] = $stmt->stmts[0]; - $newStmts = \array_merge($newStmts, $this->processReplaceIfs($stmt, $booleanAndConditions, new \PhpParser\Node\Stmt\Return_(), $afterStmts)); + $newStmts = \array_merge($newStmts, $this->processReplaceIfs($stmt, $booleanAndConditions, new Return_(), $afterStmts)); $node->stmts = $newStmts; return $node; } // remove next node unset($newStmts[$key + 1]); $afterStmts[] = $stmt->stmts[0]; - $ifNextReturnClone = $stmt->stmts[0] instanceof \PhpParser\Node\Stmt\Return_ ? clone $stmt->stmts[0] : new \PhpParser\Node\Stmt\Return_(); + $ifNextReturnClone = $stmt->stmts[0] instanceof Return_ ? clone $stmt->stmts[0] : new Return_(); if ($this->isInLoopWithoutContinueOrBreak($stmt)) { - $afterStmts[] = new \PhpParser\Node\Stmt\Return_(); + $afterStmts[] = new Return_(); } $changedStmts = $this->processReplaceIfs($stmt, $booleanAndConditions, $ifNextReturnClone, $afterStmts); $changedStmts = \array_merge($newStmts, $changedStmts); @@ -148,30 +148,30 @@ CODE_SAMPLE } return null; } - private function isInLoopWithoutContinueOrBreak(\PhpParser\Node\Stmt\If_ $if) : bool + private function isInLoopWithoutContinueOrBreak(If_ $if) : bool { if (!$this->contextAnalyzer->isInLoop($if)) { return \false; } - if ($if->stmts[0] instanceof \PhpParser\Node\Stmt\Continue_) { + if ($if->stmts[0] instanceof Continue_) { return \false; } - return !$if->stmts[0] instanceof \PhpParser\Node\Stmt\Break_; + return !$if->stmts[0] instanceof Break_; } /** * @param Expr[] $conditions * @param Stmt[] $afters * @return Stmt[] */ - private function processReplaceIfs(\PhpParser\Node\Stmt\If_ $if, array $conditions, \PhpParser\Node\Stmt\Return_ $ifNextReturnClone, array $afters) : array + private function processReplaceIfs(If_ $if, array $conditions, Return_ $ifNextReturnClone, array $afters) : array { $ifs = $this->invertedIfFactory->createFromConditions($if, $conditions, $ifNextReturnClone); $this->mirrorComments($ifs[0], $if); $result = \array_merge($ifs, $afters); - if ($if->stmts[0] instanceof \PhpParser\Node\Stmt\Return_) { + if ($if->stmts[0] instanceof Return_) { return $result; } - if (!$ifNextReturnClone->expr instanceof \PhpParser\Node\Expr) { + if (!$ifNextReturnClone->expr instanceof Expr) { return $result; } if ($this->contextAnalyzer->isInLoop($if)) { @@ -179,12 +179,12 @@ CODE_SAMPLE } return \array_merge($result, [$ifNextReturnClone]); } - private function shouldSkip(\Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface $stmtsAware, \PhpParser\Node\Stmt\If_ $if, ?\PhpParser\Node\Stmt $nexStmt) : bool + private function shouldSkip(StmtsAwareInterface $stmtsAware, If_ $if, ?Stmt $nexStmt) : bool { if (!$this->ifManipulator->isIfWithOnlyOneStmt($if)) { return \true; } - if (!$if->cond instanceof \PhpParser\Node\Expr\BinaryOp\BooleanAnd) { + if (!$if->cond instanceof BooleanAnd) { return \true; } if (!$this->ifManipulator->isIfWithoutElseAndElseIfs($if)) { @@ -198,14 +198,14 @@ CODE_SAMPLE } return !$this->isLastIfOrBeforeLastReturn($if, $nexStmt); } - private function isIfStmtExprUsedInNextReturn(\PhpParser\Node\Stmt\If_ $if, \PhpParser\Node\Stmt\Return_ $return) : bool + private function isIfStmtExprUsedInNextReturn(If_ $if, Return_ $return) : bool { - if (!$return->expr instanceof \PhpParser\Node\Expr) { + if (!$return->expr instanceof Expr) { return \false; } - $ifExprs = $this->betterNodeFinder->findInstanceOf($if->stmts, \PhpParser\Node\Expr::class); + $ifExprs = $this->betterNodeFinder->findInstanceOf($if->stmts, Expr::class); foreach ($ifExprs as $ifExpr) { - $isExprFoundInReturn = (bool) $this->betterNodeFinder->findFirst($return->expr, function (\PhpParser\Node $node) use($ifExpr) : bool { + $isExprFoundInReturn = (bool) $this->betterNodeFinder->findFirst($return->expr, function (Node $node) use($ifExpr) : bool { return $this->nodeComparator->areNodesEqual($node, $ifExpr); }); if ($isExprFoundInReturn) { @@ -214,31 +214,31 @@ CODE_SAMPLE } return \false; } - private function isParentIfReturnsVoidOrParentIfHasNextNode(\Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface $stmtsAware) : bool + private function isParentIfReturnsVoidOrParentIfHasNextNode(StmtsAwareInterface $stmtsAware) : bool { - if (!$stmtsAware instanceof \PhpParser\Node\Stmt\If_) { + if (!$stmtsAware instanceof If_) { return \false; } - $nextParent = $stmtsAware->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - return $nextParent instanceof \PhpParser\Node; + $nextParent = $stmtsAware->getAttribute(AttributeKey::NEXT_NODE); + return $nextParent instanceof Node; } - private function isNestedIfInLoop(\PhpParser\Node\Stmt\If_ $if, \Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface $stmtsAware) : bool + private function isNestedIfInLoop(If_ $if, StmtsAwareInterface $stmtsAware) : bool { if (!$this->contextAnalyzer->isInLoop($if)) { return \false; } - return $stmtsAware instanceof \PhpParser\Node\Stmt\If_ || $stmtsAware instanceof \PhpParser\Node\Stmt\Else_ || $stmtsAware instanceof \PhpParser\Node\Stmt\ElseIf_; + return $stmtsAware instanceof If_ || $stmtsAware instanceof Else_ || $stmtsAware instanceof ElseIf_; } - private function isLastIfOrBeforeLastReturn(\PhpParser\Node\Stmt\If_ $if, ?\PhpParser\Node\Stmt $nextStmt) : bool + private function isLastIfOrBeforeLastReturn(If_ $if, ?Stmt $nextStmt) : bool { - if ($nextStmt instanceof \PhpParser\Node) { - return $nextStmt instanceof \PhpParser\Node\Stmt\Return_; + if ($nextStmt instanceof Node) { + return $nextStmt instanceof Return_; } - $parent = $if->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node) { + $parent = $if->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Node) { return \false; } - if ($parent instanceof \PhpParser\Node\Stmt\If_) { + if ($parent instanceof If_) { return $this->isLastIfOrBeforeLastReturn($parent, $nextStmt); } return !$this->contextAnalyzer->isHasAssignWithIndirectReturn($parent, $if); diff --git a/rules/EarlyReturn/Rector/If_/ChangeIfElseValueAssignToEarlyReturnRector.php b/rules/EarlyReturn/Rector/If_/ChangeIfElseValueAssignToEarlyReturnRector.php index 4fb37cc15f4..4d262748a51 100644 --- a/rules/EarlyReturn/Rector/If_/ChangeIfElseValueAssignToEarlyReturnRector.php +++ b/rules/EarlyReturn/Rector/If_/ChangeIfElseValueAssignToEarlyReturnRector.php @@ -14,14 +14,14 @@ use Rector\Core\NodeManipulator\IfManipulator; use Rector\Core\NodeManipulator\StmtsManipulator; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://engineering.helpscout.com/reducing-complexity-with-guard-clauses-in-php-and-javascript-74600fd865c7 * * @see \Rector\Tests\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector\ChangeIfElseValueAssignToEarlyReturnRectorTest */ -final class ChangeIfElseValueAssignToEarlyReturnRector extends \Rector\Core\Rector\AbstractRector +final class ChangeIfElseValueAssignToEarlyReturnRector extends AbstractRector { /** * @readonly @@ -33,14 +33,14 @@ final class ChangeIfElseValueAssignToEarlyReturnRector extends \Rector\Core\Rect * @var \Rector\Core\NodeManipulator\StmtsManipulator */ private $stmtsManipulator; - public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator, \Rector\Core\NodeManipulator\StmtsManipulator $stmtsManipulator) + public function __construct(IfManipulator $ifManipulator, StmtsManipulator $stmtsManipulator) { $this->ifManipulator = $ifManipulator; $this->stmtsManipulator = $stmtsManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change if/else value to early return', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change if/else value to early return', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -74,16 +74,16 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node * @return Stmt[]|null */ - public function refactor(\PhpParser\Node $node) : ?array + public function refactor(Node $node) : ?array { - $nextNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if (!$nextNode instanceof \PhpParser\Node\Stmt\Return_) { + $nextNode = $node->getAttribute(AttributeKey::NEXT_NODE); + if (!$nextNode instanceof Return_) { return null; } if ($nextNode->expr === null) { @@ -96,12 +96,12 @@ CODE_SAMPLE $lastIfStmtKey = \key($node->stmts); /** @var Assign $assign */ $assign = $this->stmtsManipulator->getUnwrappedLastStmt($node->stmts); - $returnLastIf = new \PhpParser\Node\Stmt\Return_($assign->expr); + $returnLastIf = new Return_($assign->expr); $this->mirrorComments($returnLastIf, $assign); $node->stmts[$lastIfStmtKey] = $returnLastIf; $else = $node->else; - if (!$else instanceof \PhpParser\Node\Stmt\Else_) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$else instanceof Else_) { + throw new ShouldNotHappenException(); } /** @var array $elseStmts */ $elseStmts = $else->stmts; @@ -109,7 +109,7 @@ CODE_SAMPLE $assign = $this->stmtsManipulator->getUnwrappedLastStmt($elseStmts); \end($elseStmts); $lastElseStmtKey = \key($elseStmts); - $returnLastElse = new \PhpParser\Node\Stmt\Return_($assign->expr); + $returnLastElse = new Return_($assign->expr); $this->mirrorComments($returnLastElse, $assign); $elseStmts[$lastElseStmtKey] = $returnLastElse; $node->else = null; diff --git a/rules/EarlyReturn/Rector/If_/ChangeNestedIfsToEarlyReturnRector.php b/rules/EarlyReturn/Rector/If_/ChangeNestedIfsToEarlyReturnRector.php index fc4acd8a240..a49b1124a87 100644 --- a/rules/EarlyReturn/Rector/If_/ChangeNestedIfsToEarlyReturnRector.php +++ b/rules/EarlyReturn/Rector/If_/ChangeNestedIfsToEarlyReturnRector.php @@ -13,12 +13,12 @@ use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; use Rector\Core\NodeManipulator\IfManipulator; use Rector\Core\Rector\AbstractRector; use Rector\EarlyReturn\NodeTransformer\ConditionInverter; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector\ChangeNestedIfsToEarlyReturnRectorTest */ -final class ChangeNestedIfsToEarlyReturnRector extends \Rector\Core\Rector\AbstractRector +final class ChangeNestedIfsToEarlyReturnRector extends AbstractRector { /** * @readonly @@ -30,14 +30,14 @@ final class ChangeNestedIfsToEarlyReturnRector extends \Rector\Core\Rector\Abstr * @var \Rector\Core\NodeManipulator\IfManipulator */ private $ifManipulator; - public function __construct(\Rector\EarlyReturn\NodeTransformer\ConditionInverter $conditionInverter, \Rector\Core\NodeManipulator\IfManipulator $ifManipulator) + public function __construct(ConditionInverter $conditionInverter, IfManipulator $ifManipulator) { $this->conditionInverter = $conditionInverter; $this->ifManipulator = $ifManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change nested ifs to early return', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change nested ifs to early return', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -76,12 +76,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface::class]; + return [StmtsAwareInterface::class]; } /** * @param StmtsAwareInterface $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $stmts = $node->stmts; if ($stmts === null) { @@ -89,10 +89,10 @@ CODE_SAMPLE } foreach ($stmts as $key => $stmt) { $nextStmt = $stmts[$key + 1] ?? null; - if (!$nextStmt instanceof \PhpParser\Node\Stmt\Return_) { + if (!$nextStmt instanceof Return_) { continue; } - if (!$stmt instanceof \PhpParser\Node\Stmt\If_) { + if (!$stmt instanceof If_) { continue; } $nestedIfsWithOnlyReturn = $this->ifManipulator->collectNestedIfsWithOnlyReturn($stmt); @@ -108,7 +108,7 @@ CODE_SAMPLE * @param If_[] $nestedIfsWithOnlyReturn * @return Stmt[] */ - private function processNestedIfsWithOnlyReturn(array $nestedIfsWithOnlyReturn, \PhpParser\Node\Stmt\Return_ $nextReturn) : array + private function processNestedIfsWithOnlyReturn(array $nestedIfsWithOnlyReturn, Return_ $nextReturn) : array { // add nested if openly after this $nestedIfsWithOnlyReturnCount = \count($nestedIfsWithOnlyReturn); @@ -129,14 +129,14 @@ CODE_SAMPLE /** * @return Stmt[] */ - private function createStandaloneIfsWithReturn(\PhpParser\Node\Stmt\If_ $nestedIfWithOnlyReturn, \PhpParser\Node\Stmt\Return_ $return) : array + private function createStandaloneIfsWithReturn(If_ $nestedIfWithOnlyReturn, Return_ $return) : array { $invertedCondition = $this->conditionInverter->createInvertedCondition($nestedIfWithOnlyReturn->cond); // special case - if ($invertedCondition instanceof \PhpParser\Node\Expr\BooleanNot && $invertedCondition->expr instanceof \PhpParser\Node\Expr\BinaryOp\BooleanAnd) { - $booleanNotPartIf = new \PhpParser\Node\Stmt\If_(new \PhpParser\Node\Expr\BooleanNot($invertedCondition->expr->left)); + if ($invertedCondition instanceof BooleanNot && $invertedCondition->expr instanceof BooleanAnd) { + $booleanNotPartIf = new If_(new BooleanNot($invertedCondition->expr->left)); $booleanNotPartIf->stmts = [clone $return]; - $secondBooleanNotPartIf = new \PhpParser\Node\Stmt\If_(new \PhpParser\Node\Expr\BooleanNot($invertedCondition->expr->right)); + $secondBooleanNotPartIf = new If_(new BooleanNot($invertedCondition->expr->right)); $secondBooleanNotPartIf->stmts = [clone $return]; return [$booleanNotPartIf, $secondBooleanNotPartIf]; } diff --git a/rules/EarlyReturn/Rector/If_/ChangeOrIfContinueToMultiContinueRector.php b/rules/EarlyReturn/Rector/If_/ChangeOrIfContinueToMultiContinueRector.php index 2f32fa33646..1bc6b9dec32 100644 --- a/rules/EarlyReturn/Rector/If_/ChangeOrIfContinueToMultiContinueRector.php +++ b/rules/EarlyReturn/Rector/If_/ChangeOrIfContinueToMultiContinueRector.php @@ -10,25 +10,25 @@ use PhpParser\Node\Stmt\Continue_; use PhpParser\Node\Stmt\If_; use Rector\Core\NodeManipulator\IfManipulator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector\ChangeOrIfContinueToMultiContinueRectorTest */ -final class ChangeOrIfContinueToMultiContinueRector extends \Rector\Core\Rector\AbstractRector +final class ChangeOrIfContinueToMultiContinueRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeManipulator\IfManipulator */ private $ifManipulator; - public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator) + public function __construct(IfManipulator $ifManipulator) { $this->ifManipulator = $ifManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes if || to early return', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes if || to early return', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function canDrive(Car $newCar) @@ -70,18 +70,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node * @return null|If_[] */ - public function refactor(\PhpParser\Node $node) : ?array + public function refactor(Node $node) : ?array { - if (!$this->ifManipulator->isIfWithOnly($node, \PhpParser\Node\Stmt\Continue_::class)) { + if (!$this->ifManipulator->isIfWithOnly($node, Continue_::class)) { return null; } - if (!$node->cond instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { + if (!$node->cond instanceof BooleanOr) { return null; } return $this->processMultiIfContinue($node); @@ -89,7 +89,7 @@ CODE_SAMPLE /** * @return null|If_[] */ - private function processMultiIfContinue(\PhpParser\Node\Stmt\If_ $if) : ?array + private function processMultiIfContinue(If_ $if) : ?array { $node = clone $if; /** @var Continue_ $continue */ @@ -106,9 +106,9 @@ CODE_SAMPLE * @param If_[] $ifs * @return If_[] */ - private function createMultipleIfs(\PhpParser\Node\Expr $expr, \PhpParser\Node\Stmt\Continue_ $continue, array $ifs) : array + private function createMultipleIfs(Expr $expr, Continue_ $continue, array $ifs) : array { - while ($expr instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { + while ($expr instanceof BooleanOr) { $ifs = \array_merge($ifs, $this->collectLeftbooleanOrToIfs($expr, $continue, $ifs)); $ifs[] = $this->ifManipulator->createIfStmt($expr->right, $continue); $expr = $expr->right; @@ -119,10 +119,10 @@ CODE_SAMPLE * @param If_[] $ifs * @return If_[] */ - private function collectLeftbooleanOrToIfs(\PhpParser\Node\Expr\BinaryOp\BooleanOr $booleanOr, \PhpParser\Node\Stmt\Continue_ $continue, array $ifs) : array + private function collectLeftbooleanOrToIfs(BooleanOr $booleanOr, Continue_ $continue, array $ifs) : array { $left = $booleanOr->left; - if (!$left instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { + if (!$left instanceof BooleanOr) { return [$this->ifManipulator->createIfStmt($left, $continue)]; } return $this->createMultipleIfs($left, $continue, $ifs); diff --git a/rules/EarlyReturn/Rector/If_/ChangeOrIfReturnToEarlyReturnRector.php b/rules/EarlyReturn/Rector/If_/ChangeOrIfReturnToEarlyReturnRector.php index b5e819caa7a..bdacb076b3e 100644 --- a/rules/EarlyReturn/Rector/If_/ChangeOrIfReturnToEarlyReturnRector.php +++ b/rules/EarlyReturn/Rector/If_/ChangeOrIfReturnToEarlyReturnRector.php @@ -13,25 +13,25 @@ use PhpParser\Node\Stmt\Return_; use Rector\Core\NodeManipulator\IfManipulator; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\EarlyReturn\Rector\If_\ChangeOrIfReturnToEarlyReturnRector\ChangeOrIfReturnToEarlyReturnRectorTest */ -final class ChangeOrIfReturnToEarlyReturnRector extends \Rector\Core\Rector\AbstractRector +final class ChangeOrIfReturnToEarlyReturnRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeManipulator\IfManipulator */ private $ifManipulator; - public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator) + public function __construct(IfManipulator $ifManipulator) { $this->ifManipulator = $ifManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes if || with return to early return', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes if || with return to early return', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($a, $b) @@ -67,18 +67,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node * @return null|If_[] */ - public function refactor(\PhpParser\Node $node) : ?array + public function refactor(Node $node) : ?array { - if (!$this->ifManipulator->isIfWithOnly($node, \PhpParser\Node\Stmt\Return_::class)) { + if (!$this->ifManipulator->isIfWithOnly($node, Return_::class)) { return null; } - if (!$node->cond instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { + if (!$node->cond instanceof BooleanOr) { return null; } if ($this->isInstanceofCondOnly($node->cond)) { @@ -87,8 +87,8 @@ CODE_SAMPLE /** @var Return_ $return */ $return = $node->stmts[0]; // same return? skip - $next = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if ($next instanceof \PhpParser\Node\Stmt\Return_ && $this->nodeComparator->areNodesEqual($return, $next)) { + $next = $node->getAttribute(AttributeKey::NEXT_NODE); + if ($next instanceof Return_ && $this->nodeComparator->areNodesEqual($return, $next)) { return null; } $ifs = $this->createMultipleIfs($node->cond, $return, []); @@ -103,9 +103,9 @@ CODE_SAMPLE * @param If_[] $ifs * @return If_[] */ - private function createMultipleIfs(\PhpParser\Node\Expr\BinaryOp\BooleanOr $booleanOr, \PhpParser\Node\Stmt\Return_ $return, array $ifs) : array + private function createMultipleIfs(BooleanOr $booleanOr, Return_ $return, array $ifs) : array { - while ($booleanOr instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { + while ($booleanOr instanceof BooleanOr) { $ifs = \array_merge($ifs, $this->collectLeftBooleanOrToIfs($booleanOr, $return, $ifs)); $ifs[] = $this->createIf($booleanOr->right, $return); $booleanOr = $booleanOr->right; @@ -116,29 +116,29 @@ CODE_SAMPLE * @param If_[] $ifs * @return If_[] */ - private function collectLeftBooleanOrToIfs(\PhpParser\Node\Expr\BinaryOp\BooleanOr $booleanOr, \PhpParser\Node\Stmt\Return_ $return, array $ifs) : array + private function collectLeftBooleanOrToIfs(BooleanOr $booleanOr, Return_ $return, array $ifs) : array { $left = $booleanOr->left; - if (!$left instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { + if (!$left instanceof BooleanOr) { return [$this->createIf($left, $return)]; } return $this->createMultipleIfs($left, $return, $ifs); } - private function createIf(\PhpParser\Node\Expr $expr, \PhpParser\Node\Stmt\Return_ $return) : \PhpParser\Node\Stmt\If_ + private function createIf(Expr $expr, Return_ $return) : If_ { - return new \PhpParser\Node\Stmt\If_($expr, ['stmts' => [$return]]); + return new If_($expr, ['stmts' => [$return]]); } /** * @param \PhpParser\Node\Expr\BinaryOp\BooleanOr|\PhpParser\Node\Expr\BinaryOp $booleanOr */ private function isInstanceofCondOnly($booleanOr) : bool { - if ($booleanOr->left instanceof \PhpParser\Node\Expr\BinaryOp) { + if ($booleanOr->left instanceof BinaryOp) { return $this->isInstanceofCondOnly($booleanOr->left); } - if ($booleanOr->right instanceof \PhpParser\Node\Expr\BinaryOp) { + if ($booleanOr->right instanceof BinaryOp) { return $this->isInstanceofCondOnly($booleanOr->right); } - return $booleanOr->left instanceof \PhpParser\Node\Expr\Instanceof_ || $booleanOr->right instanceof \PhpParser\Node\Expr\Instanceof_; + return $booleanOr->left instanceof Instanceof_ || $booleanOr->right instanceof Instanceof_; } } diff --git a/rules/EarlyReturn/Rector/If_/RemoveAlwaysElseRector.php b/rules/EarlyReturn/Rector/If_/RemoveAlwaysElseRector.php index 3b51c1ba641..a6e1815780f 100644 --- a/rules/EarlyReturn/Rector/If_/RemoveAlwaysElseRector.php +++ b/rules/EarlyReturn/Rector/If_/RemoveAlwaysElseRector.php @@ -13,16 +13,16 @@ use PhpParser\Node\Stmt\If_; use PhpParser\Node\Stmt\Return_; use PhpParser\Node\Stmt\Throw_; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\EarlyReturn\Rector\If_\RemoveAlwaysElseRector\RemoveAlwaysElseRectorTest */ -final class RemoveAlwaysElseRector extends \Rector\Core\Rector\AbstractRector +final class RemoveAlwaysElseRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Split if statement, when if condition always break execution flow', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Split if statement, when if condition always break execution flow', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($value) @@ -55,20 +55,20 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node * @return Node[]|null */ - public function refactor(\PhpParser\Node $node) : ?array + public function refactor(Node $node) : ?array { if ($this->doesLastStatementBreakFlow($node)) { return null; } if ($node->elseifs !== []) { $originalNode = clone $node; - $if = new \PhpParser\Node\Stmt\If_($node->cond); + $if = new If_($node->cond); $if->stmts = $node->stmts; $this->mirrorComments($if, $node); /** @var ElseIf_ $firstElseIf */ @@ -77,7 +77,7 @@ CODE_SAMPLE $node->stmts = $firstElseIf->stmts; $this->mirrorComments($node, $firstElseIf); $nodesToReturnAfterNode = $this->getStatementsElseIfs($node); - if ($originalNode->else instanceof \PhpParser\Node\Stmt\Else_) { + if ($originalNode->else instanceof Else_) { $node->else = null; $nodesToReturnAfterNode = \array_merge($nodesToReturnAfterNode, [$originalNode->else]); } @@ -93,7 +93,7 @@ CODE_SAMPLE /** * @return ElseIf_[] */ - private function getStatementsElseIfs(\PhpParser\Node\Stmt\If_ $if) : array + private function getStatementsElseIfs(If_ $if) : array { $statements = []; foreach ($if->elseifs as $key => $elseif) { @@ -111,6 +111,6 @@ CODE_SAMPLE private function doesLastStatementBreakFlow($node) : bool { $lastStmt = \end($node->stmts); - return !($lastStmt instanceof \PhpParser\Node\Stmt\Return_ || $lastStmt instanceof \PhpParser\Node\Stmt\Throw_ || $lastStmt instanceof \PhpParser\Node\Stmt\Continue_ || $lastStmt instanceof \PhpParser\Node\Stmt\Expression && $lastStmt->expr instanceof \PhpParser\Node\Expr\Exit_); + return !($lastStmt instanceof Return_ || $lastStmt instanceof Throw_ || $lastStmt instanceof Continue_ || $lastStmt instanceof Expression && $lastStmt->expr instanceof Exit_); } } diff --git a/rules/EarlyReturn/Rector/Return_/PreparedValueToEarlyReturnRector.php b/rules/EarlyReturn/Rector/Return_/PreparedValueToEarlyReturnRector.php index ed4622ea7d2..e819ddbcc80 100644 --- a/rules/EarlyReturn/Rector/Return_/PreparedValueToEarlyReturnRector.php +++ b/rules/EarlyReturn/Rector/Return_/PreparedValueToEarlyReturnRector.php @@ -13,25 +13,25 @@ use PhpParser\Node\Stmt\Return_; use Rector\Core\NodeManipulator\IfManipulator; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector\PreparedValueToEarlyReturnRectorTest */ -final class PreparedValueToEarlyReturnRector extends \Rector\Core\Rector\AbstractRector +final class PreparedValueToEarlyReturnRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeManipulator\IfManipulator */ private $ifManipulator; - public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator) + public function __construct(IfManipulator $ifManipulator) { $this->ifManipulator = $ifManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Return early prepared value in ifs', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Return early prepared value in ifs', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -74,12 +74,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Return_::class]; + return [Return_::class]; } /** * @param Return_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $ifsBefore = $this->getIfsBefore($node); if ($this->shouldSkip($ifsBefore, $node->expr)) { @@ -102,7 +102,7 @@ CODE_SAMPLE $expressionIf = $ifBefore->stmts[0]; /** @var Assign $assignIf */ $assignIf = $expressionIf->expr; - $ifBefore->stmts[0] = new \PhpParser\Node\Stmt\Return_($assignIf->expr); + $ifBefore->stmts[0] = new Return_($assignIf->expr); } /** @var Assign $assignPrevious */ $assignPrevious = $previousFirstExpression->expr; @@ -113,10 +113,10 @@ CODE_SAMPLE /** * @param If_[] $ifsBefore */ - private function isAssignVarUsedInIfCond(array $ifsBefore, ?\PhpParser\Node\Expr $expr) : bool + private function isAssignVarUsedInIfCond(array $ifsBefore, ?Expr $expr) : bool { foreach ($ifsBefore as $ifBefore) { - $isUsedInIfCond = (bool) $this->betterNodeFinder->findFirst($ifBefore->cond, function (\PhpParser\Node $node) use($expr) : bool { + $isUsedInIfCond = (bool) $this->betterNodeFinder->findFirst($ifBefore->cond, function (Node $node) use($expr) : bool { return $this->nodeComparator->areNodesEqual($node, $expr); }); if ($isUsedInIfCond) { @@ -128,14 +128,14 @@ CODE_SAMPLE /** * @param If_[] $ifsBefore */ - private function isPreviousVarUsedInAssignExpr(array $ifsBefore, \PhpParser\Node\Expr $expr) : bool + private function isPreviousVarUsedInAssignExpr(array $ifsBefore, Expr $expr) : bool { foreach ($ifsBefore as $ifBefore) { /** @var Expression $expression */ $expression = $ifBefore->stmts[0]; /** @var Assign $assign */ $assign = $expression->expr; - $isUsedInAssignExpr = (bool) $this->betterNodeFinder->findFirst($assign->expr, function (\PhpParser\Node $node) use($expr) : bool { + $isUsedInAssignExpr = (bool) $this->betterNodeFinder->findFirst($assign->expr, function (Node $node) use($expr) : bool { return $this->nodeComparator->areNodesEqual($node, $expr); }); if ($isUsedInAssignExpr) { @@ -147,26 +147,26 @@ CODE_SAMPLE /** * @param If_[] $ifsBefore */ - private function shouldSkip(array $ifsBefore, ?\PhpParser\Node\Expr $returnExpr) : bool + private function shouldSkip(array $ifsBefore, ?Expr $returnExpr) : bool { if ($ifsBefore === []) { return \true; } return !(bool) $this->getPreviousIfLinearEquals($ifsBefore[0], $returnExpr); } - private function getPreviousIfLinearEquals(?\PhpParser\Node $node, ?\PhpParser\Node\Expr $expr) : ?\PhpParser\Node\Stmt\Expression + private function getPreviousIfLinearEquals(?Node $node, ?Expr $expr) : ?Expression { - if (!$node instanceof \PhpParser\Node) { + if (!$node instanceof Node) { return null; } - if (!$expr instanceof \PhpParser\Node\Expr) { + if (!$expr instanceof Expr) { return null; } - $previous = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_NODE); - if (!$previous instanceof \PhpParser\Node\Stmt\Expression) { + $previous = $node->getAttribute(AttributeKey::PREVIOUS_NODE); + if (!$previous instanceof Expression) { return $this->getPreviousIfLinearEquals($previous, $expr); } - if (!$previous->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$previous->expr instanceof Assign) { return null; } if ($this->nodeComparator->areNodesEqual($previous->expr->var, $expr)) { @@ -177,10 +177,10 @@ CODE_SAMPLE /** * @return If_[] */ - private function getIfsBefore(\PhpParser\Node\Stmt\Return_ $return) : array + private function getIfsBefore(Return_ $return) : array { - $parent = $return->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\FunctionLike && !$parent instanceof \PhpParser\Node\Stmt\If_) { + $parent = $return->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof FunctionLike && !$parent instanceof If_) { return []; } if ($parent->stmts === []) { @@ -197,10 +197,10 @@ CODE_SAMPLE * @param If_[] $stmts * @return If_[] */ - private function collectIfs(array $stmts, \PhpParser\Node\Stmt\Return_ $return) : array + private function collectIfs(array $stmts, Return_ $return) : array { /** @va If_[] $ifs */ - $ifs = $this->betterNodeFinder->findInstanceOf($stmts, \PhpParser\Node\Stmt\If_::class); + $ifs = $this->betterNodeFinder->findInstanceOf($stmts, If_::class); /** Skip entirely if found skipped ifs */ foreach ($ifs as $if) { /** @var If_ $if */ @@ -212,10 +212,10 @@ CODE_SAMPLE return []; } $expression = $stmts[0]; - if (!$expression instanceof \PhpParser\Node\Stmt\Expression) { + if (!$expression instanceof Expression) { return []; } - if (!$expression->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$expression->expr instanceof Assign) { return []; } $assign = $expression->expr; diff --git a/rules/EarlyReturn/Rector/Return_/ReturnBinaryAndToEarlyReturnRector.php b/rules/EarlyReturn/Rector/Return_/ReturnBinaryAndToEarlyReturnRector.php index 004eaa38881..cc96c4681a6 100644 --- a/rules/EarlyReturn/Rector/Return_/ReturnBinaryAndToEarlyReturnRector.php +++ b/rules/EarlyReturn/Rector/Return_/ReturnBinaryAndToEarlyReturnRector.php @@ -12,12 +12,12 @@ use Rector\Core\NodeAnalyzer\CallAnalyzer; use Rector\Core\NodeManipulator\IfManipulator; use Rector\Core\PhpParser\Node\AssignAndBinaryMap; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector\ReturnBinaryAndToEarlyReturnRectorTest */ -final class ReturnBinaryAndToEarlyReturnRector extends \Rector\Core\Rector\AbstractRector +final class ReturnBinaryAndToEarlyReturnRector extends AbstractRector { /** * @readonly @@ -34,15 +34,15 @@ final class ReturnBinaryAndToEarlyReturnRector extends \Rector\Core\Rector\Abstr * @var \Rector\Core\NodeAnalyzer\CallAnalyzer */ private $callAnalyzer; - public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator, \Rector\Core\PhpParser\Node\AssignAndBinaryMap $assignAndBinaryMap, \Rector\Core\NodeAnalyzer\CallAnalyzer $callAnalyzer) + public function __construct(IfManipulator $ifManipulator, AssignAndBinaryMap $assignAndBinaryMap, CallAnalyzer $callAnalyzer) { $this->ifManipulator = $ifManipulator; $this->assignAndBinaryMap = $assignAndBinaryMap; $this->callAnalyzer = $callAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes Single return of && to early returns', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes Single return of && to early returns', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function accept() @@ -71,15 +71,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Return_::class]; + return [Return_::class]; } /** * @param Return_ $node * @return null|Node[] */ - public function refactor(\PhpParser\Node $node) : ?array + public function refactor(Node $node) : ?array { - if (!$node->expr instanceof \PhpParser\Node\Expr\BinaryOp\BooleanAnd) { + if (!$node->expr instanceof BooleanAnd) { return null; } $left = $node->expr->left; @@ -95,30 +95,30 @@ CODE_SAMPLE /** @var BooleanAnd $booleanAnd */ $booleanAnd = $node->expr; $lastReturnExpr = $this->assignAndBinaryMap->getTruthyExpr($booleanAnd->right); - return \array_merge($ifNegations, [new \PhpParser\Node\Stmt\Return_($lastReturnExpr)]); + return \array_merge($ifNegations, [new Return_($lastReturnExpr)]); } /** * @param If_[] $ifNegations * @return If_[] */ - private function createMultipleIfsNegation(\PhpParser\Node\Expr $expr, \PhpParser\Node\Stmt\Return_ $return, array $ifNegations) : array + private function createMultipleIfsNegation(Expr $expr, Return_ $return, array $ifNegations) : array { - while ($expr instanceof \PhpParser\Node\Expr\BinaryOp\BooleanAnd) { + while ($expr instanceof BooleanAnd) { $ifNegations = \array_merge($ifNegations, $this->collectLeftBooleanAndToIfs($expr, $return, $ifNegations)); - $ifNegations[] = $this->ifManipulator->createIfNegation($expr->right, new \PhpParser\Node\Stmt\Return_($this->nodeFactory->createFalse())); + $ifNegations[] = $this->ifManipulator->createIfNegation($expr->right, new Return_($this->nodeFactory->createFalse())); $expr = $expr->right; } - return $ifNegations + [$this->ifManipulator->createIfNegation($expr, new \PhpParser\Node\Stmt\Return_($this->nodeFactory->createFalse()))]; + return $ifNegations + [$this->ifManipulator->createIfNegation($expr, new Return_($this->nodeFactory->createFalse()))]; } /** * @param If_[] $ifNegations * @return If_[] */ - private function collectLeftBooleanAndToIfs(\PhpParser\Node\Expr\BinaryOp\BooleanAnd $booleanAnd, \PhpParser\Node\Stmt\Return_ $return, array $ifNegations) : array + private function collectLeftBooleanAndToIfs(BooleanAnd $booleanAnd, Return_ $return, array $ifNegations) : array { $left = $booleanAnd->left; - if (!$left instanceof \PhpParser\Node\Expr\BinaryOp\BooleanAnd) { - return [$this->ifManipulator->createIfNegation($left, new \PhpParser\Node\Stmt\Return_($this->nodeFactory->createFalse()))]; + if (!$left instanceof BooleanAnd) { + return [$this->ifManipulator->createIfNegation($left, new Return_($this->nodeFactory->createFalse()))]; } return $this->createMultipleIfsNegation($left, $return, $ifNegations); } diff --git a/rules/EarlyReturn/Rector/Return_/ReturnBinaryOrToEarlyReturnRector.php b/rules/EarlyReturn/Rector/Return_/ReturnBinaryOrToEarlyReturnRector.php index e628f49edab..1a6bfa36083 100644 --- a/rules/EarlyReturn/Rector/Return_/ReturnBinaryOrToEarlyReturnRector.php +++ b/rules/EarlyReturn/Rector/Return_/ReturnBinaryOrToEarlyReturnRector.php @@ -13,12 +13,12 @@ use Rector\Core\NodeAnalyzer\CallAnalyzer; use Rector\Core\NodeManipulator\IfManipulator; use Rector\Core\PhpParser\Node\AssignAndBinaryMap; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector\ReturnBinaryOrToEarlyReturnRectorTest */ -final class ReturnBinaryOrToEarlyReturnRector extends \Rector\Core\Rector\AbstractRector +final class ReturnBinaryOrToEarlyReturnRector extends AbstractRector { /** * @readonly @@ -35,15 +35,15 @@ final class ReturnBinaryOrToEarlyReturnRector extends \Rector\Core\Rector\Abstra * @var \Rector\Core\NodeAnalyzer\CallAnalyzer */ private $callAnalyzer; - public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator, \Rector\Core\PhpParser\Node\AssignAndBinaryMap $assignAndBinaryMap, \Rector\Core\NodeAnalyzer\CallAnalyzer $callAnalyzer) + public function __construct(IfManipulator $ifManipulator, AssignAndBinaryMap $assignAndBinaryMap, CallAnalyzer $callAnalyzer) { $this->ifManipulator = $ifManipulator; $this->assignAndBinaryMap = $assignAndBinaryMap; $this->callAnalyzer = $callAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes Single return of || to early returns', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes Single return of || to early returns', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function accept() @@ -71,15 +71,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Return_::class]; + return [Return_::class]; } /** * @param Return_ $node * @return null|Node[] */ - public function refactor(\PhpParser\Node $node) : ?array + public function refactor(Node $node) : ?array { - if (!$node->expr instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { + if (!$node->expr instanceof BooleanOr) { return null; } /** @var BooleanOr $booleanOr */ @@ -95,37 +95,37 @@ CODE_SAMPLE } $this->mirrorComments($ifs[0], $node); $lastReturnExpr = $this->assignAndBinaryMap->getTruthyExpr($booleanOr->right); - return \array_merge($ifs, [new \PhpParser\Node\Stmt\Return_($lastReturnExpr)]); + return \array_merge($ifs, [new Return_($lastReturnExpr)]); } /** * @param If_[] $ifs * @return If_[] */ - private function createMultipleIfs(\PhpParser\Node\Expr $expr, \PhpParser\Node\Stmt\Return_ $return, array $ifs) : array + private function createMultipleIfs(Expr $expr, Return_ $return, array $ifs) : array { - while ($expr instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { + while ($expr instanceof BooleanOr) { $ifs = \array_merge($ifs, $this->collectLeftBooleanOrToIfs($expr, $return, $ifs)); - $ifs[] = $this->ifManipulator->createIfStmt($expr->right, new \PhpParser\Node\Stmt\Return_($this->nodeFactory->createTrue())); + $ifs[] = $this->ifManipulator->createIfStmt($expr->right, new Return_($this->nodeFactory->createTrue())); $expr = $expr->right; - if ($expr instanceof \PhpParser\Node\Expr\BinaryOp\BooleanAnd) { + if ($expr instanceof BooleanAnd) { return []; } - if (!$expr instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { + if (!$expr instanceof BooleanOr) { continue; } return []; } - return $ifs + [$this->ifManipulator->createIfStmt($expr, new \PhpParser\Node\Stmt\Return_($this->nodeFactory->createTrue()))]; + return $ifs + [$this->ifManipulator->createIfStmt($expr, new Return_($this->nodeFactory->createTrue()))]; } /** * @param If_[] $ifs * @return If_[] */ - private function collectLeftBooleanOrToIfs(\PhpParser\Node\Expr\BinaryOp\BooleanOr $BooleanOr, \PhpParser\Node\Stmt\Return_ $return, array $ifs) : array + private function collectLeftBooleanOrToIfs(BooleanOr $BooleanOr, Return_ $return, array $ifs) : array { $left = $BooleanOr->left; - if (!$left instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { - return [$this->ifManipulator->createIfStmt($left, new \PhpParser\Node\Stmt\Return_($this->nodeFactory->createTrue()))]; + if (!$left instanceof BooleanOr) { + return [$this->ifManipulator->createIfStmt($left, new Return_($this->nodeFactory->createTrue()))]; } return $this->createMultipleIfs($left, $return, $ifs); } diff --git a/rules/MysqlToMysqli/Rector/Assign/MysqlAssignToMysqliRector.php b/rules/MysqlToMysqli/Rector/Assign/MysqlAssignToMysqliRector.php index 457ccffe766..20251126362 100644 --- a/rules/MysqlToMysqli/Rector/Assign/MysqlAssignToMysqliRector.php +++ b/rules/MysqlToMysqli/Rector/Assign/MysqlAssignToMysqliRector.php @@ -15,13 +15,13 @@ use PhpParser\Node\Name; use PhpParser\Node\Scalar\LNumber; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.phpclasses.org/blog/package/9199/post/3-Smoothly-Migrate-your-PHP-Code-using-the-Old-MySQL-extension-to-MySQLi.html * @see \Rector\Tests\MysqlToMysqli\Rector\Assign\MysqlAssignToMysqliRector\MysqlAssignToMysqliRectorTest */ -final class MysqlAssignToMysqliRector extends \Rector\Core\Rector\AbstractRector +final class MysqlAssignToMysqliRector extends AbstractRector { /** * @var array @@ -31,9 +31,9 @@ final class MysqlAssignToMysqliRector extends \Rector\Core\Rector\AbstractRector * @var string */ private const MYSQLI_DATA_SEEK = 'mysqli_data_seek'; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Converts more complex mysql functions to mysqli', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Converts more complex mysql functions to mysqli', [new CodeSample(<<<'CODE_SAMPLE' $data = mysql_db_name($result, $row); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -48,14 +48,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Assign::class]; + return [Assign::class]; } /** * @param Assign $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->expr instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$node->expr instanceof FuncCall) { return null; } /** @var FuncCall $funcCallNode */ @@ -77,67 +77,67 @@ CODE_SAMPLE } return $this->processFieldToFieldDirect($node, $funcCallNode); } - private function processMysqlTableName(\PhpParser\Node\Expr\Assign $assign, \PhpParser\Node\Expr\FuncCall $funcCall) : \PhpParser\Node\Expr\FuncCall + private function processMysqlTableName(Assign $assign, FuncCall $funcCall) : FuncCall { - $funcCall->name = new \PhpParser\Node\Name(self::MYSQLI_DATA_SEEK); - $newFuncCall = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('mysql_fetch_array'), [$funcCall->args[0]]); - $newAssignNode = new \PhpParser\Node\Expr\Assign($assign->var, new \PhpParser\Node\Expr\ArrayDimFetch($newFuncCall, new \PhpParser\Node\Scalar\LNumber(0))); + $funcCall->name = new Name(self::MYSQLI_DATA_SEEK); + $newFuncCall = new FuncCall(new Name('mysql_fetch_array'), [$funcCall->args[0]]); + $newAssignNode = new Assign($assign->var, new ArrayDimFetch($newFuncCall, new LNumber(0))); $this->nodesToAddCollector->addNodeAfterNode($newAssignNode, $assign); return $funcCall; } - private function processMysqlDbName(\PhpParser\Node\Expr\Assign $assign, \PhpParser\Node\Expr\FuncCall $funcCall) : \PhpParser\Node\Expr\FuncCall + private function processMysqlDbName(Assign $assign, FuncCall $funcCall) : FuncCall { - $funcCall->name = new \PhpParser\Node\Name(self::MYSQLI_DATA_SEEK); - $mysqlFetchRowFuncCall = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('mysqli_fetch_row'), [$funcCall->args[0]]); - $fetchVariable = new \PhpParser\Node\Expr\Variable('fetch'); - $newAssignNode = new \PhpParser\Node\Expr\Assign($fetchVariable, $mysqlFetchRowFuncCall); + $funcCall->name = new Name(self::MYSQLI_DATA_SEEK); + $mysqlFetchRowFuncCall = new FuncCall(new Name('mysqli_fetch_row'), [$funcCall->args[0]]); + $fetchVariable = new Variable('fetch'); + $newAssignNode = new Assign($fetchVariable, $mysqlFetchRowFuncCall); $this->nodesToAddCollector->addNodeAfterNode($newAssignNode, $assign); - $newAssignNodeAfter = new \PhpParser\Node\Expr\Assign($assign->var, new \PhpParser\Node\Expr\ArrayDimFetch($fetchVariable, new \PhpParser\Node\Scalar\LNumber(0))); + $newAssignNodeAfter = new Assign($assign->var, new ArrayDimFetch($fetchVariable, new LNumber(0))); $this->nodesToAddCollector->addNodeAfterNode($newAssignNodeAfter, $assign); return $funcCall; } - private function processMysqliSelectDb(\PhpParser\Node\Expr\Assign $assign, \PhpParser\Node\Expr\FuncCall $funcCall) : \PhpParser\Node\Expr\FuncCall + private function processMysqliSelectDb(Assign $assign, FuncCall $funcCall) : FuncCall { - $funcCall->name = new \PhpParser\Node\Name('mysqli_select_db'); - $newAssignNode = new \PhpParser\Node\Expr\Assign($assign->var, new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('mysqli_query'), [$funcCall->args[1]])); + $funcCall->name = new Name('mysqli_select_db'); + $newAssignNode = new Assign($assign->var, new FuncCall(new Name('mysqli_query'), [$funcCall->args[1]])); $this->nodesToAddCollector->addNodeAfterNode($newAssignNode, $assign); unset($funcCall->args[1]); return $funcCall; } - private function processMysqlFetchField(\PhpParser\Node\Expr\Assign $assign, \PhpParser\Node\Expr\FuncCall $funcCall) : \PhpParser\Node\Expr\Assign + private function processMysqlFetchField(Assign $assign, FuncCall $funcCall) : Assign { - $funcCall->name = isset($funcCall->args[1]) ? new \PhpParser\Node\Name('mysqli_fetch_field_direct') : new \PhpParser\Node\Name('mysqli_fetch_field'); + $funcCall->name = isset($funcCall->args[1]) ? new Name('mysqli_fetch_field_direct') : new Name('mysqli_fetch_field'); return $assign; } - private function processMysqlResult(\PhpParser\Node\Expr\Assign $assign, \PhpParser\Node\Expr\FuncCall $funcCall) : \PhpParser\Node\Expr\FuncCall + private function processMysqlResult(Assign $assign, FuncCall $funcCall) : FuncCall { $fetchField = null; - if (isset($funcCall->args[2]) && $funcCall->args[2] instanceof \PhpParser\Node\Arg) { + if (isset($funcCall->args[2]) && $funcCall->args[2] instanceof Arg) { $fetchField = $funcCall->args[2]->value; unset($funcCall->args[2]); } - $funcCall->name = new \PhpParser\Node\Name(self::MYSQLI_DATA_SEEK); - $mysqlFetchArrayFuncCall = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('mysqli_fetch_array'), [$funcCall->args[0]]); - $fetchVariable = new \PhpParser\Node\Expr\Variable('fetch'); - $newAssignNode = new \PhpParser\Node\Expr\Assign($fetchVariable, $mysqlFetchArrayFuncCall); + $funcCall->name = new Name(self::MYSQLI_DATA_SEEK); + $mysqlFetchArrayFuncCall = new FuncCall(new Name('mysqli_fetch_array'), [$funcCall->args[0]]); + $fetchVariable = new Variable('fetch'); + $newAssignNode = new Assign($fetchVariable, $mysqlFetchArrayFuncCall); $this->nodesToAddCollector->addNodeAfterNode($newAssignNode, $assign); - $newAssignNodeAfter = new \PhpParser\Node\Expr\Assign($assign->var, new \PhpParser\Node\Expr\ArrayDimFetch($fetchVariable, $fetchField ?? new \PhpParser\Node\Scalar\LNumber(0))); + $newAssignNodeAfter = new Assign($assign->var, new ArrayDimFetch($fetchVariable, $fetchField ?? new LNumber(0))); $this->nodesToAddCollector->addNodeAfterNode($newAssignNodeAfter, $assign); return $funcCall; } - private function processFieldToFieldDirect(\PhpParser\Node\Expr\Assign $assign, \PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Expr\Assign + private function processFieldToFieldDirect(Assign $assign, FuncCall $funcCall) : ?Assign { foreach (self::FIELD_TO_FIELD_DIRECT as $funcName => $property) { if ($this->isName($funcCall, $funcName)) { - $parentNode = $funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentNode instanceof \PhpParser\Node\Expr\PropertyFetch) { + $parentNode = $funcCall->getAttribute(AttributeKey::PARENT_NODE); + if ($parentNode instanceof PropertyFetch) { continue; } - if ($parentNode instanceof \PhpParser\Node\Expr\StaticPropertyFetch) { + if ($parentNode instanceof StaticPropertyFetch) { continue; } - $funcCall->name = new \PhpParser\Node\Name('mysqli_fetch_field_direct'); - $assign->expr = new \PhpParser\Node\Expr\PropertyFetch($funcCall, $property); + $funcCall->name = new Name('mysqli_fetch_field_direct'); + $assign->expr = new PropertyFetch($funcCall, $property); return $assign; } } diff --git a/rules/MysqlToMysqli/Rector/FuncCall/MysqlFuncCallToMysqliRector.php b/rules/MysqlToMysqli/Rector/FuncCall/MysqlFuncCallToMysqliRector.php index b94a9070c9e..4732a68702c 100644 --- a/rules/MysqlToMysqli/Rector/FuncCall/MysqlFuncCallToMysqliRector.php +++ b/rules/MysqlToMysqli/Rector/FuncCall/MysqlFuncCallToMysqliRector.php @@ -11,22 +11,22 @@ use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Name; use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.phpclasses.org/blog/package/9199/post/3-Smoothly-Migrate-your-PHP-Code-using-the-Old-MySQL-extension-to-MySQLi.html * * @see \Rector\Tests\MysqlToMysqli\Rector\FuncCall\MysqlFuncCallToMysqliRector\MysqlFuncCallToMysqliRectorTest */ -final class MysqlFuncCallToMysqliRector extends \Rector\Core\Rector\AbstractRector +final class MysqlFuncCallToMysqliRector extends AbstractRector { /** * @var string */ private const MYSQLI_QUERY = 'mysqli_query'; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Converts more complex mysql functions to mysqli', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Converts more complex mysql functions to mysqli', [new CodeSample(<<<'CODE_SAMPLE' mysql_drop_db($database); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -39,12 +39,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Expr\FuncCall + public function refactor(Node $node) : ?FuncCall { if ($this->isName($node, 'mysql_create_db')) { return $this->processMysqlCreateDb($node); @@ -53,55 +53,55 @@ CODE_SAMPLE return $this->processMysqlDropDb($node); } if ($this->isName($node, 'mysql_list_dbs')) { - $node->name = new \PhpParser\Node\Name(self::MYSQLI_QUERY); - $node->args[0] = new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\String_('SHOW DATABASES')); + $node->name = new Name(self::MYSQLI_QUERY); + $node->args[0] = new Arg(new String_('SHOW DATABASES')); return $node; } - if ($this->isName($node, 'mysql_list_fields') && $node->args[0] instanceof \PhpParser\Node\Arg && $node->args[1] instanceof \PhpParser\Node\Arg) { - $node->name = new \PhpParser\Node\Name(self::MYSQLI_QUERY); + if ($this->isName($node, 'mysql_list_fields') && $node->args[0] instanceof Arg && $node->args[1] instanceof Arg) { + $node->name = new Name(self::MYSQLI_QUERY); $node->args[0]->value = $this->joinStringWithNode('SHOW COLUMNS FROM', $node->args[1]->value); unset($node->args[1]); return $node; } - if ($this->isName($node, 'mysql_list_tables') && $node->args[0] instanceof \PhpParser\Node\Arg) { - $node->name = new \PhpParser\Node\Name(self::MYSQLI_QUERY); + if ($this->isName($node, 'mysql_list_tables') && $node->args[0] instanceof Arg) { + $node->name = new Name(self::MYSQLI_QUERY); $node->args[0]->value = $this->joinStringWithNode('SHOW TABLES FROM', $node->args[0]->value); return $node; } return null; } - private function processMysqlCreateDb(\PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Expr\FuncCall + private function processMysqlCreateDb(FuncCall $funcCall) : ?FuncCall { if (!isset($funcCall->args[0])) { return null; } - if (!$funcCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[0] instanceof Arg) { return null; } - $funcCall->name = new \PhpParser\Node\Name(self::MYSQLI_QUERY); + $funcCall->name = new Name(self::MYSQLI_QUERY); $funcCall->args[0]->value = $this->joinStringWithNode('CREATE DATABASE', $funcCall->args[0]->value); return $funcCall; } - private function processMysqlDropDb(\PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Expr\FuncCall + private function processMysqlDropDb(FuncCall $funcCall) : ?FuncCall { if (!isset($funcCall->args[0])) { return null; } - if (!$funcCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[0] instanceof Arg) { return null; } - $funcCall->name = new \PhpParser\Node\Name(self::MYSQLI_QUERY); + $funcCall->name = new Name(self::MYSQLI_QUERY); $funcCall->args[0]->value = $this->joinStringWithNode('DROP DATABASE', $funcCall->args[0]->value); return $funcCall; } /** * @return \PhpParser\Node\Scalar\String_|\PhpParser\Node\Expr\BinaryOp\Concat */ - private function joinStringWithNode(string $string, \PhpParser\Node\Expr $expr) + private function joinStringWithNode(string $string, Expr $expr) { - if ($expr instanceof \PhpParser\Node\Scalar\String_) { - return new \PhpParser\Node\Scalar\String_($string . ' ' . $expr->value); + if ($expr instanceof String_) { + return new String_($string . ' ' . $expr->value); } - return new \PhpParser\Node\Expr\BinaryOp\Concat(new \PhpParser\Node\Scalar\String_($string . ' '), $expr); + return new Concat(new String_($string . ' '), $expr); } } diff --git a/rules/MysqlToMysqli/Rector/FuncCall/MysqlPConnectToMysqliConnectRector.php b/rules/MysqlToMysqli/Rector/FuncCall/MysqlPConnectToMysqliConnectRector.php index e15ef052c32..0c9a51b3292 100644 --- a/rules/MysqlToMysqli/Rector/FuncCall/MysqlPConnectToMysqliConnectRector.php +++ b/rules/MysqlToMysqli/Rector/FuncCall/MysqlPConnectToMysqliConnectRector.php @@ -11,17 +11,17 @@ use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Name; use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://stackoverflow.com/a/34041762/1348344 * @see \Rector\Tests\MysqlToMysqli\Rector\FuncCall\MysqlPConnectToMysqliConnectRector\MysqlPConnectToMysqliConnectRectorTest */ -final class MysqlPConnectToMysqliConnectRector extends \Rector\Core\Rector\AbstractRector +final class MysqlPConnectToMysqliConnectRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace mysql_pconnect() with mysqli_connect() with host p: prefix', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace mysql_pconnect() with mysqli_connect() with host p: prefix', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run($host, $username, $password) @@ -46,12 +46,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'mysql_pconnect')) { return null; @@ -59,21 +59,21 @@ CODE_SAMPLE if (!isset($node->args[0])) { return null; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } - $node->name = new \PhpParser\Node\Name('mysqli_connect'); + $node->name = new Name('mysqli_connect'); $node->args[0]->value = $this->joinStringWithNode('p:', $node->args[0]->value); return $node; } /** * @return \PhpParser\Node\Scalar\String_|\PhpParser\Node\Expr\BinaryOp\Concat */ - private function joinStringWithNode(string $string, \PhpParser\Node\Expr $expr) + private function joinStringWithNode(string $string, Expr $expr) { - if ($expr instanceof \PhpParser\Node\Scalar\String_) { - return new \PhpParser\Node\Scalar\String_($string . $expr->value); + if ($expr instanceof String_) { + return new String_($string . $expr->value); } - return new \PhpParser\Node\Expr\BinaryOp\Concat(new \PhpParser\Node\Scalar\String_($string), $expr); + return new Concat(new String_($string), $expr); } } diff --git a/rules/MysqlToMysqli/Rector/FuncCall/MysqlQueryMysqlErrorWithLinkRector.php b/rules/MysqlToMysqli/Rector/FuncCall/MysqlQueryMysqlErrorWithLinkRector.php index 56cdc51d068..0bbe8d198c7 100644 --- a/rules/MysqlToMysqli/Rector/FuncCall/MysqlQueryMysqlErrorWithLinkRector.php +++ b/rules/MysqlToMysqli/Rector/FuncCall/MysqlQueryMysqlErrorWithLinkRector.php @@ -15,14 +15,14 @@ use PHPStan\Type\ResourceType; use PHPStan\Type\Type; use PHPStan\Type\UnionType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/mysqli.error.php * * @see \Rector\Tests\MysqlToMysqli\Rector\FuncCall\MysqlQueryMysqlErrorWithLinkRector\MysqlQueryMysqlErrorWithLinkRectorTest */ -final class MysqlQueryMysqlErrorWithLinkRector extends \Rector\Core\Rector\AbstractRector +final class MysqlQueryMysqlErrorWithLinkRector extends AbstractRector { /** * @var array @@ -32,9 +32,9 @@ final class MysqlQueryMysqlErrorWithLinkRector extends \Rector\Core\Rector\Abstr * @var array */ private const FUNCTION_CONNECTION_PARAMETER_POSITION_MAP = ['mysql_affected_rows' => 0, 'mysql_client_encoding' => 0, 'mysql_close' => 0, 'mysql_errno' => 0, 'mysql_error' => 0, 'mysql_get_host_info' => 0, 'mysql_get_proto_info' => 0, 'mysql_get_server_info' => 0, 'mysql_info' => 0, 'mysql_insert_id' => 0, 'mysql_ping' => 0, 'mysql_query' => 1, 'mysql_real_escape_string' => 1, 'mysql_select_db' => 1, 'mysql_set_charset' => 1, 'mysql_stat' => 0, 'mysql_thread_id' => 0]; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add mysql_query and mysql_error with connection', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add mysql_query and mysql_error with connection', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -69,12 +69,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach (self::FUNCTION_RENAME_MAP as $oldFunction => $newFunction) { if (!$this->isName($node, $oldFunction)) { @@ -84,51 +84,51 @@ CODE_SAMPLE if ($args === [] || !$this->isProbablyMysql($args[0]->value)) { $connectionVariable = $this->findConnectionVariable($node); $this->removeExistingConnectionParameter($node); - if (!$connectionVariable instanceof \PhpParser\Node\Expr) { + if (!$connectionVariable instanceof Expr) { return null; } - $node->args = \array_merge([new \PhpParser\Node\Arg($connectionVariable)], $node->args); + $node->args = \array_merge([new Arg($connectionVariable)], $node->args); } - $node->name = new \PhpParser\Node\Name($newFunction); + $node->name = new Name($newFunction); return $node; } return null; } - private function isProbablyMysql(\PhpParser\Node\Expr $expr) : bool + private function isProbablyMysql(Expr $expr) : bool { - if ($this->isObjectType($expr, new \PHPStan\Type\ObjectType('mysqli'))) { + if ($this->isObjectType($expr, new ObjectType('mysqli'))) { return \true; } $staticType = $this->getType($expr); - $resourceType = new \PHPStan\Type\ResourceType(); + $resourceType = new ResourceType(); if ($staticType->equals($resourceType)) { return \true; } if ($this->isUnionTypeWithResourceSubType($staticType, $resourceType)) { return \true; } - if (!$expr instanceof \PhpParser\Node\Expr\Variable) { + if (!$expr instanceof Variable) { return \false; } return $this->isMysqliConnect($expr); } - private function findConnectionVariable(\PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Expr + private function findConnectionVariable(FuncCall $funcCall) : ?Expr { - $connectionAssign = $this->betterNodeFinder->findFirstPrevious($funcCall, function (\PhpParser\Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + $connectionAssign = $this->betterNodeFinder->findFirstPrevious($funcCall, function (Node $node) : bool { + if (!$node instanceof Assign) { return \false; } - if ($this->isObjectType($node->expr, new \PHPStan\Type\ObjectType('mysqli'))) { + if ($this->isObjectType($node->expr, new ObjectType('mysqli'))) { return \true; } - return $node->expr instanceof \PhpParser\Node\Expr\FuncCall && $this->nodeNameResolver->isName($node->expr, 'mysqli_connect'); + return $node->expr instanceof FuncCall && $this->nodeNameResolver->isName($node->expr, 'mysqli_connect'); }); - if (!$connectionAssign instanceof \PhpParser\Node\Expr\Assign) { + if (!$connectionAssign instanceof Assign) { return null; } return $connectionAssign->var; } - private function removeExistingConnectionParameter(\PhpParser\Node\Expr\FuncCall $funcCall) : void + private function removeExistingConnectionParameter(FuncCall $funcCall) : void { /** @var string $functionName */ $functionName = $this->getName($funcCall); @@ -138,9 +138,9 @@ CODE_SAMPLE $connectionPosition = self::FUNCTION_CONNECTION_PARAMETER_POSITION_MAP[$functionName]; unset($funcCall->args[$connectionPosition]); } - private function isUnionTypeWithResourceSubType(\PHPStan\Type\Type $staticType, \PHPStan\Type\ResourceType $resourceType) : bool + private function isUnionTypeWithResourceSubType(Type $staticType, ResourceType $resourceType) : bool { - if ($staticType instanceof \PHPStan\Type\UnionType) { + if ($staticType instanceof UnionType) { foreach ($staticType->getTypes() as $type) { if ($type->equals($resourceType)) { return \true; @@ -149,13 +149,13 @@ CODE_SAMPLE } return \false; } - private function isMysqliConnect(\PhpParser\Node\Expr\Variable $variable) : bool + private function isMysqliConnect(Variable $variable) : bool { - return (bool) $this->betterNodeFinder->findFirstPrevious($variable, function (\PhpParser\Node $node) use($variable) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + return (bool) $this->betterNodeFinder->findFirstPrevious($variable, function (Node $node) use($variable) : bool { + if (!$node instanceof Assign) { return \false; } - if (!$node->expr instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$node->expr instanceof FuncCall) { return \false; } if (!$this->nodeComparator->areNodesEqual($node->var, $variable)) { diff --git a/rules/Naming/AssignVariableNameResolver/NewAssignVariableNameResolver.php b/rules/Naming/AssignVariableNameResolver/NewAssignVariableNameResolver.php index e41cc326bfa..45310fb0fec 100644 --- a/rules/Naming/AssignVariableNameResolver/NewAssignVariableNameResolver.php +++ b/rules/Naming/AssignVariableNameResolver/NewAssignVariableNameResolver.php @@ -11,29 +11,29 @@ use Rector\NodeNameResolver\NodeNameResolver; /** * @implements AssignVariableNameResolverInterface */ -final class NewAssignVariableNameResolver implements \Rector\Naming\Contract\AssignVariableNameResolverInterface +final class NewAssignVariableNameResolver implements AssignVariableNameResolverInterface { /** * @readonly * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } - public function match(\PhpParser\Node $node) : bool + public function match(Node $node) : bool { - return $node instanceof \PhpParser\Node\Expr\New_; + return $node instanceof New_; } /** * @param New_ $node */ - public function resolve(\PhpParser\Node $node) : string + public function resolve(Node $node) : string { $className = $this->nodeNameResolver->getName($node->class); if ($className === null) { - throw new \Rector\Core\Exception\NotImplementedYetException(); + throw new NotImplementedYetException(); } return $this->nodeNameResolver->getShortName($className); } diff --git a/rules/Naming/AssignVariableNameResolver/PropertyFetchAssignVariableNameResolver.php b/rules/Naming/AssignVariableNameResolver/PropertyFetchAssignVariableNameResolver.php index d7c41323050..cc130517b9e 100644 --- a/rules/Naming/AssignVariableNameResolver/PropertyFetchAssignVariableNameResolver.php +++ b/rules/Naming/AssignVariableNameResolver/PropertyFetchAssignVariableNameResolver.php @@ -11,33 +11,33 @@ use Rector\NodeNameResolver\NodeNameResolver; /** * @implements AssignVariableNameResolverInterface */ -final class PropertyFetchAssignVariableNameResolver implements \Rector\Naming\Contract\AssignVariableNameResolverInterface +final class PropertyFetchAssignVariableNameResolver implements AssignVariableNameResolverInterface { /** * @readonly * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } - public function match(\PhpParser\Node $node) : bool + public function match(Node $node) : bool { - return $node instanceof \PhpParser\Node\Expr\PropertyFetch; + return $node instanceof PropertyFetch; } /** * @param PropertyFetch $node */ - public function resolve(\PhpParser\Node $node) : string + public function resolve(Node $node) : string { $varName = $this->nodeNameResolver->getName($node->var); if (!\is_string($varName)) { - throw new \Rector\Core\Exception\NotImplementedYetException(); + throw new NotImplementedYetException(); } $propertyName = $this->nodeNameResolver->getName($node->name); if (!\is_string($propertyName)) { - throw new \Rector\Core\Exception\NotImplementedYetException(); + throw new NotImplementedYetException(); } if ($varName === 'this') { return $propertyName; diff --git a/rules/Naming/Contract/AssignVariableNameResolverInterface.php b/rules/Naming/Contract/AssignVariableNameResolverInterface.php index b7d947810a3..ea4b754c507 100644 --- a/rules/Naming/Contract/AssignVariableNameResolverInterface.php +++ b/rules/Naming/Contract/AssignVariableNameResolverInterface.php @@ -9,9 +9,9 @@ use PhpParser\Node; */ interface AssignVariableNameResolverInterface { - public function match(\PhpParser\Node $node) : bool; + public function match(Node $node) : bool; /** * @param TNode $node */ - public function resolve(\PhpParser\Node $node) : string; + public function resolve(Node $node) : string; } diff --git a/rules/Naming/Contract/Guard/ConflictingNameGuardInterface.php b/rules/Naming/Contract/Guard/ConflictingNameGuardInterface.php index c6a2b74132d..8fcf79eb9b3 100644 --- a/rules/Naming/Contract/Guard/ConflictingNameGuardInterface.php +++ b/rules/Naming/Contract/Guard/ConflictingNameGuardInterface.php @@ -12,5 +12,5 @@ interface ConflictingNameGuardInterface /** * @param TRename $renameValueObject */ - public function isConflicting(\Rector\Naming\Contract\RenameValueObjectInterface $renameValueObject) : bool; + public function isConflicting(RenameValueObjectInterface $renameValueObject) : bool; } diff --git a/rules/Naming/Contract/RenameParamValueObjectInterface.php b/rules/Naming/Contract/RenameParamValueObjectInterface.php index 6568ce9b6de..dcb6b588fa1 100644 --- a/rules/Naming/Contract/RenameParamValueObjectInterface.php +++ b/rules/Naming/Contract/RenameParamValueObjectInterface.php @@ -13,5 +13,5 @@ interface RenameParamValueObjectInterface extends \Rector\Naming\Contract\Rename * @return \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure */ public function getFunctionLike(); - public function getParam() : \PhpParser\Node\Param; + public function getParam() : Param; } diff --git a/rules/Naming/Contract/RenamePropertyValueObjectInterface.php b/rules/Naming/Contract/RenamePropertyValueObjectInterface.php index 3c274e1617b..ed7bceb0dd0 100644 --- a/rules/Naming/Contract/RenamePropertyValueObjectInterface.php +++ b/rules/Naming/Contract/RenamePropertyValueObjectInterface.php @@ -8,8 +8,8 @@ use PhpParser\Node\Stmt\Property; use PhpParser\Node\Stmt\PropertyProperty; interface RenamePropertyValueObjectInterface extends \Rector\Naming\Contract\RenameValueObjectInterface { - public function getClassLike() : \PhpParser\Node\Stmt\ClassLike; + public function getClassLike() : ClassLike; public function getClassLikeName() : string; - public function getProperty() : \PhpParser\Node\Stmt\Property; - public function getPropertyProperty() : \PhpParser\Node\Stmt\PropertyProperty; + public function getProperty() : Property; + public function getPropertyProperty() : PropertyProperty; } diff --git a/rules/Naming/ExpectedNameResolver/InflectorSingularResolver.php b/rules/Naming/ExpectedNameResolver/InflectorSingularResolver.php index 7e65c3e600e..47610b8e22c 100644 --- a/rules/Naming/ExpectedNameResolver/InflectorSingularResolver.php +++ b/rules/Naming/ExpectedNameResolver/InflectorSingularResolver.php @@ -38,15 +38,15 @@ final class InflectorSingularResolver * @var \Doctrine\Inflector\Inflector */ private $inflector; - public function __construct(\RectorPrefix20220607\Doctrine\Inflector\Inflector $inflector) + public function __construct(Inflector $inflector) { $this->inflector = $inflector; } public function resolve(string $currentName) : string { - $matchBy = \RectorPrefix20220607\Nette\Utils\Strings::match($currentName, self::BY_MIDDLE_REGEX); + $matchBy = Strings::match($currentName, self::BY_MIDDLE_REGEX); if ($matchBy !== null) { - return \RectorPrefix20220607\Nette\Utils\Strings::substring($currentName, 0, -\strlen((string) $matchBy['by'])); + return Strings::substring($currentName, 0, -\strlen((string) $matchBy['by'])); } $resolvedValue = $this->resolveSingularizeMap($currentName); if ($resolvedValue !== null) { @@ -78,12 +78,12 @@ final class InflectorSingularResolver if ($currentName === $plural) { return $singular; } - if (\Rector\Core\Util\StringUtils::isMatch($currentName, '#' . \ucfirst($plural) . '#')) { - $resolvedValue = \RectorPrefix20220607\Nette\Utils\Strings::replace($currentName, '#' . \ucfirst($plural) . '#', \ucfirst($singular)); + if (StringUtils::isMatch($currentName, '#' . \ucfirst($plural) . '#')) { + $resolvedValue = Strings::replace($currentName, '#' . \ucfirst($plural) . '#', \ucfirst($singular)); return $this->singularizeCamelParts($resolvedValue); } - if (\Rector\Core\Util\StringUtils::isMatch($currentName, '#' . $plural . '#')) { - $resolvedValue = \RectorPrefix20220607\Nette\Utils\Strings::replace($currentName, '#' . $plural . '#', $singular); + if (StringUtils::isMatch($currentName, '#' . $plural . '#')) { + $resolvedValue = Strings::replace($currentName, '#' . $plural . '#', $singular); return $this->singularizeCamelParts($resolvedValue); } } @@ -91,7 +91,7 @@ final class InflectorSingularResolver } private function singularizeCamelParts(string $currentName) : string { - $camelCases = \RectorPrefix20220607\Nette\Utils\Strings::matchAll($currentName, self::CAMELCASE_REGEX); + $camelCases = Strings::matchAll($currentName, self::CAMELCASE_REGEX); $resolvedName = ''; foreach ($camelCases as $camelCase) { $value = $this->inflector->singularize($camelCase[self::CAMELCASE]); diff --git a/rules/Naming/ExpectedNameResolver/MatchParamTypeExpectedNameResolver.php b/rules/Naming/ExpectedNameResolver/MatchParamTypeExpectedNameResolver.php index 3cf4549f153..9da22b95d1a 100644 --- a/rules/Naming/ExpectedNameResolver/MatchParamTypeExpectedNameResolver.php +++ b/rules/Naming/ExpectedNameResolver/MatchParamTypeExpectedNameResolver.php @@ -19,12 +19,12 @@ final class MatchParamTypeExpectedNameResolver * @var \Rector\Naming\Naming\PropertyNaming */ private $propertyNaming; - public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\Naming\Naming\PropertyNaming $propertyNaming) + public function __construct(StaticTypeMapper $staticTypeMapper, PropertyNaming $propertyNaming) { $this->staticTypeMapper = $staticTypeMapper; $this->propertyNaming = $propertyNaming; } - public function resolve(\PhpParser\Node\Param $param) : ?string + public function resolve(Param $param) : ?string { // nothing to verify if ($param->type === null) { @@ -32,7 +32,7 @@ final class MatchParamTypeExpectedNameResolver } $staticType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($param->type); $expectedName = $this->propertyNaming->getExpectedNameFromType($staticType); - if (!$expectedName instanceof \Rector\Naming\ValueObject\ExpectedName) { + if (!$expectedName instanceof ExpectedName) { return null; } return $expectedName->getName(); diff --git a/rules/Naming/ExpectedNameResolver/MatchPropertyTypeExpectedNameResolver.php b/rules/Naming/ExpectedNameResolver/MatchPropertyTypeExpectedNameResolver.php index 66489ecd44b..8adf5fac2d5 100644 --- a/rules/Naming/ExpectedNameResolver/MatchPropertyTypeExpectedNameResolver.php +++ b/rules/Naming/ExpectedNameResolver/MatchPropertyTypeExpectedNameResolver.php @@ -45,7 +45,7 @@ final class MatchPropertyTypeExpectedNameResolver * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Naming\Naming\PropertyNaming $propertyNaming, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\NodeManipulator\PropertyManipulator $propertyManipulator, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(PropertyNaming $propertyNaming, PhpDocInfoFactory $phpDocInfoFactory, NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder, PropertyManipulator $propertyManipulator, ReflectionResolver $reflectionResolver) { $this->propertyNaming = $propertyNaming; $this->phpDocInfoFactory = $phpDocInfoFactory; @@ -54,14 +54,14 @@ final class MatchPropertyTypeExpectedNameResolver $this->propertyManipulator = $propertyManipulator; $this->reflectionResolver = $reflectionResolver; } - public function resolve(\PhpParser\Node\Stmt\Property $property) : ?string + public function resolve(Property $property) : ?string { - $class = $this->betterNodeFinder->findParentType($property, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($property, Class_::class); + if (!$class instanceof Class_) { return null; } $classReflection = $this->reflectionResolver->resolveClassReflection($property); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return null; } $propertyName = $this->nodeNameResolver->getName($property); @@ -70,7 +70,7 @@ final class MatchPropertyTypeExpectedNameResolver } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); $expectedName = $this->propertyNaming->getExpectedNameFromType($phpDocInfo->getVarType()); - if (!$expectedName instanceof \Rector\Naming\ValueObject\ExpectedName) { + if (!$expectedName instanceof ExpectedName) { return null; } // skip if already has suffix diff --git a/rules/Naming/Guard/BreakingVariableRenameGuard.php b/rules/Naming/Guard/BreakingVariableRenameGuard.php index e9456b794d7..ac9ffe49849 100644 --- a/rules/Naming/Guard/BreakingVariableRenameGuard.php +++ b/rules/Naming/Guard/BreakingVariableRenameGuard.php @@ -63,7 +63,7 @@ final class BreakingVariableRenameGuard * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Naming\Naming\ConflictingNameResolver $conflictingNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\Naming\Naming\OverridenExistingNamesResolver $overridenExistingNamesResolver, \Rector\PHPStanStaticTypeMapper\Utils\TypeUnwrapper $typeUnwrapper, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(BetterNodeFinder $betterNodeFinder, ConflictingNameResolver $conflictingNameResolver, NodeTypeResolver $nodeTypeResolver, OverridenExistingNamesResolver $overridenExistingNamesResolver, TypeUnwrapper $typeUnwrapper, NodeNameResolver $nodeNameResolver) { $this->betterNodeFinder = $betterNodeFinder; $this->conflictingNameResolver = $conflictingNameResolver; @@ -75,7 +75,7 @@ final class BreakingVariableRenameGuard /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $functionLike */ - public function shouldSkipVariable(string $currentName, string $expectedName, $functionLike, \PhpParser\Node\Expr\Variable $variable) : bool + public function shouldSkipVariable(string $currentName, string $expectedName, $functionLike, Variable $variable) : bool { // is the suffix? → also accepted $expectedNameCamelCase = \ucfirst($expectedName); @@ -105,7 +105,7 @@ final class BreakingVariableRenameGuard /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $classMethod */ - public function shouldSkipParam(string $currentName, string $expectedName, $classMethod, \PhpParser\Node\Param $param) : bool + public function shouldSkipParam(string $currentName, string $expectedName, $classMethod, Param $param) : bool { // is the suffix? → also accepted $expectedNameCamelCase = \ucfirst($expectedName); @@ -131,17 +131,17 @@ final class BreakingVariableRenameGuard if ($this->isDateTimeAtNamingConvention($param)) { return \true; } - return (bool) $this->betterNodeFinder->find((array) $classMethod->stmts, function (\PhpParser\Node $node) use($expectedName) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + return (bool) $this->betterNodeFinder->find((array) $classMethod->stmts, function (Node $node) use($expectedName) : bool { + if (!$node instanceof Variable) { return \false; } return $this->nodeNameResolver->isName($node, $expectedName); }); } - private function isVariableAlreadyDefined(\PhpParser\Node\Expr\Variable $variable, string $currentVariableName) : bool + private function isVariableAlreadyDefined(Variable $variable, string $currentVariableName) : bool { - $scope = $variable->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { + $scope = $variable->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { return \false; } $trinaryLogic = $scope->hasVariableType($currentVariableName); @@ -155,22 +155,22 @@ final class BreakingVariableRenameGuard */ private function hasConflictVariable($functionLike, string $newName) : bool { - return $this->betterNodeFinder->hasInstanceOfName((array) $functionLike->stmts, \PhpParser\Node\Expr\Variable::class, $newName); + return $this->betterNodeFinder->hasInstanceOfName((array) $functionLike->stmts, Variable::class, $newName); } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $functionLike */ private function isUsedInClosureUsesName(string $expectedName, $functionLike) : bool { - if (!$functionLike instanceof \PhpParser\Node\Expr\Closure) { + if (!$functionLike instanceof Closure) { return \false; } return $this->betterNodeFinder->hasVariableOfName($functionLike->uses, $expectedName); } - private function isUsedInForeachKeyValueVar(\PhpParser\Node\Expr\Variable $variable, string $currentName) : bool + private function isUsedInForeachKeyValueVar(Variable $variable, string $currentName) : bool { - $previousForeach = $this->betterNodeFinder->findFirstPreviousOfTypes($variable, [\PhpParser\Node\Stmt\Foreach_::class]); - if ($previousForeach instanceof \PhpParser\Node\Stmt\Foreach_) { + $previousForeach = $this->betterNodeFinder->findFirstPreviousOfTypes($variable, [Foreach_::class]); + if ($previousForeach instanceof Foreach_) { if ($previousForeach->keyVar === $variable) { return \false; } @@ -189,11 +189,11 @@ final class BreakingVariableRenameGuard } return \false; } - private function isUsedInIfAndOtherBranches(\PhpParser\Node\Expr\Variable $variable, string $currentVariableName) : bool + private function isUsedInIfAndOtherBranches(Variable $variable, string $currentVariableName) : bool { // is in if branches? - $previousIf = $this->betterNodeFinder->findFirstPreviousOfTypes($variable, [\PhpParser\Node\Stmt\If_::class]); - if ($previousIf instanceof \PhpParser\Node\Stmt\If_) { + $previousIf = $this->betterNodeFinder->findFirstPreviousOfTypes($variable, [If_::class]); + if ($previousIf instanceof If_) { $variableUses = []; $variableUses[] = $this->betterNodeFinder->findVariableOfName($previousIf->stmts, $currentVariableName); $previousStmts = $previousIf->else !== null ? $previousIf->else->stmts : []; @@ -209,25 +209,25 @@ final class BreakingVariableRenameGuard /** * @TODO Remove once ParamRenamer created */ - private function isRamseyUuidInterface(\PhpParser\Node\Param $param) : bool + private function isRamseyUuidInterface(Param $param) : bool { - return $this->nodeTypeResolver->isObjectType($param, new \PHPStan\Type\ObjectType('Ramsey\\Uuid\\UuidInterface')); + return $this->nodeTypeResolver->isObjectType($param, new ObjectType('Ramsey\\Uuid\\UuidInterface')); } /** * @TODO Remove once ParamRenamer created */ - private function isDateTimeAtNamingConvention(\PhpParser\Node\Param $param) : bool + private function isDateTimeAtNamingConvention(Param $param) : bool { $type = $this->nodeTypeResolver->getType($param); $type = $this->typeUnwrapper->unwrapFirstObjectTypeFromUnionType($type); - if (!$type instanceof \PHPStan\Type\TypeWithClassName) { + if (!$type instanceof TypeWithClassName) { return \false; } - if (!\is_a($type->getClassName(), \DateTimeInterface::class, \true)) { + if (!\is_a($type->getClassName(), DateTimeInterface::class, \true)) { return \false; } /** @var string $currentName */ $currentName = $this->nodeNameResolver->getName($param); - return \Rector\Core\Util\StringUtils::isMatch($currentName, self::AT_NAMING_REGEX . ''); + return StringUtils::isMatch($currentName, self::AT_NAMING_REGEX . ''); } } diff --git a/rules/Naming/Guard/DateTimeAtNamingConventionGuard.php b/rules/Naming/Guard/DateTimeAtNamingConventionGuard.php index b8f6e1e7370..2cb54adb087 100644 --- a/rules/Naming/Guard/DateTimeAtNamingConventionGuard.php +++ b/rules/Naming/Guard/DateTimeAtNamingConventionGuard.php @@ -14,7 +14,7 @@ use Rector\PHPStanStaticTypeMapper\Utils\TypeUnwrapper; /** * @implements ConflictingNameGuardInterface */ -final class DateTimeAtNamingConventionGuard implements \Rector\Naming\Contract\Guard\ConflictingNameGuardInterface +final class DateTimeAtNamingConventionGuard implements ConflictingNameGuardInterface { /** * @var string @@ -31,7 +31,7 @@ final class DateTimeAtNamingConventionGuard implements \Rector\Naming\Contract\G * @var \Rector\PHPStanStaticTypeMapper\Utils\TypeUnwrapper */ private $typeUnwrapper; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\PHPStanStaticTypeMapper\Utils\TypeUnwrapper $typeUnwrapper) + public function __construct(NodeTypeResolver $nodeTypeResolver, TypeUnwrapper $typeUnwrapper) { $this->nodeTypeResolver = $nodeTypeResolver; $this->typeUnwrapper = $typeUnwrapper; @@ -39,20 +39,20 @@ final class DateTimeAtNamingConventionGuard implements \Rector\Naming\Contract\G /** * @param PropertyRename $renameValueObject */ - public function isConflicting(\Rector\Naming\Contract\RenameValueObjectInterface $renameValueObject) : bool + public function isConflicting(RenameValueObjectInterface $renameValueObject) : bool { return $this->isDateTimeAtNamingConvention($renameValueObject); } - private function isDateTimeAtNamingConvention(\Rector\Naming\ValueObject\PropertyRename $propertyRename) : bool + private function isDateTimeAtNamingConvention(PropertyRename $propertyRename) : bool { $type = $this->nodeTypeResolver->getType($propertyRename->getProperty()); $type = $this->typeUnwrapper->unwrapFirstObjectTypeFromUnionType($type); - if (!$type instanceof \PHPStan\Type\TypeWithClassName) { + if (!$type instanceof TypeWithClassName) { return \false; } - if (!\is_a($type->getClassName(), \DateTimeInterface::class, \true)) { + if (!\is_a($type->getClassName(), DateTimeInterface::class, \true)) { return \false; } - return \Rector\Core\Util\StringUtils::isMatch($propertyRename->getCurrentName(), self::AT_NAMING_REGEX . ''); + return StringUtils::isMatch($propertyRename->getCurrentName(), self::AT_NAMING_REGEX . ''); } } diff --git a/rules/Naming/Guard/HasMagicGetSetGuard.php b/rules/Naming/Guard/HasMagicGetSetGuard.php index 56043a53cdd..adbac0d4a1f 100644 --- a/rules/Naming/Guard/HasMagicGetSetGuard.php +++ b/rules/Naming/Guard/HasMagicGetSetGuard.php @@ -10,21 +10,21 @@ use Rector\Naming\ValueObject\PropertyRename; /** * @implements ConflictingNameGuardInterface */ -final class HasMagicGetSetGuard implements \Rector\Naming\Contract\Guard\ConflictingNameGuardInterface +final class HasMagicGetSetGuard implements ConflictingNameGuardInterface { /** * @readonly * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ReflectionProvider $reflectionProvider) { $this->reflectionProvider = $reflectionProvider; } /** * @param PropertyRename $renameValueObject */ - public function isConflicting(\Rector\Naming\Contract\RenameValueObjectInterface $renameValueObject) : bool + public function isConflicting(RenameValueObjectInterface $renameValueObject) : bool { if (!$this->reflectionProvider->hasClass($renameValueObject->getClassLikeName())) { return \false; diff --git a/rules/Naming/Guard/NotPrivatePropertyGuard.php b/rules/Naming/Guard/NotPrivatePropertyGuard.php index eb2267e94e7..e6322065029 100644 --- a/rules/Naming/Guard/NotPrivatePropertyGuard.php +++ b/rules/Naming/Guard/NotPrivatePropertyGuard.php @@ -9,12 +9,12 @@ use Rector\Naming\ValueObject\PropertyRename; /** * @implements ConflictingNameGuardInterface */ -final class NotPrivatePropertyGuard implements \Rector\Naming\Contract\Guard\ConflictingNameGuardInterface +final class NotPrivatePropertyGuard implements ConflictingNameGuardInterface { /** * @param PropertyRename $renameValueObject */ - public function isConflicting(\Rector\Naming\Contract\RenameValueObjectInterface $renameValueObject) : bool + public function isConflicting(RenameValueObjectInterface $renameValueObject) : bool { return !$renameValueObject->isPrivateProperty(); } diff --git a/rules/Naming/Guard/PropertyConflictingNameGuard/MatchPropertyTypeConflictingNameGuard.php b/rules/Naming/Guard/PropertyConflictingNameGuard/MatchPropertyTypeConflictingNameGuard.php index c09559d3bbc..1c505ee398c 100644 --- a/rules/Naming/Guard/PropertyConflictingNameGuard/MatchPropertyTypeConflictingNameGuard.php +++ b/rules/Naming/Guard/PropertyConflictingNameGuard/MatchPropertyTypeConflictingNameGuard.php @@ -26,7 +26,7 @@ final class MatchPropertyTypeConflictingNameGuard * @var \Rector\Naming\PhpArray\ArrayFilter */ private $arrayFilter; - public function __construct(\Rector\Naming\ExpectedNameResolver\MatchPropertyTypeExpectedNameResolver $matchPropertyTypeExpectedNameResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Naming\PhpArray\ArrayFilter $arrayFilter) + public function __construct(MatchPropertyTypeExpectedNameResolver $matchPropertyTypeExpectedNameResolver, NodeNameResolver $nodeNameResolver, ArrayFilter $arrayFilter) { $this->matchPropertyTypeExpectedNameResolver = $matchPropertyTypeExpectedNameResolver; $this->nodeNameResolver = $nodeNameResolver; @@ -35,7 +35,7 @@ final class MatchPropertyTypeConflictingNameGuard /** * @param PropertyRename $renameValueObject */ - public function isConflicting(\Rector\Naming\Contract\RenameValueObjectInterface $renameValueObject) : bool + public function isConflicting(RenameValueObjectInterface $renameValueObject) : bool { $conflictingPropertyNames = $this->resolve($renameValueObject->getClassLike()); return \in_array($renameValueObject->getExpectedName(), $conflictingPropertyNames, \true); @@ -43,7 +43,7 @@ final class MatchPropertyTypeConflictingNameGuard /** * @return string[] */ - public function resolve(\PhpParser\Node\Stmt\ClassLike $classLike) : array + public function resolve(ClassLike $classLike) : array { $expectedNames = []; foreach ($classLike->getProperties() as $property) { diff --git a/rules/Naming/Guard/RamseyUuidInterfaceGuard.php b/rules/Naming/Guard/RamseyUuidInterfaceGuard.php index 809701e4b31..a5656de3c91 100644 --- a/rules/Naming/Guard/RamseyUuidInterfaceGuard.php +++ b/rules/Naming/Guard/RamseyUuidInterfaceGuard.php @@ -11,22 +11,22 @@ use Rector\NodeTypeResolver\NodeTypeResolver; /** * @implements ConflictingNameGuardInterface */ -final class RamseyUuidInterfaceGuard implements \Rector\Naming\Contract\Guard\ConflictingNameGuardInterface +final class RamseyUuidInterfaceGuard implements ConflictingNameGuardInterface { /** * @readonly * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(NodeTypeResolver $nodeTypeResolver) { $this->nodeTypeResolver = $nodeTypeResolver; } /** * @param PropertyRename $renameValueObject */ - public function isConflicting(\Rector\Naming\Contract\RenameValueObjectInterface $renameValueObject) : bool + public function isConflicting(RenameValueObjectInterface $renameValueObject) : bool { - return $this->nodeTypeResolver->isObjectType($renameValueObject->getProperty(), new \PHPStan\Type\ObjectType('Ramsey\\Uuid\\UuidInterface')); + return $this->nodeTypeResolver->isObjectType($renameValueObject->getProperty(), new ObjectType('Ramsey\\Uuid\\UuidInterface')); } } diff --git a/rules/Naming/Matcher/CallMatcher.php b/rules/Naming/Matcher/CallMatcher.php index 24a875c420e..4e27b8ca61e 100644 --- a/rules/Naming/Matcher/CallMatcher.php +++ b/rules/Naming/Matcher/CallMatcher.php @@ -15,15 +15,15 @@ final class CallMatcher * @return FuncCall|StaticCall|MethodCall|null * @param \PhpParser\Node\Expr\Assign|\PhpParser\Node\Stmt\Foreach_ $node */ - public function matchCall($node) : ?\PhpParser\Node + public function matchCall($node) : ?Node { - if ($node->expr instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node->expr instanceof MethodCall) { return $node->expr; } - if ($node->expr instanceof \PhpParser\Node\Expr\StaticCall) { + if ($node->expr instanceof StaticCall) { return $node->expr; } - if ($node->expr instanceof \PhpParser\Node\Expr\FuncCall) { + if ($node->expr instanceof FuncCall) { return $node->expr; } return null; diff --git a/rules/Naming/Matcher/ForeachMatcher.php b/rules/Naming/Matcher/ForeachMatcher.php index afc673c5cd0..5ad7383ad1f 100644 --- a/rules/Naming/Matcher/ForeachMatcher.php +++ b/rules/Naming/Matcher/ForeachMatcher.php @@ -28,19 +28,19 @@ final class ForeachMatcher * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Naming\Matcher\CallMatcher $callMatcher, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeNameResolver $nodeNameResolver, \Rector\Naming\Matcher\CallMatcher $callMatcher, BetterNodeFinder $betterNodeFinder) { $this->nodeNameResolver = $nodeNameResolver; $this->callMatcher = $callMatcher; $this->betterNodeFinder = $betterNodeFinder; } - public function match(\PhpParser\Node\Stmt\Foreach_ $foreach) : ?\Rector\Naming\ValueObject\VariableAndCallForeach + public function match(Foreach_ $foreach) : ?VariableAndCallForeach { $call = $this->callMatcher->matchCall($foreach); if ($call === null) { return null; } - if (!$foreach->valueVar instanceof \PhpParser\Node\Expr\Variable) { + if (!$foreach->valueVar instanceof Variable) { return null; } $functionLike = $this->getFunctionLike($foreach); @@ -51,13 +51,13 @@ final class ForeachMatcher if ($variableName === null) { return null; } - return new \Rector\Naming\ValueObject\VariableAndCallForeach($foreach->valueVar, $call, $variableName, $functionLike); + return new VariableAndCallForeach($foreach->valueVar, $call, $variableName, $functionLike); } /** * @return \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure|null */ - private function getFunctionLike(\PhpParser\Node\Stmt\Foreach_ $foreach) + private function getFunctionLike(Foreach_ $foreach) { - return $this->betterNodeFinder->findParentByTypes($foreach, [\PhpParser\Node\Expr\Closure::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class]); + return $this->betterNodeFinder->findParentByTypes($foreach, [Closure::class, ClassMethod::class, Function_::class]); } } diff --git a/rules/Naming/Matcher/VariableAndCallAssignMatcher.php b/rules/Naming/Matcher/VariableAndCallAssignMatcher.php index a355bd37baf..f7a2d82e2bb 100644 --- a/rules/Naming/Matcher/VariableAndCallAssignMatcher.php +++ b/rules/Naming/Matcher/VariableAndCallAssignMatcher.php @@ -29,19 +29,19 @@ final class VariableAndCallAssignMatcher * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\Naming\Matcher\CallMatcher $callMatcher, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(\Rector\Naming\Matcher\CallMatcher $callMatcher, NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder) { $this->callMatcher = $callMatcher; $this->nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; } - public function match(\PhpParser\Node\Expr\Assign $assign) : ?\Rector\Naming\ValueObject\VariableAndCallAssign + public function match(Assign $assign) : ?VariableAndCallAssign { $call = $this->callMatcher->matchCall($assign); if ($call === null) { return null; } - if (!$assign->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$assign->var instanceof Variable) { return null; } $variableName = $this->nodeNameResolver->getName($assign->var); @@ -49,16 +49,16 @@ final class VariableAndCallAssignMatcher return null; } $functionLike = $this->getFunctionLike($assign); - if (!$functionLike instanceof \PhpParser\Node\FunctionLike) { + if (!$functionLike instanceof FunctionLike) { return null; } - return new \Rector\Naming\ValueObject\VariableAndCallAssign($assign->var, $call, $assign, $variableName, $functionLike); + return new VariableAndCallAssign($assign->var, $call, $assign, $variableName, $functionLike); } /** * @return \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure|null */ - private function getFunctionLike(\PhpParser\Node\Expr\Assign $assign) + private function getFunctionLike(Assign $assign) { - return $this->betterNodeFinder->findParentByTypes($assign, [\PhpParser\Node\Expr\Closure::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class]); + return $this->betterNodeFinder->findParentByTypes($assign, [Closure::class, ClassMethod::class, Function_::class]); } } diff --git a/rules/Naming/NamespaceMatcher.php b/rules/Naming/NamespaceMatcher.php index c1fd2b8fb35..700a0f274d4 100644 --- a/rules/Naming/NamespaceMatcher.php +++ b/rules/Naming/NamespaceMatcher.php @@ -9,13 +9,13 @@ final class NamespaceMatcher /** * @param string[] $oldToNewNamespace */ - public function matchRenamedNamespace(string $name, array $oldToNewNamespace) : ?\Rector\Renaming\ValueObject\RenamedNamespace + public function matchRenamedNamespace(string $name, array $oldToNewNamespace) : ?RenamedNamespace { \krsort($oldToNewNamespace); /** @var string $oldNamespace */ foreach ($oldToNewNamespace as $oldNamespace => $newNamespace) { if (\strncmp($name, $oldNamespace, \strlen($oldNamespace)) === 0) { - return new \Rector\Renaming\ValueObject\RenamedNamespace($name, $oldNamespace, $newNamespace); + return new RenamedNamespace($name, $oldNamespace, $newNamespace); } } return null; diff --git a/rules/Naming/Naming/AliasNameResolver.php b/rules/Naming/Naming/AliasNameResolver.php index 5a283b042d6..6779540f027 100644 --- a/rules/Naming/Naming/AliasNameResolver.php +++ b/rules/Naming/Naming/AliasNameResolver.php @@ -17,14 +17,14 @@ final class AliasNameResolver { $this->useImportsResolver = $useImportsResolver; } - public function resolveByName(\PhpParser\Node\Name $name) : ?string + public function resolveByName(Name $name) : ?string { $uses = $this->useImportsResolver->resolveForNode($name); $nameString = $name->toString(); foreach ($uses as $use) { - $prefix = $use instanceof \PhpParser\Node\Stmt\GroupUse ? $use->prefix . '\\' : ''; + $prefix = $use instanceof GroupUse ? $use->prefix . '\\' : ''; foreach ($use->uses as $useUse) { - if (!$useUse->alias instanceof \PhpParser\Node\Identifier) { + if (!$useUse->alias instanceof Identifier) { continue; } $name = $prefix . $useUse->name->toString(); diff --git a/rules/Naming/Naming/ConflictingNameResolver.php b/rules/Naming/Naming/ConflictingNameResolver.php index de78172c193..dd938018071 100644 --- a/rules/Naming/Naming/ConflictingNameResolver.php +++ b/rules/Naming/Naming/ConflictingNameResolver.php @@ -42,7 +42,7 @@ final class ConflictingNameResolver * @var \Rector\Core\NodeManipulator\FunctionLikeManipulator */ private $functionLikeManipulator; - public function __construct(\Rector\Naming\PhpArray\ArrayFilter $arrayFilter, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Naming\Naming\ExpectedNameResolver $expectedNameResolver, \Rector\Naming\ExpectedNameResolver\MatchParamTypeExpectedNameResolver $matchParamTypeExpectedNameResolver, \Rector\Core\NodeManipulator\FunctionLikeManipulator $functionLikeManipulator) + public function __construct(ArrayFilter $arrayFilter, BetterNodeFinder $betterNodeFinder, \Rector\Naming\Naming\ExpectedNameResolver $expectedNameResolver, MatchParamTypeExpectedNameResolver $matchParamTypeExpectedNameResolver, FunctionLikeManipulator $functionLikeManipulator) { $this->arrayFilter = $arrayFilter; $this->betterNodeFinder = $betterNodeFinder; @@ -101,7 +101,7 @@ final class ConflictingNameResolver { $names = []; /** @var Assign[] $assigns */ - $assigns = $this->betterNodeFinder->findInstanceOf((array) $functionLike->stmts, \PhpParser\Node\Expr\Assign::class); + $assigns = $this->betterNodeFinder->findInstanceOf((array) $functionLike->stmts, Assign::class); foreach ($assigns as $assign) { $name = $this->expectedNameResolver->resolveForAssignNew($assign); if ($name === null) { @@ -119,7 +119,7 @@ final class ConflictingNameResolver { $names = []; /** @var Assign[] $assigns */ - $assigns = $this->betterNodeFinder->findInstanceOf((array) $functionLike->stmts, \PhpParser\Node\Expr\Assign::class); + $assigns = $this->betterNodeFinder->findInstanceOf((array) $functionLike->stmts, Assign::class); foreach ($assigns as $assign) { $name = $this->expectedNameResolver->resolveForAssignNonNew($assign); if ($name === null) { diff --git a/rules/Naming/Naming/ExpectedNameResolver.php b/rules/Naming/Naming/ExpectedNameResolver.php index 1da4d90c22f..584789207a0 100644 --- a/rules/Naming/Naming/ExpectedNameResolver.php +++ b/rules/Naming/Naming/ExpectedNameResolver.php @@ -45,16 +45,16 @@ final class ExpectedNameResolver * @var \Rector\Naming\ExpectedNameResolver\MatchParamTypeExpectedNameResolver */ private $matchParamTypeExpectedNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\Naming\Naming\PropertyNaming $propertyNaming, \Rector\Naming\ExpectedNameResolver\MatchParamTypeExpectedNameResolver $matchParamTypeExpectedNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver, \Rector\Naming\Naming\PropertyNaming $propertyNaming, MatchParamTypeExpectedNameResolver $matchParamTypeExpectedNameResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->nodeTypeResolver = $nodeTypeResolver; $this->propertyNaming = $propertyNaming; $this->matchParamTypeExpectedNameResolver = $matchParamTypeExpectedNameResolver; } - public function resolveForParamIfNotYet(\PhpParser\Node\Param $param) : ?string + public function resolveForParamIfNotYet(Param $param) : ?string { - if ($param->type instanceof \PhpParser\Node\UnionType) { + if ($param->type instanceof UnionType) { return null; } $expectedName = $this->matchParamTypeExpectedNameResolver->resolve($param); @@ -71,35 +71,35 @@ final class ExpectedNameResolver } return $expectedName; } - public function resolveForAssignNonNew(\PhpParser\Node\Expr\Assign $assign) : ?string + public function resolveForAssignNonNew(Assign $assign) : ?string { - if ($assign->expr instanceof \PhpParser\Node\Expr\New_) { + if ($assign->expr instanceof New_) { return null; } - if (!$assign->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$assign->var instanceof Variable) { return null; } /** @var Variable $variable */ $variable = $assign->var; return $this->nodeNameResolver->getName($variable); } - public function resolveForAssignNew(\PhpParser\Node\Expr\Assign $assign) : ?string + public function resolveForAssignNew(Assign $assign) : ?string { - if (!$assign->expr instanceof \PhpParser\Node\Expr\New_) { + if (!$assign->expr instanceof New_) { return null; } - if (!$assign->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$assign->var instanceof Variable) { return null; } /** @var New_ $new */ $new = $assign->expr; - if (!$new->class instanceof \PhpParser\Node\Name) { + if (!$new->class instanceof Name) { return null; } $className = $this->nodeNameResolver->getName($new->class); - $fullyQualifiedObjectType = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($className); + $fullyQualifiedObjectType = new FullyQualifiedObjectType($className); $expectedName = $this->propertyNaming->getExpectedNameFromType($fullyQualifiedObjectType); - if (!$expectedName instanceof \Rector\Naming\ValueObject\ExpectedName) { + if (!$expectedName instanceof ExpectedName) { return null; } return $expectedName->getName(); @@ -117,10 +117,10 @@ final class ExpectedNameResolver return null; } $returnedType = $this->nodeTypeResolver->getType($expr); - if ($returnedType instanceof \PHPStan\Type\ArrayType) { + if ($returnedType instanceof ArrayType) { return null; } - if ($returnedType instanceof \PHPStan\Type\MixedType) { + if ($returnedType instanceof MixedType) { return null; } $expectedName = $this->propertyNaming->getExpectedNameFromType($returnedType); @@ -154,9 +154,9 @@ final class ExpectedNameResolver return null; } $innerReturnedType = null; - if ($returnedType instanceof \PHPStan\Type\ArrayType) { + if ($returnedType instanceof ArrayType) { $innerReturnedType = $this->resolveReturnTypeFromArrayType($expr, $returnedType); - if (!$innerReturnedType instanceof \PHPStan\Type\Type) { + if (!$innerReturnedType instanceof Type) { return null; } } @@ -165,7 +165,7 @@ final class ExpectedNameResolver return ($expectedNameFromType2 = $expectedNameFromType) ? $expectedNameFromType2->getSingularized() : null; } $expectedNameFromMethodName = $this->propertyNaming->getExpectedNameFromMethodName($name); - if (!$expectedNameFromMethodName instanceof \Rector\Naming\ValueObject\ExpectedName) { + if (!$expectedNameFromMethodName instanceof ExpectedName) { return ($expectedNameFromType2 = $expectedNameFromType) ? $expectedNameFromType2->getSingularized() : null; } if ($expectedNameFromMethodName->isSingular()) { @@ -173,33 +173,33 @@ final class ExpectedNameResolver } return $expectedNameFromMethodName->getSingularized(); } - private function isReturnedTypeAnArrayAndExpectedNameFromTypeNotNull(\PHPStan\Type\Type $returnedType, ?\Rector\Naming\ValueObject\ExpectedName $expectedName) : bool + private function isReturnedTypeAnArrayAndExpectedNameFromTypeNotNull(Type $returnedType, ?ExpectedName $expectedName) : bool { - return $returnedType instanceof \PHPStan\Type\ArrayType && $expectedName !== null; + return $returnedType instanceof ArrayType && $expectedName !== null; } /** * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\FuncCall $expr */ private function isDynamicNameCall($expr) : bool { - if ($expr->name instanceof \PhpParser\Node\Expr\StaticCall) { + if ($expr->name instanceof StaticCall) { return \true; } - if ($expr->name instanceof \PhpParser\Node\Expr\MethodCall) { + if ($expr->name instanceof MethodCall) { return \true; } - return $expr->name instanceof \PhpParser\Node\Expr\FuncCall; + return $expr->name instanceof FuncCall; } /** * @param \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $expr */ - private function resolveReturnTypeFromArrayType($expr, \PHPStan\Type\ArrayType $arrayType) : ?\PHPStan\Type\Type + private function resolveReturnTypeFromArrayType($expr, ArrayType $arrayType) : ?Type { - $parentNode = $expr->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node\Stmt\Foreach_) { + $parentNode = $expr->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof Foreach_) { return null; } - if (!$arrayType->getItemType() instanceof \PHPStan\Type\ObjectType) { + if (!$arrayType->getItemType() instanceof ObjectType) { return null; } return $arrayType->getItemType(); diff --git a/rules/Naming/Naming/OverridenExistingNamesResolver.php b/rules/Naming/Naming/OverridenExistingNamesResolver.php index 33b9bbfe1b7..b03f8358adb 100644 --- a/rules/Naming/Naming/OverridenExistingNamesResolver.php +++ b/rules/Naming/Naming/OverridenExistingNamesResolver.php @@ -32,7 +32,7 @@ final class OverridenExistingNamesResolver * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\Naming\PhpArray\ArrayFilter $arrayFilter, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(ArrayFilter $arrayFilter, BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver) { $this->arrayFilter = $arrayFilter; $this->betterNodeFinder = $betterNodeFinder; @@ -52,10 +52,10 @@ final class OverridenExistingNamesResolver public function hasNameInFunctionLikeForParam(string $expectedName, $classMethod) : bool { /** @var Assign[] $assigns */ - $assigns = $this->betterNodeFinder->findInstanceOf((array) $classMethod->stmts, \PhpParser\Node\Expr\Assign::class); + $assigns = $this->betterNodeFinder->findInstanceOf((array) $classMethod->stmts, Assign::class); $usedVariableNames = []; foreach ($assigns as $assign) { - if (!$assign->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$assign->var instanceof Variable) { continue; } $variableName = $this->nodeNameResolver->getName($assign->var); @@ -78,7 +78,7 @@ final class OverridenExistingNamesResolver } $currentlyUsedNames = []; /** @var Assign[] $assigns */ - $assigns = $this->betterNodeFinder->findInstanceOf((array) $functionLike->stmts, \PhpParser\Node\Expr\Assign::class); + $assigns = $this->betterNodeFinder->findInstanceOf((array) $functionLike->stmts, Assign::class); foreach ($assigns as $assign) { /** @var Variable $assignVariable */ $assignVariable = $assign->var; diff --git a/rules/Naming/Naming/PropertyNaming.php b/rules/Naming/Naming/PropertyNaming.php index 70e6c7976d5..dbe148951d0 100644 --- a/rules/Naming/Naming/PropertyNaming.php +++ b/rules/Naming/Naming/PropertyNaming.php @@ -59,40 +59,40 @@ final class PropertyNaming * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\PHPStanStaticTypeMapper\Utils\TypeUnwrapper $typeUnwrapper, \Rector\Naming\RectorNamingInflector $rectorNamingInflector, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(TypeUnwrapper $typeUnwrapper, RectorNamingInflector $rectorNamingInflector, NodeTypeResolver $nodeTypeResolver) { $this->typeUnwrapper = $typeUnwrapper; $this->rectorNamingInflector = $rectorNamingInflector; $this->nodeTypeResolver = $nodeTypeResolver; } - public function getExpectedNameFromMethodName(string $methodName) : ?\Rector\Naming\ValueObject\ExpectedName + public function getExpectedNameFromMethodName(string $methodName) : ?ExpectedName { - $matches = \RectorPrefix20220607\Nette\Utils\Strings::match($methodName, self::GET_PREFIX_REGEX); + $matches = Strings::match($methodName, self::GET_PREFIX_REGEX); if ($matches === null) { return null; } $originalName = \lcfirst($matches['root_name']); - return new \Rector\Naming\ValueObject\ExpectedName($originalName, $this->rectorNamingInflector->singularize($originalName)); + return new ExpectedName($originalName, $this->rectorNamingInflector->singularize($originalName)); } - public function getExpectedNameFromType(\PHPStan\Type\Type $type) : ?\Rector\Naming\ValueObject\ExpectedName + public function getExpectedNameFromType(Type $type) : ?ExpectedName { $type = $this->typeUnwrapper->unwrapNullableType($type); - if (!$type instanceof \PHPStan\Type\TypeWithClassName) { + if (!$type instanceof TypeWithClassName) { return null; } - if ($type instanceof \Rector\StaticTypeMapper\ValueObject\Type\SelfObjectType) { + if ($type instanceof SelfObjectType) { return null; } - if ($type instanceof \PHPStan\Type\StaticType) { + if ($type instanceof StaticType) { return null; } - $className = $type instanceof \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType ? $type->getClassName() : $this->nodeTypeResolver->getFullyQualifiedClassName($type); + $className = $type instanceof AliasedObjectType ? $type->getClassName() : $this->nodeTypeResolver->getFullyQualifiedClassName($type); // generic types are usually mix of parent type and specific type - various way to handle it - if ($type instanceof \PHPStan\Type\Generic\GenericObjectType) { + if ($type instanceof GenericObjectType) { return null; } foreach (self::EXCLUDED_CLASSES as $excludedClass) { - if (\Rector\Core\Util\StringUtils::isMatch($className, $excludedClass)) { + if (StringUtils::isMatch($className, $excludedClass)) { return null; } } @@ -103,23 +103,23 @@ final class PropertyNaming $shortClassName = \strtolower($shortClassName); } // remove "_" - $shortClassName = \RectorPrefix20220607\Nette\Utils\Strings::replace($shortClassName, '#_#', ''); + $shortClassName = Strings::replace($shortClassName, '#_#', ''); $shortClassName = $this->normalizeUpperCase($shortClassName); // prolong too short generic names with one namespace up $originalName = $this->prolongIfTooShort($shortClassName, $className); - return new \Rector\Naming\ValueObject\ExpectedName($originalName, $this->rectorNamingInflector->singularize($originalName)); + return new ExpectedName($originalName, $this->rectorNamingInflector->singularize($originalName)); } /** * @param \PHPStan\Type\ThisType|\PHPStan\Type\ObjectType|string $objectType */ public function fqnToVariableName($objectType) : string { - if ($objectType instanceof \PHPStan\Type\ThisType) { + if ($objectType instanceof ThisType) { $objectType = $objectType->getStaticObjectType(); } $className = $this->resolveClassName($objectType); if (\strpos($className, '\\') !== \false) { - $shortClassName = (string) \RectorPrefix20220607\Nette\Utils\Strings::after($className, '\\', -1); + $shortClassName = (string) Strings::after($className, '\\', -1); } else { $shortClassName = $className; } @@ -142,7 +142,7 @@ final class PropertyNaming private function resolveShortClassName(string $className) : string { if (\strpos($className, '\\') !== \false) { - return (string) \RectorPrefix20220607\Nette\Utils\Strings::after($className, '\\', -1); + return (string) Strings::after($className, '\\', -1); } return $className; } @@ -150,15 +150,15 @@ final class PropertyNaming { // is SomeInterface if (\substr_compare($shortClassName, self::INTERFACE, -\strlen(self::INTERFACE)) === 0) { - $shortClassName = \RectorPrefix20220607\Nette\Utils\Strings::substring($shortClassName, 0, -\strlen(self::INTERFACE)); + $shortClassName = Strings::substring($shortClassName, 0, -\strlen(self::INTERFACE)); } // is ISomeClass if ($this->isPrefixedInterface($shortClassName)) { - $shortClassName = \RectorPrefix20220607\Nette\Utils\Strings::substring($shortClassName, 1); + $shortClassName = Strings::substring($shortClassName, 1); } // is AbstractClass if (\strncmp($shortClassName, 'Abstract', \strlen('Abstract')) === 0) { - $shortClassName = \RectorPrefix20220607\Nette\Utils\Strings::substring($shortClassName, \strlen('Abstract')); + $shortClassName = Strings::substring($shortClassName, \strlen('Abstract')); } return $shortClassName; } @@ -177,8 +177,8 @@ final class PropertyNaming private function prolongIfTooShort(string $shortClassName, string $className) : string { if (\in_array($shortClassName, ['Factory', 'Repository'], \true)) { - $namespaceAbove = (string) \RectorPrefix20220607\Nette\Utils\Strings::after($className, '\\', -2); - $namespaceAbove = (string) \RectorPrefix20220607\Nette\Utils\Strings::before($namespaceAbove, '\\'); + $namespaceAbove = (string) Strings::after($className, '\\', -2); + $namespaceAbove = (string) Strings::before($namespaceAbove, '\\'); return \lcfirst($namespaceAbove) . $shortClassName; } return \lcfirst($shortClassName); @@ -188,7 +188,7 @@ final class PropertyNaming */ private function resolveClassName($objectType) : string { - if ($objectType instanceof \PHPStan\Type\ObjectType) { + if ($objectType instanceof ObjectType) { return $objectType->getClassName(); } return $objectType; @@ -198,28 +198,28 @@ final class PropertyNaming if (\strpos($fqn, '\\') === \false) { return $fqn; } - $lastNamePart = \RectorPrefix20220607\Nette\Utils\Strings::after($fqn, '\\', -1); + $lastNamePart = Strings::after($fqn, '\\', -1); if (!\is_string($lastNamePart)) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } if (\substr_compare($lastNamePart, self::INTERFACE, -\strlen(self::INTERFACE)) === 0) { - return \RectorPrefix20220607\Nette\Utils\Strings::substring($lastNamePart, 0, -\strlen(self::INTERFACE)); + return Strings::substring($lastNamePart, 0, -\strlen(self::INTERFACE)); } return $lastNamePart; } private function removeInterfaceSuffixPrefix(string $className, string $category) : string { // suffix - if (\RectorPrefix20220607\Nette\Utils\Strings::match($className, '#' . $category . '$#i')) { - return \RectorPrefix20220607\Nette\Utils\Strings::substring($className, 0, -\strlen($category)); + if (Strings::match($className, '#' . $category . '$#i')) { + return Strings::substring($className, 0, -\strlen($category)); } // prefix - if (\RectorPrefix20220607\Nette\Utils\Strings::match($className, '#^' . $category . '#i')) { - return \RectorPrefix20220607\Nette\Utils\Strings::substring($className, \strlen($category)); + if (Strings::match($className, '#^' . $category . '#i')) { + return Strings::substring($className, \strlen($category)); } // starts with "I\W+"? - if (\Rector\Core\Util\StringUtils::isMatch($className, self::I_PREFIX_REGEX)) { - return \RectorPrefix20220607\Nette\Utils\Strings::substring($className, 1); + if (StringUtils::isMatch($className, self::I_PREFIX_REGEX)) { + return Strings::substring($className, 1); } return $className; } diff --git a/rules/Naming/Naming/UseImportsResolver.php b/rules/Naming/Naming/UseImportsResolver.php index 8916e2822a6..d407394577a 100644 --- a/rules/Naming/Naming/UseImportsResolver.php +++ b/rules/Naming/Naming/UseImportsResolver.php @@ -17,34 +17,34 @@ final class UseImportsResolver * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(BetterNodeFinder $betterNodeFinder) { $this->betterNodeFinder = $betterNodeFinder; } /** * @return Use_[]|GroupUse[] */ - public function resolveForNode(\PhpParser\Node $node) : array + public function resolveForNode(Node $node) : array { - $namespace = $this->betterNodeFinder->findParentByTypes($node, [\PhpParser\Node\Stmt\Namespace_::class, \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace::class]); - if (!$namespace instanceof \PhpParser\Node) { + $namespace = $this->betterNodeFinder->findParentByTypes($node, [Namespace_::class, FileWithoutNamespace::class]); + if (!$namespace instanceof Node) { return []; } - return \array_filter($namespace->stmts, function (\PhpParser\Node\Stmt $stmt) : bool { - return $stmt instanceof \PhpParser\Node\Stmt\Use_ || $stmt instanceof \PhpParser\Node\Stmt\GroupUse; + return \array_filter($namespace->stmts, function (Stmt $stmt) : bool { + return $stmt instanceof Use_ || $stmt instanceof GroupUse; }); } /** * @return Use_[] */ - public function resolveBareUsesForNode(\PhpParser\Node $node) : array + public function resolveBareUsesForNode(Node $node) : array { - $namespace = $this->betterNodeFinder->findParentByTypes($node, [\PhpParser\Node\Stmt\Namespace_::class, \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace::class]); - if (!$namespace instanceof \PhpParser\Node) { + $namespace = $this->betterNodeFinder->findParentByTypes($node, [Namespace_::class, FileWithoutNamespace::class]); + if (!$namespace instanceof Node) { return []; } - return \array_filter($namespace->stmts, function (\PhpParser\Node\Stmt $stmt) : bool { - return $stmt instanceof \PhpParser\Node\Stmt\Use_; + return \array_filter($namespace->stmts, function (Stmt $stmt) : bool { + return $stmt instanceof Use_; }); } } diff --git a/rules/Naming/Naming/VariableNaming.php b/rules/Naming/Naming/VariableNaming.php index 81e6e53055a..84fceaa0bbf 100644 --- a/rules/Naming/Naming/VariableNaming.php +++ b/rules/Naming/Naming/VariableNaming.php @@ -43,25 +43,25 @@ final class VariableNaming /** * @param AssignVariableNameResolverInterface[] $assignVariableNameResolvers */ - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, array $assignVariableNameResolvers) + public function __construct(NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver, array $assignVariableNameResolvers) { $this->nodeNameResolver = $nodeNameResolver; $this->nodeTypeResolver = $nodeTypeResolver; $this->assignVariableNameResolvers = $assignVariableNameResolvers; } - public function resolveFromNodeWithScopeCountAndFallbackName(\PhpParser\Node\Expr $expr, ?\PHPStan\Analyser\Scope $scope, string $fallbackName) : string + public function resolveFromNodeWithScopeCountAndFallbackName(Expr $expr, ?Scope $scope, string $fallbackName) : string { $name = $this->resolveFromNode($expr); if ($name === null) { $name = $fallbackName; } if (\strpos($name, '\\') !== \false) { - $name = (string) \RectorPrefix20220607\Nette\Utils\Strings::after($name, '\\', -1); + $name = (string) Strings::after($name, '\\', -1); } $countedValueName = $this->createCountedValueName($name, $scope); return \lcfirst($countedValueName); } - public function createCountedValueName(string $valueName, ?\PHPStan\Analyser\Scope $scope) : string + public function createCountedValueName(string $valueName, ?Scope $scope) : string { if ($scope === null) { return $valueName; @@ -79,33 +79,33 @@ final class VariableNaming } return $valueName; } - public function resolveFromFuncCallFirstArgumentWithSuffix(\PhpParser\Node\Expr\FuncCall $funcCall, string $suffix, string $fallbackName, ?\PHPStan\Analyser\Scope $scope) : string + public function resolveFromFuncCallFirstArgumentWithSuffix(FuncCall $funcCall, string $suffix, string $fallbackName, ?Scope $scope) : string { $bareName = $this->resolveBareFuncCallArgumentName($funcCall, $fallbackName, $suffix); return $this->createCountedValueName($bareName, $scope); } - public function resolveFromNodeAndType(\PhpParser\Node $node, \PHPStan\Type\Type $type) : ?string + public function resolveFromNodeAndType(Node $node, Type $type) : ?string { $variableName = $this->resolveBareFromNode($node); if ($variableName === null) { return null; } // adjust static to specific class - if ($variableName === 'this' && $type instanceof \PHPStan\Type\ThisType) { + if ($variableName === 'this' && $type instanceof ThisType) { $shortClassName = $this->nodeNameResolver->getShortName($type->getClassName()); $variableName = \lcfirst($shortClassName); } else { $variableName = $this->nodeNameResolver->getShortName($variableName); } - $variableNameUnicodeString = new \RectorPrefix20220607\Symfony\Component\String\UnicodeString($variableName); + $variableNameUnicodeString = new UnicodeString($variableName); return $variableNameUnicodeString->camel()->toString(); } - private function resolveFromNode(\PhpParser\Node $node) : ?string + private function resolveFromNode(Node $node) : ?string { $nodeType = $this->nodeTypeResolver->getType($node); return $this->resolveFromNodeAndType($node, $nodeType); } - private function resolveBareFromNode(\PhpParser\Node $node) : ?string + private function resolveBareFromNode(Node $node) : ?string { $node = $this->unwrapNode($node); foreach ($this->assignVariableNameResolvers as $assignVariableNameResolver) { @@ -113,20 +113,20 @@ final class VariableNaming return $assignVariableNameResolver->resolve($node); } } - if ($node !== null && ($node instanceof \PhpParser\Node\Expr\MethodCall || $node instanceof \PhpParser\Node\Expr\NullsafeMethodCall || $node instanceof \PhpParser\Node\Expr\StaticCall)) { + if ($node !== null && ($node instanceof MethodCall || $node instanceof NullsafeMethodCall || $node instanceof StaticCall)) { return $this->resolveFromMethodCall($node); } - if ($node instanceof \PhpParser\Node\Expr\FuncCall) { + if ($node instanceof FuncCall) { return $this->resolveFromNode($node->name); } - if (!$node instanceof \PhpParser\Node) { - throw new \Rector\Core\Exception\NotImplementedYetException(); + if (!$node instanceof Node) { + throw new NotImplementedYetException(); } $paramName = $this->nodeNameResolver->getName($node); if ($paramName !== null) { return $paramName; } - if ($node instanceof \PhpParser\Node\Scalar\String_) { + if ($node instanceof String_) { return $node->value; } return null; @@ -136,7 +136,7 @@ final class VariableNaming */ private function resolveFromMethodCall($node) : ?string { - if ($node->name instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node->name instanceof MethodCall) { return $this->resolveFromMethodCall($node->name); } $methodName = $this->nodeNameResolver->getName($node->name); @@ -145,29 +145,29 @@ final class VariableNaming } return $methodName; } - private function unwrapNode(\PhpParser\Node $node) : ?\PhpParser\Node + private function unwrapNode(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Arg) { + if ($node instanceof Arg) { return $node->value; } - if ($node instanceof \PhpParser\Node\Expr\Cast) { + if ($node instanceof Cast) { return $node->expr; } - if ($node instanceof \PhpParser\Node\Expr\Ternary) { + if ($node instanceof Ternary) { return $node->if; } return $node; } - private function resolveBareFuncCallArgumentName(\PhpParser\Node\Expr\FuncCall $funcCall, string $fallbackName, string $suffix) : string + private function resolveBareFuncCallArgumentName(FuncCall $funcCall, string $fallbackName, string $suffix) : string { if (!isset($funcCall->args[0])) { return ''; } - if (!$funcCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[0] instanceof Arg) { return ''; } $argumentValue = $funcCall->args[0]->value; - if ($argumentValue instanceof \PhpParser\Node\Expr\MethodCall || $argumentValue instanceof \PhpParser\Node\Expr\StaticCall) { + if ($argumentValue instanceof MethodCall || $argumentValue instanceof StaticCall) { $name = $this->nodeNameResolver->getName($argumentValue->name); } else { $name = $this->nodeNameResolver->getName($argumentValue); diff --git a/rules/Naming/NamingConvention/NamingConventionAnalyzer.php b/rules/Naming/NamingConvention/NamingConventionAnalyzer.php index c6720158408..c7eacef984c 100644 --- a/rules/Naming/NamingConvention/NamingConventionAnalyzer.php +++ b/rules/Naming/NamingConvention/NamingConventionAnalyzer.php @@ -15,7 +15,7 @@ final class NamingConventionAnalyzer * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } @@ -35,6 +35,6 @@ final class NamingConventionAnalyzer return \true; } // starts with or ends with - return \Rector\Core\Util\StringUtils::isMatch($currentName, '#^(' . $expectedName . '|' . $expectedName . '$)#i'); + return StringUtils::isMatch($currentName, '#^(' . $expectedName . '|' . $expectedName . '$)#i'); } } diff --git a/rules/Naming/ParamRenamer/ParamRenamer.php b/rules/Naming/ParamRenamer/ParamRenamer.php index 3dac3abf6fd..ff583c623d3 100644 --- a/rules/Naming/ParamRenamer/ParamRenamer.php +++ b/rules/Naming/ParamRenamer/ParamRenamer.php @@ -19,12 +19,12 @@ final class ParamRenamer * @var \Rector\BetterPhpDocParser\PhpDocManipulator\PropertyDocBlockManipulator */ private $propertyDocBlockManipulator; - public function __construct(\Rector\Naming\VariableRenamer $variableRenamer, \Rector\BetterPhpDocParser\PhpDocManipulator\PropertyDocBlockManipulator $propertyDocBlockManipulator) + public function __construct(VariableRenamer $variableRenamer, PropertyDocBlockManipulator $propertyDocBlockManipulator) { $this->variableRenamer = $variableRenamer; $this->propertyDocBlockManipulator = $propertyDocBlockManipulator; } - public function rename(\Rector\Naming\ValueObject\ParamRename $paramRename) : void + public function rename(ParamRename $paramRename) : void { // 1. rename param $paramRename->getVariable()->name = $paramRename->getExpectedName(); diff --git a/rules/Naming/PhpDoc/VarTagValueNodeRenamer.php b/rules/Naming/PhpDoc/VarTagValueNodeRenamer.php index 804c5590608..f36457131b9 100644 --- a/rules/Naming/PhpDoc/VarTagValueNodeRenamer.php +++ b/rules/Naming/PhpDoc/VarTagValueNodeRenamer.php @@ -8,10 +8,10 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey; final class VarTagValueNodeRenamer { - public function renameAssignVarTagVariableName(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, string $originalName, string $expectedName) : void + public function renameAssignVarTagVariableName(PhpDocInfo $phpDocInfo, string $originalName, string $expectedName) : void { $varTagValueNode = $phpDocInfo->getVarTagValueNode(); - if (!$varTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) { + if (!$varTagValueNode instanceof VarTagValueNode) { return; } if ($varTagValueNode->variableName !== '$' . $originalName) { @@ -19,6 +19,6 @@ final class VarTagValueNodeRenamer } $varTagValueNode->variableName = '$' . $expectedName; // invoke node reprint - same as in php-parser - $varTagValueNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE, null); + $varTagValueNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null); } } diff --git a/rules/Naming/PropertyRenamer/MatchTypePropertyRenamer.php b/rules/Naming/PropertyRenamer/MatchTypePropertyRenamer.php index 428b8716f2d..c41004585fb 100644 --- a/rules/Naming/PropertyRenamer/MatchTypePropertyRenamer.php +++ b/rules/Naming/PropertyRenamer/MatchTypePropertyRenamer.php @@ -18,12 +18,12 @@ final class MatchTypePropertyRenamer * @var \Rector\Naming\Guard\PropertyConflictingNameGuard\MatchPropertyTypeConflictingNameGuard */ private $matchPropertyTypeConflictingNameGuard; - public function __construct(\Rector\Naming\PropertyRenamer\PropertyRenamer $propertyRenamer, \Rector\Naming\Guard\PropertyConflictingNameGuard\MatchPropertyTypeConflictingNameGuard $matchPropertyTypeConflictingNameGuard) + public function __construct(\Rector\Naming\PropertyRenamer\PropertyRenamer $propertyRenamer, MatchPropertyTypeConflictingNameGuard $matchPropertyTypeConflictingNameGuard) { $this->propertyRenamer = $propertyRenamer; $this->matchPropertyTypeConflictingNameGuard = $matchPropertyTypeConflictingNameGuard; } - public function rename(\Rector\Naming\ValueObject\PropertyRename $propertyRename) : ?\PhpParser\Node\Stmt\Property + public function rename(PropertyRename $propertyRename) : ?Property { if ($this->matchPropertyTypeConflictingNameGuard->isConflicting($propertyRename)) { return null; diff --git a/rules/Naming/PropertyRenamer/PropertyFetchRenamer.php b/rules/Naming/PropertyRenamer/PropertyFetchRenamer.php index f4ef2ca1c8b..4db3a4515a4 100644 --- a/rules/Naming/PropertyRenamer/PropertyFetchRenamer.php +++ b/rules/Naming/PropertyRenamer/PropertyFetchRenamer.php @@ -23,20 +23,20 @@ final class PropertyFetchRenamer * @var \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer */ private $propertyFetchAnalyzer; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, PropertyFetchAnalyzer $propertyFetchAnalyzer) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; } - public function renamePropertyFetchesInClass(\PhpParser\Node\Stmt\ClassLike $classLike, string $currentName, string $expectedName) : void + public function renamePropertyFetchesInClass(ClassLike $classLike, string $currentName, string $expectedName) : void { // 1. replace property fetch rename in whole class - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classLike, function (\PhpParser\Node $node) use($currentName, $expectedName) : ?Node { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classLike, function (Node $node) use($currentName, $expectedName) : ?Node { if (!$this->propertyFetchAnalyzer->isLocalPropertyFetchName($node, $currentName)) { return null; } /** @var StaticPropertyFetch|PropertyFetch $node */ - $node->name = $node instanceof \PhpParser\Node\Expr\PropertyFetch ? new \PhpParser\Node\Identifier($expectedName) : new \PhpParser\Node\VarLikeIdentifier($expectedName); + $node->name = $node instanceof PropertyFetch ? new Identifier($expectedName) : new VarLikeIdentifier($expectedName); return $node; }); } diff --git a/rules/Naming/PropertyRenamer/PropertyPromotionRenamer.php b/rules/Naming/PropertyRenamer/PropertyPromotionRenamer.php index 1abda0148cc..9da243c7825 100644 --- a/rules/Naming/PropertyRenamer/PropertyPromotionRenamer.php +++ b/rules/Naming/PropertyRenamer/PropertyPromotionRenamer.php @@ -60,7 +60,7 @@ final class PropertyPromotionRenamer * @var \Rector\Naming\VariableRenamer */ private $variableRenamer; - public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider, \Rector\Naming\ExpectedNameResolver\MatchParamTypeExpectedNameResolver $matchParamTypeExpectedNameResolver, \Rector\Naming\ValueObjectFactory\ParamRenameFactory $paramRenameFactory, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Naming\ParamRenamer\ParamRenamer $paramRenamer, \Rector\Naming\PropertyRenamer\PropertyFetchRenamer $propertyFetchRenamer, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Naming\VariableRenamer $variableRenamer) + public function __construct(PhpVersionProvider $phpVersionProvider, MatchParamTypeExpectedNameResolver $matchParamTypeExpectedNameResolver, ParamRenameFactory $paramRenameFactory, PhpDocInfoFactory $phpDocInfoFactory, ParamRenamer $paramRenamer, \Rector\Naming\PropertyRenamer\PropertyFetchRenamer $propertyFetchRenamer, NodeNameResolver $nodeNameResolver, VariableRenamer $variableRenamer) { $this->phpVersionProvider = $phpVersionProvider; $this->matchParamTypeExpectedNameResolver = $matchParamTypeExpectedNameResolver; @@ -71,13 +71,13 @@ final class PropertyPromotionRenamer $this->nodeNameResolver = $nodeNameResolver; $this->variableRenamer = $variableRenamer; } - public function renamePropertyPromotion(\PhpParser\Node\Stmt\ClassLike $classLike) : void + public function renamePropertyPromotion(ClassLike $classLike) : void { - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::PROPERTY_PROMOTION)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::PROPERTY_PROMOTION)) { return; } - $constructClassMethod = $classLike->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$constructClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $constructClassMethod = $classLike->getMethod(MethodName::CONSTRUCT); + if (!$constructClassMethod instanceof ClassMethod) { return; } // resolve possible and existing param names @@ -101,7 +101,7 @@ final class PropertyPromotionRenamer $this->renameParamVarNameAndVariableUsage($classLike, $constructClassMethod, $desiredPropertyName, $param); } } - private function renameParamVarNameAndVariableUsage(\PhpParser\Node\Stmt\ClassLike $classLike, \PhpParser\Node\Stmt\ClassMethod $classMethod, string $desiredPropertyName, \PhpParser\Node\Param $param) : void + private function renameParamVarNameAndVariableUsage(ClassLike $classLike, ClassMethod $classMethod, string $desiredPropertyName, Param $param) : void { $classMethodPhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); $currentParamName = $this->nodeNameResolver->getName($param); @@ -112,14 +112,14 @@ final class PropertyPromotionRenamer $param->var->name = $desiredPropertyName; $this->variableRenamer->renameVariableInFunctionLike($classMethod, $paramVarName, $desiredPropertyName); } - private function renameParamDoc(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\Param $param, string $paramVarName, string $desiredPropertyName) : void + private function renameParamDoc(PhpDocInfo $phpDocInfo, Param $param, string $paramVarName, string $desiredPropertyName) : void { $paramTagValueNode = $phpDocInfo->getParamTagValueNodeByName($paramVarName); - if (!$paramTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode) { + if (!$paramTagValueNode instanceof ParamTagValueNode) { return; } $paramRename = $this->paramRenameFactory->createFromResolvedExpectedName($param, $desiredPropertyName); - if (!$paramRename instanceof \Rector\Naming\ValueObject\ParamRename) { + if (!$paramRename instanceof ParamRename) { return; } $this->paramRenamer->rename($paramRename); @@ -137,7 +137,7 @@ final class PropertyPromotionRenamer /** * @return int[]|string[] */ - private function resolveBlockingParamNames(\PhpParser\Node\Stmt\ClassMethod $classMethod) : array + private function resolveBlockingParamNames(ClassMethod $classMethod) : array { $futureParamNames = []; foreach ($classMethod->params as $param) { diff --git a/rules/Naming/PropertyRenamer/PropertyRenamer.php b/rules/Naming/PropertyRenamer/PropertyRenamer.php index 3bc11b11c6c..a2c4fdc7afc 100644 --- a/rules/Naming/PropertyRenamer/PropertyRenamer.php +++ b/rules/Naming/PropertyRenamer/PropertyRenamer.php @@ -19,12 +19,12 @@ final class PropertyRenamer * @var \Rector\Naming\PropertyRenamer\PropertyFetchRenamer */ private $propertyFetchRenamer; - public function __construct(\Rector\Naming\RenameGuard\PropertyRenameGuard $propertyRenameGuard, \Rector\Naming\PropertyRenamer\PropertyFetchRenamer $propertyFetchRenamer) + public function __construct(PropertyRenameGuard $propertyRenameGuard, \Rector\Naming\PropertyRenamer\PropertyFetchRenamer $propertyFetchRenamer) { $this->propertyRenameGuard = $propertyRenameGuard; $this->propertyFetchRenamer = $propertyFetchRenamer; } - public function rename(\Rector\Naming\ValueObject\PropertyRename $propertyRename) : ?\PhpParser\Node\Stmt\Property + public function rename(PropertyRename $propertyRename) : ?Property { if ($propertyRename->isAlreadyExpectedName()) { return null; @@ -33,11 +33,11 @@ final class PropertyRenamer return null; } $onlyPropertyProperty = $propertyRename->getPropertyProperty(); - $onlyPropertyProperty->name = new \PhpParser\Node\VarLikeIdentifier($propertyRename->getExpectedName()); + $onlyPropertyProperty->name = new VarLikeIdentifier($propertyRename->getExpectedName()); $this->renamePropertyFetchesInClass($propertyRename); return $propertyRename->getProperty(); } - private function renamePropertyFetchesInClass(\Rector\Naming\ValueObject\PropertyRename $propertyRename) : void + private function renamePropertyFetchesInClass(PropertyRename $propertyRename) : void { $this->propertyFetchRenamer->renamePropertyFetchesInClass($propertyRename->getClassLike(), $propertyRename->getCurrentName(), $propertyRename->getExpectedName()); } diff --git a/rules/Naming/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector.php b/rules/Naming/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector.php index 45fced7dc01..734df07cf32 100644 --- a/rules/Naming/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector.php +++ b/rules/Naming/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector.php @@ -22,12 +22,12 @@ use Rector\Naming\ValueObject\VariableAndCallAssign; use Rector\Naming\VariableRenamer; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\PHPStanStaticTypeMapper\Utils\TypeUnwrapper; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector\RenameVariableToMatchMethodCallReturnTypeRectorTest */ -final class RenameVariableToMatchMethodCallReturnTypeRector extends \Rector\Core\Rector\AbstractRector +final class RenameVariableToMatchMethodCallReturnTypeRector extends AbstractRector { /** * @readonly @@ -74,7 +74,7 @@ final class RenameVariableToMatchMethodCallReturnTypeRector extends \Rector\Core * @var \Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer */ private $familyRelationsAnalyzer; - public function __construct(\Rector\Naming\Guard\BreakingVariableRenameGuard $breakingVariableRenameGuard, \Rector\Naming\Naming\ExpectedNameResolver $expectedNameResolver, \Rector\Naming\NamingConvention\NamingConventionAnalyzer $namingConventionAnalyzer, \Rector\Naming\PhpDoc\VarTagValueNodeRenamer $varTagValueNodeRenamer, \Rector\Naming\Matcher\VariableAndCallAssignMatcher $variableAndCallAssignMatcher, \Rector\Naming\VariableRenamer $variableRenamer, \Rector\PHPStanStaticTypeMapper\Utils\TypeUnwrapper $typeUnwrapper, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer $familyRelationsAnalyzer) + public function __construct(BreakingVariableRenameGuard $breakingVariableRenameGuard, ExpectedNameResolver $expectedNameResolver, NamingConventionAnalyzer $namingConventionAnalyzer, VarTagValueNodeRenamer $varTagValueNodeRenamer, VariableAndCallAssignMatcher $variableAndCallAssignMatcher, VariableRenamer $variableRenamer, TypeUnwrapper $typeUnwrapper, ReflectionProvider $reflectionProvider, FamilyRelationsAnalyzer $familyRelationsAnalyzer) { $this->breakingVariableRenameGuard = $breakingVariableRenameGuard; $this->expectedNameResolver = $expectedNameResolver; @@ -86,9 +86,9 @@ final class RenameVariableToMatchMethodCallReturnTypeRector extends \Rector\Core $this->reflectionProvider = $reflectionProvider; $this->familyRelationsAnalyzer = $familyRelationsAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Rename variable to match method return type', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Rename variable to match method return type', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -123,15 +123,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Assign::class]; + return [Assign::class]; } /** * @param Assign $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $variableAndCallAssign = $this->variableAndCallAssignMatcher->match($node); - if (!$variableAndCallAssign instanceof \Rector\Naming\ValueObject\VariableAndCallAssign) { + if (!$variableAndCallAssign instanceof VariableAndCallAssign) { return null; } $call = $variableAndCallAssign->getCall(); @@ -156,16 +156,16 @@ CODE_SAMPLE */ private function isMultipleCall($callNode) : bool { - $parentNode = $callNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $callNode->getAttribute(AttributeKey::PARENT_NODE); $callNodeClass = \get_class($callNode); - while ($parentNode instanceof \PhpParser\Node) { - $usedNodes = $this->betterNodeFinder->find($parentNode, function (\PhpParser\Node $node) use($callNodeClass, $callNode) : bool { + while ($parentNode instanceof Node) { + $usedNodes = $this->betterNodeFinder->find($parentNode, function (Node $node) use($callNodeClass, $callNode) : bool { $nodeClass = \get_class($node); if ($callNodeClass !== $nodeClass) { return \false; } - $usedNodeOriginalNode = $callNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE); - if (!$usedNodeOriginalNode instanceof \PhpParser\Node) { + $usedNodeOriginalNode = $callNode->getAttribute(AttributeKey::ORIGINAL_NODE); + if (!$usedNodeOriginalNode instanceof Node) { return \false; } if (\get_class($usedNodeOriginalNode) !== \get_class($callNode)) { @@ -184,11 +184,11 @@ CODE_SAMPLE if (\count($usedNodes) > 1) { return \true; } - $parentNode = $parentNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $parentNode->getAttribute(AttributeKey::PARENT_NODE); } return \false; } - private function shouldSkip(\Rector\Naming\ValueObject\VariableAndCallAssign $variableAndCallAssign, string $expectedName) : bool + private function shouldSkip(VariableAndCallAssign $variableAndCallAssign, string $expectedName) : bool { if ($this->namingConventionAnalyzer->isCallMatchingVariableName($variableAndCallAssign->getCall(), $variableAndCallAssign->getVariableName(), $expectedName)) { return \true; @@ -198,7 +198,7 @@ CODE_SAMPLE } return $this->breakingVariableRenameGuard->shouldSkipVariable($variableAndCallAssign->getVariableName(), $expectedName, $variableAndCallAssign->getFunctionLike(), $variableAndCallAssign->getVariable()); } - private function renameVariable(\Rector\Naming\ValueObject\VariableAndCallAssign $variableAndCallAssign, string $expectedName) : void + private function renameVariable(VariableAndCallAssign $variableAndCallAssign, string $expectedName) : void { $assign = $variableAndCallAssign->getAssign(); $assignPhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($assign); @@ -212,10 +212,10 @@ CODE_SAMPLE { $callStaticType = $this->getType($expr); $callStaticType = $this->typeUnwrapper->unwrapNullableType($callStaticType); - if (!$callStaticType instanceof \PHPStan\Type\ObjectType) { + if (!$callStaticType instanceof ObjectType) { return \false; } - if (\is_a($callStaticType->getClassName(), \PhpParser\Node\Stmt\ClassLike::class, \true)) { + if (\is_a($callStaticType->getClassName(), ClassLike::class, \true)) { return \false; } if (!$this->reflectionProvider->hasClass($callStaticType->getClassName())) { diff --git a/rules/Naming/Rector/ClassMethod/RenameParamToMatchTypeRector.php b/rules/Naming/Rector/ClassMethod/RenameParamToMatchTypeRector.php index cd377f6febf..f59fa050656 100644 --- a/rules/Naming/Rector/ClassMethod/RenameParamToMatchTypeRector.php +++ b/rules/Naming/Rector/ClassMethod/RenameParamToMatchTypeRector.php @@ -16,12 +16,12 @@ use Rector\Naming\Naming\ExpectedNameResolver; use Rector\Naming\ParamRenamer\ParamRenamer; use Rector\Naming\ValueObject\ParamRename; use Rector\Naming\ValueObjectFactory\ParamRenameFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector\RenameParamToMatchTypeRectorTest */ -final class RenameParamToMatchTypeRector extends \Rector\Core\Rector\AbstractRector +final class RenameParamToMatchTypeRector extends AbstractRector { /** * @var bool @@ -52,7 +52,7 @@ final class RenameParamToMatchTypeRector extends \Rector\Core\Rector\AbstractRec * @var \Rector\Naming\ParamRenamer\ParamRenamer */ private $paramRenamer; - public function __construct(\Rector\Naming\Guard\BreakingVariableRenameGuard $breakingVariableRenameGuard, \Rector\Naming\Naming\ExpectedNameResolver $expectedNameResolver, \Rector\Naming\ExpectedNameResolver\MatchParamTypeExpectedNameResolver $matchParamTypeExpectedNameResolver, \Rector\Naming\ValueObjectFactory\ParamRenameFactory $paramRenameFactory, \Rector\Naming\ParamRenamer\ParamRenamer $paramRenamer) + public function __construct(BreakingVariableRenameGuard $breakingVariableRenameGuard, ExpectedNameResolver $expectedNameResolver, MatchParamTypeExpectedNameResolver $matchParamTypeExpectedNameResolver, ParamRenameFactory $paramRenameFactory, ParamRenamer $paramRenamer) { $this->breakingVariableRenameGuard = $breakingVariableRenameGuard; $this->expectedNameResolver = $expectedNameResolver; @@ -60,9 +60,9 @@ final class RenameParamToMatchTypeRector extends \Rector\Core\Rector\AbstractRec $this->paramRenameFactory = $paramRenameFactory; $this->paramRenamer = $paramRenamer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Rename param to match ClassType', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Rename param to match ClassType', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run(Apple $pie) @@ -87,12 +87,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\Closure::class]; + return [ClassMethod::class, Function_::class, Closure::class]; } /** * @param ClassMethod|Function_|Closure $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $this->hasChanged = \false; foreach ($node->params as $param) { @@ -108,7 +108,7 @@ CODE_SAMPLE continue; } $paramRename = $this->paramRenameFactory->createFromResolvedExpectedName($param, $expectedName); - if (!$paramRename instanceof \Rector\Naming\ValueObject\ParamRename) { + if (!$paramRename instanceof ParamRename) { continue; } $this->paramRenamer->rename($paramRename); @@ -122,18 +122,18 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $classMethod */ - private function shouldSkipParam(\PhpParser\Node\Param $param, string $expectedName, $classMethod) : bool + private function shouldSkipParam(Param $param, string $expectedName, $classMethod) : bool { /** @var string $paramName */ $paramName = $this->getName($param); if ($this->breakingVariableRenameGuard->shouldSkipParam($paramName, $expectedName, $classMethod, $param)) { return \true; } - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$classMethod instanceof ClassMethod) { return \false; } // promoted property - if (!$this->isName($classMethod, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if (!$this->isName($classMethod, MethodName::CONSTRUCT)) { return \false; } return $param->flags !== 0; diff --git a/rules/Naming/Rector/ClassMethod/RenameVariableToMatchNewTypeRector.php b/rules/Naming/Rector/ClassMethod/RenameVariableToMatchNewTypeRector.php index 6e89d4ec541..f81c42625a5 100644 --- a/rules/Naming/Rector/ClassMethod/RenameVariableToMatchNewTypeRector.php +++ b/rules/Naming/Rector/ClassMethod/RenameVariableToMatchNewTypeRector.php @@ -12,12 +12,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\Naming\Guard\BreakingVariableRenameGuard; use Rector\Naming\Naming\ExpectedNameResolver; use Rector\Naming\VariableRenamer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector\RenameVariableToMatchNewTypeRectorTest */ -final class RenameVariableToMatchNewTypeRector extends \Rector\Core\Rector\AbstractRector +final class RenameVariableToMatchNewTypeRector extends AbstractRector { /** * @readonly @@ -34,15 +34,15 @@ final class RenameVariableToMatchNewTypeRector extends \Rector\Core\Rector\Abstr * @var \Rector\Naming\VariableRenamer */ private $variableRenamer; - public function __construct(\Rector\Naming\Guard\BreakingVariableRenameGuard $breakingVariableRenameGuard, \Rector\Naming\Naming\ExpectedNameResolver $expectedNameResolver, \Rector\Naming\VariableRenamer $variableRenamer) + public function __construct(BreakingVariableRenameGuard $breakingVariableRenameGuard, ExpectedNameResolver $expectedNameResolver, VariableRenamer $variableRenamer) { $this->breakingVariableRenameGuard = $breakingVariableRenameGuard; $this->expectedNameResolver = $expectedNameResolver; $this->variableRenamer = $variableRenamer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Rename variable to match new ClassType', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Rename variable to match new ClassType', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run() @@ -69,12 +69,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $hasChanged = \false; $assignsOfNew = $this->getAssignsOfNew($node); @@ -97,7 +97,7 @@ CODE_SAMPLE } $hasChanged = \true; // 1. rename assigned variable - $assignOfNew->var = new \PhpParser\Node\Expr\Variable($expectedName); + $assignOfNew->var = new Variable($expectedName); // 2. rename variable in the $this->variableRenamer->renameVariableInFunctionLike($node, $currentName, $expectedName, $assignOfNew); } @@ -109,12 +109,12 @@ CODE_SAMPLE /** * @return Assign[] */ - private function getAssignsOfNew(\PhpParser\Node\Stmt\ClassMethod $classMethod) : array + private function getAssignsOfNew(ClassMethod $classMethod) : array { /** @var Assign[] $assigns */ - $assigns = $this->betterNodeFinder->findInstanceOf((array) $classMethod->stmts, \PhpParser\Node\Expr\Assign::class); - return \array_filter($assigns, function (\PhpParser\Node\Expr\Assign $assign) : bool { - return $assign->expr instanceof \PhpParser\Node\Expr\New_; + $assigns = $this->betterNodeFinder->findInstanceOf((array) $classMethod->stmts, Assign::class); + return \array_filter($assigns, function (Assign $assign) : bool { + return $assign->expr instanceof New_; }); } } diff --git a/rules/Naming/Rector/Class_/RenamePropertyToMatchTypeRector.php b/rules/Naming/Rector/Class_/RenamePropertyToMatchTypeRector.php index 34960b690aa..405c360ae48 100644 --- a/rules/Naming/Rector/Class_/RenamePropertyToMatchTypeRector.php +++ b/rules/Naming/Rector/Class_/RenamePropertyToMatchTypeRector.php @@ -14,12 +14,12 @@ use Rector\Naming\PropertyRenamer\MatchTypePropertyRenamer; use Rector\Naming\PropertyRenamer\PropertyPromotionRenamer; use Rector\Naming\ValueObject\PropertyRename; use Rector\Naming\ValueObjectFactory\PropertyRenameFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Naming\Rector\Class_\RenamePropertyToMatchTypeRector\RenamePropertyToMatchTypeRectorTest */ -final class RenamePropertyToMatchTypeRector extends \Rector\Core\Rector\AbstractRector +final class RenamePropertyToMatchTypeRector extends AbstractRector { /** * @var bool @@ -45,16 +45,16 @@ final class RenamePropertyToMatchTypeRector extends \Rector\Core\Rector\Abstract * @var \Rector\Naming\PropertyRenamer\PropertyPromotionRenamer */ private $propertyPromotionRenamer; - public function __construct(\Rector\Naming\PropertyRenamer\MatchTypePropertyRenamer $matchTypePropertyRenamer, \Rector\Naming\ValueObjectFactory\PropertyRenameFactory $propertyRenameFactory, \Rector\Naming\ExpectedNameResolver\MatchPropertyTypeExpectedNameResolver $matchPropertyTypeExpectedNameResolver, \Rector\Naming\PropertyRenamer\PropertyPromotionRenamer $propertyPromotionRenamer) + public function __construct(MatchTypePropertyRenamer $matchTypePropertyRenamer, PropertyRenameFactory $propertyRenameFactory, MatchPropertyTypeExpectedNameResolver $matchPropertyTypeExpectedNameResolver, PropertyPromotionRenamer $propertyPromotionRenamer) { $this->matchTypePropertyRenamer = $matchTypePropertyRenamer; $this->propertyRenameFactory = $propertyRenameFactory; $this->matchPropertyTypeExpectedNameResolver = $matchPropertyTypeExpectedNameResolver; $this->propertyPromotionRenamer = $propertyPromotionRenamer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Rename property and method param to match its type', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Rename property and method param to match its type', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { /** @@ -89,12 +89,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class, \PhpParser\Node\Stmt\Interface_::class]; + return [Class_::class, Interface_::class]; } /** * @param Class_|Interface_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $this->refactorClassProperties($node); $this->propertyPromotionRenamer->renamePropertyPromotion($node); @@ -103,7 +103,7 @@ CODE_SAMPLE } return $node; } - private function refactorClassProperties(\PhpParser\Node\Stmt\ClassLike $classLike) : void + private function refactorClassProperties(ClassLike $classLike) : void { foreach ($classLike->getProperties() as $property) { $expectedPropertyName = $this->matchPropertyTypeExpectedNameResolver->resolve($property); @@ -111,11 +111,11 @@ CODE_SAMPLE continue; } $propertyRename = $this->propertyRenameFactory->createFromExpectedName($property, $expectedPropertyName); - if (!$propertyRename instanceof \Rector\Naming\ValueObject\PropertyRename) { + if (!$propertyRename instanceof PropertyRename) { continue; } $renameProperty = $this->matchTypePropertyRenamer->rename($propertyRename); - if (!$renameProperty instanceof \PhpParser\Node\Stmt\Property) { + if (!$renameProperty instanceof Property) { continue; } $this->hasChanged = \true; diff --git a/rules/Naming/Rector/Foreach_/RenameForeachValueVariableToMatchExprVariableRector.php b/rules/Naming/Rector/Foreach_/RenameForeachValueVariableToMatchExprVariableRector.php index e5c33e532a7..e949e2bc69c 100644 --- a/rules/Naming/Rector/Foreach_/RenameForeachValueVariableToMatchExprVariableRector.php +++ b/rules/Naming/Rector/Foreach_/RenameForeachValueVariableToMatchExprVariableRector.php @@ -15,12 +15,12 @@ use Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer; use Rector\Core\Rector\AbstractRector; use Rector\Naming\ExpectedNameResolver\InflectorSingularResolver; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector\RenameForeachValueVariableToMatchExprVariableRectorTest */ -final class RenameForeachValueVariableToMatchExprVariableRector extends \Rector\Core\Rector\AbstractRector +final class RenameForeachValueVariableToMatchExprVariableRector extends AbstractRector { /** * @readonly @@ -37,15 +37,15 @@ final class RenameForeachValueVariableToMatchExprVariableRector extends \Rector\ * @var \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer */ private $propertyFetchAnalyzer; - public function __construct(\Rector\Naming\ExpectedNameResolver\InflectorSingularResolver $inflectorSingularResolver, \Rector\CodeQuality\NodeAnalyzer\ForeachAnalyzer $foreachAnalyzer, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer) + public function __construct(InflectorSingularResolver $inflectorSingularResolver, ForeachAnalyzer $foreachAnalyzer, PropertyFetchAnalyzer $propertyFetchAnalyzer) { $this->inflectorSingularResolver = $inflectorSingularResolver; $this->foreachAnalyzer = $foreachAnalyzer; $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Renames value variable name in foreach loop to match expression variable', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Renames value variable name in foreach loop to match expression variable', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -76,15 +76,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Foreach_::class]; + return [Foreach_::class]; } /** * @param Foreach_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $isPropertyFetch = $this->propertyFetchAnalyzer->isPropertyFetch($node->expr); - if (!$node->expr instanceof \PhpParser\Node\Expr\Variable && !$isPropertyFetch) { + if (!$node->expr instanceof Variable && !$isPropertyFetch) { return null; } /** @var Variable|PropertyFetch|StaticPropertyFetch $expr */ @@ -96,7 +96,7 @@ CODE_SAMPLE if ($exprName === null) { return null; } - if ($node->keyVar instanceof \PhpParser\Node) { + if ($node->keyVar instanceof Node) { return null; } $valueVarName = $this->getName($node->valueVar); @@ -124,26 +124,26 @@ CODE_SAMPLE return \false; } /** @var PropertyFetch|StaticPropertyFetch $expr */ - $variableType = $expr instanceof \PhpParser\Node\Expr\PropertyFetch ? $this->nodeTypeResolver->getType($expr->var) : $this->nodeTypeResolver->getType($expr->class); - if ($variableType instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) { - $currentClassLike = $this->betterNodeFinder->findParentType($expr, \PhpParser\Node\Stmt\ClassLike::class); - if ($currentClassLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $variableType = $expr instanceof PropertyFetch ? $this->nodeTypeResolver->getType($expr->var) : $this->nodeTypeResolver->getType($expr->class); + if ($variableType instanceof FullyQualifiedObjectType) { + $currentClassLike = $this->betterNodeFinder->findParentType($expr, ClassLike::class); + if ($currentClassLike instanceof ClassLike) { return !$this->nodeNameResolver->isName($currentClassLike, $variableType->getClassName()); } } - return !$variableType instanceof \PHPStan\Type\ThisType; + return !$variableType instanceof ThisType; } - private function processRename(\PhpParser\Node\Stmt\Foreach_ $foreach, string $valueVarName, string $singularValueVarName) : \PhpParser\Node\Stmt\Foreach_ + private function processRename(Foreach_ $foreach, string $valueVarName, string $singularValueVarName) : Foreach_ { - $foreach->valueVar = new \PhpParser\Node\Expr\Variable($singularValueVarName); - $this->traverseNodesWithCallable($foreach->stmts, function (\PhpParser\Node $node) use($singularValueVarName, $valueVarName) : ?Variable { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + $foreach->valueVar = new Variable($singularValueVarName); + $this->traverseNodesWithCallable($foreach->stmts, function (Node $node) use($singularValueVarName, $valueVarName) : ?Variable { + if (!$node instanceof Variable) { return null; } if (!$this->isName($node, $valueVarName)) { return null; } - return new \PhpParser\Node\Expr\Variable($singularValueVarName); + return new Variable($singularValueVarName); }); return $foreach; } diff --git a/rules/Naming/Rector/Foreach_/RenameForeachValueVariableToMatchMethodCallReturnTypeRector.php b/rules/Naming/Rector/Foreach_/RenameForeachValueVariableToMatchMethodCallReturnTypeRector.php index dd05fa22d05..f2ec3b67a8e 100644 --- a/rules/Naming/Rector/Foreach_/RenameForeachValueVariableToMatchMethodCallReturnTypeRector.php +++ b/rules/Naming/Rector/Foreach_/RenameForeachValueVariableToMatchMethodCallReturnTypeRector.php @@ -12,12 +12,12 @@ use Rector\Naming\Naming\ExpectedNameResolver; use Rector\Naming\NamingConvention\NamingConventionAnalyzer; use Rector\Naming\ValueObject\VariableAndCallForeach; use Rector\Naming\VariableRenamer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector\RenameForeachValueVariableToMatchMethodCallReturnTypeRectorTest */ -final class RenameForeachValueVariableToMatchMethodCallReturnTypeRector extends \Rector\Core\Rector\AbstractRector +final class RenameForeachValueVariableToMatchMethodCallReturnTypeRector extends AbstractRector { /** * @readonly @@ -44,7 +44,7 @@ final class RenameForeachValueVariableToMatchMethodCallReturnTypeRector extends * @var \Rector\Naming\Matcher\ForeachMatcher */ private $foreachMatcher; - public function __construct(\Rector\Naming\Guard\BreakingVariableRenameGuard $breakingVariableRenameGuard, \Rector\Naming\Naming\ExpectedNameResolver $expectedNameResolver, \Rector\Naming\NamingConvention\NamingConventionAnalyzer $namingConventionAnalyzer, \Rector\Naming\VariableRenamer $variableRenamer, \Rector\Naming\Matcher\ForeachMatcher $foreachMatcher) + public function __construct(BreakingVariableRenameGuard $breakingVariableRenameGuard, ExpectedNameResolver $expectedNameResolver, NamingConventionAnalyzer $namingConventionAnalyzer, VariableRenamer $variableRenamer, ForeachMatcher $foreachMatcher) { $this->breakingVariableRenameGuard = $breakingVariableRenameGuard; $this->expectedNameResolver = $expectedNameResolver; @@ -52,9 +52,9 @@ final class RenameForeachValueVariableToMatchMethodCallReturnTypeRector extends $this->variableRenamer = $variableRenamer; $this->foreachMatcher = $foreachMatcher; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Renames value variable name in foreach loop to match method type', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Renames value variable name in foreach loop to match method type', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -85,15 +85,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Foreach_::class]; + return [Foreach_::class]; } /** * @param Foreach_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $variableAndCallForeach = $this->foreachMatcher->match($node); - if (!$variableAndCallForeach instanceof \Rector\Naming\ValueObject\VariableAndCallForeach) { + if (!$variableAndCallForeach instanceof VariableAndCallForeach) { return null; } $expectedName = $this->expectedNameResolver->resolveForForeach($variableAndCallForeach->getCall()); @@ -109,14 +109,14 @@ CODE_SAMPLE $this->renameVariable($variableAndCallForeach, $expectedName); return $node; } - private function shouldSkip(\Rector\Naming\ValueObject\VariableAndCallForeach $variableAndCallForeach, string $expectedName) : bool + private function shouldSkip(VariableAndCallForeach $variableAndCallForeach, string $expectedName) : bool { if ($this->namingConventionAnalyzer->isCallMatchingVariableName($variableAndCallForeach->getCall(), $variableAndCallForeach->getVariableName(), $expectedName)) { return \true; } return $this->breakingVariableRenameGuard->shouldSkipVariable($variableAndCallForeach->getVariableName(), $expectedName, $variableAndCallForeach->getFunctionLike(), $variableAndCallForeach->getVariable()); } - private function renameVariable(\Rector\Naming\ValueObject\VariableAndCallForeach $variableAndCallForeach, string $expectedName) : void + private function renameVariable(VariableAndCallForeach $variableAndCallForeach, string $expectedName) : void { $this->variableRenamer->renameVariableInFunctionLike($variableAndCallForeach->getFunctionLike(), $variableAndCallForeach->getVariableName(), $expectedName, null); } diff --git a/rules/Naming/RectorNamingInflector.php b/rules/Naming/RectorNamingInflector.php index 76ff261e927..21d8ce8a48b 100644 --- a/rules/Naming/RectorNamingInflector.php +++ b/rules/Naming/RectorNamingInflector.php @@ -17,13 +17,13 @@ final class RectorNamingInflector * @var \Doctrine\Inflector\Inflector */ private $inflector; - public function __construct(\RectorPrefix20220607\Doctrine\Inflector\Inflector $inflector) + public function __construct(Inflector $inflector) { $this->inflector = $inflector; } public function singularize(string $name) : string { - $matches = \RectorPrefix20220607\Nette\Utils\Strings::match($name, self::DATA_INFO_SUFFIX_REGEX); + $matches = Strings::match($name, self::DATA_INFO_SUFFIX_REGEX); if ($matches === null) { return $this->inflector->singularize($name); } diff --git a/rules/Naming/RenameGuard/PropertyRenameGuard.php b/rules/Naming/RenameGuard/PropertyRenameGuard.php index 935331adc34..3acb0c7fcbf 100644 --- a/rules/Naming/RenameGuard/PropertyRenameGuard.php +++ b/rules/Naming/RenameGuard/PropertyRenameGuard.php @@ -19,7 +19,7 @@ final class PropertyRenameGuard { $this->conflictingNameGuards = $conflictingNameGuards; } - public function shouldSkip(\Rector\Naming\Contract\RenameValueObjectInterface $renameValueObject) : bool + public function shouldSkip(RenameValueObjectInterface $renameValueObject) : bool { foreach ($this->conflictingNameGuards as $conflictingNameGuard) { if ($conflictingNameGuard->isConflicting($renameValueObject)) { diff --git a/rules/Naming/ValueObject/ParamRename.php b/rules/Naming/ValueObject/ParamRename.php index a9a28884a75..ab725890b56 100644 --- a/rules/Naming/ValueObject/ParamRename.php +++ b/rules/Naming/ValueObject/ParamRename.php @@ -9,7 +9,7 @@ use PhpParser\Node\Param; use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Function_; use Rector\Naming\Contract\RenameParamValueObjectInterface; -final class ParamRename implements \Rector\Naming\Contract\RenameParamValueObjectInterface +final class ParamRename implements RenameParamValueObjectInterface { /** * @readonly @@ -39,7 +39,7 @@ final class ParamRename implements \Rector\Naming\Contract\RenameParamValueObjec /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $functionLike */ - public function __construct(string $currentName, string $expectedName, \PhpParser\Node\Param $param, \PhpParser\Node\Expr\Variable $variable, $functionLike) + public function __construct(string $currentName, string $expectedName, Param $param, Variable $variable, $functionLike) { $this->currentName = $currentName; $this->expectedName = $expectedName; @@ -62,11 +62,11 @@ final class ParamRename implements \Rector\Naming\Contract\RenameParamValueObjec { return $this->functionLike; } - public function getParam() : \PhpParser\Node\Param + public function getParam() : Param { return $this->param; } - public function getVariable() : \PhpParser\Node\Expr\Variable + public function getVariable() : Variable { return $this->variable; } diff --git a/rules/Naming/ValueObject/PropertyRename.php b/rules/Naming/ValueObject/PropertyRename.php index adadb9d46af..2654e9b2080 100644 --- a/rules/Naming/ValueObject/PropertyRename.php +++ b/rules/Naming/ValueObject/PropertyRename.php @@ -7,7 +7,7 @@ use PhpParser\Node\Stmt\ClassLike; use PhpParser\Node\Stmt\Property; use PhpParser\Node\Stmt\PropertyProperty; use Rector\Naming\Contract\RenamePropertyValueObjectInterface; -final class PropertyRename implements \Rector\Naming\Contract\RenamePropertyValueObjectInterface +final class PropertyRename implements RenamePropertyValueObjectInterface { /** * @readonly @@ -39,7 +39,7 @@ final class PropertyRename implements \Rector\Naming\Contract\RenamePropertyValu * @var \PhpParser\Node\Stmt\PropertyProperty */ private $propertyProperty; - public function __construct(\PhpParser\Node\Stmt\Property $property, string $expectedName, string $currentName, \PhpParser\Node\Stmt\ClassLike $classLike, string $classLikeName, \PhpParser\Node\Stmt\PropertyProperty $propertyProperty) + public function __construct(Property $property, string $expectedName, string $currentName, ClassLike $classLike, string $classLikeName, PropertyProperty $propertyProperty) { $this->property = $property; $this->expectedName = $expectedName; @@ -48,7 +48,7 @@ final class PropertyRename implements \Rector\Naming\Contract\RenamePropertyValu $this->classLikeName = $classLikeName; $this->propertyProperty = $propertyProperty; } - public function getProperty() : \PhpParser\Node\Stmt\Property + public function getProperty() : Property { return $this->property; } @@ -68,7 +68,7 @@ final class PropertyRename implements \Rector\Naming\Contract\RenamePropertyValu { return $this->currentName === $this->expectedName; } - public function getClassLike() : \PhpParser\Node\Stmt\ClassLike + public function getClassLike() : ClassLike { return $this->classLike; } @@ -76,7 +76,7 @@ final class PropertyRename implements \Rector\Naming\Contract\RenamePropertyValu { return $this->classLikeName; } - public function getPropertyProperty() : \PhpParser\Node\Stmt\PropertyProperty + public function getPropertyProperty() : PropertyProperty { return $this->propertyProperty; } diff --git a/rules/Naming/ValueObject/VariableAndCallAssign.php b/rules/Naming/ValueObject/VariableAndCallAssign.php index 57479ab8a26..554c1b0a011 100644 --- a/rules/Naming/ValueObject/VariableAndCallAssign.php +++ b/rules/Naming/ValueObject/VariableAndCallAssign.php @@ -42,7 +42,7 @@ final class VariableAndCallAssign * @param \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $expr * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $functionLike */ - public function __construct(\PhpParser\Node\Expr\Variable $variable, $expr, \PhpParser\Node\Expr\Assign $assign, string $variableName, $functionLike) + public function __construct(Variable $variable, $expr, Assign $assign, string $variableName, $functionLike) { $this->variable = $variable; $this->expr = $expr; @@ -50,7 +50,7 @@ final class VariableAndCallAssign $this->variableName = $variableName; $this->functionLike = $functionLike; } - public function getVariable() : \PhpParser\Node\Expr\Variable + public function getVariable() : Variable { return $this->variable; } @@ -72,7 +72,7 @@ final class VariableAndCallAssign { return $this->functionLike; } - public function getAssign() : \PhpParser\Node\Expr\Assign + public function getAssign() : Assign { return $this->assign; } diff --git a/rules/Naming/ValueObject/VariableAndCallForeach.php b/rules/Naming/ValueObject/VariableAndCallForeach.php index 8f320ebc2cc..7b97199045f 100644 --- a/rules/Naming/ValueObject/VariableAndCallForeach.php +++ b/rules/Naming/ValueObject/VariableAndCallForeach.php @@ -36,14 +36,14 @@ final class VariableAndCallForeach * @param \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $expr * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $functionLike */ - public function __construct(\PhpParser\Node\Expr\Variable $variable, $expr, string $variableName, $functionLike) + public function __construct(Variable $variable, $expr, string $variableName, $functionLike) { $this->variable = $variable; $this->expr = $expr; $this->variableName = $variableName; $this->functionLike = $functionLike; } - public function getVariable() : \PhpParser\Node\Expr\Variable + public function getVariable() : Variable { return $this->variable; } diff --git a/rules/Naming/ValueObjectFactory/ParamRenameFactory.php b/rules/Naming/ValueObjectFactory/ParamRenameFactory.php index 6c796be3abf..8a3c755a39d 100644 --- a/rules/Naming/ValueObjectFactory/ParamRenameFactory.php +++ b/rules/Naming/ValueObjectFactory/ParamRenameFactory.php @@ -25,25 +25,25 @@ final class ParamRenameFactory * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder) { $this->nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; } - public function createFromResolvedExpectedName(\PhpParser\Node\Param $param, string $expectedName) : ?\Rector\Naming\ValueObject\ParamRename + public function createFromResolvedExpectedName(Param $param, string $expectedName) : ?ParamRename { /** @var ClassMethod|Function_|Closure|ArrowFunction|null $functionLike */ - $functionLike = $this->betterNodeFinder->findParentType($param, \PhpParser\Node\FunctionLike::class); + $functionLike = $this->betterNodeFinder->findParentType($param, FunctionLike::class); if ($functionLike === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException("There shouldn't be a param outside of FunctionLike"); + throw new ShouldNotHappenException("There shouldn't be a param outside of FunctionLike"); } - if ($functionLike instanceof \PhpParser\Node\Expr\ArrowFunction) { + if ($functionLike instanceof ArrowFunction) { return null; } $currentName = $this->nodeNameResolver->getName($param->var); if ($currentName === null) { return null; } - return new \Rector\Naming\ValueObject\ParamRename($currentName, $expectedName, $param, $param->var, $functionLike); + return new ParamRename($currentName, $expectedName, $param, $param->var, $functionLike); } } diff --git a/rules/Naming/ValueObjectFactory/PropertyRenameFactory.php b/rules/Naming/ValueObjectFactory/PropertyRenameFactory.php index 80a392a1364..e45f3533e65 100644 --- a/rules/Naming/ValueObjectFactory/PropertyRenameFactory.php +++ b/rules/Naming/ValueObjectFactory/PropertyRenameFactory.php @@ -23,19 +23,19 @@ final class PropertyRenameFactory * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder) { $this->nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; } - public function createFromExpectedName(\PhpParser\Node\Stmt\Property $property, string $expectedName) : ?\Rector\Naming\ValueObject\PropertyRename + public function createFromExpectedName(Property $property, string $expectedName) : ?PropertyRename { $currentName = $this->nodeNameResolver->getName($property); - $classLike = $this->betterNodeFinder->findParentType($property, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($property, ClassLike::class); + if (!$classLike instanceof ClassLike) { return null; } $className = (string) $this->nodeNameResolver->getName($classLike); - return new \Rector\Naming\ValueObject\PropertyRename($property, $expectedName, $currentName, $classLike, $className, $property->props[0]); + return new PropertyRename($property, $expectedName, $currentName, $classLike, $className, $property->props[0]); } } diff --git a/rules/Naming/VariableRenamer.php b/rules/Naming/VariableRenamer.php index d8930863980..711aca8dd60 100644 --- a/rules/Naming/VariableRenamer.php +++ b/rules/Naming/VariableRenamer.php @@ -44,7 +44,7 @@ final class VariableRenamer * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Naming\PhpDoc\VarTagValueNodeRenamer $varTagValueNodeRenamer, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver, VarTagValueNodeRenamer $varTagValueNodeRenamer, PhpDocInfoFactory $phpDocInfoFactory, BetterNodeFinder $betterNodeFinder) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->nodeNameResolver = $nodeNameResolver; @@ -55,23 +55,23 @@ final class VariableRenamer /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $functionLike */ - public function renameVariableInFunctionLike($functionLike, string $oldName, string $expectedName, ?\PhpParser\Node\Expr\Assign $assign = null) : void + public function renameVariableInFunctionLike($functionLike, string $oldName, string $expectedName, ?Assign $assign = null) : void { $isRenamingActive = \false; if ($assign === null) { $isRenamingActive = \true; } - $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $functionLike->stmts, function (\PhpParser\Node $node) use($oldName, $expectedName, $assign, &$isRenamingActive) : ?Variable { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $functionLike->stmts, function (Node $node) use($oldName, $expectedName, $assign, &$isRenamingActive) : ?Variable { if ($assign !== null && $node === $assign) { $isRenamingActive = \true; return null; } - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + if (!$node instanceof Variable) { return null; } // skip param names - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\Param) { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof Param) { return null; } // TODO: Remove in next PR (with above param check?), @@ -85,10 +85,10 @@ final class VariableRenamer return $this->renameVariableIfMatchesName($node, $oldName, $expectedName); }); } - private function isParamInParentFunction(\PhpParser\Node\Expr\Variable $variable) : bool + private function isParamInParentFunction(Variable $variable) : bool { - $closure = $this->betterNodeFinder->findParentType($variable, \PhpParser\Node\Expr\Closure::class); - if (!$closure instanceof \PhpParser\Node\Expr\Closure) { + $closure = $this->betterNodeFinder->findParentType($variable, Closure::class); + if (!$closure instanceof Closure) { return \false; } $variableName = $this->nodeNameResolver->getName($variable); @@ -102,7 +102,7 @@ final class VariableRenamer } return \false; } - private function renameVariableIfMatchesName(\PhpParser\Node\Expr\Variable $variable, string $oldName, string $expectedName) : ?\PhpParser\Node\Expr\Variable + private function renameVariableIfMatchesName(Variable $variable, string $oldName, string $expectedName) : ?Variable { if (!$this->nodeNameResolver->isName($variable, $oldName)) { return null; @@ -115,10 +115,10 @@ final class VariableRenamer /** * Expression doc block has higher priority */ - private function resolvePhpDocInfo(\PhpParser\Node\Expr\Variable $variable) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo + private function resolvePhpDocInfo(Variable $variable) : PhpDocInfo { $expression = $this->betterNodeFinder->resolveCurrentStatement($variable); - if ($expression instanceof \PhpParser\Node) { + if ($expression instanceof Node) { return $this->phpDocInfoFactory->createFromNodeOrEmpty($expression); } return $this->phpDocInfoFactory->createFromNodeOrEmpty($variable); diff --git a/rules/PSR4/Composer/PSR4AutoloadPathsProvider.php b/rules/PSR4/Composer/PSR4AutoloadPathsProvider.php index d80500b54bc..3d5e35c422d 100644 --- a/rules/PSR4/Composer/PSR4AutoloadPathsProvider.php +++ b/rules/PSR4/Composer/PSR4AutoloadPathsProvider.php @@ -16,7 +16,7 @@ final class PSR4AutoloadPathsProvider * @var \Symplify\SmartFileSystem\Json\JsonFileSystem */ private $jsonFileSystem; - public function __construct(\RectorPrefix20220607\Symplify\SmartFileSystem\Json\JsonFileSystem $jsonFileSystem) + public function __construct(JsonFileSystem $jsonFileSystem) { $this->jsonFileSystem = $jsonFileSystem; } @@ -29,7 +29,7 @@ final class PSR4AutoloadPathsProvider return $this->cachedComposerJsonPSR4AutoloadPaths; } $composerJson = $this->jsonFileSystem->loadFilePathToJson($this->getComposerJsonPath()); - $psr4Autoloads = \array_merge($composerJson[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::AUTOLOAD]['psr-4'] ?? [], $composerJson[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::AUTOLOAD_DEV]['psr-4'] ?? []); + $psr4Autoloads = \array_merge($composerJson[ComposerJsonSection::AUTOLOAD]['psr-4'] ?? [], $composerJson[ComposerJsonSection::AUTOLOAD_DEV]['psr-4'] ?? []); $this->cachedComposerJsonPSR4AutoloadPaths = $this->removeEmptyNamespaces($psr4Autoloads); return $this->cachedComposerJsonPSR4AutoloadPaths; } diff --git a/rules/PSR4/Composer/PSR4NamespaceMatcher.php b/rules/PSR4/Composer/PSR4NamespaceMatcher.php index d6aca1fc21c..2ac623f8b6f 100644 --- a/rules/PSR4/Composer/PSR4NamespaceMatcher.php +++ b/rules/PSR4/Composer/PSR4NamespaceMatcher.php @@ -7,11 +7,11 @@ use RectorPrefix20220607\Nette\Utils\Strings; use PhpParser\Node; use Rector\Core\ValueObject\Application\File; use Rector\PSR4\Contract\PSR4AutoloadNamespaceMatcherInterface; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; /** * @see \Rector\Tests\PSR4\Composer\PSR4NamespaceMatcherTest */ -final class PSR4NamespaceMatcher implements \Rector\PSR4\Contract\PSR4AutoloadNamespaceMatcherInterface +final class PSR4NamespaceMatcher implements PSR4AutoloadNamespaceMatcherInterface { /** * @readonly @@ -22,7 +22,7 @@ final class PSR4NamespaceMatcher implements \Rector\PSR4\Contract\PSR4AutoloadNa { $this->psr4AutoloadPathsProvider = $psr4AutoloadPathsProvider; } - public function getExpectedNamespace(\Rector\Core\ValueObject\Application\File $file, \PhpParser\Node $node) : ?string + public function getExpectedNamespace(File $file, Node $node) : ?string { $smartFileInfo = $file->getSmartFileInfo(); $psr4Autoloads = $this->psr4AutoloadPathsProvider->provide(); @@ -46,10 +46,10 @@ final class PSR4NamespaceMatcher implements \Rector\PSR4\Contract\PSR4AutoloadNa /** * Get the extra path that is not included in root PSR-4 namespace */ - private function resolveExtraNamespace(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo, string $path) : string + private function resolveExtraNamespace(SmartFileInfo $smartFileInfo, string $path) : string { - $extraNamespace = \RectorPrefix20220607\Nette\Utils\Strings::substring($smartFileInfo->getRelativeDirectoryPath(), \RectorPrefix20220607\Nette\Utils\Strings::length($path) + 1); - $extraNamespace = \RectorPrefix20220607\Nette\Utils\Strings::replace($extraNamespace, '#/#', '\\'); + $extraNamespace = Strings::substring($smartFileInfo->getRelativeDirectoryPath(), Strings::length($path) + 1); + $extraNamespace = Strings::replace($extraNamespace, '#/#', '\\'); return \trim($extraNamespace); } } diff --git a/rules/PSR4/Contract/PSR4AutoloadNamespaceMatcherInterface.php b/rules/PSR4/Contract/PSR4AutoloadNamespaceMatcherInterface.php index c4e359ba39a..f15c6a7650a 100644 --- a/rules/PSR4/Contract/PSR4AutoloadNamespaceMatcherInterface.php +++ b/rules/PSR4/Contract/PSR4AutoloadNamespaceMatcherInterface.php @@ -7,5 +7,5 @@ use PhpParser\Node; use Rector\Core\ValueObject\Application\File; interface PSR4AutoloadNamespaceMatcherInterface { - public function getExpectedNamespace(\Rector\Core\ValueObject\Application\File $file, \PhpParser\Node $node) : ?string; + public function getExpectedNamespace(File $file, Node $node) : ?string; } diff --git a/rules/PSR4/FileInfoAnalyzer/FileInfoDeletionAnalyzer.php b/rules/PSR4/FileInfoAnalyzer/FileInfoDeletionAnalyzer.php index 6f3d12ee658..5d2fa6a0dcc 100644 --- a/rules/PSR4/FileInfoAnalyzer/FileInfoDeletionAnalyzer.php +++ b/rules/PSR4/FileInfoAnalyzer/FileInfoDeletionAnalyzer.php @@ -25,12 +25,12 @@ final class FileInfoDeletionAnalyzer * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\CodingStyle\Naming\ClassNaming $classNaming, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(ClassNaming $classNaming, NodeNameResolver $nodeNameResolver) { $this->classNaming = $classNaming; $this->nodeNameResolver = $nodeNameResolver; } - public function isClassLikeAndFileInfoMatch(\Rector\Core\ValueObject\Application\File $file, \PhpParser\Node\Stmt\ClassLike $classLike) : bool + public function isClassLikeAndFileInfoMatch(File $file, ClassLike $classLike) : bool { $className = (string) $this->nodeNameResolver->getName($classLike); $smartFileInfo = $file->getSmartFileInfo(); @@ -40,6 +40,6 @@ final class FileInfoDeletionAnalyzer } public function clearNameFromTestingPrefix(string $name) : string { - return \RectorPrefix20220607\Nette\Utils\Strings::replace($name, self::TESTING_PREFIX_REGEX, ''); + return Strings::replace($name, self::TESTING_PREFIX_REGEX, ''); } } diff --git a/rules/PSR4/NodeManipulator/FullyQualifyStmtsAnalyzer.php b/rules/PSR4/NodeManipulator/FullyQualifyStmtsAnalyzer.php index 695e0cafbc8..afae19e7bc0 100644 --- a/rules/PSR4/NodeManipulator/FullyQualifyStmtsAnalyzer.php +++ b/rules/PSR4/NodeManipulator/FullyQualifyStmtsAnalyzer.php @@ -38,7 +38,7 @@ final class FullyQualifyStmtsAnalyzer * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ParameterProvider $parameterProvider, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider) { $this->parameterProvider = $parameterProvider; $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; @@ -51,35 +51,35 @@ final class FullyQualifyStmtsAnalyzer public function process(array $stmts) : void { // no need to - if ($this->parameterProvider->provideBoolParameter(\Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES)) { + if ($this->parameterProvider->provideBoolParameter(Option::AUTO_IMPORT_NAMES)) { return; } // FQNize all class names - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmts, function (\PhpParser\Node $node) : ?FullyQualified { - if (!$node instanceof \PhpParser\Node\Name) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmts, function (Node $node) : ?FullyQualified { + if (!$node instanceof Name) { return null; } $name = $this->nodeNameResolver->getName($node); - if (\in_array($name, [\Rector\Core\Enum\ObjectReference::STATIC, \Rector\Core\Enum\ObjectReference::PARENT, \Rector\Core\Enum\ObjectReference::SELF], \true)) { + if (\in_array($name, [ObjectReference::STATIC, ObjectReference::PARENT, ObjectReference::SELF], \true)) { return null; } if ($this->isNativeConstant($node)) { return null; } - return new \PhpParser\Node\Name\FullyQualified($name); + return new FullyQualified($name); }); } - private function isNativeConstant(\PhpParser\Node\Name $name) : bool + private function isNativeConstant(Name $name) : bool { - $parent = $name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\Expr\ConstFetch) { + $parent = $name->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof ConstFetch) { return \false; } - $scope = $name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $name->getAttribute(AttributeKey::SCOPE); if (!$this->reflectionProvider->hasConstant($name, $scope)) { return \false; } $constantReflection = $this->reflectionProvider->getConstant($name, $scope); - return $constantReflection instanceof \PHPStan\Reflection\Constant\RuntimeConstantReflection; + return $constantReflection instanceof RuntimeConstantReflection; } } diff --git a/rules/PSR4/NodeManipulator/NamespaceManipulator.php b/rules/PSR4/NodeManipulator/NamespaceManipulator.php index fb0c805f9fc..2a479d8c34b 100644 --- a/rules/PSR4/NodeManipulator/NamespaceManipulator.php +++ b/rules/PSR4/NodeManipulator/NamespaceManipulator.php @@ -7,10 +7,10 @@ use PhpParser\Node\Stmt\ClassLike; use PhpParser\Node\Stmt\Namespace_; final class NamespaceManipulator { - public function removeClassLikes(\PhpParser\Node\Stmt\Namespace_ $namespace) : void + public function removeClassLikes(Namespace_ $namespace) : void { foreach ($namespace->stmts as $key => $namespaceStatement) { - if (!$namespaceStatement instanceof \PhpParser\Node\Stmt\ClassLike) { + if (!$namespaceStatement instanceof ClassLike) { continue; } unset($namespace->stmts[$key]); diff --git a/rules/PSR4/Rector/FileWithoutNamespace/NormalizeNamespaceByPSR4ComposerAutoloadRector.php b/rules/PSR4/Rector/FileWithoutNamespace/NormalizeNamespaceByPSR4ComposerAutoloadRector.php index a420b5edfe3..cbf358c64ee 100644 --- a/rules/PSR4/Rector/FileWithoutNamespace/NormalizeNamespaceByPSR4ComposerAutoloadRector.php +++ b/rules/PSR4/Rector/FileWithoutNamespace/NormalizeNamespaceByPSR4ComposerAutoloadRector.php @@ -13,12 +13,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\PSR4\Contract\PSR4AutoloadNamespaceMatcherInterface; use Rector\PSR4\NodeManipulator\FullyQualifyStmtsAnalyzer; use Rector\PSR4\Rector\Namespace_\MultipleClassFileToPsr4ClassesRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ComposerJsonAwareCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ComposerJsonAwareCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector\NormalizeNamespaceByPSR4ComposerAutoloadRectorTest */ -final class NormalizeNamespaceByPSR4ComposerAutoloadRector extends \Rector\Core\Rector\AbstractRector +final class NormalizeNamespaceByPSR4ComposerAutoloadRector extends AbstractRector { /** * @readonly @@ -35,16 +35,16 @@ final class NormalizeNamespaceByPSR4ComposerAutoloadRector extends \Rector\Core\ * @var \Rector\Core\NodeAnalyzer\InlineHTMLAnalyzer */ private $inlineHTMLAnalyzer; - public function __construct(\Rector\PSR4\Contract\PSR4AutoloadNamespaceMatcherInterface $psr4AutoloadNamespaceMatcher, \Rector\PSR4\NodeManipulator\FullyQualifyStmtsAnalyzer $fullyQualifyStmtsAnalyzer, \Rector\Core\NodeAnalyzer\InlineHTMLAnalyzer $inlineHTMLAnalyzer) + public function __construct(PSR4AutoloadNamespaceMatcherInterface $psr4AutoloadNamespaceMatcher, FullyQualifyStmtsAnalyzer $fullyQualifyStmtsAnalyzer, InlineHTMLAnalyzer $inlineHTMLAnalyzer) { $this->psr4AutoloadNamespaceMatcher = $psr4AutoloadNamespaceMatcher; $this->fullyQualifyStmtsAnalyzer = $fullyQualifyStmtsAnalyzer; $this->inlineHTMLAnalyzer = $inlineHTMLAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - $description = \sprintf('Adds namespace to namespace-less files or correct namespace to match PSR-4 in `composer.json` autoload section. Run with combination with "%s"', \Rector\PSR4\Rector\Namespace_\MultipleClassFileToPsr4ClassesRector::class); - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition($description, [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ComposerJsonAwareCodeSample(<<<'CODE_SAMPLE' + $description = \sprintf('Adds namespace to namespace-less files or correct namespace to match PSR-4 in `composer.json` autoload section. Run with combination with "%s"', MultipleClassFileToPsr4ClassesRector::class); + return new RuleDefinition($description, [new ComposerJsonAwareCodeSample(<<<'CODE_SAMPLE' // src/SomeClass.php class SomeClass @@ -76,12 +76,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Namespace_::class, \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace::class]; + return [Namespace_::class, FileWithoutNamespace::class]; } /** * @param FileWithoutNamespace|Namespace_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $processNode = clone $node; if ($this->inlineHTMLAnalyzer->hasInlineHTML($processNode)) { @@ -92,37 +92,37 @@ CODE_SAMPLE return null; } // is namespace and already correctly named? - if ($processNode instanceof \PhpParser\Node\Stmt\Namespace_ && $this->nodeNameResolver->isCaseSensitiveName($processNode, $expectedNamespace)) { + if ($processNode instanceof Namespace_ && $this->nodeNameResolver->isCaseSensitiveName($processNode, $expectedNamespace)) { return null; } - if ($processNode instanceof \PhpParser\Node\Stmt\Namespace_ && $this->hasNamespaceInPreviousNamespace($processNode)) { + if ($processNode instanceof Namespace_ && $this->hasNamespaceInPreviousNamespace($processNode)) { return null; } // to put declare_strict types on correct place - if ($processNode instanceof \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace) { + if ($processNode instanceof FileWithoutNamespace) { return $this->refactorFileWithoutNamespace($processNode, $expectedNamespace); } - $processNode->name = new \PhpParser\Node\Name($expectedNamespace); + $processNode->name = new Name($expectedNamespace); $this->fullyQualifyStmtsAnalyzer->process($processNode->stmts); return $processNode; } - private function hasNamespaceInPreviousNamespace(\PhpParser\Node\Stmt\Namespace_ $namespace) : bool + private function hasNamespaceInPreviousNamespace(Namespace_ $namespace) : bool { - return (bool) $this->betterNodeFinder->findFirstPrevious($namespace, function (\PhpParser\Node $node) : bool { - return $node instanceof \PhpParser\Node\Stmt\Namespace_; + return (bool) $this->betterNodeFinder->findFirstPrevious($namespace, function (Node $node) : bool { + return $node instanceof Namespace_; }); } - private function refactorFileWithoutNamespace(\Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace $fileWithoutNamespace, string $expectedNamespace) : \PhpParser\Node\Stmt\Namespace_ + private function refactorFileWithoutNamespace(FileWithoutNamespace $fileWithoutNamespace, string $expectedNamespace) : Namespace_ { $nodes = $fileWithoutNamespace->stmts; $nodesWithStrictTypesThenNamespace = []; foreach ($nodes as $key => $fileWithoutNamespace) { - if ($fileWithoutNamespace instanceof \PhpParser\Node\Stmt\Declare_) { + if ($fileWithoutNamespace instanceof Declare_) { $nodesWithStrictTypesThenNamespace[] = $fileWithoutNamespace; unset($nodes[$key]); } } - $namespace = new \PhpParser\Node\Stmt\Namespace_(new \PhpParser\Node\Name($expectedNamespace), $nodes); + $namespace = new Namespace_(new Name($expectedNamespace), $nodes); $nodesWithStrictTypesThenNamespace[] = $namespace; $this->fullyQualifyStmtsAnalyzer->process($nodes); return $namespace; diff --git a/rules/PSR4/Rector/Namespace_/MultipleClassFileToPsr4ClassesRector.php b/rules/PSR4/Rector/Namespace_/MultipleClassFileToPsr4ClassesRector.php index 7ce64a1dcb6..6546fae5254 100644 --- a/rules/PSR4/Rector/Namespace_/MultipleClassFileToPsr4ClassesRector.php +++ b/rules/PSR4/Rector/Namespace_/MultipleClassFileToPsr4ClassesRector.php @@ -13,12 +13,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\PSR4\FileInfoAnalyzer\FileInfoDeletionAnalyzer; use Rector\PSR4\NodeManipulator\NamespaceManipulator; use Rector\Symfony\Printer\NeighbourClassLikePrinter; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\PSR4\Rector\Namespace_\MultipleClassFileToPsr4ClassesRector\MultipleClassFileToPsr4ClassesRectorTest */ -final class MultipleClassFileToPsr4ClassesRector extends \Rector\Core\Rector\AbstractRector +final class MultipleClassFileToPsr4ClassesRector extends AbstractRector { /** * @readonly @@ -40,16 +40,16 @@ final class MultipleClassFileToPsr4ClassesRector extends \Rector\Core\Rector\Abs * @var \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector */ private $removedAndAddedFilesCollector; - public function __construct(\Rector\PSR4\NodeManipulator\NamespaceManipulator $namespaceManipulator, \Rector\PSR4\FileInfoAnalyzer\FileInfoDeletionAnalyzer $fileInfoDeletionAnalyzer, \Rector\Symfony\Printer\NeighbourClassLikePrinter $neighbourClassLikePrinter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector) + public function __construct(NamespaceManipulator $namespaceManipulator, FileInfoDeletionAnalyzer $fileInfoDeletionAnalyzer, NeighbourClassLikePrinter $neighbourClassLikePrinter, RemovedAndAddedFilesCollector $removedAndAddedFilesCollector) { $this->namespaceManipulator = $namespaceManipulator; $this->fileInfoDeletionAnalyzer = $fileInfoDeletionAnalyzer; $this->neighbourClassLikePrinter = $neighbourClassLikePrinter; $this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change multiple classes in one file to standalone PSR-4 classes.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change multiple classes in one file to standalone PSR-4 classes.', [new CodeSample(<<<'CODE_SAMPLE' namespace App\Exceptions; use Exception; @@ -88,21 +88,21 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Namespace_::class, \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace::class]; + return [Namespace_::class, FileWithoutNamespace::class]; } /** * @param Namespace_|FileWithoutNamespace $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->hasAtLeastTwoClassLikes($node)) { return null; } $nodeToReturn = null; - if ($node instanceof \PhpParser\Node\Stmt\Namespace_) { + if ($node instanceof Namespace_) { $nodeToReturn = $this->refactorNamespace($node); } - if ($node instanceof \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace) { + if ($node instanceof FileWithoutNamespace) { $nodeToReturn = $this->refactorFileWithoutNamespace($node); } // 1. remove this node @@ -114,12 +114,12 @@ CODE_SAMPLE $this->removedAndAddedFilesCollector->removeFile($smartFileInfo); return null; } - private function hasAtLeastTwoClassLikes(\PhpParser\Node $node) : bool + private function hasAtLeastTwoClassLikes(Node $node) : bool { $nonAnonymousClassLikes = $this->findNonAnonymousClassLikes($node); return \count($nonAnonymousClassLikes) > 1; } - private function refactorNamespace(\PhpParser\Node\Stmt\Namespace_ $namespace) : ?\PhpParser\Node\Stmt\Namespace_ + private function refactorNamespace(Namespace_ $namespace) : ?Namespace_ { $classLikes = $this->findNonAnonymousClassLikes($namespace); $this->namespaceManipulator->removeClassLikes($namespace); @@ -137,7 +137,7 @@ CODE_SAMPLE } return $nodeToReturn; } - private function refactorFileWithoutNamespace(\Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace $fileWithoutNamespace) : ?\Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace + private function refactorFileWithoutNamespace(FileWithoutNamespace $fileWithoutNamespace) : ?FileWithoutNamespace { $classLikes = $this->findNonAnonymousClassLikes($fileWithoutNamespace); $nodeToReturn = null; @@ -155,7 +155,7 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Stmt\Namespace_|\Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace $mainNode */ - private function printNewNodes(\PhpParser\Node\Stmt\ClassLike $classLike, $mainNode) : void + private function printNewNodes(ClassLike $classLike, $mainNode) : void { $smartFileInfo = $this->file->getSmartFileInfo(); $this->neighbourClassLikePrinter->printClassLike($classLike, $mainNode, $smartFileInfo, $this->file); @@ -163,11 +163,11 @@ CODE_SAMPLE /** * @return ClassLike[] */ - private function findNonAnonymousClassLikes(\PhpParser\Node $node) : array + private function findNonAnonymousClassLikes(Node $node) : array { - $classLikes = $this->betterNodeFinder->findInstanceOf([$node], \PhpParser\Node\Stmt\ClassLike::class); - return \array_filter($classLikes, function (\PhpParser\Node\Stmt\ClassLike $classLike) : bool { - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLikes = $this->betterNodeFinder->findInstanceOf([$node], ClassLike::class); + return \array_filter($classLikes, function (ClassLike $classLike) : bool { + if (!$classLike instanceof Class_) { return \true; } return !$classLike->isAnonymous(); diff --git a/rules/Php52/Rector/Property/VarToPublicPropertyRector.php b/rules/Php52/Rector/Property/VarToPublicPropertyRector.php index 11be35ad7fa..e4491edf17d 100644 --- a/rules/Php52/Rector/Property/VarToPublicPropertyRector.php +++ b/rules/Php52/Rector/Property/VarToPublicPropertyRector.php @@ -9,29 +9,29 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Privatization\NodeManipulator\VisibilityManipulator; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php52\Rector\Property\VarToPublicPropertyRector\VarToPublicPropertyRectorTest */ -final class VarToPublicPropertyRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class VarToPublicPropertyRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\Privatization\NodeManipulator\VisibilityManipulator */ private $visibilityManipulator; - public function __construct(\Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator) + public function __construct(VisibilityManipulator $visibilityManipulator) { $this->visibilityManipulator = $visibilityManipulator; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::PROPERTY_MODIFIER; + return PhpVersionFeature::PROPERTY_MODIFIER; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change property modifier from `var` to `public`', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change property modifier from `var` to `public`', [new CodeSample(<<<'CODE_SAMPLE' final class SomeController { var $name = 'Tom'; @@ -50,12 +50,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { // explicitly public if ($node->flags !== 0) { diff --git a/rules/Php52/Rector/Switch_/ContinueToBreakInSwitchRector.php b/rules/Php52/Rector/Switch_/ContinueToBreakInSwitchRector.php index 35f01b040a5..1252fa421d7 100644 --- a/rules/Php52/Rector/Switch_/ContinueToBreakInSwitchRector.php +++ b/rules/Php52/Rector/Switch_/ContinueToBreakInSwitchRector.php @@ -14,21 +14,21 @@ use PHPStan\Type\ConstantType; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://stackoverflow.com/a/12349889/1348344 * @see \Rector\Tests\Php52\Rector\Switch_\ContinueToBreakInSwitchRector\ContinueToBreakInSwitchRectorTest */ -final class ContinueToBreakInSwitchRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ContinueToBreakInSwitchRector extends AbstractRector implements MinPhpVersionInterface { public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::CONTINUE_TO_BREAK; + return PhpVersionFeature::CONTINUE_TO_BREAK; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Use break instead of continue in switch statements', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Use break instead of continue in switch statements', [new CodeSample(<<<'CODE_SAMPLE' function some_run($value) { switch ($value) { @@ -61,17 +61,17 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Switch_::class]; + return [Switch_::class]; } /** * @param Switch_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Stmt\Switch_ + public function refactor(Node $node) : ?Switch_ { $hasChanged = \false; foreach ($node->cases as $case) { foreach ($case->stmts as $key => $caseStmt) { - if (!$caseStmt instanceof \PhpParser\Node\Stmt\Continue_) { + if (!$caseStmt instanceof Continue_) { continue; } $newStmt = $this->processContinueStatement($caseStmt); @@ -90,17 +90,17 @@ CODE_SAMPLE /** * @return \PhpParser\Node\Stmt\Break_|\PhpParser\Node\Stmt\Continue_ */ - private function processContinueStatement(\PhpParser\Node\Stmt\Continue_ $continue) + private function processContinueStatement(Continue_ $continue) { if ($continue->num === null) { - return new \PhpParser\Node\Stmt\Break_(); + return new Break_(); } - if ($continue->num instanceof \PhpParser\Node\Scalar\LNumber) { + if ($continue->num instanceof LNumber) { $continueNumber = $this->valueResolver->getValue($continue->num); if ($continueNumber <= 1) { - return new \PhpParser\Node\Stmt\Break_(); + return new Break_(); } - } elseif ($continue->num instanceof \PhpParser\Node\Expr\Variable) { + } elseif ($continue->num instanceof Variable) { return $this->processVariableNum($continue, $continue->num); } return $continue; @@ -108,18 +108,18 @@ CODE_SAMPLE /** * @return \PhpParser\Node\Stmt\Continue_|\PhpParser\Node\Stmt\Break_ */ - private function processVariableNum(\PhpParser\Node\Stmt\Continue_ $continue, \PhpParser\Node\Expr\Variable $numVariable) + private function processVariableNum(Continue_ $continue, Variable $numVariable) { $staticType = $this->getType($numVariable); - if (!$staticType instanceof \PHPStan\Type\ConstantType) { + if (!$staticType instanceof ConstantType) { return $continue; } - if (!$staticType instanceof \PHPStan\Type\Constant\ConstantIntegerType) { + if (!$staticType instanceof ConstantIntegerType) { return $continue; } if ($staticType->getValue() > 1) { return $continue; } - return new \PhpParser\Node\Stmt\Break_(); + return new Break_(); } } diff --git a/rules/Php53/Rector/FuncCall/DirNameFileConstantToDirConstantRector.php b/rules/Php53/Rector/FuncCall/DirNameFileConstantToDirConstantRector.php index 433696419b4..7e948dfb23a 100644 --- a/rules/Php53/Rector/FuncCall/DirNameFileConstantToDirConstantRector.php +++ b/rules/Php53/Rector/FuncCall/DirNameFileConstantToDirConstantRector.php @@ -11,16 +11,16 @@ use PhpParser\Node\Scalar\MagicConst\File; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector\DirNameFileConstantToDirConstantRectorTest */ -final class DirNameFileConstantToDirConstantRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class DirNameFileConstantToDirConstantRector extends AbstractRector implements MinPhpVersionInterface { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Convert dirname(__FILE__) to __DIR__', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Convert dirname(__FILE__) to __DIR__', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -45,12 +45,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'dirname')) { return null; @@ -61,17 +61,17 @@ CODE_SAMPLE if (!isset($node->args[0])) { return null; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } $firstArgValue = $node->args[0]->value; - if (!$firstArgValue instanceof \PhpParser\Node\Scalar\MagicConst\File) { + if (!$firstArgValue instanceof File) { return null; } - return new \PhpParser\Node\Scalar\MagicConst\Dir(); + return new Dir(); } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::DIR_CONSTANT; + return PhpVersionFeature::DIR_CONSTANT; } } diff --git a/rules/Php53/Rector/Ternary/TernaryToElvisRector.php b/rules/Php53/Rector/Ternary/TernaryToElvisRector.php index f1a67feec3f..ec63dbe10fc 100644 --- a/rules/Php53/Rector/Ternary/TernaryToElvisRector.php +++ b/rules/Php53/Rector/Ternary/TernaryToElvisRector.php @@ -9,18 +9,18 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog http://php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary https://stackoverflow.com/a/1993455/1348344 * * @see \Rector\Tests\Php53\Rector\Ternary\TernaryToElvisRector\TernaryToElvisRectorTest */ -final class TernaryToElvisRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class TernaryToElvisRector extends AbstractRector implements MinPhpVersionInterface { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Use ?: instead of ?, where useful', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Use ?: instead of ?, where useful', [new CodeSample(<<<'CODE_SAMPLE' function elvis() { $value = $a ? $a : false; @@ -39,22 +39,22 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Ternary::class]; + return [Ternary::class]; } /** * @param Ternary $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->nodeComparator->areNodesEqual($node->cond, $node->if)) { return null; } - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); $node->if = null; return $node; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::ELVIS_OPERATOR; + return PhpVersionFeature::ELVIS_OPERATOR; } } diff --git a/rules/Php53/Rector/Variable/ReplaceHttpServerVarsByServerRector.php b/rules/Php53/Rector/Variable/ReplaceHttpServerVarsByServerRector.php index fe644a9f42b..a4d9a16089e 100644 --- a/rules/Php53/Rector/Variable/ReplaceHttpServerVarsByServerRector.php +++ b/rules/Php53/Rector/Variable/ReplaceHttpServerVarsByServerRector.php @@ -8,13 +8,13 @@ use PhpParser\Node\Expr\Variable; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php53\Rector\Variable\ReplaceHttpServerVarsByServerRector\ReplaceHttpServerVarsByServerRectorTest * @changelog https://blog.tigertech.net/posts/php-5-3-http-server-vars/ */ -final class ReplaceHttpServerVarsByServerRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ReplaceHttpServerVarsByServerRector extends AbstractRector implements MinPhpVersionInterface { /** * @var array @@ -22,23 +22,23 @@ final class ReplaceHttpServerVarsByServerRector extends \Rector\Core\Rector\Abst 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 \Rector\Core\ValueObject\PhpVersionFeature::SERVER_VAR; + return PhpVersionFeature::SERVER_VAR; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Rename old $HTTP_* variable names to new replacements', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$serverVars = $HTTP_SERVER_VARS;', '$serverVars = $_SERVER;')]); + return new RuleDefinition('Rename old $HTTP_* variable names to new replacements', [new CodeSample('$serverVars = $HTTP_SERVER_VARS;', '$serverVars = $_SERVER;')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Variable::class]; + return [Variable::class]; } /** * @param Variable $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach (self::VARIABLE_RENAME_MAP as $oldName => $newName) { if (!$this->isName($node, $oldName)) { diff --git a/rules/Php54/Rector/Break_/RemoveZeroBreakContinueRector.php b/rules/Php54/Rector/Break_/RemoveZeroBreakContinueRector.php index 1dbbdfd5e4f..44d1f6216ff 100644 --- a/rules/Php54/Rector/Break_/RemoveZeroBreakContinueRector.php +++ b/rules/Php54/Rector/Break_/RemoveZeroBreakContinueRector.php @@ -13,22 +13,22 @@ use PHPStan\Type\ConstantType; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/control-structures.continue.php https://www.php.net/manual/en/control-structures.break.php * * @see \Rector\Tests\Php54\Rector\Break_\RemoveZeroBreakContinueRector\RemoveZeroBreakContinueRectorTest */ -final class RemoveZeroBreakContinueRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class RemoveZeroBreakContinueRector extends AbstractRector implements MinPhpVersionInterface { public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NO_ZERO_BREAK; + return PhpVersionFeature::NO_ZERO_BREAK; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove 0 from break and continue', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove 0 from break and continue', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($random) @@ -65,17 +65,17 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Break_::class, \PhpParser\Node\Stmt\Continue_::class]; + return [Break_::class, Continue_::class]; } /** * @param Break_|Continue_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->num === null) { return null; } - if ($node->num instanceof \PhpParser\Node\Scalar\LNumber) { + if ($node->num instanceof LNumber) { $number = $this->valueResolver->getValue($node->num); if ($number > 1) { return null; @@ -86,7 +86,7 @@ CODE_SAMPLE } return null; } - if ($node->num instanceof \PhpParser\Node\Expr\Variable) { + if ($node->num instanceof Variable) { return $this->processVariableNum($node, $node->num); } return null; @@ -94,17 +94,17 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Stmt\Break_|\PhpParser\Node\Stmt\Continue_ $stmt */ - private function processVariableNum($stmt, \PhpParser\Node\Expr\Variable $numVariable) : ?\PhpParser\Node + private function processVariableNum($stmt, Variable $numVariable) : ?Node { $staticType = $this->getType($numVariable); - if ($staticType instanceof \PHPStan\Type\ConstantType) { - if ($staticType instanceof \PHPStan\Type\Constant\ConstantIntegerType) { + if ($staticType instanceof ConstantType) { + if ($staticType instanceof ConstantIntegerType) { if ($staticType->getValue() === 0) { $stmt->num = null; return $stmt; } if ($staticType->getValue() > 0) { - $stmt->num = new \PhpParser\Node\Scalar\LNumber($staticType->getValue()); + $stmt->num = new LNumber($staticType->getValue()); return $stmt; } } diff --git a/rules/Php54/Rector/FuncCall/RemoveReferenceFromCallRector.php b/rules/Php54/Rector/FuncCall/RemoveReferenceFromCallRector.php index bd10793d379..93c31388557 100644 --- a/rules/Php54/Rector/FuncCall/RemoveReferenceFromCallRector.php +++ b/rules/Php54/Rector/FuncCall/RemoveReferenceFromCallRector.php @@ -9,20 +9,20 @@ use PhpParser\Node\Expr\FuncCall; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php54\Rector\FuncCall\RemoveReferenceFromCallRector\RemoveReferenceFromCallRectorTest */ -final class RemoveReferenceFromCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class RemoveReferenceFromCallRector extends AbstractRector implements MinPhpVersionInterface { public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NO_REFERENCE_IN_ARG; + return PhpVersionFeature::NO_REFERENCE_IN_ARG; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove & from function and method calls', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove & from function and method calls', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run($one) @@ -47,17 +47,17 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node * @return \PhpParser\Node\Expr\FuncCall|null */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { $hasChanged = \false; foreach ($node->args as $nodeArg) { - if (!$nodeArg instanceof \PhpParser\Node\Arg) { + if (!$nodeArg instanceof Arg) { continue; } if (!$nodeArg->byRef) { diff --git a/rules/Php55/Rector/Class_/ClassConstantToSelfClassRector.php b/rules/Php55/Rector/Class_/ClassConstantToSelfClassRector.php index cdef2f6afbb..9197fdb1c70 100644 --- a/rules/Php55/Rector/Class_/ClassConstantToSelfClassRector.php +++ b/rules/Php55/Rector/Class_/ClassConstantToSelfClassRector.php @@ -9,18 +9,18 @@ use PhpParser\Node\Scalar\MagicConst\Class_; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/deprecations_php_7_4 (not confirmed yet) * @changelog https://3v4l.org/INd7o * @see \Rector\Tests\Php55\Rector\Class_\ClassConstantToSelfClassRector\ClassConstantToSelfClassRectorTest */ -final class ClassConstantToSelfClassRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ClassConstantToSelfClassRector extends AbstractRector implements MinPhpVersionInterface { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change `__CLASS__` to self::class', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change `__CLASS__` to self::class', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function callOnMe() @@ -45,17 +45,17 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Scalar\MagicConst\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : \PhpParser\Node\Expr\ClassConstFetch + public function refactor(Node $node) : ClassConstFetch { return $this->nodeFactory->createSelfFetchConstant('class'); } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::CLASSNAME_CONSTANT; + return PhpVersionFeature::CLASSNAME_CONSTANT; } } diff --git a/rules/Php55/Rector/FuncCall/GetCalledClassToSelfClassRector.php b/rules/Php55/Rector/FuncCall/GetCalledClassToSelfClassRector.php index 263d4420d84..b33bf939c7d 100644 --- a/rules/Php55/Rector/FuncCall/GetCalledClassToSelfClassRector.php +++ b/rules/Php55/Rector/FuncCall/GetCalledClassToSelfClassRector.php @@ -11,27 +11,27 @@ use Rector\Core\NodeAnalyzer\ClassAnalyzer; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/ChangeLog-5.php#5.5.0 * @changelog https://3v4l.org/GU9dP * @see \Rector\Tests\Php55\Rector\FuncCall\GetCalledClassToSelfClassRector\GetCalledClassToSelfClassRectorTest */ -final class GetCalledClassToSelfClassRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class GetCalledClassToSelfClassRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\Core\NodeAnalyzer\ClassAnalyzer */ private $classAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer) + public function __construct(ClassAnalyzer $classAnalyzer) { $this->classAnalyzer = $classAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change get_called_class() to self::class on final class', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change get_called_class() to self::class on final class', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function callOnMe() @@ -56,30 +56,30 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'get_called_class')) { return null; } - $class = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$class instanceof Class_) { return null; } if ($class->isFinal()) { - return $this->nodeFactory->createClassConstFetch(\Rector\Core\Enum\ObjectReference::SELF, 'class'); + return $this->nodeFactory->createClassConstFetch(ObjectReference::SELF, 'class'); } if ($this->classAnalyzer->isAnonymousClass($class)) { - return $this->nodeFactory->createClassConstFetch(\Rector\Core\Enum\ObjectReference::SELF, 'class'); + return $this->nodeFactory->createClassConstFetch(ObjectReference::SELF, 'class'); } return null; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::CLASSNAME_CONSTANT; + return PhpVersionFeature::CLASSNAME_CONSTANT; } } diff --git a/rules/Php55/Rector/FuncCall/GetCalledClassToStaticClassRector.php b/rules/Php55/Rector/FuncCall/GetCalledClassToStaticClassRector.php index cfb4a6cd059..aac493d026a 100644 --- a/rules/Php55/Rector/FuncCall/GetCalledClassToStaticClassRector.php +++ b/rules/Php55/Rector/FuncCall/GetCalledClassToStaticClassRector.php @@ -11,27 +11,27 @@ use Rector\Core\NodeAnalyzer\ClassAnalyzer; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/ChangeLog-5.php#5.5.0 * @changelog https://3v4l.org/dJgXd * @see \Rector\Tests\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector\GetCalledClassToStaticClassRectorTest */ -final class GetCalledClassToStaticClassRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class GetCalledClassToStaticClassRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\Core\NodeAnalyzer\ClassAnalyzer */ private $classAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer) + public function __construct(ClassAnalyzer $classAnalyzer) { $this->classAnalyzer = $classAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change get_called_class() to static::class on non-final class', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change get_called_class() to static::class on non-final class', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function callOnMe() @@ -56,30 +56,30 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'get_called_class')) { return null; } - $class = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { - return $this->nodeFactory->createClassConstFetch(\Rector\Core\Enum\ObjectReference::STATIC, 'class'); + $class = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$class instanceof Class_) { + return $this->nodeFactory->createClassConstFetch(ObjectReference::STATIC, 'class'); } if ($this->classAnalyzer->isAnonymousClass($class)) { return null; } if (!$class->isFinal()) { - return $this->nodeFactory->createClassConstFetch(\Rector\Core\Enum\ObjectReference::STATIC, 'class'); + return $this->nodeFactory->createClassConstFetch(ObjectReference::STATIC, 'class'); } return null; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::CLASSNAME_CONSTANT; + return PhpVersionFeature::CLASSNAME_CONSTANT; } } diff --git a/rules/Php55/Rector/FuncCall/PregReplaceEModifierRector.php b/rules/Php55/Rector/FuncCall/PregReplaceEModifierRector.php index 7bbc54c1de0..2b31b255372 100644 --- a/rules/Php55/Rector/FuncCall/PregReplaceEModifierRector.php +++ b/rules/Php55/Rector/FuncCall/PregReplaceEModifierRector.php @@ -15,14 +15,14 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Php55\RegexMatcher; use Rector\Php72\NodeFactory\AnonymousFunctionFactory; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/remove_preg_replace_eval_modifier https://stackoverflow.com/q/19245205/1348344 * * @see \Rector\Tests\Php55\Rector\FuncCall\PregReplaceEModifierRector\PregReplaceEModifierRectorTest */ -final class PregReplaceEModifierRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class PregReplaceEModifierRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -39,7 +39,7 @@ final class PregReplaceEModifierRector extends \Rector\Core\Rector\AbstractRecto * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Php72\NodeFactory\AnonymousFunctionFactory $anonymousFunctionFactory, \Rector\Php55\RegexMatcher $regexMatcher, \Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(AnonymousFunctionFactory $anonymousFunctionFactory, RegexMatcher $regexMatcher, ArgsAnalyzer $argsAnalyzer) { $this->anonymousFunctionFactory = $anonymousFunctionFactory; $this->regexMatcher = $regexMatcher; @@ -47,11 +47,11 @@ final class PregReplaceEModifierRector extends \Rector\Core\Rector\AbstractRecto } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::PREG_REPLACE_CALLBACK_E_MODIFIER; + return PhpVersionFeature::PREG_REPLACE_CALLBACK_E_MODIFIER; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('The /e modifier is no longer supported, use preg_replace_callback instead', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('The /e modifier is no longer supported, use preg_replace_callback instead', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -78,12 +78,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'preg_replace')) { return null; @@ -95,17 +95,17 @@ CODE_SAMPLE $firstArgument = $node->args[0]; $firstArgumentValue = $firstArgument->value; $patternWithoutE = $this->regexMatcher->resolvePatternExpressionWithoutEIfFound($firstArgumentValue); - if (!$patternWithoutE instanceof \PhpParser\Node\Expr) { + if (!$patternWithoutE instanceof Expr) { return null; } /** @var Arg $secondArgument */ $secondArgument = $node->args[1]; $secondArgumentValue = $secondArgument->value; $anonymousFunction = $this->anonymousFunctionFactory->createAnonymousFunctionFromString($secondArgumentValue); - if (!$anonymousFunction instanceof \PhpParser\Node\Expr\Closure) { + if (!$anonymousFunction instanceof Closure) { return null; } - $node->name = new \PhpParser\Node\Name('preg_replace_callback'); + $node->name = new Name('preg_replace_callback'); $firstArgument->value = $patternWithoutE; $secondArgument->value = $anonymousFunction; return $node; diff --git a/rules/Php55/Rector/String_/StringClassNameToClassConstantRector.php b/rules/Php55/Rector/String_/StringClassNameToClassConstantRector.php index bc628253bfa..8815c506054 100644 --- a/rules/Php55/Rector/String_/StringClassNameToClassConstantRector.php +++ b/rules/Php55/Rector/String_/StringClassNameToClassConstantRector.php @@ -16,15 +16,15 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; use RectorPrefix20220607\Symplify\PackageBuilder\Reflection\ClassLikeExistenceChecker; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @changelog https://wiki.php.net/rfc/class_name_scalars https://github.com/symfony/symfony/blob/2.8/UPGRADE-2.8.md#form * * @see \Rector\Tests\Php55\Rector\String_\StringClassNameToClassConstantRector\StringClassNameToClassConstantRectorTest */ -final class StringClassNameToClassConstantRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface, \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class StringClassNameToClassConstantRector extends AbstractRector implements AllowEmptyConfigurableRectorInterface, MinPhpVersionInterface { /** * @var string[] @@ -39,13 +39,13 @@ final class StringClassNameToClassConstantRector extends \Rector\Core\Rector\Abs * @var \Symplify\PackageBuilder\Reflection\ClassLikeExistenceChecker */ private $classLikeExistenceChecker; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Reflection\ClassLikeExistenceChecker $classLikeExistenceChecker) + public function __construct(ClassLikeExistenceChecker $classLikeExistenceChecker) { $this->classLikeExistenceChecker = $classLikeExistenceChecker; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace string class names by ::class constant', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace string class names by ::class constant', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class AnotherClass { } @@ -78,12 +78,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Scalar\String_::class]; + return [String_::class]; } /** * @param String_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $classLikeName = $node->value; // remove leading slash @@ -94,34 +94,34 @@ CODE_SAMPLE if ($this->shouldSkip($classLikeName, $node)) { return null; } - $fullyQualified = new \PhpParser\Node\Name\FullyQualified($classLikeName); - return new \PhpParser\Node\Expr\ClassConstFetch($fullyQualified, 'class'); + $fullyQualified = new FullyQualified($classLikeName); + return new ClassConstFetch($fullyQualified, 'class'); } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configuration); + Assert::allString($configuration); $this->classesToSkip = $configuration; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::CLASSNAME_CONSTANT; + return PhpVersionFeature::CLASSNAME_CONSTANT; } - private function isPartOfIsAFuncCall(\PhpParser\Node\Scalar\String_ $string) : bool + private function isPartOfIsAFuncCall(String_ $string) : bool { - $parent = $string->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\Arg) { + $parent = $string->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Arg) { return \false; } - $parentParent = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentParent instanceof \PhpParser\Node\Expr\FuncCall) { + $parentParent = $parent->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentParent instanceof FuncCall) { return \false; } return $this->nodeNameResolver->isName($parentParent, 'is_a'); } - private function shouldSkip(string $classLikeName, \PhpParser\Node\Scalar\String_ $string) : bool + private function shouldSkip(string $classLikeName, String_ $string) : bool { if (!$this->classLikeExistenceChecker->doesClassLikeInsensitiveExists($classLikeName)) { return \true; @@ -135,7 +135,7 @@ CODE_SAMPLE return \true; } // allow class strings to be part of class const arrays, as probably on purpose - $parentClassConst = $this->betterNodeFinder->findParentType($string, \PhpParser\Node\Stmt\ClassConst::class); - return $parentClassConst instanceof \PhpParser\Node\Stmt\ClassConst; + $parentClassConst = $this->betterNodeFinder->findParentType($string, ClassConst::class); + return $parentClassConst instanceof ClassConst; } } diff --git a/rules/Php55/RegexMatcher.php b/rules/Php55/RegexMatcher.php index 09550d5514c..76b153b9ce7 100644 --- a/rules/Php55/RegexMatcher.php +++ b/rules/Php55/RegexMatcher.php @@ -25,43 +25,43 @@ final class RegexMatcher * @var \Rector\Core\PhpParser\Node\Value\ValueResolver */ private $valueResolver; - public function __construct(\Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver) + public function __construct(ValueResolver $valueResolver) { $this->valueResolver = $valueResolver; } - public function resolvePatternExpressionWithoutEIfFound(\PhpParser\Node\Expr $expr) : ?\PhpParser\Node\Expr + public function resolvePatternExpressionWithoutEIfFound(Expr $expr) : ?Expr { - if ($expr instanceof \PhpParser\Node\Scalar\String_) { + if ($expr instanceof String_) { $pattern = $this->valueResolver->getValue($expr); if (!\is_string($pattern)) { return null; } $delimiter = $pattern[0]; /** @var string $modifiers */ - $modifiers = \RectorPrefix20220607\Nette\Utils\Strings::after($pattern, $delimiter, -1); + $modifiers = Strings::after($pattern, $delimiter, -1); if (\strpos($modifiers, 'e') === \false) { return null; } $patternWithoutE = $this->createPatternWithoutE($pattern, $delimiter, $modifiers); - return new \PhpParser\Node\Scalar\String_($patternWithoutE); + return new String_($patternWithoutE); } - if ($expr instanceof \PhpParser\Node\Expr\BinaryOp\Concat) { + if ($expr instanceof Concat) { return $this->matchConcat($expr); } return null; } private function createPatternWithoutE(string $pattern, string $delimiter, string $modifiers) : string { - $modifiersWithoutE = \RectorPrefix20220607\Nette\Utils\Strings::replace($modifiers, '#e#', ''); - return \RectorPrefix20220607\Nette\Utils\Strings::before($pattern, $delimiter, -1) . $delimiter . $modifiersWithoutE; + $modifiersWithoutE = Strings::replace($modifiers, '#e#', ''); + return Strings::before($pattern, $delimiter, -1) . $delimiter . $modifiersWithoutE; } - private function matchConcat(\PhpParser\Node\Expr\BinaryOp\Concat $concat) : ?\PhpParser\Node\Expr + private function matchConcat(Concat $concat) : ?Expr { $lastItem = $concat->right; - if (!$lastItem instanceof \PhpParser\Node\Scalar\String_) { + if (!$lastItem instanceof String_) { return null; } - $matches = \RectorPrefix20220607\Nette\Utils\Strings::match($lastItem->value, self::LETTER_SUFFIX_REGEX); + $matches = Strings::match($lastItem->value, self::LETTER_SUFFIX_REGEX); if (!isset($matches['modifiers'])) { return null; } @@ -69,7 +69,7 @@ final class RegexMatcher return null; } // replace last "e" in the code - $lastItem->value = \RectorPrefix20220607\Nette\Utils\Strings::replace($lastItem->value, self::LAST_E_REGEX, '$1$2'); + $lastItem->value = Strings::replace($lastItem->value, self::LAST_E_REGEX, '$1$2'); return $concat; } } diff --git a/rules/Php56/NodeAnalyzer/UndefinedVariableResolver.php b/rules/Php56/NodeAnalyzer/UndefinedVariableResolver.php index 5b950bd1ca6..9ad975e29c5 100644 --- a/rules/Php56/NodeAnalyzer/UndefinedVariableResolver.php +++ b/rules/Php56/NodeAnalyzer/UndefinedVariableResolver.php @@ -58,7 +58,7 @@ final class UndefinedVariableResolver * @var \Rector\Core\NodeAnalyzer\VariableAnalyzer */ private $variableAnalyzer; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\NodeAnalyzer\VariableAnalyzer $variableAnalyzer) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver, NodeComparator $nodeComparator, BetterNodeFinder $betterNodeFinder, VariableAnalyzer $variableAnalyzer) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->nodeNameResolver = $nodeNameResolver; @@ -73,20 +73,20 @@ final class UndefinedVariableResolver public function resolve($node) : array { $undefinedVariables = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $node->stmts, function (\PhpParser\Node $node) use(&$undefinedVariables) : ?int { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $node->stmts, function (Node $node) use(&$undefinedVariables) : ?int { // entering new scope - break! - if ($node instanceof \PhpParser\Node\FunctionLike && !$node instanceof \PhpParser\Node\Expr\ArrowFunction) { - return \PhpParser\NodeTraverser::STOP_TRAVERSAL; + if ($node instanceof FunctionLike && !$node instanceof ArrowFunction) { + return NodeTraverser::STOP_TRAVERSAL; } - if ($node instanceof \PhpParser\Node\Stmt\Foreach_) { + if ($node instanceof Foreach_) { // handled above - return \PhpParser\NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; + return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; } - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + if (!$node instanceof Variable) { return null; } - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node) { + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof Node) { return null; } if ($this->shouldSkipVariable($node, $parentNode)) { @@ -98,7 +98,7 @@ final class UndefinedVariableResolver } // defined 100 % /** @var Scope $scope */ - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $node->getAttribute(AttributeKey::SCOPE); if ($scope->hasVariableType($variableName)->yes()) { return null; } @@ -107,25 +107,25 @@ final class UndefinedVariableResolver }); return \array_unique($undefinedVariables); } - private function issetOrUnsetOrEmptyParent(\PhpParser\Node $parentNode) : bool + private function issetOrUnsetOrEmptyParent(Node $parentNode) : bool { - return \in_array(\get_class($parentNode), [\PhpParser\Node\Stmt\Unset_::class, \PhpParser\Node\Expr\Cast\Unset_::class, \PhpParser\Node\Expr\Isset_::class, \PhpParser\Node\Expr\Empty_::class], \true); + return \in_array(\get_class($parentNode), [Unset_::class, UnsetCast::class, Isset_::class, Empty_::class], \true); } - private function isAsCoalesceLeftOrAssignOpCoalesceVar(\PhpParser\Node $parentNode, \PhpParser\Node\Expr\Variable $variable) : bool + private function isAsCoalesceLeftOrAssignOpCoalesceVar(Node $parentNode, Variable $variable) : bool { - if ($parentNode instanceof \PhpParser\Node\Expr\BinaryOp\Coalesce && $parentNode->left === $variable) { + if ($parentNode instanceof Coalesce && $parentNode->left === $variable) { return \true; } - if (!$parentNode instanceof \PhpParser\Node\Expr\AssignOp\Coalesce) { + if (!$parentNode instanceof AssignOpCoalesce) { return \false; } return $parentNode->var === $variable; } - private function isAssign(\PhpParser\Node $parentNode) : bool + private function isAssign(Node $parentNode) : bool { - return \in_array(\get_class($parentNode), [\PhpParser\Node\Expr\Assign::class, \PhpParser\Node\Expr\AssignRef::class], \true); + return \in_array(\get_class($parentNode), [Assign::class, AssignRef::class], \true); } - private function shouldSkipVariable(\PhpParser\Node\Expr\Variable $variable, \PhpParser\Node $parentNode) : bool + private function shouldSkipVariable(Variable $variable, Node $parentNode) : bool { if ($this->variableAnalyzer->isStaticOrGlobal($variable)) { return \true; @@ -162,30 +162,30 @@ final class UndefinedVariableResolver } return $this->isAfterSwitchCaseWithParentCase($variable); } - private function isAfterSwitchCaseWithParentCase(\PhpParser\Node\Expr\Variable $variable) : bool + private function isAfterSwitchCaseWithParentCase(Variable $variable) : bool { - $previousSwitch = $this->betterNodeFinder->findFirstPrevious($variable, function (\PhpParser\Node $subNode) : bool { - return $subNode instanceof \PhpParser\Node\Stmt\Switch_; + $previousSwitch = $this->betterNodeFinder->findFirstPrevious($variable, function (Node $subNode) : bool { + return $subNode instanceof Switch_; }); - if (!$previousSwitch instanceof \PhpParser\Node\Stmt\Switch_) { + if (!$previousSwitch instanceof Switch_) { return \false; } - $parentSwitch = $previousSwitch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - return $parentSwitch instanceof \PhpParser\Node\Stmt\Case_; + $parentSwitch = $previousSwitch->getAttribute(AttributeKey::PARENT_NODE); + return $parentSwitch instanceof Case_; } - private function isDifferentWithOriginalNodeOrNoScope(\PhpParser\Node\Expr\Variable $variable) : bool + private function isDifferentWithOriginalNodeOrNoScope(Variable $variable) : bool { - $originalNode = $variable->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE); + $originalNode = $variable->getAttribute(AttributeKey::ORIGINAL_NODE); if (!$this->nodeComparator->areNodesEqual($variable, $originalNode)) { return \true; } - $nodeScope = $variable->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - return !$nodeScope instanceof \PHPStan\Analyser\Scope; + $nodeScope = $variable->getAttribute(AttributeKey::SCOPE); + return !$nodeScope instanceof Scope; } - private function hasPreviousCheckedWithIsset(\PhpParser\Node\Expr\Variable $variable) : bool + private function hasPreviousCheckedWithIsset(Variable $variable) : bool { - return (bool) $this->betterNodeFinder->findFirstPrevious($variable, function (\PhpParser\Node $subNode) use($variable) : bool { - if (!$subNode instanceof \PhpParser\Node\Expr\Isset_) { + return (bool) $this->betterNodeFinder->findFirstPrevious($variable, function (Node $subNode) use($variable) : bool { + if (!$subNode instanceof Isset_) { return \false; } $vars = $subNode->vars; @@ -197,22 +197,22 @@ final class UndefinedVariableResolver return \false; }); } - private function hasPreviousCheckedWithEmpty(\PhpParser\Node\Expr\Variable $variable) : bool + private function hasPreviousCheckedWithEmpty(Variable $variable) : bool { - return (bool) $this->betterNodeFinder->findFirstPrevious($variable, function (\PhpParser\Node $subNode) use($variable) : bool { - if (!$subNode instanceof \PhpParser\Node\Expr\Empty_) { + return (bool) $this->betterNodeFinder->findFirstPrevious($variable, function (Node $subNode) use($variable) : bool { + if (!$subNode instanceof Empty_) { return \false; } $subNodeExpr = $subNode->expr; return $this->nodeComparator->areNodesEqual($subNodeExpr, $variable); }); } - private function isListAssign(\PhpParser\Node $node) : bool + private function isListAssign(Node $node) : bool { - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentNode instanceof \PhpParser\Node\Expr\List_) { + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); + if ($parentNode instanceof List_) { return \true; } - return $parentNode instanceof \PhpParser\Node\Expr\Array_; + return $parentNode instanceof Array_; } } diff --git a/rules/Php56/Rector/FuncCall/PowToExpRector.php b/rules/Php56/Rector/FuncCall/PowToExpRector.php index 408a2fa6673..f3dec281f32 100644 --- a/rules/Php56/Rector/FuncCall/PowToExpRector.php +++ b/rules/Php56/Rector/FuncCall/PowToExpRector.php @@ -11,37 +11,37 @@ use Rector\Core\NodeAnalyzer\ArgsAnalyzer; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php56\Rector\FuncCall\PowToExpRector\PowToExpRectorTest */ -final class PowToExpRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class PowToExpRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(ArgsAnalyzer $argsAnalyzer) { $this->argsAnalyzer = $argsAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes pow(val, val2) to ** (exp) parameter', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('pow(1, 2);', '1**2;')]); + return new RuleDefinition('Changes pow(val, val2) to ** (exp) parameter', [new CodeSample('pow(1, 2);', '1**2;')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'pow')) { return null; @@ -56,10 +56,10 @@ final class PowToExpRector extends \Rector\Core\Rector\AbstractRector implements $firstArgument = $node->args[0]; /** @var Arg $secondArgument */ $secondArgument = $node->args[1]; - return new \PhpParser\Node\Expr\BinaryOp\Pow($firstArgument->value, $secondArgument->value); + return new Pow($firstArgument->value, $secondArgument->value); } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::EXP_OPERATOR; + return PhpVersionFeature::EXP_OPERATOR; } } diff --git a/rules/Php56/Rector/FunctionLike/AddDefaultValueForUndefinedVariableRector.php b/rules/Php56/Rector/FunctionLike/AddDefaultValueForUndefinedVariableRector.php index ea37e6b33eb..b8f7e6e435d 100644 --- a/rules/Php56/Rector/FunctionLike/AddDefaultValueForUndefinedVariableRector.php +++ b/rules/Php56/Rector/FunctionLike/AddDefaultValueForUndefinedVariableRector.php @@ -18,15 +18,15 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Php56\NodeAnalyzer\UndefinedVariableResolver; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/vimeo/psalm/blob/29b70442b11e3e66113935a2ee22e165a70c74a4/docs/fixing_code.md#possiblyundefinedvariable * @changelog https://3v4l.org/MZFel * * @see \Rector\Tests\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector\AddDefaultValueForUndefinedVariableRectorTest */ -final class AddDefaultValueForUndefinedVariableRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class AddDefaultValueForUndefinedVariableRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -38,18 +38,18 @@ final class AddDefaultValueForUndefinedVariableRector extends \Rector\Core\Recto * @var \Rector\Core\NodeAnalyzer\InlineHTMLAnalyzer */ private $inlineHTMLAnalyzer; - public function __construct(\Rector\Php56\NodeAnalyzer\UndefinedVariableResolver $undefinedVariableResolver, \Rector\Core\NodeAnalyzer\InlineHTMLAnalyzer $inlineHTMLAnalyzer) + public function __construct(UndefinedVariableResolver $undefinedVariableResolver, InlineHTMLAnalyzer $inlineHTMLAnalyzer) { $this->undefinedVariableResolver = $undefinedVariableResolver; $this->inlineHTMLAnalyzer = $inlineHTMLAnalyzer; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::REQUIRE_DEFAULT_VALUE; + return PhpVersionFeature::REQUIRE_DEFAULT_VALUE; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Adds default value for undefined variable', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Adds default value for undefined variable', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -81,12 +81,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\Closure::class]; + return [ClassMethod::class, Function_::class, Closure::class]; } /** * @param ClassMethod|Function_|Closure $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->inlineHTMLAnalyzer->hasInlineHTML($node)) { return null; @@ -97,9 +97,9 @@ CODE_SAMPLE } $variablesInitiation = []; foreach ($undefinedVariableNames as $undefinedVariableName) { - $value = $this->isArray($undefinedVariableName, (array) $node->stmts) ? new \PhpParser\Node\Expr\Array_([]) : $this->nodeFactory->createNull(); - $assign = new \PhpParser\Node\Expr\Assign(new \PhpParser\Node\Expr\Variable($undefinedVariableName), $value); - $variablesInitiation[] = new \PhpParser\Node\Stmt\Expression($assign); + $value = $this->isArray($undefinedVariableName, (array) $node->stmts) ? new Array_([]) : $this->nodeFactory->createNull(); + $assign = new Assign(new Variable($undefinedVariableName), $value); + $variablesInitiation[] = new Expression($assign); } $node->stmts = \array_merge($variablesInitiation, (array) $node->stmts); return $node; @@ -109,8 +109,8 @@ CODE_SAMPLE */ private function isArray(string $undefinedVariable, array $stmts) : bool { - return (bool) $this->betterNodeFinder->findFirst($stmts, function (\PhpParser\Node $node) use($undefinedVariable) : bool { - if (!$node instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + return (bool) $this->betterNodeFinder->findFirst($stmts, function (Node $node) use($undefinedVariable) : bool { + if (!$node instanceof ArrayDimFetch) { return \false; } return $this->isName($node->var, $undefinedVariable); diff --git a/rules/Php70/EregToPcreTransformer.php b/rules/Php70/EregToPcreTransformer.php index 3215ea69f66..08e1fefb13d 100644 --- a/rules/Php70/EregToPcreTransformer.php +++ b/rules/Php70/EregToPcreTransformer.php @@ -88,7 +88,7 @@ final class EregToPcreTransformer } [$r, $i] = $this->_ere2pcre($content, 0); if ($i !== \strlen($content)) { - throw new \Rector\Php70\Exception\InvalidEregException('unescaped metacharacter ")"'); + throw new InvalidEregException('unescaped metacharacter ")"'); } if ($ignorecase) { return $this->icache[$content] = '#' . $r . '#mi'; @@ -119,24 +119,24 @@ final class EregToPcreTransformer ++$i; } if ($i >= $l) { - throw new \Rector\Php70\Exception\InvalidEregException('"[" does not have a matching "]"'); + throw new InvalidEregException('"[" does not have a matching "]"'); } $start = \true; $i = (int) $i; [$cls, $i] = $this->processSquareBracket($content, $i, $l, $cls, $start); if ($i >= $l) { - throw new \Rector\Php70\Exception\InvalidEregException('"[" does not have a matching "]"'); + throw new InvalidEregException('"[" does not have a matching "]"'); } $r[$rr] .= '[' . $cls . ']'; } elseif ($char === ')') { break; } elseif ($char === '*' || $char === '+' || $char === '?') { - throw new \Rector\Php70\Exception\InvalidEregException('unescaped metacharacter "' . $char . '"'); + throw new InvalidEregException('unescaped metacharacter "' . $char . '"'); } elseif ($char === '{') { if ($i + 1 < $l && \strpos('0123456789', $content[$i + 1]) !== \false) { $r[$rr] .= '\\{'; } else { - throw new \Rector\Php70\Exception\InvalidEregException('unescaped metacharacter "' . $char . '"'); + throw new InvalidEregException('unescaped metacharacter "' . $char . '"'); } } elseif ($char === '.') { $r[$rr] .= $char; @@ -146,7 +146,7 @@ final class EregToPcreTransformer continue; } elseif ($char === '|') { if ($r[$rr] === '') { - throw new \Rector\Php70\Exception\InvalidEregException('empty branch'); + throw new InvalidEregException('empty branch'); } $r[] = ''; ++$rr; @@ -154,7 +154,7 @@ final class EregToPcreTransformer continue; } elseif ($char === '\\') { if (++$i >= $l) { - throw new \Rector\Php70\Exception\InvalidEregException('an invalid escape sequence at the end'); + throw new InvalidEregException('an invalid escape sequence at the end'); } $r[$rr] .= $this->_ere2pcre_escape($content[$i]); } else { @@ -176,7 +176,7 @@ final class EregToPcreTransformer } } if ($r[$rr] === '') { - throw new \Rector\Php70\Exception\InvalidEregException('empty regular expression or branch'); + throw new InvalidEregException('empty regular expression or branch'); } return [\implode('|', $r), $i]; } @@ -193,7 +193,7 @@ final class EregToPcreTransformer $position = $i + 1; [$t, $ii] = $this->_ere2pcre($content, $position); if ($ii >= $l || $content[$ii] !== ')') { - throw new \Rector\Php70\Exception\InvalidEregException('"(" does not have a matching ")"'); + throw new InvalidEregException('"(" does not have a matching ")"'); } $r[$rr] .= '(' . $t . ')'; $i = $ii; @@ -215,7 +215,7 @@ final class EregToPcreTransformer $a = $s[$i]; ++$i; if ($a === '-' && !$start && !($i < $l && $s[$i] === ']')) { - throw new \Rector\Php70\Exception\InvalidEregException('"-" is invalid for the start character in the brackets'); + throw new InvalidEregException('"-" is invalid for the start character in the brackets'); } if ($i < $l && $s[$i] === '-') { $b = $s[++$i]; @@ -225,7 +225,7 @@ final class EregToPcreTransformer break; } elseif (\ord($a) > \ord($b)) { $errorMessage = \sprintf('an invalid character range %d-%d"', (int) $a, (int) $b); - throw new \Rector\Php70\Exception\InvalidEregException($errorMessage); + throw new InvalidEregException($errorMessage); } $cls .= $this->_ere2pcre_escape($a) . '-' . $this->_ere2pcre_escape($b); } else { @@ -238,8 +238,8 @@ final class EregToPcreTransformer } private function _ere2pcre_escape(string $content) : string { - if ($content === "\0") { - throw new \Rector\Php70\Exception\InvalidEregException('a literal null byte in the regex'); + if ($content === "\x00") { + throw new InvalidEregException('a literal null byte in the regex'); } if (\strpos('\\^$.[]|()?*+{}-/', $content) !== \false) { return '\\' . $content; @@ -253,18 +253,18 @@ final class EregToPcreTransformer { $ii = \strpos($s, '}', $i); if ($ii === \false) { - throw new \Rector\Php70\Exception\InvalidEregException('"{" does not have a matching "}"'); + throw new InvalidEregException('"{" does not have a matching "}"'); } $start = $i + 1; $length = $ii - ($i + 1); - $bound = \RectorPrefix20220607\Nette\Utils\Strings::substring($s, $start, $length); - $matches = \RectorPrefix20220607\Nette\Utils\Strings::match($bound, self::BOUND_REGEX); + $bound = Strings::substring($s, $start, $length); + $matches = Strings::match($bound, self::BOUND_REGEX); if ($matches === null) { - throw new \Rector\Php70\Exception\InvalidEregException('an invalid bound'); + throw new InvalidEregException('an invalid bound'); } if (isset($matches[self::MAXIMAL_NUMBER_PART])) { if ($matches[self::MINIMAL_NUMBER_PART] > $matches[self::MAXIMAL_NUMBER_PART]) { - throw new \Rector\Php70\Exception\InvalidEregException('an invalid bound'); + throw new InvalidEregException('an invalid bound'); } $r[$rr] .= '{' . $matches[self::MINIMAL_NUMBER_PART] . ',' . $matches[self::MAXIMAL_NUMBER_PART] . '}'; } elseif (isset($matches['comma'])) { @@ -282,13 +282,13 @@ final class EregToPcreTransformer $offset = $i; $ii = \strpos($content, ']', $offset); if ($ii === \false) { - throw new \Rector\Php70\Exception\InvalidEregException('"[" does not have a matching "]"'); + throw new InvalidEregException('"[" does not have a matching "]"'); } $start = $i + 1; $length = $ii - ($i + 1); - $ccls = \RectorPrefix20220607\Nette\Utils\Strings::substring($content, $start, $length); + $ccls = Strings::substring($content, $start, $length); if (!isset(self::CHARACTER_CLASS_MAP[$ccls])) { - throw new \Rector\Php70\Exception\InvalidEregException('an invalid or unsupported character class [' . $ccls . ']'); + throw new InvalidEregException('an invalid or unsupported character class [' . $ccls . ']'); } $cls .= self::CHARACTER_CLASS_MAP[$ccls]; $i = $ii + 1; diff --git a/rules/Php70/Exception/InvalidEregException.php b/rules/Php70/Exception/InvalidEregException.php index c1ef21e8764..5d7e16a9774 100644 --- a/rules/Php70/Exception/InvalidEregException.php +++ b/rules/Php70/Exception/InvalidEregException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace Rector\Php70\Exception; use Exception; -final class InvalidEregException extends \Exception +final class InvalidEregException extends Exception { } diff --git a/rules/Php70/NodeAnalyzer/Php4ConstructorClassMethodAnalyzer.php b/rules/Php70/NodeAnalyzer/Php4ConstructorClassMethodAnalyzer.php index 33c021f8f14..85ece7ba551 100644 --- a/rules/Php70/NodeAnalyzer/Php4ConstructorClassMethodAnalyzer.php +++ b/rules/Php70/NodeAnalyzer/Php4ConstructorClassMethodAnalyzer.php @@ -8,7 +8,7 @@ use PHPStan\Analyser\Scope; use PHPStan\Reflection\ClassReflection; final class Php4ConstructorClassMethodAnalyzer { - public function detect(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PHPStan\Analyser\Scope $scope) : bool + public function detect(ClassMethod $classMethod, Scope $scope) : bool { // catch only classes without namespace if ($scope->getNamespace() !== null) { @@ -21,7 +21,7 @@ final class Php4ConstructorClassMethodAnalyzer return \false; } $classReflection = $scope->getClassReflection(); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } return !$classReflection->isAnonymous(); diff --git a/rules/Php70/Rector/Assign/ListSplitStringRector.php b/rules/Php70/Rector/Assign/ListSplitStringRector.php index 865d9ee29dc..c7083b81362 100644 --- a/rules/Php70/Rector/Assign/ListSplitStringRector.php +++ b/rules/Php70/Rector/Assign/ListSplitStringRector.php @@ -10,41 +10,41 @@ use PHPStan\Type\StringType; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog http://php.net/manual/en/migration70.incompatible.php#migration70.incompatible.variable-handling.list * * @changelog https://stackoverflow.com/a/47965344/1348344 * @see \Rector\Tests\Php70\Rector\Assign\ListSplitStringRector\ListSplitStringRectorTest */ -final class ListSplitStringRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ListSplitStringRector extends AbstractRector implements MinPhpVersionInterface { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('list() cannot split string directly anymore, use str_split()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('list($foo) = "string";', 'list($foo) = str_split("string");')]); + return new RuleDefinition('list() cannot split string directly anymore, use str_split()', [new CodeSample('list($foo) = "string";', 'list($foo) = str_split("string");')]); } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NO_LIST_SPLIT_STRING; + return PhpVersionFeature::NO_LIST_SPLIT_STRING; } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Assign::class]; + return [Assign::class]; } /** * @param Assign $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->var instanceof \PhpParser\Node\Expr\List_) { + if (!$node->var instanceof List_) { return null; } $exprType = $this->getType($node->expr); - if (!$exprType instanceof \PHPStan\Type\StringType) { + if (!$exprType instanceof StringType) { return null; } $node->expr = $this->nodeFactory->createFuncCall('str_split', [$node->expr]); diff --git a/rules/Php70/Rector/Assign/ListSwapArrayOrderRector.php b/rules/Php70/Rector/Assign/ListSwapArrayOrderRector.php index 32525ef5551..e63ab3799ee 100644 --- a/rules/Php70/Rector/Assign/ListSwapArrayOrderRector.php +++ b/rules/Php70/Rector/Assign/ListSwapArrayOrderRector.php @@ -13,38 +13,38 @@ use Rector\Core\Contract\PhpParser\NodePrinterInterface; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog http://php.net/manual/en/migration70.incompatible.php#migration70.incompatible.variable-handling.list * @see \Rector\Tests\Php70\Rector\Assign\ListSwapArrayOrderRector\ListSwapArrayOrderRectorTest */ -final class ListSwapArrayOrderRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ListSwapArrayOrderRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\Core\Contract\PhpParser\NodePrinterInterface */ private $nodePrinter; - public function __construct(\Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter) + public function __construct(NodePrinterInterface $nodePrinter) { $this->nodePrinter = $nodePrinter; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('list() assigns variables in reverse order - relevant in array assign', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('list($a[], $a[]) = [1, 2];', 'list($a[], $a[]) = array_reverse([1, 2]);')]); + return new RuleDefinition('list() assigns variables in reverse order - relevant in array assign', [new CodeSample('list($a[], $a[]) = [1, 2];', 'list($a[], $a[]) = array_reverse([1, 2]);')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Assign::class]; + return [Assign::class]; } /** * @param Assign $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkipAssign($node)) { return null; @@ -53,10 +53,10 @@ final class ListSwapArrayOrderRector extends \Rector\Core\Rector\AbstractRector $list = $node->var; $printedVariables = []; foreach ($list->items as $arrayItem) { - if (!$arrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$arrayItem instanceof ArrayItem) { continue; } - if ($arrayItem->value instanceof \PhpParser\Node\Expr\ArrayDimFetch && $arrayItem->value->dim === null) { + if ($arrayItem->value instanceof ArrayDimFetch && $arrayItem->value->dim === null) { $printedVariables[] = $this->nodePrinter->print($arrayItem->value->var); } else { return null; @@ -73,14 +73,14 @@ final class ListSwapArrayOrderRector extends \Rector\Core\Rector\AbstractRector } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::LIST_SWAP_ORDER; + return PhpVersionFeature::LIST_SWAP_ORDER; } - private function shouldSkipAssign(\PhpParser\Node\Expr\Assign $assign) : bool + private function shouldSkipAssign(Assign $assign) : bool { - if (!$assign->var instanceof \PhpParser\Node\Expr\List_) { + if (!$assign->var instanceof List_) { return \true; } // already converted - return $assign->expr instanceof \PhpParser\Node\Expr\FuncCall && $this->isName($assign->expr, 'array_reverse'); + return $assign->expr instanceof FuncCall && $this->isName($assign->expr, 'array_reverse'); } } diff --git a/rules/Php70/Rector/Break_/BreakNotInLoopOrSwitchToReturnRector.php b/rules/Php70/Rector/Break_/BreakNotInLoopOrSwitchToReturnRector.php index 43459b68a55..cbf47501048 100644 --- a/rules/Php70/Rector/Break_/BreakNotInLoopOrSwitchToReturnRector.php +++ b/rules/Php70/Rector/Break_/BreakNotInLoopOrSwitchToReturnRector.php @@ -10,32 +10,32 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeNestingScope\ContextAnalyzer; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://stackoverflow.com/questions/3618030/php-fatal-error-cannot-break-continue https://stackoverflow.com/questions/11988281/why-does-cannot-break-continue-1-level-comes-in-php * * @changelog https://3v4l.org/Qtelt * @see \Rector\Tests\Php70\Rector\Break_\BreakNotInLoopOrSwitchToReturnRector\BreakNotInLoopOrSwitchToReturnRectorTest */ -final class BreakNotInLoopOrSwitchToReturnRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class BreakNotInLoopOrSwitchToReturnRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\NodeNestingScope\ContextAnalyzer */ private $contextAnalyzer; - public function __construct(\Rector\NodeNestingScope\ContextAnalyzer $contextAnalyzer) + public function __construct(ContextAnalyzer $contextAnalyzer) { $this->contextAnalyzer = $contextAnalyzer; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NO_BREAK_OUTSIDE_LOOP; + return PhpVersionFeature::NO_BREAK_OUTSIDE_LOOP; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Convert break outside for/foreach/switch context to return', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Convert break outside for/foreach/switch context to return', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -68,12 +68,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Break_::class]; + return [Break_::class]; } /** * @param Break_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->contextAnalyzer->isInLoop($node)) { return null; @@ -82,7 +82,7 @@ CODE_SAMPLE return null; } if ($this->contextAnalyzer->isInIf($node)) { - return new \PhpParser\Node\Stmt\Return_(); + return new Return_(); } $this->removeNode($node); return $node; diff --git a/rules/Php70/Rector/ClassMethod/Php4ConstructorRector.php b/rules/Php70/Rector/ClassMethod/Php4ConstructorRector.php index f2a14b1877e..143a4ad3012 100644 --- a/rules/Php70/Rector/ClassMethod/Php4ConstructorRector.php +++ b/rules/Php70/Rector/ClassMethod/Php4ConstructorRector.php @@ -21,13 +21,13 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver; use Rector\Php70\NodeAnalyzer\Php4ConstructorClassMethodAnalyzer; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/remove_php4_constructors * @see \Rector\Tests\Php70\Rector\ClassMethod\Php4ConstructorRector\Php4ConstructorRectorTest */ -final class Php4ConstructorRector extends \Rector\Core\Rector\AbstractScopeAwareRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class Php4ConstructorRector extends AbstractScopeAwareRector implements MinPhpVersionInterface { /** * @readonly @@ -39,18 +39,18 @@ final class Php4ConstructorRector extends \Rector\Core\Rector\AbstractScopeAware * @var \Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver */ private $parentClassScopeResolver; - public function __construct(\Rector\Php70\NodeAnalyzer\Php4ConstructorClassMethodAnalyzer $php4ConstructorClassMethodAnalyzer, \Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver $parentClassScopeResolver) + public function __construct(Php4ConstructorClassMethodAnalyzer $php4ConstructorClassMethodAnalyzer, ParentClassScopeResolver $parentClassScopeResolver) { $this->php4ConstructorClassMethodAnalyzer = $php4ConstructorClassMethodAnalyzer; $this->parentClassScopeResolver = $parentClassScopeResolver; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NO_PHP4_CONSTRUCTOR; + return PhpVersionFeature::NO_PHP4_CONSTRUCTOR; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes PHP 4 style constructor to __construct.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes PHP 4 style constructor to __construct.', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function SomeClass() @@ -73,18 +73,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactorWithScope(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : ?\PhpParser\Node + public function refactorWithScope(Node $node, Scope $scope) : ?Node { if (!$this->php4ConstructorClassMethodAnalyzer->detect($node, $scope)) { return null; } - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLike = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$classLike instanceof Class_) { return null; } // process parent call references first @@ -93,10 +93,10 @@ CODE_SAMPLE if (!$this->nodeNameResolver->areNamesEqual($classLike, $node)) { return null; } - $classMethod = $classLike->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); + $classMethod = $classLike->getMethod(MethodName::CONSTRUCT); // does it already have a __construct method? - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { - $node->name = new \PhpParser\Node\Identifier(\Rector\Core\ValueObject\MethodName::CONSTRUCT); + if (!$classMethod instanceof ClassMethod) { + $node->name = new Identifier(MethodName::CONSTRUCT); } $stmts = $node->stmts; if ($stmts === null) { @@ -105,64 +105,64 @@ CODE_SAMPLE if (\count($stmts) === 1) { /** @var Expression|Expr $stmt */ $stmt = $stmts[0]; - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { return null; } - if ($this->isLocalMethodCallNamed($stmt->expr, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if ($this->isLocalMethodCallNamed($stmt->expr, MethodName::CONSTRUCT)) { $this->removeNode($node); return null; } } return $node; } - private function processClassMethodStatementsForParentConstructorCalls(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PHPStan\Analyser\Scope $scope) : void + private function processClassMethodStatementsForParentConstructorCalls(ClassMethod $classMethod, Scope $scope) : void { if (!\is_iterable($classMethod->stmts)) { return; } foreach ($classMethod->stmts as $methodStmt) { - if (!$methodStmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$methodStmt instanceof Expression) { continue; } $methodStmt = $methodStmt->expr; - if (!$methodStmt instanceof \PhpParser\Node\Expr\StaticCall) { + if (!$methodStmt instanceof StaticCall) { continue; } $this->processParentPhp4ConstructCall($methodStmt, $scope); } } - private function processParentPhp4ConstructCall(\PhpParser\Node\Expr\StaticCall $staticCall, \PHPStan\Analyser\Scope $scope) : void + private function processParentPhp4ConstructCall(StaticCall $staticCall, Scope $scope) : void { $parentClassReflection = $this->parentClassScopeResolver->resolveParentClassReflection($scope); // no parent class - if (!$parentClassReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$parentClassReflection instanceof ClassReflection) { return; } - if (!$staticCall->class instanceof \PhpParser\Node\Name) { + if (!$staticCall->class instanceof Name) { return; } // rename ParentClass if ($this->isName($staticCall->class, $parentClassReflection->getName())) { - $staticCall->class = new \PhpParser\Node\Name(\Rector\Core\Enum\ObjectReference::PARENT); + $staticCall->class = new Name(ObjectReference::PARENT); } - if (!$this->isName($staticCall->class, \Rector\Core\Enum\ObjectReference::PARENT)) { + if (!$this->isName($staticCall->class, ObjectReference::PARENT)) { return; } // it's not a parent PHP 4 constructor call if (!$this->isName($staticCall->name, $parentClassReflection->getName())) { return; } - $staticCall->name = new \PhpParser\Node\Identifier(\Rector\Core\ValueObject\MethodName::CONSTRUCT); + $staticCall->name = new Identifier(MethodName::CONSTRUCT); } - private function isLocalMethodCallNamed(\PhpParser\Node\Expr $expr, string $name) : bool + private function isLocalMethodCallNamed(Expr $expr, string $name) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$expr instanceof MethodCall) { return \false; } - if ($expr->var instanceof \PhpParser\Node\Expr\StaticCall) { + if ($expr->var instanceof StaticCall) { return \false; } - if ($expr->var instanceof \PhpParser\Node\Expr\MethodCall) { + if ($expr->var instanceof MethodCall) { return \false; } if (!$this->isName($expr->var, 'this')) { diff --git a/rules/Php70/Rector/FuncCall/CallUserMethodRector.php b/rules/Php70/Rector/FuncCall/CallUserMethodRector.php index 3c45ea21a5b..e3d15685824 100644 --- a/rules/Php70/Rector/FuncCall/CallUserMethodRector.php +++ b/rules/Php70/Rector/FuncCall/CallUserMethodRector.php @@ -9,12 +9,12 @@ use PhpParser\Node\Name; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php70\Rector\FuncCall\CallUserMethodRector\CallUserMethodRectorTest */ -final class CallUserMethodRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class CallUserMethodRector extends AbstractRector implements MinPhpVersionInterface { /** * @var array @@ -22,30 +22,30 @@ final class CallUserMethodRector extends \Rector\Core\Rector\AbstractRector impl private const OLD_TO_NEW_FUNCTIONS = ['call_user_method' => 'call_user_func', 'call_user_method_array' => 'call_user_func_array']; public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NO_CALL_USER_METHOD; + return PhpVersionFeature::NO_CALL_USER_METHOD; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes call_user_method()/call_user_method_array() to call_user_func()/call_user_func_array()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('call_user_method($method, $obj, "arg1", "arg2");', 'call_user_func(array(&$obj, "method"), "arg1", "arg2");')]); + return new RuleDefinition('Changes call_user_method()/call_user_method_array() to call_user_func()/call_user_func_array()', [new CodeSample('call_user_method($method, $obj, "arg1", "arg2");', 'call_user_func(array(&$obj, "method"), "arg1", "arg2");')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $oldFunctionNames = \array_keys(self::OLD_TO_NEW_FUNCTIONS); if (!$this->isNames($node, $oldFunctionNames)) { return null; } $newName = self::OLD_TO_NEW_FUNCTIONS[$this->getName($node)]; - $node->name = new \PhpParser\Node\Name($newName); + $node->name = new Name($newName); $oldArgs = $node->args; unset($node->args[1]); $newArgs = [$this->nodeFactory->createArg([$oldArgs[1]->value, $oldArgs[0]->value])]; diff --git a/rules/Php70/Rector/FuncCall/EregToPregMatchRector.php b/rules/Php70/Rector/FuncCall/EregToPregMatchRector.php index b9866eb57af..fcfbf821387 100644 --- a/rules/Php70/Rector/FuncCall/EregToPregMatchRector.php +++ b/rules/Php70/Rector/FuncCall/EregToPregMatchRector.php @@ -20,14 +20,14 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Php70\EregToPcreTransformer; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog http://php.net/reference.pcre.pattern.posix https://stackoverflow.com/a/17033826/1348344 https://docstore.mik.ua/orelly/webprog/pcook/ch13_02.htm * * @see \Rector\Tests\Php70\Rector\FuncCall\EregToPregMatchRector\EregToPregMatchRectorTest */ -final class EregToPregMatchRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class EregToPregMatchRector extends AbstractRector implements MinPhpVersionInterface { /** * @var array @@ -43,30 +43,30 @@ final class EregToPregMatchRector extends \Rector\Core\Rector\AbstractRector imp * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Php70\EregToPcreTransformer $eregToPcreTransformer, \Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(EregToPcreTransformer $eregToPcreTransformer, ArgsAnalyzer $argsAnalyzer) { $this->eregToPcreTransformer = $eregToPcreTransformer; $this->argsAnalyzer = $argsAnalyzer; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NO_EREG_FUNCTION; + return PhpVersionFeature::NO_EREG_FUNCTION; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes ereg*() to preg*() calls', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('ereg("hi")', 'preg_match("#hi#");')]); + return new RuleDefinition('Changes ereg*() to preg*() calls', [new CodeSample('ereg("hi")', 'preg_match("#hi#");')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -76,23 +76,23 @@ final class EregToPregMatchRector extends \Rector\Core\Rector\AbstractRector imp /** @var Arg $firstArg */ $firstArg = $node->args[0]; $patternNode = $firstArg->value; - if ($patternNode instanceof \PhpParser\Node\Scalar\String_) { + if ($patternNode instanceof String_) { $this->processStringPattern($node, $patternNode, $functionName); - } elseif ($patternNode instanceof \PhpParser\Node\Expr\Variable) { + } elseif ($patternNode instanceof Variable) { $this->processVariablePattern($node, $patternNode, $functionName); } $this->processSplitLimitArgument($node, $functionName); - $node->name = new \PhpParser\Node\Name(self::OLD_NAMES_TO_NEW_ONES[$functionName]); + $node->name = new Name(self::OLD_NAMES_TO_NEW_ONES[$functionName]); // ereg|eregi 3rd argument return value fix - if (\in_array($functionName, ['ereg', 'eregi'], \true) && isset($node->args[2]) && $node->args[2] instanceof \PhpParser\Node\Arg) { - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentNode instanceof \PhpParser\Node\Expr\Assign) { + if (\in_array($functionName, ['ereg', 'eregi'], \true) && isset($node->args[2]) && $node->args[2] instanceof Arg) { + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); + if ($parentNode instanceof Assign) { return $this->createTernaryWithStrlenOfFirstMatch($node); } } return $node; } - private function shouldSkip(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function shouldSkip(FuncCall $funcCall) : bool { $functionName = $this->getName($funcCall); if ($functionName === null) { @@ -103,20 +103,20 @@ final class EregToPregMatchRector extends \Rector\Core\Rector\AbstractRector imp } return !$this->argsAnalyzer->isArgInstanceInArgsPosition($funcCall->args, 0); } - private function processStringPattern(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Scalar\String_ $string, string $functionName) : void + private function processStringPattern(FuncCall $funcCall, String_ $string, string $functionName) : void { $pattern = $string->value; $pattern = $this->eregToPcreTransformer->transform($pattern, $this->isCaseInsensitiveFunction($functionName)); /** @var Arg $arg */ $arg = $funcCall->args[0]; - $arg->value = new \PhpParser\Node\Scalar\String_($pattern); + $arg->value = new String_($pattern); } - private function processVariablePattern(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr\Variable $variable, string $functionName) : void + private function processVariablePattern(FuncCall $funcCall, Variable $variable, string $functionName) : void { - $pregQuotePatternNode = $this->nodeFactory->createFuncCall('preg_quote', [new \PhpParser\Node\Arg($variable), new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\String_('#'))]); - $startConcat = new \PhpParser\Node\Expr\BinaryOp\Concat(new \PhpParser\Node\Scalar\String_('#'), $pregQuotePatternNode); + $pregQuotePatternNode = $this->nodeFactory->createFuncCall('preg_quote', [new Arg($variable), new Arg(new String_('#'))]); + $startConcat = new Concat(new String_('#'), $pregQuotePatternNode); $endDelimiter = $this->isCaseInsensitiveFunction($functionName) ? '#mi' : '#m'; - $concat = new \PhpParser\Node\Expr\BinaryOp\Concat($startConcat, new \PhpParser\Node\Scalar\String_($endDelimiter)); + $concat = new Concat($startConcat, new String_($endDelimiter)); /** @var Arg $arg */ $arg = $funcCall->args[0]; $arg->value = $concat; @@ -127,19 +127,19 @@ final class EregToPregMatchRector extends \Rector\Core\Rector\AbstractRector imp * ↓ * preg_split('# #', 'hey Tom', 1); */ - private function processSplitLimitArgument(\PhpParser\Node\Expr\FuncCall $funcCall, string $functionName) : void + private function processSplitLimitArgument(FuncCall $funcCall, string $functionName) : void { if (!isset($funcCall->args[2])) { return; } - if (!$funcCall->args[2] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[2] instanceof Arg) { return; } if (\strncmp($functionName, 'split', \strlen('split')) !== 0) { return; } // 3rd argument - $limit, 0 → 1 - if (!$funcCall->args[2]->value instanceof \PhpParser\Node\Scalar\LNumber) { + if (!$funcCall->args[2]->value instanceof LNumber) { return; } /** @var LNumber $limitNumberNode */ @@ -149,13 +149,13 @@ final class EregToPregMatchRector extends \Rector\Core\Rector\AbstractRector imp } $limitNumberNode->value = 1; } - private function createTernaryWithStrlenOfFirstMatch(\PhpParser\Node\Expr\FuncCall $funcCall) : \PhpParser\Node\Expr\Ternary + private function createTernaryWithStrlenOfFirstMatch(FuncCall $funcCall) : Ternary { /** @var Arg $thirdArg */ $thirdArg = $funcCall->args[2]; - $arrayDimFetch = new \PhpParser\Node\Expr\ArrayDimFetch($thirdArg->value, new \PhpParser\Node\Scalar\LNumber(0)); + $arrayDimFetch = new ArrayDimFetch($thirdArg->value, new LNumber(0)); $strlenFuncCall = $this->nodeFactory->createFuncCall('strlen', [$arrayDimFetch]); - return new \PhpParser\Node\Expr\Ternary($funcCall, $strlenFuncCall, $this->nodeFactory->createFalse()); + return new Ternary($funcCall, $strlenFuncCall, $this->nodeFactory->createFalse()); } private function isCaseInsensitiveFunction(string $functionName) : bool { diff --git a/rules/Php70/Rector/FuncCall/MultiDirnameRector.php b/rules/Php70/Rector/FuncCall/MultiDirnameRector.php index 1d5b8c0a683..d7496a6eabb 100644 --- a/rules/Php70/Rector/FuncCall/MultiDirnameRector.php +++ b/rules/Php70/Rector/FuncCall/MultiDirnameRector.php @@ -10,12 +10,12 @@ use PhpParser\Node\Scalar\LNumber; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php70\Rector\FuncCall\MultiDirnameRector\MultiDirnameRectorTest */ -final class MultiDirnameRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class MultiDirnameRector extends AbstractRector implements MinPhpVersionInterface { /** * @var string @@ -25,21 +25,21 @@ final class MultiDirnameRector extends \Rector\Core\Rector\AbstractRector implem * @var int */ private $nestingLevel = 0; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes multiple dirname() calls to one with nesting level', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('dirname(dirname($path));', 'dirname($path, 2);')]); + return new RuleDefinition('Changes multiple dirname() calls to one with nesting level', [new CodeSample('dirname(dirname($path));', 'dirname($path, 2);')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $this->nestingLevel = 0; if (!$this->isName($node, self::DIRNAME)) { @@ -55,14 +55,14 @@ final class MultiDirnameRector extends \Rector\Core\Rector\AbstractRector implem return $activeFuncCallNode; } $node->args[0] = $lastFuncCallNode->args[0]; - $node->args[1] = new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\LNumber($this->nestingLevel)); + $node->args[1] = new Arg(new LNumber($this->nestingLevel)); return $node; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::DIRNAME_LEVELS; + return PhpVersionFeature::DIRNAME_LEVELS; } - private function matchNestedDirnameFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Expr\FuncCall + private function matchNestedDirnameFuncCall(FuncCall $funcCall) : ?FuncCall { if (!$this->isName($funcCall, self::DIRNAME)) { return null; @@ -73,7 +73,7 @@ final class MultiDirnameRector extends \Rector\Core\Rector\AbstractRector implem } // dirname($path, ); if (\count($args) === 2) { - if (!$args[1]->value instanceof \PhpParser\Node\Scalar\LNumber) { + if (!$args[1]->value instanceof LNumber) { return null; } /** @var LNumber $levelNumber */ @@ -83,7 +83,7 @@ final class MultiDirnameRector extends \Rector\Core\Rector\AbstractRector implem ++$this->nestingLevel; } $nestedFuncCallNode = $args[0]->value; - if (!$nestedFuncCallNode instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$nestedFuncCallNode instanceof FuncCall) { return null; } if ($this->isName($nestedFuncCallNode, self::DIRNAME)) { diff --git a/rules/Php70/Rector/FuncCall/NonVariableToVariableOnFunctionCallRector.php b/rules/Php70/Rector/FuncCall/NonVariableToVariableOnFunctionCallRector.php index 8a870fb9a05..61dbdc732df 100644 --- a/rules/Php70/Rector/FuncCall/NonVariableToVariableOnFunctionCallRector.php +++ b/rules/Php70/Rector/FuncCall/NonVariableToVariableOnFunctionCallRector.php @@ -35,14 +35,14 @@ use Rector\NodeNestingScope\ParentScopeFinder; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Php70\ValueObject\VariableAssignPair; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/migration70.incompatible.php * * @see \Rector\Tests\Php70\Rector\FuncCall\NonVariableToVariableOnFunctionCallRector\NonVariableToVariableOnFunctionCallRectorTest */ -final class NonVariableToVariableOnFunctionCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class NonVariableToVariableOnFunctionCallRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -64,52 +64,52 @@ final class NonVariableToVariableOnFunctionCallRector extends \Rector\Core\Recto * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Naming\Naming\VariableNaming $variableNaming, \Rector\NodeNestingScope\ParentScopeFinder $parentScopeFinder, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(VariableNaming $variableNaming, ParentScopeFinder $parentScopeFinder, ReflectionResolver $reflectionResolver, ArgsAnalyzer $argsAnalyzer) { $this->variableNaming = $variableNaming; $this->parentScopeFinder = $parentScopeFinder; $this->reflectionResolver = $reflectionResolver; $this->argsAnalyzer = $argsAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Transform non variable like arguments to variable where a function or method expects an argument passed by reference', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('reset(a());', '$a = a(); reset($a);')]); + return new RuleDefinition('Transform non variable like arguments to variable where a function or method expects an argument passed by reference', [new CodeSample('reset(a());', '$a = a(); reset($a);')]); } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::VARIABLE_ON_FUNC_CALL; + return PhpVersionFeature::VARIABLE_ON_FUNC_CALL; } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [FuncCall::class, MethodCall::class, StaticCall::class]; } /** * @param FuncCall|MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $arguments = $this->getNonVariableArguments($node); if ($arguments === []) { return null; } $scopeNode = $this->parentScopeFinder->find($node); - if (!$scopeNode instanceof \PhpParser\Node) { + if (!$scopeNode instanceof Node) { return null; } - $currentScope = $scopeNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$currentScope instanceof \PHPStan\Analyser\MutatingScope) { + $currentScope = $scopeNode->getAttribute(AttributeKey::SCOPE); + if (!$currentScope instanceof MutatingScope) { return null; } foreach ($arguments as $key => $argument) { - if (!$node->args[$key] instanceof \PhpParser\Node\Arg) { + if (!$node->args[$key] instanceof Arg) { continue; } $replacements = $this->getReplacementsFor($argument, $currentScope, $scopeNode); $currentStmt = $this->betterNodeFinder->resolveCurrentStatement($node); - if (!$currentStmt instanceof \PhpParser\Node\Stmt) { + if (!$currentStmt instanceof Stmt) { continue; } $this->nodesToAddCollector->addNodeBeforeNode($replacements->getAssign(), $currentStmt, $this->file->getSmartFileInfo()); @@ -117,7 +117,7 @@ final class NonVariableToVariableOnFunctionCallRector extends \Rector\Core\Recto // add variable name to scope, so we prevent duplication of new variable of the same name $currentScope = $currentScope->assignExpression($replacements->getVariable(), $currentScope->getType($replacements->getVariable())); } - $scopeNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, $currentScope); + $scopeNode->setAttribute(AttributeKey::SCOPE, $currentScope); return $node; } /** @@ -155,33 +155,33 @@ final class NonVariableToVariableOnFunctionCallRector extends \Rector\Core\Recto /** * @param \PhpParser\Node\Expr\Closure|\PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Stmt\Namespace_ $scopeNode */ - private function getReplacementsFor(\PhpParser\Node\Expr $expr, \PHPStan\Analyser\MutatingScope $scope, $scopeNode) : \Rector\Php70\ValueObject\VariableAssignPair + private function getReplacementsFor(Expr $expr, MutatingScope $scope, $scopeNode) : VariableAssignPair { if ($this->isAssign($expr)) { /** @var Assign|AssignRef|AssignOp $expr */ if ($this->isVariableLikeNode($expr->var)) { - return new \Rector\Php70\ValueObject\VariableAssignPair($expr->var, $expr); + return new VariableAssignPair($expr->var, $expr); } } $variableName = $this->variableNaming->resolveFromNodeWithScopeCountAndFallbackName($expr, $scope, 'tmp'); - $variable = new \PhpParser\Node\Expr\Variable($variableName); + $variable = new Variable($variableName); // add a new scope with this variable - $mutatingScope = $scope->assignExpression($variable, new \PHPStan\Type\MixedType()); - $scopeNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, $mutatingScope); - return new \Rector\Php70\ValueObject\VariableAssignPair($variable, new \PhpParser\Node\Expr\Assign($variable, $expr)); + $mutatingScope = $scope->assignExpression($variable, new MixedType()); + $scopeNode->setAttribute(AttributeKey::SCOPE, $mutatingScope); + return new VariableAssignPair($variable, new Assign($variable, $expr)); } - private function isVariableLikeNode(\PhpParser\Node\Expr $expr) : bool + private function isVariableLikeNode(Expr $expr) : bool { - return $expr instanceof \PhpParser\Node\Expr\Variable || $expr instanceof \PhpParser\Node\Expr\ArrayDimFetch || $expr instanceof \PhpParser\Node\Expr\PropertyFetch || $expr instanceof \PhpParser\Node\Expr\StaticPropertyFetch; + return $expr instanceof Variable || $expr instanceof ArrayDimFetch || $expr instanceof PropertyFetch || $expr instanceof StaticPropertyFetch; } - private function isAssign(\PhpParser\Node\Expr $expr) : bool + private function isAssign(Expr $expr) : bool { - if ($expr instanceof \PhpParser\Node\Expr\Assign) { + if ($expr instanceof Assign) { return \true; } - if ($expr instanceof \PhpParser\Node\Expr\AssignRef) { + if ($expr instanceof AssignRef) { return \true; } - return $expr instanceof \PhpParser\Node\Expr\AssignOp; + return $expr instanceof AssignOp; } } diff --git a/rules/Php70/Rector/FuncCall/RandomFunctionRector.php b/rules/Php70/Rector/FuncCall/RandomFunctionRector.php index ca906631d23..b54e1fa8538 100644 --- a/rules/Php70/Rector/FuncCall/RandomFunctionRector.php +++ b/rules/Php70/Rector/FuncCall/RandomFunctionRector.php @@ -11,41 +11,41 @@ use PhpParser\Node\Scalar\LNumber; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php70\Rector\FuncCall\RandomFunctionRector\RandomFunctionRectorTest */ -final class RandomFunctionRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class RandomFunctionRector extends AbstractRector implements MinPhpVersionInterface { /** * @var array */ private const OLD_TO_NEW_FUNCTION_NAMES = ['getrandmax' => 'mt_getrandmax', 'srand' => 'mt_srand', 'mt_rand' => 'random_int', 'rand' => 'random_int']; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes rand, srand and getrandmax by new mt_* alternatives.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('rand();', 'mt_rand();')]); + return new RuleDefinition('Changes rand, srand and getrandmax by new mt_* alternatives.', [new CodeSample('rand();', 'mt_rand();')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node * @return \PhpParser\Node\Expr\FuncCall|null */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { foreach (self::OLD_TO_NEW_FUNCTION_NAMES as $oldFunctionName => $newFunctionName) { if ($this->isName($node, $oldFunctionName)) { - $node->name = new \PhpParser\Node\Name($newFunctionName); + $node->name = new Name($newFunctionName); // special case: random_int(); → random_int(0, getrandmax()); if ($newFunctionName === 'random_int' && $node->args === []) { - $node->args[0] = new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\LNumber(0)); - $node->args[1] = new \PhpParser\Node\Arg($this->nodeFactory->createFuncCall('mt_getrandmax')); + $node->args[0] = new Arg(new LNumber(0)); + $node->args[1] = new Arg($this->nodeFactory->createFuncCall('mt_getrandmax')); } return $node; } @@ -54,6 +54,6 @@ final class RandomFunctionRector extends \Rector\Core\Rector\AbstractRector impl } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::CSPRNG_FUNCTIONS; + return PhpVersionFeature::CSPRNG_FUNCTIONS; } } diff --git a/rules/Php70/Rector/FuncCall/RenameMktimeWithoutArgsToTimeRector.php b/rules/Php70/Rector/FuncCall/RenameMktimeWithoutArgsToTimeRector.php index 6553e667803..74f88743add 100644 --- a/rules/Php70/Rector/FuncCall/RenameMktimeWithoutArgsToTimeRector.php +++ b/rules/Php70/Rector/FuncCall/RenameMktimeWithoutArgsToTimeRector.php @@ -9,17 +9,17 @@ use PhpParser\Node\Name; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/F5GE8 * @see \Rector\Tests\Php70\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector\RenameMktimeWithoutArgsToTimeRectorTest */ -final class RenameMktimeWithoutArgsToTimeRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class RenameMktimeWithoutArgsToTimeRector extends AbstractRector implements MinPhpVersionInterface { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Renames mktime() without arguments to time()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Renames mktime() without arguments to time()', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -43,19 +43,19 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NO_MKTIME_WITHOUT_ARG; + return PhpVersionFeature::NO_MKTIME_WITHOUT_ARG; } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'mktime')) { return null; @@ -63,7 +63,7 @@ CODE_SAMPLE if ($node->args !== []) { return null; } - $node->name = new \PhpParser\Node\Name('time'); + $node->name = new Name('time'); return $node; } } diff --git a/rules/Php70/Rector/FunctionLike/ExceptionHandlerTypehintRector.php b/rules/Php70/Rector/FunctionLike/ExceptionHandlerTypehintRector.php index 6ba3d171aaa..bfc1de3e897 100644 --- a/rules/Php70/Rector/FunctionLike/ExceptionHandlerTypehintRector.php +++ b/rules/Php70/Rector/FunctionLike/ExceptionHandlerTypehintRector.php @@ -12,23 +12,23 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\Util\StringUtils; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/typed_properties_v2#proposal * * @see \Rector\Tests\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector\ExceptionHandlerTypehintRectorTest */ -final class ExceptionHandlerTypehintRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ExceptionHandlerTypehintRector extends AbstractRector implements MinPhpVersionInterface { /** * @var string * @see https://regex101.com/r/VBFXCR/1 */ private const HANDLE_INSENSITIVE_REGEX = '#handle#i'; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change typehint from `Exception` to `Throwable`.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change typehint from `Exception` to `Throwable`.', [new CodeSample(<<<'CODE_SAMPLE' function handler(Exception $exception) { ... } set_exception_handler('handler'); CODE_SAMPLE @@ -43,12 +43,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Stmt\ClassMethod::class]; + return [Function_::class, ClassMethod::class]; } /** * @param Function_|ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { // exception handle has 1 param exactly if (\count($node->params) !== 1) { @@ -59,23 +59,23 @@ CODE_SAMPLE return null; } // handle only Exception typehint - $actualType = $paramNode->type instanceof \PhpParser\Node\NullableType ? $this->getName($paramNode->type->type) : $this->getName($paramNode->type); + $actualType = $paramNode->type instanceof NullableType ? $this->getName($paramNode->type->type) : $this->getName($paramNode->type); if ($actualType !== 'Exception') { return null; } // is probably handling exceptions - if (!\Rector\Core\Util\StringUtils::isMatch((string) $node->name, self::HANDLE_INSENSITIVE_REGEX)) { + if (!StringUtils::isMatch((string) $node->name, self::HANDLE_INSENSITIVE_REGEX)) { return null; } - if (!$paramNode->type instanceof \PhpParser\Node\NullableType) { - $paramNode->type = new \PhpParser\Node\Name\FullyQualified('Throwable'); + if (!$paramNode->type instanceof NullableType) { + $paramNode->type = new FullyQualified('Throwable'); } else { - $paramNode->type->type = new \PhpParser\Node\Name\FullyQualified('Throwable'); + $paramNode->type->type = new FullyQualified('Throwable'); } return $node; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::THROWABLE_TYPE; + return PhpVersionFeature::THROWABLE_TYPE; } } diff --git a/rules/Php70/Rector/If_/IfToSpaceshipRector.php b/rules/Php70/Rector/If_/IfToSpaceshipRector.php index c3d8e77cddb..f1314b53314 100644 --- a/rules/Php70/Rector/If_/IfToSpaceshipRector.php +++ b/rules/Php70/Rector/If_/IfToSpaceshipRector.php @@ -18,14 +18,14 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/combined-comparison-operator https://3v4l.org/LPbA0 * * @see \Rector\Tests\Php70\Rector\If_\IfToSpaceshipRector\IfToSpaceshipRectorTest */ -final class IfToSpaceshipRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class IfToSpaceshipRector extends AbstractRector implements MinPhpVersionInterface { /** * @var int|float|string|bool|mixed[]|null @@ -55,9 +55,9 @@ final class IfToSpaceshipRector extends \Rector\Core\Rector\AbstractRector imple * @var \PhpParser\Node\Expr\Ternary|null */ private $ternary = null; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes if/else to spaceship <=> where useful', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes if/else to spaceship <=> where useful', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -90,14 +90,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->cond instanceof \PhpParser\Node\Expr\BinaryOp\Equal && !$node->cond instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { + if (!$node->cond instanceof Equal && !$node->cond instanceof Identical) { return null; } $this->reset(); @@ -120,16 +120,16 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::SPACESHIP; + return PhpVersionFeature::SPACESHIP; } - private function processReturnSpaceship(\PhpParser\Node\Expr $firstValue, \PhpParser\Node\Expr $secondValue) : \PhpParser\Node\Stmt\Return_ + private function processReturnSpaceship(Expr $firstValue, Expr $secondValue) : Return_ { - if ($this->nextNode instanceof \PhpParser\Node\Stmt\Return_) { + if ($this->nextNode instanceof Return_) { $this->removeNode($this->nextNode); } // spaceship ready! - $spaceship = new \PhpParser\Node\Expr\BinaryOp\Spaceship($secondValue, $firstValue); - return new \PhpParser\Node\Stmt\Return_($spaceship); + $spaceship = new Spaceship($secondValue, $firstValue); + return new Return_($spaceship); } private function reset() : void { @@ -139,14 +139,14 @@ CODE_SAMPLE $this->firstValue = null; $this->secondValue = null; } - private function matchOnEqualFirstValueAndSecondValue(\PhpParser\Node\Stmt\If_ $if) : void + private function matchOnEqualFirstValueAndSecondValue(If_ $if) : void { $this->matchOnEqual($if); if ($if->else !== null) { $this->processElse($if->else); } else { - $nextNode = $if->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if ($nextNode instanceof \PhpParser\Node\Stmt\Return_ && $nextNode->expr instanceof \PhpParser\Node\Expr\Ternary) { + $nextNode = $if->getAttribute(AttributeKey::NEXT_NODE); + if ($nextNode instanceof Return_ && $nextNode->expr instanceof Ternary) { $this->ternary = $nextNode->expr; $this->processTernary($this->ternary, $nextNode); } @@ -155,7 +155,7 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Expr\BinaryOp\Equal|\PhpParser\Node\Expr\BinaryOp\Identical $binaryOp */ - private function areVariablesEqual($binaryOp, \PhpParser\Node\Expr $firstValue, \PhpParser\Node\Expr $secondValue) : bool + private function areVariablesEqual($binaryOp, Expr $firstValue, Expr $secondValue) : bool { if ($this->nodeComparator->areNodesEqual($binaryOp->left, $firstValue) && $this->nodeComparator->areNodesEqual($binaryOp->right, $secondValue)) { return \true; @@ -165,37 +165,37 @@ CODE_SAMPLE } return $this->nodeComparator->areNodesEqual($binaryOp->left, $secondValue); } - private function matchOnEqual(\PhpParser\Node\Stmt\If_ $if) : void + private function matchOnEqual(If_ $if) : void { if (\count($if->stmts) !== 1) { return; } $onlyIfStmt = $if->stmts[0]; - if ($onlyIfStmt instanceof \PhpParser\Node\Stmt\Return_) { + if ($onlyIfStmt instanceof Return_) { if ($onlyIfStmt->expr === null) { return; } $this->onEqual = $this->valueResolver->getValue($onlyIfStmt->expr); } } - private function processElse(\PhpParser\Node\Stmt\Else_ $else) : void + private function processElse(Else_ $else) : void { if (\count($else->stmts) !== 1) { return; } - if (!$else->stmts[0] instanceof \PhpParser\Node\Stmt\Return_) { + if (!$else->stmts[0] instanceof Return_) { return; } /** @var Return_ $returnNode */ $returnNode = $else->stmts[0]; - if ($returnNode->expr instanceof \PhpParser\Node\Expr\Ternary) { + if ($returnNode->expr instanceof Ternary) { $this->ternary = $returnNode->expr; $this->processTernary($returnNode->expr, null); } } - private function processTernary(\PhpParser\Node\Expr\Ternary $ternary, ?\PhpParser\Node\Stmt\Return_ $return) : void + private function processTernary(Ternary $ternary, ?Return_ $return) : void { - if ($ternary->cond instanceof \PhpParser\Node\Expr\BinaryOp\Smaller) { + if ($ternary->cond instanceof Smaller) { $this->firstValue = $ternary->cond->left; $this->secondValue = $ternary->cond->right; if ($ternary->if !== null) { @@ -203,7 +203,7 @@ CODE_SAMPLE } $this->onGreater = $this->valueResolver->getValue($ternary->else); $this->nextNode = $return; - } elseif ($ternary->cond instanceof \PhpParser\Node\Expr\BinaryOp\Greater) { + } elseif ($ternary->cond instanceof Greater) { $this->firstValue = $ternary->cond->right; $this->secondValue = $ternary->cond->left; if ($ternary->if !== null) { @@ -213,16 +213,16 @@ CODE_SAMPLE $this->nextNode = $return; } } - private function processAscendingSort(?\PhpParser\Node\Expr\Ternary $ternary, \PhpParser\Node\Expr $firstValue, \PhpParser\Node\Expr $secondValue) : \PhpParser\Node\Stmt\Return_ + private function processAscendingSort(?Ternary $ternary, Expr $firstValue, Expr $secondValue) : Return_ { - if ($ternary instanceof \PhpParser\Node\Expr\Ternary && !$ternary->cond instanceof \PhpParser\Node\Expr\BinaryOp\Greater) { + if ($ternary instanceof Ternary && !$ternary->cond instanceof Greater) { return $this->processReturnSpaceship($secondValue, $firstValue); } return $this->processReturnSpaceship($firstValue, $secondValue); } - private function processDescendingSort(?\PhpParser\Node\Expr\Ternary $ternary, \PhpParser\Node\Expr $firstValue, \PhpParser\Node\Expr $secondValue) : \PhpParser\Node\Stmt\Return_ + private function processDescendingSort(?Ternary $ternary, Expr $firstValue, Expr $secondValue) : Return_ { - if ($ternary instanceof \PhpParser\Node\Expr\Ternary && !$ternary->cond instanceof \PhpParser\Node\Expr\BinaryOp\Smaller) { + if ($ternary instanceof Ternary && !$ternary->cond instanceof Smaller) { return $this->processReturnSpaceship($secondValue, $firstValue); } return $this->processReturnSpaceship($firstValue, $secondValue); diff --git a/rules/Php70/Rector/List_/EmptyListRector.php b/rules/Php70/Rector/List_/EmptyListRector.php index 2a264ce2971..d23a5178397 100644 --- a/rules/Php70/Rector/List_/EmptyListRector.php +++ b/rules/Php70/Rector/List_/EmptyListRector.php @@ -10,17 +10,17 @@ use PhpParser\Node\Expr\Variable; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog http://php.net/manual/en/migration70.incompatible.php#migration70.incompatible.variable-handling.list * @see \Rector\Tests\Php70\Rector\List_\EmptyListRector\EmptyListRectorTest */ -final class EmptyListRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class EmptyListRector extends AbstractRector implements MinPhpVersionInterface { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('list() cannot be empty', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('list() cannot be empty', [new CodeSample(<<<'CODE_SAMPLE' 'list() = $values;' CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -30,26 +30,26 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NO_EMPTY_LIST; + return PhpVersionFeature::NO_EMPTY_LIST; } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\List_::class]; + return [List_::class]; } /** * @param List_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($node->items as $item) { if ($item !== null) { return null; } } - $node->items[0] = new \PhpParser\Node\Expr\ArrayItem(new \PhpParser\Node\Expr\Variable('unusedGenerated')); + $node->items[0] = new ArrayItem(new Variable('unusedGenerated')); return $node; } } diff --git a/rules/Php70/Rector/MethodCall/ThisCallOnStaticMethodToStaticCallRector.php b/rules/Php70/Rector/MethodCall/ThisCallOnStaticMethodToStaticCallRector.php index 663a1ffda45..dfc5230c552 100644 --- a/rules/Php70/Rector/MethodCall/ThisCallOnStaticMethodToStaticCallRector.php +++ b/rules/Php70/Rector/MethodCall/ThisCallOnStaticMethodToStaticCallRector.php @@ -16,13 +16,13 @@ use Rector\Core\Reflection\ReflectionResolver; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeCollector\StaticAnalyzer; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/rkiSC * @see \Rector\Tests\Php70\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector\ThisCallOnStaticMethodToStaticCallRectorTest */ -final class ThisCallOnStaticMethodToStaticCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ThisCallOnStaticMethodToStaticCallRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -34,18 +34,18 @@ final class ThisCallOnStaticMethodToStaticCallRector extends \Rector\Core\Rector * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\NodeCollector\StaticAnalyzer $staticAnalyzer, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(StaticAnalyzer $staticAnalyzer, ReflectionResolver $reflectionResolver) { $this->staticAnalyzer = $staticAnalyzer; $this->reflectionResolver = $reflectionResolver; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::STATIC_CALL_ON_NON_STATIC; + return PhpVersionFeature::STATIC_CALL_ON_NON_STATIC; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes $this->call() to static method to static call', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes $this->call() to static method to static call', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public static function run() @@ -78,14 +78,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$node->var instanceof Variable) { return null; } if (!$this->nodeNameResolver->isName($node->var, 'this')) { @@ -96,11 +96,11 @@ CODE_SAMPLE return null; } // skip PHPUnit calls, as they accept both self:: and $this-> formats - if ($this->isObjectType($node->var, new \PHPStan\Type\ObjectType('PHPUnit\\Framework\\TestCase'))) { + if ($this->isObjectType($node->var, new ObjectType('PHPUnit\\Framework\\TestCase'))) { return null; } - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($node, ClassLike::class); + if (!$classLike instanceof ClassLike) { return null; } $className = (string) $this->nodeNameResolver->getName($classLike); @@ -114,22 +114,22 @@ CODE_SAMPLE /** * @return ObjectReference::STATIC|ObjectReference::SELF */ - private function resolveClassSelf(\PhpParser\Node\Expr\MethodCall $methodCall) : string + private function resolveClassSelf(MethodCall $methodCall) : string { - $classLike = $this->betterNodeFinder->findParentType($methodCall, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { - return \Rector\Core\Enum\ObjectReference::STATIC; + $classLike = $this->betterNodeFinder->findParentType($methodCall, Class_::class); + if (!$classLike instanceof Class_) { + return ObjectReference::STATIC; } if ($classLike->isFinal()) { - return \Rector\Core\Enum\ObjectReference::SELF; + return ObjectReference::SELF; } $methodReflection = $this->reflectionResolver->resolveMethodReflectionFromMethodCall($methodCall); - if (!$methodReflection instanceof \PHPStan\Reflection\Php\PhpMethodReflection) { - return \Rector\Core\Enum\ObjectReference::STATIC; + if (!$methodReflection instanceof PhpMethodReflection) { + return ObjectReference::STATIC; } if (!$methodReflection->isPrivate()) { - return \Rector\Core\Enum\ObjectReference::STATIC; + return ObjectReference::STATIC; } - return \Rector\Core\Enum\ObjectReference::SELF; + return ObjectReference::SELF; } } diff --git a/rules/Php70/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php b/rules/Php70/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php index 8a7807bced5..28990a17acb 100644 --- a/rules/Php70/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php +++ b/rules/Php70/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php @@ -22,14 +22,14 @@ use Rector\NodeCollector\StaticAnalyzer; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; use ReflectionMethod; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://thephp.cc/news/2017/07/dont-call-instance-methods-statically https://3v4l.org/tQ32f https://3v4l.org/jB9jn * * @see \Rector\Tests\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector\StaticCallOnNonStaticToInstanceCallRectorTest */ -final class StaticCallOnNonStaticToInstanceCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class StaticCallOnNonStaticToInstanceCallRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -51,7 +51,7 @@ final class StaticCallOnNonStaticToInstanceCallRector extends \Rector\Core\Recto * @var \Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver */ private $parentClassScopeResolver; - public function __construct(\Rector\NodeCollector\StaticAnalyzer $staticAnalyzer, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver $parentClassScopeResolver) + public function __construct(StaticAnalyzer $staticAnalyzer, ReflectionProvider $reflectionProvider, ReflectionResolver $reflectionResolver, ParentClassScopeResolver $parentClassScopeResolver) { $this->staticAnalyzer = $staticAnalyzer; $this->reflectionProvider = $reflectionProvider; @@ -60,11 +60,11 @@ final class StaticCallOnNonStaticToInstanceCallRector extends \Rector\Core\Recto } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::INSTANCE_CALL; + return PhpVersionFeature::INSTANCE_CALL; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes static call to instance call, where not useful', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes static call to instance call, where not useful', [new CodeSample(<<<'CODE_SAMPLE' class Something { public function doWork() @@ -103,14 +103,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class]; + return [StaticCall::class]; } /** * @param StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node->name instanceof \PhpParser\Node\Expr) { + if ($node->name instanceof Expr) { return null; } $methodName = $this->getName($node->name); @@ -125,36 +125,36 @@ CODE_SAMPLE return null; } if ($this->isInstantiable($className)) { - $new = new \PhpParser\Node\Expr\New_($node->class); - return new \PhpParser\Node\Expr\MethodCall($new, $node->name, $node->args); + $new = new New_($node->class); + return new MethodCall($new, $node->name, $node->args); } return null; } - private function resolveStaticCallClassName(\PhpParser\Node\Expr\StaticCall $staticCall) : ?string + private function resolveStaticCallClassName(StaticCall $staticCall) : ?string { - if ($staticCall->class instanceof \PhpParser\Node\Expr\PropertyFetch) { + if ($staticCall->class instanceof PropertyFetch) { $objectType = $this->getType($staticCall->class); - if ($objectType instanceof \PHPStan\Type\ObjectType) { + if ($objectType instanceof ObjectType) { return $objectType->getClassName(); } } return $this->getName($staticCall->class); } - private function shouldSkip(string $methodName, string $className, \PhpParser\Node\Expr\StaticCall $staticCall) : bool + private function shouldSkip(string $methodName, string $className, StaticCall $staticCall) : bool { $isStaticMethod = $this->staticAnalyzer->isStaticMethod($methodName, $className); if ($isStaticMethod) { return \true; } $className = $this->getName($staticCall->class); - if (\in_array($className, [\Rector\Core\Enum\ObjectReference::PARENT, \Rector\Core\Enum\ObjectReference::SELF, \Rector\Core\Enum\ObjectReference::STATIC], \true)) { + if (\in_array($className, [ObjectReference::PARENT, ObjectReference::SELF, ObjectReference::STATIC], \true)) { return \true; } if ($className === 'class') { return \true; } - $scope = $staticCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { + $scope = $staticCall->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { return \true; } $parentClassName = $this->parentClassScopeResolver->resolveParentClassName($scope); @@ -166,13 +166,13 @@ CODE_SAMPLE return \false; } $methodReflection = $this->reflectionResolver->resolveMethodReflection($className, '__callStatic', null); - if ($methodReflection instanceof \PHPStan\Reflection\MethodReflection) { + if ($methodReflection instanceof MethodReflection) { return \false; } $classReflection = $this->reflectionProvider->getClass($className); $nativeReflection = $classReflection->getNativeReflection(); $reflectionMethod = $nativeReflection->getConstructor(); - if (!$reflectionMethod instanceof \ReflectionMethod) { + if (!$reflectionMethod instanceof ReflectionMethod) { return \true; } if (!$reflectionMethod->isPublic()) { diff --git a/rules/Php70/Rector/Switch_/ReduceMultipleDefaultSwitchRector.php b/rules/Php70/Rector/Switch_/ReduceMultipleDefaultSwitchRector.php index ffdfa90fc8b..8986f475c32 100644 --- a/rules/Php70/Rector/Switch_/ReduceMultipleDefaultSwitchRector.php +++ b/rules/Php70/Rector/Switch_/ReduceMultipleDefaultSwitchRector.php @@ -10,8 +10,8 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/iGDVW * @@ -19,15 +19,15 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @see \Rector\Tests\Php70\Rector\Switch_\ReduceMultipleDefaultSwitchRector\ReduceMultipleDefaultSwitchRectorTest */ -final class ReduceMultipleDefaultSwitchRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ReduceMultipleDefaultSwitchRector extends AbstractRector implements MinPhpVersionInterface { public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NO_MULTIPLE_DEFAULT_SWITCH; + return PhpVersionFeature::NO_MULTIPLE_DEFAULT_SWITCH; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove first default switch, that is ignored', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove first default switch, that is ignored', [new CodeSample(<<<'CODE_SAMPLE' switch ($expr) { default: echo "Hello World"; @@ -51,12 +51,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Switch_::class]; + return [Switch_::class]; } /** * @param Switch_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $defaultCases = []; foreach ($node->cases as $case) { @@ -83,10 +83,10 @@ CODE_SAMPLE $this->removeNode($defaultCase); } } - private function keepStatementsToParentCase(\PhpParser\Node\Stmt\Case_ $case) : void + private function keepStatementsToParentCase(Case_ $case) : void { - $previousNode = $case->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_NODE); - if (!$previousNode instanceof \PhpParser\Node\Stmt\Case_) { + $previousNode = $case->getAttribute(AttributeKey::PREVIOUS_NODE); + if (!$previousNode instanceof Case_) { return; } if ($previousNode->stmts === []) { diff --git a/rules/Php70/Rector/Ternary/TernaryToNullCoalescingRector.php b/rules/Php70/Rector/Ternary/TernaryToNullCoalescingRector.php index 9a81bc2c2b9..9f05cccce8a 100644 --- a/rules/Php70/Rector/Ternary/TernaryToNullCoalescingRector.php +++ b/rules/Php70/Rector/Ternary/TernaryToNullCoalescingRector.php @@ -13,36 +13,36 @@ use PhpParser\Node\Expr\Ternary; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php70\Rector\Ternary\TernaryToNullCoalescingRector\TernaryToNullCoalescingRectorTest */ -final class TernaryToNullCoalescingRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class TernaryToNullCoalescingRector extends AbstractRector implements MinPhpVersionInterface { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes unneeded null check to ?? operator', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$value === null ? 10 : $value;', '$value ?? 10;'), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('isset($value) ? $value : 10;', '$value ?? 10;')]); + return new RuleDefinition('Changes unneeded null check to ?? operator', [new CodeSample('$value === null ? 10 : $value;', '$value ?? 10;'), new CodeSample('isset($value) ? $value : 10;', '$value ?? 10;')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Ternary::class]; + return [Ternary::class]; } /** * @param Ternary $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node->cond instanceof \PhpParser\Node\Expr\Isset_) { + if ($node->cond instanceof Isset_) { return $this->processTernaryWithIsset($node, $node->cond); } - if ($node->cond instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { + if ($node->cond instanceof Identical) { $checkedNode = $node->else; $fallbackNode = $node->if; - } elseif ($node->cond instanceof \PhpParser\Node\Expr\BinaryOp\NotIdentical) { + } elseif ($node->cond instanceof NotIdentical) { $checkedNode = $node->if; $fallbackNode = $node->else; } else { @@ -52,24 +52,24 @@ final class TernaryToNullCoalescingRector extends \Rector\Core\Rector\AbstractRe if ($checkedNode === null) { return null; } - if (!$fallbackNode instanceof \PhpParser\Node\Expr) { + if (!$fallbackNode instanceof Expr) { return null; } /** @var Identical|NotIdentical $ternaryCompareNode */ $ternaryCompareNode = $node->cond; if ($this->isNullMatch($ternaryCompareNode->left, $ternaryCompareNode->right, $checkedNode)) { - return new \PhpParser\Node\Expr\BinaryOp\Coalesce($checkedNode, $fallbackNode); + return new Coalesce($checkedNode, $fallbackNode); } if ($this->isNullMatch($ternaryCompareNode->right, $ternaryCompareNode->left, $checkedNode)) { - return new \PhpParser\Node\Expr\BinaryOp\Coalesce($checkedNode, $fallbackNode); + return new Coalesce($checkedNode, $fallbackNode); } return null; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NULL_COALESCE; + return PhpVersionFeature::NULL_COALESCE; } - private function processTernaryWithIsset(\PhpParser\Node\Expr\Ternary $ternary, \PhpParser\Node\Expr\Isset_ $isset) : ?\PhpParser\Node\Expr\BinaryOp\Coalesce + private function processTernaryWithIsset(Ternary $ternary, Isset_ $isset) : ?Coalesce { if ($ternary->if === null) { return null; @@ -84,9 +84,9 @@ final class TernaryToNullCoalescingRector extends \Rector\Core\Rector\AbstractRe if (!$this->nodeComparator->areNodesEqual($ternary->if, $isset->vars[0])) { return null; } - return new \PhpParser\Node\Expr\BinaryOp\Coalesce($ternary->if, $ternary->else); + return new Coalesce($ternary->if, $ternary->else); } - private function isNullMatch(\PhpParser\Node\Expr $possibleNullExpr, \PhpParser\Node\Expr $firstNode, \PhpParser\Node\Expr $secondNode) : bool + private function isNullMatch(Expr $possibleNullExpr, Expr $firstNode, Expr $secondNode) : bool { if (!$this->valueResolver->isNull($possibleNullExpr)) { return \false; diff --git a/rules/Php70/Rector/Ternary/TernaryToSpaceshipRector.php b/rules/Php70/Rector/Ternary/TernaryToSpaceshipRector.php index 8bb7a553c3f..8f4daaf70a2 100644 --- a/rules/Php70/Rector/Ternary/TernaryToSpaceshipRector.php +++ b/rules/Php70/Rector/Ternary/TernaryToSpaceshipRector.php @@ -12,17 +12,17 @@ use PhpParser\Node\Expr\Ternary; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/combined-comparison-operator * @see \Rector\Tests\Php70\Rector\Ternary\TernaryToSpaceshipRector\TernaryToSpaceshipRectorTest */ -final class TernaryToSpaceshipRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class TernaryToSpaceshipRector extends AbstractRector implements MinPhpVersionInterface { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Use <=> spaceship instead of ternary with same effect', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Use <=> spaceship instead of ternary with same effect', [new CodeSample(<<<'CODE_SAMPLE' function order_func($a, $b) { return ($a < $b) ? -1 : (($a > $b) ? 1 : 0); } @@ -39,12 +39,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Ternary::class]; + return [Ternary::class]; } /** * @param Ternary $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -59,18 +59,18 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::SPACESHIP; + return PhpVersionFeature::SPACESHIP; } - private function shouldSkip(\PhpParser\Node\Expr\Ternary $ternary) : bool + private function shouldSkip(Ternary $ternary) : bool { - if (!$ternary->cond instanceof \PhpParser\Node\Expr\BinaryOp) { + if (!$ternary->cond instanceof BinaryOp) { return \true; } - if (!$ternary->else instanceof \PhpParser\Node\Expr\Ternary) { + if (!$ternary->else instanceof Ternary) { return \true; } $nestedTernary = $ternary->else; - if (!$nestedTernary->cond instanceof \PhpParser\Node\Expr\BinaryOp) { + if (!$nestedTernary->cond instanceof BinaryOp) { return \true; } // $a X $b ? . : ($a X $b ? . : .) @@ -83,33 +83,33 @@ CODE_SAMPLE /** * Matches "$a < $b ? -1 : ($a > $b ? 1 : 0)" */ - private function processSmallerThanTernary(\PhpParser\Node\Expr\Ternary $node, \PhpParser\Node\Expr\Ternary $nestedTernary) : ?\PhpParser\Node\Expr\BinaryOp\Spaceship + private function processSmallerThanTernary(Ternary $node, Ternary $nestedTernary) : ?Spaceship { - if (!$node->cond instanceof \PhpParser\Node\Expr\BinaryOp\Smaller) { + if (!$node->cond instanceof Smaller) { return null; } - if (!$nestedTernary->cond instanceof \PhpParser\Node\Expr\BinaryOp\Greater) { + if (!$nestedTernary->cond instanceof Greater) { return null; } if (!$this->valueResolver->areValuesEqual([$node->if, $nestedTernary->if, $nestedTernary->else], [-1, 1, 0])) { return null; } - return new \PhpParser\Node\Expr\BinaryOp\Spaceship($node->cond->left, $node->cond->right); + return new Spaceship($node->cond->left, $node->cond->right); } /** * Matches "$a > $b ? -1 : ($a < $b ? 1 : 0)" */ - private function processGreaterThanTernary(\PhpParser\Node\Expr\Ternary $node, \PhpParser\Node\Expr\Ternary $nestedTernary) : ?\PhpParser\Node\Expr\BinaryOp\Spaceship + private function processGreaterThanTernary(Ternary $node, Ternary $nestedTernary) : ?Spaceship { - if (!$node->cond instanceof \PhpParser\Node\Expr\BinaryOp\Greater) { + if (!$node->cond instanceof Greater) { return null; } - if (!$nestedTernary->cond instanceof \PhpParser\Node\Expr\BinaryOp\Smaller) { + if (!$nestedTernary->cond instanceof Smaller) { return null; } if (!$this->valueResolver->areValuesEqual([$node->if, $nestedTernary->if, $nestedTernary->else], [-1, 1, 0])) { return null; } - return new \PhpParser\Node\Expr\BinaryOp\Spaceship($node->cond->right, $node->cond->left); + return new Spaceship($node->cond->right, $node->cond->left); } } diff --git a/rules/Php70/Rector/Variable/WrapVariableVariableNameInCurlyBracesRector.php b/rules/Php70/Rector/Variable/WrapVariableVariableNameInCurlyBracesRector.php index 6036033f703..88cd21ae61e 100644 --- a/rules/Php70/Rector/Variable/WrapVariableVariableNameInCurlyBracesRector.php +++ b/rules/Php70/Rector/Variable/WrapVariableVariableNameInCurlyBracesRector.php @@ -9,21 +9,21 @@ use PhpParser\Node\Expr\Variable; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php70\Rector\Variable\WrapVariableVariableNameInCurlyBracesRector\WrapVariableVariableNameInCurlyBracesRectorTest * @changelog https://www.php.net/manual/en/language.variables.variable.php */ -final class WrapVariableVariableNameInCurlyBracesRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class WrapVariableVariableNameInCurlyBracesRector extends AbstractRector implements MinPhpVersionInterface { public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::WRAP_VARIABLE_VARIABLE; + return PhpVersionFeature::WRAP_VARIABLE_VARIABLE; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Ensure variable variables are wrapped in curly braces', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Ensure variable variables are wrapped in curly braces', [new CodeSample(<<<'CODE_SAMPLE' function run($foo) { global $$foo->bar; @@ -42,23 +42,23 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Variable::class]; + return [Variable::class]; } /** * @param Variable $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $nodeName = $node->name; - if (!$nodeName instanceof \PhpParser\Node\Expr\PropertyFetch && !$nodeName instanceof \PhpParser\Node\Expr\Variable) { + if (!$nodeName instanceof PropertyFetch && !$nodeName instanceof Variable) { return null; } if ($node->getEndTokenPos() !== $nodeName->getEndTokenPos()) { return null; } - if ($nodeName instanceof \PhpParser\Node\Expr\PropertyFetch) { - return new \PhpParser\Node\Expr\Variable(new \PhpParser\Node\Expr\PropertyFetch($nodeName->var, $nodeName->name)); + if ($nodeName instanceof PropertyFetch) { + return new Variable(new PropertyFetch($nodeName->var, $nodeName->name)); } - return new \PhpParser\Node\Expr\Variable(new \PhpParser\Node\Expr\Variable($nodeName->name)); + return new Variable(new Variable($nodeName->name)); } } diff --git a/rules/Php70/ValueObject/VariableAssignPair.php b/rules/Php70/ValueObject/VariableAssignPair.php index 0012ff68d5e..3aa1feeb694 100644 --- a/rules/Php70/ValueObject/VariableAssignPair.php +++ b/rules/Php70/ValueObject/VariableAssignPair.php @@ -27,7 +27,7 @@ final class VariableAssignPair * @param Variable|ArrayDimFetch|PropertyFetch|StaticPropertyFetch $variable * @param Assign|AssignOp|AssignRef $assign */ - public function __construct(\PhpParser\Node $variable, \PhpParser\Node $assign) + public function __construct(Node $variable, Node $assign) { $this->variable = $variable; $this->assign = $assign; diff --git a/rules/Php71/IsArrayAndDualCheckToAble.php b/rules/Php71/IsArrayAndDualCheckToAble.php index 5f0df509485..e7f3142e4c1 100644 --- a/rules/Php71/IsArrayAndDualCheckToAble.php +++ b/rules/Php71/IsArrayAndDualCheckToAble.php @@ -25,15 +25,15 @@ final class IsArrayAndDualCheckToAble * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\Core\NodeManipulator\BinaryOpManipulator $binaryOpManipulator, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(BinaryOpManipulator $binaryOpManipulator, NodeNameResolver $nodeNameResolver) { $this->binaryOpManipulator = $binaryOpManipulator; $this->nodeNameResolver = $nodeNameResolver; } - public function processBooleanOr(\PhpParser\Node\Expr\BinaryOp\BooleanOr $booleanOr, string $type, string $newMethodName) : ?\PhpParser\Node\Expr\FuncCall + public function processBooleanOr(BooleanOr $booleanOr, string $type, string $newMethodName) : ?FuncCall { - $twoNodeMatch = $this->binaryOpManipulator->matchFirstAndSecondConditionNode($booleanOr, \PhpParser\Node\Expr\Instanceof_::class, \PhpParser\Node\Expr\FuncCall::class); - if (!$twoNodeMatch instanceof \Rector\Php71\ValueObject\TwoNodeMatch) { + $twoNodeMatch = $this->binaryOpManipulator->matchFirstAndSecondConditionNode($booleanOr, Instanceof_::class, FuncCall::class); + if (!$twoNodeMatch instanceof TwoNodeMatch) { return null; } /** @var Instanceof_ $instanceOf */ @@ -41,7 +41,7 @@ final class IsArrayAndDualCheckToAble /** @var FuncCall $funcCall */ $funcCall = $twoNodeMatch->getSecondExpr(); $instanceOfClass = $instanceOf->class; - if ($instanceOfClass instanceof \PhpParser\Node\Expr) { + if ($instanceOfClass instanceof Expr) { return null; } if ((string) $instanceOfClass !== $type) { @@ -53,16 +53,16 @@ final class IsArrayAndDualCheckToAble if (!isset($funcCall->args[0])) { return null; } - if (!$funcCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[0] instanceof Arg) { return null; } // both use same var - if (!$funcCall->args[0]->value instanceof \PhpParser\Node\Expr\Variable) { + if (!$funcCall->args[0]->value instanceof Variable) { return null; } /** @var Variable $firstVarNode */ $firstVarNode = $funcCall->args[0]->value; - if (!$instanceOf->expr instanceof \PhpParser\Node\Expr\Variable) { + if (!$instanceOf->expr instanceof Variable) { return null; } /** @var Variable $secondVarNode */ @@ -71,6 +71,6 @@ final class IsArrayAndDualCheckToAble if ($firstVarNode->name !== $secondVarNode->name) { return null; } - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name($newMethodName), [new \PhpParser\Node\Arg($firstVarNode)]); + return new FuncCall(new Name($newMethodName), [new Arg($firstVarNode)]); } } diff --git a/rules/Php71/NodeAnalyzer/CountableAnalyzer.php b/rules/Php71/NodeAnalyzer/CountableAnalyzer.php index 02d76338105..d2d2e0a7ff0 100644 --- a/rules/Php71/NodeAnalyzer/CountableAnalyzer.php +++ b/rules/Php71/NodeAnalyzer/CountableAnalyzer.php @@ -57,7 +57,7 @@ final class CountableAnalyzer * @var \Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector */ private $constructorAssignDetector; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector $constructorAssignDetector) + public function __construct(NodeTypeResolver $nodeTypeResolver, NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider, BetterNodeFinder $betterNodeFinder, PropertyFetchAnalyzer $propertyFetchAnalyzer, ConstructorAssignDetector $constructorAssignDetector) { $this->nodeTypeResolver = $nodeTypeResolver; $this->nodeNameResolver = $nodeNameResolver; @@ -66,24 +66,24 @@ final class CountableAnalyzer $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; $this->constructorAssignDetector = $constructorAssignDetector; } - public function isCastableArrayType(\PhpParser\Node\Expr $expr, \PHPStan\Type\ArrayType $arrayType) : bool + public function isCastableArrayType(Expr $expr, ArrayType $arrayType) : bool { if (!$this->propertyFetchAnalyzer->isPropertyFetch($expr)) { return \false; } - if ($arrayType instanceof \PHPStan\Type\Constant\ConstantArrayType) { + if ($arrayType instanceof ConstantArrayType) { return \false; } /** @var StaticPropertyFetch|PropertyFetch $expr */ - $callerObjectType = $expr instanceof \PhpParser\Node\Expr\StaticPropertyFetch ? $this->nodeTypeResolver->getType($expr->class) : $this->nodeTypeResolver->getType($expr->var); + $callerObjectType = $expr instanceof StaticPropertyFetch ? $this->nodeTypeResolver->getType($expr->class) : $this->nodeTypeResolver->getType($expr->var); $propertyName = $this->nodeNameResolver->getName($expr->name); if (!\is_string($propertyName)) { return \false; } - if ($callerObjectType instanceof \PHPStan\Type\UnionType) { + if ($callerObjectType instanceof UnionType) { $callerObjectType = $callerObjectType->getTypes()[0]; } - if (!$callerObjectType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$callerObjectType instanceof TypeWithClassName) { return \false; } if ($this->isCallerObjectClassNameStmtOrArray($callerObjectType)) { @@ -97,7 +97,7 @@ final class CountableAnalyzer return \false; } $phpPropertyReflection = $this->resolveProperty($expr, $classReflection, $propertyName); - if (!$phpPropertyReflection instanceof \PHPStan\Reflection\Php\PhpPropertyReflection) { + if (!$phpPropertyReflection instanceof PhpPropertyReflection) { return \false; } $nativeType = $phpPropertyReflection->getNativeType(); @@ -107,26 +107,26 @@ final class CountableAnalyzer $propertyDefaultValue = $propertiesDefaults[$propertyName]; return $propertyDefaultValue === null; } - private function isCallerObjectClassNameStmtOrArray(\PHPStan\Type\TypeWithClassName $typeWithClassName) : bool + private function isCallerObjectClassNameStmtOrArray(TypeWithClassName $typeWithClassName) : bool { - if (\is_a($typeWithClassName->getClassName(), \PhpParser\Node\Stmt::class, \true)) { + if (\is_a($typeWithClassName->getClassName(), Stmt::class, \true)) { return \true; } - return \is_a($typeWithClassName->getClassName(), \PhpParser\Node\Expr\Array_::class, \true); + return \is_a($typeWithClassName->getClassName(), Array_::class, \true); } /** * @param \PhpParser\Node\Expr\StaticPropertyFetch|\PhpParser\Node\Expr\PropertyFetch $propertyFetch */ - private function isIterableOrFilledAtConstruct(\PHPStan\Type\Type $nativeType, $propertyFetch) : bool + private function isIterableOrFilledAtConstruct(Type $nativeType, $propertyFetch) : bool { if ($nativeType->isIterable()->yes()) { return \true; } - $classLike = $this->betterNodeFinder->findParentType($propertyFetch, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($propertyFetch, ClassLike::class); + if (!$classLike instanceof ClassLike) { return \false; } - if ($propertyFetch->name instanceof \PhpParser\Node\Expr) { + if ($propertyFetch->name instanceof Expr) { return \false; } $propertyName = (string) $this->nodeNameResolver->getName($propertyFetch->name); @@ -135,10 +135,10 @@ final class CountableAnalyzer /** * @param \PhpParser\Node\Expr\StaticPropertyFetch|\PhpParser\Node\Expr\PropertyFetch $propertyFetch */ - private function resolveProperty($propertyFetch, \PHPStan\Reflection\ClassReflection $classReflection, string $propertyName) : ?\PHPStan\Reflection\PropertyReflection + private function resolveProperty($propertyFetch, ClassReflection $classReflection, string $propertyName) : ?PropertyReflection { - $scope = $propertyFetch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { + $scope = $propertyFetch->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { return null; } return $classReflection->getProperty($propertyName, $scope); diff --git a/rules/Php71/Rector/Assign/AssignArrayToStringRector.php b/rules/Php71/Rector/Assign/AssignArrayToStringRector.php index e98a103bfb8..044603a9426 100644 --- a/rules/Php71/Rector/Assign/AssignArrayToStringRector.php +++ b/rules/Php71/Rector/Assign/AssignArrayToStringRector.php @@ -17,22 +17,22 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://stackoverflow.com/a/41000866/1348344 https://3v4l.org/ABDNv * * @see \Rector\Tests\Php71\Rector\Assign\AssignArrayToStringRector\AssignArrayToStringRectorTest */ -final class AssignArrayToStringRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class AssignArrayToStringRector extends AbstractRector implements MinPhpVersionInterface { public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NO_ASSIGN_ARRAY_TO_STRING; + return PhpVersionFeature::NO_ASSIGN_ARRAY_TO_STRING; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('String cannot be turned into array by assignment anymore', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('String cannot be turned into array by assignment anymore', [new CodeSample(<<<'CODE_SAMPLE' $string = ''; $string[] = 1; CODE_SAMPLE @@ -47,15 +47,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Assign::class, \PhpParser\Node\Stmt\Property::class]; + return [Assign::class, Property::class]; } /** * @param Assign|Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $defaultExpr = $this->resolveDefaultValueExpr($node); - if (!$defaultExpr instanceof \PhpParser\Node\Expr) { + if (!$defaultExpr instanceof Expr) { return null; } if (!$this->isEmptyString($defaultExpr)) { @@ -68,12 +68,12 @@ CODE_SAMPLE $exprUsages = $this->betterNodeFinder->findSameNamedExprs($assignedVar); // detect if is part of variable assign? foreach ($exprUsages as $exprUsage) { - $parent = $exprUsage->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + $parent = $exprUsage->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof ArrayDimFetch) { continue; } - $firstAssign = $this->betterNodeFinder->findParentType($parent, \PhpParser\Node\Expr\Assign::class); - if (!$firstAssign instanceof \PhpParser\Node\Expr\Assign) { + $firstAssign = $this->betterNodeFinder->findParentType($parent, Assign::class); + if (!$firstAssign instanceof Assign) { continue; } // skip explicit assigns @@ -86,26 +86,26 @@ CODE_SAMPLE if (!$shouldRetype) { return null; } - if ($node instanceof \PhpParser\Node\Stmt\Property) { - $node->props[0]->default = new \PhpParser\Node\Expr\Array_(); + if ($node instanceof Property) { + $node->props[0]->default = new Array_(); return $node; } - $node->expr = new \PhpParser\Node\Expr\Array_(); + $node->expr = new Array_(); return $node; } /** * @param \PhpParser\Node\Expr\Assign|\PhpParser\Node\Stmt\Property $node */ - private function resolveDefaultValueExpr($node) : ?\PhpParser\Node\Expr + private function resolveDefaultValueExpr($node) : ?Expr { - if ($node instanceof \PhpParser\Node\Stmt\Property) { + if ($node instanceof Property) { return $node->props[0]->default; } return $node->expr; } - private function isEmptyString(\PhpParser\Node\Expr $expr) : bool + private function isEmptyString(Expr $expr) : bool { - if (!$expr instanceof \PhpParser\Node\Scalar\String_) { + if (!$expr instanceof String_) { return \false; } return $expr->value === ''; @@ -116,7 +116,7 @@ CODE_SAMPLE */ private function resolveAssignedVar($node) { - if ($node instanceof \PhpParser\Node\Expr\Assign) { + if ($node instanceof Assign) { return $node->var; } return $node; diff --git a/rules/Php71/Rector/BinaryOp/BinaryOpBetweenNumberAndStringRector.php b/rules/Php71/Rector/BinaryOp/BinaryOpBetweenNumberAndStringRector.php index 8462c248d4c..3dd38500e24 100644 --- a/rules/Php71/Rector/BinaryOp/BinaryOpBetweenNumberAndStringRector.php +++ b/rules/Php71/Rector/BinaryOp/BinaryOpBetweenNumberAndStringRector.php @@ -18,31 +18,31 @@ use Rector\Core\NodeAnalyzer\ExprAnalyzer; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/XPEEl * @changelog https://3v4l.org/ObNQZ * @see \Rector\Tests\Php71\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector\BinaryOpBetweenNumberAndStringRectorTest */ -final class BinaryOpBetweenNumberAndStringRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class BinaryOpBetweenNumberAndStringRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\Core\NodeAnalyzer\ExprAnalyzer */ private $exprAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ExprAnalyzer $exprAnalyzer) + public function __construct(ExprAnalyzer $exprAnalyzer) { $this->exprAnalyzer = $exprAnalyzer; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::BINARY_OP_NUMBER_STRING; + return PhpVersionFeature::BINARY_OP_NUMBER_STRING; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change binary operation between some number + string to PHP 7.1 compatible version', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change binary operation between some number + string to PHP 7.1 compatible version', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -69,17 +69,17 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp::class]; + return [BinaryOp::class]; } /** * @param BinaryOp $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\Concat) { + if ($node instanceof Concat) { return null; } - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\Coalesce) { + if ($node instanceof Coalesce) { return null; } if ($this->exprAnalyzer->isNonTypedFromParam($node->left)) { @@ -89,29 +89,29 @@ CODE_SAMPLE return null; } if ($this->isStringOrStaticNonNumbericString($node->left) && $this->nodeTypeResolver->isNumberType($node->right)) { - $node->left = new \PhpParser\Node\Scalar\LNumber(0); + $node->left = new LNumber(0); return $node; } if ($this->isStringOrStaticNonNumbericString($node->right) && $this->nodeTypeResolver->isNumberType($node->left)) { - $node->right = new \PhpParser\Node\Scalar\LNumber(0); + $node->right = new LNumber(0); return $node; } return null; } - private function isStringOrStaticNonNumbericString(\PhpParser\Node\Expr $expr) : bool + private function isStringOrStaticNonNumbericString(Expr $expr) : bool { // replace only scalar values, not variables/constants/etc. - if (!$expr instanceof \PhpParser\Node\Scalar && !$expr instanceof \PhpParser\Node\Expr\Variable) { + if (!$expr instanceof Scalar && !$expr instanceof Variable) { return \false; } - if ($expr instanceof \PhpParser\Node\Scalar\MagicConst\Line) { + if ($expr instanceof Line) { return \false; } $value = null; $exprStaticType = $this->getType($expr); - if ($expr instanceof \PhpParser\Node\Scalar\String_) { + if ($expr instanceof String_) { $value = $expr->value; - } elseif ($exprStaticType instanceof \PHPStan\Type\Constant\ConstantStringType) { + } elseif ($exprStaticType instanceof ConstantStringType) { $value = $exprStaticType->getValue(); } else { return \false; diff --git a/rules/Php71/Rector/BooleanOr/IsIterableRector.php b/rules/Php71/Rector/BooleanOr/IsIterableRector.php index 86088cdcf02..ae0a0abd955 100644 --- a/rules/Php71/Rector/BooleanOr/IsIterableRector.php +++ b/rules/Php71/Rector/BooleanOr/IsIterableRector.php @@ -12,12 +12,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Php71\IsArrayAndDualCheckToAble; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php71\Rector\BooleanOr\IsIterableRector\IsIterableRectorTest */ -final class IsIterableRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class IsIterableRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -34,7 +34,7 @@ final class IsIterableRector extends \Rector\Core\Rector\AbstractRector implemen * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Php71\IsArrayAndDualCheckToAble $isArrayAndDualCheckToAble, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(IsArrayAndDualCheckToAble $isArrayAndDualCheckToAble, ReflectionProvider $reflectionProvider, PhpVersionProvider $phpVersionProvider) { $this->isArrayAndDualCheckToAble = $isArrayAndDualCheckToAble; $this->reflectionProvider = $reflectionProvider; @@ -42,23 +42,23 @@ final class IsIterableRector extends \Rector\Core\Rector\AbstractRector implemen } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::IS_ITERABLE; + return PhpVersionFeature::IS_ITERABLE; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes is_array + Traversable check to is_iterable', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('is_array($foo) || $foo instanceof Traversable;', 'is_iterable($foo);')]); + return new RuleDefinition('Changes is_array + Traversable check to is_iterable', [new CodeSample('is_array($foo) || $foo instanceof Traversable;', 'is_iterable($foo);')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\BooleanOr::class]; + return [BooleanOr::class]; } /** * @param BooleanOr $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip()) { return null; @@ -67,9 +67,9 @@ final class IsIterableRector extends \Rector\Core\Rector\AbstractRector implemen } private function shouldSkip() : bool { - if ($this->reflectionProvider->hasFunction(new \PhpParser\Node\Name('is_iterable'), null)) { + if ($this->reflectionProvider->hasFunction(new Name('is_iterable'), null)) { return \false; } - return !$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::IS_ITERABLE); + return !$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::IS_ITERABLE); } } diff --git a/rules/Php71/Rector/ClassConst/PublicConstantVisibilityRector.php b/rules/Php71/Rector/ClassConst/PublicConstantVisibilityRector.php index e05b1251cf7..f53960c9b48 100644 --- a/rules/Php71/Rector/ClassConst/PublicConstantVisibilityRector.php +++ b/rules/Php71/Rector/ClassConst/PublicConstantVisibilityRector.php @@ -9,27 +9,27 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Privatization\NodeManipulator\VisibilityManipulator; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/class_const_visibility * * @see \Rector\Tests\Php71\Rector\ClassConst\PublicConstantVisibilityRector\PublicConstantVisibilityRectorTest */ -final class PublicConstantVisibilityRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class PublicConstantVisibilityRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\Privatization\NodeManipulator\VisibilityManipulator */ private $visibilityManipulator; - public function __construct(\Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator) + public function __construct(VisibilityManipulator $visibilityManipulator) { $this->visibilityManipulator = $visibilityManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add explicit public constant visibility.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add explicit public constant visibility.', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { const HEY = 'you'; @@ -48,12 +48,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassConst::class]; + return [ClassConst::class]; } /** * @param ClassConst $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { // already non-public if (!$node->isPublic()) { @@ -68,6 +68,6 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::CONSTANT_VISIBILITY; + return PhpVersionFeature::CONSTANT_VISIBILITY; } } diff --git a/rules/Php71/Rector/FuncCall/CountOnNullRector.php b/rules/Php71/Rector/FuncCall/CountOnNullRector.php index e98b026344b..69bccb724d1 100644 --- a/rules/Php71/Rector/FuncCall/CountOnNullRector.php +++ b/rules/Php71/Rector/FuncCall/CountOnNullRector.php @@ -30,14 +30,14 @@ use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\NodeTypeResolver\TypeAnalyzer\CountableTypeAnalyzer; use Rector\Php71\NodeAnalyzer\CountableAnalyzer; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/Bndc9 * * @see \Rector\Tests\Php71\Rector\FuncCall\CountOnNullRector\CountOnNullRectorTest */ -final class CountOnNullRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class CountOnNullRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -59,7 +59,7 @@ final class CountOnNullRector extends \Rector\Core\Rector\AbstractRector impleme * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\NodeTypeResolver\TypeAnalyzer\CountableTypeAnalyzer $countableTypeAnalyzer, \Rector\Php71\NodeAnalyzer\CountableAnalyzer $countableAnalyzer, \Rector\Core\NodeAnalyzer\VariableAnalyzer $variableAnalyzer, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(CountableTypeAnalyzer $countableTypeAnalyzer, CountableAnalyzer $countableAnalyzer, VariableAnalyzer $variableAnalyzer, PhpVersionProvider $phpVersionProvider) { $this->countableTypeAnalyzer = $countableTypeAnalyzer; $this->countableAnalyzer = $countableAnalyzer; @@ -68,11 +68,11 @@ final class CountOnNullRector extends \Rector\Core\Rector\AbstractRector impleme } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::COUNT_ON_NULL; + return PhpVersionFeature::COUNT_ON_NULL; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes count() on null to safe ternary check', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes count() on null to safe ternary check', [new CodeSample(<<<'CODE_SAMPLE' $values = null; $count = count($values); CODE_SAMPLE @@ -87,12 +87,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -105,37 +105,37 @@ CODE_SAMPLE } // this can lead to false positive by phpstan, but that's best we can do $onlyValueType = $this->getType($countedNode); - if ($onlyValueType instanceof \PHPStan\Type\ArrayType) { + if ($onlyValueType instanceof ArrayType) { if (!$this->countableAnalyzer->isCastableArrayType($countedNode, $onlyValueType)) { return null; } return $this->castToArray($countedNode, $node); } - if ($this->nodeTypeResolver->isNullableTypeOfSpecificType($countedNode, \PHPStan\Type\ArrayType::class)) { + if ($this->nodeTypeResolver->isNullableTypeOfSpecificType($countedNode, ArrayType::class)) { return $this->castToArray($countedNode, $node); } $countedType = $this->getType($countedNode); if ($this->isAlwaysIterableType($countedType)) { return null; } - if ($this->nodeTypeResolver->isNullableType($countedNode) || $countedType instanceof \PHPStan\Type\NullType) { - $identical = new \PhpParser\Node\Expr\BinaryOp\Identical($countedNode, $this->nodeFactory->createNull()); - return new \PhpParser\Node\Expr\Ternary($identical, new \PhpParser\Node\Scalar\LNumber(0), $node); + if ($this->nodeTypeResolver->isNullableType($countedNode) || $countedType instanceof NullType) { + $identical = new Identical($countedNode, $this->nodeFactory->createNull()); + return new Ternary($identical, new LNumber(0), $node); } - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::IS_COUNTABLE)) { - $conditionNode = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('is_countable'), [new \PhpParser\Node\Arg($countedNode)]); + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::IS_COUNTABLE)) { + $conditionNode = new FuncCall(new Name('is_countable'), [new Arg($countedNode)]); } else { - $instanceof = new \PhpParser\Node\Expr\Instanceof_($countedNode, new \PhpParser\Node\Name\FullyQualified('Countable')); - $conditionNode = new \PhpParser\Node\Expr\BinaryOp\BooleanOr($this->nodeFactory->createFuncCall('is_array', [new \PhpParser\Node\Arg($countedNode)]), $instanceof); + $instanceof = new Instanceof_($countedNode, new FullyQualified('Countable')); + $conditionNode = new BooleanOr($this->nodeFactory->createFuncCall('is_array', [new Arg($countedNode)]), $instanceof); } - return new \PhpParser\Node\Expr\Ternary($conditionNode, $node, new \PhpParser\Node\Scalar\LNumber(0)); + return new Ternary($conditionNode, $node, new LNumber(0)); } - private function isAlwaysIterableType(\PHPStan\Type\Type $possibleUnionType) : bool + private function isAlwaysIterableType(Type $possibleUnionType) : bool { if ($possibleUnionType->isIterable()->yes()) { return \true; } - if (!$possibleUnionType instanceof \PHPStan\Type\UnionType) { + if (!$possibleUnionType instanceof UnionType) { return \false; } $types = $possibleUnionType->getTypes(); @@ -146,7 +146,7 @@ CODE_SAMPLE } return \true; } - private function shouldSkip(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function shouldSkip(FuncCall $funcCall) : bool { if (!$this->isName($funcCall, 'count')) { return \true; @@ -154,30 +154,30 @@ CODE_SAMPLE if (!isset($funcCall->args[0])) { return \true; } - if (!$funcCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[0] instanceof Arg) { return \true; } - if ($funcCall->args[0]->value instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if ($funcCall->args[0]->value instanceof ClassConstFetch) { return \true; } - $parentNode = $funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentNode instanceof \PhpParser\Node\Expr\Ternary) { + $parentNode = $funcCall->getAttribute(AttributeKey::PARENT_NODE); + if ($parentNode instanceof Ternary) { return \true; } // skip node in trait, as impossible to analyse - $trait = $this->betterNodeFinder->findParentType($funcCall, \PhpParser\Node\Stmt\Trait_::class); - if ($trait instanceof \PhpParser\Node\Stmt\Trait_) { + $trait = $this->betterNodeFinder->findParentType($funcCall, Trait_::class); + if ($trait instanceof Trait_) { return \true; } - if (!$funcCall->args[0]->value instanceof \PhpParser\Node\Expr\Variable) { + if (!$funcCall->args[0]->value instanceof Variable) { return \false; } return $this->variableAnalyzer->isStaticOrGlobal($funcCall->args[0]->value); } - private function castToArray(\PhpParser\Node\Expr $countedExpr, \PhpParser\Node\Expr\FuncCall $funcCall) : \PhpParser\Node\Expr\FuncCall + private function castToArray(Expr $countedExpr, FuncCall $funcCall) : FuncCall { - $castArray = new \PhpParser\Node\Expr\Cast\Array_($countedExpr); - $funcCall->args = [new \PhpParser\Node\Arg($castArray)]; + $castArray = new Array_($countedExpr); + $funcCall->args = [new Arg($castArray)]; return $funcCall; } } diff --git a/rules/Php71/Rector/FuncCall/RemoveExtraParametersRector.php b/rules/Php71/Rector/FuncCall/RemoveExtraParametersRector.php index 6bb416d4b9c..5f69c2ead82 100644 --- a/rules/Php71/Rector/FuncCall/RemoveExtraParametersRector.php +++ b/rules/Php71/Rector/FuncCall/RemoveExtraParametersRector.php @@ -18,15 +18,15 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.reddit.com/r/PHP/comments/a1ie7g/is_there_a_linter_for_argumentcounterror_for_php/ * @changelog http://php.net/manual/en/class.argumentcounterror.php * * @see \Rector\Tests\Php71\Rector\FuncCall\RemoveExtraParametersRector\RemoveExtraParametersRectorTest */ -final class RemoveExtraParametersRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class RemoveExtraParametersRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -38,43 +38,43 @@ final class RemoveExtraParametersRector extends \Rector\Core\Rector\AbstractRect * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Core\NodeAnalyzer\VariadicAnalyzer $variadicAnalyzer, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(VariadicAnalyzer $variadicAnalyzer, ReflectionResolver $reflectionResolver) { $this->variadicAnalyzer = $variadicAnalyzer; $this->reflectionResolver = $reflectionResolver; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NO_EXTRA_PARAMETERS; + return PhpVersionFeature::NO_EXTRA_PARAMETERS; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove extra parameters', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('strlen("asdf", 1);', 'strlen("asdf");')]); + return new RuleDefinition('Remove extra parameters', [new CodeSample('strlen("asdf", 1);', 'strlen("asdf");')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [FuncCall::class, MethodCall::class, StaticCall::class]; } /** * @param FuncCall|MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } // unreliable count of arguments $functionLikeReflection = $this->reflectionResolver->resolveFunctionLikeReflectionFromCall($node); - if ($functionLikeReflection instanceof \PHPStan\Reflection\Type\UnionTypeMethodReflection) { + if ($functionLikeReflection instanceof UnionTypeMethodReflection) { return null; } if ($functionLikeReflection === null) { return null; } - if ($functionLikeReflection instanceof \PHPStan\Reflection\Php\PhpMethodReflection) { + if ($functionLikeReflection instanceof PhpMethodReflection) { $classReflection = $functionLikeReflection->getDeclaringClass(); if ($classReflection->isInterface()) { return null; @@ -99,11 +99,11 @@ final class RemoveExtraParametersRector extends \Rector\Core\Rector\AbstractRect if ($call->args === []) { return \true; } - if ($call instanceof \PhpParser\Node\Expr\StaticCall) { - if (!$call->class instanceof \PhpParser\Node\Name) { + if ($call instanceof StaticCall) { + if (!$call->class instanceof Name) { return \true; } - if ($this->isName($call->class, \Rector\Core\Enum\ObjectReference::PARENT)) { + if ($this->isName($call->class, ObjectReference::PARENT)) { return \true; } } diff --git a/rules/Php71/Rector/List_/ListToArrayDestructRector.php b/rules/Php71/Rector/List_/ListToArrayDestructRector.php index 109828c4edc..669f353c08c 100644 --- a/rules/Php71/Rector/List_/ListToArrayDestructRector.php +++ b/rules/Php71/Rector/List_/ListToArrayDestructRector.php @@ -12,18 +12,18 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/short_list_syntax https://www.php.net/manual/en/migration71.new-features.php#migration71.new-features.symmetric-array-destructuring * * @see \Rector\Tests\Php71\Rector\List_\ListToArrayDestructRector\ListToArrayDestructRectorTest */ -final class ListToArrayDestructRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ListToArrayDestructRector extends AbstractRector implements MinPhpVersionInterface { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change list() to array destruct', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change list() to array destruct', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -54,27 +54,27 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\List_::class]; + return [List_::class]; } /** * @param List_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentNode instanceof \PhpParser\Node\Expr\Assign && $parentNode->var === $node) { - return new \PhpParser\Node\Expr\Array_($node->items); + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); + if ($parentNode instanceof Assign && $parentNode->var === $node) { + return new Array_($node->items); } - if (!$parentNode instanceof \PhpParser\Node\Stmt\Foreach_) { + if (!$parentNode instanceof Foreach_) { return null; } if ($parentNode->valueVar !== $node) { return null; } - return new \PhpParser\Node\Expr\Array_($node->items); + return new Array_($node->items); } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::ARRAY_DESTRUCT; + return PhpVersionFeature::ARRAY_DESTRUCT; } } diff --git a/rules/Php71/Rector/Name/ReservedObjectRector.php b/rules/Php71/Rector/Name/ReservedObjectRector.php index 1711baa4739..82afb2b015e 100644 --- a/rules/Php71/Rector/Name/ReservedObjectRector.php +++ b/rules/Php71/Rector/Name/ReservedObjectRector.php @@ -12,15 +12,15 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @changelog https://wiki.php.net/rfc/object-typehint https://github.com/cebe/yii2/commit/9548a212ecf6e50fcdb0e5ba6daad88019cfc544 * * @see \Rector\Tests\Php71\Rector\Name\ReservedObjectRector\ReservedObjectRectorTest */ -final class ReservedObjectRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface, \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ReservedObjectRector extends AbstractRector implements ConfigurableRectorInterface, MinPhpVersionInterface { /** * @var array @@ -28,11 +28,11 @@ final class ReservedObjectRector extends \Rector\Core\Rector\AbstractRector impl private $reservedKeywordsToReplacements = []; public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::RESERVED_OBJECT_KEYWORD; + return PhpVersionFeature::RESERVED_OBJECT_KEYWORD; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes reserved "Object" name to "Object" where can be configured', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes reserved "Object" name to "Object" where can be configured', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class Object { } @@ -49,14 +49,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Identifier::class, \PhpParser\Node\Name::class]; + return [Identifier::class, Name::class]; } /** * @param Identifier|Name $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Identifier) { + if ($node instanceof Identifier) { return $this->processIdentifier($node); } return $this->processName($node); @@ -66,11 +66,11 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString(\array_keys($configuration)); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configuration); + Assert::allString(\array_keys($configuration)); + Assert::allString($configuration); $this->reservedKeywordsToReplacements = $configuration; } - private function processIdentifier(\PhpParser\Node\Identifier $identifier) : \PhpParser\Node\Identifier + private function processIdentifier(Identifier $identifier) : Identifier { foreach ($this->reservedKeywordsToReplacements as $reservedKeyword => $replacement) { if (!$this->isName($identifier, $reservedKeyword)) { @@ -81,12 +81,12 @@ CODE_SAMPLE } return $identifier; } - private function processName(\PhpParser\Node\Name $name) : \PhpParser\Node\Name + private function processName(Name $name) : Name { // we look for "extends " - $parentNode = $name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $name->getAttribute(AttributeKey::PARENT_NODE); // "Object" can part of namespace name - if ($parentNode instanceof \PhpParser\Node\Stmt\Namespace_) { + if ($parentNode instanceof Namespace_) { return $name; } // process lass part @@ -94,7 +94,7 @@ CODE_SAMPLE if (\strtolower($name->getLast()) === \strtolower($reservedKeyword)) { $name->parts[\count($name->parts) - 1] = $replacement; // invoke override - $name->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $name->setAttribute(AttributeKey::ORIGINAL_NODE, null); } } return $name; diff --git a/rules/Php71/Rector/TryCatch/MultiExceptionCatchRector.php b/rules/Php71/Rector/TryCatch/MultiExceptionCatchRector.php index 22b3f8208e4..a57bf8bf367 100644 --- a/rules/Php71/Rector/TryCatch/MultiExceptionCatchRector.php +++ b/rules/Php71/Rector/TryCatch/MultiExceptionCatchRector.php @@ -11,27 +11,27 @@ use Rector\Core\Contract\PhpParser\NodePrinterInterface; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/multiple-catch * * @see \Rector\Tests\Php71\Rector\TryCatch\MultiExceptionCatchRector\MultiExceptionCatchRectorTest */ -final class MultiExceptionCatchRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class MultiExceptionCatchRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\Core\Contract\PhpParser\NodePrinterInterface */ private $nodePrinter; - public function __construct(\Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter) + public function __construct(NodePrinterInterface $nodePrinter) { $this->nodePrinter = $nodePrinter; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes multi catch of same exception to single one | separated.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes multi catch of same exception to single one | separated.', [new CodeSample(<<<'CODE_SAMPLE' try { // Some code... } catch (ExceptionType1 $exception) { @@ -54,12 +54,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\TryCatch::class]; + return [TryCatch::class]; } /** * @param TryCatch $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (\count($node->catches) < 2) { return null; @@ -89,12 +89,12 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::MULTI_EXCEPTION_CATCH; + return PhpVersionFeature::MULTI_EXCEPTION_CATCH; } /** * @return array */ - private function collectCatchKeysByContent(\PhpParser\Node\Stmt\TryCatch $tryCatch) : array + private function collectCatchKeysByContent(TryCatch $tryCatch) : array { $catchKeysByContent = []; foreach ($tryCatch->catches as $catch) { diff --git a/rules/Php71/ValueObject/TwoNodeMatch.php b/rules/Php71/ValueObject/TwoNodeMatch.php index 41f665a662e..57837d27f1b 100644 --- a/rules/Php71/ValueObject/TwoNodeMatch.php +++ b/rules/Php71/ValueObject/TwoNodeMatch.php @@ -16,16 +16,16 @@ final class TwoNodeMatch * @var \PhpParser\Node\Expr */ private $secondExpr; - public function __construct(\PhpParser\Node\Expr $firstExpr, \PhpParser\Node\Expr $secondExpr) + public function __construct(Expr $firstExpr, Expr $secondExpr) { $this->firstExpr = $firstExpr; $this->secondExpr = $secondExpr; } - public function getFirstExpr() : \PhpParser\Node\Expr + public function getFirstExpr() : Expr { return $this->firstExpr; } - public function getSecondExpr() : \PhpParser\Node\Expr + public function getSecondExpr() : Expr { return $this->secondExpr; } diff --git a/rules/Php72/NodeFactory/AnonymousFunctionFactory.php b/rules/Php72/NodeFactory/AnonymousFunctionFactory.php index 03b928accae..fc95bd5f982 100644 --- a/rules/Php72/NodeFactory/AnonymousFunctionFactory.php +++ b/rules/Php72/NodeFactory/AnonymousFunctionFactory.php @@ -108,7 +108,7 @@ final class AnonymousFunctionFactory * @var \Symplify\PackageBuilder\Reflection\PrivatesAccessor */ private $privatesAccessor; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\Core\PhpParser\Parser\SimplePhpParser $simplePhpParser, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\PhpParser\AstResolver $astResolver, \Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter, \RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor $privatesAccessor) + public function __construct(NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder, NodeFactory $nodeFactory, StaticTypeMapper $staticTypeMapper, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, SimplePhpParser $simplePhpParser, NodeComparator $nodeComparator, AstResolver $astResolver, NodePrinterInterface $nodePrinter, PrivatesAccessor $privatesAccessor) { $this->nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; @@ -126,73 +126,73 @@ final class AnonymousFunctionFactory * @param Stmt[] $stmts * @param \PhpParser\Node\Identifier|\PhpParser\Node\Name|\PhpParser\Node\NullableType|\PhpParser\Node\UnionType|\PhpParser\Node\ComplexType|null $returnTypeNode */ - public function create(array $params, array $stmts, $returnTypeNode, bool $static = \false) : \PhpParser\Node\Expr\Closure + public function create(array $params, array $stmts, $returnTypeNode, bool $static = \false) : Closure { $useVariables = $this->createUseVariablesFromParams($stmts, $params); - $anonymousFunctionNode = new \PhpParser\Node\Expr\Closure(); + $anonymousFunctionNode = new Closure(); $anonymousFunctionNode->params = $params; if ($static) { $anonymousFunctionNode->static = $static; } foreach ($useVariables as $useVariable) { $anonymousFunctionNode = $this->applyNestedUses($anonymousFunctionNode, $useVariable); - $anonymousFunctionNode->uses[] = new \PhpParser\Node\Expr\ClosureUse($useVariable); + $anonymousFunctionNode->uses[] = new ClosureUse($useVariable); } - if ($returnTypeNode instanceof \PhpParser\Node) { + if ($returnTypeNode instanceof Node) { $anonymousFunctionNode->returnType = $returnTypeNode; } $anonymousFunctionNode->stmts = $stmts; return $anonymousFunctionNode; } - public function createFromPhpMethodReflection(\PHPStan\Reflection\Php\PhpMethodReflection $phpMethodReflection, \PhpParser\Node\Expr $expr) : ?\PhpParser\Node\Expr\Closure + public function createFromPhpMethodReflection(PhpMethodReflection $phpMethodReflection, Expr $expr) : ?Closure { /** @var FunctionVariantWithPhpDocs $functionVariantWithPhpDoc */ - $functionVariantWithPhpDoc = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($phpMethodReflection->getVariants()); - $anonymousFunction = new \PhpParser\Node\Expr\Closure(); + $functionVariantWithPhpDoc = ParametersAcceptorSelector::selectSingle($phpMethodReflection->getVariants()); + $anonymousFunction = new Closure(); $newParams = $this->createParams($phpMethodReflection, $functionVariantWithPhpDoc->getParameters()); $anonymousFunction->params = $newParams; $innerMethodCall = $this->createInnerMethodCall($phpMethodReflection, $expr, $newParams); if ($innerMethodCall === null) { return null; } - if (!$functionVariantWithPhpDoc->getReturnType() instanceof \PHPStan\Type\MixedType) { - $returnType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($functionVariantWithPhpDoc->getReturnType(), \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN); + if (!$functionVariantWithPhpDoc->getReturnType() instanceof MixedType) { + $returnType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($functionVariantWithPhpDoc->getReturnType(), TypeKind::RETURN); $anonymousFunction->returnType = $returnType; } // does method return something? - $anonymousFunction->stmts[] = $functionVariantWithPhpDoc->getReturnType() instanceof \PHPStan\Type\VoidType ? new \PhpParser\Node\Stmt\Expression($innerMethodCall) : new \PhpParser\Node\Stmt\Return_($innerMethodCall); - if ($expr instanceof \PhpParser\Node\Expr\Variable && !$this->nodeNameResolver->isName($expr, 'this')) { - $anonymousFunction->uses[] = new \PhpParser\Node\Expr\ClosureUse($expr); + $anonymousFunction->stmts[] = $functionVariantWithPhpDoc->getReturnType() instanceof VoidType ? new Expression($innerMethodCall) : new Return_($innerMethodCall); + if ($expr instanceof Variable && !$this->nodeNameResolver->isName($expr, 'this')) { + $anonymousFunction->uses[] = new ClosureUse($expr); } return $anonymousFunction; } - public function createAnonymousFunctionFromString(\PhpParser\Node\Expr $expr) : ?\PhpParser\Node\Expr\Closure + public function createAnonymousFunctionFromString(Expr $expr) : ?Closure { - if (!$expr instanceof \PhpParser\Node\Scalar\String_) { + if (!$expr instanceof String_) { // not supported yet - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $phpCode = 'value . ';'; $contentStmts = $this->simplePhpParser->parseString($phpCode); - $anonymousFunction = new \PhpParser\Node\Expr\Closure(); + $anonymousFunction = new Closure(); $firstNode = $contentStmts[0] ?? null; - if (!$firstNode instanceof \PhpParser\Node\Stmt\Expression) { + if (!$firstNode instanceof Expression) { return null; } $stmt = $firstNode->expr; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmt, function (\PhpParser\Node $node) : Node { - if (!$node instanceof \PhpParser\Node\Scalar\String_) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmt, function (Node $node) : Node { + if (!$node instanceof String_) { return $node; } - $match = \RectorPrefix20220607\Nette\Utils\Strings::match($node->value, self::DIM_FETCH_REGEX); + $match = Strings::match($node->value, self::DIM_FETCH_REGEX); if ($match === null) { return $node; } - $matchesVariable = new \PhpParser\Node\Expr\Variable('matches'); - return new \PhpParser\Node\Expr\ArrayDimFetch($matchesVariable, new \PhpParser\Node\Scalar\LNumber((int) $match['number'])); + $matchesVariable = new Variable('matches'); + return new ArrayDimFetch($matchesVariable, new LNumber((int) $match['number'])); }); - $anonymousFunction->stmts[] = new \PhpParser\Node\Stmt\Return_($stmt); - $anonymousFunction->params[] = new \PhpParser\Node\Param(new \PhpParser\Node\Expr\Variable('matches')); + $anonymousFunction->stmts[] = new Return_($stmt); + $anonymousFunction->params[] = new Param(new Variable('matches')); return $anonymousFunction; } /** @@ -214,10 +214,10 @@ final class AnonymousFunctionFactory } return \array_values($uniqueUses); } - private function applyNestedUses(\PhpParser\Node\Expr\Closure $anonymousFunctionNode, \PhpParser\Node\Expr\Variable $useVariable) : \PhpParser\Node\Expr\Closure + private function applyNestedUses(Closure $anonymousFunctionNode, Variable $useVariable) : Closure { - $parent = $this->betterNodeFinder->findParentType($useVariable, \PhpParser\Node\Expr\Closure::class); - if (!$parent instanceof \PhpParser\Node\Expr\Closure) { + $parent = $this->betterNodeFinder->findParentType($useVariable, Closure::class); + if (!$parent instanceof Closure) { return $anonymousFunctionNode; } $paramNames = $this->nodeNameResolver->getNames($parent->params); @@ -225,17 +225,17 @@ final class AnonymousFunctionFactory return $anonymousFunctionNode; } $anonymousFunctionNode = clone $anonymousFunctionNode; - while ($parent instanceof \PhpParser\Node\Expr\Closure) { - $parentOfParent = $this->betterNodeFinder->findParentType($parent, \PhpParser\Node\Expr\Closure::class); + while ($parent instanceof Closure) { + $parentOfParent = $this->betterNodeFinder->findParentType($parent, Closure::class); $uses = []; - while ($parentOfParent instanceof \PhpParser\Node\Expr\Closure) { + while ($parentOfParent instanceof Closure) { $uses = $this->collectUsesEqual($parentOfParent, $uses, $useVariable); - $parentOfParent = $this->betterNodeFinder->findParentType($parentOfParent, \PhpParser\Node\Expr\Closure::class); + $parentOfParent = $this->betterNodeFinder->findParentType($parentOfParent, Closure::class); } $uses = \array_merge($parent->uses, $uses); $uses = $this->cleanClosureUses($uses); $parent->uses = $uses; - $parent = $this->betterNodeFinder->findParentType($parent, \PhpParser\Node\Expr\Closure::class); + $parent = $this->betterNodeFinder->findParentType($parent, Closure::class); } return $anonymousFunctionNode; } @@ -243,11 +243,11 @@ final class AnonymousFunctionFactory * @param ClosureUse[] $uses * @return ClosureUse[] */ - private function collectUsesEqual(\PhpParser\Node\Expr\Closure $closure, array $uses, \PhpParser\Node\Expr\Variable $useVariable) : array + private function collectUsesEqual(Closure $closure, array $uses, Variable $useVariable) : array { foreach ($closure->params as $param) { if ($this->nodeComparator->areNodesEqual($param->var, $useVariable)) { - $uses[] = new \PhpParser\Node\Expr\ClosureUse($param->var); + $uses[] = new ClosureUse($param->var); } } return $uses; @@ -273,7 +273,7 @@ final class AnonymousFunctionFactory { $paramNames = $this->collectParamNames($paramNodes); /** @var Variable[] $variables */ - $variables = $this->betterNodeFinder->findInstanceOf($nodes, \PhpParser\Node\Expr\Variable::class); + $variables = $this->betterNodeFinder->findInstanceOf($nodes, Variable::class); /** @var array $filteredVariables */ $filteredVariables = []; $alreadyAssignedVariables = []; @@ -289,8 +289,8 @@ final class AnonymousFunctionFactory if (\in_array($variableName, $paramNames, \true)) { continue; } - $parentNode = $variable->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentNode instanceof \PhpParser\Node && \in_array(\get_class($parentNode), [\PhpParser\Node\Expr\Assign::class, \PhpParser\Node\Stmt\Foreach_::class, \PhpParser\Node\Param::class], \true)) { + $parentNode = $variable->getAttribute(AttributeKey::PARENT_NODE); + if ($parentNode instanceof Node && \in_array(\get_class($parentNode), [Assign::class, Foreach_::class, Param::class], \true)) { $alreadyAssignedVariables[] = $variableName; } if (!$this->nodeNameResolver->isNames($variable, $alreadyAssignedVariables)) { @@ -303,7 +303,7 @@ final class AnonymousFunctionFactory * @param ParameterReflection[] $parameterReflections * @return Param[] */ - private function createParams(\PHPStan\Reflection\Php\PhpMethodReflection $phpMethodReflection, array $parameterReflections) : array + private function createParams(PhpMethodReflection $phpMethodReflection, array $parameterReflections) : array { $classReflection = $phpMethodReflection->getDeclaringClass(); $className = $classReflection->getName(); @@ -312,7 +312,7 @@ final class AnonymousFunctionFactory $classMethod = $this->astResolver->resolveClassMethod($className, $methodName); $params = []; foreach ($parameterReflections as $key => $parameterReflection) { - $param = new \PhpParser\Node\Param(new \PhpParser\Node\Expr\Variable($parameterReflection->getName())); + $param = new Param(new Variable($parameterReflection->getName())); $this->applyParamType($param, $parameterReflection); $this->applyParamDefaultValue($param, $parameterReflection, $key, $classMethod); $this->applyParamByReference($param, $parameterReflection); @@ -320,45 +320,45 @@ final class AnonymousFunctionFactory } return $params; } - private function applyParamType(\PhpParser\Node\Param $param, \PHPStan\Reflection\ParameterReflection $parameterReflection) : void + private function applyParamType(Param $param, ParameterReflection $parameterReflection) : void { - if ($parameterReflection->getType() instanceof \PHPStan\Type\MixedType) { + if ($parameterReflection->getType() instanceof MixedType) { return; } - $param->type = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($parameterReflection->getType(), \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM); + $param->type = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($parameterReflection->getType(), TypeKind::PARAM); } - private function applyParamByReference(\PhpParser\Node\Param $param, \PHPStan\Reflection\ParameterReflection $parameterReflection) : void + private function applyParamByReference(Param $param, ParameterReflection $parameterReflection) : void { /** @var ReflectionParameter $reflection */ $reflection = $this->privatesAccessor->getPrivateProperty($parameterReflection, 'reflection'); $param->byRef = $reflection->isPassedByReference(); } - private function applyParamDefaultValue(\PhpParser\Node\Param $param, \PHPStan\Reflection\ParameterReflection $parameterReflection, int $key, \PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function applyParamDefaultValue(Param $param, ParameterReflection $parameterReflection, int $key, ClassMethod $classMethod) : void { - if (!$parameterReflection->getDefaultValue() instanceof \PHPStan\Type\Type) { + if (!$parameterReflection->getDefaultValue() instanceof Type) { return; } $printDefaultValue = $this->nodePrinter->print($classMethod->params[$key]->default); - $param->default = new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name($printDefaultValue)); + $param->default = new ConstFetch(new Name($printDefaultValue)); } /** * @param Param[] $params * @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|null */ - private function createInnerMethodCall(\PHPStan\Reflection\Php\PhpMethodReflection $phpMethodReflection, \PhpParser\Node\Expr $expr, array $params) + private function createInnerMethodCall(PhpMethodReflection $phpMethodReflection, Expr $expr, array $params) { if ($phpMethodReflection->isStatic()) { $expr = $this->normalizeClassConstFetchForStatic($expr); if ($expr === null) { return null; } - $innerMethodCall = new \PhpParser\Node\Expr\StaticCall($expr, $phpMethodReflection->getName()); + $innerMethodCall = new StaticCall($expr, $phpMethodReflection->getName()); } else { $expr = $this->resolveExpr($expr); - if (!$expr instanceof \PhpParser\Node\Expr) { + if (!$expr instanceof Expr) { return null; } - $innerMethodCall = new \PhpParser\Node\Expr\MethodCall($expr, $phpMethodReflection->getName()); + $innerMethodCall = new MethodCall($expr, $phpMethodReflection->getName()); } $innerMethodCall->args = $this->nodeFactory->createArgsFromParams($params); return $innerMethodCall; @@ -366,9 +366,9 @@ final class AnonymousFunctionFactory /** * @return null|\PhpParser\Node\Name|\PhpParser\Node\Name\FullyQualified|\PhpParser\Node\Expr */ - private function normalizeClassConstFetchForStatic(\PhpParser\Node\Expr $expr) + private function normalizeClassConstFetchForStatic(Expr $expr) { - if (!$expr instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if (!$expr instanceof ClassConstFetch) { return $expr; } if (!$this->nodeNameResolver->isName($expr->name, 'class')) { @@ -379,15 +379,15 @@ final class AnonymousFunctionFactory if ($className === null) { return null; } - $name = new \PhpParser\Node\Name($className); - return $name->isSpecialClassName() ? $name : new \PhpParser\Node\Name\FullyQualified($className); + $name = new Name($className); + return $name->isSpecialClassName() ? $name : new FullyQualified($className); } /** * @return \PhpParser\Node\Expr\New_|\PhpParser\Node\Expr|null */ - private function resolveExpr(\PhpParser\Node\Expr $expr) + private function resolveExpr(Expr $expr) { - if (!$expr instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if (!$expr instanceof ClassConstFetch) { return $expr; } if (!$this->nodeNameResolver->isName($expr->name, 'class')) { @@ -395,6 +395,6 @@ final class AnonymousFunctionFactory } // dynamic name, nothing we can do $className = $this->nodeNameResolver->getName($expr->class); - return $className === null ? null : new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name\FullyQualified($className)); + return $className === null ? null : new New_(new FullyQualified($className)); } } diff --git a/rules/Php72/Rector/Assign/ListEachRector.php b/rules/Php72/Rector/Assign/ListEachRector.php index 844a3a55f7e..902c7421678 100644 --- a/rules/Php72/Rector/Assign/ListEachRector.php +++ b/rules/Php72/Rector/Assign/ListEachRector.php @@ -15,31 +15,31 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/deprecations_php_7_2#each * * @see \Rector\Tests\Php72\Rector\Assign\ListEachRector\ListEachRectorTest */ -final class ListEachRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ListEachRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\Core\NodeManipulator\AssignManipulator */ private $assignManipulator; - public function __construct(\Rector\Core\NodeManipulator\AssignManipulator $assignManipulator) + public function __construct(AssignManipulator $assignManipulator) { $this->assignManipulator = $assignManipulator; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::DEPRECATE_EACH; + return PhpVersionFeature::DEPRECATE_EACH; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('each() function is deprecated, use key() and current() instead', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('each() function is deprecated, use key() and current() instead', [new CodeSample(<<<'CODE_SAMPLE' list($key, $callback) = each($callbacks); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -54,12 +54,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Assign::class]; + return [Assign::class]; } /** * @param Assign $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -69,43 +69,43 @@ CODE_SAMPLE /** @var FuncCall $eachFuncCall */ $eachFuncCall = $node->expr; // only key: list($key, ) = each($values); - if ($listNode->items[0] instanceof \PhpParser\Node\Expr\ArrayItem && $listNode->items[1] === null) { + if ($listNode->items[0] instanceof ArrayItem && $listNode->items[1] === null) { $keyFuncCall = $this->nodeFactory->createFuncCall('key', $eachFuncCall->args); - return new \PhpParser\Node\Expr\Assign($listNode->items[0]->value, $keyFuncCall); + return new Assign($listNode->items[0]->value, $keyFuncCall); } // only value: list(, $value) = each($values); - if ($listNode->items[1] instanceof \PhpParser\Node\Expr\ArrayItem && $listNode->items[0] === null) { + if ($listNode->items[1] instanceof ArrayItem && $listNode->items[0] === null) { $nextFuncCall = $this->nodeFactory->createFuncCall('next', $eachFuncCall->args); $this->nodesToAddCollector->addNodeAfterNode($nextFuncCall, $node); $currentFuncCall = $this->nodeFactory->createFuncCall('current', $eachFuncCall->args); $secondArrayItem = $listNode->items[1]; - return new \PhpParser\Node\Expr\Assign($secondArrayItem->value, $currentFuncCall); + return new Assign($secondArrayItem->value, $currentFuncCall); } // both: list($key, $value) = each($values); $currentFuncCall = $this->nodeFactory->createFuncCall('current', $eachFuncCall->args); $secondArrayItem = $listNode->items[1]; - if (!$secondArrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$secondArrayItem instanceof ArrayItem) { + throw new ShouldNotHappenException(); } - $assign = new \PhpParser\Node\Expr\Assign($secondArrayItem->value, $currentFuncCall); + $assign = new Assign($secondArrayItem->value, $currentFuncCall); $this->nodesToAddCollector->addNodeAfterNode($assign, $node); $nextFuncCall = $this->nodeFactory->createFuncCall('next', $eachFuncCall->args); $this->nodesToAddCollector->addNodeAfterNode($nextFuncCall, $node); $keyFuncCall = $this->nodeFactory->createFuncCall('key', $eachFuncCall->args); $firstArrayItem = $listNode->items[0]; - if (!$firstArrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$firstArrayItem instanceof ArrayItem) { + throw new ShouldNotHappenException(); } - return new \PhpParser\Node\Expr\Assign($firstArrayItem->value, $keyFuncCall); + return new Assign($firstArrayItem->value, $keyFuncCall); } - private function shouldSkip(\PhpParser\Node\Expr\Assign $assign) : bool + private function shouldSkip(Assign $assign) : bool { if (!$this->assignManipulator->isListToEachAssign($assign)) { return \true; } // assign should be top level, e.g. not in a while loop - $parentNode = $assign->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node\Stmt\Expression) { + $parentNode = $assign->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof Expression) { return \true; } /** @var List_ $listNode */ diff --git a/rules/Php72/Rector/Assign/ReplaceEachAssignmentWithKeyCurrentRector.php b/rules/Php72/Rector/Assign/ReplaceEachAssignmentWithKeyCurrentRector.php index 0603e2698c5..4d0fac71d46 100644 --- a/rules/Php72/Rector/Assign/ReplaceEachAssignmentWithKeyCurrentRector.php +++ b/rules/Php72/Rector/Assign/ReplaceEachAssignmentWithKeyCurrentRector.php @@ -16,12 +16,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php72\Rector\Assign\ReplaceEachAssignmentWithKeyCurrentRector\ReplaceEachAssignmentWithKeyCurrentRectorTest */ -final class ReplaceEachAssignmentWithKeyCurrentRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ReplaceEachAssignmentWithKeyCurrentRector extends AbstractRector implements MinPhpVersionInterface { /** * @var string @@ -29,11 +29,11 @@ final class ReplaceEachAssignmentWithKeyCurrentRector extends \Rector\Core\Recto private const KEY = 'key'; public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NO_EACH_OUTSIDE_LOOP; + return PhpVersionFeature::NO_EACH_OUTSIDE_LOOP; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace each() assign outside loop', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace each() assign outside loop', [new CodeSample(<<<'CODE_SAMPLE' $array = ['b' => 1, 'a' => 2]; $eachedArray = each($array); CODE_SAMPLE @@ -52,12 +52,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Assign::class]; + return [Assign::class]; } /** * @param Assign $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -67,7 +67,7 @@ CODE_SAMPLE if (!isset($eachFuncCall->args[0])) { return null; } - if (!$eachFuncCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$eachFuncCall->args[0] instanceof Arg) { return null; } $eachedVariable = $eachFuncCall->args[0]->value; @@ -77,38 +77,38 @@ CODE_SAMPLE $this->removeNode($node); return null; } - private function shouldSkip(\PhpParser\Node\Expr\Assign $assign) : bool + private function shouldSkip(Assign $assign) : bool { - if (!$assign->expr instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$assign->expr instanceof FuncCall) { return \true; } if (!$this->nodeNameResolver->isName($assign->expr, 'each')) { return \true; } - $parentNode = $assign->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentNode instanceof \PhpParser\Node\Stmt\While_) { + $parentNode = $assign->getAttribute(AttributeKey::PARENT_NODE); + if ($parentNode instanceof While_) { return \true; } // skip assign to List - if (!$parentNode instanceof \PhpParser\Node\Expr\Assign) { + if (!$parentNode instanceof Assign) { return \false; } - return $parentNode->var instanceof \PhpParser\Node\Expr\List_; + return $parentNode->var instanceof List_; } /** * @return array */ - private function createNewNodes(\PhpParser\Node\Expr $assignVariable, \PhpParser\Node\Expr $eachedVariable) : array + private function createNewNodes(Expr $assignVariable, Expr $eachedVariable) : array { - return [$this->createDimFetchAssignWithFuncCall($assignVariable, $eachedVariable, 1, 'current'), $this->createDimFetchAssignWithFuncCall($assignVariable, $eachedVariable, 'value', 'current'), $this->createDimFetchAssignWithFuncCall($assignVariable, $eachedVariable, 0, self::KEY), $this->createDimFetchAssignWithFuncCall($assignVariable, $eachedVariable, self::KEY, self::KEY), $this->nodeFactory->createFuncCall('next', [new \PhpParser\Node\Arg($eachedVariable)])]; + return [$this->createDimFetchAssignWithFuncCall($assignVariable, $eachedVariable, 1, 'current'), $this->createDimFetchAssignWithFuncCall($assignVariable, $eachedVariable, 'value', 'current'), $this->createDimFetchAssignWithFuncCall($assignVariable, $eachedVariable, 0, self::KEY), $this->createDimFetchAssignWithFuncCall($assignVariable, $eachedVariable, self::KEY, self::KEY), $this->nodeFactory->createFuncCall('next', [new Arg($eachedVariable)])]; } /** * @param string|int $dimValue */ - private function createDimFetchAssignWithFuncCall(\PhpParser\Node\Expr $assignVariable, \PhpParser\Node\Expr $eachedVariable, $dimValue, string $functionName) : \PhpParser\Node\Expr\Assign + private function createDimFetchAssignWithFuncCall(Expr $assignVariable, Expr $eachedVariable, $dimValue, string $functionName) : Assign { - $dim = \PhpParser\BuilderHelpers::normalizeValue($dimValue); - $arrayDimFetch = new \PhpParser\Node\Expr\ArrayDimFetch($assignVariable, $dim); - return new \PhpParser\Node\Expr\Assign($arrayDimFetch, $this->nodeFactory->createFuncCall($functionName, [new \PhpParser\Node\Arg($eachedVariable)])); + $dim = BuilderHelpers::normalizeValue($dimValue); + $arrayDimFetch = new ArrayDimFetch($assignVariable, $dim); + return new Assign($arrayDimFetch, $this->nodeFactory->createFuncCall($functionName, [new Arg($eachedVariable)])); } } diff --git a/rules/Php72/Rector/FuncCall/CreateFunctionToAnonymousFunctionRector.php b/rules/Php72/Rector/FuncCall/CreateFunctionToAnonymousFunctionRector.php index 01f0a47d65e..d03e037282c 100644 --- a/rules/Php72/Rector/FuncCall/CreateFunctionToAnonymousFunctionRector.php +++ b/rules/Php72/Rector/FuncCall/CreateFunctionToAnonymousFunctionRector.php @@ -24,14 +24,14 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Php72\NodeFactory\AnonymousFunctionFactory; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://stackoverflow.com/q/48161526/1348344 http://php.net/manual/en/migration72.deprecated.php#migration72.deprecated.create_function-function * * @see \Rector\Tests\Php72\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector\CreateFunctionToAnonymousFunctionRectorTest */ -final class CreateFunctionToAnonymousFunctionRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class CreateFunctionToAnonymousFunctionRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -53,7 +53,7 @@ final class CreateFunctionToAnonymousFunctionRector extends \Rector\Core\Rector\ * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Core\PhpParser\Parser\InlineCodeParser $inlineCodeParser, \Rector\Php72\NodeFactory\AnonymousFunctionFactory $anonymousFunctionFactory, \Rector\Core\Php\ReservedKeywordAnalyzer $reservedKeywordAnalyzer, \Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(InlineCodeParser $inlineCodeParser, AnonymousFunctionFactory $anonymousFunctionFactory, ReservedKeywordAnalyzer $reservedKeywordAnalyzer, ArgsAnalyzer $argsAnalyzer) { $this->inlineCodeParser = $inlineCodeParser; $this->anonymousFunctionFactory = $anonymousFunctionFactory; @@ -62,11 +62,11 @@ final class CreateFunctionToAnonymousFunctionRector extends \Rector\Core\Rector\ } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::DEPRECATE_CREATE_FUNCTION; + return PhpVersionFeature::DEPRECATE_CREATE_FUNCTION; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Use anonymous functions instead of deprecated create_function()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Use anonymous functions instead of deprecated create_function()', [new CodeSample(<<<'CODE_SAMPLE' class ClassWithCreateFunction { public function run() @@ -93,13 +93,13 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node * @return Closure|null */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'create_function')) { return null; @@ -128,7 +128,7 @@ CODE_SAMPLE /** * @return Param[] */ - private function createParamsFromString(\PhpParser\Node\Expr $expr) : array + private function createParamsFromString(Expr $expr) : array { $content = $this->inlineCodeParser->stringify($expr); $content = 'expr; $function = $assign->expr; - if (!$function instanceof \PhpParser\Node\Expr\Closure) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$function instanceof Closure) { + throw new ShouldNotHappenException(); } return $function->params; } /** * @return Expression[]|Stmt[] */ - private function parseStringToBody(\PhpParser\Node\Expr $expr) : array + private function parseStringToBody(Expr $expr) : array { - if (!$expr instanceof \PhpParser\Node\Scalar\String_ && !$expr instanceof \PhpParser\Node\Scalar\Encapsed && !$expr instanceof \PhpParser\Node\Expr\BinaryOp\Concat) { + if (!$expr instanceof String_ && !$expr instanceof Encapsed && !$expr instanceof Concat) { // special case of code elsewhere return [$this->createEval($expr)]; } $expr = $this->inlineCodeParser->stringify($expr); return $this->inlineCodeParser->parse($expr); } - private function createEval(\PhpParser\Node\Expr $expr) : \PhpParser\Node\Stmt\Expression + private function createEval(Expr $expr) : Expression { - $evalFuncCall = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('eval'), [new \PhpParser\Node\Arg($expr)]); - return new \PhpParser\Node\Stmt\Expression($evalFuncCall); + $evalFuncCall = new FuncCall(new Name('eval'), [new Arg($expr)]); + return new Expression($evalFuncCall); } } diff --git a/rules/Php72/Rector/FuncCall/GetClassOnNullRector.php b/rules/Php72/Rector/FuncCall/GetClassOnNullRector.php index 3ab86b2c5df..d633e56888b 100644 --- a/rules/Php72/Rector/FuncCall/GetClassOnNullRector.php +++ b/rules/Php72/Rector/FuncCall/GetClassOnNullRector.php @@ -16,22 +16,22 @@ use Rector\Core\Rector\AbstractScopeAwareRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog http://php.net/manual/en/migration72.incompatible.php#migration72.incompatible.no-null-to-get_class https://3v4l.org/sk0fp * * @see \Rector\Tests\Php72\Rector\FuncCall\GetClassOnNullRector\GetClassOnNullRectorTest */ -final class GetClassOnNullRector extends \Rector\Core\Rector\AbstractScopeAwareRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class GetClassOnNullRector extends AbstractScopeAwareRector implements MinPhpVersionInterface { public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NO_NULL_ON_GET_CLASS; + return PhpVersionFeature::NO_NULL_ON_GET_CLASS; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Null is no more allowed in get_class()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Null is no more allowed in get_class()', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function getItem() @@ -58,12 +58,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactorWithScope(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : ?\PhpParser\Node + public function refactorWithScope(Node $node, Scope $scope) : ?Node { if (!$this->isName($node, 'get_class')) { return null; @@ -71,7 +71,7 @@ CODE_SAMPLE if (!isset($node->args[0])) { return null; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } $firstArgValue = $node->args[0]->value; @@ -83,26 +83,26 @@ CODE_SAMPLE return null; } $firstArgType = $this->getType($firstArgValue); - if (!$this->nodeTypeResolver->isNullableType($firstArgValue) && !$firstArgType instanceof \PHPStan\Type\NullType) { + if (!$this->nodeTypeResolver->isNullableType($firstArgValue) && !$firstArgType instanceof NullType) { return null; } - $notIdentical = new \PhpParser\Node\Expr\BinaryOp\NotIdentical($firstArgValue, $this->nodeFactory->createNull()); + $notIdentical = new NotIdentical($firstArgValue, $this->nodeFactory->createNull()); $funcCall = $this->createGetClassFuncCall($node); $selfClassConstFetch = $this->nodeFactory->createClassConstReference('self'); - return new \PhpParser\Node\Expr\Ternary($notIdentical, $funcCall, $selfClassConstFetch); + return new Ternary($notIdentical, $funcCall, $selfClassConstFetch); } - private function shouldSkip(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function shouldSkip(FuncCall $funcCall) : bool { - $isJustAdded = (bool) $funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::DO_NOT_CHANGE); + $isJustAdded = (bool) $funcCall->getAttribute(AttributeKey::DO_NOT_CHANGE); if ($isJustAdded) { return \true; } - $classLike = $this->betterNodeFinder->findParentType($funcCall, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLike = $this->betterNodeFinder->findParentType($funcCall, Class_::class); + if (!$classLike instanceof Class_) { return \true; } - $parent = $funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\Expr\Ternary) { + $parent = $funcCall->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof Ternary) { if ($this->isIdenticalToNotNull($funcCall, $parent)) { return \true; } @@ -110,24 +110,24 @@ CODE_SAMPLE } return \false; } - private function createGetClassFuncCall(\PhpParser\Node\Expr\FuncCall $oldFuncCall) : \PhpParser\Node\Expr\FuncCall + private function createGetClassFuncCall(FuncCall $oldFuncCall) : FuncCall { - $funcCall = new \PhpParser\Node\Expr\FuncCall($oldFuncCall->name, $oldFuncCall->args); - $funcCall->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::DO_NOT_CHANGE, \true); + $funcCall = new FuncCall($oldFuncCall->name, $oldFuncCall->args); + $funcCall->setAttribute(AttributeKey::DO_NOT_CHANGE, \true); return $funcCall; } /** * E.g. "$value === [!null] ? get_class($value)" */ - private function isIdenticalToNotNull(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr\Ternary $ternary) : bool + private function isIdenticalToNotNull(FuncCall $funcCall, Ternary $ternary) : bool { - if (!$ternary->cond instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { + if (!$ternary->cond instanceof Identical) { return \false; } if (!isset($funcCall->args[0])) { return \false; } - if (!$funcCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[0] instanceof Arg) { return \false; } if ($this->nodeComparator->areNodesEqual($ternary->cond->left, $funcCall->args[0]->value) && !$this->valueResolver->isNull($ternary->cond->right)) { @@ -141,15 +141,15 @@ CODE_SAMPLE /** * E.g. "$value !== null ? get_class($value)" */ - private function isNotIdenticalToNull(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr\Ternary $ternary) : bool + private function isNotIdenticalToNull(FuncCall $funcCall, Ternary $ternary) : bool { - if (!$ternary->cond instanceof \PhpParser\Node\Expr\BinaryOp\NotIdentical) { + if (!$ternary->cond instanceof NotIdentical) { return \false; } if (!isset($funcCall->args[0])) { return \false; } - if (!$funcCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[0] instanceof Arg) { return \false; } if ($this->nodeComparator->areNodesEqual($ternary->cond->left, $funcCall->args[0]->value) && $this->valueResolver->isNull($ternary->cond->right)) { diff --git a/rules/Php72/Rector/FuncCall/IsObjectOnIncompleteClassRector.php b/rules/Php72/Rector/FuncCall/IsObjectOnIncompleteClassRector.php index c1ce40d791b..0966a160342 100644 --- a/rules/Php72/Rector/FuncCall/IsObjectOnIncompleteClassRector.php +++ b/rules/Php72/Rector/FuncCall/IsObjectOnIncompleteClassRector.php @@ -12,22 +12,22 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog http://php.net/manual/en/migration72.incompatible.php#migration72.incompatible.is_object-on-incomplete_class https://3v4l.org/SpiE6 * * @see \Rector\Tests\Php72\Rector\FuncCall\IsObjectOnIncompleteClassRector\IsObjectOnIncompleteClassRectorTest */ -final class IsObjectOnIncompleteClassRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class IsObjectOnIncompleteClassRector extends AbstractRector implements MinPhpVersionInterface { public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::INVERTED_BOOL_IS_OBJECT_INCOMPLETE_CLASS; + return PhpVersionFeature::INVERTED_BOOL_IS_OBJECT_INCOMPLETE_CLASS; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Incomplete class returns inverted bool on is_object()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Incomplete class returns inverted bool on is_object()', [new CodeSample(<<<'CODE_SAMPLE' $incompleteObject = new __PHP_Incomplete_Class; $isObject = is_object($incompleteObject); CODE_SAMPLE @@ -42,21 +42,21 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'is_object')) { return null; } - $incompleteClassObjectType = new \PHPStan\Type\ObjectType('__PHP_Incomplete_Class'); + $incompleteClassObjectType = new ObjectType('__PHP_Incomplete_Class'); if (!isset($node->args[0])) { return null; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } if (!$this->isObjectType($node->args[0]->value, $incompleteClassObjectType)) { @@ -65,11 +65,11 @@ CODE_SAMPLE if ($this->shouldSkip($node)) { return null; } - return new \PhpParser\Node\Expr\BooleanNot($node); + return new BooleanNot($node); } - private function shouldSkip(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function shouldSkip(FuncCall $funcCall) : bool { - $parentNode = $funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - return $parentNode instanceof \PhpParser\Node\Expr\BooleanNot; + $parentNode = $funcCall->getAttribute(AttributeKey::PARENT_NODE); + return $parentNode instanceof BooleanNot; } } diff --git a/rules/Php72/Rector/FuncCall/ParseStrWithResultArgumentRector.php b/rules/Php72/Rector/FuncCall/ParseStrWithResultArgumentRector.php index 3db39639c24..a09fa6bc7a3 100644 --- a/rules/Php72/Rector/FuncCall/ParseStrWithResultArgumentRector.php +++ b/rules/Php72/Rector/FuncCall/ParseStrWithResultArgumentRector.php @@ -12,22 +12,22 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/gueff/blogimus/commit/04086a10320595470efe446c7ddd90e602aa7228 https://github.com/pxgamer/youtube-dl-php/commit/83cb32b8b36844f2e39f82a862a5ab73da77b608 * * @see \Rector\Tests\Php72\Rector\FuncCall\ParseStrWithResultArgumentRector\ParseStrWithResultArgumentRectorTest */ -final class ParseStrWithResultArgumentRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ParseStrWithResultArgumentRector extends AbstractRector implements MinPhpVersionInterface { public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::RESULT_ARG_IN_PARSE_STR; + return PhpVersionFeature::RESULT_ARG_IN_PARSE_STR; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Use $result argument in parse_str() function', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Use $result argument in parse_str() function', [new CodeSample(<<<'CODE_SAMPLE' parse_str($this->query); $data = get_defined_vars(); CODE_SAMPLE @@ -42,12 +42,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'parse_str')) { return null; @@ -55,18 +55,18 @@ CODE_SAMPLE if (isset($node->args[1])) { return null; } - $resultVariable = new \PhpParser\Node\Expr\Variable('result'); - $node->args[1] = new \PhpParser\Node\Arg($resultVariable); + $resultVariable = new Variable('result'); + $node->args[1] = new Arg($resultVariable); $expression = $this->betterNodeFinder->resolveCurrentStatement($node); - if (!$expression instanceof \PhpParser\Node\Stmt) { + if (!$expression instanceof Stmt) { return null; } - $nextExpression = $expression->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); + $nextExpression = $expression->getAttribute(AttributeKey::NEXT_NODE); if ($nextExpression === null) { return null; } - $this->traverseNodesWithCallable($nextExpression, function (\PhpParser\Node $node) use($resultVariable) : ?Variable { - if (!$node instanceof \PhpParser\Node\Expr\FuncCall) { + $this->traverseNodesWithCallable($nextExpression, function (Node $node) use($resultVariable) : ?Variable { + if (!$node instanceof FuncCall) { return null; } if (!$this->isName($node, 'get_defined_vars')) { diff --git a/rules/Php72/Rector/FuncCall/StringifyDefineRector.php b/rules/Php72/Rector/FuncCall/StringifyDefineRector.php index 660f7c21dc9..4202d4cc612 100644 --- a/rules/Php72/Rector/FuncCall/StringifyDefineRector.php +++ b/rules/Php72/Rector/FuncCall/StringifyDefineRector.php @@ -12,30 +12,30 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\TypeAnalyzer\StringTypeAnalyzer; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/YiTeP * @see \Rector\Tests\Php72\Rector\FuncCall\StringifyDefineRector\StringifyDefineRectorTest */ -final class StringifyDefineRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class StringifyDefineRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\NodeTypeResolver\TypeAnalyzer\StringTypeAnalyzer */ private $stringTypeAnalyzer; - public function __construct(\Rector\NodeTypeResolver\TypeAnalyzer\StringTypeAnalyzer $stringTypeAnalyzer) + public function __construct(StringTypeAnalyzer $stringTypeAnalyzer) { $this->stringTypeAnalyzer = $stringTypeAnalyzer; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::STRING_IN_FIRST_DEFINE_ARG; + return PhpVersionFeature::STRING_IN_FIRST_DEFINE_ARG; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Make first argument of define() string', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Make first argument of define() string', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(int $a) @@ -62,12 +62,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'define')) { return null; @@ -75,18 +75,18 @@ CODE_SAMPLE if (!isset($node->args[0])) { return null; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } if ($this->stringTypeAnalyzer->isStringOrUnionStringOnlyType($node->args[0]->value)) { return null; } - if ($node->args[0]->value instanceof \PhpParser\Node\Expr\ConstFetch) { + if ($node->args[0]->value instanceof ConstFetch) { $nodeName = $this->getName($node->args[0]->value); if ($nodeName === null) { return null; } - $node->args[0]->value = new \PhpParser\Node\Scalar\String_($nodeName); + $node->args[0]->value = new String_($nodeName); } return $node; } diff --git a/rules/Php72/Rector/FuncCall/StringsAssertNakedRector.php b/rules/Php72/Rector/FuncCall/StringsAssertNakedRector.php index e4fad0df9b6..b6fd1353a51 100644 --- a/rules/Php72/Rector/FuncCall/StringsAssertNakedRector.php +++ b/rules/Php72/Rector/FuncCall/StringsAssertNakedRector.php @@ -12,31 +12,31 @@ use Rector\Core\PhpParser\Parser\SimplePhpParser; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/simplesamlphp/simplesamlphp/pull/708/files * * @see \Rector\Tests\Php72\Rector\FuncCall\StringsAssertNakedRector\StringsAssertNakedRectorTest */ -final class StringsAssertNakedRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class StringsAssertNakedRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\Core\PhpParser\Parser\SimplePhpParser */ private $simplePhpParser; - public function __construct(\Rector\Core\PhpParser\Parser\SimplePhpParser $simplePhpParser) + public function __construct(SimplePhpParser $simplePhpParser) { $this->simplePhpParser = $simplePhpParser; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::STRING_IN_ASSERT_ARG; + return PhpVersionFeature::STRING_IN_ASSERT_ARG; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('String asserts must be passed directly to assert()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('String asserts must be passed directly to assert()', [new CodeSample(<<<'CODE_SAMPLE' function nakedAssert() { assert('true === true'); @@ -57,21 +57,21 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'assert')) { return null; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } $firstArgValue = $node->args[0]->value; - if (!$firstArgValue instanceof \PhpParser\Node\Scalar\String_) { + if (!$firstArgValue instanceof String_) { return null; } $phpCode = 'value . ';'; @@ -79,10 +79,10 @@ CODE_SAMPLE if (!isset($contentStmts[0])) { return null; } - if (!$contentStmts[0] instanceof \PhpParser\Node\Stmt\Expression) { + if (!$contentStmts[0] instanceof Expression) { return null; } - $node->args[0] = new \PhpParser\Node\Arg($contentStmts[0]->expr); + $node->args[0] = new Arg($contentStmts[0]->expr); return $node; } } diff --git a/rules/Php72/Rector/Unset_/UnsetCastRector.php b/rules/Php72/Rector/Unset_/UnsetCastRector.php index 42519a58afb..6793547e8a4 100644 --- a/rules/Php72/Rector/Unset_/UnsetCastRector.php +++ b/rules/Php72/Rector/Unset_/UnsetCastRector.php @@ -11,20 +11,20 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php72\Rector\Unset_\UnsetCastRector\UnsetCastRectorTest */ -final class UnsetCastRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class UnsetCastRector extends AbstractRector implements MinPhpVersionInterface { public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NO_UNSET_CAST; + return PhpVersionFeature::NO_UNSET_CAST; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Removes (unset) cast', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Removes (unset) cast', [new CodeSample(<<<'CODE_SAMPLE' $different = (unset) $value; $value = (unset) $value; @@ -41,15 +41,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Cast\Unset_::class, \PhpParser\Node\Expr\Assign::class]; + return [Unset_::class, Assign::class]; } /** * @param Unset_|Assign $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\Assign) { - if ($node->expr instanceof \PhpParser\Node\Expr\Cast\Unset_) { + if ($node instanceof Assign) { + if ($node->expr instanceof Unset_) { $unset = $node->expr; if ($this->nodeComparator->areNodesEqual($node->var, $unset->expr)) { return $this->nodeFactory->createFuncCall('unset', [$node->var]); @@ -57,8 +57,8 @@ CODE_SAMPLE } return null; } - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentNode instanceof \PhpParser\Node\Stmt\Expression) { + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); + if ($parentNode instanceof Expression) { $this->removeNode($node); return null; } diff --git a/rules/Php72/Rector/While_/WhileEachToForeachRector.php b/rules/Php72/Rector/While_/WhileEachToForeachRector.php index dcb4651e621..5851d852e38 100644 --- a/rules/Php72/Rector/While_/WhileEachToForeachRector.php +++ b/rules/Php72/Rector/While_/WhileEachToForeachRector.php @@ -15,31 +15,31 @@ use Rector\Core\NodeManipulator\AssignManipulator; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/deprecations_php_7_2#each * * @see \Rector\Tests\Php72\Rector\While_\WhileEachToForeachRector\WhileEachToForeachRectorTest */ -final class WhileEachToForeachRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class WhileEachToForeachRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\Core\NodeManipulator\AssignManipulator */ private $assignManipulator; - public function __construct(\Rector\Core\NodeManipulator\AssignManipulator $assignManipulator) + public function __construct(AssignManipulator $assignManipulator) { $this->assignManipulator = $assignManipulator; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::DEPRECATE_EACH; + return PhpVersionFeature::DEPRECATE_EACH; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('each() function is deprecated, use foreach() instead.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('each() function is deprecated, use foreach() instead.', [new CodeSample(<<<'CODE_SAMPLE' while (list($key, $callback) = each($callbacks)) { // ... } @@ -49,7 +49,7 @@ foreach ($callbacks as $key => $callback) { // ... } CODE_SAMPLE -), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' +), new CodeSample(<<<'CODE_SAMPLE' while (list($key) = each($callbacks)) { // ... } @@ -66,14 +66,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\While_::class]; + return [While_::class]; } /** * @param While_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->cond instanceof \PhpParser\Node\Expr\Assign) { + if (!$node->cond instanceof Assign) { return null; } /** @var Assign $assignNode */ @@ -88,13 +88,13 @@ CODE_SAMPLE if (!isset($eachFuncCall->args[0])) { return null; } - if (!$eachFuncCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$eachFuncCall->args[0] instanceof Arg) { return null; } $foreachedExpr = \count($listNode->items) === 1 ? $this->nodeFactory->createFuncCall('array_keys', [$eachFuncCall->args[0]]) : $eachFuncCall->args[0]->value; /** @var ArrayItem $arrayItem */ $arrayItem = \array_pop($listNode->items); - $foreach = new \PhpParser\Node\Stmt\Foreach_($foreachedExpr, $arrayItem, ['stmts' => $node->stmts]); + $foreach = new Foreach_($foreachedExpr, $arrayItem, ['stmts' => $node->stmts]); $this->mirrorComments($foreach, $node); // is key included? add it to foreach if ($listNode->items !== []) { diff --git a/rules/Php73/NodeTypeAnalyzer/NodeTypeAnalyzer.php b/rules/Php73/NodeTypeAnalyzer/NodeTypeAnalyzer.php index 32d70b69321..26fe0524a57 100644 --- a/rules/Php73/NodeTypeAnalyzer/NodeTypeAnalyzer.php +++ b/rules/Php73/NodeTypeAnalyzer/NodeTypeAnalyzer.php @@ -10,15 +10,15 @@ use PHPStan\Type\Type; use PHPStan\Type\UnionType; final class NodeTypeAnalyzer { - public function isStringyType(\PHPStan\Type\Type $type) : bool + public function isStringyType(Type $type) : bool { - if ($type instanceof \PHPStan\Type\StringType) { + if ($type instanceof StringType) { return \true; } - if ($type instanceof \PHPStan\Type\Accessory\AccessoryNumericStringType) { + if ($type instanceof AccessoryNumericStringType) { return \true; } - if ($type instanceof \PHPStan\Type\IntersectionType || $type instanceof \PHPStan\Type\UnionType) { + if ($type instanceof IntersectionType || $type instanceof UnionType) { foreach ($type->getTypes() as $innerType) { if (!$this->isStringyType($innerType)) { return \false; diff --git a/rules/Php73/Rector/BooleanOr/IsCountableRector.php b/rules/Php73/Rector/BooleanOr/IsCountableRector.php index 1dd1ce8436f..b77a7c326ff 100644 --- a/rules/Php73/Rector/BooleanOr/IsCountableRector.php +++ b/rules/Php73/Rector/BooleanOr/IsCountableRector.php @@ -11,12 +11,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Php71\IsArrayAndDualCheckToAble; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php73\Rector\BinaryOr\IsCountableRector\IsCountableRectorTest */ -final class IsCountableRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class IsCountableRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -28,14 +28,14 @@ final class IsCountableRector extends \Rector\Core\Rector\AbstractRector impleme * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\Php71\IsArrayAndDualCheckToAble $isArrayAndDualCheckToAble, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(IsArrayAndDualCheckToAble $isArrayAndDualCheckToAble, ReflectionProvider $reflectionProvider) { $this->isArrayAndDualCheckToAble = $isArrayAndDualCheckToAble; $this->reflectionProvider = $reflectionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes is_array + Countable check to is_countable', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes is_array + Countable check to is_countable', [new CodeSample(<<<'CODE_SAMPLE' is_array($foo) || $foo instanceof Countable; CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -48,12 +48,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\BooleanOr::class]; + return [BooleanOr::class]; } /** * @param BooleanOr $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip()) { return null; @@ -62,10 +62,10 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::IS_COUNTABLE; + return PhpVersionFeature::IS_COUNTABLE; } private function shouldSkip() : bool { - return !$this->reflectionProvider->hasFunction(new \PhpParser\Node\Name('is_countable'), null); + return !$this->reflectionProvider->hasFunction(new Name('is_countable'), null); } } diff --git a/rules/Php73/Rector/ConstFetch/SensitiveConstantNameRector.php b/rules/Php73/Rector/ConstFetch/SensitiveConstantNameRector.php index 44ff6accb03..38550db6e3c 100644 --- a/rules/Php73/Rector/ConstFetch/SensitiveConstantNameRector.php +++ b/rules/Php73/Rector/ConstFetch/SensitiveConstantNameRector.php @@ -12,14 +12,14 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/case_insensitive_constant_deprecation * * @see \Rector\Tests\Php73\Rector\ConstFetch\SensitiveConstantNameRector\SensitiveConstantNameRectorTest */ -final class SensitiveConstantNameRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class SensitiveConstantNameRector extends AbstractRector implements MinPhpVersionInterface { /** * @see http://php.net/manual/en/reserved.constants.php @@ -31,17 +31,17 @@ final class SensitiveConstantNameRector extends \Rector\Core\Rector\AbstractRect * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ReflectionProvider $reflectionProvider) { $this->reflectionProvider = $reflectionProvider; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::DEPRECATE_INSENSITIVE_CONSTANT_NAME; + return PhpVersionFeature::DEPRECATE_INSENSITIVE_CONSTANT_NAME; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes case insensitive constants to sensitive ones.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes case insensitive constants to sensitive ones.', [new CodeSample(<<<'CODE_SAMPLE' define('FOO', 42, true); var_dump(FOO); var_dump(foo); @@ -58,12 +58,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\ConstFetch::class]; + return [ConstFetch::class]; } /** * @param ConstFetch $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $constantName = $this->getName($node); if ($constantName === null) { @@ -75,8 +75,8 @@ CODE_SAMPLE return null; } // constant is defined in current lower/upper case - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if ($this->reflectionProvider->hasConstant(new \PhpParser\Node\Name($constantName), $scope)) { + $scope = $node->getAttribute(AttributeKey::SCOPE); + if ($this->reflectionProvider->hasConstant(new Name($constantName), $scope)) { return null; } // is uppercase, all good @@ -86,7 +86,7 @@ CODE_SAMPLE if (\strpos($uppercasedConstantName, '\\') !== \false) { return null; } - $node->name = new \PhpParser\Node\Name\FullyQualified($uppercasedConstantName); + $node->name = new FullyQualified($uppercasedConstantName); return $node; } } diff --git a/rules/Php73/Rector/FuncCall/ArrayKeyFirstLastRector.php b/rules/Php73/Rector/FuncCall/ArrayKeyFirstLastRector.php index 2fd5a1ee098..3bdbd8714bd 100644 --- a/rules/Php73/Rector/FuncCall/ArrayKeyFirstLastRector.php +++ b/rules/Php73/Rector/FuncCall/ArrayKeyFirstLastRector.php @@ -12,8 +12,8 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://tomasvotruba.com/blog/2018/08/16/whats-new-in-php-73-in-30-seconds-in-diffs/#2-first-and-last-array-key * @@ -22,7 +22,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @see \Rector\Tests\Php73\Rector\FuncCall\ArrayKeyFirstLastRector\ArrayKeyFirstLastRectorTest */ -final class ArrayKeyFirstLastRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ArrayKeyFirstLastRector extends AbstractRector implements MinPhpVersionInterface { /** * @var string @@ -41,20 +41,20 @@ final class ArrayKeyFirstLastRector extends \Rector\Core\Rector\AbstractRector i * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ReflectionProvider $reflectionProvider) { $this->reflectionProvider = $reflectionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Make use of array_key_first() and array_key_last()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Make use of array_key_first() and array_key_last()', [new CodeSample(<<<'CODE_SAMPLE' reset($items); $firstKey = key($items); CODE_SAMPLE , <<<'CODE_SAMPLE' $firstKey = array_key_first($items); CODE_SAMPLE -), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' +), new CodeSample(<<<'CODE_SAMPLE' end($items); $lastKey = key($items); CODE_SAMPLE @@ -68,23 +68,23 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } $nextExpression = $this->getNextExpression($node); - if (!$nextExpression instanceof \PhpParser\Node) { + if (!$nextExpression instanceof Node) { return null; } $resetOrEndFuncCall = $node; - $keyFuncCall = $this->betterNodeFinder->findFirst($nextExpression, function (\PhpParser\Node $node) use($resetOrEndFuncCall) : bool { - if (!$node instanceof \PhpParser\Node\Expr\FuncCall) { + $keyFuncCall = $this->betterNodeFinder->findFirst($nextExpression, function (Node $node) use($resetOrEndFuncCall) : bool { + if (!$node instanceof FuncCall) { return \false; } if (!$this->isName($node, 'key')) { @@ -92,37 +92,37 @@ CODE_SAMPLE } return $this->nodeComparator->areNodesEqual($resetOrEndFuncCall->args[0], $node->args[0]); }); - if (!$keyFuncCall instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$keyFuncCall instanceof FuncCall) { return null; } $newName = self::PREVIOUS_TO_NEW_FUNCTIONS[$this->getName($node)]; - $keyFuncCall->name = new \PhpParser\Node\Name($newName); + $keyFuncCall->name = new Name($newName); $this->removeNode($node); return $node; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::ARRAY_KEY_FIRST_LAST; + return PhpVersionFeature::ARRAY_KEY_FIRST_LAST; } - private function shouldSkip(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function shouldSkip(FuncCall $funcCall) : bool { if (!$this->isNames($funcCall, ['reset', 'end'])) { return \true; } - if (!$this->reflectionProvider->hasFunction(new \PhpParser\Node\Name(self::ARRAY_KEY_FIRST), null)) { + if (!$this->reflectionProvider->hasFunction(new Name(self::ARRAY_KEY_FIRST), null)) { return \true; } - return !$this->reflectionProvider->hasFunction(new \PhpParser\Node\Name(self::ARRAY_KEY_LAST), null); + return !$this->reflectionProvider->hasFunction(new Name(self::ARRAY_KEY_LAST), null); } - private function getNextExpression(\PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node + private function getNextExpression(FuncCall $funcCall) : ?Node { $currentExpression = $this->betterNodeFinder->resolveCurrentStatement($funcCall); - if (!$currentExpression instanceof \PhpParser\Node\Stmt\Expression) { + if (!$currentExpression instanceof Expression) { return null; } if ($currentExpression->expr !== $funcCall) { return null; } - return $currentExpression->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); + return $currentExpression->getAttribute(AttributeKey::NEXT_NODE); } } diff --git a/rules/Php73/Rector/FuncCall/JsonThrowOnErrorRector.php b/rules/Php73/Rector/FuncCall/JsonThrowOnErrorRector.php index 2f10a040586..3116e00104d 100644 --- a/rules/Php73/Rector/FuncCall/JsonThrowOnErrorRector.php +++ b/rules/Php73/Rector/FuncCall/JsonThrowOnErrorRector.php @@ -13,18 +13,18 @@ use PhpParser\Node\Scalar\LNumber; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog http://wiki.php.net/rfc/json_throw_on_error * @changelog https://3v4l.org/5HMVE * @see \Rector\Tests\Php73\Rector\FuncCall\JsonThrowOnErrorRector\JsonThrowOnErrorRectorTest */ -final class JsonThrowOnErrorRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class JsonThrowOnErrorRector extends AbstractRector implements MinPhpVersionInterface { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Adds JSON_THROW_ON_ERROR to json_encode() and json_decode() to throw JsonException on error', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Adds JSON_THROW_ON_ERROR to json_encode() and json_decode() to throw JsonException on error', [new CodeSample(<<<'CODE_SAMPLE' json_encode($content); json_decode($json); CODE_SAMPLE @@ -39,12 +39,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -59,9 +59,9 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::JSON_EXCEPTION; + return PhpVersionFeature::JSON_EXCEPTION; } - private function shouldSkip(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function shouldSkip(FuncCall $funcCall) : bool { if (!$this->isNames($funcCall, ['json_encode', 'json_decode'])) { return \true; @@ -70,51 +70,51 @@ CODE_SAMPLE return \true; } foreach ($funcCall->args as $arg) { - if (!$arg instanceof \PhpParser\Node\Arg) { + if (!$arg instanceof Arg) { continue; } - if ($arg->name instanceof \PhpParser\Node\Identifier) { + if ($arg->name instanceof Identifier) { return \true; } } if ($this->isFirstValueStringOrArray($funcCall)) { return \true; } - return (bool) $this->betterNodeFinder->findFirstNext($funcCall, function (\PhpParser\Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Expr\FuncCall) { + return (bool) $this->betterNodeFinder->findFirstNext($funcCall, function (Node $node) : bool { + if (!$node instanceof FuncCall) { return \false; } return $this->isNames($node, ['json_last_error', 'json_last_error_msg']); }); } - private function processJsonEncode(\PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Expr\FuncCall + private function processJsonEncode(FuncCall $funcCall) : ?FuncCall { if (isset($funcCall->args[1])) { return null; } - $funcCall->args[1] = new \PhpParser\Node\Arg($this->createConstFetch('JSON_THROW_ON_ERROR')); + $funcCall->args[1] = new Arg($this->createConstFetch('JSON_THROW_ON_ERROR')); return $funcCall; } - private function processJsonDecode(\PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Expr\FuncCall + private function processJsonDecode(FuncCall $funcCall) : ?FuncCall { if (isset($funcCall->args[3])) { return null; } // set default to inter-args if (!isset($funcCall->args[1])) { - $funcCall->args[1] = new \PhpParser\Node\Arg($this->nodeFactory->createNull()); + $funcCall->args[1] = new Arg($this->nodeFactory->createNull()); } if (!isset($funcCall->args[2])) { - $funcCall->args[2] = new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\LNumber(512)); + $funcCall->args[2] = new Arg(new LNumber(512)); } - $funcCall->args[3] = new \PhpParser\Node\Arg($this->createConstFetch('JSON_THROW_ON_ERROR')); + $funcCall->args[3] = new Arg($this->createConstFetch('JSON_THROW_ON_ERROR')); return $funcCall; } - private function createConstFetch(string $name) : \PhpParser\Node\Expr\ConstFetch + private function createConstFetch(string $name) : ConstFetch { - return new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name($name)); + return new ConstFetch(new Name($name)); } - private function isFirstValueStringOrArray(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function isFirstValueStringOrArray(FuncCall $funcCall) : bool { if (!isset($funcCall->args[0])) { return \false; diff --git a/rules/Php73/Rector/FuncCall/RegexDashEscapeRector.php b/rules/Php73/Rector/FuncCall/RegexDashEscapeRector.php index 077e817db1d..3b79bf87a9f 100644 --- a/rules/Php73/Rector/FuncCall/RegexDashEscapeRector.php +++ b/rules/Php73/Rector/FuncCall/RegexDashEscapeRector.php @@ -14,13 +14,13 @@ use Rector\Core\Util\StringUtils; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/dRG8U * @see \Rector\Tests\Php73\Rector\FuncCall\RegexDashEscapeRector\RegexDashEscapeRectorTest */ -final class RegexDashEscapeRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class RegexDashEscapeRector extends AbstractRector implements MinPhpVersionInterface { /** * @var string @@ -44,17 +44,17 @@ final class RegexDashEscapeRector extends \Rector\Core\Rector\AbstractRector imp * @var \Rector\Core\Php\Regex\RegexPatternArgumentManipulator */ private $regexPatternArgumentManipulator; - public function __construct(\Rector\Core\Php\Regex\RegexPatternArgumentManipulator $regexPatternArgumentManipulator) + public function __construct(RegexPatternArgumentManipulator $regexPatternArgumentManipulator) { $this->regexPatternArgumentManipulator = $regexPatternArgumentManipulator; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::ESCAPE_DASH_IN_REGEX; + return PhpVersionFeature::ESCAPE_DASH_IN_REGEX; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Escape - in some cases', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Escape - in some cases', [new CodeSample(<<<'CODE_SAMPLE' preg_match("#[\w-()]#", 'some text'); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -67,12 +67,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [FuncCall::class, StaticCall::class]; } /** * @param FuncCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $regexArguments = $this->regexPatternArgumentManipulator->matchCallArgumentWithRegexPattern($node); if ($regexArguments === []) { @@ -80,7 +80,7 @@ CODE_SAMPLE } $hasChanged = \false; foreach ($regexArguments as $regexArgument) { - if (\Rector\Core\Util\StringUtils::isMatch($regexArgument->value, self::THREE_BACKSLASH_FOR_ESCAPE_NEXT_REGEX)) { + if (StringUtils::isMatch($regexArgument->value, self::THREE_BACKSLASH_FOR_ESCAPE_NEXT_REGEX)) { continue; } $this->escapeStringNode($regexArgument); @@ -91,19 +91,19 @@ CODE_SAMPLE } return null; } - private function escapeStringNode(\PhpParser\Node\Scalar\String_ $string) : void + private function escapeStringNode(String_ $string) : void { $stringValue = $string->value; - if (\Rector\Core\Util\StringUtils::isMatch($stringValue, self::LEFT_HAND_UNESCAPED_DASH_REGEX)) { - $string->value = \RectorPrefix20220607\Nette\Utils\Strings::replace($stringValue, self::LEFT_HAND_UNESCAPED_DASH_REGEX, '$1\\-'); + if (StringUtils::isMatch($stringValue, self::LEFT_HAND_UNESCAPED_DASH_REGEX)) { + $string->value = Strings::replace($stringValue, self::LEFT_HAND_UNESCAPED_DASH_REGEX, '$1\\-'); // helped needed to skip re-escaping regular expression - $string->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::IS_REGULAR_PATTERN, \true); + $string->setAttribute(AttributeKey::IS_REGULAR_PATTERN, \true); return; } - if (\Rector\Core\Util\StringUtils::isMatch($stringValue, self::RIGHT_HAND_UNESCAPED_DASH_REGEX)) { - $string->value = \RectorPrefix20220607\Nette\Utils\Strings::replace($stringValue, self::RIGHT_HAND_UNESCAPED_DASH_REGEX, '\\-$1]'); + if (StringUtils::isMatch($stringValue, self::RIGHT_HAND_UNESCAPED_DASH_REGEX)) { + $string->value = Strings::replace($stringValue, self::RIGHT_HAND_UNESCAPED_DASH_REGEX, '\\-$1]'); // helped needed to skip re-escaping regular expression - $string->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::IS_REGULAR_PATTERN, \true); + $string->setAttribute(AttributeKey::IS_REGULAR_PATTERN, \true); } } } diff --git a/rules/Php73/Rector/FuncCall/SensitiveDefineRector.php b/rules/Php73/Rector/FuncCall/SensitiveDefineRector.php index 22232440541..35d39e32d49 100644 --- a/rules/Php73/Rector/FuncCall/SensitiveDefineRector.php +++ b/rules/Php73/Rector/FuncCall/SensitiveDefineRector.php @@ -8,22 +8,22 @@ use PhpParser\Node\Expr\FuncCall; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/case_insensitive_constant_deprecation * * @see \Rector\Tests\Php73\Rector\FuncCall\SensitiveDefineRector\SensitiveDefineRectorTest */ -final class SensitiveDefineRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class SensitiveDefineRector extends AbstractRector implements MinPhpVersionInterface { public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::DEPRECATE_INSENSITIVE_CONSTANT_DEFINE; + return PhpVersionFeature::DEPRECATE_INSENSITIVE_CONSTANT_DEFINE; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes case insensitive constants to sensitive ones.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes case insensitive constants to sensitive ones.', [new CodeSample(<<<'CODE_SAMPLE' define('FOO', 42, true); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -36,12 +36,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'define')) { return null; diff --git a/rules/Php73/Rector/FuncCall/SetCookieRector.php b/rules/Php73/Rector/FuncCall/SetCookieRector.php index 77d5969bfdb..5f43adf9163 100644 --- a/rules/Php73/Rector/FuncCall/SetCookieRector.php +++ b/rules/Php73/Rector/FuncCall/SetCookieRector.php @@ -14,8 +14,8 @@ use PhpParser\Node\VariadicPlaceholder; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * Convert legacy setcookie arguments to new array options * @@ -23,22 +23,22 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @changelog https://www.php.net/setcookie https://wiki.php.net/rfc/same-site-cookie */ -final class SetCookieRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class SetCookieRector extends AbstractRector implements MinPhpVersionInterface { /** * Conversion table from argument index to options name * @var array */ private const KNOWN_OPTIONS = [2 => 'expires', 3 => 'path', 4 => 'domain', 5 => 'secure', 6 => 'httponly']; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Convert setcookie argument to PHP7.3 option array', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Convert setcookie argument to PHP7.3 option array', [new CodeSample(<<<'CODE_SAMPLE' setcookie('name', $value, 360); CODE_SAMPLE , <<<'CODE_SAMPLE' setcookie('name', $value, ['expires' => 360]); CODE_SAMPLE -), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' +), new CodeSample(<<<'CODE_SAMPLE' setcookie('name', $name, 0, '', '', true, true); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -51,12 +51,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -66,9 +66,9 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::SETCOOKIE_ACCEPT_ARRAY_OPTIONS; + return PhpVersionFeature::SETCOOKIE_ACCEPT_ARRAY_OPTIONS; } - private function shouldSkip(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function shouldSkip(FuncCall $funcCall) : bool { if (!$this->isNames($funcCall, ['setcookie', 'setrawcookie'])) { return \true; @@ -77,18 +77,18 @@ CODE_SAMPLE if ($argsCount <= 2) { return \true; } - if ($funcCall->args[2] instanceof \PhpParser\Node\Arg && $funcCall->args[2]->value instanceof \PhpParser\Node\Expr\Array_) { + if ($funcCall->args[2] instanceof Arg && $funcCall->args[2]->value instanceof Array_) { return \true; } if ($argsCount === 3) { - return $funcCall->args[2] instanceof \PhpParser\Node\Arg && $funcCall->args[2]->value instanceof \PhpParser\Node\Expr\Variable; + return $funcCall->args[2] instanceof Arg && $funcCall->args[2]->value instanceof Variable; } return \false; } /** * @return Arg[]|VariadicPlaceholder[] */ - private function composeNewArgs(\PhpParser\Node\Expr\FuncCall $funcCall) : array + private function composeNewArgs(FuncCall $funcCall) : array { $items = []; $args = $funcCall->args; @@ -98,10 +98,10 @@ CODE_SAMPLE unset($args[0]); unset($args[1]); foreach ($args as $idx => $arg) { - $newKey = new \PhpParser\Node\Scalar\String_(self::KNOWN_OPTIONS[$idx]); - $items[] = new \PhpParser\Node\Expr\ArrayItem($arg->value, $newKey); + $newKey = new String_(self::KNOWN_OPTIONS[$idx]); + $items[] = new ArrayItem($arg->value, $newKey); } - $newArgs[] = new \PhpParser\Node\Arg(new \PhpParser\Node\Expr\Array_($items)); + $newArgs[] = new Arg(new Array_($items)); return $newArgs; } } diff --git a/rules/Php73/Rector/FuncCall/StringifyStrNeedlesRector.php b/rules/Php73/Rector/FuncCall/StringifyStrNeedlesRector.php index b6946defc64..0e170b55cfa 100644 --- a/rules/Php73/Rector/FuncCall/StringifyStrNeedlesRector.php +++ b/rules/Php73/Rector/FuncCall/StringifyStrNeedlesRector.php @@ -13,13 +13,13 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Php73\NodeTypeAnalyzer\NodeTypeAnalyzer; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/deprecations_php_7_3#string_search_functions_with_integer_needle * @see \Rector\Tests\Php73\Rector\FuncCall\StringifyStrNeedlesRector\StringifyStrNeedlesRectorTest */ -final class StringifyStrNeedlesRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class StringifyStrNeedlesRector extends AbstractRector implements MinPhpVersionInterface { /** * @var string[] @@ -30,17 +30,17 @@ final class StringifyStrNeedlesRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Php73\NodeTypeAnalyzer\NodeTypeAnalyzer */ private $nodeTypeAnalyzer; - public function __construct(\Rector\Php73\NodeTypeAnalyzer\NodeTypeAnalyzer $nodeTypeAnalyzer) + public function __construct(NodeTypeAnalyzer $nodeTypeAnalyzer) { $this->nodeTypeAnalyzer = $nodeTypeAnalyzer; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::DEPRECATE_INT_IN_STR_NEEDLES; + return PhpVersionFeature::DEPRECATE_INT_IN_STR_NEEDLES; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Makes needles explicit strings', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Makes needles explicit strings', [new CodeSample(<<<'CODE_SAMPLE' $needle = 5; $fivePosition = strpos('725', $needle); CODE_SAMPLE @@ -55,12 +55,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isNames($node, self::NEEDLE_STRING_SENSITIVE_FUNCTIONS)) { return null; @@ -68,25 +68,25 @@ CODE_SAMPLE if (!isset($node->args[1])) { return null; } - if (!$node->args[1] instanceof \PhpParser\Node\Arg) { + if (!$node->args[1] instanceof Arg) { return null; } // is argument string? $needleArgValue = $node->args[1]->value; $needleType = $this->getType($needleArgValue); - if ($needleType instanceof \PHPStan\Type\StringType) { + if ($needleType instanceof StringType) { return null; } if ($this->nodeTypeAnalyzer->isStringyType($needleType)) { return null; } - if ($needleArgValue instanceof \PhpParser\Node\Expr\Cast\String_) { + if ($needleArgValue instanceof String_) { return null; } - if ($needleArgValue instanceof \PhpParser\Node\Scalar\Encapsed) { + if ($needleArgValue instanceof Encapsed) { return null; } - $node->args[1]->value = new \PhpParser\Node\Expr\Cast\String_($node->args[1]->value); + $node->args[1]->value = new String_($node->args[1]->value); return $node; } } diff --git a/rules/Php73/Rector/String_/SensitiveHereNowDocRector.php b/rules/Php73/Rector/String_/SensitiveHereNowDocRector.php index b92a40aa2bb..e66b91df227 100644 --- a/rules/Php73/Rector/String_/SensitiveHereNowDocRector.php +++ b/rules/Php73/Rector/String_/SensitiveHereNowDocRector.php @@ -9,13 +9,13 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/flexible_heredoc_nowdoc_syntaxes * @see \Rector\Tests\Php73\Rector\String_\SensitiveHereNowDocRector\SensitiveHereNowDocRectorTest */ -final class SensitiveHereNowDocRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class SensitiveHereNowDocRector extends AbstractRector implements MinPhpVersionInterface { /** * @var string @@ -27,11 +27,11 @@ final class SensitiveHereNowDocRector extends \Rector\Core\Rector\AbstractRector private const ATTRIBUTE_DOC_LABEL = 'docLabel'; public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::SENSITIVE_HERE_NOW_DOC; + return PhpVersionFeature::SENSITIVE_HERE_NOW_DOC; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes heredoc/nowdoc that contains closing word to safe wrapper name', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes heredoc/nowdoc that contains closing word to safe wrapper name', [new CodeSample(<<<'CODE_SAMPLE' $value = <<getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND); - if (!\in_array($kind, [\PhpParser\Node\Scalar\String_::KIND_HEREDOC, \PhpParser\Node\Scalar\String_::KIND_NOWDOC], \true)) { + $kind = $node->getAttribute(AttributeKey::KIND); + if (!\in_array($kind, [String_::KIND_HEREDOC, String_::KIND_NOWDOC], \true)) { return null; } // the doc label is not in the string → ok @@ -67,7 +67,7 @@ CODE_SAMPLE } $node->setAttribute(self::ATTRIBUTE_DOC_LABEL, $this->uniquateDocLabel($node->value, $docLabel)); // invoke redraw - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); return $node; } private function uniquateDocLabel(string $value, string $docLabel) : string diff --git a/rules/Php74/Guard/MakePropertyTypedGuard.php b/rules/Php74/Guard/MakePropertyTypedGuard.php index 128386b8e17..94490307704 100644 --- a/rules/Php74/Guard/MakePropertyTypedGuard.php +++ b/rules/Php74/Guard/MakePropertyTypedGuard.php @@ -37,7 +37,7 @@ final class MakePropertyTypedGuard * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\NodeAnalyzer\PropertyAnalyzer $propertyAnalyzer, \Rector\Core\NodeManipulator\PropertyManipulator $propertyManipulator, \Rector\Privatization\Guard\ParentPropertyLookupGuard $parentPropertyLookupGuard, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(NodeNameResolver $nodeNameResolver, PropertyAnalyzer $propertyAnalyzer, PropertyManipulator $propertyManipulator, ParentPropertyLookupGuard $parentPropertyLookupGuard, ReflectionResolver $reflectionResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->propertyAnalyzer = $propertyAnalyzer; @@ -45,7 +45,7 @@ final class MakePropertyTypedGuard $this->parentPropertyLookupGuard = $parentPropertyLookupGuard; $this->reflectionResolver = $reflectionResolver; } - public function isLegal(\PhpParser\Node\Stmt\Property $property, bool $inlinePublic = \true) : bool + public function isLegal(Property $property, bool $inlinePublic = \true) : bool { if ($property->type !== null) { return \false; @@ -54,7 +54,7 @@ final class MakePropertyTypedGuard return \false; } $classReflection = $this->reflectionResolver->resolveClassReflection($property); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } /** @@ -76,7 +76,7 @@ final class MakePropertyTypedGuard } return $this->isSafeProtectedProperty($property, $classReflection); } - private function isSafeProtectedProperty(\PhpParser\Node\Stmt\Property $property, \PHPStan\Reflection\ClassReflection $classReflection) : bool + private function isSafeProtectedProperty(Property $property, ClassReflection $classReflection) : bool { if (!$property->isProtected()) { return \false; diff --git a/rules/Php74/NodeAnalyzer/ClosureArrowFunctionAnalyzer.php b/rules/Php74/NodeAnalyzer/ClosureArrowFunctionAnalyzer.php index f76735d60a3..813dbe9fea8 100644 --- a/rules/Php74/NodeAnalyzer/ClosureArrowFunctionAnalyzer.php +++ b/rules/Php74/NodeAnalyzer/ClosureArrowFunctionAnalyzer.php @@ -23,18 +23,18 @@ final class ClosureArrowFunctionAnalyzer * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeComparator $nodeComparator) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeComparator = $nodeComparator; } - public function matchArrowFunctionExpr(\PhpParser\Node\Expr\Closure $closure) : ?\PhpParser\Node\Expr + public function matchArrowFunctionExpr(Closure $closure) : ?Expr { if (\count($closure->stmts) !== 1) { return null; } $onlyStmt = $closure->stmts[0]; - if (!$onlyStmt instanceof \PhpParser\Node\Stmt\Return_) { + if (!$onlyStmt instanceof Return_) { return null; } /** @var Return_ $return */ @@ -47,13 +47,13 @@ final class ClosureArrowFunctionAnalyzer } return $return->expr; } - private function shouldSkipForUsedReferencedValue(\PhpParser\Node\Expr\Closure $closure) : bool + private function shouldSkipForUsedReferencedValue(Closure $closure) : bool { $referencedValues = $this->resolveReferencedUseVariablesFromClosure($closure); if ($referencedValues === []) { return \false; } - $isFoundInStmt = (bool) $this->betterNodeFinder->findFirstInFunctionLikeScoped($closure, function (\PhpParser\Node $node) use($referencedValues) : bool { + $isFoundInStmt = (bool) $this->betterNodeFinder->findFirstInFunctionLikeScoped($closure, function (Node $node) use($referencedValues) : bool { foreach ($referencedValues as $referencedValue) { if ($this->nodeComparator->areNodesEqual($node, $referencedValue)) { return \true; @@ -69,14 +69,14 @@ final class ClosureArrowFunctionAnalyzer /** * @param Variable[] $referencedValues */ - private function isFoundInInnerUses(\PhpParser\Node\Expr\Closure $node, array $referencedValues) : bool + private function isFoundInInnerUses(Closure $node, array $referencedValues) : bool { - return (bool) $this->betterNodeFinder->findFirstInFunctionLikeScoped($node, function (\PhpParser\Node $subNode) use($referencedValues) : bool { - if (!$subNode instanceof \PhpParser\Node\Expr\Closure) { + return (bool) $this->betterNodeFinder->findFirstInFunctionLikeScoped($node, function (Node $subNode) use($referencedValues) : bool { + if (!$subNode instanceof Closure) { return \false; } foreach ($referencedValues as $referencedValue) { - $isFoundInInnerUses = (bool) \array_filter($subNode->uses, function (\PhpParser\Node\Expr\ClosureUse $closureUse) use($referencedValue) : bool { + $isFoundInInnerUses = (bool) \array_filter($subNode->uses, function (ClosureUse $closureUse) use($referencedValue) : bool { return $closureUse->byRef && $this->nodeComparator->areNodesEqual($closureUse->var, $referencedValue); }); if ($isFoundInInnerUses) { @@ -89,7 +89,7 @@ final class ClosureArrowFunctionAnalyzer /** * @return Variable[] */ - private function resolveReferencedUseVariablesFromClosure(\PhpParser\Node\Expr\Closure $closure) : array + private function resolveReferencedUseVariablesFromClosure(Closure $closure) : array { $referencedValues = []; /** @var ClosureUse $use */ diff --git a/rules/Php74/Rector/ArrayDimFetch/CurlyToSquareBracketArrayStringRector.php b/rules/Php74/Rector/ArrayDimFetch/CurlyToSquareBracketArrayStringRector.php index b72f56a6fd1..92b98a48a14 100644 --- a/rules/Php74/Rector/ArrayDimFetch/CurlyToSquareBracketArrayStringRector.php +++ b/rules/Php74/Rector/ArrayDimFetch/CurlyToSquareBracketArrayStringRector.php @@ -10,30 +10,30 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Php74\Tokenizer\FollowedByCurlyBracketAnalyzer; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/migration74.deprecated.php * @see \Rector\Tests\Php74\Rector\ArrayDimFetch\CurlyToSquareBracketArrayStringRector\CurlyToSquareBracketArrayStringRectorTest */ -final class CurlyToSquareBracketArrayStringRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class CurlyToSquareBracketArrayStringRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\Php74\Tokenizer\FollowedByCurlyBracketAnalyzer */ private $followedByCurlyBracketAnalyzer; - public function __construct(\Rector\Php74\Tokenizer\FollowedByCurlyBracketAnalyzer $followedByCurlyBracketAnalyzer) + public function __construct(FollowedByCurlyBracketAnalyzer $followedByCurlyBracketAnalyzer) { $this->followedByCurlyBracketAnalyzer = $followedByCurlyBracketAnalyzer; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::DEPRECATE_CURLY_BRACKET_ARRAY_STRING; + return PhpVersionFeature::DEPRECATE_CURLY_BRACKET_ARRAY_STRING; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change curly based array and string to square bracket', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change curly based array and string to square bracket', [new CodeSample(<<<'CODE_SAMPLE' $string = 'test'; echo $string{0}; $array = ['test']; @@ -52,18 +52,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\ArrayDimFetch::class]; + return [ArrayDimFetch::class]; } /** * @param ArrayDimFetch $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->followedByCurlyBracketAnalyzer->isFollowed($this->file, $node)) { return null; } // re-draw the ArrayDimFetch to use [] bracket - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); return $node; } } diff --git a/rules/Php74/Rector/Assign/NullCoalescingOperatorRector.php b/rules/Php74/Rector/Assign/NullCoalescingOperatorRector.php index 7f0dd2b8ac6..9cee5e775b3 100644 --- a/rules/Php74/Rector/Assign/NullCoalescingOperatorRector.php +++ b/rules/Php74/Rector/Assign/NullCoalescingOperatorRector.php @@ -10,17 +10,17 @@ use PhpParser\Node\Expr\BinaryOp\Coalesce; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/null_coalesce_equal_operator * @see \Rector\Tests\Php74\Rector\Assign\NullCoalescingOperatorRector\NullCoalescingOperatorRectorTest */ -final class NullCoalescingOperatorRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class NullCoalescingOperatorRector extends AbstractRector implements MinPhpVersionInterface { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Use null coalescing operator ??=', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Use null coalescing operator ??=', [new CodeSample(<<<'CODE_SAMPLE' $array = []; $array['user_id'] = $array['user_id'] ?? 'value'; CODE_SAMPLE @@ -35,23 +35,23 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Assign::class]; + return [Assign::class]; } /** * @param Assign $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Expr\AssignOp\Coalesce + public function refactor(Node $node) : ?AssignCoalesce { - if (!$node->expr instanceof \PhpParser\Node\Expr\BinaryOp\Coalesce) { + if (!$node->expr instanceof Coalesce) { return null; } if (!$this->nodeComparator->areNodesEqual($node->var, $node->expr->left)) { return null; } - return new \PhpParser\Node\Expr\AssignOp\Coalesce($node->var, $node->expr->right); + return new AssignCoalesce($node->var, $node->expr->right); } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NULL_COALESCE_ASSIGN; + return PhpVersionFeature::NULL_COALESCE_ASSIGN; } } diff --git a/rules/Php74/Rector/Closure/ClosureToArrowFunctionRector.php b/rules/Php74/Rector/Closure/ClosureToArrowFunctionRector.php index 36a2fbfcaf7..d3e9c1bc8f5 100644 --- a/rules/Php74/Rector/Closure/ClosureToArrowFunctionRector.php +++ b/rules/Php74/Rector/Closure/ClosureToArrowFunctionRector.php @@ -12,27 +12,27 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Php74\NodeAnalyzer\ClosureArrowFunctionAnalyzer; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/arrow_functions_v2 * * @see \Rector\Tests\Php74\Rector\Closure\ClosureToArrowFunctionRector\ClosureToArrowFunctionRectorTest */ -final class ClosureToArrowFunctionRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ClosureToArrowFunctionRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\Php74\NodeAnalyzer\ClosureArrowFunctionAnalyzer */ private $closureArrowFunctionAnalyzer; - public function __construct(\Rector\Php74\NodeAnalyzer\ClosureArrowFunctionAnalyzer $closureArrowFunctionAnalyzer) + public function __construct(ClosureArrowFunctionAnalyzer $closureArrowFunctionAnalyzer) { $this->closureArrowFunctionAnalyzer = $closureArrowFunctionAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change closure to arrow function', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change closure to arrow function', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($meetups) @@ -59,30 +59,30 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Closure::class]; + return [Closure::class]; } /** * @param Closure $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $returnExpr = $this->closureArrowFunctionAnalyzer->matchArrowFunctionExpr($node); - if (!$returnExpr instanceof \PhpParser\Node\Expr) { + if (!$returnExpr instanceof Expr) { return null; } - $arrowFunction = new \PhpParser\Node\Expr\ArrowFunction(['params' => $node->params, 'returnType' => $node->returnType, 'byRef' => $node->byRef, 'expr' => $returnExpr]); + $arrowFunction = new ArrowFunction(['params' => $node->params, 'returnType' => $node->returnType, 'byRef' => $node->byRef, 'expr' => $returnExpr]); if ($node->static) { $arrowFunction->static = \true; } - $comments = $node->stmts[0]->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS) ?? []; + $comments = $node->stmts[0]->getAttribute(AttributeKey::COMMENTS) ?? []; if ($comments !== []) { $this->mirrorComments($arrowFunction->expr, $node->stmts[0]); - $arrowFunction->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENT_CLOSURE_RETURN_MIRRORED, \true); + $arrowFunction->setAttribute(AttributeKey::COMMENT_CLOSURE_RETURN_MIRRORED, \true); } return $arrowFunction; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::ARROW_FUNCTION; + return PhpVersionFeature::ARROW_FUNCTION; } } diff --git a/rules/Php74/Rector/Double/RealToFloatTypeCastRector.php b/rules/Php74/Rector/Double/RealToFloatTypeCastRector.php index 9990a426f2f..0b7096c48a8 100644 --- a/rules/Php74/Rector/Double/RealToFloatTypeCastRector.php +++ b/rules/Php74/Rector/Double/RealToFloatTypeCastRector.php @@ -9,21 +9,21 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/deprecations_php_7_4 * @see \Rector\Tests\Php74\Rector\Double\RealToFloatTypeCastRector\RealToFloatTypeCastRectorTest */ -final class RealToFloatTypeCastRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class RealToFloatTypeCastRector extends AbstractRector implements MinPhpVersionInterface { public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::DEPRECATE_REAL; + return PhpVersionFeature::DEPRECATE_REAL; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change deprecated (real) to (float)', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change deprecated (real) to (float)', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -52,19 +52,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Cast\Double::class]; + return [Double::class]; } /** * @param Double $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $kind = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND); - if ($kind !== \PhpParser\Node\Expr\Cast\Double::KIND_REAL) { + $kind = $node->getAttribute(AttributeKey::KIND); + if ($kind !== Double::KIND_REAL) { return null; } - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND, \PhpParser\Node\Expr\Cast\Double::KIND_FLOAT); - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $node->setAttribute(AttributeKey::KIND, Double::KIND_FLOAT); + $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); return $node; } } diff --git a/rules/Php74/Rector/FuncCall/ArrayKeyExistsOnPropertyRector.php b/rules/Php74/Rector/FuncCall/ArrayKeyExistsOnPropertyRector.php index d955b851c36..86426872bcd 100644 --- a/rules/Php74/Rector/FuncCall/ArrayKeyExistsOnPropertyRector.php +++ b/rules/Php74/Rector/FuncCall/ArrayKeyExistsOnPropertyRector.php @@ -11,22 +11,22 @@ use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/deprecations_php_7_4 (not confirmed yet) * @changelog https://3v4l.org/69mpd * @see \Rector\Tests\Php74\Rector\FuncCall\ArrayKeyExistsOnPropertyRector\ArrayKeyExistsOnPropertyRectorTest */ -final class ArrayKeyExistsOnPropertyRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ArrayKeyExistsOnPropertyRector extends AbstractRector implements MinPhpVersionInterface { public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::ARRAY_KEY_EXISTS_TO_PROPERTY_EXISTS; + return PhpVersionFeature::ARRAY_KEY_EXISTS_TO_PROPERTY_EXISTS; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change array_key_exists() on property to property_exists()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change array_key_exists() on property to property_exists()', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public $value; @@ -51,12 +51,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'array_key_exists')) { return null; @@ -64,14 +64,14 @@ CODE_SAMPLE if (!isset($node->args[1])) { return null; } - if (!$node->args[1] instanceof \PhpParser\Node\Arg) { + if (!$node->args[1] instanceof Arg) { return null; } $firstArgStaticType = $this->getType($node->args[1]->value); - if (!$firstArgStaticType instanceof \PHPStan\Type\ObjectType) { + if (!$firstArgStaticType instanceof ObjectType) { return null; } - $node->name = new \PhpParser\Node\Name('property_exists'); + $node->name = new Name('property_exists'); $node->args = \array_reverse($node->args); return $node; } diff --git a/rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php b/rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php index 2cd250333da..e1d596dc9de 100644 --- a/rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php +++ b/rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php @@ -19,15 +19,15 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\TypeAnalyzer\ArrayTypeAnalyzer; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/spread_operator_for_array * * @see \Rector\Tests\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector\Php74ArraySpreadInsteadOfArrayMergeRectorTest * @see \Rector\Tests\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector\Php81ArraySpreadInsteadOfArrayMergeRectorTest */ -final class ArraySpreadInsteadOfArrayMergeRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ArraySpreadInsteadOfArrayMergeRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -39,14 +39,14 @@ final class ArraySpreadInsteadOfArrayMergeRector extends \Rector\Core\Rector\Abs * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\NodeTypeResolver\TypeAnalyzer\ArrayTypeAnalyzer $arrayTypeAnalyzer, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(ArrayTypeAnalyzer $arrayTypeAnalyzer, PhpVersionProvider $phpVersionProvider) { $this->arrayTypeAnalyzer = $arrayTypeAnalyzer; $this->phpVersionProvider = $phpVersionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change array_merge() to spread operator', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change array_merge() to spread operator', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($iter1, $iter2) @@ -80,12 +80,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->isName($node, 'array_merge')) { return $this->refactorArray($node); @@ -94,13 +94,13 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::ARRAY_SPREAD; + return PhpVersionFeature::ARRAY_SPREAD; } - private function refactorArray(\PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Expr\Array_ + private function refactorArray(FuncCall $funcCall) : ?Array_ { - $array = new \PhpParser\Node\Expr\Array_(); + $array = new Array_(); foreach ($funcCall->args as $arg) { - if (!$arg instanceof \PhpParser\Node\Arg) { + if (!$arg instanceof Arg) { continue; } // cannot handle unpacked arguments @@ -116,23 +116,23 @@ CODE_SAMPLE } return $array; } - private function shouldSkipArrayForInvalidTypeOrKeys(\PhpParser\Node\Expr $expr) : bool + private function shouldSkipArrayForInvalidTypeOrKeys(Expr $expr) : bool { // we have no idea what it is → cannot change it if (!$this->arrayTypeAnalyzer->isArrayType($expr)) { return \true; } $arrayStaticType = $this->getType($expr); - if (!$arrayStaticType instanceof \PHPStan\Type\ArrayType) { + if (!$arrayStaticType instanceof ArrayType) { return \true; } return !$this->isArrayKeyTypeAllowed($arrayStaticType); } - private function isArrayKeyTypeAllowed(\PHPStan\Type\ArrayType $arrayType) : bool + private function isArrayKeyTypeAllowed(ArrayType $arrayType) : bool { - $allowedKeyTypes = [\PHPStan\Type\IntegerType::class]; - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::ARRAY_SPREAD_STRING_KEYS)) { - $allowedKeyTypes[] = \PHPStan\Type\StringType::class; + $allowedKeyTypes = [IntegerType::class]; + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::ARRAY_SPREAD_STRING_KEYS)) { + $allowedKeyTypes[] = StringType::class; } foreach ($allowedKeyTypes as $allowedKeyType) { if ($arrayType->getKeyType() instanceof $allowedKeyType) { @@ -141,35 +141,35 @@ CODE_SAMPLE } return \false; } - private function resolveValue(\PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr + private function resolveValue(Expr $expr) : Expr { - if ($expr instanceof \PhpParser\Node\Expr\FuncCall && $this->isIteratorToArrayFuncCall($expr)) { + if ($expr instanceof FuncCall && $this->isIteratorToArrayFuncCall($expr)) { /** @var Arg $arg */ $arg = $expr->args[0]; /** @var FuncCall $expr */ $expr = $arg->value; } - if (!$expr instanceof \PhpParser\Node\Expr\Ternary) { + if (!$expr instanceof Ternary) { return $expr; } - if (!$expr->cond instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$expr->cond instanceof FuncCall) { return $expr; } if (!$this->isName($expr->cond, 'is_array')) { return $expr; } - if ($expr->if instanceof \PhpParser\Node\Expr\Variable && $this->isIteratorToArrayFuncCall($expr->else)) { + if ($expr->if instanceof Variable && $this->isIteratorToArrayFuncCall($expr->else)) { return $expr->if; } return $expr; } - private function createUnpackedArrayItem(\PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr\ArrayItem + private function createUnpackedArrayItem(Expr $expr) : ArrayItem { - return new \PhpParser\Node\Expr\ArrayItem($expr, null, \false, [], \true); + return new ArrayItem($expr, null, \false, [], \true); } - private function isIteratorToArrayFuncCall(\PhpParser\Node\Expr $expr) : bool + private function isIteratorToArrayFuncCall(Expr $expr) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$expr instanceof FuncCall) { return \false; } if (!$this->nodeNameResolver->isName($expr, 'iterator_to_array')) { @@ -178,6 +178,6 @@ CODE_SAMPLE if (!isset($expr->args[0])) { return \false; } - return $expr->args[0] instanceof \PhpParser\Node\Arg; + return $expr->args[0] instanceof Arg; } } diff --git a/rules/Php74/Rector/FuncCall/FilterVarToAddSlashesRector.php b/rules/Php74/Rector/FuncCall/FilterVarToAddSlashesRector.php index e79f47444aa..6974e32d1fe 100644 --- a/rules/Php74/Rector/FuncCall/FilterVarToAddSlashesRector.php +++ b/rules/Php74/Rector/FuncCall/FilterVarToAddSlashesRector.php @@ -10,22 +10,22 @@ use PhpParser\Node\Name; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/deprecations_php_7_4 (not confirmed yet) * @changelog https://3v4l.org/9rLjE * @see \Rector\Tests\Php74\Rector\FuncCall\FilterVarToAddSlashesRector\FilterVarToAddSlashesRectorTest */ -final class FilterVarToAddSlashesRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class FilterVarToAddSlashesRector extends AbstractRector implements MinPhpVersionInterface { public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::FILTER_VAR_TO_ADD_SLASHES; + return PhpVersionFeature::FILTER_VAR_TO_ADD_SLASHES; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change filter_var() with slash escaping to addslashes()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change filter_var() with slash escaping to addslashes()', [new CodeSample(<<<'CODE_SAMPLE' $var= "Satya's here!"; filter_var($var, FILTER_SANITIZE_MAGIC_QUOTES); CODE_SAMPLE @@ -40,12 +40,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'filter_var')) { return null; @@ -53,13 +53,13 @@ CODE_SAMPLE if (!isset($node->args[1])) { return null; } - if (!$node->args[1] instanceof \PhpParser\Node\Arg) { + if (!$node->args[1] instanceof Arg) { return null; } if (!$this->isName($node->args[1]->value, 'FILTER_SANITIZE_MAGIC_QUOTES')) { return null; } - $node->name = new \PhpParser\Node\Name('addslashes'); + $node->name = new Name('addslashes'); unset($node->args[1]); return $node; } diff --git a/rules/Php74/Rector/FuncCall/MbStrrposEncodingArgumentPositionRector.php b/rules/Php74/Rector/FuncCall/MbStrrposEncodingArgumentPositionRector.php index b5b137e28d7..7df1208873d 100644 --- a/rules/Php74/Rector/FuncCall/MbStrrposEncodingArgumentPositionRector.php +++ b/rules/Php74/Rector/FuncCall/MbStrrposEncodingArgumentPositionRector.php @@ -11,34 +11,34 @@ use PHPStan\Type\IntegerType; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/deprecations_php_7_4 https://3v4l.org/kLdtB * * @see \Rector\Tests\Php74\Rector\FuncCall\MbStrrposEncodingArgumentPositionRector\MbStrrposEncodingArgumentPositionRectorTest */ -final class MbStrrposEncodingArgumentPositionRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class MbStrrposEncodingArgumentPositionRector extends AbstractRector implements MinPhpVersionInterface { public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::CHANGE_MB_STRPOS_ARG_POSITION; + return PhpVersionFeature::CHANGE_MB_STRPOS_ARG_POSITION; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change mb_strrpos() encoding argument position', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('mb_strrpos($text, "abc", "UTF-8");', 'mb_strrpos($text, "abc", 0, "UTF-8");')]); + return new RuleDefinition('Change mb_strrpos() encoding argument position', [new CodeSample('mb_strrpos($text, "abc", "UTF-8");', 'mb_strrpos($text, "abc", 0, "UTF-8");')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'mb_strrpos')) { return null; @@ -49,15 +49,15 @@ final class MbStrrposEncodingArgumentPositionRector extends \Rector\Core\Rector\ if (isset($node->args[3])) { return null; } - if (!$node->args[2] instanceof \PhpParser\Node\Arg) { + if (!$node->args[2] instanceof Arg) { return null; } $secondArgType = $this->getType($node->args[2]->value); - if ($secondArgType instanceof \PHPStan\Type\IntegerType) { + if ($secondArgType instanceof IntegerType) { return null; } $node->args[3] = $node->args[2]; - $node->args[2] = new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\LNumber(0)); + $node->args[2] = new Arg(new LNumber(0)); return $node; } } diff --git a/rules/Php74/Rector/LNumber/AddLiteralSeparatorToNumberRector.php b/rules/Php74/Rector/LNumber/AddLiteralSeparatorToNumberRector.php index dbf82c64e3f..cb76c2737b9 100644 --- a/rules/Php74/Rector/LNumber/AddLiteralSeparatorToNumberRector.php +++ b/rules/Php74/Rector/LNumber/AddLiteralSeparatorToNumberRector.php @@ -13,8 +13,8 @@ use Rector\Core\Util\StringUtils; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @changelog https://wiki.php.net/rfc/numeric_literal_separator @@ -25,7 +25,7 @@ use RectorPrefix20220607\Webmozart\Assert\Assert; * Taking the most generic use case to the account: https://wiki.php.net/rfc/numeric_literal_separator#should_it_be_the_role_of_an_ide_to_group_digits * The final check should be done manually */ -final class AddLiteralSeparatorToNumberRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface, \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class AddLiteralSeparatorToNumberRector extends AbstractRector implements AllowEmptyConfigurableRectorInterface, MinPhpVersionInterface { /** * @api @@ -50,12 +50,12 @@ final class AddLiteralSeparatorToNumberRector extends \Rector\Core\Rector\Abstra public function configure(array $configuration) : void { $limitValue = $configuration[self::LIMIT_VALUE] ?? self::DEFAULT_LIMIT_VALUE; - \RectorPrefix20220607\Webmozart\Assert\Assert::integer($limitValue); + Assert::integer($limitValue); $this->limitValue = $limitValue; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add "_" as thousands separator in numbers for higher or equals to limitValue config', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add "_" as thousands separator in numbers for higher or equals to limitValue config', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -82,14 +82,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Scalar\LNumber::class, \PhpParser\Node\Scalar\DNumber::class]; + return [LNumber::class, DNumber::class]; } /** * @param LNumber|DNumber $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $rawValue = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::RAW_VALUE); + $rawValue = $node->getAttribute(AttributeKey::RAW_VALUE); if ($this->shouldSkip($node, $rawValue)) { return null; } @@ -110,7 +110,7 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::LITERAL_SEPARATOR; + return PhpVersionFeature::LITERAL_SEPARATOR; } /** * @param \PhpParser\Node\Scalar\LNumber|\PhpParser\Node\Scalar\DNumber $node @@ -128,16 +128,16 @@ CODE_SAMPLE if ($node->value < $this->limitValue) { return \true; } - $kind = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND); - if (\in_array($kind, [\PhpParser\Node\Scalar\LNumber::KIND_BIN, \PhpParser\Node\Scalar\LNumber::KIND_OCT, \PhpParser\Node\Scalar\LNumber::KIND_HEX], \true)) { + $kind = $node->getAttribute(AttributeKey::KIND); + if (\in_array($kind, [LNumber::KIND_BIN, LNumber::KIND_OCT, LNumber::KIND_HEX], \true)) { return \true; } // e+/e- - if (\Rector\Core\Util\StringUtils::isMatch($rawValue, '#e#i')) { + if (StringUtils::isMatch($rawValue, '#e#i')) { return \true; } // too short - return \RectorPrefix20220607\Nette\Utils\Strings::length($rawValue) <= self::GROUP_SIZE; + return Strings::length($rawValue) <= self::GROUP_SIZE; } /** * @return string[] diff --git a/rules/Php74/Rector/MethodCall/ChangeReflectionTypeToStringToGetNameRector.php b/rules/Php74/Rector/MethodCall/ChangeReflectionTypeToStringToGetNameRector.php index 3f661f26c88..61031e5a666 100644 --- a/rules/Php74/Rector/MethodCall/ChangeReflectionTypeToStringToGetNameRector.php +++ b/rules/Php74/Rector/MethodCall/ChangeReflectionTypeToStringToGetNameRector.php @@ -16,8 +16,8 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.reddit.com/r/PHP/comments/apikof/whats_the_deal_with_reflectiontype/ https://www.php.net/manual/en/reflectiontype.tostring.php * @@ -26,7 +26,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @see \Rector\Tests\Php74\Rector\MethodCall\ChangeReflectionTypeToStringToGetNameRector\ChangeReflectionTypeToStringToGetNameRectorTest */ -final class ChangeReflectionTypeToStringToGetNameRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ChangeReflectionTypeToStringToGetNameRector extends AbstractRector implements MinPhpVersionInterface { /** * @var string @@ -39,11 +39,11 @@ final class ChangeReflectionTypeToStringToGetNameRector extends \Rector\Core\Rec private $callsByVariable = []; public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::REFLECTION_TYPE_GETNAME; + return PhpVersionFeature::REFLECTION_TYPE_GETNAME; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change string calls on ReflectionType', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change string calls on ReflectionType', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function go(ReflectionFunction $reflectionFunction) @@ -82,27 +82,27 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\Cast\String_::class]; + return [MethodCall::class, String_::class]; } /** * @param MethodCall|String_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node instanceof MethodCall) { return $this->refactorMethodCall($node); } - if ($node->expr instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node->expr instanceof MethodCall) { return $this->refactorIfHasReturnTypeWasCalled($node->expr); } - if (!$node->expr instanceof \PhpParser\Node\Expr\Variable) { + if (!$node->expr instanceof Variable) { return null; } - if (!$this->isObjectType($node->expr, new \PHPStan\Type\ObjectType('ReflectionType'))) { + if (!$this->isObjectType($node->expr, new ObjectType('ReflectionType'))) { return null; } $type = $this->nodeTypeResolver->getType($node->expr); - if (!$type instanceof \PHPStan\Type\UnionType) { + if (!$type instanceof UnionType) { return $this->nodeFactory->createMethodCall($node->expr, self::GET_NAME); } if (!$this->isWithReflectionType($type)) { @@ -110,10 +110,10 @@ CODE_SAMPLE } return null; } - private function isWithReflectionType(\PHPStan\Type\UnionType $unionType) : bool + private function isWithReflectionType(UnionType $unionType) : bool { foreach ($unionType->getTypes() as $type) { - if (!$type instanceof \PHPStan\Type\ObjectType) { + if (!$type instanceof ObjectType) { continue; } if ($type->getClassName() !== 'ReflectionType') { @@ -123,7 +123,7 @@ CODE_SAMPLE } return \false; } - private function refactorMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node + private function refactorMethodCall(MethodCall $methodCall) : ?Node { $this->collectCallByVariable($methodCall); if ($this->shouldSkipMethodCall($methodCall)) { @@ -137,9 +137,9 @@ CODE_SAMPLE } return null; } - private function refactorIfHasReturnTypeWasCalled(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node + private function refactorIfHasReturnTypeWasCalled(MethodCall $methodCall) : ?Node { - if (!$methodCall->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$methodCall->var instanceof Variable) { return null; } $variableName = $this->getName($methodCall->var); @@ -150,10 +150,10 @@ CODE_SAMPLE } return null; } - private function collectCallByVariable(\PhpParser\Node\Expr\MethodCall $methodCall) : void + private function collectCallByVariable(MethodCall $methodCall) : void { // bit workaround for now - if ($methodCall->var instanceof \PhpParser\Node\Expr\Variable) { + if ($methodCall->var instanceof Variable) { $variableName = $this->getName($methodCall->var); $methodName = $this->getName($methodCall->name); if (!\is_string($variableName)) { @@ -165,36 +165,36 @@ CODE_SAMPLE $this->callsByVariable[$variableName][] = $methodName; } } - private function shouldSkipMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + private function shouldSkipMethodCall(MethodCall $methodCall) : bool { - $scope = $methodCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $methodCall->getAttribute(AttributeKey::SCOPE); // just added node → skip it - if (!$scope instanceof \PHPStan\Analyser\Scope) { + if (!$scope instanceof Scope) { return \true; } // is to string retype? - $parentNode = $methodCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentNode instanceof \PhpParser\Node\Expr\Cast\String_) { + $parentNode = $methodCall->getAttribute(AttributeKey::PARENT_NODE); + if ($parentNode instanceof String_) { return \false; } // probably already converted - return !$parentNode instanceof \PhpParser\Node\Expr\BinaryOp\Concat; + return !$parentNode instanceof Concat; } - private function isReflectionParameterGetTypeMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + private function isReflectionParameterGetTypeMethodCall(MethodCall $methodCall) : bool { - if (!$this->isObjectType($methodCall->var, new \PHPStan\Type\ObjectType('ReflectionParameter'))) { + if (!$this->isObjectType($methodCall->var, new ObjectType('ReflectionParameter'))) { return \false; } return $this->isName($methodCall->name, 'getType'); } - private function refactorReflectionParameterGetName(\PhpParser\Node\Expr\MethodCall $methodCall) : \PhpParser\Node\Expr\Ternary + private function refactorReflectionParameterGetName(MethodCall $methodCall) : Ternary { $getNameMethodCall = $this->nodeFactory->createMethodCall($methodCall, self::GET_NAME); - return new \PhpParser\Node\Expr\Ternary($methodCall, $getNameMethodCall, $this->nodeFactory->createNull()); + return new Ternary($methodCall, $getNameMethodCall, $this->nodeFactory->createNull()); } - private function isReflectionFunctionAbstractGetReturnTypeMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + private function isReflectionFunctionAbstractGetReturnTypeMethodCall(MethodCall $methodCall) : bool { - if (!$this->isObjectType($methodCall->var, new \PHPStan\Type\ObjectType('ReflectionFunctionAbstract'))) { + if (!$this->isObjectType($methodCall->var, new ObjectType('ReflectionFunctionAbstract'))) { return \false; } return $this->isName($methodCall->name, 'getReturnType'); @@ -202,13 +202,13 @@ CODE_SAMPLE /** * @return \PhpParser\Node|\PhpParser\Node\Expr\Ternary */ - private function refactorReflectionFunctionGetReturnType(\PhpParser\Node\Expr\MethodCall $methodCall) + private function refactorReflectionFunctionGetReturnType(MethodCall $methodCall) { $refactoredMethodCall = $this->refactorIfHasReturnTypeWasCalled($methodCall); if ($refactoredMethodCall !== null) { return $refactoredMethodCall; } $getNameMethodCall = $this->nodeFactory->createMethodCall($methodCall, self::GET_NAME); - return new \PhpParser\Node\Expr\Ternary($methodCall, $getNameMethodCall, $this->nodeFactory->createNull()); + return new Ternary($methodCall, $getNameMethodCall, $this->nodeFactory->createNull()); } } diff --git a/rules/Php74/Rector/Property/RestoreDefaultNullToNullableTypePropertyRector.php b/rules/Php74/Rector/Property/RestoreDefaultNullToNullableTypePropertyRector.php index 9c3925ce6a2..9d6b4879b98 100644 --- a/rules/Php74/Rector/Property/RestoreDefaultNullToNullableTypePropertyRector.php +++ b/rules/Php74/Rector/Property/RestoreDefaultNullToNullableTypePropertyRector.php @@ -10,25 +10,25 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector\RestoreDefaultNullToNullableTypePropertyRectorTest */ -final class RestoreDefaultNullToNullableTypePropertyRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class RestoreDefaultNullToNullableTypePropertyRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector */ private $constructorAssignDetector; - public function __construct(\Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector $constructorAssignDetector) + public function __construct(ConstructorAssignDetector $constructorAssignDetector) { $this->constructorAssignDetector = $constructorAssignDetector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add null default to properties with PHP 7.4 property nullable type', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add null default to properties with PHP 7.4 property nullable type', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public ?string $name; @@ -47,12 +47,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -63,9 +63,9 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES; + return PhpVersionFeature::TYPED_PROPERTIES; } - private function shouldSkip(\PhpParser\Node\Stmt\Property $property) : bool + private function shouldSkip(Property $property) : bool { if ($property->type === null) { return \true; @@ -85,10 +85,10 @@ CODE_SAMPLE } // is variable assigned in constructor $propertyName = $this->getName($property); - $classLike = $this->betterNodeFinder->findParentType($property, \PhpParser\Node\Stmt\Class_::class); + $classLike = $this->betterNodeFinder->findParentType($property, Class_::class); // a trait can be used in multiple context, we don't know whether it is assigned in __construct or not // so it needs to has null default - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + if (!$classLike instanceof Class_) { return \false; } return $this->constructorAssignDetector->isPropertyAssigned($classLike, $propertyName); diff --git a/rules/Php74/Rector/Property/TypedPropertyRector.php b/rules/Php74/Rector/Property/TypedPropertyRector.php index 756a826f36c..c7f0d73b70c 100644 --- a/rules/Php74/Rector/Property/TypedPropertyRector.php +++ b/rules/Php74/Rector/Property/TypedPropertyRector.php @@ -27,8 +27,8 @@ use Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector; use Rector\TypeDeclaration\TypeInferer\VarDocPropertyTypeInferer; use Rector\VendorLocker\VendorLockResolver; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/typed_properties_v2#proposal * @@ -37,7 +37,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * @see \Rector\Tests\Php74\Rector\Property\TypedPropertyRector\DoctrineTypedPropertyRectorTest * @see \Rector\Tests\Php74\Rector\Property\TypedPropertyRector\ImportedTest */ -final class TypedPropertyRector extends \Rector\Core\Rector\AbstractScopeAwareRector implements \Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface, \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class TypedPropertyRector extends AbstractScopeAwareRector implements AllowEmptyConfigurableRectorInterface, MinPhpVersionInterface { /** * @var string @@ -93,7 +93,7 @@ final class TypedPropertyRector extends \Rector\Core\Rector\AbstractScopeAwareRe * @var \Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector */ private $constructorAssignDetector; - public function __construct(\Rector\TypeDeclaration\TypeInferer\VarDocPropertyTypeInferer $varDocPropertyTypeInferer, \Rector\VendorLocker\VendorLockResolver $vendorLockResolver, \Rector\PHPStanStaticTypeMapper\DoctrineTypeAnalyzer $doctrineTypeAnalyzer, \Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover $varTagRemover, \Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer $familyRelationsAnalyzer, \Rector\Php74\TypeAnalyzer\ObjectTypeAnalyzer $objectTypeAnalyzer, \Rector\Php74\Guard\MakePropertyTypedGuard $makePropertyTypedGuard, \Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector $constructorAssignDetector) + public function __construct(VarDocPropertyTypeInferer $varDocPropertyTypeInferer, VendorLockResolver $vendorLockResolver, DoctrineTypeAnalyzer $doctrineTypeAnalyzer, VarTagRemover $varTagRemover, FamilyRelationsAnalyzer $familyRelationsAnalyzer, ObjectTypeAnalyzer $objectTypeAnalyzer, MakePropertyTypedGuard $makePropertyTypedGuard, ConstructorAssignDetector $constructorAssignDetector) { $this->varDocPropertyTypeInferer = $varDocPropertyTypeInferer; $this->vendorLockResolver = $vendorLockResolver; @@ -108,9 +108,9 @@ final class TypedPropertyRector extends \Rector\Core\Rector\AbstractScopeAwareRe { $this->inlinePublic = $configuration[self::INLINE_PUBLIC] ?? (bool) \current($configuration); } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes property type by `@var` annotations or default value.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes property type by `@var` annotations or default value.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' final class SomeClass { /** @@ -136,24 +136,24 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactorWithScope(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : ?\PhpParser\Node + public function refactorWithScope(Node $node, Scope $scope) : ?Node { if (!$this->makePropertyTypedGuard->isLegal($node, $this->inlinePublic)) { return null; } $varType = $this->varDocPropertyTypeInferer->inferProperty($node); - if ($varType instanceof \PHPStan\Type\MixedType) { + if ($varType instanceof MixedType) { return null; } if ($this->objectTypeAnalyzer->isSpecial($varType)) { return null; } - $propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($varType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY); + $propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($varType, TypeKind::PROPERTY); if ($this->isNullOrNonClassLikeTypeOrMixedOrVendorLockedIn($propertyTypeNode, $node)) { return null; } @@ -168,21 +168,21 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES; + return PhpVersionFeature::TYPED_PROPERTIES; } /** * @param \PhpParser\Node\Name|\PhpParser\Node\ComplexType|null $node */ - private function isNullOrNonClassLikeTypeOrMixedOrVendorLockedIn($node, \PhpParser\Node\Stmt\Property $property) : bool + private function isNullOrNonClassLikeTypeOrMixedOrVendorLockedIn($node, Property $property) : bool { - if (!$node instanceof \PhpParser\Node) { + if (!$node instanceof Node) { return \true; } - if ($node instanceof \PhpParser\Node\NullableType && $this->isName($node->type, 'mixed')) { + if ($node instanceof NullableType && $this->isName($node->type, 'mixed')) { return \true; } // false positive - if (!$node instanceof \PhpParser\Node\Name) { + if (!$node instanceof Name) { return $this->vendorLockResolver->isPropertyTypeChangeVendorLockedIn($property); } if ($this->isName($node, 'mixed')) { @@ -190,7 +190,7 @@ CODE_SAMPLE } return $this->vendorLockResolver->isPropertyTypeChangeVendorLockedIn($property); } - private function removeDefaultValueForDoctrineCollection(\PhpParser\Node\Stmt\Property $property, \PHPStan\Type\Type $propertyType) : void + private function removeDefaultValueForDoctrineCollection(Property $property, Type $propertyType) : void { if (!$this->doctrineTypeAnalyzer->isDoctrineCollectionWithIterableUnionType($propertyType)) { return; @@ -198,12 +198,12 @@ CODE_SAMPLE $onlyProperty = $property->props[0]; $onlyProperty->default = null; } - private function addDefaultValueNullForNullableType(\PhpParser\Node\Stmt\Property $property, \PHPStan\Type\Type $propertyType) : void + private function addDefaultValueNullForNullableType(Property $property, Type $propertyType) : void { - if (!$propertyType instanceof \PHPStan\Type\UnionType) { + if (!$propertyType instanceof UnionType) { return; } - if (!$propertyType->isSuperTypeOf(new \PHPStan\Type\NullType())->yes()) { + if (!$propertyType->isSuperTypeOf(new NullType())->yes()) { return; } $onlyProperty = $property->props[0]; @@ -211,8 +211,8 @@ CODE_SAMPLE if ($onlyProperty->default !== null) { return; } - $classLike = $this->betterNodeFinder->findParentType($property, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($property, ClassLike::class); + if (!$classLike instanceof ClassLike) { return; } $propertyName = $this->nodeNameResolver->getName($property); diff --git a/rules/Php74/Rector/StaticCall/ExportToReflectionFunctionRector.php b/rules/Php74/Rector/StaticCall/ExportToReflectionFunctionRector.php index e0cce78b4fb..d70b87855a5 100644 --- a/rules/Php74/Rector/StaticCall/ExportToReflectionFunctionRector.php +++ b/rules/Php74/Rector/StaticCall/ExportToReflectionFunctionRector.php @@ -14,31 +14,31 @@ use Rector\Core\NodeAnalyzer\ArgsAnalyzer; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/deprecations_php_7_4 (not confirmed yet) * @changelog https://3v4l.org/RTCUq * @see \Rector\Tests\Php74\Rector\StaticCall\ExportToReflectionFunctionRector\ExportToReflectionFunctionRectorTest */ -final class ExportToReflectionFunctionRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ExportToReflectionFunctionRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(ArgsAnalyzer $argsAnalyzer) { $this->argsAnalyzer = $argsAnalyzer; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::EXPORT_TO_REFLECTION_FUNCTION; + return PhpVersionFeature::EXPORT_TO_REFLECTION_FUNCTION; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change export() to ReflectionFunction alternatives', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change export() to ReflectionFunction alternatives', [new CodeSample(<<<'CODE_SAMPLE' $reflectionFunction = ReflectionFunction::export('foo'); $reflectionFunctionAsString = ReflectionFunction::export('foo', true); CODE_SAMPLE @@ -53,18 +53,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class]; + return [StaticCall::class]; } /** * @param StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->class instanceof \PhpParser\Node\Name) { + if (!$node->class instanceof Name) { return null; } $callerType = $this->nodeTypeResolver->getType($node->class); - if (!$callerType->isSuperTypeOf(new \PHPStan\Type\ObjectType('ReflectionFunction'))->yes()) { + if (!$callerType->isSuperTypeOf(new ObjectType('ReflectionFunction'))->yes()) { return null; } if (!$this->isName($node->name, 'export')) { @@ -75,14 +75,14 @@ CODE_SAMPLE } /** @var Arg $firstArg */ $firstArg = $node->args[0]; - $new = new \PhpParser\Node\Expr\New_($node->class, [new \PhpParser\Node\Arg($firstArg->value)]); + $new = new New_($node->class, [new Arg($firstArg->value)]); if (!$this->argsAnalyzer->isArgInstanceInArgsPosition($node->args, 1)) { return $new; } /** @var Arg $secondArg */ $secondArg = $node->args[1]; if ($this->valueResolver->isTrue($secondArg->value)) { - return new \PhpParser\Node\Expr\Cast\String_($new); + return new String_($new); } return $new; } diff --git a/rules/Php74/Tokenizer/FollowedByCurlyBracketAnalyzer.php b/rules/Php74/Tokenizer/FollowedByCurlyBracketAnalyzer.php index 56c22ee1345..d3f9a200004 100644 --- a/rules/Php74/Tokenizer/FollowedByCurlyBracketAnalyzer.php +++ b/rules/Php74/Tokenizer/FollowedByCurlyBracketAnalyzer.php @@ -7,7 +7,7 @@ use PhpParser\Node; use Rector\Core\ValueObject\Application\File; final class FollowedByCurlyBracketAnalyzer { - public function isFollowed(\Rector\Core\ValueObject\Application\File $file, \PhpParser\Node $node) : bool + public function isFollowed(File $file, Node $node) : bool { $oldTokens = $file->getOldTokens(); $endTokenPost = $node->getEndTokenPos(); diff --git a/rules/Php74/TypeAnalyzer/ObjectTypeAnalyzer.php b/rules/Php74/TypeAnalyzer/ObjectTypeAnalyzer.php index df59859baae..c89d7d825a4 100644 --- a/rules/Php74/TypeAnalyzer/ObjectTypeAnalyzer.php +++ b/rules/Php74/TypeAnalyzer/ObjectTypeAnalyzer.php @@ -9,15 +9,15 @@ use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType; final class ObjectTypeAnalyzer { - public function isSpecial(\PHPStan\Type\Type $varType) : bool + public function isSpecial(Type $varType) : bool { // we are not sure what object type this is - if ($varType instanceof \Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType) { + if ($varType instanceof NonExistingObjectType) { return \true; } - $types = $varType instanceof \PHPStan\Type\UnionType ? $varType->getTypes() : [$varType]; + $types = $varType instanceof UnionType ? $varType->getTypes() : [$varType]; foreach ($types as $type) { - if (!$type instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) { + if (!$type instanceof FullyQualifiedObjectType) { continue; } if ($type->getClassName() !== 'Prophecy\\Prophecy\\ObjectProphecy') { diff --git a/rules/Php80/Contract/StrStartWithMatchAndRefactorInterface.php b/rules/Php80/Contract/StrStartWithMatchAndRefactorInterface.php index bd7343e8add..9c66ca23f81 100644 --- a/rules/Php80/Contract/StrStartWithMatchAndRefactorInterface.php +++ b/rules/Php80/Contract/StrStartWithMatchAndRefactorInterface.php @@ -14,9 +14,9 @@ interface StrStartWithMatchAndRefactorInterface /** * @param \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical $binaryOp */ - public function match($binaryOp) : ?\Rector\Php80\ValueObject\StrStartsWith; + public function match($binaryOp) : ?StrStartsWith; /** * @return FuncCall|BooleanNot|null */ - public function refactorStrStartsWith(\Rector\Php80\ValueObject\StrStartsWith $strStartsWith) : ?\PhpParser\Node; + public function refactorStrStartsWith(StrStartsWith $strStartsWith) : ?Node; } diff --git a/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/StrncmpMatchAndRefactor.php b/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/StrncmpMatchAndRefactor.php index 145f4df6624..07307a346d0 100644 --- a/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/StrncmpMatchAndRefactor.php +++ b/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/StrncmpMatchAndRefactor.php @@ -17,7 +17,7 @@ use Rector\Php80\Contract\StrStartWithMatchAndRefactorInterface; use Rector\Php80\NodeFactory\StrStartsWithFuncCallFactory; use Rector\Php80\ValueObject\StrStartsWith; use Rector\Php80\ValueObjectFactory\StrStartsWithFactory; -final class StrncmpMatchAndRefactor implements \Rector\Php80\Contract\StrStartWithMatchAndRefactorInterface +final class StrncmpMatchAndRefactor implements StrStartWithMatchAndRefactorInterface { /** * @var string @@ -48,7 +48,7 @@ final class StrncmpMatchAndRefactor implements \Rector\Php80\Contract\StrStartWi * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Php80\ValueObjectFactory\StrStartsWithFactory $strStartsWithFactory, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Php80\NodeFactory\StrStartsWithFuncCallFactory $strStartsWithFuncCallFactory, \Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(NodeNameResolver $nodeNameResolver, StrStartsWithFactory $strStartsWithFactory, NodeComparator $nodeComparator, StrStartsWithFuncCallFactory $strStartsWithFuncCallFactory, ArgsAnalyzer $argsAnalyzer) { $this->nodeNameResolver = $nodeNameResolver; $this->strStartsWithFactory = $strStartsWithFactory; @@ -59,13 +59,13 @@ final class StrncmpMatchAndRefactor implements \Rector\Php80\Contract\StrStartWi /** * @param \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical $binaryOp */ - public function match($binaryOp) : ?\Rector\Php80\ValueObject\StrStartsWith + public function match($binaryOp) : ?StrStartsWith { - $isPositive = $binaryOp instanceof \PhpParser\Node\Expr\BinaryOp\Identical; - if ($binaryOp->left instanceof \PhpParser\Node\Expr\FuncCall && $this->nodeNameResolver->isName($binaryOp->left, self::FUNCTION_NAME)) { + $isPositive = $binaryOp instanceof Identical; + if ($binaryOp->left instanceof FuncCall && $this->nodeNameResolver->isName($binaryOp->left, self::FUNCTION_NAME)) { return $this->strStartsWithFactory->createFromFuncCall($binaryOp->left, $isPositive); } - if (!$binaryOp->right instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$binaryOp->right instanceof FuncCall) { return null; } if (!$this->nodeNameResolver->isName($binaryOp->right, self::FUNCTION_NAME)) { @@ -73,7 +73,7 @@ final class StrncmpMatchAndRefactor implements \Rector\Php80\Contract\StrStartWi } return $this->strStartsWithFactory->createFromFuncCall($binaryOp->right, $isPositive); } - public function refactorStrStartsWith(\Rector\Php80\ValueObject\StrStartsWith $strStartsWith) : ?\PhpParser\Node + public function refactorStrStartsWith(StrStartsWith $strStartsWith) : ?Node { if ($this->isNeedleExprWithStrlen($strStartsWith)) { return $this->strStartsWithFuncCallFactory->createStrStartsWith($strStartsWith); @@ -83,7 +83,7 @@ final class StrncmpMatchAndRefactor implements \Rector\Php80\Contract\StrStartWi } return null; } - private function isNeedleExprWithStrlen(\Rector\Php80\ValueObject\StrStartsWith $strStartsWith) : bool + private function isNeedleExprWithStrlen(StrStartsWith $strStartsWith) : bool { $strncmpFuncCall = $strStartsWith->getFuncCall(); $needleExpr = $strStartsWith->getNeedleExpr(); @@ -93,7 +93,7 @@ final class StrncmpMatchAndRefactor implements \Rector\Php80\Contract\StrStartWi /** @var Arg $thirdArg */ $thirdArg = $strncmpFuncCall->args[2]; $secondArgumentValue = $thirdArg->value; - if (!$secondArgumentValue instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$secondArgumentValue instanceof FuncCall) { return \false; } if (!$this->nodeNameResolver->isName($secondArgumentValue, 'strlen')) { @@ -109,7 +109,7 @@ final class StrncmpMatchAndRefactor implements \Rector\Php80\Contract\StrStartWi $strlenArgumentValue = $firstArg->value; return $this->nodeComparator->areNodesEqual($needleExpr, $strlenArgumentValue); } - private function isHardcodedStringWithLNumberLength(\Rector\Php80\ValueObject\StrStartsWith $strStartsWith) : bool + private function isHardcodedStringWithLNumberLength(StrStartsWith $strStartsWith) : bool { $strncmpFuncCall = $strStartsWith->getFuncCall(); if (!$this->argsAnalyzer->isArgsInstanceInArgsPositions($strncmpFuncCall->args, [1, 2])) { @@ -118,13 +118,13 @@ final class StrncmpMatchAndRefactor implements \Rector\Php80\Contract\StrStartWi /** @var Arg $secondArg */ $secondArg = $strncmpFuncCall->args[1]; $hardcodedStringNeedle = $secondArg->value; - if (!$hardcodedStringNeedle instanceof \PhpParser\Node\Scalar\String_) { + if (!$hardcodedStringNeedle instanceof String_) { return \false; } /** @var Arg $thirdArg */ $thirdArg = $strncmpFuncCall->args[2]; $lNumberLength = $thirdArg->value; - if (!$lNumberLength instanceof \PhpParser\Node\Scalar\LNumber) { + if (!$lNumberLength instanceof LNumber) { return \false; } return $lNumberLength->value === \strlen($hardcodedStringNeedle->value); diff --git a/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/StrposMatchAndRefactor.php b/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/StrposMatchAndRefactor.php index d07d353bb3b..974878bf846 100644 --- a/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/StrposMatchAndRefactor.php +++ b/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/StrposMatchAndRefactor.php @@ -17,7 +17,7 @@ use Rector\NodeNameResolver\NodeNameResolver; use Rector\Php80\Contract\StrStartWithMatchAndRefactorInterface; use Rector\Php80\NodeFactory\StrStartsWithFuncCallFactory; use Rector\Php80\ValueObject\StrStartsWith; -final class StrposMatchAndRefactor implements \Rector\Php80\Contract\StrStartWithMatchAndRefactorInterface +final class StrposMatchAndRefactor implements StrStartWithMatchAndRefactorInterface { /** * @readonly @@ -39,7 +39,7 @@ final class StrposMatchAndRefactor implements \Rector\Php80\Contract\StrStartWit * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\Php80\NodeFactory\StrStartsWithFuncCallFactory $strStartsWithFuncCallFactory, \Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(NodeNameResolver $nodeNameResolver, ValueResolver $valueResolver, StrStartsWithFuncCallFactory $strStartsWithFuncCallFactory, ArgsAnalyzer $argsAnalyzer) { $this->nodeNameResolver = $nodeNameResolver; $this->valueResolver = $valueResolver; @@ -49,13 +49,13 @@ final class StrposMatchAndRefactor implements \Rector\Php80\Contract\StrStartWit /** * @param \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical $binaryOp */ - public function match($binaryOp) : ?\Rector\Php80\ValueObject\StrStartsWith + public function match($binaryOp) : ?StrStartsWith { - $isPositive = $binaryOp instanceof \PhpParser\Node\Expr\BinaryOp\Identical; - if ($binaryOp->left instanceof \PhpParser\Node\Expr\FuncCall && $this->nodeNameResolver->isName($binaryOp->left, 'strpos')) { + $isPositive = $binaryOp instanceof Identical; + if ($binaryOp->left instanceof FuncCall && $this->nodeNameResolver->isName($binaryOp->left, 'strpos')) { return $this->processBinaryOpLeft($binaryOp, $isPositive); } - if (!$binaryOp->right instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$binaryOp->right instanceof FuncCall) { return null; } if (!$this->nodeNameResolver->isName($binaryOp->right, 'strpos')) { @@ -66,13 +66,13 @@ final class StrposMatchAndRefactor implements \Rector\Php80\Contract\StrStartWit /** * @return FuncCall|BooleanNot */ - public function refactorStrStartsWith(\Rector\Php80\ValueObject\StrStartsWith $strStartsWith) : \PhpParser\Node + public function refactorStrStartsWith(StrStartsWith $strStartsWith) : Node { $strposFuncCall = $strStartsWith->getFuncCall(); - $strposFuncCall->name = new \PhpParser\Node\Name('str_starts_with'); + $strposFuncCall->name = new Name('str_starts_with'); return $this->strStartsWithFuncCallFactory->createStrStartsWith($strStartsWith); } - private function processBinaryOpLeft(\PhpParser\Node\Expr\BinaryOp $binaryOp, bool $isPositive) : ?\Rector\Php80\ValueObject\StrStartsWith + private function processBinaryOpLeft(BinaryOp $binaryOp, bool $isPositive) : ?StrStartsWith { if (!$this->valueResolver->isValue($binaryOp->right, 0)) { return null; @@ -88,9 +88,9 @@ final class StrposMatchAndRefactor implements \Rector\Php80\Contract\StrStartWit /** @var Arg $secondArg */ $secondArg = $funcCall->args[1]; $needle = $secondArg->value; - return new \Rector\Php80\ValueObject\StrStartsWith($funcCall, $haystack, $needle, $isPositive); + return new StrStartsWith($funcCall, $haystack, $needle, $isPositive); } - private function processBinaryOpRight(\PhpParser\Node\Expr\BinaryOp $binaryOp, bool $isPositive) : ?\Rector\Php80\ValueObject\StrStartsWith + private function processBinaryOpRight(BinaryOp $binaryOp, bool $isPositive) : ?StrStartsWith { if (!$this->valueResolver->isValue($binaryOp->left, 0)) { return null; @@ -106,6 +106,6 @@ final class StrposMatchAndRefactor implements \Rector\Php80\Contract\StrStartWit /** @var Arg $secondArg */ $secondArg = $funcCall->args[1]; $needle = $secondArg->value; - return new \Rector\Php80\ValueObject\StrStartsWith($funcCall, $haystack, $needle, $isPositive); + return new StrStartsWith($funcCall, $haystack, $needle, $isPositive); } } diff --git a/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/SubstrMatchAndRefactor.php b/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/SubstrMatchAndRefactor.php index ffda5c985cd..f522d2cffca 100644 --- a/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/SubstrMatchAndRefactor.php +++ b/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/SubstrMatchAndRefactor.php @@ -17,7 +17,7 @@ use Rector\NodeNameResolver\NodeNameResolver; use Rector\Php80\Contract\StrStartWithMatchAndRefactorInterface; use Rector\Php80\NodeFactory\StrStartsWithFuncCallFactory; use Rector\Php80\ValueObject\StrStartsWith; -final class SubstrMatchAndRefactor implements \Rector\Php80\Contract\StrStartWithMatchAndRefactorInterface +final class SubstrMatchAndRefactor implements StrStartWithMatchAndRefactorInterface { /** * @readonly @@ -44,7 +44,7 @@ final class SubstrMatchAndRefactor implements \Rector\Php80\Contract\StrStartWit * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Php80\NodeFactory\StrStartsWithFuncCallFactory $strStartsWithFuncCallFactory, \Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(NodeNameResolver $nodeNameResolver, ValueResolver $valueResolver, NodeComparator $nodeComparator, StrStartsWithFuncCallFactory $strStartsWithFuncCallFactory, ArgsAnalyzer $argsAnalyzer) { $this->nodeNameResolver = $nodeNameResolver; $this->valueResolver = $valueResolver; @@ -55,10 +55,10 @@ final class SubstrMatchAndRefactor implements \Rector\Php80\Contract\StrStartWit /** * @param \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical $binaryOp */ - public function match($binaryOp) : ?\Rector\Php80\ValueObject\StrStartsWith + public function match($binaryOp) : ?StrStartsWith { - $isPositive = $binaryOp instanceof \PhpParser\Node\Expr\BinaryOp\Identical; - if ($binaryOp->left instanceof \PhpParser\Node\Expr\FuncCall && $this->nodeNameResolver->isName($binaryOp->left, 'substr')) { + $isPositive = $binaryOp instanceof Identical; + if ($binaryOp->left instanceof FuncCall && $this->nodeNameResolver->isName($binaryOp->left, 'substr')) { /** @var FuncCall $funcCall */ $funcCall = $binaryOp->left; if (!$this->argsAnalyzer->isArgInstanceInArgsPosition($funcCall->args, 0)) { @@ -67,9 +67,9 @@ final class SubstrMatchAndRefactor implements \Rector\Php80\Contract\StrStartWit /** @var Arg $arg */ $arg = $funcCall->args[0]; $haystack = $arg->value; - return new \Rector\Php80\ValueObject\StrStartsWith($funcCall, $haystack, $binaryOp->right, $isPositive); + return new StrStartsWith($funcCall, $haystack, $binaryOp->right, $isPositive); } - if ($binaryOp->right instanceof \PhpParser\Node\Expr\FuncCall && $this->nodeNameResolver->isName($binaryOp->right, 'substr')) { + if ($binaryOp->right instanceof FuncCall && $this->nodeNameResolver->isName($binaryOp->right, 'substr')) { /** @var FuncCall $funcCall */ $funcCall = $binaryOp->right; if (!$this->argsAnalyzer->isArgInstanceInArgsPosition($funcCall->args, 0)) { @@ -78,11 +78,11 @@ final class SubstrMatchAndRefactor implements \Rector\Php80\Contract\StrStartWit /** @var Arg $arg */ $arg = $funcCall->args[0]; $haystack = $arg->value; - return new \Rector\Php80\ValueObject\StrStartsWith($funcCall, $haystack, $binaryOp->left, $isPositive); + return new StrStartsWith($funcCall, $haystack, $binaryOp->left, $isPositive); } return null; } - public function refactorStrStartsWith(\Rector\Php80\ValueObject\StrStartsWith $strStartsWith) : ?\PhpParser\Node + public function refactorStrStartsWith(StrStartsWith $strStartsWith) : ?Node { if ($this->isStrlenWithNeedleExpr($strStartsWith)) { return $this->strStartsWithFuncCallFactory->createStrStartsWith($strStartsWith); @@ -92,7 +92,7 @@ final class SubstrMatchAndRefactor implements \Rector\Php80\Contract\StrStartWit } return null; } - private function isStrlenWithNeedleExpr(\Rector\Php80\ValueObject\StrStartsWith $strStartsWith) : bool + private function isStrlenWithNeedleExpr(StrStartsWith $strStartsWith) : bool { $substrFuncCall = $strStartsWith->getFuncCall(); if (!$this->argsAnalyzer->isArgInstanceInArgsPosition($substrFuncCall->args, 1)) { @@ -109,7 +109,7 @@ final class SubstrMatchAndRefactor implements \Rector\Php80\Contract\StrStartWit /** @var Arg $arg2 */ $arg2 = $substrFuncCall->args[2]; $secondFuncCallArgValue = $arg2->value; - if (!$secondFuncCallArgValue instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$secondFuncCallArgValue instanceof FuncCall) { return \false; } if (!$this->nodeNameResolver->isName($secondFuncCallArgValue, 'strlen')) { @@ -126,7 +126,7 @@ final class SubstrMatchAndRefactor implements \Rector\Php80\Contract\StrStartWit $comparedNeedleExpr = $strStartsWith->getNeedleExpr(); return $this->nodeComparator->areNodesEqual($needleExpr, $comparedNeedleExpr); } - private function isHardcodedStringWithLNumberLength(\Rector\Php80\ValueObject\StrStartsWith $strStartsWith) : bool + private function isHardcodedStringWithLNumberLength(StrStartsWith $strStartsWith) : bool { $substrFuncCall = $strStartsWith->getFuncCall(); if (!$this->argsAnalyzer->isArgInstanceInArgsPosition($substrFuncCall->args, 1)) { @@ -138,7 +138,7 @@ final class SubstrMatchAndRefactor implements \Rector\Php80\Contract\StrStartWit return \false; } $hardcodedStringNeedle = $strStartsWith->getNeedleExpr(); - if (!$hardcodedStringNeedle instanceof \PhpParser\Node\Scalar\String_) { + if (!$hardcodedStringNeedle instanceof String_) { return \false; } if (!$this->argsAnalyzer->isArgInstanceInArgsPosition($substrFuncCall->args, 2)) { @@ -147,7 +147,7 @@ final class SubstrMatchAndRefactor implements \Rector\Php80\Contract\StrStartWit /** @var Arg $arg2 */ $arg2 = $substrFuncCall->args[2]; $lNumberLength = $arg2->value; - if (!$lNumberLength instanceof \PhpParser\Node\Scalar\LNumber) { + if (!$lNumberLength instanceof LNumber) { return \false; } return $lNumberLength->value === \strlen($hardcodedStringNeedle->value); diff --git a/rules/Php80/NodeAnalyzer/AnnotationTargetResolver.php b/rules/Php80/NodeAnalyzer/AnnotationTargetResolver.php index 7776e2fda92..d1322cc6430 100644 --- a/rules/Php80/NodeAnalyzer/AnnotationTargetResolver.php +++ b/rules/Php80/NodeAnalyzer/AnnotationTargetResolver.php @@ -25,7 +25,7 @@ final class AnnotationTargetResolver * @var \Rector\Core\PhpParser\Node\NodeFactory */ private $nodeFactory; - public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory) + public function __construct(NodeFactory $nodeFactory) { $this->nodeFactory = $nodeFactory; } diff --git a/rules/Php80/NodeAnalyzer/EnumParamAnalyzer.php b/rules/Php80/NodeAnalyzer/EnumParamAnalyzer.php index f961ae7d8f0..fc0984576f0 100644 --- a/rules/Php80/NodeAnalyzer/EnumParamAnalyzer.php +++ b/rules/Php80/NodeAnalyzer/EnumParamAnalyzer.php @@ -25,14 +25,14 @@ final class EnumParamAnalyzer * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ReflectionProvider $reflectionProvider) { $this->reflectionProvider = $reflectionProvider; } - public function matchParameterClassName(\PHPStan\Reflection\ParameterReflection $parameterReflection, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : ?\Rector\Php80\ValueObject\ClassNameAndTagValueNode + public function matchParameterClassName(ParameterReflection $parameterReflection, PhpDocInfo $phpDocInfo) : ?ClassNameAndTagValueNode { $paramTagValueNode = $phpDocInfo->getParamTagValueByName($parameterReflection->getName()); - if (!$paramTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode) { + if (!$paramTagValueNode instanceof ParamTagValueNode) { return null; } $className = $this->resolveClassFromConstType($paramTagValueNode->type); @@ -42,41 +42,41 @@ final class EnumParamAnalyzer if (!$this->reflectionProvider->hasClass($className)) { return null; } - return new \Rector\Php80\ValueObject\ClassNameAndTagValueNode($className, $paramTagValueNode); + return new ClassNameAndTagValueNode($className, $paramTagValueNode); } - public function matchReturnClassName(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : ?\Rector\Php80\ValueObject\ClassNameAndTagValueNode + public function matchReturnClassName(PhpDocInfo $phpDocInfo) : ?ClassNameAndTagValueNode { $returnTagValueNode = $phpDocInfo->getReturnTagValue(); - if (!$returnTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode) { + if (!$returnTagValueNode instanceof ReturnTagValueNode) { return null; } $className = $this->resolveClassFromConstType($returnTagValueNode->type); if (!\is_string($className)) { return null; } - return new \Rector\Php80\ValueObject\ClassNameAndTagValueNode($className, $returnTagValueNode); + return new ClassNameAndTagValueNode($className, $returnTagValueNode); } - public function matchPropertyClassName(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : ?\Rector\Php80\ValueObject\ClassNameAndTagValueNode + public function matchPropertyClassName(PhpDocInfo $phpDocInfo) : ?ClassNameAndTagValueNode { $varTagValueNode = $phpDocInfo->getVarTagValueNode(); - if (!$varTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) { + if (!$varTagValueNode instanceof VarTagValueNode) { return null; } $className = $this->resolveClassFromConstType($varTagValueNode->type); if (!\is_string($className)) { return null; } - return new \Rector\Php80\ValueObject\ClassNameAndTagValueNode($className, $varTagValueNode); + return new ClassNameAndTagValueNode($className, $varTagValueNode); } - private function resolveClassFromConstType(\PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode) : ?string + private function resolveClassFromConstType(TypeNode $typeNode) : ?string { - if (!$typeNode instanceof \PHPStan\PhpDocParser\Ast\Type\ConstTypeNode) { + if (!$typeNode instanceof ConstTypeNode) { return null; } - if (!$typeNode->constExpr instanceof \PHPStan\PhpDocParser\Ast\ConstExpr\ConstFetchNode) { + if (!$typeNode->constExpr instanceof ConstFetchNode) { return null; } $constExpr = $typeNode->constExpr; - return $constExpr->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::RESOLVED_CLASS); + return $constExpr->getAttribute(PhpDocAttributeKey::RESOLVED_CLASS); } } diff --git a/rules/Php80/NodeAnalyzer/MatchSwitchAnalyzer.php b/rules/Php80/NodeAnalyzer/MatchSwitchAnalyzer.php index 76e089776af..0814024b382 100644 --- a/rules/Php80/NodeAnalyzer/MatchSwitchAnalyzer.php +++ b/rules/Php80/NodeAnalyzer/MatchSwitchAnalyzer.php @@ -34,7 +34,7 @@ final class MatchSwitchAnalyzer * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\Php80\NodeAnalyzer\SwitchAnalyzer $switchAnalyzer, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(\Rector\Php80\NodeAnalyzer\SwitchAnalyzer $switchAnalyzer, NodeNameResolver $nodeNameResolver, NodeComparator $nodeComparator) { $this->switchAnalyzer = $switchAnalyzer; $this->nodeNameResolver = $nodeNameResolver; @@ -43,7 +43,7 @@ final class MatchSwitchAnalyzer /** * @param CondAndExpr[] $condAndExprs */ - public function shouldSkipSwitch(\PhpParser\Node\Stmt\Switch_ $switch, array $condAndExprs) : bool + public function shouldSkipSwitch(Switch_ $switch, array $condAndExprs) : bool { if ($condAndExprs === []) { return \true; @@ -78,10 +78,10 @@ final class MatchSwitchAnalyzer $assignVariableNames = []; foreach ($condAndExprs as $condAndExpr) { $expr = $condAndExpr->getExpr(); - if (!$expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$expr instanceof Assign) { continue; } - if ($expr->var instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if ($expr->var instanceof ArrayDimFetch) { $arrayDimFethName = $this->nodeNameResolver->getName($expr->var->var); $assignVariableNames[] = \get_class($expr->var) . $arrayDimFethName . '[]'; } else { @@ -91,7 +91,7 @@ final class MatchSwitchAnalyzer $assignVariableNames = \array_unique($assignVariableNames); return \count($assignVariableNames) <= 1; } - public function hasDefaultValue(\PhpParser\Node\Expr\Match_ $match) : bool + public function hasDefaultValue(Match_ $match) : bool { foreach ($match->arms as $matchArm) { if ($matchArm->conds === null) { @@ -111,29 +111,29 @@ final class MatchSwitchAnalyzer { $condAndExprKinds = []; foreach ($condAndExprs as $condAndExpr) { - if ($condAndExpr->equalsMatchKind(\Rector\Php80\Enum\MatchKind::THROW)) { + if ($condAndExpr->equalsMatchKind(MatchKind::THROW)) { continue; } $condAndExprKinds[] = $condAndExpr->getMatchKind(); } return \array_unique($condAndExprKinds); } - private function isNextStmtReturnWithExpr(\PhpParser\Node\Stmt\Switch_ $switch) : bool + private function isNextStmtReturnWithExpr(Switch_ $switch) : bool { - $next = $switch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if (!$next instanceof \PhpParser\Node\Stmt\Return_) { + $next = $switch->getAttribute(AttributeKey::NEXT_NODE); + if (!$next instanceof Return_) { return \false; } - if (!$next->expr instanceof \PhpParser\Node\Expr) { + if (!$next->expr instanceof Expr) { return \false; } foreach ($switch->cases as $case) { /** @var Expression[] $expressions */ - $expressions = \array_filter($case->stmts, function (\PhpParser\Node $node) : bool { - return $node instanceof \PhpParser\Node\Stmt\Expression; + $expressions = \array_filter($case->stmts, function (Node $node) : bool { + return $node instanceof Expression; }); foreach ($expressions as $expression) { - if (!$expression->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$expression->expr instanceof Assign) { continue; } if (!$this->nodeComparator->areNodesEqual($expression->expr->var, $next->expr)) { @@ -143,9 +143,9 @@ final class MatchSwitchAnalyzer } return \true; } - private function isNextStmtThrows(\PhpParser\Node\Stmt\Switch_ $switch) : bool + private function isNextStmtThrows(Switch_ $switch) : bool { - $next = $switch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - return $next instanceof \PhpParser\Node\Stmt\Throw_; + $next = $switch->getAttribute(AttributeKey::NEXT_NODE); + return $next instanceof Throw_; } } diff --git a/rules/Php80/NodeAnalyzer/PhpAttributeAnalyzer.php b/rules/Php80/NodeAnalyzer/PhpAttributeAnalyzer.php index 5433881f259..d45d6a30af2 100644 --- a/rules/Php80/NodeAnalyzer/PhpAttributeAnalyzer.php +++ b/rules/Php80/NodeAnalyzer/PhpAttributeAnalyzer.php @@ -28,7 +28,7 @@ final class PhpAttributeAnalyzer * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\Core\PhpParser\AstResolver $astResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(AstResolver $astResolver, NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider) { $this->astResolver = $astResolver; $this->nodeNameResolver = $nodeNameResolver; @@ -49,7 +49,7 @@ final class PhpAttributeAnalyzer } return \false; } - public function hasInheritedPhpAttribute(\PhpParser\Node\Stmt\ClassLike $classLike, string $attributeClass) : bool + public function hasInheritedPhpAttribute(ClassLike $classLike, string $attributeClass) : bool { $className = (string) $this->nodeNameResolver->getName($classLike); if (!$this->reflectionProvider->hasClass($className)) { @@ -60,7 +60,7 @@ final class PhpAttributeAnalyzer foreach ($ancestorClassReflections as $ancestorClassReflection) { $ancestorClassName = $ancestorClassReflection->getName(); $class = $this->astResolver->resolveClassFromName($ancestorClassName); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + if (!$class instanceof Class_) { continue; } if ($this->hasPhpAttribute($class, $attributeClass)) { diff --git a/rules/Php80/NodeAnalyzer/PromotedPropertyCandidateResolver.php b/rules/Php80/NodeAnalyzer/PromotedPropertyCandidateResolver.php index 9eac23261d0..714f33bbb11 100644 --- a/rules/Php80/NodeAnalyzer/PromotedPropertyCandidateResolver.php +++ b/rules/Php80/NodeAnalyzer/PromotedPropertyCandidateResolver.php @@ -68,7 +68,7 @@ final class PromotedPropertyCandidateResolver * @var \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer */ private $propertyFetchAnalyzer; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\TypeDeclaration\TypeInferer\VarDocPropertyTypeInferer $varDocPropertyTypeInferer, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeTypeResolver\TypeComparator\TypeComparator $typeComparator, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer) + public function __construct(NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder, NodeComparator $nodeComparator, VarDocPropertyTypeInferer $varDocPropertyTypeInferer, NodeTypeResolver $nodeTypeResolver, TypeComparator $typeComparator, TypeFactory $typeFactory, PropertyFetchAnalyzer $propertyFetchAnalyzer) { $this->nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; @@ -82,10 +82,10 @@ final class PromotedPropertyCandidateResolver /** * @return PropertyPromotionCandidate[] */ - public function resolveFromClass(\PhpParser\Node\Stmt\Class_ $class) : array + public function resolveFromClass(Class_ $class) : array { - $constructClassMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$constructClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $constructClassMethod = $class->getMethod(MethodName::CONSTRUCT); + if (!$constructClassMethod instanceof ClassMethod) { return []; } $propertyPromotionCandidates = []; @@ -95,29 +95,29 @@ final class PromotedPropertyCandidateResolver continue; } $propertyPromotionCandidate = $this->matchPropertyPromotionCandidate($property, $constructClassMethod); - if (!$propertyPromotionCandidate instanceof \Rector\Php80\ValueObject\PropertyPromotionCandidate) { + if (!$propertyPromotionCandidate instanceof PropertyPromotionCandidate) { continue; } $propertyPromotionCandidates[] = $propertyPromotionCandidate; } return $propertyPromotionCandidates; } - private function matchPropertyPromotionCandidate(\PhpParser\Node\Stmt\Property $property, \PhpParser\Node\Stmt\ClassMethod $constructClassMethod) : ?\Rector\Php80\ValueObject\PropertyPromotionCandidate + private function matchPropertyPromotionCandidate(Property $property, ClassMethod $constructClassMethod) : ?PropertyPromotionCandidate { $onlyProperty = $property->props[0]; $propertyName = $this->nodeNameResolver->getName($onlyProperty); $firstParamAsVariable = $this->resolveFirstParamUses($constructClassMethod); // match property name to assign in constructor foreach ((array) $constructClassMethod->stmts as $stmt) { - if ($stmt instanceof \PhpParser\Node\Stmt\Expression) { + if ($stmt instanceof Expression) { $stmt = $stmt->expr; } - if (!$stmt instanceof \PhpParser\Node\Expr\Assign) { + if (!$stmt instanceof Assign) { continue; } $assign = $stmt; // promoted property must use non-static property only - if (!$assign->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$assign->var instanceof PropertyFetch) { continue; } if (!$this->propertyFetchAnalyzer->isLocalPropertyFetchName($assign->var, $propertyName)) { @@ -125,42 +125,42 @@ final class PromotedPropertyCandidateResolver } // 1. is param $assignedExpr = $assign->expr; - if (!$assignedExpr instanceof \PhpParser\Node\Expr\Variable) { + if (!$assignedExpr instanceof Variable) { continue; } $matchedParam = $this->matchClassMethodParamByAssignedVariable($constructClassMethod, $assignedExpr); - if (!$matchedParam instanceof \PhpParser\Node\Param) { + if (!$matchedParam instanceof Param) { continue; } if ($this->shouldSkipParam($matchedParam, $property, $assignedExpr, $firstParamAsVariable)) { continue; } - return new \Rector\Php80\ValueObject\PropertyPromotionCandidate($property, $assign, $matchedParam); + return new PropertyPromotionCandidate($property, $assign, $matchedParam); } return null; } /** * @return array */ - private function resolveFirstParamUses(\PhpParser\Node\Stmt\ClassMethod $classMethod) : array + private function resolveFirstParamUses(ClassMethod $classMethod) : array { $paramByFirstUsage = []; foreach ($classMethod->params as $param) { $paramName = $this->nodeNameResolver->getName($param); - $firstParamVariable = $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (\PhpParser\Node $node) use($paramName) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + $firstParamVariable = $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (Node $node) use($paramName) : bool { + if (!$node instanceof Variable) { return \false; } return $this->nodeNameResolver->isName($node, $paramName); }); - if (!$firstParamVariable instanceof \PhpParser\Node) { + if (!$firstParamVariable instanceof Node) { continue; } $paramByFirstUsage[$paramName] = $firstParamVariable->getStartTokenPos(); } return $paramByFirstUsage; } - private function matchClassMethodParamByAssignedVariable(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Expr\Variable $variable) : ?\PhpParser\Node\Param + private function matchClassMethodParamByAssignedVariable(ClassMethod $classMethod, Variable $variable) : ?Param { foreach ($classMethod->params as $param) { if (!$this->nodeComparator->areNodesEqual($variable, $param->var)) { @@ -173,7 +173,7 @@ final class PromotedPropertyCandidateResolver /** * @param array $firstParamAsVariable */ - private function isParamUsedBeforeAssign(\PhpParser\Node\Expr\Variable $variable, array $firstParamAsVariable) : bool + private function isParamUsedBeforeAssign(Variable $variable, array $firstParamAsVariable) : bool { $variableName = $this->nodeNameResolver->getName($variable); $firstVariablePosition = $firstParamAsVariable[$variableName] ?? null; @@ -182,7 +182,7 @@ final class PromotedPropertyCandidateResolver } return $firstVariablePosition < $variable->getStartTokenPos(); } - private function hasConflictingParamType(\PhpParser\Node\Param $param, \PHPStan\Type\Type $propertyType) : bool + private function hasConflictingParamType(Param $param, Type $propertyType) : bool { if ($param->type === null) { return \false; @@ -192,7 +192,7 @@ final class PromotedPropertyCandidateResolver $defaultValueType = $this->nodeTypeResolver->getType($param->default); $matchedParamType = $this->typeFactory->createMixedPassedOrUnionType([$matchedParamType, $defaultValueType]); } - if (!$propertyType instanceof \PHPStan\Type\UnionType) { + if (!$propertyType instanceof UnionType) { return \false; } if ($this->typeComparator->areTypesEqual($propertyType, $matchedParamType)) { @@ -204,19 +204,19 @@ final class PromotedPropertyCandidateResolver } return !$this->hasTemplatedGenericType($propertyType); } - private function hasTemplatedGenericType(\PHPStan\Type\UnionType $unionType) : bool + private function hasTemplatedGenericType(UnionType $unionType) : bool { foreach ($unionType->getTypes() as $type) { - if ($type instanceof \PHPStan\Type\Generic\TemplateType) { + if ($type instanceof TemplateType) { return \true; } } return \false; } - private function hasMixedType(\PHPStan\Type\UnionType $unionType) : bool + private function hasMixedType(UnionType $unionType) : bool { foreach ($unionType->getTypes() as $type) { - if ($type instanceof \PHPStan\Type\MixedType) { + if ($type instanceof MixedType) { return \true; } } @@ -225,7 +225,7 @@ final class PromotedPropertyCandidateResolver /** * @param int[] $firstParamAsVariable */ - private function shouldSkipParam(\PhpParser\Node\Param $matchedParam, \PhpParser\Node\Stmt\Property $property, \PhpParser\Node\Expr\Variable $assignedVariable, array $firstParamAsVariable) : bool + private function shouldSkipParam(Param $matchedParam, Property $property, Variable $assignedVariable, array $firstParamAsVariable) : bool { // already promoted if ($matchedParam->flags !== 0) { diff --git a/rules/Php80/NodeAnalyzer/PromotedPropertyResolver.php b/rules/Php80/NodeAnalyzer/PromotedPropertyResolver.php index e866c060d1d..f15215c646b 100644 --- a/rules/Php80/NodeAnalyzer/PromotedPropertyResolver.php +++ b/rules/Php80/NodeAnalyzer/PromotedPropertyResolver.php @@ -12,10 +12,10 @@ final class PromotedPropertyResolver /** * @return Param[] */ - public function resolveFromClass(\PhpParser\Node\Stmt\Class_ $class) : array + public function resolveFromClass(Class_ $class) : array { - $constructClassMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$constructClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $constructClassMethod = $class->getMethod(MethodName::CONSTRUCT); + if (!$constructClassMethod instanceof ClassMethod) { return []; } $promotedPropertyParams = []; diff --git a/rules/Php80/NodeAnalyzer/SwitchAnalyzer.php b/rules/Php80/NodeAnalyzer/SwitchAnalyzer.php index 070bcf630a9..d6319f72f02 100644 --- a/rules/Php80/NodeAnalyzer/SwitchAnalyzer.php +++ b/rules/Php80/NodeAnalyzer/SwitchAnalyzer.php @@ -23,7 +23,7 @@ final class SwitchAnalyzer * @var \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory */ private $typeFactory; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory) + public function __construct(NodeTypeResolver $nodeTypeResolver, TypeFactory $typeFactory) { $this->nodeTypeResolver = $nodeTypeResolver; $this->typeFactory = $typeFactory; @@ -35,7 +35,7 @@ final class SwitchAnalyzer { $types = []; foreach ($cases as $case) { - if ($case->cond instanceof \PhpParser\Node\Expr) { + if ($case->cond instanceof Expr) { $types[] = $this->nodeTypeResolver->getType($case->cond); } } @@ -45,7 +45,7 @@ final class SwitchAnalyzer $uniqueTypes = $this->typeFactory->uniquateTypes($types); return \count($uniqueTypes) > 1; } - public function hasEachCaseBreak(\PhpParser\Node\Stmt\Switch_ $switch) : bool + public function hasEachCaseBreak(Switch_ $switch) : bool { $totalCases = \count($switch->cases); if ($totalCases === 1) { @@ -62,14 +62,14 @@ final class SwitchAnalyzer } return \true; } - public function hasEachCaseSingleStmt(\PhpParser\Node\Stmt\Switch_ $switch) : bool + public function hasEachCaseSingleStmt(Switch_ $switch) : bool { foreach ($switch->cases as $case) { if ($case->cond === null) { continue; } - $stmtsWithoutBreak = \array_filter($case->stmts, function (\PhpParser\Node $node) : bool { - return !$node instanceof \PhpParser\Node\Stmt\Break_; + $stmtsWithoutBreak = \array_filter($case->stmts, function (Node $node) : bool { + return !$node instanceof Break_; }); if (\count($stmtsWithoutBreak) !== 1) { return \false; @@ -77,37 +77,37 @@ final class SwitchAnalyzer } return \true; } - public function hasDefaultSingleStmt(\PhpParser\Node\Stmt\Switch_ $switch) : bool + public function hasDefaultSingleStmt(Switch_ $switch) : bool { foreach ($switch->cases as $case) { if ($case->cond === null) { - $stmtsWithoutBreak = \array_filter($case->stmts, function (\PhpParser\Node $node) : bool { - return !$node instanceof \PhpParser\Node\Stmt\Break_; + $stmtsWithoutBreak = \array_filter($case->stmts, function (Node $node) : bool { + return !$node instanceof Break_; }); return \count($stmtsWithoutBreak) === 1; } } return \false; } - private function hasBreakOrReturnOrEmpty(\PhpParser\Node\Stmt\Case_ $case) : bool + private function hasBreakOrReturnOrEmpty(Case_ $case) : bool { if ($case->stmts === []) { return \true; } foreach ($case->stmts as $caseStmt) { - if ($caseStmt instanceof \PhpParser\Node\Stmt\Break_) { + if ($caseStmt instanceof Break_) { return \true; } - if ($caseStmt instanceof \PhpParser\Node\Stmt\Return_) { + if ($caseStmt instanceof Return_) { return \true; } } return \false; } - private function containsCaseReturn(\PhpParser\Node\Stmt\Case_ $case) : bool + private function containsCaseReturn(Case_ $case) : bool { foreach ($case->stmts as $stmt) { - if ($stmt instanceof \PhpParser\Node\Stmt\Return_) { + if ($stmt instanceof Return_) { return \true; } } diff --git a/rules/Php80/NodeFactory/AttrGroupsFactory.php b/rules/Php80/NodeFactory/AttrGroupsFactory.php index 7bc187c7a6c..5825b6aa92f 100644 --- a/rules/Php80/NodeFactory/AttrGroupsFactory.php +++ b/rules/Php80/NodeFactory/AttrGroupsFactory.php @@ -14,7 +14,7 @@ final class AttrGroupsFactory * @var \Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory */ private $phpAttributeGroupFactory; - public function __construct(\Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory $phpAttributeGroupFactory) + public function __construct(PhpAttributeGroupFactory $phpAttributeGroupFactory) { $this->phpAttributeGroupFactory = $phpAttributeGroupFactory; } diff --git a/rules/Php80/NodeFactory/AttributeFlagFactory.php b/rules/Php80/NodeFactory/AttributeFlagFactory.php index 5f3a7eadbc2..e67fcb0c395 100644 --- a/rules/Php80/NodeFactory/AttributeFlagFactory.php +++ b/rules/Php80/NodeFactory/AttributeFlagFactory.php @@ -12,14 +12,14 @@ final class AttributeFlagFactory * @param ClassConstFetch[] $classConstFetches * @return ClassConstFetch|BitwiseOr|null */ - public function createFlagCollection(array $classConstFetches) : ?\PhpParser\Node\Expr + public function createFlagCollection(array $classConstFetches) : ?Expr { if ($classConstFetches === []) { return null; } $flagCollection = \array_shift($classConstFetches); foreach ($classConstFetches as $classConstFetch) { - $flagCollection = new \PhpParser\Node\Expr\BinaryOp\BitwiseOr($flagCollection, $classConstFetch); + $flagCollection = new BitwiseOr($flagCollection, $classConstFetch); } return $flagCollection; } diff --git a/rules/Php80/NodeFactory/MatchArmsFactory.php b/rules/Php80/NodeFactory/MatchArmsFactory.php index 45d9aa3a1ba..fd21399994a 100644 --- a/rules/Php80/NodeFactory/MatchArmsFactory.php +++ b/rules/Php80/NodeFactory/MatchArmsFactory.php @@ -17,12 +17,12 @@ final class MatchArmsFactory $matchArms = []; foreach ($condAndExprs as $condAndExpr) { $expr = $condAndExpr->getExpr(); - if ($expr instanceof \PhpParser\Node\Expr\Assign) { + if ($expr instanceof Assign) { // $this->assignExpr = $expr->var; $expr = $expr->expr; } $condExprs = $condAndExpr->getCondExprs(); - $matchArms[] = new \PhpParser\Node\MatchArm($condExprs, $expr); + $matchArms[] = new MatchArm($condExprs, $expr); } return $matchArms; } diff --git a/rules/Php80/NodeFactory/MatchFactory.php b/rules/Php80/NodeFactory/MatchFactory.php index 2c389c08ece..f8d99e238f9 100644 --- a/rules/Php80/NodeFactory/MatchFactory.php +++ b/rules/Php80/NodeFactory/MatchFactory.php @@ -20,9 +20,9 @@ final class MatchFactory /** * @param CondAndExpr[] $condAndExprs */ - public function createFromCondAndExprs(\PhpParser\Node\Expr $condExpr, array $condAndExprs) : \PhpParser\Node\Expr\Match_ + public function createFromCondAndExprs(Expr $condExpr, array $condAndExprs) : Match_ { $matchArms = $this->matchArmsFactory->createFromCondAndExprs($condAndExprs); - return new \PhpParser\Node\Expr\Match_($condExpr, $matchArms); + return new Match_($condExpr, $matchArms); } } diff --git a/rules/Php80/NodeFactory/StrStartsWithFuncCallFactory.php b/rules/Php80/NodeFactory/StrStartsWithFuncCallFactory.php index 8edd9aee20a..1b8791d1848 100644 --- a/rules/Php80/NodeFactory/StrStartsWithFuncCallFactory.php +++ b/rules/Php80/NodeFactory/StrStartsWithFuncCallFactory.php @@ -13,13 +13,13 @@ final class StrStartsWithFuncCallFactory /** * @return \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\BooleanNot */ - public function createStrStartsWith(\Rector\Php80\ValueObject\StrStartsWith $strStartsWith) + public function createStrStartsWith(StrStartsWith $strStartsWith) { - $args = [new \PhpParser\Node\Arg($strStartsWith->getHaystackExpr()), new \PhpParser\Node\Arg($strStartsWith->getNeedleExpr())]; - $funcCall = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('str_starts_with'), $args); + $args = [new Arg($strStartsWith->getHaystackExpr()), new Arg($strStartsWith->getNeedleExpr())]; + $funcCall = new FuncCall(new Name('str_starts_with'), $args); if ($strStartsWith->isPositive()) { return $funcCall; } - return new \PhpParser\Node\Expr\BooleanNot($funcCall); + return new BooleanNot($funcCall); } } diff --git a/rules/Php80/NodeManipulator/AttributeGroupNamedArgumentManipulator.php b/rules/Php80/NodeManipulator/AttributeGroupNamedArgumentManipulator.php index c8fa945d103..08a5b36d099 100644 --- a/rules/Php80/NodeManipulator/AttributeGroupNamedArgumentManipulator.php +++ b/rules/Php80/NodeManipulator/AttributeGroupNamedArgumentManipulator.php @@ -27,7 +27,7 @@ final class AttributeGroupNamedArgumentManipulator /** * Special case for JMS Access type, where string is replaced by specific value */ - private function processReplaceAttr(\PhpParser\Node\Attribute $attribute, string $attrName) : void + private function processReplaceAttr(Attribute $attribute, string $attrName) : void { if (!\in_array($attrName, ['JMS\\Serializer\\Annotation\\AccessType', 'JMS\\AccessType'], \true)) { return; @@ -40,9 +40,9 @@ final class AttributeGroupNamedArgumentManipulator if ($currentArg->name !== null) { return; } - if (!$currentArg->value instanceof \PhpParser\Node\Scalar\String_) { + if (!$currentArg->value instanceof String_) { return; } - $currentArg->name = new \PhpParser\Node\Identifier('type'); + $currentArg->name = new Identifier('type'); } } diff --git a/rules/Php80/NodeManipulator/ResourceReturnToObject.php b/rules/Php80/NodeManipulator/ResourceReturnToObject.php index 4e6d2d97d98..e519d9ed871 100644 --- a/rules/Php80/NodeManipulator/ResourceReturnToObject.php +++ b/rules/Php80/NodeManipulator/ResourceReturnToObject.php @@ -41,7 +41,7 @@ final class ResourceReturnToObject * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver, BetterNodeFinder $betterNodeFinder, NodeComparator $nodeComparator) { $this->nodeNameResolver = $nodeNameResolver; $this->nodeTypeResolver = $nodeTypeResolver; @@ -55,7 +55,7 @@ final class ResourceReturnToObject */ public function refactor($node, array $collectionFunctionToReturnObject) { - if ($node instanceof \PhpParser\Node\Expr\FuncCall) { + if ($node instanceof FuncCall) { return $this->processFuncCall($node, $collectionFunctionToReturnObject); } return $this->processBooleanOr($node, $collectionFunctionToReturnObject); @@ -63,10 +63,10 @@ final class ResourceReturnToObject /** * @param array $collectionFunctionToReturnObject */ - private function processFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall, array $collectionFunctionToReturnObject) : ?\PhpParser\Node\Expr\Instanceof_ + private function processFuncCall(FuncCall $funcCall, array $collectionFunctionToReturnObject) : ?Instanceof_ { - $parent = $funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\Expr\BinaryOp && !$parent instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { + $parent = $funcCall->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof BinaryOp && !$parent instanceof BooleanOr) { return null; } if ($this->shouldSkip($funcCall)) { @@ -78,12 +78,12 @@ final class ResourceReturnToObject } /** @var Expr $argResourceValue */ $argResourceValue = $funcCall->args[0]->value; - return new \PhpParser\Node\Expr\Instanceof_($argResourceValue, new \PhpParser\Node\Name\FullyQualified($objectInstanceCheck)); + return new Instanceof_($argResourceValue, new FullyQualified($objectInstanceCheck)); } /** * @param array $collectionFunctionToReturnObject */ - private function resolveArgValueType(\PhpParser\Node\Expr\FuncCall $funcCall, array $collectionFunctionToReturnObject) : ?\PHPStan\Type\Type + private function resolveArgValueType(FuncCall $funcCall, array $collectionFunctionToReturnObject) : ?Type { /** @var Expr $argResourceValue */ $argResourceValue = $funcCall->args[0]->value; @@ -91,7 +91,7 @@ final class ResourceReturnToObject // if detected type is not FullyQualifiedObjectType, it still can be a resource to object, when: // - in the right position of BooleanOr, it be NeverType // - the object changed after init - if (!$argValueType instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) { + if (!$argValueType instanceof FullyQualifiedObjectType) { $argValueType = $this->resolveArgValueTypeFromPreviousAssign($funcCall, $argResourceValue, $collectionFunctionToReturnObject); } return $argValueType; @@ -99,10 +99,10 @@ final class ResourceReturnToObject /** * @param array $collectionFunctionToReturnObject */ - private function resolveObjectInstanceCheck(\PhpParser\Node\Expr\FuncCall $funcCall, array $collectionFunctionToReturnObject) : ?string + private function resolveObjectInstanceCheck(FuncCall $funcCall, array $collectionFunctionToReturnObject) : ?string { $argValueType = $this->resolveArgValueType($funcCall, $collectionFunctionToReturnObject); - if (!$argValueType instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) { + if (!$argValueType instanceof FullyQualifiedObjectType) { return null; } $className = $argValueType->getClassName(); @@ -116,10 +116,10 @@ final class ResourceReturnToObject /** * @param array $collectionFunctionToReturnObject */ - private function resolveArgValueTypeFromPreviousAssign(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr $expr, array $collectionFunctionToReturnObject) : ?\Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType + private function resolveArgValueTypeFromPreviousAssign(FuncCall $funcCall, Expr $expr, array $collectionFunctionToReturnObject) : ?FullyQualifiedObjectType { $objectInstanceCheck = null; - $assign = $this->betterNodeFinder->findFirstPrevious($funcCall, function (\PhpParser\Node $subNode) use(&$objectInstanceCheck, $expr, $collectionFunctionToReturnObject) : bool { + $assign = $this->betterNodeFinder->findFirstPrevious($funcCall, function (Node $subNode) use(&$objectInstanceCheck, $expr, $collectionFunctionToReturnObject) : bool { if (!$this->isAssignWithFuncCallExpr($subNode)) { return \false; } @@ -135,32 +135,32 @@ final class ResourceReturnToObject } return \false; }); - if (!$assign instanceof \PhpParser\Node\Expr\Assign) { + if (!$assign instanceof Assign) { return null; } /** @var string $objectInstanceCheck */ - return new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($objectInstanceCheck); + return new FullyQualifiedObjectType($objectInstanceCheck); } - private function isAssignWithFuncCallExpr(\PhpParser\Node $node) : bool + private function isAssignWithFuncCallExpr(Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + if (!$node instanceof Assign) { return \false; } - return $node->expr instanceof \PhpParser\Node\Expr\FuncCall; + return $node->expr instanceof FuncCall; } /** * @param array $collectionFunctionToReturnObject */ - private function processBooleanOr(\PhpParser\Node\Expr\BinaryOp\BooleanOr $booleanOr, array $collectionFunctionToReturnObject) : ?\PhpParser\Node\Expr\Instanceof_ + private function processBooleanOr(BooleanOr $booleanOr, array $collectionFunctionToReturnObject) : ?Instanceof_ { $left = $booleanOr->left; $right = $booleanOr->right; $funCall = null; $instanceof = null; - if ($left instanceof \PhpParser\Node\Expr\FuncCall && $right instanceof \PhpParser\Node\Expr\Instanceof_) { + if ($left instanceof FuncCall && $right instanceof Instanceof_) { $funCall = $left; $instanceof = $right; - } elseif ($left instanceof \PhpParser\Node\Expr\Instanceof_ && $right instanceof \PhpParser\Node\Expr\FuncCall) { + } elseif ($left instanceof Instanceof_ && $right instanceof FuncCall) { $funCall = $right; $instanceof = $left; } else { @@ -182,9 +182,9 @@ final class ResourceReturnToObject } return $instanceof; } - private function isInstanceOfObjectCheck(\PhpParser\Node\Expr\Instanceof_ $instanceof, \PhpParser\Node\Expr $expr, string $objectInstanceCheck) : bool + private function isInstanceOfObjectCheck(Instanceof_ $instanceof, Expr $expr, string $objectInstanceCheck) : bool { - if (!$instanceof->class instanceof \PhpParser\Node\Name\FullyQualified) { + if (!$instanceof->class instanceof FullyQualified) { return \false; } if (!$this->nodeComparator->areNodesEqual($expr, $instanceof->expr)) { @@ -192,7 +192,7 @@ final class ResourceReturnToObject } return $this->nodeNameResolver->isName($instanceof->class, $objectInstanceCheck); } - private function shouldSkip(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function shouldSkip(FuncCall $funcCall) : bool { if (!$this->nodeNameResolver->isName($funcCall, 'is_resource')) { return \true; @@ -201,6 +201,6 @@ final class ResourceReturnToObject return \true; } $argResource = $funcCall->args[0]; - return !$argResource instanceof \PhpParser\Node\Arg; + return !$argResource instanceof Arg; } } diff --git a/rules/Php80/NodeManipulator/TokenManipulator.php b/rules/Php80/NodeManipulator/TokenManipulator.php index 49bb3e8a460..2e76291b552 100644 --- a/rules/Php80/NodeManipulator/TokenManipulator.php +++ b/rules/Php80/NodeManipulator/TokenManipulator.php @@ -68,7 +68,7 @@ final class TokenManipulator * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\PostRector\Collector\NodesToRemoveCollector $nodesToRemoveCollector, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver, NodesToRemoveCollector $nodesToRemoveCollector, ValueResolver $valueResolver, NodeComparator $nodeComparator, ArgsAnalyzer $argsAnalyzer) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->nodeNameResolver = $nodeNameResolver; @@ -81,50 +81,50 @@ final class TokenManipulator /** * @param Node[] $nodes */ - public function refactorArrayToken(array $nodes, \PhpParser\Node\Expr $singleTokenExpr) : void + public function refactorArrayToken(array $nodes, Expr $singleTokenExpr) : void { $this->replaceTokenDimFetchZeroWithGetTokenName($nodes, $singleTokenExpr); // replace "$token[1]"; with "$token->value" - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($nodes, function (\PhpParser\Node $node) : ?PropertyFetch { - if (!$node instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($nodes, function (Node $node) : ?PropertyFetch { + if (!$node instanceof ArrayDimFetch) { return null; } if (!$this->isArrayDimFetchWithDimIntegerValue($node, 1)) { return null; } $tokenStaticType = $this->nodeTypeResolver->getType($node->var); - if (!$tokenStaticType instanceof \PHPStan\Type\ArrayType) { + if (!$tokenStaticType instanceof ArrayType) { return null; } - return new \PhpParser\Node\Expr\PropertyFetch($node->var, 'text'); + return new PropertyFetch($node->var, 'text'); }); } /** * @param Node[] $nodes */ - public function refactorNonArrayToken(array $nodes, \PhpParser\Node\Expr $singleTokenExpr) : void + public function refactorNonArrayToken(array $nodes, Expr $singleTokenExpr) : void { // replace "$content = $token;" → "$content = $token->text;" - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($nodes, function (\PhpParser\Node $node) use($singleTokenExpr) { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($nodes, function (Node $node) use($singleTokenExpr) { + if (!$node instanceof Assign) { return null; } if (!$this->nodeComparator->areNodesEqual($node->expr, $singleTokenExpr)) { return null; } $tokenStaticType = $this->nodeTypeResolver->getType($node->expr); - if ($tokenStaticType instanceof \PHPStan\Type\ArrayType) { + if ($tokenStaticType instanceof ArrayType) { return null; } - $node->expr = new \PhpParser\Node\Expr\PropertyFetch($singleTokenExpr, 'text'); + $node->expr = new PropertyFetch($singleTokenExpr, 'text'); }); // replace "$name = null;" → "$name = $token->getTokenName();" - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($nodes, function (\PhpParser\Node $node) use($singleTokenExpr) : ?Assign { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($nodes, function (Node $node) use($singleTokenExpr) : ?Assign { + if (!$node instanceof Assign) { return null; } $tokenStaticType = $this->nodeTypeResolver->getType($node->expr); - if ($tokenStaticType instanceof \PHPStan\Type\ArrayType) { + if ($tokenStaticType instanceof ArrayType) { return null; } if ($this->assignedNameExpr === null) { @@ -136,21 +136,21 @@ final class TokenManipulator if (!$this->valueResolver->isValue($node->expr, 'null')) { return null; } - $node->expr = new \PhpParser\Node\Expr\MethodCall($singleTokenExpr, 'getTokenName'); + $node->expr = new MethodCall($singleTokenExpr, 'getTokenName'); return $node; }); } /** * @param Node[] $nodes */ - public function refactorTokenIsKind(array $nodes, \PhpParser\Node\Expr $singleTokenExpr) : void + public function refactorTokenIsKind(array $nodes, Expr $singleTokenExpr) : void { - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($nodes, function (\PhpParser\Node $node) use($singleTokenExpr) : ?MethodCall { - if (!$node instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($nodes, function (Node $node) use($singleTokenExpr) : ?MethodCall { + if (!$node instanceof Identical) { return null; } $arrayDimFetchAndConstFetch = $this->matchArrayDimFetchAndConstFetch($node); - if (!$arrayDimFetchAndConstFetch instanceof \Rector\Php80\ValueObject\ArrayDimFetchAndConstFetch) { + if (!$arrayDimFetchAndConstFetch instanceof ArrayDimFetchAndConstFetch) { return null; } if (!$this->isArrayDimFetchWithDimIntegerValue($arrayDimFetchAndConstFetch->getArrayDimFetch(), 0)) { @@ -165,7 +165,7 @@ final class TokenManipulator if ($constName === null) { return null; } - if (!\Rector\Core\Util\StringUtils::isMatch($constName, '#^T_#')) { + if (!StringUtils::isMatch($constName, '#^T_#')) { return null; } return $this->createIsTConstTypeMethodCall($arrayDimFetch, $arrayDimFetchAndConstFetch->getConstFetch()); @@ -174,10 +174,10 @@ final class TokenManipulator /** * @param Node[] $nodes */ - public function removeIsArray(array $nodes, \PhpParser\Node\Expr\Variable $singleTokenVariable) : void + public function removeIsArray(array $nodes, Variable $singleTokenVariable) : void { - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($nodes, function (\PhpParser\Node $node) use($singleTokenVariable) { - if (!$node instanceof \PhpParser\Node\Expr\FuncCall) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($nodes, function (Node $node) use($singleTokenVariable) { + if (!$node instanceof FuncCall) { return null; } if (!$this->nodeNameResolver->isName($node, 'is_array')) { @@ -204,10 +204,10 @@ final class TokenManipulator * * @param Node[] $nodes */ - private function replaceTokenDimFetchZeroWithGetTokenName(array $nodes, \PhpParser\Node\Expr $singleTokenExpr) : void + private function replaceTokenDimFetchZeroWithGetTokenName(array $nodes, Expr $singleTokenExpr) : void { - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($nodes, function (\PhpParser\Node $node) use($singleTokenExpr) : ?MethodCall { - if (!$node instanceof \PhpParser\Node\Expr\FuncCall) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($nodes, function (Node $node) use($singleTokenExpr) : ?MethodCall { + if (!$node instanceof FuncCall) { return null; } if (!$this->nodeNameResolver->isName($node, 'token_name')) { @@ -219,11 +219,11 @@ final class TokenManipulator /** @var Arg $firstArg */ $firstArg = $node->args[0]; $possibleTokenArray = $firstArg->value; - if (!$possibleTokenArray instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$possibleTokenArray instanceof ArrayDimFetch) { return null; } $tokenStaticType = $this->nodeTypeResolver->getType($possibleTokenArray->var); - if (!$tokenStaticType instanceof \PHPStan\Type\ArrayType) { + if (!$tokenStaticType instanceof ArrayType) { return null; } if ($possibleTokenArray->dim === null) { @@ -236,47 +236,47 @@ final class TokenManipulator return null; } // save token variable name for later - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentNode instanceof \PhpParser\Node\Expr\Assign) { + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); + if ($parentNode instanceof Assign) { $this->assignedNameExpr = $parentNode->var; } - return new \PhpParser\Node\Expr\MethodCall($singleTokenExpr, 'getTokenName'); + return new MethodCall($singleTokenExpr, 'getTokenName'); }); } - private function isArrayDimFetchWithDimIntegerValue(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch, int $value) : bool + private function isArrayDimFetchWithDimIntegerValue(ArrayDimFetch $arrayDimFetch, int $value) : bool { if ($arrayDimFetch->dim === null) { return \false; } return $this->valueResolver->isValue($arrayDimFetch->dim, $value); } - private function matchArrayDimFetchAndConstFetch(\PhpParser\Node\Expr\BinaryOp\Identical $identical) : ?\Rector\Php80\ValueObject\ArrayDimFetchAndConstFetch + private function matchArrayDimFetchAndConstFetch(Identical $identical) : ?ArrayDimFetchAndConstFetch { - if ($identical->left instanceof \PhpParser\Node\Expr\ArrayDimFetch && $identical->right instanceof \PhpParser\Node\Expr\ConstFetch) { - return new \Rector\Php80\ValueObject\ArrayDimFetchAndConstFetch($identical->left, $identical->right); + if ($identical->left instanceof ArrayDimFetch && $identical->right instanceof ConstFetch) { + return new ArrayDimFetchAndConstFetch($identical->left, $identical->right); } - if (!$identical->right instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$identical->right instanceof ArrayDimFetch) { return null; } - if (!$identical->left instanceof \PhpParser\Node\Expr\ConstFetch) { + if (!$identical->left instanceof ConstFetch) { return null; } - return new \Rector\Php80\ValueObject\ArrayDimFetchAndConstFetch($identical->right, $identical->left); + return new ArrayDimFetchAndConstFetch($identical->right, $identical->left); } - private function createIsTConstTypeMethodCall(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch, \PhpParser\Node\Expr\ConstFetch $constFetch) : \PhpParser\Node\Expr\MethodCall + private function createIsTConstTypeMethodCall(ArrayDimFetch $arrayDimFetch, ConstFetch $constFetch) : MethodCall { - return new \PhpParser\Node\Expr\MethodCall($arrayDimFetch->var, 'is', [new \PhpParser\Node\Arg($constFetch)]); + return new MethodCall($arrayDimFetch->var, 'is', [new Arg($constFetch)]); } - private function shouldSkipNodeRemovalForPartOfIf(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function shouldSkipNodeRemovalForPartOfIf(FuncCall $funcCall) : bool { - $parentNode = $funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $funcCall->getAttribute(AttributeKey::PARENT_NODE); // cannot remove x from if(x) - if ($parentNode instanceof \PhpParser\Node\Stmt\If_ && $parentNode->cond === $funcCall) { + if ($parentNode instanceof If_ && $parentNode->cond === $funcCall) { return \true; } - if ($parentNode instanceof \PhpParser\Node\Expr\BooleanNot) { - $parentParentNode = $parentNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentParentNode instanceof \PhpParser\Node\Stmt\If_) { + if ($parentNode instanceof BooleanNot) { + $parentParentNode = $parentNode->getAttribute(AttributeKey::PARENT_NODE); + if ($parentParentNode instanceof If_) { $parentParentNode->cond = $parentNode; return \true; } @@ -286,10 +286,10 @@ final class TokenManipulator /** * @return \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\FuncCall */ - private function matchParentNodeInCaseOfIdenticalTrue(\PhpParser\Node\Expr\FuncCall $funcCall) + private function matchParentNodeInCaseOfIdenticalTrue(FuncCall $funcCall) { - $parentNode = $funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentNode instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { + $parentNode = $funcCall->getAttribute(AttributeKey::PARENT_NODE); + if ($parentNode instanceof Identical) { $isRightValueTrue = $this->valueResolver->isValue($parentNode->right, \true); if ($parentNode->left === $funcCall && $isRightValueTrue) { return $parentNode; diff --git a/rules/Php80/NodeResolver/RequireOptionalParamResolver.php b/rules/Php80/NodeResolver/RequireOptionalParamResolver.php index f485dc3dd7b..9819487e8c9 100644 --- a/rules/Php80/NodeResolver/RequireOptionalParamResolver.php +++ b/rules/Php80/NodeResolver/RequireOptionalParamResolver.php @@ -15,7 +15,7 @@ final class RequireOptionalParamResolver */ public function resolveFromReflection($functionLikeReflection) : array { - $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($functionLikeReflection->getVariants()); + $parametersAcceptor = ParametersAcceptorSelector::selectSingle($functionLikeReflection->getVariants()); $optionalParams = []; $requireParams = []; foreach ($parametersAcceptor->getParameters() as $position => $parameterReflection) { diff --git a/rules/Php80/NodeResolver/SwitchExprsResolver.php b/rules/Php80/NodeResolver/SwitchExprsResolver.php index 860382b311f..e2caa58365d 100644 --- a/rules/Php80/NodeResolver/SwitchExprsResolver.php +++ b/rules/Php80/NodeResolver/SwitchExprsResolver.php @@ -18,7 +18,7 @@ final class SwitchExprsResolver /** * @return CondAndExpr[] */ - public function resolve(\PhpParser\Node\Stmt\Switch_ $switch) : array + public function resolve(Switch_ $switch) : array { $condAndExpr = []; $collectionEmptyCasesCond = []; @@ -28,7 +28,7 @@ final class SwitchExprsResolver if (!$this->isValidCase($case)) { return []; } - if ($case->stmts === [] && $case->cond instanceof \PhpParser\Node\Expr) { + if ($case->stmts === [] && $case->cond instanceof Expr) { $collectionEmptyCasesCond[$key] = $case->cond; } } @@ -37,7 +37,7 @@ final class SwitchExprsResolver continue; } $expr = $case->stmts[0]; - if ($expr instanceof \PhpParser\Node\Stmt\Expression) { + if ($expr instanceof Expression) { $expr = $expr->expr; } $condExprs = []; @@ -53,29 +53,29 @@ final class SwitchExprsResolver $condExprs = $emptyCasesCond; $condExprs[] = $case->cond; } - if ($expr instanceof \PhpParser\Node\Stmt\Return_) { + if ($expr instanceof Return_) { $returnedExpr = $expr->expr; - if (!$returnedExpr instanceof \PhpParser\Node\Expr) { + if (!$returnedExpr instanceof Expr) { return []; } - $condAndExpr[] = new \Rector\Php80\ValueObject\CondAndExpr($condExprs, $returnedExpr, \Rector\Php80\Enum\MatchKind::RETURN); - } elseif ($expr instanceof \PhpParser\Node\Expr\Assign) { - $condAndExpr[] = new \Rector\Php80\ValueObject\CondAndExpr($condExprs, $expr, \Rector\Php80\Enum\MatchKind::ASSIGN); - } elseif ($expr instanceof \PhpParser\Node\Expr) { - $condAndExpr[] = new \Rector\Php80\ValueObject\CondAndExpr($condExprs, $expr, \Rector\Php80\Enum\MatchKind::NORMAL); - } elseif ($expr instanceof \PhpParser\Node\Stmt\Throw_) { - $throwExpr = new \PhpParser\Node\Expr\Throw_($expr->expr); - $condAndExpr[] = new \Rector\Php80\ValueObject\CondAndExpr($condExprs, $throwExpr, \Rector\Php80\Enum\MatchKind::THROW); + $condAndExpr[] = new CondAndExpr($condExprs, $returnedExpr, MatchKind::RETURN); + } elseif ($expr instanceof Assign) { + $condAndExpr[] = new CondAndExpr($condExprs, $expr, MatchKind::ASSIGN); + } elseif ($expr instanceof Expr) { + $condAndExpr[] = new CondAndExpr($condExprs, $expr, MatchKind::NORMAL); + } elseif ($expr instanceof Throw_) { + $throwExpr = new Expr\Throw_($expr->expr); + $condAndExpr[] = new CondAndExpr($condExprs, $throwExpr, MatchKind::THROW); } else { return []; } } return $condAndExpr; } - private function moveDefaultCaseToLast(\PhpParser\Node\Stmt\Switch_ $switch) : void + private function moveDefaultCaseToLast(Switch_ $switch) : void { foreach ($switch->cases as $key => $case) { - if ($case->cond instanceof \PhpParser\Node\Expr) { + if ($case->cond instanceof Expr) { continue; } // not has next? default is at the end, no need move @@ -94,13 +94,13 @@ final class SwitchExprsResolver break; } } - private function isValidCase(\PhpParser\Node\Stmt\Case_ $case) : bool + private function isValidCase(Case_ $case) : bool { // prepend to previous one if ($case->stmts === []) { return \true; } - if (\count($case->stmts) === 2 && $case->stmts[1] instanceof \PhpParser\Node\Stmt\Break_) { + if (\count($case->stmts) === 2 && $case->stmts[1] instanceof Break_) { return \true; } // default throws stmts @@ -108,11 +108,11 @@ final class SwitchExprsResolver return \false; } // throws expressoin - if ($case->stmts[0] instanceof \PhpParser\Node\Stmt\Throw_) { + if ($case->stmts[0] instanceof Throw_) { return \true; } // instant return - if ($case->stmts[0] instanceof \PhpParser\Node\Stmt\Return_) { + if ($case->stmts[0] instanceof Return_) { return \true; } // default value diff --git a/rules/Php80/PhpDoc/PhpDocNodeFinder.php b/rules/Php80/PhpDoc/PhpDocNodeFinder.php index dc586095680..0a800dc3884 100644 --- a/rules/Php80/PhpDoc/PhpDocNodeFinder.php +++ b/rules/Php80/PhpDoc/PhpDocNodeFinder.php @@ -12,11 +12,11 @@ final class PhpDocNodeFinder * @param class-string $nodeType * @return TNode[] */ - public function findByType(\PHPStan\PhpDocParser\Ast\Node $node, string $nodeType) : array + public function findByType(Node $node, string $nodeType) : array { $foundNodes = []; - $phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser(); - $phpDocNodeTraverser->traverseWithCallable($node, '', function (\PHPStan\PhpDocParser\Ast\Node $node) use(&$foundNodes, $nodeType) { + $phpDocNodeTraverser = new PhpDocNodeTraverser(); + $phpDocNodeTraverser->traverseWithCallable($node, '', function (Node $node) use(&$foundNodes, $nodeType) { if (!\is_a($node, $nodeType, \true)) { return null; } diff --git a/rules/Php80/Rector/Catch_/RemoveUnusedVariableInCatchRector.php b/rules/Php80/Rector/Catch_/RemoveUnusedVariableInCatchRector.php index 4fa7e2b8b56..1ab9057b09d 100644 --- a/rules/Php80/Rector/Catch_/RemoveUnusedVariableInCatchRector.php +++ b/rules/Php80/Rector/Catch_/RemoveUnusedVariableInCatchRector.php @@ -10,27 +10,27 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\DeadCode\NodeAnalyzer\ExprUsedInNodeAnalyzer; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/non-capturing_catches * * @see \Rector\Tests\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector\RemoveUnusedVariableInCatchRectorTest */ -final class RemoveUnusedVariableInCatchRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class RemoveUnusedVariableInCatchRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\DeadCode\NodeAnalyzer\ExprUsedInNodeAnalyzer */ private $exprUsedInNodeAnalyzer; - public function __construct(\Rector\DeadCode\NodeAnalyzer\ExprUsedInNodeAnalyzer $exprUsedInNodeAnalyzer) + public function __construct(ExprUsedInNodeAnalyzer $exprUsedInNodeAnalyzer) { $this->exprUsedInNodeAnalyzer = $exprUsedInNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove unused variable in catch()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove unused variable in catch()', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run() @@ -59,15 +59,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Catch_::class]; + return [Catch_::class]; } /** * @param Catch_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $caughtVar = $node->var; - if (!$caughtVar instanceof \PhpParser\Node\Expr\Variable) { + if (!$caughtVar instanceof Variable) { return null; } if ($this->isVariableUsedInStmts($node->stmts, $caughtVar)) { @@ -81,20 +81,20 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NON_CAPTURING_CATCH; + return PhpVersionFeature::NON_CAPTURING_CATCH; } /** * @param Node[] $nodes */ - private function isVariableUsedInStmts(array $nodes, \PhpParser\Node\Expr\Variable $variable) : bool + private function isVariableUsedInStmts(array $nodes, Variable $variable) : bool { - return (bool) $this->betterNodeFinder->findFirst($nodes, function (\PhpParser\Node $node) use($variable) : bool { + return (bool) $this->betterNodeFinder->findFirst($nodes, function (Node $node) use($variable) : bool { return $this->exprUsedInNodeAnalyzer->isUsed($node, $variable); }); } - private function isVariableUsedNext(\PhpParser\Node\Stmt\Catch_ $catch, \PhpParser\Node\Expr\Variable $variable) : bool + private function isVariableUsedNext(Catch_ $catch, Variable $variable) : bool { - return (bool) $this->betterNodeFinder->findFirstNext($catch, function (\PhpParser\Node $node) use($variable) : bool { + return (bool) $this->betterNodeFinder->findFirstNext($catch, function (Node $node) use($variable) : bool { return $this->exprUsedInNodeAnalyzer->isUsed($node, $variable); }); } diff --git a/rules/Php80/Rector/ClassMethod/AddParamBasedOnParentClassMethodRector.php b/rules/Php80/Rector/ClassMethod/AddParamBasedOnParentClassMethodRector.php index 27992a18eb9..c0b04081b3c 100644 --- a/rules/Php80/Rector/ClassMethod/AddParamBasedOnParentClassMethodRector.php +++ b/rules/Php80/Rector/ClassMethod/AddParamBasedOnParentClassMethodRector.php @@ -21,13 +21,13 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\VendorLocker\ParentClassMethodTypeOverrideGuard; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/lsp_errors * @see \Rector\Tests\Php80\Rector\ClassMethod\AddParamBasedOnParentClassMethodRector\AddParamBasedOnParentClassMethodRectorTest */ -final class AddParamBasedOnParentClassMethodRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class AddParamBasedOnParentClassMethodRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -44,7 +44,7 @@ final class AddParamBasedOnParentClassMethodRector extends \Rector\Core\Rector\A * @var \Rector\Core\Contract\PhpParser\NodePrinterInterface */ private $nodePrinter; - public function __construct(\Rector\VendorLocker\ParentClassMethodTypeOverrideGuard $parentClassMethodTypeOverrideGuard, \Rector\Core\PhpParser\AstResolver $astResolver, \Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter) + public function __construct(ParentClassMethodTypeOverrideGuard $parentClassMethodTypeOverrideGuard, AstResolver $astResolver, NodePrinterInterface $nodePrinter) { $this->parentClassMethodTypeOverrideGuard = $parentClassMethodTypeOverrideGuard; $this->astResolver = $astResolver; @@ -52,11 +52,11 @@ final class AddParamBasedOnParentClassMethodRector extends \Rector\Core\Rector\A } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::FATAL_ERROR_ON_INCOMPATIBLE_METHOD_SIGNATURE; + return PhpVersionFeature::FATAL_ERROR_ON_INCOMPATIBLE_METHOD_SIGNATURE; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add missing parameter based on parent class method', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add missing parameter based on parent class method', [new CodeSample(<<<'CODE_SAMPLE' class A { public function execute($foo) @@ -91,22 +91,22 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($this->nodeNameResolver->isName($node, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if ($this->nodeNameResolver->isName($node, MethodName::CONSTRUCT)) { return null; } $parentMethodReflection = $this->parentClassMethodTypeOverrideGuard->getParentClassMethod($node); - if (!$parentMethodReflection instanceof \PHPStan\Reflection\MethodReflection) { + if (!$parentMethodReflection instanceof MethodReflection) { return null; } $parentClassMethod = $this->astResolver->resolveClassMethodFromMethodReflection($parentMethodReflection); - if (!$parentClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$parentClassMethod instanceof ClassMethod) { return null; } if ($parentClassMethod->isPrivate()) { @@ -128,14 +128,14 @@ CODE_SAMPLE * @param Param[] $currentClassMethodParams * @param Param[] $parentClassMethodParams */ - private function processAddNullDefaultParam(\PhpParser\Node\Stmt\ClassMethod $classMethod, array $currentClassMethodParams, array $parentClassMethodParams) : ?\PhpParser\Node\Stmt\ClassMethod + private function processAddNullDefaultParam(ClassMethod $classMethod, array $currentClassMethodParams, array $parentClassMethodParams) : ?ClassMethod { $hasChanged = \false; foreach ($currentClassMethodParams as $key => $currentClassMethodParam) { if (isset($parentClassMethodParams[$key])) { continue; } - if ($currentClassMethodParam->default instanceof \PhpParser\Node\Expr) { + if ($currentClassMethodParam->default instanceof Expr) { continue; } $currentClassMethodParams[$key]->default = $this->nodeFactory->createNull(); @@ -150,7 +150,7 @@ CODE_SAMPLE * @param array $currentClassMethodParams * @param array $parentClassMethodParams */ - private function processReplaceClassMethodParams(\PhpParser\Node\Stmt\ClassMethod $node, \PhpParser\Node\Stmt\ClassMethod $parentClassMethod, array $currentClassMethodParams, array $parentClassMethodParams) : ?\PhpParser\Node\Stmt\ClassMethod + private function processReplaceClassMethodParams(ClassMethod $node, ClassMethod $parentClassMethod, array $currentClassMethodParams, array $parentClassMethodParams) : ?ClassMethod { $originalParams = $node->params; foreach ($parentClassMethodParams as $key => $parentClassMethodParam) { @@ -163,8 +163,8 @@ CODE_SAMPLE } continue; } - $isUsedInStmts = (bool) $this->betterNodeFinder->findFirstInFunctionLikeScoped($node, function (\PhpParser\Node $subNode) use($parentClassMethodParam) : bool { - if (!$subNode instanceof \PhpParser\Node\Expr\Variable) { + $isUsedInStmts = (bool) $this->betterNodeFinder->findFirstInFunctionLikeScoped($node, function (Node $subNode) use($parentClassMethodParam) : bool { + if (!$subNode instanceof Variable) { return \false; } return $this->nodeComparator->areNodesEqual($subNode, $parentClassMethodParam->var); @@ -174,32 +174,32 @@ CODE_SAMPLE return null; } $paramDefault = $parentClassMethodParam->default; - if ($paramDefault instanceof \PhpParser\Node\Expr) { + if ($paramDefault instanceof Expr) { $printParamDefault = $this->nodePrinter->print($paramDefault); - $paramDefault = new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name($printParamDefault)); + $paramDefault = new ConstFetch(new Name($printParamDefault)); } $paramName = $this->nodeNameResolver->getName($parentClassMethodParam); $paramType = $this->resolveParamType($parentClassMethodParam); - $node->params[$key] = new \PhpParser\Node\Param(new \PhpParser\Node\Expr\Variable($paramName), $paramDefault, $paramType, $parentClassMethodParam->byRef, $parentClassMethodParam->variadic, [], $parentClassMethodParam->flags, $parentClassMethodParam->attrGroups); + $node->params[$key] = new Param(new Variable($paramName), $paramDefault, $paramType, $parentClassMethodParam->byRef, $parentClassMethodParam->variadic, [], $parentClassMethodParam->flags, $parentClassMethodParam->attrGroups); } return $node; } /** * @return null|\PhpParser\Node\Identifier|\PhpParser\Node\Name|\PhpParser\Node\ComplexType */ - private function resolveParamType(\PhpParser\Node\Param $param) + private function resolveParamType(Param $param) { if ($param->type === null) { return null; } $paramType = $param->type; - $paramType->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $paramType->setAttribute(AttributeKey::ORIGINAL_NODE, null); return $paramType; } /** * @return string[] */ - private function collectParamNamesNextKey(\PhpParser\Node\Stmt\ClassMethod $classMethod, int $key) : array + private function collectParamNamesNextKey(ClassMethod $classMethod, int $key) : array { $paramNames = []; foreach ($classMethod->params as $paramKey => $param) { diff --git a/rules/Php80/Rector/ClassMethod/FinalPrivateToPrivateVisibilityRector.php b/rules/Php80/Rector/ClassMethod/FinalPrivateToPrivateVisibilityRector.php index a5ecad314e0..d966ff283d0 100644 --- a/rules/Php80/Rector/ClassMethod/FinalPrivateToPrivateVisibilityRector.php +++ b/rules/Php80/Rector/ClassMethod/FinalPrivateToPrivateVisibilityRector.php @@ -10,29 +10,29 @@ use Rector\Core\ValueObject\MethodName; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Privatization\NodeManipulator\VisibilityManipulator; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector\FinalPrivateToPrivateVisibilityRectorTest */ -final class FinalPrivateToPrivateVisibilityRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class FinalPrivateToPrivateVisibilityRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\Privatization\NodeManipulator\VisibilityManipulator */ private $visibilityManipulator; - public function __construct(\Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator) + public function __construct(VisibilityManipulator $visibilityManipulator) { $this->visibilityManipulator = $visibilityManipulator; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NO_FINAL_PRIVATE; + return PhpVersionFeature::NO_FINAL_PRIVATE; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes method visibility from final private to only private', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes method visibility from final private to only private', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { final private function getter() { @@ -55,12 +55,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -68,12 +68,12 @@ CODE_SAMPLE $this->visibilityManipulator->makeNonFinal($node); return $node; } - private function shouldSkip(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkip(ClassMethod $classMethod) : bool { if (!$classMethod->isFinal()) { return \true; } - if ($classMethod->name->toString() === \Rector\Core\ValueObject\MethodName::CONSTRUCT) { + if ($classMethod->name->toString() === MethodName::CONSTRUCT) { return \true; } return !$classMethod->isPrivate(); diff --git a/rules/Php80/Rector/ClassMethod/SetStateToStaticRector.php b/rules/Php80/Rector/ClassMethod/SetStateToStaticRector.php index 5b25d689d00..6d46998f003 100644 --- a/rules/Php80/Rector/ClassMethod/SetStateToStaticRector.php +++ b/rules/Php80/Rector/ClassMethod/SetStateToStaticRector.php @@ -10,29 +10,29 @@ use Rector\Core\ValueObject\MethodName; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Privatization\NodeManipulator\VisibilityManipulator; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php80\Rector\ClassMethod\SetStateToStaticRector\SetStateToStaticRectorTest */ -final class SetStateToStaticRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class SetStateToStaticRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\Privatization\NodeManipulator\VisibilityManipulator */ private $visibilityManipulator; - public function __construct(\Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator) + public function __construct(VisibilityManipulator $visibilityManipulator) { $this->visibilityManipulator = $visibilityManipulator; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::STATIC_VISIBILITY_SET_STATE; + return PhpVersionFeature::STATIC_VISIBILITY_SET_STATE; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Adds static visibility to __set_state() methods', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Adds static visibility to __set_state() methods', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function __set_state($properties) { @@ -55,12 +55,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -68,9 +68,9 @@ CODE_SAMPLE $this->visibilityManipulator->makeStatic($node); return $node; } - private function shouldSkip(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkip(ClassMethod $classMethod) : bool { - if (!$this->isName($classMethod, \Rector\Core\ValueObject\MethodName::SET_STATE)) { + if (!$this->isName($classMethod, MethodName::SET_STATE)) { return \true; } return $classMethod->isStatic(); diff --git a/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php b/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php index 6f380c9467e..f99ce89cb66 100644 --- a/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php +++ b/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php @@ -33,15 +33,15 @@ use Rector\PhpAttribute\RemovableAnnotationAnalyzer; use Rector\PhpAttribute\UnwrapableAnnotationAnalyzer; use Rector\VersionBonding\Contract\MinPhpVersionInterface; use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @changelog https://wiki.php.net/rfc/attributes_v2 * * @see \Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\AnnotationToAttributeRectorTest */ -final class AnnotationToAttributeRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface, \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class AnnotationToAttributeRector extends AbstractRector implements ConfigurableRectorInterface, MinPhpVersionInterface { /** * @var AnnotationToAttribute[] @@ -92,7 +92,7 @@ final class AnnotationToAttributeRector extends \Rector\Core\Rector\AbstractRect * @var \Rector\Naming\Naming\UseImportsResolver */ private $useImportsResolver; - public function __construct(\Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory $phpAttributeGroupFactory, \Rector\Php80\NodeFactory\AttrGroupsFactory $attrGroupsFactory, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover $phpDocTagRemover, \Rector\Php80\PhpDoc\PhpDocNodeFinder $phpDocNodeFinder, \Rector\PhpAttribute\UnwrapableAnnotationAnalyzer $unwrapableAnnotationAnalyzer, \Rector\PhpAttribute\RemovableAnnotationAnalyzer $removableAnnotationAnalyzer, \Rector\Php80\NodeManipulator\AttributeGroupNamedArgumentManipulator $attributeGroupNamedArgumentManipulator, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider, \Rector\Naming\Naming\UseImportsResolver $useImportsResolver) + public function __construct(PhpAttributeGroupFactory $phpAttributeGroupFactory, AttrGroupsFactory $attrGroupsFactory, PhpDocTagRemover $phpDocTagRemover, PhpDocNodeFinder $phpDocNodeFinder, UnwrapableAnnotationAnalyzer $unwrapableAnnotationAnalyzer, RemovableAnnotationAnalyzer $removableAnnotationAnalyzer, AttributeGroupNamedArgumentManipulator $attributeGroupNamedArgumentManipulator, PhpVersionProvider $phpVersionProvider, UseImportsResolver $useImportsResolver) { $this->phpAttributeGroupFactory = $phpAttributeGroupFactory; $this->attrGroupsFactory = $attrGroupsFactory; @@ -104,9 +104,9 @@ final class AnnotationToAttributeRector extends \Rector\Core\Rector\AbstractRect $this->phpVersionProvider = $phpVersionProvider; $this->useImportsResolver = $useImportsResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change annotation to attribute', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change annotation to attribute', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Routing\Annotation\Route; class SymfonyRoute @@ -130,22 +130,22 @@ class SymfonyRoute } } CODE_SAMPLE -, [new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Routing\\Annotation\\Route')])]); +, [new AnnotationToAttribute('Symfony\\Component\\Routing\\Annotation\\Route')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class, \PhpParser\Node\Stmt\Property::class, \PhpParser\Node\Param::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\Closure::class, \PhpParser\Node\Expr\ArrowFunction::class]; + return [Class_::class, Property::class, Param::class, ClassMethod::class, Function_::class, Closure::class, ArrowFunction::class]; } /** * @param Class_|Property|Param|ClassMethod|Function_|Closure|ArrowFunction $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); - if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$phpDocInfo instanceof PhpDocInfo) { return null; } $uses = $this->useImportsResolver->resolveBareUsesForNode($node); @@ -166,27 +166,27 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Php80\ValueObject\AnnotationToAttribute::class); + Assert::allIsAOf($configuration, AnnotationToAttribute::class); $this->annotationsToAttributes = $configuration; $this->unwrapableAnnotationAnalyzer->configure($configuration); $this->removableAnnotationAnalyzer->configure($configuration); } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::ATTRIBUTES; + return PhpVersionFeature::ATTRIBUTES; } /** * @return AttributeGroup[] */ - private function processGenericTags(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : array + private function processGenericTags(PhpDocInfo $phpDocInfo) : array { $attributeGroups = []; - $phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser(); - $phpDocNodeTraverser->traverseWithCallable($phpDocInfo->getPhpDocNode(), '', function (\PHPStan\PhpDocParser\Ast\Node $docNode) use(&$attributeGroups, $phpDocInfo) : ?int { - if (!$docNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) { + $phpDocNodeTraverser = new PhpDocNodeTraverser(); + $phpDocNodeTraverser->traverseWithCallable($phpDocInfo->getPhpDocNode(), '', function (DocNode $docNode) use(&$attributeGroups, $phpDocInfo) : ?int { + if (!$docNode instanceof PhpDocTagNode) { return null; } - if (!$docNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) { + if (!$docNode->value instanceof GenericTagValueNode) { return null; } $tag = \trim($docNode->name, '@'); @@ -201,7 +201,7 @@ CODE_SAMPLE } $attributeGroups[] = $this->phpAttributeGroupFactory->createFromSimpleTag($annotationToAttribute); $phpDocInfo->markAsChanged(); - return \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser::NODE_REMOVE; + return PhpDocNodeTraverser::NODE_REMOVE; } return null; }); @@ -211,42 +211,42 @@ CODE_SAMPLE * @param Node\Stmt\Use_[] $uses * @return AttributeGroup[] */ - private function processDoctrineAnnotationClasses(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, array $uses) : array + private function processDoctrineAnnotationClasses(PhpDocInfo $phpDocInfo, array $uses) : array { if ($phpDocInfo->getPhpDocNode()->children === []) { return []; } $doctrineTagAndAnnotationToAttributes = []; foreach ($phpDocInfo->getPhpDocNode()->children as $phpDocChildNode) { - if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) { + if (!$phpDocChildNode instanceof PhpDocTagNode) { continue; } - if (!$phpDocChildNode->value instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$phpDocChildNode->value instanceof DoctrineAnnotationTagValueNode) { continue; } $doctrineTagValueNode = $phpDocChildNode->value; $annotationToAttribute = $this->matchAnnotationToAttribute($doctrineTagValueNode); - if (!$annotationToAttribute instanceof \Rector\Php80\ValueObject\AnnotationToAttribute) { + if (!$annotationToAttribute instanceof AnnotationToAttribute) { continue; } - $nestedDoctrineAnnotationTagValueNodes = $this->phpDocNodeFinder->findByType($doctrineTagValueNode, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode::class); + $nestedDoctrineAnnotationTagValueNodes = $this->phpDocNodeFinder->findByType($doctrineTagValueNode, DoctrineAnnotationTagValueNode::class); $shouldInlinedNested = \false; // depends on PHP 8.1+ - nested values, skip for now - if ($nestedDoctrineAnnotationTagValueNodes !== [] && !$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::NEW_INITIALIZERS)) { + if ($nestedDoctrineAnnotationTagValueNodes !== [] && !$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::NEW_INITIALIZERS)) { if (!$this->unwrapableAnnotationAnalyzer->areUnwrappable($nestedDoctrineAnnotationTagValueNodes)) { continue; } $shouldInlinedNested = \true; } if (!$this->removableAnnotationAnalyzer->isRemovable($doctrineTagValueNode)) { - $doctrineTagAndAnnotationToAttributes[] = new \Rector\Php80\ValueObject\DoctrineTagAndAnnotationToAttribute($doctrineTagValueNode, $annotationToAttribute); + $doctrineTagAndAnnotationToAttributes[] = new DoctrineTagAndAnnotationToAttribute($doctrineTagValueNode, $annotationToAttribute); } else { $shouldInlinedNested = \true; } if ($shouldInlinedNested) { // inline nested foreach ($nestedDoctrineAnnotationTagValueNodes as $nestedDoctrineAnnotationTagValueNode) { - $doctrineTagAndAnnotationToAttributes[] = new \Rector\Php80\ValueObject\DoctrineTagAndAnnotationToAttribute($nestedDoctrineAnnotationTagValueNode, $annotationToAttribute); + $doctrineTagAndAnnotationToAttributes[] = new DoctrineTagAndAnnotationToAttribute($nestedDoctrineAnnotationTagValueNode, $annotationToAttribute); } } $this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $doctrineTagValueNode); @@ -256,7 +256,7 @@ CODE_SAMPLE /** * @return \Rector\Php80\ValueObject\AnnotationToAttribute|null */ - private function matchAnnotationToAttribute(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) + private function matchAnnotationToAttribute(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) { foreach ($this->annotationsToAttributes as $annotationToAttribute) { if (!$doctrineAnnotationTagValueNode->hasClassName($annotationToAttribute->getTag())) { diff --git a/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php b/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php index aff5db3a4b5..834850db75a 100644 --- a/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php +++ b/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php @@ -26,14 +26,14 @@ use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Php80\NodeAnalyzer\PromotedPropertyCandidateResolver; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/constructor_promotion https://github.com/php/php-src/pull/5291 * * @see \Rector\Tests\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector\ClassPropertyAssignToConstructorPromotionRectorTest */ -final class ClassPropertyAssignToConstructorPromotionRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ClassPropertyAssignToConstructorPromotionRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -65,7 +65,7 @@ final class ClassPropertyAssignToConstructorPromotionRector extends \Rector\Core * @var \Rector\Core\NodeAnalyzer\PropertyAnalyzer */ private $propertyAnalyzer; - public function __construct(\Rector\Php80\NodeAnalyzer\PromotedPropertyCandidateResolver $promotedPropertyCandidateResolver, \Rector\Naming\VariableRenamer $variableRenamer, \Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover $varTagRemover, \Rector\Core\NodeAnalyzer\ParamAnalyzer $paramAnalyzer, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\Core\NodeAnalyzer\PropertyAnalyzer $propertyAnalyzer) + public function __construct(PromotedPropertyCandidateResolver $promotedPropertyCandidateResolver, VariableRenamer $variableRenamer, VarTagRemover $varTagRemover, ParamAnalyzer $paramAnalyzer, PhpDocTypeChanger $phpDocTypeChanger, PropertyAnalyzer $propertyAnalyzer) { $this->promotedPropertyCandidateResolver = $promotedPropertyCandidateResolver; $this->variableRenamer = $variableRenamer; @@ -74,9 +74,9 @@ final class ClassPropertyAssignToConstructorPromotionRector extends \Rector\Core $this->phpDocTypeChanger = $phpDocTypeChanger; $this->propertyAnalyzer = $propertyAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change simple property init and assign to constructor promotion', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change simple property init and assign to constructor promotion', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public float $someVariable; @@ -104,19 +104,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $promotionCandidates = $this->promotedPropertyCandidateResolver->resolveFromClass($node); if ($promotionCandidates === []) { return null; } /** @var ClassMethod $constructClassMethod */ - $constructClassMethod = $node->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); + $constructClassMethod = $node->getMethod(MethodName::CONSTRUCT); $classMethodPhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($constructClassMethod); foreach ($promotionCandidates as $promotionCandidate) { // does property have some useful annotations? @@ -138,11 +138,11 @@ CODE_SAMPLE $oldName = $this->getName($param->var); $this->variableRenamer->renameVariableInFunctionLike($constructClassMethod, $oldName, $propertyName, null); $paramTagValueNode = $classMethodPhpDocInfo->getParamTagValueNodeByName($paramName); - if (!$paramTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode) { + if (!$paramTagValueNode instanceof ParamTagValueNode) { $this->decorateParamWithPropertyPhpDocInfo($constructClassMethod, $property, $param, $paramName); } elseif ($paramTagValueNode->parameterName !== '$' . $propertyName) { $paramTagValueNode->parameterName = '$' . $propertyName; - $paramTagValueNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE, null); + $paramTagValueNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null); } // property name has higher priority $propertyName = $this->getName($property); @@ -157,24 +157,24 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::PROPERTY_PROMOTION; + return PhpVersionFeature::PROPERTY_PROMOTION; } - private function processNullableType(\PhpParser\Node\Stmt\Property $property, \PhpParser\Node\Param $param) : void + private function processNullableType(Property $property, Param $param) : void { if ($this->nodeTypeResolver->isNullableType($property)) { $objectType = $this->getType($property); - $param->type = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($objectType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM); + $param->type = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($objectType, TypeKind::PARAM); } } - private function decorateParamWithPropertyPhpDocInfo(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Stmt\Property $property, \PhpParser\Node\Param $param, string $paramName) : void + private function decorateParamWithPropertyPhpDocInfo(ClassMethod $classMethod, Property $property, Param $param, string $paramName) : void { $propertyPhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); $propertyPhpDocInfo->markAsChanged(); - $param->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $propertyPhpDocInfo); + $param->setAttribute(AttributeKey::PHP_DOC_INFO, $propertyPhpDocInfo); // make sure the docblock is useful if ($param->type === null) { $varTagValueNode = $propertyPhpDocInfo->getVarTagValueNode(); - if (!$varTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) { + if (!$varTagValueNode instanceof VarTagValueNode) { return; } $paramType = $this->staticTypeMapper->mapPHPStanPhpDocTypeToPHPStanType($varTagValueNode, $property); @@ -185,7 +185,7 @@ CODE_SAMPLE } $this->varTagRemover->removeVarPhpTagValueNodeIfNotComment($param, $paramType); } - private function shouldSkipParam(\PhpParser\Node\Param $param) : bool + private function shouldSkipParam(Param $param) : bool { if ($param->variadic) { return \true; @@ -197,11 +197,11 @@ CODE_SAMPLE } else { $type = $param->type; } - if (!$type instanceof \PhpParser\Node\UnionType) { + if (!$type instanceof UnionType) { return \false; } foreach ($type->types as $type) { - if (!$type instanceof \PhpParser\Node\Identifier) { + if (!$type instanceof Identifier) { continue; } if (!$this->isName($type, 'callable')) { diff --git a/rules/Php80/Rector/Class_/DoctrineAnnotationClassToAttributeRector.php b/rules/Php80/Rector/Class_/DoctrineAnnotationClassToAttributeRector.php index ab57b76f9df..838784bc774 100644 --- a/rules/Php80/Rector/Class_/DoctrineAnnotationClassToAttributeRector.php +++ b/rules/Php80/Rector/Class_/DoctrineAnnotationClassToAttributeRector.php @@ -22,8 +22,8 @@ use Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory; use Rector\PostRector\Collector\PropertyToAddCollector; use Rector\PostRector\ValueObject\PropertyMetadata; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @changelog https://php.watch/articles/php-attributes#syntax @@ -33,7 +33,7 @@ use RectorPrefix20220607\Webmozart\Assert\Assert; * * @see \Rector\Tests\Php80\Rector\Class_\DoctrineAnnotationClassToAttributeRector\DoctrineAnnotationClassToAttributeRectorTest */ -final class DoctrineAnnotationClassToAttributeRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface, \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class DoctrineAnnotationClassToAttributeRector extends AbstractRector implements ConfigurableRectorInterface, MinPhpVersionInterface { /** * @var string @@ -77,7 +77,7 @@ final class DoctrineAnnotationClassToAttributeRector extends \Rector\Core\Rector * @var \Rector\Php80\NodeAnalyzer\AnnotationTargetResolver */ private $annotationTargetResolver; - public function __construct(\Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover $phpDocTagRemover, \Rector\Php80\NodeFactory\AttributeFlagFactory $attributeFlagFactory, \Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory $phpAttributeGroupFactory, \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer $phpAttributeAnalyzer, \Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector, \Rector\Php80\NodeAnalyzer\AnnotationTargetResolver $annotationTargetResolver) + public function __construct(PhpDocTagRemover $phpDocTagRemover, AttributeFlagFactory $attributeFlagFactory, PhpAttributeGroupFactory $phpAttributeGroupFactory, PhpAttributeAnalyzer $phpAttributeAnalyzer, PropertyToAddCollector $propertyToAddCollector, AnnotationTargetResolver $annotationTargetResolver) { $this->phpDocTagRemover = $phpDocTagRemover; $this->attributeFlagFactory = $attributeFlagFactory; @@ -88,11 +88,11 @@ final class DoctrineAnnotationClassToAttributeRector extends \Rector\Core\Rector } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::ATTRIBUTES; + return PhpVersionFeature::ATTRIBUTES; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Refactor Doctrine @annotation annotated class to a PHP 8.0 attribute class', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Refactor Doctrine @annotation annotated class to a PHP 8.0 attribute class', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' use Doctrine\Common\Annotations\Annotation\Target; /** @@ -118,15 +118,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); - if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$phpDocInfo instanceof PhpDocInfo) { return null; } if ($this->shouldSkipClass($phpDocInfo, $node)) { @@ -140,11 +140,11 @@ CODE_SAMPLE $this->decorateTarget($phpDocInfo, $attributeGroup); foreach ($node->getProperties() as $property) { $propertyPhpDocInfo = $this->phpDocInfoFactory->createFromNode($property); - if (!$propertyPhpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$propertyPhpDocInfo instanceof PhpDocInfo) { continue; } $requiredDoctrineAnnotationTagValueNode = $propertyPhpDocInfo->findOneByAnnotationClass('Doctrine\\Common\\Annotations\\Annotation\\Required'); - if (!$requiredDoctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$requiredDoctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { continue; } if ($this->shouldRemoveAnnotations) { @@ -152,7 +152,7 @@ CODE_SAMPLE } // require in constructor $propertyName = $this->getName($property); - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($propertyName, new \PHPStan\Type\MixedType(), \PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC); + $propertyMetadata = new PropertyMetadata($propertyName, new MixedType(), Class_::MODIFIER_PUBLIC); $this->propertyToAddCollector->addPropertyToClass($node, $propertyMetadata); if ($this->shouldRemoveAnnotations) { $this->removeNode($property); @@ -167,20 +167,20 @@ CODE_SAMPLE public function configure(array $configuration) : void { $shouldRemoveAnnotations = $configuration[self::REMOVE_ANNOTATIONS] ?? (bool) \current($configuration); - \RectorPrefix20220607\Webmozart\Assert\Assert::boolean($shouldRemoveAnnotations); + Assert::boolean($shouldRemoveAnnotations); $this->shouldRemoveAnnotations = $shouldRemoveAnnotations; } - private function decorateTarget(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\AttributeGroup $attributeGroup) : void + private function decorateTarget(PhpDocInfo $phpDocInfo, AttributeGroup $attributeGroup) : void { $targetDoctrineAnnotationTagValueNode = $phpDocInfo->findOneByAnnotationClasses(['Doctrine\\Common\\Annotations\\Annotation\\Target', 'Target']); - if (!$targetDoctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$targetDoctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return; } if ($this->shouldRemoveAnnotations) { $this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $targetDoctrineAnnotationTagValueNode); } $targets = $targetDoctrineAnnotationTagValueNode->getSilentValue(); - if ($targets instanceof \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode) { + if ($targets instanceof CurlyListNode) { $targetValues = $targets->getValuesWithExplicitSilentAndWithoutQuotes(); } elseif (\is_string($targets)) { $targetValues = [$targets]; @@ -192,9 +192,9 @@ CODE_SAMPLE if ($flagCollection === null) { return; } - $attributeGroup->attrs[0]->args[] = new \PhpParser\Node\Arg($flagCollection); + $attributeGroup->attrs[0]->args[] = new Arg($flagCollection); } - private function shouldSkipClass(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\Stmt\Class_ $class) : bool + private function shouldSkipClass(PhpDocInfo $phpDocInfo, Class_ $class) : bool { if (!$phpDocInfo->hasByNames(['Annotation', 'annotation'])) { return \true; diff --git a/rules/Php80/Rector/Class_/StringableForToStringRector.php b/rules/Php80/Rector/Class_/StringableForToStringRector.php index 403fc004888..428e715a080 100644 --- a/rules/Php80/Rector/Class_/StringableForToStringRector.php +++ b/rules/Php80/Rector/Class_/StringableForToStringRector.php @@ -20,14 +20,14 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer; use Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/stringable * * @see \Rector\Tests\Php80\Rector\Class_\StringableForToStringRector\StringableForToStringRectorTest */ -final class StringableForToStringRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class StringableForToStringRector extends AbstractRector implements MinPhpVersionInterface { /** * @var string @@ -48,7 +48,7 @@ final class StringableForToStringRector extends \Rector\Core\Rector\AbstractRect * @var \Rector\Core\NodeAnalyzer\ClassAnalyzer */ private $classAnalyzer; - public function __construct(\Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer $familyRelationsAnalyzer, \Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer $returnTypeInferer, \Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer) + public function __construct(FamilyRelationsAnalyzer $familyRelationsAnalyzer, ReturnTypeInferer $returnTypeInferer, ClassAnalyzer $classAnalyzer) { $this->familyRelationsAnalyzer = $familyRelationsAnalyzer; $this->returnTypeInferer = $returnTypeInferer; @@ -56,11 +56,11 @@ final class StringableForToStringRector extends \Rector\Core\Rector\AbstractRect } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::STRINGABLE; + return PhpVersionFeature::STRINGABLE; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add `Stringable` interface to classes with `__toString()` method', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add `Stringable` interface to classes with `__toString()` method', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function __toString() @@ -85,15 +85,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $toStringClassMethod = $node->getMethod(\Rector\Core\ValueObject\MethodName::TO_STRING); - if (!$toStringClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $toStringClassMethod = $node->getMethod(MethodName::TO_STRING); + if (!$toStringClassMethod instanceof ClassMethod) { return null; } // warning, classes that implements __toString() will return Stringable interface even if they don't implemen it @@ -106,44 +106,44 @@ CODE_SAMPLE return null; } $returnType = $this->returnTypeInferer->inferFunctionLike($toStringClassMethod); - if (!$returnType instanceof \PHPStan\Type\StringType) { + if (!$returnType instanceof StringType) { $this->processNotStringType($toStringClassMethod); } // add interface - $node->implements[] = new \PhpParser\Node\Name\FullyQualified(self::STRINGABLE); + $node->implements[] = new FullyQualified(self::STRINGABLE); // add return type if ($toStringClassMethod->returnType === null) { - $toStringClassMethod->returnType = new \PhpParser\Node\Name('string'); + $toStringClassMethod->returnType = new Name('string'); } return $node; } - private function processNotStringType(\PhpParser\Node\Stmt\ClassMethod $toStringClassMethod) : void + private function processNotStringType(ClassMethod $toStringClassMethod) : void { if ($toStringClassMethod->isAbstract()) { return; } - $hasReturn = $this->betterNodeFinder->hasInstancesOfInFunctionLikeScoped($toStringClassMethod, \PhpParser\Node\Stmt\Return_::class); + $hasReturn = $this->betterNodeFinder->hasInstancesOfInFunctionLikeScoped($toStringClassMethod, Return_::class); if (!$hasReturn) { $stmts = (array) $toStringClassMethod->stmts; \end($stmts); $lastKey = \key($stmts); $lastKey = $lastKey === null ? 0 : (int) $lastKey + 1; - $toStringClassMethod->stmts[$lastKey] = new \PhpParser\Node\Stmt\Return_(new \PhpParser\Node\Scalar\String_('')); + $toStringClassMethod->stmts[$lastKey] = new Return_(new String_('')); return; } - $this->traverseNodesWithCallable((array) $toStringClassMethod->stmts, function (\PhpParser\Node $subNode) { - if (!$subNode instanceof \PhpParser\Node\Stmt\Return_) { + $this->traverseNodesWithCallable((array) $toStringClassMethod->stmts, function (Node $subNode) { + if (!$subNode instanceof Return_) { return null; } - if (!$subNode->expr instanceof \PhpParser\Node\Expr) { - $subNode->expr = new \PhpParser\Node\Scalar\String_(''); + if (!$subNode->expr instanceof Expr) { + $subNode->expr = new String_(''); return null; } $type = $this->nodeTypeResolver->getType($subNode->expr); - if ($type instanceof \PHPStan\Type\StringType) { + if ($type instanceof StringType) { return null; } - $subNode->expr = new \PhpParser\Node\Expr\Cast\String_($subNode->expr); + $subNode->expr = new CastString_($subNode->expr); return null; }); } diff --git a/rules/Php80/Rector/FuncCall/ClassOnObjectRector.php b/rules/Php80/Rector/FuncCall/ClassOnObjectRector.php index 64bcfdeaadc..ff6721ff4e0 100644 --- a/rules/Php80/Rector/FuncCall/ClassOnObjectRector.php +++ b/rules/Php80/Rector/FuncCall/ClassOnObjectRector.php @@ -11,18 +11,18 @@ use PhpParser\Node\Name; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/class_name_literal_on_object * * @see \Rector\Tests\Php80\Rector\FuncCall\ClassOnObjectRector\ClassOnObjectRectorTest */ -final class ClassOnObjectRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ClassOnObjectRector extends AbstractRector implements MinPhpVersionInterface { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change get_class($object) to faster $object::class', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change get_class($object) to faster $object::class', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($object) @@ -47,27 +47,27 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->nodeNameResolver->isName($node, 'get_class')) { return null; } if (!isset($node->args[0])) { - return new \PhpParser\Node\Expr\ClassConstFetch(new \PhpParser\Node\Name('self'), 'class'); + return new ClassConstFetch(new Name('self'), 'class'); } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } $object = $node->args[0]->value; - return new \PhpParser\Node\Expr\ClassConstFetch($object, 'class'); + return new ClassConstFetch($object, 'class'); } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::CLASS_ON_OBJECT; + return PhpVersionFeature::CLASS_ON_OBJECT; } } diff --git a/rules/Php80/Rector/FuncCall/Php8ResourceReturnToObjectRector.php b/rules/Php80/Rector/FuncCall/Php8ResourceReturnToObjectRector.php index aa4b6da3b5b..01ef64a6110 100644 --- a/rules/Php80/Rector/FuncCall/Php8ResourceReturnToObjectRector.php +++ b/rules/Php80/Rector/FuncCall/Php8ResourceReturnToObjectRector.php @@ -10,14 +10,14 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Php80\NodeManipulator\ResourceReturnToObject; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/migration80.incompatible.php#migration80.incompatible.resource2object * * @see \Rector\Tests\Php80\Rector\FuncCall\Php8ResourceReturnToObjectRector\Php8ResourceReturnToObjectRectorTest */ -final class Php8ResourceReturnToObjectRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class Php8ResourceReturnToObjectRector extends AbstractRector implements MinPhpVersionInterface { /** * @var array @@ -83,13 +83,13 @@ final class Php8ResourceReturnToObjectRector extends \Rector\Core\Rector\Abstrac * @var \Rector\Php80\NodeManipulator\ResourceReturnToObject */ private $resourceReturnToObject; - public function __construct(\Rector\Php80\NodeManipulator\ResourceReturnToObject $resourceReturnToObject) + public function __construct(ResourceReturnToObject $resourceReturnToObject) { $this->resourceReturnToObject = $resourceReturnToObject; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change is_resource() to instanceof Object', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change is_resource() to instanceof Object', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -116,17 +116,17 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Expr\BinaryOp\BooleanOr::class]; + return [FuncCall::class, BooleanOr::class]; } /** * @param FuncCall|BooleanOr $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { return $this->resourceReturnToObject->refactor($node, self::COLLECTION_FUNCTION_TO_RETURN_OBJECT); } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::PHP8_RESOURCE_TO_OBJECT; + return PhpVersionFeature::PHP8_RESOURCE_TO_OBJECT; } } diff --git a/rules/Php80/Rector/FuncCall/TokenGetAllToObjectRector.php b/rules/Php80/Rector/FuncCall/TokenGetAllToObjectRector.php index 80cc1916371..75a33eaebc2 100644 --- a/rules/Php80/Rector/FuncCall/TokenGetAllToObjectRector.php +++ b/rules/Php80/Rector/FuncCall/TokenGetAllToObjectRector.php @@ -18,31 +18,31 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Php80\NodeManipulator\TokenManipulator; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/token_as_object * * @see \Rector\Tests\Php80\Rector\FuncCall\TokenGetAllToObjectRector\TokenGetAllToObjectRectorTest */ -final class TokenGetAllToObjectRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class TokenGetAllToObjectRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\Php80\NodeManipulator\TokenManipulator */ private $tokenManipulator; - public function __construct(\Rector\Php80\NodeManipulator\TokenManipulator $tokenManipulator) + public function __construct(TokenManipulator $tokenManipulator) { $this->tokenManipulator = $tokenManipulator; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::PHP_TOKEN; + return PhpVersionFeature::PHP_TOKEN; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Convert `token_get_all` to `PhpToken::tokenize`', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Convert `token_get_all` to `PhpToken::tokenize`', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run() @@ -80,12 +80,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->nodeNameResolver->isName($node, 'token_get_all')) { return null; @@ -93,14 +93,14 @@ CODE_SAMPLE $this->refactorTokensVariable($node); return $this->nodeFactory->createStaticCall('PhpToken', 'tokenize', $node->args); } - private function refactorTokensVariable(\PhpParser\Node\Expr\FuncCall $funcCall) : void + private function refactorTokensVariable(FuncCall $funcCall) : void { - $assign = $funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$assign instanceof \PhpParser\Node\Expr\Assign) { + $assign = $funcCall->getAttribute(AttributeKey::PARENT_NODE); + if (!$assign instanceof Assign) { return; } /** @var ClassMethod|Function_|null $classMethodOrFunction */ - $classMethodOrFunction = $this->betterNodeFinder->findParentByTypes($funcCall, [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class]); + $classMethodOrFunction = $this->betterNodeFinder->findParentByTypes($funcCall, [ClassMethod::class, Function_::class]); if ($classMethodOrFunction === null) { return; } @@ -110,7 +110,7 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike */ - private function replaceGetNameOrGetValue($functionLike, \PhpParser\Node\Expr $assignedExpr) : void + private function replaceGetNameOrGetValue($functionLike, Expr $assignedExpr) : void { $tokensForeaches = $this->findForeachesOverTokenVariable($functionLike, $assignedExpr); foreach ($tokensForeaches as $tokenForeach) { @@ -121,28 +121,28 @@ CODE_SAMPLE * @return Foreach_[] * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike */ - private function findForeachesOverTokenVariable($functionLike, \PhpParser\Node\Expr $assignedExpr) : array + private function findForeachesOverTokenVariable($functionLike, Expr $assignedExpr) : array { - return $this->betterNodeFinder->find((array) $functionLike->stmts, function (\PhpParser\Node $node) use($assignedExpr) : bool { - if (!$node instanceof \PhpParser\Node\Stmt\Foreach_) { + return $this->betterNodeFinder->find((array) $functionLike->stmts, function (Node $node) use($assignedExpr) : bool { + if (!$node instanceof Foreach_) { return \false; } return $this->nodeComparator->areNodesEqual($node->expr, $assignedExpr); }); } - private function refactorTokenInForeach(\PhpParser\Node\Stmt\Foreach_ $tokensForeach) : void + private function refactorTokenInForeach(Foreach_ $tokensForeach) : void { $singleToken = $tokensForeach->valueVar; - if (!$singleToken instanceof \PhpParser\Node\Expr\Variable) { + if (!$singleToken instanceof Variable) { return; } - $this->traverseNodesWithCallable($tokensForeach, function (\PhpParser\Node $node) use($singleToken) { + $this->traverseNodesWithCallable($tokensForeach, function (Node $node) use($singleToken) { $this->tokenManipulator->refactorArrayToken([$node], $singleToken); $this->tokenManipulator->refactorNonArrayToken([$node], $singleToken); $this->tokenManipulator->refactorTokenIsKind([$node], $singleToken); $this->tokenManipulator->removeIsArray([$node], $singleToken); // drop if "If_" node not needed - if ($node instanceof \PhpParser\Node\Stmt\If_ && $node->else !== null) { + if ($node instanceof If_ && $node->else !== null) { if (!$this->nodeComparator->areNodesEqual($node->stmts, $node->else->stmts)) { return null; } @@ -154,15 +154,15 @@ CODE_SAMPLE /** * @param Stmt[] $stmts */ - private function unwrapStmts(array $stmts, \PhpParser\Node\Stmt\If_ $if) : void + private function unwrapStmts(array $stmts, If_ $if) : void { // move /* */ doc block from if to first element to keep it $currentPhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($if); foreach ($stmts as $key => $stmt) { if ($key === 0) { - $stmt->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $currentPhpDocInfo); + $stmt->setAttribute(AttributeKey::PHP_DOC_INFO, $currentPhpDocInfo); // move // comments - $stmt->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $if->getComments()); + $stmt->setAttribute(AttributeKey::COMMENTS, $if->getComments()); } $this->nodesToAddCollector->addNodeAfterNode($stmt, $if); } diff --git a/rules/Php80/Rector/FunctionLike/UnionTypesRector.php b/rules/Php80/Rector/FunctionLike/UnionTypesRector.php index 1e7ab2a17a2..862cde836f2 100644 --- a/rules/Php80/Rector/FunctionLike/UnionTypesRector.php +++ b/rules/Php80/Rector/FunctionLike/UnionTypesRector.php @@ -29,12 +29,12 @@ use Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer; use Rector\VendorLocker\NodeVendorLocker\ClassMethodParamVendorLockResolver; use Rector\VendorLocker\NodeVendorLocker\ClassMethodReturnTypeOverrideGuard; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php80\Rector\FunctionLike\UnionTypesRector\UnionTypesRectorTest */ -final class UnionTypesRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class UnionTypesRector extends AbstractRector implements MinPhpVersionInterface { /** * @var bool @@ -70,7 +70,7 @@ final class UnionTypesRector extends \Rector\Core\Rector\AbstractRector implemen * @var \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory */ private $typeFactory; - public function __construct(\Rector\DeadCode\PhpDoc\TagRemover\ReturnTagRemover $returnTagRemover, \Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover $paramTagRemover, \Rector\VendorLocker\NodeVendorLocker\ClassMethodParamVendorLockResolver $classMethodParamVendorLockResolver, \Rector\VendorLocker\NodeVendorLocker\ClassMethodReturnTypeOverrideGuard $classMethodReturnTypeOverrideGuard, \Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer $unionTypeAnalyzer, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory) + public function __construct(ReturnTagRemover $returnTagRemover, ParamTagRemover $paramTagRemover, ClassMethodParamVendorLockResolver $classMethodParamVendorLockResolver, ClassMethodReturnTypeOverrideGuard $classMethodReturnTypeOverrideGuard, UnionTypeAnalyzer $unionTypeAnalyzer, TypeFactory $typeFactory) { $this->returnTagRemover = $returnTagRemover; $this->paramTagRemover = $paramTagRemover; @@ -79,9 +79,9 @@ final class UnionTypesRector extends \Rector\Core\Rector\AbstractRector implemen $this->unionTypeAnalyzer = $unionTypeAnalyzer; $this->typeFactory = $typeFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change docs types to union types, where possible (properties are covered by TypedPropertiesRector)', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change docs types to union types, where possible (properties are covered by TypedPropertiesRector)', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { /** @@ -108,15 +108,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\Closure::class, \PhpParser\Node\Expr\ArrowFunction::class]; + return [ClassMethod::class, Function_::class, Closure::class, ArrowFunction::class]; } /** * @param ClassMethod | Function_ | Closure | ArrowFunction $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $this->hasChanged = \false; - if ($node instanceof \PhpParser\Node\Stmt\ClassMethod && $this->classMethodReturnTypeOverrideGuard->shouldSkipClassMethod($node)) { + if ($node instanceof ClassMethod && $this->classMethodReturnTypeOverrideGuard->shouldSkipClassMethod($node)) { return null; } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); @@ -134,22 +134,22 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::UNION_TYPES; + return PhpVersionFeature::UNION_TYPES; } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure|\PhpParser\Node\Expr\ArrowFunction $functionLike */ - private function refactorParamTypes($functionLike, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void + private function refactorParamTypes($functionLike, PhpDocInfo $phpDocInfo) : void { // skip parent class lock too, just to be safe in case of different parent docs - if ($functionLike instanceof \PhpParser\Node\Stmt\ClassMethod && $this->classMethodParamVendorLockResolver->isSoftLocked($functionLike)) { + if ($functionLike instanceof ClassMethod && $this->classMethodParamVendorLockResolver->isSoftLocked($functionLike)) { return; } foreach ($functionLike->getParams() as $param) { /** @var string $paramName */ $paramName = $this->getName($param->var); $paramType = $phpDocInfo->getParamType($paramName); - if (!$paramType instanceof \PHPStan\Type\UnionType) { + if (!$paramType instanceof UnionType) { continue; } if ($this->unionTypeAnalyzer->hasObjectWithoutClassType($paramType)) { @@ -157,14 +157,14 @@ CODE_SAMPLE continue; } $uniqueatedParamType = $this->filterOutDuplicatedArrayTypes($paramType); - if (!$uniqueatedParamType instanceof \PHPStan\Type\UnionType) { + if (!$uniqueatedParamType instanceof UnionType) { continue; } // mixed has to be standalone type, cannot be part of union type declaration - if ($paramType->isSuperTypeOf(new \PHPStan\Type\MixedType())->yes()) { + if ($paramType->isSuperTypeOf(new MixedType())->yes()) { continue; } - $phpParserUnionType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($uniqueatedParamType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM); + $phpParserUnionType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($uniqueatedParamType, TypeKind::PARAM); if ($this->shouldSkipParamTypeRefactor($param->type, $phpParserUnionType)) { continue; } @@ -172,37 +172,37 @@ CODE_SAMPLE $this->hasChanged = \true; } } - private function changeObjectWithoutClassType(\PhpParser\Node\Param $param, \PHPStan\Type\UnionType $unionType) : void + private function changeObjectWithoutClassType(Param $param, UnionType $unionType) : void { if (!$this->unionTypeAnalyzer->hasObjectWithoutClassTypeWithOnlyFullyQualifiedObjectType($unionType)) { return; } - $param->type = new \PhpParser\Node\Name('object'); + $param->type = new Name('object'); $this->hasChanged = \true; } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure|\PhpParser\Node\Expr\ArrowFunction $functionLike */ - private function refactorReturnType($functionLike, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void + private function refactorReturnType($functionLike, PhpDocInfo $phpDocInfo) : void { // do not override existing return type if ($functionLike->getReturnType() !== null) { return; } $returnType = $phpDocInfo->getReturnType(); - if (!$returnType instanceof \PHPStan\Type\UnionType) { + if (!$returnType instanceof UnionType) { return; } $uniqueatedReturnType = $this->filterOutDuplicatedArrayTypes($returnType); - if (!$uniqueatedReturnType instanceof \PHPStan\Type\UnionType) { + if (!$uniqueatedReturnType instanceof UnionType) { return; } // mixed has to be standalone type, cannot be part of union type declaration - if ($uniqueatedReturnType->isSuperTypeOf(new \PHPStan\Type\MixedType())->yes()) { + if ($uniqueatedReturnType->isSuperTypeOf(new MixedType())->yes()) { return; } - $phpParserUnionType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($uniqueatedReturnType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN); - if (!$phpParserUnionType instanceof \PhpParser\Node\UnionType) { + $phpParserUnionType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($uniqueatedReturnType, TypeKind::RETURN); + if (!$phpParserUnionType instanceof PhpParserUnionType) { return; } $functionLike->returnType = $phpParserUnionType; @@ -211,13 +211,13 @@ CODE_SAMPLE /** * @return \PHPStan\Type\UnionType|\PHPStan\Type\Type */ - private function filterOutDuplicatedArrayTypes(\PHPStan\Type\UnionType $unionType) + private function filterOutDuplicatedArrayTypes(UnionType $unionType) { $hasArrayType = \false; $singleArrayTypes = []; $originalTypeCount = \count($unionType->getTypes()); foreach ($unionType->getTypes() as $unionedType) { - if ($unionedType instanceof \PHPStan\Type\ArrayType) { + if ($unionedType instanceof ArrayType) { if ($hasArrayType) { continue; } @@ -238,20 +238,20 @@ CODE_SAMPLE */ private function shouldSkipParamTypeRefactor($type, $phpParserUnionType) : bool { - if (!$phpParserUnionType instanceof \PhpParser\Node\UnionType) { + if (!$phpParserUnionType instanceof PhpParserUnionType) { return \true; } - if ($type instanceof \PhpParser\Node\UnionType) { + if ($type instanceof PhpParserUnionType) { return \true; } if (\count($phpParserUnionType->types) > 1) { return \false; } $firstType = $phpParserUnionType->types[0]; - if (!$firstType instanceof \PhpParser\Node\Name\FullyQualified) { + if (!$firstType instanceof FullyQualified) { return \false; } - if (!$type instanceof \PhpParser\Node\Name\FullyQualified) { + if (!$type instanceof FullyQualified) { return \false; } return $type->toString() === $firstType->toString(); diff --git a/rules/Php80/Rector/Identical/StrEndsWithRector.php b/rules/Php80/Rector/Identical/StrEndsWithRector.php index aa9b1c96261..aff4ee3f61e 100644 --- a/rules/Php80/Rector/Identical/StrEndsWithRector.php +++ b/rules/Php80/Rector/Identical/StrEndsWithRector.php @@ -20,14 +20,14 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Nette\NodeAnalyzer\BinaryOpAnalyzer; use Rector\Nette\ValueObject\FuncCallAndExpr; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions * * @see \Rector\Tests\Php80\Rector\Identical\StrEndsWithRector\StrEndsWithRectorTest */ -final class StrEndsWithRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class StrEndsWithRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -39,18 +39,18 @@ final class StrEndsWithRector extends \Rector\Core\Rector\AbstractRector impleme * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Nette\NodeAnalyzer\BinaryOpAnalyzer $binaryOpAnalyzer, \Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(BinaryOpAnalyzer $binaryOpAnalyzer, ArgsAnalyzer $argsAnalyzer) { $this->binaryOpAnalyzer = $binaryOpAnalyzer; $this->argsAnalyzer = $argsAnalyzer; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::STR_ENDS_WITH; + return PhpVersionFeature::STR_ENDS_WITH; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change helper functions to str_ends_with()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change helper functions to str_ends_with()', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -72,7 +72,7 @@ class SomeClass } } CODE_SAMPLE -), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' +), new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -101,12 +101,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\Identical::class, \PhpParser\Node\Expr\BinaryOp\NotIdentical::class]; + return [Identical::class, NotIdentical::class]; } /** * @param Identical|NotIdentical $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { return $this->refactorSubstr($node) ?? $this->refactorSubstrCompare($node); } @@ -116,12 +116,12 @@ CODE_SAMPLE * $isMatch = 'needle' === substr($haystack, -6) * @return \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\BooleanNot|null */ - private function refactorSubstr(\PhpParser\Node\Expr\BinaryOp $binaryOp) + private function refactorSubstr(BinaryOp $binaryOp) { - if ($binaryOp->left instanceof \PhpParser\Node\Expr\FuncCall && $this->isName($binaryOp->left, 'substr')) { + if ($binaryOp->left instanceof FuncCall && $this->isName($binaryOp->left, 'substr')) { $substrFuncCall = $binaryOp->left; $comparedNeedleExpr = $binaryOp->right; - } elseif ($binaryOp->right instanceof \PhpParser\Node\Expr\FuncCall && $this->isName($binaryOp->right, 'substr')) { + } elseif ($binaryOp->right instanceof FuncCall && $this->isName($binaryOp->right, 'substr')) { $substrFuncCall = $binaryOp->right; $comparedNeedleExpr = $binaryOp->left; } else { @@ -138,16 +138,16 @@ CODE_SAMPLE /** @var Arg $firstArg */ $firstArg = $substrFuncCall->args[0]; $haystack = $firstArg->value; - $isPositive = $binaryOp instanceof \PhpParser\Node\Expr\BinaryOp\Identical; + $isPositive = $binaryOp instanceof Identical; return $this->buildReturnNode($haystack, $comparedNeedleExpr, $isPositive); } /** * @return \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\BooleanNot|null */ - private function refactorSubstrCompare(\PhpParser\Node\Expr\BinaryOp $binaryOp) + private function refactorSubstrCompare(BinaryOp $binaryOp) { $funcCallAndExpr = $this->binaryOpAnalyzer->matchFuncCallAndOtherExpr($binaryOp, 'substr_compare'); - if (!$funcCallAndExpr instanceof \Rector\Nette\ValueObject\FuncCallAndExpr) { + if (!$funcCallAndExpr instanceof FuncCallAndExpr) { return null; } $expr = $funcCallAndExpr->getExpr(); @@ -170,15 +170,15 @@ CODE_SAMPLE if (!$this->isUnaryMinusStrlenFuncCallArgValue($thirdArgValue, $needle) && !$this->isHardCodedLNumberAndString($thirdArgValue, $needle)) { return null; } - $isPositive = $binaryOp instanceof \PhpParser\Node\Expr\BinaryOp\Identical; + $isPositive = $binaryOp instanceof Identical; return $this->buildReturnNode($haystack, $needle, $isPositive); } - private function isUnaryMinusStrlenFuncCallArgValue(\PhpParser\Node\Expr $substrOffset, \PhpParser\Node\Expr $needle) : bool + private function isUnaryMinusStrlenFuncCallArgValue(Expr $substrOffset, Expr $needle) : bool { - if (!$substrOffset instanceof \PhpParser\Node\Expr\UnaryMinus) { + if (!$substrOffset instanceof UnaryMinus) { return \false; } - if (!$substrOffset->expr instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$substrOffset->expr instanceof FuncCall) { return \false; } $funcCall = $substrOffset->expr; @@ -188,21 +188,21 @@ CODE_SAMPLE if (!isset($funcCall->args[0])) { return \false; } - if (!$funcCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[0] instanceof Arg) { return \false; } return $this->nodeComparator->areNodesEqual($funcCall->args[0]->value, $needle); } - private function isHardCodedLNumberAndString(\PhpParser\Node\Expr $substrOffset, \PhpParser\Node\Expr $needle) : bool + private function isHardCodedLNumberAndString(Expr $substrOffset, Expr $needle) : bool { - if (!$substrOffset instanceof \PhpParser\Node\Expr\UnaryMinus) { + if (!$substrOffset instanceof UnaryMinus) { return \false; } - if (!$substrOffset->expr instanceof \PhpParser\Node\Scalar\LNumber) { + if (!$substrOffset->expr instanceof LNumber) { return \false; } $lNumber = $substrOffset->expr; - if (!$needle instanceof \PhpParser\Node\Scalar\String_) { + if (!$needle instanceof String_) { return \false; } return $lNumber->value === \strlen($needle->value); @@ -210,11 +210,11 @@ CODE_SAMPLE /** * @return \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\BooleanNot */ - private function buildReturnNode(\PhpParser\Node\Expr $haystack, \PhpParser\Node\Expr $needle, bool $isPositive) + private function buildReturnNode(Expr $haystack, Expr $needle, bool $isPositive) { $funcCall = $this->nodeFactory->createFuncCall('str_ends_with', [$haystack, $needle]); if (!$isPositive) { - return new \PhpParser\Node\Expr\BooleanNot($funcCall); + return new BooleanNot($funcCall); } return $funcCall; } diff --git a/rules/Php80/Rector/Identical/StrStartsWithRector.php b/rules/Php80/Rector/Identical/StrStartsWithRector.php index 23631b7571b..bbe05bdec19 100644 --- a/rules/Php80/Rector/Identical/StrStartsWithRector.php +++ b/rules/Php80/Rector/Identical/StrStartsWithRector.php @@ -11,8 +11,8 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Php80\Contract\StrStartWithMatchAndRefactorInterface; use Rector\Php80\ValueObject\StrStartsWith; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions * @@ -21,7 +21,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @see \Rector\Tests\Php80\Rector\Identical\StrStartsWithRector\StrStartsWithRectorTest */ -final class StrStartsWithRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class StrStartsWithRector extends AbstractRector implements MinPhpVersionInterface { /** * @var StrStartWithMatchAndRefactorInterface[] @@ -37,11 +37,11 @@ final class StrStartsWithRector extends \Rector\Core\Rector\AbstractRector imple } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::STR_STARTS_WITH; + return PhpVersionFeature::STR_STARTS_WITH; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change helper functions to str_starts_with()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change helper functions to str_starts_with()', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -70,16 +70,16 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\Identical::class, \PhpParser\Node\Expr\BinaryOp\NotIdentical::class]; + return [Identical::class, NotIdentical::class]; } /** * @param Identical|NotIdentical $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->strStartWithMatchAndRefactors as $strStartWithMatchAndRefactor) { $strStartsWithValueObject = $strStartWithMatchAndRefactor->match($node); - if (!$strStartsWithValueObject instanceof \Rector\Php80\ValueObject\StrStartsWith) { + if (!$strStartsWithValueObject instanceof StrStartsWith) { continue; } return $strStartWithMatchAndRefactor->refactorStrStartsWith($strStartsWithValueObject); diff --git a/rules/Php80/Rector/NotIdentical/StrContainsRector.php b/rules/Php80/Rector/NotIdentical/StrContainsRector.php index 09ce788e48c..80efd97a33f 100644 --- a/rules/Php80/Rector/NotIdentical/StrContainsRector.php +++ b/rules/Php80/Rector/NotIdentical/StrContainsRector.php @@ -12,14 +12,14 @@ use PhpParser\Node\Name; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://externals.io/message/108562 https://github.com/php/php-src/pull/5179 * * @see \Rector\Tests\Php80\Rector\NotIdentical\StrContainsRector\StrContainsRectorTest */ -final class StrContainsRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class StrContainsRector extends AbstractRector implements MinPhpVersionInterface { /** * @var string[] @@ -27,11 +27,11 @@ final class StrContainsRector extends \Rector\Core\Rector\AbstractRector impleme private const OLD_STR_NAMES = ['strpos', 'strstr']; public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::STR_CONTAINS; + return PhpVersionFeature::STR_CONTAINS; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace strpos() !== false and strstr() with str_contains()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace strpos() !== false and strstr() with str_contains()', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -56,30 +56,30 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\Identical::class, \PhpParser\Node\Expr\BinaryOp\NotIdentical::class]; + return [Identical::class, NotIdentical::class]; } /** * @param Identical|NotIdentical $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $funcCall = $this->matchIdenticalOrNotIdenticalToFalse($node); - if (!$funcCall instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$funcCall instanceof FuncCall) { return null; } - $funcCall->name = new \PhpParser\Node\Name('str_contains'); - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { - return new \PhpParser\Node\Expr\BooleanNot($funcCall); + $funcCall->name = new Name('str_contains'); + if ($node instanceof Identical) { + return new BooleanNot($funcCall); } return $funcCall; } /** * @param \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical $expr */ - private function matchIdenticalOrNotIdenticalToFalse($expr) : ?\PhpParser\Node\Expr\FuncCall + private function matchIdenticalOrNotIdenticalToFalse($expr) : ?FuncCall { if ($this->valueResolver->isFalse($expr->left)) { - if (!$expr->right instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$expr->right instanceof FuncCall) { return null; } if (!$this->isNames($expr->right, self::OLD_STR_NAMES)) { @@ -90,7 +90,7 @@ CODE_SAMPLE return $funcCall; } if ($this->valueResolver->isFalse($expr->right)) { - if (!$expr->left instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$expr->left instanceof FuncCall) { return null; } if (!$this->isNames($expr->left, self::OLD_STR_NAMES)) { diff --git a/rules/Php80/Rector/Switch_/ChangeSwitchToMatchRector.php b/rules/Php80/Rector/Switch_/ChangeSwitchToMatchRector.php index 6888fecf08e..11ef2da6824 100644 --- a/rules/Php80/Rector/Switch_/ChangeSwitchToMatchRector.php +++ b/rules/Php80/Rector/Switch_/ChangeSwitchToMatchRector.php @@ -22,15 +22,15 @@ use Rector\Php80\NodeFactory\MatchFactory; use Rector\Php80\NodeResolver\SwitchExprsResolver; use Rector\Php80\ValueObject\CondAndExpr; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/match_expression_v2 * @changelog https://3v4l.org/572T5 * * @see \Rector\Tests\Php80\Rector\Switch_\ChangeSwitchToMatchRector\ChangeSwitchToMatchRectorTest */ -final class ChangeSwitchToMatchRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ChangeSwitchToMatchRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -47,15 +47,15 @@ final class ChangeSwitchToMatchRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Php80\NodeFactory\MatchFactory */ private $matchFactory; - public function __construct(\Rector\Php80\NodeResolver\SwitchExprsResolver $switchExprsResolver, \Rector\Php80\NodeAnalyzer\MatchSwitchAnalyzer $matchSwitchAnalyzer, \Rector\Php80\NodeFactory\MatchFactory $matchFactory) + public function __construct(SwitchExprsResolver $switchExprsResolver, MatchSwitchAnalyzer $matchSwitchAnalyzer, MatchFactory $matchFactory) { $this->switchExprsResolver = $switchExprsResolver; $this->matchSwitchAnalyzer = $matchSwitchAnalyzer; $this->matchFactory = $matchFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change switch() to match()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change switch() to match()', [new CodeSample(<<<'CODE_SAMPLE' switch ($input) { case Lexer::T_SELECT: $statement = 'select'; @@ -81,12 +81,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Switch_::class]; + return [Switch_::class]; } /** * @param Switch_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $condAndExprs = $this->switchExprsResolver->resolve($node); if ($this->matchSwitchAnalyzer->shouldSkipSwitch($node, $condAndExprs)) { @@ -97,15 +97,15 @@ CODE_SAMPLE } $isReturn = \false; foreach ($condAndExprs as $condAndExpr) { - if ($condAndExpr->equalsMatchKind(\Rector\Php80\Enum\MatchKind::RETURN)) { + if ($condAndExpr->equalsMatchKind(MatchKind::RETURN)) { $isReturn = \true; break; } $expr = $condAndExpr->getExpr(); - if ($expr instanceof \PhpParser\Node\Expr\Throw_) { + if ($expr instanceof Throw_) { continue; } - if (!$expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$expr instanceof Assign) { return null; } } @@ -117,29 +117,29 @@ CODE_SAMPLE return $this->processReturn($match); } $assignExpr = $this->resolveAssignExpr($condAndExprs); - if ($assignExpr instanceof \PhpParser\Node\Expr) { + if ($assignExpr instanceof Expr) { return $this->changeToAssign($node, $match, $assignExpr); } return $match; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::MATCH_EXPRESSION; + return PhpVersionFeature::MATCH_EXPRESSION; } - private function processReturn(\PhpParser\Node\Expr\Match_ $match) : ?\PhpParser\Node\Stmt\Return_ + private function processReturn(Match_ $match) : ?Return_ { if (!$this->matchSwitchAnalyzer->hasDefaultValue($match)) { return null; } - return new \PhpParser\Node\Stmt\Return_($match); + return new Return_($match); } - private function changeToAssign(\PhpParser\Node\Stmt\Switch_ $switch, \PhpParser\Node\Expr\Match_ $match, \PhpParser\Node\Expr $assignExpr) : \PhpParser\Node\Expr\Assign + private function changeToAssign(Switch_ $switch, Match_ $match, Expr $assignExpr) : Assign { - $prevInitializedAssign = $this->betterNodeFinder->findFirstInlinedPrevious($switch, function (\PhpParser\Node $node) use($assignExpr) : bool { - return $node instanceof \PhpParser\Node\Expr\Assign && $this->nodeComparator->areNodesEqual($node->var, $assignExpr); + $prevInitializedAssign = $this->betterNodeFinder->findFirstInlinedPrevious($switch, function (Node $node) use($assignExpr) : bool { + return $node instanceof Assign && $this->nodeComparator->areNodesEqual($node->var, $assignExpr); }); - $assign = new \PhpParser\Node\Expr\Assign($assignExpr, $match); - if (!$prevInitializedAssign instanceof \PhpParser\Node\Expr\Assign) { + $assign = new Assign($assignExpr, $match); + if (!$prevInitializedAssign instanceof Assign) { return $assign; } if ($this->matchSwitchAnalyzer->hasDefaultValue($match)) { @@ -148,10 +148,10 @@ CODE_SAMPLE return $assign; } } else { - $match->arms[\count($match->arms)] = new \PhpParser\Node\MatchArm(null, $prevInitializedAssign->expr); + $match->arms[\count($match->arms)] = new MatchArm(null, $prevInitializedAssign->expr); } - $parentAssign = $prevInitializedAssign->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentAssign instanceof \PhpParser\Node\Stmt\Expression) { + $parentAssign = $prevInitializedAssign->getAttribute(AttributeKey::PARENT_NODE); + if ($parentAssign instanceof Expression) { $this->removeNode($parentAssign); } return $assign; @@ -159,11 +159,11 @@ CODE_SAMPLE /** * @param CondAndExpr[] $condAndExprs */ - private function resolveAssignExpr(array $condAndExprs) : ?\PhpParser\Node\Expr + private function resolveAssignExpr(array $condAndExprs) : ?Expr { foreach ($condAndExprs as $condAndExpr) { $expr = $condAndExpr->getExpr(); - if (!$expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$expr instanceof Assign) { continue; } return $expr->var; @@ -173,41 +173,41 @@ CODE_SAMPLE /** * @param CondAndExpr[] $condAndExprs */ - private function processImplicitReturnAfterSwitch(\PhpParser\Node\Stmt\Switch_ $switch, \PhpParser\Node\Expr\Match_ $match, array $condAndExprs) : \PhpParser\Node\Expr\Match_ + private function processImplicitReturnAfterSwitch(Switch_ $switch, Match_ $match, array $condAndExprs) : Match_ { - $nextNode = $switch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if (!$nextNode instanceof \PhpParser\Node\Stmt\Return_) { + $nextNode = $switch->getAttribute(AttributeKey::NEXT_NODE); + if (!$nextNode instanceof Return_) { return $match; } $returnedExpr = $nextNode->expr; - if (!$returnedExpr instanceof \PhpParser\Node\Expr) { + if (!$returnedExpr instanceof Expr) { return $match; } if ($this->matchSwitchAnalyzer->hasDefaultValue($match)) { return $match; } $assignExpr = $this->resolveAssignExpr($condAndExprs); - if (!$assignExpr instanceof \PhpParser\Node\Expr) { + if (!$assignExpr instanceof Expr) { $this->removeNode($nextNode); } - $condAndExprs[] = new \Rector\Php80\ValueObject\CondAndExpr([], $returnedExpr, \Rector\Php80\Enum\MatchKind::RETURN); + $condAndExprs[] = new CondAndExpr([], $returnedExpr, MatchKind::RETURN); return $this->matchFactory->createFromCondAndExprs($switch->cond, $condAndExprs); } /** * @param CondAndExpr[] $condAndExprs */ - private function processImplicitThrowsAfterSwitch(\PhpParser\Node\Stmt\Switch_ $switch, \PhpParser\Node\Expr\Match_ $match, array $condAndExprs) : \PhpParser\Node\Expr\Match_ + private function processImplicitThrowsAfterSwitch(Switch_ $switch, Match_ $match, array $condAndExprs) : Match_ { - $nextNode = $switch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if (!$nextNode instanceof \PhpParser\Node\Stmt\Throw_) { + $nextNode = $switch->getAttribute(AttributeKey::NEXT_NODE); + if (!$nextNode instanceof ThrowsStmt) { return $match; } if ($this->matchSwitchAnalyzer->hasDefaultValue($match)) { return $match; } $this->removeNode($nextNode); - $throw = new \PhpParser\Node\Expr\Throw_($nextNode->expr); - $condAndExprs[] = new \Rector\Php80\ValueObject\CondAndExpr([], $throw, \Rector\Php80\Enum\MatchKind::RETURN); + $throw = new Throw_($nextNode->expr); + $condAndExprs[] = new CondAndExpr([], $throw, MatchKind::RETURN); return $this->matchFactory->createFromCondAndExprs($switch->cond, $condAndExprs); } } diff --git a/rules/Php80/Rector/Ternary/GetDebugTypeRector.php b/rules/Php80/Rector/Ternary/GetDebugTypeRector.php index a50f84001ac..c01634c6bf3 100644 --- a/rules/Php80/Rector/Ternary/GetDebugTypeRector.php +++ b/rules/Php80/Rector/Ternary/GetDebugTypeRector.php @@ -10,22 +10,22 @@ use PhpParser\Node\Expr\Ternary; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/get_debug_type * * @see \Rector\Tests\Php80\Rector\Ternary\GetDebugTypeRector\GetDebugTypeRectorTest */ -final class GetDebugTypeRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class GetDebugTypeRector extends AbstractRector implements MinPhpVersionInterface { public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::GET_DEBUG_TYPE; + return PhpVersionFeature::GET_DEBUG_TYPE; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change ternary type resolve to get_debug_type()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change ternary type resolve to get_debug_type()', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($value) @@ -50,12 +50,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Ternary::class]; + return [Ternary::class]; } /** * @param Ternary $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -68,48 +68,48 @@ CODE_SAMPLE if (!isset($funcCall->args[0])) { return null; } - if (!$funcCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[0] instanceof Arg) { return null; } $firstExpr = $funcCall->args[0]->value; return $this->nodeFactory->createFuncCall('get_debug_type', [$firstExpr]); } - private function shouldSkip(\PhpParser\Node\Expr\Ternary $ternary) : bool + private function shouldSkip(Ternary $ternary) : bool { - if (!$ternary->cond instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$ternary->cond instanceof FuncCall) { return \true; } if (!$this->nodeNameResolver->isName($ternary->cond, 'is_object')) { return \true; } - if (!$ternary->if instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$ternary->if instanceof FuncCall) { return \true; } if (!$this->nodeNameResolver->isName($ternary->if, 'get_class')) { return \true; } - if (!$ternary->else instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$ternary->else instanceof FuncCall) { return \true; } return !$this->nodeNameResolver->isName($ternary->else, 'gettype'); } - private function areValuesIdentical(\PhpParser\Node\Expr\Ternary $ternary) : bool + private function areValuesIdentical(Ternary $ternary) : bool { /** @var FuncCall $isObjectFuncCall */ $isObjectFuncCall = $ternary->cond; - if (!$isObjectFuncCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$isObjectFuncCall->args[0] instanceof Arg) { return \false; } $firstExpr = $isObjectFuncCall->args[0]->value; /** @var FuncCall $getClassFuncCall */ $getClassFuncCall = $ternary->if; - if (!$getClassFuncCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$getClassFuncCall->args[0] instanceof Arg) { return \false; } $secondExpr = $getClassFuncCall->args[0]->value; /** @var FuncCall $gettypeFuncCall */ $gettypeFuncCall = $ternary->else; - if (!$gettypeFuncCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$gettypeFuncCall->args[0] instanceof Arg) { return \false; } $thirdExpr = $gettypeFuncCall->args[0]->value; diff --git a/rules/Php80/ValueObject/ArrayDimFetchAndConstFetch.php b/rules/Php80/ValueObject/ArrayDimFetchAndConstFetch.php index bebd383b9a8..3106aecf1e1 100644 --- a/rules/Php80/ValueObject/ArrayDimFetchAndConstFetch.php +++ b/rules/Php80/ValueObject/ArrayDimFetchAndConstFetch.php @@ -17,16 +17,16 @@ final class ArrayDimFetchAndConstFetch * @var \PhpParser\Node\Expr\ConstFetch */ private $constFetch; - public function __construct(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch, \PhpParser\Node\Expr\ConstFetch $constFetch) + public function __construct(ArrayDimFetch $arrayDimFetch, ConstFetch $constFetch) { $this->arrayDimFetch = $arrayDimFetch; $this->constFetch = $constFetch; } - public function getArrayDimFetch() : \PhpParser\Node\Expr\ArrayDimFetch + public function getArrayDimFetch() : ArrayDimFetch { return $this->arrayDimFetch; } - public function getConstFetch() : \PhpParser\Node\Expr\ConstFetch + public function getConstFetch() : ConstFetch { return $this->constFetch; } diff --git a/rules/Php80/ValueObject/CondAndExpr.php b/rules/Php80/ValueObject/CondAndExpr.php index 637af8795c7..25717f8ca4b 100644 --- a/rules/Php80/ValueObject/CondAndExpr.php +++ b/rules/Php80/ValueObject/CondAndExpr.php @@ -26,13 +26,13 @@ final class CondAndExpr * @param Expr[]|null $condExprs * @param MatchKind::* $matchKind */ - public function __construct($condExprs, \PhpParser\Node\Expr $expr, string $matchKind) + public function __construct($condExprs, Expr $expr, string $matchKind) { $this->condExprs = $condExprs; $this->expr = $expr; $this->matchKind = $matchKind; } - public function getExpr() : \PhpParser\Node\Expr + public function getExpr() : Expr { return $this->expr; } diff --git a/rules/Php80/ValueObject/DoctrineTagAndAnnotationToAttribute.php b/rules/Php80/ValueObject/DoctrineTagAndAnnotationToAttribute.php index 2ab2b3906f9..b65c78d15ca 100644 --- a/rules/Php80/ValueObject/DoctrineTagAndAnnotationToAttribute.php +++ b/rules/Php80/ValueObject/DoctrineTagAndAnnotationToAttribute.php @@ -16,12 +16,12 @@ final class DoctrineTagAndAnnotationToAttribute * @var \Rector\Php80\ValueObject\AnnotationToAttribute */ private $annotationToAttribute; - public function __construct(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, \Rector\Php80\ValueObject\AnnotationToAttribute $annotationToAttribute) + public function __construct(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, \Rector\Php80\ValueObject\AnnotationToAttribute $annotationToAttribute) { $this->doctrineAnnotationTagValueNode = $doctrineAnnotationTagValueNode; $this->annotationToAttribute = $annotationToAttribute; } - public function getDoctrineAnnotationTagValueNode() : \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode + public function getDoctrineAnnotationTagValueNode() : DoctrineAnnotationTagValueNode { return $this->doctrineAnnotationTagValueNode; } diff --git a/rules/Php80/ValueObject/PropertyPromotionCandidate.php b/rules/Php80/ValueObject/PropertyPromotionCandidate.php index 80d1bcb0543..3808a79da33 100644 --- a/rules/Php80/ValueObject/PropertyPromotionCandidate.php +++ b/rules/Php80/ValueObject/PropertyPromotionCandidate.php @@ -23,21 +23,21 @@ final class PropertyPromotionCandidate * @var \PhpParser\Node\Param */ private $param; - public function __construct(\PhpParser\Node\Stmt\Property $property, \PhpParser\Node\Expr\Assign $assign, \PhpParser\Node\Param $param) + public function __construct(Property $property, Assign $assign, Param $param) { $this->property = $property; $this->assign = $assign; $this->param = $param; } - public function getProperty() : \PhpParser\Node\Stmt\Property + public function getProperty() : Property { return $this->property; } - public function getAssign() : \PhpParser\Node\Expr\Assign + public function getAssign() : Assign { return $this->assign; } - public function getParam() : \PhpParser\Node\Param + public function getParam() : Param { return $this->param; } diff --git a/rules/Php80/ValueObject/StrStartsWith.php b/rules/Php80/ValueObject/StrStartsWith.php index 0fa235d89c8..90ececd2f21 100644 --- a/rules/Php80/ValueObject/StrStartsWith.php +++ b/rules/Php80/ValueObject/StrStartsWith.php @@ -27,18 +27,18 @@ final class StrStartsWith * @var bool */ private $isPositive; - public function __construct(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr $haystackExpr, \PhpParser\Node\Expr $needleExpr, bool $isPositive) + public function __construct(FuncCall $funcCall, Expr $haystackExpr, Expr $needleExpr, bool $isPositive) { $this->funcCall = $funcCall; $this->haystackExpr = $haystackExpr; $this->needleExpr = $needleExpr; $this->isPositive = $isPositive; } - public function getFuncCall() : \PhpParser\Node\Expr\FuncCall + public function getFuncCall() : FuncCall { return $this->funcCall; } - public function getHaystackExpr() : \PhpParser\Node\Expr + public function getHaystackExpr() : Expr { return $this->haystackExpr; } @@ -46,7 +46,7 @@ final class StrStartsWith { return $this->isPositive; } - public function getNeedleExpr() : \PhpParser\Node\Expr + public function getNeedleExpr() : Expr { return $this->needleExpr; } diff --git a/rules/Php80/ValueObjectFactory/StrStartsWithFactory.php b/rules/Php80/ValueObjectFactory/StrStartsWithFactory.php index b4a4ebbcbf7..9b8af79a4b4 100644 --- a/rules/Php80/ValueObjectFactory/StrStartsWithFactory.php +++ b/rules/Php80/ValueObjectFactory/StrStartsWithFactory.php @@ -14,11 +14,11 @@ final class StrStartsWithFactory * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(ArgsAnalyzer $argsAnalyzer) { $this->argsAnalyzer = $argsAnalyzer; } - public function createFromFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall, bool $isPositive) : ?\Rector\Php80\ValueObject\StrStartsWith + public function createFromFuncCall(FuncCall $funcCall, bool $isPositive) : ?StrStartsWith { if (!$this->argsAnalyzer->isArgsInstanceInArgsPositions($funcCall->args, [0, 1])) { return null; @@ -29,6 +29,6 @@ final class StrStartsWithFactory /** @var Arg $secondArg */ $secondArg = $funcCall->args[1]; $needle = $secondArg->value; - return new \Rector\Php80\ValueObject\StrStartsWith($funcCall, $haystack, $needle, $isPositive); + return new StrStartsWith($funcCall, $haystack, $needle, $isPositive); } } diff --git a/rules/Php81/NodeAnalyzer/ComplexNewAnalyzer.php b/rules/Php81/NodeAnalyzer/ComplexNewAnalyzer.php index e96adecabd0..e2df97fef56 100644 --- a/rules/Php81/NodeAnalyzer/ComplexNewAnalyzer.php +++ b/rules/Php81/NodeAnalyzer/ComplexNewAnalyzer.php @@ -22,14 +22,14 @@ final class ComplexNewAnalyzer * @var \Rector\Core\NodeAnalyzer\ExprAnalyzer */ private $exprAnalyzer; - public function __construct(\Rector\Core\NodeManipulator\ArrayManipulator $arrayManipulator, \Rector\Core\NodeAnalyzer\ExprAnalyzer $exprAnalyzer) + public function __construct(ArrayManipulator $arrayManipulator, ExprAnalyzer $exprAnalyzer) { $this->arrayManipulator = $arrayManipulator; $this->exprAnalyzer = $exprAnalyzer; } - public function isDynamic(\PhpParser\Node\Expr\New_ $new) : bool + public function isDynamic(New_ $new) : bool { - if (!$new->class instanceof \PhpParser\Node\Name\FullyQualified) { + if (!$new->class instanceof FullyQualified) { return \true; } $args = $new->getArgs(); @@ -39,7 +39,7 @@ final class ComplexNewAnalyzer continue; } // new inside array is allowed for New in initializer - if ($value instanceof \PhpParser\Node\Expr\Array_ && $this->isAllowedArray($value)) { + if ($value instanceof Array_ && $this->isAllowedArray($value)) { continue; } if (!$this->exprAnalyzer->isDynamicExpr($value)) { @@ -49,24 +49,24 @@ final class ComplexNewAnalyzer } return \false; } - private function isAllowedNew(\PhpParser\Node\Expr $expr) : bool + private function isAllowedNew(Expr $expr) : bool { - if ($expr instanceof \PhpParser\Node\Expr\New_) { + if ($expr instanceof New_) { return !$this->isDynamic($expr); } return \false; } - private function isAllowedArray(\PhpParser\Node\Expr\Array_ $array) : bool + private function isAllowedArray(Array_ $array) : bool { if (!$this->arrayManipulator->isDynamicArray($array)) { return \true; } $arrayItems = $array->items; foreach ($arrayItems as $arrayItem) { - if (!$arrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$arrayItem instanceof ArrayItem) { continue; } - if (!$arrayItem->value instanceof \PhpParser\Node\Expr\New_) { + if (!$arrayItem->value instanceof New_) { return \false; } if ($this->isDynamic($arrayItem->value)) { diff --git a/rules/Php81/NodeAnalyzer/EnumConstListClassDetector.php b/rules/Php81/NodeAnalyzer/EnumConstListClassDetector.php index 26ceca6d49c..f14e8effb74 100644 --- a/rules/Php81/NodeAnalyzer/EnumConstListClassDetector.php +++ b/rules/Php81/NodeAnalyzer/EnumConstListClassDetector.php @@ -15,11 +15,11 @@ final class EnumConstListClassDetector * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(NodeTypeResolver $nodeTypeResolver) { $this->nodeTypeResolver = $nodeTypeResolver; } - public function detect(\PhpParser\Node\Stmt\Class_ $class) : bool + public function detect(Class_ $class) : bool { $classConstants = $class->getConstants(); // must have at least 2 constants, otherwise probably not enum @@ -43,7 +43,7 @@ final class EnumConstListClassDetector // only scalar values are allowed foreach ($classConstants as $classConstant) { $onlyConstConst = $classConstant->consts[0]; - if (!$onlyConstConst->value instanceof \PhpParser\Node\Scalar) { + if (!$onlyConstConst->value instanceof Scalar) { return \false; } } diff --git a/rules/Php81/NodeFactory/ClassFromEnumFactory.php b/rules/Php81/NodeFactory/ClassFromEnumFactory.php index f54155cb5c2..ac95ac96c05 100644 --- a/rules/Php81/NodeFactory/ClassFromEnumFactory.php +++ b/rules/Php81/NodeFactory/ClassFromEnumFactory.php @@ -19,34 +19,34 @@ final class ClassFromEnumFactory * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } - public function createFromEnum(\PhpParser\Node\Stmt\Enum_ $enum) : \PhpParser\Node\Stmt\Class_ + public function createFromEnum(Enum_ $enum) : Class_ { $shortClassName = $this->nodeNameResolver->getShortName($enum); $classConsts = []; foreach ($enum->stmts as $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\EnumCase) { + if (!$stmt instanceof EnumCase) { continue; } $constValue = $this->createConstValue($stmt); - $classConsts[] = new \PhpParser\Node\Stmt\ClassConst([new \PhpParser\Node\Const_($stmt->name, $constValue)], \Rector\Core\ValueObject\Visibility::PUBLIC); + $classConsts[] = new ClassConst([new Const_($stmt->name, $constValue)], Visibility::PUBLIC); } - $class = new \PhpParser\Node\Stmt\Class_($shortClassName, ['stmts' => $classConsts]); + $class = new Class_($shortClassName, ['stmts' => $classConsts]); $class->namespacedName = $enum->namespacedName; return $class; } - private function createConstValue(\PhpParser\Node\Stmt\EnumCase $enumCase) : \PhpParser\Node\Expr + private function createConstValue(EnumCase $enumCase) : Expr { - if ($enumCase->expr instanceof \PhpParser\Node\Expr) { + if ($enumCase->expr instanceof Expr) { return $enumCase->expr; } /** @var string $enumName */ $enumName = $this->nodeNameResolver->getName($enumCase); // minimal convention $lowercasedEnumValue = \strtolower($enumName); - return new \PhpParser\Node\Scalar\String_($lowercasedEnumValue); + return new String_($lowercasedEnumValue); } } diff --git a/rules/Php81/NodeFactory/EnumFactory.php b/rules/Php81/NodeFactory/EnumFactory.php index 8a30e7e4f19..63079fecb0d 100644 --- a/rules/Php81/NodeFactory/EnumFactory.php +++ b/rules/Php81/NodeFactory/EnumFactory.php @@ -37,21 +37,21 @@ final class EnumFactory * @var \Rector\Core\PhpParser\Node\Value\ValueResolver */ private $valueResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \PhpParser\BuilderFactory $builderFactory, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver) + public function __construct(NodeNameResolver $nodeNameResolver, PhpDocInfoFactory $phpDocInfoFactory, BuilderFactory $builderFactory, ValueResolver $valueResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->phpDocInfoFactory = $phpDocInfoFactory; $this->builderFactory = $builderFactory; $this->valueResolver = $valueResolver; } - public function createFromClass(\PhpParser\Node\Stmt\Class_ $class) : \PhpParser\Node\Stmt\Enum_ + public function createFromClass(Class_ $class) : Enum_ { $shortClassName = $this->nodeNameResolver->getShortName($class); - $enum = new \PhpParser\Node\Stmt\Enum_($shortClassName); + $enum = new Enum_($shortClassName); $constants = $class->getConstants(); if ($constants !== []) { $value = $this->valueResolver->getValue($constants[0]->consts[0]->value); - $enum->scalarType = \is_string($value) ? new \PhpParser\Node\Identifier('string') : new \PhpParser\Node\Identifier('int'); + $enum->scalarType = \is_string($value) ? new Identifier('string') : new Identifier('int'); // constant to cases foreach ($constants as $constant) { $enum->stmts[] = $this->createEnumCaseFromConst($constant); @@ -59,34 +59,34 @@ final class EnumFactory } return $enum; } - public function createFromSpatieClass(\PhpParser\Node\Stmt\Class_ $class) : \PhpParser\Node\Stmt\Enum_ + public function createFromSpatieClass(Class_ $class) : Enum_ { $shortClassName = $this->nodeNameResolver->getShortName($class); - $enum = new \PhpParser\Node\Stmt\Enum_($shortClassName); + $enum = new Enum_($shortClassName); // constant to cases $phpDocInfo = $this->phpDocInfoFactory->createFromNode($class); $docBlockMethods = ($phpDocInfo2 = $phpDocInfo) ? $phpDocInfo2->getTagsByName('@method') : null; if ($docBlockMethods !== null) { - $enum->scalarType = new \PhpParser\Node\Identifier('string'); + $enum->scalarType = new Identifier('string'); foreach ($docBlockMethods as $docBlockMethod) { $enum->stmts[] = $this->createEnumCaseFromDocComment($docBlockMethod); } } return $enum; } - private function createEnumCaseFromConst(\PhpParser\Node\Stmt\ClassConst $classConst) : \PhpParser\Node\Stmt\EnumCase + private function createEnumCaseFromConst(ClassConst $classConst) : EnumCase { $constConst = $classConst->consts[0]; - $enumCase = new \PhpParser\Node\Stmt\EnumCase($constConst->name, $constConst->value); + $enumCase = new EnumCase($constConst->name, $constConst->value); // mirror comments - $enumCase->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $classConst->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO)); - $enumCase->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $classConst->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS)); + $enumCase->setAttribute(AttributeKey::PHP_DOC_INFO, $classConst->getAttribute(AttributeKey::PHP_DOC_INFO)); + $enumCase->setAttribute(AttributeKey::COMMENTS, $classConst->getAttribute(AttributeKey::COMMENTS)); return $enumCase; } - private function createEnumCaseFromDocComment(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode $phpDocTagNode) : \PhpParser\Node\Stmt\EnumCase + private function createEnumCaseFromDocComment(PhpDocTagNode $phpDocTagNode) : EnumCase { /** @var MethodTagValueNode $nodeValue */ $nodeValue = $phpDocTagNode->value; - return new \PhpParser\Node\Stmt\EnumCase($nodeValue->methodName, $this->builderFactory->val($nodeValue->methodName)); + return new EnumCase($nodeValue->methodName, $this->builderFactory->val($nodeValue->methodName)); } } diff --git a/rules/Php81/Rector/ClassConst/FinalizePublicClassConstantRector.php b/rules/Php81/Rector/ClassConst/FinalizePublicClassConstantRector.php index d95834595ac..a55b31e5fb0 100644 --- a/rules/Php81/Rector/ClassConst/FinalizePublicClassConstantRector.php +++ b/rules/Php81/Rector/ClassConst/FinalizePublicClassConstantRector.php @@ -13,14 +13,14 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer; use Rector\Privatization\NodeManipulator\VisibilityManipulator; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://php.watch/versions/8.1/final-class-const * * @see \Rector\Tests\Php81\Rector\ClassConst\FinalizePublicClassConstantRector\FinalizePublicClassConstantRectorTest */ -final class FinalizePublicClassConstantRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class FinalizePublicClassConstantRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -42,16 +42,16 @@ final class FinalizePublicClassConstantRector extends \Rector\Core\Rector\Abstra * @var \Rector\Privatization\NodeManipulator\VisibilityManipulator */ private $visibilityManipulator; - public function __construct(\Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer $familyRelationsAnalyzer, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer, \Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator) + public function __construct(FamilyRelationsAnalyzer $familyRelationsAnalyzer, ReflectionProvider $reflectionProvider, ClassAnalyzer $classAnalyzer, VisibilityManipulator $visibilityManipulator) { $this->familyRelationsAnalyzer = $familyRelationsAnalyzer; $this->reflectionProvider = $reflectionProvider; $this->classAnalyzer = $classAnalyzer; $this->visibilityManipulator = $visibilityManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add final to constants that does not have children', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add final to constants that does not have children', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public const NAME = 'value'; @@ -70,15 +70,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassConst::class]; + return [ClassConst::class]; } /** * @param ClassConst $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $class = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$class instanceof Class_) { return null; } if ($class->isFinal()) { @@ -101,9 +101,9 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::FINAL_CLASS_CONSTANTS; + return PhpVersionFeature::FINAL_CLASS_CONSTANTS; } - private function isClassHasChildren(\PhpParser\Node\Stmt\Class_ $class) : bool + private function isClassHasChildren(Class_ $class) : bool { $className = (string) $this->nodeNameResolver->getName($class); if (!$this->reflectionProvider->hasClass($className)) { diff --git a/rules/Php81/Rector/ClassMethod/NewInInitializerRector.php b/rules/Php81/Rector/ClassMethod/NewInInitializerRector.php index d03cc078a43..b6b3930abe9 100644 --- a/rules/Php81/Rector/ClassMethod/NewInInitializerRector.php +++ b/rules/Php81/Rector/ClassMethod/NewInInitializerRector.php @@ -22,14 +22,14 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer; use Rector\Php81\NodeAnalyzer\ComplexNewAnalyzer; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/new_in_initializers * * @see \Rector\Tests\Php81\Rector\ClassMethod\NewInInitializerRector\NewInInitializerRectorTest */ -final class NewInInitializerRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class NewInInitializerRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -46,15 +46,15 @@ final class NewInInitializerRector extends \Rector\Core\Rector\AbstractRector im * @var \Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer */ private $classChildAnalyzer; - public function __construct(\Rector\Php81\NodeAnalyzer\ComplexNewAnalyzer $complexNewAnalyzer, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer $classChildAnalyzer) + public function __construct(ComplexNewAnalyzer $complexNewAnalyzer, ReflectionResolver $reflectionResolver, ClassChildAnalyzer $classChildAnalyzer) { $this->complexNewAnalyzer = $complexNewAnalyzer; $this->reflectionResolver = $reflectionResolver; $this->classChildAnalyzer = $classChildAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace property declaration of new state with direct new', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace property declaration of new state with direct new', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { private Logger $logger; @@ -82,12 +82,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isLegalClass($node)) { return null; @@ -103,13 +103,13 @@ CODE_SAMPLE /** @var string $paramName */ $paramName = $this->getName($param->var); $toPropertyAssigns = $this->betterNodeFinder->findClassMethodAssignsToLocalProperty($node, $paramName); - $toPropertyAssigns = \array_filter($toPropertyAssigns, function (\PhpParser\Node\Expr\Assign $assign) : bool { - return $assign->expr instanceof \PhpParser\Node\Expr\BinaryOp\Coalesce; + $toPropertyAssigns = \array_filter($toPropertyAssigns, function (Assign $assign) : bool { + return $assign->expr instanceof Coalesce; }); foreach ($toPropertyAssigns as $toPropertyAssign) { /** @var Coalesce $coalesce */ $coalesce = $toPropertyAssign->expr; - if (!$coalesce->right instanceof \PhpParser\Node\Expr\New_) { + if (!$coalesce->right instanceof New_) { continue; } if ($this->complexNewAnalyzer->isDynamic($coalesce->right)) { @@ -127,34 +127,34 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::NEW_INITIALIZERS; + return PhpVersionFeature::NEW_INITIALIZERS; } - private function isOverrideAbstractMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function isOverrideAbstractMethod(ClassMethod $classMethod) : bool { $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); $methodName = $this->nodeNameResolver->getName($classMethod); - return $classReflection instanceof \PHPStan\Reflection\ClassReflection && $this->classChildAnalyzer->hasAbstractParentClassMethod($classReflection, $methodName); + return $classReflection instanceof ClassReflection && $this->classChildAnalyzer->hasAbstractParentClassMethod($classReflection, $methodName); } - private function processPropertyPromotion(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Param $param, string $paramName) : void + private function processPropertyPromotion(ClassMethod $classMethod, Param $param, string $paramName) : void { - $classLike = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($classMethod, ClassLike::class); + if (!$classLike instanceof ClassLike) { return; } $property = $classLike->getProperty($paramName); - if (!$property instanceof \PhpParser\Node\Stmt\Property) { + if (!$property instanceof Property) { return; } $param->flags = $property->flags; $this->removeNode($property); } - private function isLegalClass(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function isLegalClass(ClassMethod $classMethod) : bool { - $classLike = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\ClassLike::class); - if ($classLike instanceof \PhpParser\Node\Stmt\Interface_) { + $classLike = $this->betterNodeFinder->findParentType($classMethod, ClassLike::class); + if ($classLike instanceof Interface_) { return \false; } - if ($classLike instanceof \PhpParser\Node\Stmt\Class_) { + if ($classLike instanceof Class_) { return !$classLike->isAbstract(); } return \true; @@ -162,9 +162,9 @@ CODE_SAMPLE /** * @return Param[] */ - private function matchConstructorParams(\PhpParser\Node\Stmt\ClassMethod $classMethod) : array + private function matchConstructorParams(ClassMethod $classMethod) : array { - if (!$this->isName($classMethod, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if (!$this->isName($classMethod, MethodName::CONSTRUCT)) { return []; } if ($classMethod->params === []) { @@ -173,8 +173,8 @@ CODE_SAMPLE if ((array) $classMethod->stmts === []) { return []; } - return \array_filter($classMethod->params, function (\PhpParser\Node\Param $param) : bool { - return $param->type instanceof \PhpParser\Node\NullableType; + return \array_filter($classMethod->params, function (Param $param) : bool { + return $param->type instanceof NullableType; }); } } diff --git a/rules/Php81/Rector/Class_/ConstantListClassToEnumRector.php b/rules/Php81/Rector/Class_/ConstantListClassToEnumRector.php index 81c46aa4200..0c57930b8bc 100644 --- a/rules/Php81/Rector/Class_/ConstantListClassToEnumRector.php +++ b/rules/Php81/Rector/Class_/ConstantListClassToEnumRector.php @@ -19,12 +19,12 @@ use Rector\Php80\NodeAnalyzer\EnumParamAnalyzer; use Rector\Php80\ValueObject\ClassNameAndTagValueNode; use Rector\Php81\NodeAnalyzer\EnumConstListClassDetector; use Rector\Php81\NodeFactory\EnumFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php81\Rector\Class_\ConstantListClassToEnumRector\ConstantListClassToEnumRectorTest */ -final class ConstantListClassToEnumRector extends \Rector\Core\Rector\AbstractRector +final class ConstantListClassToEnumRector extends AbstractRector { /** * @readonly @@ -51,7 +51,7 @@ final class ConstantListClassToEnumRector extends \Rector\Core\Rector\AbstractRe * @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover */ private $phpDocTagRemover; - public function __construct(\Rector\Php81\NodeAnalyzer\EnumConstListClassDetector $enumConstListClassDetector, \Rector\Php81\NodeFactory\EnumFactory $enumFactory, \Rector\Php80\NodeAnalyzer\EnumParamAnalyzer $enumParamAnalyzer, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover $phpDocTagRemover) + public function __construct(EnumConstListClassDetector $enumConstListClassDetector, EnumFactory $enumFactory, EnumParamAnalyzer $enumParamAnalyzer, ReflectionResolver $reflectionResolver, PhpDocTagRemover $phpDocTagRemover) { $this->enumConstListClassDetector = $enumConstListClassDetector; $this->enumFactory = $enumFactory; @@ -59,9 +59,9 @@ final class ConstantListClassToEnumRector extends \Rector\Core\Rector\AbstractRe $this->reflectionResolver = $reflectionResolver; $this->phpDocTagRemover = $phpDocTagRemover; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Upgrade constant list classes to full blown enum', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Upgrade constant list classes to full blown enum', [new CodeSample(<<<'CODE_SAMPLE' class Direction { public const LEFT = 'left'; @@ -84,33 +84,33 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Property::class]; + return [Class_::class, ClassMethod::class, Property::class]; } /** * @param Class_|ClassMethod|Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Stmt\Class_) { + if ($node instanceof Class_) { if (!$this->enumConstListClassDetector->detect($node)) { return null; } return $this->enumFactory->createFromClass($node); } - if ($node instanceof \PhpParser\Node\Stmt\ClassMethod) { + if ($node instanceof ClassMethod) { return $this->refactorClassMethod($node); } return $this->refactorProperty($node); } - private function refactorClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Stmt\ClassMethod + private function refactorClassMethod(ClassMethod $classMethod) : ?ClassMethod { // enum param types doc requires a docblock $phpDocInfo = $this->phpDocInfoFactory->createFromNode($classMethod); - if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$phpDocInfo instanceof PhpDocInfo) { return null; } $methodReflection = $this->reflectionResolver->resolveMethodReflectionFromClassMethod($classMethod); - if (!$methodReflection instanceof \PHPStan\Reflection\MethodReflection) { + if (!$methodReflection instanceof MethodReflection) { return null; } // refactor params @@ -124,7 +124,7 @@ CODE_SAMPLE } return null; } - private function getParamByName(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $desiredParamName) : ?\PhpParser\Node\Param + private function getParamByName(ClassMethod $classMethod, string $desiredParamName) : ?Param { foreach ($classMethod->params as $param) { if (!$this->nodeNameResolver->isName($param, $desiredParamName)) { @@ -134,47 +134,47 @@ CODE_SAMPLE } return null; } - private function refactorParams(\PHPStan\Reflection\MethodReflection $methodReflection, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function refactorParams(MethodReflection $methodReflection, PhpDocInfo $phpDocInfo, ClassMethod $classMethod) : bool { $hasNodeChanged = \false; - $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); + $parametersAcceptor = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); foreach ($parametersAcceptor->getParameters() as $parameterReflection) { $classNameAndTagValueNode = $this->enumParamAnalyzer->matchParameterClassName($parameterReflection, $phpDocInfo); - if (!$classNameAndTagValueNode instanceof \Rector\Php80\ValueObject\ClassNameAndTagValueNode) { + if (!$classNameAndTagValueNode instanceof ClassNameAndTagValueNode) { continue; } $param = $this->getParamByName($classMethod, $parameterReflection->getName()); - if (!$param instanceof \PhpParser\Node\Param) { + if (!$param instanceof Param) { continue; } // change and remove - $param->type = new \PhpParser\Node\Name\FullyQualified($classNameAndTagValueNode->getEnumClass()); + $param->type = new FullyQualified($classNameAndTagValueNode->getEnumClass()); $hasNodeChanged = \true; $this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $classNameAndTagValueNode->getTagValueNode()); } return $hasNodeChanged; } - private function refactorReturn(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function refactorReturn(PhpDocInfo $phpDocInfo, ClassMethod $classMethod) : bool { $classNameAndTagValueNode = $this->enumParamAnalyzer->matchReturnClassName($phpDocInfo); - if (!$classNameAndTagValueNode instanceof \Rector\Php80\ValueObject\ClassNameAndTagValueNode) { + if (!$classNameAndTagValueNode instanceof ClassNameAndTagValueNode) { return \false; } - $classMethod->returnType = new \PhpParser\Node\Name\FullyQualified($classNameAndTagValueNode->getEnumClass()); + $classMethod->returnType = new FullyQualified($classNameAndTagValueNode->getEnumClass()); $this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $classNameAndTagValueNode->getTagValueNode()); return \true; } - private function refactorProperty(\PhpParser\Node\Stmt\Property $property) : ?\PhpParser\Node\Stmt\Property + private function refactorProperty(Property $property) : ?Property { $phpDocInfo = $this->phpDocInfoFactory->createFromNode($property); - if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$phpDocInfo instanceof PhpDocInfo) { return null; } $classNameAndTagValueNode = $this->enumParamAnalyzer->matchPropertyClassName($phpDocInfo); - if (!$classNameAndTagValueNode instanceof \Rector\Php80\ValueObject\ClassNameAndTagValueNode) { + if (!$classNameAndTagValueNode instanceof ClassNameAndTagValueNode) { return null; } - $property->type = new \PhpParser\Node\Name\FullyQualified($classNameAndTagValueNode->getEnumClass()); + $property->type = new FullyQualified($classNameAndTagValueNode->getEnumClass()); $this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $classNameAndTagValueNode->getTagValueNode()); return $property; } diff --git a/rules/Php81/Rector/Class_/MyCLabsClassToEnumRector.php b/rules/Php81/Rector/Class_/MyCLabsClassToEnumRector.php index 51a2427f34b..4870fcbd7b3 100644 --- a/rules/Php81/Rector/Class_/MyCLabsClassToEnumRector.php +++ b/rules/Php81/Rector/Class_/MyCLabsClassToEnumRector.php @@ -10,28 +10,28 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Php81\NodeFactory\EnumFactory; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/enumerations * @changelog https://github.com/myclabs/php-enum * * @see \Rector\Tests\Php81\Rector\Class_\MyCLabsClassToEnumRector\MyCLabsClassToEnumRectorTest */ -final class MyCLabsClassToEnumRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class MyCLabsClassToEnumRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\Php81\NodeFactory\EnumFactory */ private $enumFactory; - public function __construct(\Rector\Php81\NodeFactory\EnumFactory $enumFactory) + public function __construct(EnumFactory $enumFactory) { $this->enumFactory = $enumFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Refactor MyCLabs enum class to native Enum', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Refactor MyCLabs enum class to native Enum', [new CodeSample(<<<'CODE_SAMPLE' use MyCLabs\Enum\Enum; final class Action extends Enum @@ -54,20 +54,20 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node, new \PHPStan\Type\ObjectType('MyCLabs\\Enum\\Enum'))) { + if (!$this->isObjectType($node, new ObjectType('MyCLabs\\Enum\\Enum'))) { return null; } return $this->enumFactory->createFromClass($node); } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::ENUM; + return PhpVersionFeature::ENUM; } } diff --git a/rules/Php81/Rector/Class_/SpatieEnumClassToEnumRector.php b/rules/Php81/Rector/Class_/SpatieEnumClassToEnumRector.php index 1f2edb4f342..b8615e973c9 100644 --- a/rules/Php81/Rector/Class_/SpatieEnumClassToEnumRector.php +++ b/rules/Php81/Rector/Class_/SpatieEnumClassToEnumRector.php @@ -11,32 +11,32 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Php81\NodeFactory\EnumFactory; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/enumerations * @changelog https://github.com/spatie/enum * * @see \Rector\Tests\Php81\Rector\Class_\SpatieEnumClassToEnumRector\SpatieEnumClassToEnumRectorTest */ -final class SpatieEnumClassToEnumRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class SpatieEnumClassToEnumRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\Php81\NodeFactory\EnumFactory */ private $enumFactory; - public function __construct(\Rector\Php81\NodeFactory\EnumFactory $enumFactory) + public function __construct(EnumFactory $enumFactory) { $this->enumFactory = $enumFactory; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::ENUM; + return PhpVersionFeature::ENUM; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Refactor Spatie enum class to native Enum', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Refactor Spatie enum class to native Enum', [new CodeSample(<<<'CODE_SAMPLE' use \Spatie\Enum\Enum; /** @@ -63,14 +63,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Stmt\Enum_ + public function refactor(Node $node) : ?Enum_ { - if (!$this->isObjectType($node, new \PHPStan\Type\ObjectType('Spatie\\Enum\\Enum'))) { + if (!$this->isObjectType($node, new ObjectType('Spatie\\Enum\\Enum'))) { return null; } return $this->enumFactory->createFromSpatieClass($node); diff --git a/rules/Php81/Rector/FuncCall/NullToStrictStringFuncCallArgRector.php b/rules/Php81/Rector/FuncCall/NullToStrictStringFuncCallArgRector.php index 36ceb3922a4..106604847e1 100644 --- a/rules/Php81/Rector/FuncCall/NullToStrictStringFuncCallArgRector.php +++ b/rules/Php81/Rector/FuncCall/NullToStrictStringFuncCallArgRector.php @@ -27,12 +27,12 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Php73\NodeTypeAnalyzer\NodeTypeAnalyzer; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector\NullToStrictStringFuncCallArgRectorTest */ -final class NullToStrictStringFuncCallArgRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class NullToStrictStringFuncCallArgRector extends AbstractRector implements MinPhpVersionInterface { /** * @var array @@ -53,15 +53,15 @@ final class NullToStrictStringFuncCallArgRector extends \Rector\Core\Rector\Abst * @var \Rector\Php73\NodeTypeAnalyzer\NodeTypeAnalyzer */ private $nodeTypeAnalyzer; - public function __construct(\Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer, \Rector\Php73\NodeTypeAnalyzer\NodeTypeAnalyzer $nodeTypeAnalyzer) + public function __construct(ReflectionResolver $reflectionResolver, ArgsAnalyzer $argsAnalyzer, NodeTypeAnalyzer $nodeTypeAnalyzer) { $this->reflectionResolver = $reflectionResolver; $this->argsAnalyzer = $argsAnalyzer; $this->nodeTypeAnalyzer = $nodeTypeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change null to strict string defined function call args', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change null to strict string defined function call args', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -86,12 +86,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -104,7 +104,7 @@ CODE_SAMPLE $isChanged = \false; foreach ($positions as $position) { $result = $this->processNullToStrictStringOnNodePosition($node, $args, $position); - if ($result instanceof \PhpParser\Node) { + if ($result instanceof Node) { $node = $result; $isChanged = \true; } @@ -116,19 +116,19 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::DEPRECATE_NULL_ARG_IN_STRING_FUNCTION; + return PhpVersionFeature::DEPRECATE_NULL_ARG_IN_STRING_FUNCTION; } /** * @param Arg[] $args * @return int[]|string[] */ - private function resolveNamedPositions(\PhpParser\Node\Expr\FuncCall $funcCall, array $args) : array + private function resolveNamedPositions(FuncCall $funcCall, array $args) : array { $functionName = $this->nodeNameResolver->getName($funcCall); $argNames = self::ARG_POSITION_NAME_NULL_TO_STRICT_STRING[$functionName]; $positions = []; foreach ($args as $position => $arg) { - if (!$arg->name instanceof \PhpParser\Node\Identifier) { + if (!$arg->name instanceof Identifier) { continue; } if (!$this->nodeNameResolver->isNames($arg->name, $argNames)) { @@ -142,11 +142,11 @@ CODE_SAMPLE * @param Arg[] $args * @param int|string $position */ - private function processNullToStrictStringOnNodePosition(\PhpParser\Node\Expr\FuncCall $funcCall, array $args, $position) : ?\PhpParser\Node\Expr\FuncCall + private function processNullToStrictStringOnNodePosition(FuncCall $funcCall, array $args, $position) : ?FuncCall { $argValue = $args[$position]->value; - if ($argValue instanceof \PhpParser\Node\Expr\ConstFetch && $this->valueResolver->isNull($argValue)) { - $args[$position]->value = new \PhpParser\Node\Scalar\String_(''); + if ($argValue instanceof ConstFetch && $this->valueResolver->isNull($argValue)) { + $args[$position]->value = new String_(''); $funcCall->args = $args; return $funcCall; } @@ -157,56 +157,56 @@ CODE_SAMPLE if ($this->isAnErrorTypeFromParentScope($argValue, $type)) { return null; } - if ($args[$position]->value instanceof \PhpParser\Node\Expr\MethodCall) { - $trait = $this->betterNodeFinder->findParentType($funcCall, \PhpParser\Node\Stmt\Trait_::class); - if ($trait instanceof \PhpParser\Node\Stmt\Trait_) { + if ($args[$position]->value instanceof MethodCall) { + $trait = $this->betterNodeFinder->findParentType($funcCall, Trait_::class); + if ($trait instanceof Trait_) { return null; } } if ($this->isCastedReassign($argValue)) { return null; } - $args[$position]->value = new \PhpParser\Node\Expr\Cast\String_($argValue); + $args[$position]->value = new CastString_($argValue); $funcCall->args = $args; return $funcCall; } - private function isCastedReassign(\PhpParser\Node\Expr $expr) : bool + private function isCastedReassign(Expr $expr) : bool { - return (bool) $this->betterNodeFinder->findFirstPrevious($expr, function (\PhpParser\Node $subNode) use($expr) : bool { - if (!$subNode instanceof \PhpParser\Node\Expr\Assign) { + return (bool) $this->betterNodeFinder->findFirstPrevious($expr, function (Node $subNode) use($expr) : bool { + if (!$subNode instanceof Assign) { return \false; } if (!$this->nodeComparator->areNodesEqual($subNode->var, $expr)) { return \false; } - return $subNode->expr instanceof \PhpParser\Node\Expr\Cast\String_; + return $subNode->expr instanceof CastString_; }); } - private function isAnErrorTypeFromParentScope(\PhpParser\Node\Expr $expr, \PHPStan\Type\Type $type) : bool + private function isAnErrorTypeFromParentScope(Expr $expr, Type $type) : bool { - if (!$type instanceof \PHPStan\Type\MixedType) { + if (!$type instanceof MixedType) { return \false; } - $scope = $expr->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { + $scope = $expr->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { return \false; } $parentScope = $scope->getParentScope(); - if ($parentScope instanceof \PHPStan\Analyser\Scope) { - return $parentScope->getType($expr) instanceof \PHPStan\Type\ErrorType; + if ($parentScope instanceof Scope) { + return $parentScope->getType($expr) instanceof ErrorType; } return \false; } /** * @return int[]|string[] */ - private function resolveOriginalPositions(\PhpParser\Node\Expr\FuncCall $funcCall) : array + private function resolveOriginalPositions(FuncCall $funcCall) : array { $functionReflection = $this->reflectionResolver->resolveFunctionLikeReflectionFromCall($funcCall); - if (!$functionReflection instanceof \PHPStan\Reflection\Native\NativeFunctionReflection) { + if (!$functionReflection instanceof NativeFunctionReflection) { return []; } - $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($functionReflection->getVariants()); + $parametersAcceptor = ParametersAcceptorSelector::selectSingle($functionReflection->getVariants()); $functionName = $this->nodeNameResolver->getName($funcCall); $argNames = self::ARG_POSITION_NAME_NULL_TO_STRICT_STRING[$functionName]; $positions = []; @@ -217,7 +217,7 @@ CODE_SAMPLE } return $positions; } - private function shouldSkip(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function shouldSkip(FuncCall $funcCall) : bool { $functionNames = \array_keys(self::ARG_POSITION_NAME_NULL_TO_STRICT_STRING); return !$this->nodeNameResolver->isNames($funcCall, $functionNames); diff --git a/rules/Php81/Rector/FuncCall/Php81ResourceReturnToObjectRector.php b/rules/Php81/Rector/FuncCall/Php81ResourceReturnToObjectRector.php index cdb393c97a5..57d42dd7e6f 100644 --- a/rules/Php81/Rector/FuncCall/Php81ResourceReturnToObjectRector.php +++ b/rules/Php81/Rector/FuncCall/Php81ResourceReturnToObjectRector.php @@ -10,14 +10,14 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Php80\NodeManipulator\ResourceReturnToObject; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://www.php.net/manual/en/migration81.incompatible.php#migration81.incompatible.resource2object * * @see \Rector\Tests\Php81\Rector\FuncCall\Php81ResourceReturnToObjectRector\Php81ResourceReturnToObjectRectorTest */ -final class Php81ResourceReturnToObjectRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class Php81ResourceReturnToObjectRector extends AbstractRector implements MinPhpVersionInterface { /** * @var array @@ -52,13 +52,13 @@ final class Php81ResourceReturnToObjectRector extends \Rector\Core\Rector\Abstra * @var \Rector\Php80\NodeManipulator\ResourceReturnToObject */ private $resourceReturnToObject; - public function __construct(\Rector\Php80\NodeManipulator\ResourceReturnToObject $resourceReturnToObject) + public function __construct(ResourceReturnToObject $resourceReturnToObject) { $this->resourceReturnToObject = $resourceReturnToObject; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change is_resource() to instanceof Object', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change is_resource() to instanceof Object', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -85,17 +85,17 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Expr\BinaryOp\BooleanOr::class]; + return [FuncCall::class, BooleanOr::class]; } /** * @param FuncCall|BooleanOr $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { return $this->resourceReturnToObject->refactor($node, self::COLLECTION_FUNCTION_TO_RETURN_OBJECT); } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::PHP81_RESOURCE_TO_OBJECT; + return PhpVersionFeature::PHP81_RESOURCE_TO_OBJECT; } } diff --git a/rules/Php81/Rector/FunctionLike/IntersectionTypesRector.php b/rules/Php81/Rector/FunctionLike/IntersectionTypesRector.php index 15bef9550f1..0b145afd51e 100644 --- a/rules/Php81/Rector/FunctionLike/IntersectionTypesRector.php +++ b/rules/Php81/Rector/FunctionLike/IntersectionTypesRector.php @@ -15,20 +15,20 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php81\Rector\FunctionLike\IntersectionTypesRector\IntersectionTypesRectorTest */ -final class IntersectionTypesRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class IntersectionTypesRector extends AbstractRector implements MinPhpVersionInterface { /** * @var bool */ private $hasChanged = \false; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change docs to intersection types, where possible (properties are covered by TypedPropertyRector (@todo))', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change docs to intersection types, where possible (properties are covered by TypedPropertyRector (@todo))', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { /** @@ -54,16 +54,16 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\ArrowFunction::class, \PhpParser\Node\Expr\Closure::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class]; + return [ArrowFunction::class, Closure::class, ClassMethod::class, Function_::class]; } /** * @param ArrowFunction|Closure|ClassMethod|Function_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $this->hasChanged = \false; $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); - if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$phpDocInfo instanceof PhpDocInfo) { return null; } $this->refactorParamTypes($node, $phpDocInfo); @@ -75,12 +75,12 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::INTERSECTION_TYPES; + return PhpVersionFeature::INTERSECTION_TYPES; } /** * @param \PhpParser\Node\Expr\ArrowFunction|\PhpParser\Node\Expr\Closure|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike */ - private function refactorParamTypes($functionLike, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void + private function refactorParamTypes($functionLike, PhpDocInfo $phpDocInfo) : void { foreach ($functionLike->params as $param) { if ($param->type !== null) { @@ -89,14 +89,14 @@ CODE_SAMPLE /** @var string $paramName */ $paramName = $this->getName($param->var); $paramType = $phpDocInfo->getParamType($paramName); - if (!$paramType instanceof \PHPStan\Type\IntersectionType) { + if (!$paramType instanceof IntersectionType) { continue; } if (!$this->isIntersectionableType($paramType)) { continue; } - $phpParserIntersectionType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($paramType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM); - if (!$phpParserIntersectionType instanceof \PhpParser\Node\IntersectionType) { + $phpParserIntersectionType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($paramType, TypeKind::PARAM); + if (!$phpParserIntersectionType instanceof Node\IntersectionType) { continue; } $param->type = $phpParserIntersectionType; @@ -106,10 +106,10 @@ CODE_SAMPLE /** * Only class-type are supported https://wiki.php.net/rfc/pure-intersection-types#supported_types */ - private function isIntersectionableType(\PHPStan\Type\IntersectionType $intersectionType) : bool + private function isIntersectionableType(IntersectionType $intersectionType) : bool { foreach ($intersectionType->getTypes() as $intersectionedType) { - if ($intersectionedType instanceof \PHPStan\Type\TypeWithClassName) { + if ($intersectionedType instanceof TypeWithClassName) { continue; } return \false; diff --git a/rules/Php81/Rector/MethodCall/MyCLabsMethodCallToEnumConstRector.php b/rules/Php81/Rector/MethodCall/MyCLabsMethodCallToEnumConstRector.php index b906769d11c..76755a96b7d 100644 --- a/rules/Php81/Rector/MethodCall/MyCLabsMethodCallToEnumConstRector.php +++ b/rules/Php81/Rector/MethodCall/MyCLabsMethodCallToEnumConstRector.php @@ -10,19 +10,19 @@ use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/enumerations * @changelog https://github.com/myclabs/php-enum * * @see \Rector\Tests\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector\MyCLabsMethodCallToEnumConstRectorTest */ -final class MyCLabsMethodCallToEnumConstRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class MyCLabsMethodCallToEnumConstRector extends AbstractRector implements MinPhpVersionInterface { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Refactor MyCLabs enum fetch to Enum const', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Refactor MyCLabs enum fetch to Enum const', [new CodeSample(<<<'CODE_SAMPLE' $name = SomeEnum::VALUE()->getKey(); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -35,20 +35,20 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('MyCLabs\\Enum\\Enum'))) { + if (!$this->isObjectType($node->var, new ObjectType('MyCLabs\\Enum\\Enum'))) { return null; } if (!$this->isName($node->name, 'getKey')) { return null; } - if (!$node->var instanceof \PhpParser\Node\Expr\StaticCall) { + if (!$node->var instanceof StaticCall) { return null; } $staticCall = $node->var; @@ -64,6 +64,6 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::ENUM; + return PhpVersionFeature::ENUM; } } diff --git a/rules/Php81/Rector/Property/ReadOnlyPropertyRector.php b/rules/Php81/Rector/Property/ReadOnlyPropertyRector.php index 79c72b08015..89e6fb56067 100644 --- a/rules/Php81/Rector/Property/ReadOnlyPropertyRector.php +++ b/rules/Php81/Rector/Property/ReadOnlyPropertyRector.php @@ -15,14 +15,14 @@ use Rector\Core\ValueObject\Visibility; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Privatization\NodeManipulator\VisibilityManipulator; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/readonly_properties_v2 * * @see \Rector\Tests\Php81\Rector\Property\ReadOnlyPropertyRector\ReadOnlyPropertyRectorTest */ -final class ReadOnlyPropertyRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ReadOnlyPropertyRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -39,15 +39,15 @@ final class ReadOnlyPropertyRector extends \Rector\Core\Rector\AbstractRector im * @var \Rector\Privatization\NodeManipulator\VisibilityManipulator */ private $visibilityManipulator; - public function __construct(\Rector\Core\NodeManipulator\PropertyManipulator $propertyManipulator, \Rector\Core\NodeManipulator\PropertyFetchAssignManipulator $propertyFetchAssignManipulator, \Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator) + public function __construct(PropertyManipulator $propertyManipulator, PropertyFetchAssignManipulator $propertyFetchAssignManipulator, VisibilityManipulator $visibilityManipulator) { $this->propertyManipulator = $propertyManipulator; $this->propertyFetchAssignManipulator = $propertyFetchAssignManipulator; $this->visibilityManipulator = $visibilityManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Decorate read-only property with `readonly` attribute', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Decorate read-only property with `readonly` attribute', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function __construct( @@ -82,23 +82,23 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class, \PhpParser\Node\Param::class]; + return [Property::class, Param::class]; } /** * @param Property|Param $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Param) { + if ($node instanceof Param) { return $this->refactorParam($node); } return $this->refactorProperty($node); } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::READONLY_PROPERTY; + return PhpVersionFeature::READONLY_PROPERTY; } - private function refactorProperty(\PhpParser\Node\Stmt\Property $property) : ?\PhpParser\Node\Stmt\Property + private function refactorProperty(Property $property) : ?Property { // 1. is property read-only? if ($this->propertyManipulator->isPropertyChangeableExceptConstructor($property)) { @@ -107,13 +107,13 @@ CODE_SAMPLE if ($property->isReadonly()) { return null; } - if ($property->props[0]->default instanceof \PhpParser\Node\Expr) { + if ($property->props[0]->default instanceof Expr) { return null; } if ($property->type === null) { return null; } - if (!$this->visibilityManipulator->hasVisibility($property, \Rector\Core\ValueObject\Visibility::PRIVATE)) { + if (!$this->visibilityManipulator->hasVisibility($property, Visibility::PRIVATE)) { return null; } if ($property->isStatic()) { @@ -125,16 +125,16 @@ CODE_SAMPLE $this->visibilityManipulator->makeReadonly($property); $attributeGroups = $property->attrGroups; if ($attributeGroups !== []) { - $property->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $property->setAttribute(AttributeKey::ORIGINAL_NODE, null); } return $property; } /** * @return \PhpParser\Node\Param|null */ - private function refactorParam(\PhpParser\Node\Param $param) + private function refactorParam(Param $param) { - if (!$this->visibilityManipulator->hasVisibility($param, \Rector\Core\ValueObject\Visibility::PRIVATE)) { + if (!$this->visibilityManipulator->hasVisibility($param, Visibility::PRIVATE)) { return null; } if ($param->type === null) { diff --git a/rules/Php82/Rector/Class_/ReadOnlyClassRector.php b/rules/Php82/Rector/Class_/ReadOnlyClassRector.php index d5f0a099176..2a8d79501ed 100644 --- a/rules/Php82/Rector/Class_/ReadOnlyClassRector.php +++ b/rules/Php82/Rector/Class_/ReadOnlyClassRector.php @@ -16,14 +16,14 @@ use Rector\Core\ValueObject\Visibility; use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer; use Rector\Privatization\NodeManipulator\VisibilityManipulator; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/readonly_classes * * @see \Rector\Tests\Php82\Rector\Class_\ReadOnlyClassRector\ReadOnlyClassRectorTest */ -final class ReadOnlyClassRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ReadOnlyClassRector extends AbstractRector implements MinPhpVersionInterface { /** * @var string @@ -44,15 +44,15 @@ final class ReadOnlyClassRector extends \Rector\Core\Rector\AbstractRector imple * @var \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer */ private $phpAttributeAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer, \Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator, \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer $phpAttributeAnalyzer) + public function __construct(ClassAnalyzer $classAnalyzer, VisibilityManipulator $visibilityManipulator, PhpAttributeAnalyzer $phpAttributeAnalyzer) { $this->classAnalyzer = $classAnalyzer; $this->visibilityManipulator = $visibilityManipulator; $this->phpAttributeAnalyzer = $phpAttributeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Decorate read-only class with `readonly` attribute', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Decorate read-only class with `readonly` attribute', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function __construct( @@ -77,19 +77,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } $this->visibilityManipulator->makeReadonly($node); - $constructClassMethod = $node->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if ($constructClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $constructClassMethod = $node->getMethod(MethodName::CONSTRUCT); + if ($constructClassMethod instanceof ClassMethod) { foreach ($constructClassMethod->getParams() as $param) { $this->visibilityManipulator->removeReadonly($param); } @@ -101,9 +101,9 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::READONLY_CLASS; + return PhpVersionFeature::READONLY_CLASS; } - private function shouldSkip(\PhpParser\Node\Stmt\Class_ $class) : bool + private function shouldSkip(Class_ $class) : bool { if ($this->shouldSkipClass($class)) { return \true; @@ -118,8 +118,8 @@ CODE_SAMPLE return \true; } } - $constructClassMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$constructClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $constructClassMethod = $class->getMethod(MethodName::CONSTRUCT); + if (!$constructClassMethod instanceof ClassMethod) { // no __construct means no property promotion, skip if class has no property defined return $properties === []; } @@ -142,10 +142,10 @@ CODE_SAMPLE } return \false; } - private function shouldSkipClass(\PhpParser\Node\Stmt\Class_ $class) : bool + private function shouldSkipClass(Class_ $class) : bool { // need to have test fixture once feature added to nikic/PHP-Parser - if ($this->visibilityManipulator->hasVisibility($class, \Rector\Core\ValueObject\Visibility::READONLY)) { + if ($this->visibilityManipulator->hasVisibility($class, Visibility::READONLY)) { return \true; } if ($this->classAnalyzer->isAnonymousClass($class)) { @@ -163,7 +163,7 @@ CODE_SAMPLE { foreach ($params as $param) { // has non-property promotion, skip - if (!$this->visibilityManipulator->hasVisibility($param, \Rector\Core\ValueObject\Visibility::READONLY)) { + if (!$this->visibilityManipulator->hasVisibility($param, Visibility::READONLY)) { return \true; } // type is missing, invalid syntax diff --git a/rules/Privatization/Guard/ParentPropertyLookupGuard.php b/rules/Privatization/Guard/ParentPropertyLookupGuard.php index 829961cefe7..45bc2290894 100644 --- a/rules/Privatization/Guard/ParentPropertyLookupGuard.php +++ b/rules/Privatization/Guard/ParentPropertyLookupGuard.php @@ -44,7 +44,7 @@ final class ParentPropertyLookupGuard * @var \Rector\Core\PhpParser\AstResolver */ private $astResolver; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \Rector\Core\PhpParser\AstResolver $astResolver) + public function __construct(BetterNodeFinder $betterNodeFinder, ReflectionResolver $reflectionResolver, NodeNameResolver $nodeNameResolver, PropertyFetchAnalyzer $propertyFetchAnalyzer, AstResolver $astResolver) { $this->betterNodeFinder = $betterNodeFinder; $this->reflectionResolver = $reflectionResolver; @@ -52,17 +52,17 @@ final class ParentPropertyLookupGuard $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; $this->astResolver = $astResolver; } - public function isLegal(\PhpParser\Node\Stmt\Property $property) : bool + public function isLegal(Property $property) : bool { - $class = $this->betterNodeFinder->findParentType($property, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($property, Class_::class); + if (!$class instanceof Class_) { return \false; } if ($class->extends === null) { return \true; } $classReflection = $this->reflectionResolver->resolveClassReflection($property); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } $propertyName = $this->nodeNameResolver->getName($property); @@ -82,10 +82,10 @@ final class ParentPropertyLookupGuard } return \true; } - private function isFoundInParentClassMethods(\PHPStan\Reflection\ClassReflection $parentClassReflection, string $propertyName, string $className) : bool + private function isFoundInParentClassMethods(ClassReflection $parentClassReflection, string $propertyName, string $className) : bool { $classLike = $this->astResolver->resolveClassFromName($parentClassReflection->getName()); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + if (!$classLike instanceof Class_) { return \false; } $methods = $classLike->getMethods(); @@ -102,13 +102,13 @@ final class ParentPropertyLookupGuard */ private function isFoundInMethodStmts(array $stmts, string $propertyName, string $className) : bool { - return (bool) $this->betterNodeFinder->findFirst($stmts, function (\PhpParser\Node $subNode) use($propertyName, $className) : bool { + return (bool) $this->betterNodeFinder->findFirst($stmts, function (Node $subNode) use($propertyName, $className) : bool { if (!$this->propertyFetchAnalyzer->isPropertyFetch($subNode)) { return \false; } /** @var PropertyFetch|StaticPropertyFetch $subNode */ - if ($subNode instanceof \PhpParser\Node\Expr\PropertyFetch) { - if (!$subNode->var instanceof \PhpParser\Node\Expr\Variable) { + if ($subNode instanceof PropertyFetch) { + if (!$subNode->var instanceof Variable) { return \false; } if (!$this->nodeNameResolver->isName($subNode->var, 'this')) { @@ -116,7 +116,7 @@ final class ParentPropertyLookupGuard } return $this->nodeNameResolver->isName($subNode, $propertyName); } - if (!$this->nodeNameResolver->isNames($subNode->class, [\Rector\Core\Enum\ObjectReference::SELF, \Rector\Core\Enum\ObjectReference::STATIC, $className])) { + if (!$this->nodeNameResolver->isNames($subNode->class, [ObjectReference::SELF, ObjectReference::STATIC, $className])) { return \false; } return $this->nodeNameResolver->isName($subNode->name, $propertyName); diff --git a/rules/Privatization/Naming/ConstantNaming.php b/rules/Privatization/Naming/ConstantNaming.php index 3511bd7b7d3..047bb8a94ed 100644 --- a/rules/Privatization/Naming/ConstantNaming.php +++ b/rules/Privatization/Naming/ConstantNaming.php @@ -14,7 +14,7 @@ final class ConstantNaming * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } @@ -30,7 +30,7 @@ final class ConstantNaming /** * @return string|null */ - public function createFromVariable(\PhpParser\Node\Expr\Variable $variable) + public function createFromVariable(Variable $variable) { $variableName = $this->nodeNameResolver->getName($variable); if ($variableName === null) { @@ -40,7 +40,7 @@ final class ConstantNaming } private function createUnderscoreUppercaseString(string $propertyName) : string { - $propertyNameUnicodeString = new \RectorPrefix20220607\Symfony\Component\String\UnicodeString($propertyName); + $propertyNameUnicodeString = new UnicodeString($propertyName); return $propertyNameUnicodeString->snake()->upper()->toString(); } } diff --git a/rules/Privatization/NodeAnalyzer/PropertyFetchByMethodAnalyzer.php b/rules/Privatization/NodeAnalyzer/PropertyFetchByMethodAnalyzer.php index 45909976b2b..cb73b0274a9 100644 --- a/rules/Privatization/NodeAnalyzer/PropertyFetchByMethodAnalyzer.php +++ b/rules/Privatization/NodeAnalyzer/PropertyFetchByMethodAnalyzer.php @@ -26,7 +26,7 @@ final class PropertyFetchByMethodAnalyzer /** * @var array> */ - private const SCOPE_CHANGING_NODE_TYPES = [\PhpParser\Node\Stmt\Do_::class, \PhpParser\Node\Stmt\While_::class, \PhpParser\Node\Stmt\If_::class, \PhpParser\Node\Stmt\Else_::class]; + private const SCOPE_CHANGING_NODE_TYPES = [Do_::class, While_::class, If_::class, Else_::class]; /** * @readonly * @var \Rector\NodeNameResolver\NodeNameResolver @@ -42,7 +42,7 @@ final class PropertyFetchByMethodAnalyzer * @var \Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser */ private $simpleCallableNodeTraverser; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser) + public function __construct(NodeNameResolver $nodeNameResolver, PropertyFetchAnalyzer $propertyFetchAnalyzer, SimpleCallableNodeTraverser $simpleCallableNodeTraverser) { $this->nodeNameResolver = $nodeNameResolver; $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; @@ -52,7 +52,7 @@ final class PropertyFetchByMethodAnalyzer * @param string[] $propertyNames * @return array */ - public function collectPropertyFetchByMethods(\PhpParser\Node\Stmt\Class_ $class, array $propertyNames) : array + public function collectPropertyFetchByMethods(Class_ $class, array $propertyNames) : array { $propertyUsageByMethods = []; foreach ($propertyNames as $propertyName) { @@ -76,24 +76,24 @@ final class PropertyFetchByMethodAnalyzer } return $propertyUsageByMethods; } - private function isContainsLocalPropertyFetchNameOrPropertyChangingInMultipleMethodCalls(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $propertyName) : bool + private function isContainsLocalPropertyFetchNameOrPropertyChangingInMultipleMethodCalls(ClassMethod $classMethod, string $propertyName) : bool { if (!$this->propertyFetchAnalyzer->containsLocalPropertyFetchName($classMethod, $propertyName)) { return \true; } return $this->isPropertyChangingInMultipleMethodCalls($classMethod, $propertyName); } - private function isPropertyWithDefaultValue(\PhpParser\Node\Stmt\Class_ $class, string $propertyName) : bool + private function isPropertyWithDefaultValue(Class_ $class, string $propertyName) : bool { $property = $class->getProperty($propertyName); - if (!$property instanceof \PhpParser\Node\Stmt\Property) { + if (!$property instanceof Property) { return \false; } - return $property->props[0]->default instanceof \PhpParser\Node\Expr; + return $property->props[0]->default instanceof Expr; } - private function isInConstructWithPropertyChanging(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $propertyName) : bool + private function isInConstructWithPropertyChanging(ClassMethod $classMethod, string $propertyName) : bool { - if (!$this->nodeNameResolver->isName($classMethod, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if (!$this->nodeNameResolver->isName($classMethod, MethodName::CONSTRUCT)) { return \false; } return $this->isPropertyChanging($classMethod, $propertyName); @@ -101,18 +101,18 @@ final class PropertyFetchByMethodAnalyzer /** * Covers https://github.com/rectorphp/rector/pull/2558#discussion_r363036110 */ - private function isPropertyChangingInMultipleMethodCalls(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $propertyName) : bool + private function isPropertyChangingInMultipleMethodCalls(ClassMethod $classMethod, string $propertyName) : bool { $isPropertyChanging = \false; $isPropertyReadInIf = \false; $isIfFollowedByAssign = \false; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->getStmts(), function (\PhpParser\Node $node) use(&$isPropertyChanging, $propertyName, &$isPropertyReadInIf, &$isIfFollowedByAssign) : ?int { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->getStmts(), function (Node $node) use(&$isPropertyChanging, $propertyName, &$isPropertyReadInIf, &$isIfFollowedByAssign) : ?int { if ($isPropertyReadInIf) { if (!$this->propertyFetchAnalyzer->isLocalPropertyOfNames($node, [$propertyName])) { return null; } - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentNode instanceof \PhpParser\Node\Expr\Assign && $parentNode->var === $node) { + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); + if ($parentNode instanceof Assign && $parentNode->var === $node) { $isIfFollowedByAssign = \true; } } @@ -124,18 +124,18 @@ final class PropertyFetchByMethodAnalyzer if (!$isPropertyChanging) { return null; } - return \PhpParser\NodeTraverser::STOP_TRAVERSAL; + return NodeTraverser::STOP_TRAVERSAL; }); return $isPropertyChanging || $isIfFollowedByAssign || $isPropertyReadInIf; } - private function isPropertyReadInNode(bool $isPropertyReadInIf, \PhpParser\Node $node, string $propertyName) : bool + private function isPropertyReadInNode(bool $isPropertyReadInIf, Node $node, string $propertyName) : bool { - if ($node instanceof \PhpParser\Node\Stmt\If_) { + if ($node instanceof If_) { return $this->isPropertyReadInIf($node, $propertyName); } return $isPropertyReadInIf; } - private function isScopeChangingNode(\PhpParser\Node $node) : bool + private function isScopeChangingNode(Node $node) : bool { foreach (self::SCOPE_CHANGING_NODE_TYPES as $type) { if (\is_a($node, $type, \true)) { @@ -144,34 +144,34 @@ final class PropertyFetchByMethodAnalyzer } return \false; } - private function isPropertyReadInIf(\PhpParser\Node\Stmt\If_ $if, string $propertyName) : bool + private function isPropertyReadInIf(If_ $if, string $propertyName) : bool { $isPropertyReadInIf = \false; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($if->cond, function (\PhpParser\Node $node) use($propertyName, &$isPropertyReadInIf) : ?int { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($if->cond, function (Node $node) use($propertyName, &$isPropertyReadInIf) : ?int { if (!$this->propertyFetchAnalyzer->isLocalPropertyOfNames($node, [$propertyName])) { return null; } $isPropertyReadInIf = \true; - return \PhpParser\NodeTraverser::STOP_TRAVERSAL; + return NodeTraverser::STOP_TRAVERSAL; }); return $isPropertyReadInIf; } - private function isPropertyChanging(\PhpParser\Node $node, string $privatePropertyName) : bool + private function isPropertyChanging(Node $node, string $privatePropertyName) : bool { $isPropertyChanging = \false; // here cannot be any property assign - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($node, function (\PhpParser\Node $node) use(&$isPropertyChanging, $privatePropertyName) : ?int { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($node, function (Node $node) use(&$isPropertyChanging, $privatePropertyName) : ?int { + if (!$node instanceof Assign) { return null; } - if (!$node->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$node->var instanceof PropertyFetch) { return null; } if (!$this->nodeNameResolver->isName($node->var->name, $privatePropertyName)) { return null; } $isPropertyChanging = \true; - return \PhpParser\NodeTraverser::STOP_TRAVERSAL; + return NodeTraverser::STOP_TRAVERSAL; }); return $isPropertyChanging; } diff --git a/rules/Privatization/NodeFactory/ClassConstantFactory.php b/rules/Privatization/NodeFactory/ClassConstantFactory.php index f471558b1e6..3fd05c05b0f 100644 --- a/rules/Privatization/NodeFactory/ClassConstantFactory.php +++ b/rules/Privatization/NodeFactory/ClassConstantFactory.php @@ -23,23 +23,23 @@ final class ClassConstantFactory * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory */ private $phpDocInfoFactory; - public function __construct(\Rector\Privatization\Naming\ConstantNaming $constantNaming, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory) + public function __construct(ConstantNaming $constantNaming, PhpDocInfoFactory $phpDocInfoFactory) { $this->constantNaming = $constantNaming; $this->phpDocInfoFactory = $phpDocInfoFactory; } - public function createFromProperty(\PhpParser\Node\Stmt\Property $property) : \PhpParser\Node\Stmt\ClassConst + public function createFromProperty(Property $property) : ClassConst { $propertyProperty = $property->props[0]; $constantName = $this->constantNaming->createFromProperty($propertyProperty); /** @var Expr $defaultValue */ $defaultValue = $propertyProperty->default; - $const = new \PhpParser\Node\Const_($constantName, $defaultValue); - $classConst = new \PhpParser\Node\Stmt\ClassConst([$const]); - $classConst->flags = $property->flags & ~\PhpParser\Node\Stmt\Class_::MODIFIER_STATIC; + $const = new Const_($constantName, $defaultValue); + $classConst = new ClassConst([$const]); + $classConst->flags = $property->flags & ~Class_::MODIFIER_STATIC; $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); $phpDocInfo->markAsChanged(); - $classConst->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $phpDocInfo); + $classConst->setAttribute(AttributeKey::PHP_DOC_INFO, $phpDocInfo); return $classConst; } } diff --git a/rules/Privatization/NodeFactory/ClassConstantFetchValueFactory.php b/rules/Privatization/NodeFactory/ClassConstantFetchValueFactory.php index f0b4f326e16..df27981b536 100644 --- a/rules/Privatization/NodeFactory/ClassConstantFetchValueFactory.php +++ b/rules/Privatization/NodeFactory/ClassConstantFetchValueFactory.php @@ -25,7 +25,7 @@ final class ClassConstantFetchValueFactory * @var \Rector\Privatization\Reflection\ClassConstantsResolver */ private $classConstantsResolver; - public function __construct(\Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\Privatization\Reflection\ClassConstantsResolver $classConstantsResolver) + public function __construct(ValueResolver $valueResolver, NodeFactory $nodeFactory, ClassConstantsResolver $classConstantsResolver) { $this->valueResolver = $valueResolver; $this->nodeFactory = $nodeFactory; @@ -34,7 +34,7 @@ final class ClassConstantFetchValueFactory /** * @param class-string $classWithConstants */ - public function create(\PhpParser\Node\Expr $expr, string $classWithConstants, bool $caseInsensitive) : ?\PhpParser\Node\Expr\ClassConstFetch + public function create(Expr $expr, string $classWithConstants, bool $caseInsensitive) : ?ClassConstFetch { $value = $this->valueResolver->getValue($expr); if ($value === null) { diff --git a/rules/Privatization/NodeManipulator/VisibilityManipulator.php b/rules/Privatization/NodeManipulator/VisibilityManipulator.php index 0f5a331e892..accf3435e65 100644 --- a/rules/Privatization/NodeManipulator/VisibilityManipulator.php +++ b/rules/Privatization/NodeManipulator/VisibilityManipulator.php @@ -27,14 +27,14 @@ final class VisibilityManipulator */ public function makeStatic($node) : void { - $this->addVisibilityFlag($node, \Rector\Core\ValueObject\Visibility::STATIC); + $this->addVisibilityFlag($node, Visibility::STATIC); } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Class_ $node */ public function makeAbstract($node) : void { - $this->addVisibilityFlag($node, \Rector\Core\ValueObject\Visibility::ABSTRACT); + $this->addVisibilityFlag($node, Visibility::ABSTRACT); } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property $node @@ -44,14 +44,14 @@ final class VisibilityManipulator if (!$node->isStatic()) { return; } - $node->flags -= \PhpParser\Node\Stmt\Class_::MODIFIER_STATIC; + $node->flags -= Class_::MODIFIER_STATIC; } /** * @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\ClassConst $node */ public function makeFinal($node) : void { - $this->addVisibilityFlag($node, \Rector\Core\ValueObject\Visibility::FINAL); + $this->addVisibilityFlag($node, Visibility::FINAL); } /** * @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\ClassMethod $node @@ -61,7 +61,7 @@ final class VisibilityManipulator if (!$node->isFinal()) { return; } - $node->flags -= \PhpParser\Node\Stmt\Class_::MODIFIER_FINAL; + $node->flags -= Class_::MODIFIER_FINAL; } /** * This way "abstract", "static", "final" are kept @@ -74,13 +74,13 @@ final class VisibilityManipulator return; } if ($node->isPublic()) { - $node->flags -= \PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC; + $node->flags -= Class_::MODIFIER_PUBLIC; } if ($node->isProtected()) { - $node->flags -= \PhpParser\Node\Stmt\Class_::MODIFIER_PROTECTED; + $node->flags -= Class_::MODIFIER_PROTECTED; } if ($node->isPrivate()) { - $node->flags -= \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE; + $node->flags -= Class_::MODIFIER_PRIVATE; } } /** @@ -88,7 +88,7 @@ final class VisibilityManipulator */ public function changeNodeVisibility($node, int $visibility) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::oneOf($visibility, [\Rector\Core\ValueObject\Visibility::PUBLIC, \Rector\Core\ValueObject\Visibility::PROTECTED, \Rector\Core\ValueObject\Visibility::PRIVATE, \Rector\Core\ValueObject\Visibility::STATIC, \Rector\Core\ValueObject\Visibility::ABSTRACT, \Rector\Core\ValueObject\Visibility::FINAL]); + Assert::oneOf($visibility, [Visibility::PUBLIC, Visibility::PROTECTED, Visibility::PRIVATE, Visibility::STATIC, Visibility::ABSTRACT, Visibility::FINAL]); $this->replaceVisibilityFlag($node, $visibility); } /** @@ -96,53 +96,53 @@ final class VisibilityManipulator */ public function makePublic($node) : void { - $this->replaceVisibilityFlag($node, \Rector\Core\ValueObject\Visibility::PUBLIC); + $this->replaceVisibilityFlag($node, Visibility::PUBLIC); } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassConst $node */ public function makeProtected($node) : void { - $this->replaceVisibilityFlag($node, \Rector\Core\ValueObject\Visibility::PROTECTED); + $this->replaceVisibilityFlag($node, Visibility::PROTECTED); } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassConst $node */ public function makePrivate($node) : void { - $this->replaceVisibilityFlag($node, \Rector\Core\ValueObject\Visibility::PRIVATE); + $this->replaceVisibilityFlag($node, Visibility::PRIVATE); } /** * @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\ClassConst $node */ public function removeFinal($node) : void { - $node->flags -= \PhpParser\Node\Stmt\Class_::MODIFIER_FINAL; + $node->flags -= Class_::MODIFIER_FINAL; } - public function removeAbstract(\PhpParser\Node\Stmt\ClassMethod $classMethod) : void + public function removeAbstract(ClassMethod $classMethod) : void { - $classMethod->flags -= \PhpParser\Node\Stmt\Class_::MODIFIER_ABSTRACT; + $classMethod->flags -= Class_::MODIFIER_ABSTRACT; } /** * @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $node */ public function makeReadonly($node) : void { - $this->addVisibilityFlag($node, \Rector\Core\ValueObject\Visibility::READONLY); + $this->addVisibilityFlag($node, Visibility::READONLY); } /** * @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $node */ public function isReadonly($node) : bool { - return $this->hasVisibility($node, \Rector\Core\ValueObject\Visibility::READONLY); + return $this->hasVisibility($node, Visibility::READONLY); } /** * @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $node */ public function removeReadonly($node) : void { - $this->removeVisibilityFlag($node, \Rector\Core\ValueObject\Visibility::READONLY); + $this->removeVisibilityFlag($node, Visibility::READONLY); } /** * @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassConst|\PhpParser\Node\Param $node @@ -163,11 +163,11 @@ final class VisibilityManipulator */ private function replaceVisibilityFlag($node, int $visibility) : void { - $isStatic = $node instanceof \PhpParser\Node\Stmt\ClassMethod && $node->isStatic(); + $isStatic = $node instanceof ClassMethod && $node->isStatic(); if ($isStatic) { $this->makeNonStatic($node); } - if ($visibility !== \Rector\Core\ValueObject\Visibility::STATIC && $visibility !== \Rector\Core\ValueObject\Visibility::ABSTRACT && $visibility !== \Rector\Core\ValueObject\Visibility::FINAL) { + if ($visibility !== Visibility::STATIC && $visibility !== Visibility::ABSTRACT && $visibility !== Visibility::FINAL) { $this->removeVisibility($node); } $this->addVisibilityFlag($node, $visibility); diff --git a/rules/Privatization/NodeReplacer/PropertyFetchWithConstFetchReplacer.php b/rules/Privatization/NodeReplacer/PropertyFetchWithConstFetchReplacer.php index cb6e0c4d088..f83f577d9bc 100644 --- a/rules/Privatization/NodeReplacer/PropertyFetchWithConstFetchReplacer.php +++ b/rules/Privatization/NodeReplacer/PropertyFetchWithConstFetchReplacer.php @@ -41,7 +41,7 @@ final class PropertyFetchWithConstFetchReplacer * @var \Rector\Core\PhpParser\Node\NodeFactory */ private $nodeFactory; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \Rector\Privatization\Naming\ConstantNaming $constantNaming, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory) + public function __construct(NodeNameResolver $nodeNameResolver, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, PropertyFetchAnalyzer $propertyFetchAnalyzer, ConstantNaming $constantNaming, NodeFactory $nodeFactory) { $this->nodeNameResolver = $nodeNameResolver; $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; @@ -49,12 +49,12 @@ final class PropertyFetchWithConstFetchReplacer $this->constantNaming = $constantNaming; $this->nodeFactory = $nodeFactory; } - public function replace(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\Property $property) : void + public function replace(Class_ $class, Property $property) : void { $propertyProperty = $property->props[0]; $propertyName = $this->nodeNameResolver->getName($property); $constantName = $this->constantNaming->createFromProperty($propertyProperty); - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($class, function (\PhpParser\Node $node) use($propertyName, $constantName) : ?ClassConstFetch { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($class, function (Node $node) use($propertyName, $constantName) : ?ClassConstFetch { if (!$this->propertyFetchAnalyzer->isLocalPropertyFetch($node)) { return null; } diff --git a/rules/Privatization/NodeReplacer/PropertyFetchWithVariableReplacer.php b/rules/Privatization/NodeReplacer/PropertyFetchWithVariableReplacer.php index b7f6dcc8ee4..0f6fc683868 100644 --- a/rules/Privatization/NodeReplacer/PropertyFetchWithVariableReplacer.php +++ b/rules/Privatization/NodeReplacer/PropertyFetchWithVariableReplacer.php @@ -22,7 +22,7 @@ final class PropertyFetchWithVariableReplacer * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->nodeNameResolver = $nodeNameResolver; @@ -30,22 +30,22 @@ final class PropertyFetchWithVariableReplacer /** * @param array $methodsByPropertyName */ - public function replacePropertyFetchesByVariable(\PhpParser\Node\Stmt\Class_ $class, array $methodsByPropertyName) : void + public function replacePropertyFetchesByVariable(Class_ $class, array $methodsByPropertyName) : void { foreach ($methodsByPropertyName as $propertyName => $methodNames) { $methodName = $methodNames[0]; $classMethod = $class->getMethod($methodName); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$classMethod instanceof ClassMethod) { continue; } - $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->getStmts(), function (\PhpParser\Node $node) use($propertyName) : ?Variable { - if (!$node instanceof \PhpParser\Node\Expr\PropertyFetch) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->getStmts(), function (Node $node) use($propertyName) : ?Variable { + if (!$node instanceof PropertyFetch) { return null; } if (!$this->nodeNameResolver->isName($node, $propertyName)) { return null; } - return new \PhpParser\Node\Expr\Variable($propertyName); + return new Variable($propertyName); }); } } diff --git a/rules/Privatization/Rector/ClassMethod/PrivatizeFinalClassMethodRector.php b/rules/Privatization/Rector/ClassMethod/PrivatizeFinalClassMethodRector.php index a065f12e786..a66466c8d01 100644 --- a/rules/Privatization/Rector/ClassMethod/PrivatizeFinalClassMethodRector.php +++ b/rules/Privatization/Rector/ClassMethod/PrivatizeFinalClassMethodRector.php @@ -10,12 +10,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; use Rector\Privatization\NodeManipulator\VisibilityManipulator; use Rector\Privatization\VisibilityGuard\ClassMethodVisibilityGuard; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Privatization\Rector\ClassMethod\PrivatizeFinalClassMethodRector\PrivatizeFinalClassMethodRectorTest */ -final class PrivatizeFinalClassMethodRector extends \Rector\Core\Rector\AbstractRector +final class PrivatizeFinalClassMethodRector extends AbstractRector { /** * @readonly @@ -32,15 +32,15 @@ final class PrivatizeFinalClassMethodRector extends \Rector\Core\Rector\Abstract * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Privatization\VisibilityGuard\ClassMethodVisibilityGuard $classMethodVisibilityGuard, \Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(ClassMethodVisibilityGuard $classMethodVisibilityGuard, VisibilityManipulator $visibilityManipulator, ReflectionResolver $reflectionResolver) { $this->classMethodVisibilityGuard = $classMethodVisibilityGuard; $this->visibilityManipulator = $visibilityManipulator; $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change protected class method to private if possible', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change protected class method to private if possible', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { protected function someMethod() @@ -63,15 +63,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $classReflection = $this->reflectionResolver->resolveClassReflection($node); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return null; } if (!$classReflection->isClass()) { @@ -92,7 +92,7 @@ CODE_SAMPLE $this->visibilityManipulator->makePrivate($node); return $node; } - private function shouldSkipClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkipClassMethod(ClassMethod $classMethod) : bool { if ($this->isName($classMethod, 'createComponent*')) { return \true; diff --git a/rules/Privatization/Rector/Class_/ChangeGlobalVariablesToPropertiesRector.php b/rules/Privatization/Rector/Class_/ChangeGlobalVariablesToPropertiesRector.php index 04eac29a439..477a59e4e21 100644 --- a/rules/Privatization/Rector/Class_/ChangeGlobalVariablesToPropertiesRector.php +++ b/rules/Privatization/Rector/Class_/ChangeGlobalVariablesToPropertiesRector.php @@ -13,15 +13,15 @@ use PhpParser\Node\Stmt\Global_; use PhpParser\NodeTraverser; use Rector\Core\Rector\AbstractRector; use Rector\PostRector\Collector\PropertyToAddCollector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/DWC4P * * @changelog https://stackoverflow.com/a/12446305/1348344 * @see \Rector\Tests\Privatization\Rector\Class_\ChangeGlobalVariablesToPropertiesRector\ChangeGlobalVariablesToPropertiesRectorTest */ -final class ChangeGlobalVariablesToPropertiesRector extends \Rector\Core\Rector\AbstractRector +final class ChangeGlobalVariablesToPropertiesRector extends AbstractRector { /** * @var string[] @@ -32,13 +32,13 @@ final class ChangeGlobalVariablesToPropertiesRector extends \Rector\Core\Rector\ * @var \Rector\PostRector\Collector\PropertyToAddCollector */ private $propertyToAddCollector; - public function __construct(\Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector) + public function __construct(PropertyToAddCollector $propertyToAddCollector) { $this->propertyToAddCollector = $propertyToAddCollector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change global $variables to private properties', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change global $variables to private properties', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function go() @@ -76,12 +76,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($node->getMethods() as $classMethod) { $this->collectGlobalVariableNamesAndRefactorToPropertyFetch($node, $classMethod); @@ -94,21 +94,21 @@ CODE_SAMPLE } return $node; } - private function collectGlobalVariableNamesAndRefactorToPropertyFetch(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function collectGlobalVariableNamesAndRefactorToPropertyFetch(Class_ $class, ClassMethod $classMethod) : void { $this->globalVariableNames = []; - $this->traverseNodesWithCallable($classMethod, function (\PhpParser\Node $node) use($class) { - if ($node instanceof \PhpParser\Node\Stmt\Global_) { + $this->traverseNodesWithCallable($classMethod, function (Node $node) use($class) { + if ($node instanceof Global_) { $this->refactorGlobal($class, $node); - return \PhpParser\NodeTraverser::DONT_TRAVERSE_CHILDREN; + return NodeTraverser::DONT_TRAVERSE_CHILDREN; } - if ($node instanceof \PhpParser\Node\Expr\Variable) { + if ($node instanceof Variable) { return $this->refactorGlobalVariable($node); } return null; }); } - private function refactorGlobal(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\Global_ $global) : void + private function refactorGlobal(Class_ $class, Global_ $global) : void { foreach ($global->vars as $var) { $varName = $this->getName($var); @@ -122,7 +122,7 @@ CODE_SAMPLE } $this->removeNode($global); } - private function refactorGlobalVariable(\PhpParser\Node\Expr\Variable $variable) : ?\PhpParser\Node\Expr\PropertyFetch + private function refactorGlobalVariable(Variable $variable) : ?PropertyFetch { if (!$this->isNames($variable, $this->globalVariableNames)) { return null; @@ -134,19 +134,19 @@ CODE_SAMPLE } return $this->nodeFactory->createPropertyFetch('this', $variableName); } - private function isReadOnly(\PhpParser\Node\Stmt\Class_ $class, string $globalVariableName) : bool + private function isReadOnly(Class_ $class, string $globalVariableName) : bool { /** @var ClassMethod[] $classMethods */ - $classMethods = $this->betterNodeFinder->findInstanceOf($class, \PhpParser\Node\Stmt\ClassMethod::class); + $classMethods = $this->betterNodeFinder->findInstanceOf($class, ClassMethod::class); foreach ($classMethods as $classMethod) { - $isReAssign = (bool) $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (\PhpParser\Node $node) use($globalVariableName) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + $isReAssign = (bool) $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (Node $node) use($globalVariableName) : bool { + if (!$node instanceof Assign) { return \false; } - if ($node->var instanceof \PhpParser\Node\Expr\Variable) { + if ($node->var instanceof Variable) { return $this->nodeNameResolver->isName($node->var, $globalVariableName); } - if ($node->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if ($node->var instanceof PropertyFetch) { return $this->nodeNameResolver->isName($node->var, $globalVariableName); } return \false; diff --git a/rules/Privatization/Rector/Class_/ChangeLocalPropertyToVariableRector.php b/rules/Privatization/Rector/Class_/ChangeLocalPropertyToVariableRector.php index 10cc396cddf..eb7ade2cb17 100644 --- a/rules/Privatization/Rector/Class_/ChangeLocalPropertyToVariableRector.php +++ b/rules/Privatization/Rector/Class_/ChangeLocalPropertyToVariableRector.php @@ -10,12 +10,12 @@ use Rector\Core\NodeManipulator\ClassManipulator; use Rector\Core\Rector\AbstractRector; use Rector\Privatization\NodeAnalyzer\PropertyFetchByMethodAnalyzer; use Rector\Privatization\NodeReplacer\PropertyFetchWithVariableReplacer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Privatization\Rector\Class_\ChangeLocalPropertyToVariableRector\ChangeLocalPropertyToVariableRectorTest */ -final class ChangeLocalPropertyToVariableRector extends \Rector\Core\Rector\AbstractRector +final class ChangeLocalPropertyToVariableRector extends AbstractRector { /** * @readonly @@ -37,16 +37,16 @@ final class ChangeLocalPropertyToVariableRector extends \Rector\Core\Rector\Abst * @var \Rector\Core\NodeAnalyzer\ClassAnalyzer */ private $classAnalyzer; - public function __construct(\Rector\Core\NodeManipulator\ClassManipulator $classManipulator, \Rector\Privatization\NodeReplacer\PropertyFetchWithVariableReplacer $propertyFetchWithVariableReplacer, \Rector\Privatization\NodeAnalyzer\PropertyFetchByMethodAnalyzer $propertyFetchByMethodAnalyzer, \Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer) + public function __construct(ClassManipulator $classManipulator, PropertyFetchWithVariableReplacer $propertyFetchWithVariableReplacer, PropertyFetchByMethodAnalyzer $propertyFetchByMethodAnalyzer, ClassAnalyzer $classAnalyzer) { $this->classManipulator = $classManipulator; $this->propertyFetchWithVariableReplacer = $propertyFetchWithVariableReplacer; $this->propertyFetchByMethodAnalyzer = $propertyFetchByMethodAnalyzer; $this->classAnalyzer = $classAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change local property used in single method to local variable', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change local property used in single method to local variable', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { private $count; @@ -74,12 +74,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->classAnalyzer->isAnonymousClass($node)) { return null; diff --git a/rules/Privatization/Rector/Class_/ChangeReadOnlyVariableWithDefaultValueToConstantRector.php b/rules/Privatization/Rector/Class_/ChangeReadOnlyVariableWithDefaultValueToConstantRector.php index 85846b92434..465b385d914 100644 --- a/rules/Privatization/Rector/Class_/ChangeReadOnlyVariableWithDefaultValueToConstantRector.php +++ b/rules/Privatization/Rector/Class_/ChangeReadOnlyVariableWithDefaultValueToConstantRector.php @@ -20,12 +20,12 @@ use Rector\Core\NodeManipulator\ClassMethodAssignManipulator; use Rector\Core\Rector\AbstractRector; use Rector\PostRector\Collector\PropertyToAddCollector; use Rector\Privatization\Naming\ConstantNaming; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Privatization\Rector\Class_\ChangeReadOnlyVariableWithDefaultValueToConstantRector\ChangeReadOnlyVariableWithDefaultValueToConstantRectorTest */ -final class ChangeReadOnlyVariableWithDefaultValueToConstantRector extends \Rector\Core\Rector\AbstractRector +final class ChangeReadOnlyVariableWithDefaultValueToConstantRector extends AbstractRector { /** * @readonly @@ -47,16 +47,16 @@ final class ChangeReadOnlyVariableWithDefaultValueToConstantRector extends \Rect * @var \Rector\Privatization\Naming\ConstantNaming */ private $constantNaming; - public function __construct(\Rector\Core\NodeManipulator\ClassMethodAssignManipulator $classMethodAssignManipulator, \Rector\BetterPhpDocParser\PhpDocManipulator\VarAnnotationManipulator $varAnnotationManipulator, \Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector, \Rector\Privatization\Naming\ConstantNaming $constantNaming) + public function __construct(ClassMethodAssignManipulator $classMethodAssignManipulator, VarAnnotationManipulator $varAnnotationManipulator, PropertyToAddCollector $propertyToAddCollector, ConstantNaming $constantNaming) { $this->classMethodAssignManipulator = $classMethodAssignManipulator; $this->varAnnotationManipulator = $varAnnotationManipulator; $this->propertyToAddCollector = $propertyToAddCollector; $this->constantNaming = $constantNaming; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change variable with read only status with default value to constant', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change variable with read only status with default value to constant', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -96,12 +96,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $readOnlyVariableAssigns = $this->collectReadOnlyVariableAssigns($node); $readOnlyVariableAssigns = $this->filterOutUniqueNames($readOnlyVariableAssigns); @@ -109,14 +109,14 @@ CODE_SAMPLE return null; } foreach ($readOnlyVariableAssigns as $readOnlyVariableAssign) { - $classMethod = $this->betterNodeFinder->findParentType($readOnlyVariableAssign, \PhpParser\Node\Stmt\ClassMethod::class); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $classMethod = $this->betterNodeFinder->findParentType($readOnlyVariableAssign, ClassMethod::class); + if (!$classMethod instanceof ClassMethod) { + throw new ShouldNotHappenException(); } $methodName = $this->getName($classMethod); $classMethod = $node->getMethod($methodName); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$classMethod instanceof ClassMethod) { + throw new ShouldNotHappenException(); } $this->refactorClassMethod($classMethod, $node, $readOnlyVariableAssigns); } @@ -125,7 +125,7 @@ CODE_SAMPLE /** * @return Assign[] */ - private function collectReadOnlyVariableAssigns(\PhpParser\Node\Stmt\Class_ $class) : array + private function collectReadOnlyVariableAssigns(Class_ $class) : array { $readOnlyVariables = []; foreach ($class->getMethods() as $classMethod) { @@ -171,18 +171,18 @@ CODE_SAMPLE /** * @param Assign[] $readOnlyVariableAssigns */ - private function refactorClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Stmt\Class_ $class, array $readOnlyVariableAssigns) : void + private function refactorClassMethod(ClassMethod $classMethod, Class_ $class, array $readOnlyVariableAssigns) : void { foreach ($readOnlyVariableAssigns as $readOnlyVariableAssign) { /** @var Variable|ClassConstFetch $variable */ $variable = $readOnlyVariableAssign->var; // already overridden - if (!$variable instanceof \PhpParser\Node\Expr\Variable) { + if (!$variable instanceof Variable) { continue; } $variableName = $this->getName($variable); if ($variableName === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } foreach ($classMethod->getParams() as $param) { if ($this->nodeNameResolver->isName($param->var, $variableName)) { @@ -196,7 +196,7 @@ CODE_SAMPLE $this->replaceVariableWithClassConstFetch($classMethod, $variableName, $classConst); } } - private function isFoundByRefParam(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function isFoundByRefParam(ClassMethod $classMethod) : bool { $params = $classMethod->getParams(); foreach ($params as $param) { @@ -206,35 +206,35 @@ CODE_SAMPLE } return \false; } - private function createPrivateClassConst(\PhpParser\Node\Expr\Variable $variable, \PhpParser\Node\Expr $expr) : \PhpParser\Node\Stmt\ClassConst + private function createPrivateClassConst(Variable $variable, Expr $expr) : ClassConst { $constantName = $this->constantNaming->createFromVariable($variable); if ($constantName === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } - $const = new \PhpParser\Node\Const_($constantName, $expr); - $classConst = new \PhpParser\Node\Stmt\ClassConst([$const]); - $classConst->flags = \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE; + $const = new Const_($constantName, $expr); + $classConst = new ClassConst([$const]); + $classConst->flags = Class_::MODIFIER_PRIVATE; $this->mirrorComments($classConst, $variable); $constantType = $this->getType($classConst->consts[0]->value); $this->varAnnotationManipulator->decorateNodeWithType($classConst, $constantType); return $classConst; } - private function replaceVariableWithClassConstFetch(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $variableName, \PhpParser\Node\Stmt\ClassConst $classConst) : void + private function replaceVariableWithClassConstFetch(ClassMethod $classMethod, string $variableName, ClassConst $classConst) : void { $constantName = $this->getName($classConst); if ($constantName === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } - $this->traverseNodesWithCallable($classMethod, function (\PhpParser\Node $node) use($variableName, $constantName) : ?ClassConstFetch { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + $this->traverseNodesWithCallable($classMethod, function (Node $node) use($variableName, $constantName) : ?ClassConstFetch { + if (!$node instanceof Variable) { return null; } if (!$this->nodeNameResolver->isName($node, $variableName)) { return null; } // replace with constant fetch - return new \PhpParser\Node\Expr\ClassConstFetch(new \PhpParser\Node\Name('self'), new \PhpParser\Node\Identifier($constantName)); + return new ClassConstFetch(new Name('self'), new Identifier($constantName)); }); } } diff --git a/rules/Privatization/Rector/Class_/FinalizeClassesWithoutChildrenRector.php b/rules/Privatization/Rector/Class_/FinalizeClassesWithoutChildrenRector.php index f664edd2dd3..eb99ce67f20 100644 --- a/rules/Privatization/Rector/Class_/FinalizeClassesWithoutChildrenRector.php +++ b/rules/Privatization/Rector/Class_/FinalizeClassesWithoutChildrenRector.php @@ -12,12 +12,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; use Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer; use Rector\Privatization\NodeManipulator\VisibilityManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector\FinalizeClassesWithoutChildrenRectorTest */ -final class FinalizeClassesWithoutChildrenRector extends \Rector\Core\Rector\AbstractRector +final class FinalizeClassesWithoutChildrenRector extends AbstractRector { /** * @var string[] @@ -47,16 +47,16 @@ final class FinalizeClassesWithoutChildrenRector extends \Rector\Core\Rector\Abs * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer, \Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer $familyRelationsAnalyzer, \Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(ClassAnalyzer $classAnalyzer, FamilyRelationsAnalyzer $familyRelationsAnalyzer, VisibilityManipulator $visibilityManipulator, ReflectionResolver $reflectionResolver) { $this->classAnalyzer = $classAnalyzer; $this->familyRelationsAnalyzer = $familyRelationsAnalyzer; $this->visibilityManipulator = $visibilityManipulator; $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Finalize every class that has no children', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Finalize every class that has no children', [new CodeSample(<<<'CODE_SAMPLE' class FirstClass { } @@ -89,12 +89,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkipClass($node)) { return null; @@ -107,7 +107,7 @@ CODE_SAMPLE return null; } $classReflection = $this->reflectionResolver->resolveClassReflection($node); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return null; } $childrenClassReflections = $this->familyRelationsAnalyzer->getChildrenOfClassReflection($classReflection); @@ -120,11 +120,11 @@ CODE_SAMPLE $this->visibilityManipulator->makeFinal($node); return $node; } - private function hasDoctrineAttr(\PhpParser\Node\Stmt\Class_ $class) : bool + private function hasDoctrineAttr(Class_ $class) : bool { foreach ($class->attrGroups as $attrGroup) { foreach ($attrGroup->attrs as $attribute) { - if (!$attribute->name instanceof \PhpParser\Node\Name\FullyQualified) { + if (!$attribute->name instanceof FullyQualified) { continue; } $className = $this->nodeNameResolver->getName($attribute->name); @@ -138,7 +138,7 @@ CODE_SAMPLE } return \false; } - private function shouldSkipClass(\PhpParser\Node\Stmt\Class_ $class) : bool + private function shouldSkipClass(Class_ $class) : bool { if ($class->isFinal()) { return \true; diff --git a/rules/Privatization/Rector/Class_/RepeatedLiteralToClassConstantRector.php b/rules/Privatization/Rector/Class_/RepeatedLiteralToClassConstantRector.php index 505e9b002c9..68bb4192ff4 100644 --- a/rules/Privatization/Rector/Class_/RepeatedLiteralToClassConstantRector.php +++ b/rules/Privatization/Rector/Class_/RepeatedLiteralToClassConstantRector.php @@ -14,12 +14,12 @@ use Rector\Core\NodeManipulator\ClassInsertManipulator; use Rector\Core\Php\ReservedKeywordAnalyzer; use Rector\Core\Rector\AbstractRector; use Rector\Core\Util\StaticRectorStrings; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Privatization\Rector\Class_\RepeatedLiteralToClassConstantRector\RepeatedLiteralToClassConstantRectorTest */ -final class RepeatedLiteralToClassConstantRector extends \Rector\Core\Rector\AbstractRector +final class RepeatedLiteralToClassConstantRector extends AbstractRector { /** * @var string @@ -52,14 +52,14 @@ final class RepeatedLiteralToClassConstantRector extends \Rector\Core\Rector\Abs * @var \Rector\Core\Php\ReservedKeywordAnalyzer */ private $reservedKeywordAnalyzer; - public function __construct(\Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator, \Rector\Core\Php\ReservedKeywordAnalyzer $reservedKeywordAnalyzer) + public function __construct(ClassInsertManipulator $classInsertManipulator, ReservedKeywordAnalyzer $reservedKeywordAnalyzer) { $this->classInsertManipulator = $classInsertManipulator; $this->reservedKeywordAnalyzer = $reservedKeywordAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace repeated strings with constant', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace repeated strings with constant', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($key, $items) @@ -92,19 +92,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { // skip tests, where string values are often used as fixtures if ($this->isName($node, '*Test')) { return null; } /** @var String_[] $strings */ - $strings = $this->betterNodeFinder->findInstanceOf($node, \PhpParser\Node\Scalar\String_::class); + $strings = $this->betterNodeFinder->findInstanceOf($node, String_::class); $stringsToReplace = $this->resolveStringsToReplace($strings); if ($stringsToReplace === []) { return null; @@ -143,17 +143,17 @@ CODE_SAMPLE /** * @param string[] $stringsToReplace */ - private function replaceStringsWithClassConstReferences(\PhpParser\Node\Stmt\Class_ $class, array $stringsToReplace) : void + private function replaceStringsWithClassConstReferences(Class_ $class, array $stringsToReplace) : void { $classConsts = $class->getConstants(); - $this->traverseNodesWithCallable($class, function (\PhpParser\Node $node) use($stringsToReplace, $classConsts) : ?ClassConstFetch { - if (!$node instanceof \PhpParser\Node\Scalar\String_) { + $this->traverseNodesWithCallable($class, function (Node $node) use($stringsToReplace, $classConsts) : ?ClassConstFetch { + if (!$node instanceof String_) { return null; } if (!$this->valueResolver->isValues($node, $stringsToReplace)) { return null; } - $isInMethod = (bool) $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassMethod::class); + $isInMethod = (bool) $this->betterNodeFinder->findParentType($node, ClassMethod::class); if (!$isInMethod) { return null; } @@ -185,15 +185,15 @@ CODE_SAMPLE /** * @param string[] $stringsToReplace */ - private function addClassConsts(array $stringsToReplace, \PhpParser\Node\Stmt\Class_ $class) : void + private function addClassConsts(array $stringsToReplace, Class_ $class) : void { foreach ($stringsToReplace as $stringToReplace) { $constantName = $this->createConstName($stringToReplace); - $classConst = $this->nodeFactory->createClassConstant($constantName, new \PhpParser\Node\Scalar\String_($stringToReplace), \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $classConst = $this->nodeFactory->createClassConstant($constantName, new String_($stringToReplace), Class_::MODIFIER_PRIVATE); $this->classInsertManipulator->addConstantToClass($class, $stringToReplace, $classConst); } } - private function shouldSkipString(\PhpParser\Node\Scalar\String_ $string) : bool + private function shouldSkipString(String_ $string) : bool { $value = $string->value; // value is too short @@ -207,12 +207,12 @@ CODE_SAMPLE return \true; } // is replaceable value? - $matches = \RectorPrefix20220607\Nette\Utils\Strings::match($value, '#(?<' . self::VALUE . '>[\\w\\-\\/\\_]+)#'); + $matches = Strings::match($value, '#(?<' . self::VALUE . '>[\\w\\-\\/\\_]+)#'); if (!isset($matches[self::VALUE])) { return \true; } // skip values in another constants - $parentConst = $this->betterNodeFinder->findParentType($string, \PhpParser\Node\Stmt\ClassConst::class); + $parentConst = $this->betterNodeFinder->findParentType($string, ClassConst::class); if ($parentConst !== null) { return \true; } @@ -221,10 +221,10 @@ CODE_SAMPLE private function createConstName(string $value) : string { // replace slashes and dashes - $value = \RectorPrefix20220607\Nette\Utils\Strings::replace($value, self::SLASH_AND_DASH_REGEX, self::UNDERSCORE); + $value = Strings::replace($value, self::SLASH_AND_DASH_REGEX, self::UNDERSCORE); // find beginning numbers $beginningNumbers = ''; - $matches = \RectorPrefix20220607\Nette\Utils\Strings::match($value, '#(?<' . self::NUMBERS . '>[0-9]*)(?<' . self::VALUE . '>.*)#'); + $matches = Strings::match($value, '#(?<' . self::NUMBERS . '>[0-9]*)(?<' . self::VALUE . '>.*)#'); if (isset($matches[self::NUMBERS])) { $beginningNumbers = $matches[self::NUMBERS]; } @@ -234,7 +234,7 @@ CODE_SAMPLE // convert camelcase parts to underscore $parts = \explode(self::UNDERSCORE, (string) $value); $parts = \array_map(function (string $value) : string { - return \Rector\Core\Util\StaticRectorStrings::camelCaseToUnderscore($value); + return StaticRectorStrings::camelCaseToUnderscore($value); }, $parts); // apply "CONST" prefix if constant beginning with number if ($beginningNumbers !== '') { @@ -242,7 +242,7 @@ CODE_SAMPLE $parts = \array_filter($parts); } $value = \implode(self::UNDERSCORE, $parts); - return \strtoupper(\RectorPrefix20220607\Nette\Utils\Strings::replace($value, '#_+#', self::UNDERSCORE)); + return \strtoupper(Strings::replace($value, '#_+#', self::UNDERSCORE)); } private function isNativeConstantResemblingValue(string $value) : bool { diff --git a/rules/Privatization/Rector/MethodCall/PrivatizeLocalGetterToPropertyRector.php b/rules/Privatization/Rector/MethodCall/PrivatizeLocalGetterToPropertyRector.php index d957be68d4a..4cc83372234 100644 --- a/rules/Privatization/Rector/MethodCall/PrivatizeLocalGetterToPropertyRector.php +++ b/rules/Privatization/Rector/MethodCall/PrivatizeLocalGetterToPropertyRector.php @@ -11,16 +11,16 @@ use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Return_; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Privatization\Rector\MethodCall\PrivatizeLocalGetterToPropertyRector\PrivatizeLocalGetterToPropertyRectorTest */ -final class PrivatizeLocalGetterToPropertyRector extends \Rector\Core\Rector\AbstractRector +final class PrivatizeLocalGetterToPropertyRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Privatize getter of local property to property', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Privatize getter of local property to property', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { private $some; @@ -59,21 +59,21 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$node->var instanceof Variable) { return null; } if (!$this->nodeNameResolver->isName($node->var, 'this')) { return null; } - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLike = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$classLike instanceof Class_) { return null; } $methodName = $this->getName($node->name); @@ -81,23 +81,23 @@ CODE_SAMPLE return null; } $classMethod = $classLike->getMethod($methodName); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$classMethod instanceof ClassMethod) { return null; } return $this->matchLocalPropertyFetchInGetterMethod($classMethod); } - private function matchLocalPropertyFetchInGetterMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Expr\PropertyFetch + private function matchLocalPropertyFetchInGetterMethod(ClassMethod $classMethod) : ?PropertyFetch { $stmts = (array) $classMethod->stmts; if (\count($stmts) !== 1) { return null; } $onlyStmt = $stmts[0] ?? null; - if (!$onlyStmt instanceof \PhpParser\Node\Stmt\Return_) { + if (!$onlyStmt instanceof Return_) { return null; } $returnedExpr = $onlyStmt->expr; - if (!$returnedExpr instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$returnedExpr instanceof PropertyFetch) { return null; } return $returnedExpr; diff --git a/rules/Privatization/Rector/MethodCall/ReplaceStringWithClassConstantRector.php b/rules/Privatization/Rector/MethodCall/ReplaceStringWithClassConstantRector.php index 9280a3adb6e..7fd8baa940c 100644 --- a/rules/Privatization/Rector/MethodCall/ReplaceStringWithClassConstantRector.php +++ b/rules/Privatization/Rector/MethodCall/ReplaceStringWithClassConstantRector.php @@ -11,13 +11,13 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Privatization\NodeFactory\ClassConstantFetchValueFactory; use Rector\Privatization\ValueObject\ReplaceStringWithClassConstant; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Privatization\Rector\MethodCall\ReplaceStringWithClassConstantRector\ReplaceStringWithClassConstantRectorTest */ -final class ReplaceStringWithClassConstantRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class ReplaceStringWithClassConstantRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var ReplaceStringWithClassConstant[] @@ -28,13 +28,13 @@ final class ReplaceStringWithClassConstantRector extends \Rector\Core\Rector\Abs * @var \Rector\Privatization\NodeFactory\ClassConstantFetchValueFactory */ private $classConstantFetchValueFactory; - public function __construct(\Rector\Privatization\NodeFactory\ClassConstantFetchValueFactory $classConstantFetchValueFactory) + public function __construct(ClassConstantFetchValueFactory $classConstantFetchValueFactory) { $this->classConstantFetchValueFactory = $classConstantFetchValueFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace string values in specific method call by constant of provided class', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace string values in specific method call by constant of provided class', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -52,19 +52,19 @@ class SomeClass } } CODE_SAMPLE -, [new \Rector\Privatization\ValueObject\ReplaceStringWithClassConstant('SomeClass', 'call', 0, 'Placeholder')])]); +, [new ReplaceStringWithClassConstant('SomeClass', 'call', 0, 'Placeholder')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->args === []) { return null; @@ -72,11 +72,11 @@ CODE_SAMPLE $hasChanged = \false; foreach ($this->replaceStringWithClassConstants as $replaceStringWithClassConstant) { $desiredArg = $this->matchArg($node, $replaceStringWithClassConstant); - if (!$desiredArg instanceof \PhpParser\Node\Arg) { + if (!$desiredArg instanceof Arg) { continue; } $classConstFetch = $this->classConstantFetchValueFactory->create($desiredArg->value, $replaceStringWithClassConstant->getClassWithConstants(), $replaceStringWithClassConstant->isCaseInsensitive()); - if (!$classConstFetch instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if (!$classConstFetch instanceof ClassConstFetch) { continue; } $desiredArg->value = $classConstFetch; @@ -92,10 +92,10 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Privatization\ValueObject\ReplaceStringWithClassConstant::class); + Assert::allIsAOf($configuration, ReplaceStringWithClassConstant::class); $this->replaceStringWithClassConstants = $configuration; } - private function matchArg(\PhpParser\Node\Expr\MethodCall $methodCall, \Rector\Privatization\ValueObject\ReplaceStringWithClassConstant $replaceStringWithClassConstant) : ?\PhpParser\Node\Arg + private function matchArg(MethodCall $methodCall, ReplaceStringWithClassConstant $replaceStringWithClassConstant) : ?Arg { if (!$this->isObjectType($methodCall->var, $replaceStringWithClassConstant->getObjectType())) { return null; @@ -104,10 +104,10 @@ CODE_SAMPLE return null; } $desiredArg = $methodCall->args[$replaceStringWithClassConstant->getArgPosition()] ?? null; - if (!$desiredArg instanceof \PhpParser\Node\Arg) { + if (!$desiredArg instanceof Arg) { return null; } - if ($desiredArg->value instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if ($desiredArg->value instanceof ClassConstFetch) { return null; } return $desiredArg; diff --git a/rules/Privatization/Rector/Property/ChangeReadOnlyPropertyWithDefaultValueToConstantRector.php b/rules/Privatization/Rector/Property/ChangeReadOnlyPropertyWithDefaultValueToConstantRector.php index 4785e41ca4d..663249d5774 100644 --- a/rules/Privatization/Rector/Property/ChangeReadOnlyPropertyWithDefaultValueToConstantRector.php +++ b/rules/Privatization/Rector/Property/ChangeReadOnlyPropertyWithDefaultValueToConstantRector.php @@ -12,12 +12,12 @@ use Rector\Core\NodeManipulator\PropertyManipulator; use Rector\Core\Rector\AbstractRector; use Rector\Privatization\NodeFactory\ClassConstantFactory; use Rector\Privatization\NodeReplacer\PropertyFetchWithConstFetchReplacer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Privatization\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector\ChangeReadOnlyPropertyWithDefaultValueToConstantRectorTest */ -final class ChangeReadOnlyPropertyWithDefaultValueToConstantRector extends \Rector\Core\Rector\AbstractRector +final class ChangeReadOnlyPropertyWithDefaultValueToConstantRector extends AbstractRector { /** * @readonly @@ -34,15 +34,15 @@ final class ChangeReadOnlyPropertyWithDefaultValueToConstantRector extends \Rect * @var \Rector\Privatization\NodeReplacer\PropertyFetchWithConstFetchReplacer */ private $propertyFetchWithConstFetchReplacer; - public function __construct(\Rector\Core\NodeManipulator\PropertyManipulator $propertyManipulator, \Rector\Privatization\NodeFactory\ClassConstantFactory $classConstantFactory, \Rector\Privatization\NodeReplacer\PropertyFetchWithConstFetchReplacer $propertyFetchWithConstFetchReplacer) + public function __construct(PropertyManipulator $propertyManipulator, ClassConstantFactory $classConstantFactory, PropertyFetchWithConstFetchReplacer $propertyFetchWithConstFetchReplacer) { $this->propertyManipulator = $propertyManipulator; $this->classConstantFactory = $classConstantFactory; $this->propertyFetchWithConstFetchReplacer = $propertyFetchWithConstFetchReplacer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change property with read only status with default value to constant', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change property with read only status with default value to constant', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { /** @@ -87,12 +87,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -106,8 +106,8 @@ CODE_SAMPLE if (!$node->isPrivate()) { return null; } - $class = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$class instanceof Class_) { return null; } // is property read only? @@ -115,22 +115,22 @@ CODE_SAMPLE return null; } /** @var Class_ $classLike */ - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); + $classLike = $this->betterNodeFinder->findParentType($node, Class_::class); $this->propertyFetchWithConstFetchReplacer->replace($classLike, $node); return $this->classConstantFactory->createFromProperty($node); } - private function shouldSkip(\PhpParser\Node\Stmt\Property $property) : bool + private function shouldSkip(Property $property) : bool { if (\count($property->props) !== 1) { return \true; } - $classLike = $this->betterNodeFinder->findParentType($property, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLike = $this->betterNodeFinder->findParentType($property, Class_::class); + if (!$classLike instanceof Class_) { return \true; } if ($property->attrGroups !== []) { return \true; } - return $this->isObjectType($classLike, new \PHPStan\Type\ObjectType('PHP_CodeSniffer\\Sniffs\\Sniff')); + return $this->isObjectType($classLike, new ObjectType('PHP_CodeSniffer\\Sniffs\\Sniff')); } } diff --git a/rules/Privatization/Rector/Property/PrivatizeFinalClassPropertyRector.php b/rules/Privatization/Rector/Property/PrivatizeFinalClassPropertyRector.php index 42de8fff739..f3cbf581f7c 100644 --- a/rules/Privatization/Rector/Property/PrivatizeFinalClassPropertyRector.php +++ b/rules/Privatization/Rector/Property/PrivatizeFinalClassPropertyRector.php @@ -9,12 +9,12 @@ use PhpParser\Node\Stmt\Property; use Rector\Core\Rector\AbstractRector; use Rector\Privatization\Guard\ParentPropertyLookupGuard; use Rector\Privatization\NodeManipulator\VisibilityManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector\PrivatizeFinalClassPropertyRectorTest */ -final class PrivatizeFinalClassPropertyRector extends \Rector\Core\Rector\AbstractRector +final class PrivatizeFinalClassPropertyRector extends AbstractRector { /** * @readonly @@ -26,14 +26,14 @@ final class PrivatizeFinalClassPropertyRector extends \Rector\Core\Rector\Abstra * @var \Rector\Privatization\Guard\ParentPropertyLookupGuard */ private $parentPropertyLookupGuard; - public function __construct(\Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator, \Rector\Privatization\Guard\ParentPropertyLookupGuard $parentPropertyLookupGuard) + public function __construct(VisibilityManipulator $visibilityManipulator, ParentPropertyLookupGuard $parentPropertyLookupGuard) { $this->visibilityManipulator = $visibilityManipulator; $this->parentPropertyLookupGuard = $parentPropertyLookupGuard; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change property to private if possible', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change property to private if possible', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { protected $value; @@ -52,15 +52,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLike = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$classLike instanceof Class_) { return null; } if (!$classLike->isFinal()) { @@ -75,7 +75,7 @@ CODE_SAMPLE $this->visibilityManipulator->makePrivate($node); return $node; } - private function shouldSkipProperty(\PhpParser\Node\Stmt\Property $property) : bool + private function shouldSkipProperty(Property $property) : bool { if (\count($property->props) !== 1) { return \true; diff --git a/rules/Privatization/Reflection/ClassConstantsResolver.php b/rules/Privatization/Reflection/ClassConstantsResolver.php index d9161b92d4f..f97d74486ae 100644 --- a/rules/Privatization/Reflection/ClassConstantsResolver.php +++ b/rules/Privatization/Reflection/ClassConstantsResolver.php @@ -15,7 +15,7 @@ final class ClassConstantsResolver * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ReflectionProvider $reflectionProvider) { $this->reflectionProvider = $reflectionProvider; } diff --git a/rules/Privatization/TypeManipulator/NormalizeTypeToRespectArrayScalarType.php b/rules/Privatization/TypeManipulator/NormalizeTypeToRespectArrayScalarType.php index e0fcaab7685..2af73ebd70f 100644 --- a/rules/Privatization/TypeManipulator/NormalizeTypeToRespectArrayScalarType.php +++ b/rules/Privatization/TypeManipulator/NormalizeTypeToRespectArrayScalarType.php @@ -18,11 +18,11 @@ final class NormalizeTypeToRespectArrayScalarType * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } - public function normalizeToArray(\PHPStan\Type\Type $type, ?\PhpParser\Node $returnNode) : \PHPStan\Type\Type + public function normalizeToArray(Type $type, ?Node $returnNode) : Type { if ($returnNode === null) { return $type; @@ -30,38 +30,38 @@ final class NormalizeTypeToRespectArrayScalarType if (!$this->nodeNameResolver->isName($returnNode, 'array')) { return $type; } - if ($type instanceof \PHPStan\Type\UnionType) { + if ($type instanceof UnionType) { return $this->normalizeUnionType($type); } - if ($type instanceof \PHPStan\Type\MixedType) { - return new \PHPStan\Type\ArrayType($type, $type); + if ($type instanceof MixedType) { + return new ArrayType($type, $type); } - if ($type instanceof \PHPStan\Type\ArrayType) { + if ($type instanceof ArrayType) { return $this->resolveArrayType($type); } return $type; } - private function resolveArrayType(\PHPStan\Type\ArrayType $arrayType) : \PHPStan\Type\ArrayType + private function resolveArrayType(ArrayType $arrayType) : ArrayType { $itemType = $arrayType->getItemType(); - if (!$itemType instanceof \PHPStan\Type\IntersectionType) { + if (!$itemType instanceof IntersectionType) { return $arrayType; } $types = $itemType->getTypes(); foreach ($types as $key => $itemTypeType) { - if ($itemTypeType instanceof \PHPStan\Type\Accessory\NonEmptyArrayType) { + if ($itemTypeType instanceof NonEmptyArrayType) { unset($types[$key]); } } - $arrayItemType = \count($types) === 1 ? \array_pop($types) : new \PHPStan\Type\IntersectionType($types); - return new \PHPStan\Type\ArrayType($arrayType->getKeyType(), $arrayItemType); + $arrayItemType = \count($types) === 1 ? \array_pop($types) : new IntersectionType($types); + return new ArrayType($arrayType->getKeyType(), $arrayItemType); } - private function normalizeUnionType(\PHPStan\Type\UnionType $unionType) : \PHPStan\Type\UnionType + private function normalizeUnionType(UnionType $unionType) : UnionType { $normalizedTypes = []; foreach ($unionType->getTypes() as $unionedType) { - if ($unionedType instanceof \PHPStan\Type\MixedType) { - $normalizedTypes[] = new \PHPStan\Type\ArrayType($unionedType, $unionedType); + if ($unionedType instanceof MixedType) { + $normalizedTypes[] = new ArrayType($unionedType, $unionedType); continue; } $normalizedTypes[] = $unionedType; @@ -69,6 +69,6 @@ final class NormalizeTypeToRespectArrayScalarType if ($unionType->getTypes() === $normalizedTypes) { return $unionType; } - return new \PHPStan\Type\UnionType($normalizedTypes); + return new UnionType($normalizedTypes); } } diff --git a/rules/Privatization/TypeManipulator/TypeNormalizer.php b/rules/Privatization/TypeManipulator/TypeNormalizer.php index dee33583975..223bda35449 100644 --- a/rules/Privatization/TypeManipulator/TypeNormalizer.php +++ b/rules/Privatization/TypeManipulator/TypeNormalizer.php @@ -13,11 +13,11 @@ final class TypeNormalizer * Generalize false/true type to bool, * as mostly default value but accepts both */ - public function generalizeConstantBoolTypes(\PHPStan\Type\Type $type) : \PHPStan\Type\Type + public function generalizeConstantBoolTypes(Type $type) : Type { - return \PHPStan\Type\TypeTraverser::map($type, function (\PHPStan\Type\Type $type, callable $traverseCallback) { - if ($type instanceof \PHPStan\Type\Constant\ConstantBooleanType) { - return new \PHPStan\Type\BooleanType(); + return TypeTraverser::map($type, function (Type $type, callable $traverseCallback) { + if ($type instanceof ConstantBooleanType) { + return new BooleanType(); } return $traverseCallback($type, $traverseCallback); }); diff --git a/rules/Privatization/ValueObject/ReplaceStringWithClassConstant.php b/rules/Privatization/ValueObject/ReplaceStringWithClassConstant.php index 3ddb2f21bf3..10cd3cb2d97 100644 --- a/rules/Privatization/ValueObject/ReplaceStringWithClassConstant.php +++ b/rules/Privatization/ValueObject/ReplaceStringWithClassConstant.php @@ -42,11 +42,11 @@ final class ReplaceStringWithClassConstant $this->argPosition = $argPosition; $this->classWithConstants = $classWithConstants; $this->caseInsensitive = $caseInsensitive; - \Rector\Core\Validation\RectorAssert::className($class); + RectorAssert::className($class); } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->class); + return new ObjectType($this->class); } public function getMethod() : string { diff --git a/rules/Privatization/VisibilityGuard/ClassMethodVisibilityGuard.php b/rules/Privatization/VisibilityGuard/ClassMethodVisibilityGuard.php index 83e570083dd..41c36d90c45 100644 --- a/rules/Privatization/VisibilityGuard/ClassMethodVisibilityGuard.php +++ b/rules/Privatization/VisibilityGuard/ClassMethodVisibilityGuard.php @@ -13,11 +13,11 @@ final class ClassMethodVisibilityGuard * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } - public function isClassMethodVisibilityGuardedByParent(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PHPStan\Reflection\ClassReflection $classReflection) : bool + public function isClassMethodVisibilityGuardedByParent(ClassMethod $classMethod, ClassReflection $classReflection) : bool { $methodName = $this->nodeNameResolver->getName($classMethod); /** @var ClassReflection[] $parentClassReflections */ @@ -29,7 +29,7 @@ final class ClassMethodVisibilityGuard } return \false; } - public function isClassMethodVisibilityGuardedByTrait(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PHPStan\Reflection\ClassReflection $classReflection) : bool + public function isClassMethodVisibilityGuardedByTrait(ClassMethod $classMethod, ClassReflection $classReflection) : bool { $parentTraitReflections = $this->getLocalAndParentTraitReflections($classReflection); $methodName = $this->nodeNameResolver->getName($classMethod); @@ -43,7 +43,7 @@ final class ClassMethodVisibilityGuard /** * @return ClassReflection[] */ - private function getLocalAndParentTraitReflections(\PHPStan\Reflection\ClassReflection $classReflection) : array + private function getLocalAndParentTraitReflections(ClassReflection $classReflection) : array { $traitReflections = $classReflection->getTraits(); foreach ($classReflection->getParents() as $parentClassReflection) { diff --git a/rules/Removing/NodeManipulator/ComplexNodeRemover.php b/rules/Removing/NodeManipulator/ComplexNodeRemover.php index 74608d53150..defb4b32aa7 100644 --- a/rules/Removing/NodeManipulator/ComplexNodeRemover.php +++ b/rules/Removing/NodeManipulator/ComplexNodeRemover.php @@ -54,7 +54,7 @@ final class ComplexNodeRemover * @var \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer */ private $propertyFetchAnalyzer; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeRemoval\NodeRemover $nodeRemover, \Rector\DeadCode\SideEffect\SideEffectNodeDetector $sideEffectNodeDetector, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer) + public function __construct(NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder, NodeRemover $nodeRemover, SideEffectNodeDetector $sideEffectNodeDetector, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, PropertyFetchAnalyzer $propertyFetchAnalyzer) { $this->nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; @@ -63,24 +63,24 @@ final class ComplexNodeRemover $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; } - public function removePropertyAndUsages(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\Property $property, bool $removeAssignSideEffect) : void + public function removePropertyAndUsages(Class_ $class, Property $property, bool $removeAssignSideEffect) : void { $propertyName = $this->nodeNameResolver->getName($property); $hasSideEffect = \false; $isPartOfAnotherAssign = \false; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($class->stmts, function (\PhpParser\Node $node) use($removeAssignSideEffect, $propertyName, &$hasSideEffect, &$isPartOfAnotherAssign) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($class->stmts, function (Node $node) use($removeAssignSideEffect, $propertyName, &$hasSideEffect, &$isPartOfAnotherAssign) { // here should be checked all expr like stmts that can hold assign, e.f. if, foreach etc. etc. - if (!$node instanceof \PhpParser\Node\Stmt\Expression) { + if (!$node instanceof Expression) { return null; } $nodeExpr = $node->expr; // remove direct assigns - if (!$nodeExpr instanceof \PhpParser\Node\Expr\Assign) { + if (!$nodeExpr instanceof Assign) { return null; } $assign = $nodeExpr; // skip double assigns - if ($assign->expr instanceof \PhpParser\Node\Expr\Assign) { + if ($assign->expr instanceof Assign) { $isPartOfAnotherAssign = \true; return null; } @@ -136,20 +136,20 @@ final class ComplexNodeRemover } return $removedParamKeys; } - private function removeConstructorDependency(\PhpParser\Node\Stmt\Class_ $class, string $propertyName) : void + private function removeConstructorDependency(Class_ $class, string $propertyName) : void { - $classMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $class->getMethod(MethodName::CONSTRUCT); + if (!$classMethod instanceof ClassMethod) { return; } $stmts = (array) $classMethod->stmts; $paramKeysToBeRemoved = []; foreach ($stmts as $key => $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { continue; } $stmtExpr = $stmt->expr; - if (!$stmtExpr instanceof \PhpParser\Node\Expr\Assign) { + if (!$stmtExpr instanceof Assign) { continue; } if (!$this->propertyFetchAnalyzer->isLocalPropertyFetch($stmtExpr->var)) { @@ -161,7 +161,7 @@ final class ComplexNodeRemover continue; } unset($classMethod->stmts[$key]); - if (!$stmtExpr->expr instanceof \PhpParser\Node\Expr\Variable) { + if (!$stmtExpr->expr instanceof Variable) { continue; } $key = $this->resolveToBeClearedParamFromConstructor($classMethod, $stmtExpr->expr); @@ -177,12 +177,12 @@ final class ComplexNodeRemover /** * @return StaticPropertyFetch[]|PropertyFetch[] */ - private function resolvePropertyFetchFromDimFetch(\PhpParser\Node\Expr $expr) : array + private function resolvePropertyFetchFromDimFetch(Expr $expr) : array { // unwrap array dim fetch, till we get to parent too caller node /** @var PropertyFetch[]|StaticPropertyFetch[] $propertyFetches */ $propertyFetches = []; - while ($expr instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + while ($expr instanceof ArrayDimFetch) { $propertyFetches = $this->collectPropertyFetches($expr->dim, $propertyFetches); $expr = $expr->var; } @@ -192,9 +192,9 @@ final class ComplexNodeRemover * @param StaticPropertyFetch[]|PropertyFetch[] $propertyFetches * @return PropertyFetch[]|StaticPropertyFetch[] */ - private function collectPropertyFetches(?\PhpParser\Node\Expr $expr, array $propertyFetches) : array + private function collectPropertyFetches(?Expr $expr, array $propertyFetches) : array { - if (!$expr instanceof \PhpParser\Node\Expr) { + if (!$expr instanceof Expr) { return $propertyFetches; } if ($this->propertyFetchAnalyzer->isLocalPropertyFetch($expr)) { @@ -203,11 +203,11 @@ final class ComplexNodeRemover } return $propertyFetches; } - private function resolveToBeClearedParamFromConstructor(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Expr\Variable $assignedVariable) : ?int + private function resolveToBeClearedParamFromConstructor(ClassMethod $classMethod, Variable $assignedVariable) : ?int { // is variable used somewhere else? skip it - $variables = $this->betterNodeFinder->findInstanceOf($classMethod, \PhpParser\Node\Expr\Variable::class); - $paramNamedVariables = \array_filter($variables, function (\PhpParser\Node\Expr\Variable $variable) use($assignedVariable) : bool { + $variables = $this->betterNodeFinder->findInstanceOf($classMethod, Variable::class); + $paramNamedVariables = \array_filter($variables, function (Variable $variable) use($assignedVariable) : bool { return $this->nodeNameResolver->areNamesEqual($variable, $assignedVariable); }); // there is more than 1 use, keep it in the constructor diff --git a/rules/Removing/Rector/ClassMethod/ArgumentRemoverRector.php b/rules/Removing/Rector/ClassMethod/ArgumentRemoverRector.php index bacd8a0f604..19a38430b08 100644 --- a/rules/Removing/Rector/ClassMethod/ArgumentRemoverRector.php +++ b/rules/Removing/Rector/ClassMethod/ArgumentRemoverRector.php @@ -12,21 +12,21 @@ use PhpParser\Node\VariadicPlaceholder; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Removing\ValueObject\ArgumentRemover; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Removing\Rector\ClassMethod\ArgumentRemoverRector\ArgumentRemoverRectorTest */ -final class ArgumentRemoverRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class ArgumentRemoverRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var ArgumentRemover[] */ private $removedArguments = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Removes defined arguments in defined methods and their calls.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Removes defined arguments in defined methods and their calls.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' $someObject = new SomeClass; $someObject->someMethod(true); CODE_SAMPLE @@ -34,20 +34,20 @@ CODE_SAMPLE $someObject = new SomeClass; $someObject->someMethod(); CODE_SAMPLE -, [new \Rector\Removing\ValueObject\ArgumentRemover('ExampleClass', 'someMethod', 0, [\true])])]); +, [new ArgumentRemover('ExampleClass', 'someMethod', 0, [\true])])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class, \PhpParser\Node\Stmt\ClassMethod::class]; + 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 */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { foreach ($this->removedArguments as $removedArgument) { if (!$this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($node, $removedArgument->getObjectType())) { @@ -65,16 +65,16 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Removing\ValueObject\ArgumentRemover::class); + 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, \Rector\Removing\ValueObject\ArgumentRemover $argumentRemover) : void + private function processPosition($node, ArgumentRemover $argumentRemover) : void { if ($argumentRemover->getValue() === null) { - if ($node instanceof \PhpParser\Node\Expr\MethodCall || $node instanceof \PhpParser\Node\Expr\StaticCall) { + if ($node instanceof MethodCall || $node instanceof StaticCall) { $this->nodeRemover->removeArg($node, $argumentRemover->getPosition()); } else { $this->nodeRemover->removeParam($node, $argumentRemover->getPosition()); @@ -87,7 +87,7 @@ CODE_SAMPLE return; } // only argument specific value can be removed - if ($node instanceof \PhpParser\Node\Stmt\ClassMethod) { + if ($node instanceof ClassMethod) { return; } if (!isset($node->args[$argumentRemover->getPosition()])) { @@ -102,7 +102,7 @@ CODE_SAMPLE */ private function removeByName($node, int $position, string $name) : void { - if ($node instanceof \PhpParser\Node\Expr\MethodCall || $node instanceof \PhpParser\Node\Expr\StaticCall) { + if ($node instanceof MethodCall || $node instanceof StaticCall) { if (isset($node->args[$position]) && $this->isName($node->args[$position], $name)) { $this->nodeRemover->removeArg($node, $position); } @@ -119,7 +119,7 @@ CODE_SAMPLE */ private function isArgumentValueMatch($arg, array $values) : bool { - if (!$arg instanceof \PhpParser\Node\Arg) { + if (!$arg instanceof Arg) { return \false; } $nodeValue = $this->valueResolver->getValue($arg->value); diff --git a/rules/Removing/Rector/Class_/RemoveInterfacesRector.php b/rules/Removing/Rector/Class_/RemoveInterfacesRector.php index f4fbe07f3aa..1820c378bf1 100644 --- a/rules/Removing/Rector/Class_/RemoveInterfacesRector.php +++ b/rules/Removing/Rector/Class_/RemoveInterfacesRector.php @@ -7,21 +7,21 @@ use PhpParser\Node; use PhpParser\Node\Stmt\Class_; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Removing\Rector\Class_\RemoveInterfacesRector\RemoveInterfacesRectorTest */ -final class RemoveInterfacesRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RemoveInterfacesRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var string[] */ private $interfacesToRemove = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Removes interfaces usage from class.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Removes interfaces usage from class.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass implements SomeInterface { } @@ -38,12 +38,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->implements === []) { return null; @@ -65,7 +65,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configuration); + Assert::allString($configuration); /** @var string[] $configuration */ $this->interfacesToRemove = $configuration; } diff --git a/rules/Removing/Rector/Class_/RemoveParentRector.php b/rules/Removing/Rector/Class_/RemoveParentRector.php index 456c3aee010..c45b033ba0a 100644 --- a/rules/Removing/Rector/Class_/RemoveParentRector.php +++ b/rules/Removing/Rector/Class_/RemoveParentRector.php @@ -10,13 +10,13 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Removing\Rector\Class_\RemoveParentRector\RemoveParentRectorTest */ -final class RemoveParentRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RemoveParentRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var string[] @@ -27,13 +27,13 @@ final class RemoveParentRector extends \Rector\Core\Rector\AbstractRector implem * @var \Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver */ private $parentClassScopeResolver; - public function __construct(\Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver $parentClassScopeResolver) + public function __construct(ParentClassScopeResolver $parentClassScopeResolver) { $this->parentClassScopeResolver = $parentClassScopeResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Removes extends class by name', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Removes extends class by name', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' final class SomeClass extends SomeParentClass { } @@ -50,16 +50,16 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $node->getAttribute(AttributeKey::SCOPE); $parentClassReflection = $this->parentClassScopeResolver->resolveParentClassReflection($scope); - if (!$parentClassReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$parentClassReflection instanceof ClassReflection) { return null; } foreach ($this->parentClassesToRemove as $parentClassToRemove) { @@ -77,7 +77,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configuration); + Assert::allString($configuration); $this->parentClassesToRemove = $configuration; } } diff --git a/rules/Removing/Rector/Class_/RemoveTraitUseRector.php b/rules/Removing/Rector/Class_/RemoveTraitUseRector.php index 1de54639ce9..8619343d326 100644 --- a/rules/Removing/Rector/Class_/RemoveTraitUseRector.php +++ b/rules/Removing/Rector/Class_/RemoveTraitUseRector.php @@ -9,13 +9,13 @@ use PhpParser\Node\Stmt\Trait_; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Removing\Rector\Class_\RemoveTraitUseRector\RemoveTraitUseRectorTest */ -final class RemoveTraitUseRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RemoveTraitUseRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var bool @@ -25,9 +25,9 @@ final class RemoveTraitUseRector extends \Rector\Core\Rector\AbstractRector impl * @var string[] */ private $traitsToRemove = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove specific traits from code', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove specific traits from code', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { use SomeTrait; @@ -45,12 +45,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class, \PhpParser\Node\Stmt\Trait_::class]; + return [Class_::class, Trait_::class]; } /** * @param Class_|Trait_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $this->classHasChanged = \false; foreach ($node->getTraitUses() as $traitUse) { @@ -64,7 +64,7 @@ CODE_SAMPLE } // invoke re-print if ($this->classHasChanged) { - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); return $node; } return null; @@ -74,7 +74,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configuration); + Assert::allString($configuration); $this->traitsToRemove = $configuration; } } diff --git a/rules/Removing/Rector/FuncCall/RemoveFuncCallArgRector.php b/rules/Removing/Rector/FuncCall/RemoveFuncCallArgRector.php index ec1b6ca683c..0641551e51a 100644 --- a/rules/Removing/Rector/FuncCall/RemoveFuncCallArgRector.php +++ b/rules/Removing/Rector/FuncCall/RemoveFuncCallArgRector.php @@ -9,41 +9,41 @@ use PhpParser\Node\Expr\FuncCall; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Removing\ValueObject\RemoveFuncCallArg; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Removing\Rector\FuncCall\RemoveFuncCallArgRector\RemoveFuncCallArgRectorTest */ -final class RemoveFuncCallArgRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RemoveFuncCallArgRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var RemoveFuncCallArg[] */ private $removedFunctionArguments = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove argument by position by function name', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove argument by position by function name', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' remove_last_arg(1, 2); CODE_SAMPLE , <<<'CODE_SAMPLE' remove_last_arg(1); CODE_SAMPLE -, [new \Rector\Removing\ValueObject\RemoveFuncCallArg('remove_last_arg', 1)])]); +, [new RemoveFuncCallArg('remove_last_arg', 1)])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node->name instanceof \PhpParser\Node\Expr) { + if ($node->name instanceof Expr) { return null; } $hasChanged = \false; @@ -69,7 +69,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Removing\ValueObject\RemoveFuncCallArg::class); + Assert::allIsAOf($configuration, RemoveFuncCallArg::class); $this->removedFunctionArguments = $configuration; } } diff --git a/rules/Removing/Rector/FuncCall/RemoveFuncCallRector.php b/rules/Removing/Rector/FuncCall/RemoveFuncCallRector.php index d96b549e374..4f8bf9cfdd0 100644 --- a/rules/Removing/Rector/FuncCall/RemoveFuncCallRector.php +++ b/rules/Removing/Rector/FuncCall/RemoveFuncCallRector.php @@ -10,13 +10,13 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\NodeRemoval\BreakingRemovalGuard; use Rector\Removing\ValueObject\RemoveFuncCall; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Removing\Rector\FuncCall\RemoveFuncCallRector\RemoveFuncCallRectorTest */ -final class RemoveFuncCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RemoveFuncCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var RemoveFuncCall[] @@ -27,32 +27,32 @@ final class RemoveFuncCallRector extends \Rector\Core\Rector\AbstractRector impl * @var \Rector\NodeRemoval\BreakingRemovalGuard */ private $breakingRemovalGuard; - public function __construct(\Rector\NodeRemoval\BreakingRemovalGuard $breakingRemovalGuard) + public function __construct(BreakingRemovalGuard $breakingRemovalGuard) { $this->breakingRemovalGuard = $breakingRemovalGuard; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove ini_get by configuration', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove ini_get by configuration', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' ini_get('y2k_compliance'); ini_get('keep_me'); CODE_SAMPLE , <<<'CODE_SAMPLE' ini_get('keep_me'); CODE_SAMPLE -, [new \Rector\Removing\ValueObject\RemoveFuncCall('ini_get', [1 => ['y2k_compliance']])])]); +, [new RemoveFuncCall('ini_get', [1 => ['y2k_compliance']])])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->removeFuncCalls as $removeFuncCall) { if (!$this->isName($node, $removeFuncCall->getFuncCall())) { @@ -63,7 +63,7 @@ CODE_SAMPLE return $node; } $removedFuncCall = $this->refactorFuncCallsWithPositions($node, $removeFuncCall); - if ($removedFuncCall instanceof \PhpParser\Node\Expr\FuncCall) { + if ($removedFuncCall instanceof FuncCall) { return $node; } } @@ -74,10 +74,10 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Removing\ValueObject\RemoveFuncCall::class); + Assert::allIsAOf($configuration, RemoveFuncCall::class); $this->removeFuncCalls = $configuration; } - private function refactorFuncCallsWithPositions(\PhpParser\Node\Expr\FuncCall $funcCall, \Rector\Removing\ValueObject\RemoveFuncCall $removeFuncCall) : ?\PhpParser\Node\Expr\FuncCall + private function refactorFuncCallsWithPositions(FuncCall $funcCall, RemoveFuncCall $removeFuncCall) : ?FuncCall { foreach ($removeFuncCall->getArgumentPositionAndValues() as $argumentPosition => $values) { if (!$this->isArgumentPositionValueMatch($funcCall, $argumentPosition, $values)) { @@ -93,12 +93,12 @@ CODE_SAMPLE /** * @param mixed[] $values */ - private function isArgumentPositionValueMatch(\PhpParser\Node\Expr\FuncCall $funcCall, int $argumentPosition, array $values) : bool + private function isArgumentPositionValueMatch(FuncCall $funcCall, int $argumentPosition, array $values) : bool { if (!isset($funcCall->args[$argumentPosition])) { return \false; } - if (!$funcCall->args[$argumentPosition] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[$argumentPosition] instanceof Arg) { return \false; } return $this->valueResolver->isValues($funcCall->args[$argumentPosition]->value, $values); diff --git a/rules/Removing/ValueObject/ArgumentRemover.php b/rules/Removing/ValueObject/ArgumentRemover.php index 97d96ff378c..3ff9287e0c6 100644 --- a/rules/Removing/ValueObject/ArgumentRemover.php +++ b/rules/Removing/ValueObject/ArgumentRemover.php @@ -35,11 +35,11 @@ final class ArgumentRemover $this->method = $method; $this->position = $position; $this->value = $value; - \Rector\Core\Validation\RectorAssert::className($class); + RectorAssert::className($class); } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->class); + return new ObjectType($this->class); } public function getMethod() : string { diff --git a/rules/RemovingStatic/Rector/ClassMethod/LocallyCalledStaticMethodToNonStaticRector.php b/rules/RemovingStatic/Rector/ClassMethod/LocallyCalledStaticMethodToNonStaticRector.php index c15125bd12a..3b0abed8904 100644 --- a/rules/RemovingStatic/Rector/ClassMethod/LocallyCalledStaticMethodToNonStaticRector.php +++ b/rules/RemovingStatic/Rector/ClassMethod/LocallyCalledStaticMethodToNonStaticRector.php @@ -15,12 +15,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; use Rector\Privatization\NodeManipulator\VisibilityManipulator; use Rector\Privatization\VisibilityGuard\ClassMethodVisibilityGuard; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\RemovingStatic\Rector\ClassMethod\LocallyCalledStaticMethodToNonStaticRector\LocallyCalledStaticMethodToNonStaticRectorTest */ -final class LocallyCalledStaticMethodToNonStaticRector extends \Rector\Core\Rector\AbstractRector +final class LocallyCalledStaticMethodToNonStaticRector extends AbstractRector { /** * @readonly @@ -37,15 +37,15 @@ final class LocallyCalledStaticMethodToNonStaticRector extends \Rector\Core\Rect * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Privatization\VisibilityGuard\ClassMethodVisibilityGuard $classMethodVisibilityGuard, \Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(ClassMethodVisibilityGuard $classMethodVisibilityGuard, VisibilityManipulator $visibilityManipulator, ReflectionResolver $reflectionResolver) { $this->classMethodVisibilityGuard = $classMethodVisibilityGuard; $this->visibilityManipulator = $visibilityManipulator; $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change static method and local-only calls to non-static', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change static method and local-only calls to non-static', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -78,14 +78,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Expr\StaticCall::class]; + return [ClassMethod::class, StaticCall::class]; } /** * @param ClassMethod|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Stmt\ClassMethod) { + if ($node instanceof ClassMethod) { if (!$node->isPrivate()) { return null; } @@ -93,13 +93,13 @@ CODE_SAMPLE } return $this->refactorStaticCall($node); } - private function refactorClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Stmt\ClassMethod + private function refactorClassMethod(ClassMethod $classMethod) : ?ClassMethod { if (!$classMethod->isStatic()) { return null; } $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return null; } if ($this->classMethodVisibilityGuard->isClassMethodVisibilityGuardedByParent($classMethod, $classReflection)) { @@ -109,14 +109,14 @@ CODE_SAMPLE $this->visibilityManipulator->makeNonStatic($classMethod); return $classMethod; } - private function refactorStaticCall(\PhpParser\Node\Expr\StaticCall $staticCall) : ?\PhpParser\Node\Expr\MethodCall + private function refactorStaticCall(StaticCall $staticCall) : ?MethodCall { - $classLike = $this->betterNodeFinder->findParentType($staticCall, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($staticCall, ClassLike::class); + if (!$classLike instanceof ClassLike) { return null; } /** @var ClassMethod[] $classMethods */ - $classMethods = $this->betterNodeFinder->findInstanceOf($classLike, \PhpParser\Node\Stmt\ClassMethod::class); + $classMethods = $this->betterNodeFinder->findInstanceOf($classLike, ClassMethod::class); foreach ($classMethods as $classMethod) { if (!$this->isClassMethodMatchingStaticCall($classMethod, $staticCall)) { continue; @@ -124,27 +124,27 @@ CODE_SAMPLE if ($this->isInStaticClassMethod($staticCall)) { continue; } - $thisVariable = new \PhpParser\Node\Expr\Variable('this'); - return new \PhpParser\Node\Expr\MethodCall($thisVariable, $staticCall->name, $staticCall->args); + $thisVariable = new Variable('this'); + return new MethodCall($thisVariable, $staticCall->name, $staticCall->args); } return null; } - private function isInStaticClassMethod(\PhpParser\Node\Expr\StaticCall $staticCall) : bool + private function isInStaticClassMethod(StaticCall $staticCall) : bool { - $locationClassMethod = $this->betterNodeFinder->findParentType($staticCall, \PhpParser\Node\Stmt\ClassMethod::class); - if (!$locationClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $locationClassMethod = $this->betterNodeFinder->findParentType($staticCall, ClassMethod::class); + if (!$locationClassMethod instanceof ClassMethod) { return \false; } return $locationClassMethod->isStatic(); } - private function isClassMethodMatchingStaticCall(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Expr\StaticCall $staticCall) : bool + private function isClassMethodMatchingStaticCall(ClassMethod $classMethod, StaticCall $staticCall) : bool { - $classLike = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($classMethod, ClassLike::class); + if (!$classLike instanceof ClassLike) { return \false; } $className = (string) $this->nodeNameResolver->getName($classLike); - $objectType = new \PHPStan\Type\ObjectType($className); + $objectType = new ObjectType($className); $callerType = $this->nodeTypeResolver->getType($staticCall->class); return $objectType->equals($callerType); } diff --git a/rules/Renaming/Contract/MethodCallRenameInterface.php b/rules/Renaming/Contract/MethodCallRenameInterface.php index d649d6e7770..97d492a0427 100644 --- a/rules/Renaming/Contract/MethodCallRenameInterface.php +++ b/rules/Renaming/Contract/MethodCallRenameInterface.php @@ -7,7 +7,7 @@ use PHPStan\Type\ObjectType; interface MethodCallRenameInterface { public function getClass() : string; - public function getObjectType() : \PHPStan\Type\ObjectType; + public function getObjectType() : ObjectType; public function getOldMethod() : string; public function getNewMethod() : string; } diff --git a/rules/Renaming/Contract/RenameClassConstFetchInterface.php b/rules/Renaming/Contract/RenameClassConstFetchInterface.php index ec0728d80e3..3657c36e74f 100644 --- a/rules/Renaming/Contract/RenameClassConstFetchInterface.php +++ b/rules/Renaming/Contract/RenameClassConstFetchInterface.php @@ -6,7 +6,7 @@ namespace Rector\Renaming\Contract; use PHPStan\Type\ObjectType; interface RenameClassConstFetchInterface { - public function getOldObjectType() : \PHPStan\Type\ObjectType; + public function getOldObjectType() : ObjectType; public function getOldConstant() : string; public function getNewConstant() : string; } diff --git a/rules/Renaming/NodeManipulator/ClassRenamer.php b/rules/Renaming/NodeManipulator/ClassRenamer.php index c2762abd88c..1aace111630 100644 --- a/rules/Renaming/NodeManipulator/ClassRenamer.php +++ b/rules/Renaming/NodeManipulator/ClassRenamer.php @@ -101,7 +101,7 @@ final class ClassRenamer * @var \Rector\Naming\Naming\UseImportsResolver */ private $useImportsResolver; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\CodingStyle\Naming\ClassNaming $classNaming, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocClassRenamer $phpDocClassRenamer, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockClassRenamer $docBlockClassRenamer, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\NodeRemoval\NodeRemover $nodeRemover, \RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \Rector\Naming\Naming\UseImportsResolver $useImportsResolver) + public function __construct(BetterNodeFinder $betterNodeFinder, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, ClassNaming $classNaming, NodeNameResolver $nodeNameResolver, PhpDocClassRenamer $phpDocClassRenamer, PhpDocInfoFactory $phpDocInfoFactory, DocBlockClassRenamer $docBlockClassRenamer, ReflectionProvider $reflectionProvider, NodeRemover $nodeRemover, ParameterProvider $parameterProvider, UseImportsResolver $useImportsResolver) { $this->betterNodeFinder = $betterNodeFinder; $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; @@ -118,17 +118,17 @@ final class ClassRenamer /** * @param array $oldToNewClasses */ - public function renameNode(\PhpParser\Node $node, array $oldToNewClasses) : ?\PhpParser\Node + public function renameNode(Node $node, array $oldToNewClasses) : ?Node { $oldToNewTypes = $this->createOldToNewTypes($oldToNewClasses); $this->refactorPhpDoc($node, $oldToNewTypes, $oldToNewClasses); - if ($node instanceof \PhpParser\Node\Name) { + if ($node instanceof Name) { return $this->refactorName($node, $oldToNewClasses); } - if ($node instanceof \PhpParser\Node\Stmt\Namespace_) { + if ($node instanceof Namespace_) { return $this->refactorNamespace($node, $oldToNewClasses); } - if ($node instanceof \PhpParser\Node\Stmt\ClassLike) { + if ($node instanceof ClassLike) { return $this->refactorClassLike($node, $oldToNewClasses); } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); @@ -141,36 +141,36 @@ final class ClassRenamer * @param OldToNewType[] $oldToNewTypes * @param array $oldToNewClasses */ - private function refactorPhpDoc(\PhpParser\Node $node, array $oldToNewTypes, array $oldToNewClasses) : void + private function refactorPhpDoc(Node $node, array $oldToNewTypes, array $oldToNewClasses) : void { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); - if (!$phpDocInfo->hasByTypes(\Rector\BetterPhpDocParser\ValueObject\NodeTypes::TYPE_AWARE_NODES) && !$phpDocInfo->hasByAnnotationClasses(\Rector\BetterPhpDocParser\ValueObject\NodeTypes::TYPE_AWARE_DOCTRINE_ANNOTATION_CLASSES)) { + if (!$phpDocInfo->hasByTypes(NodeTypes::TYPE_AWARE_NODES) && !$phpDocInfo->hasByAnnotationClasses(NodeTypes::TYPE_AWARE_DOCTRINE_ANNOTATION_CLASSES)) { return; } - if ($node instanceof \PhpParser\Node\AttributeGroup) { + if ($node instanceof AttributeGroup) { return; } $this->docBlockClassRenamer->renamePhpDocType($phpDocInfo, $oldToNewTypes); $this->phpDocClassRenamer->changeTypeInAnnotationTypes($node, $phpDocInfo, $oldToNewClasses); } - private function shouldSkip(string $newName, \PhpParser\Node\Name $name, ?\PhpParser\Node $parentNode = null) : bool + private function shouldSkip(string $newName, Name $name, ?Node $parentNode = null) : bool { - if ($parentNode instanceof \PhpParser\Node\Expr\StaticCall && $parentNode->class === $name && $this->reflectionProvider->hasClass($newName)) { + if ($parentNode instanceof StaticCall && $parentNode->class === $name && $this->reflectionProvider->hasClass($newName)) { $classReflection = $this->reflectionProvider->getClass($newName); return $classReflection->isInterface(); } // parent is not a Node, possibly removed by other rule // skip change it - if (!$parentNode instanceof \PhpParser\Node) { + if (!$parentNode instanceof Node) { return \true; } - if (!$parentNode instanceof \PhpParser\Node\Stmt\Namespace_) { + if (!$parentNode instanceof Namespace_) { return \false; } if ($parentNode->name !== $name) { return \false; } - $namespaceNewName = \RectorPrefix20220607\Nette\Utils\Strings::before($newName, '\\', -1); + $namespaceNewName = Strings::before($newName, '\\', -1); if ($namespaceNewName === null) { return \false; } @@ -179,7 +179,7 @@ final class ClassRenamer /** * @param array $oldToNewClasses */ - private function refactorName(\PhpParser\Node\Name $name, array $oldToNewClasses) : ?\PhpParser\Node\Name + private function refactorName(Name $name, array $oldToNewClasses) : ?Name { $stringName = $this->nodeNameResolver->getName($name); $newName = $oldToNewClasses[$stringName] ?? null; @@ -189,39 +189,39 @@ final class ClassRenamer if (!$this->isClassToInterfaceValidChange($name, $newName)) { return null; } - $parentNode = $name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $name->getAttribute(AttributeKey::PARENT_NODE); if ($this->shouldSkip($newName, $name, $parentNode)) { return null; } // no need to preslash "use \SomeNamespace" of imported namespace - if ($parentNode instanceof \PhpParser\Node\Stmt\UseUse && ($parentNode->type === \PhpParser\Node\Stmt\Use_::TYPE_NORMAL || $parentNode->type === \PhpParser\Node\Stmt\Use_::TYPE_UNKNOWN)) { + if ($parentNode instanceof UseUse && ($parentNode->type === Use_::TYPE_NORMAL || $parentNode->type === Use_::TYPE_UNKNOWN)) { // no need to rename imports, they will be handled by autoimport and coding standard // also they might cause some rename return null; } $last = $name->getLast(); - $newFullyQualified = new \PhpParser\Node\Name\FullyQualified($newName); + $newFullyQualified = new FullyQualified($newName); $newNameLastName = $newFullyQualified->getLast(); - $importNames = $this->parameterProvider->provideBoolParameter(\Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES); + $importNames = $this->parameterProvider->provideBoolParameter(Option::AUTO_IMPORT_NAMES); if ($this->shouldRemoveUseName($last, $newNameLastName, $importNames)) { $this->removeUseName($name); } - return new \PhpParser\Node\Name\FullyQualified($newName); + return new FullyQualified($newName); } - private function removeUseName(\PhpParser\Node\Name $oldName) : void + private function removeUseName(Name $oldName) : void { - $uses = $this->betterNodeFinder->findFirstPrevious($oldName, function (\PhpParser\Node $node) use($oldName) : bool { - return $node instanceof \PhpParser\Node\Stmt\UseUse && $this->nodeNameResolver->areNamesEqual($node, $oldName); + $uses = $this->betterNodeFinder->findFirstPrevious($oldName, function (Node $node) use($oldName) : bool { + return $node instanceof UseUse && $this->nodeNameResolver->areNamesEqual($node, $oldName); }); - if (!$uses instanceof \PhpParser\Node\Stmt\UseUse) { + if (!$uses instanceof UseUse) { return; } if ($uses->alias !== null) { return; } // ios the only one? Remove whole use instead to avoid "use ;" constructions - $parentUse = $uses->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentUse instanceof \PhpParser\Node\Stmt\Use_ && \count($parentUse->uses) === 1) { + $parentUse = $uses->getAttribute(AttributeKey::PARENT_NODE); + if ($parentUse instanceof Use_ && \count($parentUse->uses) === 1) { $this->nodeRemover->removeNode($parentUse); } else { $this->nodeRemover->removeNode($uses); @@ -230,14 +230,14 @@ final class ClassRenamer /** * @param array $oldToNewClasses */ - private function refactorNamespace(\PhpParser\Node\Stmt\Namespace_ $namespace, array $oldToNewClasses) : ?\PhpParser\Node + private function refactorNamespace(Namespace_ $namespace, array $oldToNewClasses) : ?Node { $name = $this->nodeNameResolver->getName($namespace); if ($name === null) { return null; } $classLike = $this->getClassOfNamespaceToRefactor($namespace, $oldToNewClasses); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + if (!$classLike instanceof ClassLike) { return null; } $currentName = (string) $this->nodeNameResolver->getName($classLike); @@ -248,16 +248,16 @@ final class ClassRenamer $newNamespace = $this->classNaming->getNamespace($newClassFullyQualified); // Renaming to class without namespace (example MyNamespace\DateTime -> DateTimeImmutable) if (!\is_string($newNamespace)) { - $classLike->name = new \PhpParser\Node\Identifier($newClassFullyQualified); + $classLike->name = new Identifier($newClassFullyQualified); return $classLike; } - $namespace->name = new \PhpParser\Node\Name($newNamespace); + $namespace->name = new Name($newNamespace); return $namespace; } /** * @param array $oldToNewClasses */ - private function refactorClassLike(\PhpParser\Node\Stmt\ClassLike $classLike, array $oldToNewClasses) : ?\PhpParser\Node + private function refactorClassLike(ClassLike $classLike, array $oldToNewClasses) : ?Node { // rename interfaces $this->renameClassImplements($classLike, $oldToNewClasses); @@ -277,13 +277,13 @@ final class ClassRenamer if ($this->isClassAboutToBeDuplicated($newName)) { return null; } - $classLike->name = new \PhpParser\Node\Identifier($newClassNamePart); + $classLike->name = new Identifier($newClassNamePart); $classNamingGetNamespace = $this->classNaming->getNamespace($className); // Old class did not have any namespace, we need to wrap class with Namespace_ node if ($newNamespacePart !== null && $classNamingGetNamespace === null) { $this->changeNameToFullyQualifiedName($classLike); - $name = new \PhpParser\Node\Name($newNamespacePart); - return new \PhpParser\Node\Stmt\Namespace_($name, [$classLike]); + $name = new Name($newNamespacePart); + return new Namespace_($name, [$classLike]); } return $classLike; } @@ -299,22 +299,22 @@ final class ClassRenamer * - implements SomeInterface * - implements SomeClass */ - private function isClassToInterfaceValidChange(\PhpParser\Node\Name $name, string $newClassName) : bool + private function isClassToInterfaceValidChange(Name $name, string $newClassName) : bool { if (!$this->reflectionProvider->hasClass($newClassName)) { return \true; } $classReflection = $this->reflectionProvider->getClass($newClassName); // ensure new is not with interface - $parentNode = $name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentNode instanceof \PhpParser\Node\Expr\New_ && $classReflection->isInterface()) { + $parentNode = $name->getAttribute(AttributeKey::PARENT_NODE); + if ($parentNode instanceof New_ && $classReflection->isInterface()) { return \false; } - if ($parentNode instanceof \PhpParser\Node\Stmt\Class_) { + if ($parentNode instanceof Class_) { return $this->isValidClassNameChange($name, $parentNode, $classReflection); } // prevent to change to import, that already exists - if ($parentNode instanceof \PhpParser\Node\Stmt\UseUse) { + if ($parentNode instanceof UseUse) { return $this->isValidUseImportChange($newClassName, $parentNode); } return \true; @@ -322,57 +322,57 @@ final class ClassRenamer /** * @param array $oldToNewClasses */ - private function getClassOfNamespaceToRefactor(\PhpParser\Node\Stmt\Namespace_ $namespace, array $oldToNewClasses) : ?\PhpParser\Node\Stmt\ClassLike + private function getClassOfNamespaceToRefactor(Namespace_ $namespace, array $oldToNewClasses) : ?ClassLike { - $foundClass = $this->betterNodeFinder->findFirst($namespace, function (\PhpParser\Node $node) use($oldToNewClasses) : bool { - if (!$node instanceof \PhpParser\Node\Stmt\ClassLike) { + $foundClass = $this->betterNodeFinder->findFirst($namespace, function (Node $node) use($oldToNewClasses) : bool { + if (!$node instanceof ClassLike) { return \false; } $classLikeName = $this->nodeNameResolver->getName($node); return isset($oldToNewClasses[$classLikeName]); }); - return $foundClass instanceof \PhpParser\Node\Stmt\ClassLike ? $foundClass : null; + return $foundClass instanceof ClassLike ? $foundClass : null; } /** * @param string[] $oldToNewClasses */ - private function renameClassImplements(\PhpParser\Node\Stmt\ClassLike $classLike, array $oldToNewClasses) : void + private function renameClassImplements(ClassLike $classLike, array $oldToNewClasses) : void { - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + if (!$classLike instanceof Class_) { return; } /** @var Scope|null $scope */ - $scope = $classLike->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $classLike->getAttribute(AttributeKey::SCOPE); $classLike->implements = \array_unique($classLike->implements); foreach ($classLike->implements as $key => $implementName) { - $virtualNode = (bool) $implementName->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::VIRTUAL_NODE); + $virtualNode = (bool) $implementName->getAttribute(AttributeKey::VIRTUAL_NODE); if (!$virtualNode) { continue; } - $namespaceName = $scope instanceof \PHPStan\Analyser\Scope ? $scope->getNamespace() : null; + $namespaceName = $scope instanceof Scope ? $scope->getNamespace() : null; $fullyQualifiedName = $namespaceName . '\\' . $implementName->toString(); $newName = $oldToNewClasses[$fullyQualifiedName] ?? null; if ($newName === null) { continue; } - $classLike->implements[$key] = new \PhpParser\Node\Name\FullyQualified($newName); + $classLike->implements[$key] = new FullyQualified($newName); } } private function isClassAboutToBeDuplicated(string $newName) : bool { return $this->reflectionProvider->hasClass($newName); } - private function changeNameToFullyQualifiedName(\PhpParser\Node\Stmt\ClassLike $classLike) : void + private function changeNameToFullyQualifiedName(ClassLike $classLike) : void { - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classLike, function (\PhpParser\Node $node) { - if (!$node instanceof \PhpParser\Node\Name\FullyQualified) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classLike, function (Node $node) { + if (!$node instanceof FullyQualified) { return null; } // invoke override - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); }); } - private function isValidClassNameChange(\PhpParser\Node\Name $name, \PhpParser\Node\Stmt\Class_ $class, \PHPStan\Reflection\ClassReflection $classReflection) : bool + private function isValidClassNameChange(Name $name, Class_ $class, ClassReflection $classReflection) : bool { if ($class->extends === $name) { // is class to interface? @@ -386,14 +386,14 @@ final class ClassRenamer // is interface to class? return !(\in_array($name, $class->implements, \true) && $classReflection->isClass()); } - private function isValidUseImportChange(string $newName, \PhpParser\Node\Stmt\UseUse $useUse) : bool + private function isValidUseImportChange(string $newName, UseUse $useUse) : bool { $uses = $this->useImportsResolver->resolveForNode($useUse); if ($uses === []) { return \true; } foreach ($uses as $use) { - $prefix = $use instanceof \PhpParser\Node\Stmt\GroupUse ? $use->prefix . '\\' : ''; + $prefix = $use instanceof GroupUse ? $use->prefix . '\\' : ''; foreach ($use->uses as $useUse) { if ($prefix . $useUse->name->toString() === $newName) { // name already exists @@ -419,9 +419,9 @@ final class ClassRenamer } $oldToNewTypes = []; foreach ($oldToNewClasses as $oldClass => $newClass) { - $oldObjectType = new \PHPStan\Type\ObjectType($oldClass); - $newObjectType = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($newClass); - $oldToNewTypes[] = new \Rector\NodeTypeResolver\ValueObject\OldToNewType($oldObjectType, $newObjectType); + $oldObjectType = new ObjectType($oldClass); + $newObjectType = new FullyQualifiedObjectType($newClass); + $oldToNewTypes[] = new OldToNewType($oldObjectType, $newObjectType); } $this->oldToNewTypesByCacheKey[$cacheKey] = $oldToNewTypes; return $oldToNewTypes; diff --git a/rules/Renaming/NodeManipulator/SwitchManipulator.php b/rules/Renaming/NodeManipulator/SwitchManipulator.php index 0c450316ba4..37b7bff1c65 100644 --- a/rules/Renaming/NodeManipulator/SwitchManipulator.php +++ b/rules/Renaming/NodeManipulator/SwitchManipulator.php @@ -15,14 +15,14 @@ final class SwitchManipulator public function removeBreakNodes(array $stmts) : array { foreach ($stmts as $key => $node) { - if (!$node instanceof \PhpParser\Node\Stmt\Break_) { + if (!$node instanceof Break_) { continue; } - if (!$node->num instanceof \PhpParser\Node\Scalar\LNumber || $node->num->value === 1) { + if (!$node->num instanceof LNumber || $node->num->value === 1) { unset($stmts[$key]); continue; } - $node->num = $node->num->value === 2 ? null : new \PhpParser\Node\Scalar\LNumber($node->num->value - 1); + $node->num = $node->num->value === 2 ? null : new LNumber($node->num->value - 1); } return $stmts; } diff --git a/rules/Renaming/Rector/ClassConstFetch/RenameClassConstFetchRector.php b/rules/Renaming/Rector/ClassConstFetch/RenameClassConstFetchRector.php index 2364c9df281..fc0645548f3 100644 --- a/rules/Renaming/Rector/ClassConstFetch/RenameClassConstFetchRector.php +++ b/rules/Renaming/Rector/ClassConstFetch/RenameClassConstFetchRector.php @@ -12,21 +12,21 @@ use Rector\Core\Rector\AbstractRector; use Rector\Renaming\Contract\RenameClassConstFetchInterface; use Rector\Renaming\ValueObject\RenameClassAndConstFetch; use Rector\Renaming\ValueObject\RenameClassConstFetch; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector\RenameClassConstFetchRectorTest */ -final class RenameClassConstFetchRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RenameClassConstFetchRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var RenameClassConstFetchInterface[] */ private $renameClassConstFetches = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replaces defined class constants in their calls.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replaces defined class constants in their calls.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' $value = SomeClass::OLD_CONSTANT; $value = SomeClass::OTHER_OLD_CONSTANT; CODE_SAMPLE @@ -34,19 +34,19 @@ CODE_SAMPLE $value = SomeClass::NEW_CONSTANT; $value = DifferentClass::NEW_CONSTANT; CODE_SAMPLE -, [new \Rector\Renaming\ValueObject\RenameClassConstFetch('SomeClass', 'OLD_CONSTANT', 'NEW_CONSTANT'), new \Rector\Renaming\ValueObject\RenameClassAndConstFetch('SomeClass', 'OTHER_OLD_CONSTANT', 'DifferentClass', 'NEW_CONSTANT')])]); +, [new RenameClassConstFetch('SomeClass', 'OLD_CONSTANT', 'NEW_CONSTANT'), new RenameClassAndConstFetch('SomeClass', 'OTHER_OLD_CONSTANT', 'DifferentClass', 'NEW_CONSTANT')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\ClassConstFetch::class]; + return [ClassConstFetch::class]; } /** * @param ClassConstFetch $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Expr\ClassConstFetch + public function refactor(Node $node) : ?ClassConstFetch { foreach ($this->renameClassConstFetches as $renameClassConstFetch) { if (!$this->isObjectType($node->class, $renameClassConstFetch->getOldObjectType())) { @@ -55,10 +55,10 @@ CODE_SAMPLE if (!$this->isName($node->name, $renameClassConstFetch->getOldConstant())) { continue; } - if ($renameClassConstFetch instanceof \Rector\Renaming\ValueObject\RenameClassAndConstFetch) { + if ($renameClassConstFetch instanceof RenameClassAndConstFetch) { return $this->createClassAndConstFetch($renameClassConstFetch); } - $node->name = new \PhpParser\Node\Identifier($renameClassConstFetch->getNewConstant()); + $node->name = new Identifier($renameClassConstFetch->getNewConstant()); return $node; } return null; @@ -68,11 +68,11 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Renaming\Contract\RenameClassConstFetchInterface::class); + Assert::allIsAOf($configuration, RenameClassConstFetchInterface::class); $this->renameClassConstFetches = $configuration; } - private function createClassAndConstFetch(\Rector\Renaming\ValueObject\RenameClassAndConstFetch $renameClassAndConstFetch) : \PhpParser\Node\Expr\ClassConstFetch + private function createClassAndConstFetch(RenameClassAndConstFetch $renameClassAndConstFetch) : ClassConstFetch { - return new \PhpParser\Node\Expr\ClassConstFetch(new \PhpParser\Node\Name\FullyQualified($renameClassAndConstFetch->getNewClass()), new \PhpParser\Node\Identifier($renameClassAndConstFetch->getNewConstant())); + return new ClassConstFetch(new FullyQualified($renameClassAndConstFetch->getNewClass()), new Identifier($renameClassAndConstFetch->getNewConstant())); } } diff --git a/rules/Renaming/Rector/ClassMethod/RenameAnnotationRector.php b/rules/Renaming/Rector/ClassMethod/RenameAnnotationRector.php index 2f71ec6973b..85a7771f2b3 100644 --- a/rules/Renaming/Rector/ClassMethod/RenameAnnotationRector.php +++ b/rules/Renaming/Rector/ClassMethod/RenameAnnotationRector.php @@ -13,13 +13,13 @@ use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockTagReplacer; use Rector\Renaming\Contract\RenameAnnotationInterface; use Rector\Renaming\ValueObject\RenameAnnotationByType; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Renaming\Rector\ClassMethod\RenameAnnotationRector\RenameAnnotationRectorTest */ -final class RenameAnnotationRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RenameAnnotationRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var RenameAnnotationInterface[] @@ -30,13 +30,13 @@ final class RenameAnnotationRector extends \Rector\Core\Rector\AbstractRector im * @var \Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockTagReplacer */ private $docBlockTagReplacer; - public function __construct(\Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockTagReplacer $docBlockTagReplacer) + public function __construct(DocBlockTagReplacer $docBlockTagReplacer) { $this->docBlockTagReplacer = $docBlockTagReplacer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns defined annotations above properties and methods to their new values.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns defined annotations above properties and methods to their new values.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' use PHPUnit\Framework\TestCase; final class SomeTest extends TestCase @@ -62,28 +62,28 @@ final class SomeTest extends TestCase } } CODE_SAMPLE -, [new \Rector\Renaming\ValueObject\RenameAnnotationByType('PHPUnit\\Framework\\TestCase', 'test', 'scenario')])]); +, [new RenameAnnotationByType('PHPUnit\\Framework\\TestCase', 'test', 'scenario')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Property::class, \PhpParser\Node\Stmt\Expression::class]; + return [ClassMethod::class, Property::class, Expression::class]; } /** * @param ClassMethod|Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLike = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$classLike instanceof Class_) { return null; } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $hasChanged = \false; foreach ($this->renameAnnotations as $renameAnnotation) { - if ($renameAnnotation instanceof \Rector\Renaming\ValueObject\RenameAnnotationByType && !$this->isObjectType($classLike, $renameAnnotation->getObjectType())) { + if ($renameAnnotation instanceof RenameAnnotationByType && !$this->isObjectType($classLike, $renameAnnotation->getObjectType())) { continue; } $hasDocBlockChanged = $this->docBlockTagReplacer->replaceTagByAnother($phpDocInfo, $renameAnnotation->getOldAnnotation(), $renameAnnotation->getNewAnnotation()); @@ -101,7 +101,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Renaming\Contract\RenameAnnotationInterface::class); + Assert::allIsAOf($configuration, RenameAnnotationInterface::class); $this->renameAnnotations = $configuration; } } diff --git a/rules/Renaming/Rector/ConstFetch/RenameConstantRector.php b/rules/Renaming/Rector/ConstFetch/RenameConstantRector.php index 6962ebc3de9..daaf0c44996 100644 --- a/rules/Renaming/Rector/ConstFetch/RenameConstantRector.php +++ b/rules/Renaming/Rector/ConstFetch/RenameConstantRector.php @@ -8,21 +8,21 @@ use PhpParser\Node\Expr\ConstFetch; use PhpParser\Node\Name; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Renaming\Rector\ConstFetch\RenameConstantRector\RenameConstantRectorTest */ -final class RenameConstantRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RenameConstantRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var array */ private $oldToNewConstants = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace constant by new ones', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace constant by new ones', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run() @@ -47,18 +47,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\ConstFetch::class]; + return [ConstFetch::class]; } /** * @param ConstFetch $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->oldToNewConstants as $oldConstant => $newConstant) { if (!$this->isName($node->name, $oldConstant)) { continue; } - $node->name = new \PhpParser\Node\Name($newConstant); + $node->name = new Name($newConstant); return $node; } return null; @@ -68,8 +68,8 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString(\array_keys($configuration)); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configuration); + Assert::allString(\array_keys($configuration)); + Assert::allString($configuration); /** @var array $configuration */ $this->oldToNewConstants = $configuration; } diff --git a/rules/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector.php b/rules/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector.php index 508de339a14..5e1eab33da4 100644 --- a/rules/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector.php +++ b/rules/Renaming/Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector.php @@ -19,13 +19,13 @@ use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\NodeTypeResolver\PhpDoc\PhpDocTypeRenamer; use Rector\Renaming\ValueObject\PseudoNamespaceToNamespace; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector\PseudoNamespaceToNamespaceRectorTest */ -final class PseudoNamespaceToNamespaceRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class PseudoNamespaceToNamespaceRector extends AbstractRector implements ConfigurableRectorInterface { /** * @see https://regex101.com/r/chvLgs/1/ @@ -45,13 +45,13 @@ final class PseudoNamespaceToNamespaceRector extends \Rector\Core\Rector\Abstrac * @var \Rector\NodeTypeResolver\PhpDoc\PhpDocTypeRenamer */ private $phpDocTypeRenamer; - public function __construct(\Rector\NodeTypeResolver\PhpDoc\PhpDocTypeRenamer $phpDocTypeRenamer) + public function __construct(PhpDocTypeRenamer $phpDocTypeRenamer) { $this->phpDocTypeRenamer = $phpDocTypeRenamer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replaces defined Pseudo_Namespaces by Namespace\\Ones.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replaces defined Pseudo_Namespaces by Namespace\\Ones.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' /** @var Some_Chicken $someService */ $someService = new Some_Chicken; $someClassToKeep = new Some_Class_To_Keep; @@ -61,7 +61,7 @@ CODE_SAMPLE $someService = new Some\Chicken; $someClassToKeep = new Some_Class_To_Keep; CODE_SAMPLE -, [new \Rector\Renaming\ValueObject\PseudoNamespaceToNamespace('Some_', ['Some_Class_To_Keep'])])]); +, [new PseudoNamespaceToNamespace('Some_', ['Some_Class_To_Keep'])])]); } /** * @return array> @@ -69,15 +69,15 @@ CODE_SAMPLE public function getNodeTypes() : array { // property, method - return [\Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace::class, \PhpParser\Node\Stmt\Namespace_::class]; + return [FileWithoutNamespace::class, Namespace_::class]; } /** * @param Namespace_|FileWithoutNamespace $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $this->newNamespace = null; - if ($node instanceof \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace) { + if ($node instanceof FileWithoutNamespace) { $changedStmts = $this->refactorStmts($node->stmts); if ($changedStmts === null) { return null; @@ -85,10 +85,10 @@ CODE_SAMPLE $node->stmts = $changedStmts; // add a new namespace? if ($this->newNamespace !== null) { - return new \PhpParser\Node\Stmt\Namespace_(new \PhpParser\Node\Name($this->newNamespace), $changedStmts); + return new Namespace_(new Name($this->newNamespace), $changedStmts); } } - if ($node instanceof \PhpParser\Node\Stmt\Namespace_) { + if ($node instanceof Namespace_) { return $this->refactorNamespace($node); } return null; @@ -98,7 +98,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Renaming\ValueObject\PseudoNamespaceToNamespace::class); + Assert::allIsAOf($configuration, PseudoNamespaceToNamespace::class); $this->pseudoNamespacesToNamespaces = $configuration; } /** @@ -108,17 +108,17 @@ CODE_SAMPLE private function refactorStmts(array $stmts) : ?array { $hasChanged = \false; - $this->traverseNodesWithCallable($stmts, function (\PhpParser\Node $node) use(&$hasChanged) : ?Node { - if (!$node instanceof \PhpParser\Node\Name && !$node instanceof \PhpParser\Node\Identifier && !$node instanceof \PhpParser\Node\Stmt\Property && !$node instanceof \PhpParser\Node\FunctionLike) { + $this->traverseNodesWithCallable($stmts, function (Node $node) use(&$hasChanged) : ?Node { + if (!$node instanceof Name && !$node instanceof Identifier && !$node instanceof Property && !$node instanceof FunctionLike) { return null; } if ($this->refactorPhpDoc($node)) { $hasChanged = \true; } // @todo - update rule to allow for bool instanceof check - if ($node instanceof \PhpParser\Node\Name || $node instanceof \PhpParser\Node\Identifier) { + if ($node instanceof Name || $node instanceof Identifier) { $changedNode = $this->processNameOrIdentifier($node); - if ($changedNode instanceof \PhpParser\Node) { + if ($changedNode instanceof Node) { $hasChanged = \true; return $changedNode; } @@ -134,7 +134,7 @@ CODE_SAMPLE * @return Identifier|Name|null * @param \PhpParser\Node\Name|\PhpParser\Node\Identifier $node */ - private function processNameOrIdentifier($node) : ?\PhpParser\Node + private function processNameOrIdentifier($node) : ?Node { // no name → skip if ($node->toString() === '') { @@ -148,23 +148,23 @@ CODE_SAMPLE if ($excludedClasses !== [] && $this->isNames($node, $excludedClasses)) { return null; } - if ($node instanceof \PhpParser\Node\Name) { + if ($node instanceof Name) { return $this->processName($node); } return $this->processIdentifier($node); } return null; } - private function processName(\PhpParser\Node\Name $name) : \PhpParser\Node\Name + private function processName(Name $name) : Name { $nodeName = $this->getName($name); $name->parts = \explode('_', $nodeName); return $name; } - private function processIdentifier(\PhpParser\Node\Identifier $identifier) : ?\PhpParser\Node\Identifier + private function processIdentifier(Identifier $identifier) : ?Identifier { - $parentNode = $identifier->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node\Stmt\Class_) { + $parentNode = $identifier->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof Class_) { return null; } $name = $this->getName($identifier); @@ -172,18 +172,18 @@ CODE_SAMPLE return null; } /** @var string $namespaceName */ - $namespaceName = \RectorPrefix20220607\Nette\Utils\Strings::before($name, '_', -1); + $namespaceName = Strings::before($name, '_', -1); /** @var string $lastNewNamePart */ - $lastNewNamePart = \RectorPrefix20220607\Nette\Utils\Strings::after($name, '_', -1); - $newNamespace = \RectorPrefix20220607\Nette\Utils\Strings::replace($namespaceName, self::SPLIT_BY_UNDERSCORE_REGEX, '$1$2\\\\$4'); + $lastNewNamePart = Strings::after($name, '_', -1); + $newNamespace = Strings::replace($namespaceName, self::SPLIT_BY_UNDERSCORE_REGEX, '$1$2\\\\$4'); if ($this->newNamespace !== null && $this->newNamespace !== $newNamespace) { - throw new \Rector\Core\Exception\ShouldNotHappenException('There cannot be 2 different namespaces in one file'); + throw new ShouldNotHappenException('There cannot be 2 different namespaces in one file'); } $this->newNamespace = $newNamespace; $identifier->name = $lastNewNamePart; return $identifier; } - private function refactorNamespace(\PhpParser\Node\Stmt\Namespace_ $namespace) : ?\PhpParser\Node\Stmt\Namespace_ + private function refactorNamespace(Namespace_ $namespace) : ?Namespace_ { $changedStmts = $this->refactorStmts($namespace->stmts); if ($changedStmts === null) { diff --git a/rules/Renaming/Rector/FuncCall/RenameFunctionRector.php b/rules/Renaming/Rector/FuncCall/RenameFunctionRector.php index a876587e6db..329493e44d1 100644 --- a/rules/Renaming/Rector/FuncCall/RenameFunctionRector.php +++ b/rules/Renaming/Rector/FuncCall/RenameFunctionRector.php @@ -10,40 +10,40 @@ use PhpParser\Node\Name\FullyQualified; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Renaming\Rector\FuncCall\RenameFunctionRector\RenameFunctionRectorTest */ -final class RenameFunctionRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RenameFunctionRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var array */ private $oldFunctionToNewFunction = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns defined function call new one.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample('view("...", []);', 'Laravel\\Templating\\render("...", []);', ['view' => 'Laravel\\Templating\\render'])]); + return new RuleDefinition('Turns defined function call new one.', [new ConfiguredCodeSample('view("...", []);', 'Laravel\\Templating\\render("...", []);', ['view' => 'Laravel\\Templating\\render'])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->oldFunctionToNewFunction as $oldFunction => $newFunction) { if (!$this->isName($node, $oldFunction)) { continue; } // not to refactor here - $isVirtual = (bool) $node->name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::VIRTUAL_NODE); + $isVirtual = (bool) $node->name->getAttribute(AttributeKey::VIRTUAL_NODE); if ($isVirtual) { continue; } @@ -57,15 +57,15 @@ final class RenameFunctionRector extends \Rector\Core\Rector\AbstractRector impl */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString(\array_values($configuration)); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configuration); + Assert::allString(\array_values($configuration)); + Assert::allString($configuration); $this->oldFunctionToNewFunction = $configuration; } - private function createName(string $newFunction) : \PhpParser\Node\Name + private function createName(string $newFunction) : Name { if (\strpos($newFunction, '\\') !== \false) { - return new \PhpParser\Node\Name\FullyQualified($newFunction); + return new FullyQualified($newFunction); } - return new \PhpParser\Node\Name($newFunction); + return new Name($newFunction); } } diff --git a/rules/Renaming/Rector/MethodCall/RenameMethodRector.php b/rules/Renaming/Rector/MethodCall/RenameMethodRector.php index 73dfb5d9b9e..3438f0e3182 100644 --- a/rules/Renaming/Rector/MethodCall/RenameMethodRector.php +++ b/rules/Renaming/Rector/MethodCall/RenameMethodRector.php @@ -22,13 +22,13 @@ use Rector\Renaming\Collector\MethodCallRenameCollector; use Rector\Renaming\Contract\MethodCallRenameInterface; use Rector\Renaming\ValueObject\MethodCallRename; use Rector\Renaming\ValueObject\MethodCallRenameWithArrayKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Renaming\Rector\MethodCall\RenameMethodRector\RenameMethodRectorTest */ -final class RenameMethodRector extends \Rector\Core\Rector\AbstractScopeAwareRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RenameMethodRector extends AbstractScopeAwareRector implements ConfigurableRectorInterface { /** * @var MethodCallRenameInterface[] @@ -54,16 +54,16 @@ final class RenameMethodRector extends \Rector\Core\Rector\AbstractScopeAwareRec * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\Core\NodeManipulator\ClassManipulator $classManipulator, \Rector\Renaming\Collector\MethodCallRenameCollector $methodCallRenameCollector, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ClassManipulator $classManipulator, MethodCallRenameCollector $methodCallRenameCollector, ReflectionResolver $reflectionResolver, ReflectionProvider $reflectionProvider) { $this->classManipulator = $classManipulator; $this->methodCallRenameCollector = $methodCallRenameCollector; $this->reflectionResolver = $reflectionResolver; $this->reflectionProvider = $reflectionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns method names to new ones.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns method names to new ones.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' $someObject = new SomeExampleClass; $someObject->oldMethod(); CODE_SAMPLE @@ -71,19 +71,19 @@ CODE_SAMPLE $someObject = new SomeExampleClass; $someObject->newMethod(); CODE_SAMPLE -, [new \Rector\Renaming\ValueObject\MethodCallRename('SomeExampleClass', 'oldMethod', 'newMethod')])]); +, [new MethodCallRename('SomeExampleClass', 'oldMethod', 'newMethod')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class, \PhpParser\Node\Stmt\ClassMethod::class]; + return [MethodCall::class, StaticCall::class, ClassMethod::class]; } /** * @param MethodCall|StaticCall|ClassMethod $node */ - public function refactorWithScope(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : ?\PhpParser\Node + public function refactorWithScope(Node $node, Scope $scope) : ?Node { $classReflection = $scope->getClassReflection(); foreach ($this->methodCallRenames as $methodCallRename) { @@ -99,9 +99,9 @@ CODE_SAMPLE if ($this->shouldSkipClassMethod($node, $methodCallRename)) { continue; } - $node->name = new \PhpParser\Node\Identifier($methodCallRename->getNewMethod()); - if ($methodCallRename instanceof \Rector\Renaming\ValueObject\MethodCallRenameWithArrayKey && !$node instanceof \PhpParser\Node\Stmt\ClassMethod) { - return new \PhpParser\Node\Expr\ArrayDimFetch($node, \PhpParser\BuilderHelpers::normalizeValue($methodCallRename->getArrayKey())); + $node->name = new Identifier($methodCallRename->getNewMethod()); + if ($methodCallRename instanceof MethodCallRenameWithArrayKey && !$node instanceof ClassMethod) { + return new ArrayDimFetch($node, BuilderHelpers::normalizeValue($methodCallRename->getArrayKey())); } return $node; } @@ -112,18 +112,18 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Renaming\Contract\MethodCallRenameInterface::class); + Assert::allIsAOf($configuration, MethodCallRenameInterface::class); $this->methodCallRenames = $configuration; $this->methodCallRenameCollector->addMethodCallRenames($configuration); } /** * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Stmt\ClassMethod $node */ - private function shouldSkipClassMethod($node, \Rector\Renaming\Contract\MethodCallRenameInterface $methodCallRename) : bool + private function shouldSkipClassMethod($node, MethodCallRenameInterface $methodCallRename) : bool { - if (!$node instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$node instanceof ClassMethod) { $classReflection = $this->reflectionResolver->resolveClassReflectionSourceObject($node); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } $targetClass = $methodCallRename->getClass(); @@ -142,10 +142,10 @@ CODE_SAMPLE } return $this->shouldSkipForAlreadyExistingClassMethod($node, $methodCallRename); } - private function shouldSkipForAlreadyExistingClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod, \Rector\Renaming\Contract\MethodCallRenameInterface $methodCallRename) : bool + private function shouldSkipForAlreadyExistingClassMethod(ClassMethod $classMethod, MethodCallRenameInterface $methodCallRename) : bool { - $classLike = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($classMethod, ClassLike::class); + if (!$classLike instanceof ClassLike) { return \false; } return (bool) $classLike->getMethod($methodCallRename->getNewMethod()); @@ -153,12 +153,12 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $node */ - private function shouldKeepForParentInterface(\Rector\Renaming\Contract\MethodCallRenameInterface $methodCallRename, $node, ?\PHPStan\Reflection\ClassReflection $classReflection) : bool + private function shouldKeepForParentInterface(MethodCallRenameInterface $methodCallRename, $node, ?ClassReflection $classReflection) : bool { - if (!$node instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$node instanceof ClassMethod) { return \false; } - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } // interface can change current method, as parent contract is still valid diff --git a/rules/Renaming/Rector/Name/RenameClassRector.php b/rules/Renaming/Rector/Name/RenameClassRector.php index 6ab687742ac..1af0be8bcaf 100644 --- a/rules/Renaming/Rector/Name/RenameClassRector.php +++ b/rules/Renaming/Rector/Name/RenameClassRector.php @@ -18,13 +18,13 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace; use Rector\Core\Rector\AbstractRector; use Rector\Renaming\NodeManipulator\ClassRenamer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Renaming\Rector\Name\RenameClassRector\RenameClassRectorTest */ -final class RenameClassRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RenameClassRector extends AbstractRector implements ConfigurableRectorInterface { /** * @readonly @@ -41,15 +41,15 @@ final class RenameClassRector extends \Rector\Core\Rector\AbstractRector impleme * @var \Rector\Core\Configuration\RectorConfigProvider */ private $rectorConfigProvider; - public function __construct(\Rector\Core\Configuration\RenamedClassesDataCollector $renamedClassesDataCollector, \Rector\Renaming\NodeManipulator\ClassRenamer $classRenamer, \Rector\Core\Configuration\RectorConfigProvider $rectorConfigProvider) + public function __construct(RenamedClassesDataCollector $renamedClassesDataCollector, ClassRenamer $classRenamer, RectorConfigProvider $rectorConfigProvider) { $this->renamedClassesDataCollector = $renamedClassesDataCollector; $this->classRenamer = $classRenamer; $this->rectorConfigProvider = $rectorConfigProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replaces defined classes by new ones.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replaces defined classes by new ones.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' namespace App; use SomeOldClass; @@ -80,18 +80,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Name::class, \PhpParser\Node\Stmt\Property::class, \PhpParser\Node\FunctionLike::class, \PhpParser\Node\Stmt\Expression::class, \PhpParser\Node\Stmt\ClassLike::class, \PhpParser\Node\Stmt\Namespace_::class, \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace::class, \PhpParser\Node\Stmt\Use_::class]; + return [Name::class, Property::class, FunctionLike::class, Expression::class, ClassLike::class, Namespace_::class, FileWithoutNamespace::class, Use_::class]; } /** * @param FunctionLike|Name|ClassLike|Expression|Namespace_|Property|FileWithoutNamespace|Use_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $oldToNewClasses = $this->renamedClassesDataCollector->getOldToNewClasses(); if ($oldToNewClasses === []) { return null; } - if (!$node instanceof \PhpParser\Node\Stmt\Use_) { + if (!$node instanceof Use_) { return $this->classRenamer->renameNode($node, $oldToNewClasses); } if (!$this->rectorConfigProvider->shouldImportNames()) { @@ -104,17 +104,17 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configuration); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString(\array_keys($configuration)); + Assert::allString($configuration); + Assert::allString(\array_keys($configuration)); $this->addOldToNewClasses($configuration); } /** * @param array $oldToNewClasses */ - private function processCleanUpUse(\PhpParser\Node\Stmt\Use_ $use, array $oldToNewClasses) : ?\PhpParser\Node\Stmt\Use_ + private function processCleanUpUse(Use_ $use, array $oldToNewClasses) : ?Use_ { foreach ($use->uses as $useUse) { - if (!$useUse->alias instanceof \PhpParser\Node\Identifier && isset($oldToNewClasses[$useUse->name->toString()])) { + if (!$useUse->alias instanceof Identifier && isset($oldToNewClasses[$useUse->name->toString()])) { $this->removeNode($use); return $use; } @@ -126,8 +126,8 @@ CODE_SAMPLE */ private function addOldToNewClasses(array $oldToNewClasses) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString(\array_keys($oldToNewClasses)); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($oldToNewClasses); + Assert::allString(\array_keys($oldToNewClasses)); + Assert::allString($oldToNewClasses); $this->renamedClassesDataCollector->addOldToNewClasses($oldToNewClasses); } } diff --git a/rules/Renaming/Rector/Namespace_/RenameNamespaceRector.php b/rules/Renaming/Rector/Namespace_/RenameNamespaceRector.php index cd7222bed5e..e9a5948080f 100644 --- a/rules/Renaming/Rector/Namespace_/RenameNamespaceRector.php +++ b/rules/Renaming/Rector/Namespace_/RenameNamespaceRector.php @@ -22,18 +22,18 @@ use Rector\Naming\NamespaceMatcher; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockNamespaceRenamer; use Rector\Renaming\ValueObject\RenamedNamespace; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Renaming\Rector\Namespace_\RenameNamespaceRector\RenameNamespaceRectorTest */ -final class RenameNamespaceRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RenameNamespaceRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var array> */ - private const ONLY_CHANGE_DOCBLOCK_NODE = [\PhpParser\Node\Stmt\Property::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Stmt\Expression::class, \PhpParser\Node\Stmt\ClassLike::class, \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace::class]; + private const ONLY_CHANGE_DOCBLOCK_NODE = [Property::class, ClassMethod::class, Function_::class, Expression::class, ClassLike::class, FileWithoutNamespace::class]; /** * @var array */ @@ -52,14 +52,14 @@ final class RenameNamespaceRector extends \Rector\Core\Rector\AbstractRector imp * @var \Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockNamespaceRenamer */ private $docBlockNamespaceRenamer; - public function __construct(\Rector\Naming\NamespaceMatcher $namespaceMatcher, \Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockNamespaceRenamer $docBlockNamespaceRenamer) + public function __construct(NamespaceMatcher $namespaceMatcher, DocBlockNamespaceRenamer $docBlockNamespaceRenamer) { $this->namespaceMatcher = $namespaceMatcher; $this->docBlockNamespaceRenamer = $docBlockNamespaceRenamer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replaces old namespace by new one.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample('$someObject = new SomeOldNamespace\\SomeClass;', '$someObject = new SomeNewNamespace\\SomeClass;', ['SomeOldNamespace' => 'SomeNewNamespace'])]); + return new RuleDefinition('Replaces old namespace by new one.', [new ConfiguredCodeSample('$someObject = new SomeOldNamespace\\SomeClass;', '$someObject = new SomeNewNamespace\\SomeClass;', ['SomeOldNamespace' => 'SomeNewNamespace'])]); } /** * @return array> @@ -67,12 +67,12 @@ final class RenameNamespaceRector extends \Rector\Core\Rector\AbstractRector imp public function getNodeTypes() : array { $item3Unpacked = self::ONLY_CHANGE_DOCBLOCK_NODE; - return \array_merge([\PhpParser\Node\Stmt\Namespace_::class, \PhpParser\Node\Stmt\Use_::class, \PhpParser\Node\Name::class], $item3Unpacked); + return \array_merge([Namespace_::class, Use_::class, Name::class], $item3Unpacked); } /** * @param Namespace_|Use_|Name|Property|ClassMethod|Function_|Expression|ClassLike|FileWithoutNamespace $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (\in_array(\get_class($node), self::ONLY_CHANGE_DOCBLOCK_NODE, \true)) { /** @var Property|ClassMethod|Function_|Expression|ClassLike|FileWithoutNamespace $node */ @@ -84,32 +84,32 @@ final class RenameNamespaceRector extends \Rector\Core\Rector\AbstractRector imp return null; } $renamedNamespaceValueObject = $this->namespaceMatcher->matchRenamedNamespace($name, $this->oldToNewNamespaces); - if (!$renamedNamespaceValueObject instanceof \Rector\Renaming\ValueObject\RenamedNamespace) { + if (!$renamedNamespaceValueObject instanceof RenamedNamespace) { return null; } if ($this->isClassFullyQualifiedName($node)) { return null; } - if ($node instanceof \PhpParser\Node\Stmt\Namespace_) { + if ($node instanceof Namespace_) { $newName = $renamedNamespaceValueObject->getNameInNewNamespace(); - $node->name = new \PhpParser\Node\Name($newName); + $node->name = new Name($newName); $this->isChangedInNamespaces[$newName] = \true; return $node; } - if ($node instanceof \PhpParser\Node\Stmt\Use_) { + if ($node instanceof Use_) { $newName = $renamedNamespaceValueObject->getNameInNewNamespace(); - $node->uses[0]->name = new \PhpParser\Node\Name($newName); + $node->uses[0]->name = new Name($newName); return $node; } - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); // already resolved above - if ($parent instanceof \PhpParser\Node\Stmt\Namespace_) { + if ($parent instanceof Namespace_) { return null; } - if (!$parent instanceof \PhpParser\Node\Stmt\UseUse) { + if (!$parent instanceof UseUse) { return $this->processFullyQualified($node, $renamedNamespaceValueObject); } - if ($parent->type !== \PhpParser\Node\Stmt\Use_::TYPE_UNKNOWN) { + if ($parent->type !== Use_::TYPE_UNKNOWN) { return $this->processFullyQualified($node, $renamedNamespaceValueObject); } return null; @@ -119,12 +119,12 @@ final class RenameNamespaceRector extends \Rector\Core\Rector\AbstractRector imp */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allStringNotEmpty(\array_keys($configuration)); - \RectorPrefix20220607\Webmozart\Assert\Assert::allStringNotEmpty($configuration); + Assert::allStringNotEmpty(\array_keys($configuration)); + Assert::allStringNotEmpty($configuration); /** @var array $configuration */ $this->oldToNewNamespaces = $configuration; } - private function processFullyQualified(\PhpParser\Node\Name $name, \Rector\Renaming\ValueObject\RenamedNamespace $renamedNamespace) : ?\PhpParser\Node\Name\FullyQualified + private function processFullyQualified(Name $name, RenamedNamespace $renamedNamespace) : ?FullyQualified { if (\strncmp($name->toString(), $renamedNamespace->getNewNamespace() . '\\', \strlen($renamedNamespace->getNewNamespace() . '\\')) === 0) { return null; @@ -132,10 +132,10 @@ final class RenameNamespaceRector extends \Rector\Core\Rector\AbstractRector imp $nameInNewNamespace = $renamedNamespace->getNameInNewNamespace(); $values = \array_values($this->oldToNewNamespaces); if (!isset($this->isChangedInNamespaces[$nameInNewNamespace])) { - return new \PhpParser\Node\Name\FullyQualified($nameInNewNamespace); + return new FullyQualified($nameInNewNamespace); } if (!\in_array($nameInNewNamespace, $values, \true)) { - return new \PhpParser\Node\Name\FullyQualified($nameInNewNamespace); + return new FullyQualified($nameInNewNamespace); } return null; } @@ -143,13 +143,13 @@ final class RenameNamespaceRector extends \Rector\Core\Rector\AbstractRector imp * Checks for "new \ClassNoNamespace;" * This should be skipped, not a namespace. */ - private function isClassFullyQualifiedName(\PhpParser\Node $node) : bool + private function isClassFullyQualifiedName(Node $node) : bool { - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node) { + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof Node) { return \false; } - if (!$parentNode instanceof \PhpParser\Node\Expr\New_) { + if (!$parentNode instanceof New_) { return \false; } /** @var FullyQualified $fullyQualifiedNode */ diff --git a/rules/Renaming/Rector/PropertyFetch/RenamePropertyRector.php b/rules/Renaming/Rector/PropertyFetch/RenamePropertyRector.php index 271a14319e2..d97f893b45c 100644 --- a/rules/Renaming/Rector/PropertyFetch/RenamePropertyRector.php +++ b/rules/Renaming/Rector/PropertyFetch/RenamePropertyRector.php @@ -15,35 +15,35 @@ use PHPStan\Type\ThisType; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Renaming\ValueObject\RenameProperty; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Renaming\Rector\PropertyFetch\RenamePropertyRector\RenamePropertyRectorTest */ -final class RenamePropertyRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RenamePropertyRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var RenameProperty[] */ private $renamedProperties = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replaces defined old properties by new ones.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample('$someObject->someOldProperty;', '$someObject->someNewProperty;', [new \Rector\Renaming\ValueObject\RenameProperty('SomeClass', 'someOldProperty', 'someNewProperty')])]); + return new RuleDefinition('Replaces defined old properties by new ones.', [new ConfiguredCodeSample('$someObject->someOldProperty;', '$someObject->someNewProperty;', [new RenameProperty('SomeClass', 'someOldProperty', 'someNewProperty')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\PropertyFetch::class, \PhpParser\Node\Stmt\ClassLike::class]; + return [PropertyFetch::class, ClassLike::class]; } /** * @param PropertyFetch|ClassLike $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Stmt\ClassLike) { + if ($node instanceof ClassLike) { return $this->processFromClassLike($node); } return $this->processFromPropertyFetch($node); @@ -53,41 +53,41 @@ final class RenamePropertyRector extends \Rector\Core\Rector\AbstractRector impl */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Renaming\ValueObject\RenameProperty::class); + Assert::allIsAOf($configuration, RenameProperty::class); $this->renamedProperties = $configuration; } - private function processFromClassLike(\PhpParser\Node\Stmt\ClassLike $classLike) : \PhpParser\Node\Stmt\ClassLike + private function processFromClassLike(ClassLike $classLike) : ClassLike { foreach ($this->renamedProperties as $renamedProperty) { $this->renameProperty($classLike, $renamedProperty); } return $classLike; } - private function renameProperty(\PhpParser\Node\Stmt\ClassLike $classLike, \Rector\Renaming\ValueObject\RenameProperty $renameProperty) : void + private function renameProperty(ClassLike $classLike, RenameProperty $renameProperty) : void { $classLikeName = (string) $this->nodeNameResolver->getName($classLike); $renamePropertyObjectType = $renameProperty->getObjectType(); $className = $renamePropertyObjectType->getClassName(); - $classLikeNameObjectType = new \PHPStan\Type\ObjectType($classLikeName); - $classNameObjectType = new \PHPStan\Type\ObjectType($className); + $classLikeNameObjectType = new ObjectType($classLikeName); + $classNameObjectType = new ObjectType($className); $isSuperType = $classNameObjectType->isSuperTypeOf($classLikeNameObjectType)->yes(); if ($classLikeName !== $className && !$isSuperType) { return; } $property = $classLike->getProperty($renameProperty->getOldProperty()); - if (!$property instanceof \PhpParser\Node\Stmt\Property) { + if (!$property instanceof Property) { return; } $newProperty = $renameProperty->getNewProperty(); $targetNewProperty = $classLike->getProperty($newProperty); - if ($targetNewProperty instanceof \PhpParser\Node\Stmt\Property) { + if ($targetNewProperty instanceof Property) { return; } - $property->props[0]->name = new \PhpParser\Node\VarLikeIdentifier($newProperty); + $property->props[0]->name = new VarLikeIdentifier($newProperty); } - private function processFromPropertyFetch(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : ?\PhpParser\Node\Expr\PropertyFetch + private function processFromPropertyFetch(PropertyFetch $propertyFetch) : ?PropertyFetch { - $class = $this->betterNodeFinder->findParentType($propertyFetch, \PhpParser\Node\Stmt\Class_::class); + $class = $this->betterNodeFinder->findParentType($propertyFetch, Class_::class); foreach ($this->renamedProperties as $renamedProperty) { if (!$this->isObjectType($propertyFetch->var, $renamedProperty->getObjectType())) { continue; @@ -97,10 +97,10 @@ final class RenamePropertyRector extends \Rector\Core\Rector\AbstractRector impl continue; } $nodeVarType = $this->nodeTypeResolver->getType($propertyFetch->var); - if ($nodeVarType instanceof \PHPStan\Type\ThisType && $class instanceof \PhpParser\Node\Stmt\ClassLike) { + if ($nodeVarType instanceof ThisType && $class instanceof ClassLike) { $this->renameProperty($class, $renamedProperty); } - $propertyFetch->name = new \PhpParser\Node\Identifier($renamedProperty->getNewProperty()); + $propertyFetch->name = new Identifier($renamedProperty->getNewProperty()); return $propertyFetch; } return null; diff --git a/rules/Renaming/Rector/StaticCall/RenameStaticMethodRector.php b/rules/Renaming/Rector/StaticCall/RenameStaticMethodRector.php index 0bc301a3e5c..d0bb9eaf252 100644 --- a/rules/Renaming/Rector/StaticCall/RenameStaticMethodRector.php +++ b/rules/Renaming/Rector/StaticCall/RenameStaticMethodRector.php @@ -10,33 +10,33 @@ use PhpParser\Node\Name\FullyQualified; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Renaming\ValueObject\RenameStaticMethod; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Renaming\Rector\StaticCall\RenameStaticMethodRector\RenameStaticMethodRectorTest */ -final class RenameStaticMethodRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RenameStaticMethodRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var RenameStaticMethod[] */ private $staticMethodRenames = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns method names to new ones.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample('SomeClass::oldStaticMethod();', 'AnotherExampleClass::newStaticMethod();', [new \Rector\Renaming\ValueObject\RenameStaticMethod('SomeClass', 'oldMethod', 'AnotherExampleClass', 'newStaticMethod')])]); + return new RuleDefinition('Turns method names to new ones.', [new ConfiguredCodeSample('SomeClass::oldStaticMethod();', 'AnotherExampleClass::newStaticMethod();', [new RenameStaticMethod('SomeClass', 'oldMethod', 'AnotherExampleClass', 'newStaticMethod')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class]; + return [StaticCall::class]; } /** * @param StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->staticMethodRenames as $staticMethodRename) { if (!$this->isObjectType($node->class, $staticMethodRename->getOldObjectType())) { @@ -54,14 +54,14 @@ final class RenameStaticMethodRector extends \Rector\Core\Rector\AbstractRector */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Renaming\ValueObject\RenameStaticMethod::class); + Assert::allIsAOf($configuration, RenameStaticMethod::class); $this->staticMethodRenames = $configuration; } - private function rename(\PhpParser\Node\Expr\StaticCall $staticCall, \Rector\Renaming\ValueObject\RenameStaticMethod $renameStaticMethod) : \PhpParser\Node\Expr\StaticCall + private function rename(StaticCall $staticCall, RenameStaticMethod $renameStaticMethod) : StaticCall { - $staticCall->name = new \PhpParser\Node\Identifier($renameStaticMethod->getNewMethod()); + $staticCall->name = new Identifier($renameStaticMethod->getNewMethod()); if ($renameStaticMethod->hasClassChanged()) { - $staticCall->class = new \PhpParser\Node\Name\FullyQualified($renameStaticMethod->getNewClass()); + $staticCall->class = new FullyQualified($renameStaticMethod->getNewClass()); } return $staticCall; } diff --git a/rules/Renaming/Rector/String_/RenameStringRector.php b/rules/Renaming/Rector/String_/RenameStringRector.php index 3f5b3574a64..3136a5f331c 100644 --- a/rules/Renaming/Rector/String_/RenameStringRector.php +++ b/rules/Renaming/Rector/String_/RenameStringRector.php @@ -7,23 +7,23 @@ use PhpParser\Node; use PhpParser\Node\Scalar\String_; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @changelog https://github.com/symfony/symfony/pull/35858 * * @see \Rector\Tests\Renaming\Rector\String_\RenameStringRector\RenameStringRectorTest */ -final class RenameStringRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RenameStringRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var array */ private $stringChanges = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change string value', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change string value', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -48,18 +48,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Scalar\String_::class]; + return [String_::class]; } /** * @param String_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->stringChanges as $oldValue => $newValue) { if (!$this->valueResolver->isValue($node, $oldValue)) { continue; } - return new \PhpParser\Node\Scalar\String_($newValue); + return new String_($newValue); } return null; } @@ -68,8 +68,8 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString(\array_keys($configuration)); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configuration); + Assert::allString(\array_keys($configuration)); + Assert::allString($configuration); $this->stringChanges = $configuration; } } diff --git a/rules/Renaming/ValueObject/MethodCallRename.php b/rules/Renaming/ValueObject/MethodCallRename.php index a2fd83b6443..2621990474f 100644 --- a/rules/Renaming/ValueObject/MethodCallRename.php +++ b/rules/Renaming/ValueObject/MethodCallRename.php @@ -6,7 +6,7 @@ namespace Rector\Renaming\ValueObject; use PHPStan\Type\ObjectType; use Rector\Core\Validation\RectorAssert; use Rector\Renaming\Contract\MethodCallRenameInterface; -final class MethodCallRename implements \Rector\Renaming\Contract\MethodCallRenameInterface +final class MethodCallRename implements MethodCallRenameInterface { /** * @readonly @@ -28,15 +28,15 @@ final class MethodCallRename implements \Rector\Renaming\Contract\MethodCallRena $this->class = $class; $this->oldMethod = $oldMethod; $this->newMethod = $newMethod; - \Rector\Core\Validation\RectorAssert::className($class); + RectorAssert::className($class); } public function getClass() : string { return $this->class; } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->class); + return new ObjectType($this->class); } public function getOldMethod() : string { diff --git a/rules/Renaming/ValueObject/MethodCallRenameWithArrayKey.php b/rules/Renaming/ValueObject/MethodCallRenameWithArrayKey.php index 4addb8682e6..b9f30aa7fcd 100644 --- a/rules/Renaming/ValueObject/MethodCallRenameWithArrayKey.php +++ b/rules/Renaming/ValueObject/MethodCallRenameWithArrayKey.php @@ -6,7 +6,7 @@ namespace Rector\Renaming\ValueObject; use PHPStan\Type\ObjectType; use Rector\Core\Validation\RectorAssert; use Rector\Renaming\Contract\MethodCallRenameInterface; -final class MethodCallRenameWithArrayKey implements \Rector\Renaming\Contract\MethodCallRenameInterface +final class MethodCallRenameWithArrayKey implements MethodCallRenameInterface { /** * @readonly @@ -36,15 +36,15 @@ final class MethodCallRenameWithArrayKey implements \Rector\Renaming\Contract\Me $this->oldMethod = $oldMethod; $this->newMethod = $newMethod; $this->arrayKey = $arrayKey; - \Rector\Core\Validation\RectorAssert::className($class); + RectorAssert::className($class); } public function getClass() : string { return $this->class; } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->class); + return new ObjectType($this->class); } public function getOldMethod() : string { diff --git a/rules/Renaming/ValueObject/RenameAnnotation.php b/rules/Renaming/ValueObject/RenameAnnotation.php index 59b08c67e77..396c0d88f5a 100644 --- a/rules/Renaming/ValueObject/RenameAnnotation.php +++ b/rules/Renaming/ValueObject/RenameAnnotation.php @@ -7,7 +7,7 @@ use Rector\Renaming\Contract\RenameAnnotationInterface; /** * @api */ -final class RenameAnnotation implements \Rector\Renaming\Contract\RenameAnnotationInterface +final class RenameAnnotation implements RenameAnnotationInterface { /** * @readonly diff --git a/rules/Renaming/ValueObject/RenameAnnotationByType.php b/rules/Renaming/ValueObject/RenameAnnotationByType.php index 74ea4f8b531..613602e065b 100644 --- a/rules/Renaming/ValueObject/RenameAnnotationByType.php +++ b/rules/Renaming/ValueObject/RenameAnnotationByType.php @@ -6,7 +6,7 @@ namespace Rector\Renaming\ValueObject; use PHPStan\Type\ObjectType; use Rector\Core\Validation\RectorAssert; use Rector\Renaming\Contract\RenameAnnotationInterface; -final class RenameAnnotationByType implements \Rector\Renaming\Contract\RenameAnnotationInterface +final class RenameAnnotationByType implements RenameAnnotationInterface { /** * @readonly @@ -28,11 +28,11 @@ final class RenameAnnotationByType implements \Rector\Renaming\Contract\RenameAn $this->type = $type; $this->oldAnnotation = $oldAnnotation; $this->newAnnotation = $newAnnotation; - \Rector\Core\Validation\RectorAssert::className($type); + RectorAssert::className($type); } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->type); + return new ObjectType($this->type); } public function getOldAnnotation() : string { diff --git a/rules/Renaming/ValueObject/RenameClassAndConstFetch.php b/rules/Renaming/ValueObject/RenameClassAndConstFetch.php index 73ac7318d9c..ef57320aedf 100644 --- a/rules/Renaming/ValueObject/RenameClassAndConstFetch.php +++ b/rules/Renaming/ValueObject/RenameClassAndConstFetch.php @@ -5,7 +5,7 @@ namespace Rector\Renaming\ValueObject; use PHPStan\Type\ObjectType; use Rector\Renaming\Contract\RenameClassConstFetchInterface; -final class RenameClassAndConstFetch implements \Rector\Renaming\Contract\RenameClassConstFetchInterface +final class RenameClassAndConstFetch implements RenameClassConstFetchInterface { /** * @readonly @@ -34,9 +34,9 @@ final class RenameClassAndConstFetch implements \Rector\Renaming\Contract\Rename $this->newClass = $newClass; $this->newConstant = $newConstant; } - public function getOldObjectType() : \PHPStan\Type\ObjectType + public function getOldObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->oldClass); + return new ObjectType($this->oldClass); } public function getOldConstant() : string { diff --git a/rules/Renaming/ValueObject/RenameClassConstFetch.php b/rules/Renaming/ValueObject/RenameClassConstFetch.php index df8da671477..e289e995414 100644 --- a/rules/Renaming/ValueObject/RenameClassConstFetch.php +++ b/rules/Renaming/ValueObject/RenameClassConstFetch.php @@ -5,7 +5,7 @@ namespace Rector\Renaming\ValueObject; use PHPStan\Type\ObjectType; use Rector\Renaming\Contract\RenameClassConstFetchInterface; -final class RenameClassConstFetch implements \Rector\Renaming\Contract\RenameClassConstFetchInterface +final class RenameClassConstFetch implements RenameClassConstFetchInterface { /** * @readonly @@ -28,9 +28,9 @@ final class RenameClassConstFetch implements \Rector\Renaming\Contract\RenameCla $this->oldConstant = $oldConstant; $this->newConstant = $newConstant; } - public function getOldObjectType() : \PHPStan\Type\ObjectType + public function getOldObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->oldClass); + return new ObjectType($this->oldClass); } public function getOldConstant() : string { diff --git a/rules/Renaming/ValueObject/RenameProperty.php b/rules/Renaming/ValueObject/RenameProperty.php index dd9040ad3dd..39117e66b04 100644 --- a/rules/Renaming/ValueObject/RenameProperty.php +++ b/rules/Renaming/ValueObject/RenameProperty.php @@ -27,11 +27,11 @@ final class RenameProperty $this->type = $type; $this->oldProperty = $oldProperty; $this->newProperty = $newProperty; - \Rector\Core\Validation\RectorAssert::className($type); + RectorAssert::className($type); } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->type); + return new ObjectType($this->type); } public function getOldProperty() : string { diff --git a/rules/Renaming/ValueObject/RenameStaticMethod.php b/rules/Renaming/ValueObject/RenameStaticMethod.php index 4e8e0c387b0..184f3413e67 100644 --- a/rules/Renaming/ValueObject/RenameStaticMethod.php +++ b/rules/Renaming/ValueObject/RenameStaticMethod.php @@ -33,9 +33,9 @@ final class RenameStaticMethod $this->newClass = $newClass; $this->newMethod = $newMethod; } - public function getOldObjectType() : \PHPStan\Type\ObjectType + public function getOldObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->oldClass); + return new ObjectType($this->oldClass); } public function getOldMethod() : string { diff --git a/rules/Restoration/Rector/ClassConstFetch/MissingClassConstantReferenceToStringRector.php b/rules/Restoration/Rector/ClassConstFetch/MissingClassConstantReferenceToStringRector.php index 17846e7ec14..1b00c507056 100644 --- a/rules/Restoration/Rector/ClassConstFetch/MissingClassConstantReferenceToStringRector.php +++ b/rules/Restoration/Rector/ClassConstFetch/MissingClassConstantReferenceToStringRector.php @@ -8,25 +8,25 @@ use PhpParser\Node\Expr\ClassConstFetch; use PhpParser\Node\Scalar\String_; use PHPStan\Reflection\ReflectionProvider; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Restoration\Rector\ClassConstFetch\MissingClassConstantReferenceToStringRector\MissingClassConstantReferenceToStringRectorTest */ -final class MissingClassConstantReferenceToStringRector extends \Rector\Core\Rector\AbstractRector +final class MissingClassConstantReferenceToStringRector extends AbstractRector { /** * @readonly * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ReflectionProvider $reflectionProvider) { $this->reflectionProvider = $reflectionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Convert missing class reference to string', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Convert missing class reference to string', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -51,12 +51,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\ClassConstFetch::class]; + return [ClassConstFetch::class]; } /** * @param ClassConstFetch $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node->name, 'class')) { return null; @@ -68,6 +68,6 @@ CODE_SAMPLE if ($this->reflectionProvider->hasClass($referencedClass)) { return null; } - return new \PhpParser\Node\Scalar\String_($referencedClass); + return new String_($referencedClass); } } diff --git a/rules/Restoration/Rector/ClassLike/UpdateFileNameByClassNameFileSystemRector.php b/rules/Restoration/Rector/ClassLike/UpdateFileNameByClassNameFileSystemRector.php index ab67def3eb8..6888d75fbb9 100644 --- a/rules/Restoration/Rector/ClassLike/UpdateFileNameByClassNameFileSystemRector.php +++ b/rules/Restoration/Rector/ClassLike/UpdateFileNameByClassNameFileSystemRector.php @@ -8,25 +8,25 @@ use PhpParser\Node\Stmt\ClassLike; use Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\Application\File; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Restoration\Rector\ClassLike\UpdateFileNameByClassNameFileSystemRector\UpdateFileNameByClassNameFileSystemRectorTest */ -final class UpdateFileNameByClassNameFileSystemRector extends \Rector\Core\Rector\AbstractRector +final class UpdateFileNameByClassNameFileSystemRector extends AbstractRector { /** * @readonly * @var \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector */ private $removedAndAddedFilesCollector; - public function __construct(\Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector) + public function __construct(RemovedAndAddedFilesCollector $removedAndAddedFilesCollector) { $this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Rename file to respect class name', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Rename file to respect class name', [new CodeSample(<<<'CODE_SAMPLE' // app/SomeClass.php class AnotherClass { @@ -45,12 +45,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassLike::class]; + return [ClassLike::class]; } /** * @param ClassLike $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $className = $this->getName($node); if ($className === null) { diff --git a/rules/Restoration/Rector/Class_/RemoveFinalFromEntityRector.php b/rules/Restoration/Rector/Class_/RemoveFinalFromEntityRector.php index 39d25446119..cb1b1317fc0 100644 --- a/rules/Restoration/Rector/Class_/RemoveFinalFromEntityRector.php +++ b/rules/Restoration/Rector/Class_/RemoveFinalFromEntityRector.php @@ -7,25 +7,25 @@ use PhpParser\Node; use PhpParser\Node\Stmt\Class_; use Rector\Core\Rector\AbstractRector; use Rector\Privatization\NodeManipulator\VisibilityManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Restoration\Rector\Class_\RemoveFinalFromEntityRector\RemoveFinalFromEntityRectorTest */ -final class RemoveFinalFromEntityRector extends \Rector\Core\Rector\AbstractRector +final class RemoveFinalFromEntityRector extends AbstractRector { /** * @readonly * @var \Rector\Privatization\NodeManipulator\VisibilityManipulator */ private $visibilityManipulator; - public function __construct(\Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator) + public function __construct(VisibilityManipulator $visibilityManipulator) { $this->visibilityManipulator = $visibilityManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove final from Doctrine entities', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove final from Doctrine entities', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\ORM\Mapping as ORM; /** @@ -52,12 +52,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); if (!$phpDocInfo->hasByAnnotationClasses(['Doctrine\\ORM\\Mapping\\Entity', 'Doctrine\\ORM\\Mapping\\Embeddable'])) { diff --git a/rules/Restoration/Rector/Namespace_/CompleteImportForPartialAnnotationRector.php b/rules/Restoration/Rector/Namespace_/CompleteImportForPartialAnnotationRector.php index f8a0189b609..109dfc47555 100644 --- a/rules/Restoration/Rector/Namespace_/CompleteImportForPartialAnnotationRector.php +++ b/rules/Restoration/Rector/Namespace_/CompleteImportForPartialAnnotationRector.php @@ -14,13 +14,13 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\Util\StringUtils; use Rector\Restoration\ValueObject\CompleteImportForPartialAnnotation; use RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\UseBuilder; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Restoration\Rector\Namespace_\CompleteImportForPartialAnnotationRector\CompleteImportForPartialAnnotationRectorTest */ -final class CompleteImportForPartialAnnotationRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class CompleteImportForPartialAnnotationRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var CompleteImportForPartialAnnotation[] @@ -31,13 +31,13 @@ final class CompleteImportForPartialAnnotationRector extends \Rector\Core\Rector * @var \Rector\Core\Contract\PhpParser\NodePrinterInterface */ private $nodePrinter; - public function __construct(\Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter) + public function __construct(NodePrinterInterface $nodePrinter) { $this->nodePrinter = $nodePrinter; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('In case you have accidentally removed use imports but code still contains partial use statements, this will save you', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('In case you have accidentally removed use imports but code still contains partial use statements, this will save you', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { /** @@ -57,29 +57,29 @@ class SomeClass public $id; } CODE_SAMPLE -, [new \Rector\Restoration\ValueObject\CompleteImportForPartialAnnotation('Doctrine\\ORM\\Mapping', 'ORM')])]); +, [new CompleteImportForPartialAnnotation('Doctrine\\ORM\\Mapping', 'ORM')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Namespace_::class]; + return [Namespace_::class]; } /** * @param Namespace_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $class = $this->betterNodeFinder->findFirstInstanceOf($node->stmts, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findFirstInstanceOf($node->stmts, Class_::class); + if (!$class instanceof Class_) { return null; } $printedClass = $this->nodePrinter->print($class); $hasChanged = \false; foreach ($this->useImportsToRestore as $useImportToRestore) { $annotationToSeek = '#\\*\\s+\\@' . $useImportToRestore->getAlias() . '#'; - if (!\Rector\Core\Util\StringUtils::isMatch($printedClass, $annotationToSeek)) { + if (!StringUtils::isMatch($printedClass, $annotationToSeek)) { continue; } $node = $this->addImportToNamespaceIfMissing($node, $useImportToRestore); @@ -95,14 +95,14 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Restoration\ValueObject\CompleteImportForPartialAnnotation::class); - $default = [new \Rector\Restoration\ValueObject\CompleteImportForPartialAnnotation('Doctrine\\ORM\\Mapping', 'ORM'), new \Rector\Restoration\ValueObject\CompleteImportForPartialAnnotation('Symfony\\Component\\Validator\\Constraints', 'Assert'), new \Rector\Restoration\ValueObject\CompleteImportForPartialAnnotation('JMS\\Serializer\\Annotation', 'Serializer')]; + Assert::allIsAOf($configuration, CompleteImportForPartialAnnotation::class); + $default = [new CompleteImportForPartialAnnotation('Doctrine\\ORM\\Mapping', 'ORM'), new CompleteImportForPartialAnnotation('Symfony\\Component\\Validator\\Constraints', 'Assert'), new CompleteImportForPartialAnnotation('JMS\\Serializer\\Annotation', 'Serializer')]; $this->useImportsToRestore = \array_merge($configuration, $default); } - private function addImportToNamespaceIfMissing(\PhpParser\Node\Stmt\Namespace_ $namespace, \Rector\Restoration\ValueObject\CompleteImportForPartialAnnotation $completeImportForPartialAnnotation) : \PhpParser\Node\Stmt\Namespace_ + private function addImportToNamespaceIfMissing(Namespace_ $namespace, CompleteImportForPartialAnnotation $completeImportForPartialAnnotation) : Namespace_ { foreach ($namespace->stmts as $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Use_) { + if (!$stmt instanceof Use_) { continue; } $useUse = $stmt->uses[0]; @@ -117,9 +117,9 @@ CODE_SAMPLE } return $this->addImportToNamespace($namespace, $completeImportForPartialAnnotation); } - private function addImportToNamespace(\PhpParser\Node\Stmt\Namespace_ $namespace, \Rector\Restoration\ValueObject\CompleteImportForPartialAnnotation $completeImportForPartialAnnotation) : \PhpParser\Node\Stmt\Namespace_ + private function addImportToNamespace(Namespace_ $namespace, CompleteImportForPartialAnnotation $completeImportForPartialAnnotation) : Namespace_ { - $useBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\UseBuilder($completeImportForPartialAnnotation->getUse()); + $useBuilder = new UseBuilder($completeImportForPartialAnnotation->getUse()); if ($completeImportForPartialAnnotation->getAlias() !== '') { $useBuilder->as($completeImportForPartialAnnotation->getAlias()); } diff --git a/rules/Restoration/Rector/Property/MakeTypedPropertyNullableIfCheckedRector.php b/rules/Restoration/Rector/Property/MakeTypedPropertyNullableIfCheckedRector.php index 2b8d53c9b8e..d296c37f818 100644 --- a/rules/Restoration/Rector/Property/MakeTypedPropertyNullableIfCheckedRector.php +++ b/rules/Restoration/Rector/Property/MakeTypedPropertyNullableIfCheckedRector.php @@ -14,16 +14,16 @@ use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\Property; use PhpParser\Node\Stmt\PropertyProperty; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Restoration\Rector\Property\MakeTypedPropertyNullableIfCheckedRector\MakeTypedPropertyNullableIfCheckedRectorTest */ -final class MakeTypedPropertyNullableIfCheckedRector extends \Rector\Core\Rector\AbstractRector +final class MakeTypedPropertyNullableIfCheckedRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Make typed property nullable if checked', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Make typed property nullable if checked', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { private AnotherClass $anotherClass; @@ -56,12 +56,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkipProperty($node)) { return null; @@ -72,18 +72,18 @@ CODE_SAMPLE if (!$isPropretyNullChecked) { return null; } - if ($node->type instanceof \PhpParser\Node\ComplexType) { + if ($node->type instanceof ComplexType) { return null; } $currentPropertyType = $node->type; if ($currentPropertyType === null) { return null; } - $node->type = new \PhpParser\Node\NullableType($currentPropertyType); + $node->type = new NullableType($currentPropertyType); $onlyProperty->default = $this->nodeFactory->createNull(); return $node; } - private function shouldSkipProperty(\PhpParser\Node\Stmt\Property $property) : bool + private function shouldSkipProperty(Property $property) : bool { if (\count($property->props) !== 1) { return \true; @@ -91,12 +91,12 @@ CODE_SAMPLE if ($property->type === null) { return \true; } - return $property->type instanceof \PhpParser\Node\NullableType; + return $property->type instanceof NullableType; } - private function isPropertyNullChecked(\PhpParser\Node\Stmt\PropertyProperty $onlyPropertyProperty) : bool + private function isPropertyNullChecked(PropertyProperty $onlyPropertyProperty) : bool { - $classLike = $this->betterNodeFinder->findParentType($onlyPropertyProperty, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLike = $this->betterNodeFinder->findParentType($onlyPropertyProperty, Class_::class); + if (!$classLike instanceof Class_) { return \false; } if ($this->isIdenticalOrNotIdenticalToNull($classLike, $onlyPropertyProperty)) { @@ -104,10 +104,10 @@ CODE_SAMPLE } return $this->isBooleanNot($classLike, $onlyPropertyProperty); } - private function isIdenticalOrNotIdenticalToNull(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\PropertyProperty $onlyPropertyProperty) : bool + private function isIdenticalOrNotIdenticalToNull(Class_ $class, PropertyProperty $onlyPropertyProperty) : bool { $isIdenticalOrNotIdenticalToNull = \false; - $this->traverseNodesWithCallable($class->stmts, function (\PhpParser\Node $node) use($onlyPropertyProperty, &$isIdenticalOrNotIdenticalToNull) { + $this->traverseNodesWithCallable($class->stmts, function (Node $node) use($onlyPropertyProperty, &$isIdenticalOrNotIdenticalToNull) { $matchedPropertyFetchName = $this->matchPropertyFetchNameComparedToNull($node); if ($matchedPropertyFetchName === null) { return null; @@ -119,14 +119,14 @@ CODE_SAMPLE }); return $isIdenticalOrNotIdenticalToNull; } - private function isBooleanNot(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\PropertyProperty $onlyPropertyProperty) : bool + private function isBooleanNot(Class_ $class, PropertyProperty $onlyPropertyProperty) : bool { $isBooleanNot = \false; - $this->traverseNodesWithCallable($class->stmts, function (\PhpParser\Node $node) use($onlyPropertyProperty, &$isBooleanNot) { - if (!$node instanceof \PhpParser\Node\Expr\BooleanNot) { + $this->traverseNodesWithCallable($class->stmts, function (Node $node) use($onlyPropertyProperty, &$isBooleanNot) { + if (!$node instanceof BooleanNot) { return null; } - if (!$node->expr instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$node->expr instanceof PropertyFetch) { return null; } if (!$this->isName($node->expr->var, 'this')) { @@ -144,14 +144,14 @@ CODE_SAMPLE * $this-> === null * null === $this-> */ - private function matchPropertyFetchNameComparedToNull(\PhpParser\Node $node) : ?string + private function matchPropertyFetchNameComparedToNull(Node $node) : ?string { - if (!$node instanceof \PhpParser\Node\Expr\BinaryOp\Identical && !$node instanceof \PhpParser\Node\Expr\BinaryOp\NotIdentical) { + if (!$node instanceof Identical && !$node instanceof NotIdentical) { return null; } - if ($node->left instanceof \PhpParser\Node\Expr\PropertyFetch && $this->valueResolver->isNull($node->right)) { + if ($node->left instanceof PropertyFetch && $this->valueResolver->isNull($node->right)) { $propertyFetch = $node->left; - } elseif ($node->right instanceof \PhpParser\Node\Expr\PropertyFetch && $this->valueResolver->isNull($node->left)) { + } elseif ($node->right instanceof PropertyFetch && $this->valueResolver->isNull($node->left)) { $propertyFetch = $node->right; } else { return null; diff --git a/rules/Strict/NodeFactory/ExactCompareFactory.php b/rules/Strict/NodeFactory/ExactCompareFactory.php index 66c50123a2e..775d40145e4 100644 --- a/rules/Strict/NodeFactory/ExactCompareFactory.php +++ b/rules/Strict/NodeFactory/ExactCompareFactory.php @@ -31,31 +31,31 @@ final class ExactCompareFactory * @var \Rector\Core\PhpParser\Node\NodeFactory */ private $nodeFactory; - public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory) + public function __construct(NodeFactory $nodeFactory) { $this->nodeFactory = $nodeFactory; } /** * @return \PhpParser\Node\Expr|null */ - public function createIdenticalFalsyCompare(\PHPStan\Type\Type $exprType, \PhpParser\Node\Expr $expr, bool $treatAsNonEmpty) + public function createIdenticalFalsyCompare(Type $exprType, Expr $expr, bool $treatAsNonEmpty) { - if ($exprType instanceof \PHPStan\Type\StringType) { - return new \PhpParser\Node\Expr\BinaryOp\Identical($expr, new \PhpParser\Node\Scalar\String_('')); + if ($exprType instanceof StringType) { + return new Identical($expr, new String_('')); } - if ($exprType instanceof \PHPStan\Type\IntegerType) { - return new \PhpParser\Node\Expr\BinaryOp\Identical($expr, new \PhpParser\Node\Scalar\LNumber(0)); + if ($exprType instanceof IntegerType) { + return new Identical($expr, new LNumber(0)); } - if ($exprType instanceof \PHPStan\Type\BooleanType) { - return new \PhpParser\Node\Expr\BinaryOp\Identical($expr, $this->nodeFactory->createFalse()); + if ($exprType instanceof BooleanType) { + return new Identical($expr, $this->nodeFactory->createFalse()); } - if ($exprType instanceof \PHPStan\Type\ArrayType) { - return new \PhpParser\Node\Expr\BinaryOp\Identical($expr, new \PhpParser\Node\Expr\Array_([])); + if ($exprType instanceof ArrayType) { + return new Identical($expr, new Array_([])); } - if ($exprType instanceof \PHPStan\Type\NullType) { - return new \PhpParser\Node\Expr\BinaryOp\Identical($expr, $this->nodeFactory->createNull()); + if ($exprType instanceof NullType) { + return new Identical($expr, $this->nodeFactory->createNull()); } - if (!$exprType instanceof \PHPStan\Type\UnionType) { + if (!$exprType instanceof UnionType) { return null; } return $this->createTruthyFromUnionType($exprType, $expr, $treatAsNonEmpty); @@ -63,18 +63,18 @@ final class ExactCompareFactory /** * @return \PhpParser\Node\Expr|null */ - public function createNotIdenticalFalsyCompare(\PHPStan\Type\Type $exprType, \PhpParser\Node\Expr $expr, bool $treatAsNotEmpty) + public function createNotIdenticalFalsyCompare(Type $exprType, Expr $expr, bool $treatAsNotEmpty) { - if ($exprType instanceof \PHPStan\Type\StringType) { - return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, new \PhpParser\Node\Scalar\String_('')); + if ($exprType instanceof StringType) { + return new NotIdentical($expr, new String_('')); } - if ($exprType instanceof \PHPStan\Type\IntegerType) { - return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, new \PhpParser\Node\Scalar\LNumber(0)); + if ($exprType instanceof IntegerType) { + return new NotIdentical($expr, new LNumber(0)); } - if ($exprType instanceof \PHPStan\Type\ArrayType) { - return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, new \PhpParser\Node\Expr\Array_([])); + if ($exprType instanceof ArrayType) { + return new NotIdentical($expr, new Array_([])); } - if (!$exprType instanceof \PHPStan\Type\UnionType) { + if (!$exprType instanceof UnionType) { return null; } return $this->createFromUnionType($exprType, $expr, $treatAsNotEmpty); @@ -82,27 +82,27 @@ final class ExactCompareFactory /** * @return \PhpParser\Node\Expr|null */ - private function createFromUnionType(\PHPStan\Type\UnionType $unionType, \PhpParser\Node\Expr $expr, bool $treatAsNotEmpty) + private function createFromUnionType(UnionType $unionType, Expr $expr, bool $treatAsNotEmpty) { - $unionType = \PHPStan\Type\TypeCombinator::removeNull($unionType); - if ($unionType instanceof \PHPStan\Type\BooleanType) { - return new \PhpParser\Node\Expr\BinaryOp\Identical($expr, $this->nodeFactory->createTrue()); + $unionType = TypeCombinator::removeNull($unionType); + if ($unionType instanceof BooleanType) { + return new Identical($expr, $this->nodeFactory->createTrue()); } - if ($unionType instanceof \PHPStan\Type\TypeWithClassName) { - return new \PhpParser\Node\Expr\Instanceof_($expr, new \PhpParser\Node\Name\FullyQualified($unionType->getClassName())); + if ($unionType instanceof TypeWithClassName) { + return new Instanceof_($expr, new FullyQualified($unionType->getClassName())); } $nullConstFetch = $this->nodeFactory->createNull(); - $toNullNotIdentical = new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, $nullConstFetch); - if ($unionType instanceof \PHPStan\Type\UnionType) { + $toNullNotIdentical = new NotIdentical($expr, $nullConstFetch); + if ($unionType instanceof UnionType) { return $this->resolveFromCleanedNullUnionType($unionType, $expr, $treatAsNotEmpty); } $compareExpr = $this->createNotIdenticalFalsyCompare($unionType, $expr, $treatAsNotEmpty); - if (!$compareExpr instanceof \PhpParser\Node\Expr) { + if (!$compareExpr instanceof Expr) { return null; } - return new \PhpParser\Node\Expr\BinaryOp\BooleanAnd($toNullNotIdentical, $compareExpr); + return new BooleanAnd($toNullNotIdentical, $compareExpr); } - private function resolveFromCleanedNullUnionType(\PHPStan\Type\UnionType $unionType, \PhpParser\Node\Expr $expr, bool $treatAsNotEmpty) : ?\PhpParser\Node\Expr + private function resolveFromCleanedNullUnionType(UnionType $unionType, Expr $expr, bool $treatAsNotEmpty) : ?Expr { $compareExprs = []; foreach ($unionType->getTypes() as $unionedType) { @@ -113,7 +113,7 @@ final class ExactCompareFactory /** * @return array */ - private function collectCompareExprs(\PHPStan\Type\UnionType $unionType, \PhpParser\Node\Expr $expr, bool $treatAsNonEmpty) : array + private function collectCompareExprs(UnionType $unionType, Expr $expr, bool $treatAsNonEmpty) : array { $compareExprs = []; foreach ($unionType->getTypes() as $unionedType) { @@ -121,53 +121,53 @@ final class ExactCompareFactory } return $compareExprs; } - private function cleanUpPossibleNullableUnionType(\PHPStan\Type\UnionType $unionType) : \PHPStan\Type\Type + private function cleanUpPossibleNullableUnionType(UnionType $unionType) : Type { - return \count($unionType->getTypes()) === 2 ? \PHPStan\Type\TypeCombinator::removeNull($unionType) : $unionType; + return \count($unionType->getTypes()) === 2 ? TypeCombinator::removeNull($unionType) : $unionType; } /** * @param array $compareExprs */ - private function resolveTruthyExpr(array $compareExprs) : ?\PhpParser\Node\Expr + private function resolveTruthyExpr(array $compareExprs) : ?Expr { $truthyExpr = \array_shift($compareExprs); foreach ($compareExprs as $compareExpr) { - if (!$compareExpr instanceof \PhpParser\Node\Expr) { + if (!$compareExpr instanceof Expr) { return null; } - if (!$truthyExpr instanceof \PhpParser\Node\Expr) { + if (!$truthyExpr instanceof Expr) { return null; } - $truthyExpr = new \PhpParser\Node\Expr\BinaryOp\BooleanOr($truthyExpr, $compareExpr); + $truthyExpr = new BooleanOr($truthyExpr, $compareExpr); } return $truthyExpr; } /** * @return \PhpParser\Node\Expr|null */ - private function createTruthyFromUnionType(\PHPStan\Type\UnionType $unionType, \PhpParser\Node\Expr $expr, bool $treatAsNonEmpty) + private function createTruthyFromUnionType(UnionType $unionType, Expr $expr, bool $treatAsNonEmpty) { $unionType = $this->cleanUpPossibleNullableUnionType($unionType); - if ($unionType instanceof \PHPStan\Type\UnionType) { + if ($unionType instanceof UnionType) { $compareExprs = $this->collectCompareExprs($unionType, $expr, $treatAsNonEmpty); return $this->resolveTruthyExpr($compareExprs); } - if ($unionType instanceof \PHPStan\Type\BooleanType) { - return new \PhpParser\Node\Expr\BinaryOp\Identical($expr, $this->nodeFactory->createTrue()); + if ($unionType instanceof BooleanType) { + return new Identical($expr, $this->nodeFactory->createTrue()); } - if ($unionType instanceof \PHPStan\Type\TypeWithClassName) { - $instanceOf = new \PhpParser\Node\Expr\Instanceof_($expr, new \PhpParser\Node\Name\FullyQualified($unionType->getClassName())); - return new \PhpParser\Node\Expr\BooleanNot($instanceOf); + if ($unionType instanceof TypeWithClassName) { + $instanceOf = new Instanceof_($expr, new FullyQualified($unionType->getClassName())); + return new BooleanNot($instanceOf); } - $toNullIdentical = new \PhpParser\Node\Expr\BinaryOp\Identical($expr, $this->nodeFactory->createNull()); + $toNullIdentical = new Identical($expr, $this->nodeFactory->createNull()); if ($treatAsNonEmpty) { return $toNullIdentical; } // assume we have to check empty string, integer and bools $scalarFalsyIdentical = $this->createIdenticalFalsyCompare($unionType, $expr, $treatAsNonEmpty); - if (!$scalarFalsyIdentical instanceof \PhpParser\Node\Expr) { + if (!$scalarFalsyIdentical instanceof Expr) { return null; } - return new \PhpParser\Node\Expr\BinaryOp\BooleanOr($toNullIdentical, $scalarFalsyIdentical); + return new BooleanOr($toNullIdentical, $scalarFalsyIdentical); } } diff --git a/rules/Strict/Rector/AbstractFalsyScalarRuleFixerRector.php b/rules/Strict/Rector/AbstractFalsyScalarRuleFixerRector.php index 0afff06776d..8f6a0c39f53 100644 --- a/rules/Strict/Rector/AbstractFalsyScalarRuleFixerRector.php +++ b/rules/Strict/Rector/AbstractFalsyScalarRuleFixerRector.php @@ -9,7 +9,7 @@ use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector\BooleanInBooleanNotRuleFixerRectorTest */ -abstract class AbstractFalsyScalarRuleFixerRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +abstract class AbstractFalsyScalarRuleFixerRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var string @@ -25,7 +25,7 @@ abstract class AbstractFalsyScalarRuleFixerRector extends \Rector\Core\Rector\Ab public function configure(array $configuration) : void { $treatAsNonEmpty = $configuration[self::TREAT_AS_NON_EMPTY] ?? (bool) \current($configuration); - \RectorPrefix20220607\Webmozart\Assert\Assert::boolean($treatAsNonEmpty); + Assert::boolean($treatAsNonEmpty); $this->treatAsNonEmpty = $treatAsNonEmpty; } } diff --git a/rules/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector.php b/rules/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector.php index 9cce0ae9231..ee551363f8f 100644 --- a/rules/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector.php +++ b/rules/Strict/Rector/BooleanNot/BooleanInBooleanNotRuleFixerRector.php @@ -10,29 +10,29 @@ use PHPStan\Analyser\Scope; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Strict\NodeFactory\ExactCompareFactory; use Rector\Strict\Rector\AbstractFalsyScalarRuleFixerRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * Fixer Rector for PHPStan rule: * https://github.com/phpstan/phpstan-strict-rules/blob/0705fefc7c9168529fd130e341428f5f10f4f01d/src/Rules/BooleansInConditions/BooleanInBooleanNotRule.php * * @see \Rector\Tests\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector\BooleanInBooleanNotRuleFixerRectorTest */ -final class BooleanInBooleanNotRuleFixerRector extends \Rector\Strict\Rector\AbstractFalsyScalarRuleFixerRector +final class BooleanInBooleanNotRuleFixerRector extends AbstractFalsyScalarRuleFixerRector { /** * @readonly * @var \Rector\Strict\NodeFactory\ExactCompareFactory */ private $exactCompareFactory; - public function __construct(\Rector\Strict\NodeFactory\ExactCompareFactory $exactCompareFactory) + public function __construct(ExactCompareFactory $exactCompareFactory) { $this->exactCompareFactory = $exactCompareFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { $errorMessage = \sprintf('Fixer for PHPStan reports by strict type rule - "%s"', 'PHPStan\\Rules\\BooleansInConditions\\BooleanInBooleanNotRule'); - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition($errorMessage, [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition($errorMessage, [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(string|null $name) @@ -65,15 +65,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BooleanNot::class]; + return [BooleanNot::class]; } /** * @param BooleanNot $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Expr + public function refactor(Node $node) : ?Expr { - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { + $scope = $node->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { return null; } $exprType = $scope->getType($node->expr); diff --git a/rules/Strict/Rector/Empty_/DisallowedEmptyRuleFixerRector.php b/rules/Strict/Rector/Empty_/DisallowedEmptyRuleFixerRector.php index 4bf67ad118f..0f9b295df6e 100644 --- a/rules/Strict/Rector/Empty_/DisallowedEmptyRuleFixerRector.php +++ b/rules/Strict/Rector/Empty_/DisallowedEmptyRuleFixerRector.php @@ -12,26 +12,26 @@ use PHPStan\Analyser\Scope; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Strict\NodeFactory\ExactCompareFactory; use Rector\Strict\Rector\AbstractFalsyScalarRuleFixerRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector\DisallowedEmptyRuleFixerRectorTest */ -final class DisallowedEmptyRuleFixerRector extends \Rector\Strict\Rector\AbstractFalsyScalarRuleFixerRector +final class DisallowedEmptyRuleFixerRector extends AbstractFalsyScalarRuleFixerRector { /** * @readonly * @var \Rector\Strict\NodeFactory\ExactCompareFactory */ private $exactCompareFactory; - public function __construct(\Rector\Strict\NodeFactory\ExactCompareFactory $exactCompareFactory) + public function __construct(ExactCompareFactory $exactCompareFactory) { $this->exactCompareFactory = $exactCompareFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { $errorMessage = \sprintf('Fixer for PHPStan reports by strict type rule - "%s"', 'PHPStan\\Rules\\DisallowedConstructs\\DisallowedEmptyRule'); - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition($errorMessage, [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition($errorMessage, [new ConfiguredCodeSample(<<<'CODE_SAMPLE' final class SomeEmptyArray { public function run(array $items) @@ -56,22 +56,22 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Empty_::class, \PhpParser\Node\Expr\BooleanNot::class]; + return [Empty_::class, BooleanNot::class]; } /** * @param Empty_|BooleanNot $node * @return \PhpParser\Node\Expr|null */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { + $scope = $node->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { return null; } - if ($node instanceof \PhpParser\Node\Expr\BooleanNot) { + if ($node instanceof BooleanNot) { return $this->refactorBooleanNot($node, $scope); } - if ($node->expr instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if ($node->expr instanceof ArrayDimFetch) { return null; } return $this->refactorEmpty($node, $scope, $this->treatAsNonEmpty); @@ -79,9 +79,9 @@ CODE_SAMPLE /** * @return \PhpParser\Node\Expr|null */ - private function refactorBooleanNot(\PhpParser\Node\Expr\BooleanNot $booleanNot, \PHPStan\Analyser\Scope $scope) + private function refactorBooleanNot(BooleanNot $booleanNot, Scope $scope) { - if (!$booleanNot->expr instanceof \PhpParser\Node\Expr\Empty_) { + if (!$booleanNot->expr instanceof Empty_) { return null; } $empty = $booleanNot->expr; @@ -91,7 +91,7 @@ CODE_SAMPLE /** * @return \PhpParser\Node\Expr|null */ - private function refactorEmpty(\PhpParser\Node\Expr\Empty_ $empty, \PHPStan\Analyser\Scope $scope, bool $treatAsNonEmpty) + private function refactorEmpty(Empty_ $empty, Scope $scope, bool $treatAsNonEmpty) { $exprType = $scope->getType($empty->expr); return $this->exactCompareFactory->createIdenticalFalsyCompare($exprType, $empty->expr, $treatAsNonEmpty); diff --git a/rules/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector.php b/rules/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector.php index 9266a395610..c9ac6963b7d 100644 --- a/rules/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector.php +++ b/rules/Strict/Rector/If_/BooleanInIfConditionRuleFixerRector.php @@ -10,8 +10,8 @@ use PHPStan\Analyser\Scope; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Strict\NodeFactory\ExactCompareFactory; use Rector\Strict\Rector\AbstractFalsyScalarRuleFixerRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * Fixer Rector for PHPStan rules: * https://github.com/phpstan/phpstan-strict-rules/blob/master/src/Rules/BooleansInConditions/BooleanInIfConditionRule.php @@ -19,21 +19,21 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @see \Rector\Tests\Strict\Rector\If_\BooleanInIfConditionRuleFixerRector\BooleanInIfConditionRuleFixerRectorTest */ -final class BooleanInIfConditionRuleFixerRector extends \Rector\Strict\Rector\AbstractFalsyScalarRuleFixerRector +final class BooleanInIfConditionRuleFixerRector extends AbstractFalsyScalarRuleFixerRector { /** * @readonly * @var \Rector\Strict\NodeFactory\ExactCompareFactory */ private $exactCompareFactory; - public function __construct(\Rector\Strict\NodeFactory\ExactCompareFactory $exactCompareFactory) + public function __construct(ExactCompareFactory $exactCompareFactory) { $this->exactCompareFactory = $exactCompareFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { $errorMessage = \sprintf('Fixer for PHPStan reports by strict type rule - "%s"', 'PHPStan\\Rules\\BooleansInConditions\\BooleanInIfConditionRule'); - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition($errorMessage, [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition($errorMessage, [new ConfiguredCodeSample(<<<'CODE_SAMPLE' final class NegatedString { public function run(string $name) @@ -66,15 +66,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\If_::class]; + return [If_::class]; } /** * @param If_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Stmt\If_ + public function refactor(Node $node) : ?If_ { - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { + $scope = $node->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { return null; } // 1. if @@ -87,7 +87,7 @@ CODE_SAMPLE foreach ($node->elseifs as $elseif) { $elseifCondExprType = $scope->getType($elseif->cond); $notIdentical = $this->exactCompareFactory->createNotIdenticalFalsyCompare($elseifCondExprType, $elseif->cond, $this->treatAsNonEmpty); - if (!$notIdentical instanceof \PhpParser\Node\Expr) { + if (!$notIdentical instanceof Expr) { continue; } $elseif->cond = $notIdentical; diff --git a/rules/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector.php b/rules/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector.php index f64b3e4a92e..a8ff7a4f8dc 100644 --- a/rules/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector.php +++ b/rules/Strict/Rector/Ternary/BooleanInTernaryOperatorRuleFixerRector.php @@ -10,29 +10,29 @@ use PHPStan\Analyser\Scope; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Strict\NodeFactory\ExactCompareFactory; use Rector\Strict\Rector\AbstractFalsyScalarRuleFixerRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * Fixer Rector for PHPStan rule: * https://github.com/phpstan/phpstan-strict-rules/blob/master/src/Rules/BooleansInConditions/BooleanInTernaryOperatorRule.php * * @see \Rector\Tests\Strict\Rector\Ternary\BooleanInTernaryOperatorRuleFixerRector\BooleanInTernaryOperatorRuleFixerRectorTest */ -final class BooleanInTernaryOperatorRuleFixerRector extends \Rector\Strict\Rector\AbstractFalsyScalarRuleFixerRector +final class BooleanInTernaryOperatorRuleFixerRector extends AbstractFalsyScalarRuleFixerRector { /** * @readonly * @var \Rector\Strict\NodeFactory\ExactCompareFactory */ private $exactCompareFactory; - public function __construct(\Rector\Strict\NodeFactory\ExactCompareFactory $exactCompareFactory) + public function __construct(ExactCompareFactory $exactCompareFactory) { $this->exactCompareFactory = $exactCompareFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { $errorMessage = \sprintf('Fixer for PHPStan reports by strict type rule - "%s"', 'PHPStan\\Rules\\BooleansInConditions\\BooleanInTernaryOperatorRule'); - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition($errorMessage, [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition($errorMessage, [new ConfiguredCodeSample(<<<'CODE_SAMPLE' final class ArrayCompare { public function run(array $data) @@ -57,15 +57,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Ternary::class]; + return [Ternary::class]; } /** * @param Ternary $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Expr\Ternary + public function refactor(Node $node) : ?Ternary { - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { + $scope = $node->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { return null; } // skip short ternary @@ -74,7 +74,7 @@ CODE_SAMPLE } $exprType = $scope->getType($node->cond); $falsyIdentical = $this->exactCompareFactory->createNotIdenticalFalsyCompare($exprType, $node->cond, $this->treatAsNonEmpty); - if (!$falsyIdentical instanceof \PhpParser\Node\Expr) { + if (!$falsyIdentical instanceof Expr) { return null; } $node->cond = $falsyIdentical; diff --git a/rules/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector.php b/rules/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector.php index b22620288ec..7a156026ee4 100644 --- a/rules/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector.php +++ b/rules/Strict/Rector/Ternary/DisallowedShortTernaryRuleFixerRector.php @@ -11,29 +11,29 @@ use PHPStan\Analyser\Scope; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Strict\NodeFactory\ExactCompareFactory; use Rector\Strict\Rector\AbstractFalsyScalarRuleFixerRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * Fixer Rector for PHPStan rule: * https://github.com/phpstan/phpstan-strict-rules/blob/master/src/Rules/DisallowedConstructs/DisallowedShortTernaryRule.php * * @see \Rector\Tests\Strict\Rector\Ternary\DisallowedShortTernaryRuleFixerRector\DisallowedShortTernaryRuleFixerRectorTest */ -final class DisallowedShortTernaryRuleFixerRector extends \Rector\Strict\Rector\AbstractFalsyScalarRuleFixerRector +final class DisallowedShortTernaryRuleFixerRector extends AbstractFalsyScalarRuleFixerRector { /** * @readonly * @var \Rector\Strict\NodeFactory\ExactCompareFactory */ private $exactCompareFactory; - public function __construct(\Rector\Strict\NodeFactory\ExactCompareFactory $exactCompareFactory) + public function __construct(ExactCompareFactory $exactCompareFactory) { $this->exactCompareFactory = $exactCompareFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { $errorMessage = \sprintf('Fixer for PHPStan reports by strict type rule - "%s"', 'PHPStan\\Rules\\DisallowedConstructs\\DisallowedShortTernaryRule'); - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition($errorMessage, [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition($errorMessage, [new ConfiguredCodeSample(<<<'CODE_SAMPLE' final class ShortTernaryArray { public function run(array $array) @@ -58,15 +58,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Ternary::class]; + return [Ternary::class]; } /** * @param Ternary $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Expr\Ternary + public function refactor(Node $node) : ?Ternary { - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { + $scope = $node->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { return null; } // skip non-short ternary @@ -74,26 +74,26 @@ CODE_SAMPLE return null; } // special case for reset() function - if ($node->cond instanceof \PhpParser\Node\Expr\FuncCall && $this->isName($node->cond, 'reset')) { + if ($node->cond instanceof FuncCall && $this->isName($node->cond, 'reset')) { $this->refactorResetFuncCall($node, $node->cond, $scope); return $node; } $exprType = $scope->getType($node->cond); $compareExpr = $this->exactCompareFactory->createNotIdenticalFalsyCompare($exprType, $node->cond, $this->treatAsNonEmpty); - if (!$compareExpr instanceof \PhpParser\Node\Expr) { + if (!$compareExpr instanceof Expr) { return null; } $node->if = $node->cond; $node->cond = $compareExpr; return $node; } - private function refactorResetFuncCall(\PhpParser\Node\Expr\Ternary $ternary, \PhpParser\Node\Expr\FuncCall $resetFuncCall, \PHPStan\Analyser\Scope $scope) : void + private function refactorResetFuncCall(Ternary $ternary, FuncCall $resetFuncCall, Scope $scope) : void { $ternary->if = $ternary->cond; $firstArgValue = $resetFuncCall->args[0]->value; $firstArgType = $scope->getType($firstArgValue); $falsyCompareExpr = $this->exactCompareFactory->createNotIdenticalFalsyCompare($firstArgType, $firstArgValue, $this->treatAsNonEmpty); - if (!$falsyCompareExpr instanceof \PhpParser\Node\Expr) { + if (!$falsyCompareExpr instanceof Expr) { return; } $ternary->cond = $falsyCompareExpr; diff --git a/rules/Transform/NodeAnalyzer/FuncCallStaticCallToMethodCallAnalyzer.php b/rules/Transform/NodeAnalyzer/FuncCallStaticCallToMethodCallAnalyzer.php index 93b9eec78a5..6c7cef29cfb 100644 --- a/rules/Transform/NodeAnalyzer/FuncCallStaticCallToMethodCallAnalyzer.php +++ b/rules/Transform/NodeAnalyzer/FuncCallStaticCallToMethodCallAnalyzer.php @@ -49,7 +49,7 @@ final class FuncCallStaticCallToMethodCallAnalyzer * @var \Rector\PostRector\Collector\PropertyToAddCollector */ private $propertyToAddCollector; - public function __construct(\Rector\Transform\NodeTypeAnalyzer\TypeProvidingExprFromClassResolver $typeProvidingExprFromClassResolver, \Rector\Naming\Naming\PropertyNaming $propertyNaming, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\Transform\NodeFactory\PropertyFetchFactory $propertyFetchFactory, \Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector) + public function __construct(TypeProvidingExprFromClassResolver $typeProvidingExprFromClassResolver, PropertyNaming $propertyNaming, NodeNameResolver $nodeNameResolver, NodeFactory $nodeFactory, PropertyFetchFactory $propertyFetchFactory, PropertyToAddCollector $propertyToAddCollector) { $this->typeProvidingExprFromClassResolver = $typeProvidingExprFromClassResolver; $this->propertyNaming = $propertyNaming; @@ -62,24 +62,24 @@ final class FuncCallStaticCallToMethodCallAnalyzer * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike * @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\PropertyFetch|\PhpParser\Node\Expr\Variable */ - public function matchTypeProvidingExpr(\PhpParser\Node\Stmt\Class_ $class, $functionLike, \PHPStan\Type\ObjectType $objectType) + public function matchTypeProvidingExpr(Class_ $class, $functionLike, ObjectType $objectType) { $expr = $this->typeProvidingExprFromClassResolver->resolveTypeProvidingExprFromClass($class, $functionLike, $objectType); if ($expr !== null) { - if ($expr instanceof \PhpParser\Node\Expr\Variable) { + if ($expr instanceof Variable) { $this->addClassMethodParamForVariable($expr, $objectType, $functionLike); } return $expr; } $propertyName = $this->propertyNaming->fqnToVariableName($objectType); - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($propertyName, $objectType, \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $propertyMetadata = new PropertyMetadata($propertyName, $objectType, Class_::MODIFIER_PRIVATE); $this->propertyToAddCollector->addPropertyToClass($class, $propertyMetadata); return $this->propertyFetchFactory->createFromType($objectType); } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike */ - private function addClassMethodParamForVariable(\PhpParser\Node\Expr\Variable $variable, \PHPStan\Type\ObjectType $objectType, $functionLike) : void + private function addClassMethodParamForVariable(Variable $variable, ObjectType $objectType, $functionLike) : void { /** @var string $variableName */ $variableName = $this->nodeNameResolver->getName($variable); diff --git a/rules/Transform/NodeAnalyzer/SingletonClassMethodAnalyzer.php b/rules/Transform/NodeAnalyzer/SingletonClassMethodAnalyzer.php index 0de2978c81e..3bcfd758485 100644 --- a/rules/Transform/NodeAnalyzer/SingletonClassMethodAnalyzer.php +++ b/rules/Transform/NodeAnalyzer/SingletonClassMethodAnalyzer.php @@ -46,7 +46,7 @@ final class SingletonClassMethodAnalyzer * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeTypeResolver $nodeTypeResolver, ValueResolver $valueResolver, NodeComparator $nodeComparator, BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver) { $this->nodeTypeResolver = $nodeTypeResolver; $this->valueResolver = $valueResolver; @@ -63,36 +63,36 @@ final class SingletonClassMethodAnalyzer * * Matches "static::$instance" on success */ - public function matchStaticPropertyFetch(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Expr\StaticPropertyFetch + public function matchStaticPropertyFetch(ClassMethod $classMethod) : ?StaticPropertyFetch { $stmts = (array) $classMethod->stmts; if (\count($stmts) !== 2) { return null; } $firstStmt = $stmts[0] ?? null; - if (!$firstStmt instanceof \PhpParser\Node\Stmt\If_) { + if (!$firstStmt instanceof If_) { return null; } $staticPropertyFetch = $this->matchStaticPropertyFetchInIfCond($firstStmt->cond); if (\count($firstStmt->stmts) !== 1) { return null; } - if (!$firstStmt->stmts[0] instanceof \PhpParser\Node\Stmt\Expression) { + if (!$firstStmt->stmts[0] instanceof Expression) { return null; } $stmt = $firstStmt->stmts[0]->expr; // create self and assign to static property - if (!$stmt instanceof \PhpParser\Node\Expr\Assign) { + if (!$stmt instanceof Assign) { return null; } if (!$this->nodeComparator->areNodesEqual($staticPropertyFetch, $stmt->var)) { return null; } - if (!$stmt->expr instanceof \PhpParser\Node\Expr\New_) { + if (!$stmt->expr instanceof New_) { return null; } - $class = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($classMethod, Class_::class); + if (!$class instanceof Class_) { return null; } $className = $this->nodeNameResolver->getName($class); @@ -100,28 +100,28 @@ final class SingletonClassMethodAnalyzer return null; } // the "self" class is created - if (!$this->nodeTypeResolver->isObjectType($stmt->expr->class, new \PHPStan\Type\ObjectType($className))) { + if (!$this->nodeTypeResolver->isObjectType($stmt->expr->class, new ObjectType($className))) { return null; } return $staticPropertyFetch; } - private function matchStaticPropertyFetchInIfCond(\PhpParser\Node\Expr $expr) : ?\PhpParser\Node\Expr\StaticPropertyFetch + private function matchStaticPropertyFetchInIfCond(Expr $expr) : ?StaticPropertyFetch { // matching: "self::$static === null" - if ($expr instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { - if ($this->valueResolver->isNull($expr->left) && $expr->right instanceof \PhpParser\Node\Expr\StaticPropertyFetch) { + if ($expr instanceof Identical) { + if ($this->valueResolver->isNull($expr->left) && $expr->right instanceof StaticPropertyFetch) { return $expr->right; } - if ($this->valueResolver->isNull($expr->right) && $expr->left instanceof \PhpParser\Node\Expr\StaticPropertyFetch) { + if ($this->valueResolver->isNull($expr->right) && $expr->left instanceof StaticPropertyFetch) { return $expr->left; } } // matching: "! self::$static" - if (!$expr instanceof \PhpParser\Node\Expr\BooleanNot) { + if (!$expr instanceof BooleanNot) { return null; } $negatedExpr = $expr->expr; - if (!$negatedExpr instanceof \PhpParser\Node\Expr\StaticPropertyFetch) { + if (!$negatedExpr instanceof StaticPropertyFetch) { return null; } return $negatedExpr; diff --git a/rules/Transform/NodeFactory/PropertyFetchFactory.php b/rules/Transform/NodeFactory/PropertyFetchFactory.php index 5de5d43fce8..8db027020fc 100644 --- a/rules/Transform/NodeFactory/PropertyFetchFactory.php +++ b/rules/Transform/NodeFactory/PropertyFetchFactory.php @@ -14,14 +14,14 @@ final class PropertyFetchFactory * @var \Rector\Naming\Naming\PropertyNaming */ private $propertyNaming; - public function __construct(\Rector\Naming\Naming\PropertyNaming $propertyNaming) + public function __construct(PropertyNaming $propertyNaming) { $this->propertyNaming = $propertyNaming; } - public function createFromType(\PHPStan\Type\ObjectType $objectType) : \PhpParser\Node\Expr\PropertyFetch + public function createFromType(ObjectType $objectType) : PropertyFetch { - $thisVariable = new \PhpParser\Node\Expr\Variable('this'); + $thisVariable = new Variable('this'); $propertyName = $this->propertyNaming->fqnToVariableName($objectType->getClassName()); - return new \PhpParser\Node\Expr\PropertyFetch($thisVariable, $propertyName); + return new PropertyFetch($thisVariable, $propertyName); } } diff --git a/rules/Transform/NodeFactory/UnwrapClosureFactory.php b/rules/Transform/NodeFactory/UnwrapClosureFactory.php index cc6d75777ad..b97ea8973ae 100644 --- a/rules/Transform/NodeFactory/UnwrapClosureFactory.php +++ b/rules/Transform/NodeFactory/UnwrapClosureFactory.php @@ -15,20 +15,20 @@ final class UnwrapClosureFactory /** * @return Node[] */ - public function createAssign(\PhpParser\Node\Expr\Variable $resultVariable, \PhpParser\Node\Arg $arg) : array + public function createAssign(Variable $resultVariable, Arg $arg) : array { $argValue = $arg->value; - if ($argValue instanceof \PhpParser\Node\Expr\Closure) { + if ($argValue instanceof Closure) { $unwrappedNodes = $argValue->getStmts(); \end($argValue->stmts); $lastStmtKey = \key($argValue->stmts); $lastStmt = $argValue->stmts[$lastStmtKey]; - if ($lastStmt instanceof \PhpParser\Node\Stmt\Return_ && $lastStmt->expr !== null) { + if ($lastStmt instanceof Return_ && $lastStmt->expr !== null) { unset($unwrappedNodes[$lastStmtKey]); - $unwrappedNodes[] = new \PhpParser\Node\Expr\Assign($resultVariable, $lastStmt->expr); + $unwrappedNodes[] = new Assign($resultVariable, $lastStmt->expr); } return $unwrappedNodes; } - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } } diff --git a/rules/Transform/NodeTypeAnalyzer/TypeProvidingExprFromClassResolver.php b/rules/Transform/NodeTypeAnalyzer/TypeProvidingExprFromClassResolver.php index d0d85be8a2d..6b300c23672 100644 --- a/rules/Transform/NodeTypeAnalyzer/TypeProvidingExprFromClassResolver.php +++ b/rules/Transform/NodeTypeAnalyzer/TypeProvidingExprFromClassResolver.php @@ -47,7 +47,7 @@ final class TypeProvidingExprFromClassResolver * @var \Rector\Naming\Naming\PropertyNaming */ private $propertyNaming; - public function __construct(\Rector\PHPStanStaticTypeMapper\Utils\TypeUnwrapper $typeUnwrapper, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Naming\Naming\PropertyNaming $propertyNaming) + public function __construct(TypeUnwrapper $typeUnwrapper, ReflectionProvider $reflectionProvider, NodeNameResolver $nodeNameResolver, PropertyNaming $propertyNaming) { $this->typeUnwrapper = $typeUnwrapper; $this->reflectionProvider = $reflectionProvider; @@ -58,7 +58,7 @@ final class TypeProvidingExprFromClassResolver * @return MethodCall|PropertyFetch|Variable|null * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike */ - public function resolveTypeProvidingExprFromClass(\PhpParser\Node\Stmt\Class_ $class, $functionLike, \PHPStan\Type\ObjectType $objectType) : ?\PhpParser\Node\Expr + public function resolveTypeProvidingExprFromClass(Class_ $class, $functionLike, ObjectType $objectType) : ?Expr { $className = (string) $this->nodeNameResolver->getName($class); // A. match a method @@ -68,8 +68,8 @@ final class TypeProvidingExprFromClassResolver return $methodCallProvidingType; } // B. match existing property - $scope = $class->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { + $scope = $class->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { return null; } $propertyFetch = $this->resolvePropertyFetchProvidingType($classReflection, $scope, $objectType); @@ -79,21 +79,21 @@ final class TypeProvidingExprFromClassResolver // C. param in constructor? return $this->resolveConstructorParamProvidingType($functionLike, $objectType); } - private function resolveMethodCallProvidingType(\PHPStan\Reflection\ClassReflection $classReflection, \PHPStan\Type\ObjectType $objectType) : ?\PhpParser\Node\Expr\MethodCall + private function resolveMethodCallProvidingType(ClassReflection $classReflection, ObjectType $objectType) : ?MethodCall { $methodReflections = $this->getClassMethodReflections($classReflection); foreach ($methodReflections as $methodReflection) { - $functionVariant = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); + $functionVariant = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); $returnType = $functionVariant->getReturnType(); if (!$this->isMatchingType($returnType, $objectType)) { continue; } - $thisVariable = new \PhpParser\Node\Expr\Variable('this'); - return new \PhpParser\Node\Expr\MethodCall($thisVariable, $methodReflection->getName()); + $thisVariable = new Variable('this'); + return new MethodCall($thisVariable, $methodReflection->getName()); } return null; } - private function resolvePropertyFetchProvidingType(\PHPStan\Reflection\ClassReflection $classReflection, \PHPStan\Analyser\Scope $scope, \PHPStan\Type\ObjectType $objectType) : ?\PhpParser\Node\Expr\PropertyFetch + private function resolvePropertyFetchProvidingType(ClassReflection $classReflection, Scope $scope, ObjectType $objectType) : ?PropertyFetch { $nativeReflectionClass = $classReflection->getNativeReflection(); foreach ($nativeReflectionClass->getProperties() as $reflectionProperty) { @@ -103,31 +103,31 @@ final class TypeProvidingExprFromClassResolver if (!$this->isMatchingType($readableType, $objectType)) { continue; } - return new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable('this'), $reflectionProperty->getName()); + return new PropertyFetch(new Variable('this'), $reflectionProperty->getName()); } return null; } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike */ - private function resolveConstructorParamProvidingType($functionLike, \PHPStan\Type\ObjectType $objectType) : ?\PhpParser\Node\Expr\Variable + private function resolveConstructorParamProvidingType($functionLike, ObjectType $objectType) : ?Variable { - if (!$functionLike instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$functionLike instanceof ClassMethod) { return null; } - if (!$this->nodeNameResolver->isName($functionLike, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if (!$this->nodeNameResolver->isName($functionLike, MethodName::CONSTRUCT)) { return null; } $variableName = $this->propertyNaming->fqnToVariableName($objectType); - return new \PhpParser\Node\Expr\Variable($variableName); + return new Variable($variableName); } - private function isMatchingType(\PHPStan\Type\Type $readableType, \PHPStan\Type\ObjectType $objectType) : bool + private function isMatchingType(Type $readableType, ObjectType $objectType) : bool { - if ($readableType instanceof \PHPStan\Type\MixedType) { + if ($readableType instanceof MixedType) { return \false; } $readableType = $this->typeUnwrapper->unwrapNullableType($readableType); - if (!$readableType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$readableType instanceof TypeWithClassName) { return \false; } return $readableType->equals($objectType); @@ -135,7 +135,7 @@ final class TypeProvidingExprFromClassResolver /** * @return MethodReflection[] */ - private function getClassMethodReflections(\PHPStan\Reflection\ClassReflection $classReflection) : array + private function getClassMethodReflections(ClassReflection $classReflection) : array { $nativeClassReflection = $classReflection->getNativeReflection(); $methodReflections = []; diff --git a/rules/Transform/Rector/Assign/DimFetchAssignToMethodCallRector.php b/rules/Transform/Rector/Assign/DimFetchAssignToMethodCallRector.php index 75aac042a99..bf39b87a8eb 100644 --- a/rules/Transform/Rector/Assign/DimFetchAssignToMethodCallRector.php +++ b/rules/Transform/Rector/Assign/DimFetchAssignToMethodCallRector.php @@ -12,21 +12,21 @@ use PhpParser\Node\Expr\Variable; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Transform\ValueObject\DimFetchAssignToMethodCall; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\Assign\DimFetchAssignToMethodCallRector\DimFetchAssignToMethodCallRectorTest */ -final class DimFetchAssignToMethodCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class DimFetchAssignToMethodCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var DimFetchAssignToMethodCall[] */ private $dimFetchAssignToMethodCalls = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change magic array access add to $list[], to explicit $list->addMethod(...)', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change magic array access add to $list[], to explicit $list->addMethod(...)', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' use Nette\Application\Routers\Route; use Nette\Application\Routers\RouteList; @@ -51,45 +51,45 @@ class RouterFactory } } CODE_SAMPLE -, [new \Rector\Transform\ValueObject\DimFetchAssignToMethodCall('Nette\\Application\\Routers\\RouteList', 'Nette\\Application\\Routers\\Route', 'addRoute')])]); +, [new DimFetchAssignToMethodCall('Nette\\Application\\Routers\\RouteList', 'Nette\\Application\\Routers\\Route', 'addRoute')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Assign::class]; + return [Assign::class]; } /** * @param Assign $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->var instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$node->var instanceof ArrayDimFetch) { return null; } $arrayDimFetch = $node->var; - if (!$arrayDimFetch->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$arrayDimFetch->var instanceof Variable) { return null; } - if (!$node->expr instanceof \PhpParser\Node\Expr\New_) { + if (!$node->expr instanceof New_) { return null; } $dimFetchAssignToMethodCall = $this->findDimFetchAssignToMethodCall($node); - if (!$dimFetchAssignToMethodCall instanceof \Rector\Transform\ValueObject\DimFetchAssignToMethodCall) { + if (!$dimFetchAssignToMethodCall instanceof DimFetchAssignToMethodCall) { return null; } - return new \PhpParser\Node\Expr\MethodCall($arrayDimFetch->var, $dimFetchAssignToMethodCall->getAddMethod(), $node->expr->args); + return new MethodCall($arrayDimFetch->var, $dimFetchAssignToMethodCall->getAddMethod(), $node->expr->args); } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\DimFetchAssignToMethodCall::class); + Assert::allIsAOf($configuration, DimFetchAssignToMethodCall::class); $this->dimFetchAssignToMethodCalls = $configuration; } - private function findDimFetchAssignToMethodCall(\PhpParser\Node\Expr\Assign $assign) : ?\Rector\Transform\ValueObject\DimFetchAssignToMethodCall + private function findDimFetchAssignToMethodCall(Assign $assign) : ?DimFetchAssignToMethodCall { /** @var ArrayDimFetch $arrayDimFetch */ $arrayDimFetch = $assign->var; diff --git a/rules/Transform/Rector/Assign/GetAndSetToMethodCallRector.php b/rules/Transform/Rector/Assign/GetAndSetToMethodCallRector.php index 1220d2f006c..0f422ad0d10 100644 --- a/rules/Transform/Rector/Assign/GetAndSetToMethodCallRector.php +++ b/rules/Transform/Rector/Assign/GetAndSetToMethodCallRector.php @@ -16,13 +16,13 @@ use Rector\Core\NodeManipulator\MagicPropertyFetchAnalyzer; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\Transform\ValueObject\GetAndSetToMethodCall; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\Assign\GetAndSetToMethodCallRector\GetAndSetToMethodCallRectorTest */ -final class GetAndSetToMethodCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class GetAndSetToMethodCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var GetAndSetToMethodCall[] @@ -38,14 +38,14 @@ final class GetAndSetToMethodCallRector extends \Rector\Core\Rector\AbstractRect * @var \Rector\Core\NodeManipulator\MagicPropertyFetchAnalyzer */ private $magicPropertyFetchAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \Rector\Core\NodeManipulator\MagicPropertyFetchAnalyzer $magicPropertyFetchAnalyzer) + public function __construct(PropertyFetchAnalyzer $propertyFetchAnalyzer, MagicPropertyFetchAnalyzer $magicPropertyFetchAnalyzer) { $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; $this->magicPropertyFetchAnalyzer = $magicPropertyFetchAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns defined `__get`/`__set` to specific method calls.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns defined `__get`/`__set` to specific method calls.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' $container = new SomeContainer; $container->someService = $someService; CODE_SAMPLE @@ -53,22 +53,22 @@ CODE_SAMPLE $container = new SomeContainer; $container->setService("someService", $someService); CODE_SAMPLE -, [new \Rector\Transform\ValueObject\GetAndSetToMethodCall('SomeContainer', 'addService', 'getService')])]); +, [new GetAndSetToMethodCall('SomeContainer', 'addService', 'getService')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Assign::class, \PhpParser\Node\Expr\PropertyFetch::class]; + return [Assign::class, PropertyFetch::class]; } /** * @param Assign|PropertyFetch $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\Assign) { - if ($node->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if ($node instanceof Assign) { + if ($node->var instanceof PropertyFetch) { return $this->processMagicSet($node->expr, $node->var); } return null; @@ -80,10 +80,10 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\GetAndSetToMethodCall::class); + Assert::allIsAOf($configuration, GetAndSetToMethodCall::class); $this->getAndSetToMethodCalls = $configuration; } - private function processMagicSet(\PhpParser\Node\Expr $expr, \PhpParser\Node\Expr\PropertyFetch $propertyFetch) : ?\PhpParser\Node + private function processMagicSet(Expr $expr, PropertyFetch $propertyFetch) : ?Node { foreach ($this->getAndSetToMethodCalls as $getAndSetToMethodCall) { $objectType = $getAndSetToMethodCall->getObjectType(); @@ -94,15 +94,15 @@ CODE_SAMPLE } return null; } - private function processPropertyFetch(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : ?\PhpParser\Node\Expr\MethodCall + private function processPropertyFetch(PropertyFetch $propertyFetch) : ?MethodCall { - $parentNode = $propertyFetch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $propertyFetch->getAttribute(AttributeKey::PARENT_NODE); foreach ($this->getAndSetToMethodCalls as $getAndSetToMethodCall) { if ($this->shouldSkipPropertyFetch($propertyFetch, $getAndSetToMethodCall->getObjectType())) { continue; } // setter, skip - if (!$parentNode instanceof \PhpParser\Node\Expr\Assign) { + if (!$parentNode instanceof Assign) { return $this->createMethodCallNodeFromPropertyFetchNode($propertyFetch, $getAndSetToMethodCall->getGetMethod()); } if ($parentNode->var !== $propertyFetch) { @@ -111,7 +111,7 @@ CODE_SAMPLE } return null; } - private function shouldSkipPropertyFetch(\PhpParser\Node\Expr\PropertyFetch $propertyFetch, \PHPStan\Type\ObjectType $objectType) : bool + private function shouldSkipPropertyFetch(PropertyFetch $propertyFetch, ObjectType $objectType) : bool { if (!$this->isObjectType($propertyFetch->var, $objectType)) { return \true; @@ -121,12 +121,12 @@ CODE_SAMPLE } return $this->propertyFetchAnalyzer->isPropertyToSelf($propertyFetch); } - private function createMethodCallNodeFromAssignNode(\PhpParser\Node\Expr\PropertyFetch $propertyFetch, \PhpParser\Node\Expr $expr, string $method) : \PhpParser\Node\Expr\MethodCall + private function createMethodCallNodeFromAssignNode(PropertyFetch $propertyFetch, Expr $expr, string $method) : MethodCall { $propertyName = $this->getName($propertyFetch->name); return $this->nodeFactory->createMethodCall($propertyFetch->var, $method, [$propertyName, $expr]); } - private function createMethodCallNodeFromPropertyFetchNode(\PhpParser\Node\Expr\PropertyFetch $propertyFetch, string $method) : \PhpParser\Node\Expr\MethodCall + private function createMethodCallNodeFromPropertyFetchNode(PropertyFetch $propertyFetch, string $method) : MethodCall { /** @var Variable $variableNode */ $variableNode = $propertyFetch->var; diff --git a/rules/Transform/Rector/Assign/PropertyAssignToMethodCallRector.php b/rules/Transform/Rector/Assign/PropertyAssignToMethodCallRector.php index 8055306fcd8..54d383afc3a 100644 --- a/rules/Transform/Rector/Assign/PropertyAssignToMethodCallRector.php +++ b/rules/Transform/Rector/Assign/PropertyAssignToMethodCallRector.php @@ -10,21 +10,21 @@ use PhpParser\Node\Expr\Variable; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Transform\ValueObject\PropertyAssignToMethodCall; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\Assign\PropertyAssignToMethodCallRector\PropertyAssignToMethodCallRectorTest */ -final class PropertyAssignToMethodCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class PropertyAssignToMethodCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var PropertyAssignToMethodCall[] */ private $propertyAssignsToMethodCalls = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns property assign of specific type and property name to method call', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns property assign of specific type and property name to method call', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' $someObject = new SomeClass; $someObject->oldProperty = false; CODE_SAMPLE @@ -32,21 +32,21 @@ CODE_SAMPLE $someObject = new SomeClass; $someObject->newMethodCall(false); CODE_SAMPLE -, [new \Rector\Transform\ValueObject\PropertyAssignToMethodCall('SomeClass', 'oldProperty', 'newMethodCall')])]); +, [new PropertyAssignToMethodCall('SomeClass', 'oldProperty', 'newMethodCall')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Assign::class]; + return [Assign::class]; } /** * @param Assign $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$node->var instanceof PropertyFetch) { return null; } $propertyFetchNode = $node->var; @@ -68,7 +68,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\PropertyAssignToMethodCall::class); + Assert::allIsAOf($configuration, PropertyAssignToMethodCall::class); $this->propertyAssignsToMethodCalls = $configuration; } } diff --git a/rules/Transform/Rector/Assign/PropertyFetchToMethodCallRector.php b/rules/Transform/Rector/Assign/PropertyFetchToMethodCallRector.php index 5d244b09198..a5beb371d66 100644 --- a/rules/Transform/Rector/Assign/PropertyFetchToMethodCallRector.php +++ b/rules/Transform/Rector/Assign/PropertyFetchToMethodCallRector.php @@ -11,21 +11,21 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Rector\AbstractRector; use Rector\Transform\ValueObject\PropertyFetchToMethodCall; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\Assign\PropertyFetchToMethodCallRector\PropertyFetchToMethodCallRectorTest */ -final class PropertyFetchToMethodCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class PropertyFetchToMethodCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var PropertyFetchToMethodCall[] */ private $propertiesToMethodCalls = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replaces properties assign calls be defined methods.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replaces properties assign calls be defined methods.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' $result = $object->property; $object->property = $value; @@ -37,24 +37,24 @@ $object->setProperty($value); $bare = $object->getConfig('someArg'); CODE_SAMPLE -, [new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('SomeObject', 'property', 'getProperty', 'setProperty'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('SomeObject', 'bareProperty', 'getConfig', null, ['someArg'])])]); +, [new PropertyFetchToMethodCall('SomeObject', 'property', 'getProperty', 'setProperty'), new PropertyFetchToMethodCall('SomeObject', 'bareProperty', 'getConfig', null, ['someArg'])])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Assign::class, \PhpParser\Node\Expr\PropertyFetch::class]; + return [Assign::class, PropertyFetch::class]; } /** * @param PropertyFetch|Assign $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\Assign && $node->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if ($node instanceof Assign && $node->var instanceof PropertyFetch) { return $this->processSetter($node); } - if ($node instanceof \PhpParser\Node\Expr\PropertyFetch) { + if ($node instanceof PropertyFetch) { return $this->processGetter($node); } return null; @@ -64,29 +64,29 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\PropertyFetchToMethodCall::class); + Assert::allIsAOf($configuration, PropertyFetchToMethodCall::class); $this->propertiesToMethodCalls = $configuration; } - private function processSetter(\PhpParser\Node\Expr\Assign $assign) : ?\PhpParser\Node + private function processSetter(Assign $assign) : ?Node { /** @var PropertyFetch $propertyFetchNode */ $propertyFetchNode = $assign->var; $propertyToMethodCall = $this->matchPropertyFetchCandidate($propertyFetchNode); - if (!$propertyToMethodCall instanceof \Rector\Transform\ValueObject\PropertyFetchToMethodCall) { + if (!$propertyToMethodCall instanceof PropertyFetchToMethodCall) { return null; } if ($propertyToMethodCall->getNewSetMethod() === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $args = $this->nodeFactory->createArgs([$assign->expr]); /** @var Variable $variable */ $variable = $propertyFetchNode->var; return $this->nodeFactory->createMethodCall($variable, $propertyToMethodCall->getNewSetMethod(), $args); } - private function processGetter(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : ?\PhpParser\Node + private function processGetter(PropertyFetch $propertyFetch) : ?Node { $propertyToMethodCall = $this->matchPropertyFetchCandidate($propertyFetch); - if (!$propertyToMethodCall instanceof \Rector\Transform\ValueObject\PropertyFetchToMethodCall) { + if (!$propertyToMethodCall instanceof PropertyFetchToMethodCall) { return null; } // simple method name @@ -100,7 +100,7 @@ CODE_SAMPLE } return $propertyFetch; } - private function matchPropertyFetchCandidate(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : ?\Rector\Transform\ValueObject\PropertyFetchToMethodCall + private function matchPropertyFetchCandidate(PropertyFetch $propertyFetch) : ?PropertyFetchToMethodCall { foreach ($this->propertiesToMethodCalls as $propertyToMethodCall) { if (!$this->isObjectType($propertyFetch->var, $propertyToMethodCall->getOldObjectType())) { diff --git a/rules/Transform/Rector/Attribute/AttributeKeyToClassConstFetchRector.php b/rules/Transform/Rector/Attribute/AttributeKeyToClassConstFetchRector.php index 8b0b931e25f..b8097b8d2c0 100644 --- a/rules/Transform/Rector/Attribute/AttributeKeyToClassConstFetchRector.php +++ b/rules/Transform/Rector/Attribute/AttributeKeyToClassConstFetchRector.php @@ -9,23 +9,23 @@ use PhpParser\Node\Identifier; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Transform\ValueObject\AttributeKeyToClassConstFetch; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @changelog https://github.com/doctrine/dbal/blob/3.1.x/src/Types/Types.php * * @see \Rector\Tests\Transform\Rector\Attribute\AttributeKeyToClassConstFetchRector\AttributeKeyToClassConstFetchRectorTest */ -final class AttributeKeyToClassConstFetchRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class AttributeKeyToClassConstFetchRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var AttributeKeyToClassConstFetch[] */ private $attributeKeysToClassConstFetches = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace key value on specific attribute to class constant', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace key value on specific attribute to class constant', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' use Doctrine\ORM\Mapping\Column; class SomeClass @@ -44,19 +44,19 @@ class SomeClass public $name; } CODE_SAMPLE -, [new \Rector\Transform\ValueObject\AttributeKeyToClassConstFetch('Doctrine\\ORM\\Mapping\\Column', 'type', 'Doctrine\\DBAL\\Types\\Types', ['string' => 'STRING'])])]); +, [new AttributeKeyToClassConstFetch('Doctrine\\ORM\\Mapping\\Column', 'type', 'Doctrine\\DBAL\\Types\\Types', ['string' => 'STRING'])])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Attribute::class]; + return [Attribute::class]; } /** * @param Attribute $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->attributeKeysToClassConstFetches as $attributeKeyToClassConstFetch) { if (!$this->isName($node->name, $attributeKeyToClassConstFetch->getAttributeClass())) { @@ -64,7 +64,7 @@ CODE_SAMPLE } foreach ($node->args as $arg) { $argName = $arg->name; - if (!$argName instanceof \PhpParser\Node\Identifier) { + if (!$argName instanceof Identifier) { continue; } if (!$this->isName($argName, $attributeKeyToClassConstFetch->getAttributeKey())) { @@ -86,7 +86,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\AttributeKeyToClassConstFetch::class); + Assert::allIsAOf($configuration, AttributeKeyToClassConstFetch::class); $this->attributeKeysToClassConstFetches = $configuration; } } diff --git a/rules/Transform/Rector/ClassMethod/ReturnTypeWillChangeRector.php b/rules/Transform/Rector/ClassMethod/ReturnTypeWillChangeRector.php index 4db8b92e4b8..c5569c08a69 100644 --- a/rules/Transform/Rector/ClassMethod/ReturnTypeWillChangeRector.php +++ b/rules/Transform/Rector/ClassMethod/ReturnTypeWillChangeRector.php @@ -16,12 +16,12 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer; use Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Transform\Rector\ClassMethod\ReturnTypeWillChangeRector\ReturnTypeWillChangeRectorTest */ -final class ReturnTypeWillChangeRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface, \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ReturnTypeWillChangeRector extends AbstractRector implements AllowEmptyConfigurableRectorInterface, MinPhpVersionInterface { /** * @var array @@ -37,14 +37,14 @@ final class ReturnTypeWillChangeRector extends \Rector\Core\Rector\AbstractRecto * @var \Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory */ private $phpAttributeGroupFactory; - public function __construct(\Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer $phpAttributeAnalyzer, \Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory $phpAttributeGroupFactory) + public function __construct(PhpAttributeAnalyzer $phpAttributeAnalyzer, PhpAttributeGroupFactory $phpAttributeGroupFactory) { $this->phpAttributeAnalyzer = $phpAttributeAnalyzer; $this->phpAttributeGroupFactory = $phpAttributeGroupFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add #[\\ReturnTypeWillChange] attribute to configured instanceof class with methods', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add #[\\ReturnTypeWillChange] attribute to configured instanceof class with methods', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass implements ArrayAccess { public function offsetGet($offset) @@ -68,12 +68,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->phpAttributeAnalyzer->hasPhpAttribute($node, 'ReturnTypeWillChange')) { return null; @@ -81,25 +81,25 @@ CODE_SAMPLE if ($node->returnType !== null) { return null; } - $classLike = $this->betterNodeFinder->findParentByTypes($node, [\PhpParser\Node\Stmt\Class_::class, \PhpParser\Node\Stmt\Interface_::class]); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentByTypes($node, [Class_::class, Interface_::class]); + if (!$classLike instanceof ClassLike) { return null; } /** @var array $classMethodsOfClass */ $classMethodsOfClass = \array_merge_recursive($this->resolveDefaultConfig(), $this->classMethodsOfClass); $className = (string) $this->nodeNameResolver->getName($classLike); - $objectType = new \PHPStan\Type\ObjectType($className); + $objectType = new ObjectType($className); $methodName = $this->nodeNameResolver->getName($node); $hasChanged = \false; foreach ($classMethodsOfClass as $class => $methods) { - $configuredClassObjectType = new \PHPStan\Type\ObjectType($class); + $configuredClassObjectType = new ObjectType($class); if (!$configuredClassObjectType->isSuperTypeOf($objectType)->yes()) { continue; } if (!\in_array($methodName, $methods, \true)) { continue; } - $attributeGroup = $this->phpAttributeGroupFactory->createFromClass(\Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator::RETURN_TYPE_WILL_CHANGE_ATTRIBUTE); + $attributeGroup = $this->phpAttributeGroupFactory->createFromClass(PhpDocFromTypeDeclarationDecorator::RETURN_TYPE_WILL_CHANGE_ATTRIBUTE); $node->attrGroups[] = $attributeGroup; $hasChanged = \true; break; @@ -118,7 +118,7 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::RETURN_TYPE_WILL_CHANGE_ATTRIBUTE; + return PhpVersionFeature::RETURN_TYPE_WILL_CHANGE_ATTRIBUTE; } /** * @return array @@ -126,7 +126,7 @@ CODE_SAMPLE private function resolveDefaultConfig() : array { $configuration = []; - foreach (\Rector\BetterPhpDocParser\PhpDocParser\PhpDocFromTypeDeclarationDecorator::ADD_RETURN_TYPE_WILL_CHANGE as $classWithMethods) { + foreach (PhpDocFromTypeDeclarationDecorator::ADD_RETURN_TYPE_WILL_CHANGE as $classWithMethods) { foreach ($classWithMethods as $class => $methods) { $configuration[$class] = \array_merge($configuration[$class] ?? [], $methods); } diff --git a/rules/Transform/Rector/ClassMethod/WrapReturnRector.php b/rules/Transform/Rector/ClassMethod/WrapReturnRector.php index 9c11d0c8101..565c8b68709 100644 --- a/rules/Transform/Rector/ClassMethod/WrapReturnRector.php +++ b/rules/Transform/Rector/ClassMethod/WrapReturnRector.php @@ -11,21 +11,21 @@ use PhpParser\Node\Stmt\Return_; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Transform\ValueObject\WrapReturn; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\ClassMethod\WrapReturnRector\WrapReturnRectorTest */ -final class WrapReturnRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class WrapReturnRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var WrapReturn[] */ private $typeMethodWraps = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Wrap return value of specific method', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Wrap return value of specific method', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function getItem() @@ -43,19 +43,19 @@ final class SomeClass } } CODE_SAMPLE -, [new \Rector\Transform\ValueObject\WrapReturn('SomeClass', 'getItem', \true)])]); +, [new WrapReturn('SomeClass', 'getItem', \true)])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->typeMethodWraps as $typeMethodWrap) { if (!$this->isObjectType($node, $typeMethodWrap->getObjectType())) { @@ -76,18 +76,18 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\WrapReturn::class); + Assert::allIsAOf($configuration, WrapReturn::class); $this->typeMethodWraps = $configuration; } - private function wrap(\PhpParser\Node\Stmt\ClassMethod $classMethod, bool $isArrayWrap) : ?\PhpParser\Node\Stmt\ClassMethod + private function wrap(ClassMethod $classMethod, bool $isArrayWrap) : ?ClassMethod { if (!\is_iterable($classMethod->stmts)) { return null; } foreach ($classMethod->stmts as $key => $stmt) { - if ($stmt instanceof \PhpParser\Node\Stmt\Return_ && $stmt->expr !== null) { - if ($isArrayWrap && !$stmt->expr instanceof \PhpParser\Node\Expr\Array_) { - $stmt->expr = new \PhpParser\Node\Expr\Array_([new \PhpParser\Node\Expr\ArrayItem($stmt->expr)]); + if ($stmt instanceof Return_ && $stmt->expr !== null) { + if ($isArrayWrap && !$stmt->expr instanceof Array_) { + $stmt->expr = new Array_([new ArrayItem($stmt->expr)]); } $classMethod->stmts[$key] = $stmt; } diff --git a/rules/Transform/Rector/Class_/AddAllowDynamicPropertiesAttributeRector.php b/rules/Transform/Rector/Class_/AddAllowDynamicPropertiesAttributeRector.php index a0a687ff4c6..c1a159660e5 100644 --- a/rules/Transform/Rector/Class_/AddAllowDynamicPropertiesAttributeRector.php +++ b/rules/Transform/Rector/Class_/AddAllowDynamicPropertiesAttributeRector.php @@ -15,15 +15,15 @@ use Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer; use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer; use Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @changelog https://wiki.php.net/rfc/deprecate_dynamic_properties * * @see \Rector\Tests\Transform\Rector\Class_\AddAllowDynamicPropertiesAttributeRector\AddAllowDynamicPropertiesAttributeRectorTest */ -final class AddAllowDynamicPropertiesAttributeRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface, \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class AddAllowDynamicPropertiesAttributeRector extends AbstractRector implements AllowEmptyConfigurableRectorInterface, MinPhpVersionInterface { /** * @var string @@ -53,16 +53,16 @@ final class AddAllowDynamicPropertiesAttributeRector extends \Rector\Core\Rector * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer $familyRelationsAnalyzer, \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer $phpAttributeAnalyzer, \Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory $phpAttributeGroupFactory, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(FamilyRelationsAnalyzer $familyRelationsAnalyzer, PhpAttributeAnalyzer $phpAttributeAnalyzer, PhpAttributeGroupFactory $phpAttributeGroupFactory, ReflectionProvider $reflectionProvider) { $this->familyRelationsAnalyzer = $familyRelationsAnalyzer; $this->phpAttributeAnalyzer = $phpAttributeAnalyzer; $this->phpAttributeGroupFactory = $phpAttributeGroupFactory; $this->reflectionProvider = $reflectionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add the `AllowDynamicProperties` attribute to all classes', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add the `AllowDynamicProperties` attribute to all classes', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' namespace Example\Domain; class SomeObject { @@ -84,18 +84,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } public function configure(array $configuration) : void { $transformOnNamespaces = $configuration; - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($transformOnNamespaces); + Assert::allString($transformOnNamespaces); $this->transformOnNamespaces = $transformOnNamespaces; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -104,34 +104,34 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::DEPRECATE_DYNAMIC_PROPERTIES; + return PhpVersionFeature::DEPRECATE_DYNAMIC_PROPERTIES; } - private function isDescendantOfStdclass(\PhpParser\Node\Stmt\Class_ $class) : bool + private function isDescendantOfStdclass(Class_ $class) : bool { - if (!$class->extends instanceof \PhpParser\Node\Name\FullyQualified) { + if (!$class->extends instanceof FullyQualified) { return \false; } $ancestorClassNames = $this->familyRelationsAnalyzer->getClassLikeAncestorNames($class); return \in_array('stdClass', $ancestorClassNames, \true); } - private function hasNeededAttributeAlready(\PhpParser\Node\Stmt\Class_ $class) : bool + private function hasNeededAttributeAlready(Class_ $class) : bool { $nodeHasAttribute = $this->phpAttributeAnalyzer->hasPhpAttribute($class, self::ATTRIBUTE); if ($nodeHasAttribute) { return \true; } - if (!$class->extends instanceof \PhpParser\Node\Name\FullyQualified) { + if (!$class->extends instanceof FullyQualified) { return \false; } return $this->phpAttributeAnalyzer->hasInheritedPhpAttribute($class, self::ATTRIBUTE); } - private function addAllowDynamicPropertiesAttribute(\PhpParser\Node\Stmt\Class_ $class) : \PhpParser\Node\Stmt\Class_ + private function addAllowDynamicPropertiesAttribute(Class_ $class) : Class_ { $attributeGroup = $this->phpAttributeGroupFactory->createFromClass(self::ATTRIBUTE); $class->attrGroups[] = $attributeGroup; return $class; } - private function shouldSkip(\PhpParser\Node\Stmt\Class_ $class) : bool + private function shouldSkip(Class_ $class) : bool { if ($this->transformOnNamespaces !== []) { $className = (string) $this->nodeNameResolver->getName($class); @@ -149,10 +149,10 @@ CODE_SAMPLE } return $this->hasMagicSetMethod($class); } - private function hasMagicSetMethod(\PhpParser\Node\Stmt\Class_ $class) : bool + private function hasMagicSetMethod(Class_ $class) : bool { $className = (string) $this->getName($class); $classReflection = $this->reflectionProvider->getClass($className); - return $classReflection->hasMethod(\Rector\Core\ValueObject\MethodName::__SET); + return $classReflection->hasMethod(MethodName::__SET); } } diff --git a/rules/Transform/Rector/Class_/AddInterfaceByTraitRector.php b/rules/Transform/Rector/Class_/AddInterfaceByTraitRector.php index 3775b4c1da0..4c15632e058 100644 --- a/rules/Transform/Rector/Class_/AddInterfaceByTraitRector.php +++ b/rules/Transform/Rector/Class_/AddInterfaceByTraitRector.php @@ -10,13 +10,13 @@ use PHPStan\Reflection\ClassReflection; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\Class_\AddInterfaceByTraitRector\AddInterfaceByTraitRectorTest */ -final class AddInterfaceByTraitRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class AddInterfaceByTraitRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var array @@ -27,13 +27,13 @@ final class AddInterfaceByTraitRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(ReflectionResolver $reflectionResolver) { $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add interface by used trait', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add interface by used trait', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { use SomeTrait; @@ -52,15 +52,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $classReflection = $this->reflectionResolver->resolveClassReflection($node); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return null; } $hasChanged = \false; @@ -73,7 +73,7 @@ CODE_SAMPLE continue 2; } } - $node->implements[] = new \PhpParser\Node\Name\FullyQualified($interfaceName); + $node->implements[] = new FullyQualified($interfaceName); $hasChanged = \true; } if (!$hasChanged) { @@ -87,8 +87,8 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString(\array_keys($configuration)); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configuration); + Assert::allString(\array_keys($configuration)); + Assert::allString($configuration); $this->interfaceByTrait = $configuration; } } diff --git a/rules/Transform/Rector/Class_/ChangeSingletonToServiceRector.php b/rules/Transform/Rector/Class_/ChangeSingletonToServiceRector.php index 1e0c6eea511..4b4470181be 100644 --- a/rules/Transform/Rector/Class_/ChangeSingletonToServiceRector.php +++ b/rules/Transform/Rector/Class_/ChangeSingletonToServiceRector.php @@ -12,15 +12,15 @@ use Rector\Core\ValueObject\MethodName; use Rector\Privatization\NodeManipulator\VisibilityManipulator; use Rector\Transform\NodeAnalyzer\SingletonClassMethodAnalyzer; use Rector\Transform\ValueObject\PropertyAndClassMethodName; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://3v4l.org/lifbH * @changelog https://stackoverflow.com/a/203359/1348344 * @changelog http://cleancode.blog/2017/07/20/how-to-avoid-many-instances-in-singleton-pattern/ * @see \Rector\Tests\Transform\Rector\Class_\ChangeSingletonToServiceRector\ChangeSingletonToServiceRectorTest */ -final class ChangeSingletonToServiceRector extends \Rector\Core\Rector\AbstractRector +final class ChangeSingletonToServiceRector extends AbstractRector { /** * @readonly @@ -37,15 +37,15 @@ final class ChangeSingletonToServiceRector extends \Rector\Core\Rector\AbstractR * @var \Rector\Privatization\NodeManipulator\VisibilityManipulator */ private $visibilityManipulator; - public function __construct(\Rector\Transform\NodeAnalyzer\SingletonClassMethodAnalyzer $singletonClassMethodAnalyzer, \Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer, \Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator) + public function __construct(SingletonClassMethodAnalyzer $singletonClassMethodAnalyzer, ClassAnalyzer $classAnalyzer, VisibilityManipulator $visibilityManipulator) { $this->singletonClassMethodAnalyzer = $singletonClassMethodAnalyzer; $this->classAnalyzer = $classAnalyzer; $this->visibilityManipulator = $visibilityManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change singleton class to normal class that can be registered as a service', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change singleton class to normal class that can be registered as a service', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { private static $instance; @@ -79,48 +79,48 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->classAnalyzer->isAnonymousClass($node)) { return null; } $propertyAndClassMethodName = $this->matchStaticPropertyFetchAndGetSingletonMethodName($node); - if (!$propertyAndClassMethodName instanceof \Rector\Transform\ValueObject\PropertyAndClassMethodName) { + if (!$propertyAndClassMethodName instanceof PropertyAndClassMethodName) { return null; } return $this->refactorClassStmts($node, $propertyAndClassMethodName); } - private function matchStaticPropertyFetchAndGetSingletonMethodName(\PhpParser\Node\Stmt\Class_ $class) : ?\Rector\Transform\ValueObject\PropertyAndClassMethodName + private function matchStaticPropertyFetchAndGetSingletonMethodName(Class_ $class) : ?PropertyAndClassMethodName { foreach ($class->getMethods() as $classMethod) { if (!$classMethod->isStatic()) { continue; } $staticPropertyFetch = $this->singletonClassMethodAnalyzer->matchStaticPropertyFetch($classMethod); - if (!$staticPropertyFetch instanceof \PhpParser\Node\Expr\StaticPropertyFetch) { + if (!$staticPropertyFetch instanceof StaticPropertyFetch) { return null; } /** @var string $propertyName */ $propertyName = $this->getName($staticPropertyFetch); /** @var string $classMethodName */ $classMethodName = $this->getName($classMethod); - return new \Rector\Transform\ValueObject\PropertyAndClassMethodName($propertyName, $classMethodName); + return new PropertyAndClassMethodName($propertyName, $classMethodName); } return null; } - private function refactorClassStmts(\PhpParser\Node\Stmt\Class_ $class, \Rector\Transform\ValueObject\PropertyAndClassMethodName $propertyAndClassMethodName) : \PhpParser\Node\Stmt\Class_ + private function refactorClassStmts(Class_ $class, PropertyAndClassMethodName $propertyAndClassMethodName) : Class_ { foreach ($class->getMethods() as $classMethod) { if ($this->isName($classMethod, $propertyAndClassMethodName->getClassMethodName())) { $this->nodeRemover->removeNodeFromStatements($class, $classMethod); continue; } - if (!$this->isNames($classMethod, [\Rector\Core\ValueObject\MethodName::CONSTRUCT, \Rector\Core\ValueObject\MethodName::CLONE, '__wakeup'])) { + if (!$this->isNames($classMethod, [MethodName::CONSTRUCT, MethodName::CLONE, '__wakeup'])) { continue; } if ($classMethod->isPublic()) { @@ -136,7 +136,7 @@ CODE_SAMPLE $this->removePropertyByName($class, $propertyAndClassMethodName->getPropertyName()); return $class; } - private function removePropertyByName(\PhpParser\Node\Stmt\Class_ $class, string $propertyName) : void + private function removePropertyByName(Class_ $class, string $propertyName) : void { foreach ($class->getProperties() as $property) { if (!$this->isName($property, $propertyName)) { diff --git a/rules/Transform/Rector/Class_/MergeInterfacesRector.php b/rules/Transform/Rector/Class_/MergeInterfacesRector.php index ee38b07465f..c98c700bfb3 100644 --- a/rules/Transform/Rector/Class_/MergeInterfacesRector.php +++ b/rules/Transform/Rector/Class_/MergeInterfacesRector.php @@ -8,8 +8,8 @@ use PhpParser\Node\Name; use PhpParser\Node\Stmt\Class_; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * Covers cases like @@ -18,15 +18,15 @@ use RectorPrefix20220607\Webmozart\Assert\Assert; * * @see \Rector\Tests\Transform\Rector\Class_\MergeInterfacesRector\MergeInterfacesRectorTest */ -final class MergeInterfacesRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class MergeInterfacesRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var array */ private $oldToNewInterfaces = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Merges old interface to a new one, that already has its methods', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Merges old interface to a new one, that already has its methods', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass implements SomeInterface, SomeOldInterface { } @@ -43,12 +43,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->implements === []) { return null; @@ -60,7 +60,7 @@ CODE_SAMPLE continue; } $interface = $this->getName($implement); - $node->implements[$key] = new \PhpParser\Node\Name($this->oldToNewInterfaces[$interface]); + $node->implements[$key] = new Name($this->oldToNewInterfaces[$interface]); $hasChanged = \true; } if (!$hasChanged) { @@ -74,11 +74,11 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString(\array_keys($configuration)); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configuration); + Assert::allString(\array_keys($configuration)); + Assert::allString($configuration); $this->oldToNewInterfaces = $configuration; } - private function makeImplementsUnique(\PhpParser\Node\Stmt\Class_ $class) : void + private function makeImplementsUnique(Class_ $class) : void { $alreadyAddedNames = []; foreach ($class->implements as $key => $name) { diff --git a/rules/Transform/Rector/Class_/ParentClassToTraitsRector.php b/rules/Transform/Rector/Class_/ParentClassToTraitsRector.php index 236c8525df8..1d485e21f42 100644 --- a/rules/Transform/Rector/Class_/ParentClassToTraitsRector.php +++ b/rules/Transform/Rector/Class_/ParentClassToTraitsRector.php @@ -11,8 +11,8 @@ use Rector\Core\NodeAnalyzer\ClassAnalyzer; use Rector\Core\NodeManipulator\ClassInsertManipulator; use Rector\Core\Rector\AbstractRector; use Rector\Transform\ValueObject\ParentClassToTraits; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * Can handle cases like: @@ -21,7 +21,7 @@ use RectorPrefix20220607\Webmozart\Assert\Assert; * * @see \Rector\Tests\Transform\Rector\Class_\ParentClassToTraitsRector\ParentClassToTraitsRectorTest */ -final class ParentClassToTraitsRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class ParentClassToTraitsRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var ParentClassToTraits[] @@ -37,14 +37,14 @@ final class ParentClassToTraitsRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Core\NodeAnalyzer\ClassAnalyzer */ private $classAnalyzer; - public function __construct(\Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator, \Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer) + public function __construct(ClassInsertManipulator $classInsertManipulator, ClassAnalyzer $classAnalyzer) { $this->classInsertManipulator = $classInsertManipulator; $this->classAnalyzer = $classAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replaces parent class to specific traits', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replaces parent class to specific traits', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass extends Nette\Object { } @@ -55,22 +55,22 @@ class SomeClass use Nette\SmartObject; } CODE_SAMPLE -, [new \Rector\Transform\ValueObject\ParentClassToTraits('Nette\\Object', ['Nette\\SmartObject'])])]); +, [new ParentClassToTraits('Nette\\Object', ['Nette\\SmartObject'])])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $parentExtends = $node->extends; - if (!$parentExtends instanceof \PhpParser\Node\Name) { + if (!$parentExtends instanceof Name) { return null; } if ($this->classAnalyzer->isAnonymousClass($node)) { @@ -93,10 +93,10 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\ParentClassToTraits::class); + Assert::allIsAOf($configuration, ParentClassToTraits::class); $this->parentClassToTraits = $configuration; } - private function removeParentClass(\PhpParser\Node\Stmt\Class_ $class) : void + private function removeParentClass(Class_ $class) : void { $class->extends = null; } diff --git a/rules/Transform/Rector/Class_/RemoveAllowDynamicPropertiesAttributeRector.php b/rules/Transform/Rector/Class_/RemoveAllowDynamicPropertiesAttributeRector.php index 9749191163a..0cbb0740e09 100644 --- a/rules/Transform/Rector/Class_/RemoveAllowDynamicPropertiesAttributeRector.php +++ b/rules/Transform/Rector/Class_/RemoveAllowDynamicPropertiesAttributeRector.php @@ -8,15 +8,15 @@ use PhpParser\Node\Stmt\Class_; use Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @changelog https://wiki.php.net/rfc/deprecate_dynamic_properties * * @see \Rector\Tests\Transform\Rector\Class_\RemoveAllowDynamicPropertiesAttributeRector\RemoveAllowDynamicPropertiesAttributeRectorTest */ -final class RemoveAllowDynamicPropertiesAttributeRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface +final class RemoveAllowDynamicPropertiesAttributeRector extends AbstractRector implements AllowEmptyConfigurableRectorInterface { /** * @var string @@ -31,13 +31,13 @@ final class RemoveAllowDynamicPropertiesAttributeRector extends \Rector\Core\Rec * @var \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer */ private $phpAttributeAnalyzer; - public function __construct(\Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer $phpAttributeAnalyzer) + public function __construct(PhpAttributeAnalyzer $phpAttributeAnalyzer) { $this->phpAttributeAnalyzer = $phpAttributeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove the `AllowDynamicProperties` attribute from all classes', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove the `AllowDynamicProperties` attribute from all classes', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' namespace Example\Domain; #[AllowDynamicProperties] @@ -59,25 +59,25 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } public function configure(array $configuration) : void { $transformOnNamespaces = $configuration; - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($transformOnNamespaces); + Assert::allString($transformOnNamespaces); $this->transformOnNamespaces = $transformOnNamespaces; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldRemove($node)) { return $this->removeAllowDynamicPropertiesAttribute($node); } return null; } - private function removeAllowDynamicPropertiesAttribute(\PhpParser\Node\Stmt\Class_ $class) : \PhpParser\Node\Stmt\Class_ + private function removeAllowDynamicPropertiesAttribute(Class_ $class) : Class_ { $newAttrGroups = []; foreach ($class->attrGroups as $attrGroup) { @@ -95,7 +95,7 @@ CODE_SAMPLE $class->attrGroups = $newAttrGroups; return $class; } - private function shouldRemove(\PhpParser\Node\Stmt\Class_ $class) : bool + private function shouldRemove(Class_ $class) : bool { if ($this->transformOnNamespaces !== []) { $className = (string) $this->nodeNameResolver->getName($class); diff --git a/rules/Transform/Rector/FuncCall/ArgumentFuncCallToMethodCallRector.php b/rules/Transform/Rector/FuncCall/ArgumentFuncCallToMethodCallRector.php index 975d1bdeddd..bdce8caab5e 100644 --- a/rules/Transform/Rector/FuncCall/ArgumentFuncCallToMethodCallRector.php +++ b/rules/Transform/Rector/FuncCall/ArgumentFuncCallToMethodCallRector.php @@ -22,13 +22,13 @@ use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use Rector\Transform\Contract\ValueObject\ArgumentFuncCallToMethodCallInterface; use Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall; use Rector\Transform\ValueObject\ArrayFuncCallToMethodCall; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\FuncCall\ArgumentFuncCallToMethodCallRector\ArgumentFuncCallToMethodCallRectorTest */ -final class ArgumentFuncCallToMethodCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class ArgumentFuncCallToMethodCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var ArgumentFuncCallToMethodCallInterface[] @@ -49,15 +49,15 @@ final class ArgumentFuncCallToMethodCallRector extends \Rector\Core\Rector\Abstr * @var \Rector\PostRector\Collector\PropertyToAddCollector */ private $propertyToAddCollector; - public function __construct(\Rector\NodeTypeResolver\TypeAnalyzer\ArrayTypeAnalyzer $arrayTypeAnalyzer, \Rector\Naming\Naming\PropertyNaming $propertyNaming, \Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector) + public function __construct(ArrayTypeAnalyzer $arrayTypeAnalyzer, PropertyNaming $propertyNaming, PropertyToAddCollector $propertyToAddCollector) { $this->arrayTypeAnalyzer = $arrayTypeAnalyzer; $this->propertyNaming = $propertyNaming; $this->propertyToAddCollector = $propertyToAddCollector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Move help facade-like function calls to constructor injection', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Move help facade-like function calls to constructor injection', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeController { public function action() @@ -87,33 +87,33 @@ class SomeController } } CODE_SAMPLE -, [new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('view', 'Illuminate\\Contracts\\View\\Factory', 'make')])]); +, [new ArgumentFuncCallToMethodCall('view', 'Illuminate\\Contracts\\View\\Factory', 'make')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkipFuncCall($node)) { return null; } /** @var Class_ $classLike */ - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); + $classLike = $this->betterNodeFinder->findParentType($node, Class_::class); foreach ($this->argumentFuncCallToMethodCalls as $argumentFuncCallToMethodCall) { if (!$this->isName($node, $argumentFuncCallToMethodCall->getFunction())) { continue; } - if ($argumentFuncCallToMethodCall instanceof \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall) { + if ($argumentFuncCallToMethodCall instanceof ArgumentFuncCallToMethodCall) { return $this->refactorFuncCallToMethodCall($argumentFuncCallToMethodCall, $classLike, $node); } - if ($argumentFuncCallToMethodCall instanceof \Rector\Transform\ValueObject\ArrayFuncCallToMethodCall) { + if ($argumentFuncCallToMethodCall instanceof ArrayFuncCallToMethodCall) { return $this->refactorArrayFunctionToMethodCall($argumentFuncCallToMethodCall, $node, $classLike); } } @@ -124,15 +124,15 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\Contract\ValueObject\ArgumentFuncCallToMethodCallInterface::class); + Assert::allIsAOf($configuration, ArgumentFuncCallToMethodCallInterface::class); $this->argumentFuncCallToMethodCalls = $configuration; } - private function shouldSkipFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function shouldSkipFuncCall(FuncCall $funcCall) : bool { // we can inject only in injectable class method context /** @var ClassMethod|null $classMethod */ - $classMethod = $this->betterNodeFinder->findParentType($funcCall, \PhpParser\Node\Stmt\ClassMethod::class); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $this->betterNodeFinder->findParentType($funcCall, ClassMethod::class); + if (!$classMethod instanceof ClassMethod) { return \true; } return $classMethod->isStatic(); @@ -140,14 +140,14 @@ CODE_SAMPLE /** * @return MethodCall|PropertyFetch|null */ - private function refactorFuncCallToMethodCall(\Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall $argumentFuncCallToMethodCall, \PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node + private function refactorFuncCallToMethodCall(ArgumentFuncCallToMethodCall $argumentFuncCallToMethodCall, Class_ $class, FuncCall $funcCall) : ?Node { - $fullyQualifiedObjectType = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($argumentFuncCallToMethodCall->getClass()); + $fullyQualifiedObjectType = new FullyQualifiedObjectType($argumentFuncCallToMethodCall->getClass()); $expectedName = $this->propertyNaming->getExpectedNameFromType($fullyQualifiedObjectType); - if (!$expectedName instanceof \Rector\Naming\ValueObject\ExpectedName) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$expectedName instanceof ExpectedName) { + throw new ShouldNotHappenException(); } - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($expectedName->getName(), $fullyQualifiedObjectType, \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $propertyMetadata = new PropertyMetadata($expectedName->getName(), $fullyQualifiedObjectType, Class_::MODIFIER_PRIVATE); $this->propertyToAddCollector->addPropertyToClass($class, $propertyMetadata); $propertyFetchNode = $this->nodeFactory->createPropertyFetch('this', $expectedName->getName()); if ($funcCall->args === []) { @@ -156,36 +156,36 @@ CODE_SAMPLE if ($this->isFunctionToMethodCallWithArgs($funcCall, $argumentFuncCallToMethodCall)) { $methodName = $argumentFuncCallToMethodCall->getMethodIfArgs(); if (!\is_string($methodName)) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } - return new \PhpParser\Node\Expr\MethodCall($propertyFetchNode, $methodName, $funcCall->args); + return new MethodCall($propertyFetchNode, $methodName, $funcCall->args); } return null; } /** * @return PropertyFetch|MethodCall|null */ - private function refactorArrayFunctionToMethodCall(\Rector\Transform\ValueObject\ArrayFuncCallToMethodCall $arrayFuncCallToMethodCall, \PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Stmt\Class_ $class) : ?\PhpParser\Node + private function refactorArrayFunctionToMethodCall(ArrayFuncCallToMethodCall $arrayFuncCallToMethodCall, FuncCall $funcCall, Class_ $class) : ?Node { $propertyName = $this->propertyNaming->fqnToVariableName($arrayFuncCallToMethodCall->getClass()); $propertyFetch = $this->nodeFactory->createPropertyFetch('this', $propertyName); - $fullyQualifiedObjectType = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($arrayFuncCallToMethodCall->getClass()); - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($propertyName, $fullyQualifiedObjectType, \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $fullyQualifiedObjectType = new FullyQualifiedObjectType($arrayFuncCallToMethodCall->getClass()); + $propertyMetadata = new PropertyMetadata($propertyName, $fullyQualifiedObjectType, Class_::MODIFIER_PRIVATE); $this->propertyToAddCollector->addPropertyToClass($class, $propertyMetadata); return $this->createMethodCallArrayFunctionToMethodCall($funcCall, $arrayFuncCallToMethodCall, $propertyFetch); } /** * @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\PropertyFetch */ - private function refactorEmptyFuncCallArgs(\Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall $argumentFuncCallToMethodCall, \PhpParser\Node\Expr\PropertyFetch $propertyFetch) + private function refactorEmptyFuncCallArgs(ArgumentFuncCallToMethodCall $argumentFuncCallToMethodCall, PropertyFetch $propertyFetch) { if ($argumentFuncCallToMethodCall->getMethodIfNoArgs() !== null) { $methodName = $argumentFuncCallToMethodCall->getMethodIfNoArgs(); - return new \PhpParser\Node\Expr\MethodCall($propertyFetch, $methodName); + return new MethodCall($propertyFetch, $methodName); } return $propertyFetch; } - private function isFunctionToMethodCallWithArgs(\PhpParser\Node\Expr\FuncCall $funcCall, \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall $argumentFuncCallToMethodCall) : bool + private function isFunctionToMethodCallWithArgs(FuncCall $funcCall, ArgumentFuncCallToMethodCall $argumentFuncCallToMethodCall) : bool { if ($argumentFuncCallToMethodCall->getMethodIfArgs() === null) { return \false; @@ -195,20 +195,20 @@ CODE_SAMPLE /** * @return PropertyFetch|MethodCall|null */ - private function createMethodCallArrayFunctionToMethodCall(\PhpParser\Node\Expr\FuncCall $funcCall, \Rector\Transform\ValueObject\ArrayFuncCallToMethodCall $arrayFuncCallToMethodCall, \PhpParser\Node\Expr\PropertyFetch $propertyFetch) : ?\PhpParser\Node + private function createMethodCallArrayFunctionToMethodCall(FuncCall $funcCall, ArrayFuncCallToMethodCall $arrayFuncCallToMethodCall, PropertyFetch $propertyFetch) : ?Node { if ($funcCall->args === []) { return $propertyFetch; } - if (!$funcCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[0] instanceof Arg) { return null; } if ($this->arrayTypeAnalyzer->isArrayType($funcCall->args[0]->value)) { - return new \PhpParser\Node\Expr\MethodCall($propertyFetch, $arrayFuncCallToMethodCall->getArrayMethod(), $funcCall->args); + return new MethodCall($propertyFetch, $arrayFuncCallToMethodCall->getArrayMethod(), $funcCall->args); } if ($arrayFuncCallToMethodCall->getNonArrayMethod() === '') { return null; } - return new \PhpParser\Node\Expr\MethodCall($propertyFetch, $arrayFuncCallToMethodCall->getNonArrayMethod(), $funcCall->args); + return new MethodCall($propertyFetch, $arrayFuncCallToMethodCall->getNonArrayMethod(), $funcCall->args); } } diff --git a/rules/Transform/Rector/FuncCall/FuncCallToConstFetchRector.php b/rules/Transform/Rector/FuncCall/FuncCallToConstFetchRector.php index 0ccaab940c4..a2f51e42e96 100644 --- a/rules/Transform/Rector/FuncCall/FuncCallToConstFetchRector.php +++ b/rules/Transform/Rector/FuncCall/FuncCallToConstFetchRector.php @@ -9,21 +9,21 @@ use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Name; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\FuncCall\FuncCallToConstFetchRector\FunctionCallToConstantRectorTest */ -final class FuncCallToConstFetchRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class FuncCallToConstFetchRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var string[] */ private $functionsToConstants = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes use of function calls to use constants', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes use of function calls to use constants', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -48,12 +48,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $functionName = $this->getName($node); if (!\is_string($functionName)) { @@ -62,15 +62,15 @@ CODE_SAMPLE if (!\array_key_exists($functionName, $this->functionsToConstants)) { return null; } - return new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name($this->functionsToConstants[$functionName])); + return new ConstFetch(new Name($this->functionsToConstants[$functionName])); } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configuration); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString(\array_keys($configuration)); + Assert::allString($configuration); + Assert::allString(\array_keys($configuration)); /** @var array $configuration */ $this->functionsToConstants = $configuration; } diff --git a/rules/Transform/Rector/FuncCall/FuncCallToMethodCallRector.php b/rules/Transform/Rector/FuncCall/FuncCallToMethodCallRector.php index b7306962665..7609dac1467 100644 --- a/rules/Transform/Rector/FuncCall/FuncCallToMethodCallRector.php +++ b/rules/Transform/Rector/FuncCall/FuncCallToMethodCallRector.php @@ -11,13 +11,13 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Transform\NodeAnalyzer\FuncCallStaticCallToMethodCallAnalyzer; use Rector\Transform\ValueObject\FuncCallToMethodCall; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\FuncCall\FuncCallToMethodCallRector\FuncCallToMethodCallRectorTest */ -final class FuncCallToMethodCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class FuncCallToMethodCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var FuncCallToMethodCall[] @@ -28,13 +28,13 @@ final class FuncCallToMethodCallRector extends \Rector\Core\Rector\AbstractRecto * @var \Rector\Transform\NodeAnalyzer\FuncCallStaticCallToMethodCallAnalyzer */ private $funcCallStaticCallToMethodCallAnalyzer; - public function __construct(\Rector\Transform\NodeAnalyzer\FuncCallStaticCallToMethodCallAnalyzer $funcCallStaticCallToMethodCallAnalyzer) + public function __construct(FuncCallStaticCallToMethodCallAnalyzer $funcCallStaticCallToMethodCallAnalyzer) { $this->funcCallStaticCallToMethodCallAnalyzer = $funcCallStaticCallToMethodCallAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns defined function calls to local method calls.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns defined function calls to local method calls.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -62,26 +62,26 @@ class SomeClass } } CODE_SAMPLE -, [new \Rector\Transform\ValueObject\FuncCallToMethodCall('view', 'Namespaced\\SomeRenderer', 'render')])]); +, [new FuncCallToMethodCall('view', 'Namespaced\\SomeRenderer', 'render')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLike = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$classLike instanceof Class_) { return null; } - $classMethod = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassMethod::class); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $this->betterNodeFinder->findParentType($node, ClassMethod::class); + if (!$classMethod instanceof ClassMethod) { return null; } if ($classMethod->isStatic()) { @@ -101,7 +101,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\FuncCallToMethodCall::class); + Assert::allIsAOf($configuration, FuncCallToMethodCall::class); $this->funcNameToMethodCallNames = $configuration; } } diff --git a/rules/Transform/Rector/FuncCall/FuncCallToNewRector.php b/rules/Transform/Rector/FuncCall/FuncCallToNewRector.php index 23a01f3607f..f2cc03babc9 100644 --- a/rules/Transform/Rector/FuncCall/FuncCallToNewRector.php +++ b/rules/Transform/Rector/FuncCall/FuncCallToNewRector.php @@ -9,21 +9,21 @@ use PhpParser\Node\Expr\New_; use PhpParser\Node\Name\FullyQualified; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\FuncCall\FuncCallToNewRector\FuncCallToNewRectorTest */ -final class FuncCallToNewRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class FuncCallToNewRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var string[] */ private $functionToNew = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change configured function calls to new Instance', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change configured function calls to new Instance', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -48,18 +48,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->functionToNew as $function => $new) { if (!$this->isName($node, $function)) { continue; } - return new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name\FullyQualified($new), $node->args); + return new New_(new FullyQualified($new), $node->args); } return null; } @@ -68,7 +68,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configuration); + Assert::allString($configuration); $this->functionToNew = $configuration; } } diff --git a/rules/Transform/Rector/FuncCall/FuncCallToStaticCallRector.php b/rules/Transform/Rector/FuncCall/FuncCallToStaticCallRector.php index 5d82e60ecd6..3f7264bfb07 100644 --- a/rules/Transform/Rector/FuncCall/FuncCallToStaticCallRector.php +++ b/rules/Transform/Rector/FuncCall/FuncCallToStaticCallRector.php @@ -8,33 +8,33 @@ use PhpParser\Node\Expr\FuncCall; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Transform\ValueObject\FuncCallToStaticCall; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\FuncCall\FuncCallToStaticCallRector\FuncCallToStaticCallRectorTest */ -final class FuncCallToStaticCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class FuncCallToStaticCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var FuncCallToStaticCall[] */ private $funcCallsToStaticCalls = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns defined function call to static method call.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample('view("...", []);', 'SomeClass::render("...", []);', [new \Rector\Transform\ValueObject\FuncCallToStaticCall('view', 'SomeStaticClass', 'render')])]); + return new RuleDefinition('Turns defined function call to static method call.', [new ConfiguredCodeSample('view("...", []);', 'SomeClass::render("...", []);', [new FuncCallToStaticCall('view', 'SomeStaticClass', 'render')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->funcCallsToStaticCalls as $funcCallToStaticCall) { if (!$this->isName($node, $funcCallToStaticCall->getOldFuncName())) { @@ -49,7 +49,7 @@ final class FuncCallToStaticCallRector extends \Rector\Core\Rector\AbstractRecto */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\FuncCallToStaticCall::class); + Assert::allIsAOf($configuration, FuncCallToStaticCall::class); $this->funcCallsToStaticCalls = $configuration; } } diff --git a/rules/Transform/Rector/FunctionLike/FileGetContentsAndJsonDecodeToStaticCallRector.php b/rules/Transform/Rector/FunctionLike/FileGetContentsAndJsonDecodeToStaticCallRector.php index 0d24e60b3d4..2a88f002023 100644 --- a/rules/Transform/Rector/FunctionLike/FileGetContentsAndJsonDecodeToStaticCallRector.php +++ b/rules/Transform/Rector/FunctionLike/FileGetContentsAndJsonDecodeToStaticCallRector.php @@ -15,21 +15,21 @@ use PhpParser\Node\Stmt\Return_; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Transform\ValueObject\StaticCallRecipe; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\FunctionLike\FileGetContentsAndJsonDecodeToStaticCallRector\FileGetContentsAndJsonDecodeToStaticCallRectorTest */ -final class FileGetContentsAndJsonDecodeToStaticCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class FileGetContentsAndJsonDecodeToStaticCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var \Rector\Transform\ValueObject\StaticCallRecipe */ private $staticCallRecipe; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Merge 2 function calls to static call', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Merge 2 function calls to static call', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function load($filePath) @@ -48,19 +48,19 @@ final class SomeClass } } CODE_SAMPLE -, [new \Rector\Transform\ValueObject\StaticCallRecipe('FileLoader', 'loadJson')])]); +, [new StaticCallRecipe('FileLoader', 'loadJson')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\FunctionLike::class]; + return [FunctionLike::class]; } /** * @param FunctionLike $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $stmts = $node->getStmts(); if ($stmts === null) { @@ -87,38 +87,38 @@ CODE_SAMPLE public function configure(array $configuration) : void { $staticCallRecipe = $configuration[0] ?? null; - \RectorPrefix20220607\Webmozart\Assert\Assert::isInstanceOf($staticCallRecipe, \Rector\Transform\ValueObject\StaticCallRecipe::class); + Assert::isInstanceOf($staticCallRecipe, StaticCallRecipe::class); $this->staticCallRecipe = $staticCallRecipe; } - private function createStaticCall(\PhpParser\Node\Expr\FuncCall $fileGetContentsFuncCall) : \PhpParser\Node\Expr\StaticCall + private function createStaticCall(FuncCall $fileGetContentsFuncCall) : StaticCall { - $fullyQualified = new \PhpParser\Node\Name\FullyQualified($this->staticCallRecipe->getClassName()); - return new \PhpParser\Node\Expr\StaticCall($fullyQualified, $this->staticCallRecipe->getMethodName(), $fileGetContentsFuncCall->getArgs()); + $fullyQualified = new FullyQualified($this->staticCallRecipe->getClassName()); + return new StaticCall($fullyQualified, $this->staticCallRecipe->getMethodName(), $fileGetContentsFuncCall->getArgs()); } - private function processStmt(?\PhpParser\Node\Stmt $previousStmt, \PhpParser\Node\Stmt $currentStmt) : bool + private function processStmt(?Stmt $previousStmt, Stmt $currentStmt) : bool { - if (!$previousStmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$previousStmt instanceof Expression) { return \false; } $previousExpr = $previousStmt->expr; - if (!$previousExpr instanceof \PhpParser\Node\Expr\Assign) { + if (!$previousExpr instanceof Assign) { return \false; } $previousAssign = $previousExpr; - if (!$previousAssign->expr instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$previousAssign->expr instanceof FuncCall) { return \false; } if (!$this->isName($previousAssign->expr, 'file_get_contents')) { return \false; } $fileGetContentsFuncCall = $previousAssign->expr; - if ($currentStmt instanceof \PhpParser\Node\Stmt\Return_) { + if ($currentStmt instanceof Return_) { return $this->refactorReturnAndAssign($currentStmt, $fileGetContentsFuncCall); } - if (!$currentStmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$currentStmt instanceof Expression) { return \false; } - if (!$currentStmt->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$currentStmt->expr instanceof Assign) { return \false; } return $this->refactorReturnAndAssign($currentStmt->expr, $fileGetContentsFuncCall); @@ -126,9 +126,9 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Stmt\Return_|\PhpParser\Node\Expr\Assign $currentStmt */ - private function refactorReturnAndAssign($currentStmt, \PhpParser\Node\Expr\FuncCall $fileGetContentsFuncCall) : bool + private function refactorReturnAndAssign($currentStmt, FuncCall $fileGetContentsFuncCall) : bool { - if (!$currentStmt->expr instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$currentStmt->expr instanceof FuncCall) { return \false; } if (!$this->isName($currentStmt->expr, 'json_decode')) { diff --git a/rules/Transform/Rector/Isset_/UnsetAndIssetToMethodCallRector.php b/rules/Transform/Rector/Isset_/UnsetAndIssetToMethodCallRector.php index d45c9686006..730273d277b 100644 --- a/rules/Transform/Rector/Isset_/UnsetAndIssetToMethodCallRector.php +++ b/rules/Transform/Rector/Isset_/UnsetAndIssetToMethodCallRector.php @@ -10,21 +10,21 @@ use PhpParser\Node\Stmt\Unset_; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Transform\ValueObject\UnsetAndIssetToMethodCall; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\Isset_\UnsetAndIssetToMethodCallRector\UnsetAndIssetToMethodCallRectorTest */ -final class UnsetAndIssetToMethodCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class UnsetAndIssetToMethodCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var UnsetAndIssetToMethodCall[] */ private $issetUnsetToMethodCalls = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns defined `__isset`/`__unset` calls to specific method calls.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns defined `__isset`/`__unset` calls to specific method calls.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' $container = new SomeContainer; isset($container["someKey"]); unset($container["someKey"]); @@ -34,22 +34,22 @@ $container = new SomeContainer; $container->hasService("someKey"); $container->removeService("someKey"); CODE_SAMPLE -, [new \Rector\Transform\ValueObject\UnsetAndIssetToMethodCall('SomeContainer', 'hasService', 'removeService')])]); +, [new UnsetAndIssetToMethodCall('SomeContainer', 'hasService', 'removeService')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Isset_::class, \PhpParser\Node\Stmt\Unset_::class]; + return [Isset_::class, Unset_::class]; } /** * @param Isset_|Unset_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($node->vars as $arrayDimFetch) { - if (!$arrayDimFetch instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$arrayDimFetch instanceof ArrayDimFetch) { continue; } foreach ($this->issetUnsetToMethodCalls as $issetUnsetToMethodCall) { @@ -69,18 +69,18 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\UnsetAndIssetToMethodCall::class); + Assert::allIsAOf($configuration, UnsetAndIssetToMethodCall::class); $this->issetUnsetToMethodCalls = $configuration; } - private function processArrayDimFetchNode(\PhpParser\Node $node, \PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch, \Rector\Transform\ValueObject\UnsetAndIssetToMethodCall $unsetAndIssetToMethodCall) : ?\PhpParser\Node + private function processArrayDimFetchNode(Node $node, ArrayDimFetch $arrayDimFetch, UnsetAndIssetToMethodCall $unsetAndIssetToMethodCall) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\Isset_) { + if ($node instanceof Isset_) { if ($unsetAndIssetToMethodCall->getIssetMethodCall() === '') { return null; } return $this->nodeFactory->createMethodCall($arrayDimFetch->var, $unsetAndIssetToMethodCall->getIssetMethodCall(), [$arrayDimFetch->dim]); } - if ($node instanceof \PhpParser\Node\Stmt\Unset_) { + if ($node instanceof Unset_) { if ($unsetAndIssetToMethodCall->getUnsedMethodCall() === '') { return null; } diff --git a/rules/Transform/Rector/MethodCall/CallableInMethodCallToVariableRector.php b/rules/Transform/Rector/MethodCall/CallableInMethodCallToVariableRector.php index b1000ebe07b..9bcd0654a0c 100644 --- a/rules/Transform/Rector/MethodCall/CallableInMethodCallToVariableRector.php +++ b/rules/Transform/Rector/MethodCall/CallableInMethodCallToVariableRector.php @@ -12,15 +12,15 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Transform\NodeFactory\UnwrapClosureFactory; use Rector\Transform\ValueObject\CallableInMethodCallToVariable; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @changelog https://github.com/nette/caching/commit/5ffe263752af5ccf3866a28305e7b2669ab4da82 * * @see \Rector\Tests\Transform\Rector\MethodCall\CallableInMethodCallToVariableRector\CallableInMethodCallToVariableRectorTest */ -final class CallableInMethodCallToVariableRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class CallableInMethodCallToVariableRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var CallableInMethodCallToVariable[] @@ -31,13 +31,13 @@ final class CallableInMethodCallToVariableRector extends \Rector\Core\Rector\Abs * @var \Rector\Transform\NodeFactory\UnwrapClosureFactory */ private $unwrapClosureFactory; - public function __construct(\Rector\Transform\NodeFactory\UnwrapClosureFactory $unwrapClosureFactory) + public function __construct(UnwrapClosureFactory $unwrapClosureFactory) { $this->unwrapClosureFactory = $unwrapClosureFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change a callable in method call to standalone variable assign', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change a callable in method call to standalone variable assign', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run() @@ -60,19 +60,19 @@ final class SomeClass } } CODE_SAMPLE -, [new \Rector\Transform\ValueObject\CallableInMethodCallToVariable('Nette\\Caching\\Cache', 'save', 1)])]); +, [new CallableInMethodCallToVariable('Nette\\Caching\\Cache', 'save', 1)])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Expr\MethodCall + public function refactor(Node $node) : ?MethodCall { foreach ($this->callableInMethodCallToVariable as $singleCallableInMethodCallToVariable) { if (!$this->isObjectType($node->var, $singleCallableInMethodCallToVariable->getObjectType())) { @@ -85,15 +85,15 @@ CODE_SAMPLE if (!isset($node->args[$position])) { continue; } - if (!$node->args[$position] instanceof \PhpParser\Node\Arg) { + if (!$node->args[$position] instanceof Arg) { continue; } $arg = $node->args[$position]; $argValueType = $this->getType($arg->value); - if (!$argValueType instanceof \PHPStan\Type\ClosureType) { + if (!$argValueType instanceof ClosureType) { continue; } - $resultVariable = new \PhpParser\Node\Expr\Variable('result'); + $resultVariable = new Variable('result'); $unwrappedNodes = $this->unwrapClosureFactory->createAssign($resultVariable, $arg); $arg->value = $resultVariable; $this->nodesToAddCollector->addNodesBeforeNode($unwrappedNodes, $node); @@ -106,7 +106,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\CallableInMethodCallToVariable::class); + Assert::allIsAOf($configuration, CallableInMethodCallToVariable::class); $this->callableInMethodCallToVariable = $configuration; } } diff --git a/rules/Transform/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector.php b/rules/Transform/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector.php index fcd52328e57..62bd61a5ad4 100644 --- a/rules/Transform/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector.php +++ b/rules/Transform/Rector/MethodCall/MethodCallToAnotherMethodCallWithArgumentsRector.php @@ -9,21 +9,21 @@ use PhpParser\Node\Identifier; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Transform\ValueObject\MethodCallToAnotherMethodCallWithArguments; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector\MethodCallToAnotherMethodCallWithArgumentsRectorTest */ -final class MethodCallToAnotherMethodCallWithArgumentsRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class MethodCallToAnotherMethodCallWithArgumentsRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var MethodCallToAnotherMethodCallWithArguments[] */ private $methodCallRenamesWithAddedArguments = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns old method call with specific types to new one with arguments', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns old method call with specific types to new one with arguments', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' $serviceDefinition = new Nette\DI\ServiceDefinition; $serviceDefinition->setInject(); CODE_SAMPLE @@ -31,19 +31,19 @@ CODE_SAMPLE $serviceDefinition = new Nette\DI\ServiceDefinition; $serviceDefinition->addTag('inject'); CODE_SAMPLE -, [new \Rector\Transform\ValueObject\MethodCallToAnotherMethodCallWithArguments('Nette\\DI\\ServiceDefinition', 'setInject', 'addTag', ['inject'])])]); +, [new MethodCallToAnotherMethodCallWithArguments('Nette\\DI\\ServiceDefinition', 'setInject', 'addTag', ['inject'])])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->methodCallRenamesWithAddedArguments as $methodCallRenameWithAddedArgument) { if (!$this->isObjectType($node->var, $methodCallRenameWithAddedArgument->getObjectType())) { @@ -52,7 +52,7 @@ CODE_SAMPLE if (!$this->isName($node->name, $methodCallRenameWithAddedArgument->getOldMethod())) { continue; } - $node->name = new \PhpParser\Node\Identifier($methodCallRenameWithAddedArgument->getNewMethod()); + $node->name = new Identifier($methodCallRenameWithAddedArgument->getNewMethod()); $node->args = $this->nodeFactory->createArgs($methodCallRenameWithAddedArgument->getNewArguments()); return $node; } @@ -63,7 +63,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\MethodCallToAnotherMethodCallWithArguments::class); + Assert::allIsAOf($configuration, MethodCallToAnotherMethodCallWithArguments::class); $this->methodCallRenamesWithAddedArguments = $configuration; } } diff --git a/rules/Transform/Rector/MethodCall/MethodCallToMethodCallRector.php b/rules/Transform/Rector/MethodCall/MethodCallToMethodCallRector.php index 71615a594e7..c164505b87d 100644 --- a/rules/Transform/Rector/MethodCall/MethodCallToMethodCallRector.php +++ b/rules/Transform/Rector/MethodCall/MethodCallToMethodCallRector.php @@ -16,13 +16,13 @@ use Rector\Naming\Naming\PropertyNaming; use Rector\PostRector\Collector\PropertyToAddCollector; use Rector\PostRector\ValueObject\PropertyMetadata; use Rector\Transform\ValueObject\MethodCallToMethodCall; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\MethodCall\MethodCallToMethodCallRector\MethodCallToMethodCallRectorTest */ -final class MethodCallToMethodCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class MethodCallToMethodCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var MethodCallToMethodCall[] @@ -43,15 +43,15 @@ final class MethodCallToMethodCallRector extends \Rector\Core\Rector\AbstractRec * @var \Rector\PostRector\Collector\PropertyToAddCollector */ private $propertyToAddCollector; - public function __construct(\Rector\Naming\Naming\PropertyNaming $propertyNaming, \Rector\Core\NodeAnalyzer\PropertyPresenceChecker $propertyPresenceChecker, \Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector) + public function __construct(PropertyNaming $propertyNaming, PropertyPresenceChecker $propertyPresenceChecker, PropertyToAddCollector $propertyToAddCollector) { $this->propertyNaming = $propertyNaming; $this->propertyPresenceChecker = $propertyPresenceChecker; $this->propertyToAddCollector = $propertyToAddCollector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change method one method from one service to a method call to in another service', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change method one method from one service to a method call to in another service', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function __construct( @@ -79,43 +79,43 @@ class SomeClass } } CODE_SAMPLE -, [new \Rector\Transform\ValueObject\MethodCallToMethodCall('FirstDependency', 'go', 'SecondDependency', 'away')])]); +, [new MethodCallToMethodCall('FirstDependency', 'go', 'SecondDependency', 'away')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->methodCallsToMethodsCalls as $methodCallToMethodCall) { - if (!$node->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$node->var instanceof PropertyFetch) { continue; } if (!$this->isMatch($node, $methodCallToMethodCall)) { continue; } $propertyFetch = $node->var; - $class = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$class instanceof Class_) { continue; } - $newObjectType = new \PHPStan\Type\ObjectType($methodCallToMethodCall->getNewType()); + $newObjectType = new ObjectType($methodCallToMethodCall->getNewType()); $newPropertyName = $this->matchNewPropertyName($methodCallToMethodCall, $class); if ($newPropertyName === null) { continue; } - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($newPropertyName, $newObjectType, \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $propertyMetadata = new PropertyMetadata($newPropertyName, $newObjectType, Class_::MODIFIER_PRIVATE); $this->propertyToAddCollector->addPropertyToClass($class, $propertyMetadata); // rename property - $node->var = new \PhpParser\Node\Expr\PropertyFetch($propertyFetch->var, $newPropertyName); + $node->var = new PropertyFetch($propertyFetch->var, $newPropertyName); // rename method - $node->name = new \PhpParser\Node\Identifier($methodCallToMethodCall->getNewMethod()); + $node->name = new Identifier($methodCallToMethodCall->getNewMethod()); return $node; } return null; @@ -125,20 +125,20 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\MethodCallToMethodCall::class); + Assert::allIsAOf($configuration, MethodCallToMethodCall::class); $this->methodCallsToMethodsCalls = $configuration; } - private function isMatch(\PhpParser\Node\Expr\MethodCall $methodCall, \Rector\Transform\ValueObject\MethodCallToMethodCall $methodCallToMethodCall) : bool + private function isMatch(MethodCall $methodCall, MethodCallToMethodCall $methodCallToMethodCall) : bool { - if (!$this->isObjectType($methodCall->var, new \PHPStan\Type\ObjectType($methodCallToMethodCall->getOldType()))) { + if (!$this->isObjectType($methodCall->var, new ObjectType($methodCallToMethodCall->getOldType()))) { return \false; } return $this->isName($methodCall->name, $methodCallToMethodCall->getOldMethod()); } - private function matchNewPropertyName(\Rector\Transform\ValueObject\MethodCallToMethodCall $methodCallToMethodCall, \PhpParser\Node\Stmt\Class_ $class) : ?string + private function matchNewPropertyName(MethodCallToMethodCall $methodCallToMethodCall, Class_ $class) : ?string { $newPropertyName = $this->propertyNaming->fqnToVariableName($methodCallToMethodCall->getNewType()); - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($newPropertyName, new \PHPStan\Type\ObjectType($methodCallToMethodCall->getNewType()), \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $propertyMetadata = new PropertyMetadata($newPropertyName, new ObjectType($methodCallToMethodCall->getNewType()), Class_::MODIFIER_PRIVATE); $classContextProperty = $this->propertyPresenceChecker->getClassContextProperty($class, $propertyMetadata); if ($classContextProperty === null) { return $newPropertyName; diff --git a/rules/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector.php b/rules/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector.php index fa7d4fe57e2..93f87bc7863 100644 --- a/rules/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector.php +++ b/rules/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector.php @@ -8,21 +8,21 @@ use PhpParser\Node\Expr\MethodCall; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Transform\ValueObject\MethodCallToPropertyFetch; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\MethodCall\MethodCallToPropertyFetchRector\MethodCallToPropertyFetchRectorTest */ -final class MethodCallToPropertyFetchRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class MethodCallToPropertyFetchRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var MethodCallToPropertyFetch[] */ private $methodCallsToPropertyFetches = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns method call "$this->something()" to property fetch "$this->something"', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns method call "$this->something()" to property fetch "$this->something"', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -47,12 +47,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->methodCallsToPropertyFetches as $methodCallToPropertyFetch) { if (!$this->isName($node->name, $methodCallToPropertyFetch->getOldMethod())) { @@ -70,7 +70,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\MethodCallToPropertyFetch::class); + Assert::allIsAOf($configuration, MethodCallToPropertyFetch::class); $this->methodCallsToPropertyFetches = $configuration; } } diff --git a/rules/Transform/Rector/MethodCall/MethodCallToStaticCallRector.php b/rules/Transform/Rector/MethodCall/MethodCallToStaticCallRector.php index 351d06e4eaf..4917398817d 100644 --- a/rules/Transform/Rector/MethodCall/MethodCallToStaticCallRector.php +++ b/rules/Transform/Rector/MethodCall/MethodCallToStaticCallRector.php @@ -8,21 +8,21 @@ use PhpParser\Node\Expr\MethodCall; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Transform\ValueObject\MethodCallToStaticCall; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\MethodCall\MethodCallToStaticCallRector\MethodCallToStaticCallRectorTest */ -final class MethodCallToStaticCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class MethodCallToStaticCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var MethodCallToStaticCall[] */ private $methodCallsToStaticCalls = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change method call to desired static call', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change method call to desired static call', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' final class SomeClass { private $anotherDependency; @@ -54,19 +54,19 @@ final class SomeClass } } CODE_SAMPLE -, [new \Rector\Transform\ValueObject\MethodCallToStaticCall('AnotherDependency', 'process', 'StaticCaller', 'anotherMethod')])]); +, [new MethodCallToStaticCall('AnotherDependency', 'process', 'StaticCaller', 'anotherMethod')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->methodCallsToStaticCalls as $methodCallToStaticCall) { if (!$this->isObjectType($node->var, $methodCallToStaticCall->getOldObjectType())) { @@ -84,7 +84,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\MethodCallToStaticCall::class); + Assert::allIsAOf($configuration, MethodCallToStaticCall::class); $this->methodCallsToStaticCalls = $configuration; } } diff --git a/rules/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector.php b/rules/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector.php index 1c3d17fd5f3..5cf1ffe0836 100644 --- a/rules/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector.php +++ b/rules/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector.php @@ -8,21 +8,21 @@ use PhpParser\Node\Expr\MethodCall; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\MethodCall\ReplaceParentCallByPropertyCallRector\ReplaceParentCallByPropertyCallRectorTest */ -final class ReplaceParentCallByPropertyCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class ReplaceParentCallByPropertyCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var ReplaceParentCallByPropertyCall[] */ private $parentCallToProperties = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes method calls in child of specific types to defined property method call', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes method calls in child of specific types to defined property method call', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run(SomeTypeToReplace $someTypeToReplace) @@ -40,19 +40,19 @@ final class SomeClass } } CODE_SAMPLE -, [new \Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall('SomeTypeToReplace', 'someMethodCall', 'someProperty')])]); +, [new ReplaceParentCallByPropertyCall('SomeTypeToReplace', 'someMethodCall', 'someProperty')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->parentCallToProperties as $parentCallToProperty) { if (!$this->isObjectType($node->var, $parentCallToProperty->getObjectType())) { @@ -71,7 +71,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall::class); + Assert::allIsAOf($configuration, ReplaceParentCallByPropertyCall::class); $this->parentCallToProperties = $configuration; } } diff --git a/rules/Transform/Rector/MethodCall/ServiceGetterToConstructorInjectionRector.php b/rules/Transform/Rector/MethodCall/ServiceGetterToConstructorInjectionRector.php index 964c4d38a04..adafd5986dd 100644 --- a/rules/Transform/Rector/MethodCall/ServiceGetterToConstructorInjectionRector.php +++ b/rules/Transform/Rector/MethodCall/ServiceGetterToConstructorInjectionRector.php @@ -17,13 +17,13 @@ use Rector\Naming\Naming\PropertyNaming; use Rector\PostRector\Collector\PropertyToAddCollector; use Rector\PostRector\ValueObject\PropertyMetadata; use Rector\Transform\ValueObject\ServiceGetterToConstructorInjection; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\MethodCall\ServiceGetterToConstructorInjectionRector\ServiceGetterToConstructorInjectionRectorTest */ -final class ServiceGetterToConstructorInjectionRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class ServiceGetterToConstructorInjectionRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var ServiceGetterToConstructorInjection[] @@ -44,15 +44,15 @@ final class ServiceGetterToConstructorInjectionRector extends \Rector\Core\Recto * @var \Rector\PostRector\Collector\PropertyToAddCollector */ private $propertyToAddCollector; - public function __construct(\Rector\Naming\Naming\PropertyNaming $propertyNaming, \Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer, \Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector) + public function __construct(PropertyNaming $propertyNaming, ClassAnalyzer $classAnalyzer, PropertyToAddCollector $propertyToAddCollector) { $this->propertyNaming = $propertyNaming; $this->classAnalyzer = $classAnalyzer; $this->propertyToAddCollector = $propertyToAddCollector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Get service call to constructor injection', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Get service call to constructor injection', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' final class SomeClass { /** @@ -116,22 +116,22 @@ final class SomeClass } } CODE_SAMPLE -, [new \Rector\Transform\ValueObject\ServiceGetterToConstructorInjection('FirstService', 'getAnotherService', 'AnotherService')])]); +, [new ServiceGetterToConstructorInjection('FirstService', 'getAnotherService', 'AnotherService')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLike = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$classLike instanceof Class_) { return null; } if ($this->classAnalyzer->isAnonymousClass($classLike)) { @@ -144,11 +144,11 @@ CODE_SAMPLE if (!$this->isName($node->name, $methodCallToService->getOldMethod())) { continue; } - $serviceObjectType = new \PHPStan\Type\ObjectType($methodCallToService->getServiceType()); + $serviceObjectType = new ObjectType($methodCallToService->getServiceType()); $propertyName = $this->propertyNaming->fqnToVariableName($serviceObjectType); - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($propertyName, $serviceObjectType, \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $propertyMetadata = new PropertyMetadata($propertyName, $serviceObjectType, Class_::MODIFIER_PRIVATE); $this->propertyToAddCollector->addPropertyToClass($classLike, $propertyMetadata); - return new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable('this'), new \PhpParser\Node\Identifier($propertyName)); + return new PropertyFetch(new Variable('this'), new Identifier($propertyName)); } return $node; } @@ -157,7 +157,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\ServiceGetterToConstructorInjection::class); + Assert::allIsAOf($configuration, ServiceGetterToConstructorInjection::class); $this->methodCallToServices = $configuration; } } diff --git a/rules/Transform/Rector/New_/NewArgToMethodCallRector.php b/rules/Transform/Rector/New_/NewArgToMethodCallRector.php index 0886c0a030d..e36393100bb 100644 --- a/rules/Transform/Rector/New_/NewArgToMethodCallRector.php +++ b/rules/Transform/Rector/New_/NewArgToMethodCallRector.php @@ -10,23 +10,23 @@ use PhpParser\Node\Expr\New_; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Transform\ValueObject\NewArgToMethodCall; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @changelog https://github.com/symfony/symfony/pull/35308 * * @see \Rector\Tests\Transform\Rector\New_\NewArgToMethodCallRector\NewArgToMethodCallRectorTest */ -final class NewArgToMethodCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class NewArgToMethodCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var NewArgToMethodCall[] */ private $newArgsToMethodCalls = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change new with specific argument to method call', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change new with specific argument to method call', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -45,19 +45,19 @@ class SomeClass } } CODE_SAMPLE -, [new \Rector\Transform\ValueObject\NewArgToMethodCall('Dotenv', \true, 'usePutenv')])]); +, [new NewArgToMethodCall('Dotenv', \true, 'usePutenv')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\New_::class]; + return [New_::class]; } /** * @param New_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->newArgsToMethodCalls as $newArgToMethodCall) { if (!$this->isObjectType($node->class, $newArgToMethodCall->getObjectType())) { @@ -66,7 +66,7 @@ CODE_SAMPLE if (!isset($node->args[0])) { return null; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } $firstArgValue = $node->args[0]->value; @@ -74,7 +74,7 @@ CODE_SAMPLE continue; } unset($node->args[0]); - return new \PhpParser\Node\Expr\MethodCall($node, 'usePutenv'); + return new MethodCall($node, 'usePutenv'); } return null; } @@ -83,7 +83,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\NewArgToMethodCall::class); + Assert::allIsAOf($configuration, NewArgToMethodCall::class); $this->newArgsToMethodCalls = $configuration; } } diff --git a/rules/Transform/Rector/New_/NewToConstructorInjectionRector.php b/rules/Transform/Rector/New_/NewToConstructorInjectionRector.php index 8d80a739846..2a03380fbc6 100644 --- a/rules/Transform/Rector/New_/NewToConstructorInjectionRector.php +++ b/rules/Transform/Rector/New_/NewToConstructorInjectionRector.php @@ -18,13 +18,13 @@ use Rector\Naming\ValueObject\ExpectedName; use Rector\PostRector\Collector\PropertyToAddCollector; use Rector\PostRector\ValueObject\PropertyMetadata; use Rector\Transform\NodeFactory\PropertyFetchFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\New_\NewToConstructorInjectionRector\NewToConstructorInjectionRectorTest */ -final class NewToConstructorInjectionRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class NewToConstructorInjectionRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var ObjectType[] @@ -45,15 +45,15 @@ final class NewToConstructorInjectionRector extends \Rector\Core\Rector\Abstract * @var \Rector\PostRector\Collector\PropertyToAddCollector */ private $propertyToAddCollector; - public function __construct(\Rector\Transform\NodeFactory\PropertyFetchFactory $propertyFetchFactory, \Rector\Naming\Naming\PropertyNaming $propertyNaming, \Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector) + public function __construct(PropertyFetchFactory $propertyFetchFactory, PropertyNaming $propertyNaming, PropertyToAddCollector $propertyToAddCollector) { $this->propertyFetchFactory = $propertyFetchFactory; $this->propertyNaming = $propertyNaming; $this->propertyToAddCollector = $propertyToAddCollector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change defined new type to constructor injection', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change defined new type to constructor injection', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -89,23 +89,23 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\New_::class, \PhpParser\Node\Expr\Assign::class, \PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Stmt\Expression::class]; + return [New_::class, Assign::class, MethodCall::class, Expression::class]; } /** * @param New_|Assign|MethodCall|Expression $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node instanceof MethodCall) { return $this->refactorMethodCall($node); } - if ($node instanceof \PhpParser\Node\Stmt\Expression) { + if ($node instanceof Expression) { $nodeExpr = $node->expr; - if ($nodeExpr instanceof \PhpParser\Node\Expr\Assign) { + if ($nodeExpr instanceof Assign) { $this->refactorAssignExpression($node, $nodeExpr); } } - if ($node instanceof \PhpParser\Node\Expr\New_) { + if ($node instanceof New_) { $this->refactorNew($node); } return null; @@ -116,15 +116,15 @@ CODE_SAMPLE public function configure(array $configuration) : void { $typesToConstructorInjections = $configuration; - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($typesToConstructorInjections); + Assert::allString($typesToConstructorInjections); foreach ($typesToConstructorInjections as $typeToConstructorInjection) { - $this->constructorInjectionObjectTypes[] = new \PHPStan\Type\ObjectType($typeToConstructorInjection); + $this->constructorInjectionObjectTypes[] = new ObjectType($typeToConstructorInjection); } } - private function refactorMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node\Expr\MethodCall + private function refactorMethodCall(MethodCall $methodCall) : ?MethodCall { foreach ($this->constructorInjectionObjectTypes as $constructorInjectionObjectType) { - if (!$methodCall->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$methodCall->var instanceof Variable) { continue; } if (!$this->isObjectType($methodCall->var, $constructorInjectionObjectType)) { @@ -138,10 +138,10 @@ CODE_SAMPLE } return null; } - private function refactorAssignExpression(\PhpParser\Node\Stmt\Expression $expression, \PhpParser\Node\Expr\Assign $assign) : void + private function refactorAssignExpression(Expression $expression, Assign $assign) : void { - $currentAssign = $assign->expr instanceof \PhpParser\Node\Expr\Assign ? $assign->expr : $assign; - if (!$currentAssign->expr instanceof \PhpParser\Node\Expr\New_) { + $currentAssign = $assign->expr instanceof Assign ? $assign->expr : $assign; + if (!$currentAssign->expr instanceof New_) { return; } foreach ($this->constructorInjectionObjectTypes as $constructorInjectionObjectType) { @@ -151,21 +151,21 @@ CODE_SAMPLE $this->removeNode($expression); } } - private function refactorNew(\PhpParser\Node\Expr\New_ $new) : void + private function refactorNew(New_ $new) : void { foreach ($this->constructorInjectionObjectTypes as $constructorInjectionObjectType) { if (!$this->isObjectType($new->class, $constructorInjectionObjectType)) { continue; } - $classLike = $this->betterNodeFinder->findParentType($new, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLike = $this->betterNodeFinder->findParentType($new, Class_::class); + if (!$classLike instanceof Class_) { continue; } $expectedPropertyName = $this->propertyNaming->getExpectedNameFromType($constructorInjectionObjectType); - if (!$expectedPropertyName instanceof \Rector\Naming\ValueObject\ExpectedName) { + if (!$expectedPropertyName instanceof ExpectedName) { continue; } - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($expectedPropertyName->getName(), $constructorInjectionObjectType, \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $propertyMetadata = new PropertyMetadata($expectedPropertyName->getName(), $constructorInjectionObjectType, Class_::MODIFIER_PRIVATE); $this->propertyToAddCollector->addPropertyToClass($classLike, $propertyMetadata); } } diff --git a/rules/Transform/Rector/New_/NewToMethodCallRector.php b/rules/Transform/Rector/New_/NewToMethodCallRector.php index 1091c4c899f..3fa7a4a056a 100644 --- a/rules/Transform/Rector/New_/NewToMethodCallRector.php +++ b/rules/Transform/Rector/New_/NewToMethodCallRector.php @@ -16,13 +16,13 @@ use Rector\Core\Rector\AbstractRector; use Rector\PostRector\Collector\PropertyToAddCollector; use Rector\PostRector\ValueObject\PropertyMetadata; use Rector\Transform\ValueObject\NewToMethodCall; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\New_\NewToMethodCallRector\NewToMethodCallRectorTest */ -final class NewToMethodCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class NewToMethodCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var NewToMethodCall[] @@ -43,15 +43,15 @@ final class NewToMethodCallRector extends \Rector\Core\Rector\AbstractRector imp * @var \Rector\PostRector\Collector\PropertyToAddCollector */ private $propertyToAddCollector; - public function __construct(\Rector\CodingStyle\Naming\ClassNaming $classNaming, \Rector\Core\NodeManipulator\PropertyManipulator $propertyManipulator, \Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector) + public function __construct(ClassNaming $classNaming, PropertyManipulator $propertyManipulator, PropertyToAddCollector $propertyToAddCollector) { $this->classNaming = $classNaming; $this->propertyManipulator = $propertyManipulator; $this->propertyToAddCollector = $propertyToAddCollector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replaces creating object instances with "new" keyword with factory method.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replaces creating object instances with "new" keyword with factory method.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function example() { @@ -72,22 +72,22 @@ class SomeClass } } CODE_SAMPLE -, [new \Rector\Transform\ValueObject\NewToMethodCall('MyClass', 'MyClassFactory', 'create')])]); +, [new NewToMethodCall('MyClass', 'MyClassFactory', 'create')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\New_::class]; + return [New_::class]; } /** * @param New_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $class = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$class instanceof Class_) { return null; } $className = $this->getName($class); @@ -107,11 +107,11 @@ CODE_SAMPLE $serviceObjectType = $newToMethodCall->getServiceObjectType(); $propertyName = $this->classNaming->getShortName($serviceObjectType->getClassName()); $propertyName = \lcfirst($propertyName); - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($propertyName, $newToMethodCall->getServiceObjectType(), \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $propertyMetadata = new PropertyMetadata($propertyName, $newToMethodCall->getServiceObjectType(), Class_::MODIFIER_PRIVATE); $this->propertyToAddCollector->addPropertyToClass($class, $propertyMetadata); } - $propertyFetch = new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable('this'), $propertyName); - return new \PhpParser\Node\Expr\MethodCall($propertyFetch, $newToMethodCall->getServiceMethod(), $node->args); + $propertyFetch = new PropertyFetch(new Variable('this'), $propertyName); + return new MethodCall($propertyFetch, $newToMethodCall->getServiceMethod(), $node->args); } return $node; } @@ -120,7 +120,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\NewToMethodCall::class); + Assert::allIsAOf($configuration, NewToMethodCall::class); $this->newsToMethodCalls = $configuration; } } diff --git a/rules/Transform/Rector/New_/NewToStaticCallRector.php b/rules/Transform/Rector/New_/NewToStaticCallRector.php index a9b25b8f276..49ff8aacc76 100644 --- a/rules/Transform/Rector/New_/NewToStaticCallRector.php +++ b/rules/Transform/Rector/New_/NewToStaticCallRector.php @@ -8,21 +8,21 @@ use PhpParser\Node\Expr\New_; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Transform\ValueObject\NewToStaticCall; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\New_\NewToStaticCallRector\NewToStaticCallRectorTest */ -final class NewToStaticCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class NewToStaticCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var NewToStaticCall[] */ private $typeToStaticCalls = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change new Object to static call', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change new Object to static call', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -40,19 +40,19 @@ class SomeClass } } CODE_SAMPLE -, [new \Rector\Transform\ValueObject\NewToStaticCall('Cookie', 'Cookie', 'create')])]); +, [new NewToStaticCall('Cookie', 'Cookie', 'create')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\New_::class]; + return [New_::class]; } /** * @param New_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->typeToStaticCalls as $typeToStaticCall) { if (!$this->isObjectType($node->class, $typeToStaticCall->getObjectType())) { @@ -67,7 +67,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\NewToStaticCall::class); + Assert::allIsAOf($configuration, NewToStaticCall::class); $this->typeToStaticCalls = $configuration; } } diff --git a/rules/Transform/Rector/StaticCall/StaticCallToFuncCallRector.php b/rules/Transform/Rector/StaticCall/StaticCallToFuncCallRector.php index c2c601e7552..38aca85e877 100644 --- a/rules/Transform/Rector/StaticCall/StaticCallToFuncCallRector.php +++ b/rules/Transform/Rector/StaticCall/StaticCallToFuncCallRector.php @@ -10,13 +10,13 @@ use PhpParser\Node\Name\FullyQualified; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Transform\ValueObject\StaticCallToFuncCall; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\StaticCall\StaticCallToFuncCallRector\StaticCallToFuncCallRectorTest */ -final class StaticCallToFuncCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class StaticCallToFuncCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var StaticCallToFuncCall[] @@ -29,21 +29,21 @@ final class StaticCallToFuncCallRector extends \Rector\Core\Rector\AbstractRecto { $this->staticCallsToFunctions = $staticCallsToFunctions; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns static call to function call.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample('OldClass::oldMethod("args");', 'new_function("args");', [new \Rector\Transform\ValueObject\StaticCallToFuncCall('OldClass', 'oldMethod', 'new_function')])]); + return new RuleDefinition('Turns static call to function call.', [new ConfiguredCodeSample('OldClass::oldMethod("args");', 'new_function("args");', [new StaticCallToFuncCall('OldClass', 'oldMethod', 'new_function')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class]; + return [StaticCall::class]; } /** * @param StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->staticCallsToFunctions as $staticCallToFunction) { if (!$this->isObjectType($node->class, $staticCallToFunction->getObjectType())) { @@ -52,7 +52,7 @@ final class StaticCallToFuncCallRector extends \Rector\Core\Rector\AbstractRecto if (!$this->isName($node->name, $staticCallToFunction->getMethod())) { continue; } - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name\FullyQualified($staticCallToFunction->getFunction()), $node->args); + return new FuncCall(new FullyQualified($staticCallToFunction->getFunction()), $node->args); } return null; } @@ -61,7 +61,7 @@ final class StaticCallToFuncCallRector extends \Rector\Core\Rector\AbstractRecto */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\StaticCallToFuncCall::class); + Assert::allIsAOf($configuration, StaticCallToFuncCall::class); $this->staticCallsToFunctions = $configuration; } } diff --git a/rules/Transform/Rector/StaticCall/StaticCallToMethodCallRector.php b/rules/Transform/Rector/StaticCall/StaticCallToMethodCallRector.php index 0b264bc979f..e9fc5e3c962 100644 --- a/rules/Transform/Rector/StaticCall/StaticCallToMethodCallRector.php +++ b/rules/Transform/Rector/StaticCall/StaticCallToMethodCallRector.php @@ -15,13 +15,13 @@ use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Rector\AbstractRector; use Rector\Transform\NodeAnalyzer\FuncCallStaticCallToMethodCallAnalyzer; use Rector\Transform\ValueObject\StaticCallToMethodCall; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\StaticCall\StaticCallToMethodCallRector\StaticCallToMethodCallRectorTest */ -final class StaticCallToMethodCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class StaticCallToMethodCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var StaticCallToMethodCall[] @@ -32,13 +32,13 @@ final class StaticCallToMethodCallRector extends \Rector\Core\Rector\AbstractRec * @var \Rector\Transform\NodeAnalyzer\FuncCallStaticCallToMethodCallAnalyzer */ private $funcCallStaticCallToMethodCallAnalyzer; - public function __construct(\Rector\Transform\NodeAnalyzer\FuncCallStaticCallToMethodCallAnalyzer $funcCallStaticCallToMethodCallAnalyzer) + public function __construct(FuncCallStaticCallToMethodCallAnalyzer $funcCallStaticCallToMethodCallAnalyzer) { $this->funcCallStaticCallToMethodCallAnalyzer = $funcCallStaticCallToMethodCallAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change static call to service method via constructor injection', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change static call to service method via constructor injection', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' use Nette\Utils\FileSystem; class SomeClass @@ -70,26 +70,26 @@ class SomeClass } } CODE_SAMPLE -, [new \Rector\Transform\ValueObject\StaticCallToMethodCall('Nette\\Utils\\FileSystem', 'write', 'Symplify\\SmartFileSystem\\SmartFileSystem', 'dumpFile')])]); +, [new StaticCallToMethodCall('Nette\\Utils\\FileSystem', 'write', 'Symplify\\SmartFileSystem\\SmartFileSystem', 'dumpFile')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class]; + return [StaticCall::class]; } /** * @param StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLike = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$classLike instanceof Class_) { return null; } - $classMethod = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassMethod::class); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $this->betterNodeFinder->findParentType($node, ClassMethod::class); + if (!$classMethod instanceof ClassMethod) { return null; } foreach ($this->staticCallsToMethodCalls as $staticCallToMethodCall) { @@ -106,9 +106,9 @@ CODE_SAMPLE $methodName = $staticCallToMethodCall->getMethodName(); } if (!\is_string($methodName)) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } - return new \PhpParser\Node\Expr\MethodCall($expr, $methodName, $node->args); + return new MethodCall($expr, $methodName, $node->args); } return $node; } @@ -117,12 +117,12 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\StaticCallToMethodCall::class); + Assert::allIsAOf($configuration, StaticCallToMethodCall::class); $this->staticCallsToMethodCalls = $configuration; } - private function refactorToInstanceCall(\PhpParser\Node\Expr\StaticCall $staticCall, \Rector\Transform\ValueObject\StaticCallToMethodCall $staticCallToMethodCall) : \PhpParser\Node\Expr\MethodCall + private function refactorToInstanceCall(StaticCall $staticCall, StaticCallToMethodCall $staticCallToMethodCall) : MethodCall { - $new = new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name\FullyQualified($staticCallToMethodCall->getClassType())); - return new \PhpParser\Node\Expr\MethodCall($new, $staticCallToMethodCall->getMethodName(), $staticCall->args); + $new = new New_(new FullyQualified($staticCallToMethodCall->getClassType())); + return new MethodCall($new, $staticCallToMethodCall->getMethodName(), $staticCall->args); } } diff --git a/rules/Transform/Rector/StaticCall/StaticCallToNewRector.php b/rules/Transform/Rector/StaticCall/StaticCallToNewRector.php index d09c44f8648..3a3ad884caa 100644 --- a/rules/Transform/Rector/StaticCall/StaticCallToNewRector.php +++ b/rules/Transform/Rector/StaticCall/StaticCallToNewRector.php @@ -10,23 +10,23 @@ use PhpParser\Node\Name\FullyQualified; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Transform\ValueObject\StaticCallToNew; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @changelog https://github.com/symfony/symfony/pull/35308 * * @see \Rector\Tests\Transform\Rector\StaticCall\StaticCallToNewRector\StaticCallToNewRectorTest */ -final class StaticCallToNewRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class StaticCallToNewRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var StaticCallToNew[] */ private $staticCallsToNews = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change static call to new instance', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change static call to new instance', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -44,19 +44,19 @@ class SomeClass } } CODE_SAMPLE -, [new \Rector\Transform\ValueObject\StaticCallToNew('JsonResponse', 'create')])]); +, [new StaticCallToNew('JsonResponse', 'create')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class]; + return [StaticCall::class]; } /** * @param Node\Expr\StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->staticCallsToNews as $staticCallToNew) { if (!$this->isName($node->class, $staticCallToNew->getClass())) { @@ -69,7 +69,7 @@ CODE_SAMPLE if ($class === null) { continue; } - return new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name\FullyQualified($class), $node->args); + return new New_(new FullyQualified($class), $node->args); } return $node; } @@ -78,7 +78,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\StaticCallToNew::class); + Assert::allIsAOf($configuration, StaticCallToNew::class); $this->staticCallsToNews = $configuration; } } diff --git a/rules/Transform/Rector/String_/StringToClassConstantRector.php b/rules/Transform/Rector/String_/StringToClassConstantRector.php index 201b4827183..add2aeafe6d 100644 --- a/rules/Transform/Rector/String_/StringToClassConstantRector.php +++ b/rules/Transform/Rector/String_/StringToClassConstantRector.php @@ -8,21 +8,21 @@ use PhpParser\Node\Scalar\String_; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Transform\ValueObject\StringToClassConstant; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\String_\StringToClassConstantRector\StringToClassConstantRectorTest */ -final class StringToClassConstantRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class StringToClassConstantRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var StringToClassConstant[] */ private $stringsToClassConstants = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes strings to specific constants', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes strings to specific constants', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' final class SomeSubscriber { public static function getSubscribedEvents() @@ -40,19 +40,19 @@ final class SomeSubscriber } } CODE_SAMPLE -, [new \Rector\Transform\ValueObject\StringToClassConstant('compiler.post_dump', 'Yet\\AnotherClass', 'CONSTANT')])]); +, [new StringToClassConstant('compiler.post_dump', 'Yet\\AnotherClass', 'CONSTANT')])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Scalar\String_::class]; + return [String_::class]; } /** * @param String_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->stringsToClassConstants as $stringToClassConstant) { if (!$this->valueResolver->isValue($node, $stringToClassConstant->getString())) { @@ -67,7 +67,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Transform\ValueObject\StringToClassConstant::class); + Assert::allIsAOf($configuration, StringToClassConstant::class); $this->stringsToClassConstants = $configuration; } } diff --git a/rules/Transform/Rector/String_/ToStringToMethodCallRector.php b/rules/Transform/Rector/String_/ToStringToMethodCallRector.php index 04a596ccd47..75e850e3019 100644 --- a/rules/Transform/Rector/String_/ToStringToMethodCallRector.php +++ b/rules/Transform/Rector/String_/ToStringToMethodCallRector.php @@ -10,21 +10,21 @@ use PhpParser\Node\Identifier; use PHPStan\Type\ObjectType; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Transform\Rector\String_\ToStringToMethodCallRector\ToStringToMethodCallRectorTest */ -final class ToStringToMethodCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class ToStringToMethodCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var array */ private $methodNamesByType = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns defined code uses of "__toString()" method to specific method calls.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns defined code uses of "__toString()" method to specific method calls.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' $someValue = new SomeObject; $result = (string) $someValue; $result = $someValue->__toString(); @@ -41,14 +41,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Cast\String_::class, \PhpParser\Node\Expr\MethodCall::class]; + return [String_::class, MethodCall::class]; } /** * @param String_|MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\Cast\String_) { + if ($node instanceof String_) { return $this->processStringNode($node); } return $this->processMethodCall($node); @@ -58,31 +58,31 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allString(\array_keys($configuration)); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configuration); + Assert::allString(\array_keys($configuration)); + Assert::allString($configuration); /** @var array $configuration */ $this->methodNamesByType = $configuration; } - private function processStringNode(\PhpParser\Node\Expr\Cast\String_ $string) : ?\PhpParser\Node + private function processStringNode(String_ $string) : ?Node { foreach ($this->methodNamesByType as $type => $methodName) { - if (!$this->isObjectType($string->expr, new \PHPStan\Type\ObjectType($type))) { + if (!$this->isObjectType($string->expr, new ObjectType($type))) { continue; } return $this->nodeFactory->createMethodCall($string->expr, $methodName); } return null; } - private function processMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node + private function processMethodCall(MethodCall $methodCall) : ?Node { foreach ($this->methodNamesByType as $type => $methodName) { - if (!$this->isObjectType($methodCall->var, new \PHPStan\Type\ObjectType($type))) { + if (!$this->isObjectType($methodCall->var, new ObjectType($type))) { continue; } if (!$this->isName($methodCall->name, '__toString')) { continue; } - $methodCall->name = new \PhpParser\Node\Identifier($methodName); + $methodCall->name = new Identifier($methodName); return $methodCall; } return null; diff --git a/rules/Transform/ValueObject/ArgumentFuncCallToMethodCall.php b/rules/Transform/ValueObject/ArgumentFuncCallToMethodCall.php index a0b061213a3..3c436801eb7 100644 --- a/rules/Transform/ValueObject/ArgumentFuncCallToMethodCall.php +++ b/rules/Transform/ValueObject/ArgumentFuncCallToMethodCall.php @@ -5,7 +5,7 @@ namespace Rector\Transform\ValueObject; use Rector\Core\Validation\RectorAssert; use Rector\Transform\Contract\ValueObject\ArgumentFuncCallToMethodCallInterface; -final class ArgumentFuncCallToMethodCall implements \Rector\Transform\Contract\ValueObject\ArgumentFuncCallToMethodCallInterface +final class ArgumentFuncCallToMethodCall implements ArgumentFuncCallToMethodCallInterface { /** * @readonly @@ -33,7 +33,7 @@ final class ArgumentFuncCallToMethodCall implements \Rector\Transform\Contract\V $this->class = $class; $this->methodIfArgs = $methodIfArgs; $this->methodIfNoArgs = $methodIfNoArgs; - \Rector\Core\Validation\RectorAssert::className($class); + RectorAssert::className($class); } public function getFunction() : string { diff --git a/rules/Transform/ValueObject/ArrayFuncCallToMethodCall.php b/rules/Transform/ValueObject/ArrayFuncCallToMethodCall.php index ad54981cfd1..af1836efe8d 100644 --- a/rules/Transform/ValueObject/ArrayFuncCallToMethodCall.php +++ b/rules/Transform/ValueObject/ArrayFuncCallToMethodCall.php @@ -5,7 +5,7 @@ namespace Rector\Transform\ValueObject; use Rector\Core\Validation\RectorAssert; use Rector\Transform\Contract\ValueObject\ArgumentFuncCallToMethodCallInterface; -final class ArrayFuncCallToMethodCall implements \Rector\Transform\Contract\ValueObject\ArgumentFuncCallToMethodCallInterface +final class ArrayFuncCallToMethodCall implements ArgumentFuncCallToMethodCallInterface { /** * @var non-empty-string @@ -39,7 +39,7 @@ final class ArrayFuncCallToMethodCall implements \Rector\Transform\Contract\Valu $this->class = $class; $this->arrayMethod = $arrayMethod; $this->nonArrayMethod = $nonArrayMethod; - \Rector\Core\Validation\RectorAssert::className($class); + RectorAssert::className($class); } public function getFunction() : string { diff --git a/rules/Transform/ValueObject/CallableInMethodCallToVariable.php b/rules/Transform/ValueObject/CallableInMethodCallToVariable.php index 03dc0a06214..6995833be19 100644 --- a/rules/Transform/ValueObject/CallableInMethodCallToVariable.php +++ b/rules/Transform/ValueObject/CallableInMethodCallToVariable.php @@ -27,9 +27,9 @@ final class CallableInMethodCallToVariable $this->methodName = $methodName; $this->argumentPosition = $argumentPosition; } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->classType); + return new ObjectType($this->classType); } public function getMethodName() : string { diff --git a/rules/Transform/ValueObject/DimFetchAssignToMethodCall.php b/rules/Transform/ValueObject/DimFetchAssignToMethodCall.php index 2ea7c8e2c52..5cb6401b2ca 100644 --- a/rules/Transform/ValueObject/DimFetchAssignToMethodCall.php +++ b/rules/Transform/ValueObject/DimFetchAssignToMethodCall.php @@ -27,13 +27,13 @@ final class DimFetchAssignToMethodCall $this->itemClass = $itemClass; $this->addMethod = $addMethod; } - public function getListObjectType() : \PHPStan\Type\ObjectType + public function getListObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->listClass); + return new ObjectType($this->listClass); } - public function getItemObjectType() : \PHPStan\Type\ObjectType + public function getItemObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->itemClass); + return new ObjectType($this->itemClass); } public function getAddMethod() : string { diff --git a/rules/Transform/ValueObject/FuncCallToMethodCall.php b/rules/Transform/ValueObject/FuncCallToMethodCall.php index 921d736d045..ddbc534a741 100644 --- a/rules/Transform/ValueObject/FuncCallToMethodCall.php +++ b/rules/Transform/ValueObject/FuncCallToMethodCall.php @@ -31,9 +31,9 @@ final class FuncCallToMethodCall { return $this->oldFuncName; } - public function getNewObjectType() : \PHPStan\Type\ObjectType + public function getNewObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->newClassName); + return new ObjectType($this->newClassName); } public function getNewMethodName() : string { diff --git a/rules/Transform/ValueObject/GetAndSetToMethodCall.php b/rules/Transform/ValueObject/GetAndSetToMethodCall.php index ab8db8ccfef..102b0f069ea 100644 --- a/rules/Transform/ValueObject/GetAndSetToMethodCall.php +++ b/rules/Transform/ValueObject/GetAndSetToMethodCall.php @@ -38,8 +38,8 @@ final class GetAndSetToMethodCall { return $this->setMethod; } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->classType); + return new ObjectType($this->classType); } } diff --git a/rules/Transform/ValueObject/MethodCallToAnotherMethodCallWithArguments.php b/rules/Transform/ValueObject/MethodCallToAnotherMethodCallWithArguments.php index 792674b2fc8..7e935f987e8 100644 --- a/rules/Transform/ValueObject/MethodCallToAnotherMethodCallWithArguments.php +++ b/rules/Transform/ValueObject/MethodCallToAnotherMethodCallWithArguments.php @@ -36,11 +36,11 @@ final class MethodCallToAnotherMethodCallWithArguments $this->oldMethod = $oldMethod; $this->newMethod = $newMethod; $this->newArguments = $newArguments; - \Rector\Core\Validation\RectorAssert::className($type); + RectorAssert::className($type); } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->type); + return new ObjectType($this->type); } public function getOldMethod() : string { diff --git a/rules/Transform/ValueObject/MethodCallToMethodCall.php b/rules/Transform/ValueObject/MethodCallToMethodCall.php index 8e069287e43..dda5bf9ef5d 100644 --- a/rules/Transform/ValueObject/MethodCallToMethodCall.php +++ b/rules/Transform/ValueObject/MethodCallToMethodCall.php @@ -36,8 +36,8 @@ final class MethodCallToMethodCall $this->oldMethod = $oldMethod; $this->newType = $newType; $this->newMethod = $newMethod; - \Rector\Core\Validation\RectorAssert::className($oldType); - \Rector\Core\Validation\RectorAssert::className($newType); + RectorAssert::className($oldType); + RectorAssert::className($newType); } public function getOldType() : string { diff --git a/rules/Transform/ValueObject/MethodCallToPropertyFetch.php b/rules/Transform/ValueObject/MethodCallToPropertyFetch.php index 5352b101dc4..05f71614cac 100644 --- a/rules/Transform/ValueObject/MethodCallToPropertyFetch.php +++ b/rules/Transform/ValueObject/MethodCallToPropertyFetch.php @@ -27,11 +27,11 @@ final class MethodCallToPropertyFetch $this->oldType = $oldType; $this->oldMethod = $oldMethod; $this->newProperty = $newProperty; - \Rector\Core\Validation\RectorAssert::className($oldType); + RectorAssert::className($oldType); } - public function getOldObjectType() : \PHPStan\Type\ObjectType + public function getOldObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->oldType); + return new ObjectType($this->oldType); } public function getNewProperty() : string { diff --git a/rules/Transform/ValueObject/MethodCallToStaticCall.php b/rules/Transform/ValueObject/MethodCallToStaticCall.php index 59b7ca5fa0f..acd1d0edf26 100644 --- a/rules/Transform/ValueObject/MethodCallToStaticCall.php +++ b/rules/Transform/ValueObject/MethodCallToStaticCall.php @@ -33,9 +33,9 @@ final class MethodCallToStaticCall $this->newClass = $newClass; $this->newMethod = $newMethod; } - public function getOldObjectType() : \PHPStan\Type\ObjectType + public function getOldObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->oldClass); + return new ObjectType($this->oldClass); } public function getOldMethod() : string { diff --git a/rules/Transform/ValueObject/NewArgToMethodCall.php b/rules/Transform/ValueObject/NewArgToMethodCall.php index 83a4aa41879..1d909465677 100644 --- a/rules/Transform/ValueObject/NewArgToMethodCall.php +++ b/rules/Transform/ValueObject/NewArgToMethodCall.php @@ -29,11 +29,11 @@ final class NewArgToMethodCall $this->type = $type; $this->value = $value; $this->methodCall = $methodCall; - \Rector\Core\Validation\RectorAssert::className($type); + RectorAssert::className($type); } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->type); + return new ObjectType($this->type); } /** * @return mixed diff --git a/rules/Transform/ValueObject/NewToMethodCall.php b/rules/Transform/ValueObject/NewToMethodCall.php index 376dd4892e9..63c8cdd2bd4 100644 --- a/rules/Transform/ValueObject/NewToMethodCall.php +++ b/rules/Transform/ValueObject/NewToMethodCall.php @@ -27,13 +27,13 @@ final class NewToMethodCall $this->serviceType = $serviceType; $this->serviceMethod = $serviceMethod; } - public function getNewObjectType() : \PHPStan\Type\ObjectType + public function getNewObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->newType); + return new ObjectType($this->newType); } - public function getServiceObjectType() : \PHPStan\Type\ObjectType + public function getServiceObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->serviceType); + return new ObjectType($this->serviceType); } public function getServiceMethod() : string { diff --git a/rules/Transform/ValueObject/NewToStaticCall.php b/rules/Transform/ValueObject/NewToStaticCall.php index 50d55d348af..789a6f2f607 100644 --- a/rules/Transform/ValueObject/NewToStaticCall.php +++ b/rules/Transform/ValueObject/NewToStaticCall.php @@ -27,12 +27,12 @@ final class NewToStaticCall $this->type = $type; $this->staticCallClass = $staticCallClass; $this->staticCallMethod = $staticCallMethod; - \Rector\Core\Validation\RectorAssert::className($type); - \Rector\Core\Validation\RectorAssert::className($staticCallClass); + RectorAssert::className($type); + RectorAssert::className($staticCallClass); } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->type); + return new ObjectType($this->type); } public function getStaticCallClass() : string { diff --git a/rules/Transform/ValueObject/PropertyAssignToMethodCall.php b/rules/Transform/ValueObject/PropertyAssignToMethodCall.php index 13661be8385..84360109109 100644 --- a/rules/Transform/ValueObject/PropertyAssignToMethodCall.php +++ b/rules/Transform/ValueObject/PropertyAssignToMethodCall.php @@ -27,11 +27,11 @@ final class PropertyAssignToMethodCall $this->class = $class; $this->oldPropertyName = $oldPropertyName; $this->newMethodName = $newMethodName; - \Rector\Core\Validation\RectorAssert::className($class); + RectorAssert::className($class); } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->class); + return new ObjectType($this->class); } public function getOldPropertyName() : string { diff --git a/rules/Transform/ValueObject/PropertyFetchToMethodCall.php b/rules/Transform/ValueObject/PropertyFetchToMethodCall.php index e968542df7f..d6040984593 100644 --- a/rules/Transform/ValueObject/PropertyFetchToMethodCall.php +++ b/rules/Transform/ValueObject/PropertyFetchToMethodCall.php @@ -42,11 +42,11 @@ final class PropertyFetchToMethodCall $this->newGetMethod = $newGetMethod; $this->newSetMethod = $newSetMethod; $this->newGetArguments = $newGetArguments; - \Rector\Core\Validation\RectorAssert::className($oldType); + RectorAssert::className($oldType); } - public function getOldObjectType() : \PHPStan\Type\ObjectType + public function getOldObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->oldType); + return new ObjectType($this->oldType); } public function getOldProperty() : string { diff --git a/rules/Transform/ValueObject/ReplaceParentCallByPropertyCall.php b/rules/Transform/ValueObject/ReplaceParentCallByPropertyCall.php index 4de46e937a3..610d81b9b26 100644 --- a/rules/Transform/ValueObject/ReplaceParentCallByPropertyCall.php +++ b/rules/Transform/ValueObject/ReplaceParentCallByPropertyCall.php @@ -27,11 +27,11 @@ final class ReplaceParentCallByPropertyCall $this->class = $class; $this->method = $method; $this->property = $property; - \Rector\Core\Validation\RectorAssert::className($class); + RectorAssert::className($class); } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->class); + return new ObjectType($this->class); } public function getMethod() : string { diff --git a/rules/Transform/ValueObject/ServiceGetterToConstructorInjection.php b/rules/Transform/ValueObject/ServiceGetterToConstructorInjection.php index 706ee8b416a..6a8abfa117c 100644 --- a/rules/Transform/ValueObject/ServiceGetterToConstructorInjection.php +++ b/rules/Transform/ValueObject/ServiceGetterToConstructorInjection.php @@ -27,12 +27,12 @@ final class ServiceGetterToConstructorInjection $this->oldType = $oldType; $this->oldMethod = $oldMethod; $this->serviceType = $serviceType; - \Rector\Core\Validation\RectorAssert::className($oldType); - \Rector\Core\Validation\RectorAssert::className($serviceType); + RectorAssert::className($oldType); + RectorAssert::className($serviceType); } - public function getOldObjectType() : \PHPStan\Type\ObjectType + public function getOldObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->oldType); + return new ObjectType($this->oldType); } public function getOldMethod() : string { diff --git a/rules/Transform/ValueObject/StaticCallToFuncCall.php b/rules/Transform/ValueObject/StaticCallToFuncCall.php index df019cae930..e6a7ba786a8 100644 --- a/rules/Transform/ValueObject/StaticCallToFuncCall.php +++ b/rules/Transform/ValueObject/StaticCallToFuncCall.php @@ -27,11 +27,11 @@ final class StaticCallToFuncCall $this->class = $class; $this->method = $method; $this->function = $function; - \Rector\Core\Validation\RectorAssert::className($class); + RectorAssert::className($class); } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->class); + return new ObjectType($this->class); } public function getMethod() : string { diff --git a/rules/Transform/ValueObject/StaticCallToMethodCall.php b/rules/Transform/ValueObject/StaticCallToMethodCall.php index 12ceb2e3d26..b875eac5d90 100644 --- a/rules/Transform/ValueObject/StaticCallToMethodCall.php +++ b/rules/Transform/ValueObject/StaticCallToMethodCall.php @@ -36,9 +36,9 @@ final class StaticCallToMethodCall $this->classType = $classType; $this->methodName = $methodName; } - public function getClassObjectType() : \PHPStan\Type\ObjectType + public function getClassObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->classType); + return new ObjectType($this->classType); } public function getClassType() : string { @@ -48,16 +48,16 @@ final class StaticCallToMethodCall { return $this->methodName; } - public function isStaticCallMatch(\PhpParser\Node\Expr\StaticCall $staticCall) : bool + public function isStaticCallMatch(StaticCall $staticCall) : bool { - if (!$staticCall->class instanceof \PhpParser\Node\Name) { + if (!$staticCall->class instanceof Name) { return \false; } $staticCallClassName = $staticCall->class->toString(); if ($staticCallClassName !== $this->staticClass) { return \false; } - if (!$staticCall->name instanceof \PhpParser\Node\Identifier) { + if (!$staticCall->name instanceof Identifier) { return \false; } // all methods diff --git a/rules/Transform/ValueObject/StaticCallToNew.php b/rules/Transform/ValueObject/StaticCallToNew.php index a345360e653..beb9b721280 100644 --- a/rules/Transform/ValueObject/StaticCallToNew.php +++ b/rules/Transform/ValueObject/StaticCallToNew.php @@ -20,7 +20,7 @@ final class StaticCallToNew { $this->class = $class; $this->method = $method; - \Rector\Core\Validation\RectorAssert::className($class); + RectorAssert::className($class); } public function getClass() : string { diff --git a/rules/Transform/ValueObject/StringToClassConstant.php b/rules/Transform/ValueObject/StringToClassConstant.php index f6e4bba791d..80409af7514 100644 --- a/rules/Transform/ValueObject/StringToClassConstant.php +++ b/rules/Transform/ValueObject/StringToClassConstant.php @@ -26,7 +26,7 @@ final class StringToClassConstant $this->string = $string; $this->class = $class; $this->constant = $constant; - \Rector\Core\Validation\RectorAssert::className($class); + RectorAssert::className($class); } public function getString() : string { diff --git a/rules/Transform/ValueObject/UnsetAndIssetToMethodCall.php b/rules/Transform/ValueObject/UnsetAndIssetToMethodCall.php index ad922066e50..04e3b53435e 100644 --- a/rules/Transform/ValueObject/UnsetAndIssetToMethodCall.php +++ b/rules/Transform/ValueObject/UnsetAndIssetToMethodCall.php @@ -27,11 +27,11 @@ final class UnsetAndIssetToMethodCall $this->type = $type; $this->issetMethodCall = $issetMethodCall; $this->unsedMethodCall = $unsedMethodCall; - \Rector\Core\Validation\RectorAssert::className($type); + RectorAssert::className($type); } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->type); + return new ObjectType($this->type); } public function getIssetMethodCall() : string { diff --git a/rules/Transform/ValueObject/WrapReturn.php b/rules/Transform/ValueObject/WrapReturn.php index b432b496ad2..724ae9fa359 100644 --- a/rules/Transform/ValueObject/WrapReturn.php +++ b/rules/Transform/ValueObject/WrapReturn.php @@ -27,11 +27,11 @@ final class WrapReturn $this->type = $type; $this->method = $method; $this->isArrayWrap = $isArrayWrap; - \Rector\Core\Validation\RectorAssert::className($type); + RectorAssert::className($type); } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->type); + return new ObjectType($this->type); } public function getMethod() : string { diff --git a/rules/TypeDeclaration/AlreadyAssignDetector/ConstructorAssignDetector.php b/rules/TypeDeclaration/AlreadyAssignDetector/ConstructorAssignDetector.php index f316a479811..e06c720ffd1 100644 --- a/rules/TypeDeclaration/AlreadyAssignDetector/ConstructorAssignDetector.php +++ b/rules/TypeDeclaration/AlreadyAssignDetector/ConstructorAssignDetector.php @@ -48,7 +48,7 @@ final class ConstructorAssignDetector * @var \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer */ private $propertyFetchAnalyzer; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\TypeDeclaration\Matcher\PropertyAssignMatcher $propertyAssignMatcher, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\TypeDeclaration\NodeAnalyzer\AutowiredClassMethodOrPropertyAnalyzer $autowiredClassMethodOrPropertyAnalyzer, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer) + public function __construct(NodeTypeResolver $nodeTypeResolver, PropertyAssignMatcher $propertyAssignMatcher, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, AutowiredClassMethodOrPropertyAnalyzer $autowiredClassMethodOrPropertyAnalyzer, PropertyFetchAnalyzer $propertyFetchAnalyzer) { $this->nodeTypeResolver = $nodeTypeResolver; $this->propertyAssignMatcher = $propertyAssignMatcher; @@ -56,7 +56,7 @@ final class ConstructorAssignDetector $this->autowiredClassMethodOrPropertyAnalyzer = $autowiredClassMethodOrPropertyAnalyzer; $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; } - public function isPropertyAssigned(\PhpParser\Node\Stmt\ClassLike $classLike, string $propertyName) : bool + public function isPropertyAssigned(ClassLike $classLike, string $propertyName) : bool { $initializeClassMethods = $this->matchInitializeClassMethod($classLike); if ($initializeClassMethods === []) { @@ -65,9 +65,9 @@ final class ConstructorAssignDetector $isAssignedInConstructor = \false; $this->decorateFirstLevelStatementAttribute($initializeClassMethods); foreach ($initializeClassMethods as $initializeClassMethod) { - $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $initializeClassMethod->stmts, function (\PhpParser\Node $node) use($propertyName, &$isAssignedInConstructor) : ?int { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $initializeClassMethod->stmts, function (Node $node) use($propertyName, &$isAssignedInConstructor) : ?int { $expr = $this->matchAssignExprToPropertyName($node, $propertyName); - if (!$expr instanceof \PhpParser\Node\Expr) { + if (!$expr instanceof Expr) { return null; } /** @var Assign $assign */ @@ -78,7 +78,7 @@ final class ConstructorAssignDetector return null; } $isAssignedInConstructor = \true; - return \PhpParser\NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; + return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; }); } if (!$isAssignedInConstructor) { @@ -86,9 +86,9 @@ final class ConstructorAssignDetector } return $isAssignedInConstructor; } - private function matchAssignExprToPropertyName(\PhpParser\Node $node, string $propertyName) : ?\PhpParser\Node\Expr + private function matchAssignExprToPropertyName(Node $node, string $propertyName) : ?Expr { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + if (!$node instanceof Assign) { return null; } return $this->propertyAssignMatcher->matchPropertyAssignExpr($node, $propertyName); @@ -101,7 +101,7 @@ final class ConstructorAssignDetector foreach ($classMethods as $classMethod) { foreach ((array) $classMethod->stmts as $methodStmt) { $methodStmt->setAttribute(self::IS_FIRST_LEVEL_STATEMENT, \true); - if ($methodStmt instanceof \PhpParser\Node\Stmt\Expression) { + if ($methodStmt instanceof Expression) { $methodStmt->expr->setAttribute(self::IS_FIRST_LEVEL_STATEMENT, \true); } } @@ -110,21 +110,21 @@ final class ConstructorAssignDetector /** * @return ClassMethod[] */ - private function matchInitializeClassMethod(\PhpParser\Node\Stmt\ClassLike $classLike) : array + private function matchInitializeClassMethod(ClassLike $classLike) : array { $initializingClassMethods = []; - $constructClassMethod = $classLike->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if ($constructClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $constructClassMethod = $classLike->getMethod(MethodName::CONSTRUCT); + if ($constructClassMethod instanceof ClassMethod) { $initializingClassMethods[] = $constructClassMethod; } - $testCaseObjectType = new \PHPStan\Type\ObjectType('PHPUnit\\Framework\\TestCase'); + $testCaseObjectType = new ObjectType('PHPUnit\\Framework\\TestCase'); if ($this->nodeTypeResolver->isObjectType($classLike, $testCaseObjectType)) { - $setUpClassMethod = $classLike->getMethod(\Rector\Core\ValueObject\MethodName::SET_UP); - if ($setUpClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $setUpClassMethod = $classLike->getMethod(MethodName::SET_UP); + if ($setUpClassMethod instanceof ClassMethod) { $initializingClassMethods[] = $setUpClassMethod; } - $setUpBeforeClassMethod = $classLike->getMethod(\Rector\Core\ValueObject\MethodName::SET_UP_BEFORE_CLASS); - if ($setUpBeforeClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $setUpBeforeClassMethod = $classLike->getMethod(MethodName::SET_UP_BEFORE_CLASS); + if ($setUpBeforeClassMethod instanceof ClassMethod) { $initializingClassMethods[] = $setUpBeforeClassMethod; } } diff --git a/rules/TypeDeclaration/AlreadyAssignDetector/NullTypeAssignDetector.php b/rules/TypeDeclaration/AlreadyAssignDetector/NullTypeAssignDetector.php index 337da8f9c16..3e262196be3 100644 --- a/rules/TypeDeclaration/AlreadyAssignDetector/NullTypeAssignDetector.php +++ b/rules/TypeDeclaration/AlreadyAssignDetector/NullTypeAssignDetector.php @@ -43,7 +43,7 @@ final class NullTypeAssignDetector * @var \Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser */ private $simpleCallableNodeTraverser; - public function __construct(\Rector\NodeNestingScope\ScopeNestingComparator $scopeNestingComparator, \Rector\PHPStanStaticTypeMapper\DoctrineTypeAnalyzer $doctrineTypeAnalyzer, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\TypeDeclaration\Matcher\PropertyAssignMatcher $propertyAssignMatcher, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser) + public function __construct(ScopeNestingComparator $scopeNestingComparator, DoctrineTypeAnalyzer $doctrineTypeAnalyzer, NodeTypeResolver $nodeTypeResolver, PropertyAssignMatcher $propertyAssignMatcher, SimpleCallableNodeTraverser $simpleCallableNodeTraverser) { $this->scopeNestingComparator = $scopeNestingComparator; $this->doctrineTypeAnalyzer = $doctrineTypeAnalyzer; @@ -51,31 +51,31 @@ final class NullTypeAssignDetector $this->propertyAssignMatcher = $propertyAssignMatcher; $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; } - public function detect(\PhpParser\Node\Stmt\ClassLike $classLike, string $propertyName) : bool + public function detect(ClassLike $classLike, string $propertyName) : bool { $needsNullType = \false; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classLike->stmts, function (\PhpParser\Node $node) use($propertyName, &$needsNullType) : ?int { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classLike->stmts, function (Node $node) use($propertyName, &$needsNullType) : ?int { $expr = $this->matchAssignExprToPropertyName($node, $propertyName); - if (!$expr instanceof \PhpParser\Node\Expr) { + if (!$expr instanceof Expr) { return null; } if ($this->scopeNestingComparator->isNodeConditionallyScoped($expr)) { $needsNullType = \true; - return \PhpParser\NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; + return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; } // not in doctrine property $staticType = $this->nodeTypeResolver->getType($expr); if ($this->doctrineTypeAnalyzer->isDoctrineCollectionWithIterableUnionType($staticType)) { $needsNullType = \false; - return \PhpParser\NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; + return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; } return null; }); return $needsNullType; } - private function matchAssignExprToPropertyName(\PhpParser\Node $node, string $propertyName) : ?\PhpParser\Node\Expr + private function matchAssignExprToPropertyName(Node $node, string $propertyName) : ?Expr { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + if (!$node instanceof Assign) { return null; } return $this->propertyAssignMatcher->matchPropertyAssignExpr($node, $propertyName); diff --git a/rules/TypeDeclaration/AlreadyAssignDetector/PropertyDefaultAssignDetector.php b/rules/TypeDeclaration/AlreadyAssignDetector/PropertyDefaultAssignDetector.php index 318e5df2c01..b942b9e854d 100644 --- a/rules/TypeDeclaration/AlreadyAssignDetector/PropertyDefaultAssignDetector.php +++ b/rules/TypeDeclaration/AlreadyAssignDetector/PropertyDefaultAssignDetector.php @@ -7,10 +7,10 @@ use PhpParser\Node\Stmt\ClassLike; use PhpParser\Node\Stmt\Property; final class PropertyDefaultAssignDetector { - public function detect(\PhpParser\Node\Stmt\ClassLike $classLike, string $propertyName) : bool + public function detect(ClassLike $classLike, string $propertyName) : bool { $property = $classLike->getProperty($propertyName); - if (!$property instanceof \PhpParser\Node\Stmt\Property) { + if (!$property instanceof Property) { return \false; } return $property->props[0]->default !== null; diff --git a/rules/TypeDeclaration/Contract/PHPStan/TypeWithClassTypeSpecifierInterface.php b/rules/TypeDeclaration/Contract/PHPStan/TypeWithClassTypeSpecifierInterface.php index 1d892328786..515f3ffa62c 100644 --- a/rules/TypeDeclaration/Contract/PHPStan/TypeWithClassTypeSpecifierInterface.php +++ b/rules/TypeDeclaration/Contract/PHPStan/TypeWithClassTypeSpecifierInterface.php @@ -8,6 +8,6 @@ use PHPStan\Type\ObjectType; use PHPStan\Type\TypeWithClassName; interface TypeWithClassTypeSpecifierInterface { - public function match(\PHPStan\Type\ObjectType $objectType, \PHPStan\Analyser\Scope $scope) : bool; - public function resolveObjectReferenceType(\PHPStan\Type\ObjectType $objectType, \PHPStan\Analyser\Scope $scope) : \PHPStan\Type\TypeWithClassName; + public function match(ObjectType $objectType, Scope $scope) : bool; + public function resolveObjectReferenceType(ObjectType $objectType, Scope $scope) : TypeWithClassName; } diff --git a/rules/TypeDeclaration/Contract/TypeInferer/ParamTypeInfererInterface.php b/rules/TypeDeclaration/Contract/TypeInferer/ParamTypeInfererInterface.php index a8b8f36318a..393c15aa966 100644 --- a/rules/TypeDeclaration/Contract/TypeInferer/ParamTypeInfererInterface.php +++ b/rules/TypeDeclaration/Contract/TypeInferer/ParamTypeInfererInterface.php @@ -7,5 +7,5 @@ use PhpParser\Node\Param; use PHPStan\Type\Type; interface ParamTypeInfererInterface { - public function inferParam(\PhpParser\Node\Param $param) : \PHPStan\Type\Type; + public function inferParam(Param $param) : Type; } diff --git a/rules/TypeDeclaration/Contract/TypeInferer/ReturnTypeInfererInterface.php b/rules/TypeDeclaration/Contract/TypeInferer/ReturnTypeInfererInterface.php index a3f84924681..2acd4718a2f 100644 --- a/rules/TypeDeclaration/Contract/TypeInferer/ReturnTypeInfererInterface.php +++ b/rules/TypeDeclaration/Contract/TypeInferer/ReturnTypeInfererInterface.php @@ -6,7 +6,7 @@ namespace Rector\TypeDeclaration\Contract\TypeInferer; use PhpParser\Node\FunctionLike; use PHPStan\Type\Type; use Rector\TypeDeclaration\Contract\PriorityAwareInterface; -interface ReturnTypeInfererInterface extends \Rector\TypeDeclaration\Contract\PriorityAwareInterface +interface ReturnTypeInfererInterface extends PriorityAwareInterface { - public function inferFunctionLike(\PhpParser\Node\FunctionLike $functionLike) : \PHPStan\Type\Type; + public function inferFunctionLike(FunctionLike $functionLike) : Type; } diff --git a/rules/TypeDeclaration/Exception/ConflictingPriorityException.php b/rules/TypeDeclaration/Exception/ConflictingPriorityException.php index 677adba0544..f8cd6c7432d 100644 --- a/rules/TypeDeclaration/Exception/ConflictingPriorityException.php +++ b/rules/TypeDeclaration/Exception/ConflictingPriorityException.php @@ -5,9 +5,9 @@ namespace Rector\TypeDeclaration\Exception; use Exception; use Rector\TypeDeclaration\Contract\PriorityAwareInterface; -final class ConflictingPriorityException extends \Exception +final class ConflictingPriorityException extends Exception { - public function __construct(\Rector\TypeDeclaration\Contract\PriorityAwareInterface $firstPriorityAwareTypeInferer, \Rector\TypeDeclaration\Contract\PriorityAwareInterface $secondPriorityAwareTypeInferer) + public function __construct(PriorityAwareInterface $firstPriorityAwareTypeInferer, PriorityAwareInterface $secondPriorityAwareTypeInferer) { $message = \sprintf('There are 2 type inferers with %d priority:%s- %s%s- %s.%sChange value in "getPriority()" method in one of them to different value', $firstPriorityAwareTypeInferer->getPriority(), \PHP_EOL, \get_class($firstPriorityAwareTypeInferer), \PHP_EOL, \get_class($secondPriorityAwareTypeInferer), \PHP_EOL); parent::__construct($message); diff --git a/rules/TypeDeclaration/FunctionLikeReturnTypeResolver.php b/rules/TypeDeclaration/FunctionLikeReturnTypeResolver.php index 852b264e32b..e71253aed92 100644 --- a/rules/TypeDeclaration/FunctionLikeReturnTypeResolver.php +++ b/rules/TypeDeclaration/FunctionLikeReturnTypeResolver.php @@ -14,15 +14,15 @@ final class FunctionLikeReturnTypeResolver * @var \Rector\StaticTypeMapper\StaticTypeMapper */ private $staticTypeMapper; - public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper) + public function __construct(StaticTypeMapper $staticTypeMapper) { $this->staticTypeMapper = $staticTypeMapper; } - public function resolveFunctionLikeReturnTypeToPHPStanType(\PhpParser\Node\FunctionLike $functionLike) : \PHPStan\Type\Type + public function resolveFunctionLikeReturnTypeToPHPStanType(FunctionLike $functionLike) : Type { $functionReturnType = $functionLike->getReturnType(); if ($functionReturnType === null) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } return $this->staticTypeMapper->mapPhpParserNodePHPStanType($functionReturnType); } diff --git a/rules/TypeDeclaration/Guard/PhpDocNestedAnnotationGuard.php b/rules/TypeDeclaration/Guard/PhpDocNestedAnnotationGuard.php index a6d4a6b2923..871be95293f 100644 --- a/rules/TypeDeclaration/Guard/PhpDocNestedAnnotationGuard.php +++ b/rules/TypeDeclaration/Guard/PhpDocNestedAnnotationGuard.php @@ -22,7 +22,7 @@ final class PhpDocNestedAnnotationGuard * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory */ private $phpDocInfoFactory; - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory) { $this->phpDocInfoFactory = $phpDocInfoFactory; } @@ -30,9 +30,9 @@ final class PhpDocNestedAnnotationGuard * Check if rector accidentally skipped annotation during parsing which it should not have (this bug is likely related to parsing of annotations * in phpstan / rector) */ - public function isPhpDocCommentCorrectlyParsed(\PhpParser\Node $node) : bool + public function isPhpDocCommentCorrectlyParsed(Node $node) : bool { - $comments = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, []); + $comments = $node->getAttribute(AttributeKey::COMMENTS, []); if ((\is_array($comments) || $comments instanceof \Countable ? \count($comments) : 0) !== 1) { return \true; } @@ -48,8 +48,8 @@ final class PhpDocNestedAnnotationGuard } public function hasAnnotationCountChanged(string $originalPhpDocText, string $updatedPhpDocText) : bool { - $originalAnnotationCount = \count(\RectorPrefix20220607\Nette\Utils\Strings::matchAll($originalPhpDocText, self::SIMPLE_ANNOTATION_REGEX)); - $reconstructedAnnotationCount = \count(\RectorPrefix20220607\Nette\Utils\Strings::matchAll($updatedPhpDocText, self::SIMPLE_ANNOTATION_REGEX)); + $originalAnnotationCount = \count(Strings::matchAll($originalPhpDocText, self::SIMPLE_ANNOTATION_REGEX)); + $reconstructedAnnotationCount = \count(Strings::matchAll($updatedPhpDocText, self::SIMPLE_ANNOTATION_REGEX)); return $originalAnnotationCount !== $reconstructedAnnotationCount; } } diff --git a/rules/TypeDeclaration/Guard/PropertyTypeOverrideGuard.php b/rules/TypeDeclaration/Guard/PropertyTypeOverrideGuard.php index c24a7340a32..16353fe81e7 100644 --- a/rules/TypeDeclaration/Guard/PropertyTypeOverrideGuard.php +++ b/rules/TypeDeclaration/Guard/PropertyTypeOverrideGuard.php @@ -19,15 +19,15 @@ final class PropertyTypeOverrideGuard * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(NodeNameResolver $nodeNameResolver, ReflectionResolver $reflectionResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->reflectionResolver = $reflectionResolver; } - public function isLegal(\PhpParser\Node\Stmt\Property $property) : bool + public function isLegal(Property $property) : bool { $classReflection = $this->reflectionResolver->resolveClassReflection($property); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \true; } $propertyName = $this->nodeNameResolver->getName($property); diff --git a/rules/TypeDeclaration/Helper/PhpDocNullableTypeHelper.php b/rules/TypeDeclaration/Helper/PhpDocNullableTypeHelper.php index 7049846c842..c6a4ab9ebb5 100644 --- a/rules/TypeDeclaration/Helper/PhpDocNullableTypeHelper.php +++ b/rules/TypeDeclaration/Helper/PhpDocNullableTypeHelper.php @@ -24,7 +24,7 @@ final class PhpDocNullableTypeHelper * @var \Rector\Core\PhpParser\Node\Value\ValueResolver */ private $valueResolver; - public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver) + public function __construct(StaticTypeMapper $staticTypeMapper, ValueResolver $valueResolver) { $this->staticTypeMapper = $staticTypeMapper; $this->valueResolver = $valueResolver; @@ -32,9 +32,9 @@ final class PhpDocNullableTypeHelper /** * @return Type|null Returns null if it was not possible to resolve new php doc type or if update is not required */ - public function resolveUpdatedPhpDocTypeFromPhpDocTypeAndPhpParserType(\PHPStan\Type\Type $phpDocType, \PHPStan\Type\Type $phpParserType) : ?\PHPStan\Type\Type + public function resolveUpdatedPhpDocTypeFromPhpDocTypeAndPhpParserType(Type $phpDocType, Type $phpParserType) : ?Type { - if ($phpParserType instanceof \PHPStan\Type\MixedType) { + if ($phpParserType instanceof MixedType) { return null; } return $this->resolveUpdatedPhpDocTypeFromPhpDocTypeAndPhpParserTypeNullInfo($phpDocType, $this->isParserTypeContainingNullType($phpParserType)); @@ -42,28 +42,28 @@ final class PhpDocNullableTypeHelper /** * @return Type|null Returns null if it was not possible to resolve new php doc param type or if update is not required */ - public function resolveUpdatedPhpDocTypeFromPhpDocTypeAndParamNode(\PHPStan\Type\Type $phpDocType, \PhpParser\Node\Param $param) : ?\PHPStan\Type\Type + public function resolveUpdatedPhpDocTypeFromPhpDocTypeAndParamNode(Type $phpDocType, Param $param) : ?Type { if ($param->type === null) { return null; } $phpParserType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($param->type); - if ($phpParserType instanceof \PHPStan\Type\UnionType) { - $isPhpParserTypeContainingNullType = \PHPStan\Type\TypeCombinator::containsNull($phpParserType); + if ($phpParserType instanceof UnionType) { + $isPhpParserTypeContainingNullType = TypeCombinator::containsNull($phpParserType); } elseif ($param->default !== null) { $value = $this->valueResolver->getValue($param->default); - $isPhpParserTypeContainingNullType = $value === null || $param->default instanceof \PhpParser\Node\Expr\ConstFetch && $value === 'null'; + $isPhpParserTypeContainingNullType = $value === null || $param->default instanceof ConstFetch && $value === 'null'; } else { $isPhpParserTypeContainingNullType = \false; } $resolvedType = $this->resolveUpdatedPhpDocTypeFromPhpDocTypeAndPhpParserTypeNullInfo($phpDocType, $isPhpParserTypeContainingNullType); - if ($resolvedType instanceof \PHPStan\Type\UnionType) { + if ($resolvedType instanceof UnionType) { return $this->cleanNullableMixed($resolvedType); } - if ($resolvedType instanceof \PHPStan\Type\Type) { + if ($resolvedType instanceof Type) { return $resolvedType; } - if (!$phpDocType instanceof \PHPStan\Type\UnionType) { + if (!$phpDocType instanceof UnionType) { return null; } $cleanNullableMixed = $this->cleanNullableMixed($phpDocType); @@ -72,15 +72,15 @@ final class PhpDocNullableTypeHelper } return $cleanNullableMixed; } - private function cleanNullableMixed(\PHPStan\Type\UnionType $unionType) : \PHPStan\Type\Type + private function cleanNullableMixed(UnionType $unionType) : Type { - if (!\PHPStan\Type\TypeCombinator::containsNull($unionType)) { + if (!TypeCombinator::containsNull($unionType)) { return $unionType; } $types = $unionType->getTypes(); foreach ($types as $type) { - if ($type instanceof \PHPStan\Type\MixedType) { - return \PHPStan\Type\TypeCombinator::removeNull($unionType); + if ($type instanceof MixedType) { + return TypeCombinator::removeNull($unionType); } } return $unionType; @@ -92,26 +92,26 @@ final class PhpDocNullableTypeHelper /** * @param Type[] $updatedDocTypes */ - private function composeUpdatedPhpDocType(array $updatedDocTypes) : \PHPStan\Type\Type + private function composeUpdatedPhpDocType(array $updatedDocTypes) : Type { - return \count($updatedDocTypes) === 1 ? $updatedDocTypes[0] : new \PHPStan\Type\UnionType($updatedDocTypes); + return \count($updatedDocTypes) === 1 ? $updatedDocTypes[0] : new UnionType($updatedDocTypes); } - private function isParserTypeContainingNullType(\PHPStan\Type\Type $phpParserType) : bool + private function isParserTypeContainingNullType(Type $phpParserType) : bool { - if ($phpParserType instanceof \PHPStan\Type\UnionType) { - return \PHPStan\Type\TypeCombinator::containsNull($phpParserType); + if ($phpParserType instanceof UnionType) { + return TypeCombinator::containsNull($phpParserType); } return \false; } - private function resolveUpdatedPhpDocTypeFromPhpDocTypeAndPhpParserTypeNullInfo(\PHPStan\Type\Type $phpDocType, bool $isPhpParserTypeContainingNullType) : ?\PHPStan\Type\Type + private function resolveUpdatedPhpDocTypeFromPhpDocTypeAndPhpParserTypeNullInfo(Type $phpDocType, bool $isPhpParserTypeContainingNullType) : ?Type { /** @var array<(NullType | UnionType)> $updatedDocTypes */ $updatedDocTypes = []; $phpDocTypeContainsNullType = \false; - if ($phpDocType instanceof \PHPStan\Type\UnionType) { - $phpDocTypeContainsNullType = \PHPStan\Type\TypeCombinator::containsNull($phpDocType); + if ($phpDocType instanceof UnionType) { + $phpDocTypeContainsNullType = TypeCombinator::containsNull($phpDocType); foreach ($phpDocType->getTypes() as $subType) { - if ($subType instanceof \PHPStan\Type\NullType) { + if ($subType instanceof NullType) { continue; } $updatedDocTypes[] = $subType; @@ -123,7 +123,7 @@ final class PhpDocNullableTypeHelper return null; } if ($isPhpParserTypeContainingNullType) { - $updatedDocTypes[] = new \PHPStan\Type\NullType(); + $updatedDocTypes[] = new NullType(); } return $this->composeUpdatedPhpDocType($updatedDocTypes); } diff --git a/rules/TypeDeclaration/Matcher/PropertyAssignMatcher.php b/rules/TypeDeclaration/Matcher/PropertyAssignMatcher.php index 73cc5f5b7c2..ec8e6bc091e 100644 --- a/rules/TypeDeclaration/Matcher/PropertyAssignMatcher.php +++ b/rules/TypeDeclaration/Matcher/PropertyAssignMatcher.php @@ -20,7 +20,7 @@ final class PropertyAssignMatcher * @var \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer */ private $propertyFetchAnalyzer; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer) + public function __construct(NodeNameResolver $nodeNameResolver, PropertyFetchAnalyzer $propertyFetchAnalyzer) { $this->nodeNameResolver = $nodeNameResolver; $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; @@ -30,7 +30,7 @@ final class PropertyAssignMatcher * - $this->propertyName = $expr; * - $this->propertyName[] = $expr; */ - public function matchPropertyAssignExpr(\PhpParser\Node\Expr\Assign $assign, string $propertyName) : ?\PhpParser\Node\Expr + public function matchPropertyAssignExpr(Assign $assign, string $propertyName) : ?Expr { if ($this->propertyFetchAnalyzer->isPropertyFetch($assign->var)) { if (!$this->nodeNameResolver->isName($assign->var, $propertyName)) { @@ -38,7 +38,7 @@ final class PropertyAssignMatcher } return $assign->expr; } - if ($assign->var instanceof \PhpParser\Node\Expr\ArrayDimFetch && $this->propertyFetchAnalyzer->isPropertyFetch($assign->var->var)) { + if ($assign->var instanceof ArrayDimFetch && $this->propertyFetchAnalyzer->isPropertyFetch($assign->var->var)) { if (!$this->nodeNameResolver->isName($assign->var->var, $propertyName)) { return null; } diff --git a/rules/TypeDeclaration/NodeAnalyzer/AutowiredClassMethodOrPropertyAnalyzer.php b/rules/TypeDeclaration/NodeAnalyzer/AutowiredClassMethodOrPropertyAnalyzer.php index beb4ec5b804..5c800913c13 100644 --- a/rules/TypeDeclaration/NodeAnalyzer/AutowiredClassMethodOrPropertyAnalyzer.php +++ b/rules/TypeDeclaration/NodeAnalyzer/AutowiredClassMethodOrPropertyAnalyzer.php @@ -21,7 +21,7 @@ final class AutowiredClassMethodOrPropertyAnalyzer * @var \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer */ private $phpAttributeAnalyzer; - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer $phpAttributeAnalyzer) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory, PhpAttributeAnalyzer $phpAttributeAnalyzer) { $this->phpDocInfoFactory = $phpDocInfoFactory; $this->phpAttributeAnalyzer = $phpAttributeAnalyzer; @@ -35,6 +35,6 @@ final class AutowiredClassMethodOrPropertyAnalyzer if ($nodePhpDocInfo->hasByNames(['required', 'inject'])) { return \true; } - return $this->phpAttributeAnalyzer->hasPhpAttributes($node, [\RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required::class, 'Nette\\DI\\Attributes\\Inject']); + return $this->phpAttributeAnalyzer->hasPhpAttributes($node, [Required::class, 'Nette\\DI\\Attributes\\Inject']); } } diff --git a/rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php b/rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php index b34501dd3db..6ae22a34e3f 100644 --- a/rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php +++ b/rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php @@ -28,7 +28,7 @@ final class CallTypesResolver * @var \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory */ private $typeFactory; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory) + public function __construct(NodeTypeResolver $nodeTypeResolver, TypeFactory $typeFactory) { $this->nodeTypeResolver = $nodeTypeResolver; $this->typeFactory = $typeFactory; @@ -41,11 +41,11 @@ final class CallTypesResolver { $staticTypesByArgumentPosition = []; foreach ($calls as $call) { - if (!$call instanceof \PhpParser\Node\Expr\StaticCall && !$call instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$call instanceof StaticCall && !$call instanceof MethodCall) { continue; } foreach ($call->args as $position => $arg) { - if (!$arg instanceof \PhpParser\Node\Arg) { + if (!$arg instanceof Arg) { continue; } $argValueType = $this->resolveStrictArgValueType($arg); @@ -55,16 +55,16 @@ final class CallTypesResolver // unite to single type return $this->unionToSingleType($staticTypesByArgumentPosition); } - private function resolveStrictArgValueType(\PhpParser\Node\Arg $arg) : \PHPStan\Type\Type + private function resolveStrictArgValueType(Arg $arg) : Type { $argValueType = $this->nodeTypeResolver->getNativeType($arg->value); // "self" in another object is not correct, this make it independent return $this->correctSelfType($argValueType); } - private function correctSelfType(\PHPStan\Type\Type $argValueType) : \PHPStan\Type\Type + private function correctSelfType(Type $argValueType) : Type { - if ($argValueType instanceof \PHPStan\Type\ThisType) { - return new \PHPStan\Type\ObjectType($argValueType->getClassName()); + if ($argValueType instanceof ThisType) { + return new ObjectType($argValueType->getClassName()); } return $argValueType; } @@ -84,14 +84,14 @@ final class CallTypesResolver if (\count($staticTypeByArgumentPosition) !== 1) { return $staticTypeByArgumentPosition; } - if (!$staticTypeByArgumentPosition[0] instanceof \PHPStan\Type\NullType) { + if (!$staticTypeByArgumentPosition[0] instanceof NullType) { return $staticTypeByArgumentPosition; } - return [new \PHPStan\Type\MixedType()]; + return [new MixedType()]; } - private function narrowParentObjectTreeToSingleObjectChildType(\PHPStan\Type\Type $type) : \PHPStan\Type\Type + private function narrowParentObjectTreeToSingleObjectChildType(Type $type) : Type { - if (!$type instanceof \PHPStan\Type\UnionType) { + if (!$type instanceof UnionType) { return $type; } if (!$this->isTypeWithClassNameOnly($type)) { @@ -100,7 +100,7 @@ final class CallTypesResolver /** @var TypeWithClassName $firstUnionedType */ $firstUnionedType = $type->getTypes()[0]; foreach ($type->getTypes() as $unionedType) { - if (!$unionedType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$unionedType instanceof TypeWithClassName) { return $type; } if ($unionedType->isSuperTypeOf($firstUnionedType)->yes()) { @@ -109,10 +109,10 @@ final class CallTypesResolver } return $firstUnionedType; } - private function isTypeWithClassNameOnly(\PHPStan\Type\UnionType $unionType) : bool + private function isTypeWithClassNameOnly(UnionType $unionType) : bool { foreach ($unionType->getTypes() as $unionedType) { - if (!$unionedType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$unionedType instanceof TypeWithClassName) { return \false; } } diff --git a/rules/TypeDeclaration/NodeAnalyzer/CallerParamMatcher.php b/rules/TypeDeclaration/NodeAnalyzer/CallerParamMatcher.php index 2a54a7b8e65..e7cd0611dd2 100644 --- a/rules/TypeDeclaration/NodeAnalyzer/CallerParamMatcher.php +++ b/rules/TypeDeclaration/NodeAnalyzer/CallerParamMatcher.php @@ -31,7 +31,7 @@ final class CallerParamMatcher * @var \Rector\Core\PhpParser\AstResolver */ private $astResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\AstResolver $astResolver) + public function __construct(NodeNameResolver $nodeNameResolver, AstResolver $astResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->astResolver = $astResolver; @@ -40,10 +40,10 @@ final class CallerParamMatcher * @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\FuncCall $call * @return null|\PhpParser\Node\Identifier|\PhpParser\Node\Name|\PhpParser\Node\NullableType|\PhpParser\Node\UnionType|\PhpParser\Node\ComplexType */ - public function matchCallParamType($call, \PhpParser\Node\Param $param, \PHPStan\Analyser\Scope $scope) + public function matchCallParamType($call, Param $param, Scope $scope) { $callParam = $this->matchCallParam($call, $param, $scope); - if (!$callParam instanceof \PhpParser\Node\Param) { + if (!$callParam instanceof Param) { return null; } return $callParam->type; @@ -51,7 +51,7 @@ final class CallerParamMatcher /** * @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\FuncCall $call */ - public function matchCallParam($call, \PhpParser\Node\Param $param, \PHPStan\Analyser\Scope $scope) : ?\PhpParser\Node\Param + public function matchCallParam($call, Param $param, Scope $scope) : ?Param { $callArgPosition = $this->matchCallArgPosition($call, $param); if ($callArgPosition === null) { @@ -63,7 +63,7 @@ final class CallerParamMatcher } return $classMethodOrFunction->params[$callArgPosition] ?? null; } - public function matchParentParam(\PhpParser\Node\Expr\StaticCall $parentStaticCall, \PhpParser\Node\Param $param, \PHPStan\Analyser\Scope $scope) : ?\PhpParser\Node\Param + public function matchParentParam(StaticCall $parentStaticCall, Param $param, Scope $scope) : ?Param { $methodName = $this->nodeNameResolver->getName($parentStaticCall->name); if ($methodName === null) { @@ -80,14 +80,14 @@ final class CallerParamMatcher * @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\FuncCall $call * @return int|null */ - private function matchCallArgPosition($call, \PhpParser\Node\Param $param) + private function matchCallArgPosition($call, Param $param) { $paramName = $this->nodeNameResolver->getName($param); foreach ($call->args as $argPosition => $arg) { - if (!$arg instanceof \PhpParser\Node\Arg) { + if (!$arg instanceof Arg) { continue; } - if (!$arg->value instanceof \PhpParser\Node\Expr\Variable) { + if (!$arg->value instanceof Variable) { continue; } if (!$this->nodeNameResolver->isName($arg->value, $paramName)) { @@ -97,10 +97,10 @@ final class CallerParamMatcher } return null; } - private function resolveParentMethodParam(\PHPStan\Analyser\Scope $scope, string $methodName, int $paramPosition) : ?\PhpParser\Node\Param + private function resolveParentMethodParam(Scope $scope, string $methodName, int $paramPosition) : ?Param { $classReflection = $scope->getClassReflection(); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return null; } foreach ($classReflection->getParents() as $parentClassReflection) { @@ -108,7 +108,7 @@ final class CallerParamMatcher continue; } $parentClassMethod = $this->astResolver->resolveClassMethod($parentClassReflection->getName(), $methodName); - if (!$parentClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$parentClassMethod instanceof ClassMethod) { continue; } return $parentClassMethod->params[$paramPosition] ?? null; diff --git a/rules/TypeDeclaration/NodeAnalyzer/ClassMethodAndPropertyAnalyzer.php b/rules/TypeDeclaration/NodeAnalyzer/ClassMethodAndPropertyAnalyzer.php index f083341616e..ecd5f5bd3d8 100644 --- a/rules/TypeDeclaration/NodeAnalyzer/ClassMethodAndPropertyAnalyzer.php +++ b/rules/TypeDeclaration/NodeAnalyzer/ClassMethodAndPropertyAnalyzer.php @@ -14,23 +14,23 @@ final class ClassMethodAndPropertyAnalyzer * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } - public function hasClassMethodOnlyStatementReturnOfPropertyFetch(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $propertyName) : bool + public function hasClassMethodOnlyStatementReturnOfPropertyFetch(ClassMethod $classMethod, string $propertyName) : bool { $stmts = (array) $classMethod->stmts; if (\count($stmts) !== 1) { return \false; } $onlyClassMethodStmt = $stmts[0] ?? null; - if (!$onlyClassMethodStmt instanceof \PhpParser\Node\Stmt\Return_) { + if (!$onlyClassMethodStmt instanceof Return_) { return \false; } /** @var Return_ $return */ $return = $onlyClassMethodStmt; - if (!$return->expr instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$return->expr instanceof PropertyFetch) { return \false; } return $this->nodeNameResolver->isName($return->expr, $propertyName); diff --git a/rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php b/rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php index 9947754cd19..f3d6f2f0e17 100644 --- a/rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php +++ b/rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php @@ -40,7 +40,7 @@ final class ClassMethodParamTypeCompleter * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\VendorLocker\NodeVendorLocker\ClassMethodParamVendorLockResolver $classMethodParamVendorLockResolver, \Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeCommonTypeNarrower $unionTypeCommonTypeNarrower, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(StaticTypeMapper $staticTypeMapper, ClassMethodParamVendorLockResolver $classMethodParamVendorLockResolver, UnionTypeCommonTypeNarrower $unionTypeCommonTypeNarrower, PhpVersionProvider $phpVersionProvider) { $this->staticTypeMapper = $staticTypeMapper; $this->classMethodParamVendorLockResolver = $classMethodParamVendorLockResolver; @@ -50,7 +50,7 @@ final class ClassMethodParamTypeCompleter /** * @param array $classParameterTypes */ - public function complete(\PhpParser\Node\Stmt\ClassMethod $classMethod, array $classParameterTypes, int $maxUnionTypes) : ?\PhpParser\Node\Stmt\ClassMethod + public function complete(ClassMethod $classMethod, array $classParameterTypes, int $maxUnionTypes) : ?ClassMethod { $hasChanged = \false; foreach ($classParameterTypes as $position => $argumentStaticType) { @@ -58,8 +58,8 @@ final class ClassMethodParamTypeCompleter if ($this->shouldSkipArgumentStaticType($classMethod, $argumentStaticType, $position, $maxUnionTypes)) { continue; } - $phpParserTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($argumentStaticType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM); - if (!$phpParserTypeNode instanceof \PhpParser\Node) { + $phpParserTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($argumentStaticType, TypeKind::PARAM); + if (!$phpParserTypeNode instanceof Node) { continue; } // check default override @@ -76,13 +76,13 @@ final class ClassMethodParamTypeCompleter } return null; } - private function shouldSkipArgumentStaticType(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PHPStan\Type\Type $argumentStaticType, int $position, int $maxUnionTypes) : bool + private function shouldSkipArgumentStaticType(ClassMethod $classMethod, Type $argumentStaticType, int $position, int $maxUnionTypes) : bool { - if ($argumentStaticType instanceof \PHPStan\Type\MixedType) { + if ($argumentStaticType instanceof MixedType) { return \true; } // skip mixed in union type - if ($argumentStaticType instanceof \PHPStan\Type\UnionType && $argumentStaticType->isSuperTypeOf(new \PHPStan\Type\MixedType())->yes()) { + if ($argumentStaticType instanceof UnionType && $argumentStaticType->isSuperTypeOf(new MixedType())->yes()) { return \true; } if (!isset($classMethod->params[$position])) { @@ -116,48 +116,48 @@ final class ClassMethodParamTypeCompleter // already completed → skip return $currentParameterStaticType->equals($argumentStaticType); } - private function isClosureAndCallableType(\PHPStan\Type\Type $parameterStaticType, \PHPStan\Type\Type $argumentStaticType) : bool + private function isClosureAndCallableType(Type $parameterStaticType, Type $argumentStaticType) : bool { - if ($parameterStaticType instanceof \PHPStan\Type\CallableType && $this->isClosureObjectType($argumentStaticType)) { + if ($parameterStaticType instanceof CallableType && $this->isClosureObjectType($argumentStaticType)) { return \true; } - return $argumentStaticType instanceof \PHPStan\Type\CallableType && $this->isClosureObjectType($parameterStaticType); + return $argumentStaticType instanceof CallableType && $this->isClosureObjectType($parameterStaticType); } - private function isClosureObjectType(\PHPStan\Type\Type $type) : bool + private function isClosureObjectType(Type $type) : bool { - if (!$type instanceof \PHPStan\Type\ObjectType) { + if (!$type instanceof ObjectType) { return \false; } return $type->getClassName() === 'Closure'; } - private function isTooDetailedUnionType(\PHPStan\Type\Type $currentType, \PHPStan\Type\Type $newType, int $maxUnionTypes) : bool + private function isTooDetailedUnionType(Type $currentType, Type $newType, int $maxUnionTypes) : bool { - if ($currentType instanceof \PHPStan\Type\MixedType) { + if ($currentType instanceof MixedType) { return \false; } - if (!$newType instanceof \PHPStan\Type\UnionType) { + if (!$newType instanceof UnionType) { return \false; } return \count($newType->getTypes()) > $maxUnionTypes; } - private function narrowUnionTypeIfNotSupported(\PHPStan\Type\Type $type) : \PHPStan\Type\Type + private function narrowUnionTypeIfNotSupported(Type $type) : Type { - if (!$type instanceof \PHPStan\Type\UnionType) { + if (!$type instanceof UnionType) { return $type; } // union is supported, so it's ok - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::UNION_TYPES)) { + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::UNION_TYPES)) { return $type; } $narrowedObjectType = $this->unionTypeCommonTypeNarrower->narrowToSharedObjectType($type); - if ($narrowedObjectType instanceof \PHPStan\Type\ObjectType) { + if ($narrowedObjectType instanceof ObjectType) { return $narrowedObjectType; } return $type; } - private function isAcceptedByDefault(\PhpParser\Node\Param $param, \PHPStan\Type\Type $argumentStaticType) : bool + private function isAcceptedByDefault(Param $param, Type $argumentStaticType) : bool { - if (!$param->default instanceof \PhpParser\Node\Expr) { + if (!$param->default instanceof Expr) { return \true; } $defaultExpr = $param->default; diff --git a/rules/TypeDeclaration/NodeAnalyzer/ControllerRenderMethodAnalyzer.php b/rules/TypeDeclaration/NodeAnalyzer/ControllerRenderMethodAnalyzer.php index 32726e5b435..13f9ce7b57e 100644 --- a/rules/TypeDeclaration/NodeAnalyzer/ControllerRenderMethodAnalyzer.php +++ b/rules/TypeDeclaration/NodeAnalyzer/ControllerRenderMethodAnalyzer.php @@ -32,18 +32,18 @@ final class ControllerRenderMethodAnalyzer * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\RectorPrefix20220607\Symplify\Astral\Naming\SimpleNameResolver $simpleNameResolver, \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer $phpAttributeAnalyzer, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(SimpleNameResolver $simpleNameResolver, PhpAttributeAnalyzer $phpAttributeAnalyzer, PhpDocInfoFactory $phpDocInfoFactory, ReflectionResolver $reflectionResolver) { $this->simpleNameResolver = $simpleNameResolver; $this->phpAttributeAnalyzer = $phpAttributeAnalyzer; $this->phpDocInfoFactory = $phpDocInfoFactory; $this->reflectionResolver = $reflectionResolver; } - public function isRenderMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + public function isRenderMethod(ClassMethod $classMethod) : bool { // nette one? $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } if ($this->isNetteRenderMethod($classReflection, $classMethod)) { @@ -51,7 +51,7 @@ final class ControllerRenderMethodAnalyzer } return $this->isSymfonyRenderMethod($classReflection, $classMethod); } - private function isNetteRenderMethod(\PHPStan\Reflection\ClassReflection $classReflection, \PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function isNetteRenderMethod(ClassReflection $classReflection, ClassMethod $classMethod) : bool { if (!$classReflection->isSubclassOf('Nette\\Application\\UI\\Control')) { return \false; @@ -61,7 +61,7 @@ final class ControllerRenderMethodAnalyzer } return $this->simpleNameResolver->isNames($classMethod->name, ['render*', 'handle*', 'action*']); } - private function isSymfonyRenderMethod(\PHPStan\Reflection\ClassReflection $classReflection, \PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function isSymfonyRenderMethod(ClassReflection $classReflection, ClassMethod $classMethod) : bool { if (!$classReflection->isSubclassOf('Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller') && !$classReflection->isSubclassOf('Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController')) { return \false; @@ -76,7 +76,7 @@ final class ControllerRenderMethodAnalyzer return \true; } $phpDocInfo = $this->phpDocInfoFactory->createFromNode($classMethod); - if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$phpDocInfo instanceof PhpDocInfo) { return \false; } return $phpDocInfo->hasByAnnotationClass('Symfony\\Component\\Routing\\Annotation\\Route'); diff --git a/rules/TypeDeclaration/NodeAnalyzer/ReturnStrictTypeAnalyzer.php b/rules/TypeDeclaration/NodeAnalyzer/ReturnStrictTypeAnalyzer.php index 44b2db458fa..9e1a80edcdc 100644 --- a/rules/TypeDeclaration/NodeAnalyzer/ReturnStrictTypeAnalyzer.php +++ b/rules/TypeDeclaration/NodeAnalyzer/ReturnStrictTypeAnalyzer.php @@ -32,7 +32,7 @@ final class ReturnStrictTypeAnalyzer * @var \Rector\StaticTypeMapper\StaticTypeMapper */ private $staticTypeMapper; - public function __construct(\Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\TypeDeclaration\NodeAnalyzer\TypeNodeUnwrapper $typeNodeUnwrapper, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper) + public function __construct(ReflectionResolver $reflectionResolver, \Rector\TypeDeclaration\NodeAnalyzer\TypeNodeUnwrapper $typeNodeUnwrapper, StaticTypeMapper $staticTypeMapper) { $this->reflectionResolver = $reflectionResolver; $this->typeNodeUnwrapper = $typeNodeUnwrapper; @@ -50,12 +50,12 @@ final class ReturnStrictTypeAnalyzer return []; } $returnedExpr = $return->expr; - if ($returnedExpr instanceof \PhpParser\Node\Expr\MethodCall || $returnedExpr instanceof \PhpParser\Node\Expr\StaticCall || $returnedExpr instanceof \PhpParser\Node\Expr\FuncCall) { + if ($returnedExpr instanceof MethodCall || $returnedExpr instanceof StaticCall || $returnedExpr instanceof FuncCall) { $returnNode = $this->resolveMethodCallReturnNode($returnedExpr); } else { return []; } - if (!$returnNode instanceof \PhpParser\Node) { + if (!$returnNode instanceof Node) { return []; } $returnedStrictTypeNodes[] = $returnNode; @@ -65,7 +65,7 @@ final class ReturnStrictTypeAnalyzer /** * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\FuncCall $call */ - private function resolveMethodCallReturnNode($call) : ?\PhpParser\Node + private function resolveMethodCallReturnNode($call) : ?Node { $methodReflection = $this->reflectionResolver->resolveFunctionLikeReflectionFromCall($call); if ($methodReflection === null) { @@ -73,9 +73,9 @@ final class ReturnStrictTypeAnalyzer } $parametersAcceptor = $methodReflection->getVariants()[0]; $returnType = $parametersAcceptor->getReturnType(); - if ($returnType instanceof \PHPStan\Type\MixedType) { + if ($returnType instanceof MixedType) { return null; } - return $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($returnType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN); + return $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($returnType, TypeKind::RETURN); } } diff --git a/rules/TypeDeclaration/NodeAnalyzer/TypeNodeUnwrapper.php b/rules/TypeDeclaration/NodeAnalyzer/TypeNodeUnwrapper.php index 8894bf4d150..6b1c6a9d678 100644 --- a/rules/TypeDeclaration/NodeAnalyzer/TypeNodeUnwrapper.php +++ b/rules/TypeDeclaration/NodeAnalyzer/TypeNodeUnwrapper.php @@ -16,7 +16,7 @@ final class TypeNodeUnwrapper * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(NodeComparator $nodeComparator) { $this->nodeComparator = $nodeComparator; } @@ -28,11 +28,11 @@ final class TypeNodeUnwrapper { $unwrappedTypeNodes = []; foreach ($typeNodes as $typeNode) { - if ($typeNode instanceof \PhpParser\Node\UnionType) { + if ($typeNode instanceof UnionType) { $unwrappedTypeNodes = \array_merge($unwrappedTypeNodes, $typeNode->types); - } elseif ($typeNode instanceof \PhpParser\Node\NullableType) { + } elseif ($typeNode instanceof NullableType) { $unwrappedTypeNodes[] = $typeNode->type; - $unwrappedTypeNodes[] = new \PhpParser\Node\Identifier('null'); + $unwrappedTypeNodes[] = new Identifier('null'); } else { $unwrappedTypeNodes[] = $typeNode; } diff --git a/rules/TypeDeclaration/NodeTypeAnalyzer/CallTypeAnalyzer.php b/rules/TypeDeclaration/NodeTypeAnalyzer/CallTypeAnalyzer.php index 44914cc1ebb..fc4b3d4d8ed 100644 --- a/rules/TypeDeclaration/NodeTypeAnalyzer/CallTypeAnalyzer.php +++ b/rules/TypeDeclaration/NodeTypeAnalyzer/CallTypeAnalyzer.php @@ -16,7 +16,7 @@ final class CallTypeAnalyzer * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(ReflectionResolver $reflectionResolver) { $this->reflectionResolver = $reflectionResolver; } @@ -30,7 +30,7 @@ final class CallTypeAnalyzer if ($methodReflection === null) { return []; } - $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); + $parametersAcceptor = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); $parameterTypes = []; /** @var ParameterReflection $parameterReflection */ foreach ($parametersAcceptor->getParameters() as $parameterReflection) { diff --git a/rules/TypeDeclaration/NodeTypeAnalyzer/DetailedTypeAnalyzer.php b/rules/TypeDeclaration/NodeTypeAnalyzer/DetailedTypeAnalyzer.php index a8eeded0ccd..d434c124705 100644 --- a/rules/TypeDeclaration/NodeTypeAnalyzer/DetailedTypeAnalyzer.php +++ b/rules/TypeDeclaration/NodeTypeAnalyzer/DetailedTypeAnalyzer.php @@ -14,20 +14,20 @@ final class DetailedTypeAnalyzer * @var int */ private const MAX_NUMBER_OF_TYPES = 3; - public function isTooDetailed(\PHPStan\Type\Type $type) : bool + public function isTooDetailed(Type $type) : bool { - if ($type instanceof \PHPStan\Type\UnionType) { + if ($type instanceof UnionType) { return \count($type->getTypes()) > self::MAX_NUMBER_OF_TYPES; } - if ($type instanceof \PHPStan\Type\Constant\ConstantArrayType) { + if ($type instanceof ConstantArrayType) { return \count($type->getValueTypes()) > self::MAX_NUMBER_OF_TYPES; } - if ($type instanceof \PHPStan\Type\Generic\GenericObjectType) { + if ($type instanceof GenericObjectType) { return $this->isTooDetailedGenericObjectType($type); } return \false; } - private function isTooDetailedGenericObjectType(\PHPStan\Type\Generic\GenericObjectType $genericObjectType) : bool + private function isTooDetailedGenericObjectType(GenericObjectType $genericObjectType) : bool { if (\count($genericObjectType->getTypes()) !== 1) { return \false; diff --git a/rules/TypeDeclaration/NodeTypeAnalyzer/PropertyTypeDecorator.php b/rules/TypeDeclaration/NodeTypeAnalyzer/PropertyTypeDecorator.php index 6195cb86c26..ac242533b23 100644 --- a/rules/TypeDeclaration/NodeTypeAnalyzer/PropertyTypeDecorator.php +++ b/rules/TypeDeclaration/NodeTypeAnalyzer/PropertyTypeDecorator.php @@ -37,7 +37,7 @@ final class PropertyTypeDecorator * @var \Rector\Core\PhpParser\Node\NodeFactory */ private $nodeFactory; - public function __construct(\Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer $unionTypeAnalyzer, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory) + public function __construct(UnionTypeAnalyzer $unionTypeAnalyzer, PhpDocTypeChanger $phpDocTypeChanger, PhpVersionProvider $phpVersionProvider, NodeFactory $nodeFactory) { $this->unionTypeAnalyzer = $unionTypeAnalyzer; $this->phpDocTypeChanger = $phpDocTypeChanger; @@ -47,10 +47,10 @@ final class PropertyTypeDecorator /** * @param \PhpParser\Node\Name|\PhpParser\Node\ComplexType $typeNode */ - public function decoratePropertyUnionType(\PHPStan\Type\UnionType $unionType, $typeNode, \PhpParser\Node\Stmt\Property $property, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void + public function decoratePropertyUnionType(UnionType $unionType, $typeNode, Property $property, PhpDocInfo $phpDocInfo) : void { if (!$this->unionTypeAnalyzer->isNullable($unionType)) { - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::UNION_TYPES)) { + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::UNION_TYPES)) { $property->type = $typeNode; } else { $this->phpDocTypeChanger->changeVarType($phpDocInfo, $unionType); @@ -68,11 +68,11 @@ final class PropertyTypeDecorator $this->phpDocTypeChanger->changeVarType($phpDocInfo, $unionType); } } - private function isDocBlockRequired(\PHPStan\Type\UnionType $unionType) : bool + private function isDocBlockRequired(UnionType $unionType) : bool { foreach ($unionType->getTypes() as $unionedType) { - if ($unionedType instanceof \PHPStan\Type\ArrayType) { - $describedArray = $unionedType->describe(\PHPStan\Type\VerbosityLevel::value()); + if ($unionedType instanceof ArrayType) { + $describedArray = $unionedType->describe(VerbosityLevel::value()); if ($describedArray !== 'array') { return \true; } diff --git a/rules/TypeDeclaration/NodeTypeAnalyzer/TraitTypeAnalyzer.php b/rules/TypeDeclaration/NodeTypeAnalyzer/TraitTypeAnalyzer.php index 7a87ce6a626..2cf5a9badaf 100644 --- a/rules/TypeDeclaration/NodeTypeAnalyzer/TraitTypeAnalyzer.php +++ b/rules/TypeDeclaration/NodeTypeAnalyzer/TraitTypeAnalyzer.php @@ -19,14 +19,14 @@ final class TraitTypeAnalyzer * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(NodeTypeResolver $nodeTypeResolver, ReflectionProvider $reflectionProvider) { $this->nodeTypeResolver = $nodeTypeResolver; $this->reflectionProvider = $reflectionProvider; } - public function isTraitType(\PHPStan\Type\Type $type) : bool + public function isTraitType(Type $type) : bool { - if (!$type instanceof \PHPStan\Type\TypeWithClassName) { + if (!$type instanceof TypeWithClassName) { return \false; } $fullyQualifiedName = $this->nodeTypeResolver->getFullyQualifiedClassName($type); diff --git a/rules/TypeDeclaration/PHPStan/ObjectTypeSpecifier.php b/rules/TypeDeclaration/PHPStan/ObjectTypeSpecifier.php index d6352ebcd8e..a518ca11a82 100644 --- a/rules/TypeDeclaration/PHPStan/ObjectTypeSpecifier.php +++ b/rules/TypeDeclaration/PHPStan/ObjectTypeSpecifier.php @@ -51,7 +51,7 @@ final class ObjectTypeSpecifier /** * @param TypeWithClassTypeSpecifierInterface[] $typeWithClassTypeSpecifiers */ - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Naming\Naming\UseImportsResolver $useImportsResolver, array $typeWithClassTypeSpecifiers, \Rector\StaticTypeMapper\Naming\NameScopeFactory $nameScopeFactory) + public function __construct(ReflectionProvider $reflectionProvider, UseImportsResolver $useImportsResolver, array $typeWithClassTypeSpecifiers, NameScopeFactory $nameScopeFactory) { $this->reflectionProvider = $reflectionProvider; $this->useImportsResolver = $useImportsResolver; @@ -62,11 +62,11 @@ final class ObjectTypeSpecifier * @param \PHPStan\Analyser\Scope|null $scope * @return \PHPStan\Type\TypeWithClassName|\Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType|\PHPStan\Type\UnionType|\PHPStan\Type\MixedType */ - public function narrowToFullyQualifiedOrAliasedObjectType(\PhpParser\Node $node, \PHPStan\Type\ObjectType $objectType, $scope) + public function narrowToFullyQualifiedOrAliasedObjectType(Node $node, ObjectType $objectType, $scope) { $this->nameScopeFactory->createNameScopeFromNodeWithoutTemplateTypes($node); // @todo reuse name scope - if ($scope instanceof \PHPStan\Analyser\Scope) { + if ($scope instanceof Scope) { foreach ($this->typeWithClassTypeSpecifiers as $typeWithClassTypeSpecifier) { if ($typeWithClassTypeSpecifier->match($objectType, $scope)) { return $typeWithClassTypeSpecifier->resolveObjectReferenceType($objectType, $scope); @@ -76,9 +76,9 @@ final class ObjectTypeSpecifier $uses = $this->useImportsResolver->resolveForNode($node); if ($uses === []) { if (!$this->reflectionProvider->hasClass($objectType->getClassName())) { - return new \Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType($objectType->getClassName()); + return new NonExistingObjectType($objectType->getClassName()); } - return new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($objectType->getClassName(), null, $objectType->getClassReflection()); + return new FullyQualifiedObjectType($objectType->getClassName(), null, $objectType->getClassReflection()); } $aliasedObjectType = $this->matchAliasedObjectType($node, $objectType, $uses); if ($aliasedObjectType !== null) { @@ -90,23 +90,23 @@ final class ObjectTypeSpecifier } $className = \ltrim($objectType->getClassName(), '\\'); if ($this->reflectionProvider->hasClass($className)) { - return new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($className); + return new FullyQualifiedObjectType($className); } // invalid type - return new \Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType($className); + return new NonExistingObjectType($className); } /** * @param Use_[]|GroupUse[] $uses */ - private function matchAliasedObjectType(\PhpParser\Node $node, \PHPStan\Type\ObjectType $objectType, array $uses) : ?\Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType + private function matchAliasedObjectType(Node $node, ObjectType $objectType, array $uses) : ?AliasedObjectType { if ($uses === []) { return null; } $className = $objectType->getClassName(); - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); foreach ($uses as $use) { - $prefix = $use instanceof \PhpParser\Node\Stmt\GroupUse ? $use->prefix . '\\' : ''; + $prefix = $use instanceof GroupUse ? $use->prefix . '\\' : ''; foreach ($use->uses as $useUse) { if ($useUse->alias === null) { continue; @@ -115,26 +115,26 @@ final class ObjectTypeSpecifier $alias = $useUse->alias->toString(); $fullyQualifiedName = $prefix . $useUse->name->toString(); $processAliasedObject = $this->processAliasedObject($alias, $className, $useName, $parent, $fullyQualifiedName); - if ($processAliasedObject instanceof \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType) { + if ($processAliasedObject instanceof AliasedObjectType) { return $processAliasedObject; } } } return null; } - private function processAliasedObject(string $alias, string $className, string $useName, ?\PhpParser\Node $parentNode, string $fullyQualifiedName) : ?\Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType + private function processAliasedObject(string $alias, string $className, string $useName, ?Node $parentNode, string $fullyQualifiedName) : ?AliasedObjectType { // A. is alias in use statement matching this class alias if ($alias === $className) { - return new \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType($alias, $fullyQualifiedName); + return new AliasedObjectType($alias, $fullyQualifiedName); } // B. is aliased classes matching the class name and parent node is MethodCall/StaticCall - if ($useName === $className && ($parentNode instanceof \PhpParser\Node\Expr\MethodCall || $parentNode instanceof \PhpParser\Node\Expr\StaticCall)) { - return new \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType($useName, $fullyQualifiedName); + if ($useName === $className && ($parentNode instanceof MethodCall || $parentNode instanceof StaticCall)) { + return new AliasedObjectType($useName, $fullyQualifiedName); } // C. is aliased classes matching the class name if ($useName === $className) { - return new \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType($alias, $fullyQualifiedName); + return new AliasedObjectType($alias, $fullyQualifiedName); } return null; } @@ -142,13 +142,13 @@ final class ObjectTypeSpecifier * @param Use_[]|GroupUse[] $uses * @return \Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType|\Rector\StaticTypeMapper\ValueObject\Type\ShortenedGenericObjectType|null */ - private function matchShortenedObjectType(\PHPStan\Type\ObjectType $objectType, array $uses) + private function matchShortenedObjectType(ObjectType $objectType, array $uses) { if ($uses === []) { return null; } foreach ($uses as $use) { - $prefix = $use instanceof \PhpParser\Node\Stmt\GroupUse ? $use->prefix . '\\' : ''; + $prefix = $use instanceof GroupUse ? $use->prefix . '\\' : ''; foreach ($use->uses as $useUse) { if ($useUse->alias !== null) { continue; @@ -158,27 +158,27 @@ final class ObjectTypeSpecifier return $partialNamespaceObjectType; } $partialNamespaceObjectType = $this->matchClassWithLastUseImportPart($prefix, $objectType, $useUse); - if ($partialNamespaceObjectType instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) { + if ($partialNamespaceObjectType instanceof FullyQualifiedObjectType) { // keep Generic items - if ($objectType instanceof \PHPStan\Type\Generic\GenericObjectType) { - return new \Rector\StaticTypeMapper\ValueObject\Type\ShortenedGenericObjectType($objectType->getClassName(), $objectType->getTypes(), $partialNamespaceObjectType->getClassName()); + if ($objectType instanceof GenericObjectType) { + return new ShortenedGenericObjectType($objectType->getClassName(), $objectType->getTypes(), $partialNamespaceObjectType->getClassName()); } return $partialNamespaceObjectType->getShortNameType(); } - if ($partialNamespaceObjectType instanceof \Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType) { + if ($partialNamespaceObjectType instanceof ShortenedObjectType) { return $partialNamespaceObjectType; } } } return null; } - private function matchPartialNamespaceObjectType(string $prefix, \PHPStan\Type\ObjectType $objectType, \PhpParser\Node\Stmt\UseUse $useUse) : ?\Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType + private function matchPartialNamespaceObjectType(string $prefix, ObjectType $objectType, UseUse $useUse) : ?ShortenedObjectType { // partial namespace if (\strncmp($objectType->getClassName(), $useUse->name->getLast() . '\\', \strlen($useUse->name->getLast() . '\\')) !== 0) { return null; } - $classNameWithoutLastUsePart = \RectorPrefix20220607\Nette\Utils\Strings::after($objectType->getClassName(), '\\', 1); + $classNameWithoutLastUsePart = Strings::after($objectType->getClassName(), '\\', 1); $connectedClassName = $prefix . $useUse->name->toString() . '\\' . $classNameWithoutLastUsePart; if (!$this->reflectionProvider->hasClass($connectedClassName)) { return null; @@ -186,12 +186,12 @@ final class ObjectTypeSpecifier if ($objectType->getClassName() === $connectedClassName) { return null; } - return new \Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType($objectType->getClassName(), $connectedClassName); + return new ShortenedObjectType($objectType->getClassName(), $connectedClassName); } /** * @return FullyQualifiedObjectType|ShortenedObjectType|null */ - private function matchClassWithLastUseImportPart(string $prefix, \PHPStan\Type\ObjectType $objectType, \PhpParser\Node\Stmt\UseUse $useUse) : ?\PHPStan\Type\ObjectType + private function matchClassWithLastUseImportPart(string $prefix, ObjectType $objectType, UseUse $useUse) : ?ObjectType { if ($useUse->name->getLast() !== $objectType->getClassName()) { return null; @@ -200,8 +200,8 @@ final class ObjectTypeSpecifier return null; } if ($objectType->getClassName() === $prefix . $useUse->name->toString()) { - return new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($objectType->getClassName()); + return new FullyQualifiedObjectType($objectType->getClassName()); } - return new \Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType($objectType->getClassName(), $prefix . $useUse->name->toString()); + return new ShortenedObjectType($objectType->getClassName(), $prefix . $useUse->name->toString()); } } diff --git a/rules/TypeDeclaration/PHPStan/TypeSpecifier/SameNamespacedTypeSpecifier.php b/rules/TypeDeclaration/PHPStan/TypeSpecifier/SameNamespacedTypeSpecifier.php index acfcbd6389d..4172c9143de 100644 --- a/rules/TypeDeclaration/PHPStan/TypeSpecifier/SameNamespacedTypeSpecifier.php +++ b/rules/TypeDeclaration/PHPStan/TypeSpecifier/SameNamespacedTypeSpecifier.php @@ -9,18 +9,18 @@ use PHPStan\Type\ObjectType; use PHPStan\Type\TypeWithClassName; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use Rector\TypeDeclaration\Contract\PHPStan\TypeWithClassTypeSpecifierInterface; -final class SameNamespacedTypeSpecifier implements \Rector\TypeDeclaration\Contract\PHPStan\TypeWithClassTypeSpecifierInterface +final class SameNamespacedTypeSpecifier implements TypeWithClassTypeSpecifierInterface { /** * @readonly * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ReflectionProvider $reflectionProvider) { $this->reflectionProvider = $reflectionProvider; } - public function match(\PHPStan\Type\ObjectType $objectType, \PHPStan\Analyser\Scope $scope) : bool + public function match(ObjectType $objectType, Scope $scope) : bool { $namespaceName = $scope->getNamespace(); if ($namespaceName === null) { @@ -29,9 +29,9 @@ final class SameNamespacedTypeSpecifier implements \Rector\TypeDeclaration\Contr $namespacedClassName = $namespaceName . '\\' . \ltrim($objectType->getClassName(), '\\'); return $this->reflectionProvider->hasClass($namespacedClassName); } - public function resolveObjectReferenceType(\PHPStan\Type\ObjectType $objectType, \PHPStan\Analyser\Scope $scope) : \PHPStan\Type\TypeWithClassName + public function resolveObjectReferenceType(ObjectType $objectType, Scope $scope) : TypeWithClassName { $namespacedClassName = $scope->getNamespace() . '\\' . \ltrim($objectType->getClassName(), '\\'); - return new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($namespacedClassName); + return new FullyQualifiedObjectType($namespacedClassName); } } diff --git a/rules/TypeDeclaration/PHPStan/TypeSpecifier/SelfStaticParentTypeSpecifier.php b/rules/TypeDeclaration/PHPStan/TypeSpecifier/SelfStaticParentTypeSpecifier.php index 2e45c935aa9..deb20396fe5 100644 --- a/rules/TypeDeclaration/PHPStan/TypeSpecifier/SelfStaticParentTypeSpecifier.php +++ b/rules/TypeDeclaration/PHPStan/TypeSpecifier/SelfStaticParentTypeSpecifier.php @@ -13,33 +13,33 @@ use Rector\Core\Exception\ShouldNotHappenException; use Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType; use Rector\StaticTypeMapper\ValueObject\Type\SelfObjectType; use Rector\TypeDeclaration\Contract\PHPStan\TypeWithClassTypeSpecifierInterface; -final class SelfStaticParentTypeSpecifier implements \Rector\TypeDeclaration\Contract\PHPStan\TypeWithClassTypeSpecifierInterface +final class SelfStaticParentTypeSpecifier implements TypeWithClassTypeSpecifierInterface { - public function match(\PHPStan\Type\ObjectType $objectType, \PHPStan\Analyser\Scope $scope) : bool + public function match(ObjectType $objectType, Scope $scope) : bool { $classReflection = $scope->getClassReflection(); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } - return \in_array($objectType->getClassName(), [\Rector\Core\Enum\ObjectReference::STATIC, \Rector\Core\Enum\ObjectReference::PARENT, \Rector\Core\Enum\ObjectReference::SELF], \true); + return \in_array($objectType->getClassName(), [ObjectReference::STATIC, ObjectReference::PARENT, ObjectReference::SELF], \true); } - public function resolveObjectReferenceType(\PHPStan\Type\ObjectType $objectType, \PHPStan\Analyser\Scope $scope) : \PHPStan\Type\TypeWithClassName + public function resolveObjectReferenceType(ObjectType $objectType, Scope $scope) : TypeWithClassName { $classReflection = $scope->getClassReflection(); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$classReflection instanceof ClassReflection) { + throw new ShouldNotHappenException(); } $classReference = $objectType->getClassName(); - if ($classReference === \Rector\Core\Enum\ObjectReference::STATIC) { - return new \PHPStan\Type\StaticType($classReflection); + if ($classReference === ObjectReference::STATIC) { + return new StaticType($classReflection); } - if ($classReference === \Rector\Core\Enum\ObjectReference::SELF) { - return new \Rector\StaticTypeMapper\ValueObject\Type\SelfObjectType($classReference, null, $classReflection); + if ($classReference === ObjectReference::SELF) { + return new SelfObjectType($classReference, null, $classReflection); } $parentClassReflection = $classReflection->getParentClass(); - if (!$parentClassReflection instanceof \PHPStan\Reflection\ClassReflection) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$parentClassReflection instanceof ClassReflection) { + throw new ShouldNotHappenException(); } - return new \Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType($parentClassReflection); + return new ParentStaticType($parentClassReflection); } } diff --git a/rules/TypeDeclaration/PhpDocParser/NonInformativeReturnTagRemover.php b/rules/TypeDeclaration/PhpDocParser/NonInformativeReturnTagRemover.php index 7adfb4091f2..0a9deab8945 100644 --- a/rules/TypeDeclaration/PhpDocParser/NonInformativeReturnTagRemover.php +++ b/rules/TypeDeclaration/PhpDocParser/NonInformativeReturnTagRemover.php @@ -33,7 +33,7 @@ final class NonInformativeReturnTagRemover /** * @var array, string[]> */ - private const USELESS_DOC_NAMES_BY_TYPE_CLASS = [\PHPStan\Type\IterableType::class => ['iterable'], \PHPStan\Type\CallableType::class => ['callable'], \PHPStan\Type\VoidType::class => ['void'], \PHPStan\Type\ArrayType::class => ['array'], \Rector\StaticTypeMapper\ValueObject\Type\SelfObjectType::class => ['self'], \Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType::class => ['parent'], \PHPStan\Type\BooleanType::class => ['bool', 'boolean'], \PHPStan\Type\ObjectWithoutClassType::class => ['object']]; + private const USELESS_DOC_NAMES_BY_TYPE_CLASS = [IterableType::class => ['iterable'], CallableType::class => ['callable'], VoidType::class => ['void'], ArrayType::class => ['array'], SelfObjectType::class => ['self'], ParentStaticType::class => ['parent'], BooleanType::class => ['bool', 'boolean'], ObjectWithoutClassType::class => ['object']]; /** * @readonly * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory @@ -44,7 +44,7 @@ final class NonInformativeReturnTagRemover * @var \Symplify\PackageBuilder\Php\TypeChecker */ private $typeChecker; - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \RectorPrefix20220607\Symplify\PackageBuilder\Php\TypeChecker $typeChecker) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory, TypeChecker $typeChecker) { $this->phpDocInfoFactory = $phpDocInfoFactory; $this->typeChecker = $typeChecker; @@ -56,7 +56,7 @@ final class NonInformativeReturnTagRemover { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike); $returnTagValueNode = $phpDocInfo->getReturnTagValue(); - if (!$returnTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode) { + if (!$returnTagValueNode instanceof ReturnTagValueNode) { return; } // useful @@ -65,8 +65,8 @@ final class NonInformativeReturnTagRemover } $returnType = $phpDocInfo->getReturnType(); // is bare type - if ($this->typeChecker->isInstanceOf($returnType, [\PHPStan\Type\FloatType::class, \PHPStan\Type\StringType::class, \PHPStan\Type\IntegerType::class])) { - $phpDocInfo->removeByType(\PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode::class); + if ($this->typeChecker->isInstanceOf($returnType, [FloatType::class, StringType::class, IntegerType::class])) { + $phpDocInfo->removeByType(ReturnTagValueNode::class); return; } $this->removeNonUniqueUselessDocNames($returnType, $returnTagValueNode, $phpDocInfo); @@ -74,7 +74,7 @@ final class NonInformativeReturnTagRemover $this->removeNullableType($returnType, $returnTagValueNode, $phpDocInfo); $this->removeFullyQualifiedObjectType($returnType, $returnTagValueNode, $phpDocInfo); } - private function removeNonUniqueUselessDocNames(\PHPStan\Type\Type $returnType, \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode $returnTagValueNode, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void + private function removeNonUniqueUselessDocNames(Type $returnType, ReturnTagValueNode $returnTagValueNode, PhpDocInfo $phpDocInfo) : void { foreach (self::USELESS_DOC_NAMES_BY_TYPE_CLASS as $typeClass => $uselessDocNames) { if (!\is_a($returnType, $typeClass, \true)) { @@ -83,87 +83,87 @@ final class NonInformativeReturnTagRemover if (!$this->isIdentifierWithValues($returnTagValueNode->type, $uselessDocNames)) { continue; } - $phpDocInfo->removeByType(\PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode::class); + $phpDocInfo->removeByType(ReturnTagValueNode::class); return; } } - private function removeShortObjectType(\PHPStan\Type\Type $returnType, \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode $returnTagValueNode, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void + private function removeShortObjectType(Type $returnType, ReturnTagValueNode $returnTagValueNode, PhpDocInfo $phpDocInfo) : void { - if (!$returnType instanceof \Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType) { + if (!$returnType instanceof ShortenedObjectType) { return; } if (!$this->isIdentifierWithValues($returnTagValueNode->type, [$returnType->getShortName()])) { return; } - $phpDocInfo->removeByType(\PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode::class); + $phpDocInfo->removeByType(ReturnTagValueNode::class); } - private function removeNullableType(\PHPStan\Type\Type $returnType, \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode $returnTagValueNode, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void + private function removeNullableType(Type $returnType, ReturnTagValueNode $returnTagValueNode, PhpDocInfo $phpDocInfo) : void { $nullabledReturnType = $this->matchNullabledType($returnType); - if (!$nullabledReturnType instanceof \PHPStan\Type\Type) { + if (!$nullabledReturnType instanceof Type) { return; } $nullabledReturnTagValueNode = $this->matchNullabledReturnTagValueNode($returnTagValueNode); - if (!$nullabledReturnTagValueNode instanceof \PHPStan\PhpDocParser\Ast\Type\TypeNode) { + if (!$nullabledReturnTagValueNode instanceof TypeNode) { return; } - if (!$nullabledReturnType instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) { + if (!$nullabledReturnType instanceof FullyQualifiedObjectType) { return; } - if (!$nullabledReturnTagValueNode instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode) { + if (!$nullabledReturnTagValueNode instanceof IdentifierTypeNode) { return; } if (\substr_compare($nullabledReturnType->getClassName(), $nullabledReturnTagValueNode->name, -\strlen($nullabledReturnTagValueNode->name)) !== 0) { return; } - $phpDocInfo->removeByType(\PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode::class); + $phpDocInfo->removeByType(ReturnTagValueNode::class); } - private function removeFullyQualifiedObjectType(\PHPStan\Type\Type $returnType, \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode $returnTagValueNode, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void + private function removeFullyQualifiedObjectType(Type $returnType, ReturnTagValueNode $returnTagValueNode, PhpDocInfo $phpDocInfo) : void { - if (!$returnType instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) { + if (!$returnType instanceof FullyQualifiedObjectType) { return; } - if (!$returnTagValueNode->type instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode) { + if (!$returnTagValueNode->type instanceof IdentifierTypeNode) { return; } $className = $returnType->getClassName(); $returnTagValueNodeType = (string) $returnTagValueNode->type; if ($this->isClassNameAndPartMatch($className, $returnTagValueNodeType)) { - $phpDocInfo->removeByType(\PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode::class); + $phpDocInfo->removeByType(ReturnTagValueNode::class); } } /** * @param string[] $values */ - private function isIdentifierWithValues(\PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode, array $values) : bool + private function isIdentifierWithValues(TypeNode $typeNode, array $values) : bool { - if (!$typeNode instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode) { + if (!$typeNode instanceof IdentifierTypeNode) { return \false; } return \in_array($typeNode->name, $values, \true); } - private function matchNullabledType(\PHPStan\Type\Type $returnType) : ?\PHPStan\Type\Type + private function matchNullabledType(Type $returnType) : ?Type { - if (!$returnType instanceof \PHPStan\Type\UnionType) { + if (!$returnType instanceof UnionType) { return null; } - if (!$returnType->isSuperTypeOf(new \PHPStan\Type\NullType())->yes()) { + if (!$returnType->isSuperTypeOf(new NullType())->yes()) { return null; } if (\count($returnType->getTypes()) !== 2) { return null; } foreach ($returnType->getTypes() as $unionedReturnType) { - if ($unionedReturnType instanceof \PHPStan\Type\NullType) { + if ($unionedReturnType instanceof NullType) { continue; } return $unionedReturnType; } return null; } - private function matchNullabledReturnTagValueNode(\PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode $returnTagValueNode) : ?\PHPStan\PhpDocParser\Ast\Type\TypeNode + private function matchNullabledReturnTagValueNode(ReturnTagValueNode $returnTagValueNode) : ?TypeNode { - if (!$returnTagValueNode->type instanceof \PHPStan\PhpDocParser\Ast\Type\UnionTypeNode) { + if (!$returnTagValueNode->type instanceof UnionTypeNode) { return null; } if (\count($returnTagValueNode->type->types) !== 2) { diff --git a/rules/TypeDeclaration/PhpDocParser/ParamPhpDocNodeFactory.php b/rules/TypeDeclaration/PhpDocParser/ParamPhpDocNodeFactory.php index 228d13ea0ad..eb0aae5e055 100644 --- a/rules/TypeDeclaration/PhpDocParser/ParamPhpDocNodeFactory.php +++ b/rules/TypeDeclaration/PhpDocParser/ParamPhpDocNodeFactory.php @@ -14,12 +14,12 @@ final class ParamPhpDocNodeFactory * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } - public function create(\PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode, \PhpParser\Node\Param $param) : \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode + public function create(TypeNode $typeNode, Param $param) : ParamTagValueNode { - return new \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode($typeNode, $param->variadic, '$' . $this->nodeNameResolver->getName($param), ''); + return new ParamTagValueNode($typeNode, $param->variadic, '$' . $this->nodeNameResolver->getName($param), ''); } } diff --git a/rules/TypeDeclaration/PhpParserTypeAnalyzer.php b/rules/TypeDeclaration/PhpParserTypeAnalyzer.php index e9257ff03e0..235198b7765 100644 --- a/rules/TypeDeclaration/PhpParserTypeAnalyzer.php +++ b/rules/TypeDeclaration/PhpParserTypeAnalyzer.php @@ -17,7 +17,7 @@ final class PhpParserTypeAnalyzer * @var \Rector\StaticTypeMapper\StaticTypeMapper */ private $staticTypeMapper; - public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper) + public function __construct(StaticTypeMapper $staticTypeMapper) { $this->staticTypeMapper = $staticTypeMapper; } @@ -32,11 +32,11 @@ final class PhpParserTypeAnalyzer return \false; } // possible - https://3v4l.org/ZuJCh - if ($possibleSubtype instanceof \PhpParser\Node\NullableType && !$possibleParentType instanceof \PhpParser\Node\NullableType) { + if ($possibleSubtype instanceof NullableType && !$possibleParentType instanceof NullableType) { return $this->isCovariantSubtypeOf($possibleSubtype->type, $possibleParentType); } // not possible - https://3v4l.org/iNDTc - if (!$possibleSubtype instanceof \PhpParser\Node\NullableType && $possibleParentType instanceof \PhpParser\Node\NullableType) { + if (!$possibleSubtype instanceof NullableType && $possibleParentType instanceof NullableType) { return \false; } $subtypeType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($possibleParentType); @@ -49,9 +49,9 @@ final class PhpParserTypeAnalyzer */ private function isUnionType($possibleSubtype, $possibleParentType) : bool { - if ($possibleSubtype instanceof \PhpParser\Node\UnionType) { + if ($possibleSubtype instanceof UnionType) { return \true; } - return $possibleParentType instanceof \PhpParser\Node\UnionType; + return $possibleParentType instanceof UnionType; } } diff --git a/rules/TypeDeclaration/Rector/ClassMethod/AddArrayParamDocTypeRector.php b/rules/TypeDeclaration/Rector/ClassMethod/AddArrayParamDocTypeRector.php index d602b08f9cd..ea5caaab731 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/AddArrayParamDocTypeRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/AddArrayParamDocTypeRector.php @@ -18,12 +18,12 @@ use Rector\Core\NodeAnalyzer\ParamAnalyzer; use Rector\Core\Rector\AbstractRector; use Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover; use Rector\TypeDeclaration\TypeInferer\ParamTypeInferer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddArrayParamDocTypeRector\AddArrayParamDocTypeRectorTest */ -final class AddArrayParamDocTypeRector extends \Rector\Core\Rector\AbstractRector +final class AddArrayParamDocTypeRector extends AbstractRector { /** * @readonly @@ -45,16 +45,16 @@ final class AddArrayParamDocTypeRector extends \Rector\Core\Rector\AbstractRecto * @var \Rector\Core\NodeAnalyzer\ParamAnalyzer */ private $paramAnalyzer; - public function __construct(\Rector\TypeDeclaration\TypeInferer\ParamTypeInferer $paramTypeInferer, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover $paramTagRemover, \Rector\Core\NodeAnalyzer\ParamAnalyzer $paramAnalyzer) + public function __construct(ParamTypeInferer $paramTypeInferer, PhpDocTypeChanger $phpDocTypeChanger, ParamTagRemover $paramTagRemover, ParamAnalyzer $paramAnalyzer) { $this->paramTypeInferer = $paramTypeInferer; $this->phpDocTypeChanger = $phpDocTypeChanger; $this->paramTagRemover = $paramTagRemover; $this->paramAnalyzer = $paramAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Adds @param annotation to array parameters inferred from the rest of the code', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Adds @param annotation to array parameters inferred from the rest of the code', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { /** @@ -92,12 +92,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->getParams() === []) { return null; @@ -109,14 +109,14 @@ CODE_SAMPLE continue; } $paramType = $this->paramTypeInferer->inferParam($param); - if ($paramType instanceof \PHPStan\Type\MixedType) { + if ($paramType instanceof MixedType) { continue; } - if ($paramType instanceof \PHPStan\Type\CallableType) { + if ($paramType instanceof CallableType) { continue; } - if ($this->paramAnalyzer->isNullable($param) && !$paramType instanceof \PHPStan\Type\UnionType) { - $paramType = new \PHPStan\Type\UnionType([$paramType, new \PHPStan\Type\NullType()]); + if ($this->paramAnalyzer->isNullable($param) && !$paramType instanceof UnionType) { + $paramType = new UnionType([$paramType, new NullType()]); } $paramName = $this->getName($param); $this->phpDocTypeChanger->changeParamType($phpDocInfo, $paramType, $param, $paramName); @@ -128,7 +128,7 @@ CODE_SAMPLE } return null; } - private function shouldSkipParam(\PhpParser\Node\Param $param) : bool + private function shouldSkipParam(Param $param) : bool { // type missing at all if ($param->type === null) { @@ -137,7 +137,7 @@ CODE_SAMPLE // not an array type $paramType = $this->nodeTypeResolver->getType($param->type); // weird case for maybe interface - if ($paramType->isIterable()->maybe() && $paramType instanceof \PHPStan\Type\ObjectType) { + if ($paramType->isIterable()->maybe() && $paramType instanceof ObjectType) { return \true; } $isArrayable = $paramType->isIterable()->yes() || $paramType->isArray()->yes() || ($paramType->isIterable()->maybe() || $paramType->isArray()->maybe()); @@ -146,13 +146,13 @@ CODE_SAMPLE } return $this->isArrayExplicitMixed($paramType); } - private function isArrayExplicitMixed(\PHPStan\Type\Type $type) : bool + private function isArrayExplicitMixed(Type $type) : bool { - if (!$type instanceof \PHPStan\Type\ArrayType) { + if (!$type instanceof ArrayType) { return \false; } $iterableValueType = $type->getIterableValueType(); - if (!$iterableValueType instanceof \PHPStan\Type\MixedType) { + if (!$iterableValueType instanceof MixedType) { return \false; } return $iterableValueType->isExplicitMixed(); diff --git a/rules/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector.php b/rules/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector.php index 05cd6cc0290..7e8a0a5b754 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector.php @@ -27,12 +27,12 @@ use Rector\TypeDeclaration\TypeAnalyzer\IterableTypeAnalyzer; use Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer; use Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer\ReturnTypeDeclarationReturnTypeInfererTypeInferer; use Rector\VendorLocker\NodeVendorLocker\ClassMethodReturnTypeOverrideGuard; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector\AddArrayReturnDocTypeRectorTest */ -final class AddArrayReturnDocTypeRector extends \Rector\Core\Rector\AbstractRector +final class AddArrayReturnDocTypeRector extends AbstractRector { /** * @readonly @@ -79,7 +79,7 @@ final class AddArrayReturnDocTypeRector extends \Rector\Core\Rector\AbstractRect * @var \Rector\TypeDeclaration\TypeAnalyzer\IterableTypeAnalyzer */ private $iterableTypeAnalyzer; - public function __construct(\Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer $returnTypeInferer, \Rector\VendorLocker\NodeVendorLocker\ClassMethodReturnTypeOverrideGuard $classMethodReturnTypeOverrideGuard, \Rector\TypeDeclaration\TypeAnalyzer\AdvancedArrayAnalyzer $advancedArrayAnalyzer, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\Privatization\TypeManipulator\NormalizeTypeToRespectArrayScalarType $normalizeTypeToRespectArrayScalarType, \Rector\DeadCode\PhpDoc\TagRemover\ReturnTagRemover $returnTagRemover, \Rector\TypeDeclaration\NodeTypeAnalyzer\DetailedTypeAnalyzer $detailedTypeAnalyzer, \Rector\Privatization\TypeManipulator\TypeNormalizer $typeNormalizer, \Rector\TypeDeclaration\TypeAnalyzer\IterableTypeAnalyzer $iterableTypeAnalyzer) + public function __construct(ReturnTypeInferer $returnTypeInferer, ClassMethodReturnTypeOverrideGuard $classMethodReturnTypeOverrideGuard, AdvancedArrayAnalyzer $advancedArrayAnalyzer, PhpDocTypeChanger $phpDocTypeChanger, NormalizeTypeToRespectArrayScalarType $normalizeTypeToRespectArrayScalarType, ReturnTagRemover $returnTagRemover, DetailedTypeAnalyzer $detailedTypeAnalyzer, TypeNormalizer $typeNormalizer, IterableTypeAnalyzer $iterableTypeAnalyzer) { $this->returnTypeInferer = $returnTypeInferer; $this->classMethodReturnTypeOverrideGuard = $classMethodReturnTypeOverrideGuard; @@ -91,9 +91,9 @@ final class AddArrayReturnDocTypeRector extends \Rector\Core\Rector\AbstractRect $this->typeNormalizer = $typeNormalizer; $this->iterableTypeAnalyzer = $iterableTypeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Adds @return annotation to array parameters inferred from the rest of the code', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Adds @return annotation to array parameters inferred from the rest of the code', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { /** @@ -131,18 +131,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); if ($this->shouldSkip($node, $phpDocInfo)) { return null; } - $inferredReturnType = $this->returnTypeInferer->inferFunctionLikeWithExcludedInferers($node, [\Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer\ReturnTypeDeclarationReturnTypeInfererTypeInferer::class]); + $inferredReturnType = $this->returnTypeInferer->inferFunctionLikeWithExcludedInferers($node, [ReturnTypeDeclarationReturnTypeInfererTypeInferer::class]); $inferredReturnType = $this->normalizeTypeToRespectArrayScalarType->normalizeToArray($inferredReturnType, $node->returnType); // generalize false/true type to bool, as mostly default value but accepts both $inferredReturnType = $this->typeNormalizer->generalizeConstantBoolTypes($inferredReturnType); @@ -163,7 +163,7 @@ CODE_SAMPLE } return null; } - private function shouldSkip(\PhpParser\Node\Stmt\ClassMethod $classMethod, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : bool + private function shouldSkip(ClassMethod $classMethod, PhpDocInfo $phpDocInfo) : bool { if ($this->shouldSkipClassMethod($classMethod)) { return \true; @@ -172,24 +172,24 @@ CODE_SAMPLE return \true; } $currentPhpDocReturnType = $phpDocInfo->getReturnType(); - if ($currentPhpDocReturnType instanceof \PHPStan\Type\ArrayType && $currentPhpDocReturnType->getItemType() instanceof \PHPStan\Type\MixedType) { + if ($currentPhpDocReturnType instanceof ArrayType && $currentPhpDocReturnType->getItemType() instanceof MixedType) { return \true; } if ($this->hasInheritDoc($classMethod)) { return \true; } - return $currentPhpDocReturnType instanceof \PHPStan\Type\IterableType; + return $currentPhpDocReturnType instanceof IterableType; } - private function shouldSkipType(\PHPStan\Type\Type $newType, \PHPStan\Type\Type $currentType, \PhpParser\Node\Stmt\ClassMethod $classMethod, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : bool + private function shouldSkipType(Type $newType, Type $currentType, ClassMethod $classMethod, PhpDocInfo $phpDocInfo) : bool { if (!$this->iterableTypeAnalyzer->isIterableType($newType)) { return \true; } - if ($newType instanceof \PHPStan\Type\ArrayType && $this->shouldSkipArrayType($newType, $classMethod, $phpDocInfo)) { + if ($newType instanceof ArrayType && $this->shouldSkipArrayType($newType, $classMethod, $phpDocInfo)) { return \true; } // not an array type - if ($newType instanceof \PHPStan\Type\VoidType) { + if ($newType instanceof VoidType) { return \true; } if ($this->advancedArrayAnalyzer->isMoreSpecificArrayTypeOverride($newType, $phpDocInfo)) { @@ -200,7 +200,7 @@ CODE_SAMPLE } return $this->detailedTypeAnalyzer->isTooDetailed($newType); } - private function shouldSkipClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkipClassMethod(ClassMethod $classMethod) : bool { if ($this->classMethodReturnTypeOverrideGuard->shouldSkipClassMethod($classMethod)) { return \true; @@ -210,30 +210,30 @@ CODE_SAMPLE } return !$this->isNames($classMethod->returnType, ['array', 'iterable', 'Iterator', 'Generator']); } - private function hasArrayShapeNode(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function hasArrayShapeNode(ClassMethod $classMethod) : bool { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); $returnTagValueNode = $phpDocInfo->getReturnTagValue(); - if (!$returnTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode) { + if (!$returnTagValueNode instanceof ReturnTagValueNode) { return \false; } - if ($returnTagValueNode->type instanceof \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode) { + if ($returnTagValueNode->type instanceof GenericTypeNode) { return \true; } - if ($returnTagValueNode->type instanceof \PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode) { + if ($returnTagValueNode->type instanceof ArrayShapeNode) { return \true; } - if (!$returnTagValueNode->type instanceof \PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode) { + if (!$returnTagValueNode->type instanceof ArrayTypeNode) { return \false; } - return $returnTagValueNode->type->type instanceof \PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode; + return $returnTagValueNode->type->type instanceof ArrayShapeNode; } - private function hasInheritDoc(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function hasInheritDoc(ClassMethod $classMethod) : bool { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); return $phpDocInfo->hasInheritDoc(); } - private function shouldSkipArrayType(\PHPStan\Type\ArrayType $arrayType, \PhpParser\Node\Stmt\ClassMethod $classMethod, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : bool + private function shouldSkipArrayType(ArrayType $arrayType, ClassMethod $classMethod, PhpDocInfo $phpDocInfo) : bool { if ($this->advancedArrayAnalyzer->isNewAndCurrentTypeBothCallable($arrayType, $phpDocInfo)) { return \true; @@ -243,11 +243,11 @@ CODE_SAMPLE } return $this->advancedArrayAnalyzer->isMixedOfSpecificOverride($arrayType, $phpDocInfo); } - private function isGenericTypeToMixedTypeOverride(\PHPStan\Type\Type $newType, \PHPStan\Type\Type $currentType) : bool + private function isGenericTypeToMixedTypeOverride(Type $newType, Type $currentType) : bool { - if ($newType instanceof \PHPStan\Type\Generic\GenericObjectType && $currentType instanceof \PHPStan\Type\MixedType) { + if ($newType instanceof GenericObjectType && $currentType instanceof MixedType) { $types = $newType->getTypes(); - if ($types[0] instanceof \PHPStan\Type\MixedType && $types[1] instanceof \PHPStan\Type\ArrayType) { + if ($types[0] instanceof MixedType && $types[1] instanceof ArrayType) { return \true; } } diff --git a/rules/TypeDeclaration/Rector/ClassMethod/AddMethodCallBasedStrictParamTypeRector.php b/rules/TypeDeclaration/Rector/ClassMethod/AddMethodCallBasedStrictParamTypeRector.php index a1c0f9ab66f..9db1f1cf425 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/AddMethodCallBasedStrictParamTypeRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/AddMethodCallBasedStrictParamTypeRector.php @@ -9,14 +9,14 @@ use Rector\Core\PhpParser\NodeFinder\LocalMethodCallFinder; use Rector\Core\Rector\AbstractRector; use Rector\TypeDeclaration\NodeAnalyzer\CallTypesResolver; use Rector\TypeDeclaration\NodeAnalyzer\ClassMethodParamTypeCompleter; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/symplify/phpstan-rules/blob/master/docs/rules_overview.md#checktypehintcallertyperule * * @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector\AddMethodCallBasedStrictParamTypeRectorTest */ -final class AddMethodCallBasedStrictParamTypeRector extends \Rector\Core\Rector\AbstractRector +final class AddMethodCallBasedStrictParamTypeRector extends AbstractRector { /** * @var int @@ -37,15 +37,15 @@ final class AddMethodCallBasedStrictParamTypeRector extends \Rector\Core\Rector\ * @var \Rector\Core\PhpParser\NodeFinder\LocalMethodCallFinder */ private $localMethodCallFinder; - public function __construct(\Rector\TypeDeclaration\NodeAnalyzer\CallTypesResolver $callTypesResolver, \Rector\TypeDeclaration\NodeAnalyzer\ClassMethodParamTypeCompleter $classMethodParamTypeCompleter, \Rector\Core\PhpParser\NodeFinder\LocalMethodCallFinder $localMethodCallFinder) + public function __construct(CallTypesResolver $callTypesResolver, ClassMethodParamTypeCompleter $classMethodParamTypeCompleter, LocalMethodCallFinder $localMethodCallFinder) { $this->callTypesResolver = $callTypesResolver; $this->classMethodParamTypeCompleter = $classMethodParamTypeCompleter; $this->localMethodCallFinder = $localMethodCallFinder; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change private method param type to strict type, based on passed strict types', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change private method param type to strict type, based on passed strict types', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run(int $value) @@ -78,12 +78,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->params === []) { return null; diff --git a/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeDeclarationRector.php b/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeDeclarationRector.php index 8b444f9d867..59f3ce07c64 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeDeclarationRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeDeclarationRector.php @@ -19,13 +19,13 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\TypeComparator\TypeComparator; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector\AddParamTypeDeclarationRectorTest */ -final class AddParamTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class AddParamTypeDeclarationRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var AddParamTypeDeclaration[] @@ -45,14 +45,14 @@ final class AddParamTypeDeclarationRector extends \Rector\Core\Rector\AbstractRe * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\NodeTypeResolver\TypeComparator\TypeComparator $typeComparator, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(TypeComparator $typeComparator, PhpVersionProvider $phpVersionProvider) { $this->typeComparator = $typeComparator; $this->phpVersionProvider = $phpVersionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add param types where needed', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add param types where needed', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function process($name) @@ -68,25 +68,25 @@ class SomeClass } } CODE_SAMPLE -, [new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('SomeClass', 'process', 0, new \PHPStan\Type\StringType())])]); +, [new AddParamTypeDeclaration('SomeClass', 'process', 0, new StringType())])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } /** @var ClassLike $classLike */ - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassLike::class); + $classLike = $this->betterNodeFinder->findParentType($node, ClassLike::class); foreach ($this->addParamTypeDeclarations as $addParamTypeDeclaration) { if (!$this->isObjectType($classLike, $addParamTypeDeclaration->getObjectType())) { continue; @@ -106,25 +106,25 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration::class); + Assert::allIsAOf($configuration, AddParamTypeDeclaration::class); $this->addParamTypeDeclarations = $configuration; } - private function shouldSkip(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkip(ClassMethod $classMethod) : bool { // skip class methods without args if ($classMethod->params === []) { return \true; } - $classLike = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($classMethod, ClassLike::class); + if (!$classLike instanceof ClassLike) { return \true; } // skip traits - if ($classLike instanceof \PhpParser\Node\Stmt\Trait_) { + if ($classLike instanceof Trait_) { return \true; } // skip class without parents/interfaces - if ($classLike instanceof \PhpParser\Node\Stmt\Class_) { + if ($classLike instanceof Class_) { if ($classLike->implements !== []) { return \false; } @@ -134,15 +134,15 @@ CODE_SAMPLE /** @var Interface_ $classLike */ return !(bool) $classLike->extends; } - private function refactorClassMethodWithTypehintByParameterPosition(\PhpParser\Node\Stmt\ClassMethod $classMethod, \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration $addParamTypeDeclaration) : void + private function refactorClassMethodWithTypehintByParameterPosition(ClassMethod $classMethod, AddParamTypeDeclaration $addParamTypeDeclaration) : void { $parameter = $classMethod->params[$addParamTypeDeclaration->getPosition()] ?? null; - if (!$parameter instanceof \PhpParser\Node\Param) { + if (!$parameter instanceof Param) { return; } $this->refactorParameter($parameter, $addParamTypeDeclaration); } - private function refactorParameter(\PhpParser\Node\Param $param, \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration $addParamTypeDeclaration) : void + private function refactorParameter(Param $param, AddParamTypeDeclaration $addParamTypeDeclaration) : void { // already set → no change if ($param->type !== null) { @@ -151,11 +151,11 @@ CODE_SAMPLE return; } } - $paramTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($addParamTypeDeclaration->getParamType(), \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM); + $paramTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($addParamTypeDeclaration->getParamType(), TypeKind::PARAM); $this->hasChanged = \true; // remove it - if ($addParamTypeDeclaration->getParamType() instanceof \PHPStan\Type\MixedType) { - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::MIXED_TYPE)) { + if ($addParamTypeDeclaration->getParamType() instanceof MixedType) { + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::MIXED_TYPE)) { $param->type = $paramTypeNode; return; } diff --git a/rules/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationRector.php b/rules/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationRector.php index cb77fe13446..d59b1274602 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationRector.php @@ -15,13 +15,13 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\TypeComparator\TypeComparator; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector\AddReturnTypeDeclarationRectorTest */ -final class AddReturnTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class AddReturnTypeDeclarationRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var AddReturnTypeDeclaration[] @@ -41,15 +41,15 @@ final class AddReturnTypeDeclarationRector extends \Rector\Core\Rector\AbstractR * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\NodeTypeResolver\TypeComparator\TypeComparator $typeComparator, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(TypeComparator $typeComparator, PhpVersionProvider $phpVersionProvider) { $this->typeComparator = $typeComparator; $this->phpVersionProvider = $phpVersionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - $arrayType = new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes defined return typehint of method and class.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + $arrayType = new ArrayType(new MixedType(), new MixedType()); + return new RuleDefinition('Changes defined return typehint of method and class.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function getData() @@ -65,19 +65,19 @@ class SomeClass } } CODE_SAMPLE -, [new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('SomeClass', 'getData', $arrayType)])]); +, [new AddReturnTypeDeclaration('SomeClass', 'getData', $arrayType)])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->methodReturnTypes as $methodReturnType) { if (!$this->isObjectType($node, $methodReturnType->getObjectType())) { @@ -99,13 +99,13 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration::class); + Assert::allIsAOf($configuration, AddReturnTypeDeclaration::class); $this->methodReturnTypes = $configuration; } - private function processClassMethodNodeWithTypehints(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PHPStan\Type\Type $newType) : void + private function processClassMethodNodeWithTypehints(ClassMethod $classMethod, Type $newType) : void { // remove it - if ($newType instanceof \PHPStan\Type\MixedType && !$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::MIXED_TYPE)) { + if ($newType instanceof MixedType && !$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::MIXED_TYPE)) { $classMethod->returnType = null; return; } @@ -116,7 +116,7 @@ CODE_SAMPLE return; } } - $returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($newType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN); + $returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($newType, TypeKind::RETURN); $classMethod->returnType = $returnTypeNode; $this->hasChanged = \true; } diff --git a/rules/TypeDeclaration/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector.php b/rules/TypeDeclaration/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector.php index 810219d02cd..bc5603a81d1 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector.php @@ -19,13 +19,13 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\TypeDeclaration\TypeInferer\SilentVoidResolver; use Rector\VendorLocker\NodeVendorLocker\ClassMethodReturnVendorLockResolver; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector\AddVoidReturnTypeWhereNoReturnRectorTest */ -final class AddVoidReturnTypeWhereNoReturnRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface, \Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface +final class AddVoidReturnTypeWhereNoReturnRector extends AbstractRector implements MinPhpVersionInterface, AllowEmptyConfigurableRectorInterface { /** * @var string using phpdoc instead of a native void type can ease the migration path for consumers of code being processed. @@ -55,16 +55,16 @@ final class AddVoidReturnTypeWhereNoReturnRector extends \Rector\Core\Rector\Abs * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\TypeDeclaration\TypeInferer\SilentVoidResolver $silentVoidResolver, \Rector\VendorLocker\NodeVendorLocker\ClassMethodReturnVendorLockResolver $classMethodReturnVendorLockResolver, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(SilentVoidResolver $silentVoidResolver, ClassMethodReturnVendorLockResolver $classMethodReturnVendorLockResolver, PhpDocTypeChanger $phpDocTypeChanger, ReflectionResolver $reflectionResolver) { $this->silentVoidResolver = $silentVoidResolver; $this->classMethodReturnVendorLockResolver = $classMethodReturnVendorLockResolver; $this->phpDocTypeChanger = $phpDocTypeChanger; $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add return type void to function like without any return', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add return type void to function like without any return', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function getValues() @@ -91,12 +91,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\Closure::class]; + return [ClassMethod::class, Function_::class, Closure::class]; } /** * @param ClassMethod|Function_|Closure $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->returnType !== null) { return null; @@ -111,15 +111,15 @@ CODE_SAMPLE $this->changePhpDocToVoidIfNotNever($node); return $node; } - if ($node instanceof \PhpParser\Node\Stmt\ClassMethod && $this->classMethodReturnVendorLockResolver->isVendorLocked($node)) { + if ($node instanceof ClassMethod && $this->classMethodReturnVendorLockResolver->isVendorLocked($node)) { return null; } - $node->returnType = new \PhpParser\Node\Identifier('void'); + $node->returnType = new Identifier('void'); return $node; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::VOID_TYPE; + return PhpVersionFeature::VOID_TYPE; } /** * @param mixed[] $configuration @@ -127,7 +127,7 @@ CODE_SAMPLE public function configure(array $configuration) : void { $usePhpdoc = $configuration[self::USE_PHPDOC] ?? (bool) \current($configuration); - \RectorPrefix20220607\Webmozart\Assert\Assert::boolean($usePhpdoc); + Assert::boolean($usePhpdoc); $this->usePhpdoc = $usePhpdoc; } /** @@ -136,17 +136,17 @@ CODE_SAMPLE private function changePhpDocToVoidIfNotNever($node) : void { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); - if ($phpDocInfo->getReturnType() instanceof \PHPStan\Type\NeverType) { + if ($phpDocInfo->getReturnType() instanceof NeverType) { return; } - $this->phpDocTypeChanger->changeReturnType($phpDocInfo, new \PHPStan\Type\VoidType()); + $this->phpDocTypeChanger->changeReturnType($phpDocInfo, new VoidType()); } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $functionLike */ private function shouldSkipClassMethod($functionLike) : bool { - if (!$functionLike instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$functionLike instanceof ClassMethod) { return \false; } if ($functionLike->isMagic()) { @@ -160,10 +160,10 @@ CODE_SAMPLE } return \false; } - private function isInsideFinalClass(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function isInsideFinalClass(ClassMethod $classMethod) : bool { $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } return $classReflection->isFinal(); diff --git a/rules/TypeDeclaration/Rector/ClassMethod/ArrayShapeFromConstantArrayReturnRector.php b/rules/TypeDeclaration/Rector/ClassMethod/ArrayShapeFromConstantArrayReturnRector.php index c8283b80a47..c2a0224f80c 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/ArrayShapeFromConstantArrayReturnRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/ArrayShapeFromConstantArrayReturnRector.php @@ -19,12 +19,12 @@ use Rector\Core\Util\StringUtils; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use RectorPrefix20220607\Symplify\Astral\TypeAnalyzer\ClassMethodReturnTypeResolver; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\ArrayShapeFromConstantArrayReturnRector\ArrayShapeFromConstantArrayReturnRectorTest */ -final class ArrayShapeFromConstantArrayReturnRector extends \Rector\Core\Rector\AbstractRector +final class ArrayShapeFromConstantArrayReturnRector extends AbstractRector { /** * @see https://regex101.com/r/WvUD0m/2 @@ -41,14 +41,14 @@ final class ArrayShapeFromConstantArrayReturnRector extends \Rector\Core\Rector\ * @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger */ private $phpDocTypeChanger; - public function __construct(\RectorPrefix20220607\Symplify\Astral\TypeAnalyzer\ClassMethodReturnTypeResolver $classMethodReturnTypeResolver, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger) + public function __construct(ClassMethodReturnTypeResolver $classMethodReturnTypeResolver, PhpDocTypeChanger $phpDocTypeChanger) { $this->classMethodReturnTypeResolver = $classMethodReturnTypeResolver; $this->phpDocTypeChanger = $phpDocTypeChanger; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add array shape exact types based on constant keys of array', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add array shape exact types based on constant keys of array', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run(string $name) @@ -76,40 +76,40 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { /** @var Return_[] $returns */ - $returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($node, \PhpParser\Node\Stmt\Return_::class); + $returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($node, Return_::class); // exact one shape only if (\count($returns) !== 1) { return null; } $return = $returns[0]; - if (!$return->expr instanceof \PhpParser\Node\Expr) { + if (!$return->expr instanceof Expr) { return null; } $returnExprType = $this->getType($return->expr); - if (!$returnExprType instanceof \PHPStan\Type\Constant\ConstantArrayType) { + if (!$returnExprType instanceof ConstantArrayType) { return null; } if ($this->shouldSkip($returnExprType)) { return null; } - $returnType = $this->classMethodReturnTypeResolver->resolve($node, $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE)); - if ($returnType instanceof \PHPStan\Type\Constant\ConstantArrayType) { + $returnType = $this->classMethodReturnTypeResolver->resolve($node, $node->getAttribute(AttributeKey::SCOPE)); + if ($returnType instanceof ConstantArrayType) { return null; } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); - $returnExprTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($returnExprType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN); - if ($returnExprTypeNode instanceof \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode) { + $returnExprTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($returnExprType, TypeKind::RETURN); + if ($returnExprTypeNode instanceof GenericTypeNode) { return null; } - if ($returnExprTypeNode instanceof \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode) { + if ($returnExprTypeNode instanceof SpacingAwareArrayTypeNode) { return null; } $hasChanged = $this->phpDocTypeChanger->changeReturnType($phpDocInfo, $returnExprType); @@ -118,28 +118,28 @@ CODE_SAMPLE } return $node; } - private function shouldSkip(\PHPStan\Type\Constant\ConstantArrayType $constantArrayType) : bool + private function shouldSkip(ConstantArrayType $constantArrayType) : bool { $keyType = $constantArrayType->getKeyType(); // empty array - if ($keyType instanceof \PHPStan\Type\NeverType) { + if ($keyType instanceof NeverType) { return \true; } - $types = $keyType instanceof \PHPStan\Type\UnionType ? $keyType->getTypes() : [$keyType]; + $types = $keyType instanceof UnionType ? $keyType->getTypes() : [$keyType]; foreach ($types as $type) { - if (!$type instanceof \PHPStan\Type\Constant\ConstantStringType) { + if (!$type instanceof ConstantStringType) { continue; } $value = $type->getValue(); if (\trim($value) === '') { return \true; } - if (\Rector\Core\Util\StringUtils::isMatch($value, self::SKIPPED_CHAR_REGEX)) { + if (StringUtils::isMatch($value, self::SKIPPED_CHAR_REGEX)) { return \true; } } $itemType = $constantArrayType->getItemType(); - if ($itemType instanceof \PHPStan\Type\Constant\ConstantArrayType) { + if ($itemType instanceof ConstantArrayType) { return $this->shouldSkip($itemType); } return \false; diff --git a/rules/TypeDeclaration/Rector/ClassMethod/ParamAnnotationIncorrectNullableRector.php b/rules/TypeDeclaration/Rector/ClassMethod/ParamAnnotationIncorrectNullableRector.php index c19fd6cb248..07c9a714229 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/ParamAnnotationIncorrectNullableRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/ParamAnnotationIncorrectNullableRector.php @@ -18,12 +18,12 @@ use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\TypeDeclaration\Guard\PhpDocNestedAnnotationGuard; use Rector\TypeDeclaration\Helper\PhpDocNullableTypeHelper; use Rector\TypeDeclaration\PhpDocParser\ParamPhpDocNodeFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\ParamAnnotationIncorrectNullableRector\ParamAnnotationIncorrectNullableRectorTest */ -final class ParamAnnotationIncorrectNullableRector extends \Rector\Core\Rector\AbstractRector +final class ParamAnnotationIncorrectNullableRector extends AbstractRector { /** * @readonly @@ -50,7 +50,7 @@ final class ParamAnnotationIncorrectNullableRector extends \Rector\Core\Rector\A * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\NodeTypeResolver\TypeComparator\TypeComparator $typeComparator, \Rector\TypeDeclaration\Helper\PhpDocNullableTypeHelper $phpDocNullableTypeHelper, \Rector\TypeDeclaration\Guard\PhpDocNestedAnnotationGuard $phpDocNestedAnnotationGuard, \Rector\TypeDeclaration\PhpDocParser\ParamPhpDocNodeFactory $paramPhpDocNodeFactory, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(TypeComparator $typeComparator, PhpDocNullableTypeHelper $phpDocNullableTypeHelper, PhpDocNestedAnnotationGuard $phpDocNestedAnnotationGuard, ParamPhpDocNodeFactory $paramPhpDocNodeFactory, PhpVersionProvider $phpVersionProvider) { $this->typeComparator = $typeComparator; $this->phpDocNullableTypeHelper = $phpDocNullableTypeHelper; @@ -58,9 +58,9 @@ final class ParamAnnotationIncorrectNullableRector extends \Rector\Core\Rector\A $this->paramPhpDocNodeFactory = $paramPhpDocNodeFactory; $this->phpVersionProvider = $phpVersionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add or remove null type from @param phpdoc typehint based on php parameter type declaration', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add or remove null type from @param phpdoc typehint based on php parameter type declaration', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { /** @@ -95,17 +95,17 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class]; + return [ClassMethod::class, Function_::class]; } /** * @param ClassMethod|Function_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->getParams() === []) { return null; } - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::TYPED_PROPERTIES)) { return null; } if (!$this->phpDocNestedAnnotationGuard->isPhpDocCommentCorrectlyParsed($node)) { @@ -118,7 +118,7 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $node */ - private function matchParamByName(string $desiredParamName, $node) : ?\PhpParser\Node\Param + private function matchParamByName(string $desiredParamName, $node) : ?Param { foreach ($node->getParams() as $param) { $paramName = $this->nodeNameResolver->getName($param); @@ -129,13 +129,13 @@ CODE_SAMPLE } return null; } - private function wasUpdateOfParamTypeRequired(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PHPStan\Type\Type $newType, \PhpParser\Node\Param $param, string $paramName) : bool + private function wasUpdateOfParamTypeRequired(PhpDocInfo $phpDocInfo, Type $newType, Param $param, string $paramName) : bool { // better skip, could crash hard if ($phpDocInfo->hasInvalidTag('@param')) { return \false; } - $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM); + $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, TypeKind::PARAM); $paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramName); // override existing type if ($paramTagValueNode !== null) { @@ -155,7 +155,7 @@ CODE_SAMPLE * @return ClassMethod|Function_|null * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $node */ - private function updateParamTagsIfRequired(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, $node, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : ?\PhpParser\Node + private function updateParamTagsIfRequired(PhpDocNode $phpDocNode, $node, PhpDocInfo $phpDocInfo) : ?Node { $paramTagValueNodes = $phpDocNode->getParamTagValues(); $paramTagWasUpdated = \false; @@ -164,12 +164,12 @@ CODE_SAMPLE continue; } $param = $this->matchParamByName($paramTagValueNode->parameterName, $node); - if (!$param instanceof \PhpParser\Node\Param) { + if (!$param instanceof Param) { continue; } $docType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($paramTagValueNode->type, $node); $updatedPhpDocType = $this->phpDocNullableTypeHelper->resolveUpdatedPhpDocTypeFromPhpDocTypeAndParamNode($docType, $param); - if (!$updatedPhpDocType instanceof \PHPStan\Type\Type) { + if (!$updatedPhpDocType instanceof Type) { continue; } if ($this->wasUpdateOfParamTypeRequired($phpDocInfo, $updatedPhpDocType, $param, $paramTagValueNode->parameterName)) { diff --git a/rules/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector.php b/rules/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector.php index 5a1c5f139b1..82499e6eb45 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector.php @@ -24,12 +24,12 @@ use Rector\Core\Reflection\ReflectionResolver; use Rector\TypeDeclaration\NodeAnalyzer\CallerParamMatcher; use Rector\VendorLocker\ParentClassMethodTypeOverrideGuard; use RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\ParamTypeByMethodCallTypeRector\ParamTypeByMethodCallTypeRectorTest */ -final class ParamTypeByMethodCallTypeRector extends \Rector\Core\Rector\AbstractScopeAwareRector +final class ParamTypeByMethodCallTypeRector extends AbstractScopeAwareRector { /** * @readonly @@ -51,16 +51,16 @@ final class ParamTypeByMethodCallTypeRector extends \Rector\Core\Rector\Abstract * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\TypeDeclaration\NodeAnalyzer\CallerParamMatcher $callerParamMatcher, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\VendorLocker\ParentClassMethodTypeOverrideGuard $parentClassMethodTypeOverrideGuard, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(CallerParamMatcher $callerParamMatcher, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, ParentClassMethodTypeOverrideGuard $parentClassMethodTypeOverrideGuard, ReflectionResolver $reflectionResolver) { $this->callerParamMatcher = $callerParamMatcher; $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->parentClassMethodTypeOverrideGuard = $parentClassMethodTypeOverrideGuard; $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change param type based on passed method call type', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change param type based on passed method call type', [new CodeSample(<<<'CODE_SAMPLE' class SomeTypedService { public function run(string $name) @@ -109,18 +109,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactorWithScope(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : ?\PhpParser\Node + public function refactorWithScope(Node $node, Scope $scope) : ?Node { if ($this->shouldSkipClassMethod($node)) { return null; } /** @var array $callers */ - $callers = $this->betterNodeFinder->findInstancesOf((array) $node->stmts, [\PhpParser\Node\Expr\StaticCall::class, \PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\FuncCall::class]); + $callers = $this->betterNodeFinder->findInstancesOf((array) $node->stmts, [StaticCall::class, MethodCall::class, FuncCall::class]); $hasChanged = \false; foreach ($node->params as $param) { if ($this->shouldSkipParam($param, $node)) { @@ -140,7 +140,7 @@ CODE_SAMPLE } return null; } - private function shouldSkipClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkipClassMethod(ClassMethod $classMethod) : bool { if ($classMethod->params === []) { return \true; @@ -149,7 +149,7 @@ CODE_SAMPLE return \true; } $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \true; } return !$classReflection->isClass(); @@ -157,11 +157,11 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Identifier|\PhpParser\Node\Name|\PhpParser\Node\NullableType|\PhpParser\Node\UnionType|\PhpParser\Node\ComplexType $paramType */ - private function mirrorParamType(\PhpParser\Node\Param $decoratedParam, $paramType) : void + private function mirrorParamType(Param $decoratedParam, $paramType) : void { // mimic type $newParamType = $paramType; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($newParamType, function (\PhpParser\Node $node) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($newParamType, function (Node $node) { // original attributes have to removed to avoid tokens crashing from origin positions $node->setAttributes([]); return null; @@ -171,30 +171,30 @@ CODE_SAMPLE /** * Should skip param because one of them is conditional types? */ - private function isParamConditioned(\PhpParser\Node\Param $param, \PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function isParamConditioned(Param $param, ClassMethod $classMethod) : bool { $paramName = $this->nodeNameResolver->getName($param->var); if ($paramName === null) { return \false; } /** @var Variable[] $variables */ - $variables = $this->betterNodeFinder->findInstanceOf((array) $classMethod->stmts, \PhpParser\Node\Expr\Variable::class); + $variables = $this->betterNodeFinder->findInstanceOf((array) $classMethod->stmts, Variable::class); foreach ($variables as $variable) { if (!$this->isName($variable, $paramName)) { continue; } - $conditional = $this->betterNodeFinder->findParentType($variable, \PhpParser\Node\Stmt\If_::class); - if ($conditional instanceof \PhpParser\Node\Stmt\If_) { + $conditional = $this->betterNodeFinder->findParentType($variable, If_::class); + if ($conditional instanceof If_) { return \true; } - $conditional = $this->betterNodeFinder->findParentType($variable, \PhpParser\Node\Expr\Ternary::class); - if ($conditional instanceof \PhpParser\Node\Expr\Ternary) { + $conditional = $this->betterNodeFinder->findParentType($variable, Ternary::class); + if ($conditional instanceof Ternary) { return \true; } } return \false; } - private function shouldSkipParam(\PhpParser\Node\Param $param, \PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkipParam(Param $param, ClassMethod $classMethod) : bool { if ($this->isParamConditioned($param, $classMethod)) { return \true; diff --git a/rules/TypeDeclaration/Rector/ClassMethod/ParamTypeByParentCallTypeRector.php b/rules/TypeDeclaration/Rector/ClassMethod/ParamTypeByParentCallTypeRector.php index b20d746fb0d..df8fc0fc787 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/ParamTypeByParentCallTypeRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/ParamTypeByParentCallTypeRector.php @@ -14,12 +14,12 @@ use Rector\Core\Rector\AbstractScopeAwareRector; use Rector\Core\Reflection\ReflectionResolver; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\TypeDeclaration\NodeAnalyzer\CallerParamMatcher; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\ParamTypeByParentCallTypeRector\ParamTypeByParentCallTypeRectorTest */ -final class ParamTypeByParentCallTypeRector extends \Rector\Core\Rector\AbstractScopeAwareRector +final class ParamTypeByParentCallTypeRector extends AbstractScopeAwareRector { /** * @readonly @@ -31,14 +31,14 @@ final class ParamTypeByParentCallTypeRector extends \Rector\Core\Rector\Abstract * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\TypeDeclaration\NodeAnalyzer\CallerParamMatcher $callerParamMatcher, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(CallerParamMatcher $callerParamMatcher, ReflectionResolver $reflectionResolver) { $this->callerParamMatcher = $callerParamMatcher; $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change param type based on parent param type', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change param type based on parent param type', [new CodeSample(<<<'CODE_SAMPLE' class SomeControl { public function __construct(string $name) @@ -77,18 +77,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactorWithScope(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : ?\PhpParser\Node + public function refactorWithScope(Node $node, Scope $scope) : ?Node { if ($this->shouldSkip($node)) { return null; } $parentStaticCall = $this->findParentStaticCall($node); - if (!$parentStaticCall instanceof \PhpParser\Node\Expr\StaticCall) { + if (!$parentStaticCall instanceof StaticCall) { return null; } $hasChanged = \false; @@ -98,7 +98,7 @@ CODE_SAMPLE continue; } $parentParam = $this->callerParamMatcher->matchParentParam($parentStaticCall, $param, $scope); - if (!$parentParam instanceof \PhpParser\Node\Param) { + if (!$parentParam instanceof Param) { continue; } if ($parentParam->type === null) { @@ -107,8 +107,8 @@ CODE_SAMPLE // mimic type $paramType = $parentParam->type; // original attributes have to removed to avoid tokens crashing from origin positions - $this->traverseNodesWithCallable($paramType, function (\PhpParser\Node $node) { - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $this->traverseNodesWithCallable($paramType, function (Node $node) { + $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); return null; }); $param->type = $paramType; @@ -119,13 +119,13 @@ CODE_SAMPLE } return null; } - private function findParentStaticCall(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Expr\StaticCall + private function findParentStaticCall(ClassMethod $classMethod) : ?StaticCall { $classMethodName = $this->getName($classMethod); /** @var StaticCall[] $staticCalls */ - $staticCalls = $this->betterNodeFinder->findInstanceOf($classMethod, \PhpParser\Node\Expr\StaticCall::class); + $staticCalls = $this->betterNodeFinder->findInstanceOf($classMethod, StaticCall::class); foreach ($staticCalls as $staticCall) { - if (!$this->isName($staticCall->class, \Rector\Core\Enum\ObjectReference::PARENT)) { + if (!$this->isName($staticCall->class, ObjectReference::PARENT)) { continue; } if (!$this->isName($staticCall->name, $classMethodName)) { @@ -135,13 +135,13 @@ CODE_SAMPLE } return null; } - private function shouldSkip(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkip(ClassMethod $classMethod) : bool { if ($classMethod->params === []) { return \true; } $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \true; } return !$classReflection->isClass(); diff --git a/rules/TypeDeclaration/Rector/ClassMethod/ReturnAnnotationIncorrectNullableRector.php b/rules/TypeDeclaration/Rector/ClassMethod/ReturnAnnotationIncorrectNullableRector.php index af103498c59..5235bd4241a 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/ReturnAnnotationIncorrectNullableRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/ReturnAnnotationIncorrectNullableRector.php @@ -15,12 +15,12 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\TypeDeclaration\Guard\PhpDocNestedAnnotationGuard; use Rector\TypeDeclaration\Helper\PhpDocNullableTypeHelper; use Rector\VendorLocker\NodeVendorLocker\ClassMethodReturnTypeOverrideGuard; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnAnnotationIncorrectNullableRector\ReturnAnnotationIncorrectNullableRectorTest */ -final class ReturnAnnotationIncorrectNullableRector extends \Rector\Core\Rector\AbstractRector +final class ReturnAnnotationIncorrectNullableRector extends AbstractRector { /** * @readonly @@ -47,7 +47,7 @@ final class ReturnAnnotationIncorrectNullableRector extends \Rector\Core\Rector\ * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\TypeDeclaration\Helper\PhpDocNullableTypeHelper $phpDocNullableTypeHelper, \Rector\VendorLocker\NodeVendorLocker\ClassMethodReturnTypeOverrideGuard $classMethodReturnTypeOverrideGuard, \Rector\TypeDeclaration\Guard\PhpDocNestedAnnotationGuard $phpDocNestedAnnotationGuard, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PhpDocTypeChanger $phpDocTypeChanger, PhpDocNullableTypeHelper $phpDocNullableTypeHelper, ClassMethodReturnTypeOverrideGuard $classMethodReturnTypeOverrideGuard, PhpDocNestedAnnotationGuard $phpDocNestedAnnotationGuard, PhpVersionProvider $phpVersionProvider) { $this->phpDocTypeChanger = $phpDocTypeChanger; $this->phpDocNullableTypeHelper = $phpDocNullableTypeHelper; @@ -55,9 +55,9 @@ final class ReturnAnnotationIncorrectNullableRector extends \Rector\Core\Rector\ $this->phpDocNestedAnnotationGuard = $phpDocNestedAnnotationGuard; $this->phpVersionProvider = $phpVersionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add or remove null type from @return phpdoc typehint based on php return type declaration', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add or remove null type from @return phpdoc typehint based on php return type declaration', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { /** @@ -88,21 +88,21 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class]; + return [ClassMethod::class, Function_::class]; } /** * @param ClassMethod|Function_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $returnType = $node->getReturnType(); - if ($node instanceof \PhpParser\Node\Stmt\ClassMethod && $this->classMethodReturnTypeOverrideGuard->shouldSkipClassMethod($node)) { + if ($node instanceof ClassMethod && $this->classMethodReturnTypeOverrideGuard->shouldSkipClassMethod($node)) { return null; } if ($returnType === null) { return null; } - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::TYPED_PROPERTIES)) { return null; } if (!$this->phpDocNestedAnnotationGuard->isPhpDocCommentCorrectlyParsed($node)) { @@ -110,14 +110,14 @@ CODE_SAMPLE } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $returnTagValueNode = $phpDocInfo->getReturnTagValue(); - if (!$returnTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode) { + if (!$returnTagValueNode instanceof ReturnTagValueNode) { return null; } $phpStanDocTypeNode = $returnTagValueNode->type; $phpParserType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($returnType); $docType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($phpStanDocTypeNode, $node); $updatedPhpDocType = $this->phpDocNullableTypeHelper->resolveUpdatedPhpDocTypeFromPhpDocTypeAndPhpParserType($docType, $phpParserType); - if (!$updatedPhpDocType instanceof \PHPStan\Type\Type) { + if (!$updatedPhpDocType instanceof Type) { return null; } $this->phpDocTypeChanger->changeReturnType($phpDocInfo, $updatedPhpDocType); diff --git a/rules/TypeDeclaration/Rector/ClassMethod/ReturnNeverTypeRector.php b/rules/TypeDeclaration/Rector/ClassMethod/ReturnNeverTypeRector.php index a757c11f9df..46601815778 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/ReturnNeverTypeRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/ReturnNeverTypeRector.php @@ -20,14 +20,14 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeNestingScope\ValueObject\ControlStructure; use Rector\VendorLocker\ParentClassMethodTypeOverrideGuard; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/noreturn_type * * @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector\ReturnNeverTypeRectorTest */ -final class ReturnNeverTypeRector extends \Rector\Core\Rector\AbstractRector +final class ReturnNeverTypeRector extends AbstractRector { /** * @readonly @@ -44,15 +44,15 @@ final class ReturnNeverTypeRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\VendorLocker\ParentClassMethodTypeOverrideGuard $parentClassMethodTypeOverrideGuard, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(ParentClassMethodTypeOverrideGuard $parentClassMethodTypeOverrideGuard, PhpDocTypeChanger $phpDocTypeChanger, PhpVersionProvider $phpVersionProvider) { $this->parentClassMethodTypeOverrideGuard = $parentClassMethodTypeOverrideGuard; $this->phpDocTypeChanger = $phpDocTypeChanger; $this->phpVersionProvider = $phpVersionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add "never" return-type for methods that never return anything', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add "never" return-type for methods that never return anything', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run() @@ -80,23 +80,23 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\Closure::class]; + return [ClassMethod::class, Function_::class, Closure::class]; } /** * @param ClassMethod|Function_|Closure $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::NEVER_TYPE)) { + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::NEVER_TYPE)) { // never-type supported natively - $node->returnType = new \PhpParser\Node\Name('never'); + $node->returnType = new Name('never'); } else { // static anlysis based never type $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); - $hasChanged = $this->phpDocTypeChanger->changeReturnType($phpDocInfo, new \PHPStan\Type\NeverType()); + $hasChanged = $this->phpDocTypeChanger->changeReturnType($phpDocInfo, new NeverType()); if (!$hasChanged) { return null; } @@ -108,27 +108,27 @@ CODE_SAMPLE */ private function shouldSkip($node) : bool { - $hasReturn = $this->betterNodeFinder->hasInstancesOfInFunctionLikeScoped($node, \PhpParser\Node\Stmt\Return_::class); - if ($node instanceof \PhpParser\Node\Stmt\ClassMethod && $node->isMagic()) { + $hasReturn = $this->betterNodeFinder->hasInstancesOfInFunctionLikeScoped($node, Return_::class); + if ($node instanceof ClassMethod && $node->isMagic()) { return \true; } if ($hasReturn) { return \true; } - $yieldAndConditionalNodes = \array_merge([\PhpParser\Node\Expr\Yield_::class], \Rector\NodeNestingScope\ValueObject\ControlStructure::CONDITIONAL_NODE_SCOPE_TYPES); + $yieldAndConditionalNodes = \array_merge([Yield_::class], ControlStructure::CONDITIONAL_NODE_SCOPE_TYPES); $hasNotNeverNodes = $this->betterNodeFinder->hasInstancesOfInFunctionLikeScoped($node, $yieldAndConditionalNodes); if ($hasNotNeverNodes) { return \true; } - $hasNeverNodes = $this->betterNodeFinder->hasInstancesOfInFunctionLikeScoped($node, [\PhpParser\Node\Stmt\Throw_::class]); + $hasNeverNodes = $this->betterNodeFinder->hasInstancesOfInFunctionLikeScoped($node, [Throw_::class]); $hasNeverFuncCall = $this->hasNeverFuncCall($node); if (!$hasNeverNodes && !$hasNeverFuncCall) { return \true; } - if ($node instanceof \PhpParser\Node\Stmt\ClassMethod && !$this->parentClassMethodTypeOverrideGuard->isReturnTypeChangeAllowed($node)) { + if ($node instanceof ClassMethod && !$this->parentClassMethodTypeOverrideGuard->isReturnTypeChangeAllowed($node)) { return \true; } - if (!$node->returnType instanceof \PhpParser\Node) { + if (!$node->returnType instanceof Node) { return \false; } return $this->isName($node->returnType, 'never'); @@ -140,14 +140,14 @@ CODE_SAMPLE { $hasNeverType = \false; foreach ((array) $functionLike->stmts as $stmt) { - if ($stmt instanceof \PhpParser\Node\Stmt\Expression) { + if ($stmt instanceof Expression) { $stmt = $stmt->expr; } - if ($stmt instanceof \PhpParser\Node\Stmt) { + if ($stmt instanceof Stmt) { continue; } $stmtType = $this->getType($stmt); - if ($stmtType instanceof \PHPStan\Type\NeverType) { + if ($stmtType instanceof NeverType) { $hasNeverType = \true; } } diff --git a/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromReturnNewRector.php b/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromReturnNewRector.php index a36a31f8ec8..02b9c660e4d 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromReturnNewRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromReturnNewRector.php @@ -24,12 +24,12 @@ use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\StaticTypeMapper\ValueObject\Type\SelfStaticType; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector\ReturnTypeFromReturnNewRectorTest */ -final class ReturnTypeFromReturnNewRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ReturnTypeFromReturnNewRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -46,15 +46,15 @@ final class ReturnTypeFromReturnNewRector extends \Rector\Core\Rector\AbstractRe * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(TypeFactory $typeFactory, ReflectionProvider $reflectionProvider, ReflectionResolver $reflectionResolver) { $this->typeFactory = $typeFactory; $this->reflectionProvider = $reflectionProvider; $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add return type to function like with return new', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add return type to function like with return new', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function action() @@ -79,65 +79,65 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\Closure::class, \PhpParser\Node\Expr\ArrowFunction::class]; + return [ClassMethod::class, Function_::class, Closure::class, ArrowFunction::class]; } /** * @param ClassMethod|Function_|ArrowFunction $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->returnType !== null) { return null; } - if ($node instanceof \PhpParser\Node\Expr\ArrowFunction) { - $returns = [new \PhpParser\Node\Stmt\Return_($node->expr)]; + if ($node instanceof ArrowFunction) { + $returns = [new Return_($node->expr)]; } else { /** @var Return_[] $returns */ - $returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($node, \PhpParser\Node\Stmt\Return_::class); + $returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($node, Return_::class); } if ($returns === []) { return null; } $newTypes = []; foreach ($returns as $return) { - if (!$return->expr instanceof \PhpParser\Node\Expr\New_) { + if (!$return->expr instanceof New_) { return null; } $new = $return->expr; - if (!$new->class instanceof \PhpParser\Node\Name) { + if (!$new->class instanceof Name) { return null; } $newTypes[] = $this->createObjectTypeFromNew($new); } $returnType = $this->typeFactory->createMixedPassedOrUnionType($newTypes); - $returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($returnType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN); + $returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($returnType, TypeKind::RETURN); $node->returnType = $returnTypeNode; return $node; } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::SCALAR_TYPES; + return PhpVersionFeature::SCALAR_TYPES; } /** * @return \PHPStan\Type\ObjectType|\PHPStan\Type\StaticType */ - private function createObjectTypeFromNew(\PhpParser\Node\Expr\New_ $new) + private function createObjectTypeFromNew(New_ $new) { $className = $this->getName($new->class); if ($className === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } - if ($className === \Rector\Core\Enum\ObjectReference::STATIC || $className === \Rector\Core\Enum\ObjectReference::SELF) { + if ($className === ObjectReference::STATIC || $className === ObjectReference::SELF) { $classReflection = $this->reflectionResolver->resolveClassReflection($new); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$classReflection instanceof ClassReflection) { + throw new ShouldNotHappenException(); } - if ($className === \Rector\Core\Enum\ObjectReference::SELF) { - return new \Rector\StaticTypeMapper\ValueObject\Type\SelfStaticType($classReflection); + if ($className === ObjectReference::SELF) { + return new SelfStaticType($classReflection); } - return new \PHPStan\Type\StaticType($classReflection); + return new StaticType($classReflection); } $classReflection = $this->reflectionProvider->getClass($className); - return new \PHPStan\Type\ObjectType($className, null, $classReflection); + return new ObjectType($className, null, $classReflection); } } diff --git a/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector.php b/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector.php index 7cfd4abc5bd..6acb47bc03c 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector.php @@ -26,12 +26,12 @@ use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\TypeDeclaration\NodeAnalyzer\ReturnStrictTypeAnalyzer; use Rector\TypeDeclaration\NodeAnalyzer\TypeNodeUnwrapper; use Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\ReturnTypeFromStrictTypedCallRectorTest */ -final class ReturnTypeFromStrictTypedCallRector extends \Rector\Core\Rector\AbstractRector +final class ReturnTypeFromStrictTypedCallRector extends AbstractRector { /** * @readonly @@ -53,16 +53,16 @@ final class ReturnTypeFromStrictTypedCallRector extends \Rector\Core\Rector\Abst * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\TypeDeclaration\NodeAnalyzer\TypeNodeUnwrapper $typeNodeUnwrapper, \Rector\TypeDeclaration\NodeAnalyzer\ReturnStrictTypeAnalyzer $returnStrictTypeAnalyzer, \Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer $returnTypeInferer, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(TypeNodeUnwrapper $typeNodeUnwrapper, ReturnStrictTypeAnalyzer $returnStrictTypeAnalyzer, ReturnTypeInferer $returnTypeInferer, PhpVersionProvider $phpVersionProvider) { $this->typeNodeUnwrapper = $typeNodeUnwrapper; $this->returnStrictTypeAnalyzer = $returnStrictTypeAnalyzer; $this->returnTypeInferer = $returnTypeInferer; $this->phpVersionProvider = $phpVersionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add return type from strict return type of call', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add return type from strict return type of call', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function getData() @@ -97,34 +97,34 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\Closure::class, \PhpParser\Node\Expr\ArrowFunction::class]; + return [ClassMethod::class, Function_::class, Closure::class, ArrowFunction::class]; } /** * @param ClassMethod|Function_|Closure|ArrowFunction $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->isSkipped($node)) { return null; } - if ($node instanceof \PhpParser\Node\Expr\ArrowFunction) { + if ($node instanceof ArrowFunction) { return $this->processArrowFunction($node); } /** @var Return_[] $returns */ - $returns = $this->betterNodeFinder->find((array) $node->stmts, function (\PhpParser\Node $subNode) use($node) : bool { - $currentFunctionLike = $this->betterNodeFinder->findParentType($subNode, \PhpParser\Node\FunctionLike::class); + $returns = $this->betterNodeFinder->find((array) $node->stmts, function (Node $subNode) use($node) : bool { + $currentFunctionLike = $this->betterNodeFinder->findParentType($subNode, FunctionLike::class); if ($currentFunctionLike === $node) { - return $subNode instanceof \PhpParser\Node\Stmt\Return_; + return $subNode instanceof Return_; } - $currentReturn = $this->betterNodeFinder->findParentType($subNode, \PhpParser\Node\Stmt\Return_::class); - if (!$currentReturn instanceof \PhpParser\Node\Stmt\Return_) { + $currentReturn = $this->betterNodeFinder->findParentType($subNode, Return_::class); + if (!$currentReturn instanceof Return_) { return \false; } - $currentFunctionLike = $this->betterNodeFinder->findParentType($currentReturn, \PhpParser\Node\FunctionLike::class); + $currentFunctionLike = $this->betterNodeFinder->findParentType($currentReturn, FunctionLike::class); if ($currentFunctionLike !== $node) { return \false; } - return $subNode instanceof \PhpParser\Node\Stmt\Return_; + return $subNode instanceof Return_; }); $returnedStrictTypes = $this->returnStrictTypeAnalyzer->collectStrictReturnTypes($returns); if ($returnedStrictTypes === []) { @@ -133,24 +133,24 @@ CODE_SAMPLE if (\count($returnedStrictTypes) === 1) { return $this->refactorSingleReturnType($returns[0], $returnedStrictTypes[0], $node); } - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::UNION_TYPES)) { + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::UNION_TYPES)) { /** @var PhpParserUnionType[] $returnedStrictTypes */ $unwrappedTypes = $this->typeNodeUnwrapper->unwrapNullableUnionTypes($returnedStrictTypes); - $returnType = new \PhpParser\Node\UnionType($unwrappedTypes); + $returnType = new PhpParserUnionType($unwrappedTypes); $node->returnType = $returnType; return $node; } return null; } - private function processArrowFunction(\PhpParser\Node\Expr\ArrowFunction $arrowFunction) : ?\PhpParser\Node\Expr\ArrowFunction + private function processArrowFunction(ArrowFunction $arrowFunction) : ?ArrowFunction { $resolvedType = $this->nodeTypeResolver->getType($arrowFunction->expr); // void type is not accepted for arrow functions - https://www.php.net/manual/en/functions.arrow.php#125673 - if ($resolvedType instanceof \PHPStan\Type\VoidType) { + if ($resolvedType instanceof VoidType) { return null; } - $returnType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($resolvedType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN); - if (!$returnType instanceof \PhpParser\Node) { + $returnType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($resolvedType, TypeKind::RETURN); + if (!$returnType instanceof Node) { return null; } $arrowFunction->returnType = $returnType; @@ -162,9 +162,9 @@ CODE_SAMPLE private function isUnionPossibleReturnsVoid($node) : bool { $inferReturnType = $this->returnTypeInferer->inferFunctionLike($node); - if ($inferReturnType instanceof \PHPStan\Type\UnionType) { + if ($inferReturnType instanceof UnionType) { foreach ($inferReturnType->getTypes() as $type) { - if ($type instanceof \PHPStan\Type\VoidType) { + if ($type instanceof VoidType) { return \true; } } @@ -175,10 +175,10 @@ CODE_SAMPLE * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $node * @return \PhpParser\Node\Expr\Closure|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ */ - private function processSingleUnionType($node, \PHPStan\Type\UnionType $unionType, \PhpParser\Node\NullableType $nullableType) + private function processSingleUnionType($node, UnionType $unionType, NullableType $nullableType) { $types = $unionType->getTypes(); - $returnType = $types[0] instanceof \PHPStan\Type\ObjectType && $types[1] instanceof \PHPStan\Type\NullType ? new \PhpParser\Node\NullableType(new \PhpParser\Node\Name\FullyQualified($types[0]->getClassName())) : $nullableType; + $returnType = $types[0] instanceof ObjectType && $types[1] instanceof NullType ? new NullableType(new FullyQualified($types[0]->getClassName())) : $nullableType; $node->returnType = $returnType; return $node; } @@ -187,16 +187,16 @@ CODE_SAMPLE */ private function isSkipped($node) : bool { - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::SCALAR_TYPES)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::SCALAR_TYPES)) { return \true; } - if ($node instanceof \PhpParser\Node\Expr\ArrowFunction) { + if ($node instanceof ArrowFunction) { return $node->returnType !== null; } if ($node->returnType !== null) { return \true; } - if (!$node instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$node instanceof ClassMethod) { return $this->isUnionPossibleReturnsVoid($node); } if (!$node->isMagic()) { @@ -209,17 +209,17 @@ CODE_SAMPLE * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $functionLike * @return \PhpParser\Node\Expr\Closure|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ */ - private function refactorSingleReturnType(\PhpParser\Node\Stmt\Return_ $return, $returnedStrictTypeNode, $functionLike) + private function refactorSingleReturnType(Return_ $return, $returnedStrictTypeNode, $functionLike) { $resolvedType = $this->nodeTypeResolver->getType($return); - if ($resolvedType instanceof \PHPStan\Type\UnionType) { - if (!$returnedStrictTypeNode instanceof \PhpParser\Node\NullableType) { + if ($resolvedType instanceof UnionType) { + if (!$returnedStrictTypeNode instanceof NullableType) { return $functionLike; } return $this->processSingleUnionType($functionLike, $resolvedType, $returnedStrictTypeNode); } /** @var Name $returnType */ - $returnType = $resolvedType instanceof \PHPStan\Type\ObjectType ? new \PhpParser\Node\Name\FullyQualified($resolvedType->getClassName()) : $returnedStrictTypeNode; + $returnType = $resolvedType instanceof ObjectType ? new FullyQualified($resolvedType->getClassName()) : $returnedStrictTypeNode; $functionLike->returnType = $returnType; return $functionLike; } diff --git a/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedPropertyRector.php b/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedPropertyRector.php index 77ddd583aa7..3901e88eb81 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedPropertyRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedPropertyRector.php @@ -16,12 +16,12 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector\ReturnTypeFromStrictTypedPropertyRectorTest */ -final class ReturnTypeFromStrictTypedPropertyRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ReturnTypeFromStrictTypedPropertyRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -33,14 +33,14 @@ final class ReturnTypeFromStrictTypedPropertyRector extends \Rector\Core\Rector\ * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(TypeFactory $typeFactory, ReflectionResolver $reflectionResolver) { $this->typeFactory = $typeFactory; $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add return method return type based on strict typed property', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add return method return type based on strict typed property', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { private int $age = 100; @@ -69,12 +69,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->returnType !== null) { return null; @@ -85,11 +85,11 @@ CODE_SAMPLE } // add type to return type $propertyType = $this->typeFactory->createMixedPassedOrUnionType($propertyTypes); - if ($propertyType instanceof \PHPStan\Type\MixedType) { + if ($propertyType instanceof MixedType) { return null; } - $propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN); - if (!$propertyTypeNode instanceof \PhpParser\Node) { + $propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, TypeKind::RETURN); + if (!$propertyTypeNode instanceof Node) { return null; } $node->returnType = $propertyTypeNode; @@ -97,29 +97,29 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES; + return PhpVersionFeature::TYPED_PROPERTIES; } /** * @return Type[] */ - private function resolveReturnPropertyType(\PhpParser\Node\Stmt\ClassMethod $classMethod) : array + private function resolveReturnPropertyType(ClassMethod $classMethod) : array { /** @var Return_[] $returns */ - $returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($classMethod, \PhpParser\Node\Stmt\Return_::class); + $returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($classMethod, Return_::class); $propertyTypes = []; foreach ($returns as $return) { if ($return->expr === null) { return []; } - if (!$return->expr instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$return->expr instanceof PropertyFetch) { return []; } $phpPropertyReflection = $this->reflectionResolver->resolvePropertyReflectionFromPropertyFetch($return->expr); - if (!$phpPropertyReflection instanceof \PHPStan\Reflection\Php\PhpPropertyReflection) { + if (!$phpPropertyReflection instanceof PhpPropertyReflection) { return []; } // all property must have type declaration - if ($phpPropertyReflection->getNativeType() instanceof \PHPStan\Type\MixedType) { + if ($phpPropertyReflection->getNativeType() instanceof MixedType) { return []; } $propertyTypes[] = $phpPropertyReflection->getNativeType(); diff --git a/rules/TypeDeclaration/Rector/Closure/AddClosureReturnTypeRector.php b/rules/TypeDeclaration/Rector/Closure/AddClosureReturnTypeRector.php index 9300071aaf5..bad638d0831 100644 --- a/rules/TypeDeclaration/Rector/Closure/AddClosureReturnTypeRector.php +++ b/rules/TypeDeclaration/Rector/Closure/AddClosureReturnTypeRector.php @@ -11,25 +11,25 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector\AddClosureReturnTypeRectorTest */ -final class AddClosureReturnTypeRector extends \Rector\Core\Rector\AbstractScopeAwareRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class AddClosureReturnTypeRector extends AbstractScopeAwareRector implements MinPhpVersionInterface { /** * @readonly * @var \Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer */ private $returnTypeInferer; - public function __construct(\Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer $returnTypeInferer) + public function __construct(ReturnTypeInferer $returnTypeInferer) { $this->returnTypeInferer = $returnTypeInferer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add known return type to functions', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add known return type to functions', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run($meetups) @@ -58,18 +58,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Closure::class]; + return [Closure::class]; } /** * @param Closure $node */ - public function refactorWithScope(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : ?\PhpParser\Node + public function refactorWithScope(Node $node, Scope $scope) : ?Node { if ($node->returnType !== null) { return null; } $inferedReturnType = $this->returnTypeInferer->inferFunctionLike($node); - $returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($inferedReturnType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN); + $returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($inferedReturnType, TypeKind::RETURN); if ($returnTypeNode === null) { return null; } @@ -78,6 +78,6 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::SCALAR_TYPES; + return PhpVersionFeature::SCALAR_TYPES; } } diff --git a/rules/TypeDeclaration/Rector/FunctionLike/ParamTypeDeclarationRector.php b/rules/TypeDeclaration/Rector/FunctionLike/ParamTypeDeclarationRector.php index cca362c1cec..2661316fea1 100644 --- a/rules/TypeDeclaration/Rector/FunctionLike/ParamTypeDeclarationRector.php +++ b/rules/TypeDeclaration/Rector/FunctionLike/ParamTypeDeclarationRector.php @@ -24,8 +24,8 @@ use Rector\TypeDeclaration\TypeInferer\ParamTypeInferer; use Rector\VendorLocker\ParentClassMethodTypeOverrideGuard; use Rector\VendorLocker\VendorLockResolver; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/scalar_type_hints_v5 * @changelog https://github.com/nikic/TypeUtil @@ -36,7 +36,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @deprecated Use specific rules to infer params instead. This rule will be split info many small ones. */ -final class ParamTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ParamTypeDeclarationRector extends AbstractRector implements MinPhpVersionInterface { /** * @var bool @@ -72,7 +72,7 @@ final class ParamTypeDeclarationRector extends \Rector\Core\Rector\AbstractRecto * @var \Rector\TypeDeclaration\NodeAnalyzer\ControllerRenderMethodAnalyzer */ private $controllerRenderMethodAnalyzer; - public function __construct(\Rector\VendorLocker\VendorLockResolver $vendorLockResolver, \Rector\TypeDeclaration\TypeInferer\ParamTypeInferer $paramTypeInferer, \Rector\TypeDeclaration\NodeTypeAnalyzer\TraitTypeAnalyzer $traitTypeAnalyzer, \Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover $paramTagRemover, \Rector\VendorLocker\ParentClassMethodTypeOverrideGuard $parentClassMethodTypeOverrideGuard, \Rector\TypeDeclaration\NodeAnalyzer\ControllerRenderMethodAnalyzer $controllerRenderMethodAnalyzer) + public function __construct(VendorLockResolver $vendorLockResolver, ParamTypeInferer $paramTypeInferer, TraitTypeAnalyzer $traitTypeAnalyzer, ParamTagRemover $paramTagRemover, ParentClassMethodTypeOverrideGuard $parentClassMethodTypeOverrideGuard, ControllerRenderMethodAnalyzer $controllerRenderMethodAnalyzer) { $this->vendorLockResolver = $vendorLockResolver; $this->paramTypeInferer = $paramTypeInferer; @@ -87,11 +87,11 @@ final class ParamTypeDeclarationRector extends \Rector\Core\Rector\AbstractRecto public function getNodeTypes() : array { // why not on Param node? because class like docblock is edited too for @param tags - return [\PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Stmt\ClassMethod::class]; + return [Function_::class, ClassMethod::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change @param types to type declarations if not a BC-break', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change @param types to type declarations if not a BC-break', [new CodeSample(<<<'CODE_SAMPLE' abstract class VendorParentClass { /** @@ -149,13 +149,13 @@ CODE_SAMPLE /** * @param ClassMethod|Function_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $this->hasChanged = \false; if ($node->params === []) { return null; } - if ($node instanceof \PhpParser\Node\Stmt\ClassMethod && $this->controllerRenderMethodAnalyzer->isRenderMethod($node)) { + if ($node instanceof ClassMethod && $this->controllerRenderMethodAnalyzer->isRenderMethod($node)) { return null; } foreach ($node->params as $position => $param) { @@ -168,39 +168,39 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::SCALAR_TYPES; + return PhpVersionFeature::SCALAR_TYPES; } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike */ - private function refactorParam(\PhpParser\Node\Param $param, int $position, $functionLike) : void + private function refactorParam(Param $param, int $position, $functionLike) : void { if ($this->shouldSkipParam($param, $functionLike)) { return; } $inferedType = $this->paramTypeInferer->inferParam($param); - if ($inferedType instanceof \PHPStan\Type\MixedType) { + if ($inferedType instanceof MixedType) { return; } // mixed type cannot be part of union - if ($inferedType instanceof \PHPStan\Type\UnionType && $inferedType->isSuperTypeOf(new \PHPStan\Type\MixedType())->yes()) { + if ($inferedType instanceof UnionType && $inferedType->isSuperTypeOf(new MixedType())->yes()) { return; } - if ($inferedType instanceof \Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType) { + if ($inferedType instanceof NonExistingObjectType) { return; } if ($this->traitTypeAnalyzer->isTraitType($inferedType)) { return; } - $paramTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($inferedType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM); - if (!$paramTypeNode instanceof \PhpParser\Node) { + $paramTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($inferedType, TypeKind::PARAM); + if (!$paramTypeNode instanceof Node) { return; } - $parentNode = $functionLike->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentNode instanceof \PhpParser\Node\Stmt\Interface_ && $parentNode->extends !== []) { + $parentNode = $functionLike->getAttribute(AttributeKey::PARENT_NODE); + if ($parentNode instanceof Interface_ && $parentNode->extends !== []) { return; } - if ($functionLike instanceof \PhpParser\Node\Stmt\ClassMethod && $this->parentClassMethodTypeOverrideGuard->hasParentClassMethodDifferentType($functionLike, $position, $inferedType)) { + if ($functionLike instanceof ClassMethod && $this->parentClassMethodTypeOverrideGuard->hasParentClassMethodDifferentType($functionLike, $position, $inferedType)) { return; } $param->type = $paramTypeNode; @@ -211,7 +211,7 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike */ - private function shouldSkipParam(\PhpParser\Node\Param $param, $functionLike) : bool + private function shouldSkipParam(Param $param, $functionLike) : bool { if ($param->variadic) { return \true; @@ -221,8 +221,8 @@ CODE_SAMPLE } // is nette return type? $returnType = $functionLike->returnType; - if ($returnType instanceof \PhpParser\Node\Name\FullyQualified) { - $objectType = new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Control'); + if ($returnType instanceof FullyQualified) { + $objectType = new ObjectType('Nette\\Application\\UI\\Control'); $returnObjectType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($returnType); if ($objectType->isSuperTypeOf($returnObjectType)->yes()) { return \true; diff --git a/rules/TypeDeclaration/Rector/FunctionLike/ReturnTypeDeclarationRector.php b/rules/TypeDeclaration/Rector/FunctionLike/ReturnTypeDeclarationRector.php index 13b4f82f224..aa53ee316d1 100644 --- a/rules/TypeDeclaration/Rector/FunctionLike/ReturnTypeDeclarationRector.php +++ b/rules/TypeDeclaration/Rector/FunctionLike/ReturnTypeDeclarationRector.php @@ -29,14 +29,14 @@ use Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer\ReturnTypeDeclarationRe use Rector\VendorLocker\NodeVendorLocker\ClassMethodReturnTypeOverrideGuard; use Rector\VendorLocker\VendorLockResolver; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://wiki.php.net/rfc/scalar_type_hints_v5 * * @see \Rector\Tests\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector\ReturnTypeDeclarationRectorTest */ -final class ReturnTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ReturnTypeDeclarationRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -78,7 +78,7 @@ final class ReturnTypeDeclarationRector extends \Rector\Core\Rector\AbstractRect * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer $returnTypeInferer, \Rector\TypeDeclaration\TypeAlreadyAddedChecker\ReturnTypeAlreadyAddedChecker $returnTypeAlreadyAddedChecker, \Rector\TypeDeclaration\PhpDocParser\NonInformativeReturnTagRemover $nonInformativeReturnTagRemover, \Rector\VendorLocker\NodeVendorLocker\ClassMethodReturnTypeOverrideGuard $classMethodReturnTypeOverrideGuard, \Rector\VendorLocker\VendorLockResolver $vendorLockResolver, \Rector\TypeDeclaration\PhpParserTypeAnalyzer $phpParserTypeAnalyzer, \Rector\TypeDeclaration\TypeAnalyzer\ObjectTypeComparator $objectTypeComparator, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(ReturnTypeInferer $returnTypeInferer, ReturnTypeAlreadyAddedChecker $returnTypeAlreadyAddedChecker, NonInformativeReturnTagRemover $nonInformativeReturnTagRemover, ClassMethodReturnTypeOverrideGuard $classMethodReturnTypeOverrideGuard, VendorLockResolver $vendorLockResolver, PhpParserTypeAnalyzer $phpParserTypeAnalyzer, ObjectTypeComparator $objectTypeComparator, PhpVersionProvider $phpVersionProvider) { $this->returnTypeInferer = $returnTypeInferer; $this->returnTypeAlreadyAddedChecker = $returnTypeAlreadyAddedChecker; @@ -94,11 +94,11 @@ final class ReturnTypeDeclarationRector extends \Rector\Core\Rector\AbstractRect */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Stmt\ClassMethod::class]; + return [Function_::class, ClassMethod::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change @return types and type from static analysis to type declarations if not a BC-break', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change @return types and type from static analysis to type declarations if not a BC-break', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { /** @@ -122,27 +122,27 @@ CODE_SAMPLE /** * @param ClassMethod|Function_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkipClassLike($node)) { return null; } - if ($node instanceof \PhpParser\Node\Stmt\ClassMethod && $this->shouldSkipClassMethod($node)) { + if ($node instanceof ClassMethod && $this->shouldSkipClassMethod($node)) { return null; } - $inferedReturnType = $this->returnTypeInferer->inferFunctionLikeWithExcludedInferers($node, [\Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer\ReturnTypeDeclarationReturnTypeInfererTypeInferer::class]); - if ($inferedReturnType instanceof \PHPStan\Type\MixedType) { + $inferedReturnType = $this->returnTypeInferer->inferFunctionLikeWithExcludedInferers($node, [ReturnTypeDeclarationReturnTypeInfererTypeInferer::class]); + if ($inferedReturnType instanceof MixedType) { return null; } if ($this->returnTypeAlreadyAddedChecker->isSameOrBetterReturnTypeAlreadyAdded($node, $inferedReturnType)) { return null; } - if (!$inferedReturnType instanceof \PHPStan\Type\UnionType) { + if (!$inferedReturnType instanceof UnionType) { return $this->processType($node, $inferedReturnType); } foreach ($inferedReturnType->getTypes() as $unionedType) { // mixed type cannot be joined with another types - if ($unionedType instanceof \PHPStan\Type\MixedType) { + if ($unionedType instanceof MixedType) { return null; } } @@ -150,16 +150,16 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::SCALAR_TYPES; + return PhpVersionFeature::SCALAR_TYPES; } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $node */ - private function processType($node, \PHPStan\Type\Type $inferedType) : ?\PhpParser\Node + private function processType($node, Type $inferedType) : ?Node { - $inferredReturnNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($inferedType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN); + $inferredReturnNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($inferedType, TypeKind::RETURN); // nothing to change in PHP code - if (!$inferredReturnNode instanceof \PhpParser\Node) { + if (!$inferredReturnNode instanceof Node) { return null; } if ($this->shouldSkipInferredReturnNode($node)) { @@ -174,7 +174,7 @@ CODE_SAMPLE $this->nonInformativeReturnTagRemover->removeReturnTagIfNotUseful($node); return $node; } - private function shouldSkipClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkipClassMethod(ClassMethod $classMethod) : bool { if ($this->classMethodReturnTypeOverrideGuard->shouldSkipClassMethod($classMethod)) { return \true; @@ -190,17 +190,17 @@ CODE_SAMPLE if ($functionLike->returnType === null) { return \false; } - return (bool) $functionLike->returnType->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::DO_NOT_CHANGE); + return (bool) $functionLike->returnType->getAttribute(AttributeKey::DO_NOT_CHANGE); } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike */ - private function shouldSkipExistingReturnType($functionLike, \PHPStan\Type\Type $inferedType) : bool + private function shouldSkipExistingReturnType($functionLike, Type $inferedType) : bool { if ($functionLike->returnType === null) { return \false; } - if ($functionLike instanceof \PhpParser\Node\Stmt\ClassMethod && $this->vendorLockResolver->isReturnChangeVendorLockedIn($functionLike)) { + if ($functionLike instanceof ClassMethod && $this->vendorLockResolver->isReturnChangeVendorLockedIn($functionLike)) { return \true; } $currentType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($functionLike->returnType); @@ -220,7 +220,7 @@ CODE_SAMPLE return; } $isSubtype = $this->phpParserTypeAnalyzer->isCovariantSubtypeOf($inferredReturnNode, $functionLike->returnType); - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::COVARIANT_RETURN) && $isSubtype) { + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::COVARIANT_RETURN) && $isSubtype) { $functionLike->returnType = $inferredReturnNode; return; } @@ -229,12 +229,12 @@ CODE_SAMPLE $functionLike->returnType = $inferredReturnNode; } } - private function isNullableTypeSubType(\PHPStan\Type\Type $currentType, \PHPStan\Type\Type $inferedType) : bool + private function isNullableTypeSubType(Type $currentType, Type $inferedType) : bool { - if (!$currentType instanceof \PHPStan\Type\UnionType) { + if (!$currentType instanceof UnionType) { return \false; } - if (!$inferedType instanceof \PHPStan\Type\UnionType) { + if (!$inferedType instanceof UnionType) { return \false; } // probably more/less strict union type on purpose @@ -243,12 +243,12 @@ CODE_SAMPLE } return $inferedType->isSubTypeOf($currentType)->yes(); } - private function shouldSkipClassLike(\PhpParser\Node\FunctionLike $functionLike) : bool + private function shouldSkipClassLike(FunctionLike $functionLike) : bool { - if (!$functionLike instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$functionLike instanceof ClassMethod) { return \false; } - $classLike = $this->betterNodeFinder->findParentType($functionLike, \PhpParser\Node\Stmt\Class_::class); - return !$classLike instanceof \PhpParser\Node\Stmt\Class_; + $classLike = $this->betterNodeFinder->findParentType($functionLike, Class_::class); + return !$classLike instanceof Class_; } } diff --git a/rules/TypeDeclaration/Rector/MethodCall/FormerNullableArgumentToScalarTypedRector.php b/rules/TypeDeclaration/Rector/MethodCall/FormerNullableArgumentToScalarTypedRector.php index ca1f3bc9373..e5acd3cfed4 100644 --- a/rules/TypeDeclaration/Rector/MethodCall/FormerNullableArgumentToScalarTypedRector.php +++ b/rules/TypeDeclaration/Rector/MethodCall/FormerNullableArgumentToScalarTypedRector.php @@ -17,25 +17,25 @@ use PHPStan\Type\StringType; use PHPStan\Type\Type; use Rector\Core\Rector\AbstractRector; use Rector\TypeDeclaration\NodeTypeAnalyzer\CallTypeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\TypeDeclaration\Rector\MethodCall\FormerNullableArgumentToScalarTypedRector\FormerNullableArgumentToScalarTypedRectorTest */ -final class FormerNullableArgumentToScalarTypedRector extends \Rector\Core\Rector\AbstractRector +final class FormerNullableArgumentToScalarTypedRector extends AbstractRector { /** * @readonly * @var \Rector\TypeDeclaration\NodeTypeAnalyzer\CallTypeAnalyzer */ private $callTypeAnalyzer; - public function __construct(\Rector\TypeDeclaration\NodeTypeAnalyzer\CallTypeAnalyzer $callTypeAnalyzer) + public function __construct(CallTypeAnalyzer $callTypeAnalyzer) { $this->callTypeAnalyzer = $callTypeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change null in argument, that is now not nullable anymore', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change null in argument, that is now not nullable anymore', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run() @@ -68,12 +68,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->args === []) { return null; @@ -83,7 +83,7 @@ CODE_SAMPLE return null; } foreach ($node->args as $key => $arg) { - if (!$arg instanceof \PhpParser\Node\Arg) { + if (!$arg instanceof Arg) { continue; } if (!$this->valueResolver->isNull($arg->value)) { @@ -97,22 +97,22 @@ CODE_SAMPLE /** * @param Type[] $methodParameterTypes */ - private function refactorArg(\PhpParser\Node\Arg $arg, array $methodParameterTypes, int $key) : void + private function refactorArg(Arg $arg, array $methodParameterTypes, int $key) : void { if (!isset($methodParameterTypes[$key])) { return; } $parameterType = $methodParameterTypes[$key]; - if ($parameterType instanceof \PHPStan\Type\StringType) { - $arg->value = new \PhpParser\Node\Scalar\String_(''); + if ($parameterType instanceof StringType) { + $arg->value = new String_(''); } - if ($parameterType instanceof \PHPStan\Type\IntegerType) { - $arg->value = new \PhpParser\Node\Scalar\LNumber(0); + if ($parameterType instanceof IntegerType) { + $arg->value = new LNumber(0); } - if ($parameterType instanceof \PHPStan\Type\FloatType) { - $arg->value = new \PhpParser\Node\Scalar\DNumber(0); + if ($parameterType instanceof FloatType) { + $arg->value = new DNumber(0); } - if ($parameterType instanceof \PHPStan\Type\BooleanType) { + if ($parameterType instanceof BooleanType) { $arg->value = $this->nodeFactory->createFalse(); } } diff --git a/rules/TypeDeclaration/Rector/Param/ParamTypeFromStrictTypedPropertyRector.php b/rules/TypeDeclaration/Rector/Param/ParamTypeFromStrictTypedPropertyRector.php index c1e19bbbdbf..d818d20b5ee 100644 --- a/rules/TypeDeclaration/Rector/Param/ParamTypeFromStrictTypedPropertyRector.php +++ b/rules/TypeDeclaration/Rector/Param/ParamTypeFromStrictTypedPropertyRector.php @@ -23,12 +23,12 @@ use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\VendorLocker\ParentClassMethodTypeOverrideGuard; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\TypeDeclaration\Rector\Param\ParamTypeFromStrictTypedPropertyRector\ParamTypeFromStrictTypedPropertyRectorTest */ -final class ParamTypeFromStrictTypedPropertyRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class ParamTypeFromStrictTypedPropertyRector extends AbstractRector implements MinPhpVersionInterface { /** * @readonly @@ -40,14 +40,14 @@ final class ParamTypeFromStrictTypedPropertyRector extends \Rector\Core\Rector\A * @var \Rector\VendorLocker\ParentClassMethodTypeOverrideGuard */ private $parentClassMethodTypeOverrideGuard; - public function __construct(\Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\VendorLocker\ParentClassMethodTypeOverrideGuard $parentClassMethodTypeOverrideGuard) + public function __construct(ReflectionResolver $reflectionResolver, ParentClassMethodTypeOverrideGuard $parentClassMethodTypeOverrideGuard) { $this->reflectionResolver = $reflectionResolver; $this->parentClassMethodTypeOverrideGuard = $parentClassMethodTypeOverrideGuard; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add param type from $param set to typed property', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add param type from $param set to typed property', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { private int $age; @@ -76,20 +76,20 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Param::class]; + return [Param::class]; } /** * @param Param $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\Stmt\ClassMethod) { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof ClassMethod) { return null; } return $this->decorateParamWithType($parent, $node); } - public function decorateParamWithType(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Param $param) : ?\PhpParser\Node\Param + public function decorateParamWithType(ClassMethod $classMethod, Param $param) : ?Param { if ($param->type !== null) { return null; @@ -100,19 +100,19 @@ CODE_SAMPLE $originalParamType = $this->resolveParamOriginalType($param); $paramName = $this->getName($param); /** @var Assign[] $assigns */ - $assigns = $this->betterNodeFinder->findInstanceOf((array) $classMethod->getStmts(), \PhpParser\Node\Expr\Assign::class); + $assigns = $this->betterNodeFinder->findInstanceOf((array) $classMethod->getStmts(), Assign::class); foreach ($assigns as $assign) { if (!$this->nodeComparator->areNodesEqual($assign->expr, $param->var)) { continue; } - if (!$assign->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$assign->var instanceof PropertyFetch) { continue; } if ($this->hasTypeChangedBeforeAssign($assign, $paramName, $originalParamType)) { return null; } $singlePropertyTypeNode = $this->matchPropertySingleTypeNode($assign->var); - if (!$singlePropertyTypeNode instanceof \PhpParser\Node) { + if (!$singlePropertyTypeNode instanceof Node) { return null; } $param->type = $singlePropertyTypeNode; @@ -122,33 +122,33 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES; + return PhpVersionFeature::TYPED_PROPERTIES; } /** * @return Name|ComplexType|null */ - private function matchPropertySingleTypeNode(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : ?\PhpParser\Node + private function matchPropertySingleTypeNode(PropertyFetch $propertyFetch) : ?Node { $phpPropertyReflection = $this->reflectionResolver->resolvePropertyReflectionFromPropertyFetch($propertyFetch); - if (!$phpPropertyReflection instanceof \PHPStan\Reflection\Php\PhpPropertyReflection) { + if (!$phpPropertyReflection instanceof PhpPropertyReflection) { return null; } $propertyType = $phpPropertyReflection->getNativeType(); - if ($propertyType instanceof \PHPStan\Type\MixedType) { + if ($propertyType instanceof MixedType) { return null; } - if ($propertyType instanceof \PHPStan\Type\UnionType) { + if ($propertyType instanceof UnionType) { return null; } - if ($propertyType instanceof \PhpParser\Node\NullableType) { + if ($propertyType instanceof NullableType) { return null; } - return $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY); + return $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, TypeKind::PROPERTY); } - private function hasTypeChangedBeforeAssign(\PhpParser\Node\Expr\Assign $assign, string $paramName, \PHPStan\Type\Type $originalType) : bool + private function hasTypeChangedBeforeAssign(Assign $assign, string $paramName, Type $originalType) : bool { - $scope = $assign->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { + $scope = $assign->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { return \false; } if (!$scope->hasVariableType($paramName)->yes()) { @@ -157,15 +157,15 @@ CODE_SAMPLE $currentParamType = $scope->getVariableType($paramName); return !$currentParamType->equals($originalType); } - private function resolveParamOriginalType(\PhpParser\Node\Param $param) : \PHPStan\Type\Type + private function resolveParamOriginalType(Param $param) : Type { - $scope = $param->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { - return new \PHPStan\Type\MixedType(); + $scope = $param->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { + return new MixedType(); } $paramName = $this->getName($param); if (!$scope->hasVariableType($paramName)->yes()) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } return $scope->getVariableType($paramName); } diff --git a/rules/TypeDeclaration/Rector/Property/AddPropertyTypeDeclarationRector.php b/rules/TypeDeclaration/Rector/Property/AddPropertyTypeDeclarationRector.php index 38b93cca2e4..1b349950926 100644 --- a/rules/TypeDeclaration/Rector/Property/AddPropertyTypeDeclarationRector.php +++ b/rules/TypeDeclaration/Rector/Property/AddPropertyTypeDeclarationRector.php @@ -13,13 +13,13 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\TypeDeclaration\ValueObject\AddPropertyTypeDeclaration; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\TypeDeclaration\Rector\Property\AddPropertyTypeDeclarationRector\AddPropertyTypeDeclarationRectorTest */ -final class AddPropertyTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class AddPropertyTypeDeclarationRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var AddPropertyTypeDeclaration[] @@ -30,14 +30,14 @@ final class AddPropertyTypeDeclarationRector extends \Rector\Core\Rector\Abstrac * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(ReflectionResolver $reflectionResolver) { $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - $configuration = [new \Rector\TypeDeclaration\ValueObject\AddPropertyTypeDeclaration('ParentClass', 'name', new \PHPStan\Type\StringType())]; - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add type to property by added rules, mostly public/property by parent type', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + $configuration = [new AddPropertyTypeDeclaration('ParentClass', 'name', new StringType())]; + return new RuleDefinition('Add type to property by added rules, mostly public/property by parent type', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass extends ParentClass { public $name; @@ -56,19 +56,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { // type is already known if ($node->type !== null) { return null; } $classReflection = $this->reflectionResolver->resolveClassReflection($node); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return null; } foreach ($this->addPropertyTypeDeclarations as $addPropertyTypeDeclaration) { @@ -78,10 +78,10 @@ CODE_SAMPLE if (!$this->isName($node, $addPropertyTypeDeclaration->getPropertyName())) { continue; } - $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($addPropertyTypeDeclaration->getType(), \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY); + $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($addPropertyTypeDeclaration->getType(), TypeKind::PROPERTY); if ($typeNode === null) { // invalid configuration - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $node->type = $typeNode; return $node; @@ -93,10 +93,10 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\TypeDeclaration\ValueObject\AddPropertyTypeDeclaration::class); + Assert::allIsAOf($configuration, AddPropertyTypeDeclaration::class); $this->addPropertyTypeDeclarations = $configuration; } - private function isClassReflectionType(\PHPStan\Reflection\ClassReflection $classReflection, string $type) : bool + private function isClassReflectionType(ClassReflection $classReflection, string $type) : bool { if ($classReflection->hasTraitUse($type)) { return \true; diff --git a/rules/TypeDeclaration/Rector/Property/PropertyTypeDeclarationRector.php b/rules/TypeDeclaration/Rector/Property/PropertyTypeDeclarationRector.php index b7886951cb4..6cd38b6be52 100644 --- a/rules/TypeDeclaration/Rector/Property/PropertyTypeDeclarationRector.php +++ b/rules/TypeDeclaration/Rector/Property/PropertyTypeDeclarationRector.php @@ -17,12 +17,12 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\TypeDeclaration\Guard\PropertyTypeOverrideGuard; use Rector\TypeDeclaration\TypeInferer\VarDocPropertyTypeInferer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector\PropertyTypeDeclarationRectorTest */ -final class PropertyTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector +final class PropertyTypeDeclarationRector extends AbstractRector { /** * @readonly @@ -44,16 +44,16 @@ final class PropertyTypeDeclarationRector extends \Rector\Core\Rector\AbstractRe * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\TypeDeclaration\TypeInferer\VarDocPropertyTypeInferer $varDocPropertyTypeInferer, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\TypeDeclaration\Guard\PropertyTypeOverrideGuard $propertyTypeOverrideGuard, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(VarDocPropertyTypeInferer $varDocPropertyTypeInferer, PhpDocTypeChanger $phpDocTypeChanger, PropertyTypeOverrideGuard $propertyTypeOverrideGuard, PhpVersionProvider $phpVersionProvider) { $this->varDocPropertyTypeInferer = $varDocPropertyTypeInferer; $this->phpDocTypeChanger = $phpDocTypeChanger; $this->propertyTypeOverrideGuard = $propertyTypeOverrideGuard; $this->phpVersionProvider = $phpVersionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add @var to properties that are missing it', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add @var to properties that are missing it', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { private $value; @@ -85,12 +85,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (\count($node->props) !== 1) { return null; @@ -106,37 +106,37 @@ CODE_SAMPLE return null; } $type = $this->varDocPropertyTypeInferer->inferProperty($node); - if ($type instanceof \PHPStan\Type\MixedType) { + if ($type instanceof MixedType) { return null; } - if (!$node->isPrivate() && $type instanceof \PHPStan\Type\NullType) { + if (!$node->isPrivate() && $type instanceof NullType) { return null; } - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES) && $this->propertyTypeOverrideGuard->isLegal($node)) { + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::TYPED_PROPERTIES) && $this->propertyTypeOverrideGuard->isLegal($node)) { $this->completeTypedProperty($type, $node); return $node; } $this->phpDocTypeChanger->changeVarType($phpDocInfo, $type); return $node; } - private function isVarDocAlreadySet(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : bool + private function isVarDocAlreadySet(PhpDocInfo $phpDocInfo) : bool { foreach (['@var', '@phpstan-var', '@psalm-var'] as $tagName) { $varType = $phpDocInfo->getVarType($tagName); - if (!$varType instanceof \PHPStan\Type\MixedType) { + if (!$varType instanceof MixedType) { return \true; } } return \false; } - private function completeTypedProperty(\PHPStan\Type\Type $type, \PhpParser\Node\Stmt\Property $property) : void + private function completeTypedProperty(Type $type, Property $property) : void { - $propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY); + $propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, TypeKind::PROPERTY); if ($propertyTypeNode === null) { return; } - if ($propertyTypeNode instanceof \PhpParser\Node\UnionType) { - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::UNION_TYPES)) { + if ($propertyTypeNode instanceof UnionType) { + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::UNION_TYPES)) { $property->type = $propertyTypeNode; return; } diff --git a/rules/TypeDeclaration/Rector/Property/TypedPropertyFromAssignsRector.php b/rules/TypeDeclaration/Rector/Property/TypedPropertyFromAssignsRector.php index b17cb22dc90..088b1896724 100644 --- a/rules/TypeDeclaration/Rector/Property/TypedPropertyFromAssignsRector.php +++ b/rules/TypeDeclaration/Rector/Property/TypedPropertyFromAssignsRector.php @@ -20,12 +20,12 @@ use Rector\Php74\Guard\MakePropertyTypedGuard; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\TypeDeclaration\NodeTypeAnalyzer\PropertyTypeDecorator; use Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer\AllAssignNodePropertyTypeInferer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\TypedPropertyFromAssignsRectorTest */ -final class TypedPropertyFromAssignsRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface +final class TypedPropertyFromAssignsRector extends AbstractRector implements AllowEmptyConfigurableRectorInterface { /** * @var string @@ -71,7 +71,7 @@ final class TypedPropertyFromAssignsRector extends \Rector\Core\Rector\AbstractR * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer\AllAssignNodePropertyTypeInferer $allAssignNodePropertyTypeInferer, \Rector\TypeDeclaration\NodeTypeAnalyzer\PropertyTypeDecorator $propertyTypeDecorator, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover $varTagRemover, \Rector\Php74\Guard\MakePropertyTypedGuard $makePropertyTypedGuard, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(AllAssignNodePropertyTypeInferer $allAssignNodePropertyTypeInferer, PropertyTypeDecorator $propertyTypeDecorator, PhpDocTypeChanger $phpDocTypeChanger, VarTagRemover $varTagRemover, MakePropertyTypedGuard $makePropertyTypedGuard, PhpVersionProvider $phpVersionProvider) { $this->allAssignNodePropertyTypeInferer = $allAssignNodePropertyTypeInferer; $this->propertyTypeDecorator = $propertyTypeDecorator; @@ -84,9 +84,9 @@ final class TypedPropertyFromAssignsRector extends \Rector\Core\Rector\AbstractR { $this->inlinePublic = $configuration[self::INLINE_PUBLIC] ?? (bool) \current($configuration); } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add typed property from assigned types', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add typed property from assigned types', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' final class SomeClass { private $name; @@ -115,31 +115,31 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->makePropertyTypedGuard->isLegal($node, $this->inlinePublic)) { return null; } $inferredType = $this->allAssignNodePropertyTypeInferer->inferProperty($node); - if (!$inferredType instanceof \PHPStan\Type\Type) { + if (!$inferredType instanceof Type) { return null; } - if ($inferredType instanceof \PHPStan\Type\MixedType) { + if ($inferredType instanceof MixedType) { return null; } $inferredType = $this->decorateTypeWithNullableIfDefaultPropertyNull($node, $inferredType); $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); - $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($inferredType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY); + $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($inferredType, TypeKind::PROPERTY); if ($typeNode === null) { $this->phpDocTypeChanger->changeVarType($phpDocInfo, $inferredType); return $node; } - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::TYPED_PROPERTIES)) { $this->phpDocTypeChanger->changeVarType($phpDocInfo, $inferredType); return $node; } @@ -148,7 +148,7 @@ CODE_SAMPLE $this->phpDocTypeChanger->changeVarType($phpDocInfo, $inferredType); return $node; } - if ($inferredType instanceof \PHPStan\Type\UnionType) { + if ($inferredType instanceof UnionType) { $this->propertyTypeDecorator->decoratePropertyUnionType($inferredType, $typeNode, $node, $phpDocInfo); } else { $node->type = $typeNode; @@ -156,18 +156,18 @@ CODE_SAMPLE $this->varTagRemover->removeVarTagIfUseless($phpDocInfo, $node); return $node; } - private function decorateTypeWithNullableIfDefaultPropertyNull(\PhpParser\Node\Stmt\Property $property, \PHPStan\Type\Type $inferredType) : \PHPStan\Type\Type + private function decorateTypeWithNullableIfDefaultPropertyNull(Property $property, Type $inferredType) : Type { $defaultExpr = $property->props[0]->default; - if (!$defaultExpr instanceof \PhpParser\Node\Expr) { + if (!$defaultExpr instanceof Expr) { return $inferredType; } if (!$this->valueResolver->isNull($defaultExpr)) { return $inferredType; } - if (\PHPStan\Type\TypeCombinator::containsNull($inferredType)) { + if (TypeCombinator::containsNull($inferredType)) { return $inferredType; } - return \PHPStan\Type\TypeCombinator::addNull($inferredType); + return TypeCombinator::addNull($inferredType); } } diff --git a/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictConstructorRector.php b/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictConstructorRector.php index 790306bf0c6..1b24563ef90 100644 --- a/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictConstructorRector.php +++ b/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictConstructorRector.php @@ -16,12 +16,12 @@ use Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector; use Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer\ConstructorPropertyTypeInferer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector\TypedPropertyFromStrictConstructorRectorTest */ -final class TypedPropertyFromStrictConstructorRector extends \Rector\Core\Rector\AbstractRector +final class TypedPropertyFromStrictConstructorRector extends AbstractRector { /** * @readonly @@ -48,7 +48,7 @@ final class TypedPropertyFromStrictConstructorRector extends \Rector\Core\Rector * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer\ConstructorPropertyTypeInferer $constructorPropertyTypeInferer, \Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover $varTagRemover, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector $constructorAssignDetector, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(ConstructorPropertyTypeInferer $constructorPropertyTypeInferer, VarTagRemover $varTagRemover, PhpDocTypeChanger $phpDocTypeChanger, ConstructorAssignDetector $constructorAssignDetector, PhpVersionProvider $phpVersionProvider) { $this->constructorPropertyTypeInferer = $constructorPropertyTypeInferer; $this->varTagRemover = $varTagRemover; @@ -56,9 +56,9 @@ final class TypedPropertyFromStrictConstructorRector extends \Rector\Core\Rector $this->constructorAssignDetector = $constructorAssignDetector; $this->phpVersionProvider = $phpVersionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add typed properties based only on strict constructor types', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add typed properties based only on strict constructor types', [new CodeSample(<<<'CODE_SAMPLE' class SomeObject { private $name; @@ -87,34 +87,34 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->type !== null) { return null; } $varType = $this->constructorPropertyTypeInferer->inferProperty($node); - if (!$varType instanceof \PHPStan\Type\Type) { + if (!$varType instanceof Type) { return null; } - if ($varType instanceof \PHPStan\Type\MixedType) { + if ($varType instanceof MixedType) { return null; } - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLike = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$classLike instanceof Class_) { return null; } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::TYPED_PROPERTIES)) { $this->phpDocTypeChanger->changeVarType($phpDocInfo, $varType); return $node; } - $propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($varType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY); - if (!$propertyTypeNode instanceof \PhpParser\Node) { + $propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($varType, TypeKind::PROPERTY); + if (!$propertyTypeNode instanceof Node) { return null; } // public property can be anything @@ -132,6 +132,6 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES; + return PhpVersionFeature::TYPED_PROPERTIES; } } diff --git a/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictGetterMethodReturnTypeRector.php b/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictGetterMethodReturnTypeRector.php index 7fad8a6f784..b5ae8f593bc 100644 --- a/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictGetterMethodReturnTypeRector.php +++ b/rules/TypeDeclaration/Rector/Property/TypedPropertyFromStrictGetterMethodReturnTypeRector.php @@ -17,12 +17,12 @@ use Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\Privatization\Guard\ParentPropertyLookupGuard; use Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer\GetterTypeDeclarationPropertyTypeInferer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector\TypedPropertyFromStrictGetterMethodReturnTypeRectorTest */ -final class TypedPropertyFromStrictGetterMethodReturnTypeRector extends \Rector\Core\Rector\AbstractRector +final class TypedPropertyFromStrictGetterMethodReturnTypeRector extends AbstractRector { /** * @readonly @@ -49,7 +49,7 @@ final class TypedPropertyFromStrictGetterMethodReturnTypeRector extends \Rector\ * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer\GetterTypeDeclarationPropertyTypeInferer $getterTypeDeclarationPropertyTypeInferer, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover $varTagRemover, \Rector\Privatization\Guard\ParentPropertyLookupGuard $parentPropertyLookupGuard, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(GetterTypeDeclarationPropertyTypeInferer $getterTypeDeclarationPropertyTypeInferer, PhpDocTypeChanger $phpDocTypeChanger, VarTagRemover $varTagRemover, ParentPropertyLookupGuard $parentPropertyLookupGuard, PhpVersionProvider $phpVersionProvider) { $this->getterTypeDeclarationPropertyTypeInferer = $getterTypeDeclarationPropertyTypeInferer; $this->phpDocTypeChanger = $phpDocTypeChanger; @@ -57,9 +57,9 @@ final class TypedPropertyFromStrictGetterMethodReturnTypeRector extends \Rector\ $this->parentPropertyLookupGuard = $parentPropertyLookupGuard; $this->phpVersionProvider = $phpVersionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Complete property type based on getter strict types', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Complete property type based on getter strict types', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public $name; @@ -88,12 +88,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node\Stmt\Property + public function refactor(Node $node) : ?Property { if ($node->type !== null) { return null; @@ -102,23 +102,23 @@ CODE_SAMPLE return null; } $getterReturnType = $this->getterTypeDeclarationPropertyTypeInferer->inferProperty($node); - if (!$getterReturnType instanceof \PHPStan\Type\Type) { + if (!$getterReturnType instanceof Type) { return null; } - if ($getterReturnType instanceof \PHPStan\Type\MixedType) { + if ($getterReturnType instanceof MixedType) { return null; } - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::TYPED_PROPERTIES)) { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $this->phpDocTypeChanger->changeVarType($phpDocInfo, $getterReturnType); return $node; } // if property is public, it should be nullable - if ($node->isPublic() && !\PHPStan\Type\TypeCombinator::containsNull($getterReturnType)) { - $getterReturnType = \PHPStan\Type\TypeCombinator::addNull($getterReturnType); + if ($node->isPublic() && !TypeCombinator::containsNull($getterReturnType)) { + $getterReturnType = TypeCombinator::addNull($getterReturnType); } - $propertyType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($getterReturnType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY); - if (!$propertyType instanceof \PhpParser\Node) { + $propertyType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($getterReturnType, TypeKind::PROPERTY); + if (!$propertyType instanceof Node) { return null; } $node->type = $propertyType; @@ -129,15 +129,15 @@ CODE_SAMPLE } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES; + return PhpVersionFeature::TYPED_PROPERTIES; } - private function decorateDefaultNull(\PHPStan\Type\Type $propertyType, \PhpParser\Node\Stmt\Property $property) : void + private function decorateDefaultNull(Type $propertyType, Property $property) : void { - if (!\PHPStan\Type\TypeCombinator::containsNull($propertyType)) { + if (!TypeCombinator::containsNull($propertyType)) { return; } $propertyProperty = $property->props[0]; - if ($propertyProperty->default instanceof \PhpParser\Node\Expr) { + if ($propertyProperty->default instanceof Expr) { return; } $propertyProperty->default = $this->nodeFactory->createNull(); diff --git a/rules/TypeDeclaration/Rector/Property/VarAnnotationIncorrectNullableRector.php b/rules/TypeDeclaration/Rector/Property/VarAnnotationIncorrectNullableRector.php index 7dbf8f1a001..18241cf5dc8 100644 --- a/rules/TypeDeclaration/Rector/Property/VarAnnotationIncorrectNullableRector.php +++ b/rules/TypeDeclaration/Rector/Property/VarAnnotationIncorrectNullableRector.php @@ -15,12 +15,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\TypeDeclaration\Guard\PhpDocNestedAnnotationGuard; use Rector\TypeDeclaration\Helper\PhpDocNullableTypeHelper; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\TypeDeclaration\Rector\Property\VarAnnotationIncorrectNullableRector\VarAnnotationIncorrectNullableRectorTest */ -final class VarAnnotationIncorrectNullableRector extends \Rector\Core\Rector\AbstractRector +final class VarAnnotationIncorrectNullableRector extends AbstractRector { /** * @readonly @@ -42,16 +42,16 @@ final class VarAnnotationIncorrectNullableRector extends \Rector\Core\Rector\Abs * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\TypeDeclaration\Helper\PhpDocNullableTypeHelper $phpDocNullableTypeHelper, \Rector\TypeDeclaration\Guard\PhpDocNestedAnnotationGuard $phpDocNestedAnnotationGuard, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PhpDocTypeChanger $phpDocTypeChanger, PhpDocNullableTypeHelper $phpDocNullableTypeHelper, PhpDocNestedAnnotationGuard $phpDocNestedAnnotationGuard, PhpVersionProvider $phpVersionProvider) { $this->phpDocTypeChanger = $phpDocTypeChanger; $this->phpDocNullableTypeHelper = $phpDocNullableTypeHelper; $this->phpDocNestedAnnotationGuard = $phpDocNestedAnnotationGuard; $this->phpVersionProvider = $phpVersionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add or remove null type from @var phpdoc typehint based on php property type declaration', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add or remove null type from @var phpdoc typehint based on php property type declaration', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { /** @@ -76,17 +76,17 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (\count($node->props) !== 1) { return null; } - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::TYPED_PROPERTIES)) { return null; } if (!$this->phpDocNestedAnnotationGuard->isPhpDocCommentCorrectlyParsed($node)) { @@ -101,7 +101,7 @@ CODE_SAMPLE } $phpParserType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($node->type); $varTagValueNode = $phpDocInfo->getVarTagValueNode(); - if (!$varTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) { + if (!$varTagValueNode instanceof VarTagValueNode) { return null; } if ($varTagValueNode->type === null) { @@ -109,7 +109,7 @@ CODE_SAMPLE } $docType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($varTagValueNode->type, $node); $updatedPhpDocType = $this->phpDocNullableTypeHelper->resolveUpdatedPhpDocTypeFromPhpDocTypeAndPhpParserType($docType, $phpParserType); - if (!$updatedPhpDocType instanceof \PHPStan\Type\Type) { + if (!$updatedPhpDocType instanceof Type) { return null; } $this->phpDocTypeChanger->changeVarType($phpDocInfo, $updatedPhpDocType); @@ -118,11 +118,11 @@ CODE_SAMPLE } return $node; } - private function isVarDocAlreadySet(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : bool + private function isVarDocAlreadySet(PhpDocInfo $phpDocInfo) : bool { foreach (['@var', '@phpstan-var', '@psalm-var'] as $tagName) { $varType = $phpDocInfo->getVarType($tagName); - if (!$varType instanceof \PHPStan\Type\MixedType) { + if (!$varType instanceof MixedType) { return \true; } } diff --git a/rules/TypeDeclaration/Sorter/PriorityAwareSorter.php b/rules/TypeDeclaration/Sorter/PriorityAwareSorter.php index 0d4f5f1b91a..f4fe42000d9 100644 --- a/rules/TypeDeclaration/Sorter/PriorityAwareSorter.php +++ b/rules/TypeDeclaration/Sorter/PriorityAwareSorter.php @@ -25,12 +25,12 @@ final class PriorityAwareSorter /** * @param PriorityAwareInterface[] $sortedTypeInferers */ - private function ensurePriorityIsUnique(array $sortedTypeInferers, \Rector\TypeDeclaration\Contract\PriorityAwareInterface $priorityAware) : void + private function ensurePriorityIsUnique(array $sortedTypeInferers, PriorityAwareInterface $priorityAware) : void { if (!isset($sortedTypeInferers[$priorityAware->getPriority()])) { return; } $alreadySetPropertyTypeInferer = $sortedTypeInferers[$priorityAware->getPriority()]; - throw new \Rector\TypeDeclaration\Exception\ConflictingPriorityException($priorityAware, $alreadySetPropertyTypeInferer); + throw new ConflictingPriorityException($priorityAware, $alreadySetPropertyTypeInferer); } } diff --git a/rules/TypeDeclaration/TypeAlreadyAddedChecker/ReturnTypeAlreadyAddedChecker.php b/rules/TypeDeclaration/TypeAlreadyAddedChecker/ReturnTypeAlreadyAddedChecker.php index d086f70824a..a2c73e3b01d 100644 --- a/rules/TypeDeclaration/TypeAlreadyAddedChecker/ReturnTypeAlreadyAddedChecker.php +++ b/rules/TypeDeclaration/TypeAlreadyAddedChecker/ReturnTypeAlreadyAddedChecker.php @@ -53,7 +53,7 @@ final class ReturnTypeAlreadyAddedChecker * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeNameResolver $nodeNameResolver, StaticTypeMapper $staticTypeMapper, NodeComparator $nodeComparator, BetterNodeFinder $betterNodeFinder) { $this->nodeNameResolver = $nodeNameResolver; $this->staticTypeMapper = $staticTypeMapper; @@ -63,14 +63,14 @@ final class ReturnTypeAlreadyAddedChecker /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike */ - public function isSameOrBetterReturnTypeAlreadyAdded($functionLike, \PHPStan\Type\Type $returnType) : bool + public function isSameOrBetterReturnTypeAlreadyAdded($functionLike, Type $returnType) : bool { $nodeReturnType = $functionLike->returnType; /** @param Identifier|Name|NullableType|PhpParserUnionType|null $returnTypeNode */ if ($nodeReturnType === null) { return \false; } - $returnNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($returnType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN); + $returnNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($returnType, TypeKind::RETURN); if ($this->nodeComparator->areNodesEqual($nodeReturnType, $returnNode)) { return \true; } @@ -82,22 +82,22 @@ final class ReturnTypeAlreadyAddedChecker return \true; } // is class-string type? → skip - if ($returnType instanceof \PHPStan\Type\Generic\GenericObjectType && $returnType->getClassName() === 'class-string') { + if ($returnType instanceof GenericObjectType && $returnType->getClassName() === 'class-string') { return \true; } // prevent overriding self with itself - if (!$functionLike->returnType instanceof \PhpParser\Node\Name) { + if (!$functionLike->returnType instanceof Name) { return \false; } if ($functionLike->returnType->toLowerString() !== 'self') { return \false; } // skip "self" by "static" override - if ($returnType instanceof \PHPStan\Type\ThisType) { + if ($returnType instanceof ThisType) { return \true; } - $classLike = $this->betterNodeFinder->findParentType($functionLike, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($functionLike, ClassLike::class); + if (!$classLike instanceof ClassLike) { return \false; } $className = (string) $this->nodeNameResolver->getName($classLike); @@ -108,7 +108,7 @@ final class ReturnTypeAlreadyAddedChecker /** * @param \PhpParser\Node\ComplexType|\PhpParser\Node\Identifier|\PhpParser\Node\Name $returnTypeNode */ - private function isArrayIterableIteratorCoType($returnTypeNode, \PHPStan\Type\Type $returnType) : bool + private function isArrayIterableIteratorCoType($returnTypeNode, Type $returnType) : bool { if (!$this->nodeNameResolver->isNames($returnTypeNode, self::FOREACHABLE_TYPES)) { return \false; @@ -118,24 +118,24 @@ final class ReturnTypeAlreadyAddedChecker /** * @param \PhpParser\Node\ComplexType|\PhpParser\Node\Identifier|\PhpParser\Node\Name $returnTypeNode */ - private function isUnionCoType($returnTypeNode, \PHPStan\Type\Type $type) : bool + private function isUnionCoType($returnTypeNode, Type $type) : bool { - if (!$type instanceof \PHPStan\Type\UnionType) { + if (!$type instanceof UnionType) { return \false; } // skip nullable type - if ($type->isSuperTypeOf(new \PHPStan\Type\NullType())->yes()) { + if ($type->isSuperTypeOf(new NullType())->yes()) { return \false; } $classMethodReturnType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($returnTypeNode); return $classMethodReturnType->isSuperTypeOf($type)->yes(); } - private function isStaticTypeIterable(\PHPStan\Type\Type $type) : bool + private function isStaticTypeIterable(Type $type) : bool { if ($this->isArrayIterableOrIteratorType($type)) { return \true; } - if ($type instanceof \PHPStan\Type\UnionType || $type instanceof \PHPStan\Type\IntersectionType) { + if ($type instanceof UnionType || $type instanceof IntersectionType) { foreach ($type->getTypes() as $joinedType) { if (!$this->isStaticTypeIterable($joinedType)) { return \false; @@ -145,17 +145,17 @@ final class ReturnTypeAlreadyAddedChecker } return \false; } - private function isArrayIterableOrIteratorType(\PHPStan\Type\Type $type) : bool + private function isArrayIterableOrIteratorType(Type $type) : bool { - if ($type instanceof \PHPStan\Type\ArrayType) { + if ($type instanceof ArrayType) { return \true; } - if ($type instanceof \PHPStan\Type\IterableType) { + if ($type instanceof IterableType) { return \true; } - if (!$type instanceof \PHPStan\Type\ObjectType) { + if (!$type instanceof ObjectType) { return \false; } - return $type->getClassName() === \Iterator::class; + return $type->getClassName() === Iterator::class; } } diff --git a/rules/TypeDeclaration/TypeAnalyzer/AdvancedArrayAnalyzer.php b/rules/TypeDeclaration/TypeAnalyzer/AdvancedArrayAnalyzer.php index 946a2613009..38901bf7e63 100644 --- a/rules/TypeDeclaration/TypeAnalyzer/AdvancedArrayAnalyzer.php +++ b/rules/TypeDeclaration/TypeAnalyzer/AdvancedArrayAnalyzer.php @@ -28,57 +28,57 @@ final class AdvancedArrayAnalyzer * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory */ private $phpDocInfoFactory; - public function __construct(\Rector\TypeDeclaration\TypeNormalizer $typeNormalizer, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory) + public function __construct(TypeNormalizer $typeNormalizer, PhpDocInfoFactory $phpDocInfoFactory) { $this->typeNormalizer = $typeNormalizer; $this->phpDocInfoFactory = $phpDocInfoFactory; } - public function isClassStringArrayByStringArrayOverride(\PHPStan\Type\ArrayType $arrayType, \PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + public function isClassStringArrayByStringArrayOverride(ArrayType $arrayType, ClassMethod $classMethod) : bool { - if (!$arrayType instanceof \PHPStan\Type\Constant\ConstantArrayType) { + if (!$arrayType instanceof ConstantArrayType) { return \false; } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); $arrayType = $this->typeNormalizer->convertConstantArrayTypeToArrayType($arrayType); - if (!$arrayType instanceof \PHPStan\Type\ArrayType) { + if (!$arrayType instanceof ArrayType) { return \false; } $currentReturnType = $phpDocInfo->getReturnType(); - if (!$currentReturnType instanceof \PHPStan\Type\ArrayType) { + if (!$currentReturnType instanceof ArrayType) { return \false; } - if (!$currentReturnType->getItemType() instanceof \PHPStan\Type\ClassStringType) { + if (!$currentReturnType->getItemType() instanceof ClassStringType) { return \false; } - return $arrayType->getItemType() instanceof \PHPStan\Type\StringType; + return $arrayType->getItemType() instanceof StringType; } - public function isMixedOfSpecificOverride(\PHPStan\Type\ArrayType $arrayType, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : bool + public function isMixedOfSpecificOverride(ArrayType $arrayType, PhpDocInfo $phpDocInfo) : bool { - if (!$arrayType->getItemType() instanceof \PHPStan\Type\MixedType) { + if (!$arrayType->getItemType() instanceof MixedType) { return \false; } $currentReturnType = $phpDocInfo->getReturnType(); - $arrayTypes = \PHPStan\Type\TypeUtils::getArrays($currentReturnType); + $arrayTypes = TypeUtils::getArrays($currentReturnType); return $arrayTypes !== []; } - public function isMoreSpecificArrayTypeOverride(\PHPStan\Type\Type $newType, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : bool + public function isMoreSpecificArrayTypeOverride(Type $newType, PhpDocInfo $phpDocInfo) : bool { - if (!$newType instanceof \PHPStan\Type\Constant\ConstantArrayType) { + if (!$newType instanceof ConstantArrayType) { return \false; } - if (!$newType->getItemType() instanceof \PHPStan\Type\NeverType) { + if (!$newType->getItemType() instanceof NeverType) { return \false; } $phpDocReturnType = $phpDocInfo->getReturnType(); - if (!$phpDocReturnType instanceof \PHPStan\Type\ArrayType) { + if (!$phpDocReturnType instanceof ArrayType) { return \false; } - return !$phpDocReturnType->getItemType() instanceof \PHPStan\Type\VoidType; + return !$phpDocReturnType->getItemType() instanceof VoidType; } - public function isNewAndCurrentTypeBothCallable(\PHPStan\Type\ArrayType $newArrayType, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : bool + public function isNewAndCurrentTypeBothCallable(ArrayType $newArrayType, PhpDocInfo $phpDocInfo) : bool { $currentReturnType = $phpDocInfo->getReturnType(); - if (!$currentReturnType instanceof \PHPStan\Type\ArrayType) { + if (!$currentReturnType instanceof ArrayType) { return \false; } if (!$newArrayType->getItemType()->isCallable()->yes()) { diff --git a/rules/TypeDeclaration/TypeAnalyzer/GenericClassStringTypeNormalizer.php b/rules/TypeDeclaration/TypeAnalyzer/GenericClassStringTypeNormalizer.php index 3af0d2745f5..e192b618553 100644 --- a/rules/TypeDeclaration/TypeAnalyzer/GenericClassStringTypeNormalizer.php +++ b/rules/TypeDeclaration/TypeAnalyzer/GenericClassStringTypeNormalizer.php @@ -34,7 +34,7 @@ final class GenericClassStringTypeNormalizer * @var \Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer */ private $unionTypeAnalyzer; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\TypeDeclaration\NodeTypeAnalyzer\DetailedTypeAnalyzer $detailedTypeAnalyzer, \Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer $unionTypeAnalyzer) + public function __construct(ReflectionProvider $reflectionProvider, DetailedTypeAnalyzer $detailedTypeAnalyzer, UnionTypeAnalyzer $unionTypeAnalyzer) { $this->reflectionProvider = $reflectionProvider; $this->detailedTypeAnalyzer = $detailedTypeAnalyzer; @@ -43,10 +43,10 @@ final class GenericClassStringTypeNormalizer /** * @return \PHPStan\Type\ArrayType|\PHPStan\Type\UnionType|\PHPStan\Type\Type */ - public function normalize(\PHPStan\Type\Type $type) + public function normalize(Type $type) { - $type = \PHPStan\Type\TypeTraverser::map($type, function (\PHPStan\Type\Type $type, $callback) : Type { - if (!$type instanceof \PHPStan\Type\Constant\ConstantStringType) { + $type = TypeTraverser::map($type, function (Type $type, $callback) : Type { + if (!$type instanceof ConstantStringType) { return $callback($type); } $value = $type->getValue(); @@ -59,63 +59,63 @@ final class GenericClassStringTypeNormalizer } return $this->resolveStringType($value); }); - if ($type instanceof \PHPStan\Type\UnionType && !$this->unionTypeAnalyzer->isNullable($type, \true)) { + if ($type instanceof UnionType && !$this->unionTypeAnalyzer->isNullable($type, \true)) { return $this->resolveClassStringInUnionType($type); } - if ($type instanceof \PHPStan\Type\ArrayType && $type->getKeyType() instanceof \PHPStan\Type\UnionType) { + if ($type instanceof ArrayType && $type->getKeyType() instanceof UnionType) { return $this->resolveArrayTypeWithUnionKeyType($type); } return $type; } - public function isAllGenericClassStringType(\PHPStan\Type\UnionType $unionType) : bool + public function isAllGenericClassStringType(UnionType $unionType) : bool { foreach ($unionType->getTypes() as $type) { - if (!$type instanceof \PHPStan\Type\Generic\GenericClassStringType) { + if (!$type instanceof GenericClassStringType) { return \false; } } return \true; } - private function resolveArrayTypeWithUnionKeyType(\PHPStan\Type\ArrayType $arrayType) : \PHPStan\Type\ArrayType + private function resolveArrayTypeWithUnionKeyType(ArrayType $arrayType) : ArrayType { $itemType = $arrayType->getItemType(); - if (!$itemType instanceof \PHPStan\Type\UnionType) { + if (!$itemType instanceof UnionType) { return $arrayType; } $keyType = $arrayType->getKeyType(); $isAllGenericClassStringType = $this->isAllGenericClassStringType($itemType); if (!$isAllGenericClassStringType) { - return new \PHPStan\Type\ArrayType($keyType, new \PHPStan\Type\MixedType()); + return new ArrayType($keyType, new MixedType()); } if ($this->detailedTypeAnalyzer->isTooDetailed($itemType)) { - return new \PHPStan\Type\ArrayType($keyType, new \PHPStan\Type\ClassStringType()); + return new ArrayType($keyType, new ClassStringType()); } return $arrayType; } /** * @return \PHPStan\Type\UnionType|\PHPStan\Type\ArrayType */ - private function resolveClassStringInUnionType(\PHPStan\Type\UnionType $type) + private function resolveClassStringInUnionType(UnionType $type) { $unionTypes = $type->getTypes(); foreach ($unionTypes as $unionType) { - if (!$unionType instanceof \PHPStan\Type\ArrayType) { + if (!$unionType instanceof ArrayType) { return $type; } $keyType = $unionType->getKeyType(); $itemType = $unionType->getItemType(); - if ($itemType instanceof \PHPStan\Type\ArrayType) { - $arrayType = new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); - return new \PHPStan\Type\ArrayType($keyType, $arrayType); + if ($itemType instanceof ArrayType) { + $arrayType = new ArrayType(new MixedType(), new MixedType()); + return new ArrayType($keyType, $arrayType); } - if (!$keyType instanceof \PHPStan\Type\MixedType && !$keyType instanceof \PHPStan\Type\Constant\ConstantIntegerType) { + if (!$keyType instanceof MixedType && !$keyType instanceof ConstantIntegerType) { return $type; } - if (!$itemType instanceof \PHPStan\Type\ClassStringType) { + if (!$itemType instanceof ClassStringType) { return $type; } } - return new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\ClassStringType()); + return new ArrayType(new MixedType(), new ClassStringType()); } /** * @return \PHPStan\Type\Generic\GenericClassStringType|\PHPStan\Type\StringType @@ -124,11 +124,11 @@ final class GenericClassStringTypeNormalizer { $classReflection = $this->reflectionProvider->getClass($value); if ($classReflection->isBuiltin()) { - return new \PHPStan\Type\Generic\GenericClassStringType(new \PHPStan\Type\ObjectType($value)); + return new GenericClassStringType(new ObjectType($value)); } if (\strpos($value, '\\') !== \false) { - return new \PHPStan\Type\Generic\GenericClassStringType(new \PHPStan\Type\ObjectType($value)); + return new GenericClassStringType(new ObjectType($value)); } - return new \PHPStan\Type\StringType(); + return new StringType(); } } diff --git a/rules/TypeDeclaration/TypeAnalyzer/IterableTypeAnalyzer.php b/rules/TypeDeclaration/TypeAnalyzer/IterableTypeAnalyzer.php index 54aed47f311..9887a76f039 100644 --- a/rules/TypeDeclaration/TypeAnalyzer/IterableTypeAnalyzer.php +++ b/rules/TypeDeclaration/TypeAnalyzer/IterableTypeAnalyzer.php @@ -17,22 +17,22 @@ final class IterableTypeAnalyzer * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ReflectionProvider $reflectionProvider) { $this->reflectionProvider = $reflectionProvider; } - public function isIterableType(\PHPStan\Type\Type $type) : bool + public function isIterableType(Type $type) : bool { if ($this->isUnionOfIterableTypes($type)) { return \true; } - if ($type instanceof \PHPStan\Type\ArrayType) { + if ($type instanceof ArrayType) { return \true; } - if ($type instanceof \PHPStan\Type\IterableType) { + if ($type instanceof IterableType) { return \true; } - if ($type instanceof \PHPStan\Type\Generic\GenericObjectType) { + if ($type instanceof GenericObjectType) { if (!$this->reflectionProvider->hasClass($type->getClassName())) { return \false; } @@ -43,14 +43,14 @@ final class IterableTypeAnalyzer } return \false; } - private function isUnionOfIterableTypes(\PHPStan\Type\Type $type) : bool + private function isUnionOfIterableTypes(Type $type) : bool { - if (!$type instanceof \PHPStan\Type\UnionType) { + if (!$type instanceof UnionType) { return \false; } foreach ($type->getTypes() as $unionedType) { // nullable union is allowed - if ($unionedType instanceof \PHPStan\Type\NullType) { + if ($unionedType instanceof NullType) { continue; } if (!$this->isIterableType($unionedType)) { diff --git a/rules/TypeDeclaration/TypeAnalyzer/ObjectTypeComparator.php b/rules/TypeDeclaration/TypeAnalyzer/ObjectTypeComparator.php index 735c5312fb4..503580ebab5 100644 --- a/rules/TypeDeclaration/TypeAnalyzer/ObjectTypeComparator.php +++ b/rules/TypeDeclaration/TypeAnalyzer/ObjectTypeComparator.php @@ -13,32 +13,32 @@ final class ObjectTypeComparator * E.g. current E, new type A, E extends A → true * Also for closure/callable, iterable/Traversable/Iterator/Generator */ - public function isCurrentObjectTypeSubType(\PHPStan\Type\Type $currentType, \PHPStan\Type\Type $newType) : bool + public function isCurrentObjectTypeSubType(Type $currentType, Type $newType) : bool { - if ($newType instanceof \PHPStan\Type\ObjectWithoutClassType && $currentType instanceof \PHPStan\Type\ObjectType) { + if ($newType instanceof ObjectWithoutClassType && $currentType instanceof ObjectType) { return \true; } if ($this->isBothCallable($currentType, $newType)) { return \true; } - if (!$currentType instanceof \PHPStan\Type\ObjectType) { + if (!$currentType instanceof ObjectType) { return \false; } - if (!$newType instanceof \PHPStan\Type\ObjectType) { + if (!$newType instanceof ObjectType) { return \false; } return $newType->isSuperTypeOf($currentType)->yes(); } - private function isBothCallable(\PHPStan\Type\Type $currentType, \PHPStan\Type\Type $newType) : bool + private function isBothCallable(Type $currentType, Type $newType) : bool { - if ($currentType instanceof \PHPStan\Type\CallableType && $this->isClosure($newType)) { + if ($currentType instanceof CallableType && $this->isClosure($newType)) { return \true; } - return $newType instanceof \PHPStan\Type\CallableType && $this->isClosure($currentType); + return $newType instanceof CallableType && $this->isClosure($currentType); } - private function isClosure(\PHPStan\Type\Type $type) : bool + private function isClosure(Type $type) : bool { - $closureObjectType = new \PHPStan\Type\ObjectType('Closure'); + $closureObjectType = new ObjectType('Closure'); return $closureObjectType->equals($type); } } diff --git a/rules/TypeDeclaration/TypeInferer/AssignToPropertyTypeInferer.php b/rules/TypeDeclaration/TypeInferer/AssignToPropertyTypeInferer.php index 5baf9a677bd..2e32f2b3a7b 100644 --- a/rules/TypeDeclaration/TypeInferer/AssignToPropertyTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/AssignToPropertyTypeInferer.php @@ -69,7 +69,7 @@ final class AssignToPropertyTypeInferer * @var \Rector\Core\PhpParser\Node\Value\ValueResolver */ private $valueResolver; - public function __construct(\Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector $constructorAssignDetector, \Rector\TypeDeclaration\Matcher\PropertyAssignMatcher $propertyAssignMatcher, \Rector\TypeDeclaration\AlreadyAssignDetector\PropertyDefaultAssignDetector $propertyDefaultAssignDetector, \Rector\TypeDeclaration\AlreadyAssignDetector\NullTypeAssignDetector $nullTypeAssignDetector, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\Core\NodeAnalyzer\ExprAnalyzer $exprAnalyzer, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver) + public function __construct(ConstructorAssignDetector $constructorAssignDetector, PropertyAssignMatcher $propertyAssignMatcher, PropertyDefaultAssignDetector $propertyDefaultAssignDetector, NullTypeAssignDetector $nullTypeAssignDetector, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, TypeFactory $typeFactory, NodeTypeResolver $nodeTypeResolver, ExprAnalyzer $exprAnalyzer, ValueResolver $valueResolver) { $this->constructorAssignDetector = $constructorAssignDetector; $this->propertyAssignMatcher = $propertyAssignMatcher; @@ -81,15 +81,15 @@ final class AssignToPropertyTypeInferer $this->exprAnalyzer = $exprAnalyzer; $this->valueResolver = $valueResolver; } - public function inferPropertyInClassLike(\PhpParser\Node\Stmt\Property $property, string $propertyName, \PhpParser\Node\Stmt\ClassLike $classLike) : ?\PHPStan\Type\Type + public function inferPropertyInClassLike(Property $property, string $propertyName, ClassLike $classLike) : ?Type { $assignedExprTypes = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classLike->stmts, function (\PhpParser\Node $node) use($propertyName, &$assignedExprTypes) { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classLike->stmts, function (Node $node) use($propertyName, &$assignedExprTypes) { + if (!$node instanceof Assign) { return null; } $expr = $this->propertyAssignMatcher->matchPropertyAssignExpr($node, $propertyName); - if (!$expr instanceof \PhpParser\Node\Expr) { + if (!$expr instanceof Expr) { return null; } if ($this->exprAnalyzer->isNonTypedFromParam($node->expr)) { @@ -99,7 +99,7 @@ final class AssignToPropertyTypeInferer return null; }); if ($this->shouldAddNullType($classLike, $propertyName, $assignedExprTypes)) { - $assignedExprTypes[] = new \PHPStan\Type\NullType(); + $assignedExprTypes[] = new NullType(); } if ($assignedExprTypes === []) { return null; @@ -111,9 +111,9 @@ final class AssignToPropertyTypeInferer } return $inferredType; } - private function shouldSkipWithDifferentDefaultValueType(?\PhpParser\Node\Expr $expr, \PHPStan\Type\Type $inferredType) : bool + private function shouldSkipWithDifferentDefaultValueType(?Expr $expr, Type $inferredType) : bool { - if (!$expr instanceof \PhpParser\Node\Expr) { + if (!$expr instanceof Expr) { return \false; } if ($this->valueResolver->isNull($expr)) { @@ -122,18 +122,18 @@ final class AssignToPropertyTypeInferer $defaultType = $this->nodeTypeResolver->getNativeType($expr); return $inferredType->isSuperTypeOf($defaultType)->no(); } - private function resolveExprStaticTypeIncludingDimFetch(\PhpParser\Node\Expr\Assign $assign) : \PHPStan\Type\Type + private function resolveExprStaticTypeIncludingDimFetch(Assign $assign) : Type { $exprStaticType = $this->nodeTypeResolver->getType($assign->expr); - if ($assign->var instanceof \PhpParser\Node\Expr\ArrayDimFetch) { - return new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), $exprStaticType); + if ($assign->var instanceof ArrayDimFetch) { + return new ArrayType(new MixedType(), $exprStaticType); } return $exprStaticType; } /** * @param Type[] $assignedExprTypes */ - private function shouldAddNullType(\PhpParser\Node\Stmt\ClassLike $classLike, string $propertyName, array $assignedExprTypes) : bool + private function shouldAddNullType(ClassLike $classLike, string $propertyName, array $assignedExprTypes) : bool { $hasPropertyDefaultValue = $this->propertyDefaultAssignDetector->detect($classLike, $propertyName); $isAssignedInConstructor = $this->constructorAssignDetector->isPropertyAssigned($classLike, $propertyName); diff --git a/rules/TypeDeclaration/TypeInferer/ParamTypeInferer.php b/rules/TypeDeclaration/TypeInferer/ParamTypeInferer.php index 6a0782b1c26..28a1b6ab4eb 100644 --- a/rules/TypeDeclaration/TypeInferer/ParamTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/ParamTypeInferer.php @@ -30,28 +30,28 @@ final class ParamTypeInferer /** * @param ParamTypeInfererInterface[] $paramTypeInferers */ - public function __construct(\Rector\TypeDeclaration\TypeAnalyzer\GenericClassStringTypeNormalizer $genericClassStringTypeNormalizer, array $paramTypeInferers, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(GenericClassStringTypeNormalizer $genericClassStringTypeNormalizer, array $paramTypeInferers, NodeTypeResolver $nodeTypeResolver) { $this->genericClassStringTypeNormalizer = $genericClassStringTypeNormalizer; $this->paramTypeInferers = $paramTypeInferers; $this->nodeTypeResolver = $nodeTypeResolver; } - public function inferParam(\PhpParser\Node\Param $param) : \PHPStan\Type\Type + public function inferParam(Param $param) : Type { foreach ($this->paramTypeInferers as $paramTypeInferer) { $paramType = $paramTypeInferer->inferParam($param); - if ($paramType instanceof \PHPStan\Type\MixedType) { + if ($paramType instanceof MixedType) { continue; } $inferedType = $this->genericClassStringTypeNormalizer->normalize($paramType); - if ($param->default instanceof \PhpParser\Node) { + if ($param->default instanceof Node) { $paramDefaultType = $this->nodeTypeResolver->getType($param->default); if (!$paramDefaultType instanceof $inferedType) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } } return $inferedType; } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } } diff --git a/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/FunctionLikeDocParamTypeInferer.php b/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/FunctionLikeDocParamTypeInferer.php index e2163b851e3..b8d6e36dd07 100644 --- a/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/FunctionLikeDocParamTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/FunctionLikeDocParamTypeInferer.php @@ -14,7 +14,7 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Rector\Core\PhpParser\Node\BetterNodeFinder; use Rector\NodeNameResolver\NodeNameResolver; use Rector\TypeDeclaration\Contract\TypeInferer\ParamTypeInfererInterface; -final class FunctionLikeDocParamTypeInferer implements \Rector\TypeDeclaration\Contract\TypeInferer\ParamTypeInfererInterface +final class FunctionLikeDocParamTypeInferer implements ParamTypeInfererInterface { /** * @readonly @@ -31,38 +31,38 @@ final class FunctionLikeDocParamTypeInferer implements \Rector\TypeDeclaration\C * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeNameResolver $nodeNameResolver, PhpDocInfoFactory $phpDocInfoFactory, BetterNodeFinder $betterNodeFinder) { $this->nodeNameResolver = $nodeNameResolver; $this->phpDocInfoFactory = $phpDocInfoFactory; $this->betterNodeFinder = $betterNodeFinder; } - public function inferParam(\PhpParser\Node\Param $param) : \PHPStan\Type\Type + public function inferParam(Param $param) : Type { $functionLike = $this->resolveScopeNode($param); - if (!$functionLike instanceof \PhpParser\Node\FunctionLike) { - return new \PHPStan\Type\MixedType(); + if (!$functionLike instanceof FunctionLike) { + return new MixedType(); } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike); $paramTypesByName = $phpDocInfo->getParamTypesByName(); if ($paramTypesByName === []) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } return $this->matchParamNodeFromDoc($paramTypesByName, $param); } /** * @return ClassMethod|Function_|null */ - private function resolveScopeNode(\PhpParser\Node\Param $param) : ?\PhpParser\Node + private function resolveScopeNode(Param $param) : ?Node { - return $this->betterNodeFinder->findParentByTypes($param, [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class]); + return $this->betterNodeFinder->findParentByTypes($param, [ClassMethod::class, Function_::class]); } /** * @param Type[] $paramWithTypes */ - private function matchParamNodeFromDoc(array $paramWithTypes, \PhpParser\Node\Param $param) : \PHPStan\Type\Type + private function matchParamNodeFromDoc(array $paramWithTypes, Param $param) : Type { $paramNodeName = '$' . $this->nodeNameResolver->getName($param->var); - return $paramWithTypes[$paramNodeName] ?? new \PHPStan\Type\MixedType(); + return $paramWithTypes[$paramNodeName] ?? new MixedType(); } } diff --git a/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/GetterNodeParamTypeInferer.php b/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/GetterNodeParamTypeInferer.php index 618ed2421c6..0947b0ccfc5 100644 --- a/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/GetterNodeParamTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/GetterNodeParamTypeInferer.php @@ -19,7 +19,7 @@ use Rector\NodeNameResolver\NodeNameResolver; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\TypeDeclaration\Contract\TypeInferer\ParamTypeInfererInterface; use RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser; -final class GetterNodeParamTypeInferer implements \Rector\TypeDeclaration\Contract\TypeInferer\ParamTypeInfererInterface +final class GetterNodeParamTypeInferer implements ParamTypeInfererInterface { /** * @readonly @@ -51,7 +51,7 @@ final class GetterNodeParamTypeInferer implements \Rector\TypeDeclaration\Contra * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\Core\NodeManipulator\PropertyFetchAssignManipulator $propertyFetchAssignManipulator, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(PropertyFetchAssignManipulator $propertyFetchAssignManipulator, PropertyFetchAnalyzer $propertyFetchAnalyzer, PhpDocInfoFactory $phpDocInfoFactory, NodeNameResolver $nodeNameResolver, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, BetterNodeFinder $betterNodeFinder) { $this->propertyFetchAssignManipulator = $propertyFetchAssignManipulator; $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; @@ -60,24 +60,24 @@ final class GetterNodeParamTypeInferer implements \Rector\TypeDeclaration\Contra $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->betterNodeFinder = $betterNodeFinder; } - public function inferParam(\PhpParser\Node\Param $param) : \PHPStan\Type\Type + public function inferParam(Param $param) : Type { - $class = $this->betterNodeFinder->findParentType($param, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { - return new \PHPStan\Type\MixedType(); + $class = $this->betterNodeFinder->findParentType($param, Class_::class); + if (!$class instanceof Class_) { + return new MixedType(); } /** @var ClassMethod $classMethod */ - $classMethod = $param->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $classMethod = $param->getAttribute(AttributeKey::PARENT_NODE); /** @var string $paramName */ $paramName = $this->nodeNameResolver->getName($param); $propertyNames = $this->propertyFetchAssignManipulator->getPropertyNamesOfAssignOfVariable($classMethod, $paramName); if ($propertyNames === []) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } - $returnType = new \PHPStan\Type\MixedType(); + $returnType = new MixedType(); // resolve property assigns - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($class, function (\PhpParser\Node $node) use($propertyNames, &$returnType) : ?int { - if (!$node instanceof \PhpParser\Node\Stmt\Return_) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($class, function (Node $node) use($propertyNames, &$returnType) : ?int { + if (!$node instanceof Return_) { return null; } if ($node->expr === null) { @@ -88,17 +88,17 @@ final class GetterNodeParamTypeInferer implements \Rector\TypeDeclaration\Contra return null; } // what is return type? - $classMethod = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassMethod::class); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $this->betterNodeFinder->findParentType($node, ClassMethod::class); + if (!$classMethod instanceof ClassMethod) { return null; } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); $methodReturnType = $phpDocInfo->getReturnType(); - if ($methodReturnType instanceof \PHPStan\Type\MixedType) { + if ($methodReturnType instanceof MixedType) { return null; } $returnType = $methodReturnType; - return \PhpParser\NodeTraverser::STOP_TRAVERSAL; + return NodeTraverser::STOP_TRAVERSAL; }); return $returnType; } diff --git a/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/KnownArrayParamTypeInferer.php b/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/KnownArrayParamTypeInferer.php index c5f20377f1f..d4007e9da82 100644 --- a/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/KnownArrayParamTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/KnownArrayParamTypeInferer.php @@ -13,7 +13,7 @@ use PHPStan\Type\Type; use Rector\Core\PhpParser\Node\BetterNodeFinder; use Rector\NodeNameResolver\NodeNameResolver; use Rector\TypeDeclaration\Contract\TypeInferer\ParamTypeInfererInterface; -final class KnownArrayParamTypeInferer implements \Rector\TypeDeclaration\Contract\TypeInferer\ParamTypeInfererInterface +final class KnownArrayParamTypeInferer implements ParamTypeInfererInterface { /** * @readonly @@ -30,28 +30,28 @@ final class KnownArrayParamTypeInferer implements \Rector\TypeDeclaration\Contra * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider, BetterNodeFinder $betterNodeFinder) { $this->nodeNameResolver = $nodeNameResolver; $this->reflectionProvider = $reflectionProvider; $this->betterNodeFinder = $betterNodeFinder; } - public function inferParam(\PhpParser\Node\Param $param) : \PHPStan\Type\Type + public function inferParam(Param $param) : Type { - $class = $this->betterNodeFinder->findParentType($param, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { - return new \PHPStan\Type\MixedType(); + $class = $this->betterNodeFinder->findParentType($param, Class_::class); + if (!$class instanceof Class_) { + return new MixedType(); } $className = (string) $this->nodeNameResolver->getName($class); if (!$this->reflectionProvider->hasClass($className)) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } $classReflection = $this->reflectionProvider->getClass($className); $paramName = $this->nodeNameResolver->getName($param); // @todo create map later if ($paramName === 'configs' && $classReflection->isSubclassOf('Symfony\\Component\\DependencyInjection\\Extension\\Extension')) { - return new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\StringType()); + return new ArrayType(new MixedType(), new StringType()); } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } } diff --git a/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/PHPUnitDataProviderParamTypeInferer.php b/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/PHPUnitDataProviderParamTypeInferer.php index d633e461f7b..5ff556ce605 100644 --- a/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/PHPUnitDataProviderParamTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/PHPUnitDataProviderParamTypeInferer.php @@ -26,7 +26,7 @@ use Rector\NodeTypeResolver\NodeTypeResolver; use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory; use Rector\TypeDeclaration\Contract\TypeInferer\ParamTypeInfererInterface; use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; -final class PHPUnitDataProviderParamTypeInferer implements \Rector\TypeDeclaration\Contract\TypeInferer\ParamTypeInfererInterface +final class PHPUnitDataProviderParamTypeInferer implements ParamTypeInfererInterface { /** * @see https://regex101.com/r/hW09Vt/1 @@ -52,7 +52,7 @@ final class PHPUnitDataProviderParamTypeInferer implements \Rector\TypeDeclarati * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory */ private $phpDocInfoFactory; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory) + public function __construct(BetterNodeFinder $betterNodeFinder, TypeFactory $typeFactory, PhpDocInfoFactory $phpDocInfoFactory) { $this->betterNodeFinder = $betterNodeFinder; $this->typeFactory = $typeFactory; @@ -62,45 +62,45 @@ final class PHPUnitDataProviderParamTypeInferer implements \Rector\TypeDeclarati /** * @required */ - public function autowire(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) : void + public function autowire(NodeTypeResolver $nodeTypeResolver) : void { $this->nodeTypeResolver = $nodeTypeResolver; } - public function inferParam(\PhpParser\Node\Param $param) : \PHPStan\Type\Type + public function inferParam(Param $param) : Type { $dataProviderClassMethod = $this->resolveDataProviderClassMethod($param); - if (!$dataProviderClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { - return new \PHPStan\Type\MixedType(); + if (!$dataProviderClassMethod instanceof ClassMethod) { + return new MixedType(); } - $parameterPosition = $param->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARAMETER_POSITION); + $parameterPosition = $param->getAttribute(AttributeKey::PARAMETER_POSITION); if ($parameterPosition === null) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } /** @var Return_[] $returns */ - $returns = $this->betterNodeFinder->findInstanceOf((array) $dataProviderClassMethod->stmts, \PhpParser\Node\Stmt\Return_::class); + $returns = $this->betterNodeFinder->findInstanceOf((array) $dataProviderClassMethod->stmts, Return_::class); if ($returns !== []) { return $this->resolveReturnStaticArrayTypeByParameterPosition($returns, $parameterPosition); } /** @var Yield_[] $yields */ - $yields = $this->betterNodeFinder->findInstanceOf((array) $dataProviderClassMethod->stmts, \PhpParser\Node\Expr\Yield_::class); + $yields = $this->betterNodeFinder->findInstanceOf((array) $dataProviderClassMethod->stmts, Yield_::class); return $this->resolveYieldStaticArrayTypeByParameterPosition($yields, $parameterPosition); } - private function resolveDataProviderClassMethod(\PhpParser\Node\Param $param) : ?\PhpParser\Node\Stmt\ClassMethod + private function resolveDataProviderClassMethod(Param $param) : ?ClassMethod { $phpDocInfo = $this->getFunctionLikePhpDocInfo($param); $phpDocTagNode = $phpDocInfo->getByName('@dataProvider'); - if (!$phpDocTagNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) { + if (!$phpDocTagNode instanceof PhpDocTagNode) { return null; } - $class = $this->betterNodeFinder->findParentType($param, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($param, Class_::class); + if (!$class instanceof Class_) { return null; } - if (!$phpDocTagNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) { + if (!$phpDocTagNode->value instanceof GenericTagValueNode) { return null; } $content = $phpDocTagNode->value->value; - $match = \RectorPrefix20220607\Nette\Utils\Strings::match($content, self::METHOD_NAME_REGEX); + $match = Strings::match($content, self::METHOD_NAME_REGEX); if ($match === null) { return null; } @@ -110,30 +110,30 @@ final class PHPUnitDataProviderParamTypeInferer implements \Rector\TypeDeclarati /** * @param Return_[] $returns */ - private function resolveReturnStaticArrayTypeByParameterPosition(array $returns, int $parameterPosition) : \PHPStan\Type\Type + private function resolveReturnStaticArrayTypeByParameterPosition(array $returns, int $parameterPosition) : Type { $firstReturnedExpr = $returns[0]->expr; - if (!$firstReturnedExpr instanceof \PhpParser\Node\Expr\Array_) { - return new \PHPStan\Type\MixedType(); + if (!$firstReturnedExpr instanceof Array_) { + return new MixedType(); } $paramOnPositionTypes = $this->resolveParamOnPositionTypes($firstReturnedExpr, $parameterPosition); if ($paramOnPositionTypes === []) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } return $this->typeFactory->createMixedPassedOrUnionType($paramOnPositionTypes); } /** * @param Yield_[] $yields */ - private function resolveYieldStaticArrayTypeByParameterPosition(array $yields, int $parameterPosition) : \PHPStan\Type\Type + private function resolveYieldStaticArrayTypeByParameterPosition(array $yields, int $parameterPosition) : Type { $paramOnPositionTypes = []; foreach ($yields as $yield) { - if (!$yield->value instanceof \PhpParser\Node\Expr\Array_) { + if (!$yield->value instanceof Array_) { continue; } $type = $this->getTypeFromClassMethodYield($yield->value); - if (!$type instanceof \PHPStan\Type\Constant\ConstantArrayType) { + if (!$type instanceof ConstantArrayType) { return $type; } foreach ($type->getValueTypes() as $position => $valueType) { @@ -144,45 +144,45 @@ final class PHPUnitDataProviderParamTypeInferer implements \Rector\TypeDeclarati } } if ($paramOnPositionTypes === []) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } return $this->typeFactory->createMixedPassedOrUnionType($paramOnPositionTypes); } /** * @return \PHPStan\Type\MixedType|\PHPStan\Type\Constant\ConstantArrayType */ - private function getTypeFromClassMethodYield(\PhpParser\Node\Expr\Array_ $classMethodYieldArrayNode) + private function getTypeFromClassMethodYield(Array_ $classMethodYieldArrayNode) { $arrayTypes = $this->nodeTypeResolver->getType($classMethodYieldArrayNode); // impossible to resolve - if (!$arrayTypes instanceof \PHPStan\Type\Constant\ConstantArrayType) { - return new \PHPStan\Type\MixedType(); + if (!$arrayTypes instanceof ConstantArrayType) { + return new MixedType(); } return $arrayTypes; } - private function getFunctionLikePhpDocInfo(\PhpParser\Node\Param $param) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo + private function getFunctionLikePhpDocInfo(Param $param) : PhpDocInfo { - $parent = $param->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\FunctionLike) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $parent = $param->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof FunctionLike) { + throw new ShouldNotHappenException(); } return $this->phpDocInfoFactory->createFromNodeOrEmpty($parent); } /** * @return Type[] */ - private function resolveParamOnPositionTypes(\PhpParser\Node\Expr\Array_ $array, int $parameterPosition) : array + private function resolveParamOnPositionTypes(Array_ $array, int $parameterPosition) : array { $paramOnPositionTypes = []; foreach ($array->items as $singleDataProvidedSet) { - if (!$singleDataProvidedSet instanceof \PhpParser\Node\Expr\ArrayItem || !$singleDataProvidedSet->value instanceof \PhpParser\Node\Expr\Array_) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$singleDataProvidedSet instanceof ArrayItem || !$singleDataProvidedSet->value instanceof Array_) { + throw new ShouldNotHappenException(); } foreach ($singleDataProvidedSet->value->items as $position => $singleDataProvidedSetItem) { if ($position !== $parameterPosition) { continue; } - if (!$singleDataProvidedSetItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$singleDataProvidedSetItem instanceof ArrayItem) { continue; } $paramOnPositionTypes[] = $this->nodeTypeResolver->getType($singleDataProvidedSetItem->value); diff --git a/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/PropertyNodeParamTypeInferer.php b/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/PropertyNodeParamTypeInferer.php index 7b06145a74d..e465592eb3a 100644 --- a/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/PropertyNodeParamTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/PropertyNodeParamTypeInferer.php @@ -21,7 +21,7 @@ use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\StaticTypeMapper\StaticTypeMapper; use Rector\TypeDeclaration\Contract\TypeInferer\ParamTypeInfererInterface; use RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser; -final class PropertyNodeParamTypeInferer implements \Rector\TypeDeclaration\Contract\TypeInferer\ParamTypeInfererInterface +final class PropertyNodeParamTypeInferer implements ParamTypeInfererInterface { /** * @readonly @@ -63,7 +63,7 @@ final class PropertyNodeParamTypeInferer implements \Rector\TypeDeclaration\Cont * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(PropertyFetchAnalyzer $propertyFetchAnalyzer, NodeNameResolver $nodeNameResolver, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeTypeResolver $nodeTypeResolver, TypeFactory $typeFactory, BetterNodeFinder $betterNodeFinder, StaticTypeMapper $staticTypeMapper, NodeComparator $nodeComparator) { $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; $this->nodeNameResolver = $nodeNameResolver; @@ -74,28 +74,28 @@ final class PropertyNodeParamTypeInferer implements \Rector\TypeDeclaration\Cont $this->staticTypeMapper = $staticTypeMapper; $this->nodeComparator = $nodeComparator; } - public function inferParam(\PhpParser\Node\Param $param) : \PHPStan\Type\Type + public function inferParam(Param $param) : Type { - $classLike = $this->betterNodeFinder->findParentType($param, \PhpParser\Node\Stmt\Class_::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { - return new \PHPStan\Type\MixedType(); + $classLike = $this->betterNodeFinder->findParentType($param, Class_::class); + if (!$classLike instanceof Class_) { + return new MixedType(); } $paramName = $this->nodeNameResolver->getName($param); /** @var ClassMethod $classMethod */ - $classMethod = $param->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $classMethod = $param->getAttribute(AttributeKey::PARENT_NODE); $propertyStaticTypes = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classMethod, function (\PhpParser\Node $node) use($paramName, &$propertyStaticTypes) { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classMethod, function (Node $node) use($paramName, &$propertyStaticTypes) { + if (!$node instanceof Assign) { return null; } if (!$this->propertyFetchAnalyzer->isVariableAssignToThisPropertyFetch($node, $paramName)) { return null; } $exprType = $this->nodeTypeResolver->getType($node->expr); - $nodeExprType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($exprType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM); + $nodeExprType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($exprType, TypeKind::PARAM); $varType = $this->nodeTypeResolver->getType($node->var); - $nodeVarType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($varType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::ANY); - if ($nodeExprType instanceof \PhpParser\Node && !$this->nodeComparator->areNodesEqual($nodeExprType, $nodeVarType)) { + $nodeVarType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($varType, TypeKind::ANY); + if ($nodeExprType instanceof Node && !$this->nodeComparator->areNodesEqual($nodeExprType, $nodeVarType)) { return null; } $propertyStaticTypes[] = $varType; diff --git a/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/SplFixedArrayParamTypeInferer.php b/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/SplFixedArrayParamTypeInferer.php index 44d77903a88..a3fb35d852e 100644 --- a/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/SplFixedArrayParamTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/ParamTypeInferer/SplFixedArrayParamTypeInferer.php @@ -9,7 +9,7 @@ use PHPStan\Type\Type; use Rector\NodeTypeResolver\NodeTypeResolver; use Rector\TypeDeclaration\Contract\TypeInferer\ParamTypeInfererInterface; use Rector\TypeDeclaration\TypeInferer\SplArrayFixedTypeNarrower; -final class SplFixedArrayParamTypeInferer implements \Rector\TypeDeclaration\Contract\TypeInferer\ParamTypeInfererInterface +final class SplFixedArrayParamTypeInferer implements ParamTypeInfererInterface { /** * @readonly @@ -21,15 +21,15 @@ final class SplFixedArrayParamTypeInferer implements \Rector\TypeDeclaration\Con * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\TypeDeclaration\TypeInferer\SplArrayFixedTypeNarrower $splArrayFixedTypeNarrower, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(SplArrayFixedTypeNarrower $splArrayFixedTypeNarrower, NodeTypeResolver $nodeTypeResolver) { $this->splArrayFixedTypeNarrower = $splArrayFixedTypeNarrower; $this->nodeTypeResolver = $nodeTypeResolver; } - public function inferParam(\PhpParser\Node\Param $param) : \PHPStan\Type\Type + public function inferParam(Param $param) : Type { if ($param->type === null) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } $paramType = $this->nodeTypeResolver->getType($param->type); return $this->splArrayFixedTypeNarrower->narrow($paramType); diff --git a/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/AllAssignNodePropertyTypeInferer.php b/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/AllAssignNodePropertyTypeInferer.php index 029bff2adb2..9ee12296e83 100644 --- a/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/AllAssignNodePropertyTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/AllAssignNodePropertyTypeInferer.php @@ -26,16 +26,16 @@ final class AllAssignNodePropertyTypeInferer * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\TypeDeclaration\TypeInferer\AssignToPropertyTypeInferer $assignToPropertyTypeInferer, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(AssignToPropertyTypeInferer $assignToPropertyTypeInferer, NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder) { $this->assignToPropertyTypeInferer = $assignToPropertyTypeInferer; $this->nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; } - public function inferProperty(\PhpParser\Node\Stmt\Property $property) : ?\PHPStan\Type\Type + public function inferProperty(Property $property) : ?Type { - $classLike = $this->betterNodeFinder->findParentType($property, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($property, ClassLike::class); + if (!$classLike instanceof ClassLike) { return null; } $propertyName = $this->nodeNameResolver->getName($property); diff --git a/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/ConstructorPropertyTypeInferer.php b/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/ConstructorPropertyTypeInferer.php index 5366e6438f5..68b053c8a4a 100644 --- a/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/ConstructorPropertyTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/ConstructorPropertyTypeInferer.php @@ -92,7 +92,7 @@ final class ConstructorPropertyTypeInferer * @var \Rector\NodeTypeResolver\TypeComparator\TypeComparator */ private $typeComparator; - public function __construct(\Rector\Core\NodeManipulator\ClassMethodPropertyFetchManipulator $classMethodPropertyFetchManipulator, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\NodeAnalyzer\ParamAnalyzer $paramAnalyzer, \Rector\TypeDeclaration\TypeInferer\AssignToPropertyTypeInferer $assignToPropertyTypeInferer, \Rector\NodeTypeResolver\TypeComparator\TypeComparator $typeComparator) + public function __construct(ClassMethodPropertyFetchManipulator $classMethodPropertyFetchManipulator, ReflectionProvider $reflectionProvider, NodeNameResolver $nodeNameResolver, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, TypeFactory $typeFactory, StaticTypeMapper $staticTypeMapper, NodeTypeResolver $nodeTypeResolver, BetterNodeFinder $betterNodeFinder, ParamAnalyzer $paramAnalyzer, AssignToPropertyTypeInferer $assignToPropertyTypeInferer, TypeComparator $typeComparator) { $this->classMethodPropertyFetchManipulator = $classMethodPropertyFetchManipulator; $this->reflectionProvider = $reflectionProvider; @@ -106,20 +106,20 @@ final class ConstructorPropertyTypeInferer $this->assignToPropertyTypeInferer = $assignToPropertyTypeInferer; $this->typeComparator = $typeComparator; } - public function inferProperty(\PhpParser\Node\Stmt\Property $property) : ?\PHPStan\Type\Type + public function inferProperty(Property $property) : ?Type { - $classLike = $this->betterNodeFinder->findParentType($property, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($property, ClassLike::class); + if (!$classLike instanceof ClassLike) { return null; } - $classMethod = $classLike->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $classLike->getMethod(MethodName::CONSTRUCT); + if (!$classMethod instanceof ClassMethod) { return null; } $propertyName = $this->nodeNameResolver->getName($property); // 1. direct property = param assign $param = $this->classMethodPropertyFetchManipulator->findParamAssignToPropertyName($classMethod, $propertyName); - if ($param instanceof \PhpParser\Node\Param) { + if ($param instanceof Param) { if ($param->type === null) { return null; } @@ -136,16 +136,16 @@ final class ConstructorPropertyTypeInferer if ($resolvedTypes === []) { return null; } - $resolvedType = \count($resolvedTypes) === 1 ? $resolvedTypes[0] : \PHPStan\Type\TypeCombinator::union(...$resolvedTypes); + $resolvedType = \count($resolvedTypes) === 1 ? $resolvedTypes[0] : TypeCombinator::union(...$resolvedTypes); return $this->resolveType($property, $propertyName, $classLike, $resolvedType); } - private function resolveType(\PhpParser\Node\Stmt\Property $property, string $propertyName, \PhpParser\Node\Stmt\ClassLike $classLike, ?\PHPStan\Type\Type $resolvedType) : ?\PHPStan\Type\Type + private function resolveType(Property $property, string $propertyName, ClassLike $classLike, ?Type $resolvedType) : ?Type { - if (!$resolvedType instanceof \PHPStan\Type\Type) { + if (!$resolvedType instanceof Type) { return null; } $exactType = $this->assignToPropertyTypeInferer->inferPropertyInClassLike($property, $propertyName, $classLike); - if (!$exactType instanceof \PHPStan\Type\UnionType) { + if (!$exactType instanceof UnionType) { return $resolvedType; } if ($this->typeComparator->areTypesEqual($resolvedType, $exactType)) { @@ -153,39 +153,39 @@ final class ConstructorPropertyTypeInferer } return null; } - private function resolveFromParamType(\PhpParser\Node\Param $param, \PhpParser\Node\Stmt\ClassMethod $classMethod, string $propertyName) : \PHPStan\Type\Type + private function resolveFromParamType(Param $param, ClassMethod $classMethod, string $propertyName) : Type { $type = $this->resolveParamTypeToPHPStanType($param); - if ($type instanceof \PHPStan\Type\MixedType) { - return new \PHPStan\Type\MixedType(); + if ($type instanceof MixedType) { + return new MixedType(); } $types = []; // it's an array - annotation → make type more precise, if possible - if ($type instanceof \PHPStan\Type\ArrayType || $param->variadic) { + if ($type instanceof ArrayType || $param->variadic) { $types[] = $this->getResolveParamStaticTypeAsPHPStanType($classMethod, $propertyName); } else { $types[] = $type; } if ($this->isParamNullable($param)) { - $types[] = new \PHPStan\Type\NullType(); + $types[] = new NullType(); } return $this->typeFactory->createMixedPassedOrUnionType($types); } - private function resolveParamTypeToPHPStanType(\PhpParser\Node\Param $param) : \PHPStan\Type\Type + private function resolveParamTypeToPHPStanType(Param $param) : Type { if ($param->type === null) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } if ($this->paramAnalyzer->isNullable($param)) { /** @var NullableType $type */ $type = $param->type; $types = []; - $types[] = new \PHPStan\Type\NullType(); + $types[] = new NullType(); $types[] = $this->staticTypeMapper->mapPhpParserNodePHPStanType($type->type); return $this->typeFactory->createMixedPassedOrUnionType($types); } // special case for alias - if ($param->type instanceof \PhpParser\Node\Name\FullyQualified) { + if ($param->type instanceof FullyQualified) { $type = $this->resolveFullyQualifiedOrAliasedObjectType($param); if ($type !== null) { return $type; @@ -193,35 +193,35 @@ final class ConstructorPropertyTypeInferer } return $this->staticTypeMapper->mapPhpParserNodePHPStanType($param->type); } - private function getResolveParamStaticTypeAsPHPStanType(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $propertyName) : \PHPStan\Type\Type + private function getResolveParamStaticTypeAsPHPStanType(ClassMethod $classMethod, string $propertyName) : Type { - $paramStaticType = new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); - $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (\PhpParser\Node $node) use($propertyName, &$paramStaticType) : ?int { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + $paramStaticType = new ArrayType(new MixedType(), new MixedType()); + $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) use($propertyName, &$paramStaticType) : ?int { + if (!$node instanceof Variable) { return null; } if (!$this->nodeNameResolver->isName($node, $propertyName)) { return null; } $paramStaticType = $this->nodeTypeResolver->getType($node); - return \PhpParser\NodeTraverser::STOP_TRAVERSAL; + return NodeTraverser::STOP_TRAVERSAL; }); return $paramStaticType; } - private function isParamNullable(\PhpParser\Node\Param $param) : bool + private function isParamNullable(Param $param) : bool { if ($this->paramAnalyzer->isNullable($param)) { return \true; } if ($param->default !== null) { $defaultValueStaticType = $this->nodeTypeResolver->getType($param->default); - if ($defaultValueStaticType instanceof \PHPStan\Type\NullType) { + if ($defaultValueStaticType instanceof NullType) { return \true; } } return \false; } - private function resolveFullyQualifiedOrAliasedObjectType(\PhpParser\Node\Param $param) : ?\PHPStan\Type\Type + private function resolveFullyQualifiedOrAliasedObjectType(Param $param) : ?Type { if ($param->type === null) { return null; @@ -230,18 +230,18 @@ final class ConstructorPropertyTypeInferer if (!\is_string($fullyQualifiedName)) { return null; } - $originalName = $param->type->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NAME); - if (!$originalName instanceof \PhpParser\Node\Name) { + $originalName = $param->type->getAttribute(AttributeKey::ORIGINAL_NAME); + if (!$originalName instanceof Name) { return null; } // if the FQN has different ending than the original, it was aliased and we need to return the alias if (\substr_compare($fullyQualifiedName, '\\' . $originalName->toString(), -\strlen('\\' . $originalName->toString())) !== 0) { $className = $originalName->toString(); if ($this->reflectionProvider->hasClass($className)) { - return new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($className); + return new FullyQualifiedObjectType($className); } // @note: $fullyQualifiedName is a guess, needs real life test - return new \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType($originalName->toString(), $fullyQualifiedName); + return new AliasedObjectType($originalName->toString(), $fullyQualifiedName); } return null; } diff --git a/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/DefaultValuePropertyTypeInferer.php b/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/DefaultValuePropertyTypeInferer.php index 56cb6e74ee0..03eac58637a 100644 --- a/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/DefaultValuePropertyTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/DefaultValuePropertyTypeInferer.php @@ -17,15 +17,15 @@ final class DefaultValuePropertyTypeInferer * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(NodeTypeResolver $nodeTypeResolver) { $this->nodeTypeResolver = $nodeTypeResolver; } - public function inferProperty(\PhpParser\Node\Stmt\Property $property) : ?\PHPStan\Type\Type + public function inferProperty(Property $property) : ?Type { $propertyProperty = $property->props[0]; if ($propertyProperty->default === null) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } return $this->nodeTypeResolver->getType($propertyProperty->default); } diff --git a/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/GetterTypeDeclarationPropertyTypeInferer.php b/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/GetterTypeDeclarationPropertyTypeInferer.php index ce05f879c93..fbb4ae74970 100644 --- a/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/GetterTypeDeclarationPropertyTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/PropertyTypeInferer/GetterTypeDeclarationPropertyTypeInferer.php @@ -35,17 +35,17 @@ final class GetterTypeDeclarationPropertyTypeInferer * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\TypeDeclaration\FunctionLikeReturnTypeResolver $functionLikeReturnTypeResolver, \Rector\TypeDeclaration\NodeAnalyzer\ClassMethodAndPropertyAnalyzer $classMethodAndPropertyAnalyzer, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(FunctionLikeReturnTypeResolver $functionLikeReturnTypeResolver, ClassMethodAndPropertyAnalyzer $classMethodAndPropertyAnalyzer, NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder) { $this->functionLikeReturnTypeResolver = $functionLikeReturnTypeResolver; $this->classMethodAndPropertyAnalyzer = $classMethodAndPropertyAnalyzer; $this->nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; } - public function inferProperty(\PhpParser\Node\Stmt\Property $property) : ?\PHPStan\Type\Type + public function inferProperty(Property $property) : ?Type { - $classLike = $this->betterNodeFinder->findParentType($property, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + $classLike = $this->betterNodeFinder->findParentType($property, ClassLike::class); + if (!$classLike instanceof Class_) { // anonymous class return null; } @@ -57,10 +57,10 @@ final class GetterTypeDeclarationPropertyTypeInferer } $returnType = $this->functionLikeReturnTypeResolver->resolveFunctionLikeReturnTypeToPHPStanType($classMethod); // let PhpDoc solve that later for more precise type - if ($returnType instanceof \PHPStan\Type\ArrayType) { - return new \PHPStan\Type\MixedType(); + if ($returnType instanceof ArrayType) { + return new MixedType(); } - if (!$returnType instanceof \PHPStan\Type\MixedType) { + if (!$returnType instanceof MixedType) { return $returnType; } } diff --git a/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer.php b/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer.php index b929b7c1c42..b1f13714e9f 100644 --- a/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer.php @@ -87,7 +87,7 @@ final class ReturnTypeInferer /** * @param ReturnTypeInfererInterface[] $returnTypeInferers */ - public function __construct(array $returnTypeInferers, \Rector\TypeDeclaration\TypeNormalizer $typeNormalizer, \Rector\TypeDeclaration\Sorter\PriorityAwareSorter $priorityAwareSorter, \Rector\TypeDeclaration\TypeAnalyzer\GenericClassStringTypeNormalizer $genericClassStringTypeNormalizer, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider, \RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(array $returnTypeInferers, TypeNormalizer $typeNormalizer, PriorityAwareSorter $priorityAwareSorter, GenericClassStringTypeNormalizer $genericClassStringTypeNormalizer, PhpVersionProvider $phpVersionProvider, ParameterProvider $parameterProvider, BetterNodeFinder $betterNodeFinder, ReflectionProvider $reflectionProvider, NodeTypeResolver $nodeTypeResolver, NodeNameResolver $nodeNameResolver) { $this->typeNormalizer = $typeNormalizer; $this->genericClassStringTypeNormalizer = $genericClassStringTypeNormalizer; @@ -102,7 +102,7 @@ final class ReturnTypeInferer /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $functionLike */ - public function inferFunctionLike($functionLike) : \PHPStan\Type\Type + public function inferFunctionLike($functionLike) : Type { return $this->inferFunctionLikeWithExcludedInferers($functionLike, []); } @@ -110,86 +110,86 @@ final class ReturnTypeInferer * @param array> $excludedInferers * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $functionLike */ - public function inferFunctionLikeWithExcludedInferers($functionLike, array $excludedInferers) : \PHPStan\Type\Type + public function inferFunctionLikeWithExcludedInferers($functionLike, array $excludedInferers) : Type { - $isSupportedStaticReturnType = $this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::STATIC_RETURN_TYPE); - $isAutoImport = $this->parameterProvider->provideBoolParameter(\Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES); + $isSupportedStaticReturnType = $this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::STATIC_RETURN_TYPE); + $isAutoImport = $this->parameterProvider->provideBoolParameter(Option::AUTO_IMPORT_NAMES); if ($this->isAutoImportWithFullyQualifiedReturn($isAutoImport, $functionLike)) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } foreach ($this->returnTypeInferers as $returnTypeInferer) { if ($this->shouldSkipExcludedTypeInferer($returnTypeInferer, $excludedInferers)) { continue; } $originalType = $returnTypeInferer->inferFunctionLike($functionLike); - if ($originalType instanceof \PHPStan\Type\MixedType) { + if ($originalType instanceof MixedType) { continue; } $type = $this->typeNormalizer->normalizeArrayTypeAndArrayNever($originalType); // in case of void, check return type of children methods - if ($type instanceof \PHPStan\Type\MixedType) { + if ($type instanceof MixedType) { continue; } $type = $this->verifyStaticType($type, $isSupportedStaticReturnType); - if (!$type instanceof \PHPStan\Type\Type) { + if (!$type instanceof Type) { continue; } $type = $this->verifyThisType($type, $functionLike); - if (!$type instanceof \PHPStan\Type\Type) { + if (!$type instanceof Type) { continue; } // normalize ConstStringType to ClassStringType $resolvedType = $this->genericClassStringTypeNormalizer->normalize($type); return $this->resolveTypeWithVoidHandling($functionLike, $resolvedType); } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } - public function verifyStaticType(\PHPStan\Type\Type $type, bool $isSupportedStaticReturnType) : ?\PHPStan\Type\Type + public function verifyStaticType(Type $type, bool $isSupportedStaticReturnType) : ?Type { if ($this->isStaticType($type)) { /** @var TypeWithClassName $type */ return $this->resolveStaticType($isSupportedStaticReturnType, $type); } - if ($type instanceof \PHPStan\Type\UnionType) { + if ($type instanceof UnionType) { return $this->resolveUnionStaticTypes($type, $isSupportedStaticReturnType); } return $type; } - public function verifyThisType(\PHPStan\Type\Type $type, \PhpParser\Node\FunctionLike $functionLike) : ?\PHPStan\Type\Type + public function verifyThisType(Type $type, FunctionLike $functionLike) : ?Type { - if (!$type instanceof \PHPStan\Type\ThisType) { + if (!$type instanceof ThisType) { return $type; } - $class = $this->betterNodeFinder->findParentType($functionLike, \PhpParser\Node\Stmt\Class_::class); + $class = $this->betterNodeFinder->findParentType($functionLike, Class_::class); $objectType = $type->getStaticObjectType(); $objectTypeClassName = $objectType->getClassName(); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + if (!$class instanceof Class_) { return $type; } if ($this->nodeNameResolver->isName($class, $objectTypeClassName)) { return $type; } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $functionLike */ - private function resolveTypeWithVoidHandling($functionLike, \PHPStan\Type\Type $resolvedType) : \PHPStan\Type\Type + private function resolveTypeWithVoidHandling($functionLike, Type $resolvedType) : Type { - if ($resolvedType instanceof \PHPStan\Type\VoidType) { - $hasReturnValue = (bool) $this->betterNodeFinder->findFirstInFunctionLikeScoped($functionLike, function (\PhpParser\Node $subNode) : bool { - if (!$subNode instanceof \PhpParser\Node\Stmt\Return_) { + if ($resolvedType instanceof VoidType) { + $hasReturnValue = (bool) $this->betterNodeFinder->findFirstInFunctionLikeScoped($functionLike, function (Node $subNode) : bool { + if (!$subNode instanceof Return_) { return \false; } - return $subNode->expr instanceof \PhpParser\Node\Expr; + return $subNode->expr instanceof Expr; }); if ($hasReturnValue) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } } - if ($resolvedType instanceof \PHPStan\Type\UnionType) { + if ($resolvedType instanceof UnionType) { $benevolentUnionTypeIntegerType = $this->resolveBenevolentUnionTypeInteger($functionLike, $resolvedType); - if ($benevolentUnionTypeIntegerType instanceof \PHPStan\Type\IntegerType) { + if ($benevolentUnionTypeIntegerType instanceof IntegerType) { return $benevolentUnionTypeIntegerType; } } @@ -199,19 +199,19 @@ final class ReturnTypeInferer * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $functionLike * @return \PHPStan\Type\UnionType|\PHPStan\Type\IntegerType */ - private function resolveBenevolentUnionTypeInteger($functionLike, \PHPStan\Type\UnionType $unionType) + private function resolveBenevolentUnionTypeInteger($functionLike, UnionType $unionType) { $types = $unionType->getTypes(); $countTypes = \count($types); if ($countTypes !== 2) { return $unionType; } - if (!($types[0] instanceof \PHPStan\Type\IntegerType && $types[1] instanceof \PHPStan\Type\StringType)) { + if (!($types[0] instanceof IntegerType && $types[1] instanceof StringType)) { return $unionType; } - $returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($functionLike, \PhpParser\Node\Stmt\Return_::class); - $returnsWithExpr = \array_filter($returns, function (\PhpParser\Node\Stmt\Return_ $return) : bool { - return $return->expr instanceof \PhpParser\Node\Expr; + $returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($functionLike, Return_::class); + $returnsWithExpr = \array_filter($returns, function (Return_ $return) : bool { + return $return->expr instanceof Expr; }); if ($returns !== $returnsWithExpr) { return $unionType; @@ -223,24 +223,24 @@ final class ReturnTypeInferer /** @var Expr $expr */ $expr = $returnWithExpr->expr; $type = $this->nodeTypeResolver->getType($expr); - if (!$type instanceof \PHPStan\Type\BenevolentUnionType) { + if (!$type instanceof BenevolentUnionType) { return $unionType; } } return $types[0]; } - private function isAutoImportWithFullyQualifiedReturn(bool $isAutoImport, \PhpParser\Node\FunctionLike $functionLike) : bool + private function isAutoImportWithFullyQualifiedReturn(bool $isAutoImport, FunctionLike $functionLike) : bool { if (!$isAutoImport) { return \false; } - if (!$functionLike instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$functionLike instanceof ClassMethod) { return \false; } if ($this->isNamespacedFullyQualified($functionLike->returnType)) { return \true; } - if (!$functionLike->returnType instanceof \PhpParser\Node\UnionType) { + if (!$functionLike->returnType instanceof PhpParserUnionType) { return \false; } $types = $functionLike->returnType->types; @@ -251,21 +251,21 @@ final class ReturnTypeInferer } return \false; } - private function isNamespacedFullyQualified(?\PhpParser\Node $node) : bool + private function isNamespacedFullyQualified(?Node $node) : bool { - return $node instanceof \PhpParser\Node\Name\FullyQualified && \strpos($node->toString(), '\\') !== \false; + return $node instanceof FullyQualified && \strpos($node->toString(), '\\') !== \false; } - private function isStaticType(\PHPStan\Type\Type $type) : bool + private function isStaticType(Type $type) : bool { - if (!$type instanceof \PHPStan\Type\TypeWithClassName) { + if (!$type instanceof TypeWithClassName) { return \false; } - return $type->getClassName() === \Rector\Core\Enum\ObjectReference::STATIC; + return $type->getClassName() === ObjectReference::STATIC; } /** * @param array> $excludedInferers */ - private function shouldSkipExcludedTypeInferer(\Rector\TypeDeclaration\Contract\TypeInferer\ReturnTypeInfererInterface $returnTypeInferer, array $excludedInferers) : bool + private function shouldSkipExcludedTypeInferer(ReturnTypeInfererInterface $returnTypeInferer, array $excludedInferers) : bool { foreach ($excludedInferers as $excludedInferer) { if (\is_a($returnTypeInferer, $excludedInferer)) { @@ -277,7 +277,7 @@ final class ReturnTypeInferer /** * @return \PHPStan\Type\UnionType|null */ - private function resolveUnionStaticTypes(\PHPStan\Type\UnionType $unionType, bool $isSupportedStaticReturnType) + private function resolveUnionStaticTypes(UnionType $unionType, bool $isSupportedStaticReturnType) { $resolvedTypes = []; $hasStatic = \false; @@ -285,7 +285,7 @@ final class ReturnTypeInferer if ($this->isStaticType($unionedType)) { /** @var FullyQualifiedObjectType $unionedType */ $classReflection = $this->reflectionProvider->getClass($unionedType->getClassName()); - $resolvedTypes[] = new \PHPStan\Type\ThisType($classReflection); + $resolvedTypes[] = new ThisType($classReflection); $hasStatic = \true; continue; } @@ -298,17 +298,17 @@ final class ReturnTypeInferer if (!$isSupportedStaticReturnType) { return null; } - return new \PHPStan\Type\UnionType($resolvedTypes); + return new UnionType($resolvedTypes); } - private function resolveStaticType(bool $isSupportedStaticReturnType, \PHPStan\Type\TypeWithClassName $typeWithClassName) : ?\PHPStan\Type\ThisType + private function resolveStaticType(bool $isSupportedStaticReturnType, TypeWithClassName $typeWithClassName) : ?ThisType { if (!$isSupportedStaticReturnType) { return null; } $classReflection = $typeWithClassName->getClassReflection(); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$classReflection instanceof ClassReflection) { + throw new ShouldNotHappenException(); } - return new \PHPStan\Type\ThisType($classReflection); + return new ThisType($classReflection); } } diff --git a/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer/ReturnTagReturnTypeInfererTypeInferer.php b/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer/ReturnTagReturnTypeInfererTypeInferer.php index 7e2a944f2eb..31ceb3c49f3 100644 --- a/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer/ReturnTagReturnTypeInfererTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer/ReturnTagReturnTypeInfererTypeInferer.php @@ -7,18 +7,18 @@ use PhpParser\Node\FunctionLike; use PHPStan\Type\Type; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Rector\TypeDeclaration\Contract\TypeInferer\ReturnTypeInfererInterface; -final class ReturnTagReturnTypeInfererTypeInferer implements \Rector\TypeDeclaration\Contract\TypeInferer\ReturnTypeInfererInterface +final class ReturnTagReturnTypeInfererTypeInferer implements ReturnTypeInfererInterface { /** * @readonly * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory */ private $phpDocInfoFactory; - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory) { $this->phpDocInfoFactory = $phpDocInfoFactory; } - public function inferFunctionLike(\PhpParser\Node\FunctionLike $functionLike) : \PHPStan\Type\Type + public function inferFunctionLike(FunctionLike $functionLike) : Type { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike); return $phpDocInfo->getReturnType(); diff --git a/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer/ReturnTypeDeclarationReturnTypeInfererTypeInferer.php b/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer/ReturnTypeDeclarationReturnTypeInfererTypeInferer.php index 9c846273fc4..0b0da5b37ad 100644 --- a/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer/ReturnTypeDeclarationReturnTypeInfererTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer/ReturnTypeDeclarationReturnTypeInfererTypeInferer.php @@ -9,7 +9,7 @@ use PHPStan\Type\Type; use Rector\NodeNameResolver\NodeNameResolver; use Rector\TypeDeclaration\Contract\TypeInferer\ReturnTypeInfererInterface; use Rector\TypeDeclaration\FunctionLikeReturnTypeResolver; -final class ReturnTypeDeclarationReturnTypeInfererTypeInferer implements \Rector\TypeDeclaration\Contract\TypeInferer\ReturnTypeInfererInterface +final class ReturnTypeDeclarationReturnTypeInfererTypeInferer implements ReturnTypeInfererInterface { /** * @readonly @@ -21,19 +21,19 @@ final class ReturnTypeDeclarationReturnTypeInfererTypeInferer implements \Rector * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\TypeDeclaration\FunctionLikeReturnTypeResolver $functionLikeReturnTypeResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(FunctionLikeReturnTypeResolver $functionLikeReturnTypeResolver, NodeNameResolver $nodeNameResolver) { $this->functionLikeReturnTypeResolver = $functionLikeReturnTypeResolver; $this->nodeNameResolver = $nodeNameResolver; } - public function inferFunctionLike(\PhpParser\Node\FunctionLike $functionLike) : \PHPStan\Type\Type + public function inferFunctionLike(FunctionLike $functionLike) : Type { if ($functionLike->getReturnType() === null) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } // resolve later with more precise type, e.g. Type[] if ($this->nodeNameResolver->isNames($functionLike->getReturnType(), ['array', 'iterable'])) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } return $this->functionLikeReturnTypeResolver->resolveFunctionLikeReturnTypeToPHPStanType($functionLike); } diff --git a/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer/ReturnedNodesReturnTypeInfererTypeInferer.php b/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer/ReturnedNodesReturnTypeInfererTypeInferer.php index 04d1e676f4d..b9941c51ff6 100644 --- a/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer/ReturnedNodesReturnTypeInfererTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer/ReturnedNodesReturnTypeInfererTypeInferer.php @@ -28,7 +28,7 @@ use Rector\TypeDeclaration\Contract\TypeInferer\ReturnTypeInfererInterface; use Rector\TypeDeclaration\TypeInferer\SilentVoidResolver; use Rector\TypeDeclaration\TypeInferer\SplArrayFixedTypeNarrower; use RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser; -final class ReturnedNodesReturnTypeInfererTypeInferer implements \Rector\TypeDeclaration\Contract\TypeInferer\ReturnTypeInfererInterface +final class ReturnedNodesReturnTypeInfererTypeInferer implements ReturnTypeInfererInterface { /** * @readonly @@ -75,7 +75,7 @@ final class ReturnedNodesReturnTypeInfererTypeInferer implements \Rector\TypeDec * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\TypeDeclaration\TypeInferer\SilentVoidResolver $silentVoidResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \Rector\TypeDeclaration\TypeInferer\SplArrayFixedTypeNarrower $splArrayFixedTypeNarrower, \Rector\Core\PhpParser\AstResolver $reflectionAstResolver, \Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(SilentVoidResolver $silentVoidResolver, NodeTypeResolver $nodeTypeResolver, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, TypeFactory $typeFactory, SplArrayFixedTypeNarrower $splArrayFixedTypeNarrower, AstResolver $reflectionAstResolver, NodePrinterInterface $nodePrinter, ReflectionResolver $reflectionResolver, BetterNodeFinder $betterNodeFinder) { $this->silentVoidResolver = $silentVoidResolver; $this->nodeTypeResolver = $nodeTypeResolver; @@ -87,14 +87,14 @@ final class ReturnedNodesReturnTypeInfererTypeInferer implements \Rector\TypeDec $this->reflectionResolver = $reflectionResolver; $this->betterNodeFinder = $betterNodeFinder; } - public function inferFunctionLike(\PhpParser\Node\FunctionLike $functionLike) : \PHPStan\Type\Type + public function inferFunctionLike(FunctionLike $functionLike) : Type { - $classLike = $this->betterNodeFinder->findParentType($functionLike, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { - return new \PHPStan\Type\MixedType(); + $classLike = $this->betterNodeFinder->findParentType($functionLike, ClassLike::class); + if (!$classLike instanceof ClassLike) { + return new MixedType(); } - if ($functionLike instanceof \PhpParser\Node\Stmt\ClassMethod && $classLike instanceof \PhpParser\Node\Stmt\Interface_) { - return new \PHPStan\Type\MixedType(); + if ($functionLike instanceof ClassMethod && $classLike instanceof Interface_) { + return new MixedType(); } $types = []; $localReturnNodes = $this->collectReturns($functionLike); @@ -108,7 +108,7 @@ final class ReturnedNodesReturnTypeInfererTypeInferer implements \Rector\TypeDec $types[] = $this->splArrayFixedTypeNarrower->narrow($returnedExprType); } if ($this->silentVoidResolver->hasSilentVoid($functionLike)) { - $types[] = new \PHPStan\Type\VoidType(); + $types[] = new VoidType(); } return $this->typeFactory->createMixedPassedOrUnionType($types); } @@ -119,15 +119,15 @@ final class ReturnedNodesReturnTypeInfererTypeInferer implements \Rector\TypeDec /** * @return Return_[] */ - private function collectReturns(\PhpParser\Node\FunctionLike $functionLike) : array + private function collectReturns(FunctionLike $functionLike) : array { $returns = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $functionLike->getStmts(), function (\PhpParser\Node $node) use(&$returns) : ?int { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $functionLike->getStmts(), function (Node $node) use(&$returns) : ?int { // skip Return_ nodes in nested functions or switch statements - if ($node instanceof \PhpParser\Node\FunctionLike) { - return \PhpParser\NodeTraverser::DONT_TRAVERSE_CHILDREN; + if ($node instanceof FunctionLike) { + return NodeTraverser::DONT_TRAVERSE_CHILDREN; } - if (!$node instanceof \PhpParser\Node\Stmt\Return_) { + if (!$node instanceof Return_) { return null; } $returns[] = $node; @@ -139,69 +139,69 @@ final class ReturnedNodesReturnTypeInfererTypeInferer implements \Rector\TypeDec * @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Interface_|\PhpParser\Node\Stmt\Trait_ $classLike * @return \PHPStan\Type\VoidType|\PHPStan\Type\MixedType */ - private function resolveNoLocalReturnNodes($classLike, \PhpParser\Node\FunctionLike $functionLike) + private function resolveNoLocalReturnNodes($classLike, FunctionLike $functionLike) { // void type if (!$this->isAbstractMethod($classLike, $functionLike)) { - return new \PHPStan\Type\VoidType(); + return new VoidType(); } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } /** * @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Interface_|\PhpParser\Node\Stmt\Trait_ $classLike */ - private function isAbstractMethod($classLike, \PhpParser\Node\FunctionLike $functionLike) : bool + private function isAbstractMethod($classLike, FunctionLike $functionLike) : bool { - if ($functionLike instanceof \PhpParser\Node\Stmt\ClassMethod && $functionLike->isAbstract()) { + if ($functionLike instanceof ClassMethod && $functionLike->isAbstract()) { return \true; } - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + if (!$classLike instanceof Class_) { return \false; } return $classLike->isAbstract(); } - private function inferFromReturnedMethodCall(\PhpParser\Node\Stmt\Return_ $return, \PhpParser\Node\FunctionLike $originalFunctionLike) : \PHPStan\Type\Type + private function inferFromReturnedMethodCall(Return_ $return, FunctionLike $originalFunctionLike) : Type { - if (!$return->expr instanceof \PhpParser\Node\Expr\MethodCall) { - return new \PHPStan\Type\MixedType(); + if (!$return->expr instanceof MethodCall) { + return new MixedType(); } $methodReflection = $this->reflectionResolver->resolveMethodReflectionFromMethodCall($return->expr); - if (!$methodReflection instanceof \PHPStan\Reflection\MethodReflection) { - return new \PHPStan\Type\MixedType(); + if (!$methodReflection instanceof MethodReflection) { + return new MixedType(); } return $this->resolveClassMethod($methodReflection, $originalFunctionLike); } - private function isArrayTypeMixed(\PHPStan\Type\Type $type) : bool + private function isArrayTypeMixed(Type $type) : bool { - if (!$type instanceof \PHPStan\Type\ArrayType) { + if (!$type instanceof ArrayType) { return \false; } - if (!$type->getItemType() instanceof \PHPStan\Type\MixedType) { + if (!$type->getItemType() instanceof MixedType) { return \false; } - return $type->getKeyType() instanceof \PHPStan\Type\MixedType; + return $type->getKeyType() instanceof MixedType; } - private function correctWithNestedType(\PHPStan\Type\Type $resolvedType, \PhpParser\Node\Stmt\Return_ $return, \PhpParser\Node\FunctionLike $functionLike) : \PHPStan\Type\Type + private function correctWithNestedType(Type $resolvedType, Return_ $return, FunctionLike $functionLike) : Type { - if ($resolvedType instanceof \PHPStan\Type\MixedType || $this->isArrayTypeMixed($resolvedType)) { + if ($resolvedType instanceof MixedType || $this->isArrayTypeMixed($resolvedType)) { $correctedType = $this->inferFromReturnedMethodCall($return, $functionLike); // override only if has some extra value - if (!$correctedType instanceof \PHPStan\Type\MixedType && !$correctedType instanceof \PHPStan\Type\VoidType) { + if (!$correctedType instanceof MixedType && !$correctedType instanceof VoidType) { return $correctedType; } } return $resolvedType; } - private function resolveClassMethod(\PHPStan\Reflection\MethodReflection $methodReflection, \PhpParser\Node\FunctionLike $originalFunctionLike) : \PHPStan\Type\Type + private function resolveClassMethod(MethodReflection $methodReflection, FunctionLike $originalFunctionLike) : Type { $classMethod = $this->reflectionAstResolver->resolveClassMethodFromMethodReflection($methodReflection); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { - return new \PHPStan\Type\MixedType(); + if (!$classMethod instanceof ClassMethod) { + return new MixedType(); } $classMethodCacheKey = $this->nodePrinter->print($classMethod); $functionLikeCacheKey = $this->nodePrinter->print($originalFunctionLike); if ($classMethodCacheKey === $functionLikeCacheKey) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } return $this->inferFunctionLike($classMethod); } diff --git a/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer/SetterNodeReturnTypeInfererTypeInferer.php b/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer/SetterNodeReturnTypeInfererTypeInferer.php index 76d39c8c890..7940757e0fa 100644 --- a/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer/SetterNodeReturnTypeInfererTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer/SetterNodeReturnTypeInfererTypeInferer.php @@ -18,7 +18,7 @@ use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory; use Rector\TypeDeclaration\Contract\TypeInferer\ReturnTypeInfererInterface; use Rector\TypeDeclaration\TypeInferer\AssignToPropertyTypeInferer; -final class SetterNodeReturnTypeInfererTypeInferer implements \Rector\TypeDeclaration\Contract\TypeInferer\ReturnTypeInfererInterface +final class SetterNodeReturnTypeInfererTypeInferer implements ReturnTypeInfererInterface { /** * @readonly @@ -50,7 +50,7 @@ final class SetterNodeReturnTypeInfererTypeInferer implements \Rector\TypeDeclar * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\TypeDeclaration\TypeInferer\AssignToPropertyTypeInferer $assignToPropertyTypeInferer, \Rector\Core\NodeManipulator\FunctionLikeManipulator $functionLikeManipulator, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\AstResolver $astResolver, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(AssignToPropertyTypeInferer $assignToPropertyTypeInferer, FunctionLikeManipulator $functionLikeManipulator, TypeFactory $typeFactory, BetterNodeFinder $betterNodeFinder, AstResolver $astResolver, ReflectionResolver $reflectionResolver) { $this->assignToPropertyTypeInferer = $assignToPropertyTypeInferer; $this->functionLikeManipulator = $functionLikeManipulator; @@ -59,33 +59,33 @@ final class SetterNodeReturnTypeInfererTypeInferer implements \Rector\TypeDeclar $this->astResolver = $astResolver; $this->reflectionResolver = $reflectionResolver; } - public function inferFunctionLike(\PhpParser\Node\FunctionLike $functionLike) : \PHPStan\Type\Type + public function inferFunctionLike(FunctionLike $functionLike) : Type { - $classLike = $this->betterNodeFinder->findParentType($functionLike, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { - return new \PHPStan\Type\MixedType(); + $classLike = $this->betterNodeFinder->findParentType($functionLike, ClassLike::class); + if (!$classLike instanceof ClassLike) { + return new MixedType(); } $returnedPropertyNames = $this->functionLikeManipulator->getReturnedLocalPropertyNames($functionLike); $classReflection = $this->reflectionResolver->resolveClassReflection($classLike); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { - return new \PHPStan\Type\MixedType(); + if (!$classReflection instanceof ClassReflection) { + return new MixedType(); } $types = []; - $scope = $classLike->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $classLike->getAttribute(AttributeKey::SCOPE); foreach ($returnedPropertyNames as $returnedPropertyName) { if (!$classReflection->hasProperty($returnedPropertyName)) { continue; } $propertyReflection = $classReflection->getProperty($returnedPropertyName, $scope); - if (!$propertyReflection instanceof \PHPStan\Reflection\Php\PhpPropertyReflection) { + if (!$propertyReflection instanceof PhpPropertyReflection) { continue; } $property = $this->astResolver->resolvePropertyFromPropertyReflection($propertyReflection); - if (!$property instanceof \PhpParser\Node\Stmt\Property) { + if (!$property instanceof Property) { continue; } $inferredPropertyType = $this->assignToPropertyTypeInferer->inferPropertyInClassLike($property, $returnedPropertyName, $classLike); - if (!$inferredPropertyType instanceof \PHPStan\Type\Type) { + if (!$inferredPropertyType instanceof Type) { continue; } $types[] = $inferredPropertyType; diff --git a/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer/YieldNodesReturnTypeInfererTypeInferer.php b/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer/YieldNodesReturnTypeInfererTypeInferer.php index 6dca6685f45..af5bc8b1f47 100644 --- a/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer/YieldNodesReturnTypeInfererTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/ReturnTypeInferer/YieldNodesReturnTypeInfererTypeInferer.php @@ -20,7 +20,7 @@ use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedGenericObjectType; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use Rector\TypeDeclaration\Contract\TypeInferer\ReturnTypeInfererInterface; use RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser; -final class YieldNodesReturnTypeInfererTypeInferer implements \Rector\TypeDeclaration\Contract\TypeInferer\ReturnTypeInfererInterface +final class YieldNodesReturnTypeInfererTypeInferer implements ReturnTypeInfererInterface { /** * @readonly @@ -42,44 +42,44 @@ final class YieldNodesReturnTypeInfererTypeInferer implements \Rector\TypeDeclar * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeTypeResolver $nodeTypeResolver, TypeFactory $typeFactory, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver) { $this->nodeTypeResolver = $nodeTypeResolver; $this->typeFactory = $typeFactory; $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->nodeNameResolver = $nodeNameResolver; } - public function inferFunctionLike(\PhpParser\Node\FunctionLike $functionLike) : \PHPStan\Type\Type + public function inferFunctionLike(FunctionLike $functionLike) : Type { $yieldNodes = $this->findCurrentScopeYieldNodes($functionLike); if ($yieldNodes === []) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } $types = []; foreach ($yieldNodes as $yieldNode) { $value = $this->resolveYieldValue($yieldNode); - if (!$value instanceof \PhpParser\Node\Expr) { + if (!$value instanceof Expr) { continue; } $resolvedType = $this->nodeTypeResolver->getType($value); - if ($resolvedType instanceof \PHPStan\Type\MixedType) { + if ($resolvedType instanceof MixedType) { continue; } $types[] = $resolvedType; } $returnType = $functionLike->getReturnType(); $className = 'Generator'; - if ($returnType instanceof \PhpParser\Node\Identifier && $returnType->name === 'iterable') { + if ($returnType instanceof Identifier && $returnType->name === 'iterable') { $className = 'Iterator'; } - if ($returnType instanceof \PhpParser\Node\Name && !$this->nodeNameResolver->isName($returnType, 'Generator')) { + if ($returnType instanceof Name && !$this->nodeNameResolver->isName($returnType, 'Generator')) { $className = $this->nodeNameResolver->getName($returnType); } if ($types === []) { - return new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($className); + return new FullyQualifiedObjectType($className); } $types = $this->typeFactory->createMixedPassedOrUnionType($types); - return new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedGenericObjectType($className, [$types]); + return new FullyQualifiedGenericObjectType($className, [$types]); } public function getPriority() : int { @@ -88,15 +88,15 @@ final class YieldNodesReturnTypeInfererTypeInferer implements \Rector\TypeDeclar /** * @return Yield_[]|YieldFrom[] */ - private function findCurrentScopeYieldNodes(\PhpParser\Node\FunctionLike $functionLike) : array + private function findCurrentScopeYieldNodes(FunctionLike $functionLike) : array { $yieldNodes = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $functionLike->getStmts(), function (\PhpParser\Node $node) use(&$yieldNodes) : ?int { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $functionLike->getStmts(), function (Node $node) use(&$yieldNodes) : ?int { // skip nested scope - if ($node instanceof \PhpParser\Node\FunctionLike) { - return \PhpParser\NodeTraverser::DONT_TRAVERSE_CHILDREN; + if ($node instanceof FunctionLike) { + return NodeTraverser::DONT_TRAVERSE_CHILDREN; } - if (!$node instanceof \PhpParser\Node\Expr\Yield_ && !$node instanceof \PhpParser\Node\Expr\YieldFrom) { + if (!$node instanceof Yield_ && !$node instanceof YieldFrom) { return null; } $yieldNodes[] = $node; @@ -107,9 +107,9 @@ final class YieldNodesReturnTypeInfererTypeInferer implements \Rector\TypeDeclar /** * @param \PhpParser\Node\Expr\Yield_|\PhpParser\Node\Expr\YieldFrom $yieldExpr */ - private function resolveYieldValue($yieldExpr) : ?\PhpParser\Node\Expr + private function resolveYieldValue($yieldExpr) : ?Expr { - if ($yieldExpr instanceof \PhpParser\Node\Expr\Yield_) { + if ($yieldExpr instanceof Yield_) { return $yieldExpr->value; } return $yieldExpr->expr; diff --git a/rules/TypeDeclaration/TypeInferer/SilentVoidResolver.php b/rules/TypeDeclaration/TypeInferer/SilentVoidResolver.php index 0a3422ab87e..57a9da322da 100644 --- a/rules/TypeDeclaration/TypeInferer/SilentVoidResolver.php +++ b/rules/TypeDeclaration/TypeInferer/SilentVoidResolver.php @@ -25,7 +25,7 @@ final class SilentVoidResolver * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(BetterNodeFinder $betterNodeFinder) { $this->betterNodeFinder = $betterNodeFinder; } @@ -34,18 +34,18 @@ final class SilentVoidResolver */ public function hasExclusiveVoid($functionLike) : bool { - $classLike = $this->betterNodeFinder->findParentType($functionLike, \PhpParser\Node\Stmt\ClassLike::class); - if ($classLike instanceof \PhpParser\Node\Stmt\Interface_) { + $classLike = $this->betterNodeFinder->findParentType($functionLike, ClassLike::class); + if ($classLike instanceof Interface_) { return \false; } if ($this->hasNeverType($functionLike)) { return \false; } - if ($this->betterNodeFinder->hasInstancesOfInFunctionLikeScoped($functionLike, \PhpParser\Node\Expr\Yield_::class)) { + if ($this->betterNodeFinder->hasInstancesOfInFunctionLikeScoped($functionLike, Yield_::class)) { return \false; } /** @var Return_[] $returns */ - $returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($functionLike, \PhpParser\Node\Stmt\Return_::class); + $returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($functionLike, Return_::class); foreach ($returns as $return) { if ($return->expr !== null) { return \false; @@ -53,9 +53,9 @@ final class SilentVoidResolver } return \true; } - public function hasSilentVoid(\PhpParser\Node\FunctionLike $functionLike) : bool + public function hasSilentVoid(FunctionLike $functionLike) : bool { - if ($functionLike instanceof \PhpParser\Node\Expr\ArrowFunction) { + if ($functionLike instanceof ArrowFunction) { return \false; } if ($this->hasStmtsAlwaysReturn((array) $functionLike->getStmts())) { @@ -63,14 +63,14 @@ final class SilentVoidResolver } foreach ((array) $functionLike->getStmts() as $stmt) { // has switch with always return - if ($stmt instanceof \PhpParser\Node\Stmt\Switch_ && $this->isSwitchWithAlwaysReturn($stmt)) { + if ($stmt instanceof Switch_ && $this->isSwitchWithAlwaysReturn($stmt)) { return \false; } // is part of try/catch - if ($stmt instanceof \PhpParser\Node\Stmt\TryCatch && $this->isTryCatchAlwaysReturn($stmt)) { + if ($stmt instanceof TryCatch && $this->isTryCatchAlwaysReturn($stmt)) { return \false; } - if ($stmt instanceof \PhpParser\Node\Stmt\Throw_) { + if ($stmt instanceof Throw_) { return \false; } } @@ -82,17 +82,17 @@ final class SilentVoidResolver private function hasStmtsAlwaysReturn(array $stmts) : bool { foreach ($stmts as $stmt) { - if ($stmt instanceof \PhpParser\Node\Stmt\Expression) { + if ($stmt instanceof Expression) { $stmt = $stmt->expr; } // is 1st level return - if ($stmt instanceof \PhpParser\Node\Stmt\Return_) { + if ($stmt instanceof Return_) { return \true; } } return \false; } - private function isSwitchWithAlwaysReturn(\PhpParser\Node\Stmt\Switch_ $switch) : bool + private function isSwitchWithAlwaysReturn(Switch_ $switch) : bool { $hasDefault = \false; foreach ($switch->cases as $case) { @@ -108,7 +108,7 @@ final class SilentVoidResolver // has same amount of returns as switches return \count($switch->cases) === $casesWithReturnCount; } - private function isTryCatchAlwaysReturn(\PhpParser\Node\Stmt\TryCatch $tryCatch) : bool + private function isTryCatchAlwaysReturn(TryCatch $tryCatch) : bool { if (!$this->hasStmtsAlwaysReturn($tryCatch->stmts)) { return \false; @@ -124,14 +124,14 @@ final class SilentVoidResolver */ private function hasNeverType($functionLike) : bool { - return $this->betterNodeFinder->hasInstancesOf($functionLike, [\PhpParser\Node\Stmt\Throw_::class]); + return $this->betterNodeFinder->hasInstancesOf($functionLike, [Throw_::class]); } - private function resolveReturnCount(\PhpParser\Node\Stmt\Switch_ $switch) : int + private function resolveReturnCount(Switch_ $switch) : int { $casesWithReturnCount = 0; foreach ($switch->cases as $case) { foreach ($case->stmts as $caseStmt) { - if (!$caseStmt instanceof \PhpParser\Node\Stmt\Return_) { + if (!$caseStmt instanceof Return_) { continue; } ++$casesWithReturnCount; diff --git a/rules/TypeDeclaration/TypeInferer/SplArrayFixedTypeNarrower.php b/rules/TypeDeclaration/TypeInferer/SplArrayFixedTypeNarrower.php index 81e53db9c27..18b7850382b 100644 --- a/rules/TypeDeclaration/TypeInferer/SplArrayFixedTypeNarrower.php +++ b/rules/TypeDeclaration/TypeInferer/SplArrayFixedTypeNarrower.php @@ -9,27 +9,27 @@ use PHPStan\Type\Type; use PHPStan\Type\TypeWithClassName; final class SplArrayFixedTypeNarrower { - public function narrow(\PHPStan\Type\Type $paramType) : \PHPStan\Type\Type + public function narrow(Type $paramType) : Type { - if ($paramType->isSuperTypeOf(new \PHPStan\Type\ObjectType('SplFixedArray'))->no()) { + if ($paramType->isSuperTypeOf(new ObjectType('SplFixedArray'))->no()) { return $paramType; } - if (!$paramType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$paramType instanceof TypeWithClassName) { return $paramType; } - if ($paramType instanceof \PHPStan\Type\Generic\GenericObjectType) { + if ($paramType instanceof GenericObjectType) { return $paramType; } $types = []; if ($paramType->getClassName() === 'PhpCsFixer\\Tokenizer\\Tokens') { - $types[] = new \PHPStan\Type\ObjectType('PhpCsFixer\\Tokenizer\\Token'); + $types[] = new ObjectType('PhpCsFixer\\Tokenizer\\Token'); } if ($paramType->getClassName() === 'PhpCsFixer\\Doctrine\\Annotation\\Tokens') { - $types[] = new \PHPStan\Type\ObjectType('PhpCsFixer\\Doctrine\\Annotation\\Token'); + $types[] = new ObjectType('PhpCsFixer\\Doctrine\\Annotation\\Token'); } if ($types === []) { return $paramType; } - return new \PHPStan\Type\Generic\GenericObjectType($paramType->getClassName(), $types); + return new GenericObjectType($paramType->getClassName(), $types); } } diff --git a/rules/TypeDeclaration/TypeInferer/VarDocPropertyTypeInferer.php b/rules/TypeDeclaration/TypeInferer/VarDocPropertyTypeInferer.php index 077ecb00824..31d78b3bb82 100644 --- a/rules/TypeDeclaration/TypeInferer/VarDocPropertyTypeInferer.php +++ b/rules/TypeDeclaration/TypeInferer/VarDocPropertyTypeInferer.php @@ -88,7 +88,7 @@ final class VarDocPropertyTypeInferer * @var \Rector\NodeTypeResolver\TypeComparator\TypeComparator */ private $typeComparator; - public function __construct(\Rector\TypeDeclaration\TypeAnalyzer\GenericClassStringTypeNormalizer $genericClassStringTypeNormalizer, \Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer\DefaultValuePropertyTypeInferer $defaultValuePropertyTypeInferer, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \Rector\PHPStanStaticTypeMapper\DoctrineTypeAnalyzer $doctrineTypeAnalyzer, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector $constructorAssignDetector, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\NodeFinder\PropertyFetchFinder $propertyFetchFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\NodeManipulator\PropertyManipulator $propertyManipulator, \Rector\TypeDeclaration\TypeInferer\AssignToPropertyTypeInferer $assignToPropertyTypeInferer, \Rector\NodeTypeResolver\TypeComparator\TypeComparator $typeComparator) + public function __construct(GenericClassStringTypeNormalizer $genericClassStringTypeNormalizer, DefaultValuePropertyTypeInferer $defaultValuePropertyTypeInferer, TypeFactory $typeFactory, DoctrineTypeAnalyzer $doctrineTypeAnalyzer, PhpDocInfoFactory $phpDocInfoFactory, ConstructorAssignDetector $constructorAssignDetector, BetterNodeFinder $betterNodeFinder, PropertyFetchFinder $propertyFetchFinder, NodeNameResolver $nodeNameResolver, PropertyManipulator $propertyManipulator, \Rector\TypeDeclaration\TypeInferer\AssignToPropertyTypeInferer $assignToPropertyTypeInferer, TypeComparator $typeComparator) { $this->genericClassStringTypeNormalizer = $genericClassStringTypeNormalizer; $this->defaultValuePropertyTypeInferer = $defaultValuePropertyTypeInferer; @@ -103,20 +103,20 @@ final class VarDocPropertyTypeInferer $this->assignToPropertyTypeInferer = $assignToPropertyTypeInferer; $this->typeComparator = $typeComparator; } - public function inferProperty(\PhpParser\Node\Stmt\Property $property) : \PHPStan\Type\Type + public function inferProperty(Property $property) : Type { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); $resolvedType = $phpDocInfo->getVarType(); - if ($resolvedType instanceof \PHPStan\Type\VoidType) { - return new \PHPStan\Type\MixedType(); + if ($resolvedType instanceof VoidType) { + return new MixedType(); } - $class = $this->betterNodeFinder->findParentType($property, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { - return new \PHPStan\Type\MixedType(); + $class = $this->betterNodeFinder->findParentType($property, Class_::class); + if (!$class instanceof Class_) { + return new MixedType(); } // default value type must be added to each resolved type if set $propertyDefaultValue = $property->props[0]->default; - if ($propertyDefaultValue instanceof \PhpParser\Node\Expr) { + if ($propertyDefaultValue instanceof Expr) { $resolvedType = $this->unionTypeWithDefaultExpr($property, $resolvedType); } else { $resolvedType = $this->makeNullableForAccessedBeforeInitialization($property, $resolvedType, $phpDocInfo); @@ -125,37 +125,37 @@ final class VarDocPropertyTypeInferer $propertyName = $this->nodeNameResolver->getName($property); $assignInferredPropertyType = $this->assignToPropertyTypeInferer->inferPropertyInClassLike($property, $propertyName, $class); if ($this->shouldAddNull($resolvedType, $assignInferredPropertyType)) { - $resolvedType = \PHPStan\Type\TypeCombinator::addNull($resolvedType); + $resolvedType = TypeCombinator::addNull($resolvedType); } if (!$this->typeComparator->areTypesPossiblyIncluded($resolvedType, $assignInferredPropertyType)) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } return $resolvedType; } - private function shouldAddNull(\PHPStan\Type\Type $resolvedType, ?\PHPStan\Type\Type $assignInferredPropertyType) : bool + private function shouldAddNull(Type $resolvedType, ?Type $assignInferredPropertyType) : bool { - if (!$assignInferredPropertyType instanceof \PHPStan\Type\Type) { + if (!$assignInferredPropertyType instanceof Type) { return \false; } - if (!$assignInferredPropertyType instanceof \PHPStan\Type\UnionType) { + if (!$assignInferredPropertyType instanceof UnionType) { return \false; } - if (!\PHPStan\Type\TypeCombinator::containsNull($assignInferredPropertyType)) { + if (!TypeCombinator::containsNull($assignInferredPropertyType)) { return \false; } - return !\PHPStan\Type\TypeCombinator::containsNull($resolvedType); + return !TypeCombinator::containsNull($resolvedType); } - private function makeNullableForAccessedBeforeInitialization(\PhpParser\Node\Stmt\Property $property, \PHPStan\Type\Type $resolvedType, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : \PHPStan\Type\Type + private function makeNullableForAccessedBeforeInitialization(Property $property, Type $resolvedType, PhpDocInfo $phpDocInfo) : Type { - $types = $resolvedType instanceof \PHPStan\Type\UnionType ? $resolvedType->getTypes() : [$resolvedType]; + $types = $resolvedType instanceof UnionType ? $resolvedType->getTypes() : [$resolvedType]; foreach ($types as $type) { - if ($type instanceof \PHPStan\Type\NullType) { + if ($type instanceof NullType) { return $resolvedType; } } - $classLike = $this->betterNodeFinder->findParentType($property, \PhpParser\Node\Stmt\Class_::class); + $classLike = $this->betterNodeFinder->findParentType($property, Class_::class); // not has parent Class_? return early - if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) { + if (!$classLike instanceof Class_) { return $resolvedType; } // is never accessed, return early @@ -172,35 +172,35 @@ final class VarDocPropertyTypeInferer if ($this->propertyManipulator->isAllowedReadOnly($property, $phpDocInfo)) { return $resolvedType; } - return new \PHPStan\Type\UnionType(\array_merge($types, [new \PHPStan\Type\NullType()])); + return new UnionType(\array_merge($types, [new NullType()])); } - private function shouldUnionWithDefaultValue(\PHPStan\Type\Type $defaultValueType, \PHPStan\Type\Type $type) : bool + private function shouldUnionWithDefaultValue(Type $defaultValueType, Type $type) : bool { - if ($defaultValueType instanceof \PHPStan\Type\MixedType) { + if ($defaultValueType instanceof MixedType) { return \false; } // skip empty array type (mixed[]) - if ($defaultValueType instanceof \PHPStan\Type\ArrayType && $defaultValueType->getItemType() instanceof \PHPStan\Type\NeverType && !$type instanceof \PHPStan\Type\MixedType) { + if ($defaultValueType instanceof ArrayType && $defaultValueType->getItemType() instanceof NeverType && !$type instanceof MixedType) { return \false; } - if ($type instanceof \PHPStan\Type\MixedType) { + if ($type instanceof MixedType) { return \true; } return !$this->doctrineTypeAnalyzer->isDoctrineCollectionWithIterableUnionType($type); } - private function unionWithDefaultValueType(\PHPStan\Type\Type $defaultValueType, \PHPStan\Type\Type $resolvedType) : \PHPStan\Type\Type + private function unionWithDefaultValueType(Type $defaultValueType, Type $resolvedType) : Type { $types = []; $types[] = $defaultValueType; - if (!$resolvedType instanceof \PHPStan\Type\MixedType) { + if (!$resolvedType instanceof MixedType) { $types[] = $resolvedType; } return $this->typeFactory->createMixedPassedOrUnionType($types); } - private function unionTypeWithDefaultExpr(\PhpParser\Node\Stmt\Property $property, \PHPStan\Type\Type $resolvedType) : \PHPStan\Type\Type + private function unionTypeWithDefaultExpr(Property $property, Type $resolvedType) : Type { $defaultValueType = $this->defaultValuePropertyTypeInferer->inferProperty($property); - if (!$defaultValueType instanceof \PHPStan\Type\Type) { + if (!$defaultValueType instanceof Type) { return $resolvedType; } if (!$this->shouldUnionWithDefaultValue($defaultValueType, $resolvedType)) { diff --git a/rules/TypeDeclaration/TypeNormalizer.php b/rules/TypeDeclaration/TypeNormalizer.php index 646ae28b3f2..8cfb2bcbb3b 100644 --- a/rules/TypeDeclaration/TypeNormalizer.php +++ b/rules/TypeDeclaration/TypeNormalizer.php @@ -35,22 +35,22 @@ final class TypeNormalizer * @var \Symplify\PackageBuilder\Reflection\PrivatesAccessor */ private $privatesAccessor; - public function __construct(\Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor $privatesAccessor) + public function __construct(TypeFactory $typeFactory, PrivatesAccessor $privatesAccessor) { $this->typeFactory = $typeFactory; $this->privatesAccessor = $privatesAccessor; } - public function convertConstantArrayTypeToArrayType(\PHPStan\Type\Constant\ConstantArrayType $constantArrayType) : ?\PHPStan\Type\ArrayType + public function convertConstantArrayTypeToArrayType(ConstantArrayType $constantArrayType) : ?ArrayType { $nonConstantValueTypes = []; - if ($constantArrayType->getItemType() instanceof \PHPStan\Type\UnionType) { + if ($constantArrayType->getItemType() instanceof UnionType) { /** @var UnionType $unionType */ $unionType = $constantArrayType->getItemType(); foreach ($unionType->getTypes() as $unionedType) { - if ($unionedType instanceof \PHPStan\Type\Constant\ConstantStringType) { - $stringType = new \PHPStan\Type\StringType(); + if ($unionedType instanceof ConstantStringType) { + $stringType = new StringType(); $nonConstantValueTypes[\get_class($stringType)] = $stringType; - } elseif ($unionedType instanceof \PHPStan\Type\ObjectType) { + } elseif ($unionedType instanceof ObjectType) { $nonConstantValueTypes[] = $unionedType; } else { return null; @@ -67,46 +67,46 @@ final class TypeNormalizer * ↓ * int[]|string[][]|bool[][] */ - public function normalizeArrayOfUnionToUnionArray(\PHPStan\Type\Type $type, int $arrayNesting = 1) : \PHPStan\Type\Type + public function normalizeArrayOfUnionToUnionArray(Type $type, int $arrayNesting = 1) : Type { - if (!$type instanceof \PHPStan\Type\ArrayType) { + if (!$type instanceof ArrayType) { return $type; } - if ($type instanceof \PHPStan\Type\Constant\ConstantArrayType && $arrayNesting === 1) { + if ($type instanceof ConstantArrayType && $arrayNesting === 1) { return $type; } // first collection of types if ($arrayNesting === 1) { $this->collectedNestedArrayTypes = []; } - if ($type->getItemType() instanceof \PHPStan\Type\ArrayType) { + if ($type->getItemType() instanceof ArrayType) { ++$arrayNesting; $this->normalizeArrayOfUnionToUnionArray($type->getItemType(), $arrayNesting); - } elseif ($type->getItemType() instanceof \PHPStan\Type\UnionType) { + } elseif ($type->getItemType() instanceof UnionType) { $this->collectNestedArrayTypeFromUnionType($type->getItemType(), $arrayNesting); } else { - $this->collectedNestedArrayTypes[] = new \Rector\TypeDeclaration\ValueObject\NestedArrayType($type->getItemType(), $arrayNesting, $type->getKeyType()); + $this->collectedNestedArrayTypes[] = new NestedArrayType($type->getItemType(), $arrayNesting, $type->getKeyType()); } return $this->createUnionedTypesFromArrayTypes($this->collectedNestedArrayTypes); } /** * From "string[]|mixed[]" based on empty array to to "string[]" */ - public function normalizeArrayTypeAndArrayNever(\PHPStan\Type\Type $type) : \PHPStan\Type\Type + public function normalizeArrayTypeAndArrayNever(Type $type) : Type { - return \PHPStan\Type\TypeTraverser::map($type, function (\PHPStan\Type\Type $traversedType, callable $traverserCallable) : Type { + return TypeTraverser::map($type, function (Type $traversedType, callable $traverserCallable) : Type { if ($this->isConstantArrayNever($traversedType)) { - \assert($traversedType instanceof \PHPStan\Type\Constant\ConstantArrayType); + \assert($traversedType instanceof ConstantArrayType); // not sure why, but with direct new node everything gets nulled to MixedType - $this->privatesAccessor->setPrivatePropertyOfClass($traversedType, 'keyType', new \PHPStan\Type\MixedType(), \PHPStan\Type\Type::class); - $this->privatesAccessor->setPrivatePropertyOfClass($traversedType, 'itemType', new \PHPStan\Type\MixedType(), \PHPStan\Type\Type::class); + $this->privatesAccessor->setPrivatePropertyOfClass($traversedType, 'keyType', new MixedType(), Type::class); + $this->privatesAccessor->setPrivatePropertyOfClass($traversedType, 'itemType', new MixedType(), Type::class); return $traversedType; } - if ($traversedType instanceof \PHPStan\Type\UnionType) { + if ($traversedType instanceof UnionType) { $traversedTypeTypes = $traversedType->getTypes(); $countTraversedTypes = \count($traversedTypeTypes); if ($this->isUnionMixedArrayNeverType($countTraversedTypes, $traversedTypeTypes)) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } $collectedTypes = $this->getCollectedTypes($traversedTypeTypes); $countCollectedTypes = \count($collectedTypes); @@ -115,15 +115,15 @@ final class TypeNormalizer return $this->typeFactory->createMixedPassedOrUnionType($collectedTypes); } } - if ($traversedType instanceof \PHPStan\Type\NeverType) { - return new \PHPStan\Type\MixedType(); + if ($traversedType instanceof NeverType) { + return new MixedType(); } return $traverserCallable($traversedType, $traverserCallable); }); } - private function isConstantArrayNever(\PHPStan\Type\Type $type) : bool + private function isConstantArrayNever(Type $type) : bool { - return $type instanceof \PHPStan\Type\Constant\ConstantArrayType && $type->getKeyType() instanceof \PHPStan\Type\NeverType && $type->getItemType() instanceof \PHPStan\Type\NeverType; + return $type instanceof ConstantArrayType && $type->getKeyType() instanceof NeverType && $type->getItemType() instanceof NeverType; } /** * @param Type[] $traversedTypeTypes @@ -151,24 +151,24 @@ final class TypeNormalizer /** * @param array $nonConstantValueTypes */ - private function createArrayTypeFromNonConstantValueTypes(array $nonConstantValueTypes) : \PHPStan\Type\ArrayType + private function createArrayTypeFromNonConstantValueTypes(array $nonConstantValueTypes) : ArrayType { $nonConstantValueTypes = \array_values($nonConstantValueTypes); if (\count($nonConstantValueTypes) > 1) { - $nonConstantValueType = new \PHPStan\Type\UnionType($nonConstantValueTypes); + $nonConstantValueType = new UnionType($nonConstantValueTypes); } else { $nonConstantValueType = $nonConstantValueTypes[0]; } - return new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), $nonConstantValueType); + return new ArrayType(new MixedType(), $nonConstantValueType); } - private function collectNestedArrayTypeFromUnionType(\PHPStan\Type\UnionType $unionType, int $arrayNesting) : void + private function collectNestedArrayTypeFromUnionType(UnionType $unionType, int $arrayNesting) : void { foreach ($unionType->getTypes() as $unionedType) { - if ($unionedType instanceof \PHPStan\Type\ArrayType) { + if ($unionedType instanceof ArrayType) { ++$arrayNesting; $this->normalizeArrayOfUnionToUnionArray($unionedType, $arrayNesting); } else { - $this->collectedNestedArrayTypes[] = new \Rector\TypeDeclaration\ValueObject\NestedArrayType($unionedType, $arrayNesting); + $this->collectedNestedArrayTypes[] = new NestedArrayType($unionedType, $arrayNesting); } } } @@ -182,21 +182,21 @@ final class TypeNormalizer foreach ($collectedNestedArrayTypes as $collectedNestedArrayType) { $arrayType = $collectedNestedArrayType->getType(); for ($i = 0; $i < $collectedNestedArrayType->getArrayNestingLevel(); ++$i) { - $arrayType = new \PHPStan\Type\ArrayType($collectedNestedArrayType->getKeyType(), $arrayType); + $arrayType = new ArrayType($collectedNestedArrayType->getKeyType(), $arrayType); } /** @var ArrayType $arrayType */ $unionedTypes[] = $arrayType; } if (\count($unionedTypes) > 1) { - return new \PHPStan\Type\UnionType($unionedTypes); + return new UnionType($unionedTypes); } return $unionedTypes[0]; } - private function isArrayNeverType(\PHPStan\Type\Type $type) : bool + private function isArrayNeverType(Type $type) : bool { - if (!$type instanceof \PHPStan\Type\ArrayType) { + if (!$type instanceof ArrayType) { return \false; } - return $type->getKeyType() instanceof \PHPStan\Type\NeverType && $type->getItemType() instanceof \PHPStan\Type\NeverType; + return $type->getKeyType() instanceof NeverType && $type->getItemType() instanceof NeverType; } } diff --git a/rules/TypeDeclaration/ValueObject/AddParamTypeDeclaration.php b/rules/TypeDeclaration/ValueObject/AddParamTypeDeclaration.php index cd7ef65eb63..86d5e3647e3 100644 --- a/rules/TypeDeclaration/ValueObject/AddParamTypeDeclaration.php +++ b/rules/TypeDeclaration/ValueObject/AddParamTypeDeclaration.php @@ -31,17 +31,17 @@ final class AddParamTypeDeclaration /** * @param int<0, max> $position */ - public function __construct(string $className, string $methodName, int $position, \PHPStan\Type\Type $paramType) + public function __construct(string $className, string $methodName, int $position, Type $paramType) { $this->className = $className; $this->methodName = $methodName; $this->position = $position; $this->paramType = $paramType; - \Rector\Core\Validation\RectorAssert::className($className); + RectorAssert::className($className); } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->className); + return new ObjectType($this->className); } public function getMethodName() : string { @@ -51,7 +51,7 @@ final class AddParamTypeDeclaration { return $this->position; } - public function getParamType() : \PHPStan\Type\Type + public function getParamType() : Type { return $this->paramType; } diff --git a/rules/TypeDeclaration/ValueObject/AddPropertyTypeDeclaration.php b/rules/TypeDeclaration/ValueObject/AddPropertyTypeDeclaration.php index 7c628e571d6..b79880348a3 100644 --- a/rules/TypeDeclaration/ValueObject/AddPropertyTypeDeclaration.php +++ b/rules/TypeDeclaration/ValueObject/AddPropertyTypeDeclaration.php @@ -22,12 +22,12 @@ final class AddPropertyTypeDeclaration * @var \PHPStan\Type\Type */ private $type; - public function __construct(string $class, string $propertyName, \PHPStan\Type\Type $type) + public function __construct(string $class, string $propertyName, Type $type) { $this->class = $class; $this->propertyName = $propertyName; $this->type = $type; - \Rector\Core\Validation\RectorAssert::className($class); + RectorAssert::className($class); } public function getClass() : string { @@ -37,7 +37,7 @@ final class AddPropertyTypeDeclaration { return $this->propertyName; } - public function getType() : \PHPStan\Type\Type + public function getType() : Type { return $this->type; } diff --git a/rules/TypeDeclaration/ValueObject/AddReturnTypeDeclaration.php b/rules/TypeDeclaration/ValueObject/AddReturnTypeDeclaration.php index f2f9d914a30..157264cc95c 100644 --- a/rules/TypeDeclaration/ValueObject/AddReturnTypeDeclaration.php +++ b/rules/TypeDeclaration/ValueObject/AddReturnTypeDeclaration.php @@ -23,12 +23,12 @@ final class AddReturnTypeDeclaration * @var \PHPStan\Type\Type */ private $returnType; - public function __construct(string $class, string $method, \PHPStan\Type\Type $returnType) + public function __construct(string $class, string $method, Type $returnType) { $this->class = $class; $this->method = $method; $this->returnType = $returnType; - \Rector\Core\Validation\RectorAssert::className($class); + RectorAssert::className($class); } public function getClass() : string { @@ -38,12 +38,12 @@ final class AddReturnTypeDeclaration { return $this->method; } - public function getReturnType() : \PHPStan\Type\Type + public function getReturnType() : Type { return $this->returnType; } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->class); + return new ObjectType($this->class); } } diff --git a/rules/TypeDeclaration/ValueObject/NestedArrayType.php b/rules/TypeDeclaration/ValueObject/NestedArrayType.php index b011061e097..67447090d71 100644 --- a/rules/TypeDeclaration/ValueObject/NestedArrayType.php +++ b/rules/TypeDeclaration/ValueObject/NestedArrayType.php @@ -22,13 +22,13 @@ final class NestedArrayType * @var \PHPStan\Type\Type|null */ private $keyType; - public function __construct(\PHPStan\Type\Type $type, int $arrayNestingLevel, ?\PHPStan\Type\Type $keyType = null) + public function __construct(Type $type, int $arrayNestingLevel, ?Type $keyType = null) { $this->type = $type; $this->arrayNestingLevel = $arrayNestingLevel; $this->keyType = $keyType; } - public function getType() : \PHPStan\Type\Type + public function getType() : Type { return $this->type; } @@ -36,11 +36,11 @@ final class NestedArrayType { return $this->arrayNestingLevel; } - public function getKeyType() : \PHPStan\Type\Type + public function getKeyType() : Type { - if ($this->keyType instanceof \PHPStan\Type\Type) { + if ($this->keyType instanceof Type) { return $this->keyType; } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } } diff --git a/rules/Visibility/Rector/ClassConst/ChangeConstantVisibilityRector.php b/rules/Visibility/Rector/ClassConst/ChangeConstantVisibilityRector.php index 7cdf8886f19..00efbfa3842 100644 --- a/rules/Visibility/Rector/ClassConst/ChangeConstantVisibilityRector.php +++ b/rules/Visibility/Rector/ClassConst/ChangeConstantVisibilityRector.php @@ -10,13 +10,13 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\Visibility; use Rector\Privatization\NodeManipulator\VisibilityManipulator; use Rector\Visibility\ValueObject\ChangeConstantVisibility; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Visibility\Rector\ClassConst\ChangeConstantVisibilityRector\ChangeConstantVisibilityRectorTest */ -final class ChangeConstantVisibilityRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class ChangeConstantVisibilityRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var ChangeConstantVisibility[] @@ -27,13 +27,13 @@ final class ChangeConstantVisibilityRector extends \Rector\Core\Rector\AbstractR * @var \Rector\Privatization\NodeManipulator\VisibilityManipulator */ private $visibilityManipulator; - public function __construct(\Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator) + public function __construct(VisibilityManipulator $visibilityManipulator) { $this->visibilityManipulator = $visibilityManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change visibility of constant from parent class.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change visibility of constant from parent class.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class FrameworkClass { protected const SOME_CONSTANT = 1; @@ -55,19 +55,19 @@ class MyClass extends FrameworkClass protected const SOME_CONSTANT = 1; } CODE_SAMPLE -, [new \Rector\Visibility\ValueObject\ChangeConstantVisibility('ParentObject', 'SOME_CONSTANT', \Rector\Core\ValueObject\Visibility::PROTECTED)])]); +, [new ChangeConstantVisibility('ParentObject', 'SOME_CONSTANT', Visibility::PROTECTED)])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassConst::class]; + return [ClassConst::class]; } /** * @param ClassConst $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->classConstantVisibilityChanges as $classConstantVisibilityChange) { if (!$this->isObjectType($node, $classConstantVisibilityChange->getObjectType())) { @@ -86,7 +86,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Visibility\ValueObject\ChangeConstantVisibility::class); + Assert::allIsAOf($configuration, ChangeConstantVisibility::class); $this->classConstantVisibilityChanges = $configuration; } } diff --git a/rules/Visibility/Rector/ClassMethod/ChangeMethodVisibilityRector.php b/rules/Visibility/Rector/ClassMethod/ChangeMethodVisibilityRector.php index aa7fb4a14d0..9417744a7f8 100644 --- a/rules/Visibility/Rector/ClassMethod/ChangeMethodVisibilityRector.php +++ b/rules/Visibility/Rector/ClassMethod/ChangeMethodVisibilityRector.php @@ -12,13 +12,13 @@ use Rector\Core\ValueObject\Visibility; use Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver; use Rector\Privatization\NodeManipulator\VisibilityManipulator; use Rector\Visibility\ValueObject\ChangeMethodVisibility; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector\ChangeMethodVisibilityRectorTest */ -final class ChangeMethodVisibilityRector extends \Rector\Core\Rector\AbstractScopeAwareRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class ChangeMethodVisibilityRector extends AbstractScopeAwareRector implements ConfigurableRectorInterface { /** * @var ChangeMethodVisibility[] @@ -34,14 +34,14 @@ final class ChangeMethodVisibilityRector extends \Rector\Core\Rector\AbstractSco * @var \Rector\Privatization\NodeManipulator\VisibilityManipulator */ private $visibilityManipulator; - public function __construct(\Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver $parentClassScopeResolver, \Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator) + public function __construct(ParentClassScopeResolver $parentClassScopeResolver, VisibilityManipulator $visibilityManipulator) { $this->parentClassScopeResolver = $parentClassScopeResolver; $this->visibilityManipulator = $visibilityManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change visibility of method from parent class.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change visibility of method from parent class.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class FrameworkClass { protected function someMethod() @@ -71,19 +71,19 @@ class MyClass extends FrameworkClass } } CODE_SAMPLE -, [new \Rector\Visibility\ValueObject\ChangeMethodVisibility('FrameworkClass', 'someMethod', \Rector\Core\ValueObject\Visibility::PROTECTED)])]); +, [new ChangeMethodVisibility('FrameworkClass', 'someMethod', Visibility::PROTECTED)])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactorWithScope(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : ?\PhpParser\Node + public function refactorWithScope(Node $node, Scope $scope) : ?Node { $parentClassName = $this->parentClassScopeResolver->resolveParentClassName($scope); if ($parentClassName === null) { @@ -106,7 +106,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Visibility\ValueObject\ChangeMethodVisibility::class); + Assert::allIsAOf($configuration, ChangeMethodVisibility::class); $this->methodVisibilities = $configuration; } } diff --git a/rules/Visibility/Rector/ClassMethod/ExplicitPublicClassMethodRector.php b/rules/Visibility/Rector/ClassMethod/ExplicitPublicClassMethodRector.php index 3e8dcffd884..078025b99f7 100644 --- a/rules/Visibility/Rector/ClassMethod/ExplicitPublicClassMethodRector.php +++ b/rules/Visibility/Rector/ClassMethod/ExplicitPublicClassMethodRector.php @@ -8,25 +8,25 @@ use PhpParser\Node\Stmt\ClassMethod; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\Visibility; use Rector\Privatization\NodeManipulator\VisibilityManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Visibility\Rector\ClassMethod\ExplicitPublicClassMethodRector\ExplicitPublicClassMethodRectorTest */ -final class ExplicitPublicClassMethodRector extends \Rector\Core\Rector\AbstractRector +final class ExplicitPublicClassMethodRector extends AbstractRector { /** * @readonly * @var \Rector\Privatization\NodeManipulator\VisibilityManipulator */ private $visibilityManipulator; - public function __construct(\Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator) + public function __construct(VisibilityManipulator $visibilityManipulator) { $this->visibilityManipulator = $visibilityManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add explicit public method visibility.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add explicit public method visibility.', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { function foo() @@ -49,19 +49,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { // already non-public if (!$node->isPublic()) { return null; } // explicitly public - if ($this->visibilityManipulator->hasVisibility($node, \Rector\Core\ValueObject\Visibility::PUBLIC)) { + if ($this->visibilityManipulator->hasVisibility($node, Visibility::PUBLIC)) { return null; } $this->visibilityManipulator->makePublic($node); diff --git a/rules/Visibility/ValueObject/ChangeConstantVisibility.php b/rules/Visibility/ValueObject/ChangeConstantVisibility.php index a79bdb20a50..792bb3ac84c 100644 --- a/rules/Visibility/ValueObject/ChangeConstantVisibility.php +++ b/rules/Visibility/ValueObject/ChangeConstantVisibility.php @@ -27,11 +27,11 @@ final class ChangeConstantVisibility $this->class = $class; $this->constant = $constant; $this->visibility = $visibility; - \Rector\Core\Validation\RectorAssert::className($class); + RectorAssert::className($class); } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->class); + return new ObjectType($this->class); } public function getConstant() : string { diff --git a/rules/Visibility/ValueObject/ChangeMethodVisibility.php b/rules/Visibility/ValueObject/ChangeMethodVisibility.php index a18f472588e..f4c1950d3b9 100644 --- a/rules/Visibility/ValueObject/ChangeMethodVisibility.php +++ b/rules/Visibility/ValueObject/ChangeMethodVisibility.php @@ -26,7 +26,7 @@ final class ChangeMethodVisibility $this->class = $class; $this->method = $method; $this->visibility = $visibility; - \Rector\Core\Validation\RectorAssert::className($class); + RectorAssert::className($class); } public function getClass() : string { diff --git a/src/Application/ApplicationFileProcessor.php b/src/Application/ApplicationFileProcessor.php index 48afce94ed0..8e01ab3a833 100644 --- a/src/Application/ApplicationFileProcessor.php +++ b/src/Application/ApplicationFileProcessor.php @@ -23,7 +23,7 @@ use RectorPrefix20220607\Symplify\EasyParallel\FileSystem\FilePathNormalizer; use RectorPrefix20220607\Symplify\EasyParallel\ScheduleFactory; use RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider; use RectorPrefix20220607\Symplify\PackageBuilder\Yaml\ParametersMerger; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem; use RectorPrefix20220607\Webmozart\Assert\Assert; final class ApplicationFileProcessor @@ -104,7 +104,7 @@ final class ApplicationFileProcessor /** * @param FileProcessorInterface[] $fileProcessors */ - public function __construct(\RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \Rector\Core\Application\FileDecorator\FileDiffFileDecorator $fileDiffFileDecorator, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesProcessor $removedAndAddedFilesProcessor, \Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle, \Rector\Core\ValueObjectFactory\Application\FileFactory $fileFactory, \PHPStan\Analyser\NodeScopeResolver $nodeScopeResolver, \RectorPrefix20220607\Symplify\PackageBuilder\Yaml\ParametersMerger $parametersMerger, \Rector\Parallel\Application\ParallelFileProcessor $parallelFileProcessor, \RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \RectorPrefix20220607\Symplify\EasyParallel\ScheduleFactory $scheduleFactory, \RectorPrefix20220607\Symplify\EasyParallel\FileSystem\FilePathNormalizer $filePathNormalizer, \RectorPrefix20220607\Symplify\EasyParallel\CpuCoreCountProvider $cpuCoreCountProvider, array $fileProcessors = []) + public function __construct(SmartFileSystem $smartFileSystem, FileDiffFileDecorator $fileDiffFileDecorator, RemovedAndAddedFilesProcessor $removedAndAddedFilesProcessor, OutputStyleInterface $rectorOutputStyle, FileFactory $fileFactory, NodeScopeResolver $nodeScopeResolver, ParametersMerger $parametersMerger, ParallelFileProcessor $parallelFileProcessor, ParameterProvider $parameterProvider, ScheduleFactory $scheduleFactory, FilePathNormalizer $filePathNormalizer, CpuCoreCountProvider $cpuCoreCountProvider, array $fileProcessors = []) { $this->smartFileSystem = $smartFileSystem; $this->fileDiffFileDecorator = $fileDiffFileDecorator; @@ -123,12 +123,12 @@ final class ApplicationFileProcessor /** * @return array{system_errors: SystemError[], file_diffs: FileDiff[]} */ - public function run(\Rector\Core\ValueObject\Configuration $configuration, \RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input) : array + public function run(Configuration $configuration, InputInterface $input) : array { $fileInfos = $this->fileFactory->createFileInfosFromPaths($configuration->getPaths(), $configuration); // no files found if ($fileInfos === []) { - return [\Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS => [], \Rector\Parallel\ValueObject\Bridge::FILE_DIFFS => []]; + return [Bridge::SYSTEM_ERRORS => [], Bridge::FILE_DIFFS => []]; } $this->configureCustomErrorHandler(); if ($configuration->isParallel()) { @@ -142,7 +142,7 @@ final class ApplicationFileProcessor $this->fileDiffFileDecorator->decorate($files); $this->printFiles($files, $configuration); } - $systemErrorsAndFileDiffs[\Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS] = \array_merge($systemErrorsAndFileDiffs[\Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS], $this->systemErrors); + $systemErrorsAndFileDiffs[Bridge::SYSTEM_ERRORS] = \array_merge($systemErrorsAndFileDiffs[Bridge::SYSTEM_ERRORS], $this->systemErrors); $this->restoreErrorHandler(); return $systemErrorsAndFileDiffs; } @@ -152,14 +152,14 @@ final class ApplicationFileProcessor * @param File[] $files * @return array{system_errors: SystemError[], file_diffs: FileDiff[]} */ - public function processFiles(array $files, \Rector\Core\ValueObject\Configuration $configuration) : array + public function processFiles(array $files, Configuration $configuration) : array { $shouldShowProgressBar = $configuration->shouldShowProgressBar(); if ($shouldShowProgressBar) { $fileCount = \count($files); $this->rectorOutputStyle->progressStart($fileCount); } - $systemErrorsAndFileDiffs = [\Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS => [], \Rector\Parallel\ValueObject\Bridge::FILE_DIFFS => []]; + $systemErrorsAndFileDiffs = [Bridge::SYSTEM_ERRORS => [], Bridge::FILE_DIFFS => []]; foreach ($files as $file) { foreach ($this->fileProcessors as $fileProcessor) { if (!$fileProcessor->supports($file, $configuration)) { @@ -179,7 +179,7 @@ final class ApplicationFileProcessor /** * @param File[] $files */ - private function printFiles(array $files, \Rector\Core\ValueObject\Configuration $configuration) : void + private function printFiles(array $files, Configuration $configuration) : void { if ($configuration->isDryRun()) { return; @@ -191,7 +191,7 @@ final class ApplicationFileProcessor $this->printFile($file); } } - private function printFile(\Rector\Core\ValueObject\Application\File $file) : void + private function printFile(File $file) : void { $smartFileInfo = $file->getSmartFileInfo(); $this->smartFileSystem->dumpFile($smartFileInfo->getPathname(), $file->getFileContent()); @@ -211,7 +211,7 @@ final class ApplicationFileProcessor if (\in_array($code, [\E_DEPRECATED, \E_WARNING], \true)) { return \true; } - $this->systemErrors[] = new \Rector\Core\ValueObject\Error\SystemError($message, $file, $line); + $this->systemErrors[] = new SystemError($message, $file, $line); return \true; }; \set_error_handler($errorHandlerCallback); @@ -224,11 +224,11 @@ final class ApplicationFileProcessor * @param SmartFileInfo[] $fileInfos * @return array{system_errors: SystemError[], file_diffs: FileDiff[]} */ - private function runParallel(array $fileInfos, \Rector\Core\ValueObject\Configuration $configuration, \RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input) : array + private function runParallel(array $fileInfos, Configuration $configuration, InputInterface $input) : array { // must be a string, otherwise the serialization returns empty arrays $filePaths = $this->filePathNormalizer->resolveFilePathsFromFileInfos($fileInfos); - $schedule = $this->scheduleFactory->create($this->cpuCoreCountProvider->provide(), $this->parameterProvider->provideIntParameter(\Rector\Core\Configuration\Option::PARALLEL_JOB_SIZE), $this->parameterProvider->provideIntParameter(\Rector\Core\Configuration\Option::PARALLEL_MAX_NUMBER_OF_PROCESSES), $filePaths); + $schedule = $this->scheduleFactory->create($this->cpuCoreCountProvider->provide(), $this->parameterProvider->provideIntParameter(Option::PARALLEL_JOB_SIZE), $this->parameterProvider->provideIntParameter(Option::PARALLEL_MAX_NUMBER_OF_PROCESSES), $filePaths); // for progress bar $isProgressBarStarted = \false; $postFileCallback = function (int $stepCount) use(&$isProgressBarStarted, $filePaths, $configuration) : void { @@ -245,7 +245,7 @@ final class ApplicationFileProcessor }; $mainScript = $this->resolveCalledRectorBinary(); if ($mainScript === null) { - throw new \RectorPrefix20220607\Symplify\EasyParallel\Exception\ParallelShouldNotHappenException('[parallel] Main script was not found'); + throw new ParallelShouldNotHappenException('[parallel] Main script was not found'); } // mimics see https://github.com/phpstan/phpstan-src/commit/9124c66dcc55a222e21b1717ba5f60771f7dda92#diff-387b8f04e0db7a06678eb52ce0c0d0aff73e0d7d8fc5df834d0a5fbec198e5daR139 return $this->parallelFileProcessor->process($schedule, $mainScript, $postFileCallback, $input); @@ -279,7 +279,7 @@ final class ApplicationFileProcessor */ private function resolvePhpFilePaths(array $files) : array { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($files, \Rector\Core\ValueObject\Application\File::class); + Assert::allIsAOf($files, File::class); $filePaths = []; foreach ($files as $file) { $smartFileInfo = $file->getSmartFileInfo(); diff --git a/src/Application/ChangedNodeScopeRefresher.php b/src/Application/ChangedNodeScopeRefresher.php index 3f59983e413..0d6aee9252d 100644 --- a/src/Application/ChangedNodeScopeRefresher.php +++ b/src/Application/ChangedNodeScopeRefresher.php @@ -17,7 +17,7 @@ use Rector\Core\NodeAnalyzer\UnreachableStmtAnalyzer; use Rector\Core\PhpParser\Node\BetterNodeFinder; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\NodeTypeResolver\PHPStan\Scope\PHPStanNodeScopeResolver; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; /** * In case of changed node, we need to re-traverse the PHPStan Scope to make all the new nodes aware of what is going on. */ @@ -43,20 +43,20 @@ final class ChangedNodeScopeRefresher * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeTypeResolver\PHPStan\Scope\PHPStanNodeScopeResolver $phpStanNodeScopeResolver, \Rector\Core\NodeAnalyzer\ScopeAnalyzer $scopeAnalyzer, \Rector\Core\NodeAnalyzer\UnreachableStmtAnalyzer $unreachableStmtAnalyzer, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(PHPStanNodeScopeResolver $phpStanNodeScopeResolver, ScopeAnalyzer $scopeAnalyzer, UnreachableStmtAnalyzer $unreachableStmtAnalyzer, BetterNodeFinder $betterNodeFinder) { $this->phpStanNodeScopeResolver = $phpStanNodeScopeResolver; $this->scopeAnalyzer = $scopeAnalyzer; $this->unreachableStmtAnalyzer = $unreachableStmtAnalyzer; $this->betterNodeFinder = $betterNodeFinder; } - public function refresh(\PhpParser\Node $node, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo, ?\PHPStan\Analyser\MutatingScope $mutatingScope) : void + public function refresh(Node $node, SmartFileInfo $smartFileInfo, ?MutatingScope $mutatingScope) : void { // nothing to refresh if (!$this->scopeAnalyzer->hasScope($node)) { return; } - if (!$mutatingScope instanceof \PHPStan\Analyser\MutatingScope) { + if (!$mutatingScope instanceof MutatingScope) { /** * Node does not has Scope, while: * @@ -65,17 +65,17 @@ final class ChangedNodeScopeRefresher */ $currentStmt = $this->betterNodeFinder->resolveCurrentStatement($node); if (!$this->unreachableStmtAnalyzer->isStmtPHPStanUnreachable($currentStmt)) { - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - $errorMessage = \sprintf('Node "%s" with parent of "%s" is missing scope required for scope refresh.', \get_class($node), $parent instanceof \PhpParser\Node ? \get_class($parent) : null); - throw new \Rector\Core\Exception\ShouldNotHappenException($errorMessage); + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + $errorMessage = \sprintf('Node "%s" with parent of "%s" is missing scope required for scope refresh.', \get_class($node), $parent instanceof Node ? \get_class($parent) : null); + throw new ShouldNotHappenException($errorMessage); } } // note from flight: when we traverse ClassMethod, the scope must be already in Class_, otherwise it crashes // so we need to somehow get a parent scope that is already in the same place the $node is - if ($node instanceof \PhpParser\Node\Attribute) { + if ($node instanceof Attribute) { // we'll have to fake-traverse 2 layers up, as PHPStan skips Scope for AttributeGroups and consequently Attributes - $attributeGroup = new \PhpParser\Node\AttributeGroup([$node]); - $node = new \PhpParser\Node\Stmt\Property(0, [], [], null, [$attributeGroup]); + $attributeGroup = new AttributeGroup([$node]); + $node = new Property(0, [], [], null, [$attributeGroup]); } $stmts = $this->resolveStmts($node); $this->phpStanNodeScopeResolver->processNodes($stmts, $smartFileInfo, $mutatingScope); @@ -83,15 +83,15 @@ final class ChangedNodeScopeRefresher /** * @return Stmt[] */ - private function resolveStmts(\PhpParser\Node $node) : array + private function resolveStmts(Node $node) : array { - if ($node instanceof \PhpParser\Node\Stmt) { + if ($node instanceof Stmt) { return [$node]; } - if ($node instanceof \PhpParser\Node\Expr) { - return [new \PhpParser\Node\Stmt\Expression($node)]; + if ($node instanceof Expr) { + return [new Expression($node)]; } $errorMessage = \sprintf('Complete parent node of "%s" be a stmt.', \get_class($node)); - throw new \Rector\Core\Exception\ShouldNotHappenException($errorMessage); + throw new ShouldNotHappenException($errorMessage); } } diff --git a/src/Application/FileDecorator/FileDiffFileDecorator.php b/src/Application/FileDecorator/FileDiffFileDecorator.php index 56e58b054b4..55689b3dccb 100644 --- a/src/Application/FileDecorator/FileDiffFileDecorator.php +++ b/src/Application/FileDecorator/FileDiffFileDecorator.php @@ -6,14 +6,14 @@ namespace Rector\Core\Application\FileDecorator; use Rector\ChangesReporting\ValueObjectFactory\FileDiffFactory; use Rector\Core\Contract\Application\FileDecoratorInterface; use Rector\Core\ValueObject\Application\File; -final class FileDiffFileDecorator implements \Rector\Core\Contract\Application\FileDecoratorInterface +final class FileDiffFileDecorator implements FileDecoratorInterface { /** * @readonly * @var \Rector\ChangesReporting\ValueObjectFactory\FileDiffFactory */ private $fileDiffFactory; - public function __construct(\Rector\ChangesReporting\ValueObjectFactory\FileDiffFactory $fileDiffFactory) + public function __construct(FileDiffFactory $fileDiffFactory) { $this->fileDiffFactory = $fileDiffFactory; } diff --git a/src/Application/FileProcessor.php b/src/Application/FileProcessor.php index ffaca05a657..7b33137c49c 100644 --- a/src/Application/FileProcessor.php +++ b/src/Application/FileProcessor.php @@ -37,7 +37,7 @@ final class FileProcessor * @var \Rector\Core\PhpParser\NodeTraverser\FileWithoutNamespaceNodeTraverser */ private $fileWithoutNamespaceNodeTraverser; - public function __construct(\Rector\ChangesReporting\Collector\AffectedFilesCollector $affectedFilesCollector, \Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator, \Rector\Core\PhpParser\Parser\RectorParser $rectorParser, \Rector\Core\PhpParser\NodeTraverser\RectorNodeTraverser $rectorNodeTraverser, \Rector\Core\PhpParser\NodeTraverser\FileWithoutNamespaceNodeTraverser $fileWithoutNamespaceNodeTraverser) + public function __construct(AffectedFilesCollector $affectedFilesCollector, NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator, RectorParser $rectorParser, RectorNodeTraverser $rectorNodeTraverser, FileWithoutNamespaceNodeTraverser $fileWithoutNamespaceNodeTraverser) { $this->affectedFilesCollector = $affectedFilesCollector; $this->nodeScopeAndMetadataDecorator = $nodeScopeAndMetadataDecorator; @@ -45,7 +45,7 @@ final class FileProcessor $this->rectorNodeTraverser = $rectorNodeTraverser; $this->fileWithoutNamespaceNodeTraverser = $fileWithoutNamespaceNodeTraverser; } - public function parseFileInfoToLocalCache(\Rector\Core\ValueObject\Application\File $file) : void + public function parseFileInfoToLocalCache(File $file) : void { // store tokens by absolute path, so we don't have to print them right now $smartFileInfo = $file->getSmartFileInfo(); @@ -55,7 +55,7 @@ final class FileProcessor $newStmts = $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($file, $oldStmts); $file->hydrateStmtsAndTokens($newStmts, $oldStmts, $oldTokens); } - public function refactor(\Rector\Core\ValueObject\Application\File $file, \Rector\Core\ValueObject\Configuration $configuration) : void + public function refactor(File $file, Configuration $configuration) : void { $newStmts = $this->fileWithoutNamespaceNodeTraverser->traverse($file->getNewStmts()); $newStmts = $this->rectorNodeTraverser->traverse($newStmts); diff --git a/src/Application/FileProcessor/PhpFileProcessor.php b/src/Application/FileProcessor/PhpFileProcessor.php index 266056dca91..c80cf4d6682 100644 --- a/src/Application/FileProcessor/PhpFileProcessor.php +++ b/src/Application/FileProcessor/PhpFileProcessor.php @@ -21,7 +21,7 @@ use Rector\Parallel\ValueObject\Bridge; use Rector\PostRector\Application\PostFileProcessor; use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment; use Throwable; -final class PhpFileProcessor implements \Rector\Core\Contract\Processor\FileProcessorInterface +final class PhpFileProcessor implements FileProcessorInterface { /** * @readonly @@ -63,7 +63,7 @@ final class PhpFileProcessor implements \Rector\Core\Contract\Processor\FileProc * @var \Rector\ChangesReporting\ValueObjectFactory\ErrorFactory */ private $errorFactory; - public function __construct(\Rector\Core\PhpParser\Printer\FormatPerservingPrinter $formatPerservingPrinter, \Rector\Core\Application\FileProcessor $fileProcessor, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, \Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle, \Rector\Core\Application\FileDecorator\FileDiffFileDecorator $fileDiffFileDecorator, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \Rector\PostRector\Application\PostFileProcessor $postFileProcessor, \Rector\ChangesReporting\ValueObjectFactory\ErrorFactory $errorFactory) + public function __construct(FormatPerservingPrinter $formatPerservingPrinter, FileProcessor $fileProcessor, RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, OutputStyleInterface $rectorOutputStyle, FileDiffFileDecorator $fileDiffFileDecorator, CurrentFileProvider $currentFileProvider, PostFileProcessor $postFileProcessor, ErrorFactory $errorFactory) { $this->formatPerservingPrinter = $formatPerservingPrinter; $this->fileProcessor = $fileProcessor; @@ -77,14 +77,14 @@ final class PhpFileProcessor implements \Rector\Core\Contract\Processor\FileProc /** * @return array{system_errors: SystemError[], file_diffs: FileDiff[]} */ - public function process(\Rector\Core\ValueObject\Application\File $file, \Rector\Core\ValueObject\Configuration $configuration) : array + public function process(File $file, Configuration $configuration) : array { - $systemErrorsAndFileDiffs = [\Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS => [], \Rector\Parallel\ValueObject\Bridge::FILE_DIFFS => []]; + $systemErrorsAndFileDiffs = [Bridge::SYSTEM_ERRORS => [], Bridge::FILE_DIFFS => []]; // 1. parse files to nodes $parsingSystemErrors = $this->parseFileAndDecorateNodes($file); if ($parsingSystemErrors !== []) { // we cannot process this file as the parsing and type resolving itself went wrong - $systemErrorsAndFileDiffs[\Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS] = $parsingSystemErrors; + $systemErrorsAndFileDiffs[Bridge::SYSTEM_ERRORS] = $parsingSystemErrors; return $systemErrorsAndFileDiffs; } // 2. change nodes with Rectors @@ -102,13 +102,13 @@ final class PhpFileProcessor implements \Rector\Core\Contract\Processor\FileProc } while ($file->hasChanged()); // return json here $fileDiff = $file->getFileDiff(); - if (!$fileDiff instanceof \Rector\Core\ValueObject\Reporting\FileDiff) { + if (!$fileDiff instanceof FileDiff) { return $systemErrorsAndFileDiffs; } - $systemErrorsAndFileDiffs[\Rector\Parallel\ValueObject\Bridge::FILE_DIFFS] = [$fileDiff]; + $systemErrorsAndFileDiffs[Bridge::FILE_DIFFS] = [$fileDiff]; return $systemErrorsAndFileDiffs; } - public function supports(\Rector\Core\ValueObject\Application\File $file, \Rector\Core\ValueObject\Configuration $configuration) : bool + public function supports(File $file, Configuration $configuration) : bool { $smartFileInfo = $file->getSmartFileInfo(); return $smartFileInfo->hasSuffixes($configuration->getFileExtensions()); @@ -120,7 +120,7 @@ final class PhpFileProcessor implements \Rector\Core\Contract\Processor\FileProc { return ['php']; } - private function refactorNodesWithRectors(\Rector\Core\ValueObject\Application\File $file, \Rector\Core\ValueObject\Configuration $configuration) : void + private function refactorNodesWithRectors(File $file, Configuration $configuration) : void { $this->currentFileProvider->setFile($file); $this->fileProcessor->refactor($file, $configuration); @@ -128,31 +128,31 @@ final class PhpFileProcessor implements \Rector\Core\Contract\Processor\FileProc /** * @return SystemError[] */ - private function parseFileAndDecorateNodes(\Rector\Core\ValueObject\Application\File $file) : array + private function parseFileAndDecorateNodes(File $file) : array { $this->currentFileProvider->setFile($file); $this->notifyFile($file); try { $this->fileProcessor->parseFileInfoToLocalCache($file); - } catch (\Rector\Core\Exception\ShouldNotHappenException $shouldNotHappenException) { + } catch (ShouldNotHappenException $shouldNotHappenException) { throw $shouldNotHappenException; - } catch (\PHPStan\AnalysedCodeException $analysedCodeException) { + } catch (AnalysedCodeException $analysedCodeException) { // inform about missing classes in tests - if (\Rector\Testing\PHPUnit\StaticPHPUnitEnvironment::isPHPUnitRun()) { + if (StaticPHPUnitEnvironment::isPHPUnitRun()) { throw $analysedCodeException; } $autoloadSystemError = $this->errorFactory->createAutoloadError($analysedCodeException, $file->getSmartFileInfo()); return [$autoloadSystemError]; - } catch (\Throwable $throwable) { - if ($this->rectorOutputStyle->isVerbose() || \Rector\Testing\PHPUnit\StaticPHPUnitEnvironment::isPHPUnitRun()) { + } catch (Throwable $throwable) { + if ($this->rectorOutputStyle->isVerbose() || StaticPHPUnitEnvironment::isPHPUnitRun()) { throw $throwable; } - $systemError = new \Rector\Core\ValueObject\Error\SystemError($throwable->getMessage(), $file->getRelativeFilePath(), $throwable->getLine()); + $systemError = new SystemError($throwable->getMessage(), $file->getRelativeFilePath(), $throwable->getLine()); return [$systemError]; } return []; } - private function printFile(\Rector\Core\ValueObject\Application\File $file, \Rector\Core\ValueObject\Configuration $configuration) : void + private function printFile(File $file, Configuration $configuration) : void { $smartFileInfo = $file->getSmartFileInfo(); if ($this->removedAndAddedFilesCollector->isFileRemoved($smartFileInfo)) { @@ -163,7 +163,7 @@ final class PhpFileProcessor implements \Rector\Core\Contract\Processor\FileProc $file->changeFileContent($newContent); $this->fileDiffFileDecorator->decorate([$file]); } - private function notifyFile(\Rector\Core\ValueObject\Application\File $file) : void + private function notifyFile(File $file) : void { if (!$this->rectorOutputStyle->isVerbose()) { return; diff --git a/src/Application/FileSystem/RemovedAndAddedFilesCollector.php b/src/Application/FileSystem/RemovedAndAddedFilesCollector.php index 60bb97d6c01..10c27eb7c22 100644 --- a/src/Application/FileSystem/RemovedAndAddedFilesCollector.php +++ b/src/Application/FileSystem/RemovedAndAddedFilesCollector.php @@ -8,7 +8,7 @@ use Rector\Core\ValueObject\Application\MovedFile; use Rector\FileSystemRector\Contract\AddedFileInterface; use Rector\FileSystemRector\ValueObject\AddedFileWithContent; use Rector\FileSystemRector\ValueObject\AddedFileWithNodes; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class RemovedAndAddedFilesCollector { /** @@ -23,7 +23,7 @@ final class RemovedAndAddedFilesCollector * @var MovedFile[] */ private $movedFiles = []; - public function removeFile(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : void + public function removeFile(SmartFileInfo $smartFileInfo) : void { $this->removedFileInfos[] = $smartFileInfo; } @@ -34,7 +34,7 @@ final class RemovedAndAddedFilesCollector { return $this->removedFileInfos; } - public function isFileRemoved(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : bool + public function isFileRemoved(SmartFileInfo $smartFileInfo) : bool { // early assign to variable for increase performance // @see https://3v4l.org/FM3vY#focus=8.0.7 vs https://3v4l.org/JZW7b#focus=8.0.7 @@ -55,7 +55,7 @@ final class RemovedAndAddedFilesCollector } return \false; } - public function addAddedFile(\Rector\FileSystemRector\Contract\AddedFileInterface $addedFile) : void + public function addAddedFile(AddedFileInterface $addedFile) : void { $this->addedFiles[] = $addedFile; } @@ -64,8 +64,8 @@ final class RemovedAndAddedFilesCollector */ public function getAddedFilesWithContent() : array { - return \array_filter($this->addedFiles, function (\Rector\FileSystemRector\Contract\AddedFileInterface $addedFile) : bool { - return $addedFile instanceof \Rector\FileSystemRector\ValueObject\AddedFileWithContent; + return \array_filter($this->addedFiles, function (AddedFileInterface $addedFile) : bool { + return $addedFile instanceof AddedFileWithContent; }); } /** @@ -73,8 +73,8 @@ final class RemovedAndAddedFilesCollector */ public function getAddedFilesWithNodes() : array { - return \array_filter($this->addedFiles, function (\Rector\FileSystemRector\Contract\AddedFileInterface $addedFile) : bool { - return $addedFile instanceof \Rector\FileSystemRector\ValueObject\AddedFileWithNodes; + return \array_filter($this->addedFiles, function (AddedFileInterface $addedFile) : bool { + return $addedFile instanceof AddedFileWithNodes; }); } public function getAffectedFilesCount() : int @@ -98,9 +98,9 @@ final class RemovedAndAddedFilesCollector $this->movedFiles = []; $this->removedFileInfos = []; } - public function addMovedFile(\Rector\Core\ValueObject\Application\File $file, string $newPathName) : void + public function addMovedFile(File $file, string $newPathName) : void { - $this->movedFiles[] = new \Rector\Core\ValueObject\Application\MovedFile($file, $newPathName); + $this->movedFiles[] = new MovedFile($file, $newPathName); } /** * @return MovedFile[] diff --git a/src/Application/FileSystem/RemovedAndAddedFilesProcessor.php b/src/Application/FileSystem/RemovedAndAddedFilesProcessor.php index 396052724fb..73e80df8dab 100644 --- a/src/Application/FileSystem/RemovedAndAddedFilesProcessor.php +++ b/src/Application/FileSystem/RemovedAndAddedFilesProcessor.php @@ -32,21 +32,21 @@ final class RemovedAndAddedFilesProcessor * @var \Rector\Core\Contract\Console\OutputStyleInterface */ private $rectorOutputStyle; - public function __construct(\RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \Rector\Core\PhpParser\Printer\NodesWithFileDestinationPrinter $nodesWithFileDestinationPrinter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, \Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle) + public function __construct(SmartFileSystem $smartFileSystem, NodesWithFileDestinationPrinter $nodesWithFileDestinationPrinter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, OutputStyleInterface $rectorOutputStyle) { $this->smartFileSystem = $smartFileSystem; $this->nodesWithFileDestinationPrinter = $nodesWithFileDestinationPrinter; $this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector; $this->rectorOutputStyle = $rectorOutputStyle; } - public function run(\Rector\Core\ValueObject\Configuration $configuration) : void + public function run(Configuration $configuration) : void { $this->processAddedFilesWithContent($configuration); $this->processAddedFilesWithNodes($configuration); $this->processMovedFilesWithNodes($configuration); $this->processDeletedFiles($configuration); } - private function processDeletedFiles(\Rector\Core\ValueObject\Configuration $configuration) : void + private function processDeletedFiles(Configuration $configuration) : void { foreach ($this->removedAndAddedFilesCollector->getRemovedFiles() as $removedFile) { $relativePath = $removedFile->getRelativeFilePathFromDirectory(\getcwd()); @@ -60,7 +60,7 @@ final class RemovedAndAddedFilesProcessor } } } - private function processAddedFilesWithContent(\Rector\Core\ValueObject\Configuration $configuration) : void + private function processAddedFilesWithContent(Configuration $configuration) : void { foreach ($this->removedAndAddedFilesCollector->getAddedFilesWithContent() as $addedFileWithContent) { if ($configuration->isDryRun()) { @@ -73,7 +73,7 @@ final class RemovedAndAddedFilesProcessor } } } - private function processAddedFilesWithNodes(\Rector\Core\ValueObject\Configuration $configuration) : void + private function processAddedFilesWithNodes(Configuration $configuration) : void { foreach ($this->removedAndAddedFilesCollector->getAddedFilesWithNodes() as $addedFileWithNode) { $fileContent = $this->nodesWithFileDestinationPrinter->printNodesWithFileDestination($addedFileWithNode); @@ -87,7 +87,7 @@ final class RemovedAndAddedFilesProcessor } } } - private function processMovedFilesWithNodes(\Rector\Core\ValueObject\Configuration $configuration) : void + private function processMovedFilesWithNodes(Configuration $configuration) : void { foreach ($this->removedAndAddedFilesCollector->getMovedFiles() as $movedFile) { $fileContent = $this->nodesWithFileDestinationPrinter->printNodesWithFileDestination($movedFile); diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 630e4b3c31e..e184280ad41 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -16,11 +16,11 @@ final class VersionResolver /** * @var string */ - public const PACKAGE_VERSION = '39c7ae65e9489b88a886f035a22db8f427db0e16'; + public const PACKAGE_VERSION = 'dbdb5931d619487a9a6cad7432df8201661cafa0'; /** * @var string */ - public const RELEASE_DATE = '2022-06-07 09:34:38'; + public const RELEASE_DATE = '2022-06-07 08:17:10'; /** * @var int */ @@ -30,7 +30,7 @@ final class VersionResolver // resolve current tag \exec('git tag --points-at', $tagExecOutput, $tagExecResultCode); if ($tagExecResultCode !== self::SUCCESS_CODE) { - throw new \Rector\Core\Exception\VersionException('Ensure to run compile from composer git repository clone and that git binary is available.'); + throw new VersionException('Ensure to run compile from composer git repository clone and that git binary is available.'); } if ($tagExecOutput !== []) { $tag = $tagExecOutput[0]; @@ -40,17 +40,17 @@ final class VersionResolver } \exec('git log --pretty="%H" -n1 HEAD', $commitHashExecOutput, $commitHashResultCode); if ($commitHashResultCode !== 0) { - throw new \Rector\Core\Exception\VersionException('Ensure to run compile from composer git repository clone and that git binary is available.'); + throw new VersionException('Ensure to run compile from composer git repository clone and that git binary is available.'); } $version = \trim($commitHashExecOutput[0]); return \trim($version, '"'); } - public static function resolverReleaseDateTime() : \DateTime + public static function resolverReleaseDateTime() : DateTime { \exec('git log -n1 --pretty=%ci HEAD', $output, $resultCode); if ($resultCode !== self::SUCCESS_CODE) { - throw new \Rector\Core\Exception\VersionException('You must ensure to run compile from composer git repository clone and that git binary is available.'); + throw new VersionException('You must ensure to run compile from composer git repository clone and that git binary is available.'); } - return new \DateTime(\trim($output[0])); + return new DateTime(\trim($output[0])); } } diff --git a/src/Autoloading/AdditionalAutoloader.php b/src/Autoloading/AdditionalAutoloader.php index 0c3387f088f..773a220b7df 100644 --- a/src/Autoloading/AdditionalAutoloader.php +++ b/src/Autoloading/AdditionalAutoloader.php @@ -28,19 +28,19 @@ final class AdditionalAutoloader * @var \Rector\Core\StaticReflection\DynamicSourceLocatorDecorator */ private $dynamicSourceLocatorDecorator; - public function __construct(\RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemGuard $fileSystemGuard, \RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \Rector\Core\StaticReflection\DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator) + public function __construct(FileSystemGuard $fileSystemGuard, ParameterProvider $parameterProvider, DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator) { $this->fileSystemGuard = $fileSystemGuard; $this->parameterProvider = $parameterProvider; $this->dynamicSourceLocatorDecorator = $dynamicSourceLocatorDecorator; } - public function autoloadInput(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input) : void + public function autoloadInput(InputInterface $input) : void { - if (!$input->hasOption(\Rector\Core\Configuration\Option::AUTOLOAD_FILE)) { + if (!$input->hasOption(Option::AUTOLOAD_FILE)) { return; } /** @var string|null $autoloadFile */ - $autoloadFile = $input->getOption(\Rector\Core\Configuration\Option::AUTOLOAD_FILE); + $autoloadFile = $input->getOption(Option::AUTOLOAD_FILE); if ($autoloadFile === null) { return; } @@ -49,7 +49,7 @@ final class AdditionalAutoloader } public function autoloadPaths() : void { - $autoloadPaths = $this->parameterProvider->provideArrayParameter(\Rector\Core\Configuration\Option::AUTOLOAD_PATHS); + $autoloadPaths = $this->parameterProvider->provideArrayParameter(Option::AUTOLOAD_PATHS); $this->dynamicSourceLocatorDecorator->addPaths($autoloadPaths); } } diff --git a/src/Autoloading/BootstrapFilesIncluder.php b/src/Autoloading/BootstrapFilesIncluder.php index 647c95c26b0..9bdbfbaaf09 100644 --- a/src/Autoloading/BootstrapFilesIncluder.php +++ b/src/Autoloading/BootstrapFilesIncluder.php @@ -18,7 +18,7 @@ final class BootstrapFilesIncluder * @var \Symplify\PackageBuilder\Parameter\ParameterProvider */ private $parameterProvider; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider) + public function __construct(ParameterProvider $parameterProvider) { $this->parameterProvider = $parameterProvider; } @@ -28,27 +28,27 @@ final class BootstrapFilesIncluder */ public function includeBootstrapFiles() : void { - $bootstrapFiles = $this->parameterProvider->provideArrayParameter(\Rector\Core\Configuration\Option::BOOTSTRAP_FILES); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($bootstrapFiles); + $bootstrapFiles = $this->parameterProvider->provideArrayParameter(Option::BOOTSTRAP_FILES); + Assert::allString($bootstrapFiles); /** @var string[] $bootstrapFiles */ foreach ($bootstrapFiles as $bootstrapFile) { if (!\is_file($bootstrapFile)) { - throw new \Rector\Core\Exception\ShouldNotHappenException(\sprintf('Bootstrap file "%s" does not exist.', $bootstrapFile)); + throw new ShouldNotHappenException(\sprintf('Bootstrap file "%s" does not exist.', $bootstrapFile)); } try { require_once $bootstrapFile; - } catch (\Throwable $throwable) { + } catch (Throwable $throwable) { $errorMessage = \sprintf('"%s" thrown in "%s" on line %d while loading bootstrap file %s: %s', \get_class($throwable), $throwable->getFile(), $throwable->getLine(), $bootstrapFile, $throwable->getMessage()); - throw new \Rector\Core\Exception\ShouldNotHappenException($errorMessage, $throwable->getCode(), $throwable); + throw new ShouldNotHappenException($errorMessage, $throwable->getCode(), $throwable); } } $stubsRectorDirectory = \realpath(__DIR__ . '/../../stubs-rector'); if ($stubsRectorDirectory === \false) { return; } - $dir = new \RecursiveDirectoryIterator($stubsRectorDirectory, \RecursiveDirectoryIterator::SKIP_DOTS); + $dir = new RecursiveDirectoryIterator($stubsRectorDirectory, RecursiveDirectoryIterator::SKIP_DOTS); /** @var SplFileInfo[] $stubs */ - $stubs = new \RecursiveIteratorIterator($dir); + $stubs = new RecursiveIteratorIterator($dir); foreach ($stubs as $stub) { require_once $stub->getRealPath(); } diff --git a/src/Bootstrap/ExtensionConfigResolver.php b/src/Bootstrap/ExtensionConfigResolver.php index f7df0877b52..a833e9f80bb 100644 --- a/src/Bootstrap/ExtensionConfigResolver.php +++ b/src/Bootstrap/ExtensionConfigResolver.php @@ -5,7 +5,7 @@ namespace Rector\Core\Bootstrap; use Rector\RectorInstaller\GeneratedConfig; use ReflectionClass; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class ExtensionConfigResolver { /** @@ -17,12 +17,12 @@ final class ExtensionConfigResolver if (!\class_exists('Rector\\RectorInstaller\\GeneratedConfig')) { return $configFileInfos; } - $generatedConfigReflectionClass = new \ReflectionClass('Rector\\RectorInstaller\\GeneratedConfig'); + $generatedConfigReflectionClass = new ReflectionClass('Rector\\RectorInstaller\\GeneratedConfig'); if ($generatedConfigReflectionClass->getFileName() === \false) { return $configFileInfos; } $generatedConfigDirectory = \dirname($generatedConfigReflectionClass->getFileName()); - foreach (\Rector\RectorInstaller\GeneratedConfig::EXTENSIONS as $extensionConfig) { + foreach (GeneratedConfig::EXTENSIONS as $extensionConfig) { /** @var string[] $includedFiles */ $includedFiles = $extensionConfig['extra']['includes'] ?? []; foreach ($includedFiles as $includedFile) { @@ -32,7 +32,7 @@ final class ExtensionConfigResolver $installPath = $extensionConfig['install_path']; $includedFilePath = \sprintf('%s/%s', $installPath, $includedFile); } - $configFileInfos[] = new \Symplify\SmartFileSystem\SmartFileInfo($includedFilePath); + $configFileInfos[] = new SmartFileInfo($includedFilePath); } } return $configFileInfos; diff --git a/src/Bootstrap/RectorConfigsResolver.php b/src/Bootstrap/RectorConfigsResolver.php index 010a7bba32d..868f7ed7544 100644 --- a/src/Bootstrap/RectorConfigsResolver.php +++ b/src/Bootstrap/RectorConfigsResolver.php @@ -8,18 +8,18 @@ use RectorPrefix20220607\Symfony\Component\Console\Input\ArgvInput; use RectorPrefix20220607\Symplify\SmartFileSystem\Exception\FileNotFoundException; final class RectorConfigsResolver { - public function provide() : \Rector\Core\ValueObject\Bootstrap\BootstrapConfigs + public function provide() : BootstrapConfigs { - $argvInput = new \RectorPrefix20220607\Symfony\Component\Console\Input\ArgvInput(); + $argvInput = new ArgvInput(); $mainConfigFile = $this->resolveFromInputWithFallback($argvInput, 'rector.php'); $rectorRecipeConfigFile = $this->resolveRectorRecipeConfig($argvInput); $configFiles = []; if ($rectorRecipeConfigFile !== null) { $configFiles[] = $rectorRecipeConfigFile; } - return new \Rector\Core\ValueObject\Bootstrap\BootstrapConfigs($mainConfigFile, $configFiles); + return new BootstrapConfigs($mainConfigFile, $configFiles); } - private function resolveRectorRecipeConfig(\RectorPrefix20220607\Symfony\Component\Console\Input\ArgvInput $argvInput) : ?string + private function resolveRectorRecipeConfig(ArgvInput $argvInput) : ?string { if ($argvInput->getFirstArgument() !== 'generate') { return null; @@ -31,7 +31,7 @@ final class RectorConfigsResolver } return $rectorRecipeFilePath; } - private function resolveFromInput(\RectorPrefix20220607\Symfony\Component\Console\Input\ArgvInput $argvInput) : ?string + private function resolveFromInput(ArgvInput $argvInput) : ?string { $configFile = $this->getOptionValue($argvInput, ['--config', '-c']); if ($configFile === null) { @@ -39,11 +39,11 @@ final class RectorConfigsResolver } if (!\file_exists($configFile)) { $message = \sprintf('File "%s" was not found', $configFile); - throw new \RectorPrefix20220607\Symplify\SmartFileSystem\Exception\FileNotFoundException($message); + throw new FileNotFoundException($message); } return \realpath($configFile); } - private function resolveFromInputWithFallback(\RectorPrefix20220607\Symfony\Component\Console\Input\ArgvInput $argvInput, string $fallbackFile) : ?string + private function resolveFromInputWithFallback(ArgvInput $argvInput, string $fallbackFile) : ?string { $configFile = $this->resolveFromInput($argvInput); if ($configFile !== null) { @@ -62,7 +62,7 @@ final class RectorConfigsResolver /** * @param string[] $optionNames */ - private function getOptionValue(\RectorPrefix20220607\Symfony\Component\Console\Input\ArgvInput $argvInput, array $optionNames) : ?string + private function getOptionValue(ArgvInput $argvInput, array $optionNames) : ?string { foreach ($optionNames as $optionName) { if ($argvInput->hasParameterOption($optionName, \true)) { diff --git a/src/Config/Loader/ConfigureCallMergingLoaderFactory.php b/src/Config/Loader/ConfigureCallMergingLoaderFactory.php index 8712e85b685..4e0ab70e4eb 100644 --- a/src/Config/Loader/ConfigureCallMergingLoaderFactory.php +++ b/src/Config/Loader/ConfigureCallMergingLoaderFactory.php @@ -12,21 +12,21 @@ use RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderInterface; use RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderResolver; use RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder; use RectorPrefix20220607\Symplify\SymplifyKernel\Contract\Config\LoaderFactoryInterface; -final class ConfigureCallMergingLoaderFactory implements \RectorPrefix20220607\Symplify\SymplifyKernel\Contract\Config\LoaderFactoryInterface +final class ConfigureCallMergingLoaderFactory implements LoaderFactoryInterface { /** * @readonly * @var \Rector\Core\DependencyInjection\Collector\ConfigureCallValuesCollector */ private $configureCallValuesCollector; - public function __construct(\Rector\Core\DependencyInjection\Collector\ConfigureCallValuesCollector $configureCallValuesCollector) + public function __construct(ConfigureCallValuesCollector $configureCallValuesCollector) { $this->configureCallValuesCollector = $configureCallValuesCollector; } - public function create(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder, string $currentWorkingDirectory) : \RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderInterface + public function create(ContainerBuilder $containerBuilder, string $currentWorkingDirectory) : LoaderInterface { - $fileLocator = new \RectorPrefix20220607\Symfony\Component\Config\FileLocator([$currentWorkingDirectory]); - $loaderResolver = new \RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderResolver([new \RectorPrefix20220607\Symfony\Component\Config\Loader\GlobFileLoader($fileLocator), new \Rector\Core\DependencyInjection\Loader\ConfigurableCallValuesCollectingPhpFileLoader($containerBuilder, $fileLocator, $this->configureCallValuesCollector)]); - return new \RectorPrefix20220607\Symfony\Component\Config\Loader\DelegatingLoader($loaderResolver); + $fileLocator = new FileLocator([$currentWorkingDirectory]); + $loaderResolver = new LoaderResolver([new GlobFileLoader($fileLocator), new ConfigurableCallValuesCollectingPhpFileLoader($containerBuilder, $fileLocator, $this->configureCallValuesCollector)]); + return new DelegatingLoader($loaderResolver); } } diff --git a/src/Configuration/ConfigurationFactory.php b/src/Configuration/ConfigurationFactory.php index c27d53f18f8..444b482ac3c 100644 --- a/src/Configuration/ConfigurationFactory.php +++ b/src/Configuration/ConfigurationFactory.php @@ -20,7 +20,7 @@ final class ConfigurationFactory * @var \Rector\Core\Contract\Console\OutputStyleInterface */ private $rectorOutputStyle; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle) + public function __construct(ParameterProvider $parameterProvider, OutputStyleInterface $rectorOutputStyle) { $this->parameterProvider = $parameterProvider; $this->rectorOutputStyle = $rectorOutputStyle; @@ -28,15 +28,15 @@ final class ConfigurationFactory /** * @param string[] $paths */ - public function createForTests(array $paths) : \Rector\Core\ValueObject\Configuration + public function createForTests(array $paths) : Configuration { $fileExtensions = $this->parameterProvider->provideArrayParameter(\Rector\Core\Configuration\Option::FILE_EXTENSIONS); - return new \Rector\Core\ValueObject\Configuration(\true, \true, \false, \Rector\ChangesReporting\Output\ConsoleOutputFormatter::NAME, $fileExtensions, $paths); + return new Configuration(\true, \true, \false, ConsoleOutputFormatter::NAME, $fileExtensions, $paths); } /** * Needs to run in the start of the life cycle, since the rest of workflow uses it. */ - public function createFromInput(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input) : \Rector\Core\ValueObject\Configuration + public function createFromInput(InputInterface $input) : Configuration { $isDryRun = (bool) $input->getOption(\Rector\Core\Configuration\Option::DRY_RUN); $shouldClearCache = (bool) $input->getOption(\Rector\Core\Configuration\Option::CLEAR_CACHE); @@ -50,9 +50,9 @@ final class ConfigurationFactory $parallelIdentifier = (string) $input->getOption(\Rector\Core\Configuration\Option::PARALLEL_IDENTIFIER); /** @var string|null $memoryLimit */ $memoryLimit = $input->getOption(\Rector\Core\Configuration\Option::MEMORY_LIMIT); - return new \Rector\Core\ValueObject\Configuration($isDryRun, $showProgressBar, $shouldClearCache, $outputFormat, $fileExtensions, $paths, $showDiffs, $parallelPort, $parallelIdentifier, $isParallel, $memoryLimit); + return new Configuration($isDryRun, $showProgressBar, $shouldClearCache, $outputFormat, $fileExtensions, $paths, $showDiffs, $parallelPort, $parallelIdentifier, $isParallel, $memoryLimit); } - private function shouldShowProgressBar(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, string $outputFormat) : bool + private function shouldShowProgressBar(InputInterface $input, string $outputFormat) : bool { $noProgressBar = (bool) $input->getOption(\Rector\Core\Configuration\Option::NO_PROGRESS_BAR); if ($noProgressBar) { @@ -61,7 +61,7 @@ final class ConfigurationFactory if ($this->rectorOutputStyle->isVerbose()) { return \false; } - return $outputFormat === \Rector\ChangesReporting\Output\ConsoleOutputFormatter::NAME; + return $outputFormat === ConsoleOutputFormatter::NAME; } /** * @param string[] $commandLinePaths @@ -80,7 +80,7 @@ final class ConfigurationFactory /** * @return string[]|mixed[] */ - private function resolvePaths(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input) : array + private function resolvePaths(InputInterface $input) : array { $commandLinePaths = (array) $input->getArgument(\Rector\Core\Configuration\Option::SOURCE); // command line has priority diff --git a/src/Configuration/CurrentNodeProvider.php b/src/Configuration/CurrentNodeProvider.php index a06d9666cfb..49b423b9498 100644 --- a/src/Configuration/CurrentNodeProvider.php +++ b/src/Configuration/CurrentNodeProvider.php @@ -10,11 +10,11 @@ final class CurrentNodeProvider * @var \PhpParser\Node|null */ private $node; - public function setNode(\PhpParser\Node $node) : void + public function setNode(Node $node) : void { $this->node = $node; } - public function getNode() : ?\PhpParser\Node + public function getNode() : ?Node { return $this->node; } diff --git a/src/Configuration/Option.php b/src/Configuration/Option.php index 223ccb84dc5..b8e6d981711 100644 --- a/src/Configuration/Option.php +++ b/src/Configuration/Option.php @@ -85,7 +85,7 @@ final class Option * @deprecated Use @see \Rector\Config\RectorConfig::skip() instead * @var string */ - public const SKIP = \RectorPrefix20220607\Symplify\Skipper\ValueObject\Option::SKIP; + public const SKIP = SkipperOption::SKIP; /** * @deprecated Use RectorConfig::fileExtensions() instead * @var string @@ -108,7 +108,7 @@ final class Option * @var class-string * @internal */ - public const CACHE_CLASS = \Rector\Caching\ValueObject\Storage\FileCacheStorage::class; + public const CACHE_CLASS = FileCacheStorage::class; /** * @var string */ diff --git a/src/Configuration/RectorConfigProvider.php b/src/Configuration/RectorConfigProvider.php index e2fb32964ba..fba30bf1958 100644 --- a/src/Configuration/RectorConfigProvider.php +++ b/src/Configuration/RectorConfigProvider.php @@ -15,7 +15,7 @@ final class RectorConfigProvider * @var \Symplify\PackageBuilder\Parameter\ParameterProvider */ private $parameterProvider; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider) + public function __construct(ParameterProvider $parameterProvider) { $this->parameterProvider = $parameterProvider; } diff --git a/src/Configuration/RenamedClassesDataCollector.php b/src/Configuration/RenamedClassesDataCollector.php index a802dbd02ca..842d8511bf2 100644 --- a/src/Configuration/RenamedClassesDataCollector.php +++ b/src/Configuration/RenamedClassesDataCollector.php @@ -35,14 +35,14 @@ final class RenamedClassesDataCollector { return $this->oldToNewClasses; } - public function matchClassName(\PHPStan\Type\ObjectType $objectType) : ?\PHPStan\Type\ObjectType + public function matchClassName(ObjectType $objectType) : ?ObjectType { $className = $objectType->getClassName(); $renamedClassName = $this->oldToNewClasses[$className] ?? null; if ($renamedClassName === null) { return null; } - return new \PHPStan\Type\ObjectType($renamedClassName); + return new ObjectType($renamedClassName); } /** * @return string[] diff --git a/src/Configuration/ValueObjectInliner.php b/src/Configuration/ValueObjectInliner.php index bb6e80dd4c4..2e8330003db 100644 --- a/src/Configuration/ValueObjectInliner.php +++ b/src/Configuration/ValueObjectInliner.php @@ -25,11 +25,11 @@ final class ValueObjectInliner * @param ReflectionClass $reflectionClass * @return mixed[] */ - public static function resolveArgumentValues(\ReflectionClass $reflectionClass, object $object) : array + public static function resolveArgumentValues(ReflectionClass $reflectionClass, object $object) : array { $argumentValues = []; $constructorReflectionMethod = $reflectionClass->getConstructor(); - if (!$constructorReflectionMethod instanceof \ReflectionMethod) { + if (!$constructorReflectionMethod instanceof ReflectionMethod) { // value object without constructor return []; } @@ -55,12 +55,12 @@ final class ValueObjectInliner } return $inlineServices; } - private static function inlineSingle(object $object) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\InlineServiceConfigurator + private static function inlineSingle(object $object) : InlineServiceConfigurator { - $reflectionClass = new \ReflectionClass($object); + $reflectionClass = new ReflectionClass($object); $className = $reflectionClass->getName(); $argumentValues = self::resolveArgumentValues($reflectionClass, $object); - $inlineServiceConfigurator = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\InlineServiceConfigurator(new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition($className)); + $inlineServiceConfigurator = new InlineServiceConfigurator(new Definition($className)); if ($argumentValues !== []) { $inlineServiceConfigurator->args($argumentValues); } diff --git a/src/Console/Command/AbstractProcessCommand.php b/src/Console/Command/AbstractProcessCommand.php index 5b5378d5655..3386deaf771 100644 --- a/src/Console/Command/AbstractProcessCommand.php +++ b/src/Console/Command/AbstractProcessCommand.php @@ -10,7 +10,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Command\Command; use RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument; use RectorPrefix20220607\Symfony\Component\Console\Input\InputOption; use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; -abstract class AbstractProcessCommand extends \RectorPrefix20220607\Symfony\Component\Console\Command\Command +abstract class AbstractProcessCommand extends Command { /** * @var \Rector\Core\Configuration\ConfigurationFactory @@ -19,22 +19,22 @@ abstract class AbstractProcessCommand extends \RectorPrefix20220607\Symfony\Comp /** * @required */ - public function autowire(\Rector\Core\Configuration\ConfigurationFactory $configurationFactory) : void + public function autowire(ConfigurationFactory $configurationFactory) : void { $this->configurationFactory = $configurationFactory; } protected function configure() : void { - $this->addArgument(\Rector\Core\Configuration\Option::SOURCE, \RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument::OPTIONAL | \RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument::IS_ARRAY, 'Files or directories to be upgraded.'); - $this->addOption(\Rector\Core\Configuration\Option::DRY_RUN, \Rector\Core\Configuration\Option::DRY_RUN_SHORT, \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Only see the diff of changes, do not save them to files.'); - $this->addOption(\Rector\Core\Configuration\Option::AUTOLOAD_FILE, \Rector\Core\Configuration\Option::AUTOLOAD_FILE_SHORT, \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED, 'Path to file with extra autoload (will be included)'); - $this->addOption(\Rector\Core\Configuration\Option::NO_PROGRESS_BAR, null, \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Hide progress bar. Useful e.g. for nicer CI output.'); - $this->addOption(\Rector\Core\Configuration\Option::NO_DIFFS, null, \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Hide diffs of changed files. Useful e.g. for nicer CI output.'); - $this->addOption(\Rector\Core\Configuration\Option::OUTPUT_FORMAT, null, \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED, 'Select output format', \Rector\ChangesReporting\Output\ConsoleOutputFormatter::NAME); - $this->addOption(\Rector\Core\Configuration\Option::DEBUG, null, \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Display debug output.'); - $this->addOption(\Rector\Core\Configuration\Option::MEMORY_LIMIT, null, \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED, 'Memory limit for process'); - $this->addOption(\Rector\Core\Configuration\Option::CLEAR_CACHE, null, \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Clear unchaged files cache'); - $this->addOption(\Rector\Core\Configuration\Option::PARALLEL_PORT, null, \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED); - $this->addOption(\Rector\Core\Configuration\Option::PARALLEL_IDENTIFIER, null, \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED); + $this->addArgument(Option::SOURCE, InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'Files or directories to be upgraded.'); + $this->addOption(Option::DRY_RUN, Option::DRY_RUN_SHORT, InputOption::VALUE_NONE, 'Only see the diff of changes, do not save them to files.'); + $this->addOption(Option::AUTOLOAD_FILE, Option::AUTOLOAD_FILE_SHORT, InputOption::VALUE_REQUIRED, 'Path to file with extra autoload (will be included)'); + $this->addOption(Option::NO_PROGRESS_BAR, null, InputOption::VALUE_NONE, 'Hide progress bar. Useful e.g. for nicer CI output.'); + $this->addOption(Option::NO_DIFFS, null, InputOption::VALUE_NONE, 'Hide diffs of changed files. Useful e.g. for nicer CI output.'); + $this->addOption(Option::OUTPUT_FORMAT, null, InputOption::VALUE_REQUIRED, 'Select output format', ConsoleOutputFormatter::NAME); + $this->addOption(Option::DEBUG, null, InputOption::VALUE_NONE, 'Display debug output.'); + $this->addOption(Option::MEMORY_LIMIT, null, InputOption::VALUE_REQUIRED, 'Memory limit for process'); + $this->addOption(Option::CLEAR_CACHE, null, InputOption::VALUE_NONE, 'Clear unchaged files cache'); + $this->addOption(Option::PARALLEL_PORT, null, InputOption::VALUE_REQUIRED); + $this->addOption(Option::PARALLEL_IDENTIFIER, null, InputOption::VALUE_REQUIRED); } } diff --git a/src/Console/Command/InitCommand.php b/src/Console/Command/InitCommand.php index 1b713ec5dbf..07eb4b9c337 100644 --- a/src/Console/Command/InitCommand.php +++ b/src/Console/Command/InitCommand.php @@ -13,7 +13,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Input\InputOption; use RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; use RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle; use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem; -final class InitCommand extends \RectorPrefix20220607\Symfony\Component\Console\Command\Command +final class InitCommand extends Command { /** * @var string @@ -39,7 +39,7 @@ final class InitCommand extends \RectorPrefix20220607\Symfony\Component\Console\ * @var \Symfony\Component\Console\Style\SymfonyStyle */ private $symfonyStyle; - public function __construct(\RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider, \RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle) + public function __construct(SmartFileSystem $smartFileSystem, OutputStyleInterface $rectorOutputStyle, PhpVersionProvider $phpVersionProvider, SymfonyStyle $symfonyStyle) { $this->smartFileSystem = $smartFileSystem; $this->rectorOutputStyle = $rectorOutputStyle; @@ -52,11 +52,11 @@ final class InitCommand extends \RectorPrefix20220607\Symfony\Component\Console\ $this->setName('init'); $this->setDescription('Generate rector.php configuration file'); // deprecated - $this->addOption(\Rector\Core\Configuration\Option::TEMPLATE_TYPE, null, \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_OPTIONAL, 'A template type like default, nette, doctrine etc.'); + $this->addOption(Option::TEMPLATE_TYPE, null, InputOption::VALUE_OPTIONAL, 'A template type like default, nette, doctrine etc.'); } - protected function execute(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : int + protected function execute(InputInterface $input, OutputInterface $output) : int { - $templateType = (string) $input->getOption(\Rector\Core\Configuration\Option::TEMPLATE_TYPE); + $templateType = (string) $input->getOption(Option::TEMPLATE_TYPE); if ($templateType !== '') { // notice warning $this->symfonyStyle->warning('The option "--type" is deprecated. Custom config should be part of project documentation instead.'); @@ -69,12 +69,12 @@ final class InitCommand extends \RectorPrefix20220607\Symfony\Component\Console\ } else { $this->smartFileSystem->copy(self::TEMPLATE_PATH, $rectorRootFilePath); $fullPHPVersion = (string) $this->phpVersionProvider->provide(); - $phpVersion = \RectorPrefix20220607\Nette\Utils\Strings::substring($fullPHPVersion, 0, 1) . \RectorPrefix20220607\Nette\Utils\Strings::substring($fullPHPVersion, 2, 1); + $phpVersion = Strings::substring($fullPHPVersion, 0, 1) . Strings::substring($fullPHPVersion, 2, 1); $fileContent = $this->smartFileSystem->readFile($rectorRootFilePath); $fileContent = \str_replace('LevelSetList::UP_TO_PHP_XY', \sprintf('LevelSetList::UP_TO_PHP_%d', $phpVersion), $fileContent); $this->smartFileSystem->dumpFile($rectorRootFilePath, $fileContent); $this->rectorOutputStyle->success('"rector.php" config file was added'); } - return \RectorPrefix20220607\Symfony\Component\Console\Command\Command::SUCCESS; + return Command::SUCCESS; } } diff --git a/src/Console/Command/ProcessCommand.php b/src/Console/Command/ProcessCommand.php index f91be364752..7c27750adf2 100644 --- a/src/Console/Command/ProcessCommand.php +++ b/src/Console/Command/ProcessCommand.php @@ -22,7 +22,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Application; use RectorPrefix20220607\Symfony\Component\Console\Command\Command; use RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface; use RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class ProcessCommand extends \Rector\Core\Console\Command\AbstractProcessCommand { /** @@ -75,7 +75,7 @@ final class ProcessCommand extends \Rector\Core\Console\Command\AbstractProcessC * @var \Rector\Core\Util\MemoryLimiter */ private $memoryLimiter; - public function __construct(\Rector\Core\Autoloading\AdditionalAutoloader $additionalAutoloader, \Rector\Caching\Detector\ChangedFilesDetector $changedFilesDetector, \Rector\Core\Reporting\MissingRectorRulesReporter $missingRectorRulesReporter, \Rector\Core\Application\ApplicationFileProcessor $applicationFileProcessor, \Rector\Core\ValueObjectFactory\ProcessResultFactory $processResultFactory, \Rector\Core\StaticReflection\DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator, \Rector\Core\Validation\EmptyConfigurableRectorChecker $emptyConfigurableRectorChecker, \Rector\Core\Console\Output\OutputFormatterCollector $outputFormatterCollector, \Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle, \Rector\Core\Util\MemoryLimiter $memoryLimiter) + public function __construct(AdditionalAutoloader $additionalAutoloader, ChangedFilesDetector $changedFilesDetector, MissingRectorRulesReporter $missingRectorRulesReporter, ApplicationFileProcessor $applicationFileProcessor, ProcessResultFactory $processResultFactory, DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator, EmptyConfigurableRectorChecker $emptyConfigurableRectorChecker, OutputFormatterCollector $outputFormatterCollector, OutputStyleInterface $rectorOutputStyle, MemoryLimiter $memoryLimiter) { $this->additionalAutoloader = $additionalAutoloader; $this->changedFilesDetector = $changedFilesDetector; @@ -95,7 +95,7 @@ final class ProcessCommand extends \Rector\Core\Console\Command\AbstractProcessC $this->setDescription('Upgrades or refactors source code with provided rectors'); parent::configure(); } - protected function execute(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : int + protected function execute(InputInterface $input, OutputInterface $output) : int { $exitCode = $this->missingRectorRulesReporter->reportIfMissing(); if ($exitCode !== null) { @@ -104,8 +104,8 @@ final class ProcessCommand extends \Rector\Core\Console\Command\AbstractProcessC $configuration = $this->configurationFactory->createFromInput($input); $this->memoryLimiter->adjust($configuration); // disable console output in case of json output formatter - if ($configuration->getOutputFormat() === \Rector\ChangesReporting\Output\JsonOutputFormatter::NAME) { - $this->rectorOutputStyle->setVerbosity(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_QUIET); + if ($configuration->getOutputFormat() === JsonOutputFormatter::NAME) { + $this->rectorOutputStyle->setVerbosity(OutputInterface::VERBOSITY_QUIET); } $this->additionalAutoloader->autoloadInput($input); $this->additionalAutoloader->autoloadPaths(); @@ -128,23 +128,23 @@ final class ProcessCommand extends \Rector\Core\Console\Command\AbstractProcessC $this->invalidateCacheForChangedAndErroredFiles($processResult); return $this->resolveReturnCode($processResult, $configuration); } - protected function initialize(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : void + protected function initialize(InputInterface $input, OutputInterface $output) : void { $application = $this->getApplication(); - if (!$application instanceof \RectorPrefix20220607\Symfony\Component\Console\Application) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$application instanceof Application) { + throw new ShouldNotHappenException(); } - $optionDebug = (bool) $input->getOption(\Rector\Core\Configuration\Option::DEBUG); + $optionDebug = (bool) $input->getOption(Option::DEBUG); if ($optionDebug) { $application->setCatchExceptions(\false); } // clear cache - $optionClearCache = (bool) $input->getOption(\Rector\Core\Configuration\Option::CLEAR_CACHE); + $optionClearCache = (bool) $input->getOption(Option::CLEAR_CACHE); if ($optionDebug || $optionClearCache) { $this->changedFilesDetector->clear(); } } - private function invalidateCacheForChangedAndErroredFiles(\Rector\Core\ValueObject\ProcessResult $processResult) : void + private function invalidateCacheForChangedAndErroredFiles(ProcessResult $processResult) : void { foreach ($processResult->getChangedFileInfos() as $changedFileInfo) { $this->changedFilesDetector->invalidateFile($changedFileInfo); @@ -154,20 +154,20 @@ final class ProcessCommand extends \Rector\Core\Console\Command\AbstractProcessC if (!\is_string($errorFile)) { continue; } - $errorFileInfo = new \Symplify\SmartFileSystem\SmartFileInfo($errorFile); + $errorFileInfo = new SmartFileInfo($errorFile); $this->changedFilesDetector->invalidateFile($errorFileInfo); } } - private function resolveReturnCode(\Rector\Core\ValueObject\ProcessResult $processResult, \Rector\Core\ValueObject\Configuration $configuration) : int + private function resolveReturnCode(ProcessResult $processResult, Configuration $configuration) : int { // some system errors were found → fail if ($processResult->getErrors() !== []) { - return \RectorPrefix20220607\Symfony\Component\Console\Command\Command::FAILURE; + return Command::FAILURE; } // inverse error code for CI dry-run if (!$configuration->isDryRun()) { - return \RectorPrefix20220607\Symfony\Component\Console\Command\Command::SUCCESS; + return Command::SUCCESS; } - return $processResult->getFileDiffs() === [] ? \RectorPrefix20220607\Symfony\Component\Console\Command\Command::SUCCESS : \RectorPrefix20220607\Symfony\Component\Console\Command\Command::FAILURE; + return $processResult->getFileDiffs() === [] ? Command::SUCCESS : Command::FAILURE; } } diff --git a/src/Console/Command/WorkerCommand.php b/src/Console/Command/WorkerCommand.php index 7a1056b0278..144a1b546b9 100644 --- a/src/Console/Command/WorkerCommand.php +++ b/src/Console/Command/WorkerCommand.php @@ -33,7 +33,7 @@ final class WorkerCommand extends \Rector\Core\Console\Command\AbstractProcessCo * @var \Rector\Core\Util\MemoryLimiter */ private $memoryLimiter; - public function __construct(\Rector\Parallel\WorkerRunner $workerRunner, \Rector\Core\Util\MemoryLimiter $memoryLimiter) + public function __construct(WorkerRunner $workerRunner, MemoryLimiter $memoryLimiter) { $this->workerRunner = $workerRunner; $this->memoryLimiter = $memoryLimiter; @@ -45,19 +45,19 @@ final class WorkerCommand extends \Rector\Core\Console\Command\AbstractProcessCo $this->setDescription('(Internal) Support for parallel process'); parent::configure(); } - protected function execute(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : int + protected function execute(InputInterface $input, OutputInterface $output) : int { $configuration = $this->configurationFactory->createFromInput($input); $this->memoryLimiter->adjust($configuration); - $streamSelectLoop = new \RectorPrefix20220607\React\EventLoop\StreamSelectLoop(); + $streamSelectLoop = new StreamSelectLoop(); $parallelIdentifier = $configuration->getParallelIdentifier(); - $tcpConnector = new \RectorPrefix20220607\React\Socket\TcpConnector($streamSelectLoop); + $tcpConnector = new TcpConnector($streamSelectLoop); $promise = $tcpConnector->connect('127.0.0.1:' . $configuration->getParallelPort()); - $promise->then(function (\RectorPrefix20220607\React\Socket\ConnectionInterface $connection) use($parallelIdentifier, $configuration) : void { - $inDecoder = new \RectorPrefix20220607\Clue\React\NDJson\Decoder($connection, \true, 512, \JSON_INVALID_UTF8_IGNORE); - $outEncoder = new \RectorPrefix20220607\Clue\React\NDJson\Encoder($connection, \JSON_INVALID_UTF8_IGNORE); + $promise->then(function (ConnectionInterface $connection) use($parallelIdentifier, $configuration) : void { + $inDecoder = new Decoder($connection, \true, 512, \JSON_INVALID_UTF8_IGNORE); + $outEncoder = new Encoder($connection, \JSON_INVALID_UTF8_IGNORE); // handshake? - $outEncoder->write([\RectorPrefix20220607\Symplify\EasyParallel\Enum\ReactCommand::ACTION => \RectorPrefix20220607\Symplify\EasyParallel\Enum\Action::HELLO, \RectorPrefix20220607\Symplify\EasyParallel\Enum\ReactCommand::IDENTIFIER => $parallelIdentifier]); + $outEncoder->write([ReactCommand::ACTION => Action::HELLO, ReactCommand::IDENTIFIER => $parallelIdentifier]); $this->workerRunner->run($outEncoder, $inDecoder, $configuration); }); $streamSelectLoop->run(); diff --git a/src/Console/ConsoleApplication.php b/src/Console/ConsoleApplication.php index 751e98a8673..7524ce21cef 100644 --- a/src/Console/ConsoleApplication.php +++ b/src/Console/ConsoleApplication.php @@ -15,7 +15,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface; use RectorPrefix20220607\Symfony\Component\Console\Input\InputOption; use RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; use RectorPrefix20220607\Symplify\PackageBuilder\Console\Command\CommandNaming; -final class ConsoleApplication extends \RectorPrefix20220607\Symfony\Component\Console\Application +final class ConsoleApplication extends Application { /** * @var string @@ -26,16 +26,16 @@ final class ConsoleApplication extends \RectorPrefix20220607\Symfony\Component\C */ public function __construct(array $commands = []) { - parent::__construct(self::NAME, \Rector\Core\Application\VersionResolver::PACKAGE_VERSION); + parent::__construct(self::NAME, VersionResolver::PACKAGE_VERSION); $this->addCommands($commands); - $this->setDefaultCommand(\RectorPrefix20220607\Symplify\PackageBuilder\Console\Command\CommandNaming::classToName(\Rector\Core\Console\Command\ProcessCommand::class)); + $this->setDefaultCommand(CommandNaming::classToName(ProcessCommand::class)); } - public function doRun(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : int + public function doRun(InputInterface $input, OutputInterface $output) : int { // @fixes https://github.com/rectorphp/rector/issues/2205 $isXdebugAllowed = $input->hasParameterOption('--xdebug'); if (!$isXdebugAllowed) { - $xdebugHandler = new \RectorPrefix20220607\Composer\XdebugHandler\XdebugHandler('rector'); + $xdebugHandler = new XdebugHandler('rector'); $xdebugHandler->check(); unset($xdebugHandler); } @@ -50,14 +50,14 @@ final class ConsoleApplication extends \RectorPrefix20220607\Symfony\Component\C } return parent::doRun($input, $output); } - protected function getDefaultInputDefinition() : \RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition + protected function getDefaultInputDefinition() : InputDefinition { $defaultInputDefinition = parent::getDefaultInputDefinition(); $this->removeUnusedOptions($defaultInputDefinition); $this->addCustomOptions($defaultInputDefinition); return $defaultInputDefinition; } - private function shouldPrintMetaInformation(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input) : bool + private function shouldPrintMetaInformation(InputInterface $input) : bool { $hasNoArguments = $input->getFirstArgument() === null; if ($hasNoArguments) { @@ -68,20 +68,20 @@ final class ConsoleApplication extends \RectorPrefix20220607\Symfony\Component\C return \false; } $outputFormat = $input->getParameterOption(['-o', '--output-format']); - return $outputFormat === \Rector\ChangesReporting\Output\ConsoleOutputFormatter::NAME; + return $outputFormat === ConsoleOutputFormatter::NAME; } - private function removeUnusedOptions(\RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition $inputDefinition) : void + private function removeUnusedOptions(InputDefinition $inputDefinition) : void { $options = $inputDefinition->getOptions(); unset($options['quiet'], $options['no-interaction']); $inputDefinition->setOptions($options); } - private function addCustomOptions(\RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition $inputDefinition) : void + private function addCustomOptions(InputDefinition $inputDefinition) : void { - $inputDefinition->addOption(new \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption(\Rector\Core\Configuration\Option::CONFIG, 'c', \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED, 'Path to config file', $this->getDefaultConfigPath())); - $inputDefinition->addOption(new \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption(\Rector\Core\Configuration\Option::DEBUG, null, \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Enable debug verbosity (-vvv)')); - $inputDefinition->addOption(new \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption(\Rector\Core\Configuration\Option::XDEBUG, null, \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Allow running xdebug')); - $inputDefinition->addOption(new \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption(\Rector\Core\Configuration\Option::CLEAR_CACHE, null, \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Clear cache')); + $inputDefinition->addOption(new InputOption(Option::CONFIG, 'c', InputOption::VALUE_REQUIRED, 'Path to config file', $this->getDefaultConfigPath())); + $inputDefinition->addOption(new InputOption(Option::DEBUG, null, InputOption::VALUE_NONE, 'Enable debug verbosity (-vvv)')); + $inputDefinition->addOption(new InputOption(Option::XDEBUG, null, InputOption::VALUE_NONE, 'Allow running xdebug')); + $inputDefinition->addOption(new InputOption(Option::CLEAR_CACHE, null, InputOption::VALUE_NONE, 'Clear cache')); } private function getDefaultConfigPath() : string { diff --git a/src/Console/Output/OutputFormatterCollector.php b/src/Console/Output/OutputFormatterCollector.php index 5e0bf65dac6..574014088c4 100644 --- a/src/Console/Output/OutputFormatterCollector.php +++ b/src/Console/Output/OutputFormatterCollector.php @@ -20,7 +20,7 @@ final class OutputFormatterCollector $this->outputFormatters[$outputFormatter->getName()] = $outputFormatter; } } - public function getByName(string $name) : \Rector\ChangesReporting\Contract\Output\OutputFormatterInterface + public function getByName(string $name) : OutputFormatterInterface { $this->ensureOutputFormatExists($name); return $this->outputFormatters[$name]; @@ -37,6 +37,6 @@ final class OutputFormatterCollector if (isset($this->outputFormatters[$name])) { return; } - throw new \Rector\Core\Exception\Configuration\InvalidConfigurationException(\sprintf('Output formatter "%s" was not found. Pick one of "%s".', $name, \implode('", "', $this->getNames()))); + throw new InvalidConfigurationException(\sprintf('Output formatter "%s" was not found. Pick one of "%s".', $name, \implode('", "', $this->getNames()))); } } diff --git a/src/Console/Output/RectorOutputStyle.php b/src/Console/Output/RectorOutputStyle.php index 604e7bca837..817f5f4d5dd 100644 --- a/src/Console/Output/RectorOutputStyle.php +++ b/src/Console/Output/RectorOutputStyle.php @@ -9,14 +9,14 @@ use Rector\Core\Contract\Console\OutputStyleInterface; * This services helps to abstract from Symfony, and allow custom output formatters to use this Rector internal class. * It is very helpful while scoping Rector from analysed project. */ -final class RectorOutputStyle implements \Rector\Core\Contract\Console\OutputStyleInterface +final class RectorOutputStyle implements OutputStyleInterface { /** * @readonly * @var \Rector\Core\Console\Style\RectorConsoleOutputStyle */ private $rectorConsoleOutputStyle; - public function __construct(\Rector\Core\Console\Style\RectorConsoleOutputStyle $rectorConsoleOutputStyle) + public function __construct(RectorConsoleOutputStyle $rectorConsoleOutputStyle) { $this->rectorConsoleOutputStyle = $rectorConsoleOutputStyle; } diff --git a/src/Console/Style/RectorConsoleOutputStyle.php b/src/Console/Style/RectorConsoleOutputStyle.php index 48c20e97084..9529ad8780b 100644 --- a/src/Console/Style/RectorConsoleOutputStyle.php +++ b/src/Console/Style/RectorConsoleOutputStyle.php @@ -9,7 +9,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Helper\ProgressBar; use RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface; use RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; use RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle; -final class RectorConsoleOutputStyle extends \RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle +final class RectorConsoleOutputStyle extends SymfonyStyle { /** * @var mixed|ProgressBar @@ -19,18 +19,18 @@ final class RectorConsoleOutputStyle extends \RectorPrefix20220607\Symfony\Compo * @var bool|null */ private $isCiDetected = null; - public function __construct(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) + public function __construct(InputInterface $input, OutputInterface $output) { parent::__construct($input, $output); // silent output in tests if (\defined('PHPUNIT_COMPOSER_INSTALL')) { - $this->setVerbosity(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_QUIET); + $this->setVerbosity(OutputInterface::VERBOSITY_QUIET); } } /** * @see https://github.com/phpstan/phpstan-src/commit/0993d180e5a15a17631d525909356081be59ffeb */ - public function createProgressBar(int $max = 0) : \RectorPrefix20220607\Symfony\Component\Console\Helper\ProgressBar + public function createProgressBar(int $max = 0) : ProgressBar { $progressBar = parent::createProgressBar($max); $progressBar->setOverwrite(!$this->isCiDetected()); @@ -63,15 +63,15 @@ final class RectorConsoleOutputStyle extends \RectorPrefix20220607\Symfony\Compo private function isCiDetected() : bool { if ($this->isCiDetected === null) { - $ciDetector = new \RectorPrefix20220607\OndraM\CiDetector\CiDetector(); + $ciDetector = new CiDetector(); $this->isCiDetected = $ciDetector->isCiDetected(); } return $this->isCiDetected; } - private function getProgressBar() : \RectorPrefix20220607\Symfony\Component\Console\Helper\ProgressBar + private function getProgressBar() : ProgressBar { if (!isset($this->progressBar)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\RuntimeException('The ProgressBar is not started.'); + throw new RuntimeException('The ProgressBar is not started.'); } return $this->progressBar; } diff --git a/src/Console/Style/RectorConsoleOutputStyleFactory.php b/src/Console/Style/RectorConsoleOutputStyleFactory.php index c174da34b33..9cc1e11772f 100644 --- a/src/Console/Style/RectorConsoleOutputStyleFactory.php +++ b/src/Console/Style/RectorConsoleOutputStyleFactory.php @@ -15,19 +15,19 @@ final class RectorConsoleOutputStyleFactory * @var \Symplify\PackageBuilder\Reflection\PrivatesCaller */ private $privatesCaller; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller $privatesCaller) + public function __construct(PrivatesCaller $privatesCaller) { $this->privatesCaller = $privatesCaller; } public function create() : \Rector\Core\Console\Style\RectorConsoleOutputStyle { - $argvInput = new \RectorPrefix20220607\Symfony\Component\Console\Input\ArgvInput(); - $consoleOutput = new \RectorPrefix20220607\Symfony\Component\Console\Output\ConsoleOutput(); + $argvInput = new ArgvInput(); + $consoleOutput = new ConsoleOutput(); // to configure all -v, -vv, -vvv options without memory-lock to Application run() arguments - $this->privatesCaller->callPrivateMethod(new \RectorPrefix20220607\Symfony\Component\Console\Application(), 'configureIO', [$argvInput, $consoleOutput]); + $this->privatesCaller->callPrivateMethod(new Application(), 'configureIO', [$argvInput, $consoleOutput]); // --debug is called if ($argvInput->hasParameterOption('--debug')) { - $consoleOutput->setVerbosity(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_DEBUG); + $consoleOutput->setVerbosity(OutputInterface::VERBOSITY_DEBUG); } return new \Rector\Core\Console\Style\RectorConsoleOutputStyle($argvInput, $consoleOutput); } diff --git a/src/Contract/PHPStan/Reflection/TypeToCallReflectionResolver/TypeToCallReflectionResolverInterface.php b/src/Contract/PHPStan/Reflection/TypeToCallReflectionResolver/TypeToCallReflectionResolverInterface.php index 9bf2a1ffc4a..6ea4010ac15 100644 --- a/src/Contract/PHPStan/Reflection/TypeToCallReflectionResolver/TypeToCallReflectionResolverInterface.php +++ b/src/Contract/PHPStan/Reflection/TypeToCallReflectionResolver/TypeToCallReflectionResolverInterface.php @@ -12,10 +12,10 @@ use PHPStan\Type\Type; */ interface TypeToCallReflectionResolverInterface { - public function supports(\PHPStan\Type\Type $type) : bool; + public function supports(Type $type) : bool; /** * @param TType $type * @return FunctionReflection|MethodReflection|null */ - public function resolve(\PHPStan\Type\Type $type, \PHPStan\Analyser\Scope $scope); + public function resolve(Type $type, Scope $scope); } diff --git a/src/Contract/PhpParser/Node/StmtsAwareInterface.php b/src/Contract/PhpParser/Node/StmtsAwareInterface.php index 14b6ece528e..ce0a923e02a 100644 --- a/src/Contract/PhpParser/Node/StmtsAwareInterface.php +++ b/src/Contract/PhpParser/Node/StmtsAwareInterface.php @@ -8,6 +8,6 @@ use PhpParser\Node\Stmt; /** * @property Stmt[]|null $stmts */ -interface StmtsAwareInterface extends \PhpParser\Node +interface StmtsAwareInterface extends Node { } diff --git a/src/Contract/Processor/FileProcessorInterface.php b/src/Contract/Processor/FileProcessorInterface.php index 25d6a4b7749..b1200820b9e 100644 --- a/src/Contract/Processor/FileProcessorInterface.php +++ b/src/Contract/Processor/FileProcessorInterface.php @@ -9,11 +9,11 @@ use Rector\Core\ValueObject\Error\SystemError; use Rector\Core\ValueObject\Reporting\FileDiff; interface FileProcessorInterface { - public function supports(\Rector\Core\ValueObject\Application\File $file, \Rector\Core\ValueObject\Configuration $configuration) : bool; + public function supports(File $file, Configuration $configuration) : bool; /** * @return array{system_errors: SystemError[], file_diffs: FileDiff[]} */ - public function process(\Rector\Core\ValueObject\Application\File $file, \Rector\Core\ValueObject\Configuration $configuration) : array; + public function process(File $file, Configuration $configuration) : array; /** * @return string[] */ diff --git a/src/Contract/Rector/ConfigurableRectorInterface.php b/src/Contract/Rector/ConfigurableRectorInterface.php index ca55b2a3849..fe534a6fd6d 100644 --- a/src/Contract/Rector/ConfigurableRectorInterface.php +++ b/src/Contract/Rector/ConfigurableRectorInterface.php @@ -3,8 +3,8 @@ declare (strict_types=1); namespace Rector\Core\Contract\Rector; -use Symplify\RuleDocGenerator\Contract\ConfigurableRuleInterface; -interface ConfigurableRectorInterface extends \Symplify\RuleDocGenerator\Contract\ConfigurableRuleInterface +use RectorPrefix20220607\Symplify\RuleDocGenerator\Contract\ConfigurableRuleInterface; +interface ConfigurableRectorInterface extends ConfigurableRuleInterface { /** * @param mixed[] $configuration diff --git a/src/Contract/Rector/PhpRectorInterface.php b/src/Contract/Rector/PhpRectorInterface.php index 086bc8f5fa5..880cbd44aef 100644 --- a/src/Contract/Rector/PhpRectorInterface.php +++ b/src/Contract/Rector/PhpRectorInterface.php @@ -5,7 +5,7 @@ namespace Rector\Core\Contract\Rector; use PhpParser\Node; use PhpParser\NodeVisitor; -interface PhpRectorInterface extends \PhpParser\NodeVisitor, \Rector\Core\Contract\Rector\RectorInterface +interface PhpRectorInterface extends NodeVisitor, \Rector\Core\Contract\Rector\RectorInterface { /** * List of nodes this class checks, classes that implements \PhpParser\Node @@ -18,5 +18,5 @@ interface PhpRectorInterface extends \PhpParser\NodeVisitor, \Rector\Core\Contra * Process Node of matched type * @return Node|Node[]|null */ - public function refactor(\PhpParser\Node $node); + public function refactor(Node $node); } diff --git a/src/Contract/Rector/RectorInterface.php b/src/Contract/Rector/RectorInterface.php index 832178afac4..2bf5488d0ee 100644 --- a/src/Contract/Rector/RectorInterface.php +++ b/src/Contract/Rector/RectorInterface.php @@ -3,7 +3,7 @@ declare (strict_types=1); namespace Rector\Core\Contract\Rector; -use Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface; -interface RectorInterface extends \Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface +use RectorPrefix20220607\Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface; +interface RectorInterface extends DocumentedRuleInterface { } diff --git a/src/Contract/Rector/ScopeAwarePhpRectorInterface.php b/src/Contract/Rector/ScopeAwarePhpRectorInterface.php index b8f4ac071ca..74a59b127a7 100644 --- a/src/Contract/Rector/ScopeAwarePhpRectorInterface.php +++ b/src/Contract/Rector/ScopeAwarePhpRectorInterface.php @@ -11,5 +11,5 @@ interface ScopeAwarePhpRectorInterface extends \Rector\Core\Contract\Rector\PhpR * Process Node of matched type with its PHPStan scope * @return Node|Node[]|null */ - public function refactorWithScope(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope); + public function refactorWithScope(Node $node, Scope $scope); } diff --git a/src/DependencyInjection/Collector/ConfigureCallValuesCollector.php b/src/DependencyInjection/Collector/ConfigureCallValuesCollector.php index 02708e9716a..87f67eef671 100644 --- a/src/DependencyInjection/Collector/ConfigureCallValuesCollector.php +++ b/src/DependencyInjection/Collector/ConfigureCallValuesCollector.php @@ -28,8 +28,8 @@ final class ConfigureCallValuesCollector private $symfonyStyle; public function __construct() { - $this->parametersMerger = new \RectorPrefix20220607\Symplify\PackageBuilder\Yaml\ParametersMerger(); - $symfonyStyleFactory = new \RectorPrefix20220607\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory(); + $this->parametersMerger = new ParametersMerger(); + $symfonyStyleFactory = new SymfonyStyleFactory(); $this->symfonyStyle = $symfonyStyleFactory->create(); } /** @@ -42,7 +42,7 @@ final class ConfigureCallValuesCollector /** * @param class-string $className */ - public function collectFromServiceAndClassName(string $className, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) : void + public function collectFromServiceAndClassName(string $className, Definition $definition) : void { foreach ($definition->getMethodCalls() as $methodCall) { if ($methodCall[0] !== 'configure') { @@ -65,7 +65,7 @@ final class ConfigureCallValuesCollector if (\is_string($firstKey) && \is_array($configureValue[$firstKey])) { // has class some public constants? // fixes bug when 1 item is unwrapped and treated as constant key, without rule having public constant - $classReflection = new \ReflectionClass($rectorClass); + $classReflection = new ReflectionClass($rectorClass); $reflectionClassConstants = $classReflection->getReflectionConstants(); $result = []; \array_walk($reflectionClassConstants, function ($value) use(&$result) { diff --git a/src/DependencyInjection/CompilerPass/MakeRectorsPublicCompilerPass.php b/src/DependencyInjection/CompilerPass/MakeRectorsPublicCompilerPass.php index f16ac125431..2b16ad455d2 100644 --- a/src/DependencyInjection/CompilerPass/MakeRectorsPublicCompilerPass.php +++ b/src/DependencyInjection/CompilerPass/MakeRectorsPublicCompilerPass.php @@ -6,15 +6,15 @@ namespace Rector\Core\DependencyInjection\CompilerPass; use Rector\Core\Contract\Rector\RectorInterface; use RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder; -final class MakeRectorsPublicCompilerPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +final class MakeRectorsPublicCompilerPass implements CompilerPassInterface { - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder) : void + public function process(ContainerBuilder $containerBuilder) : void { foreach ($containerBuilder->getDefinitions() as $definition) { if ($definition->getClass() === null) { continue; } - if (!\is_a($definition->getClass(), \Rector\Core\Contract\Rector\RectorInterface::class, \true)) { + if (!\is_a($definition->getClass(), RectorInterface::class, \true)) { continue; } $definition->setPublic(\true); diff --git a/src/DependencyInjection/CompilerPass/MergeImportedRectorConfigureCallValuesCompilerPass.php b/src/DependencyInjection/CompilerPass/MergeImportedRectorConfigureCallValuesCompilerPass.php index 1fa96d4f22e..5a928654473 100644 --- a/src/DependencyInjection/CompilerPass/MergeImportedRectorConfigureCallValuesCompilerPass.php +++ b/src/DependencyInjection/CompilerPass/MergeImportedRectorConfigureCallValuesCompilerPass.php @@ -7,7 +7,7 @@ use Rector\Core\DependencyInjection\Collector\ConfigureCallValuesCollector; use RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder; use RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition; -final class MergeImportedRectorConfigureCallValuesCompilerPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +final class MergeImportedRectorConfigureCallValuesCompilerPass implements CompilerPassInterface { /** * @var string @@ -18,17 +18,17 @@ final class MergeImportedRectorConfigureCallValuesCompilerPass implements \Recto * @var \Rector\Core\DependencyInjection\Collector\ConfigureCallValuesCollector */ private $configureCallValuesCollector; - public function __construct(\Rector\Core\DependencyInjection\Collector\ConfigureCallValuesCollector $configureCallValuesCollector) + public function __construct(ConfigureCallValuesCollector $configureCallValuesCollector) { $this->configureCallValuesCollector = $configureCallValuesCollector; } - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder) : void + public function process(ContainerBuilder $containerBuilder) : void { foreach ($containerBuilder->getDefinitions() as $id => $definition) { $this->completeCollectedArguments($id, $definition); } } - private function completeCollectedArguments(string $serviceClass, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) : void + private function completeCollectedArguments(string $serviceClass, Definition $definition) : void { $configureCallValues = $this->configureCallValuesCollector->getConfigureCallValues($serviceClass); if ($configureCallValues === []) { diff --git a/src/DependencyInjection/CompilerPass/RemoveSkippedRectorsCompilerPass.php b/src/DependencyInjection/CompilerPass/RemoveSkippedRectorsCompilerPass.php index e6f25ae0591..64c384fccbd 100644 --- a/src/DependencyInjection/CompilerPass/RemoveSkippedRectorsCompilerPass.php +++ b/src/DependencyInjection/CompilerPass/RemoveSkippedRectorsCompilerPass.php @@ -11,9 +11,9 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder; * This compiler pass removed Rectors skipped in `SKIP` parameters. * It uses Skipper from Symplify - https://github.com/symplify/skipper */ -final class RemoveSkippedRectorsCompilerPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +final class RemoveSkippedRectorsCompilerPass implements CompilerPassInterface { - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder) : void + public function process(ContainerBuilder $containerBuilder) : void { $skippedRectorClasses = $this->resolveSkippedRectorClasses($containerBuilder); foreach ($containerBuilder->getDefinitions() as $id => $definition) { @@ -29,9 +29,9 @@ final class RemoveSkippedRectorsCompilerPass implements \RectorPrefix20220607\Sy /** * @return string[] */ - private function resolveSkippedRectorClasses(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder) : array + private function resolveSkippedRectorClasses(ContainerBuilder $containerBuilder) : array { - $skipParameters = (array) $containerBuilder->getParameter(\Rector\Core\Configuration\Option::SKIP); + $skipParameters = (array) $containerBuilder->getParameter(Option::SKIP); return \array_filter($skipParameters, function ($element) : bool { return $this->isRectorClass($element); }); @@ -44,6 +44,6 @@ final class RemoveSkippedRectorsCompilerPass implements \RectorPrefix20220607\Sy if (!\is_string($element)) { return \false; } - return \is_a($element, \Rector\Core\Contract\Rector\RectorInterface::class, \true); + return \is_a($element, RectorInterface::class, \true); } } diff --git a/src/DependencyInjection/Loader/ConfigurableCallValuesCollectingPhpFileLoader.php b/src/DependencyInjection/Loader/ConfigurableCallValuesCollectingPhpFileLoader.php index c50ef9b3b46..9118c1ba03f 100644 --- a/src/DependencyInjection/Loader/ConfigurableCallValuesCollectingPhpFileLoader.php +++ b/src/DependencyInjection/Loader/ConfigurableCallValuesCollectingPhpFileLoader.php @@ -11,14 +11,14 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\PhpFileLoa /** * @property-read ContainerBuilder $container */ -final class ConfigurableCallValuesCollectingPhpFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\PhpFileLoader +final class ConfigurableCallValuesCollectingPhpFileLoader extends PhpFileLoader { /** * @readonly * @var \Rector\Core\DependencyInjection\Collector\ConfigureCallValuesCollector */ private $configureCallValuesCollector; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder, \RectorPrefix20220607\Symfony\Component\Config\FileLocatorInterface $fileLocator, \Rector\Core\DependencyInjection\Collector\ConfigureCallValuesCollector $configureCallValuesCollector) + public function __construct(ContainerBuilder $containerBuilder, FileLocatorInterface $fileLocator, ConfigureCallValuesCollector $configureCallValuesCollector) { $this->configureCallValuesCollector = $configureCallValuesCollector; parent::__construct($containerBuilder, $fileLocator); @@ -51,7 +51,7 @@ final class ConfigurableCallValuesCollectingPhpFileLoader extends \RectorPrefix2 private function collectConfigureCallsFromJustImportedConfigurableRectorDefinitions() : void { foreach ($this->container->getDefinitions() as $class => $definition) { - if (!\is_a($class, \Rector\Core\Contract\Rector\ConfigurableRectorInterface::class, \true)) { + if (!\is_a($class, ConfigurableRectorInterface::class, \true)) { continue; } $this->configureCallValuesCollector->collectFromServiceAndClassName($class, $definition); diff --git a/src/DependencyInjection/Loader/Configurator/RectorServiceConfigurator.php b/src/DependencyInjection/Loader/Configurator/RectorServiceConfigurator.php index 1f28ad1d0a5..0b0ddad1baa 100644 --- a/src/DependencyInjection/Loader/Configurator/RectorServiceConfigurator.php +++ b/src/DependencyInjection/Loader/Configurator/RectorServiceConfigurator.php @@ -11,7 +11,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurat * @api * Same as Symfony service configurator, with extra "configure()" method for easier DX */ -final class RectorServiceConfigurator extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ServiceConfigurator +final class RectorServiceConfigurator extends ServiceConfigurator { /** * @deprecated Use @see \Rector\Config\RectorConfig instead @@ -23,7 +23,7 @@ final class RectorServiceConfigurator extends \RectorPrefix20220607\Symfony\Comp // decorate with value object inliner so Symfony understands, see https://getrector.org/blog/2020/09/07/how-to-inline-value-object-in-symfony-php-config \array_walk_recursive($configuration, function (&$value) { if (\is_object($value)) { - $value = \Rector\Core\Configuration\ValueObjectInliner::inline($value); + $value = ValueObjectInliner::inline($value); } return $value; }); @@ -33,11 +33,11 @@ final class RectorServiceConfigurator extends \RectorPrefix20220607\Symfony\Comp private function ensureClassIsConfigurable(?string $class) : void { if ($class === null) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException('The class is missing'); + throw new InvalidConfigurationException('The class is missing'); } - if (!\is_a($class, \Rector\Core\Contract\Rector\ConfigurableRectorInterface::class, \true)) { - $errorMessage = \sprintf('The service "%s" is not configurable. Make it implement "%s" or remove "configure()" call.', $class, \Rector\Core\Contract\Rector\ConfigurableRectorInterface::class); - throw new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException($errorMessage); + if (!\is_a($class, ConfigurableRectorInterface::class, \true)) { + $errorMessage = \sprintf('The service "%s" is not configurable. Make it implement "%s" or remove "configure()" call.', $class, ConfigurableRectorInterface::class); + throw new InvalidConfigurationException($errorMessage); } } } diff --git a/src/DependencyInjection/RectorContainerFactory.php b/src/DependencyInjection/RectorContainerFactory.php index 33442ef7484..b9110345034 100644 --- a/src/DependencyInjection/RectorContainerFactory.php +++ b/src/DependencyInjection/RectorContainerFactory.php @@ -12,27 +12,27 @@ use Rector\Core\ValueObject\Bootstrap\BootstrapConfigs; use RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle; final class RectorContainerFactory { - public function createFromBootstrapConfigs(\Rector\Core\ValueObject\Bootstrap\BootstrapConfigs $bootstrapConfigs) : \RectorPrefix20220607\Psr\Container\ContainerInterface + public function createFromBootstrapConfigs(BootstrapConfigs $bootstrapConfigs) : ContainerInterface { $container = $this->createFromConfigs($bootstrapConfigs->getConfigFiles()); $mainConfigFile = $bootstrapConfigs->getMainConfigFile(); if ($mainConfigFile !== null) { // warning about old syntax before RectorConfig - $fileContents = \RectorPrefix20220607\Nette\Utils\FileSystem::read($mainConfigFile); + $fileContents = FileSystem::read($mainConfigFile); if (\strpos($fileContents, 'ContainerConfigurator $containerConfigurator') !== \false) { /** @var SymfonyStyle $symfonyStyle */ - $symfonyStyle = $container->get(\RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle::class); + $symfonyStyle = $container->get(SymfonyStyle::class); $warningMessage = \sprintf('Your "%s" config is using old syntax with "ContainerConfigurator".%sUpgrade to "RectorConfig" that allows better autocomplete and future standard: https://getrector.org/blog/new-in-rector-012-introducing-rector-config-with-autocomplete', $mainConfigFile, \PHP_EOL); $symfonyStyle->error($warningMessage); // to make message noticable \sleep(10); } /** @var ChangedFilesDetector $changedFilesDetector */ - $changedFilesDetector = $container->get(\Rector\Caching\Detector\ChangedFilesDetector::class); + $changedFilesDetector = $container->get(ChangedFilesDetector::class); $changedFilesDetector->setFirstResolvedConfigFileInfo($mainConfigFile); } /** @var BootstrapFilesIncluder $bootstrapFilesIncluder */ - $bootstrapFilesIncluder = $container->get(\Rector\Core\Autoloading\BootstrapFilesIncluder::class); + $bootstrapFilesIncluder = $container->get(BootstrapFilesIncluder::class); $bootstrapFilesIncluder->includeBootstrapFiles(); return $container; } @@ -40,9 +40,9 @@ final class RectorContainerFactory * @param string[] $configFiles * @api */ - private function createFromConfigs(array $configFiles) : \RectorPrefix20220607\Psr\Container\ContainerInterface + private function createFromConfigs(array $configFiles) : ContainerInterface { - $rectorKernel = new \Rector\Core\Kernel\RectorKernel(); + $rectorKernel = new RectorKernel(); return $rectorKernel->createFromConfigs($configFiles); } } diff --git a/src/Differ/DefaultDiffer.php b/src/Differ/DefaultDiffer.php index 5f6a7717090..09285e12553 100644 --- a/src/Differ/DefaultDiffer.php +++ b/src/Differ/DefaultDiffer.php @@ -14,8 +14,8 @@ final class DefaultDiffer private $differ; public function __construct() { - $strictUnifiedDiffOutputBuilder = new \RectorPrefix20220607\SebastianBergmann\Diff\Output\StrictUnifiedDiffOutputBuilder(['fromFile' => 'Original', 'toFile' => 'New']); - $this->differ = new \RectorPrefix20220607\SebastianBergmann\Diff\Differ($strictUnifiedDiffOutputBuilder); + $strictUnifiedDiffOutputBuilder = new StrictUnifiedDiffOutputBuilder(['fromFile' => 'Original', 'toFile' => 'New']); + $this->differ = new Differ($strictUnifiedDiffOutputBuilder); } public function diff(string $old, string $new) : string { diff --git a/src/Error/ExceptionCorrector.php b/src/Error/ExceptionCorrector.php index b682b4da09a..e2e2acfe404 100644 --- a/src/Error/ExceptionCorrector.php +++ b/src/Error/ExceptionCorrector.php @@ -8,7 +8,7 @@ use Rector\Core\Contract\Rector\RectorInterface; use Throwable; final class ExceptionCorrector { - public function matchRectorClass(\Throwable $throwable) : ?string + public function matchRectorClass(Throwable $throwable) : ?string { if (!isset($throwable->getTrace()[0])) { return null; @@ -18,12 +18,12 @@ final class ExceptionCorrector } /** @var string $class */ $class = $throwable->getTrace()[0]['class']; - if (!\is_a($class, \Rector\Core\Contract\Rector\RectorInterface::class, \true)) { + if (!\is_a($class, RectorInterface::class, \true)) { return null; } return $class; } - public function getAutoloadExceptionMessageAndAddLocation(\PHPStan\AnalysedCodeException $analysedCodeException) : string + public function getAutoloadExceptionMessageAndAddLocation(AnalysedCodeException $analysedCodeException) : string { return \sprintf('Analyze error: "%s". Include your files in "$rectorConfig->autoloadPaths([...]);" or "$rectorConfig->bootstrapFiles([...]);" in "rector.php" config.%sSee https://github.com/rectorphp/rector#configuration', $analysedCodeException->getMessage(), \PHP_EOL); } diff --git a/src/Exception/Cache/CachingException.php b/src/Exception/Cache/CachingException.php index e6bfdb2f91f..65f23546651 100644 --- a/src/Exception/Cache/CachingException.php +++ b/src/Exception/Cache/CachingException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace Rector\Core\Exception\Cache; use Exception; -final class CachingException extends \Exception +final class CachingException extends Exception { } diff --git a/src/Exception/Configuration/InvalidConfigurationException.php b/src/Exception/Configuration/InvalidConfigurationException.php index d029a1804b9..ffa5082bdfe 100644 --- a/src/Exception/Configuration/InvalidConfigurationException.php +++ b/src/Exception/Configuration/InvalidConfigurationException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace Rector\Core\Exception\Configuration; use Exception; -final class InvalidConfigurationException extends \Exception +final class InvalidConfigurationException extends Exception { } diff --git a/src/Exception/NotImplementedYetException.php b/src/Exception/NotImplementedYetException.php index 22e091811e1..953b7d3de92 100644 --- a/src/Exception/NotImplementedYetException.php +++ b/src/Exception/NotImplementedYetException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace Rector\Core\Exception; use Exception; -final class NotImplementedYetException extends \Exception +final class NotImplementedYetException extends Exception { } diff --git a/src/Exception/ShouldNotHappenException.php b/src/Exception/ShouldNotHappenException.php index 20c0d04c252..9bc1932fb24 100644 --- a/src/Exception/ShouldNotHappenException.php +++ b/src/Exception/ShouldNotHappenException.php @@ -5,13 +5,13 @@ namespace Rector\Core\Exception; use Exception; use Throwable; -final class ShouldNotHappenException extends \Exception +final class ShouldNotHappenException extends Exception { /** * @param string $message * @param int $code */ - public function __construct($message = '', $code = 0, ?\Throwable $throwable = null) + public function __construct($message = '', $code = 0, ?Throwable $throwable = null) { if ($message === '') { $message = $this->createDefaultMessageWithLocation(); diff --git a/src/Exception/VersionException.php b/src/Exception/VersionException.php index 2c619c7e22b..b0f3969d063 100644 --- a/src/Exception/VersionException.php +++ b/src/Exception/VersionException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace Rector\Core\Exception; use Exception; -final class VersionException extends \Exception +final class VersionException extends Exception { } diff --git a/src/Exclusion/ExclusionManager.php b/src/Exclusion/ExclusionManager.php index 8c18d2447df..69ecff28966 100644 --- a/src/Exclusion/ExclusionManager.php +++ b/src/Exclusion/ExclusionManager.php @@ -30,32 +30,32 @@ final class ExclusionManager * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory */ private $phpDocInfoFactory; - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory) { $this->phpDocInfoFactory = $phpDocInfoFactory; } - public function isNodeSkippedByRector(\PhpParser\Node $node, \Rector\Core\Contract\Rector\PhpRectorInterface $phpRector) : bool + public function isNodeSkippedByRector(Node $node, PhpRectorInterface $phpRector) : bool { - if ($node instanceof \PhpParser\Node\Stmt\PropertyProperty || $node instanceof \PhpParser\Node\Const_) { - $node = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$node instanceof \PhpParser\Node) { + if ($node instanceof PropertyProperty || $node instanceof Const_) { + $node = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$node instanceof Node) { return \false; } } if ($this->hasNoRectorPhpDocTagMatch($node, $phpRector)) { return \true; } - if ($node instanceof \PhpParser\Node\Stmt) { + if ($node instanceof Stmt) { return \false; } // recurse up until a Stmt node is found since it might contain a noRector - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); if ($parentNode === null) { return \false; } return $this->isNodeSkippedByRector($parentNode, $phpRector); } - private function hasNoRectorPhpDocTagMatch(\PhpParser\Node $node, \Rector\Core\Contract\Rector\PhpRectorInterface $phpRector) : bool + private function hasNoRectorPhpDocTagMatch(Node $node, PhpRectorInterface $phpRector) : bool { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); /** @var PhpDocTagNode[] $noRectorTags */ @@ -73,8 +73,8 @@ final class ExclusionManager private function matchesNoRectorTag(array $noRectorPhpDocTagNodes, string $rectorClass) : bool { foreach ($noRectorPhpDocTagNodes as $noRectorPhpDocTagNode) { - if (!$noRectorPhpDocTagNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$noRectorPhpDocTagNode->value instanceof GenericTagValueNode) { + throw new ShouldNotHappenException(); } $description = $noRectorPhpDocTagNode->value->value; if ($description === '') { @@ -84,7 +84,7 @@ final class ExclusionManager if ($description === $rectorClass) { return \true; } - if (!\is_a($description, \Rector\Core\Contract\Rector\RectorInterface::class, \true)) { + if (!\is_a($description, RectorInterface::class, \true)) { return \true; } } @@ -93,14 +93,14 @@ final class ExclusionManager /** * @param class-string $rectorClass */ - private function matchesNoRectorComment(\PhpParser\Node $node, string $rectorClass) : bool + private function matchesNoRectorComment(Node $node, string $rectorClass) : bool { foreach ($node->getComments() as $comment) { - if (\Rector\Core\Util\StringUtils::isMatch($comment->getText(), self::NO_RECTOR_START_REGEX)) { + if (StringUtils::isMatch($comment->getText(), self::NO_RECTOR_START_REGEX)) { return \true; } $noRectorWithRule = '#@noRector \\\\?' . \preg_quote($rectorClass, '#') . '$#'; - if (\Rector\Core\Util\StringUtils::isMatch($comment->getText(), $noRectorWithRule)) { + if (StringUtils::isMatch($comment->getText(), $noRectorWithRule)) { return \true; } } diff --git a/src/FileSystem/FilesFinder.php b/src/FileSystem/FilesFinder.php index 748ff6106b6..a955c773e13 100644 --- a/src/FileSystem/FilesFinder.php +++ b/src/FileSystem/FilesFinder.php @@ -10,7 +10,7 @@ use RectorPrefix20220607\Symfony\Component\Finder\SplFileInfo; use RectorPrefix20220607\Symplify\Skipper\SkipCriteriaResolver\SkippedPathsResolver; use RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemFilter; use RectorPrefix20220607\Symplify\SmartFileSystem\Finder\FinderSanitizer; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; /** * @see \Rector\Core\Tests\FileSystem\FilesFinder\FilesFinderTest */ @@ -51,7 +51,7 @@ final class FilesFinder * @var \Rector\Caching\UnchangedFilesFilter */ private $unchangedFilesFilter; - public function __construct(\Rector\Core\FileSystem\FilesystemTweaker $filesystemTweaker, \RectorPrefix20220607\Symplify\SmartFileSystem\Finder\FinderSanitizer $finderSanitizer, \RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemFilter $fileSystemFilter, \RectorPrefix20220607\Symplify\Skipper\SkipCriteriaResolver\SkippedPathsResolver $skippedPathsResolver, \Rector\Caching\UnchangedFilesFilter $unchangedFilesFilter) + public function __construct(\Rector\Core\FileSystem\FilesystemTweaker $filesystemTweaker, FinderSanitizer $finderSanitizer, FileSystemFilter $fileSystemFilter, SkippedPathsResolver $skippedPathsResolver, UnchangedFilesFilter $unchangedFilesFilter) { $this->filesystemTweaker = $filesystemTweaker; $this->finderSanitizer = $finderSanitizer; @@ -82,7 +82,7 @@ final class FilesFinder if ($directories === []) { return []; } - $finder = \RectorPrefix20220607\Symfony\Component\Finder\Finder::create()->files()->size('> 0')->in($directories)->sortByName(); + $finder = Finder::create()->files()->size('> 0')->in($directories)->sortByName(); if ($suffixes !== []) { $suffixesPattern = $this->normalizeSuffixesToPattern($suffixes); $finder->name($suffixesPattern); @@ -99,13 +99,13 @@ final class FilesFinder $suffixesPattern = \implode('|', $suffixes); return '#\\.(' . $suffixesPattern . ')$#'; } - private function addFilterWithExcludedPaths(\RectorPrefix20220607\Symfony\Component\Finder\Finder $finder) : void + private function addFilterWithExcludedPaths(Finder $finder) : void { $excludePaths = $this->skippedPathsResolver->resolve(); if ($excludePaths === []) { return; } - $finder->filter(function (\RectorPrefix20220607\Symfony\Component\Finder\SplFileInfo $splFileInfo) use($excludePaths) : bool { + $finder->filter(function (SplFileInfo $splFileInfo) use($excludePaths) : bool { /** @var string|false $realPath */ $realPath = $splFileInfo->getRealPath(); if ($realPath === \false) { @@ -118,7 +118,7 @@ final class FilesFinder foreach ($excludePaths as $excludePath) { // make the path work accross different OSes $excludePath = \str_replace('\\', '/', $excludePath); - if (\Rector\Core\Util\StringUtils::isMatch($realPath, '#' . \preg_quote($excludePath, '#') . '#')) { + if (StringUtils::isMatch($realPath, '#' . \preg_quote($excludePath, '#') . '#')) { return \false; } $excludePath = $this->normalizeForFnmatch($excludePath); @@ -136,11 +136,11 @@ final class FilesFinder private function normalizeForFnmatch(string $path) : string { // ends with * - if (\Rector\Core\Util\StringUtils::isMatch($path, self::ENDS_WITH_ASTERISK_REGEX)) { + if (StringUtils::isMatch($path, self::ENDS_WITH_ASTERISK_REGEX)) { return '*' . $path; } // starts with * - if (\Rector\Core\Util\StringUtils::isMatch($path, self::STARTS_WITH_ASTERISK_REGEX)) { + if (StringUtils::isMatch($path, self::STARTS_WITH_ASTERISK_REGEX)) { return $path . '*'; } return $path; diff --git a/src/FileSystem/PhpFilesFinder.php b/src/FileSystem/PhpFilesFinder.php index babc4ec293b..901d0b23093 100644 --- a/src/FileSystem/PhpFilesFinder.php +++ b/src/FileSystem/PhpFilesFinder.php @@ -6,7 +6,7 @@ namespace Rector\Core\FileSystem; use Rector\Caching\UnchangedFilesFilter; use Rector\Core\Util\StringUtils; use Rector\Core\ValueObject\StaticNonPhpFileSuffixes; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class PhpFilesFinder { /** @@ -19,7 +19,7 @@ final class PhpFilesFinder * @var \Rector\Caching\UnchangedFilesFilter */ private $unchangedFilesFilter; - public function __construct(\Rector\Core\FileSystem\FilesFinder $filesFinder, \Rector\Caching\UnchangedFilesFilter $unchangedFilesFilter) + public function __construct(\Rector\Core\FileSystem\FilesFinder $filesFinder, UnchangedFilesFilter $unchangedFilesFilter) { $this->filesFinder = $filesFinder; $this->unchangedFilesFilter = $unchangedFilesFilter; @@ -31,7 +31,7 @@ final class PhpFilesFinder public function findInPaths(array $paths) : array { $phpFileInfos = $this->filesFinder->findInDirectoriesAndFiles($paths); - $suffixRegexPattern = \Rector\Core\ValueObject\StaticNonPhpFileSuffixes::getSuffixRegexPattern(); + $suffixRegexPattern = StaticNonPhpFileSuffixes::getSuffixRegexPattern(); // filter out non-PHP files foreach ($phpFileInfos as $key => $phpFileInfo) { $pathName = $phpFileInfo->getPathname(); @@ -51,7 +51,7 @@ final class PhpFilesFinder /** * only check with regex when needed */ - if (\Rector\Core\Util\StringUtils::isMatch($pathName, $suffixRegexPattern)) { + if (StringUtils::isMatch($pathName, $suffixRegexPattern)) { unset($phpFileInfos[$key]); } } diff --git a/src/Kernel/RectorKernel.php b/src/Kernel/RectorKernel.php index a911840535d..33b682253b1 100644 --- a/src/Kernel/RectorKernel.php +++ b/src/Kernel/RectorKernel.php @@ -20,7 +20,7 @@ use RectorPrefix20220607\Symplify\PackageBuilder\ValueObject\ConsoleColorDiffCon use RectorPrefix20220607\Symplify\Skipper\ValueObject\SkipperConfig; use RectorPrefix20220607\Symplify\SymplifyKernel\ContainerBuilderFactory; use RectorPrefix20220607\Symplify\SymplifyKernel\Contract\LightKernelInterface; -final class RectorKernel implements \RectorPrefix20220607\Symplify\SymplifyKernel\Contract\LightKernelInterface +final class RectorKernel implements LightKernelInterface { /** * @readonly @@ -33,7 +33,7 @@ final class RectorKernel implements \RectorPrefix20220607\Symplify\SymplifyKerne private $container = null; public function __construct() { - $this->configureCallValuesCollector = new \Rector\Core\DependencyInjection\Collector\ConfigureCallValuesCollector(); + $this->configureCallValuesCollector = new ConfigureCallValuesCollector(); } /** * @param string[] $configFiles @@ -43,8 +43,8 @@ final class RectorKernel implements \RectorPrefix20220607\Symplify\SymplifyKerne $defaultConfigFiles = $this->createDefaultConfigFiles(); $configFiles = \array_merge($defaultConfigFiles, $configFiles); $compilerPasses = $this->createCompilerPasses(); - $configureCallMergingLoaderFactory = new \Rector\Core\Config\Loader\ConfigureCallMergingLoaderFactory($this->configureCallValuesCollector); - $containerBuilderFactory = new \RectorPrefix20220607\Symplify\SymplifyKernel\ContainerBuilderFactory($configureCallMergingLoaderFactory); + $configureCallMergingLoaderFactory = new ConfigureCallMergingLoaderFactory($this->configureCallValuesCollector); + $containerBuilderFactory = new ContainerBuilderFactory($configureCallMergingLoaderFactory); $containerBuilder = $containerBuilderFactory->create($configFiles, $compilerPasses, []); // @see https://symfony.com/blog/new-in-symfony-4-4-dependency-injection-improvements-part-1 $containerBuilder->setParameter('container.dumper.inline_factories', \true); @@ -57,7 +57,7 @@ final class RectorKernel implements \RectorPrefix20220607\Symplify\SymplifyKerne public function getContainer() : \RectorPrefix20220607\Psr\Container\ContainerInterface { if ($this->container === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } return $this->container; } @@ -68,13 +68,13 @@ final class RectorKernel implements \RectorPrefix20220607\Symplify\SymplifyKerne { return [ // must run before AutowireArrayParameterCompilerPass, as the autowired array cannot contain removed services - new \Rector\Core\DependencyInjection\CompilerPass\RemoveSkippedRectorsCompilerPass(), + new RemoveSkippedRectorsCompilerPass(), // autowire Rectors by default (mainly for tests) - new \RectorPrefix20220607\Symplify\PackageBuilder\DependencyInjection\CompilerPass\AutowireInterfacesCompilerPass([\Rector\Core\Contract\Rector\RectorInterface::class]), - new \Rector\Core\DependencyInjection\CompilerPass\MakeRectorsPublicCompilerPass(), + new AutowireInterfacesCompilerPass([RectorInterface::class]), + new MakeRectorsPublicCompilerPass(), // add all merged arguments of Rector services - new \Rector\Core\DependencyInjection\CompilerPass\MergeImportedRectorConfigureCallValuesCompilerPass($this->configureCallValuesCollector), - new \RectorPrefix20220607\Symplify\AutowireArrayParameter\DependencyInjection\CompilerPass\AutowireArrayParameterCompilerPass(), + new MergeImportedRectorConfigureCallValuesCompilerPass($this->configureCallValuesCollector), + new AutowireArrayParameterCompilerPass(), ]; } /** @@ -82,6 +82,6 @@ final class RectorKernel implements \RectorPrefix20220607\Symplify\SymplifyKerne */ private function createDefaultConfigFiles() : array { - return [__DIR__ . '/../../config/config.php', \RectorPrefix20220607\Symplify\Astral\ValueObject\AstralConfig::FILE_PATH, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonManipulatorConfig::FILE_PATH, \RectorPrefix20220607\Symplify\Skipper\ValueObject\SkipperConfig::FILE_PATH, \RectorPrefix20220607\Symplify\PackageBuilder\ValueObject\ConsoleColorDiffConfig::FILE_PATH]; + return [__DIR__ . '/../../config/config.php', AstralConfig::FILE_PATH, ComposerJsonManipulatorConfig::FILE_PATH, SkipperConfig::FILE_PATH, ConsoleColorDiffConfig::FILE_PATH]; } } diff --git a/src/Logging/CurrentRectorProvider.php b/src/Logging/CurrentRectorProvider.php index c1b632ba3bc..3dfeab0aa2f 100644 --- a/src/Logging/CurrentRectorProvider.php +++ b/src/Logging/CurrentRectorProvider.php @@ -10,11 +10,11 @@ final class CurrentRectorProvider * @var \Rector\Core\Contract\Rector\RectorInterface|null */ private $currentRector; - public function changeCurrentRector(\Rector\Core\Contract\Rector\RectorInterface $rector) : void + public function changeCurrentRector(RectorInterface $rector) : void { $this->currentRector = $rector; } - public function getCurrentRector() : ?\Rector\Core\Contract\Rector\RectorInterface + public function getCurrentRector() : ?RectorInterface { return $this->currentRector; } diff --git a/src/NodeAnalyzer/ArgsAnalyzer.php b/src/NodeAnalyzer/ArgsAnalyzer.php index 0b1fc3ff5e0..962e98740e3 100644 --- a/src/NodeAnalyzer/ArgsAnalyzer.php +++ b/src/NodeAnalyzer/ArgsAnalyzer.php @@ -16,7 +16,7 @@ final class ArgsAnalyzer if (!isset($args[$position])) { return \false; } - return $args[$position] instanceof \PhpParser\Node\Arg; + return $args[$position] instanceof Arg; } /** * @param Arg[]|VariadicPlaceholder[] $args @@ -28,7 +28,7 @@ final class ArgsAnalyzer if (!isset($args[$position])) { return \false; } - if ($args[$position] instanceof \PhpParser\Node\Arg) { + if ($args[$position] instanceof Arg) { continue; } return \false; @@ -41,10 +41,10 @@ final class ArgsAnalyzer public function hasNamedArg(array $args) : bool { foreach ($args as $arg) { - if (!$arg instanceof \PhpParser\Node\Arg) { + if (!$arg instanceof Arg) { continue; } - if ($arg->name instanceof \PhpParser\Node\Identifier) { + if ($arg->name instanceof Identifier) { return \true; } } diff --git a/src/NodeAnalyzer/CallAnalyzer.php b/src/NodeAnalyzer/CallAnalyzer.php index 74e9e0fa974..9ad6f5eeacc 100644 --- a/src/NodeAnalyzer/CallAnalyzer.php +++ b/src/NodeAnalyzer/CallAnalyzer.php @@ -22,7 +22,7 @@ final class CallAnalyzer /** * @var array> */ - private const OBJECT_CALL_TYPES = [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\NullsafeMethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + private const OBJECT_CALL_TYPES = [MethodCall::class, NullsafeMethodCall::class, StaticCall::class]; /** * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ @@ -32,23 +32,23 @@ final class CallAnalyzer * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(NodeComparator $nodeComparator) { $this->nodeComparator = $nodeComparator; } /** * @required */ - public function autowire(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) : void + public function autowire(BetterNodeFinder $betterNodeFinder) : void { $this->betterNodeFinder = $betterNodeFinder; } - public function isObjectCall(\PhpParser\Node\Expr $expr) : bool + public function isObjectCall(Expr $expr) : bool { - if ($expr instanceof \PhpParser\Node\Expr\BooleanNot) { + if ($expr instanceof BooleanNot) { $expr = $expr->expr; } - if ($expr instanceof \PhpParser\Node\Expr\BinaryOp) { + if ($expr instanceof BinaryOp) { $isObjectCallLeft = $this->isObjectCall($expr->left); $isObjectCallRight = $this->isObjectCall($expr->right); return $isObjectCallLeft || $isObjectCallRight; @@ -72,19 +72,19 @@ final class CallAnalyzer } return \false; } - public function isNewInstance(\PhpParser\Node\Expr $expr) : bool + public function isNewInstance(Expr $expr) : bool { - if ($expr instanceof \PhpParser\Node\Expr\Clone_ || $expr instanceof \PhpParser\Node\Expr\New_) { + if ($expr instanceof Clone_ || $expr instanceof New_) { return \true; } - return (bool) $this->betterNodeFinder->findFirstPrevious($expr, function (\PhpParser\Node $node) use($expr) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + return (bool) $this->betterNodeFinder->findFirstPrevious($expr, function (Node $node) use($expr) : bool { + if (!$node instanceof Assign) { return \false; } if (!$this->nodeComparator->areNodesEqual($node->var, $expr)) { return \false; } - return $node->expr instanceof \PhpParser\Node\Expr\Clone_ || $node->expr instanceof \PhpParser\Node\Expr\New_; + return $node->expr instanceof Clone_ || $node->expr instanceof New_; }); } } diff --git a/src/NodeAnalyzer/ClassAnalyzer.php b/src/NodeAnalyzer/ClassAnalyzer.php index 48eee0984e4..66b58c38b30 100644 --- a/src/NodeAnalyzer/ClassAnalyzer.php +++ b/src/NodeAnalyzer/ClassAnalyzer.php @@ -21,17 +21,17 @@ final class ClassAnalyzer * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } - public function isAnonymousClass(\PhpParser\Node $node) : bool + public function isAnonymousClass(Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Stmt\Class_) { + if (!$node instanceof Class_) { return \false; } - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\Expr\New_) { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof New_) { return \false; } if ($node->isAnonymous()) { @@ -42,6 +42,6 @@ final class ClassAnalyzer return \true; } // match PHPStan pattern for anonymous classes - return \Rector\Core\Util\StringUtils::isMatch($className, self::ANONYMOUS_CLASS_REGEX); + return StringUtils::isMatch($className, self::ANONYMOUS_CLASS_REGEX); } } diff --git a/src/NodeAnalyzer/CoalesceAnalyzer.php b/src/NodeAnalyzer/CoalesceAnalyzer.php index d858b134415..d6765ce0c7b 100644 --- a/src/NodeAnalyzer/CoalesceAnalyzer.php +++ b/src/NodeAnalyzer/CoalesceAnalyzer.php @@ -14,8 +14,8 @@ final class CoalesceAnalyzer /** * @var array> */ - private const ISSETABLE_EXPR = [\PhpParser\Node\Expr\Variable::class, \PhpParser\Node\Expr\ArrayDimFetch::class, \PhpParser\Node\Expr\PropertyFetch::class, \PhpParser\Node\Expr\StaticPropertyFetch::class]; - public function hasIssetableLeft(\PhpParser\Node\Expr\BinaryOp\Coalesce $coalesce) : bool + private const ISSETABLE_EXPR = [Variable::class, ArrayDimFetch::class, PropertyFetch::class, StaticPropertyFetch::class]; + public function hasIssetableLeft(Coalesce $coalesce) : bool { $leftClass = \get_class($coalesce->left); return \in_array($leftClass, self::ISSETABLE_EXPR, \true); diff --git a/src/NodeAnalyzer/CompactFuncCallAnalyzer.php b/src/NodeAnalyzer/CompactFuncCallAnalyzer.php index b4dd2f89419..119c4e08637 100644 --- a/src/NodeAnalyzer/CompactFuncCallAnalyzer.php +++ b/src/NodeAnalyzer/CompactFuncCallAnalyzer.php @@ -18,11 +18,11 @@ final class CompactFuncCallAnalyzer * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } - public function isInCompact(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr\Variable $variable) : bool + public function isInCompact(FuncCall $funcCall, Variable $variable) : bool { if (!$this->nodeNameResolver->isName($funcCall, 'compact')) { return \false; @@ -42,13 +42,13 @@ final class CompactFuncCallAnalyzer continue; } /** @var Arg|ArrayItem $node */ - if ($node->value instanceof \PhpParser\Node\Expr\Array_) { + if ($node->value instanceof Array_) { if ($this->isInArgOrArrayItemNodes($node->value->items, $variableName)) { return \true; } continue; } - if (!$node->value instanceof \PhpParser\Node\Scalar\String_) { + if (!$node->value instanceof String_) { continue; } if ($node->value->value === $variableName) { @@ -65,6 +65,6 @@ final class CompactFuncCallAnalyzer if ($node === null) { return \true; } - return $node instanceof \PhpParser\Node\VariadicPlaceholder; + return $node instanceof VariadicPlaceholder; } } diff --git a/src/NodeAnalyzer/ConstFetchAnalyzer.php b/src/NodeAnalyzer/ConstFetchAnalyzer.php index 8c87cde7038..ada12ddb9c7 100644 --- a/src/NodeAnalyzer/ConstFetchAnalyzer.php +++ b/src/NodeAnalyzer/ConstFetchAnalyzer.php @@ -11,28 +11,28 @@ use PhpParser\Node\Expr\ConstFetch; */ final class ConstFetchAnalyzer { - public function isTrueOrFalse(\PhpParser\Node $node) : bool + public function isTrueOrFalse(Node $node) : bool { if ($this->isTrue($node)) { return \true; } return $this->isFalse($node); } - public function isFalse(\PhpParser\Node $node) : bool + public function isFalse(Node $node) : bool { return $this->isConstantWithLowercasedName($node, 'false'); } - public function isTrue(\PhpParser\Node $node) : bool + public function isTrue(Node $node) : bool { return $this->isConstantWithLowercasedName($node, 'true'); } - public function isNull(\PhpParser\Node $node) : bool + public function isNull(Node $node) : bool { return $this->isConstantWithLowercasedName($node, 'null'); } - private function isConstantWithLowercasedName(\PhpParser\Node $node, string $name) : bool + private function isConstantWithLowercasedName(Node $node, string $name) : bool { - if (!$node instanceof \PhpParser\Node\Expr\ConstFetch) { + if (!$node instanceof ConstFetch) { return \false; } return $node->name->toLowerString() === $name; diff --git a/src/NodeAnalyzer/EnumAnalyzer.php b/src/NodeAnalyzer/EnumAnalyzer.php index 8fa1ea153f1..4dc66cfa80c 100644 --- a/src/NodeAnalyzer/EnumAnalyzer.php +++ b/src/NodeAnalyzer/EnumAnalyzer.php @@ -20,7 +20,7 @@ final class EnumAnalyzer * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder) { $this->nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; @@ -28,13 +28,13 @@ final class EnumAnalyzer /** * @see https://github.com/myclabs/php-enum#declaration */ - public function isEnumClassConst(\PhpParser\Node\Stmt\ClassConst $classConst) : bool + public function isEnumClassConst(ClassConst $classConst) : bool { - $class = $this->betterNodeFinder->findParentType($classConst, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($classConst, Class_::class); + if (!$class instanceof Class_) { return \false; } - if (!$class->extends instanceof \PhpParser\Node\Name) { + if (!$class->extends instanceof Name) { return \false; } return $this->nodeNameResolver->isName($class->extends, '*Enum'); diff --git a/src/NodeAnalyzer/ExprAnalyzer.php b/src/NodeAnalyzer/ExprAnalyzer.php index 5b7787dd55b..93fd58c7f9d 100644 --- a/src/NodeAnalyzer/ExprAnalyzer.php +++ b/src/NodeAnalyzer/ExprAnalyzer.php @@ -46,7 +46,7 @@ final class ExprAnalyzer * @var \Rector\Core\NodeManipulator\ArrayManipulator */ private $arrayManipulator; - public function __construct(\Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\NodeManipulator\ArrayManipulator $arrayManipulator) + public function __construct(NodeComparator $nodeComparator, BetterNodeFinder $betterNodeFinder, PhpDocInfoFactory $phpDocInfoFactory, NodeNameResolver $nodeNameResolver, ArrayManipulator $arrayManipulator) { $this->nodeComparator = $nodeComparator; $this->betterNodeFinder = $betterNodeFinder; @@ -54,13 +54,13 @@ final class ExprAnalyzer $this->nodeNameResolver = $nodeNameResolver; $this->arrayManipulator = $arrayManipulator; } - public function isNonTypedFromParam(\PhpParser\Node\Expr $expr) : bool + public function isNonTypedFromParam(Expr $expr) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\Variable) { + if (!$expr instanceof Variable) { return \false; } - $functionLike = $this->betterNodeFinder->findParentType($expr, \PhpParser\Node\FunctionLike::class); - if (!$functionLike instanceof \PhpParser\Node\FunctionLike) { + $functionLike = $this->betterNodeFinder->findParentType($expr, FunctionLike::class); + if (!$functionLike instanceof FunctionLike) { return \false; } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike); @@ -74,28 +74,28 @@ final class ExprAnalyzer continue; } $paramTag = $phpDocInfo->getParamTagValueByName($paramName); - return $paramTag instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode && $param->type === null; + return $paramTag instanceof ParamTagValueNode && $param->type === null; } return \false; } - public function isDynamicExpr(\PhpParser\Node\Expr $expr) : bool + public function isDynamicExpr(Expr $expr) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\Array_) { - if ($expr instanceof \PhpParser\Node\Scalar) { + if (!$expr instanceof Array_) { + if ($expr instanceof Scalar) { // string interpolation is true, otherwise false - return $expr instanceof \PhpParser\Node\Scalar\Encapsed; + return $expr instanceof Encapsed; } return !$this->isAllowedConstFetchOrClassConstFetch($expr); } return $this->arrayManipulator->isDynamicArray($expr); } - private function isAllowedConstFetchOrClassConstFetch(\PhpParser\Node\Expr $expr) : bool + private function isAllowedConstFetchOrClassConstFetch(Expr $expr) : bool { - if ($expr instanceof \PhpParser\Node\Expr\ConstFetch) { + if ($expr instanceof ConstFetch) { return \true; } - if ($expr instanceof \PhpParser\Node\Expr\ClassConstFetch) { - return $expr->class instanceof \PhpParser\Node\Name && $expr->name instanceof \PhpParser\Node\Identifier; + if ($expr instanceof ClassConstFetch) { + return $expr->class instanceof Name && $expr->name instanceof Identifier; } return \false; } diff --git a/src/NodeAnalyzer/InlineHTMLAnalyzer.php b/src/NodeAnalyzer/InlineHTMLAnalyzer.php index 3e88be4a22a..1484593f14a 100644 --- a/src/NodeAnalyzer/InlineHTMLAnalyzer.php +++ b/src/NodeAnalyzer/InlineHTMLAnalyzer.php @@ -14,15 +14,15 @@ final class InlineHTMLAnalyzer * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(BetterNodeFinder $betterNodeFinder) { $this->betterNodeFinder = $betterNodeFinder; } - public function hasInlineHTML(\PhpParser\Node $node) : bool + public function hasInlineHTML(Node $node) : bool { - if ($node instanceof \PhpParser\Node\FunctionLike) { - return (bool) $this->betterNodeFinder->findInstanceOf((array) $node->getStmts(), \PhpParser\Node\Stmt\InlineHTML::class); + if ($node instanceof FunctionLike) { + return (bool) $this->betterNodeFinder->findInstanceOf((array) $node->getStmts(), InlineHTML::class); } - return (bool) $this->betterNodeFinder->findInstanceOf($node, \PhpParser\Node\Stmt\InlineHTML::class); + return (bool) $this->betterNodeFinder->findInstanceOf($node, InlineHTML::class); } } diff --git a/src/NodeAnalyzer/ParamAnalyzer.php b/src/NodeAnalyzer/ParamAnalyzer.php index d8f3d5acd08..5d36269d7be 100644 --- a/src/NodeAnalyzer/ParamAnalyzer.php +++ b/src/NodeAnalyzer/ParamAnalyzer.php @@ -48,7 +48,7 @@ final class ParamAnalyzer * @var \Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser */ private $simpleCallableNodeTraverser; - public function __construct(\Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\NodeManipulator\FuncCallManipulator $funcCallManipulator, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser) + public function __construct(NodeComparator $nodeComparator, ValueResolver $valueResolver, NodeNameResolver $nodeNameResolver, FuncCallManipulator $funcCallManipulator, SimpleCallableNodeTraverser $simpleCallableNodeTraverser) { $this->nodeComparator = $nodeComparator; $this->valueResolver = $valueResolver; @@ -56,21 +56,21 @@ final class ParamAnalyzer $this->funcCallManipulator = $funcCallManipulator; $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; } - public function isParamUsedInClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Param $param) : bool + public function isParamUsedInClassMethod(ClassMethod $classMethod, Param $param) : bool { $isParamUsed = \false; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classMethod->stmts, function (\PhpParser\Node $node) use(&$isParamUsed, $param) : ?int { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classMethod->stmts, function (Node $node) use(&$isParamUsed, $param) : ?int { if ($this->isUsedAsArg($node, $param)) { $isParamUsed = \true; } // skip nested anonymous class - if ($node instanceof \PhpParser\Node\Stmt\Class_ || $node instanceof \PhpParser\Node\Stmt\Function_) { - return \PhpParser\NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; + if ($node instanceof Class_ || $node instanceof Function_) { + return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; } - if ($node instanceof \PhpParser\Node\Expr\Variable && $this->nodeComparator->areNodesEqual($node, $param->var)) { + if ($node instanceof Variable && $this->nodeComparator->areNodesEqual($node, $param->var)) { $isParamUsed = \true; } - if ($node instanceof \PhpParser\Node\Expr\Closure && $this->isVariableInClosureUses($node, $param->var)) { + if ($node instanceof Closure && $this->isVariableInClosureUses($node, $param->var)) { $isParamUsed = \true; } if ($this->isParamUsed($node, $param)) { @@ -92,7 +92,7 @@ final class ParamAnalyzer } return \false; } - public function isNullable(\PhpParser\Node\Param $param) : bool + public function isNullable(Param $param) : bool { if ($param->variadic) { return \false; @@ -100,13 +100,13 @@ final class ParamAnalyzer if ($param->type === null) { return \false; } - return $param->type instanceof \PhpParser\Node\NullableType; + return $param->type instanceof NullableType; } - public function hasDefaultNull(\PhpParser\Node\Param $param) : bool + public function hasDefaultNull(Param $param) : bool { - return $param->default instanceof \PhpParser\Node\Expr\ConstFetch && $this->valueResolver->isNull($param->default); + return $param->default instanceof ConstFetch && $this->valueResolver->isNull($param->default); } - private function isVariableInClosureUses(\PhpParser\Node\Expr\Closure $closure, \PhpParser\Node\Expr\Variable $variable) : bool + private function isVariableInClosureUses(Closure $closure, Variable $variable) : bool { foreach ($closure->uses as $use) { if ($this->nodeComparator->areNodesEqual($use->var, $variable)) { @@ -115,9 +115,9 @@ final class ParamAnalyzer } return \false; } - private function isUsedAsArg(\PhpParser\Node $node, \PhpParser\Node\Param $param) : bool + private function isUsedAsArg(Node $node, Param $param) : bool { - if ($node instanceof \PhpParser\Node\Expr\New_ || $node instanceof \PhpParser\Node\Expr\CallLike) { + if ($node instanceof New_ || $node instanceof CallLike) { foreach ($node->getArgs() as $arg) { if ($this->nodeComparator->areNodesEqual($param->var, $arg->value)) { return \true; @@ -126,9 +126,9 @@ final class ParamAnalyzer } return \false; } - private function isParamUsed(\PhpParser\Node $node, \PhpParser\Node\Param $param) : bool + private function isParamUsed(Node $node, Param $param) : bool { - if (!$node instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$node instanceof FuncCall) { return \false; } if (!$this->nodeNameResolver->isName($node, 'compact')) { diff --git a/src/NodeAnalyzer/PropertyAnalyzer.php b/src/NodeAnalyzer/PropertyAnalyzer.php index 7c0dfe9ed58..f47bc0890bf 100644 --- a/src/NodeAnalyzer/PropertyAnalyzer.php +++ b/src/NodeAnalyzer/PropertyAnalyzer.php @@ -17,20 +17,20 @@ final class PropertyAnalyzer * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(NodeTypeResolver $nodeTypeResolver) { $this->nodeTypeResolver = $nodeTypeResolver; } - public function hasForbiddenType(\PhpParser\Node\Stmt\Property $property) : bool + public function hasForbiddenType(Property $property) : bool { $propertyType = $this->nodeTypeResolver->getType($property); - if ($propertyType instanceof \PHPStan\Type\NullType) { + if ($propertyType instanceof NullType) { return \true; } if ($this->isCallableType($propertyType)) { return \true; } - if (!$propertyType instanceof \PHPStan\Type\UnionType) { + if (!$propertyType instanceof UnionType) { return \false; } $types = $propertyType->getTypes(); @@ -41,11 +41,11 @@ final class PropertyAnalyzer } return \false; } - private function isCallableType(\PHPStan\Type\Type $type) : bool + private function isCallableType(Type $type) : bool { - if ($type instanceof \PHPStan\Type\TypeWithClassName) { + if ($type instanceof TypeWithClassName) { return $type->getClassName() === 'Closure'; } - return $type instanceof \PHPStan\Type\CallableType; + return $type instanceof CallableType; } } diff --git a/src/NodeAnalyzer/PropertyFetchAnalyzer.php b/src/NodeAnalyzer/PropertyFetchAnalyzer.php index b7f87451ecb..6c5d0290305 100644 --- a/src/NodeAnalyzer/PropertyFetchAnalyzer.php +++ b/src/NodeAnalyzer/PropertyFetchAnalyzer.php @@ -43,29 +43,29 @@ final class PropertyFetchAnalyzer * @var \Rector\Core\PhpParser\AstResolver */ private $astResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\AstResolver $astResolver) + public function __construct(NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder, AstResolver $astResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; $this->astResolver = $astResolver; } - public function isLocalPropertyFetch(\PhpParser\Node $node) : bool + public function isLocalPropertyFetch(Node $node) : bool { - if ($node instanceof \PhpParser\Node\Expr\PropertyFetch) { - if (!$node->var instanceof \PhpParser\Node\Expr\Variable) { + if ($node instanceof PropertyFetch) { + if (!$node->var instanceof Variable) { return \false; } return $this->nodeNameResolver->isName($node->var, self::THIS); } - if ($node instanceof \PhpParser\Node\Expr\StaticPropertyFetch) { - if (!$node->class instanceof \PhpParser\Node\Name) { + if ($node instanceof StaticPropertyFetch) { + if (!$node->class instanceof Name) { return \false; } - return $this->nodeNameResolver->isNames($node->class, [\Rector\Core\Enum\ObjectReference::SELF, \Rector\Core\Enum\ObjectReference::STATIC]); + return $this->nodeNameResolver->isNames($node->class, [ObjectReference::SELF, ObjectReference::STATIC]); } return \false; } - public function isLocalPropertyFetchName(\PhpParser\Node $node, string $desiredPropertyName) : bool + public function isLocalPropertyFetchName(Node $node, string $desiredPropertyName) : bool { if (!$this->isLocalPropertyFetch($node)) { return \false; @@ -73,9 +73,9 @@ final class PropertyFetchAnalyzer /** @var PropertyFetch|StaticPropertyFetch $node */ return $this->nodeNameResolver->isName($node->name, $desiredPropertyName); } - public function containsLocalPropertyFetchName(\PhpParser\Node $node, string $propertyName) : bool + public function containsLocalPropertyFetchName(Node $node, string $propertyName) : bool { - return (bool) $this->betterNodeFinder->findFirst($node, function (\PhpParser\Node $node) use($propertyName) : bool { + return (bool) $this->betterNodeFinder->findFirst($node, function (Node $node) use($propertyName) : bool { return $this->isLocalPropertyFetchName($node, $propertyName); }); } @@ -84,14 +84,14 @@ final class PropertyFetchAnalyzer */ public function isPropertyToSelf($expr) : bool { - if ($expr instanceof \PhpParser\Node\Expr\PropertyFetch && !$this->nodeNameResolver->isName($expr->var, self::THIS)) { + if ($expr instanceof PropertyFetch && !$this->nodeNameResolver->isName($expr->var, self::THIS)) { return \false; } - if ($expr instanceof \PhpParser\Node\Expr\StaticPropertyFetch && !$this->nodeNameResolver->isName($expr->class, \Rector\Core\Enum\ObjectReference::SELF)) { + if ($expr instanceof StaticPropertyFetch && !$this->nodeNameResolver->isName($expr->class, ObjectReference::SELF)) { return \false; } - $class = $this->betterNodeFinder->findParentType($expr, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($expr, Class_::class); + if (!$class instanceof Class_) { return \false; } foreach ($class->getProperties() as $property) { @@ -102,23 +102,23 @@ final class PropertyFetchAnalyzer } return \false; } - public function isPropertyFetch(\PhpParser\Node $node) : bool + public function isPropertyFetch(Node $node) : bool { - if ($node instanceof \PhpParser\Node\Expr\PropertyFetch) { + if ($node instanceof PropertyFetch) { return \true; } - return $node instanceof \PhpParser\Node\Expr\StaticPropertyFetch; + return $node instanceof StaticPropertyFetch; } /** * Matches: * "$this->someValue = $;" */ - public function isVariableAssignToThisPropertyFetch(\PhpParser\Node $node, string $variableName) : bool + public function isVariableAssignToThisPropertyFetch(Node $node, string $variableName) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + if (!$node instanceof Assign) { return \false; } - if (!$node->expr instanceof \PhpParser\Node\Expr\Variable) { + if (!$node->expr instanceof Variable) { return \false; } if (!$this->nodeNameResolver->isName($node->expr, $variableName)) { @@ -126,27 +126,27 @@ final class PropertyFetchAnalyzer } return $this->isLocalPropertyFetch($node->var); } - public function isFilledViaMethodCallInConstructStmts(\PhpParser\Node\Stmt\ClassLike $classLike, string $propertyName) : bool + public function isFilledViaMethodCallInConstructStmts(ClassLike $classLike, string $propertyName) : bool { - $classMethod = $classLike->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $classLike->getMethod(MethodName::CONSTRUCT); + if (!$classMethod instanceof ClassMethod) { return \false; } $className = (string) $this->nodeNameResolver->getName($classLike); $stmts = (array) $classMethod->stmts; foreach ($stmts as $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { continue; } - if (!$stmt->expr instanceof \PhpParser\Node\Expr\MethodCall && !$stmt->expr instanceof \PhpParser\Node\Expr\StaticCall) { + if (!$stmt->expr instanceof MethodCall && !$stmt->expr instanceof StaticCall) { continue; } $callerClassMethod = $this->astResolver->resolveClassMethodFromCall($stmt->expr); - if (!$callerClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$callerClassMethod instanceof ClassMethod) { continue; } - $callerClass = $this->betterNodeFinder->findParentType($callerClassMethod, \PhpParser\Node\Stmt\Class_::class); - if (!$callerClass instanceof \PhpParser\Node\Stmt\Class_) { + $callerClass = $this->betterNodeFinder->findParentType($callerClassMethod, Class_::class); + if (!$callerClass instanceof Class_) { continue; } $callerClassName = (string) $this->nodeNameResolver->getName($callerClass); @@ -160,7 +160,7 @@ final class PropertyFetchAnalyzer /** * @param string[] $propertyNames */ - public function isLocalPropertyOfNames(\PhpParser\Node $node, array $propertyNames) : bool + public function isLocalPropertyOfNames(Node $node, array $propertyNames) : bool { if (!$this->isLocalPropertyFetch($node)) { return \false; @@ -168,20 +168,20 @@ final class PropertyFetchAnalyzer /** @var PropertyFetch $node */ return $this->nodeNameResolver->isNames($node->name, $propertyNames); } - private function isPropertyAssignFoundInClassMethod(\PhpParser\Node\Stmt\ClassLike $classLike, string $className, string $callerClassName, \PhpParser\Node\Stmt\ClassMethod $classMethod, string $propertyName) : bool + private function isPropertyAssignFoundInClassMethod(ClassLike $classLike, string $className, string $callerClassName, ClassMethod $classMethod, string $propertyName) : bool { - if ($className !== $callerClassName && !$classLike instanceof \PhpParser\Node\Stmt\Trait_) { - $objectType = new \PHPStan\Type\ObjectType($className); - $callerObjectType = new \PHPStan\Type\ObjectType($callerClassName); + if ($className !== $callerClassName && !$classLike instanceof Trait_) { + $objectType = new ObjectType($className); + $callerObjectType = new ObjectType($callerClassName); if (!$callerObjectType->isSuperTypeOf($objectType)->yes()) { return \false; } } foreach ((array) $classMethod->stmts as $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { continue; } - if (!$stmt->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$stmt->expr instanceof Assign) { continue; } if ($this->isLocalPropertyFetchName($stmt->expr->var, $propertyName)) { diff --git a/src/NodeAnalyzer/PropertyPresenceChecker.php b/src/NodeAnalyzer/PropertyPresenceChecker.php index d9eb9199f64..96446e1ac15 100644 --- a/src/NodeAnalyzer/PropertyPresenceChecker.php +++ b/src/NodeAnalyzer/PropertyPresenceChecker.php @@ -39,7 +39,7 @@ final class PropertyPresenceChecker * @var \Rector\Core\PhpParser\AstResolver */ private $astResolver; - public function __construct(\Rector\Php80\NodeAnalyzer\PromotedPropertyResolver $promotedPropertyResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\PhpParser\AstResolver $astResolver) + public function __construct(PromotedPropertyResolver $promotedPropertyResolver, NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider, AstResolver $astResolver) { $this->promotedPropertyResolver = $promotedPropertyResolver; $this->nodeNameResolver = $nodeNameResolver; @@ -49,7 +49,7 @@ final class PropertyPresenceChecker /** * Includes parent classes and traits */ - public function hasClassContextProperty(\PhpParser\Node\Stmt\Class_ $class, \Rector\PostRector\ValueObject\PropertyMetadata $propertyMetadata) : bool + public function hasClassContextProperty(Class_ $class, PropertyMetadata $propertyMetadata) : bool { $propertyOrParam = $this->getClassContextProperty($class, $propertyMetadata); return $propertyOrParam !== null; @@ -57,7 +57,7 @@ final class PropertyPresenceChecker /** * @return \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param|null */ - public function getClassContextProperty(\PhpParser\Node\Stmt\Class_ $class, \Rector\PostRector\ValueObject\PropertyMetadata $propertyMetadata) + public function getClassContextProperty(Class_ $class, PropertyMetadata $propertyMetadata) { $className = $this->nodeNameResolver->getName($class); if ($className === null) { @@ -67,11 +67,11 @@ final class PropertyPresenceChecker return null; } $property = $class->getProperty($propertyMetadata->getName()); - if ($property instanceof \PhpParser\Node\Stmt\Property) { + if ($property instanceof Property) { return $property; } $property = $this->matchPropertyByParentNonPrivateProperties($className, $propertyMetadata); - if ($property instanceof \PhpParser\Node\Stmt\Property || $property instanceof \PhpParser\Node\Param) { + if ($property instanceof Property || $property instanceof Param) { return $property; } $promotedPropertyParams = $this->promotedPropertyResolver->resolveFromClass($class); @@ -103,15 +103,15 @@ final class PropertyPresenceChecker /** * @return \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param|null */ - private function matchPropertyByType(\Rector\PostRector\ValueObject\PropertyMetadata $propertyMetadata, \PHPStan\Reflection\Php\PhpPropertyReflection $phpPropertyReflection) + private function matchPropertyByType(PropertyMetadata $propertyMetadata, PhpPropertyReflection $phpPropertyReflection) { if ($propertyMetadata->getType() === null) { return null; } - if (!$propertyMetadata->getType() instanceof \PHPStan\Type\TypeWithClassName) { + if (!$propertyMetadata->getType() instanceof TypeWithClassName) { return null; } - if (!$phpPropertyReflection->getWritableType() instanceof \PHPStan\Type\TypeWithClassName) { + if (!$phpPropertyReflection->getWritableType() instanceof TypeWithClassName) { return null; } $propertyObjectType = $propertyMetadata->getType(); @@ -123,13 +123,13 @@ final class PropertyPresenceChecker /** * @return \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param|null */ - private function matchPropertyByParentNonPrivateProperties(string $className, \Rector\PostRector\ValueObject\PropertyMetadata $propertyMetadata) + private function matchPropertyByParentNonPrivateProperties(string $className, PropertyMetadata $propertyMetadata) { $availablePropertyReflections = $this->getParentClassNonPrivatePropertyReflections($className); foreach ($availablePropertyReflections as $availablePropertyReflection) { // 1. match type by priority $property = $this->matchPropertyByType($propertyMetadata, $availablePropertyReflection); - if ($property instanceof \PhpParser\Node\Stmt\Property || $property instanceof \PhpParser\Node\Param) { + if ($property instanceof Property || $property instanceof Param) { return $property; } $nativePropertyReflection = $availablePropertyReflection->getNativeReflection(); @@ -143,7 +143,7 @@ final class PropertyPresenceChecker /** * @return string[] */ - private function resolveNonPrivatePropertyNames(\PHPStan\Reflection\ClassReflection $classReflection) : array + private function resolveNonPrivatePropertyNames(ClassReflection $classReflection) : array { $propertyNames = []; $nativeReflection = $classReflection->getNativeReflection(); diff --git a/src/NodeAnalyzer/ScopeAnalyzer.php b/src/NodeAnalyzer/ScopeAnalyzer.php index 87061858f51..9680579186a 100644 --- a/src/NodeAnalyzer/ScopeAnalyzer.php +++ b/src/NodeAnalyzer/ScopeAnalyzer.php @@ -16,8 +16,8 @@ final class ScopeAnalyzer /** * @var array> */ - private const NO_SCOPE_NODES = [\PhpParser\Node\Name::class, \PhpParser\Node\Stmt\Namespace_::class, \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace::class, \PhpParser\Node\Identifier::class, \PhpParser\Node\Stmt\Enum_::class, \PhpParser\Node\Param::class, \PhpParser\Node\Arg::class]; - public function hasScope(\PhpParser\Node $node) : bool + private const NO_SCOPE_NODES = [Name::class, Namespace_::class, FileWithoutNamespace::class, Identifier::class, Enum_::class, Param::class, Arg::class]; + public function hasScope(Node $node) : bool { foreach (self::NO_SCOPE_NODES as $noScopeNode) { if ($node instanceof $noScopeNode) { diff --git a/src/NodeAnalyzer/UnreachableStmtAnalyzer.php b/src/NodeAnalyzer/UnreachableStmtAnalyzer.php index c6849bb6361..3f272b578dd 100644 --- a/src/NodeAnalyzer/UnreachableStmtAnalyzer.php +++ b/src/NodeAnalyzer/UnreachableStmtAnalyzer.php @@ -12,20 +12,20 @@ final class UnreachableStmtAnalyzer * in case of unreachable stmts, no other node will have available scope * recursively check previous expressions, until we find nothing or is_unreachable */ - public function isStmtPHPStanUnreachable(?\PhpParser\Node\Stmt $stmt) : bool + public function isStmtPHPStanUnreachable(?Stmt $stmt) : bool { - if (!$stmt instanceof \PhpParser\Node\Stmt) { + if (!$stmt instanceof Stmt) { return \false; } - if ($stmt->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::IS_UNREACHABLE) === \true) { + if ($stmt->getAttribute(AttributeKey::IS_UNREACHABLE) === \true) { // here the scope is never available for next stmt so we have nothing to refresh return \true; } - $previousStmt = $stmt->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_NODE); - if (!$previousStmt instanceof \PhpParser\Node) { + $previousStmt = $stmt->getAttribute(AttributeKey::PREVIOUS_NODE); + if (!$previousStmt instanceof Node) { return \false; } - if ($previousStmt instanceof \PhpParser\Node\Stmt) { + if ($previousStmt instanceof Stmt) { return $this->isStmtPHPStanUnreachable($previousStmt); } return \true; diff --git a/src/NodeAnalyzer/VariableAnalyzer.php b/src/NodeAnalyzer/VariableAnalyzer.php index 3a3448542d7..1a4ff666014 100644 --- a/src/NodeAnalyzer/VariableAnalyzer.php +++ b/src/NodeAnalyzer/VariableAnalyzer.php @@ -24,18 +24,18 @@ final class VariableAnalyzer * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeComparator $nodeComparator) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeComparator = $nodeComparator; } - public function isStaticOrGlobal(\PhpParser\Node\Expr\Variable $variable) : bool + public function isStaticOrGlobal(Variable $variable) : bool { if ($this->isParentStaticOrGlobal($variable)) { return \true; } - return (bool) $this->betterNodeFinder->findFirstPrevious($variable, function (\PhpParser\Node $node) use($variable) : bool { - if (!\in_array(\get_class($node), [\PhpParser\Node\Stmt\Static_::class, \PhpParser\Node\Stmt\Global_::class], \true)) { + return (bool) $this->betterNodeFinder->findFirstPrevious($variable, function (Node $node) use($variable) : bool { + if (!\in_array(\get_class($node), [Static_::class, Global_::class], \true)) { return \false; } /** @@ -44,7 +44,7 @@ final class VariableAnalyzer */ $vars = $node->vars; foreach ($vars as $var) { - $staticVarVariable = $var instanceof \PhpParser\Node\Stmt\StaticVar ? $var->var : $var; + $staticVarVariable = $var instanceof StaticVar ? $var->var : $var; if ($this->nodeComparator->areNodesEqual($staticVarVariable, $variable)) { return \true; } @@ -52,35 +52,35 @@ final class VariableAnalyzer return \false; }); } - public function isUsedByReference(\PhpParser\Node\Expr\Variable $variable) : bool + public function isUsedByReference(Variable $variable) : bool { - return (bool) $this->betterNodeFinder->findFirstPrevious($variable, function (\PhpParser\Node $subNode) use($variable) : bool { - if (!$subNode instanceof \PhpParser\Node\Expr\Variable) { + return (bool) $this->betterNodeFinder->findFirstPrevious($variable, function (Node $subNode) use($variable) : bool { + if (!$subNode instanceof Variable) { return \false; } if (!$this->nodeComparator->areNodesEqual($subNode, $variable)) { return \false; } - $parent = $subNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\Expr\ClosureUse) { + $parent = $subNode->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof ClosureUse) { return \false; } return $parent->byRef; }); } - private function isParentStaticOrGlobal(\PhpParser\Node\Expr\Variable $variable) : bool + private function isParentStaticOrGlobal(Variable $variable) : bool { - $parentNode = $variable->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node) { + $parentNode = $variable->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof Node) { return \false; } - if ($parentNode instanceof \PhpParser\Node\Stmt\Global_) { + if ($parentNode instanceof Global_) { return \true; } - if (!$parentNode instanceof \PhpParser\Node\Stmt\StaticVar) { + if (!$parentNode instanceof StaticVar) { return \false; } - $parentParentNode = $parentNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - return $parentParentNode instanceof \PhpParser\Node\Stmt\Static_; + $parentParentNode = $parentNode->getAttribute(AttributeKey::PARENT_NODE); + return $parentParentNode instanceof Static_; } } diff --git a/src/NodeAnalyzer/VariadicAnalyzer.php b/src/NodeAnalyzer/VariadicAnalyzer.php index 76ad6e9017c..d32724ce9e7 100644 --- a/src/NodeAnalyzer/VariadicAnalyzer.php +++ b/src/NodeAnalyzer/VariadicAnalyzer.php @@ -36,7 +36,7 @@ final class VariadicAnalyzer * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\AstResolver $astResolver, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver, AstResolver $astResolver, ReflectionResolver $reflectionResolver) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeNameResolver = $nodeNameResolver; @@ -55,13 +55,13 @@ final class VariadicAnalyzer if ($this->hasVariadicVariant($functionLikeReflection)) { return \true; } - if ($functionLikeReflection instanceof \PHPStan\Reflection\FunctionReflection) { + if ($functionLikeReflection instanceof FunctionReflection) { $function = $this->astResolver->resolveFunctionFromFunctionReflection($functionLikeReflection); - if (!$function instanceof \PhpParser\Node\Stmt\Function_) { + if (!$function instanceof Function_) { return \false; } - return (bool) $this->betterNodeFinder->findFirst($function->stmts, function (\PhpParser\Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Expr\FuncCall) { + return (bool) $this->betterNodeFinder->findFirst($function->stmts, function (Node $node) : bool { + if (!$node instanceof FuncCall) { return \false; } return $this->nodeNameResolver->isNames($node, ['func_get_args', 'func_num_args', 'func_get_arg']); diff --git a/src/NodeDecorator/CreatedByRuleDecorator.php b/src/NodeDecorator/CreatedByRuleDecorator.php index abbf18a35b0..f822272f7ea 100644 --- a/src/NodeDecorator/CreatedByRuleDecorator.php +++ b/src/NodeDecorator/CreatedByRuleDecorator.php @@ -10,9 +10,9 @@ final class CreatedByRuleDecorator /** * @param mixed[]|\PhpParser\Node $node */ - public function decorate($node, \PhpParser\Node $originalNode, string $rectorClass) : void + public function decorate($node, Node $originalNode, string $rectorClass) : void { - if ($node instanceof \PhpParser\Node) { + if ($node instanceof Node) { $node = [$node]; } foreach ($node as $singleNode) { @@ -20,10 +20,10 @@ final class CreatedByRuleDecorator } $this->createByRule($originalNode, $rectorClass); } - private function createByRule(\PhpParser\Node $node, string $rectorClass) : void + private function createByRule(Node $node, string $rectorClass) : void { - $mergeCreatedByRule = \array_merge($node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CREATED_BY_RULE) ?? [], [$rectorClass]); + $mergeCreatedByRule = \array_merge($node->getAttribute(AttributeKey::CREATED_BY_RULE) ?? [], [$rectorClass]); $mergeCreatedByRule = \array_unique($mergeCreatedByRule); - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CREATED_BY_RULE, $mergeCreatedByRule); + $node->setAttribute(AttributeKey::CREATED_BY_RULE, $mergeCreatedByRule); } } diff --git a/src/NodeDecorator/NamespacedNameDecorator.php b/src/NodeDecorator/NamespacedNameDecorator.php index 0c29009c172..b89b226374d 100644 --- a/src/NodeDecorator/NamespacedNameDecorator.php +++ b/src/NodeDecorator/NamespacedNameDecorator.php @@ -15,8 +15,8 @@ final class NamespacedNameDecorator { $nodes = \is_array($node) ? $node : [$node]; // traverse with node name resolver, to to comply with PHPStan default parser - $nameResolver = new \PhpParser\NodeVisitor\NameResolver(null, ['replaceNodes' => \false, 'preserveOriginalNames' => \true]); - $nodeTraverser = new \PhpParser\NodeTraverser(); + $nameResolver = new NameResolver(null, ['replaceNodes' => \false, 'preserveOriginalNames' => \true]); + $nodeTraverser = new NodeTraverser(); $nodeTraverser->addVisitor($nameResolver); $nodeTraverser->traverse($nodes); } diff --git a/src/NodeDecorator/PropertyTypeDecorator.php b/src/NodeDecorator/PropertyTypeDecorator.php index f770f91e6d8..cad1a05673b 100644 --- a/src/NodeDecorator/PropertyTypeDecorator.php +++ b/src/NodeDecorator/PropertyTypeDecorator.php @@ -34,24 +34,24 @@ final class PropertyTypeDecorator * @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger */ private $phpDocTypeChanger; - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory, PhpVersionProvider $phpVersionProvider, StaticTypeMapper $staticTypeMapper, PhpDocTypeChanger $phpDocTypeChanger) { $this->phpDocInfoFactory = $phpDocInfoFactory; $this->phpVersionProvider = $phpVersionProvider; $this->staticTypeMapper = $staticTypeMapper; $this->phpDocTypeChanger = $phpDocTypeChanger; } - public function decorate(\PhpParser\Node\Stmt\Property $property, ?\PHPStan\Type\Type $type) : void + public function decorate(Property $property, ?Type $type) : void { if ($type === null) { return; } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES)) { - $phpParserType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY); + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::TYPED_PROPERTIES)) { + $phpParserType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, TypeKind::PROPERTY); if ($phpParserType !== null) { $property->type = $phpParserType; - if ($type instanceof \PHPStan\Type\Generic\GenericObjectType) { + if ($type instanceof GenericObjectType) { $this->phpDocTypeChanger->changeVarType($phpDocInfo, $type); } return; diff --git a/src/NodeManipulator/ArrayDestructVariableFilter.php b/src/NodeManipulator/ArrayDestructVariableFilter.php index d0456cc4a68..31151b0ac76 100644 --- a/src/NodeManipulator/ArrayDestructVariableFilter.php +++ b/src/NodeManipulator/ArrayDestructVariableFilter.php @@ -23,7 +23,7 @@ final class ArrayDestructVariableFilter * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->nodeNameResolver = $nodeNameResolver; @@ -32,14 +32,14 @@ final class ArrayDestructVariableFilter * @param Assign[] $variableAssigns * @return Assign[] */ - public function filterOut(array $variableAssigns, \PhpParser\Node\Stmt\ClassMethod $classMethod) : array + public function filterOut(array $variableAssigns, ClassMethod $classMethod) : array { $arrayDestructionCreatedVariables = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classMethod, function (\PhpParser\Node $node) use(&$arrayDestructionCreatedVariables) { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classMethod, function (Node $node) use(&$arrayDestructionCreatedVariables) { + if (!$node instanceof Assign) { return null; } - if (!$node->var instanceof \PhpParser\Node\Expr\Array_ && !$node->var instanceof \PhpParser\Node\Expr\List_) { + if (!$node->var instanceof Array_ && !$node->var instanceof List_) { return null; } foreach ($node->var->items as $arrayItem) { @@ -47,7 +47,7 @@ final class ArrayDestructVariableFilter if ($arrayItem === null) { continue; } - if (!$arrayItem->value instanceof \PhpParser\Node\Expr\Variable) { + if (!$arrayItem->value instanceof Variable) { continue; } /** @var string $variableName */ @@ -55,7 +55,7 @@ final class ArrayDestructVariableFilter $arrayDestructionCreatedVariables[] = $variableName; } }); - return \array_filter($variableAssigns, function (\PhpParser\Node\Expr\Assign $assign) use($arrayDestructionCreatedVariables) : bool { + return \array_filter($variableAssigns, function (Assign $assign) use($arrayDestructionCreatedVariables) : bool { return !$this->nodeNameResolver->isNames($assign->var, $arrayDestructionCreatedVariables); }); } diff --git a/src/NodeManipulator/ArrayManipulator.php b/src/NodeManipulator/ArrayManipulator.php index 302f8d527e9..2398730af3c 100644 --- a/src/NodeManipulator/ArrayManipulator.php +++ b/src/NodeManipulator/ArrayManipulator.php @@ -22,21 +22,21 @@ final class ArrayManipulator * @var \Rector\ChangesReporting\Collector\RectorChangeCollector */ private $rectorChangeCollector; - public function __construct(\Rector\ChangesReporting\Collector\RectorChangeCollector $rectorChangeCollector) + public function __construct(RectorChangeCollector $rectorChangeCollector) { $this->rectorChangeCollector = $rectorChangeCollector; } /** * @required */ - public function autowire(\Rector\Core\NodeAnalyzer\ExprAnalyzer $exprAnalyzer) : void + public function autowire(ExprAnalyzer $exprAnalyzer) : void { $this->exprAnalyzer = $exprAnalyzer; } - public function isDynamicArray(\PhpParser\Node\Expr\Array_ $array) : bool + public function isDynamicArray(Array_ $array) : bool { foreach ($array->items as $item) { - if (!$item instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$item instanceof ArrayItem) { continue; } if (!$this->isAllowedArrayKey($item->key)) { @@ -48,23 +48,23 @@ final class ArrayManipulator } return \false; } - public function addItemToArrayUnderKey(\PhpParser\Node\Expr\Array_ $array, \PhpParser\Node\Expr\ArrayItem $newArrayItem, string $key) : void + public function addItemToArrayUnderKey(Array_ $array, ArrayItem $newArrayItem, string $key) : void { foreach ($array->items as $item) { if ($item === null) { continue; } if ($this->hasKeyName($item, $key)) { - if (!$item->value instanceof \PhpParser\Node\Expr\Array_) { + if (!$item->value instanceof Array_) { continue; } $item->value->items[] = $newArrayItem; return; } } - $array->items[] = new \PhpParser\Node\Expr\ArrayItem(new \PhpParser\Node\Expr\Array_([$newArrayItem]), new \PhpParser\Node\Scalar\String_($key)); + $array->items[] = new ArrayItem(new Array_([$newArrayItem]), new String_($key)); } - public function findItemInInArrayByKeyAndUnset(\PhpParser\Node\Expr\Array_ $array, string $keyName) : ?\PhpParser\Node\Expr\ArrayItem + public function findItemInInArrayByKeyAndUnset(Array_ $array, string $keyName) : ?ArrayItem { foreach ($array->items as $i => $item) { if ($item === null) { @@ -74,7 +74,7 @@ final class ArrayManipulator continue; } $removedArrayItem = $array->items[$i]; - if (!$removedArrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$removedArrayItem instanceof ArrayItem) { continue; } // remove + recount for the printer @@ -84,23 +84,23 @@ final class ArrayManipulator } return null; } - public function hasKeyName(\PhpParser\Node\Expr\ArrayItem $arrayItem, string $name) : bool + public function hasKeyName(ArrayItem $arrayItem, string $name) : bool { - if (!$arrayItem->key instanceof \PhpParser\Node\Scalar\String_) { + if (!$arrayItem->key instanceof String_) { return \false; } return $arrayItem->key->value === $name; } - private function isAllowedArrayKey(?\PhpParser\Node\Expr $expr) : bool + private function isAllowedArrayKey(?Expr $expr) : bool { - if (!$expr instanceof \PhpParser\Node\Expr) { + if (!$expr instanceof Expr) { return \true; } - return \in_array(\get_class($expr), [\PhpParser\Node\Scalar\String_::class, \PhpParser\Node\Scalar\LNumber::class], \true); + return \in_array(\get_class($expr), [String_::class, LNumber::class], \true); } - private function isAllowedArrayValue(\PhpParser\Node\Expr $expr) : bool + private function isAllowedArrayValue(Expr $expr) : bool { - if ($expr instanceof \PhpParser\Node\Expr\Array_) { + if ($expr instanceof Array_) { return !$this->isDynamicArray($expr); } return !$this->exprAnalyzer->isDynamicExpr($expr); diff --git a/src/NodeManipulator/AssignManipulator.php b/src/NodeManipulator/AssignManipulator.php index fe921ac38f1..e8acb7f84cb 100644 --- a/src/NodeManipulator/AssignManipulator.php +++ b/src/NodeManipulator/AssignManipulator.php @@ -29,7 +29,7 @@ final class AssignManipulator /** * @var array> */ - private const MODIFYING_NODE_TYPES = [\PhpParser\Node\Expr\AssignOp::class, \PhpParser\Node\Expr\PreDec::class, \PhpParser\Node\Expr\PostDec::class, \PhpParser\Node\Expr\PreInc::class, \PhpParser\Node\Expr\PostInc::class]; + private const MODIFYING_NODE_TYPES = [AssignOp::class, PreDec::class, PostDec::class, PreInc::class, PostInc::class]; /** * @readonly * @var \Rector\NodeNameResolver\NodeNameResolver @@ -55,7 +55,7 @@ final class AssignManipulator * @var \Symplify\PackageBuilder\Php\TypeChecker */ private $typeChecker; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \RectorPrefix20220607\Symplify\PackageBuilder\Php\TypeChecker $typeChecker) + public function __construct(NodeNameResolver $nodeNameResolver, NodeComparator $nodeComparator, BetterNodeFinder $betterNodeFinder, PropertyFetchAnalyzer $propertyFetchAnalyzer, TypeChecker $typeChecker) { $this->nodeNameResolver = $nodeNameResolver; $this->nodeComparator = $nodeComparator; @@ -67,57 +67,57 @@ final class AssignManipulator * Matches: * each() = [1, 2]; */ - public function isListToEachAssign(\PhpParser\Node\Expr\Assign $assign) : bool + public function isListToEachAssign(Assign $assign) : bool { - if (!$assign->expr instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$assign->expr instanceof FuncCall) { return \false; } - if (!$assign->var instanceof \PhpParser\Node\Expr\List_) { + if (!$assign->var instanceof List_) { return \false; } return $this->nodeNameResolver->isName($assign->expr, 'each'); } - public function isLeftPartOfAssign(\PhpParser\Node $node) : bool + public function isLeftPartOfAssign(Node $node) : bool { - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\Expr\Assign && $this->nodeComparator->areNodesEqual($parent->var, $node)) { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof Assign && $this->nodeComparator->areNodesEqual($parent->var, $node)) { return \true; } if ($parent !== null && $this->typeChecker->isInstanceOf($parent, self::MODIFYING_NODE_TYPES)) { return \true; } // traverse up to array dim fetches - if ($parent instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if ($parent instanceof ArrayDimFetch) { $previousParent = $parent; - while ($parent instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + while ($parent instanceof ArrayDimFetch) { $previousParent = $parent; - $parent = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parent = $parent->getAttribute(AttributeKey::PARENT_NODE); } - if ($parent instanceof \PhpParser\Node\Expr\Assign) { + if ($parent instanceof Assign) { return $parent->var === $previousParent; } } return \false; } - public function isNodePartOfAssign(\PhpParser\Node $node) : bool + public function isNodePartOfAssign(Node $node) : bool { $previousNode = $node; - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - while ($parentNode instanceof \PhpParser\Node && !$parentNode instanceof \PhpParser\Node\Stmt\Expression) { - if ($parentNode instanceof \PhpParser\Node\Expr\Assign && $this->nodeComparator->areNodesEqual($parentNode->var, $previousNode)) { + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); + while ($parentNode instanceof Node && !$parentNode instanceof Expression) { + if ($parentNode instanceof Assign && $this->nodeComparator->areNodesEqual($parentNode->var, $previousNode)) { return \true; } $previousNode = $parentNode; - $parentNode = $parentNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $parentNode->getAttribute(AttributeKey::PARENT_NODE); } return \false; } /** * @return array */ - public function resolveAssignsToLocalPropertyFetches(\PhpParser\Node\FunctionLike $functionLike) : array + public function resolveAssignsToLocalPropertyFetches(FunctionLike $functionLike) : array { - return $this->betterNodeFinder->find((array) $functionLike->getStmts(), function (\PhpParser\Node $node) : bool { + return $this->betterNodeFinder->find((array) $functionLike->getStmts(), function (Node $node) : bool { if (!$this->propertyFetchAnalyzer->isLocalPropertyFetch($node)) { return \false; } diff --git a/src/NodeManipulator/BinaryOpManipulator.php b/src/NodeManipulator/BinaryOpManipulator.php index 7325e74b965..a7bcc4b2e2a 100644 --- a/src/NodeManipulator/BinaryOpManipulator.php +++ b/src/NodeManipulator/BinaryOpManipulator.php @@ -19,7 +19,7 @@ final class BinaryOpManipulator * @var \Rector\Core\PhpParser\Node\AssignAndBinaryMap */ private $assignAndBinaryMap; - public function __construct(\Rector\Core\PhpParser\Node\AssignAndBinaryMap $assignAndBinaryMap) + public function __construct(AssignAndBinaryMap $assignAndBinaryMap) { $this->assignAndBinaryMap = $assignAndBinaryMap; } @@ -30,14 +30,14 @@ final class BinaryOpManipulator * @param callable(Node $firstNode, Node $secondNode=): bool|class-string $firstCondition * @param callable(Node $firstNode, Node $secondNode=): bool|class-string $secondCondition */ - public function matchFirstAndSecondConditionNode(\PhpParser\Node\Expr\BinaryOp $binaryOp, $firstCondition, $secondCondition) : ?\Rector\Php71\ValueObject\TwoNodeMatch + public function matchFirstAndSecondConditionNode(BinaryOp $binaryOp, $firstCondition, $secondCondition) : ?TwoNodeMatch { $this->validateCondition($firstCondition); $this->validateCondition($secondCondition); $firstCondition = $this->normalizeCondition($firstCondition); $secondCondition = $this->normalizeCondition($secondCondition); if ($firstCondition($binaryOp->left, $binaryOp->right) && $secondCondition($binaryOp->right, $binaryOp->left)) { - return new \Rector\Php71\ValueObject\TwoNodeMatch($binaryOp->left, $binaryOp->right); + return new TwoNodeMatch($binaryOp->left, $binaryOp->right); } if (!$firstCondition($binaryOp->right, $binaryOp->left)) { return null; @@ -45,15 +45,15 @@ final class BinaryOpManipulator if (!$secondCondition($binaryOp->left, $binaryOp->right)) { return null; } - return new \Rector\Php71\ValueObject\TwoNodeMatch($binaryOp->right, $binaryOp->left); + return new TwoNodeMatch($binaryOp->right, $binaryOp->left); } - public function inverseBinaryOp(\PhpParser\Node\Expr\BinaryOp $binaryOp) : ?\PhpParser\Node\Expr\BinaryOp + public function inverseBinaryOp(BinaryOp $binaryOp) : ?BinaryOp { // no nesting - if ($binaryOp->left instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { + if ($binaryOp->left instanceof BooleanOr) { return null; } - if ($binaryOp->right instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { + if ($binaryOp->right instanceof BooleanOr) { return null; } $inversedNodeClass = $this->resolveInversedNodeClass($binaryOp); @@ -64,13 +64,13 @@ final class BinaryOpManipulator $secondInversedNode = $this->inverseNode($binaryOp->right); return new $inversedNodeClass($firstInversedNode, $secondInversedNode); } - public function invertCondition(\PhpParser\Node\Expr\BinaryOp $binaryOp) : ?\PhpParser\Node\Expr\BinaryOp + public function invertCondition(BinaryOp $binaryOp) : ?BinaryOp { // no nesting - if ($binaryOp->left instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { + if ($binaryOp->left instanceof BooleanOr) { return null; } - if ($binaryOp->right instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { + if ($binaryOp->right instanceof BooleanOr) { return null; } $inversedNodeClass = $this->resolveInversedNodeClass($binaryOp); @@ -82,18 +82,18 @@ final class BinaryOpManipulator /** * @return \PhpParser\Node\Expr\BinaryOp|\PhpParser\Node\Expr|\PhpParser\Node\Expr\BooleanNot */ - public function inverseNode(\PhpParser\Node\Expr $expr) + public function inverseNode(Expr $expr) { - if ($expr instanceof \PhpParser\Node\Expr\BinaryOp) { + if ($expr instanceof BinaryOp) { $inversedBinaryOp = $this->assignAndBinaryMap->getInversed($expr); if ($inversedBinaryOp !== null) { return new $inversedBinaryOp($expr->left, $expr->right); } } - if ($expr instanceof \PhpParser\Node\Expr\BooleanNot) { + if ($expr instanceof BooleanNot) { return $expr->expr; } - return new \PhpParser\Node\Expr\BooleanNot($expr); + return new BooleanNot($expr); } /** * @param callable(Node $firstNode, Node $secondNode=): bool|class-string $firstCondition @@ -103,10 +103,10 @@ final class BinaryOpManipulator if (\is_callable($firstCondition)) { return; } - if (\is_a($firstCondition, \PhpParser\Node::class, \true)) { + if (\is_a($firstCondition, Node::class, \true)) { return; } - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } /** * @param callable(Node $firstNode, Node $secondNode=): bool|class-string $condition @@ -117,21 +117,21 @@ final class BinaryOpManipulator if (\is_callable($condition)) { return $condition; } - return function (\PhpParser\Node $node) use($condition) : bool { + return function (Node $node) use($condition) : bool { return \is_a($node, $condition, \true); }; } /** * @return class-string|null */ - private function resolveInversedNodeClass(\PhpParser\Node\Expr\BinaryOp $binaryOp) : ?string + private function resolveInversedNodeClass(BinaryOp $binaryOp) : ?string { $inversedNodeClass = $this->assignAndBinaryMap->getInversed($binaryOp); if ($inversedNodeClass !== null) { return $inversedNodeClass; } - if ($binaryOp instanceof \PhpParser\Node\Expr\BinaryOp\BooleanOr) { - return \PhpParser\Node\Expr\BinaryOp\BooleanAnd::class; + if ($binaryOp instanceof BooleanOr) { + return BooleanAnd::class; } return null; } diff --git a/src/NodeManipulator/ClassConstManipulator.php b/src/NodeManipulator/ClassConstManipulator.php index a7e5dd49e94..60ebeee2856 100644 --- a/src/NodeManipulator/ClassConstManipulator.php +++ b/src/NodeManipulator/ClassConstManipulator.php @@ -29,28 +29,28 @@ final class ClassConstManipulator * @var \Rector\Core\PhpParser\AstResolver */ private $astResolver; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\AstResolver $astResolver) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver, AstResolver $astResolver) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeNameResolver = $nodeNameResolver; $this->astResolver = $astResolver; } - public function hasClassConstFetch(\PhpParser\Node\Stmt\ClassConst $classConst, \PHPStan\Reflection\ClassReflection $classReflection) : bool + public function hasClassConstFetch(ClassConst $classConst, ClassReflection $classReflection) : bool { - $class = $this->betterNodeFinder->findParentType($classConst, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($classConst, Class_::class); + if (!$class instanceof Class_) { return \false; } $className = (string) $this->nodeNameResolver->getName($class); foreach ($classReflection->getAncestors() as $ancestorClassReflection) { $ancestorClass = $this->astResolver->resolveClassFromClassReflection($ancestorClassReflection, $ancestorClassReflection->getName()); - if (!$ancestorClass instanceof \PhpParser\Node\Stmt\ClassLike) { + if (!$ancestorClass instanceof ClassLike) { continue; } // has in class? - $isClassConstFetchFound = (bool) $this->betterNodeFinder->find($ancestorClass, function (\PhpParser\Node $node) use($classConst, $className) : bool { + $isClassConstFetchFound = (bool) $this->betterNodeFinder->find($ancestorClass, function (Node $node) use($classConst, $className) : bool { // property + static fetch - if (!$node instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if (!$node instanceof ClassConstFetch) { return \false; } return $this->isNameMatch($node, $classConst, $className); @@ -61,7 +61,7 @@ final class ClassConstManipulator } return \false; } - private function isNameMatch(\PhpParser\Node\Expr\ClassConstFetch $classConstFetch, \PhpParser\Node\Stmt\ClassConst $classConst, string $className) : bool + private function isNameMatch(ClassConstFetch $classConstFetch, ClassConst $classConst, string $className) : bool { $classConstName = (string) $this->nodeNameResolver->getName($classConst); $selfConstantName = 'self::' . $classConstName; diff --git a/src/NodeManipulator/ClassDependencyManipulator.php b/src/NodeManipulator/ClassDependencyManipulator.php index 6ff53859551..bce7e5f7f73 100644 --- a/src/NodeManipulator/ClassDependencyManipulator.php +++ b/src/NodeManipulator/ClassDependencyManipulator.php @@ -84,7 +84,7 @@ final class ClassDependencyManipulator * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator, \Rector\Core\NodeManipulator\ClassMethodAssignManipulator $classMethodAssignManipulator, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\Core\NodeManipulator\StmtsManipulator $stmtsManipulator, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider, \Rector\Core\NodeAnalyzer\PropertyPresenceChecker $propertyPresenceChecker, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\PostRector\Collector\NodesToRemoveCollector $nodesToRemoveCollector, \Rector\TypeDeclaration\NodeAnalyzer\AutowiredClassMethodOrPropertyAnalyzer $autowiredClassMethodOrPropertyAnalyzer, \Rector\Core\NodeManipulator\Dependency\DependencyClassMethodDecorator $dependencyClassMethodDecorator, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(\Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator, \Rector\Core\NodeManipulator\ClassMethodAssignManipulator $classMethodAssignManipulator, NodeFactory $nodeFactory, \Rector\Core\NodeManipulator\StmtsManipulator $stmtsManipulator, PhpVersionProvider $phpVersionProvider, PropertyPresenceChecker $propertyPresenceChecker, NodeNameResolver $nodeNameResolver, NodesToRemoveCollector $nodesToRemoveCollector, AutowiredClassMethodOrPropertyAnalyzer $autowiredClassMethodOrPropertyAnalyzer, DependencyClassMethodDecorator $dependencyClassMethodDecorator, ReflectionResolver $reflectionResolver) { $this->classInsertManipulator = $classInsertManipulator; $this->classMethodAssignManipulator = $classMethodAssignManipulator; @@ -98,12 +98,12 @@ final class ClassDependencyManipulator $this->dependencyClassMethodDecorator = $dependencyClassMethodDecorator; $this->reflectionResolver = $reflectionResolver; } - public function addConstructorDependency(\PhpParser\Node\Stmt\Class_ $class, \Rector\PostRector\ValueObject\PropertyMetadata $propertyMetadata) : void + public function addConstructorDependency(Class_ $class, PropertyMetadata $propertyMetadata) : void { if ($this->hasClassPropertyAndDependency($class, $propertyMetadata)) { return; } - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::PROPERTY_PROMOTION)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::PROPERTY_PROMOTION)) { $this->classInsertManipulator->addPropertyToClass($class, $propertyMetadata->getName(), $propertyMetadata->getType()); } if ($this->shouldAddPromotedProperty($class, $propertyMetadata)) { @@ -113,32 +113,32 @@ final class ClassDependencyManipulator $this->addConstructorDependencyWithCustomAssign($class, $propertyMetadata->getName(), $propertyMetadata->getType(), $assign); } } - public function addConstructorDependencyWithCustomAssign(\PhpParser\Node\Stmt\Class_ $class, string $name, ?\PHPStan\Type\Type $type, \PhpParser\Node\Expr\Assign $assign) : void + public function addConstructorDependencyWithCustomAssign(Class_ $class, string $name, ?Type $type, Assign $assign) : void { /** @var ClassMethod|null $constructorMethod */ - $constructorMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); + $constructorMethod = $class->getMethod(MethodName::CONSTRUCT); if ($constructorMethod !== null) { $this->classMethodAssignManipulator->addParameterAndAssignToMethod($constructorMethod, $name, $type, $assign); return; } - $constructorMethod = $this->nodeFactory->createPublicMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); + $constructorMethod = $this->nodeFactory->createPublicMethod(MethodName::CONSTRUCT); $this->classMethodAssignManipulator->addParameterAndAssignToMethod($constructorMethod, $name, $type, $assign); $this->classInsertManipulator->addAsFirstMethod($class, $constructorMethod); /** @var Scope $scope */ - $scope = $class->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $class->getAttribute(AttributeKey::SCOPE); $this->dependencyClassMethodDecorator->decorateConstructorWithParentDependencies($class, $constructorMethod, $scope); } /** * @param Stmt[] $stmts */ - public function addStmtsToConstructorIfNotThereYet(\PhpParser\Node\Stmt\Class_ $class, array $stmts) : void + public function addStmtsToConstructorIfNotThereYet(Class_ $class, array $stmts) : void { - $classMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { - $classMethod = $this->nodeFactory->createPublicMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); + $classMethod = $class->getMethod(MethodName::CONSTRUCT); + if (!$classMethod instanceof ClassMethod) { + $classMethod = $this->nodeFactory->createPublicMethod(MethodName::CONSTRUCT); // keep parent constructor call - if ($this->hasClassParentClassMethod($class, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { - $classMethod->stmts[] = $this->createParentClassMethodCall(\Rector\Core\ValueObject\MethodName::CONSTRUCT); + if ($this->hasClassParentClassMethod($class, MethodName::CONSTRUCT)) { + $classMethod->stmts[] = $this->createParentClassMethodCall(MethodName::CONSTRUCT); } $classMethod->stmts = \array_merge((array) $classMethod->stmts, $stmts); $class->stmts = \array_merge($class->stmts, [$classMethod]); @@ -151,36 +151,36 @@ final class ClassDependencyManipulator } $classMethod->stmts = \array_merge($stmts, (array) $classMethod->stmts); } - public function addInjectProperty(\PhpParser\Node\Stmt\Class_ $class, \Rector\PostRector\ValueObject\PropertyMetadata $propertyMetadata) : void + public function addInjectProperty(Class_ $class, PropertyMetadata $propertyMetadata) : void { if ($this->propertyPresenceChecker->hasClassContextProperty($class, $propertyMetadata)) { return; } $this->classInsertManipulator->addInjectPropertyToClass($class, $propertyMetadata); } - private function addPromotedProperty(\PhpParser\Node\Stmt\Class_ $class, \Rector\PostRector\ValueObject\PropertyMetadata $propertyMetadata) : void + private function addPromotedProperty(Class_ $class, PropertyMetadata $propertyMetadata) : void { - $constructClassMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); + $constructClassMethod = $class->getMethod(MethodName::CONSTRUCT); $param = $this->nodeFactory->createPromotedPropertyParam($propertyMetadata); - if ($constructClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if ($constructClassMethod instanceof ClassMethod) { // parameter is already added if ($this->hasMethodParameter($constructClassMethod, $propertyMetadata->getName())) { return; } $constructClassMethod->params[] = $param; } else { - $constructClassMethod = $this->nodeFactory->createPublicMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); + $constructClassMethod = $this->nodeFactory->createPublicMethod(MethodName::CONSTRUCT); $constructClassMethod->params[] = $param; $this->classInsertManipulator->addAsFirstMethod($class, $constructClassMethod); } /** @var Scope $scope */ - $scope = $class->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $class->getAttribute(AttributeKey::SCOPE); $this->dependencyClassMethodDecorator->decorateConstructorWithParentDependencies($class, $constructClassMethod, $scope); } - private function hasClassParentClassMethod(\PhpParser\Node\Stmt\Class_ $class, string $methodName) : bool + private function hasClassParentClassMethod(Class_ $class, string $methodName) : bool { $classReflection = $this->reflectionResolver->resolveClassReflection($class); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } foreach ($classReflection->getParents() as $parentClassReflection) { @@ -190,15 +190,15 @@ final class ClassDependencyManipulator } return \false; } - private function createParentClassMethodCall(string $methodName) : \PhpParser\Node\Stmt\Expression + private function createParentClassMethodCall(string $methodName) : Expression { - $staticCall = new \PhpParser\Node\Expr\StaticCall(new \PhpParser\Node\Name(\Rector\Core\Enum\ObjectReference::PARENT), $methodName); - return new \PhpParser\Node\Stmt\Expression($staticCall); + $staticCall = new StaticCall(new Name(ObjectReference::PARENT), $methodName); + return new Expression($staticCall); } - private function isParamInConstructor(\PhpParser\Node\Stmt\Class_ $class, string $propertyName) : bool + private function isParamInConstructor(Class_ $class, string $propertyName) : bool { - $constructClassMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$constructClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $constructClassMethod = $class->getMethod(MethodName::CONSTRUCT); + if (!$constructClassMethod instanceof ClassMethod) { return \false; } foreach ($constructClassMethod->params as $param) { @@ -208,7 +208,7 @@ final class ClassDependencyManipulator } return \false; } - private function hasClassPropertyAndDependency(\PhpParser\Node\Stmt\Class_ $class, \Rector\PostRector\ValueObject\PropertyMetadata $propertyMetadata) : bool + private function hasClassPropertyAndDependency(Class_ $class, PropertyMetadata $propertyMetadata) : bool { $property = $this->propertyPresenceChecker->getClassContextProperty($class, $propertyMetadata); if ($property === null) { @@ -218,9 +218,9 @@ final class ClassDependencyManipulator return $this->isParamInConstructor($class, $propertyMetadata->getName()); } // is inject/autowired property? - return $property instanceof \PhpParser\Node\Stmt\Property; + return $property instanceof Property; } - private function hasMethodParameter(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $name) : bool + private function hasMethodParameter(ClassMethod $classMethod, string $name) : bool { foreach ($classMethod->params as $param) { if ($this->nodeNameResolver->isName($param->var, $name)) { @@ -229,14 +229,14 @@ final class ClassDependencyManipulator } return \false; } - private function shouldAddPromotedProperty(\PhpParser\Node\Stmt\Class_ $class, \Rector\PostRector\ValueObject\PropertyMetadata $propertyMetadata) : bool + private function shouldAddPromotedProperty(Class_ $class, PropertyMetadata $propertyMetadata) : bool { - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::PROPERTY_PROMOTION)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::PROPERTY_PROMOTION)) { return \false; } // only if the property does not exist yet $existingProperty = $class->getProperty($propertyMetadata->getName()); - if (!$existingProperty instanceof \PhpParser\Node\Stmt\Property) { + if (!$existingProperty instanceof Property) { return \true; } return $this->nodesToRemoveCollector->isNodeRemoved($existingProperty); diff --git a/src/NodeManipulator/ClassInsertManipulator.php b/src/NodeManipulator/ClassInsertManipulator.php index e1f01098925..91c83e70d0d 100644 --- a/src/NodeManipulator/ClassInsertManipulator.php +++ b/src/NodeManipulator/ClassInsertManipulator.php @@ -20,7 +20,7 @@ final class ClassInsertManipulator /** * @var array> */ - private const BEFORE_TRAIT_TYPES = [\PhpParser\Node\Stmt\TraitUse::class, \PhpParser\Node\Stmt\Property::class, \PhpParser\Node\Stmt\ClassMethod::class]; + private const BEFORE_TRAIT_TYPES = [TraitUse::class, Property::class, ClassMethod::class]; /** * @readonly * @var \Rector\Core\PhpParser\Node\NodeFactory @@ -31,7 +31,7 @@ final class ClassInsertManipulator * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeFactory $nodeFactory, NodeNameResolver $nodeNameResolver) { $this->nodeFactory = $nodeFactory; $this->nodeNameResolver = $nodeNameResolver; @@ -39,10 +39,10 @@ final class ClassInsertManipulator /** * @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassConst|\PhpParser\Node\Stmt\ClassMethod $stmt */ - public function addAsFirstMethod(\PhpParser\Node\Stmt\Class_ $class, $stmt) : void + public function addAsFirstMethod(Class_ $class, $stmt) : void { - $scope = $class->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - $stmt->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, $scope); + $scope = $class->getAttribute(AttributeKey::SCOPE); + $stmt->setAttribute(AttributeKey::SCOPE, $scope); if ($this->isSuccessToInsertBeforeFirstMethod($class, $stmt)) { return; } @@ -51,7 +51,7 @@ final class ClassInsertManipulator } $class->stmts[] = $stmt; } - public function addConstantToClass(\PhpParser\Node\Stmt\Class_ $class, string $constantName, \PhpParser\Node\Stmt\ClassConst $classConst) : void + public function addConstantToClass(Class_ $class, string $constantName, ClassConst $classConst) : void { if ($this->hasClassConstant($class, $constantName)) { return; @@ -61,7 +61,7 @@ final class ClassInsertManipulator /** * @param Property[] $properties */ - public function addPropertiesToClass(\PhpParser\Node\Stmt\Class_ $class, array $properties) : void + public function addPropertiesToClass(Class_ $class, array $properties) : void { foreach ($properties as $property) { $this->addAsFirstMethod($class, $property); @@ -70,34 +70,34 @@ final class ClassInsertManipulator /** * @internal Use PropertyAdder service instead */ - public function addPropertyToClass(\PhpParser\Node\Stmt\Class_ $class, string $name, ?\PHPStan\Type\Type $type) : void + public function addPropertyToClass(Class_ $class, string $name, ?Type $type) : void { $existingProperty = $class->getProperty($name); - if ($existingProperty instanceof \PhpParser\Node\Stmt\Property) { + if ($existingProperty instanceof Property) { return; } $property = $this->nodeFactory->createPrivatePropertyFromNameAndType($name, $type); $this->addAsFirstMethod($class, $property); } - public function addInjectPropertyToClass(\PhpParser\Node\Stmt\Class_ $class, \Rector\PostRector\ValueObject\PropertyMetadata $propertyMetadata) : void + public function addInjectPropertyToClass(Class_ $class, PropertyMetadata $propertyMetadata) : void { $existingProperty = $class->getProperty($propertyMetadata->getName()); - if ($existingProperty instanceof \PhpParser\Node\Stmt\Property) { + if ($existingProperty instanceof Property) { return; } $property = $this->nodeFactory->createPublicInjectPropertyFromNameAndType($propertyMetadata->getName(), $propertyMetadata->getType()); $this->addAsFirstMethod($class, $property); } - public function addAsFirstTrait(\PhpParser\Node\Stmt\Class_ $class, string $traitName) : void + public function addAsFirstTrait(Class_ $class, string $traitName) : void { - $traitUse = new \PhpParser\Node\Stmt\TraitUse([new \PhpParser\Node\Name\FullyQualified($traitName)]); + $traitUse = new TraitUse([new FullyQualified($traitName)]); $this->addTraitUse($class, $traitUse); } /** * @param Stmt[] $stmts * @return Stmt[] */ - private function insertBefore(array $stmts, \PhpParser\Node\Stmt $stmt, int $key) : array + private function insertBefore(array $stmts, Stmt $stmt, int $key) : array { \array_splice($stmts, $key, 0, [$stmt]); return $stmts; @@ -105,10 +105,10 @@ final class ClassInsertManipulator /** * @param \PhpParser\Node\Stmt\ClassConst|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property $stmt */ - private function isSuccessToInsertBeforeFirstMethod(\PhpParser\Node\Stmt\Class_ $class, $stmt) : bool + private function isSuccessToInsertBeforeFirstMethod(Class_ $class, $stmt) : bool { foreach ($class->stmts as $key => $classStmt) { - if (!$classStmt instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$classStmt instanceof ClassMethod) { continue; } $class->stmts = $this->insertBefore($class->stmts, $stmt, $key); @@ -119,11 +119,11 @@ final class ClassInsertManipulator /** * @param \PhpParser\Node\Stmt\ClassConst|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property $stmt */ - private function isSuccessToInsertAfterLastProperty(\PhpParser\Node\Stmt\Class_ $class, $stmt) : bool + private function isSuccessToInsertAfterLastProperty(Class_ $class, $stmt) : bool { $previousElement = null; foreach ($class->stmts as $key => $classStmt) { - if ($previousElement instanceof \PhpParser\Node\Stmt\Property && !$classStmt instanceof \PhpParser\Node\Stmt\Property) { + if ($previousElement instanceof Property && !$classStmt instanceof Property) { $class->stmts = $this->insertBefore($class->stmts, $stmt, $key); return \true; } @@ -131,7 +131,7 @@ final class ClassInsertManipulator } return \false; } - private function hasClassConstant(\PhpParser\Node\Stmt\Class_ $class, string $constantName) : bool + private function hasClassConstant(Class_ $class, string $constantName) : bool { foreach ($class->getConstants() as $classConst) { if ($this->nodeNameResolver->isName($classConst, $constantName)) { @@ -140,7 +140,7 @@ final class ClassInsertManipulator } return \false; } - private function addTraitUse(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\TraitUse $traitUse) : void + private function addTraitUse(Class_ $class, TraitUse $traitUse) : void { foreach (self::BEFORE_TRAIT_TYPES as $type) { foreach ($class->stmts as $key => $classStmt) { diff --git a/src/NodeManipulator/ClassManipulator.php b/src/NodeManipulator/ClassManipulator.php index 02887773261..4b277ef8968 100644 --- a/src/NodeManipulator/ClassManipulator.php +++ b/src/NodeManipulator/ClassManipulator.php @@ -34,14 +34,14 @@ final class ClassManipulator * @var \Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer */ private $classChildAnalyzer; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\PostRector\Collector\NodesToRemoveCollector $nodesToRemoveCollector, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer $classChildAnalyzer) + public function __construct(NodeNameResolver $nodeNameResolver, NodesToRemoveCollector $nodesToRemoveCollector, ReflectionProvider $reflectionProvider, ClassChildAnalyzer $classChildAnalyzer) { $this->nodeNameResolver = $nodeNameResolver; $this->nodesToRemoveCollector = $nodesToRemoveCollector; $this->reflectionProvider = $reflectionProvider; $this->classChildAnalyzer = $classChildAnalyzer; } - public function hasParentMethodOrInterface(\PHPStan\Type\ObjectType $objectType, string $oldMethod, string $newMethod) : bool + public function hasParentMethodOrInterface(ObjectType $objectType, string $oldMethod, string $newMethod) : bool { if (!$this->reflectionProvider->hasClass($objectType->getClassName())) { return \false; @@ -62,14 +62,14 @@ final class ClassManipulator /** * @return string[] */ - public function getPrivatePropertyNames(\PhpParser\Node\Stmt\Class_ $class) : array + public function getPrivatePropertyNames(Class_ $class) : array { - $privateProperties = \array_filter($class->getProperties(), function (\PhpParser\Node\Stmt\Property $property) : bool { + $privateProperties = \array_filter($class->getProperties(), function (Property $property) : bool { return $property->isPrivate(); }); return $this->nodeNameResolver->getNames($privateProperties); } - public function hasTrait(\PhpParser\Node\Stmt\Class_ $class, string $desiredTrait) : bool + public function hasTrait(Class_ $class, string $desiredTrait) : bool { foreach ($class->getTraitUses() as $traitUse) { foreach ($traitUse->traits as $traitName) { @@ -81,14 +81,14 @@ final class ClassManipulator } return \false; } - public function replaceTrait(\PhpParser\Node\Stmt\Class_ $class, string $oldTrait, string $newTrait) : void + public function replaceTrait(Class_ $class, string $oldTrait, string $newTrait) : void { foreach ($class->getTraitUses() as $traitUse) { foreach ($traitUse->traits as $key => $traitTrait) { if (!$this->nodeNameResolver->isName($traitTrait, $oldTrait)) { continue; } - $traitUse->traits[$key] = new \PhpParser\Node\Name\FullyQualified($newTrait); + $traitUse->traits[$key] = new FullyQualified($newTrait); break; } } @@ -99,12 +99,12 @@ final class ClassManipulator */ public function getClassLikeNodeParentInterfaceNames($classLike) : array { - if ($classLike instanceof \PhpParser\Node\Stmt\Class_) { + if ($classLike instanceof Class_) { return $this->nodeNameResolver->getNames($classLike->implements); } return $this->nodeNameResolver->getNames($classLike->extends); } - public function removeInterface(\PhpParser\Node\Stmt\Class_ $class, string $desiredInterface) : void + public function removeInterface(Class_ $class, string $desiredInterface) : void { foreach ($class->implements as $implement) { if (!$this->nodeNameResolver->isName($implement, $desiredInterface)) { diff --git a/src/NodeManipulator/ClassMethodAssignManipulator.php b/src/NodeManipulator/ClassMethodAssignManipulator.php index 0d9bda4f941..739a29b6345 100644 --- a/src/NodeManipulator/ClassMethodAssignManipulator.php +++ b/src/NodeManipulator/ClassMethodAssignManipulator.php @@ -73,7 +73,7 @@ final class ClassMethodAssignManipulator * @var \Rector\DeadCode\NodeAnalyzer\ExprUsedInNextNodeAnalyzer */ private $exprUsedInNextNodeAnalyzer; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\NodeManipulator\VariableManipulator $variableManipulator, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\Core\NodeManipulator\ArrayDestructVariableFilter $arrayDestructVariableFilter, \Rector\DeadCode\NodeAnalyzer\ExprUsedInNextNodeAnalyzer $exprUsedInNextNodeAnalyzer) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeFactory $nodeFactory, NodeNameResolver $nodeNameResolver, \Rector\Core\NodeManipulator\VariableManipulator $variableManipulator, NodeComparator $nodeComparator, ReflectionResolver $reflectionResolver, \Rector\Core\NodeManipulator\ArrayDestructVariableFilter $arrayDestructVariableFilter, ExprUsedInNextNodeAnalyzer $exprUsedInNextNodeAnalyzer) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeFactory = $nodeFactory; @@ -87,7 +87,7 @@ final class ClassMethodAssignManipulator /** * @return Assign[] */ - public function collectReadyOnlyAssignScalarVariables(\PhpParser\Node\Stmt\ClassMethod $classMethod, \Rector\Core\ValueObject\Application\File $file) : array + public function collectReadyOnlyAssignScalarVariables(ClassMethod $classMethod, File $file) : array { $assignsOfScalarOrArrayToVariable = $this->variableManipulator->collectScalarOrArrayAssignsOfVariable($classMethod); // filter out [$value] = $array, array destructing @@ -102,13 +102,13 @@ final class ClassMethodAssignManipulator $readOnlyVariableAssigns = $this->filterOutNeverUsedNext($readOnlyVariableAssigns); return $this->variableManipulator->filterOutChangedVariables($readOnlyVariableAssigns, $classMethod); } - public function addParameterAndAssignToMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $name, ?\PHPStan\Type\Type $type, \PhpParser\Node\Expr\Assign $assign) : void + public function addParameterAndAssignToMethod(ClassMethod $classMethod, string $name, ?Type $type, Assign $assign) : void { if ($this->hasMethodParameter($classMethod, $name)) { return; } $classMethod->params[] = $this->nodeFactory->createParamFromNameAndType($name, $type); - $classMethod->stmts[] = new \PhpParser\Node\Stmt\Expression($assign); + $classMethod->stmts[] = new Expression($assign); $classMethodHash = \spl_object_hash($classMethod); $this->alreadyAddedClassMethodNames[$classMethodHash][] = $name; } @@ -118,7 +118,7 @@ final class ClassMethodAssignManipulator */ private function filterOutNeverUsedNext(array $readOnlyVariableAssigns) : array { - return \array_filter($readOnlyVariableAssigns, function (\PhpParser\Node\Expr\Assign $assign) : bool { + return \array_filter($readOnlyVariableAssigns, function (Assign $assign) : bool { return $this->exprUsedInNextNodeAnalyzer->isUsed($assign->var); }); } @@ -126,10 +126,10 @@ final class ClassMethodAssignManipulator * @param Assign[] $variableAssigns * @return Assign[] */ - private function filterOutReferencedVariables(array $variableAssigns, \PhpParser\Node\Stmt\ClassMethod $classMethod) : array + private function filterOutReferencedVariables(array $variableAssigns, ClassMethod $classMethod) : array { $referencedVariables = $this->collectReferenceVariableNames($classMethod); - return \array_filter($variableAssigns, function (\PhpParser\Node\Expr\Assign $assign) use($referencedVariables) : bool { + return \array_filter($variableAssigns, function (Assign $assign) use($referencedVariables) : bool { return !$this->nodeNameResolver->isNames($assign->var, $referencedVariables); }); } @@ -141,9 +141,9 @@ final class ClassMethodAssignManipulator */ private function filterOutMultiAssigns(array $readOnlyVariableAssigns) : array { - return \array_filter($readOnlyVariableAssigns, function (\PhpParser\Node\Expr\Assign $assign) : bool { - $parent = $assign->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - return !$parent instanceof \PhpParser\Node\Expr\Assign; + return \array_filter($readOnlyVariableAssigns, function (Assign $assign) : bool { + $parent = $assign->getAttribute(AttributeKey::PARENT_NODE); + return !$parent instanceof Assign; }); } /** @@ -154,7 +154,7 @@ final class ClassMethodAssignManipulator { foreach ($variableAssigns as $key => $variableAssign) { $foreach = $this->findParentForeach($variableAssign); - if (!$foreach instanceof \PhpParser\Node\Stmt\Foreach_) { + if (!$foreach instanceof Foreach_) { continue; } if ($this->nodeComparator->areNodesEqual($foreach->valueVar, $variableAssign->var)) { @@ -167,7 +167,7 @@ final class ClassMethodAssignManipulator } return $variableAssigns; } - private function hasMethodParameter(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $name) : bool + private function hasMethodParameter(ClassMethod $classMethod, string $name) : bool { foreach ($classMethod->params as $param) { if ($this->nodeNameResolver->isName($param->var, $name)) { @@ -183,16 +183,16 @@ final class ClassMethodAssignManipulator /** * @return string[] */ - private function collectReferenceVariableNames(\PhpParser\Node\Stmt\ClassMethod $classMethod) : array + private function collectReferenceVariableNames(ClassMethod $classMethod) : array { $referencedVariables = []; /** @var Variable[] $variables */ - $variables = $this->betterNodeFinder->findInstanceOf($classMethod, \PhpParser\Node\Expr\Variable::class); + $variables = $this->betterNodeFinder->findInstanceOf($classMethod, Variable::class); foreach ($variables as $variable) { if ($this->nodeNameResolver->isName($variable, 'this')) { continue; } - $parent = $variable->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parent = $variable->getAttribute(AttributeKey::PARENT_NODE); if ($parent !== null && $this->isExplicitlyReferenced($parent)) { $variableName = $this->nodeNameResolver->getName($variable); if ($variableName === null) { @@ -202,11 +202,11 @@ final class ClassMethodAssignManipulator continue; } $argumentPosition = null; - if ($parent instanceof \PhpParser\Node\Arg) { - $argumentPosition = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ARGUMENT_POSITION); - $parent = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + if ($parent instanceof Arg) { + $argumentPosition = $parent->getAttribute(AttributeKey::ARGUMENT_POSITION); + $parent = $parent->getAttribute(AttributeKey::PARENT_NODE); } - if (!$parent instanceof \PhpParser\Node) { + if (!$parent instanceof Node) { continue; } if ($argumentPosition === null) { @@ -223,23 +223,23 @@ final class ClassMethodAssignManipulator } return $referencedVariables; } - private function findParentForeach(\PhpParser\Node\Expr\Assign $assign) : ?\PhpParser\Node\Stmt\Foreach_ + private function findParentForeach(Assign $assign) : ?Foreach_ { /** @var Foreach_|FunctionLike|null $foundNode */ - $foundNode = $this->betterNodeFinder->findParentByTypes($assign, [\PhpParser\Node\Stmt\Foreach_::class, \PhpParser\Node\FunctionLike::class]); - if (!$foundNode instanceof \PhpParser\Node\Stmt\Foreach_) { + $foundNode = $this->betterNodeFinder->findParentByTypes($assign, [Foreach_::class, FunctionLike::class]); + if (!$foundNode instanceof Foreach_) { return null; } return $foundNode; } - private function isExplicitlyReferenced(\PhpParser\Node $node) : bool + private function isExplicitlyReferenced(Node $node) : bool { - if ($node instanceof \PhpParser\Node\Arg || $node instanceof \PhpParser\Node\Expr\ClosureUse || $node instanceof \PhpParser\Node\Param) { + if ($node instanceof Arg || $node instanceof ClosureUse || $node instanceof Param) { return $node->byRef; } return \false; } - private function isCallOrConstructorWithReference(\PhpParser\Node $node, \PhpParser\Node\Expr\Variable $variable, int $argumentPosition) : bool + private function isCallOrConstructorWithReference(Node $node, Variable $variable, int $argumentPosition) : bool { if ($this->isMethodCallWithReferencedArgument($node, $variable)) { return \true; @@ -249,13 +249,13 @@ final class ClassMethodAssignManipulator } return $this->isConstructorWithReference($node, $argumentPosition); } - private function isMethodCallWithReferencedArgument(\PhpParser\Node $node, \PhpParser\Node\Expr\Variable $variable) : bool + private function isMethodCallWithReferencedArgument(Node $node, Variable $variable) : bool { - if (!$node instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$node instanceof MethodCall) { return \false; } $methodReflection = $this->reflectionResolver->resolveMethodReflectionFromMethodCall($node); - if (!$methodReflection instanceof \PHPStan\Reflection\MethodReflection) { + if (!$methodReflection instanceof MethodReflection) { return \false; } $variableName = $this->nodeNameResolver->getName($variable); @@ -274,9 +274,9 @@ final class ClassMethodAssignManipulator * - array_shift($value) * - sort($values) */ - private function isFuncCallWithReferencedArgument(\PhpParser\Node $node, \PhpParser\Node\Expr\Variable $variable) : bool + private function isFuncCallWithReferencedArgument(Node $node, Variable $variable) : bool { - if (!$node instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$node instanceof FuncCall) { return \false; } if (!$this->nodeNameResolver->isNames($node, ['array_shift', '*sort'])) { @@ -285,23 +285,23 @@ final class ClassMethodAssignManipulator if (!isset($node->args[0])) { return \false; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return \false; } // is 1t argument return $node->args[0]->value !== $variable; } - private function isConstructorWithReference(\PhpParser\Node $node, int $argumentPosition) : bool + private function isConstructorWithReference(Node $node, int $argumentPosition) : bool { - if (!$node instanceof \PhpParser\Node\Expr\New_) { + if (!$node instanceof New_) { return \false; } return $this->isParameterReferencedInMethodReflection($node, $argumentPosition); } - private function isParameterReferencedInMethodReflection(\PhpParser\Node\Expr\New_ $new, int $argumentPosition) : bool + private function isParameterReferencedInMethodReflection(New_ $new, int $argumentPosition) : bool { $methodReflection = $this->reflectionResolver->resolveMethodReflectionFromNew($new); - if (!$methodReflection instanceof \PHPStan\Reflection\MethodReflection) { + if (!$methodReflection instanceof MethodReflection) { return \false; } foreach ($methodReflection->getVariants() as $parametersAcceptor) { diff --git a/src/NodeManipulator/ClassMethodManipulator.php b/src/NodeManipulator/ClassMethodManipulator.php index 882d7b82b1e..af230e06b59 100644 --- a/src/NodeManipulator/ClassMethodManipulator.php +++ b/src/NodeManipulator/ClassMethodManipulator.php @@ -39,20 +39,20 @@ final class ClassMethodManipulator * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver, ReflectionResolver $reflectionResolver) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeNameResolver = $nodeNameResolver; $this->nodeTypeResolver = $nodeTypeResolver; $this->reflectionResolver = $reflectionResolver; } - public function isNamedConstructor(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + public function isNamedConstructor(ClassMethod $classMethod) : bool { - if (!$this->nodeNameResolver->isName($classMethod, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if (!$this->nodeNameResolver->isName($classMethod, MethodName::CONSTRUCT)) { return \false; } - $class = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($classMethod, Class_::class); + if (!$class instanceof Class_) { return \false; } if ($classMethod->isPrivate()) { @@ -63,14 +63,14 @@ final class ClassMethodManipulator } return $classMethod->isProtected(); } - public function hasParentMethodOrInterfaceMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod, ?string $methodName = null) : bool + public function hasParentMethodOrInterfaceMethod(ClassMethod $classMethod, ?string $methodName = null) : bool { $methodName = $methodName ?? $this->nodeNameResolver->getName($classMethod->name); if ($methodName === null) { return \false; } $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } foreach ($classReflection->getParents() as $parentClassReflection) { @@ -88,12 +88,12 @@ final class ClassMethodManipulator /** * @param string[] $possibleNames */ - public function addMethodParameterIfMissing(\PhpParser\Node $node, \PHPStan\Type\ObjectType $objectType, array $possibleNames) : string + public function addMethodParameterIfMissing(Node $node, ObjectType $objectType, array $possibleNames) : string { - $classMethod = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassMethod::class); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $this->betterNodeFinder->findParentType($node, ClassMethod::class); + if (!$classMethod instanceof ClassMethod) { // or null? - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } foreach ($classMethod->params as $paramNode) { if (!$this->nodeTypeResolver->isObjectType($paramNode, $objectType)) { @@ -102,13 +102,13 @@ final class ClassMethodManipulator return $this->nodeNameResolver->getName($paramNode); } $paramName = $this->resolveName($classMethod, $possibleNames); - $classMethod->params[] = new \PhpParser\Node\Param(new \PhpParser\Node\Expr\Variable($paramName), null, new \PhpParser\Node\Name\FullyQualified($objectType->getClassName())); + $classMethod->params[] = new Param(new Variable($paramName), null, new FullyQualified($objectType->getClassName())); return $paramName; } /** * @param string[] $possibleNames */ - private function resolveName(\PhpParser\Node\Stmt\ClassMethod $classMethod, array $possibleNames) : string + private function resolveName(ClassMethod $classMethod, array $possibleNames) : string { foreach ($possibleNames as $possibleName) { foreach ($classMethod->params as $paramNode) { @@ -118,6 +118,6 @@ final class ClassMethodManipulator } return $possibleName; } - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } } diff --git a/src/NodeManipulator/ClassMethodPropertyFetchManipulator.php b/src/NodeManipulator/ClassMethodPropertyFetchManipulator.php index 75ffc02f802..b3d27b2a4fd 100644 --- a/src/NodeManipulator/ClassMethodPropertyFetchManipulator.php +++ b/src/NodeManipulator/ClassMethodPropertyFetchManipulator.php @@ -36,7 +36,7 @@ final class ClassMethodPropertyFetchManipulator * @var \Rector\Core\NodeManipulator\FunctionLikeManipulator */ private $functionLikeManipulator; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\NodeManipulator\FunctionLikeManipulator $functionLikeManipulator) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder, \Rector\Core\NodeManipulator\FunctionLikeManipulator $functionLikeManipulator) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->nodeNameResolver = $nodeNameResolver; @@ -52,25 +52,25 @@ final class ClassMethodPropertyFetchManipulator * ↓ * (SomeType $anotherValue) */ - public function findParamAssignToPropertyName(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $propertyName) : ?\PhpParser\Node\Param + public function findParamAssignToPropertyName(ClassMethod $classMethod, string $propertyName) : ?Param { $assignedParamName = null; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (\PhpParser\Node $node) use($propertyName, &$assignedParamName, $classMethod) : ?int { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) use($propertyName, &$assignedParamName, $classMethod) : ?int { + if (!$node instanceof Assign) { return null; } if (!$this->nodeNameResolver->isName($node->var, $propertyName)) { return null; } - if ($node->expr instanceof \PhpParser\Node\Expr\MethodCall || $node->expr instanceof \PhpParser\Node\Expr\StaticCall) { + if ($node->expr instanceof MethodCall || $node->expr instanceof StaticCall) { return null; } - $parentClassMethod = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassMethod::class); + $parentClassMethod = $this->betterNodeFinder->findParentType($node, ClassMethod::class); if ($parentClassMethod !== $classMethod) { return null; } $assignedParamName = $this->nodeNameResolver->getName($node->expr); - return \PhpParser\NodeTraverser::STOP_TRAVERSAL; + return NodeTraverser::STOP_TRAVERSAL; }); /** @var string|null $assignedParamName */ if ($assignedParamName === null) { @@ -93,12 +93,12 @@ final class ClassMethodPropertyFetchManipulator * * @return Expr[] */ - public function findAssignsToPropertyName(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $propertyName) : array + public function findAssignsToPropertyName(ClassMethod $classMethod, string $propertyName) : array { $assignExprs = []; $paramNames = $this->functionLikeManipulator->resolveParamNames($classMethod); - $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (\PhpParser\Node $node) use($propertyName, &$assignExprs, $paramNames, $classMethod) : ?int { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) use($propertyName, &$assignExprs, $paramNames, $classMethod) : ?int { + if (!$node instanceof Assign) { return null; } if (!$this->nodeNameResolver->isName($node->var, $propertyName)) { @@ -108,7 +108,7 @@ final class ClassMethodPropertyFetchManipulator if ($this->nodeNameResolver->isNames($node->expr, $paramNames)) { return null; } - $parentClassMethod = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassMethod::class); + $parentClassMethod = $this->betterNodeFinder->findParentType($node, ClassMethod::class); if ($parentClassMethod !== $classMethod) { return null; } diff --git a/src/NodeManipulator/Dependency/DependencyClassMethodDecorator.php b/src/NodeManipulator/Dependency/DependencyClassMethodDecorator.php index 560d44031b7..3a2ff0696a6 100644 --- a/src/NodeManipulator/Dependency/DependencyClassMethodDecorator.php +++ b/src/NodeManipulator/Dependency/DependencyClassMethodDecorator.php @@ -48,7 +48,7 @@ final class DependencyClassMethodDecorator * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\Core\NodeAnalyzer\PromotedPropertyParamCleaner $promotedPropertyParamCleaner, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\PhpParser\AstResolver $astResolver, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeFactory $nodeFactory, PromotedPropertyParamCleaner $promotedPropertyParamCleaner, ReflectionProvider $reflectionProvider, AstResolver $astResolver, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver) { $this->nodeFactory = $nodeFactory; $this->promotedPropertyParamCleaner = $promotedPropertyParamCleaner; @@ -60,7 +60,7 @@ final class DependencyClassMethodDecorator /** * Add "parent::__construct(X, Y, Z)" where needed */ - public function decorateConstructorWithParentDependencies(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\ClassMethod $classMethod, \PHPStan\Analyser\Scope $scope) : void + public function decorateConstructorWithParentDependencies(Class_ $class, ClassMethod $classMethod, Scope $scope) : void { $className = (string) $this->nodeNameResolver->getName($class); if (!$this->reflectionProvider->hasClass($className)) { @@ -68,19 +68,19 @@ final class DependencyClassMethodDecorator } $classReflection = $this->reflectionProvider->getClass($className); foreach ($classReflection->getParents() as $parentClassReflection) { - if (!$parentClassReflection->hasMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if (!$parentClassReflection->hasMethod(MethodName::CONSTRUCT)) { continue; } - $constructorMethodReflection = $parentClassReflection->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT, $scope); + $constructorMethodReflection = $parentClassReflection->getMethod(MethodName::CONSTRUCT, $scope); $parentConstructorClassMethod = $this->astResolver->resolveClassMethodFromMethodReflection($constructorMethodReflection); - if (!$parentConstructorClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$parentConstructorClassMethod instanceof ClassMethod) { continue; } $this->completeParentConstructorBasedOnParentNode($classMethod, $parentConstructorClassMethod); break; } } - private function completeParentConstructorBasedOnParentNode(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Stmt\ClassMethod $parentClassMethod) : void + private function completeParentConstructorBasedOnParentNode(ClassMethod $classMethod, ClassMethod $parentClassMethod) : void { $paramsWithoutDefaultValue = []; foreach ($parentClassMethod->params as $param) { @@ -95,7 +95,7 @@ final class DependencyClassMethodDecorator $classMethod->params = \array_merge($cleanParams, $classMethod->params); } $staticCall = $this->nodeFactory->createParentConstructWithParams($cleanParams); - $classMethod->stmts[] = new \PhpParser\Node\Stmt\Expression($staticCall); + $classMethod->stmts[] = new Expression($staticCall); } /** * @param Param[] $params @@ -105,7 +105,7 @@ final class DependencyClassMethodDecorator { $cleanParams = $this->promotedPropertyParamCleaner->cleanFromFlags($params); // remove deep attributes to avoid bugs with nested tokens re-print - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($cleanParams, function (\PhpParser\Node $node) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($cleanParams, function (Node $node) { $node->setAttributes([]); return null; }); diff --git a/src/NodeManipulator/ForeachManipulator.php b/src/NodeManipulator/ForeachManipulator.php index 53509471054..f7a692096fb 100644 --- a/src/NodeManipulator/ForeachManipulator.php +++ b/src/NodeManipulator/ForeachManipulator.php @@ -11,13 +11,13 @@ final class ForeachManipulator /** * @param callable(Node $node, Foreach_ $foreach=): ?Node $callable */ - public function matchOnlyStmt(\PhpParser\Node\Stmt\Foreach_ $foreach, callable $callable) : ?\PhpParser\Node + public function matchOnlyStmt(Foreach_ $foreach, callable $callable) : ?Node { if (\count($foreach->stmts) !== 1) { return null; } $innerNode = $foreach->stmts[0]; - $innerNode = $innerNode instanceof \PhpParser\Node\Stmt\Expression ? $innerNode->expr : $innerNode; + $innerNode = $innerNode instanceof Expression ? $innerNode->expr : $innerNode; return $callable($innerNode, $foreach); } } diff --git a/src/NodeManipulator/FuncCallManipulator.php b/src/NodeManipulator/FuncCallManipulator.php index b30e17d68b0..1bd9d69d134 100644 --- a/src/NodeManipulator/FuncCallManipulator.php +++ b/src/NodeManipulator/FuncCallManipulator.php @@ -13,7 +13,7 @@ final class FuncCallManipulator * @var \Rector\Core\PhpParser\Node\Value\ValueResolver */ private $valueResolver; - public function __construct(\Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver) + public function __construct(ValueResolver $valueResolver) { $this->valueResolver = $valueResolver; } @@ -26,7 +26,7 @@ final class FuncCallManipulator $arguments = []; foreach ($compactFuncCalls as $compactFuncCall) { foreach ($compactFuncCall->args as $arg) { - if (!$arg instanceof \PhpParser\Node\Arg) { + if (!$arg instanceof Arg) { continue; } $value = $this->valueResolver->getValue($arg->value); diff --git a/src/NodeManipulator/FunctionLikeManipulator.php b/src/NodeManipulator/FunctionLikeManipulator.php index 1f6fd77cd5f..90176ab4afd 100644 --- a/src/NodeManipulator/FunctionLikeManipulator.php +++ b/src/NodeManipulator/FunctionLikeManipulator.php @@ -27,7 +27,7 @@ final class FunctionLikeManipulator * @var \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer */ private $propertyFetchAnalyzer; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver, PropertyFetchAnalyzer $propertyFetchAnalyzer) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->nodeNameResolver = $nodeNameResolver; @@ -36,15 +36,15 @@ final class FunctionLikeManipulator /** * @return string[] */ - public function getReturnedLocalPropertyNames(\PhpParser\Node\FunctionLike $functionLike) : array + public function getReturnedLocalPropertyNames(FunctionLike $functionLike) : array { // process only class methods - if ($functionLike instanceof \PhpParser\Node\Stmt\Function_) { + if ($functionLike instanceof Function_) { return []; } $returnedLocalPropertyNames = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($functionLike, function (\PhpParser\Node $node) use(&$returnedLocalPropertyNames) { - if (!$node instanceof \PhpParser\Node\Stmt\Return_) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($functionLike, function (Node $node) use(&$returnedLocalPropertyNames) { + if (!$node instanceof Return_) { return null; } if ($node->expr === null) { @@ -64,7 +64,7 @@ final class FunctionLikeManipulator /** * @return string[] */ - public function resolveParamNames(\PhpParser\Node\FunctionLike $functionLike) : array + public function resolveParamNames(FunctionLike $functionLike) : array { $paramNames = []; foreach ($functionLike->getParams() as $param) { diff --git a/src/NodeManipulator/IfManipulator.php b/src/NodeManipulator/IfManipulator.php index 6febc005b75..2a3792904f3 100644 --- a/src/NodeManipulator/IfManipulator.php +++ b/src/NodeManipulator/IfManipulator.php @@ -52,7 +52,7 @@ final class IfManipulator * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\NodeManipulator\StmtsManipulator $stmtsManipulator, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\EarlyReturn\NodeTransformer\ConditionInverter $conditionInverter, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver, \Rector\Core\NodeManipulator\StmtsManipulator $stmtsManipulator, ValueResolver $valueResolver, ConditionInverter $conditionInverter, NodeComparator $nodeComparator) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeNameResolver = $nodeNameResolver; @@ -68,16 +68,16 @@ final class IfManipulator * return $value; * } */ - public function matchIfNotNullReturnValue(\PhpParser\Node\Stmt\If_ $if) : ?\PhpParser\Node\Expr + public function matchIfNotNullReturnValue(If_ $if) : ?Expr { if (\count($if->stmts) !== 1) { return null; } $insideIfNode = $if->stmts[0]; - if (!$insideIfNode instanceof \PhpParser\Node\Stmt\Return_) { + if (!$insideIfNode instanceof Return_) { return null; } - if (!$if->cond instanceof \PhpParser\Node\Expr\BinaryOp\NotIdentical) { + if (!$if->cond instanceof NotIdentical) { return null; } return $this->matchComparedAndReturnedNode($if->cond, $insideIfNode); @@ -93,16 +93,16 @@ final class IfManipulator * return 53; * } */ - public function matchIfValueReturnValue(\PhpParser\Node\Stmt\If_ $if) : ?\PhpParser\Node\Expr + public function matchIfValueReturnValue(If_ $if) : ?Expr { if (\count($if->stmts) !== 1) { return null; } $insideIfStmt = $if->stmts[0]; - if (!$insideIfStmt instanceof \PhpParser\Node\Stmt\Return_) { + if (!$insideIfStmt instanceof Return_) { return null; } - if (!$if->cond instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { + if (!$if->cond instanceof Identical) { return null; } if ($this->nodeComparator->areNodesEqual($if->cond->left, $insideIfStmt->expr)) { @@ -116,7 +116,7 @@ final class IfManipulator /** * @return mixed[] */ - public function collectNestedIfsWithOnlyReturn(\PhpParser\Node\Stmt\If_ $if) : array + public function collectNestedIfsWithOnlyReturn(If_ $if) : array { $ifs = []; $currentIf = $if; @@ -128,14 +128,14 @@ final class IfManipulator if ($ifs === []) { return []; } - if (!$this->hasOnlyStmtOfType($currentIf, \PhpParser\Node\Stmt\Return_::class)) { + if (!$this->hasOnlyStmtOfType($currentIf, Return_::class)) { return []; } // last node is with the return value $ifs[] = $currentIf; return $ifs; } - public function isIfAndElseWithSameVariableAssignAsLastStmts(\PhpParser\Node\Stmt\If_ $if, \PhpParser\Node\Expr $desiredExpr) : bool + public function isIfAndElseWithSameVariableAssignAsLastStmts(If_ $if, Expr $desiredExpr) : bool { if ($if->else === null) { return \false; @@ -144,14 +144,14 @@ final class IfManipulator return \false; } $lastIfStmt = $this->stmtsManipulator->getUnwrappedLastStmt($if->stmts); - if (!$lastIfStmt instanceof \PhpParser\Node\Expr\Assign) { + if (!$lastIfStmt instanceof Assign) { return \false; } $lastElseStmt = $this->stmtsManipulator->getUnwrappedLastStmt($if->else->stmts); - if (!$lastElseStmt instanceof \PhpParser\Node\Expr\Assign) { + if (!$lastElseStmt instanceof Assign) { return \false; } - if (!$lastIfStmt->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$lastIfStmt->var instanceof Variable) { return \false; } if (!$this->nodeComparator->areNodesEqual($lastIfStmt->var, $lastElseStmt->var)) { @@ -165,12 +165,12 @@ final class IfManipulator * } else { * } */ - public function isIfOrIfElseWithFunctionCondition(\PhpParser\Node\Stmt\If_ $if, string $functionName) : bool + public function isIfOrIfElseWithFunctionCondition(If_ $if, string $functionName) : bool { if ((bool) $if->elseifs) { return \false; } - if (!$if->cond instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$if->cond instanceof FuncCall) { return \false; } return $this->nodeNameResolver->isName($if->cond, $functionName); @@ -178,13 +178,13 @@ final class IfManipulator /** * @return If_[] */ - public function collectNestedIfsWithNonBreaking(\PhpParser\Node\Stmt\Foreach_ $foreach) : array + public function collectNestedIfsWithNonBreaking(Foreach_ $foreach) : array { if (\count($foreach->stmts) !== 1) { return []; } $onlyForeachStmt = $foreach->stmts[0]; - if (!$onlyForeachStmt instanceof \PhpParser\Node\Stmt\If_) { + if (!$onlyForeachStmt instanceof If_) { return []; } $ifs = []; @@ -198,12 +198,12 @@ final class IfManipulator if (!$this->isIfWithoutElseAndElseIfs($currentIf)) { return []; } - $betterNodeFinderFindInstanceOf = $this->betterNodeFinder->findInstanceOf($currentIf->stmts, \PhpParser\Node\Stmt\Return_::class); + $betterNodeFinderFindInstanceOf = $this->betterNodeFinder->findInstanceOf($currentIf->stmts, Return_::class); if ($betterNodeFinderFindInstanceOf !== []) { return []; } /** @var Exit_[] $exits */ - $exits = $this->betterNodeFinder->findInstanceOf($currentIf->stmts, \PhpParser\Node\Expr\Exit_::class); + $exits = $this->betterNodeFinder->findInstanceOf($currentIf->stmts, Exit_::class); if ($exits !== []) { return []; } @@ -214,9 +214,9 @@ final class IfManipulator /** * @param class-string $className */ - public function isIfWithOnly(\PhpParser\Node $node, string $className) : bool + public function isIfWithOnly(Node $node, string $className) : bool { - if (!$node instanceof \PhpParser\Node\Stmt\If_) { + if (!$node instanceof If_) { return \false; } if (!$this->isIfWithoutElseAndElseIfs($node)) { @@ -224,27 +224,27 @@ final class IfManipulator } return $this->hasOnlyStmtOfType($node, $className); } - public function isIfWithOnlyOneStmt(\PhpParser\Node\Stmt\If_ $if) : bool + public function isIfWithOnlyOneStmt(If_ $if) : bool { return \count($if->stmts) === 1; } - public function isIfWithoutElseAndElseIfs(\PhpParser\Node\Stmt\If_ $if) : bool + public function isIfWithoutElseAndElseIfs(If_ $if) : bool { if ($if->else !== null) { return \false; } return !(bool) $if->elseifs; } - public function createIfNegation(\PhpParser\Node\Expr $expr, \PhpParser\Node\Stmt $stmt) : \PhpParser\Node\Stmt\If_ + public function createIfNegation(Expr $expr, Stmt $stmt) : If_ { $expr = $this->conditionInverter->createInvertedCondition($expr); return $this->createIfStmt($expr, $stmt); } - public function createIfStmt(\PhpParser\Node\Expr $expr, \PhpParser\Node\Stmt $stmt) : \PhpParser\Node\Stmt\If_ + public function createIfStmt(Expr $expr, Stmt $stmt) : If_ { - return new \PhpParser\Node\Stmt\If_($expr, ['stmts' => [$stmt]]); + return new If_($expr, ['stmts' => [$stmt]]); } - private function matchComparedAndReturnedNode(\PhpParser\Node\Expr\BinaryOp\NotIdentical $notIdentical, \PhpParser\Node\Stmt\Return_ $return) : ?\PhpParser\Node\Expr + private function matchComparedAndReturnedNode(NotIdentical $notIdentical, Return_ $return) : ?Expr { if ($this->nodeComparator->areNodesEqual($notIdentical->left, $return->expr) && $this->valueResolver->isNull($notIdentical->right)) { return $notIdentical->left; @@ -257,17 +257,17 @@ final class IfManipulator } return null; } - private function isIfWithOnlyStmtIf(\PhpParser\Node\Stmt\If_ $if) : bool + private function isIfWithOnlyStmtIf(If_ $if) : bool { if (!$this->isIfWithoutElseAndElseIfs($if)) { return \false; } - return $this->hasOnlyStmtOfType($if, \PhpParser\Node\Stmt\If_::class); + return $this->hasOnlyStmtOfType($if, If_::class); } /** * @param class-string $desiredType */ - private function hasOnlyStmtOfType(\PhpParser\Node\Stmt\If_ $if, string $desiredType) : bool + private function hasOnlyStmtOfType(If_ $if, string $desiredType) : bool { $stmts = $if->stmts; if (\count($stmts) !== 1) { diff --git a/src/NodeManipulator/MagicPropertyFetchAnalyzer.php b/src/NodeManipulator/MagicPropertyFetchAnalyzer.php index 0bed3f02f19..2ec54807e2d 100644 --- a/src/NodeManipulator/MagicPropertyFetchAnalyzer.php +++ b/src/NodeManipulator/MagicPropertyFetchAnalyzer.php @@ -37,7 +37,7 @@ final class MagicPropertyFetchAnalyzer * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver, ReflectionProvider $reflectionProvider) { $this->nodeNameResolver = $nodeNameResolver; $this->nodeTypeResolver = $nodeTypeResolver; @@ -46,13 +46,13 @@ final class MagicPropertyFetchAnalyzer /** * @param \PhpParser\Node\Expr\PropertyFetch|\PhpParser\Node\Expr\StaticPropertyFetch $expr */ - public function isMagicOnType($expr, \PHPStan\Type\Type $type) : bool + public function isMagicOnType($expr, Type $type) : bool { $varNodeType = $this->nodeTypeResolver->getType($expr); - if ($varNodeType instanceof \PHPStan\Type\ErrorType) { + if ($varNodeType instanceof ErrorType) { return \true; } - if ($varNodeType instanceof \PHPStan\Type\MixedType) { + if ($varNodeType instanceof MixedType) { return \false; } if ($varNodeType->isSuperTypeOf($type)->yes()) { @@ -69,16 +69,16 @@ final class MagicPropertyFetchAnalyzer */ private function hasPublicProperty($expr, string $propertyName) : bool { - $scope = $expr->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $scope = $expr->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { + throw new ShouldNotHappenException(); } - if ($expr instanceof \PhpParser\Node\Expr\PropertyFetch) { + if ($expr instanceof PropertyFetch) { $propertyFetchType = $scope->getType($expr->var); } else { $propertyFetchType = $this->nodeTypeResolver->getType($expr->class); } - if (!$propertyFetchType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$propertyFetchType instanceof TypeWithClassName) { return \false; } $propertyFetchType = $propertyFetchType->getClassName(); diff --git a/src/NodeManipulator/MethodCallManipulator.php b/src/NodeManipulator/MethodCallManipulator.php index 01d118ed265..b6d04aa68ba 100644 --- a/src/NodeManipulator/MethodCallManipulator.php +++ b/src/NodeManipulator/MethodCallManipulator.php @@ -27,7 +27,7 @@ final class MethodCallManipulator * @var \Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer */ private $fluentChainMethodCallNodeAnalyzer; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer $fluentChainMethodCallNodeAnalyzer) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver, FluentChainMethodCallNodeAnalyzer $fluentChainMethodCallNodeAnalyzer) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeNameResolver = $nodeNameResolver; @@ -36,7 +36,7 @@ final class MethodCallManipulator /** * @return string[] */ - public function findMethodCallNamesOnVariable(\PhpParser\Node\Expr\Variable $variable) : array + public function findMethodCallNamesOnVariable(Variable $variable) : array { $methodCallsOnVariable = $this->findMethodCallsOnVariable($variable); $methodCallNamesOnVariable = []; @@ -52,24 +52,24 @@ final class MethodCallManipulator /** * @return MethodCall[] */ - public function findMethodCallsOnVariable(\PhpParser\Node\Expr\Variable $variable) : array + public function findMethodCallsOnVariable(Variable $variable) : array { // get scope node, e.g. parent function call, method call or anonymous function - $classMethod = $this->betterNodeFinder->findParentType($variable, \PhpParser\Node\Stmt\ClassMethod::class); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $this->betterNodeFinder->findParentType($variable, ClassMethod::class); + if (!$classMethod instanceof ClassMethod) { return []; } $variableName = $this->nodeNameResolver->getName($variable); if ($variableName === null) { return []; } - return $this->betterNodeFinder->find((array) $classMethod->stmts, function (\PhpParser\Node $node) use($variableName) : bool { - if (!$node instanceof \PhpParser\Node\Expr\MethodCall) { + return $this->betterNodeFinder->find((array) $classMethod->stmts, function (Node $node) use($variableName) : bool { + if (!$node instanceof MethodCall) { return \false; } // cover fluent interfaces too $callerNode = $this->fluentChainMethodCallNodeAnalyzer->resolveRootExpr($node); - if (!$callerNode instanceof \PhpParser\Node\Expr\Variable) { + if (!$callerNode instanceof Variable) { return \false; } return $this->nodeNameResolver->isName($callerNode, $variableName); diff --git a/src/NodeManipulator/PropertyFetchAssignManipulator.php b/src/NodeManipulator/PropertyFetchAssignManipulator.php index 87cc376524f..61209b185f4 100644 --- a/src/NodeManipulator/PropertyFetchAssignManipulator.php +++ b/src/NodeManipulator/PropertyFetchAssignManipulator.php @@ -38,39 +38,39 @@ final class PropertyFetchAssignManipulator * @var \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer */ private $propertyFetchAnalyzer; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder, PropertyFetchAnalyzer $propertyFetchAnalyzer) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; } - public function isAssignedMultipleTimesInConstructor(\PhpParser\Node\Stmt\Property $property) : bool + public function isAssignedMultipleTimesInConstructor(Property $property) : bool { - $classLike = $this->betterNodeFinder->findParentType($property, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($property, ClassLike::class); + if (!$classLike instanceof ClassLike) { return \false; } - $classMethod = $classLike->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $classLike->getMethod(MethodName::CONSTRUCT); + if (!$classMethod instanceof ClassMethod) { return \false; } $count = 0; $propertyName = $this->nodeNameResolver->getName($property); - $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->getStmts(), function (\PhpParser\Node $node) use($propertyName, $classLike, &$count) : ?int { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->getStmts(), function (Node $node) use($propertyName, $classLike, &$count) : ?int { + if (!$node instanceof Assign) { return null; } if (!$this->propertyFetchAnalyzer->isLocalPropertyFetchName($node->var, $propertyName)) { return null; } - $parentClassLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassLike::class); + $parentClassLike = $this->betterNodeFinder->findParentType($node, ClassLike::class); if ($parentClassLike !== $classLike) { return null; } ++$count; if ($count === 2) { - return \PhpParser\NodeTraverser::STOP_TRAVERSAL; + return NodeTraverser::STOP_TRAVERSAL; } return null; }); @@ -79,11 +79,11 @@ final class PropertyFetchAssignManipulator /** * @return string[] */ - public function getPropertyNamesOfAssignOfVariable(\PhpParser\Node $node, string $paramName) : array + public function getPropertyNamesOfAssignOfVariable(Node $node, string $paramName) : array { $propertyNames = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($node, function (\PhpParser\Node $node) use($paramName, &$propertyNames) { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($node, function (Node $node) use($paramName, &$propertyNames) { + if (!$node instanceof Assign) { return null; } if (!$this->isVariableAssignToThisPropertyFetch($node, $paramName)) { @@ -102,15 +102,15 @@ final class PropertyFetchAssignManipulator * Matches: * "$this->someValue = $;" */ - private function isVariableAssignToThisPropertyFetch(\PhpParser\Node\Expr\Assign $assign, string $variableName) : bool + private function isVariableAssignToThisPropertyFetch(Assign $assign, string $variableName) : bool { - if (!$assign->expr instanceof \PhpParser\Node\Expr\Variable) { + if (!$assign->expr instanceof Variable) { return \false; } if (!$this->nodeNameResolver->isName($assign->expr, $variableName)) { return \false; } - if (!$assign->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$assign->var instanceof PropertyFetch) { return \false; } $propertyFetch = $assign->var; diff --git a/src/NodeManipulator/PropertyManipulator.php b/src/NodeManipulator/PropertyManipulator.php index e0729732542..08dccc0b48a 100644 --- a/src/NodeManipulator/PropertyManipulator.php +++ b/src/NodeManipulator/PropertyManipulator.php @@ -133,7 +133,7 @@ final class PropertyManipulator * @var \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer */ private $propertyFetchAnalyzer; - public function __construct(\Rector\Core\NodeManipulator\AssignManipulator $assignManipulator, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\ReadWrite\Guard\VariableToConstantGuard $variableToConstantGuard, \Rector\ReadWrite\NodeAnalyzer\ReadWritePropertyAnalyzer $readWritePropertyAnalyzer, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \RectorPrefix20220607\Symplify\PackageBuilder\Php\TypeChecker $typeChecker, \Rector\Core\PhpParser\NodeFinder\PropertyFetchFinder $propertyFetchFinder, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer $phpAttributeAnalyzer, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\Php80\NodeAnalyzer\PromotedPropertyResolver $promotedPropertyResolver, \Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector $constructorAssignDetector, \Rector\Core\PhpParser\AstResolver $astResolver, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer) + public function __construct(\Rector\Core\NodeManipulator\AssignManipulator $assignManipulator, BetterNodeFinder $betterNodeFinder, VariableToConstantGuard $variableToConstantGuard, ReadWritePropertyAnalyzer $readWritePropertyAnalyzer, PhpDocInfoFactory $phpDocInfoFactory, TypeChecker $typeChecker, PropertyFetchFinder $propertyFetchFinder, ReflectionResolver $reflectionResolver, NodeNameResolver $nodeNameResolver, PhpAttributeAnalyzer $phpAttributeAnalyzer, NodeTypeResolver $nodeTypeResolver, PromotedPropertyResolver $promotedPropertyResolver, ConstructorAssignDetector $constructorAssignDetector, AstResolver $astResolver, PropertyFetchAnalyzer $propertyFetchAnalyzer) { $this->assignManipulator = $assignManipulator; $this->betterNodeFinder = $betterNodeFinder; @@ -154,7 +154,7 @@ final class PropertyManipulator /** * @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $propertyOrPromotedParam */ - public function isAllowedReadOnly($propertyOrPromotedParam, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : bool + public function isAllowedReadOnly($propertyOrPromotedParam, PhpDocInfo $phpDocInfo) : bool { if ($phpDocInfo->hasByAnnotationClasses(self::ALLOWED_READONLY_ANNOTATION_CLASS_OR_ATTRIBUTES)) { return \true; @@ -164,7 +164,7 @@ final class PropertyManipulator /** * @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $propertyOrPromotedParam */ - public function isPropertyUsedInReadContext(\PhpParser\Node\Stmt\Class_ $class, $propertyOrPromotedParam) : bool + public function isPropertyUsedInReadContext(Class_ $class, $propertyOrPromotedParam) : bool { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($propertyOrPromotedParam); if ($this->isAllowedReadOnly($propertyOrPromotedParam, $phpDocInfo)) { @@ -177,18 +177,18 @@ final class PropertyManipulator } } // has classLike $this->$variable call? - $classLike = $this->betterNodeFinder->findParentType($propertyOrPromotedParam, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($propertyOrPromotedParam, ClassLike::class); + if (!$classLike instanceof ClassLike) { return \false; } - return (bool) $this->betterNodeFinder->findFirst($classLike->stmts, function (\PhpParser\Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Expr\PropertyFetch) { + return (bool) $this->betterNodeFinder->findFirst($classLike->stmts, function (Node $node) : bool { + if (!$node instanceof PropertyFetch) { return \false; } if (!$this->readWritePropertyAnalyzer->isRead($node)) { return \false; } - return $node->name instanceof \PhpParser\Node\Expr; + return $node->name instanceof Expr; }); } /** @@ -196,9 +196,9 @@ final class PropertyManipulator */ public function isPropertyChangeableExceptConstructor($propertyOrParam) : bool { - $class = $this->betterNodeFinder->findParentType($propertyOrParam, \PhpParser\Node\Stmt\Class_::class); + $class = $this->betterNodeFinder->findParentType($propertyOrParam, Class_::class); // does not has parent type ClassLike? Possibly parent is changed by other rule - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + if (!$class instanceof Class_) { return \true; } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($class); @@ -215,21 +215,21 @@ final class PropertyManipulator } // skip for constructor? it is allowed to set value in constructor method $propertyName = (string) $this->nodeNameResolver->getName($propertyFetch); - $classMethod = $this->betterNodeFinder->findParentType($propertyFetch, \PhpParser\Node\Stmt\ClassMethod::class); + $classMethod = $this->betterNodeFinder->findParentType($propertyFetch, ClassMethod::class); if ($this->isPropertyAssignedOnlyInConstructor($class, $propertyName, $classMethod)) { continue; } if ($this->assignManipulator->isLeftPartOfAssign($propertyFetch)) { return \true; } - $isInUnset = (bool) $this->betterNodeFinder->findParentType($propertyFetch, \PhpParser\Node\Stmt\Unset_::class); + $isInUnset = (bool) $this->betterNodeFinder->findParentType($propertyFetch, Unset_::class); if ($isInUnset) { return \true; } } return \false; } - public function isPropertyChangeable(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\Property $property) : bool + public function isPropertyChangeable(Class_ $class, Property $property) : bool { $propertyFetches = $this->propertyFetchFinder->findPrivatePropertyFetches($class, $property); foreach ($propertyFetches as $propertyFetch) { @@ -242,7 +242,7 @@ final class PropertyManipulator } return \false; } - public function resolveExistingClassPropertyNameByType(\PhpParser\Node\Stmt\Class_ $class, \PHPStan\Type\Type $type) : ?string + public function resolveExistingClassPropertyNameByType(Class_ $class, Type $type) : ?string { foreach ($class->getProperties() as $property) { $propertyType = $this->nodeTypeResolver->getType($property); @@ -261,11 +261,11 @@ final class PropertyManipulator } return null; } - public function isUsedByTrait(\PHPStan\Reflection\ClassReflection $classReflection, string $propertyName) : bool + public function isUsedByTrait(ClassReflection $classReflection, string $propertyName) : bool { foreach ($classReflection->getTraits() as $traitUse) { $trait = $this->astResolver->resolveClassFromName($traitUse->getName()); - if (!$trait instanceof \PhpParser\Node\Stmt\Trait_) { + if (!$trait instanceof Trait_) { continue; } if ($this->propertyFetchAnalyzer->containsLocalPropertyFetchName($trait, $propertyName)) { @@ -274,13 +274,13 @@ final class PropertyManipulator } return \false; } - private function isPropertyAssignedOnlyInConstructor(\PhpParser\Node\Stmt\Class_ $class, string $propertyName, ?\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function isPropertyAssignedOnlyInConstructor(Class_ $class, string $propertyName, ?ClassMethod $classMethod) : bool { - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$classMethod instanceof ClassMethod) { return \false; } // there is property unset in Test class, so only check on __construct - if (!$this->nodeNameResolver->isName($classMethod->name, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if (!$this->nodeNameResolver->isName($classMethod->name, MethodName::CONSTRUCT)) { return \false; } return $this->constructorAssignDetector->isPropertyAssigned($class, $propertyName); @@ -290,27 +290,27 @@ final class PropertyManipulator */ private function isChangeableContext($propertyFetch) : bool { - $parent = $propertyFetch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node) { + $parent = $propertyFetch->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Node) { return \false; } - if ($this->typeChecker->isInstanceOf($parent, [\PhpParser\Node\Expr\PreInc::class, \PhpParser\Node\Expr\PreDec::class, \PhpParser\Node\Expr\PostInc::class, \PhpParser\Node\Expr\PostDec::class])) { - $parent = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + if ($this->typeChecker->isInstanceOf($parent, [PreInc::class, PreDec::class, PostInc::class, PostDec::class])) { + $parent = $parent->getAttribute(AttributeKey::PARENT_NODE); } - if (!$parent instanceof \PhpParser\Node) { + if (!$parent instanceof Node) { return \false; } - if ($parent instanceof \PhpParser\Node\Arg) { + if ($parent instanceof Arg) { $readArg = $this->variableToConstantGuard->isReadArg($parent); if (!$readArg) { return \true; } - $caller = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($caller instanceof \PhpParser\Node\Expr\MethodCall || $caller instanceof \PhpParser\Node\Expr\StaticCall) { + $caller = $parent->getAttribute(AttributeKey::PARENT_NODE); + if ($caller instanceof MethodCall || $caller instanceof StaticCall) { return $this->isFoundByRefParam($caller); } } - if ($parent instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if ($parent instanceof ArrayDimFetch) { return !$this->readWritePropertyAnalyzer->isRead($propertyFetch); } return \false; @@ -324,7 +324,7 @@ final class PropertyManipulator if ($functionLikeReflection === null) { return \false; } - $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($functionLikeReflection->getVariants()); + $parametersAcceptor = ParametersAcceptorSelector::selectSingle($functionLikeReflection->getVariants()); foreach ($parametersAcceptor->getParameters() as $parameterReflection) { if ($parameterReflection->passedByReference()->yes()) { return \true; diff --git a/src/NodeManipulator/StmtsManipulator.php b/src/NodeManipulator/StmtsManipulator.php index 96e92687882..b8ec67cdfa4 100644 --- a/src/NodeManipulator/StmtsManipulator.php +++ b/src/NodeManipulator/StmtsManipulator.php @@ -21,7 +21,7 @@ final class StmtsManipulator * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeComparator $nodeComparator) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->nodeComparator = $nodeComparator; @@ -29,12 +29,12 @@ final class StmtsManipulator /** * @param Stmt[] $stmts */ - public function getUnwrappedLastStmt(array $stmts) : ?\PhpParser\Node + public function getUnwrappedLastStmt(array $stmts) : ?Node { \end($stmts); $lastStmtKey = \key($stmts); $lastStmt = $stmts[$lastStmtKey]; - if ($lastStmt instanceof \PhpParser\Node\Stmt\Expression) { + if ($lastStmt instanceof Expression) { return $lastStmt->expr; } return $lastStmt; @@ -43,9 +43,9 @@ final class StmtsManipulator * @param Stmt[] $stmts * @return Stmt[] */ - public function filterOutExistingStmts(\PhpParser\Node\Stmt\ClassMethod $classMethod, array $stmts) : array + public function filterOutExistingStmts(ClassMethod $classMethod, array $stmts) : array { - $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (\PhpParser\Node $node) use(&$stmts) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) use(&$stmts) { foreach ($stmts as $key => $assign) { if (!$this->nodeComparator->areNodesEqual($node, $assign)) { continue; diff --git a/src/NodeManipulator/VariableManipulator.php b/src/NodeManipulator/VariableManipulator.php index fce0701e73c..fe0b2a91760 100644 --- a/src/NodeManipulator/VariableManipulator.php +++ b/src/NodeManipulator/VariableManipulator.php @@ -61,7 +61,7 @@ final class VariableManipulator * @var \Rector\Core\NodeAnalyzer\ExprAnalyzer */ private $exprAnalyzer; - public function __construct(\Rector\Core\NodeManipulator\AssignManipulator $assignManipulator, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\ReadWrite\Guard\VariableToConstantGuard $variableToConstantGuard, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\NodeAnalyzer\ExprAnalyzer $exprAnalyzer) + public function __construct(\Rector\Core\NodeManipulator\AssignManipulator $assignManipulator, BetterNodeFinder $betterNodeFinder, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver, VariableToConstantGuard $variableToConstantGuard, NodeComparator $nodeComparator, ExprAnalyzer $exprAnalyzer) { $this->assignManipulator = $assignManipulator; $this->betterNodeFinder = $betterNodeFinder; @@ -74,19 +74,19 @@ final class VariableManipulator /** * @return Assign[] */ - public function collectScalarOrArrayAssignsOfVariable(\PhpParser\Node\Stmt\ClassMethod $classMethod) : array + public function collectScalarOrArrayAssignsOfVariable(ClassMethod $classMethod) : array { - $currentClass = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\Class_::class); - if (!$currentClass instanceof \PhpParser\Node\Stmt\Class_) { + $currentClass = $this->betterNodeFinder->findParentType($classMethod, Class_::class); + if (!$currentClass instanceof Class_) { return []; } $currentClassName = (string) $this->nodeNameResolver->getName($currentClass); $assignsOfArrayToVariable = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->getStmts(), function (\PhpParser\Node $node) use(&$assignsOfArrayToVariable, $currentClass, $currentClassName) { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->getStmts(), function (Node $node) use(&$assignsOfArrayToVariable, $currentClass, $currentClassName) { + if (!$node instanceof Assign) { return null; } - if (!$node->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$node->var instanceof Variable) { return null; } if ($this->exprAnalyzer->isDynamicExpr($node->expr)) { @@ -98,10 +98,10 @@ final class VariableManipulator if ($this->isTestCaseExpectedVariable($node->var)) { return null; } - if ($node->expr instanceof \PhpParser\Node\Expr\ConstFetch) { + if ($node->expr instanceof ConstFetch) { return null; } - if ($node->expr instanceof \PhpParser\Node\Expr\ClassConstFetch && $this->isOutsideClass($node->expr, $currentClass, $currentClassName)) { + if ($node->expr instanceof ClassConstFetch && $this->isOutsideClass($node->expr, $currentClass, $currentClassName)) { return null; } $assignsOfArrayToVariable[] = $node; @@ -112,13 +112,13 @@ final class VariableManipulator * @param Assign[] $assignsOfArrayToVariable * @return Assign[] */ - public function filterOutChangedVariables(array $assignsOfArrayToVariable, \PhpParser\Node\Stmt\ClassMethod $classMethod) : array + public function filterOutChangedVariables(array $assignsOfArrayToVariable, ClassMethod $classMethod) : array { - return \array_filter($assignsOfArrayToVariable, function (\PhpParser\Node\Expr\Assign $assign) use($classMethod) : bool { + return \array_filter($assignsOfArrayToVariable, function (Assign $assign) use($classMethod) : bool { return $this->isReadOnlyVariable($classMethod, $assign); }); } - private function isOutsideClass(\PhpParser\Node\Expr\ClassConstFetch $classConstFetch, \PhpParser\Node\Stmt\Class_ $currentClass, string $currentClassName) : bool + private function isOutsideClass(ClassConstFetch $classConstFetch, Class_ $currentClass, string $currentClassName) : bool { /** * Dynamic class already checked on $this->exprAnalyzer->isDynamicValue() early @@ -126,20 +126,20 @@ final class VariableManipulator */ $class = $classConstFetch->class; if ($this->nodeNameResolver->isName($class, 'self')) { - return $currentClass->extends instanceof \PhpParser\Node\Name\FullyQualified; + return $currentClass->extends instanceof FullyQualified; } return !$this->nodeNameResolver->isName($class, $currentClassName); } - private function hasEncapsedStringPart(\PhpParser\Node\Expr $expr) : bool + private function hasEncapsedStringPart(Expr $expr) : bool { - return (bool) $this->betterNodeFinder->findFirst($expr, function (\PhpParser\Node $subNode) : bool { - return $subNode instanceof \PhpParser\Node\Scalar\Encapsed || $subNode instanceof \PhpParser\Node\Scalar\EncapsedStringPart; + return (bool) $this->betterNodeFinder->findFirst($expr, function (Node $subNode) : bool { + return $subNode instanceof Encapsed || $subNode instanceof EncapsedStringPart; }); } - private function isTestCaseExpectedVariable(\PhpParser\Node\Expr\Variable $variable) : bool + private function isTestCaseExpectedVariable(Variable $variable) : bool { - $classLike = $this->betterNodeFinder->findParentType($variable, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($variable, ClassLike::class); + if (!$classLike instanceof ClassLike) { return \false; } $className = (string) $this->nodeNameResolver->getName($classLike); @@ -152,15 +152,15 @@ final class VariableManipulator * Inspiration * @see \Rector\Core\NodeManipulator\PropertyManipulator::isPropertyUsedInReadContext() */ - private function isReadOnlyVariable(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Expr\Assign $assign) : bool + private function isReadOnlyVariable(ClassMethod $classMethod, Assign $assign) : bool { - if (!$assign->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$assign->var instanceof Variable) { return \false; } $variableUsages = $this->collectVariableUsages($classMethod, $assign->var, $assign); foreach ($variableUsages as $variableUsage) { - $parent = $variableUsage->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\Arg && !$this->variableToConstantGuard->isReadArg($parent)) { + $parent = $variableUsage->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof Arg && !$this->variableToConstantGuard->isReadArg($parent)) { return \false; } if (!$this->assignManipulator->isLeftPartOfAssign($variableUsage)) { @@ -173,14 +173,14 @@ final class VariableManipulator /** * @return Variable[] */ - private function collectVariableUsages(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Expr\Variable $variable, \PhpParser\Node\Expr\Assign $assign) : array + private function collectVariableUsages(ClassMethod $classMethod, Variable $variable, Assign $assign) : array { - return $this->betterNodeFinder->find((array) $classMethod->getStmts(), function (\PhpParser\Node $node) use($variable, $assign) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + return $this->betterNodeFinder->find((array) $classMethod->getStmts(), function (Node $node) use($variable, $assign) : bool { + if (!$node instanceof Variable) { return \false; } // skip initialization - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); if ($parentNode === $assign) { return \false; } diff --git a/src/NonPhpFile/NonPhpFileProcessor.php b/src/NonPhpFile/NonPhpFileProcessor.php index 279b1ec3424..ab9045ac581 100644 --- a/src/NonPhpFile/NonPhpFileProcessor.php +++ b/src/NonPhpFile/NonPhpFileProcessor.php @@ -12,7 +12,7 @@ use Rector\Core\ValueObject\Error\SystemError; use Rector\Core\ValueObject\Reporting\FileDiff; use Rector\Core\ValueObject\StaticNonPhpFileSuffixes; use Rector\Parallel\ValueObject\Bridge; -final class NonPhpFileProcessor implements \Rector\Core\Contract\Processor\FileProcessorInterface +final class NonPhpFileProcessor implements FileProcessorInterface { /** * @var NonPhpRectorInterface[] @@ -27,7 +27,7 @@ final class NonPhpFileProcessor implements \Rector\Core\Contract\Processor\FileP /** * @param NonPhpRectorInterface[] $nonPhpRectors */ - public function __construct(array $nonPhpRectors, \Rector\ChangesReporting\ValueObjectFactory\FileDiffFactory $fileDiffFactory) + public function __construct(array $nonPhpRectors, FileDiffFactory $fileDiffFactory) { $this->nonPhpRectors = $nonPhpRectors; $this->fileDiffFactory = $fileDiffFactory; @@ -35,9 +35,9 @@ final class NonPhpFileProcessor implements \Rector\Core\Contract\Processor\FileP /** * @return array{system_errors: SystemError[], file_diffs: FileDiff[]} */ - public function process(\Rector\Core\ValueObject\Application\File $file, \Rector\Core\ValueObject\Configuration $configuration) : array + public function process(File $file, Configuration $configuration) : array { - $systemErrorsAndFileDiffs = [\Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS => [], \Rector\Parallel\ValueObject\Bridge::FILE_DIFFS => []]; + $systemErrorsAndFileDiffs = [Bridge::SYSTEM_ERRORS => [], Bridge::FILE_DIFFS => []]; if ($this->nonPhpRectors === []) { return $systemErrorsAndFileDiffs; } @@ -52,11 +52,11 @@ final class NonPhpFileProcessor implements \Rector\Core\Contract\Processor\FileP } if ($oldFileContent !== $newFileContent) { $fileDiff = $this->fileDiffFactory->createFileDiff($file, $oldFileContent, $newFileContent); - $systemErrorsAndFileDiffs[\Rector\Parallel\ValueObject\Bridge::FILE_DIFFS][] = $fileDiff; + $systemErrorsAndFileDiffs[Bridge::FILE_DIFFS][] = $fileDiff; } return $systemErrorsAndFileDiffs; } - public function supports(\Rector\Core\ValueObject\Application\File $file, \Rector\Core\ValueObject\Configuration $configuration) : bool + public function supports(File $file, Configuration $configuration) : bool { $smartFileInfo = $file->getSmartFileInfo(); // early assign to variable for increase performance @@ -75,6 +75,6 @@ final class NonPhpFileProcessor implements \Rector\Core\Contract\Processor\FileP */ public function getSupportedFileExtensions() : array { - return \Rector\Core\ValueObject\StaticNonPhpFileSuffixes::SUFFIXES; + return StaticNonPhpFileSuffixes::SUFFIXES; } } diff --git a/src/NonPhpFile/Rector/RenameClassNonPhpRector.php b/src/NonPhpFile/Rector/RenameClassNonPhpRector.php index d50ab21e672..95eba964477 100644 --- a/src/NonPhpFile/Rector/RenameClassNonPhpRector.php +++ b/src/NonPhpFile/Rector/RenameClassNonPhpRector.php @@ -8,11 +8,11 @@ use Rector\Core\Configuration\RenamedClassesDataCollector; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Contract\Rector\NonPhpRectorInterface; use Rector\PostRector\Contract\Rector\ComplementaryRectorInterface; -use Symplify\RuleDocGenerator\Contract\ConfigurableRuleInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\Contract\ConfigurableRuleInterface; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; -final class RenameClassNonPhpRector implements \Rector\Core\Contract\Rector\NonPhpRectorInterface, \Symplify\RuleDocGenerator\Contract\ConfigurableRuleInterface, \Rector\Core\Contract\Rector\ConfigurableRectorInterface, \Rector\PostRector\Contract\Rector\ComplementaryRectorInterface +final class RenameClassNonPhpRector implements NonPhpRectorInterface, ConfigurableRuleInterface, ConfigurableRectorInterface, ComplementaryRectorInterface { /** * @see https://regex101.com/r/HKUFJD/7 @@ -35,13 +35,13 @@ final class RenameClassNonPhpRector implements \Rector\Core\Contract\Rector\NonP * @var \Rector\Core\Configuration\RenamedClassesDataCollector */ private $renamedClassesDataCollector; - public function __construct(\Rector\Core\Configuration\RenamedClassesDataCollector $renamedClassesDataCollector) + public function __construct(RenamedClassesDataCollector $renamedClassesDataCollector) { $this->renamedClassesDataCollector = $renamedClassesDataCollector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change class names and just renamed classes in non-PHP files, NEON, YAML, TWIG, LATTE, blade etc. mostly with regular expressions', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change class names and just renamed classes in non-PHP files, NEON, YAML, TWIG, LATTE, blade etc. mostly with regular expressions', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' services: - SomeOldClass CODE_SAMPLE @@ -62,8 +62,8 @@ CODE_SAMPLE public function configure(array $configuration) : void { $renameClasses = $configuration; - \RectorPrefix20220607\Webmozart\Assert\Assert::allString(\array_keys($renameClasses)); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($renameClasses); + Assert::allString(\array_keys($renameClasses)); + Assert::allString($renameClasses); $this->renameClasses = $renameClasses; } /** @@ -75,7 +75,7 @@ CODE_SAMPLE foreach ($classRenames as $oldClass => $newClass) { // the old class is without slashes, it can make mess as similar to a word in the text, so we have to be more strict about it $oldClassRegex = $this->createOldClassRegex($oldClass); - $newContent = \RectorPrefix20220607\Nette\Utils\Strings::replace($newContent, $oldClassRegex, function (array $match) use($newClass) : string { + $newContent = Strings::replace($newContent, $oldClassRegex, function (array $match) use($newClass) : string { return ($match['extra_space'] ?? '') . $newClass; }); } diff --git a/src/PHPStan/Reflection/TypeToCallReflectionResolver/ClosureTypeToCallReflectionResolver.php b/src/PHPStan/Reflection/TypeToCallReflectionResolver/ClosureTypeToCallReflectionResolver.php index 7b60887b724..3cdee730cbb 100644 --- a/src/PHPStan/Reflection/TypeToCallReflectionResolver/ClosureTypeToCallReflectionResolver.php +++ b/src/PHPStan/Reflection/TypeToCallReflectionResolver/ClosureTypeToCallReflectionResolver.php @@ -12,17 +12,17 @@ use Rector\Core\Contract\PHPStan\Reflection\TypeToCallReflectionResolver\TypeToC /** * @implements TypeToCallReflectionResolverInterface */ -final class ClosureTypeToCallReflectionResolver implements \Rector\Core\Contract\PHPStan\Reflection\TypeToCallReflectionResolver\TypeToCallReflectionResolverInterface +final class ClosureTypeToCallReflectionResolver implements TypeToCallReflectionResolverInterface { - public function supports(\PHPStan\Type\Type $type) : bool + public function supports(Type $type) : bool { - return $type instanceof \PHPStan\Type\ClosureType; + return $type instanceof ClosureType; } /** * @param ClosureType $type */ - public function resolve(\PHPStan\Type\Type $type, \PHPStan\Analyser\Scope $scope) : \PHPStan\Reflection\Native\NativeFunctionReflection + public function resolve(Type $type, Scope $scope) : NativeFunctionReflection { - return new \PHPStan\Reflection\Native\NativeFunctionReflection('{closure}', $type->getCallableParametersAcceptors($scope), null, \PHPStan\TrinaryLogic::createMaybe(), \false); + return new NativeFunctionReflection('{closure}', $type->getCallableParametersAcceptors($scope), null, TrinaryLogic::createMaybe(), \false); } } diff --git a/src/PHPStan/Reflection/TypeToCallReflectionResolver/ConstantArrayTypeToCallReflectionResolver.php b/src/PHPStan/Reflection/TypeToCallReflectionResolver/ConstantArrayTypeToCallReflectionResolver.php index 18ece141b32..63e2dbec1ca 100644 --- a/src/PHPStan/Reflection/TypeToCallReflectionResolver/ConstantArrayTypeToCallReflectionResolver.php +++ b/src/PHPStan/Reflection/TypeToCallReflectionResolver/ConstantArrayTypeToCallReflectionResolver.php @@ -19,28 +19,28 @@ use Rector\Core\Contract\PHPStan\Reflection\TypeToCallReflectionResolver\TypeToC * * @implements TypeToCallReflectionResolverInterface */ -final class ConstantArrayTypeToCallReflectionResolver implements \Rector\Core\Contract\PHPStan\Reflection\TypeToCallReflectionResolver\TypeToCallReflectionResolverInterface +final class ConstantArrayTypeToCallReflectionResolver implements TypeToCallReflectionResolverInterface { /** * @readonly * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ReflectionProvider $reflectionProvider) { $this->reflectionProvider = $reflectionProvider; } - public function supports(\PHPStan\Type\Type $type) : bool + public function supports(Type $type) : bool { - return $type instanceof \PHPStan\Type\Constant\ConstantArrayType; + return $type instanceof ConstantArrayType; } /** * @param ConstantArrayType $type */ - public function resolve(\PHPStan\Type\Type $type, \PHPStan\Analyser\Scope $scope) : ?\PHPStan\Reflection\MethodReflection + public function resolve(Type $type, Scope $scope) : ?MethodReflection { $constantArrayTypeAndMethod = $this->findTypeAndMethodName($type); - if (!$constantArrayTypeAndMethod instanceof \PHPStan\Type\Constant\ConstantArrayTypeAndMethod) { + if (!$constantArrayTypeAndMethod instanceof ConstantArrayTypeAndMethod) { return null; } if ($constantArrayTypeAndMethod->isUnknown()) { @@ -59,7 +59,7 @@ final class ConstantArrayTypeToCallReflectionResolver implements \Rector\Core\Co /** * @see https://github.com/phpstan/phpstan-src/blob/b1fd47bda2a7a7d25091197b125c0adf82af6757/src/Type/Constant/ConstantArrayType.php#L209 */ - private function findTypeAndMethodName(\PHPStan\Type\Constant\ConstantArrayType $constantArrayType) : ?\PHPStan\Type\Constant\ConstantArrayTypeAndMethod + private function findTypeAndMethodName(ConstantArrayType $constantArrayType) : ?ConstantArrayTypeAndMethod { if (!$this->areKeyTypesValid($constantArrayType)) { return null; @@ -69,37 +69,37 @@ final class ConstantArrayTypeToCallReflectionResolver implements \Rector\Core\Co } $classOrObjectType = $constantArrayType->getValueTypes()[0]; $methodType = $constantArrayType->getValueTypes()[1]; - if (!$methodType instanceof \PHPStan\Type\Constant\ConstantStringType) { - return \PHPStan\Type\Constant\ConstantArrayTypeAndMethod::createUnknown(); + if (!$methodType instanceof ConstantStringType) { + return ConstantArrayTypeAndMethod::createUnknown(); } - $objectWithoutClassType = new \PHPStan\Type\ObjectWithoutClassType(); - if ($classOrObjectType instanceof \PHPStan\Type\Constant\ConstantStringType) { + $objectWithoutClassType = new ObjectWithoutClassType(); + if ($classOrObjectType instanceof ConstantStringType) { $value = $classOrObjectType->getValue(); if (!$this->reflectionProvider->hasClass($value)) { - return \PHPStan\Type\Constant\ConstantArrayTypeAndMethod::createUnknown(); + return ConstantArrayTypeAndMethod::createUnknown(); } $classReflection = $this->reflectionProvider->getClass($value); - $type = new \PHPStan\Type\ObjectType($classReflection->getName()); + $type = new ObjectType($classReflection->getName()); } elseif ($objectWithoutClassType->isSuperTypeOf($classOrObjectType)->yes()) { $type = $classOrObjectType; } else { - return \PHPStan\Type\Constant\ConstantArrayTypeAndMethod::createUnknown(); + return ConstantArrayTypeAndMethod::createUnknown(); } $trinaryLogic = $type->hasMethod($methodType->getValue()); if (!$trinaryLogic->no()) { - return \PHPStan\Type\Constant\ConstantArrayTypeAndMethod::createConcrete($type, $methodType->getValue(), $trinaryLogic); + return ConstantArrayTypeAndMethod::createConcrete($type, $methodType->getValue(), $trinaryLogic); } return null; } - private function areKeyTypesValid(\PHPStan\Type\Constant\ConstantArrayType $constantArrayType) : bool + private function areKeyTypesValid(ConstantArrayType $constantArrayType) : bool { $keyTypes = $constantArrayType->getKeyTypes(); if (\count($keyTypes) !== 2) { return \false; } - if ($keyTypes[0]->isSuperTypeOf(new \PHPStan\Type\Constant\ConstantIntegerType(0))->no()) { + if ($keyTypes[0]->isSuperTypeOf(new ConstantIntegerType(0))->no()) { return \false; } - return !$keyTypes[1]->isSuperTypeOf(new \PHPStan\Type\Constant\ConstantIntegerType(1))->no(); + return !$keyTypes[1]->isSuperTypeOf(new ConstantIntegerType(1))->no(); } } diff --git a/src/PHPStan/Reflection/TypeToCallReflectionResolver/ConstantStringTypeToCallReflectionResolver.php b/src/PHPStan/Reflection/TypeToCallReflectionResolver/ConstantStringTypeToCallReflectionResolver.php index d71492f02fd..8f686e52013 100644 --- a/src/PHPStan/Reflection/TypeToCallReflectionResolver/ConstantStringTypeToCallReflectionResolver.php +++ b/src/PHPStan/Reflection/TypeToCallReflectionResolver/ConstantStringTypeToCallReflectionResolver.php @@ -17,7 +17,7 @@ use Rector\Core\Contract\PHPStan\Reflection\TypeToCallReflectionResolver\TypeToC * * @implements TypeToCallReflectionResolverInterface */ -final class ConstantStringTypeToCallReflectionResolver implements \Rector\Core\Contract\PHPStan\Reflection\TypeToCallReflectionResolver\TypeToCallReflectionResolverInterface +final class ConstantStringTypeToCallReflectionResolver implements TypeToCallReflectionResolverInterface { /** * Took from https://github.com/phpstan/phpstan-src/blob/8376548f76e2c845ae047e3010e873015b796818/src/Type/Constant/ConstantStringType.php#L158 @@ -40,28 +40,28 @@ final class ConstantStringTypeToCallReflectionResolver implements \Rector\Core\C * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ReflectionProvider $reflectionProvider) { $this->reflectionProvider = $reflectionProvider; } - public function supports(\PHPStan\Type\Type $type) : bool + public function supports(Type $type) : bool { - return $type instanceof \PHPStan\Type\Constant\ConstantStringType; + return $type instanceof ConstantStringType; } /** * @param ConstantStringType $type * @return FunctionReflection|MethodReflection|null */ - public function resolve(\PHPStan\Type\Type $type, \PHPStan\Analyser\Scope $scope) + public function resolve(Type $type, Scope $scope) { $value = $type->getValue(); // 'my_function' - $name = new \PhpParser\Node\Name($value); + $name = new Name($value); if ($this->reflectionProvider->hasFunction($name, null)) { return $this->reflectionProvider->getFunction($name, null); } // 'MyClass::myStaticFunction' - $matches = \RectorPrefix20220607\Nette\Utils\Strings::match($value, self::STATIC_METHOD_REGEX); + $matches = Strings::match($value, self::STATIC_METHOD_REGEX); if ($matches === null) { return null; } diff --git a/src/PHPStan/Reflection/TypeToCallReflectionResolver/ObjectTypeToCallReflectionResolver.php b/src/PHPStan/Reflection/TypeToCallReflectionResolver/ObjectTypeToCallReflectionResolver.php index c0faff4f7d0..daa29e4caca 100644 --- a/src/PHPStan/Reflection/TypeToCallReflectionResolver/ObjectTypeToCallReflectionResolver.php +++ b/src/PHPStan/Reflection/TypeToCallReflectionResolver/ObjectTypeToCallReflectionResolver.php @@ -15,34 +15,34 @@ use Rector\Core\ValueObject\MethodName; * * @implements TypeToCallReflectionResolverInterface */ -final class ObjectTypeToCallReflectionResolver implements \Rector\Core\Contract\PHPStan\Reflection\TypeToCallReflectionResolver\TypeToCallReflectionResolverInterface +final class ObjectTypeToCallReflectionResolver implements TypeToCallReflectionResolverInterface { /** * @readonly * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ReflectionProvider $reflectionProvider) { $this->reflectionProvider = $reflectionProvider; } - public function supports(\PHPStan\Type\Type $type) : bool + public function supports(Type $type) : bool { - return $type instanceof \PHPStan\Type\ObjectType; + return $type instanceof ObjectType; } /** * @param ObjectType $type */ - public function resolve(\PHPStan\Type\Type $type, \PHPStan\Analyser\Scope $scope) : ?\PHPStan\Reflection\MethodReflection + public function resolve(Type $type, Scope $scope) : ?MethodReflection { $className = $type->getClassName(); if (!$this->reflectionProvider->hasClass($className)) { return null; } $classReflection = $this->reflectionProvider->getClass($className); - if (!$classReflection->hasNativeMethod(\Rector\Core\ValueObject\MethodName::INVOKE)) { + if (!$classReflection->hasNativeMethod(MethodName::INVOKE)) { return null; } - return $classReflection->getNativeMethod(\Rector\Core\ValueObject\MethodName::INVOKE); + return $classReflection->getNativeMethod(MethodName::INVOKE); } } diff --git a/src/PHPStan/Reflection/TypeToCallReflectionResolver/TypeToCallReflectionResolverRegistry.php b/src/PHPStan/Reflection/TypeToCallReflectionResolver/TypeToCallReflectionResolverRegistry.php index ffb1b066a3c..0c1671962cb 100644 --- a/src/PHPStan/Reflection/TypeToCallReflectionResolver/TypeToCallReflectionResolverRegistry.php +++ b/src/PHPStan/Reflection/TypeToCallReflectionResolver/TypeToCallReflectionResolverRegistry.php @@ -25,7 +25,7 @@ final class TypeToCallReflectionResolverRegistry /** * @return FunctionReflection|MethodReflection|null */ - public function resolve(\PHPStan\Type\Type $type, \PHPStan\Analyser\Scope $scope) + public function resolve(Type $type, Scope $scope) { foreach ($this->resolvers as $resolver) { if (!$resolver->supports($type)) { diff --git a/src/Php/PhpVersionProvider.php b/src/Php/PhpVersionProvider.php index 520619e165d..102cdf1a8b7 100644 --- a/src/Php/PhpVersionProvider.php +++ b/src/Php/PhpVersionProvider.php @@ -31,7 +31,7 @@ final class PhpVersionProvider * @var \Rector\Core\Php\PhpVersionResolver\ProjectComposerJsonPhpVersionResolver */ private $projectComposerJsonPhpVersionResolver; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \Rector\Core\Php\PhpVersionResolver\ProjectComposerJsonPhpVersionResolver $projectComposerJsonPhpVersionResolver) + public function __construct(ParameterProvider $parameterProvider, ProjectComposerJsonPhpVersionResolver $projectComposerJsonPhpVersionResolver) { $this->parameterProvider = $parameterProvider; $this->projectComposerJsonPhpVersionResolver = $projectComposerJsonPhpVersionResolver; @@ -41,15 +41,15 @@ final class PhpVersionProvider */ public function provide() : int { - $phpVersionFeatures = $this->parameterProvider->provideParameter(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES); + $phpVersionFeatures = $this->parameterProvider->provideParameter(Option::PHP_VERSION_FEATURES); $this->validatePhpVersionFeaturesParameter($phpVersionFeatures); if ($phpVersionFeatures > 0) { return $phpVersionFeatures; } // for tests - if (\Rector\Testing\PHPUnit\StaticPHPUnitEnvironment::isPHPUnitRun()) { + if (StaticPHPUnitEnvironment::isPHPUnitRun()) { // so we don't have to keep with up with newest version - return \Rector\Core\ValueObject\PhpVersion::PHP_10; + return PhpVersion::PHP_10; } $projectComposerJson = \getcwd() . '/composer.json'; if (\file_exists($projectComposerJson)) { @@ -73,7 +73,7 @@ final class PhpVersionProvider return; } // get all constants - $phpVersionReflectionClass = new \ReflectionClass(\Rector\Core\ValueObject\PhpVersion::class); + $phpVersionReflectionClass = new ReflectionClass(PhpVersion::class); // @todo check if (\in_array($phpVersionFeatures, $phpVersionReflectionClass->getConstants(), \true)) { return; @@ -81,7 +81,7 @@ final class PhpVersionProvider if (!\is_int($phpVersionFeatures)) { $this->throwInvalidTypeException($phpVersionFeatures); } - if (\Rector\Core\Util\StringUtils::isMatch((string) $phpVersionFeatures, self::VALID_PHP_VERSION_REGEX) && $phpVersionFeatures >= \Rector\Core\ValueObject\PhpVersion::PHP_53 - 1) { + if (StringUtils::isMatch((string) $phpVersionFeatures, self::VALID_PHP_VERSION_REGEX) && $phpVersionFeatures >= PhpVersion::PHP_53 - 1) { return; } $this->throwInvalidTypeException($phpVersionFeatures); @@ -91,7 +91,7 @@ final class PhpVersionProvider */ private function throwInvalidTypeException($phpVersionFeatures) : void { - $errorMessage = \sprintf('Parameter "%s::%s" must be int, "%s" given.%sUse constant from "%s" to provide it, e.g. "%s::%s"', \Rector\Core\Configuration\Option::class, 'PHP_VERSION_FEATURES', (string) $phpVersionFeatures, \PHP_EOL, \Rector\Core\ValueObject\PhpVersion::class, \Rector\Core\ValueObject\PhpVersion::class, 'PHP_80'); - throw new \Rector\Core\Exception\Configuration\InvalidConfigurationException($errorMessage); + $errorMessage = \sprintf('Parameter "%s::%s" must be int, "%s" given.%sUse constant from "%s" to provide it, e.g. "%s::%s"', Option::class, 'PHP_VERSION_FEATURES', (string) $phpVersionFeatures, \PHP_EOL, PhpVersion::class, PhpVersion::class, 'PHP_80'); + throw new InvalidConfigurationException($errorMessage); } } diff --git a/src/Php/PhpVersionResolver/ProjectComposerJsonPhpVersionResolver.php b/src/Php/PhpVersionResolver/ProjectComposerJsonPhpVersionResolver.php index 4768b54bd02..86a2e2e99cf 100644 --- a/src/Php/PhpVersionResolver/ProjectComposerJsonPhpVersionResolver.php +++ b/src/Php/PhpVersionResolver/ProjectComposerJsonPhpVersionResolver.php @@ -26,7 +26,7 @@ final class ProjectComposerJsonPhpVersionResolver * @var \Rector\Core\Util\PhpVersionFactory */ private $phpVersionFactory; - public function __construct(\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ComposerJsonFactory $composerJsonFactory, \RectorPrefix20220607\Composer\Semver\VersionParser $versionParser, \Rector\Core\Util\PhpVersionFactory $phpVersionFactory) + public function __construct(ComposerJsonFactory $composerJsonFactory, VersionParser $versionParser, PhpVersionFactory $phpVersionFactory) { $this->composerJsonFactory = $composerJsonFactory; $this->versionParser = $versionParser; diff --git a/src/Php/Regex/RegexPatternArgumentManipulator.php b/src/Php/Regex/RegexPatternArgumentManipulator.php index 2a889ad2bd1..dbf9fc616b7 100644 --- a/src/Php/Regex/RegexPatternArgumentManipulator.php +++ b/src/Php/Regex/RegexPatternArgumentManipulator.php @@ -30,7 +30,7 @@ final class RegexPatternArgumentManipulator /** * @var array> */ - private const STATIC_METHODS_WITH_PATTERNS_TO_ARGUMENT_POSITION = [\RectorPrefix20220607\Nette\Utils\Strings::class => ['match' => 1, 'matchAll' => 1, 'replace' => 1, 'split' => 1]]; + private const STATIC_METHODS_WITH_PATTERNS_TO_ARGUMENT_POSITION = [Strings::class => ['match' => 1, 'matchAll' => 1, 'replace' => 1, 'split' => 1]]; /** * @readonly * @var \Rector\Core\PhpParser\Node\BetterNodeFinder @@ -56,7 +56,7 @@ final class RegexPatternArgumentManipulator * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\Core\PhpParser\NodeFinder\LocalConstantFinder $localConstantFinder, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver, LocalConstantFinder $localConstantFinder, NodeComparator $nodeComparator) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeNameResolver = $nodeNameResolver; @@ -70,7 +70,7 @@ final class RegexPatternArgumentManipulator */ public function matchCallArgumentWithRegexPattern($call) : array { - if ($call instanceof \PhpParser\Node\Expr\FuncCall) { + if ($call instanceof FuncCall) { return $this->processFuncCall($call); } return $this->processStaticCall($call); @@ -78,7 +78,7 @@ final class RegexPatternArgumentManipulator /** * @return String_[] */ - private function processFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall) : array + private function processFuncCall(FuncCall $funcCall) : array { foreach (self::FUNCTIONS_WITH_PATTERNS_TO_ARGUMENT_POSITION as $functionName => $argumentPosition) { if (!$this->nodeNameResolver->isName($funcCall, $functionName)) { @@ -87,7 +87,7 @@ final class RegexPatternArgumentManipulator if (!isset($funcCall->args[$argumentPosition])) { return []; } - if (!$funcCall->args[$argumentPosition] instanceof \PhpParser\Node\Arg) { + if (!$funcCall->args[$argumentPosition] instanceof Arg) { return []; } return $this->resolveArgumentValues($funcCall->args[$argumentPosition]->value); @@ -97,10 +97,10 @@ final class RegexPatternArgumentManipulator /** * @return String_[] */ - private function processStaticCall(\PhpParser\Node\Expr\StaticCall $staticCall) : array + private function processStaticCall(StaticCall $staticCall) : array { foreach (self::STATIC_METHODS_WITH_PATTERNS_TO_ARGUMENT_POSITION as $type => $methodNamesToArgumentPosition) { - if (!$this->nodeTypeResolver->isObjectType($staticCall->class, new \PHPStan\Type\ObjectType($type))) { + if (!$this->nodeTypeResolver->isObjectType($staticCall->class, new ObjectType($type))) { continue; } foreach ($methodNamesToArgumentPosition as $methodName => $argumentPosition) { @@ -110,7 +110,7 @@ final class RegexPatternArgumentManipulator if (!isset($staticCall->args[$argumentPosition])) { return []; } - if (!$staticCall->args[$argumentPosition] instanceof \PhpParser\Node\Arg) { + if (!$staticCall->args[$argumentPosition] instanceof Arg) { return []; } return $this->resolveArgumentValues($staticCall->args[$argumentPosition]->value); @@ -121,22 +121,22 @@ final class RegexPatternArgumentManipulator /** * @return String_[] */ - private function resolveArgumentValues(\PhpParser\Node\Expr $expr) : array + private function resolveArgumentValues(Expr $expr) : array { - if ($expr instanceof \PhpParser\Node\Scalar\String_) { + if ($expr instanceof String_) { return [$expr]; } - if ($expr instanceof \PhpParser\Node\Expr\Variable) { + if ($expr instanceof Variable) { $strings = []; $assignNodes = $this->findAssignerForVariable($expr); foreach ($assignNodes as $assignNode) { - if ($assignNode->expr instanceof \PhpParser\Node\Scalar\String_) { + if ($assignNode->expr instanceof String_) { $strings[] = $assignNode->expr; } } return $strings; } - if ($expr instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if ($expr instanceof ClassConstFetch) { return $this->matchClassConstFetchStringValue($expr); } return []; @@ -144,14 +144,14 @@ final class RegexPatternArgumentManipulator /** * @return Assign[] */ - private function findAssignerForVariable(\PhpParser\Node\Expr\Variable $variable) : array + private function findAssignerForVariable(Variable $variable) : array { - $classMethod = $this->betterNodeFinder->findParentType($variable, \PhpParser\Node\Stmt\ClassMethod::class); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $this->betterNodeFinder->findParentType($variable, ClassMethod::class); + if (!$classMethod instanceof ClassMethod) { return []; } - return $this->betterNodeFinder->find([$classMethod], function (\PhpParser\Node $node) use($variable) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + return $this->betterNodeFinder->find([$classMethod], function (Node $node) use($variable) : bool { + if (!$node instanceof Assign) { return \false; } return $this->nodeComparator->areNodesEqual($node->var, $variable); @@ -160,13 +160,13 @@ final class RegexPatternArgumentManipulator /** * @return String_[] */ - private function matchClassConstFetchStringValue(\PhpParser\Node\Expr\ClassConstFetch $classConstFetch) : array + private function matchClassConstFetchStringValue(ClassConstFetch $classConstFetch) : array { $classConst = $this->localConstantFinder->match($classConstFetch); - if (!$classConst instanceof \PhpParser\Node\Const_) { + if (!$classConst instanceof Const_) { return []; } - if ($classConst->value instanceof \PhpParser\Node\Scalar\String_) { + if ($classConst->value instanceof String_) { return [$classConst->value]; } return []; diff --git a/src/PhpParser/AstResolver.php b/src/PhpParser/AstResolver.php index 10a61538d11..09aef9e7ef2 100644 --- a/src/PhpParser/AstResolver.php +++ b/src/PhpParser/AstResolver.php @@ -32,7 +32,7 @@ use Rector\NodeNameResolver\NodeNameResolver; use Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator; use Rector\NodeTypeResolver\NodeTypeResolver; use RectorPrefix20220607\Symplify\Astral\PhpParser\SmartPhpParser; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; /** * The nodes provided by this resolver is for read-only analysis only! * They are not part of node tree processed by Rector, so any changes will not make effect in final printed file. @@ -93,7 +93,7 @@ final class AstResolver * @var \Rector\Core\PhpParser\ClassLikeAstResolver */ private $classLikeAstResolver; - public function __construct(\RectorPrefix20220607\Symplify\Astral\PhpParser\SmartPhpParser $smartPhpParser, \Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\Core\PhpParser\ClassLikeAstResolver $classLikeAstResolver) + public function __construct(SmartPhpParser $smartPhpParser, NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator, BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider, ReflectionResolver $reflectionResolver, NodeTypeResolver $nodeTypeResolver, \Rector\Core\PhpParser\ClassLikeAstResolver $classLikeAstResolver) { $this->smartPhpParser = $smartPhpParser; $this->nodeScopeAndMetadataDecorator = $nodeScopeAndMetadataDecorator; @@ -118,11 +118,11 @@ final class AstResolver /** * @return \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Trait_|\PhpParser\Node\Stmt\Interface_|\PhpParser\Node\Stmt\Enum_|null */ - public function resolveClassFromObjectType(\PHPStan\Type\TypeWithClassName $typeWithClassName) + public function resolveClassFromObjectType(TypeWithClassName $typeWithClassName) { return $this->resolveClassFromName($typeWithClassName->getClassName()); } - public function resolveClassMethodFromMethodReflection(\PHPStan\Reflection\MethodReflection $methodReflection) : ?\PhpParser\Node\Stmt\ClassMethod + public function resolveClassMethodFromMethodReflection(MethodReflection $methodReflection) : ?ClassMethod { $classReflection = $methodReflection->getDeclaringClass(); if (isset($this->classMethodsByClassAndMethod[$classReflection->getName()][$methodReflection->getName()])) { @@ -137,8 +137,8 @@ final class AstResolver if ($nodes === null) { return null; } - $class = $this->betterNodeFinder->findFirstInstanceOf($nodes, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findFirstInstanceOf($nodes, Class_::class); + if (!$class instanceof Class_) { // avoids looking for a class in a file where is not present $this->classMethodsByClassAndMethod[$classReflection->getName()][$methodReflection->getName()] = null; return null; @@ -151,14 +151,14 @@ final class AstResolver * @param \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $call * @return \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|null */ - public function resolveClassMethodOrFunctionFromCall($call, \PHPStan\Analyser\Scope $scope) + public function resolveClassMethodOrFunctionFromCall($call, Scope $scope) { - if ($call instanceof \PhpParser\Node\Expr\FuncCall) { + if ($call instanceof FuncCall) { return $this->resolveFunctionFromFuncCall($call, $scope); } return $this->resolveClassMethodFromCall($call); } - public function resolveFunctionFromFunctionReflection(\PHPStan\Reflection\FunctionReflection $functionReflection) : ?\PhpParser\Node\Stmt\Function_ + public function resolveFunctionFromFunctionReflection(FunctionReflection $functionReflection) : ?Function_ { if (isset($this->functionsByName[$functionReflection->getName()])) { return $this->functionsByName[$functionReflection->getName()]; @@ -172,7 +172,7 @@ final class AstResolver return null; } /** @var Function_[] $functions */ - $functions = $this->betterNodeFinder->findInstanceOf($nodes, \PhpParser\Node\Stmt\Function_::class); + $functions = $this->betterNodeFinder->findInstanceOf($nodes, Function_::class); foreach ($functions as $function) { if (!$this->nodeNameResolver->isName($function, $functionReflection->getName())) { continue; @@ -188,14 +188,14 @@ final class AstResolver /** * @param class-string $className */ - public function resolveClassMethod(string $className, string $methodName) : ?\PhpParser\Node\Stmt\ClassMethod + public function resolveClassMethod(string $className, string $methodName) : ?ClassMethod { $methodReflection = $this->reflectionResolver->resolveMethodReflection($className, $methodName, null); - if (!$methodReflection instanceof \PHPStan\Reflection\MethodReflection) { + if (!$methodReflection instanceof MethodReflection) { return null; } $classMethod = $this->resolveClassMethodFromMethodReflection($methodReflection); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$classMethod instanceof ClassMethod) { return $this->locateClassMethodInTrait($methodName, $methodReflection); } return $classMethod; @@ -203,14 +203,14 @@ final class AstResolver /** * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $call */ - public function resolveClassMethodFromCall($call) : ?\PhpParser\Node\Stmt\ClassMethod + public function resolveClassMethodFromCall($call) : ?ClassMethod { - if ($call instanceof \PhpParser\Node\Expr\MethodCall) { + if ($call instanceof MethodCall) { $callerStaticType = $this->nodeTypeResolver->getType($call->var); } else { $callerStaticType = $this->nodeTypeResolver->getType($call->class); } - if (!$callerStaticType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$callerStaticType instanceof TypeWithClassName) { return null; } $methodName = $this->nodeNameResolver->getName($call->name); @@ -222,14 +222,14 @@ final class AstResolver /** * @return \PhpParser\Node\Stmt\Trait_|\PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Interface_|\PhpParser\Node\Stmt\Enum_|null */ - public function resolveClassFromClassReflection(\PHPStan\Reflection\ClassReflection $classReflection, string $className) + public function resolveClassFromClassReflection(ClassReflection $classReflection, string $className) { return $this->classLikeAstResolver->resolveClassFromClassReflection($classReflection, $className); } /** * @return Trait_[] */ - public function parseClassReflectionTraits(\PHPStan\Reflection\ClassReflection $classReflection) : array + public function parseClassReflectionTraits(ClassReflection $classReflection) : array { /** @var ClassReflection[] $classLikes */ $classLikes = $classReflection->getTraits(\true); @@ -244,10 +244,10 @@ final class AstResolver continue; } /** @var Trait_|null $trait */ - $trait = $this->betterNodeFinder->findFirst($nodes, function (\PhpParser\Node $node) use($classLike) : bool { - return $node instanceof \PhpParser\Node\Stmt\Trait_ && $this->nodeNameResolver->isName($node, $classLike->getName()); + $trait = $this->betterNodeFinder->findFirst($nodes, function (Node $node) use($classLike) : bool { + return $node instanceof Trait_ && $this->nodeNameResolver->isName($node, $classLike->getName()); }); - if (!$trait instanceof \PhpParser\Node\Stmt\Trait_) { + if (!$trait instanceof Trait_) { continue; } $traits[] = $trait; @@ -257,7 +257,7 @@ final class AstResolver /** * @return \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param|null */ - public function resolvePropertyFromPropertyReflection(\PHPStan\Reflection\Php\PhpPropertyReflection $phpPropertyReflection) + public function resolvePropertyFromPropertyReflection(PhpPropertyReflection $phpPropertyReflection) { $classReflection = $phpPropertyReflection->getDeclaringClass(); $fileName = $classReflection->getFileName(); @@ -271,7 +271,7 @@ final class AstResolver $nativeReflectionProperty = $phpPropertyReflection->getNativeReflection(); $desiredPropertyName = $nativeReflectionProperty->getName(); /** @var Property[] $properties */ - $properties = $this->betterNodeFinder->findInstanceOf($nodes, \PhpParser\Node\Stmt\Property::class); + $properties = $this->betterNodeFinder->findInstanceOf($nodes, Property::class); foreach ($properties as $property) { if ($this->nodeNameResolver->isName($property, $desiredPropertyName)) { return $property; @@ -280,16 +280,16 @@ final class AstResolver // promoted property return $this->findPromotedPropertyByName($nodes, $desiredPropertyName); } - private function locateClassMethodInTrait(string $methodName, \PHPStan\Reflection\MethodReflection $methodReflection) : ?\PhpParser\Node\Stmt\ClassMethod + private function locateClassMethodInTrait(string $methodName, MethodReflection $methodReflection) : ?ClassMethod { $classReflection = $methodReflection->getDeclaringClass(); $traits = $this->parseClassReflectionTraits($classReflection); /** @var ClassMethod|null $classMethod */ - $classMethod = $this->betterNodeFinder->findFirst($traits, function (\PhpParser\Node $node) use($methodName) : bool { - return $node instanceof \PhpParser\Node\Stmt\ClassMethod && $this->nodeNameResolver->isName($node, $methodName); + $classMethod = $this->betterNodeFinder->findFirst($traits, function (Node $node) use($methodName) : bool { + return $node instanceof ClassMethod && $this->nodeNameResolver->isName($node, $methodName); }); $this->classMethodsByClassAndMethod[$classReflection->getName()][$methodName] = $classMethod; - if ($classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if ($classMethod instanceof ClassMethod) { return $classMethod; } return null; @@ -303,21 +303,21 @@ final class AstResolver if ($stmts === []) { return null; } - $smartFileInfo = new \Symplify\SmartFileSystem\SmartFileInfo($fileName); - $file = new \Rector\Core\ValueObject\Application\File($smartFileInfo, $smartFileInfo->getContents()); + $smartFileInfo = new SmartFileInfo($fileName); + $file = new File($smartFileInfo, $smartFileInfo->getContents()); return $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($file, $stmts); } /** * @param Stmt[] $stmts */ - private function findPromotedPropertyByName(array $stmts, string $desiredPropertyName) : ?\PhpParser\Node\Param + private function findPromotedPropertyByName(array $stmts, string $desiredPropertyName) : ?Param { - $class = $this->betterNodeFinder->findFirstInstanceOf($stmts, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findFirstInstanceOf($stmts, Class_::class); + if (!$class instanceof Class_) { return null; } - $constructClassMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$constructClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $constructClassMethod = $class->getMethod(MethodName::CONSTRUCT); + if (!$constructClassMethod instanceof ClassMethod) { return null; } foreach ($constructClassMethod->getParams() as $param) { @@ -330,9 +330,9 @@ final class AstResolver } return null; } - private function resolveFunctionFromFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall, \PHPStan\Analyser\Scope $scope) : ?\PhpParser\Node\Stmt\Function_ + private function resolveFunctionFromFuncCall(FuncCall $funcCall, Scope $scope) : ?Function_ { - if ($funcCall->name instanceof \PhpParser\Node\Expr) { + if ($funcCall->name instanceof Expr) { return null; } if (!$this->reflectionProvider->hasFunction($funcCall->name, $scope)) { diff --git a/src/PhpParser/ClassLikeAstResolver.php b/src/PhpParser/ClassLikeAstResolver.php index 5a738a3b8c4..0e66a333319 100644 --- a/src/PhpParser/ClassLikeAstResolver.php +++ b/src/PhpParser/ClassLikeAstResolver.php @@ -31,7 +31,7 @@ final class ClassLikeAstResolver * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\RectorPrefix20220607\Symplify\Astral\PhpParser\SmartPhpParser $smartPhpParser, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(SmartPhpParser $smartPhpParser, BetterNodeFinder $betterNodeFinder) { $this->smartPhpParser = $smartPhpParser; $this->betterNodeFinder = $betterNodeFinder; @@ -39,7 +39,7 @@ final class ClassLikeAstResolver /** * @return \PhpParser\Node\Stmt\Trait_|\PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Interface_|\PhpParser\Node\Stmt\Enum_|null */ - public function resolveClassFromClassReflection(\PHPStan\Reflection\ClassReflection $classReflection, string $desiredClassName) + public function resolveClassFromClassReflection(ClassReflection $classReflection, string $desiredClassName) { if ($classReflection->isBuiltin()) { return null; @@ -61,7 +61,7 @@ final class ClassLikeAstResolver return null; } /** @var array $classLikes */ - $classLikes = $this->betterNodeFinder->findInstanceOf($stmts, \PhpParser\Node\Stmt\ClassLike::class); + $classLikes = $this->betterNodeFinder->findInstanceOf($stmts, ClassLike::class); $reflectionClassName = $classReflection->getName(); foreach ($classLikes as $classLike) { if ($reflectionClassName !== $desiredClassName) { diff --git a/src/PhpParser/Comparing/ConditionSearcher.php b/src/PhpParser/Comparing/ConditionSearcher.php index df5c8835b33..d88d3ae01a1 100644 --- a/src/PhpParser/Comparing/ConditionSearcher.php +++ b/src/PhpParser/Comparing/ConditionSearcher.php @@ -23,14 +23,14 @@ final class ConditionSearcher * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeComparator = $nodeComparator; } - public function hasIfAndElseForVariableRedeclaration(\PhpParser\Node\Expr\Assign $assign, \PhpParser\Node\Stmt\If_ $if) : bool + public function hasIfAndElseForVariableRedeclaration(Assign $assign, If_ $if) : bool { - if (!$if->else instanceof \PhpParser\Node\Stmt\Else_) { + if (!$if->else instanceof Else_) { return \false; } $ifElse = $if->else; @@ -44,7 +44,7 @@ final class ConditionSearcher return \false; } } - $isInCond = (bool) $this->betterNodeFinder->findFirst($if->cond, function (\PhpParser\Node $subNode) use($varNode) : bool { + $isInCond = (bool) $this->betterNodeFinder->findFirst($if->cond, function (Node $subNode) use($varNode) : bool { return $this->nodeComparator->areNodesEqual($varNode, $subNode); }); if ($isInCond) { @@ -55,7 +55,7 @@ final class ConditionSearcher /** * @param Stmt[] $stmts */ - private function hasVariableRedeclaration(\PhpParser\Node\Expr\Variable $variable, array $stmts) : bool + private function hasVariableRedeclaration(Variable $variable, array $stmts) : bool { foreach ($stmts as $stmt) { if ($this->hasVariableUsedInExpression($variable, $stmt)) { @@ -67,27 +67,27 @@ final class ConditionSearcher } return \false; } - private function hasVariableUsedInExpression(\PhpParser\Node\Expr\Variable $variable, \PhpParser\Node\Stmt $stmt) : bool + private function hasVariableUsedInExpression(Variable $variable, Stmt $stmt) : bool { - if ($stmt instanceof \PhpParser\Node\Stmt\Expression) { - $node = $stmt->expr instanceof \PhpParser\Node\Expr\Assign ? $stmt->expr->expr : $stmt->expr; + if ($stmt instanceof Expression) { + $node = $stmt->expr instanceof Assign ? $stmt->expr->expr : $stmt->expr; } else { $node = $stmt; } - return (bool) $this->betterNodeFinder->findFirst($node, function (\PhpParser\Node $subNode) use($variable) : bool { + return (bool) $this->betterNodeFinder->findFirst($node, function (Node $subNode) use($variable) : bool { return $this->nodeComparator->areNodesEqual($variable, $subNode); }); } - private function hasVariableDeclaration(\PhpParser\Node\Expr\Variable $variable, \PhpParser\Node\Stmt $stmt) : bool + private function hasVariableDeclaration(Variable $variable, Stmt $stmt) : bool { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { return \false; } - if (!$stmt->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$stmt->expr instanceof Assign) { return \false; } $assign = $stmt->expr; - if (!$assign->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$assign->var instanceof Variable) { return \false; } $assignedVariable = $assign->var; diff --git a/src/PhpParser/Comparing/NodeComparator.php b/src/PhpParser/Comparing/NodeComparator.php index 50dcda65a37..3a8e5758c20 100644 --- a/src/PhpParser/Comparing/NodeComparator.php +++ b/src/PhpParser/Comparing/NodeComparator.php @@ -18,7 +18,7 @@ final class NodeComparator * @var \Rector\Core\Contract\PhpParser\NodePrinterInterface */ private $nodePrinter; - public function __construct(\Rector\Comments\CommentRemover $commentRemover, \Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter) + public function __construct(CommentRemover $commentRemover, NodePrinterInterface $nodePrinter) { $this->commentRemover = $commentRemover; $this->nodePrinter = $nodePrinter; @@ -44,7 +44,7 @@ final class NodeComparator /** * @param Node[] $availableNodes */ - public function isNodeEqual(\PhpParser\Node $singleNode, array $availableNodes) : bool + public function isNodeEqual(Node $singleNode, array $availableNodes) : bool { foreach ($availableNodes as $availableNode) { if ($this->areNodesEqual($singleNode, $availableNode)) { @@ -56,7 +56,7 @@ final class NodeComparator /** * Checks even clone nodes */ - public function areSameNode(\PhpParser\Node $firstNode, \PhpParser\Node $secondNode) : bool + public function areSameNode(Node $firstNode, Node $secondNode) : bool { if ($firstNode === $secondNode) { return \true; diff --git a/src/PhpParser/Node/AssignAndBinaryMap.php b/src/PhpParser/Node/AssignAndBinaryMap.php index 68fe35ded7f..5d9e03d10b2 100644 --- a/src/PhpParser/Node/AssignAndBinaryMap.php +++ b/src/PhpParser/Node/AssignAndBinaryMap.php @@ -49,11 +49,11 @@ final class AssignAndBinaryMap /** * @var array, class-string> */ - private const BINARY_OP_TO_INVERSE_CLASSES = [\PhpParser\Node\Expr\BinaryOp\Identical::class => \PhpParser\Node\Expr\BinaryOp\NotIdentical::class, \PhpParser\Node\Expr\BinaryOp\NotIdentical::class => \PhpParser\Node\Expr\BinaryOp\Identical::class, \PhpParser\Node\Expr\BinaryOp\Equal::class => \PhpParser\Node\Expr\BinaryOp\NotEqual::class, \PhpParser\Node\Expr\BinaryOp\NotEqual::class => \PhpParser\Node\Expr\BinaryOp\Equal::class, \PhpParser\Node\Expr\BinaryOp\Greater::class => \PhpParser\Node\Expr\BinaryOp\SmallerOrEqual::class, \PhpParser\Node\Expr\BinaryOp\Smaller::class => \PhpParser\Node\Expr\BinaryOp\GreaterOrEqual::class, \PhpParser\Node\Expr\BinaryOp\GreaterOrEqual::class => \PhpParser\Node\Expr\BinaryOp\Smaller::class, \PhpParser\Node\Expr\BinaryOp\SmallerOrEqual::class => \PhpParser\Node\Expr\BinaryOp\Greater::class]; + private const BINARY_OP_TO_INVERSE_CLASSES = [Identical::class => NotIdentical::class, NotIdentical::class => Identical::class, Equal::class => NotEqual::class, NotEqual::class => Equal::class, Greater::class => SmallerOrEqual::class, Smaller::class => GreaterOrEqual::class, GreaterOrEqual::class => Smaller::class, SmallerOrEqual::class => Greater::class]; /** * @var array, class-string> */ - private const ASSIGN_OP_TO_BINARY_OP_CLASSES = [\PhpParser\Node\Expr\AssignOp\BitwiseOr::class => \PhpParser\Node\Expr\BinaryOp\BitwiseOr::class, \PhpParser\Node\Expr\AssignOp\BitwiseAnd::class => \PhpParser\Node\Expr\BinaryOp\BitwiseAnd::class, \PhpParser\Node\Expr\AssignOp\BitwiseXor::class => \PhpParser\Node\Expr\BinaryOp\BitwiseXor::class, \PhpParser\Node\Expr\AssignOp\Plus::class => \PhpParser\Node\Expr\BinaryOp\Plus::class, \PhpParser\Node\Expr\AssignOp\Div::class => \PhpParser\Node\Expr\BinaryOp\Div::class, \PhpParser\Node\Expr\AssignOp\Mul::class => \PhpParser\Node\Expr\BinaryOp\Mul::class, \PhpParser\Node\Expr\AssignOp\Minus::class => \PhpParser\Node\Expr\BinaryOp\Minus::class, \PhpParser\Node\Expr\AssignOp\Concat::class => \PhpParser\Node\Expr\BinaryOp\Concat::class, \PhpParser\Node\Expr\AssignOp\Pow::class => \PhpParser\Node\Expr\BinaryOp\Pow::class, \PhpParser\Node\Expr\AssignOp\Mod::class => \PhpParser\Node\Expr\BinaryOp\Mod::class, \PhpParser\Node\Expr\AssignOp\ShiftLeft::class => \PhpParser\Node\Expr\BinaryOp\ShiftLeft::class, \PhpParser\Node\Expr\AssignOp\ShiftRight::class => \PhpParser\Node\Expr\BinaryOp\ShiftRight::class]; + private const ASSIGN_OP_TO_BINARY_OP_CLASSES = [AssignBitwiseOr::class => BitwiseOr::class, AssignBitwiseAnd::class => BitwiseAnd::class, AssignBitwiseXor::class => BitwiseXor::class, AssignPlus::class => Plus::class, AssignDiv::class => Div::class, AssignMul::class => Mul::class, AssignMinus::class => Minus::class, AssignConcat::class => Concat::class, AssignPow::class => Pow::class, AssignMod::class => Mod::class, AssignShiftLeft::class => ShiftLeft::class, AssignShiftRight::class => ShiftRight::class]; /** * @var array, class-string> */ @@ -65,13 +65,13 @@ final class AssignAndBinaryMap /** * @return class-string|null */ - public function getAlternative(\PhpParser\Node $node) : ?string + public function getAlternative(Node $node) : ?string { $nodeClass = \get_class($node); - if ($node instanceof \PhpParser\Node\Expr\AssignOp) { + if ($node instanceof AssignOp) { return self::ASSIGN_OP_TO_BINARY_OP_CLASSES[$nodeClass] ?? null; } - if ($node instanceof \PhpParser\Node\Expr\BinaryOp) { + if ($node instanceof BinaryOp) { return $this->binaryOpToAssignClasses[$nodeClass] ?? null; } return null; @@ -79,27 +79,27 @@ final class AssignAndBinaryMap /** * @return class-string|null */ - public function getInversed(\PhpParser\Node\Expr\BinaryOp $binaryOp) : ?string + public function getInversed(BinaryOp $binaryOp) : ?string { $nodeClass = \get_class($binaryOp); return self::BINARY_OP_TO_INVERSE_CLASSES[$nodeClass] ?? null; } - public function getTruthyExpr(\PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr + public function getTruthyExpr(Expr $expr) : Expr { - if ($expr instanceof \PhpParser\Node\Expr\Cast\Bool_) { + if ($expr instanceof Bool_) { return $expr; } - if ($expr instanceof \PhpParser\Node\Expr\BooleanNot) { + if ($expr instanceof BooleanNot) { return $expr; } - $scope = $expr->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { - return new \PhpParser\Node\Expr\Cast\Bool_($expr); + $scope = $expr->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { + return new Bool_($expr); } $type = $scope->getType($expr); - if ($type instanceof \PHPStan\Type\BooleanType) { + if ($type instanceof BooleanType) { return $expr; } - return new \PhpParser\Node\Expr\Cast\Bool_($expr); + return new Bool_($expr); } } diff --git a/src/PhpParser/Node/BetterNodeFinder.php b/src/PhpParser/Node/BetterNodeFinder.php index c3b93fe2f64..9af4ad3e865 100644 --- a/src/PhpParser/Node/BetterNodeFinder.php +++ b/src/PhpParser/Node/BetterNodeFinder.php @@ -57,7 +57,7 @@ final class BetterNodeFinder * @var \Rector\Core\NodeAnalyzer\ClassAnalyzer */ private $classAnalyzer; - public function __construct(\PhpParser\NodeFinder $nodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \RectorPrefix20220607\Symplify\PackageBuilder\Php\TypeChecker $typeChecker, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer) + public function __construct(NodeFinder $nodeFinder, NodeNameResolver $nodeNameResolver, TypeChecker $typeChecker, NodeComparator $nodeComparator, ClassAnalyzer $classAnalyzer) { $this->nodeFinder = $nodeFinder; $this->nodeNameResolver = $nodeNameResolver; @@ -70,11 +70,11 @@ final class BetterNodeFinder * @param array> $types * @return T|null */ - public function findParentByTypes(\PhpParser\Node $currentNode, array $types) : ?\PhpParser\Node + public function findParentByTypes(Node $currentNode, array $types) : ?Node { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($types, \PhpParser\Node::class); - while ($currentNode = $currentNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE)) { - if (!$currentNode instanceof \PhpParser\Node) { + Assert::allIsAOf($types, Node::class); + while ($currentNode = $currentNode->getAttribute(AttributeKey::PARENT_NODE)) { + if (!$currentNode instanceof Node) { return null; } foreach ($types as $type) { @@ -90,19 +90,19 @@ final class BetterNodeFinder * @param class-string $type * @return T|null */ - public function findParentType(\PhpParser\Node $node, string $type) : ?\PhpParser\Node + public function findParentType(Node $node, string $type) : ?Node { - \RectorPrefix20220607\Webmozart\Assert\Assert::isAOf($type, \PhpParser\Node::class); - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node) { + Assert::isAOf($type, Node::class); + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Node) { return null; } do { if (\is_a($parent, $type, \true)) { return $parent; } - $parent = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - } while ($parent instanceof \PhpParser\Node); + $parent = $parent->getAttribute(AttributeKey::PARENT_NODE); + } while ($parent instanceof Node); return null; } /** @@ -135,9 +135,9 @@ final class BetterNodeFinder * @param class-string $type * @param \PhpParser\Node|mixed[] $nodes */ - public function findFirstInstanceOf($nodes, string $type) : ?\PhpParser\Node + public function findFirstInstanceOf($nodes, string $type) : ?Node { - \RectorPrefix20220607\Webmozart\Assert\Assert::isAOf($type, \PhpParser\Node::class); + Assert::isAOf($type, Node::class); return $this->nodeFinder->findFirstInstanceOf($nodes, $type); } /** @@ -146,7 +146,7 @@ final class BetterNodeFinder */ public function hasInstanceOfName($nodes, string $type, string $name) : bool { - \RectorPrefix20220607\Webmozart\Assert\Assert::isAOf($type, \PhpParser\Node::class); + Assert::isAOf($type, Node::class); return (bool) $this->findInstanceOfName($nodes, $type, $name); } /** @@ -154,15 +154,15 @@ final class BetterNodeFinder */ public function hasVariableOfName($nodes, string $name) : bool { - return $this->findVariableOfName($nodes, $name) instanceof \PhpParser\Node; + return $this->findVariableOfName($nodes, $name) instanceof Node; } /** * @param \PhpParser\Node|mixed[] $nodes * @return Variable|null */ - public function findVariableOfName($nodes, string $name) : ?\PhpParser\Node + public function findVariableOfName($nodes, string $name) : ?Node { - return $this->findInstanceOfName($nodes, \PhpParser\Node\Expr\Variable::class, $name); + return $this->findInstanceOfName($nodes, Variable::class, $name); } /** * @param \PhpParser\Node|mixed[] $nodes @@ -170,10 +170,10 @@ final class BetterNodeFinder */ public function hasInstancesOf($nodes, array $types) : bool { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($types, \PhpParser\Node::class); + Assert::allIsAOf($types, Node::class); foreach ($types as $type) { $foundNode = $this->nodeFinder->findFirstInstanceOf($nodes, $type); - if (!$foundNode instanceof \PhpParser\Node) { + if (!$foundNode instanceof Node) { continue; } return \true; @@ -185,9 +185,9 @@ final class BetterNodeFinder * @param class-string $type * @param \PhpParser\Node|mixed[] $nodes */ - public function findLastInstanceOf($nodes, string $type) : ?\PhpParser\Node + public function findLastInstanceOf($nodes, string $type) : ?Node { - \RectorPrefix20220607\Webmozart\Assert\Assert::isAOf($type, \PhpParser\Node::class); + Assert::isAOf($type, Node::class); $foundInstances = $this->nodeFinder->findInstanceOf($nodes, $type); if ($foundInstances === []) { return null; @@ -209,38 +209,38 @@ final class BetterNodeFinder * @param Node[] $nodes * @return ClassLike|null */ - public function findFirstNonAnonymousClass(array $nodes) : ?\PhpParser\Node + public function findFirstNonAnonymousClass(array $nodes) : ?Node { // skip anonymous classes - return $this->findFirst($nodes, function (\PhpParser\Node $node) : bool { - return $node instanceof \PhpParser\Node\Stmt\Class_ && !$this->classAnalyzer->isAnonymousClass($node); + return $this->findFirst($nodes, function (Node $node) : bool { + return $node instanceof Class_ && !$this->classAnalyzer->isAnonymousClass($node); }); } /** * @param \PhpParser\Node|mixed[] $nodes * @param callable(Node $filter): bool $filter */ - public function findFirst($nodes, callable $filter) : ?\PhpParser\Node + public function findFirst($nodes, callable $filter) : ?Node { return $this->nodeFinder->findFirst($nodes, $filter); } /** * @return Assign[] */ - public function findClassMethodAssignsToLocalProperty(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $propertyName) : array + public function findClassMethodAssignsToLocalProperty(ClassMethod $classMethod, string $propertyName) : array { - return $this->find((array) $classMethod->stmts, function (\PhpParser\Node $node) use($classMethod, $propertyName) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + return $this->find((array) $classMethod->stmts, function (Node $node) use($classMethod, $propertyName) : bool { + if (!$node instanceof Assign) { return \false; } - if (!$node->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$node->var instanceof PropertyFetch) { return \false; } $propertyFetch = $node->var; if (!$this->nodeNameResolver->isName($propertyFetch->var, 'this')) { return \false; } - $parentFunctionLike = $this->findParentType($node, \PhpParser\Node\Stmt\ClassMethod::class); + $parentFunctionLike = $this->findParentType($node, ClassMethod::class); if ($parentFunctionLike !== $classMethod) { return \false; } @@ -250,10 +250,10 @@ final class BetterNodeFinder /** * @return Assign|null */ - public function findPreviousAssignToExpr(\PhpParser\Node\Expr $expr) : ?\PhpParser\Node + public function findPreviousAssignToExpr(Expr $expr) : ?Node { - return $this->findFirstPrevious($expr, function (\PhpParser\Node $node) use($expr) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + return $this->findFirstPrevious($expr, function (Node $node) use($expr) : bool { + if (!$node instanceof Assign) { return \false; } return $this->nodeComparator->areNodesEqual($node->var, $expr); @@ -264,15 +264,15 @@ final class BetterNodeFinder * * @param callable(Node $node): bool $filter */ - public function findFirstInlinedPrevious(\PhpParser\Node $node, callable $filter) : ?\PhpParser\Node + public function findFirstInlinedPrevious(Node $node, callable $filter) : ?Node { - $previousNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_NODE); - if (!$previousNode instanceof \PhpParser\Node) { + $previousNode = $node->getAttribute(AttributeKey::PREVIOUS_NODE); + if (!$previousNode instanceof Node) { return null; } $foundNode = $this->findFirst($previousNode, $filter); // we found what we need - if ($foundNode instanceof \PhpParser\Node) { + if ($foundNode instanceof Node) { return $foundNode; } return $this->findFirstInlinedPrevious($previousNode, $filter); @@ -282,18 +282,18 @@ final class BetterNodeFinder * * @param callable(Node $node): bool $filter */ - public function findFirstPrevious(\PhpParser\Node $node, callable $filter) : ?\PhpParser\Node + public function findFirstPrevious(Node $node, callable $filter) : ?Node { $foundNode = $this->findFirstInlinedPrevious($node, $filter); // we found what we need - if ($foundNode instanceof \PhpParser\Node) { + if ($foundNode instanceof Node) { return $foundNode; } - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\FunctionLike) { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof FunctionLike) { return null; } - if ($parent instanceof \PhpParser\Node) { + if ($parent instanceof Node) { return $this->findFirstPrevious($parent, $filter); } return null; @@ -302,36 +302,36 @@ final class BetterNodeFinder * @template T of Node * @param array> $types */ - public function findFirstPreviousOfTypes(\PhpParser\Node $mainNode, array $types) : ?\PhpParser\Node + public function findFirstPreviousOfTypes(Node $mainNode, array $types) : ?Node { - return $this->findFirstPrevious($mainNode, function (\PhpParser\Node $node) use($types) : bool { + return $this->findFirstPrevious($mainNode, function (Node $node) use($types) : bool { return $this->typeChecker->isInstanceOf($node, $types); }); } /** * @param callable(Node $node): bool $filter */ - public function findFirstNext(\PhpParser\Node $node, callable $filter) : ?\PhpParser\Node + public function findFirstNext(Node $node, callable $filter) : ?Node { - $next = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); - if ($next instanceof \PhpParser\Node) { - if ($next instanceof \PhpParser\Node\Stmt\Return_ && $next->expr === null) { - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\Stmt\Case_) { + $next = $node->getAttribute(AttributeKey::NEXT_NODE); + if ($next instanceof Node) { + if ($next instanceof Return_ && $next->expr === null) { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Case_) { return null; } } $found = $this->findFirst($next, $filter); - if ($found instanceof \PhpParser\Node) { + if ($found instanceof Node) { return $found; } return $this->findFirstNext($next, $filter); } - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\Stmt\Return_ || $parent instanceof \PhpParser\Node\FunctionLike) { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof Return_ || $parent instanceof FunctionLike) { return null; } - if ($parent instanceof \PhpParser\Node) { + if ($parent instanceof Node) { return $this->findFirstNext($parent, $filter); } return null; @@ -344,23 +344,23 @@ final class BetterNodeFinder { // assign of empty string to something $scopeNode = $this->findParentScope($expr); - if (!$scopeNode instanceof \PhpParser\Node) { + if (!$scopeNode instanceof Node) { return []; } - if ($expr instanceof \PhpParser\Node\Expr\Variable) { + if ($expr instanceof Variable) { $exprName = $this->nodeNameResolver->getName($expr); if ($exprName === null) { return []; } - $variables = $this->findInstancesOf($scopeNode, [\PhpParser\Node\Expr\Variable::class]); - return \array_filter($variables, function (\PhpParser\Node\Expr\Variable $variable) use($exprName) : bool { + $variables = $this->findInstancesOf($scopeNode, [Variable::class]); + return \array_filter($variables, function (Variable $variable) use($exprName) : bool { return $this->nodeNameResolver->isName($variable, $exprName); }); } - if ($expr instanceof \PhpParser\Node\Stmt\Property) { + if ($expr instanceof Property) { $singleProperty = $expr->props[0]; $exprName = $this->nodeNameResolver->getName($singleProperty->name); - } elseif ($expr instanceof \PhpParser\Node\Expr\StaticPropertyFetch || $expr instanceof \PhpParser\Node\Expr\PropertyFetch) { + } elseif ($expr instanceof StaticPropertyFetch || $expr instanceof PropertyFetch) { $exprName = $this->nodeNameResolver->getName($expr->name); } else { return []; @@ -368,7 +368,7 @@ final class BetterNodeFinder if ($exprName === null) { return []; } - $propertyFetches = $this->findInstancesOf($scopeNode, [\PhpParser\Node\Expr\PropertyFetch::class, \PhpParser\Node\Expr\StaticPropertyFetch::class]); + $propertyFetches = $this->findInstancesOf($scopeNode, [PropertyFetch::class, StaticPropertyFetch::class]); return \array_filter($propertyFetches, function ($propertyFetch) use($exprName) : bool { return $this->nodeNameResolver->isName($propertyFetch->name, $exprName); }); @@ -386,7 +386,7 @@ final class BetterNodeFinder foreach ($types as $type) { $foundNodes = $this->findInstanceOf((array) $functionLike->stmts, $type); foreach ($foundNodes as $foundNode) { - $parentFunctionLike = $this->findParentByTypes($foundNode, [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\Closure::class]); + $parentFunctionLike = $this->findParentByTypes($foundNode, [ClassMethod::class, Function_::class, Closure::class]); if ($parentFunctionLike === $functionLike) { return \true; } @@ -414,7 +414,7 @@ final class BetterNodeFinder continue; } foreach ($nodes as $key => $node) { - $parentFunctionLike = $this->findParentByTypes($node, [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\Closure::class]); + $parentFunctionLike = $this->findParentByTypes($node, [ClassMethod::class, Function_::class, Closure::class]); if ($parentFunctionLike !== $functionLike) { unset($nodes[$key]); } @@ -430,29 +430,29 @@ final class BetterNodeFinder * @param callable(Node $node): bool $filter * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $functionLike */ - public function findFirstInFunctionLikeScoped($functionLike, callable $filter) : ?\PhpParser\Node + public function findFirstInFunctionLikeScoped($functionLike, callable $filter) : ?Node { $foundNode = $this->findFirst((array) $functionLike->stmts, $filter); - if (!$foundNode instanceof \PhpParser\Node) { + if (!$foundNode instanceof Node) { return null; } - $parentFunctionLike = $this->findParentByTypes($foundNode, [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\Closure::class, \PhpParser\Node\Stmt\Class_::class]); + $parentFunctionLike = $this->findParentByTypes($foundNode, [ClassMethod::class, Function_::class, Closure::class, Class_::class]); if ($parentFunctionLike !== $functionLike) { return null; } return $foundNode; } - public function resolveCurrentStatement(\PhpParser\Node $node) : ?\PhpParser\Node\Stmt + public function resolveCurrentStatement(Node $node) : ?Stmt { - if ($node instanceof \PhpParser\Node\Stmt) { + if ($node instanceof Stmt) { return $node; } $currentStmt = $node; - while ($currentStmt = $currentStmt->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE)) { - if ($currentStmt instanceof \PhpParser\Node\Stmt) { + while ($currentStmt = $currentStmt->getAttribute(AttributeKey::PARENT_NODE)) { + if ($currentStmt instanceof Stmt) { return $currentStmt; } - if (!$currentStmt instanceof \PhpParser\Node) { + if (!$currentStmt instanceof Node) { return null; } } @@ -463,9 +463,9 @@ final class BetterNodeFinder * @param \PhpParser\Node|mixed[] $nodes * @param class-string $type */ - private function findInstanceOfName($nodes, string $type, string $name) : ?\PhpParser\Node + private function findInstanceOfName($nodes, string $type, string $name) : ?Node { - \RectorPrefix20220607\Webmozart\Assert\Assert::isAOf($type, \PhpParser\Node::class); + Assert::isAOf($type, Node::class); $foundInstances = $this->nodeFinder->findInstanceOf($nodes, $type); foreach ($foundInstances as $foundInstance) { if (!$this->nodeNameResolver->isName($foundInstance, $name)) { @@ -478,8 +478,8 @@ final class BetterNodeFinder /** * @return \PhpParser\Node|null */ - private function findParentScope(\PhpParser\Node $node) + private function findParentScope(Node $node) { - return $this->findParentByTypes($node, [\PhpParser\Node\Expr\Closure::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Class_::class, \PhpParser\Node\Stmt\Namespace_::class]); + return $this->findParentByTypes($node, [Closure::class, Function_::class, ClassMethod::class, Class_::class, Namespace_::class]); } } diff --git a/src/PhpParser/Node/CustomNode/FileWithoutNamespace.php b/src/PhpParser/Node/CustomNode/FileWithoutNamespace.php index 1f5f982f57e..6e93b8a2e9b 100644 --- a/src/PhpParser/Node/CustomNode/FileWithoutNamespace.php +++ b/src/PhpParser/Node/CustomNode/FileWithoutNamespace.php @@ -7,7 +7,7 @@ use PhpParser\Node\Stmt; /** * Inspired by https://github.com/phpstan/phpstan-src/commit/ed81c3ad0b9877e6122c79b4afda9d10f3994092 */ -final class FileWithoutNamespace extends \PhpParser\Node\Stmt +final class FileWithoutNamespace extends Stmt { /** * @var Stmt[] diff --git a/src/PhpParser/Node/NamedVariableFactory.php b/src/PhpParser/Node/NamedVariableFactory.php index 56c2fa1b70b..db94299a5d0 100644 --- a/src/PhpParser/Node/NamedVariableFactory.php +++ b/src/PhpParser/Node/NamedVariableFactory.php @@ -20,19 +20,19 @@ final class NamedVariableFactory * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\Naming\Naming\VariableNaming $variableNaming, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(VariableNaming $variableNaming, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) { $this->variableNaming = $variableNaming; $this->betterNodeFinder = $betterNodeFinder; } - public function createVariable(\PhpParser\Node $node, string $variableName) : \PhpParser\Node\Expr\Variable + public function createVariable(Node $node, string $variableName) : Variable { $currentStmt = $this->betterNodeFinder->resolveCurrentStatement($node); - if (!$currentStmt instanceof \PhpParser\Node) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$currentStmt instanceof Node) { + throw new ShouldNotHappenException(); } - $scope = $currentStmt->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $currentStmt->getAttribute(AttributeKey::SCOPE); $variableName = $this->variableNaming->createCountedValueName($variableName, $scope); - return new \PhpParser\Node\Expr\Variable($variableName); + return new Variable($variableName); } } diff --git a/src/PhpParser/Node/NodeFactory.php b/src/PhpParser/Node/NodeFactory.php index 14c075c0b81..fa598e9321d 100644 --- a/src/PhpParser/Node/NodeFactory.php +++ b/src/PhpParser/Node/NodeFactory.php @@ -117,7 +117,7 @@ final class NodeFactory * @var \Rector\Core\NodeDecorator\PropertyTypeDecorator */ private $propertyTypeDecorator; - public function __construct(\PhpParser\BuilderFactory $builderFactory, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\Core\Configuration\CurrentNodeProvider $currentNodeProvider, \Rector\Core\PhpParser\AstResolver $reflectionAstResolver, \Rector\Core\NodeDecorator\PropertyTypeDecorator $propertyTypeDecorator) + public function __construct(BuilderFactory $builderFactory, PhpDocInfoFactory $phpDocInfoFactory, PhpVersionProvider $phpVersionProvider, StaticTypeMapper $staticTypeMapper, NodeNameResolver $nodeNameResolver, PhpDocTypeChanger $phpDocTypeChanger, CurrentNodeProvider $currentNodeProvider, AstResolver $reflectionAstResolver, PropertyTypeDecorator $propertyTypeDecorator) { $this->builderFactory = $builderFactory; $this->phpDocInfoFactory = $phpDocInfoFactory; @@ -132,16 +132,16 @@ final class NodeFactory /** * Creates "SomeClass::CONSTANT" */ - public function createShortClassConstFetch(string $shortClassName, string $constantName) : \PhpParser\Node\Expr\ClassConstFetch + public function createShortClassConstFetch(string $shortClassName, string $constantName) : ClassConstFetch { - $name = new \PhpParser\Node\Name($shortClassName); + $name = new Name($shortClassName); return $this->createClassConstFetchFromName($name, $constantName); } /** * @param string|ObjectReference::* $className * Creates "\SomeClass::CONSTANT" */ - public function createClassConstFetch(string $className, string $constantName) : \PhpParser\Node\Expr\ClassConstFetch + public function createClassConstFetch(string $className, string $constantName) : ClassConstFetch { $name = $this->createName($className); return $this->createClassConstFetchFromName($name, $constantName); @@ -150,7 +150,7 @@ final class NodeFactory * @param string|ObjectReference::* $className * Creates "\SomeClass::class" */ - public function createClassConstReference(string $className) : \PhpParser\Node\Expr\ClassConstFetch + public function createClassConstReference(string $className) : ClassConstFetch { return $this->createClassConstFetch($className, 'class'); } @@ -159,7 +159,7 @@ final class NodeFactory * * @param mixed[] $items */ - public function createArray(array $items) : \PhpParser\Node\Expr\Array_ + public function createArray(array $items) : Array_ { $arrayItems = []; $defaultKey = 0; @@ -168,7 +168,7 @@ final class NodeFactory $arrayItems[] = $this->createArrayItem($item, $customKey); ++$defaultKey; } - return new \PhpParser\Node\Expr\Array_($arrayItems); + return new Array_($arrayItems); } /** * Creates "($args)" @@ -186,54 +186,54 @@ final class NodeFactory /** * Creates $this->property = $property; */ - public function createPropertyAssignment(string $propertyName) : \PhpParser\Node\Expr\Assign + public function createPropertyAssignment(string $propertyName) : Assign { - $variable = new \PhpParser\Node\Expr\Variable($propertyName); + $variable = new Variable($propertyName); return $this->createPropertyAssignmentWithExpr($propertyName, $variable); } - public function createPropertyAssignmentWithExpr(string $propertyName, \PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr\Assign + public function createPropertyAssignmentWithExpr(string $propertyName, Expr $expr) : Assign { $propertyFetch = $this->createPropertyFetch(self::THIS, $propertyName); - return new \PhpParser\Node\Expr\Assign($propertyFetch, $expr); + return new Assign($propertyFetch, $expr); } /** * @param mixed $argument */ - public function createArg($argument) : \PhpParser\Node\Arg + public function createArg($argument) : Arg { - return new \PhpParser\Node\Arg(\PhpParser\BuilderHelpers::normalizeValue($argument)); + return new Arg(BuilderHelpers::normalizeValue($argument)); } - public function createPublicMethod(string $name) : \PhpParser\Node\Stmt\ClassMethod + public function createPublicMethod(string $name) : ClassMethod { - $methodBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\MethodBuilder($name); + $methodBuilder = new MethodBuilder($name); $methodBuilder->makePublic(); return $methodBuilder->getNode(); } - public function createParamFromNameAndType(string $name, ?\PHPStan\Type\Type $type) : \PhpParser\Node\Param + public function createParamFromNameAndType(string $name, ?Type $type) : Param { - $paramBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\ParamBuilder($name); + $paramBuilder = new ParamBuilder($name); if ($type !== null) { - $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM); + $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, TypeKind::PARAM); if ($typeNode !== null) { $paramBuilder->setType($typeNode); } } return $paramBuilder->getNode(); } - public function createPublicInjectPropertyFromNameAndType(string $name, ?\PHPStan\Type\Type $type) : \PhpParser\Node\Stmt\Property + public function createPublicInjectPropertyFromNameAndType(string $name, ?Type $type) : Property { - $propertyBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\PropertyBuilder($name); + $propertyBuilder = new PropertyBuilder($name); $propertyBuilder->makePublic(); $property = $propertyBuilder->getNode(); $this->propertyTypeDecorator->decorate($property, $type); // add @inject $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); - $phpDocInfo->addPhpDocTagNode(new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode('@inject', new \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode(''))); + $phpDocInfo->addPhpDocTagNode(new PhpDocTagNode('@inject', new GenericTagValueNode(''))); return $property; } - public function createPrivatePropertyFromNameAndType(string $name, ?\PHPStan\Type\Type $type) : \PhpParser\Node\Stmt\Property + public function createPrivatePropertyFromNameAndType(string $name, ?Type $type) : Property { - $propertyBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\PropertyBuilder($name); + $propertyBuilder = new PropertyBuilder($name); $propertyBuilder->makePrivate(); $property = $propertyBuilder->getNode(); $this->propertyTypeDecorator->decorate($property, $type); @@ -242,123 +242,123 @@ final class NodeFactory /** * @param mixed[] $arguments */ - public function createLocalMethodCall(string $method, array $arguments = []) : \PhpParser\Node\Expr\MethodCall + public function createLocalMethodCall(string $method, array $arguments = []) : MethodCall { - $variable = new \PhpParser\Node\Expr\Variable('this'); + $variable = new Variable('this'); return $this->createMethodCall($variable, $method, $arguments); } /** * @param mixed[] $arguments * @param string|\PhpParser\Node\Expr $variable */ - public function createMethodCall($variable, string $method, array $arguments = []) : \PhpParser\Node\Expr\MethodCall + public function createMethodCall($variable, string $method, array $arguments = []) : MethodCall { if (\is_string($variable)) { - $variable = new \PhpParser\Node\Expr\Variable($variable); + $variable = new Variable($variable); } - if ($variable instanceof \PhpParser\Node\Expr\PropertyFetch) { - $variable = new \PhpParser\Node\Expr\PropertyFetch($variable->var, $variable->name); + if ($variable instanceof PropertyFetch) { + $variable = new PropertyFetch($variable->var, $variable->name); } - if ($variable instanceof \PhpParser\Node\Expr\StaticPropertyFetch) { - $variable = new \PhpParser\Node\Expr\StaticPropertyFetch($variable->class, $variable->name); + if ($variable instanceof StaticPropertyFetch) { + $variable = new StaticPropertyFetch($variable->class, $variable->name); } - if ($variable instanceof \PhpParser\Node\Expr\MethodCall) { - $variable = new \PhpParser\Node\Expr\MethodCall($variable->var, $variable->name, $variable->args); + if ($variable instanceof MethodCall) { + $variable = new MethodCall($variable->var, $variable->name, $variable->args); } return $this->builderFactory->methodCall($variable, $method, $arguments); } /** * @param string|\PhpParser\Node\Expr $variable */ - public function createPropertyFetch($variable, string $property) : \PhpParser\Node\Expr\PropertyFetch + public function createPropertyFetch($variable, string $property) : PropertyFetch { if (\is_string($variable)) { - $variable = new \PhpParser\Node\Expr\Variable($variable); + $variable = new Variable($variable); } return $this->builderFactory->propertyFetch($variable, $property); } /** * @param Param[] $params */ - public function createParentConstructWithParams(array $params) : \PhpParser\Node\Expr\StaticCall + public function createParentConstructWithParams(array $params) : StaticCall { - return new \PhpParser\Node\Expr\StaticCall(new \PhpParser\Node\Name(\Rector\Core\Enum\ObjectReference::PARENT), new \PhpParser\Node\Identifier(\Rector\Core\ValueObject\MethodName::CONSTRUCT), $this->createArgsFromParams($params)); + return new StaticCall(new Name(ObjectReference::PARENT), new Identifier(MethodName::CONSTRUCT), $this->createArgsFromParams($params)); } - public function createProperty(string $name) : \PhpParser\Node\Stmt\Property + public function createProperty(string $name) : Property { - $propertyBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\PropertyBuilder($name); + $propertyBuilder = new PropertyBuilder($name); $property = $propertyBuilder->getNode(); $this->phpDocInfoFactory->createFromNode($property); return $property; } - public function createPrivateProperty(string $name) : \PhpParser\Node\Stmt\Property + public function createPrivateProperty(string $name) : Property { - $propertyBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\PropertyBuilder($name); + $propertyBuilder = new PropertyBuilder($name); $propertyBuilder->makePrivate(); $property = $propertyBuilder->getNode(); $this->phpDocInfoFactory->createFromNode($property); return $property; } - public function createPublicProperty(string $name) : \PhpParser\Node\Stmt\Property + public function createPublicProperty(string $name) : Property { - $propertyBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\PropertyBuilder($name); + $propertyBuilder = new PropertyBuilder($name); $propertyBuilder->makePublic(); $property = $propertyBuilder->getNode(); $this->phpDocInfoFactory->createFromNode($property); return $property; } - public function createGetterClassMethod(string $propertyName, \PHPStan\Type\Type $type) : \PhpParser\Node\Stmt\ClassMethod + public function createGetterClassMethod(string $propertyName, Type $type) : ClassMethod { - $methodBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\MethodBuilder('get' . \ucfirst($propertyName)); + $methodBuilder = new MethodBuilder('get' . \ucfirst($propertyName)); $methodBuilder->makePublic(); - $propertyFetch = new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable(self::THIS), $propertyName); - $return = new \PhpParser\Node\Stmt\Return_($propertyFetch); + $propertyFetch = new PropertyFetch(new Variable(self::THIS), $propertyName); + $return = new Return_($propertyFetch); $methodBuilder->addStmt($return); - $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN); + $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, TypeKind::RETURN); if ($typeNode !== null) { $methodBuilder->setReturnType($typeNode); } return $methodBuilder->getNode(); } - public function createSetterClassMethod(string $propertyName, \PHPStan\Type\Type $type) : \PhpParser\Node\Stmt\ClassMethod + public function createSetterClassMethod(string $propertyName, Type $type) : ClassMethod { - $methodBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\MethodBuilder('set' . \ucfirst($propertyName)); + $methodBuilder = new MethodBuilder('set' . \ucfirst($propertyName)); $methodBuilder->makePublic(); - $variable = new \PhpParser\Node\Expr\Variable($propertyName); + $variable = new Variable($propertyName); $param = $this->createParamWithType($variable, $type); $methodBuilder->addParam($param); - $propertyFetch = new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable(self::THIS), $propertyName); - $assign = new \PhpParser\Node\Expr\Assign($propertyFetch, $variable); + $propertyFetch = new PropertyFetch(new Variable(self::THIS), $propertyName); + $assign = new Assign($propertyFetch, $variable); $methodBuilder->addStmt($assign); - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::VOID_TYPE)) { - $methodBuilder->setReturnType(new \PhpParser\Node\Name('void')); + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::VOID_TYPE)) { + $methodBuilder->setReturnType(new Name('void')); } return $methodBuilder->getNode(); } /** * @param Expr[] $exprs */ - public function createConcat(array $exprs) : ?\PhpParser\Node\Expr\BinaryOp\Concat + public function createConcat(array $exprs) : ?Concat { if (\count($exprs) < 2) { return null; } $previousConcat = \array_shift($exprs); foreach ($exprs as $expr) { - $previousConcat = new \PhpParser\Node\Expr\BinaryOp\Concat($previousConcat, $expr); + $previousConcat = new Concat($previousConcat, $expr); } - if (!$previousConcat instanceof \PhpParser\Node\Expr\BinaryOp\Concat) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$previousConcat instanceof Concat) { + throw new ShouldNotHappenException(); } return $previousConcat; } - public function createClosureFromClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : \PhpParser\Node\Expr\Closure + public function createClosureFromClassMethod(ClassMethod $classMethod) : Closure { $classMethodName = $this->nodeNameResolver->getName($classMethod); $args = $this->createArgs($classMethod->params); - $methodCall = new \PhpParser\Node\Expr\MethodCall(new \PhpParser\Node\Expr\Variable(self::THIS), $classMethodName, $args); - $return = new \PhpParser\Node\Stmt\Return_($methodCall); - return new \PhpParser\Node\Expr\Closure(['params' => $classMethod->params, 'stmts' => [$return], 'returnType' => $classMethod->returnType]); + $methodCall = new MethodCall(new Variable(self::THIS), $classMethodName, $args); + $return = new Return_($methodCall); + return new Closure(['params' => $classMethod->params, 'stmts' => [$return], 'returnType' => $classMethod->returnType]); } /** * @param string[] $names @@ -368,8 +368,8 @@ final class NodeFactory { $uses = []; foreach ($names as $name) { - $useUse = new \PhpParser\Node\Stmt\UseUse(new \PhpParser\Node\Name($name)); - $uses[] = new \PhpParser\Node\Stmt\Use_([$useUse]); + $useUse = new UseUse(new Name($name)); + $uses[] = new Use_([$useUse]); } return $uses; } @@ -377,24 +377,24 @@ final class NodeFactory * @param string|ObjectReference::* $class * @param Node[] $args */ - public function createStaticCall(string $class, string $method, array $args = []) : \PhpParser\Node\Expr\StaticCall + public function createStaticCall(string $class, string $method, array $args = []) : StaticCall { $name = $this->createName($class); $args = $this->createArgs($args); - return new \PhpParser\Node\Expr\StaticCall($name, $method, $args); + return new StaticCall($name, $method, $args); } /** * @param mixed[] $arguments */ - public function createFuncCall(string $name, array $arguments = []) : \PhpParser\Node\Expr\FuncCall + public function createFuncCall(string $name, array $arguments = []) : FuncCall { $arguments = $this->createArgs($arguments); - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name($name), $arguments); + return new FuncCall(new Name($name), $arguments); } - public function createSelfFetchConstant(string $constantName) : \PhpParser\Node\Expr\ClassConstFetch + public function createSelfFetchConstant(string $constantName) : ClassConstFetch { - $name = new \PhpParser\Node\Name(\Rector\Core\Enum\ObjectReference::SELF); - return new \PhpParser\Node\Expr\ClassConstFetch($name, $constantName); + $name = new Name(ObjectReference::SELF); + return new ClassConstFetch($name, $constantName); } /** * @param Param[] $params @@ -404,66 +404,66 @@ final class NodeFactory { $args = []; foreach ($params as $param) { - $args[] = new \PhpParser\Node\Arg($param->var); + $args[] = new Arg($param->var); } return $args; } - public function createNull() : \PhpParser\Node\Expr\ConstFetch + public function createNull() : ConstFetch { - return new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('null')); + return new ConstFetch(new Name('null')); } - public function createPromotedPropertyParam(\Rector\PostRector\ValueObject\PropertyMetadata $propertyMetadata) : \PhpParser\Node\Param + public function createPromotedPropertyParam(PropertyMetadata $propertyMetadata) : Param { - $paramBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\ParamBuilder($propertyMetadata->getName()); + $paramBuilder = new ParamBuilder($propertyMetadata->getName()); $propertyType = $propertyMetadata->getType(); if ($propertyType !== null) { - $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY); + $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, TypeKind::PROPERTY); if ($typeNode !== null) { $paramBuilder->setType($typeNode); } } $param = $paramBuilder->getNode(); $propertyFlags = $propertyMetadata->getFlags(); - $param->flags = $propertyFlags !== 0 ? $propertyFlags : \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE; + $param->flags = $propertyFlags !== 0 ? $propertyFlags : Class_::MODIFIER_PRIVATE; return $param; } - public function createFalse() : \PhpParser\Node\Expr\ConstFetch + public function createFalse() : ConstFetch { - return new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('false')); + return new ConstFetch(new Name('false')); } - public function createTrue() : \PhpParser\Node\Expr\ConstFetch + public function createTrue() : ConstFetch { - return new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('true')); + return new ConstFetch(new Name('true')); } - public function createClosureFromMethodReflection(\PHPStan\Reflection\MethodReflection $methodReflection) : \PhpParser\Node\Expr\Closure + public function createClosureFromMethodReflection(MethodReflection $methodReflection) : Closure { $classMethod = $this->reflectionAstResolver->resolveClassMethodFromMethodReflection($methodReflection); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$classMethod instanceof ClassMethod) { + throw new ShouldNotHappenException(); } return $this->createClosureFromClassMethod($classMethod); } /** * @param string|ObjectReference::* $constantName */ - public function createClassConstFetchFromName(\PhpParser\Node\Name $className, string $constantName) : \PhpParser\Node\Expr\ClassConstFetch + public function createClassConstFetchFromName(Name $className, string $constantName) : ClassConstFetch { $classConstFetch = $this->builderFactory->classConstFetch($className, $constantName); $classNameString = $className->toString(); - if (\in_array($classNameString, [\Rector\Core\Enum\ObjectReference::SELF, \Rector\Core\Enum\ObjectReference::STATIC], \true)) { + if (\in_array($classNameString, [ObjectReference::SELF, ObjectReference::STATIC], \true)) { $currentNode = $this->currentNodeProvider->getNode(); if ($currentNode !== null) { - $classConstFetch->class->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::RESOLVED_NAME, $className); + $classConstFetch->class->setAttribute(AttributeKey::RESOLVED_NAME, $className); } } else { - $classConstFetch->class->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::RESOLVED_NAME, $classNameString); + $classConstFetch->class->setAttribute(AttributeKey::RESOLVED_NAME, $classNameString); } return $classConstFetch; } /** * @param array $newNodes */ - public function createReturnBooleanAnd(array $newNodes) : ?\PhpParser\Node\Expr + public function createReturnBooleanAnd(array $newNodes) : ?Expr { if ($newNodes === []) { return null; @@ -473,15 +473,15 @@ final class NodeFactory } return $this->createBooleanAndFromNodes($newNodes); } - public function createClassConstant(string $name, \PhpParser\Node\Expr $expr, int $modifier) : \PhpParser\Node\Stmt\ClassConst + public function createClassConstant(string $name, Expr $expr, int $modifier) : ClassConst { - $expr = \PhpParser\BuilderHelpers::normalizeValue($expr); - $const = new \PhpParser\Node\Const_($name, $expr); - $classConst = new \PhpParser\Node\Stmt\ClassConst([$const]); + $expr = BuilderHelpers::normalizeValue($expr); + $const = new Const_($name, $expr); + $classConst = new ClassConst([$const]); $classConst->flags |= $modifier; // add @var type by default $staticType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($expr); - if (!$staticType instanceof \PHPStan\Type\MixedType) { + if (!$staticType instanceof MixedType) { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classConst); $this->phpDocTypeChanger->changeVarType($phpDocInfo, $staticType); } @@ -491,33 +491,33 @@ final class NodeFactory * @param mixed $item * @param string|int|null $key */ - private function createArrayItem($item, $key = null) : \PhpParser\Node\Expr\ArrayItem + private function createArrayItem($item, $key = null) : ArrayItem { $arrayItem = null; - if ($item instanceof \PhpParser\Node\Expr\Variable || $item instanceof \PhpParser\Node\Expr\MethodCall || $item instanceof \PhpParser\Node\Expr\StaticCall || $item instanceof \PhpParser\Node\Expr\FuncCall || $item instanceof \PhpParser\Node\Expr\BinaryOp\Concat || $item instanceof \PhpParser\Node\Scalar || $item instanceof \PhpParser\Node\Expr\Cast) { - $arrayItem = new \PhpParser\Node\Expr\ArrayItem($item); - } elseif ($item instanceof \PhpParser\Node\Identifier) { - $string = new \PhpParser\Node\Scalar\String_($item->toString()); - $arrayItem = new \PhpParser\Node\Expr\ArrayItem($string); - } elseif (\is_scalar($item) || $item instanceof \PhpParser\Node\Expr\Array_) { - $itemValue = \PhpParser\BuilderHelpers::normalizeValue($item); - $arrayItem = new \PhpParser\Node\Expr\ArrayItem($itemValue); + if ($item instanceof Variable || $item instanceof MethodCall || $item instanceof StaticCall || $item instanceof FuncCall || $item instanceof Concat || $item instanceof Scalar || $item instanceof Cast) { + $arrayItem = new ArrayItem($item); + } elseif ($item instanceof Identifier) { + $string = new String_($item->toString()); + $arrayItem = new ArrayItem($string); + } elseif (\is_scalar($item) || $item instanceof Array_) { + $itemValue = BuilderHelpers::normalizeValue($item); + $arrayItem = new ArrayItem($itemValue); } elseif (\is_array($item)) { - $arrayItem = new \PhpParser\Node\Expr\ArrayItem($this->createArray($item)); + $arrayItem = new ArrayItem($this->createArray($item)); } - if ($item === null || $item instanceof \PhpParser\Node\Expr\ClassConstFetch) { - $itemValue = \PhpParser\BuilderHelpers::normalizeValue($item); - $arrayItem = new \PhpParser\Node\Expr\ArrayItem($itemValue); + if ($item === null || $item instanceof ClassConstFetch) { + $itemValue = BuilderHelpers::normalizeValue($item); + $arrayItem = new ArrayItem($itemValue); } - if ($item instanceof \PhpParser\Node\Arg) { - $arrayItem = new \PhpParser\Node\Expr\ArrayItem($item->value); + if ($item instanceof Arg) { + $arrayItem = new ArrayItem($item->value); } if ($arrayItem !== null) { $this->decorateArrayItemWithKey($key, $arrayItem); return $arrayItem; } $nodeClass = \is_object($item) ? \get_class($item) : $item; - throw new \Rector\Core\Exception\NotImplementedYetException(\sprintf('Not implemented yet. Go to "%s()" and add check for "%s" node.', __METHOD__, (string) $nodeClass)); + throw new NotImplementedYetException(\sprintf('Not implemented yet. Go to "%s()" and add check for "%s" node.', __METHOD__, (string) $nodeClass)); } /** * @param mixed $value @@ -525,7 +525,7 @@ final class NodeFactory */ private function normalizeArgValue($value) { - if ($value instanceof \PhpParser\Node\Param) { + if ($value instanceof Param) { return $value->var; } return $value; @@ -533,29 +533,29 @@ final class NodeFactory /** * @param int|string|null $key */ - private function decorateArrayItemWithKey($key, \PhpParser\Node\Expr\ArrayItem $arrayItem) : void + private function decorateArrayItemWithKey($key, ArrayItem $arrayItem) : void { if ($key !== null) { - $arrayItem->key = \PhpParser\BuilderHelpers::normalizeValue($key); + $arrayItem->key = BuilderHelpers::normalizeValue($key); } } /** * @param NotIdentical[]|BooleanAnd[] $exprs */ - private function createBooleanAndFromNodes(array $exprs) : \PhpParser\Node\Expr\BinaryOp\BooleanAnd + private function createBooleanAndFromNodes(array $exprs) : BooleanAnd { /** @var NotIdentical|BooleanAnd $booleanAnd */ $booleanAnd = \array_shift($exprs); foreach ($exprs as $expr) { - $booleanAnd = new \PhpParser\Node\Expr\BinaryOp\BooleanAnd($booleanAnd, $expr); + $booleanAnd = new BooleanAnd($booleanAnd, $expr); } /** @var BooleanAnd $booleanAnd */ return $booleanAnd; } - private function createParamWithType(\PhpParser\Node\Expr\Variable $variable, \PHPStan\Type\Type $type) : \PhpParser\Node\Param + private function createParamWithType(Variable $variable, Type $type) : Param { - $param = new \PhpParser\Node\Param($variable); - $phpParserTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM); + $param = new Param($variable); + $phpParserTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, TypeKind::PARAM); $param->type = $phpParserTypeNode; return $param; } @@ -565,9 +565,9 @@ final class NodeFactory */ private function createName(string $className) { - if (\in_array($className, [\Rector\Core\Enum\ObjectReference::PARENT, \Rector\Core\Enum\ObjectReference::SELF, \Rector\Core\Enum\ObjectReference::STATIC], \true)) { - return new \PhpParser\Node\Name($className); + if (\in_array($className, [ObjectReference::PARENT, ObjectReference::SELF, ObjectReference::STATIC], \true)) { + return new Name($className); } - return new \PhpParser\Node\Name\FullyQualified($className); + return new FullyQualified($className); } } diff --git a/src/PhpParser/Node/Value/ValueResolver.php b/src/PhpParser/Node/Value/ValueResolver.php index bda37fd152e..92c41e58ded 100644 --- a/src/PhpParser/Node/Value/ValueResolver.php +++ b/src/PhpParser/Node/Value/ValueResolver.php @@ -63,7 +63,7 @@ final class ValueResolver * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\Core\NodeAnalyzer\ConstFetchAnalyzer $constFetchAnalyzer, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver, ConstFetchAnalyzer $constFetchAnalyzer, ReflectionProvider $reflectionProvider, CurrentFileProvider $currentFileProvider, BetterNodeFinder $betterNodeFinder) { $this->nodeNameResolver = $nodeNameResolver; $this->nodeTypeResolver = $nodeTypeResolver; @@ -75,32 +75,32 @@ final class ValueResolver /** * @param mixed $value */ - public function isValue(\PhpParser\Node\Expr $expr, $value) : bool + public function isValue(Expr $expr, $value) : bool { return $this->getValue($expr) === $value; } - public function getStringValue(\PhpParser\Node\Expr $expr) : string + public function getStringValue(Expr $expr) : string { $resolvedValue = $this->getValue($expr); if (!\is_string($resolvedValue)) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } return $resolvedValue; } /** * @return mixed|null */ - public function getValue(\PhpParser\Node\Expr $expr, bool $resolvedClassReference = \false) + public function getValue(Expr $expr, bool $resolvedClassReference = \false) { - if ($expr instanceof \PhpParser\Node\Expr\BinaryOp\Concat) { + if ($expr instanceof Concat) { return $this->processConcat($expr, $resolvedClassReference); } - if ($expr instanceof \PhpParser\Node\Expr\ClassConstFetch && $resolvedClassReference) { + if ($expr instanceof ClassConstFetch && $resolvedClassReference) { $class = $this->nodeNameResolver->getName($expr->class); - if (\in_array($class, [\Rector\Core\Enum\ObjectReference::SELF, \Rector\Core\Enum\ObjectReference::STATIC], \true)) { + if (\in_array($class, [ObjectReference::SELF, ObjectReference::STATIC], \true)) { // @todo scope is needed - $classLike = $this->betterNodeFinder->findParentType($expr, \PhpParser\Node\Stmt\ClassLike::class); - if ($classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($expr, ClassLike::class); + if ($classLike instanceof ClassLike) { return (string) $this->nodeNameResolver->getName($classLike); } } @@ -111,20 +111,20 @@ final class ValueResolver try { $constExprEvaluator = $this->getConstExprEvaluator(); $value = $constExprEvaluator->evaluateDirectly($expr); - } catch (\PhpParser\ConstExprEvaluationException $exception) { + } catch (ConstExprEvaluationException $exception) { $value = null; } if ($value !== null) { return $value; } - if ($expr instanceof \PhpParser\Node\Expr\ConstFetch) { + if ($expr instanceof ConstFetch) { return $this->nodeNameResolver->getName($expr); } $nodeStaticType = $this->nodeTypeResolver->getType($expr); - if ($nodeStaticType instanceof \PHPStan\Type\Constant\ConstantArrayType) { + if ($nodeStaticType instanceof ConstantArrayType) { return $this->extractConstantArrayTypeValue($nodeStaticType); } - if ($nodeStaticType instanceof \PHPStan\Type\ConstantScalarType) { + if ($nodeStaticType instanceof ConstantScalarType) { return $nodeStaticType->getValue(); } return null; @@ -132,7 +132,7 @@ final class ValueResolver /** * @param mixed[] $expectedValues */ - public function isValues(\PhpParser\Node\Expr $expr, array $expectedValues) : bool + public function isValues(Expr $expr, array $expectedValues) : bool { foreach ($expectedValues as $expectedValue) { if ($this->isValue($expr, $expectedValue)) { @@ -141,23 +141,23 @@ final class ValueResolver } return \false; } - public function isFalse(\PhpParser\Node $node) : bool + public function isFalse(Node $node) : bool { return $this->constFetchAnalyzer->isFalse($node); } - public function isTrueOrFalse(\PhpParser\Node $node) : bool + public function isTrueOrFalse(Node $node) : bool { return $this->constFetchAnalyzer->isTrueOrFalse($node); } - public function isTrue(\PhpParser\Node $node) : bool + public function isTrue(Node $node) : bool { return $this->constFetchAnalyzer->isTrue($node); } - public function isNull(\PhpParser\Node $node) : bool + public function isNull(Node $node) : bool { return $this->constFetchAnalyzer->isNull($node); } - public function isValueEqual(\PhpParser\Node\Expr $firstExpr, \PhpParser\Node\Expr $secondExpr) : bool + public function isValueEqual(Expr $firstExpr, Expr $secondExpr) : bool { $firstValue = $this->getValue($firstExpr); $secondValue = $this->getValue($secondExpr); @@ -179,36 +179,36 @@ final class ValueResolver } return \true; } - private function processConcat(\PhpParser\Node\Expr\BinaryOp\Concat $concat, bool $resolvedClassReference) : string + private function processConcat(Concat $concat, bool $resolvedClassReference) : string { return $this->getValue($concat->left, $resolvedClassReference) . $this->getValue($concat->right, $resolvedClassReference); } - private function getConstExprEvaluator() : \PhpParser\ConstExprEvaluator + private function getConstExprEvaluator() : ConstExprEvaluator { if ($this->constExprEvaluator !== null) { return $this->constExprEvaluator; } - $this->constExprEvaluator = new \PhpParser\ConstExprEvaluator(function (\PhpParser\Node\Expr $expr) { - if ($expr instanceof \PhpParser\Node\Scalar\MagicConst\Dir) { + $this->constExprEvaluator = new ConstExprEvaluator(function (Expr $expr) { + if ($expr instanceof Dir) { // __DIR__ return $this->resolveDirConstant(); } - if ($expr instanceof \PhpParser\Node\Scalar\MagicConst\File) { + if ($expr instanceof File) { // __FILE__ return $this->resolveFileConstant($expr); } // resolve "SomeClass::SOME_CONST" - if ($expr instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if ($expr instanceof ClassConstFetch) { return $this->resolveClassConstFetch($expr); } - throw new \PhpParser\ConstExprEvaluationException(\sprintf('Expression of type "%s" cannot be evaluated', $expr->getType())); + throw new ConstExprEvaluationException(\sprintf('Expression of type "%s" cannot be evaluated', $expr->getType())); }); return $this->constExprEvaluator; } /** * @return mixed[]|null */ - private function extractConstantArrayTypeValue(\PHPStan\Type\Constant\ConstantArrayType $constantArrayType) : ?array + private function extractConstantArrayTypeValue(ConstantArrayType $constantArrayType) : ?array { $keys = []; foreach ($constantArrayType->getKeyTypes() as $i => $keyType) { @@ -217,11 +217,11 @@ final class ValueResolver } $values = []; foreach ($constantArrayType->getValueTypes() as $i => $valueType) { - if ($valueType instanceof \PHPStan\Type\Constant\ConstantArrayType) { + if ($valueType instanceof ConstantArrayType) { $value = $this->extractConstantArrayTypeValue($valueType); - } elseif ($valueType instanceof \PHPStan\Type\ConstantScalarType) { + } elseif ($valueType instanceof ConstantScalarType) { $value = $valueType->getValue(); - } elseif ($valueType instanceof \PHPStan\Type\TypeWithClassName) { + } elseif ($valueType instanceof TypeWithClassName) { continue; } else { return null; @@ -236,7 +236,7 @@ final class ValueResolver $smartFileInfo = $file->getSmartFileInfo(); return $smartFileInfo->getPath(); } - private function resolveFileConstant(\PhpParser\Node\Scalar\MagicConst\File $file) : string + private function resolveFileConstant(File $file) : string { $file = $this->currentFileProvider->getFile(); $smartFileInfo = $file->getSmartFileInfo(); @@ -245,20 +245,20 @@ final class ValueResolver /** * @return string|mixed */ - private function resolveClassConstFetch(\PhpParser\Node\Expr\ClassConstFetch $classConstFetch) + private function resolveClassConstFetch(ClassConstFetch $classConstFetch) { $class = $this->nodeNameResolver->getName($classConstFetch->class); $constant = $this->nodeNameResolver->getName($classConstFetch->name); if ($class === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } if ($constant === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } - if ($class === \Rector\Core\Enum\ObjectReference::SELF) { - $classLike = $this->betterNodeFinder->findParentType($classConstFetch, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if ($class === ObjectReference::SELF) { + $classLike = $this->betterNodeFinder->findParentType($classConstFetch, ClassLike::class); + if (!$classLike instanceof ClassLike) { + throw new ShouldNotHappenException(); } $class = (string) $this->nodeNameResolver->getName($classLike); } diff --git a/src/PhpParser/NodeFinder/LocalConstantFinder.php b/src/PhpParser/NodeFinder/LocalConstantFinder.php index c61e9ec7fd2..da98a56324c 100644 --- a/src/PhpParser/NodeFinder/LocalConstantFinder.php +++ b/src/PhpParser/NodeFinder/LocalConstantFinder.php @@ -27,20 +27,20 @@ final class LocalConstantFinder * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeTypeResolver $nodeTypeResolver, NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder) { $this->nodeTypeResolver = $nodeTypeResolver; $this->nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; } - public function match(\PhpParser\Node\Expr\ClassConstFetch $classConstFetch) : ?\PhpParser\Node\Const_ + public function match(ClassConstFetch $classConstFetch) : ?Const_ { - $class = $this->betterNodeFinder->findParentType($classConstFetch, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($classConstFetch, Class_::class); + if (!$class instanceof Class_) { return null; } $constantClassType = $this->nodeTypeResolver->getType($classConstFetch->class); - if (!$constantClassType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$constantClassType instanceof TypeWithClassName) { return null; } if (!$this->nodeNameResolver->isName($class, $constantClassType->getClassName())) { @@ -52,7 +52,7 @@ final class LocalConstantFinder } return $this->findConstantByName($class, $constatName); } - private function findConstantByName(\PhpParser\Node\Stmt\Class_ $class, string $constatName) : ?\PhpParser\Node\Const_ + private function findConstantByName(Class_ $class, string $constatName) : ?Const_ { foreach ($class->getConstants() as $classConsts) { foreach ($classConsts->consts as $const) { diff --git a/src/PhpParser/NodeFinder/LocalMethodCallFinder.php b/src/PhpParser/NodeFinder/LocalMethodCallFinder.php index f02fad516b4..ecf723d095a 100644 --- a/src/PhpParser/NodeFinder/LocalMethodCallFinder.php +++ b/src/PhpParser/NodeFinder/LocalMethodCallFinder.php @@ -27,7 +27,7 @@ final class LocalMethodCallFinder * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeTypeResolver $nodeTypeResolver, NodeNameResolver $nodeNameResolver) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeTypeResolver = $nodeTypeResolver; @@ -36,10 +36,10 @@ final class LocalMethodCallFinder /** * @return MethodCall[] */ - public function match(\PhpParser\Node\Stmt\ClassMethod $classMethod) : array + public function match(ClassMethod $classMethod) : array { - $class = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($classMethod, Class_::class); + if (!$class instanceof Class_) { return []; } $className = $this->nodeNameResolver->getName($class); @@ -47,12 +47,12 @@ final class LocalMethodCallFinder return []; } /** @var MethodCall[] $methodCalls */ - $methodCalls = $this->betterNodeFinder->findInstanceOf($class, \PhpParser\Node\Expr\MethodCall::class); + $methodCalls = $this->betterNodeFinder->findInstanceOf($class, MethodCall::class); $classMethodName = $this->nodeNameResolver->getName($classMethod); $matchingMethodCalls = []; foreach ($methodCalls as $methodCall) { $callerType = $this->nodeTypeResolver->getType($methodCall->var); - if (!$callerType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$callerType instanceof TypeWithClassName) { continue; } if ($callerType->getClassName() !== $className) { diff --git a/src/PhpParser/NodeFinder/PropertyFetchFinder.php b/src/PhpParser/NodeFinder/PropertyFetchFinder.php index 4d8219af209..11390e9d492 100644 --- a/src/PhpParser/NodeFinder/PropertyFetchFinder.php +++ b/src/PhpParser/NodeFinder/PropertyFetchFinder.php @@ -53,7 +53,7 @@ final class PropertyFetchFinder * @var \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer */ private $propertyFetchAnalyzer; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\Core\PhpParser\AstResolver $astResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver, ReflectionResolver $reflectionResolver, AstResolver $astResolver, NodeTypeResolver $nodeTypeResolver, PropertyFetchAnalyzer $propertyFetchAnalyzer) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeNameResolver = $nodeNameResolver; @@ -66,7 +66,7 @@ final class PropertyFetchFinder * @return PropertyFetch[]|StaticPropertyFetch[] * @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $propertyOrPromotedParam */ - public function findPrivatePropertyFetches(\PhpParser\Node\Stmt\Class_ $class, $propertyOrPromotedParam) : array + public function findPrivatePropertyFetches(Class_ $class, $propertyOrPromotedParam) : array { $propertyName = $this->resolvePropertyName($propertyOrPromotedParam); if ($propertyName === null) { @@ -82,10 +82,10 @@ final class PropertyFetchFinder /** * @return PropertyFetch[]|StaticPropertyFetch[] */ - public function findLocalPropertyFetchesByName(\PhpParser\Node\Stmt\Class_ $class, string $paramName) : array + public function findLocalPropertyFetchesByName(Class_ $class, string $paramName) : array { /** @var PropertyFetch[]|StaticPropertyFetch[] $propertyFetches */ - $propertyFetches = $this->betterNodeFinder->findInstancesOf($class, [\PhpParser\Node\Expr\PropertyFetch::class, \PhpParser\Node\Expr\StaticPropertyFetch::class]); + $propertyFetches = $this->betterNodeFinder->findInstancesOf($class, [PropertyFetch::class, StaticPropertyFetch::class]); $foundPropertyFetches = []; foreach ($propertyFetches as $propertyFetch) { if ($this->propertyFetchAnalyzer->isLocalPropertyFetchName($propertyFetch, $paramName)) { @@ -102,18 +102,18 @@ final class PropertyFetchFinder private function findPropertyFetchesInClassLike($class, array $stmts, string $propertyName, bool $hasTrait) : array { /** @var PropertyFetch[] $propertyFetches */ - $propertyFetches = $this->betterNodeFinder->findInstanceOf($stmts, \PhpParser\Node\Expr\PropertyFetch::class); + $propertyFetches = $this->betterNodeFinder->findInstanceOf($stmts, PropertyFetch::class); /** @var PropertyFetch[] $matchingPropertyFetches */ - $matchingPropertyFetches = \array_filter($propertyFetches, function (\PhpParser\Node\Expr\PropertyFetch $propertyFetch) use($propertyName, $class, $hasTrait) : bool { + $matchingPropertyFetches = \array_filter($propertyFetches, function (PropertyFetch $propertyFetch) use($propertyName, $class, $hasTrait) : bool { if ($this->isInAnonymous($propertyFetch, $class, $hasTrait)) { return \false; } return $this->isNamePropertyNameEquals($propertyFetch, $propertyName, $class); }); /** @var StaticPropertyFetch[] $staticPropertyFetches */ - $staticPropertyFetches = $this->betterNodeFinder->findInstanceOf($stmts, \PhpParser\Node\Expr\StaticPropertyFetch::class); + $staticPropertyFetches = $this->betterNodeFinder->findInstanceOf($stmts, StaticPropertyFetch::class); /** @var StaticPropertyFetch[] $matchingStaticPropertyFetches */ - $matchingStaticPropertyFetches = \array_filter($staticPropertyFetches, function (\PhpParser\Node\Expr\StaticPropertyFetch $staticPropertyFetch) use($propertyName) : bool { + $matchingStaticPropertyFetches = \array_filter($staticPropertyFetches, function (StaticPropertyFetch $staticPropertyFetch) use($propertyName) : bool { return $this->nodeNameResolver->isName($staticPropertyFetch->name, $propertyName); }); return \array_merge($matchingPropertyFetches, $matchingStaticPropertyFetches); @@ -121,10 +121,10 @@ final class PropertyFetchFinder /** * @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Trait_ $class */ - private function isInAnonymous(\PhpParser\Node\Expr\PropertyFetch $propertyFetch, $class, bool $hasTrait) : bool + private function isInAnonymous(PropertyFetch $propertyFetch, $class, bool $hasTrait) : bool { - $parent = $this->betterNodeFinder->findParentType($propertyFetch, \PhpParser\Node\Stmt\Class_::class); - if (!$parent instanceof \PhpParser\Node\Stmt\Class_) { + $parent = $this->betterNodeFinder->findParentType($propertyFetch, Class_::class); + if (!$parent instanceof Class_) { return \false; } return $parent !== $class && !$hasTrait; @@ -132,7 +132,7 @@ final class PropertyFetchFinder /** * @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Trait_ $class */ - private function isNamePropertyNameEquals(\PhpParser\Node\Expr\PropertyFetch $propertyFetch, string $propertyName, $class) : bool + private function isNamePropertyNameEquals(PropertyFetch $propertyFetch, string $propertyName, $class) : bool { // early check if property fetch name is not equals with property name // so next check is check var name and var type only @@ -143,7 +143,7 @@ final class PropertyFetchFinder return \true; } $propertyFetchVarType = $this->nodeTypeResolver->getType($propertyFetch->var); - if (!$propertyFetchVarType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$propertyFetchVarType instanceof TypeWithClassName) { return \false; } $propertyFetchVarTypeClassName = $propertyFetchVarType->getClassName(); @@ -155,7 +155,7 @@ final class PropertyFetchFinder */ private function resolvePropertyName($propertyOrPromotedParam) : ?string { - if ($propertyOrPromotedParam instanceof \PhpParser\Node\Stmt\Property) { + if ($propertyOrPromotedParam instanceof Property) { return $this->nodeNameResolver->getName($propertyOrPromotedParam->props[0]); } return $this->nodeNameResolver->getName($propertyOrPromotedParam->var); diff --git a/src/PhpParser/NodeTransformer.php b/src/PhpParser/NodeTransformer.php index fa7b479841a..65a3bc2027d 100644 --- a/src/PhpParser/NodeTransformer.php +++ b/src/PhpParser/NodeTransformer.php @@ -31,10 +31,10 @@ final class NodeTransformer * to: * - ["Hi %s", $name] */ - public function transformSprintfToArray(\PhpParser\Node\Expr\FuncCall $sprintfFuncCall) : ?\PhpParser\Node\Expr\Array_ + public function transformSprintfToArray(FuncCall $sprintfFuncCall) : ?Array_ { $sprintfStringAndArgs = $this->splitMessageAndArgs($sprintfFuncCall); - if (!$sprintfStringAndArgs instanceof \Rector\Core\ValueObject\SprintfStringAndArgs) { + if (!$sprintfStringAndArgs instanceof SprintfStringAndArgs) { return null; } $arrayItems = $sprintfStringAndArgs->getArrayItems(); @@ -42,50 +42,50 @@ final class NodeTransformer $messageParts = $this->splitBySpace($stringValue); $arrayMessageParts = []; foreach ($messageParts as $messagePart) { - if (\Rector\Core\Util\StringUtils::isMatch($messagePart, self::PERCENT_TEXT_REGEX)) { + if (StringUtils::isMatch($messagePart, self::PERCENT_TEXT_REGEX)) { /** @var Expr $messagePartNode */ $messagePartNode = \array_shift($arrayItems); } else { - $messagePartNode = new \PhpParser\Node\Scalar\String_($messagePart); + $messagePartNode = new String_($messagePart); } - $arrayMessageParts[] = new \PhpParser\Node\Expr\ArrayItem($messagePartNode); + $arrayMessageParts[] = new ArrayItem($messagePartNode); } - return new \PhpParser\Node\Expr\Array_($arrayMessageParts); + return new Array_($arrayMessageParts); } /** * @return Expression[] */ - public function transformArrayToYields(\PhpParser\Node\Expr\Array_ $array) : array + public function transformArrayToYields(Array_ $array) : array { $yieldNodes = []; foreach ($array->items as $arrayItem) { if ($arrayItem === null) { continue; } - $expressionNode = new \PhpParser\Node\Stmt\Expression(new \PhpParser\Node\Expr\Yield_($arrayItem->value, $arrayItem->key)); + $expressionNode = new Expression(new Yield_($arrayItem->value, $arrayItem->key)); $arrayItemComments = $arrayItem->getComments(); if ($arrayItemComments !== []) { - $expressionNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $arrayItemComments); + $expressionNode->setAttribute(AttributeKey::COMMENTS, $arrayItemComments); } $yieldNodes[] = $expressionNode; } return $yieldNodes; } - public function transformConcatToStringArray(\PhpParser\Node\Expr\BinaryOp\Concat $concat) : \PhpParser\Node\Expr\Array_ + public function transformConcatToStringArray(Concat $concat) : Array_ { $arrayItems = $this->transformConcatToItems($concat); - $array = \PhpParser\BuilderHelpers::normalizeValue($arrayItems); - if (!$array instanceof \PhpParser\Node\Expr\Array_) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $array = BuilderHelpers::normalizeValue($arrayItems); + if (!$array instanceof Array_) { + throw new ShouldNotHappenException(); } return $array; } - private function splitMessageAndArgs(\PhpParser\Node\Expr\FuncCall $sprintfFuncCall) : ?\Rector\Core\ValueObject\SprintfStringAndArgs + private function splitMessageAndArgs(FuncCall $sprintfFuncCall) : ?SprintfStringAndArgs { $stringArgument = null; $arrayItems = []; foreach ($sprintfFuncCall->args as $i => $arg) { - if (!$arg instanceof \PhpParser\Node\Arg) { + if (!$arg instanceof Arg) { continue; } if ($i === 0) { @@ -94,13 +94,13 @@ final class NodeTransformer $arrayItems[] = $arg->value; } } - if (!$stringArgument instanceof \PhpParser\Node\Scalar\String_) { + if (!$stringArgument instanceof String_) { return null; } if ($arrayItems === []) { return null; } - return new \Rector\Core\ValueObject\SprintfStringAndArgs($stringArgument, $arrayItems); + return new SprintfStringAndArgs($stringArgument, $arrayItems); } /** * @return string[] @@ -113,7 +113,7 @@ final class NodeTransformer /** * @return mixed[] */ - private function transformConcatToItems(\PhpParser\Node\Expr\BinaryOp\Concat $concat) : array + private function transformConcatToItems(Concat $concat) : array { $arrayItems = $this->transformConcatItemToArrayItems($concat->left); return \array_merge($arrayItems, $this->transformConcatItemToArrayItems($concat->right)); @@ -121,19 +121,19 @@ final class NodeTransformer /** * @return mixed[]|Expr[]|String_[] */ - private function transformConcatItemToArrayItems(\PhpParser\Node\Expr $expr) : array + private function transformConcatItemToArrayItems(Expr $expr) : array { - if ($expr instanceof \PhpParser\Node\Expr\BinaryOp\Concat) { + if ($expr instanceof Concat) { return $this->transformConcatToItems($expr); } - if (!$expr instanceof \PhpParser\Node\Scalar\String_) { + if (!$expr instanceof String_) { return [$expr]; } $arrayItems = []; $parts = $this->splitBySpace($expr->value); foreach ($parts as $part) { if (\trim($part) !== '') { - $arrayItems[] = new \PhpParser\Node\Scalar\String_($part); + $arrayItems[] = new String_($part); } } return $arrayItems; diff --git a/src/PhpParser/NodeTraverser/FileWithoutNamespaceNodeTraverser.php b/src/PhpParser/NodeTraverser/FileWithoutNamespaceNodeTraverser.php index d04520140ea..471d3eb0c13 100644 --- a/src/PhpParser/NodeTraverser/FileWithoutNamespaceNodeTraverser.php +++ b/src/PhpParser/NodeTraverser/FileWithoutNamespaceNodeTraverser.php @@ -9,14 +9,14 @@ use PhpParser\NodeFinder; use PhpParser\NodeTraverser; use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace; use Rector\NodeTypeResolver\Node\AttributeKey; -final class FileWithoutNamespaceNodeTraverser extends \PhpParser\NodeTraverser +final class FileWithoutNamespaceNodeTraverser extends NodeTraverser { /** * @readonly * @var \PhpParser\NodeFinder */ private $nodeFinder; - public function __construct(\PhpParser\NodeFinder $nodeFinder) + public function __construct(NodeFinder $nodeFinder) { $this->nodeFinder = $nodeFinder; } @@ -27,11 +27,11 @@ final class FileWithoutNamespaceNodeTraverser extends \PhpParser\NodeTraverser */ public function traverse(array $nodes) : array { - $hasNamespace = (bool) $this->nodeFinder->findFirstInstanceOf($nodes, \PhpParser\Node\Stmt\Namespace_::class); + $hasNamespace = (bool) $this->nodeFinder->findFirstInstanceOf($nodes, Namespace_::class); if (!$hasNamespace && $nodes !== []) { - $fileWithoutNamespace = new \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace($nodes); + $fileWithoutNamespace = new FileWithoutNamespace($nodes); foreach ($nodes as $node) { - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE, $fileWithoutNamespace); + $node->setAttribute(AttributeKey::PARENT_NODE, $fileWithoutNamespace); } return [$fileWithoutNamespace]; } diff --git a/src/PhpParser/NodeTraverser/RectorNodeTraverser.php b/src/PhpParser/NodeTraverser/RectorNodeTraverser.php index fa8d272e9c5..ac683abf3f1 100644 --- a/src/PhpParser/NodeTraverser/RectorNodeTraverser.php +++ b/src/PhpParser/NodeTraverser/RectorNodeTraverser.php @@ -7,7 +7,7 @@ use PhpParser\Node; use PhpParser\NodeTraverser; use Rector\Core\Contract\Rector\PhpRectorInterface; use Rector\VersionBonding\PhpVersionedFilter; -final class RectorNodeTraverser extends \PhpParser\NodeTraverser +final class RectorNodeTraverser extends NodeTraverser { /** * @var bool @@ -26,7 +26,7 @@ final class RectorNodeTraverser extends \PhpParser\NodeTraverser /** * @param PhpRectorInterface[] $phpRectors */ - public function __construct(array $phpRectors, \Rector\VersionBonding\PhpVersionedFilter $phpVersionedFilter) + public function __construct(array $phpRectors, PhpVersionedFilter $phpVersionedFilter) { $this->phpRectors = $phpRectors; $this->phpVersionedFilter = $phpVersionedFilter; diff --git a/src/PhpParser/Parser/InlineCodeParser.php b/src/PhpParser/Parser/InlineCodeParser.php index 2996ce11847..2f853ccd314 100644 --- a/src/PhpParser/Parser/InlineCodeParser.php +++ b/src/PhpParser/Parser/InlineCodeParser.php @@ -60,7 +60,7 @@ final class InlineCodeParser * @var \Symplify\SmartFileSystem\SmartFileSystem */ private $smartFileSystem; - public function __construct(\Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter, \Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator, \Rector\Core\PhpParser\Parser\SimplePhpParser $simplePhpParser, \RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem) + public function __construct(NodePrinterInterface $nodePrinter, NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator, \Rector\Core\PhpParser\Parser\SimplePhpParser $simplePhpParser, SmartFileSystem $smartFileSystem) { $this->nodePrinter = $nodePrinter; $this->nodeScopeAndMetadataDecorator = $nodeScopeAndMetadataDecorator; @@ -77,30 +77,30 @@ final class InlineCodeParser $content = $this->smartFileSystem->readFile($content); } // wrap code so php-parser can interpret it - $content = \Rector\Core\Util\StringUtils::isMatch($content, self::OPEN_PHP_TAG_REGEX) ? $content : 'simplePhpParser->parseString($content); return $this->nodeScopeAndMetadataDecorator->decorateStmtsFromString($stmts); } - public function stringify(\PhpParser\Node\Expr $expr) : string + public function stringify(Expr $expr) : string { - if ($expr instanceof \PhpParser\Node\Scalar\String_) { + if ($expr instanceof String_) { return $expr->value; } - if ($expr instanceof \PhpParser\Node\Scalar\Encapsed) { + if ($expr instanceof Encapsed) { // remove " $expr = \trim($this->nodePrinter->print($expr), '""'); // use \$ → $ - $expr = \RectorPrefix20220607\Nette\Utils\Strings::replace($expr, self::PRESLASHED_DOLLAR_REGEX, '$'); + $expr = Strings::replace($expr, self::PRESLASHED_DOLLAR_REGEX, '$'); // use \'{$...}\' → $... - return \RectorPrefix20220607\Nette\Utils\Strings::replace($expr, self::CURLY_BRACKET_WRAPPER_REGEX, '$1'); + return Strings::replace($expr, self::CURLY_BRACKET_WRAPPER_REGEX, '$1'); } - if ($expr instanceof \PhpParser\Node\Expr\BinaryOp\Concat) { + if ($expr instanceof Concat) { return $this->stringify($expr->left) . $this->stringify($expr->right); } - if ($expr instanceof \PhpParser\Node\Expr\Variable || $expr instanceof \PhpParser\Node\Expr\PropertyFetch || $expr instanceof \PhpParser\Node\Expr\StaticPropertyFetch) { + if ($expr instanceof Variable || $expr instanceof PropertyFetch || $expr instanceof StaticPropertyFetch) { return $this->nodePrinter->print($expr); } - throw new \Rector\Core\Exception\ShouldNotHappenException(\get_class($expr) . ' ' . __METHOD__); + throw new ShouldNotHappenException(\get_class($expr) . ' ' . __METHOD__); } } diff --git a/src/PhpParser/Parser/RectorParser.php b/src/PhpParser/Parser/RectorParser.php index 32e7024a54b..5460d885e00 100644 --- a/src/PhpParser/Parser/RectorParser.php +++ b/src/PhpParser/Parser/RectorParser.php @@ -7,7 +7,7 @@ use PhpParser\Lexer; use PhpParser\Node\Stmt; use PHPStan\Parser\Parser; use Rector\Core\PhpParser\ValueObject\StmtsAndTokens; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class RectorParser { /** @@ -20,7 +20,7 @@ final class RectorParser * @var \PHPStan\Parser\Parser */ private $parser; - public function __construct(\PhpParser\Lexer $lexer, \PHPStan\Parser\Parser $parser) + public function __construct(Lexer $lexer, Parser $parser) { $this->lexer = $lexer; $this->parser = $parser; @@ -28,14 +28,14 @@ final class RectorParser /** * @return Stmt[] */ - public function parseFile(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : array + public function parseFile(SmartFileInfo $smartFileInfo) : array { return $this->parser->parseFile($smartFileInfo->getRealPath()); } - public function parseFileToStmtsAndTokens(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : \Rector\Core\PhpParser\ValueObject\StmtsAndTokens + public function parseFileToStmtsAndTokens(SmartFileInfo $smartFileInfo) : StmtsAndTokens { $stmts = $this->parseFile($smartFileInfo); $tokens = $this->lexer->getTokens(); - return new \Rector\Core\PhpParser\ValueObject\StmtsAndTokens($stmts, $tokens); + return new StmtsAndTokens($stmts, $tokens); } } diff --git a/src/PhpParser/Parser/SimplePhpParser.php b/src/PhpParser/Parser/SimplePhpParser.php index 0ef4e8cc04a..fdc21745bbc 100644 --- a/src/PhpParser/Parser/SimplePhpParser.php +++ b/src/PhpParser/Parser/SimplePhpParser.php @@ -21,11 +21,11 @@ final class SimplePhpParser * @var \Symplify\SmartFileSystem\SmartFileSystem */ private $smartFileSystem; - public function __construct(\RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem) + public function __construct(SmartFileSystem $smartFileSystem) { $this->smartFileSystem = $smartFileSystem; - $parserFactory = new \PhpParser\ParserFactory(); - $this->phpParser = $parserFactory->create(\PhpParser\ParserFactory::PREFER_PHP7); + $parserFactory = new ParserFactory(); + $this->phpParser = $parserFactory->create(ParserFactory::PREFER_PHP7); } /** * @return Stmt[] @@ -44,8 +44,8 @@ final class SimplePhpParser if ($stmts === null) { return []; } - $nodeTraverser = new \PhpParser\NodeTraverser(); - $nodeTraverser->addVisitor(new \PhpParser\NodeVisitor\NodeConnectingVisitor()); + $nodeTraverser = new NodeTraverser(); + $nodeTraverser->addVisitor(new NodeConnectingVisitor()); return $nodeTraverser->traverse($stmts); } } diff --git a/src/PhpParser/Printer/BetterStandardPrinter.php b/src/PhpParser/Printer/BetterStandardPrinter.php index 07d2e26c389..cb1b35a76e8 100644 --- a/src/PhpParser/Printer/BetterStandardPrinter.php +++ b/src/PhpParser/Printer/BetterStandardPrinter.php @@ -36,7 +36,7 @@ use Rector\NodeTypeResolver\Node\AttributeKey; * * @property array $insertionMap */ -final class BetterStandardPrinter extends \PhpParser\PrettyPrinter\Standard implements \Rector\Core\Contract\PhpParser\NodePrinterInterface +final class BetterStandardPrinter extends Standard implements NodePrinterInterface { /** * @var string @@ -82,7 +82,7 @@ final class BetterStandardPrinter extends \PhpParser\PrettyPrinter\Standard impl /** * @param mixed[] $options */ - public function __construct(\Rector\Comments\NodeDocBlock\DocBlockUpdater $docBlockUpdater, \Rector\Core\Configuration\RectorConfigProvider $rectorConfigProvider, array $options = []) + public function __construct(DocBlockUpdater $docBlockUpdater, RectorConfigProvider $rectorConfigProvider, array $options = []) { $this->docBlockUpdater = $docBlockUpdater; $this->rectorConfigProvider = $rectorConfigProvider; @@ -105,7 +105,7 @@ final class BetterStandardPrinter extends \PhpParser\PrettyPrinter\Standard impl $this->tabOrSpaceIndentCharacter = $this->rectorConfigProvider->getIndentChar(); $content = parent::printFormatPreserving($newStmts, $origStmts, $origTokens); // add new line in case of added stmts - if (\count($stmts) !== \count($origStmts) && !\Rector\Core\Util\StringUtils::isMatch($content, self::NEWLINE_END_REGEX)) { + if (\count($stmts) !== \count($origStmts) && !StringUtils::isMatch($content, self::NEWLINE_END_REGEX)) { $content .= $this->nl; } return $content; @@ -132,18 +132,18 @@ final class BetterStandardPrinter extends \PhpParser\PrettyPrinter\Standard impl $stmts = \array_values($stmts); return parent::prettyPrintFile($stmts) . \PHP_EOL; } - public function pFileWithoutNamespace(\Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace $fileWithoutNamespace) : string + public function pFileWithoutNamespace(FileWithoutNamespace $fileWithoutNamespace) : string { $content = $this->pStmts($fileWithoutNamespace->stmts, \false); return \ltrim($content); } - protected function p(\PhpParser\Node $node, $parentFormatPreserved = \false) : string + protected function p(Node $node, $parentFormatPreserved = \false) : string { $content = parent::p($node, $parentFormatPreserved); - if ($node instanceof \PhpParser\Node\Expr) { + if ($node instanceof Expr) { $content = $this->resolveContentOnExpr($node, $content); } - return $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::WRAPPED_IN_PARENTHESES) === \true ? '(' . $content . ')' : $content; + return $node->getAttribute(AttributeKey::WRAPPED_IN_PARENTHESES) === \true ? '(' . $content . ')' : $content; } /** * This allows to use both spaces and tabs vs. original space-only @@ -196,7 +196,7 @@ final class BetterStandardPrinter extends \PhpParser\PrettyPrinter\Standard impl if (!$this->containsNop($nodes)) { return $content; } - return \RectorPrefix20220607\Nette\Utils\Strings::replace($content, self::EXTRA_SPACE_BEFORE_NOP_REGEX, ''); + return Strings::replace($content, self::EXTRA_SPACE_BEFORE_NOP_REGEX, ''); } /** * Do not preslash all slashes (parent behavior), but only those: @@ -209,12 +209,12 @@ final class BetterStandardPrinter extends \PhpParser\PrettyPrinter\Standard impl */ protected function pSingleQuotedString(string $string) : string { - return "'" . \RectorPrefix20220607\Nette\Utils\Strings::replace($string, self::QUOTED_SLASH_REGEX, '\\\\$0') . "'"; + return "'" . Strings::replace($string, self::QUOTED_SLASH_REGEX, '\\\\$0') . "'"; } /** * Emulates 1_000 in PHP 7.3- version */ - protected function pScalar_DNumber(\PhpParser\Node\Scalar\DNumber $dNumber) : string + protected function pScalar_DNumber(DNumber $dNumber) : string { if (\is_string($dNumber->value)) { return $dNumber->value; @@ -227,53 +227,53 @@ final class BetterStandardPrinter extends \PhpParser\PrettyPrinter\Standard impl * ↓ * "use (" */ - protected function pExpr_Closure(\PhpParser\Node\Expr\Closure $closure) : string + protected function pExpr_Closure(Closure $closure) : string { $closureContent = parent::pExpr_Closure($closure); if ($closure->uses === []) { return $closureContent; } - return \RectorPrefix20220607\Nette\Utils\Strings::replace($closureContent, self::USE_REGEX, '$1 ('); + return Strings::replace($closureContent, self::USE_REGEX, '$1 ('); } /** * Do not add "()" on Expressions * @see https://github.com/rectorphp/rector/pull/401#discussion_r181487199 */ - protected function pExpr_Yield(\PhpParser\Node\Expr\Yield_ $yield) : string + protected function pExpr_Yield(Yield_ $yield) : string { if ($yield->value === null) { return 'yield'; } - $parentNode = $yield->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $yield->getAttribute(AttributeKey::PARENT_NODE); // brackets are needed only in case of assign, @see https://www.php.net/manual/en/language.generators.syntax.php - $shouldAddBrackets = $parentNode instanceof \PhpParser\Node\Expr\Assign; + $shouldAddBrackets = $parentNode instanceof Assign; return \sprintf('%syield %s%s%s', $shouldAddBrackets ? '(' : '', $yield->key !== null ? $this->p($yield->key) . ' => ' : '', $this->p($yield->value), $shouldAddBrackets ? ')' : ''); } /** * Print arrays in short [] by default, * to prevent manual explicit array shortening. */ - protected function pExpr_Array(\PhpParser\Node\Expr\Array_ $array) : string + protected function pExpr_Array(Array_ $array) : string { - if (!$array->hasAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND)) { - $array->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND, \PhpParser\Node\Expr\Array_::KIND_SHORT); + if (!$array->hasAttribute(AttributeKey::KIND)) { + $array->setAttribute(AttributeKey::KIND, Array_::KIND_SHORT); } return parent::pExpr_Array($array); } /** * Fixes escaping of regular patterns */ - protected function pScalar_String(\PhpParser\Node\Scalar\String_ $string) : string + protected function pScalar_String(String_ $string) : string { - $isRegularPattern = (bool) $string->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::IS_REGULAR_PATTERN, \false); + $isRegularPattern = (bool) $string->getAttribute(AttributeKey::IS_REGULAR_PATTERN, \false); if (!$isRegularPattern) { return parent::pScalar_String($string); } - $kind = $string->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND, \PhpParser\Node\Scalar\String_::KIND_SINGLE_QUOTED); - if ($kind === \PhpParser\Node\Scalar\String_::KIND_DOUBLE_QUOTED) { + $kind = $string->getAttribute(AttributeKey::KIND, String_::KIND_SINGLE_QUOTED); + if ($kind === String_::KIND_DOUBLE_QUOTED) { return $this->wrapValueWith($string, '"'); } - if ($kind === \PhpParser\Node\Scalar\String_::KIND_SINGLE_QUOTED) { + if ($kind === String_::KIND_SINGLE_QUOTED) { return $this->wrapValueWith($string, "'"); } return parent::pScalar_String($string); @@ -291,24 +291,24 @@ final class BetterStandardPrinter extends \PhpParser\PrettyPrinter\Standard impl * ↓ * "...$params): ReturnType" */ - protected function pStmt_ClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : string + protected function pStmt_ClassMethod(ClassMethod $classMethod) : string { $content = parent::pStmt_ClassMethod($classMethod); - if (!$classMethod->returnType instanceof \PhpParser\Node) { + if (!$classMethod->returnType instanceof Node) { return $content; } // this approach is chosen, to keep changes in parent pStmt_ClassMethod() updated - return \RectorPrefix20220607\Nette\Utils\Strings::replace($content, self::REPLACE_COLON_WITH_SPACE_REGEX, '$1: '); + return Strings::replace($content, self::REPLACE_COLON_WITH_SPACE_REGEX, '$1: '); } /** * Clean class and trait from empty "use x;" for traits causing invalid code */ - protected function pStmt_Class(\PhpParser\Node\Stmt\Class_ $class) : string + protected function pStmt_Class(Class_ $class) : string { $shouldReindex = \false; foreach ($class->stmts as $key => $stmt) { // remove empty ones - if ($stmt instanceof \PhpParser\Node\Stmt\TraitUse && $stmt->traits === []) { + if ($stmt instanceof TraitUse && $stmt->traits === []) { unset($class->stmts[$key]); $shouldReindex = \true; } @@ -321,14 +321,14 @@ final class BetterStandardPrinter extends \PhpParser\PrettyPrinter\Standard impl /** * It remove all spaces extra to parent */ - protected function pStmt_Declare(\PhpParser\Node\Stmt\Declare_ $declare) : string + protected function pStmt_Declare(Declare_ $declare) : string { $declareString = parent::pStmt_Declare($declare); - return \RectorPrefix20220607\Nette\Utils\Strings::replace($declareString, '#\\s+#', ''); + return Strings::replace($declareString, '#\\s+#', ''); } - protected function pExpr_Ternary(\PhpParser\Node\Expr\Ternary $ternary) : string + protected function pExpr_Ternary(Ternary $ternary) : string { - $kind = $ternary->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::KIND); + $kind = $ternary->getAttribute(AttributeKey::KIND); if ($kind === 'wrapped_with_brackets') { $pExprTernary = parent::pExpr_Ternary($ternary); return '(' . $pExprTernary . ')'; @@ -338,20 +338,20 @@ final class BetterStandardPrinter extends \PhpParser\PrettyPrinter\Standard impl /** * Remove extra \\ from FQN use imports, for easier use in the code */ - protected function pStmt_Use(\PhpParser\Node\Stmt\Use_ $use) : string + protected function pStmt_Use(Use_ $use) : string { - if ($use->type !== \PhpParser\Node\Stmt\Use_::TYPE_NORMAL) { + if ($use->type !== Use_::TYPE_NORMAL) { return parent::pStmt_Use($use); } foreach ($use->uses as $useUse) { - if (!$useUse->name instanceof \PhpParser\Node\Name\FullyQualified) { + if (!$useUse->name instanceof FullyQualified) { continue; } - $useUse->name = new \PhpParser\Node\Name($useUse->name->toString()); + $useUse->name = new Name($useUse->name->toString()); } return parent::pStmt_Use($use); } - protected function pScalar_EncapsedStringPart(\PhpParser\Node\Scalar\EncapsedStringPart $encapsedStringPart) : string + protected function pScalar_EncapsedStringPart(EncapsedStringPart $encapsedStringPart) : string { // parent throws exception, but we need to compare string return '`' . $encapsedStringPart->value . '`'; @@ -360,8 +360,8 @@ final class BetterStandardPrinter extends \PhpParser\PrettyPrinter\Standard impl { $result = parent::pCommaSeparated($nodes); $last = \end($nodes); - if ($last instanceof \PhpParser\Node) { - $trailingComma = $last->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::FUNC_ARGS_TRAILING_COMMA); + if ($last instanceof Node) { + $trailingComma = $last->getAttribute(AttributeKey::FUNC_ARGS_TRAILING_COMMA); if ($trailingComma === \false) { $result = \rtrim($result, ','); } @@ -382,22 +382,22 @@ final class BetterStandardPrinter extends \PhpParser\PrettyPrinter\Standard impl */ protected function pModifiers(int $modifiers) : string { - return (($modifiers & \PhpParser\Node\Stmt\Class_::MODIFIER_FINAL) !== 0 ? 'final ' : '') . (($modifiers & \PhpParser\Node\Stmt\Class_::MODIFIER_ABSTRACT) !== 0 ? 'abstract ' : '') . (($modifiers & \PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC) !== 0 ? 'public ' : '') . (($modifiers & \PhpParser\Node\Stmt\Class_::MODIFIER_PROTECTED) !== 0 ? 'protected ' : '') . (($modifiers & \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE) !== 0 ? 'private ' : '') . (($modifiers & \PhpParser\Node\Stmt\Class_::MODIFIER_STATIC) !== 0 ? 'static ' : '') . (($modifiers & \PhpParser\Node\Stmt\Class_::MODIFIER_READONLY) !== 0 ? 'readonly ' : ''); + return (($modifiers & Class_::MODIFIER_FINAL) !== 0 ? 'final ' : '') . (($modifiers & Class_::MODIFIER_ABSTRACT) !== 0 ? 'abstract ' : '') . (($modifiers & Class_::MODIFIER_PUBLIC) !== 0 ? 'public ' : '') . (($modifiers & Class_::MODIFIER_PROTECTED) !== 0 ? 'protected ' : '') . (($modifiers & Class_::MODIFIER_PRIVATE) !== 0 ? 'private ' : '') . (($modifiers & Class_::MODIFIER_STATIC) !== 0 ? 'static ' : '') . (($modifiers & Class_::MODIFIER_READONLY) !== 0 ? 'readonly ' : ''); } - private function resolveContentOnExpr(\PhpParser\Node\Expr $expr, string $content) : string + private function resolveContentOnExpr(Expr $expr, string $content) : string { - $parentNode = $expr->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node\Expr\ArrowFunction) { + $parentNode = $expr->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof ArrowFunction) { return $content; } if ($parentNode->expr !== $expr) { return $content; } - if (!$parentNode->hasAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENT_CLOSURE_RETURN_MIRRORED)) { + if (!$parentNode->hasAttribute(AttributeKey::COMMENT_CLOSURE_RETURN_MIRRORED)) { return $content; } /** @var Comment[] $comments */ - $comments = $expr->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS) ?? []; + $comments = $expr->getAttribute(AttributeKey::COMMENTS) ?? []; if ($comments === []) { return $content; } @@ -413,7 +413,7 @@ final class BetterStandardPrinter extends \PhpParser\PrettyPrinter\Standard impl */ private function resolveNewStmts(array $stmts) : array { - if (\count($stmts) === 1 && $stmts[0] instanceof \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace) { + if (\count($stmts) === 1 && $stmts[0] instanceof FileWithoutNamespace) { return $this->resolveNewStmts($stmts[0]->stmts); } return $stmts; @@ -425,7 +425,7 @@ final class BetterStandardPrinter extends \PhpParser\PrettyPrinter\Standard impl { // move phpdoc from node to "comment" attribute foreach ($nodes as $node) { - if (!$node instanceof \PhpParser\Node) { + if (!$node instanceof Node) { continue; } $this->docBlockUpdater->updateNodeWithPhpDocInfo($node); @@ -437,13 +437,13 @@ final class BetterStandardPrinter extends \PhpParser\PrettyPrinter\Standard impl private function containsNop(array $nodes) : bool { foreach ($nodes as $node) { - if ($node instanceof \PhpParser\Node\Stmt\Nop) { + if ($node instanceof Nop) { return \true; } } return \false; } - private function wrapValueWith(\PhpParser\Node\Scalar\String_ $string, string $wrap) : string + private function wrapValueWith(String_ $string, string $wrap) : string { return $wrap . $string->value . $wrap; } diff --git a/src/PhpParser/Printer/FormatPerservingPrinter.php b/src/PhpParser/Printer/FormatPerservingPrinter.php index 389762abe0b..091db8103d5 100644 --- a/src/PhpParser/Printer/FormatPerservingPrinter.php +++ b/src/PhpParser/Printer/FormatPerservingPrinter.php @@ -8,7 +8,7 @@ use PhpParser\Node\Stmt; use PhpParser\Node\Stmt\Namespace_; use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace; use Rector\Core\ValueObject\Application\File; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem; /** * @see \Rector\Core\Tests\PhpParser\Printer\FormatPerservingPrinterTest @@ -25,7 +25,7 @@ final class FormatPerservingPrinter * @var \Symplify\SmartFileSystem\SmartFileSystem */ private $smartFileSystem; - public function __construct(\Rector\Core\PhpParser\Printer\BetterStandardPrinter $betterStandardPrinter, \RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem) + public function __construct(\Rector\Core\PhpParser\Printer\BetterStandardPrinter $betterStandardPrinter, SmartFileSystem $smartFileSystem) { $this->betterStandardPrinter = $betterStandardPrinter; $this->smartFileSystem = $smartFileSystem; @@ -35,19 +35,19 @@ final class FormatPerservingPrinter * @param Node[] $oldStmts * @param Node[] $oldTokens */ - public function printToFile(\Symplify\SmartFileSystem\SmartFileInfo $fileInfo, array $newStmts, array $oldStmts, array $oldTokens) : string + public function printToFile(SmartFileInfo $fileInfo, array $newStmts, array $oldStmts, array $oldTokens) : string { $newContent = $this->betterStandardPrinter->printFormatPreserving($newStmts, $oldStmts, $oldTokens); $this->smartFileSystem->dumpFile($fileInfo->getRealPath(), $newContent); $this->smartFileSystem->chmod($fileInfo->getRealPath(), $fileInfo->getPerms()); return $newContent; } - public function printParsedStmstAndTokensToString(\Rector\Core\ValueObject\Application\File $file) : string + public function printParsedStmstAndTokensToString(File $file) : string { $newStmts = $this->resolveNewStmts($file); return $this->betterStandardPrinter->printFormatPreserving($newStmts, $file->getOldStmts(), $file->getOldTokens()); } - public function printParsedStmstAndTokens(\Rector\Core\ValueObject\Application\File $file) : string + public function printParsedStmstAndTokens(File $file) : string { $newStmts = $this->resolveNewStmts($file); return $this->printToFile($file->getSmartFileInfo(), $newStmts, $file->getOldStmts(), $file->getOldTokens()); @@ -55,7 +55,7 @@ final class FormatPerservingPrinter /** * @return Stmt[]|mixed[] */ - private function resolveNewStmts(\Rector\Core\ValueObject\Application\File $file) : array + private function resolveNewStmts(File $file) : array { $newStmts = $file->getNewStmts(); if (\count($newStmts) !== 1) { @@ -63,7 +63,7 @@ final class FormatPerservingPrinter } /** @var Namespace_|FileWithoutNamespace $onlyStmt */ $onlyStmt = $newStmts[0]; - if (!$onlyStmt instanceof \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace) { + if (!$onlyStmt instanceof FileWithoutNamespace) { return $newStmts; } return $onlyStmt->stmts; diff --git a/src/PhpParser/Printer/NodesWithFileDestinationPrinter.php b/src/PhpParser/Printer/NodesWithFileDestinationPrinter.php index 0f1df36ef78..45b0287290a 100644 --- a/src/PhpParser/Printer/NodesWithFileDestinationPrinter.php +++ b/src/PhpParser/Printer/NodesWithFileDestinationPrinter.php @@ -18,12 +18,12 @@ final class NodesWithFileDestinationPrinter * @var \Rector\PostRector\Application\PostFileProcessor */ private $postFileProcessor; - public function __construct(\Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter, \Rector\PostRector\Application\PostFileProcessor $postFileProcessor) + public function __construct(NodePrinterInterface $nodePrinter, PostFileProcessor $postFileProcessor) { $this->nodePrinter = $nodePrinter; $this->postFileProcessor = $postFileProcessor; } - public function printNodesWithFileDestination(\Rector\FileSystemRector\Contract\FileWithNodesInterface $fileWithNodes) : string + public function printNodesWithFileDestination(FileWithNodesInterface $fileWithNodes) : string { $nodes = $this->postFileProcessor->traverse($fileWithNodes->getNodes()); return $this->nodePrinter->prettyPrintFile($nodes); diff --git a/src/ProcessAnalyzer/RectifiedAnalyzer.php b/src/ProcessAnalyzer/RectifiedAnalyzer.php index e98b9c48d1b..b93a67f0c56 100644 --- a/src/ProcessAnalyzer/RectifiedAnalyzer.php +++ b/src/ProcessAnalyzer/RectifiedAnalyzer.php @@ -27,16 +27,16 @@ final class RectifiedAnalyzer * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(NodeComparator $nodeComparator) { $this->nodeComparator = $nodeComparator; } - public function verify(\Rector\Core\Contract\Rector\RectorInterface $rector, \PhpParser\Node $node, \Rector\Core\ValueObject\Application\File $currentFile) : ?\Rector\Core\ValueObject\RectifiedNode + public function verify(RectorInterface $rector, Node $node, File $currentFile) : ?RectifiedNode { $smartFileInfo = $currentFile->getSmartFileInfo(); $realPath = $smartFileInfo->getRealPath(); if (!isset($this->previousFileWithNodes[$realPath])) { - $this->previousFileWithNodes[$realPath] = new \Rector\Core\ValueObject\RectifiedNode(\get_class($rector), $node); + $this->previousFileWithNodes[$realPath] = new RectifiedNode(\get_class($rector), $node); return null; } /** @var RectifiedNode $rectifiedNode */ @@ -48,20 +48,20 @@ final class RectifiedAnalyzer $this->previousFileWithNodes[$realPath] = null; return $rectifiedNode; } - private function shouldContinue(\Rector\Core\ValueObject\RectifiedNode $rectifiedNode, \Rector\Core\Contract\Rector\RectorInterface $rector, \PhpParser\Node $node) : bool + private function shouldContinue(RectifiedNode $rectifiedNode, RectorInterface $rector, Node $node) : bool { - $originalNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE); + $originalNode = $node->getAttribute(AttributeKey::ORIGINAL_NODE); if ($rectifiedNode->getRectorClass() === \get_class($rector) && $rectifiedNode->getNode() === $node) { /** * allow to revisit the Node with same Rector rule if Node is changed by other rule */ return !$this->nodeComparator->areNodesEqual($originalNode, $node); } - if ($rector instanceof \Rector\Core\Rector\AbstractScopeAwareRector) { - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - return $scope instanceof \PHPStan\Analyser\Scope; + if ($rector instanceof AbstractScopeAwareRector) { + $scope = $node->getAttribute(AttributeKey::SCOPE); + return $scope instanceof Scope; } - if ($originalNode instanceof \PhpParser\Node) { + if ($originalNode instanceof Node) { return \true; } $startTokenPos = $node->getStartTokenPos(); diff --git a/src/Provider/CurrentFileProvider.php b/src/Provider/CurrentFileProvider.php index 46fbebd57fc..7acca641931 100644 --- a/src/Provider/CurrentFileProvider.php +++ b/src/Provider/CurrentFileProvider.php @@ -10,11 +10,11 @@ final class CurrentFileProvider * @var \Rector\Core\ValueObject\Application\File|null */ private $file; - public function setFile(\Rector\Core\ValueObject\Application\File $file) : void + public function setFile(File $file) : void { $this->file = $file; } - public function getFile() : ?\Rector\Core\ValueObject\Application\File + public function getFile() : ?File { return $this->file; } diff --git a/src/Rector/AbstractRector.php b/src/Rector/AbstractRector.php index 058c11b412a..dd45eb714ca 100644 --- a/src/Rector/AbstractRector.php +++ b/src/Rector/AbstractRector.php @@ -42,12 +42,12 @@ use Rector\StaticTypeMapper\StaticTypeMapper; use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; use RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser; use RectorPrefix20220607\Symplify\Skipper\Skipper\Skipper; -abstract class AbstractRector extends \PhpParser\NodeVisitorAbstract implements \Rector\Core\Contract\Rector\PhpRectorInterface +abstract class AbstractRector extends NodeVisitorAbstract implements PhpRectorInterface { /** * @var string[] */ - private const ATTRIBUTES_TO_MIRROR = [\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, \Rector\NodeTypeResolver\Node\AttributeKey::RESOLVED_NAME, \Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE]; + private const ATTRIBUTES_TO_MIRROR = [AttributeKey::SCOPE, AttributeKey::RESOLVED_NAME, AttributeKey::PARENT_NODE]; /** * @var string */ @@ -158,7 +158,7 @@ CODE_SAMPLE; /** * @required */ - public function autowire(\Rector\PostRector\Collector\NodesToRemoveCollector $nodesToRemoveCollector, \Rector\PostRector\Collector\NodesToAddCollector $nodesToAddCollector, \Rector\NodeRemoval\NodeRemover $nodeRemover, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Core\Exclusion\ExclusionManager $exclusionManager, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\Core\Logging\CurrentRectorProvider $currentRectorProvider, \Rector\Core\Configuration\CurrentNodeProvider $currentNodeProvider, \RectorPrefix20220607\Symplify\Skipper\Skipper\Skipper $skipper, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \Rector\Core\ProcessAnalyzer\RectifiedAnalyzer $rectifiedAnalyzer, \Rector\Core\NodeDecorator\CreatedByRuleDecorator $createdByRuleDecorator, \Rector\Core\Application\ChangedNodeScopeRefresher $changedNodeScopeRefresher, \Rector\Core\Console\Output\RectorOutputStyle $rectorOutputStyle) : void + public function autowire(NodesToRemoveCollector $nodesToRemoveCollector, NodesToAddCollector $nodesToAddCollector, NodeRemover $nodeRemover, NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeFactory $nodeFactory, PhpDocInfoFactory $phpDocInfoFactory, ExclusionManager $exclusionManager, StaticTypeMapper $staticTypeMapper, CurrentRectorProvider $currentRectorProvider, CurrentNodeProvider $currentNodeProvider, Skipper $skipper, ValueResolver $valueResolver, BetterNodeFinder $betterNodeFinder, NodeComparator $nodeComparator, CurrentFileProvider $currentFileProvider, RectifiedAnalyzer $rectifiedAnalyzer, CreatedByRuleDecorator $createdByRuleDecorator, ChangedNodeScopeRefresher $changedNodeScopeRefresher, RectorOutputStyle $rectorOutputStyle) : void { $this->nodesToRemoveCollector = $nodesToRemoveCollector; $this->nodesToAddCollector = $nodesToAddCollector; @@ -189,8 +189,8 @@ CODE_SAMPLE; { // workaround for file around refactor() $file = $this->currentFileProvider->getFile(); - if (!$file instanceof \Rector\Core\ValueObject\Application\File) { - throw new \Rector\Core\Exception\ShouldNotHappenException('File object is missing. Make sure you call $this->currentFileProvider->setFile(...) before traversing.'); + if (!$file instanceof File) { + throw new ShouldNotHappenException('File object is missing. Make sure you call $this->currentFileProvider->setFile(...) before traversing.'); } $this->file = $file; return parent::beforeTraverse($nodes); @@ -198,7 +198,7 @@ CODE_SAMPLE; /** * @return Node|null */ - public final function enterNode(\PhpParser\Node $node) + public final function enterNode(Node $node) { $nodeClass = \get_class($node); if (!$this->isMatchingNodeType($nodeClass)) { @@ -208,8 +208,8 @@ CODE_SAMPLE; return null; } /** @var Node $originalNode */ - $originalNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE) ?? clone $node; - $createdByRule = $originalNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CREATED_BY_RULE) ?? []; + $originalNode = $node->getAttribute(AttributeKey::ORIGINAL_NODE) ?? clone $node; + $createdByRule = $originalNode->getAttribute(AttributeKey::CREATED_BY_RULE) ?? []; if (\in_array(static::class, $createdByRule, \true)) { return null; } @@ -225,12 +225,12 @@ CODE_SAMPLE; } if ($node === []) { $errorMessage = \sprintf(self::EMPTY_NODE_ARRAY_MESSAGE, static::class); - throw new \Rector\Core\Exception\ShouldNotHappenException($errorMessage); + throw new ShouldNotHappenException($errorMessage); } /** @var Node[]|Node $node */ $this->createdByRuleDecorator->decorate($node, $originalNode, static::class); /** @var Node $originalNode */ - $rectorWithLineChange = new \Rector\ChangesReporting\ValueObject\RectorWithLineChange(\get_class($this), $originalNode->getLine()); + $rectorWithLineChange = new RectorWithLineChange(\get_class($this), $originalNode->getLine()); $this->file->addRectorClassWithLine($rectorWithLineChange); /** @var Node $originalNode */ if (\is_array($node)) { @@ -245,7 +245,7 @@ CODE_SAMPLE; // update parents relations - must run before connectParentNodes() /** @var Node $node */ $this->mirrorAttributes($originalAttributes, $node); - $currentScope = $originalNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $currentScope = $originalNode->getAttribute(AttributeKey::SCOPE); $this->changedNodeScopeRefresher->refresh($node, $this->file->getSmartFileInfo(), $currentScope); $this->connectParentNodes($node); // is equals node type? return node early @@ -254,8 +254,8 @@ CODE_SAMPLE; } // search "infinite recursion" in https://github.com/nikic/PHP-Parser/blob/master/doc/component/Walking_the_AST.markdown $originalNodeHash = \spl_object_hash($originalNode); - if ($originalNode instanceof \PhpParser\Node\Stmt && $node instanceof \PhpParser\Node\Expr) { - $node = new \PhpParser\Node\Stmt\Expression($node); + if ($originalNode instanceof Stmt && $node instanceof Expr) { + $node = new Expression($node); } $this->nodesToReturn[$originalNodeHash] = $node; return $node; @@ -264,35 +264,35 @@ CODE_SAMPLE; * Replacing nodes in leaveNode() method avoids infinite recursion * see"infinite recursion" in https://github.com/nikic/PHP-Parser/blob/master/doc/component/Walking_the_AST.markdown */ - public function leaveNode(\PhpParser\Node $node) + public function leaveNode(Node $node) { $objectHash = \spl_object_hash($node); // update parents relations!!! return $this->nodesToReturn[$objectHash] ?? $node; } - protected function isName(\PhpParser\Node $node, string $name) : bool + protected function isName(Node $node, string $name) : bool { return $this->nodeNameResolver->isName($node, $name); } /** * @param string[] $names */ - protected function isNames(\PhpParser\Node $node, array $names) : bool + protected function isNames(Node $node, array $names) : bool { return $this->nodeNameResolver->isNames($node, $names); } - protected function getName(\PhpParser\Node $node) : ?string + protected function getName(Node $node) : ?string { return $this->nodeNameResolver->getName($node); } - protected function isObjectType(\PhpParser\Node $node, \PHPStan\Type\ObjectType $objectType) : bool + protected function isObjectType(Node $node, ObjectType $objectType) : bool { return $this->nodeTypeResolver->isObjectType($node, $objectType); } /** * Use this method for getting expr|node type */ - protected function getType(\PhpParser\Node $node) : \PHPStan\Type\Type + protected function getType(Node $node) : Type { return $this->nodeTypeResolver->getType($node); } @@ -304,11 +304,11 @@ CODE_SAMPLE; { $this->simpleCallableNodeTraverser->traverseNodesWithCallable($nodes, $callable); } - protected function mirrorComments(\PhpParser\Node $newNode, \PhpParser\Node $oldNode) : void + protected function mirrorComments(Node $newNode, Node $oldNode) : void { - $newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $oldNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO)); - if (!$newNode instanceof \PhpParser\Node\Stmt\Nop) { - $newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $oldNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS)); + $newNode->setAttribute(AttributeKey::PHP_DOC_INFO, $oldNode->getAttribute(AttributeKey::PHP_DOC_INFO)); + if (!$newNode instanceof Nop) { + $newNode->setAttribute(AttributeKey::COMMENTS, $oldNode->getAttribute(AttributeKey::COMMENTS)); } } /** @@ -319,11 +319,11 @@ CODE_SAMPLE; protected function appendArgs(array $currentArgs, array $appendingArgs) : array { foreach ($appendingArgs as $appendingArg) { - $currentArgs[] = new \PhpParser\Node\Arg($appendingArg->value); + $currentArgs[] = new Arg($appendingArg->value); } return $currentArgs; } - protected function removeNode(\PhpParser\Node $node) : void + protected function removeNode(Node $node) : void { $this->nodeRemover->removeNode($node); } @@ -339,7 +339,7 @@ CODE_SAMPLE; } return \false; } - private function shouldSkipCurrentNode(\PhpParser\Node $node) : bool + private function shouldSkipCurrentNode(Node $node) : bool { if ($this->nodesToRemoveCollector->isNodeRemoved($node)) { return \true; @@ -352,12 +352,12 @@ CODE_SAMPLE; return \true; } $rectifiedNode = $this->rectifiedAnalyzer->verify($this, $node, $this->file); - return $rectifiedNode instanceof \Rector\Core\ValueObject\RectifiedNode; + return $rectifiedNode instanceof RectifiedNode; } /** * @param array $originalAttributes */ - private function mirrorAttributes(array $originalAttributes, \PhpParser\Node $newNode) : void + private function mirrorAttributes(array $originalAttributes, Node $newNode) : void { foreach ($originalAttributes as $attributeName => $oldAttributeValue) { if (!\in_array($attributeName, self::ATTRIBUTES_TO_MIRROR, \true)) { @@ -366,10 +366,10 @@ CODE_SAMPLE; $newNode->setAttribute($attributeName, $oldAttributeValue); } } - private function connectParentNodes(\PhpParser\Node $node) : void + private function connectParentNodes(Node $node) : void { - $nodeTraverser = new \PhpParser\NodeTraverser(); - $nodeTraverser->addVisitor(new \PhpParser\NodeVisitor\ParentConnectingVisitor()); + $nodeTraverser = new NodeTraverser(); + $nodeTraverser->addVisitor(new ParentConnectingVisitor()); $nodeTraverser->traverse([$node]); } private function printDebugCurrentFileAndRule() : void diff --git a/src/Rector/AbstractScopeAwareRector.php b/src/Rector/AbstractScopeAwareRector.php index 30360a317b8..b0753d58632 100644 --- a/src/Rector/AbstractScopeAwareRector.php +++ b/src/Rector/AbstractScopeAwareRector.php @@ -12,19 +12,19 @@ use Rector\NodeTypeResolver\Node\AttributeKey; * @internal Currently in experimental testing for core Rector rules. So we can verify if this feature is useful or not. * Do not use outside in custom rules. Go for AbstractRector instead. */ -abstract class AbstractScopeAwareRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ScopeAwarePhpRectorInterface +abstract class AbstractScopeAwareRector extends \Rector\Core\Rector\AbstractRector implements ScopeAwarePhpRectorInterface { /** * Process Node of matched type with its PHPStan scope * @return Node|Node[]|null */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - $errorMessage = \sprintf('Scope not available on "%s" node with parent node of "%s", but is required by a refactorWithScope() method of "%s" rule. Fix scope refresh on changed nodes first', \get_class($node), $parent instanceof \PhpParser\Node ? \get_class($parent) : null, static::class); - throw new \Rector\Core\Exception\ShouldNotHappenException($errorMessage); + $scope = $node->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + $errorMessage = \sprintf('Scope not available on "%s" node with parent node of "%s", but is required by a refactorWithScope() method of "%s" rule. Fix scope refresh on changed nodes first', \get_class($node), $parent instanceof Node ? \get_class($parent) : null, static::class); + throw new ShouldNotHappenException($errorMessage); } return $this->refactorWithScope($node, $scope); } diff --git a/src/Reflection/ReflectionResolver.php b/src/Reflection/ReflectionResolver.php index f18aa277345..8d7dc892b56 100644 --- a/src/Reflection/ReflectionResolver.php +++ b/src/Reflection/ReflectionResolver.php @@ -68,7 +68,7 @@ final class ReflectionResolver * @var \Rector\Core\NodeAnalyzer\ClassAnalyzer */ private $classAnalyzer; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PHPStan\Reflection\TypeToCallReflectionResolver\TypeToCallReflectionResolverRegistry $typeToCallReflectionResolverRegistry, \Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer) + public function __construct(ReflectionProvider $reflectionProvider, BetterNodeFinder $betterNodeFinder, NodeTypeResolver $nodeTypeResolver, NodeNameResolver $nodeNameResolver, TypeToCallReflectionResolverRegistry $typeToCallReflectionResolverRegistry, ClassAnalyzer $classAnalyzer) { $this->reflectionProvider = $reflectionProvider; $this->betterNodeFinder = $betterNodeFinder; @@ -80,25 +80,25 @@ final class ReflectionResolver /** * @required */ - public function autowire(\Rector\Core\PhpParser\AstResolver $astResolver) : void + public function autowire(AstResolver $astResolver) : void { $this->astResolver = $astResolver; } - public function resolveClassAndAnonymousClass(\PhpParser\Node\Stmt\ClassLike $classLike) : \PHPStan\Reflection\ClassReflection + public function resolveClassAndAnonymousClass(ClassLike $classLike) : ClassReflection { - if ($classLike instanceof \PhpParser\Node\Stmt\Class_ && $this->classAnalyzer->isAnonymousClass($classLike)) { - return $this->reflectionProvider->getAnonymousClassReflection($classLike, $classLike->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE)); + if ($classLike instanceof Class_ && $this->classAnalyzer->isAnonymousClass($classLike)) { + return $this->reflectionProvider->getAnonymousClassReflection($classLike, $classLike->getAttribute(AttributeKey::SCOPE)); } $className = (string) $this->nodeNameResolver->getName($classLike); return $this->reflectionProvider->getClass($className); } - public function resolveClassReflection(?\PhpParser\Node $node) : ?\PHPStan\Reflection\ClassReflection + public function resolveClassReflection(?Node $node) : ?ClassReflection { - if (!$node instanceof \PhpParser\Node) { + if (!$node instanceof Node) { return null; } - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { + $scope = $node->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { return null; } return $scope->getClassReflection(); @@ -106,16 +106,16 @@ final class ReflectionResolver /** * @param \PhpParser\Node\Expr\New_|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node */ - public function resolveClassReflectionSourceObject($node) : ?\PHPStan\Reflection\ClassReflection + public function resolveClassReflectionSourceObject($node) : ?ClassReflection { - if ($node instanceof \PhpParser\Node\Expr\New_ && $node->class instanceof \PhpParser\Node\Name\FullyQualified) { + if ($node instanceof New_ && $node->class instanceof FullyQualified) { $className = $node->class->toString(); if ($this->reflectionProvider->hasClass($className)) { return $this->reflectionProvider->getClass($className); } return null; } - if ($node instanceof \PhpParser\Node\Expr\MethodCall || $node instanceof \PhpParser\Node\Expr\StaticCall) { + if ($node instanceof MethodCall || $node instanceof StaticCall) { $classMethod = $this->astResolver->resolveClassMethodFromCall($node); return $this->resolveClassReflection($classMethod); } @@ -124,14 +124,14 @@ final class ReflectionResolver /** * @param class-string $className */ - public function resolveMethodReflection(string $className, string $methodName, ?\PHPStan\Analyser\Scope $scope) : ?\PHPStan\Reflection\MethodReflection + public function resolveMethodReflection(string $className, string $methodName, ?Scope $scope) : ?MethodReflection { if (!$this->reflectionProvider->hasClass($className)) { return null; } $classReflection = $this->reflectionProvider->getClass($className); // better, with support for "@method" annotation methods - if ($scope instanceof \PHPStan\Analyser\Scope) { + if ($scope instanceof Scope) { if ($classReflection->hasMethod($methodName)) { return $classReflection->getMethod($methodName, $scope); } @@ -140,35 +140,35 @@ final class ReflectionResolver } return null; } - public function resolveMethodReflectionFromStaticCall(\PhpParser\Node\Expr\StaticCall $staticCall) : ?\PHPStan\Reflection\MethodReflection + public function resolveMethodReflectionFromStaticCall(StaticCall $staticCall) : ?MethodReflection { $objectType = $this->nodeTypeResolver->getType($staticCall->class); /** @var array $classNames */ - $classNames = \PHPStan\Type\TypeUtils::getDirectClassNames($objectType); + $classNames = TypeUtils::getDirectClassNames($objectType); $methodName = $this->nodeNameResolver->getName($staticCall->name); if ($methodName === null) { return null; } - $scope = $staticCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $staticCall->getAttribute(AttributeKey::SCOPE); foreach ($classNames as $className) { $methodReflection = $this->resolveMethodReflection($className, $methodName, $scope); - if ($methodReflection instanceof \PHPStan\Reflection\MethodReflection) { + if ($methodReflection instanceof MethodReflection) { return $methodReflection; } } return null; } - public function resolveMethodReflectionFromMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PHPStan\Reflection\MethodReflection + public function resolveMethodReflectionFromMethodCall(MethodCall $methodCall) : ?MethodReflection { $callerType = $this->nodeTypeResolver->getType($methodCall->var); - if (!$callerType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$callerType instanceof TypeWithClassName) { return null; } $methodName = $this->nodeNameResolver->getName($methodCall->name); if ($methodName === null) { return null; } - $scope = $methodCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $methodCall->getAttribute(AttributeKey::SCOPE); return $this->resolveMethodReflection($callerType->getClassName(), $methodName, $scope); } /** @@ -177,18 +177,18 @@ final class ReflectionResolver */ public function resolveFunctionLikeReflectionFromCall($call) { - if ($call instanceof \PhpParser\Node\Expr\MethodCall) { + if ($call instanceof MethodCall) { return $this->resolveMethodReflectionFromMethodCall($call); } - if ($call instanceof \PhpParser\Node\Expr\StaticCall) { + if ($call instanceof StaticCall) { return $this->resolveMethodReflectionFromStaticCall($call); } return $this->resolveFunctionReflectionFromFuncCall($call); } - public function resolveMethodReflectionFromClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PHPStan\Reflection\MethodReflection + public function resolveMethodReflectionFromClassMethod(ClassMethod $classMethod) : ?MethodReflection { - $classLike = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($classMethod, ClassLike::class); + if (!$classLike instanceof ClassLike) { return null; } $className = $this->nodeNameResolver->getName($classLike); @@ -196,25 +196,25 @@ final class ReflectionResolver return null; } $methodName = $this->nodeNameResolver->getName($classMethod); - $scope = $classMethod->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $classMethod->getAttribute(AttributeKey::SCOPE); return $this->resolveMethodReflection($className, $methodName, $scope); } - public function resolveMethodReflectionFromNew(\PhpParser\Node\Expr\New_ $new) : ?\PHPStan\Reflection\MethodReflection + public function resolveMethodReflectionFromNew(New_ $new) : ?MethodReflection { $newClassType = $this->nodeTypeResolver->getType($new->class); - if (!$newClassType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$newClassType instanceof TypeWithClassName) { return null; } - $scope = $new->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - return $this->resolveMethodReflection($newClassType->getClassName(), \Rector\Core\ValueObject\MethodName::CONSTRUCT, $scope); + $scope = $new->getAttribute(AttributeKey::SCOPE); + return $this->resolveMethodReflection($newClassType->getClassName(), MethodName::CONSTRUCT, $scope); } /** * @param \PhpParser\Node\Expr\PropertyFetch|\PhpParser\Node\Expr\StaticPropertyFetch $propertyFetch */ - public function resolvePropertyReflectionFromPropertyFetch($propertyFetch) : ?\PHPStan\Reflection\Php\PhpPropertyReflection + public function resolvePropertyReflectionFromPropertyFetch($propertyFetch) : ?PhpPropertyReflection { - $fetcheeType = $propertyFetch instanceof \PhpParser\Node\Expr\PropertyFetch ? $this->nodeTypeResolver->getType($propertyFetch->var) : $this->nodeTypeResolver->getType($propertyFetch->class); - if (!$fetcheeType instanceof \PHPStan\Type\TypeWithClassName) { + $fetcheeType = $propertyFetch instanceof PropertyFetch ? $this->nodeTypeResolver->getType($propertyFetch->var) : $this->nodeTypeResolver->getType($propertyFetch->class); + if (!$fetcheeType instanceof TypeWithClassName) { return null; } if (!$this->reflectionProvider->hasClass($fetcheeType->getClassName())) { @@ -228,10 +228,10 @@ final class ReflectionResolver if (!$classReflection->hasProperty($propertyName)) { return null; } - $scope = $propertyFetch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if ($scope instanceof \PHPStan\Analyser\Scope) { + $scope = $propertyFetch->getAttribute(AttributeKey::SCOPE); + if ($scope instanceof Scope) { $propertyRelfection = $classReflection->getProperty($propertyName, $scope); - if ($propertyRelfection instanceof \PHPStan\Reflection\Php\PhpPropertyReflection) { + if ($propertyRelfection instanceof PhpPropertyReflection) { return $propertyRelfection; } return null; @@ -241,16 +241,16 @@ final class ReflectionResolver /** * @return \PHPStan\Reflection\FunctionReflection|\PHPStan\Reflection\MethodReflection|null */ - private function resolveFunctionReflectionFromFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall) + private function resolveFunctionReflectionFromFuncCall(FuncCall $funcCall) { - $scope = $funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if ($funcCall->name instanceof \PhpParser\Node\Name) { + $scope = $funcCall->getAttribute(AttributeKey::SCOPE); + if ($funcCall->name instanceof Name) { if ($this->reflectionProvider->hasFunction($funcCall->name, $scope)) { return $this->reflectionProvider->getFunction($funcCall->name, $scope); } return null; } - if (!$scope instanceof \PHPStan\Analyser\Scope) { + if (!$scope instanceof Scope) { return null; } // fallback to callable diff --git a/src/Reporting/MissingRectorRulesReporter.php b/src/Reporting/MissingRectorRulesReporter.php index 7de09693a78..4aff645b2d2 100644 --- a/src/Reporting/MissingRectorRulesReporter.php +++ b/src/Reporting/MissingRectorRulesReporter.php @@ -23,24 +23,24 @@ final class MissingRectorRulesReporter /** * @param RectorInterface[] $rectors */ - public function __construct(array $rectors, \Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle) + public function __construct(array $rectors, OutputStyleInterface $rectorOutputStyle) { $this->rectors = $rectors; $this->rectorOutputStyle = $rectorOutputStyle; } public function reportIfMissing() : ?int { - $activeRectors = \array_filter($this->rectors, function (\Rector\Core\Contract\Rector\RectorInterface $rector) : bool { - if ($rector instanceof \Rector\PostRector\Contract\Rector\PostRectorInterface) { + $activeRectors = \array_filter($this->rectors, function (RectorInterface $rector) : bool { + if ($rector instanceof PostRectorInterface) { return \false; } - return !$rector instanceof \Rector\PostRector\Contract\Rector\ComplementaryRectorInterface; + return !$rector instanceof ComplementaryRectorInterface; }); if ($activeRectors !== []) { return null; } $this->report(); - return \RectorPrefix20220607\Symfony\Component\Console\Command\Command::FAILURE; + return Command::FAILURE; } public function report() : void { diff --git a/src/StaticReflection/DynamicSourceLocatorDecorator.php b/src/StaticReflection/DynamicSourceLocatorDecorator.php index 762d23dbf39..bae18d6c7bf 100644 --- a/src/StaticReflection/DynamicSourceLocatorDecorator.php +++ b/src/StaticReflection/DynamicSourceLocatorDecorator.php @@ -27,7 +27,7 @@ final class DynamicSourceLocatorDecorator * @var \Rector\Core\FileSystem\PhpFilesFinder */ private $phpFilesFinder; - public function __construct(\RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemFilter $fileSystemFilter, \Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider $dynamicSourceLocatorProvider, \Rector\Core\FileSystem\PhpFilesFinder $phpFilesFinder) + public function __construct(FileSystemFilter $fileSystemFilter, DynamicSourceLocatorProvider $dynamicSourceLocatorProvider, PhpFilesFinder $phpFilesFinder) { $this->fileSystemFilter = $fileSystemFilter; $this->dynamicSourceLocatorProvider = $dynamicSourceLocatorProvider; diff --git a/src/StaticReflection/SourceLocator/ParentAttributeSourceLocator.php b/src/StaticReflection/SourceLocator/ParentAttributeSourceLocator.php index e10a03e86d9..c5fb36081e9 100644 --- a/src/StaticReflection/SourceLocator/ParentAttributeSourceLocator.php +++ b/src/StaticReflection/SourceLocator/ParentAttributeSourceLocator.php @@ -23,7 +23,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; * * @see https://github.com/rectorphp/rector-src/pull/368/ */ -final class ParentAttributeSourceLocator implements \PHPStan\BetterReflection\SourceLocator\Type\SourceLocator +final class ParentAttributeSourceLocator implements SourceLocator { /** * @var \Rector\Core\PhpParser\AstResolver @@ -34,18 +34,18 @@ final class ParentAttributeSourceLocator implements \PHPStan\BetterReflection\So * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ReflectionProvider $reflectionProvider) { $this->reflectionProvider = $reflectionProvider; } /** * @required */ - public function autowire(\Rector\Core\PhpParser\AstResolver $astResolver) : void + public function autowire(AstResolver $astResolver) : void { $this->astResolver = $astResolver; } - public function locateIdentifier(\PHPStan\BetterReflection\Reflector\Reflector $reflector, \PHPStan\BetterReflection\Identifier\Identifier $identifier) : ?\PHPStan\BetterReflection\Reflection\Reflection + public function locateIdentifier(Reflector $reflector, Identifier $identifier) : ?Reflection { $identifierName = $identifier->getName(); if ($identifierName === 'Symfony\\Component\\DependencyInjection\\Attribute\\Autoconfigure' && $this->reflectionProvider->hasClass($identifierName)) { @@ -54,17 +54,17 @@ final class ParentAttributeSourceLocator implements \PHPStan\BetterReflection\So if ($class === null) { return null; } - $class->namespacedName = new \PhpParser\Node\Name\FullyQualified($identifierName); - $fakeLocatedSource = new \PHPStan\BetterReflection\SourceLocator\Located\LocatedSource('virtual', null); - $classReflector = new \PHPStan\BetterReflection\Reflector\ClassReflector($this); - return \PHPStan\BetterReflection\Reflection\ReflectionClass::createFromNode($classReflector, $class, $fakeLocatedSource, new \PhpParser\Node\Stmt\Namespace_(new \PhpParser\Node\Name('Symfony\\Component\\DependencyInjection\\Attribute'))); + $class->namespacedName = new FullyQualified($identifierName); + $fakeLocatedSource = new LocatedSource('virtual', null); + $classReflector = new ClassReflector($this); + return ReflectionClass::createFromNode($classReflector, $class, $fakeLocatedSource, new Namespace_(new Name('Symfony\\Component\\DependencyInjection\\Attribute'))); } return null; } /** * @return array */ - public function locateIdentifiersByType(\PHPStan\BetterReflection\Reflector\Reflector $reflector, \PHPStan\BetterReflection\Identifier\IdentifierType $identifierType) : array + public function locateIdentifiersByType(Reflector $reflector, IdentifierType $identifierType) : array { return []; } diff --git a/src/StaticReflection/SourceLocator/RenamedClassesSourceLocator.php b/src/StaticReflection/SourceLocator/RenamedClassesSourceLocator.php index d0b0b373c4f..186526beb43 100644 --- a/src/StaticReflection/SourceLocator/RenamedClassesSourceLocator.php +++ b/src/StaticReflection/SourceLocator/RenamedClassesSourceLocator.php @@ -16,18 +16,18 @@ use RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\ClassBuilder; /** * Inspired from \PHPStan\BetterReflection\SourceLocator\Type\StringSourceLocator */ -final class RenamedClassesSourceLocator implements \PHPStan\BetterReflection\SourceLocator\Type\SourceLocator +final class RenamedClassesSourceLocator implements SourceLocator { /** * @readonly * @var \Rector\Core\Configuration\RenamedClassesDataCollector */ private $renamedClassesDataCollector; - public function __construct(\Rector\Core\Configuration\RenamedClassesDataCollector $renamedClassesDataCollector) + public function __construct(RenamedClassesDataCollector $renamedClassesDataCollector) { $this->renamedClassesDataCollector = $renamedClassesDataCollector; } - public function locateIdentifier(\PHPStan\BetterReflection\Reflector\Reflector $reflector, \PHPStan\BetterReflection\Identifier\Identifier $identifier) : ?\PHPStan\BetterReflection\Reflection\Reflection + public function locateIdentifier(Reflector $reflector, Identifier $identifier) : ?Reflection { if (!$identifier->isClass()) { return null; @@ -45,16 +45,16 @@ final class RenamedClassesSourceLocator implements \PHPStan\BetterReflection\Sou /** * @return array */ - public function locateIdentifiersByType(\PHPStan\BetterReflection\Reflector\Reflector $reflector, \PHPStan\BetterReflection\Identifier\IdentifierType $identifierType) : array + public function locateIdentifiersByType(Reflector $reflector, IdentifierType $identifierType) : array { return []; } - private function createFakeReflectionClassFromClassName(string $oldClass) : \PHPStan\BetterReflection\Reflection\ReflectionClass + private function createFakeReflectionClassFromClassName(string $oldClass) : ReflectionClass { - $classBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\ClassBuilder($oldClass); + $classBuilder = new ClassBuilder($oldClass); $class = $classBuilder->getNode(); - $fakeLocatedSource = new \PHPStan\BetterReflection\SourceLocator\Located\LocatedSource('virtual', null); - $classReflector = new \PHPStan\BetterReflection\Reflector\ClassReflector($this); - return \PHPStan\BetterReflection\Reflection\ReflectionClass::createFromNode($classReflector, $class, $fakeLocatedSource); + $fakeLocatedSource = new LocatedSource('virtual', null); + $classReflector = new ClassReflector($this); + return ReflectionClass::createFromNode($classReflector, $class, $fakeLocatedSource); } } diff --git a/src/Util/MemoryLimiter.php b/src/Util/MemoryLimiter.php index 682d6d88e0d..d3d33cda6d4 100644 --- a/src/Util/MemoryLimiter.php +++ b/src/Util/MemoryLimiter.php @@ -16,7 +16,7 @@ final class MemoryLimiter * @see https://regex101.com/r/pmiGUM/1 */ private const VALID_MEMORY_LIMIT_REGEX = '#^-?\\d+[kMG]?$#i'; - public function adjust(\Rector\Core\ValueObject\Configuration $configuration) : void + public function adjust(Configuration $configuration) : void { $memoryLimit = $configuration->getMemoryLimit(); if ($memoryLimit === null) { @@ -26,16 +26,16 @@ final class MemoryLimiter $memorySetResult = \ini_set('memory_limit', $memoryLimit); if ($memorySetResult === \false) { $errorMessage = \sprintf('Memory limit "%s" cannot be set.', $memoryLimit); - throw new \Rector\RectorGenerator\Exception\ConfigurationException($errorMessage); + throw new ConfigurationException($errorMessage); } } private function validateMemoryLimitFormat(string $memoryLimit) : void { - $memoryLimitFormatMatch = \RectorPrefix20220607\Nette\Utils\Strings::match($memoryLimit, self::VALID_MEMORY_LIMIT_REGEX); + $memoryLimitFormatMatch = Strings::match($memoryLimit, self::VALID_MEMORY_LIMIT_REGEX); if ($memoryLimitFormatMatch !== null) { return; } $errorMessage = \sprintf('Invalid memory limit format "%s".', $memoryLimit); - throw new \Rector\RectorGenerator\Exception\ConfigurationException($errorMessage); + throw new ConfigurationException($errorMessage); } } diff --git a/src/Util/StaticRectorStrings.php b/src/Util/StaticRectorStrings.php index d6ccfd3f92e..b2cfad3e012 100644 --- a/src/Util/StaticRectorStrings.php +++ b/src/Util/StaticRectorStrings.php @@ -19,7 +19,7 @@ final class StaticRectorStrings if ($input === \strtolower($input)) { return $input; } - $matches = \RectorPrefix20220607\Nette\Utils\Strings::matchAll($input, self::CAMEL_CASE_SPLIT_REGEX); + $matches = Strings::matchAll($input, self::CAMEL_CASE_SPLIT_REGEX); $parts = []; foreach ($matches as $match) { $matchedPart = (string) $match[0]; @@ -47,7 +47,7 @@ final class StaticRectorStrings { foreach ($prefixesToRemove as $prefixToRemove) { if (\strncmp($value, $prefixToRemove, \strlen($prefixToRemove)) === 0) { - $value = \RectorPrefix20220607\Nette\Utils\Strings::substring($value, \RectorPrefix20220607\Nette\Utils\Strings::length($prefixToRemove)); + $value = Strings::substring($value, Strings::length($prefixToRemove)); } } return $value; @@ -59,7 +59,7 @@ final class StaticRectorStrings { foreach ($suffixesToRemove as $suffixToRemove) { if (\substr_compare($value, $suffixToRemove, -\strlen($suffixToRemove)) === 0) { - $value = \RectorPrefix20220607\Nette\Utils\Strings::substring($value, 0, -\RectorPrefix20220607\Nette\Utils\Strings::length($suffixToRemove)); + $value = Strings::substring($value, 0, -Strings::length($suffixToRemove)); } } return $value; diff --git a/src/Util/StringUtils.php b/src/Util/StringUtils.php index 0a4e47eafc9..d86cfe03a3d 100644 --- a/src/Util/StringUtils.php +++ b/src/Util/StringUtils.php @@ -8,7 +8,7 @@ final class StringUtils { public static function isMatch(string $value, string $regex) : bool { - $match = \RectorPrefix20220607\Nette\Utils\Strings::match($value, $regex); + $match = Strings::match($value, $regex); return $match !== null; } } diff --git a/src/Validation/Collector/EmptyConfigurableRectorCollector.php b/src/Validation/Collector/EmptyConfigurableRectorCollector.php index cee260c0bd6..31f3d6bb37b 100644 --- a/src/Validation/Collector/EmptyConfigurableRectorCollector.php +++ b/src/Validation/Collector/EmptyConfigurableRectorCollector.php @@ -18,7 +18,7 @@ final class EmptyConfigurableRectorCollector * @var \Symfony\Component\DependencyInjection\ContainerBuilder */ private $containerBuilder; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder) + public function __construct(ContainerBuilder $containerBuilder) { $this->containerBuilder = $containerBuilder; } @@ -29,14 +29,14 @@ final class EmptyConfigurableRectorCollector { $emptyConfigurableRectorClasses = []; foreach ($this->containerBuilder->getServiceIds() as $serviceId) { - if (!\is_a($serviceId, \Rector\Core\Contract\Rector\ConfigurableRectorInterface::class, \true)) { + if (!\is_a($serviceId, ConfigurableRectorInterface::class, \true)) { continue; } - if (\is_a($serviceId, \Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface::class, \true)) { + if (\is_a($serviceId, AllowEmptyConfigurableRectorInterface::class, \true)) { continue; } // it seems always loaded - if (\is_a($serviceId, \Rector\Core\NonPhpFile\Rector\RenameClassNonPhpRector::class, \true)) { + if (\is_a($serviceId, RenameClassNonPhpRector::class, \true)) { continue; } $serviceDefinition = $this->containerBuilder->getDefinition($serviceId); @@ -47,7 +47,7 @@ final class EmptyConfigurableRectorCollector } return $emptyConfigurableRectorClasses; } - private function hasConfigureMethodCall(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) : bool + private function hasConfigureMethodCall(Definition $definition) : bool { foreach ($definition->getMethodCalls() as $methodCall) { if ($methodCall[0] === 'configure') { diff --git a/src/Validation/EmptyConfigurableRectorChecker.php b/src/Validation/EmptyConfigurableRectorChecker.php index 8263058f868..b819a8ac1a8 100644 --- a/src/Validation/EmptyConfigurableRectorChecker.php +++ b/src/Validation/EmptyConfigurableRectorChecker.php @@ -18,7 +18,7 @@ final class EmptyConfigurableRectorChecker * @var \Rector\Core\Contract\Console\OutputStyleInterface */ private $rectorOutputStyle; - public function __construct(\Rector\Core\Validation\Collector\EmptyConfigurableRectorCollector $emptyConfigurableRectorCollector, \Rector\Core\Contract\Console\OutputStyleInterface $rectorOutputStyle) + public function __construct(EmptyConfigurableRectorCollector $emptyConfigurableRectorCollector, OutputStyleInterface $rectorOutputStyle) { $this->emptyConfigurableRectorCollector = $emptyConfigurableRectorCollector; $this->rectorOutputStyle = $rectorOutputStyle; diff --git a/src/Validation/RectorAssert.php b/src/Validation/RectorAssert.php index ddf528325a5..2887a865a2c 100644 --- a/src/Validation/RectorAssert.php +++ b/src/Validation/RectorAssert.php @@ -21,10 +21,10 @@ final class RectorAssert */ public static function className(string $className) : void { - if (\Rector\Core\Util\StringUtils::isMatch($className, self::CLASS_NAME_REGEX)) { + if (StringUtils::isMatch($className, self::CLASS_NAME_REGEX)) { return; } $errorMessage = $className . ' is not a valid class name'; - throw new \RectorPrefix20220607\Webmozart\Assert\InvalidArgumentException($errorMessage); + throw new InvalidArgumentException($errorMessage); } } diff --git a/src/ValueObject/Application/File.php b/src/ValueObject/Application/File.php index 8bd2e9dc061..a05b77afe9b 100644 --- a/src/ValueObject/Application/File.php +++ b/src/ValueObject/Application/File.php @@ -7,7 +7,7 @@ use PhpParser\Node\Stmt; use Rector\ChangesReporting\ValueObject\RectorWithLineChange; use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\ValueObject\Reporting\FileDiff; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; /** * @see \Rector\Core\ValueObjectFactory\Application\FileFactory */ @@ -51,7 +51,7 @@ final class File * @var string */ private $fileContent; - public function __construct(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo, string $fileContent) + public function __construct(SmartFileInfo $smartFileInfo, string $fileContent) { $this->smartFileInfo = $smartFileInfo; $this->fileContent = $fileContent; @@ -61,7 +61,7 @@ final class File { return $this->smartFileInfo->getRealPath(); } - public function getSmartFileInfo() : \Symplify\SmartFileSystem\SmartFileInfo + public function getSmartFileInfo() : SmartFileInfo { return $this->smartFileInfo; } @@ -93,11 +93,11 @@ final class File { $this->hasChanged = $status; } - public function setFileDiff(\Rector\Core\ValueObject\Reporting\FileDiff $fileDiff) : void + public function setFileDiff(FileDiff $fileDiff) : void { $this->fileDiff = $fileDiff; } - public function getFileDiff() : ?\Rector\Core\ValueObject\Reporting\FileDiff + public function getFileDiff() : ?FileDiff { return $this->fileDiff; } @@ -109,7 +109,7 @@ final class File public function hydrateStmtsAndTokens(array $newStmts, array $oldStmts, array $oldTokens) : void { if ($this->oldStmts !== []) { - throw new \Rector\Core\Exception\ShouldNotHappenException('Double stmts override'); + throw new ShouldNotHappenException('Double stmts override'); } $this->oldStmts = $oldStmts; $this->newStmts = $newStmts; @@ -143,7 +143,7 @@ final class File { $this->newStmts = $newStmts; } - public function addRectorClassWithLine(\Rector\ChangesReporting\ValueObject\RectorWithLineChange $rectorWithLineChange) : void + public function addRectorClassWithLine(RectorWithLineChange $rectorWithLineChange) : void { $this->rectorWithLineChanges[] = $rectorWithLineChange; } diff --git a/src/ValueObject/Application/MovedFile.php b/src/ValueObject/Application/MovedFile.php index 3c87ab6aef4..866649a889f 100644 --- a/src/ValueObject/Application/MovedFile.php +++ b/src/ValueObject/Application/MovedFile.php @@ -5,7 +5,7 @@ namespace Rector\Core\ValueObject\Application; use PhpParser\Node\Stmt; use Rector\FileSystemRector\Contract\FileWithNodesInterface; -final class MovedFile implements \Rector\FileSystemRector\Contract\FileWithNodesInterface +final class MovedFile implements FileWithNodesInterface { /** * @readonly diff --git a/src/ValueObject/Configuration.php b/src/ValueObject/Configuration.php index e65c40ae565..372bf54ba8d 100644 --- a/src/ValueObject/Configuration.php +++ b/src/ValueObject/Configuration.php @@ -25,7 +25,7 @@ final class Configuration * @readonly * @var string */ - private $outputFormat = \Rector\ChangesReporting\Output\ConsoleOutputFormatter::NAME; + private $outputFormat = ConsoleOutputFormatter::NAME; /** * @var string[] * @readonly @@ -68,7 +68,7 @@ final class Configuration * @param string|null $parallelIdentifier * @param string|null $memoryLimit */ - public function __construct(bool $isDryRun = \false, bool $showProgressBar = \true, bool $shouldClearCache = \false, string $outputFormat = \Rector\ChangesReporting\Output\ConsoleOutputFormatter::NAME, array $fileExtensions = ['php'], array $paths = [], bool $showDiffs = \true, $parallelPort = null, $parallelIdentifier = null, bool $isParallel = \false, $memoryLimit = null) + public function __construct(bool $isDryRun = \false, bool $showProgressBar = \true, bool $shouldClearCache = \false, string $outputFormat = ConsoleOutputFormatter::NAME, array $fileExtensions = ['php'], array $paths = [], bool $showDiffs = \true, $parallelPort = null, $parallelIdentifier = null, bool $isParallel = \false, $memoryLimit = null) { $this->isDryRun = $isDryRun; $this->showProgressBar = $showProgressBar; diff --git a/src/ValueObject/Error/SystemError.php b/src/ValueObject/Error/SystemError.php index 979bb04f18a..abeac94ce5e 100644 --- a/src/ValueObject/Error/SystemError.php +++ b/src/ValueObject/Error/SystemError.php @@ -5,7 +5,7 @@ namespace Rector\Core\ValueObject\Error; use Rector\Parallel\ValueObject\Name; use RectorPrefix20220607\Symplify\EasyParallel\Contract\SerializableInterface; -final class SystemError implements \RectorPrefix20220607\Symplify\EasyParallel\Contract\SerializableInterface +final class SystemError implements SerializableInterface { /** * @readonly @@ -70,14 +70,14 @@ final class SystemError implements \RectorPrefix20220607\Symplify\EasyParallel\C */ public function jsonSerialize() : array { - return [\Rector\Parallel\ValueObject\Name::MESSAGE => $this->message, \Rector\Parallel\ValueObject\Name::RELATIVE_FILE_PATH => $this->relativeFilePath, \Rector\Parallel\ValueObject\Name::LINE => $this->line, \Rector\Parallel\ValueObject\Name::RECTOR_CLASS => $this->rectorClass]; + return [Name::MESSAGE => $this->message, Name::RELATIVE_FILE_PATH => $this->relativeFilePath, Name::LINE => $this->line, Name::RECTOR_CLASS => $this->rectorClass]; } /** * @param mixed[] $json */ - public static function decode(array $json) : \RectorPrefix20220607\Symplify\EasyParallel\Contract\SerializableInterface + public static function decode(array $json) : SerializableInterface { - return new self($json[\Rector\Parallel\ValueObject\Name::MESSAGE], $json[\Rector\Parallel\ValueObject\Name::RELATIVE_FILE_PATH], $json[\Rector\Parallel\ValueObject\Name::LINE], $json[\Rector\Parallel\ValueObject\Name::RECTOR_CLASS]); + return new self($json[Name::MESSAGE], $json[Name::RELATIVE_FILE_PATH], $json[Name::LINE], $json[Name::RECTOR_CLASS]); } public function getRectorClass() : ?string { diff --git a/src/ValueObject/ProcessResult.php b/src/ValueObject/ProcessResult.php index 8ade87ee2dc..ad6f3536243 100644 --- a/src/ValueObject/ProcessResult.php +++ b/src/ValueObject/ProcessResult.php @@ -5,7 +5,7 @@ namespace Rector\Core\ValueObject; use Rector\Core\ValueObject\Error\SystemError; use Rector\Core\ValueObject\Reporting\FileDiff; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Core\ValueObjectFactory\ProcessResultFactory @@ -48,8 +48,8 @@ final class ProcessResult $this->addedFilesCount = $addedFilesCount; $this->removedFilesCount = $removedFilesCount; $this->removedNodeCount = $removedNodeCount; - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($fileDiffs, \Rector\Core\ValueObject\Reporting\FileDiff::class); - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($systemErrors, \Rector\Core\ValueObject\Error\SystemError::class); + Assert::allIsAOf($fileDiffs, FileDiff::class); + Assert::allIsAOf($systemErrors, SystemError::class); } /** * @return FileDiff[] @@ -88,7 +88,7 @@ final class ProcessResult { $fileInfos = []; foreach ($this->fileDiffs as $fileDiff) { - $fileInfos[] = new \Symplify\SmartFileSystem\SmartFileInfo($fileDiff->getRelativeFilePath()); + $fileInfos[] = new SmartFileInfo($fileDiff->getRelativeFilePath()); } return \array_unique($fileInfos); } diff --git a/src/ValueObject/RectifiedNode.php b/src/ValueObject/RectifiedNode.php index eacf4a37689..9943eb7ec17 100644 --- a/src/ValueObject/RectifiedNode.php +++ b/src/ValueObject/RectifiedNode.php @@ -20,7 +20,7 @@ final class RectifiedNode /** * @param class-string $rectorClass */ - public function __construct(string $rectorClass, \PhpParser\Node $node) + public function __construct(string $rectorClass, Node $node) { $this->rectorClass = $rectorClass; $this->node = $node; @@ -32,7 +32,7 @@ final class RectifiedNode { return $this->rectorClass; } - public function getNode() : \PhpParser\Node + public function getNode() : Node { return $this->node; } diff --git a/src/ValueObject/Reporting/FileDiff.php b/src/ValueObject/Reporting/FileDiff.php index da145787852..f6d7eb58bdb 100644 --- a/src/ValueObject/Reporting/FileDiff.php +++ b/src/ValueObject/Reporting/FileDiff.php @@ -8,7 +8,7 @@ use Rector\ChangesReporting\ValueObject\RectorWithLineChange; use Rector\Core\Contract\Rector\RectorInterface; use RectorPrefix20220607\Symplify\EasyParallel\Contract\SerializableInterface; use RectorPrefix20220607\Webmozart\Assert\Assert; -final class FileDiff implements \RectorPrefix20220607\Symplify\EasyParallel\Contract\SerializableInterface +final class FileDiff implements SerializableInterface { /** * @var string @@ -64,7 +64,7 @@ final class FileDiff implements \RectorPrefix20220607\Symplify\EasyParallel\Cont $this->diff = $diff; $this->diffConsoleFormatted = $diffConsoleFormatted; $this->rectorsWithLineChanges = $rectorsWithLineChanges; - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($rectorsWithLineChanges, \Rector\ChangesReporting\ValueObject\RectorWithLineChange::class); + Assert::allIsAOf($rectorsWithLineChanges, RectorWithLineChange::class); } public function getDiff() : string { @@ -98,7 +98,7 @@ final class FileDiff implements \RectorPrefix20220607\Symplify\EasyParallel\Cont } public function getFirstLineNumber() : ?int { - $match = \RectorPrefix20220607\Nette\Utils\Strings::match($this->diff, self::FIRST_LINE_REGEX); + $match = Strings::match($this->diff, self::FIRST_LINE_REGEX); // probably some error in diff if (!isset($match[self::FIRST_LINE_KEY])) { return null; @@ -115,11 +115,11 @@ final class FileDiff implements \RectorPrefix20220607\Symplify\EasyParallel\Cont /** * @param array $json */ - public static function decode(array $json) : \RectorPrefix20220607\Symplify\EasyParallel\Contract\SerializableInterface + public static function decode(array $json) : SerializableInterface { $rectorWithLineChanges = []; foreach ($json[self::KEY_RECTORS_WITH_LINE_CHANGES] as $rectorWithLineChangesJson) { - $rectorWithLineChanges[] = \Rector\ChangesReporting\ValueObject\RectorWithLineChange::decode($rectorWithLineChangesJson); + $rectorWithLineChanges[] = RectorWithLineChange::decode($rectorWithLineChangesJson); } return new self($json[self::KEY_RELATIVE_FILE_PATH], $json[self::KEY_DIFF], $json[self::KEY_DIFF_CONSOLE_FORMATTED], $rectorWithLineChanges); } diff --git a/src/ValueObject/SprintfStringAndArgs.php b/src/ValueObject/SprintfStringAndArgs.php index 6e2db924d2a..1894b0f05e9 100644 --- a/src/ValueObject/SprintfStringAndArgs.php +++ b/src/ValueObject/SprintfStringAndArgs.php @@ -20,7 +20,7 @@ final class SprintfStringAndArgs /** * @param Expr[] $arrayItems */ - public function __construct(\PhpParser\Node\Scalar\String_ $string, array $arrayItems) + public function __construct(String_ $string, array $arrayItems) { $this->string = $string; $this->arrayItems = $arrayItems; diff --git a/src/ValueObject/Visibility.php b/src/ValueObject/Visibility.php index 884e69449f8..bbf6af7f3aa 100644 --- a/src/ValueObject/Visibility.php +++ b/src/ValueObject/Visibility.php @@ -9,29 +9,29 @@ final class Visibility /** * @var int */ - public const PUBLIC = \PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC; + public const PUBLIC = Class_::MODIFIER_PUBLIC; /** * @var int */ - public const PROTECTED = \PhpParser\Node\Stmt\Class_::MODIFIER_PROTECTED; + public const PROTECTED = Class_::MODIFIER_PROTECTED; /** * @var int */ - public const PRIVATE = \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE; + public const PRIVATE = Class_::MODIFIER_PRIVATE; /** * @var int */ - public const STATIC = \PhpParser\Node\Stmt\Class_::MODIFIER_STATIC; + public const STATIC = Class_::MODIFIER_STATIC; /** * @var int */ - public const ABSTRACT = \PhpParser\Node\Stmt\Class_::MODIFIER_ABSTRACT; + public const ABSTRACT = Class_::MODIFIER_ABSTRACT; /** * @var int */ - public const FINAL = \PhpParser\Node\Stmt\Class_::MODIFIER_FINAL; + public const FINAL = Class_::MODIFIER_FINAL; /** * @var int */ - public const READONLY = \PhpParser\Node\Stmt\Class_::MODIFIER_READONLY; + public const READONLY = Class_::MODIFIER_READONLY; } diff --git a/src/ValueObjectFactory/Application/FileFactory.php b/src/ValueObjectFactory/Application/FileFactory.php index 062fa795d97..b3a389fa15b 100644 --- a/src/ValueObjectFactory/Application/FileFactory.php +++ b/src/ValueObjectFactory/Application/FileFactory.php @@ -8,7 +8,7 @@ use Rector\Core\Contract\Processor\FileProcessorInterface; use Rector\Core\FileSystem\FilesFinder; use Rector\Core\ValueObject\Application\File; use Rector\Core\ValueObject\Configuration; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; /** * @see \Rector\Core\ValueObject\Application\File */ @@ -32,7 +32,7 @@ final class FileFactory /** * @param FileProcessorInterface[] $fileProcessors */ - public function __construct(\Rector\Core\FileSystem\FilesFinder $filesFinder, \Rector\Caching\Detector\ChangedFilesDetector $changedFilesDetector, array $fileProcessors) + public function __construct(FilesFinder $filesFinder, ChangedFilesDetector $changedFilesDetector, array $fileProcessors) { $this->filesFinder = $filesFinder; $this->changedFilesDetector = $changedFilesDetector; @@ -42,7 +42,7 @@ final class FileFactory * @param string[] $paths * @return SmartFileInfo[] */ - public function createFileInfosFromPaths(array $paths, \Rector\Core\ValueObject\Configuration $configuration) : array + public function createFileInfosFromPaths(array $paths, Configuration $configuration) : array { if ($configuration->shouldClearCache()) { $this->changedFilesDetector->clear(); @@ -54,19 +54,19 @@ final class FileFactory * @param string[] $paths * @return File[] */ - public function createFromPaths(array $paths, \Rector\Core\ValueObject\Configuration $configuration) : array + public function createFromPaths(array $paths, Configuration $configuration) : array { $fileInfos = $this->createFileInfosFromPaths($paths, $configuration); $files = []; foreach ($fileInfos as $fileInfo) { - $files[] = new \Rector\Core\ValueObject\Application\File($fileInfo, $fileInfo->getContents()); + $files[] = new File($fileInfo, $fileInfo->getContents()); } return $files; } /** * @return string[] */ - private function resolveSupportedFileExtensions(\Rector\Core\ValueObject\Configuration $configuration) : array + private function resolveSupportedFileExtensions(Configuration $configuration) : array { $supportedFileExtensions = []; foreach ($this->fileProcessors as $fileProcessor) { diff --git a/src/ValueObjectFactory/ProcessResultFactory.php b/src/ValueObjectFactory/ProcessResultFactory.php index 0fac6ef2b54..bcaf7e67b50 100644 --- a/src/ValueObjectFactory/ProcessResultFactory.php +++ b/src/ValueObjectFactory/ProcessResultFactory.php @@ -22,7 +22,7 @@ final class ProcessResultFactory * @var \Rector\PostRector\Collector\NodesToRemoveCollector */ private $nodesToRemoveCollector; - public function __construct(\Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, \Rector\PostRector\Collector\NodesToRemoveCollector $nodesToRemoveCollector) + public function __construct(RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, NodesToRemoveCollector $nodesToRemoveCollector) { $this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector; $this->nodesToRemoveCollector = $nodesToRemoveCollector; @@ -30,10 +30,10 @@ final class ProcessResultFactory /** * @param array{system_errors: SystemError[], file_diffs: FileDiff[]} $errorsAndFileDiffs */ - public function create(array $errorsAndFileDiffs) : \Rector\Core\ValueObject\ProcessResult + public function create(array $errorsAndFileDiffs) : ProcessResult { - $systemErrors = $errorsAndFileDiffs[\Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS]; - $fileDiffs = $errorsAndFileDiffs[\Rector\Parallel\ValueObject\Bridge::FILE_DIFFS]; - return new \Rector\Core\ValueObject\ProcessResult($systemErrors, $fileDiffs, $this->removedAndAddedFilesCollector->getAddedFileCount(), $this->removedAndAddedFilesCollector->getRemovedFilesCount(), $this->nodesToRemoveCollector->getCount()); + $systemErrors = $errorsAndFileDiffs[Bridge::SYSTEM_ERRORS]; + $fileDiffs = $errorsAndFileDiffs[Bridge::FILE_DIFFS]; + return new ProcessResult($systemErrors, $fileDiffs, $this->removedAndAddedFilesCollector->getAddedFileCount(), $this->removedAndAddedFilesCollector->getRemovedFilesCount(), $this->nodesToRemoveCollector->getCount()); } } diff --git a/src/functions/node_helper.php b/src/functions/node_helper.php index 75278a41249..a30b5f213ea 100644 --- a/src/functions/node_helper.php +++ b/src/functions/node_helper.php @@ -12,13 +12,13 @@ if (!\function_exists('dump_with_depth')) { */ function dump_with_depth($value, int $depth = 2) : void { - \RectorPrefix20220607\Tracy\Dumper::dump($value, [\RectorPrefix20220607\Tracy\Dumper::DEPTH => $depth]); + Dumper::dump($value, [Dumper::DEPTH => $depth]); } } if (!\function_exists('dn')) { - function dn(\PhpParser\Node $node, int $depth = 2) : void + function dn(Node $node, int $depth = 2) : void { - \RectorPrefix20220607\dump_node($node, $depth); + dump_node($node, $depth); } } if (!\function_exists('dump_node')) { @@ -29,7 +29,7 @@ if (!\function_exists('dump_node')) { { $nodes = \is_array($node) ? $node : [$node]; foreach ($nodes as $node) { - \RectorPrefix20220607\Tracy\Dumper::dump($node, [\RectorPrefix20220607\Tracy\Dumper::DEPTH => $depth]); + Dumper::dump($node, [Dumper::DEPTH => $depth]); } } } @@ -39,11 +39,11 @@ if (!\function_exists('print_node')) { */ function print_node($node) : void { - $standard = new \PhpParser\PrettyPrinter\Standard(); + $standard = new Standard(); $nodes = \is_array($node) ? $node : [$node]; foreach ($nodes as $node) { $printedContent = $standard->prettyPrint([$node]); - \RectorPrefix20220607\Tracy\Dumper::dump($printedContent); + Dumper::dump($printedContent); } } } diff --git a/vendor/autoload.php b/vendor/autoload.php index 51652af82b4..3f1ed8bb6cd 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) { require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitff8fc41592b030e55c0e49764944895e::getLoader(); +return ComposerAutoloaderInitea991af8a48b066b6508e12123515df3::getLoader(); diff --git a/vendor/clue/ndjson-react/src/Decoder.php b/vendor/clue/ndjson-react/src/Decoder.php index 1e470100a77..3426aa605fd 100644 --- a/vendor/clue/ndjson-react/src/Decoder.php +++ b/vendor/clue/ndjson-react/src/Decoder.php @@ -9,7 +9,7 @@ use RectorPrefix20220607\React\Stream\WritableStreamInterface; /** * The Decoder / Parser reads from a plain stream and emits data objects for each JSON element */ -class Decoder extends \RectorPrefix20220607\Evenement\EventEmitter implements \RectorPrefix20220607\React\Stream\ReadableStreamInterface +class Decoder extends EventEmitter implements ReadableStreamInterface { private $input; private $assoc; @@ -27,7 +27,7 @@ class Decoder extends \RectorPrefix20220607\Evenement\EventEmitter implements \R * @param int $maxlength * @throws \BadMethodCallException */ - public function __construct(\RectorPrefix20220607\React\Stream\ReadableStreamInterface $input, $assoc = \false, $depth = 512, $options = 0, $maxlength = 65536) + public function __construct(ReadableStreamInterface $input, $assoc = \false, $depth = 512, $options = 0, $maxlength = 65536) { // @codeCoverageIgnoreStart if ($options !== 0 && \PHP_VERSION < 5.4) { @@ -74,9 +74,9 @@ class Decoder extends \RectorPrefix20220607\Evenement\EventEmitter implements \R { $this->input->resume(); } - public function pipe(\RectorPrefix20220607\React\Stream\WritableStreamInterface $dest, array $options = array()) + public function pipe(WritableStreamInterface $dest, array $options = array()) { - \RectorPrefix20220607\React\Stream\Util::pipe($this, $dest, $options); + Util::pipe($this, $dest, $options); return $dest; } /** @internal */ diff --git a/vendor/clue/ndjson-react/src/Encoder.php b/vendor/clue/ndjson-react/src/Encoder.php index eed6febe3b9..f477b1464b9 100644 --- a/vendor/clue/ndjson-react/src/Encoder.php +++ b/vendor/clue/ndjson-react/src/Encoder.php @@ -7,7 +7,7 @@ use RectorPrefix20220607\React\Stream\WritableStreamInterface; /** * The Encoder / Serializer can be used to write any value, encode it as a JSON text and forward it to an output stream */ -class Encoder extends \RectorPrefix20220607\Evenement\EventEmitter implements \RectorPrefix20220607\React\Stream\WritableStreamInterface +class Encoder extends EventEmitter implements WritableStreamInterface { private $output; private $options; @@ -20,7 +20,7 @@ class Encoder extends \RectorPrefix20220607\Evenement\EventEmitter implements \R * @throws \InvalidArgumentException * @throws \BadMethodCallException */ - public function __construct(\RectorPrefix20220607\React\Stream\WritableStreamInterface $output, $options = 0, $depth = 512) + public function __construct(WritableStreamInterface $output, $options = 0, $depth = 512) { // @codeCoverageIgnoreStart if (\defined('JSON_PRETTY_PRINT') && $options & \JSON_PRETTY_PRINT) { diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php index c6b31fe7e89..27ed620c4fc 100644 --- a/vendor/composer/InstalledVersions.php +++ b/vendor/composer/InstalledVersions.php @@ -104,7 +104,7 @@ class InstalledVersions * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package * @return bool */ - public static function satisfies(\RectorPrefix20220607\Composer\Semver\VersionParser $parser, $packageName, $constraint) + public static function satisfies(VersionParser $parser, $packageName, $constraint) { $constraint = $parser->parseConstraints($constraint); $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); @@ -281,7 +281,7 @@ class InstalledVersions } $installed = array(); if (self::$canGetVendors) { - foreach (\RectorPrefix20220607\Composer\Autoload\ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { if (isset(self::$installedByVendor[$vendorDir])) { $installed[] = self::$installedByVendor[$vendorDir]; } elseif (\is_file($vendorDir . '/composer/installed.php')) { diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 233171cdcaa..14665347c85 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -7,7 +7,6 @@ $baseDir = dirname($vendorDir); return array( 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', - 'Normalizer' => $vendorDir . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php', 'PHPStan\\PhpDocParser\\Ast\\ConstExpr\\ConstExprArrayItemNode' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprArrayItemNode.php', 'PHPStan\\PhpDocParser\\Ast\\ConstExpr\\ConstExprArrayNode' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprArrayNode.php', 'PHPStan\\PhpDocParser\\Ast\\ConstExpr\\ConstExprFalseNode' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprFalseNode.php', @@ -461,6 +460,7 @@ return array( 'RectorPrefix20220607\\Nette\\Utils\\Type' => $vendorDir . '/nette/utils/src/Utils/Type.php', 'RectorPrefix20220607\\Nette\\Utils\\UnknownImageFileException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php', 'RectorPrefix20220607\\Nette\\Utils\\Validators' => $vendorDir . '/nette/utils/src/Utils/Validators.php', + 'RectorPrefix20220607\\Normalizer' => $vendorDir . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php', 'RectorPrefix20220607\\OndraM\\CiDetector\\CiDetector' => $vendorDir . '/ondram/ci-detector/src/CiDetector.php', 'RectorPrefix20220607\\OndraM\\CiDetector\\CiDetectorInterface' => $vendorDir . '/ondram/ci-detector/src/CiDetectorInterface.php', 'RectorPrefix20220607\\OndraM\\CiDetector\\Ci\\AbstractCi' => $vendorDir . '/ondram/ci-detector/src/Ci/AbstractCi.php', @@ -1160,11 +1160,23 @@ return array( 'RectorPrefix20220607\\Symplify\\PackageBuilder\\Reflection\\PrivatesAccessor' => $vendorDir . '/symplify/package-builder/src/Reflection/PrivatesAccessor.php', 'RectorPrefix20220607\\Symplify\\PackageBuilder\\Reflection\\PrivatesCaller' => $vendorDir . '/symplify/package-builder/src/Reflection/PrivatesCaller.php', 'RectorPrefix20220607\\Symplify\\PackageBuilder\\Strings\\StringFormatConverter' => $vendorDir . '/symplify/package-builder/src/Strings/StringFormatConverter.php', - 'RectorPrefix20220607\\Symplify\\PackageBuilder\\Testing\\AbstractKernelTestCase' => $vendorDir . '/symplify/package-builder/src/Testing/AbstractKernelTestCase.php', 'RectorPrefix20220607\\Symplify\\PackageBuilder\\ValueObject\\ConsoleColorDiffConfig' => $vendorDir . '/symplify/package-builder/src/ValueObject/ConsoleColorDiffConfig.php', 'RectorPrefix20220607\\Symplify\\PackageBuilder\\ValueObject\\MethodName' => $vendorDir . '/symplify/package-builder/src/ValueObject/MethodName.php', 'RectorPrefix20220607\\Symplify\\PackageBuilder\\ValueObject\\Option' => $vendorDir . '/symplify/package-builder/src/ValueObject/Option.php', 'RectorPrefix20220607\\Symplify\\PackageBuilder\\Yaml\\ParametersMerger' => $vendorDir . '/symplify/package-builder/src/Yaml/ParametersMerger.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\Contract\\Category\\CategoryInfererInterface' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/Contract/Category/CategoryInfererInterface.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\Contract\\CodeSampleInterface' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/Contract/CodeSampleInterface.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\Contract\\ConfigurableRuleInterface' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/Contract/ConfigurableRuleInterface.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\Contract\\DocumentedRuleInterface' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/Contract/DocumentedRuleInterface.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\Contract\\RuleCodeSamplePrinterInterface' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/Contract/RuleCodeSamplePrinterInterface.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\Exception\\PoorDocumentationException' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/Exception/PoorDocumentationException.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\Exception\\ShouldNotHappenException' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/Exception/ShouldNotHappenException.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\ValueObject\\AbstractCodeSample' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/ValueObject/AbstractCodeSample.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\ValueObject\\CodeSample\\CodeSample' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/CodeSample.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\ValueObject\\CodeSample\\ComposerJsonAwareCodeSample' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/ComposerJsonAwareCodeSample.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\ValueObject\\CodeSample\\ConfiguredCodeSample' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/ConfiguredCodeSample.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\ValueObject\\CodeSample\\ExtraFileCodeSample' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/ExtraFileCodeSample.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\ValueObject\\RuleDefinition' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/ValueObject/RuleDefinition.php', 'RectorPrefix20220607\\Symplify\\Skipper\\Contract\\SkipVoterInterface' => $vendorDir . '/symplify/skipper/src/Contract/SkipVoterInterface.php', 'RectorPrefix20220607\\Symplify\\Skipper\\FileSystem\\FnMatchPathNormalizer' => $vendorDir . '/symplify/skipper/src/FileSystem/FnMatchPathNormalizer.php', 'RectorPrefix20220607\\Symplify\\Skipper\\Matcher\\FileInfoMatcher' => $vendorDir . '/symplify/skipper/src/Matcher/FileInfoMatcher.php', @@ -3071,17 +3083,4 @@ return array( 'Rector\\Visibility\\Rector\\ClassMethod\\ExplicitPublicClassMethodRector' => $baseDir . '/rules/Visibility/Rector/ClassMethod/ExplicitPublicClassMethodRector.php', 'Rector\\Visibility\\ValueObject\\ChangeConstantVisibility' => $baseDir . '/rules/Visibility/ValueObject/ChangeConstantVisibility.php', 'Rector\\Visibility\\ValueObject\\ChangeMethodVisibility' => $baseDir . '/rules/Visibility/ValueObject/ChangeMethodVisibility.php', - 'Symplify\\RuleDocGenerator\\Contract\\Category\\CategoryInfererInterface' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/Contract/Category/CategoryInfererInterface.php', - 'Symplify\\RuleDocGenerator\\Contract\\CodeSampleInterface' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/Contract/CodeSampleInterface.php', - 'Symplify\\RuleDocGenerator\\Contract\\ConfigurableRuleInterface' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/Contract/ConfigurableRuleInterface.php', - 'Symplify\\RuleDocGenerator\\Contract\\DocumentedRuleInterface' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/Contract/DocumentedRuleInterface.php', - 'Symplify\\RuleDocGenerator\\Contract\\RuleCodeSamplePrinterInterface' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/Contract/RuleCodeSamplePrinterInterface.php', - 'Symplify\\RuleDocGenerator\\Exception\\PoorDocumentationException' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/Exception/PoorDocumentationException.php', - 'Symplify\\RuleDocGenerator\\Exception\\ShouldNotHappenException' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/Exception/ShouldNotHappenException.php', - 'Symplify\\RuleDocGenerator\\ValueObject\\AbstractCodeSample' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/ValueObject/AbstractCodeSample.php', - 'Symplify\\RuleDocGenerator\\ValueObject\\CodeSample\\CodeSample' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/CodeSample.php', - 'Symplify\\RuleDocGenerator\\ValueObject\\CodeSample\\ComposerJsonAwareCodeSample' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/ComposerJsonAwareCodeSample.php', - 'Symplify\\RuleDocGenerator\\ValueObject\\CodeSample\\ConfiguredCodeSample' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/ConfiguredCodeSample.php', - 'Symplify\\RuleDocGenerator\\ValueObject\\CodeSample\\ExtraFileCodeSample' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/ExtraFileCodeSample.php', - 'Symplify\\RuleDocGenerator\\ValueObject\\RuleDefinition' => $vendorDir . '/symplify/rule-doc-generator-contracts/src/ValueObject/RuleDefinition.php', ); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index 4beb792ba78..8105c7e3a04 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -6,7 +6,6 @@ $vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( - 'Symplify\\RuleDocGenerator\\' => array($vendorDir . '/symplify/rule-doc-generator-contracts/src'), 'Rector\\Symfony\\' => array($vendorDir . '/rector/rector-symfony/src'), 'Rector\\RectorInstaller\\' => array($vendorDir . '/rector/extension-installer/src'), 'Rector\\RectorGenerator\\' => array($vendorDir . '/rector/rector-generator/src'), @@ -23,6 +22,7 @@ return array( 'RectorPrefix20220607\\Symplify\\SymplifyKernel\\' => array($vendorDir . '/symplify/symplify-kernel/src'), 'RectorPrefix20220607\\Symplify\\SmartFileSystem\\' => array($vendorDir . '/symplify/smart-file-system/src'), 'RectorPrefix20220607\\Symplify\\Skipper\\' => array($vendorDir . '/symplify/skipper/src'), + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\' => array($vendorDir . '/symplify/rule-doc-generator-contracts/src'), 'RectorPrefix20220607\\Symplify\\PackageBuilder\\' => array($vendorDir . '/symplify/package-builder/src'), 'RectorPrefix20220607\\Symplify\\EasyTesting\\' => array($vendorDir . '/symplify/easy-testing/src'), 'RectorPrefix20220607\\Symplify\\EasyParallel\\' => array($vendorDir . '/symplify/easy-parallel/src'), diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 7666fd033b8..7f4dcedcc09 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitff8fc41592b030e55c0e49764944895e +class ComposerAutoloaderInitea991af8a48b066b6508e12123515df3 { private static $loader; @@ -22,19 +22,19 @@ class ComposerAutoloaderInitff8fc41592b030e55c0e49764944895e return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitff8fc41592b030e55c0e49764944895e', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitea991af8a48b066b6508e12123515df3', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInitff8fc41592b030e55c0e49764944895e', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitea991af8a48b066b6508e12123515df3', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitff8fc41592b030e55c0e49764944895e::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInitea991af8a48b066b6508e12123515df3::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $includeFiles = \Composer\Autoload\ComposerStaticInitff8fc41592b030e55c0e49764944895e::$files; + $includeFiles = \Composer\Autoload\ComposerStaticInitea991af8a48b066b6508e12123515df3::$files; foreach ($includeFiles as $fileIdentifier => $file) { - composerRequireff8fc41592b030e55c0e49764944895e($fileIdentifier, $file); + composerRequireea991af8a48b066b6508e12123515df3($fileIdentifier, $file); } return $loader; @@ -46,7 +46,7 @@ class ComposerAutoloaderInitff8fc41592b030e55c0e49764944895e * @param string $file * @return void */ -function composerRequireff8fc41592b030e55c0e49764944895e($fileIdentifier, $file) +function composerRequireea991af8a48b066b6508e12123515df3($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 65af01ee6de..376a42d9cb0 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitff8fc41592b030e55c0e49764944895e +class ComposerStaticInitea991af8a48b066b6508e12123515df3 { public static $files = array ( '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', @@ -20,10 +20,6 @@ class ComposerStaticInitff8fc41592b030e55c0e49764944895e ); public static $prefixLengthsPsr4 = array ( - 'S' => - array ( - 'Symplify\\RuleDocGenerator\\' => 26, - ), 'R' => array ( 'Rector\\Symfony\\' => 15, @@ -42,6 +38,7 @@ class ComposerStaticInitff8fc41592b030e55c0e49764944895e 'RectorPrefix20220607\\Symplify\\SymplifyKernel\\' => 45, 'RectorPrefix20220607\\Symplify\\SmartFileSystem\\' => 46, 'RectorPrefix20220607\\Symplify\\Skipper\\' => 38, + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\' => 47, 'RectorPrefix20220607\\Symplify\\PackageBuilder\\' => 45, 'RectorPrefix20220607\\Symplify\\EasyTesting\\' => 42, 'RectorPrefix20220607\\Symplify\\EasyParallel\\' => 43, @@ -86,10 +83,6 @@ class ComposerStaticInitff8fc41592b030e55c0e49764944895e ); public static $prefixDirsPsr4 = array ( - 'Symplify\\RuleDocGenerator\\' => - array ( - 0 => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src', - ), 'Rector\\Symfony\\' => array ( 0 => __DIR__ . '/..' . '/rector/rector-symfony/src', @@ -156,6 +149,10 @@ class ComposerStaticInitff8fc41592b030e55c0e49764944895e array ( 0 => __DIR__ . '/..' . '/symplify/skipper/src', ), + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\' => + array ( + 0 => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src', + ), 'RectorPrefix20220607\\Symplify\\PackageBuilder\\' => array ( 0 => __DIR__ . '/..' . '/symplify/package-builder/src', @@ -308,7 +305,6 @@ class ComposerStaticInitff8fc41592b030e55c0e49764944895e public static $classMap = array ( 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', - 'Normalizer' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php', 'PHPStan\\PhpDocParser\\Ast\\ConstExpr\\ConstExprArrayItemNode' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprArrayItemNode.php', 'PHPStan\\PhpDocParser\\Ast\\ConstExpr\\ConstExprArrayNode' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprArrayNode.php', 'PHPStan\\PhpDocParser\\Ast\\ConstExpr\\ConstExprFalseNode' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprFalseNode.php', @@ -762,6 +758,7 @@ class ComposerStaticInitff8fc41592b030e55c0e49764944895e 'RectorPrefix20220607\\Nette\\Utils\\Type' => __DIR__ . '/..' . '/nette/utils/src/Utils/Type.php', 'RectorPrefix20220607\\Nette\\Utils\\UnknownImageFileException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php', 'RectorPrefix20220607\\Nette\\Utils\\Validators' => __DIR__ . '/..' . '/nette/utils/src/Utils/Validators.php', + 'RectorPrefix20220607\\Normalizer' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php', 'RectorPrefix20220607\\OndraM\\CiDetector\\CiDetector' => __DIR__ . '/..' . '/ondram/ci-detector/src/CiDetector.php', 'RectorPrefix20220607\\OndraM\\CiDetector\\CiDetectorInterface' => __DIR__ . '/..' . '/ondram/ci-detector/src/CiDetectorInterface.php', 'RectorPrefix20220607\\OndraM\\CiDetector\\Ci\\AbstractCi' => __DIR__ . '/..' . '/ondram/ci-detector/src/Ci/AbstractCi.php', @@ -1461,11 +1458,23 @@ class ComposerStaticInitff8fc41592b030e55c0e49764944895e 'RectorPrefix20220607\\Symplify\\PackageBuilder\\Reflection\\PrivatesAccessor' => __DIR__ . '/..' . '/symplify/package-builder/src/Reflection/PrivatesAccessor.php', 'RectorPrefix20220607\\Symplify\\PackageBuilder\\Reflection\\PrivatesCaller' => __DIR__ . '/..' . '/symplify/package-builder/src/Reflection/PrivatesCaller.php', 'RectorPrefix20220607\\Symplify\\PackageBuilder\\Strings\\StringFormatConverter' => __DIR__ . '/..' . '/symplify/package-builder/src/Strings/StringFormatConverter.php', - 'RectorPrefix20220607\\Symplify\\PackageBuilder\\Testing\\AbstractKernelTestCase' => __DIR__ . '/..' . '/symplify/package-builder/src/Testing/AbstractKernelTestCase.php', 'RectorPrefix20220607\\Symplify\\PackageBuilder\\ValueObject\\ConsoleColorDiffConfig' => __DIR__ . '/..' . '/symplify/package-builder/src/ValueObject/ConsoleColorDiffConfig.php', 'RectorPrefix20220607\\Symplify\\PackageBuilder\\ValueObject\\MethodName' => __DIR__ . '/..' . '/symplify/package-builder/src/ValueObject/MethodName.php', 'RectorPrefix20220607\\Symplify\\PackageBuilder\\ValueObject\\Option' => __DIR__ . '/..' . '/symplify/package-builder/src/ValueObject/Option.php', 'RectorPrefix20220607\\Symplify\\PackageBuilder\\Yaml\\ParametersMerger' => __DIR__ . '/..' . '/symplify/package-builder/src/Yaml/ParametersMerger.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\Contract\\Category\\CategoryInfererInterface' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/Contract/Category/CategoryInfererInterface.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\Contract\\CodeSampleInterface' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/Contract/CodeSampleInterface.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\Contract\\ConfigurableRuleInterface' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/Contract/ConfigurableRuleInterface.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\Contract\\DocumentedRuleInterface' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/Contract/DocumentedRuleInterface.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\Contract\\RuleCodeSamplePrinterInterface' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/Contract/RuleCodeSamplePrinterInterface.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\Exception\\PoorDocumentationException' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/Exception/PoorDocumentationException.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\Exception\\ShouldNotHappenException' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/Exception/ShouldNotHappenException.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\ValueObject\\AbstractCodeSample' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/ValueObject/AbstractCodeSample.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\ValueObject\\CodeSample\\CodeSample' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/CodeSample.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\ValueObject\\CodeSample\\ComposerJsonAwareCodeSample' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/ComposerJsonAwareCodeSample.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\ValueObject\\CodeSample\\ConfiguredCodeSample' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/ConfiguredCodeSample.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\ValueObject\\CodeSample\\ExtraFileCodeSample' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/ExtraFileCodeSample.php', + 'RectorPrefix20220607\\Symplify\\RuleDocGenerator\\ValueObject\\RuleDefinition' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/ValueObject/RuleDefinition.php', 'RectorPrefix20220607\\Symplify\\Skipper\\Contract\\SkipVoterInterface' => __DIR__ . '/..' . '/symplify/skipper/src/Contract/SkipVoterInterface.php', 'RectorPrefix20220607\\Symplify\\Skipper\\FileSystem\\FnMatchPathNormalizer' => __DIR__ . '/..' . '/symplify/skipper/src/FileSystem/FnMatchPathNormalizer.php', 'RectorPrefix20220607\\Symplify\\Skipper\\Matcher\\FileInfoMatcher' => __DIR__ . '/..' . '/symplify/skipper/src/Matcher/FileInfoMatcher.php', @@ -3372,27 +3381,14 @@ class ComposerStaticInitff8fc41592b030e55c0e49764944895e 'Rector\\Visibility\\Rector\\ClassMethod\\ExplicitPublicClassMethodRector' => __DIR__ . '/../..' . '/rules/Visibility/Rector/ClassMethod/ExplicitPublicClassMethodRector.php', 'Rector\\Visibility\\ValueObject\\ChangeConstantVisibility' => __DIR__ . '/../..' . '/rules/Visibility/ValueObject/ChangeConstantVisibility.php', 'Rector\\Visibility\\ValueObject\\ChangeMethodVisibility' => __DIR__ . '/../..' . '/rules/Visibility/ValueObject/ChangeMethodVisibility.php', - 'Symplify\\RuleDocGenerator\\Contract\\Category\\CategoryInfererInterface' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/Contract/Category/CategoryInfererInterface.php', - 'Symplify\\RuleDocGenerator\\Contract\\CodeSampleInterface' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/Contract/CodeSampleInterface.php', - 'Symplify\\RuleDocGenerator\\Contract\\ConfigurableRuleInterface' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/Contract/ConfigurableRuleInterface.php', - 'Symplify\\RuleDocGenerator\\Contract\\DocumentedRuleInterface' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/Contract/DocumentedRuleInterface.php', - 'Symplify\\RuleDocGenerator\\Contract\\RuleCodeSamplePrinterInterface' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/Contract/RuleCodeSamplePrinterInterface.php', - 'Symplify\\RuleDocGenerator\\Exception\\PoorDocumentationException' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/Exception/PoorDocumentationException.php', - 'Symplify\\RuleDocGenerator\\Exception\\ShouldNotHappenException' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/Exception/ShouldNotHappenException.php', - 'Symplify\\RuleDocGenerator\\ValueObject\\AbstractCodeSample' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/ValueObject/AbstractCodeSample.php', - 'Symplify\\RuleDocGenerator\\ValueObject\\CodeSample\\CodeSample' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/CodeSample.php', - 'Symplify\\RuleDocGenerator\\ValueObject\\CodeSample\\ComposerJsonAwareCodeSample' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/ComposerJsonAwareCodeSample.php', - 'Symplify\\RuleDocGenerator\\ValueObject\\CodeSample\\ConfiguredCodeSample' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/ConfiguredCodeSample.php', - 'Symplify\\RuleDocGenerator\\ValueObject\\CodeSample\\ExtraFileCodeSample' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/ExtraFileCodeSample.php', - 'Symplify\\RuleDocGenerator\\ValueObject\\RuleDefinition' => __DIR__ . '/..' . '/symplify/rule-doc-generator-contracts/src/ValueObject/RuleDefinition.php', ); public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitff8fc41592b030e55c0e49764944895e::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitff8fc41592b030e55c0e49764944895e::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitff8fc41592b030e55c0e49764944895e::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitea991af8a48b066b6508e12123515df3::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitea991af8a48b066b6508e12123515df3::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitea991af8a48b066b6508e12123515df3::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 7b77bc34369..7d88cd7638f 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -3255,17 +3255,17 @@ }, { "name": "symplify\/astral", - "version": "10.2.10", - "version_normalized": "10.2.10.0", + "version": "10.2.11", + "version_normalized": "10.2.11.0", "source": { "type": "git", "url": "https:\/\/github.com\/symplify\/astral.git", - "reference": "9eac7f0006a1bc7410f77c50f28373b580615a66" + "reference": "5843f2042cb942b9552b8995767d9a734b0258af" }, "dist": { "type": "zip", - "url": "https:\/\/api.github.com\/repos\/symplify\/astral\/zipball\/9eac7f0006a1bc7410f77c50f28373b580615a66", - "reference": "9eac7f0006a1bc7410f77c50f28373b580615a66", + "url": "https:\/\/api.github.com\/repos\/symplify\/astral\/zipball\/5843f2042cb942b9552b8995767d9a734b0258af", + "reference": "5843f2042cb942b9552b8995767d9a734b0258af", "shasum": "" }, "require": { @@ -3276,37 +3276,37 @@ "phpstan\/phpstan": "^1.7.6", "symfony\/config": "^6.0", "symfony\/dependency-injection": "^6.0", - "symplify\/package-builder": "^10.2.10", - "symplify\/smart-file-system": "^10.2.10", - "symplify\/symplify-kernel": "^10.2.10" + "symplify\/package-builder": "^10.2.11", + "symplify\/smart-file-system": "^10.2.11", + "symplify\/symplify-kernel": "^10.2.11" }, "conflict": { - "symplify\/autowire-array-parameter": "<10.2.10", - "symplify\/coding-standard": "<10.2.10", - "symplify\/composer-json-manipulator": "<10.2.10", - "symplify\/config-transformer": "<10.2.10", - "symplify\/easy-ci": "<10.2.10", - "symplify\/easy-coding-standard": "<10.2.10", - "symplify\/easy-parallel": "<10.2.10", - "symplify\/easy-testing": "<10.2.10", - "symplify\/monorepo-builder": "<10.2.10", - "symplify\/neon-config-dumper": "<10.2.10", - "symplify\/php-config-printer": "<10.2.10", - "symplify\/phpstan-extensions": "<10.2.10", - "symplify\/phpstan-rules": "<10.2.10", - "symplify\/rule-doc-generator": "<10.2.10", - "symplify\/rule-doc-generator-contracts": "<10.2.10", - "symplify\/skipper": "<10.2.10", + "symplify\/autowire-array-parameter": "<10.2.11", + "symplify\/coding-standard": "<10.2.11", + "symplify\/composer-json-manipulator": "<10.2.11", + "symplify\/config-transformer": "<10.2.11", + "symplify\/easy-ci": "<10.2.11", + "symplify\/easy-coding-standard": "<10.2.11", + "symplify\/easy-parallel": "<10.2.11", + "symplify\/easy-testing": "<10.2.11", + "symplify\/monorepo-builder": "<10.2.11", + "symplify\/neon-config-dumper": "<10.2.11", + "symplify\/php-config-printer": "<10.2.11", + "symplify\/phpstan-extensions": "<10.2.11", + "symplify\/phpstan-rules": "<10.2.11", + "symplify\/rule-doc-generator": "<10.2.11", + "symplify\/rule-doc-generator-contracts": "<10.2.11", + "symplify\/skipper": "<10.2.11", "symplify\/smart-file-system": "<9.4.70", - "symplify\/symfony-static-dumper": "<10.2.10", + "symplify\/symfony-static-dumper": "<10.2.11", "symplify\/symplify-kernel": "<9.4.70", - "symplify\/vendor-patches": "<10.2.10" + "symplify\/vendor-patches": "<10.2.11" }, "require-dev": { "phpunit\/phpunit": "^9.5", - "symplify\/easy-testing": "^10.2.10" + "symplify\/easy-testing": "^10.2.11" }, - "time": "2022-06-06T23:07:40+00:00", + "time": "2022-06-07T07:45:10+00:00", "type": "phpstan-extension", "extra": { "branch-alias": { @@ -3331,7 +3331,7 @@ ], "description": "Toolking for smart daily work with AST", "support": { - "source": "https:\/\/github.com\/symplify\/astral\/tree\/10.2.10" + "source": "https:\/\/github.com\/symplify\/astral\/tree\/10.2.11" }, "funding": [ { @@ -3347,51 +3347,51 @@ }, { "name": "symplify\/autowire-array-parameter", - "version": "10.2.10", - "version_normalized": "10.2.10.0", + "version": "10.2.11", + "version_normalized": "10.2.11.0", "source": { "type": "git", "url": "https:\/\/github.com\/symplify\/autowire-array-parameter.git", - "reference": "671c677e48701b89dd8f7f6c59e6f5349552bc04" + "reference": "42e3b884517f108e221f89815e51e2d5fc915e4d" }, "dist": { "type": "zip", - "url": "https:\/\/api.github.com\/repos\/symplify\/autowire-array-parameter\/zipball\/671c677e48701b89dd8f7f6c59e6f5349552bc04", - "reference": "671c677e48701b89dd8f7f6c59e6f5349552bc04", + "url": "https:\/\/api.github.com\/repos\/symplify\/autowire-array-parameter\/zipball\/42e3b884517f108e221f89815e51e2d5fc915e4d", + "reference": "42e3b884517f108e221f89815e51e2d5fc915e4d", "shasum": "" }, "require": { "nette\/utils": "^3.2", "php": ">=8.0", "symfony\/dependency-injection": "^6.0", - "symplify\/package-builder": "^10.2.10" + "symplify\/package-builder": "^10.2.11" }, "conflict": { - "symplify\/astral": "<10.2.10", - "symplify\/coding-standard": "<10.2.10", - "symplify\/composer-json-manipulator": "<10.2.10", - "symplify\/config-transformer": "<10.2.10", - "symplify\/easy-ci": "<10.2.10", - "symplify\/easy-coding-standard": "<10.2.10", - "symplify\/easy-parallel": "<10.2.10", - "symplify\/easy-testing": "<10.2.10", - "symplify\/monorepo-builder": "<10.2.10", - "symplify\/neon-config-dumper": "<10.2.10", - "symplify\/php-config-printer": "<10.2.10", - "symplify\/phpstan-extensions": "<10.2.10", - "symplify\/phpstan-rules": "<10.2.10", - "symplify\/rule-doc-generator": "<10.2.10", - "symplify\/rule-doc-generator-contracts": "<10.2.10", - "symplify\/skipper": "<10.2.10", - "symplify\/smart-file-system": "<10.2.10", - "symplify\/symfony-static-dumper": "<10.2.10", - "symplify\/symplify-kernel": "<10.2.10", - "symplify\/vendor-patches": "<10.2.10" + "symplify\/astral": "<10.2.11", + "symplify\/coding-standard": "<10.2.11", + "symplify\/composer-json-manipulator": "<10.2.11", + "symplify\/config-transformer": "<10.2.11", + "symplify\/easy-ci": "<10.2.11", + "symplify\/easy-coding-standard": "<10.2.11", + "symplify\/easy-parallel": "<10.2.11", + "symplify\/easy-testing": "<10.2.11", + "symplify\/monorepo-builder": "<10.2.11", + "symplify\/neon-config-dumper": "<10.2.11", + "symplify\/php-config-printer": "<10.2.11", + "symplify\/phpstan-extensions": "<10.2.11", + "symplify\/phpstan-rules": "<10.2.11", + "symplify\/rule-doc-generator": "<10.2.11", + "symplify\/rule-doc-generator-contracts": "<10.2.11", + "symplify\/skipper": "<10.2.11", + "symplify\/smart-file-system": "<10.2.11", + "symplify\/symfony-static-dumper": "<10.2.11", + "symplify\/symplify-kernel": "<10.2.11", + "symplify\/vendor-patches": "<10.2.11" }, "require-dev": { "phpunit\/phpunit": "^9.5" }, - "time": "2022-06-06T23:07:43+00:00", + "time": "2022-06-07T07:45:17+00:00", "type": "library", "extra": { "branch-alias": { @@ -3410,7 +3410,7 @@ ], "description": "Autowire array parameters for your Symfony applications", "support": { - "source": "https:\/\/github.com\/symplify\/autowire-array-parameter\/tree\/10.2.10" + "source": "https:\/\/github.com\/symplify\/autowire-array-parameter\/tree\/10.2.11" }, "funding": [ { @@ -3426,17 +3426,17 @@ }, { "name": "symplify\/composer-json-manipulator", - "version": "10.2.10", - "version_normalized": "10.2.10.0", + "version": "10.2.11", + "version_normalized": "10.2.11.0", "source": { "type": "git", "url": "https:\/\/github.com\/symplify\/composer-json-manipulator.git", - "reference": "867a328dd5526cf0f502119fb31a2b7308d60e7d" + "reference": "c606fa81fd41c0a43f0067d4bf5cb210cd02ffac" }, "dist": { "type": "zip", - "url": "https:\/\/api.github.com\/repos\/symplify\/composer-json-manipulator\/zipball\/867a328dd5526cf0f502119fb31a2b7308d60e7d", - "reference": "867a328dd5526cf0f502119fb31a2b7308d60e7d", + "url": "https:\/\/api.github.com\/repos\/symplify\/composer-json-manipulator\/zipball\/c606fa81fd41c0a43f0067d4bf5cb210cd02ffac", + "reference": "c606fa81fd41c0a43f0067d4bf5cb210cd02ffac", "shasum": "" }, "require": { @@ -3445,35 +3445,35 @@ "symfony\/config": "^6.0", "symfony\/dependency-injection": "^6.0", "symfony\/filesystem": "^6.0", - "symplify\/package-builder": "^10.2.10", - "symplify\/smart-file-system": "^10.2.10", - "symplify\/symplify-kernel": "^10.2.10" + "symplify\/package-builder": "^10.2.11", + "symplify\/smart-file-system": "^10.2.11", + "symplify\/symplify-kernel": "^10.2.11" }, "conflict": { - "symplify\/astral": "<10.2.10", - "symplify\/autowire-array-parameter": "<10.2.10", - "symplify\/coding-standard": "<10.2.10", - "symplify\/config-transformer": "<10.2.10", - "symplify\/easy-ci": "<10.2.10", - "symplify\/easy-coding-standard": "<10.2.10", - "symplify\/easy-parallel": "<10.2.10", - "symplify\/easy-testing": "<10.2.10", - "symplify\/monorepo-builder": "<10.2.10", - "symplify\/neon-config-dumper": "<10.2.10", - "symplify\/php-config-printer": "<10.2.10", - "symplify\/phpstan-extensions": "<10.2.10", - "symplify\/phpstan-rules": "<10.2.10", - "symplify\/rule-doc-generator": "<10.2.10", - "symplify\/rule-doc-generator-contracts": "<10.2.10", - "symplify\/skipper": "<10.2.10", - "symplify\/symfony-static-dumper": "<10.2.10", + "symplify\/astral": "<10.2.11", + "symplify\/autowire-array-parameter": "<10.2.11", + "symplify\/coding-standard": "<10.2.11", + "symplify\/config-transformer": "<10.2.11", + "symplify\/easy-ci": "<10.2.11", + "symplify\/easy-coding-standard": "<10.2.11", + "symplify\/easy-parallel": "<10.2.11", + "symplify\/easy-testing": "<10.2.11", + "symplify\/monorepo-builder": "<10.2.11", + "symplify\/neon-config-dumper": "<10.2.11", + "symplify\/php-config-printer": "<10.2.11", + "symplify\/phpstan-extensions": "<10.2.11", + "symplify\/phpstan-rules": "<10.2.11", + "symplify\/rule-doc-generator": "<10.2.11", + "symplify\/rule-doc-generator-contracts": "<10.2.11", + "symplify\/skipper": "<10.2.11", + "symplify\/symfony-static-dumper": "<10.2.11", "symplify\/symplify-kernel": "<9.4.70", - "symplify\/vendor-patches": "<10.2.10" + "symplify\/vendor-patches": "<10.2.11" }, "require-dev": { "phpunit\/phpunit": "^9.5" }, - "time": "2022-06-06T23:08:02+00:00", + "time": "2022-06-07T07:45:31+00:00", "type": "symfony-bundle", "extra": { "branch-alias": { @@ -3492,7 +3492,7 @@ ], "description": "Package to load, merge and save composer.json file(s)", "support": { - "source": "https:\/\/github.com\/symplify\/composer-json-manipulator\/tree\/10.2.10" + "source": "https:\/\/github.com\/symplify\/composer-json-manipulator\/tree\/10.2.11" }, "funding": [ { @@ -3508,17 +3508,17 @@ }, { "name": "symplify\/easy-parallel", - "version": "10.2.10", - "version_normalized": "10.2.10.0", + "version": "10.2.11", + "version_normalized": "10.2.11.0", "source": { "type": "git", "url": "https:\/\/github.com\/symplify\/easy-parallel.git", - "reference": "3715dbb7871355469c2871b478ad634235594166" + "reference": "e7b801118667e8739248ae4b4649b57e7490d5b7" }, "dist": { "type": "zip", - "url": "https:\/\/api.github.com\/repos\/symplify\/easy-parallel\/zipball\/3715dbb7871355469c2871b478ad634235594166", - "reference": "3715dbb7871355469c2871b478ad634235594166", + "url": "https:\/\/api.github.com\/repos\/symplify\/easy-parallel\/zipball\/e7b801118667e8739248ae4b4649b57e7490d5b7", + "reference": "e7b801118667e8739248ae4b4649b57e7490d5b7", "shasum": "" }, "require": { @@ -3528,34 +3528,34 @@ "react\/event-loop": "^1.3", "react\/socket": "^1.11", "symfony\/console": "^6.0", - "symplify\/package-builder": "^10.2.10" + "symplify\/package-builder": "^10.2.11" }, "conflict": { - "symplify\/astral": "<10.2.10", - "symplify\/autowire-array-parameter": "<10.2.10", - "symplify\/coding-standard": "<10.2.10", - "symplify\/composer-json-manipulator": "<10.2.10", - "symplify\/config-transformer": "<10.2.10", - "symplify\/easy-ci": "<10.2.10", - "symplify\/easy-coding-standard": "<10.2.10", - "symplify\/easy-testing": "<10.2.10", - "symplify\/monorepo-builder": "<10.2.10", - "symplify\/neon-config-dumper": "<10.2.10", - "symplify\/php-config-printer": "<10.2.10", - "symplify\/phpstan-extensions": "<10.2.10", - "symplify\/phpstan-rules": "<10.2.10", - "symplify\/rule-doc-generator": "<10.2.10", - "symplify\/rule-doc-generator-contracts": "<10.2.10", - "symplify\/skipper": "<10.2.10", - "symplify\/smart-file-system": "<10.2.10", - "symplify\/symfony-static-dumper": "<10.2.10", - "symplify\/symplify-kernel": "<10.2.10", - "symplify\/vendor-patches": "<10.2.10" + "symplify\/astral": "<10.2.11", + "symplify\/autowire-array-parameter": "<10.2.11", + "symplify\/coding-standard": "<10.2.11", + "symplify\/composer-json-manipulator": "<10.2.11", + "symplify\/config-transformer": "<10.2.11", + "symplify\/easy-ci": "<10.2.11", + "symplify\/easy-coding-standard": "<10.2.11", + "symplify\/easy-testing": "<10.2.11", + "symplify\/monorepo-builder": "<10.2.11", + "symplify\/neon-config-dumper": "<10.2.11", + "symplify\/php-config-printer": "<10.2.11", + "symplify\/phpstan-extensions": "<10.2.11", + "symplify\/phpstan-rules": "<10.2.11", + "symplify\/rule-doc-generator": "<10.2.11", + "symplify\/rule-doc-generator-contracts": "<10.2.11", + "symplify\/skipper": "<10.2.11", + "symplify\/smart-file-system": "<10.2.11", + "symplify\/symfony-static-dumper": "<10.2.11", + "symplify\/symplify-kernel": "<10.2.11", + "symplify\/vendor-patches": "<10.2.11" }, "require-dev": { "phpunit\/phpunit": "^9.5" }, - "time": "2022-06-06T23:07:51+00:00", + "time": "2022-06-07T07:45:41+00:00", "type": "library", "extra": { "branch-alias": { @@ -3575,23 +3575,23 @@ "description": "Helper package for easier CLI project parallelization", "support": { "issues": "https:\/\/github.com\/symplify\/easy-parallel\/issues", - "source": "https:\/\/github.com\/symplify\/easy-parallel\/tree\/10.2.10" + "source": "https:\/\/github.com\/symplify\/easy-parallel\/tree\/10.2.11" }, "install-path": "..\/symplify\/easy-parallel" }, { "name": "symplify\/easy-testing", - "version": "10.2.10", - "version_normalized": "10.2.10.0", + "version": "10.2.11", + "version_normalized": "10.2.11.0", "source": { "type": "git", "url": "https:\/\/github.com\/symplify\/easy-testing.git", - "reference": "26d00205b56abaef67ad327fe774f0db08172d05" + "reference": "0bbbd73c55dbd745783ad256a25ad679f74aecaa" }, "dist": { "type": "zip", - "url": "https:\/\/api.github.com\/repos\/symplify\/easy-testing\/zipball\/26d00205b56abaef67ad327fe774f0db08172d05", - "reference": "26d00205b56abaef67ad327fe774f0db08172d05", + "url": "https:\/\/api.github.com\/repos\/symplify\/easy-testing\/zipball\/0bbbd73c55dbd745783ad256a25ad679f74aecaa", + "reference": "0bbbd73c55dbd745783ad256a25ad679f74aecaa", "shasum": "" }, "require": { @@ -3600,34 +3600,34 @@ "symfony\/console": "^6.0", "symfony\/dependency-injection": "^6.0", "symfony\/finder": "^6.0", - "symplify\/package-builder": "^10.2.10", - "symplify\/smart-file-system": "^10.2.10", - "symplify\/symplify-kernel": "^10.2.10" + "symplify\/package-builder": "^10.2.11", + "symplify\/smart-file-system": "^10.2.11", + "symplify\/symplify-kernel": "^10.2.11" }, "conflict": { - "symplify\/astral": "<10.2.10", - "symplify\/autowire-array-parameter": "<10.2.10", - "symplify\/coding-standard": "<10.2.10", - "symplify\/composer-json-manipulator": "<10.2.10", - "symplify\/config-transformer": "<10.2.10", - "symplify\/easy-ci": "<10.2.10", - "symplify\/easy-coding-standard": "<10.2.10", - "symplify\/easy-parallel": "<10.2.10", - "symplify\/monorepo-builder": "<10.2.10", - "symplify\/neon-config-dumper": "<10.2.10", - "symplify\/php-config-printer": "<10.2.10", - "symplify\/phpstan-extensions": "<10.2.10", - "symplify\/phpstan-rules": "<10.2.10", - "symplify\/rule-doc-generator": "<10.2.10", - "symplify\/rule-doc-generator-contracts": "<10.2.10", - "symplify\/skipper": "<10.2.10", - "symplify\/symfony-static-dumper": "<10.2.10", - "symplify\/vendor-patches": "<10.2.10" + "symplify\/astral": "<10.2.11", + "symplify\/autowire-array-parameter": "<10.2.11", + "symplify\/coding-standard": "<10.2.11", + "symplify\/composer-json-manipulator": "<10.2.11", + "symplify\/config-transformer": "<10.2.11", + "symplify\/easy-ci": "<10.2.11", + "symplify\/easy-coding-standard": "<10.2.11", + "symplify\/easy-parallel": "<10.2.11", + "symplify\/monorepo-builder": "<10.2.11", + "symplify\/neon-config-dumper": "<10.2.11", + "symplify\/php-config-printer": "<10.2.11", + "symplify\/phpstan-extensions": "<10.2.11", + "symplify\/phpstan-rules": "<10.2.11", + "symplify\/rule-doc-generator": "<10.2.11", + "symplify\/rule-doc-generator-contracts": "<10.2.11", + "symplify\/skipper": "<10.2.11", + "symplify\/symfony-static-dumper": "<10.2.11", + "symplify\/vendor-patches": "<10.2.11" }, "require-dev": { "phpunit\/phpunit": "^9.5" }, - "time": "2022-06-06T23:07:42+00:00", + "time": "2022-06-07T07:45:49+00:00", "bin": [ "bin\/easy-testing" ], @@ -3649,7 +3649,7 @@ ], "description": "Testing made easy", "support": { - "source": "https:\/\/github.com\/symplify\/easy-testing\/tree\/10.2.10" + "source": "https:\/\/github.com\/symplify\/easy-testing\/tree\/10.2.11" }, "funding": [ { @@ -3665,17 +3665,17 @@ }, { "name": "symplify\/package-builder", - "version": "10.2.10", - "version_normalized": "10.2.10.0", + "version": "10.2.11", + "version_normalized": "10.2.11.0", "source": { "type": "git", "url": "https:\/\/github.com\/symplify\/package-builder.git", - "reference": "f706037ff0c645349d125c6b66d2d44426e6e5e9" + "reference": "f21028fe2918c3931b808433f7b2eb64e9108796" }, "dist": { "type": "zip", - "url": "https:\/\/api.github.com\/repos\/symplify\/package-builder\/zipball\/f706037ff0c645349d125c6b66d2d44426e6e5e9", - "reference": "f706037ff0c645349d125c6b66d2d44426e6e5e9", + "url": "https:\/\/api.github.com\/repos\/symplify\/package-builder\/zipball\/f21028fe2918c3931b808433f7b2eb64e9108796", + "reference": "f21028fe2918c3931b808433f7b2eb64e9108796", "shasum": "" }, "require": { @@ -3686,34 +3686,34 @@ "symfony\/console": "^6.0", "symfony\/dependency-injection": "^6.0", "symfony\/finder": "^6.0", - "symplify\/easy-testing": "^10.2.10", - "symplify\/symplify-kernel": "^10.2.10" + "symplify\/easy-testing": "^10.2.11", + "symplify\/symplify-kernel": "^10.2.11" }, "conflict": { - "symplify\/astral": "<10.2.10", - "symplify\/autowire-array-parameter": "<10.2.10", - "symplify\/coding-standard": "<10.2.10", - "symplify\/composer-json-manipulator": "<10.2.10", - "symplify\/config-transformer": "<10.2.10", - "symplify\/easy-ci": "<10.2.10", - "symplify\/easy-coding-standard": "<10.2.10", - "symplify\/easy-parallel": "<10.2.10", - "symplify\/monorepo-builder": "<10.2.10", - "symplify\/neon-config-dumper": "<10.2.10", - "symplify\/php-config-printer": "<10.2.10", - "symplify\/phpstan-extensions": "<10.2.10", - "symplify\/phpstan-rules": "<10.2.10", - "symplify\/rule-doc-generator": "<10.2.10", - "symplify\/rule-doc-generator-contracts": "<10.2.10", - "symplify\/skipper": "<10.2.10", - "symplify\/smart-file-system": "<10.2.10", - "symplify\/symfony-static-dumper": "<10.2.10", - "symplify\/vendor-patches": "<10.2.10" + "symplify\/astral": "<10.2.11", + "symplify\/autowire-array-parameter": "<10.2.11", + "symplify\/coding-standard": "<10.2.11", + "symplify\/composer-json-manipulator": "<10.2.11", + "symplify\/config-transformer": "<10.2.11", + "symplify\/easy-ci": "<10.2.11", + "symplify\/easy-coding-standard": "<10.2.11", + "symplify\/easy-parallel": "<10.2.11", + "symplify\/monorepo-builder": "<10.2.11", + "symplify\/neon-config-dumper": "<10.2.11", + "symplify\/php-config-printer": "<10.2.11", + "symplify\/phpstan-extensions": "<10.2.11", + "symplify\/phpstan-rules": "<10.2.11", + "symplify\/rule-doc-generator": "<10.2.11", + "symplify\/rule-doc-generator-contracts": "<10.2.11", + "symplify\/skipper": "<10.2.11", + "symplify\/smart-file-system": "<10.2.11", + "symplify\/symfony-static-dumper": "<10.2.11", + "symplify\/vendor-patches": "<10.2.11" }, "require-dev": { "phpunit\/phpunit": "^9.5" }, - "time": "2022-06-06T23:08:18+00:00", + "time": "2022-06-07T07:46:06+00:00", "type": "library", "extra": { "branch-alias": { @@ -3732,7 +3732,7 @@ ], "description": "Dependency Injection, Console and Kernel toolkit for Symplify packages.", "support": { - "source": "https:\/\/github.com\/symplify\/package-builder\/tree\/10.2.10" + "source": "https:\/\/github.com\/symplify\/package-builder\/tree\/10.2.11" }, "funding": [ { @@ -3748,17 +3748,17 @@ }, { "name": "symplify\/rule-doc-generator-contracts", - "version": "10.2.10", - "version_normalized": "10.2.10.0", + "version": "10.2.11", + "version_normalized": "10.2.11.0", "source": { "type": "git", "url": "https:\/\/github.com\/symplify\/rule-doc-generator-contracts.git", - "reference": "8f8c950f08d88b7e711a9b312c820db19472cceb" + "reference": "bccc996527d350dc9b49194be207409401fbabe4" }, "dist": { "type": "zip", - "url": "https:\/\/api.github.com\/repos\/symplify\/rule-doc-generator-contracts\/zipball\/8f8c950f08d88b7e711a9b312c820db19472cceb", - "reference": "8f8c950f08d88b7e711a9b312c820db19472cceb", + "url": "https:\/\/api.github.com\/repos\/symplify\/rule-doc-generator-contracts\/zipball\/bccc996527d350dc9b49194be207409401fbabe4", + "reference": "bccc996527d350dc9b49194be207409401fbabe4", "shasum": "" }, "require": { @@ -3766,29 +3766,29 @@ "php": ">=8.0" }, "conflict": { - "symplify\/astral": "<10.2.10", - "symplify\/autowire-array-parameter": "<10.2.10", - "symplify\/coding-standard": "<10.2.10", - "symplify\/composer-json-manipulator": "<10.2.10", - "symplify\/config-transformer": "<10.2.10", - "symplify\/easy-ci": "<10.2.10", - "symplify\/easy-coding-standard": "<10.2.10", - "symplify\/easy-parallel": "<10.2.10", - "symplify\/easy-testing": "<10.2.10", - "symplify\/monorepo-builder": "<10.2.10", - "symplify\/neon-config-dumper": "<10.2.10", - "symplify\/package-builder": "<10.2.10", - "symplify\/php-config-printer": "<10.2.10", - "symplify\/phpstan-extensions": "<10.2.10", - "symplify\/phpstan-rules": "<10.2.10", - "symplify\/rule-doc-generator": "<10.2.10", - "symplify\/skipper": "<10.2.10", - "symplify\/smart-file-system": "<10.2.10", - "symplify\/symfony-static-dumper": "<10.2.10", - "symplify\/symplify-kernel": "<10.2.10", - "symplify\/vendor-patches": "<10.2.10" + "symplify\/astral": "<10.2.11", + "symplify\/autowire-array-parameter": "<10.2.11", + "symplify\/coding-standard": "<10.2.11", + "symplify\/composer-json-manipulator": "<10.2.11", + "symplify\/config-transformer": "<10.2.11", + "symplify\/easy-ci": "<10.2.11", + "symplify\/easy-coding-standard": "<10.2.11", + "symplify\/easy-parallel": "<10.2.11", + "symplify\/easy-testing": "<10.2.11", + "symplify\/monorepo-builder": "<10.2.11", + "symplify\/neon-config-dumper": "<10.2.11", + "symplify\/package-builder": "<10.2.11", + "symplify\/php-config-printer": "<10.2.11", + "symplify\/phpstan-extensions": "<10.2.11", + "symplify\/phpstan-rules": "<10.2.11", + "symplify\/rule-doc-generator": "<10.2.11", + "symplify\/skipper": "<10.2.11", + "symplify\/smart-file-system": "<10.2.11", + "symplify\/symfony-static-dumper": "<10.2.11", + "symplify\/symplify-kernel": "<10.2.11", + "symplify\/vendor-patches": "<10.2.11" }, - "time": "2022-06-06T23:08:46+00:00", + "time": "2022-06-07T07:46:36+00:00", "type": "library", "extra": { "branch-alias": { @@ -3798,7 +3798,7 @@ "installation-source": "dist", "autoload": { "psr-4": { - "Symplify\\RuleDocGenerator\\": "src" + "RectorPrefix20220607\\Symplify\\RuleDocGenerator\\": "src" } }, "notification-url": "https:\/\/packagist.org\/downloads\/", @@ -3807,7 +3807,7 @@ ], "description": "Contracts for production code of RuleDocGenerator", "support": { - "source": "https:\/\/github.com\/symplify\/rule-doc-generator-contracts\/tree\/10.2.10" + "source": "https:\/\/github.com\/symplify\/rule-doc-generator-contracts\/tree\/10.2.11" }, "funding": [ { @@ -3823,17 +3823,17 @@ }, { "name": "symplify\/skipper", - "version": "10.2.10", - "version_normalized": "10.2.10.0", + "version": "10.2.11", + "version_normalized": "10.2.11.0", "source": { "type": "git", "url": "https:\/\/github.com\/symplify\/skipper.git", - "reference": "77a2afc796aa106eef77ae859531cc2c68417d66" + "reference": "4dd05340bd48a7700e80a34d4e3498983f99cb6b" }, "dist": { "type": "zip", - "url": "https:\/\/api.github.com\/repos\/symplify\/skipper\/zipball\/77a2afc796aa106eef77ae859531cc2c68417d66", - "reference": "77a2afc796aa106eef77ae859531cc2c68417d66", + "url": "https:\/\/api.github.com\/repos\/symplify\/skipper\/zipball\/4dd05340bd48a7700e80a34d4e3498983f99cb6b", + "reference": "4dd05340bd48a7700e80a34d4e3498983f99cb6b", "shasum": "" }, "require": { @@ -3843,34 +3843,34 @@ "symfony\/dependency-injection": "^6.0", "symfony\/filesystem": "^6.0", "symfony\/finder": "^6.0", - "symplify\/package-builder": "^10.2.10", - "symplify\/smart-file-system": "^10.2.10", - "symplify\/symplify-kernel": "^10.2.10" + "symplify\/package-builder": "^10.2.11", + "symplify\/smart-file-system": "^10.2.11", + "symplify\/symplify-kernel": "^10.2.11" }, "conflict": { - "symplify\/astral": "<10.2.10", - "symplify\/autowire-array-parameter": "<10.2.10", - "symplify\/coding-standard": "<10.2.10", - "symplify\/composer-json-manipulator": "<10.2.10", - "symplify\/config-transformer": "<10.2.10", - "symplify\/easy-ci": "<10.2.10", - "symplify\/easy-coding-standard": "<10.2.10", - "symplify\/easy-parallel": "<10.2.10", - "symplify\/easy-testing": "<10.2.10", - "symplify\/monorepo-builder": "<10.2.10", - "symplify\/neon-config-dumper": "<10.2.10", - "symplify\/php-config-printer": "<10.2.10", - "symplify\/phpstan-extensions": "<10.2.10", - "symplify\/phpstan-rules": "<10.2.10", - "symplify\/rule-doc-generator": "<10.2.10", - "symplify\/rule-doc-generator-contracts": "<10.2.10", - "symplify\/symfony-static-dumper": "<10.2.10", - "symplify\/vendor-patches": "<10.2.10" + "symplify\/astral": "<10.2.11", + "symplify\/autowire-array-parameter": "<10.2.11", + "symplify\/coding-standard": "<10.2.11", + "symplify\/composer-json-manipulator": "<10.2.11", + "symplify\/config-transformer": "<10.2.11", + "symplify\/easy-ci": "<10.2.11", + "symplify\/easy-coding-standard": "<10.2.11", + "symplify\/easy-parallel": "<10.2.11", + "symplify\/easy-testing": "<10.2.11", + "symplify\/monorepo-builder": "<10.2.11", + "symplify\/neon-config-dumper": "<10.2.11", + "symplify\/php-config-printer": "<10.2.11", + "symplify\/phpstan-extensions": "<10.2.11", + "symplify\/phpstan-rules": "<10.2.11", + "symplify\/rule-doc-generator": "<10.2.11", + "symplify\/rule-doc-generator-contracts": "<10.2.11", + "symplify\/symfony-static-dumper": "<10.2.11", + "symplify\/vendor-patches": "<10.2.11" }, "require-dev": { "phpunit\/phpunit": "^9.5" }, - "time": "2022-06-06T23:08:48+00:00", + "time": "2022-06-07T07:46:33+00:00", "type": "library", "extra": { "branch-alias": { @@ -3889,7 +3889,7 @@ ], "description": "Skip files by rule class, directory, file or fnmatch", "support": { - "source": "https:\/\/github.com\/symplify\/skipper\/tree\/10.2.10" + "source": "https:\/\/github.com\/symplify\/skipper\/tree\/10.2.11" }, "funding": [ { @@ -3905,17 +3905,17 @@ }, { "name": "symplify\/smart-file-system", - "version": "10.2.10", - "version_normalized": "10.2.10.0", + "version": "10.2.11", + "version_normalized": "10.2.11.0", "source": { "type": "git", "url": "https:\/\/github.com\/symplify\/smart-file-system.git", - "reference": "da20e03540e169eb3a2461b888ec88dc77765f72" + "reference": "dd89f04155f611f307f1bb6a8304472ab7c1680a" }, "dist": { "type": "zip", - "url": "https:\/\/api.github.com\/repos\/symplify\/smart-file-system\/zipball\/da20e03540e169eb3a2461b888ec88dc77765f72", - "reference": "da20e03540e169eb3a2461b888ec88dc77765f72", + "url": "https:\/\/api.github.com\/repos\/symplify\/smart-file-system\/zipball\/dd89f04155f611f307f1bb6a8304472ab7c1680a", + "reference": "dd89f04155f611f307f1bb6a8304472ab7c1680a", "shasum": "" }, "require": { @@ -3925,33 +3925,33 @@ "symfony\/finder": "^6.0" }, "conflict": { - "symplify\/astral": "<10.2.10", - "symplify\/autowire-array-parameter": "<10.2.10", - "symplify\/coding-standard": "<10.2.10", - "symplify\/composer-json-manipulator": "<10.2.10", - "symplify\/config-transformer": "<10.2.10", - "symplify\/easy-ci": "<10.2.10", - "symplify\/easy-coding-standard": "<10.2.10", - "symplify\/easy-parallel": "<10.2.10", - "symplify\/easy-testing": "<10.2.10", - "symplify\/monorepo-builder": "<10.2.10", - "symplify\/neon-config-dumper": "<10.2.10", - "symplify\/package-builder": "<10.2.10", - "symplify\/php-config-printer": "<10.2.10", - "symplify\/phpstan-extensions": "<10.2.10", - "symplify\/phpstan-rules": "<10.2.10", - "symplify\/rule-doc-generator": "<10.2.10", - "symplify\/rule-doc-generator-contracts": "<10.2.10", - "symplify\/skipper": "<10.2.10", - "symplify\/symfony-static-dumper": "<10.2.10", - "symplify\/symplify-kernel": "<10.2.10", - "symplify\/vendor-patches": "<10.2.10" + "symplify\/astral": "<10.2.11", + "symplify\/autowire-array-parameter": "<10.2.11", + "symplify\/coding-standard": "<10.2.11", + "symplify\/composer-json-manipulator": "<10.2.11", + "symplify\/config-transformer": "<10.2.11", + "symplify\/easy-ci": "<10.2.11", + "symplify\/easy-coding-standard": "<10.2.11", + "symplify\/easy-parallel": "<10.2.11", + "symplify\/easy-testing": "<10.2.11", + "symplify\/monorepo-builder": "<10.2.11", + "symplify\/neon-config-dumper": "<10.2.11", + "symplify\/package-builder": "<10.2.11", + "symplify\/php-config-printer": "<10.2.11", + "symplify\/phpstan-extensions": "<10.2.11", + "symplify\/phpstan-rules": "<10.2.11", + "symplify\/rule-doc-generator": "<10.2.11", + "symplify\/rule-doc-generator-contracts": "<10.2.11", + "symplify\/skipper": "<10.2.11", + "symplify\/symfony-static-dumper": "<10.2.11", + "symplify\/symplify-kernel": "<10.2.11", + "symplify\/vendor-patches": "<10.2.11" }, "require-dev": { "nette\/finder": "^2.5", "phpunit\/phpunit": "^9.5" }, - "time": "2022-06-06T23:08:48+00:00", + "time": "2022-06-07T07:46:37+00:00", "type": "library", "extra": { "branch-alias": { @@ -3970,7 +3970,7 @@ ], "description": "Sanitized FileInfo with safe getRealPath() and other handy methods", "support": { - "source": "https:\/\/github.com\/symplify\/smart-file-system\/tree\/10.2.10" + "source": "https:\/\/github.com\/symplify\/smart-file-system\/tree\/10.2.11" }, "funding": [ { @@ -3986,52 +3986,52 @@ }, { "name": "symplify\/symplify-kernel", - "version": "10.2.10", - "version_normalized": "10.2.10.0", + "version": "10.2.11", + "version_normalized": "10.2.11.0", "source": { "type": "git", "url": "https:\/\/github.com\/symplify\/symplify-kernel.git", - "reference": "f337821aaf9254b8478567d46f954fdfd8fbea5e" + "reference": "f476ff580d64e8b9f83786924713a6159637ce91" }, "dist": { "type": "zip", - "url": "https:\/\/api.github.com\/repos\/symplify\/symplify-kernel\/zipball\/f337821aaf9254b8478567d46f954fdfd8fbea5e", - "reference": "f337821aaf9254b8478567d46f954fdfd8fbea5e", + "url": "https:\/\/api.github.com\/repos\/symplify\/symplify-kernel\/zipball\/f476ff580d64e8b9f83786924713a6159637ce91", + "reference": "f476ff580d64e8b9f83786924713a6159637ce91", "shasum": "" }, "require": { "php": ">=8.0", "symfony\/console": "^6.0", "symfony\/dependency-injection": "^6.0", - "symplify\/autowire-array-parameter": "^10.2.10", - "symplify\/composer-json-manipulator": "^10.2.10", - "symplify\/package-builder": "^10.2.10", - "symplify\/smart-file-system": "^10.2.10", + "symplify\/autowire-array-parameter": "^10.2.11", + "symplify\/composer-json-manipulator": "^10.2.11", + "symplify\/package-builder": "^10.2.11", + "symplify\/smart-file-system": "^10.2.11", "webmozart\/assert": "^1.10" }, "conflict": { - "symplify\/astral": "<10.2.10", - "symplify\/coding-standard": "<10.2.10", - "symplify\/config-transformer": "<10.2.10", - "symplify\/easy-ci": "<10.2.10", - "symplify\/easy-coding-standard": "<10.2.10", - "symplify\/easy-parallel": "<10.2.10", - "symplify\/easy-testing": "<10.2.10", - "symplify\/monorepo-builder": "<10.2.10", - "symplify\/neon-config-dumper": "<10.2.10", - "symplify\/php-config-printer": "<10.2.10", - "symplify\/phpstan-extensions": "<10.2.10", - "symplify\/phpstan-rules": "<10.2.10", - "symplify\/rule-doc-generator": "<10.2.10", - "symplify\/rule-doc-generator-contracts": "<10.2.10", - "symplify\/skipper": "<10.2.10", - "symplify\/symfony-static-dumper": "<10.2.10", - "symplify\/vendor-patches": "<10.2.10" + "symplify\/astral": "<10.2.11", + "symplify\/coding-standard": "<10.2.11", + "symplify\/config-transformer": "<10.2.11", + "symplify\/easy-ci": "<10.2.11", + "symplify\/easy-coding-standard": "<10.2.11", + "symplify\/easy-parallel": "<10.2.11", + "symplify\/easy-testing": "<10.2.11", + "symplify\/monorepo-builder": "<10.2.11", + "symplify\/neon-config-dumper": "<10.2.11", + "symplify\/php-config-printer": "<10.2.11", + "symplify\/phpstan-extensions": "<10.2.11", + "symplify\/phpstan-rules": "<10.2.11", + "symplify\/rule-doc-generator": "<10.2.11", + "symplify\/rule-doc-generator-contracts": "<10.2.11", + "symplify\/skipper": "<10.2.11", + "symplify\/symfony-static-dumper": "<10.2.11", + "symplify\/vendor-patches": "<10.2.11" }, "require-dev": { "phpunit\/phpunit": "^9.5" }, - "time": "2022-06-06T23:09:30+00:00", + "time": "2022-06-07T07:46:43+00:00", "type": "library", "extra": { "branch-alias": { @@ -4050,7 +4050,7 @@ ], "description": "Internal Kernel for Symplify packages", "support": { - "source": "https:\/\/github.com\/symplify\/symplify-kernel\/tree\/10.2.10" + "source": "https:\/\/github.com\/symplify\/symplify-kernel\/tree\/10.2.11" }, "install-path": "..\/symplify\/symplify-kernel" }, diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 6b050ab4eda..5777bc03ee4 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -2,4 +2,4 @@ namespace RectorPrefix20220607; -return array('root' => array('name' => 'rector/rector-src', 'pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => \NULL, 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(0 => '0.13.x-dev'), 'dev' => \false), 'versions' => array('clue/ndjson-react' => array('pretty_version' => 'v1.2.0', 'version' => '1.2.0.0', 'reference' => '708411c7e45ac85371a99d50f52284971494bede', 'type' => 'library', 'install_path' => __DIR__ . '/../clue/ndjson-react', 'aliases' => array(), 'dev_requirement' => \false), 'composer/pcre' => array('pretty_version' => '3.0.0', 'version' => '3.0.0.0', 'reference' => 'e300eb6c535192decd27a85bc72a9290f0d6b3bd', 'type' => 'library', 'install_path' => __DIR__ . '/./pcre', 'aliases' => array(), 'dev_requirement' => \false), 'composer/semver' => array('pretty_version' => '3.3.2', 'version' => '3.3.2.0', 'reference' => '3953f23262f2bff1919fc82183ad9acb13ff62c9', 'type' => 'library', 'install_path' => __DIR__ . '/./semver', 'aliases' => array(), 'dev_requirement' => \false), 'composer/xdebug-handler' => array('pretty_version' => '3.0.3', 'version' => '3.0.3.0', 'reference' => 'ced299686f41dce890debac69273b47ffe98a40c', 'type' => 'library', 'install_path' => __DIR__ . '/./xdebug-handler', 'aliases' => array(), 'dev_requirement' => \false), 'doctrine/inflector' => array('pretty_version' => '2.0.4', 'version' => '2.0.4.0', 'reference' => '8b7ff3e4b7de6b2c84da85637b59fd2880ecaa89', 'type' => 'library', 'install_path' => __DIR__ . '/../doctrine/inflector', 'aliases' => array(), 'dev_requirement' => \false), 'evenement/evenement' => array('pretty_version' => 'v3.0.1', 'version' => '3.0.1.0', 'reference' => '531bfb9d15f8aa57454f5f0285b18bec903b8fb7', 'type' => 'library', 'install_path' => __DIR__ . '/../evenement/evenement', 'aliases' => array(), 'dev_requirement' => \false), 'nette/neon' => array('pretty_version' => 'v3.3.3', 'version' => '3.3.3.0', 'reference' => '22e384da162fab42961d48eb06c06d3ad0c11b95', 'type' => 'library', 'install_path' => __DIR__ . '/../nette/neon', 'aliases' => array(), 'dev_requirement' => \false), 'nette/utils' => array('pretty_version' => 'v3.2.7', 'version' => '3.2.7.0', 'reference' => '0af4e3de4df9f1543534beab255ccf459e7a2c99', 'type' => 'library', 'install_path' => __DIR__ . '/../nette/utils', 'aliases' => array(), 'dev_requirement' => \false), 'nikic/php-parser' => array('pretty_version' => 'v4.14.0', 'version' => '4.14.0.0', 'reference' => '34bea19b6e03d8153165d8f30bba4c3be86184c1', 'type' => 'library', 'install_path' => __DIR__ . '/../nikic/php-parser', 'aliases' => array(), 'dev_requirement' => \false), 'ondram/ci-detector' => array('pretty_version' => '4.1.0', 'version' => '4.1.0.0', 'reference' => '8a4b664e916df82ff26a44709942dfd593fa6f30', 'type' => 'library', 'install_path' => __DIR__ . '/../ondram/ci-detector', 'aliases' => array(), 'dev_requirement' => \false), 'phpstan/phpdoc-parser' => array('pretty_version' => '1.5.1', 'version' => '1.5.1.0', 'reference' => '981cc368a216c988e862a75e526b6076987d1b50', 'type' => 'library', 'install_path' => __DIR__ . '/../phpstan/phpdoc-parser', 'aliases' => array(), 'dev_requirement' => \false), 'phpstan/phpstan' => array('pretty_version' => '1.7.10', 'version' => '1.7.10.0', 'reference' => '25e069474cf00215b0f64c60a26230908ef3eefa', 'type' => 'library', 'install_path' => __DIR__ . '/../phpstan/phpstan', 'aliases' => array(), 'dev_requirement' => \false), 'phpstan/phpstan-phpunit' => array('pretty_version' => '1.1.1', 'version' => '1.1.1.0', 'reference' => '4a3c437c09075736285d1cabb5c75bf27ed0bc84', 'type' => 'phpstan-extension', 'install_path' => __DIR__ . '/../phpstan/phpstan-phpunit', 'aliases' => array(), 'dev_requirement' => \false), 'psr/cache' => array('pretty_version' => '3.0.0', 'version' => '3.0.0.0', 'reference' => 'aa5030cfa5405eccfdcb1083ce040c2cb8d253bf', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/cache', 'aliases' => array(), 'dev_requirement' => \false), 'psr/container' => array('pretty_version' => '2.0.2', 'version' => '2.0.2.0', 'reference' => 'c71ecc56dfe541dbd90c5360474fbc405f8d5963', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/container', 'aliases' => array(), 'dev_requirement' => \false), 'psr/container-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.1|2.0')), 'psr/event-dispatcher' => array('pretty_version' => '1.0.0', 'version' => '1.0.0.0', 'reference' => 'dbefd12671e8a14ec7f180cab83036ed26714bb0', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/event-dispatcher', 'aliases' => array(), 'dev_requirement' => \false), 'psr/log' => array('pretty_version' => '3.0.0', 'version' => '3.0.0.0', 'reference' => 'fe5ea303b0887d5caefd3d431c3e61ad47037001', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/log', 'aliases' => array(), 'dev_requirement' => \false), 'psr/log-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0|2.0|3.0')), 'react/cache' => array('pretty_version' => 'v1.1.1', 'version' => '1.1.1.0', 'reference' => '4bf736a2cccec7298bdf745db77585966fc2ca7e', 'type' => 'library', 'install_path' => __DIR__ . '/../react/cache', 'aliases' => array(), 'dev_requirement' => \false), 'react/child-process' => array('pretty_version' => 'v0.6.4', 'version' => '0.6.4.0', 'reference' => 'a778f3fb828d68caf8a9ab6567fd8342a86f12fe', 'type' => 'library', 'install_path' => __DIR__ . '/../react/child-process', 'aliases' => array(), 'dev_requirement' => \false), 'react/dns' => array('pretty_version' => 'v1.9.0', 'version' => '1.9.0.0', 'reference' => '6d38296756fa644e6cb1bfe95eff0f9a4ed6edcb', 'type' => 'library', 'install_path' => __DIR__ . '/../react/dns', 'aliases' => array(), 'dev_requirement' => \false), 'react/event-loop' => array('pretty_version' => 'v1.3.0', 'version' => '1.3.0.0', 'reference' => '187fb56f46d424afb6ec4ad089269c72eec2e137', 'type' => 'library', 'install_path' => __DIR__ . '/../react/event-loop', 'aliases' => array(), 'dev_requirement' => \false), 'react/promise' => array('pretty_version' => 'v2.9.0', 'version' => '2.9.0.0', 'reference' => '234f8fd1023c9158e2314fa9d7d0e6a83db42910', 'type' => 'library', 'install_path' => __DIR__ . '/../react/promise', 'aliases' => array(), 'dev_requirement' => \false), 'react/promise-timer' => array('pretty_version' => 'v1.8.0', 'version' => '1.8.0.0', 'reference' => '0bbbcc79589e5bfdddba68a287f1cb805581a479', 'type' => 'library', 'install_path' => __DIR__ . '/../react/promise-timer', 'aliases' => array(), 'dev_requirement' => \false), 'react/socket' => array('pretty_version' => 'v1.11.0', 'version' => '1.11.0.0', 'reference' => 'f474156aaab4f09041144fa8b57c7d70aed32a1c', 'type' => 'library', 'install_path' => __DIR__ . '/../react/socket', 'aliases' => array(), 'dev_requirement' => \false), 'react/stream' => array('pretty_version' => 'v1.2.0', 'version' => '1.2.0.0', 'reference' => '7a423506ee1903e89f1e08ec5f0ed430ff784ae9', 'type' => 'library', 'install_path' => __DIR__ . '/../react/stream', 'aliases' => array(), 'dev_requirement' => \false), 'rector/extension-installer' => array('pretty_version' => '0.11.2', 'version' => '0.11.2.0', 'reference' => '05544e9b195863b8571ae2a3b903cbec7fa062e0', 'type' => 'composer-plugin', 'install_path' => __DIR__ . '/../rector/extension-installer', 'aliases' => array(), 'dev_requirement' => \false), 'rector/rector' => array('dev_requirement' => \false, 'replaced' => array(0 => '0.13.x-dev', 1 => 'dev-main')), 'rector/rector-cakephp' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '7bc99a7caedb12817ef56443f6392ced53c54b56', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-cakephp', 'aliases' => array(0 => '0.11.x-dev'), 'dev_requirement' => \false), 'rector/rector-doctrine' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'f5bf84ccdd110e2ce34ea0d28ae66aa98aa44c92', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-doctrine', 'aliases' => array(0 => '0.11.x-dev'), 'dev_requirement' => \false), 'rector/rector-generator' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '623c9e23d10ba24782de7f17caacdf2aaa65d543', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-generator', 'aliases' => array(0 => '9999999-dev'), 'dev_requirement' => \false), 'rector/rector-laravel' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '25afcdb5f140f72a710783c3922b8080a381cc2c', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-laravel', 'aliases' => array(0 => '0.11.x-dev'), 'dev_requirement' => \false), 'rector/rector-nette' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '4307b98001cfb0fcfcb7d730249c34488c347f96', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-nette', 'aliases' => array(0 => '0.11.x-dev'), 'dev_requirement' => \false), 'rector/rector-phpoffice' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '29f4cf098107617b2d71da1542f7c74201212119', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-phpoffice', 'aliases' => array(0 => '0.11.x-dev'), 'dev_requirement' => \false), 'rector/rector-phpunit' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '9d58f8ab076bb2e363c8f6426ac5328815ca63ca', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-phpunit', 'aliases' => array(0 => '0.11.x-dev'), 'dev_requirement' => \false), 'rector/rector-src' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => \NULL, 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(0 => '0.13.x-dev'), 'dev_requirement' => \false), 'rector/rector-symfony' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'a8ff9fb8572409b53826c7d44a718e239e3670b2', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-symfony', 'aliases' => array(0 => '0.11.x-dev'), 'dev_requirement' => \false), 'sebastian/diff' => array('pretty_version' => '4.0.4', 'version' => '4.0.4.0', 'reference' => '3461e3fccc7cfdfc2720be910d3bd73c69be590d', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/diff', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/cache-contracts' => array('dev_requirement' => \false, 'replaced' => array(0 => 'v3.1.0')), 'symfony/config' => array('pretty_version' => 'v6.1.0', 'version' => '6.1.0.0', 'reference' => 'ed8d12417bcacd2d969750feb1fe1aab1c11e613', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/config', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/console' => array('pretty_version' => 'v6.1.0', 'version' => '6.1.0.0', 'reference' => 'c9646197ef43b0e2ff44af61e7f0571526fd4170', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/console', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/contracts' => array('pretty_version' => 'v3.1.0', 'version' => '3.1.0.0', 'reference' => 'a4a823e4e2ed8e49c29d08e42a0e797a4306585e', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/contracts', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/dependency-injection' => array('pretty_version' => 'v6.1.0', 'version' => '6.1.0.0', 'reference' => 'fc1fcd2b153f585934e80055bb3254913def2a6e', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/dependency-injection', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/deprecation-contracts' => array('dev_requirement' => \false, 'replaced' => array(0 => 'v3.1.0')), 'symfony/event-dispatcher-contracts' => array('dev_requirement' => \false, 'replaced' => array(0 => 'v3.1.0')), 'symfony/filesystem' => array('pretty_version' => 'v6.1.0', 'version' => '6.1.0.0', 'reference' => '3132d2f43ca799c2aa099f9738d98228c56baa5d', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/filesystem', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/finder' => array('pretty_version' => 'v6.1.0', 'version' => '6.1.0.0', 'reference' => '45b8beb69d6eb3b05a65689ebfd4222326773f8f', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/finder', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/http-client-contracts' => array('dev_requirement' => \false, 'replaced' => array(0 => 'v3.1.0')), 'symfony/polyfill-ctype' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/polyfill-intl-grapheme' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/polyfill-intl-normalizer' => array('pretty_version' => 'v1.26.0', 'version' => '1.26.0.0', 'reference' => '219aa369ceff116e673852dce47c3a41794c14bd', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-intl-normalizer', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/polyfill-mbstring' => array('pretty_version' => 'v1.26.0', 'version' => '1.26.0.0', 'reference' => '9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/service-contracts' => array('dev_requirement' => \false, 'replaced' => array(0 => 'v3.1.0')), 'symfony/service-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.1|2.0|3.0')), 'symfony/string' => array('pretty_version' => 'v6.1.0', 'version' => '6.1.0.0', 'reference' => 'd3edc75baf9f1d4f94879764dda2e1ac33499529', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/string', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/translation-contracts' => array('dev_requirement' => \false, 'replaced' => array(0 => 'v3.1.0')), 'symplify/astral' => array('pretty_version' => '10.2.10', 'version' => '10.2.10.0', 'reference' => '9eac7f0006a1bc7410f77c50f28373b580615a66', 'type' => 'phpstan-extension', 'install_path' => __DIR__ . '/../symplify/astral', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/autowire-array-parameter' => array('pretty_version' => '10.2.10', 'version' => '10.2.10.0', 'reference' => '671c677e48701b89dd8f7f6c59e6f5349552bc04', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/autowire-array-parameter', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/composer-json-manipulator' => array('pretty_version' => '10.2.10', 'version' => '10.2.10.0', 'reference' => '867a328dd5526cf0f502119fb31a2b7308d60e7d', 'type' => 'symfony-bundle', 'install_path' => __DIR__ . '/../symplify/composer-json-manipulator', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/easy-parallel' => array('pretty_version' => '10.2.10', 'version' => '10.2.10.0', 'reference' => '3715dbb7871355469c2871b478ad634235594166', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/easy-parallel', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/easy-testing' => array('pretty_version' => '10.2.10', 'version' => '10.2.10.0', 'reference' => '26d00205b56abaef67ad327fe774f0db08172d05', 'type' => 'symfony-bundle', 'install_path' => __DIR__ . '/../symplify/easy-testing', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/package-builder' => array('pretty_version' => '10.2.10', 'version' => '10.2.10.0', 'reference' => 'f706037ff0c645349d125c6b66d2d44426e6e5e9', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/package-builder', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/rule-doc-generator-contracts' => array('pretty_version' => '10.2.10', 'version' => '10.2.10.0', 'reference' => '8f8c950f08d88b7e711a9b312c820db19472cceb', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/rule-doc-generator-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/skipper' => array('pretty_version' => '10.2.10', 'version' => '10.2.10.0', 'reference' => '77a2afc796aa106eef77ae859531cc2c68417d66', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/skipper', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/smart-file-system' => array('pretty_version' => '10.2.10', 'version' => '10.2.10.0', 'reference' => 'da20e03540e169eb3a2461b888ec88dc77765f72', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/smart-file-system', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/symplify-kernel' => array('pretty_version' => '10.2.10', 'version' => '10.2.10.0', 'reference' => 'f337821aaf9254b8478567d46f954fdfd8fbea5e', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/symplify-kernel', 'aliases' => array(), 'dev_requirement' => \false), 'tracy/tracy' => array('pretty_version' => 'v2.9.3', 'version' => '2.9.3.0', 'reference' => '3aadc88c00d7aca84ce2f07da236a703cc183d52', 'type' => 'library', 'install_path' => __DIR__ . '/../tracy/tracy', 'aliases' => array(), 'dev_requirement' => \false), 'webmozart/assert' => array('pretty_version' => '1.11.0', 'version' => '1.11.0.0', 'reference' => '11cb2199493b2f8a3b53e7f19068fc6aac760991', 'type' => 'library', 'install_path' => __DIR__ . '/../webmozart/assert', 'aliases' => array(), 'dev_requirement' => \false))); +return array('root' => array('name' => 'rector/rector-src', 'pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => NULL, 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(0 => '0.13.x-dev'), 'dev' => \false), 'versions' => array('clue/ndjson-react' => array('pretty_version' => 'v1.2.0', 'version' => '1.2.0.0', 'reference' => '708411c7e45ac85371a99d50f52284971494bede', 'type' => 'library', 'install_path' => __DIR__ . '/../clue/ndjson-react', 'aliases' => array(), 'dev_requirement' => \false), 'composer/pcre' => array('pretty_version' => '3.0.0', 'version' => '3.0.0.0', 'reference' => 'e300eb6c535192decd27a85bc72a9290f0d6b3bd', 'type' => 'library', 'install_path' => __DIR__ . '/./pcre', 'aliases' => array(), 'dev_requirement' => \false), 'composer/semver' => array('pretty_version' => '3.3.2', 'version' => '3.3.2.0', 'reference' => '3953f23262f2bff1919fc82183ad9acb13ff62c9', 'type' => 'library', 'install_path' => __DIR__ . '/./semver', 'aliases' => array(), 'dev_requirement' => \false), 'composer/xdebug-handler' => array('pretty_version' => '3.0.3', 'version' => '3.0.3.0', 'reference' => 'ced299686f41dce890debac69273b47ffe98a40c', 'type' => 'library', 'install_path' => __DIR__ . '/./xdebug-handler', 'aliases' => array(), 'dev_requirement' => \false), 'doctrine/inflector' => array('pretty_version' => '2.0.4', 'version' => '2.0.4.0', 'reference' => '8b7ff3e4b7de6b2c84da85637b59fd2880ecaa89', 'type' => 'library', 'install_path' => __DIR__ . '/../doctrine/inflector', 'aliases' => array(), 'dev_requirement' => \false), 'evenement/evenement' => array('pretty_version' => 'v3.0.1', 'version' => '3.0.1.0', 'reference' => '531bfb9d15f8aa57454f5f0285b18bec903b8fb7', 'type' => 'library', 'install_path' => __DIR__ . '/../evenement/evenement', 'aliases' => array(), 'dev_requirement' => \false), 'nette/neon' => array('pretty_version' => 'v3.3.3', 'version' => '3.3.3.0', 'reference' => '22e384da162fab42961d48eb06c06d3ad0c11b95', 'type' => 'library', 'install_path' => __DIR__ . '/../nette/neon', 'aliases' => array(), 'dev_requirement' => \false), 'nette/utils' => array('pretty_version' => 'v3.2.7', 'version' => '3.2.7.0', 'reference' => '0af4e3de4df9f1543534beab255ccf459e7a2c99', 'type' => 'library', 'install_path' => __DIR__ . '/../nette/utils', 'aliases' => array(), 'dev_requirement' => \false), 'nikic/php-parser' => array('pretty_version' => 'v4.14.0', 'version' => '4.14.0.0', 'reference' => '34bea19b6e03d8153165d8f30bba4c3be86184c1', 'type' => 'library', 'install_path' => __DIR__ . '/../nikic/php-parser', 'aliases' => array(), 'dev_requirement' => \false), 'ondram/ci-detector' => array('pretty_version' => '4.1.0', 'version' => '4.1.0.0', 'reference' => '8a4b664e916df82ff26a44709942dfd593fa6f30', 'type' => 'library', 'install_path' => __DIR__ . '/../ondram/ci-detector', 'aliases' => array(), 'dev_requirement' => \false), 'phpstan/phpdoc-parser' => array('pretty_version' => '1.5.1', 'version' => '1.5.1.0', 'reference' => '981cc368a216c988e862a75e526b6076987d1b50', 'type' => 'library', 'install_path' => __DIR__ . '/../phpstan/phpdoc-parser', 'aliases' => array(), 'dev_requirement' => \false), 'phpstan/phpstan' => array('pretty_version' => '1.7.10', 'version' => '1.7.10.0', 'reference' => '25e069474cf00215b0f64c60a26230908ef3eefa', 'type' => 'library', 'install_path' => __DIR__ . '/../phpstan/phpstan', 'aliases' => array(), 'dev_requirement' => \false), 'phpstan/phpstan-phpunit' => array('pretty_version' => '1.1.1', 'version' => '1.1.1.0', 'reference' => '4a3c437c09075736285d1cabb5c75bf27ed0bc84', 'type' => 'phpstan-extension', 'install_path' => __DIR__ . '/../phpstan/phpstan-phpunit', 'aliases' => array(), 'dev_requirement' => \false), 'psr/cache' => array('pretty_version' => '3.0.0', 'version' => '3.0.0.0', 'reference' => 'aa5030cfa5405eccfdcb1083ce040c2cb8d253bf', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/cache', 'aliases' => array(), 'dev_requirement' => \false), 'psr/container' => array('pretty_version' => '2.0.2', 'version' => '2.0.2.0', 'reference' => 'c71ecc56dfe541dbd90c5360474fbc405f8d5963', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/container', 'aliases' => array(), 'dev_requirement' => \false), 'psr/container-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.1|2.0')), 'psr/event-dispatcher' => array('pretty_version' => '1.0.0', 'version' => '1.0.0.0', 'reference' => 'dbefd12671e8a14ec7f180cab83036ed26714bb0', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/event-dispatcher', 'aliases' => array(), 'dev_requirement' => \false), 'psr/log' => array('pretty_version' => '3.0.0', 'version' => '3.0.0.0', 'reference' => 'fe5ea303b0887d5caefd3d431c3e61ad47037001', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/log', 'aliases' => array(), 'dev_requirement' => \false), 'psr/log-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0|2.0|3.0')), 'react/cache' => array('pretty_version' => 'v1.1.1', 'version' => '1.1.1.0', 'reference' => '4bf736a2cccec7298bdf745db77585966fc2ca7e', 'type' => 'library', 'install_path' => __DIR__ . '/../react/cache', 'aliases' => array(), 'dev_requirement' => \false), 'react/child-process' => array('pretty_version' => 'v0.6.4', 'version' => '0.6.4.0', 'reference' => 'a778f3fb828d68caf8a9ab6567fd8342a86f12fe', 'type' => 'library', 'install_path' => __DIR__ . '/../react/child-process', 'aliases' => array(), 'dev_requirement' => \false), 'react/dns' => array('pretty_version' => 'v1.9.0', 'version' => '1.9.0.0', 'reference' => '6d38296756fa644e6cb1bfe95eff0f9a4ed6edcb', 'type' => 'library', 'install_path' => __DIR__ . '/../react/dns', 'aliases' => array(), 'dev_requirement' => \false), 'react/event-loop' => array('pretty_version' => 'v1.3.0', 'version' => '1.3.0.0', 'reference' => '187fb56f46d424afb6ec4ad089269c72eec2e137', 'type' => 'library', 'install_path' => __DIR__ . '/../react/event-loop', 'aliases' => array(), 'dev_requirement' => \false), 'react/promise' => array('pretty_version' => 'v2.9.0', 'version' => '2.9.0.0', 'reference' => '234f8fd1023c9158e2314fa9d7d0e6a83db42910', 'type' => 'library', 'install_path' => __DIR__ . '/../react/promise', 'aliases' => array(), 'dev_requirement' => \false), 'react/promise-timer' => array('pretty_version' => 'v1.8.0', 'version' => '1.8.0.0', 'reference' => '0bbbcc79589e5bfdddba68a287f1cb805581a479', 'type' => 'library', 'install_path' => __DIR__ . '/../react/promise-timer', 'aliases' => array(), 'dev_requirement' => \false), 'react/socket' => array('pretty_version' => 'v1.11.0', 'version' => '1.11.0.0', 'reference' => 'f474156aaab4f09041144fa8b57c7d70aed32a1c', 'type' => 'library', 'install_path' => __DIR__ . '/../react/socket', 'aliases' => array(), 'dev_requirement' => \false), 'react/stream' => array('pretty_version' => 'v1.2.0', 'version' => '1.2.0.0', 'reference' => '7a423506ee1903e89f1e08ec5f0ed430ff784ae9', 'type' => 'library', 'install_path' => __DIR__ . '/../react/stream', 'aliases' => array(), 'dev_requirement' => \false), 'rector/extension-installer' => array('pretty_version' => '0.11.2', 'version' => '0.11.2.0', 'reference' => '05544e9b195863b8571ae2a3b903cbec7fa062e0', 'type' => 'composer-plugin', 'install_path' => __DIR__ . '/../rector/extension-installer', 'aliases' => array(), 'dev_requirement' => \false), 'rector/rector' => array('dev_requirement' => \false, 'replaced' => array(0 => '0.13.x-dev', 1 => 'dev-main')), 'rector/rector-cakephp' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '7bc99a7caedb12817ef56443f6392ced53c54b56', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-cakephp', 'aliases' => array(0 => '0.11.x-dev'), 'dev_requirement' => \false), 'rector/rector-doctrine' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'f5bf84ccdd110e2ce34ea0d28ae66aa98aa44c92', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-doctrine', 'aliases' => array(0 => '0.11.x-dev'), 'dev_requirement' => \false), 'rector/rector-generator' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '623c9e23d10ba24782de7f17caacdf2aaa65d543', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-generator', 'aliases' => array(0 => '9999999-dev'), 'dev_requirement' => \false), 'rector/rector-laravel' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '25afcdb5f140f72a710783c3922b8080a381cc2c', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-laravel', 'aliases' => array(0 => '0.11.x-dev'), 'dev_requirement' => \false), 'rector/rector-nette' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '4307b98001cfb0fcfcb7d730249c34488c347f96', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-nette', 'aliases' => array(0 => '0.11.x-dev'), 'dev_requirement' => \false), 'rector/rector-phpoffice' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '29f4cf098107617b2d71da1542f7c74201212119', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-phpoffice', 'aliases' => array(0 => '0.11.x-dev'), 'dev_requirement' => \false), 'rector/rector-phpunit' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '9d58f8ab076bb2e363c8f6426ac5328815ca63ca', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-phpunit', 'aliases' => array(0 => '0.11.x-dev'), 'dev_requirement' => \false), 'rector/rector-src' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => NULL, 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(0 => '0.13.x-dev'), 'dev_requirement' => \false), 'rector/rector-symfony' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'a8ff9fb8572409b53826c7d44a718e239e3670b2', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-symfony', 'aliases' => array(0 => '0.11.x-dev'), 'dev_requirement' => \false), 'sebastian/diff' => array('pretty_version' => '4.0.4', 'version' => '4.0.4.0', 'reference' => '3461e3fccc7cfdfc2720be910d3bd73c69be590d', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/diff', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/cache-contracts' => array('dev_requirement' => \false, 'replaced' => array(0 => 'v3.1.0')), 'symfony/config' => array('pretty_version' => 'v6.1.0', 'version' => '6.1.0.0', 'reference' => 'ed8d12417bcacd2d969750feb1fe1aab1c11e613', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/config', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/console' => array('pretty_version' => 'v6.1.0', 'version' => '6.1.0.0', 'reference' => 'c9646197ef43b0e2ff44af61e7f0571526fd4170', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/console', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/contracts' => array('pretty_version' => 'v3.1.0', 'version' => '3.1.0.0', 'reference' => 'a4a823e4e2ed8e49c29d08e42a0e797a4306585e', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/contracts', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/dependency-injection' => array('pretty_version' => 'v6.1.0', 'version' => '6.1.0.0', 'reference' => 'fc1fcd2b153f585934e80055bb3254913def2a6e', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/dependency-injection', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/deprecation-contracts' => array('dev_requirement' => \false, 'replaced' => array(0 => 'v3.1.0')), 'symfony/event-dispatcher-contracts' => array('dev_requirement' => \false, 'replaced' => array(0 => 'v3.1.0')), 'symfony/filesystem' => array('pretty_version' => 'v6.1.0', 'version' => '6.1.0.0', 'reference' => '3132d2f43ca799c2aa099f9738d98228c56baa5d', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/filesystem', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/finder' => array('pretty_version' => 'v6.1.0', 'version' => '6.1.0.0', 'reference' => '45b8beb69d6eb3b05a65689ebfd4222326773f8f', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/finder', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/http-client-contracts' => array('dev_requirement' => \false, 'replaced' => array(0 => 'v3.1.0')), 'symfony/polyfill-ctype' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/polyfill-intl-grapheme' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/polyfill-intl-normalizer' => array('pretty_version' => 'v1.26.0', 'version' => '1.26.0.0', 'reference' => '219aa369ceff116e673852dce47c3a41794c14bd', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-intl-normalizer', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/polyfill-mbstring' => array('pretty_version' => 'v1.26.0', 'version' => '1.26.0.0', 'reference' => '9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/service-contracts' => array('dev_requirement' => \false, 'replaced' => array(0 => 'v3.1.0')), 'symfony/service-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.1|2.0|3.0')), 'symfony/string' => array('pretty_version' => 'v6.1.0', 'version' => '6.1.0.0', 'reference' => 'd3edc75baf9f1d4f94879764dda2e1ac33499529', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/string', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/translation-contracts' => array('dev_requirement' => \false, 'replaced' => array(0 => 'v3.1.0')), 'symplify/astral' => array('pretty_version' => '10.2.11', 'version' => '10.2.11.0', 'reference' => '5843f2042cb942b9552b8995767d9a734b0258af', 'type' => 'phpstan-extension', 'install_path' => __DIR__ . '/../symplify/astral', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/autowire-array-parameter' => array('pretty_version' => '10.2.11', 'version' => '10.2.11.0', 'reference' => '42e3b884517f108e221f89815e51e2d5fc915e4d', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/autowire-array-parameter', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/composer-json-manipulator' => array('pretty_version' => '10.2.11', 'version' => '10.2.11.0', 'reference' => 'c606fa81fd41c0a43f0067d4bf5cb210cd02ffac', 'type' => 'symfony-bundle', 'install_path' => __DIR__ . '/../symplify/composer-json-manipulator', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/easy-parallel' => array('pretty_version' => '10.2.11', 'version' => '10.2.11.0', 'reference' => 'e7b801118667e8739248ae4b4649b57e7490d5b7', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/easy-parallel', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/easy-testing' => array('pretty_version' => '10.2.11', 'version' => '10.2.11.0', 'reference' => '0bbbd73c55dbd745783ad256a25ad679f74aecaa', 'type' => 'symfony-bundle', 'install_path' => __DIR__ . '/../symplify/easy-testing', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/package-builder' => array('pretty_version' => '10.2.11', 'version' => '10.2.11.0', 'reference' => 'f21028fe2918c3931b808433f7b2eb64e9108796', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/package-builder', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/rule-doc-generator-contracts' => array('pretty_version' => '10.2.11', 'version' => '10.2.11.0', 'reference' => 'bccc996527d350dc9b49194be207409401fbabe4', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/rule-doc-generator-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/skipper' => array('pretty_version' => '10.2.11', 'version' => '10.2.11.0', 'reference' => '4dd05340bd48a7700e80a34d4e3498983f99cb6b', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/skipper', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/smart-file-system' => array('pretty_version' => '10.2.11', 'version' => '10.2.11.0', 'reference' => 'dd89f04155f611f307f1bb6a8304472ab7c1680a', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/smart-file-system', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/symplify-kernel' => array('pretty_version' => '10.2.11', 'version' => '10.2.11.0', 'reference' => 'f476ff580d64e8b9f83786924713a6159637ce91', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/symplify-kernel', 'aliases' => array(), 'dev_requirement' => \false), 'tracy/tracy' => array('pretty_version' => 'v2.9.3', 'version' => '2.9.3.0', 'reference' => '3aadc88c00d7aca84ce2f07da236a703cc183d52', 'type' => 'library', 'install_path' => __DIR__ . '/../tracy/tracy', 'aliases' => array(), 'dev_requirement' => \false), 'webmozart/assert' => array('pretty_version' => '1.11.0', 'version' => '1.11.0.0', 'reference' => '11cb2199493b2f8a3b53e7f19068fc6aac760991', 'type' => 'library', 'install_path' => __DIR__ . '/../webmozart/assert', 'aliases' => array(), 'dev_requirement' => \false))); diff --git a/vendor/composer/pcre/src/PcreException.php b/vendor/composer/pcre/src/PcreException.php index bc87837864d..4e2afb6d37c 100644 --- a/vendor/composer/pcre/src/PcreException.php +++ b/vendor/composer/pcre/src/PcreException.php @@ -23,7 +23,7 @@ class PcreException extends \RuntimeException if (\is_array($pattern)) { $pattern = \implode(', ', $pattern); } - return new \RectorPrefix20220607\Composer\Pcre\PcreException($function . '(): failed executing "' . $pattern . '": ' . self::pcreLastErrorMessage($code), $code); + return new PcreException($function . '(): failed executing "' . $pattern . '": ' . self::pcreLastErrorMessage($code), $code); } /** * @param int $code diff --git a/vendor/composer/pcre/src/Preg.php b/vendor/composer/pcre/src/Preg.php index 37dc12f5b79..47f62ef93bf 100644 --- a/vendor/composer/pcre/src/Preg.php +++ b/vendor/composer/pcre/src/Preg.php @@ -29,7 +29,7 @@ class Preg } $result = \preg_match($pattern, $subject, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset); if ($result === \false) { - throw \RectorPrefix20220607\Composer\Pcre\PcreException::fromFunction('preg_match', $pattern); + throw PcreException::fromFunction('preg_match', $pattern); } return $result; } @@ -47,7 +47,7 @@ class Preg { $result = \preg_match($pattern, $subject, $matches, $flags | \PREG_UNMATCHED_AS_NULL | \PREG_OFFSET_CAPTURE, $offset); if ($result === \false) { - throw \RectorPrefix20220607\Composer\Pcre\PcreException::fromFunction('preg_match', $pattern); + throw PcreException::fromFunction('preg_match', $pattern); } return $result; } @@ -67,7 +67,7 @@ class Preg } $result = \preg_match_all($pattern, $subject, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset); if ($result === \false || $result === null) { - throw \RectorPrefix20220607\Composer\Pcre\PcreException::fromFunction('preg_match_all', $pattern); + throw PcreException::fromFunction('preg_match_all', $pattern); } return $result; } @@ -85,7 +85,7 @@ class Preg { $result = \preg_match_all($pattern, $subject, $matches, $flags | \PREG_UNMATCHED_AS_NULL | \PREG_OFFSET_CAPTURE, $offset); if ($result === \false || $result === null) { - throw \RectorPrefix20220607\Composer\Pcre\PcreException::fromFunction('preg_match_all', $pattern); + throw PcreException::fromFunction('preg_match_all', $pattern); } return $result; } @@ -105,7 +105,7 @@ class Preg } $result = \preg_replace($pattern, $replacement, $subject, $limit, $count); if ($result === null) { - throw \RectorPrefix20220607\Composer\Pcre\PcreException::fromFunction('preg_replace', $pattern); + throw PcreException::fromFunction('preg_replace', $pattern); } return $result; } @@ -125,7 +125,7 @@ class Preg } $result = \preg_replace_callback($pattern, $replacement, $subject, $limit, $count, $flags | \PREG_UNMATCHED_AS_NULL); if ($result === null) { - throw \RectorPrefix20220607\Composer\Pcre\PcreException::fromFunction('preg_replace_callback', $pattern); + throw PcreException::fromFunction('preg_replace_callback', $pattern); } return $result; } @@ -146,7 +146,7 @@ class Preg $result = \preg_replace_callback_array($pattern, $subject, $limit, $count, $flags | \PREG_UNMATCHED_AS_NULL); if ($result === null) { $pattern = \array_keys($pattern); - throw \RectorPrefix20220607\Composer\Pcre\PcreException::fromFunction('preg_replace_callback_array', $pattern); + throw PcreException::fromFunction('preg_replace_callback_array', $pattern); } return $result; } @@ -161,7 +161,7 @@ class Preg } $result = \preg_split($pattern, $subject, $limit, $flags); if ($result === \false) { - throw \RectorPrefix20220607\Composer\Pcre\PcreException::fromFunction('preg_split', $pattern); + throw PcreException::fromFunction('preg_split', $pattern); } return $result; } @@ -174,7 +174,7 @@ class Preg { $result = \preg_split($pattern, $subject, $limit, $flags | \PREG_SPLIT_OFFSET_CAPTURE); if ($result === \false) { - throw \RectorPrefix20220607\Composer\Pcre\PcreException::fromFunction('preg_split', $pattern); + throw PcreException::fromFunction('preg_split', $pattern); } return $result; } @@ -189,7 +189,7 @@ class Preg { $result = \preg_grep($pattern, $array, $flags); if ($result === \false) { - throw \RectorPrefix20220607\Composer\Pcre\PcreException::fromFunction('preg_grep', $pattern); + throw PcreException::fromFunction('preg_grep', $pattern); } return $result; } diff --git a/vendor/composer/pcre/src/Regex.php b/vendor/composer/pcre/src/Regex.php index aac0f110c0f..792abdbd4f4 100644 --- a/vendor/composer/pcre/src/Regex.php +++ b/vendor/composer/pcre/src/Regex.php @@ -17,19 +17,19 @@ class Regex */ public static function isMatch(string $pattern, string $subject, int $offset = 0) : bool { - return (bool) \RectorPrefix20220607\Composer\Pcre\Preg::match($pattern, $subject, $matches, 0, $offset); + return (bool) Preg::match($pattern, $subject, $matches, 0, $offset); } /** * @param non-empty-string $pattern * @param int $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported */ - public static function match(string $pattern, string $subject, int $flags = 0, int $offset = 0) : \RectorPrefix20220607\Composer\Pcre\MatchResult + public static function match(string $pattern, string $subject, int $flags = 0, int $offset = 0) : MatchResult { if (($flags & \PREG_OFFSET_CAPTURE) !== 0) { throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the return type, use matchWithOffsets() instead'); } - $count = \RectorPrefix20220607\Composer\Pcre\Preg::match($pattern, $subject, $matches, $flags, $offset); - return new \RectorPrefix20220607\Composer\Pcre\MatchResult($count, $matches); + $count = Preg::match($pattern, $subject, $matches, $flags, $offset); + return new MatchResult($count, $matches); } /** * Runs preg_match with PREG_OFFSET_CAPTURE @@ -37,16 +37,16 @@ class Regex * @param non-empty-string $pattern * @param int $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported */ - public static function matchWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0) : \RectorPrefix20220607\Composer\Pcre\MatchWithOffsetsResult + public static function matchWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0) : MatchWithOffsetsResult { - $count = \RectorPrefix20220607\Composer\Pcre\Preg::matchWithOffsets($pattern, $subject, $matches, $flags, $offset); - return new \RectorPrefix20220607\Composer\Pcre\MatchWithOffsetsResult($count, $matches); + $count = Preg::matchWithOffsets($pattern, $subject, $matches, $flags, $offset); + return new MatchWithOffsetsResult($count, $matches); } /** * @param non-empty-string $pattern * @param int $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported */ - public static function matchAll(string $pattern, string $subject, int $flags = 0, int $offset = 0) : \RectorPrefix20220607\Composer\Pcre\MatchAllResult + public static function matchAll(string $pattern, string $subject, int $flags = 0, int $offset = 0) : MatchAllResult { if (($flags & \PREG_OFFSET_CAPTURE) !== 0) { throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the return type, use matchAllWithOffsets() instead'); @@ -54,8 +54,8 @@ class Regex if (($flags & \PREG_SET_ORDER) !== 0) { throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the return type'); } - $count = \RectorPrefix20220607\Composer\Pcre\Preg::matchAll($pattern, $subject, $matches, $flags, $offset); - return new \RectorPrefix20220607\Composer\Pcre\MatchAllResult($count, $matches); + $count = Preg::matchAll($pattern, $subject, $matches, $flags, $offset); + return new MatchAllResult($count, $matches); } /** * Runs preg_match_all with PREG_OFFSET_CAPTURE @@ -63,39 +63,39 @@ class Regex * @param non-empty-string $pattern * @param int $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported */ - public static function matchAllWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0) : \RectorPrefix20220607\Composer\Pcre\MatchAllWithOffsetsResult + public static function matchAllWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0) : MatchAllWithOffsetsResult { - $count = \RectorPrefix20220607\Composer\Pcre\Preg::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset); - return new \RectorPrefix20220607\Composer\Pcre\MatchAllWithOffsetsResult($count, $matches); + $count = Preg::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset); + return new MatchAllWithOffsetsResult($count, $matches); } /** * @param string|string[] $pattern * @param string|string[] $replacement * @param string $subject */ - public static function replace($pattern, $replacement, $subject, int $limit = -1) : \RectorPrefix20220607\Composer\Pcre\ReplaceResult + public static function replace($pattern, $replacement, $subject, int $limit = -1) : ReplaceResult { - $result = \RectorPrefix20220607\Composer\Pcre\Preg::replace($pattern, $replacement, $subject, $limit, $count); - return new \RectorPrefix20220607\Composer\Pcre\ReplaceResult($count, $result); + $result = Preg::replace($pattern, $replacement, $subject, $limit, $count); + return new ReplaceResult($count, $result); } /** * @param string|string[] $pattern * @param string $subject * @param int $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set */ - public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, int $flags = 0) : \RectorPrefix20220607\Composer\Pcre\ReplaceResult + public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, int $flags = 0) : ReplaceResult { - $result = \RectorPrefix20220607\Composer\Pcre\Preg::replaceCallback($pattern, $replacement, $subject, $limit, $count, $flags); - return new \RectorPrefix20220607\Composer\Pcre\ReplaceResult($count, $result); + $result = Preg::replaceCallback($pattern, $replacement, $subject, $limit, $count, $flags); + return new ReplaceResult($count, $result); } /** * @param array $pattern * @param string $subject * @param int $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set */ - public static function replaceCallbackArray(array $pattern, $subject, int $limit = -1, int $flags = 0) : \RectorPrefix20220607\Composer\Pcre\ReplaceResult + public static function replaceCallbackArray(array $pattern, $subject, int $limit = -1, int $flags = 0) : ReplaceResult { - $result = \RectorPrefix20220607\Composer\Pcre\Preg::replaceCallbackArray($pattern, $subject, $limit, $count, $flags); - return new \RectorPrefix20220607\Composer\Pcre\ReplaceResult($count, $result); + $result = Preg::replaceCallbackArray($pattern, $subject, $limit, $count, $flags); + return new ReplaceResult($count, $result); } } diff --git a/vendor/composer/semver/src/Comparator.php b/vendor/composer/semver/src/Comparator.php index 36c75c6edf9..dc74f4502b2 100644 --- a/vendor/composer/semver/src/Comparator.php +++ b/vendor/composer/semver/src/Comparator.php @@ -98,7 +98,7 @@ class Comparator */ public static function compare($version1, $operator, $version2) { - $constraint = new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint($operator, $version2); - return $constraint->matchSpecific(new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('==', $version1), \true); + $constraint = new Constraint($operator, $version2); + return $constraint->matchSpecific(new Constraint('==', $version1), \true); } } diff --git a/vendor/composer/semver/src/CompilingMatcher.php b/vendor/composer/semver/src/CompilingMatcher.php index 285cc57d5f9..c9c99f9eb2e 100644 --- a/vendor/composer/semver/src/CompilingMatcher.php +++ b/vendor/composer/semver/src/CompilingMatcher.php @@ -32,7 +32,7 @@ class CompilingMatcher /** * @phpstan-var array */ - private static $transOpInt = array(\RectorPrefix20220607\Composer\Semver\Constraint\Constraint::OP_EQ => \RectorPrefix20220607\Composer\Semver\Constraint\Constraint::STR_OP_EQ, \RectorPrefix20220607\Composer\Semver\Constraint\Constraint::OP_LT => \RectorPrefix20220607\Composer\Semver\Constraint\Constraint::STR_OP_LT, \RectorPrefix20220607\Composer\Semver\Constraint\Constraint::OP_LE => \RectorPrefix20220607\Composer\Semver\Constraint\Constraint::STR_OP_LE, \RectorPrefix20220607\Composer\Semver\Constraint\Constraint::OP_GT => \RectorPrefix20220607\Composer\Semver\Constraint\Constraint::STR_OP_GT, \RectorPrefix20220607\Composer\Semver\Constraint\Constraint::OP_GE => \RectorPrefix20220607\Composer\Semver\Constraint\Constraint::STR_OP_GE, \RectorPrefix20220607\Composer\Semver\Constraint\Constraint::OP_NE => \RectorPrefix20220607\Composer\Semver\Constraint\Constraint::STR_OP_NE); + private static $transOpInt = array(Constraint::OP_EQ => Constraint::STR_OP_EQ, Constraint::OP_LT => Constraint::STR_OP_LT, Constraint::OP_LE => Constraint::STR_OP_LE, Constraint::OP_GT => Constraint::STR_OP_GT, Constraint::OP_GE => Constraint::STR_OP_GE, Constraint::OP_NE => Constraint::STR_OP_NE); /** * Clears the memoization cache once you are done * @@ -53,7 +53,7 @@ class CompilingMatcher * * @return mixed */ - public static function match(\RectorPrefix20220607\Composer\Semver\Constraint\ConstraintInterface $constraint, $operator, $version) + public static function match(ConstraintInterface $constraint, $operator, $version) { $resultCacheKey = $operator . $constraint . ';' . $version; if (isset(self::$resultCache[$resultCacheKey])) { @@ -63,7 +63,7 @@ class CompilingMatcher self::$enabled = !\in_array('eval', \explode(',', (string) \ini_get('disable_functions')), \true); } if (!self::$enabled) { - return self::$resultCache[$resultCacheKey] = $constraint->matches(new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint(self::$transOpInt[$operator], $version)); + return self::$resultCache[$resultCacheKey] = $constraint->matches(new Constraint(self::$transOpInt[$operator], $version)); } $cacheKey = $operator . $constraint; if (!isset(self::$compiledCheckerCache[$cacheKey])) { diff --git a/vendor/composer/semver/src/Constraint/Bound.php b/vendor/composer/semver/src/Constraint/Bound.php index 0fa60294c04..6eb493aadf9 100644 --- a/vendor/composer/semver/src/Constraint/Bound.php +++ b/vendor/composer/semver/src/Constraint/Bound.php @@ -65,7 +65,7 @@ class Bound * * @return bool */ - public function compareTo(\RectorPrefix20220607\Composer\Semver\Constraint\Bound $other, $operator) + public function compareTo(Bound $other, $operator) { if (!\in_array($operator, array('<', '>'), \true)) { throw new \InvalidArgumentException('Does not support any other operator other than > or <.'); @@ -91,13 +91,13 @@ class Bound */ public static function zero() { - return new \RectorPrefix20220607\Composer\Semver\Constraint\Bound('0.0.0.0-dev', \true); + return new Bound('0.0.0.0-dev', \true); } /** * @return self */ public static function positiveInfinity() { - return new \RectorPrefix20220607\Composer\Semver\Constraint\Bound(\PHP_INT_MAX . '.0.0.0', \false); + return new Bound(\PHP_INT_MAX . '.0.0.0', \false); } } diff --git a/vendor/composer/semver/src/Constraint/Constraint.php b/vendor/composer/semver/src/Constraint/Constraint.php index bbdef954a82..efd9bb83803 100644 --- a/vendor/composer/semver/src/Constraint/Constraint.php +++ b/vendor/composer/semver/src/Constraint/Constraint.php @@ -13,7 +13,7 @@ namespace RectorPrefix20220607\Composer\Semver\Constraint; /** * Defines a constraint. */ -class Constraint implements \RectorPrefix20220607\Composer\Semver\Constraint\ConstraintInterface +class Constraint implements ConstraintInterface { /* operator integer values */ const OP_EQ = 0; @@ -97,7 +97,7 @@ class Constraint implements \RectorPrefix20220607\Composer\Semver\Constraint\Con * * @return bool */ - public function matches(\RectorPrefix20220607\Composer\Semver\Constraint\ConstraintInterface $provider) + public function matches(ConstraintInterface $provider) { if ($provider instanceof self) { return $this->matchSpecific($provider); @@ -250,7 +250,7 @@ class Constraint implements \RectorPrefix20220607\Composer\Semver\Constraint\Con * * @return bool */ - public function matchSpecific(\RectorPrefix20220607\Composer\Semver\Constraint\Constraint $provider, $compareBranches = \false) + public function matchSpecific(Constraint $provider, $compareBranches = \false) { $noEqualOp = \str_replace('=', '', self::$transOpInt[$this->operator]); $providerNoEqualOp = \str_replace('=', '', self::$transOpInt[$provider->operator]); @@ -320,34 +320,34 @@ class Constraint implements \RectorPrefix20220607\Composer\Semver\Constraint\Con } // Branches if (\strpos($this->version, 'dev-') === 0) { - $this->lowerBound = \RectorPrefix20220607\Composer\Semver\Constraint\Bound::zero(); - $this->upperBound = \RectorPrefix20220607\Composer\Semver\Constraint\Bound::positiveInfinity(); + $this->lowerBound = Bound::zero(); + $this->upperBound = Bound::positiveInfinity(); return; } switch ($this->operator) { case self::OP_EQ: - $this->lowerBound = new \RectorPrefix20220607\Composer\Semver\Constraint\Bound($this->version, \true); - $this->upperBound = new \RectorPrefix20220607\Composer\Semver\Constraint\Bound($this->version, \true); + $this->lowerBound = new Bound($this->version, \true); + $this->upperBound = new Bound($this->version, \true); break; case self::OP_LT: - $this->lowerBound = \RectorPrefix20220607\Composer\Semver\Constraint\Bound::zero(); - $this->upperBound = new \RectorPrefix20220607\Composer\Semver\Constraint\Bound($this->version, \false); + $this->lowerBound = Bound::zero(); + $this->upperBound = new Bound($this->version, \false); break; case self::OP_LE: - $this->lowerBound = \RectorPrefix20220607\Composer\Semver\Constraint\Bound::zero(); - $this->upperBound = new \RectorPrefix20220607\Composer\Semver\Constraint\Bound($this->version, \true); + $this->lowerBound = Bound::zero(); + $this->upperBound = new Bound($this->version, \true); break; case self::OP_GT: - $this->lowerBound = new \RectorPrefix20220607\Composer\Semver\Constraint\Bound($this->version, \false); - $this->upperBound = \RectorPrefix20220607\Composer\Semver\Constraint\Bound::positiveInfinity(); + $this->lowerBound = new Bound($this->version, \false); + $this->upperBound = Bound::positiveInfinity(); break; case self::OP_GE: - $this->lowerBound = new \RectorPrefix20220607\Composer\Semver\Constraint\Bound($this->version, \true); - $this->upperBound = \RectorPrefix20220607\Composer\Semver\Constraint\Bound::positiveInfinity(); + $this->lowerBound = new Bound($this->version, \true); + $this->upperBound = Bound::positiveInfinity(); break; case self::OP_NE: - $this->lowerBound = \RectorPrefix20220607\Composer\Semver\Constraint\Bound::zero(); - $this->upperBound = \RectorPrefix20220607\Composer\Semver\Constraint\Bound::positiveInfinity(); + $this->lowerBound = Bound::zero(); + $this->upperBound = Bound::positiveInfinity(); break; } } diff --git a/vendor/composer/semver/src/Constraint/ConstraintInterface.php b/vendor/composer/semver/src/Constraint/ConstraintInterface.php index 60fcc75976a..8eed1f3a2c6 100644 --- a/vendor/composer/semver/src/Constraint/ConstraintInterface.php +++ b/vendor/composer/semver/src/Constraint/ConstraintInterface.php @@ -25,7 +25,7 @@ interface ConstraintInterface * * @return bool */ - public function matches(\RectorPrefix20220607\Composer\Semver\Constraint\ConstraintInterface $provider); + public function matches(ConstraintInterface $provider); /** * Provides a compiled version of the constraint for the given operator * The compiled version must be a PHP expression. diff --git a/vendor/composer/semver/src/Constraint/MatchAllConstraint.php b/vendor/composer/semver/src/Constraint/MatchAllConstraint.php index 21b30371310..ddef832990a 100644 --- a/vendor/composer/semver/src/Constraint/MatchAllConstraint.php +++ b/vendor/composer/semver/src/Constraint/MatchAllConstraint.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Composer\Semver\Constraint; * * This constraint matches everything. */ -class MatchAllConstraint implements \RectorPrefix20220607\Composer\Semver\Constraint\ConstraintInterface +class MatchAllConstraint implements ConstraintInterface { /** @var string|null */ protected $prettyString; @@ -24,7 +24,7 @@ class MatchAllConstraint implements \RectorPrefix20220607\Composer\Semver\Constr * * @return bool */ - public function matches(\RectorPrefix20220607\Composer\Semver\Constraint\ConstraintInterface $provider) + public function matches(ConstraintInterface $provider) { return \true; } @@ -64,13 +64,13 @@ class MatchAllConstraint implements \RectorPrefix20220607\Composer\Semver\Constr */ public function getUpperBound() { - return \RectorPrefix20220607\Composer\Semver\Constraint\Bound::positiveInfinity(); + return Bound::positiveInfinity(); } /** * {@inheritDoc} */ public function getLowerBound() { - return \RectorPrefix20220607\Composer\Semver\Constraint\Bound::zero(); + return Bound::zero(); } } diff --git a/vendor/composer/semver/src/Constraint/MatchNoneConstraint.php b/vendor/composer/semver/src/Constraint/MatchNoneConstraint.php index 9981a44ed8d..8fa5e7d0714 100644 --- a/vendor/composer/semver/src/Constraint/MatchNoneConstraint.php +++ b/vendor/composer/semver/src/Constraint/MatchNoneConstraint.php @@ -13,7 +13,7 @@ namespace RectorPrefix20220607\Composer\Semver\Constraint; /** * Blackhole of constraints, nothing escapes it */ -class MatchNoneConstraint implements \RectorPrefix20220607\Composer\Semver\Constraint\ConstraintInterface +class MatchNoneConstraint implements ConstraintInterface { /** @var string|null */ protected $prettyString; @@ -22,7 +22,7 @@ class MatchNoneConstraint implements \RectorPrefix20220607\Composer\Semver\Const * * @return bool */ - public function matches(\RectorPrefix20220607\Composer\Semver\Constraint\ConstraintInterface $provider) + public function matches(ConstraintInterface $provider) { return \false; } @@ -62,13 +62,13 @@ class MatchNoneConstraint implements \RectorPrefix20220607\Composer\Semver\Const */ public function getUpperBound() { - return new \RectorPrefix20220607\Composer\Semver\Constraint\Bound('0.0.0.0-dev', \false); + return new Bound('0.0.0.0-dev', \false); } /** * {@inheritDoc} */ public function getLowerBound() { - return new \RectorPrefix20220607\Composer\Semver\Constraint\Bound('0.0.0.0-dev', \false); + return new Bound('0.0.0.0-dev', \false); } } diff --git a/vendor/composer/semver/src/Constraint/MultiConstraint.php b/vendor/composer/semver/src/Constraint/MultiConstraint.php index bd044f9b91c..f1e3bbb7394 100644 --- a/vendor/composer/semver/src/Constraint/MultiConstraint.php +++ b/vendor/composer/semver/src/Constraint/MultiConstraint.php @@ -13,7 +13,7 @@ namespace RectorPrefix20220607\Composer\Semver\Constraint; /** * Defines a conjunctive or disjunctive set of constraints. */ -class MultiConstraint implements \RectorPrefix20220607\Composer\Semver\Constraint\ConstraintInterface +class MultiConstraint implements ConstraintInterface { /** * @var ConstraintInterface[] @@ -95,7 +95,7 @@ class MultiConstraint implements \RectorPrefix20220607\Composer\Semver\Constrain * * @return bool */ - public function matches(\RectorPrefix20220607\Composer\Semver\Constraint\ConstraintInterface $provider) + public function matches(ConstraintInterface $provider) { if (\false === $this->conjunctive) { foreach ($this->constraints as $constraint) { @@ -108,7 +108,7 @@ class MultiConstraint implements \RectorPrefix20220607\Composer\Semver\Constrain // when matching a conjunctive and a disjunctive multi constraint we have to iterate over the disjunctive one // otherwise we'd return true if different parts of the disjunctive constraint match the conjunctive one // which would lead to incorrect results, e.g. [>1 and <2] would match [<1 or >2] although they do not intersect - if ($provider instanceof \RectorPrefix20220607\Composer\Semver\Constraint\MultiConstraint && $provider->isDisjunctive()) { + if ($provider instanceof MultiConstraint && $provider->isDisjunctive()) { return $provider->matches($this); } foreach ($this->constraints as $constraint) { @@ -185,7 +185,7 @@ class MultiConstraint implements \RectorPrefix20220607\Composer\Semver\Constrain public static function create(array $constraints, $conjunctive = \true) { if (0 === \count($constraints)) { - return new \RectorPrefix20220607\Composer\Semver\Constraint\MatchAllConstraint(); + return new MatchAllConstraint(); } if (1 === \count($constraints)) { return $constraints[0]; @@ -219,7 +219,7 @@ class MultiConstraint implements \RectorPrefix20220607\Composer\Semver\Constrain $right = $constraints[$i]; if ($left instanceof self && $left->conjunctive && $right instanceof self && $right->conjunctive && \count($left->constraints) === 2 && \count($right->constraints) === 2 && ($left0 = (string) $left->constraints[0]) && $left0[0] === '>' && $left0[1] === '=' && ($left1 = (string) $left->constraints[1]) && $left1[0] === '<' && ($right0 = (string) $right->constraints[0]) && $right0[0] === '>' && $right0[1] === '=' && ($right1 = (string) $right->constraints[1]) && $right1[0] === '<' && \substr($left1, 2) === \substr($right0, 3)) { $optimized = \true; - $left = new \RectorPrefix20220607\Composer\Semver\Constraint\MultiConstraint(array($left->constraints[0], $right->constraints[1]), \true); + $left = new MultiConstraint(array($left->constraints[0], $right->constraints[1]), \true); } else { $mergedConstraints[] = $left; $left = $right; diff --git a/vendor/composer/semver/src/Interval.php b/vendor/composer/semver/src/Interval.php index 11193048911..1cfd2cca179 100644 --- a/vendor/composer/semver/src/Interval.php +++ b/vendor/composer/semver/src/Interval.php @@ -17,7 +17,7 @@ class Interval private $start; /** @var Constraint */ private $end; - public function __construct(\RectorPrefix20220607\Composer\Semver\Constraint\Constraint $start, \RectorPrefix20220607\Composer\Semver\Constraint\Constraint $end) + public function __construct(Constraint $start, Constraint $end) { $this->start = $start; $this->end = $end; @@ -43,7 +43,7 @@ class Interval { static $zero; if (null === $zero) { - $zero = new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('>=', '0.0.0.0-dev'); + $zero = new Constraint('>=', '0.0.0.0-dev'); } return $zero; } @@ -54,7 +54,7 @@ class Interval { static $positiveInfinity; if (null === $positiveInfinity) { - $positiveInfinity = new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('<', \PHP_INT_MAX . '.0.0.0'); + $positiveInfinity = new Constraint('<', \PHP_INT_MAX . '.0.0.0'); } return $positiveInfinity; } diff --git a/vendor/composer/semver/src/Intervals.php b/vendor/composer/semver/src/Intervals.php index 04f37c0a09f..dd24c2b84df 100644 --- a/vendor/composer/semver/src/Intervals.php +++ b/vendor/composer/semver/src/Intervals.php @@ -51,15 +51,15 @@ class Intervals * * @return bool */ - public static function isSubsetOf(\RectorPrefix20220607\Composer\Semver\Constraint\ConstraintInterface $candidate, \RectorPrefix20220607\Composer\Semver\Constraint\ConstraintInterface $constraint) + public static function isSubsetOf(ConstraintInterface $candidate, ConstraintInterface $constraint) { - if ($constraint instanceof \RectorPrefix20220607\Composer\Semver\Constraint\MatchAllConstraint) { + if ($constraint instanceof MatchAllConstraint) { return \true; } - if ($candidate instanceof \RectorPrefix20220607\Composer\Semver\Constraint\MatchNoneConstraint || $constraint instanceof \RectorPrefix20220607\Composer\Semver\Constraint\MatchNoneConstraint) { + if ($candidate instanceof MatchNoneConstraint || $constraint instanceof MatchNoneConstraint) { return \false; } - $intersectionIntervals = self::get(new \RectorPrefix20220607\Composer\Semver\Constraint\MultiConstraint(array($candidate, $constraint), \true)); + $intersectionIntervals = self::get(new MultiConstraint(array($candidate, $constraint), \true)); $candidateIntervals = self::get($candidate); if (\count($intersectionIntervals['numeric']) !== \count($candidateIntervals['numeric'])) { return \false; @@ -93,15 +93,15 @@ class Intervals * * @return bool */ - public static function haveIntersections(\RectorPrefix20220607\Composer\Semver\Constraint\ConstraintInterface $a, \RectorPrefix20220607\Composer\Semver\Constraint\ConstraintInterface $b) + public static function haveIntersections(ConstraintInterface $a, ConstraintInterface $b) { - if ($a instanceof \RectorPrefix20220607\Composer\Semver\Constraint\MatchAllConstraint || $b instanceof \RectorPrefix20220607\Composer\Semver\Constraint\MatchAllConstraint) { + if ($a instanceof MatchAllConstraint || $b instanceof MatchAllConstraint) { return \true; } - if ($a instanceof \RectorPrefix20220607\Composer\Semver\Constraint\MatchNoneConstraint || $b instanceof \RectorPrefix20220607\Composer\Semver\Constraint\MatchNoneConstraint) { + if ($a instanceof MatchNoneConstraint || $b instanceof MatchNoneConstraint) { return \false; } - $intersectionIntervals = self::generateIntervals(new \RectorPrefix20220607\Composer\Semver\Constraint\MultiConstraint(array($a, $b), \true), \true); + $intersectionIntervals = self::generateIntervals(new MultiConstraint(array($a, $b), \true), \true); return \count($intersectionIntervals['numeric']) > 0 || $intersectionIntervals['branches']['exclude'] || \count($intersectionIntervals['branches']['names']) > 0; } /** @@ -114,15 +114,15 @@ class Intervals * * @return ConstraintInterface */ - public static function compactConstraint(\RectorPrefix20220607\Composer\Semver\Constraint\ConstraintInterface $constraint) + public static function compactConstraint(ConstraintInterface $constraint) { - if (!$constraint instanceof \RectorPrefix20220607\Composer\Semver\Constraint\MultiConstraint) { + if (!$constraint instanceof MultiConstraint) { return $constraint; } $intervals = self::generateIntervals($constraint); $constraints = array(); $hasNumericMatchAll = \false; - if (\count($intervals['numeric']) === 1 && (string) $intervals['numeric'][0]->getStart() === (string) \RectorPrefix20220607\Composer\Semver\Interval::fromZero() && (string) $intervals['numeric'][0]->getEnd() === (string) \RectorPrefix20220607\Composer\Semver\Interval::untilPositiveInfinity()) { + if (\count($intervals['numeric']) === 1 && (string) $intervals['numeric'][0]->getStart() === (string) Interval::fromZero() && (string) $intervals['numeric'][0]->getEnd() === (string) Interval::untilPositiveInfinity()) { $constraints[] = $intervals['numeric'][0]->getStart(); $hasNumericMatchAll = \true; } else { @@ -139,21 +139,21 @@ class Intervals // only add a start if we didn't already do so, can be skipped if we're looking at second // interval in [>=M, N, P, =M, !=N] already and we only want to add !=P right now - if (\count($unEqualConstraints) === 0 && (string) $interval->getStart() !== (string) \RectorPrefix20220607\Composer\Semver\Interval::fromZero()) { + if (\count($unEqualConstraints) === 0 && (string) $interval->getStart() !== (string) Interval::fromZero()) { $unEqualConstraints[] = $interval->getStart(); } - $unEqualConstraints[] = new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('!=', $interval->getEnd()->getVersion()); + $unEqualConstraints[] = new Constraint('!=', $interval->getEnd()->getVersion()); continue; } } if (\count($unEqualConstraints) > 0) { // this is where the end of the following interval of a != constraint is added as explained above - if ((string) $interval->getEnd() !== (string) \RectorPrefix20220607\Composer\Semver\Interval::untilPositiveInfinity()) { + if ((string) $interval->getEnd() !== (string) Interval::untilPositiveInfinity()) { $unEqualConstraints[] = $interval->getEnd(); } // count is 1 if entire constraint is just one != expression if (\count($unEqualConstraints) > 1) { - $constraints[] = new \RectorPrefix20220607\Composer\Semver\Constraint\MultiConstraint($unEqualConstraints, \true); + $constraints[] = new MultiConstraint($unEqualConstraints, \true); } else { $constraints[] = $unEqualConstraints[0]; } @@ -162,15 +162,15 @@ class Intervals } // convert back >= x - <= x intervals to == x if ($interval->getStart()->getVersion() === $interval->getEnd()->getVersion() && $interval->getStart()->getOperator() === '>=' && $interval->getEnd()->getOperator() === '<=') { - $constraints[] = new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('==', $interval->getStart()->getVersion()); + $constraints[] = new Constraint('==', $interval->getStart()->getVersion()); continue; } - if ((string) $interval->getStart() === (string) \RectorPrefix20220607\Composer\Semver\Interval::fromZero()) { + if ((string) $interval->getStart() === (string) Interval::fromZero()) { $constraints[] = $interval->getEnd(); - } elseif ((string) $interval->getEnd() === (string) \RectorPrefix20220607\Composer\Semver\Interval::untilPositiveInfinity()) { + } elseif ((string) $interval->getEnd() === (string) Interval::untilPositiveInfinity()) { $constraints[] = $interval->getStart(); } else { - $constraints[] = new \RectorPrefix20220607\Composer\Semver\Constraint\MultiConstraint(array($interval->getStart(), $interval->getEnd()), \true); + $constraints[] = new MultiConstraint(array($interval->getStart(), $interval->getEnd()), \true); } } } @@ -178,43 +178,43 @@ class Intervals if (0 === \count($intervals['branches']['names'])) { if ($intervals['branches']['exclude']) { if ($hasNumericMatchAll) { - return new \RectorPrefix20220607\Composer\Semver\Constraint\MatchAllConstraint(); + return new MatchAllConstraint(); } // otherwise constraint should contain a != operator and already cover this } } else { foreach ($intervals['branches']['names'] as $branchName) { if ($intervals['branches']['exclude']) { - $devConstraints[] = new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('!=', $branchName); + $devConstraints[] = new Constraint('!=', $branchName); } else { - $devConstraints[] = new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('==', $branchName); + $devConstraints[] = new Constraint('==', $branchName); } } // excluded branches, e.g. != dev-foo are conjunctive with the interval, so // > 2.0 != dev-foo must return a conjunctive constraint if ($intervals['branches']['exclude']) { if (\count($constraints) > 1) { - return new \RectorPrefix20220607\Composer\Semver\Constraint\MultiConstraint(\array_merge(array(new \RectorPrefix20220607\Composer\Semver\Constraint\MultiConstraint($constraints, \false)), $devConstraints), \true); + return new MultiConstraint(\array_merge(array(new MultiConstraint($constraints, \false)), $devConstraints), \true); } - if (\count($constraints) === 1 && (string) $constraints[0] === (string) \RectorPrefix20220607\Composer\Semver\Interval::fromZero()) { + if (\count($constraints) === 1 && (string) $constraints[0] === (string) Interval::fromZero()) { if (\count($devConstraints) > 1) { - return new \RectorPrefix20220607\Composer\Semver\Constraint\MultiConstraint($devConstraints, \true); + return new MultiConstraint($devConstraints, \true); } return $devConstraints[0]; } - return new \RectorPrefix20220607\Composer\Semver\Constraint\MultiConstraint(\array_merge($constraints, $devConstraints), \true); + return new MultiConstraint(\array_merge($constraints, $devConstraints), \true); } // otherwise devConstraints contains a list of == operators for branches which are disjunctive with the // rest of the constraint $constraints = \array_merge($constraints, $devConstraints); } if (\count($constraints) > 1) { - return new \RectorPrefix20220607\Composer\Semver\Constraint\MultiConstraint($constraints, \false); + return new MultiConstraint($constraints, \false); } if (\count($constraints) === 1) { return $constraints[0]; } - return new \RectorPrefix20220607\Composer\Semver\Constraint\MatchNoneConstraint(); + return new MatchNoneConstraint(); } /** * Creates an array of numeric intervals and branch constraints representing a given constraint @@ -226,7 +226,7 @@ class Intervals * @return array * @phpstan-return array{'numeric': Interval[], 'branches': array{'names': string[], 'exclude': bool}} */ - public static function get(\RectorPrefix20220607\Composer\Semver\Constraint\ConstraintInterface $constraint) + public static function get(ConstraintInterface $constraint) { $key = (string) $constraint; if (!isset(self::$intervalsCache[$key])) { @@ -239,18 +239,18 @@ class Intervals * * @phpstan-return array{'numeric': Interval[], 'branches': array{'names': string[], 'exclude': bool}} */ - private static function generateIntervals(\RectorPrefix20220607\Composer\Semver\Constraint\ConstraintInterface $constraint, $stopOnFirstValidInterval = \false) + private static function generateIntervals(ConstraintInterface $constraint, $stopOnFirstValidInterval = \false) { - if ($constraint instanceof \RectorPrefix20220607\Composer\Semver\Constraint\MatchAllConstraint) { - return array('numeric' => array(new \RectorPrefix20220607\Composer\Semver\Interval(\RectorPrefix20220607\Composer\Semver\Interval::fromZero(), \RectorPrefix20220607\Composer\Semver\Interval::untilPositiveInfinity())), 'branches' => \RectorPrefix20220607\Composer\Semver\Interval::anyDev()); + if ($constraint instanceof MatchAllConstraint) { + return array('numeric' => array(new Interval(Interval::fromZero(), Interval::untilPositiveInfinity())), 'branches' => Interval::anyDev()); } - if ($constraint instanceof \RectorPrefix20220607\Composer\Semver\Constraint\MatchNoneConstraint) { + if ($constraint instanceof MatchNoneConstraint) { return array('numeric' => array(), 'branches' => array('names' => array(), 'exclude' => \false)); } - if ($constraint instanceof \RectorPrefix20220607\Composer\Semver\Constraint\Constraint) { + if ($constraint instanceof Constraint) { return self::generateSingleConstraintIntervals($constraint); } - if (!$constraint instanceof \RectorPrefix20220607\Composer\Semver\Constraint\MultiConstraint) { + if (!$constraint instanceof MultiConstraint) { throw new \UnexpectedValueException('The constraint passed in should be an MatchAllConstraint, Constraint or MultiConstraint instance, got ' . \get_class($constraint) . '.'); } $constraints = $constraint->getConstraints(); @@ -262,7 +262,7 @@ class Intervals $constraintBranches[] = $res['branches']; } if ($constraint->isDisjunctive()) { - $branches = \RectorPrefix20220607\Composer\Semver\Interval::noDev(); + $branches = Interval::noDev(); foreach ($constraintBranches as $b) { if ($b['exclude']) { if ($branches['exclude']) { @@ -288,7 +288,7 @@ class Intervals } } } else { - $branches = \RectorPrefix20220607\Composer\Semver\Interval::anyDev(); + $branches = Interval::anyDev(); foreach ($constraintBranches as $b) { if ($b['exclude']) { if ($branches['exclude']) { @@ -345,13 +345,13 @@ class Intervals $activeIntervals--; } if (!$start && $activeIntervals >= $activationThreshold) { - $start = new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint($border['operator'], $border['version']); + $start = new Constraint($border['operator'], $border['version']); } elseif ($start && $activeIntervals < $activationThreshold) { // filter out invalid intervals like > x - <= x, or >= x - < x if (\version_compare($start->getVersion(), $border['version'], '=') && ($start->getOperator() === '>' && $border['operator'] === '<=' || $start->getOperator() === '>=' && $border['operator'] === '<')) { unset($intervals[$index]); } else { - $intervals[$index] = new \RectorPrefix20220607\Composer\Semver\Interval($start, new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint($border['operator'], $border['version'])); + $intervals[$index] = new Interval($start, new Constraint($border['operator'], $border['version'])); $index++; if ($stopOnFirstValidInterval) { break; @@ -365,7 +365,7 @@ class Intervals /** * @phpstan-return array{'numeric': Interval[], 'branches': array{'names': string[], 'exclude': bool}} */ - private static function generateSingleConstraintIntervals(\RectorPrefix20220607\Composer\Semver\Constraint\Constraint $constraint) + private static function generateSingleConstraintIntervals(Constraint $constraint) { $op = $constraint->getOperator(); // handle branch constraints first @@ -374,7 +374,7 @@ class Intervals $branches = array('names' => array(), 'exclude' => \false); // != dev-foo means any numeric version may match, we treat >/< like != they are not really defined for branches if ($op === '!=') { - $intervals[] = new \RectorPrefix20220607\Composer\Semver\Interval(\RectorPrefix20220607\Composer\Semver\Interval::fromZero(), \RectorPrefix20220607\Composer\Semver\Interval::untilPositiveInfinity()); + $intervals[] = new Interval(Interval::fromZero(), Interval::untilPositiveInfinity()); $branches = array('names' => array($constraint->getVersion()), 'exclude' => \true); } elseif ($op === '==') { $branches['names'][] = $constraint->getVersion(); @@ -383,17 +383,17 @@ class Intervals } if ($op[0] === '>') { // > & >= - return array('numeric' => array(new \RectorPrefix20220607\Composer\Semver\Interval($constraint, \RectorPrefix20220607\Composer\Semver\Interval::untilPositiveInfinity())), 'branches' => \RectorPrefix20220607\Composer\Semver\Interval::noDev()); + return array('numeric' => array(new Interval($constraint, Interval::untilPositiveInfinity())), 'branches' => Interval::noDev()); } if ($op[0] === '<') { // < & <= - return array('numeric' => array(new \RectorPrefix20220607\Composer\Semver\Interval(\RectorPrefix20220607\Composer\Semver\Interval::fromZero(), $constraint)), 'branches' => \RectorPrefix20220607\Composer\Semver\Interval::noDev()); + return array('numeric' => array(new Interval(Interval::fromZero(), $constraint)), 'branches' => Interval::noDev()); } if ($op === '!=') { // convert !=x to intervals of 0 - x - +inf + dev* - return array('numeric' => array(new \RectorPrefix20220607\Composer\Semver\Interval(\RectorPrefix20220607\Composer\Semver\Interval::fromZero(), new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('<', $constraint->getVersion())), new \RectorPrefix20220607\Composer\Semver\Interval(new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('>', $constraint->getVersion()), \RectorPrefix20220607\Composer\Semver\Interval::untilPositiveInfinity())), 'branches' => \RectorPrefix20220607\Composer\Semver\Interval::anyDev()); + return array('numeric' => array(new Interval(Interval::fromZero(), new Constraint('<', $constraint->getVersion())), new Interval(new Constraint('>', $constraint->getVersion()), Interval::untilPositiveInfinity())), 'branches' => Interval::anyDev()); } // convert ==x to an interval of >=x - <=x - return array('numeric' => array(new \RectorPrefix20220607\Composer\Semver\Interval(new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('>=', $constraint->getVersion()), new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('<=', $constraint->getVersion()))), 'branches' => \RectorPrefix20220607\Composer\Semver\Interval::noDev()); + return array('numeric' => array(new Interval(new Constraint('>=', $constraint->getVersion()), new Constraint('<=', $constraint->getVersion()))), 'branches' => Interval::noDev()); } } diff --git a/vendor/composer/semver/src/Semver.php b/vendor/composer/semver/src/Semver.php index f686b7f6ab3..d39a6748ea7 100644 --- a/vendor/composer/semver/src/Semver.php +++ b/vendor/composer/semver/src/Semver.php @@ -28,10 +28,10 @@ class Semver public static function satisfies($version, $constraints) { if (null === self::$versionParser) { - self::$versionParser = new \RectorPrefix20220607\Composer\Semver\VersionParser(); + self::$versionParser = new VersionParser(); } $versionParser = self::$versionParser; - $provider = new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('==', $versionParser->normalize($version)); + $provider = new Constraint('==', $versionParser->normalize($version)); $parsedConstraints = $versionParser->parseConstraints($constraints); return $parsedConstraints->matches($provider); } @@ -46,7 +46,7 @@ class Semver public static function satisfiedBy(array $versions, $constraints) { $versions = \array_filter($versions, function ($version) use($constraints) { - return \RectorPrefix20220607\Composer\Semver\Semver::satisfies($version, $constraints); + return Semver::satisfies($version, $constraints); }); return \array_values($versions); } @@ -81,7 +81,7 @@ class Semver private static function usort(array $versions, $direction) { if (null === self::$versionParser) { - self::$versionParser = new \RectorPrefix20220607\Composer\Semver\VersionParser(); + self::$versionParser = new VersionParser(); } $versionParser = self::$versionParser; $normalized = array(); @@ -96,7 +96,7 @@ class Semver if ($left[0] === $right[0]) { return 0; } - if (\RectorPrefix20220607\Composer\Semver\Comparator::lessThan($left[0], $right[0])) { + if (Comparator::lessThan($left[0], $right[0])) { return -$direction; } return $direction; diff --git a/vendor/composer/semver/src/VersionParser.php b/vendor/composer/semver/src/VersionParser.php index 2ab3077a01e..39f64a023be 100644 --- a/vendor/composer/semver/src/VersionParser.php +++ b/vendor/composer/semver/src/VersionParser.php @@ -240,11 +240,11 @@ class VersionParser if (1 === \count($constraintObjects)) { $constraint = $constraintObjects[0]; } else { - $constraint = new \RectorPrefix20220607\Composer\Semver\Constraint\MultiConstraint($constraintObjects); + $constraint = new MultiConstraint($constraintObjects); } $orGroups[] = $constraint; } - $constraint = \RectorPrefix20220607\Composer\Semver\Constraint\MultiConstraint::create($orGroups, \false); + $constraint = MultiConstraint::create($orGroups, \false); $constraint->setPrettyString($prettyConstraint); return $constraint; } @@ -276,9 +276,9 @@ class VersionParser } if (\preg_match('{^(v)?[xX*](\\.[xX*])*$}i', $constraint, $match)) { if (!empty($match[1]) || !empty($match[2])) { - return array(new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('>=', '0.0.0.0-dev')); + return array(new Constraint('>=', '0.0.0.0-dev')); } - return array(new \RectorPrefix20220607\Composer\Semver\Constraint\MatchAllConstraint()); + return array(new MatchAllConstraint()); } $versionRegex = 'v?(\\d++)(?:\\.(\\d++))?(?:\\.(\\d++))?(?:\\.(\\d++))?(?:' . self::$modifierRegex . '|\\.([xX*][.-]?dev))(?:\\+[^\\s]+)?'; // Tilde Range @@ -310,12 +310,12 @@ class VersionParser $stabilitySuffix .= '-dev'; } $lowVersion = $this->normalize(\substr($constraint . $stabilitySuffix, 1)); - $lowerBound = new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('>=', $lowVersion); + $lowerBound = new Constraint('>=', $lowVersion); // For upper bound, we increment the position of one more significance, // but highPosition = 0 would be illegal $highPosition = \max(1, $position - 1); $highVersion = $this->manipulateVersionString($matches, $highPosition, 1) . '-dev'; - $upperBound = new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('<', $highVersion); + $upperBound = new Constraint('<', $highVersion); return array($lowerBound, $upperBound); } // Caret Range @@ -338,11 +338,11 @@ class VersionParser $stabilitySuffix .= '-dev'; } $lowVersion = $this->normalize(\substr($constraint . $stabilitySuffix, 1)); - $lowerBound = new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('>=', $lowVersion); + $lowerBound = new Constraint('>=', $lowVersion); // For upper bound, we increment the position of one more significance, // but highPosition = 0 would be illegal $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev'; - $upperBound = new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('<', $highVersion); + $upperBound = new Constraint('<', $highVersion); return array($lowerBound, $upperBound); } // X Range @@ -360,9 +360,9 @@ class VersionParser $lowVersion = $this->manipulateVersionString($matches, $position) . '-dev'; $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev'; if ($lowVersion === '0.0.0.0-dev') { - return array(new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('<', $highVersion)); + return array(new Constraint('<', $highVersion)); } - return array(new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('>=', $lowVersion), new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('<', $highVersion)); + return array(new Constraint('>=', $lowVersion), new Constraint('<', $highVersion)); } // Hyphen Range // @@ -377,19 +377,19 @@ class VersionParser $lowStabilitySuffix = '-dev'; } $lowVersion = $this->normalize($matches['from']); - $lowerBound = new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('>=', $lowVersion . $lowStabilitySuffix); + $lowerBound = new Constraint('>=', $lowVersion . $lowStabilitySuffix); $empty = function ($x) { return $x === 0 || $x === '0' ? \false : empty($x); }; if (!$empty($matches[12]) && !$empty($matches[13]) || !empty($matches[15]) || !empty($matches[17]) || !empty($matches[18])) { $highVersion = $this->normalize($matches['to']); - $upperBound = new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('<=', $highVersion); + $upperBound = new Constraint('<=', $highVersion); } else { $highMatch = array('', $matches[11], $matches[12], $matches[13], $matches[14]); // validate to version $this->normalize($matches['to']); $highVersion = $this->manipulateVersionString($highMatch, $empty($matches[12]) ? 1 : 2, 1) . '-dev'; - $upperBound = new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint('<', $highVersion); + $upperBound = new Constraint('<', $highVersion); } return array($lowerBound, $upperBound); } @@ -417,7 +417,7 @@ class VersionParser } } } - return array(new \RectorPrefix20220607\Composer\Semver\Constraint\Constraint($matches[1] ?: '=', $version)); + return array(new Constraint($matches[1] ?: '=', $version)); } catch (\Exception $e) { } } diff --git a/vendor/composer/xdebug-handler/src/PhpConfig.php b/vendor/composer/xdebug-handler/src/PhpConfig.php index 678593c5653..895b5112413 100644 --- a/vendor/composer/xdebug-handler/src/PhpConfig.php +++ b/vendor/composer/xdebug-handler/src/PhpConfig.php @@ -62,7 +62,7 @@ class PhpConfig */ private function getDataAndReset() : ?array { - $data = \RectorPrefix20220607\Composer\XdebugHandler\XdebugHandler::getRestartSettings(); + $data = XdebugHandler::getRestartSettings(); if ($data !== null) { $this->updateEnv('PHPRC', $data['phprc']); $this->updateEnv('PHP_INI_SCAN_DIR', $data['scanDir']); @@ -77,6 +77,6 @@ class PhpConfig */ private function updateEnv(string $name, $value) : void { - \RectorPrefix20220607\Composer\XdebugHandler\Process::setEnv($name, \false !== $value ? $value : null); + Process::setEnv($name, \false !== $value ? $value : null); } } diff --git a/vendor/composer/xdebug-handler/src/Process.php b/vendor/composer/xdebug-handler/src/Process.php index 1207dd6984f..30f087c2186 100644 --- a/vendor/composer/xdebug-handler/src/Process.php +++ b/vendor/composer/xdebug-handler/src/Process.php @@ -35,9 +35,9 @@ class Process return "'" . \str_replace("'", "'\\''", $arg) . "'"; } $quote = \strpbrk($arg, " \t") !== \false || $arg === ''; - $arg = \RectorPrefix20220607\Composer\Pcre\Preg::replace('/(\\\\*)"/', '$1$1\\"', $arg, -1, $dquotes); + $arg = Preg::replace('/(\\\\*)"/', '$1$1\\"', $arg, -1, $dquotes); if ($meta) { - $meta = $dquotes || \RectorPrefix20220607\Composer\Pcre\Preg::isMatch('/%[^%]+%/', $arg); + $meta = $dquotes || Preg::isMatch('/%[^%]+%/', $arg); if (!$meta) { $quote = $quote || \strpbrk($arg, '^&|<>()') !== \false; } elseif ($module && !$dquotes && $quote) { @@ -45,10 +45,10 @@ class Process } } if ($quote) { - $arg = '"' . \RectorPrefix20220607\Composer\Pcre\Preg::replace('/(\\\\*)$/', '$1$1', $arg) . '"'; + $arg = '"' . Preg::replace('/(\\\\*)$/', '$1$1', $arg) . '"'; } if ($meta) { - $arg = \RectorPrefix20220607\Composer\Pcre\Preg::replace('/(["^&|<>()%])/', '^$1', $arg); + $arg = Preg::replace('/(["^&|<>()%])/', '^$1', $arg); } return $arg; } diff --git a/vendor/composer/xdebug-handler/src/Status.php b/vendor/composer/xdebug-handler/src/Status.php index 975bf479830..d750379a52b 100644 --- a/vendor/composer/xdebug-handler/src/Status.php +++ b/vendor/composer/xdebug-handler/src/Status.php @@ -46,7 +46,7 @@ class Status public function __construct(string $envAllowXdebug, bool $debug) { $start = \getenv(self::ENV_RESTART); - \RectorPrefix20220607\Composer\XdebugHandler\Process::setEnv(self::ENV_RESTART); + Process::setEnv(self::ENV_RESTART); $this->time = \is_numeric($start) ? \round((\microtime(\true) - $start) * 1000) : 0; $this->envAllowXdebug = $envAllowXdebug; $this->debug = $debug && \defined('STDERR'); @@ -57,7 +57,7 @@ class Status * * @return void */ - public function setLogger(\RectorPrefix20220607\Psr\Log\LoggerInterface $logger) : void + public function setLogger(LoggerInterface $logger) : void { $this->logger = $logger; } @@ -83,7 +83,7 @@ class Status private function output(string $text, ?string $level = null) : void { if ($this->logger !== null) { - $this->logger->log($level !== null ? $level : \RectorPrefix20220607\Psr\Log\LogLevel::DEBUG, $text); + $this->logger->log($level !== null ? $level : LogLevel::DEBUG, $text); } if ($this->debug) { \fwrite(\STDERR, \sprintf('xdebug-handler[%d] %s', \getmypid(), $text . \PHP_EOL)); @@ -106,7 +106,7 @@ class Status */ private function reportError(string $error) : void { - $this->output(\sprintf('No restart (%s)', $error), \RectorPrefix20220607\Psr\Log\LogLevel::WARNING); + $this->output(\sprintf('No restart (%s)', $error), LogLevel::WARNING); } /** * Info status message @@ -135,7 +135,7 @@ class Status private function reportRestart() : void { $this->output($this->getLoadedMessage()); - \RectorPrefix20220607\Composer\XdebugHandler\Process::setEnv(self::ENV_RESTART, (string) \microtime(\true)); + Process::setEnv(self::ENV_RESTART, (string) \microtime(\true)); } /** * Restarted status message @@ -144,7 +144,7 @@ class Status { $loaded = $this->getLoadedMessage(); $text = \sprintf('Restarted (%d ms). %s', $this->time, $loaded); - $level = $this->loaded !== null ? \RectorPrefix20220607\Psr\Log\LogLevel::WARNING : null; + $level = $this->loaded !== null ? LogLevel::WARNING : null; $this->output($text, $level); } /** diff --git a/vendor/composer/xdebug-handler/src/XdebugHandler.php b/vendor/composer/xdebug-handler/src/XdebugHandler.php index 080f61823e6..c2c6cda71be 100644 --- a/vendor/composer/xdebug-handler/src/XdebugHandler.php +++ b/vendor/composer/xdebug-handler/src/XdebugHandler.php @@ -76,12 +76,12 @@ class XdebugHandler if ($this->cli = \PHP_SAPI === 'cli') { $this->debug = (string) \getenv(self::DEBUG); } - $this->statusWriter = new \RectorPrefix20220607\Composer\XdebugHandler\Status($this->envAllowXdebug, (bool) $this->debug); + $this->statusWriter = new Status($this->envAllowXdebug, (bool) $this->debug); } /** * Activates status message output to a PSR3 logger */ - public function setLogger(\RectorPrefix20220607\Psr\Log\LoggerInterface $logger) : self + public function setLogger(LoggerInterface $logger) : self { $this->statusWriter->setLogger($logger); return $this; @@ -111,11 +111,11 @@ class XdebugHandler */ public function check() : void { - $this->notify(\RectorPrefix20220607\Composer\XdebugHandler\Status::CHECK, self::$xdebugVersion . '|' . self::$xdebugMode); + $this->notify(Status::CHECK, self::$xdebugVersion . '|' . self::$xdebugMode); $envArgs = \explode('|', (string) \getenv($this->envAllowXdebug)); if (!(bool) $envArgs[0] && $this->requiresRestart(self::$xdebugActive)) { // Restart required - $this->notify(\RectorPrefix20220607\Composer\XdebugHandler\Status::RESTART); + $this->notify(Status::RESTART); if ($this->prepareRestart()) { $command = $this->getCommand(); $this->restart($command); @@ -124,8 +124,8 @@ class XdebugHandler } if (self::RESTART_ID === $envArgs[0] && \count($envArgs) === 5) { // Restarted, so unset environment variable and use saved values - $this->notify(\RectorPrefix20220607\Composer\XdebugHandler\Status::RESTARTED); - \RectorPrefix20220607\Composer\XdebugHandler\Process::setEnv($this->envAllowXdebug); + $this->notify(Status::RESTARTED); + Process::setEnv($this->envAllowXdebug); self::$inRestart = \true; if (self::$xdebugVersion === null) { // Skipped version is only set if Xdebug is not loaded @@ -136,7 +136,7 @@ class XdebugHandler $this->setEnvRestartSettings($envArgs); return; } - $this->notify(\RectorPrefix20220607\Composer\XdebugHandler\Status::NORESTART); + $this->notify(Status::NORESTART); $settings = self::getRestartSettings(); if ($settings !== null) { // Called with existing settings, so sync our settings @@ -227,11 +227,11 @@ class XdebugHandler private function doRestart(array $command) : void { $this->tryEnableSignals(); - $this->notify(\RectorPrefix20220607\Composer\XdebugHandler\Status::RESTARTING, \implode(' ', $command)); + $this->notify(Status::RESTARTING, \implode(' ', $command)); if (\PHP_VERSION_ID >= 70400) { $cmd = $command; } else { - $cmd = \RectorPrefix20220607\Composer\XdebugHandler\Process::escapeShellCommand($command); + $cmd = Process::escapeShellCommand($command); if (\defined('PHP_WINDOWS_VERSION_BUILD')) { // Outer quotes required on cmd string below PHP 8 $cmd = '"' . $cmd . '"'; @@ -243,13 +243,13 @@ class XdebugHandler } if (!isset($exitCode)) { // Unlikely that php or the default shell cannot be invoked - $this->notify(\RectorPrefix20220607\Composer\XdebugHandler\Status::ERROR, 'Unable to restart process'); + $this->notify(Status::ERROR, 'Unable to restart process'); $exitCode = -1; } else { - $this->notify(\RectorPrefix20220607\Composer\XdebugHandler\Status::INFO, 'Restarted process exited ' . $exitCode); + $this->notify(Status::INFO, 'Restarted process exited ' . $exitCode); } if ($this->debug === '2') { - $this->notify(\RectorPrefix20220607\Composer\XdebugHandler\Status::INFO, 'Temp ini saved: ' . $this->tmpIni); + $this->notify(Status::INFO, 'Temp ini saved: ' . $this->tmpIni); } else { @\unlink((string) $this->tmpIni); } @@ -281,7 +281,7 @@ class XdebugHandler $error = 'Unable to set environment variables'; } if ($error !== null) { - $this->notify(\RectorPrefix20220607\Composer\XdebugHandler\Status::ERROR, $error); + $this->notify(Status::ERROR, $error); } return $error === null; } @@ -310,10 +310,10 @@ class XdebugHandler return \false; } // Check and remove directives after HOST and PATH sections - if (\RectorPrefix20220607\Composer\Pcre\Preg::isMatchWithOffsets($sectionRegex, $data, $matches, \PREG_OFFSET_CAPTURE)) { + if (Preg::isMatchWithOffsets($sectionRegex, $data, $matches, \PREG_OFFSET_CAPTURE)) { $data = \substr($data, 0, $matches[0][1]); } - $content .= \RectorPrefix20220607\Composer\Pcre\Preg::replace($xdebugRegex, ';$1', $data) . \PHP_EOL; + $content .= Preg::replace($xdebugRegex, ';$1', $data) . \PHP_EOL; } // Merge loaded settings into our ini content, if it is valid $config = \parse_ini_string($content); @@ -424,7 +424,7 @@ class XdebugHandler private function setEnvRestartSettings(array $envArgs) : void { $settings = [\php_ini_loaded_file(), $envArgs[2], $envArgs[3], $envArgs[4], \getenv($this->envOriginalInis), self::$skipped]; - \RectorPrefix20220607\Composer\XdebugHandler\Process::setEnv(self::RESTART_SETTINGS, \implode('|', $settings)); + Process::setEnv(self::RESTART_SETTINGS, \implode('|', $settings)); } /** * Syncs settings and the environment if called with existing settings @@ -435,10 +435,10 @@ class XdebugHandler { if (\false === \getenv($this->envOriginalInis)) { // Called by another app, so make original inis available - \RectorPrefix20220607\Composer\XdebugHandler\Process::setEnv($this->envOriginalInis, \implode(\PATH_SEPARATOR, $settings['inis'])); + Process::setEnv($this->envOriginalInis, \implode(\PATH_SEPARATOR, $settings['inis'])); } self::$skipped = $settings['skipped']; - $this->notify(\RectorPrefix20220607\Composer\XdebugHandler\Status::INFO, 'Process called with existing restart settings'); + $this->notify(Status::INFO, 'Process called with existing restart settings'); } /** * Returns true if there are no known configuration issues @@ -532,7 +532,7 @@ class XdebugHandler self::$xdebugMode = $iniMode !== '' ? $iniMode : 'off'; } // An empty comma-separated list is treated as mode 'off' - if (\RectorPrefix20220607\Composer\Pcre\Preg::isMatch('/^,+$/', \str_replace(' ', '', self::$xdebugMode))) { + if (Preg::isMatch('/^,+$/', \str_replace(' ', '', self::$xdebugMode))) { self::$xdebugMode = 'off'; } self::$xdebugActive = self::$xdebugMode !== 'off'; diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/CachedWordInflector.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/CachedWordInflector.php index 708b9564bd6..481557ef945 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/CachedWordInflector.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/CachedWordInflector.php @@ -3,13 +3,13 @@ declare (strict_types=1); namespace RectorPrefix20220607\Doctrine\Inflector; -class CachedWordInflector implements \RectorPrefix20220607\Doctrine\Inflector\WordInflector +class CachedWordInflector implements WordInflector { /** @var WordInflector */ private $wordInflector; /** @var string[] */ private $cache = []; - public function __construct(\RectorPrefix20220607\Doctrine\Inflector\WordInflector $wordInflector) + public function __construct(WordInflector $wordInflector) { $this->wordInflector = $wordInflector; } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/GenericLanguageInflectorFactory.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/GenericLanguageInflectorFactory.php index 110cc9339e8..06d0595567c 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/GenericLanguageInflectorFactory.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/GenericLanguageInflectorFactory.php @@ -5,7 +5,7 @@ namespace RectorPrefix20220607\Doctrine\Inflector; use RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset; use function array_unshift; -abstract class GenericLanguageInflectorFactory implements \RectorPrefix20220607\Doctrine\Inflector\LanguageInflectorFactory +abstract class GenericLanguageInflectorFactory implements LanguageInflectorFactory { /** @var Ruleset[] */ private $singularRulesets = []; @@ -16,30 +16,30 @@ abstract class GenericLanguageInflectorFactory implements \RectorPrefix20220607\ $this->singularRulesets[] = $this->getSingularRuleset(); $this->pluralRulesets[] = $this->getPluralRuleset(); } - public final function build() : \RectorPrefix20220607\Doctrine\Inflector\Inflector + public final function build() : Inflector { - return new \RectorPrefix20220607\Doctrine\Inflector\Inflector(new \RectorPrefix20220607\Doctrine\Inflector\CachedWordInflector(new \RectorPrefix20220607\Doctrine\Inflector\RulesetInflector(...$this->singularRulesets)), new \RectorPrefix20220607\Doctrine\Inflector\CachedWordInflector(new \RectorPrefix20220607\Doctrine\Inflector\RulesetInflector(...$this->pluralRulesets))); + return new Inflector(new CachedWordInflector(new RulesetInflector(...$this->singularRulesets)), new CachedWordInflector(new RulesetInflector(...$this->pluralRulesets))); } - public final function withSingularRules(?\RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset $singularRules, bool $reset = \false) : \RectorPrefix20220607\Doctrine\Inflector\LanguageInflectorFactory + public final function withSingularRules(?Ruleset $singularRules, bool $reset = \false) : LanguageInflectorFactory { if ($reset) { $this->singularRulesets = []; } - if ($singularRules instanceof \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset) { - \array_unshift($this->singularRulesets, $singularRules); + if ($singularRules instanceof Ruleset) { + array_unshift($this->singularRulesets, $singularRules); } return $this; } - public final function withPluralRules(?\RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset $pluralRules, bool $reset = \false) : \RectorPrefix20220607\Doctrine\Inflector\LanguageInflectorFactory + public final function withPluralRules(?Ruleset $pluralRules, bool $reset = \false) : LanguageInflectorFactory { if ($reset) { $this->pluralRulesets = []; } - if ($pluralRules instanceof \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset) { - \array_unshift($this->pluralRulesets, $pluralRules); + if ($pluralRules instanceof Ruleset) { + array_unshift($this->pluralRulesets, $pluralRules); } return $this; } - protected abstract function getSingularRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset; - protected abstract function getPluralRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset; + protected abstract function getSingularRuleset() : Ruleset; + protected abstract function getPluralRuleset() : Ruleset; } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Inflector.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Inflector.php index 544202024a5..111908cea12 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Inflector.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Inflector.php @@ -25,7 +25,7 @@ class Inflector private $singularizer; /** @var WordInflector */ private $pluralizer; - public function __construct(\RectorPrefix20220607\Doctrine\Inflector\WordInflector $singularizer, \RectorPrefix20220607\Doctrine\Inflector\WordInflector $pluralizer) + public function __construct(WordInflector $singularizer, WordInflector $pluralizer) { $this->singularizer = $singularizer; $this->pluralizer = $pluralizer; @@ -35,25 +35,25 @@ class Inflector */ public function tableize(string $word) : string { - $tableized = \preg_replace('~(?<=\\w)([A-Z])~u', '_$1', $word); + $tableized = preg_replace('~(?<=\\w)([A-Z])~u', '_$1', $word); if ($tableized === null) { - throw new \RuntimeException(\sprintf('preg_replace returned null for value "%s"', $word)); + throw new RuntimeException(sprintf('preg_replace returned null for value "%s"', $word)); } - return \mb_strtolower($tableized); + return mb_strtolower($tableized); } /** * Converts a word into the format for a Doctrine class name. Converts 'table_name' to 'TableName'. */ public function classify(string $word) : string { - return \str_replace([' ', '_', '-'], '', \ucwords($word, ' _-')); + return str_replace([' ', '_', '-'], '', ucwords($word, ' _-')); } /** * Camelizes a word. This uses the classify() method and turns the first character to lowercase. */ public function camelize(string $word) : string { - return \lcfirst($this->classify($word)); + return lcfirst($this->classify($word)); } /** * Uppercases words with configurable delimiters between words. @@ -80,9 +80,9 @@ class Inflector * * @return string The string with all delimiter-separated words capitalized. */ - public function capitalize(string $string, string $delimiters = " \n\t\r\0\v-") : string + public function capitalize(string $string, string $delimiters = " \n\t\r\x00\v-") : string { - return \ucwords($string, $delimiters); + return ucwords($string, $delimiters); } /** * Checks if the given string seems like it has utf8 characters in it. @@ -91,24 +91,24 @@ class Inflector */ public function seemsUtf8(string $string) : bool { - for ($i = 0; $i < \strlen($string); $i++) { - if (\ord($string[$i]) < 0x80) { + for ($i = 0; $i < strlen($string); $i++) { + if (ord($string[$i]) < 0x80) { continue; // 0bbbbbbb } - if ((\ord($string[$i]) & 0xe0) === 0xc0) { + if ((ord($string[$i]) & 0xe0) === 0xc0) { $n = 1; // 110bbbbb - } elseif ((\ord($string[$i]) & 0xf0) === 0xe0) { + } elseif ((ord($string[$i]) & 0xf0) === 0xe0) { $n = 2; // 1110bbbb - } elseif ((\ord($string[$i]) & 0xf8) === 0xf0) { + } elseif ((ord($string[$i]) & 0xf8) === 0xf0) { $n = 3; // 11110bbb - } elseif ((\ord($string[$i]) & 0xfc) === 0xf8) { + } elseif ((ord($string[$i]) & 0xfc) === 0xf8) { $n = 4; // 111110bb - } elseif ((\ord($string[$i]) & 0xfe) === 0xfc) { + } elseif ((ord($string[$i]) & 0xfe) === 0xfc) { $n = 5; // 1111110b } else { @@ -117,7 +117,7 @@ class Inflector } for ($j = 0; $j < $n; $j++) { // n bytes matching 10bbbbbb follow ? - if (++$i === \strlen($string) || (\ord($string[$i]) & 0xc0) !== 0x80) { + if (++$i === strlen($string) || (ord($string[$i]) & 0xc0) !== 0x80) { return \false; } } @@ -133,21 +133,21 @@ class Inflector */ public function unaccent(string $string) : string { - if (\preg_match('/[\\x80-\\xff]/', $string) === \false) { + if (preg_match('/[\\x80-\\xff]/', $string) === \false) { return $string; } if ($this->seemsUtf8($string)) { - $string = \strtr($string, self::ACCENTED_CHARACTERS); + $string = strtr($string, self::ACCENTED_CHARACTERS); } else { $characters = []; // Assume ISO-8859-1 if not UTF-8 - $characters['in'] = \chr(128) . \chr(131) . \chr(138) . \chr(142) . \chr(154) . \chr(158) . \chr(159) . \chr(162) . \chr(165) . \chr(181) . \chr(192) . \chr(193) . \chr(194) . \chr(195) . \chr(196) . \chr(197) . \chr(199) . \chr(200) . \chr(201) . \chr(202) . \chr(203) . \chr(204) . \chr(205) . \chr(206) . \chr(207) . \chr(209) . \chr(210) . \chr(211) . \chr(212) . \chr(213) . \chr(214) . \chr(216) . \chr(217) . \chr(218) . \chr(219) . \chr(220) . \chr(221) . \chr(224) . \chr(225) . \chr(226) . \chr(227) . \chr(228) . \chr(229) . \chr(231) . \chr(232) . \chr(233) . \chr(234) . \chr(235) . \chr(236) . \chr(237) . \chr(238) . \chr(239) . \chr(241) . \chr(242) . \chr(243) . \chr(244) . \chr(245) . \chr(246) . \chr(248) . \chr(249) . \chr(250) . \chr(251) . \chr(252) . \chr(253) . \chr(255); + $characters['in'] = chr(128) . chr(131) . chr(138) . chr(142) . chr(154) . chr(158) . chr(159) . chr(162) . chr(165) . chr(181) . chr(192) . chr(193) . chr(194) . chr(195) . chr(196) . chr(197) . chr(199) . chr(200) . chr(201) . chr(202) . chr(203) . chr(204) . chr(205) . chr(206) . chr(207) . chr(209) . chr(210) . chr(211) . chr(212) . chr(213) . chr(214) . chr(216) . chr(217) . chr(218) . chr(219) . chr(220) . chr(221) . chr(224) . chr(225) . chr(226) . chr(227) . chr(228) . chr(229) . chr(231) . chr(232) . chr(233) . chr(234) . chr(235) . chr(236) . chr(237) . chr(238) . chr(239) . chr(241) . chr(242) . chr(243) . chr(244) . chr(245) . chr(246) . chr(248) . chr(249) . chr(250) . chr(251) . chr(252) . chr(253) . chr(255); $characters['out'] = 'EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy'; - $string = \strtr($string, $characters['in'], $characters['out']); + $string = strtr($string, $characters['in'], $characters['out']); $doubleChars = []; - $doubleChars['in'] = [\chr(140), \chr(156), \chr(198), \chr(208), \chr(222), \chr(223), \chr(230), \chr(240), \chr(254)]; + $doubleChars['in'] = [chr(140), chr(156), chr(198), chr(208), chr(222), chr(223), chr(230), chr(240), chr(254)]; $doubleChars['out'] = ['OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th']; - $string = \str_replace($doubleChars['in'], $doubleChars['out'], $string); + $string = str_replace($doubleChars['in'], $doubleChars['out'], $string); } return $string; } @@ -163,21 +163,21 @@ class Inflector { // Remove all non url friendly characters with the unaccent function $unaccented = $this->unaccent($string); - if (\function_exists('mb_strtolower')) { - $lowered = \mb_strtolower($unaccented); + if (function_exists('mb_strtolower')) { + $lowered = mb_strtolower($unaccented); } else { - $lowered = \strtolower($unaccented); + $lowered = strtolower($unaccented); } $replacements = ['/\\W/' => ' ', '/([A-Z]+)([A-Z][a-z])/' => 'RectorPrefix20220607\\1_\\2', '/([a-z\\d])([A-Z])/' => 'RectorPrefix20220607\\1_\\2', '/[^A-Z^a-z^0-9^\\/]+/' => '-']; $urlized = $lowered; foreach ($replacements as $pattern => $replacement) { - $replaced = \preg_replace($pattern, $replacement, $urlized); + $replaced = preg_replace($pattern, $replacement, $urlized); if ($replaced === null) { - throw new \RuntimeException(\sprintf('preg_replace returned null for value "%s"', $urlized)); + throw new RuntimeException(sprintf('preg_replace returned null for value "%s"', $urlized)); } $urlized = $replaced; } - return \trim($urlized, '-'); + return trim($urlized, '-'); } /** * Returns a word in singular form. diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/InflectorFactory.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/InflectorFactory.php index 83d6930eddf..655f48871b5 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/InflectorFactory.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/InflectorFactory.php @@ -13,27 +13,27 @@ use InvalidArgumentException; use function sprintf; final class InflectorFactory { - public static function create() : \RectorPrefix20220607\Doctrine\Inflector\LanguageInflectorFactory + public static function create() : LanguageInflectorFactory { - return self::createForLanguage(\RectorPrefix20220607\Doctrine\Inflector\Language::ENGLISH); + return self::createForLanguage(Language::ENGLISH); } - public static function createForLanguage(string $language) : \RectorPrefix20220607\Doctrine\Inflector\LanguageInflectorFactory + public static function createForLanguage(string $language) : LanguageInflectorFactory { switch ($language) { - case \RectorPrefix20220607\Doctrine\Inflector\Language::ENGLISH: - return new \RectorPrefix20220607\Doctrine\Inflector\Rules\English\InflectorFactory(); - case \RectorPrefix20220607\Doctrine\Inflector\Language::FRENCH: - return new \RectorPrefix20220607\Doctrine\Inflector\Rules\French\InflectorFactory(); - case \RectorPrefix20220607\Doctrine\Inflector\Language::NORWEGIAN_BOKMAL: - return new \RectorPrefix20220607\Doctrine\Inflector\Rules\NorwegianBokmal\InflectorFactory(); - case \RectorPrefix20220607\Doctrine\Inflector\Language::PORTUGUESE: - return new \RectorPrefix20220607\Doctrine\Inflector\Rules\Portuguese\InflectorFactory(); - case \RectorPrefix20220607\Doctrine\Inflector\Language::SPANISH: - return new \RectorPrefix20220607\Doctrine\Inflector\Rules\Spanish\InflectorFactory(); - case \RectorPrefix20220607\Doctrine\Inflector\Language::TURKISH: - return new \RectorPrefix20220607\Doctrine\Inflector\Rules\Turkish\InflectorFactory(); + case Language::ENGLISH: + return new English\InflectorFactory(); + case Language::FRENCH: + return new French\InflectorFactory(); + case Language::NORWEGIAN_BOKMAL: + return new NorwegianBokmal\InflectorFactory(); + case Language::PORTUGUESE: + return new Portuguese\InflectorFactory(); + case Language::SPANISH: + return new Spanish\InflectorFactory(); + case Language::TURKISH: + return new Turkish\InflectorFactory(); default: - throw new \InvalidArgumentException(\sprintf('Language "%s" is not supported.', $language)); + throw new InvalidArgumentException(sprintf('Language "%s" is not supported.', $language)); } } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/LanguageInflectorFactory.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/LanguageInflectorFactory.php index 8efa784603f..2d275114d5f 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/LanguageInflectorFactory.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/LanguageInflectorFactory.php @@ -13,7 +13,7 @@ interface LanguageInflectorFactory * * @return $this */ - public function withSingularRules(?\RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset $singularRules, bool $reset = \false) : self; + public function withSingularRules(?Ruleset $singularRules, bool $reset = \false) : self; /** * Applies custom rules for pluralisation * @@ -21,9 +21,9 @@ interface LanguageInflectorFactory * * @return $this */ - public function withPluralRules(?\RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset $pluralRules, bool $reset = \false) : self; + public function withPluralRules(?Ruleset $pluralRules, bool $reset = \false) : self; /** * Builds the inflector instance with all applicable rules */ - public function build() : \RectorPrefix20220607\Doctrine\Inflector\Inflector; + public function build() : Inflector; } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/NoopWordInflector.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/NoopWordInflector.php index d7c7515e1e7..da60b25fb6b 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/NoopWordInflector.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/NoopWordInflector.php @@ -3,7 +3,7 @@ declare (strict_types=1); namespace RectorPrefix20220607\Doctrine\Inflector; -class NoopWordInflector implements \RectorPrefix20220607\Doctrine\Inflector\WordInflector +class NoopWordInflector implements WordInflector { public function inflect(string $word) : string { diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Inflectible.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Inflectible.php index eeefa515a5f..7bb39536abb 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Inflectible.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Inflectible.php @@ -14,165 +14,165 @@ class Inflectible */ public static function getSingular() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(s)tatuses$'), 'RectorPrefix20220607\\1\\2tatus')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(s)tatus$'), 'RectorPrefix20220607\\1\\2tatus')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(c)ampus$'), 'RectorPrefix20220607\\1\\2ampus')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('^(.*)(menu)s$'), 'RectorPrefix20220607\\1\\2')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(quiz)zes$'), '\\1')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(matr)ices$'), '\\1ix')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(vert|ind)ices$'), '\\1ex')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('^(ox)en'), '\\1')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(alias)(es)*$'), '\\1')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(buffal|her|potat|tomat|volcan)oes$'), '\\1o')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|viri?)i$'), '\\1us')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('([ftw]ax)es'), '\\1')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(analys|ax|cris|test|thes)es$'), '\\1is')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(shoe|slave)s$'), '\\1')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(o)es$'), '\\1')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('ouses$'), 'ouse')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('([^a])uses$'), '\\1us')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('([m|l])ice$'), '\\1ouse')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(x|ch|ss|sh)es$'), '\\1')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(m)ovies$'), 'RectorPrefix20220607\\1\\2ovie')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(s)eries$'), 'RectorPrefix20220607\\1\\2eries')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('([^aeiouy]|qu)ies$'), '\\1y')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('([lr])ves$'), '\\1f')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(tive)s$'), '\\1')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(hive)s$'), '\\1')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(drive)s$'), '\\1')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(dive)s$'), '\\1')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(olive)s$'), '\\1')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('([^fo])ves$'), '\\1fe')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(^analy)ses$'), '\\1sis')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(analy|diagno|^ba|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$'), 'RectorPrefix20220607\\1\\2sis')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(tax)a$'), '\\1on')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(c)riteria$'), '\\1riterion')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('([ti])a$'), '\\1um')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(p)eople$'), 'RectorPrefix20220607\\1\\2erson')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(m)en$'), '\\1an')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(c)hildren$'), 'RectorPrefix20220607\\1\\2hild')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(f)eet$'), '\\1oot')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(n)ews$'), 'RectorPrefix20220607\\1\\2ews')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('eaus$'), 'eau')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('s$'), '')); + (yield new Transformation(new Pattern('(s)tatuses$'), 'RectorPrefix20220607\\1\\2tatus')); + (yield new Transformation(new Pattern('(s)tatus$'), 'RectorPrefix20220607\\1\\2tatus')); + (yield new Transformation(new Pattern('(c)ampus$'), 'RectorPrefix20220607\\1\\2ampus')); + (yield new Transformation(new Pattern('^(.*)(menu)s$'), 'RectorPrefix20220607\\1\\2')); + (yield new Transformation(new Pattern('(quiz)zes$'), '\\1')); + (yield new Transformation(new Pattern('(matr)ices$'), '\\1ix')); + (yield new Transformation(new Pattern('(vert|ind)ices$'), '\\1ex')); + (yield new Transformation(new Pattern('^(ox)en'), '\\1')); + (yield new Transformation(new Pattern('(alias)(es)*$'), '\\1')); + (yield new Transformation(new Pattern('(buffal|her|potat|tomat|volcan)oes$'), '\\1o')); + (yield new Transformation(new Pattern('(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|viri?)i$'), '\\1us')); + (yield new Transformation(new Pattern('([ftw]ax)es'), '\\1')); + (yield new Transformation(new Pattern('(analys|ax|cris|test|thes)es$'), '\\1is')); + (yield new Transformation(new Pattern('(shoe|slave)s$'), '\\1')); + (yield new Transformation(new Pattern('(o)es$'), '\\1')); + (yield new Transformation(new Pattern('ouses$'), 'ouse')); + (yield new Transformation(new Pattern('([^a])uses$'), '\\1us')); + (yield new Transformation(new Pattern('([m|l])ice$'), '\\1ouse')); + (yield new Transformation(new Pattern('(x|ch|ss|sh)es$'), '\\1')); + (yield new Transformation(new Pattern('(m)ovies$'), 'RectorPrefix20220607\\1\\2ovie')); + (yield new Transformation(new Pattern('(s)eries$'), 'RectorPrefix20220607\\1\\2eries')); + (yield new Transformation(new Pattern('([^aeiouy]|qu)ies$'), '\\1y')); + (yield new Transformation(new Pattern('([lr])ves$'), '\\1f')); + (yield new Transformation(new Pattern('(tive)s$'), '\\1')); + (yield new Transformation(new Pattern('(hive)s$'), '\\1')); + (yield new Transformation(new Pattern('(drive)s$'), '\\1')); + (yield new Transformation(new Pattern('(dive)s$'), '\\1')); + (yield new Transformation(new Pattern('(olive)s$'), '\\1')); + (yield new Transformation(new Pattern('([^fo])ves$'), '\\1fe')); + (yield new Transformation(new Pattern('(^analy)ses$'), '\\1sis')); + (yield new Transformation(new Pattern('(analy|diagno|^ba|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$'), 'RectorPrefix20220607\\1\\2sis')); + (yield new Transformation(new Pattern('(tax)a$'), '\\1on')); + (yield new Transformation(new Pattern('(c)riteria$'), '\\1riterion')); + (yield new Transformation(new Pattern('([ti])a$'), '\\1um')); + (yield new Transformation(new Pattern('(p)eople$'), 'RectorPrefix20220607\\1\\2erson')); + (yield new Transformation(new Pattern('(m)en$'), '\\1an')); + (yield new Transformation(new Pattern('(c)hildren$'), 'RectorPrefix20220607\\1\\2hild')); + (yield new Transformation(new Pattern('(f)eet$'), '\\1oot')); + (yield new Transformation(new Pattern('(n)ews$'), 'RectorPrefix20220607\\1\\2ews')); + (yield new Transformation(new Pattern('eaus$'), 'eau')); + (yield new Transformation(new Pattern('s$'), '')); } /** * @return Transformation[] */ public static function getPlural() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(s)tatus$'), 'RectorPrefix20220607\\1\\2tatuses')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(quiz)$'), '\\1zes')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('^(ox)$'), 'RectorPrefix20220607\\1\\2en')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('([m|l])ouse$'), '\\1ice')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(matr|vert|ind)(ix|ex)$'), '\\1ices')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(x|ch|ss|sh)$'), '\\1es')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('([^aeiouy]|qu)y$'), '\\1ies')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(hive|gulf)$'), '\\1s')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(?:([^f])fe|([lr])f)$'), 'RectorPrefix20220607\\1\\2ves')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('sis$'), 'ses')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('([ti])um$'), '\\1a')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(tax)on$'), '\\1a')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(c)riterion$'), '\\1riteria')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(p)erson$'), '\\1eople')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(m)an$'), '\\1en')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(c)hild$'), '\\1hildren')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(f)oot$'), '\\1eet')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(buffal|her|potat|tomat|volcan)o$'), 'RectorPrefix20220607\\1\\2oes')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|vir)us$'), '\\1i')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('us$'), 'uses')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(alias)$'), '\\1es')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('(analys|ax|cris|test|thes)is$'), '\\1es')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('s$'), 's')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('^$'), '')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('$'), 's')); + (yield new Transformation(new Pattern('(s)tatus$'), 'RectorPrefix20220607\\1\\2tatuses')); + (yield new Transformation(new Pattern('(quiz)$'), '\\1zes')); + (yield new Transformation(new Pattern('^(ox)$'), 'RectorPrefix20220607\\1\\2en')); + (yield new Transformation(new Pattern('([m|l])ouse$'), '\\1ice')); + (yield new Transformation(new Pattern('(matr|vert|ind)(ix|ex)$'), '\\1ices')); + (yield new Transformation(new Pattern('(x|ch|ss|sh)$'), '\\1es')); + (yield new Transformation(new Pattern('([^aeiouy]|qu)y$'), '\\1ies')); + (yield new Transformation(new Pattern('(hive|gulf)$'), '\\1s')); + (yield new Transformation(new Pattern('(?:([^f])fe|([lr])f)$'), 'RectorPrefix20220607\\1\\2ves')); + (yield new Transformation(new Pattern('sis$'), 'ses')); + (yield new Transformation(new Pattern('([ti])um$'), '\\1a')); + (yield new Transformation(new Pattern('(tax)on$'), '\\1a')); + (yield new Transformation(new Pattern('(c)riterion$'), '\\1riteria')); + (yield new Transformation(new Pattern('(p)erson$'), '\\1eople')); + (yield new Transformation(new Pattern('(m)an$'), '\\1en')); + (yield new Transformation(new Pattern('(c)hild$'), '\\1hildren')); + (yield new Transformation(new Pattern('(f)oot$'), '\\1eet')); + (yield new Transformation(new Pattern('(buffal|her|potat|tomat|volcan)o$'), 'RectorPrefix20220607\\1\\2oes')); + (yield new Transformation(new Pattern('(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|vir)us$'), '\\1i')); + (yield new Transformation(new Pattern('us$'), 'uses')); + (yield new Transformation(new Pattern('(alias)$'), '\\1es')); + (yield new Transformation(new Pattern('(analys|ax|cris|test|thes)is$'), '\\1es')); + (yield new Transformation(new Pattern('s$'), 's')); + (yield new Transformation(new Pattern('^$'), '')); + (yield new Transformation(new Pattern('$'), 's')); } /** * @return Substitution[] */ public static function getIrregular() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('atlas'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('atlases'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('axe'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('axes'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('beef'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('beefs'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('brother'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('brothers'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('cafe'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('cafes'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('chateau'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('chateaux'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('niveau'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('niveaux'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('child'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('children'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('canvas'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('canvases'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('cookie'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('cookies'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('corpus'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('corpuses'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('cow'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('cows'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('criterion'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('criteria'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('curriculum'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('curricula'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('demo'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('demos'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('domino'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('dominoes'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('echo'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('echoes'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('foot'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('feet'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('fungus'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('fungi'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('ganglion'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('ganglions'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('gas'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('gases'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('genie'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('genies'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('genus'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('genera'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('goose'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('geese'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('graffito'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('graffiti'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('hippopotamus'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('hippopotami'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('hoof'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('hoofs'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('human'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('humans'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('iris'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('irises'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('larva'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('larvae'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('leaf'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('leaves'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('lens'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('lenses'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('loaf'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('loaves'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('man'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('men'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('medium'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('media'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('memorandum'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('memoranda'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('money'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('monies'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('mongoose'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('mongooses'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('motto'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('mottoes'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('move'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('moves'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('mythos'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('mythoi'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('niche'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('niches'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('nucleus'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('nuclei'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('numen'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('numina'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('occiput'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('occiputs'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('octopus'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('octopuses'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('opus'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('opuses'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('ox'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('oxen'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('passerby'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('passersby'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('penis'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('penises'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('person'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('people'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('plateau'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('plateaux'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('runner-up'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('runners-up'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('safe'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('safes'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('sex'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('sexes'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('soliloquy'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('soliloquies'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('son-in-law'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('sons-in-law'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('syllabus'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('syllabi'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('testis'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('testes'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('thief'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('thieves'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('tooth'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('teeth'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('tornado'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('tornadoes'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('trilby'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('trilbys'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('turf'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('turfs'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('valve'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('valves'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('volcano'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('volcanoes'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('abuse'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('abuses'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('avalanche'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('avalanches'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('cache'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('caches'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('criterion'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('criteria'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('curve'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('curves'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('emphasis'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('emphases'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('foe'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('foes'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('grave'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('graves'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('hoax'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('hoaxes'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('medium'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('media'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('neurosis'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('neuroses'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('save'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('saves'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('wave'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('waves'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('oasis'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('oases'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('valve'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('valves'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('zombie'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('zombies'))); + (yield new Substitution(new Word('atlas'), new Word('atlases'))); + (yield new Substitution(new Word('axe'), new Word('axes'))); + (yield new Substitution(new Word('beef'), new Word('beefs'))); + (yield new Substitution(new Word('brother'), new Word('brothers'))); + (yield new Substitution(new Word('cafe'), new Word('cafes'))); + (yield new Substitution(new Word('chateau'), new Word('chateaux'))); + (yield new Substitution(new Word('niveau'), new Word('niveaux'))); + (yield new Substitution(new Word('child'), new Word('children'))); + (yield new Substitution(new Word('canvas'), new Word('canvases'))); + (yield new Substitution(new Word('cookie'), new Word('cookies'))); + (yield new Substitution(new Word('corpus'), new Word('corpuses'))); + (yield new Substitution(new Word('cow'), new Word('cows'))); + (yield new Substitution(new Word('criterion'), new Word('criteria'))); + (yield new Substitution(new Word('curriculum'), new Word('curricula'))); + (yield new Substitution(new Word('demo'), new Word('demos'))); + (yield new Substitution(new Word('domino'), new Word('dominoes'))); + (yield new Substitution(new Word('echo'), new Word('echoes'))); + (yield new Substitution(new Word('foot'), new Word('feet'))); + (yield new Substitution(new Word('fungus'), new Word('fungi'))); + (yield new Substitution(new Word('ganglion'), new Word('ganglions'))); + (yield new Substitution(new Word('gas'), new Word('gases'))); + (yield new Substitution(new Word('genie'), new Word('genies'))); + (yield new Substitution(new Word('genus'), new Word('genera'))); + (yield new Substitution(new Word('goose'), new Word('geese'))); + (yield new Substitution(new Word('graffito'), new Word('graffiti'))); + (yield new Substitution(new Word('hippopotamus'), new Word('hippopotami'))); + (yield new Substitution(new Word('hoof'), new Word('hoofs'))); + (yield new Substitution(new Word('human'), new Word('humans'))); + (yield new Substitution(new Word('iris'), new Word('irises'))); + (yield new Substitution(new Word('larva'), new Word('larvae'))); + (yield new Substitution(new Word('leaf'), new Word('leaves'))); + (yield new Substitution(new Word('lens'), new Word('lenses'))); + (yield new Substitution(new Word('loaf'), new Word('loaves'))); + (yield new Substitution(new Word('man'), new Word('men'))); + (yield new Substitution(new Word('medium'), new Word('media'))); + (yield new Substitution(new Word('memorandum'), new Word('memoranda'))); + (yield new Substitution(new Word('money'), new Word('monies'))); + (yield new Substitution(new Word('mongoose'), new Word('mongooses'))); + (yield new Substitution(new Word('motto'), new Word('mottoes'))); + (yield new Substitution(new Word('move'), new Word('moves'))); + (yield new Substitution(new Word('mythos'), new Word('mythoi'))); + (yield new Substitution(new Word('niche'), new Word('niches'))); + (yield new Substitution(new Word('nucleus'), new Word('nuclei'))); + (yield new Substitution(new Word('numen'), new Word('numina'))); + (yield new Substitution(new Word('occiput'), new Word('occiputs'))); + (yield new Substitution(new Word('octopus'), new Word('octopuses'))); + (yield new Substitution(new Word('opus'), new Word('opuses'))); + (yield new Substitution(new Word('ox'), new Word('oxen'))); + (yield new Substitution(new Word('passerby'), new Word('passersby'))); + (yield new Substitution(new Word('penis'), new Word('penises'))); + (yield new Substitution(new Word('person'), new Word('people'))); + (yield new Substitution(new Word('plateau'), new Word('plateaux'))); + (yield new Substitution(new Word('runner-up'), new Word('runners-up'))); + (yield new Substitution(new Word('safe'), new Word('safes'))); + (yield new Substitution(new Word('sex'), new Word('sexes'))); + (yield new Substitution(new Word('soliloquy'), new Word('soliloquies'))); + (yield new Substitution(new Word('son-in-law'), new Word('sons-in-law'))); + (yield new Substitution(new Word('syllabus'), new Word('syllabi'))); + (yield new Substitution(new Word('testis'), new Word('testes'))); + (yield new Substitution(new Word('thief'), new Word('thieves'))); + (yield new Substitution(new Word('tooth'), new Word('teeth'))); + (yield new Substitution(new Word('tornado'), new Word('tornadoes'))); + (yield new Substitution(new Word('trilby'), new Word('trilbys'))); + (yield new Substitution(new Word('turf'), new Word('turfs'))); + (yield new Substitution(new Word('valve'), new Word('valves'))); + (yield new Substitution(new Word('volcano'), new Word('volcanoes'))); + (yield new Substitution(new Word('abuse'), new Word('abuses'))); + (yield new Substitution(new Word('avalanche'), new Word('avalanches'))); + (yield new Substitution(new Word('cache'), new Word('caches'))); + (yield new Substitution(new Word('criterion'), new Word('criteria'))); + (yield new Substitution(new Word('curve'), new Word('curves'))); + (yield new Substitution(new Word('emphasis'), new Word('emphases'))); + (yield new Substitution(new Word('foe'), new Word('foes'))); + (yield new Substitution(new Word('grave'), new Word('graves'))); + (yield new Substitution(new Word('hoax'), new Word('hoaxes'))); + (yield new Substitution(new Word('medium'), new Word('media'))); + (yield new Substitution(new Word('neurosis'), new Word('neuroses'))); + (yield new Substitution(new Word('save'), new Word('saves'))); + (yield new Substitution(new Word('wave'), new Word('waves'))); + (yield new Substitution(new Word('oasis'), new Word('oases'))); + (yield new Substitution(new Word('valve'), new Word('valves'))); + (yield new Substitution(new Word('zombie'), new Word('zombies'))); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/InflectorFactory.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/InflectorFactory.php index 9a075f339c7..bd2c2278b07 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/InflectorFactory.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/InflectorFactory.php @@ -5,14 +5,14 @@ namespace RectorPrefix20220607\Doctrine\Inflector\Rules\English; use RectorPrefix20220607\Doctrine\Inflector\GenericLanguageInflectorFactory; use RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset; -final class InflectorFactory extends \RectorPrefix20220607\Doctrine\Inflector\GenericLanguageInflectorFactory +final class InflectorFactory extends GenericLanguageInflectorFactory { - protected function getSingularRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + protected function getSingularRuleset() : Ruleset { - return \RectorPrefix20220607\Doctrine\Inflector\Rules\English\Rules::getSingularRuleset(); + return Rules::getSingularRuleset(); } - protected function getPluralRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + protected function getPluralRuleset() : Ruleset { - return \RectorPrefix20220607\Doctrine\Inflector\Rules\English\Rules::getPluralRuleset(); + return Rules::getPluralRuleset(); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Rules.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Rules.php index ab0c5c36fe1..db4f062eb32 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Rules.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Rules.php @@ -9,12 +9,12 @@ use RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions; use RectorPrefix20220607\Doctrine\Inflector\Rules\Transformations; final class Rules { - public static function getSingularRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + public static function getSingularRuleset() : Ruleset { - return new \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformations(...\RectorPrefix20220607\Doctrine\Inflector\Rules\English\Inflectible::getSingular()), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Patterns(...\RectorPrefix20220607\Doctrine\Inflector\Rules\English\Uninflected::getSingular()), (new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions(...\RectorPrefix20220607\Doctrine\Inflector\Rules\English\Inflectible::getIrregular()))->getFlippedSubstitutions()); + return new Ruleset(new Transformations(...Inflectible::getSingular()), new Patterns(...Uninflected::getSingular()), (new Substitutions(...Inflectible::getIrregular()))->getFlippedSubstitutions()); } - public static function getPluralRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + public static function getPluralRuleset() : Ruleset { - return new \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformations(...\RectorPrefix20220607\Doctrine\Inflector\Rules\English\Inflectible::getPlural()), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Patterns(...\RectorPrefix20220607\Doctrine\Inflector\Rules\English\Uninflected::getPlural()), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions(...\RectorPrefix20220607\Doctrine\Inflector\Rules\English\Inflectible::getIrregular())); + return new Ruleset(new Transformations(...Inflectible::getPlural()), new Patterns(...Uninflected::getPlural()), new Substitutions(...Inflectible::getIrregular())); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Uninflected.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Uninflected.php index 0c3b77ebac9..6c0400d80cc 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Uninflected.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/English/Uninflected.php @@ -12,19 +12,19 @@ final class Uninflected public static function getSingular() : iterable { yield from self::getDefault(); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('.*ss')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('clothes')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('data')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('fascia')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('fuchsia')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('galleria')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('mafia')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('militia')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('pants')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('petunia')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('sepia')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('trivia')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('utopia')); + (yield new Pattern('.*ss')); + (yield new Pattern('clothes')); + (yield new Pattern('data')); + (yield new Pattern('fascia')); + (yield new Pattern('fuchsia')); + (yield new Pattern('galleria')); + (yield new Pattern('mafia')); + (yield new Pattern('militia')); + (yield new Pattern('pants')); + (yield new Pattern('petunia')); + (yield new Pattern('sepia')); + (yield new Pattern('trivia')); + (yield new Pattern('utopia')); } /** * @return Pattern[] @@ -32,156 +32,156 @@ final class Uninflected public static function getPlural() : iterable { yield from self::getDefault(); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('people')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('trivia')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('\\w+ware$')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('media')); + (yield new Pattern('people')); + (yield new Pattern('trivia')); + (yield new Pattern('\\w+ware$')); + (yield new Pattern('media')); } /** * @return Pattern[] */ private static function getDefault() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('\\w+media')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('advice')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('aircraft')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('amoyese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('art')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('audio')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('baggage')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('bison')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('borghese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('bream')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('breeches')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('britches')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('buffalo')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('butter')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('cantus')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('carp')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('chassis')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('clippers')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('clothing')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('coal')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('cod')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('coitus')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('compensation')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('congoese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('contretemps')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('coreopsis')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('corps')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('cotton')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('data')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('debris')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('deer')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('diabetes')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('djinn')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('education')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('eland')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('elk')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('emoji')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('equipment')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('evidence')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('faroese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('feedback')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('fish')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('flounder')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('flour')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('foochowese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('food')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('furniture')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('gallows')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('genevese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('genoese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('gilbertese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('gold')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('headquarters')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('herpes')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('hijinks')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('homework')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('hottentotese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('impatience')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('information')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('innings')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('jackanapes')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('jeans')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('jedi')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('kiplingese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('knowledge')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('kongoese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('leather')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('love')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('lucchese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('luggage')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('mackerel')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('Maltese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('management')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('metadata')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('mews')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('money')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('moose')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('mumps')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('music')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('nankingese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('news')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('nexus')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('niasese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('nutrition')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('offspring')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('oil')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('patience')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('pekingese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('piedmontese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('pincers')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('pistoiese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('plankton')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('pliers')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('pokemon')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('police')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('polish')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('portuguese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('proceedings')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('progress')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('rabies')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('rain')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('research')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('rhinoceros')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('rice')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('salmon')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('sand')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('sarawakese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('scissors')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('sea[- ]bass')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('series')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('shavese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('shears')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('sheep')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('siemens')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('silk')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('sms')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('soap')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('social media')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('spam')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('species')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('staff')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('sugar')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('swine')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('talent')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('toothpaste')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('traffic')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('travel')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('trousers')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('trout')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('tuna')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('us')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('vermontese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('vinegar')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('weather')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('wenchowese')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('wheat')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('whiting')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('wildebeest')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('wood')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('wool')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('yengeese')); + (yield new Pattern('\\w+media')); + (yield new Pattern('advice')); + (yield new Pattern('aircraft')); + (yield new Pattern('amoyese')); + (yield new Pattern('art')); + (yield new Pattern('audio')); + (yield new Pattern('baggage')); + (yield new Pattern('bison')); + (yield new Pattern('borghese')); + (yield new Pattern('bream')); + (yield new Pattern('breeches')); + (yield new Pattern('britches')); + (yield new Pattern('buffalo')); + (yield new Pattern('butter')); + (yield new Pattern('cantus')); + (yield new Pattern('carp')); + (yield new Pattern('chassis')); + (yield new Pattern('clippers')); + (yield new Pattern('clothing')); + (yield new Pattern('coal')); + (yield new Pattern('cod')); + (yield new Pattern('coitus')); + (yield new Pattern('compensation')); + (yield new Pattern('congoese')); + (yield new Pattern('contretemps')); + (yield new Pattern('coreopsis')); + (yield new Pattern('corps')); + (yield new Pattern('cotton')); + (yield new Pattern('data')); + (yield new Pattern('debris')); + (yield new Pattern('deer')); + (yield new Pattern('diabetes')); + (yield new Pattern('djinn')); + (yield new Pattern('education')); + (yield new Pattern('eland')); + (yield new Pattern('elk')); + (yield new Pattern('emoji')); + (yield new Pattern('equipment')); + (yield new Pattern('evidence')); + (yield new Pattern('faroese')); + (yield new Pattern('feedback')); + (yield new Pattern('fish')); + (yield new Pattern('flounder')); + (yield new Pattern('flour')); + (yield new Pattern('foochowese')); + (yield new Pattern('food')); + (yield new Pattern('furniture')); + (yield new Pattern('gallows')); + (yield new Pattern('genevese')); + (yield new Pattern('genoese')); + (yield new Pattern('gilbertese')); + (yield new Pattern('gold')); + (yield new Pattern('headquarters')); + (yield new Pattern('herpes')); + (yield new Pattern('hijinks')); + (yield new Pattern('homework')); + (yield new Pattern('hottentotese')); + (yield new Pattern('impatience')); + (yield new Pattern('information')); + (yield new Pattern('innings')); + (yield new Pattern('jackanapes')); + (yield new Pattern('jeans')); + (yield new Pattern('jedi')); + (yield new Pattern('kiplingese')); + (yield new Pattern('knowledge')); + (yield new Pattern('kongoese')); + (yield new Pattern('leather')); + (yield new Pattern('love')); + (yield new Pattern('lucchese')); + (yield new Pattern('luggage')); + (yield new Pattern('mackerel')); + (yield new Pattern('Maltese')); + (yield new Pattern('management')); + (yield new Pattern('metadata')); + (yield new Pattern('mews')); + (yield new Pattern('money')); + (yield new Pattern('moose')); + (yield new Pattern('mumps')); + (yield new Pattern('music')); + (yield new Pattern('nankingese')); + (yield new Pattern('news')); + (yield new Pattern('nexus')); + (yield new Pattern('niasese')); + (yield new Pattern('nutrition')); + (yield new Pattern('offspring')); + (yield new Pattern('oil')); + (yield new Pattern('patience')); + (yield new Pattern('pekingese')); + (yield new Pattern('piedmontese')); + (yield new Pattern('pincers')); + (yield new Pattern('pistoiese')); + (yield new Pattern('plankton')); + (yield new Pattern('pliers')); + (yield new Pattern('pokemon')); + (yield new Pattern('police')); + (yield new Pattern('polish')); + (yield new Pattern('portuguese')); + (yield new Pattern('proceedings')); + (yield new Pattern('progress')); + (yield new Pattern('rabies')); + (yield new Pattern('rain')); + (yield new Pattern('research')); + (yield new Pattern('rhinoceros')); + (yield new Pattern('rice')); + (yield new Pattern('salmon')); + (yield new Pattern('sand')); + (yield new Pattern('sarawakese')); + (yield new Pattern('scissors')); + (yield new Pattern('sea[- ]bass')); + (yield new Pattern('series')); + (yield new Pattern('shavese')); + (yield new Pattern('shears')); + (yield new Pattern('sheep')); + (yield new Pattern('siemens')); + (yield new Pattern('silk')); + (yield new Pattern('sms')); + (yield new Pattern('soap')); + (yield new Pattern('social media')); + (yield new Pattern('spam')); + (yield new Pattern('species')); + (yield new Pattern('staff')); + (yield new Pattern('sugar')); + (yield new Pattern('swine')); + (yield new Pattern('talent')); + (yield new Pattern('toothpaste')); + (yield new Pattern('traffic')); + (yield new Pattern('travel')); + (yield new Pattern('trousers')); + (yield new Pattern('trout')); + (yield new Pattern('tuna')); + (yield new Pattern('us')); + (yield new Pattern('vermontese')); + (yield new Pattern('vinegar')); + (yield new Pattern('weather')); + (yield new Pattern('wenchowese')); + (yield new Pattern('wheat')); + (yield new Pattern('whiting')); + (yield new Pattern('wildebeest')); + (yield new Pattern('wood')); + (yield new Pattern('wool')); + (yield new Pattern('yengeese')); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/Inflectible.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/Inflectible.php index e5aec989089..9c0078bd62d 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/Inflectible.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/Inflectible.php @@ -14,33 +14,33 @@ class Inflectible */ public static function getSingular() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/(b|cor|ém|gemm|soupir|trav|vant|vitr)aux$/'), '\\1ail')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/ails$/'), 'ail')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/(journ|chev)aux$/'), '\\1al')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/(bijou|caillou|chou|genou|hibou|joujou|pou|au|eu|eau)x$/'), '\\1')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/s$/'), '')); + (yield new Transformation(new Pattern('/(b|cor|ém|gemm|soupir|trav|vant|vitr)aux$/'), '\\1ail')); + (yield new Transformation(new Pattern('/ails$/'), 'ail')); + (yield new Transformation(new Pattern('/(journ|chev)aux$/'), '\\1al')); + (yield new Transformation(new Pattern('/(bijou|caillou|chou|genou|hibou|joujou|pou|au|eu|eau)x$/'), '\\1')); + (yield new Transformation(new Pattern('/s$/'), '')); } /** * @return Transformation[] */ public static function getPlural() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/(s|x|z)$/'), '\\1')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/(b|cor|ém|gemm|soupir|trav|vant|vitr)ail$/'), '\\1aux')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/ail$/'), 'ails')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/(chacal|carnaval|festival|récital)$/'), '\\1s')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/al$/'), 'aux')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/(bleu|émeu|landau|pneu|sarrau)$/'), '\\1s')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/(bijou|caillou|chou|genou|hibou|joujou|lieu|pou|au|eu|eau)$/'), '\\1x')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/$/'), 's')); + (yield new Transformation(new Pattern('/(s|x|z)$/'), '\\1')); + (yield new Transformation(new Pattern('/(b|cor|ém|gemm|soupir|trav|vant|vitr)ail$/'), '\\1aux')); + (yield new Transformation(new Pattern('/ail$/'), 'ails')); + (yield new Transformation(new Pattern('/(chacal|carnaval|festival|récital)$/'), '\\1s')); + (yield new Transformation(new Pattern('/al$/'), 'aux')); + (yield new Transformation(new Pattern('/(bleu|émeu|landau|pneu|sarrau)$/'), '\\1s')); + (yield new Transformation(new Pattern('/(bijou|caillou|chou|genou|hibou|joujou|lieu|pou|au|eu|eau)$/'), '\\1x')); + (yield new Transformation(new Pattern('/$/'), 's')); } /** * @return Substitution[] */ public static function getIrregular() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('monsieur'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('messieurs'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('madame'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('mesdames'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('mademoiselle'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('mesdemoiselles'))); + (yield new Substitution(new Word('monsieur'), new Word('messieurs'))); + (yield new Substitution(new Word('madame'), new Word('mesdames'))); + (yield new Substitution(new Word('mademoiselle'), new Word('mesdemoiselles'))); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/InflectorFactory.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/InflectorFactory.php index d5a7e0635eb..92d179a7be6 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/InflectorFactory.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/InflectorFactory.php @@ -5,14 +5,14 @@ namespace RectorPrefix20220607\Doctrine\Inflector\Rules\French; use RectorPrefix20220607\Doctrine\Inflector\GenericLanguageInflectorFactory; use RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset; -final class InflectorFactory extends \RectorPrefix20220607\Doctrine\Inflector\GenericLanguageInflectorFactory +final class InflectorFactory extends GenericLanguageInflectorFactory { - protected function getSingularRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + protected function getSingularRuleset() : Ruleset { - return \RectorPrefix20220607\Doctrine\Inflector\Rules\French\Rules::getSingularRuleset(); + return Rules::getSingularRuleset(); } - protected function getPluralRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + protected function getPluralRuleset() : Ruleset { - return \RectorPrefix20220607\Doctrine\Inflector\Rules\French\Rules::getPluralRuleset(); + return Rules::getPluralRuleset(); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/Rules.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/Rules.php index 3e54849d29d..ba7480c8677 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/Rules.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/Rules.php @@ -9,12 +9,12 @@ use RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions; use RectorPrefix20220607\Doctrine\Inflector\Rules\Transformations; final class Rules { - public static function getSingularRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + public static function getSingularRuleset() : Ruleset { - return new \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformations(...\RectorPrefix20220607\Doctrine\Inflector\Rules\French\Inflectible::getSingular()), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Patterns(...\RectorPrefix20220607\Doctrine\Inflector\Rules\French\Uninflected::getSingular()), (new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions(...\RectorPrefix20220607\Doctrine\Inflector\Rules\French\Inflectible::getIrregular()))->getFlippedSubstitutions()); + return new Ruleset(new Transformations(...Inflectible::getSingular()), new Patterns(...Uninflected::getSingular()), (new Substitutions(...Inflectible::getIrregular()))->getFlippedSubstitutions()); } - public static function getPluralRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + public static function getPluralRuleset() : Ruleset { - return new \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformations(...\RectorPrefix20220607\Doctrine\Inflector\Rules\French\Inflectible::getPlural()), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Patterns(...\RectorPrefix20220607\Doctrine\Inflector\Rules\French\Uninflected::getPlural()), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions(...\RectorPrefix20220607\Doctrine\Inflector\Rules\French\Inflectible::getIrregular())); + return new Ruleset(new Transformations(...Inflectible::getPlural()), new Patterns(...Uninflected::getPlural()), new Substitutions(...Inflectible::getIrregular())); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/Uninflected.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/Uninflected.php index df06e8f9139..f520aae7a59 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/Uninflected.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/French/Uninflected.php @@ -25,6 +25,6 @@ final class Uninflected */ private static function getDefault() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('')); + (yield new Pattern('')); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Inflectible.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Inflectible.php index 532fee17cbe..0a13b819bde 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Inflectible.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Inflectible.php @@ -14,23 +14,23 @@ class Inflectible */ public static function getSingular() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/re$/i'), 'r')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/er$/i'), '')); + (yield new Transformation(new Pattern('/re$/i'), 'r')); + (yield new Transformation(new Pattern('/er$/i'), '')); } /** * @return Transformation[] */ public static function getPlural() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/e$/i'), 'er')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/r$/i'), 're')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/$/'), 'er')); + (yield new Transformation(new Pattern('/e$/i'), 'er')); + (yield new Transformation(new Pattern('/r$/i'), 're')); + (yield new Transformation(new Pattern('/$/'), 'er')); } /** * @return Substitution[] */ public static function getIrregular() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('konto'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('konti'))); + (yield new Substitution(new Word('konto'), new Word('konti'))); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/InflectorFactory.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/InflectorFactory.php index 8767e24c25d..bdda870dfeb 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/InflectorFactory.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/InflectorFactory.php @@ -5,14 +5,14 @@ namespace RectorPrefix20220607\Doctrine\Inflector\Rules\NorwegianBokmal; use RectorPrefix20220607\Doctrine\Inflector\GenericLanguageInflectorFactory; use RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset; -final class InflectorFactory extends \RectorPrefix20220607\Doctrine\Inflector\GenericLanguageInflectorFactory +final class InflectorFactory extends GenericLanguageInflectorFactory { - protected function getSingularRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + protected function getSingularRuleset() : Ruleset { - return \RectorPrefix20220607\Doctrine\Inflector\Rules\NorwegianBokmal\Rules::getSingularRuleset(); + return Rules::getSingularRuleset(); } - protected function getPluralRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + protected function getPluralRuleset() : Ruleset { - return \RectorPrefix20220607\Doctrine\Inflector\Rules\NorwegianBokmal\Rules::getPluralRuleset(); + return Rules::getPluralRuleset(); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Rules.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Rules.php index 639b1fd2cf3..49ad1f76f5b 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Rules.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Rules.php @@ -9,12 +9,12 @@ use RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions; use RectorPrefix20220607\Doctrine\Inflector\Rules\Transformations; final class Rules { - public static function getSingularRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + public static function getSingularRuleset() : Ruleset { - return new \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformations(...\RectorPrefix20220607\Doctrine\Inflector\Rules\NorwegianBokmal\Inflectible::getSingular()), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Patterns(...\RectorPrefix20220607\Doctrine\Inflector\Rules\NorwegianBokmal\Uninflected::getSingular()), (new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions(...\RectorPrefix20220607\Doctrine\Inflector\Rules\NorwegianBokmal\Inflectible::getIrregular()))->getFlippedSubstitutions()); + return new Ruleset(new Transformations(...Inflectible::getSingular()), new Patterns(...Uninflected::getSingular()), (new Substitutions(...Inflectible::getIrregular()))->getFlippedSubstitutions()); } - public static function getPluralRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + public static function getPluralRuleset() : Ruleset { - return new \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformations(...\RectorPrefix20220607\Doctrine\Inflector\Rules\NorwegianBokmal\Inflectible::getPlural()), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Patterns(...\RectorPrefix20220607\Doctrine\Inflector\Rules\NorwegianBokmal\Uninflected::getPlural()), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions(...\RectorPrefix20220607\Doctrine\Inflector\Rules\NorwegianBokmal\Inflectible::getIrregular())); + return new Ruleset(new Transformations(...Inflectible::getPlural()), new Patterns(...Uninflected::getPlural()), new Substitutions(...Inflectible::getIrregular())); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Uninflected.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Uninflected.php index f0ae7aaef38..2d9f14ef964 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Uninflected.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Uninflected.php @@ -25,8 +25,8 @@ final class Uninflected */ private static function getDefault() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('barn')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('fjell')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('hus')); + (yield new Pattern('barn')); + (yield new Pattern('fjell')); + (yield new Pattern('hus')); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Pattern.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Pattern.php index cb0fe035597..f69caa1ec7f 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Pattern.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Pattern.php @@ -29,6 +29,6 @@ final class Pattern } public function matches(string $word) : bool { - return \preg_match($this->getRegex(), $word) === 1; + return preg_match($this->getRegex(), $word) === 1; } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Patterns.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Patterns.php index 1568d3d45a2..f74f94629e4 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Patterns.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Patterns.php @@ -12,16 +12,16 @@ class Patterns private $patterns; /** @var string */ private $regex; - public function __construct(\RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern ...$patterns) + public function __construct(Pattern ...$patterns) { $this->patterns = $patterns; - $patterns = \array_map(static function (\RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern $pattern) : string { + $patterns = array_map(static function (Pattern $pattern) : string { return $pattern->getPattern(); }, $this->patterns); - $this->regex = '/^(?:' . \implode('|', $patterns) . ')$/i'; + $this->regex = '/^(?:' . implode('|', $patterns) . ')$/i'; } public function matches(string $word) : bool { - return \preg_match($this->regex, $word, $regs) === 1; + return preg_match($this->regex, $word, $regs) === 1; } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/Inflectible.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/Inflectible.php index dc2261620a8..05618a95b32 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/Inflectible.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/Inflectible.php @@ -14,87 +14,87 @@ class Inflectible */ public static function getSingular() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/^(g|)ases$/i'), '\\1ás')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/(japon|escoc|ingl|dinamarqu|fregu|portugu)eses$/i'), '\\1ês')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/(ae|ao|oe)s$/'), 'ao')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/(ãe|ão|õe)s$/'), 'ão')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/^(.*[^s]s)es$/i'), '\\1')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/sses$/i'), 'sse')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/ns$/i'), 'm')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/(r|t|f|v)is$/i'), '\\1il')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/uis$/i'), 'ul')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/ois$/i'), 'ol')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/eis$/i'), 'ei')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/éis$/i'), 'el')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/([^p])ais$/i'), '\\1al')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/(r|z)es$/i'), '\\1')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/^(á|gá)s$/i'), '\\1s')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/([^ê])s$/i'), '\\1')); + (yield new Transformation(new Pattern('/^(g|)ases$/i'), '\\1ás')); + (yield new Transformation(new Pattern('/(japon|escoc|ingl|dinamarqu|fregu|portugu)eses$/i'), '\\1ês')); + (yield new Transformation(new Pattern('/(ae|ao|oe)s$/'), 'ao')); + (yield new Transformation(new Pattern('/(ãe|ão|õe)s$/'), 'ão')); + (yield new Transformation(new Pattern('/^(.*[^s]s)es$/i'), '\\1')); + (yield new Transformation(new Pattern('/sses$/i'), 'sse')); + (yield new Transformation(new Pattern('/ns$/i'), 'm')); + (yield new Transformation(new Pattern('/(r|t|f|v)is$/i'), '\\1il')); + (yield new Transformation(new Pattern('/uis$/i'), 'ul')); + (yield new Transformation(new Pattern('/ois$/i'), 'ol')); + (yield new Transformation(new Pattern('/eis$/i'), 'ei')); + (yield new Transformation(new Pattern('/éis$/i'), 'el')); + (yield new Transformation(new Pattern('/([^p])ais$/i'), '\\1al')); + (yield new Transformation(new Pattern('/(r|z)es$/i'), '\\1')); + (yield new Transformation(new Pattern('/^(á|gá)s$/i'), '\\1s')); + (yield new Transformation(new Pattern('/([^ê])s$/i'), '\\1')); } /** * @return Transformation[] */ public static function getPlural() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/^(alem|c|p)ao$/i'), '\\1aes')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/^(irm|m)ao$/i'), '\\1aos')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/ao$/i'), 'oes')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/^(alem|c|p)ão$/i'), '\\1ães')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/^(irm|m)ão$/i'), '\\1ãos')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/ão$/i'), 'ões')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/^(|g)ás$/i'), '\\1ases')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/^(japon|escoc|ingl|dinamarqu|fregu|portugu)ês$/i'), '\\1eses')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/m$/i'), 'ns')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/([^aeou])il$/i'), '\\1is')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/ul$/i'), 'uis')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/ol$/i'), 'ois')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/el$/i'), 'eis')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/al$/i'), 'ais')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/(z|r)$/i'), '\\1es')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/(s)$/i'), '\\1')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/$/'), 's')); + (yield new Transformation(new Pattern('/^(alem|c|p)ao$/i'), '\\1aes')); + (yield new Transformation(new Pattern('/^(irm|m)ao$/i'), '\\1aos')); + (yield new Transformation(new Pattern('/ao$/i'), 'oes')); + (yield new Transformation(new Pattern('/^(alem|c|p)ão$/i'), '\\1ães')); + (yield new Transformation(new Pattern('/^(irm|m)ão$/i'), '\\1ãos')); + (yield new Transformation(new Pattern('/ão$/i'), 'ões')); + (yield new Transformation(new Pattern('/^(|g)ás$/i'), '\\1ases')); + (yield new Transformation(new Pattern('/^(japon|escoc|ingl|dinamarqu|fregu|portugu)ês$/i'), '\\1eses')); + (yield new Transformation(new Pattern('/m$/i'), 'ns')); + (yield new Transformation(new Pattern('/([^aeou])il$/i'), '\\1is')); + (yield new Transformation(new Pattern('/ul$/i'), 'uis')); + (yield new Transformation(new Pattern('/ol$/i'), 'ois')); + (yield new Transformation(new Pattern('/el$/i'), 'eis')); + (yield new Transformation(new Pattern('/al$/i'), 'ais')); + (yield new Transformation(new Pattern('/(z|r)$/i'), '\\1es')); + (yield new Transformation(new Pattern('/(s)$/i'), '\\1')); + (yield new Transformation(new Pattern('/$/'), 's')); } /** * @return Substitution[] */ public static function getIrregular() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('abdomen'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('abdomens'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('alemão'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('alemães'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('artesã'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('artesãos'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('álcool'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('álcoois'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('árvore'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('árvores'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('bencão'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('bencãos'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('cão'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('cães'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('campus'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('campi'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('cadáver'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('cadáveres'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('capelão'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('capelães'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('capitão'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('capitães'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('chão'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('chãos'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('charlatão'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('charlatães'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('cidadão'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('cidadãos'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('consul'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('consules'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('cristão'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('cristãos'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('difícil'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('difíceis'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('email'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('emails'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('escrivão'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('escrivães'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('fóssil'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('fósseis'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('gás'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('gases'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('germens'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('germen'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('grão'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('grãos'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('hífen'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('hífens'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('irmão'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('irmãos'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('liquens'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('liquen'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('mal'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('males'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('mão'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('mãos'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('orfão'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('orfãos'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('país'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('países'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('pai'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('pais'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('pão'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('pães'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('projétil'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('projéteis'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('réptil'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('répteis'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('sacristão'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('sacristães'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('sotão'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('sotãos'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('tabelião'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('tabeliães'))); + (yield new Substitution(new Word('abdomen'), new Word('abdomens'))); + (yield new Substitution(new Word('alemão'), new Word('alemães'))); + (yield new Substitution(new Word('artesã'), new Word('artesãos'))); + (yield new Substitution(new Word('álcool'), new Word('álcoois'))); + (yield new Substitution(new Word('árvore'), new Word('árvores'))); + (yield new Substitution(new Word('bencão'), new Word('bencãos'))); + (yield new Substitution(new Word('cão'), new Word('cães'))); + (yield new Substitution(new Word('campus'), new Word('campi'))); + (yield new Substitution(new Word('cadáver'), new Word('cadáveres'))); + (yield new Substitution(new Word('capelão'), new Word('capelães'))); + (yield new Substitution(new Word('capitão'), new Word('capitães'))); + (yield new Substitution(new Word('chão'), new Word('chãos'))); + (yield new Substitution(new Word('charlatão'), new Word('charlatães'))); + (yield new Substitution(new Word('cidadão'), new Word('cidadãos'))); + (yield new Substitution(new Word('consul'), new Word('consules'))); + (yield new Substitution(new Word('cristão'), new Word('cristãos'))); + (yield new Substitution(new Word('difícil'), new Word('difíceis'))); + (yield new Substitution(new Word('email'), new Word('emails'))); + (yield new Substitution(new Word('escrivão'), new Word('escrivães'))); + (yield new Substitution(new Word('fóssil'), new Word('fósseis'))); + (yield new Substitution(new Word('gás'), new Word('gases'))); + (yield new Substitution(new Word('germens'), new Word('germen'))); + (yield new Substitution(new Word('grão'), new Word('grãos'))); + (yield new Substitution(new Word('hífen'), new Word('hífens'))); + (yield new Substitution(new Word('irmão'), new Word('irmãos'))); + (yield new Substitution(new Word('liquens'), new Word('liquen'))); + (yield new Substitution(new Word('mal'), new Word('males'))); + (yield new Substitution(new Word('mão'), new Word('mãos'))); + (yield new Substitution(new Word('orfão'), new Word('orfãos'))); + (yield new Substitution(new Word('país'), new Word('países'))); + (yield new Substitution(new Word('pai'), new Word('pais'))); + (yield new Substitution(new Word('pão'), new Word('pães'))); + (yield new Substitution(new Word('projétil'), new Word('projéteis'))); + (yield new Substitution(new Word('réptil'), new Word('répteis'))); + (yield new Substitution(new Word('sacristão'), new Word('sacristães'))); + (yield new Substitution(new Word('sotão'), new Word('sotãos'))); + (yield new Substitution(new Word('tabelião'), new Word('tabeliães'))); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/InflectorFactory.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/InflectorFactory.php index 754ac0d2233..184e894fce7 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/InflectorFactory.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/InflectorFactory.php @@ -5,14 +5,14 @@ namespace RectorPrefix20220607\Doctrine\Inflector\Rules\Portuguese; use RectorPrefix20220607\Doctrine\Inflector\GenericLanguageInflectorFactory; use RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset; -final class InflectorFactory extends \RectorPrefix20220607\Doctrine\Inflector\GenericLanguageInflectorFactory +final class InflectorFactory extends GenericLanguageInflectorFactory { - protected function getSingularRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + protected function getSingularRuleset() : Ruleset { - return \RectorPrefix20220607\Doctrine\Inflector\Rules\Portuguese\Rules::getSingularRuleset(); + return Rules::getSingularRuleset(); } - protected function getPluralRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + protected function getPluralRuleset() : Ruleset { - return \RectorPrefix20220607\Doctrine\Inflector\Rules\Portuguese\Rules::getPluralRuleset(); + return Rules::getPluralRuleset(); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/Rules.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/Rules.php index 59a6beb0f77..f4ca0f0a28c 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/Rules.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/Rules.php @@ -9,12 +9,12 @@ use RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions; use RectorPrefix20220607\Doctrine\Inflector\Rules\Transformations; final class Rules { - public static function getSingularRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + public static function getSingularRuleset() : Ruleset { - return new \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformations(...\RectorPrefix20220607\Doctrine\Inflector\Rules\Portuguese\Inflectible::getSingular()), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Patterns(...\RectorPrefix20220607\Doctrine\Inflector\Rules\Portuguese\Uninflected::getSingular()), (new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions(...\RectorPrefix20220607\Doctrine\Inflector\Rules\Portuguese\Inflectible::getIrregular()))->getFlippedSubstitutions()); + return new Ruleset(new Transformations(...Inflectible::getSingular()), new Patterns(...Uninflected::getSingular()), (new Substitutions(...Inflectible::getIrregular()))->getFlippedSubstitutions()); } - public static function getPluralRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + public static function getPluralRuleset() : Ruleset { - return new \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformations(...\RectorPrefix20220607\Doctrine\Inflector\Rules\Portuguese\Inflectible::getPlural()), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Patterns(...\RectorPrefix20220607\Doctrine\Inflector\Rules\Portuguese\Uninflected::getPlural()), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions(...\RectorPrefix20220607\Doctrine\Inflector\Rules\Portuguese\Inflectible::getIrregular())); + return new Ruleset(new Transformations(...Inflectible::getPlural()), new Patterns(...Uninflected::getPlural()), new Substitutions(...Inflectible::getIrregular())); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/Uninflected.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/Uninflected.php index 83d6c82c1fc..d0708614f78 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/Uninflected.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Portuguese/Uninflected.php @@ -25,10 +25,10 @@ final class Uninflected */ private static function getDefault() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('tórax')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('tênis')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('ônibus')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('lápis')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('fênix')); + (yield new Pattern('tórax')); + (yield new Pattern('tênis')); + (yield new Pattern('ônibus')); + (yield new Pattern('lápis')); + (yield new Pattern('fênix')); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Ruleset.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Ruleset.php index 9a2d2d00107..0f8ef3cf867 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Ruleset.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Ruleset.php @@ -11,21 +11,21 @@ class Ruleset private $uninflected; /** @var Substitutions */ private $irregular; - public function __construct(\RectorPrefix20220607\Doctrine\Inflector\Rules\Transformations $regular, \RectorPrefix20220607\Doctrine\Inflector\Rules\Patterns $uninflected, \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions $irregular) + public function __construct(Transformations $regular, Patterns $uninflected, Substitutions $irregular) { $this->regular = $regular; $this->uninflected = $uninflected; $this->irregular = $irregular; } - public function getRegular() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformations + public function getRegular() : Transformations { return $this->regular; } - public function getUninflected() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Patterns + public function getUninflected() : Patterns { return $this->uninflected; } - public function getIrregular() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions + public function getIrregular() : Substitutions { return $this->irregular; } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/Inflectible.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/Inflectible.php index ccb4ae7d69c..512a4614bf3 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/Inflectible.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/Inflectible.php @@ -14,36 +14,36 @@ class Inflectible */ public static function getSingular() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/ereses$/'), 'erés')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/iones$/'), 'ión')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/ces$/'), 'z')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/es$/'), '')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/s$/'), '')); + (yield new Transformation(new Pattern('/ereses$/'), 'erés')); + (yield new Transformation(new Pattern('/iones$/'), 'ión')); + (yield new Transformation(new Pattern('/ces$/'), 'z')); + (yield new Transformation(new Pattern('/es$/'), '')); + (yield new Transformation(new Pattern('/s$/'), '')); } /** * @return Transformation[] */ public static function getPlural() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/ú([sn])$/i'), 'RectorPrefix20220607\\u\\1es')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/ó([sn])$/i'), 'RectorPrefix20220607\\o\\1es')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/í([sn])$/i'), 'RectorPrefix20220607\\i\\1es')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/é([sn])$/i'), 'RectorPrefix20220607\\e\\1es')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/á([sn])$/i'), 'RectorPrefix20220607\\a\\1es')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/z$/i'), 'ces')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/([aeiou]s)$/i'), '\\1')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/([^aeéiou])$/i'), '\\1es')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/$/'), 's')); + (yield new Transformation(new Pattern('/ú([sn])$/i'), 'RectorPrefix20220607\\u\\1es')); + (yield new Transformation(new Pattern('/ó([sn])$/i'), 'RectorPrefix20220607\\o\\1es')); + (yield new Transformation(new Pattern('/í([sn])$/i'), 'RectorPrefix20220607\\i\\1es')); + (yield new Transformation(new Pattern('/é([sn])$/i'), 'RectorPrefix20220607\\e\\1es')); + (yield new Transformation(new Pattern('/á([sn])$/i'), 'RectorPrefix20220607\\a\\1es')); + (yield new Transformation(new Pattern('/z$/i'), 'ces')); + (yield new Transformation(new Pattern('/([aeiou]s)$/i'), '\\1')); + (yield new Transformation(new Pattern('/([^aeéiou])$/i'), '\\1es')); + (yield new Transformation(new Pattern('/$/'), 's')); } /** * @return Substitution[] */ public static function getIrregular() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('el'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('los'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('papá'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('papás'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('mamá'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('mamás'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('sofá'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('sofás'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('mes'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('meses'))); + (yield new Substitution(new Word('el'), new Word('los'))); + (yield new Substitution(new Word('papá'), new Word('papás'))); + (yield new Substitution(new Word('mamá'), new Word('mamás'))); + (yield new Substitution(new Word('sofá'), new Word('sofás'))); + (yield new Substitution(new Word('mes'), new Word('meses'))); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/InflectorFactory.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/InflectorFactory.php index b72dfba1ea6..30dcbcda0e4 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/InflectorFactory.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/InflectorFactory.php @@ -5,14 +5,14 @@ namespace RectorPrefix20220607\Doctrine\Inflector\Rules\Spanish; use RectorPrefix20220607\Doctrine\Inflector\GenericLanguageInflectorFactory; use RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset; -final class InflectorFactory extends \RectorPrefix20220607\Doctrine\Inflector\GenericLanguageInflectorFactory +final class InflectorFactory extends GenericLanguageInflectorFactory { - protected function getSingularRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + protected function getSingularRuleset() : Ruleset { - return \RectorPrefix20220607\Doctrine\Inflector\Rules\Spanish\Rules::getSingularRuleset(); + return Rules::getSingularRuleset(); } - protected function getPluralRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + protected function getPluralRuleset() : Ruleset { - return \RectorPrefix20220607\Doctrine\Inflector\Rules\Spanish\Rules::getPluralRuleset(); + return Rules::getPluralRuleset(); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/Rules.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/Rules.php index 50303954702..85eb070df39 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/Rules.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/Rules.php @@ -9,12 +9,12 @@ use RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions; use RectorPrefix20220607\Doctrine\Inflector\Rules\Transformations; final class Rules { - public static function getSingularRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + public static function getSingularRuleset() : Ruleset { - return new \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformations(...\RectorPrefix20220607\Doctrine\Inflector\Rules\Spanish\Inflectible::getSingular()), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Patterns(...\RectorPrefix20220607\Doctrine\Inflector\Rules\Spanish\Uninflected::getSingular()), (new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions(...\RectorPrefix20220607\Doctrine\Inflector\Rules\Spanish\Inflectible::getIrregular()))->getFlippedSubstitutions()); + return new Ruleset(new Transformations(...Inflectible::getSingular()), new Patterns(...Uninflected::getSingular()), (new Substitutions(...Inflectible::getIrregular()))->getFlippedSubstitutions()); } - public static function getPluralRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + public static function getPluralRuleset() : Ruleset { - return new \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformations(...\RectorPrefix20220607\Doctrine\Inflector\Rules\Spanish\Inflectible::getPlural()), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Patterns(...\RectorPrefix20220607\Doctrine\Inflector\Rules\Spanish\Uninflected::getPlural()), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions(...\RectorPrefix20220607\Doctrine\Inflector\Rules\Spanish\Inflectible::getIrregular())); + return new Ruleset(new Transformations(...Inflectible::getPlural()), new Patterns(...Uninflected::getPlural()), new Substitutions(...Inflectible::getIrregular())); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/Uninflected.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/Uninflected.php index f984d7d341d..6d894ef86bb 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/Uninflected.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Spanish/Uninflected.php @@ -25,8 +25,8 @@ final class Uninflected */ private static function getDefault() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('lunes')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('rompecabezas')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('crisis')); + (yield new Pattern('lunes')); + (yield new Pattern('rompecabezas')); + (yield new Pattern('crisis')); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Substitution.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Substitution.php index 1a6ea32c3a4..a4cbc1576b3 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Substitution.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Substitution.php @@ -9,16 +9,16 @@ final class Substitution private $from; /** @var Word */ private $to; - public function __construct(\RectorPrefix20220607\Doctrine\Inflector\Rules\Word $from, \RectorPrefix20220607\Doctrine\Inflector\Rules\Word $to) + public function __construct(Word $from, Word $to) { $this->from = $from; $this->to = $to; } - public function getFrom() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Word + public function getFrom() : Word { return $this->from; } - public function getTo() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Word + public function getTo() : Word { return $this->to; } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Substitutions.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Substitutions.php index 792c98e832d..aeaa83f9242 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Substitutions.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Substitutions.php @@ -7,32 +7,32 @@ use RectorPrefix20220607\Doctrine\Inflector\WordInflector; use function strtolower; use function strtoupper; use function substr; -class Substitutions implements \RectorPrefix20220607\Doctrine\Inflector\WordInflector +class Substitutions implements WordInflector { /** @var Substitution[] */ private $substitutions; - public function __construct(\RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution ...$substitutions) + public function __construct(Substitution ...$substitutions) { foreach ($substitutions as $substitution) { $this->substitutions[$substitution->getFrom()->getWord()] = $substitution; } } - public function getFlippedSubstitutions() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions + public function getFlippedSubstitutions() : Substitutions { $substitutions = []; foreach ($this->substitutions as $substitution) { - $substitutions[] = new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution($substitution->getTo(), $substitution->getFrom()); + $substitutions[] = new Substitution($substitution->getTo(), $substitution->getFrom()); } - return new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions(...$substitutions); + return new Substitutions(...$substitutions); } public function inflect(string $word) : string { - $lowerWord = \strtolower($word); + $lowerWord = strtolower($word); if (isset($this->substitutions[$lowerWord])) { $firstLetterUppercase = $lowerWord[0] !== $word[0]; $toWord = $this->substitutions[$lowerWord]->getTo()->getWord(); if ($firstLetterUppercase) { - return \strtoupper($toWord[0]) . \substr($toWord, 1); + return strtoupper($toWord[0]) . substr($toWord, 1); } return $toWord; } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Transformation.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Transformation.php index 78e8d6770b5..24feec0fdc4 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Transformation.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Transformation.php @@ -5,18 +5,18 @@ namespace RectorPrefix20220607\Doctrine\Inflector\Rules; use RectorPrefix20220607\Doctrine\Inflector\WordInflector; use function preg_replace; -final class Transformation implements \RectorPrefix20220607\Doctrine\Inflector\WordInflector +final class Transformation implements WordInflector { /** @var Pattern */ private $pattern; /** @var string */ private $replacement; - public function __construct(\RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern $pattern, string $replacement) + public function __construct(Pattern $pattern, string $replacement) { $this->pattern = $pattern; $this->replacement = $replacement; } - public function getPattern() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern + public function getPattern() : Pattern { return $this->pattern; } @@ -26,6 +26,6 @@ final class Transformation implements \RectorPrefix20220607\Doctrine\Inflector\W } public function inflect(string $word) : string { - return (string) \preg_replace($this->pattern->getRegex(), $this->replacement, $word); + return (string) preg_replace($this->pattern->getRegex(), $this->replacement, $word); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Transformations.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Transformations.php index 3fabaf8a0b1..1a97644f703 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Transformations.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Transformations.php @@ -4,11 +4,11 @@ declare (strict_types=1); namespace RectorPrefix20220607\Doctrine\Inflector\Rules; use RectorPrefix20220607\Doctrine\Inflector\WordInflector; -class Transformations implements \RectorPrefix20220607\Doctrine\Inflector\WordInflector +class Transformations implements WordInflector { /** @var Transformation[] */ private $transformations; - public function __construct(\RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation ...$transformations) + public function __construct(Transformation ...$transformations) { $this->transformations = $transformations; } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/Inflectible.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/Inflectible.php index 99425bd6cf6..1543238004f 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/Inflectible.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/Inflectible.php @@ -14,23 +14,23 @@ class Inflectible */ public static function getSingular() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/l[ae]r$/i'), '')); + (yield new Transformation(new Pattern('/l[ae]r$/i'), '')); } /** * @return Transformation[] */ public static function getPlural() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/([eöiü][^aoıueöiü]{0,6})$/u'), '\\1ler')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformation(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('/([aoıu][^aoıueöiü]{0,6})$/u'), '\\1lar')); + (yield new Transformation(new Pattern('/([eöiü][^aoıueöiü]{0,6})$/u'), '\\1ler')); + (yield new Transformation(new Pattern('/([aoıu][^aoıueöiü]{0,6})$/u'), '\\1lar')); } /** * @return Substitution[] */ public static function getIrregular() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('ben'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('biz'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('sen'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('siz'))); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitution(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('o'), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Word('onlar'))); + (yield new Substitution(new Word('ben'), new Word('biz'))); + (yield new Substitution(new Word('sen'), new Word('siz'))); + (yield new Substitution(new Word('o'), new Word('onlar'))); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/InflectorFactory.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/InflectorFactory.php index ed1e90138dc..c7d6780603c 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/InflectorFactory.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/InflectorFactory.php @@ -5,14 +5,14 @@ namespace RectorPrefix20220607\Doctrine\Inflector\Rules\Turkish; use RectorPrefix20220607\Doctrine\Inflector\GenericLanguageInflectorFactory; use RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset; -final class InflectorFactory extends \RectorPrefix20220607\Doctrine\Inflector\GenericLanguageInflectorFactory +final class InflectorFactory extends GenericLanguageInflectorFactory { - protected function getSingularRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + protected function getSingularRuleset() : Ruleset { - return \RectorPrefix20220607\Doctrine\Inflector\Rules\Turkish\Rules::getSingularRuleset(); + return Rules::getSingularRuleset(); } - protected function getPluralRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + protected function getPluralRuleset() : Ruleset { - return \RectorPrefix20220607\Doctrine\Inflector\Rules\Turkish\Rules::getPluralRuleset(); + return Rules::getPluralRuleset(); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/Rules.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/Rules.php index 7b13eccfca3..9401b3a6770 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/Rules.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/Rules.php @@ -9,12 +9,12 @@ use RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions; use RectorPrefix20220607\Doctrine\Inflector\Rules\Transformations; final class Rules { - public static function getSingularRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + public static function getSingularRuleset() : Ruleset { - return new \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformations(...\RectorPrefix20220607\Doctrine\Inflector\Rules\Turkish\Inflectible::getSingular()), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Patterns(...\RectorPrefix20220607\Doctrine\Inflector\Rules\Turkish\Uninflected::getSingular()), (new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions(...\RectorPrefix20220607\Doctrine\Inflector\Rules\Turkish\Inflectible::getIrregular()))->getFlippedSubstitutions()); + return new Ruleset(new Transformations(...Inflectible::getSingular()), new Patterns(...Uninflected::getSingular()), (new Substitutions(...Inflectible::getIrregular()))->getFlippedSubstitutions()); } - public static function getPluralRuleset() : \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset + public static function getPluralRuleset() : Ruleset { - return new \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset(new \RectorPrefix20220607\Doctrine\Inflector\Rules\Transformations(...\RectorPrefix20220607\Doctrine\Inflector\Rules\Turkish\Inflectible::getPlural()), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Patterns(...\RectorPrefix20220607\Doctrine\Inflector\Rules\Turkish\Uninflected::getPlural()), new \RectorPrefix20220607\Doctrine\Inflector\Rules\Substitutions(...\RectorPrefix20220607\Doctrine\Inflector\Rules\Turkish\Inflectible::getIrregular())); + return new Ruleset(new Transformations(...Inflectible::getPlural()), new Patterns(...Uninflected::getPlural()), new Substitutions(...Inflectible::getIrregular())); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/Uninflected.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/Uninflected.php index dda0fba90f3..b708f5aab87 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/Uninflected.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/Turkish/Uninflected.php @@ -25,8 +25,8 @@ final class Uninflected */ private static function getDefault() : iterable { - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('lunes')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('rompecabezas')); - (yield new \RectorPrefix20220607\Doctrine\Inflector\Rules\Pattern('crisis')); + (yield new Pattern('lunes')); + (yield new Pattern('rompecabezas')); + (yield new Pattern('crisis')); } } diff --git a/vendor/doctrine/inflector/lib/Doctrine/Inflector/RulesetInflector.php b/vendor/doctrine/inflector/lib/Doctrine/Inflector/RulesetInflector.php index 47e272e0ca3..c8fae04f046 100644 --- a/vendor/doctrine/inflector/lib/Doctrine/Inflector/RulesetInflector.php +++ b/vendor/doctrine/inflector/lib/Doctrine/Inflector/RulesetInflector.php @@ -14,13 +14,13 @@ use function array_merge; * - The first ruleset that returns a different value for a regular word wins * - If none of the above match, the word is left as-is */ -class RulesetInflector implements \RectorPrefix20220607\Doctrine\Inflector\WordInflector +class RulesetInflector implements WordInflector { /** @var Ruleset[] */ private $rulesets; - public function __construct(\RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset $ruleset, \RectorPrefix20220607\Doctrine\Inflector\Rules\Ruleset ...$rulesets) + public function __construct(Ruleset $ruleset, Ruleset ...$rulesets) { - $this->rulesets = \array_merge([$ruleset], $rulesets); + $this->rulesets = array_merge([$ruleset], $rulesets); } public function inflect(string $word) : string { diff --git a/vendor/evenement/evenement/examples/benchmark-emit-no-arguments.php b/vendor/evenement/evenement/examples/benchmark-emit-no-arguments.php index e4ac567fff9..d2b61ea9cdc 100644 --- a/vendor/evenement/evenement/examples/benchmark-emit-no-arguments.php +++ b/vendor/evenement/evenement/examples/benchmark-emit-no-arguments.php @@ -14,12 +14,12 @@ namespace RectorPrefix20220607; const ITERATIONS = 10000000; use RectorPrefix20220607\Evenement\EventEmitter; require __DIR__ . '/../vendor/autoload.php'; -$emitter = new \RectorPrefix20220607\Evenement\EventEmitter(); +$emitter = new EventEmitter(); $emitter->on('event', function () { }); $start = \microtime(\true); -for ($i = 0; $i < \ITERATIONS; $i++) { +for ($i = 0; $i < \RectorPrefix20220607\ITERATIONS; $i++) { $emitter->emit('event'); } $time = \microtime(\true) - $start; -echo 'Emitting ', \number_format(\ITERATIONS), ' events took: ', \number_format($time, 2), 's', \PHP_EOL; +echo 'Emitting ', \number_format(\RectorPrefix20220607\ITERATIONS), ' events took: ', \number_format($time, 2), 's', \PHP_EOL; diff --git a/vendor/evenement/evenement/examples/benchmark-emit-once.php b/vendor/evenement/evenement/examples/benchmark-emit-once.php index f3a9c2e4382..0a1070172d0 100644 --- a/vendor/evenement/evenement/examples/benchmark-emit-once.php +++ b/vendor/evenement/evenement/examples/benchmark-emit-once.php @@ -15,12 +15,12 @@ namespace RectorPrefix20220607; const ITERATIONS = 100000; use RectorPrefix20220607\Evenement\EventEmitter; require __DIR__ . '/../vendor/autoload.php'; -$emitter = new \RectorPrefix20220607\Evenement\EventEmitter(); -for ($i = 0; $i < \ITERATIONS; $i++) { +$emitter = new EventEmitter(); +for ($i = 0; $i < \RectorPrefix20220607\ITERATIONS; $i++) { $emitter->once('event', function ($a, $b, $c) { }); } $start = \microtime(\true); $emitter->emit('event', [1, 2, 3]); $time = \microtime(\true) - $start; -echo 'Emitting one event to ', \number_format(\ITERATIONS), ' once listeners took: ', \number_format($time, 2), 's', \PHP_EOL; +echo 'Emitting one event to ', \number_format(\RectorPrefix20220607\ITERATIONS), ' once listeners took: ', \number_format($time, 2), 's', \PHP_EOL; diff --git a/vendor/evenement/evenement/examples/benchmark-emit-one-argument.php b/vendor/evenement/evenement/examples/benchmark-emit-one-argument.php index b21c261a777..5d89b55da70 100644 --- a/vendor/evenement/evenement/examples/benchmark-emit-one-argument.php +++ b/vendor/evenement/evenement/examples/benchmark-emit-one-argument.php @@ -14,12 +14,12 @@ namespace RectorPrefix20220607; const ITERATIONS = 10000000; use RectorPrefix20220607\Evenement\EventEmitter; require __DIR__ . '/../vendor/autoload.php'; -$emitter = new \RectorPrefix20220607\Evenement\EventEmitter(); +$emitter = new EventEmitter(); $emitter->on('event', function ($a) { }); $start = \microtime(\true); -for ($i = 0; $i < \ITERATIONS; $i++) { +for ($i = 0; $i < \RectorPrefix20220607\ITERATIONS; $i++) { $emitter->emit('event', [1]); } $time = \microtime(\true) - $start; -echo 'Emitting ', \number_format(\ITERATIONS), ' events took: ', \number_format($time, 2), 's', \PHP_EOL; +echo 'Emitting ', \number_format(\RectorPrefix20220607\ITERATIONS), ' events took: ', \number_format($time, 2), 's', \PHP_EOL; diff --git a/vendor/evenement/evenement/examples/benchmark-emit.php b/vendor/evenement/evenement/examples/benchmark-emit.php index 9e066b7baf7..970e0d3be2b 100644 --- a/vendor/evenement/evenement/examples/benchmark-emit.php +++ b/vendor/evenement/evenement/examples/benchmark-emit.php @@ -14,12 +14,12 @@ namespace RectorPrefix20220607; const ITERATIONS = 10000000; use RectorPrefix20220607\Evenement\EventEmitter; require __DIR__ . '/../vendor/autoload.php'; -$emitter = new \RectorPrefix20220607\Evenement\EventEmitter(); +$emitter = new EventEmitter(); $emitter->on('event', function ($a, $b, $c) { }); $start = \microtime(\true); -for ($i = 0; $i < \ITERATIONS; $i++) { +for ($i = 0; $i < \RectorPrefix20220607\ITERATIONS; $i++) { $emitter->emit('event', [1, 2, 3]); } $time = \microtime(\true) - $start; -echo 'Emitting ', \number_format(\ITERATIONS), ' events took: ', \number_format($time, 2), 's', \PHP_EOL; +echo 'Emitting ', \number_format(\RectorPrefix20220607\ITERATIONS), ' events took: ', \number_format($time, 2), 's', \PHP_EOL; diff --git a/vendor/evenement/evenement/examples/benchmark-remove-listener-once.php b/vendor/evenement/evenement/examples/benchmark-remove-listener-once.php index 1fe6a60a187..b87c624ac4a 100644 --- a/vendor/evenement/evenement/examples/benchmark-remove-listener-once.php +++ b/vendor/evenement/evenement/examples/benchmark-remove-listener-once.php @@ -15,9 +15,9 @@ namespace RectorPrefix20220607; const ITERATIONS = 100000; use RectorPrefix20220607\Evenement\EventEmitter; require __DIR__ . '/../vendor/autoload.php'; -$emitter = new \RectorPrefix20220607\Evenement\EventEmitter(); +$emitter = new EventEmitter(); $listeners = []; -for ($i = 0; $i < \ITERATIONS; $i++) { +for ($i = 0; $i < \RectorPrefix20220607\ITERATIONS; $i++) { $listeners[] = function ($a, $b, $c) { }; } @@ -26,10 +26,10 @@ foreach ($listeners as $listener) { $emitter->once('event', $listener); } $time = \microtime(\true) - $start; -echo 'Adding ', \number_format(\ITERATIONS), ' once listeners took: ', \number_format($time, 2), 's', \PHP_EOL; +echo 'Adding ', \number_format(\RectorPrefix20220607\ITERATIONS), ' once listeners took: ', \number_format($time, 2), 's', \PHP_EOL; $start = \microtime(\true); foreach ($listeners as $listener) { $emitter->removeListener('event', $listener); } $time = \microtime(\true) - $start; -echo 'Removing ', \number_format(\ITERATIONS), ' once listeners took: ', \number_format($time, 2), 's', \PHP_EOL; +echo 'Removing ', \number_format(\RectorPrefix20220607\ITERATIONS), ' once listeners took: ', \number_format($time, 2), 's', \PHP_EOL; diff --git a/vendor/evenement/evenement/src/Evenement/EventEmitter.php b/vendor/evenement/evenement/src/Evenement/EventEmitter.php index eb6d56a8321..d33c421efa6 100644 --- a/vendor/evenement/evenement/src/Evenement/EventEmitter.php +++ b/vendor/evenement/evenement/src/Evenement/EventEmitter.php @@ -11,7 +11,7 @@ declare (strict_types=1); */ namespace RectorPrefix20220607\Evenement; -class EventEmitter implements \RectorPrefix20220607\Evenement\EventEmitterInterface +class EventEmitter implements EventEmitterInterface { use EventEmitterTrait; } diff --git a/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php b/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php index dbb95763bfd..2a52dece9f7 100644 --- a/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php +++ b/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php @@ -19,7 +19,7 @@ trait EventEmitterTrait public function on($event, callable $listener) { if ($event === null) { - throw new \InvalidArgumentException('event name must not be null'); + throw new InvalidArgumentException('event name must not be null'); } if (!isset($this->listeners[$event])) { $this->listeners[$event] = []; @@ -30,7 +30,7 @@ trait EventEmitterTrait public function once($event, callable $listener) { if ($event === null) { - throw new \InvalidArgumentException('event name must not be null'); + throw new InvalidArgumentException('event name must not be null'); } if (!isset($this->onceListeners[$event])) { $this->onceListeners[$event] = []; @@ -41,7 +41,7 @@ trait EventEmitterTrait public function removeListener($event, callable $listener) { if ($event === null) { - throw new \InvalidArgumentException('event name must not be null'); + throw new InvalidArgumentException('event name must not be null'); } if (isset($this->listeners[$event])) { $index = \array_search($listener, $this->listeners[$event], \true); @@ -90,7 +90,7 @@ trait EventEmitterTrait public function emit($event, array $arguments = []) { if ($event === null) { - throw new \InvalidArgumentException('event name must not be null'); + throw new InvalidArgumentException('event name must not be null'); } if (isset($this->listeners[$event])) { foreach ($this->listeners[$event] as $listener) { diff --git a/vendor/evenement/evenement/tests/Evenement/Tests/EventEmitterTest.php b/vendor/evenement/evenement/tests/Evenement/Tests/EventEmitterTest.php index 18c702ac1b3..c81f6d1d272 100644 --- a/vendor/evenement/evenement/tests/Evenement/Tests/EventEmitterTest.php +++ b/vendor/evenement/evenement/tests/Evenement/Tests/EventEmitterTest.php @@ -13,13 +13,13 @@ namespace RectorPrefix20220607\Evenement\Tests; use RectorPrefix20220607\Evenement\EventEmitter; use InvalidArgumentException; -use RectorPrefix20220607\PHPUnit\Framework\TestCase; -class EventEmitterTest extends \RectorPrefix20220607\PHPUnit\Framework\TestCase +use PHPUnit\Framework\TestCase; +class EventEmitterTest extends TestCase { private $emitter; public function setUp() { - $this->emitter = new \RectorPrefix20220607\Evenement\EventEmitter(); + $this->emitter = new EventEmitter(); } public function testAddListenerWithLambda() { @@ -28,7 +28,7 @@ class EventEmitterTest extends \RectorPrefix20220607\PHPUnit\Framework\TestCase } public function testAddListenerWithMethod() { - $listener = new \RectorPrefix20220607\Evenement\Tests\Listener(); + $listener = new Listener(); $this->emitter->on('foo', [$listener, 'onFoo']); } public function testAddListenerWithStaticMethod() @@ -191,14 +191,14 @@ class EventEmitterTest extends \RectorPrefix20220607\PHPUnit\Framework\TestCase } public function testCallablesClass() { - $listener = new \RectorPrefix20220607\Evenement\Tests\Listener(); + $listener = new Listener(); $this->emitter->on('foo', [$listener, 'onFoo']); $this->emitter->emit('foo', ['bar']); self::assertSame(['bar'], $listener->getData()); } public function testCallablesClassInvoke() { - $listener = new \RectorPrefix20220607\Evenement\Tests\Listener(); + $listener = new Listener(); $this->emitter->on('foo', $listener); $this->emitter->emit('foo', ['bar']); self::assertSame(['bar'], $listener->getMagicData()); @@ -207,7 +207,7 @@ class EventEmitterTest extends \RectorPrefix20220607\PHPUnit\Framework\TestCase { $this->emitter->on('foo', '\\Evenement\\Tests\\Listener::onBar'); $this->emitter->emit('foo', ['bar']); - self::assertSame(['bar'], \RectorPrefix20220607\Evenement\Tests\Listener::getStaticData()); + self::assertSame(['bar'], Listener::getStaticData()); } public function testCallablesFunction() { @@ -285,28 +285,28 @@ class EventEmitterTest extends \RectorPrefix20220607\PHPUnit\Framework\TestCase } public function testEventNameMustBeStringOn() { - self::expectException(\InvalidArgumentException::class); + self::expectException(InvalidArgumentException::class); self::expectExceptionMessage('event name must not be null'); $this->emitter->on(null, function () { }); } public function testEventNameMustBeStringOnce() { - self::expectException(\InvalidArgumentException::class); + self::expectException(InvalidArgumentException::class); self::expectExceptionMessage('event name must not be null'); $this->emitter->once(null, function () { }); } public function testEventNameMustBeStringRemoveListener() { - self::expectException(\InvalidArgumentException::class); + self::expectException(InvalidArgumentException::class); self::expectExceptionMessage('event name must not be null'); $this->emitter->removeListener(null, function () { }); } public function testEventNameMustBeStringEmit() { - self::expectException(\InvalidArgumentException::class); + self::expectException(InvalidArgumentException::class); self::expectExceptionMessage('event name must not be null'); $this->emitter->emit(null); } diff --git a/vendor/nette/neon/bin/neon-lint b/vendor/nette/neon/bin/neon-lint index 3719574277f..9328d742ad9 100644 --- a/vendor/nette/neon/bin/neon-lint +++ b/vendor/nette/neon/bin/neon-lint @@ -28,7 +28,7 @@ if ($argc < 2) { echo "Usage: neon-lint \n"; exit(1); } -$ok = \RectorPrefix20220607\scanPath($argv[1]); +$ok = scanPath($argv[1]); exit($ok ? 0 : 1); function scanPath(string $path) : bool { @@ -40,7 +40,7 @@ function scanPath(string $path) : bool $success = \true; foreach ($it as $file) { echo \str_pad(\str_repeat('.', $counter++ % 40), 40), "\r"; - $success = \RectorPrefix20220607\lintFile((string) $file) && $success; + $success = lintFile((string) $file) && $success; } echo \str_pad('', 40), "\r"; echo "Done.\n"; @@ -61,9 +61,9 @@ function lintFile(string $file) : bool $contents = \substr($s, 3); } try { - \RectorPrefix20220607\Nette\Neon\Neon::decode($s); + Nette\Neon\Neon::decode($s); return \true; - } catch (\RectorPrefix20220607\Nette\Neon\Exception $e) { + } catch (Nette\Neon\Exception $e) { \fwrite(\STDERR, "[ERROR] {$file} {$e->getMessage()}\n"); } finally { \restore_error_handler(); diff --git a/vendor/nette/neon/src/Neon/Decoder.php b/vendor/nette/neon/src/Neon/Decoder.php index c5747bb1e2b..36720c1c037 100644 --- a/vendor/nette/neon/src/Neon/Decoder.php +++ b/vendor/nette/neon/src/Neon/Decoder.php @@ -22,10 +22,10 @@ final class Decoder $node = $this->parseToNode($input); return $node->toValue(); } - public function parseToNode(string $input) : \RectorPrefix20220607\Nette\Neon\Node + public function parseToNode(string $input) : Node { - $lexer = new \RectorPrefix20220607\Nette\Neon\Lexer(); - $parser = new \RectorPrefix20220607\Nette\Neon\Parser(); + $lexer = new Lexer(); + $parser = new Parser(); $tokens = $lexer->tokenize($input); return $parser->parse($tokens); } diff --git a/vendor/nette/neon/src/Neon/Encoder.php b/vendor/nette/neon/src/Neon/Encoder.php index b8f3ed6cbc3..f581ead01fc 100644 --- a/vendor/nette/neon/src/Neon/Encoder.php +++ b/vendor/nette/neon/src/Neon/Encoder.php @@ -27,31 +27,31 @@ final class Encoder $node = $this->valueToNode($val, $this->blockMode); return $node->toString(); } - public function valueToNode($val, bool $blockMode = \false) : \RectorPrefix20220607\Nette\Neon\Node + public function valueToNode($val, bool $blockMode = \false) : Node { if ($val instanceof \DateTimeInterface) { - return new \RectorPrefix20220607\Nette\Neon\Node\LiteralNode($val); - } elseif ($val instanceof \RectorPrefix20220607\Nette\Neon\Entity && $val->value === \RectorPrefix20220607\Nette\Neon\Neon::Chain) { - $node = new \RectorPrefix20220607\Nette\Neon\Node\EntityChainNode(); + return new Node\LiteralNode($val); + } elseif ($val instanceof Entity && $val->value === Neon::Chain) { + $node = new Node\EntityChainNode(); foreach ($val->attributes as $entity) { $node->chain[] = $this->valueToNode($entity); } return $node; - } elseif ($val instanceof \RectorPrefix20220607\Nette\Neon\Entity) { - return new \RectorPrefix20220607\Nette\Neon\Node\EntityNode($this->valueToNode($val->value), $this->arrayToNodes((array) $val->attributes)); + } elseif ($val instanceof Entity) { + return new Node\EntityNode($this->valueToNode($val->value), $this->arrayToNodes((array) $val->attributes)); } elseif (\is_object($val) || \is_array($val)) { if ($blockMode) { - $node = new \RectorPrefix20220607\Nette\Neon\Node\BlockArrayNode(); + $node = new Node\BlockArrayNode(); } else { $isList = \is_array($val) && (!$val || \array_keys($val) === \range(0, \count($val) - 1)); - $node = new \RectorPrefix20220607\Nette\Neon\Node\InlineArrayNode($isList ? '[' : '{'); + $node = new Node\InlineArrayNode($isList ? '[' : '{'); } $node->items = $this->arrayToNodes($val, $blockMode); return $node; - } elseif (\is_string($val) && \RectorPrefix20220607\Nette\Neon\Lexer::requiresDelimiters($val)) { - return new \RectorPrefix20220607\Nette\Neon\Node\StringNode($val); + } elseif (\is_string($val) && Lexer::requiresDelimiters($val)) { + return new Node\StringNode($val); } else { - return new \RectorPrefix20220607\Nette\Neon\Node\LiteralNode($val); + return new Node\LiteralNode($val); } } /** @return Node\ArrayItemNode[] */ @@ -61,10 +61,10 @@ final class Encoder $counter = 0; $hide = \true; foreach ($val as $k => $v) { - $res[] = $item = new \RectorPrefix20220607\Nette\Neon\Node\ArrayItemNode(); + $res[] = $item = new Node\ArrayItemNode(); $item->key = $hide && $k === $counter ? null : self::valueToNode($k); $item->value = self::valueToNode($v, $blockMode); - if ($item->value instanceof \RectorPrefix20220607\Nette\Neon\Node\BlockArrayNode) { + if ($item->value instanceof Node\BlockArrayNode) { $item->value->indentation = $this->indentation; } if ($hide && \is_int($k)) { diff --git a/vendor/nette/neon/src/Neon/Lexer.php b/vendor/nette/neon/src/Neon/Lexer.php index 5606d747406..738ac653ed6 100644 --- a/vendor/nette/neon/src/Neon/Lexer.php +++ b/vendor/nette/neon/src/Neon/Lexer.php @@ -12,14 +12,14 @@ final class Lexer { public const Patterns = [ // strings - \RectorPrefix20220607\Nette\Neon\Token::String => ' + Token::String => ' \'\'\'\\n (?:(?: [^\\n] | \\n(?![\\t\\ ]*+\'\'\') )*+ \\n)?[\\t\\ ]*+\'\'\' | """\\n (?:(?: [^\\n] | \\n(?![\\t\\ ]*+""") )*+ \\n)?[\\t\\ ]*+""" | \' (?: \'\' | [^\'\\n] )*+ \' | " (?: \\\\. | [^"\\\\\\n] )*+ " ', // literal / boolean / integer / float - \RectorPrefix20220607\Nette\Neon\Token::Literal => ' + Token::Literal => ' (?: [^#"\',:=[\\]{}()\\n\\t\\ `-] | (? '[,:=[\\]{}()-]', + Token::Char => '[,:=[\\]{}()-]', // comment - \RectorPrefix20220607\Nette\Neon\Token::Comment => '\\#.*+', + Token::Comment => '\\#.*+', // new line - \RectorPrefix20220607\Nette\Neon\Token::Newline => '\\n++', + Token::Newline => '\\n++', // whitespace - \RectorPrefix20220607\Nette\Neon\Token::Whitespace => '[\\t\\ ]++', + Token::Whitespace => '[\\t\\ ]++', ]; - public function tokenize(string $input) : \RectorPrefix20220607\Nette\Neon\TokenStream + public function tokenize(string $input) : TokenStream { $input = \str_replace("\r", '', $input); $pattern = '~(' . \implode(')|(', self::Patterns) . ')~Amixu'; $res = \preg_match_all($pattern, $input, $tokens, \PREG_SET_ORDER); if ($res === \false) { - throw new \RectorPrefix20220607\Nette\Neon\Exception('Invalid UTF-8 sequence.'); + throw new Exception('Invalid UTF-8 sequence.'); } $types = \array_keys(self::Patterns); $offset = 0; @@ -53,16 +53,16 @@ final class Lexer break; } elseif ($token[$i] !== '') { $type = $types[$i - 1]; - if ($type === \RectorPrefix20220607\Nette\Neon\Token::Char) { + if ($type === Token::Char) { $type = $token[0]; } break; } } - $token = new \RectorPrefix20220607\Nette\Neon\Token($token[0], $type); + $token = new Token($token[0], $type); $offset += \strlen($token->value); } - $stream = new \RectorPrefix20220607\Nette\Neon\TokenStream($tokens); + $stream = new TokenStream($tokens); if ($offset !== \strlen($input)) { $s = \str_replace("\n", '\\n', \substr($input, $offset, 40)); $stream->error("Unexpected '{$s}'", \count($tokens)); @@ -71,6 +71,6 @@ final class Lexer } public static function requiresDelimiters(string $s) : bool { - return \preg_match('~[\\x00-\\x1F]|^[+-.]?\\d|^(true|false|yes|no|on|off|null)$~Di', $s) || !\preg_match('~^' . self::Patterns[\RectorPrefix20220607\Nette\Neon\Token::Literal] . '$~Dx', $s); + return \preg_match('~[\\x00-\\x1F]|^[+-.]?\\d|^(true|false|yes|no|on|off|null)$~Di', $s) || !\preg_match('~^' . self::Patterns[Token::Literal] . '$~Dx', $s); } } diff --git a/vendor/nette/neon/src/Neon/Neon.php b/vendor/nette/neon/src/Neon/Neon.php index 67906ef8465..f8988d26001 100644 --- a/vendor/nette/neon/src/Neon/Neon.php +++ b/vendor/nette/neon/src/Neon/Neon.php @@ -13,7 +13,7 @@ namespace RectorPrefix20220607\Nette\Neon; */ final class Neon { - public const BLOCK = \RectorPrefix20220607\Nette\Neon\Encoder::BLOCK; + public const BLOCK = Encoder::BLOCK; public const Chain = '!!chain'; public const CHAIN = self::Chain; /** @@ -21,7 +21,7 @@ final class Neon */ public static function encode($value, bool $blockMode = \false, string $indentation = "\t") : string { - $encoder = new \RectorPrefix20220607\Nette\Neon\Encoder(); + $encoder = new Encoder(); $encoder->blockMode = $blockMode; $encoder->indentation = $indentation; return $encoder->encode($value); @@ -32,7 +32,7 @@ final class Neon */ public static function decode(string $input) { - $decoder = new \RectorPrefix20220607\Nette\Neon\Decoder(); + $decoder = new Decoder(); return $decoder->decode($input); } /** @@ -42,7 +42,7 @@ final class Neon public static function decodeFile(string $file) { if (!\is_file($file)) { - throw new \RectorPrefix20220607\Nette\Neon\Exception("File '{$file}' does not exist."); + throw new Exception("File '{$file}' does not exist."); } $input = \file_get_contents($file); if (\substr($input, 0, 3) === "") { diff --git a/vendor/nette/neon/src/Neon/Node/ArrayItemNode.php b/vendor/nette/neon/src/Neon/Node/ArrayItemNode.php index 4704fe01fe1..b031e03a468 100644 --- a/vendor/nette/neon/src/Neon/Node/ArrayItemNode.php +++ b/vendor/nette/neon/src/Neon/Node/ArrayItemNode.php @@ -9,7 +9,7 @@ namespace RectorPrefix20220607\Nette\Neon\Node; use RectorPrefix20220607\Nette\Neon\Node; /** @internal */ -final class ArrayItemNode extends \RectorPrefix20220607\Nette\Neon\Node +final class ArrayItemNode extends Node { /** @var ?Node */ public $key; @@ -46,7 +46,7 @@ final class ArrayItemNode extends \RectorPrefix20220607\Nette\Neon\Node $res = ''; foreach ($items as $item) { $v = $item->value->toString(); - $res .= ($item->key ? $item->key->toString() . ':' : '-') . ($item->value instanceof \RectorPrefix20220607\Nette\Neon\Node\BlockArrayNode && $item->value->items ? "\n" . $v . (\substr($v, -2, 1) === "\n" ? '' : "\n") : ' ' . $v . "\n"); + $res .= ($item->key ? $item->key->toString() . ':' : '-') . ($item->value instanceof BlockArrayNode && $item->value->items ? "\n" . $v . (\substr($v, -2, 1) === "\n" ? '' : "\n") : ' ' . $v . "\n"); } return $res; } diff --git a/vendor/nette/neon/src/Neon/Node/ArrayNode.php b/vendor/nette/neon/src/Neon/Node/ArrayNode.php index ddef3d40d03..079e36060c8 100644 --- a/vendor/nette/neon/src/Neon/Node/ArrayNode.php +++ b/vendor/nette/neon/src/Neon/Node/ArrayNode.php @@ -9,14 +9,14 @@ namespace RectorPrefix20220607\Nette\Neon\Node; use RectorPrefix20220607\Nette\Neon\Node; /** @internal */ -abstract class ArrayNode extends \RectorPrefix20220607\Nette\Neon\Node +abstract class ArrayNode extends Node { /** @var ArrayItemNode[] */ public $items = []; /** @return mixed[] */ public function toValue() : array { - return \RectorPrefix20220607\Nette\Neon\Node\ArrayItemNode::itemsToArray($this->items); + return ArrayItemNode::itemsToArray($this->items); } public function &getIterator() : \Generator { diff --git a/vendor/nette/neon/src/Neon/Node/BlockArrayNode.php b/vendor/nette/neon/src/Neon/Node/BlockArrayNode.php index b2a2aacbf93..db689af0220 100644 --- a/vendor/nette/neon/src/Neon/Node/BlockArrayNode.php +++ b/vendor/nette/neon/src/Neon/Node/BlockArrayNode.php @@ -8,7 +8,7 @@ declare (strict_types=1); namespace RectorPrefix20220607\Nette\Neon\Node; /** @internal */ -final class BlockArrayNode extends \RectorPrefix20220607\Nette\Neon\Node\ArrayNode +final class BlockArrayNode extends ArrayNode { /** @var string */ public $indentation; @@ -21,7 +21,7 @@ final class BlockArrayNode extends \RectorPrefix20220607\Nette\Neon\Node\ArrayNo if (\count($this->items) === 0) { return '[]'; } - $res = \RectorPrefix20220607\Nette\Neon\Node\ArrayItemNode::itemsToBlockString($this->items); + $res = ArrayItemNode::itemsToBlockString($this->items); return \preg_replace('#^(?=.)#m', $this->indentation, $res); } } diff --git a/vendor/nette/neon/src/Neon/Node/EntityChainNode.php b/vendor/nette/neon/src/Neon/Node/EntityChainNode.php index c03c1c8b4ec..99345ba10c9 100644 --- a/vendor/nette/neon/src/Neon/Node/EntityChainNode.php +++ b/vendor/nette/neon/src/Neon/Node/EntityChainNode.php @@ -10,7 +10,7 @@ namespace RectorPrefix20220607\Nette\Neon\Node; use RectorPrefix20220607\Nette\Neon; use RectorPrefix20220607\Nette\Neon\Node; /** @internal */ -final class EntityChainNode extends \RectorPrefix20220607\Nette\Neon\Node +final class EntityChainNode extends Node { /** @var EntityNode[] */ public $chain = []; @@ -18,13 +18,13 @@ final class EntityChainNode extends \RectorPrefix20220607\Nette\Neon\Node { $this->chain = $chain; } - public function toValue() : \RectorPrefix20220607\Nette\Neon\Entity + public function toValue() : Neon\Entity { $entities = []; foreach ($this->chain as $item) { $entities[] = $item->toValue(); } - return new \RectorPrefix20220607\Nette\Neon\Entity(\RectorPrefix20220607\Nette\Neon\Neon::Chain, $entities); + return new Neon\Entity(Neon\Neon::Chain, $entities); } public function toString() : string { diff --git a/vendor/nette/neon/src/Neon/Node/EntityNode.php b/vendor/nette/neon/src/Neon/Node/EntityNode.php index f1b774a2081..eb0273bc28b 100644 --- a/vendor/nette/neon/src/Neon/Node/EntityNode.php +++ b/vendor/nette/neon/src/Neon/Node/EntityNode.php @@ -10,24 +10,24 @@ namespace RectorPrefix20220607\Nette\Neon\Node; use RectorPrefix20220607\Nette\Neon\Entity; use RectorPrefix20220607\Nette\Neon\Node; /** @internal */ -final class EntityNode extends \RectorPrefix20220607\Nette\Neon\Node +final class EntityNode extends Node { /** @var Node */ public $value; /** @var ArrayItemNode[] */ public $attributes; - public function __construct(\RectorPrefix20220607\Nette\Neon\Node $value, array $attributes = []) + public function __construct(Node $value, array $attributes = []) { $this->value = $value; $this->attributes = $attributes; } - public function toValue() : \RectorPrefix20220607\Nette\Neon\Entity + public function toValue() : Entity { - return new \RectorPrefix20220607\Nette\Neon\Entity($this->value->toValue(), \RectorPrefix20220607\Nette\Neon\Node\ArrayItemNode::itemsToArray($this->attributes)); + return new Entity($this->value->toValue(), ArrayItemNode::itemsToArray($this->attributes)); } public function toString() : string { - return $this->value->toString() . '(' . ($this->attributes ? \RectorPrefix20220607\Nette\Neon\Node\ArrayItemNode::itemsToInlineString($this->attributes) : '') . ')'; + return $this->value->toString() . '(' . ($this->attributes ? ArrayItemNode::itemsToInlineString($this->attributes) : '') . ')'; } public function &getIterator() : \Generator { diff --git a/vendor/nette/neon/src/Neon/Node/InlineArrayNode.php b/vendor/nette/neon/src/Neon/Node/InlineArrayNode.php index 62c90120ae2..32a6bed56d3 100644 --- a/vendor/nette/neon/src/Neon/Node/InlineArrayNode.php +++ b/vendor/nette/neon/src/Neon/Node/InlineArrayNode.php @@ -8,7 +8,7 @@ declare (strict_types=1); namespace RectorPrefix20220607\Nette\Neon\Node; /** @internal */ -final class InlineArrayNode extends \RectorPrefix20220607\Nette\Neon\Node\ArrayNode +final class InlineArrayNode extends ArrayNode { /** @var string */ public $bracket; @@ -18,6 +18,6 @@ final class InlineArrayNode extends \RectorPrefix20220607\Nette\Neon\Node\ArrayN } public function toString() : string { - return $this->bracket . \RectorPrefix20220607\Nette\Neon\Node\ArrayItemNode::itemsToInlineString($this->items) . ['[' => ']', '{' => '}', '(' => ')'][$this->bracket]; + return $this->bracket . ArrayItemNode::itemsToInlineString($this->items) . ['[' => ']', '{' => '}', '(' => ')'][$this->bracket]; } } diff --git a/vendor/nette/neon/src/Neon/Node/LiteralNode.php b/vendor/nette/neon/src/Neon/Node/LiteralNode.php index 69732005240..4bdbbed73c2 100644 --- a/vendor/nette/neon/src/Neon/Node/LiteralNode.php +++ b/vendor/nette/neon/src/Neon/Node/LiteralNode.php @@ -9,7 +9,7 @@ namespace RectorPrefix20220607\Nette\Neon\Node; use RectorPrefix20220607\Nette\Neon\Node; /** @internal */ -final class LiteralNode extends \RectorPrefix20220607\Nette\Neon\Node +final class LiteralNode extends Node { private const SimpleTypes = ['true' => \true, 'True' => \true, 'TRUE' => \true, 'yes' => \true, 'Yes' => \true, 'YES' => \true, 'on' => \true, 'On' => \true, 'ON' => \true, 'false' => \false, 'False' => \false, 'FALSE' => \false, 'no' => \false, 'No' => \false, 'NO' => \false, 'off' => \false, 'Off' => \false, 'OFF' => \false, 'null' => null, 'Null' => null, 'NULL' => null]; private const DeprecatedTypes = ['on' => 1, 'On' => 1, 'ON' => 1, 'off' => 1, 'Off' => 1, 'OFF' => 1]; diff --git a/vendor/nette/neon/src/Neon/Node/StringNode.php b/vendor/nette/neon/src/Neon/Node/StringNode.php index fc46246e7fb..a2d82572d80 100644 --- a/vendor/nette/neon/src/Neon/Node/StringNode.php +++ b/vendor/nette/neon/src/Neon/Node/StringNode.php @@ -10,9 +10,9 @@ namespace RectorPrefix20220607\Nette\Neon\Node; use RectorPrefix20220607\Nette; use RectorPrefix20220607\Nette\Neon\Node; /** @internal */ -final class StringNode extends \RectorPrefix20220607\Nette\Neon\Node +final class StringNode extends Node { - private const EscapeSequences = ['t' => "\t", 'n' => "\n", 'r' => "\r", 'f' => "\f", 'b' => "\10", '"' => '"', '\\' => '\\', '/' => '/', '_' => " "]; + private const EscapeSequences = ['t' => "\t", 'n' => "\n", 'r' => "\r", 'f' => "\f", 'b' => "\x08", '"' => '"', '\\' => '\\', '/' => '/', '_' => " "]; /** @var string */ public $value; public function __construct(string $value) @@ -47,12 +47,12 @@ final class StringNode extends \RectorPrefix20220607\Nette\Neon\Node if (($res = \json_decode('"' . $sq . '"')) !== null) { return $res; } - throw new \RectorPrefix20220607\Nette\Neon\Exception("Invalid UTF-8 sequence {$sq}"); + throw new Nette\Neon\Exception("Invalid UTF-8 sequence {$sq}"); } elseif ($sq[1] === 'x' && \strlen($sq) === 4) { \trigger_error("Neon: '{$sq}' is deprecated, use '\\uXXXX' instead.", \E_USER_DEPRECATED); return \chr(\hexdec(\substr($sq, 2))); } else { - throw new \RectorPrefix20220607\Nette\Neon\Exception("Invalid escaping sequence {$sq}"); + throw new Nette\Neon\Exception("Invalid escaping sequence {$sq}"); } }, $res); } diff --git a/vendor/nette/neon/src/Neon/Parser.php b/vendor/nette/neon/src/Neon/Parser.php index a519f1c2238..522f22afaa7 100644 --- a/vendor/nette/neon/src/Neon/Parser.php +++ b/vendor/nette/neon/src/Neon/Parser.php @@ -14,32 +14,32 @@ final class Parser private $tokens; /** @var int[] */ private $posToLine = []; - public function parse(\RectorPrefix20220607\Nette\Neon\TokenStream $tokens) : \RectorPrefix20220607\Nette\Neon\Node + public function parse(TokenStream $tokens) : Node { $this->tokens = $tokens; $this->initLines(); - while ($this->tokens->consume(\RectorPrefix20220607\Nette\Neon\Token::Newline)) { + while ($this->tokens->consume(Token::Newline)) { } $node = $this->parseBlock($this->tokens->getIndentation()); - while ($this->tokens->consume(\RectorPrefix20220607\Nette\Neon\Token::Newline)) { + while ($this->tokens->consume(Token::Newline)) { } if ($this->tokens->isNext()) { $this->tokens->error(); } return $node; } - private function parseBlock(string $indent, bool $onlyBullets = \false) : \RectorPrefix20220607\Nette\Neon\Node + private function parseBlock(string $indent, bool $onlyBullets = \false) : Node { - $res = new \RectorPrefix20220607\Nette\Neon\Node\BlockArrayNode($indent); + $res = new Node\BlockArrayNode($indent); $this->injectPos($res); $keyCheck = []; loop: - $item = new \RectorPrefix20220607\Nette\Neon\Node\ArrayItemNode(); + $item = new Node\ArrayItemNode(); $this->injectPos($item); if ($this->tokens->consume('-')) { // continue } elseif (!$this->tokens->isNext() || $onlyBullets) { - return $res->items ? $res : $this->injectPos(new \RectorPrefix20220607\Nette\Neon\Node\LiteralNode(null)); + return $res->items ? $res : $this->injectPos(new Node\LiteralNode(null)); } else { $value = $this->parseValue(); if ($this->tokens->consume(':', '=')) { @@ -53,10 +53,10 @@ final class Parser } } $res->items[] = $item; - $item->value = new \RectorPrefix20220607\Nette\Neon\Node\LiteralNode(null); + $item->value = new Node\LiteralNode(null); $this->injectPos($item->value); - if ($this->tokens->consume(\RectorPrefix20220607\Nette\Neon\Token::Newline)) { - while ($this->tokens->consume(\RectorPrefix20220607\Nette\Neon\Token::Newline)) { + if ($this->tokens->consume(Token::Newline)) { + while ($this->tokens->consume(Token::Newline)) { } $nextIndent = $this->tokens->getIndentation(); if (\strncmp($nextIndent, $indent, \min(\strlen($nextIndent), \strlen($indent)))) { @@ -76,16 +76,16 @@ final class Parser // open new block after dash } elseif ($this->tokens->isNext()) { $item->value = $this->parseValue(); - if ($this->tokens->isNext() && !$this->tokens->isNext(\RectorPrefix20220607\Nette\Neon\Token::Newline)) { + if ($this->tokens->isNext() && !$this->tokens->isNext(Token::Newline)) { $this->tokens->error(); } } - if ($item->value instanceof \RectorPrefix20220607\Nette\Neon\Node\BlockArrayNode) { + if ($item->value instanceof Node\BlockArrayNode) { $item->value->indentation = \substr($item->value->indentation, \strlen($indent)); } $this->injectPos($res, $res->startTokenPos, $item->value->endTokenPos); $this->injectPos($item, $item->startTokenPos, $item->value->endTokenPos); - while ($this->tokens->consume(\RectorPrefix20220607\Nette\Neon\Token::Newline)) { + while ($this->tokens->consume(Token::Newline)) { } if (!$this->tokens->isNext()) { return $res; @@ -101,18 +101,18 @@ final class Parser } goto loop; } - private function parseValue() : \RectorPrefix20220607\Nette\Neon\Node + private function parseValue() : Node { - if ($token = $this->tokens->consume(\RectorPrefix20220607\Nette\Neon\Token::String)) { + if ($token = $this->tokens->consume(Token::String)) { try { - $node = new \RectorPrefix20220607\Nette\Neon\Node\StringNode(\RectorPrefix20220607\Nette\Neon\Node\StringNode::parse($token->value)); + $node = new Node\StringNode(Node\StringNode::parse($token->value)); $this->injectPos($node, $this->tokens->getPos() - 1); - } catch (\RectorPrefix20220607\Nette\Neon\Exception $e) { + } catch (Exception $e) { $this->tokens->error($e->getMessage(), $this->tokens->getPos() - 1); } - } elseif ($token = $this->tokens->consume(\RectorPrefix20220607\Nette\Neon\Token::Literal)) { + } elseif ($token = $this->tokens->consume(Token::Literal)) { $pos = $this->tokens->getPos() - 1; - $node = new \RectorPrefix20220607\Nette\Neon\Node\LiteralNode(\RectorPrefix20220607\Nette\Neon\Node\LiteralNode::parse($token->value, $this->tokens->isNext(':', '='))); + $node = new Node\LiteralNode(Node\LiteralNode::parse($token->value, $this->tokens->isNext(':', '='))); $this->injectPos($node, $pos); } elseif ($this->tokens->isNext('[', '(', '{')) { $node = $this->parseBraces(); @@ -121,55 +121,55 @@ final class Parser } return $this->parseEntity($node); } - private function parseEntity(\RectorPrefix20220607\Nette\Neon\Node $node) : \RectorPrefix20220607\Nette\Neon\Node + private function parseEntity(Node $node) : Node { if (!$this->tokens->isNext('(')) { return $node; } $attributes = $this->parseBraces(); - $entities[] = $this->injectPos(new \RectorPrefix20220607\Nette\Neon\Node\EntityNode($node, $attributes->items), $node->startTokenPos, $attributes->endTokenPos); - while ($token = $this->tokens->consume(\RectorPrefix20220607\Nette\Neon\Token::Literal)) { - $valueNode = new \RectorPrefix20220607\Nette\Neon\Node\LiteralNode(\RectorPrefix20220607\Nette\Neon\Node\LiteralNode::parse($token->value)); + $entities[] = $this->injectPos(new Node\EntityNode($node, $attributes->items), $node->startTokenPos, $attributes->endTokenPos); + while ($token = $this->tokens->consume(Token::Literal)) { + $valueNode = new Node\LiteralNode(Node\LiteralNode::parse($token->value)); $this->injectPos($valueNode, $this->tokens->getPos() - 1); if ($this->tokens->isNext('(')) { $attributes = $this->parseBraces(); - $entities[] = $this->injectPos(new \RectorPrefix20220607\Nette\Neon\Node\EntityNode($valueNode, $attributes->items), $valueNode->startTokenPos, $attributes->endTokenPos); + $entities[] = $this->injectPos(new Node\EntityNode($valueNode, $attributes->items), $valueNode->startTokenPos, $attributes->endTokenPos); } else { - $entities[] = $this->injectPos(new \RectorPrefix20220607\Nette\Neon\Node\EntityNode($valueNode), $valueNode->startTokenPos); + $entities[] = $this->injectPos(new Node\EntityNode($valueNode), $valueNode->startTokenPos); break; } } - return \count($entities) === 1 ? $entities[0] : $this->injectPos(new \RectorPrefix20220607\Nette\Neon\Node\EntityChainNode($entities), $node->startTokenPos, \end($entities)->endTokenPos); + return \count($entities) === 1 ? $entities[0] : $this->injectPos(new Node\EntityChainNode($entities), $node->startTokenPos, \end($entities)->endTokenPos); } - private function parseBraces() : \RectorPrefix20220607\Nette\Neon\Node\InlineArrayNode + private function parseBraces() : Node\InlineArrayNode { $token = $this->tokens->consume(); $endBrace = ['[' => ']', '{' => '}', '(' => ')'][$token->value]; - $res = new \RectorPrefix20220607\Nette\Neon\Node\InlineArrayNode($token->value); + $res = new Node\InlineArrayNode($token->value); $this->injectPos($res, $this->tokens->getPos() - 1); $keyCheck = []; loop: - while ($this->tokens->consume(\RectorPrefix20220607\Nette\Neon\Token::Newline)) { + while ($this->tokens->consume(Token::Newline)) { } if ($this->tokens->consume($endBrace)) { $this->injectPos($res, $res->startTokenPos, $this->tokens->getPos() - 1); return $res; } - $res->items[] = $item = new \RectorPrefix20220607\Nette\Neon\Node\ArrayItemNode(); + $res->items[] = $item = new Node\ArrayItemNode(); $this->injectPos($item, $this->tokens->getPos()); $value = $this->parseValue(); if ($this->tokens->consume(':', '=')) { $this->checkArrayKey($value, $keyCheck); $item->key = $value; - $item->value = $this->tokens->isNext(\RectorPrefix20220607\Nette\Neon\Token::Newline, ',', $endBrace) ? $this->injectPos(new \RectorPrefix20220607\Nette\Neon\Node\LiteralNode(null), $this->tokens->getPos()) : $this->parseValue(); + $item->value = $this->tokens->isNext(Token::Newline, ',', $endBrace) ? $this->injectPos(new Node\LiteralNode(null), $this->tokens->getPos()) : $this->parseValue(); } else { $item->value = $value; } $this->injectPos($item, $item->startTokenPos, $item->value->endTokenPos); - if ($this->tokens->consume(',', \RectorPrefix20220607\Nette\Neon\Token::Newline)) { + if ($this->tokens->consume(',', Token::Newline)) { goto loop; } - while ($this->tokens->consume(\RectorPrefix20220607\Nette\Neon\Token::Newline)) { + while ($this->tokens->consume(Token::Newline)) { } if (!$this->tokens->isNext($endBrace)) { $this->tokens->error(); @@ -177,9 +177,9 @@ final class Parser goto loop; } /** @param true[] $arr */ - private function checkArrayKey(\RectorPrefix20220607\Nette\Neon\Node $key, array &$arr) : void + private function checkArrayKey(Node $key, array &$arr) : void { - if (!$key instanceof \RectorPrefix20220607\Nette\Neon\Node\StringNode && !$key instanceof \RectorPrefix20220607\Nette\Neon\Node\LiteralNode || !\is_scalar($key->value)) { + if (!$key instanceof Node\StringNode && !$key instanceof Node\LiteralNode || !\is_scalar($key->value)) { $this->tokens->error('Unacceptable key', $key->startTokenPos); } $k = (string) $key->value; @@ -188,7 +188,7 @@ final class Parser } $arr[$k] = \true; } - private function injectPos(\RectorPrefix20220607\Nette\Neon\Node $node, int $start = null, int $end = null) : \RectorPrefix20220607\Nette\Neon\Node + private function injectPos(Node $node, int $start = null, int $end = null) : Node { $node->startTokenPos = $start ?? $this->tokens->getPos(); $node->startLine = $this->posToLine[$node->startTokenPos]; diff --git a/vendor/nette/neon/src/Neon/TokenStream.php b/vendor/nette/neon/src/Neon/TokenStream.php index 635b8e56f11..f149fa0c8f8 100644 --- a/vendor/nette/neon/src/Neon/TokenStream.php +++ b/vendor/nette/neon/src/Neon/TokenStream.php @@ -29,18 +29,18 @@ final class TokenStream } public function isNext(...$types) : bool { - while (\in_array($this->tokens[$this->pos]->type ?? null, [\RectorPrefix20220607\Nette\Neon\Token::Comment, \RectorPrefix20220607\Nette\Neon\Token::Whitespace], \true)) { + while (\in_array($this->tokens[$this->pos]->type ?? null, [Token::Comment, Token::Whitespace], \true)) { $this->pos++; } return $types ? \in_array($this->tokens[$this->pos]->type ?? null, $types, \true) : isset($this->tokens[$this->pos]); } - public function consume(...$types) : ?\RectorPrefix20220607\Nette\Neon\Token + public function consume(...$types) : ?Token { return $this->isNext(...$types) ? $this->tokens[$this->pos++] : null; } public function getIndentation() : string { - return \in_array($this->tokens[$this->pos - 2]->type ?? null, [\RectorPrefix20220607\Nette\Neon\Token::Newline, null], \true) && ($this->tokens[$this->pos - 1]->type ?? null) === \RectorPrefix20220607\Nette\Neon\Token::Whitespace ? $this->tokens[$this->pos - 1]->value : ''; + return \in_array($this->tokens[$this->pos - 2]->type ?? null, [Token::Newline, null], \true) && ($this->tokens[$this->pos - 1]->type ?? null) === Token::Whitespace ? $this->tokens[$this->pos - 1]->value : ''; } /** @return never */ public function error(?string $message = null, ?int $pos = null) : void @@ -57,6 +57,6 @@ final class TokenStream $col = \strlen($input) - \strrpos("\n" . $input, "\n") + 1; $token = $this->tokens[$pos] ?? null; $message = $message ?? 'Unexpected ' . ($token === null ? 'end' : "'" . \str_replace("\n", '', \substr($this->tokens[$pos]->value, 0, 40)) . "'"); - throw new \RectorPrefix20220607\Nette\Neon\Exception("{$message} on line {$line}, column {$col}."); + throw new Exception("{$message} on line {$line}, column {$col}."); } } diff --git a/vendor/nette/neon/src/Neon/Traverser.php b/vendor/nette/neon/src/Neon/Traverser.php index d2d281af9cb..d957ca5583d 100644 --- a/vendor/nette/neon/src/Neon/Traverser.php +++ b/vendor/nette/neon/src/Neon/Traverser.php @@ -22,19 +22,19 @@ final class Traverser * @param callable(Node): (Node|int|null)|null $enter * @param callable(Node): (Node|int|null)|null $leave */ - public function traverse(\RectorPrefix20220607\Nette\Neon\Node $node, ?callable $enter = null, ?callable $leave = null) : \RectorPrefix20220607\Nette\Neon\Node + public function traverse(Node $node, ?callable $enter = null, ?callable $leave = null) : Node { $this->enter = $enter; $this->leave = $leave; $this->stop = \false; return $this->traverseNode($node); } - private function traverseNode(\RectorPrefix20220607\Nette\Neon\Node $node) : \RectorPrefix20220607\Nette\Neon\Node + private function traverseNode(Node $node) : Node { $children = \true; if ($this->enter) { $res = ($this->enter)($node); - if ($res instanceof \RectorPrefix20220607\Nette\Neon\Node) { + if ($res instanceof Node) { $node = $res; } elseif ($res === self::DontTraverseChildren) { $children = \false; @@ -53,7 +53,7 @@ final class Traverser } if (!$this->stop && $this->leave) { $res = ($this->leave)($node); - if ($res instanceof \RectorPrefix20220607\Nette\Neon\Node) { + if ($res instanceof Node) { $node = $res; } elseif ($res === self::StopTraversal) { $this->stop = \true; diff --git a/vendor/nette/utils/src/HtmlStringable.php b/vendor/nette/utils/src/HtmlStringable.php index 5d4c78d1d66..e2e29698ee6 100644 --- a/vendor/nette/utils/src/HtmlStringable.php +++ b/vendor/nette/utils/src/HtmlStringable.php @@ -14,4 +14,4 @@ interface HtmlStringable */ function __toString() : string; } -\interface_exists(\RectorPrefix20220607\Nette\Utils\IHtmlString::class); +\interface_exists(Utils\IHtmlString::class); diff --git a/vendor/nette/utils/src/Iterators/CachingIterator.php b/vendor/nette/utils/src/Iterators/CachingIterator.php index 3f2315f58ef..a83a82b50c9 100644 --- a/vendor/nette/utils/src/Iterators/CachingIterator.php +++ b/vendor/nette/utils/src/Iterators/CachingIterator.php @@ -38,7 +38,7 @@ class CachingIterator extends \CachingIterator implements \Countable } elseif ($iterator instanceof \Traversable) { $iterator = new \IteratorIterator($iterator); } else { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException(\sprintf('Invalid argument passed to %s; array or Traversable expected, %s given.', self::class, \is_object($iterator) ? \get_class($iterator) : \gettype($iterator))); + throw new Nette\InvalidArgumentException(\sprintf('Invalid argument passed to %s; array or Traversable expected, %s given.', self::class, \is_object($iterator) ? \get_class($iterator) : \gettype($iterator))); } parent::__construct($iterator, 0); } @@ -93,7 +93,7 @@ class CachingIterator extends \CachingIterator implements \Countable if ($inner instanceof \Countable) { return $inner->count(); } else { - throw new \RectorPrefix20220607\Nette\NotSupportedException('Iterator is not countable.'); + throw new Nette\NotSupportedException('Iterator is not countable.'); } } /** diff --git a/vendor/nette/utils/src/SmartObject.php b/vendor/nette/utils/src/SmartObject.php index b5b93c08b50..098a618a906 100644 --- a/vendor/nette/utils/src/SmartObject.php +++ b/vendor/nette/utils/src/SmartObject.php @@ -23,7 +23,7 @@ trait SmartObject public function __call(string $name, array $args) { $class = static::class; - if (\RectorPrefix20220607\Nette\Utils\ObjectHelpers::hasProperty($class, $name) === 'event') { + if (ObjectHelpers::hasProperty($class, $name) === 'event') { // calling event handlers $handlers = $this->{$name} ?? null; if (\is_iterable($handlers)) { @@ -31,10 +31,10 @@ trait SmartObject $handler(...$args); } } elseif ($handlers !== null) { - throw new \RectorPrefix20220607\Nette\UnexpectedValueException("Property {$class}::\${$name} must be iterable or null, " . \gettype($handlers) . ' given.'); + throw new UnexpectedValueException("Property {$class}::\${$name} must be iterable or null, " . \gettype($handlers) . ' given.'); } } else { - \RectorPrefix20220607\Nette\Utils\ObjectHelpers::strictCall($class, $name); + ObjectHelpers::strictCall($class, $name); } } /** @@ -42,7 +42,7 @@ trait SmartObject */ public static function __callStatic(string $name, array $args) { - \RectorPrefix20220607\Nette\Utils\ObjectHelpers::strictStaticCall(static::class, $name); + ObjectHelpers::strictStaticCall(static::class, $name); } /** * @return mixed @@ -51,10 +51,10 @@ trait SmartObject public function &__get(string $name) { $class = static::class; - if ($prop = \RectorPrefix20220607\Nette\Utils\ObjectHelpers::getMagicProperties($class)[$name] ?? null) { + if ($prop = ObjectHelpers::getMagicProperties($class)[$name] ?? null) { // property getter if (!($prop & 0b1)) { - throw new \RectorPrefix20220607\Nette\MemberAccessException("Cannot read a write-only property {$class}::\${$name}."); + throw new MemberAccessException("Cannot read a write-only property {$class}::\${$name}."); } $m = ($prop & 0b10 ? 'get' : 'is') . \ucfirst($name); if ($prop & 0b10000) { @@ -71,7 +71,7 @@ trait SmartObject return $val; } } else { - \RectorPrefix20220607\Nette\Utils\ObjectHelpers::strictGet($class, $name); + ObjectHelpers::strictGet($class, $name); } } /** @@ -82,13 +82,13 @@ trait SmartObject public function __set(string $name, $value) { $class = static::class; - if (\RectorPrefix20220607\Nette\Utils\ObjectHelpers::hasProperty($class, $name)) { + if (ObjectHelpers::hasProperty($class, $name)) { // unsetted property $this->{$name} = $value; - } elseif ($prop = \RectorPrefix20220607\Nette\Utils\ObjectHelpers::getMagicProperties($class)[$name] ?? null) { + } elseif ($prop = ObjectHelpers::getMagicProperties($class)[$name] ?? null) { // property setter if (!($prop & 0b1000)) { - throw new \RectorPrefix20220607\Nette\MemberAccessException("Cannot write to a read-only property {$class}::\${$name}."); + throw new MemberAccessException("Cannot write to a read-only property {$class}::\${$name}."); } $m = 'set' . \ucfirst($name); if ($prop & 0b10000) { @@ -99,7 +99,7 @@ trait SmartObject } $this->{$m}($value); } else { - \RectorPrefix20220607\Nette\Utils\ObjectHelpers::strictSet($class, $name); + ObjectHelpers::strictSet($class, $name); } } /** @@ -109,12 +109,12 @@ trait SmartObject public function __unset(string $name) { $class = static::class; - if (!\RectorPrefix20220607\Nette\Utils\ObjectHelpers::hasProperty($class, $name)) { - throw new \RectorPrefix20220607\Nette\MemberAccessException("Cannot unset the property {$class}::\${$name}."); + if (!ObjectHelpers::hasProperty($class, $name)) { + throw new MemberAccessException("Cannot unset the property {$class}::\${$name}."); } } public function __isset(string $name) : bool { - return isset(\RectorPrefix20220607\Nette\Utils\ObjectHelpers::getMagicProperties(static::class)[$name]); + return isset(ObjectHelpers::getMagicProperties(static::class)[$name]); } } diff --git a/vendor/nette/utils/src/StaticClass.php b/vendor/nette/utils/src/StaticClass.php index 6c86a01d2bb..494009388c4 100644 --- a/vendor/nette/utils/src/StaticClass.php +++ b/vendor/nette/utils/src/StaticClass.php @@ -27,6 +27,6 @@ trait StaticClass */ public static function __callStatic(string $name, array $args) { - \RectorPrefix20220607\Nette\Utils\ObjectHelpers::strictStaticCall(static::class, $name); + Utils\ObjectHelpers::strictStaticCall(static::class, $name); } } diff --git a/vendor/nette/utils/src/Translator.php b/vendor/nette/utils/src/Translator.php index 7fd61376206..1541757f215 100644 --- a/vendor/nette/utils/src/Translator.php +++ b/vendor/nette/utils/src/Translator.php @@ -19,4 +19,4 @@ interface Translator */ function translate($message, ...$parameters) : string; } -\interface_exists(\RectorPrefix20220607\Nette\Localization\ITranslator::class); +\interface_exists(ITranslator::class); diff --git a/vendor/nette/utils/src/Utils/ArrayHash.php b/vendor/nette/utils/src/Utils/ArrayHash.php index 58f0ec15da8..ba291535d94 100644 --- a/vendor/nette/utils/src/Utils/ArrayHash.php +++ b/vendor/nette/utils/src/Utils/ArrayHash.php @@ -51,7 +51,7 @@ class ArrayHash extends \stdClass implements \ArrayAccess, \Countable, \Iterator { if (!\is_scalar($key)) { // prevents null - throw new \RectorPrefix20220607\Nette\InvalidArgumentException(\sprintf('Key must be either a string or an integer, %s given.', \gettype($key))); + throw new Nette\InvalidArgumentException(\sprintf('Key must be either a string or an integer, %s given.', \gettype($key))); } $this->{$key} = $value; } diff --git a/vendor/nette/utils/src/Utils/ArrayList.php b/vendor/nette/utils/src/Utils/ArrayList.php index 4dae90784fa..4eb85e989f2 100644 --- a/vendor/nette/utils/src/Utils/ArrayList.php +++ b/vendor/nette/utils/src/Utils/ArrayList.php @@ -24,8 +24,8 @@ class ArrayList implements \ArrayAccess, \Countable, \IteratorAggregate */ public static function from(array $array) { - if (!\RectorPrefix20220607\Nette\Utils\Arrays::isList($array)) { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException('Array is not valid list.'); + if (!Arrays::isList($array)) { + throw new Nette\InvalidArgumentException('Array is not valid list.'); } $obj = new static(); $obj->list = $array; @@ -57,7 +57,7 @@ class ArrayList implements \ArrayAccess, \Countable, \IteratorAggregate if ($index === null) { $this->list[] = $value; } elseif (!\is_int($index) || $index < 0 || $index >= \count($this->list)) { - throw new \RectorPrefix20220607\Nette\OutOfRangeException('Offset invalid or out of range'); + throw new Nette\OutOfRangeException('Offset invalid or out of range'); } else { $this->list[$index] = $value; } @@ -72,7 +72,7 @@ class ArrayList implements \ArrayAccess, \Countable, \IteratorAggregate public function offsetGet($index) { if (!\is_int($index) || $index < 0 || $index >= \count($this->list)) { - throw new \RectorPrefix20220607\Nette\OutOfRangeException('Offset invalid or out of range'); + throw new Nette\OutOfRangeException('Offset invalid or out of range'); } return $this->list[$index]; } @@ -92,7 +92,7 @@ class ArrayList implements \ArrayAccess, \Countable, \IteratorAggregate public function offsetUnset($index) : void { if (!\is_int($index) || $index < 0 || $index >= \count($this->list)) { - throw new \RectorPrefix20220607\Nette\OutOfRangeException('Offset invalid or out of range'); + throw new Nette\OutOfRangeException('Offset invalid or out of range'); } \array_splice($this->list, $index, 1); } diff --git a/vendor/nette/utils/src/Utils/Arrays.php b/vendor/nette/utils/src/Utils/Arrays.php index 9cc2b449492..5afeb21a256 100644 --- a/vendor/nette/utils/src/Utils/Arrays.php +++ b/vendor/nette/utils/src/Utils/Arrays.php @@ -26,12 +26,12 @@ class Arrays */ public static function get(array $array, $key, $default = null) { - foreach (\is_array($key) ? $key : [$key] as $k) { - if (\is_array($array) && \array_key_exists($k, $array)) { + foreach (is_array($key) ? $key : [$key] as $k) { + if (is_array($array) && \array_key_exists($k, $array)) { $array = $array[$k]; } else { if (\func_num_args() < 3) { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException("Missing item '{$k}'."); + throw new Nette\InvalidArgumentException("Missing item '{$k}'."); } return $default; } @@ -48,11 +48,11 @@ class Arrays */ public static function &getRef(array &$array, $key) { - foreach (\is_array($key) ? $key : [$key] as $k) { - if (\is_array($array) || $array === null) { + foreach (is_array($key) ? $key : [$key] as $k) { + if (is_array($array) || $array === null) { $array =& $array[$k]; } else { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException('Traversed item is not an array.'); + throw new Nette\InvalidArgumentException('Traversed item is not an array.'); } } return $array; @@ -71,7 +71,7 @@ class Arrays { $res = $array1 + $array2; foreach (\array_intersect_key($array1, $array2) as $k => $v) { - if (\is_array($v) && \is_array($array2[$k])) { + if (is_array($v) && is_array($array2[$k])) { $res[$k] = self::mergeTree($v, $array2[$k]); } } @@ -84,7 +84,7 @@ class Arrays */ public static function getKeyOffset(array $array, $key) : ?int { - return \RectorPrefix20220607\Nette\Utils\Helpers::falseToNull(\array_search(self::toKey($key), \array_keys($array), \true)); + return Helpers::falseToNull(\array_search(self::toKey($key), \array_keys($array), \true)); } /** * @deprecated use getKeyOffset() @@ -109,7 +109,7 @@ class Arrays */ public static function first(array $array) { - return \count($array) ? \reset($array) : null; + return count($array) ? \reset($array) : null; } /** * Returns the last item from the array or null if array is empty. @@ -119,7 +119,7 @@ class Arrays */ public static function last(array $array) { - return \count($array) ? \end($array) : null; + return count($array) ? \end($array) : null; } /** * Inserts the contents of the $inserted array into the $array immediately after the $key. @@ -129,7 +129,7 @@ class Arrays public static function insertBefore(array &$array, $key, array $inserted) : void { $offset = $key === null ? 0 : (int) self::getKeyOffset($array, $key); - $array = \array_slice($array, 0, $offset, \true) + $inserted + \array_slice($array, $offset, \count($array), \true); + $array = \array_slice($array, 0, $offset, \true) + $inserted + \array_slice($array, $offset, count($array), \true); } /** * Inserts the contents of the $inserted array into the $array before the $key. @@ -139,9 +139,9 @@ class Arrays public static function insertAfter(array &$array, $key, array $inserted) : void { if ($key === null || ($offset = self::getKeyOffset($array, $key)) === null) { - $offset = \count($array) - 1; + $offset = count($array) - 1; } - $array = \array_slice($array, 0, $offset + 1, \true) + $inserted + \array_slice($array, $offset + 1, \count($array), \true); + $array = \array_slice($array, 0, $offset + 1, \true) + $inserted + \array_slice($array, $offset + 1, count($array), \true); } /** * Renames key in array. @@ -168,7 +168,7 @@ class Arrays */ public static function grep(array $array, string $pattern, int $flags = 0) : array { - return \RectorPrefix20220607\Nette\Utils\Strings::pcre('preg_grep', [$pattern, $array, $flags]); + return Strings::pcre('preg_grep', [$pattern, $array, $flags]); } /** * Transforms multidimensional array to flat array. @@ -191,8 +191,8 @@ class Arrays public static function isList($value) : bool { $arrayIsList = function (array $array) : bool { - if (\function_exists('RectorPrefix20220607\\array_is_list')) { - return array_is_list($array); + if (\function_exists('array_is_list')) { + return \array_is_list($array); } if ($array === []) { return \true; @@ -206,7 +206,7 @@ class Arrays } return \true; }; - return \is_array($value) && (\PHP_VERSION_ID < 80100 ? !$value || \array_keys($value) === \range(0, \count($value) - 1) : $arrayIsList($value)); + return is_array($value) && (\PHP_VERSION_ID < 80100 ? !$value || \array_keys($value) === \range(0, count($value) - 1) : $arrayIsList($value)); } /** * Reformats table to associative tree. Path looks like 'field|field[]field->field=field'. @@ -215,15 +215,15 @@ class Arrays */ public static function associate(array $array, $path) { - $parts = \is_array($path) ? $path : \preg_split('#(\\[\\]|->|=|\\|)#', $path, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY); + $parts = is_array($path) ? $path : \preg_split('#(\\[\\]|->|=|\\|)#', $path, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY); if (!$parts || $parts === ['->'] || $parts[0] === '=' || $parts[0] === '|') { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException("Invalid path '{$path}'."); + throw new Nette\InvalidArgumentException("Invalid path '{$path}'."); } $res = $parts[0] === '->' ? new \stdClass() : []; foreach ($array as $rowOrig) { $row = (array) $rowOrig; $x =& $res; - for ($i = 0; $i < \count($parts); $i++) { + for ($i = 0; $i < count($parts); $i++) { $part = $parts[$i]; if ($part === '[]') { $x =& $x[]; @@ -239,7 +239,7 @@ class Arrays } $x =& $x->{$row[$parts[$i]]}; } else { - $row = \is_object($rowOrig) ? $rowOrig : (object) $row; + $row = is_object($rowOrig) ? $rowOrig : (object) $row; } } elseif ($part !== '|') { $x =& $x[(string) $row[$part]]; @@ -259,7 +259,7 @@ class Arrays { $res = []; foreach ($array as $k => $v) { - $res[\is_int($k) ? $v : $k] = \is_int($k) ? $filling : $v; + $res[is_int($k) ? $v : $k] = is_int($k) ? $filling : $v; } return $res; } @@ -280,7 +280,7 @@ class Arrays unset($array[$key]); return $value; } elseif (\func_num_args() < 3) { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException("Missing item '{$key}'."); + throw new Nette\InvalidArgumentException("Missing item '{$key}'."); } else { return $default; } diff --git a/vendor/nette/utils/src/Utils/Callback.php b/vendor/nette/utils/src/Utils/Callback.php index bcb7763bc2c..b84996d042b 100644 --- a/vendor/nette/utils/src/Utils/Callback.php +++ b/vendor/nette/utils/src/Utils/Callback.php @@ -25,7 +25,7 @@ final class Callback try { return \Closure::fromCallable($method === null ? $callable : [$callable, $method]); } catch (\TypeError $e) { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException($e->getMessage()); + throw new Nette\InvalidArgumentException($e->getMessage()); } } /** @@ -58,7 +58,7 @@ final class Callback { $prev = \set_error_handler(function ($severity, $message, $file) use($onError, &$prev, $function) : ?bool { if ($file === __FILE__) { - $msg = \ini_get('html_errors') ? \RectorPrefix20220607\Nette\Utils\Html::htmlToText($message) : $message; + $msg = \ini_get('html_errors') ? Html::htmlToText($message) : $message; $msg = \preg_replace("#^{$function}\\(.*?\\): #", '', $msg); if ($onError($msg, $severity) !== \false) { return null; @@ -82,7 +82,7 @@ final class Callback public static function check($callable, bool $syntax = \false) { if (!\is_callable($callable, $syntax)) { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException($syntax ? 'Given value is not a callable type.' : \sprintf("Callback '%s' is not callable.", self::toString($callable))); + throw new Nette\InvalidArgumentException($syntax ? 'Given value is not a callable type.' : \sprintf("Callback '%s' is not callable.", self::toString($callable))); } return $callable; } @@ -95,10 +95,10 @@ final class Callback if ($callable instanceof \Closure) { $inner = self::unwrap($callable); return '{closure' . ($inner instanceof \Closure ? '}' : ' ' . self::toString($inner) . '}'); - } elseif (\is_string($callable) && $callable[0] === "\0") { + } elseif (is_string($callable) && $callable[0] === "\x00") { return '{lambda}'; } else { - \is_callable(\is_object($callable) ? [$callable, '__invoke'] : $callable, \true, $textual); + \is_callable(is_object($callable) ? [$callable, '__invoke'] : $callable, \true, $textual); return $textual; } } @@ -113,11 +113,11 @@ final class Callback if ($callable instanceof \Closure) { $callable = self::unwrap($callable); } - if (\is_string($callable) && \strpos($callable, '::')) { + if (is_string($callable) && \strpos($callable, '::')) { return new \ReflectionMethod($callable); - } elseif (\is_array($callable)) { + } elseif (is_array($callable)) { return new \ReflectionMethod($callable[0], $callable[1]); - } elseif (\is_object($callable) && !$callable instanceof \Closure) { + } elseif (is_object($callable) && !$callable instanceof \Closure) { return new \ReflectionMethod($callable, '__invoke'); } else { return new \ReflectionFunction($callable); @@ -128,7 +128,7 @@ final class Callback */ public static function isStatic(callable $callable) : bool { - return \is_array($callable) ? \is_string($callable[0]) : \is_string($callable); + return is_array($callable) ? is_string($callable[0]) : is_string($callable); } /** * Unwraps closure created by Closure::fromCallable(). diff --git a/vendor/nette/utils/src/Utils/DateTime.php b/vendor/nette/utils/src/Utils/DateTime.php index 59842a13f48..d117f1a1a2a 100644 --- a/vendor/nette/utils/src/Utils/DateTime.php +++ b/vendor/nette/utils/src/Utils/DateTime.php @@ -55,7 +55,7 @@ class DateTime extends \DateTime implements \JsonSerializable { $s = \sprintf('%04d-%02d-%02d %02d:%02d:%02.5F', $year, $month, $day, $hour, $minute, $second); if (!\checkdate($month, $day, $year) || $hour < 0 || $hour > 23 || $minute < 0 || $minute > 59 || $second < 0 || $second >= 60) { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException("Invalid date '{$s}'"); + throw new Nette\InvalidArgumentException("Invalid date '{$s}'"); } return new static($s); } @@ -74,7 +74,7 @@ class DateTime extends \DateTime implements \JsonSerializable } elseif (\is_string($timezone)) { $timezone = new \DateTimeZone($timezone); } elseif (!$timezone instanceof \DateTimeZone) { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException('Invalid timezone given'); + throw new Nette\InvalidArgumentException('Invalid timezone given'); } $date = parent::createFromFormat($format, $time, $timezone); return $date ? static::from($date) : \false; diff --git a/vendor/nette/utils/src/Utils/FileSystem.php b/vendor/nette/utils/src/Utils/FileSystem.php index e2079d86b58..f70dddbdf7a 100644 --- a/vendor/nette/utils/src/Utils/FileSystem.php +++ b/vendor/nette/utils/src/Utils/FileSystem.php @@ -22,7 +22,7 @@ final class FileSystem { if (!\is_dir($dir) && !@\mkdir($dir, $mode, \true) && !\is_dir($dir)) { // @ - dir may already exist - throw new \RectorPrefix20220607\Nette\IOException(\sprintf("Unable to create directory '%s' with mode %s. %s", self::normalizePath($dir), \decoct($mode), \RectorPrefix20220607\Nette\Utils\Helpers::getLastError())); + throw new Nette\IOException(\sprintf("Unable to create directory '%s' with mode %s. %s", self::normalizePath($dir), \decoct($mode), Helpers::getLastError())); } } /** @@ -33,9 +33,9 @@ final class FileSystem public static function copy(string $origin, string $target, bool $overwrite = \true) : void { if (\stream_is_local($origin) && !\file_exists($origin)) { - throw new \RectorPrefix20220607\Nette\IOException(\sprintf("File or directory '%s' not found.", self::normalizePath($origin))); + throw new Nette\IOException(\sprintf("File or directory '%s' not found.", self::normalizePath($origin))); } elseif (!$overwrite && \file_exists($target)) { - throw new \RectorPrefix20220607\Nette\InvalidStateException(\sprintf("File or directory '%s' already exists.", self::normalizePath($target))); + throw new Nette\InvalidStateException(\sprintf("File or directory '%s' already exists.", self::normalizePath($target))); } elseif (\is_dir($origin)) { static::createDir($target); foreach (new \FilesystemIterator($target) as $item) { @@ -52,7 +52,7 @@ final class FileSystem static::createDir(\dirname($target)); if (($s = @\fopen($origin, 'rb')) && ($d = @\fopen($target, 'wb')) && @\stream_copy_to_stream($s, $d) === \false) { // @ is escalated to exception - throw new \RectorPrefix20220607\Nette\IOException(\sprintf("Unable to copy file '%s' to '%s'. %s", self::normalizePath($origin), self::normalizePath($target), \RectorPrefix20220607\Nette\Utils\Helpers::getLastError())); + throw new Nette\IOException(\sprintf("Unable to copy file '%s' to '%s'. %s", self::normalizePath($origin), self::normalizePath($target), Helpers::getLastError())); } } } @@ -66,7 +66,7 @@ final class FileSystem $func = \DIRECTORY_SEPARATOR === '\\' && \is_dir($path) ? 'rmdir' : 'unlink'; if (!@$func($path)) { // @ is escalated to exception - throw new \RectorPrefix20220607\Nette\IOException(\sprintf("Unable to delete '%s'. %s", self::normalizePath($path), \RectorPrefix20220607\Nette\Utils\Helpers::getLastError())); + throw new Nette\IOException(\sprintf("Unable to delete '%s'. %s", self::normalizePath($path), Helpers::getLastError())); } } elseif (\is_dir($path)) { foreach (new \FilesystemIterator($path) as $item) { @@ -74,7 +74,7 @@ final class FileSystem } if (!@\rmdir($path)) { // @ is escalated to exception - throw new \RectorPrefix20220607\Nette\IOException(\sprintf("Unable to delete directory '%s'. %s", self::normalizePath($path), \RectorPrefix20220607\Nette\Utils\Helpers::getLastError())); + throw new Nette\IOException(\sprintf("Unable to delete directory '%s'. %s", self::normalizePath($path), Helpers::getLastError())); } } } @@ -86,9 +86,9 @@ final class FileSystem public static function rename(string $origin, string $target, bool $overwrite = \true) : void { if (!$overwrite && \file_exists($target)) { - throw new \RectorPrefix20220607\Nette\InvalidStateException(\sprintf("File or directory '%s' already exists.", self::normalizePath($target))); + throw new Nette\InvalidStateException(\sprintf("File or directory '%s' already exists.", self::normalizePath($target))); } elseif (!\file_exists($origin)) { - throw new \RectorPrefix20220607\Nette\IOException(\sprintf("File or directory '%s' not found.", self::normalizePath($origin))); + throw new Nette\IOException(\sprintf("File or directory '%s' not found.", self::normalizePath($origin))); } else { static::createDir(\dirname($target)); if (\realpath($origin) !== \realpath($target)) { @@ -96,7 +96,7 @@ final class FileSystem } if (!@\rename($origin, $target)) { // @ is escalated to exception - throw new \RectorPrefix20220607\Nette\IOException(\sprintf("Unable to rename file or directory '%s' to '%s'. %s", self::normalizePath($origin), self::normalizePath($target), \RectorPrefix20220607\Nette\Utils\Helpers::getLastError())); + throw new Nette\IOException(\sprintf("Unable to rename file or directory '%s' to '%s'. %s", self::normalizePath($origin), self::normalizePath($target), Helpers::getLastError())); } } } @@ -109,7 +109,7 @@ final class FileSystem $content = @\file_get_contents($file); // @ is escalated to exception if ($content === \false) { - throw new \RectorPrefix20220607\Nette\IOException(\sprintf("Unable to read file '%s'. %s", self::normalizePath($file), \RectorPrefix20220607\Nette\Utils\Helpers::getLastError())); + throw new Nette\IOException(\sprintf("Unable to read file '%s'. %s", self::normalizePath($file), Helpers::getLastError())); } return $content; } @@ -122,11 +122,11 @@ final class FileSystem static::createDir(\dirname($file)); if (@\file_put_contents($file, $content) === \false) { // @ is escalated to exception - throw new \RectorPrefix20220607\Nette\IOException(\sprintf("Unable to write file '%s'. %s", self::normalizePath($file), \RectorPrefix20220607\Nette\Utils\Helpers::getLastError())); + throw new Nette\IOException(\sprintf("Unable to write file '%s'. %s", self::normalizePath($file), Helpers::getLastError())); } if ($mode !== null && !@\chmod($file, $mode)) { // @ is escalated to exception - throw new \RectorPrefix20220607\Nette\IOException(\sprintf("Unable to chmod file '%s' to mode %s. %s", self::normalizePath($file), \decoct($mode), \RectorPrefix20220607\Nette\Utils\Helpers::getLastError())); + throw new Nette\IOException(\sprintf("Unable to chmod file '%s' to mode %s. %s", self::normalizePath($file), \decoct($mode), Helpers::getLastError())); } } /** @@ -138,7 +138,7 @@ final class FileSystem if (\is_file($path)) { if (!@\chmod($path, $fileMode)) { // @ is escalated to exception - throw new \RectorPrefix20220607\Nette\IOException(\sprintf("Unable to chmod file '%s' to mode %s. %s", self::normalizePath($path), \decoct($fileMode), \RectorPrefix20220607\Nette\Utils\Helpers::getLastError())); + throw new Nette\IOException(\sprintf("Unable to chmod file '%s' to mode %s. %s", self::normalizePath($path), \decoct($fileMode), Helpers::getLastError())); } } elseif (\is_dir($path)) { foreach (new \FilesystemIterator($path) as $item) { @@ -146,10 +146,10 @@ final class FileSystem } if (!@\chmod($path, $dirMode)) { // @ is escalated to exception - throw new \RectorPrefix20220607\Nette\IOException(\sprintf("Unable to chmod directory '%s' to mode %s. %s", self::normalizePath($path), \decoct($dirMode), \RectorPrefix20220607\Nette\Utils\Helpers::getLastError())); + throw new Nette\IOException(\sprintf("Unable to chmod directory '%s' to mode %s. %s", self::normalizePath($path), \decoct($dirMode), Helpers::getLastError())); } } else { - throw new \RectorPrefix20220607\Nette\IOException(\sprintf("File or directory '%s' not found.", self::normalizePath($path))); + throw new Nette\IOException(\sprintf("File or directory '%s' not found.", self::normalizePath($path))); } } /** diff --git a/vendor/nette/utils/src/Utils/Helpers.php b/vendor/nette/utils/src/Utils/Helpers.php index 2fcf104fa80..2dae587f127 100644 --- a/vendor/nette/utils/src/Utils/Helpers.php +++ b/vendor/nette/utils/src/Utils/Helpers.php @@ -32,7 +32,7 @@ class Helpers public static function getLastError() : string { $message = \error_get_last()['message'] ?? ''; - $message = \ini_get('html_errors') ? \RectorPrefix20220607\Nette\Utils\Html::htmlToText($message) : $message; + $message = \ini_get('html_errors') ? Html::htmlToText($message) : $message; $message = \preg_replace('#^\\w+\\(.*?\\): #', '', $message); return $message; } @@ -55,7 +55,7 @@ class Helpers public static function clamp($value, $min, $max) { if ($min > $max) { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException("Minimum ({$min}) is not less than maximum ({$max})."); + throw new Nette\InvalidArgumentException("Minimum ({$min}) is not less than maximum ({$max})."); } return \min(\max($value, $min), $max); } diff --git a/vendor/nette/utils/src/Utils/Html.php b/vendor/nette/utils/src/Utils/Html.php index bdece5caaa9..c501a6aeccc 100644 --- a/vendor/nette/utils/src/Utils/Html.php +++ b/vendor/nette/utils/src/Utils/Html.php @@ -227,7 +227,7 @@ use function is_array, is_float, is_object, is_string; * @method self width(?int $val) * @method self wrap(?string $val) */ -class Html implements \ArrayAccess, \Countable, \IteratorAggregate, \RectorPrefix20220607\Nette\HtmlStringable +class Html implements \ArrayAccess, \Countable, \IteratorAggregate, HtmlStringable { use Nette\SmartObject; /** @var array element's attributes */ @@ -252,13 +252,13 @@ class Html implements \ArrayAccess, \Countable, \IteratorAggregate, \RectorPrefi $el = new static(); $parts = \explode(' ', (string) $name, 2); $el->setName($parts[0]); - if (\is_array($attrs)) { + if (is_array($attrs)) { $el->attrs = $attrs; } elseif ($attrs !== null) { $el->setText($attrs); } if (isset($parts[1])) { - foreach (\RectorPrefix20220607\Nette\Utils\Strings::matchAll($parts[1] . ' ', '#([a-z0-9:-]+)(?:=(["\'])?(.*?)(?(2)\\2|\\s))?#i') as $m) { + foreach (Strings::matchAll($parts[1] . ' ', '#([a-z0-9:-]+)(?:=(["\'])?(.*?)(?(2)\\2|\\s))?#i') as $m) { $el->attrs[$m[1]] = $m[3] ?? \true; } } @@ -340,13 +340,13 @@ class Html implements \ArrayAccess, \Countable, \IteratorAggregate, \RectorPrefi */ public function appendAttribute(string $name, $value, $option = \true) { - if (\is_array($value)) { + if (is_array($value)) { $prev = isset($this->attrs[$name]) ? (array) $this->attrs[$name] : []; $this->attrs[$name] = $value + $prev; } elseif ((string) $value === '') { $tmp =& $this->attrs[$name]; // appending empty value? -> ignore, but ensure it exists - } elseif (!isset($this->attrs[$name]) || \is_array($this->attrs[$name])) { + } elseif (!isset($this->attrs[$name]) || is_array($this->attrs[$name])) { // needs array $this->attrs[$name][$value] = $option; } else { @@ -502,7 +502,7 @@ class Html implements \ArrayAccess, \Countable, \IteratorAggregate, \RectorPrefi */ public final function setText($text) { - if (!$text instanceof \RectorPrefix20220607\Nette\HtmlStringable) { + if (!$text instanceof HtmlStringable) { $text = \htmlspecialchars((string) $text, \ENT_NOQUOTES, 'UTF-8'); } $this->children = [(string) $text]; @@ -531,7 +531,7 @@ class Html implements \ArrayAccess, \Countable, \IteratorAggregate, \RectorPrefi */ public function addText($text) { - if (!$text instanceof \RectorPrefix20220607\Nette\HtmlStringable) { + if (!$text instanceof HtmlStringable) { $text = \htmlspecialchars((string) $text, \ENT_NOQUOTES, 'UTF-8'); } return $this->insert(null, $text); @@ -687,7 +687,7 @@ class Html implements \ArrayAccess, \Countable, \IteratorAggregate, \RectorPrefi */ public final function attributes() : string { - if (!\is_array($this->attrs)) { + if (!is_array($this->attrs)) { return ''; } $s = ''; @@ -702,16 +702,16 @@ class Html implements \ArrayAccess, \Countable, \IteratorAggregate, \RectorPrefi $s .= ' ' . $key; } continue; - } elseif (\is_array($value)) { + } elseif (is_array($value)) { if (\strncmp($key, 'data-', 5) === 0) { - $value = \RectorPrefix20220607\Nette\Utils\Json::encode($value); + $value = Json::encode($value); } else { $tmp = null; foreach ($value as $k => $v) { if ($v != null) { // intentionally ==, skip nulls & empty string // composite 'style' vs. 'others' - $tmp[] = $v === \true ? $k : (\is_string($k) ? $k . ':' . $v : $v); + $tmp[] = $v === \true ? $k : (is_string($k) ? $k . ':' . $v : $v); } } if ($tmp === null) { @@ -719,7 +719,7 @@ class Html implements \ArrayAccess, \Countable, \IteratorAggregate, \RectorPrefi } $value = \implode($key === 'style' || !\strncmp($key, 'on', 2) ? ';' : ' ', $tmp); } - } elseif (\is_float($value)) { + } elseif (is_float($value)) { $value = \rtrim(\rtrim(\number_format($value, 10, '.', ''), '0'), '.'); } else { $value = (string) $value; @@ -736,7 +736,7 @@ class Html implements \ArrayAccess, \Countable, \IteratorAggregate, \RectorPrefi public function __clone() { foreach ($this->children as $key => $value) { - if (\is_object($value)) { + if (is_object($value)) { $this->children[$key] = clone $value; } } diff --git a/vendor/nette/utils/src/Utils/Image.php b/vendor/nette/utils/src/Utils/Image.php index 7a51abfcf4c..f44b7d33843 100644 --- a/vendor/nette/utils/src/Utils/Image.php +++ b/vendor/nette/utils/src/Utils/Image.php @@ -105,7 +105,7 @@ class Image public const EXACT = 0b1000; /** image types */ public const JPEG = \IMAGETYPE_JPEG, PNG = \IMAGETYPE_PNG, GIF = \IMAGETYPE_GIF, WEBP = \IMAGETYPE_WEBP, AVIF = 19, BMP = \IMAGETYPE_BMP; - public const EMPTY_GIF = "GIF89a\1\0\1\0€\0\0\0\0\0\0\0\0!ù\4\1\0\0\0\0,\0\0\0\0\1\0\1\0\0\2\2D\1\0;"; + public const EMPTY_GIF = "GIF89a\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00!\xf9\x04\x01\x00\x00\x00\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02D\x01\x00;"; private const FORMATS = [self::JPEG => 'jpeg', self::PNG => 'png', self::GIF => 'gif', self::WEBP => 'webp', self::AVIF => 'avif', self::BMP => 'bmp']; /** @var resource|\GdImage */ private $image; @@ -125,11 +125,11 @@ class Image public static function fromFile(string $file, ?int &$type = null) { if (!\extension_loaded('gd')) { - throw new \RectorPrefix20220607\Nette\NotSupportedException('PHP extension GD is not loaded.'); + throw new Nette\NotSupportedException('PHP extension GD is not loaded.'); } $type = self::detectTypeFromFile($file); if (!$type) { - throw new \RectorPrefix20220607\Nette\Utils\UnknownImageFileException(\is_file($file) ? "Unknown type of file '{$file}'." : "File '{$file}' not found."); + throw new UnknownImageFileException(\is_file($file) ? "Unknown type of file '{$file}'." : "File '{$file}' not found."); } return self::invokeSafe('imagecreatefrom' . self::FORMATS[$type], $file, "Unable to open file '{$file}'.", __METHOD__); } @@ -142,22 +142,22 @@ class Image public static function fromString(string $s, ?int &$type = null) { if (!\extension_loaded('gd')) { - throw new \RectorPrefix20220607\Nette\NotSupportedException('PHP extension GD is not loaded.'); + throw new Nette\NotSupportedException('PHP extension GD is not loaded.'); } $type = self::detectTypeFromString($s); if (!$type) { - throw new \RectorPrefix20220607\Nette\Utils\UnknownImageFileException('Unknown type of image.'); + throw new UnknownImageFileException('Unknown type of image.'); } return self::invokeSafe('imagecreatefromstring', $s, 'Unable to open image from string.', __METHOD__); } private static function invokeSafe(string $func, string $arg, string $message, string $callee) : self { $errors = []; - $res = \RectorPrefix20220607\Nette\Utils\Callback::invokeSafe($func, [$arg], function (string $message) use(&$errors) : void { + $res = Callback::invokeSafe($func, [$arg], function (string $message) use(&$errors) : void { $errors[] = $message; }); if (!$res) { - throw new \RectorPrefix20220607\Nette\Utils\ImageException($message . ' Errors: ' . \implode(', ', $errors)); + throw new ImageException($message . ' Errors: ' . \implode(', ', $errors)); } elseif ($errors) { \trigger_error($callee . '(): ' . \implode(', ', $errors), \E_USER_WARNING); } @@ -171,10 +171,10 @@ class Image public static function fromBlank(int $width, int $height, ?array $color = null) { if (!\extension_loaded('gd')) { - throw new \RectorPrefix20220607\Nette\NotSupportedException('PHP extension GD is not loaded.'); + throw new Nette\NotSupportedException('PHP extension GD is not loaded.'); } if ($width < 1 || $height < 1) { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException('Image width and height must be greater than zero.'); + throw new Nette\InvalidArgumentException('Image width and height must be greater than zero.'); } $image = \imagecreatetruecolor($width, $height); if ($color) { @@ -210,7 +210,7 @@ class Image public static function typeToExtension(int $type) : string { if (!isset(self::FORMATS[$type])) { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException("Unsupported image type '{$type}'."); + throw new Nette\InvalidArgumentException("Unsupported image type '{$type}'."); } return self::FORMATS[$type]; } @@ -252,7 +252,7 @@ class Image protected function setImageResource($image) { if (!$image instanceof \GdImage && !(\is_resource($image) && \get_resource_type($image) === 'gd')) { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException('Image is not valid.'); + throw new Nette\InvalidArgumentException('Image is not valid.'); } $this->image = $image; return $this; @@ -312,7 +312,7 @@ class Image if ($flags & self::STRETCH) { // non-proportional if (!$newWidth || !$newHeight) { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException('For stretching must be both width and height specified.'); + throw new Nette\InvalidArgumentException('For stretching must be both width and height specified.'); } if ($flags & self::SHRINK_ONLY) { $newWidth = (int) \round($srcWidth * \min(1, $newWidth / $srcWidth)); @@ -321,7 +321,7 @@ class Image } else { // proportional if (!$newWidth && !$newHeight) { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException('At least width or height must be specified.'); + throw new Nette\InvalidArgumentException('At least width or height must be specified.'); } $scale = []; if ($newWidth > 0) { @@ -468,7 +468,7 @@ class Image $extensions = \array_flip(self::FORMATS) + ['jpg' => self::JPEG]; $ext = \strtolower(\pathinfo($file, \PATHINFO_EXTENSION)); if (!isset($extensions[$ext])) { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException("Unsupported file extension '{$ext}'."); + throw new Nette\InvalidArgumentException("Unsupported file extension '{$ext}'."); } $type = $extensions[$ext]; } @@ -479,7 +479,7 @@ class Image */ public function toString(int $type = self::JPEG, ?int $quality = null) : string { - return \RectorPrefix20220607\Nette\Utils\Helpers::capture(function () use($type, $quality) { + return Helpers::capture(function () use($type, $quality) { $this->output($type, $quality); }); } @@ -543,10 +543,10 @@ class Image // @ is escalated to exception break; default: - throw new \RectorPrefix20220607\Nette\InvalidArgumentException("Unsupported image type '{$type}'."); + throw new Nette\InvalidArgumentException("Unsupported image type '{$type}'."); } if (!$success) { - throw new \RectorPrefix20220607\Nette\Utils\ImageException(\RectorPrefix20220607\Nette\Utils\Helpers::getLastError() ?: 'Unknown error'); + throw new ImageException(Helpers::getLastError() ?: 'Unknown error'); } } /** @@ -558,7 +558,7 @@ class Image { $function = 'image' . $name; if (!\function_exists($function)) { - \RectorPrefix20220607\Nette\Utils\ObjectHelpers::strictCall(static::class, $name); + ObjectHelpers::strictCall(static::class, $name); } foreach ($args as $key => $value) { if ($value instanceof self) { @@ -590,13 +590,13 @@ class Image $num = (int) $num; return \false; } - throw new \RectorPrefix20220607\Nette\InvalidArgumentException("Expected dimension in int|string, '{$num}' given."); + throw new Nette\InvalidArgumentException("Expected dimension in int|string, '{$num}' given."); } /** * Prevents serialization. */ public function __sleep() : array { - throw new \RectorPrefix20220607\Nette\NotSupportedException('You cannot serialize or unserialize ' . self::class . ' instances.'); + throw new Nette\NotSupportedException('You cannot serialize or unserialize ' . self::class . ' instances.'); } } diff --git a/vendor/nette/utils/src/Utils/Json.php b/vendor/nette/utils/src/Utils/Json.php index 842dc1bb407..4043d4bedf4 100644 --- a/vendor/nette/utils/src/Utils/Json.php +++ b/vendor/nette/utils/src/Utils/Json.php @@ -29,7 +29,7 @@ final class Json // since PHP 5.6.6 & PECL JSON-C 1.3.7 $json = \json_encode($value, $flags); if ($error = \json_last_error()) { - throw new \RectorPrefix20220607\Nette\Utils\JsonException(\json_last_error_msg(), $error); + throw new JsonException(\json_last_error_msg(), $error); } return $json; } @@ -42,7 +42,7 @@ final class Json { $value = \json_decode($json, null, 512, $flags | \JSON_BIGINT_AS_STRING); if ($error = \json_last_error()) { - throw new \RectorPrefix20220607\Nette\Utils\JsonException(\json_last_error_msg(), $error); + throw new JsonException(\json_last_error_msg(), $error); } return $value; } diff --git a/vendor/nette/utils/src/Utils/ObjectHelpers.php b/vendor/nette/utils/src/Utils/ObjectHelpers.php index 865988a29d5..6910c8ae6df 100644 --- a/vendor/nette/utils/src/Utils/ObjectHelpers.php +++ b/vendor/nette/utils/src/Utils/ObjectHelpers.php @@ -25,7 +25,7 @@ final class ObjectHelpers $hint = self::getSuggestion(\array_merge(\array_filter($rc->getProperties(\ReflectionProperty::IS_PUBLIC), function ($p) { return !$p->isStatic(); }), self::parseFullDoc($rc, '~^[ \\t*]*@property(?:-read)?[ \\t]+(?:\\S+[ \\t]+)??\\$(\\w+)~m')), $name); - throw new \RectorPrefix20220607\Nette\MemberAccessException("Cannot read an undeclared property {$class}::\${$name}" . ($hint ? ", did you mean \${$hint}?" : '.')); + throw new MemberAccessException("Cannot read an undeclared property {$class}::\${$name}" . ($hint ? ", did you mean \${$hint}?" : '.')); } /** * @return never @@ -37,7 +37,7 @@ final class ObjectHelpers $hint = self::getSuggestion(\array_merge(\array_filter($rc->getProperties(\ReflectionProperty::IS_PUBLIC), function ($p) { return !$p->isStatic(); }), self::parseFullDoc($rc, '~^[ \\t*]*@property(?:-write)?[ \\t]+(?:\\S+[ \\t]+)??\\$(\\w+)~m')), $name); - throw new \RectorPrefix20220607\Nette\MemberAccessException("Cannot write to an undeclared property {$class}::\${$name}" . ($hint ? ", did you mean \${$hint}?" : '.')); + throw new MemberAccessException("Cannot write to an undeclared property {$class}::\${$name}" . ($hint ? ", did you mean \${$hint}?" : '.')); } /** * @return never @@ -56,10 +56,10 @@ final class ObjectHelpers // insufficient visibility $rm = new \ReflectionMethod($class, $method); $visibility = $rm->isPrivate() ? 'private ' : ($rm->isProtected() ? 'protected ' : ''); - throw new \RectorPrefix20220607\Nette\MemberAccessException("Call to {$visibility}method {$class}::{$method}() from " . ($context ? "scope {$context}." : 'global scope.')); + throw new MemberAccessException("Call to {$visibility}method {$class}::{$method}() from " . ($context ? "scope {$context}." : 'global scope.')); } else { $hint = self::getSuggestion(\array_merge(\get_class_methods($class), self::parseFullDoc(new \ReflectionClass($class), '~^[ \\t*]*@method[ \\t]+(?:\\S+[ \\t]+)??(\\w+)\\(~m'), $additionalMethods), $method); - throw new \RectorPrefix20220607\Nette\MemberAccessException("Call to undefined method {$class}::{$method}()" . ($hint ? ", did you mean {$hint}()?" : '.')); + throw new MemberAccessException("Call to undefined method {$class}::{$method}()" . ($hint ? ", did you mean {$hint}()?" : '.')); } } /** @@ -79,12 +79,12 @@ final class ObjectHelpers // insufficient visibility $rm = new \ReflectionMethod($class, $method); $visibility = $rm->isPrivate() ? 'private ' : ($rm->isProtected() ? 'protected ' : ''); - throw new \RectorPrefix20220607\Nette\MemberAccessException("Call to {$visibility}method {$class}::{$method}() from " . ($context ? "scope {$context}." : 'global scope.')); + throw new MemberAccessException("Call to {$visibility}method {$class}::{$method}() from " . ($context ? "scope {$context}." : 'global scope.')); } else { $hint = self::getSuggestion(\array_filter((new \ReflectionClass($class))->getMethods(\ReflectionMethod::IS_PUBLIC), function ($m) { return $m->isStatic(); }), $method); - throw new \RectorPrefix20220607\Nette\MemberAccessException("Call to undefined static method {$class}::{$method}()" . ($hint ? ", did you mean {$hint}()?" : '.')); + throw new MemberAccessException("Call to undefined static method {$class}::{$method}()" . ($hint ? ", did you mean {$hint}()?" : '.')); } } /** diff --git a/vendor/nette/utils/src/Utils/ObjectMixin.php b/vendor/nette/utils/src/Utils/ObjectMixin.php index 03223ebf0e5..11b055a3f19 100644 --- a/vendor/nette/utils/src/Utils/ObjectMixin.php +++ b/vendor/nette/utils/src/Utils/ObjectMixin.php @@ -19,7 +19,7 @@ final class ObjectMixin public static function getSuggestion(array $possibilities, string $value) : ?string { \trigger_error(__METHOD__ . '() has been renamed to Nette\\Utils\\ObjectHelpers::getSuggestion()', \E_USER_DEPRECATED); - return \RectorPrefix20220607\Nette\Utils\ObjectHelpers::getSuggestion($possibilities, $value); + return ObjectHelpers::getSuggestion($possibilities, $value); } public static function setExtensionMethod() : void { diff --git a/vendor/nette/utils/src/Utils/Random.php b/vendor/nette/utils/src/Utils/Random.php index 7b0a968cff6..6884c792995 100644 --- a/vendor/nette/utils/src/Utils/Random.php +++ b/vendor/nette/utils/src/Utils/Random.php @@ -25,9 +25,9 @@ final class Random }, $charlist), 3); $chLen = \strlen($charlist); if ($length < 1) { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException('Length must be greater than zero.'); + throw new Nette\InvalidArgumentException('Length must be greater than zero.'); } elseif ($chLen < 2) { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException('Character list must contain at least two chars.'); + throw new Nette\InvalidArgumentException('Character list must contain at least two chars.'); } $res = ''; for ($i = 0; $i < $length; $i++) { diff --git a/vendor/nette/utils/src/Utils/Reflection.php b/vendor/nette/utils/src/Utils/Reflection.php index e26e12f4438..f8df50bb23b 100644 --- a/vendor/nette/utils/src/Utils/Reflection.php +++ b/vendor/nette/utils/src/Utils/Reflection.php @@ -45,7 +45,7 @@ final class Reflection */ public static function getReturnTypes(\ReflectionFunctionAbstract $func) : array { - $type = \RectorPrefix20220607\Nette\Utils\Type::fromReflection($func); + $type = Type::fromReflection($func); return $type ? $type->getNames() : []; } /** @@ -62,7 +62,7 @@ final class Reflection */ public static function getParameterTypes(\ReflectionParameter $param) : array { - $type = \RectorPrefix20220607\Nette\Utils\Type::fromReflection($param); + $type = Type::fromReflection($param); return $type ? $type->getNames() : []; } /** @@ -79,7 +79,7 @@ final class Reflection */ public static function getPropertyTypes(\ReflectionProperty $prop) : array { - $type = \RectorPrefix20220607\Nette\Utils\Type::fromReflection($prop); + $type = Type::fromReflection($prop); return $type ? $type->getNames() : []; } /** @@ -90,11 +90,11 @@ final class Reflection if ($type === null) { return null; } elseif ($type instanceof \ReflectionNamedType) { - return \RectorPrefix20220607\Nette\Utils\Type::resolve($type->getName(), $reflection); - } elseif ($type instanceof \ReflectionUnionType || $type instanceof \RectorPrefix20220607\ReflectionIntersectionType) { - throw new \RectorPrefix20220607\Nette\InvalidStateException('The ' . self::toString($reflection) . ' is not expected to have a union or intersection type.'); + return Type::resolve($type->getName(), $reflection); + } elseif ($type instanceof \ReflectionUnionType || $type instanceof \ReflectionIntersectionType) { + throw new Nette\InvalidStateException('The ' . self::toString($reflection) . ' is not expected to have a union or intersection type.'); } else { - throw new \RectorPrefix20220607\Nette\InvalidStateException('Unexpected type of ' . self::toString($reflection)); + throw new Nette\InvalidStateException('Unexpected type of ' . self::toString($reflection)); } } /** @@ -108,7 +108,7 @@ final class Reflection $const = $orig = $param->getDefaultValueConstantName(); $pair = \explode('::', $const); if (isset($pair[1])) { - $pair[0] = \RectorPrefix20220607\Nette\Utils\Type::resolve($pair[0], $param); + $pair[0] = Type::resolve($pair[0], $param); try { $rcc = new \ReflectionClassConstant($pair[0], $pair[1]); } catch (\ReflectionException $e) { @@ -182,7 +182,7 @@ final class Reflection } elseif ($ref instanceof \ReflectionParameter) { return '$' . $ref->name . ' in ' . self::toString($ref->getDeclaringFunction()); } else { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException(); + throw new Nette\InvalidArgumentException(); } } /** @@ -194,7 +194,7 @@ final class Reflection { $lower = \strtolower($name); if (empty($name)) { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException('Class name must not be empty.'); + throw new Nette\InvalidArgumentException('Class name must not be empty.'); } elseif (isset(self::BUILTIN_TYPES[$lower])) { return $lower; } elseif ($lower === 'self' || $lower === 'static') { @@ -220,7 +220,7 @@ final class Reflection public static function getUseStatements(\ReflectionClass $class) : array { if ($class->isAnonymous()) { - throw new \RectorPrefix20220607\Nette\NotImplementedException('Anonymous classes are not supported.'); + throw new Nette\NotImplementedException('Anonymous classes are not supported.'); } static $cache = []; if (!isset($cache[$name = $class->name])) { @@ -257,7 +257,7 @@ final class Reflection case \T_CLASS: case \T_INTERFACE: case \T_TRAIT: - case \PHP_VERSION_ID < 80100 ? \T_CLASS : T_ENUM: + case \PHP_VERSION_ID < 80100 ? \T_CLASS : \T_ENUM: if ($name = self::fetch($tokens, \T_STRING)) { $class = $namespace . $name; $classLevel = $level + 1; diff --git a/vendor/nette/utils/src/Utils/Strings.php b/vendor/nette/utils/src/Utils/Strings.php index 3033553fce2..baa5aa6018e 100644 --- a/vendor/nette/utils/src/Utils/Strings.php +++ b/vendor/nette/utils/src/Utils/Strings.php @@ -15,7 +15,7 @@ use function is_array, is_object, strlen; class Strings { use Nette\StaticClass; - public const TRIM_CHARACTERS = " \t\n\r\0\v "; + public const TRIM_CHARACTERS = " \t\n\r\x00\v "; /** * Checks if the string is valid in UTF-8 encoding. */ @@ -38,9 +38,9 @@ class Strings public static function chr(int $code) : string { if ($code < 0 || $code >= 0xd800 && $code <= 0xdfff || $code > 0x10ffff) { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException('Code point must be in range 0x0 to 0xD7FF or 0xE000 to 0x10FFFF.'); + throw new Nette\InvalidArgumentException('Code point must be in range 0x0 to 0xD7FF or 0xE000 to 0x10FFFF.'); } elseif (!\extension_loaded('iconv')) { - throw new \RectorPrefix20220607\Nette\NotSupportedException(__METHOD__ . '() requires ICONV extension that is not loaded.'); + throw new Nette\NotSupportedException(__METHOD__ . '() requires ICONV extension that is not loaded.'); } return \iconv('UTF-32BE', 'UTF-8//IGNORE', \pack('N', $code)); } @@ -49,14 +49,14 @@ class Strings */ public static function startsWith(string $haystack, string $needle) : bool { - return \strncmp($haystack, $needle, \strlen($needle)) === 0; + return \strncmp($haystack, $needle, strlen($needle)) === 0; } /** * Ends the $haystack string with the suffix $needle? */ public static function endsWith(string $haystack, string $needle) : bool { - return $needle === '' || \substr($haystack, -\strlen($needle)) === $needle; + return $needle === '' || \substr($haystack, -strlen($needle)) === $needle; } /** * Does $haystack contain $needle? @@ -75,7 +75,7 @@ class Strings return \mb_substr($s, $start, $length, 'UTF-8'); // MB is much faster } elseif (!\extension_loaded('iconv')) { - throw new \RectorPrefix20220607\Nette\NotSupportedException(__METHOD__ . '() requires extension ICONV or MBSTRING, neither is loaded.'); + throw new Nette\NotSupportedException(__METHOD__ . '() requires extension ICONV or MBSTRING, neither is loaded.'); } elseif ($length === null) { $length = self::length($s); } elseif ($start < 0 && $length < 0) { @@ -138,10 +138,10 @@ class Strings $s = $transliterator->transliterate($s); // use iconv because The transliterator leaves some characters out of ASCII, eg → ʾ if ($iconv === 'glibc') { - $s = \strtr($s, '?', "\1"); + $s = \strtr($s, '?', "\x01"); // temporarily hide ? to distinguish them from the garbage that iconv creates $s = \iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $s); - $s = \str_replace(['?', "\1"], ['', '?'], $s); + $s = \str_replace(['?', "\x01"], ['', '?'], $s); // remove garbage and restore ? characters } elseif ($iconv === 'libiconv') { $s = \iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $s); @@ -152,11 +152,11 @@ class Strings } } elseif ($iconv === 'glibc' || $iconv === 'libiconv') { // temporarily hide these characters to distinguish them from the garbage that iconv creates - $s = \strtr($s, '`\'"^~?', "\1\2\3\4\5\6"); + $s = \strtr($s, '`\'"^~?', "\x01\x02\x03\x04\x05\x06"); if ($iconv === 'glibc') { // glibc implementation is very limited. transliterate into Windows-1250 and then into ASCII, so most Eastern European characters are preserved $s = \iconv('UTF-8', 'WINDOWS-1250//TRANSLIT//IGNORE', $s); - $s = \strtr($s, "¥£¼Œ§ŠªŽ¯¹³¾œšºŸž¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ– ‹—›¦­·", 'ALLSSSSTZZZallssstzzzRAAAALCCCEEEEIIDDNNOOOOxRUUUUYTsraaaalccceeeeiiddnnooooruuuuyt- <->|-.'); + $s = \strtr($s, "\xa5\xa3\xbc\x8c\xa7\x8a\xaa\x8d\x8f\x8e\xaf\xb9\xb3\xbe\x9c\x9a\xba\x9d\x9f\x9e\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf8\xf9\xfa\xfb\xfc\xfd\xfe\x96\xa0\x8b\x97\x9b\xa6\xad\xb7", 'ALLSSSSTZZZallssstzzzRAAAALCCCEEEEIIDDNNOOOOxRUUUUYTsraaaalccceeeeiiddnnooooruuuuyt- <->|-.'); $s = self::pcre('preg_replace', ['#[^\\x00-\\x7F]++#', '', $s]); } else { $s = \iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $s); @@ -164,7 +164,7 @@ class Strings // remove garbage that iconv creates during transliteration (eg à -> Y') $s = \str_replace(['`', "'", '"', '^', '~', '?'], '', $s); // restore temporarily hidden characters - $s = \strtr($s, "\1\2\3\4\5\6", '`\'"^~?'); + $s = \strtr($s, "\x01\x02\x03\x04\x05\x06", '`\'"^~?'); } else { $s = self::pcre('preg_replace', ['#[^\\x00-\\x7F]++#', '', $s]); // remove non-ascii chars @@ -278,10 +278,10 @@ class Strings public static function findPrefix(array $strings) : string { $first = \array_shift($strings); - for ($i = 0; $i < \strlen($first); $i++) { + for ($i = 0; $i < strlen($first); $i++) { foreach ($strings as $s) { if (!isset($s[$i]) || $first[$i] !== $s[$i]) { - while ($i && $first[$i - 1] >= "€" && $first[$i] >= "€" && $first[$i] < "À") { + while ($i && $first[$i - 1] >= "\x80" && $first[$i] >= "\x80" && $first[$i] < "\xc0") { $i--; } return \substr($first, 0, $i); @@ -296,7 +296,7 @@ class Strings */ public static function length(string $s) : int { - return \function_exists('mb_strlen') ? \mb_strlen($s, 'UTF-8') : \strlen(\utf8_decode($s)); + return \function_exists('mb_strlen') ? \mb_strlen($s, 'UTF-8') : strlen(\utf8_decode($s)); } /** * Removes all left and right side spaces (or the characters passed as second argument) from a UTF-8 encoded string. @@ -330,7 +330,7 @@ class Strings public static function reverse(string $s) : string { if (!\extension_loaded('iconv')) { - throw new \RectorPrefix20220607\Nette\NotSupportedException(__METHOD__ . '() requires ICONV extension that is not loaded.'); + throw new Nette\NotSupportedException(__METHOD__ . '() requires ICONV extension that is not loaded.'); } return \iconv('UTF-32LE', 'UTF-8', \strrev(\iconv('UTF-8', 'UTF-32BE', $s))); } @@ -350,7 +350,7 @@ class Strings public static function after(string $haystack, string $needle, int $nth = 1) : ?string { $pos = self::pos($haystack, $needle, $nth); - return $pos === null ? null : \substr($haystack, $pos + \strlen($needle)); + return $pos === null ? null : \substr($haystack, $pos + strlen($needle)); } /** * Returns position in characters of $nth occurence of $needle in $haystack or null if the $needle was not found. @@ -377,7 +377,7 @@ class Strings $pos++; } } else { - $len = \strlen($haystack); + $len = strlen($haystack); if ($needle === '') { return $len; } elseif ($len === 0) { @@ -388,7 +388,7 @@ class Strings $pos--; } } - return \RectorPrefix20220607\Nette\Utils\Helpers::falseToNull($pos); + return Helpers::falseToNull($pos); } /** * Splits a string into array by the regular expression. Parenthesized expression in the delimiter are captured. @@ -404,7 +404,7 @@ class Strings */ public static function match(string $subject, string $pattern, int $flags = 0, int $offset = 0) : ?array { - if ($offset > \strlen($subject)) { + if ($offset > strlen($subject)) { return null; } return self::pcre('preg_match', [$pattern, $subject, &$m, $flags, $offset]) ? $m : null; @@ -415,7 +415,7 @@ class Strings */ public static function matchAll(string $subject, string $pattern, int $flags = 0, int $offset = 0) : array { - if ($offset > \strlen($subject)) { + if ($offset > strlen($subject)) { return []; } self::pcre('preg_match_all', [$pattern, $subject, &$m, $flags & \PREG_PATTERN_ORDER ? $flags : $flags | \PREG_SET_ORDER, $offset]); @@ -428,12 +428,12 @@ class Strings */ public static function replace(string $subject, $pattern, $replacement = '', int $limit = -1) : string { - if (\is_object($replacement) || \is_array($replacement)) { + if (is_object($replacement) || is_array($replacement)) { if (!\is_callable($replacement, \false, $textual)) { - throw new \RectorPrefix20220607\Nette\InvalidStateException("Callback '{$textual}' is not callable."); + throw new Nette\InvalidStateException("Callback '{$textual}' is not callable."); } return self::pcre('preg_replace_callback', [$pattern, $replacement, $subject, $limit]); - } elseif (\is_array($pattern) && \is_string(\key($pattern))) { + } elseif (is_array($pattern) && \is_string(\key($pattern))) { $replacement = \array_values($pattern); $pattern = \array_keys($pattern); } @@ -442,12 +442,12 @@ class Strings /** @internal */ public static function pcre(string $func, array $args) { - $res = \RectorPrefix20220607\Nette\Utils\Callback::invokeSafe($func, $args, function (string $message) use($args) : void { + $res = Callback::invokeSafe($func, $args, function (string $message) use($args) : void { // compile-time error, not detectable by preg_last_error - throw new \RectorPrefix20220607\Nette\Utils\RegexpException($message . ' in pattern: ' . \implode(' or ', (array) $args[0])); + throw new RegexpException($message . ' in pattern: ' . \implode(' or ', (array) $args[0])); }); if (($code = \preg_last_error()) && ($res === null || !\in_array($func, ['preg_filter', 'preg_replace_callback', 'preg_replace'], \true))) { - throw new \RectorPrefix20220607\Nette\Utils\RegexpException((\RectorPrefix20220607\Nette\Utils\RegexpException::MESSAGES[$code] ?? 'Unknown error') . ' (pattern: ' . \implode(' or ', (array) $args[0]) . ')', $code); + throw new RegexpException((RegexpException::MESSAGES[$code] ?? 'Unknown error') . ' (pattern: ' . \implode(' or ', (array) $args[0]) . ')', $code); } return $res; } diff --git a/vendor/nette/utils/src/Utils/Type.php b/vendor/nette/utils/src/Utils/Type.php index 8dbeadb3648..73c04c2452d 100644 --- a/vendor/nette/utils/src/Utils/Type.php +++ b/vendor/nette/utils/src/Utils/Type.php @@ -38,12 +38,12 @@ final class Type } elseif ($type instanceof \ReflectionNamedType) { $name = self::resolve($type->getName(), $reflection); return new self($type->allowsNull() && $type->getName() !== 'mixed' ? [$name, 'null'] : [$name]); - } elseif ($type instanceof \ReflectionUnionType || $type instanceof \RectorPrefix20220607\ReflectionIntersectionType) { + } elseif ($type instanceof \ReflectionUnionType || $type instanceof \ReflectionIntersectionType) { return new self(\array_map(function ($t) use($reflection) { return self::resolve($t->getName(), $reflection); }, $type->getTypes()), $type instanceof \ReflectionUnionType ? '|' : '&'); } else { - throw new \RectorPrefix20220607\Nette\InvalidStateException('Unexpected type of ' . \RectorPrefix20220607\Nette\Utils\Reflection::toString($reflection)); + throw new Nette\InvalidStateException('Unexpected type of ' . Reflection::toString($reflection)); } } /** @@ -55,7 +55,7 @@ final class Type \\?([\\w\\\\]+)| [\\w\\\\]+ (?: (&[\\w\\\\]+)* | (\\|[\\w\\\\]+)* ) )()$#xAD', $type, $m)) { - throw new \RectorPrefix20220607\Nette\InvalidArgumentException("Invalid type '{$type}'."); + throw new Nette\InvalidArgumentException("Invalid type '{$type}'."); } [, $nType, $iType] = $m; if ($nType) { @@ -148,21 +148,21 @@ final class Type */ public function isBuiltin() : bool { - return $this->single && \RectorPrefix20220607\Nette\Utils\Reflection::isBuiltinType($this->types[0]); + return $this->single && Reflection::isBuiltinType($this->types[0]); } /** * Returns true whether the type is both a single and a class name. */ public function isClass() : bool { - return $this->single && !\RectorPrefix20220607\Nette\Utils\Reflection::isBuiltinType($this->types[0]); + return $this->single && !Reflection::isBuiltinType($this->types[0]); } /** * Determines if type is special class name self/parent/static. */ public function isClassKeyword() : bool { - return $this->single && \RectorPrefix20220607\Nette\Utils\Reflection::isClassKeyword($this->types[0]); + return $this->single && Reflection::isClassKeyword($this->types[0]); } /** * Verifies type compatibility. For example, it checks if a value of a certain type could be passed as a parameter. @@ -177,17 +177,17 @@ final class Type if (!$type->isIntersection()) { return \false; } - return \RectorPrefix20220607\Nette\Utils\Arrays::every($this->types, function ($currentType) use($type) { - $builtin = \RectorPrefix20220607\Nette\Utils\Reflection::isBuiltinType($currentType); - return \RectorPrefix20220607\Nette\Utils\Arrays::some($type->types, function ($testedType) use($currentType, $builtin) { + return Arrays::every($this->types, function ($currentType) use($type) { + $builtin = Reflection::isBuiltinType($currentType); + return Arrays::some($type->types, function ($testedType) use($currentType, $builtin) { return $builtin ? \strcasecmp($currentType, $testedType) === 0 : \is_a($testedType, $currentType, \true); }); }); } $method = $type->isIntersection() ? 'some' : 'every'; - return \RectorPrefix20220607\Nette\Utils\Arrays::$method($type->types, function ($testedType) { - $builtin = \RectorPrefix20220607\Nette\Utils\Reflection::isBuiltinType($testedType); - return \RectorPrefix20220607\Nette\Utils\Arrays::some($this->types, function ($currentType) use($testedType, $builtin) { + return Arrays::$method($type->types, function ($testedType) { + $builtin = Reflection::isBuiltinType($testedType); + return Arrays::some($this->types, function ($currentType) use($testedType, $builtin) { return $builtin ? \strcasecmp($currentType, $testedType) === 0 : \is_a($testedType, $currentType, \true); }); }); diff --git a/vendor/nette/utils/src/Utils/Validators.php b/vendor/nette/utils/src/Utils/Validators.php index 7c6065bad8f..c0f04b60153 100644 --- a/vendor/nette/utils/src/Utils/Validators.php +++ b/vendor/nette/utils/src/Utils/Validators.php @@ -31,7 +31,7 @@ class Validators // pseudo-types 'callable' => [self::class, 'isCallable'], 'iterable' => 'is_iterable', - 'list' => [\RectorPrefix20220607\Nette\Utils\Arrays::class, 'isList'], + 'list' => [Arrays::class, 'isList'], 'mixed' => [self::class, 'isMixed'], 'none' => [self::class, 'isNone'], 'number' => [self::class, 'isNumber'], @@ -60,7 +60,7 @@ class Validators 'type' => [self::class, 'isType'], ]; /** @var array */ - protected static $counters = ['string' => 'strlen', 'unicode' => [\RectorPrefix20220607\Nette\Utils\Strings::class, 'length'], 'array' => 'count', 'list' => 'count', 'alnum' => 'strlen', 'alpha' => 'strlen', 'digit' => 'strlen', 'lower' => 'strlen', 'space' => 'strlen', 'upper' => 'strlen', 'xdigit' => 'strlen']; + protected static $counters = ['string' => 'strlen', 'unicode' => [Strings::class, 'length'], 'array' => 'count', 'list' => 'count', 'alnum' => 'strlen', 'alpha' => 'strlen', 'digit' => 'strlen', 'lower' => 'strlen', 'space' => 'strlen', 'upper' => 'strlen', 'xdigit' => 'strlen']; /** * Verifies that the value is of expected types separated by pipe. * @param mixed $value @@ -77,7 +77,7 @@ class Validators } elseif (\is_object($value)) { $type .= ' ' . \get_class($value); } - throw new \RectorPrefix20220607\Nette\Utils\AssertionException("The {$label} expects to be {$expected}, {$type} given."); + throw new AssertionException("The {$label} expects to be {$expected}, {$type} given."); } } /** @@ -89,7 +89,7 @@ class Validators public static function assertField(array $array, $key, ?string $expected = null, string $label = "item '%' in array") : void { if (!\array_key_exists($key, $array)) { - throw new \RectorPrefix20220607\Nette\Utils\AssertionException('Missing ' . \str_replace('%', $key, $label) . '.'); + throw new AssertionException('Missing ' . \str_replace('%', $key, $label) . '.'); } elseif ($expected) { static::assert($array[$key], $expected, \str_replace('%', $key, $label)); } @@ -122,7 +122,7 @@ class Validators continue; } } elseif ($type === 'pattern') { - if (\RectorPrefix20220607\Nette\Utils\Strings::match($value, '|^' . ($item[1] ?? '') . '$|D')) { + if (Strings::match($value, '|^' . ($item[1] ?? '') . '$|D')) { return \true; } continue; @@ -220,7 +220,7 @@ class Validators */ public static function isList($value) : bool { - return \RectorPrefix20220607\Nette\Utils\Arrays::isList($value); + return Arrays::isList($value); } /** * Checks if the value is in the given range [min, max], where the upper or lower limit can be omitted (null). @@ -253,7 +253,7 @@ class Validators { $atom = "[-a-z0-9!#\$%&'*+/=?^_`{|}~]"; // RFC 5322 unquoted characters in local-part - $alpha = "a-z€-ÿ"; + $alpha = "a-z\x80-\xff"; // superset of IDN return (bool) \preg_match(<< ['startLine', 'endLine', 'startFilePos', 'endFilePos', 'comments']]); $parser = (new \PhpParser\ParserFactory())->create(\PhpParser\ParserFactory::PREFER_PHP7, $lexer); @@ -43,7 +43,7 @@ foreach ($files as $file) { $errorHandler = new \PhpParser\ErrorHandler\Collecting(); $stmts = $parser->parse($code, $errorHandler); foreach ($errorHandler->getErrors() as $error) { - $message = \RectorPrefix20220607\formatErrorMessage($error, $code, $attributes['with-column-info']); + $message = formatErrorMessage($error, $code, $attributes['with-column-info']); \fwrite(\STDERR, $message . "\n"); } if (null === $stmts) { @@ -53,7 +53,7 @@ foreach ($files as $file) { try { $stmts = $parser->parse($code); } catch (\PhpParser\Error $error) { - $message = \RectorPrefix20220607\formatErrorMessage($error, $code, $attributes['with-column-info']); + $message = formatErrorMessage($error, $code, $attributes['with-column-info']); \fwrite(\STDERR, $message . "\n"); exit(1); } @@ -163,14 +163,14 @@ function parseArgs($args) break; case '--help': case '-h': - \RectorPrefix20220607\showHelp(); + showHelp(); break; case '--': $parseOptions = \false; break; default: if ($arg[0] === '-') { - \RectorPrefix20220607\showHelp("Invalid operation {$arg}."); + showHelp("Invalid operation {$arg}."); } else { $files[] = $arg; } diff --git a/vendor/nikic/php-parser/grammar/phpyLang.php b/vendor/nikic/php-parser/grammar/phpyLang.php index d853bd2a480..e448bfe6c35 100644 --- a/vendor/nikic/php-parser/grammar/phpyLang.php +++ b/vendor/nikic/php-parser/grammar/phpyLang.php @@ -19,17 +19,17 @@ const ARGS = '\\((?[^()]*+(?:\\((?&args)\\)[^()]*+)*+)\\)'; /////////////////////////////// function preprocessGrammar($code) { - $code = \RectorPrefix20220607\resolveNodes($code); - $code = \RectorPrefix20220607\resolveMacros($code); - $code = \RectorPrefix20220607\resolveStackAccess($code); + $code = resolveNodes($code); + $code = resolveMacros($code); + $code = resolveStackAccess($code); return $code; } function resolveNodes($code) { - return \preg_replace_callback('~\\b(?[A-Z][a-zA-Z_\\\\]++)\\s*' . \PARAMS . '~', function ($matches) { + return \preg_replace_callback('~\\b(?[A-Z][a-zA-Z_\\\\]++)\\s*' . \RectorPrefix20220607\PARAMS . '~', function ($matches) { // recurse - $matches['params'] = \RectorPrefix20220607\resolveNodes($matches['params']); - $params = \RectorPrefix20220607\magicSplit('(?:' . \PARAMS . '|' . \ARGS . ')(*SKIP)(*FAIL)|,', $matches['params']); + $matches['params'] = resolveNodes($matches['params']); + $params = magicSplit('(?:' . \RectorPrefix20220607\PARAMS . '|' . \RectorPrefix20220607\ARGS . ')(*SKIP)(*FAIL)|,', $matches['params']); $paramCode = ''; foreach ($params as $param) { $paramCode .= $param . ', '; @@ -39,52 +39,52 @@ function resolveNodes($code) } function resolveMacros($code) { - return \preg_replace_callback('~\\b(?)(?!array\\()(?[a-z][A-Za-z]++)' . \ARGS . '~', function ($matches) { + return \preg_replace_callback('~\\b(?)(?!array\\()(?[a-z][A-Za-z]++)' . \RectorPrefix20220607\ARGS . '~', function ($matches) { // recurse - $matches['args'] = \RectorPrefix20220607\resolveMacros($matches['args']); + $matches['args'] = resolveMacros($matches['args']); $name = $matches['name']; - $args = \RectorPrefix20220607\magicSplit('(?:' . \PARAMS . '|' . \ARGS . ')(*SKIP)(*FAIL)|,', $matches['args']); + $args = magicSplit('(?:' . \RectorPrefix20220607\PARAMS . '|' . \RectorPrefix20220607\ARGS . ')(*SKIP)(*FAIL)|,', $matches['args']); if ('attributes' === $name) { - \RectorPrefix20220607\assertArgs(0, $args, $name); + assertArgs(0, $args, $name); return '$this->startAttributeStack[#1] + $this->endAttributes'; } if ('stackAttributes' === $name) { - \RectorPrefix20220607\assertArgs(1, $args, $name); + assertArgs(1, $args, $name); return '$this->startAttributeStack[' . $args[0] . ']' . ' + $this->endAttributeStack[' . $args[0] . ']'; } if ('init' === $name) { return '$$ = array(' . \implode(', ', $args) . ')'; } if ('push' === $name) { - \RectorPrefix20220607\assertArgs(2, $args, $name); + assertArgs(2, $args, $name); return $args[0] . '[] = ' . $args[1] . '; $$ = ' . $args[0]; } if ('pushNormalizing' === $name) { - \RectorPrefix20220607\assertArgs(2, $args, $name); + assertArgs(2, $args, $name); return 'if (is_array(' . $args[1] . ')) { $$ = array_merge(' . $args[0] . ', ' . $args[1] . '); }' . ' else { ' . $args[0] . '[] = ' . $args[1] . '; $$ = ' . $args[0] . '; }'; } if ('toArray' == $name) { - \RectorPrefix20220607\assertArgs(1, $args, $name); + assertArgs(1, $args, $name); return 'is_array(' . $args[0] . ') ? ' . $args[0] . ' : array(' . $args[0] . ')'; } if ('parseVar' === $name) { - \RectorPrefix20220607\assertArgs(1, $args, $name); + assertArgs(1, $args, $name); return 'substr(' . $args[0] . ', 1)'; } if ('parseEncapsed' === $name) { - \RectorPrefix20220607\assertArgs(3, $args, $name); + assertArgs(3, $args, $name); return 'foreach (' . $args[0] . ' as $s) { if ($s instanceof Node\\Scalar\\EncapsedStringPart) {' . ' $s->value = Node\\Scalar\\String_::parseEscapeSequences($s->value, ' . $args[1] . ', ' . $args[2] . '); } }'; } if ('makeNop' === $name) { - \RectorPrefix20220607\assertArgs(3, $args, $name); + assertArgs(3, $args, $name); return '$startAttributes = ' . $args[1] . ';' . ' if (isset($startAttributes[\'comments\']))' . ' { ' . $args[0] . ' = new Stmt\\Nop($startAttributes + ' . $args[2] . '); }' . ' else { ' . $args[0] . ' = null; }'; } if ('makeZeroLengthNop' == $name) { - \RectorPrefix20220607\assertArgs(2, $args, $name); + assertArgs(2, $args, $name); return '$startAttributes = ' . $args[1] . ';' . ' if (isset($startAttributes[\'comments\']))' . ' { ' . $args[0] . ' = new Stmt\\Nop($this->createCommentNopAttributes($startAttributes[\'comments\'])); }' . ' else { ' . $args[0] . ' = null; }'; } if ('prependLeadingComments' === $name) { - \RectorPrefix20220607\assertArgs(1, $args, $name); + assertArgs(1, $args, $name); return '$attrs = $this->startAttributeStack[#1]; $stmts = ' . $args[0] . '; ' . 'if (!empty($attrs[\'comments\'])) {' . '$stmts[0]->setAttribute(\'comments\', ' . 'array_merge($attrs[\'comments\'], $stmts[0]->getAttribute(\'comments\', []))); }'; } return $matches[0]; @@ -113,11 +113,11 @@ function removeTrailingWhitespace($code) ////////////////////////////// function regex($regex) { - return '~' . \LIB . '(?:' . \str_replace('~', '\\~', $regex) . ')~'; + return '~' . \RectorPrefix20220607\LIB . '(?:' . \str_replace('~', '\\~', $regex) . ')~'; } function magicSplit($regex, $string) { - $pieces = \preg_split(\RectorPrefix20220607\regex('(?:(?&string)|(?&comment)|(?&code))(*SKIP)(*FAIL)|' . $regex), $string); + $pieces = \preg_split(regex('(?:(?&string)|(?&comment)|(?&code))(*SKIP)(*FAIL)|' . $regex), $string); foreach ($pieces as &$piece) { $piece = \trim($piece); } diff --git a/vendor/nikic/php-parser/grammar/rebuildParsers.php b/vendor/nikic/php-parser/grammar/rebuildParsers.php index 7906f3cc87d..4fca1f5ba95 100644 --- a/vendor/nikic/php-parser/grammar/rebuildParsers.php +++ b/vendor/nikic/php-parser/grammar/rebuildParsers.php @@ -27,18 +27,18 @@ foreach ($grammarFileToName as $grammarFile => $name) { echo "Building temporary {$name} grammar file.\n"; $grammarCode = \file_get_contents($grammarFile); $grammarCode = \str_replace('%tokens', $tokens, $grammarCode); - $grammarCode = \RectorPrefix20220607\preprocessGrammar($grammarCode); + $grammarCode = preprocessGrammar($grammarCode); \file_put_contents($tmpGrammarFile, $grammarCode); $additionalArgs = $optionDebug ? '-t -v' : ''; echo "Building {$name} parser.\n"; - $output = \RectorPrefix20220607\execCmd("{$kmyacc} {$additionalArgs} -m {$skeletonFile} -p {$name} {$tmpGrammarFile}"); + $output = execCmd("{$kmyacc} {$additionalArgs} -m {$skeletonFile} -p {$name} {$tmpGrammarFile}"); $resultCode = \file_get_contents($tmpResultFile); - $resultCode = \RectorPrefix20220607\removeTrailingWhitespace($resultCode); - \RectorPrefix20220607\ensureDirExists($resultDir); + $resultCode = removeTrailingWhitespace($resultCode); + ensureDirExists($resultDir); \file_put_contents("{$resultDir}/{$name}.php", $resultCode); \unlink($tmpResultFile); echo "Building token definition.\n"; - $output = \RectorPrefix20220607\execCmd("{$kmyacc} -m {$tokensTemplate} {$tmpGrammarFile}"); + $output = execCmd("{$kmyacc} -m {$tokensTemplate} {$tmpGrammarFile}"); \rename($tmpResultFile, $tokensResultsFile); if (!$optionKeepTmpGrammar) { \unlink($tmpGrammarFile); diff --git a/vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php b/vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php index 8e4d54a40f7..ff753cd2374 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php @@ -3,13 +3,13 @@ declare (strict_types=1); namespace PhpParser\Builder; -use RectorPrefix20220607\PhpParser; +use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Const_; use PhpParser\Node\Identifier; use PhpParser\Node\Stmt; -class ClassConst implements \PhpParser\Builder +class ClassConst implements PhpParser\Builder { protected $flags = 0; protected $attributes = []; @@ -24,7 +24,7 @@ class ClassConst implements \PhpParser\Builder */ public function __construct($name, $value) { - $this->constants = [new \PhpParser\Node\Const_($name, \PhpParser\BuilderHelpers::normalizeValue($value))]; + $this->constants = [new Const_($name, BuilderHelpers::normalizeValue($value))]; } /** * Add another constant to const group @@ -36,7 +36,7 @@ class ClassConst implements \PhpParser\Builder */ public function addConst($name, $value) { - $this->constants[] = new \PhpParser\Node\Const_($name, \PhpParser\BuilderHelpers::normalizeValue($value)); + $this->constants[] = new Const_($name, BuilderHelpers::normalizeValue($value)); return $this; } /** @@ -46,7 +46,7 @@ class ClassConst implements \PhpParser\Builder */ public function makePublic() { - $this->flags = \PhpParser\BuilderHelpers::addModifier($this->flags, \PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PUBLIC); return $this; } /** @@ -56,7 +56,7 @@ class ClassConst implements \PhpParser\Builder */ public function makeProtected() { - $this->flags = \PhpParser\BuilderHelpers::addModifier($this->flags, \PhpParser\Node\Stmt\Class_::MODIFIER_PROTECTED); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PROTECTED); return $this; } /** @@ -66,7 +66,7 @@ class ClassConst implements \PhpParser\Builder */ public function makePrivate() { - $this->flags = \PhpParser\BuilderHelpers::addModifier($this->flags, \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PRIVATE); return $this; } /** @@ -76,7 +76,7 @@ class ClassConst implements \PhpParser\Builder */ public function makeFinal() { - $this->flags = \PhpParser\BuilderHelpers::addModifier($this->flags, \PhpParser\Node\Stmt\Class_::MODIFIER_FINAL); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_FINAL); return $this; } /** @@ -88,7 +88,7 @@ class ClassConst implements \PhpParser\Builder */ public function setDocComment($docComment) { - $this->attributes = ['comments' => [\PhpParser\BuilderHelpers::normalizeDocComment($docComment)]]; + $this->attributes = ['comments' => [BuilderHelpers::normalizeDocComment($docComment)]]; return $this; } /** @@ -100,7 +100,7 @@ class ClassConst implements \PhpParser\Builder */ public function addAttribute($attribute) { - $this->attributeGroups[] = \PhpParser\BuilderHelpers::normalizeAttribute($attribute); + $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } /** @@ -108,8 +108,8 @@ class ClassConst implements \PhpParser\Builder * * @return Stmt\ClassConst The built constant node */ - public function getNode() : \PhpParser\Node + public function getNode() : PhpParser\Node { - return new \PhpParser\Node\Stmt\ClassConst($this->constants, $this->flags, $this->attributes, $this->attributeGroups); + return new Stmt\ClassConst($this->constants, $this->flags, $this->attributes, $this->attributeGroups); } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php b/vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php index cf8d5a64667..444b266e504 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php @@ -3,7 +3,7 @@ declare (strict_types=1); namespace PhpParser\Builder; -use RectorPrefix20220607\PhpParser; +use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Name; @@ -38,7 +38,7 @@ class Class_ extends \PhpParser\Builder\Declaration */ public function extend($class) { - $this->extends = \PhpParser\BuilderHelpers::normalizeName($class); + $this->extends = BuilderHelpers::normalizeName($class); return $this; } /** @@ -51,7 +51,7 @@ class Class_ extends \PhpParser\Builder\Declaration public function implement(...$interfaces) { foreach ($interfaces as $interface) { - $this->implements[] = \PhpParser\BuilderHelpers::normalizeName($interface); + $this->implements[] = BuilderHelpers::normalizeName($interface); } return $this; } @@ -62,7 +62,7 @@ class Class_ extends \PhpParser\Builder\Declaration */ public function makeAbstract() { - $this->flags = \PhpParser\BuilderHelpers::addClassModifier($this->flags, \PhpParser\Node\Stmt\Class_::MODIFIER_ABSTRACT); + $this->flags = BuilderHelpers::addClassModifier($this->flags, Stmt\Class_::MODIFIER_ABSTRACT); return $this; } /** @@ -72,12 +72,12 @@ class Class_ extends \PhpParser\Builder\Declaration */ public function makeFinal() { - $this->flags = \PhpParser\BuilderHelpers::addClassModifier($this->flags, \PhpParser\Node\Stmt\Class_::MODIFIER_FINAL); + $this->flags = BuilderHelpers::addClassModifier($this->flags, Stmt\Class_::MODIFIER_FINAL); return $this; } public function makeReadonly() { - $this->flags = \PhpParser\BuilderHelpers::addClassModifier($this->flags, \PhpParser\Node\Stmt\Class_::MODIFIER_READONLY); + $this->flags = BuilderHelpers::addClassModifier($this->flags, Stmt\Class_::MODIFIER_READONLY); return $this; } /** @@ -89,8 +89,8 @@ class Class_ extends \PhpParser\Builder\Declaration */ public function addStmt($stmt) { - $stmt = \PhpParser\BuilderHelpers::normalizeNode($stmt); - $targets = [\PhpParser\Node\Stmt\TraitUse::class => &$this->uses, \PhpParser\Node\Stmt\ClassConst::class => &$this->constants, \PhpParser\Node\Stmt\Property::class => &$this->properties, \PhpParser\Node\Stmt\ClassMethod::class => &$this->methods]; + $stmt = BuilderHelpers::normalizeNode($stmt); + $targets = [Stmt\TraitUse::class => &$this->uses, Stmt\ClassConst::class => &$this->constants, Stmt\Property::class => &$this->properties, Stmt\ClassMethod::class => &$this->methods]; $class = \get_class($stmt); if (!isset($targets[$class])) { throw new \LogicException(\sprintf('Unexpected node of type "%s"', $stmt->getType())); @@ -107,7 +107,7 @@ class Class_ extends \PhpParser\Builder\Declaration */ public function addAttribute($attribute) { - $this->attributeGroups[] = \PhpParser\BuilderHelpers::normalizeAttribute($attribute); + $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } /** @@ -115,8 +115,8 @@ class Class_ extends \PhpParser\Builder\Declaration * * @return Stmt\Class_ The built class node */ - public function getNode() : \PhpParser\Node + public function getNode() : PhpParser\Node { - return new \PhpParser\Node\Stmt\Class_($this->name, ['flags' => $this->flags, 'extends' => $this->extends, 'implements' => $this->implements, 'stmts' => \array_merge($this->uses, $this->constants, $this->properties, $this->methods), 'attrGroups' => $this->attributeGroups], $this->attributes); + return new Stmt\Class_($this->name, ['flags' => $this->flags, 'extends' => $this->extends, 'implements' => $this->implements, 'stmts' => \array_merge($this->uses, $this->constants, $this->properties, $this->methods), 'attrGroups' => $this->attributeGroups], $this->attributes); } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Builder/Declaration.php b/vendor/nikic/php-parser/lib/PhpParser/Builder/Declaration.php index 132516482d6..d44671423ec 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Builder/Declaration.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Builder/Declaration.php @@ -3,9 +3,9 @@ declare (strict_types=1); namespace PhpParser\Builder; -use RectorPrefix20220607\PhpParser; +use PhpParser; use PhpParser\BuilderHelpers; -abstract class Declaration implements \PhpParser\Builder +abstract class Declaration implements PhpParser\Builder { protected $attributes = []; public abstract function addStmt($stmt); @@ -32,7 +32,7 @@ abstract class Declaration implements \PhpParser\Builder */ public function setDocComment($docComment) { - $this->attributes['comments'] = [\PhpParser\BuilderHelpers::normalizeDocComment($docComment)]; + $this->attributes['comments'] = [BuilderHelpers::normalizeDocComment($docComment)]; return $this; } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Builder/EnumCase.php b/vendor/nikic/php-parser/lib/PhpParser/Builder/EnumCase.php index 70a26fc536b..db5ce323117 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Builder/EnumCase.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Builder/EnumCase.php @@ -3,12 +3,12 @@ declare (strict_types=1); namespace PhpParser\Builder; -use RectorPrefix20220607\PhpParser; +use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Identifier; use PhpParser\Node\Stmt; -class EnumCase implements \PhpParser\Builder +class EnumCase implements PhpParser\Builder { protected $name; protected $value = null; @@ -33,7 +33,7 @@ class EnumCase implements \PhpParser\Builder */ public function setValue($value) { - $this->value = \PhpParser\BuilderHelpers::normalizeValue($value); + $this->value = BuilderHelpers::normalizeValue($value); return $this; } /** @@ -45,7 +45,7 @@ class EnumCase implements \PhpParser\Builder */ public function setDocComment($docComment) { - $this->attributes = ['comments' => [\PhpParser\BuilderHelpers::normalizeDocComment($docComment)]]; + $this->attributes = ['comments' => [BuilderHelpers::normalizeDocComment($docComment)]]; return $this; } /** @@ -57,7 +57,7 @@ class EnumCase implements \PhpParser\Builder */ public function addAttribute($attribute) { - $this->attributeGroups[] = \PhpParser\BuilderHelpers::normalizeAttribute($attribute); + $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } /** @@ -65,8 +65,8 @@ class EnumCase implements \PhpParser\Builder * * @return Stmt\EnumCase The built constant node */ - public function getNode() : \PhpParser\Node + public function getNode() : PhpParser\Node { - return new \PhpParser\Node\Stmt\EnumCase($this->name, $this->value, $this->attributes, $this->attributeGroups); + return new Stmt\EnumCase($this->name, $this->value, $this->attributes, $this->attributeGroups); } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Builder/Enum_.php b/vendor/nikic/php-parser/lib/PhpParser/Builder/Enum_.php index 78a9205e3fc..c89ff7ee6ea 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Builder/Enum_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Builder/Enum_.php @@ -3,7 +3,7 @@ declare (strict_types=1); namespace PhpParser\Builder; -use RectorPrefix20220607\PhpParser; +use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Identifier; @@ -38,7 +38,7 @@ class Enum_ extends \PhpParser\Builder\Declaration */ public function setScalarType($scalarType) { - $this->scalarType = \PhpParser\BuilderHelpers::normalizeType($scalarType); + $this->scalarType = BuilderHelpers::normalizeType($scalarType); return $this; } /** @@ -51,7 +51,7 @@ class Enum_ extends \PhpParser\Builder\Declaration public function implement(...$interfaces) { foreach ($interfaces as $interface) { - $this->implements[] = \PhpParser\BuilderHelpers::normalizeName($interface); + $this->implements[] = BuilderHelpers::normalizeName($interface); } return $this; } @@ -64,8 +64,8 @@ class Enum_ extends \PhpParser\Builder\Declaration */ public function addStmt($stmt) { - $stmt = \PhpParser\BuilderHelpers::normalizeNode($stmt); - $targets = [\PhpParser\Node\Stmt\TraitUse::class => &$this->uses, \PhpParser\Node\Stmt\EnumCase::class => &$this->enumCases, \PhpParser\Node\Stmt\ClassConst::class => &$this->constants, \PhpParser\Node\Stmt\ClassMethod::class => &$this->methods]; + $stmt = BuilderHelpers::normalizeNode($stmt); + $targets = [Stmt\TraitUse::class => &$this->uses, Stmt\EnumCase::class => &$this->enumCases, Stmt\ClassConst::class => &$this->constants, Stmt\ClassMethod::class => &$this->methods]; $class = \get_class($stmt); if (!isset($targets[$class])) { throw new \LogicException(\sprintf('Unexpected node of type "%s"', $stmt->getType())); @@ -82,7 +82,7 @@ class Enum_ extends \PhpParser\Builder\Declaration */ public function addAttribute($attribute) { - $this->attributeGroups[] = \PhpParser\BuilderHelpers::normalizeAttribute($attribute); + $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } /** @@ -90,8 +90,8 @@ class Enum_ extends \PhpParser\Builder\Declaration * * @return Stmt\Enum_ The built enum node */ - public function getNode() : \PhpParser\Node + public function getNode() : PhpParser\Node { - return new \PhpParser\Node\Stmt\Enum_($this->name, ['scalarType' => $this->scalarType, 'implements' => $this->implements, 'stmts' => \array_merge($this->uses, $this->enumCases, $this->constants, $this->methods), 'attrGroups' => $this->attributeGroups], $this->attributes); + return new Stmt\Enum_($this->name, ['scalarType' => $this->scalarType, 'implements' => $this->implements, 'stmts' => \array_merge($this->uses, $this->enumCases, $this->constants, $this->methods), 'attrGroups' => $this->attributeGroups], $this->attributes); } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php b/vendor/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php index 588aca36d3f..6dfd36a77c1 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php @@ -30,8 +30,8 @@ abstract class FunctionLike extends \PhpParser\Builder\Declaration */ public function addParam($param) { - $param = \PhpParser\BuilderHelpers::normalizeNode($param); - if (!$param instanceof \PhpParser\Node\Param) { + $param = BuilderHelpers::normalizeNode($param); + if (!$param instanceof Node\Param) { throw new \LogicException(\sprintf('Expected parameter node, got "%s"', $param->getType())); } $this->params[] = $param; @@ -60,7 +60,7 @@ abstract class FunctionLike extends \PhpParser\Builder\Declaration */ public function setReturnType($type) { - $this->returnType = \PhpParser\BuilderHelpers::normalizeType($type); + $this->returnType = BuilderHelpers::normalizeType($type); return $this; } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Builder/Function_.php b/vendor/nikic/php-parser/lib/PhpParser/Builder/Function_.php index ab7a84d736a..f3c3ca3d54f 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Builder/Function_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Builder/Function_.php @@ -3,7 +3,7 @@ declare (strict_types=1); namespace PhpParser\Builder; -use RectorPrefix20220607\PhpParser; +use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Stmt; @@ -31,7 +31,7 @@ class Function_ extends \PhpParser\Builder\FunctionLike */ public function addStmt($stmt) { - $this->stmts[] = \PhpParser\BuilderHelpers::normalizeStmt($stmt); + $this->stmts[] = BuilderHelpers::normalizeStmt($stmt); return $this; } /** @@ -43,7 +43,7 @@ class Function_ extends \PhpParser\Builder\FunctionLike */ public function addAttribute($attribute) { - $this->attributeGroups[] = \PhpParser\BuilderHelpers::normalizeAttribute($attribute); + $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } /** @@ -51,8 +51,8 @@ class Function_ extends \PhpParser\Builder\FunctionLike * * @return Stmt\Function_ The built function node */ - public function getNode() : \PhpParser\Node + public function getNode() : Node { - return new \PhpParser\Node\Stmt\Function_($this->name, ['byRef' => $this->returnByRef, 'params' => $this->params, 'returnType' => $this->returnType, 'stmts' => $this->stmts, 'attrGroups' => $this->attributeGroups], $this->attributes); + return new Stmt\Function_($this->name, ['byRef' => $this->returnByRef, 'params' => $this->params, 'returnType' => $this->returnType, 'stmts' => $this->stmts, 'attrGroups' => $this->attributeGroups], $this->attributes); } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Builder/Interface_.php b/vendor/nikic/php-parser/lib/PhpParser/Builder/Interface_.php index 9bb780d0096..fcaa3e80918 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Builder/Interface_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Builder/Interface_.php @@ -3,7 +3,7 @@ declare (strict_types=1); namespace PhpParser\Builder; -use RectorPrefix20220607\PhpParser; +use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Name; @@ -35,7 +35,7 @@ class Interface_ extends \PhpParser\Builder\Declaration public function extend(...$interfaces) { foreach ($interfaces as $interface) { - $this->extends[] = \PhpParser\BuilderHelpers::normalizeName($interface); + $this->extends[] = BuilderHelpers::normalizeName($interface); } return $this; } @@ -48,10 +48,10 @@ class Interface_ extends \PhpParser\Builder\Declaration */ public function addStmt($stmt) { - $stmt = \PhpParser\BuilderHelpers::normalizeNode($stmt); - if ($stmt instanceof \PhpParser\Node\Stmt\ClassConst) { + $stmt = BuilderHelpers::normalizeNode($stmt); + if ($stmt instanceof Stmt\ClassConst) { $this->constants[] = $stmt; - } elseif ($stmt instanceof \PhpParser\Node\Stmt\ClassMethod) { + } elseif ($stmt instanceof Stmt\ClassMethod) { // we erase all statements in the body of an interface method $stmt->stmts = null; $this->methods[] = $stmt; @@ -69,7 +69,7 @@ class Interface_ extends \PhpParser\Builder\Declaration */ public function addAttribute($attribute) { - $this->attributeGroups[] = \PhpParser\BuilderHelpers::normalizeAttribute($attribute); + $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } /** @@ -77,8 +77,8 @@ class Interface_ extends \PhpParser\Builder\Declaration * * @return Stmt\Interface_ The built interface node */ - public function getNode() : \PhpParser\Node + public function getNode() : PhpParser\Node { - return new \PhpParser\Node\Stmt\Interface_($this->name, ['extends' => $this->extends, 'stmts' => \array_merge($this->constants, $this->methods), 'attrGroups' => $this->attributeGroups], $this->attributes); + return new Stmt\Interface_($this->name, ['extends' => $this->extends, 'stmts' => \array_merge($this->constants, $this->methods), 'attrGroups' => $this->attributeGroups], $this->attributes); } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php b/vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php index 1c5020c57c9..97050de1a27 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php @@ -3,7 +3,7 @@ declare (strict_types=1); namespace PhpParser\Builder; -use RectorPrefix20220607\PhpParser; +use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Stmt; @@ -31,7 +31,7 @@ class Method extends \PhpParser\Builder\FunctionLike */ public function makePublic() { - $this->flags = \PhpParser\BuilderHelpers::addModifier($this->flags, \PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PUBLIC); return $this; } /** @@ -41,7 +41,7 @@ class Method extends \PhpParser\Builder\FunctionLike */ public function makeProtected() { - $this->flags = \PhpParser\BuilderHelpers::addModifier($this->flags, \PhpParser\Node\Stmt\Class_::MODIFIER_PROTECTED); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PROTECTED); return $this; } /** @@ -51,7 +51,7 @@ class Method extends \PhpParser\Builder\FunctionLike */ public function makePrivate() { - $this->flags = \PhpParser\BuilderHelpers::addModifier($this->flags, \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PRIVATE); return $this; } /** @@ -61,7 +61,7 @@ class Method extends \PhpParser\Builder\FunctionLike */ public function makeStatic() { - $this->flags = \PhpParser\BuilderHelpers::addModifier($this->flags, \PhpParser\Node\Stmt\Class_::MODIFIER_STATIC); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_STATIC); return $this; } /** @@ -74,7 +74,7 @@ class Method extends \PhpParser\Builder\FunctionLike if (!empty($this->stmts)) { throw new \LogicException('Cannot make method with statements abstract'); } - $this->flags = \PhpParser\BuilderHelpers::addModifier($this->flags, \PhpParser\Node\Stmt\Class_::MODIFIER_ABSTRACT); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_ABSTRACT); $this->stmts = null; // abstract methods don't have statements return $this; @@ -86,7 +86,7 @@ class Method extends \PhpParser\Builder\FunctionLike */ public function makeFinal() { - $this->flags = \PhpParser\BuilderHelpers::addModifier($this->flags, \PhpParser\Node\Stmt\Class_::MODIFIER_FINAL); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_FINAL); return $this; } /** @@ -101,7 +101,7 @@ class Method extends \PhpParser\Builder\FunctionLike if (null === $this->stmts) { throw new \LogicException('Cannot add statements to an abstract method'); } - $this->stmts[] = \PhpParser\BuilderHelpers::normalizeStmt($stmt); + $this->stmts[] = BuilderHelpers::normalizeStmt($stmt); return $this; } /** @@ -113,7 +113,7 @@ class Method extends \PhpParser\Builder\FunctionLike */ public function addAttribute($attribute) { - $this->attributeGroups[] = \PhpParser\BuilderHelpers::normalizeAttribute($attribute); + $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } /** @@ -121,8 +121,8 @@ class Method extends \PhpParser\Builder\FunctionLike * * @return Stmt\ClassMethod The built method node */ - public function getNode() : \PhpParser\Node + public function getNode() : Node { - return new \PhpParser\Node\Stmt\ClassMethod($this->name, ['flags' => $this->flags, 'byRef' => $this->returnByRef, 'params' => $this->params, 'returnType' => $this->returnType, 'stmts' => $this->stmts, 'attrGroups' => $this->attributeGroups], $this->attributes); + return new Stmt\ClassMethod($this->name, ['flags' => $this->flags, 'byRef' => $this->returnByRef, 'params' => $this->params, 'returnType' => $this->returnType, 'stmts' => $this->stmts, 'attrGroups' => $this->attributeGroups], $this->attributes); } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php b/vendor/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php index 7988b75e370..5c76282a0ac 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php @@ -3,7 +3,7 @@ declare (strict_types=1); namespace PhpParser\Builder; -use RectorPrefix20220607\PhpParser; +use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Stmt; @@ -18,7 +18,7 @@ class Namespace_ extends \PhpParser\Builder\Declaration */ public function __construct($name) { - $this->name = null !== $name ? \PhpParser\BuilderHelpers::normalizeName($name) : null; + $this->name = null !== $name ? BuilderHelpers::normalizeName($name) : null; } /** * Adds a statement. @@ -29,7 +29,7 @@ class Namespace_ extends \PhpParser\Builder\Declaration */ public function addStmt($stmt) { - $this->stmts[] = \PhpParser\BuilderHelpers::normalizeStmt($stmt); + $this->stmts[] = BuilderHelpers::normalizeStmt($stmt); return $this; } /** @@ -37,8 +37,8 @@ class Namespace_ extends \PhpParser\Builder\Declaration * * @return Stmt\Namespace_ The built node */ - public function getNode() : \PhpParser\Node + public function getNode() : Node { - return new \PhpParser\Node\Stmt\Namespace_($this->name, $this->stmts, $this->attributes); + return new Stmt\Namespace_($this->name, $this->stmts, $this->attributes); } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php b/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php index 6711d3b1a5c..7b004725106 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php @@ -3,10 +3,10 @@ declare (strict_types=1); namespace PhpParser\Builder; -use RectorPrefix20220607\PhpParser; +use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Node; -class Param implements \PhpParser\Builder +class Param implements PhpParser\Builder { protected $name; protected $default = null; @@ -34,7 +34,7 @@ class Param implements \PhpParser\Builder */ public function setDefault($value) { - $this->default = \PhpParser\BuilderHelpers::normalizeValue($value); + $this->default = BuilderHelpers::normalizeValue($value); return $this; } /** @@ -46,7 +46,7 @@ class Param implements \PhpParser\Builder */ public function setType($type) { - $this->type = \PhpParser\BuilderHelpers::normalizeType($type); + $this->type = BuilderHelpers::normalizeType($type); if ($this->type == 'void') { throw new \LogicException('Parameter type cannot be void'); } @@ -94,7 +94,7 @@ class Param implements \PhpParser\Builder */ public function addAttribute($attribute) { - $this->attributeGroups[] = \PhpParser\BuilderHelpers::normalizeAttribute($attribute); + $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } /** @@ -102,8 +102,8 @@ class Param implements \PhpParser\Builder * * @return Node\Param The built parameter node */ - public function getNode() : \PhpParser\Node + public function getNode() : Node { - return new \PhpParser\Node\Param(new \PhpParser\Node\Expr\Variable($this->name), $this->default, $this->type, $this->byRef, $this->variadic, [], 0, $this->attributeGroups); + return new Node\Param(new Node\Expr\Variable($this->name), $this->default, $this->type, $this->byRef, $this->variadic, [], 0, $this->attributeGroups); } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php b/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php index da1bb76b6ce..7a985e7c498 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php @@ -3,14 +3,14 @@ declare (strict_types=1); namespace PhpParser\Builder; -use RectorPrefix20220607\PhpParser; +use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Identifier; use PhpParser\Node\Name; use PhpParser\Node\Stmt; use PhpParser\Node\ComplexType; -class Property implements \PhpParser\Builder +class Property implements PhpParser\Builder { protected $name; protected $flags = 0; @@ -36,7 +36,7 @@ class Property implements \PhpParser\Builder */ public function makePublic() { - $this->flags = \PhpParser\BuilderHelpers::addModifier($this->flags, \PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PUBLIC); return $this; } /** @@ -46,7 +46,7 @@ class Property implements \PhpParser\Builder */ public function makeProtected() { - $this->flags = \PhpParser\BuilderHelpers::addModifier($this->flags, \PhpParser\Node\Stmt\Class_::MODIFIER_PROTECTED); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PROTECTED); return $this; } /** @@ -56,7 +56,7 @@ class Property implements \PhpParser\Builder */ public function makePrivate() { - $this->flags = \PhpParser\BuilderHelpers::addModifier($this->flags, \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PRIVATE); return $this; } /** @@ -66,7 +66,7 @@ class Property implements \PhpParser\Builder */ public function makeStatic() { - $this->flags = \PhpParser\BuilderHelpers::addModifier($this->flags, \PhpParser\Node\Stmt\Class_::MODIFIER_STATIC); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_STATIC); return $this; } /** @@ -76,7 +76,7 @@ class Property implements \PhpParser\Builder */ public function makeReadonly() { - $this->flags = \PhpParser\BuilderHelpers::addModifier($this->flags, \PhpParser\Node\Stmt\Class_::MODIFIER_READONLY); + $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_READONLY); return $this; } /** @@ -88,7 +88,7 @@ class Property implements \PhpParser\Builder */ public function setDefault($value) { - $this->default = \PhpParser\BuilderHelpers::normalizeValue($value); + $this->default = BuilderHelpers::normalizeValue($value); return $this; } /** @@ -100,7 +100,7 @@ class Property implements \PhpParser\Builder */ public function setDocComment($docComment) { - $this->attributes = ['comments' => [\PhpParser\BuilderHelpers::normalizeDocComment($docComment)]]; + $this->attributes = ['comments' => [BuilderHelpers::normalizeDocComment($docComment)]]; return $this; } /** @@ -112,7 +112,7 @@ class Property implements \PhpParser\Builder */ public function setType($type) { - $this->type = \PhpParser\BuilderHelpers::normalizeType($type); + $this->type = BuilderHelpers::normalizeType($type); return $this; } /** @@ -124,7 +124,7 @@ class Property implements \PhpParser\Builder */ public function addAttribute($attribute) { - $this->attributeGroups[] = \PhpParser\BuilderHelpers::normalizeAttribute($attribute); + $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } /** @@ -132,8 +132,8 @@ class Property implements \PhpParser\Builder * * @return Stmt\Property The built property node */ - public function getNode() : \PhpParser\Node + public function getNode() : PhpParser\Node { - return new \PhpParser\Node\Stmt\Property($this->flags !== 0 ? $this->flags : \PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC, [new \PhpParser\Node\Stmt\PropertyProperty($this->name, $this->default)], $this->attributes, $this->type, $this->attributeGroups); + return new Stmt\Property($this->flags !== 0 ? $this->flags : Stmt\Class_::MODIFIER_PUBLIC, [new Stmt\PropertyProperty($this->name, $this->default)], $this->attributes, $this->type, $this->attributeGroups); } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUse.php b/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUse.php index c7a70eb7111..0c68467ca68 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUse.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUse.php @@ -7,7 +7,7 @@ use PhpParser\Builder; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Stmt; -class TraitUse implements \PhpParser\Builder +class TraitUse implements Builder { protected $traits = []; protected $adaptations = []; @@ -31,7 +31,7 @@ class TraitUse implements \PhpParser\Builder */ public function and($trait) { - $this->traits[] = \PhpParser\BuilderHelpers::normalizeName($trait); + $this->traits[] = BuilderHelpers::normalizeName($trait); return $this; } /** @@ -43,8 +43,8 @@ class TraitUse implements \PhpParser\Builder */ public function with($adaptation) { - $adaptation = \PhpParser\BuilderHelpers::normalizeNode($adaptation); - if (!$adaptation instanceof \PhpParser\Node\Stmt\TraitUseAdaptation) { + $adaptation = BuilderHelpers::normalizeNode($adaptation); + if (!$adaptation instanceof Stmt\TraitUseAdaptation) { throw new \LogicException('Adaptation must have type TraitUseAdaptation'); } $this->adaptations[] = $adaptation; @@ -55,8 +55,8 @@ class TraitUse implements \PhpParser\Builder * * @return Node The built node */ - public function getNode() : \PhpParser\Node + public function getNode() : Node { - return new \PhpParser\Node\Stmt\TraitUse($this->traits, $this->adaptations); + return new Stmt\TraitUse($this->traits, $this->adaptations); } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php b/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php index e81a68a46c1..094a0c975d7 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php @@ -7,7 +7,7 @@ use PhpParser\Builder; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Stmt; -class TraitUseAdaptation implements \PhpParser\Builder +class TraitUseAdaptation implements Builder { const TYPE_UNDEFINED = 0; const TYPE_ALIAS = 1; @@ -28,8 +28,8 @@ class TraitUseAdaptation implements \PhpParser\Builder public function __construct($trait, $method) { $this->type = self::TYPE_UNDEFINED; - $this->trait = \is_null($trait) ? null : \PhpParser\BuilderHelpers::normalizeName($trait); - $this->method = \PhpParser\BuilderHelpers::normalizeIdentifier($method); + $this->trait = \is_null($trait) ? null : BuilderHelpers::normalizeName($trait); + $this->method = BuilderHelpers::normalizeIdentifier($method); } /** * Sets alias of method. @@ -56,7 +56,7 @@ class TraitUseAdaptation implements \PhpParser\Builder */ public function makePublic() { - $this->setModifier(\PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC); + $this->setModifier(Stmt\Class_::MODIFIER_PUBLIC); return $this; } /** @@ -66,7 +66,7 @@ class TraitUseAdaptation implements \PhpParser\Builder */ public function makeProtected() { - $this->setModifier(\PhpParser\Node\Stmt\Class_::MODIFIER_PROTECTED); + $this->setModifier(Stmt\Class_::MODIFIER_PROTECTED); return $this; } /** @@ -76,7 +76,7 @@ class TraitUseAdaptation implements \PhpParser\Builder */ public function makePrivate() { - $this->setModifier(\PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $this->setModifier(Stmt\Class_::MODIFIER_PRIVATE); return $this; } /** @@ -98,7 +98,7 @@ class TraitUseAdaptation implements \PhpParser\Builder throw new \LogicException('Cannot add overwritten traits for not precedence adaptation buider'); } foreach ($traits as $trait) { - $this->insteadof[] = \PhpParser\BuilderHelpers::normalizeName($trait); + $this->insteadof[] = BuilderHelpers::normalizeName($trait); } return $this; } @@ -121,13 +121,13 @@ class TraitUseAdaptation implements \PhpParser\Builder * * @return Node The built node */ - public function getNode() : \PhpParser\Node + public function getNode() : Node { switch ($this->type) { case self::TYPE_ALIAS: - return new \PhpParser\Node\Stmt\TraitUseAdaptation\Alias($this->trait, $this->method, $this->modifier, $this->alias); + return new Stmt\TraitUseAdaptation\Alias($this->trait, $this->method, $this->modifier, $this->alias); case self::TYPE_PRECEDENCE: - return new \PhpParser\Node\Stmt\TraitUseAdaptation\Precedence($this->trait, $this->method, $this->insteadof); + return new Stmt\TraitUseAdaptation\Precedence($this->trait, $this->method, $this->insteadof); default: throw new \LogicException('Type of adaptation is not defined'); } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Builder/Trait_.php b/vendor/nikic/php-parser/lib/PhpParser/Builder/Trait_.php index 187945889be..fe26aec5d6b 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Builder/Trait_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Builder/Trait_.php @@ -3,7 +3,7 @@ declare (strict_types=1); namespace PhpParser\Builder; -use RectorPrefix20220607\PhpParser; +use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Stmt; @@ -33,12 +33,12 @@ class Trait_ extends \PhpParser\Builder\Declaration */ public function addStmt($stmt) { - $stmt = \PhpParser\BuilderHelpers::normalizeNode($stmt); - if ($stmt instanceof \PhpParser\Node\Stmt\Property) { + $stmt = BuilderHelpers::normalizeNode($stmt); + if ($stmt instanceof Stmt\Property) { $this->properties[] = $stmt; - } elseif ($stmt instanceof \PhpParser\Node\Stmt\ClassMethod) { + } elseif ($stmt instanceof Stmt\ClassMethod) { $this->methods[] = $stmt; - } elseif ($stmt instanceof \PhpParser\Node\Stmt\TraitUse) { + } elseif ($stmt instanceof Stmt\TraitUse) { $this->uses[] = $stmt; } else { throw new \LogicException(\sprintf('Unexpected node of type "%s"', $stmt->getType())); @@ -54,7 +54,7 @@ class Trait_ extends \PhpParser\Builder\Declaration */ public function addAttribute($attribute) { - $this->attributeGroups[] = \PhpParser\BuilderHelpers::normalizeAttribute($attribute); + $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } /** @@ -62,8 +62,8 @@ class Trait_ extends \PhpParser\Builder\Declaration * * @return Stmt\Trait_ The built interface node */ - public function getNode() : \PhpParser\Node + public function getNode() : PhpParser\Node { - return new \PhpParser\Node\Stmt\Trait_($this->name, ['stmts' => \array_merge($this->uses, $this->properties, $this->methods), 'attrGroups' => $this->attributeGroups], $this->attributes); + return new Stmt\Trait_($this->name, ['stmts' => \array_merge($this->uses, $this->properties, $this->methods), 'attrGroups' => $this->attributeGroups], $this->attributes); } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Builder/Use_.php b/vendor/nikic/php-parser/lib/PhpParser/Builder/Use_.php index 88abf33b5a1..58da5234555 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Builder/Use_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Builder/Use_.php @@ -7,7 +7,7 @@ use PhpParser\Builder; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Stmt; -class Use_ implements \PhpParser\Builder +class Use_ implements Builder { protected $name; protected $type; @@ -20,7 +20,7 @@ class Use_ implements \PhpParser\Builder */ public function __construct($name, int $type) { - $this->name = \PhpParser\BuilderHelpers::normalizeName($name); + $this->name = BuilderHelpers::normalizeName($name); $this->type = $type; } /** @@ -40,8 +40,8 @@ class Use_ implements \PhpParser\Builder * * @return Stmt\Use_ The built node */ - public function getNode() : \PhpParser\Node + public function getNode() : Node { - return new \PhpParser\Node\Stmt\Use_([new \PhpParser\Node\Stmt\UseUse($this->name, $this->alias)], $this->type); + return new Stmt\Use_([new Stmt\UseUse($this->name, $this->alias)], $this->type); } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/BuilderFactory.php b/vendor/nikic/php-parser/lib/PhpParser/BuilderFactory.php index b7e632c8cf0..fc97c3ec35e 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/BuilderFactory.php +++ b/vendor/nikic/php-parser/lib/PhpParser/BuilderFactory.php @@ -159,7 +159,7 @@ class BuilderFactory */ public function use($name) : \PhpParser\Builder\Use_ { - return new \PhpParser\Builder\Use_($name, \PhpParser\Node\Stmt\Use_::TYPE_NORMAL); + return new \PhpParser\Builder\Use_($name, Use_::TYPE_NORMAL); } /** * Creates a function use builder. @@ -170,7 +170,7 @@ class BuilderFactory */ public function useFunction($name) : \PhpParser\Builder\Use_ { - return new \PhpParser\Builder\Use_($name, \PhpParser\Node\Stmt\Use_::TYPE_FUNCTION); + return new \PhpParser\Builder\Use_($name, Use_::TYPE_FUNCTION); } /** * Creates a constant use builder. @@ -181,7 +181,7 @@ class BuilderFactory */ public function useConst($name) : \PhpParser\Builder\Use_ { - return new \PhpParser\Builder\Use_($name, \PhpParser\Node\Stmt\Use_::TYPE_CONSTANT); + return new \PhpParser\Builder\Use_($name, Use_::TYPE_CONSTANT); } /** * Creates a class constant builder. @@ -213,7 +213,7 @@ class BuilderFactory * * @return Expr */ - public function val($value) : \PhpParser\Node\Expr + public function val($value) : Expr { return \PhpParser\BuilderHelpers::normalizeValue($value); } @@ -224,12 +224,12 @@ class BuilderFactory * * @return Expr\Variable */ - public function var($name) : \PhpParser\Node\Expr\Variable + public function var($name) : Expr\Variable { - if (!\is_string($name) && !$name instanceof \PhpParser\Node\Expr) { + if (!\is_string($name) && !$name instanceof Expr) { throw new \LogicException('Variable name must be string or Expr'); } - return new \PhpParser\Node\Expr\Variable($name); + return new Expr\Variable($name); } /** * Normalizes an argument list. @@ -244,8 +244,8 @@ class BuilderFactory { $normalizedArgs = []; foreach ($args as $key => $arg) { - if (!$arg instanceof \PhpParser\Node\Arg) { - $arg = new \PhpParser\Node\Arg(\PhpParser\BuilderHelpers::normalizeValue($arg)); + if (!$arg instanceof Arg) { + $arg = new Arg(\PhpParser\BuilderHelpers::normalizeValue($arg)); } if (\is_string($key)) { $arg->name = \PhpParser\BuilderHelpers::normalizeIdentifier($key); @@ -262,9 +262,9 @@ class BuilderFactory * * @return Expr\FuncCall */ - public function funcCall($name, array $args = []) : \PhpParser\Node\Expr\FuncCall + public function funcCall($name, array $args = []) : Expr\FuncCall { - return new \PhpParser\Node\Expr\FuncCall(\PhpParser\BuilderHelpers::normalizeNameOrExpr($name), $this->args($args)); + return new Expr\FuncCall(\PhpParser\BuilderHelpers::normalizeNameOrExpr($name), $this->args($args)); } /** * Creates a method call node. @@ -275,9 +275,9 @@ class BuilderFactory * * @return Expr\MethodCall */ - public function methodCall(\PhpParser\Node\Expr $var, $name, array $args = []) : \PhpParser\Node\Expr\MethodCall + public function methodCall(Expr $var, $name, array $args = []) : Expr\MethodCall { - return new \PhpParser\Node\Expr\MethodCall($var, \PhpParser\BuilderHelpers::normalizeIdentifierOrExpr($name), $this->args($args)); + return new Expr\MethodCall($var, \PhpParser\BuilderHelpers::normalizeIdentifierOrExpr($name), $this->args($args)); } /** * Creates a static method call node. @@ -288,9 +288,9 @@ class BuilderFactory * * @return Expr\StaticCall */ - public function staticCall($class, $name, array $args = []) : \PhpParser\Node\Expr\StaticCall + public function staticCall($class, $name, array $args = []) : Expr\StaticCall { - return new \PhpParser\Node\Expr\StaticCall(\PhpParser\BuilderHelpers::normalizeNameOrExpr($class), \PhpParser\BuilderHelpers::normalizeIdentifierOrExpr($name), $this->args($args)); + return new Expr\StaticCall(\PhpParser\BuilderHelpers::normalizeNameOrExpr($class), \PhpParser\BuilderHelpers::normalizeIdentifierOrExpr($name), $this->args($args)); } /** * Creates an object creation node. @@ -300,9 +300,9 @@ class BuilderFactory * * @return Expr\New_ */ - public function new($class, array $args = []) : \PhpParser\Node\Expr\New_ + public function new($class, array $args = []) : Expr\New_ { - return new \PhpParser\Node\Expr\New_(\PhpParser\BuilderHelpers::normalizeNameOrExpr($class), $this->args($args)); + return new Expr\New_(\PhpParser\BuilderHelpers::normalizeNameOrExpr($class), $this->args($args)); } /** * Creates a constant fetch node. @@ -311,9 +311,9 @@ class BuilderFactory * * @return Expr\ConstFetch */ - public function constFetch($name) : \PhpParser\Node\Expr\ConstFetch + public function constFetch($name) : Expr\ConstFetch { - return new \PhpParser\Node\Expr\ConstFetch(\PhpParser\BuilderHelpers::normalizeName($name)); + return new Expr\ConstFetch(\PhpParser\BuilderHelpers::normalizeName($name)); } /** * Creates a property fetch node. @@ -323,9 +323,9 @@ class BuilderFactory * * @return Expr\PropertyFetch */ - public function propertyFetch(\PhpParser\Node\Expr $var, $name) : \PhpParser\Node\Expr\PropertyFetch + public function propertyFetch(Expr $var, $name) : Expr\PropertyFetch { - return new \PhpParser\Node\Expr\PropertyFetch($var, \PhpParser\BuilderHelpers::normalizeIdentifierOrExpr($name)); + return new Expr\PropertyFetch($var, \PhpParser\BuilderHelpers::normalizeIdentifierOrExpr($name)); } /** * Creates a class constant fetch node. @@ -335,9 +335,9 @@ class BuilderFactory * * @return Expr\ClassConstFetch */ - public function classConstFetch($class, $name) : \PhpParser\Node\Expr\ClassConstFetch + public function classConstFetch($class, $name) : Expr\ClassConstFetch { - return new \PhpParser\Node\Expr\ClassConstFetch(\PhpParser\BuilderHelpers::normalizeNameOrExpr($class), \PhpParser\BuilderHelpers::normalizeIdentifier($name)); + return new Expr\ClassConstFetch(\PhpParser\BuilderHelpers::normalizeNameOrExpr($class), \PhpParser\BuilderHelpers::normalizeIdentifier($name)); } /** * Creates nested Concat nodes from a list of expressions. @@ -346,7 +346,7 @@ class BuilderFactory * * @return Concat */ - public function concat(...$exprs) : \PhpParser\Node\Expr\BinaryOp\Concat + public function concat(...$exprs) : Concat { $numExprs = \count($exprs); if ($numExprs < 2) { @@ -354,7 +354,7 @@ class BuilderFactory } $lastConcat = $this->normalizeStringExpr($exprs[0]); for ($i = 1; $i < $numExprs; $i++) { - $lastConcat = new \PhpParser\Node\Expr\BinaryOp\Concat($lastConcat, $this->normalizeStringExpr($exprs[$i])); + $lastConcat = new Concat($lastConcat, $this->normalizeStringExpr($exprs[$i])); } return $lastConcat; } @@ -362,13 +362,13 @@ class BuilderFactory * @param string|Expr $expr * @return Expr */ - private function normalizeStringExpr($expr) : \PhpParser\Node\Expr + private function normalizeStringExpr($expr) : Expr { - if ($expr instanceof \PhpParser\Node\Expr) { + if ($expr instanceof Expr) { return $expr; } if (\is_string($expr)) { - return new \PhpParser\Node\Scalar\String_($expr); + return new String_($expr); } throw new \LogicException('Expected string or Expr'); } diff --git a/vendor/nikic/php-parser/lib/PhpParser/BuilderHelpers.php b/vendor/nikic/php-parser/lib/PhpParser/BuilderHelpers.php index 4f13d5ec7f1..c8b3881f9c6 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/BuilderHelpers.php +++ b/vendor/nikic/php-parser/lib/PhpParser/BuilderHelpers.php @@ -43,14 +43,14 @@ final class BuilderHelpers * * @return Stmt The normalized statement node */ - public static function normalizeStmt($node) : \PhpParser\Node\Stmt + public static function normalizeStmt($node) : Stmt { $node = self::normalizeNode($node); - if ($node instanceof \PhpParser\Node\Stmt) { + if ($node instanceof Stmt) { return $node; } - if ($node instanceof \PhpParser\Node\Expr) { - return new \PhpParser\Node\Stmt\Expression($node); + if ($node instanceof Expr) { + return new Stmt\Expression($node); } throw new \LogicException('Expected statement or expression node'); } @@ -61,13 +61,13 @@ final class BuilderHelpers * * @return Identifier The normalized identifier */ - public static function normalizeIdentifier($name) : \PhpParser\Node\Identifier + public static function normalizeIdentifier($name) : Identifier { - if ($name instanceof \PhpParser\Node\Identifier) { + if ($name instanceof Identifier) { return $name; } if (\is_string($name)) { - return new \PhpParser\Node\Identifier($name); + return new Identifier($name); } throw new \LogicException('RectorPrefix20220607\\Expected string or instance of Node\\Identifier'); } @@ -80,11 +80,11 @@ final class BuilderHelpers */ public static function normalizeIdentifierOrExpr($name) { - if ($name instanceof \PhpParser\Node\Identifier || $name instanceof \PhpParser\Node\Expr) { + if ($name instanceof Identifier || $name instanceof Expr) { return $name; } if (\is_string($name)) { - return new \PhpParser\Node\Identifier($name); + return new Identifier($name); } throw new \LogicException('RectorPrefix20220607\\Expected string or instance of Node\\Identifier or Node\\Expr'); } @@ -95,9 +95,9 @@ final class BuilderHelpers * * @return Name The normalized name */ - public static function normalizeName($name) : \PhpParser\Node\Name + public static function normalizeName($name) : Name { - if ($name instanceof \PhpParser\Node\Name) { + if ($name instanceof Name) { return $name; } if (\is_string($name)) { @@ -105,12 +105,12 @@ final class BuilderHelpers throw new \LogicException('Name cannot be empty'); } if ($name[0] === '\\') { - return new \PhpParser\Node\Name\FullyQualified(\substr($name, 1)); + return new Name\FullyQualified(\substr($name, 1)); } if (0 === \strpos($name, 'namespace\\')) { - return new \PhpParser\Node\Name\Relative(\substr($name, \strlen('namespace\\'))); + return new Name\Relative(\substr($name, \strlen('namespace\\'))); } - return new \PhpParser\Node\Name($name); + return new Name($name); } throw new \LogicException('RectorPrefix20220607\\Name must be a string or an instance of Node\\Name'); } @@ -123,10 +123,10 @@ final class BuilderHelpers */ public static function normalizeNameOrExpr($name) { - if ($name instanceof \PhpParser\Node\Expr) { + if ($name instanceof Expr) { return $name; } - if (!\is_string($name) && !$name instanceof \PhpParser\Node\Name) { + if (!\is_string($name) && !$name instanceof Name) { throw new \LogicException('RectorPrefix20220607\\Name must be a string or an instance of Node\\Name or Node\\Expr'); } return self::normalizeName($name); @@ -144,7 +144,7 @@ final class BuilderHelpers public static function normalizeType($type) { if (!\is_string($type)) { - if (!$type instanceof \PhpParser\Node\Name && !$type instanceof \PhpParser\Node\Identifier && !$type instanceof \PhpParser\Node\ComplexType) { + if (!$type instanceof Name && !$type instanceof Identifier && !$type instanceof ComplexType) { throw new \LogicException('Type must be a string, or an instance of Name, Identifier or ComplexType'); } return $type; @@ -157,7 +157,7 @@ final class BuilderHelpers $builtinTypes = ['array', 'callable', 'string', 'int', 'float', 'bool', 'iterable', 'void', 'object', 'mixed', 'never']; $lowerType = \strtolower($type); if (\in_array($lowerType, $builtinTypes)) { - $type = new \PhpParser\Node\Identifier($lowerType); + $type = new Identifier($lowerType); } else { $type = self::normalizeName($type); } @@ -165,7 +165,7 @@ final class BuilderHelpers if ($nullable && \in_array((string) $type, $notNullableTypes)) { throw new \LogicException(\sprintf('%s type cannot be nullable', $type)); } - return $nullable ? new \PhpParser\Node\NullableType($type) : $type; + return $nullable ? new NullableType($type) : $type; } /** * Normalizes a value: Converts nulls, booleans, integers, @@ -175,25 +175,25 @@ final class BuilderHelpers * * @return Expr The normalized value */ - public static function normalizeValue($value) : \PhpParser\Node\Expr + public static function normalizeValue($value) : Expr { if ($value instanceof \PhpParser\Node\Expr) { return $value; } if (\is_null($value)) { - return new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('null')); + return new Expr\ConstFetch(new Name('null')); } if (\is_bool($value)) { - return new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name($value ? 'true' : 'false')); + return new Expr\ConstFetch(new Name($value ? 'true' : 'false')); } if (\is_int($value)) { - return new \PhpParser\Node\Scalar\LNumber($value); + return new Scalar\LNumber($value); } if (\is_float($value)) { - return new \PhpParser\Node\Scalar\DNumber($value); + return new Scalar\DNumber($value); } if (\is_string($value)) { - return new \PhpParser\Node\Scalar\String_($value); + return new Scalar\String_($value); } if (\is_array($value)) { $items = []; @@ -201,13 +201,13 @@ final class BuilderHelpers foreach ($value as $itemKey => $itemValue) { // for consecutive, numeric keys don't generate keys if (null !== $lastKey && ++$lastKey === $itemKey) { - $items[] = new \PhpParser\Node\Expr\ArrayItem(self::normalizeValue($itemValue)); + $items[] = new Expr\ArrayItem(self::normalizeValue($itemValue)); } else { $lastKey = null; - $items[] = new \PhpParser\Node\Expr\ArrayItem(self::normalizeValue($itemValue), self::normalizeValue($itemKey)); + $items[] = new Expr\ArrayItem(self::normalizeValue($itemValue), self::normalizeValue($itemKey)); } } - return new \PhpParser\Node\Expr\Array_($items); + return new Expr\Array_($items); } throw new \LogicException('Invalid value'); } @@ -255,7 +255,7 @@ final class BuilderHelpers */ public static function addModifier(int $modifiers, int $modifier) : int { - \PhpParser\Node\Stmt\Class_::verifyModifier($modifiers, $modifier); + Stmt\Class_::verifyModifier($modifiers, $modifier); return $modifiers | $modifier; } /** @@ -264,7 +264,7 @@ final class BuilderHelpers */ public static function addClassModifier(int $existingModifiers, int $modifierToSet) : int { - \PhpParser\Node\Stmt\Class_::verifyClassModifier($existingModifiers, $modifierToSet); + Stmt\Class_::verifyClassModifier($existingModifiers, $modifierToSet); return $existingModifiers | $modifierToSet; } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/ConstExprEvaluator.php b/vendor/nikic/php-parser/lib/PhpParser/ConstExprEvaluator.php index ef9e4100b4e..b37c94a1c81 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/ConstExprEvaluator.php +++ b/vendor/nikic/php-parser/lib/PhpParser/ConstExprEvaluator.php @@ -37,7 +37,7 @@ class ConstExprEvaluator */ public function __construct(callable $fallbackEvaluator = null) { - $this->fallbackEvaluator = $fallbackEvaluator ?? function (\PhpParser\Node\Expr $expr) { + $this->fallbackEvaluator = $fallbackEvaluator ?? function (Expr $expr) { throw new \PhpParser\ConstExprEvaluationException("Expression of type {$expr->getType()} cannot be evaluated"); }; } @@ -58,7 +58,7 @@ class ConstExprEvaluator * * @throws ConstExprEvaluationException if the expression cannot be evaluated or an error occurred */ - public function evaluateSilently(\PhpParser\Node\Expr $expr) + public function evaluateSilently(Expr $expr) { \set_error_handler(function ($num, $str, $file, $line) { throw new \ErrorException($str, 0, $num, $file, $line); @@ -91,69 +91,69 @@ class ConstExprEvaluator * * @throws ConstExprEvaluationException if the expression cannot be evaluated */ - public function evaluateDirectly(\PhpParser\Node\Expr $expr) + public function evaluateDirectly(Expr $expr) { return $this->evaluate($expr); } - private function evaluate(\PhpParser\Node\Expr $expr) + private function evaluate(Expr $expr) { - if ($expr instanceof \PhpParser\Node\Scalar\LNumber || $expr instanceof \PhpParser\Node\Scalar\DNumber || $expr instanceof \PhpParser\Node\Scalar\String_) { + if ($expr instanceof Scalar\LNumber || $expr instanceof Scalar\DNumber || $expr instanceof Scalar\String_) { return $expr->value; } - if ($expr instanceof \PhpParser\Node\Expr\Array_) { + if ($expr instanceof Expr\Array_) { return $this->evaluateArray($expr); } // Unary operators - if ($expr instanceof \PhpParser\Node\Expr\UnaryPlus) { + if ($expr instanceof Expr\UnaryPlus) { return +$this->evaluate($expr->expr); } - if ($expr instanceof \PhpParser\Node\Expr\UnaryMinus) { + if ($expr instanceof Expr\UnaryMinus) { return -$this->evaluate($expr->expr); } - if ($expr instanceof \PhpParser\Node\Expr\BooleanNot) { + if ($expr instanceof Expr\BooleanNot) { return !$this->evaluate($expr->expr); } - if ($expr instanceof \PhpParser\Node\Expr\BitwiseNot) { + if ($expr instanceof Expr\BitwiseNot) { return ~$this->evaluate($expr->expr); } - if ($expr instanceof \PhpParser\Node\Expr\BinaryOp) { + if ($expr instanceof Expr\BinaryOp) { return $this->evaluateBinaryOp($expr); } - if ($expr instanceof \PhpParser\Node\Expr\Ternary) { + if ($expr instanceof Expr\Ternary) { return $this->evaluateTernary($expr); } - if ($expr instanceof \PhpParser\Node\Expr\ArrayDimFetch && null !== $expr->dim) { + if ($expr instanceof Expr\ArrayDimFetch && null !== $expr->dim) { return $this->evaluate($expr->var)[$this->evaluate($expr->dim)]; } - if ($expr instanceof \PhpParser\Node\Expr\ConstFetch) { + if ($expr instanceof Expr\ConstFetch) { return $this->evaluateConstFetch($expr); } return ($this->fallbackEvaluator)($expr); } - private function evaluateArray(\PhpParser\Node\Expr\Array_ $expr) + private function evaluateArray(Expr\Array_ $expr) { $array = []; foreach ($expr->items as $item) { if (null !== $item->key) { $array[$this->evaluate($item->key)] = $this->evaluate($item->value); } elseif ($item->unpack) { - $array = \array_merge($array, $this->evaluate($item->value)); + $array = array_merge($array, $this->evaluate($item->value)); } else { $array[] = $this->evaluate($item->value); } } return $array; } - private function evaluateTernary(\PhpParser\Node\Expr\Ternary $expr) + private function evaluateTernary(Expr\Ternary $expr) { if (null === $expr->if) { return $this->evaluate($expr->cond) ?: $this->evaluate($expr->else); } return $this->evaluate($expr->cond) ? $this->evaluate($expr->if) : $this->evaluate($expr->else); } - private function evaluateBinaryOp(\PhpParser\Node\Expr\BinaryOp $expr) + private function evaluateBinaryOp(Expr\BinaryOp $expr) { - if ($expr instanceof \PhpParser\Node\Expr\BinaryOp\Coalesce && $expr->left instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if ($expr instanceof Expr\BinaryOp\Coalesce && $expr->left instanceof Expr\ArrayDimFetch) { // This needs to be special cased to respect BP_VAR_IS fetch semantics return $this->evaluate($expr->left->var)[$this->evaluate($expr->left->dim)] ?? $this->evaluate($expr->right); } @@ -219,7 +219,7 @@ class ConstExprEvaluator } throw new \Exception('Should not happen'); } - private function evaluateConstFetch(\PhpParser\Node\Expr\ConstFetch $expr) + private function evaluateConstFetch(Expr\ConstFetch $expr) { $name = $expr->name->toLowerString(); switch ($name) { diff --git a/vendor/nikic/php-parser/lib/PhpParser/ErrorHandler/Collecting.php b/vendor/nikic/php-parser/lib/PhpParser/ErrorHandler/Collecting.php index 77cdc669a5c..536fc0bf5d0 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/ErrorHandler/Collecting.php +++ b/vendor/nikic/php-parser/lib/PhpParser/ErrorHandler/Collecting.php @@ -10,11 +10,11 @@ use PhpParser\ErrorHandler; * * This allows graceful handling of errors. */ -class Collecting implements \PhpParser\ErrorHandler +class Collecting implements ErrorHandler { /** @var Error[] Collected errors */ private $errors = []; - public function handleError(\PhpParser\Error $error) + public function handleError(Error $error) { $this->errors[] = $error; } diff --git a/vendor/nikic/php-parser/lib/PhpParser/ErrorHandler/Throwing.php b/vendor/nikic/php-parser/lib/PhpParser/ErrorHandler/Throwing.php index 98a384ea3f9..7308184f715 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/ErrorHandler/Throwing.php +++ b/vendor/nikic/php-parser/lib/PhpParser/ErrorHandler/Throwing.php @@ -10,9 +10,9 @@ use PhpParser\ErrorHandler; * * This is the default strategy used by all components. */ -class Throwing implements \PhpParser\ErrorHandler +class Throwing implements ErrorHandler { - public function handleError(\PhpParser\Error $error) + public function handleError(Error $error) { throw $error; } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Internal/PrintableNewAnonClassNode.php b/vendor/nikic/php-parser/lib/PhpParser/Internal/PrintableNewAnonClassNode.php index 6885403e946..8acf128e12c 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Internal/PrintableNewAnonClassNode.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Internal/PrintableNewAnonClassNode.php @@ -15,7 +15,7 @@ use PhpParser\Node\Expr; * * @internal */ -class PrintableNewAnonClassNode extends \PhpParser\Node\Expr +class PrintableNewAnonClassNode extends Expr { /** @var Node\AttributeGroup[] PHP attribute groups */ public $attrGroups; @@ -27,7 +27,7 @@ class PrintableNewAnonClassNode extends \PhpParser\Node\Expr public $implements; /** @var Node\Stmt[] Statements */ public $stmts; - public function __construct(array $attrGroups, array $args, \PhpParser\Node\Name $extends = null, array $implements, array $stmts, array $attributes) + public function __construct(array $attrGroups, array $args, Node\Name $extends = null, array $implements, array $stmts, array $attributes) { parent::__construct($attributes); $this->attrGroups = $attrGroups; @@ -36,10 +36,10 @@ class PrintableNewAnonClassNode extends \PhpParser\Node\Expr $this->implements = $implements; $this->stmts = $stmts; } - public static function fromNewNode(\PhpParser\Node\Expr\New_ $newNode) + public static function fromNewNode(Expr\New_ $newNode) { $class = $newNode->class; - \assert($class instanceof \PhpParser\Node\Stmt\Class_); + \assert($class instanceof Node\Stmt\Class_); // We don't assert that $class->name is null here, to allow consumers to assign unique names // to anonymous classes for their own purposes. We simplify ignore the name here. return new self($class->attrGroups, $newNode->args, $class->extends, $class->implements, $class->stmts, $newNode->getAttributes()); diff --git a/vendor/nikic/php-parser/lib/PhpParser/Lexer.php b/vendor/nikic/php-parser/lib/PhpParser/Lexer.php index 0316edbbfd6..e7c12943981 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Lexer.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Lexer.php @@ -86,7 +86,7 @@ class Lexer $tokens = []; for ($i = $start; $i < $end; $i++) { $chr = $this->code[$i]; - if ($chr === "\0") { + if ($chr === "\x00") { // PHP cuts error message after null byte, so need special case $errorMsg = 'Unexpected null byte'; } else { @@ -257,7 +257,7 @@ class Lexer $token = $this->tokens[$this->pos]; } else { // EOF token with ID 0 - $token = "\0"; + $token = "\x00"; } if ($this->attributeStartLineUsed) { $startAttributes['startLine'] = $this->line; @@ -417,44 +417,44 @@ class Lexer for ($i = 256; $i < 1000; ++$i) { if (\T_DOUBLE_COLON === $i) { // T_DOUBLE_COLON is equivalent to T_PAAMAYIM_NEKUDOTAYIM - $tokenMap[$i] = \PhpParser\Parser\Tokens::T_PAAMAYIM_NEKUDOTAYIM; + $tokenMap[$i] = Tokens::T_PAAMAYIM_NEKUDOTAYIM; } elseif (\T_OPEN_TAG_WITH_ECHO === $i) { // T_OPEN_TAG_WITH_ECHO with dropped T_OPEN_TAG results in T_ECHO - $tokenMap[$i] = \PhpParser\Parser\Tokens::T_ECHO; + $tokenMap[$i] = Tokens::T_ECHO; } elseif (\T_CLOSE_TAG === $i) { // T_CLOSE_TAG is equivalent to ';' $tokenMap[$i] = \ord(';'); } elseif ('UNKNOWN' !== ($name = \token_name($i))) { if ('T_HASHBANG' === $name) { // HHVM uses a special token for #! hashbang lines - $tokenMap[$i] = \PhpParser\Parser\Tokens::T_INLINE_HTML; - } elseif (\defined($name = \PhpParser\Parser\Tokens::class . '::' . $name)) { + $tokenMap[$i] = Tokens::T_INLINE_HTML; + } elseif (\defined($name = Tokens::class . '::' . $name)) { // Other tokens can be mapped directly $tokenMap[$i] = \constant($name); } } } // HHVM uses a special token for numbers that overflow to double - if (\defined('T_ONUMBER')) { - $tokenMap[\T_ONUMBER] = \PhpParser\Parser\Tokens::T_DNUMBER; + if (\defined('RectorPrefix20220607\\T_ONUMBER')) { + $tokenMap[\RectorPrefix20220607\T_ONUMBER] = Tokens::T_DNUMBER; } // HHVM also has a separate token for the __COMPILER_HALT_OFFSET__ constant - if (\defined('T_COMPILER_HALT_OFFSET')) { - $tokenMap[\T_COMPILER_HALT_OFFSET] = \PhpParser\Parser\Tokens::T_STRING; + if (\defined('RectorPrefix20220607\\T_COMPILER_HALT_OFFSET')) { + $tokenMap[\RectorPrefix20220607\T_COMPILER_HALT_OFFSET] = Tokens::T_STRING; } // Assign tokens for which we define compatibility constants, as token_name() does not know them. - $tokenMap[\T_FN] = \PhpParser\Parser\Tokens::T_FN; - $tokenMap[\T_COALESCE_EQUAL] = \PhpParser\Parser\Tokens::T_COALESCE_EQUAL; - $tokenMap[\T_NAME_QUALIFIED] = \PhpParser\Parser\Tokens::T_NAME_QUALIFIED; - $tokenMap[\T_NAME_FULLY_QUALIFIED] = \PhpParser\Parser\Tokens::T_NAME_FULLY_QUALIFIED; - $tokenMap[\T_NAME_RELATIVE] = \PhpParser\Parser\Tokens::T_NAME_RELATIVE; - $tokenMap[\T_MATCH] = \PhpParser\Parser\Tokens::T_MATCH; - $tokenMap[\T_NULLSAFE_OBJECT_OPERATOR] = \PhpParser\Parser\Tokens::T_NULLSAFE_OBJECT_OPERATOR; - $tokenMap[\T_ATTRIBUTE] = \PhpParser\Parser\Tokens::T_ATTRIBUTE; - $tokenMap[\T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG] = \PhpParser\Parser\Tokens::T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG; - $tokenMap[\T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG] = \PhpParser\Parser\Tokens::T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG; - $tokenMap[\T_ENUM] = \PhpParser\Parser\Tokens::T_ENUM; - $tokenMap[\T_READONLY] = \PhpParser\Parser\Tokens::T_READONLY; + $tokenMap[\T_FN] = Tokens::T_FN; + $tokenMap[\T_COALESCE_EQUAL] = Tokens::T_COALESCE_EQUAL; + $tokenMap[\T_NAME_QUALIFIED] = Tokens::T_NAME_QUALIFIED; + $tokenMap[\T_NAME_FULLY_QUALIFIED] = Tokens::T_NAME_FULLY_QUALIFIED; + $tokenMap[\T_NAME_RELATIVE] = Tokens::T_NAME_RELATIVE; + $tokenMap[\T_MATCH] = Tokens::T_MATCH; + $tokenMap[\T_NULLSAFE_OBJECT_OPERATOR] = Tokens::T_NULLSAFE_OBJECT_OPERATOR; + $tokenMap[\T_ATTRIBUTE] = Tokens::T_ATTRIBUTE; + $tokenMap[\T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG] = Tokens::T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG; + $tokenMap[\T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG] = Tokens::T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG; + $tokenMap[\T_ENUM] = Tokens::T_ENUM; + $tokenMap[\T_READONLY] = Tokens::T_READONLY; return $tokenMap; } private function createIdentifierTokenMap() : array diff --git a/vendor/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php b/vendor/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php index 096d5e53a73..e368bf4a411 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php @@ -18,7 +18,7 @@ use PhpParser\Lexer\TokenEmulator\NumericLiteralSeparatorEmulator; use PhpParser\Lexer\TokenEmulator\ReadonlyTokenEmulator; use PhpParser\Lexer\TokenEmulator\ReverseEmulator; use PhpParser\Lexer\TokenEmulator\TokenEmulator; -class Emulative extends \PhpParser\Lexer +class Emulative extends Lexer { const PHP_7_3 = '7.3dev'; const PHP_7_4 = '7.4dev'; @@ -40,7 +40,7 @@ class Emulative extends \PhpParser\Lexer $this->targetPhpVersion = $options['phpVersion'] ?? \PhpParser\Lexer\Emulative::PHP_8_1; unset($options['phpVersion']); parent::__construct($options); - $emulators = [new \PhpParser\Lexer\TokenEmulator\FlexibleDocStringEmulator(), new \PhpParser\Lexer\TokenEmulator\FnTokenEmulator(), new \PhpParser\Lexer\TokenEmulator\MatchTokenEmulator(), new \PhpParser\Lexer\TokenEmulator\CoaleseEqualTokenEmulator(), new \PhpParser\Lexer\TokenEmulator\NumericLiteralSeparatorEmulator(), new \PhpParser\Lexer\TokenEmulator\NullsafeTokenEmulator(), new \PhpParser\Lexer\TokenEmulator\AttributeEmulator(), new \PhpParser\Lexer\TokenEmulator\EnumTokenEmulator(), new \PhpParser\Lexer\TokenEmulator\ReadonlyTokenEmulator(), new \PhpParser\Lexer\TokenEmulator\ExplicitOctalEmulator()]; + $emulators = [new FlexibleDocStringEmulator(), new FnTokenEmulator(), new MatchTokenEmulator(), new CoaleseEqualTokenEmulator(), new NumericLiteralSeparatorEmulator(), new NullsafeTokenEmulator(), new AttributeEmulator(), new EnumTokenEmulator(), new ReadonlyTokenEmulator(), new ExplicitOctalEmulator()]; // Collect emulators that are relevant for the PHP version we're running // and the PHP version we're targeting for emulation. foreach ($emulators as $emulator) { @@ -49,12 +49,12 @@ class Emulative extends \PhpParser\Lexer $this->emulators[] = $emulator; } else { if ($this->isReverseEmulationNeeded($emulatorPhpVersion)) { - $this->emulators[] = new \PhpParser\Lexer\TokenEmulator\ReverseEmulator($emulator); + $this->emulators[] = new ReverseEmulator($emulator); } } } } - public function startLexing(string $code, \PhpParser\ErrorHandler $errorHandler = null) + public function startLexing(string $code, ErrorHandler $errorHandler = null) { $emulators = \array_filter($this->emulators, function ($emulator) use($code) { return $emulator->isEmulationNeeded($code); @@ -68,7 +68,7 @@ class Emulative extends \PhpParser\Lexer foreach ($emulators as $emulator) { $code = $emulator->preprocessCode($code, $this->patches); } - $collector = new \PhpParser\ErrorHandler\Collecting(); + $collector = new ErrorHandler\Collecting(); parent::startLexing($code, $collector); $this->sortPatches(); $this->fixupTokens(); diff --git a/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php b/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php index c191111e615..7481f2598d0 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php @@ -8,7 +8,7 @@ final class AttributeEmulator extends \PhpParser\Lexer\TokenEmulator\TokenEmulat { public function getPhpVersion() : string { - return \PhpParser\Lexer\Emulative::PHP_8_0; + return Emulative::PHP_8_0; } public function isEmulationNeeded(string $code) : bool { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/CoaleseEqualTokenEmulator.php b/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/CoaleseEqualTokenEmulator.php index bc1e67af6ab..2b9f54df02b 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/CoaleseEqualTokenEmulator.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/CoaleseEqualTokenEmulator.php @@ -8,7 +8,7 @@ final class CoaleseEqualTokenEmulator extends \PhpParser\Lexer\TokenEmulator\Tok { public function getPhpVersion() : string { - return \PhpParser\Lexer\Emulative::PHP_7_4; + return Emulative::PHP_7_4; } public function isEmulationNeeded(string $code) : bool { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php b/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php index 9b1ae6dd636..8a4b8ee3143 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php @@ -8,7 +8,7 @@ final class EnumTokenEmulator extends \PhpParser\Lexer\TokenEmulator\KeywordEmul { public function getPhpVersion() : string { - return \PhpParser\Lexer\Emulative::PHP_8_1; + return Emulative::PHP_8_1; } public function getKeywordString() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ExplicitOctalEmulator.php b/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ExplicitOctalEmulator.php index 16cddc42bca..fc6a179bc42 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ExplicitOctalEmulator.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ExplicitOctalEmulator.php @@ -8,7 +8,7 @@ class ExplicitOctalEmulator extends \PhpParser\Lexer\TokenEmulator\TokenEmulator { public function getPhpVersion() : string { - return \PhpParser\Lexer\Emulative::PHP_8_1; + return Emulative::PHP_8_1; } public function isEmulationNeeded(string $code) : bool { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FlexibleDocStringEmulator.php b/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FlexibleDocStringEmulator.php index 3ef7c08b2c2..eb4ff0484e2 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FlexibleDocStringEmulator.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FlexibleDocStringEmulator.php @@ -13,7 +13,7 @@ final class FlexibleDocStringEmulator extends \PhpParser\Lexer\TokenEmulator\Tok REGEX; public function getPhpVersion() : string { - return \PhpParser\Lexer\Emulative::PHP_7_3; + return Emulative::PHP_7_3; } public function isEmulationNeeded(string $code) : bool { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FnTokenEmulator.php b/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FnTokenEmulator.php index 443e43daba2..c2403414076 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FnTokenEmulator.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FnTokenEmulator.php @@ -8,7 +8,7 @@ final class FnTokenEmulator extends \PhpParser\Lexer\TokenEmulator\KeywordEmulat { public function getPhpVersion() : string { - return \PhpParser\Lexer\Emulative::PHP_7_4; + return Emulative::PHP_7_4; } public function getKeywordString() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php b/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php index 47be4ff09a9..93892930d99 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php @@ -8,7 +8,7 @@ final class MatchTokenEmulator extends \PhpParser\Lexer\TokenEmulator\KeywordEmu { public function getPhpVersion() : string { - return \PhpParser\Lexer\Emulative::PHP_8_0; + return Emulative::PHP_8_0; } public function getKeywordString() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php b/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php index 12c66454cb4..83c5c4d0b7b 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php @@ -8,7 +8,7 @@ final class NullsafeTokenEmulator extends \PhpParser\Lexer\TokenEmulator\TokenEm { public function getPhpVersion() : string { - return \PhpParser\Lexer\Emulative::PHP_8_0; + return Emulative::PHP_8_0; } public function isEmulationNeeded(string $code) : bool { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NumericLiteralSeparatorEmulator.php b/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NumericLiteralSeparatorEmulator.php index a6649ba2e71..3de1690d34d 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NumericLiteralSeparatorEmulator.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NumericLiteralSeparatorEmulator.php @@ -15,7 +15,7 @@ final class NumericLiteralSeparatorEmulator extends \PhpParser\Lexer\TokenEmulat const NUMBER = '~' . self::FLOAT . '|' . self::BIN . '|' . self::HEX . '|' . self::DEC . '~iA'; public function getPhpVersion() : string { - return \PhpParser\Lexer\Emulative::PHP_7_4; + return Emulative::PHP_7_4; } public function isEmulationNeeded(string $code) : bool { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyTokenEmulator.php b/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyTokenEmulator.php index a4c9872bfad..bca47bbc5f0 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyTokenEmulator.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyTokenEmulator.php @@ -8,7 +8,7 @@ final class ReadonlyTokenEmulator extends \PhpParser\Lexer\TokenEmulator\Keyword { public function getPhpVersion() : string { - return \PhpParser\Lexer\Emulative::PHP_8_1; + return Emulative::PHP_8_1; } public function getKeywordString() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/NameContext.php b/vendor/nikic/php-parser/lib/PhpParser/NameContext.php index 4e301bacbbb..ada35b10977 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/NameContext.php +++ b/vendor/nikic/php-parser/lib/PhpParser/NameContext.php @@ -32,10 +32,10 @@ class NameContext * * @param Name|null $namespace Null is the global namespace */ - public function startNamespace(\PhpParser\Node\Name $namespace = null) + public function startNamespace(Name $namespace = null) { $this->namespace = $namespace; - $this->origAliases = $this->aliases = [\PhpParser\Node\Stmt\Use_::TYPE_NORMAL => [], \PhpParser\Node\Stmt\Use_::TYPE_FUNCTION => [], \PhpParser\Node\Stmt\Use_::TYPE_CONSTANT => []]; + $this->origAliases = $this->aliases = [Stmt\Use_::TYPE_NORMAL => [], Stmt\Use_::TYPE_FUNCTION => [], Stmt\Use_::TYPE_CONSTANT => []]; } /** * Add an alias / import. @@ -45,16 +45,16 @@ class NameContext * @param int $type One of Stmt\Use_::TYPE_* * @param array $errorAttrs Attributes to use to report an error */ - public function addAlias(\PhpParser\Node\Name $name, string $aliasName, int $type, array $errorAttrs = []) + public function addAlias(Name $name, string $aliasName, int $type, array $errorAttrs = []) { // Constant names are case sensitive, everything else case insensitive - if ($type === \PhpParser\Node\Stmt\Use_::TYPE_CONSTANT) { + if ($type === Stmt\Use_::TYPE_CONSTANT) { $aliasLookupName = $aliasName; } else { $aliasLookupName = \strtolower($aliasName); } if (isset($this->aliases[$type][$aliasLookupName])) { - $typeStringMap = [\PhpParser\Node\Stmt\Use_::TYPE_NORMAL => '', \PhpParser\Node\Stmt\Use_::TYPE_FUNCTION => 'function ', \PhpParser\Node\Stmt\Use_::TYPE_CONSTANT => 'const ']; + $typeStringMap = [Stmt\Use_::TYPE_NORMAL => '', Stmt\Use_::TYPE_FUNCTION => 'function ', Stmt\Use_::TYPE_CONSTANT => 'const ']; $this->errorHandler->handleError(new \PhpParser\Error(\sprintf('Cannot use %s%s as %s because the name is already in use', $typeStringMap[$type], $name, $aliasName), $errorAttrs)); return; } @@ -78,10 +78,10 @@ class NameContext * * @return null|Name Resolved name, or null if static resolution is not possible */ - public function getResolvedName(\PhpParser\Node\Name $name, int $type) + public function getResolvedName(Name $name, int $type) { // don't resolve special class names - if ($type === \PhpParser\Node\Stmt\Use_::TYPE_NORMAL && $name->isSpecialClassName()) { + if ($type === Stmt\Use_::TYPE_NORMAL && $name->isSpecialClassName()) { if (!$name->isUnqualified()) { $this->errorHandler->handleError(new \PhpParser\Error(\sprintf("'\\%s' is an invalid class name", $name->toString()), $name->getAttributes())); } @@ -95,16 +95,16 @@ class NameContext if (null !== ($resolvedName = $this->resolveAlias($name, $type))) { return $resolvedName; } - if ($type !== \PhpParser\Node\Stmt\Use_::TYPE_NORMAL && $name->isUnqualified()) { + if ($type !== Stmt\Use_::TYPE_NORMAL && $name->isUnqualified()) { if (null === $this->namespace) { // outside of a namespace unaliased unqualified is same as fully qualified - return new \PhpParser\Node\Name\FullyQualified($name, $name->getAttributes()); + return new FullyQualified($name, $name->getAttributes()); } // Cannot resolve statically return null; } // if no alias exists prepend current namespace - return \PhpParser\Node\Name\FullyQualified::concat($this->namespace, $name, $name->getAttributes()); + return FullyQualified::concat($this->namespace, $name, $name->getAttributes()); } /** * Get resolved class name. @@ -113,9 +113,9 @@ class NameContext * * @return Name Resolved name */ - public function getResolvedClassName(\PhpParser\Node\Name $name) : \PhpParser\Node\Name + public function getResolvedClassName(Name $name) : Name { - return $this->getResolvedName($name, \PhpParser\Node\Stmt\Use_::TYPE_NORMAL); + return $this->getResolvedName($name, Stmt\Use_::TYPE_NORMAL); } /** * Get possible ways of writing a fully qualified name (e.g., by making use of aliases). @@ -128,14 +128,14 @@ class NameContext public function getPossibleNames(string $name, int $type) : array { $lcName = \strtolower($name); - if ($type === \PhpParser\Node\Stmt\Use_::TYPE_NORMAL) { + if ($type === Stmt\Use_::TYPE_NORMAL) { // self, parent and static must always be unqualified if ($lcName === "self" || $lcName === "parent" || $lcName === "static") { - return [new \PhpParser\Node\Name($name)]; + return [new Name($name)]; } } // Collect possible ways to write this name, starting with the fully-qualified name - $possibleNames = [new \PhpParser\Node\Name\FullyQualified($name)]; + $possibleNames = [new FullyQualified($name)]; if (null !== ($nsRelativeName = $this->getNamespaceRelativeName($name, $lcName, $type))) { // Make sure there is no alias that makes the normally namespace-relative name // into something else @@ -144,24 +144,24 @@ class NameContext } } // Check for relevant namespace use statements - foreach ($this->origAliases[\PhpParser\Node\Stmt\Use_::TYPE_NORMAL] as $alias => $orig) { + foreach ($this->origAliases[Stmt\Use_::TYPE_NORMAL] as $alias => $orig) { $lcOrig = $orig->toLowerString(); if (0 === \strpos($lcName, $lcOrig . '\\')) { - $possibleNames[] = new \PhpParser\Node\Name($alias . \substr($name, \strlen($lcOrig))); + $possibleNames[] = new Name($alias . \substr($name, \strlen($lcOrig))); } } // Check for relevant type-specific use statements foreach ($this->origAliases[$type] as $alias => $orig) { - if ($type === \PhpParser\Node\Stmt\Use_::TYPE_CONSTANT) { + if ($type === Stmt\Use_::TYPE_CONSTANT) { // Constants are are complicated-sensitive $normalizedOrig = $this->normalizeConstName($orig->toString()); if ($normalizedOrig === $this->normalizeConstName($name)) { - $possibleNames[] = new \PhpParser\Node\Name($alias); + $possibleNames[] = new Name($alias); } } else { // Everything else is case-insensitive if ($orig->toLowerString() === $lcName) { - $possibleNames[] = new \PhpParser\Node\Name($alias); + $possibleNames[] = new Name($alias); } } } @@ -175,7 +175,7 @@ class NameContext * * @return Name Shortest representation */ - public function getShortName(string $name, int $type) : \PhpParser\Node\Name + public function getShortName(string $name, int $type) : Name { $possibleNames = $this->getPossibleNames($name, $type); // Find shortest name @@ -190,22 +190,22 @@ class NameContext } return $shortestName; } - private function resolveAlias(\PhpParser\Node\Name $name, $type) + private function resolveAlias(Name $name, $type) { $firstPart = $name->getFirst(); if ($name->isQualified()) { // resolve aliases for qualified names, always against class alias table $checkName = \strtolower($firstPart); - if (isset($this->aliases[\PhpParser\Node\Stmt\Use_::TYPE_NORMAL][$checkName])) { - $alias = $this->aliases[\PhpParser\Node\Stmt\Use_::TYPE_NORMAL][$checkName]; - return \PhpParser\Node\Name\FullyQualified::concat($alias, $name->slice(1), $name->getAttributes()); + if (isset($this->aliases[Stmt\Use_::TYPE_NORMAL][$checkName])) { + $alias = $this->aliases[Stmt\Use_::TYPE_NORMAL][$checkName]; + return FullyQualified::concat($alias, $name->slice(1), $name->getAttributes()); } } elseif ($name->isUnqualified()) { // constant aliases are case-sensitive, function aliases case-insensitive - $checkName = $type === \PhpParser\Node\Stmt\Use_::TYPE_CONSTANT ? $firstPart : \strtolower($firstPart); + $checkName = $type === Stmt\Use_::TYPE_CONSTANT ? $firstPart : \strtolower($firstPart); if (isset($this->aliases[$type][$checkName])) { // resolve unqualified aliases - return new \PhpParser\Node\Name\FullyQualified($this->aliases[$type][$checkName], $name->getAttributes()); + return new FullyQualified($this->aliases[$type][$checkName], $name->getAttributes()); } } // No applicable aliases @@ -214,18 +214,18 @@ class NameContext private function getNamespaceRelativeName(string $name, string $lcName, int $type) { if (null === $this->namespace) { - return new \PhpParser\Node\Name($name); + return new Name($name); } - if ($type === \PhpParser\Node\Stmt\Use_::TYPE_CONSTANT) { + if ($type === Stmt\Use_::TYPE_CONSTANT) { // The constants true/false/null always resolve to the global symbols, even inside a // namespace, so they may be used without qualification if ($lcName === "true" || $lcName === "false" || $lcName === "null") { - return new \PhpParser\Node\Name($name); + return new Name($name); } } $namespacePrefix = \strtolower($this->namespace . '\\'); if (0 === \strpos($lcName, $namespacePrefix)) { - return new \PhpParser\Node\Name(\substr($name, \strlen($namespacePrefix))); + return new Name(\substr($name, \strlen($namespacePrefix))); } return null; } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Arg.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Arg.php index 96554e0fc9f..9d3995e2373 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Arg.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Arg.php @@ -5,7 +5,7 @@ namespace PhpParser\Node; use PhpParser\Node\VariadicPlaceholder; use PhpParser\NodeAbstract; -class Arg extends \PhpParser\NodeAbstract +class Arg extends NodeAbstract { /** @var Identifier|null Parameter name (for named parameters) */ public $name; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Attribute.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Attribute.php index 4fa29de3e4d..eaef6eba4c0 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Attribute.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Attribute.php @@ -5,7 +5,7 @@ namespace PhpParser\Node; use PhpParser\Node; use PhpParser\NodeAbstract; -class Attribute extends \PhpParser\NodeAbstract +class Attribute extends NodeAbstract { /** @var Name Attribute name */ public $name; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/AttributeGroup.php b/vendor/nikic/php-parser/lib/PhpParser/Node/AttributeGroup.php index abb7a5f421b..2033a9fc442 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/AttributeGroup.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/AttributeGroup.php @@ -5,7 +5,7 @@ namespace PhpParser\Node; use PhpParser\Node; use PhpParser\NodeAbstract; -class AttributeGroup extends \PhpParser\NodeAbstract +class AttributeGroup extends NodeAbstract { /** @var Attribute[] Attributes */ public $attrs; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/ComplexType.php b/vendor/nikic/php-parser/lib/PhpParser/Node/ComplexType.php index 5a1d720e77a..b3198655124 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/ComplexType.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/ComplexType.php @@ -9,6 +9,6 @@ use PhpParser\NodeAbstract; * * It does not provide any shared behavior and exists only for type-checking purposes. */ -abstract class ComplexType extends \PhpParser\NodeAbstract +abstract class ComplexType extends NodeAbstract { } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Const_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Const_.php index 92b4b1b7962..a6602239b6f 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Const_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Const_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node; use PhpParser\NodeAbstract; -class Const_ extends \PhpParser\NodeAbstract +class Const_ extends NodeAbstract { /** @var Identifier Name */ public $name; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr.php index b6086a67015..96e2da64b59 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace PhpParser\Node; use PhpParser\NodeAbstract; -abstract class Expr extends \PhpParser\NodeAbstract +abstract class Expr extends NodeAbstract { } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayDimFetch.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayDimFetch.php index 2a849771193..a0eaa88784c 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayDimFetch.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayDimFetch.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class ArrayDimFetch extends \PhpParser\Node\Expr +class ArrayDimFetch extends Expr { /** @var Expr Variable */ public $var; @@ -17,7 +17,7 @@ class ArrayDimFetch extends \PhpParser\Node\Expr * @param null|Expr $dim Array index / dim * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $var, \PhpParser\Node\Expr $dim = null, array $attributes = []) + public function __construct(Expr $var, Expr $dim = null, array $attributes = []) { $this->attributes = $attributes; $this->var = $var; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php index dab9575c42b..9aeabc71abd 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class ArrayItem extends \PhpParser\Node\Expr +class ArrayItem extends Expr { /** @var null|Expr Key */ public $key; @@ -22,7 +22,7 @@ class ArrayItem extends \PhpParser\Node\Expr * @param bool $byRef Whether to assign by reference * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $value, \PhpParser\Node\Expr $key = null, bool $byRef = \false, array $attributes = [], bool $unpack = \false) + public function __construct(Expr $value, Expr $key = null, bool $byRef = \false, array $attributes = [], bool $unpack = \false) { $this->attributes = $attributes; $this->key = $key; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Array_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Array_.php index cc02c52d053..a728e79143b 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Array_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Array_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class Array_ extends \PhpParser\Node\Expr +class Array_ extends Expr { // For use in "kind" attribute const KIND_LONG = 1; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrowFunction.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrowFunction.php index fed8aef5e44..9dd43fa069f 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrowFunction.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrowFunction.php @@ -6,7 +6,7 @@ namespace PhpParser\Node\Expr; use PhpParser\Node; use PhpParser\Node\Expr; use PhpParser\Node\FunctionLike; -class ArrowFunction extends \PhpParser\Node\Expr implements \PhpParser\Node\FunctionLike +class ArrowFunction extends Expr implements FunctionLike { /** @var bool */ public $static; @@ -37,7 +37,7 @@ class ArrowFunction extends \PhpParser\Node\Expr implements \PhpParser\Node\Func $this->byRef = $subNodes['byRef'] ?? \false; $this->params = $subNodes['params'] ?? []; $returnType = $subNodes['returnType'] ?? null; - $this->returnType = \is_string($returnType) ? new \PhpParser\Node\Identifier($returnType) : $returnType; + $this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType; $this->expr = $subNodes['expr']; $this->attrGroups = $subNodes['attrGroups'] ?? []; } @@ -66,7 +66,7 @@ class ArrowFunction extends \PhpParser\Node\Expr implements \PhpParser\Node\Func */ public function getStmts() : ?array { - return [new \PhpParser\Node\Stmt\Return_($this->expr)]; + return [new Node\Stmt\Return_($this->expr)]; } public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Assign.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Assign.php index 3b6ce18d758..1fa7a37c05d 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Assign.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Assign.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class Assign extends \PhpParser\Node\Expr +class Assign extends Expr { /** @var Expr Variable */ public $var; @@ -17,7 +17,7 @@ class Assign extends \PhpParser\Node\Expr * @param Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $var, \PhpParser\Node\Expr $expr, array $attributes = []) + public function __construct(Expr $var, Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->var = $var; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp.php index 9ceca5804f8..762e6c42f9c 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -abstract class AssignOp extends \PhpParser\Node\Expr +abstract class AssignOp extends Expr { /** @var Expr Variable */ public $var; @@ -17,7 +17,7 @@ abstract class AssignOp extends \PhpParser\Node\Expr * @param Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $var, \PhpParser\Node\Expr $expr, array $attributes = []) + public function __construct(Expr $var, Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->var = $var; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php index 1c70eddcb42..3cc3be84e03 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\AssignOp; use PhpParser\Node\Expr\AssignOp; -class BitwiseAnd extends \PhpParser\Node\Expr\AssignOp +class BitwiseAnd extends AssignOp { public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseOr.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseOr.php index cf0731b68e6..957cde219ef 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseOr.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseOr.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\AssignOp; use PhpParser\Node\Expr\AssignOp; -class BitwiseOr extends \PhpParser\Node\Expr\AssignOp +class BitwiseOr extends AssignOp { public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseXor.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseXor.php index 083cf51d323..dadd2e13151 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseXor.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseXor.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\AssignOp; use PhpParser\Node\Expr\AssignOp; -class BitwiseXor extends \PhpParser\Node\Expr\AssignOp +class BitwiseXor extends AssignOp { public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Coalesce.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Coalesce.php index c4466b35471..c49b025f9a3 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Coalesce.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Coalesce.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\AssignOp; use PhpParser\Node\Expr\AssignOp; -class Coalesce extends \PhpParser\Node\Expr\AssignOp +class Coalesce extends AssignOp { public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Concat.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Concat.php index c43f28ca360..24b6fc56e4d 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Concat.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Concat.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\AssignOp; use PhpParser\Node\Expr\AssignOp; -class Concat extends \PhpParser\Node\Expr\AssignOp +class Concat extends AssignOp { public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Div.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Div.php index 4eafbc8709d..d587e8b3ef4 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Div.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Div.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\AssignOp; use PhpParser\Node\Expr\AssignOp; -class Div extends \PhpParser\Node\Expr\AssignOp +class Div extends AssignOp { public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Minus.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Minus.php index 9d0852d4d97..238ebd95dc5 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Minus.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Minus.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\AssignOp; use PhpParser\Node\Expr\AssignOp; -class Minus extends \PhpParser\Node\Expr\AssignOp +class Minus extends AssignOp { public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mod.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mod.php index 5c24034f9b6..30561569ded 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mod.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mod.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\AssignOp; use PhpParser\Node\Expr\AssignOp; -class Mod extends \PhpParser\Node\Expr\AssignOp +class Mod extends AssignOp { public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mul.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mul.php index 8492746878d..cce3c82a4ec 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mul.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mul.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\AssignOp; use PhpParser\Node\Expr\AssignOp; -class Mul extends \PhpParser\Node\Expr\AssignOp +class Mul extends AssignOp { public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Plus.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Plus.php index a4ac25f2864..36cb4d0b96d 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Plus.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Plus.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\AssignOp; use PhpParser\Node\Expr\AssignOp; -class Plus extends \PhpParser\Node\Expr\AssignOp +class Plus extends AssignOp { public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Pow.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Pow.php index 4d659be96b8..dfb6c596b02 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Pow.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Pow.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\AssignOp; use PhpParser\Node\Expr\AssignOp; -class Pow extends \PhpParser\Node\Expr\AssignOp +class Pow extends AssignOp { public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftLeft.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftLeft.php index b4adbdea9f8..a5bdccaa9c7 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftLeft.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftLeft.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\AssignOp; use PhpParser\Node\Expr\AssignOp; -class ShiftLeft extends \PhpParser\Node\Expr\AssignOp +class ShiftLeft extends AssignOp { public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftRight.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftRight.php index da6450bf081..980376b31e3 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftRight.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftRight.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\AssignOp; use PhpParser\Node\Expr\AssignOp; -class ShiftRight extends \PhpParser\Node\Expr\AssignOp +class ShiftRight extends AssignOp { public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignRef.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignRef.php index 405711a2b99..258fef8d01f 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignRef.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignRef.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class AssignRef extends \PhpParser\Node\Expr +class AssignRef extends Expr { /** @var Expr Variable reference is assigned to */ public $var; @@ -17,7 +17,7 @@ class AssignRef extends \PhpParser\Node\Expr * @param Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $var, \PhpParser\Node\Expr $expr, array $attributes = []) + public function __construct(Expr $var, Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->var = $var; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp.php index 772b88ccb61..2139c510807 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -abstract class BinaryOp extends \PhpParser\Node\Expr +abstract class BinaryOp extends Expr { /** @var Expr The left hand side expression */ public $left; @@ -17,7 +17,7 @@ abstract class BinaryOp extends \PhpParser\Node\Expr * @param Expr $right The right hand side expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $left, \PhpParser\Node\Expr $right, array $attributes = []) + public function __construct(Expr $left, Expr $right, array $attributes = []) { $this->attributes = $attributes; $this->left = $left; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php index b556e39cc3c..030748a180c 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class BitwiseAnd extends \PhpParser\Node\Expr\BinaryOp +class BitwiseAnd extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseOr.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseOr.php index d5a2672e8d7..aa352511719 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseOr.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseOr.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class BitwiseOr extends \PhpParser\Node\Expr\BinaryOp +class BitwiseOr extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseXor.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseXor.php index 66e1263ebb2..32fa8750802 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseXor.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseXor.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class BitwiseXor extends \PhpParser\Node\Expr\BinaryOp +class BitwiseXor extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanAnd.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanAnd.php index 6643d86a05d..7eafed220f9 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanAnd.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanAnd.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class BooleanAnd extends \PhpParser\Node\Expr\BinaryOp +class BooleanAnd extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanOr.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanOr.php index 4997ebc20d7..d67b8cfe4b9 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanOr.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanOr.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class BooleanOr extends \PhpParser\Node\Expr\BinaryOp +class BooleanOr extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Coalesce.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Coalesce.php index 4501167422d..a4609721525 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Coalesce.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Coalesce.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class Coalesce extends \PhpParser\Node\Expr\BinaryOp +class Coalesce extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Concat.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Concat.php index 9d22aeb1273..1ae7f1d1ec1 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Concat.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Concat.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class Concat extends \PhpParser\Node\Expr\BinaryOp +class Concat extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Div.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Div.php index dee8fe52f42..e740e7545c0 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Div.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Div.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class Div extends \PhpParser\Node\Expr\BinaryOp +class Div extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Equal.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Equal.php index d292c0a568e..a589439e6d7 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Equal.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Equal.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class Equal extends \PhpParser\Node\Expr\BinaryOp +class Equal extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Greater.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Greater.php index a1e8b615d0c..1fa4f206aef 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Greater.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Greater.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class Greater extends \PhpParser\Node\Expr\BinaryOp +class Greater extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php index 8bb0a0e4ad4..99a79d6eac8 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class GreaterOrEqual extends \PhpParser\Node\Expr\BinaryOp +class GreaterOrEqual extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Identical.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Identical.php index d266d6af5fb..4618e684d5e 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Identical.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Identical.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class Identical extends \PhpParser\Node\Expr\BinaryOp +class Identical extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalAnd.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalAnd.php index d27ed6b0f07..00b29b7dcc8 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalAnd.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalAnd.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class LogicalAnd extends \PhpParser\Node\Expr\BinaryOp +class LogicalAnd extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalOr.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalOr.php index 89c44eb8b6d..f4090f5262a 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalOr.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalOr.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class LogicalOr extends \PhpParser\Node\Expr\BinaryOp +class LogicalOr extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalXor.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalXor.php index 08f2dd040a3..8c5c0906a06 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalXor.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalXor.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class LogicalXor extends \PhpParser\Node\Expr\BinaryOp +class LogicalXor extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Minus.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Minus.php index cef1605fb6a..6671c7eddfd 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Minus.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Minus.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class Minus extends \PhpParser\Node\Expr\BinaryOp +class Minus extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mod.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mod.php index a1ed3e41c9c..8d07df825a8 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mod.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mod.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class Mod extends \PhpParser\Node\Expr\BinaryOp +class Mod extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mul.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mul.php index b7af04331a0..1c22220f97d 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mul.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mul.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class Mul extends \PhpParser\Node\Expr\BinaryOp +class Mul extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotEqual.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotEqual.php index 033b7962f7a..cb3aa9976bf 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotEqual.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotEqual.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class NotEqual extends \PhpParser\Node\Expr\BinaryOp +class NotEqual extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotIdentical.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotIdentical.php index 4f8d179ebab..6f4a821821f 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotIdentical.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotIdentical.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class NotIdentical extends \PhpParser\Node\Expr\BinaryOp +class NotIdentical extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Plus.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Plus.php index 9604e59efea..3b47eefa6b5 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Plus.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Plus.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class Plus extends \PhpParser\Node\Expr\BinaryOp +class Plus extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Pow.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Pow.php index f99a5d455ed..962889a5542 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Pow.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Pow.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class Pow extends \PhpParser\Node\Expr\BinaryOp +class Pow extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftLeft.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftLeft.php index b9d06893d44..81a6ce4715a 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftLeft.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftLeft.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class ShiftLeft extends \PhpParser\Node\Expr\BinaryOp +class ShiftLeft extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftRight.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftRight.php index 547f20f54d4..883504d28de 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftRight.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftRight.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class ShiftRight extends \PhpParser\Node\Expr\BinaryOp +class ShiftRight extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Smaller.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Smaller.php index dd4cf0768cd..0106078ae86 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Smaller.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Smaller.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class Smaller extends \PhpParser\Node\Expr\BinaryOp +class Smaller extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/SmallerOrEqual.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/SmallerOrEqual.php index 1c1fc19c919..7d3e7766ca0 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/SmallerOrEqual.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/SmallerOrEqual.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class SmallerOrEqual extends \PhpParser\Node\Expr\BinaryOp +class SmallerOrEqual extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Spaceship.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Spaceship.php index db21044eeba..12398835ce9 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Spaceship.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Spaceship.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\BinaryOp; use PhpParser\Node\Expr\BinaryOp; -class Spaceship extends \PhpParser\Node\Expr\BinaryOp +class Spaceship extends BinaryOp { public function getOperatorSigil() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BitwiseNot.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BitwiseNot.php index 593bf361d9f..fa39ab5eef6 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BitwiseNot.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BitwiseNot.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class BitwiseNot extends \PhpParser\Node\Expr +class BitwiseNot extends Expr { /** @var Expr Expression */ public $expr; @@ -14,7 +14,7 @@ class BitwiseNot extends \PhpParser\Node\Expr * @param Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $expr, array $attributes = []) + public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BooleanNot.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BooleanNot.php index 6b1c65c03c0..5277b5a32e3 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BooleanNot.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BooleanNot.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class BooleanNot extends \PhpParser\Node\Expr +class BooleanNot extends Expr { /** @var Expr Expression */ public $expr; @@ -14,7 +14,7 @@ class BooleanNot extends \PhpParser\Node\Expr * @param Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $expr, array $attributes = []) + public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/CallLike.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/CallLike.php index 1007faab398..bf9ad36bc1a 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/CallLike.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/CallLike.php @@ -6,7 +6,7 @@ namespace PhpParser\Node\Expr; use PhpParser\Node\Arg; use PhpParser\Node\Expr; use PhpParser\Node\VariadicPlaceholder; -abstract class CallLike extends \PhpParser\Node\Expr +abstract class CallLike extends Expr { /** * Return raw arguments, which may be actual Args, or VariadicPlaceholders for first-class @@ -21,7 +21,7 @@ abstract class CallLike extends \PhpParser\Node\Expr public function isFirstClassCallable() : bool { foreach ($this->getRawArgs() as $arg) { - if ($arg instanceof \PhpParser\Node\VariadicPlaceholder) { + if ($arg instanceof VariadicPlaceholder) { return \true; } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast.php index 97ed36fda3e..a27bd7dce80 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -abstract class Cast extends \PhpParser\Node\Expr +abstract class Cast extends Expr { /** @var Expr Expression */ public $expr; @@ -14,7 +14,7 @@ abstract class Cast extends \PhpParser\Node\Expr * @param Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $expr, array $attributes = []) + public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Array_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Array_.php index 3cf9d84965e..9da0dd97237 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Array_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Array_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\Cast; use PhpParser\Node\Expr\Cast; -class Array_ extends \PhpParser\Node\Expr\Cast +class Array_ extends Cast { public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Bool_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Bool_.php index e52dcfc70b6..99e6a2faa28 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Bool_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Bool_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\Cast; use PhpParser\Node\Expr\Cast; -class Bool_ extends \PhpParser\Node\Expr\Cast +class Bool_ extends Cast { public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Double.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Double.php index ad50ed02947..1b0cc9ef8c5 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Double.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Double.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\Cast; use PhpParser\Node\Expr\Cast; -class Double extends \PhpParser\Node\Expr\Cast +class Double extends Cast { // For use in "kind" attribute const KIND_DOUBLE = 1; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Int_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Int_.php index bf463980c7b..52823e6c216 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Int_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Int_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\Cast; use PhpParser\Node\Expr\Cast; -class Int_ extends \PhpParser\Node\Expr\Cast +class Int_ extends Cast { public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Object_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Object_.php index bfb7ff35c83..e4526f5aff4 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Object_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Object_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\Cast; use PhpParser\Node\Expr\Cast; -class Object_ extends \PhpParser\Node\Expr\Cast +class Object_ extends Cast { public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/String_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/String_.php index e5ea7898998..9c07a046289 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/String_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/String_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\Cast; use PhpParser\Node\Expr\Cast; -class String_ extends \PhpParser\Node\Expr\Cast +class String_ extends Cast { public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Unset_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Unset_.php index afcc50e1f83..3934af29427 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Unset_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Unset_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr\Cast; use PhpParser\Node\Expr\Cast; -class Unset_ extends \PhpParser\Node\Expr\Cast +class Unset_ extends Cast { public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ClassConstFetch.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ClassConstFetch.php index c57799abb3f..349bcdb84e0 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ClassConstFetch.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ClassConstFetch.php @@ -6,7 +6,7 @@ namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; use PhpParser\Node\Identifier; use PhpParser\Node\Name; -class ClassConstFetch extends \PhpParser\Node\Expr +class ClassConstFetch extends Expr { /** @var Name|Expr Class name */ public $class; @@ -23,7 +23,7 @@ class ClassConstFetch extends \PhpParser\Node\Expr { $this->attributes = $attributes; $this->class = $class; - $this->name = \is_string($name) ? new \PhpParser\Node\Identifier($name) : $name; + $this->name = \is_string($name) ? new Identifier($name) : $name; } public function getSubNodeNames() : array { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Clone_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Clone_.php index 2a1ed0cf56d..801bd008189 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Clone_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Clone_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class Clone_ extends \PhpParser\Node\Expr +class Clone_ extends Expr { /** @var Expr Expression */ public $expr; @@ -14,7 +14,7 @@ class Clone_ extends \PhpParser\Node\Expr * @param Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $expr, array $attributes = []) + public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Closure.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Closure.php index dda0fec8b87..60ef9319bf7 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Closure.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Closure.php @@ -7,7 +7,7 @@ use PhpParser\Node; use PhpParser\Node\Expr; use PhpParser\Node\FunctionLike; use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; -class Closure extends \PhpParser\Node\Expr implements \PhpParser\Node\FunctionLike, \Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface +class Closure extends Expr implements FunctionLike, StmtsAwareInterface { /** @var bool Whether the closure is static */ public $static; @@ -44,7 +44,7 @@ class Closure extends \PhpParser\Node\Expr implements \PhpParser\Node\FunctionLi $this->params = $subNodes['params'] ?? []; $this->uses = $subNodes['uses'] ?? []; $returnType = $subNodes['returnType'] ?? null; - $this->returnType = \is_string($returnType) ? new \PhpParser\Node\Identifier($returnType) : $returnType; + $this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType; $this->stmts = $subNodes['stmts'] ?? []; $this->attrGroups = $subNodes['attrGroups'] ?? []; } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php index a711835dfde..4d57956282a 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class ClosureUse extends \PhpParser\Node\Expr +class ClosureUse extends Expr { /** @var Expr\Variable Variable to use */ public $var; @@ -17,7 +17,7 @@ class ClosureUse extends \PhpParser\Node\Expr * @param bool $byRef Whether to use by reference * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr\Variable $var, bool $byRef = \false, array $attributes = []) + public function __construct(Expr\Variable $var, bool $byRef = \false, array $attributes = []) { $this->attributes = $attributes; $this->var = $var; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ConstFetch.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ConstFetch.php index e9280393fda..50c1a8a028c 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ConstFetch.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ConstFetch.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; use PhpParser\Node\Name; -class ConstFetch extends \PhpParser\Node\Expr +class ConstFetch extends Expr { /** @var Name Constant name */ public $name; @@ -15,7 +15,7 @@ class ConstFetch extends \PhpParser\Node\Expr * @param Name $name Constant name * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Name $name, array $attributes = []) + public function __construct(Name $name, array $attributes = []) { $this->attributes = $attributes; $this->name = $name; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Empty_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Empty_.php index 34f53dbe747..220efdbbd63 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Empty_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Empty_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class Empty_ extends \PhpParser\Node\Expr +class Empty_ extends Expr { /** @var Expr Expression */ public $expr; @@ -14,7 +14,7 @@ class Empty_ extends \PhpParser\Node\Expr * @param Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $expr, array $attributes = []) + public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Error.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Error.php index 722c13141ec..f9e673fb122 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Error.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Error.php @@ -10,7 +10,7 @@ use PhpParser\Node\Expr; * An error node may be placed at a position where an expression is required, but an error occurred. * Error nodes will not be present if the parser is run in throwOnError mode (the default). */ -class Error extends \PhpParser\Node\Expr +class Error extends Expr { /** * Constructs an error node. diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ErrorSuppress.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ErrorSuppress.php index d3841eff848..e13c96da861 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ErrorSuppress.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ErrorSuppress.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class ErrorSuppress extends \PhpParser\Node\Expr +class ErrorSuppress extends Expr { /** @var Expr Expression */ public $expr; @@ -14,7 +14,7 @@ class ErrorSuppress extends \PhpParser\Node\Expr * @param Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $expr, array $attributes = []) + public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Eval_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Eval_.php index 9ad0468a997..27989b47238 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Eval_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Eval_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class Eval_ extends \PhpParser\Node\Expr +class Eval_ extends Expr { /** @var Expr Expression */ public $expr; @@ -14,7 +14,7 @@ class Eval_ extends \PhpParser\Node\Expr * @param Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $expr, array $attributes = []) + public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Exit_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Exit_.php index 7dbca5ca74f..9576d982f20 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Exit_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Exit_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class Exit_ extends \PhpParser\Node\Expr +class Exit_ extends Expr { /* For use in "kind" attribute */ const KIND_EXIT = 1; @@ -17,7 +17,7 @@ class Exit_ extends \PhpParser\Node\Expr * @param null|Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $expr = null, array $attributes = []) + public function __construct(Expr $expr = null, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Include_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Include_.php index 3ca17df520a..000f87a1a4b 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Include_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Include_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class Include_ extends \PhpParser\Node\Expr +class Include_ extends Expr { const TYPE_INCLUDE = 1; const TYPE_INCLUDE_ONCE = 2; @@ -21,7 +21,7 @@ class Include_ extends \PhpParser\Node\Expr * @param int $type Type of include * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $expr, int $type, array $attributes = []) + public function __construct(Expr $expr, int $type, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Instanceof_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Instanceof_.php index e37e8ea59c1..651e481658c 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Instanceof_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Instanceof_.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; use PhpParser\Node\Name; -class Instanceof_ extends \PhpParser\Node\Expr +class Instanceof_ extends Expr { /** @var Expr Expression */ public $expr; @@ -18,7 +18,7 @@ class Instanceof_ extends \PhpParser\Node\Expr * @param Name|Expr $class Class name * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $expr, $class, array $attributes = []) + public function __construct(Expr $expr, $class, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Isset_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Isset_.php index 6017e8027d0..f6205e7c455 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Isset_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Isset_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class Isset_ extends \PhpParser\Node\Expr +class Isset_ extends Expr { /** @var Expr[] Variables */ public $vars; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/List_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/List_.php index c3f531445e7..dfa5a3ade28 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/List_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/List_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class List_ extends \PhpParser\Node\Expr +class List_ extends Expr { /** @var (ArrayItem|null)[] List of items to assign to */ public $items; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Match_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Match_.php index 8bed5eacf67..c302f171fab 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Match_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Match_.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Expr; use PhpParser\Node; use PhpParser\Node\MatchArm; -class Match_ extends \PhpParser\Node\Expr +class Match_ extends Node\Expr { /** @var Node\Expr */ public $cond; @@ -14,7 +14,7 @@ class Match_ extends \PhpParser\Node\Expr /** * @param MatchArm[] $arms */ - public function __construct(\PhpParser\Node\Expr $cond, array $arms = [], array $attributes = []) + public function __construct(Node\Expr $cond, array $arms = [], array $attributes = []) { $this->attributes = $attributes; $this->cond = $cond; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/MethodCall.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/MethodCall.php index b7b4944d74c..235181855ef 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/MethodCall.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/MethodCall.php @@ -23,11 +23,11 @@ class MethodCall extends \PhpParser\Node\Expr\CallLike * @param array $args Arguments * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $var, $name, array $args = [], array $attributes = []) + public function __construct(Expr $var, $name, array $args = [], array $attributes = []) { $this->attributes = $attributes; $this->var = $var; - $this->name = \is_string($name) ? new \PhpParser\Node\Identifier($name) : $name; + $this->name = \is_string($name) ? new Identifier($name) : $name; $this->args = $args; } public function getSubNodeNames() : array diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafeMethodCall.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafeMethodCall.php index 206cb235097..fb33349cd59 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafeMethodCall.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafeMethodCall.php @@ -23,11 +23,11 @@ class NullsafeMethodCall extends \PhpParser\Node\Expr\CallLike * @param array $args Arguments * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $var, $name, array $args = [], array $attributes = []) + public function __construct(Expr $var, $name, array $args = [], array $attributes = []) { $this->attributes = $attributes; $this->var = $var; - $this->name = \is_string($name) ? new \PhpParser\Node\Identifier($name) : $name; + $this->name = \is_string($name) ? new Identifier($name) : $name; $this->args = $args; } public function getSubNodeNames() : array diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafePropertyFetch.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafePropertyFetch.php index b4365fd3583..060834c001f 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafePropertyFetch.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafePropertyFetch.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; use PhpParser\Node\Identifier; -class NullsafePropertyFetch extends \PhpParser\Node\Expr +class NullsafePropertyFetch extends Expr { /** @var Expr Variable holding object */ public $var; @@ -18,11 +18,11 @@ class NullsafePropertyFetch extends \PhpParser\Node\Expr * @param string|Identifier|Expr $name Property name * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $var, $name, array $attributes = []) + public function __construct(Expr $var, $name, array $attributes = []) { $this->attributes = $attributes; $this->var = $var; - $this->name = \is_string($name) ? new \PhpParser\Node\Identifier($name) : $name; + $this->name = \is_string($name) ? new Identifier($name) : $name; } public function getSubNodeNames() : array { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PostDec.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PostDec.php index b8a14c87d4a..e0ab3cbc4ab 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PostDec.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PostDec.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class PostDec extends \PhpParser\Node\Expr +class PostDec extends Expr { /** @var Expr Variable */ public $var; @@ -14,7 +14,7 @@ class PostDec extends \PhpParser\Node\Expr * @param Expr $var Variable * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $var, array $attributes = []) + public function __construct(Expr $var, array $attributes = []) { $this->attributes = $attributes; $this->var = $var; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PostInc.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PostInc.php index c754a877e7a..02576c8839b 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PostInc.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PostInc.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class PostInc extends \PhpParser\Node\Expr +class PostInc extends Expr { /** @var Expr Variable */ public $var; @@ -14,7 +14,7 @@ class PostInc extends \PhpParser\Node\Expr * @param Expr $var Variable * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $var, array $attributes = []) + public function __construct(Expr $var, array $attributes = []) { $this->attributes = $attributes; $this->var = $var; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PreDec.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PreDec.php index 30158c71157..a945d1ffee9 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PreDec.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PreDec.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class PreDec extends \PhpParser\Node\Expr +class PreDec extends Expr { /** @var Expr Variable */ public $var; @@ -14,7 +14,7 @@ class PreDec extends \PhpParser\Node\Expr * @param Expr $var Variable * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $var, array $attributes = []) + public function __construct(Expr $var, array $attributes = []) { $this->attributes = $attributes; $this->var = $var; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PreInc.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PreInc.php index 521eeca5e41..b02faaa404f 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PreInc.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PreInc.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class PreInc extends \PhpParser\Node\Expr +class PreInc extends Expr { /** @var Expr Variable */ public $var; @@ -14,7 +14,7 @@ class PreInc extends \PhpParser\Node\Expr * @param Expr $var Variable * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $var, array $attributes = []) + public function __construct(Expr $var, array $attributes = []) { $this->attributes = $attributes; $this->var = $var; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Print_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Print_.php index 2debd7698d8..d03c390edfc 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Print_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Print_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class Print_ extends \PhpParser\Node\Expr +class Print_ extends Expr { /** @var Expr Expression */ public $expr; @@ -14,7 +14,7 @@ class Print_ extends \PhpParser\Node\Expr * @param Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $expr, array $attributes = []) + public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PropertyFetch.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PropertyFetch.php index 877f5721a6f..6deb62032f9 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PropertyFetch.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PropertyFetch.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; use PhpParser\Node\Identifier; -class PropertyFetch extends \PhpParser\Node\Expr +class PropertyFetch extends Expr { /** @var Expr Variable holding object */ public $var; @@ -18,11 +18,11 @@ class PropertyFetch extends \PhpParser\Node\Expr * @param string|Identifier|Expr $name Property name * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $var, $name, array $attributes = []) + public function __construct(Expr $var, $name, array $attributes = []) { $this->attributes = $attributes; $this->var = $var; - $this->name = \is_string($name) ? new \PhpParser\Node\Identifier($name) : $name; + $this->name = \is_string($name) ? new Identifier($name) : $name; } public function getSubNodeNames() : array { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ShellExec.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ShellExec.php index c681d9b707d..b7f711edb0a 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ShellExec.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ShellExec.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class ShellExec extends \PhpParser\Node\Expr +class ShellExec extends Expr { /** @var array Encapsed string array */ public $parts; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/StaticCall.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/StaticCall.php index 4f86bc95748..a3675b60fa8 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/StaticCall.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/StaticCall.php @@ -28,7 +28,7 @@ class StaticCall extends \PhpParser\Node\Expr\CallLike { $this->attributes = $attributes; $this->class = $class; - $this->name = \is_string($name) ? new \PhpParser\Node\Identifier($name) : $name; + $this->name = \is_string($name) ? new Identifier($name) : $name; $this->args = $args; } public function getSubNodeNames() : array diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/StaticPropertyFetch.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/StaticPropertyFetch.php index 042b1673134..86f34304441 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/StaticPropertyFetch.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/StaticPropertyFetch.php @@ -6,7 +6,7 @@ namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; use PhpParser\Node\Name; use PhpParser\Node\VarLikeIdentifier; -class StaticPropertyFetch extends \PhpParser\Node\Expr +class StaticPropertyFetch extends Expr { /** @var Name|Expr Class name */ public $class; @@ -23,7 +23,7 @@ class StaticPropertyFetch extends \PhpParser\Node\Expr { $this->attributes = $attributes; $this->class = $class; - $this->name = \is_string($name) ? new \PhpParser\Node\VarLikeIdentifier($name) : $name; + $this->name = \is_string($name) ? new VarLikeIdentifier($name) : $name; } public function getSubNodeNames() : array { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Ternary.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Ternary.php index 0412b3b4ad8..426ba105c06 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Ternary.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Ternary.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class Ternary extends \PhpParser\Node\Expr +class Ternary extends Expr { /** @var Expr Condition */ public $cond; @@ -20,7 +20,7 @@ class Ternary extends \PhpParser\Node\Expr * @param Expr $else Expression for false * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $cond, $if, \PhpParser\Node\Expr $else, array $attributes = []) + public function __construct(Expr $cond, $if, Expr $else, array $attributes = []) { $this->attributes = $attributes; $this->cond = $cond; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Throw_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Throw_.php index 76b8859fbc9..6f7c91edabf 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Throw_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Throw_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node; -class Throw_ extends \PhpParser\Node\Expr +class Throw_ extends Node\Expr { /** @var Node\Expr Expression */ public $expr; @@ -14,7 +14,7 @@ class Throw_ extends \PhpParser\Node\Expr * @param Node\Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $expr, array $attributes = []) + public function __construct(Node\Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryMinus.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryMinus.php index eb702bd47a4..b933fdd8213 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryMinus.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryMinus.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class UnaryMinus extends \PhpParser\Node\Expr +class UnaryMinus extends Expr { /** @var Expr Expression */ public $expr; @@ -14,7 +14,7 @@ class UnaryMinus extends \PhpParser\Node\Expr * @param Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $expr, array $attributes = []) + public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryPlus.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryPlus.php index 6ab4e22f7e0..916f50a8ca3 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryPlus.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryPlus.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class UnaryPlus extends \PhpParser\Node\Expr +class UnaryPlus extends Expr { /** @var Expr Expression */ public $expr; @@ -14,7 +14,7 @@ class UnaryPlus extends \PhpParser\Node\Expr * @param Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $expr, array $attributes = []) + public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Variable.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Variable.php index a41bb083a2e..97d884e06b7 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Variable.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Variable.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class Variable extends \PhpParser\Node\Expr +class Variable extends Expr { /** @var string|Expr Name */ public $name; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/YieldFrom.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/YieldFrom.php index 46ee58b4eb4..8149a09db0c 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/YieldFrom.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/YieldFrom.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class YieldFrom extends \PhpParser\Node\Expr +class YieldFrom extends Expr { /** @var Expr Expression to yield from */ public $expr; @@ -14,7 +14,7 @@ class YieldFrom extends \PhpParser\Node\Expr * @param Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $expr, array $attributes = []) + public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Yield_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Yield_.php index 0d502159295..d48a463200d 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Yield_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Yield_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Expr; use PhpParser\Node\Expr; -class Yield_ extends \PhpParser\Node\Expr +class Yield_ extends Expr { /** @var null|Expr Key expression */ public $key; @@ -17,7 +17,7 @@ class Yield_ extends \PhpParser\Node\Expr * @param null|Expr $key Key expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $value = null, \PhpParser\Node\Expr $key = null, array $attributes = []) + public function __construct(Expr $value = null, Expr $key = null, array $attributes = []) { $this->attributes = $attributes; $this->key = $key; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/FunctionLike.php b/vendor/nikic/php-parser/lib/PhpParser/Node/FunctionLike.php index b7af83bf4b2..74554375d48 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/FunctionLike.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/FunctionLike.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node; use PhpParser\Node; -interface FunctionLike extends \PhpParser\Node +interface FunctionLike extends Node { /** * Whether to return by reference diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Identifier.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Identifier.php index 933d3669851..54245ba5d0e 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Identifier.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Identifier.php @@ -7,7 +7,7 @@ use PhpParser\NodeAbstract; /** * Represents a non-namespaced name. Namespaced names are represented using Name nodes. */ -class Identifier extends \PhpParser\NodeAbstract +class Identifier extends NodeAbstract { /** @var string Identifier as string */ public $name; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/MatchArm.php b/vendor/nikic/php-parser/lib/PhpParser/Node/MatchArm.php index 6fdc3fd78b6..7ad2f398e79 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/MatchArm.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/MatchArm.php @@ -5,7 +5,7 @@ namespace PhpParser\Node; use PhpParser\Node; use PhpParser\NodeAbstract; -class MatchArm extends \PhpParser\NodeAbstract +class MatchArm extends NodeAbstract { /** @var null|Node\Expr[] */ public $conds; @@ -14,7 +14,7 @@ class MatchArm extends \PhpParser\NodeAbstract /** * @param null|Node\Expr[] $conds */ - public function __construct($conds, \PhpParser\Node\Expr $body, array $attributes = []) + public function __construct($conds, Node\Expr $body, array $attributes = []) { $this->conds = $conds; $this->body = $body; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Name.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Name.php index a6ba084de88..72410007159 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Name.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Name.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node; use PhpParser\NodeAbstract; -class Name extends \PhpParser\NodeAbstract +class Name extends NodeAbstract { /** @var string[] Parts of the name */ public $parts; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Param.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Param.php index bf5ba231323..37bcf5ece79 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Param.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Param.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node; use PhpParser\NodeAbstract; -class Param extends \PhpParser\NodeAbstract +class Param extends NodeAbstract { /** @var null|Identifier|Name|ComplexType Type declaration */ public $type; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/DNumber.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/DNumber.php index 287db39cf3b..915b12c9236 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/DNumber.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/DNumber.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Scalar; use PhpParser\Node\Scalar; -class DNumber extends \PhpParser\Node\Scalar +class DNumber extends Scalar { /** @var float Number value */ public $value; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php index 540cbf462f0..6e28cd7d7d9 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Scalar; use PhpParser\Node\Expr; use PhpParser\Node\Scalar; -class Encapsed extends \PhpParser\Node\Scalar +class Encapsed extends Scalar { /** @var Expr[] list of string parts */ public $parts; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php index 2fb20e08766..3f066aad910 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Scalar; use PhpParser\Node\Scalar; -class EncapsedStringPart extends \PhpParser\Node\Scalar +class EncapsedStringPart extends Scalar { /** @var string String value */ public $value; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php index 9c1e1485d58..5c257595094 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Scalar; use PhpParser\Error; use PhpParser\Node\Scalar; -class LNumber extends \PhpParser\Node\Scalar +class LNumber extends Scalar { /* For use in "kind" attribute */ const KIND_BIN = 2; @@ -55,7 +55,7 @@ class LNumber extends \PhpParser\Node\Scalar return new \PhpParser\Node\Scalar\LNumber(\bindec($str), $attributes); } if (!$allowInvalidOctal && \strpbrk($str, '89')) { - throw new \PhpParser\Error('Invalid numeric literal', $attributes); + throw new Error('Invalid numeric literal', $attributes); } // Strip optional explicit octal prefix. if ('o' === $str[1] || 'O' === $str[1]) { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst.php index 7a4c8ddbef5..c254461a1fa 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Scalar; use PhpParser\Node\Scalar; -abstract class MagicConst extends \PhpParser\Node\Scalar +abstract class MagicConst extends Scalar { /** * Constructs a magic constant node. diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Class_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Class_.php index 798b9631ac9..3155e15c27f 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Class_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Class_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Scalar\MagicConst; use PhpParser\Node\Scalar\MagicConst; -class Class_ extends \PhpParser\Node\Scalar\MagicConst +class Class_ extends MagicConst { public function getName() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Dir.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Dir.php index dcd9c674b74..88b50450424 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Dir.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Dir.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Scalar\MagicConst; use PhpParser\Node\Scalar\MagicConst; -class Dir extends \PhpParser\Node\Scalar\MagicConst +class Dir extends MagicConst { public function getName() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/File.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/File.php index 83041241675..31799b0acd1 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/File.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/File.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Scalar\MagicConst; use PhpParser\Node\Scalar\MagicConst; -class File extends \PhpParser\Node\Scalar\MagicConst +class File extends MagicConst { public function getName() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Function_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Function_.php index 499df387171..007cee9c17e 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Function_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Function_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Scalar\MagicConst; use PhpParser\Node\Scalar\MagicConst; -class Function_ extends \PhpParser\Node\Scalar\MagicConst +class Function_ extends MagicConst { public function getName() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Line.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Line.php index bf952bd589b..b3c8ae248b1 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Line.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Line.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Scalar\MagicConst; use PhpParser\Node\Scalar\MagicConst; -class Line extends \PhpParser\Node\Scalar\MagicConst +class Line extends MagicConst { public function getName() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Method.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Method.php index 97d957fb34a..b2984c82ad2 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Method.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Method.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Scalar\MagicConst; use PhpParser\Node\Scalar\MagicConst; -class Method extends \PhpParser\Node\Scalar\MagicConst +class Method extends MagicConst { public function getName() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Namespace_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Namespace_.php index dfcef84df92..d27cb8629f0 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Namespace_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Namespace_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Scalar\MagicConst; use PhpParser\Node\Scalar\MagicConst; -class Namespace_ extends \PhpParser\Node\Scalar\MagicConst +class Namespace_ extends MagicConst { public function getName() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Trait_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Trait_.php index 519056c2d30..ec276d45293 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Trait_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Trait_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Scalar\MagicConst; use PhpParser\Node\Scalar\MagicConst; -class Trait_ extends \PhpParser\Node\Scalar\MagicConst +class Trait_ extends MagicConst { public function getName() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.php index f6d6150e44b..0ee6438ae5b 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Scalar; use PhpParser\Error; use PhpParser\Node\Scalar; -class String_ extends \PhpParser\Node\Scalar +class String_ extends Scalar { /* For use in "kind" attribute */ const KIND_SINGLE_QUOTED = 1; @@ -14,7 +14,7 @@ class String_ extends \PhpParser\Node\Scalar const KIND_NOWDOC = 4; /** @var string String value */ public $value; - protected static $replacements = ['\\' => '\\', '$' => '$', 'n' => "\n", 'r' => "\r", 't' => "\t", 'f' => "\f", 'v' => "\v", 'e' => "\33"]; + protected static $replacements = ['\\' => '\\', '$' => '$', 'n' => "\n", 'r' => "\r", 't' => "\t", 'f' => "\f", 'v' => "\v", 'e' => "\x1b"]; /** * Constructs a string scalar node. * @@ -35,7 +35,7 @@ class String_ extends \PhpParser\Node\Scalar */ public static function fromString(string $str, array $attributes = [], bool $parseUnicodeEscape = \true) : self { - $attributes['kind'] = $str[0] === "'" || $str[1] === "'" && ($str[0] === 'b' || $str[0] === 'B') ? \PhpParser\Node\Scalar\String_::KIND_SINGLE_QUOTED : \PhpParser\Node\Scalar\String_::KIND_DOUBLE_QUOTED; + $attributes['kind'] = $str[0] === "'" || $str[1] === "'" && ($str[0] === 'b' || $str[0] === 'B') ? Scalar\String_::KIND_SINGLE_QUOTED : Scalar\String_::KIND_DOUBLE_QUOTED; $attributes['rawValue'] = $str; $string = self::parse($str, $parseUnicodeEscape); return new self($string, $attributes); @@ -116,7 +116,7 @@ class String_ extends \PhpParser\Node\Scalar if ($num <= 0x1fffff) { return \chr(($num >> 18) + 0xf0) . \chr(($num >> 12 & 0x3f) + 0x80) . \chr(($num >> 6 & 0x3f) + 0x80) . \chr(($num & 0x3f) + 0x80); } - throw new \PhpParser\Error('Invalid UTF-8 codepoint escape sequence: Codepoint too large'); + throw new Error('Invalid UTF-8 codepoint escape sequence: Codepoint too large'); } public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt.php index bf7a24cce9d..de93d0eb643 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace PhpParser\Node; use PhpParser\NodeAbstract; -abstract class Stmt extends \PhpParser\NodeAbstract +abstract class Stmt extends NodeAbstract { } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Break_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Break_.php index fb385e414b7..2a116274441 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Break_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Break_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; -class Break_ extends \PhpParser\Node\Stmt +class Break_ extends Node\Stmt { /** @var null|Node\Expr Number of loops to break */ public $num; @@ -14,7 +14,7 @@ class Break_ extends \PhpParser\Node\Stmt * @param null|Node\Expr $num Number of loops to break * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $num = null, array $attributes = []) + public function __construct(Node\Expr $num = null, array $attributes = []) { $this->attributes = $attributes; $this->num = $num; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Case_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Case_.php index 24795fefe5a..c41348023f0 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Case_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Case_.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node; use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; -class Case_ extends \PhpParser\Node\Stmt implements \Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface +class Case_ extends Node\Stmt implements StmtsAwareInterface { /** @var null|Node\Expr Condition (null for default) */ public $cond; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Catch_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Catch_.php index 1050317ef5f..b97179253bc 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Catch_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Catch_.php @@ -6,7 +6,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node; use PhpParser\Node\Expr; use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; -class Catch_ extends \PhpParser\Node\Stmt implements \Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface +class Catch_ extends Node\Stmt implements StmtsAwareInterface { /** @var Node\Name[] Types of exceptions to catch */ public $types; @@ -22,7 +22,7 @@ class Catch_ extends \PhpParser\Node\Stmt implements \Rector\Core\Contract\PhpPa * @param Node\Stmt[] $stmts Statements * @param array $attributes Additional attributes */ - public function __construct(array $types, \PhpParser\Node\Expr\Variable $var = null, array $stmts = [], array $attributes = []) + public function __construct(array $types, Expr\Variable $var = null, array $stmts = [], array $attributes = []) { $this->attributes = $attributes; $this->types = $types; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassConst.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassConst.php index 751f33b5de2..f3c566e265a 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassConst.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassConst.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; -class ClassConst extends \PhpParser\Node\Stmt +class ClassConst extends Node\Stmt { /** @var int Modifiers */ public $flags; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassLike.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassLike.php index a0b58d56d12..d64a6a66bf4 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassLike.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassLike.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; -abstract class ClassLike extends \PhpParser\Node\Stmt +abstract class ClassLike extends Node\Stmt { /** @var Node\Identifier|null Name */ public $name; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassMethod.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassMethod.php index 54ed84a998d..311e1964ca4 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassMethod.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassMethod.php @@ -6,7 +6,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node; use PhpParser\Node\FunctionLike; use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; -class ClassMethod extends \PhpParser\Node\Stmt implements \PhpParser\Node\FunctionLike, \Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface +class ClassMethod extends Node\Stmt implements FunctionLike, StmtsAwareInterface { /** @var int Flags */ public $flags; @@ -41,10 +41,10 @@ class ClassMethod extends \PhpParser\Node\Stmt implements \PhpParser\Node\Functi $this->attributes = $attributes; $this->flags = $subNodes['flags'] ?? $subNodes['type'] ?? 0; $this->byRef = $subNodes['byRef'] ?? \false; - $this->name = \is_string($name) ? new \PhpParser\Node\Identifier($name) : $name; + $this->name = \is_string($name) ? new Node\Identifier($name) : $name; $this->params = $subNodes['params'] ?? []; $returnType = $subNodes['returnType'] ?? null; - $this->returnType = \is_string($returnType) ? new \PhpParser\Node\Identifier($returnType) : $returnType; + $this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType; $this->stmts = \array_key_exists('stmts', $subNodes) ? $subNodes['stmts'] : []; $this->attrGroups = $subNodes['attrGroups'] ?? []; } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Class_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Class_.php index bfe9fedc125..db2dee3e207 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Class_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Class_.php @@ -38,7 +38,7 @@ class Class_ extends \PhpParser\Node\Stmt\ClassLike { $this->attributes = $attributes; $this->flags = $subNodes['flags'] ?? $subNodes['type'] ?? 0; - $this->name = \is_string($name) ? new \PhpParser\Node\Identifier($name) : $name; + $this->name = \is_string($name) ? new Node\Identifier($name) : $name; $this->extends = $subNodes['extends'] ?? null; $this->implements = $subNodes['implements'] ?? []; $this->stmts = $subNodes['stmts'] ?? []; @@ -85,16 +85,16 @@ class Class_ extends \PhpParser\Node\Stmt\ClassLike public static function verifyClassModifier($a, $b) { if ($a & self::MODIFIER_ABSTRACT && $b & self::MODIFIER_ABSTRACT) { - throw new \PhpParser\Error('Multiple abstract modifiers are not allowed'); + throw new Error('Multiple abstract modifiers are not allowed'); } if ($a & self::MODIFIER_FINAL && $b & self::MODIFIER_FINAL) { - throw new \PhpParser\Error('Multiple final modifiers are not allowed'); + throw new Error('Multiple final modifiers are not allowed'); } if ($a & self::MODIFIER_READONLY && $b & self::MODIFIER_READONLY) { - throw new \PhpParser\Error('Multiple readonly modifiers are not allowed'); + throw new Error('Multiple readonly modifiers are not allowed'); } if ($a & 48 && $b & 48) { - throw new \PhpParser\Error('Cannot use the final modifier on an abstract class'); + throw new Error('Cannot use the final modifier on an abstract class'); } } /** @@ -103,22 +103,22 @@ class Class_ extends \PhpParser\Node\Stmt\ClassLike public static function verifyModifier($a, $b) { if ($a & self::VISIBILITY_MODIFIER_MASK && $b & self::VISIBILITY_MODIFIER_MASK) { - throw new \PhpParser\Error('Multiple access type modifiers are not allowed'); + throw new Error('Multiple access type modifiers are not allowed'); } if ($a & self::MODIFIER_ABSTRACT && $b & self::MODIFIER_ABSTRACT) { - throw new \PhpParser\Error('Multiple abstract modifiers are not allowed'); + throw new Error('Multiple abstract modifiers are not allowed'); } if ($a & self::MODIFIER_STATIC && $b & self::MODIFIER_STATIC) { - throw new \PhpParser\Error('Multiple static modifiers are not allowed'); + throw new Error('Multiple static modifiers are not allowed'); } if ($a & self::MODIFIER_FINAL && $b & self::MODIFIER_FINAL) { - throw new \PhpParser\Error('Multiple final modifiers are not allowed'); + throw new Error('Multiple final modifiers are not allowed'); } if ($a & self::MODIFIER_READONLY && $b & self::MODIFIER_READONLY) { - throw new \PhpParser\Error('Multiple readonly modifiers are not allowed'); + throw new Error('Multiple readonly modifiers are not allowed'); } if ($a & 48 && $b & 48) { - throw new \PhpParser\Error('Cannot use the final modifier on an abstract class member'); + throw new Error('Cannot use the final modifier on an abstract class member'); } } public function getType() : string diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Const_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Const_.php index f1cdb990a28..aff84aa0815 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Const_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Const_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; -class Const_ extends \PhpParser\Node\Stmt +class Const_ extends Node\Stmt { /** @var Node\Const_[] Constant declarations */ public $consts; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Continue_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Continue_.php index f9ba1759d10..58f02f3ce15 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Continue_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Continue_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; -class Continue_ extends \PhpParser\Node\Stmt +class Continue_ extends Node\Stmt { /** @var null|Node\Expr Number of loops to continue */ public $num; @@ -14,7 +14,7 @@ class Continue_ extends \PhpParser\Node\Stmt * @param null|Node\Expr $num Number of loops to continue * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $num = null, array $attributes = []) + public function __construct(Node\Expr $num = null, array $attributes = []) { $this->attributes = $attributes; $this->num = $num; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php index 4fedbc16f95..4fde5c280ab 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; -class DeclareDeclare extends \PhpParser\Node\Stmt +class DeclareDeclare extends Node\Stmt { /** @var Node\Identifier Key */ public $key; @@ -17,10 +17,10 @@ class DeclareDeclare extends \PhpParser\Node\Stmt * @param Node\Expr $value Value * @param array $attributes Additional attributes */ - public function __construct($key, \PhpParser\Node\Expr $value, array $attributes = []) + public function __construct($key, Node\Expr $value, array $attributes = []) { $this->attributes = $attributes; - $this->key = \is_string($key) ? new \PhpParser\Node\Identifier($key) : $key; + $this->key = \is_string($key) ? new Node\Identifier($key) : $key; $this->value = $value; } public function getSubNodeNames() : array diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Declare_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Declare_.php index 3f29d73c15e..5b36d6f582a 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Declare_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Declare_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; -class Declare_ extends \PhpParser\Node\Stmt +class Declare_ extends Node\Stmt { /** @var DeclareDeclare[] List of declares */ public $declares; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Do_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Do_.php index ecfecb4bba7..17da9d364cf 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Do_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Do_.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node; use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; -class Do_ extends \PhpParser\Node\Stmt implements \Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface +class Do_ extends Node\Stmt implements StmtsAwareInterface { /** @var Node\Stmt[] Statements */ public $stmts; @@ -18,7 +18,7 @@ class Do_ extends \PhpParser\Node\Stmt implements \Rector\Core\Contract\PhpParse * @param Node\Stmt[] $stmts Statements * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $cond, array $stmts = [], array $attributes = []) + public function __construct(Node\Expr $cond, array $stmts = [], array $attributes = []) { $this->attributes = $attributes; $this->cond = $cond; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Echo_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Echo_.php index 07cb98688a9..c5090535487 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Echo_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Echo_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; -class Echo_ extends \PhpParser\Node\Stmt +class Echo_ extends Node\Stmt { /** @var Node\Expr[] Expressions */ public $exprs; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ElseIf_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ElseIf_.php index 6dd62954443..4e9fe370cfd 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ElseIf_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ElseIf_.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node; use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; -class ElseIf_ extends \PhpParser\Node\Stmt implements \Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface +class ElseIf_ extends Node\Stmt implements StmtsAwareInterface { /** @var Node\Expr Condition */ public $cond; @@ -18,7 +18,7 @@ class ElseIf_ extends \PhpParser\Node\Stmt implements \Rector\Core\Contract\PhpP * @param Node\Stmt[] $stmts Statements * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $cond, array $stmts = [], array $attributes = []) + public function __construct(Node\Expr $cond, array $stmts = [], array $attributes = []) { $this->attributes = $attributes; $this->cond = $cond; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Else_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Else_.php index b5c9fb1c5a0..0de38d6c851 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Else_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Else_.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node; use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; -class Else_ extends \PhpParser\Node\Stmt implements \Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface +class Else_ extends Node\Stmt implements StmtsAwareInterface { /** @var Node\Stmt[] Statements */ public $stmts; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/EnumCase.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/EnumCase.php index aa0485a5a03..539c2761ed4 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/EnumCase.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/EnumCase.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node; use PhpParser\Node\AttributeGroup; -class EnumCase extends \PhpParser\Node\Stmt +class EnumCase extends Node\Stmt { /** @var Node\Identifier Enum case name */ public $name; @@ -19,10 +19,10 @@ class EnumCase extends \PhpParser\Node\Stmt * @param AttributeGroup[] $attrGroups PHP attribute groups * @param array $attributes Additional attributes */ - public function __construct($name, \PhpParser\Node\Expr $expr = null, array $attrGroups = [], array $attributes = []) + public function __construct($name, Node\Expr $expr = null, array $attrGroups = [], array $attributes = []) { parent::__construct($attributes); - $this->name = \is_string($name) ? new \PhpParser\Node\Identifier($name) : $name; + $this->name = \is_string($name) ? new Node\Identifier($name) : $name; $this->expr = $expr; $this->attrGroups = $attrGroups; } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Enum_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Enum_.php index b1edc42130b..48cf8d69a17 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Enum_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Enum_.php @@ -21,7 +21,7 @@ class Enum_ extends \PhpParser\Node\Stmt\ClassLike */ public function __construct($name, array $subNodes = [], array $attributes = []) { - $this->name = \is_string($name) ? new \PhpParser\Node\Identifier($name) : $name; + $this->name = \is_string($name) ? new Node\Identifier($name) : $name; $this->scalarType = $subNodes['scalarType'] ?? null; $this->implements = $subNodes['implements'] ?? []; $this->stmts = $subNodes['stmts'] ?? []; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Expression.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Expression.php index fac2b9e3f61..4971d2f6296 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Expression.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Expression.php @@ -7,7 +7,7 @@ use PhpParser\Node; /** * Represents statements of type "expr;" */ -class Expression extends \PhpParser\Node\Stmt +class Expression extends Node\Stmt { /** @var Node\Expr Expression */ public $expr; @@ -17,7 +17,7 @@ class Expression extends \PhpParser\Node\Stmt * @param Node\Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $expr, array $attributes = []) + public function __construct(Node\Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Finally_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Finally_.php index 11a42a2d708..bff89f7661b 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Finally_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Finally_.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node; use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; -class Finally_ extends \PhpParser\Node\Stmt implements \Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface +class Finally_ extends Node\Stmt implements StmtsAwareInterface { /** @var Node\Stmt[] Statements */ public $stmts; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/For_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/For_.php index 9b7f40ea0de..f3faf36d146 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/For_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/For_.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node; use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; -class For_ extends \PhpParser\Node\Stmt implements \Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface +class For_ extends Node\Stmt implements StmtsAwareInterface { /** @var Node\Expr[] Init expressions */ public $init; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Foreach_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Foreach_.php index fc7c7e91ca9..add373119e1 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Foreach_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Foreach_.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node; use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; -class Foreach_ extends \PhpParser\Node\Stmt implements \Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface +class Foreach_ extends Node\Stmt implements StmtsAwareInterface { /** @var Node\Expr Expression to iterate */ public $expr; @@ -28,7 +28,7 @@ class Foreach_ extends \PhpParser\Node\Stmt implements \Rector\Core\Contract\Php * 'stmts' => array(): Statements * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $expr, \PhpParser\Node\Expr $valueVar, array $subNodes = [], array $attributes = []) + public function __construct(Node\Expr $expr, Node\Expr $valueVar, array $subNodes = [], array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Function_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Function_.php index 069c81cbc00..6e534f520b5 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Function_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Function_.php @@ -6,7 +6,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node; use PhpParser\Node\FunctionLike; use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; -class Function_ extends \PhpParser\Node\Stmt implements \PhpParser\Node\FunctionLike, \Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface +class Function_ extends Node\Stmt implements FunctionLike, StmtsAwareInterface { /** @var bool Whether function returns by reference */ public $byRef; @@ -38,10 +38,10 @@ class Function_ extends \PhpParser\Node\Stmt implements \PhpParser\Node\Function { $this->attributes = $attributes; $this->byRef = $subNodes['byRef'] ?? \false; - $this->name = \is_string($name) ? new \PhpParser\Node\Identifier($name) : $name; + $this->name = \is_string($name) ? new Node\Identifier($name) : $name; $this->params = $subNodes['params'] ?? []; $returnType = $subNodes['returnType'] ?? null; - $this->returnType = \is_string($returnType) ? new \PhpParser\Node\Identifier($returnType) : $returnType; + $this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType; $this->stmts = $subNodes['stmts'] ?? []; $this->attrGroups = $subNodes['attrGroups'] ?? []; } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Global_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Global_.php index f497b086d97..600c6788847 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Global_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Global_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; -class Global_ extends \PhpParser\Node\Stmt +class Global_ extends Node\Stmt { /** @var Node\Expr[] Variables */ public $vars; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Goto_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Goto_.php index 39b4a7eb5f9..0edfd25aa14 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Goto_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Goto_.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node\Identifier; use PhpParser\Node\Stmt; -class Goto_ extends \PhpParser\Node\Stmt +class Goto_ extends Stmt { /** @var Identifier Name of label to jump to */ public $name; @@ -18,7 +18,7 @@ class Goto_ extends \PhpParser\Node\Stmt public function __construct($name, array $attributes = []) { $this->attributes = $attributes; - $this->name = \is_string($name) ? new \PhpParser\Node\Identifier($name) : $name; + $this->name = \is_string($name) ? new Identifier($name) : $name; } public function getSubNodeNames() : array { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/GroupUse.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/GroupUse.php index e713e6c9442..f43407dcdd5 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/GroupUse.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/GroupUse.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node\Name; use PhpParser\Node\Stmt; -class GroupUse extends \PhpParser\Node\Stmt +class GroupUse extends Stmt { /** @var int Type of group use */ public $type; @@ -21,7 +21,7 @@ class GroupUse extends \PhpParser\Node\Stmt * @param int $type Type of group use * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Name $prefix, array $uses, int $type = \PhpParser\Node\Stmt\Use_::TYPE_NORMAL, array $attributes = []) + public function __construct(Name $prefix, array $uses, int $type = \PhpParser\Node\Stmt\Use_::TYPE_NORMAL, array $attributes = []) { $this->attributes = $attributes; $this->type = $type; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/HaltCompiler.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/HaltCompiler.php index 8a74c922758..ebc9654e5a3 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/HaltCompiler.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/HaltCompiler.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node\Stmt; -class HaltCompiler extends \PhpParser\Node\Stmt +class HaltCompiler extends Stmt { /** @var string Remaining text after halt compiler statement. */ public $remaining; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/If_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/If_.php index 8d48ec27640..e0673d294c0 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/If_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/If_.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node; use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; -class If_ extends \PhpParser\Node\Stmt implements \Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface +class If_ extends Node\Stmt implements StmtsAwareInterface { /** @var Node\Expr Condition expression */ public $cond; @@ -25,7 +25,7 @@ class If_ extends \PhpParser\Node\Stmt implements \Rector\Core\Contract\PhpParse * 'else' => null : Else clause * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $cond, array $subNodes = [], array $attributes = []) + public function __construct(Node\Expr $cond, array $subNodes = [], array $attributes = []) { $this->attributes = $attributes; $this->cond = $cond; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/InlineHTML.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/InlineHTML.php index f04643ccea5..8643d5c7b5a 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/InlineHTML.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/InlineHTML.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node\Stmt; -class InlineHTML extends \PhpParser\Node\Stmt +class InlineHTML extends Stmt { /** @var string String */ public $value; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Interface_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Interface_.php index 617e8c82860..ceae98b3c7f 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Interface_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Interface_.php @@ -21,7 +21,7 @@ class Interface_ extends \PhpParser\Node\Stmt\ClassLike public function __construct($name, array $subNodes = [], array $attributes = []) { $this->attributes = $attributes; - $this->name = \is_string($name) ? new \PhpParser\Node\Identifier($name) : $name; + $this->name = \is_string($name) ? new Node\Identifier($name) : $name; $this->extends = $subNodes['extends'] ?? []; $this->stmts = $subNodes['stmts'] ?? []; $this->attrGroups = $subNodes['attrGroups'] ?? []; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Label.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Label.php index 8d6aca3567c..fa8563152e1 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Label.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Label.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node\Identifier; use PhpParser\Node\Stmt; -class Label extends \PhpParser\Node\Stmt +class Label extends Stmt { /** @var Identifier Name */ public $name; @@ -18,7 +18,7 @@ class Label extends \PhpParser\Node\Stmt public function __construct($name, array $attributes = []) { $this->attributes = $attributes; - $this->name = \is_string($name) ? new \PhpParser\Node\Identifier($name) : $name; + $this->name = \is_string($name) ? new Identifier($name) : $name; } public function getSubNodeNames() : array { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php index fb19c018b1c..0b329e689cc 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; -class Namespace_ extends \PhpParser\Node\Stmt +class Namespace_ extends Node\Stmt { /* For use in the "kind" attribute */ const KIND_SEMICOLON = 1; @@ -20,7 +20,7 @@ class Namespace_ extends \PhpParser\Node\Stmt * @param null|Node\Stmt[] $stmts Statements * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Name $name = null, $stmts = [], array $attributes = []) + public function __construct(Node\Name $name = null, $stmts = [], array $attributes = []) { $this->attributes = $attributes; $this->name = $name; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Nop.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Nop.php index 0607a815b8b..1d74246cae8 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Nop.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Nop.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node; /** Nop/empty statement (;). */ -class Nop extends \PhpParser\Node\Stmt +class Nop extends Node\Stmt { public function getSubNodeNames() : array { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Property.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Property.php index 8c29dfe6f14..c57ef5688a9 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Property.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Property.php @@ -7,7 +7,7 @@ use PhpParser\Node; use PhpParser\Node\ComplexType; use PhpParser\Node\Identifier; use PhpParser\Node\Name; -class Property extends \PhpParser\Node\Stmt +class Property extends Node\Stmt { /** @var int Modifiers */ public $flags; @@ -31,7 +31,7 @@ class Property extends \PhpParser\Node\Stmt $this->attributes = $attributes; $this->flags = $flags; $this->props = $props; - $this->type = \is_string($type) ? new \PhpParser\Node\Identifier($type) : $type; + $this->type = \is_string($type) ? new Identifier($type) : $type; $this->attrGroups = $attrGroups; } public function getSubNodeNames() : array diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php index a912201c6cd..533f8572ab6 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; -class PropertyProperty extends \PhpParser\Node\Stmt +class PropertyProperty extends Node\Stmt { /** @var Node\VarLikeIdentifier Name */ public $name; @@ -17,10 +17,10 @@ class PropertyProperty extends \PhpParser\Node\Stmt * @param null|Node\Expr $default Default value * @param array $attributes Additional attributes */ - public function __construct($name, \PhpParser\Node\Expr $default = null, array $attributes = []) + public function __construct($name, Node\Expr $default = null, array $attributes = []) { $this->attributes = $attributes; - $this->name = \is_string($name) ? new \PhpParser\Node\VarLikeIdentifier($name) : $name; + $this->name = \is_string($name) ? new Node\VarLikeIdentifier($name) : $name; $this->default = $default; } public function getSubNodeNames() : array diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Return_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Return_.php index 7371503db1f..b91bbe1be17 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Return_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Return_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; -class Return_ extends \PhpParser\Node\Stmt +class Return_ extends Node\Stmt { /** @var null|Node\Expr Expression */ public $expr; @@ -14,7 +14,7 @@ class Return_ extends \PhpParser\Node\Stmt * @param null|Node\Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $expr = null, array $attributes = []) + public function __construct(Node\Expr $expr = null, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php index bfc19ec4b19..424311a68f0 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node; use PhpParser\Node\Expr; -class StaticVar extends \PhpParser\Node\Stmt +class StaticVar extends Node\Stmt { /** @var Expr\Variable Variable */ public $var; @@ -18,7 +18,7 @@ class StaticVar extends \PhpParser\Node\Stmt * @param null|Node\Expr $default Default value * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr\Variable $var, \PhpParser\Node\Expr $default = null, array $attributes = []) + public function __construct(Expr\Variable $var, Node\Expr $default = null, array $attributes = []) { $this->attributes = $attributes; $this->var = $var; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Static_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Static_.php index 3877b909873..7a0a347a791 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Static_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Static_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node\Stmt; -class Static_ extends \PhpParser\Node\Stmt +class Static_ extends Stmt { /** @var StaticVar[] Variable definitions */ public $vars; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Switch_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Switch_.php index 04c53d60d26..0edbd2dfda1 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Switch_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Switch_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; -class Switch_ extends \PhpParser\Node\Stmt +class Switch_ extends Node\Stmt { /** @var Node\Expr Condition */ public $cond; @@ -17,7 +17,7 @@ class Switch_ extends \PhpParser\Node\Stmt * @param Case_[] $cases Case list * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $cond, array $cases, array $attributes = []) + public function __construct(Node\Expr $cond, array $cases, array $attributes = []) { $this->attributes = $attributes; $this->cond = $cond; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Throw_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Throw_.php index ca0efaf54bc..fd38ef1ff21 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Throw_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Throw_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; -class Throw_ extends \PhpParser\Node\Stmt +class Throw_ extends Node\Stmt { /** @var Node\Expr Expression */ public $expr; @@ -14,7 +14,7 @@ class Throw_ extends \PhpParser\Node\Stmt * @param Node\Expr $expr Expression * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $expr, array $attributes = []) + public function __construct(Node\Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUse.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUse.php index 50ac1baf918..98d9e70e326 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUse.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUse.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; -class TraitUse extends \PhpParser\Node\Stmt +class TraitUse extends Node\Stmt { /** @var Node\Name[] Traits */ public $traits; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation.php index 8f7bea3162e..02f9f066998 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; -abstract class TraitUseAdaptation extends \PhpParser\Node\Stmt +abstract class TraitUseAdaptation extends Node\Stmt { /** @var Node\Name|null Trait name */ public $trait; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php index 503795d5d87..32c226642e3 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt\TraitUseAdaptation; use PhpParser\Node; -class Alias extends \PhpParser\Node\Stmt\TraitUseAdaptation +class Alias extends Node\Stmt\TraitUseAdaptation { /** @var null|int New modifier */ public $newModifier; @@ -23,9 +23,9 @@ class Alias extends \PhpParser\Node\Stmt\TraitUseAdaptation { $this->attributes = $attributes; $this->trait = $trait; - $this->method = \is_string($method) ? new \PhpParser\Node\Identifier($method) : $method; + $this->method = \is_string($method) ? new Node\Identifier($method) : $method; $this->newModifier = $newModifier; - $this->newName = \is_string($newName) ? new \PhpParser\Node\Identifier($newName) : $newName; + $this->newName = \is_string($newName) ? new Node\Identifier($newName) : $newName; } public function getSubNodeNames() : array { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php index 50c9246df69..486a17289fc 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt\TraitUseAdaptation; use PhpParser\Node; -class Precedence extends \PhpParser\Node\Stmt\TraitUseAdaptation +class Precedence extends Node\Stmt\TraitUseAdaptation { /** @var Node\Name[] Overwritten traits */ public $insteadof; @@ -16,11 +16,11 @@ class Precedence extends \PhpParser\Node\Stmt\TraitUseAdaptation * @param Node\Name[] $insteadof Overwritten traits * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Name $trait, $method, array $insteadof, array $attributes = []) + public function __construct(Node\Name $trait, $method, array $insteadof, array $attributes = []) { $this->attributes = $attributes; $this->trait = $trait; - $this->method = \is_string($method) ? new \PhpParser\Node\Identifier($method) : $method; + $this->method = \is_string($method) ? new Node\Identifier($method) : $method; $this->insteadof = $insteadof; } public function getSubNodeNames() : array diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Trait_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Trait_.php index abc321eba1c..017bca351c3 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Trait_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Trait_.php @@ -18,7 +18,7 @@ class Trait_ extends \PhpParser\Node\Stmt\ClassLike public function __construct($name, array $subNodes = [], array $attributes = []) { $this->attributes = $attributes; - $this->name = \is_string($name) ? new \PhpParser\Node\Identifier($name) : $name; + $this->name = \is_string($name) ? new Node\Identifier($name) : $name; $this->stmts = $subNodes['stmts'] ?? []; $this->attrGroups = $subNodes['attrGroups'] ?? []; } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TryCatch.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TryCatch.php index 8cf18d41ac2..1241b61dbea 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TryCatch.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TryCatch.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node; use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; -class TryCatch extends \PhpParser\Node\Stmt implements \Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface +class TryCatch extends Node\Stmt implements StmtsAwareInterface { /** @var Node\Stmt[] Statements */ public $stmts; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Unset_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Unset_.php index 9fcd89f047d..c5a24f7187f 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Unset_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Unset_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; -class Unset_ extends \PhpParser\Node\Stmt +class Unset_ extends Node\Stmt { /** @var Node\Expr[] Variables to unset */ public $vars; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php index 124ca5593d9..a56f4faf6e5 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node; use PhpParser\Node\Identifier; -class UseUse extends \PhpParser\Node\Stmt +class UseUse extends Node\Stmt { /** @var int One of the Stmt\Use_::TYPE_* constants. Will only differ from TYPE_UNKNOWN for mixed group uses */ public $type; @@ -21,12 +21,12 @@ class UseUse extends \PhpParser\Node\Stmt * @param int $type Type of the use element (for mixed group use only) * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Name $name, $alias = null, int $type = \PhpParser\Node\Stmt\Use_::TYPE_UNKNOWN, array $attributes = []) + public function __construct(Node\Name $name, $alias = null, int $type = \PhpParser\Node\Stmt\Use_::TYPE_UNKNOWN, array $attributes = []) { $this->attributes = $attributes; $this->type = $type; $this->name = $name; - $this->alias = \is_string($alias) ? new \PhpParser\Node\Identifier($alias) : $alias; + $this->alias = \is_string($alias) ? new Identifier($alias) : $alias; } public function getSubNodeNames() : array { @@ -37,12 +37,12 @@ class UseUse extends \PhpParser\Node\Stmt * * @return Identifier */ - public function getAlias() : \PhpParser\Node\Identifier + public function getAlias() : Identifier { if (null !== $this->alias) { return $this->alias; } - return new \PhpParser\Node\Identifier($this->name->getLast()); + return new Identifier($this->name->getLast()); } public function getType() : string { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Use_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Use_.php index 90d0f776d50..6702649cd1f 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Use_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Use_.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node\Stmt; -class Use_ extends \PhpParser\Node\Stmt +class Use_ extends Stmt { /** * Unknown type. Both Stmt\Use_ / Stmt\GroupUse and Stmt\UseUse have a $type property, one of them will always be diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/While_.php b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/While_.php index 2eb7fed6dc1..6d2ac149bf7 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/While_.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/While_.php @@ -5,7 +5,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node; use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; -class While_ extends \PhpParser\Node\Stmt implements \Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface +class While_ extends Node\Stmt implements StmtsAwareInterface { /** @var Node\Expr Condition */ public $cond; @@ -18,7 +18,7 @@ class While_ extends \PhpParser\Node\Stmt implements \Rector\Core\Contract\PhpPa * @param Node\Stmt[] $stmts Statements * @param array $attributes Additional attributes */ - public function __construct(\PhpParser\Node\Expr $cond, array $stmts = [], array $attributes = []) + public function __construct(Node\Expr $cond, array $stmts = [], array $attributes = []) { $this->attributes = $attributes; $this->cond = $cond; diff --git a/vendor/nikic/php-parser/lib/PhpParser/Node/VariadicPlaceholder.php b/vendor/nikic/php-parser/lib/PhpParser/Node/VariadicPlaceholder.php index 0dc69279b87..63a0951daf7 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Node/VariadicPlaceholder.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Node/VariadicPlaceholder.php @@ -7,7 +7,7 @@ use PhpParser\NodeAbstract; /** * Represents the "..." in "foo(...)" of the first-class callable syntax. */ -class VariadicPlaceholder extends \PhpParser\NodeAbstract +class VariadicPlaceholder extends NodeAbstract { /** * Create a variadic argument placeholder (first-class callable syntax). diff --git a/vendor/nikic/php-parser/lib/PhpParser/NodeDumper.php b/vendor/nikic/php-parser/lib/PhpParser/NodeDumper.php index 100beeb8fd1..89f4b573f74 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/NodeDumper.php +++ b/vendor/nikic/php-parser/lib/PhpParser/NodeDumper.php @@ -63,9 +63,9 @@ class NodeDumper } elseif (\is_scalar($value)) { if ('flags' === $key || 'newModifier' === $key) { $r .= $this->dumpFlags($value); - } elseif ('type' === $key && $node instanceof \PhpParser\Node\Expr\Include_) { + } elseif ('type' === $key && $node instanceof Include_) { $r .= $this->dumpIncludeType($value); - } elseif ('type' === $key && ($node instanceof \PhpParser\Node\Stmt\Use_ || $node instanceof \PhpParser\Node\Stmt\UseUse || $node instanceof \PhpParser\Node\Stmt\GroupUse)) { + } elseif ('type' === $key && ($node instanceof Use_ || $node instanceof UseUse || $node instanceof GroupUse)) { $r .= $this->dumpUseType($value); } else { $r .= $value; @@ -103,25 +103,25 @@ class NodeDumper protected function dumpFlags($flags) { $strs = []; - if ($flags & \PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC) { + if ($flags & Class_::MODIFIER_PUBLIC) { $strs[] = 'MODIFIER_PUBLIC'; } - if ($flags & \PhpParser\Node\Stmt\Class_::MODIFIER_PROTECTED) { + if ($flags & Class_::MODIFIER_PROTECTED) { $strs[] = 'MODIFIER_PROTECTED'; } - if ($flags & \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE) { + if ($flags & Class_::MODIFIER_PRIVATE) { $strs[] = 'MODIFIER_PRIVATE'; } - if ($flags & \PhpParser\Node\Stmt\Class_::MODIFIER_ABSTRACT) { + if ($flags & Class_::MODIFIER_ABSTRACT) { $strs[] = 'MODIFIER_ABSTRACT'; } - if ($flags & \PhpParser\Node\Stmt\Class_::MODIFIER_STATIC) { + if ($flags & Class_::MODIFIER_STATIC) { $strs[] = 'MODIFIER_STATIC'; } - if ($flags & \PhpParser\Node\Stmt\Class_::MODIFIER_FINAL) { + if ($flags & Class_::MODIFIER_FINAL) { $strs[] = 'MODIFIER_FINAL'; } - if ($flags & \PhpParser\Node\Stmt\Class_::MODIFIER_READONLY) { + if ($flags & Class_::MODIFIER_READONLY) { $strs[] = 'MODIFIER_READONLY'; } if ($strs) { @@ -132,7 +132,7 @@ class NodeDumper } protected function dumpIncludeType($type) { - $map = [\PhpParser\Node\Expr\Include_::TYPE_INCLUDE => 'TYPE_INCLUDE', \PhpParser\Node\Expr\Include_::TYPE_INCLUDE_ONCE => 'TYPE_INCLUDE_ONCE', \PhpParser\Node\Expr\Include_::TYPE_REQUIRE => 'TYPE_REQUIRE', \PhpParser\Node\Expr\Include_::TYPE_REQUIRE_ONCE => 'TYPE_REQUIRE_ONCE']; + $map = [Include_::TYPE_INCLUDE => 'TYPE_INCLUDE', Include_::TYPE_INCLUDE_ONCE => 'TYPE_INCLUDE_ONCE', Include_::TYPE_REQUIRE => 'TYPE_REQUIRE', Include_::TYPE_REQUIRE_ONCE => 'TYPE_REQUIRE_ONCE']; if (!isset($map[$type])) { return $type; } @@ -140,7 +140,7 @@ class NodeDumper } protected function dumpUseType($type) { - $map = [\PhpParser\Node\Stmt\Use_::TYPE_UNKNOWN => 'TYPE_UNKNOWN', \PhpParser\Node\Stmt\Use_::TYPE_NORMAL => 'TYPE_NORMAL', \PhpParser\Node\Stmt\Use_::TYPE_FUNCTION => 'TYPE_FUNCTION', \PhpParser\Node\Stmt\Use_::TYPE_CONSTANT => 'TYPE_CONSTANT']; + $map = [Use_::TYPE_UNKNOWN => 'TYPE_UNKNOWN', Use_::TYPE_NORMAL => 'TYPE_NORMAL', Use_::TYPE_FUNCTION => 'TYPE_FUNCTION', Use_::TYPE_CONSTANT => 'TYPE_CONSTANT']; if (!isset($map[$type])) { return $type; } diff --git a/vendor/nikic/php-parser/lib/PhpParser/NodeFinder.php b/vendor/nikic/php-parser/lib/PhpParser/NodeFinder.php index 0a9eb4e56be..335f6ecb0eb 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/NodeFinder.php +++ b/vendor/nikic/php-parser/lib/PhpParser/NodeFinder.php @@ -20,7 +20,7 @@ class NodeFinder if (!\is_array($nodes)) { $nodes = [$nodes]; } - $visitor = new \PhpParser\NodeVisitor\FindingVisitor($filter); + $visitor = new FindingVisitor($filter); $traverser = new \PhpParser\NodeTraverser(); $traverser->addVisitor($visitor); $traverser->traverse($nodes); @@ -53,7 +53,7 @@ class NodeFinder if (!\is_array($nodes)) { $nodes = [$nodes]; } - $visitor = new \PhpParser\NodeVisitor\FirstFindingVisitor($filter); + $visitor = new FirstFindingVisitor($filter); $traverser = new \PhpParser\NodeTraverser(); $traverser->addVisitor($visitor); $traverser->traverse($nodes); diff --git a/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/CloningVisitor.php b/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/CloningVisitor.php index 49dec17eca6..ea57d2f2a08 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/CloningVisitor.php +++ b/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/CloningVisitor.php @@ -10,9 +10,9 @@ use PhpParser\NodeVisitorAbstract; * * This visitor is required to perform format-preserving pretty prints. */ -class CloningVisitor extends \PhpParser\NodeVisitorAbstract +class CloningVisitor extends NodeVisitorAbstract { - public function enterNode(\PhpParser\Node $origNode) + public function enterNode(Node $origNode) { $node = clone $origNode; $node->setAttribute('origNode', $origNode); diff --git a/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/FindingVisitor.php b/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/FindingVisitor.php index aeb3fb8f996..6da6af2cccb 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/FindingVisitor.php +++ b/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/FindingVisitor.php @@ -9,7 +9,7 @@ use PhpParser\NodeVisitorAbstract; * This visitor can be used to find and collect all nodes satisfying some criterion determined by * a filter callback. */ -class FindingVisitor extends \PhpParser\NodeVisitorAbstract +class FindingVisitor extends NodeVisitorAbstract { /** @var callable Filter callback */ protected $filterCallback; @@ -35,7 +35,7 @@ class FindingVisitor extends \PhpParser\NodeVisitorAbstract $this->foundNodes = []; return null; } - public function enterNode(\PhpParser\Node $node) + public function enterNode(Node $node) { $filterCallback = $this->filterCallback; if ($filterCallback($node)) { diff --git a/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/FirstFindingVisitor.php b/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/FirstFindingVisitor.php index 30e53f3b159..b19f20f2f6b 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/FirstFindingVisitor.php +++ b/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/FirstFindingVisitor.php @@ -10,7 +10,7 @@ use PhpParser\NodeVisitorAbstract; * This visitor can be used to find the first node satisfying some criterion determined by * a filter callback. */ -class FirstFindingVisitor extends \PhpParser\NodeVisitorAbstract +class FirstFindingVisitor extends NodeVisitorAbstract { /** @var callable Filter callback */ protected $filterCallback; @@ -36,12 +36,12 @@ class FirstFindingVisitor extends \PhpParser\NodeVisitorAbstract $this->foundNode = null; return null; } - public function enterNode(\PhpParser\Node $node) + public function enterNode(Node $node) { $filterCallback = $this->filterCallback; if ($filterCallback($node)) { $this->foundNode = $node; - return \PhpParser\NodeTraverser::STOP_TRAVERSAL; + return NodeTraverser::STOP_TRAVERSAL; } return null; } diff --git a/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/NameResolver.php b/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/NameResolver.php index 20c437191a3..a2a8a84fbe1 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/NameResolver.php +++ b/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/NameResolver.php @@ -11,7 +11,7 @@ use PhpParser\Node\Name; use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\Stmt; use PhpParser\NodeVisitorAbstract; -class NameResolver extends \PhpParser\NodeVisitorAbstract +class NameResolver extends NodeVisitorAbstract { /** @var NameContext Naming context */ protected $nameContext; @@ -32,9 +32,9 @@ class NameResolver extends \PhpParser\NodeVisitorAbstract * @param ErrorHandler|null $errorHandler Error handler * @param array $options Options */ - public function __construct(\PhpParser\ErrorHandler $errorHandler = null, array $options = []) + public function __construct(ErrorHandler $errorHandler = null, array $options = []) { - $this->nameContext = new \PhpParser\NameContext($errorHandler ?? new \PhpParser\ErrorHandler\Throwing()); + $this->nameContext = new NameContext($errorHandler ?? new ErrorHandler\Throwing()); $this->preserveOriginalNames = $options['preserveOriginalNames'] ?? \false; $this->replaceNodes = $options['replaceNodes'] ?? \true; } @@ -43,7 +43,7 @@ class NameResolver extends \PhpParser\NodeVisitorAbstract * * @return NameContext */ - public function getNameContext() : \PhpParser\NameContext + public function getNameContext() : NameContext { return $this->nameContext; } @@ -52,19 +52,19 @@ class NameResolver extends \PhpParser\NodeVisitorAbstract $this->nameContext->startNamespace(); return null; } - public function enterNode(\PhpParser\Node $node) + public function enterNode(Node $node) { - if ($node instanceof \PhpParser\Node\Stmt\Namespace_) { + if ($node instanceof Stmt\Namespace_) { $this->nameContext->startNamespace($node->name); - } elseif ($node instanceof \PhpParser\Node\Stmt\Use_) { + } elseif ($node instanceof Stmt\Use_) { foreach ($node->uses as $use) { $this->addAlias($use, $node->type, null); } - } elseif ($node instanceof \PhpParser\Node\Stmt\GroupUse) { + } elseif ($node instanceof Stmt\GroupUse) { foreach ($node->uses as $use) { $this->addAlias($use, $node->type, $node->prefix); } - } elseif ($node instanceof \PhpParser\Node\Stmt\Class_) { + } elseif ($node instanceof Stmt\Class_) { if (null !== $node->extends) { $node->extends = $this->resolveClassName($node->extends); } @@ -75,13 +75,13 @@ class NameResolver extends \PhpParser\NodeVisitorAbstract if (null !== $node->name) { $this->addNamespacedName($node); } - } elseif ($node instanceof \PhpParser\Node\Stmt\Interface_) { + } elseif ($node instanceof Stmt\Interface_) { foreach ($node->extends as &$interface) { $interface = $this->resolveClassName($interface); } $this->resolveAttrGroups($node); $this->addNamespacedName($node); - } elseif ($node instanceof \PhpParser\Node\Stmt\Enum_) { + } elseif ($node instanceof Stmt\Enum_) { foreach ($node->implements as &$interface) { $interface = $this->resolveClassName($interface); } @@ -89,46 +89,46 @@ class NameResolver extends \PhpParser\NodeVisitorAbstract if (null !== $node->name) { $this->addNamespacedName($node); } - } elseif ($node instanceof \PhpParser\Node\Stmt\Trait_) { + } elseif ($node instanceof Stmt\Trait_) { $this->resolveAttrGroups($node); $this->addNamespacedName($node); - } elseif ($node instanceof \PhpParser\Node\Stmt\Function_) { + } elseif ($node instanceof Stmt\Function_) { $this->resolveSignature($node); $this->resolveAttrGroups($node); $this->addNamespacedName($node); - } elseif ($node instanceof \PhpParser\Node\Stmt\ClassMethod || $node instanceof \PhpParser\Node\Expr\Closure || $node instanceof \PhpParser\Node\Expr\ArrowFunction) { + } elseif ($node instanceof Stmt\ClassMethod || $node instanceof Expr\Closure || $node instanceof Expr\ArrowFunction) { $this->resolveSignature($node); $this->resolveAttrGroups($node); - } elseif ($node instanceof \PhpParser\Node\Stmt\Property) { + } elseif ($node instanceof Stmt\Property) { if (null !== $node->type) { $node->type = $this->resolveType($node->type); } $this->resolveAttrGroups($node); - } elseif ($node instanceof \PhpParser\Node\Stmt\Const_) { + } elseif ($node instanceof Stmt\Const_) { foreach ($node->consts as $const) { $this->addNamespacedName($const); } } else { - if ($node instanceof \PhpParser\Node\Stmt\ClassConst) { + if ($node instanceof Stmt\ClassConst) { $this->resolveAttrGroups($node); } else { - if ($node instanceof \PhpParser\Node\Stmt\EnumCase) { + if ($node instanceof Stmt\EnumCase) { $this->resolveAttrGroups($node); - } elseif ($node instanceof \PhpParser\Node\Expr\StaticCall || $node instanceof \PhpParser\Node\Expr\StaticPropertyFetch || $node instanceof \PhpParser\Node\Expr\ClassConstFetch || $node instanceof \PhpParser\Node\Expr\New_ || $node instanceof \PhpParser\Node\Expr\Instanceof_) { - if ($node->class instanceof \PhpParser\Node\Name) { + } elseif ($node instanceof Expr\StaticCall || $node instanceof Expr\StaticPropertyFetch || $node instanceof Expr\ClassConstFetch || $node instanceof Expr\New_ || $node instanceof Expr\Instanceof_) { + if ($node->class instanceof Name) { $node->class = $this->resolveClassName($node->class); } - } elseif ($node instanceof \PhpParser\Node\Stmt\Catch_) { + } elseif ($node instanceof Stmt\Catch_) { foreach ($node->types as &$type) { $type = $this->resolveClassName($type); } - } elseif ($node instanceof \PhpParser\Node\Expr\FuncCall) { - if ($node->name instanceof \PhpParser\Node\Name) { - $node->name = $this->resolveName($node->name, \PhpParser\Node\Stmt\Use_::TYPE_FUNCTION); + } elseif ($node instanceof Expr\FuncCall) { + if ($node->name instanceof Name) { + $node->name = $this->resolveName($node->name, Stmt\Use_::TYPE_FUNCTION); } - } elseif ($node instanceof \PhpParser\Node\Expr\ConstFetch) { - $node->name = $this->resolveName($node->name, \PhpParser\Node\Stmt\Use_::TYPE_CONSTANT); - } elseif ($node instanceof \PhpParser\Node\Stmt\TraitUse) { + } elseif ($node instanceof Expr\ConstFetch) { + $node->name = $this->resolveName($node->name, Stmt\Use_::TYPE_CONSTANT); + } elseif ($node instanceof Stmt\TraitUse) { foreach ($node->traits as &$trait) { $trait = $this->resolveClassName($trait); } @@ -136,7 +136,7 @@ class NameResolver extends \PhpParser\NodeVisitorAbstract if (null !== $adaptation->trait) { $adaptation->trait = $this->resolveClassName($adaptation->trait); } - if ($adaptation instanceof \PhpParser\Node\Stmt\TraitUseAdaptation\Precedence) { + if ($adaptation instanceof Stmt\TraitUseAdaptation\Precedence) { foreach ($adaptation->insteadof as &$insteadof) { $insteadof = $this->resolveClassName($insteadof); } @@ -147,10 +147,10 @@ class NameResolver extends \PhpParser\NodeVisitorAbstract } return null; } - private function addAlias(\PhpParser\Node\Stmt\UseUse $use, $type, \PhpParser\Node\Name $prefix = null) + private function addAlias(Stmt\UseUse $use, $type, Name $prefix = null) { // Add prefix for group uses - $name = $prefix ? \PhpParser\Node\Name::concat($prefix, $use->name) : $use->name; + $name = $prefix ? Name::concat($prefix, $use->name) : $use->name; // Type is determined either by individual element or whole use declaration $type |= $use->type; $this->nameContext->addAlias($name, (string) $use->getAlias(), $type, $use->getAttributes()); @@ -166,14 +166,14 @@ class NameResolver extends \PhpParser\NodeVisitorAbstract } private function resolveType($node) { - if ($node instanceof \PhpParser\Node\Name) { + if ($node instanceof Name) { return $this->resolveClassName($node); } - if ($node instanceof \PhpParser\Node\NullableType) { + if ($node instanceof Node\NullableType) { $node->type = $this->resolveType($node->type); return $node; } - if ($node instanceof \PhpParser\Node\UnionType || $node instanceof \PhpParser\Node\IntersectionType) { + if ($node instanceof Node\UnionType || $node instanceof Node\IntersectionType) { foreach ($node->types as &$type) { $type = $this->resolveType($type); } @@ -189,14 +189,14 @@ class NameResolver extends \PhpParser\NodeVisitorAbstract * * @return Name Resolved name, or original name with attribute */ - protected function resolveName(\PhpParser\Node\Name $name, int $type) : \PhpParser\Node\Name + protected function resolveName(Name $name, int $type) : Name { if (!$this->replaceNodes) { $resolvedName = $this->nameContext->getResolvedName($name, $type); if (null !== $resolvedName) { $name->setAttribute('resolvedName', $resolvedName); } else { - $name->setAttribute('namespacedName', \PhpParser\Node\Name\FullyQualified::concat($this->nameContext->getNamespace(), $name, $name->getAttributes())); + $name->setAttribute('namespacedName', FullyQualified::concat($this->nameContext->getNamespace(), $name, $name->getAttributes())); } return $name; } @@ -212,18 +212,18 @@ class NameResolver extends \PhpParser\NodeVisitorAbstract } // unqualified names inside a namespace cannot be resolved at compile-time // add the namespaced version of the name as an attribute - $name->setAttribute('namespacedName', \PhpParser\Node\Name\FullyQualified::concat($this->nameContext->getNamespace(), $name, $name->getAttributes())); + $name->setAttribute('namespacedName', FullyQualified::concat($this->nameContext->getNamespace(), $name, $name->getAttributes())); return $name; } - protected function resolveClassName(\PhpParser\Node\Name $name) + protected function resolveClassName(Name $name) { - return $this->resolveName($name, \PhpParser\Node\Stmt\Use_::TYPE_NORMAL); + return $this->resolveName($name, Stmt\Use_::TYPE_NORMAL); } - protected function addNamespacedName(\PhpParser\Node $node) + protected function addNamespacedName(Node $node) { - $node->namespacedName = \PhpParser\Node\Name::concat($this->nameContext->getNamespace(), (string) $node->name); + $node->namespacedName = Name::concat($this->nameContext->getNamespace(), (string) $node->name); } - protected function resolveAttrGroups(\PhpParser\Node $node) + protected function resolveAttrGroups(Node $node) { foreach ($node->attrGroups as $attrGroup) { foreach ($attrGroup->attrs as $attr) { diff --git a/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/NodeConnectingVisitor.php b/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/NodeConnectingVisitor.php index 3086403aecd..9a96210ce93 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/NodeConnectingVisitor.php +++ b/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/NodeConnectingVisitor.php @@ -14,7 +14,7 @@ use PhpParser\NodeVisitorAbstract; * node can be accessed through $node->getAttribute('previous'), * and the next node can be accessed through $node->getAttribute('next'). */ -final class NodeConnectingVisitor extends \PhpParser\NodeVisitorAbstract +final class NodeConnectingVisitor extends NodeVisitorAbstract { /** * @var Node[] @@ -29,7 +29,7 @@ final class NodeConnectingVisitor extends \PhpParser\NodeVisitorAbstract $this->stack = []; $this->previous = null; } - public function enterNode(\PhpParser\Node $node) + public function enterNode(Node $node) { if (!empty($this->stack)) { $node->setAttribute('parent', $this->stack[\count($this->stack) - 1]); @@ -40,7 +40,7 @@ final class NodeConnectingVisitor extends \PhpParser\NodeVisitorAbstract } $this->stack[] = $node; } - public function leaveNode(\PhpParser\Node $node) + public function leaveNode(Node $node) { $this->previous = $node; \array_pop($this->stack); diff --git a/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php b/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php index 848f2478eec..b27ca88a335 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php +++ b/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php @@ -13,7 +13,7 @@ use PhpParser\NodeVisitorAbstract; * On the child node, the parent node can be accessed through * $node->getAttribute('parent'). */ -final class ParentConnectingVisitor extends \PhpParser\NodeVisitorAbstract +final class ParentConnectingVisitor extends NodeVisitorAbstract { /** * @var Node[] @@ -23,15 +23,15 @@ final class ParentConnectingVisitor extends \PhpParser\NodeVisitorAbstract { $this->stack = []; } - public function enterNode(\PhpParser\Node $node) + public function enterNode(Node $node) { if (!empty($this->stack)) { - $node->setAttribute('parent', $this->stack[\count($this->stack) - 1]); + $node->setAttribute('parent', $this->stack[count($this->stack) - 1]); } $this->stack[] = $node; } - public function leaveNode(\PhpParser\Node $node) + public function leaveNode(Node $node) { - \array_pop($this->stack); + array_pop($this->stack); } } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Parser/Multiple.php b/vendor/nikic/php-parser/lib/PhpParser/Parser/Multiple.php index cec9a97133a..31752cb4029 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Parser/Multiple.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Parser/Multiple.php @@ -6,7 +6,7 @@ namespace PhpParser\Parser; use PhpParser\Error; use PhpParser\ErrorHandler; use PhpParser\Parser; -class Multiple implements \PhpParser\Parser +class Multiple implements Parser { /** @var Parser[] List of parsers to try, in order of preference */ private $parsers; @@ -23,10 +23,10 @@ class Multiple implements \PhpParser\Parser { $this->parsers = $parsers; } - public function parse(string $code, \PhpParser\ErrorHandler $errorHandler = null) + public function parse(string $code, ErrorHandler $errorHandler = null) { if (null === $errorHandler) { - $errorHandler = new \PhpParser\ErrorHandler\Throwing(); + $errorHandler = new ErrorHandler\Throwing(); } list($firstStmts, $firstError) = $this->tryParse($this->parsers[0], $errorHandler, $code); if ($firstError === null) { @@ -40,13 +40,13 @@ class Multiple implements \PhpParser\Parser } throw $firstError; } - private function tryParse(\PhpParser\Parser $parser, \PhpParser\ErrorHandler $errorHandler, $code) + private function tryParse(Parser $parser, ErrorHandler $errorHandler, $code) { $stmts = null; $error = null; try { $stmts = $parser->parse($code, $errorHandler); - } catch (\PhpParser\Error $error) { + } catch (Error $error) { } return [$stmts, $error]; } diff --git a/vendor/nikic/php-parser/lib/PhpParser/Parser/Php5.php b/vendor/nikic/php-parser/lib/PhpParser/Parser/Php5.php index 9b534dcb116..003c5c11967 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Parser/Php5.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Parser/Php5.php @@ -55,7 +55,7 @@ class Php5 extends \PhpParser\ParserAbstract }, 4 => function ($stackPos) { $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { - $nop = new \PhpParser\Node\Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); + $nop = new Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); } else { $nop = null; } @@ -222,23 +222,23 @@ class Php5 extends \PhpParser\ParserAbstract }, 83 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos]; }, 84 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Identifier($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\Identifier($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 85 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Identifier($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\Identifier($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 86 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Identifier($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\Identifier($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 87 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Identifier($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\Identifier($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 88 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 89 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 90 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 91 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Name(\substr($this->semStack[$stackPos - (1 - 1)], 1), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Name(\substr($this->semStack[$stackPos - (1 - 1)], 1), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 92 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Variable(\substr($this->semStack[$stackPos - (1 - 1)], 1), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Variable(\substr($this->semStack[$stackPos - (1 - 1)], 1), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 93 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 94 => function ($stackPos) { @@ -246,35 +246,35 @@ class Php5 extends \PhpParser\ParserAbstract }, 95 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 96 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\HaltCompiler($this->lexer->handleHaltCompiler(), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\HaltCompiler($this->lexer->handleHaltCompiler(), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 97 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Namespace_($this->semStack[$stackPos - (3 - 2)], null, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); - $this->semValue->setAttribute('kind', \PhpParser\Node\Stmt\Namespace_::KIND_SEMICOLON); + $this->semValue = new Stmt\Namespace_($this->semStack[$stackPos - (3 - 2)], null, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue->setAttribute('kind', Stmt\Namespace_::KIND_SEMICOLON); $this->checkNamespace($this->semValue); }, 98 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Namespace_($this->semStack[$stackPos - (5 - 2)], $this->semStack[$stackPos - (5 - 4)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); - $this->semValue->setAttribute('kind', \PhpParser\Node\Stmt\Namespace_::KIND_BRACED); + $this->semValue = new Stmt\Namespace_($this->semStack[$stackPos - (5 - 2)], $this->semStack[$stackPos - (5 - 4)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); + $this->semValue->setAttribute('kind', Stmt\Namespace_::KIND_BRACED); $this->checkNamespace($this->semValue); }, 99 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Namespace_(null, $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); - $this->semValue->setAttribute('kind', \PhpParser\Node\Stmt\Namespace_::KIND_BRACED); + $this->semValue = new Stmt\Namespace_(null, $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue->setAttribute('kind', Stmt\Namespace_::KIND_BRACED); $this->checkNamespace($this->semValue); }, 100 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Use_($this->semStack[$stackPos - (3 - 2)], \PhpParser\Node\Stmt\Use_::TYPE_NORMAL, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Use_($this->semStack[$stackPos - (3 - 2)], Stmt\Use_::TYPE_NORMAL, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 101 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Use_($this->semStack[$stackPos - (4 - 3)], $this->semStack[$stackPos - (4 - 2)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Use_($this->semStack[$stackPos - (4 - 3)], $this->semStack[$stackPos - (4 - 2)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 102 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (2 - 1)]; }, 103 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Const_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Const_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 104 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Use_::TYPE_FUNCTION; + $this->semValue = Stmt\Use_::TYPE_FUNCTION; }, 105 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Use_::TYPE_CONSTANT; + $this->semValue = Stmt\Use_::TYPE_CONSTANT; }, 106 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\GroupUse($this->semStack[$stackPos - (7 - 3)], $this->semStack[$stackPos - (7 - 6)], $this->semStack[$stackPos - (7 - 2)], $this->startAttributeStack[$stackPos - (7 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\GroupUse($this->semStack[$stackPos - (7 - 3)], $this->semStack[$stackPos - (7 - 6)], $this->semStack[$stackPos - (7 - 2)], $this->startAttributeStack[$stackPos - (7 - 1)] + $this->endAttributes); }, 107 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\GroupUse($this->semStack[$stackPos - (6 - 2)], $this->semStack[$stackPos - (6 - 5)], \PhpParser\Node\Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\GroupUse($this->semStack[$stackPos - (6 - 2)], $this->semStack[$stackPos - (6 - 5)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); }, 108 => function ($stackPos) { $this->semStack[$stackPos - (3 - 1)][] = $this->semStack[$stackPos - (3 - 3)]; $this->semValue = $this->semStack[$stackPos - (3 - 1)]; @@ -291,20 +291,20 @@ class Php5 extends \PhpParser\ParserAbstract }, 113 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (1 - 1)]); }, 114 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\UseUse($this->semStack[$stackPos - (1 - 1)], null, \PhpParser\Node\Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\UseUse($this->semStack[$stackPos - (1 - 1)], null, Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos - (1 - 1)); }, 115 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\UseUse($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], \PhpParser\Node\Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\UseUse($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos - (3 - 3)); }, 116 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\UseUse($this->semStack[$stackPos - (1 - 1)], null, \PhpParser\Node\Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\UseUse($this->semStack[$stackPos - (1 - 1)], null, Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos - (1 - 1)); }, 117 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\UseUse($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], \PhpParser\Node\Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\UseUse($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos - (3 - 3)); }, 118 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; - $this->semValue->type = \PhpParser\Node\Stmt\Use_::TYPE_NORMAL; + $this->semValue->type = Stmt\Use_::TYPE_NORMAL; }, 119 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (2 - 2)]; $this->semValue->type = $this->semStack[$stackPos - (2 - 1)]; @@ -314,14 +314,14 @@ class Php5 extends \PhpParser\ParserAbstract }, 121 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (1 - 1)]); }, 122 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Const_($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Node\Const_($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 123 => function ($stackPos) { $this->semStack[$stackPos - (3 - 1)][] = $this->semStack[$stackPos - (3 - 3)]; $this->semValue = $this->semStack[$stackPos - (3 - 1)]; }, 124 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (1 - 1)]); }, 125 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Const_($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Node\Const_($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 126 => function ($stackPos) { if (\is_array($this->semStack[$stackPos - (2 - 2)])) { $this->semValue = \array_merge($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)]); @@ -334,7 +334,7 @@ class Php5 extends \PhpParser\ParserAbstract }, 128 => function ($stackPos) { $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { - $nop = new \PhpParser\Node\Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); + $nop = new Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); } else { $nop = null; } @@ -349,7 +349,7 @@ class Php5 extends \PhpParser\ParserAbstract }, 131 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 132 => function ($stackPos) { - throw new \PhpParser\Error('__HALT_COMPILER() can only be used from the outermost scope', $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + throw new Error('__HALT_COMPILER() can only be used from the outermost scope', $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 133 => function ($stackPos) { if ($this->semStack[$stackPos - (3 - 2)]) { $this->semValue = $this->semStack[$stackPos - (3 - 2)]; @@ -361,7 +361,7 @@ class Php5 extends \PhpParser\ParserAbstract } else { $startAttributes = $this->startAttributeStack[$stackPos - (3 - 1)]; if (isset($startAttributes['comments'])) { - $this->semValue = new \PhpParser\Node\Stmt\Nop($startAttributes + $this->endAttributes); + $this->semValue = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $this->semValue = null; } @@ -370,60 +370,60 @@ class Php5 extends \PhpParser\ParserAbstract } } }, 134 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\If_($this->semStack[$stackPos - (5 - 2)], ['stmts' => \is_array($this->semStack[$stackPos - (5 - 3)]) ? $this->semStack[$stackPos - (5 - 3)] : array($this->semStack[$stackPos - (5 - 3)]), 'elseifs' => $this->semStack[$stackPos - (5 - 4)], 'else' => $this->semStack[$stackPos - (5 - 5)]], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\If_($this->semStack[$stackPos - (5 - 2)], ['stmts' => \is_array($this->semStack[$stackPos - (5 - 3)]) ? $this->semStack[$stackPos - (5 - 3)] : array($this->semStack[$stackPos - (5 - 3)]), 'elseifs' => $this->semStack[$stackPos - (5 - 4)], 'else' => $this->semStack[$stackPos - (5 - 5)]], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); }, 135 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\If_($this->semStack[$stackPos - (8 - 2)], ['stmts' => $this->semStack[$stackPos - (8 - 4)], 'elseifs' => $this->semStack[$stackPos - (8 - 5)], 'else' => $this->semStack[$stackPos - (8 - 6)]], $this->startAttributeStack[$stackPos - (8 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\If_($this->semStack[$stackPos - (8 - 2)], ['stmts' => $this->semStack[$stackPos - (8 - 4)], 'elseifs' => $this->semStack[$stackPos - (8 - 5)], 'else' => $this->semStack[$stackPos - (8 - 6)]], $this->startAttributeStack[$stackPos - (8 - 1)] + $this->endAttributes); }, 136 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\While_($this->semStack[$stackPos - (3 - 2)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\While_($this->semStack[$stackPos - (3 - 2)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 137 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Do_($this->semStack[$stackPos - (5 - 4)], \is_array($this->semStack[$stackPos - (5 - 2)]) ? $this->semStack[$stackPos - (5 - 2)] : array($this->semStack[$stackPos - (5 - 2)]), $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Do_($this->semStack[$stackPos - (5 - 4)], \is_array($this->semStack[$stackPos - (5 - 2)]) ? $this->semStack[$stackPos - (5 - 2)] : array($this->semStack[$stackPos - (5 - 2)]), $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); }, 138 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\For_(['init' => $this->semStack[$stackPos - (9 - 3)], 'cond' => $this->semStack[$stackPos - (9 - 5)], 'loop' => $this->semStack[$stackPos - (9 - 7)], 'stmts' => $this->semStack[$stackPos - (9 - 9)]], $this->startAttributeStack[$stackPos - (9 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\For_(['init' => $this->semStack[$stackPos - (9 - 3)], 'cond' => $this->semStack[$stackPos - (9 - 5)], 'loop' => $this->semStack[$stackPos - (9 - 7)], 'stmts' => $this->semStack[$stackPos - (9 - 9)]], $this->startAttributeStack[$stackPos - (9 - 1)] + $this->endAttributes); }, 139 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Switch_($this->semStack[$stackPos - (3 - 2)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Switch_($this->semStack[$stackPos - (3 - 2)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 140 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Break_(null, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Break_(null, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 141 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Break_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Break_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 142 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Continue_(null, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Continue_(null, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 143 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Continue_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Continue_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 144 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Return_(null, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Return_(null, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 145 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Return_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Return_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 146 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Global_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Global_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 147 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Static_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Static_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 148 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Echo_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Echo_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 149 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\InlineHTML($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\InlineHTML($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 150 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Expression($this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Expression($this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 151 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Expression($this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Expression($this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 152 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Unset_($this->semStack[$stackPos - (5 - 3)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Unset_($this->semStack[$stackPos - (5 - 3)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); }, 153 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Foreach_($this->semStack[$stackPos - (7 - 3)], $this->semStack[$stackPos - (7 - 5)][0], ['keyVar' => null, 'byRef' => $this->semStack[$stackPos - (7 - 5)][1], 'stmts' => $this->semStack[$stackPos - (7 - 7)]], $this->startAttributeStack[$stackPos - (7 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Foreach_($this->semStack[$stackPos - (7 - 3)], $this->semStack[$stackPos - (7 - 5)][0], ['keyVar' => null, 'byRef' => $this->semStack[$stackPos - (7 - 5)][1], 'stmts' => $this->semStack[$stackPos - (7 - 7)]], $this->startAttributeStack[$stackPos - (7 - 1)] + $this->endAttributes); }, 154 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Foreach_($this->semStack[$stackPos - (9 - 3)], $this->semStack[$stackPos - (9 - 7)][0], ['keyVar' => $this->semStack[$stackPos - (9 - 5)], 'byRef' => $this->semStack[$stackPos - (9 - 7)][1], 'stmts' => $this->semStack[$stackPos - (9 - 9)]], $this->startAttributeStack[$stackPos - (9 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Foreach_($this->semStack[$stackPos - (9 - 3)], $this->semStack[$stackPos - (9 - 7)][0], ['keyVar' => $this->semStack[$stackPos - (9 - 5)], 'byRef' => $this->semStack[$stackPos - (9 - 7)][1], 'stmts' => $this->semStack[$stackPos - (9 - 9)]], $this->startAttributeStack[$stackPos - (9 - 1)] + $this->endAttributes); }, 155 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Declare_($this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 5)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Declare_($this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 5)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); }, 156 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\TryCatch($this->semStack[$stackPos - (6 - 3)], $this->semStack[$stackPos - (6 - 5)], $this->semStack[$stackPos - (6 - 6)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\TryCatch($this->semStack[$stackPos - (6 - 3)], $this->semStack[$stackPos - (6 - 5)], $this->semStack[$stackPos - (6 - 6)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); $this->checkTryCatch($this->semValue); }, 157 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Throw_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Throw_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 158 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Goto_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Goto_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 159 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Label($this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Label($this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 160 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Expression($this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Expression($this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 161 => function ($stackPos) { $this->semValue = array(); /* means: no statement */ @@ -432,7 +432,7 @@ class Php5 extends \PhpParser\ParserAbstract }, 163 => function ($stackPos) { $startAttributes = $this->startAttributeStack[$stackPos - (1 - 1)]; if (isset($startAttributes['comments'])) { - $this->semValue = new \PhpParser\Node\Stmt\Nop($startAttributes + $this->endAttributes); + $this->semValue = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $this->semValue = null; } @@ -446,11 +446,11 @@ class Php5 extends \PhpParser\ParserAbstract $this->semStack[$stackPos - (2 - 1)][] = $this->semStack[$stackPos - (2 - 2)]; $this->semValue = $this->semStack[$stackPos - (2 - 1)]; }, 166 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Catch_(array($this->semStack[$stackPos - (8 - 3)]), $this->semStack[$stackPos - (8 - 4)], $this->semStack[$stackPos - (8 - 7)], $this->startAttributeStack[$stackPos - (8 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Catch_(array($this->semStack[$stackPos - (8 - 3)]), $this->semStack[$stackPos - (8 - 4)], $this->semStack[$stackPos - (8 - 7)], $this->startAttributeStack[$stackPos - (8 - 1)] + $this->endAttributes); }, 167 => function ($stackPos) { $this->semValue = null; }, 168 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Finally_($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Finally_($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 169 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (1 - 1)]); }, 170 => function ($stackPos) { @@ -469,21 +469,21 @@ class Php5 extends \PhpParser\ParserAbstract }, 176 => function ($stackPos) { $this->semValue = \true; }, 177 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Function_($this->semStack[$stackPos - (10 - 3)], ['byRef' => $this->semStack[$stackPos - (10 - 2)], 'params' => $this->semStack[$stackPos - (10 - 5)], 'returnType' => $this->semStack[$stackPos - (10 - 7)], 'stmts' => $this->semStack[$stackPos - (10 - 9)]], $this->startAttributeStack[$stackPos - (10 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Function_($this->semStack[$stackPos - (10 - 3)], ['byRef' => $this->semStack[$stackPos - (10 - 2)], 'params' => $this->semStack[$stackPos - (10 - 5)], 'returnType' => $this->semStack[$stackPos - (10 - 7)], 'stmts' => $this->semStack[$stackPos - (10 - 9)]], $this->startAttributeStack[$stackPos - (10 - 1)] + $this->endAttributes); }, 178 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Class_($this->semStack[$stackPos - (7 - 2)], ['type' => $this->semStack[$stackPos - (7 - 1)], 'extends' => $this->semStack[$stackPos - (7 - 3)], 'implements' => $this->semStack[$stackPos - (7 - 4)], 'stmts' => $this->semStack[$stackPos - (7 - 6)]], $this->startAttributeStack[$stackPos - (7 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Class_($this->semStack[$stackPos - (7 - 2)], ['type' => $this->semStack[$stackPos - (7 - 1)], 'extends' => $this->semStack[$stackPos - (7 - 3)], 'implements' => $this->semStack[$stackPos - (7 - 4)], 'stmts' => $this->semStack[$stackPos - (7 - 6)]], $this->startAttributeStack[$stackPos - (7 - 1)] + $this->endAttributes); $this->checkClass($this->semValue, $stackPos - (7 - 2)); }, 179 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Interface_($this->semStack[$stackPos - (6 - 2)], ['extends' => $this->semStack[$stackPos - (6 - 3)], 'stmts' => $this->semStack[$stackPos - (6 - 5)]], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Interface_($this->semStack[$stackPos - (6 - 2)], ['extends' => $this->semStack[$stackPos - (6 - 3)], 'stmts' => $this->semStack[$stackPos - (6 - 5)]], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); $this->checkInterface($this->semValue, $stackPos - (6 - 2)); }, 180 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Trait_($this->semStack[$stackPos - (5 - 2)], ['stmts' => $this->semStack[$stackPos - (5 - 4)]], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Trait_($this->semStack[$stackPos - (5 - 2)], ['stmts' => $this->semStack[$stackPos - (5 - 4)]], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); }, 181 => function ($stackPos) { $this->semValue = 0; }, 182 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_ABSTRACT; + $this->semValue = Stmt\Class_::MODIFIER_ABSTRACT; }, 183 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_FINAL; + $this->semValue = Stmt\Class_::MODIFIER_FINAL; }, 184 => function ($stackPos) { $this->semValue = null; }, 185 => function ($stackPos) { @@ -521,7 +521,7 @@ class Php5 extends \PhpParser\ParserAbstract $this->semStack[$stackPos - (3 - 1)][] = $this->semStack[$stackPos - (3 - 3)]; $this->semValue = $this->semStack[$stackPos - (3 - 1)]; }, 201 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\DeclareDeclare($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\DeclareDeclare($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 202 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (3 - 2)]; }, 203 => function ($stackPos) { @@ -536,9 +536,9 @@ class Php5 extends \PhpParser\ParserAbstract $this->semStack[$stackPos - (2 - 1)][] = $this->semStack[$stackPos - (2 - 2)]; $this->semValue = $this->semStack[$stackPos - (2 - 1)]; }, 208 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Case_($this->semStack[$stackPos - (4 - 2)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Case_($this->semStack[$stackPos - (4 - 2)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 209 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Case_(null, $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Case_(null, $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 210 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos]; }, 211 => function ($stackPos) { @@ -553,22 +553,22 @@ class Php5 extends \PhpParser\ParserAbstract $this->semStack[$stackPos - (2 - 1)][] = $this->semStack[$stackPos - (2 - 2)]; $this->semValue = $this->semStack[$stackPos - (2 - 1)]; }, 216 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\ElseIf_($this->semStack[$stackPos - (3 - 2)], \is_array($this->semStack[$stackPos - (3 - 3)]) ? $this->semStack[$stackPos - (3 - 3)] : array($this->semStack[$stackPos - (3 - 3)]), $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\ElseIf_($this->semStack[$stackPos - (3 - 2)], \is_array($this->semStack[$stackPos - (3 - 3)]) ? $this->semStack[$stackPos - (3 - 3)] : array($this->semStack[$stackPos - (3 - 3)]), $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 217 => function ($stackPos) { $this->semValue = array(); }, 218 => function ($stackPos) { $this->semStack[$stackPos - (2 - 1)][] = $this->semStack[$stackPos - (2 - 2)]; $this->semValue = $this->semStack[$stackPos - (2 - 1)]; }, 219 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\ElseIf_($this->semStack[$stackPos - (4 - 2)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\ElseIf_($this->semStack[$stackPos - (4 - 2)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 220 => function ($stackPos) { $this->semValue = null; }, 221 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Else_(\is_array($this->semStack[$stackPos - (2 - 2)]) ? $this->semStack[$stackPos - (2 - 2)] : array($this->semStack[$stackPos - (2 - 2)]), $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Else_(\is_array($this->semStack[$stackPos - (2 - 2)]) ? $this->semStack[$stackPos - (2 - 2)] : array($this->semStack[$stackPos - (2 - 2)]), $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 222 => function ($stackPos) { $this->semValue = null; }, 223 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Else_($this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Else_($this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 224 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (1 - 1)], \false); }, 225 => function ($stackPos) { @@ -585,17 +585,17 @@ class Php5 extends \PhpParser\ParserAbstract $this->semStack[$stackPos - (3 - 1)][] = $this->semStack[$stackPos - (3 - 3)]; $this->semValue = $this->semStack[$stackPos - (3 - 1)]; }, 231 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Param($this->semStack[$stackPos - (4 - 4)], null, $this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 2)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Node\Param($this->semStack[$stackPos - (4 - 4)], null, $this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 2)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); $this->checkParam($this->semValue); }, 232 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Param($this->semStack[$stackPos - (6 - 4)], $this->semStack[$stackPos - (6 - 6)], $this->semStack[$stackPos - (6 - 1)], $this->semStack[$stackPos - (6 - 2)], $this->semStack[$stackPos - (6 - 3)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); + $this->semValue = new Node\Param($this->semStack[$stackPos - (6 - 4)], $this->semStack[$stackPos - (6 - 6)], $this->semStack[$stackPos - (6 - 1)], $this->semStack[$stackPos - (6 - 2)], $this->semStack[$stackPos - (6 - 3)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); $this->checkParam($this->semValue); }, 233 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 234 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Identifier('array', $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\Identifier('array', $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 235 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Identifier('callable', $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\Identifier('callable', $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 236 => function ($stackPos) { $this->semValue = null; }, 237 => function ($stackPos) { @@ -609,18 +609,18 @@ class Php5 extends \PhpParser\ParserAbstract }, 241 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (3 - 2)]; }, 242 => function ($stackPos) { - $this->semValue = array(new \PhpParser\Node\Arg($this->semStack[$stackPos - (3 - 2)], \false, \false, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes)); + $this->semValue = array(new Node\Arg($this->semStack[$stackPos - (3 - 2)], \false, \false, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes)); }, 243 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (1 - 1)]); }, 244 => function ($stackPos) { $this->semStack[$stackPos - (3 - 1)][] = $this->semStack[$stackPos - (3 - 3)]; $this->semValue = $this->semStack[$stackPos - (3 - 1)]; }, 245 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Arg($this->semStack[$stackPos - (1 - 1)], \false, \false, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\Arg($this->semStack[$stackPos - (1 - 1)], \false, \false, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 246 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Arg($this->semStack[$stackPos - (2 - 2)], \true, \false, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Node\Arg($this->semStack[$stackPos - (2 - 2)], \true, \false, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 247 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Arg($this->semStack[$stackPos - (2 - 2)], \false, \true, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Node\Arg($this->semStack[$stackPos - (2 - 2)], \false, \true, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 248 => function ($stackPos) { $this->semStack[$stackPos - (3 - 1)][] = $this->semStack[$stackPos - (3 - 3)]; $this->semValue = $this->semStack[$stackPos - (3 - 1)]; @@ -629,18 +629,18 @@ class Php5 extends \PhpParser\ParserAbstract }, 250 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 251 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Variable($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Variable($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 252 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Variable($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Variable($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 253 => function ($stackPos) { $this->semStack[$stackPos - (3 - 1)][] = $this->semStack[$stackPos - (3 - 3)]; $this->semValue = $this->semStack[$stackPos - (3 - 1)]; }, 254 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (1 - 1)]); }, 255 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\StaticVar($this->semStack[$stackPos - (1 - 1)], null, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\StaticVar($this->semStack[$stackPos - (1 - 1)], null, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 256 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\StaticVar($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\StaticVar($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 257 => function ($stackPos) { if ($this->semStack[$stackPos - (2 - 2)] !== null) { $this->semStack[$stackPos - (2 - 1)][] = $this->semStack[$stackPos - (2 - 2)]; @@ -651,7 +651,7 @@ class Php5 extends \PhpParser\ParserAbstract }, 259 => function ($stackPos) { $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { - $nop = new \PhpParser\Node\Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); + $nop = new Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); } else { $nop = null; } @@ -660,15 +660,15 @@ class Php5 extends \PhpParser\ParserAbstract } $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 260 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Property($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Property($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); $this->checkProperty($this->semValue, $stackPos - (3 - 1)); }, 261 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\ClassConst($this->semStack[$stackPos - (3 - 2)], 0, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\ClassConst($this->semStack[$stackPos - (3 - 2)], 0, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 262 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\ClassMethod($this->semStack[$stackPos - (9 - 4)], ['type' => $this->semStack[$stackPos - (9 - 1)], 'byRef' => $this->semStack[$stackPos - (9 - 3)], 'params' => $this->semStack[$stackPos - (9 - 6)], 'returnType' => $this->semStack[$stackPos - (9 - 8)], 'stmts' => $this->semStack[$stackPos - (9 - 9)]], $this->startAttributeStack[$stackPos - (9 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\ClassMethod($this->semStack[$stackPos - (9 - 4)], ['type' => $this->semStack[$stackPos - (9 - 1)], 'byRef' => $this->semStack[$stackPos - (9 - 3)], 'params' => $this->semStack[$stackPos - (9 - 6)], 'returnType' => $this->semStack[$stackPos - (9 - 8)], 'stmts' => $this->semStack[$stackPos - (9 - 9)]], $this->startAttributeStack[$stackPos - (9 - 1)] + $this->endAttributes); $this->checkClassMethod($this->semValue, $stackPos - (9 - 1)); }, 263 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\TraitUse($this->semStack[$stackPos - (3 - 2)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\TraitUse($this->semStack[$stackPos - (3 - 2)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 264 => function ($stackPos) { $this->semValue = array(); }, 265 => function ($stackPos) { @@ -679,15 +679,15 @@ class Php5 extends \PhpParser\ParserAbstract $this->semStack[$stackPos - (2 - 1)][] = $this->semStack[$stackPos - (2 - 2)]; $this->semValue = $this->semStack[$stackPos - (2 - 1)]; }, 268 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\TraitUseAdaptation\Precedence($this->semStack[$stackPos - (4 - 1)][0], $this->semStack[$stackPos - (4 - 1)][1], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\TraitUseAdaptation\Precedence($this->semStack[$stackPos - (4 - 1)][0], $this->semStack[$stackPos - (4 - 1)][1], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 269 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos - (5 - 1)][0], $this->semStack[$stackPos - (5 - 1)][1], $this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 4)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos - (5 - 1)][0], $this->semStack[$stackPos - (5 - 1)][1], $this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 4)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); }, 270 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos - (4 - 1)][0], $this->semStack[$stackPos - (4 - 1)][1], $this->semStack[$stackPos - (4 - 3)], null, $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos - (4 - 1)][0], $this->semStack[$stackPos - (4 - 1)][1], $this->semStack[$stackPos - (4 - 3)], null, $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 271 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos - (4 - 1)][0], $this->semStack[$stackPos - (4 - 1)][1], null, $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos - (4 - 1)][0], $this->semStack[$stackPos - (4 - 1)][1], null, $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 272 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos - (4 - 1)][0], $this->semStack[$stackPos - (4 - 1)][1], null, $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos - (4 - 1)][0], $this->semStack[$stackPos - (4 - 1)][1], null, $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 273 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)]); }, 274 => function ($stackPos) { @@ -712,28 +712,28 @@ class Php5 extends \PhpParser\ParserAbstract $this->checkModifier($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)], $stackPos - (2 - 2)); $this->semValue = $this->semStack[$stackPos - (2 - 1)] | $this->semStack[$stackPos - (2 - 2)]; }, 284 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC; + $this->semValue = Stmt\Class_::MODIFIER_PUBLIC; }, 285 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_PROTECTED; + $this->semValue = Stmt\Class_::MODIFIER_PROTECTED; }, 286 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE; + $this->semValue = Stmt\Class_::MODIFIER_PRIVATE; }, 287 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_STATIC; + $this->semValue = Stmt\Class_::MODIFIER_STATIC; }, 288 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_ABSTRACT; + $this->semValue = Stmt\Class_::MODIFIER_ABSTRACT; }, 289 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_FINAL; + $this->semValue = Stmt\Class_::MODIFIER_FINAL; }, 290 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (1 - 1)]); }, 291 => function ($stackPos) { $this->semStack[$stackPos - (3 - 1)][] = $this->semStack[$stackPos - (3 - 3)]; $this->semValue = $this->semStack[$stackPos - (3 - 1)]; }, 292 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\VarLikeIdentifier(\substr($this->semStack[$stackPos - (1 - 1)], 1), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\VarLikeIdentifier(\substr($this->semStack[$stackPos - (1 - 1)], 1), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 293 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\PropertyProperty($this->semStack[$stackPos - (1 - 1)], null, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\PropertyProperty($this->semStack[$stackPos - (1 - 1)], null, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 294 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\PropertyProperty($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\PropertyProperty($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 295 => function ($stackPos) { $this->semStack[$stackPos - (3 - 1)][] = $this->semStack[$stackPos - (3 - 3)]; $this->semValue = $this->semStack[$stackPos - (3 - 1)]; @@ -746,161 +746,161 @@ class Php5 extends \PhpParser\ParserAbstract }, 299 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 300 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Assign($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Assign($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 301 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Assign($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Assign($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 302 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignRef($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignRef($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 303 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignRef($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignRef($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 304 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 305 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Clone_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Clone_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 306 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\Plus($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\Plus($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 307 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\Minus($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\Minus($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 308 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\Mul($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\Mul($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 309 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\Div($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\Div($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 310 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\Concat($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\Concat($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 311 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\Mod($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\Mod($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 312 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\BitwiseAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\BitwiseAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 313 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\BitwiseOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\BitwiseOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 314 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\BitwiseXor($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\BitwiseXor($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 315 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\ShiftLeft($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\ShiftLeft($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 316 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\ShiftRight($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\ShiftRight($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 317 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\Pow($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\Pow($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 318 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\Coalesce($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\Coalesce($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 319 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\PostInc($this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\PostInc($this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 320 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\PreInc($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\PreInc($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 321 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\PostDec($this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\PostDec($this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 322 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\PreDec($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\PreDec($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 323 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\BooleanOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\BooleanOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 324 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\BooleanAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\BooleanAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 325 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\LogicalOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\LogicalOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 326 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\LogicalAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\LogicalAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 327 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\LogicalXor($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\LogicalXor($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 328 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\BitwiseOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\BitwiseOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 329 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 330 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 331 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\BitwiseXor($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\BitwiseXor($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 332 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Concat($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Concat($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 333 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Plus($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Plus($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 334 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Minus($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Minus($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 335 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Mul($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Mul($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 336 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Div($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Div($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 337 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Mod($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Mod($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 338 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\ShiftLeft($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\ShiftLeft($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 339 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\ShiftRight($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\ShiftRight($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 340 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Pow($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Pow($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 341 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\UnaryPlus($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\UnaryPlus($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 342 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\UnaryMinus($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\UnaryMinus($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 343 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BooleanNot($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BooleanNot($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 344 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BitwiseNot($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BitwiseNot($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 345 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Identical($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Identical($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 346 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\NotIdentical($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\NotIdentical($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 347 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Equal($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Equal($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 348 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\NotEqual($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\NotEqual($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 349 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Spaceship($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Spaceship($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 350 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Smaller($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Smaller($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 351 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\SmallerOrEqual($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\SmallerOrEqual($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 352 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Greater($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Greater($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 353 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\GreaterOrEqual($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\GreaterOrEqual($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 354 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Instanceof_($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Instanceof_($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 355 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 356 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (3 - 2)]; }, 357 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Ternary($this->semStack[$stackPos - (5 - 1)], $this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 5)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Ternary($this->semStack[$stackPos - (5 - 1)], $this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 5)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); }, 358 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Ternary($this->semStack[$stackPos - (4 - 1)], null, $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Ternary($this->semStack[$stackPos - (4 - 1)], null, $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 359 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Coalesce($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Coalesce($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 360 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Isset_($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Isset_($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 361 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Empty_($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Empty_($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 362 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Include_($this->semStack[$stackPos - (2 - 2)], \PhpParser\Node\Expr\Include_::TYPE_INCLUDE, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Include_($this->semStack[$stackPos - (2 - 2)], Expr\Include_::TYPE_INCLUDE, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 363 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Include_($this->semStack[$stackPos - (2 - 2)], \PhpParser\Node\Expr\Include_::TYPE_INCLUDE_ONCE, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Include_($this->semStack[$stackPos - (2 - 2)], Expr\Include_::TYPE_INCLUDE_ONCE, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 364 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Eval_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Eval_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 365 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Include_($this->semStack[$stackPos - (2 - 2)], \PhpParser\Node\Expr\Include_::TYPE_REQUIRE, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Include_($this->semStack[$stackPos - (2 - 2)], Expr\Include_::TYPE_REQUIRE, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 366 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Include_($this->semStack[$stackPos - (2 - 2)], \PhpParser\Node\Expr\Include_::TYPE_REQUIRE_ONCE, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Include_($this->semStack[$stackPos - (2 - 2)], Expr\Include_::TYPE_REQUIRE_ONCE, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 367 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Cast\Int_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Cast\Int_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 368 => function ($stackPos) { $attrs = $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes; $attrs['kind'] = $this->getFloatCastKind($this->semStack[$stackPos - (2 - 1)]); - $this->semValue = new \PhpParser\Node\Expr\Cast\Double($this->semStack[$stackPos - (2 - 2)], $attrs); + $this->semValue = new Expr\Cast\Double($this->semStack[$stackPos - (2 - 2)], $attrs); }, 369 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Cast\String_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Cast\String_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 370 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Cast\Array_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Cast\Array_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 371 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Cast\Object_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Cast\Object_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 372 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Cast\Bool_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Cast\Bool_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 373 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Cast\Unset_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Cast\Unset_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 374 => function ($stackPos) { $attrs = $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes; - $attrs['kind'] = \strtolower($this->semStack[$stackPos - (2 - 1)]) === 'exit' ? \PhpParser\Node\Expr\Exit_::KIND_EXIT : \PhpParser\Node\Expr\Exit_::KIND_DIE; - $this->semValue = new \PhpParser\Node\Expr\Exit_($this->semStack[$stackPos - (2 - 2)], $attrs); + $attrs['kind'] = \strtolower($this->semStack[$stackPos - (2 - 1)]) === 'exit' ? Expr\Exit_::KIND_EXIT : Expr\Exit_::KIND_DIE; + $this->semValue = new Expr\Exit_($this->semStack[$stackPos - (2 - 2)], $attrs); }, 375 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ErrorSuppress($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ErrorSuppress($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 376 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 377 => function ($stackPos) { @@ -908,49 +908,49 @@ class Php5 extends \PhpParser\ParserAbstract }, 378 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 379 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ShellExec($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ShellExec($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 380 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Print_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Print_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 381 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Yield_(null, null, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Yield_(null, null, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 382 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\YieldFrom($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\YieldFrom($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 383 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Closure(['static' => \false, 'byRef' => $this->semStack[$stackPos - (10 - 2)], 'params' => $this->semStack[$stackPos - (10 - 4)], 'uses' => $this->semStack[$stackPos - (10 - 6)], 'returnType' => $this->semStack[$stackPos - (10 - 7)], 'stmts' => $this->semStack[$stackPos - (10 - 9)]], $this->startAttributeStack[$stackPos - (10 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Closure(['static' => \false, 'byRef' => $this->semStack[$stackPos - (10 - 2)], 'params' => $this->semStack[$stackPos - (10 - 4)], 'uses' => $this->semStack[$stackPos - (10 - 6)], 'returnType' => $this->semStack[$stackPos - (10 - 7)], 'stmts' => $this->semStack[$stackPos - (10 - 9)]], $this->startAttributeStack[$stackPos - (10 - 1)] + $this->endAttributes); }, 384 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Closure(['static' => \true, 'byRef' => $this->semStack[$stackPos - (11 - 3)], 'params' => $this->semStack[$stackPos - (11 - 5)], 'uses' => $this->semStack[$stackPos - (11 - 7)], 'returnType' => $this->semStack[$stackPos - (11 - 8)], 'stmts' => $this->semStack[$stackPos - (11 - 10)]], $this->startAttributeStack[$stackPos - (11 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Closure(['static' => \true, 'byRef' => $this->semStack[$stackPos - (11 - 3)], 'params' => $this->semStack[$stackPos - (11 - 5)], 'uses' => $this->semStack[$stackPos - (11 - 7)], 'returnType' => $this->semStack[$stackPos - (11 - 8)], 'stmts' => $this->semStack[$stackPos - (11 - 10)]], $this->startAttributeStack[$stackPos - (11 - 1)] + $this->endAttributes); }, 385 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (3 - 2)]; }, 386 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (3 - 2)]; }, 387 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Yield_($this->semStack[$stackPos - (2 - 2)], null, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Yield_($this->semStack[$stackPos - (2 - 2)], null, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 388 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Yield_($this->semStack[$stackPos - (4 - 4)], $this->semStack[$stackPos - (4 - 2)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Yield_($this->semStack[$stackPos - (4 - 4)], $this->semStack[$stackPos - (4 - 2)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 389 => function ($stackPos) { $attrs = $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes; - $attrs['kind'] = \PhpParser\Node\Expr\Array_::KIND_LONG; - $this->semValue = new \PhpParser\Node\Expr\Array_($this->semStack[$stackPos - (4 - 3)], $attrs); + $attrs['kind'] = Expr\Array_::KIND_LONG; + $this->semValue = new Expr\Array_($this->semStack[$stackPos - (4 - 3)], $attrs); }, 390 => function ($stackPos) { $attrs = $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes; - $attrs['kind'] = \PhpParser\Node\Expr\Array_::KIND_SHORT; - $this->semValue = new \PhpParser\Node\Expr\Array_($this->semStack[$stackPos - (3 - 2)], $attrs); + $attrs['kind'] = Expr\Array_::KIND_SHORT; + $this->semValue = new Expr\Array_($this->semStack[$stackPos - (3 - 2)], $attrs); }, 391 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 392 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch(\PhpParser\Node\Scalar\String_::fromString($this->semStack[$stackPos - (4 - 1)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes), $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch(Scalar\String_::fromString($this->semStack[$stackPos - (4 - 1)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes), $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 393 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 394 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 395 => function ($stackPos) { - $this->semValue = array(new \PhpParser\Node\Stmt\Class_(null, ['type' => 0, 'extends' => $this->semStack[$stackPos - (7 - 3)], 'implements' => $this->semStack[$stackPos - (7 - 4)], 'stmts' => $this->semStack[$stackPos - (7 - 6)]], $this->startAttributeStack[$stackPos - (7 - 1)] + $this->endAttributes), $this->semStack[$stackPos - (7 - 2)]); + $this->semValue = array(new Stmt\Class_(null, ['type' => 0, 'extends' => $this->semStack[$stackPos - (7 - 3)], 'implements' => $this->semStack[$stackPos - (7 - 4)], 'stmts' => $this->semStack[$stackPos - (7 - 6)]], $this->startAttributeStack[$stackPos - (7 - 1)] + $this->endAttributes), $this->semStack[$stackPos - (7 - 2)]); $this->checkClass($this->semValue[0], -1); }, 396 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\New_($this->semStack[$stackPos - (3 - 2)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\New_($this->semStack[$stackPos - (3 - 2)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 397 => function ($stackPos) { list($class, $ctorArgs) = $this->semStack[$stackPos - (2 - 2)]; - $this->semValue = new \PhpParser\Node\Expr\New_($class, $ctorArgs, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\New_($class, $ctorArgs, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 398 => function ($stackPos) { $this->semValue = array(); }, 399 => function ($stackPos) { @@ -961,31 +961,31 @@ class Php5 extends \PhpParser\ParserAbstract $this->semStack[$stackPos - (3 - 1)][] = $this->semStack[$stackPos - (3 - 3)]; $this->semValue = $this->semStack[$stackPos - (3 - 1)]; }, 402 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ClosureUse($this->semStack[$stackPos - (2 - 2)], $this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ClosureUse($this->semStack[$stackPos - (2 - 2)], $this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 403 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\FuncCall($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\FuncCall($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 404 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\StaticCall($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\StaticCall($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 405 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\StaticCall($this->semStack[$stackPos - (6 - 1)], $this->semStack[$stackPos - (6 - 4)], $this->semStack[$stackPos - (6 - 6)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); + $this->semValue = new Expr\StaticCall($this->semStack[$stackPos - (6 - 1)], $this->semStack[$stackPos - (6 - 4)], $this->semStack[$stackPos - (6 - 6)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); }, 406 => function ($stackPos) { $this->semValue = $this->fixupPhp5StaticPropCall($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 407 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\FuncCall($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\FuncCall($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 408 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 409 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 410 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 411 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 412 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 413 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Name\FullyQualified(\substr($this->semStack[$stackPos - (1 - 1)], 1), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Name\FullyQualified(\substr($this->semStack[$stackPos - (1 - 1)], 1), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 414 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Name\Relative(\substr($this->semStack[$stackPos - (1 - 1)], 10), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Name\Relative(\substr($this->semStack[$stackPos - (1 - 1)], 10), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 415 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 416 => function ($stackPos) { @@ -999,13 +999,13 @@ class Php5 extends \PhpParser\ParserAbstract }, 420 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 421 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\PropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 422 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\PropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 423 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 424 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 425 => function ($stackPos) { $this->semValue = null; }, 426 => function ($stackPos) { @@ -1015,11 +1015,11 @@ class Php5 extends \PhpParser\ParserAbstract }, 428 => function ($stackPos) { $this->semValue = array(); }, 429 => function ($stackPos) { - $this->semValue = array(new \PhpParser\Node\Scalar\EncapsedStringPart(\PhpParser\Node\Scalar\String_::parseEscapeSequences($this->semStack[$stackPos - (1 - 1)], '`', \false), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes)); + $this->semValue = array(new Scalar\EncapsedStringPart(Scalar\String_::parseEscapeSequences($this->semStack[$stackPos - (1 - 1)], '`', \false), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes)); }, 430 => function ($stackPos) { foreach ($this->semStack[$stackPos - (1 - 1)] as $s) { - if ($s instanceof \PhpParser\Node\Scalar\EncapsedStringPart) { - $s->value = \PhpParser\Node\Scalar\String_::parseEscapeSequences($s->value, '`', \false); + if ($s instanceof Node\Scalar\EncapsedStringPart) { + $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '`', \false); } } $this->semValue = $this->semStack[$stackPos - (1 - 1)]; @@ -1030,25 +1030,25 @@ class Php5 extends \PhpParser\ParserAbstract }, 433 => function ($stackPos) { $this->semValue = $this->parseLNumber($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes, \true); }, 434 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Scalar\DNumber::fromString($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = Scalar\DNumber::fromString($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 435 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Scalar\String_::fromString($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes, \false); + $this->semValue = Scalar\String_::fromString($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes, \false); }, 436 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Scalar\MagicConst\Line($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Scalar\MagicConst\Line($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 437 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Scalar\MagicConst\File($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Scalar\MagicConst\File($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 438 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Scalar\MagicConst\Dir($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Scalar\MagicConst\Dir($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 439 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Scalar\MagicConst\Class_($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Scalar\MagicConst\Class_($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 440 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Scalar\MagicConst\Trait_($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Scalar\MagicConst\Trait_($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 441 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Scalar\MagicConst\Method($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Scalar\MagicConst\Method($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 442 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Scalar\MagicConst\Function_($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Scalar\MagicConst\Function_($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 443 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Scalar\MagicConst\Namespace_($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Scalar\MagicConst\Namespace_($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 444 => function ($stackPos) { $this->semValue = $this->parseDocString($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 2)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes, $this->startAttributeStack[$stackPos - (3 - 3)] + $this->endAttributeStack[$stackPos - (3 - 3)], \false); }, 445 => function ($stackPos) { @@ -1056,100 +1056,100 @@ class Php5 extends \PhpParser\ParserAbstract }, 446 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 447 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ClassConstFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ClassConstFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 448 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ConstFetch($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ConstFetch($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 449 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Array_($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Array_($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 450 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Array_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Array_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 451 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 452 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\BooleanOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\BooleanOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 453 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\BooleanAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\BooleanAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 454 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\LogicalOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\LogicalOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 455 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\LogicalAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\LogicalAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 456 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\LogicalXor($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\LogicalXor($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 457 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\BitwiseOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\BitwiseOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 458 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 459 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 460 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\BitwiseXor($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\BitwiseXor($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 461 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Concat($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Concat($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 462 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Plus($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Plus($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 463 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Minus($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Minus($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 464 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Mul($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Mul($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 465 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Div($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Div($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 466 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Mod($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Mod($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 467 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\ShiftLeft($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\ShiftLeft($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 468 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\ShiftRight($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\ShiftRight($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 469 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Pow($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Pow($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 470 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\UnaryPlus($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\UnaryPlus($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 471 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\UnaryMinus($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\UnaryMinus($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 472 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BooleanNot($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BooleanNot($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 473 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BitwiseNot($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BitwiseNot($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 474 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Identical($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Identical($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 475 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\NotIdentical($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\NotIdentical($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 476 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Equal($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Equal($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 477 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\NotEqual($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\NotEqual($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 478 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Smaller($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Smaller($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 479 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\SmallerOrEqual($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\SmallerOrEqual($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 480 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Greater($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Greater($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 481 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\GreaterOrEqual($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\GreaterOrEqual($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 482 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Ternary($this->semStack[$stackPos - (5 - 1)], $this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 5)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Ternary($this->semStack[$stackPos - (5 - 1)], $this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 5)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); }, 483 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Ternary($this->semStack[$stackPos - (4 - 1)], null, $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Ternary($this->semStack[$stackPos - (4 - 1)], null, $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 484 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 485 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (3 - 2)]; }, 486 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ConstFetch($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ConstFetch($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 487 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ClassConstFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ClassConstFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 488 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 489 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 490 => function ($stackPos) { $attrs = $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes; - $attrs['kind'] = \PhpParser\Node\Scalar\String_::KIND_DOUBLE_QUOTED; + $attrs['kind'] = Scalar\String_::KIND_DOUBLE_QUOTED; foreach ($this->semStack[$stackPos - (3 - 2)] as $s) { - if ($s instanceof \PhpParser\Node\Scalar\EncapsedStringPart) { - $s->value = \PhpParser\Node\Scalar\String_::parseEscapeSequences($s->value, '"', \true); + if ($s instanceof Node\Scalar\EncapsedStringPart) { + $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '"', \true); } } - $this->semValue = new \PhpParser\Node\Scalar\Encapsed($this->semStack[$stackPos - (3 - 2)], $attrs); + $this->semValue = new Scalar\Encapsed($this->semStack[$stackPos - (3 - 2)], $attrs); }, 491 => function ($stackPos) { $this->semValue = $this->parseDocString($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 2)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes, $this->startAttributeStack[$stackPos - (3 - 3)] + $this->endAttributeStack[$stackPos - (3 - 3)], \true); }, 492 => function ($stackPos) { @@ -1166,9 +1166,9 @@ class Php5 extends \PhpParser\ParserAbstract }, 497 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (1 - 1)]); }, 498 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayItem($this->semStack[$stackPos - (3 - 3)], $this->semStack[$stackPos - (3 - 1)], \false, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos - (3 - 3)], $this->semStack[$stackPos - (3 - 1)], \false, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 499 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayItem($this->semStack[$stackPos - (1 - 1)], null, \false, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos - (1 - 1)], null, \false, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 500 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 501 => function ($stackPos) { @@ -1178,19 +1178,19 @@ class Php5 extends \PhpParser\ParserAbstract }, 503 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 504 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (6 - 2)], $this->semStack[$stackPos - (6 - 5)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (6 - 2)], $this->semStack[$stackPos - (6 - 5)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); }, 505 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 506 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\PropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 507 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\MethodCall($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\MethodCall($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 508 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\FuncCall($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\FuncCall($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 509 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 510 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 511 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 512 => function ($stackPos) { @@ -1198,34 +1198,34 @@ class Php5 extends \PhpParser\ParserAbstract }, 513 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 514 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Variable($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Variable($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 515 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 516 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 517 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\StaticPropertyFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 518 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 519 => function ($stackPos) { $var = \substr($this->semStack[$stackPos - (1 - 1)], 1); - $this->semValue = \is_string($var) ? new \PhpParser\Node\VarLikeIdentifier($var, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes) : $var; + $this->semValue = \is_string($var) ? new Node\VarLikeIdentifier($var, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes) : $var; }, 520 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\StaticPropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 521 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\StaticPropertyFetch($this->semStack[$stackPos - (6 - 1)], $this->semStack[$stackPos - (6 - 5)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); + $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$stackPos - (6 - 1)], $this->semStack[$stackPos - (6 - 5)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); }, 522 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 523 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 524 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 525 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 526 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 527 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Variable($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Variable($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 528 => function ($stackPos) { $this->semValue = null; }, 529 => function ($stackPos) { @@ -1237,19 +1237,19 @@ class Php5 extends \PhpParser\ParserAbstract }, 532 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 533 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Error($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Error($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); $this->errorState = 2; }, 534 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\List_($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\List_($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 535 => function ($stackPos) { $this->semStack[$stackPos - (3 - 1)][] = $this->semStack[$stackPos - (3 - 3)]; $this->semValue = $this->semStack[$stackPos - (3 - 1)]; }, 536 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (1 - 1)]); }, 537 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayItem($this->semStack[$stackPos - (1 - 1)], null, \false, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos - (1 - 1)], null, \false, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 538 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayItem($this->semStack[$stackPos - (1 - 1)], null, \false, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos - (1 - 1)], null, \false, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 539 => function ($stackPos) { $this->semValue = null; }, 540 => function ($stackPos) { @@ -1262,15 +1262,15 @@ class Php5 extends \PhpParser\ParserAbstract }, 543 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (1 - 1)]); }, 544 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayItem($this->semStack[$stackPos - (3 - 3)], $this->semStack[$stackPos - (3 - 1)], \false, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos - (3 - 3)], $this->semStack[$stackPos - (3 - 1)], \false, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 545 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayItem($this->semStack[$stackPos - (1 - 1)], null, \false, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos - (1 - 1)], null, \false, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 546 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayItem($this->semStack[$stackPos - (4 - 4)], $this->semStack[$stackPos - (4 - 1)], \true, $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos - (4 - 4)], $this->semStack[$stackPos - (4 - 1)], \true, $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 547 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayItem($this->semStack[$stackPos - (2 - 2)], null, \true, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos - (2 - 2)], null, \true, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 548 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayItem($this->semStack[$stackPos - (2 - 2)], null, \false, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes, \true, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos - (2 - 2)], null, \false, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes, \true, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 549 => function ($stackPos) { $this->semStack[$stackPos - (2 - 1)][] = $this->semStack[$stackPos - (2 - 2)]; $this->semValue = $this->semStack[$stackPos - (2 - 1)]; @@ -1282,25 +1282,25 @@ class Php5 extends \PhpParser\ParserAbstract }, 552 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)]); }, 553 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Scalar\EncapsedStringPart($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Scalar\EncapsedStringPart($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 554 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Variable($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Variable($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 555 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 556 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 557 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\PropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 558 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Variable($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Variable($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 559 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Variable($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Variable($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 560 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (6 - 2)], $this->semStack[$stackPos - (6 - 4)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (6 - 2)], $this->semStack[$stackPos - (6 - 4)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); }, 561 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (3 - 2)]; }, 562 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Scalar\String_($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Scalar\String_($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 563 => function ($stackPos) { $this->semValue = $this->parseNumString($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 564 => function ($stackPos) { diff --git a/vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php b/vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php index cdbeff26ec0..cc37d01a49d 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php @@ -55,7 +55,7 @@ class Php7 extends \PhpParser\ParserAbstract }, 4 => function ($stackPos) { $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { - $nop = new \PhpParser\Node\Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); + $nop = new Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); } else { $nop = null; } @@ -226,29 +226,29 @@ class Php7 extends \PhpParser\ParserAbstract }, 85 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos]; }, 86 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Identifier($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\Identifier($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 87 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Identifier($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\Identifier($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 88 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Identifier($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\Identifier($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 89 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Identifier($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\Identifier($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 90 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 91 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 92 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 93 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 94 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 95 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 96 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Name(\substr($this->semStack[$stackPos - (1 - 1)], 1), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Name(\substr($this->semStack[$stackPos - (1 - 1)], 1), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 97 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Variable(\substr($this->semStack[$stackPos - (1 - 1)], 1), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Variable(\substr($this->semStack[$stackPos - (1 - 1)], 1), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 98 => function ($stackPos) { /* nothing */ }, 99 => function ($stackPos) { @@ -256,22 +256,22 @@ class Php7 extends \PhpParser\ParserAbstract }, 100 => function ($stackPos) { /* nothing */ }, 101 => function ($stackPos) { - $this->emitError(new \PhpParser\Error('A trailing comma is not allowed here', $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes)); + $this->emitError(new Error('A trailing comma is not allowed here', $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes)); }, 102 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos]; }, 103 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos]; }, 104 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Attribute($this->semStack[$stackPos - (1 - 1)], [], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\Attribute($this->semStack[$stackPos - (1 - 1)], [], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 105 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Attribute($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Node\Attribute($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 106 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (1 - 1)]); }, 107 => function ($stackPos) { $this->semStack[$stackPos - (3 - 1)][] = $this->semStack[$stackPos - (3 - 3)]; $this->semValue = $this->semStack[$stackPos - (3 - 1)]; }, 108 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\AttributeGroup($this->semStack[$stackPos - (4 - 2)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Node\AttributeGroup($this->semStack[$stackPos - (4 - 2)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 109 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (1 - 1)]); }, 110 => function ($stackPos) { @@ -288,35 +288,35 @@ class Php7 extends \PhpParser\ParserAbstract }, 115 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 116 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\HaltCompiler($this->lexer->handleHaltCompiler(), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\HaltCompiler($this->lexer->handleHaltCompiler(), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 117 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Namespace_($this->semStack[$stackPos - (3 - 2)], null, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); - $this->semValue->setAttribute('kind', \PhpParser\Node\Stmt\Namespace_::KIND_SEMICOLON); + $this->semValue = new Stmt\Namespace_($this->semStack[$stackPos - (3 - 2)], null, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue->setAttribute('kind', Stmt\Namespace_::KIND_SEMICOLON); $this->checkNamespace($this->semValue); }, 118 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Namespace_($this->semStack[$stackPos - (5 - 2)], $this->semStack[$stackPos - (5 - 4)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); - $this->semValue->setAttribute('kind', \PhpParser\Node\Stmt\Namespace_::KIND_BRACED); + $this->semValue = new Stmt\Namespace_($this->semStack[$stackPos - (5 - 2)], $this->semStack[$stackPos - (5 - 4)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); + $this->semValue->setAttribute('kind', Stmt\Namespace_::KIND_BRACED); $this->checkNamespace($this->semValue); }, 119 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Namespace_(null, $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); - $this->semValue->setAttribute('kind', \PhpParser\Node\Stmt\Namespace_::KIND_BRACED); + $this->semValue = new Stmt\Namespace_(null, $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue->setAttribute('kind', Stmt\Namespace_::KIND_BRACED); $this->checkNamespace($this->semValue); }, 120 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Use_($this->semStack[$stackPos - (3 - 2)], \PhpParser\Node\Stmt\Use_::TYPE_NORMAL, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Use_($this->semStack[$stackPos - (3 - 2)], Stmt\Use_::TYPE_NORMAL, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 121 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Use_($this->semStack[$stackPos - (4 - 3)], $this->semStack[$stackPos - (4 - 2)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Use_($this->semStack[$stackPos - (4 - 3)], $this->semStack[$stackPos - (4 - 2)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 122 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (2 - 1)]; }, 123 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Const_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Const_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 124 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Use_::TYPE_FUNCTION; + $this->semValue = Stmt\Use_::TYPE_FUNCTION; }, 125 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Use_::TYPE_CONSTANT; + $this->semValue = Stmt\Use_::TYPE_CONSTANT; }, 126 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\GroupUse($this->semStack[$stackPos - (7 - 3)], $this->semStack[$stackPos - (7 - 6)], $this->semStack[$stackPos - (7 - 2)], $this->startAttributeStack[$stackPos - (7 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\GroupUse($this->semStack[$stackPos - (7 - 3)], $this->semStack[$stackPos - (7 - 6)], $this->semStack[$stackPos - (7 - 2)], $this->startAttributeStack[$stackPos - (7 - 1)] + $this->endAttributes); }, 127 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\GroupUse($this->semStack[$stackPos - (6 - 2)], $this->semStack[$stackPos - (6 - 5)], \PhpParser\Node\Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\GroupUse($this->semStack[$stackPos - (6 - 2)], $this->semStack[$stackPos - (6 - 5)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); }, 128 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (2 - 1)]; }, 129 => function ($stackPos) { @@ -339,20 +339,20 @@ class Php7 extends \PhpParser\ParserAbstract }, 136 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (1 - 1)]); }, 137 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\UseUse($this->semStack[$stackPos - (1 - 1)], null, \PhpParser\Node\Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\UseUse($this->semStack[$stackPos - (1 - 1)], null, Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos - (1 - 1)); }, 138 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\UseUse($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], \PhpParser\Node\Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\UseUse($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos - (3 - 3)); }, 139 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\UseUse($this->semStack[$stackPos - (1 - 1)], null, \PhpParser\Node\Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\UseUse($this->semStack[$stackPos - (1 - 1)], null, Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos - (1 - 1)); }, 140 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\UseUse($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], \PhpParser\Node\Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\UseUse($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos - (3 - 3)); }, 141 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; - $this->semValue->type = \PhpParser\Node\Stmt\Use_::TYPE_NORMAL; + $this->semValue->type = Stmt\Use_::TYPE_NORMAL; }, 142 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (2 - 2)]; $this->semValue->type = $this->semStack[$stackPos - (2 - 1)]; @@ -364,7 +364,7 @@ class Php7 extends \PhpParser\ParserAbstract }, 145 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (1 - 1)]); }, 146 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Const_($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Node\Const_($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 147 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (2 - 1)]; }, 148 => function ($stackPos) { @@ -373,7 +373,7 @@ class Php7 extends \PhpParser\ParserAbstract }, 149 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (1 - 1)]); }, 150 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Const_($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Node\Const_($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 151 => function ($stackPos) { if (\is_array($this->semStack[$stackPos - (2 - 2)])) { $this->semValue = \array_merge($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)]); @@ -386,7 +386,7 @@ class Php7 extends \PhpParser\ParserAbstract }, 153 => function ($stackPos) { $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { - $nop = new \PhpParser\Node\Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); + $nop = new Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); } else { $nop = null; } @@ -401,7 +401,7 @@ class Php7 extends \PhpParser\ParserAbstract }, 156 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 157 => function ($stackPos) { - throw new \PhpParser\Error('__HALT_COMPILER() can only be used from the outermost scope', $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + throw new Error('__HALT_COMPILER() can only be used from the outermost scope', $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 158 => function ($stackPos) { if ($this->semStack[$stackPos - (3 - 2)]) { $this->semValue = $this->semStack[$stackPos - (3 - 2)]; @@ -413,7 +413,7 @@ class Php7 extends \PhpParser\ParserAbstract } else { $startAttributes = $this->startAttributeStack[$stackPos - (3 - 1)]; if (isset($startAttributes['comments'])) { - $this->semValue = new \PhpParser\Node\Stmt\Nop($startAttributes + $this->endAttributes); + $this->semValue = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $this->semValue = null; } @@ -422,57 +422,57 @@ class Php7 extends \PhpParser\ParserAbstract } } }, 159 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\If_($this->semStack[$stackPos - (7 - 3)], ['stmts' => \is_array($this->semStack[$stackPos - (7 - 5)]) ? $this->semStack[$stackPos - (7 - 5)] : array($this->semStack[$stackPos - (7 - 5)]), 'elseifs' => $this->semStack[$stackPos - (7 - 6)], 'else' => $this->semStack[$stackPos - (7 - 7)]], $this->startAttributeStack[$stackPos - (7 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\If_($this->semStack[$stackPos - (7 - 3)], ['stmts' => \is_array($this->semStack[$stackPos - (7 - 5)]) ? $this->semStack[$stackPos - (7 - 5)] : array($this->semStack[$stackPos - (7 - 5)]), 'elseifs' => $this->semStack[$stackPos - (7 - 6)], 'else' => $this->semStack[$stackPos - (7 - 7)]], $this->startAttributeStack[$stackPos - (7 - 1)] + $this->endAttributes); }, 160 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\If_($this->semStack[$stackPos - (10 - 3)], ['stmts' => $this->semStack[$stackPos - (10 - 6)], 'elseifs' => $this->semStack[$stackPos - (10 - 7)], 'else' => $this->semStack[$stackPos - (10 - 8)]], $this->startAttributeStack[$stackPos - (10 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\If_($this->semStack[$stackPos - (10 - 3)], ['stmts' => $this->semStack[$stackPos - (10 - 6)], 'elseifs' => $this->semStack[$stackPos - (10 - 7)], 'else' => $this->semStack[$stackPos - (10 - 8)]], $this->startAttributeStack[$stackPos - (10 - 1)] + $this->endAttributes); }, 161 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\While_($this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 5)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\While_($this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 5)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); }, 162 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Do_($this->semStack[$stackPos - (7 - 5)], \is_array($this->semStack[$stackPos - (7 - 2)]) ? $this->semStack[$stackPos - (7 - 2)] : array($this->semStack[$stackPos - (7 - 2)]), $this->startAttributeStack[$stackPos - (7 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Do_($this->semStack[$stackPos - (7 - 5)], \is_array($this->semStack[$stackPos - (7 - 2)]) ? $this->semStack[$stackPos - (7 - 2)] : array($this->semStack[$stackPos - (7 - 2)]), $this->startAttributeStack[$stackPos - (7 - 1)] + $this->endAttributes); }, 163 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\For_(['init' => $this->semStack[$stackPos - (9 - 3)], 'cond' => $this->semStack[$stackPos - (9 - 5)], 'loop' => $this->semStack[$stackPos - (9 - 7)], 'stmts' => $this->semStack[$stackPos - (9 - 9)]], $this->startAttributeStack[$stackPos - (9 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\For_(['init' => $this->semStack[$stackPos - (9 - 3)], 'cond' => $this->semStack[$stackPos - (9 - 5)], 'loop' => $this->semStack[$stackPos - (9 - 7)], 'stmts' => $this->semStack[$stackPos - (9 - 9)]], $this->startAttributeStack[$stackPos - (9 - 1)] + $this->endAttributes); }, 164 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Switch_($this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 5)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Switch_($this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 5)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); }, 165 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Break_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Break_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 166 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Continue_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Continue_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 167 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Return_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Return_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 168 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Global_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Global_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 169 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Static_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Static_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 170 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Echo_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Echo_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 171 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\InlineHTML($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\InlineHTML($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 172 => function ($stackPos) { $e = $this->semStack[$stackPos - (2 - 1)]; - if ($e instanceof \PhpParser\Node\Expr\Throw_) { + if ($e instanceof Expr\Throw_) { // For backwards-compatibility reasons, convert throw in statement position into // Stmt\Throw_ rather than Stmt\Expression(Expr\Throw_). - $this->semValue = new \PhpParser\Node\Stmt\Throw_($e->expr, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Throw_($e->expr, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); } else { - $this->semValue = new \PhpParser\Node\Stmt\Expression($e, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Expression($e, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); } }, 173 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Unset_($this->semStack[$stackPos - (5 - 3)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Unset_($this->semStack[$stackPos - (5 - 3)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); }, 174 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Foreach_($this->semStack[$stackPos - (7 - 3)], $this->semStack[$stackPos - (7 - 5)][0], ['keyVar' => null, 'byRef' => $this->semStack[$stackPos - (7 - 5)][1], 'stmts' => $this->semStack[$stackPos - (7 - 7)]], $this->startAttributeStack[$stackPos - (7 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Foreach_($this->semStack[$stackPos - (7 - 3)], $this->semStack[$stackPos - (7 - 5)][0], ['keyVar' => null, 'byRef' => $this->semStack[$stackPos - (7 - 5)][1], 'stmts' => $this->semStack[$stackPos - (7 - 7)]], $this->startAttributeStack[$stackPos - (7 - 1)] + $this->endAttributes); }, 175 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Foreach_($this->semStack[$stackPos - (9 - 3)], $this->semStack[$stackPos - (9 - 7)][0], ['keyVar' => $this->semStack[$stackPos - (9 - 5)], 'byRef' => $this->semStack[$stackPos - (9 - 7)][1], 'stmts' => $this->semStack[$stackPos - (9 - 9)]], $this->startAttributeStack[$stackPos - (9 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Foreach_($this->semStack[$stackPos - (9 - 3)], $this->semStack[$stackPos - (9 - 7)][0], ['keyVar' => $this->semStack[$stackPos - (9 - 5)], 'byRef' => $this->semStack[$stackPos - (9 - 7)][1], 'stmts' => $this->semStack[$stackPos - (9 - 9)]], $this->startAttributeStack[$stackPos - (9 - 1)] + $this->endAttributes); }, 176 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Foreach_($this->semStack[$stackPos - (6 - 3)], new \PhpParser\Node\Expr\Error($this->startAttributeStack[$stackPos - (6 - 4)] + $this->endAttributeStack[$stackPos - (6 - 4)]), ['stmts' => $this->semStack[$stackPos - (6 - 6)]], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Foreach_($this->semStack[$stackPos - (6 - 3)], new Expr\Error($this->startAttributeStack[$stackPos - (6 - 4)] + $this->endAttributeStack[$stackPos - (6 - 4)]), ['stmts' => $this->semStack[$stackPos - (6 - 6)]], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); }, 177 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Declare_($this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 5)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Declare_($this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 5)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); }, 178 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\TryCatch($this->semStack[$stackPos - (6 - 3)], $this->semStack[$stackPos - (6 - 5)], $this->semStack[$stackPos - (6 - 6)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\TryCatch($this->semStack[$stackPos - (6 - 3)], $this->semStack[$stackPos - (6 - 5)], $this->semStack[$stackPos - (6 - 6)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); $this->checkTryCatch($this->semValue); }, 179 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Goto_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Goto_($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 180 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Label($this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Label($this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 181 => function ($stackPos) { $this->semValue = array(); /* means: no statement */ @@ -481,7 +481,7 @@ class Php7 extends \PhpParser\ParserAbstract }, 183 => function ($stackPos) { $startAttributes = $this->startAttributeStack[$stackPos - (1 - 1)]; if (isset($startAttributes['comments'])) { - $this->semValue = new \PhpParser\Node\Stmt\Nop($startAttributes + $this->endAttributes); + $this->semValue = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $this->semValue = null; } @@ -500,11 +500,11 @@ class Php7 extends \PhpParser\ParserAbstract $this->semStack[$stackPos - (3 - 1)][] = $this->semStack[$stackPos - (3 - 3)]; $this->semValue = $this->semStack[$stackPos - (3 - 1)]; }, 188 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Catch_($this->semStack[$stackPos - (8 - 3)], $this->semStack[$stackPos - (8 - 4)], $this->semStack[$stackPos - (8 - 7)], $this->startAttributeStack[$stackPos - (8 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Catch_($this->semStack[$stackPos - (8 - 3)], $this->semStack[$stackPos - (8 - 4)], $this->semStack[$stackPos - (8 - 7)], $this->startAttributeStack[$stackPos - (8 - 1)] + $this->endAttributes); }, 189 => function ($stackPos) { $this->semValue = null; }, 190 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Finally_($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Finally_($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 191 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (2 - 1)]; }, 192 => function ($stackPos) { @@ -529,19 +529,19 @@ class Php7 extends \PhpParser\ParserAbstract }, 201 => function ($stackPos) { $this->semValue = []; }, 202 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Function_($this->semStack[$stackPos - (8 - 3)], ['byRef' => $this->semStack[$stackPos - (8 - 2)], 'params' => $this->semStack[$stackPos - (8 - 5)], 'returnType' => $this->semStack[$stackPos - (8 - 7)], 'stmts' => $this->semStack[$stackPos - (8 - 8)], 'attrGroups' => []], $this->startAttributeStack[$stackPos - (8 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Function_($this->semStack[$stackPos - (8 - 3)], ['byRef' => $this->semStack[$stackPos - (8 - 2)], 'params' => $this->semStack[$stackPos - (8 - 5)], 'returnType' => $this->semStack[$stackPos - (8 - 7)], 'stmts' => $this->semStack[$stackPos - (8 - 8)], 'attrGroups' => []], $this->startAttributeStack[$stackPos - (8 - 1)] + $this->endAttributes); }, 203 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Function_($this->semStack[$stackPos - (9 - 4)], ['byRef' => $this->semStack[$stackPos - (9 - 3)], 'params' => $this->semStack[$stackPos - (9 - 6)], 'returnType' => $this->semStack[$stackPos - (9 - 8)], 'stmts' => $this->semStack[$stackPos - (9 - 9)], 'attrGroups' => $this->semStack[$stackPos - (9 - 1)]], $this->startAttributeStack[$stackPos - (9 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Function_($this->semStack[$stackPos - (9 - 4)], ['byRef' => $this->semStack[$stackPos - (9 - 3)], 'params' => $this->semStack[$stackPos - (9 - 6)], 'returnType' => $this->semStack[$stackPos - (9 - 8)], 'stmts' => $this->semStack[$stackPos - (9 - 9)], 'attrGroups' => $this->semStack[$stackPos - (9 - 1)]], $this->startAttributeStack[$stackPos - (9 - 1)] + $this->endAttributes); }, 204 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Class_($this->semStack[$stackPos - (8 - 3)], ['type' => $this->semStack[$stackPos - (8 - 2)], 'extends' => $this->semStack[$stackPos - (8 - 4)], 'implements' => $this->semStack[$stackPos - (8 - 5)], 'stmts' => $this->semStack[$stackPos - (8 - 7)], 'attrGroups' => $this->semStack[$stackPos - (8 - 1)]], $this->startAttributeStack[$stackPos - (8 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Class_($this->semStack[$stackPos - (8 - 3)], ['type' => $this->semStack[$stackPos - (8 - 2)], 'extends' => $this->semStack[$stackPos - (8 - 4)], 'implements' => $this->semStack[$stackPos - (8 - 5)], 'stmts' => $this->semStack[$stackPos - (8 - 7)], 'attrGroups' => $this->semStack[$stackPos - (8 - 1)]], $this->startAttributeStack[$stackPos - (8 - 1)] + $this->endAttributes); $this->checkClass($this->semValue, $stackPos - (8 - 3)); }, 205 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Interface_($this->semStack[$stackPos - (7 - 3)], ['extends' => $this->semStack[$stackPos - (7 - 4)], 'stmts' => $this->semStack[$stackPos - (7 - 6)], 'attrGroups' => $this->semStack[$stackPos - (7 - 1)]], $this->startAttributeStack[$stackPos - (7 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Interface_($this->semStack[$stackPos - (7 - 3)], ['extends' => $this->semStack[$stackPos - (7 - 4)], 'stmts' => $this->semStack[$stackPos - (7 - 6)], 'attrGroups' => $this->semStack[$stackPos - (7 - 1)]], $this->startAttributeStack[$stackPos - (7 - 1)] + $this->endAttributes); $this->checkInterface($this->semValue, $stackPos - (7 - 3)); }, 206 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Trait_($this->semStack[$stackPos - (6 - 3)], ['stmts' => $this->semStack[$stackPos - (6 - 5)], 'attrGroups' => $this->semStack[$stackPos - (6 - 1)]], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Trait_($this->semStack[$stackPos - (6 - 3)], ['stmts' => $this->semStack[$stackPos - (6 - 5)], 'attrGroups' => $this->semStack[$stackPos - (6 - 1)]], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); }, 207 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Enum_($this->semStack[$stackPos - (8 - 3)], ['scalarType' => $this->semStack[$stackPos - (8 - 4)], 'implements' => $this->semStack[$stackPos - (8 - 5)], 'stmts' => $this->semStack[$stackPos - (8 - 7)], 'attrGroups' => $this->semStack[$stackPos - (8 - 1)]], $this->startAttributeStack[$stackPos - (8 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Enum_($this->semStack[$stackPos - (8 - 3)], ['scalarType' => $this->semStack[$stackPos - (8 - 4)], 'implements' => $this->semStack[$stackPos - (8 - 5)], 'stmts' => $this->semStack[$stackPos - (8 - 7)], 'attrGroups' => $this->semStack[$stackPos - (8 - 1)]], $this->startAttributeStack[$stackPos - (8 - 1)] + $this->endAttributes); $this->checkEnum($this->semValue, $stackPos - (8 - 3)); }, 208 => function ($stackPos) { $this->semValue = null; @@ -561,11 +561,11 @@ class Php7 extends \PhpParser\ParserAbstract $this->checkClassModifier($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)], $stackPos - (2 - 2)); $this->semValue = $this->semStack[$stackPos - (2 - 1)] | $this->semStack[$stackPos - (2 - 2)]; }, 216 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_ABSTRACT; + $this->semValue = Stmt\Class_::MODIFIER_ABSTRACT; }, 217 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_FINAL; + $this->semValue = Stmt\Class_::MODIFIER_FINAL; }, 218 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_READONLY; + $this->semValue = Stmt\Class_::MODIFIER_READONLY; }, 219 => function ($stackPos) { $this->semValue = null; }, 220 => function ($stackPos) { @@ -607,7 +607,7 @@ class Php7 extends \PhpParser\ParserAbstract $this->semStack[$stackPos - (3 - 1)][] = $this->semStack[$stackPos - (3 - 3)]; $this->semValue = $this->semStack[$stackPos - (3 - 1)]; }, 238 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\DeclareDeclare($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\DeclareDeclare($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 239 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (3 - 2)]; }, 240 => function ($stackPos) { @@ -622,15 +622,15 @@ class Php7 extends \PhpParser\ParserAbstract $this->semStack[$stackPos - (2 - 1)][] = $this->semStack[$stackPos - (2 - 2)]; $this->semValue = $this->semStack[$stackPos - (2 - 1)]; }, 245 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Case_($this->semStack[$stackPos - (4 - 2)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Case_($this->semStack[$stackPos - (4 - 2)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 246 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Case_(null, $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Case_(null, $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 247 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos]; }, 248 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos]; }, 249 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Match_($this->semStack[$stackPos - (7 - 3)], $this->semStack[$stackPos - (7 - 6)], $this->startAttributeStack[$stackPos - (7 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Match_($this->semStack[$stackPos - (7 - 3)], $this->semStack[$stackPos - (7 - 6)], $this->startAttributeStack[$stackPos - (7 - 1)] + $this->endAttributes); }, 250 => function ($stackPos) { $this->semValue = []; }, 251 => function ($stackPos) { @@ -641,9 +641,9 @@ class Php7 extends \PhpParser\ParserAbstract $this->semStack[$stackPos - (3 - 1)][] = $this->semStack[$stackPos - (3 - 3)]; $this->semValue = $this->semStack[$stackPos - (3 - 1)]; }, 254 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\MatchArm($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Node\MatchArm($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 255 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\MatchArm(null, $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Node\MatchArm(null, $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 256 => function ($stackPos) { $this->semValue = \is_array($this->semStack[$stackPos - (1 - 1)]) ? $this->semStack[$stackPos - (1 - 1)] : array($this->semStack[$stackPos - (1 - 1)]); }, 257 => function ($stackPos) { @@ -654,22 +654,22 @@ class Php7 extends \PhpParser\ParserAbstract $this->semStack[$stackPos - (2 - 1)][] = $this->semStack[$stackPos - (2 - 2)]; $this->semValue = $this->semStack[$stackPos - (2 - 1)]; }, 260 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\ElseIf_($this->semStack[$stackPos - (5 - 3)], \is_array($this->semStack[$stackPos - (5 - 5)]) ? $this->semStack[$stackPos - (5 - 5)] : array($this->semStack[$stackPos - (5 - 5)]), $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\ElseIf_($this->semStack[$stackPos - (5 - 3)], \is_array($this->semStack[$stackPos - (5 - 5)]) ? $this->semStack[$stackPos - (5 - 5)] : array($this->semStack[$stackPos - (5 - 5)]), $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); }, 261 => function ($stackPos) { $this->semValue = array(); }, 262 => function ($stackPos) { $this->semStack[$stackPos - (2 - 1)][] = $this->semStack[$stackPos - (2 - 2)]; $this->semValue = $this->semStack[$stackPos - (2 - 1)]; }, 263 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\ElseIf_($this->semStack[$stackPos - (6 - 3)], $this->semStack[$stackPos - (6 - 6)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\ElseIf_($this->semStack[$stackPos - (6 - 3)], $this->semStack[$stackPos - (6 - 6)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); }, 264 => function ($stackPos) { $this->semValue = null; }, 265 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Else_(\is_array($this->semStack[$stackPos - (2 - 2)]) ? $this->semStack[$stackPos - (2 - 2)] : array($this->semStack[$stackPos - (2 - 2)]), $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Else_(\is_array($this->semStack[$stackPos - (2 - 2)]) ? $this->semStack[$stackPos - (2 - 2)] : array($this->semStack[$stackPos - (2 - 2)]), $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 266 => function ($stackPos) { $this->semValue = null; }, 267 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Else_($this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\Else_($this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 268 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (1 - 1)], \false); }, 269 => function ($stackPos) { @@ -693,39 +693,39 @@ class Php7 extends \PhpParser\ParserAbstract $this->checkModifier($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)], $stackPos - (2 - 2)); $this->semValue = $this->semStack[$stackPos - (2 - 1)] | $this->semStack[$stackPos - (2 - 2)]; }, 278 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC; + $this->semValue = Stmt\Class_::MODIFIER_PUBLIC; }, 279 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_PROTECTED; + $this->semValue = Stmt\Class_::MODIFIER_PROTECTED; }, 280 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE; + $this->semValue = Stmt\Class_::MODIFIER_PRIVATE; }, 281 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_READONLY; + $this->semValue = Stmt\Class_::MODIFIER_READONLY; }, 282 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Param($this->semStack[$stackPos - (6 - 6)], null, $this->semStack[$stackPos - (6 - 3)], $this->semStack[$stackPos - (6 - 4)], $this->semStack[$stackPos - (6 - 5)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes, $this->semStack[$stackPos - (6 - 2)], $this->semStack[$stackPos - (6 - 1)]); + $this->semValue = new Node\Param($this->semStack[$stackPos - (6 - 6)], null, $this->semStack[$stackPos - (6 - 3)], $this->semStack[$stackPos - (6 - 4)], $this->semStack[$stackPos - (6 - 5)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes, $this->semStack[$stackPos - (6 - 2)], $this->semStack[$stackPos - (6 - 1)]); $this->checkParam($this->semValue); }, 283 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Param($this->semStack[$stackPos - (8 - 6)], $this->semStack[$stackPos - (8 - 8)], $this->semStack[$stackPos - (8 - 3)], $this->semStack[$stackPos - (8 - 4)], $this->semStack[$stackPos - (8 - 5)], $this->startAttributeStack[$stackPos - (8 - 1)] + $this->endAttributes, $this->semStack[$stackPos - (8 - 2)], $this->semStack[$stackPos - (8 - 1)]); + $this->semValue = new Node\Param($this->semStack[$stackPos - (8 - 6)], $this->semStack[$stackPos - (8 - 8)], $this->semStack[$stackPos - (8 - 3)], $this->semStack[$stackPos - (8 - 4)], $this->semStack[$stackPos - (8 - 5)], $this->startAttributeStack[$stackPos - (8 - 1)] + $this->endAttributes, $this->semStack[$stackPos - (8 - 2)], $this->semStack[$stackPos - (8 - 1)]); $this->checkParam($this->semValue); }, 284 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Param(new \PhpParser\Node\Expr\Error($this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes), null, $this->semStack[$stackPos - (6 - 3)], $this->semStack[$stackPos - (6 - 4)], $this->semStack[$stackPos - (6 - 5)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes, $this->semStack[$stackPos - (6 - 2)], $this->semStack[$stackPos - (6 - 1)]); + $this->semValue = new Node\Param(new Expr\Error($this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes), null, $this->semStack[$stackPos - (6 - 3)], $this->semStack[$stackPos - (6 - 4)], $this->semStack[$stackPos - (6 - 5)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes, $this->semStack[$stackPos - (6 - 2)], $this->semStack[$stackPos - (6 - 1)]); }, 285 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 286 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\NullableType($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Node\NullableType($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 287 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\UnionType($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\UnionType($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 288 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\IntersectionType($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\IntersectionType($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 289 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 290 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Name('static', $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\Name('static', $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 291 => function ($stackPos) { $this->semValue = $this->handleBuiltinTypes($this->semStack[$stackPos - (1 - 1)]); }, 292 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Identifier('array', $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\Identifier('array', $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 293 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Identifier('callable', $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\Identifier('callable', $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 294 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)]); }, 295 => function ($stackPos) { @@ -749,11 +749,11 @@ class Php7 extends \PhpParser\ParserAbstract }, 302 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 303 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\NullableType($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Node\NullableType($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 304 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\UnionType($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\UnionType($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 305 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\IntersectionType($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\IntersectionType($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 306 => function ($stackPos) { $this->semValue = null; }, 307 => function ($stackPos) { @@ -771,20 +771,20 @@ class Php7 extends \PhpParser\ParserAbstract }, 313 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (3 - 2)]); }, 314 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\VariadicPlaceholder($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\VariadicPlaceholder($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 315 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (1 - 1)]); }, 316 => function ($stackPos) { $this->semStack[$stackPos - (3 - 1)][] = $this->semStack[$stackPos - (3 - 3)]; $this->semValue = $this->semStack[$stackPos - (3 - 1)]; }, 317 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Arg($this->semStack[$stackPos - (1 - 1)], \false, \false, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\Arg($this->semStack[$stackPos - (1 - 1)], \false, \false, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 318 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Arg($this->semStack[$stackPos - (2 - 2)], \true, \false, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Node\Arg($this->semStack[$stackPos - (2 - 2)], \true, \false, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 319 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Arg($this->semStack[$stackPos - (2 - 2)], \false, \true, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Node\Arg($this->semStack[$stackPos - (2 - 2)], \false, \true, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 320 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Arg($this->semStack[$stackPos - (3 - 3)], \false, \false, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes, $this->semStack[$stackPos - (3 - 1)]); + $this->semValue = new Node\Arg($this->semStack[$stackPos - (3 - 3)], \false, \false, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes, $this->semStack[$stackPos - (3 - 1)]); }, 321 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (2 - 1)]; }, 322 => function ($stackPos) { @@ -802,9 +802,9 @@ class Php7 extends \PhpParser\ParserAbstract }, 327 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (1 - 1)]); }, 328 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\StaticVar($this->semStack[$stackPos - (1 - 1)], null, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\StaticVar($this->semStack[$stackPos - (1 - 1)], null, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 329 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\StaticVar($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\StaticVar($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 330 => function ($stackPos) { if ($this->semStack[$stackPos - (2 - 2)] !== null) { $this->semStack[$stackPos - (2 - 1)][] = $this->semStack[$stackPos - (2 - 2)]; @@ -815,7 +815,7 @@ class Php7 extends \PhpParser\ParserAbstract }, 332 => function ($stackPos) { $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { - $nop = new \PhpParser\Node\Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); + $nop = new Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); } else { $nop = null; } @@ -824,18 +824,18 @@ class Php7 extends \PhpParser\ParserAbstract } $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 333 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\Property($this->semStack[$stackPos - (5 - 2)], $this->semStack[$stackPos - (5 - 4)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes, $this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 1)]); + $this->semValue = new Stmt\Property($this->semStack[$stackPos - (5 - 2)], $this->semStack[$stackPos - (5 - 4)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes, $this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 1)]); $this->checkProperty($this->semValue, $stackPos - (5 - 2)); }, 334 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\ClassConst($this->semStack[$stackPos - (5 - 4)], $this->semStack[$stackPos - (5 - 2)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes, $this->semStack[$stackPos - (5 - 1)]); + $this->semValue = new Stmt\ClassConst($this->semStack[$stackPos - (5 - 4)], $this->semStack[$stackPos - (5 - 2)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes, $this->semStack[$stackPos - (5 - 1)]); $this->checkClassConst($this->semValue, $stackPos - (5 - 2)); }, 335 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\ClassMethod($this->semStack[$stackPos - (10 - 5)], ['type' => $this->semStack[$stackPos - (10 - 2)], 'byRef' => $this->semStack[$stackPos - (10 - 4)], 'params' => $this->semStack[$stackPos - (10 - 7)], 'returnType' => $this->semStack[$stackPos - (10 - 9)], 'stmts' => $this->semStack[$stackPos - (10 - 10)], 'attrGroups' => $this->semStack[$stackPos - (10 - 1)]], $this->startAttributeStack[$stackPos - (10 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\ClassMethod($this->semStack[$stackPos - (10 - 5)], ['type' => $this->semStack[$stackPos - (10 - 2)], 'byRef' => $this->semStack[$stackPos - (10 - 4)], 'params' => $this->semStack[$stackPos - (10 - 7)], 'returnType' => $this->semStack[$stackPos - (10 - 9)], 'stmts' => $this->semStack[$stackPos - (10 - 10)], 'attrGroups' => $this->semStack[$stackPos - (10 - 1)]], $this->startAttributeStack[$stackPos - (10 - 1)] + $this->endAttributes); $this->checkClassMethod($this->semValue, $stackPos - (10 - 2)); }, 336 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\TraitUse($this->semStack[$stackPos - (3 - 2)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\TraitUse($this->semStack[$stackPos - (3 - 2)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 337 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\EnumCase($this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 4)], $this->semStack[$stackPos - (5 - 1)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\EnumCase($this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 4)], $this->semStack[$stackPos - (5 - 1)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); }, 338 => function ($stackPos) { $this->semValue = null; /* will be skipped */ @@ -849,15 +849,15 @@ class Php7 extends \PhpParser\ParserAbstract $this->semStack[$stackPos - (2 - 1)][] = $this->semStack[$stackPos - (2 - 2)]; $this->semValue = $this->semStack[$stackPos - (2 - 1)]; }, 343 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\TraitUseAdaptation\Precedence($this->semStack[$stackPos - (4 - 1)][0], $this->semStack[$stackPos - (4 - 1)][1], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\TraitUseAdaptation\Precedence($this->semStack[$stackPos - (4 - 1)][0], $this->semStack[$stackPos - (4 - 1)][1], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 344 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos - (5 - 1)][0], $this->semStack[$stackPos - (5 - 1)][1], $this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 4)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos - (5 - 1)][0], $this->semStack[$stackPos - (5 - 1)][1], $this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 4)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); }, 345 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos - (4 - 1)][0], $this->semStack[$stackPos - (4 - 1)][1], $this->semStack[$stackPos - (4 - 3)], null, $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos - (4 - 1)][0], $this->semStack[$stackPos - (4 - 1)][1], $this->semStack[$stackPos - (4 - 3)], null, $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 346 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos - (4 - 1)][0], $this->semStack[$stackPos - (4 - 1)][1], null, $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos - (4 - 1)][0], $this->semStack[$stackPos - (4 - 1)][1], null, $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 347 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos - (4 - 1)][0], $this->semStack[$stackPos - (4 - 1)][1], null, $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos - (4 - 1)][0], $this->semStack[$stackPos - (4 - 1)][1], null, $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 348 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)]); }, 349 => function ($stackPos) { @@ -882,19 +882,19 @@ class Php7 extends \PhpParser\ParserAbstract $this->checkModifier($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)], $stackPos - (2 - 2)); $this->semValue = $this->semStack[$stackPos - (2 - 1)] | $this->semStack[$stackPos - (2 - 2)]; }, 359 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC; + $this->semValue = Stmt\Class_::MODIFIER_PUBLIC; }, 360 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_PROTECTED; + $this->semValue = Stmt\Class_::MODIFIER_PROTECTED; }, 361 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE; + $this->semValue = Stmt\Class_::MODIFIER_PRIVATE; }, 362 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_STATIC; + $this->semValue = Stmt\Class_::MODIFIER_STATIC; }, 363 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_ABSTRACT; + $this->semValue = Stmt\Class_::MODIFIER_ABSTRACT; }, 364 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_FINAL; + $this->semValue = Stmt\Class_::MODIFIER_FINAL; }, 365 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Stmt\Class_::MODIFIER_READONLY; + $this->semValue = Stmt\Class_::MODIFIER_READONLY; }, 366 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (2 - 1)]; }, 367 => function ($stackPos) { @@ -903,11 +903,11 @@ class Php7 extends \PhpParser\ParserAbstract $this->semStack[$stackPos - (3 - 1)][] = $this->semStack[$stackPos - (3 - 3)]; $this->semValue = $this->semStack[$stackPos - (3 - 1)]; }, 369 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\VarLikeIdentifier(\substr($this->semStack[$stackPos - (1 - 1)], 1), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Node\VarLikeIdentifier(\substr($this->semStack[$stackPos - (1 - 1)], 1), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 370 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\PropertyProperty($this->semStack[$stackPos - (1 - 1)], null, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\PropertyProperty($this->semStack[$stackPos - (1 - 1)], null, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 371 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Stmt\PropertyProperty($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Stmt\PropertyProperty($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 372 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (2 - 1)]; }, 373 => function ($stackPos) { @@ -924,201 +924,201 @@ class Php7 extends \PhpParser\ParserAbstract }, 378 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 379 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Assign($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Assign($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 380 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Assign($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Assign($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 381 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Assign($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Assign($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 382 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignRef($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignRef($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 383 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 384 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 385 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Clone_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Clone_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 386 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\Plus($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\Plus($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 387 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\Minus($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\Minus($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 388 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\Mul($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\Mul($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 389 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\Div($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\Div($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 390 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\Concat($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\Concat($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 391 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\Mod($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\Mod($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 392 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\BitwiseAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\BitwiseAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 393 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\BitwiseOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\BitwiseOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 394 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\BitwiseXor($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\BitwiseXor($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 395 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\ShiftLeft($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\ShiftLeft($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 396 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\ShiftRight($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\ShiftRight($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 397 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\Pow($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\Pow($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 398 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\AssignOp\Coalesce($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\AssignOp\Coalesce($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 399 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\PostInc($this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\PostInc($this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 400 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\PreInc($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\PreInc($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 401 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\PostDec($this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\PostDec($this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 402 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\PreDec($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\PreDec($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 403 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\BooleanOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\BooleanOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 404 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\BooleanAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\BooleanAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 405 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\LogicalOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\LogicalOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 406 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\LogicalAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\LogicalAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 407 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\LogicalXor($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\LogicalXor($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 408 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\BitwiseOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\BitwiseOr($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 409 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 410 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 411 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\BitwiseXor($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\BitwiseXor($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 412 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Concat($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Concat($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 413 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Plus($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Plus($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 414 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Minus($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Minus($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 415 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Mul($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Mul($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 416 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Div($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Div($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 417 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Mod($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Mod($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 418 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\ShiftLeft($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\ShiftLeft($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 419 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\ShiftRight($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\ShiftRight($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 420 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Pow($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Pow($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 421 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\UnaryPlus($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\UnaryPlus($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 422 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\UnaryMinus($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\UnaryMinus($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 423 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BooleanNot($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BooleanNot($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 424 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BitwiseNot($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BitwiseNot($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 425 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Identical($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Identical($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 426 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\NotIdentical($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\NotIdentical($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 427 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Equal($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Equal($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 428 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\NotEqual($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\NotEqual($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 429 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Spaceship($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Spaceship($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 430 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Smaller($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Smaller($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 431 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\SmallerOrEqual($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\SmallerOrEqual($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 432 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Greater($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Greater($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 433 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\GreaterOrEqual($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\GreaterOrEqual($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 434 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Instanceof_($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Instanceof_($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 435 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (3 - 2)]; }, 436 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Ternary($this->semStack[$stackPos - (5 - 1)], $this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 5)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Ternary($this->semStack[$stackPos - (5 - 1)], $this->semStack[$stackPos - (5 - 3)], $this->semStack[$stackPos - (5 - 5)], $this->startAttributeStack[$stackPos - (5 - 1)] + $this->endAttributes); }, 437 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Ternary($this->semStack[$stackPos - (4 - 1)], null, $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Ternary($this->semStack[$stackPos - (4 - 1)], null, $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 438 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\BinaryOp\Coalesce($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\BinaryOp\Coalesce($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 439 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Isset_($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Isset_($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 440 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Empty_($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Empty_($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 441 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Include_($this->semStack[$stackPos - (2 - 2)], \PhpParser\Node\Expr\Include_::TYPE_INCLUDE, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Include_($this->semStack[$stackPos - (2 - 2)], Expr\Include_::TYPE_INCLUDE, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 442 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Include_($this->semStack[$stackPos - (2 - 2)], \PhpParser\Node\Expr\Include_::TYPE_INCLUDE_ONCE, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Include_($this->semStack[$stackPos - (2 - 2)], Expr\Include_::TYPE_INCLUDE_ONCE, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 443 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Eval_($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Eval_($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 444 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Include_($this->semStack[$stackPos - (2 - 2)], \PhpParser\Node\Expr\Include_::TYPE_REQUIRE, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Include_($this->semStack[$stackPos - (2 - 2)], Expr\Include_::TYPE_REQUIRE, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 445 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Include_($this->semStack[$stackPos - (2 - 2)], \PhpParser\Node\Expr\Include_::TYPE_REQUIRE_ONCE, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Include_($this->semStack[$stackPos - (2 - 2)], Expr\Include_::TYPE_REQUIRE_ONCE, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 446 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Cast\Int_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Cast\Int_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 447 => function ($stackPos) { $attrs = $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes; $attrs['kind'] = $this->getFloatCastKind($this->semStack[$stackPos - (2 - 1)]); - $this->semValue = new \PhpParser\Node\Expr\Cast\Double($this->semStack[$stackPos - (2 - 2)], $attrs); + $this->semValue = new Expr\Cast\Double($this->semStack[$stackPos - (2 - 2)], $attrs); }, 448 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Cast\String_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Cast\String_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 449 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Cast\Array_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Cast\Array_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 450 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Cast\Object_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Cast\Object_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 451 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Cast\Bool_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Cast\Bool_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 452 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Cast\Unset_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Cast\Unset_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 453 => function ($stackPos) { $attrs = $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes; - $attrs['kind'] = \strtolower($this->semStack[$stackPos - (2 - 1)]) === 'exit' ? \PhpParser\Node\Expr\Exit_::KIND_EXIT : \PhpParser\Node\Expr\Exit_::KIND_DIE; - $this->semValue = new \PhpParser\Node\Expr\Exit_($this->semStack[$stackPos - (2 - 2)], $attrs); + $attrs['kind'] = \strtolower($this->semStack[$stackPos - (2 - 1)]) === 'exit' ? Expr\Exit_::KIND_EXIT : Expr\Exit_::KIND_DIE; + $this->semValue = new Expr\Exit_($this->semStack[$stackPos - (2 - 2)], $attrs); }, 454 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ErrorSuppress($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ErrorSuppress($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 455 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 456 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ShellExec($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ShellExec($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 457 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Print_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Print_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 458 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Yield_(null, null, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Yield_(null, null, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 459 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Yield_($this->semStack[$stackPos - (2 - 2)], null, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Yield_($this->semStack[$stackPos - (2 - 2)], null, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 460 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Yield_($this->semStack[$stackPos - (4 - 4)], $this->semStack[$stackPos - (4 - 2)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Yield_($this->semStack[$stackPos - (4 - 4)], $this->semStack[$stackPos - (4 - 2)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 461 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\YieldFrom($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\YieldFrom($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 462 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Throw_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Throw_($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 463 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrowFunction(['static' => \false, 'byRef' => $this->semStack[$stackPos - (8 - 2)], 'params' => $this->semStack[$stackPos - (8 - 4)], 'returnType' => $this->semStack[$stackPos - (8 - 6)], 'expr' => $this->semStack[$stackPos - (8 - 8)], 'attrGroups' => []], $this->startAttributeStack[$stackPos - (8 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrowFunction(['static' => \false, 'byRef' => $this->semStack[$stackPos - (8 - 2)], 'params' => $this->semStack[$stackPos - (8 - 4)], 'returnType' => $this->semStack[$stackPos - (8 - 6)], 'expr' => $this->semStack[$stackPos - (8 - 8)], 'attrGroups' => []], $this->startAttributeStack[$stackPos - (8 - 1)] + $this->endAttributes); }, 464 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrowFunction(['static' => \true, 'byRef' => $this->semStack[$stackPos - (9 - 3)], 'params' => $this->semStack[$stackPos - (9 - 5)], 'returnType' => $this->semStack[$stackPos - (9 - 7)], 'expr' => $this->semStack[$stackPos - (9 - 9)], 'attrGroups' => []], $this->startAttributeStack[$stackPos - (9 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrowFunction(['static' => \true, 'byRef' => $this->semStack[$stackPos - (9 - 3)], 'params' => $this->semStack[$stackPos - (9 - 5)], 'returnType' => $this->semStack[$stackPos - (9 - 7)], 'expr' => $this->semStack[$stackPos - (9 - 9)], 'attrGroups' => []], $this->startAttributeStack[$stackPos - (9 - 1)] + $this->endAttributes); }, 465 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Closure(['static' => \false, 'byRef' => $this->semStack[$stackPos - (8 - 2)], 'params' => $this->semStack[$stackPos - (8 - 4)], 'uses' => $this->semStack[$stackPos - (8 - 6)], 'returnType' => $this->semStack[$stackPos - (8 - 7)], 'stmts' => $this->semStack[$stackPos - (8 - 8)], 'attrGroups' => []], $this->startAttributeStack[$stackPos - (8 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Closure(['static' => \false, 'byRef' => $this->semStack[$stackPos - (8 - 2)], 'params' => $this->semStack[$stackPos - (8 - 4)], 'uses' => $this->semStack[$stackPos - (8 - 6)], 'returnType' => $this->semStack[$stackPos - (8 - 7)], 'stmts' => $this->semStack[$stackPos - (8 - 8)], 'attrGroups' => []], $this->startAttributeStack[$stackPos - (8 - 1)] + $this->endAttributes); }, 466 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Closure(['static' => \true, 'byRef' => $this->semStack[$stackPos - (9 - 3)], 'params' => $this->semStack[$stackPos - (9 - 5)], 'uses' => $this->semStack[$stackPos - (9 - 7)], 'returnType' => $this->semStack[$stackPos - (9 - 8)], 'stmts' => $this->semStack[$stackPos - (9 - 9)], 'attrGroups' => []], $this->startAttributeStack[$stackPos - (9 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Closure(['static' => \true, 'byRef' => $this->semStack[$stackPos - (9 - 3)], 'params' => $this->semStack[$stackPos - (9 - 5)], 'uses' => $this->semStack[$stackPos - (9 - 7)], 'returnType' => $this->semStack[$stackPos - (9 - 8)], 'stmts' => $this->semStack[$stackPos - (9 - 9)], 'attrGroups' => []], $this->startAttributeStack[$stackPos - (9 - 1)] + $this->endAttributes); }, 467 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrowFunction(['static' => \false, 'byRef' => $this->semStack[$stackPos - (9 - 3)], 'params' => $this->semStack[$stackPos - (9 - 5)], 'returnType' => $this->semStack[$stackPos - (9 - 7)], 'expr' => $this->semStack[$stackPos - (9 - 9)], 'attrGroups' => $this->semStack[$stackPos - (9 - 1)]], $this->startAttributeStack[$stackPos - (9 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrowFunction(['static' => \false, 'byRef' => $this->semStack[$stackPos - (9 - 3)], 'params' => $this->semStack[$stackPos - (9 - 5)], 'returnType' => $this->semStack[$stackPos - (9 - 7)], 'expr' => $this->semStack[$stackPos - (9 - 9)], 'attrGroups' => $this->semStack[$stackPos - (9 - 1)]], $this->startAttributeStack[$stackPos - (9 - 1)] + $this->endAttributes); }, 468 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrowFunction(['static' => \true, 'byRef' => $this->semStack[$stackPos - (10 - 4)], 'params' => $this->semStack[$stackPos - (10 - 6)], 'returnType' => $this->semStack[$stackPos - (10 - 8)], 'expr' => $this->semStack[$stackPos - (10 - 10)], 'attrGroups' => $this->semStack[$stackPos - (10 - 1)]], $this->startAttributeStack[$stackPos - (10 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrowFunction(['static' => \true, 'byRef' => $this->semStack[$stackPos - (10 - 4)], 'params' => $this->semStack[$stackPos - (10 - 6)], 'returnType' => $this->semStack[$stackPos - (10 - 8)], 'expr' => $this->semStack[$stackPos - (10 - 10)], 'attrGroups' => $this->semStack[$stackPos - (10 - 1)]], $this->startAttributeStack[$stackPos - (10 - 1)] + $this->endAttributes); }, 469 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Closure(['static' => \false, 'byRef' => $this->semStack[$stackPos - (9 - 3)], 'params' => $this->semStack[$stackPos - (9 - 5)], 'uses' => $this->semStack[$stackPos - (9 - 7)], 'returnType' => $this->semStack[$stackPos - (9 - 8)], 'stmts' => $this->semStack[$stackPos - (9 - 9)], 'attrGroups' => $this->semStack[$stackPos - (9 - 1)]], $this->startAttributeStack[$stackPos - (9 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Closure(['static' => \false, 'byRef' => $this->semStack[$stackPos - (9 - 3)], 'params' => $this->semStack[$stackPos - (9 - 5)], 'uses' => $this->semStack[$stackPos - (9 - 7)], 'returnType' => $this->semStack[$stackPos - (9 - 8)], 'stmts' => $this->semStack[$stackPos - (9 - 9)], 'attrGroups' => $this->semStack[$stackPos - (9 - 1)]], $this->startAttributeStack[$stackPos - (9 - 1)] + $this->endAttributes); }, 470 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Closure(['static' => \true, 'byRef' => $this->semStack[$stackPos - (10 - 4)], 'params' => $this->semStack[$stackPos - (10 - 6)], 'uses' => $this->semStack[$stackPos - (10 - 8)], 'returnType' => $this->semStack[$stackPos - (10 - 9)], 'stmts' => $this->semStack[$stackPos - (10 - 10)], 'attrGroups' => $this->semStack[$stackPos - (10 - 1)]], $this->startAttributeStack[$stackPos - (10 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Closure(['static' => \true, 'byRef' => $this->semStack[$stackPos - (10 - 4)], 'params' => $this->semStack[$stackPos - (10 - 6)], 'uses' => $this->semStack[$stackPos - (10 - 8)], 'returnType' => $this->semStack[$stackPos - (10 - 9)], 'stmts' => $this->semStack[$stackPos - (10 - 10)], 'attrGroups' => $this->semStack[$stackPos - (10 - 1)]], $this->startAttributeStack[$stackPos - (10 - 1)] + $this->endAttributes); }, 471 => function ($stackPos) { - $this->semValue = array(new \PhpParser\Node\Stmt\Class_(null, ['type' => 0, 'extends' => $this->semStack[$stackPos - (8 - 4)], 'implements' => $this->semStack[$stackPos - (8 - 5)], 'stmts' => $this->semStack[$stackPos - (8 - 7)], 'attrGroups' => $this->semStack[$stackPos - (8 - 1)]], $this->startAttributeStack[$stackPos - (8 - 1)] + $this->endAttributes), $this->semStack[$stackPos - (8 - 3)]); + $this->semValue = array(new Stmt\Class_(null, ['type' => 0, 'extends' => $this->semStack[$stackPos - (8 - 4)], 'implements' => $this->semStack[$stackPos - (8 - 5)], 'stmts' => $this->semStack[$stackPos - (8 - 7)], 'attrGroups' => $this->semStack[$stackPos - (8 - 1)]], $this->startAttributeStack[$stackPos - (8 - 1)] + $this->endAttributes), $this->semStack[$stackPos - (8 - 3)]); $this->checkClass($this->semValue[0], -1); }, 472 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\New_($this->semStack[$stackPos - (3 - 2)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\New_($this->semStack[$stackPos - (3 - 2)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 473 => function ($stackPos) { list($class, $ctorArgs) = $this->semStack[$stackPos - (2 - 2)]; - $this->semValue = new \PhpParser\Node\Expr\New_($class, $ctorArgs, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\New_($class, $ctorArgs, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 474 => function ($stackPos) { $this->semValue = array(); }, 475 => function ($stackPos) { @@ -1131,25 +1131,25 @@ class Php7 extends \PhpParser\ParserAbstract $this->semStack[$stackPos - (3 - 1)][] = $this->semStack[$stackPos - (3 - 3)]; $this->semValue = $this->semStack[$stackPos - (3 - 1)]; }, 479 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ClosureUse($this->semStack[$stackPos - (2 - 2)], $this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ClosureUse($this->semStack[$stackPos - (2 - 2)], $this->semStack[$stackPos - (2 - 1)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 480 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\FuncCall($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\FuncCall($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 481 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\FuncCall($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\FuncCall($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 482 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\StaticCall($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\StaticCall($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 483 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 484 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 485 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 486 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Name($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 487 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Name\FullyQualified(\substr($this->semStack[$stackPos - (1 - 1)], 1), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Name\FullyQualified(\substr($this->semStack[$stackPos - (1 - 1)], 1), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 488 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Name\Relative(\substr($this->semStack[$stackPos - (1 - 1)], 10), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Name\Relative(\substr($this->semStack[$stackPos - (1 - 1)], 10), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 489 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 490 => function ($stackPos) { @@ -1157,7 +1157,7 @@ class Php7 extends \PhpParser\ParserAbstract }, 491 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (3 - 2)]; }, 492 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Error($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Error($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); $this->errorState = 2; }, 493 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; @@ -1170,11 +1170,11 @@ class Php7 extends \PhpParser\ParserAbstract }, 497 => function ($stackPos) { $this->semValue = array(); }, 498 => function ($stackPos) { - $this->semValue = array(new \PhpParser\Node\Scalar\EncapsedStringPart(\PhpParser\Node\Scalar\String_::parseEscapeSequences($this->semStack[$stackPos - (1 - 1)], '`'), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes)); + $this->semValue = array(new Scalar\EncapsedStringPart(Scalar\String_::parseEscapeSequences($this->semStack[$stackPos - (1 - 1)], '`'), $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes)); }, 499 => function ($stackPos) { foreach ($this->semStack[$stackPos - (1 - 1)] as $s) { - if ($s instanceof \PhpParser\Node\Scalar\EncapsedStringPart) { - $s->value = \PhpParser\Node\Scalar\String_::parseEscapeSequences($s->value, '`', \true); + if ($s instanceof Node\Scalar\EncapsedStringPart) { + $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '`', \true); } } $this->semValue = $this->semStack[$stackPos - (1 - 1)]; @@ -1183,53 +1183,53 @@ class Php7 extends \PhpParser\ParserAbstract }, 501 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 502 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ConstFetch($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ConstFetch($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 503 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Scalar\MagicConst\Line($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Scalar\MagicConst\Line($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 504 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Scalar\MagicConst\File($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Scalar\MagicConst\File($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 505 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Scalar\MagicConst\Dir($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Scalar\MagicConst\Dir($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 506 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Scalar\MagicConst\Class_($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Scalar\MagicConst\Class_($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 507 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Scalar\MagicConst\Trait_($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Scalar\MagicConst\Trait_($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 508 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Scalar\MagicConst\Method($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Scalar\MagicConst\Method($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 509 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Scalar\MagicConst\Function_($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Scalar\MagicConst\Function_($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 510 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Scalar\MagicConst\Namespace_($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Scalar\MagicConst\Namespace_($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 511 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ClassConstFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ClassConstFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 512 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ClassConstFetch($this->semStack[$stackPos - (3 - 1)], new \PhpParser\Node\Expr\Error($this->startAttributeStack[$stackPos - (3 - 3)] + $this->endAttributeStack[$stackPos - (3 - 3)]), $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ClassConstFetch($this->semStack[$stackPos - (3 - 1)], new Expr\Error($this->startAttributeStack[$stackPos - (3 - 3)] + $this->endAttributeStack[$stackPos - (3 - 3)]), $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); $this->errorState = 2; }, 513 => function ($stackPos) { $attrs = $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes; - $attrs['kind'] = \PhpParser\Node\Expr\Array_::KIND_SHORT; - $this->semValue = new \PhpParser\Node\Expr\Array_($this->semStack[$stackPos - (3 - 2)], $attrs); + $attrs['kind'] = Expr\Array_::KIND_SHORT; + $this->semValue = new Expr\Array_($this->semStack[$stackPos - (3 - 2)], $attrs); }, 514 => function ($stackPos) { $attrs = $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes; - $attrs['kind'] = \PhpParser\Node\Expr\Array_::KIND_LONG; - $this->semValue = new \PhpParser\Node\Expr\Array_($this->semStack[$stackPos - (4 - 3)], $attrs); + $attrs['kind'] = Expr\Array_::KIND_LONG; + $this->semValue = new Expr\Array_($this->semStack[$stackPos - (4 - 3)], $attrs); }, 515 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 516 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Scalar\String_::fromString($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = Scalar\String_::fromString($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 517 => function ($stackPos) { $attrs = $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes; - $attrs['kind'] = \PhpParser\Node\Scalar\String_::KIND_DOUBLE_QUOTED; + $attrs['kind'] = Scalar\String_::KIND_DOUBLE_QUOTED; foreach ($this->semStack[$stackPos - (3 - 2)] as $s) { - if ($s instanceof \PhpParser\Node\Scalar\EncapsedStringPart) { - $s->value = \PhpParser\Node\Scalar\String_::parseEscapeSequences($s->value, '"', \true); + if ($s instanceof Node\Scalar\EncapsedStringPart) { + $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '"', \true); } } - $this->semValue = new \PhpParser\Node\Scalar\Encapsed($this->semStack[$stackPos - (3 - 2)], $attrs); + $this->semValue = new Scalar\Encapsed($this->semStack[$stackPos - (3 - 2)], $attrs); }, 518 => function ($stackPos) { $this->semValue = $this->parseLNumber($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 519 => function ($stackPos) { - $this->semValue = \PhpParser\Node\Scalar\DNumber::fromString($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = Scalar\DNumber::fromString($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 520 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 521 => function ($stackPos) { @@ -1267,15 +1267,15 @@ class Php7 extends \PhpParser\ParserAbstract }, 537 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 538 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 539 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 540 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 541 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\MethodCall($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\MethodCall($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 542 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\NullsafeMethodCall($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\NullsafeMethodCall($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->semStack[$stackPos - (4 - 4)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 543 => function ($stackPos) { $this->semValue = null; }, 544 => function ($stackPos) { @@ -1285,37 +1285,37 @@ class Php7 extends \PhpParser\ParserAbstract }, 546 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 547 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\PropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 548 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\NullsafePropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\NullsafePropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 549 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 550 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Variable($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Variable($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 551 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Variable($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Variable($this->semStack[$stackPos - (2 - 2)], $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 552 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Variable(new \PhpParser\Node\Expr\Error($this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes), $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Variable(new Expr\Error($this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes), $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); $this->errorState = 2; }, 553 => function ($stackPos) { $var = $this->semStack[$stackPos - (1 - 1)]->name; - $this->semValue = \is_string($var) ? new \PhpParser\Node\VarLikeIdentifier($var, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes) : $var; + $this->semValue = \is_string($var) ? new Node\VarLikeIdentifier($var, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes) : $var; }, 554 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\StaticPropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 555 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 556 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 557 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 558 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\PropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 559 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\NullsafePropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\NullsafePropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 560 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\StaticPropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 561 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\StaticPropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 562 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 563 => function ($stackPos) { @@ -1329,10 +1329,10 @@ class Php7 extends \PhpParser\ParserAbstract }, 567 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 568 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Error($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Error($this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); $this->errorState = 2; }, 569 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\List_($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\List_($this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 570 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; $end = \count($this->semValue) - 1; @@ -1349,19 +1349,19 @@ class Php7 extends \PhpParser\ParserAbstract }, 574 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (1 - 1)]); }, 575 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayItem($this->semStack[$stackPos - (1 - 1)], null, \false, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos - (1 - 1)], null, \false, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 576 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayItem($this->semStack[$stackPos - (2 - 2)], null, \true, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos - (2 - 2)], null, \true, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 577 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayItem($this->semStack[$stackPos - (1 - 1)], null, \false, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos - (1 - 1)], null, \false, $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 578 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayItem($this->semStack[$stackPos - (3 - 3)], $this->semStack[$stackPos - (3 - 1)], \false, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos - (3 - 3)], $this->semStack[$stackPos - (3 - 1)], \false, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 579 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayItem($this->semStack[$stackPos - (4 - 4)], $this->semStack[$stackPos - (4 - 1)], \true, $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos - (4 - 4)], $this->semStack[$stackPos - (4 - 1)], \true, $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 580 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayItem($this->semStack[$stackPos - (3 - 3)], $this->semStack[$stackPos - (3 - 1)], \false, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos - (3 - 3)], $this->semStack[$stackPos - (3 - 1)], \false, $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 581 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayItem($this->semStack[$stackPos - (2 - 2)], null, \false, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes, \true, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos - (2 - 2)], null, \false, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes, \true, $this->startAttributeStack[$stackPos - (2 - 1)] + $this->endAttributes); }, 582 => function ($stackPos) { $this->semValue = null; }, 583 => function ($stackPos) { @@ -1375,27 +1375,27 @@ class Php7 extends \PhpParser\ParserAbstract }, 586 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos - (2 - 1)], $this->semStack[$stackPos - (2 - 2)]); }, 587 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Scalar\EncapsedStringPart($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Scalar\EncapsedStringPart($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 588 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Variable($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Variable($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 589 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (1 - 1)]; }, 590 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (4 - 1)], $this->semStack[$stackPos - (4 - 3)], $this->startAttributeStack[$stackPos - (4 - 1)] + $this->endAttributes); }, 591 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\PropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 592 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\NullsafePropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\NullsafePropertyFetch($this->semStack[$stackPos - (3 - 1)], $this->semStack[$stackPos - (3 - 3)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 593 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Variable($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Variable($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 594 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\Variable($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); + $this->semValue = new Expr\Variable($this->semStack[$stackPos - (3 - 2)], $this->startAttributeStack[$stackPos - (3 - 1)] + $this->endAttributes); }, 595 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Expr\ArrayDimFetch($this->semStack[$stackPos - (6 - 2)], $this->semStack[$stackPos - (6 - 4)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos - (6 - 2)], $this->semStack[$stackPos - (6 - 4)], $this->startAttributeStack[$stackPos - (6 - 1)] + $this->endAttributes); }, 596 => function ($stackPos) { $this->semValue = $this->semStack[$stackPos - (3 - 2)]; }, 597 => function ($stackPos) { - $this->semValue = new \PhpParser\Node\Scalar\String_($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); + $this->semValue = new Scalar\String_($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 598 => function ($stackPos) { $this->semValue = $this->parseNumString($this->semStack[$stackPos - (1 - 1)], $this->startAttributeStack[$stackPos - (1 - 1)] + $this->endAttributes); }, 599 => function ($stackPos) { diff --git a/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php b/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php index 892bca10bf0..18062a0b731 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php +++ b/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php @@ -519,12 +519,12 @@ abstract class ParserAbstract implements \PhpParser\Parser * * @return Expr\StaticCall */ - protected function fixupPhp5StaticPropCall($prop, array $args, array $attributes) : \PhpParser\Node\Expr\StaticCall + protected function fixupPhp5StaticPropCall($prop, array $args, array $attributes) : Expr\StaticCall { if ($prop instanceof \PhpParser\Node\Expr\StaticPropertyFetch) { - $name = $prop->name instanceof \PhpParser\Node\VarLikeIdentifier ? $prop->name->toString() : $prop->name; - $var = new \PhpParser\Node\Expr\Variable($name, $prop->name->getAttributes()); - return new \PhpParser\Node\Expr\StaticCall($prop->class, $var, $args, $attributes); + $name = $prop->name instanceof VarLikeIdentifier ? $prop->name->toString() : $prop->name; + $var = new Expr\Variable($name, $prop->name->getAttributes()); + return new Expr\StaticCall($prop->class, $var, $args, $attributes); } elseif ($prop instanceof \PhpParser\Node\Expr\ArrayDimFetch) { $tmp = $prop; while ($tmp->var instanceof \PhpParser\Node\Expr\ArrayDimFetch) { @@ -539,9 +539,9 @@ abstract class ParserAbstract implements \PhpParser\Parser $tmp = $tmp->var; $this->fixupStartAttributes($tmp, $staticProp->name); } - $name = $staticProp->name instanceof \PhpParser\Node\VarLikeIdentifier ? $staticProp->name->toString() : $staticProp->name; - $tmp->var = new \PhpParser\Node\Expr\Variable($name, $staticProp->name->getAttributes()); - return new \PhpParser\Node\Expr\StaticCall($staticProp->class, $prop, $args, $attributes); + $name = $staticProp->name instanceof VarLikeIdentifier ? $staticProp->name->toString() : $staticProp->name; + $tmp->var = new Expr\Variable($name, $staticProp->name->getAttributes()); + return new Expr\StaticCall($staticProp->class, $prop, $args, $attributes); } else { throw new \Exception(); } @@ -555,7 +555,7 @@ abstract class ParserAbstract implements \PhpParser\Parser } } } - protected function handleBuiltinTypes(\PhpParser\Node\Name $name) + protected function handleBuiltinTypes(Name $name) { $builtinTypes = ['bool' => \true, 'int' => \true, 'float' => \true, 'string' => \true, 'iterable' => \true, 'void' => \true, 'object' => \true, 'null' => \true, 'false' => \true, 'mixed' => \true, 'never' => \true]; if (!$name->isUnqualified()) { @@ -582,21 +582,21 @@ abstract class ParserAbstract implements \PhpParser\Parser { $cast = \strtolower($cast); if (\strpos($cast, 'float') !== \false) { - return \PhpParser\Node\Expr\Cast\Double::KIND_FLOAT; + return Double::KIND_FLOAT; } if (\strpos($cast, 'real') !== \false) { - return \PhpParser\Node\Expr\Cast\Double::KIND_REAL; + return Double::KIND_REAL; } - return \PhpParser\Node\Expr\Cast\Double::KIND_DOUBLE; + return Double::KIND_DOUBLE; } protected function parseLNumber($str, $attributes, $allowInvalidOctal = \false) { try { - return \PhpParser\Node\Scalar\LNumber::fromString($str, $attributes, $allowInvalidOctal); + return LNumber::fromString($str, $attributes, $allowInvalidOctal); } catch (\PhpParser\Error $error) { $this->emitError($error); // Use dummy value - return new \PhpParser\Node\Scalar\LNumber(0, $attributes); + return new LNumber(0, $attributes); } } /** @@ -610,13 +610,13 @@ abstract class ParserAbstract implements \PhpParser\Parser protected function parseNumString(string $str, array $attributes) { if (!\preg_match('/^(?:0|-?[1-9][0-9]*)$/', $str)) { - return new \PhpParser\Node\Scalar\String_($str, $attributes); + return new String_($str, $attributes); } $num = +$str; if (!\is_int($num)) { - return new \PhpParser\Node\Scalar\String_($str, $attributes); + return new String_($str, $attributes); } - return new \PhpParser\Node\Scalar\LNumber($num, $attributes); + return new LNumber($num, $attributes); } protected function stripIndentation(string $string, int $indentLen, string $indentChar, bool $newlineAtStart, bool $newlineAtEnd, array $attributes) { @@ -638,7 +638,7 @@ abstract class ParserAbstract implements \PhpParser\Parser } protected function parseDocString(string $startToken, $contents, string $endToken, array $attributes, array $endTokenAttributes, bool $parseUnicodeEscape) { - $kind = \strpos($startToken, "'") === \false ? \PhpParser\Node\Scalar\String_::KIND_HEREDOC : \PhpParser\Node\Scalar\String_::KIND_NOWDOC; + $kind = \strpos($startToken, "'") === \false ? String_::KIND_HEREDOC : String_::KIND_NOWDOC; $regex = '/\\A[bB]?<<<[ \\t]*[\'"]?([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)[\'"]?(?:\\r\\n|\\n|\\r)\\z/'; $result = \preg_match($regex, $startToken, $matches); \assert($result === 1); @@ -660,14 +660,14 @@ abstract class ParserAbstract implements \PhpParser\Parser $indentChar = $indentHasSpaces ? " " : "\t"; if (\is_string($contents)) { if ($contents === '') { - return new \PhpParser\Node\Scalar\String_('', $attributes); + return new String_('', $attributes); } $contents = $this->stripIndentation($contents, $indentLen, $indentChar, \true, \true, $attributes); $contents = \preg_replace('~(\\r\\n|\\n|\\r)\\z~', '', $contents); - if ($kind === \PhpParser\Node\Scalar\String_::KIND_HEREDOC) { - $contents = \PhpParser\Node\Scalar\String_::parseEscapeSequences($contents, null, $parseUnicodeEscape); + if ($kind === String_::KIND_HEREDOC) { + $contents = String_::parseEscapeSequences($contents, null, $parseUnicodeEscape); } - return new \PhpParser\Node\Scalar\String_($contents, $attributes); + return new String_($contents, $attributes); } else { \assert(\count($contents) > 0); if (!$contents[0] instanceof \PhpParser\Node\Scalar\EncapsedStringPart) { @@ -679,7 +679,7 @@ abstract class ParserAbstract implements \PhpParser\Parser if ($part instanceof \PhpParser\Node\Scalar\EncapsedStringPart) { $isLast = $i === \count($contents) - 1; $part->value = $this->stripIndentation($part->value, $indentLen, $indentChar, $i === 0, $isLast, $part->getAttributes()); - $part->value = \PhpParser\Node\Scalar\String_::parseEscapeSequences($part->value, null, $parseUnicodeEscape); + $part->value = String_::parseEscapeSequences($part->value, null, $parseUnicodeEscape); if ($isLast) { $part->value = \preg_replace('~(\\r\\n|\\n|\\r)\\z~', '', $part->value); } @@ -689,7 +689,7 @@ abstract class ParserAbstract implements \PhpParser\Parser } $newContents[] = $part; } - return new \PhpParser\Node\Scalar\Encapsed($newContents, $attributes); + return new Encapsed($newContents, $attributes); } } /** @@ -722,7 +722,7 @@ abstract class ParserAbstract implements \PhpParser\Parser protected function checkClassModifier($a, $b, $modifierPos) { try { - \PhpParser\Node\Stmt\Class_::verifyClassModifier($a, $b); + Class_::verifyClassModifier($a, $b); } catch (\PhpParser\Error $error) { $error->setAttributes($this->getAttributesAt($modifierPos)); $this->emitError($error); @@ -732,29 +732,29 @@ abstract class ParserAbstract implements \PhpParser\Parser { // Jumping through some hoops here because verifyModifier() is also used elsewhere try { - \PhpParser\Node\Stmt\Class_::verifyModifier($a, $b); + Class_::verifyModifier($a, $b); } catch (\PhpParser\Error $error) { $error->setAttributes($this->getAttributesAt($modifierPos)); $this->emitError($error); } } - protected function checkParam(\PhpParser\Node\Param $node) + protected function checkParam(Param $node) { if ($node->variadic && null !== $node->default) { $this->emitError(new \PhpParser\Error('Variadic parameter cannot have a default value', $node->default->getAttributes())); } } - protected function checkTryCatch(\PhpParser\Node\Stmt\TryCatch $node) + protected function checkTryCatch(TryCatch $node) { if (empty($node->catches) && null === $node->finally) { $this->emitError(new \PhpParser\Error('Cannot use try without catch or finally', $node->getAttributes())); } } - protected function checkNamespace(\PhpParser\Node\Stmt\Namespace_ $node) + protected function checkNamespace(Namespace_ $node) { if (null !== $node->stmts) { foreach ($node->stmts as $stmt) { - if ($stmt instanceof \PhpParser\Node\Stmt\Namespace_) { + if ($stmt instanceof Namespace_) { $this->emitError(new \PhpParser\Error('Namespace declarations cannot be nested', $stmt->getAttributes())); } } @@ -774,7 +774,7 @@ abstract class ParserAbstract implements \PhpParser\Parser } } } - protected function checkClass(\PhpParser\Node\Stmt\Class_ $node, $namePos) + protected function checkClass(Class_ $node, $namePos) { $this->checkClassName($node->name, $namePos); if ($node->extends && $node->extends->isSpecialClassName()) { @@ -782,19 +782,19 @@ abstract class ParserAbstract implements \PhpParser\Parser } $this->checkImplementedInterfaces($node->implements); } - protected function checkInterface(\PhpParser\Node\Stmt\Interface_ $node, $namePos) + protected function checkInterface(Interface_ $node, $namePos) { $this->checkClassName($node->name, $namePos); $this->checkImplementedInterfaces($node->extends); } - protected function checkEnum(\PhpParser\Node\Stmt\Enum_ $node, $namePos) + protected function checkEnum(Enum_ $node, $namePos) { $this->checkClassName($node->name, $namePos); $this->checkImplementedInterfaces($node->implements); } - protected function checkClassMethod(\PhpParser\Node\Stmt\ClassMethod $node, $modifierPos) + protected function checkClassMethod(ClassMethod $node, $modifierPos) { - if ($node->flags & \PhpParser\Node\Stmt\Class_::MODIFIER_STATIC) { + if ($node->flags & Class_::MODIFIER_STATIC) { switch ($node->name->toLowerString()) { case '__construct': $this->emitError(new \PhpParser\Error(\sprintf('Constructor %s() cannot be static', $node->name), $this->getAttributesAt($modifierPos))); @@ -807,32 +807,32 @@ abstract class ParserAbstract implements \PhpParser\Parser break; } } - if ($node->flags & \PhpParser\Node\Stmt\Class_::MODIFIER_READONLY) { + if ($node->flags & Class_::MODIFIER_READONLY) { $this->emitError(new \PhpParser\Error(\sprintf('Method %s() cannot be readonly', $node->name), $this->getAttributesAt($modifierPos))); } } - protected function checkClassConst(\PhpParser\Node\Stmt\ClassConst $node, $modifierPos) + protected function checkClassConst(ClassConst $node, $modifierPos) { - if ($node->flags & \PhpParser\Node\Stmt\Class_::MODIFIER_STATIC) { + if ($node->flags & Class_::MODIFIER_STATIC) { $this->emitError(new \PhpParser\Error("Cannot use 'static' as constant modifier", $this->getAttributesAt($modifierPos))); } - if ($node->flags & \PhpParser\Node\Stmt\Class_::MODIFIER_ABSTRACT) { + if ($node->flags & Class_::MODIFIER_ABSTRACT) { $this->emitError(new \PhpParser\Error("Cannot use 'abstract' as constant modifier", $this->getAttributesAt($modifierPos))); } - if ($node->flags & \PhpParser\Node\Stmt\Class_::MODIFIER_READONLY) { + if ($node->flags & Class_::MODIFIER_READONLY) { $this->emitError(new \PhpParser\Error("Cannot use 'readonly' as constant modifier", $this->getAttributesAt($modifierPos))); } } - protected function checkProperty(\PhpParser\Node\Stmt\Property $node, $modifierPos) + protected function checkProperty(Property $node, $modifierPos) { - if ($node->flags & \PhpParser\Node\Stmt\Class_::MODIFIER_ABSTRACT) { + if ($node->flags & Class_::MODIFIER_ABSTRACT) { $this->emitError(new \PhpParser\Error('Properties cannot be declared abstract', $this->getAttributesAt($modifierPos))); } - if ($node->flags & \PhpParser\Node\Stmt\Class_::MODIFIER_FINAL) { + if ($node->flags & Class_::MODIFIER_FINAL) { $this->emitError(new \PhpParser\Error('Properties cannot be declared final', $this->getAttributesAt($modifierPos))); } } - protected function checkUseUse(\PhpParser\Node\Stmt\UseUse $node, $namePos) + protected function checkUseUse(UseUse $node, $namePos) { if ($node->alias && $node->alias->isSpecialClassName()) { $this->emitError(new \PhpParser\Error(\sprintf('Cannot use %s as %s because \'%2$s\' is a special class name', $node->name, $node->alias), $this->getAttributesAt($namePos))); diff --git a/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php b/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php index e731cf01af7..030f4086926 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php +++ b/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php @@ -13,105 +13,105 @@ use PhpParser\Node\Scalar; use PhpParser\Node\Scalar\MagicConst; use PhpParser\Node\Stmt; use PhpParser\PrettyPrinterAbstract; -class Standard extends \PhpParser\PrettyPrinterAbstract +class Standard extends PrettyPrinterAbstract { // Special nodes - protected function pParam(\PhpParser\Node\Param $node) + protected function pParam(Node\Param $node) { return $this->pAttrGroups($node->attrGroups, \true) . $this->pModifiers($node->flags) . ($node->type ? $this->p($node->type) . ' ' : '') . ($node->byRef ? '&' : '') . ($node->variadic ? '...' : '') . $this->p($node->var) . ($node->default ? ' = ' . $this->p($node->default) : ''); } - protected function pArg(\PhpParser\Node\Arg $node) + protected function pArg(Node\Arg $node) { return ($node->name ? $node->name->toString() . ': ' : '') . ($node->byRef ? '&' : '') . ($node->unpack ? '...' : '') . $this->p($node->value); } - protected function pVariadicPlaceholder(\PhpParser\Node\VariadicPlaceholder $node) + protected function pVariadicPlaceholder(Node\VariadicPlaceholder $node) { return '...'; } - protected function pConst(\PhpParser\Node\Const_ $node) + protected function pConst(Node\Const_ $node) { return $node->name . ' = ' . $this->p($node->value); } - protected function pNullableType(\PhpParser\Node\NullableType $node) + protected function pNullableType(Node\NullableType $node) { return '?' . $this->p($node->type); } - protected function pUnionType(\PhpParser\Node\UnionType $node) + protected function pUnionType(Node\UnionType $node) { return $this->pImplode($node->types, '|'); } - protected function pIntersectionType(\PhpParser\Node\IntersectionType $node) + protected function pIntersectionType(Node\IntersectionType $node) { return $this->pImplode($node->types, '&'); } - protected function pIdentifier(\PhpParser\Node\Identifier $node) + protected function pIdentifier(Node\Identifier $node) { return $node->name; } - protected function pVarLikeIdentifier(\PhpParser\Node\VarLikeIdentifier $node) + protected function pVarLikeIdentifier(Node\VarLikeIdentifier $node) { return '$' . $node->name; } - protected function pAttribute(\PhpParser\Node\Attribute $node) + protected function pAttribute(Node\Attribute $node) { return $this->p($node->name) . ($node->args ? '(' . $this->pCommaSeparated($node->args) . ')' : ''); } - protected function pAttributeGroup(\PhpParser\Node\AttributeGroup $node) + protected function pAttributeGroup(Node\AttributeGroup $node) { return '#[' . $this->pCommaSeparated($node->attrs) . ']'; } // Names - protected function pName(\PhpParser\Node\Name $node) + protected function pName(Name $node) { return \implode('\\', $node->parts); } - protected function pName_FullyQualified(\PhpParser\Node\Name\FullyQualified $node) + protected function pName_FullyQualified(Name\FullyQualified $node) { return '\\' . \implode('\\', $node->parts); } - protected function pName_Relative(\PhpParser\Node\Name\Relative $node) + protected function pName_Relative(Name\Relative $node) { return 'namespace\\' . \implode('\\', $node->parts); } // Magic Constants - protected function pScalar_MagicConst_Class(\PhpParser\Node\Scalar\MagicConst\Class_ $node) + protected function pScalar_MagicConst_Class(MagicConst\Class_ $node) { return '__CLASS__'; } - protected function pScalar_MagicConst_Dir(\PhpParser\Node\Scalar\MagicConst\Dir $node) + protected function pScalar_MagicConst_Dir(MagicConst\Dir $node) { return '__DIR__'; } - protected function pScalar_MagicConst_File(\PhpParser\Node\Scalar\MagicConst\File $node) + protected function pScalar_MagicConst_File(MagicConst\File $node) { return '__FILE__'; } - protected function pScalar_MagicConst_Function(\PhpParser\Node\Scalar\MagicConst\Function_ $node) + protected function pScalar_MagicConst_Function(MagicConst\Function_ $node) { return '__FUNCTION__'; } - protected function pScalar_MagicConst_Line(\PhpParser\Node\Scalar\MagicConst\Line $node) + protected function pScalar_MagicConst_Line(MagicConst\Line $node) { return '__LINE__'; } - protected function pScalar_MagicConst_Method(\PhpParser\Node\Scalar\MagicConst\Method $node) + protected function pScalar_MagicConst_Method(MagicConst\Method $node) { return '__METHOD__'; } - protected function pScalar_MagicConst_Namespace(\PhpParser\Node\Scalar\MagicConst\Namespace_ $node) + protected function pScalar_MagicConst_Namespace(MagicConst\Namespace_ $node) { return '__NAMESPACE__'; } - protected function pScalar_MagicConst_Trait(\PhpParser\Node\Scalar\MagicConst\Trait_ $node) + protected function pScalar_MagicConst_Trait(MagicConst\Trait_ $node) { return '__TRAIT__'; } // Scalars - protected function pScalar_String(\PhpParser\Node\Scalar\String_ $node) + protected function pScalar_String(Scalar\String_ $node) { - $kind = $node->getAttribute('kind', \PhpParser\Node\Scalar\String_::KIND_SINGLE_QUOTED); + $kind = $node->getAttribute('kind', Scalar\String_::KIND_SINGLE_QUOTED); switch ($kind) { - case \PhpParser\Node\Scalar\String_::KIND_NOWDOC: + case Scalar\String_::KIND_NOWDOC: $label = $node->getAttribute('docLabel'); if ($label && !$this->containsEndLabel($node->value, $label)) { if ($node->value === '') { @@ -120,9 +120,9 @@ class Standard extends \PhpParser\PrettyPrinterAbstract return "<<<'{$label}'\n{$node->value}\n{$label}" . $this->docStringEndToken; } /* break missing intentionally */ - case \PhpParser\Node\Scalar\String_::KIND_SINGLE_QUOTED: + case Scalar\String_::KIND_SINGLE_QUOTED: return $this->pSingleQuotedString($node->value); - case \PhpParser\Node\Scalar\String_::KIND_HEREDOC: + case Scalar\String_::KIND_HEREDOC: $label = $node->getAttribute('docLabel'); if ($label && !$this->containsEndLabel($node->value, $label)) { if ($node->value === '') { @@ -132,17 +132,17 @@ class Standard extends \PhpParser\PrettyPrinterAbstract return "<<<{$label}\n" . $escaped . "\n{$label}" . $this->docStringEndToken; } /* break missing intentionally */ - case \PhpParser\Node\Scalar\String_::KIND_DOUBLE_QUOTED: + case Scalar\String_::KIND_DOUBLE_QUOTED: return '"' . $this->escapeString($node->value, '"') . '"'; } throw new \Exception('Invalid string kind'); } - protected function pScalar_Encapsed(\PhpParser\Node\Scalar\Encapsed $node) + protected function pScalar_Encapsed(Scalar\Encapsed $node) { - if ($node->getAttribute('kind') === \PhpParser\Node\Scalar\String_::KIND_HEREDOC) { + if ($node->getAttribute('kind') === Scalar\String_::KIND_HEREDOC) { $label = $node->getAttribute('docLabel'); if ($label && !$this->encapsedContainsEndLabel($node->parts, $label)) { - if (\count($node->parts) === 1 && $node->parts[0] instanceof \PhpParser\Node\Scalar\EncapsedStringPart && $node->parts[0]->value === '') { + if (\count($node->parts) === 1 && $node->parts[0] instanceof Scalar\EncapsedStringPart && $node->parts[0]->value === '') { return "<<<{$label}\n{$label}" . $this->docStringEndToken; } return "<<<{$label}\n" . $this->pEncapsList($node->parts, null) . "\n{$label}" . $this->docStringEndToken; @@ -150,15 +150,15 @@ class Standard extends \PhpParser\PrettyPrinterAbstract } return '"' . $this->pEncapsList($node->parts, '"') . '"'; } - protected function pScalar_LNumber(\PhpParser\Node\Scalar\LNumber $node) + protected function pScalar_LNumber(Scalar\LNumber $node) { if ($node->value === -\PHP_INT_MAX - 1) { // PHP_INT_MIN cannot be represented as a literal, // because the sign is not part of the literal return '(-' . \PHP_INT_MAX . '-1)'; } - $kind = $node->getAttribute('kind', \PhpParser\Node\Scalar\LNumber::KIND_DEC); - if (\PhpParser\Node\Scalar\LNumber::KIND_DEC === $kind) { + $kind = $node->getAttribute('kind', Scalar\LNumber::KIND_DEC); + if (Scalar\LNumber::KIND_DEC === $kind) { return (string) $node->value; } if ($node->value < 0) { @@ -169,16 +169,16 @@ class Standard extends \PhpParser\PrettyPrinterAbstract $str = (string) $node->value; } switch ($kind) { - case \PhpParser\Node\Scalar\LNumber::KIND_BIN: + case Scalar\LNumber::KIND_BIN: return $sign . '0b' . \base_convert($str, 10, 2); - case \PhpParser\Node\Scalar\LNumber::KIND_OCT: + case Scalar\LNumber::KIND_OCT: return $sign . '0' . \base_convert($str, 10, 8); - case \PhpParser\Node\Scalar\LNumber::KIND_HEX: + case Scalar\LNumber::KIND_HEX: return $sign . '0x' . \base_convert($str, 10, 16); } throw new \Exception('Invalid number kind'); } - protected function pScalar_DNumber(\PhpParser\Node\Scalar\DNumber $node) + protected function pScalar_DNumber(Scalar\DNumber $node) { if (!\is_finite($node->value)) { if ($node->value === \INF) { @@ -201,415 +201,415 @@ class Standard extends \PhpParser\PrettyPrinterAbstract // ensure that number is really printed as float return \preg_match('/^-?[0-9]+$/', $stringValue) ? $stringValue . '.0' : $stringValue; } - protected function pScalar_EncapsedStringPart(\PhpParser\Node\Scalar\EncapsedStringPart $node) + protected function pScalar_EncapsedStringPart(Scalar\EncapsedStringPart $node) { throw new \LogicException('Cannot directly print EncapsedStringPart'); } // Assignments - protected function pExpr_Assign(\PhpParser\Node\Expr\Assign $node) + protected function pExpr_Assign(Expr\Assign $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\Assign::class, $node->var, ' = ', $node->expr); + return $this->pInfixOp(Expr\Assign::class, $node->var, ' = ', $node->expr); } - protected function pExpr_AssignRef(\PhpParser\Node\Expr\AssignRef $node) + protected function pExpr_AssignRef(Expr\AssignRef $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\AssignRef::class, $node->var, ' =& ', $node->expr); + return $this->pInfixOp(Expr\AssignRef::class, $node->var, ' =& ', $node->expr); } - protected function pExpr_AssignOp_Plus(\PhpParser\Node\Expr\AssignOp\Plus $node) + protected function pExpr_AssignOp_Plus(AssignOp\Plus $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\AssignOp\Plus::class, $node->var, ' += ', $node->expr); + return $this->pInfixOp(AssignOp\Plus::class, $node->var, ' += ', $node->expr); } - protected function pExpr_AssignOp_Minus(\PhpParser\Node\Expr\AssignOp\Minus $node) + protected function pExpr_AssignOp_Minus(AssignOp\Minus $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\AssignOp\Minus::class, $node->var, ' -= ', $node->expr); + return $this->pInfixOp(AssignOp\Minus::class, $node->var, ' -= ', $node->expr); } - protected function pExpr_AssignOp_Mul(\PhpParser\Node\Expr\AssignOp\Mul $node) + protected function pExpr_AssignOp_Mul(AssignOp\Mul $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\AssignOp\Mul::class, $node->var, ' *= ', $node->expr); + return $this->pInfixOp(AssignOp\Mul::class, $node->var, ' *= ', $node->expr); } - protected function pExpr_AssignOp_Div(\PhpParser\Node\Expr\AssignOp\Div $node) + protected function pExpr_AssignOp_Div(AssignOp\Div $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\AssignOp\Div::class, $node->var, ' /= ', $node->expr); + return $this->pInfixOp(AssignOp\Div::class, $node->var, ' /= ', $node->expr); } - protected function pExpr_AssignOp_Concat(\PhpParser\Node\Expr\AssignOp\Concat $node) + protected function pExpr_AssignOp_Concat(AssignOp\Concat $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\AssignOp\Concat::class, $node->var, ' .= ', $node->expr); + return $this->pInfixOp(AssignOp\Concat::class, $node->var, ' .= ', $node->expr); } - protected function pExpr_AssignOp_Mod(\PhpParser\Node\Expr\AssignOp\Mod $node) + protected function pExpr_AssignOp_Mod(AssignOp\Mod $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\AssignOp\Mod::class, $node->var, ' %= ', $node->expr); + return $this->pInfixOp(AssignOp\Mod::class, $node->var, ' %= ', $node->expr); } - protected function pExpr_AssignOp_BitwiseAnd(\PhpParser\Node\Expr\AssignOp\BitwiseAnd $node) + protected function pExpr_AssignOp_BitwiseAnd(AssignOp\BitwiseAnd $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\AssignOp\BitwiseAnd::class, $node->var, ' &= ', $node->expr); + return $this->pInfixOp(AssignOp\BitwiseAnd::class, $node->var, ' &= ', $node->expr); } - protected function pExpr_AssignOp_BitwiseOr(\PhpParser\Node\Expr\AssignOp\BitwiseOr $node) + protected function pExpr_AssignOp_BitwiseOr(AssignOp\BitwiseOr $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\AssignOp\BitwiseOr::class, $node->var, ' |= ', $node->expr); + return $this->pInfixOp(AssignOp\BitwiseOr::class, $node->var, ' |= ', $node->expr); } - protected function pExpr_AssignOp_BitwiseXor(\PhpParser\Node\Expr\AssignOp\BitwiseXor $node) + protected function pExpr_AssignOp_BitwiseXor(AssignOp\BitwiseXor $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\AssignOp\BitwiseXor::class, $node->var, ' ^= ', $node->expr); + return $this->pInfixOp(AssignOp\BitwiseXor::class, $node->var, ' ^= ', $node->expr); } - protected function pExpr_AssignOp_ShiftLeft(\PhpParser\Node\Expr\AssignOp\ShiftLeft $node) + protected function pExpr_AssignOp_ShiftLeft(AssignOp\ShiftLeft $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\AssignOp\ShiftLeft::class, $node->var, ' <<= ', $node->expr); + return $this->pInfixOp(AssignOp\ShiftLeft::class, $node->var, ' <<= ', $node->expr); } - protected function pExpr_AssignOp_ShiftRight(\PhpParser\Node\Expr\AssignOp\ShiftRight $node) + protected function pExpr_AssignOp_ShiftRight(AssignOp\ShiftRight $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\AssignOp\ShiftRight::class, $node->var, ' >>= ', $node->expr); + return $this->pInfixOp(AssignOp\ShiftRight::class, $node->var, ' >>= ', $node->expr); } - protected function pExpr_AssignOp_Pow(\PhpParser\Node\Expr\AssignOp\Pow $node) + protected function pExpr_AssignOp_Pow(AssignOp\Pow $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\AssignOp\Pow::class, $node->var, ' **= ', $node->expr); + return $this->pInfixOp(AssignOp\Pow::class, $node->var, ' **= ', $node->expr); } - protected function pExpr_AssignOp_Coalesce(\PhpParser\Node\Expr\AssignOp\Coalesce $node) + protected function pExpr_AssignOp_Coalesce(AssignOp\Coalesce $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\AssignOp\Coalesce::class, $node->var, ' ??= ', $node->expr); + return $this->pInfixOp(AssignOp\Coalesce::class, $node->var, ' ??= ', $node->expr); } // Binary expressions - protected function pExpr_BinaryOp_Plus(\PhpParser\Node\Expr\BinaryOp\Plus $node) + protected function pExpr_BinaryOp_Plus(BinaryOp\Plus $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\Plus::class, $node->left, ' + ', $node->right); + return $this->pInfixOp(BinaryOp\Plus::class, $node->left, ' + ', $node->right); } - protected function pExpr_BinaryOp_Minus(\PhpParser\Node\Expr\BinaryOp\Minus $node) + protected function pExpr_BinaryOp_Minus(BinaryOp\Minus $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\Minus::class, $node->left, ' - ', $node->right); + return $this->pInfixOp(BinaryOp\Minus::class, $node->left, ' - ', $node->right); } - protected function pExpr_BinaryOp_Mul(\PhpParser\Node\Expr\BinaryOp\Mul $node) + protected function pExpr_BinaryOp_Mul(BinaryOp\Mul $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\Mul::class, $node->left, ' * ', $node->right); + return $this->pInfixOp(BinaryOp\Mul::class, $node->left, ' * ', $node->right); } - protected function pExpr_BinaryOp_Div(\PhpParser\Node\Expr\BinaryOp\Div $node) + protected function pExpr_BinaryOp_Div(BinaryOp\Div $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\Div::class, $node->left, ' / ', $node->right); + return $this->pInfixOp(BinaryOp\Div::class, $node->left, ' / ', $node->right); } - protected function pExpr_BinaryOp_Concat(\PhpParser\Node\Expr\BinaryOp\Concat $node) + protected function pExpr_BinaryOp_Concat(BinaryOp\Concat $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\Concat::class, $node->left, ' . ', $node->right); + return $this->pInfixOp(BinaryOp\Concat::class, $node->left, ' . ', $node->right); } - protected function pExpr_BinaryOp_Mod(\PhpParser\Node\Expr\BinaryOp\Mod $node) + protected function pExpr_BinaryOp_Mod(BinaryOp\Mod $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\Mod::class, $node->left, ' % ', $node->right); + return $this->pInfixOp(BinaryOp\Mod::class, $node->left, ' % ', $node->right); } - protected function pExpr_BinaryOp_BooleanAnd(\PhpParser\Node\Expr\BinaryOp\BooleanAnd $node) + protected function pExpr_BinaryOp_BooleanAnd(BinaryOp\BooleanAnd $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\BooleanAnd::class, $node->left, ' && ', $node->right); + return $this->pInfixOp(BinaryOp\BooleanAnd::class, $node->left, ' && ', $node->right); } - protected function pExpr_BinaryOp_BooleanOr(\PhpParser\Node\Expr\BinaryOp\BooleanOr $node) + protected function pExpr_BinaryOp_BooleanOr(BinaryOp\BooleanOr $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\BooleanOr::class, $node->left, ' || ', $node->right); + return $this->pInfixOp(BinaryOp\BooleanOr::class, $node->left, ' || ', $node->right); } - protected function pExpr_BinaryOp_BitwiseAnd(\PhpParser\Node\Expr\BinaryOp\BitwiseAnd $node) + protected function pExpr_BinaryOp_BitwiseAnd(BinaryOp\BitwiseAnd $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\BitwiseAnd::class, $node->left, ' & ', $node->right); + return $this->pInfixOp(BinaryOp\BitwiseAnd::class, $node->left, ' & ', $node->right); } - protected function pExpr_BinaryOp_BitwiseOr(\PhpParser\Node\Expr\BinaryOp\BitwiseOr $node) + protected function pExpr_BinaryOp_BitwiseOr(BinaryOp\BitwiseOr $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\BitwiseOr::class, $node->left, ' | ', $node->right); + return $this->pInfixOp(BinaryOp\BitwiseOr::class, $node->left, ' | ', $node->right); } - protected function pExpr_BinaryOp_BitwiseXor(\PhpParser\Node\Expr\BinaryOp\BitwiseXor $node) + protected function pExpr_BinaryOp_BitwiseXor(BinaryOp\BitwiseXor $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\BitwiseXor::class, $node->left, ' ^ ', $node->right); + return $this->pInfixOp(BinaryOp\BitwiseXor::class, $node->left, ' ^ ', $node->right); } - protected function pExpr_BinaryOp_ShiftLeft(\PhpParser\Node\Expr\BinaryOp\ShiftLeft $node) + protected function pExpr_BinaryOp_ShiftLeft(BinaryOp\ShiftLeft $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\ShiftLeft::class, $node->left, ' << ', $node->right); + return $this->pInfixOp(BinaryOp\ShiftLeft::class, $node->left, ' << ', $node->right); } - protected function pExpr_BinaryOp_ShiftRight(\PhpParser\Node\Expr\BinaryOp\ShiftRight $node) + protected function pExpr_BinaryOp_ShiftRight(BinaryOp\ShiftRight $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\ShiftRight::class, $node->left, ' >> ', $node->right); + return $this->pInfixOp(BinaryOp\ShiftRight::class, $node->left, ' >> ', $node->right); } - protected function pExpr_BinaryOp_Pow(\PhpParser\Node\Expr\BinaryOp\Pow $node) + protected function pExpr_BinaryOp_Pow(BinaryOp\Pow $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\Pow::class, $node->left, ' ** ', $node->right); + return $this->pInfixOp(BinaryOp\Pow::class, $node->left, ' ** ', $node->right); } - protected function pExpr_BinaryOp_LogicalAnd(\PhpParser\Node\Expr\BinaryOp\LogicalAnd $node) + protected function pExpr_BinaryOp_LogicalAnd(BinaryOp\LogicalAnd $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\LogicalAnd::class, $node->left, ' and ', $node->right); + return $this->pInfixOp(BinaryOp\LogicalAnd::class, $node->left, ' and ', $node->right); } - protected function pExpr_BinaryOp_LogicalOr(\PhpParser\Node\Expr\BinaryOp\LogicalOr $node) + protected function pExpr_BinaryOp_LogicalOr(BinaryOp\LogicalOr $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\LogicalOr::class, $node->left, ' or ', $node->right); + return $this->pInfixOp(BinaryOp\LogicalOr::class, $node->left, ' or ', $node->right); } - protected function pExpr_BinaryOp_LogicalXor(\PhpParser\Node\Expr\BinaryOp\LogicalXor $node) + protected function pExpr_BinaryOp_LogicalXor(BinaryOp\LogicalXor $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\LogicalXor::class, $node->left, ' xor ', $node->right); + return $this->pInfixOp(BinaryOp\LogicalXor::class, $node->left, ' xor ', $node->right); } - protected function pExpr_BinaryOp_Equal(\PhpParser\Node\Expr\BinaryOp\Equal $node) + protected function pExpr_BinaryOp_Equal(BinaryOp\Equal $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\Equal::class, $node->left, ' == ', $node->right); + return $this->pInfixOp(BinaryOp\Equal::class, $node->left, ' == ', $node->right); } - protected function pExpr_BinaryOp_NotEqual(\PhpParser\Node\Expr\BinaryOp\NotEqual $node) + protected function pExpr_BinaryOp_NotEqual(BinaryOp\NotEqual $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\NotEqual::class, $node->left, ' != ', $node->right); + return $this->pInfixOp(BinaryOp\NotEqual::class, $node->left, ' != ', $node->right); } - protected function pExpr_BinaryOp_Identical(\PhpParser\Node\Expr\BinaryOp\Identical $node) + protected function pExpr_BinaryOp_Identical(BinaryOp\Identical $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\Identical::class, $node->left, ' === ', $node->right); + return $this->pInfixOp(BinaryOp\Identical::class, $node->left, ' === ', $node->right); } - protected function pExpr_BinaryOp_NotIdentical(\PhpParser\Node\Expr\BinaryOp\NotIdentical $node) + protected function pExpr_BinaryOp_NotIdentical(BinaryOp\NotIdentical $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\NotIdentical::class, $node->left, ' !== ', $node->right); + return $this->pInfixOp(BinaryOp\NotIdentical::class, $node->left, ' !== ', $node->right); } - protected function pExpr_BinaryOp_Spaceship(\PhpParser\Node\Expr\BinaryOp\Spaceship $node) + protected function pExpr_BinaryOp_Spaceship(BinaryOp\Spaceship $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\Spaceship::class, $node->left, ' <=> ', $node->right); + return $this->pInfixOp(BinaryOp\Spaceship::class, $node->left, ' <=> ', $node->right); } - protected function pExpr_BinaryOp_Greater(\PhpParser\Node\Expr\BinaryOp\Greater $node) + protected function pExpr_BinaryOp_Greater(BinaryOp\Greater $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\Greater::class, $node->left, ' > ', $node->right); + return $this->pInfixOp(BinaryOp\Greater::class, $node->left, ' > ', $node->right); } - protected function pExpr_BinaryOp_GreaterOrEqual(\PhpParser\Node\Expr\BinaryOp\GreaterOrEqual $node) + protected function pExpr_BinaryOp_GreaterOrEqual(BinaryOp\GreaterOrEqual $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\GreaterOrEqual::class, $node->left, ' >= ', $node->right); + return $this->pInfixOp(BinaryOp\GreaterOrEqual::class, $node->left, ' >= ', $node->right); } - protected function pExpr_BinaryOp_Smaller(\PhpParser\Node\Expr\BinaryOp\Smaller $node) + protected function pExpr_BinaryOp_Smaller(BinaryOp\Smaller $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\Smaller::class, $node->left, ' < ', $node->right); + return $this->pInfixOp(BinaryOp\Smaller::class, $node->left, ' < ', $node->right); } - protected function pExpr_BinaryOp_SmallerOrEqual(\PhpParser\Node\Expr\BinaryOp\SmallerOrEqual $node) + protected function pExpr_BinaryOp_SmallerOrEqual(BinaryOp\SmallerOrEqual $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\SmallerOrEqual::class, $node->left, ' <= ', $node->right); + return $this->pInfixOp(BinaryOp\SmallerOrEqual::class, $node->left, ' <= ', $node->right); } - protected function pExpr_BinaryOp_Coalesce(\PhpParser\Node\Expr\BinaryOp\Coalesce $node) + protected function pExpr_BinaryOp_Coalesce(BinaryOp\Coalesce $node) { - return $this->pInfixOp(\PhpParser\Node\Expr\BinaryOp\Coalesce::class, $node->left, ' ?? ', $node->right); + return $this->pInfixOp(BinaryOp\Coalesce::class, $node->left, ' ?? ', $node->right); } - protected function pExpr_Instanceof(\PhpParser\Node\Expr\Instanceof_ $node) + protected function pExpr_Instanceof(Expr\Instanceof_ $node) { - list($precedence, $associativity) = $this->precedenceMap[\PhpParser\Node\Expr\Instanceof_::class]; + list($precedence, $associativity) = $this->precedenceMap[Expr\Instanceof_::class]; return $this->pPrec($node->expr, $precedence, $associativity, -1) . ' instanceof ' . $this->pNewVariable($node->class); } // Unary expressions - protected function pExpr_BooleanNot(\PhpParser\Node\Expr\BooleanNot $node) + protected function pExpr_BooleanNot(Expr\BooleanNot $node) { - return $this->pPrefixOp(\PhpParser\Node\Expr\BooleanNot::class, '!', $node->expr); + return $this->pPrefixOp(Expr\BooleanNot::class, '!', $node->expr); } - protected function pExpr_BitwiseNot(\PhpParser\Node\Expr\BitwiseNot $node) + protected function pExpr_BitwiseNot(Expr\BitwiseNot $node) { - return $this->pPrefixOp(\PhpParser\Node\Expr\BitwiseNot::class, '~', $node->expr); + return $this->pPrefixOp(Expr\BitwiseNot::class, '~', $node->expr); } - protected function pExpr_UnaryMinus(\PhpParser\Node\Expr\UnaryMinus $node) + protected function pExpr_UnaryMinus(Expr\UnaryMinus $node) { - if ($node->expr instanceof \PhpParser\Node\Expr\UnaryMinus || $node->expr instanceof \PhpParser\Node\Expr\PreDec) { + if ($node->expr instanceof Expr\UnaryMinus || $node->expr instanceof Expr\PreDec) { // Enforce -(-$expr) instead of --$expr return '-(' . $this->p($node->expr) . ')'; } - return $this->pPrefixOp(\PhpParser\Node\Expr\UnaryMinus::class, '-', $node->expr); + return $this->pPrefixOp(Expr\UnaryMinus::class, '-', $node->expr); } - protected function pExpr_UnaryPlus(\PhpParser\Node\Expr\UnaryPlus $node) + protected function pExpr_UnaryPlus(Expr\UnaryPlus $node) { - if ($node->expr instanceof \PhpParser\Node\Expr\UnaryPlus || $node->expr instanceof \PhpParser\Node\Expr\PreInc) { + if ($node->expr instanceof Expr\UnaryPlus || $node->expr instanceof Expr\PreInc) { // Enforce +(+$expr) instead of ++$expr return '+(' . $this->p($node->expr) . ')'; } - return $this->pPrefixOp(\PhpParser\Node\Expr\UnaryPlus::class, '+', $node->expr); + return $this->pPrefixOp(Expr\UnaryPlus::class, '+', $node->expr); } - protected function pExpr_PreInc(\PhpParser\Node\Expr\PreInc $node) + protected function pExpr_PreInc(Expr\PreInc $node) { - return $this->pPrefixOp(\PhpParser\Node\Expr\PreInc::class, '++', $node->var); + return $this->pPrefixOp(Expr\PreInc::class, '++', $node->var); } - protected function pExpr_PreDec(\PhpParser\Node\Expr\PreDec $node) + protected function pExpr_PreDec(Expr\PreDec $node) { - return $this->pPrefixOp(\PhpParser\Node\Expr\PreDec::class, '--', $node->var); + return $this->pPrefixOp(Expr\PreDec::class, '--', $node->var); } - protected function pExpr_PostInc(\PhpParser\Node\Expr\PostInc $node) + protected function pExpr_PostInc(Expr\PostInc $node) { - return $this->pPostfixOp(\PhpParser\Node\Expr\PostInc::class, $node->var, '++'); + return $this->pPostfixOp(Expr\PostInc::class, $node->var, '++'); } - protected function pExpr_PostDec(\PhpParser\Node\Expr\PostDec $node) + protected function pExpr_PostDec(Expr\PostDec $node) { - return $this->pPostfixOp(\PhpParser\Node\Expr\PostDec::class, $node->var, '--'); + return $this->pPostfixOp(Expr\PostDec::class, $node->var, '--'); } - protected function pExpr_ErrorSuppress(\PhpParser\Node\Expr\ErrorSuppress $node) + protected function pExpr_ErrorSuppress(Expr\ErrorSuppress $node) { - return $this->pPrefixOp(\PhpParser\Node\Expr\ErrorSuppress::class, '@', $node->expr); + return $this->pPrefixOp(Expr\ErrorSuppress::class, '@', $node->expr); } - protected function pExpr_YieldFrom(\PhpParser\Node\Expr\YieldFrom $node) + protected function pExpr_YieldFrom(Expr\YieldFrom $node) { - return $this->pPrefixOp(\PhpParser\Node\Expr\YieldFrom::class, 'yield from ', $node->expr); + return $this->pPrefixOp(Expr\YieldFrom::class, 'yield from ', $node->expr); } - protected function pExpr_Print(\PhpParser\Node\Expr\Print_ $node) + protected function pExpr_Print(Expr\Print_ $node) { - return $this->pPrefixOp(\PhpParser\Node\Expr\Print_::class, 'print ', $node->expr); + return $this->pPrefixOp(Expr\Print_::class, 'print ', $node->expr); } // Casts - protected function pExpr_Cast_Int(\PhpParser\Node\Expr\Cast\Int_ $node) + protected function pExpr_Cast_Int(Cast\Int_ $node) { - return $this->pPrefixOp(\PhpParser\Node\Expr\Cast\Int_::class, '(int) ', $node->expr); + return $this->pPrefixOp(Cast\Int_::class, '(int) ', $node->expr); } - protected function pExpr_Cast_Double(\PhpParser\Node\Expr\Cast\Double $node) + protected function pExpr_Cast_Double(Cast\Double $node) { - $kind = $node->getAttribute('kind', \PhpParser\Node\Expr\Cast\Double::KIND_DOUBLE); - if ($kind === \PhpParser\Node\Expr\Cast\Double::KIND_DOUBLE) { + $kind = $node->getAttribute('kind', Cast\Double::KIND_DOUBLE); + if ($kind === Cast\Double::KIND_DOUBLE) { $cast = '(double)'; - } elseif ($kind === \PhpParser\Node\Expr\Cast\Double::KIND_FLOAT) { + } elseif ($kind === Cast\Double::KIND_FLOAT) { $cast = '(float)'; - } elseif ($kind === \PhpParser\Node\Expr\Cast\Double::KIND_REAL) { + } elseif ($kind === Cast\Double::KIND_REAL) { $cast = '(real)'; } - return $this->pPrefixOp(\PhpParser\Node\Expr\Cast\Double::class, $cast . ' ', $node->expr); + return $this->pPrefixOp(Cast\Double::class, $cast . ' ', $node->expr); } - protected function pExpr_Cast_String(\PhpParser\Node\Expr\Cast\String_ $node) + protected function pExpr_Cast_String(Cast\String_ $node) { - return $this->pPrefixOp(\PhpParser\Node\Expr\Cast\String_::class, '(string) ', $node->expr); + return $this->pPrefixOp(Cast\String_::class, '(string) ', $node->expr); } - protected function pExpr_Cast_Array(\PhpParser\Node\Expr\Cast\Array_ $node) + protected function pExpr_Cast_Array(Cast\Array_ $node) { - return $this->pPrefixOp(\PhpParser\Node\Expr\Cast\Array_::class, '(array) ', $node->expr); + return $this->pPrefixOp(Cast\Array_::class, '(array) ', $node->expr); } - protected function pExpr_Cast_Object(\PhpParser\Node\Expr\Cast\Object_ $node) + protected function pExpr_Cast_Object(Cast\Object_ $node) { - return $this->pPrefixOp(\PhpParser\Node\Expr\Cast\Object_::class, '(object) ', $node->expr); + return $this->pPrefixOp(Cast\Object_::class, '(object) ', $node->expr); } - protected function pExpr_Cast_Bool(\PhpParser\Node\Expr\Cast\Bool_ $node) + protected function pExpr_Cast_Bool(Cast\Bool_ $node) { - return $this->pPrefixOp(\PhpParser\Node\Expr\Cast\Bool_::class, '(bool) ', $node->expr); + return $this->pPrefixOp(Cast\Bool_::class, '(bool) ', $node->expr); } - protected function pExpr_Cast_Unset(\PhpParser\Node\Expr\Cast\Unset_ $node) + protected function pExpr_Cast_Unset(Cast\Unset_ $node) { - return $this->pPrefixOp(\PhpParser\Node\Expr\Cast\Unset_::class, '(unset) ', $node->expr); + return $this->pPrefixOp(Cast\Unset_::class, '(unset) ', $node->expr); } // Function calls and similar constructs - protected function pExpr_FuncCall(\PhpParser\Node\Expr\FuncCall $node) + protected function pExpr_FuncCall(Expr\FuncCall $node) { return $this->pCallLhs($node->name) . '(' . $this->pMaybeMultiline($node->args) . ')'; } - protected function pExpr_MethodCall(\PhpParser\Node\Expr\MethodCall $node) + protected function pExpr_MethodCall(Expr\MethodCall $node) { return $this->pDereferenceLhs($node->var) . '->' . $this->pObjectProperty($node->name) . '(' . $this->pMaybeMultiline($node->args) . ')'; } - protected function pExpr_NullsafeMethodCall(\PhpParser\Node\Expr\NullsafeMethodCall $node) + protected function pExpr_NullsafeMethodCall(Expr\NullsafeMethodCall $node) { return $this->pDereferenceLhs($node->var) . '?->' . $this->pObjectProperty($node->name) . '(' . $this->pMaybeMultiline($node->args) . ')'; } - protected function pExpr_StaticCall(\PhpParser\Node\Expr\StaticCall $node) + protected function pExpr_StaticCall(Expr\StaticCall $node) { - return $this->pDereferenceLhs($node->class) . '::' . ($node->name instanceof \PhpParser\Node\Expr ? $node->name instanceof \PhpParser\Node\Expr\Variable ? $this->p($node->name) : '{' . $this->p($node->name) . '}' : $node->name) . '(' . $this->pMaybeMultiline($node->args) . ')'; + return $this->pDereferenceLhs($node->class) . '::' . ($node->name instanceof Expr ? $node->name instanceof Expr\Variable ? $this->p($node->name) : '{' . $this->p($node->name) . '}' : $node->name) . '(' . $this->pMaybeMultiline($node->args) . ')'; } - protected function pExpr_Empty(\PhpParser\Node\Expr\Empty_ $node) + protected function pExpr_Empty(Expr\Empty_ $node) { return 'empty(' . $this->p($node->expr) . ')'; } - protected function pExpr_Isset(\PhpParser\Node\Expr\Isset_ $node) + protected function pExpr_Isset(Expr\Isset_ $node) { return 'isset(' . $this->pCommaSeparated($node->vars) . ')'; } - protected function pExpr_Eval(\PhpParser\Node\Expr\Eval_ $node) + protected function pExpr_Eval(Expr\Eval_ $node) { return 'eval(' . $this->p($node->expr) . ')'; } - protected function pExpr_Include(\PhpParser\Node\Expr\Include_ $node) + protected function pExpr_Include(Expr\Include_ $node) { - static $map = [\PhpParser\Node\Expr\Include_::TYPE_INCLUDE => 'include', \PhpParser\Node\Expr\Include_::TYPE_INCLUDE_ONCE => 'include_once', \PhpParser\Node\Expr\Include_::TYPE_REQUIRE => 'require', \PhpParser\Node\Expr\Include_::TYPE_REQUIRE_ONCE => 'require_once']; + static $map = [Expr\Include_::TYPE_INCLUDE => 'include', Expr\Include_::TYPE_INCLUDE_ONCE => 'include_once', Expr\Include_::TYPE_REQUIRE => 'require', Expr\Include_::TYPE_REQUIRE_ONCE => 'require_once']; return $map[$node->type] . ' ' . $this->p($node->expr); } - protected function pExpr_List(\PhpParser\Node\Expr\List_ $node) + protected function pExpr_List(Expr\List_ $node) { return 'list(' . $this->pCommaSeparated($node->items) . ')'; } // Other - protected function pExpr_Error(\PhpParser\Node\Expr\Error $node) + protected function pExpr_Error(Expr\Error $node) { throw new \LogicException('Cannot pretty-print AST with Error nodes'); } - protected function pExpr_Variable(\PhpParser\Node\Expr\Variable $node) + protected function pExpr_Variable(Expr\Variable $node) { - if ($node->name instanceof \PhpParser\Node\Expr) { + if ($node->name instanceof Expr) { return '${' . $this->p($node->name) . '}'; } else { return '$' . $node->name; } } - protected function pExpr_Array(\PhpParser\Node\Expr\Array_ $node) + protected function pExpr_Array(Expr\Array_ $node) { - $syntax = $node->getAttribute('kind', $this->options['shortArraySyntax'] ? \PhpParser\Node\Expr\Array_::KIND_SHORT : \PhpParser\Node\Expr\Array_::KIND_LONG); - if ($syntax === \PhpParser\Node\Expr\Array_::KIND_SHORT) { + $syntax = $node->getAttribute('kind', $this->options['shortArraySyntax'] ? Expr\Array_::KIND_SHORT : Expr\Array_::KIND_LONG); + if ($syntax === Expr\Array_::KIND_SHORT) { return '[' . $this->pMaybeMultiline($node->items, \true) . ']'; } else { return 'array(' . $this->pMaybeMultiline($node->items, \true) . ')'; } } - protected function pExpr_ArrayItem(\PhpParser\Node\Expr\ArrayItem $node) + protected function pExpr_ArrayItem(Expr\ArrayItem $node) { return (null !== $node->key ? $this->p($node->key) . ' => ' : '') . ($node->byRef ? '&' : '') . ($node->unpack ? '...' : '') . $this->p($node->value); } - protected function pExpr_ArrayDimFetch(\PhpParser\Node\Expr\ArrayDimFetch $node) + protected function pExpr_ArrayDimFetch(Expr\ArrayDimFetch $node) { return $this->pDereferenceLhs($node->var) . '[' . (null !== $node->dim ? $this->p($node->dim) : '') . ']'; } - protected function pExpr_ConstFetch(\PhpParser\Node\Expr\ConstFetch $node) + protected function pExpr_ConstFetch(Expr\ConstFetch $node) { return $this->p($node->name); } - protected function pExpr_ClassConstFetch(\PhpParser\Node\Expr\ClassConstFetch $node) + protected function pExpr_ClassConstFetch(Expr\ClassConstFetch $node) { return $this->pDereferenceLhs($node->class) . '::' . $this->p($node->name); } - protected function pExpr_PropertyFetch(\PhpParser\Node\Expr\PropertyFetch $node) + protected function pExpr_PropertyFetch(Expr\PropertyFetch $node) { return $this->pDereferenceLhs($node->var) . '->' . $this->pObjectProperty($node->name); } - protected function pExpr_NullsafePropertyFetch(\PhpParser\Node\Expr\NullsafePropertyFetch $node) + protected function pExpr_NullsafePropertyFetch(Expr\NullsafePropertyFetch $node) { return $this->pDereferenceLhs($node->var) . '?->' . $this->pObjectProperty($node->name); } - protected function pExpr_StaticPropertyFetch(\PhpParser\Node\Expr\StaticPropertyFetch $node) + protected function pExpr_StaticPropertyFetch(Expr\StaticPropertyFetch $node) { return $this->pDereferenceLhs($node->class) . '::$' . $this->pObjectProperty($node->name); } - protected function pExpr_ShellExec(\PhpParser\Node\Expr\ShellExec $node) + protected function pExpr_ShellExec(Expr\ShellExec $node) { return '`' . $this->pEncapsList($node->parts, '`') . '`'; } - protected function pExpr_Closure(\PhpParser\Node\Expr\Closure $node) + protected function pExpr_Closure(Expr\Closure $node) { return $this->pAttrGroups($node->attrGroups, \true) . ($node->static ? 'static ' : '') . 'function ' . ($node->byRef ? '&' : '') . '(' . $this->pCommaSeparated($node->params) . ')' . (!empty($node->uses) ? ' use(' . $this->pCommaSeparated($node->uses) . ')' : '') . (null !== $node->returnType ? ' : ' . $this->p($node->returnType) : '') . ' {' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pExpr_Match(\PhpParser\Node\Expr\Match_ $node) + protected function pExpr_Match(Expr\Match_ $node) { return 'match (' . $this->p($node->cond) . ') {' . $this->pCommaSeparatedMultiline($node->arms, \true) . $this->nl . '}'; } - protected function pMatchArm(\PhpParser\Node\MatchArm $node) + protected function pMatchArm(Node\MatchArm $node) { return ($node->conds ? $this->pCommaSeparated($node->conds) : 'default') . ' => ' . $this->p($node->body); } - protected function pExpr_ArrowFunction(\PhpParser\Node\Expr\ArrowFunction $node) + protected function pExpr_ArrowFunction(Expr\ArrowFunction $node) { return $this->pAttrGroups($node->attrGroups, \true) . ($node->static ? 'static ' : '') . 'fn' . ($node->byRef ? '&' : '') . '(' . $this->pCommaSeparated($node->params) . ')' . (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '') . ' => ' . $this->p($node->expr); } - protected function pExpr_ClosureUse(\PhpParser\Node\Expr\ClosureUse $node) + protected function pExpr_ClosureUse(Expr\ClosureUse $node) { return ($node->byRef ? '&' : '') . $this->p($node->var); } - protected function pExpr_New(\PhpParser\Node\Expr\New_ $node) + protected function pExpr_New(Expr\New_ $node) { - if ($node->class instanceof \PhpParser\Node\Stmt\Class_) { + if ($node->class instanceof Stmt\Class_) { $args = $node->args ? '(' . $this->pMaybeMultiline($node->args) . ')' : ''; return 'new ' . $this->pClassCommon($node->class, $args); } return 'new ' . $this->pNewVariable($node->class) . '(' . $this->pMaybeMultiline($node->args) . ')'; } - protected function pExpr_Clone(\PhpParser\Node\Expr\Clone_ $node) + protected function pExpr_Clone(Expr\Clone_ $node) { return 'clone ' . $this->p($node->expr); } - protected function pExpr_Ternary(\PhpParser\Node\Expr\Ternary $node) + protected function pExpr_Ternary(Expr\Ternary $node) { // a bit of cheating: we treat the ternary as a binary op where the ?...: part is the operator. // this is okay because the part between ? and : never needs parentheses. - return $this->pInfixOp(\PhpParser\Node\Expr\Ternary::class, $node->cond, ' ?' . (null !== $node->if ? ' ' . $this->p($node->if) . ' ' : '') . ': ', $node->else); + return $this->pInfixOp(Expr\Ternary::class, $node->cond, ' ?' . (null !== $node->if ? ' ' . $this->p($node->if) . ' ' : '') . ': ', $node->else); } - protected function pExpr_Exit(\PhpParser\Node\Expr\Exit_ $node) + protected function pExpr_Exit(Expr\Exit_ $node) { - $kind = $node->getAttribute('kind', \PhpParser\Node\Expr\Exit_::KIND_DIE); - return ($kind === \PhpParser\Node\Expr\Exit_::KIND_EXIT ? 'exit' : 'die') . (null !== $node->expr ? '(' . $this->p($node->expr) . ')' : ''); + $kind = $node->getAttribute('kind', Expr\Exit_::KIND_DIE); + return ($kind === Expr\Exit_::KIND_EXIT ? 'exit' : 'die') . (null !== $node->expr ? '(' . $this->p($node->expr) . ')' : ''); } - protected function pExpr_Throw(\PhpParser\Node\Expr\Throw_ $node) + protected function pExpr_Throw(Expr\Throw_ $node) { return 'throw ' . $this->p($node->expr); } - protected function pExpr_Yield(\PhpParser\Node\Expr\Yield_ $node) + protected function pExpr_Yield(Expr\Yield_ $node) { if ($node->value === null) { return 'yield'; @@ -619,7 +619,7 @@ class Standard extends \PhpParser\PrettyPrinterAbstract } } // Declarations - protected function pStmt_Namespace(\PhpParser\Node\Stmt\Namespace_ $node) + protected function pStmt_Namespace(Stmt\Namespace_ $node) { if ($this->canUseSemicolonNamespaces) { return 'namespace ' . $this->p($node->name) . ';' . $this->nl . $this->pStmts($node->stmts, \false); @@ -627,205 +627,205 @@ class Standard extends \PhpParser\PrettyPrinterAbstract return 'namespace' . (null !== $node->name ? ' ' . $this->p($node->name) : '') . ' {' . $this->pStmts($node->stmts) . $this->nl . '}'; } } - protected function pStmt_Use(\PhpParser\Node\Stmt\Use_ $node) + protected function pStmt_Use(Stmt\Use_ $node) { return 'use ' . $this->pUseType($node->type) . $this->pCommaSeparated($node->uses) . ';'; } - protected function pStmt_GroupUse(\PhpParser\Node\Stmt\GroupUse $node) + protected function pStmt_GroupUse(Stmt\GroupUse $node) { return 'use ' . $this->pUseType($node->type) . $this->pName($node->prefix) . '\\{' . $this->pCommaSeparated($node->uses) . '};'; } - protected function pStmt_UseUse(\PhpParser\Node\Stmt\UseUse $node) + protected function pStmt_UseUse(Stmt\UseUse $node) { return $this->pUseType($node->type) . $this->p($node->name) . (null !== $node->alias ? ' as ' . $node->alias : ''); } protected function pUseType($type) { - return $type === \PhpParser\Node\Stmt\Use_::TYPE_FUNCTION ? 'function ' : ($type === \PhpParser\Node\Stmt\Use_::TYPE_CONSTANT ? 'const ' : ''); + return $type === Stmt\Use_::TYPE_FUNCTION ? 'function ' : ($type === Stmt\Use_::TYPE_CONSTANT ? 'const ' : ''); } - protected function pStmt_Interface(\PhpParser\Node\Stmt\Interface_ $node) + protected function pStmt_Interface(Stmt\Interface_ $node) { return $this->pAttrGroups($node->attrGroups) . 'interface ' . $node->name . (!empty($node->extends) ? ' extends ' . $this->pCommaSeparated($node->extends) : '') . $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_Enum(\PhpParser\Node\Stmt\Enum_ $node) + protected function pStmt_Enum(Stmt\Enum_ $node) { return $this->pAttrGroups($node->attrGroups) . 'enum ' . $node->name . ($node->scalarType ? " : {$node->scalarType}" : '') . (!empty($node->implements) ? ' implements ' . $this->pCommaSeparated($node->implements) : '') . $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_Class(\PhpParser\Node\Stmt\Class_ $node) + protected function pStmt_Class(Stmt\Class_ $node) { return $this->pClassCommon($node, ' ' . $node->name); } - protected function pStmt_Trait(\PhpParser\Node\Stmt\Trait_ $node) + protected function pStmt_Trait(Stmt\Trait_ $node) { return $this->pAttrGroups($node->attrGroups) . 'trait ' . $node->name . $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_EnumCase(\PhpParser\Node\Stmt\EnumCase $node) + protected function pStmt_EnumCase(Stmt\EnumCase $node) { return $this->pAttrGroups($node->attrGroups) . 'case ' . $node->name . ($node->expr ? ' = ' . $this->p($node->expr) : '') . ';'; } - protected function pStmt_TraitUse(\PhpParser\Node\Stmt\TraitUse $node) + protected function pStmt_TraitUse(Stmt\TraitUse $node) { return 'use ' . $this->pCommaSeparated($node->traits) . (empty($node->adaptations) ? ';' : ' {' . $this->pStmts($node->adaptations) . $this->nl . '}'); } - protected function pStmt_TraitUseAdaptation_Precedence(\PhpParser\Node\Stmt\TraitUseAdaptation\Precedence $node) + protected function pStmt_TraitUseAdaptation_Precedence(Stmt\TraitUseAdaptation\Precedence $node) { return $this->p($node->trait) . '::' . $node->method . ' insteadof ' . $this->pCommaSeparated($node->insteadof) . ';'; } - protected function pStmt_TraitUseAdaptation_Alias(\PhpParser\Node\Stmt\TraitUseAdaptation\Alias $node) + protected function pStmt_TraitUseAdaptation_Alias(Stmt\TraitUseAdaptation\Alias $node) { return (null !== $node->trait ? $this->p($node->trait) . '::' : '') . $node->method . ' as' . (null !== $node->newModifier ? ' ' . \rtrim($this->pModifiers($node->newModifier), ' ') : '') . (null !== $node->newName ? ' ' . $node->newName : '') . ';'; } - protected function pStmt_Property(\PhpParser\Node\Stmt\Property $node) + protected function pStmt_Property(Stmt\Property $node) { return $this->pAttrGroups($node->attrGroups) . (0 === $node->flags ? 'var ' : $this->pModifiers($node->flags)) . ($node->type ? $this->p($node->type) . ' ' : '') . $this->pCommaSeparated($node->props) . ';'; } - protected function pStmt_PropertyProperty(\PhpParser\Node\Stmt\PropertyProperty $node) + protected function pStmt_PropertyProperty(Stmt\PropertyProperty $node) { return '$' . $node->name . (null !== $node->default ? ' = ' . $this->p($node->default) : ''); } - protected function pStmt_ClassMethod(\PhpParser\Node\Stmt\ClassMethod $node) + protected function pStmt_ClassMethod(Stmt\ClassMethod $node) { return $this->pAttrGroups($node->attrGroups) . $this->pModifiers($node->flags) . 'function ' . ($node->byRef ? '&' : '') . $node->name . '(' . $this->pMaybeMultiline($node->params) . ')' . (null !== $node->returnType ? ' : ' . $this->p($node->returnType) : '') . (null !== $node->stmts ? $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}' : ';'); } - protected function pStmt_ClassConst(\PhpParser\Node\Stmt\ClassConst $node) + protected function pStmt_ClassConst(Stmt\ClassConst $node) { return $this->pAttrGroups($node->attrGroups) . $this->pModifiers($node->flags) . 'const ' . $this->pCommaSeparated($node->consts) . ';'; } - protected function pStmt_Function(\PhpParser\Node\Stmt\Function_ $node) + protected function pStmt_Function(Stmt\Function_ $node) { return $this->pAttrGroups($node->attrGroups) . 'function ' . ($node->byRef ? '&' : '') . $node->name . '(' . $this->pCommaSeparated($node->params) . ')' . (null !== $node->returnType ? ' : ' . $this->p($node->returnType) : '') . $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_Const(\PhpParser\Node\Stmt\Const_ $node) + protected function pStmt_Const(Stmt\Const_ $node) { return 'const ' . $this->pCommaSeparated($node->consts) . ';'; } - protected function pStmt_Declare(\PhpParser\Node\Stmt\Declare_ $node) + protected function pStmt_Declare(Stmt\Declare_ $node) { return 'declare (' . $this->pCommaSeparated($node->declares) . ')' . (null !== $node->stmts ? ' {' . $this->pStmts($node->stmts) . $this->nl . '}' : ';'); } - protected function pStmt_DeclareDeclare(\PhpParser\Node\Stmt\DeclareDeclare $node) + protected function pStmt_DeclareDeclare(Stmt\DeclareDeclare $node) { return $node->key . '=' . $this->p($node->value); } // Control flow - protected function pStmt_If(\PhpParser\Node\Stmt\If_ $node) + protected function pStmt_If(Stmt\If_ $node) { return 'if (' . $this->p($node->cond) . ') {' . $this->pStmts($node->stmts) . $this->nl . '}' . ($node->elseifs ? ' ' . $this->pImplode($node->elseifs, ' ') : '') . (null !== $node->else ? ' ' . $this->p($node->else) : ''); } - protected function pStmt_ElseIf(\PhpParser\Node\Stmt\ElseIf_ $node) + protected function pStmt_ElseIf(Stmt\ElseIf_ $node) { return 'elseif (' . $this->p($node->cond) . ') {' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_Else(\PhpParser\Node\Stmt\Else_ $node) + protected function pStmt_Else(Stmt\Else_ $node) { return 'else {' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_For(\PhpParser\Node\Stmt\For_ $node) + protected function pStmt_For(Stmt\For_ $node) { return 'for (' . $this->pCommaSeparated($node->init) . ';' . (!empty($node->cond) ? ' ' : '') . $this->pCommaSeparated($node->cond) . ';' . (!empty($node->loop) ? ' ' : '') . $this->pCommaSeparated($node->loop) . ') {' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_Foreach(\PhpParser\Node\Stmt\Foreach_ $node) + protected function pStmt_Foreach(Stmt\Foreach_ $node) { return 'foreach (' . $this->p($node->expr) . ' as ' . (null !== $node->keyVar ? $this->p($node->keyVar) . ' => ' : '') . ($node->byRef ? '&' : '') . $this->p($node->valueVar) . ') {' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_While(\PhpParser\Node\Stmt\While_ $node) + protected function pStmt_While(Stmt\While_ $node) { return 'while (' . $this->p($node->cond) . ') {' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_Do(\PhpParser\Node\Stmt\Do_ $node) + protected function pStmt_Do(Stmt\Do_ $node) { return 'do {' . $this->pStmts($node->stmts) . $this->nl . '} while (' . $this->p($node->cond) . ');'; } - protected function pStmt_Switch(\PhpParser\Node\Stmt\Switch_ $node) + protected function pStmt_Switch(Stmt\Switch_ $node) { return 'switch (' . $this->p($node->cond) . ') {' . $this->pStmts($node->cases) . $this->nl . '}'; } - protected function pStmt_Case(\PhpParser\Node\Stmt\Case_ $node) + protected function pStmt_Case(Stmt\Case_ $node) { return (null !== $node->cond ? 'case ' . $this->p($node->cond) : 'default') . ':' . $this->pStmts($node->stmts); } - protected function pStmt_TryCatch(\PhpParser\Node\Stmt\TryCatch $node) + protected function pStmt_TryCatch(Stmt\TryCatch $node) { return 'try {' . $this->pStmts($node->stmts) . $this->nl . '}' . ($node->catches ? ' ' . $this->pImplode($node->catches, ' ') : '') . ($node->finally !== null ? ' ' . $this->p($node->finally) : ''); } - protected function pStmt_Catch(\PhpParser\Node\Stmt\Catch_ $node) + protected function pStmt_Catch(Stmt\Catch_ $node) { return 'catch (' . $this->pImplode($node->types, '|') . ($node->var !== null ? ' ' . $this->p($node->var) : '') . ') {' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_Finally(\PhpParser\Node\Stmt\Finally_ $node) + protected function pStmt_Finally(Stmt\Finally_ $node) { return 'finally {' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_Break(\PhpParser\Node\Stmt\Break_ $node) + protected function pStmt_Break(Stmt\Break_ $node) { return 'break' . ($node->num !== null ? ' ' . $this->p($node->num) : '') . ';'; } - protected function pStmt_Continue(\PhpParser\Node\Stmt\Continue_ $node) + protected function pStmt_Continue(Stmt\Continue_ $node) { return 'continue' . ($node->num !== null ? ' ' . $this->p($node->num) : '') . ';'; } - protected function pStmt_Return(\PhpParser\Node\Stmt\Return_ $node) + protected function pStmt_Return(Stmt\Return_ $node) { return 'return' . (null !== $node->expr ? ' ' . $this->p($node->expr) : '') . ';'; } - protected function pStmt_Throw(\PhpParser\Node\Stmt\Throw_ $node) + protected function pStmt_Throw(Stmt\Throw_ $node) { return 'throw ' . $this->p($node->expr) . ';'; } - protected function pStmt_Label(\PhpParser\Node\Stmt\Label $node) + protected function pStmt_Label(Stmt\Label $node) { return $node->name . ':'; } - protected function pStmt_Goto(\PhpParser\Node\Stmt\Goto_ $node) + protected function pStmt_Goto(Stmt\Goto_ $node) { return 'goto ' . $node->name . ';'; } // Other - protected function pStmt_Expression(\PhpParser\Node\Stmt\Expression $node) + protected function pStmt_Expression(Stmt\Expression $node) { return $this->p($node->expr) . ';'; } - protected function pStmt_Echo(\PhpParser\Node\Stmt\Echo_ $node) + protected function pStmt_Echo(Stmt\Echo_ $node) { return 'echo ' . $this->pCommaSeparated($node->exprs) . ';'; } - protected function pStmt_Static(\PhpParser\Node\Stmt\Static_ $node) + protected function pStmt_Static(Stmt\Static_ $node) { return 'static ' . $this->pCommaSeparated($node->vars) . ';'; } - protected function pStmt_Global(\PhpParser\Node\Stmt\Global_ $node) + protected function pStmt_Global(Stmt\Global_ $node) { return 'global ' . $this->pCommaSeparated($node->vars) . ';'; } - protected function pStmt_StaticVar(\PhpParser\Node\Stmt\StaticVar $node) + protected function pStmt_StaticVar(Stmt\StaticVar $node) { return $this->p($node->var) . (null !== $node->default ? ' = ' . $this->p($node->default) : ''); } - protected function pStmt_Unset(\PhpParser\Node\Stmt\Unset_ $node) + protected function pStmt_Unset(Stmt\Unset_ $node) { return 'unset(' . $this->pCommaSeparated($node->vars) . ');'; } - protected function pStmt_InlineHTML(\PhpParser\Node\Stmt\InlineHTML $node) + protected function pStmt_InlineHTML(Stmt\InlineHTML $node) { $newline = $node->getAttribute('hasLeadingNewline', \true) ? "\n" : ''; return '?>' . $newline . $node->value . 'remaining; } - protected function pStmt_Nop(\PhpParser\Node\Stmt\Nop $node) + protected function pStmt_Nop(Stmt\Nop $node) { return ''; } // Helpers - protected function pClassCommon(\PhpParser\Node\Stmt\Class_ $node, $afterClassToken) + protected function pClassCommon(Stmt\Class_ $node, $afterClassToken) { return $this->pAttrGroups($node->attrGroups, $node->name === null) . $this->pModifiers($node->flags) . 'class' . $afterClassToken . (null !== $node->extends ? ' extends ' . $this->p($node->extends) : '') . (!empty($node->implements) ? ' implements ' . $this->pCommaSeparated($node->implements) : '') . $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}'; } protected function pObjectProperty($node) { - if ($node instanceof \PhpParser\Node\Expr) { + if ($node instanceof Expr) { return '{' . $this->p($node) . '}'; } else { return $node; @@ -835,7 +835,7 @@ class Standard extends \PhpParser\PrettyPrinterAbstract { $return = ''; foreach ($encapsList as $element) { - if ($element instanceof \PhpParser\Node\Scalar\EncapsedStringPart) { + if ($element instanceof Scalar\EncapsedStringPart) { $return .= $this->escapeString($element->value, $quote); } else { $return .= '{' . $this->p($element) . '}'; @@ -889,13 +889,13 @@ class Standard extends \PhpParser\PrettyPrinterAbstract foreach ($parts as $i => $part) { $atStart = $i === 0; $atEnd = $i === \count($parts) - 1; - if ($part instanceof \PhpParser\Node\Scalar\EncapsedStringPart && $this->containsEndLabel($part->value, $label, $atStart, $atEnd)) { + if ($part instanceof Scalar\EncapsedStringPart && $this->containsEndLabel($part->value, $label, $atStart, $atEnd)) { return \true; } } return \false; } - protected function pDereferenceLhs(\PhpParser\Node $node) + protected function pDereferenceLhs(Node $node) { if (!$this->dereferenceLhsRequiresParens($node)) { return $this->p($node); @@ -903,7 +903,7 @@ class Standard extends \PhpParser\PrettyPrinterAbstract return '(' . $this->p($node) . ')'; } } - protected function pCallLhs(\PhpParser\Node $node) + protected function pCallLhs(Node $node) { if (!$this->callLhsRequiresParens($node)) { return $this->p($node); @@ -911,7 +911,7 @@ class Standard extends \PhpParser\PrettyPrinterAbstract return '(' . $this->p($node) . ')'; } } - protected function pNewVariable(\PhpParser\Node $node) + protected function pNewVariable(Node $node) { // TODO: This is not fully accurate. return $this->pDereferenceLhs($node); diff --git a/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php b/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php index b574ba01908..61fb82eb4db 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php +++ b/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php @@ -31,70 +31,70 @@ abstract class PrettyPrinterAbstract protected $precedenceMap = [ // [precedence, associativity] // where for precedence -1 is %left, 0 is %nonassoc and 1 is %right - \PhpParser\Node\Expr\BinaryOp\Pow::class => [0, 1], - \PhpParser\Node\Expr\BitwiseNot::class => [10, 1], - \PhpParser\Node\Expr\PreInc::class => [10, 1], - \PhpParser\Node\Expr\PreDec::class => [10, 1], - \PhpParser\Node\Expr\PostInc::class => [10, -1], - \PhpParser\Node\Expr\PostDec::class => [10, -1], - \PhpParser\Node\Expr\UnaryPlus::class => [10, 1], - \PhpParser\Node\Expr\UnaryMinus::class => [10, 1], - \PhpParser\Node\Expr\Cast\Int_::class => [10, 1], - \PhpParser\Node\Expr\Cast\Double::class => [10, 1], - \PhpParser\Node\Expr\Cast\String_::class => [10, 1], - \PhpParser\Node\Expr\Cast\Array_::class => [10, 1], - \PhpParser\Node\Expr\Cast\Object_::class => [10, 1], - \PhpParser\Node\Expr\Cast\Bool_::class => [10, 1], - \PhpParser\Node\Expr\Cast\Unset_::class => [10, 1], - \PhpParser\Node\Expr\ErrorSuppress::class => [10, 1], - \PhpParser\Node\Expr\Instanceof_::class => [20, 0], - \PhpParser\Node\Expr\BooleanNot::class => [30, 1], - \PhpParser\Node\Expr\BinaryOp\Mul::class => [40, -1], - \PhpParser\Node\Expr\BinaryOp\Div::class => [40, -1], - \PhpParser\Node\Expr\BinaryOp\Mod::class => [40, -1], - \PhpParser\Node\Expr\BinaryOp\Plus::class => [50, -1], - \PhpParser\Node\Expr\BinaryOp\Minus::class => [50, -1], - \PhpParser\Node\Expr\BinaryOp\Concat::class => [50, -1], - \PhpParser\Node\Expr\BinaryOp\ShiftLeft::class => [60, -1], - \PhpParser\Node\Expr\BinaryOp\ShiftRight::class => [60, -1], - \PhpParser\Node\Expr\BinaryOp\Smaller::class => [70, 0], - \PhpParser\Node\Expr\BinaryOp\SmallerOrEqual::class => [70, 0], - \PhpParser\Node\Expr\BinaryOp\Greater::class => [70, 0], - \PhpParser\Node\Expr\BinaryOp\GreaterOrEqual::class => [70, 0], - \PhpParser\Node\Expr\BinaryOp\Equal::class => [80, 0], - \PhpParser\Node\Expr\BinaryOp\NotEqual::class => [80, 0], - \PhpParser\Node\Expr\BinaryOp\Identical::class => [80, 0], - \PhpParser\Node\Expr\BinaryOp\NotIdentical::class => [80, 0], - \PhpParser\Node\Expr\BinaryOp\Spaceship::class => [80, 0], - \PhpParser\Node\Expr\BinaryOp\BitwiseAnd::class => [90, -1], - \PhpParser\Node\Expr\BinaryOp\BitwiseXor::class => [100, -1], - \PhpParser\Node\Expr\BinaryOp\BitwiseOr::class => [110, -1], - \PhpParser\Node\Expr\BinaryOp\BooleanAnd::class => [120, -1], - \PhpParser\Node\Expr\BinaryOp\BooleanOr::class => [130, -1], - \PhpParser\Node\Expr\BinaryOp\Coalesce::class => [140, 1], - \PhpParser\Node\Expr\Ternary::class => [150, 0], + BinaryOp\Pow::class => [0, 1], + Expr\BitwiseNot::class => [10, 1], + Expr\PreInc::class => [10, 1], + Expr\PreDec::class => [10, 1], + Expr\PostInc::class => [10, -1], + Expr\PostDec::class => [10, -1], + Expr\UnaryPlus::class => [10, 1], + Expr\UnaryMinus::class => [10, 1], + Cast\Int_::class => [10, 1], + Cast\Double::class => [10, 1], + Cast\String_::class => [10, 1], + Cast\Array_::class => [10, 1], + Cast\Object_::class => [10, 1], + Cast\Bool_::class => [10, 1], + Cast\Unset_::class => [10, 1], + Expr\ErrorSuppress::class => [10, 1], + Expr\Instanceof_::class => [20, 0], + Expr\BooleanNot::class => [30, 1], + BinaryOp\Mul::class => [40, -1], + BinaryOp\Div::class => [40, -1], + BinaryOp\Mod::class => [40, -1], + BinaryOp\Plus::class => [50, -1], + BinaryOp\Minus::class => [50, -1], + BinaryOp\Concat::class => [50, -1], + BinaryOp\ShiftLeft::class => [60, -1], + BinaryOp\ShiftRight::class => [60, -1], + BinaryOp\Smaller::class => [70, 0], + BinaryOp\SmallerOrEqual::class => [70, 0], + BinaryOp\Greater::class => [70, 0], + BinaryOp\GreaterOrEqual::class => [70, 0], + BinaryOp\Equal::class => [80, 0], + BinaryOp\NotEqual::class => [80, 0], + BinaryOp\Identical::class => [80, 0], + BinaryOp\NotIdentical::class => [80, 0], + BinaryOp\Spaceship::class => [80, 0], + BinaryOp\BitwiseAnd::class => [90, -1], + BinaryOp\BitwiseXor::class => [100, -1], + BinaryOp\BitwiseOr::class => [110, -1], + BinaryOp\BooleanAnd::class => [120, -1], + BinaryOp\BooleanOr::class => [130, -1], + BinaryOp\Coalesce::class => [140, 1], + Expr\Ternary::class => [150, 0], // parser uses %left for assignments, but they really behave as %right - \PhpParser\Node\Expr\Assign::class => [160, 1], - \PhpParser\Node\Expr\AssignRef::class => [160, 1], - \PhpParser\Node\Expr\AssignOp\Plus::class => [160, 1], - \PhpParser\Node\Expr\AssignOp\Minus::class => [160, 1], - \PhpParser\Node\Expr\AssignOp\Mul::class => [160, 1], - \PhpParser\Node\Expr\AssignOp\Div::class => [160, 1], - \PhpParser\Node\Expr\AssignOp\Concat::class => [160, 1], - \PhpParser\Node\Expr\AssignOp\Mod::class => [160, 1], - \PhpParser\Node\Expr\AssignOp\BitwiseAnd::class => [160, 1], - \PhpParser\Node\Expr\AssignOp\BitwiseOr::class => [160, 1], - \PhpParser\Node\Expr\AssignOp\BitwiseXor::class => [160, 1], - \PhpParser\Node\Expr\AssignOp\ShiftLeft::class => [160, 1], - \PhpParser\Node\Expr\AssignOp\ShiftRight::class => [160, 1], - \PhpParser\Node\Expr\AssignOp\Pow::class => [160, 1], - \PhpParser\Node\Expr\AssignOp\Coalesce::class => [160, 1], - \PhpParser\Node\Expr\YieldFrom::class => [165, 1], - \PhpParser\Node\Expr\Print_::class => [168, 1], - \PhpParser\Node\Expr\BinaryOp\LogicalAnd::class => [170, -1], - \PhpParser\Node\Expr\BinaryOp\LogicalXor::class => [180, -1], - \PhpParser\Node\Expr\BinaryOp\LogicalOr::class => [190, -1], - \PhpParser\Node\Expr\Include_::class => [200, -1], + Expr\Assign::class => [160, 1], + Expr\AssignRef::class => [160, 1], + AssignOp\Plus::class => [160, 1], + AssignOp\Minus::class => [160, 1], + AssignOp\Mul::class => [160, 1], + AssignOp\Div::class => [160, 1], + AssignOp\Concat::class => [160, 1], + AssignOp\Mod::class => [160, 1], + AssignOp\BitwiseAnd::class => [160, 1], + AssignOp\BitwiseOr::class => [160, 1], + AssignOp\BitwiseXor::class => [160, 1], + AssignOp\ShiftLeft::class => [160, 1], + AssignOp\ShiftRight::class => [160, 1], + AssignOp\Pow::class => [160, 1], + AssignOp\Coalesce::class => [160, 1], + Expr\YieldFrom::class => [165, 1], + Expr\Print_::class => [168, 1], + BinaryOp\LogicalAnd::class => [170, -1], + BinaryOp\LogicalXor::class => [180, -1], + BinaryOp\LogicalOr::class => [190, -1], + Expr\Include_::class => [200, -1], ]; /** @var int Current indentation level. */ protected $indentLevel; @@ -209,7 +209,7 @@ abstract class PrettyPrinterAbstract * * @return string Pretty printed node */ - public function prettyPrintExpr(\PhpParser\Node\Expr $node) : string + public function prettyPrintExpr(Expr $node) : string { $this->resetState(); return $this->handleMagicTokens($this->p($node)); @@ -227,10 +227,10 @@ abstract class PrettyPrinterAbstract return "prettyPrint($stmts); - if ($stmts[0] instanceof \PhpParser\Node\Stmt\InlineHTML) { + if ($stmts[0] instanceof Stmt\InlineHTML) { $p = \preg_replace('/^<\\?php\\s+\\?>\\n?/', '', $p); } - if ($stmts[\count($stmts) - 1] instanceof \PhpParser\Node\Stmt\InlineHTML) { + if ($stmts[\count($stmts) - 1] instanceof Stmt\InlineHTML) { $p = \preg_replace('/<\\?php$/', '', \rtrim($p)); } return $p; @@ -245,7 +245,7 @@ abstract class PrettyPrinterAbstract /* We can use semicolon-namespaces unless there is a global namespace declaration */ $this->canUseSemicolonNamespaces = \true; foreach ($nodes as $node) { - if ($node instanceof \PhpParser\Node\Stmt\Namespace_ && null === $node->name) { + if ($node instanceof Stmt\Namespace_ && null === $node->name) { $this->canUseSemicolonNamespaces = \false; break; } @@ -282,7 +282,7 @@ abstract class PrettyPrinterAbstract $comments = $node->getComments(); if ($comments) { $result .= $this->nl . $this->pComments($comments); - if ($node instanceof \PhpParser\Node\Stmt\Nop) { + if ($node instanceof Stmt\Nop) { continue; } } @@ -465,7 +465,7 @@ abstract class PrettyPrinterAbstract $this->initializeEmptyListInsertionMap(); $this->initializeModifierChangeMap(); $this->resetState(); - $this->origTokens = new \PhpParser\Internal\TokenStream($origTokens); + $this->origTokens = new TokenStream($origTokens); $this->preprocessNodes($stmts); $pos = 0; $result = $this->pArray($stmts, $origStmts, $pos, 0, 'File', 'stmts', null); @@ -509,15 +509,15 @@ abstract class PrettyPrinterAbstract $endPos = $origNode->getEndTokenPos(); \assert($startPos >= 0 && $endPos >= 0); $fallbackNode = $node; - if ($node instanceof \PhpParser\Node\Expr\New_ && $node->class instanceof \PhpParser\Node\Stmt\Class_) { + if ($node instanceof Expr\New_ && $node->class instanceof Stmt\Class_) { // Normalize node structure of anonymous classes - $node = \PhpParser\Internal\PrintableNewAnonClassNode::fromNewNode($node); - $origNode = \PhpParser\Internal\PrintableNewAnonClassNode::fromNewNode($origNode); + $node = PrintableNewAnonClassNode::fromNewNode($node); + $origNode = PrintableNewAnonClassNode::fromNewNode($origNode); } // InlineHTML node does not contain closing and opening PHP tags. If the parent formatting // is not preserved, then we need to use the fallback code to make sure the tags are // printed. - if ($node instanceof \PhpParser\Node\Stmt\InlineHTML && !$parentFormatPreserved) { + if ($node instanceof Stmt\InlineHTML && !$parentFormatPreserved) { return $this->pFallback($fallbackNode); } $indentAdjustment = $this->indentLevel - $this->origTokens->getIndentationBefore($startPos); @@ -671,7 +671,7 @@ abstract class PrettyPrinterAbstract $arrItem = $diffElem->new; /** @var Node|null $origArrItem */ $origArrItem = $diffElem->old; - if ($diffType === \PhpParser\Internal\DiffElem::TYPE_KEEP || $diffType === \PhpParser\Internal\DiffElem::TYPE_REPLACE) { + if ($diffType === DiffElem::TYPE_KEEP || $diffType === DiffElem::TYPE_REPLACE) { $beforeFirstKeepOrReplace = \false; if ($origArrItem === null || $arrItem === null) { // We can only handle the case where both are null @@ -736,7 +736,7 @@ abstract class PrettyPrinterAbstract } // If we had to remove anything, we have done so now. $skipRemovedNode = \false; - } elseif ($diffType === \PhpParser\Internal\DiffElem::TYPE_ADD) { + } elseif ($diffType === DiffElem::TYPE_ADD) { if (null === $insertStr) { // We don't have insertion information for this list type return null; @@ -765,7 +765,7 @@ abstract class PrettyPrinterAbstract } else { $result .= $insertStr; } - } elseif ($diffType === \PhpParser\Internal\DiffElem::TYPE_REMOVE) { + } elseif ($diffType === DiffElem::TYPE_REMOVE) { if (!$origArrItem instanceof \PhpParser\Node) { // We only support removal for nodes return null; @@ -868,12 +868,12 @@ abstract class PrettyPrinterAbstract break; case self::FIXUP_BRACED_NAME: case self::FIXUP_VAR_BRACED_NAME: - if ($subNode instanceof \PhpParser\Node\Expr && !$this->origTokens->haveBraces($subStartPos, $subEndPos)) { + if ($subNode instanceof Expr && !$this->origTokens->haveBraces($subStartPos, $subEndPos)) { return ($fixup === self::FIXUP_VAR_BRACED_NAME ? '$' : '') . '{' . $this->p($subNode) . '}'; } break; case self::FIXUP_ENCAPSED: - if (!$subNode instanceof \PhpParser\Node\Scalar\EncapsedStringPart && !$this->origTokens->haveBraces($subStartPos, $subEndPos)) { + if (!$subNode instanceof Scalar\EncapsedStringPart && !$this->origTokens->haveBraces($subStartPos, $subEndPos)) { return '{' . $this->p($subNode) . '}'; } break; @@ -916,7 +916,7 @@ abstract class PrettyPrinterAbstract */ protected function callLhsRequiresParens(\PhpParser\Node $node) : bool { - return !($node instanceof \PhpParser\Node\Name || $node instanceof \PhpParser\Node\Expr\Variable || $node instanceof \PhpParser\Node\Expr\ArrayDimFetch || $node instanceof \PhpParser\Node\Expr\FuncCall || $node instanceof \PhpParser\Node\Expr\MethodCall || $node instanceof \PhpParser\Node\Expr\NullsafeMethodCall || $node instanceof \PhpParser\Node\Expr\StaticCall || $node instanceof \PhpParser\Node\Expr\Array_); + return !($node instanceof \PhpParser\Node\Name || $node instanceof Expr\Variable || $node instanceof Expr\ArrayDimFetch || $node instanceof Expr\FuncCall || $node instanceof Expr\MethodCall || $node instanceof Expr\NullsafeMethodCall || $node instanceof Expr\StaticCall || $node instanceof Expr\Array_); } /** * Determines whether the LHS of a dereferencing operation must be wrapped in parenthesis. @@ -927,7 +927,7 @@ abstract class PrettyPrinterAbstract */ protected function dereferenceLhsRequiresParens(\PhpParser\Node $node) : bool { - return !($node instanceof \PhpParser\Node\Expr\Variable || $node instanceof \PhpParser\Node\Name || $node instanceof \PhpParser\Node\Expr\ArrayDimFetch || $node instanceof \PhpParser\Node\Expr\PropertyFetch || $node instanceof \PhpParser\Node\Expr\NullsafePropertyFetch || $node instanceof \PhpParser\Node\Expr\StaticPropertyFetch || $node instanceof \PhpParser\Node\Expr\FuncCall || $node instanceof \PhpParser\Node\Expr\MethodCall || $node instanceof \PhpParser\Node\Expr\NullsafeMethodCall || $node instanceof \PhpParser\Node\Expr\StaticCall || $node instanceof \PhpParser\Node\Expr\Array_ || $node instanceof \PhpParser\Node\Scalar\String_ || $node instanceof \PhpParser\Node\Expr\ConstFetch || $node instanceof \PhpParser\Node\Expr\ClassConstFetch); + return !($node instanceof Expr\Variable || $node instanceof \PhpParser\Node\Name || $node instanceof Expr\ArrayDimFetch || $node instanceof Expr\PropertyFetch || $node instanceof Expr\NullsafePropertyFetch || $node instanceof Expr\StaticPropertyFetch || $node instanceof Expr\FuncCall || $node instanceof Expr\MethodCall || $node instanceof Expr\NullsafeMethodCall || $node instanceof Expr\StaticCall || $node instanceof Expr\Array_ || $node instanceof Scalar\String_ || $node instanceof Expr\ConstFetch || $node instanceof Expr\ClassConstFetch); } /** * Print modifiers, including trailing whitespace. @@ -938,7 +938,7 @@ abstract class PrettyPrinterAbstract */ protected function pModifiers(int $modifiers) { - return ($modifiers & \PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC ? 'public ' : '') . ($modifiers & \PhpParser\Node\Stmt\Class_::MODIFIER_PROTECTED ? 'protected ' : '') . ($modifiers & \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE ? 'private ' : '') . ($modifiers & \PhpParser\Node\Stmt\Class_::MODIFIER_STATIC ? 'static ' : '') . ($modifiers & \PhpParser\Node\Stmt\Class_::MODIFIER_ABSTRACT ? 'abstract ' : '') . ($modifiers & \PhpParser\Node\Stmt\Class_::MODIFIER_FINAL ? 'final ' : '') . ($modifiers & \PhpParser\Node\Stmt\Class_::MODIFIER_READONLY ? 'readonly ' : ''); + return ($modifiers & Stmt\Class_::MODIFIER_PUBLIC ? 'public ' : '') . ($modifiers & Stmt\Class_::MODIFIER_PROTECTED ? 'protected ' : '') . ($modifiers & Stmt\Class_::MODIFIER_PRIVATE ? 'private ' : '') . ($modifiers & Stmt\Class_::MODIFIER_STATIC ? 'static ' : '') . ($modifiers & Stmt\Class_::MODIFIER_ABSTRACT ? 'abstract ' : '') . ($modifiers & Stmt\Class_::MODIFIER_FINAL ? 'final ' : '') . ($modifiers & Stmt\Class_::MODIFIER_READONLY ? 'readonly ' : ''); } /** * Determine whether a list of nodes uses multiline formatting. @@ -1019,34 +1019,34 @@ abstract class PrettyPrinterAbstract return; } $this->fixupMap = [ - \PhpParser\Node\Expr\PreInc::class => ['var' => self::FIXUP_PREC_RIGHT], - \PhpParser\Node\Expr\PreDec::class => ['var' => self::FIXUP_PREC_RIGHT], - \PhpParser\Node\Expr\PostInc::class => ['var' => self::FIXUP_PREC_LEFT], - \PhpParser\Node\Expr\PostDec::class => ['var' => self::FIXUP_PREC_LEFT], - \PhpParser\Node\Expr\Instanceof_::class => ['expr' => self::FIXUP_PREC_LEFT, 'class' => self::FIXUP_PREC_RIGHT], - \PhpParser\Node\Expr\Ternary::class => ['cond' => self::FIXUP_PREC_LEFT, 'else' => self::FIXUP_PREC_RIGHT], - \PhpParser\Node\Expr\FuncCall::class => ['name' => self::FIXUP_CALL_LHS], - \PhpParser\Node\Expr\StaticCall::class => ['class' => self::FIXUP_DEREF_LHS], - \PhpParser\Node\Expr\ArrayDimFetch::class => ['var' => self::FIXUP_DEREF_LHS], - \PhpParser\Node\Expr\ClassConstFetch::class => ['var' => self::FIXUP_DEREF_LHS], - \PhpParser\Node\Expr\New_::class => ['class' => self::FIXUP_DEREF_LHS], + Expr\PreInc::class => ['var' => self::FIXUP_PREC_RIGHT], + Expr\PreDec::class => ['var' => self::FIXUP_PREC_RIGHT], + Expr\PostInc::class => ['var' => self::FIXUP_PREC_LEFT], + Expr\PostDec::class => ['var' => self::FIXUP_PREC_LEFT], + Expr\Instanceof_::class => ['expr' => self::FIXUP_PREC_LEFT, 'class' => self::FIXUP_PREC_RIGHT], + Expr\Ternary::class => ['cond' => self::FIXUP_PREC_LEFT, 'else' => self::FIXUP_PREC_RIGHT], + Expr\FuncCall::class => ['name' => self::FIXUP_CALL_LHS], + Expr\StaticCall::class => ['class' => self::FIXUP_DEREF_LHS], + Expr\ArrayDimFetch::class => ['var' => self::FIXUP_DEREF_LHS], + Expr\ClassConstFetch::class => ['var' => self::FIXUP_DEREF_LHS], + Expr\New_::class => ['class' => self::FIXUP_DEREF_LHS], // TODO: FIXUP_NEW_VARIABLE - \PhpParser\Node\Expr\MethodCall::class => ['var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME], - \PhpParser\Node\Expr\NullsafeMethodCall::class => ['var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME], - \PhpParser\Node\Expr\StaticPropertyFetch::class => ['class' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_VAR_BRACED_NAME], - \PhpParser\Node\Expr\PropertyFetch::class => ['var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME], - \PhpParser\Node\Expr\NullsafePropertyFetch::class => ['var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME], - \PhpParser\Node\Scalar\Encapsed::class => ['parts' => self::FIXUP_ENCAPSED], + Expr\MethodCall::class => ['var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME], + Expr\NullsafeMethodCall::class => ['var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME], + Expr\StaticPropertyFetch::class => ['class' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_VAR_BRACED_NAME], + Expr\PropertyFetch::class => ['var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME], + Expr\NullsafePropertyFetch::class => ['var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME], + Scalar\Encapsed::class => ['parts' => self::FIXUP_ENCAPSED], ]; - $binaryOps = [\PhpParser\Node\Expr\BinaryOp\Pow::class, \PhpParser\Node\Expr\BinaryOp\Mul::class, \PhpParser\Node\Expr\BinaryOp\Div::class, \PhpParser\Node\Expr\BinaryOp\Mod::class, \PhpParser\Node\Expr\BinaryOp\Plus::class, \PhpParser\Node\Expr\BinaryOp\Minus::class, \PhpParser\Node\Expr\BinaryOp\Concat::class, \PhpParser\Node\Expr\BinaryOp\ShiftLeft::class, \PhpParser\Node\Expr\BinaryOp\ShiftRight::class, \PhpParser\Node\Expr\BinaryOp\Smaller::class, \PhpParser\Node\Expr\BinaryOp\SmallerOrEqual::class, \PhpParser\Node\Expr\BinaryOp\Greater::class, \PhpParser\Node\Expr\BinaryOp\GreaterOrEqual::class, \PhpParser\Node\Expr\BinaryOp\Equal::class, \PhpParser\Node\Expr\BinaryOp\NotEqual::class, \PhpParser\Node\Expr\BinaryOp\Identical::class, \PhpParser\Node\Expr\BinaryOp\NotIdentical::class, \PhpParser\Node\Expr\BinaryOp\Spaceship::class, \PhpParser\Node\Expr\BinaryOp\BitwiseAnd::class, \PhpParser\Node\Expr\BinaryOp\BitwiseXor::class, \PhpParser\Node\Expr\BinaryOp\BitwiseOr::class, \PhpParser\Node\Expr\BinaryOp\BooleanAnd::class, \PhpParser\Node\Expr\BinaryOp\BooleanOr::class, \PhpParser\Node\Expr\BinaryOp\Coalesce::class, \PhpParser\Node\Expr\BinaryOp\LogicalAnd::class, \PhpParser\Node\Expr\BinaryOp\LogicalXor::class, \PhpParser\Node\Expr\BinaryOp\LogicalOr::class]; + $binaryOps = [BinaryOp\Pow::class, BinaryOp\Mul::class, BinaryOp\Div::class, BinaryOp\Mod::class, BinaryOp\Plus::class, BinaryOp\Minus::class, BinaryOp\Concat::class, BinaryOp\ShiftLeft::class, BinaryOp\ShiftRight::class, BinaryOp\Smaller::class, BinaryOp\SmallerOrEqual::class, BinaryOp\Greater::class, BinaryOp\GreaterOrEqual::class, BinaryOp\Equal::class, BinaryOp\NotEqual::class, BinaryOp\Identical::class, BinaryOp\NotIdentical::class, BinaryOp\Spaceship::class, BinaryOp\BitwiseAnd::class, BinaryOp\BitwiseXor::class, BinaryOp\BitwiseOr::class, BinaryOp\BooleanAnd::class, BinaryOp\BooleanOr::class, BinaryOp\Coalesce::class, BinaryOp\LogicalAnd::class, BinaryOp\LogicalXor::class, BinaryOp\LogicalOr::class]; foreach ($binaryOps as $binaryOp) { $this->fixupMap[$binaryOp] = ['left' => self::FIXUP_PREC_LEFT, 'right' => self::FIXUP_PREC_RIGHT]; } - $assignOps = [\PhpParser\Node\Expr\Assign::class, \PhpParser\Node\Expr\AssignRef::class, \PhpParser\Node\Expr\AssignOp\Plus::class, \PhpParser\Node\Expr\AssignOp\Minus::class, \PhpParser\Node\Expr\AssignOp\Mul::class, \PhpParser\Node\Expr\AssignOp\Div::class, \PhpParser\Node\Expr\AssignOp\Concat::class, \PhpParser\Node\Expr\AssignOp\Mod::class, \PhpParser\Node\Expr\AssignOp\BitwiseAnd::class, \PhpParser\Node\Expr\AssignOp\BitwiseOr::class, \PhpParser\Node\Expr\AssignOp\BitwiseXor::class, \PhpParser\Node\Expr\AssignOp\ShiftLeft::class, \PhpParser\Node\Expr\AssignOp\ShiftRight::class, \PhpParser\Node\Expr\AssignOp\Pow::class, \PhpParser\Node\Expr\AssignOp\Coalesce::class]; + $assignOps = [Expr\Assign::class, Expr\AssignRef::class, AssignOp\Plus::class, AssignOp\Minus::class, AssignOp\Mul::class, AssignOp\Div::class, AssignOp\Concat::class, AssignOp\Mod::class, AssignOp\BitwiseAnd::class, AssignOp\BitwiseOr::class, AssignOp\BitwiseXor::class, AssignOp\ShiftLeft::class, AssignOp\ShiftRight::class, AssignOp\Pow::class, AssignOp\Coalesce::class]; foreach ($assignOps as $assignOp) { $this->fixupMap[$assignOp] = ['var' => self::FIXUP_PREC_LEFT, 'expr' => self::FIXUP_PREC_RIGHT]; } - $prefixOps = [\PhpParser\Node\Expr\BitwiseNot::class, \PhpParser\Node\Expr\BooleanNot::class, \PhpParser\Node\Expr\UnaryPlus::class, \PhpParser\Node\Expr\UnaryMinus::class, \PhpParser\Node\Expr\Cast\Int_::class, \PhpParser\Node\Expr\Cast\Double::class, \PhpParser\Node\Expr\Cast\String_::class, \PhpParser\Node\Expr\Cast\Array_::class, \PhpParser\Node\Expr\Cast\Object_::class, \PhpParser\Node\Expr\Cast\Bool_::class, \PhpParser\Node\Expr\Cast\Unset_::class, \PhpParser\Node\Expr\ErrorSuppress::class, \PhpParser\Node\Expr\YieldFrom::class, \PhpParser\Node\Expr\Print_::class, \PhpParser\Node\Expr\Include_::class]; + $prefixOps = [Expr\BitwiseNot::class, Expr\BooleanNot::class, Expr\UnaryPlus::class, Expr\UnaryMinus::class, Cast\Int_::class, Cast\Double::class, Cast\String_::class, Cast\Array_::class, Cast\Object_::class, Cast\Bool_::class, Cast\Unset_::class, Expr\ErrorSuppress::class, Expr\YieldFrom::class, Expr\Print_::class, Expr\Include_::class]; foreach ($prefixOps as $prefixOp) { $this->fixupMap[$prefixOp] = ['expr' => self::FIXUP_PREC_RIGHT]; } diff --git a/vendor/ondram/ci-detector/src/Ci/AbstractCi.php b/vendor/ondram/ci-detector/src/Ci/AbstractCi.php index 813be2ae817..553ddeb2720 100644 --- a/vendor/ondram/ci-detector/src/Ci/AbstractCi.php +++ b/vendor/ondram/ci-detector/src/Ci/AbstractCi.php @@ -7,11 +7,11 @@ use RectorPrefix20220607\OndraM\CiDetector\Env; /** * Unified adapter to retrieve environment variables from current continuous integration server */ -abstract class AbstractCi implements \RectorPrefix20220607\OndraM\CiDetector\Ci\CiInterface +abstract class AbstractCi implements CiInterface { /** @var Env */ protected $env; - public function __construct(\RectorPrefix20220607\OndraM\CiDetector\Env $env) + public function __construct(Env $env) { $this->env = $env; } diff --git a/vendor/ondram/ci-detector/src/Ci/AppVeyor.php b/vendor/ondram/ci-detector/src/Ci/AppVeyor.php index c5e582d4bf5..c6b3a73ad25 100644 --- a/vendor/ondram/ci-detector/src/Ci/AppVeyor.php +++ b/vendor/ondram/ci-detector/src/Ci/AppVeyor.php @@ -6,19 +6,19 @@ namespace RectorPrefix20220607\OndraM\CiDetector\Ci; use RectorPrefix20220607\OndraM\CiDetector\CiDetector; use RectorPrefix20220607\OndraM\CiDetector\Env; use RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic; -class AppVeyor extends \RectorPrefix20220607\OndraM\CiDetector\Ci\AbstractCi +class AppVeyor extends AbstractCi { - public static function isDetected(\RectorPrefix20220607\OndraM\CiDetector\Env $env) : bool + public static function isDetected(Env $env) : bool { return $env->get('APPVEYOR') === 'True'; } public function getCiName() : string { - return \RectorPrefix20220607\OndraM\CiDetector\CiDetector::CI_APPVEYOR; + return CiDetector::CI_APPVEYOR; } - public function isPullRequest() : \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic + public function isPullRequest() : TrinaryLogic { - return \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic::createFromBoolean($this->env->getString('APPVEYOR_PULL_REQUEST_NUMBER') !== ''); + return TrinaryLogic::createFromBoolean($this->env->getString('APPVEYOR_PULL_REQUEST_NUMBER') !== ''); } public function getBuildNumber() : string { diff --git a/vendor/ondram/ci-detector/src/Ci/AwsCodeBuild.php b/vendor/ondram/ci-detector/src/Ci/AwsCodeBuild.php index 9c9b601836d..ce96a1e818b 100644 --- a/vendor/ondram/ci-detector/src/Ci/AwsCodeBuild.php +++ b/vendor/ondram/ci-detector/src/Ci/AwsCodeBuild.php @@ -6,19 +6,19 @@ namespace RectorPrefix20220607\OndraM\CiDetector\Ci; use RectorPrefix20220607\OndraM\CiDetector\CiDetector; use RectorPrefix20220607\OndraM\CiDetector\Env; use RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic; -class AwsCodeBuild extends \RectorPrefix20220607\OndraM\CiDetector\Ci\AbstractCi +class AwsCodeBuild extends AbstractCi { - public static function isDetected(\RectorPrefix20220607\OndraM\CiDetector\Env $env) : bool + public static function isDetected(Env $env) : bool { return $env->get('CODEBUILD_CI') !== \false; } public function getCiName() : string { - return \RectorPrefix20220607\OndraM\CiDetector\CiDetector::CI_AWS_CODEBUILD; + return CiDetector::CI_AWS_CODEBUILD; } - public function isPullRequest() : \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic + public function isPullRequest() : TrinaryLogic { - return \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic::createFromBoolean(\mb_strpos($this->env->getString('CODEBUILD_WEBHOOK_EVENT'), 'PULL_REQUEST') === 0); + return TrinaryLogic::createFromBoolean(\mb_strpos($this->env->getString('CODEBUILD_WEBHOOK_EVENT'), 'PULL_REQUEST') === 0); } public function getBuildNumber() : string { diff --git a/vendor/ondram/ci-detector/src/Ci/AzurePipelines.php b/vendor/ondram/ci-detector/src/Ci/AzurePipelines.php index cf963f634b7..b71e2bf9a84 100644 --- a/vendor/ondram/ci-detector/src/Ci/AzurePipelines.php +++ b/vendor/ondram/ci-detector/src/Ci/AzurePipelines.php @@ -6,19 +6,19 @@ namespace RectorPrefix20220607\OndraM\CiDetector\Ci; use RectorPrefix20220607\OndraM\CiDetector\CiDetector; use RectorPrefix20220607\OndraM\CiDetector\Env; use RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic; -class AzurePipelines extends \RectorPrefix20220607\OndraM\CiDetector\Ci\AbstractCi +class AzurePipelines extends AbstractCi { - public static function isDetected(\RectorPrefix20220607\OndraM\CiDetector\Env $env) : bool + public static function isDetected(Env $env) : bool { return $env->get('BUILD_DEFINITIONVERSION') !== \false; } public function getCiName() : string { - return \RectorPrefix20220607\OndraM\CiDetector\CiDetector::CI_AZURE_PIPELINES; + return CiDetector::CI_AZURE_PIPELINES; } - public function isPullRequest() : \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic + public function isPullRequest() : TrinaryLogic { - return \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic::createFromBoolean($this->env->getString('BUILD_REASON') === 'PullRequest'); + return TrinaryLogic::createFromBoolean($this->env->getString('BUILD_REASON') === 'PullRequest'); } public function getBuildNumber() : string { diff --git a/vendor/ondram/ci-detector/src/Ci/Bamboo.php b/vendor/ondram/ci-detector/src/Ci/Bamboo.php index 91779237908..4c5f9abfeca 100644 --- a/vendor/ondram/ci-detector/src/Ci/Bamboo.php +++ b/vendor/ondram/ci-detector/src/Ci/Bamboo.php @@ -6,19 +6,19 @@ namespace RectorPrefix20220607\OndraM\CiDetector\Ci; use RectorPrefix20220607\OndraM\CiDetector\CiDetector; use RectorPrefix20220607\OndraM\CiDetector\Env; use RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic; -class Bamboo extends \RectorPrefix20220607\OndraM\CiDetector\Ci\AbstractCi +class Bamboo extends AbstractCi { - public static function isDetected(\RectorPrefix20220607\OndraM\CiDetector\Env $env) : bool + public static function isDetected(Env $env) : bool { return $env->get('bamboo_buildKey') !== \false; } public function getCiName() : string { - return \RectorPrefix20220607\OndraM\CiDetector\CiDetector::CI_BAMBOO; + return CiDetector::CI_BAMBOO; } - public function isPullRequest() : \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic + public function isPullRequest() : TrinaryLogic { - return \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic::createFromBoolean($this->env->get('bamboo_repository_pr_key') !== \false); + return TrinaryLogic::createFromBoolean($this->env->get('bamboo_repository_pr_key') !== \false); } public function getBuildNumber() : string { diff --git a/vendor/ondram/ci-detector/src/Ci/BitbucketPipelines.php b/vendor/ondram/ci-detector/src/Ci/BitbucketPipelines.php index b87f5b19955..5e64da5aa60 100644 --- a/vendor/ondram/ci-detector/src/Ci/BitbucketPipelines.php +++ b/vendor/ondram/ci-detector/src/Ci/BitbucketPipelines.php @@ -6,19 +6,19 @@ namespace RectorPrefix20220607\OndraM\CiDetector\Ci; use RectorPrefix20220607\OndraM\CiDetector\CiDetector; use RectorPrefix20220607\OndraM\CiDetector\Env; use RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic; -class BitbucketPipelines extends \RectorPrefix20220607\OndraM\CiDetector\Ci\AbstractCi +class BitbucketPipelines extends AbstractCi { - public static function isDetected(\RectorPrefix20220607\OndraM\CiDetector\Env $env) : bool + public static function isDetected(Env $env) : bool { return $env->get('BITBUCKET_COMMIT') !== \false; } public function getCiName() : string { - return \RectorPrefix20220607\OndraM\CiDetector\CiDetector::CI_BITBUCKET_PIPELINES; + return CiDetector::CI_BITBUCKET_PIPELINES; } - public function isPullRequest() : \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic + public function isPullRequest() : TrinaryLogic { - return \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic::createFromBoolean($this->env->getString('BITBUCKET_PR_ID') !== ''); + return TrinaryLogic::createFromBoolean($this->env->getString('BITBUCKET_PR_ID') !== ''); } public function getBuildNumber() : string { diff --git a/vendor/ondram/ci-detector/src/Ci/Buddy.php b/vendor/ondram/ci-detector/src/Ci/Buddy.php index 875fa02aafe..40de05cafeb 100644 --- a/vendor/ondram/ci-detector/src/Ci/Buddy.php +++ b/vendor/ondram/ci-detector/src/Ci/Buddy.php @@ -6,19 +6,19 @@ namespace RectorPrefix20220607\OndraM\CiDetector\Ci; use RectorPrefix20220607\OndraM\CiDetector\CiDetector; use RectorPrefix20220607\OndraM\CiDetector\Env; use RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic; -class Buddy extends \RectorPrefix20220607\OndraM\CiDetector\Ci\AbstractCi +class Buddy extends AbstractCi { - public static function isDetected(\RectorPrefix20220607\OndraM\CiDetector\Env $env) : bool + public static function isDetected(Env $env) : bool { return $env->get('BUDDY') !== \false; } public function getCiName() : string { - return \RectorPrefix20220607\OndraM\CiDetector\CiDetector::CI_BUDDY; + return CiDetector::CI_BUDDY; } - public function isPullRequest() : \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic + public function isPullRequest() : TrinaryLogic { - return \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic::createFromBoolean($this->env->getString('BUDDY_EXECUTION_PULL_REQUEST_ID') !== ''); + return TrinaryLogic::createFromBoolean($this->env->getString('BUDDY_EXECUTION_PULL_REQUEST_ID') !== ''); } public function getBuildNumber() : string { diff --git a/vendor/ondram/ci-detector/src/Ci/CiInterface.php b/vendor/ondram/ci-detector/src/Ci/CiInterface.php index aad9eb82e86..278b5a88aaf 100644 --- a/vendor/ondram/ci-detector/src/Ci/CiInterface.php +++ b/vendor/ondram/ci-detector/src/Ci/CiInterface.php @@ -10,7 +10,7 @@ interface CiInterface /** * Return true if this CI was detected. */ - public static function isDetected(\RectorPrefix20220607\OndraM\CiDetector\Env $env) : bool; + public static function isDetected(Env $env) : bool; /** * Get name of the CI server type. */ @@ -64,5 +64,5 @@ interface CiInterface * Returned TrinaryLogic object's value will be true if the current build is from a pull/merge request, * false if it not, and maybe if we can't determine it. */ - public function isPullRequest() : \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic; + public function isPullRequest() : TrinaryLogic; } diff --git a/vendor/ondram/ci-detector/src/Ci/Circle.php b/vendor/ondram/ci-detector/src/Ci/Circle.php index 974ec86a56f..78add1c072c 100644 --- a/vendor/ondram/ci-detector/src/Ci/Circle.php +++ b/vendor/ondram/ci-detector/src/Ci/Circle.php @@ -6,19 +6,19 @@ namespace RectorPrefix20220607\OndraM\CiDetector\Ci; use RectorPrefix20220607\OndraM\CiDetector\CiDetector; use RectorPrefix20220607\OndraM\CiDetector\Env; use RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic; -class Circle extends \RectorPrefix20220607\OndraM\CiDetector\Ci\AbstractCi +class Circle extends AbstractCi { - public static function isDetected(\RectorPrefix20220607\OndraM\CiDetector\Env $env) : bool + public static function isDetected(Env $env) : bool { return $env->get('CIRCLECI') !== \false; } public function getCiName() : string { - return \RectorPrefix20220607\OndraM\CiDetector\CiDetector::CI_CIRCLE; + return CiDetector::CI_CIRCLE; } - public function isPullRequest() : \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic + public function isPullRequest() : TrinaryLogic { - return \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic::createFromBoolean($this->env->getString('CI_PULL_REQUEST') !== ''); + return TrinaryLogic::createFromBoolean($this->env->getString('CI_PULL_REQUEST') !== ''); } public function getBuildNumber() : string { diff --git a/vendor/ondram/ci-detector/src/Ci/Codeship.php b/vendor/ondram/ci-detector/src/Ci/Codeship.php index 18e1d8ad4f6..7df7b7c5e65 100644 --- a/vendor/ondram/ci-detector/src/Ci/Codeship.php +++ b/vendor/ondram/ci-detector/src/Ci/Codeship.php @@ -6,19 +6,19 @@ namespace RectorPrefix20220607\OndraM\CiDetector\Ci; use RectorPrefix20220607\OndraM\CiDetector\CiDetector; use RectorPrefix20220607\OndraM\CiDetector\Env; use RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic; -class Codeship extends \RectorPrefix20220607\OndraM\CiDetector\Ci\AbstractCi +class Codeship extends AbstractCi { - public static function isDetected(\RectorPrefix20220607\OndraM\CiDetector\Env $env) : bool + public static function isDetected(Env $env) : bool { return $env->get('CI_NAME') === 'codeship'; } public function getCiName() : string { - return \RectorPrefix20220607\OndraM\CiDetector\CiDetector::CI_CODESHIP; + return CiDetector::CI_CODESHIP; } - public function isPullRequest() : \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic + public function isPullRequest() : TrinaryLogic { - return \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic::createFromBoolean($this->env->getString('CI_PULL_REQUEST') !== 'false'); + return TrinaryLogic::createFromBoolean($this->env->getString('CI_PULL_REQUEST') !== 'false'); } public function getBuildNumber() : string { diff --git a/vendor/ondram/ci-detector/src/Ci/Continuousphp.php b/vendor/ondram/ci-detector/src/Ci/Continuousphp.php index 3fd35240f40..de55cd5c5b5 100644 --- a/vendor/ondram/ci-detector/src/Ci/Continuousphp.php +++ b/vendor/ondram/ci-detector/src/Ci/Continuousphp.php @@ -6,19 +6,19 @@ namespace RectorPrefix20220607\OndraM\CiDetector\Ci; use RectorPrefix20220607\OndraM\CiDetector\CiDetector; use RectorPrefix20220607\OndraM\CiDetector\Env; use RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic; -class Continuousphp extends \RectorPrefix20220607\OndraM\CiDetector\Ci\AbstractCi +class Continuousphp extends AbstractCi { - public static function isDetected(\RectorPrefix20220607\OndraM\CiDetector\Env $env) : bool + public static function isDetected(Env $env) : bool { return $env->get('CONTINUOUSPHP') === 'continuousphp'; } public function getCiName() : string { - return \RectorPrefix20220607\OndraM\CiDetector\CiDetector::CI_CONTINUOUSPHP; + return CiDetector::CI_CONTINUOUSPHP; } - public function isPullRequest() : \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic + public function isPullRequest() : TrinaryLogic { - return \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic::createFromBoolean($this->env->getString('CPHP_PR_ID') !== ''); + return TrinaryLogic::createFromBoolean($this->env->getString('CPHP_PR_ID') !== ''); } public function getBuildNumber() : string { diff --git a/vendor/ondram/ci-detector/src/Ci/Drone.php b/vendor/ondram/ci-detector/src/Ci/Drone.php index 567792f5df0..2ebbd61d5ac 100644 --- a/vendor/ondram/ci-detector/src/Ci/Drone.php +++ b/vendor/ondram/ci-detector/src/Ci/Drone.php @@ -6,19 +6,19 @@ namespace RectorPrefix20220607\OndraM\CiDetector\Ci; use RectorPrefix20220607\OndraM\CiDetector\CiDetector; use RectorPrefix20220607\OndraM\CiDetector\Env; use RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic; -class Drone extends \RectorPrefix20220607\OndraM\CiDetector\Ci\AbstractCi +class Drone extends AbstractCi { - public static function isDetected(\RectorPrefix20220607\OndraM\CiDetector\Env $env) : bool + public static function isDetected(Env $env) : bool { return $env->get('CI') === 'drone'; } public function getCiName() : string { - return \RectorPrefix20220607\OndraM\CiDetector\CiDetector::CI_DRONE; + return CiDetector::CI_DRONE; } - public function isPullRequest() : \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic + public function isPullRequest() : TrinaryLogic { - return \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic::createFromBoolean($this->env->getString('DRONE_PULL_REQUEST') !== ''); + return TrinaryLogic::createFromBoolean($this->env->getString('DRONE_PULL_REQUEST') !== ''); } public function getBuildNumber() : string { diff --git a/vendor/ondram/ci-detector/src/Ci/GitHubActions.php b/vendor/ondram/ci-detector/src/Ci/GitHubActions.php index cfb3bbc7524..c3cc780aa59 100644 --- a/vendor/ondram/ci-detector/src/Ci/GitHubActions.php +++ b/vendor/ondram/ci-detector/src/Ci/GitHubActions.php @@ -6,20 +6,20 @@ namespace RectorPrefix20220607\OndraM\CiDetector\Ci; use RectorPrefix20220607\OndraM\CiDetector\CiDetector; use RectorPrefix20220607\OndraM\CiDetector\Env; use RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic; -class GitHubActions extends \RectorPrefix20220607\OndraM\CiDetector\Ci\AbstractCi +class GitHubActions extends AbstractCi { public const GITHUB_BASE_URL = 'https://github.com'; - public static function isDetected(\RectorPrefix20220607\OndraM\CiDetector\Env $env) : bool + public static function isDetected(Env $env) : bool { return $env->get('GITHUB_ACTIONS') !== \false; } public function getCiName() : string { - return \RectorPrefix20220607\OndraM\CiDetector\CiDetector::CI_GITHUB_ACTIONS; + return CiDetector::CI_GITHUB_ACTIONS; } - public function isPullRequest() : \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic + public function isPullRequest() : TrinaryLogic { - return \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic::createFromBoolean($this->env->getString('GITHUB_EVENT_NAME') === 'pull_request'); + return TrinaryLogic::createFromBoolean($this->env->getString('GITHUB_EVENT_NAME') === 'pull_request'); } public function getBuildNumber() : string { diff --git a/vendor/ondram/ci-detector/src/Ci/GitLab.php b/vendor/ondram/ci-detector/src/Ci/GitLab.php index 0a94c09ce3c..c8af5f8377f 100644 --- a/vendor/ondram/ci-detector/src/Ci/GitLab.php +++ b/vendor/ondram/ci-detector/src/Ci/GitLab.php @@ -6,19 +6,19 @@ namespace RectorPrefix20220607\OndraM\CiDetector\Ci; use RectorPrefix20220607\OndraM\CiDetector\CiDetector; use RectorPrefix20220607\OndraM\CiDetector\Env; use RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic; -class GitLab extends \RectorPrefix20220607\OndraM\CiDetector\Ci\AbstractCi +class GitLab extends AbstractCi { - public static function isDetected(\RectorPrefix20220607\OndraM\CiDetector\Env $env) : bool + public static function isDetected(Env $env) : bool { return $env->get('GITLAB_CI') !== \false; } public function getCiName() : string { - return \RectorPrefix20220607\OndraM\CiDetector\CiDetector::CI_GITLAB; + return CiDetector::CI_GITLAB; } - public function isPullRequest() : \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic + public function isPullRequest() : TrinaryLogic { - return \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic::createFromBoolean($this->env->get('CI_MERGE_REQUEST_ID') !== \false || $this->env->get('CI_EXTERNAL_PULL_REQUEST_IID') !== \false); + return TrinaryLogic::createFromBoolean($this->env->get('CI_MERGE_REQUEST_ID') !== \false || $this->env->get('CI_EXTERNAL_PULL_REQUEST_IID') !== \false); } public function getBuildNumber() : string { diff --git a/vendor/ondram/ci-detector/src/Ci/Jenkins.php b/vendor/ondram/ci-detector/src/Ci/Jenkins.php index 0f4df746511..facd06d9048 100644 --- a/vendor/ondram/ci-detector/src/Ci/Jenkins.php +++ b/vendor/ondram/ci-detector/src/Ci/Jenkins.php @@ -6,19 +6,19 @@ namespace RectorPrefix20220607\OndraM\CiDetector\Ci; use RectorPrefix20220607\OndraM\CiDetector\CiDetector; use RectorPrefix20220607\OndraM\CiDetector\Env; use RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic; -class Jenkins extends \RectorPrefix20220607\OndraM\CiDetector\Ci\AbstractCi +class Jenkins extends AbstractCi { - public static function isDetected(\RectorPrefix20220607\OndraM\CiDetector\Env $env) : bool + public static function isDetected(Env $env) : bool { return $env->get('JENKINS_URL') !== \false; } public function getCiName() : string { - return \RectorPrefix20220607\OndraM\CiDetector\CiDetector::CI_JENKINS; + return CiDetector::CI_JENKINS; } - public function isPullRequest() : \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic + public function isPullRequest() : TrinaryLogic { - return \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic::createMaybe(); + return TrinaryLogic::createMaybe(); } public function getBuildNumber() : string { diff --git a/vendor/ondram/ci-detector/src/Ci/SourceHut.php b/vendor/ondram/ci-detector/src/Ci/SourceHut.php index de253de19c1..f87021aafa9 100644 --- a/vendor/ondram/ci-detector/src/Ci/SourceHut.php +++ b/vendor/ondram/ci-detector/src/Ci/SourceHut.php @@ -6,19 +6,19 @@ namespace RectorPrefix20220607\OndraM\CiDetector\Ci; use RectorPrefix20220607\OndraM\CiDetector\CiDetector; use RectorPrefix20220607\OndraM\CiDetector\Env; use RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic; -class SourceHut extends \RectorPrefix20220607\OndraM\CiDetector\Ci\AbstractCi +class SourceHut extends AbstractCi { - public static function isDetected(\RectorPrefix20220607\OndraM\CiDetector\Env $env) : bool + public static function isDetected(Env $env) : bool { return $env->getString('CI_NAME') === 'sourcehut'; } public function getCiName() : string { - return \RectorPrefix20220607\OndraM\CiDetector\CiDetector::CI_SOURCEHUT; + return CiDetector::CI_SOURCEHUT; } - public function isPullRequest() : \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic + public function isPullRequest() : TrinaryLogic { - return \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic::createFromBoolean($this->env->getString('BUILD_REASON') === 'patchset'); + return TrinaryLogic::createFromBoolean($this->env->getString('BUILD_REASON') === 'patchset'); } public function getBuildNumber() : string { diff --git a/vendor/ondram/ci-detector/src/Ci/TeamCity.php b/vendor/ondram/ci-detector/src/Ci/TeamCity.php index 70f37c631d4..77361acae76 100644 --- a/vendor/ondram/ci-detector/src/Ci/TeamCity.php +++ b/vendor/ondram/ci-detector/src/Ci/TeamCity.php @@ -6,19 +6,19 @@ namespace RectorPrefix20220607\OndraM\CiDetector\Ci; use RectorPrefix20220607\OndraM\CiDetector\CiDetector; use RectorPrefix20220607\OndraM\CiDetector\Env; use RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic; -class TeamCity extends \RectorPrefix20220607\OndraM\CiDetector\Ci\AbstractCi +class TeamCity extends AbstractCi { - public static function isDetected(\RectorPrefix20220607\OndraM\CiDetector\Env $env) : bool + public static function isDetected(Env $env) : bool { return $env->get('TEAMCITY_VERSION') !== \false; } public function getCiName() : string { - return \RectorPrefix20220607\OndraM\CiDetector\CiDetector::CI_TEAMCITY; + return CiDetector::CI_TEAMCITY; } - public function isPullRequest() : \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic + public function isPullRequest() : TrinaryLogic { - return \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic::createMaybe(); + return TrinaryLogic::createMaybe(); } public function getBuildNumber() : string { diff --git a/vendor/ondram/ci-detector/src/Ci/Travis.php b/vendor/ondram/ci-detector/src/Ci/Travis.php index b169543aa95..b392a2a11fe 100644 --- a/vendor/ondram/ci-detector/src/Ci/Travis.php +++ b/vendor/ondram/ci-detector/src/Ci/Travis.php @@ -6,19 +6,19 @@ namespace RectorPrefix20220607\OndraM\CiDetector\Ci; use RectorPrefix20220607\OndraM\CiDetector\CiDetector; use RectorPrefix20220607\OndraM\CiDetector\Env; use RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic; -class Travis extends \RectorPrefix20220607\OndraM\CiDetector\Ci\AbstractCi +class Travis extends AbstractCi { - public static function isDetected(\RectorPrefix20220607\OndraM\CiDetector\Env $env) : bool + public static function isDetected(Env $env) : bool { return $env->get('TRAVIS') !== \false; } public function getCiName() : string { - return \RectorPrefix20220607\OndraM\CiDetector\CiDetector::CI_TRAVIS; + return CiDetector::CI_TRAVIS; } - public function isPullRequest() : \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic + public function isPullRequest() : TrinaryLogic { - return \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic::createFromBoolean($this->env->getString('TRAVIS_PULL_REQUEST') !== 'false'); + return TrinaryLogic::createFromBoolean($this->env->getString('TRAVIS_PULL_REQUEST') !== 'false'); } public function getBuildNumber() : string { diff --git a/vendor/ondram/ci-detector/src/Ci/Wercker.php b/vendor/ondram/ci-detector/src/Ci/Wercker.php index c4d10a90b3e..a19e76d1b4e 100644 --- a/vendor/ondram/ci-detector/src/Ci/Wercker.php +++ b/vendor/ondram/ci-detector/src/Ci/Wercker.php @@ -6,19 +6,19 @@ namespace RectorPrefix20220607\OndraM\CiDetector\Ci; use RectorPrefix20220607\OndraM\CiDetector\CiDetector; use RectorPrefix20220607\OndraM\CiDetector\Env; use RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic; -class Wercker extends \RectorPrefix20220607\OndraM\CiDetector\Ci\AbstractCi +class Wercker extends AbstractCi { - public static function isDetected(\RectorPrefix20220607\OndraM\CiDetector\Env $env) : bool + public static function isDetected(Env $env) : bool { return $env->get('WERCKER') === 'true'; } public function getCiName() : string { - return \RectorPrefix20220607\OndraM\CiDetector\CiDetector::CI_WERCKER; + return CiDetector::CI_WERCKER; } - public function isPullRequest() : \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic + public function isPullRequest() : TrinaryLogic { - return \RectorPrefix20220607\OndraM\CiDetector\TrinaryLogic::createMaybe(); + return TrinaryLogic::createMaybe(); } public function getBuildNumber() : string { diff --git a/vendor/ondram/ci-detector/src/CiDetector.php b/vendor/ondram/ci-detector/src/CiDetector.php index c70bdad64f0..85531e6c43b 100644 --- a/vendor/ondram/ci-detector/src/CiDetector.php +++ b/vendor/ondram/ci-detector/src/CiDetector.php @@ -8,7 +8,7 @@ use RectorPrefix20220607\OndraM\CiDetector\Exception\CiNotDetectedException; /** * Unified way to get environment variables from current continuous integration server */ -class CiDetector implements \RectorPrefix20220607\OndraM\CiDetector\CiDetectorInterface +class CiDetector implements CiDetectorInterface { public const CI_APPVEYOR = 'AppVeyor'; public const CI_AWS_CODEBUILD = 'AWS CodeBuild'; @@ -31,9 +31,9 @@ class CiDetector implements \RectorPrefix20220607\OndraM\CiDetector\CiDetectorIn private $environment; public final function __construct() { - $this->environment = new \RectorPrefix20220607\OndraM\CiDetector\Env(); + $this->environment = new Env(); } - public static function fromEnvironment(\RectorPrefix20220607\OndraM\CiDetector\Env $environment) : self + public static function fromEnvironment(Env $environment) : self { $detector = new static(); $detector->environment = $environment; @@ -44,11 +44,11 @@ class CiDetector implements \RectorPrefix20220607\OndraM\CiDetector\CiDetectorIn $ciServer = $this->detectCurrentCiServer(); return $ciServer !== null; } - public function detect() : \RectorPrefix20220607\OndraM\CiDetector\Ci\CiInterface + public function detect() : CiInterface { $ciServer = $this->detectCurrentCiServer(); if ($ciServer === null) { - throw new \RectorPrefix20220607\OndraM\CiDetector\Exception\CiNotDetectedException('No CI server detected in current environment'); + throw new CiNotDetectedException('No CI server detected in current environment'); } return $ciServer; } @@ -57,9 +57,9 @@ class CiDetector implements \RectorPrefix20220607\OndraM\CiDetector\CiDetectorIn */ protected function getCiServers() : array { - return [\RectorPrefix20220607\OndraM\CiDetector\Ci\AppVeyor::class, \RectorPrefix20220607\OndraM\CiDetector\Ci\AwsCodeBuild::class, \RectorPrefix20220607\OndraM\CiDetector\Ci\AzurePipelines::class, \RectorPrefix20220607\OndraM\CiDetector\Ci\Bamboo::class, \RectorPrefix20220607\OndraM\CiDetector\Ci\BitbucketPipelines::class, \RectorPrefix20220607\OndraM\CiDetector\Ci\Buddy::class, \RectorPrefix20220607\OndraM\CiDetector\Ci\Circle::class, \RectorPrefix20220607\OndraM\CiDetector\Ci\Codeship::class, \RectorPrefix20220607\OndraM\CiDetector\Ci\Continuousphp::class, \RectorPrefix20220607\OndraM\CiDetector\Ci\Drone::class, \RectorPrefix20220607\OndraM\CiDetector\Ci\GitHubActions::class, \RectorPrefix20220607\OndraM\CiDetector\Ci\GitLab::class, \RectorPrefix20220607\OndraM\CiDetector\Ci\Jenkins::class, \RectorPrefix20220607\OndraM\CiDetector\Ci\SourceHut::class, \RectorPrefix20220607\OndraM\CiDetector\Ci\TeamCity::class, \RectorPrefix20220607\OndraM\CiDetector\Ci\Travis::class, \RectorPrefix20220607\OndraM\CiDetector\Ci\Wercker::class]; + return [Ci\AppVeyor::class, Ci\AwsCodeBuild::class, Ci\AzurePipelines::class, Ci\Bamboo::class, Ci\BitbucketPipelines::class, Ci\Buddy::class, Ci\Circle::class, Ci\Codeship::class, Ci\Continuousphp::class, Ci\Drone::class, Ci\GitHubActions::class, Ci\GitLab::class, Ci\Jenkins::class, Ci\SourceHut::class, Ci\TeamCity::class, Ci\Travis::class, Ci\Wercker::class]; } - protected function detectCurrentCiServer() : ?\RectorPrefix20220607\OndraM\CiDetector\Ci\CiInterface + protected function detectCurrentCiServer() : ?CiInterface { $ciServers = $this->getCiServers(); foreach ($ciServers as $ciClass) { diff --git a/vendor/ondram/ci-detector/src/CiDetectorInterface.php b/vendor/ondram/ci-detector/src/CiDetectorInterface.php index 3fe18ec4864..88ac0865dec 100644 --- a/vendor/ondram/ci-detector/src/CiDetectorInterface.php +++ b/vendor/ondram/ci-detector/src/CiDetectorInterface.php @@ -19,5 +19,5 @@ interface CiDetectorInterface * * @throws CiNotDetectedException */ - public function detect() : \RectorPrefix20220607\OndraM\CiDetector\Ci\CiInterface; + public function detect() : CiInterface; } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprArrayNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprArrayNode.php index 8b346956f08..7b463fe7889 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprArrayNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprArrayNode.php @@ -19,6 +19,6 @@ class ConstExprArrayNode implements \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExp } public function __toString() : string { - return '[' . \implode(', ', $this->items) . ']'; + return '[' . implode(', ', $this->items) . ']'; } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprNode.php index 17b74390245..cb19771793e 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprNode.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace PHPStan\PhpDocParser\Ast\ConstExpr; use PHPStan\PhpDocParser\Ast\Node; -interface ConstExprNode extends \PHPStan\PhpDocParser\Ast\Node +interface ConstExprNode extends Node { } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/NodeAttributes.php b/vendor/phpstan/phpdoc-parser/src/Ast/NodeAttributes.php index 4611ce5b8d1..fbd4e00b8d6 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/NodeAttributes.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/NodeAttributes.php @@ -17,7 +17,7 @@ trait NodeAttributes } public function hasAttribute(string $key) : bool { - return \array_key_exists($key, $this->attributes); + return array_key_exists($key, $this->attributes); } /** * @return mixed diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/AssertTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/AssertTagValueNode.php index 3f62ca363e6..885334c3c90 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/AssertTagValueNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/AssertTagValueNode.php @@ -17,7 +17,7 @@ class AssertTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagVa public $isNegated; /** @var string (may be empty) */ public $description; - public function __construct(\PHPStan\PhpDocParser\Ast\Type\TypeNode $type, string $parameter, bool $isNegated, string $description) + public function __construct(TypeNode $type, string $parameter, bool $isNegated, string $description) { $this->type = $type; $this->parameter = $parameter; @@ -27,6 +27,6 @@ class AssertTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagVa public function __toString() : string { $isNegated = $this->isNegated ? '!' : ''; - return \trim("{$this->type} {$isNegated}{$this->parameter} {$this->description}"); + return trim("{$this->type} {$isNegated}{$this->parameter} {$this->description}"); } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/DeprecatedTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/DeprecatedTagValueNode.php index 3ecd192ad07..8199bef6a8c 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/DeprecatedTagValueNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/DeprecatedTagValueNode.php @@ -16,6 +16,6 @@ class DeprecatedTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocT } public function __toString() : string { - return \trim($this->description); + return trim($this->description); } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ExtendsTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ExtendsTagValueNode.php index cbad1ec8f1d..31eeaaa5901 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ExtendsTagValueNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ExtendsTagValueNode.php @@ -13,13 +13,13 @@ class ExtendsTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagV public $type; /** @var string (may be empty) */ public $description; - public function __construct(\PHPStan\PhpDocParser\Ast\Type\GenericTypeNode $type, string $description) + public function __construct(GenericTypeNode $type, string $description) { $this->type = $type; $this->description = $description; } public function __toString() : string { - return \trim("{$this->type} {$this->description}"); + return trim("{$this->type} {$this->description}"); } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ImplementsTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ImplementsTagValueNode.php index e958905c85b..1f4d6afc274 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ImplementsTagValueNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ImplementsTagValueNode.php @@ -13,13 +13,13 @@ class ImplementsTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocT public $type; /** @var string (may be empty) */ public $description; - public function __construct(\PHPStan\PhpDocParser\Ast\Type\GenericTypeNode $type, string $description) + public function __construct(GenericTypeNode $type, string $description) { $this->type = $type; $this->description = $description; } public function __toString() : string { - return \trim("{$this->type} {$this->description}"); + return trim("{$this->type} {$this->description}"); } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/InvalidTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/InvalidTagValueNode.php index 544f504e144..b6ba4b04a40 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/InvalidTagValueNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/InvalidTagValueNode.php @@ -18,7 +18,7 @@ class InvalidTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagV public $value; /** @var mixed[] */ private $exceptionArgs; - public function __construct(string $value, \PHPStan\PhpDocParser\Parser\ParserException $exception) + public function __construct(string $value, ParserException $exception) { $this->value = $value; $this->exceptionArgs = [$exception->getCurrentTokenValue(), $exception->getCurrentTokenType(), $exception->getCurrentOffset(), $exception->getExpectedTokenType(), $exception->getExpectedTokenValue()]; @@ -26,10 +26,10 @@ class InvalidTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagV public function __get(string $name) { if ($name !== 'exception') { - \trigger_error(\sprintf('Undefined property: %s::$%s', self::class, $name), \E_USER_WARNING); + trigger_error(sprintf('Undefined property: %s::$%s', self::class, $name), E_USER_WARNING); return null; } - return new \PHPStan\PhpDocParser\Parser\ParserException(...$this->exceptionArgs); + return new ParserException(...$this->exceptionArgs); } public function __toString() : string { diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MethodTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MethodTagValueNode.php index 98b0f9efb2d..b6012f3a90a 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MethodTagValueNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MethodTagValueNode.php @@ -19,7 +19,7 @@ class MethodTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagVa public $parameters; /** @var string (may be empty) */ public $description; - public function __construct(bool $isStatic, ?\PHPStan\PhpDocParser\Ast\Type\TypeNode $returnType, string $methodName, array $parameters, string $description) + public function __construct(bool $isStatic, ?TypeNode $returnType, string $methodName, array $parameters, string $description) { $this->isStatic = $isStatic; $this->returnType = $returnType; @@ -31,7 +31,7 @@ class MethodTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagVa { $static = $this->isStatic ? 'static ' : ''; $returnType = $this->returnType !== null ? "{$this->returnType} " : ''; - $parameters = \implode(', ', $this->parameters); + $parameters = implode(', ', $this->parameters); $description = $this->description !== '' ? " {$this->description}" : ''; return "{$static}{$returnType}{$this->methodName}({$parameters}){$description}"; } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MethodTagValueParameterNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MethodTagValueParameterNode.php index 625dad2dbdc..3d45e70b7d4 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MethodTagValueParameterNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MethodTagValueParameterNode.php @@ -7,7 +7,7 @@ use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode; use PHPStan\PhpDocParser\Ast\Node; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; -class MethodTagValueParameterNode implements \PHPStan\PhpDocParser\Ast\Node +class MethodTagValueParameterNode implements Node { use NodeAttributes; /** @var TypeNode|null */ @@ -20,7 +20,7 @@ class MethodTagValueParameterNode implements \PHPStan\PhpDocParser\Ast\Node public $parameterName; /** @var ConstExprNode|null */ public $defaultValue; - public function __construct(?\PHPStan\PhpDocParser\Ast\Type\TypeNode $type, bool $isReference, bool $isVariadic, string $parameterName, ?\PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode $defaultValue) + public function __construct(?TypeNode $type, bool $isReference, bool $isVariadic, string $parameterName, ?ConstExprNode $defaultValue) { $this->type = $type; $this->isReference = $isReference; diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MixinTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MixinTagValueNode.php index eab73013866..e7138d59ad5 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MixinTagValueNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MixinTagValueNode.php @@ -13,13 +13,13 @@ class MixinTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagVal public $type; /** @var string (may be empty) */ public $description; - public function __construct(\PHPStan\PhpDocParser\Ast\Type\TypeNode $type, string $description) + public function __construct(TypeNode $type, string $description) { $this->type = $type; $this->description = $description; } public function __toString() : string { - return \trim("{$this->type} {$this->description}"); + return trim("{$this->type} {$this->description}"); } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamTagValueNode.php index e7bd876968d..b7e7991058d 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamTagValueNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamTagValueNode.php @@ -19,7 +19,7 @@ class ParamTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagVal public $parameterName; /** @var string (may be empty) */ public $description; - public function __construct(\PHPStan\PhpDocParser\Ast\Type\TypeNode $type, bool $isVariadic, string $parameterName, string $description, bool $isReference = \false) + public function __construct(TypeNode $type, bool $isVariadic, string $parameterName, string $description, bool $isReference = \false) { $this->type = $type; $this->isReference = $isReference; @@ -31,6 +31,6 @@ class ParamTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagVal { $reference = $this->isReference ? '&' : ''; $variadic = $this->isVariadic ? '...' : ''; - return \trim("{$this->type} {$reference}{$variadic}{$this->parameterName} {$this->description}"); + return trim("{$this->type} {$reference}{$variadic}{$this->parameterName} {$this->description}"); } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocChildNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocChildNode.php index 5dfc267a6e0..1a4c8bc94c0 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocChildNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocChildNode.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\Node; -interface PhpDocChildNode extends \PHPStan\PhpDocParser\Ast\Node +interface PhpDocChildNode extends Node { } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocNode.php index 2c9f7935ad9..4768599a7c5 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocNode.php @@ -9,7 +9,7 @@ use function array_column; use function array_filter; use function array_map; use function implode; -class PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node +class PhpDocNode implements Node { use NodeAttributes; /** @var PhpDocChildNode[] */ @@ -26,7 +26,7 @@ class PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node */ public function getTags() : array { - return \array_filter($this->children, static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $child) : bool { + return array_filter($this->children, static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $child) : bool { return $child instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode; }); } @@ -35,7 +35,7 @@ class PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node */ public function getTagsByName(string $tagName) : array { - return \array_filter($this->getTags(), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode $tag) use($tagName) : bool { + return array_filter($this->getTags(), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode $tag) use($tagName) : bool { return $tag->name === $tagName; }); } @@ -44,7 +44,7 @@ class PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node */ public function getVarTagValues(string $tagName = '@var') : array { - return \array_filter(\array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { + return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { return $value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode; }); } @@ -53,7 +53,7 @@ class PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node */ public function getParamTagValues(string $tagName = '@param') : array { - return \array_filter(\array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { + return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { return $value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode; }); } @@ -62,7 +62,7 @@ class PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node */ public function getTemplateTagValues(string $tagName = '@template') : array { - return \array_filter(\array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { + return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { return $value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode; }); } @@ -71,7 +71,7 @@ class PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node */ public function getExtendsTagValues(string $tagName = '@extends') : array { - return \array_filter(\array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { + return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { return $value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ExtendsTagValueNode; }); } @@ -80,7 +80,7 @@ class PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node */ public function getImplementsTagValues(string $tagName = '@implements') : array { - return \array_filter(\array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { + return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { return $value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ImplementsTagValueNode; }); } @@ -89,7 +89,7 @@ class PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node */ public function getUsesTagValues(string $tagName = '@use') : array { - return \array_filter(\array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { + return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { return $value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\UsesTagValueNode; }); } @@ -98,7 +98,7 @@ class PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node */ public function getReturnTagValues(string $tagName = '@return') : array { - return \array_filter(\array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { + return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { return $value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode; }); } @@ -107,7 +107,7 @@ class PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node */ public function getThrowsTagValues(string $tagName = '@throws') : array { - return \array_filter(\array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { + return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { return $value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode; }); } @@ -116,7 +116,7 @@ class PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node */ public function getMixinTagValues(string $tagName = '@mixin') : array { - return \array_filter(\array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { + return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { return $value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\MixinTagValueNode; }); } @@ -125,7 +125,7 @@ class PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node */ public function getDeprecatedTagValues() : array { - return \array_filter(\array_column($this->getTagsByName('@deprecated'), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { + return array_filter(array_column($this->getTagsByName('@deprecated'), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { return $value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\DeprecatedTagValueNode; }); } @@ -134,7 +134,7 @@ class PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node */ public function getPropertyTagValues(string $tagName = '@property') : array { - return \array_filter(\array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { + return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { return $value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode; }); } @@ -143,7 +143,7 @@ class PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node */ public function getPropertyReadTagValues(string $tagName = '@property-read') : array { - return \array_filter(\array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { + return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { return $value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode; }); } @@ -152,7 +152,7 @@ class PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node */ public function getPropertyWriteTagValues(string $tagName = '@property-write') : array { - return \array_filter(\array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { + return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { return $value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode; }); } @@ -161,7 +161,7 @@ class PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node */ public function getMethodTagValues(string $tagName = '@method') : array { - return \array_filter(\array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { + return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { return $value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueNode; }); } @@ -170,7 +170,7 @@ class PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node */ public function getTypeAliasTagValues(string $tagName = '@phpstan-type') : array { - return \array_filter(\array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { + return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { return $value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\TypeAliasTagValueNode; }); } @@ -179,7 +179,7 @@ class PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node */ public function getTypeAliasImportTagValues(string $tagName = '@phpstan-import-type') : array { - return \array_filter(\array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { + return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { return $value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\TypeAliasImportTagValueNode; }); } @@ -188,16 +188,16 @@ class PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node */ public function getAssertTagValues(string $tagName = '@phpstan-assert') : array { - return \array_filter(\array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { + return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool { return $value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\AssertTagValueNode; }); } public function __toString() : string { - $children = \array_map(static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $child) : string { + $children = array_map(static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $child) : string { $s = (string) $child; return $s === '' ? '' : ' ' . $s; }, $this->children); - return "/**\n *" . \implode("\n *", $children) . "\n */"; + return "/**\n *" . implode("\n *", $children) . "\n */"; } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocTagNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocTagNode.php index 30be7b95749..20a984ac4fa 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocTagNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocTagNode.php @@ -19,6 +19,6 @@ class PhpDocTagNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode } public function __toString() : string { - return \trim("{$this->name} {$this->value}"); + return trim("{$this->name} {$this->value}"); } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocTagValueNode.php index 730fb073c51..15566fe1f2b 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocTagValueNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocTagValueNode.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\Node; -interface PhpDocTagValueNode extends \PHPStan\PhpDocParser\Ast\Node +interface PhpDocTagValueNode extends Node { } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PropertyTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PropertyTagValueNode.php index 0549286cccb..4cadbeec1a3 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PropertyTagValueNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PropertyTagValueNode.php @@ -15,7 +15,7 @@ class PropertyTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTag public $propertyName; /** @var string (may be empty) */ public $description; - public function __construct(\PHPStan\PhpDocParser\Ast\Type\TypeNode $type, string $propertyName, string $description) + public function __construct(TypeNode $type, string $propertyName, string $description) { $this->type = $type; $this->propertyName = $propertyName; @@ -23,6 +23,6 @@ class PropertyTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTag } public function __toString() : string { - return \trim("{$this->type} {$this->propertyName} {$this->description}"); + return trim("{$this->type} {$this->propertyName} {$this->description}"); } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ReturnTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ReturnTagValueNode.php index ee88515a7b5..e3fb544ee28 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ReturnTagValueNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ReturnTagValueNode.php @@ -13,13 +13,13 @@ class ReturnTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagVa public $type; /** @var string (may be empty) */ public $description; - public function __construct(\PHPStan\PhpDocParser\Ast\Type\TypeNode $type, string $description) + public function __construct(TypeNode $type, string $description) { $this->type = $type; $this->description = $description; } public function __toString() : string { - return \trim("{$this->type} {$this->description}"); + return trim("{$this->type} {$this->description}"); } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TemplateTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TemplateTagValueNode.php index 6a1ede8aa65..e7495160ec0 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TemplateTagValueNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TemplateTagValueNode.php @@ -15,7 +15,7 @@ class TemplateTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTag public $bound; /** @var string (may be empty) */ public $description; - public function __construct(string $name, ?\PHPStan\PhpDocParser\Ast\Type\TypeNode $bound, string $description) + public function __construct(string $name, ?TypeNode $bound, string $description) { $this->name = $name; $this->bound = $bound; @@ -24,6 +24,6 @@ class TemplateTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTag public function __toString() : string { $bound = $this->bound !== null ? " of {$this->bound}" : ''; - return \trim("{$this->name}{$bound} {$this->description}"); + return trim("{$this->name}{$bound} {$this->description}"); } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ThrowsTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ThrowsTagValueNode.php index 75db89ef341..02bf48f8c4f 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ThrowsTagValueNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ThrowsTagValueNode.php @@ -13,13 +13,13 @@ class ThrowsTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagVa public $type; /** @var string (may be empty) */ public $description; - public function __construct(\PHPStan\PhpDocParser\Ast\Type\TypeNode $type, string $description) + public function __construct(TypeNode $type, string $description) { $this->type = $type; $this->description = $description; } public function __toString() : string { - return \trim("{$this->type} {$this->description}"); + return trim("{$this->type} {$this->description}"); } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TypeAliasImportTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TypeAliasImportTagValueNode.php index 94f7341783a..2a1f390882b 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TypeAliasImportTagValueNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TypeAliasImportTagValueNode.php @@ -15,7 +15,7 @@ class TypeAliasImportTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\Ph public $importedFrom; /** @var string|null */ public $importedAs; - public function __construct(string $importedAlias, \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode $importedFrom, ?string $importedAs) + public function __construct(string $importedAlias, IdentifierTypeNode $importedFrom, ?string $importedAs) { $this->importedAlias = $importedAlias; $this->importedFrom = $importedFrom; @@ -23,6 +23,6 @@ class TypeAliasImportTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\Ph } public function __toString() : string { - return \trim("{$this->importedAlias} from {$this->importedFrom}" . ($this->importedAs !== null ? " as {$this->importedAs}" : '')); + return trim("{$this->importedAlias} from {$this->importedFrom}" . ($this->importedAs !== null ? " as {$this->importedAs}" : '')); } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TypeAliasTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TypeAliasTagValueNode.php index a78469054bf..3b41363c11d 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TypeAliasTagValueNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TypeAliasTagValueNode.php @@ -13,13 +13,13 @@ class TypeAliasTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTa public $alias; /** @var TypeNode */ public $type; - public function __construct(string $alias, \PHPStan\PhpDocParser\Ast\Type\TypeNode $type) + public function __construct(string $alias, TypeNode $type) { $this->alias = $alias; $this->type = $type; } public function __toString() : string { - return \trim("{$this->alias} {$this->type}"); + return trim("{$this->alias} {$this->type}"); } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/UsesTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/UsesTagValueNode.php index 1d6a324582b..98ab9c66c42 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/UsesTagValueNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/UsesTagValueNode.php @@ -13,13 +13,13 @@ class UsesTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValu public $type; /** @var string (may be empty) */ public $description; - public function __construct(\PHPStan\PhpDocParser\Ast\Type\GenericTypeNode $type, string $description) + public function __construct(GenericTypeNode $type, string $description) { $this->type = $type; $this->description = $description; } public function __toString() : string { - return \trim("{$this->type} {$this->description}"); + return trim("{$this->type} {$this->description}"); } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/VarTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/VarTagValueNode.php index c7b9a228192..345f27c2c1a 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/VarTagValueNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/VarTagValueNode.php @@ -15,7 +15,7 @@ class VarTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValue public $variableName; /** @var string (may be empty) */ public $description; - public function __construct(\PHPStan\PhpDocParser\Ast\Type\TypeNode $type, string $variableName, string $description) + public function __construct(TypeNode $type, string $variableName, string $description) { $this->type = $type; $this->variableName = $variableName; @@ -23,6 +23,6 @@ class VarTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValue } public function __toString() : string { - return \trim("{$this->type} " . \trim("{$this->variableName} {$this->description}")); + return trim("{$this->type} " . trim("{$this->variableName} {$this->description}")); } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/ArrayShapeItemNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ArrayShapeItemNode.php index 7b0af273050..d421a1ce010 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/Type/ArrayShapeItemNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ArrayShapeItemNode.php @@ -28,7 +28,7 @@ class ArrayShapeItemNode implements \PHPStan\PhpDocParser\Ast\Type\TypeNode public function __toString() : string { if ($this->keyName !== null) { - return \sprintf('%s%s: %s', (string) $this->keyName, $this->optional ? '?' : '', (string) $this->valueType); + return sprintf('%s%s: %s', (string) $this->keyName, $this->optional ? '?' : '', (string) $this->valueType); } return (string) $this->valueType; } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/ArrayShapeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ArrayShapeNode.php index 7e0a67ceee8..2234620c30f 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/Type/ArrayShapeNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ArrayShapeNode.php @@ -16,6 +16,6 @@ class ArrayShapeNode implements \PHPStan\PhpDocParser\Ast\Type\TypeNode } public function __toString() : string { - return 'array{' . \implode(', ', $this->items) . '}'; + return 'array{' . implode(', ', $this->items) . '}'; } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/CallableTypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/CallableTypeNode.php index 3a7190ffbd8..0fe7b9310ea 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/Type/CallableTypeNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/CallableTypeNode.php @@ -22,7 +22,7 @@ class CallableTypeNode implements \PHPStan\PhpDocParser\Ast\Type\TypeNode } public function __toString() : string { - $parameters = \implode(', ', $this->parameters); + $parameters = implode(', ', $this->parameters); return "{$this->identifier}({$parameters}): {$this->returnType}"; } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/CallableTypeParameterNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/CallableTypeParameterNode.php index 41fe84f9f42..10b65b3ed51 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/Type/CallableTypeParameterNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/CallableTypeParameterNode.php @@ -5,7 +5,7 @@ namespace PHPStan\PhpDocParser\Ast\Type; use PHPStan\PhpDocParser\Ast\Node; use PHPStan\PhpDocParser\Ast\NodeAttributes; -class CallableTypeParameterNode implements \PHPStan\PhpDocParser\Ast\Node +class CallableTypeParameterNode implements Node { use NodeAttributes; /** @var TypeNode */ diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConditionalTypeForParameterNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConditionalTypeForParameterNode.php index 5ed0ecf31ea..0f4065dc219 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConditionalTypeForParameterNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConditionalTypeForParameterNode.php @@ -28,6 +28,6 @@ class ConditionalTypeForParameterNode implements \PHPStan\PhpDocParser\Ast\Type\ } public function __toString() : string { - return \sprintf('(%s %s %s ? %s : %s)', $this->parameterName, $this->negated ? 'is not' : 'is', $this->targetType, $this->if, $this->else); + return sprintf('(%s %s %s ? %s : %s)', $this->parameterName, $this->negated ? 'is not' : 'is', $this->targetType, $this->if, $this->else); } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConditionalTypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConditionalTypeNode.php index f2778b86dfe..fcd5b1b5a5f 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConditionalTypeNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConditionalTypeNode.php @@ -28,6 +28,6 @@ class ConditionalTypeNode implements \PHPStan\PhpDocParser\Ast\Type\TypeNode } public function __toString() : string { - return \sprintf('(%s %s %s ? %s : %s)', $this->subjectType, $this->negated ? 'is not' : 'is', $this->targetType, $this->if, $this->else); + return sprintf('(%s %s %s ? %s : %s)', $this->subjectType, $this->negated ? 'is not' : 'is', $this->targetType, $this->if, $this->else); } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConstTypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConstTypeNode.php index 331108985d0..45d03a3bc2d 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConstTypeNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConstTypeNode.php @@ -10,7 +10,7 @@ class ConstTypeNode implements \PHPStan\PhpDocParser\Ast\Type\TypeNode use NodeAttributes; /** @var ConstExprNode */ public $constExpr; - public function __construct(\PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode $constExpr) + public function __construct(ConstExprNode $constExpr) { $this->constExpr = $constExpr; } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/GenericTypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/GenericTypeNode.php index 55d8861531e..85261fd49a5 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/Type/GenericTypeNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/GenericTypeNode.php @@ -19,6 +19,6 @@ class GenericTypeNode implements \PHPStan\PhpDocParser\Ast\Type\TypeNode } public function __toString() : string { - return $this->type . '<' . \implode(', ', $this->genericTypes) . '>'; + return $this->type . '<' . implode(', ', $this->genericTypes) . '>'; } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/IntersectionTypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/IntersectionTypeNode.php index d507276c4d7..c7157c35eda 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/Type/IntersectionTypeNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/IntersectionTypeNode.php @@ -16,6 +16,6 @@ class IntersectionTypeNode implements \PHPStan\PhpDocParser\Ast\Type\TypeNode } public function __toString() : string { - return '(' . \implode(' & ', $this->types) . ')'; + return '(' . implode(' & ', $this->types) . ')'; } } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/TypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/TypeNode.php index befc4d04271..4c1bd300c86 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/Type/TypeNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/TypeNode.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace PHPStan\PhpDocParser\Ast\Type; use PHPStan\PhpDocParser\Ast\Node; -interface TypeNode extends \PHPStan\PhpDocParser\Ast\Node +interface TypeNode extends Node { } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/UnionTypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/UnionTypeNode.php index f15234d7d8b..d7e55b97aa9 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/Type/UnionTypeNode.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/UnionTypeNode.php @@ -16,6 +16,6 @@ class UnionTypeNode implements \PHPStan\PhpDocParser\Ast\Type\TypeNode } public function __toString() : string { - return '(' . \implode(' | ', $this->types) . ')'; + return '(' . implode(' | ', $this->types) . ')'; } } diff --git a/vendor/phpstan/phpdoc-parser/src/Lexer/Lexer.php b/vendor/phpstan/phpdoc-parser/src/Lexer/Lexer.php index 82da6fc1c07..b84d62e1d78 100644 --- a/vendor/phpstan/phpdoc-parser/src/Lexer/Lexer.php +++ b/vendor/phpstan/phpdoc-parser/src/Lexer/Lexer.php @@ -60,10 +60,10 @@ class Lexer if ($this->regexp === null || $this->types === null) { $this->initialize(); } - \assert($this->regexp !== null); - \assert($this->types !== null); - \preg_match_all($this->regexp, $s, $tokens, \PREG_SET_ORDER); - $count = \count($this->types); + assert($this->regexp !== null); + assert($this->types !== null); + preg_match_all($this->regexp, $s, $tokens, PREG_SET_ORDER); + $count = count($this->types); foreach ($tokens as &$match) { for ($i = 1; $i <= $count; $i++) { if ($match[$i] !== null && $match[$i] !== '') { @@ -114,7 +114,7 @@ class Lexer // anything but TOKEN_CLOSE_PHPDOC or TOKEN_HORIZONTAL_WS or TOKEN_EOL self::TOKEN_OTHER => '(?:(?!\\*/)[^\\s])++', ]; - $this->regexp = '~(' . \implode(')|(', $patterns) . ')~Asi'; - $this->types = \array_keys($patterns); + $this->regexp = '~(' . implode(')|(', $patterns) . ')~Asi'; + $this->types = array_keys($patterns); } } diff --git a/vendor/phpstan/phpdoc-parser/src/Parser/ConstExprParser.php b/vendor/phpstan/phpdoc-parser/src/Parser/ConstExprParser.php index 5df37ba1dcf..905be984315 100644 --- a/vendor/phpstan/phpdoc-parser/src/Parser/ConstExprParser.php +++ b/vendor/phpstan/phpdoc-parser/src/Parser/ConstExprParser.php @@ -9,59 +9,59 @@ use function strtolower; use function trim; class ConstExprParser { - public function parse(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, bool $trimStrings = \false) : \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode + public function parse(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, bool $trimStrings = \false) : Ast\ConstExpr\ConstExprNode { - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_FLOAT)) { + if ($tokens->isCurrentTokenType(Lexer::TOKEN_FLOAT)) { $value = $tokens->currentTokenValue(); $tokens->next(); - return new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprFloatNode($value); + return new Ast\ConstExpr\ConstExprFloatNode($value); } - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_INTEGER)) { + if ($tokens->isCurrentTokenType(Lexer::TOKEN_INTEGER)) { $value = $tokens->currentTokenValue(); $tokens->next(); - return new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode($value); + return new Ast\ConstExpr\ConstExprIntegerNode($value); } - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_SINGLE_QUOTED_STRING)) { + if ($tokens->isCurrentTokenType(Lexer::TOKEN_SINGLE_QUOTED_STRING)) { $value = $tokens->currentTokenValue(); if ($trimStrings) { - $value = \trim($tokens->currentTokenValue(), "'"); + $value = trim($tokens->currentTokenValue(), "'"); } $tokens->next(); - return new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprStringNode($value); - } elseif ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_DOUBLE_QUOTED_STRING)) { + return new Ast\ConstExpr\ConstExprStringNode($value); + } elseif ($tokens->isCurrentTokenType(Lexer::TOKEN_DOUBLE_QUOTED_STRING)) { $value = $tokens->currentTokenValue(); if ($trimStrings) { - $value = \trim($tokens->currentTokenValue(), '"'); + $value = trim($tokens->currentTokenValue(), '"'); } $tokens->next(); - return new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprStringNode($value); - } elseif ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER)) { + return new Ast\ConstExpr\ConstExprStringNode($value); + } elseif ($tokens->isCurrentTokenType(Lexer::TOKEN_IDENTIFIER)) { $identifier = $tokens->currentTokenValue(); $tokens->next(); - switch (\strtolower($identifier)) { + switch (strtolower($identifier)) { case 'true': - return new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprTrueNode(); + return new Ast\ConstExpr\ConstExprTrueNode(); case 'false': - return new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprFalseNode(); + return new Ast\ConstExpr\ConstExprFalseNode(); case 'null': - return new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNullNode(); + return new Ast\ConstExpr\ConstExprNullNode(); case 'array': - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES); - return $this->parseArray($tokens, \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES); + $tokens->consumeTokenType(Lexer::TOKEN_OPEN_PARENTHESES); + return $this->parseArray($tokens, Lexer::TOKEN_CLOSE_PARENTHESES); } - if ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_DOUBLE_COLON)) { + if ($tokens->tryConsumeTokenType(Lexer::TOKEN_DOUBLE_COLON)) { $classConstantName = ''; $lastType = null; while (\true) { - if ($lastType !== \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER && $tokens->currentTokenType() === \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER) { + if ($lastType !== Lexer::TOKEN_IDENTIFIER && $tokens->currentTokenType() === Lexer::TOKEN_IDENTIFIER) { $classConstantName .= $tokens->currentTokenValue(); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER); - $lastType = \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER; + $tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER); + $lastType = Lexer::TOKEN_IDENTIFIER; continue; } - if ($lastType !== \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_WILDCARD && $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_WILDCARD)) { + if ($lastType !== Lexer::TOKEN_WILDCARD && $tokens->tryConsumeTokenType(Lexer::TOKEN_WILDCARD)) { $classConstantName .= '*'; - $lastType = \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_WILDCARD; + $lastType = Lexer::TOKEN_WILDCARD; if ($tokens->getSkippedHorizontalWhiteSpaceIfAny() !== '') { break; } @@ -69,39 +69,39 @@ class ConstExprParser } if ($lastType === null) { // trigger parse error if nothing valid was consumed - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_WILDCARD); + $tokens->consumeTokenType(Lexer::TOKEN_WILDCARD); } break; } - return new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstFetchNode($identifier, $classConstantName); + return new Ast\ConstExpr\ConstFetchNode($identifier, $classConstantName); } - return new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstFetchNode('', $identifier); - } elseif ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_SQUARE_BRACKET)) { - return $this->parseArray($tokens, \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_SQUARE_BRACKET); + return new Ast\ConstExpr\ConstFetchNode('', $identifier); + } elseif ($tokens->tryConsumeTokenType(Lexer::TOKEN_OPEN_SQUARE_BRACKET)) { + return $this->parseArray($tokens, Lexer::TOKEN_CLOSE_SQUARE_BRACKET); } - throw new \PHPStan\PhpDocParser\Parser\ParserException($tokens->currentTokenValue(), $tokens->currentTokenType(), $tokens->currentTokenOffset(), \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER); + throw new \PHPStan\PhpDocParser\Parser\ParserException($tokens->currentTokenValue(), $tokens->currentTokenType(), $tokens->currentTokenOffset(), Lexer::TOKEN_IDENTIFIER); } - private function parseArray(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, int $endToken) : \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprArrayNode + private function parseArray(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, int $endToken) : Ast\ConstExpr\ConstExprArrayNode { $items = []; if (!$tokens->tryConsumeTokenType($endToken)) { do { $items[] = $this->parseArrayItem($tokens); - } while ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COMMA) && !$tokens->isCurrentTokenType($endToken)); + } while ($tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA) && !$tokens->isCurrentTokenType($endToken)); $tokens->consumeTokenType($endToken); } - return new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprArrayNode($items); + return new Ast\ConstExpr\ConstExprArrayNode($items); } - private function parseArrayItem(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprArrayItemNode + private function parseArrayItem(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\ConstExpr\ConstExprArrayItemNode { $expr = $this->parse($tokens); - if ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_DOUBLE_ARROW)) { + if ($tokens->tryConsumeTokenType(Lexer::TOKEN_DOUBLE_ARROW)) { $key = $expr; $value = $this->parse($tokens); } else { $key = null; $value = $expr; } - return new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprArrayItemNode($key, $value); + return new Ast\ConstExpr\ConstExprArrayItemNode($key, $value); } } diff --git a/vendor/phpstan/phpdoc-parser/src/Parser/ParserException.php b/vendor/phpstan/phpdoc-parser/src/Parser/ParserException.php index 1bafcd2cb2a..c49fc330239 100644 --- a/vendor/phpstan/phpdoc-parser/src/Parser/ParserException.php +++ b/vendor/phpstan/phpdoc-parser/src/Parser/ParserException.php @@ -10,7 +10,7 @@ use function json_encode; use function sprintf; use const JSON_UNESCAPED_SLASHES; use const JSON_UNESCAPED_UNICODE; -class ParserException extends \Exception +class ParserException extends Exception { /** @var string */ private $currentTokenValue; @@ -29,7 +29,7 @@ class ParserException extends \Exception $this->currentOffset = $currentOffset; $this->expectedTokenType = $expectedTokenType; $this->expectedTokenValue = $expectedTokenValue; - parent::__construct(\sprintf('Unexpected token %s, expected %s%s at offset %d', $this->formatValue($currentTokenValue), \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_LABELS[$expectedTokenType], $expectedTokenValue !== null ? \sprintf(' (%s)', $this->formatValue($expectedTokenValue)) : '', $currentOffset)); + parent::__construct(sprintf('Unexpected token %s, expected %s%s at offset %d', $this->formatValue($currentTokenValue), Lexer::TOKEN_LABELS[$expectedTokenType], $expectedTokenValue !== null ? sprintf(' (%s)', $this->formatValue($expectedTokenValue)) : '', $currentOffset)); } public function getCurrentTokenValue() : string { @@ -53,8 +53,8 @@ class ParserException extends \Exception } private function formatValue(string $value) : string { - $json = \json_encode($value, \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES); - \assert($json !== \false); + $json = json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); + assert($json !== \false); return $json; } } diff --git a/vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php b/vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php index 23aa417b74b..4cee76eb5b7 100644 --- a/vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php +++ b/vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php @@ -12,7 +12,7 @@ use function count; use function trim; class PhpDocParser { - private const DISALLOWED_DESCRIPTION_START_TOKENS = [\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_UNION, \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_INTERSECTION]; + private const DISALLOWED_DESCRIPTION_START_TOKENS = [Lexer::TOKEN_UNION, Lexer::TOKEN_INTERSECTION]; /** @var TypeParser */ private $typeParser; /** @var ConstExprParser */ @@ -22,66 +22,66 @@ class PhpDocParser $this->typeParser = $typeParser; $this->constantExprParser = $constantExprParser; } - public function parse(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode + public function parse(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\PhpDoc\PhpDocNode { - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PHPDOC); - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + $tokens->consumeTokenType(Lexer::TOKEN_OPEN_PHPDOC); + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); $children = []; - if (!$tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PHPDOC)) { + if (!$tokens->isCurrentTokenType(Lexer::TOKEN_CLOSE_PHPDOC)) { $children[] = $this->parseChild($tokens); - while ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL) && !$tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PHPDOC)) { + while ($tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL) && !$tokens->isCurrentTokenType(Lexer::TOKEN_CLOSE_PHPDOC)) { $children[] = $this->parseChild($tokens); } } try { - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PHPDOC); + $tokens->consumeTokenType(Lexer::TOKEN_CLOSE_PHPDOC); } catch (\PHPStan\PhpDocParser\Parser\ParserException $e) { $name = ''; - if (\count($children) > 0) { - $lastChild = $children[\count($children) - 1]; - if ($lastChild instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) { + if (count($children) > 0) { + $lastChild = $children[count($children) - 1]; + if ($lastChild instanceof Ast\PhpDoc\PhpDocTagNode) { $name = $lastChild->name; } } $tokens->forwardToTheEnd(); - return new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode([new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode($name, new \PHPStan\PhpDocParser\Ast\PhpDoc\InvalidTagValueNode($e->getMessage(), $e))]); + return new Ast\PhpDoc\PhpDocNode([new Ast\PhpDoc\PhpDocTagNode($name, new Ast\PhpDoc\InvalidTagValueNode($e->getMessage(), $e))]); } - return new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode(\array_values($children)); + return new Ast\PhpDoc\PhpDocNode(array_values($children)); } - private function parseChild(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode + private function parseChild(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\PhpDoc\PhpDocChildNode { - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_TAG)) { + if ($tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_TAG)) { return $this->parseTag($tokens); } return $this->parseText($tokens); } - private function parseText(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode + private function parseText(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\PhpDoc\PhpDocTextNode { $text = ''; - while (!$tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL)) { - $text .= $tokens->getSkippedHorizontalWhiteSpaceIfAny() . $tokens->joinUntil(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL, \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PHPDOC, \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_END); - if (!$tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL)) { + while (!$tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_EOL)) { + $text .= $tokens->getSkippedHorizontalWhiteSpaceIfAny() . $tokens->joinUntil(Lexer::TOKEN_PHPDOC_EOL, Lexer::TOKEN_CLOSE_PHPDOC, Lexer::TOKEN_END); + if (!$tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_EOL)) { break; } $tokens->pushSavePoint(); $tokens->next(); - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_TAG) || $tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL) || $tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PHPDOC) || $tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_END)) { + if ($tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_TAG) || $tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_EOL) || $tokens->isCurrentTokenType(Lexer::TOKEN_CLOSE_PHPDOC) || $tokens->isCurrentTokenType(Lexer::TOKEN_END)) { $tokens->rollback(); break; } $tokens->dropSavePoint(); $text .= "\n"; } - return new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode(\trim($text, " \t")); + return new Ast\PhpDoc\PhpDocTextNode(trim($text, " \t")); } - public function parseTag(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode + public function parseTag(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\PhpDoc\PhpDocTagNode { $tag = $tokens->currentTokenValue(); $tokens->next(); $value = $this->parseTagValue($tokens, $tag); - return new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode($tag, $value); + return new Ast\PhpDoc\PhpDocTagNode($tag, $value); } - public function parseTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, string $tag) : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode + public function parseTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, string $tag) : Ast\PhpDoc\PhpDocTagValueNode { try { $tokens->pushSavePoint(); @@ -167,180 +167,180 @@ class PhpDocParser $tagValue = $this->parseAssertTagValue($tokens); break; default: - $tagValue = new \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode($this->parseOptionalDescription($tokens)); + $tagValue = new Ast\PhpDoc\GenericTagValueNode($this->parseOptionalDescription($tokens)); break; } $tokens->dropSavePoint(); } catch (\PHPStan\PhpDocParser\Parser\ParserException $e) { $tokens->rollback(); - $tagValue = new \PHPStan\PhpDocParser\Ast\PhpDoc\InvalidTagValueNode($this->parseOptionalDescription($tokens), $e); + $tagValue = new Ast\PhpDoc\InvalidTagValueNode($this->parseOptionalDescription($tokens), $e); } return $tagValue; } - private function parseParamTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode + private function parseParamTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\PhpDoc\ParamTagValueNode { $type = $this->typeParser->parse($tokens); - $isReference = $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_REFERENCE); - $isVariadic = $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_VARIADIC); + $isReference = $tokens->tryConsumeTokenType(Lexer::TOKEN_REFERENCE); + $isVariadic = $tokens->tryConsumeTokenType(Lexer::TOKEN_VARIADIC); $parameterName = $this->parseRequiredVariableName($tokens); $description = $this->parseOptionalDescription($tokens); - return new \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode($type, $isVariadic, $parameterName, $description, $isReference); + return new Ast\PhpDoc\ParamTagValueNode($type, $isVariadic, $parameterName, $description, $isReference); } - private function parseVarTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode + private function parseVarTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\PhpDoc\VarTagValueNode { $type = $this->typeParser->parse($tokens); $variableName = $this->parseOptionalVariableName($tokens); $description = $this->parseOptionalDescription($tokens, $variableName === ''); - return new \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode($type, $variableName, $description); + return new Ast\PhpDoc\VarTagValueNode($type, $variableName, $description); } - private function parseReturnTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode + private function parseReturnTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\PhpDoc\ReturnTagValueNode { $type = $this->typeParser->parse($tokens); $description = $this->parseOptionalDescription($tokens, \true); - return new \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode($type, $description); + return new Ast\PhpDoc\ReturnTagValueNode($type, $description); } - private function parseThrowsTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode + private function parseThrowsTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\PhpDoc\ThrowsTagValueNode { $type = $this->typeParser->parse($tokens); $description = $this->parseOptionalDescription($tokens, \true); - return new \PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode($type, $description); + return new Ast\PhpDoc\ThrowsTagValueNode($type, $description); } - private function parseMixinTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\PhpDoc\MixinTagValueNode + private function parseMixinTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\PhpDoc\MixinTagValueNode { $type = $this->typeParser->parse($tokens); $description = $this->parseOptionalDescription($tokens, \true); - return new \PHPStan\PhpDocParser\Ast\PhpDoc\MixinTagValueNode($type, $description); + return new Ast\PhpDoc\MixinTagValueNode($type, $description); } - private function parseDeprecatedTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\PhpDoc\DeprecatedTagValueNode + private function parseDeprecatedTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\PhpDoc\DeprecatedTagValueNode { $description = $this->parseOptionalDescription($tokens); - return new \PHPStan\PhpDocParser\Ast\PhpDoc\DeprecatedTagValueNode($description); + return new Ast\PhpDoc\DeprecatedTagValueNode($description); } - private function parsePropertyTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode + private function parsePropertyTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\PhpDoc\PropertyTagValueNode { $type = $this->typeParser->parse($tokens); $parameterName = $this->parseRequiredVariableName($tokens); $description = $this->parseOptionalDescription($tokens); - return new \PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode($type, $parameterName, $description); + return new Ast\PhpDoc\PropertyTagValueNode($type, $parameterName, $description); } - private function parseMethodTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueNode + private function parseMethodTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\PhpDoc\MethodTagValueNode { $isStatic = $tokens->tryConsumeTokenValue('static'); $returnTypeOrMethodName = $this->typeParser->parse($tokens); - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER)) { + if ($tokens->isCurrentTokenType(Lexer::TOKEN_IDENTIFIER)) { $returnType = $returnTypeOrMethodName; $methodName = $tokens->currentTokenValue(); $tokens->next(); - } elseif ($returnTypeOrMethodName instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode) { - $returnType = $isStatic ? new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('static') : null; + } elseif ($returnTypeOrMethodName instanceof Ast\Type\IdentifierTypeNode) { + $returnType = $isStatic ? new Ast\Type\IdentifierTypeNode('static') : null; $methodName = $returnTypeOrMethodName->name; $isStatic = \false; } else { - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER); + $tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER); // will throw exception exit; } $parameters = []; - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES); - if (!$tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES)) { + $tokens->consumeTokenType(Lexer::TOKEN_OPEN_PARENTHESES); + if (!$tokens->isCurrentTokenType(Lexer::TOKEN_CLOSE_PARENTHESES)) { $parameters[] = $this->parseMethodTagValueParameter($tokens); - while ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COMMA)) { + while ($tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA)) { $parameters[] = $this->parseMethodTagValueParameter($tokens); } } - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES); + $tokens->consumeTokenType(Lexer::TOKEN_CLOSE_PARENTHESES); $description = $this->parseOptionalDescription($tokens); - return new \PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueNode($isStatic, $returnType, $methodName, $parameters, $description); + return new Ast\PhpDoc\MethodTagValueNode($isStatic, $returnType, $methodName, $parameters, $description); } - private function parseMethodTagValueParameter(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueParameterNode + private function parseMethodTagValueParameter(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\PhpDoc\MethodTagValueParameterNode { switch ($tokens->currentTokenType()) { - case \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER: - case \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES: - case \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_NULLABLE: + case Lexer::TOKEN_IDENTIFIER: + case Lexer::TOKEN_OPEN_PARENTHESES: + case Lexer::TOKEN_NULLABLE: $parameterType = $this->typeParser->parse($tokens); break; default: $parameterType = null; } - $isReference = $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_REFERENCE); - $isVariadic = $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_VARIADIC); + $isReference = $tokens->tryConsumeTokenType(Lexer::TOKEN_REFERENCE); + $isVariadic = $tokens->tryConsumeTokenType(Lexer::TOKEN_VARIADIC); $parameterName = $tokens->currentTokenValue(); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_VARIABLE); - if ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_EQUAL)) { + $tokens->consumeTokenType(Lexer::TOKEN_VARIABLE); + if ($tokens->tryConsumeTokenType(Lexer::TOKEN_EQUAL)) { $defaultValue = $this->constantExprParser->parse($tokens); } else { $defaultValue = null; } - return new \PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueParameterNode($parameterType, $isReference, $isVariadic, $parameterName, $defaultValue); + return new Ast\PhpDoc\MethodTagValueParameterNode($parameterType, $isReference, $isVariadic, $parameterName, $defaultValue); } - private function parseTemplateTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode + private function parseTemplateTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\PhpDoc\TemplateTagValueNode { $name = $tokens->currentTokenValue(); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER); + $tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER); if ($tokens->tryConsumeTokenValue('of') || $tokens->tryConsumeTokenValue('as')) { $bound = $this->typeParser->parse($tokens); } else { $bound = null; } $description = $this->parseOptionalDescription($tokens); - return new \PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode($name, $bound, $description); + return new Ast\PhpDoc\TemplateTagValueNode($name, $bound, $description); } - private function parseExtendsTagValue(string $tagName, \PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode + private function parseExtendsTagValue(string $tagName, \PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\PhpDoc\PhpDocTagValueNode { - $baseType = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($tokens->currentTokenValue()); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER); + $baseType = new IdentifierTypeNode($tokens->currentTokenValue()); + $tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER); $type = $this->typeParser->parseGeneric($tokens, $baseType); $description = $this->parseOptionalDescription($tokens); switch ($tagName) { case '@extends': - return new \PHPStan\PhpDocParser\Ast\PhpDoc\ExtendsTagValueNode($type, $description); + return new Ast\PhpDoc\ExtendsTagValueNode($type, $description); case '@implements': - return new \PHPStan\PhpDocParser\Ast\PhpDoc\ImplementsTagValueNode($type, $description); + return new Ast\PhpDoc\ImplementsTagValueNode($type, $description); case '@use': - return new \PHPStan\PhpDocParser\Ast\PhpDoc\UsesTagValueNode($type, $description); + return new Ast\PhpDoc\UsesTagValueNode($type, $description); } - throw new \PHPStan\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } - private function parseTypeAliasTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\PhpDoc\TypeAliasTagValueNode + private function parseTypeAliasTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\PhpDoc\TypeAliasTagValueNode { $alias = $tokens->currentTokenValue(); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER); + $tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER); // support psalm-type syntax - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_EQUAL); + $tokens->tryConsumeTokenType(Lexer::TOKEN_EQUAL); $type = $this->typeParser->parse($tokens); - return new \PHPStan\PhpDocParser\Ast\PhpDoc\TypeAliasTagValueNode($alias, $type); + return new Ast\PhpDoc\TypeAliasTagValueNode($alias, $type); } - private function parseTypeAliasImportTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\PhpDoc\TypeAliasImportTagValueNode + private function parseTypeAliasImportTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\PhpDoc\TypeAliasImportTagValueNode { $importedAlias = $tokens->currentTokenValue(); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER); + $tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER); if (!$tokens->tryConsumeTokenValue('from')) { - throw new \PHPStan\PhpDocParser\Parser\ParserException($tokens->currentTokenValue(), $tokens->currentTokenType(), $tokens->currentTokenOffset(), \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER); + throw new \PHPStan\PhpDocParser\Parser\ParserException($tokens->currentTokenValue(), $tokens->currentTokenType(), $tokens->currentTokenOffset(), Lexer::TOKEN_IDENTIFIER); } $importedFrom = $tokens->currentTokenValue(); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER); + $tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER); $importedAs = null; if ($tokens->tryConsumeTokenValue('as')) { $importedAs = $tokens->currentTokenValue(); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER); + $tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER); } - return new \PHPStan\PhpDocParser\Ast\PhpDoc\TypeAliasImportTagValueNode($importedAlias, new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($importedFrom), $importedAs); + return new Ast\PhpDoc\TypeAliasImportTagValueNode($importedAlias, new IdentifierTypeNode($importedFrom), $importedAs); } - private function parseAssertTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\PhpDoc\AssertTagValueNode + private function parseAssertTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\PhpDoc\AssertTagValueNode { - $isNegated = $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_NEGATED); + $isNegated = $tokens->tryConsumeTokenType(Lexer::TOKEN_NEGATED); $type = $this->typeParser->parse($tokens); $parameter = $this->parseRequiredVariableName($tokens); $description = $this->parseOptionalDescription($tokens); - return new \PHPStan\PhpDocParser\Ast\PhpDoc\AssertTagValueNode($type, $parameter, $isNegated, $description); + return new Ast\PhpDoc\AssertTagValueNode($type, $parameter, $isNegated, $description); } private function parseOptionalVariableName(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : string { - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_VARIABLE)) { + if ($tokens->isCurrentTokenType(Lexer::TOKEN_VARIABLE)) { $parameterName = $tokens->currentTokenValue(); $tokens->next(); - } elseif ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_THIS_VARIABLE)) { + } elseif ($tokens->isCurrentTokenType(Lexer::TOKEN_THIS_VARIABLE)) { $parameterName = '$this'; $tokens->next(); } else { @@ -351,7 +351,7 @@ class PhpDocParser private function parseRequiredVariableName(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : string { $parameterName = $tokens->currentTokenValue(); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_VARIABLE); + $tokens->consumeTokenType(Lexer::TOKEN_VARIABLE); return $parameterName; } private function parseOptionalDescription(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, bool $limitStartToken = \false) : string @@ -361,7 +361,7 @@ class PhpDocParser if (!$tokens->isCurrentTokenType($disallowedStartToken)) { continue; } - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OTHER); + $tokens->consumeTokenType(Lexer::TOKEN_OTHER); // will throw exception } } diff --git a/vendor/phpstan/phpdoc-parser/src/Parser/TokenIterator.php b/vendor/phpstan/phpdoc-parser/src/Parser/TokenIterator.php index f89f280cdba..0756ccb3c2d 100644 --- a/vendor/phpstan/phpdoc-parser/src/Parser/TokenIterator.php +++ b/vendor/phpstan/phpdoc-parser/src/Parser/TokenIterator.php @@ -21,49 +21,49 @@ class TokenIterator { $this->tokens = $tokens; $this->index = $index; - if ($this->tokens[$this->index][\PHPStan\PhpDocParser\Lexer\Lexer::TYPE_OFFSET] !== \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_HORIZONTAL_WS) { + if ($this->tokens[$this->index][Lexer::TYPE_OFFSET] !== Lexer::TOKEN_HORIZONTAL_WS) { return; } $this->index++; } public function currentTokenValue() : string { - return $this->tokens[$this->index][\PHPStan\PhpDocParser\Lexer\Lexer::VALUE_OFFSET]; + return $this->tokens[$this->index][Lexer::VALUE_OFFSET]; } public function currentTokenType() : int { - return $this->tokens[$this->index][\PHPStan\PhpDocParser\Lexer\Lexer::TYPE_OFFSET]; + return $this->tokens[$this->index][Lexer::TYPE_OFFSET]; } public function currentTokenOffset() : int { $offset = 0; for ($i = 0; $i < $this->index; $i++) { - $offset += \strlen($this->tokens[$i][\PHPStan\PhpDocParser\Lexer\Lexer::VALUE_OFFSET]); + $offset += strlen($this->tokens[$i][Lexer::VALUE_OFFSET]); } return $offset; } public function isCurrentTokenValue(string $tokenValue) : bool { - return $this->tokens[$this->index][\PHPStan\PhpDocParser\Lexer\Lexer::VALUE_OFFSET] === $tokenValue; + return $this->tokens[$this->index][Lexer::VALUE_OFFSET] === $tokenValue; } public function isCurrentTokenType(int $tokenType) : bool { - return $this->tokens[$this->index][\PHPStan\PhpDocParser\Lexer\Lexer::TYPE_OFFSET] === $tokenType; + return $this->tokens[$this->index][Lexer::TYPE_OFFSET] === $tokenType; } public function isPrecededByHorizontalWhitespace() : bool { - return ($this->tokens[$this->index - 1][\PHPStan\PhpDocParser\Lexer\Lexer::TYPE_OFFSET] ?? -1) === \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_HORIZONTAL_WS; + return ($this->tokens[$this->index - 1][Lexer::TYPE_OFFSET] ?? -1) === Lexer::TOKEN_HORIZONTAL_WS; } /** * @throws ParserException */ public function consumeTokenType(int $tokenType) : void { - if ($this->tokens[$this->index][\PHPStan\PhpDocParser\Lexer\Lexer::TYPE_OFFSET] !== $tokenType) { + if ($this->tokens[$this->index][Lexer::TYPE_OFFSET] !== $tokenType) { $this->throwError($tokenType); } $this->index++; - if (($this->tokens[$this->index][\PHPStan\PhpDocParser\Lexer\Lexer::TYPE_OFFSET] ?? -1) !== \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_HORIZONTAL_WS) { + if (($this->tokens[$this->index][Lexer::TYPE_OFFSET] ?? -1) !== Lexer::TOKEN_HORIZONTAL_WS) { return; } $this->index++; @@ -73,11 +73,11 @@ class TokenIterator */ public function consumeTokenValue(int $tokenType, string $tokenValue) : void { - if ($this->tokens[$this->index][\PHPStan\PhpDocParser\Lexer\Lexer::TYPE_OFFSET] !== $tokenType || $this->tokens[$this->index][\PHPStan\PhpDocParser\Lexer\Lexer::VALUE_OFFSET] !== $tokenValue) { + if ($this->tokens[$this->index][Lexer::TYPE_OFFSET] !== $tokenType || $this->tokens[$this->index][Lexer::VALUE_OFFSET] !== $tokenValue) { $this->throwError($tokenType, $tokenValue); } $this->index++; - if (($this->tokens[$this->index][\PHPStan\PhpDocParser\Lexer\Lexer::TYPE_OFFSET] ?? -1) !== \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_HORIZONTAL_WS) { + if (($this->tokens[$this->index][Lexer::TYPE_OFFSET] ?? -1) !== Lexer::TOKEN_HORIZONTAL_WS) { return; } $this->index++; @@ -85,11 +85,11 @@ class TokenIterator /** @phpstan-impure */ public function tryConsumeTokenValue(string $tokenValue) : bool { - if ($this->tokens[$this->index][\PHPStan\PhpDocParser\Lexer\Lexer::VALUE_OFFSET] !== $tokenValue) { + if ($this->tokens[$this->index][Lexer::VALUE_OFFSET] !== $tokenValue) { return \false; } $this->index++; - if ($this->tokens[$this->index][\PHPStan\PhpDocParser\Lexer\Lexer::TYPE_OFFSET] === \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_HORIZONTAL_WS) { + if ($this->tokens[$this->index][Lexer::TYPE_OFFSET] === Lexer::TOKEN_HORIZONTAL_WS) { $this->index++; } return \true; @@ -97,19 +97,19 @@ class TokenIterator /** @phpstan-impure */ public function tryConsumeTokenType(int $tokenType) : bool { - if ($this->tokens[$this->index][\PHPStan\PhpDocParser\Lexer\Lexer::TYPE_OFFSET] !== $tokenType) { + if ($this->tokens[$this->index][Lexer::TYPE_OFFSET] !== $tokenType) { return \false; } $this->index++; - if ($this->tokens[$this->index][\PHPStan\PhpDocParser\Lexer\Lexer::TYPE_OFFSET] === \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_HORIZONTAL_WS) { + if ($this->tokens[$this->index][Lexer::TYPE_OFFSET] === Lexer::TOKEN_HORIZONTAL_WS) { $this->index++; } return \true; } public function getSkippedHorizontalWhiteSpaceIfAny() : string { - if ($this->index > 0 && $this->tokens[$this->index - 1][\PHPStan\PhpDocParser\Lexer\Lexer::TYPE_OFFSET] === \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_HORIZONTAL_WS) { - return $this->tokens[$this->index - 1][\PHPStan\PhpDocParser\Lexer\Lexer::VALUE_OFFSET]; + if ($this->index > 0 && $this->tokens[$this->index - 1][Lexer::TYPE_OFFSET] === Lexer::TOKEN_HORIZONTAL_WS) { + return $this->tokens[$this->index - 1][Lexer::VALUE_OFFSET]; } return ''; } @@ -117,15 +117,15 @@ class TokenIterator public function joinUntil(int ...$tokenType) : string { $s = ''; - while (!\in_array($this->tokens[$this->index][\PHPStan\PhpDocParser\Lexer\Lexer::TYPE_OFFSET], $tokenType, \true)) { - $s .= $this->tokens[$this->index++][\PHPStan\PhpDocParser\Lexer\Lexer::VALUE_OFFSET]; + while (!in_array($this->tokens[$this->index][Lexer::TYPE_OFFSET], $tokenType, \true)) { + $s .= $this->tokens[$this->index++][Lexer::VALUE_OFFSET]; } return $s; } public function next() : void { $this->index++; - if ($this->tokens[$this->index][\PHPStan\PhpDocParser\Lexer\Lexer::TYPE_OFFSET] !== \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_HORIZONTAL_WS) { + if ($this->tokens[$this->index][Lexer::TYPE_OFFSET] !== Lexer::TOKEN_HORIZONTAL_WS) { return; } $this->index++; @@ -133,7 +133,7 @@ class TokenIterator /** @phpstan-impure */ public function forwardToTheEnd() : void { - $lastToken = \count($this->tokens) - 1; + $lastToken = count($this->tokens) - 1; $this->index = $lastToken; } public function pushSavePoint() : void @@ -142,12 +142,12 @@ class TokenIterator } public function dropSavePoint() : void { - \array_pop($this->savePoints); + array_pop($this->savePoints); } public function rollback() : void { - $index = \array_pop($this->savePoints); - \assert($index !== null); + $index = array_pop($this->savePoints); + assert($index !== null); $this->index = $index; } /** diff --git a/vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php b/vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php index cb8a5021ddf..5cd9c0e513f 100644 --- a/vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php +++ b/vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php @@ -17,36 +17,36 @@ class TypeParser $this->constExprParser = $constExprParser; } /** @phpstan-impure */ - public function parse(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + public function parse(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\Type\TypeNode { - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_NULLABLE)) { + if ($tokens->isCurrentTokenType(Lexer::TOKEN_NULLABLE)) { $type = $this->parseNullable($tokens); } else { $type = $this->parseAtomic($tokens); - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_UNION)) { + if ($tokens->isCurrentTokenType(Lexer::TOKEN_UNION)) { $type = $this->parseUnion($tokens, $type); - } elseif ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_INTERSECTION)) { + } elseif ($tokens->isCurrentTokenType(Lexer::TOKEN_INTERSECTION)) { $type = $this->parseIntersection($tokens, $type); } } return $type; } /** @phpstan-impure */ - private function subParse(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + private function subParse(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\Type\TypeNode { - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_NULLABLE)) { + if ($tokens->isCurrentTokenType(Lexer::TOKEN_NULLABLE)) { $type = $this->parseNullable($tokens); - } elseif ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_VARIABLE)) { + } elseif ($tokens->isCurrentTokenType(Lexer::TOKEN_VARIABLE)) { $type = $this->parseConditionalForParameter($tokens, $tokens->currentTokenValue()); } else { $type = $this->parseAtomic($tokens); if ($tokens->isCurrentTokenValue('is')) { $type = $this->parseConditional($tokens, $type); } else { - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_UNION)) { + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); + if ($tokens->isCurrentTokenType(Lexer::TOKEN_UNION)) { $type = $this->subParseUnion($tokens, $type); - } elseif ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_INTERSECTION)) { + } elseif ($tokens->isCurrentTokenType(Lexer::TOKEN_INTERSECTION)) { $type = $this->subParseIntersection($tokens, $type); } } @@ -54,21 +54,21 @@ class TypeParser return $type; } /** @phpstan-impure */ - private function parseAtomic(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + private function parseAtomic(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\Type\TypeNode { - if ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES)) { - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + if ($tokens->tryConsumeTokenType(Lexer::TOKEN_OPEN_PARENTHESES)) { + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); $type = $this->subParse($tokens); - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES); - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_SQUARE_BRACKET)) { + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); + $tokens->consumeTokenType(Lexer::TOKEN_CLOSE_PARENTHESES); + if ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_SQUARE_BRACKET)) { return $this->tryParseArrayOrOffsetAccess($tokens, $type); } return $type; } - if ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_THIS_VARIABLE)) { - $type = new \PHPStan\PhpDocParser\Ast\Type\ThisTypeNode(); - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_SQUARE_BRACKET)) { + if ($tokens->tryConsumeTokenType(Lexer::TOKEN_THIS_VARIABLE)) { + $type = new Ast\Type\ThisTypeNode(); + if ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_SQUARE_BRACKET)) { return $this->tryParseArrayOrOffsetAccess($tokens, $type); } return $type; @@ -76,12 +76,12 @@ class TypeParser $currentTokenValue = $tokens->currentTokenValue(); $tokens->pushSavePoint(); // because of ConstFetchNode - if ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER)) { - $type = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($currentTokenValue); - if (!$tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_DOUBLE_COLON)) { + if ($tokens->tryConsumeTokenType(Lexer::TOKEN_IDENTIFIER)) { + $type = new Ast\Type\IdentifierTypeNode($currentTokenValue); + if (!$tokens->isCurrentTokenType(Lexer::TOKEN_DOUBLE_COLON)) { $tokens->dropSavePoint(); // because of ConstFetchNode - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_ANGLE_BRACKET)) { + if ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_ANGLE_BRACKET)) { $tokens->pushSavePoint(); $isHtml = $this->isHtml($tokens); $tokens->rollback(); @@ -89,16 +89,16 @@ class TypeParser return $type; } $type = $this->parseGeneric($tokens, $type); - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_SQUARE_BRACKET)) { + if ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_SQUARE_BRACKET)) { $type = $this->tryParseArrayOrOffsetAccess($tokens, $type); } - } elseif ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES)) { + } elseif ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_PARENTHESES)) { $type = $this->tryParseCallable($tokens, $type); - } elseif ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_SQUARE_BRACKET)) { + } elseif ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_SQUARE_BRACKET)) { $type = $this->tryParseArrayOrOffsetAccess($tokens, $type); - } elseif ($type->name === 'array' && $tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_CURLY_BRACKET) && !$tokens->isPrecededByHorizontalWhitespace()) { + } elseif ($type->name === 'array' && $tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_CURLY_BRACKET) && !$tokens->isPrecededByHorizontalWhitespace()) { $type = $this->parseArrayShape($tokens, $type); - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_SQUARE_BRACKET)) { + if ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_SQUARE_BRACKET)) { $type = $this->tryParseArrayOrOffsetAccess($tokens, $type); } } @@ -111,131 +111,131 @@ class TypeParser $tokens->dropSavePoint(); // because of ConstFetchNode } - $exception = new \PHPStan\PhpDocParser\Parser\ParserException($tokens->currentTokenValue(), $tokens->currentTokenType(), $tokens->currentTokenOffset(), \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER); + $exception = new \PHPStan\PhpDocParser\Parser\ParserException($tokens->currentTokenValue(), $tokens->currentTokenType(), $tokens->currentTokenOffset(), Lexer::TOKEN_IDENTIFIER); if ($this->constExprParser === null) { throw $exception; } try { $constExpr = $this->constExprParser->parse($tokens, \true); - if ($constExpr instanceof \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprArrayNode) { + if ($constExpr instanceof Ast\ConstExpr\ConstExprArrayNode) { throw $exception; } - return new \PHPStan\PhpDocParser\Ast\Type\ConstTypeNode($constExpr); - } catch (\LogicException $e) { + return new Ast\Type\ConstTypeNode($constExpr); + } catch (LogicException $e) { throw $exception; } } /** @phpstan-impure */ - private function parseUnion(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, \PHPStan\PhpDocParser\Ast\Type\TypeNode $type) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + private function parseUnion(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, Ast\Type\TypeNode $type) : Ast\Type\TypeNode { $types = [$type]; - while ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_UNION)) { + while ($tokens->tryConsumeTokenType(Lexer::TOKEN_UNION)) { $types[] = $this->parseAtomic($tokens); } - return new \PHPStan\PhpDocParser\Ast\Type\UnionTypeNode($types); + return new Ast\Type\UnionTypeNode($types); } /** @phpstan-impure */ - private function subParseUnion(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, \PHPStan\PhpDocParser\Ast\Type\TypeNode $type) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + private function subParseUnion(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, Ast\Type\TypeNode $type) : Ast\Type\TypeNode { $types = [$type]; - while ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_UNION)) { - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + while ($tokens->tryConsumeTokenType(Lexer::TOKEN_UNION)) { + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); $types[] = $this->parseAtomic($tokens); - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); } - return new \PHPStan\PhpDocParser\Ast\Type\UnionTypeNode($types); + return new Ast\Type\UnionTypeNode($types); } /** @phpstan-impure */ - private function parseIntersection(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, \PHPStan\PhpDocParser\Ast\Type\TypeNode $type) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + private function parseIntersection(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, Ast\Type\TypeNode $type) : Ast\Type\TypeNode { $types = [$type]; - while ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_INTERSECTION)) { + while ($tokens->tryConsumeTokenType(Lexer::TOKEN_INTERSECTION)) { $types[] = $this->parseAtomic($tokens); } - return new \PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode($types); + return new Ast\Type\IntersectionTypeNode($types); } /** @phpstan-impure */ - private function subParseIntersection(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, \PHPStan\PhpDocParser\Ast\Type\TypeNode $type) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + private function subParseIntersection(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, Ast\Type\TypeNode $type) : Ast\Type\TypeNode { $types = [$type]; - while ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_INTERSECTION)) { - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + while ($tokens->tryConsumeTokenType(Lexer::TOKEN_INTERSECTION)) { + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); $types[] = $this->parseAtomic($tokens); - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); } - return new \PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode($types); + return new Ast\Type\IntersectionTypeNode($types); } /** @phpstan-impure */ - private function parseConditional(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, \PHPStan\PhpDocParser\Ast\Type\TypeNode $subjectType) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + private function parseConditional(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, Ast\Type\TypeNode $subjectType) : Ast\Type\TypeNode { - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER); + $tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER); $negated = \false; if ($tokens->isCurrentTokenValue('not')) { $negated = \true; - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER); + $tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER); } $targetType = $this->parse($tokens); - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_NULLABLE); - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); + $tokens->consumeTokenType(Lexer::TOKEN_NULLABLE); + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); $ifType = $this->parse($tokens); - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COLON); - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); + $tokens->consumeTokenType(Lexer::TOKEN_COLON); + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); $elseType = $this->parse($tokens); - return new \PHPStan\PhpDocParser\Ast\Type\ConditionalTypeNode($subjectType, $targetType, $ifType, $elseType, $negated); + return new Ast\Type\ConditionalTypeNode($subjectType, $targetType, $ifType, $elseType, $negated); } /** @phpstan-impure */ - private function parseConditionalForParameter(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, string $parameterName) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + private function parseConditionalForParameter(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, string $parameterName) : Ast\Type\TypeNode { - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_VARIABLE); - $tokens->consumeTokenValue(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER, 'is'); + $tokens->consumeTokenType(Lexer::TOKEN_VARIABLE); + $tokens->consumeTokenValue(Lexer::TOKEN_IDENTIFIER, 'is'); $negated = \false; if ($tokens->isCurrentTokenValue('not')) { $negated = \true; - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER); + $tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER); } $targetType = $this->parse($tokens); - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_NULLABLE); - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); + $tokens->consumeTokenType(Lexer::TOKEN_NULLABLE); + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); $ifType = $this->parse($tokens); - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COLON); - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); + $tokens->consumeTokenType(Lexer::TOKEN_COLON); + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); $elseType = $this->parse($tokens); - return new \PHPStan\PhpDocParser\Ast\Type\ConditionalTypeForParameterNode($parameterName, $targetType, $ifType, $elseType, $negated); + return new Ast\Type\ConditionalTypeForParameterNode($parameterName, $targetType, $ifType, $elseType, $negated); } /** @phpstan-impure */ - private function parseNullable(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + private function parseNullable(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\Type\TypeNode { - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_NULLABLE); - $type = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($tokens->currentTokenValue()); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER); - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_ANGLE_BRACKET)) { + $tokens->consumeTokenType(Lexer::TOKEN_NULLABLE); + $type = new Ast\Type\IdentifierTypeNode($tokens->currentTokenValue()); + $tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER); + if ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_ANGLE_BRACKET)) { $type = $this->parseGeneric($tokens, $type); - } elseif ($type->name === 'array' && $tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_CURLY_BRACKET) && !$tokens->isPrecededByHorizontalWhitespace()) { + } elseif ($type->name === 'array' && $tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_CURLY_BRACKET) && !$tokens->isPrecededByHorizontalWhitespace()) { $type = $this->parseArrayShape($tokens, $type); } - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_SQUARE_BRACKET)) { + if ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_SQUARE_BRACKET)) { $type = $this->tryParseArrayOrOffsetAccess($tokens, $type); } - return new \PHPStan\PhpDocParser\Ast\Type\NullableTypeNode($type); + return new Ast\Type\NullableTypeNode($type); } /** @phpstan-impure */ public function isHtml(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : bool { - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_ANGLE_BRACKET); - if (!$tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER)) { + $tokens->consumeTokenType(Lexer::TOKEN_OPEN_ANGLE_BRACKET); + if (!$tokens->isCurrentTokenType(Lexer::TOKEN_IDENTIFIER)) { return \false; } $htmlTagName = $tokens->currentTokenValue(); $tokens->next(); - if (!$tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_ANGLE_BRACKET)) { + if (!$tokens->tryConsumeTokenType(Lexer::TOKEN_CLOSE_ANGLE_BRACKET)) { return \false; } - while (!$tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_END)) { - if ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_ANGLE_BRACKET) && \strpos($tokens->currentTokenValue(), '/' . $htmlTagName . '>') !== \false) { + while (!$tokens->isCurrentTokenType(Lexer::TOKEN_END)) { + if ($tokens->tryConsumeTokenType(Lexer::TOKEN_OPEN_ANGLE_BRACKET) && strpos($tokens->currentTokenValue(), '/' . $htmlTagName . '>') !== \false) { return \true; } $tokens->next(); @@ -243,87 +243,87 @@ class TypeParser return \false; } /** @phpstan-impure */ - public function parseGeneric(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode $baseType) : \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode + public function parseGeneric(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, Ast\Type\IdentifierTypeNode $baseType) : Ast\Type\GenericTypeNode { - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_ANGLE_BRACKET); - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + $tokens->consumeTokenType(Lexer::TOKEN_OPEN_ANGLE_BRACKET); + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); $genericTypes = [$this->parse($tokens)]; - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); - while ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COMMA)) { - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); - if ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_ANGLE_BRACKET)) { + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); + while ($tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA)) { + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); + if ($tokens->tryConsumeTokenType(Lexer::TOKEN_CLOSE_ANGLE_BRACKET)) { // trailing comma case - return new \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode($baseType, $genericTypes); + return new Ast\Type\GenericTypeNode($baseType, $genericTypes); } $genericTypes[] = $this->parse($tokens); - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); } - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_ANGLE_BRACKET); - return new \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode($baseType, $genericTypes); + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); + $tokens->consumeTokenType(Lexer::TOKEN_CLOSE_ANGLE_BRACKET); + return new Ast\Type\GenericTypeNode($baseType, $genericTypes); } /** @phpstan-impure */ - private function parseCallable(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode $identifier) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + private function parseCallable(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, Ast\Type\IdentifierTypeNode $identifier) : Ast\Type\TypeNode { - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES); - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + $tokens->consumeTokenType(Lexer::TOKEN_OPEN_PARENTHESES); + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); $parameters = []; - if (!$tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES)) { + if (!$tokens->isCurrentTokenType(Lexer::TOKEN_CLOSE_PARENTHESES)) { $parameters[] = $this->parseCallableParameter($tokens); - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); - while ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COMMA)) { - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES)) { + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); + while ($tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA)) { + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); + if ($tokens->isCurrentTokenType(Lexer::TOKEN_CLOSE_PARENTHESES)) { break; } $parameters[] = $this->parseCallableParameter($tokens); - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); } } - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COLON); + $tokens->consumeTokenType(Lexer::TOKEN_CLOSE_PARENTHESES); + $tokens->consumeTokenType(Lexer::TOKEN_COLON); $returnType = $this->parseCallableReturnType($tokens); - return new \PHPStan\PhpDocParser\Ast\Type\CallableTypeNode($identifier, $parameters, $returnType); + return new Ast\Type\CallableTypeNode($identifier, $parameters, $returnType); } /** @phpstan-impure */ - private function parseCallableParameter(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\Type\CallableTypeParameterNode + private function parseCallableParameter(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\Type\CallableTypeParameterNode { $type = $this->parse($tokens); - $isReference = $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_REFERENCE); - $isVariadic = $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_VARIADIC); - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_VARIABLE)) { + $isReference = $tokens->tryConsumeTokenType(Lexer::TOKEN_REFERENCE); + $isVariadic = $tokens->tryConsumeTokenType(Lexer::TOKEN_VARIADIC); + if ($tokens->isCurrentTokenType(Lexer::TOKEN_VARIABLE)) { $parameterName = $tokens->currentTokenValue(); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_VARIABLE); + $tokens->consumeTokenType(Lexer::TOKEN_VARIABLE); } else { $parameterName = ''; } - $isOptional = $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_EQUAL); - return new \PHPStan\PhpDocParser\Ast\Type\CallableTypeParameterNode($type, $isReference, $isVariadic, $parameterName, $isOptional); + $isOptional = $tokens->tryConsumeTokenType(Lexer::TOKEN_EQUAL); + return new Ast\Type\CallableTypeParameterNode($type, $isReference, $isVariadic, $parameterName, $isOptional); } /** @phpstan-impure */ - private function parseCallableReturnType(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + private function parseCallableReturnType(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\Type\TypeNode { - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_NULLABLE)) { + if ($tokens->isCurrentTokenType(Lexer::TOKEN_NULLABLE)) { $type = $this->parseNullable($tokens); - } elseif ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES)) { + } elseif ($tokens->tryConsumeTokenType(Lexer::TOKEN_OPEN_PARENTHESES)) { $type = $this->parse($tokens); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES); + $tokens->consumeTokenType(Lexer::TOKEN_CLOSE_PARENTHESES); } else { - $type = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($tokens->currentTokenValue()); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER); - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_ANGLE_BRACKET)) { + $type = new Ast\Type\IdentifierTypeNode($tokens->currentTokenValue()); + $tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER); + if ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_ANGLE_BRACKET)) { $type = $this->parseGeneric($tokens, $type); - } elseif ($type->name === 'array' && $tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_CURLY_BRACKET) && !$tokens->isPrecededByHorizontalWhitespace()) { + } elseif ($type->name === 'array' && $tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_CURLY_BRACKET) && !$tokens->isPrecededByHorizontalWhitespace()) { $type = $this->parseArrayShape($tokens, $type); } } - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_SQUARE_BRACKET)) { + if ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_SQUARE_BRACKET)) { $type = $this->tryParseArrayOrOffsetAccess($tokens, $type); } return $type; } /** @phpstan-impure */ - private function tryParseCallable(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode $identifier) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + private function tryParseCallable(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, Ast\Type\IdentifierTypeNode $identifier) : Ast\Type\TypeNode { try { $tokens->pushSavePoint(); @@ -336,22 +336,22 @@ class TypeParser return $type; } /** @phpstan-impure */ - private function tryParseArrayOrOffsetAccess(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, \PHPStan\PhpDocParser\Ast\Type\TypeNode $type) : \PHPStan\PhpDocParser\Ast\Type\TypeNode + private function tryParseArrayOrOffsetAccess(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, Ast\Type\TypeNode $type) : Ast\Type\TypeNode { try { - while ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_SQUARE_BRACKET)) { + while ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_SQUARE_BRACKET)) { $tokens->pushSavePoint(); $canBeOffsetAccessType = !$tokens->isPrecededByHorizontalWhitespace(); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_SQUARE_BRACKET); - if ($canBeOffsetAccessType && !$tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_SQUARE_BRACKET)) { + $tokens->consumeTokenType(Lexer::TOKEN_OPEN_SQUARE_BRACKET); + if ($canBeOffsetAccessType && !$tokens->isCurrentTokenType(Lexer::TOKEN_CLOSE_SQUARE_BRACKET)) { $offset = $this->parse($tokens); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_SQUARE_BRACKET); + $tokens->consumeTokenType(Lexer::TOKEN_CLOSE_SQUARE_BRACKET); $tokens->dropSavePoint(); - $type = new \PHPStan\PhpDocParser\Ast\Type\OffsetAccessTypeNode($type, $offset); + $type = new Ast\Type\OffsetAccessTypeNode($type, $offset); } else { - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_SQUARE_BRACKET); + $tokens->consumeTokenType(Lexer::TOKEN_CLOSE_SQUARE_BRACKET); $tokens->dropSavePoint(); - $type = new \PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode($type); + $type = new Ast\Type\ArrayTypeNode($type); } } } catch (\PHPStan\PhpDocParser\Parser\ParserException $e) { @@ -360,43 +360,43 @@ class TypeParser return $type; } /** @phpstan-impure */ - private function parseArrayShape(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, \PHPStan\PhpDocParser\Ast\Type\TypeNode $type) : \PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode + private function parseArrayShape(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, Ast\Type\TypeNode $type) : Ast\Type\ArrayShapeNode { - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_CURLY_BRACKET); - if ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_CURLY_BRACKET)) { - return new \PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode([]); + $tokens->consumeTokenType(Lexer::TOKEN_OPEN_CURLY_BRACKET); + if ($tokens->tryConsumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET)) { + return new Ast\Type\ArrayShapeNode([]); } - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); $items = [$this->parseArrayShapeItem($tokens)]; - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); - while ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COMMA)) { - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); - if ($tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_CURLY_BRACKET)) { + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); + while ($tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA)) { + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); + if ($tokens->tryConsumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET)) { // trailing comma case - return new \PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode($items); + return new Ast\Type\ArrayShapeNode($items); } $items[] = $this->parseArrayShapeItem($tokens); - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); } - $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_CURLY_BRACKET); - return new \PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode($items); + $tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); + $tokens->consumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET); + return new Ast\Type\ArrayShapeNode($items); } /** @phpstan-impure */ - private function parseArrayShapeItem(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : \PHPStan\PhpDocParser\Ast\Type\ArrayShapeItemNode + private function parseArrayShapeItem(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\Type\ArrayShapeItemNode { try { $tokens->pushSavePoint(); $key = $this->parseArrayShapeKey($tokens); - $optional = $tokens->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_NULLABLE); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COLON); + $optional = $tokens->tryConsumeTokenType(Lexer::TOKEN_NULLABLE); + $tokens->consumeTokenType(Lexer::TOKEN_COLON); $value = $this->parse($tokens); $tokens->dropSavePoint(); - return new \PHPStan\PhpDocParser\Ast\Type\ArrayShapeItemNode($key, $optional, $value); + return new Ast\Type\ArrayShapeItemNode($key, $optional, $value); } catch (\PHPStan\PhpDocParser\Parser\ParserException $e) { $tokens->rollback(); $value = $this->parse($tokens); - return new \PHPStan\PhpDocParser\Ast\Type\ArrayShapeItemNode(null, \false, $value); + return new Ast\Type\ArrayShapeItemNode(null, \false, $value); } } /** @@ -405,18 +405,18 @@ class TypeParser */ private function parseArrayShapeKey(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) { - if ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_INTEGER)) { - $key = new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode($tokens->currentTokenValue()); + if ($tokens->isCurrentTokenType(Lexer::TOKEN_INTEGER)) { + $key = new Ast\ConstExpr\ConstExprIntegerNode($tokens->currentTokenValue()); $tokens->next(); - } elseif ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_SINGLE_QUOTED_STRING)) { - $key = new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprStringNode(\trim($tokens->currentTokenValue(), "'")); + } elseif ($tokens->isCurrentTokenType(Lexer::TOKEN_SINGLE_QUOTED_STRING)) { + $key = new Ast\ConstExpr\ConstExprStringNode(trim($tokens->currentTokenValue(), "'")); $tokens->next(); - } elseif ($tokens->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_DOUBLE_QUOTED_STRING)) { - $key = new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprStringNode(\trim($tokens->currentTokenValue(), '"')); + } elseif ($tokens->isCurrentTokenType(Lexer::TOKEN_DOUBLE_QUOTED_STRING)) { + $key = new Ast\ConstExpr\ConstExprStringNode(trim($tokens->currentTokenValue(), '"')); $tokens->next(); } else { - $key = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($tokens->currentTokenValue()); - $tokens->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER); + $key = new Ast\Type\IdentifierTypeNode($tokens->currentTokenValue()); + $tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER); } return $key; } diff --git a/vendor/phpstan/phpstan-phpunit/src/PhpDoc/PHPUnit/MockObjectTypeNodeResolverExtension.php b/vendor/phpstan/phpstan-phpunit/src/PhpDoc/PHPUnit/MockObjectTypeNodeResolverExtension.php index 8e4c3e6b224..66092cf9bcc 100644 --- a/vendor/phpstan/phpstan-phpunit/src/PhpDoc/PHPUnit/MockObjectTypeNodeResolverExtension.php +++ b/vendor/phpstan/phpstan-phpunit/src/PhpDoc/PHPUnit/MockObjectTypeNodeResolverExtension.php @@ -14,11 +14,11 @@ use PHPStan\Type\Type; use PHPStan\Type\TypeCombinator; use PHPStan\Type\TypeWithClassName; use function array_key_exists; -class MockObjectTypeNodeResolverExtension implements \PHPStan\PhpDoc\TypeNodeResolverExtension, \PHPStan\PhpDoc\TypeNodeResolverAwareExtension +class MockObjectTypeNodeResolverExtension implements TypeNodeResolverExtension, TypeNodeResolverAwareExtension { /** @var TypeNodeResolver */ private $typeNodeResolver; - public function setTypeNodeResolver(\PHPStan\PhpDoc\TypeNodeResolver $typeNodeResolver) : void + public function setTypeNodeResolver(TypeNodeResolver $typeNodeResolver) : void { $this->typeNodeResolver = $typeNodeResolver; } @@ -26,20 +26,20 @@ class MockObjectTypeNodeResolverExtension implements \PHPStan\PhpDoc\TypeNodeRes { return 'phpunit-v1'; } - public function resolve(\PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode, \PHPStan\Analyser\NameScope $nameScope) : ?\PHPStan\Type\Type + public function resolve(TypeNode $typeNode, NameScope $nameScope) : ?Type { - if (!$typeNode instanceof \PHPStan\PhpDocParser\Ast\Type\UnionTypeNode) { + if (!$typeNode instanceof UnionTypeNode) { return null; } static $mockClassNames = ['PHPUnit_Framework_MockObject_MockObject' => \true, 'RectorPrefix20220607\\PHPUnit\\Framework\\MockObject\\MockObject' => \true, 'RectorPrefix20220607\\PHPUnit\\Framework\\MockObject\\Stub' => \true]; $types = $this->typeNodeResolver->resolveMultiple($typeNode->types, $nameScope); foreach ($types as $type) { - if (!$type instanceof \PHPStan\Type\TypeWithClassName) { + if (!$type instanceof TypeWithClassName) { continue; } - if (\array_key_exists($type->getClassName(), $mockClassNames)) { - $resultType = \PHPStan\Type\TypeCombinator::intersect(...$types); - if ($resultType instanceof \PHPStan\Type\NeverType) { + if (array_key_exists($type->getClassName(), $mockClassNames)) { + $resultType = TypeCombinator::intersect(...$types); + if ($resultType instanceof NeverType) { continue; } return $resultType; diff --git a/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertRuleHelper.php b/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertRuleHelper.php index 2ff767f3ca8..14699b5f86e 100644 --- a/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertRuleHelper.php +++ b/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertRuleHelper.php @@ -10,18 +10,18 @@ use function in_array; use function strtolower; class AssertRuleHelper { - public static function isMethodOrStaticCallOnAssert(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : bool + public static function isMethodOrStaticCallOnAssert(Node $node, Scope $scope) : bool { - $testCaseType = new \PHPStan\Type\ObjectType('RectorPrefix20220607\\PHPUnit\\Framework\\Assert'); - if ($node instanceof \PhpParser\Node\Expr\MethodCall) { + $testCaseType = new ObjectType('RectorPrefix20220607\\PHPUnit\\Framework\\Assert'); + if ($node instanceof Node\Expr\MethodCall) { $calledOnType = $scope->getType($node->var); - } elseif ($node instanceof \PhpParser\Node\Expr\StaticCall) { - if ($node->class instanceof \PhpParser\Node\Name) { + } elseif ($node instanceof Node\Expr\StaticCall) { + if ($node->class instanceof Node\Name) { $class = (string) $node->class; - if ($scope->isInClass() && \in_array(\strtolower($class), ['self', 'static', 'parent'], \true)) { - $calledOnType = new \PHPStan\Type\ObjectType($scope->getClassReflection()->getName()); + if ($scope->isInClass() && in_array(strtolower($class), ['self', 'static', 'parent'], \true)) { + $calledOnType = new ObjectType($scope->getClassReflection()->getName()); } else { - $calledOnType = new \PHPStan\Type\ObjectType($class); + $calledOnType = new ObjectType($class); } } else { $calledOnType = $scope->getType($node->class); diff --git a/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertSameBooleanExpectedRule.php b/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertSameBooleanExpectedRule.php index 89b311c112b..89f99aa294f 100644 --- a/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertSameBooleanExpectedRule.php +++ b/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertSameBooleanExpectedRule.php @@ -15,27 +15,27 @@ use function strtolower; /** * @implements Rule */ -class AssertSameBooleanExpectedRule implements \PHPStan\Rules\Rule +class AssertSameBooleanExpectedRule implements Rule { public function getNodeType() : string { - return \PhpParser\NodeAbstract::class; + return NodeAbstract::class; } - public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : array + public function processNode(Node $node, Scope $scope) : array { if (!\PHPStan\Rules\PHPUnit\AssertRuleHelper::isMethodOrStaticCallOnAssert($node, $scope)) { return []; } /** @var MethodCall|StaticCall $node */ $node = $node; - if (\count($node->getArgs()) < 2) { + if (count($node->getArgs()) < 2) { return []; } - if (!$node->name instanceof \PhpParser\Node\Identifier || \strtolower($node->name->name) !== 'assertsame') { + if (!$node->name instanceof Node\Identifier || strtolower($node->name->name) !== 'assertsame') { return []; } $expectedArgumentValue = $node->getArgs()[0]->value; - if (!$expectedArgumentValue instanceof \PhpParser\Node\Expr\ConstFetch) { + if (!$expectedArgumentValue instanceof ConstFetch) { return []; } if ($expectedArgumentValue->name->toLowerString() === 'true') { diff --git a/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertSameNullExpectedRule.php b/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertSameNullExpectedRule.php index d11b47dd505..49403c94cfd 100644 --- a/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertSameNullExpectedRule.php +++ b/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertSameNullExpectedRule.php @@ -15,27 +15,27 @@ use function strtolower; /** * @implements Rule */ -class AssertSameNullExpectedRule implements \PHPStan\Rules\Rule +class AssertSameNullExpectedRule implements Rule { public function getNodeType() : string { - return \PhpParser\NodeAbstract::class; + return NodeAbstract::class; } - public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : array + public function processNode(Node $node, Scope $scope) : array { if (!\PHPStan\Rules\PHPUnit\AssertRuleHelper::isMethodOrStaticCallOnAssert($node, $scope)) { return []; } /** @var MethodCall|StaticCall $node */ $node = $node; - if (\count($node->getArgs()) < 2) { + if (count($node->getArgs()) < 2) { return []; } - if (!$node->name instanceof \PhpParser\Node\Identifier || \strtolower($node->name->name) !== 'assertsame') { + if (!$node->name instanceof Node\Identifier || strtolower($node->name->name) !== 'assertsame') { return []; } $expectedArgumentValue = $node->getArgs()[0]->value; - if (!$expectedArgumentValue instanceof \PhpParser\Node\Expr\ConstFetch) { + if (!$expectedArgumentValue instanceof ConstFetch) { return []; } if ($expectedArgumentValue->name->toLowerString() === 'null') { diff --git a/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertSameWithCountRule.php b/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertSameWithCountRule.php index caa9b0fed06..c2b6d2d9a1d 100644 --- a/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertSameWithCountRule.php +++ b/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/AssertSameWithCountRule.php @@ -16,32 +16,32 @@ use function strtolower; /** * @implements Rule */ -class AssertSameWithCountRule implements \PHPStan\Rules\Rule +class AssertSameWithCountRule implements Rule { public function getNodeType() : string { - return \PhpParser\NodeAbstract::class; + return NodeAbstract::class; } - public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : array + public function processNode(Node $node, Scope $scope) : array { if (!\PHPStan\Rules\PHPUnit\AssertRuleHelper::isMethodOrStaticCallOnAssert($node, $scope)) { return []; } /** @var MethodCall|StaticCall $node */ $node = $node; - if (\count($node->getArgs()) < 2) { + if (count($node->getArgs()) < 2) { return []; } - if (!$node->name instanceof \PhpParser\Node\Identifier || \strtolower($node->name->name) !== 'assertsame') { + if (!$node->name instanceof Node\Identifier || strtolower($node->name->name) !== 'assertsame') { return []; } $right = $node->getArgs()[1]->value; - if ($right instanceof \PhpParser\Node\Expr\FuncCall && $right->name instanceof \PhpParser\Node\Name && \strtolower($right->name->toString()) === 'count') { + if ($right instanceof Node\Expr\FuncCall && $right->name instanceof Node\Name && strtolower($right->name->toString()) === 'count') { return ['You should use assertCount($expectedCount, $variable) instead of assertSame($expectedCount, count($variable)).']; } - if ($right instanceof \PhpParser\Node\Expr\MethodCall && $right->name instanceof \PhpParser\Node\Identifier && \strtolower($right->name->toString()) === 'count' && \count($right->getArgs()) === 0) { + if ($right instanceof Node\Expr\MethodCall && $right->name instanceof Node\Identifier && strtolower($right->name->toString()) === 'count' && count($right->getArgs()) === 0) { $type = $scope->getType($right->var); - if ((new \PHPStan\Type\ObjectType(\Countable::class))->isSuperTypeOf($type)->yes()) { + if ((new ObjectType(Countable::class))->isSuperTypeOf($type)->yes()) { return ['You should use assertCount($expectedCount, $variable) instead of assertSame($expectedCount, $variable->count()).']; } } diff --git a/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/MockMethodCallRule.php b/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/MockMethodCallRule.php index ac8a0235cb4..5f2d0f08dcf 100644 --- a/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/MockMethodCallRule.php +++ b/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/MockMethodCallRule.php @@ -22,38 +22,38 @@ use function sprintf; /** * @implements Rule */ -class MockMethodCallRule implements \PHPStan\Rules\Rule +class MockMethodCallRule implements Rule { public function getNodeType() : string { - return \PhpParser\Node\Expr\MethodCall::class; + return Node\Expr\MethodCall::class; } - public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : array + public function processNode(Node $node, Scope $scope) : array { /** @var Node\Expr\MethodCall $node */ $node = $node; - if (!$node->name instanceof \PhpParser\Node\Identifier || $node->name->name !== 'method') { + if (!$node->name instanceof Node\Identifier || $node->name->name !== 'method') { return []; } - if (\count($node->getArgs()) < 1) { + if (count($node->getArgs()) < 1) { return []; } $argType = $scope->getType($node->getArgs()[0]->value); - if (!$argType instanceof \PHPStan\Type\Constant\ConstantStringType) { + if (!$argType instanceof ConstantStringType) { return []; } $method = $argType->getValue(); $type = $scope->getType($node->var); - if ($type instanceof \PHPStan\Type\IntersectionType && (\in_array(\RectorPrefix20220607\PHPUnit\Framework\MockObject\MockObject::class, $type->getReferencedClasses(), \true) || \in_array(\RectorPrefix20220607\PHPUnit\Framework\MockObject\Stub::class, $type->getReferencedClasses(), \true)) && !$type->hasMethod($method)->yes()) { - $mockClass = \array_filter($type->getReferencedClasses(), static function (string $class) : bool { - return $class !== \RectorPrefix20220607\PHPUnit\Framework\MockObject\MockObject::class && $class !== \RectorPrefix20220607\PHPUnit\Framework\MockObject\Stub::class; + if ($type instanceof IntersectionType && (in_array(MockObject::class, $type->getReferencedClasses(), \true) || in_array(Stub::class, $type->getReferencedClasses(), \true)) && !$type->hasMethod($method)->yes()) { + $mockClass = array_filter($type->getReferencedClasses(), static function (string $class) : bool { + return $class !== MockObject::class && $class !== Stub::class; }); - return [\sprintf('Trying to mock an undefined method %s() on class %s.', $method, \implode('&', $mockClass))]; + return [sprintf('Trying to mock an undefined method %s() on class %s.', $method, implode('&', $mockClass))]; } - if ($type instanceof \PHPStan\Type\Generic\GenericObjectType && $type->getClassName() === \RectorPrefix20220607\PHPUnit\Framework\MockObject\Builder\InvocationMocker::class && \count($type->getTypes()) > 0) { + if ($type instanceof GenericObjectType && $type->getClassName() === InvocationMocker::class && count($type->getTypes()) > 0) { $mockClass = $type->getTypes()[0]; - if ($mockClass instanceof \PHPStan\Type\ObjectType && !$mockClass->hasMethod($method)->yes()) { - return [\sprintf('Trying to mock an undefined method %s() on class %s.', $method, $mockClass->getClassName())]; + if ($mockClass instanceof ObjectType && !$mockClass->hasMethod($method)->yes()) { + return [sprintf('Trying to mock an undefined method %s() on class %s.', $method, $mockClass->getClassName())]; } } return []; diff --git a/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/ShouldCallParentMethodsRule.php b/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/ShouldCallParentMethodsRule.php index 0f7bc27122f..b99760ff447 100644 --- a/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/ShouldCallParentMethodsRule.php +++ b/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/ShouldCallParentMethodsRule.php @@ -8,29 +8,29 @@ use PHPStan\Analyser\Scope; use PHPStan\Node\InClassMethodNode; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; -use RectorPrefix20220607\PHPUnit\Framework\TestCase; +use PHPUnit\Framework\TestCase; use function in_array; use function sprintf; use function strtolower; /** * @implements Rule */ -class ShouldCallParentMethodsRule implements \PHPStan\Rules\Rule +class ShouldCallParentMethodsRule implements Rule { public function getNodeType() : string { - return \PHPStan\Node\InClassMethodNode::class; + return InClassMethodNode::class; } - public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : array + public function processNode(Node $node, Scope $scope) : array { $methodName = $node->getOriginalNode()->name->name; - if (!\in_array(\strtolower($methodName), ['setup', 'teardown'], \true)) { + if (!in_array(strtolower($methodName), ['setup', 'teardown'], \true)) { return []; } if ($scope->getClassReflection() === null) { return []; } - if (!$scope->getClassReflection()->isSubclassOf(\RectorPrefix20220607\PHPUnit\Framework\TestCase::class)) { + if (!$scope->getClassReflection()->isSubclassOf(TestCase::class)) { return []; } $parentClass = $scope->getClassReflection()->getParentClass(); @@ -41,12 +41,12 @@ class ShouldCallParentMethodsRule implements \PHPStan\Rules\Rule return []; } $parentMethod = $parentClass->getNativeMethod($methodName); - if ($parentMethod->getDeclaringClass()->getName() === \RectorPrefix20220607\PHPUnit\Framework\TestCase::class) { + if ($parentMethod->getDeclaringClass()->getName() === TestCase::class) { return []; } - $hasParentCall = $this->hasParentClassCall($node->getOriginalNode()->getStmts(), \strtolower($methodName)); + $hasParentCall = $this->hasParentClassCall($node->getOriginalNode()->getStmts(), strtolower($methodName)); if (!$hasParentCall) { - return [\PHPStan\Rules\RuleErrorBuilder::message(\sprintf('Missing call to parent::%s() method.', $methodName))->build()]; + return [RuleErrorBuilder::message(sprintf('Missing call to parent::%s() method.', $methodName))->build()]; } return []; } @@ -60,23 +60,23 @@ class ShouldCallParentMethodsRule implements \PHPStan\Rules\Rule return \false; } foreach ($stmts as $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Node\Stmt\Expression) { continue; } - if (!$stmt->expr instanceof \PhpParser\Node\Expr\StaticCall) { + if (!$stmt->expr instanceof Node\Expr\StaticCall) { continue; } - if (!$stmt->expr->class instanceof \PhpParser\Node\Name) { + if (!$stmt->expr->class instanceof Node\Name) { continue; } $class = (string) $stmt->expr->class; - if (\strtolower($class) !== 'parent') { + if (strtolower($class) !== 'parent') { continue; } - if (!$stmt->expr->name instanceof \PhpParser\Node\Identifier) { + if (!$stmt->expr->name instanceof Node\Identifier) { continue; } - if (\strtolower($stmt->expr->name->name) === $methodName) { + if (strtolower($stmt->expr->name->name) === $methodName) { return \true; } } diff --git a/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/Assert/AssertFunctionTypeSpecifyingExtension.php b/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/Assert/AssertFunctionTypeSpecifyingExtension.php index 0f96abc7ece..9b8f4fc9666 100644 --- a/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/Assert/AssertFunctionTypeSpecifyingExtension.php +++ b/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/Assert/AssertFunctionTypeSpecifyingExtension.php @@ -14,27 +14,27 @@ use PHPStan\Type\FunctionTypeSpecifyingExtension; use function strlen; use function strpos; use function substr; -class AssertFunctionTypeSpecifyingExtension implements \PHPStan\Type\FunctionTypeSpecifyingExtension, \PHPStan\Analyser\TypeSpecifierAwareExtension +class AssertFunctionTypeSpecifyingExtension implements FunctionTypeSpecifyingExtension, TypeSpecifierAwareExtension { /** @var TypeSpecifier */ private $typeSpecifier; - public function setTypeSpecifier(\PHPStan\Analyser\TypeSpecifier $typeSpecifier) : void + public function setTypeSpecifier(TypeSpecifier $typeSpecifier) : void { $this->typeSpecifier = $typeSpecifier; } - public function isFunctionSupported(\PHPStan\Reflection\FunctionReflection $functionReflection, \PhpParser\Node\Expr\FuncCall $node, \PHPStan\Analyser\TypeSpecifierContext $context) : bool + public function isFunctionSupported(FunctionReflection $functionReflection, FuncCall $node, TypeSpecifierContext $context) : bool { return \PHPStan\Type\PHPUnit\Assert\AssertTypeSpecifyingExtensionHelper::isSupported($this->trimName($functionReflection->getName()), $node->getArgs()); } - public function specifyTypes(\PHPStan\Reflection\FunctionReflection $functionReflection, \PhpParser\Node\Expr\FuncCall $node, \PHPStan\Analyser\Scope $scope, \PHPStan\Analyser\TypeSpecifierContext $context) : \PHPStan\Analyser\SpecifiedTypes + public function specifyTypes(FunctionReflection $functionReflection, FuncCall $node, Scope $scope, TypeSpecifierContext $context) : SpecifiedTypes { return \PHPStan\Type\PHPUnit\Assert\AssertTypeSpecifyingExtensionHelper::specifyTypes($this->typeSpecifier, $scope, $this->trimName($functionReflection->getName()), $node->getArgs()); } private function trimName(string $functionName) : string { $prefix = 'PHPUnit\\Framework\\'; - if (\strpos($functionName, $prefix) === 0) { - return \substr($functionName, \strlen($prefix)); + if (strpos($functionName, $prefix) === 0) { + return substr($functionName, strlen($prefix)); } return $functionName; } diff --git a/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/Assert/AssertMethodTypeSpecifyingExtension.php b/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/Assert/AssertMethodTypeSpecifyingExtension.php index 81b35deb28e..75b52acc221 100644 --- a/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/Assert/AssertMethodTypeSpecifyingExtension.php +++ b/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/Assert/AssertMethodTypeSpecifyingExtension.php @@ -11,11 +11,11 @@ use PHPStan\Analyser\TypeSpecifierAwareExtension; use PHPStan\Analyser\TypeSpecifierContext; use PHPStan\Reflection\MethodReflection; use PHPStan\Type\MethodTypeSpecifyingExtension; -class AssertMethodTypeSpecifyingExtension implements \PHPStan\Type\MethodTypeSpecifyingExtension, \PHPStan\Analyser\TypeSpecifierAwareExtension +class AssertMethodTypeSpecifyingExtension implements MethodTypeSpecifyingExtension, TypeSpecifierAwareExtension { /** @var TypeSpecifier */ private $typeSpecifier; - public function setTypeSpecifier(\PHPStan\Analyser\TypeSpecifier $typeSpecifier) : void + public function setTypeSpecifier(TypeSpecifier $typeSpecifier) : void { $this->typeSpecifier = $typeSpecifier; } @@ -23,11 +23,11 @@ class AssertMethodTypeSpecifyingExtension implements \PHPStan\Type\MethodTypeSpe { return 'RectorPrefix20220607\\PHPUnit\\Framework\\Assert'; } - public function isMethodSupported(\PHPStan\Reflection\MethodReflection $methodReflection, \PhpParser\Node\Expr\MethodCall $node, \PHPStan\Analyser\TypeSpecifierContext $context) : bool + public function isMethodSupported(MethodReflection $methodReflection, MethodCall $node, TypeSpecifierContext $context) : bool { return \PHPStan\Type\PHPUnit\Assert\AssertTypeSpecifyingExtensionHelper::isSupported($methodReflection->getName(), $node->getArgs()); } - public function specifyTypes(\PHPStan\Reflection\MethodReflection $functionReflection, \PhpParser\Node\Expr\MethodCall $node, \PHPStan\Analyser\Scope $scope, \PHPStan\Analyser\TypeSpecifierContext $context) : \PHPStan\Analyser\SpecifiedTypes + public function specifyTypes(MethodReflection $functionReflection, MethodCall $node, Scope $scope, TypeSpecifierContext $context) : SpecifiedTypes { return \PHPStan\Type\PHPUnit\Assert\AssertTypeSpecifyingExtensionHelper::specifyTypes($this->typeSpecifier, $scope, $functionReflection->getName(), $node->getArgs()); } diff --git a/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/Assert/AssertStaticMethodTypeSpecifyingExtension.php b/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/Assert/AssertStaticMethodTypeSpecifyingExtension.php index 72fb29f243c..69f2ad2a334 100644 --- a/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/Assert/AssertStaticMethodTypeSpecifyingExtension.php +++ b/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/Assert/AssertStaticMethodTypeSpecifyingExtension.php @@ -11,11 +11,11 @@ use PHPStan\Analyser\TypeSpecifierAwareExtension; use PHPStan\Analyser\TypeSpecifierContext; use PHPStan\Reflection\MethodReflection; use PHPStan\Type\StaticMethodTypeSpecifyingExtension; -class AssertStaticMethodTypeSpecifyingExtension implements \PHPStan\Type\StaticMethodTypeSpecifyingExtension, \PHPStan\Analyser\TypeSpecifierAwareExtension +class AssertStaticMethodTypeSpecifyingExtension implements StaticMethodTypeSpecifyingExtension, TypeSpecifierAwareExtension { /** @var TypeSpecifier */ private $typeSpecifier; - public function setTypeSpecifier(\PHPStan\Analyser\TypeSpecifier $typeSpecifier) : void + public function setTypeSpecifier(TypeSpecifier $typeSpecifier) : void { $this->typeSpecifier = $typeSpecifier; } @@ -23,11 +23,11 @@ class AssertStaticMethodTypeSpecifyingExtension implements \PHPStan\Type\StaticM { return 'RectorPrefix20220607\\PHPUnit\\Framework\\Assert'; } - public function isStaticMethodSupported(\PHPStan\Reflection\MethodReflection $methodReflection, \PhpParser\Node\Expr\StaticCall $node, \PHPStan\Analyser\TypeSpecifierContext $context) : bool + public function isStaticMethodSupported(MethodReflection $methodReflection, StaticCall $node, TypeSpecifierContext $context) : bool { return \PHPStan\Type\PHPUnit\Assert\AssertTypeSpecifyingExtensionHelper::isSupported($methodReflection->getName(), $node->getArgs()); } - public function specifyTypes(\PHPStan\Reflection\MethodReflection $functionReflection, \PhpParser\Node\Expr\StaticCall $node, \PHPStan\Analyser\Scope $scope, \PHPStan\Analyser\TypeSpecifierContext $context) : \PHPStan\Analyser\SpecifiedTypes + public function specifyTypes(MethodReflection $functionReflection, StaticCall $node, Scope $scope, TypeSpecifierContext $context) : SpecifiedTypes { return \PHPStan\Type\PHPUnit\Assert\AssertTypeSpecifyingExtensionHelper::specifyTypes($this->typeSpecifier, $scope, $functionReflection->getName(), $node->getArgs()); } diff --git a/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/Assert/AssertTypeSpecifyingExtensionHelper.php b/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/Assert/AssertTypeSpecifyingExtensionHelper.php index a3f47845295..427b2db26af 100644 --- a/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/Assert/AssertTypeSpecifyingExtensionHelper.php +++ b/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/Assert/AssertTypeSpecifyingExtensionHelper.php @@ -34,42 +34,42 @@ class AssertTypeSpecifyingExtensionHelper { $trimmedName = self::trimName($name); $resolvers = self::getExpressionResolvers(); - if (!\array_key_exists($trimmedName, $resolvers)) { + if (!array_key_exists($trimmedName, $resolvers)) { return \false; } $resolver = $resolvers[$trimmedName]; - $resolverReflection = new \ReflectionObject($resolver); - return \count($args) >= \count($resolverReflection->getMethod('__invoke')->getParameters()) - 1; + $resolverReflection = new ReflectionObject($resolver); + return count($args) >= count($resolverReflection->getMethod('__invoke')->getParameters()) - 1; } private static function trimName(string $name) : string { - if (\strpos($name, 'assert') !== 0) { + if (strpos($name, 'assert') !== 0) { return $name; } - $name = \substr($name, \strlen('assert')); - if (\strpos($name, 'Not') === 0) { - return \substr($name, 3); + $name = substr($name, strlen('assert')); + if (strpos($name, 'Not') === 0) { + return substr($name, 3); } - if (\strpos($name, 'IsNot') === 0) { - return 'Is' . \substr($name, 5); + if (strpos($name, 'IsNot') === 0) { + return 'Is' . substr($name, 5); } return $name; } /** * @param Arg[] $args $args */ - public static function specifyTypes(\PHPStan\Analyser\TypeSpecifier $typeSpecifier, \PHPStan\Analyser\Scope $scope, string $name, array $args) : \PHPStan\Analyser\SpecifiedTypes + public static function specifyTypes(TypeSpecifier $typeSpecifier, Scope $scope, string $name, array $args) : SpecifiedTypes { $expression = self::createExpression($scope, $name, $args); if ($expression === null) { - return new \PHPStan\Analyser\SpecifiedTypes([], []); + return new SpecifiedTypes([], []); } - return $typeSpecifier->specifyTypesInCondition($scope, $expression, \PHPStan\Analyser\TypeSpecifierContext::createTruthy()); + return $typeSpecifier->specifyTypesInCondition($scope, $expression, TypeSpecifierContext::createTruthy()); } /** * @param Arg[] $args */ - private static function createExpression(\PHPStan\Analyser\Scope $scope, string $name, array $args) : ?\PhpParser\Node\Expr + private static function createExpression(Scope $scope, string $name, array $args) : ?Expr { $trimmedName = self::trimName($name); $resolvers = self::getExpressionResolvers(); @@ -78,8 +78,8 @@ class AssertTypeSpecifyingExtensionHelper if ($expression === null) { return null; } - if (\strpos($name, 'Not') !== \false) { - $expression = new \PhpParser\Node\Expr\BooleanNot($expression); + if (strpos($name, 'Not') !== \false) { + $expression = new BooleanNot($expression); } return $expression; } @@ -89,45 +89,45 @@ class AssertTypeSpecifyingExtensionHelper private static function getExpressionResolvers() : array { if (self::$resolvers === null) { - self::$resolvers = ['InstanceOf' => static function (\PHPStan\Analyser\Scope $scope, \PhpParser\Node\Arg $class, \PhpParser\Node\Arg $object) : ?Instanceof_ { + self::$resolvers = ['InstanceOf' => static function (Scope $scope, Arg $class, Arg $object) : ?Instanceof_ { $classType = $scope->getType($class->value); - if (!$classType instanceof \PHPStan\Type\Constant\ConstantStringType) { + if (!$classType instanceof ConstantStringType) { return null; } - return new \PhpParser\Node\Expr\Instanceof_($object->value, new \PhpParser\Node\Name($classType->getValue())); - }, 'Same' => static function (\PHPStan\Analyser\Scope $scope, \PhpParser\Node\Arg $expected, \PhpParser\Node\Arg $actual) : Identical { - return new \PhpParser\Node\Expr\BinaryOp\Identical($expected->value, $actual->value); - }, 'True' => static function (\PHPStan\Analyser\Scope $scope, \PhpParser\Node\Arg $actual) : Identical { - return new \PhpParser\Node\Expr\BinaryOp\Identical($actual->value, new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('true'))); - }, 'False' => static function (\PHPStan\Analyser\Scope $scope, \PhpParser\Node\Arg $actual) : Identical { - return new \PhpParser\Node\Expr\BinaryOp\Identical($actual->value, new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('false'))); - }, 'Null' => static function (\PHPStan\Analyser\Scope $scope, \PhpParser\Node\Arg $actual) : Identical { - return new \PhpParser\Node\Expr\BinaryOp\Identical($actual->value, new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('null'))); - }, 'IsArray' => static function (\PHPStan\Analyser\Scope $scope, \PhpParser\Node\Arg $actual) : FuncCall { - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('is_array'), [$actual]); - }, 'IsBool' => static function (\PHPStan\Analyser\Scope $scope, \PhpParser\Node\Arg $actual) : FuncCall { - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('is_bool'), [$actual]); - }, 'IsCallable' => static function (\PHPStan\Analyser\Scope $scope, \PhpParser\Node\Arg $actual) : FuncCall { - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('is_callable'), [$actual]); - }, 'IsFloat' => static function (\PHPStan\Analyser\Scope $scope, \PhpParser\Node\Arg $actual) : FuncCall { - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('is_float'), [$actual]); - }, 'IsInt' => static function (\PHPStan\Analyser\Scope $scope, \PhpParser\Node\Arg $actual) : FuncCall { - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('is_int'), [$actual]); - }, 'IsIterable' => static function (\PHPStan\Analyser\Scope $scope, \PhpParser\Node\Arg $actual) : FuncCall { - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('is_iterable'), [$actual]); - }, 'IsNumeric' => static function (\PHPStan\Analyser\Scope $scope, \PhpParser\Node\Arg $actual) : FuncCall { - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('is_numeric'), [$actual]); - }, 'IsObject' => static function (\PHPStan\Analyser\Scope $scope, \PhpParser\Node\Arg $actual) : FuncCall { - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('is_object'), [$actual]); - }, 'IsResource' => static function (\PHPStan\Analyser\Scope $scope, \PhpParser\Node\Arg $actual) : FuncCall { - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('is_resource'), [$actual]); - }, 'IsString' => static function (\PHPStan\Analyser\Scope $scope, \PhpParser\Node\Arg $actual) : FuncCall { - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('is_string'), [$actual]); - }, 'IsScalar' => static function (\PHPStan\Analyser\Scope $scope, \PhpParser\Node\Arg $actual) : FuncCall { - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('is_scalar'), [$actual]); - }, 'InternalType' => static function (\PHPStan\Analyser\Scope $scope, \PhpParser\Node\Arg $type, \PhpParser\Node\Arg $value) : ?FuncCall { + return new Instanceof_($object->value, new Name($classType->getValue())); + }, 'Same' => static function (Scope $scope, Arg $expected, Arg $actual) : Identical { + return new Identical($expected->value, $actual->value); + }, 'True' => static function (Scope $scope, Arg $actual) : Identical { + return new Identical($actual->value, new ConstFetch(new Name('true'))); + }, 'False' => static function (Scope $scope, Arg $actual) : Identical { + return new Identical($actual->value, new ConstFetch(new Name('false'))); + }, 'Null' => static function (Scope $scope, Arg $actual) : Identical { + return new Identical($actual->value, new ConstFetch(new Name('null'))); + }, 'IsArray' => static function (Scope $scope, Arg $actual) : FuncCall { + return new FuncCall(new Name('is_array'), [$actual]); + }, 'IsBool' => static function (Scope $scope, Arg $actual) : FuncCall { + return new FuncCall(new Name('is_bool'), [$actual]); + }, 'IsCallable' => static function (Scope $scope, Arg $actual) : FuncCall { + return new FuncCall(new Name('is_callable'), [$actual]); + }, 'IsFloat' => static function (Scope $scope, Arg $actual) : FuncCall { + return new FuncCall(new Name('is_float'), [$actual]); + }, 'IsInt' => static function (Scope $scope, Arg $actual) : FuncCall { + return new FuncCall(new Name('is_int'), [$actual]); + }, 'IsIterable' => static function (Scope $scope, Arg $actual) : FuncCall { + return new FuncCall(new Name('is_iterable'), [$actual]); + }, 'IsNumeric' => static function (Scope $scope, Arg $actual) : FuncCall { + return new FuncCall(new Name('is_numeric'), [$actual]); + }, 'IsObject' => static function (Scope $scope, Arg $actual) : FuncCall { + return new FuncCall(new Name('is_object'), [$actual]); + }, 'IsResource' => static function (Scope $scope, Arg $actual) : FuncCall { + return new FuncCall(new Name('is_resource'), [$actual]); + }, 'IsString' => static function (Scope $scope, Arg $actual) : FuncCall { + return new FuncCall(new Name('is_string'), [$actual]); + }, 'IsScalar' => static function (Scope $scope, Arg $actual) : FuncCall { + return new FuncCall(new Name('is_scalar'), [$actual]); + }, 'InternalType' => static function (Scope $scope, Arg $type, Arg $value) : ?FuncCall { $typeType = $scope->getType($type->value); - if (!$typeType instanceof \PHPStan\Type\Constant\ConstantStringType) { + if (!$typeType instanceof ConstantStringType) { return null; } switch ($typeType->getValue()) { @@ -171,11 +171,11 @@ class AssertTypeSpecifyingExtensionHelper default: return null; } - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name($functionName), [$value]); - }, 'ArrayHasKey' => static function (\PHPStan\Analyser\Scope $scope, \PhpParser\Node\Arg $key, \PhpParser\Node\Arg $array) : FuncCall { - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('array_key_exists'), [$key, $array]); - }, 'ObjectHasAttribute' => static function (\PHPStan\Analyser\Scope $scope, \PhpParser\Node\Arg $property, \PhpParser\Node\Arg $object) : FuncCall { - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('property_exists'), [$object, $property]); + return new FuncCall(new Name($functionName), [$value]); + }, 'ArrayHasKey' => static function (Scope $scope, Arg $key, Arg $array) : FuncCall { + return new FuncCall(new Name('array_key_exists'), [$key, $array]); + }, 'ObjectHasAttribute' => static function (Scope $scope, Arg $property, Arg $object) : FuncCall { + return new FuncCall(new Name('property_exists'), [$object, $property]); }]; } return self::$resolvers; diff --git a/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/InvocationMockerDynamicReturnTypeExtension.php b/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/InvocationMockerDynamicReturnTypeExtension.php index 9e2d2997397..b92550deb59 100644 --- a/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/InvocationMockerDynamicReturnTypeExtension.php +++ b/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/InvocationMockerDynamicReturnTypeExtension.php @@ -9,17 +9,17 @@ use PHPStan\Reflection\MethodReflection; use PHPStan\Type\DynamicMethodReturnTypeExtension; use PHPStan\Type\Type; use RectorPrefix20220607\PHPUnit\Framework\MockObject\Builder\InvocationMocker; -class InvocationMockerDynamicReturnTypeExtension implements \PHPStan\Type\DynamicMethodReturnTypeExtension +class InvocationMockerDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { public function getClass() : string { - return \RectorPrefix20220607\PHPUnit\Framework\MockObject\Builder\InvocationMocker::class; + return InvocationMocker::class; } - public function isMethodSupported(\PHPStan\Reflection\MethodReflection $methodReflection) : bool + public function isMethodSupported(MethodReflection $methodReflection) : bool { return $methodReflection->getName() !== 'getMatcher'; } - public function getTypeFromMethodCall(\PHPStan\Reflection\MethodReflection $methodReflection, \PhpParser\Node\Expr\MethodCall $methodCall, \PHPStan\Analyser\Scope $scope) : ?\PHPStan\Type\Type + public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope) : ?\PHPStan\Type\Type { return $scope->getType($methodCall->var); } diff --git a/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/MockBuilderDynamicReturnTypeExtension.php b/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/MockBuilderDynamicReturnTypeExtension.php index 4cb8fbbfbf1..6242c5f0527 100644 --- a/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/MockBuilderDynamicReturnTypeExtension.php +++ b/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/MockBuilderDynamicReturnTypeExtension.php @@ -10,17 +10,17 @@ use PHPStan\Type\DynamicMethodReturnTypeExtension; use PHPStan\Type\Type; use RectorPrefix20220607\PHPUnit\Framework\MockObject\MockBuilder; use function in_array; -class MockBuilderDynamicReturnTypeExtension implements \PHPStan\Type\DynamicMethodReturnTypeExtension +class MockBuilderDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { public function getClass() : string { - return \RectorPrefix20220607\PHPUnit\Framework\MockObject\MockBuilder::class; + return MockBuilder::class; } - public function isMethodSupported(\PHPStan\Reflection\MethodReflection $methodReflection) : bool + public function isMethodSupported(MethodReflection $methodReflection) : bool { - return !\in_array($methodReflection->getName(), ['getMock', 'getMockForAbstractClass', 'getMockForTrait'], \true); + return !in_array($methodReflection->getName(), ['getMock', 'getMockForAbstractClass', 'getMockForTrait'], \true); } - public function getTypeFromMethodCall(\PHPStan\Reflection\MethodReflection $methodReflection, \PhpParser\Node\Expr\MethodCall $methodCall, \PHPStan\Analyser\Scope $scope) : ?\PHPStan\Type\Type + public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope) : ?\PHPStan\Type\Type { return $scope->getType($methodCall->var); } diff --git a/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/MockObjectDynamicReturnTypeExtension.php b/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/MockObjectDynamicReturnTypeExtension.php index c77234ab5c6..30b06b5b1e6 100644 --- a/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/MockObjectDynamicReturnTypeExtension.php +++ b/vendor/phpstan/phpstan-phpunit/src/Type/PHPUnit/MockObjectDynamicReturnTypeExtension.php @@ -17,28 +17,28 @@ use RectorPrefix20220607\PHPUnit\Framework\MockObject\MockObject; use function array_filter; use function array_values; use function count; -class MockObjectDynamicReturnTypeExtension implements \PHPStan\Type\DynamicMethodReturnTypeExtension +class MockObjectDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { public function getClass() : string { - return \RectorPrefix20220607\PHPUnit\Framework\MockObject\MockObject::class; + return MockObject::class; } - public function isMethodSupported(\PHPStan\Reflection\MethodReflection $methodReflection) : bool + public function isMethodSupported(MethodReflection $methodReflection) : bool { return $methodReflection->getName() === 'expects'; } - public function getTypeFromMethodCall(\PHPStan\Reflection\MethodReflection $methodReflection, \PhpParser\Node\Expr\MethodCall $methodCall, \PHPStan\Analyser\Scope $scope) : ?\PHPStan\Type\Type + public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope) : ?\PHPStan\Type\Type { $type = $scope->getType($methodCall->var); - if (!$type instanceof \PHPStan\Type\IntersectionType) { - return new \PHPStan\Type\ObjectType(\RectorPrefix20220607\PHPUnit\Framework\MockObject\Builder\InvocationMocker::class); + if (!$type instanceof IntersectionType) { + return new ObjectType(InvocationMocker::class); } - $mockClasses = \array_values(\array_filter($type->getTypes(), static function (\PHPStan\Type\Type $type) : bool { - return !$type instanceof \PHPStan\Type\TypeWithClassName || $type->getClassName() !== \RectorPrefix20220607\PHPUnit\Framework\MockObject\MockObject::class; + $mockClasses = array_values(array_filter($type->getTypes(), static function (Type $type) : bool { + return !$type instanceof TypeWithClassName || $type->getClassName() !== MockObject::class; })); - if (\count($mockClasses) !== 1) { - return new \PHPStan\Type\ObjectType(\RectorPrefix20220607\PHPUnit\Framework\MockObject\Builder\InvocationMocker::class); + if (count($mockClasses) !== 1) { + return new ObjectType(InvocationMocker::class); } - return new \PHPStan\Type\Generic\GenericObjectType(\RectorPrefix20220607\PHPUnit\Framework\MockObject\Builder\InvocationMocker::class, $mockClasses); + return new GenericObjectType(InvocationMocker::class, $mockClasses); } } diff --git a/vendor/phpstan/phpstan/bootstrap.php b/vendor/phpstan/phpstan/bootstrap.php index 805aa06b1fb..bc812370df0 100644 --- a/vendor/phpstan/phpstan/bootstrap.php +++ b/vendor/phpstan/phpstan/bootstrap.php @@ -10,7 +10,7 @@ final class PharAutoloader private static $composerAutoloader; public static final function loadClass(string $class) : void { - if (!\extension_loaded('phar') || \defined('__PHPSTAN_RUNNING__')) { + if (!\extension_loaded('phar') || \defined('RectorPrefix20220607\\__PHPSTAN_RUNNING__')) { return; } if (\strpos($class, '_PHPStan_') === 0) { diff --git a/vendor/psr/cache/src/CacheItemPoolInterface.php b/vendor/psr/cache/src/CacheItemPoolInterface.php index 14803719229..a9f0f64bd22 100644 --- a/vendor/psr/cache/src/CacheItemPoolInterface.php +++ b/vendor/psr/cache/src/CacheItemPoolInterface.php @@ -29,7 +29,7 @@ interface CacheItemPoolInterface * @return CacheItemInterface * The corresponding Cache Item. */ - public function getItem(string $key) : \RectorPrefix20220607\Psr\Cache\CacheItemInterface; + public function getItem(string $key) : CacheItemInterface; /** * Returns a traversable set of cache items. * @@ -109,7 +109,7 @@ interface CacheItemPoolInterface * @return bool * True if the item was successfully persisted. False if there was an error. */ - public function save(\RectorPrefix20220607\Psr\Cache\CacheItemInterface $item) : bool; + public function save(CacheItemInterface $item) : bool; /** * Sets a cache item to be persisted later. * @@ -119,7 +119,7 @@ interface CacheItemPoolInterface * @return bool * False if the item could not be queued or if a commit was attempted and failed. True otherwise. */ - public function saveDeferred(\RectorPrefix20220607\Psr\Cache\CacheItemInterface $item) : bool; + public function saveDeferred(CacheItemInterface $item) : bool; /** * Persists any deferred cache items. * diff --git a/vendor/psr/cache/src/InvalidArgumentException.php b/vendor/psr/cache/src/InvalidArgumentException.php index 3ff6710882c..7a1d6d1b193 100644 --- a/vendor/psr/cache/src/InvalidArgumentException.php +++ b/vendor/psr/cache/src/InvalidArgumentException.php @@ -8,6 +8,6 @@ namespace RectorPrefix20220607\Psr\Cache; * Any time an invalid argument is passed into a method it must throw an * exception class which implements Psr\Cache\InvalidArgumentException. */ -interface InvalidArgumentException extends \RectorPrefix20220607\Psr\Cache\CacheException +interface InvalidArgumentException extends CacheException { } diff --git a/vendor/psr/container/src/ContainerExceptionInterface.php b/vendor/psr/container/src/ContainerExceptionInterface.php index 9e41219addd..4d96de916dd 100644 --- a/vendor/psr/container/src/ContainerExceptionInterface.php +++ b/vendor/psr/container/src/ContainerExceptionInterface.php @@ -6,6 +6,6 @@ use Throwable; /** * Base interface representing a generic exception in a container. */ -interface ContainerExceptionInterface extends \Throwable +interface ContainerExceptionInterface extends Throwable { } diff --git a/vendor/psr/container/src/NotFoundExceptionInterface.php b/vendor/psr/container/src/NotFoundExceptionInterface.php index 718a854b76a..17d788b12d4 100644 --- a/vendor/psr/container/src/NotFoundExceptionInterface.php +++ b/vendor/psr/container/src/NotFoundExceptionInterface.php @@ -5,6 +5,6 @@ namespace RectorPrefix20220607\Psr\Container; /** * No entry was found in the container. */ -interface NotFoundExceptionInterface extends \RectorPrefix20220607\Psr\Container\ContainerExceptionInterface +interface NotFoundExceptionInterface extends ContainerExceptionInterface { } diff --git a/vendor/psr/log/src/AbstractLogger.php b/vendor/psr/log/src/AbstractLogger.php index 271feb3b3e7..06c5043c26b 100644 --- a/vendor/psr/log/src/AbstractLogger.php +++ b/vendor/psr/log/src/AbstractLogger.php @@ -9,7 +9,7 @@ namespace RectorPrefix20220607\Psr\Log; * reduce boilerplate code that a simple Logger that does the same thing with * messages regardless of the error level has to implement. */ -abstract class AbstractLogger implements \RectorPrefix20220607\Psr\Log\LoggerInterface +abstract class AbstractLogger implements LoggerInterface { use LoggerTrait; } diff --git a/vendor/psr/log/src/LoggerAwareInterface.php b/vendor/psr/log/src/LoggerAwareInterface.php index 4ce7738da57..6e8f7d1569a 100644 --- a/vendor/psr/log/src/LoggerAwareInterface.php +++ b/vendor/psr/log/src/LoggerAwareInterface.php @@ -14,5 +14,5 @@ interface LoggerAwareInterface * * @return void */ - public function setLogger(\RectorPrefix20220607\Psr\Log\LoggerInterface $logger) : void; + public function setLogger(LoggerInterface $logger) : void; } diff --git a/vendor/psr/log/src/LoggerAwareTrait.php b/vendor/psr/log/src/LoggerAwareTrait.php index ffd2232843e..7f5cd7dd0f4 100644 --- a/vendor/psr/log/src/LoggerAwareTrait.php +++ b/vendor/psr/log/src/LoggerAwareTrait.php @@ -18,7 +18,7 @@ trait LoggerAwareTrait * * @param LoggerInterface $logger */ - public function setLogger(\RectorPrefix20220607\Psr\Log\LoggerInterface $logger) : void + public function setLogger(LoggerInterface $logger) : void { $this->logger = $logger; } diff --git a/vendor/psr/log/src/LoggerTrait.php b/vendor/psr/log/src/LoggerTrait.php index ce89472af74..2d1c5bd9f39 100644 --- a/vendor/psr/log/src/LoggerTrait.php +++ b/vendor/psr/log/src/LoggerTrait.php @@ -22,7 +22,7 @@ trait LoggerTrait */ public function emergency($message, array $context = []) : void { - $this->log(\RectorPrefix20220607\Psr\Log\LogLevel::EMERGENCY, $message, $context); + $this->log(LogLevel::EMERGENCY, $message, $context); } /** * Action must be taken immediately. @@ -37,7 +37,7 @@ trait LoggerTrait */ public function alert($message, array $context = []) : void { - $this->log(\RectorPrefix20220607\Psr\Log\LogLevel::ALERT, $message, $context); + $this->log(LogLevel::ALERT, $message, $context); } /** * Critical conditions. @@ -51,7 +51,7 @@ trait LoggerTrait */ public function critical($message, array $context = []) : void { - $this->log(\RectorPrefix20220607\Psr\Log\LogLevel::CRITICAL, $message, $context); + $this->log(LogLevel::CRITICAL, $message, $context); } /** * Runtime errors that do not require immediate action but should typically @@ -64,7 +64,7 @@ trait LoggerTrait */ public function error($message, array $context = []) : void { - $this->log(\RectorPrefix20220607\Psr\Log\LogLevel::ERROR, $message, $context); + $this->log(LogLevel::ERROR, $message, $context); } /** * Exceptional occurrences that are not errors. @@ -79,7 +79,7 @@ trait LoggerTrait */ public function warning($message, array $context = []) : void { - $this->log(\RectorPrefix20220607\Psr\Log\LogLevel::WARNING, $message, $context); + $this->log(LogLevel::WARNING, $message, $context); } /** * Normal but significant events. @@ -91,7 +91,7 @@ trait LoggerTrait */ public function notice($message, array $context = []) : void { - $this->log(\RectorPrefix20220607\Psr\Log\LogLevel::NOTICE, $message, $context); + $this->log(LogLevel::NOTICE, $message, $context); } /** * Interesting events. @@ -105,7 +105,7 @@ trait LoggerTrait */ public function info($message, array $context = []) : void { - $this->log(\RectorPrefix20220607\Psr\Log\LogLevel::INFO, $message, $context); + $this->log(LogLevel::INFO, $message, $context); } /** * Detailed debug information. @@ -117,7 +117,7 @@ trait LoggerTrait */ public function debug($message, array $context = []) : void { - $this->log(\RectorPrefix20220607\Psr\Log\LogLevel::DEBUG, $message, $context); + $this->log(LogLevel::DEBUG, $message, $context); } /** * Logs with an arbitrary level. diff --git a/vendor/psr/log/src/NullLogger.php b/vendor/psr/log/src/NullLogger.php index fbd574f6edd..056882d4037 100644 --- a/vendor/psr/log/src/NullLogger.php +++ b/vendor/psr/log/src/NullLogger.php @@ -10,7 +10,7 @@ namespace RectorPrefix20220607\Psr\Log; * is a good way to avoid littering your code with `if ($this->logger) { }` * blocks. */ -class NullLogger extends \RectorPrefix20220607\Psr\Log\AbstractLogger +class NullLogger extends AbstractLogger { /** * Logs with an arbitrary level. diff --git a/vendor/react/cache/src/ArrayCache.php b/vendor/react/cache/src/ArrayCache.php index dc7fd0ea169..b74bdec42fb 100644 --- a/vendor/react/cache/src/ArrayCache.php +++ b/vendor/react/cache/src/ArrayCache.php @@ -4,7 +4,7 @@ namespace RectorPrefix20220607\React\Cache; use RectorPrefix20220607\React\Promise; use RectorPrefix20220607\React\Promise\PromiseInterface; -class ArrayCache implements \RectorPrefix20220607\React\Cache\CacheInterface +class ArrayCache implements CacheInterface { private $limit; private $data = array(); @@ -60,13 +60,13 @@ class ArrayCache implements \RectorPrefix20220607\React\Cache\CacheInterface unset($this->data[$key], $this->expires[$key]); } if (!\array_key_exists($key, $this->data)) { - return \RectorPrefix20220607\React\Promise\resolve($default); + return Promise\resolve($default); } // remove and append to end of array to keep track of LRU info $value = $this->data[$key]; unset($this->data[$key]); $this->data[$key] = $value; - return \RectorPrefix20220607\React\Promise\resolve($value); + return Promise\resolve($value); } public function set($key, $value, $ttl = null) { @@ -93,12 +93,12 @@ class ArrayCache implements \RectorPrefix20220607\React\Cache\CacheInterface } unset($this->data[$key], $this->expires[$key]); } - return \RectorPrefix20220607\React\Promise\resolve(\true); + return Promise\resolve(\true); } public function delete($key) { unset($this->data[$key], $this->expires[$key]); - return \RectorPrefix20220607\React\Promise\resolve(\true); + return Promise\resolve(\true); } public function getMultiple(array $keys, $default = null) { @@ -106,27 +106,27 @@ class ArrayCache implements \RectorPrefix20220607\React\Cache\CacheInterface foreach ($keys as $key) { $values[$key] = $this->get($key, $default); } - return \RectorPrefix20220607\React\Promise\all($values); + return Promise\all($values); } public function setMultiple(array $values, $ttl = null) { foreach ($values as $key => $value) { $this->set($key, $value, $ttl); } - return \RectorPrefix20220607\React\Promise\resolve(\true); + return Promise\resolve(\true); } public function deleteMultiple(array $keys) { foreach ($keys as $key) { unset($this->data[$key], $this->expires[$key]); } - return \RectorPrefix20220607\React\Promise\resolve(\true); + return Promise\resolve(\true); } public function clear() { $this->data = array(); $this->expires = array(); - return \RectorPrefix20220607\React\Promise\resolve(\true); + return Promise\resolve(\true); } public function has($key) { @@ -135,13 +135,13 @@ class ArrayCache implements \RectorPrefix20220607\React\Cache\CacheInterface unset($this->data[$key], $this->expires[$key]); } if (!\array_key_exists($key, $this->data)) { - return \RectorPrefix20220607\React\Promise\resolve(\false); + return Promise\resolve(\false); } // remove and append to end of array to keep track of LRU info $value = $this->data[$key]; unset($this->data[$key]); $this->data[$key] = $value; - return \RectorPrefix20220607\React\Promise\resolve(\true); + return Promise\resolve(\true); } /** * @return float diff --git a/vendor/react/child-process/src/Process.php b/vendor/react/child-process/src/Process.php index aedf83121dd..ed57bcb1db9 100644 --- a/vendor/react/child-process/src/Process.php +++ b/vendor/react/child-process/src/Process.php @@ -55,7 +55,7 @@ use RectorPrefix20220607\React\Stream\DuplexStreamInterface; * Accordingly, if either of these pipes is in a paused state (`pause()` method * or internally due to a `pipe()` call), this detection may not trigger. */ -class Process extends \RectorPrefix20220607\Evenement\EventEmitter +class Process extends EventEmitter { /** * @var WritableStreamInterface|null|DuplexStreamInterface|ReadableStreamInterface @@ -151,12 +151,12 @@ class Process extends \RectorPrefix20220607\Evenement\EventEmitter * @param float $interval Interval to periodically monitor process state (seconds) * @throws \RuntimeException If the process is already running or fails to start */ - public function start(\RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null, $interval = 0.1) + public function start(LoopInterface $loop = null, $interval = 0.1) { if ($this->isRunning()) { throw new \RuntimeException('Process is already running'); } - $loop = $loop ?: \RectorPrefix20220607\React\EventLoop\Loop::get(); + $loop = $loop ?: Loop::get(); $cmd = $this->cmd; $fdSpec = $this->fds; $sigchild = null; @@ -217,13 +217,13 @@ class Process extends \RectorPrefix20220607\Evenement\EventEmitter $meta = \stream_get_meta_data($fd); $mode = $meta['mode'] === '' ? $this->fds[$n][1] === 'r' ? 'w' : 'r' : $meta['mode']; if ($mode === 'r+') { - $stream = new \RectorPrefix20220607\React\Stream\DuplexResourceStream($fd, $loop); + $stream = new DuplexResourceStream($fd, $loop); $stream->on('close', $streamCloseHandler); $closeCount++; } elseif ($mode === 'w') { - $stream = new \RectorPrefix20220607\React\Stream\WritableResourceStream($fd, $loop); + $stream = new WritableResourceStream($fd, $loop); } else { - $stream = new \RectorPrefix20220607\React\Stream\ReadableResourceStream($fd, $loop); + $stream = new ReadableResourceStream($fd, $loop); $stream->on('close', $streamCloseHandler); $closeCount++; } diff --git a/vendor/react/dns/src/Config/Config.php b/vendor/react/dns/src/Config/Config.php index 817ca84b8f9..e728bf72efd 100644 --- a/vendor/react/dns/src/Config/Config.php +++ b/vendor/react/dns/src/Config/Config.php @@ -34,7 +34,7 @@ final class Config // otherwise (try to) load from resolv.conf try { return self::loadResolvConfBlocking(); - } catch (\RuntimeException $ignored) { + } catch (RuntimeException $ignored) { // return empty config if parsing fails (file not found) return new self(); } @@ -75,7 +75,7 @@ final class Config } $contents = @\file_get_contents($path); if ($contents === \false) { - throw new \RuntimeException('Unable to load resolv.conf file "' . $path . '"'); + throw new RuntimeException('Unable to load resolv.conf file "' . $path . '"'); } $matches = array(); \preg_match_all('/^nameserver\\s+(\\S+)\\s*$/m', $contents, $matches); diff --git a/vendor/react/dns/src/Config/HostsFile.php b/vendor/react/dns/src/Config/HostsFile.php index efb48905413..508b35b9895 100644 --- a/vendor/react/dns/src/Config/HostsFile.php +++ b/vendor/react/dns/src/Config/HostsFile.php @@ -61,7 +61,7 @@ class HostsFile } $contents = @\file_get_contents($path); if ($contents === \false) { - throw new \RuntimeException('Unable to load hosts file "' . $path . '"'); + throw new RuntimeException('Unable to load hosts file "' . $path . '"'); } return new self($contents); } diff --git a/vendor/react/dns/src/Model/Message.php b/vendor/react/dns/src/Model/Message.php index 109578fd795..30c6edc2fe4 100644 --- a/vendor/react/dns/src/Model/Message.php +++ b/vendor/react/dns/src/Model/Message.php @@ -77,9 +77,9 @@ final class Message * @param Query $query * @return self */ - public static function createRequestForQuery(\RectorPrefix20220607\React\Dns\Query\Query $query) + public static function createRequestForQuery(Query $query) { - $request = new \RectorPrefix20220607\React\Dns\Model\Message(); + $request = new Message(); $request->id = self::generateId(); $request->rd = \true; $request->questions[] = $query; @@ -92,9 +92,9 @@ final class Message * @param Record[] $answers * @return self */ - public static function createResponseWithAnswersForQuery(\RectorPrefix20220607\React\Dns\Query\Query $query, array $answers) + public static function createResponseWithAnswersForQuery(Query $query, array $answers) { - $response = new \RectorPrefix20220607\React\Dns\Model\Message(); + $response = new Message(); $response->id = self::generateId(); $response->qr = \true; $response->rd = \true; @@ -171,7 +171,7 @@ final class Message * @var int response code (4 bit), see self::RCODE_* constants * @see self::RCODE_OK */ - public $rcode = \RectorPrefix20220607\React\Dns\Model\Message::RCODE_OK; + public $rcode = Message::RCODE_OK; /** * An array of Query objects * diff --git a/vendor/react/dns/src/Protocol/BinaryDumper.php b/vendor/react/dns/src/Protocol/BinaryDumper.php index 0114b5ec4ad..d87c1901d89 100644 --- a/vendor/react/dns/src/Protocol/BinaryDumper.php +++ b/vendor/react/dns/src/Protocol/BinaryDumper.php @@ -11,7 +11,7 @@ final class BinaryDumper * @param Message $message * @return string */ - public function toBinary(\RectorPrefix20220607\React\Dns\Model\Message $message) + public function toBinary(Message $message) { $data = ''; $data .= $this->headerToBinary($message); @@ -25,7 +25,7 @@ final class BinaryDumper * @param Message $message * @return string */ - private function headerToBinary(\RectorPrefix20220607\React\Dns\Model\Message $message) + private function headerToBinary(Message $message) { $data = ''; $data .= \pack('n', $message->id); @@ -69,44 +69,44 @@ final class BinaryDumper foreach ($records as $record) { /* @var $record Record */ switch ($record->type) { - case \RectorPrefix20220607\React\Dns\Model\Message::TYPE_A: - case \RectorPrefix20220607\React\Dns\Model\Message::TYPE_AAAA: + case Message::TYPE_A: + case Message::TYPE_AAAA: $binary = \inet_pton($record->data); break; - case \RectorPrefix20220607\React\Dns\Model\Message::TYPE_CNAME: - case \RectorPrefix20220607\React\Dns\Model\Message::TYPE_NS: - case \RectorPrefix20220607\React\Dns\Model\Message::TYPE_PTR: + case Message::TYPE_CNAME: + case Message::TYPE_NS: + case Message::TYPE_PTR: $binary = $this->domainNameToBinary($record->data); break; - case \RectorPrefix20220607\React\Dns\Model\Message::TYPE_TXT: - case \RectorPrefix20220607\React\Dns\Model\Message::TYPE_SPF: + case Message::TYPE_TXT: + case Message::TYPE_SPF: $binary = $this->textsToBinary($record->data); break; - case \RectorPrefix20220607\React\Dns\Model\Message::TYPE_MX: + case Message::TYPE_MX: $binary = \pack('n', $record->data['priority']); $binary .= $this->domainNameToBinary($record->data['target']); break; - case \RectorPrefix20220607\React\Dns\Model\Message::TYPE_SRV: + case Message::TYPE_SRV: $binary = \pack('n*', $record->data['priority'], $record->data['weight'], $record->data['port']); $binary .= $this->domainNameToBinary($record->data['target']); break; - case \RectorPrefix20220607\React\Dns\Model\Message::TYPE_SOA: + case Message::TYPE_SOA: $binary = $this->domainNameToBinary($record->data['mname']); $binary .= $this->domainNameToBinary($record->data['rname']); $binary .= \pack('N*', $record->data['serial'], $record->data['refresh'], $record->data['retry'], $record->data['expire'], $record->data['minimum']); break; - case \RectorPrefix20220607\React\Dns\Model\Message::TYPE_CAA: + case Message::TYPE_CAA: $binary = \pack('C*', $record->data['flag'], \strlen($record->data['tag'])); $binary .= $record->data['tag']; $binary .= $record->data['value']; break; - case \RectorPrefix20220607\React\Dns\Model\Message::TYPE_SSHFP: + case Message::TYPE_SSHFP: $binary = \pack('CCH*', $record->data['algorithm'], $record->data['type'], $record->data['fingerprint']); break; - case \RectorPrefix20220607\React\Dns\Model\Message::TYPE_OPT: + case Message::TYPE_OPT: $binary = ''; foreach ($record->data as $opt => $value) { - if ($opt === \RectorPrefix20220607\React\Dns\Model\Message::OPT_TCP_KEEPALIVE && $value !== null) { + if ($opt === Message::OPT_TCP_KEEPALIVE && $value !== null) { $value = \pack('n', \round($value * 10)); } $binary .= \pack('n*', $opt, \strlen((string) $value)) . $value; @@ -141,7 +141,7 @@ final class BinaryDumper private function domainNameToBinary($host) { if ($host === '') { - return "\0"; + return "\x00"; } // break up domain name at each dot that is not preceeded by a backslash (escaped notation) return $this->textsToBinary(\array_map('stripcslashes', \preg_split('/(?parse($data, 0); if ($message === null) { - throw new \InvalidArgumentException('Unable to parse binary message'); + throw new InvalidArgumentException('Unable to parse binary message'); } return $message; } @@ -39,7 +39,7 @@ final class Parser return null; } list($id, $fields, $qdCount, $anCount, $nsCount, $arCount) = \array_values(\unpack('n*', \substr($data, 0, 12))); - $message = new \RectorPrefix20220607\React\Dns\Model\Message(); + $message = new Message(); $message->id = $id; $message->rcode = $fields & 0xf; $message->ra = ($fields >> 7 & 1) === 1; @@ -100,7 +100,7 @@ final class Parser } list($type, $class) = \array_values(\unpack('n*', \substr($data, $consumed, 4))); $consumed += 4; - return array(new \RectorPrefix20220607\React\Dns\Query\Query(\implode('.', $labels), $type, $class), $consumed); + return array(new Query(\implode('.', $labels), $type, $class), $consumed); } /** * @param string $data @@ -128,45 +128,45 @@ final class Parser } $rdata = null; $expected = $consumed + $rdLength; - if (\RectorPrefix20220607\React\Dns\Model\Message::TYPE_A === $type) { + if (Message::TYPE_A === $type) { if ($rdLength === 4) { $rdata = \inet_ntop(\substr($data, $consumed, $rdLength)); $consumed += $rdLength; } - } elseif (\RectorPrefix20220607\React\Dns\Model\Message::TYPE_AAAA === $type) { + } elseif (Message::TYPE_AAAA === $type) { if ($rdLength === 16) { $rdata = \inet_ntop(\substr($data, $consumed, $rdLength)); $consumed += $rdLength; } - } elseif (\RectorPrefix20220607\React\Dns\Model\Message::TYPE_CNAME === $type || \RectorPrefix20220607\React\Dns\Model\Message::TYPE_PTR === $type || \RectorPrefix20220607\React\Dns\Model\Message::TYPE_NS === $type) { + } elseif (Message::TYPE_CNAME === $type || Message::TYPE_PTR === $type || Message::TYPE_NS === $type) { list($rdata, $consumed) = $this->readDomain($data, $consumed); - } elseif (\RectorPrefix20220607\React\Dns\Model\Message::TYPE_TXT === $type || \RectorPrefix20220607\React\Dns\Model\Message::TYPE_SPF === $type) { + } elseif (Message::TYPE_TXT === $type || Message::TYPE_SPF === $type) { $rdata = array(); while ($consumed < $expected) { $len = \ord($data[$consumed]); $rdata[] = (string) \substr($data, $consumed + 1, $len); $consumed += $len + 1; } - } elseif (\RectorPrefix20220607\React\Dns\Model\Message::TYPE_MX === $type) { + } elseif (Message::TYPE_MX === $type) { if ($rdLength > 2) { list($priority) = \array_values(\unpack('n', \substr($data, $consumed, 2))); list($target, $consumed) = $this->readDomain($data, $consumed + 2); $rdata = array('priority' => $priority, 'target' => $target); } - } elseif (\RectorPrefix20220607\React\Dns\Model\Message::TYPE_SRV === $type) { + } elseif (Message::TYPE_SRV === $type) { if ($rdLength > 6) { list($priority, $weight, $port) = \array_values(\unpack('n*', \substr($data, $consumed, 6))); list($target, $consumed) = $this->readDomain($data, $consumed + 6); $rdata = array('priority' => $priority, 'weight' => $weight, 'port' => $port, 'target' => $target); } - } elseif (\RectorPrefix20220607\React\Dns\Model\Message::TYPE_SSHFP === $type) { + } elseif (Message::TYPE_SSHFP === $type) { if ($rdLength > 2) { list($algorithm, $hash) = \array_values(\unpack('C*', \substr($data, $consumed, 2))); $fingerprint = \bin2hex(\substr($data, $consumed + 2, $rdLength - 2)); $consumed += $rdLength; $rdata = array('algorithm' => $algorithm, 'type' => $hash, 'fingerprint' => $fingerprint); } - } elseif (\RectorPrefix20220607\React\Dns\Model\Message::TYPE_SOA === $type) { + } elseif (Message::TYPE_SOA === $type) { list($mname, $consumed) = $this->readDomain($data, $consumed); list($rname, $consumed) = $this->readDomain($data, $consumed); if ($mname !== null && $rname !== null && isset($data[$consumed + 20 - 1])) { @@ -174,23 +174,23 @@ final class Parser $consumed += 20; $rdata = array('mname' => $mname, 'rname' => $rname, 'serial' => $serial, 'refresh' => $refresh, 'retry' => $retry, 'expire' => $expire, 'minimum' => $minimum); } - } elseif (\RectorPrefix20220607\React\Dns\Model\Message::TYPE_OPT === $type) { + } elseif (Message::TYPE_OPT === $type) { $rdata = array(); while (isset($data[$consumed + 4 - 1])) { list($code, $length) = \array_values(\unpack('n*', \substr($data, $consumed, 4))); $value = (string) \substr($data, $consumed + 4, $length); - if ($code === \RectorPrefix20220607\React\Dns\Model\Message::OPT_TCP_KEEPALIVE && $value === '') { + if ($code === Message::OPT_TCP_KEEPALIVE && $value === '') { $value = null; - } elseif ($code === \RectorPrefix20220607\React\Dns\Model\Message::OPT_TCP_KEEPALIVE && $length === 2) { + } elseif ($code === Message::OPT_TCP_KEEPALIVE && $length === 2) { list($value) = \array_values(\unpack('n', $value)); $value = \round($value * 0.1, 1); - } elseif ($code === \RectorPrefix20220607\React\Dns\Model\Message::OPT_TCP_KEEPALIVE) { + } elseif ($code === Message::OPT_TCP_KEEPALIVE) { break; } $rdata[$code] = $value; $consumed += 4 + $length; } - } elseif (\RectorPrefix20220607\React\Dns\Model\Message::TYPE_CAA === $type) { + } elseif (Message::TYPE_CAA === $type) { if ($rdLength > 3) { list($flag, $tagLength) = \array_values(\unpack('C*', \substr($data, $consumed, 2))); if ($tagLength > 0 && $rdLength - 2 - $tagLength > 0) { @@ -209,7 +209,7 @@ final class Parser if ($consumed !== $expected || $rdata === null) { return array(null, null); } - return array(new \RectorPrefix20220607\React\Dns\Model\Record($name, $type, $class, $ttl, $rdata), $consumed); + return array(new Record($name, $type, $class, $ttl, $rdata), $consumed); } private function readDomain($data, $consumed) { @@ -219,7 +219,7 @@ final class Parser } // use escaped notation for each label part, then join using dots return array(\implode('.', \array_map(function ($label) { - return \addcslashes($label, "\0.. ."); + return \addcslashes($label, "\x00.. ."); }, $labels)), $consumed); } /** diff --git a/vendor/react/dns/src/Query/CachingExecutor.php b/vendor/react/dns/src/Query/CachingExecutor.php index 9a28bf4a437..fffaac62153 100644 --- a/vendor/react/dns/src/Query/CachingExecutor.php +++ b/vendor/react/dns/src/Query/CachingExecutor.php @@ -5,7 +5,7 @@ namespace RectorPrefix20220607\React\Dns\Query; use RectorPrefix20220607\React\Cache\CacheInterface; use RectorPrefix20220607\React\Dns\Model\Message; use RectorPrefix20220607\React\Promise\Promise; -final class CachingExecutor implements \RectorPrefix20220607\React\Dns\Query\ExecutorInterface +final class CachingExecutor implements ExecutorInterface { /** * Default TTL for negative responses (NXDOMAIN etc.). @@ -15,26 +15,26 @@ final class CachingExecutor implements \RectorPrefix20220607\React\Dns\Query\Exe const TTL = 60; private $executor; private $cache; - public function __construct(\RectorPrefix20220607\React\Dns\Query\ExecutorInterface $executor, \RectorPrefix20220607\React\Cache\CacheInterface $cache) + public function __construct(ExecutorInterface $executor, CacheInterface $cache) { $this->executor = $executor; $this->cache = $cache; } - public function query(\RectorPrefix20220607\React\Dns\Query\Query $query) + public function query(Query $query) { $id = $query->name . ':' . $query->type . ':' . $query->class; $cache = $this->cache; $that = $this; $executor = $this->executor; $pending = $cache->get($id); - return new \RectorPrefix20220607\React\Promise\Promise(function ($resolve, $reject) use($query, $id, $cache, $executor, &$pending, $that) { + return new Promise(function ($resolve, $reject) use($query, $id, $cache, $executor, &$pending, $that) { $pending->then(function ($message) use($query, $id, $cache, $executor, &$pending, $that) { // return cached response message on cache hit if ($message !== null) { return $message; } // perform DNS lookup if not already cached - return $pending = $executor->query($query)->then(function (\RectorPrefix20220607\React\Dns\Model\Message $message) use($cache, $id, $that) { + return $pending = $executor->query($query)->then(function (Message $message) use($cache, $id, $that) { // DNS response message received => store in cache when not truncated and return if (!$message->tc) { $cache->set($id, $message, $that->ttl($message)); @@ -56,7 +56,7 @@ final class CachingExecutor implements \RectorPrefix20220607\React\Dns\Query\Exe * @return int * @internal */ - public function ttl(\RectorPrefix20220607\React\Dns\Model\Message $message) + public function ttl(Message $message) { // select TTL from answers (should all be the same), use smallest value if available // @link https://tools.ietf.org/html/rfc2181#section-5.2 diff --git a/vendor/react/dns/src/Query/CoopExecutor.php b/vendor/react/dns/src/Query/CoopExecutor.php index c9bb19cd983..6286049cb10 100644 --- a/vendor/react/dns/src/Query/CoopExecutor.php +++ b/vendor/react/dns/src/Query/CoopExecutor.php @@ -33,16 +33,16 @@ use RectorPrefix20220607\React\Promise\Promise; * ); * ``` */ -final class CoopExecutor implements \RectorPrefix20220607\React\Dns\Query\ExecutorInterface +final class CoopExecutor implements ExecutorInterface { private $executor; private $pending = array(); private $counts = array(); - public function __construct(\RectorPrefix20220607\React\Dns\Query\ExecutorInterface $base) + public function __construct(ExecutorInterface $base) { $this->executor = $base; } - public function query(\RectorPrefix20220607\React\Dns\Query\Query $query) + public function query(Query $query) { $key = $this->serializeQueryToIdentity($query); if (isset($this->pending[$key])) { @@ -67,7 +67,7 @@ final class CoopExecutor implements \RectorPrefix20220607\React\Dns\Query\Execut // when no other child promise is awaiting the same query. $pending =& $this->pending; $counts =& $this->counts; - return new \RectorPrefix20220607\React\Promise\Promise(function ($resolve, $reject) use($promise) { + return new Promise(function ($resolve, $reject) use($promise) { $promise->then($resolve, $reject); }, function () use(&$promise, $key, $query, &$pending, &$counts) { if (--$counts[$key] < 1) { @@ -78,7 +78,7 @@ final class CoopExecutor implements \RectorPrefix20220607\React\Dns\Query\Execut throw new \RuntimeException('DNS query for ' . $query->describe() . ' has been cancelled'); }); } - private function serializeQueryToIdentity(\RectorPrefix20220607\React\Dns\Query\Query $query) + private function serializeQueryToIdentity(Query $query) { return \sprintf('%s:%s:%s', $query->name, $query->type, $query->class); } diff --git a/vendor/react/dns/src/Query/ExecutorInterface.php b/vendor/react/dns/src/Query/ExecutorInterface.php index 5d3c913c65f..8988c917d54 100644 --- a/vendor/react/dns/src/Query/ExecutorInterface.php +++ b/vendor/react/dns/src/Query/ExecutorInterface.php @@ -39,5 +39,5 @@ interface ExecutorInterface * @return \React\Promise\PromiseInterface<\React\Dns\Model\Message,\Exception> * resolves with response message on success or rejects with an Exception on error */ - public function query(\RectorPrefix20220607\React\Dns\Query\Query $query); + public function query(Query $query); } diff --git a/vendor/react/dns/src/Query/FallbackExecutor.php b/vendor/react/dns/src/Query/FallbackExecutor.php index 11e916ab361..ba1e594b545 100644 --- a/vendor/react/dns/src/Query/FallbackExecutor.php +++ b/vendor/react/dns/src/Query/FallbackExecutor.php @@ -3,21 +3,21 @@ namespace RectorPrefix20220607\React\Dns\Query; use RectorPrefix20220607\React\Promise\Promise; -final class FallbackExecutor implements \RectorPrefix20220607\React\Dns\Query\ExecutorInterface +final class FallbackExecutor implements ExecutorInterface { private $executor; private $fallback; - public function __construct(\RectorPrefix20220607\React\Dns\Query\ExecutorInterface $executor, \RectorPrefix20220607\React\Dns\Query\ExecutorInterface $fallback) + public function __construct(ExecutorInterface $executor, ExecutorInterface $fallback) { $this->executor = $executor; $this->fallback = $fallback; } - public function query(\RectorPrefix20220607\React\Dns\Query\Query $query) + public function query(Query $query) { $cancelled = \false; $fallback = $this->fallback; $promise = $this->executor->query($query); - return new \RectorPrefix20220607\React\Promise\Promise(function ($resolve, $reject) use(&$promise, $fallback, $query, &$cancelled) { + return new Promise(function ($resolve, $reject) use(&$promise, $fallback, $query, &$cancelled) { $promise->then($resolve, function (\Exception $e1) use($fallback, $query, $resolve, $reject, &$cancelled, &$promise) { // reject if primary resolution rejected due to cancellation if ($cancelled) { diff --git a/vendor/react/dns/src/Query/HostsFileExecutor.php b/vendor/react/dns/src/Query/HostsFileExecutor.php index ca60c4a4538..1ccbdfc0d53 100644 --- a/vendor/react/dns/src/Query/HostsFileExecutor.php +++ b/vendor/react/dns/src/Query/HostsFileExecutor.php @@ -13,40 +13,40 @@ use RectorPrefix20220607\React\Promise; * DNS executor. If the host is not found in the hosts file, it will be passed * to the DNS executor as a fallback. */ -final class HostsFileExecutor implements \RectorPrefix20220607\React\Dns\Query\ExecutorInterface +final class HostsFileExecutor implements ExecutorInterface { private $hosts; private $fallback; - public function __construct(\RectorPrefix20220607\React\Dns\Config\HostsFile $hosts, \RectorPrefix20220607\React\Dns\Query\ExecutorInterface $fallback) + public function __construct(HostsFile $hosts, ExecutorInterface $fallback) { $this->hosts = $hosts; $this->fallback = $fallback; } - public function query(\RectorPrefix20220607\React\Dns\Query\Query $query) + public function query(Query $query) { - if ($query->class === \RectorPrefix20220607\React\Dns\Model\Message::CLASS_IN && ($query->type === \RectorPrefix20220607\React\Dns\Model\Message::TYPE_A || $query->type === \RectorPrefix20220607\React\Dns\Model\Message::TYPE_AAAA)) { + if ($query->class === Message::CLASS_IN && ($query->type === Message::TYPE_A || $query->type === Message::TYPE_AAAA)) { // forward lookup for type A or AAAA $records = array(); - $expectsColon = $query->type === \RectorPrefix20220607\React\Dns\Model\Message::TYPE_AAAA; + $expectsColon = $query->type === Message::TYPE_AAAA; foreach ($this->hosts->getIpsForHost($query->name) as $ip) { // ensure this is an IPv4/IPV6 address according to query type if ((\strpos($ip, ':') !== \false) === $expectsColon) { - $records[] = new \RectorPrefix20220607\React\Dns\Model\Record($query->name, $query->type, $query->class, 0, $ip); + $records[] = new Record($query->name, $query->type, $query->class, 0, $ip); } } if ($records) { - return \RectorPrefix20220607\React\Promise\resolve(\RectorPrefix20220607\React\Dns\Model\Message::createResponseWithAnswersForQuery($query, $records)); + return Promise\resolve(Message::createResponseWithAnswersForQuery($query, $records)); } - } elseif ($query->class === \RectorPrefix20220607\React\Dns\Model\Message::CLASS_IN && $query->type === \RectorPrefix20220607\React\Dns\Model\Message::TYPE_PTR) { + } elseif ($query->class === Message::CLASS_IN && $query->type === Message::TYPE_PTR) { // reverse lookup: extract IPv4 or IPv6 from special `.arpa` domain $ip = $this->getIpFromHost($query->name); if ($ip !== null) { $records = array(); foreach ($this->hosts->getHostsForIp($ip) as $host) { - $records[] = new \RectorPrefix20220607\React\Dns\Model\Record($query->name, $query->type, $query->class, 0, $host); + $records[] = new Record($query->name, $query->type, $query->class, 0, $host); } if ($records) { - return \RectorPrefix20220607\React\Promise\resolve(\RectorPrefix20220607\React\Dns\Model\Message::createResponseWithAnswersForQuery($query, $records)); + return Promise\resolve(Message::createResponseWithAnswersForQuery($query, $records)); } } } diff --git a/vendor/react/dns/src/Query/Query.php b/vendor/react/dns/src/Query/Query.php index ae7873edafe..6dc4417bc7a 100644 --- a/vendor/react/dns/src/Query/Query.php +++ b/vendor/react/dns/src/Query/Query.php @@ -48,7 +48,7 @@ final class Query */ public function describe() { - $class = $this->class !== \RectorPrefix20220607\React\Dns\Model\Message::CLASS_IN ? 'CLASS' . $this->class . ' ' : ''; + $class = $this->class !== Message::CLASS_IN ? 'CLASS' . $this->class . ' ' : ''; $type = 'TYPE' . $this->type; $ref = new \ReflectionClass('RectorPrefix20220607\\React\\Dns\\Model\\Message'); foreach ($ref->getConstants() as $name => $value) { diff --git a/vendor/react/dns/src/Query/RetryExecutor.php b/vendor/react/dns/src/Query/RetryExecutor.php index cde21b4e7a1..64c570d0940 100644 --- a/vendor/react/dns/src/Query/RetryExecutor.php +++ b/vendor/react/dns/src/Query/RetryExecutor.php @@ -5,23 +5,23 @@ namespace RectorPrefix20220607\React\Dns\Query; use RectorPrefix20220607\React\Promise\CancellablePromiseInterface; use RectorPrefix20220607\React\Promise\Deferred; use RectorPrefix20220607\React\Promise\PromiseInterface; -final class RetryExecutor implements \RectorPrefix20220607\React\Dns\Query\ExecutorInterface +final class RetryExecutor implements ExecutorInterface { private $executor; private $retries; - public function __construct(\RectorPrefix20220607\React\Dns\Query\ExecutorInterface $executor, $retries = 2) + public function __construct(ExecutorInterface $executor, $retries = 2) { $this->executor = $executor; $this->retries = $retries; } - public function query(\RectorPrefix20220607\React\Dns\Query\Query $query) + public function query(Query $query) { return $this->tryQuery($query, $this->retries); } - public function tryQuery(\RectorPrefix20220607\React\Dns\Query\Query $query, $retries) + public function tryQuery(Query $query, $retries) { - $deferred = new \RectorPrefix20220607\React\Promise\Deferred(function () use(&$promise) { - if ($promise instanceof \RectorPrefix20220607\React\Promise\CancellablePromiseInterface || !\interface_exists('RectorPrefix20220607\\React\\Promise\\CancellablePromiseInterface') && \method_exists($promise, 'cancel')) { + $deferred = new Deferred(function () use(&$promise) { + if ($promise instanceof CancellablePromiseInterface || !\interface_exists('RectorPrefix20220607\\React\\Promise\\CancellablePromiseInterface') && \method_exists($promise, 'cancel')) { $promise->cancel(); } }); @@ -31,7 +31,7 @@ final class RetryExecutor implements \RectorPrefix20220607\React\Dns\Query\Execu }; $executor = $this->executor; $errorback = function ($e) use($deferred, &$promise, $query, $success, &$errorback, &$retries, $executor) { - if (!$e instanceof \RectorPrefix20220607\React\Dns\Query\TimeoutException) { + if (!$e instanceof TimeoutException) { $errorback = null; $deferred->reject($e); } elseif ($retries <= 0) { diff --git a/vendor/react/dns/src/Query/SelectiveTransportExecutor.php b/vendor/react/dns/src/Query/SelectiveTransportExecutor.php index b3604af2eed..f76a26f5ea3 100644 --- a/vendor/react/dns/src/Query/SelectiveTransportExecutor.php +++ b/vendor/react/dns/src/Query/SelectiveTransportExecutor.php @@ -49,20 +49,20 @@ use RectorPrefix20220607\React\Promise\Promise; * ); * ``` */ -class SelectiveTransportExecutor implements \RectorPrefix20220607\React\Dns\Query\ExecutorInterface +class SelectiveTransportExecutor implements ExecutorInterface { private $datagramExecutor; private $streamExecutor; - public function __construct(\RectorPrefix20220607\React\Dns\Query\ExecutorInterface $datagramExecutor, \RectorPrefix20220607\React\Dns\Query\ExecutorInterface $streamExecutor) + public function __construct(ExecutorInterface $datagramExecutor, ExecutorInterface $streamExecutor) { $this->datagramExecutor = $datagramExecutor; $this->streamExecutor = $streamExecutor; } - public function query(\RectorPrefix20220607\React\Dns\Query\Query $query) + public function query(Query $query) { $stream = $this->streamExecutor; $pending = $this->datagramExecutor->query($query); - return new \RectorPrefix20220607\React\Promise\Promise(function ($resolve, $reject) use(&$pending, $stream, $query) { + return new Promise(function ($resolve, $reject) use(&$pending, $stream, $query) { $pending->then($resolve, function ($e) use(&$pending, $stream, $query, $resolve, $reject) { if ($e->getCode() === (\defined('SOCKET_EMSGSIZE') ? \SOCKET_EMSGSIZE : 90)) { $pending = $stream->query($query)->then($resolve, $reject); diff --git a/vendor/react/dns/src/Query/TcpTransportExecutor.php b/vendor/react/dns/src/Query/TcpTransportExecutor.php index ffbcb7536c3..d6a93f556d3 100644 --- a/vendor/react/dns/src/Query/TcpTransportExecutor.php +++ b/vendor/react/dns/src/Query/TcpTransportExecutor.php @@ -74,7 +74,7 @@ use RectorPrefix20220607\React\Promise\Deferred; * packages. Higher-level components should take advantage of the Socket * component instead of reimplementing this socket logic from scratch. */ -class TcpTransportExecutor implements \RectorPrefix20220607\React\Dns\Query\ExecutorInterface +class TcpTransportExecutor implements ExecutorInterface { private $nameserver; private $loop; @@ -124,7 +124,7 @@ class TcpTransportExecutor implements \RectorPrefix20220607\React\Dns\Query\Exec * @param string $nameserver * @param ?LoopInterface $loop */ - public function __construct($nameserver, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null) + public function __construct($nameserver, LoopInterface $loop = null) { if (\strpos($nameserver, '[') === \false && \substr_count($nameserver, ':') >= 2 && \strpos($nameserver, '://') === \false) { // several colons, but not enclosed in square brackets => enclose IPv6 address in square brackets @@ -135,13 +135,13 @@ class TcpTransportExecutor implements \RectorPrefix20220607\React\Dns\Query\Exec throw new \InvalidArgumentException('Invalid nameserver address given'); } $this->nameserver = 'tcp://' . $parts['host'] . ':' . (isset($parts['port']) ? $parts['port'] : 53); - $this->loop = $loop ?: \RectorPrefix20220607\React\EventLoop\Loop::get(); - $this->parser = new \RectorPrefix20220607\React\Dns\Protocol\Parser(); - $this->dumper = new \RectorPrefix20220607\React\Dns\Protocol\BinaryDumper(); + $this->loop = $loop ?: Loop::get(); + $this->parser = new Parser(); + $this->dumper = new BinaryDumper(); } - public function query(\RectorPrefix20220607\React\Dns\Query\Query $query) + public function query(Query $query) { - $request = \RectorPrefix20220607\React\Dns\Model\Message::createRequestForQuery($query); + $request = Message::createRequestForQuery($query); // keep shuffing message ID to avoid using the same message ID for two pending queries at the same time while (isset($this->pending[$request->id])) { $request->id = \mt_rand(0, 0xffff); @@ -179,12 +179,12 @@ class TcpTransportExecutor implements \RectorPrefix20220607\React\Dns\Query\Exec } $names =& $this->names; $that = $this; - $deferred = new \RectorPrefix20220607\React\Promise\Deferred(function () use($that, &$names, $request) { + $deferred = new Deferred(function () use($that, &$names, $request) { // remove from list of pending names, but remember pending query $name = $names[$request->id]; unset($names[$request->id]); $that->checkIdle(); - throw new \RectorPrefix20220607\React\Dns\Query\CancellationException('DNS query for ' . $name . ' has been cancelled'); + throw new CancellationException('DNS query for ' . $name . ' has been cancelled'); }); $this->pending[$request->id] = $deferred; $this->names[$request->id] = $query->describe(); diff --git a/vendor/react/dns/src/Query/TimeoutExecutor.php b/vendor/react/dns/src/Query/TimeoutExecutor.php index 41f9410b700..256094db07f 100644 --- a/vendor/react/dns/src/Query/TimeoutExecutor.php +++ b/vendor/react/dns/src/Query/TimeoutExecutor.php @@ -5,22 +5,22 @@ namespace RectorPrefix20220607\React\Dns\Query; use RectorPrefix20220607\React\EventLoop\Loop; use RectorPrefix20220607\React\EventLoop\LoopInterface; use RectorPrefix20220607\React\Promise\Timer; -final class TimeoutExecutor implements \RectorPrefix20220607\React\Dns\Query\ExecutorInterface +final class TimeoutExecutor implements ExecutorInterface { private $executor; private $loop; private $timeout; - public function __construct(\RectorPrefix20220607\React\Dns\Query\ExecutorInterface $executor, $timeout, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null) + public function __construct(ExecutorInterface $executor, $timeout, LoopInterface $loop = null) { $this->executor = $executor; - $this->loop = $loop ?: \RectorPrefix20220607\React\EventLoop\Loop::get(); + $this->loop = $loop ?: Loop::get(); $this->timeout = $timeout; } - public function query(\RectorPrefix20220607\React\Dns\Query\Query $query) + public function query(Query $query) { - return \RectorPrefix20220607\React\Promise\Timer\timeout($this->executor->query($query), $this->timeout, $this->loop)->then(null, function ($e) use($query) { - if ($e instanceof \RectorPrefix20220607\React\Promise\Timer\TimeoutException) { - $e = new \RectorPrefix20220607\React\Dns\Query\TimeoutException(\sprintf("DNS query for %s timed out", $query->describe()), 0, $e); + return Timer\timeout($this->executor->query($query), $this->timeout, $this->loop)->then(null, function ($e) use($query) { + if ($e instanceof Timer\TimeoutException) { + $e = new TimeoutException(\sprintf("DNS query for %s timed out", $query->describe()), 0, $e); } throw $e; }); diff --git a/vendor/react/dns/src/Query/UdpTransportExecutor.php b/vendor/react/dns/src/Query/UdpTransportExecutor.php index a2f01398a9e..f7bb914e60f 100644 --- a/vendor/react/dns/src/Query/UdpTransportExecutor.php +++ b/vendor/react/dns/src/Query/UdpTransportExecutor.php @@ -79,7 +79,7 @@ use RectorPrefix20220607\React\Promise\Deferred; * packages. Higher-level components should take advantage of the Datagram * component instead of reimplementing this socket logic from scratch. */ -final class UdpTransportExecutor implements \RectorPrefix20220607\React\Dns\Query\ExecutorInterface +final class UdpTransportExecutor implements ExecutorInterface { private $nameserver; private $loop; @@ -95,7 +95,7 @@ final class UdpTransportExecutor implements \RectorPrefix20220607\React\Dns\Quer * @param string $nameserver * @param ?LoopInterface $loop */ - public function __construct($nameserver, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null) + public function __construct($nameserver, LoopInterface $loop = null) { if (\strpos($nameserver, '[') === \false && \substr_count($nameserver, ':') >= 2 && \strpos($nameserver, '://') === \false) { // several colons, but not enclosed in square brackets => enclose IPv6 address in square brackets @@ -106,13 +106,13 @@ final class UdpTransportExecutor implements \RectorPrefix20220607\React\Dns\Quer throw new \InvalidArgumentException('Invalid nameserver address given'); } $this->nameserver = 'udp://' . $parts['host'] . ':' . (isset($parts['port']) ? $parts['port'] : 53); - $this->loop = $loop ?: \RectorPrefix20220607\React\EventLoop\Loop::get(); - $this->parser = new \RectorPrefix20220607\React\Dns\Protocol\Parser(); - $this->dumper = new \RectorPrefix20220607\React\Dns\Protocol\BinaryDumper(); + $this->loop = $loop ?: Loop::get(); + $this->parser = new Parser(); + $this->dumper = new BinaryDumper(); } - public function query(\RectorPrefix20220607\React\Dns\Query\Query $query) + public function query(Query $query) { - $request = \RectorPrefix20220607\React\Dns\Model\Message::createRequestForQuery($query); + $request = Message::createRequestForQuery($query); $queryData = $this->dumper->toBinary($request); if (isset($queryData[$this->maxPacketSize])) { return \RectorPrefix20220607\React\Promise\reject(new \RuntimeException('DNS query for ' . $query->describe() . ' failed: Query too large for UDP transport', \defined('SOCKET_EMSGSIZE') ? \SOCKET_EMSGSIZE : 90)); @@ -135,11 +135,11 @@ final class UdpTransportExecutor implements \RectorPrefix20220607\React\Dns\Quer return \RectorPrefix20220607\React\Promise\reject(new \RuntimeException('DNS query for ' . $query->describe() . ' failed: Unable to send query to DNS server ' . $this->nameserver . ' (' . (isset($m[2]) ? $m[2] : $error['message']) . ')', isset($m[1]) ? (int) $m[1] : 0)); } $loop = $this->loop; - $deferred = new \RectorPrefix20220607\React\Promise\Deferred(function () use($loop, $socket, $query) { + $deferred = new Deferred(function () use($loop, $socket, $query) { // cancellation should remove socket from loop and close socket $loop->removeReadStream($socket); \fclose($socket); - throw new \RectorPrefix20220607\React\Dns\Query\CancellationException('DNS query for ' . $query->describe() . ' has been cancelled'); + throw new CancellationException('DNS query for ' . $query->describe() . ' has been cancelled'); }); $max = $this->maxPacketSize; $parser = $this->parser; diff --git a/vendor/react/dns/src/Resolver/Factory.php b/vendor/react/dns/src/Resolver/Factory.php index e1d486caedf..e16a172ba03 100644 --- a/vendor/react/dns/src/Resolver/Factory.php +++ b/vendor/react/dns/src/Resolver/Factory.php @@ -35,10 +35,10 @@ final class Factory * @throws \InvalidArgumentException for invalid DNS server address * @throws \UnderflowException when given DNS Config object has an empty list of nameservers */ - public function create($config, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null) + public function create($config, LoopInterface $loop = null) { - $executor = $this->decorateHostsFileExecutor($this->createExecutor($config, $loop ?: \RectorPrefix20220607\React\EventLoop\Loop::get())); - return new \RectorPrefix20220607\React\Dns\Resolver\Resolver($executor); + $executor = $this->decorateHostsFileExecutor($this->createExecutor($config, $loop ?: Loop::get())); + return new Resolver($executor); } /** * Creates a cached DNS resolver instance for the given DNS config and cache @@ -56,16 +56,16 @@ final class Factory * @throws \InvalidArgumentException for invalid DNS server address * @throws \UnderflowException when given DNS Config object has an empty list of nameservers */ - public function createCached($config, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null, \RectorPrefix20220607\React\Cache\CacheInterface $cache = null) + public function createCached($config, LoopInterface $loop = null, CacheInterface $cache = null) { // default to keeping maximum of 256 responses in cache unless explicitly given - if (!$cache instanceof \RectorPrefix20220607\React\Cache\CacheInterface) { - $cache = new \RectorPrefix20220607\React\Cache\ArrayCache(256); + if (!$cache instanceof CacheInterface) { + $cache = new ArrayCache(256); } - $executor = $this->createExecutor($config, $loop ?: \RectorPrefix20220607\React\EventLoop\Loop::get()); - $executor = new \RectorPrefix20220607\React\Dns\Query\CachingExecutor($executor, $cache); + $executor = $this->createExecutor($config, $loop ?: Loop::get()); + $executor = new CachingExecutor($executor, $cache); $executor = $this->decorateHostsFileExecutor($executor); - return new \RectorPrefix20220607\React\Dns\Resolver\Resolver($executor); + return new Resolver($executor); } /** * Tries to load the hosts file and decorates the given executor on success @@ -74,17 +74,17 @@ final class Factory * @return ExecutorInterface * @codeCoverageIgnore */ - private function decorateHostsFileExecutor(\RectorPrefix20220607\React\Dns\Query\ExecutorInterface $executor) + private function decorateHostsFileExecutor(ExecutorInterface $executor) { try { - $executor = new \RectorPrefix20220607\React\Dns\Query\HostsFileExecutor(\RectorPrefix20220607\React\Dns\Config\HostsFile::loadFromPathBlocking(), $executor); + $executor = new HostsFileExecutor(HostsFile::loadFromPathBlocking(), $executor); } catch (\RuntimeException $e) { // ignore this file if it can not be loaded } // Windows does not store localhost in hosts file by default but handles this internally // To compensate for this, we explicitly use hard-coded defaults for localhost if (\DIRECTORY_SEPARATOR === '\\') { - $executor = new \RectorPrefix20220607\React\Dns\Query\HostsFileExecutor(new \RectorPrefix20220607\React\Dns\Config\HostsFile("127.0.0.1 localhost\n::1 localhost"), $executor); + $executor = new HostsFileExecutor(new HostsFile("127.0.0.1 localhost\n::1 localhost"), $executor); } return $executor; } @@ -95,9 +95,9 @@ final class Factory * @throws \InvalidArgumentException for invalid DNS server address * @throws \UnderflowException when given DNS Config object has an empty list of nameservers */ - private function createExecutor($nameserver, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop) + private function createExecutor($nameserver, LoopInterface $loop) { - if ($nameserver instanceof \RectorPrefix20220607\React\Dns\Config\Config) { + if ($nameserver instanceof Config) { if (!$nameserver->nameservers) { throw new \UnderflowException('Empty config with no DNS servers'); } @@ -108,16 +108,16 @@ final class Factory $tertiary = \next($nameserver->nameservers); if ($tertiary !== \false) { // 3 DNS servers given => nest first with fallback for second and third - return new \RectorPrefix20220607\React\Dns\Query\CoopExecutor(new \RectorPrefix20220607\React\Dns\Query\RetryExecutor(new \RectorPrefix20220607\React\Dns\Query\FallbackExecutor($this->createSingleExecutor($primary, $loop), new \RectorPrefix20220607\React\Dns\Query\FallbackExecutor($this->createSingleExecutor($secondary, $loop), $this->createSingleExecutor($tertiary, $loop))))); + return new CoopExecutor(new RetryExecutor(new FallbackExecutor($this->createSingleExecutor($primary, $loop), new FallbackExecutor($this->createSingleExecutor($secondary, $loop), $this->createSingleExecutor($tertiary, $loop))))); } elseif ($secondary !== \false) { // 2 DNS servers given => fallback from first to second - return new \RectorPrefix20220607\React\Dns\Query\CoopExecutor(new \RectorPrefix20220607\React\Dns\Query\RetryExecutor(new \RectorPrefix20220607\React\Dns\Query\FallbackExecutor($this->createSingleExecutor($primary, $loop), $this->createSingleExecutor($secondary, $loop)))); + return new CoopExecutor(new RetryExecutor(new FallbackExecutor($this->createSingleExecutor($primary, $loop), $this->createSingleExecutor($secondary, $loop)))); } else { // 1 DNS server given => use single executor $nameserver = $primary; } } - return new \RectorPrefix20220607\React\Dns\Query\CoopExecutor(new \RectorPrefix20220607\React\Dns\Query\RetryExecutor($this->createSingleExecutor($nameserver, $loop))); + return new CoopExecutor(new RetryExecutor($this->createSingleExecutor($nameserver, $loop))); } /** * @param string $nameserver @@ -125,7 +125,7 @@ final class Factory * @return ExecutorInterface * @throws \InvalidArgumentException for invalid DNS server address */ - private function createSingleExecutor($nameserver, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop) + private function createSingleExecutor($nameserver, LoopInterface $loop) { $parts = \parse_url($nameserver); if (isset($parts['scheme']) && $parts['scheme'] === 'tcp') { @@ -133,7 +133,7 @@ final class Factory } elseif (isset($parts['scheme']) && $parts['scheme'] === 'udp') { $executor = $this->createUdpExecutor($nameserver, $loop); } else { - $executor = new \RectorPrefix20220607\React\Dns\Query\SelectiveTransportExecutor($this->createUdpExecutor($nameserver, $loop), $this->createTcpExecutor($nameserver, $loop)); + $executor = new SelectiveTransportExecutor($this->createUdpExecutor($nameserver, $loop), $this->createTcpExecutor($nameserver, $loop)); } return $executor; } @@ -143,9 +143,9 @@ final class Factory * @return TimeoutExecutor * @throws \InvalidArgumentException for invalid DNS server address */ - private function createTcpExecutor($nameserver, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop) + private function createTcpExecutor($nameserver, LoopInterface $loop) { - return new \RectorPrefix20220607\React\Dns\Query\TimeoutExecutor(new \RectorPrefix20220607\React\Dns\Query\TcpTransportExecutor($nameserver, $loop), 5.0, $loop); + return new TimeoutExecutor(new TcpTransportExecutor($nameserver, $loop), 5.0, $loop); } /** * @param string $nameserver @@ -153,8 +153,8 @@ final class Factory * @return TimeoutExecutor * @throws \InvalidArgumentException for invalid DNS server address */ - private function createUdpExecutor($nameserver, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop) + private function createUdpExecutor($nameserver, LoopInterface $loop) { - return new \RectorPrefix20220607\React\Dns\Query\TimeoutExecutor(new \RectorPrefix20220607\React\Dns\Query\UdpTransportExecutor($nameserver, $loop), 5.0, $loop); + return new TimeoutExecutor(new UdpTransportExecutor($nameserver, $loop), 5.0, $loop); } } diff --git a/vendor/react/dns/src/Resolver/Resolver.php b/vendor/react/dns/src/Resolver/Resolver.php index 8c28ddbd351..c3da7da5d0e 100644 --- a/vendor/react/dns/src/Resolver/Resolver.php +++ b/vendor/react/dns/src/Resolver/Resolver.php @@ -9,24 +9,24 @@ use RectorPrefix20220607\React\Dns\RecordNotFoundException; /** * @see ResolverInterface for the base interface */ -final class Resolver implements \RectorPrefix20220607\React\Dns\Resolver\ResolverInterface +final class Resolver implements ResolverInterface { private $executor; - public function __construct(\RectorPrefix20220607\React\Dns\Query\ExecutorInterface $executor) + public function __construct(ExecutorInterface $executor) { $this->executor = $executor; } public function resolve($domain) { - return $this->resolveAll($domain, \RectorPrefix20220607\React\Dns\Model\Message::TYPE_A)->then(function (array $ips) { + return $this->resolveAll($domain, Message::TYPE_A)->then(function (array $ips) { return $ips[\array_rand($ips)]; }); } public function resolveAll($domain, $type) { - $query = new \RectorPrefix20220607\React\Dns\Query\Query($domain, $type, \RectorPrefix20220607\React\Dns\Model\Message::CLASS_IN); + $query = new Query($domain, $type, Message::CLASS_IN); $that = $this; - return $this->executor->query($query)->then(function (\RectorPrefix20220607\React\Dns\Model\Message $response) use($query, $that) { + return $this->executor->query($query)->then(function (Message $response) use($query, $that) { return $that->extractValues($query, $response); }); } @@ -39,37 +39,37 @@ final class Resolver implements \RectorPrefix20220607\React\Dns\Resolver\Resolve * @throws RecordNotFoundException when response indicates an error or contains no data * @internal */ - public function extractValues(\RectorPrefix20220607\React\Dns\Query\Query $query, \RectorPrefix20220607\React\Dns\Model\Message $response) + public function extractValues(Query $query, Message $response) { // reject if response code indicates this is an error response message $code = $response->rcode; - if ($code !== \RectorPrefix20220607\React\Dns\Model\Message::RCODE_OK) { + if ($code !== Message::RCODE_OK) { switch ($code) { - case \RectorPrefix20220607\React\Dns\Model\Message::RCODE_FORMAT_ERROR: + case Message::RCODE_FORMAT_ERROR: $message = 'Format Error'; break; - case \RectorPrefix20220607\React\Dns\Model\Message::RCODE_SERVER_FAILURE: + case Message::RCODE_SERVER_FAILURE: $message = 'Server Failure'; break; - case \RectorPrefix20220607\React\Dns\Model\Message::RCODE_NAME_ERROR: + case Message::RCODE_NAME_ERROR: $message = 'Non-Existent Domain / NXDOMAIN'; break; - case \RectorPrefix20220607\React\Dns\Model\Message::RCODE_NOT_IMPLEMENTED: + case Message::RCODE_NOT_IMPLEMENTED: $message = 'Not Implemented'; break; - case \RectorPrefix20220607\React\Dns\Model\Message::RCODE_REFUSED: + case Message::RCODE_REFUSED: $message = 'Refused'; break; default: $message = 'Unknown error response code ' . $code; } - throw new \RectorPrefix20220607\React\Dns\RecordNotFoundException('DNS query for ' . $query->describe() . ' returned an error response (' . $message . ')', $code); + throw new RecordNotFoundException('DNS query for ' . $query->describe() . ' returned an error response (' . $message . ')', $code); } $answers = $response->answers; $addresses = $this->valuesByNameAndType($answers, $query->name, $query->type); // reject if we did not receive a valid answer (domain is valid, but no record for this type could be found) if (0 === \count($addresses)) { - throw new \RectorPrefix20220607\React\Dns\RecordNotFoundException('DNS query for ' . $query->describe() . ' did not return a valid answer (NOERROR / NODATA)'); + throw new RecordNotFoundException('DNS query for ' . $query->describe() . ' did not return a valid answer (NOERROR / NODATA)'); } return \array_values($addresses); } @@ -88,7 +88,7 @@ final class Resolver implements \RectorPrefix20220607\React\Dns\Resolver\Resolve return $this->mapRecordData($records); } // no matching records found? check if there are any matching CNAMEs instead - $cnameRecords = $this->filterByType($named, \RectorPrefix20220607\React\Dns\Model\Message::TYPE_CNAME); + $cnameRecords = $this->filterByType($named, Message::TYPE_CNAME); if ($cnameRecords) { $cnames = $this->mapRecordData($cnameRecords); foreach ($cnames as $cname) { diff --git a/vendor/react/event-loop/src/ExtEvLoop.php b/vendor/react/event-loop/src/ExtEvLoop.php index 6a2a5c0e497..11adfb34b63 100644 --- a/vendor/react/event-loop/src/ExtEvLoop.php +++ b/vendor/react/event-loop/src/ExtEvLoop.php @@ -20,7 +20,7 @@ use SplObjectStorage; * @see http://php.net/manual/en/book.ev.php * @see https://bitbucket.org/osmanov/pecl-ev/overview */ -class ExtEvLoop implements \RectorPrefix20220607\React\EventLoop\LoopInterface +class ExtEvLoop implements LoopInterface { /** * @var EvLoop @@ -56,10 +56,10 @@ class ExtEvLoop implements \RectorPrefix20220607\React\EventLoop\LoopInterface private $signalEvents = array(); public function __construct() { - $this->loop = new \EvLoop(); - $this->futureTickQueue = new \RectorPrefix20220607\React\EventLoop\Tick\FutureTickQueue(); - $this->timers = new \SplObjectStorage(); - $this->signals = new \RectorPrefix20220607\React\EventLoop\SignalsHandler(); + $this->loop = new EvLoop(); + $this->futureTickQueue = new FutureTickQueue(); + $this->timers = new SplObjectStorage(); + $this->signals = new SignalsHandler(); } public function addReadStream($stream, $listener) { @@ -68,7 +68,7 @@ class ExtEvLoop implements \RectorPrefix20220607\React\EventLoop\LoopInterface return; } $callback = $this->getStreamListenerClosure($stream, $listener); - $event = $this->loop->io($stream, \Ev::READ, $callback); + $event = $this->loop->io($stream, Ev::READ, $callback); $this->readStreams[$key] = $event; } /** @@ -90,7 +90,7 @@ class ExtEvLoop implements \RectorPrefix20220607\React\EventLoop\LoopInterface return; } $callback = $this->getStreamListenerClosure($stream, $listener); - $event = $this->loop->io($stream, \Ev::WRITE, $callback); + $event = $this->loop->io($stream, Ev::WRITE, $callback); $this->writeStreams[$key] = $event; } public function removeReadStream($stream) @@ -113,7 +113,7 @@ class ExtEvLoop implements \RectorPrefix20220607\React\EventLoop\LoopInterface } public function addTimer($interval, $callback) { - $timer = new \RectorPrefix20220607\React\EventLoop\Timer\Timer($interval, $callback, \false); + $timer = new Timer($interval, $callback, \false); $that = $this; $timers = $this->timers; $callback = function () use($timer, $timers, $that) { @@ -128,7 +128,7 @@ class ExtEvLoop implements \RectorPrefix20220607\React\EventLoop\LoopInterface } public function addPeriodicTimer($interval, $callback) { - $timer = new \RectorPrefix20220607\React\EventLoop\Timer\Timer($interval, $callback, \true); + $timer = new Timer($interval, $callback, \true); $callback = function () use($timer) { \call_user_func($timer->getCallback(), $timer); }; @@ -136,7 +136,7 @@ class ExtEvLoop implements \RectorPrefix20220607\React\EventLoop\LoopInterface $this->timers->attach($timer, $event); return $timer; } - public function cancelTimer(\RectorPrefix20220607\React\EventLoop\TimerInterface $timer) + public function cancelTimer(TimerInterface $timer) { if (!isset($this->timers[$timer])) { return; @@ -157,9 +157,9 @@ class ExtEvLoop implements \RectorPrefix20220607\React\EventLoop\LoopInterface $hasPendingCallbacks = !$this->futureTickQueue->isEmpty(); $wasJustStopped = !$this->running; $nothingLeftToDo = !$this->readStreams && !$this->writeStreams && !$this->timers->count() && $this->signals->isEmpty(); - $flags = \Ev::RUN_ONCE; + $flags = Ev::RUN_ONCE; if ($wasJustStopped || $hasPendingCallbacks) { - $flags |= \Ev::RUN_NOWAIT; + $flags |= Ev::RUN_NOWAIT; } elseif ($nothingLeftToDo) { break; } diff --git a/vendor/react/event-loop/src/ExtEventLoop.php b/vendor/react/event-loop/src/ExtEventLoop.php index e5f42ea598f..ddb2db1fad7 100644 --- a/vendor/react/event-loop/src/ExtEventLoop.php +++ b/vendor/react/event-loop/src/ExtEventLoop.php @@ -19,7 +19,7 @@ use SplObjectStorage; * * @link https://pecl.php.net/package/event */ -final class ExtEventLoop implements \RectorPrefix20220607\React\EventLoop\LoopInterface +final class ExtEventLoop implements LoopInterface { private $eventBase; private $futureTickQueue; @@ -38,7 +38,7 @@ final class ExtEventLoop implements \RectorPrefix20220607\React\EventLoop\LoopIn public function __construct() { if (!\class_exists('EventBase', \false)) { - throw new \BadMethodCallException('Cannot create ExtEventLoop, ext-event extension missing'); + throw new BadMethodCallException('Cannot create ExtEventLoop, ext-event extension missing'); } // support arbitrary file descriptors and not just sockets // Windows only has limited file descriptor support, so do not require this (will fail otherwise) @@ -47,10 +47,10 @@ final class ExtEventLoop implements \RectorPrefix20220607\React\EventLoop\LoopIn if (\DIRECTORY_SEPARATOR !== '\\') { $config->requireFeatures(\EventConfig::FEATURE_FDS); } - $this->eventBase = new \EventBase($config); - $this->futureTickQueue = new \RectorPrefix20220607\React\EventLoop\Tick\FutureTickQueue(); - $this->timerEvents = new \SplObjectStorage(); - $this->signals = new \RectorPrefix20220607\React\EventLoop\SignalsHandler(); + $this->eventBase = new EventBase($config); + $this->futureTickQueue = new FutureTickQueue(); + $this->timerEvents = new SplObjectStorage(); + $this->signals = new SignalsHandler(); $this->createTimerCallback(); $this->createStreamCallback(); } @@ -69,7 +69,7 @@ final class ExtEventLoop implements \RectorPrefix20220607\React\EventLoop\LoopIn if (isset($this->readListeners[$key])) { return; } - $event = new \Event($this->eventBase, $stream, \Event::PERSIST | \Event::READ, $this->streamCallback); + $event = new Event($this->eventBase, $stream, Event::PERSIST | Event::READ, $this->streamCallback); $event->add(); $this->readEvents[$key] = $event; $this->readListeners[$key] = $listener; @@ -85,7 +85,7 @@ final class ExtEventLoop implements \RectorPrefix20220607\React\EventLoop\LoopIn if (isset($this->writeListeners[$key])) { return; } - $event = new \Event($this->eventBase, $stream, \Event::PERSIST | \Event::WRITE, $this->streamCallback); + $event = new Event($this->eventBase, $stream, Event::PERSIST | Event::WRITE, $this->streamCallback); $event->add(); $this->writeEvents[$key] = $event; $this->writeListeners[$key] = $listener; @@ -113,17 +113,17 @@ final class ExtEventLoop implements \RectorPrefix20220607\React\EventLoop\LoopIn } public function addTimer($interval, $callback) { - $timer = new \RectorPrefix20220607\React\EventLoop\Timer\Timer($interval, $callback, \false); + $timer = new Timer($interval, $callback, \false); $this->scheduleTimer($timer); return $timer; } public function addPeriodicTimer($interval, $callback) { - $timer = new \RectorPrefix20220607\React\EventLoop\Timer\Timer($interval, $callback, \true); + $timer = new Timer($interval, $callback, \true); $this->scheduleTimer($timer); return $timer; } - public function cancelTimer(\RectorPrefix20220607\React\EventLoop\TimerInterface $timer) + public function cancelTimer(TimerInterface $timer) { if ($this->timerEvents->contains($timer)) { $this->timerEvents[$timer]->free(); @@ -138,7 +138,7 @@ final class ExtEventLoop implements \RectorPrefix20220607\React\EventLoop\LoopIn { $this->signals->add($signal, $listener); if (!isset($this->signalEvents[$signal])) { - $this->signalEvents[$signal] = \Event::signal($this->eventBase, $signal, array($this->signals, 'call')); + $this->signalEvents[$signal] = Event::signal($this->eventBase, $signal, array($this->signals, 'call')); $this->signalEvents[$signal]->add(); } } @@ -155,9 +155,9 @@ final class ExtEventLoop implements \RectorPrefix20220607\React\EventLoop\LoopIn $this->running = \true; while ($this->running) { $this->futureTickQueue->tick(); - $flags = \EventBase::LOOP_ONCE; + $flags = EventBase::LOOP_ONCE; if (!$this->running || !$this->futureTickQueue->isEmpty()) { - $flags |= \EventBase::LOOP_NONBLOCK; + $flags |= EventBase::LOOP_NONBLOCK; } elseif (!$this->readEvents && !$this->writeEvents && !$this->timerEvents->count() && $this->signals->isEmpty()) { break; } @@ -173,13 +173,13 @@ final class ExtEventLoop implements \RectorPrefix20220607\React\EventLoop\LoopIn * * @param TimerInterface $timer */ - private function scheduleTimer(\RectorPrefix20220607\React\EventLoop\TimerInterface $timer) + private function scheduleTimer(TimerInterface $timer) { - $flags = \Event::TIMEOUT; + $flags = Event::TIMEOUT; if ($timer->isPeriodic()) { - $flags |= \Event::PERSIST; + $flags |= Event::PERSIST; } - $event = new \Event($this->eventBase, -1, $flags, $this->timerCallback, $timer); + $event = new Event($this->eventBase, -1, $flags, $this->timerCallback, $timer); $this->timerEvents[$timer] = $event; $event->add($timer->getInterval()); } @@ -213,10 +213,10 @@ final class ExtEventLoop implements \RectorPrefix20220607\React\EventLoop\LoopIn $write =& $this->writeListeners; $this->streamCallback = function ($stream, $flags) use(&$read, &$write) { $key = (int) $stream; - if (\Event::READ === (\Event::READ & $flags) && isset($read[$key])) { + if (Event::READ === (Event::READ & $flags) && isset($read[$key])) { \call_user_func($read[$key], $stream); } - if (\Event::WRITE === (\Event::WRITE & $flags) && isset($write[$key])) { + if (Event::WRITE === (Event::WRITE & $flags) && isset($write[$key])) { \call_user_func($write[$key], $stream); } }; diff --git a/vendor/react/event-loop/src/ExtLibevLoop.php b/vendor/react/event-loop/src/ExtLibevLoop.php index efe3d51e4b3..c73197eb29b 100644 --- a/vendor/react/event-loop/src/ExtLibevLoop.php +++ b/vendor/react/event-loop/src/ExtLibevLoop.php @@ -25,7 +25,7 @@ use SplObjectStorage; * @see https://gist.github.com/1688204 * @deprecated 1.2.0, use [`ExtEvLoop`](#extevloop) instead. */ -final class ExtLibevLoop implements \RectorPrefix20220607\React\EventLoop\LoopInterface +final class ExtLibevLoop implements LoopInterface { private $loop; private $futureTickQueue; @@ -38,12 +38,12 @@ final class ExtLibevLoop implements \RectorPrefix20220607\React\EventLoop\LoopIn public function __construct() { if (!\class_exists('RectorPrefix20220607\\libev\\EventLoop', \false)) { - throw new \BadMethodCallException('Cannot create ExtLibevLoop, ext-libev extension missing'); + throw new BadMethodCallException('Cannot create ExtLibevLoop, ext-libev extension missing'); } - $this->loop = new \RectorPrefix20220607\libev\EventLoop(); - $this->futureTickQueue = new \RectorPrefix20220607\React\EventLoop\Tick\FutureTickQueue(); - $this->timerEvents = new \SplObjectStorage(); - $this->signals = new \RectorPrefix20220607\React\EventLoop\SignalsHandler(); + $this->loop = new EventLoop(); + $this->futureTickQueue = new FutureTickQueue(); + $this->timerEvents = new SplObjectStorage(); + $this->signals = new SignalsHandler(); } public function addReadStream($stream, $listener) { @@ -53,7 +53,7 @@ final class ExtLibevLoop implements \RectorPrefix20220607\React\EventLoop\LoopIn $callback = function () use($stream, $listener) { \call_user_func($listener, $stream); }; - $event = new \RectorPrefix20220607\libev\IOEvent($callback, $stream, \RectorPrefix20220607\libev\IOEvent::READ); + $event = new IOEvent($callback, $stream, IOEvent::READ); $this->loop->add($event); $this->readEvents[(int) $stream] = $event; } @@ -65,7 +65,7 @@ final class ExtLibevLoop implements \RectorPrefix20220607\React\EventLoop\LoopIn $callback = function () use($stream, $listener) { \call_user_func($listener, $stream); }; - $event = new \RectorPrefix20220607\libev\IOEvent($callback, $stream, \RectorPrefix20220607\libev\IOEvent::WRITE); + $event = new IOEvent($callback, $stream, IOEvent::WRITE); $this->loop->add($event); $this->writeEvents[(int) $stream] = $event; } @@ -89,7 +89,7 @@ final class ExtLibevLoop implements \RectorPrefix20220607\React\EventLoop\LoopIn } public function addTimer($interval, $callback) { - $timer = new \RectorPrefix20220607\React\EventLoop\Timer\Timer($interval, $callback, \false); + $timer = new Timer($interval, $callback, \false); $that = $this; $timers = $this->timerEvents; $callback = function () use($timer, $timers, $that) { @@ -98,23 +98,23 @@ final class ExtLibevLoop implements \RectorPrefix20220607\React\EventLoop\LoopIn $that->cancelTimer($timer); } }; - $event = new \RectorPrefix20220607\libev\TimerEvent($callback, $timer->getInterval()); + $event = new TimerEvent($callback, $timer->getInterval()); $this->timerEvents->attach($timer, $event); $this->loop->add($event); return $timer; } public function addPeriodicTimer($interval, $callback) { - $timer = new \RectorPrefix20220607\React\EventLoop\Timer\Timer($interval, $callback, \true); + $timer = new Timer($interval, $callback, \true); $callback = function () use($timer) { \call_user_func($timer->getCallback(), $timer); }; - $event = new \RectorPrefix20220607\libev\TimerEvent($callback, $timer->getInterval(), $timer->getInterval()); + $event = new TimerEvent($callback, $timer->getInterval(), $timer->getInterval()); $this->timerEvents->attach($timer, $event); $this->loop->add($event); return $timer; } - public function cancelTimer(\RectorPrefix20220607\React\EventLoop\TimerInterface $timer) + public function cancelTimer(TimerInterface $timer) { if (isset($this->timerEvents[$timer])) { $this->loop->remove($this->timerEvents[$timer]); @@ -130,7 +130,7 @@ final class ExtLibevLoop implements \RectorPrefix20220607\React\EventLoop\LoopIn $this->signals->add($signal, $listener); if (!isset($this->signalEvents[$signal])) { $signals = $this->signals; - $this->signalEvents[$signal] = new \RectorPrefix20220607\libev\SignalEvent(function () use($signals, $signal) { + $this->signalEvents[$signal] = new SignalEvent(function () use($signals, $signal) { $signals->call($signal); }, $signal); $this->loop->add($this->signalEvents[$signal]); @@ -150,9 +150,9 @@ final class ExtLibevLoop implements \RectorPrefix20220607\React\EventLoop\LoopIn $this->running = \true; while ($this->running) { $this->futureTickQueue->tick(); - $flags = \RectorPrefix20220607\libev\EventLoop::RUN_ONCE; + $flags = EventLoop::RUN_ONCE; if (!$this->running || !$this->futureTickQueue->isEmpty()) { - $flags |= \RectorPrefix20220607\libev\EventLoop::RUN_NOWAIT; + $flags |= EventLoop::RUN_NOWAIT; } elseif (!$this->readEvents && !$this->writeEvents && !$this->timerEvents->count() && $this->signals->isEmpty()) { break; } diff --git a/vendor/react/event-loop/src/ExtLibeventLoop.php b/vendor/react/event-loop/src/ExtLibeventLoop.php index 4aec9059342..d2d61f06f35 100644 --- a/vendor/react/event-loop/src/ExtLibeventLoop.php +++ b/vendor/react/event-loop/src/ExtLibeventLoop.php @@ -34,7 +34,7 @@ use SplObjectStorage; * @link https://pecl.php.net/package/libevent * @deprecated 1.2.0, use [`ExtEventLoop`](#exteventloop) instead. */ -final class ExtLibeventLoop implements \RectorPrefix20220607\React\EventLoop\LoopInterface +final class ExtLibeventLoop implements LoopInterface { /** @internal */ const MICROSECONDS_PER_SECOND = 1000000; @@ -53,12 +53,12 @@ final class ExtLibeventLoop implements \RectorPrefix20220607\React\EventLoop\Loo public function __construct() { if (!\function_exists('event_base_new')) { - throw new \BadMethodCallException('Cannot create ExtLibeventLoop, ext-libevent extension missing'); + throw new BadMethodCallException('Cannot create ExtLibeventLoop, ext-libevent extension missing'); } $this->eventBase = \event_base_new(); - $this->futureTickQueue = new \RectorPrefix20220607\React\EventLoop\Tick\FutureTickQueue(); - $this->timerEvents = new \SplObjectStorage(); - $this->signals = new \RectorPrefix20220607\React\EventLoop\SignalsHandler(); + $this->futureTickQueue = new FutureTickQueue(); + $this->timerEvents = new SplObjectStorage(); + $this->signals = new SignalsHandler(); $this->createTimerCallback(); $this->createStreamCallback(); } @@ -110,17 +110,17 @@ final class ExtLibeventLoop implements \RectorPrefix20220607\React\EventLoop\Loo } public function addTimer($interval, $callback) { - $timer = new \RectorPrefix20220607\React\EventLoop\Timer\Timer($interval, $callback, \false); + $timer = new Timer($interval, $callback, \false); $this->scheduleTimer($timer); return $timer; } public function addPeriodicTimer($interval, $callback) { - $timer = new \RectorPrefix20220607\React\EventLoop\Timer\Timer($interval, $callback, \true); + $timer = new Timer($interval, $callback, \true); $this->scheduleTimer($timer); return $timer; } - public function cancelTimer(\RectorPrefix20220607\React\EventLoop\TimerInterface $timer) + public function cancelTimer(TimerInterface $timer) { if ($this->timerEvents->contains($timer)) { $event = $this->timerEvents[$timer]; @@ -175,7 +175,7 @@ final class ExtLibeventLoop implements \RectorPrefix20220607\React\EventLoop\Loo * * @param TimerInterface $timer */ - private function scheduleTimer(\RectorPrefix20220607\React\EventLoop\TimerInterface $timer) + private function scheduleTimer(TimerInterface $timer) { $this->timerEvents[$timer] = $event = \event_timer_new(); \event_timer_set($event, $this->timerCallback, $timer); @@ -201,7 +201,7 @@ final class ExtLibeventLoop implements \RectorPrefix20220607\React\EventLoop\Loo } // Reschedule periodic timers ... if ($timer->isPeriodic()) { - \event_add($timers[$timer], $timer->getInterval() * \RectorPrefix20220607\React\EventLoop\ExtLibeventLoop::MICROSECONDS_PER_SECOND); + \event_add($timers[$timer], $timer->getInterval() * ExtLibeventLoop::MICROSECONDS_PER_SECOND); // Clean-up one shot timers ... } else { $that->cancelTimer($timer); diff --git a/vendor/react/event-loop/src/ExtUvLoop.php b/vendor/react/event-loop/src/ExtUvLoop.php index 549f0d4ba72..1bec0add09a 100644 --- a/vendor/react/event-loop/src/ExtUvLoop.php +++ b/vendor/react/event-loop/src/ExtUvLoop.php @@ -16,7 +16,7 @@ use SplObjectStorage; * * @see https://github.com/bwoebi/php-uv */ -final class ExtUvLoop implements \RectorPrefix20220607\React\EventLoop\LoopInterface +final class ExtUvLoop implements LoopInterface { private $uv; private $futureTickQueue; @@ -34,10 +34,10 @@ final class ExtUvLoop implements \RectorPrefix20220607\React\EventLoop\LoopInter throw new \BadMethodCallException('Cannot create LibUvLoop, ext-uv extension missing'); } $this->uv = \uv_loop_new(); - $this->futureTickQueue = new \RectorPrefix20220607\React\EventLoop\Tick\FutureTickQueue(); - $this->timers = new \SplObjectStorage(); + $this->futureTickQueue = new FutureTickQueue(); + $this->timers = new SplObjectStorage(); $this->streamListener = $this->createStreamListener(); - $this->signals = new \RectorPrefix20220607\React\EventLoop\SignalsHandler(); + $this->signals = new SignalsHandler(); } /** * Returns the underlying ext-uv event loop. (Internal ReactPHP use only.) @@ -99,7 +99,7 @@ final class ExtUvLoop implements \RectorPrefix20220607\React\EventLoop\LoopInter */ public function addTimer($interval, $callback) { - $timer = new \RectorPrefix20220607\React\EventLoop\Timer\Timer($interval, $callback, \false); + $timer = new Timer($interval, $callback, \false); $that = $this; $timers = $this->timers; $callback = function () use($timer, $timers, $that) { @@ -118,7 +118,7 @@ final class ExtUvLoop implements \RectorPrefix20220607\React\EventLoop\LoopInter */ public function addPeriodicTimer($interval, $callback) { - $timer = new \RectorPrefix20220607\React\EventLoop\Timer\Timer($interval, $callback, \true); + $timer = new Timer($interval, $callback, \true); $callback = function () use($timer) { \call_user_func($timer->getCallback(), $timer); }; @@ -131,7 +131,7 @@ final class ExtUvLoop implements \RectorPrefix20220607\React\EventLoop\LoopInter /** * {@inheritdoc} */ - public function cancelTimer(\RectorPrefix20220607\React\EventLoop\TimerInterface $timer) + public function cancelTimer(TimerInterface $timer) { if (isset($this->timers[$timer])) { @\uv_timer_stop($this->timers[$timer]); diff --git a/vendor/react/event-loop/src/Factory.php b/vendor/react/event-loop/src/Factory.php index 62e936e5f7f..6236b74b18e 100644 --- a/vendor/react/event-loop/src/Factory.php +++ b/vendor/react/event-loop/src/Factory.php @@ -34,7 +34,7 @@ final class Factory public static function create() { $loop = self::construct(); - \RectorPrefix20220607\React\EventLoop\Loop::set($loop); + Loop::set($loop); return $loop; } /** @@ -46,22 +46,22 @@ final class Factory // @codeCoverageIgnoreStart if (\function_exists('uv_loop_new')) { // only use ext-uv on PHP 7 - return new \RectorPrefix20220607\React\EventLoop\ExtUvLoop(); + return new ExtUvLoop(); } if (\class_exists('RectorPrefix20220607\\libev\\EventLoop', \false)) { - return new \RectorPrefix20220607\React\EventLoop\ExtLibevLoop(); + return new ExtLibevLoop(); } if (\class_exists('EvLoop', \false)) { - return new \RectorPrefix20220607\React\EventLoop\ExtEvLoop(); + return new ExtEvLoop(); } if (\class_exists('EventBase', \false)) { - return new \RectorPrefix20220607\React\EventLoop\ExtEventLoop(); + return new ExtEventLoop(); } if (\function_exists('event_base_new') && \PHP_MAJOR_VERSION === 5) { // only use ext-libevent on PHP 5 for now - return new \RectorPrefix20220607\React\EventLoop\ExtLibeventLoop(); + return new ExtLibeventLoop(); } - return new \RectorPrefix20220607\React\EventLoop\StreamSelectLoop(); + return new StreamSelectLoop(); // @codeCoverageIgnoreEnd } } diff --git a/vendor/react/event-loop/src/Loop.php b/vendor/react/event-loop/src/Loop.php index 1390d65851e..3196e6d6db1 100644 --- a/vendor/react/event-loop/src/Loop.php +++ b/vendor/react/event-loop/src/Loop.php @@ -27,10 +27,10 @@ final class Loop */ public static function get() { - if (self::$instance instanceof \RectorPrefix20220607\React\EventLoop\LoopInterface) { + if (self::$instance instanceof LoopInterface) { return self::$instance; } - self::$instance = $loop = \RectorPrefix20220607\React\EventLoop\Factory::create(); + self::$instance = $loop = Factory::create(); // Automatically run loop at end of program, unless already started or stopped explicitly. // This is tested using child processes, so coverage is actually 100%, see BinTest. // @codeCoverageIgnoreStart @@ -59,7 +59,7 @@ final class Loop * @internal * @return void */ - public static function set(\RectorPrefix20220607\React\EventLoop\LoopInterface $loop) + public static function set(LoopInterface $loop) { self::$instance = $loop; } @@ -142,7 +142,7 @@ final class Loop * @return void * @see LoopInterface::cancelTimer() */ - public static function cancelTimer(\RectorPrefix20220607\React\EventLoop\TimerInterface $timer) + public static function cancelTimer(TimerInterface $timer) { return self::get()->cancelTimer($timer); } diff --git a/vendor/react/event-loop/src/LoopInterface.php b/vendor/react/event-loop/src/LoopInterface.php index e76c67d5702..c57eac5847e 100644 --- a/vendor/react/event-loop/src/LoopInterface.php +++ b/vendor/react/event-loop/src/LoopInterface.php @@ -298,7 +298,7 @@ interface LoopInterface * * @return void */ - public function cancelTimer(\RectorPrefix20220607\React\EventLoop\TimerInterface $timer); + public function cancelTimer(TimerInterface $timer); /** * Schedule a callback to be invoked on a future tick of the event loop. * diff --git a/vendor/react/event-loop/src/StreamSelectLoop.php b/vendor/react/event-loop/src/StreamSelectLoop.php index 6a9a6209d3f..a6c523fb41c 100644 --- a/vendor/react/event-loop/src/StreamSelectLoop.php +++ b/vendor/react/event-loop/src/StreamSelectLoop.php @@ -49,7 +49,7 @@ use RectorPrefix20220607\React\EventLoop\Timer\Timers; * * @link https://www.php.net/manual/en/function.stream-select.php */ -final class StreamSelectLoop implements \RectorPrefix20220607\React\EventLoop\LoopInterface +final class StreamSelectLoop implements LoopInterface { /** @internal */ const MICROSECONDS_PER_SECOND = 1000000; @@ -65,11 +65,11 @@ final class StreamSelectLoop implements \RectorPrefix20220607\React\EventLoop\Lo private $signals; public function __construct() { - $this->futureTickQueue = new \RectorPrefix20220607\React\EventLoop\Tick\FutureTickQueue(); - $this->timers = new \RectorPrefix20220607\React\EventLoop\Timer\Timers(); + $this->futureTickQueue = new FutureTickQueue(); + $this->timers = new Timers(); $this->pcntl = \function_exists('pcntl_signal') && \function_exists('pcntl_signal_dispatch'); $this->pcntlPoll = $this->pcntl && !\function_exists('pcntl_async_signals'); - $this->signals = new \RectorPrefix20220607\React\EventLoop\SignalsHandler(); + $this->signals = new SignalsHandler(); // prefer async signals if available (PHP 7.1+) or fall back to dispatching on each tick if ($this->pcntl && !$this->pcntlPoll) { \pcntl_async_signals(\true); @@ -103,17 +103,17 @@ final class StreamSelectLoop implements \RectorPrefix20220607\React\EventLoop\Lo } public function addTimer($interval, $callback) { - $timer = new \RectorPrefix20220607\React\EventLoop\Timer\Timer($interval, $callback, \false); + $timer = new Timer($interval, $callback, \false); $this->timers->add($timer); return $timer; } public function addPeriodicTimer($interval, $callback) { - $timer = new \RectorPrefix20220607\React\EventLoop\Timer\Timer($interval, $callback, \true); + $timer = new Timer($interval, $callback, \true); $this->timers->add($timer); return $timer; } - public function cancelTimer(\RectorPrefix20220607\React\EventLoop\TimerInterface $timer) + public function cancelTimer(TimerInterface $timer) { $this->timers->cancel($timer); } diff --git a/vendor/react/event-loop/src/Tick/FutureTickQueue.php b/vendor/react/event-loop/src/Tick/FutureTickQueue.php index 30052bb5fb3..c4304dc9319 100644 --- a/vendor/react/event-loop/src/Tick/FutureTickQueue.php +++ b/vendor/react/event-loop/src/Tick/FutureTickQueue.php @@ -16,7 +16,7 @@ final class FutureTickQueue private $queue; public function __construct() { - $this->queue = new \SplQueue(); + $this->queue = new SplQueue(); } /** * Add a callback to be invoked on a future tick of the event loop. diff --git a/vendor/react/event-loop/src/Timer/Timer.php b/vendor/react/event-loop/src/Timer/Timer.php index 827b10eb72e..a7b8007908b 100644 --- a/vendor/react/event-loop/src/Timer/Timer.php +++ b/vendor/react/event-loop/src/Timer/Timer.php @@ -11,7 +11,7 @@ use RectorPrefix20220607\React\EventLoop\TimerInterface; * @see TimerInterface * @internal */ -final class Timer implements \RectorPrefix20220607\React\EventLoop\TimerInterface +final class Timer implements TimerInterface { const MIN_INTERVAL = 1.0E-6; private $interval; diff --git a/vendor/react/event-loop/src/Timer/Timers.php b/vendor/react/event-loop/src/Timer/Timers.php index 9383932b881..802e3ff36d4 100644 --- a/vendor/react/event-loop/src/Timer/Timers.php +++ b/vendor/react/event-loop/src/Timer/Timers.php @@ -31,18 +31,18 @@ final class Timers { return $this->time ?: $this->updateTime(); } - public function add(\RectorPrefix20220607\React\EventLoop\TimerInterface $timer) + public function add(TimerInterface $timer) { $id = \spl_object_hash($timer); $this->timers[$id] = $timer; $this->schedule[$id] = $timer->getInterval() + $this->updateTime(); $this->sorted = \false; } - public function contains(\RectorPrefix20220607\React\EventLoop\TimerInterface $timer) + public function contains(TimerInterface $timer) { return isset($this->timers[\spl_object_hash($timer)]); } - public function cancel(\RectorPrefix20220607\React\EventLoop\TimerInterface $timer) + public function cancel(TimerInterface $timer) { $id = \spl_object_hash($timer); unset($this->timers[$id], $this->schedule[$id]); diff --git a/vendor/react/promise-timer/src/TimeoutException.php b/vendor/react/promise-timer/src/TimeoutException.php index a2df04e4f6f..9bf7960e56c 100644 --- a/vendor/react/promise-timer/src/TimeoutException.php +++ b/vendor/react/promise-timer/src/TimeoutException.php @@ -3,7 +3,7 @@ namespace RectorPrefix20220607\React\Promise\Timer; use RuntimeException; -class TimeoutException extends \RuntimeException +class TimeoutException extends RuntimeException { /** @var float */ private $timeout; diff --git a/vendor/react/promise-timer/src/functions.php b/vendor/react/promise-timer/src/functions.php index 94d3c0df411..ad6851e5019 100644 --- a/vendor/react/promise-timer/src/functions.php +++ b/vendor/react/promise-timer/src/functions.php @@ -138,12 +138,12 @@ use RectorPrefix20220607\React\Promise\PromiseInterface; * @param ?LoopInterface $loop * @return PromiseInterface */ -function timeout(\RectorPrefix20220607\React\Promise\PromiseInterface $promise, $time, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null) +function timeout(PromiseInterface $promise, $time, LoopInterface $loop = null) { // cancelling this promise will only try to cancel the input promise, // thus leaving responsibility to the input promise. $canceller = null; - if ($promise instanceof \RectorPrefix20220607\React\Promise\CancellablePromiseInterface || !\interface_exists('RectorPrefix20220607\\React\\Promise\\CancellablePromiseInterface') && \method_exists($promise, 'cancel')) { + if ($promise instanceof CancellablePromiseInterface || !\interface_exists('RectorPrefix20220607\\React\\Promise\\CancellablePromiseInterface') && \method_exists($promise, 'cancel')) { // pass promise by reference to clean reference after cancellation handler // has been invoked once in order to avoid garbage references in call stack. $canceller = function () use(&$promise) { @@ -152,9 +152,9 @@ function timeout(\RectorPrefix20220607\React\Promise\PromiseInterface $promise, }; } if ($loop === null) { - $loop = \RectorPrefix20220607\React\EventLoop\Loop::get(); + $loop = Loop::get(); } - return new \RectorPrefix20220607\React\Promise\Promise(function ($resolve, $reject) use($loop, $time, $promise) { + return new Promise(function ($resolve, $reject) use($loop, $time, $promise) { $timer = null; $promise = $promise->then(function ($v) use(&$timer, $loop, $resolve) { if ($timer) { @@ -175,10 +175,10 @@ function timeout(\RectorPrefix20220607\React\Promise\PromiseInterface $promise, } // start timeout timer which will cancel the input promise $timer = $loop->addTimer($time, function () use($time, &$promise, $reject) { - $reject(new \RectorPrefix20220607\React\Promise\Timer\TimeoutException($time, 'Timed out after ' . $time . ' seconds')); + $reject(new TimeoutException($time, 'Timed out after ' . $time . ' seconds')); // try to invoke cancellation handler of input promise and then clean // reference in order to avoid garbage references in call stack. - if ($promise instanceof \RectorPrefix20220607\React\Promise\CancellablePromiseInterface || !\interface_exists('RectorPrefix20220607\\React\\Promise\\CancellablePromiseInterface') && \method_exists($promise, 'cancel')) { + if ($promise instanceof CancellablePromiseInterface || !\interface_exists('RectorPrefix20220607\\React\\Promise\\CancellablePromiseInterface') && \method_exists($promise, 'cancel')) { $promise->cancel(); } $promise = null; @@ -219,13 +219,13 @@ function timeout(\RectorPrefix20220607\React\Promise\PromiseInterface $promise, * @param ?LoopInterface $loop * @return PromiseInterface */ -function sleep($time, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null) +function sleep($time, LoopInterface $loop = null) { if ($loop === null) { - $loop = \RectorPrefix20220607\React\EventLoop\Loop::get(); + $loop = Loop::get(); } $timer = null; - return new \RectorPrefix20220607\React\Promise\Promise(function ($resolve) use($loop, $time, &$timer) { + return new Promise(function ($resolve) use($loop, $time, &$timer) { // resolve the promise when the timer fires in $time seconds $timer = $loop->addTimer($time, function () use($resolve) { $resolve(); @@ -274,7 +274,7 @@ function sleep($time, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop * @deprecated 1.8.0 See `sleep()` instead * @see sleep() */ -function resolve($time, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null) +function resolve($time, LoopInterface $loop = null) { return \sleep($time, $loop)->then(function () use($time) { return $time; @@ -316,9 +316,9 @@ function resolve($time, \RectorPrefix20220607\React\EventLoop\LoopInterface $loo * @deprecated 1.8.0 See `sleep()` instead * @see sleep() */ -function reject($time, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null) +function reject($time, LoopInterface $loop = null) { return \sleep($time, $loop)->then(function () use($time) { - throw new \RectorPrefix20220607\React\Promise\Timer\TimeoutException($time, 'Timer expired after ' . $time . ' seconds'); + throw new TimeoutException($time, 'Timer expired after ' . $time . ' seconds'); }); } diff --git a/vendor/react/promise/src/CancellablePromiseInterface.php b/vendor/react/promise/src/CancellablePromiseInterface.php index 825d0c3b913..e16e7d49549 100644 --- a/vendor/react/promise/src/CancellablePromiseInterface.php +++ b/vendor/react/promise/src/CancellablePromiseInterface.php @@ -2,7 +2,7 @@ namespace RectorPrefix20220607\React\Promise; -interface CancellablePromiseInterface extends \RectorPrefix20220607\React\Promise\PromiseInterface +interface CancellablePromiseInterface extends PromiseInterface { /** * The `cancel()` method notifies the creator of the promise that there is no diff --git a/vendor/react/promise/src/Deferred.php b/vendor/react/promise/src/Deferred.php index 979455205e5..ad4ecb9d4a9 100644 --- a/vendor/react/promise/src/Deferred.php +++ b/vendor/react/promise/src/Deferred.php @@ -2,7 +2,7 @@ namespace RectorPrefix20220607\React\Promise; -class Deferred implements \RectorPrefix20220607\React\Promise\PromisorInterface +class Deferred implements PromisorInterface { private $promise; private $resolveCallback; @@ -16,7 +16,7 @@ class Deferred implements \RectorPrefix20220607\React\Promise\PromisorInterface public function promise() { if (null === $this->promise) { - $this->promise = new \RectorPrefix20220607\React\Promise\Promise(function ($resolve, $reject, $notify) { + $this->promise = new Promise(function ($resolve, $reject, $notify) { $this->resolveCallback = $resolve; $this->rejectCallback = $reject; $this->notifyCallback = $notify; diff --git a/vendor/react/promise/src/ExtendedPromiseInterface.php b/vendor/react/promise/src/ExtendedPromiseInterface.php index 45ded6a3593..9dfa461154a 100644 --- a/vendor/react/promise/src/ExtendedPromiseInterface.php +++ b/vendor/react/promise/src/ExtendedPromiseInterface.php @@ -2,7 +2,7 @@ namespace RectorPrefix20220607\React\Promise; -interface ExtendedPromiseInterface extends \RectorPrefix20220607\React\Promise\PromiseInterface +interface ExtendedPromiseInterface extends PromiseInterface { /** * Consumes the promise's ultimate value if the promise fulfills, or handles the diff --git a/vendor/react/promise/src/FulfilledPromise.php b/vendor/react/promise/src/FulfilledPromise.php index f633ff4cc15..6f33eea8198 100644 --- a/vendor/react/promise/src/FulfilledPromise.php +++ b/vendor/react/promise/src/FulfilledPromise.php @@ -5,12 +5,12 @@ namespace RectorPrefix20220607\React\Promise; /** * @deprecated 2.8.0 External usage of FulfilledPromise is deprecated, use `resolve()` instead. */ -class FulfilledPromise implements \RectorPrefix20220607\React\Promise\ExtendedPromiseInterface, \RectorPrefix20220607\React\Promise\CancellablePromiseInterface +class FulfilledPromise implements ExtendedPromiseInterface, CancellablePromiseInterface { private $value; public function __construct($value = null) { - if ($value instanceof \RectorPrefix20220607\React\Promise\PromiseInterface) { + if ($value instanceof PromiseInterface) { throw new \InvalidArgumentException('You cannot create React\\Promise\\FulfilledPromise with a promise. Use React\\Promise\\resolve($promiseOrValue) instead.'); } $this->value = $value; @@ -23,9 +23,9 @@ class FulfilledPromise implements \RectorPrefix20220607\React\Promise\ExtendedPr try { return resolve($onFulfilled($this->value)); } catch (\Throwable $exception) { - return new \RectorPrefix20220607\React\Promise\RejectedPromise($exception); + return new RejectedPromise($exception); } catch (\Exception $exception) { - return new \RectorPrefix20220607\React\Promise\RejectedPromise($exception); + return new RejectedPromise($exception); } } public function done(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null) @@ -34,7 +34,7 @@ class FulfilledPromise implements \RectorPrefix20220607\React\Promise\ExtendedPr return; } $result = $onFulfilled($this->value); - if ($result instanceof \RectorPrefix20220607\React\Promise\ExtendedPromiseInterface) { + if ($result instanceof ExtendedPromiseInterface) { $result->done(); } } diff --git a/vendor/react/promise/src/LazyPromise.php b/vendor/react/promise/src/LazyPromise.php index 244315b0783..cd843bc0569 100644 --- a/vendor/react/promise/src/LazyPromise.php +++ b/vendor/react/promise/src/LazyPromise.php @@ -5,7 +5,7 @@ namespace RectorPrefix20220607\React\Promise; /** * @deprecated 2.8.0 LazyPromise is deprecated and should not be used anymore. */ -class LazyPromise implements \RectorPrefix20220607\React\Promise\ExtendedPromiseInterface, \RectorPrefix20220607\React\Promise\CancellablePromiseInterface +class LazyPromise implements ExtendedPromiseInterface, CancellablePromiseInterface { private $factory; private $promise; @@ -47,9 +47,9 @@ class LazyPromise implements \RectorPrefix20220607\React\Promise\ExtendedPromise try { $this->promise = resolve(\call_user_func($this->factory)); } catch (\Throwable $exception) { - $this->promise = new \RectorPrefix20220607\React\Promise\RejectedPromise($exception); + $this->promise = new RejectedPromise($exception); } catch (\Exception $exception) { - $this->promise = new \RectorPrefix20220607\React\Promise\RejectedPromise($exception); + $this->promise = new RejectedPromise($exception); } } return $this->promise; diff --git a/vendor/react/promise/src/Promise.php b/vendor/react/promise/src/Promise.php index 0f0777bc15d..686ab78cbcf 100644 --- a/vendor/react/promise/src/Promise.php +++ b/vendor/react/promise/src/Promise.php @@ -2,7 +2,7 @@ namespace RectorPrefix20220607\React\Promise; -class Promise implements \RectorPrefix20220607\React\Promise\ExtendedPromiseInterface, \RectorPrefix20220607\React\Promise\CancellablePromiseInterface +class Promise implements ExtendedPromiseInterface, CancellablePromiseInterface { private $canceller; private $result; @@ -47,7 +47,7 @@ class Promise implements \RectorPrefix20220607\React\Promise\ExtendedPromiseInte if (null !== $this->result) { return $this->result->done($onFulfilled, $onRejected, $onProgress); } - $this->handlers[] = static function (\RectorPrefix20220607\React\Promise\ExtendedPromiseInterface $promise) use($onFulfilled, $onRejected) { + $this->handlers[] = static function (ExtendedPromiseInterface $promise) use($onFulfilled, $onRejected) { $promise->done($onFulfilled, $onRejected); }; if ($onProgress) { @@ -58,7 +58,7 @@ class Promise implements \RectorPrefix20220607\React\Promise\ExtendedPromiseInte { return $this->then(null, static function ($reason) use($onRejected) { if (!_checkTypehint($onRejected, $reason)) { - return new \RectorPrefix20220607\React\Promise\RejectedPromise($reason); + return new RejectedPromise($reason); } return $onRejected($reason); }); @@ -71,7 +71,7 @@ class Promise implements \RectorPrefix20220607\React\Promise\ExtendedPromiseInte }); }, static function ($reason) use($onFulfilledOrRejected) { return resolve($onFulfilledOrRejected())->then(function () use($reason) { - return new \RectorPrefix20220607\React\Promise\RejectedPromise($reason); + return new RejectedPromise($reason); }); }); } @@ -104,7 +104,7 @@ class Promise implements \RectorPrefix20220607\React\Promise\ExtendedPromiseInte } else { $progressHandler = $notify; } - $this->handlers[] = static function (\RectorPrefix20220607\React\Promise\ExtendedPromiseInterface $promise) use($onFulfilled, $onRejected, $resolve, $reject, $progressHandler) { + $this->handlers[] = static function (ExtendedPromiseInterface $promise) use($onFulfilled, $onRejected, $resolve, $reject, $progressHandler) { $promise->then($onFulfilled, $onRejected)->done($resolve, $reject, $progressHandler); }; $this->progressHandlers[] = $progressHandler; @@ -117,11 +117,11 @@ class Promise implements \RectorPrefix20220607\React\Promise\ExtendedPromiseInte } $this->settle(reject($reason)); } - private function settle(\RectorPrefix20220607\React\Promise\ExtendedPromiseInterface $promise) + private function settle(ExtendedPromiseInterface $promise) { $promise = $this->unwrap($promise); if ($promise === $this) { - $promise = new \RectorPrefix20220607\React\Promise\RejectedPromise(new \LogicException('Cannot resolve a promise with itself.')); + $promise = new RejectedPromise(new \LogicException('Cannot resolve a promise with itself.')); } $handlers = $this->handlers; $this->progressHandlers = $this->handlers = []; @@ -141,7 +141,7 @@ class Promise implements \RectorPrefix20220607\React\Promise\ExtendedPromiseInte } private function extract($promise) { - if ($promise instanceof \RectorPrefix20220607\React\Promise\LazyPromise) { + if ($promise instanceof LazyPromise) { $promise = $promise->promise(); } return $promise; diff --git a/vendor/react/promise/src/RejectedPromise.php b/vendor/react/promise/src/RejectedPromise.php index 1fd187fa158..e08dcede3e5 100644 --- a/vendor/react/promise/src/RejectedPromise.php +++ b/vendor/react/promise/src/RejectedPromise.php @@ -5,12 +5,12 @@ namespace RectorPrefix20220607\React\Promise; /** * @deprecated 2.8.0 External usage of RejectedPromise is deprecated, use `reject()` instead. */ -class RejectedPromise implements \RectorPrefix20220607\React\Promise\ExtendedPromiseInterface, \RectorPrefix20220607\React\Promise\CancellablePromiseInterface +class RejectedPromise implements ExtendedPromiseInterface, CancellablePromiseInterface { private $reason; public function __construct($reason = null) { - if ($reason instanceof \RectorPrefix20220607\React\Promise\PromiseInterface) { + if ($reason instanceof PromiseInterface) { throw new \InvalidArgumentException('You cannot create React\\Promise\\RejectedPromise with a promise. Use React\\Promise\\reject($promiseOrValue) instead.'); } $this->reason = $reason; @@ -23,21 +23,21 @@ class RejectedPromise implements \RectorPrefix20220607\React\Promise\ExtendedPro try { return resolve($onRejected($this->reason)); } catch (\Throwable $exception) { - return new \RectorPrefix20220607\React\Promise\RejectedPromise($exception); + return new RejectedPromise($exception); } catch (\Exception $exception) { - return new \RectorPrefix20220607\React\Promise\RejectedPromise($exception); + return new RejectedPromise($exception); } } public function done(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null) { if (null === $onRejected) { - throw \RectorPrefix20220607\React\Promise\UnhandledRejectionException::resolve($this->reason); + throw UnhandledRejectionException::resolve($this->reason); } $result = $onRejected($this->reason); if ($result instanceof self) { - throw \RectorPrefix20220607\React\Promise\UnhandledRejectionException::resolve($result->reason); + throw UnhandledRejectionException::resolve($result->reason); } - if ($result instanceof \RectorPrefix20220607\React\Promise\ExtendedPromiseInterface) { + if ($result instanceof ExtendedPromiseInterface) { $result->done(); } } @@ -52,7 +52,7 @@ class RejectedPromise implements \RectorPrefix20220607\React\Promise\ExtendedPro { return $this->then(null, function ($reason) use($onFulfilledOrRejected) { return resolve($onFulfilledOrRejected())->then(function () use($reason) { - return new \RectorPrefix20220607\React\Promise\RejectedPromise($reason); + return new RejectedPromise($reason); }); }); } diff --git a/vendor/react/promise/src/functions.php b/vendor/react/promise/src/functions.php index 720e954f4b8..9b3fac2feca 100644 --- a/vendor/react/promise/src/functions.php +++ b/vendor/react/promise/src/functions.php @@ -18,7 +18,7 @@ namespace RectorPrefix20220607\React\Promise; */ function resolve($promiseOrValue = null) { - if ($promiseOrValue instanceof \RectorPrefix20220607\React\Promise\ExtendedPromiseInterface) { + if ($promiseOrValue instanceof ExtendedPromiseInterface) { return $promiseOrValue; } // Check is_object() first to avoid method_exists() triggering @@ -28,11 +28,11 @@ function resolve($promiseOrValue = null) if (\method_exists($promiseOrValue, 'cancel')) { $canceller = [$promiseOrValue, 'cancel']; } - return new \RectorPrefix20220607\React\Promise\Promise(function ($resolve, $reject, $notify) use($promiseOrValue) { + return new Promise(function ($resolve, $reject, $notify) use($promiseOrValue) { $promiseOrValue->then($resolve, $reject, $notify); }, $canceller); } - return new \RectorPrefix20220607\React\Promise\FulfilledPromise($promiseOrValue); + return new FulfilledPromise($promiseOrValue); } /** * Creates a rejected promise for the supplied `$promiseOrValue`. @@ -52,12 +52,12 @@ function resolve($promiseOrValue = null) */ function reject($promiseOrValue = null) { - if ($promiseOrValue instanceof \RectorPrefix20220607\React\Promise\PromiseInterface) { + if ($promiseOrValue instanceof PromiseInterface) { return resolve($promiseOrValue)->then(function ($value) { - return new \RectorPrefix20220607\React\Promise\RejectedPromise($value); + return new RejectedPromise($value); }); } - return new \RectorPrefix20220607\React\Promise\RejectedPromise($promiseOrValue); + return new RejectedPromise($promiseOrValue); } /** * Returns a promise that will resolve only once all the items in @@ -86,9 +86,9 @@ function all($promisesOrValues) */ function race($promisesOrValues) { - $cancellationQueue = new \RectorPrefix20220607\React\Promise\CancellationQueue(); + $cancellationQueue = new CancellationQueue(); $cancellationQueue->enqueue($promisesOrValues); - return new \RectorPrefix20220607\React\Promise\Promise(function ($resolve, $reject, $notify) use($promisesOrValues, $cancellationQueue) { + return new Promise(function ($resolve, $reject, $notify) use($promisesOrValues, $cancellationQueue) { resolve($promisesOrValues)->done(function ($array) use($cancellationQueue, $resolve, $reject, $notify) { if (!\is_array($array) || !$array) { $resolve(); @@ -141,9 +141,9 @@ function any($promisesOrValues) */ function some($promisesOrValues, $howMany) { - $cancellationQueue = new \RectorPrefix20220607\React\Promise\CancellationQueue(); + $cancellationQueue = new CancellationQueue(); $cancellationQueue->enqueue($promisesOrValues); - return new \RectorPrefix20220607\React\Promise\Promise(function ($resolve, $reject, $notify) use($promisesOrValues, $howMany, $cancellationQueue) { + return new Promise(function ($resolve, $reject, $notify) use($promisesOrValues, $howMany, $cancellationQueue) { resolve($promisesOrValues)->done(function ($array) use($howMany, $cancellationQueue, $resolve, $reject, $notify) { if (!\is_array($array) || $howMany < 1) { $resolve([]); @@ -151,7 +151,7 @@ function some($promisesOrValues, $howMany) } $len = \count($array); if ($len < $howMany) { - throw new \RectorPrefix20220607\React\Promise\Exception\LengthException(\sprintf('Input array must contain at least %d item%s but contains only %s item%s.', $howMany, 1 === $howMany ? '' : 's', $len, 1 === $len ? '' : 's')); + throw new Exception\LengthException(\sprintf('Input array must contain at least %d item%s but contains only %s item%s.', $howMany, 1 === $howMany ? '' : 's', $len, 1 === $len ? '' : 's')); } $toResolve = $howMany; $toReject = $len - $toResolve + 1; @@ -195,9 +195,9 @@ function some($promisesOrValues, $howMany) */ function map($promisesOrValues, callable $mapFunc) { - $cancellationQueue = new \RectorPrefix20220607\React\Promise\CancellationQueue(); + $cancellationQueue = new CancellationQueue(); $cancellationQueue->enqueue($promisesOrValues); - return new \RectorPrefix20220607\React\Promise\Promise(function ($resolve, $reject, $notify) use($promisesOrValues, $mapFunc, $cancellationQueue) { + return new Promise(function ($resolve, $reject, $notify) use($promisesOrValues, $mapFunc, $cancellationQueue) { resolve($promisesOrValues)->done(function ($array) use($mapFunc, $cancellationQueue, $resolve, $reject, $notify) { if (!\is_array($array) || !$array) { $resolve([]); @@ -231,9 +231,9 @@ function map($promisesOrValues, callable $mapFunc) */ function reduce($promisesOrValues, callable $reduceFunc, $initialValue = null) { - $cancellationQueue = new \RectorPrefix20220607\React\Promise\CancellationQueue(); + $cancellationQueue = new CancellationQueue(); $cancellationQueue->enqueue($promisesOrValues); - return new \RectorPrefix20220607\React\Promise\Promise(function ($resolve, $reject, $notify) use($promisesOrValues, $reduceFunc, $initialValue, $cancellationQueue) { + return new Promise(function ($resolve, $reject, $notify) use($promisesOrValues, $reduceFunc, $initialValue, $cancellationQueue) { resolve($promisesOrValues)->done(function ($array) use($reduceFunc, $initialValue, $cancellationQueue, $resolve, $reject, $notify) { if (!\is_array($array)) { $array = []; @@ -276,7 +276,7 @@ function _checkTypehint(callable $callback, $object) } $expectedException = $parameters[0]; // PHP before v8 used an easy API: - if (\PHP_VERSION_ID < 70100 || \defined('HHVM_VERSION')) { + if (\PHP_VERSION_ID < 70100 || \defined('RectorPrefix20220607\\HHVM_VERSION')) { if (!$expectedException->getClass()) { return \true; } @@ -292,7 +292,7 @@ function _checkTypehint(callable $callback, $object) case $type instanceof \ReflectionNamedType: $types = [$type]; break; - case $type instanceof \RectorPrefix20220607\ReflectionIntersectionType: + case $type instanceof \ReflectionIntersectionType: $isTypeUnion = \false; case $type instanceof \ReflectionUnionType: $types = $type->getTypes(); diff --git a/vendor/react/socket/src/Connection.php b/vendor/react/socket/src/Connection.php index 9f9d2d38cda..8fc270aded6 100644 --- a/vendor/react/socket/src/Connection.php +++ b/vendor/react/socket/src/Connection.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\React\Stream\WritableStreamInterface; * @see ConnectionInterface * @internal */ -class Connection extends \RectorPrefix20220607\Evenement\EventEmitter implements \RectorPrefix20220607\React\Socket\ConnectionInterface +class Connection extends EventEmitter implements ConnectionInterface { /** * Internal flag whether this is a Unix domain socket (UDS) connection @@ -36,7 +36,7 @@ class Connection extends \RectorPrefix20220607\Evenement\EventEmitter implements /** @internal */ public $stream; private $input; - public function __construct($resource, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop) + public function __construct($resource, LoopInterface $loop) { // PHP < 7.3.3 (and PHP < 7.2.15) suffers from a bug where feof() might // block with 100% CPU usage on fragmented TLS records. @@ -57,9 +57,9 @@ class Connection extends \RectorPrefix20220607\Evenement\EventEmitter implements // This applies to all streams because TLS may be enabled later on. // See https://github.com/reactphp/socket/issues/105 $limitWriteChunks = \PHP_VERSION_ID < 70018 || \PHP_VERSION_ID >= 70100 && \PHP_VERSION_ID < 70104; - $this->input = new \RectorPrefix20220607\React\Stream\DuplexResourceStream($resource, $loop, $clearCompleteBuffer ? -1 : null, new \RectorPrefix20220607\React\Stream\WritableResourceStream($resource, $loop, null, $limitWriteChunks ? 8192 : null)); + $this->input = new DuplexResourceStream($resource, $loop, $clearCompleteBuffer ? -1 : null, new WritableResourceStream($resource, $loop, null, $limitWriteChunks ? 8192 : null)); $this->stream = $resource; - \RectorPrefix20220607\React\Stream\Util::forwardEvents($this->input, $this, array('data', 'end', 'error', 'close', 'pipe', 'drain')); + Util::forwardEvents($this->input, $this, array('data', 'end', 'error', 'close', 'pipe', 'drain')); $this->input->on('close', array($this, 'close')); } public function isReadable() @@ -78,7 +78,7 @@ class Connection extends \RectorPrefix20220607\Evenement\EventEmitter implements { $this->input->resume(); } - public function pipe(\RectorPrefix20220607\React\Stream\WritableStreamInterface $dest, array $options = array()) + public function pipe(WritableStreamInterface $dest, array $options = array()) { return $this->input->pipe($dest, $options); } @@ -132,13 +132,13 @@ class Connection extends \RectorPrefix20220607\Evenement\EventEmitter implements if ($this->unix) { // remove trailing colon from address for HHVM < 3.19: https://3v4l.org/5C1lo // note that technically ":" is a valid address, so keep this in place otherwise - if (\substr($address, -1) === ':' && \defined('HHVM_VERSION_ID') && \HHVM_VERSION_ID < 31900) { + if (\substr($address, -1) === ':' && \defined('RectorPrefix20220607\\HHVM_VERSION_ID') && \RectorPrefix20220607\HHVM_VERSION_ID < 31900) { $address = (string) \substr($address, 0, -1); // @codeCoverageIgnore } // work around unknown addresses should return null value: https://3v4l.org/5C1lo and https://bugs.php.net/bug.php?id=74556 // PHP uses "\0" string and HHVM uses empty string (colon removed above) - if ($address === '' || $address[0] === "\0") { + if ($address === '' || $address[0] === "\x00") { return null; // @codeCoverageIgnore } diff --git a/vendor/react/socket/src/ConnectionInterface.php b/vendor/react/socket/src/ConnectionInterface.php index 836041fe6e8..b9ce4f838bd 100644 --- a/vendor/react/socket/src/ConnectionInterface.php +++ b/vendor/react/socket/src/ConnectionInterface.php @@ -51,7 +51,7 @@ use RectorPrefix20220607\React\Stream\DuplexStreamInterface; * @see ServerInterface * @see ConnectorInterface */ -interface ConnectionInterface extends \RectorPrefix20220607\React\Stream\DuplexStreamInterface +interface ConnectionInterface extends DuplexStreamInterface { /** * Returns the full remote address (URI) where this connection has been established with diff --git a/vendor/react/socket/src/Connector.php b/vendor/react/socket/src/Connector.php index 07e55d43f30..88c491b5632 100644 --- a/vendor/react/socket/src/Connector.php +++ b/vendor/react/socket/src/Connector.php @@ -21,7 +21,7 @@ use RectorPrefix20220607\React\EventLoop\LoopInterface; * * @see ConnectorInterface for the base interface */ -final class Connector implements \RectorPrefix20220607\React\Socket\ConnectorInterface +final class Connector implements ConnectorInterface { private $connectors = array(); /** @@ -54,12 +54,12 @@ final class Connector implements \RectorPrefix20220607\React\Socket\ConnectorInt public function __construct($context = array(), $loop = null) { // swap arguments for legacy constructor signature - if (($context instanceof \RectorPrefix20220607\React\EventLoop\LoopInterface || $context === null) && (\func_num_args() <= 1 || \is_array($loop))) { + if (($context instanceof LoopInterface || $context === null) && (\func_num_args() <= 1 || \is_array($loop))) { $swap = $loop === null ? array() : $loop; $loop = $context; $context = $swap; } - if (!\is_array($context) || $loop !== null && !$loop instanceof \RectorPrefix20220607\React\EventLoop\LoopInterface) { + if (!\is_array($context) || $loop !== null && !$loop instanceof LoopInterface) { throw new \InvalidArgumentException('Expected "array $context" and "?LoopInterface $loop" arguments'); } // apply default options if not explicitly given @@ -67,53 +67,53 @@ final class Connector implements \RectorPrefix20220607\React\Socket\ConnectorInt if ($context['timeout'] === \true) { $context['timeout'] = (float) \ini_get("default_socket_timeout"); } - if ($context['tcp'] instanceof \RectorPrefix20220607\React\Socket\ConnectorInterface) { + if ($context['tcp'] instanceof ConnectorInterface) { $tcp = $context['tcp']; } else { - $tcp = new \RectorPrefix20220607\React\Socket\TcpConnector($loop, \is_array($context['tcp']) ? $context['tcp'] : array()); + $tcp = new TcpConnector($loop, \is_array($context['tcp']) ? $context['tcp'] : array()); } if ($context['dns'] !== \false) { - if ($context['dns'] instanceof \RectorPrefix20220607\React\Dns\Resolver\ResolverInterface) { + if ($context['dns'] instanceof ResolverInterface) { $resolver = $context['dns']; } else { if ($context['dns'] !== \true) { $config = $context['dns']; } else { // try to load nameservers from system config or default to Google's public DNS - $config = \RectorPrefix20220607\React\Dns\Config\Config::loadSystemConfigBlocking(); + $config = DnsConfig::loadSystemConfigBlocking(); if (!$config->nameservers) { $config->nameservers[] = '8.8.8.8'; // @codeCoverageIgnore } } - $factory = new \RectorPrefix20220607\React\Dns\Resolver\Factory(); + $factory = new DnsFactory(); $resolver = $factory->createCached($config, $loop); } if ($context['happy_eyeballs'] === \true) { - $tcp = new \RectorPrefix20220607\React\Socket\HappyEyeBallsConnector($loop, $tcp, $resolver); + $tcp = new HappyEyeBallsConnector($loop, $tcp, $resolver); } else { - $tcp = new \RectorPrefix20220607\React\Socket\DnsConnector($tcp, $resolver); + $tcp = new DnsConnector($tcp, $resolver); } } if ($context['tcp'] !== \false) { $context['tcp'] = $tcp; if ($context['timeout'] !== \false) { - $context['tcp'] = new \RectorPrefix20220607\React\Socket\TimeoutConnector($context['tcp'], $context['timeout'], $loop); + $context['tcp'] = new TimeoutConnector($context['tcp'], $context['timeout'], $loop); } $this->connectors['tcp'] = $context['tcp']; } if ($context['tls'] !== \false) { - if (!$context['tls'] instanceof \RectorPrefix20220607\React\Socket\ConnectorInterface) { - $context['tls'] = new \RectorPrefix20220607\React\Socket\SecureConnector($tcp, $loop, \is_array($context['tls']) ? $context['tls'] : array()); + if (!$context['tls'] instanceof ConnectorInterface) { + $context['tls'] = new SecureConnector($tcp, $loop, \is_array($context['tls']) ? $context['tls'] : array()); } if ($context['timeout'] !== \false) { - $context['tls'] = new \RectorPrefix20220607\React\Socket\TimeoutConnector($context['tls'], $context['timeout'], $loop); + $context['tls'] = new TimeoutConnector($context['tls'], $context['timeout'], $loop); } $this->connectors['tls'] = $context['tls']; } if ($context['unix'] !== \false) { - if (!$context['unix'] instanceof \RectorPrefix20220607\React\Socket\ConnectorInterface) { - $context['unix'] = new \RectorPrefix20220607\React\Socket\UnixConnector($loop); + if (!$context['unix'] instanceof ConnectorInterface) { + $context['unix'] = new UnixConnector($loop); } $this->connectors['unix'] = $context['unix']; } diff --git a/vendor/react/socket/src/DnsConnector.php b/vendor/react/socket/src/DnsConnector.php index d9d1fb4bbbc..8edfc781960 100644 --- a/vendor/react/socket/src/DnsConnector.php +++ b/vendor/react/socket/src/DnsConnector.php @@ -5,11 +5,11 @@ namespace RectorPrefix20220607\React\Socket; use RectorPrefix20220607\React\Dns\Resolver\ResolverInterface; use RectorPrefix20220607\React\Promise; use RectorPrefix20220607\React\Promise\CancellablePromiseInterface; -final class DnsConnector implements \RectorPrefix20220607\React\Socket\ConnectorInterface +final class DnsConnector implements ConnectorInterface { private $connector; private $resolver; - public function __construct(\RectorPrefix20220607\React\Socket\ConnectorInterface $connector, \RectorPrefix20220607\React\Dns\Resolver\ResolverInterface $resolver) + public function __construct(ConnectorInterface $connector, ResolverInterface $resolver) { $this->connector = $connector; $this->resolver = $resolver; @@ -27,7 +27,7 @@ final class DnsConnector implements \RectorPrefix20220607\React\Socket\Connector $parts = \parse_url($uri); } if (!$parts || !isset($parts['host'])) { - return \RectorPrefix20220607\React\Promise\reject(new \InvalidArgumentException('Given URI "' . $original . '" is invalid (EINVAL)', \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22)); + return Promise\reject(new \InvalidArgumentException('Given URI "' . $original . '" is invalid (EINVAL)', \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22)); } $host = \trim($parts['host'], '[]'); $connector = $this->connector; @@ -37,11 +37,11 @@ final class DnsConnector implements \RectorPrefix20220607\React\Socket\Connector } $promise = $this->resolver->resolve($host); $resolved = null; - return new \RectorPrefix20220607\React\Promise\Promise(function ($resolve, $reject) use(&$promise, &$resolved, $uri, $connector, $host, $parts) { + return new Promise\Promise(function ($resolve, $reject) use(&$promise, &$resolved, $uri, $connector, $host, $parts) { // resolve/reject with result of DNS lookup $promise->then(function ($ip) use(&$promise, &$resolved, $uri, $connector, $host, $parts) { $resolved = $ip; - return $promise = $connector->connect(\RectorPrefix20220607\React\Socket\Connector::uri($parts, $host, $ip))->then(null, function (\Exception $e) use($uri) { + return $promise = $connector->connect(Connector::uri($parts, $host, $ip))->then(null, function (\Exception $e) use($uri) { if ($e instanceof \RuntimeException) { $message = \preg_replace('/^(Connection to [^ ]+)[&?]hostname=[^ &]+/', '$1', $e->getMessage()); $e = new \RuntimeException('Connection to ' . $uri . ' failed: ' . $message, $e->getCode(), $e); @@ -76,7 +76,7 @@ final class DnsConnector implements \RectorPrefix20220607\React\Socket\Connector $reject(new \RuntimeException('Connection to ' . $uri . ' cancelled during DNS lookup (ECONNABORTED)', \defined('SOCKET_ECONNABORTED') ? \SOCKET_ECONNABORTED : 103)); } // (try to) cancel pending DNS lookup / connection attempt - if ($promise instanceof \RectorPrefix20220607\React\Promise\CancellablePromiseInterface) { + if ($promise instanceof CancellablePromiseInterface) { // overwrite callback arguments for PHP7+ only, so they do not show // up in the Exception trace and do not cause a possible cyclic reference. $_ = $reject = null; diff --git a/vendor/react/socket/src/FdServer.php b/vendor/react/socket/src/FdServer.php index 44351f55b48..a9e24c61f3c 100644 --- a/vendor/react/socket/src/FdServer.php +++ b/vendor/react/socket/src/FdServer.php @@ -30,7 +30,7 @@ use RectorPrefix20220607\React\EventLoop\LoopInterface; * @see ConnectionInterface * @internal */ -final class FdServer extends \RectorPrefix20220607\Evenement\EventEmitter implements \RectorPrefix20220607\React\Socket\ServerInterface +final class FdServer extends EventEmitter implements ServerInterface { private $master; private $loop; @@ -73,7 +73,7 @@ final class FdServer extends \RectorPrefix20220607\Evenement\EventEmitter implem * @throws \InvalidArgumentException if the listening address is invalid * @throws \RuntimeException if listening on this address fails (already in use etc.) */ - public function __construct($fd, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null) + public function __construct($fd, LoopInterface $loop = null) { if (\preg_match('#^php://fd/(\\d+)$#', $fd, $m)) { $fd = (int) $m[1]; @@ -81,7 +81,7 @@ final class FdServer extends \RectorPrefix20220607\Evenement\EventEmitter implem if (!\is_int($fd) || $fd < 0 || $fd >= \PHP_INT_MAX) { throw new \InvalidArgumentException('Invalid FD number given (EINVAL)', \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22); } - $this->loop = $loop ?: \RectorPrefix20220607\React\EventLoop\Loop::get(); + $this->loop = $loop ?: Loop::get(); $this->master = @\fopen('php://fd/' . $fd, 'r+'); if (\false === $this->master) { // Match errstr from PHP's warning message. @@ -90,7 +90,7 @@ final class FdServer extends \RectorPrefix20220607\Evenement\EventEmitter implem \preg_match('/\\[(\\d+)\\]: (.*)/', $error['message'], $m); $errno = isset($m[1]) ? (int) $m[1] : 0; $errstr = isset($m[2]) ? $m[2] : $error['message']; - throw new \RuntimeException('Failed to listen on FD ' . $fd . ': ' . $errstr . \RectorPrefix20220607\React\Socket\SocketServer::errconst($errno), $errno); + throw new \RuntimeException('Failed to listen on FD ' . $fd . ': ' . $errstr . SocketServer::errconst($errno), $errno); } $meta = \stream_get_meta_data($this->master); if (!isset($meta['stream_type']) || $meta['stream_type'] !== 'tcp_socket') { @@ -146,7 +146,7 @@ final class FdServer extends \RectorPrefix20220607\Evenement\EventEmitter implem $that = $this; $this->loop->addReadStream($this->master, function ($master) use($that) { try { - $newSocket = \RectorPrefix20220607\React\Socket\SocketServer::accept($master); + $newSocket = SocketServer::accept($master); } catch (\RuntimeException $e) { $that->emit('error', array($e)); return; @@ -167,7 +167,7 @@ final class FdServer extends \RectorPrefix20220607\Evenement\EventEmitter implem /** @internal */ public function handleConnection($socket) { - $connection = new \RectorPrefix20220607\React\Socket\Connection($socket, $this->loop); + $connection = new Connection($socket, $this->loop); $connection->unix = $this->unix; $this->emit('connection', array($connection)); } diff --git a/vendor/react/socket/src/FixedUriConnector.php b/vendor/react/socket/src/FixedUriConnector.php index 8fb5c9e7f7f..012b8141969 100644 --- a/vendor/react/socket/src/FixedUriConnector.php +++ b/vendor/react/socket/src/FixedUriConnector.php @@ -19,7 +19,7 @@ namespace RectorPrefix20220607\React\Socket; * $promise = $connector->connect('localhost:80'); * ``` */ -class FixedUriConnector implements \RectorPrefix20220607\React\Socket\ConnectorInterface +class FixedUriConnector implements ConnectorInterface { private $uri; private $connector; @@ -27,7 +27,7 @@ class FixedUriConnector implements \RectorPrefix20220607\React\Socket\ConnectorI * @param string $uri * @param ConnectorInterface $connector */ - public function __construct($uri, \RectorPrefix20220607\React\Socket\ConnectorInterface $connector) + public function __construct($uri, ConnectorInterface $connector) { $this->uri = $uri; $this->connector = $connector; diff --git a/vendor/react/socket/src/HappyEyeBallsConnectionBuilder.php b/vendor/react/socket/src/HappyEyeBallsConnectionBuilder.php index 3d9abadebd8..9a5a51f5d23 100644 --- a/vendor/react/socket/src/HappyEyeBallsConnectionBuilder.php +++ b/vendor/react/socket/src/HappyEyeBallsConnectionBuilder.php @@ -32,7 +32,7 @@ final class HappyEyeBallsConnectionBuilder public $resolver; public $uri; public $host; - public $resolved = array(\RectorPrefix20220607\React\Dns\Model\Message::TYPE_A => \false, \RectorPrefix20220607\React\Dns\Model\Message::TYPE_AAAA => \false); + public $resolved = array(Message::TYPE_A => \false, Message::TYPE_AAAA => \false); public $resolverPromises = array(); public $connectionPromises = array(); public $connectQueue = array(); @@ -45,7 +45,7 @@ final class HappyEyeBallsConnectionBuilder public $lastErrorFamily; public $lastError6; public $lastError4; - public function __construct(\RectorPrefix20220607\React\EventLoop\LoopInterface $loop, \RectorPrefix20220607\React\Socket\ConnectorInterface $connector, \RectorPrefix20220607\React\Dns\Resolver\ResolverInterface $resolver, $uri, $host, $parts) + public function __construct(LoopInterface $loop, ConnectorInterface $connector, ResolverInterface $resolver, $uri, $host, $parts) { $this->loop = $loop; $this->connector = $connector; @@ -58,7 +58,7 @@ final class HappyEyeBallsConnectionBuilder { $timer = null; $that = $this; - return new \RectorPrefix20220607\React\Promise\Promise(function ($resolve, $reject) use($that, &$timer) { + return new Promise\Promise(function ($resolve, $reject) use($that, &$timer) { $lookupResolve = function ($type) use($that, $resolve, $reject) { return function (array $ips) use($that, $type, $resolve, $reject) { unset($that->resolverPromises[$type]); @@ -70,28 +70,28 @@ final class HappyEyeBallsConnectionBuilder } }; }; - $that->resolverPromises[\RectorPrefix20220607\React\Dns\Model\Message::TYPE_AAAA] = $that->resolve(\RectorPrefix20220607\React\Dns\Model\Message::TYPE_AAAA, $reject)->then($lookupResolve(\RectorPrefix20220607\React\Dns\Model\Message::TYPE_AAAA)); - $that->resolverPromises[\RectorPrefix20220607\React\Dns\Model\Message::TYPE_A] = $that->resolve(\RectorPrefix20220607\React\Dns\Model\Message::TYPE_A, $reject)->then(function (array $ips) use($that, &$timer) { + $that->resolverPromises[Message::TYPE_AAAA] = $that->resolve(Message::TYPE_AAAA, $reject)->then($lookupResolve(Message::TYPE_AAAA)); + $that->resolverPromises[Message::TYPE_A] = $that->resolve(Message::TYPE_A, $reject)->then(function (array $ips) use($that, &$timer) { // happy path: IPv6 has resolved already (or could not resolve), continue with IPv4 addresses - if ($that->resolved[\RectorPrefix20220607\React\Dns\Model\Message::TYPE_AAAA] === \true || !$ips) { + if ($that->resolved[Message::TYPE_AAAA] === \true || !$ips) { return $ips; } // Otherwise delay processing IPv4 lookup until short timer passes or IPv6 resolves in the meantime - $deferred = new \RectorPrefix20220607\React\Promise\Deferred(); + $deferred = new Promise\Deferred(); $timer = $that->loop->addTimer($that::RESOLUTION_DELAY, function () use($deferred, $ips) { $deferred->resolve($ips); }); - $that->resolverPromises[\RectorPrefix20220607\React\Dns\Model\Message::TYPE_AAAA]->then(function () use($that, $timer, $deferred, $ips) { + $that->resolverPromises[Message::TYPE_AAAA]->then(function () use($that, $timer, $deferred, $ips) { $that->loop->cancelTimer($timer); $deferred->resolve($ips); }); return $deferred->promise(); - })->then($lookupResolve(\RectorPrefix20220607\React\Dns\Model\Message::TYPE_A)); + })->then($lookupResolve(Message::TYPE_A)); }, function ($_, $reject) use($that, &$timer) { $reject(new \RuntimeException('Connection to ' . $that->uri . ' cancelled' . (!$that->connectionPromises ? ' during DNS lookup' : '') . ' (ECONNABORTED)', \defined('SOCKET_ECONNABORTED') ? \SOCKET_ECONNABORTED : 103)); $_ = $reject = null; $that->cleanUp(); - if ($timer instanceof \RectorPrefix20220607\React\EventLoop\TimerInterface) { + if ($timer instanceof TimerInterface) { $that->loop->cancelTimer($timer); } }); @@ -110,7 +110,7 @@ final class HappyEyeBallsConnectionBuilder return $that->resolver->resolveAll($that->host, $type)->then(null, function (\Exception $e) use($type, $reject, $that) { unset($that->resolverPromises[$type]); $that->resolved[$type] = \true; - if ($type === \RectorPrefix20220607\React\Dns\Model\Message::TYPE_A) { + if ($type === Message::TYPE_A) { $that->lastError4 = $e->getMessage(); $that->lastErrorFamily = 4; } else { @@ -173,7 +173,7 @@ final class HappyEyeBallsConnectionBuilder }); // Allow next connection attempt in 100ms: https://tools.ietf.org/html/rfc8305#section-5 // Only start timer when more IPs are queued or when DNS query is still pending (might add more IPs) - if ($this->nextAttemptTimer === null && (\count($this->connectQueue) > 0 || $this->resolved[\RectorPrefix20220607\React\Dns\Model\Message::TYPE_A] === \false || $this->resolved[\RectorPrefix20220607\React\Dns\Model\Message::TYPE_AAAA] === \false)) { + if ($this->nextAttemptTimer === null && (\count($this->connectQueue) > 0 || $this->resolved[Message::TYPE_A] === \false || $this->resolved[Message::TYPE_AAAA] === \false)) { $this->nextAttemptTimer = $this->loop->addTimer(self::CONNECTION_ATTEMPT_DELAY, function () use($that, $resolve, $reject) { $that->nextAttemptTimer = null; if ($that->connectQueue) { @@ -187,7 +187,7 @@ final class HappyEyeBallsConnectionBuilder */ public function attemptConnection($ip) { - $uri = \RectorPrefix20220607\React\Socket\Connector::uri($this->parts, $this->host, $ip); + $uri = Connector::uri($this->parts, $this->host, $ip); return $this->connector->connect($uri); } /** @@ -198,16 +198,16 @@ final class HappyEyeBallsConnectionBuilder // clear list of outstanding IPs to avoid creating new connections $this->connectQueue = array(); foreach ($this->connectionPromises as $connectionPromise) { - if ($connectionPromise instanceof \RectorPrefix20220607\React\Promise\CancellablePromiseInterface) { + if ($connectionPromise instanceof CancellablePromiseInterface) { $connectionPromise->cancel(); } } foreach ($this->resolverPromises as $resolverPromise) { - if ($resolverPromise instanceof \RectorPrefix20220607\React\Promise\CancellablePromiseInterface) { + if ($resolverPromise instanceof CancellablePromiseInterface) { $resolverPromise->cancel(); } } - if ($this->nextAttemptTimer instanceof \RectorPrefix20220607\React\EventLoop\TimerInterface) { + if ($this->nextAttemptTimer instanceof TimerInterface) { $this->loop->cancelTimer($this->nextAttemptTimer); $this->nextAttemptTimer = null; } diff --git a/vendor/react/socket/src/HappyEyeBallsConnector.php b/vendor/react/socket/src/HappyEyeBallsConnector.php index 6158c3abab3..0ed0d4a50e5 100644 --- a/vendor/react/socket/src/HappyEyeBallsConnector.php +++ b/vendor/react/socket/src/HappyEyeBallsConnector.php @@ -6,12 +6,12 @@ use RectorPrefix20220607\React\Dns\Resolver\ResolverInterface; use RectorPrefix20220607\React\EventLoop\Loop; use RectorPrefix20220607\React\EventLoop\LoopInterface; use RectorPrefix20220607\React\Promise; -final class HappyEyeBallsConnector implements \RectorPrefix20220607\React\Socket\ConnectorInterface +final class HappyEyeBallsConnector implements ConnectorInterface { private $loop; private $connector; private $resolver; - public function __construct(\RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null, \RectorPrefix20220607\React\Socket\ConnectorInterface $connector = null, \RectorPrefix20220607\React\Dns\Resolver\ResolverInterface $resolver = null) + public function __construct(LoopInterface $loop = null, ConnectorInterface $connector = null, ResolverInterface $resolver = null) { // $connector and $resolver arguments are actually required, marked // optional for technical reasons only. Nullable $loop without default @@ -21,7 +21,7 @@ final class HappyEyeBallsConnector implements \RectorPrefix20220607\React\Socket if ($connector === null || $resolver === null) { throw new \InvalidArgumentException('Missing required $connector or $resolver argument'); } - $this->loop = $loop ?: \RectorPrefix20220607\React\EventLoop\Loop::get(); + $this->loop = $loop ?: Loop::get(); $this->connector = $connector; $this->resolver = $resolver; } @@ -38,14 +38,14 @@ final class HappyEyeBallsConnector implements \RectorPrefix20220607\React\Socket $parts = \parse_url($uri); } if (!$parts || !isset($parts['host'])) { - return \RectorPrefix20220607\React\Promise\reject(new \InvalidArgumentException('Given URI "' . $original . '" is invalid (EINVAL)', \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22)); + return Promise\reject(new \InvalidArgumentException('Given URI "' . $original . '" is invalid (EINVAL)', \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22)); } $host = \trim($parts['host'], '[]'); // skip DNS lookup / URI manipulation if this URI already contains an IP if (@\inet_pton($host) !== \false) { return $this->connector->connect($original); } - $builder = new \RectorPrefix20220607\React\Socket\HappyEyeBallsConnectionBuilder($this->loop, $this->connector, $this->resolver, $uri, $host, $parts); + $builder = new HappyEyeBallsConnectionBuilder($this->loop, $this->connector, $this->resolver, $uri, $host, $parts); return $builder->connect(); } } diff --git a/vendor/react/socket/src/LimitingServer.php b/vendor/react/socket/src/LimitingServer.php index 0d9c6059a87..3d45765a8bb 100644 --- a/vendor/react/socket/src/LimitingServer.php +++ b/vendor/react/socket/src/LimitingServer.php @@ -32,7 +32,7 @@ use OverflowException; * @see ServerInterface * @see ConnectionInterface */ -class LimitingServer extends \RectorPrefix20220607\Evenement\EventEmitter implements \RectorPrefix20220607\React\Socket\ServerInterface +class LimitingServer extends EventEmitter implements ServerInterface { private $connections = array(); private $server; @@ -89,7 +89,7 @@ class LimitingServer extends \RectorPrefix20220607\Evenement\EventEmitter implem * @param int|null $connectionLimit * @param bool $pauseOnLimit */ - public function __construct(\RectorPrefix20220607\React\Socket\ServerInterface $server, $connectionLimit, $pauseOnLimit = \false) + public function __construct(ServerInterface $server, $connectionLimit, $pauseOnLimit = \false) { $this->server = $server; $this->limit = $connectionLimit; @@ -141,7 +141,7 @@ class LimitingServer extends \RectorPrefix20220607\Evenement\EventEmitter implem $this->server->close(); } /** @internal */ - public function handleConnection(\RectorPrefix20220607\React\Socket\ConnectionInterface $connection) + public function handleConnection(ConnectionInterface $connection) { // close connection if limit exceeded if ($this->limit !== null && \count($this->connections) >= $this->limit) { @@ -164,7 +164,7 @@ class LimitingServer extends \RectorPrefix20220607\Evenement\EventEmitter implem $this->emit('connection', array($connection)); } /** @internal */ - public function handleDisconnection(\RectorPrefix20220607\React\Socket\ConnectionInterface $connection) + public function handleDisconnection(ConnectionInterface $connection) { unset($this->connections[\array_search($connection, $this->connections)]); // continue accepting new connection if below limit diff --git a/vendor/react/socket/src/SecureConnector.php b/vendor/react/socket/src/SecureConnector.php index c64bd056757..05e2ffdccb5 100644 --- a/vendor/react/socket/src/SecureConnector.php +++ b/vendor/react/socket/src/SecureConnector.php @@ -8,21 +8,21 @@ use RectorPrefix20220607\React\Promise; use BadMethodCallException; use InvalidArgumentException; use UnexpectedValueException; -final class SecureConnector implements \RectorPrefix20220607\React\Socket\ConnectorInterface +final class SecureConnector implements ConnectorInterface { private $connector; private $streamEncryption; private $context; - public function __construct(\RectorPrefix20220607\React\Socket\ConnectorInterface $connector, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null, array $context = array()) + public function __construct(ConnectorInterface $connector, LoopInterface $loop = null, array $context = array()) { $this->connector = $connector; - $this->streamEncryption = new \RectorPrefix20220607\React\Socket\StreamEncryption($loop ?: \RectorPrefix20220607\React\EventLoop\Loop::get(), \false); + $this->streamEncryption = new StreamEncryption($loop ?: Loop::get(), \false); $this->context = $context; } public function connect($uri) { if (!\function_exists('stream_socket_enable_crypto')) { - return \RectorPrefix20220607\React\Promise\reject(new \BadMethodCallException('Encryption not supported on your platform (HHVM < 3.8?)')); + return Promise\reject(new \BadMethodCallException('Encryption not supported on your platform (HHVM < 3.8?)')); // @codeCoverageIgnore } if (\strpos($uri, '://') === \false) { @@ -30,15 +30,15 @@ final class SecureConnector implements \RectorPrefix20220607\React\Socket\Connec } $parts = \parse_url($uri); if (!$parts || !isset($parts['scheme']) || $parts['scheme'] !== 'tls') { - return \RectorPrefix20220607\React\Promise\reject(new \InvalidArgumentException('Given URI "' . $uri . '" is invalid (EINVAL)', \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22)); + return Promise\reject(new \InvalidArgumentException('Given URI "' . $uri . '" is invalid (EINVAL)', \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22)); } $context = $this->context; $encryption = $this->streamEncryption; $connected = \false; - $promise = $this->connector->connect(\str_replace('tls://', '', $uri))->then(function (\RectorPrefix20220607\React\Socket\ConnectionInterface $connection) use($context, $encryption, $uri, &$promise, &$connected) { + $promise = $this->connector->connect(\str_replace('tls://', '', $uri))->then(function (ConnectionInterface $connection) use($context, $encryption, $uri, &$promise, &$connected) { // (unencrypted) TCP/IP connection succeeded $connected = \true; - if (!$connection instanceof \RectorPrefix20220607\React\Socket\Connection) { + if (!$connection instanceof Connection) { $connection->close(); throw new \UnexpectedValueException('Base connector does not use internal Connection class exposing stream resource'); } diff --git a/vendor/react/socket/src/SecureServer.php b/vendor/react/socket/src/SecureServer.php index 7f5bc0fb880..188d7edfc4a 100644 --- a/vendor/react/socket/src/SecureServer.php +++ b/vendor/react/socket/src/SecureServer.php @@ -51,7 +51,7 @@ use UnexpectedValueException; * @see ServerInterface * @see ConnectionInterface */ -final class SecureServer extends \RectorPrefix20220607\Evenement\EventEmitter implements \RectorPrefix20220607\React\Socket\ServerInterface +final class SecureServer extends EventEmitter implements ServerInterface { private $tcp; private $encryption; @@ -120,7 +120,7 @@ final class SecureServer extends \RectorPrefix20220607\Evenement\EventEmitter im * @see TcpServer * @link https://www.php.net/manual/en/context.ssl.php for TLS context options */ - public function __construct(\RectorPrefix20220607\React\Socket\ServerInterface $tcp, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null, array $context = array()) + public function __construct(ServerInterface $tcp, LoopInterface $loop = null, array $context = array()) { if (!\function_exists('stream_socket_enable_crypto')) { throw new \BadMethodCallException('Encryption not supported on your platform (HHVM < 3.8?)'); @@ -129,7 +129,7 @@ final class SecureServer extends \RectorPrefix20220607\Evenement\EventEmitter im // default to empty passphrase to suppress blocking passphrase prompt $context += array('passphrase' => ''); $this->tcp = $tcp; - $this->encryption = new \RectorPrefix20220607\React\Socket\StreamEncryption($loop ?: \RectorPrefix20220607\React\EventLoop\Loop::get()); + $this->encryption = new StreamEncryption($loop ?: Loop::get()); $this->context = $context; $that = $this; $this->tcp->on('connection', function ($connection) use($that) { @@ -160,9 +160,9 @@ final class SecureServer extends \RectorPrefix20220607\Evenement\EventEmitter im return $this->tcp->close(); } /** @internal */ - public function handleConnection(\RectorPrefix20220607\React\Socket\ConnectionInterface $connection) + public function handleConnection(ConnectionInterface $connection) { - if (!$connection instanceof \RectorPrefix20220607\React\Socket\Connection) { + if (!$connection instanceof Connection) { $this->emit('error', array(new \UnexpectedValueException('Base server does not use internal Connection class exposing stream resource'))); $connection->close(); return; diff --git a/vendor/react/socket/src/Server.php b/vendor/react/socket/src/Server.php index 5766361cdb9..dc062247c9b 100644 --- a/vendor/react/socket/src/Server.php +++ b/vendor/react/socket/src/Server.php @@ -10,7 +10,7 @@ use Exception; * @deprecated 1.9.0 See `SocketServer` instead * @see SocketServer */ -final class Server extends \RectorPrefix20220607\Evenement\EventEmitter implements \RectorPrefix20220607\React\Socket\ServerInterface +final class Server extends EventEmitter implements ServerInterface { private $server; /** @@ -47,9 +47,9 @@ final class Server extends \RectorPrefix20220607\Evenement\EventEmitter implemen * @deprecated 1.9.0 See `SocketServer` instead * @see SocketServer */ - public function __construct($uri, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null, array $context = array()) + public function __construct($uri, LoopInterface $loop = null, array $context = array()) { - $loop = $loop ?: \RectorPrefix20220607\React\EventLoop\Loop::get(); + $loop = $loop ?: Loop::get(); // sanitize TCP context options if not properly wrapped if ($context && (!isset($context['tcp']) && !isset($context['tls']) && !isset($context['unix']))) { $context = array('tcp' => $context); @@ -62,19 +62,19 @@ final class Server extends \RectorPrefix20220607\Evenement\EventEmitter implemen $scheme = \substr($uri, 0, $pos); } if ($scheme === 'unix') { - $server = new \RectorPrefix20220607\React\Socket\UnixServer($uri, $loop, $context['unix']); + $server = new UnixServer($uri, $loop, $context['unix']); } else { - $server = new \RectorPrefix20220607\React\Socket\TcpServer(\str_replace('tls://', '', $uri), $loop, $context['tcp']); + $server = new TcpServer(\str_replace('tls://', '', $uri), $loop, $context['tcp']); if ($scheme === 'tls') { - $server = new \RectorPrefix20220607\React\Socket\SecureServer($server, $loop, $context['tls']); + $server = new SecureServer($server, $loop, $context['tls']); } } $this->server = $server; $that = $this; - $server->on('connection', function (\RectorPrefix20220607\React\Socket\ConnectionInterface $conn) use($that) { + $server->on('connection', function (ConnectionInterface $conn) use($that) { $that->emit('connection', array($conn)); }); - $server->on('error', function (\Exception $error) use($that) { + $server->on('error', function (Exception $error) use($that) { $that->emit('error', array($error)); }); } diff --git a/vendor/react/socket/src/ServerInterface.php b/vendor/react/socket/src/ServerInterface.php index b0c3841a86a..17b9d776617 100644 --- a/vendor/react/socket/src/ServerInterface.php +++ b/vendor/react/socket/src/ServerInterface.php @@ -45,7 +45,7 @@ use RectorPrefix20220607\Evenement\EventEmitterInterface; * * @see ConnectionInterface */ -interface ServerInterface extends \RectorPrefix20220607\Evenement\EventEmitterInterface +interface ServerInterface extends EventEmitterInterface { /** * Returns the full address (URI) this server is currently listening on diff --git a/vendor/react/socket/src/SocketServer.php b/vendor/react/socket/src/SocketServer.php index a0a19e26153..68dc6865948 100644 --- a/vendor/react/socket/src/SocketServer.php +++ b/vendor/react/socket/src/SocketServer.php @@ -4,7 +4,7 @@ namespace RectorPrefix20220607\React\Socket; use RectorPrefix20220607\Evenement\EventEmitter; use RectorPrefix20220607\React\EventLoop\LoopInterface; -final class SocketServer extends \RectorPrefix20220607\Evenement\EventEmitter implements \RectorPrefix20220607\React\Socket\ServerInterface +final class SocketServer extends EventEmitter implements ServerInterface { private $server; /** @@ -29,7 +29,7 @@ final class SocketServer extends \RectorPrefix20220607\Evenement\EventEmitter im * @throws \InvalidArgumentException if the listening address is invalid * @throws \RuntimeException if listening on this address fails (already in use etc.) */ - public function __construct($uri, array $context = array(), \RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null) + public function __construct($uri, array $context = array(), LoopInterface $loop = null) { // apply default options if not explicitly given $context += array('tcp' => array(), 'tls' => array(), 'unix' => array()); @@ -39,21 +39,21 @@ final class SocketServer extends \RectorPrefix20220607\Evenement\EventEmitter im $scheme = \substr($uri, 0, $pos); } if ($scheme === 'unix') { - $server = new \RectorPrefix20220607\React\Socket\UnixServer($uri, $loop, $context['unix']); + $server = new UnixServer($uri, $loop, $context['unix']); } elseif ($scheme === 'php') { - $server = new \RectorPrefix20220607\React\Socket\FdServer($uri, $loop); + $server = new FdServer($uri, $loop); } else { if (\preg_match('#^(?:\\w+://)?\\d+$#', $uri)) { throw new \InvalidArgumentException('Invalid URI given (EINVAL)', \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22); } - $server = new \RectorPrefix20220607\React\Socket\TcpServer(\str_replace('tls://', '', $uri), $loop, $context['tcp']); + $server = new TcpServer(\str_replace('tls://', '', $uri), $loop, $context['tcp']); if ($scheme === 'tls') { - $server = new \RectorPrefix20220607\React\Socket\SecureServer($server, $loop, $context['tls']); + $server = new SecureServer($server, $loop, $context['tls']); } } $this->server = $server; $that = $this; - $server->on('connection', function (\RectorPrefix20220607\React\Socket\ConnectionInterface $conn) use($that) { + $server->on('connection', function (ConnectionInterface $conn) use($that) { $that->emit('connection', array($conn)); }); $server->on('error', function (\Exception $error) use($that) { diff --git a/vendor/react/socket/src/StreamEncryption.php b/vendor/react/socket/src/StreamEncryption.php index db2e97e3c5a..75ea121e67e 100644 --- a/vendor/react/socket/src/StreamEncryption.php +++ b/vendor/react/socket/src/StreamEncryption.php @@ -17,7 +17,7 @@ class StreamEncryption private $loop; private $method; private $server; - public function __construct(\RectorPrefix20220607\React\EventLoop\LoopInterface $loop, $server = \true) + public function __construct(LoopInterface $loop, $server = \true) { $this->loop = $loop; $this->server = $server; @@ -40,17 +40,17 @@ class StreamEncryption } } } - public function enable(\RectorPrefix20220607\React\Socket\Connection $stream) + public function enable(Connection $stream) { return $this->toggle($stream, \true); } - public function toggle(\RectorPrefix20220607\React\Socket\Connection $stream, $toggle) + public function toggle(Connection $stream, $toggle) { // pause actual stream instance to continue operation on raw stream socket $stream->pause(); // TODO: add write() event to make sure we're not sending any excessive data // cancelling this leaves this stream in an inconsistent state… - $deferred = new \RectorPrefix20220607\React\Promise\Deferred(function () { + $deferred = new Deferred(function () { throw new \RuntimeException(); }); // get actual stream socket from stream instance @@ -81,7 +81,7 @@ class StreamEncryption throw $error; }); } - public function toggleCrypto($socket, \RectorPrefix20220607\React\Promise\Deferred $deferred, $toggle, $method) + public function toggleCrypto($socket, Deferred $deferred, $toggle, $method) { $error = null; \set_error_handler(function ($_, $errstr) use(&$error) { diff --git a/vendor/react/socket/src/TcpConnector.php b/vendor/react/socket/src/TcpConnector.php index 5af44080530..ae9efa04435 100644 --- a/vendor/react/socket/src/TcpConnector.php +++ b/vendor/react/socket/src/TcpConnector.php @@ -7,13 +7,13 @@ use RectorPrefix20220607\React\EventLoop\LoopInterface; use RectorPrefix20220607\React\Promise; use InvalidArgumentException; use RuntimeException; -final class TcpConnector implements \RectorPrefix20220607\React\Socket\ConnectorInterface +final class TcpConnector implements ConnectorInterface { private $loop; private $context; - public function __construct(\RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null, array $context = array()) + public function __construct(LoopInterface $loop = null, array $context = array()) { - $this->loop = $loop ?: \RectorPrefix20220607\React\EventLoop\Loop::get(); + $this->loop = $loop ?: Loop::get(); $this->context = $context; } public function connect($uri) @@ -23,11 +23,11 @@ final class TcpConnector implements \RectorPrefix20220607\React\Socket\Connector } $parts = \parse_url($uri); if (!$parts || !isset($parts['scheme'], $parts['host'], $parts['port']) || $parts['scheme'] !== 'tcp') { - return \RectorPrefix20220607\React\Promise\reject(new \InvalidArgumentException('Given URI "' . $uri . '" is invalid (EINVAL)', \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22)); + return Promise\reject(new \InvalidArgumentException('Given URI "' . $uri . '" is invalid (EINVAL)', \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22)); } $ip = \trim($parts['host'], '[]'); if (@\inet_pton($ip) === \false) { - return \RectorPrefix20220607\React\Promise\reject(new \InvalidArgumentException('Given URI "' . $uri . '" does not contain a valid host IP (EINVAL)', \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22)); + return Promise\reject(new \InvalidArgumentException('Given URI "' . $uri . '" does not contain a valid host IP (EINVAL)', \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22)); } // use context given in constructor $context = array('socket' => $this->context); @@ -57,11 +57,11 @@ final class TcpConnector implements \RectorPrefix20220607\React\Socket\Connector $remote = 'tcp://' . $parts['host'] . ':' . $parts['port']; $stream = @\stream_socket_client($remote, $errno, $errstr, 0, \STREAM_CLIENT_CONNECT | \STREAM_CLIENT_ASYNC_CONNECT, \stream_context_create($context)); if (\false === $stream) { - return \RectorPrefix20220607\React\Promise\reject(new \RuntimeException('Connection to ' . $uri . ' failed: ' . $errstr . \RectorPrefix20220607\React\Socket\SocketServer::errconst($errno), $errno)); + return Promise\reject(new \RuntimeException('Connection to ' . $uri . ' failed: ' . $errstr . SocketServer::errconst($errno), $errno)); } // wait for connection $loop = $this->loop; - return new \RectorPrefix20220607\React\Promise\Promise(function ($resolve, $reject) use($loop, $stream, $uri) { + return new Promise\Promise(function ($resolve, $reject) use($loop, $stream, $uri) { $loop->addWriteStream($stream, function ($stream) use($loop, $resolve, $reject, $uri) { $loop->removeWriteStream($stream); // The following hack looks like the only way to @@ -91,9 +91,9 @@ final class TcpConnector implements \RectorPrefix20220607\React\Socket\Connector } // @codeCoverageIgnoreEnd \fclose($stream); - $reject(new \RuntimeException('Connection to ' . $uri . ' failed: ' . $errstr . \RectorPrefix20220607\React\Socket\SocketServer::errconst($errno), $errno)); + $reject(new \RuntimeException('Connection to ' . $uri . ' failed: ' . $errstr . SocketServer::errconst($errno), $errno)); } else { - $resolve(new \RectorPrefix20220607\React\Socket\Connection($stream, $loop)); + $resolve(new Connection($stream, $loop)); } }); }, function () use($loop, $stream, $uri) { diff --git a/vendor/react/socket/src/TcpServer.php b/vendor/react/socket/src/TcpServer.php index 7704d80fd80..b49b595437c 100644 --- a/vendor/react/socket/src/TcpServer.php +++ b/vendor/react/socket/src/TcpServer.php @@ -31,7 +31,7 @@ use RuntimeException; * @see ServerInterface * @see ConnectionInterface */ -final class TcpServer extends \RectorPrefix20220607\Evenement\EventEmitter implements \RectorPrefix20220607\React\Socket\ServerInterface +final class TcpServer extends EventEmitter implements ServerInterface { private $master; private $loop; @@ -126,9 +126,9 @@ final class TcpServer extends \RectorPrefix20220607\Evenement\EventEmitter imple * @throws InvalidArgumentException if the listening address is invalid * @throws RuntimeException if listening on this address fails (already in use etc.) */ - public function __construct($uri, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null, array $context = array()) + public function __construct($uri, LoopInterface $loop = null, array $context = array()) { - $this->loop = $loop ?: \RectorPrefix20220607\React\EventLoop\Loop::get(); + $this->loop = $loop ?: Loop::get(); // a single port has been given => assume localhost if ((string) (int) $uri === (string) $uri) { $uri = '127.0.0.1:' . $uri; @@ -158,9 +158,9 @@ final class TcpServer extends \RectorPrefix20220607\Evenement\EventEmitter imple if ($errno === 0) { // PHP does not seem to report errno, so match errno from errstr // @link https://3v4l.org/3qOBl - $errno = \RectorPrefix20220607\React\Socket\SocketServer::errno($errstr); + $errno = SocketServer::errno($errstr); } - throw new \RuntimeException('Failed to listen on "' . $uri . '": ' . $errstr . \RectorPrefix20220607\React\Socket\SocketServer::errconst($errno), $errno); + throw new \RuntimeException('Failed to listen on "' . $uri . '": ' . $errstr . SocketServer::errconst($errno), $errno); } \stream_set_blocking($this->master, \false); $this->resume(); @@ -195,7 +195,7 @@ final class TcpServer extends \RectorPrefix20220607\Evenement\EventEmitter imple $that = $this; $this->loop->addReadStream($this->master, function ($master) use($that) { try { - $newSocket = \RectorPrefix20220607\React\Socket\SocketServer::accept($master); + $newSocket = SocketServer::accept($master); } catch (\RuntimeException $e) { $that->emit('error', array($e)); return; @@ -216,6 +216,6 @@ final class TcpServer extends \RectorPrefix20220607\Evenement\EventEmitter imple /** @internal */ public function handleConnection($socket) { - $this->emit('connection', array(new \RectorPrefix20220607\React\Socket\Connection($socket, $this->loop))); + $this->emit('connection', array(new Connection($socket, $this->loop))); } } diff --git a/vendor/react/socket/src/TimeoutConnector.php b/vendor/react/socket/src/TimeoutConnector.php index dfe34e08f45..492fd733ee1 100644 --- a/vendor/react/socket/src/TimeoutConnector.php +++ b/vendor/react/socket/src/TimeoutConnector.php @@ -6,20 +6,20 @@ use RectorPrefix20220607\React\EventLoop\Loop; use RectorPrefix20220607\React\EventLoop\LoopInterface; use RectorPrefix20220607\React\Promise\Timer; use RectorPrefix20220607\React\Promise\Timer\TimeoutException; -final class TimeoutConnector implements \RectorPrefix20220607\React\Socket\ConnectorInterface +final class TimeoutConnector implements ConnectorInterface { private $connector; private $timeout; private $loop; - public function __construct(\RectorPrefix20220607\React\Socket\ConnectorInterface $connector, $timeout, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null) + public function __construct(ConnectorInterface $connector, $timeout, LoopInterface $loop = null) { $this->connector = $connector; $this->timeout = $timeout; - $this->loop = $loop ?: \RectorPrefix20220607\React\EventLoop\Loop::get(); + $this->loop = $loop ?: Loop::get(); } public function connect($uri) { - return \RectorPrefix20220607\React\Promise\Timer\timeout($this->connector->connect($uri), $this->timeout, $this->loop)->then(null, self::handler($uri)); + return Timer\timeout($this->connector->connect($uri), $this->timeout, $this->loop)->then(null, self::handler($uri)); } /** * Creates a static rejection handler that reports a proper error message in case of a timeout. @@ -34,7 +34,7 @@ final class TimeoutConnector implements \RectorPrefix20220607\React\Socket\Conne private static function handler($uri) { return function (\Exception $e) use($uri) { - if ($e instanceof \RectorPrefix20220607\React\Promise\Timer\TimeoutException) { + if ($e instanceof TimeoutException) { throw new \RuntimeException('Connection to ' . $uri . ' timed out after ' . $e->getTimeout() . ' seconds (ETIMEDOUT)', \defined('SOCKET_ETIMEDOUT') ? \SOCKET_ETIMEDOUT : 110); } throw $e; diff --git a/vendor/react/socket/src/UnixConnector.php b/vendor/react/socket/src/UnixConnector.php index 5727a4a62d6..bf45790806b 100644 --- a/vendor/react/socket/src/UnixConnector.php +++ b/vendor/react/socket/src/UnixConnector.php @@ -13,26 +13,26 @@ use RuntimeException; * Unix domain sockets use atomic operations, so we can as well emulate * async behavior. */ -final class UnixConnector implements \RectorPrefix20220607\React\Socket\ConnectorInterface +final class UnixConnector implements ConnectorInterface { private $loop; - public function __construct(\RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null) + public function __construct(LoopInterface $loop = null) { - $this->loop = $loop ?: \RectorPrefix20220607\React\EventLoop\Loop::get(); + $this->loop = $loop ?: Loop::get(); } public function connect($path) { if (\strpos($path, '://') === \false) { $path = 'unix://' . $path; } elseif (\substr($path, 0, 7) !== 'unix://') { - return \RectorPrefix20220607\React\Promise\reject(new \InvalidArgumentException('Given URI "' . $path . '" is invalid (EINVAL)', \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22)); + return Promise\reject(new \InvalidArgumentException('Given URI "' . $path . '" is invalid (EINVAL)', \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22)); } $resource = @\stream_socket_client($path, $errno, $errstr, 1.0); if (!$resource) { - return \RectorPrefix20220607\React\Promise\reject(new \RuntimeException('Unable to connect to unix domain socket "' . $path . '": ' . $errstr . \RectorPrefix20220607\React\Socket\SocketServer::errconst($errno), $errno)); + return Promise\reject(new \RuntimeException('Unable to connect to unix domain socket "' . $path . '": ' . $errstr . SocketServer::errconst($errno), $errno)); } - $connection = new \RectorPrefix20220607\React\Socket\Connection($resource, $this->loop); + $connection = new Connection($resource, $this->loop); $connection->unix = \true; - return \RectorPrefix20220607\React\Promise\resolve($connection); + return Promise\resolve($connection); } } diff --git a/vendor/react/socket/src/UnixServer.php b/vendor/react/socket/src/UnixServer.php index e14fff1da77..4c64c35058d 100644 --- a/vendor/react/socket/src/UnixServer.php +++ b/vendor/react/socket/src/UnixServer.php @@ -20,7 +20,7 @@ use RuntimeException; * @see ServerInterface * @see ConnectionInterface */ -final class UnixServer extends \RectorPrefix20220607\Evenement\EventEmitter implements \RectorPrefix20220607\React\Socket\ServerInterface +final class UnixServer extends EventEmitter implements ServerInterface { private $master; private $loop; @@ -48,9 +48,9 @@ final class UnixServer extends \RectorPrefix20220607\Evenement\EventEmitter impl * @throws InvalidArgumentException if the listening address is invalid * @throws RuntimeException if listening on this address fails (already in use etc.) */ - public function __construct($path, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null, array $context = array()) + public function __construct($path, LoopInterface $loop = null, array $context = array()) { - $this->loop = $loop ?: \RectorPrefix20220607\React\EventLoop\Loop::get(); + $this->loop = $loop ?: Loop::get(); if (\strpos($path, '://') === \false) { $path = 'unix://' . $path; } elseif (\substr($path, 0, 7) !== 'unix://') { @@ -68,7 +68,7 @@ final class UnixServer extends \RectorPrefix20220607\Evenement\EventEmitter impl $errno = isset($match[2]) ? (int) $match[2] : 0; } } - throw new \RuntimeException('Failed to listen on Unix domain socket "' . $path . '": ' . $errstr . \RectorPrefix20220607\React\Socket\SocketServer::errconst($errno), $errno); + throw new \RuntimeException('Failed to listen on Unix domain socket "' . $path . '": ' . $errstr . SocketServer::errconst($errno), $errno); } \stream_set_blocking($this->master, 0); $this->resume(); @@ -96,7 +96,7 @@ final class UnixServer extends \RectorPrefix20220607\Evenement\EventEmitter impl $that = $this; $this->loop->addReadStream($this->master, function ($master) use($that) { try { - $newSocket = \RectorPrefix20220607\React\Socket\SocketServer::accept($master); + $newSocket = SocketServer::accept($master); } catch (\RuntimeException $e) { $that->emit('error', array($e)); return; @@ -117,7 +117,7 @@ final class UnixServer extends \RectorPrefix20220607\Evenement\EventEmitter impl /** @internal */ public function handleConnection($socket) { - $connection = new \RectorPrefix20220607\React\Socket\Connection($socket, $this->loop); + $connection = new Connection($socket, $this->loop); $connection->unix = \true; $this->emit('connection', array($connection)); } diff --git a/vendor/react/stream/src/CompositeStream.php b/vendor/react/stream/src/CompositeStream.php index 193409667c7..6e3142348d2 100644 --- a/vendor/react/stream/src/CompositeStream.php +++ b/vendor/react/stream/src/CompositeStream.php @@ -3,12 +3,12 @@ namespace RectorPrefix20220607\React\Stream; use RectorPrefix20220607\Evenement\EventEmitter; -final class CompositeStream extends \RectorPrefix20220607\Evenement\EventEmitter implements \RectorPrefix20220607\React\Stream\DuplexStreamInterface +final class CompositeStream extends EventEmitter implements DuplexStreamInterface { private $readable; private $writable; private $closed = \false; - public function __construct(\RectorPrefix20220607\React\Stream\ReadableStreamInterface $readable, \RectorPrefix20220607\React\Stream\WritableStreamInterface $writable) + public function __construct(ReadableStreamInterface $readable, WritableStreamInterface $writable) { $this->readable = $readable; $this->writable = $writable; @@ -16,8 +16,8 @@ final class CompositeStream extends \RectorPrefix20220607\Evenement\EventEmitter $this->close(); return; } - \RectorPrefix20220607\React\Stream\Util::forwardEvents($this->readable, $this, array('data', 'end', 'error')); - \RectorPrefix20220607\React\Stream\Util::forwardEvents($this->writable, $this, array('drain', 'error', 'pipe')); + Util::forwardEvents($this->readable, $this, array('data', 'end', 'error')); + Util::forwardEvents($this->writable, $this, array('drain', 'error', 'pipe')); $this->readable->on('close', array($this, 'close')); $this->writable->on('close', array($this, 'close')); } @@ -36,9 +36,9 @@ final class CompositeStream extends \RectorPrefix20220607\Evenement\EventEmitter } $this->readable->resume(); } - public function pipe(\RectorPrefix20220607\React\Stream\WritableStreamInterface $dest, array $options = array()) + public function pipe(WritableStreamInterface $dest, array $options = array()) { - return \RectorPrefix20220607\React\Stream\Util::pipe($this, $dest, $options); + return Util::pipe($this, $dest, $options); } public function isWritable() { diff --git a/vendor/react/stream/src/DuplexResourceStream.php b/vendor/react/stream/src/DuplexResourceStream.php index c40f690e5c2..ec7881dc8d1 100644 --- a/vendor/react/stream/src/DuplexResourceStream.php +++ b/vendor/react/stream/src/DuplexResourceStream.php @@ -6,7 +6,7 @@ use RectorPrefix20220607\Evenement\EventEmitter; use RectorPrefix20220607\React\EventLoop\Loop; use RectorPrefix20220607\React\EventLoop\LoopInterface; use InvalidArgumentException; -final class DuplexResourceStream extends \RectorPrefix20220607\Evenement\EventEmitter implements \RectorPrefix20220607\React\Stream\DuplexStreamInterface +final class DuplexResourceStream extends EventEmitter implements DuplexStreamInterface { private $stream; /** @var LoopInterface */ @@ -33,15 +33,15 @@ final class DuplexResourceStream extends \RectorPrefix20220607\Evenement\EventEm private $writable = \true; private $closing = \false; private $listening = \false; - public function __construct($stream, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null, $readChunkSize = null, \RectorPrefix20220607\React\Stream\WritableStreamInterface $buffer = null) + public function __construct($stream, LoopInterface $loop = null, $readChunkSize = null, WritableStreamInterface $buffer = null) { if (!\is_resource($stream) || \get_resource_type($stream) !== "stream") { - throw new \InvalidArgumentException('First parameter must be a valid stream resource'); + throw new InvalidArgumentException('First parameter must be a valid stream resource'); } // ensure resource is opened for reading and wrting (fopen mode must contain "+") $meta = \stream_get_meta_data($stream); if (isset($meta['mode']) && $meta['mode'] !== '' && \strpos($meta['mode'], '+') === \false) { - throw new \InvalidArgumentException('Given stream resource is not opened in read and write mode'); + throw new InvalidArgumentException('Given stream resource is not opened in read and write mode'); } // this class relies on non-blocking I/O in order to not interrupt the event loop // e.g. pipes on Windows do not support this: https://bugs.php.net/bug.php?id=47918 @@ -60,10 +60,10 @@ final class DuplexResourceStream extends \RectorPrefix20220607\Evenement\EventEm \stream_set_read_buffer($stream, 0); } if ($buffer === null) { - $buffer = new \RectorPrefix20220607\React\Stream\WritableResourceStream($stream, $loop); + $buffer = new WritableResourceStream($stream, $loop); } $this->stream = $stream; - $this->loop = $loop ?: \RectorPrefix20220607\React\EventLoop\Loop::get(); + $this->loop = $loop ?: Loop::get(); $this->bufferSize = $readChunkSize === null ? 65536 : (int) $readChunkSize; $this->buffer = $buffer; $that = $this; @@ -132,9 +132,9 @@ final class DuplexResourceStream extends \RectorPrefix20220607\Evenement\EventEm $this->pause(); $this->buffer->end($data); } - public function pipe(\RectorPrefix20220607\React\Stream\WritableStreamInterface $dest, array $options = array()) + public function pipe(WritableStreamInterface $dest, array $options = array()) { - return \RectorPrefix20220607\React\Stream\Util::pipe($this, $dest, $options); + return Util::pipe($this, $dest, $options); } /** @internal */ public function handleData($stream) diff --git a/vendor/react/stream/src/DuplexStreamInterface.php b/vendor/react/stream/src/DuplexStreamInterface.php index 4782988747f..95fc9183162 100644 --- a/vendor/react/stream/src/DuplexStreamInterface.php +++ b/vendor/react/stream/src/DuplexStreamInterface.php @@ -34,6 +34,6 @@ namespace RectorPrefix20220607\React\Stream; * @see ReadableStreamInterface * @see WritableStreamInterface */ -interface DuplexStreamInterface extends \RectorPrefix20220607\React\Stream\ReadableStreamInterface, \RectorPrefix20220607\React\Stream\WritableStreamInterface +interface DuplexStreamInterface extends ReadableStreamInterface, WritableStreamInterface { } diff --git a/vendor/react/stream/src/ReadableResourceStream.php b/vendor/react/stream/src/ReadableResourceStream.php index ea5c03b180f..fe706fc9581 100644 --- a/vendor/react/stream/src/ReadableResourceStream.php +++ b/vendor/react/stream/src/ReadableResourceStream.php @@ -6,7 +6,7 @@ use RectorPrefix20220607\Evenement\EventEmitter; use RectorPrefix20220607\React\EventLoop\Loop; use RectorPrefix20220607\React\EventLoop\LoopInterface; use InvalidArgumentException; -final class ReadableResourceStream extends \RectorPrefix20220607\Evenement\EventEmitter implements \RectorPrefix20220607\React\Stream\ReadableStreamInterface +final class ReadableResourceStream extends EventEmitter implements ReadableStreamInterface { /** * @var resource @@ -35,15 +35,15 @@ final class ReadableResourceStream extends \RectorPrefix20220607\Evenement\Event private $bufferSize; private $closed = \false; private $listening = \false; - public function __construct($stream, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null, $readChunkSize = null) + public function __construct($stream, LoopInterface $loop = null, $readChunkSize = null) { if (!\is_resource($stream) || \get_resource_type($stream) !== "stream") { - throw new \InvalidArgumentException('First parameter must be a valid stream resource'); + throw new InvalidArgumentException('First parameter must be a valid stream resource'); } // ensure resource is opened for reading (fopen mode must contain "r" or "+") $meta = \stream_get_meta_data($stream); if (isset($meta['mode']) && $meta['mode'] !== '' && \strpos($meta['mode'], 'r') === \strpos($meta['mode'], '+')) { - throw new \InvalidArgumentException('Given stream resource is not opened in read mode'); + throw new InvalidArgumentException('Given stream resource is not opened in read mode'); } // this class relies on non-blocking I/O in order to not interrupt the event loop // e.g. pipes on Windows do not support this: https://bugs.php.net/bug.php?id=47918 @@ -62,7 +62,7 @@ final class ReadableResourceStream extends \RectorPrefix20220607\Evenement\Event \stream_set_read_buffer($stream, 0); } $this->stream = $stream; - $this->loop = $loop ?: \RectorPrefix20220607\React\EventLoop\Loop::get(); + $this->loop = $loop ?: Loop::get(); $this->bufferSize = $readChunkSize === null ? 65536 : (int) $readChunkSize; $this->resume(); } @@ -84,9 +84,9 @@ final class ReadableResourceStream extends \RectorPrefix20220607\Evenement\Event $this->listening = \true; } } - public function pipe(\RectorPrefix20220607\React\Stream\WritableStreamInterface $dest, array $options = array()) + public function pipe(WritableStreamInterface $dest, array $options = array()) { - return \RectorPrefix20220607\React\Stream\Util::pipe($this, $dest, $options); + return Util::pipe($this, $dest, $options); } public function close() { diff --git a/vendor/react/stream/src/ReadableStreamInterface.php b/vendor/react/stream/src/ReadableStreamInterface.php index 1bf5ac5a5c0..75afa08bb93 100644 --- a/vendor/react/stream/src/ReadableStreamInterface.php +++ b/vendor/react/stream/src/ReadableStreamInterface.php @@ -161,7 +161,7 @@ use RectorPrefix20220607\Evenement\EventEmitterInterface; * * @see EventEmitterInterface */ -interface ReadableStreamInterface extends \RectorPrefix20220607\Evenement\EventEmitterInterface +interface ReadableStreamInterface extends EventEmitterInterface { /** * Checks whether this stream is in a readable state (not closed already). @@ -318,7 +318,7 @@ interface ReadableStreamInterface extends \RectorPrefix20220607\Evenement\EventE * @param array $options * @return WritableStreamInterface $dest stream as-is */ - public function pipe(\RectorPrefix20220607\React\Stream\WritableStreamInterface $dest, array $options = array()); + public function pipe(WritableStreamInterface $dest, array $options = array()); /** * Closes the stream (forcefully). * diff --git a/vendor/react/stream/src/ThroughStream.php b/vendor/react/stream/src/ThroughStream.php index 696f37a8ddf..04f80f569a5 100644 --- a/vendor/react/stream/src/ThroughStream.php +++ b/vendor/react/stream/src/ThroughStream.php @@ -72,7 +72,7 @@ use InvalidArgumentException; * @see DuplexStreamInterface::close() * @see WritableStreamInterface::pipe() */ -final class ThroughStream extends \RectorPrefix20220607\Evenement\EventEmitter implements \RectorPrefix20220607\React\Stream\DuplexStreamInterface +final class ThroughStream extends EventEmitter implements DuplexStreamInterface { private $readable = \true; private $writable = \true; @@ -83,7 +83,7 @@ final class ThroughStream extends \RectorPrefix20220607\Evenement\EventEmitter i public function __construct($callback = null) { if ($callback !== null && !\is_callable($callback)) { - throw new \InvalidArgumentException('Invalid transformation callback given'); + throw new InvalidArgumentException('Invalid transformation callback given'); } $this->callback = $callback; } @@ -99,9 +99,9 @@ final class ThroughStream extends \RectorPrefix20220607\Evenement\EventEmitter i } $this->paused = \false; } - public function pipe(\RectorPrefix20220607\React\Stream\WritableStreamInterface $dest, array $options = array()) + public function pipe(WritableStreamInterface $dest, array $options = array()) { - return \RectorPrefix20220607\React\Stream\Util::pipe($this, $dest, $options); + return Util::pipe($this, $dest, $options); } public function isReadable() { diff --git a/vendor/react/stream/src/Util.php b/vendor/react/stream/src/Util.php index b412ce8b628..8bce1d969df 100644 --- a/vendor/react/stream/src/Util.php +++ b/vendor/react/stream/src/Util.php @@ -13,7 +13,7 @@ final class Util * @return WritableStreamInterface $dest stream as-is * @see ReadableStreamInterface::pipe() for more details */ - public static function pipe(\RectorPrefix20220607\React\Stream\ReadableStreamInterface $source, \RectorPrefix20220607\React\Stream\WritableStreamInterface $dest, array $options = array()) + public static function pipe(ReadableStreamInterface $source, WritableStreamInterface $dest, array $options = array()) { // source not readable => NO-OP if (!$source->isReadable()) { diff --git a/vendor/react/stream/src/WritableResourceStream.php b/vendor/react/stream/src/WritableResourceStream.php index fa7b854be93..c6b01f7d54a 100644 --- a/vendor/react/stream/src/WritableResourceStream.php +++ b/vendor/react/stream/src/WritableResourceStream.php @@ -5,7 +5,7 @@ namespace RectorPrefix20220607\React\Stream; use RectorPrefix20220607\Evenement\EventEmitter; use RectorPrefix20220607\React\EventLoop\Loop; use RectorPrefix20220607\React\EventLoop\LoopInterface; -final class WritableResourceStream extends \RectorPrefix20220607\Evenement\EventEmitter implements \RectorPrefix20220607\React\Stream\WritableStreamInterface +final class WritableResourceStream extends EventEmitter implements WritableStreamInterface { private $stream; /** @var LoopInterface */ @@ -22,7 +22,7 @@ final class WritableResourceStream extends \RectorPrefix20220607\Evenement\Event private $writable = \true; private $closed = \false; private $data = ''; - public function __construct($stream, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop = null, $writeBufferSoftLimit = null, $writeChunkSize = null) + public function __construct($stream, LoopInterface $loop = null, $writeBufferSoftLimit = null, $writeChunkSize = null) { if (!\is_resource($stream) || \get_resource_type($stream) !== "stream") { throw new \InvalidArgumentException('First parameter must be a valid stream resource'); @@ -38,7 +38,7 @@ final class WritableResourceStream extends \RectorPrefix20220607\Evenement\Event throw new \RuntimeException('Unable to set stream resource to non-blocking mode'); } $this->stream = $stream; - $this->loop = $loop ?: \RectorPrefix20220607\React\EventLoop\Loop::get(); + $this->loop = $loop ?: Loop::get(); $this->softLimit = $writeBufferSoftLimit === null ? 65536 : (int) $writeBufferSoftLimit; $this->writeChunkSize = $writeChunkSize === null ? -1 : (int) $writeChunkSize; } diff --git a/vendor/react/stream/src/WritableStreamInterface.php b/vendor/react/stream/src/WritableStreamInterface.php index 1b89e0b3b89..b6ed1a19cde 100644 --- a/vendor/react/stream/src/WritableStreamInterface.php +++ b/vendor/react/stream/src/WritableStreamInterface.php @@ -138,7 +138,7 @@ use RectorPrefix20220607\Evenement\EventEmitterInterface; * @see EventEmitterInterface * @see DuplexStreamInterface */ -interface WritableStreamInterface extends \RectorPrefix20220607\Evenement\EventEmitterInterface +interface WritableStreamInterface extends EventEmitterInterface { /** * Checks whether this stream is in a writable state (not closed already). diff --git a/vendor/rector/extension-installer/rector.php b/vendor/rector/extension-installer/rector.php index 0df665a42f1..d574b20230d 100644 --- a/vendor/rector/extension-installer/rector.php +++ b/vendor/rector/extension-installer/rector.php @@ -5,9 +5,9 @@ namespace RectorPrefix20220607; use Rector\Php74\Rector\Property\TypedPropertyRector; use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +return static function (ContainerConfigurator $containerConfigurator) : void { $services = $containerConfigurator->services(); - $services->set(\Rector\Php74\Rector\Property\TypedPropertyRector::class); - $services->set(\Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector::class); + $services->set(TypedPropertyRector::class); + $services->set(ClassPropertyAssignToConstructorPromotionRector::class); }; diff --git a/vendor/rector/extension-installer/src/LocalFilesystem.php b/vendor/rector/extension-installer/src/LocalFilesystem.php index 3e08cda20be..1badd6c1d4e 100644 --- a/vendor/rector/extension-installer/src/LocalFilesystem.php +++ b/vendor/rector/extension-installer/src/LocalFilesystem.php @@ -14,7 +14,7 @@ final class LocalFilesystem implements \Rector\RectorInstaller\Filesystem { $fileHash = \md5_file($pathToFile); if ($fileHash === \false) { - throw new \UnexpectedValueException(\sprintf('Could not hash file %s', $pathToFile)); + throw new UnexpectedValueException(\sprintf('Could not hash file %s', $pathToFile)); } return $fileHash; } @@ -22,7 +22,7 @@ final class LocalFilesystem implements \Rector\RectorInstaller\Filesystem { $bytes = \file_put_contents($pathToFile, $contents); if ($bytes === \false) { - throw new \UnexpectedValueException(\sprintf('Could not write contents to file %s', $pathToFile)); + throw new UnexpectedValueException(\sprintf('Could not write contents to file %s', $pathToFile)); } } public function hashEquals(string $hash, string $content) : bool diff --git a/vendor/rector/extension-installer/src/Plugin.php b/vendor/rector/extension-installer/src/Plugin.php index dc7c8c6083a..d40a0786fcb 100644 --- a/vendor/rector/extension-installer/src/Plugin.php +++ b/vendor/rector/extension-installer/src/Plugin.php @@ -9,18 +9,18 @@ use Composer\IO\IOInterface; use Composer\Plugin\PluginInterface; use Composer\Script\Event; use Composer\Script\ScriptEvents; -final class Plugin implements \Composer\Plugin\PluginInterface, \Composer\EventDispatcher\EventSubscriberInterface +final class Plugin implements PluginInterface, EventSubscriberInterface { - public function activate(\Composer\Composer $composer, \Composer\IO\IOInterface $io) : void + public function activate(Composer $composer, IOInterface $io) : void { } - public function deactivate(\Composer\Composer $composer, \Composer\IO\IOInterface $io) : void + public function deactivate(Composer $composer, IOInterface $io) : void { } - public function uninstall(\Composer\Composer $composer, \Composer\IO\IOInterface $io) : void + public function uninstall(Composer $composer, IOInterface $io) : void { } - public function process(\Composer\Script\Event $event) : void + public function process(Event $event) : void { $io = $event->getIO(); $composer = $event->getComposer(); @@ -36,6 +36,6 @@ final class Plugin implements \Composer\Plugin\PluginInterface, \Composer\EventD */ public static function getSubscribedEvents() : array { - return [\Composer\Script\ScriptEvents::POST_INSTALL_CMD => 'process', \Composer\Script\ScriptEvents::POST_UPDATE_CMD => 'process']; + return [ScriptEvents::POST_INSTALL_CMD => 'process', ScriptEvents::POST_UPDATE_CMD => 'process']; } } diff --git a/vendor/rector/extension-installer/src/PluginInstaller.php b/vendor/rector/extension-installer/src/PluginInstaller.php index 8bada6f4b06..a8351dbca48 100644 --- a/vendor/rector/extension-installer/src/PluginInstaller.php +++ b/vendor/rector/extension-installer/src/PluginInstaller.php @@ -69,7 +69,7 @@ CODE_SAMPLE; * @var string */ private $configurationFile; - public function __construct(\Rector\RectorInstaller\Filesystem $filesystem, \RectorPrefix20220607\Composer\Repository\InstalledRepositoryInterface $localRepository, \RectorPrefix20220607\Composer\IO\IOInterface $io, \RectorPrefix20220607\Composer\Installer\InstallationManager $installationManager, \RectorPrefix20220607\Composer\Util\Filesystem $composerFilesystem, string $configurationFile) + public function __construct(\Rector\RectorInstaller\Filesystem $filesystem, InstalledRepositoryInterface $localRepository, IOInterface $io, InstallationManager $installationManager, ComposerFilesystem $composerFilesystem, string $configurationFile) { $this->filesystem = $filesystem; $this->localRepository = $localRepository; @@ -106,7 +106,7 @@ CODE_SAMPLE; $this->io->write(\sprintf('> %s: installed', $name)); } } - private function shouldSkip(\RectorPrefix20220607\Composer\Package\PackageInterface $package) : bool + private function shouldSkip(PackageInterface $package) : bool { if ($package->getType() === self::RECTOR_EXTENSION_TYPE) { return \false; diff --git a/vendor/rector/rector-cakephp/config/config.php b/vendor/rector/rector-cakephp/config/config.php index daa9345f8c9..0ae4a748705 100644 --- a/vendor/rector/rector-cakephp/config/config.php +++ b/vendor/rector/rector-cakephp/config/config.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace RectorPrefix20220607; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $services = $rectorConfig->services(); $services->defaults()->public()->autowire()->autoconfigure(); $services->load('Rector\\CakePHP\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/{Rector,ValueObject,Contract}']); diff --git a/vendor/rector/rector-cakephp/config/sets/cakephp-fluent-options.php b/vendor/rector/rector-cakephp/config/sets/cakephp-fluent-options.php index 5c4a1e9e18a..cc90214e2d9 100644 --- a/vendor/rector/rector-cakephp/config/sets/cakephp-fluent-options.php +++ b/vendor/rector/rector-cakephp/config/sets/cakephp-fluent-options.php @@ -7,8 +7,8 @@ use Rector\CakePHP\Rector\MethodCall\ArrayToFluentCallRector; use Rector\CakePHP\ValueObject\ArrayToFluentCall; use Rector\CakePHP\ValueObject\FactoryMethod; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\CakePHP\Rector\MethodCall\ArrayToFluentCallRector::class, [\Rector\CakePHP\Rector\MethodCall\ArrayToFluentCallRector::ARRAYS_TO_FLUENT_CALLS => [new \Rector\CakePHP\ValueObject\ArrayToFluentCall('Cake\\ORM\\Association', [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(ArrayToFluentCallRector::class, [ArrayToFluentCallRector::ARRAYS_TO_FLUENT_CALLS => [new ArrayToFluentCall('Cake\\ORM\\Association', [ 'bindingKey' => 'setBindingKey', 'cascadeCallbacks' => 'setCascadeCallbacks', 'className' => 'setClassName', @@ -27,7 +27,7 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { # BelongsToMany only 'targetForeignKey' => 'setTargetForeignKey', 'through' => 'setThrough', - ]), new \Rector\CakePHP\ValueObject\ArrayToFluentCall('Cake\\ORM\\Query', ['fields' => 'select', 'conditions' => 'where', 'join' => 'join', 'order' => 'order', 'limit' => 'limit', 'offset' => 'offset', 'group' => 'group', 'having' => 'having', 'contain' => 'contain', 'page' => 'page']), new \Rector\CakePHP\ValueObject\ArrayToFluentCall('Cake\\ORM\\Association', [ + ]), new ArrayToFluentCall('Cake\\ORM\\Query', ['fields' => 'select', 'conditions' => 'where', 'join' => 'join', 'order' => 'order', 'limit' => 'limit', 'offset' => 'offset', 'group' => 'group', 'having' => 'having', 'contain' => 'contain', 'page' => 'page']), new ArrayToFluentCall('Cake\\ORM\\Association', [ 'bindingKey' => 'setBindingKey', 'cascadeCallbacks' => 'setCascadeCallbacks', 'className' => 'setClassName', @@ -46,5 +46,5 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { # BelongsToMany only 'targetForeignKey' => 'setTargetForeignKey', 'through' => 'setThrough', - ]), new \Rector\CakePHP\ValueObject\ArrayToFluentCall('Cake\\ORM\\Query', ['fields' => 'select', 'conditions' => 'where', 'join' => 'join', 'order' => 'order', 'limit' => 'limit', 'offset' => 'offset', 'group' => 'group', 'having' => 'having', 'contain' => 'contain', 'page' => 'page'])], \Rector\CakePHP\Rector\MethodCall\ArrayToFluentCallRector::FACTORY_METHODS => [new \Rector\CakePHP\ValueObject\FactoryMethod('Cake\\ORM\\Table', 'belongsTo', 'Cake\\ORM\\Association', 2), new \Rector\CakePHP\ValueObject\FactoryMethod('Cake\\ORM\\Table', 'belongsToMany', 'Cake\\ORM\\Association', 2), new \Rector\CakePHP\ValueObject\FactoryMethod('Cake\\ORM\\Table', 'hasMany', 'Cake\\ORM\\Association', 2), new \Rector\CakePHP\ValueObject\FactoryMethod('Cake\\ORM\\Table', 'hasOne', 'Cake\\ORM\\Association', 2), new \Rector\CakePHP\ValueObject\FactoryMethod('Cake\\ORM\\Table', 'find', 'Cake\\ORM\\Query', 2)]]); + ]), new ArrayToFluentCall('Cake\\ORM\\Query', ['fields' => 'select', 'conditions' => 'where', 'join' => 'join', 'order' => 'order', 'limit' => 'limit', 'offset' => 'offset', 'group' => 'group', 'having' => 'having', 'contain' => 'contain', 'page' => 'page'])], ArrayToFluentCallRector::FACTORY_METHODS => [new FactoryMethod('Cake\\ORM\\Table', 'belongsTo', 'Cake\\ORM\\Association', 2), new FactoryMethod('Cake\\ORM\\Table', 'belongsToMany', 'Cake\\ORM\\Association', 2), new FactoryMethod('Cake\\ORM\\Table', 'hasMany', 'Cake\\ORM\\Association', 2), new FactoryMethod('Cake\\ORM\\Table', 'hasOne', 'Cake\\ORM\\Association', 2), new FactoryMethod('Cake\\ORM\\Table', 'find', 'Cake\\ORM\\Query', 2)]]); }; diff --git a/vendor/rector/rector-cakephp/config/sets/cakephp30.php b/vendor/rector/rector-cakephp/config/sets/cakephp30.php index 047bb42d2e7..7da3893989b 100644 --- a/vendor/rector/rector-cakephp/config/sets/cakephp30.php +++ b/vendor/rector/rector-cakephp/config/sets/cakephp30.php @@ -6,10 +6,10 @@ namespace RectorPrefix20220607; use Rector\CakePHP\Rector\Namespace_\AppUsesStaticCallToUseStatementRector; use Rector\Config\RectorConfig; use Rector\Renaming\Rector\Name\RenameClassRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { # @see https://github.com/cakephp/upgrade/tree/master/src/Shell/Task - $rectorConfig->rule(\Rector\CakePHP\Rector\Namespace_\AppUsesStaticCallToUseStatementRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, [ + $rectorConfig->rule(AppUsesStaticCallToUseStatementRector::class); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ # see https://github.com/cakephp/upgrade/blob/756410c8b7d5aff9daec3fa1fe750a3858d422ac/src/Shell/Task/RenameClassesTask.php#L37 'Cake\\Network\\Http\\HttpSocket' => 'Cake\\Network\\Http\\Client', 'Cake\\Model\\ConnectionManager' => 'Cake\\Database\\ConnectionManager', diff --git a/vendor/rector/rector-cakephp/config/sets/cakephp34.php b/vendor/rector/rector-cakephp/config/sets/cakephp34.php index 2286cea539f..977d9408866 100644 --- a/vendor/rector/rector-cakephp/config/sets/cakephp34.php +++ b/vendor/rector/rector-cakephp/config/sets/cakephp34.php @@ -16,160 +16,160 @@ use Rector\Transform\Rector\Assign\PropertyFetchToMethodCallRector; use Rector\Transform\ValueObject\PropertyFetchToMethodCall; use Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector; use Rector\Visibility\ValueObject\ChangeMethodVisibility; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\Assign\PropertyFetchToMethodCallRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(PropertyFetchToMethodCallRector::class, [ // source: https://book.cakephp.org/3.0/en/appendices/3-4-migration-guide.html - new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\Network\\Request', 'params', 'getAttribute', null, ['params']), - new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\Network\\Request', 'data', 'getData'), - new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\Network\\Request', 'query', 'getQueryParams'), - new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\Network\\Request', 'cookies', 'getCookie'), - new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\Network\\Request', 'base', 'getAttribute', null, ['base']), - new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\Network\\Request', 'webroot', 'getAttribute', null, ['webroot']), - new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\Network\\Request', 'here', 'getAttribute', null, ['here']), + new PropertyFetchToMethodCall('Cake\\Network\\Request', 'params', 'getAttribute', null, ['params']), + new PropertyFetchToMethodCall('Cake\\Network\\Request', 'data', 'getData'), + new PropertyFetchToMethodCall('Cake\\Network\\Request', 'query', 'getQueryParams'), + new PropertyFetchToMethodCall('Cake\\Network\\Request', 'cookies', 'getCookie'), + new PropertyFetchToMethodCall('Cake\\Network\\Request', 'base', 'getAttribute', null, ['base']), + new PropertyFetchToMethodCall('Cake\\Network\\Request', 'webroot', 'getAttribute', null, ['webroot']), + new PropertyFetchToMethodCall('Cake\\Network\\Request', 'here', 'getAttribute', null, ['here']), ]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector::class, [new \Rector\Renaming\ValueObject\RenameProperty('Cake\\Network\\Request', '_session', 'session')]); - $rectorConfig->ruleWithConfiguration(\Rector\CakePHP\Rector\MethodCall\ModalToGetSetRector::class, [ - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Core\\InstanceConfigTrait', 'config', null, null, 2, 'array'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Core\\StaticConfigTrait', 'config', null, null, 2, 'array'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Console\\ConsoleOptionParser', 'command'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Console\\ConsoleOptionParser', 'description'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Console\\ConsoleOptionParser', 'epilog'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\Connection', 'driver'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\Connection', 'schemaCollection'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\Connection', 'useSavePoints', 'isSavePointsEnabled', 'enableSavePoints'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\Driver', 'autoQuoting', 'isAutoQuotingEnabled', 'enableAutoQuoting'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\Expression\\FunctionExpression', 'name'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\Expression\\QueryExpression', 'tieWith', 'getConjunction', 'setConjunction'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\Expression\\ValuesExpression', 'columns'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\Expression\\ValuesExpression', 'values'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\Expression\\ValuesExpression', 'query'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\Query', 'connection'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\Query', 'selectTypeMap'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\Query', 'bufferResults', 'isBufferedResultsEnabled', 'enableBufferedResults'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\Schema\\CachedCollection', 'cacheMetadata'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\Schema\\TableSchema', 'options'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\Schema\\TableSchema', 'temporary', 'isTemporary', 'setTemporary'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\TypeMap', 'defaults'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\TypeMap', 'types'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\TypeMapTrait', 'typeMap'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\TypeMapTrait', 'defaultTypes'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association', 'name'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association', 'cascadeCallbacks'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association', 'source'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association', 'target'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association', 'conditions'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association', 'bindingKey'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association', 'foreignKey'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association', 'dependent'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association', 'joinType'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association', 'property'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association', 'strategy'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association', 'finder'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association\\BelongsToMany', 'targetForeignKey'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association\\BelongsToMany', 'saveStrategy'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association\\BelongsToMany', 'conditions'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association\\HasMany', 'saveStrategy'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association\\HasMany', 'foreignKey'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association\\HasMany', 'sort'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association\\HasOne', 'foreignKey'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\EagerLoadable', 'config'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\EagerLoadable', 'canBeJoined', 'canBeJoined', 'setCanBeJoined'), + $rectorConfig->ruleWithConfiguration(RenamePropertyRector::class, [new RenameProperty('Cake\\Network\\Request', '_session', 'session')]); + $rectorConfig->ruleWithConfiguration(ModalToGetSetRector::class, [ + new ModalToGetSet('Cake\\Core\\InstanceConfigTrait', 'config', null, null, 2, 'array'), + new ModalToGetSet('Cake\\Core\\StaticConfigTrait', 'config', null, null, 2, 'array'), + new ModalToGetSet('Cake\\Console\\ConsoleOptionParser', 'command'), + new ModalToGetSet('Cake\\Console\\ConsoleOptionParser', 'description'), + new ModalToGetSet('Cake\\Console\\ConsoleOptionParser', 'epilog'), + new ModalToGetSet('Cake\\Database\\Connection', 'driver'), + new ModalToGetSet('Cake\\Database\\Connection', 'schemaCollection'), + new ModalToGetSet('Cake\\Database\\Connection', 'useSavePoints', 'isSavePointsEnabled', 'enableSavePoints'), + new ModalToGetSet('Cake\\Database\\Driver', 'autoQuoting', 'isAutoQuotingEnabled', 'enableAutoQuoting'), + new ModalToGetSet('Cake\\Database\\Expression\\FunctionExpression', 'name'), + new ModalToGetSet('Cake\\Database\\Expression\\QueryExpression', 'tieWith', 'getConjunction', 'setConjunction'), + new ModalToGetSet('Cake\\Database\\Expression\\ValuesExpression', 'columns'), + new ModalToGetSet('Cake\\Database\\Expression\\ValuesExpression', 'values'), + new ModalToGetSet('Cake\\Database\\Expression\\ValuesExpression', 'query'), + new ModalToGetSet('Cake\\Database\\Query', 'connection'), + new ModalToGetSet('Cake\\Database\\Query', 'selectTypeMap'), + new ModalToGetSet('Cake\\Database\\Query', 'bufferResults', 'isBufferedResultsEnabled', 'enableBufferedResults'), + new ModalToGetSet('Cake\\Database\\Schema\\CachedCollection', 'cacheMetadata'), + new ModalToGetSet('Cake\\Database\\Schema\\TableSchema', 'options'), + new ModalToGetSet('Cake\\Database\\Schema\\TableSchema', 'temporary', 'isTemporary', 'setTemporary'), + new ModalToGetSet('Cake\\Database\\TypeMap', 'defaults'), + new ModalToGetSet('Cake\\Database\\TypeMap', 'types'), + new ModalToGetSet('Cake\\Database\\TypeMapTrait', 'typeMap'), + new ModalToGetSet('Cake\\Database\\TypeMapTrait', 'defaultTypes'), + new ModalToGetSet('Cake\\ORM\\Association', 'name'), + new ModalToGetSet('Cake\\ORM\\Association', 'cascadeCallbacks'), + new ModalToGetSet('Cake\\ORM\\Association', 'source'), + new ModalToGetSet('Cake\\ORM\\Association', 'target'), + new ModalToGetSet('Cake\\ORM\\Association', 'conditions'), + new ModalToGetSet('Cake\\ORM\\Association', 'bindingKey'), + new ModalToGetSet('Cake\\ORM\\Association', 'foreignKey'), + new ModalToGetSet('Cake\\ORM\\Association', 'dependent'), + new ModalToGetSet('Cake\\ORM\\Association', 'joinType'), + new ModalToGetSet('Cake\\ORM\\Association', 'property'), + new ModalToGetSet('Cake\\ORM\\Association', 'strategy'), + new ModalToGetSet('Cake\\ORM\\Association', 'finder'), + new ModalToGetSet('Cake\\ORM\\Association\\BelongsToMany', 'targetForeignKey'), + new ModalToGetSet('Cake\\ORM\\Association\\BelongsToMany', 'saveStrategy'), + new ModalToGetSet('Cake\\ORM\\Association\\BelongsToMany', 'conditions'), + new ModalToGetSet('Cake\\ORM\\Association\\HasMany', 'saveStrategy'), + new ModalToGetSet('Cake\\ORM\\Association\\HasMany', 'foreignKey'), + new ModalToGetSet('Cake\\ORM\\Association\\HasMany', 'sort'), + new ModalToGetSet('Cake\\ORM\\Association\\HasOne', 'foreignKey'), + new ModalToGetSet('Cake\\ORM\\EagerLoadable', 'config'), + new ModalToGetSet('Cake\\ORM\\EagerLoadable', 'canBeJoined', 'canBeJoined', 'setCanBeJoined'), // note: will have to be called after setMatching() to keep the old behavior // ref: https://github.com/cakephp/cakephp/blob/4feee5463641e05c068b4d1d31dc5ee882b4240f/src/ORM/EagerLoader.php#L330 - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\EagerLoadable', 'matching'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\EagerLoadable', 'autoFields', 'isAutoFieldsEnabled', 'enableAutoFields'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Locator\\TableLocator', 'config'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Query', 'eagerLoader'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Query', 'hydrate', 'isHydrationEnabled', 'enableHydration'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Query', 'autoFields', 'isAutoFieldsEnabled', 'enableAutoFields'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Table', 'table'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Table', 'alias'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Table', 'registryAlias'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Table', 'connection'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Table', 'schema'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Table', 'primaryKey'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Table', 'displayField'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Table', 'entityClass'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'entityClass'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'from'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'sender'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'replyTo'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'readReceipt'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'returnPath'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'to'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'cc'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'bcc'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'charset'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'headerCharset'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'emailPattern'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'subject'), + new ModalToGetSet('Cake\\ORM\\EagerLoadable', 'matching'), + new ModalToGetSet('Cake\\ORM\\EagerLoadable', 'autoFields', 'isAutoFieldsEnabled', 'enableAutoFields'), + new ModalToGetSet('Cake\\ORM\\Locator\\TableLocator', 'config'), + new ModalToGetSet('Cake\\ORM\\Query', 'eagerLoader'), + new ModalToGetSet('Cake\\ORM\\Query', 'hydrate', 'isHydrationEnabled', 'enableHydration'), + new ModalToGetSet('Cake\\ORM\\Query', 'autoFields', 'isAutoFieldsEnabled', 'enableAutoFields'), + new ModalToGetSet('Cake\\ORM\\Table', 'table'), + new ModalToGetSet('Cake\\ORM\\Table', 'alias'), + new ModalToGetSet('Cake\\ORM\\Table', 'registryAlias'), + new ModalToGetSet('Cake\\ORM\\Table', 'connection'), + new ModalToGetSet('Cake\\ORM\\Table', 'schema'), + new ModalToGetSet('Cake\\ORM\\Table', 'primaryKey'), + new ModalToGetSet('Cake\\ORM\\Table', 'displayField'), + new ModalToGetSet('Cake\\ORM\\Table', 'entityClass'), + new ModalToGetSet('Cake\\Mailer\\Email', 'entityClass'), + new ModalToGetSet('Cake\\Mailer\\Email', 'from'), + new ModalToGetSet('Cake\\Mailer\\Email', 'sender'), + new ModalToGetSet('Cake\\Mailer\\Email', 'replyTo'), + new ModalToGetSet('Cake\\Mailer\\Email', 'readReceipt'), + new ModalToGetSet('Cake\\Mailer\\Email', 'returnPath'), + new ModalToGetSet('Cake\\Mailer\\Email', 'to'), + new ModalToGetSet('Cake\\Mailer\\Email', 'cc'), + new ModalToGetSet('Cake\\Mailer\\Email', 'bcc'), + new ModalToGetSet('Cake\\Mailer\\Email', 'charset'), + new ModalToGetSet('Cake\\Mailer\\Email', 'headerCharset'), + new ModalToGetSet('Cake\\Mailer\\Email', 'emailPattern'), + new ModalToGetSet('Cake\\Mailer\\Email', 'subject'), // template: have to be changed manually, non A → B change + array case - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'viewRender', 'getViewRenderer', 'setViewRenderer'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'viewVars'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'theme'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'helpers'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'emailFormat'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'transport'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'messageId'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'domain'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'attachments'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'configTransport'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Mailer\\Email', 'profile'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Validation\\Validator', 'provider'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\View\\StringTemplateTrait', 'templates'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\View\\ViewBuilder', 'templatePath'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\View\\ViewBuilder', 'layoutPath'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\View\\ViewBuilder', 'plugin'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\View\\ViewBuilder', 'helpers'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\View\\ViewBuilder', 'theme'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\View\\ViewBuilder', 'template'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\View\\ViewBuilder', 'layout'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\View\\ViewBuilder', 'options'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\View\\ViewBuilder', 'name'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\View\\ViewBuilder', 'className'), - new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\View\\ViewBuilder', 'autoLayout', 'isAutoLayoutEnabled', 'enableAutoLayout'), + new ModalToGetSet('Cake\\Mailer\\Email', 'viewRender', 'getViewRenderer', 'setViewRenderer'), + new ModalToGetSet('Cake\\Mailer\\Email', 'viewVars'), + new ModalToGetSet('Cake\\Mailer\\Email', 'theme'), + new ModalToGetSet('Cake\\Mailer\\Email', 'helpers'), + new ModalToGetSet('Cake\\Mailer\\Email', 'emailFormat'), + new ModalToGetSet('Cake\\Mailer\\Email', 'transport'), + new ModalToGetSet('Cake\\Mailer\\Email', 'messageId'), + new ModalToGetSet('Cake\\Mailer\\Email', 'domain'), + new ModalToGetSet('Cake\\Mailer\\Email', 'attachments'), + new ModalToGetSet('Cake\\Mailer\\Email', 'configTransport'), + new ModalToGetSet('Cake\\Mailer\\Email', 'profile'), + new ModalToGetSet('Cake\\Validation\\Validator', 'provider'), + new ModalToGetSet('Cake\\View\\StringTemplateTrait', 'templates'), + new ModalToGetSet('Cake\\View\\ViewBuilder', 'templatePath'), + new ModalToGetSet('Cake\\View\\ViewBuilder', 'layoutPath'), + new ModalToGetSet('Cake\\View\\ViewBuilder', 'plugin'), + new ModalToGetSet('Cake\\View\\ViewBuilder', 'helpers'), + new ModalToGetSet('Cake\\View\\ViewBuilder', 'theme'), + new ModalToGetSet('Cake\\View\\ViewBuilder', 'template'), + new ModalToGetSet('Cake\\View\\ViewBuilder', 'layout'), + new ModalToGetSet('Cake\\View\\ViewBuilder', 'options'), + new ModalToGetSet('Cake\\View\\ViewBuilder', 'name'), + new ModalToGetSet('Cake\\View\\ViewBuilder', 'className'), + new ModalToGetSet('Cake\\View\\ViewBuilder', 'autoLayout', 'isAutoLayoutEnabled', 'enableAutoLayout'), ]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [ - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Request', 'param', 'getParam'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Request', 'data', 'getData'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Request', 'query', 'getQuery'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Request', 'cookie', 'getCookie'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Request', 'method', 'getMethod'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Request', 'setInput', 'withBody'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'location', 'withLocation'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'disableCache', 'withDisabledCache'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'type', 'withType'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'charset', 'withCharset'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'cache', 'withCache'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'modified', 'withModified'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'expires', 'withExpires'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'sharable', 'withSharable'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'maxAge', 'withMaxAge'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'vary', 'withVary'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'etag', 'withEtag'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'compress', 'withCompression'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'length', 'withLength'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'mustRevalidate', 'withMustRevalidate'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'notModified', 'withNotModified'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'cookie', 'withCookie'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'file', 'withFile'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'download', 'withDownload'), + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ + new MethodCallRename('Cake\\Network\\Request', 'param', 'getParam'), + new MethodCallRename('Cake\\Network\\Request', 'data', 'getData'), + new MethodCallRename('Cake\\Network\\Request', 'query', 'getQuery'), + new MethodCallRename('Cake\\Network\\Request', 'cookie', 'getCookie'), + new MethodCallRename('Cake\\Network\\Request', 'method', 'getMethod'), + new MethodCallRename('Cake\\Network\\Request', 'setInput', 'withBody'), + new MethodCallRename('Cake\\Network\\Response', 'location', 'withLocation'), + new MethodCallRename('Cake\\Network\\Response', 'disableCache', 'withDisabledCache'), + new MethodCallRename('Cake\\Network\\Response', 'type', 'withType'), + new MethodCallRename('Cake\\Network\\Response', 'charset', 'withCharset'), + new MethodCallRename('Cake\\Network\\Response', 'cache', 'withCache'), + new MethodCallRename('Cake\\Network\\Response', 'modified', 'withModified'), + new MethodCallRename('Cake\\Network\\Response', 'expires', 'withExpires'), + new MethodCallRename('Cake\\Network\\Response', 'sharable', 'withSharable'), + new MethodCallRename('Cake\\Network\\Response', 'maxAge', 'withMaxAge'), + new MethodCallRename('Cake\\Network\\Response', 'vary', 'withVary'), + new MethodCallRename('Cake\\Network\\Response', 'etag', 'withEtag'), + new MethodCallRename('Cake\\Network\\Response', 'compress', 'withCompression'), + new MethodCallRename('Cake\\Network\\Response', 'length', 'withLength'), + new MethodCallRename('Cake\\Network\\Response', 'mustRevalidate', 'withMustRevalidate'), + new MethodCallRename('Cake\\Network\\Response', 'notModified', 'withNotModified'), + new MethodCallRename('Cake\\Network\\Response', 'cookie', 'withCookie'), + new MethodCallRename('Cake\\Network\\Response', 'file', 'withFile'), + new MethodCallRename('Cake\\Network\\Response', 'download', 'withDownload'), # psr-7 - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'header', 'getHeader'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'body', 'withBody'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'statusCode', 'getStatusCode'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Network\\Response', 'protocol', 'getProtocolVersion'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Event\\Event', 'name', 'getName'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Event\\Event', 'subject', 'getSubject'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Event\\Event', 'result', 'getResult'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Event\\Event', 'data', 'getData'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\View\\Helper\\FormHelper', 'input', 'control'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\View\\Helper\\FormHelper', 'inputs', 'controls'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\View\\Helper\\FormHelper', 'allInputs', 'allControls'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Mailer\\Mailer', 'layout', 'setLayout'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Routing\\Route\\Route', 'parse', 'parseRequest'), - new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Routing\\Router', 'parse', 'parseRequest'), + new MethodCallRename('Cake\\Network\\Response', 'header', 'getHeader'), + new MethodCallRename('Cake\\Network\\Response', 'body', 'withBody'), + new MethodCallRename('Cake\\Network\\Response', 'statusCode', 'getStatusCode'), + new MethodCallRename('Cake\\Network\\Response', 'protocol', 'getProtocolVersion'), + new MethodCallRename('Cake\\Event\\Event', 'name', 'getName'), + new MethodCallRename('Cake\\Event\\Event', 'subject', 'getSubject'), + new MethodCallRename('Cake\\Event\\Event', 'result', 'getResult'), + new MethodCallRename('Cake\\Event\\Event', 'data', 'getData'), + new MethodCallRename('Cake\\View\\Helper\\FormHelper', 'input', 'control'), + new MethodCallRename('Cake\\View\\Helper\\FormHelper', 'inputs', 'controls'), + new MethodCallRename('Cake\\View\\Helper\\FormHelper', 'allInputs', 'allControls'), + new MethodCallRename('Cake\\Mailer\\Mailer', 'layout', 'setLayout'), + new MethodCallRename('Cake\\Routing\\Route\\Route', 'parse', 'parseRequest'), + new MethodCallRename('Cake\\Routing\\Router', 'parse', 'parseRequest'), ]); - $rectorConfig->ruleWithConfiguration(\Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector::class, [new \Rector\Visibility\ValueObject\ChangeMethodVisibility('Cake\\Mailer\\MailerAwareTrait', 'getMailer', \Rector\Core\ValueObject\Visibility::PROTECTED), new \Rector\Visibility\ValueObject\ChangeMethodVisibility('Cake\\View\\CellTrait', 'cell', \Rector\Core\ValueObject\Visibility::PROTECTED)]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Cake\\Database\\Schema\\Table' => 'Cake\\Database\\Schema\\TableSchema']); + $rectorConfig->ruleWithConfiguration(ChangeMethodVisibilityRector::class, [new ChangeMethodVisibility('Cake\\Mailer\\MailerAwareTrait', 'getMailer', Visibility::PROTECTED), new ChangeMethodVisibility('Cake\\View\\CellTrait', 'cell', Visibility::PROTECTED)]); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Cake\\Database\\Schema\\Table' => 'Cake\\Database\\Schema\\TableSchema']); }; diff --git a/vendor/rector/rector-cakephp/config/sets/cakephp35.php b/vendor/rector/rector-cakephp/config/sets/cakephp35.php index 118c25a370c..0881ff2b9f0 100644 --- a/vendor/rector/rector-cakephp/config/sets/cakephp35.php +++ b/vendor/rector/rector-cakephp/config/sets/cakephp35.php @@ -10,8 +10,8 @@ use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Renaming\ValueObject\MethodCallRename; # source: https://book.cakephp.org/3.0/en/appendices/3-5-migration-guide.html -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Cake\\Http\\Client\\CookieCollection' => 'Cake\\Http\\Cookie\\CookieCollection', 'Cake\\Console\\ShellDispatcher' => 'Cake\\Console\\CommandRunner']); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Database\\Schema\\TableSchema', 'column', 'getColumn'), new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Database\\Schema\\TableSchema', 'constraint', 'getConstraint'), new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Database\\Schema\\TableSchema', 'index', 'getIndex')]); - $rectorConfig->ruleWithConfiguration(\Rector\CakePHP\Rector\MethodCall\ModalToGetSetRector::class, [new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Cache\\Cache', 'config'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Cache\\Cache', 'registry'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Console\\Shell', 'io'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Console\\ConsoleIo', 'outputAs'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Console\\ConsoleOutput', 'outputAs'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\Connection', 'logger'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\TypedResultInterface', 'returnType'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\TypedResultTrait', 'returnType'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\Log\\LoggingStatement', 'logger'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Datasource\\ModelAwareTrait', 'modelType'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\Query', 'valueBinder', 'getValueBinder', 'valueBinder'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\Schema\\TableSchema', 'columnType'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Datasource\\QueryTrait', 'eagerLoaded', 'isEagerLoaded', 'eagerLoaded'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Event\\EventDispatcherInterface', 'eventManager'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Event\\EventDispatcherTrait', 'eventManager'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Error\\Debugger', 'outputAs', 'getOutputFormat', 'setOutputFormat'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Http\\ServerRequest', 'env', 'getEnv', 'withEnv'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Http\\ServerRequest', 'charset', 'getCharset', 'withCharset'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\I18n\\I18n', 'locale'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\I18n\\I18n', 'translator'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\I18n\\I18n', 'defaultLocale'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\I18n\\I18n', 'defaultFormatter'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association\\BelongsToMany', 'sort'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\LocatorAwareTrait', 'tableLocator'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Table', 'validator'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Routing\\RouteBuilder', 'extensions'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Routing\\RouteBuilder', 'routeClass'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Routing\\RouteCollection', 'extensions'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\TestSuite\\TestFixture', 'schema'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Utility\\Security', 'salt'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\View\\View', 'template'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\View\\View', 'layout'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\View\\View', 'theme'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\View\\View', 'templatePath'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\View\\View', 'layoutPath'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\View\\View', 'autoLayout', 'isAutoLayoutEnabled', 'enableAutoLayout')]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Cake\\Http\\Client\\CookieCollection' => 'Cake\\Http\\Cookie\\CookieCollection', 'Cake\\Console\\ShellDispatcher' => 'Cake\\Console\\CommandRunner']); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Cake\\Database\\Schema\\TableSchema', 'column', 'getColumn'), new MethodCallRename('Cake\\Database\\Schema\\TableSchema', 'constraint', 'getConstraint'), new MethodCallRename('Cake\\Database\\Schema\\TableSchema', 'index', 'getIndex')]); + $rectorConfig->ruleWithConfiguration(ModalToGetSetRector::class, [new ModalToGetSet('Cake\\Cache\\Cache', 'config'), new ModalToGetSet('Cake\\Cache\\Cache', 'registry'), new ModalToGetSet('Cake\\Console\\Shell', 'io'), new ModalToGetSet('Cake\\Console\\ConsoleIo', 'outputAs'), new ModalToGetSet('Cake\\Console\\ConsoleOutput', 'outputAs'), new ModalToGetSet('Cake\\Database\\Connection', 'logger'), new ModalToGetSet('Cake\\Database\\TypedResultInterface', 'returnType'), new ModalToGetSet('Cake\\Database\\TypedResultTrait', 'returnType'), new ModalToGetSet('Cake\\Database\\Log\\LoggingStatement', 'logger'), new ModalToGetSet('Cake\\Datasource\\ModelAwareTrait', 'modelType'), new ModalToGetSet('Cake\\Database\\Query', 'valueBinder', 'getValueBinder', 'valueBinder'), new ModalToGetSet('Cake\\Database\\Schema\\TableSchema', 'columnType'), new ModalToGetSet('Cake\\Datasource\\QueryTrait', 'eagerLoaded', 'isEagerLoaded', 'eagerLoaded'), new ModalToGetSet('Cake\\Event\\EventDispatcherInterface', 'eventManager'), new ModalToGetSet('Cake\\Event\\EventDispatcherTrait', 'eventManager'), new ModalToGetSet('Cake\\Error\\Debugger', 'outputAs', 'getOutputFormat', 'setOutputFormat'), new ModalToGetSet('Cake\\Http\\ServerRequest', 'env', 'getEnv', 'withEnv'), new ModalToGetSet('Cake\\Http\\ServerRequest', 'charset', 'getCharset', 'withCharset'), new ModalToGetSet('Cake\\I18n\\I18n', 'locale'), new ModalToGetSet('Cake\\I18n\\I18n', 'translator'), new ModalToGetSet('Cake\\I18n\\I18n', 'defaultLocale'), new ModalToGetSet('Cake\\I18n\\I18n', 'defaultFormatter'), new ModalToGetSet('Cake\\ORM\\Association\\BelongsToMany', 'sort'), new ModalToGetSet('Cake\\ORM\\LocatorAwareTrait', 'tableLocator'), new ModalToGetSet('Cake\\ORM\\Table', 'validator'), new ModalToGetSet('Cake\\Routing\\RouteBuilder', 'extensions'), new ModalToGetSet('Cake\\Routing\\RouteBuilder', 'routeClass'), new ModalToGetSet('Cake\\Routing\\RouteCollection', 'extensions'), new ModalToGetSet('Cake\\TestSuite\\TestFixture', 'schema'), new ModalToGetSet('Cake\\Utility\\Security', 'salt'), new ModalToGetSet('Cake\\View\\View', 'template'), new ModalToGetSet('Cake\\View\\View', 'layout'), new ModalToGetSet('Cake\\View\\View', 'theme'), new ModalToGetSet('Cake\\View\\View', 'templatePath'), new ModalToGetSet('Cake\\View\\View', 'layoutPath'), new ModalToGetSet('Cake\\View\\View', 'autoLayout', 'isAutoLayoutEnabled', 'enableAutoLayout')]); }; diff --git a/vendor/rector/rector-cakephp/config/sets/cakephp36.php b/vendor/rector/rector-cakephp/config/sets/cakephp36.php index dce82f1d7c4..558806ba0dc 100644 --- a/vendor/rector/rector-cakephp/config/sets/cakephp36.php +++ b/vendor/rector/rector-cakephp/config/sets/cakephp36.php @@ -9,9 +9,9 @@ use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Renaming\ValueObject\MethodCallRename; use Rector\Transform\Rector\Assign\PropertyFetchToMethodCallRector; use Rector\Transform\ValueObject\PropertyFetchToMethodCall; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { # source: https://book.cakephp.org/3.0/en/appendices/3-6-migration-guide.html - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\ORM\\Table', 'association', 'getAssociation'), new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Validation\\ValidationSet', 'isPresenceRequired', 'requirePresence'), new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Validation\\ValidationSet', 'isEmptyAllowed', 'allowEmpty')]); - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\Assign\PropertyFetchToMethodCallRector::class, [new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\Controller\\Controller', 'name', 'getName', 'setName'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\Controller\\Controller', 'plugin', 'getPlugin', 'setPlugin'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\Form\\Form', 'validator', 'getValidator', 'setValidator')]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Cake\\Cache\\Engine\\ApcEngine' => 'Cake\\Cache\\Engine\\ApcuEngine', 'Cake\\Network\\Exception\\BadRequestException' => 'Cake\\Http\\Exception\\BadRequestException', 'Cake\\Network\\Exception\\ConflictException' => 'Cake\\Http\\Exception\\ConflictException', 'Cake\\Network\\Exception\\ForbiddenException' => 'Cake\\Http\\Exception\\ForbiddenException', 'Cake\\Network\\Exception\\GoneException' => 'Cake\\Http\\Exception\\GoneException', 'Cake\\Network\\Exception\\HttpException' => 'Cake\\Http\\Exception\\HttpException', 'Cake\\Network\\Exception\\InternalErrorException' => 'Cake\\Http\\Exception\\InternalErrorException', 'Cake\\Network\\Exception\\InvalidCsrfTokenException' => 'Cake\\Http\\Exception\\InvalidCsrfTokenException', 'Cake\\Network\\Exception\\MethodNotAllowedException' => 'Cake\\Http\\Exception\\MethodNotAllowedException', 'Cake\\Network\\Exception\\NotAcceptableException' => 'Cake\\Http\\Exception\\NotAcceptableException', 'Cake\\Network\\Exception\\NotFoundException' => 'Cake\\Http\\Exception\\NotFoundException', 'Cake\\Network\\Exception\\NotImplementedException' => 'Cake\\Http\\Exception\\NotImplementedException', 'Cake\\Network\\Exception\\ServiceUnavailableException' => 'Cake\\Http\\Exception\\ServiceUnavailableException', 'Cake\\Network\\Exception\\UnauthorizedException' => 'Cake\\Http\\Exception\\UnauthorizedException', 'Cake\\Network\\Exception\\UnavailableForLegalReasonsException' => 'Cake\\Http\\Exception\\UnavailableForLegalReasonsException', 'Cake\\Network\\Session' => 'Cake\\Http\\Session', 'Cake\\Network\\Session\\DatabaseSession' => 'Cake\\Http\\Session\\DatabaseSession', 'Cake\\Network\\Session\\CacheSession' => 'Cake\\Http\\Session\\CacheSession', 'Cake\\Network\\CorsBuilder' => 'Cake\\Http\\CorsBuilder', 'Cake\\View\\Widget\\WidgetRegistry' => 'Cake\\View\\Widget\\WidgetLocator']); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Cake\\ORM\\Table', 'association', 'getAssociation'), new MethodCallRename('Cake\\Validation\\ValidationSet', 'isPresenceRequired', 'requirePresence'), new MethodCallRename('Cake\\Validation\\ValidationSet', 'isEmptyAllowed', 'allowEmpty')]); + $rectorConfig->ruleWithConfiguration(PropertyFetchToMethodCallRector::class, [new PropertyFetchToMethodCall('Cake\\Controller\\Controller', 'name', 'getName', 'setName'), new PropertyFetchToMethodCall('Cake\\Controller\\Controller', 'plugin', 'getPlugin', 'setPlugin'), new PropertyFetchToMethodCall('Cake\\Form\\Form', 'validator', 'getValidator', 'setValidator')]); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Cake\\Cache\\Engine\\ApcEngine' => 'Cake\\Cache\\Engine\\ApcuEngine', 'Cake\\Network\\Exception\\BadRequestException' => 'Cake\\Http\\Exception\\BadRequestException', 'Cake\\Network\\Exception\\ConflictException' => 'Cake\\Http\\Exception\\ConflictException', 'Cake\\Network\\Exception\\ForbiddenException' => 'Cake\\Http\\Exception\\ForbiddenException', 'Cake\\Network\\Exception\\GoneException' => 'Cake\\Http\\Exception\\GoneException', 'Cake\\Network\\Exception\\HttpException' => 'Cake\\Http\\Exception\\HttpException', 'Cake\\Network\\Exception\\InternalErrorException' => 'Cake\\Http\\Exception\\InternalErrorException', 'Cake\\Network\\Exception\\InvalidCsrfTokenException' => 'Cake\\Http\\Exception\\InvalidCsrfTokenException', 'Cake\\Network\\Exception\\MethodNotAllowedException' => 'Cake\\Http\\Exception\\MethodNotAllowedException', 'Cake\\Network\\Exception\\NotAcceptableException' => 'Cake\\Http\\Exception\\NotAcceptableException', 'Cake\\Network\\Exception\\NotFoundException' => 'Cake\\Http\\Exception\\NotFoundException', 'Cake\\Network\\Exception\\NotImplementedException' => 'Cake\\Http\\Exception\\NotImplementedException', 'Cake\\Network\\Exception\\ServiceUnavailableException' => 'Cake\\Http\\Exception\\ServiceUnavailableException', 'Cake\\Network\\Exception\\UnauthorizedException' => 'Cake\\Http\\Exception\\UnauthorizedException', 'Cake\\Network\\Exception\\UnavailableForLegalReasonsException' => 'Cake\\Http\\Exception\\UnavailableForLegalReasonsException', 'Cake\\Network\\Session' => 'Cake\\Http\\Session', 'Cake\\Network\\Session\\DatabaseSession' => 'Cake\\Http\\Session\\DatabaseSession', 'Cake\\Network\\Session\\CacheSession' => 'Cake\\Http\\Session\\CacheSession', 'Cake\\Network\\CorsBuilder' => 'Cake\\Http\\CorsBuilder', 'Cake\\View\\Widget\\WidgetRegistry' => 'Cake\\View\\Widget\\WidgetLocator']); }; diff --git a/vendor/rector/rector-cakephp/config/sets/cakephp37.php b/vendor/rector/rector-cakephp/config/sets/cakephp37.php index 28e9f145234..83d4f49da7e 100644 --- a/vendor/rector/rector-cakephp/config/sets/cakephp37.php +++ b/vendor/rector/rector-cakephp/config/sets/cakephp37.php @@ -14,10 +14,10 @@ use Rector\Transform\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgument use Rector\Transform\ValueObject\MethodCallToAnotherMethodCallWithArguments; use Rector\Transform\ValueObject\PropertyFetchToMethodCall; # source: https://book.cakephp.org/3.0/en/appendices/3-7-migration-guide.html -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Form\\Form', 'errors', 'getErrors'), new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Validation\\Validation', 'cc', 'creditCard'), new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Filesystem\\Folder', 'normalizePath', 'correctSlashFor'), new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Http\\Client\\Response', 'body', 'getStringBody'), new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Core\\Plugin', 'unload', 'clear')]); - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\Assign\PropertyFetchToMethodCallRector::class, [new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\Http\\Client\\Response', 'body', 'getStringBody'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\Http\\Client\\Response', 'json', 'getJson'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\Http\\Client\\Response', 'xml', 'getXml'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\Http\\Client\\Response', 'cookies', 'getCookies'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\Http\\Client\\Response', 'code', 'getStatusCode'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\View\\View', 'request', 'getRequest', 'setRequest'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\View\\View', 'response', 'getResponse', 'setResponse'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\View\\View', 'templatePath', 'getTemplatePath', 'setTemplatePath'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\View\\View', 'template', 'getTemplate', 'setTemplate'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\View\\View', 'layout', 'getLayout', 'setLayout'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\View\\View', 'layoutPath', 'getLayoutPath', 'setLayoutPath'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\View\\View', 'autoLayout', 'isAutoLayoutEnabled', 'enableAutoLayout'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\View\\View', 'theme', 'getTheme', 'setTheme'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\View\\View', 'subDir', 'getSubDir', 'setSubDir'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\View\\View', 'plugin', 'getPlugin', 'setPlugin'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\View\\View', 'name', 'getName', 'setName'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\View\\View', 'elementCache', 'getElementCache', 'setElementCache'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\View\\View', 'helpers', 'helpers')]); - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector::class, [new \Rector\Transform\ValueObject\MethodCallToAnotherMethodCallWithArguments('Cake\\Database\\Query', 'join', 'clause', ['join']), new \Rector\Transform\ValueObject\MethodCallToAnotherMethodCallWithArguments('Cake\\Database\\Query', 'from', 'clause', ['from'])]); - $rectorConfig->ruleWithConfiguration(\Rector\CakePHP\Rector\MethodCall\ModalToGetSetRector::class, [new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Database\\Connection', 'logQueries', 'isQueryLoggingEnabled', 'enableQueryLogging'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\Association', 'className', 'getClassName', 'setClassName')]); - $rectorConfig->rule(\Rector\CakePHP\Rector\Property\ChangeSnakedFixtureNameToPascalRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Cake\\Form\\Form', 'errors', 'getErrors'), new MethodCallRename('Cake\\Validation\\Validation', 'cc', 'creditCard'), new MethodCallRename('Cake\\Filesystem\\Folder', 'normalizePath', 'correctSlashFor'), new MethodCallRename('Cake\\Http\\Client\\Response', 'body', 'getStringBody'), new MethodCallRename('Cake\\Core\\Plugin', 'unload', 'clear')]); + $rectorConfig->ruleWithConfiguration(PropertyFetchToMethodCallRector::class, [new PropertyFetchToMethodCall('Cake\\Http\\Client\\Response', 'body', 'getStringBody'), new PropertyFetchToMethodCall('Cake\\Http\\Client\\Response', 'json', 'getJson'), new PropertyFetchToMethodCall('Cake\\Http\\Client\\Response', 'xml', 'getXml'), new PropertyFetchToMethodCall('Cake\\Http\\Client\\Response', 'cookies', 'getCookies'), new PropertyFetchToMethodCall('Cake\\Http\\Client\\Response', 'code', 'getStatusCode'), new PropertyFetchToMethodCall('Cake\\View\\View', 'request', 'getRequest', 'setRequest'), new PropertyFetchToMethodCall('Cake\\View\\View', 'response', 'getResponse', 'setResponse'), new PropertyFetchToMethodCall('Cake\\View\\View', 'templatePath', 'getTemplatePath', 'setTemplatePath'), new PropertyFetchToMethodCall('Cake\\View\\View', 'template', 'getTemplate', 'setTemplate'), new PropertyFetchToMethodCall('Cake\\View\\View', 'layout', 'getLayout', 'setLayout'), new PropertyFetchToMethodCall('Cake\\View\\View', 'layoutPath', 'getLayoutPath', 'setLayoutPath'), new PropertyFetchToMethodCall('Cake\\View\\View', 'autoLayout', 'isAutoLayoutEnabled', 'enableAutoLayout'), new PropertyFetchToMethodCall('Cake\\View\\View', 'theme', 'getTheme', 'setTheme'), new PropertyFetchToMethodCall('Cake\\View\\View', 'subDir', 'getSubDir', 'setSubDir'), new PropertyFetchToMethodCall('Cake\\View\\View', 'plugin', 'getPlugin', 'setPlugin'), new PropertyFetchToMethodCall('Cake\\View\\View', 'name', 'getName', 'setName'), new PropertyFetchToMethodCall('Cake\\View\\View', 'elementCache', 'getElementCache', 'setElementCache'), new PropertyFetchToMethodCall('Cake\\View\\View', 'helpers', 'helpers')]); + $rectorConfig->ruleWithConfiguration(MethodCallToAnotherMethodCallWithArgumentsRector::class, [new MethodCallToAnotherMethodCallWithArguments('Cake\\Database\\Query', 'join', 'clause', ['join']), new MethodCallToAnotherMethodCallWithArguments('Cake\\Database\\Query', 'from', 'clause', ['from'])]); + $rectorConfig->ruleWithConfiguration(ModalToGetSetRector::class, [new ModalToGetSet('Cake\\Database\\Connection', 'logQueries', 'isQueryLoggingEnabled', 'enableQueryLogging'), new ModalToGetSet('Cake\\ORM\\Association', 'className', 'getClassName', 'setClassName')]); + $rectorConfig->rule(ChangeSnakedFixtureNameToPascalRector::class); }; diff --git a/vendor/rector/rector-cakephp/config/sets/cakephp38.php b/vendor/rector/rector-cakephp/config/sets/cakephp38.php index 57696b6e107..ab15b3fe2fc 100644 --- a/vendor/rector/rector-cakephp/config/sets/cakephp38.php +++ b/vendor/rector/rector-cakephp/config/sets/cakephp38.php @@ -7,6 +7,6 @@ use Rector\Config\RectorConfig; use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\ValueObject\MethodCallRename; # source: https://book.cakephp.org/3.0/en/appendices/3-8-migration-guide.html -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\ORM\\Entity', 'visibleProperties', 'getVisible')]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Cake\\ORM\\Entity', 'visibleProperties', 'getVisible')]); }; diff --git a/vendor/rector/rector-cakephp/config/sets/cakephp40.php b/vendor/rector/rector-cakephp/config/sets/cakephp40.php index 35b0d7be84f..e11042d9af3 100644 --- a/vendor/rector/rector-cakephp/config/sets/cakephp40.php +++ b/vendor/rector/rector-cakephp/config/sets/cakephp40.php @@ -30,15 +30,15 @@ use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector; use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration; use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration; # source: https://book.cakephp.org/4/en/appendices/4-0-migration-guide.html -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Cake\\Database\\Type' => 'Cake\\Database\\TypeFactory', 'Cake\\Console\\ConsoleErrorHandler' => 'Cake\\Error\\ConsoleErrorHandler']); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector::class, [new \Rector\Renaming\ValueObject\RenameClassConstFetch('Cake\\View\\View', 'NAME_ELEMENT', 'TYPE_ELEMENT'), new \Rector\Renaming\ValueObject\RenameClassConstFetch('Cake\\View\\View', 'NAME_LAYOUT', 'TYPE_LAYOUT'), new \Rector\Renaming\ValueObject\RenameClassAndConstFetch('Cake\\Mailer\\Email', 'MESSAGE_HTML', 'Cake\\Mailer\\Message', 'MESSAGE_HTML'), new \Rector\Renaming\ValueObject\RenameClassAndConstFetch('Cake\\Mailer\\Email', 'MESSAGE_TEXT', 'Cake\\Mailer\\Message', 'MESSAGE_TEXT'), new \Rector\Renaming\ValueObject\RenameClassAndConstFetch('Cake\\Mailer\\Email', 'MESSAGE_BOTH', 'Cake\\Mailer\\Message', 'MESSAGE_BOTH'), new \Rector\Renaming\ValueObject\RenameClassAndConstFetch('Cake\\Mailer\\Email', 'EMAIL_PATTERN', 'Cake\\Mailer\\Message', 'EMAIL_PATTERN')]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Form\\Form', 'errors', 'getErrors'), new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Mailer\\Email', 'set', 'setViewVars'), new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\ORM\\EntityInterface', 'unsetProperty', 'unset'), new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Cache\\Cache', 'engine', 'pool'), new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Http\\Cookie\\Cookie', 'getStringValue', 'getScalarValue'), new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Validation\\Validator', 'containsNonAlphaNumeric', 'notAlphaNumeric'), new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Validation\\Validator', 'errors', 'validate')]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\StaticCall\RenameStaticMethodRector::class, [new \Rector\Renaming\ValueObject\RenameStaticMethod('Router', 'pushRequest', 'Router', 'setRequest'), new \Rector\Renaming\ValueObject\RenameStaticMethod('Router', 'setRequestInfo', 'Router', 'setRequest'), new \Rector\Renaming\ValueObject\RenameStaticMethod('Router', 'setRequestContext', 'Router', 'setRequest')]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector::class, [new \Rector\Renaming\ValueObject\RenameProperty('Cake\\ORM\\Entity', '_properties', '_fields')]); - $rectorConfig->ruleWithConfiguration(\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::class, [new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Cake\\Http\\BaseApplication', 'bootstrap', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Cake\\Http\\BaseApplication', 'bootstrapCli', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Cake\\Http\\BaseApplication', 'middleware', new \PHPStan\Type\ObjectType('Cake\\Http\\MiddlewareQueue')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Cake\\Console\\Shell', 'initialize', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Cake\\Controller\\Component', 'initialize', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Cake\\Controller\\Controller', 'initialize', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Cake\\Controller\\Controller', 'render', new \PHPStan\Type\ObjectType('Cake\\Http\\Response')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Cake\\Form\\Form', 'validate', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Cake\\Form\\Form', '_buildSchema', new \PHPStan\Type\ObjectType('Cake\\Form\\Schema')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Cake\\ORM\\Behavior', 'initialize', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Cake\\ORM\\Table', 'initialize', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Cake\\ORM\\Table', 'updateAll', new \PHPStan\Type\IntegerType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Cake\\ORM\\Table', 'deleteAll', new \PHPStan\Type\IntegerType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Cake\\ORM\\Table', 'validationDefault', new \PHPStan\Type\ObjectType('Cake\\Validation\\Validator')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Cake\\ORM\\Table', 'buildRules', new \PHPStan\Type\ObjectType('Cake\\ORM\\RulesChecker')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Cake\\View\\Helper', 'initialize', new \PHPStan\Type\VoidType())]); - $eventInterfaceObjectType = new \PHPStan\Type\ObjectType('Cake\\Event\\EventInterface'); - $rectorConfig->ruleWithConfiguration(\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::class, [new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\Form\\Form', 'getData', 0, new \PHPStan\Type\UnionType([new \PHPStan\Type\StringType(), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\ORM\\Behavior', 'beforeFind', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\ORM\\Behavior', 'buildValidator', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\ORM\\Behavior', 'buildRules', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\ORM\\Behavior', 'beforeRules', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\ORM\\Behavior', 'afterRules', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\ORM\\Behavior', 'beforeSave', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\ORM\\Behavior', 'afterSave', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\ORM\\Behavior', 'beforeDelete', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\ORM\\Behavior', 'afterDelete', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\ORM\\Table', 'beforeFind', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\ORM\\Table', 'buildValidator', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\ORM\\Table', 'buildRules', 0, new \PHPStan\Type\ObjectType('Cake\\ORM\\RulesChecker')), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\ORM\\Table', 'beforeRules', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\ORM\\Table', 'afterRules', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\ORM\\Table', 'beforeSave', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\ORM\\Table', 'afterSave', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\ORM\\Table', 'beforeDelete', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\ORM\\Table', 'afterDelete', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\Controller\\Controller', 'beforeFilter', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\Controller\\Controller', 'afterFilter', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\Controller\\Controller', 'beforeRender', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\Controller\\Controller', 'beforeRedirect', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\Controller\\Component', 'shutdown', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\Controller\\Component', 'startup', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\Controller\\Component', 'beforeFilter', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\Controller\\Component', 'beforeRender', 0, $eventInterfaceObjectType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Cake\\Controller\\Component', 'beforeRedirect', 0, $eventInterfaceObjectType)]); - $rectorConfig->ruleWithConfiguration(\Rector\CakePHP\Rector\MethodCall\RenameMethodCallBasedOnParameterRector::class, [new \Rector\CakePHP\ValueObject\RenameMethodCallBasedOnParameter('Cake\\Http\\ServerRequest', 'getParam', 'paging', 'getAttribute'), new \Rector\CakePHP\ValueObject\RenameMethodCallBasedOnParameter('Cake\\Http\\ServerRequest', 'withParam', 'paging', 'withAttribute')]); - $rectorConfig->ruleWithConfiguration(\Rector\CakePHP\Rector\MethodCall\ModalToGetSetRector::class, [new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Console\\ConsoleIo', 'styles', 'setStyle', 'getStyle'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Console\\ConsoleOutput', 'styles', 'setStyle', 'getStyle'), new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\ORM\\EntityInterface', 'isNew', 'setNew', 'isNew')]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Cake\\Database\\Type' => 'Cake\\Database\\TypeFactory', 'Cake\\Console\\ConsoleErrorHandler' => 'Cake\\Error\\ConsoleErrorHandler']); + $rectorConfig->ruleWithConfiguration(RenameClassConstFetchRector::class, [new RenameClassConstFetch('Cake\\View\\View', 'NAME_ELEMENT', 'TYPE_ELEMENT'), new RenameClassConstFetch('Cake\\View\\View', 'NAME_LAYOUT', 'TYPE_LAYOUT'), new RenameClassAndConstFetch('Cake\\Mailer\\Email', 'MESSAGE_HTML', 'Cake\\Mailer\\Message', 'MESSAGE_HTML'), new RenameClassAndConstFetch('Cake\\Mailer\\Email', 'MESSAGE_TEXT', 'Cake\\Mailer\\Message', 'MESSAGE_TEXT'), new RenameClassAndConstFetch('Cake\\Mailer\\Email', 'MESSAGE_BOTH', 'Cake\\Mailer\\Message', 'MESSAGE_BOTH'), new RenameClassAndConstFetch('Cake\\Mailer\\Email', 'EMAIL_PATTERN', 'Cake\\Mailer\\Message', 'EMAIL_PATTERN')]); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Cake\\Form\\Form', 'errors', 'getErrors'), new MethodCallRename('Cake\\Mailer\\Email', 'set', 'setViewVars'), new MethodCallRename('Cake\\ORM\\EntityInterface', 'unsetProperty', 'unset'), new MethodCallRename('Cake\\Cache\\Cache', 'engine', 'pool'), new MethodCallRename('Cake\\Http\\Cookie\\Cookie', 'getStringValue', 'getScalarValue'), new MethodCallRename('Cake\\Validation\\Validator', 'containsNonAlphaNumeric', 'notAlphaNumeric'), new MethodCallRename('Cake\\Validation\\Validator', 'errors', 'validate')]); + $rectorConfig->ruleWithConfiguration(RenameStaticMethodRector::class, [new RenameStaticMethod('Router', 'pushRequest', 'Router', 'setRequest'), new RenameStaticMethod('Router', 'setRequestInfo', 'Router', 'setRequest'), new RenameStaticMethod('Router', 'setRequestContext', 'Router', 'setRequest')]); + $rectorConfig->ruleWithConfiguration(RenamePropertyRector::class, [new RenameProperty('Cake\\ORM\\Entity', '_properties', '_fields')]); + $rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [new AddReturnTypeDeclaration('Cake\\Http\\BaseApplication', 'bootstrap', new VoidType()), new AddReturnTypeDeclaration('Cake\\Http\\BaseApplication', 'bootstrapCli', new VoidType()), new AddReturnTypeDeclaration('Cake\\Http\\BaseApplication', 'middleware', new ObjectType('Cake\\Http\\MiddlewareQueue')), new AddReturnTypeDeclaration('Cake\\Console\\Shell', 'initialize', new VoidType()), new AddReturnTypeDeclaration('Cake\\Controller\\Component', 'initialize', new VoidType()), new AddReturnTypeDeclaration('Cake\\Controller\\Controller', 'initialize', new VoidType()), new AddReturnTypeDeclaration('Cake\\Controller\\Controller', 'render', new ObjectType('Cake\\Http\\Response')), new AddReturnTypeDeclaration('Cake\\Form\\Form', 'validate', new BooleanType()), new AddReturnTypeDeclaration('Cake\\Form\\Form', '_buildSchema', new ObjectType('Cake\\Form\\Schema')), new AddReturnTypeDeclaration('Cake\\ORM\\Behavior', 'initialize', new VoidType()), new AddReturnTypeDeclaration('Cake\\ORM\\Table', 'initialize', new VoidType()), new AddReturnTypeDeclaration('Cake\\ORM\\Table', 'updateAll', new IntegerType()), new AddReturnTypeDeclaration('Cake\\ORM\\Table', 'deleteAll', new IntegerType()), new AddReturnTypeDeclaration('Cake\\ORM\\Table', 'validationDefault', new ObjectType('Cake\\Validation\\Validator')), new AddReturnTypeDeclaration('Cake\\ORM\\Table', 'buildRules', new ObjectType('Cake\\ORM\\RulesChecker')), new AddReturnTypeDeclaration('Cake\\View\\Helper', 'initialize', new VoidType())]); + $eventInterfaceObjectType = new ObjectType('Cake\\Event\\EventInterface'); + $rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [new AddParamTypeDeclaration('Cake\\Form\\Form', 'getData', 0, new UnionType([new StringType(), new NullType()])), new AddParamTypeDeclaration('Cake\\ORM\\Behavior', 'beforeFind', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\ORM\\Behavior', 'buildValidator', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\ORM\\Behavior', 'buildRules', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\ORM\\Behavior', 'beforeRules', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\ORM\\Behavior', 'afterRules', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\ORM\\Behavior', 'beforeSave', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\ORM\\Behavior', 'afterSave', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\ORM\\Behavior', 'beforeDelete', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\ORM\\Behavior', 'afterDelete', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\ORM\\Table', 'beforeFind', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\ORM\\Table', 'buildValidator', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\ORM\\Table', 'buildRules', 0, new ObjectType('Cake\\ORM\\RulesChecker')), new AddParamTypeDeclaration('Cake\\ORM\\Table', 'beforeRules', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\ORM\\Table', 'afterRules', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\ORM\\Table', 'beforeSave', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\ORM\\Table', 'afterSave', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\ORM\\Table', 'beforeDelete', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\ORM\\Table', 'afterDelete', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\Controller\\Controller', 'beforeFilter', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\Controller\\Controller', 'afterFilter', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\Controller\\Controller', 'beforeRender', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\Controller\\Controller', 'beforeRedirect', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\Controller\\Component', 'shutdown', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\Controller\\Component', 'startup', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\Controller\\Component', 'beforeFilter', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\Controller\\Component', 'beforeRender', 0, $eventInterfaceObjectType), new AddParamTypeDeclaration('Cake\\Controller\\Component', 'beforeRedirect', 0, $eventInterfaceObjectType)]); + $rectorConfig->ruleWithConfiguration(RenameMethodCallBasedOnParameterRector::class, [new RenameMethodCallBasedOnParameter('Cake\\Http\\ServerRequest', 'getParam', 'paging', 'getAttribute'), new RenameMethodCallBasedOnParameter('Cake\\Http\\ServerRequest', 'withParam', 'paging', 'withAttribute')]); + $rectorConfig->ruleWithConfiguration(ModalToGetSetRector::class, [new ModalToGetSet('Cake\\Console\\ConsoleIo', 'styles', 'setStyle', 'getStyle'), new ModalToGetSet('Cake\\Console\\ConsoleOutput', 'styles', 'setStyle', 'getStyle'), new ModalToGetSet('Cake\\ORM\\EntityInterface', 'isNew', 'setNew', 'isNew')]); }; diff --git a/vendor/rector/rector-cakephp/config/sets/cakephp41.php b/vendor/rector/rector-cakephp/config/sets/cakephp41.php index 301555d9093..fe334ff01ef 100644 --- a/vendor/rector/rector-cakephp/config/sets/cakephp41.php +++ b/vendor/rector/rector-cakephp/config/sets/cakephp41.php @@ -9,8 +9,8 @@ use Rector\Config\RectorConfig; use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Renaming\ValueObject\MethodCallRename; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Cake\\Routing\\Exception\\RedirectException' => 'Cake\\Http\\Exception\\RedirectException', 'Cake\\Database\\Expression\\Comparison' => 'Cake\\Database\\Expression\\ComparisonExpression']); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Database\\Schema\\TableSchema', 'getPrimary', 'getPrimaryKey'), new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Database\\Type\\DateTimeType', 'setTimezone', 'setDatabaseTimezone'), new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Database\\Expression\\QueryExpression', 'or_', 'or'), new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Database\\Expression\\QueryExpression', 'and_', 'and'), new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\View\\Form\\ContextInterface', 'primaryKey', 'getPrimaryKey'), new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Http\\Middleware\\CsrfProtectionMiddleware', 'whitelistCallback', 'skipCheckCallback')]); - $rectorConfig->ruleWithConfiguration(\Rector\CakePHP\Rector\MethodCall\ModalToGetSetRector::class, [new \Rector\CakePHP\ValueObject\ModalToGetSet('Cake\\Form\\Form', 'schema')]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Cake\\Routing\\Exception\\RedirectException' => 'Cake\\Http\\Exception\\RedirectException', 'Cake\\Database\\Expression\\Comparison' => 'Cake\\Database\\Expression\\ComparisonExpression']); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Cake\\Database\\Schema\\TableSchema', 'getPrimary', 'getPrimaryKey'), new MethodCallRename('Cake\\Database\\Type\\DateTimeType', 'setTimezone', 'setDatabaseTimezone'), new MethodCallRename('Cake\\Database\\Expression\\QueryExpression', 'or_', 'or'), new MethodCallRename('Cake\\Database\\Expression\\QueryExpression', 'and_', 'and'), new MethodCallRename('Cake\\View\\Form\\ContextInterface', 'primaryKey', 'getPrimaryKey'), new MethodCallRename('Cake\\Http\\Middleware\\CsrfProtectionMiddleware', 'whitelistCallback', 'skipCheckCallback')]); + $rectorConfig->ruleWithConfiguration(ModalToGetSetRector::class, [new ModalToGetSet('Cake\\Form\\Form', 'schema')]); }; diff --git a/vendor/rector/rector-cakephp/config/sets/cakephp42.php b/vendor/rector/rector-cakephp/config/sets/cakephp42.php index 1b9bb2a9427..8fefd88152e 100644 --- a/vendor/rector/rector-cakephp/config/sets/cakephp42.php +++ b/vendor/rector/rector-cakephp/config/sets/cakephp42.php @@ -8,7 +8,7 @@ use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Renaming\ValueObject\MethodCallRename; # source: https://book.cakephp.org/4/en/appendices/4-2-migration-guide.html -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Cake\\Core\\Exception\\Exception' => 'Cake\\Core\\Exception\\CakeException', 'Cake\\Database\\Exception' => 'Cake\\Database\\Exception\\DatabaseException']); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\ORM\\Behavior', 'getTable', 'table')]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Cake\\Core\\Exception\\Exception' => 'Cake\\Core\\Exception\\CakeException', 'Cake\\Database\\Exception' => 'Cake\\Database\\Exception\\DatabaseException']); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Cake\\ORM\\Behavior', 'getTable', 'table')]); }; diff --git a/vendor/rector/rector-cakephp/config/sets/cakephp43.php b/vendor/rector/rector-cakephp/config/sets/cakephp43.php index 68a6b8a22ec..bbd19723710 100644 --- a/vendor/rector/rector-cakephp/config/sets/cakephp43.php +++ b/vendor/rector/rector-cakephp/config/sets/cakephp43.php @@ -13,9 +13,9 @@ use Rector\Transform\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgument use Rector\Transform\ValueObject\MethodCallToAnotherMethodCallWithArguments; use Rector\Transform\ValueObject\PropertyFetchToMethodCall; # source: https://book.cakephp.org/4.next/en/appendices/4-3-migration-guide.html -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Cake\\Controller\\Component', 'shutdown', 'afterFilter')]); - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\Assign\PropertyFetchToMethodCallRector::class, [new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\Network\\Socket', 'connected', 'isConnected'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\Network\\Socket', 'encrypted', 'isEncrypted'), new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Cake\\Network\\Socket', 'lastError', 'lastError')]); - $rectorConfig->ruleWithConfiguration(\Rector\CakePHP\Rector\MethodCall\RemoveIntermediaryMethodRector::class, [new \Rector\CakePHP\ValueObject\RemoveIntermediaryMethod('getTableLocator', 'get', 'fetchTable')]); - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\MethodCall\MethodCallToAnotherMethodCallWithArgumentsRector::class, [new \Rector\Transform\ValueObject\MethodCallToAnotherMethodCallWithArguments('Cake\\Database\\DriverInterface', 'supportsQuoting', 'supports', ['quote']), new \Rector\Transform\ValueObject\MethodCallToAnotherMethodCallWithArguments('Cake\\Database\\DriverInterface', 'supportsSavepoints', 'supports', ['savepoint'])]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Cake\\Controller\\Component', 'shutdown', 'afterFilter')]); + $rectorConfig->ruleWithConfiguration(PropertyFetchToMethodCallRector::class, [new PropertyFetchToMethodCall('Cake\\Network\\Socket', 'connected', 'isConnected'), new PropertyFetchToMethodCall('Cake\\Network\\Socket', 'encrypted', 'isEncrypted'), new PropertyFetchToMethodCall('Cake\\Network\\Socket', 'lastError', 'lastError')]); + $rectorConfig->ruleWithConfiguration(RemoveIntermediaryMethodRector::class, [new RemoveIntermediaryMethod('getTableLocator', 'get', 'fetchTable')]); + $rectorConfig->ruleWithConfiguration(MethodCallToAnotherMethodCallWithArgumentsRector::class, [new MethodCallToAnotherMethodCallWithArguments('Cake\\Database\\DriverInterface', 'supportsQuoting', 'supports', ['quote']), new MethodCallToAnotherMethodCallWithArguments('Cake\\Database\\DriverInterface', 'supportsSavepoints', 'supports', ['savepoint'])]); }; diff --git a/vendor/rector/rector-cakephp/config/sets/cakephp44.php b/vendor/rector/rector-cakephp/config/sets/cakephp44.php index 7da08fca73c..1ba48ebaaee 100644 --- a/vendor/rector/rector-cakephp/config/sets/cakephp44.php +++ b/vendor/rector/rector-cakephp/config/sets/cakephp44.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Renaming\Rector\Name\RenameClassRector; # @see https://book.cakephp.org/4/en/appendices/4-4-migration-guide.html -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Cake\\TestSuite\\ConsoleIntegrationTestTrait' => 'Cake\\Console\\TestSuite\\ConsoleIntegrationTestTrait', 'Cake\\TestSuite\\Stub\\ConsoleInput' => 'Cake\\Console\\TestSuite\\StubConsoleInput', 'Cake\\TestSuite\\Stub\\ConsoleOutput' => 'Cake\\Console\\TestSuite\\StubConsoleOutput', 'Cake\\TestSuite\\Stub\\MissingConsoleInputException' => 'Cake\\Console\\TestSuite\\MissingConsoleInputException', 'Cake\\TestSuite\\HttpClientTrait' => 'Cake\\Http\\TestSuite\\HttpClientTrait']); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Cake\\TestSuite\\ConsoleIntegrationTestTrait' => 'Cake\\Console\\TestSuite\\ConsoleIntegrationTestTrait', 'Cake\\TestSuite\\Stub\\ConsoleInput' => 'Cake\\Console\\TestSuite\\StubConsoleInput', 'Cake\\TestSuite\\Stub\\ConsoleOutput' => 'Cake\\Console\\TestSuite\\StubConsoleOutput', 'Cake\\TestSuite\\Stub\\MissingConsoleInputException' => 'Cake\\Console\\TestSuite\\MissingConsoleInputException', 'Cake\\TestSuite\\HttpClientTrait' => 'Cake\\Http\\TestSuite\\HttpClientTrait']); }; diff --git a/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-34.php b/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-34.php index dfb1cbb95d7..970f09bcf17 100644 --- a/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-34.php +++ b/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-34.php @@ -5,6 +5,6 @@ namespace RectorPrefix20220607; use Rector\CakePHP\Set\CakePHPSetList; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\CakePHP\Set\CakePHPSetList::CAKEPHP_30, \Rector\CakePHP\Set\CakePHPSetList::CAKEPHP_34]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([CakePHPSetList::CAKEPHP_30, CakePHPSetList::CAKEPHP_34]); }; diff --git a/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-35.php b/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-35.php index 1568f1c599a..dfa41069ce6 100644 --- a/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-35.php +++ b/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-35.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\CakePHP\Set\CakePHPLevelSetList; use Rector\CakePHP\Set\CakePHPSetList; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\CakePHP\Set\CakePHPSetList::CAKEPHP_35, \Rector\CakePHP\Set\CakePHPLevelSetList::UP_TO_CAKEPHP_34]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([CakePHPSetList::CAKEPHP_35, CakePHPLevelSetList::UP_TO_CAKEPHP_34]); }; diff --git a/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-36.php b/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-36.php index d85163a6170..a69a85f16bb 100644 --- a/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-36.php +++ b/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-36.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\CakePHP\Set\CakePHPLevelSetList; use Rector\CakePHP\Set\CakePHPSetList; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\CakePHP\Set\CakePHPSetList::CAKEPHP_36, \Rector\CakePHP\Set\CakePHPLevelSetList::UP_TO_CAKEPHP_35]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([CakePHPSetList::CAKEPHP_36, CakePHPLevelSetList::UP_TO_CAKEPHP_35]); }; diff --git a/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-37.php b/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-37.php index edfb0fc38bd..fc04ddef6a7 100644 --- a/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-37.php +++ b/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-37.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\CakePHP\Set\CakePHPLevelSetList; use Rector\CakePHP\Set\CakePHPSetList; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\CakePHP\Set\CakePHPSetList::CAKEPHP_37, \Rector\CakePHP\Set\CakePHPLevelSetList::UP_TO_CAKEPHP_36]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([CakePHPSetList::CAKEPHP_37, CakePHPLevelSetList::UP_TO_CAKEPHP_36]); }; diff --git a/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-38.php b/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-38.php index 22357b6114d..bee0e11a932 100644 --- a/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-38.php +++ b/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-38.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\CakePHP\Set\CakePHPLevelSetList; use Rector\CakePHP\Set\CakePHPSetList; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\CakePHP\Set\CakePHPSetList::CAKEPHP_38, \Rector\CakePHP\Set\CakePHPLevelSetList::UP_TO_CAKEPHP_37]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([CakePHPSetList::CAKEPHP_38, CakePHPLevelSetList::UP_TO_CAKEPHP_37]); }; diff --git a/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-40.php b/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-40.php index d97fd218336..37e10f5b26b 100644 --- a/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-40.php +++ b/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-40.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\CakePHP\Set\CakePHPLevelSetList; use Rector\CakePHP\Set\CakePHPSetList; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\CakePHP\Set\CakePHPSetList::CAKEPHP_40, \Rector\CakePHP\Set\CakePHPLevelSetList::UP_TO_CAKEPHP_38]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([CakePHPSetList::CAKEPHP_40, CakePHPLevelSetList::UP_TO_CAKEPHP_38]); }; diff --git a/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-41.php b/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-41.php index 21819574bff..a8cd91619e7 100644 --- a/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-41.php +++ b/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-41.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\CakePHP\Set\CakePHPLevelSetList; use Rector\CakePHP\Set\CakePHPSetList; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\CakePHP\Set\CakePHPSetList::CAKEPHP_41, \Rector\CakePHP\Set\CakePHPLevelSetList::UP_TO_CAKEPHP_40]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([CakePHPSetList::CAKEPHP_41, CakePHPLevelSetList::UP_TO_CAKEPHP_40]); }; diff --git a/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-42.php b/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-42.php index 2e719e28a51..9f91b7f2869 100644 --- a/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-42.php +++ b/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-42.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\CakePHP\Set\CakePHPLevelSetList; use Rector\CakePHP\Set\CakePHPSetList; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\CakePHP\Set\CakePHPSetList::CAKEPHP_42, \Rector\CakePHP\Set\CakePHPLevelSetList::UP_TO_CAKEPHP_41]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([CakePHPSetList::CAKEPHP_42, CakePHPLevelSetList::UP_TO_CAKEPHP_41]); }; diff --git a/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-43.php b/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-43.php index 62fea340949..bce7ea0ca50 100644 --- a/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-43.php +++ b/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-43.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\CakePHP\Set\CakePHPLevelSetList; use Rector\CakePHP\Set\CakePHPSetList; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\CakePHP\Set\CakePHPSetList::CAKEPHP_43, \Rector\CakePHP\Set\CakePHPLevelSetList::UP_TO_CAKEPHP_42]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([CakePHPSetList::CAKEPHP_43, CakePHPLevelSetList::UP_TO_CAKEPHP_42]); }; diff --git a/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-44.php b/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-44.php index 7314098034e..8f5ed046c06 100644 --- a/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-44.php +++ b/vendor/rector/rector-cakephp/config/sets/level/up-to-cakephp-44.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\CakePHP\Set\CakePHPLevelSetList; use Rector\CakePHP\Set\CakePHPSetList; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\CakePHP\Set\CakePHPSetList::CAKEPHP_44, \Rector\CakePHP\Set\CakePHPLevelSetList::UP_TO_CAKEPHP_43]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([CakePHPSetList::CAKEPHP_44, CakePHPLevelSetList::UP_TO_CAKEPHP_43]); }; diff --git a/vendor/rector/rector-cakephp/monorepo-builder.php b/vendor/rector/rector-cakephp/monorepo-builder.php index e4e22301995..544f64366de 100644 --- a/vendor/rector/rector-cakephp/monorepo-builder.php +++ b/vendor/rector/rector-cakephp/monorepo-builder.php @@ -3,12 +3,12 @@ declare (strict_types=1); namespace RectorPrefix20220607; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\PushTagReleaseWorker; use RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\TagVersionReleaseWorker; -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +return static function (ContainerConfigurator $containerConfigurator) : void { $services = $containerConfigurator->services(); // @see https://github.com/symplify/monorepo-builder#6-release-flow - $services->set(\RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\TagVersionReleaseWorker::class); - $services->set(\RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\PushTagReleaseWorker::class); + $services->set(TagVersionReleaseWorker::class); + $services->set(PushTagReleaseWorker::class); }; diff --git a/vendor/rector/rector-cakephp/rector.php b/vendor/rector/rector-cakephp/rector.php index 6fa3d88a410..661d69cc69b 100644 --- a/vendor/rector/rector-cakephp/rector.php +++ b/vendor/rector/rector-cakephp/rector.php @@ -7,14 +7,14 @@ use Rector\Config\RectorConfig; use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $rectorConfig->importNames(); $rectorConfig->paths([__DIR__ . '/src', __DIR__ . '/tests']); $rectorConfig->skip([ // for tests '*/Source/*', '*/Fixture/*', - \Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class => [__DIR__ . '/config'], + StringClassNameToClassConstantRector::class => [__DIR__ . '/config'], ]); - $rectorConfig->sets([\Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_81, \Rector\Set\ValueObject\SetList::DEAD_CODE, \Rector\Set\ValueObject\SetList::CODE_QUALITY, \Rector\Set\ValueObject\SetList::NAMING]); + $rectorConfig->sets([LevelSetList::UP_TO_PHP_81, SetList::DEAD_CODE, SetList::CODE_QUALITY, SetList::NAMING]); }; diff --git a/vendor/rector/rector-cakephp/src/Naming/CakePHPFullyQualifiedClassNameResolver.php b/vendor/rector/rector-cakephp/src/Naming/CakePHPFullyQualifiedClassNameResolver.php index cf362496c71..5cada01f8f1 100644 --- a/vendor/rector/rector-cakephp/src/Naming/CakePHPFullyQualifiedClassNameResolver.php +++ b/vendor/rector/rector-cakephp/src/Naming/CakePHPFullyQualifiedClassNameResolver.php @@ -37,7 +37,7 @@ final class CakePHPFullyQualifiedClassNameResolver * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\CakePHP\ImplicitNameResolver $implicitNameResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(ImplicitNameResolver $implicitNameResolver, ReflectionProvider $reflectionProvider) { $this->implicitNameResolver = $implicitNameResolver; $this->reflectionProvider = $reflectionProvider; @@ -55,8 +55,8 @@ final class CakePHPFullyQualifiedClassNameResolver } // Chop Lib out as locations moves those files to the top level. // But only if Lib is not the last folder. - if (\Rector\Core\Util\StringUtils::isMatch($pseudoNamespace, self::LIB_NAMESPACE_PART_REGEX)) { - $pseudoNamespace = \RectorPrefix20220607\Nette\Utils\Strings::replace($pseudoNamespace, '#\\\\Lib#', ''); + if (StringUtils::isMatch($pseudoNamespace, self::LIB_NAMESPACE_PART_REGEX)) { + $pseudoNamespace = Strings::replace($pseudoNamespace, '#\\\\Lib#', ''); } // B. is Cake native class? $cakePhpVersion = 'Cake\\' . $pseudoNamespace . '\\' . $shortClass; @@ -64,13 +64,13 @@ final class CakePHPFullyQualifiedClassNameResolver return $cakePhpVersion; } // C. is not plugin nor lib custom App class? - if (\strpos($pseudoNamespace, '\\') !== \false && !\Rector\Core\Util\StringUtils::isMatch($pseudoNamespace, self::PLUGIN_OR_LIB_REGEX)) { + if (\strpos($pseudoNamespace, '\\') !== \false && !StringUtils::isMatch($pseudoNamespace, self::PLUGIN_OR_LIB_REGEX)) { return 'App\\' . $pseudoNamespace . '\\' . $shortClass; } return $pseudoNamespace . '\\' . $shortClass; } private function normalizeFileSystemSlashes(string $pseudoNamespace) : string { - return \RectorPrefix20220607\Nette\Utils\Strings::replace($pseudoNamespace, self::SLASH_REGEX, '\\'); + return Strings::replace($pseudoNamespace, self::SLASH_REGEX, '\\'); } } diff --git a/vendor/rector/rector-cakephp/src/Rector/MethodCall/ArrayToFluentCallRector.php b/vendor/rector/rector-cakephp/src/Rector/MethodCall/ArrayToFluentCallRector.php index 4caae6cad7e..fb3798e6000 100644 --- a/vendor/rector/rector-cakephp/src/Rector/MethodCall/ArrayToFluentCallRector.php +++ b/vendor/rector/rector-cakephp/src/Rector/MethodCall/ArrayToFluentCallRector.php @@ -13,13 +13,13 @@ use Rector\CakePHP\ValueObject\ArrayToFluentCall; use Rector\CakePHP\ValueObject\FactoryMethod; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\CakePHP\Tests\Rector\MethodCall\ArrayToFluentCallRector\ArrayToFluentCallRectorTest */ -final class ArrayToFluentCallRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class ArrayToFluentCallRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var string @@ -37,9 +37,9 @@ final class ArrayToFluentCallRector extends \Rector\Core\Rector\AbstractRector i * @var FactoryMethod[] */ private $factoryMethods = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Moves array options to fluent setter method calls.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Moves array options to fluent setter method calls.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' use Cake\ORM\Table; final class ArticlesTable extends Table @@ -66,22 +66,22 @@ final class ArticlesTable extends Table } } CODE_SAMPLE -, [self::ARRAYS_TO_FLUENT_CALLS => [new \Rector\CakePHP\ValueObject\ArrayToFluentCall('ArticlesTable', ['foreignKey' => 'setForeignKey', 'propertyName' => 'setProperty'])]])]); +, [self::ARRAYS_TO_FLUENT_CALLS => [new ArrayToFluentCall('ArticlesTable', ['foreignKey' => 'setForeignKey', 'propertyName' => 'setProperty'])]])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $factoryMethod = $this->matchTypeAndMethodName($node); - if (!$factoryMethod instanceof \Rector\CakePHP\ValueObject\FactoryMethod) { + if (!$factoryMethod instanceof FactoryMethod) { return null; } foreach ($this->arraysToFluentCalls as $arrayToFluentCall) { @@ -98,15 +98,15 @@ CODE_SAMPLE public function configure(array $configuration) : void { $arraysToFluentCalls = $configuration[self::ARRAYS_TO_FLUENT_CALLS] ?? []; - \RectorPrefix20220607\Webmozart\Assert\Assert::isArray($arraysToFluentCalls); - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsInstanceOf($arraysToFluentCalls, \Rector\CakePHP\ValueObject\ArrayToFluentCall::class); + Assert::isArray($arraysToFluentCalls); + Assert::allIsInstanceOf($arraysToFluentCalls, ArrayToFluentCall::class); $this->arraysToFluentCalls = $arraysToFluentCalls; $factoryMethods = $configuration[self::FACTORY_METHODS] ?? []; - \RectorPrefix20220607\Webmozart\Assert\Assert::isArray($factoryMethods); - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsInstanceOf($factoryMethods, \Rector\CakePHP\ValueObject\FactoryMethod::class); + Assert::isArray($factoryMethods); + Assert::allIsInstanceOf($factoryMethods, FactoryMethod::class); $this->factoryMethods = $factoryMethods; } - private function matchTypeAndMethodName(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\Rector\CakePHP\ValueObject\FactoryMethod + private function matchTypeAndMethodName(MethodCall $methodCall) : ?FactoryMethod { foreach ($this->factoryMethods as $factoryMethod) { if (!$this->isObjectType($methodCall->var, $factoryMethod->getObjectType())) { @@ -119,13 +119,13 @@ CODE_SAMPLE } return null; } - private function replaceArrayToFluentMethodCalls(\PhpParser\Node\Expr\MethodCall $methodCall, int $argumentPosition, \Rector\CakePHP\ValueObject\ArrayToFluentCall $arrayToFluentCall) : ?\PhpParser\Node\Expr\MethodCall + private function replaceArrayToFluentMethodCalls(MethodCall $methodCall, int $argumentPosition, ArrayToFluentCall $arrayToFluentCall) : ?MethodCall { if (\count($methodCall->args) !== $argumentPosition) { return null; } $argumentValue = $methodCall->args[$argumentPosition - 1]->value; - if (!$argumentValue instanceof \PhpParser\Node\Expr\Array_) { + if (!$argumentValue instanceof Array_) { return null; } $arrayItemsAndFluentClass = $this->extractFluentMethods($argumentValue->items, $arrayToFluentCall->getArrayKeysToFluentCalls()); @@ -149,7 +149,7 @@ CODE_SAMPLE * @param array $originalArrayItems * @param array $arrayMap */ - private function extractFluentMethods(array $originalArrayItems, array $arrayMap) : \Rector\CakePHP\ValueObject\ArrayItemsAndFluentClass + private function extractFluentMethods(array $originalArrayItems, array $arrayMap) : ArrayItemsAndFluentClass { $newArrayItems = []; $fluentCalls = []; @@ -158,7 +158,7 @@ CODE_SAMPLE continue; } $key = $originalArrayItem->key; - if ($key instanceof \PhpParser\Node\Scalar\String_ && isset($arrayMap[$key->value])) { + if ($key instanceof String_ && isset($arrayMap[$key->value])) { /** @var string $methodName */ $methodName = $arrayMap[$key->value]; $fluentCalls[$methodName] = $originalArrayItem->value; @@ -166,6 +166,6 @@ CODE_SAMPLE $newArrayItems[] = $originalArrayItem; } } - return new \Rector\CakePHP\ValueObject\ArrayItemsAndFluentClass($newArrayItems, $fluentCalls); + return new ArrayItemsAndFluentClass($newArrayItems, $fluentCalls); } } diff --git a/vendor/rector/rector-cakephp/src/Rector/MethodCall/ModalToGetSetRector.php b/vendor/rector/rector-cakephp/src/Rector/MethodCall/ModalToGetSetRector.php index ed9a7f5d492..dee11586132 100644 --- a/vendor/rector/rector-cakephp/src/Rector/MethodCall/ModalToGetSetRector.php +++ b/vendor/rector/rector-cakephp/src/Rector/MethodCall/ModalToGetSetRector.php @@ -10,8 +10,8 @@ use PhpParser\Node\Identifier; use Rector\CakePHP\ValueObject\ModalToGetSet; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see https://book.cakephp.org/3.0/en/appendices/3-4-migration-guide.html#deprecated-combined-get-set-methods @@ -19,7 +19,7 @@ use RectorPrefix20220607\Webmozart\Assert\Assert; * * @see \Rector\CakePHP\Tests\Rector\MethodCall\ModalToGetSetRector\ModalToGetSetRectorTest */ -final class ModalToGetSetRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class ModalToGetSetRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var string @@ -29,9 +29,9 @@ final class ModalToGetSetRector extends \Rector\Core\Rector\AbstractRector imple * @var ModalToGetSet[] */ private $unprefixedMethodsToGetSet = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes combined set/get `value()` to specific `getValue()` or `setValue(x)`.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes combined set/get `value()` to specific `getValue()` or `setValue(x)`.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' $object = new InstanceConfigTrait; $config = $object->config(); @@ -49,26 +49,26 @@ $config = $object->getConfig('key'); $object->setConfig('key', 'value'); $object->setConfig(['key' => 'value']); CODE_SAMPLE -, [self::UNPREFIXED_METHODS_TO_GET_SET => [new \Rector\CakePHP\ValueObject\ModalToGetSet('InstanceConfigTrait', 'config', 'getConfig', 'setConfig')]])]); +, [self::UNPREFIXED_METHODS_TO_GET_SET => [new ModalToGetSet('InstanceConfigTrait', 'config', 'getConfig', 'setConfig')]])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $modalToGetSet = $this->matchTypeAndMethodName($node); - if (!$modalToGetSet instanceof \Rector\CakePHP\ValueObject\ModalToGetSet) { + if (!$modalToGetSet instanceof ModalToGetSet) { return null; } $newName = $this->resolveNewMethodNameByCondition($node, $modalToGetSet); - $node->name = new \PhpParser\Node\Identifier($newName); + $node->name = new Identifier($newName); return $node; } /** @@ -77,11 +77,11 @@ CODE_SAMPLE public function configure(array $configuration) : void { $unprefixedMethodsToGetSet = $configuration[self::UNPREFIXED_METHODS_TO_GET_SET] ?? $configuration; - \RectorPrefix20220607\Webmozart\Assert\Assert::isArray($unprefixedMethodsToGetSet); - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($unprefixedMethodsToGetSet, \Rector\CakePHP\ValueObject\ModalToGetSet::class); + Assert::isArray($unprefixedMethodsToGetSet); + Assert::allIsAOf($unprefixedMethodsToGetSet, ModalToGetSet::class); $this->unprefixedMethodsToGetSet = $unprefixedMethodsToGetSet; } - private function matchTypeAndMethodName(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\Rector\CakePHP\ValueObject\ModalToGetSet + private function matchTypeAndMethodName(MethodCall $methodCall) : ?ModalToGetSet { foreach ($this->unprefixedMethodsToGetSet as $unprefixedMethodToGetSet) { if (!$this->isObjectType($methodCall->var, $unprefixedMethodToGetSet->getObjectType())) { @@ -94,7 +94,7 @@ CODE_SAMPLE } return null; } - private function resolveNewMethodNameByCondition(\PhpParser\Node\Expr\MethodCall $methodCall, \Rector\CakePHP\ValueObject\ModalToGetSet $modalToGetSet) : string + private function resolveNewMethodNameByCondition(MethodCall $methodCall, ModalToGetSet $modalToGetSet) : string { if (\count($methodCall->args) >= $modalToGetSet->getMinimalSetterArgumentCount()) { return $modalToGetSet->getSetMethod(); @@ -108,7 +108,7 @@ CODE_SAMPLE } $firstArgumentType = $modalToGetSet->getFirstArgumentType(); $argumentValue = $methodCall->args[0]->value; - if ($firstArgumentType === 'array' && $argumentValue instanceof \PhpParser\Node\Expr\Array_) { + if ($firstArgumentType === 'array' && $argumentValue instanceof Array_) { return $modalToGetSet->getSetMethod(); } return $modalToGetSet->getGetMethod(); diff --git a/vendor/rector/rector-cakephp/src/Rector/MethodCall/RemoveIntermediaryMethodRector.php b/vendor/rector/rector-cakephp/src/Rector/MethodCall/RemoveIntermediaryMethodRector.php index d1c22138669..44b72928593 100644 --- a/vendor/rector/rector-cakephp/src/Rector/MethodCall/RemoveIntermediaryMethodRector.php +++ b/vendor/rector/rector-cakephp/src/Rector/MethodCall/RemoveIntermediaryMethodRector.php @@ -11,8 +11,8 @@ use Rector\CakePHP\ValueObject\RemoveIntermediaryMethod; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see https://book.cakephp.org/3.0/en/appendices/3-4-migration-guide.html#deprecated-combined-get-set-methods @@ -20,7 +20,7 @@ use RectorPrefix20220607\Webmozart\Assert\Assert; * * @see \Rector\CakePHP\Tests\Rector\MethodCall\ModalToGetSetRector\ModalToGetSetRectorTest */ -final class RemoveIntermediaryMethodRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RemoveIntermediaryMethodRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var string @@ -35,40 +35,40 @@ final class RemoveIntermediaryMethodRector extends \Rector\Core\Rector\AbstractR * @var \Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer */ private $fluentChainMethodCallNodeAnalyzer; - public function __construct(\Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer $fluentChainMethodCallNodeAnalyzer) + public function __construct(FluentChainMethodCallNodeAnalyzer $fluentChainMethodCallNodeAnalyzer) { $this->fluentChainMethodCallNodeAnalyzer = $fluentChainMethodCallNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Removes an intermediary method call for when a higher level API is added.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Removes an intermediary method call for when a higher level API is added.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' $users = $this->getTableLocator()->get('Users'); CODE_SAMPLE , <<<'CODE_SAMPLE' $users = $this->fetchTable('Users'); CODE_SAMPLE -, [self::REMOVE_INTERMEDIARY_METHOD => [new \Rector\CakePHP\ValueObject\RemoveIntermediaryMethod('getTableLocator', 'get', 'fetchTable')]])]); +, [self::REMOVE_INTERMEDIARY_METHOD => [new RemoveIntermediaryMethod('getTableLocator', 'get', 'fetchTable')]])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $removeIntermediaryMethod = $this->matchTypeAndMethodName($node); - if (!$removeIntermediaryMethod instanceof \Rector\CakePHP\ValueObject\RemoveIntermediaryMethod) { + if (!$removeIntermediaryMethod instanceof RemoveIntermediaryMethod) { return null; } /** @var MethodCall $var */ $var = $node->var; $target = $var->var; - return new \PhpParser\Node\Expr\MethodCall($target, $removeIntermediaryMethod->getFinalMethod(), $node->args); + return new MethodCall($target, $removeIntermediaryMethod->getFinalMethod(), $node->args); } /** * @param mixed[] $configuration @@ -76,17 +76,17 @@ CODE_SAMPLE public function configure(array $configuration) : void { $removeIntermediaryMethods = $configuration[self::REMOVE_INTERMEDIARY_METHOD] ?? $configuration; - \RectorPrefix20220607\Webmozart\Assert\Assert::isArray($removeIntermediaryMethods); - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($removeIntermediaryMethods, \Rector\CakePHP\ValueObject\RemoveIntermediaryMethod::class); + Assert::isArray($removeIntermediaryMethods); + Assert::allIsAOf($removeIntermediaryMethods, RemoveIntermediaryMethod::class); $this->removeIntermediaryMethod = $removeIntermediaryMethods; } - private function matchTypeAndMethodName(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\Rector\CakePHP\ValueObject\RemoveIntermediaryMethod + private function matchTypeAndMethodName(MethodCall $methodCall) : ?RemoveIntermediaryMethod { $rootMethodCall = $this->fluentChainMethodCallNodeAnalyzer->resolveRootMethodCall($methodCall); - if (!$rootMethodCall instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$rootMethodCall instanceof MethodCall) { return null; } - if (!$rootMethodCall->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$rootMethodCall->var instanceof Variable) { return null; } if (!$this->nodeNameResolver->isName($rootMethodCall->var, 'this')) { @@ -94,7 +94,7 @@ CODE_SAMPLE } /** @var MethodCall $var */ $var = $methodCall->var; - if (!$methodCall->name instanceof \PhpParser\Node\Identifier || !$var->name instanceof \PhpParser\Node\Identifier) { + if (!$methodCall->name instanceof Identifier || !$var->name instanceof Identifier) { return null; } foreach ($this->removeIntermediaryMethod as $singleRemoveIntermediaryMethod) { diff --git a/vendor/rector/rector-cakephp/src/Rector/MethodCall/RenameMethodCallBasedOnParameterRector.php b/vendor/rector/rector-cakephp/src/Rector/MethodCall/RenameMethodCallBasedOnParameterRector.php index 8879af7c48a..c58db236d2c 100644 --- a/vendor/rector/rector-cakephp/src/Rector/MethodCall/RenameMethodCallBasedOnParameterRector.php +++ b/vendor/rector/rector-cakephp/src/Rector/MethodCall/RenameMethodCallBasedOnParameterRector.php @@ -9,8 +9,8 @@ use PhpParser\Node\Identifier; use Rector\CakePHP\ValueObject\RenameMethodCallBasedOnParameter; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see https://book.cakephp.org/4.0/en/appendices/4-0-migration-guide.html @@ -18,7 +18,7 @@ use RectorPrefix20220607\Webmozart\Assert\Assert; * * @see \Rector\CakePHP\Tests\Rector\MethodCall\RenameMethodCallBasedOnParameterRector\RenameMethodCallBasedOnParameterRectorTest */ -final class RenameMethodCallBasedOnParameterRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RenameMethodCallBasedOnParameterRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var string @@ -28,10 +28,10 @@ final class RenameMethodCallBasedOnParameterRector extends \Rector\Core\Rector\A * @var RenameMethodCallBasedOnParameter[] */ private $callsWithParamRenames = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - $configuration = [self::CALLS_WITH_PARAM_RENAMES => [new \Rector\CakePHP\ValueObject\RenameMethodCallBasedOnParameter('ServerRequest', 'getParam', 'paging', 'getAttribute'), new \Rector\CakePHP\ValueObject\RenameMethodCallBasedOnParameter('ServerRequest', 'withParam', 'paging', 'withAttribute')]]; - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes method calls based on matching the first parameter value.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + $configuration = [self::CALLS_WITH_PARAM_RENAMES => [new RenameMethodCallBasedOnParameter('ServerRequest', 'getParam', 'paging', 'getAttribute'), new RenameMethodCallBasedOnParameter('ServerRequest', 'withParam', 'paging', 'withAttribute')]]; + return new RuleDefinition('Changes method calls based on matching the first parameter value.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' $object = new ServerRequest(); $config = $object->getParam('paging'); @@ -50,18 +50,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $renameMethodCallBasedOnParameter = $this->matchTypeAndMethodName($node); - if (!$renameMethodCallBasedOnParameter instanceof \Rector\CakePHP\ValueObject\RenameMethodCallBasedOnParameter) { + if (!$renameMethodCallBasedOnParameter instanceof RenameMethodCallBasedOnParameter) { return null; } - $node->name = new \PhpParser\Node\Identifier($renameMethodCallBasedOnParameter->getNewMethod()); + $node->name = new Identifier($renameMethodCallBasedOnParameter->getNewMethod()); return $node; } /** @@ -70,11 +70,11 @@ CODE_SAMPLE public function configure(array $configuration) : void { $callsWithParamRenames = $configuration[self::CALLS_WITH_PARAM_RENAMES] ?? $configuration; - \RectorPrefix20220607\Webmozart\Assert\Assert::isArray($callsWithParamRenames); - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsInstanceOf($callsWithParamRenames, \Rector\CakePHP\ValueObject\RenameMethodCallBasedOnParameter::class); + Assert::isArray($callsWithParamRenames); + Assert::allIsInstanceOf($callsWithParamRenames, RenameMethodCallBasedOnParameter::class); $this->callsWithParamRenames = $callsWithParamRenames; } - private function matchTypeAndMethodName(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\Rector\CakePHP\ValueObject\RenameMethodCallBasedOnParameter + private function matchTypeAndMethodName(MethodCall $methodCall) : ?RenameMethodCallBasedOnParameter { if (\count($methodCall->args) < 1) { return null; diff --git a/vendor/rector/rector-cakephp/src/Rector/Namespace_/AppUsesStaticCallToUseStatementRector.php b/vendor/rector/rector-cakephp/src/Rector/Namespace_/AppUsesStaticCallToUseStatementRector.php index 1aab5c437e7..c66ec105548 100644 --- a/vendor/rector/rector-cakephp/src/Rector/Namespace_/AppUsesStaticCallToUseStatementRector.php +++ b/vendor/rector/rector-cakephp/src/Rector/Namespace_/AppUsesStaticCallToUseStatementRector.php @@ -12,28 +12,28 @@ use PHPStan\Type\ObjectType; use Rector\CakePHP\Naming\CakePHPFullyQualifiedClassNameResolver; use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/cakephp/upgrade/blob/756410c8b7d5aff9daec3fa1fe750a3858d422ac/src/Shell/Task/AppUsesTask.php * @see https://github.com/cakephp/upgrade/search?q=uses&unscoped_q=uses * * @see \Rector\CakePHP\Tests\Rector\Namespace_\AppUsesStaticCallToUseStatementRector\AppUsesStaticCallToUseStatementRectorTest */ -final class AppUsesStaticCallToUseStatementRector extends \Rector\Core\Rector\AbstractRector +final class AppUsesStaticCallToUseStatementRector extends AbstractRector { /** * @readonly * @var \Rector\CakePHP\Naming\CakePHPFullyQualifiedClassNameResolver */ private $cakePHPFullyQualifiedClassNameResolver; - public function __construct(\Rector\CakePHP\Naming\CakePHPFullyQualifiedClassNameResolver $cakePHPFullyQualifiedClassNameResolver) + public function __construct(CakePHPFullyQualifiedClassNameResolver $cakePHPFullyQualifiedClassNameResolver) { $this->cakePHPFullyQualifiedClassNameResolver = $cakePHPFullyQualifiedClassNameResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change App::uses() to use imports', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change App::uses() to use imports', [new CodeSample(<<<'CODE_SAMPLE' App::uses('NotificationListener', 'Event'); CakeEventManager::instance()->attach(new NotificationListener()); @@ -50,12 +50,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace::class, \PhpParser\Node\Stmt\Namespace_::class]; + return [FileWithoutNamespace::class, Namespace_::class]; } /** * @param FileWithoutNamespace|Namespace_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $appUsesStaticCalls = $this->collectAppUseStaticCalls($node); if ($appUsesStaticCalls === []) { @@ -64,7 +64,7 @@ CODE_SAMPLE $this->nodeRemover->removeNodes($appUsesStaticCalls); $names = $this->resolveNamesFromStaticCalls($appUsesStaticCalls); $uses = $this->nodeFactory->createUsesFromNames($names); - if ($node instanceof \PhpParser\Node\Stmt\Namespace_) { + if ($node instanceof Namespace_) { $node->stmts = \array_merge($uses, $node->stmts); return $node; } @@ -73,15 +73,15 @@ CODE_SAMPLE /** * @return StaticCall[] */ - private function collectAppUseStaticCalls(\PhpParser\Node $node) : array + private function collectAppUseStaticCalls(Node $node) : array { /** @var StaticCall[] $appUsesStaticCalls */ - $appUsesStaticCalls = $this->betterNodeFinder->find($node, function (\PhpParser\Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Expr\StaticCall) { + $appUsesStaticCalls = $this->betterNodeFinder->find($node, function (Node $node) : bool { + if (!$node instanceof StaticCall) { return \false; } $callerType = $this->nodeTypeResolver->getType($node->class); - if (!$callerType->isSuperTypeOf(new \PHPStan\Type\ObjectType('App'))->yes()) { + if (!$callerType->isSuperTypeOf(new ObjectType('App'))->yes()) { return \false; } return $this->isName($node->name, 'uses'); @@ -103,21 +103,21 @@ CODE_SAMPLE /** * @param Use_[] $uses */ - private function refactorFile(\Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace $fileWithoutNamespace, array $uses) : ?\Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace + private function refactorFile(FileWithoutNamespace $fileWithoutNamespace, array $uses) : ?FileWithoutNamespace { - $hasNamespace = $this->betterNodeFinder->findFirstInstanceOf($fileWithoutNamespace, \PhpParser\Node\Stmt\Namespace_::class); + $hasNamespace = $this->betterNodeFinder->findFirstInstanceOf($fileWithoutNamespace, Namespace_::class); // already handled above if ($hasNamespace !== null) { return null; } - $hasDeclare = $this->betterNodeFinder->findFirstInstanceOf($fileWithoutNamespace, \PhpParser\Node\Stmt\Declare_::class); + $hasDeclare = $this->betterNodeFinder->findFirstInstanceOf($fileWithoutNamespace, Declare_::class); if ($hasDeclare !== null) { return $this->refactorFileWithDeclare($fileWithoutNamespace, $uses); } $fileWithoutNamespace->stmts = \array_merge($uses, $fileWithoutNamespace->stmts); return $fileWithoutNamespace; } - private function createFullyQualifiedNameFromAppUsesStaticCall(\PhpParser\Node\Expr\StaticCall $staticCall) : string + private function createFullyQualifiedNameFromAppUsesStaticCall(StaticCall $staticCall) : string { /** @var string $shortClassName */ $shortClassName = $this->valueResolver->getValue($staticCall->args[0]->value); @@ -128,18 +128,18 @@ CODE_SAMPLE /** * @param Use_[] $uses */ - private function refactorFileWithDeclare(\Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace $fileWithoutNamespace, array $uses) : \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace + private function refactorFileWithDeclare(FileWithoutNamespace $fileWithoutNamespace, array $uses) : FileWithoutNamespace { $newStmts = []; foreach ($fileWithoutNamespace->stmts as $stmt) { $newStmts[] = $stmt; - if ($stmt instanceof \PhpParser\Node\Stmt\Declare_) { + if ($stmt instanceof Declare_) { foreach ($uses as $use) { $newStmts[] = $use; } continue; } } - return new \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace($newStmts); + return new FileWithoutNamespace($newStmts); } } diff --git a/vendor/rector/rector-cakephp/src/Rector/Property/ChangeSnakedFixtureNameToPascalRector.php b/vendor/rector/rector-cakephp/src/Rector/Property/ChangeSnakedFixtureNameToPascalRector.php index 0009384360a..f7e226ba4a0 100644 --- a/vendor/rector/rector-cakephp/src/Rector/Property/ChangeSnakedFixtureNameToPascalRector.php +++ b/vendor/rector/rector-cakephp/src/Rector/Property/ChangeSnakedFixtureNameToPascalRector.php @@ -12,18 +12,18 @@ use PhpParser\Node\Stmt\Property; use PhpParser\Node\Stmt\PropertyProperty; use Rector\Core\Rector\AbstractRector; use RectorPrefix20220607\Symfony\Component\String\UnicodeString; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\CakePHP\Tests\Rector\Property\ChangeSnakedFixtureNameToPascal\ChangeSnakedFixtureNameToPascalTest * * @see https://book.cakephp.org/3.0/en/appendices/3-7-migration-guide.html */ -final class ChangeSnakedFixtureNameToPascalRector extends \Rector\Core\Rector\AbstractRector +final class ChangeSnakedFixtureNameToPascalRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes $fixtures style from snake_case to PascalCase.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes $fixtures style from snake_case to PascalCase.', [new CodeSample(<<<'CODE_SAMPLE' class SomeTest { protected $fixtures = [ @@ -48,15 +48,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($node, ClassLike::class); + if (!$classLike instanceof ClassLike) { return null; } if (!$this->isName($node, 'fixtures')) { @@ -67,29 +67,29 @@ CODE_SAMPLE } return $node; } - private function refactorPropertyWithArrayDefault(\PhpParser\Node\Stmt\PropertyProperty $propertyProperty) : void + private function refactorPropertyWithArrayDefault(PropertyProperty $propertyProperty) : void { - if (!$propertyProperty->default instanceof \PhpParser\Node\Expr\Array_) { + if (!$propertyProperty->default instanceof Array_) { return; } $array = $propertyProperty->default; foreach ($array->items as $arrayItem) { - if (!$arrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$arrayItem instanceof ArrayItem) { continue; } $itemValue = $arrayItem->value; - if (!$itemValue instanceof \PhpParser\Node\Scalar\String_) { + if (!$itemValue instanceof String_) { continue; } $this->renameFixtureName($itemValue); } } - private function renameFixtureName(\PhpParser\Node\Scalar\String_ $string) : void + private function renameFixtureName(String_ $string) : void { [$prefix, $table] = \explode('.', $string->value); $tableParts = \explode('/', $table); $pascalCaseTableParts = \array_map(function (string $token) : string { - $tokenUnicodeString = new \RectorPrefix20220607\Symfony\Component\String\UnicodeString($token); + $tokenUnicodeString = new UnicodeString($token); return \ucfirst($tokenUnicodeString->camel()->toString()); }, $tableParts); $table = \implode('/', $pascalCaseTableParts); diff --git a/vendor/rector/rector-cakephp/src/Set/CakePHPLevelSetList.php b/vendor/rector/rector-cakephp/src/Set/CakePHPLevelSetList.php index cd0094b16d8..e38d4bafd21 100644 --- a/vendor/rector/rector-cakephp/src/Set/CakePHPLevelSetList.php +++ b/vendor/rector/rector-cakephp/src/Set/CakePHPLevelSetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\CakePHP\Set; use Rector\Set\Contract\SetListInterface; -final class CakePHPLevelSetList implements \Rector\Set\Contract\SetListInterface +final class CakePHPLevelSetList implements SetListInterface { /** * @var string diff --git a/vendor/rector/rector-cakephp/src/Set/CakePHPSetList.php b/vendor/rector/rector-cakephp/src/Set/CakePHPSetList.php index 1a8ec7f2c25..eb66ce26852 100644 --- a/vendor/rector/rector-cakephp/src/Set/CakePHPSetList.php +++ b/vendor/rector/rector-cakephp/src/Set/CakePHPSetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\CakePHP\Set; use Rector\Set\Contract\SetListInterface; -final class CakePHPSetList implements \Rector\Set\Contract\SetListInterface +final class CakePHPSetList implements SetListInterface { /** * @var string diff --git a/vendor/rector/rector-cakephp/src/ValueObject/FactoryMethod.php b/vendor/rector/rector-cakephp/src/ValueObject/FactoryMethod.php index 2048c41772e..997aa4714c1 100644 --- a/vendor/rector/rector-cakephp/src/ValueObject/FactoryMethod.php +++ b/vendor/rector/rector-cakephp/src/ValueObject/FactoryMethod.php @@ -33,9 +33,9 @@ final class FactoryMethod $this->newClass = $newClass; $this->position = $position; } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->type); + return new ObjectType($this->type); } public function getMethod() : string { diff --git a/vendor/rector/rector-cakephp/src/ValueObject/ModalToGetSet.php b/vendor/rector/rector-cakephp/src/ValueObject/ModalToGetSet.php index 155ce9171bf..8d658674933 100644 --- a/vendor/rector/rector-cakephp/src/ValueObject/ModalToGetSet.php +++ b/vendor/rector/rector-cakephp/src/ValueObject/ModalToGetSet.php @@ -45,9 +45,9 @@ final class ModalToGetSet $this->getMethod = $getMethod ?? 'get' . \ucfirst($unprefixedMethod); $this->setMethod = $setMethod ?? 'set' . \ucfirst($unprefixedMethod); } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->type); + return new ObjectType($this->type); } public function getUnprefixedMethod() : string { diff --git a/vendor/rector/rector-cakephp/src/ValueObject/RenameMethodCallBasedOnParameter.php b/vendor/rector/rector-cakephp/src/ValueObject/RenameMethodCallBasedOnParameter.php index bac63b8cd74..22048e1aaf4 100644 --- a/vendor/rector/rector-cakephp/src/ValueObject/RenameMethodCallBasedOnParameter.php +++ b/vendor/rector/rector-cakephp/src/ValueObject/RenameMethodCallBasedOnParameter.php @@ -45,8 +45,8 @@ final class RenameMethodCallBasedOnParameter { return $this->newMethod; } - public function getOldObjectType() : \PHPStan\Type\ObjectType + public function getOldObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->oldClass); + return new ObjectType($this->oldClass); } } diff --git a/vendor/rector/rector-doctrine/config/config.php b/vendor/rector/rector-doctrine/config/config.php index b0f5a398748..bfdc9f4a4d2 100644 --- a/vendor/rector/rector-doctrine/config/config.php +++ b/vendor/rector/rector-doctrine/config/config.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace RectorPrefix20220607; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $services = $rectorConfig->services(); $services->defaults()->public()->autowire()->autoconfigure(); $services->load('Rector\\Doctrine\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/Rector', __DIR__ . '/../src/ValueObject']); diff --git a/vendor/rector/rector-doctrine/config/sets/doctrine-annotations-to-attributes.php b/vendor/rector/rector-doctrine/config/sets/doctrine-annotations-to-attributes.php index cbb0aefbfc0..c9402b52a1d 100644 --- a/vendor/rector/rector-doctrine/config/sets/doctrine-annotations-to-attributes.php +++ b/vendor/rector/rector-doctrine/config/sets/doctrine-annotations-to-attributes.php @@ -6,50 +6,50 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; use Rector\Php80\ValueObject\AnnotationToAttribute; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [ // class - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\Table'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\Entity'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\Column'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\UniqueConstraint'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\Table'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\Entity'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\Column'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\UniqueConstraint'), // id - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\Id'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\GeneratedValue'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\SequenceGenerator'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\Index'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\CustomIdGenerator'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\Id'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\GeneratedValue'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\SequenceGenerator'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\Index'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\CustomIdGenerator'), // relations - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\OneToOne'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\OneToMany'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\ManyToMany'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\JoinTable'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\ManyToOne'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\OneToOne'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\OneToMany'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\ManyToMany'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\JoinTable'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\ManyToOne'), // join columns - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\JoinColumns'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\JoinColumn'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\InverseJoinColumn'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\OrderBy'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\JoinColumns'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\JoinColumn'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\InverseJoinColumn'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\OrderBy'), // embed - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\Embeddable'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\Embedded'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\Embeddable'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\Embedded'), // inheritance - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\MappedSuperclass'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\InheritanceType'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\DiscriminatorColumn'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\DiscriminatorMap'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\Version'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\ChangeTrackingPolicy'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\MappedSuperclass'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\InheritanceType'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\DiscriminatorColumn'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\DiscriminatorMap'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\Version'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\ChangeTrackingPolicy'), // events - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\HasLifecycleCallbacks'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\PostLoad'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\PostPersist'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\PostRemove'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\PostUpdate'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\PrePersist'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\PreRemove'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\PreUpdate'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\Cache'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\EntityListeners'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\HasLifecycleCallbacks'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\PostLoad'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\PostPersist'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\PostRemove'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\PostUpdate'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\PrePersist'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\PreRemove'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\PreUpdate'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\Cache'), + new AnnotationToAttribute('Doctrine\\ORM\\Mapping\\EntityListeners'), ]); }; diff --git a/vendor/rector/rector-doctrine/config/sets/doctrine-behaviors-20.php b/vendor/rector/rector-doctrine/config/sets/doctrine-behaviors-20.php index d45d24c808c..de55c980d52 100644 --- a/vendor/rector/rector-doctrine/config/sets/doctrine-behaviors-20.php +++ b/vendor/rector/rector-doctrine/config/sets/doctrine-behaviors-20.php @@ -7,9 +7,9 @@ use Rector\Config\RectorConfig; use Rector\Doctrine\Rector\Class_\AddEntityIdByConditionRector; use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Transform\Rector\Class_\AddInterfaceByTraitRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\Class_\AddInterfaceByTraitRector::class, ['Knp\\DoctrineBehaviors\\Model\\Timestampable\\Timestampable' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\TimestampableInterface', 'Knp\\DoctrineBehaviors\\Model\\Timestampable\\TimestampableMethods' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\TimestampableInterface', 'Knp\\DoctrineBehaviors\\Model\\Blameable\\Blameable' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\BlameableInterface', 'Knp\\DoctrineBehaviors\\Model\\Blameable\\BlameableMethods' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\BlameableInterface', 'Knp\\DoctrineBehaviors\\Model\\Loggable\\Loggable' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\LoggableInterface', 'Knp\\DoctrineBehaviors\\Model\\SoftDeletable\\SoftDeletable' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\SoftDeletableInterface', 'Knp\\DoctrineBehaviors\\Model\\SoftDeletable\\SoftDeletableMethodsTrait' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\SoftDeletableInterface', 'Knp\\DoctrineBehaviors\\Model\\Translatable\\Translatable' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\TranslatableInterface', 'Knp\\DoctrineBehaviors\\Model\\Translatable\\TranslatableMethods' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\TranslatableInterface', 'Knp\\DoctrineBehaviors\\Model\\Translatable\\Translation' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\TranslationInterface', 'Knp\\DoctrineBehaviors\\Model\\Translatable\\TranslationMethods' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\TranslationInterface', 'Knp\\DoctrineBehaviors\\Model\\Uuidable\\Uuidable' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\UuidableInterface', 'Knp\\DoctrineBehaviors\\Model\\Uuidable\\UuidableMethods' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\UuidableInterface']); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(AddInterfaceByTraitRector::class, ['Knp\\DoctrineBehaviors\\Model\\Timestampable\\Timestampable' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\TimestampableInterface', 'Knp\\DoctrineBehaviors\\Model\\Timestampable\\TimestampableMethods' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\TimestampableInterface', 'Knp\\DoctrineBehaviors\\Model\\Blameable\\Blameable' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\BlameableInterface', 'Knp\\DoctrineBehaviors\\Model\\Blameable\\BlameableMethods' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\BlameableInterface', 'Knp\\DoctrineBehaviors\\Model\\Loggable\\Loggable' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\LoggableInterface', 'Knp\\DoctrineBehaviors\\Model\\SoftDeletable\\SoftDeletable' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\SoftDeletableInterface', 'Knp\\DoctrineBehaviors\\Model\\SoftDeletable\\SoftDeletableMethodsTrait' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\SoftDeletableInterface', 'Knp\\DoctrineBehaviors\\Model\\Translatable\\Translatable' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\TranslatableInterface', 'Knp\\DoctrineBehaviors\\Model\\Translatable\\TranslatableMethods' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\TranslatableInterface', 'Knp\\DoctrineBehaviors\\Model\\Translatable\\Translation' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\TranslationInterface', 'Knp\\DoctrineBehaviors\\Model\\Translatable\\TranslationMethods' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\TranslationInterface', 'Knp\\DoctrineBehaviors\\Model\\Uuidable\\Uuidable' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\UuidableInterface', 'Knp\\DoctrineBehaviors\\Model\\Uuidable\\UuidableMethods' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\UuidableInterface']); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ # move interface to "Contract" 'Knp\\DoctrineBehaviors\\Model\\Tree\\NodeInterface' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\TreeNodeInterface', # suffix "Trait" for traits @@ -38,5 +38,5 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { # tree 'Knp\\DoctrineBehaviors\\Model\\Tree\\Node' => 'Knp\\DoctrineBehaviors\\Model\\Tree\\TreeNodeTrait', ]); - $rectorConfig->ruleWithConfiguration(\Rector\Doctrine\Rector\Class_\AddEntityIdByConditionRector::class, ['Knp\\DoctrineBehaviors\\Model\\Translatable\\Translation', 'Knp\\DoctrineBehaviors\\Model\\Translatable\\TranslationTrait']); + $rectorConfig->ruleWithConfiguration(AddEntityIdByConditionRector::class, ['Knp\\DoctrineBehaviors\\Model\\Translatable\\Translation', 'Knp\\DoctrineBehaviors\\Model\\Translatable\\TranslationTrait']); }; diff --git a/vendor/rector/rector-doctrine/config/sets/doctrine-code-quality.php b/vendor/rector/rector-doctrine/config/sets/doctrine-code-quality.php index 4bc4eb3bad7..1f89c524c4c 100644 --- a/vendor/rector/rector-doctrine/config/sets/doctrine-code-quality.php +++ b/vendor/rector/rector-doctrine/config/sets/doctrine-code-quality.php @@ -23,22 +23,22 @@ use Rector\Transform\Rector\Attribute\AttributeKeyToClassConstFetchRector; use Rector\Transform\Rector\MethodCall\ServiceGetterToConstructorInjectionRector; use Rector\Transform\ValueObject\AttributeKeyToClassConstFetch; use Rector\Transform\ValueObject\ServiceGetterToConstructorInjection; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Doctrine\Rector\Class_\ManagerRegistryGetManagerToEntityManagerRector::class); - $rectorConfig->rule(\Rector\Doctrine\Rector\Class_\InitializeDefaultEntityCollectionRector::class); - $rectorConfig->rule(\Rector\Doctrine\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector::class); - $rectorConfig->rule(\Rector\Doctrine\Rector\Property\MakeEntityDateTimePropertyDateTimeInterfaceRector::class); - $rectorConfig->rule(\Rector\Doctrine\Rector\Class_\MoveCurrentDateTimeDefaultInEntityToConstructorRector::class); - $rectorConfig->rule(\Rector\Doctrine\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector::class); - $rectorConfig->rule(\Rector\Doctrine\Rector\Property\ChangeBigIntEntityPropertyToIntTypeRector::class); - $rectorConfig->rule(\Rector\Doctrine\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector::class); - $rectorConfig->rule(\Rector\Doctrine\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector::class); - $rectorConfig->rule(\Rector\Doctrine\Rector\Class_\RemoveRedundantDefaultClassAnnotationValuesRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(ManagerRegistryGetManagerToEntityManagerRector::class); + $rectorConfig->rule(InitializeDefaultEntityCollectionRector::class); + $rectorConfig->rule(MakeEntitySetterNullabilityInSyncWithPropertyRector::class); + $rectorConfig->rule(MakeEntityDateTimePropertyDateTimeInterfaceRector::class); + $rectorConfig->rule(MoveCurrentDateTimeDefaultInEntityToConstructorRector::class); + $rectorConfig->rule(CorrectDefaultTypesOnEntityPropertyRector::class); + $rectorConfig->rule(ChangeBigIntEntityPropertyToIntTypeRector::class); + $rectorConfig->rule(ImproveDoctrineCollectionDocTypeInEntityRector::class); + $rectorConfig->rule(RemoveRedundantDefaultPropertyAnnotationValuesRector::class); + $rectorConfig->rule(RemoveRedundantDefaultClassAnnotationValuesRector::class); // typed properties in entities from annotations/attributes - $rectorConfig->rule(\Rector\Doctrine\Rector\Property\TypedPropertyFromColumnTypeRector::class); - $rectorConfig->rule(\Rector\Doctrine\Rector\Property\TypedPropertyFromToOneRelationTypeRector::class); - $rectorConfig->rule(\Rector\Doctrine\Rector\Property\TypedPropertyFromToManyRelationTypeRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\Attribute\AttributeKeyToClassConstFetchRector::class, [new \Rector\Transform\ValueObject\AttributeKeyToClassConstFetch('Doctrine\\ORM\\Mapping\\Column', 'type', 'Doctrine\\DBAL\\Types\\Types', ['array' => 'ARRAY', 'ascii_string' => 'ASCII_STRING', 'bigint' => 'BIGINT', 'binary' => 'BINARY', 'blob' => 'BLOB', 'boolean' => 'BOOLEAN', 'date' => 'DATE_MUTABLE', 'date_immutable' => 'DATE_IMMUTABLE', 'dateinterval' => 'DATEINTERVAL', 'datetime' => 'DATETIME_MUTABLE', 'datetime_immutable' => 'DATETIME_IMMUTABLE', 'datetimetz' => 'DATETIMETZ_MUTABLE', 'datetimetz_immutable' => 'DATETIMETZ_IMMUTABLE', 'decimal' => 'DECIMAL', 'float' => 'FLOAT', 'guid' => 'GUID', 'integer' => 'INTEGER', 'json' => 'JSON', 'object' => 'OBJECT', 'simple_array' => 'SIMPLE_ARRAY', 'smallint' => 'SMALLINT', 'string' => 'STRING', 'text' => 'TEXT', 'time' => 'TIME_MUTABLE', 'time_immutable' => 'TIME_IMMUTABLE'])]); - $rectorConfig->ruleWithConfiguration(\Rector\Privatization\Rector\MethodCall\ReplaceStringWithClassConstantRector::class, [new \Rector\Privatization\ValueObject\ReplaceStringWithClassConstant('Doctrine\\ORM\\QueryBuilder', 'orderBy', 1, 'Doctrine\\Common\\Collections\\Criteria', \true), new \Rector\Privatization\ValueObject\ReplaceStringWithClassConstant('Doctrine\\ORM\\QueryBuilder', 'addOrderBy', 1, 'Doctrine\\Common\\Collections\\Criteria', \true)]); - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\MethodCall\ServiceGetterToConstructorInjectionRector::class, [new \Rector\Transform\ValueObject\ServiceGetterToConstructorInjection('Doctrine\\Common\\Persistence\\ManagerRegistry', 'getConnection', 'Doctrine\\DBAL\\Connection'), new \Rector\Transform\ValueObject\ServiceGetterToConstructorInjection('Doctrine\\ORM\\EntityManagerInterface', 'getConfiguration', 'Doctrine\\ORM\\Configuration')]); + $rectorConfig->rule(TypedPropertyFromColumnTypeRector::class); + $rectorConfig->rule(TypedPropertyFromToOneRelationTypeRector::class); + $rectorConfig->rule(TypedPropertyFromToManyRelationTypeRector::class); + $rectorConfig->ruleWithConfiguration(AttributeKeyToClassConstFetchRector::class, [new AttributeKeyToClassConstFetch('Doctrine\\ORM\\Mapping\\Column', 'type', 'Doctrine\\DBAL\\Types\\Types', ['array' => 'ARRAY', 'ascii_string' => 'ASCII_STRING', 'bigint' => 'BIGINT', 'binary' => 'BINARY', 'blob' => 'BLOB', 'boolean' => 'BOOLEAN', 'date' => 'DATE_MUTABLE', 'date_immutable' => 'DATE_IMMUTABLE', 'dateinterval' => 'DATEINTERVAL', 'datetime' => 'DATETIME_MUTABLE', 'datetime_immutable' => 'DATETIME_IMMUTABLE', 'datetimetz' => 'DATETIMETZ_MUTABLE', 'datetimetz_immutable' => 'DATETIMETZ_IMMUTABLE', 'decimal' => 'DECIMAL', 'float' => 'FLOAT', 'guid' => 'GUID', 'integer' => 'INTEGER', 'json' => 'JSON', 'object' => 'OBJECT', 'simple_array' => 'SIMPLE_ARRAY', 'smallint' => 'SMALLINT', 'string' => 'STRING', 'text' => 'TEXT', 'time' => 'TIME_MUTABLE', 'time_immutable' => 'TIME_IMMUTABLE'])]); + $rectorConfig->ruleWithConfiguration(ReplaceStringWithClassConstantRector::class, [new ReplaceStringWithClassConstant('Doctrine\\ORM\\QueryBuilder', 'orderBy', 1, 'Doctrine\\Common\\Collections\\Criteria', \true), new ReplaceStringWithClassConstant('Doctrine\\ORM\\QueryBuilder', 'addOrderBy', 1, 'Doctrine\\Common\\Collections\\Criteria', \true)]); + $rectorConfig->ruleWithConfiguration(ServiceGetterToConstructorInjectionRector::class, [new ServiceGetterToConstructorInjection('Doctrine\\Common\\Persistence\\ManagerRegistry', 'getConnection', 'Doctrine\\DBAL\\Connection'), new ServiceGetterToConstructorInjection('Doctrine\\ORM\\EntityManagerInterface', 'getConfiguration', 'Doctrine\\ORM\\Configuration')]); }; diff --git a/vendor/rector/rector-doctrine/config/sets/doctrine-common-20.php b/vendor/rector/rector-doctrine/config/sets/doctrine-common-20.php index fb3a307299a..13268a3c27b 100644 --- a/vendor/rector/rector-doctrine/config/sets/doctrine-common-20.php +++ b/vendor/rector/rector-doctrine/config/sets/doctrine-common-20.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Renaming\Rector\Name\RenameClassRector; # see https://github.com/doctrine/persistence/pull/71 -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Doctrine\\Common\\Persistence\\Event\\LifecycleEventArgs' => 'Doctrine\\Persistence\\Event\\LifecycleEventArgs', 'Doctrine\\Common\\Persistence\\Event\\LoadClassMetadataEventArgs' => 'Doctrine\\Persistence\\Event\\LoadClassMetadataEventArgs', 'Doctrine\\Common\\Persistence\\Event\\ManagerEventArgs' => 'Doctrine\\Persistence\\Event\\ManagerEventArgs', 'Doctrine\\Common\\Persistence\\Mapping\\AbstractClassMetadataFactory' => 'Doctrine\\Persistence\\Mapping\\AbstractClassMetadataFactory', 'Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata' => 'Doctrine\\Persistence\\Mapping\\ClassMetadata', 'Doctrine\\Common\\Persistence\\Mapping\\ClassMetadataFactory' => 'Doctrine\\Persistence\\Mapping\\ClassMetadataFactory', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\FileDriver' => 'Doctrine\\Persistence\\Mapping\\Driver\\FileDriver', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\MappingDriver' => 'Doctrine\\Persistence\\Mapping\\Driver\\MappingDriver', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\MappingDriverChain' => 'Doctrine\\Persistence\\Mapping\\Driver\\MappingDriverChain', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\PHPDriver' => 'Doctrine\\Persistence\\Mapping\\Driver\\PHPDriver', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\StaticPHPDriver' => 'Doctrine\\Persistence\\Mapping\\Driver\\StaticPHPDriver', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\SymfonyFileLocator' => 'Doctrine\\Persistence\\Mapping\\Driver\\SymfonyFileLocator', 'Doctrine\\Common\\Persistence\\Mapping\\MappingException' => 'Doctrine\\Persistence\\Mapping\\MappingException', 'Doctrine\\Common\\Persistence\\Mapping\\ReflectionService' => 'Doctrine\\Persistence\\Mapping\\ReflectionService', 'Doctrine\\Common\\Persistence\\Mapping\\RuntimeReflectionService' => 'Doctrine\\Persistence\\Mapping\\RuntimeReflectionService', 'Doctrine\\Common\\Persistence\\Mapping\\StaticReflectionService' => 'Doctrine\\Persistence\\Mapping\\StaticReflectionService', 'Doctrine\\Common\\Persistence\\ObjectManager' => 'Doctrine\\Persistence\\ObjectManager', 'Doctrine\\Common\\Persistence\\ObjectManagerDecorator' => 'Doctrine\\Persistence\\ObjectManagerDecorator', 'Doctrine\\Common\\Persistence\\ObjectRepository' => 'Doctrine\\Persistence\\ObjectRepository', 'Doctrine\\Common\\Persistence\\Proxy' => 'Doctrine\\Persistence\\Proxy', 'Doctrine\\Common\\Persistence\\AbstractManagerRegistry' => 'Doctrine\\Persistence\\AbstractManagerRegistry', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\DefaultFileLocator' => 'Doctrine\\Persistence\\Mapping\\Driver\\DefaultFileLocator', 'Doctrine\\Common\\Persistence\\ManagerRegistry' => 'Doctrine\\Persistence\\ManagerRegistry']); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Doctrine\\Common\\Persistence\\Event\\LifecycleEventArgs' => 'Doctrine\\Persistence\\Event\\LifecycleEventArgs', 'Doctrine\\Common\\Persistence\\Event\\LoadClassMetadataEventArgs' => 'Doctrine\\Persistence\\Event\\LoadClassMetadataEventArgs', 'Doctrine\\Common\\Persistence\\Event\\ManagerEventArgs' => 'Doctrine\\Persistence\\Event\\ManagerEventArgs', 'Doctrine\\Common\\Persistence\\Mapping\\AbstractClassMetadataFactory' => 'Doctrine\\Persistence\\Mapping\\AbstractClassMetadataFactory', 'Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata' => 'Doctrine\\Persistence\\Mapping\\ClassMetadata', 'Doctrine\\Common\\Persistence\\Mapping\\ClassMetadataFactory' => 'Doctrine\\Persistence\\Mapping\\ClassMetadataFactory', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\FileDriver' => 'Doctrine\\Persistence\\Mapping\\Driver\\FileDriver', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\MappingDriver' => 'Doctrine\\Persistence\\Mapping\\Driver\\MappingDriver', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\MappingDriverChain' => 'Doctrine\\Persistence\\Mapping\\Driver\\MappingDriverChain', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\PHPDriver' => 'Doctrine\\Persistence\\Mapping\\Driver\\PHPDriver', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\StaticPHPDriver' => 'Doctrine\\Persistence\\Mapping\\Driver\\StaticPHPDriver', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\SymfonyFileLocator' => 'Doctrine\\Persistence\\Mapping\\Driver\\SymfonyFileLocator', 'Doctrine\\Common\\Persistence\\Mapping\\MappingException' => 'Doctrine\\Persistence\\Mapping\\MappingException', 'Doctrine\\Common\\Persistence\\Mapping\\ReflectionService' => 'Doctrine\\Persistence\\Mapping\\ReflectionService', 'Doctrine\\Common\\Persistence\\Mapping\\RuntimeReflectionService' => 'Doctrine\\Persistence\\Mapping\\RuntimeReflectionService', 'Doctrine\\Common\\Persistence\\Mapping\\StaticReflectionService' => 'Doctrine\\Persistence\\Mapping\\StaticReflectionService', 'Doctrine\\Common\\Persistence\\ObjectManager' => 'Doctrine\\Persistence\\ObjectManager', 'Doctrine\\Common\\Persistence\\ObjectManagerDecorator' => 'Doctrine\\Persistence\\ObjectManagerDecorator', 'Doctrine\\Common\\Persistence\\ObjectRepository' => 'Doctrine\\Persistence\\ObjectRepository', 'Doctrine\\Common\\Persistence\\Proxy' => 'Doctrine\\Persistence\\Proxy', 'Doctrine\\Common\\Persistence\\AbstractManagerRegistry' => 'Doctrine\\Persistence\\AbstractManagerRegistry', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\DefaultFileLocator' => 'Doctrine\\Persistence\\Mapping\\Driver\\DefaultFileLocator', 'Doctrine\\Common\\Persistence\\ManagerRegistry' => 'Doctrine\\Persistence\\ManagerRegistry']); }; diff --git a/vendor/rector/rector-doctrine/config/sets/doctrine-dbal-210.php b/vendor/rector/rector-doctrine/config/sets/doctrine-dbal-210.php index 2c01472aa7f..b42aa0cc249 100644 --- a/vendor/rector/rector-doctrine/config/sets/doctrine-dbal-210.php +++ b/vendor/rector/rector-doctrine/config/sets/doctrine-dbal-210.php @@ -5,7 +5,7 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Renaming\Rector\Name\RenameClassRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { # https://github.com/doctrine/dbal/blob/master/UPGRADE.md#deprecated-type-constants - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Doctrine\\DBAL\\Types\\Type' => 'Doctrine\\DBAL\\Types\\Types']); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Doctrine\\DBAL\\Types\\Type' => 'Doctrine\\DBAL\\Types\\Types']); }; diff --git a/vendor/rector/rector-doctrine/config/sets/doctrine-dbal-211.php b/vendor/rector/rector-doctrine/config/sets/doctrine-dbal-211.php index 9dc9accae0e..9faf746c629 100644 --- a/vendor/rector/rector-doctrine/config/sets/doctrine-dbal-211.php +++ b/vendor/rector/rector-doctrine/config/sets/doctrine-dbal-211.php @@ -7,30 +7,30 @@ use Rector\Config\RectorConfig; use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Renaming\ValueObject\MethodCallRename; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ // https://github.com/doctrine/dbal/blob/master/UPGRADE.md#deprecations-in-the-wrapper-connection-class - new \Rector\Renaming\ValueObject\MethodCallRename('Doctrine\\DBAL\\Connection', 'executeUpdate', 'executeStatement'), - new \Rector\Renaming\ValueObject\MethodCallRename('Doctrine\\DBAL\\Connection', 'exec', 'executeStatement'), - new \Rector\Renaming\ValueObject\MethodCallRename('Doctrine\\DBAL\\Connection', 'query', 'executeQuery'), + new MethodCallRename('Doctrine\\DBAL\\Connection', 'executeUpdate', 'executeStatement'), + new MethodCallRename('Doctrine\\DBAL\\Connection', 'exec', 'executeStatement'), + new MethodCallRename('Doctrine\\DBAL\\Connection', 'query', 'executeQuery'), // https://github.com/doctrine/dbal/blob/master/UPGRADE.md#driverexceptiongeterrorcode-is-deprecated - new \Rector\Renaming\ValueObject\MethodCallRename('Doctrine\\DBAL\\Driver\\DriverException', 'getErrorCode', 'getSQLState'), + new MethodCallRename('Doctrine\\DBAL\\Driver\\DriverException', 'getErrorCode', 'getSQLState'), // https://github.com/doctrine/dbal/blob/master/UPGRADE.md#deprecated-expressionbuilder-methods - new \Rector\Renaming\ValueObject\MethodCallRename('Doctrine\\DBAL\\Query\\Expression\\ExpressionBuilder', 'andX', 'and'), - new \Rector\Renaming\ValueObject\MethodCallRename('Doctrine\\DBAL\\Query\\Expression\\ExpressionBuilder', 'orX', 'or'), + new MethodCallRename('Doctrine\\DBAL\\Query\\Expression\\ExpressionBuilder', 'andX', 'and'), + new MethodCallRename('Doctrine\\DBAL\\Query\\Expression\\ExpressionBuilder', 'orX', 'or'), // https://github.com/doctrine/dbal/blob/master/UPGRADE.md#deprecated-compositeexpression-methods - new \Rector\Renaming\ValueObject\MethodCallRename('Doctrine\\DBAL\\Query\\Expression\\CompositeExpression', 'add', 'with'), - new \Rector\Renaming\ValueObject\MethodCallRename('Doctrine\\DBAL\\Query\\Expression\\CompositeExpression', 'addMultiple', 'with'), + new MethodCallRename('Doctrine\\DBAL\\Query\\Expression\\CompositeExpression', 'add', 'with'), + new MethodCallRename('Doctrine\\DBAL\\Query\\Expression\\CompositeExpression', 'addMultiple', 'with'), // https://github.com/doctrine/dbal/blob/master/UPGRADE.md#deprecated-fetchmode-and-the-corresponding-methods - new \Rector\Renaming\ValueObject\MethodCallRename('Doctrine\\DBAL\\Connection', 'fetchAssoc', 'fetchAssociative'), - new \Rector\Renaming\ValueObject\MethodCallRename('Doctrine\\DBAL\\Connection', 'fetchArray', 'fetchNumeric'), - new \Rector\Renaming\ValueObject\MethodCallRename('Doctrine\\DBAL\\Connection', 'fetchColumn', 'fetchOne'), - new \Rector\Renaming\ValueObject\MethodCallRename('Doctrine\\DBAL\\Connection', 'fetchAll', 'fetchAllAssociative'), - new \Rector\Renaming\ValueObject\MethodCallRename('Doctrine\\DBAL\\Statement', 'fetchAssoc', 'fetchAssociative'), - new \Rector\Renaming\ValueObject\MethodCallRename('Doctrine\\DBAL\\Statement', 'fetchColumn', 'fetchOne'), - new \Rector\Renaming\ValueObject\MethodCallRename('Doctrine\\DBAL\\Statement', 'fetchAll', 'fetchAllAssociative'), + new MethodCallRename('Doctrine\\DBAL\\Connection', 'fetchAssoc', 'fetchAssociative'), + new MethodCallRename('Doctrine\\DBAL\\Connection', 'fetchArray', 'fetchNumeric'), + new MethodCallRename('Doctrine\\DBAL\\Connection', 'fetchColumn', 'fetchOne'), + new MethodCallRename('Doctrine\\DBAL\\Connection', 'fetchAll', 'fetchAllAssociative'), + new MethodCallRename('Doctrine\\DBAL\\Statement', 'fetchAssoc', 'fetchAssociative'), + new MethodCallRename('Doctrine\\DBAL\\Statement', 'fetchColumn', 'fetchOne'), + new MethodCallRename('Doctrine\\DBAL\\Statement', 'fetchAll', 'fetchAllAssociative'), ]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, [ + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ // https://github.com/doctrine/dbal/blob/master/UPGRADE.md#pdo-related-classes-outside-of-the-pdo-namespace-are-deprecated 'Doctrine\\DBAL\\Driver\\PDOMySql\\Driver' => 'Doctrine\\DBAL\\Driver\\PDO\\MySQL\\Driver', 'Doctrine\\DBAL\\Driver\\PDOOracle\\Driver' => 'Doctrine\\DBAL\\Driver\\PDO\\OCI\\Driver', diff --git a/vendor/rector/rector-doctrine/config/sets/doctrine-dbal-30.php b/vendor/rector/rector-doctrine/config/sets/doctrine-dbal-30.php index ac3a46b34e6..b7bb495fcb1 100644 --- a/vendor/rector/rector-doctrine/config/sets/doctrine-dbal-30.php +++ b/vendor/rector/rector-doctrine/config/sets/doctrine-dbal-30.php @@ -11,9 +11,9 @@ use Rector\Renaming\ValueObject\MethodCallRename; use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector; use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration; # https://github.com/doctrine/dbal/blob/master/UPGRADE.md#bc-break-changes-in-handling-string-and-binary-columns -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Doctrine\\DBAL\\Platforms\\AbstractPlatform', 'getVarcharTypeDeclarationSQL', 'getStringTypeDeclarationSQL'), new \Rector\Renaming\ValueObject\MethodCallRename('Doctrine\\DBAL\\Driver\\DriverException', 'getErrorCode', 'getCode')]); - $rectorConfig->ruleWithConfiguration(\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::class, [new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Doctrine\\DBAL\\Connection', 'ping', new \PHPStan\Type\VoidType())]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Doctrine\\DBAL\\Platforms\\AbstractPlatform', 'getVarcharTypeDeclarationSQL', 'getStringTypeDeclarationSQL'), new MethodCallRename('Doctrine\\DBAL\\Driver\\DriverException', 'getErrorCode', 'getCode')]); + $rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [new AddReturnTypeDeclaration('Doctrine\\DBAL\\Connection', 'ping', new VoidType())]); # https://github.com/doctrine/dbal/blob/master/UPGRADE.md#deprecated-abstractionresult - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Doctrine\\DBAL\\Abstraction\\Result' => 'Doctrine\\DBAL\\Result']); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Doctrine\\DBAL\\Abstraction\\Result' => 'Doctrine\\DBAL\\Result']); }; diff --git a/vendor/rector/rector-doctrine/config/sets/doctrine-gedmo-to-knplabs.php b/vendor/rector/rector-doctrine/config/sets/doctrine-gedmo-to-knplabs.php index 270698e2565..dcde5270076 100644 --- a/vendor/rector/rector-doctrine/config/sets/doctrine-gedmo-to-knplabs.php +++ b/vendor/rector/rector-doctrine/config/sets/doctrine-gedmo-to-knplabs.php @@ -12,12 +12,12 @@ use Rector\Doctrine\Rector\Class_\TimestampableBehaviorRector; use Rector\Doctrine\Rector\Class_\TranslationBehaviorRector; use Rector\Doctrine\Rector\Class_\TreeBehaviorRector; # version gedmo/doctrine-extensions 2.x to knplabs/doctrine-behaviors 2.0 -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Doctrine\Rector\Class_\TimestampableBehaviorRector::class); - $rectorConfig->rule(\Rector\Doctrine\Rector\Class_\SluggableBehaviorRector::class); - $rectorConfig->rule(\Rector\Doctrine\Rector\Class_\TreeBehaviorRector::class); - $rectorConfig->rule(\Rector\Doctrine\Rector\Class_\TranslationBehaviorRector::class); - $rectorConfig->rule(\Rector\Doctrine\Rector\Class_\SoftDeletableBehaviorRector::class); - $rectorConfig->rule(\Rector\Doctrine\Rector\Class_\BlameableBehaviorRector::class); - $rectorConfig->rule(\Rector\Doctrine\Rector\Class_\LoggableBehaviorRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(TimestampableBehaviorRector::class); + $rectorConfig->rule(SluggableBehaviorRector::class); + $rectorConfig->rule(TreeBehaviorRector::class); + $rectorConfig->rule(TranslationBehaviorRector::class); + $rectorConfig->rule(SoftDeletableBehaviorRector::class); + $rectorConfig->rule(BlameableBehaviorRector::class); + $rectorConfig->rule(LoggableBehaviorRector::class); }; diff --git a/vendor/rector/rector-doctrine/config/sets/doctrine-odm-23.php b/vendor/rector/rector-doctrine/config/sets/doctrine-odm-23.php index 5cefcb63d5e..d20d974ceb1 100644 --- a/vendor/rector/rector-doctrine/config/sets/doctrine-odm-23.php +++ b/vendor/rector/rector-doctrine/config/sets/doctrine-odm-23.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; use Rector\Php80\ValueObject\AnnotationToAttribute; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class, [new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\AlsoLoad'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\ChangeTrackingPolicy'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\DefaultDiscriminatorValue'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\DiscriminatorField'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\DiscriminatorMap'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\DiscriminatorValue'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Document'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\EmbeddedDocument'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\EmbedMany'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\EmbedOne'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Field'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\File'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\File\\ChunkSize'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\File\\Filename'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\File\\Length'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\File\\Metadata'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\File\\UploadDate'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\HasLifecycleCallbacks'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Id'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Index'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Indexes'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\InheritanceType'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Lock'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\MappedSuperclass'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PostLoad'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PostPersist'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PostRemove'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PostUpdate'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PreFlush'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PreLoad'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PrePersist'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PreRemove'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PreUpdate'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\QueryResultDocument'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\ReadPreference'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\ReferenceMany'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\ReferenceOne'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\ShardKey'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\UniqueIndex'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Validation'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Version'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\View')]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\AlsoLoad'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\ChangeTrackingPolicy'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\DefaultDiscriminatorValue'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\DiscriminatorField'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\DiscriminatorMap'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\DiscriminatorValue'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Document'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\EmbeddedDocument'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\EmbedMany'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\EmbedOne'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Field'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\File'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\File\\ChunkSize'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\File\\Filename'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\File\\Length'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\File\\Metadata'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\File\\UploadDate'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\HasLifecycleCallbacks'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Id'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Index'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Indexes'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\InheritanceType'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Lock'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\MappedSuperclass'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PostLoad'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PostPersist'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PostRemove'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PostUpdate'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PreFlush'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PreLoad'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PrePersist'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PreRemove'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PreUpdate'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\QueryResultDocument'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\ReadPreference'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\ReferenceMany'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\ReferenceOne'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\ShardKey'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\UniqueIndex'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Validation'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Version'), new AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\View')]); }; diff --git a/vendor/rector/rector-doctrine/config/sets/doctrine-orm-29.php b/vendor/rector/rector-doctrine/config/sets/doctrine-orm-29.php index 8190b187540..9e2ef110844 100644 --- a/vendor/rector/rector-doctrine/config/sets/doctrine-orm-29.php +++ b/vendor/rector/rector-doctrine/config/sets/doctrine-orm-29.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace RectorPrefix20220607; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $rectorConfig->import(__DIR__ . '/doctrine-annotations-to-attributes.php'); }; diff --git a/vendor/rector/rector-doctrine/config/sets/doctrine-repository-as-service.php b/vendor/rector/rector-doctrine/config/sets/doctrine-repository-as-service.php index 8a6ef042107..59801c201b0 100644 --- a/vendor/rector/rector-doctrine/config/sets/doctrine-repository-as-service.php +++ b/vendor/rector/rector-doctrine/config/sets/doctrine-repository-as-service.php @@ -21,19 +21,19 @@ use Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall; * @see https://tomasvotruba.com/blog/2018/04/02/rectify-turn-repositories-to-services-in-symfony/ * @see https://getrector.org/blog/2021/02/08/how-to-instantly-decouple-symfony-doctrine-repository-inheritance-to-clean-composition */ -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { # order matters, this needs to be first to correctly detect parent repository // covers "extends EntityRepository" - $rectorConfig->rule(\Rector\Doctrine\Rector\Class_\MoveRepositoryFromParentToConstructorRector::class); - $rectorConfig->rule(\Rector\Doctrine\Rector\MethodCall\ReplaceParentRepositoryCallsByRepositoryPropertyRector::class); - $rectorConfig->rule(\Rector\Doctrine\Rector\Class_\RemoveRepositoryFromEntityAnnotationRector::class); + $rectorConfig->rule(MoveRepositoryFromParentToConstructorRector::class); + $rectorConfig->rule(ReplaceParentRepositoryCallsByRepositoryPropertyRector::class); + $rectorConfig->rule(RemoveRepositoryFromEntityAnnotationRector::class); // covers "extends ServiceEntityRepository" // @see https://github.com/doctrine/DoctrineBundle/pull/727/files - $rectorConfig->rule(\Rector\Doctrine\Rector\ClassMethod\ServiceEntityRepositoryParentCallToDIRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector::class, [new \Rector\Renaming\ValueObject\RenameProperty('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', '_em', 'entityManager')]); - $rectorConfig->ruleWithConfiguration(\Rector\DeadCode\Rector\ClassLike\RemoveAnnotationRector::class, ['method']); - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\MethodCall\ReplaceParentCallByPropertyCallRector::class, [new \Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', 'createQueryBuilder', 'entityRepository'), new \Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', 'createResultSetMappingBuilder', 'entityRepository'), new \Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', 'clear', 'entityRepository'), new \Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', 'find', 'entityRepository'), new \Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', 'findBy', 'entityRepository'), new \Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', 'findAll', 'entityRepository'), new \Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', 'count', 'entityRepository'), new \Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', 'getClassName', 'entityRepository'), new \Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', 'matching', 'entityRepository')]); + $rectorConfig->rule(ServiceEntityRepositoryParentCallToDIRector::class); + $rectorConfig->ruleWithConfiguration(RenamePropertyRector::class, [new RenameProperty('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', '_em', 'entityManager')]); + $rectorConfig->ruleWithConfiguration(RemoveAnnotationRector::class, ['method']); + $rectorConfig->ruleWithConfiguration(ReplaceParentCallByPropertyCallRector::class, [new ReplaceParentCallByPropertyCall('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', 'createQueryBuilder', 'entityRepository'), new ReplaceParentCallByPropertyCall('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', 'createResultSetMappingBuilder', 'entityRepository'), new ReplaceParentCallByPropertyCall('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', 'clear', 'entityRepository'), new ReplaceParentCallByPropertyCall('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', 'find', 'entityRepository'), new ReplaceParentCallByPropertyCall('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', 'findBy', 'entityRepository'), new ReplaceParentCallByPropertyCall('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', 'findAll', 'entityRepository'), new ReplaceParentCallByPropertyCall('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', 'count', 'entityRepository'), new ReplaceParentCallByPropertyCall('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', 'getClassName', 'entityRepository'), new ReplaceParentCallByPropertyCall('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', 'matching', 'entityRepository')]); // @@todo - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\MethodCall\MethodCallToPropertyFetchRector::class, [new \Rector\Transform\ValueObject\MethodCallToPropertyFetch('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', 'getEntityManager', 'entityManager')]); - $rectorConfig->ruleWithConfiguration(\Rector\Removing\Rector\Class_\RemoveParentRector::class, ['Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository']); + $rectorConfig->ruleWithConfiguration(MethodCallToPropertyFetchRector::class, [new MethodCallToPropertyFetch('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository', 'getEntityManager', 'entityManager')]); + $rectorConfig->ruleWithConfiguration(RemoveParentRector::class, ['Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository']); }; diff --git a/vendor/rector/rector-doctrine/config/sets/doctrine25.php b/vendor/rector/rector-doctrine/config/sets/doctrine25.php index b2873077fb2..6ff63f76a80 100644 --- a/vendor/rector/rector-doctrine/config/sets/doctrine25.php +++ b/vendor/rector/rector-doctrine/config/sets/doctrine25.php @@ -9,7 +9,7 @@ use Rector\Removing\Rector\ClassMethod\ArgumentRemoverRector; use Rector\Removing\ValueObject\ArgumentRemover; use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector; use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::class, [new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Doctrine\\ORM\\Mapping\\ClassMetadataFactory', 'setEntityManager', 0, new \PHPStan\Type\ObjectType('Doctrine\\ORM\\EntityManagerInterface')), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Doctrine\\ORM\\Tools\\DebugUnitOfWorkListener', 'dumpIdentityMap', 0, new \PHPStan\Type\ObjectType('Doctrine\\ORM\\EntityManagerInterface'))]); - $rectorConfig->ruleWithConfiguration(\Rector\Removing\Rector\ClassMethod\ArgumentRemoverRector::class, [new \Rector\Removing\ValueObject\ArgumentRemover('Doctrine\\ORM\\Persisters\\Entity\\AbstractEntityInheritancePersister', 'getSelectJoinColumnSQL', 4, null)]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [new AddParamTypeDeclaration('Doctrine\\ORM\\Mapping\\ClassMetadataFactory', 'setEntityManager', 0, new ObjectType('Doctrine\\ORM\\EntityManagerInterface')), new AddParamTypeDeclaration('Doctrine\\ORM\\Tools\\DebugUnitOfWorkListener', 'dumpIdentityMap', 0, new ObjectType('Doctrine\\ORM\\EntityManagerInterface'))]); + $rectorConfig->ruleWithConfiguration(ArgumentRemoverRector::class, [new ArgumentRemover('Doctrine\\ORM\\Persisters\\Entity\\AbstractEntityInheritancePersister', 'getSelectJoinColumnSQL', 4, null)]); }; diff --git a/vendor/rector/rector-doctrine/monorepo-builder.php b/vendor/rector/rector-doctrine/monorepo-builder.php index e4e22301995..544f64366de 100644 --- a/vendor/rector/rector-doctrine/monorepo-builder.php +++ b/vendor/rector/rector-doctrine/monorepo-builder.php @@ -3,12 +3,12 @@ declare (strict_types=1); namespace RectorPrefix20220607; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\PushTagReleaseWorker; use RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\TagVersionReleaseWorker; -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +return static function (ContainerConfigurator $containerConfigurator) : void { $services = $containerConfigurator->services(); // @see https://github.com/symplify/monorepo-builder#6-release-flow - $services->set(\RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\TagVersionReleaseWorker::class); - $services->set(\RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\PushTagReleaseWorker::class); + $services->set(TagVersionReleaseWorker::class); + $services->set(PushTagReleaseWorker::class); }; diff --git a/vendor/rector/rector-doctrine/rector.php b/vendor/rector/rector-doctrine/rector.php index e4101b0088c..e99b8c7a1c2 100644 --- a/vendor/rector/rector-doctrine/rector.php +++ b/vendor/rector/rector-doctrine/rector.php @@ -7,7 +7,7 @@ use Rector\Config\RectorConfig; use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $rectorConfig->import(__DIR__ . '/config/config.php'); $rectorConfig->importNames(); $rectorConfig->paths([__DIR__ . '/src', __DIR__ . '/tests']); @@ -17,6 +17,6 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { '*/Source/*', '*/Fixture/*', ]); - $rectorConfig->sets([\Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_81, \Rector\Set\ValueObject\SetList::DEAD_CODE, \Rector\Set\ValueObject\SetList::CODE_QUALITY, \Rector\Set\ValueObject\SetList::NAMING]); - $rectorConfig->ruleWithConfiguration(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class, ['Doctrine\\*', 'Gedmo\\*', 'Knp\\*', 'DateTime', 'DateTimeInterface']); + $rectorConfig->sets([LevelSetList::UP_TO_PHP_81, SetList::DEAD_CODE, SetList::CODE_QUALITY, SetList::NAMING]); + $rectorConfig->ruleWithConfiguration(StringClassNameToClassConstantRector::class, ['Doctrine\\*', 'Gedmo\\*', 'Knp\\*', 'DateTime', 'DateTimeInterface']); }; diff --git a/vendor/rector/rector-doctrine/src/NodeAnalyzer/AssignPropertyFetchAnalyzer.php b/vendor/rector/rector-doctrine/src/NodeAnalyzer/AssignPropertyFetchAnalyzer.php index c8d6e2ddc68..1892ee3aa6a 100644 --- a/vendor/rector/rector-doctrine/src/NodeAnalyzer/AssignPropertyFetchAnalyzer.php +++ b/vendor/rector/rector-doctrine/src/NodeAnalyzer/AssignPropertyFetchAnalyzer.php @@ -21,7 +21,7 @@ final class AssignPropertyFetchAnalyzer * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeNameResolver = $nodeNameResolver; @@ -29,19 +29,19 @@ final class AssignPropertyFetchAnalyzer /** * @return AssignToPropertyFetch[] */ - public function resolveAssignToPropertyFetch(\PhpParser\Node\Stmt\ClassMethod $classMethod) : array + public function resolveAssignToPropertyFetch(ClassMethod $classMethod) : array { /** @var Assign[] $assigns */ - $assigns = $this->betterNodeFinder->findInstanceOf((array) $classMethod->stmts, \PhpParser\Node\Expr\Assign::class); + $assigns = $this->betterNodeFinder->findInstanceOf((array) $classMethod->stmts, Assign::class); $assignsToPropertyFetch = []; foreach ($assigns as $assign) { - if (!$assign->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$assign->var instanceof PropertyFetch) { continue; } $propertyFetch = $assign->var; /** @var string $propertyName */ $propertyName = $this->nodeNameResolver->getName($propertyFetch); - $assignsToPropertyFetch[] = new \Rector\Doctrine\ValueObject\AssignToPropertyFetch($assign, $propertyFetch, $propertyName); + $assignsToPropertyFetch[] = new AssignToPropertyFetch($assign, $propertyFetch, $propertyName); } return $assignsToPropertyFetch; } diff --git a/vendor/rector/rector-doctrine/src/NodeAnalyzer/AttributeCleaner.php b/vendor/rector/rector-doctrine/src/NodeAnalyzer/AttributeCleaner.php index 7ddc2545066..cbc61cb908c 100644 --- a/vendor/rector/rector-doctrine/src/NodeAnalyzer/AttributeCleaner.php +++ b/vendor/rector/rector-doctrine/src/NodeAnalyzer/AttributeCleaner.php @@ -22,7 +22,7 @@ final class AttributeCleaner * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\Doctrine\NodeAnalyzer\AttributeFinder $attributeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(\Rector\Doctrine\NodeAnalyzer\AttributeFinder $attributeFinder, NodeNameResolver $nodeNameResolver) { $this->attributeFinder = $attributeFinder; $this->nodeNameResolver = $nodeNameResolver; @@ -33,11 +33,11 @@ final class AttributeCleaner public function clearAttributeAndArgName($node, string $attributeClass, string $argName) : void { $attribute = $this->attributeFinder->findAttributeByClass($node, $attributeClass); - if (!$attribute instanceof \PhpParser\Node\Attribute) { + if (!$attribute instanceof Attribute) { return; } foreach ($attribute->args as $key => $arg) { - if (!$arg->name instanceof \PhpParser\Node) { + if (!$arg->name instanceof Node) { continue; } if (!$this->nodeNameResolver->isName($arg->name, $argName)) { diff --git a/vendor/rector/rector-doctrine/src/NodeAnalyzer/AttributeFinder.php b/vendor/rector/rector-doctrine/src/NodeAnalyzer/AttributeFinder.php index 5db902fd1bb..bccf9640fce 100644 --- a/vendor/rector/rector-doctrine/src/NodeAnalyzer/AttributeFinder.php +++ b/vendor/rector/rector-doctrine/src/NodeAnalyzer/AttributeFinder.php @@ -19,7 +19,7 @@ final class AttributeFinder * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } @@ -27,7 +27,7 @@ final class AttributeFinder * @param class-string $attributeClass * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassLike|\PhpParser\Node\Param $node */ - public function findAttributeByClassArgByName($node, string $attributeClass, string $argName) : ?\PhpParser\Node\Expr + public function findAttributeByClassArgByName($node, string $attributeClass, string $argName) : ?Expr { return $this->findAttributeByClassesArgByName($node, [$attributeClass], $argName); } @@ -35,10 +35,10 @@ final class AttributeFinder * @param class-string[] $attributeClasses * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassLike|\PhpParser\Node\Param $node */ - public function findAttributeByClassesArgByName($node, array $attributeClasses, string $argName) : ?\PhpParser\Node\Expr + public function findAttributeByClassesArgByName($node, array $attributeClasses, string $argName) : ?Expr { $attribute = $this->findAttributeByClasses($node, $attributeClasses); - if (!$attribute instanceof \PhpParser\Node\Attribute) { + if (!$attribute instanceof Attribute) { return null; } return $this->findArgByName($attribute, $argName); @@ -46,7 +46,7 @@ final class AttributeFinder /** * @return \PhpParser\Node\Expr|null */ - public function findArgByName(\PhpParser\Node\Attribute $attribute, string $argName) + public function findArgByName(Attribute $attribute, string $argName) { foreach ($attribute->args as $arg) { if ($arg->name === null) { @@ -63,12 +63,12 @@ final class AttributeFinder * @param class-string $attributeClass * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassLike|\PhpParser\Node\Param $node */ - public function findAttributeByClass($node, string $attributeClass) : ?\PhpParser\Node\Attribute + public function findAttributeByClass($node, string $attributeClass) : ?Attribute { /** @var AttributeGroup $attrGroup */ foreach ($node->attrGroups as $attrGroup) { foreach ($attrGroup->attrs as $attribute) { - if (!$attribute->name instanceof \PhpParser\Node\Name\FullyQualified) { + if (!$attribute->name instanceof FullyQualified) { continue; } if ($this->nodeNameResolver->isName($attribute->name, $attributeClass)) { @@ -82,11 +82,11 @@ final class AttributeFinder * @param class-string[] $attributeClasses * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassLike|\PhpParser\Node\Param $node */ - public function findAttributeByClasses($node, array $attributeClasses) : ?\PhpParser\Node\Attribute + public function findAttributeByClasses($node, array $attributeClasses) : ?Attribute { foreach ($attributeClasses as $attributeClass) { $attribute = $this->findAttributeByClass($node, $attributeClass); - if ($attribute instanceof \PhpParser\Node\Attribute) { + if ($attribute instanceof Attribute) { return $attribute; } } diff --git a/vendor/rector/rector-doctrine/src/NodeAnalyzer/AttrinationFinder.php b/vendor/rector/rector-doctrine/src/NodeAnalyzer/AttrinationFinder.php index e09d58bdfd2..8202b8850f1 100644 --- a/vendor/rector/rector-doctrine/src/NodeAnalyzer/AttrinationFinder.php +++ b/vendor/rector/rector-doctrine/src/NodeAnalyzer/AttrinationFinder.php @@ -23,7 +23,7 @@ final class AttrinationFinder * @var \Rector\Doctrine\NodeAnalyzer\AttributeFinder */ private $attributeFinder; - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Doctrine\NodeAnalyzer\AttributeFinder $attributeFinder) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory, \Rector\Doctrine\NodeAnalyzer\AttributeFinder $attributeFinder) { $this->phpDocInfoFactory = $phpDocInfoFactory; $this->attributeFinder = $attributeFinder; @@ -36,7 +36,7 @@ final class AttrinationFinder public function getByOne($node, string $name) { $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); - if ($phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo && $phpDocInfo->hasByAnnotationClass($name)) { + if ($phpDocInfo instanceof PhpDocInfo && $phpDocInfo->hasByAnnotationClass($name)) { return $phpDocInfo->getByAnnotationClass($name); } return $this->attributeFinder->findAttributeByClass($node, $name); @@ -48,22 +48,22 @@ final class AttrinationFinder public function hasByOne($node, string $name) : bool { $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); - if ($phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo && $phpDocInfo->hasByAnnotationClass($name)) { + if ($phpDocInfo instanceof PhpDocInfo && $phpDocInfo->hasByAnnotationClass($name)) { return \true; } $attribute = $this->attributeFinder->findAttributeByClass($node, $name); - return $attribute instanceof \PhpParser\Node\Attribute; + return $attribute instanceof Attribute; } /** * @param class-string[] $names */ - public function hasByMany(\PhpParser\Node\Stmt\Property $property, array $names) : bool + public function hasByMany(Property $property, array $names) : bool { $phpDocInfo = $this->phpDocInfoFactory->createFromNode($property); - if ($phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo && $phpDocInfo->hasByAnnotationClasses($names)) { + if ($phpDocInfo instanceof PhpDocInfo && $phpDocInfo->hasByAnnotationClasses($names)) { return \true; } $attribute = $this->attributeFinder->findAttributeByClasses($property, $names); - return $attribute instanceof \PhpParser\Node\Attribute; + return $attribute instanceof Attribute; } } diff --git a/vendor/rector/rector-doctrine/src/NodeAnalyzer/ConstructorAssignPropertyAnalyzer.php b/vendor/rector/rector-doctrine/src/NodeAnalyzer/ConstructorAssignPropertyAnalyzer.php index c8d552b1efc..f68427f784f 100644 --- a/vendor/rector/rector-doctrine/src/NodeAnalyzer/ConstructorAssignPropertyAnalyzer.php +++ b/vendor/rector/rector-doctrine/src/NodeAnalyzer/ConstructorAssignPropertyAnalyzer.php @@ -29,26 +29,26 @@ final class ConstructorAssignPropertyAnalyzer * @var \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer */ private $propertyFetchAnalyzer; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver, PropertyFetchAnalyzer $propertyFetchAnalyzer) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeNameResolver = $nodeNameResolver; $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; } - public function resolveConstructorAssign(\PhpParser\Node\Stmt\Property $property) : ?\PhpParser\Node + public function resolveConstructorAssign(Property $property) : ?Node { - $class = $this->betterNodeFinder->findParentType($property, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($property, Class_::class); + if (!$class instanceof Class_) { return null; } - $constructClassMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$constructClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $constructClassMethod = $class->getMethod(MethodName::CONSTRUCT); + if (!$constructClassMethod instanceof ClassMethod) { return null; } /** @var string $propertyName */ $propertyName = $this->nodeNameResolver->getName($property); - return $this->betterNodeFinder->findFirst((array) $constructClassMethod->stmts, function (\PhpParser\Node $node) use($propertyName) : ?Assign { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + return $this->betterNodeFinder->findFirst((array) $constructClassMethod->stmts, function (Node $node) use($propertyName) : ?Assign { + if (!$node instanceof Assign) { return null; } if (!$this->propertyFetchAnalyzer->isLocalPropertyFetchName($node->var, $propertyName)) { diff --git a/vendor/rector/rector-doctrine/src/NodeAnalyzer/EntityObjectTypeResolver.php b/vendor/rector/rector-doctrine/src/NodeAnalyzer/EntityObjectTypeResolver.php index 3eb9ab5061b..899474f52e3 100644 --- a/vendor/rector/rector-doctrine/src/NodeAnalyzer/EntityObjectTypeResolver.php +++ b/vendor/rector/rector-doctrine/src/NodeAnalyzer/EntityObjectTypeResolver.php @@ -34,25 +34,25 @@ final class EntityObjectTypeResolver * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Doctrine\TypeAnalyzer\TypeFinder $typeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory, TypeFinder $typeFinder, NodeNameResolver $nodeNameResolver) { $this->phpDocInfoFactory = $phpDocInfoFactory; $this->typeFinder = $typeFinder; $this->nodeNameResolver = $nodeNameResolver; } - public function resolveFromRepositoryClass(\PhpParser\Node\Stmt\Class_ $repositoryClass) : \PHPStan\Type\SubtractableType + public function resolveFromRepositoryClass(Class_ $repositoryClass) : SubtractableType { $entityType = $this->resolveFromParentConstruct($repositoryClass); - if (!$entityType instanceof \PHPStan\Type\MixedType) { + if (!$entityType instanceof MixedType) { return $entityType; } $getterReturnType = $this->resolveFromGetterReturnType($repositoryClass); - if (!$getterReturnType instanceof \PHPStan\Type\MixedType) { + if (!$getterReturnType instanceof MixedType) { return $getterReturnType; } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } - private function resolveFromGetterReturnType(\PhpParser\Node\Stmt\Class_ $repositoryClass) : \PHPStan\Type\SubtractableType + private function resolveFromGetterReturnType(Class_ $repositoryClass) : SubtractableType { foreach ($repositoryClass->getMethods() as $classMethod) { if (!$classMethod->isPublic()) { @@ -60,26 +60,26 @@ final class EntityObjectTypeResolver } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); $returnType = $phpDocInfo->getReturnType(); - $objectType = $this->typeFinder->find($returnType, \PHPStan\Type\ObjectType::class); - if (!$objectType instanceof \PHPStan\Type\ObjectType) { + $objectType = $this->typeFinder->find($returnType, ObjectType::class); + if (!$objectType instanceof ObjectType) { continue; } return $objectType; } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } - private function resolveFromParentConstruct(\PhpParser\Node\Stmt\Class_ $class) : \PHPStan\Type\SubtractableType + private function resolveFromParentConstruct(Class_ $class) : SubtractableType { - $constructorClassMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$constructorClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { - return new \PHPStan\Type\MixedType(); + $constructorClassMethod = $class->getMethod(MethodName::CONSTRUCT); + if (!$constructorClassMethod instanceof ClassMethod) { + return new MixedType(); } foreach ((array) $constructorClassMethod->stmts as $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { continue; } $argValue = $this->resolveParentConstructSecondArgument($stmt->expr); - if (!$argValue instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if (!$argValue instanceof ClassConstFetch) { continue; } if (!$this->nodeNameResolver->isName($argValue->name, 'class')) { @@ -89,23 +89,23 @@ final class EntityObjectTypeResolver if ($className === null) { continue; } - return new \PHPStan\Type\ObjectType($className); + return new ObjectType($className); } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } - private function resolveParentConstructSecondArgument(\PhpParser\Node\Expr $expr) : ?\PhpParser\Node\Expr + private function resolveParentConstructSecondArgument(Expr $expr) : ?Expr { - if (!$expr instanceof \PhpParser\Node\Expr\StaticCall) { + if (!$expr instanceof StaticCall) { return null; } if (!$this->nodeNameResolver->isName($expr->class, 'parent')) { return null; } - if (!$this->nodeNameResolver->isName($expr->name, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if (!$this->nodeNameResolver->isName($expr->name, MethodName::CONSTRUCT)) { return null; } $secondArg = $expr->args[1] ?? null; - if (!$secondArg instanceof \PhpParser\Node\Arg) { + if (!$secondArg instanceof Arg) { return null; } return $secondArg->value; diff --git a/vendor/rector/rector-doctrine/src/NodeAnalyzer/MethodCallNameOnTypeResolver.php b/vendor/rector/rector-doctrine/src/NodeAnalyzer/MethodCallNameOnTypeResolver.php index 2e0b0e9a258..f79892f920f 100644 --- a/vendor/rector/rector-doctrine/src/NodeAnalyzer/MethodCallNameOnTypeResolver.php +++ b/vendor/rector/rector-doctrine/src/NodeAnalyzer/MethodCallNameOnTypeResolver.php @@ -26,7 +26,7 @@ final class MethodCallNameOnTypeResolver * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(NodeNameResolver $nodeNameResolver, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeTypeResolver $nodeTypeResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; @@ -35,11 +35,11 @@ final class MethodCallNameOnTypeResolver /** * @return string[] */ - public function resolve(\PhpParser\Node $node, \PHPStan\Type\ObjectType $objectType) : array + public function resolve(Node $node, ObjectType $objectType) : array { $methodNames = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($node, function (\PhpParser\Node $node) use(&$methodNames, $objectType) { - if (!$node instanceof \PhpParser\Node\Expr\MethodCall) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($node, function (Node $node) use(&$methodNames, $objectType) { + if (!$node instanceof MethodCall) { return null; } if (!$this->nodeTypeResolver->isObjectType($node->var, $objectType)) { diff --git a/vendor/rector/rector-doctrine/src/NodeAnalyzer/SetterClassMethodAnalyzer.php b/vendor/rector/rector-doctrine/src/NodeAnalyzer/SetterClassMethodAnalyzer.php index d96b358ffcc..f0985f6c493 100644 --- a/vendor/rector/rector-doctrine/src/NodeAnalyzer/SetterClassMethodAnalyzer.php +++ b/vendor/rector/rector-doctrine/src/NodeAnalyzer/SetterClassMethodAnalyzer.php @@ -40,25 +40,25 @@ final class SetterClassMethodAnalyzer * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeTypeResolver $nodeTypeResolver, NodeNameResolver $nodeNameResolver, ReflectionResolver $reflectionResolver, BetterNodeFinder $betterNodeFinder) { $this->nodeTypeResolver = $nodeTypeResolver; $this->nodeNameResolver = $nodeNameResolver; $this->reflectionResolver = $reflectionResolver; $this->betterNodeFinder = $betterNodeFinder; } - public function matchNullalbeClassMethodProperty(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Stmt\Property + public function matchNullalbeClassMethodProperty(ClassMethod $classMethod) : ?Property { $propertyFetch = $this->matchNullalbeClassMethodPropertyFetch($classMethod); - if (!$propertyFetch instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$propertyFetch instanceof PropertyFetch) { return null; } $phpPropertyReflection = $this->reflectionResolver->resolvePropertyReflectionFromPropertyFetch($propertyFetch); - if (!$phpPropertyReflection instanceof \PHPStan\Reflection\Php\PhpPropertyReflection) { + if (!$phpPropertyReflection instanceof PhpPropertyReflection) { return null; } - $classLike = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($classMethod, ClassLike::class); + if (!$classLike instanceof ClassLike) { return null; } $propertyName = (string) $this->nodeNameResolver->getName($propertyFetch->name); @@ -69,20 +69,20 @@ final class SetterClassMethodAnalyzer * * public function setSomething(?Type $someValue); { <$this->someProperty> = $someValue; } */ - private function matchNullalbeClassMethodPropertyFetch(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Expr\PropertyFetch + private function matchNullalbeClassMethodPropertyFetch(ClassMethod $classMethod) : ?PropertyFetch { $propertyFetch = $this->matchSetterOnlyPropertyFetch($classMethod); - if (!$propertyFetch instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$propertyFetch instanceof PropertyFetch) { return null; } // is nullable param $onlyParam = $classMethod->params[0]; - if (!$this->nodeTypeResolver->isNullableTypeOfSpecificType($onlyParam, \PHPStan\Type\ObjectType::class)) { + if (!$this->nodeTypeResolver->isNullableTypeOfSpecificType($onlyParam, ObjectType::class)) { return null; } return $propertyFetch; } - private function matchSetterOnlyPropertyFetch(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Expr\PropertyFetch + private function matchSetterOnlyPropertyFetch(ClassMethod $classMethod) : ?PropertyFetch { if (\count($classMethod->params) !== 1) { return null; @@ -92,16 +92,16 @@ final class SetterClassMethodAnalyzer return null; } $onlyStmt = $stmts[0] ?? null; - if (!$onlyStmt instanceof \PhpParser\Node\Stmt) { + if (!$onlyStmt instanceof Stmt) { return null; } - if ($onlyStmt instanceof \PhpParser\Node\Stmt\Expression) { + if ($onlyStmt instanceof Expression) { $onlyStmt = $onlyStmt->expr; } - if (!$onlyStmt instanceof \PhpParser\Node\Expr\Assign) { + if (!$onlyStmt instanceof Assign) { return null; } - if (!$onlyStmt->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$onlyStmt->var instanceof PropertyFetch) { return null; } $propertyFetch = $onlyStmt->var; @@ -110,9 +110,9 @@ final class SetterClassMethodAnalyzer } return $propertyFetch; } - private function isVariableName(?\PhpParser\Node $node, string $name) : bool + private function isVariableName(?Node $node, string $name) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + if (!$node instanceof Variable) { return \false; } return $this->nodeNameResolver->isName($node, $name); diff --git a/vendor/rector/rector-doctrine/src/NodeAnalyzer/TargetEntityResolver.php b/vendor/rector/rector-doctrine/src/NodeAnalyzer/TargetEntityResolver.php index 747f388ecd3..05ecdc6860c 100644 --- a/vendor/rector/rector-doctrine/src/NodeAnalyzer/TargetEntityResolver.php +++ b/vendor/rector/rector-doctrine/src/NodeAnalyzer/TargetEntityResolver.php @@ -21,7 +21,7 @@ final class TargetEntityResolver * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider) { $this->nodeNameResolver = $nodeNameResolver; $this->reflectionProvider = $reflectionProvider; @@ -29,16 +29,16 @@ final class TargetEntityResolver /** * @return string|null */ - public function resolveFromExpr(\PhpParser\Node\Expr $targetEntityExpr) + public function resolveFromExpr(Expr $targetEntityExpr) { - if ($targetEntityExpr instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if ($targetEntityExpr instanceof ClassConstFetch) { $targetEntity = (string) $this->nodeNameResolver->getName($targetEntityExpr->class); if (!$this->reflectionProvider->hasClass($targetEntity)) { return null; } return $targetEntity; } - if ($targetEntityExpr instanceof \PhpParser\Node\Scalar\String_) { + if ($targetEntityExpr instanceof String_) { $targetEntity = $targetEntityExpr->value; if (!$this->reflectionProvider->hasClass($targetEntity)) { return null; @@ -46,6 +46,6 @@ final class TargetEntityResolver return $targetEntity; } $errorMessage = \sprintf('Add support for "%s" targetEntity in "%s"', \get_class($targetEntityExpr), self::class); - throw new \Rector\Core\Exception\NotImplementedYetException($errorMessage); + throw new NotImplementedYetException($errorMessage); } } diff --git a/vendor/rector/rector-doctrine/src/NodeAnalyzer/TranslatablePropertyCollectorAndRemover.php b/vendor/rector/rector-doctrine/src/NodeAnalyzer/TranslatablePropertyCollectorAndRemover.php index 51038974cdb..9d4ccc35aa0 100644 --- a/vendor/rector/rector-doctrine/src/NodeAnalyzer/TranslatablePropertyCollectorAndRemover.php +++ b/vendor/rector/rector-doctrine/src/NodeAnalyzer/TranslatablePropertyCollectorAndRemover.php @@ -33,14 +33,14 @@ final class TranslatablePropertyCollectorAndRemover * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover $phpDocTagRemover, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\NodeRemoval\NodeRemover $nodeRemover, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(PhpDocTagRemover $phpDocTagRemover, PhpDocInfoFactory $phpDocInfoFactory, NodeRemover $nodeRemover, NodeNameResolver $nodeNameResolver) { $this->phpDocTagRemover = $phpDocTagRemover; $this->phpDocInfoFactory = $phpDocInfoFactory; $this->nodeRemover = $nodeRemover; $this->nodeNameResolver = $nodeNameResolver; } - public function processClass(\PhpParser\Node\Stmt\Class_ $class) : \Rector\Doctrine\ValueObject\PropertyNamesAndPhpDocInfos + public function processClass(Class_ $class) : PropertyNamesAndPhpDocInfos { $propertyNameAndPhpDocInfos = []; foreach ($class->getProperties() as $property) { @@ -50,14 +50,14 @@ final class TranslatablePropertyCollectorAndRemover continue; } $doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass('Gedmo\\Mapping\\Annotation\\Translatable'); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { continue; } $this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $doctrineAnnotationTagValueNode); $propertyName = $this->nodeNameResolver->getName($property); - $propertyNameAndPhpDocInfos[] = new \Rector\Doctrine\ValueObject\PropertyNameAndPhpDocInfo($propertyName, $phpDocInfo); + $propertyNameAndPhpDocInfos[] = new PropertyNameAndPhpDocInfo($propertyName, $phpDocInfo); $this->nodeRemover->removeNode($property); } - return new \Rector\Doctrine\ValueObject\PropertyNamesAndPhpDocInfos($propertyNameAndPhpDocInfos); + return new PropertyNamesAndPhpDocInfos($propertyNameAndPhpDocInfos); } } diff --git a/vendor/rector/rector-doctrine/src/NodeFactory/ArrayCollectionAssignFactory.php b/vendor/rector/rector-doctrine/src/NodeFactory/ArrayCollectionAssignFactory.php index f098de4c62a..9ebcf5bcbae 100644 --- a/vendor/rector/rector-doctrine/src/NodeFactory/ArrayCollectionAssignFactory.php +++ b/vendor/rector/rector-doctrine/src/NodeFactory/ArrayCollectionAssignFactory.php @@ -15,15 +15,15 @@ final class ArrayCollectionAssignFactory * @var \Rector\Core\PhpParser\Node\NodeFactory */ private $nodeFactory; - public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory) + public function __construct(NodeFactory $nodeFactory) { $this->nodeFactory = $nodeFactory; } - public function createFromPropertyName(string $toManyPropertyName) : \PhpParser\Node\Stmt\Expression + public function createFromPropertyName(string $toManyPropertyName) : Expression { $propertyFetch = $this->nodeFactory->createPropertyFetch('this', $toManyPropertyName); - $new = new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name\FullyQualified('Doctrine\\Common\\Collections\\ArrayCollection')); - $assign = new \PhpParser\Node\Expr\Assign($propertyFetch, $new); - return new \PhpParser\Node\Stmt\Expression($assign); + $new = new New_(new FullyQualified('Doctrine\\Common\\Collections\\ArrayCollection')); + $assign = new Assign($propertyFetch, $new); + return new Expression($assign); } } diff --git a/vendor/rector/rector-doctrine/src/NodeFactory/ConstructClassMethodFactory.php b/vendor/rector/rector-doctrine/src/NodeFactory/ConstructClassMethodFactory.php index 98290aec031..5da087a17dd 100644 --- a/vendor/rector/rector-doctrine/src/NodeFactory/ConstructClassMethodFactory.php +++ b/vendor/rector/rector-doctrine/src/NodeFactory/ConstructClassMethodFactory.php @@ -34,13 +34,13 @@ final class ConstructClassMethodFactory * @var \Rector\StaticTypeMapper\StaticTypeMapper */ private $staticTypeMapper; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper) + public function __construct(NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver, StaticTypeMapper $staticTypeMapper) { $this->nodeNameResolver = $nodeNameResolver; $this->nodeTypeResolver = $nodeTypeResolver; $this->staticTypeMapper = $staticTypeMapper; } - public function createFromPublicClassProperties(\PhpParser\Node\Stmt\Class_ $class) : ?\PhpParser\Node\Stmt\ClassMethod + public function createFromPublicClassProperties(Class_ $class) : ?ClassMethod { $publicProperties = $this->resolvePublicProperties($class); if ($publicProperties === []) { @@ -54,7 +54,7 @@ final class ConstructClassMethodFactory $params[] = $this->createParam($publicProperty, $propertyName); $assigns[] = $this->createAssign($propertyName); } - $methodBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\MethodBuilder(\Rector\Core\ValueObject\MethodName::CONSTRUCT); + $methodBuilder = new MethodBuilder(MethodName::CONSTRUCT); $methodBuilder->makePublic(); $methodBuilder->addParams($params); $methodBuilder->addStmts($assigns); @@ -63,7 +63,7 @@ final class ConstructClassMethodFactory /** * @return Property[] */ - private function resolvePublicProperties(\PhpParser\Node\Stmt\Class_ $class) : array + private function resolvePublicProperties(Class_ $class) : array { $publicProperties = []; foreach ($class->getProperties() as $property) { @@ -74,19 +74,19 @@ final class ConstructClassMethodFactory } return $publicProperties; } - private function createAssign(string $name) : \PhpParser\Node\Stmt\Expression + private function createAssign(string $name) : Expression { - $propertyFetch = new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable('this'), $name); - $variable = new \PhpParser\Node\Expr\Variable($name); - $assign = new \PhpParser\Node\Expr\Assign($propertyFetch, $variable); - return new \PhpParser\Node\Stmt\Expression($assign); + $propertyFetch = new PropertyFetch(new Variable('this'), $name); + $variable = new Variable($name); + $assign = new Assign($propertyFetch, $variable); + return new Expression($assign); } - private function createParam(\PhpParser\Node\Stmt\Property $property, string $propertyName) : \PhpParser\Node\Param + private function createParam(Property $property, string $propertyName) : Param { $propertyType = $this->nodeTypeResolver->getType($property); - $propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY); - $paramVariable = new \PhpParser\Node\Expr\Variable($propertyName); - $param = new \PhpParser\Node\Param($paramVariable); + $propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, TypeKind::PROPERTY); + $paramVariable = new Variable($propertyName); + $param = new Param($paramVariable); $param->type = $propertyTypeNode; return $param; } diff --git a/vendor/rector/rector-doctrine/src/NodeFactory/ConstructorClassMethodAssignFactory.php b/vendor/rector/rector-doctrine/src/NodeFactory/ConstructorClassMethodAssignFactory.php index 5444f70681e..f34bdcbf5f7 100644 --- a/vendor/rector/rector-doctrine/src/NodeFactory/ConstructorClassMethodAssignFactory.php +++ b/vendor/rector/rector-doctrine/src/NodeFactory/ConstructorClassMethodAssignFactory.php @@ -17,9 +17,9 @@ final class ConstructorClassMethodAssignFactory { $expressions = []; foreach ($paramNames as $paramName) { - $propertyFetch = new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable('this'), $paramName); - $assign = new \PhpParser\Node\Expr\Assign($propertyFetch, new \PhpParser\Node\Expr\Variable($paramName)); - $expressions[] = new \PhpParser\Node\Stmt\Expression($assign); + $propertyFetch = new PropertyFetch(new Variable('this'), $paramName); + $assign = new Assign($propertyFetch, new Variable($paramName)); + $expressions[] = new Expression($assign); } return $expressions; } diff --git a/vendor/rector/rector-doctrine/src/NodeFactory/EntityIdNodeFactory.php b/vendor/rector/rector-doctrine/src/NodeFactory/EntityIdNodeFactory.php index 3cb559d8194..79c0d20175d 100644 --- a/vendor/rector/rector-doctrine/src/NodeFactory/EntityIdNodeFactory.php +++ b/vendor/rector/rector-doctrine/src/NodeFactory/EntityIdNodeFactory.php @@ -22,29 +22,29 @@ final class EntityIdNodeFactory * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory */ private $phpDocInfoFactory; - public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory) + public function __construct(NodeFactory $nodeFactory, PhpDocInfoFactory $phpDocInfoFactory) { $this->nodeFactory = $nodeFactory; $this->phpDocInfoFactory = $phpDocInfoFactory; } - public function createIdProperty() : \PhpParser\Node\Stmt\Property + public function createIdProperty() : Property { $idProperty = $this->nodeFactory->createPrivateProperty('id'); $this->decoratePropertyWithIdAnnotations($idProperty); return $idProperty; } - private function decoratePropertyWithIdAnnotations(\PhpParser\Node\Stmt\Property $property) : void + private function decoratePropertyWithIdAnnotations(Property $property) : void { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); // add @var int - $identifierTypeNode = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('int'); - $varTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode($identifierTypeNode, '', ''); + $identifierTypeNode = new IdentifierTypeNode('int'); + $varTagValueNode = new VarTagValueNode($identifierTypeNode, '', ''); $phpDocInfo->addTagValueNode($varTagValueNode); // add @ORM\Id $phpDocTagNodes = []; - $phpDocTagNodes[] = new \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode('@ORM\\Id', new \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode(new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('Doctrine\\ORM\\Mapping\\Id'), null, [])); - $phpDocTagNodes[] = new \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode('@ORM\\Column', new \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode(new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('Doctrine\\ORM\\Mapping\\Column'), null, ['type' => '"integer"'])); - $phpDocTagNodes[] = new \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode('@ORM\\GeneratedValue', new \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode(new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('Doctrine\\ORM\\Mapping\\GeneratedValue'), null, ['strategy' => '"AUTO"'])); + $phpDocTagNodes[] = new SpacelessPhpDocTagNode('@ORM\\Id', new DoctrineAnnotationTagValueNode(new IdentifierTypeNode('Doctrine\\ORM\\Mapping\\Id'), null, [])); + $phpDocTagNodes[] = new SpacelessPhpDocTagNode('@ORM\\Column', new DoctrineAnnotationTagValueNode(new IdentifierTypeNode('Doctrine\\ORM\\Mapping\\Column'), null, ['type' => '"integer"'])); + $phpDocTagNodes[] = new SpacelessPhpDocTagNode('@ORM\\GeneratedValue', new DoctrineAnnotationTagValueNode(new IdentifierTypeNode('Doctrine\\ORM\\Mapping\\GeneratedValue'), null, ['strategy' => '"AUTO"'])); foreach ($phpDocTagNodes as $phpDocTagNode) { $phpDocInfo->addPhpDocTagNode($phpDocTagNode); } diff --git a/vendor/rector/rector-doctrine/src/NodeFactory/ParamFactory.php b/vendor/rector/rector-doctrine/src/NodeFactory/ParamFactory.php index ed1181a9edc..519dd059592 100644 --- a/vendor/rector/rector-doctrine/src/NodeFactory/ParamFactory.php +++ b/vendor/rector/rector-doctrine/src/NodeFactory/ParamFactory.php @@ -37,7 +37,7 @@ final class ParamFactory * @var \Rector\Core\PhpParser\Node\NodeFactory */ private $nodeFactory; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory) + public function __construct(NodeTypeResolver $nodeTypeResolver, StaticTypeMapper $staticTypeMapper, NodeNameResolver $nodeNameResolver, NodeFactory $nodeFactory) { $this->nodeTypeResolver = $nodeTypeResolver; $this->staticTypeMapper = $staticTypeMapper; @@ -61,20 +61,20 @@ final class ParamFactory /** * @param string[] $optionalParamNames */ - public function createFromPropertyFetch(\PhpParser\Node\Expr\PropertyFetch $propertyFetch, array $optionalParamNames) : \PhpParser\Node\Param + public function createFromPropertyFetch(PropertyFetch $propertyFetch, array $optionalParamNames) : Param { $propertyName = $this->nodeNameResolver->getName($propertyFetch->name); if ($propertyName === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } - $variable = new \PhpParser\Node\Expr\Variable($propertyName); - $param = new \PhpParser\Node\Param($variable); + $variable = new Variable($propertyName); + $param = new Param($variable); $paramType = $this->nodeTypeResolver->getType($propertyFetch); - $paramTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($paramType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM); + $paramTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($paramType, TypeKind::PARAM); // the param is optional - make it nullable if (\in_array($propertyName, $optionalParamNames, \true)) { - if (!$paramTypeNode instanceof \PhpParser\Node\ComplexType && $paramTypeNode !== null) { - $paramTypeNode = new \PhpParser\Node\NullableType($paramTypeNode); + if (!$paramTypeNode instanceof ComplexType && $paramTypeNode !== null) { + $paramTypeNode = new NullableType($paramTypeNode); } $param->default = $this->nodeFactory->createNull(); } diff --git a/vendor/rector/rector-doctrine/src/NodeFactory/RepositoryAssignFactory.php b/vendor/rector/rector-doctrine/src/NodeFactory/RepositoryAssignFactory.php index dcf4d109b29..704cfa4995c 100644 --- a/vendor/rector/rector-doctrine/src/NodeFactory/RepositoryAssignFactory.php +++ b/vendor/rector/rector-doctrine/src/NodeFactory/RepositoryAssignFactory.php @@ -27,7 +27,7 @@ final class RepositoryAssignFactory * @var \Rector\Core\PhpParser\Node\NodeFactory */ private $nodeFactory; - public function __construct(\Rector\Doctrine\NodeAnalyzer\EntityObjectTypeResolver $entityObjectTypeResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory) + public function __construct(EntityObjectTypeResolver $entityObjectTypeResolver, NodeNameResolver $nodeNameResolver, NodeFactory $nodeFactory) { $this->entityObjectTypeResolver = $entityObjectTypeResolver; $this->nodeNameResolver = $nodeNameResolver; @@ -36,16 +36,16 @@ final class RepositoryAssignFactory /** * Creates: "$this->repository = $entityManager->getRepository(SomeEntityClass::class)" */ - public function create(\PhpParser\Node\Stmt\Class_ $repositoryClass) : \PhpParser\Node\Expr\Assign + public function create(Class_ $repositoryClass) : Assign { $entityObjectType = $this->entityObjectTypeResolver->resolveFromRepositoryClass($repositoryClass); $className = $this->nodeNameResolver->getName($repositoryClass); if (!\is_string($className)) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $repositoryClassName = $className; - if (!$entityObjectType instanceof \PHPStan\Type\TypeWithClassName) { - throw new \Rector\Core\Exception\ShouldNotHappenException(\sprintf('An entity was not found for "%s" repository.', $repositoryClassName)); + if (!$entityObjectType instanceof TypeWithClassName) { + throw new ShouldNotHappenException(\sprintf('An entity was not found for "%s" repository.', $repositoryClassName)); } $classConstFetch = $this->nodeFactory->createClassConstReference($entityObjectType->getClassName()); $methodCall = $this->nodeFactory->createMethodCall('entityManager', 'getRepository', [$classConstFetch]); diff --git a/vendor/rector/rector-doctrine/src/NodeFactory/RepositoryNodeFactory.php b/vendor/rector/rector-doctrine/src/NodeFactory/RepositoryNodeFactory.php index cbb1b218d2c..e5a1ad3643b 100644 --- a/vendor/rector/rector-doctrine/src/NodeFactory/RepositoryNodeFactory.php +++ b/vendor/rector/rector-doctrine/src/NodeFactory/RepositoryNodeFactory.php @@ -12,14 +12,14 @@ use PhpParser\Node\Expr\Variable; use PhpParser\Node\Identifier; final class RepositoryNodeFactory { - public function createRepositoryAssign(\PhpParser\Node\Expr $entityReferenceExpr) : \PhpParser\Node\Expr\Assign + public function createRepositoryAssign(Expr $entityReferenceExpr) : Assign { - $propertyFetch = new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable('this'), new \PhpParser\Node\Identifier('repository')); - return new \PhpParser\Node\Expr\Assign($propertyFetch, $this->createGetRepositoryMethodCall($entityReferenceExpr)); + $propertyFetch = new PropertyFetch(new Variable('this'), new Identifier('repository')); + return new Assign($propertyFetch, $this->createGetRepositoryMethodCall($entityReferenceExpr)); } - private function createGetRepositoryMethodCall(\PhpParser\Node\Expr $entityReferenceExpr) : \PhpParser\Node\Expr\MethodCall + private function createGetRepositoryMethodCall(Expr $entityReferenceExpr) : MethodCall { - $args = [new \PhpParser\Node\Arg($entityReferenceExpr)]; - return new \PhpParser\Node\Expr\MethodCall(new \PhpParser\Node\Expr\Variable('entityManager'), 'getRepository', $args); + $args = [new Arg($entityReferenceExpr)]; + return new MethodCall(new Variable('entityManager'), 'getRepository', $args); } } diff --git a/vendor/rector/rector-doctrine/src/NodeFactory/TranslationClassNodeFactory.php b/vendor/rector/rector-doctrine/src/NodeFactory/TranslationClassNodeFactory.php index 0c48829cb89..61f14bf1a47 100644 --- a/vendor/rector/rector-doctrine/src/NodeFactory/TranslationClassNodeFactory.php +++ b/vendor/rector/rector-doctrine/src/NodeFactory/TranslationClassNodeFactory.php @@ -24,22 +24,22 @@ final class TranslationClassNodeFactory * @var \Rector\Core\NodeManipulator\ClassInsertManipulator */ private $classInsertManipulator; - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory, ClassInsertManipulator $classInsertManipulator) { $this->phpDocInfoFactory = $phpDocInfoFactory; $this->classInsertManipulator = $classInsertManipulator; } - public function create(string $classShortName) : \PhpParser\Node\Stmt\Class_ + public function create(string $classShortName) : Class_ { - $class = new \PhpParser\Node\Stmt\Class_($classShortName); - $class->implements[] = new \PhpParser\Node\Name\FullyQualified('Knp\\DoctrineBehaviors\\Contract\\Entity\\TranslationInterface'); + $class = new Class_($classShortName); + $class->implements[] = new FullyQualified('Knp\\DoctrineBehaviors\\Contract\\Entity\\TranslationInterface'); $this->classInsertManipulator->addAsFirstTrait($class, 'Knp\\DoctrineBehaviors\\Model\\Translatable\\TranslationTrait'); $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($class); - $spacelessPhpDocTagNode = new \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode('@ORM\\Entity', new \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode(new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('Doctrine\\ORM\\Mapping\\Entity'), null, [])); + $spacelessPhpDocTagNode = new SpacelessPhpDocTagNode('@ORM\\Entity', new DoctrineAnnotationTagValueNode(new IdentifierTypeNode('Doctrine\\ORM\\Mapping\\Entity'), null, [])); $phpDocInfo->addPhpDocTagNode($spacelessPhpDocTagNode); // traverse with node name resolver, to to comply with PHPStan default parser - $nameResolver = new \PhpParser\NodeVisitor\NameResolver(null, ['replaceNodes' => \false, 'preserveOriginalNames' => \true]); - $nodeTraverser = new \PhpParser\NodeTraverser(); + $nameResolver = new NameResolver(null, ['replaceNodes' => \false, 'preserveOriginalNames' => \true]); + $nodeTraverser = new NodeTraverser(); $nodeTraverser->addVisitor($nameResolver); $nodeTraverser->traverse([$class]); return $class; diff --git a/vendor/rector/rector-doctrine/src/NodeFactory/ValueAssignFactory.php b/vendor/rector/rector-doctrine/src/NodeFactory/ValueAssignFactory.php index 5a45147125d..71dc0885241 100644 --- a/vendor/rector/rector-doctrine/src/NodeFactory/ValueAssignFactory.php +++ b/vendor/rector/rector-doctrine/src/NodeFactory/ValueAssignFactory.php @@ -14,33 +14,33 @@ use PhpParser\Node\Scalar\String_; use PhpParser\Node\Stmt\Expression; final class ValueAssignFactory { - public function createDefaultDateTimeAssign(string $propertyName) : \PhpParser\Node\Stmt\Expression + public function createDefaultDateTimeAssign(string $propertyName) : Expression { $propertyFetch = $this->createPropertyFetch($propertyName); - $assign = new \PhpParser\Node\Expr\Assign($propertyFetch, $this->createNewDateTime()); - return new \PhpParser\Node\Stmt\Expression($assign); + $assign = new Assign($propertyFetch, $this->createNewDateTime()); + return new Expression($assign); } - public function createDefaultDateTimeWithValueAssign(string $propertyName, \PhpParser\Node\Expr $defaultExpr) : \PhpParser\Node\Stmt\Expression + public function createDefaultDateTimeWithValueAssign(string $propertyName, Expr $defaultExpr) : Expression { $propertyFetch = $this->createPropertyFetch($propertyName); $newDateTime = $this->createNewDateTime(); $this->addDateTimeArgumentIfNotDefault($defaultExpr, $newDateTime); - $assign = new \PhpParser\Node\Expr\Assign($propertyFetch, $newDateTime); - return new \PhpParser\Node\Stmt\Expression($assign); + $assign = new Assign($propertyFetch, $newDateTime); + return new Expression($assign); } - private function createPropertyFetch(string $propertyName) : \PhpParser\Node\Expr\PropertyFetch + private function createPropertyFetch(string $propertyName) : PropertyFetch { - return new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable('this'), $propertyName); + return new PropertyFetch(new Variable('this'), $propertyName); } - private function createNewDateTime() : \PhpParser\Node\Expr\New_ + private function createNewDateTime() : New_ { - return new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name\FullyQualified('DateTime')); + return new New_(new FullyQualified('DateTime')); } - private function addDateTimeArgumentIfNotDefault(\PhpParser\Node\Expr $defaultExpr, \PhpParser\Node\Expr\New_ $dateTimeNew) : void + private function addDateTimeArgumentIfNotDefault(Expr $defaultExpr, New_ $dateTimeNew) : void { - if ($defaultExpr instanceof \PhpParser\Node\Scalar\String_ && ($defaultExpr->value === 'now' || $defaultExpr->value === 'now()')) { + if ($defaultExpr instanceof String_ && ($defaultExpr->value === 'now' || $defaultExpr->value === 'now()')) { return; } - $dateTimeNew->args[] = new \PhpParser\Node\Arg($defaultExpr); + $dateTimeNew->args[] = new Arg($defaultExpr); } } diff --git a/vendor/rector/rector-doctrine/src/NodeManipulator/ColumnPropertyTypeResolver.php b/vendor/rector/rector-doctrine/src/NodeManipulator/ColumnPropertyTypeResolver.php index 54d0e162f84..52704bffc24 100644 --- a/vendor/rector/rector-doctrine/src/NodeManipulator/ColumnPropertyTypeResolver.php +++ b/vendor/rector/rector-doctrine/src/NodeManipulator/ColumnPropertyTypeResolver.php @@ -52,54 +52,54 @@ final class ColumnPropertyTypeResolver * @param array $doctrineTypeToScalarType * @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/basic-mapping.html#doctrine-mapping-types */ - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \Rector\Doctrine\NodeAnalyzer\AttributeFinder $attributeFinder, array $doctrineTypeToScalarType = null) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory, TypeFactory $typeFactory, AttributeFinder $attributeFinder, array $doctrineTypeToScalarType = null) { $doctrineTypeToScalarType = $doctrineTypeToScalarType ?? [ - 'tinyint' => new \PHPStan\Type\BooleanType(), - 'boolean' => new \PHPStan\Type\BooleanType(), + 'tinyint' => new BooleanType(), + 'boolean' => new BooleanType(), // integers - 'smallint' => new \PHPStan\Type\IntegerType(), - 'mediumint' => new \PHPStan\Type\IntegerType(), - 'int' => new \PHPStan\Type\IntegerType(), - 'integer' => new \PHPStan\Type\IntegerType(), - 'numeric' => new \PHPStan\Type\IntegerType(), + 'smallint' => new IntegerType(), + 'mediumint' => new IntegerType(), + 'int' => new IntegerType(), + 'integer' => new IntegerType(), + 'numeric' => new IntegerType(), // floats - 'float' => new \PHPStan\Type\FloatType(), - 'double' => new \PHPStan\Type\FloatType(), - 'real' => new \PHPStan\Type\FloatType(), + 'float' => new FloatType(), + 'double' => new FloatType(), + 'real' => new FloatType(), // strings - 'decimal' => new \PHPStan\Type\StringType(), - 'bigint' => new \PHPStan\Type\StringType(), - 'tinytext' => new \PHPStan\Type\StringType(), - 'mediumtext' => new \PHPStan\Type\StringType(), - 'longtext' => new \PHPStan\Type\StringType(), - 'text' => new \PHPStan\Type\StringType(), - 'varchar' => new \PHPStan\Type\StringType(), - 'string' => new \PHPStan\Type\StringType(), - 'char' => new \PHPStan\Type\StringType(), - 'longblob' => new \PHPStan\Type\StringType(), - 'blob' => new \PHPStan\Type\StringType(), - 'mediumblob' => new \PHPStan\Type\StringType(), - 'tinyblob' => new \PHPStan\Type\StringType(), - 'binary' => new \PHPStan\Type\StringType(), - 'varbinary' => new \PHPStan\Type\StringType(), - 'set' => new \PHPStan\Type\StringType(), + 'decimal' => new StringType(), + 'bigint' => new StringType(), + 'tinytext' => new StringType(), + 'mediumtext' => new StringType(), + 'longtext' => new StringType(), + 'text' => new StringType(), + 'varchar' => new StringType(), + 'string' => new StringType(), + 'char' => new StringType(), + 'longblob' => new StringType(), + 'blob' => new StringType(), + 'mediumblob' => new StringType(), + 'tinyblob' => new StringType(), + 'binary' => new StringType(), + 'varbinary' => new StringType(), + 'set' => new StringType(), // date time objects - 'date' => new \PHPStan\Type\ObjectType(self::DATE_TIME_INTERFACE), - 'datetime' => new \PHPStan\Type\ObjectType(self::DATE_TIME_INTERFACE), - 'timestamp' => new \PHPStan\Type\ObjectType(self::DATE_TIME_INTERFACE), - 'time' => new \PHPStan\Type\ObjectType(self::DATE_TIME_INTERFACE), - 'year' => new \PHPStan\Type\ObjectType(self::DATE_TIME_INTERFACE), + 'date' => new ObjectType(self::DATE_TIME_INTERFACE), + 'datetime' => new ObjectType(self::DATE_TIME_INTERFACE), + 'timestamp' => new ObjectType(self::DATE_TIME_INTERFACE), + 'time' => new ObjectType(self::DATE_TIME_INTERFACE), + 'year' => new ObjectType(self::DATE_TIME_INTERFACE), ]; $this->phpDocInfoFactory = $phpDocInfoFactory; $this->typeFactory = $typeFactory; $this->attributeFinder = $attributeFinder; $this->doctrineTypeToScalarType = $doctrineTypeToScalarType; } - public function resolve(\PhpParser\Node\Stmt\Property $property, bool $isNullable) : ?\PHPStan\Type\Type + public function resolve(Property $property, bool $isNullable) : ?Type { $argValue = $this->attributeFinder->findAttributeByClassArgByName($property, self::COLUMN_CLASS, 'type'); - if ($argValue instanceof \PhpParser\Node\Scalar\String_) { + if ($argValue instanceof String_) { return $this->createPHPStanTypeFromDoctrineStringType($argValue->value, $isNullable); } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); @@ -108,15 +108,15 @@ final class ColumnPropertyTypeResolver /** * @return null|\PHPStan\Type\Type */ - private function resolveFromPhpDocInfo(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, bool $isNullable) + private function resolveFromPhpDocInfo(PhpDocInfo $phpDocInfo, bool $isNullable) { $doctrineAnnotationTagValueNode = $phpDocInfo->findOneByAnnotationClass(self::COLUMN_CLASS); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return null; } $type = $doctrineAnnotationTagValueNode->getValueWithoutQuotes('type'); if (!\is_string($type)) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } return $this->createPHPStanTypeFromDoctrineStringType($type, $isNullable); } @@ -126,12 +126,12 @@ final class ColumnPropertyTypeResolver private function createPHPStanTypeFromDoctrineStringType(string $type, bool $isNullable) { $scalarType = $this->doctrineTypeToScalarType[$type] ?? null; - if (!$scalarType instanceof \PHPStan\Type\Type) { - return new \PHPStan\Type\MixedType(); + if (!$scalarType instanceof Type) { + return new MixedType(); } $types = [$scalarType]; if ($isNullable) { - $types[] = new \PHPStan\Type\NullType(); + $types[] = new NullType(); } return $this->typeFactory->createMixedPassedOrUnionType($types); } diff --git a/vendor/rector/rector-doctrine/src/NodeManipulator/ConstructorManipulator.php b/vendor/rector/rector-doctrine/src/NodeManipulator/ConstructorManipulator.php index 58cf465659a..f2d9e87e484 100644 --- a/vendor/rector/rector-doctrine/src/NodeManipulator/ConstructorManipulator.php +++ b/vendor/rector/rector-doctrine/src/NodeManipulator/ConstructorManipulator.php @@ -22,21 +22,21 @@ final class ConstructorManipulator * @var \Rector\Core\NodeManipulator\ClassInsertManipulator */ private $classInsertManipulator; - public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator) + public function __construct(NodeFactory $nodeFactory, ClassInsertManipulator $classInsertManipulator) { $this->nodeFactory = $nodeFactory; $this->classInsertManipulator = $classInsertManipulator; } - public function addStmtToConstructor(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\Expression $newExpression) : void + public function addStmtToConstructor(Class_ $class, Expression $newExpression) : void { - $constructClassMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if ($constructClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $constructClassMethod = $class->getMethod(MethodName::CONSTRUCT); + if ($constructClassMethod instanceof ClassMethod) { $constructClassMethod->stmts[] = $newExpression; } else { - $constructClassMethod = $this->nodeFactory->createPublicMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); + $constructClassMethod = $this->nodeFactory->createPublicMethod(MethodName::CONSTRUCT); $constructClassMethod->stmts[] = $newExpression; $this->classInsertManipulator->addAsFirstMethod($class, $constructClassMethod); - $class->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $class->setAttribute(AttributeKey::ORIGINAL_NODE, null); } } } diff --git a/vendor/rector/rector-doctrine/src/NodeManipulator/DependencyRemover.php b/vendor/rector/rector-doctrine/src/NodeManipulator/DependencyRemover.php index 74c0ff6c665..d0f38d4ec09 100644 --- a/vendor/rector/rector-doctrine/src/NodeManipulator/DependencyRemover.php +++ b/vendor/rector/rector-doctrine/src/NodeManipulator/DependencyRemover.php @@ -31,13 +31,13 @@ final class DependencyRemover * @var \Rector\NodeRemoval\NodeRemover */ private $nodeRemover; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeRemoval\NodeRemover $nodeRemover) + public function __construct(NodeNameResolver $nodeNameResolver, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeRemover $nodeRemover) { $this->nodeNameResolver = $nodeNameResolver; $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->nodeRemover = $nodeRemover; } - public function removeByType(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Param $registryParam, string $type) : void + public function removeByType(Class_ $class, ClassMethod $classMethod, Param $registryParam, string $type) : void { // remove constructor param: $managerRegistry foreach ($classMethod->params as $key => $param) { @@ -51,13 +51,13 @@ final class DependencyRemover } $this->removeRegistryDependencyAssign($class, $classMethod, $registryParam); } - private function removeRegistryDependencyAssign(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Param $registryParam) : void + private function removeRegistryDependencyAssign(Class_ $class, ClassMethod $classMethod, Param $registryParam) : void { foreach ((array) $classMethod->stmts as $constructorMethodStmt) { - if (!$constructorMethodStmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$constructorMethodStmt instanceof Expression) { continue; } - if (!$constructorMethodStmt->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$constructorMethodStmt->expr instanceof Assign) { continue; } /** @var Assign $assign */ @@ -71,21 +71,21 @@ final class DependencyRemover break; } } - private function removeManagerRegistryProperty(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Expr\Assign $assign) : void + private function removeManagerRegistryProperty(Class_ $class, Assign $assign) : void { $removedPropertyName = $this->nodeNameResolver->getName($assign->var); if ($removedPropertyName === null) { return; } - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($class->stmts, function (\PhpParser\Node $node) use($removedPropertyName) : ?int { - if (!$node instanceof \PhpParser\Node\Stmt\Property) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($class->stmts, function (Node $node) use($removedPropertyName) : ?int { + if (!$node instanceof Property) { return null; } if (!$this->nodeNameResolver->isName($node, $removedPropertyName)) { return null; } $this->nodeRemover->removeNode($node); - return \PhpParser\NodeTraverser::STOP_TRAVERSAL; + return NodeTraverser::STOP_TRAVERSAL; }); } } diff --git a/vendor/rector/rector-doctrine/src/NodeManipulator/DoctrineItemDefaultValueManipulator.php b/vendor/rector/rector-doctrine/src/NodeManipulator/DoctrineItemDefaultValueManipulator.php index 7c8c3a6c9fb..d96b0992131 100644 --- a/vendor/rector/rector-doctrine/src/NodeManipulator/DoctrineItemDefaultValueManipulator.php +++ b/vendor/rector/rector-doctrine/src/NodeManipulator/DoctrineItemDefaultValueManipulator.php @@ -13,7 +13,7 @@ final class DoctrineItemDefaultValueManipulator /** * @param string|bool|int $defaultValue */ - public function remove(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, string $item, $defaultValue) : void + public function remove(PhpDocInfo $phpDocInfo, DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, string $item, $defaultValue) : void { if (!$this->hasItemWithDefaultValue($doctrineAnnotationTagValueNode, $item, $defaultValue)) { return; @@ -24,19 +24,19 @@ final class DoctrineItemDefaultValueManipulator /** * @param string|bool|int $defaultValue */ - private function hasItemWithDefaultValue(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, string $itemKey, $defaultValue) : bool + private function hasItemWithDefaultValue(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, string $itemKey, $defaultValue) : bool { $currentValue = $doctrineAnnotationTagValueNode->getValueWithoutQuotes($itemKey); if ($currentValue === null) { return \false; } if ($defaultValue === \false) { - return $currentValue instanceof \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprFalseNode; + return $currentValue instanceof ConstExprFalseNode; } if ($defaultValue === \true) { - return $currentValue instanceof \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprTrueNode; + return $currentValue instanceof ConstExprTrueNode; } - if (\is_int($defaultValue) && $currentValue instanceof \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode) { + if (\is_int($defaultValue) && $currentValue instanceof ConstExprIntegerNode) { $currentValue = (int) $currentValue->value; } return $currentValue === $defaultValue; diff --git a/vendor/rector/rector-doctrine/src/NodeManipulator/IssetDimFetchCleaner.php b/vendor/rector/rector-doctrine/src/NodeManipulator/IssetDimFetchCleaner.php index d93225a8058..a640759f9e5 100644 --- a/vendor/rector/rector-doctrine/src/NodeManipulator/IssetDimFetchCleaner.php +++ b/vendor/rector/rector-doctrine/src/NodeManipulator/IssetDimFetchCleaner.php @@ -39,7 +39,7 @@ final class IssetDimFetchCleaner * @var \Rector\NodeRemoval\NodeRemover */ private $nodeRemover; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\NodeRemoval\NodeRemover $nodeRemover) + public function __construct(BetterNodeFinder $betterNodeFinder, ValueResolver $valueResolver, NodeComparator $nodeComparator, NodeRemover $nodeRemover) { $this->betterNodeFinder = $betterNodeFinder; $this->valueResolver = $valueResolver; @@ -49,18 +49,18 @@ final class IssetDimFetchCleaner /** * @return string[] */ - public function resolveOptionalParamNames(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Expr\Variable $paramVariable) : array + public function resolveOptionalParamNames(ClassMethod $classMethod, Variable $paramVariable) : array { $optionalParamNames = []; foreach ((array) $classMethod->stmts as $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\If_) { + if (!$stmt instanceof If_) { continue; } /** @var If_ $if */ $if = $stmt; /** @var Isset_|null $isset */ - $isset = $this->betterNodeFinder->findFirstInstanceOf($if->cond, \PhpParser\Node\Expr\Isset_::class); - if (!$isset instanceof \PhpParser\Node\Expr\Isset_) { + $isset = $this->betterNodeFinder->findFirstInstanceOf($if->cond, Isset_::class); + if (!$isset instanceof Isset_) { continue; } foreach ($isset->vars as $var) { @@ -79,17 +79,17 @@ final class IssetDimFetchCleaner } return $optionalParamNames; } - public function removeArrayDimFetchIssets(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Expr\Variable $paramVariable) : void + public function removeArrayDimFetchIssets(ClassMethod $classMethod, Variable $paramVariable) : void { foreach ((array) $classMethod->stmts as $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\If_) { + if (!$stmt instanceof If_) { continue; } /** @var If_ $if */ $if = $stmt; /** @var Isset_|null $isset */ - $isset = $this->betterNodeFinder->findFirstInstanceOf($if->cond, \PhpParser\Node\Expr\Isset_::class); - if (!$isset instanceof \PhpParser\Node\Expr\Isset_) { + $isset = $this->betterNodeFinder->findFirstInstanceOf($if->cond, Isset_::class); + if (!$isset instanceof Isset_) { continue; } foreach ($isset->vars as $var) { @@ -101,9 +101,9 @@ final class IssetDimFetchCleaner } } } - private function isArrayDimFetchOnVariable(\PhpParser\Node\Expr $expr, \PhpParser\Node\Expr\Variable $desiredVariable) : bool + private function isArrayDimFetchOnVariable(Expr $expr, Variable $desiredVariable) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$expr instanceof ArrayDimFetch) { return \false; } return $this->nodeComparator->areNodesEqual($desiredVariable, $expr->var); @@ -111,9 +111,9 @@ final class IssetDimFetchCleaner /** * @return mixed|mixed[]|string|null */ - private function matchArrayDimFetchValue(\PhpParser\Node\Expr $expr, \PhpParser\Node\Expr\Variable $variable) + private function matchArrayDimFetchValue(Expr $expr, Variable $variable) { - if (!$expr instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$expr instanceof ArrayDimFetch) { return null; } if ($expr->dim === null) { @@ -124,12 +124,12 @@ final class IssetDimFetchCleaner } return $this->valueResolver->getValue($expr->dim); } - private function isRequiredIsset(\PhpParser\Node\Expr\Isset_ $isset, \PhpParser\Node\Stmt\If_ $if) : bool + private function isRequiredIsset(Isset_ $isset, If_ $if) : bool { - $issetParent = $isset->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$issetParent instanceof \PhpParser\Node\Expr\BooleanNot) { + $issetParent = $isset->getAttribute(AttributeKey::PARENT_NODE); + if (!$issetParent instanceof BooleanNot) { return \false; } - return $this->betterNodeFinder->hasInstancesOf($if->stmts, [\PhpParser\Node\Expr\Throw_::class, \PhpParser\Node\Stmt\Throw_::class]); + return $this->betterNodeFinder->hasInstancesOf($if->stmts, [Throw_::class, ThrowStmt::class]); } } diff --git a/vendor/rector/rector-doctrine/src/NodeManipulator/NullabilityColumnPropertyTypeResolver.php b/vendor/rector/rector-doctrine/src/NodeManipulator/NullabilityColumnPropertyTypeResolver.php index 15706053348..10f87a40d3a 100644 --- a/vendor/rector/rector-doctrine/src/NodeManipulator/NullabilityColumnPropertyTypeResolver.php +++ b/vendor/rector/rector-doctrine/src/NodeManipulator/NullabilityColumnPropertyTypeResolver.php @@ -35,28 +35,28 @@ final class NullabilityColumnPropertyTypeResolver /** * @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/basic-mapping.html#doctrine-mapping-types */ - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Doctrine\NodeAnalyzer\AttributeFinder $attributeFinder, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory, AttributeFinder $attributeFinder, ValueResolver $valueResolver) { $this->phpDocInfoFactory = $phpDocInfoFactory; $this->attributeFinder = $attributeFinder; $this->valueResolver = $valueResolver; } - public function isNullable(\PhpParser\Node\Stmt\Property $property) : bool + public function isNullable(Property $property) : bool { $nullableExpr = $this->attributeFinder->findAttributeByClassArgByName($property, self::COLUMN_CLASS, 'nullable'); - if ($nullableExpr instanceof \PhpParser\Node\Expr) { + if ($nullableExpr instanceof Expr) { return $this->valueResolver->isTrue($nullableExpr); } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); return $this->isNullableColumn($phpDocInfo); } - private function isNullableColumn(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : bool + private function isNullableColumn(PhpDocInfo $phpDocInfo) : bool { $doctrineAnnotationTagValueNode = $phpDocInfo->findOneByAnnotationClass(self::COLUMN_CLASS); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return \true; } $nullableValue = $doctrineAnnotationTagValueNode->getValue('nullable'); - return $nullableValue === null || $nullableValue instanceof \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprTrueNode; + return $nullableValue === null || $nullableValue instanceof ConstExprTrueNode; } } diff --git a/vendor/rector/rector-doctrine/src/NodeManipulator/PropertyTypeManipulator.php b/vendor/rector/rector-doctrine/src/NodeManipulator/PropertyTypeManipulator.php index 5ee384b74e5..bad89c8e740 100644 --- a/vendor/rector/rector-doctrine/src/NodeManipulator/PropertyTypeManipulator.php +++ b/vendor/rector/rector-doctrine/src/NodeManipulator/PropertyTypeManipulator.php @@ -22,23 +22,23 @@ final class PropertyTypeManipulator * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory */ private $phpDocInfoFactory; - public function __construct(\Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockClassRenamer $docBlockClassRenamer, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory) + public function __construct(DocBlockClassRenamer $docBlockClassRenamer, PhpDocInfoFactory $phpDocInfoFactory) { $this->docBlockClassRenamer = $docBlockClassRenamer; $this->phpDocInfoFactory = $phpDocInfoFactory; } - public function changePropertyType(\PhpParser\Node\Stmt\Property $property, string $oldClass, string $newClass) : void + public function changePropertyType(Property $property, string $oldClass, string $newClass) : void { if ($property->type !== null) { // fix later - throw new \Rector\Core\Exception\NotImplementedYetException(); + throw new NotImplementedYetException(); } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); - $oldToNewTypes = [new \Rector\NodeTypeResolver\ValueObject\OldToNewType(new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($oldClass), new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($newClass))]; + $oldToNewTypes = [new OldToNewType(new FullyQualifiedObjectType($oldClass), new FullyQualifiedObjectType($newClass))]; $this->docBlockClassRenamer->renamePhpDocType($phpDocInfo, $oldToNewTypes); if ($phpDocInfo->hasChanged()) { // invoke phpdoc reprint - $property->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $property->setAttribute(AttributeKey::ORIGINAL_NODE, null); } } } diff --git a/vendor/rector/rector-doctrine/src/NodeManipulator/ToManyRelationPropertyTypeResolver.php b/vendor/rector/rector-doctrine/src/NodeManipulator/ToManyRelationPropertyTypeResolver.php index c0da53ce70d..169213c1ff1 100644 --- a/vendor/rector/rector-doctrine/src/NodeManipulator/ToManyRelationPropertyTypeResolver.php +++ b/vendor/rector/rector-doctrine/src/NodeManipulator/ToManyRelationPropertyTypeResolver.php @@ -43,14 +43,14 @@ final class ToManyRelationPropertyTypeResolver * @var \Rector\Core\PhpParser\Node\Value\ValueResolver */ private $valueResolver; - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Doctrine\PhpDoc\ShortClassExpander $shortClassExpander, \Rector\Doctrine\NodeAnalyzer\AttributeFinder $attributeFinder, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory, ShortClassExpander $shortClassExpander, AttributeFinder $attributeFinder, ValueResolver $valueResolver) { $this->phpDocInfoFactory = $phpDocInfoFactory; $this->shortClassExpander = $shortClassExpander; $this->attributeFinder = $attributeFinder; $this->valueResolver = $valueResolver; } - public function resolve(\PhpParser\Node\Stmt\Property $property) : ?\PHPStan\Type\Type + public function resolve(Property $property) : ?Type { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); $doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClasses(self::TO_MANY_ANNOTATION_CLASSES); @@ -58,7 +58,7 @@ final class ToManyRelationPropertyTypeResolver return $this->processToManyRelation($property, $doctrineAnnotationTagValueNode); } $targetEntity = $this->attributeFinder->findAttributeByClassesArgByName($property, self::TO_MANY_ANNOTATION_CLASSES, 'targetEntity'); - if (!$targetEntity instanceof \PhpParser\Node\Expr) { + if (!$targetEntity instanceof Expr) { return null; } return $this->resolveTypeFromTargetEntity($targetEntity, $property); @@ -66,7 +66,7 @@ final class ToManyRelationPropertyTypeResolver /** * @return \PHPStan\Type\Type|null */ - private function processToManyRelation(\PhpParser\Node\Stmt\Property $property, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) + private function processToManyRelation(Property $property, DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) { $targetEntity = $doctrineAnnotationTagValueNode->getValueWithoutQuotes('targetEntity'); if (!\is_string($targetEntity)) { @@ -77,16 +77,16 @@ final class ToManyRelationPropertyTypeResolver /** * @param \PhpParser\Node\Expr|string $targetEntity */ - private function resolveTypeFromTargetEntity($targetEntity, \PhpParser\Node\Stmt\Property $property) : \PHPStan\Type\Type + private function resolveTypeFromTargetEntity($targetEntity, Property $property) : Type { - if ($targetEntity instanceof \PhpParser\Node\Expr) { + if ($targetEntity instanceof Expr) { $targetEntity = $this->valueResolver->getValue($targetEntity); } if (!\is_string($targetEntity)) { - return new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType(self::COLLECTION_TYPE); + return new FullyQualifiedObjectType(self::COLLECTION_TYPE); } $entityFullyQualifiedClass = $this->shortClassExpander->resolveFqnTargetEntity($targetEntity, $property); - $fullyQualifiedObjectType = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($entityFullyQualifiedClass); - return new \PHPStan\Type\Generic\GenericObjectType(self::COLLECTION_TYPE, [$fullyQualifiedObjectType]); + $fullyQualifiedObjectType = new FullyQualifiedObjectType($entityFullyQualifiedClass); + return new GenericObjectType(self::COLLECTION_TYPE, [$fullyQualifiedObjectType]); } } diff --git a/vendor/rector/rector-doctrine/src/NodeManipulator/ToOneRelationPropertyTypeResolver.php b/vendor/rector/rector-doctrine/src/NodeManipulator/ToOneRelationPropertyTypeResolver.php index 05ad9c28b94..cb928276a1b 100644 --- a/vendor/rector/rector-doctrine/src/NodeManipulator/ToOneRelationPropertyTypeResolver.php +++ b/vendor/rector/rector-doctrine/src/NodeManipulator/ToOneRelationPropertyTypeResolver.php @@ -50,7 +50,7 @@ final class ToOneRelationPropertyTypeResolver * @var \Rector\Doctrine\NodeAnalyzer\TargetEntityResolver */ private $targetEntityResolver; - public function __construct(\Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher $classAnnotationMatcher, \Rector\Doctrine\NodeAnalyzer\AttributeFinder $attributeFinder, \Rector\Doctrine\NodeAnalyzer\TargetEntityResolver $targetEntityResolver) + public function __construct(TypeFactory $typeFactory, PhpDocInfoFactory $phpDocInfoFactory, ClassAnnotationMatcher $classAnnotationMatcher, AttributeFinder $attributeFinder, TargetEntityResolver $targetEntityResolver) { $this->typeFactory = $typeFactory; $this->phpDocInfoFactory = $phpDocInfoFactory; @@ -58,67 +58,67 @@ final class ToOneRelationPropertyTypeResolver $this->attributeFinder = $attributeFinder; $this->targetEntityResolver = $targetEntityResolver; } - public function resolve(\PhpParser\Node\Stmt\Property $property) : ?\PHPStan\Type\Type + public function resolve(Property $property) : ?Type { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); $doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClasses(self::TO_ONE_ANNOTATION_CLASSES); - if ($doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if ($doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return $this->resolveFromDocBlock($phpDocInfo, $property, $doctrineAnnotationTagValueNode); } $targetEntity = $this->attributeFinder->findAttributeByClassesArgByName($property, self::TO_ONE_ANNOTATION_CLASSES, 'targetEntity'); - if (!$targetEntity instanceof \PhpParser\Node\Expr) { + if (!$targetEntity instanceof Expr) { return null; } $targetEntityClass = $this->targetEntityResolver->resolveFromExpr($targetEntity); if ($targetEntityClass !== null) { - $fullyQualifiedObjectType = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($targetEntityClass); + $fullyQualifiedObjectType = new FullyQualifiedObjectType($targetEntityClass); // @todo resolve nullable value return $this->resolveFromObjectType($fullyQualifiedObjectType, \false); } return null; } - private function processToOneRelation(\PhpParser\Node\Stmt\Property $property, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $toOneDoctrineAnnotationTagValueNode, ?\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $joinDoctrineAnnotationTagValueNode) : \PHPStan\Type\Type + private function processToOneRelation(Property $property, DoctrineAnnotationTagValueNode $toOneDoctrineAnnotationTagValueNode, ?DoctrineAnnotationTagValueNode $joinDoctrineAnnotationTagValueNode) : Type { $targetEntity = $toOneDoctrineAnnotationTagValueNode->getValueWithoutQuotes('targetEntity'); if (!\is_string($targetEntity)) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } if (\substr_compare($targetEntity, '::class', -\strlen('::class')) === 0) { - $targetEntity = \RectorPrefix20220607\Nette\Utils\Strings::before($targetEntity, '::class'); + $targetEntity = Strings::before($targetEntity, '::class'); } // resolve to FQN $tagFullyQualifiedName = $this->classAnnotationMatcher->resolveTagFullyQualifiedName($targetEntity, $property); - $fullyQualifiedObjectType = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($tagFullyQualifiedName); + $fullyQualifiedObjectType = new FullyQualifiedObjectType($tagFullyQualifiedName); $isNullable = $this->isNullableType($joinDoctrineAnnotationTagValueNode); return $this->resolveFromObjectType($fullyQualifiedObjectType, $isNullable); } - private function shouldAddNullType(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : bool + private function shouldAddNullType(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : bool { $isNullableValue = $doctrineAnnotationTagValueNode->getValue('nullable'); - return $isNullableValue instanceof \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprTrueNode; + return $isNullableValue instanceof ConstExprTrueNode; } - private function resolveFromDocBlock(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\Stmt\Property $property, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : \PHPStan\Type\Type + private function resolveFromDocBlock(PhpDocInfo $phpDocInfo, Property $property, DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : Type { $joinDoctrineAnnotationTagValueNode = $phpDocInfo->findOneByAnnotationClass('Doctrine\\ORM\\Mapping\\JoinColumn'); return $this->processToOneRelation($property, $doctrineAnnotationTagValueNode, $joinDoctrineAnnotationTagValueNode); } - private function resolveFromObjectType(\Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType, bool $isNullable) : \PHPStan\Type\Type + private function resolveFromObjectType(FullyQualifiedObjectType $fullyQualifiedObjectType, bool $isNullable) : Type { $types = []; $types[] = $fullyQualifiedObjectType; if ($isNullable) { - $types[] = new \PHPStan\Type\NullType(); + $types[] = new NullType(); } $propertyType = $this->typeFactory->createMixedPassedOrUnionType($types); // add default null if missing - if (!\PHPStan\Type\TypeCombinator::containsNull($propertyType)) { - $propertyType = \PHPStan\Type\TypeCombinator::addNull($propertyType); + if (!TypeCombinator::containsNull($propertyType)) { + $propertyType = TypeCombinator::addNull($propertyType); } return $propertyType; } - private function isNullableType(?\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $joinDoctrineAnnotationTagValueNode) : bool + private function isNullableType(?DoctrineAnnotationTagValueNode $joinDoctrineAnnotationTagValueNode) : bool { - if (!$joinDoctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$joinDoctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return \false; } return $this->shouldAddNullType($joinDoctrineAnnotationTagValueNode); diff --git a/vendor/rector/rector-doctrine/src/PhpDoc/ShortClassExpander.php b/vendor/rector/rector-doctrine/src/PhpDoc/ShortClassExpander.php index 18da8d39992..94429c06aff 100644 --- a/vendor/rector/rector-doctrine/src/PhpDoc/ShortClassExpander.php +++ b/vendor/rector/rector-doctrine/src/PhpDoc/ShortClassExpander.php @@ -28,7 +28,7 @@ final class ShortClassExpander * @var \Rector\TypeDeclaration\PHPStan\ObjectTypeSpecifier */ private $objectTypeSpecifier; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\TypeDeclaration\PHPStan\ObjectTypeSpecifier $objectTypeSpecifier) + public function __construct(ReflectionProvider $reflectionProvider, ObjectTypeSpecifier $objectTypeSpecifier) { $this->reflectionProvider = $reflectionProvider; $this->objectTypeSpecifier = $objectTypeSpecifier; @@ -36,22 +36,22 @@ final class ShortClassExpander /** * @api */ - public function resolveFqnTargetEntity(string $targetEntity, \PhpParser\Node $node) : string + public function resolveFqnTargetEntity(string $targetEntity, Node $node) : string { $targetEntity = $this->getCleanedUpTargetEntity($targetEntity); if ($this->reflectionProvider->hasClass($targetEntity)) { return $targetEntity; } - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { + $scope = $node->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { return $targetEntity; } $namespacedTargetEntity = $scope->getNamespace() . '\\' . $targetEntity; if ($this->reflectionProvider->hasClass($namespacedTargetEntity)) { return $namespacedTargetEntity; } - $resolvedType = $this->objectTypeSpecifier->narrowToFullyQualifiedOrAliasedObjectType($node, new \PHPStan\Type\ObjectType($targetEntity), $scope); - if ($resolvedType instanceof \Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType) { + $resolvedType = $this->objectTypeSpecifier->narrowToFullyQualifiedOrAliasedObjectType($node, new ObjectType($targetEntity), $scope); + if ($resolvedType instanceof ShortenedObjectType) { return $resolvedType->getFullyQualifiedName(); } // probably tested class @@ -59,6 +59,6 @@ final class ShortClassExpander } private function getCleanedUpTargetEntity(string $targetEntity) : string { - return \RectorPrefix20220607\Nette\Utils\Strings::replace($targetEntity, self::CLASS_CONST_REGEX, ''); + return Strings::replace($targetEntity, self::CLASS_CONST_REGEX, ''); } } diff --git a/vendor/rector/rector-doctrine/src/PhpDocParser/DoctrineDocBlockResolver.php b/vendor/rector/rector-doctrine/src/PhpDocParser/DoctrineDocBlockResolver.php index 267839a4bdb..d024ac7d7fc 100644 --- a/vendor/rector/rector-doctrine/src/PhpDocParser/DoctrineDocBlockResolver.php +++ b/vendor/rector/rector-doctrine/src/PhpDocParser/DoctrineDocBlockResolver.php @@ -27,22 +27,22 @@ final class DoctrineDocBlockResolver * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Doctrine\PhpDoc\ShortClassExpander $shortClassExpander, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory, ShortClassExpander $shortClassExpander, BetterNodeFinder $betterNodeFinder) { $this->phpDocInfoFactory = $phpDocInfoFactory; $this->shortClassExpander = $shortClassExpander; $this->betterNodeFinder = $betterNodeFinder; } - public function isDoctrineEntityClass(\PhpParser\Node\Stmt\Class_ $class) : bool + public function isDoctrineEntityClass(Class_ $class) : bool { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($class); return $phpDocInfo->hasByAnnotationClasses(['Doctrine\\ORM\\Mapping\\Entity', 'Doctrine\\ORM\\Mapping\\Embeddable']); } - public function getTargetEntity(\PhpParser\Node\Stmt\Property $property) : ?string + public function getTargetEntity(Property $property) : ?string { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); $doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClasses(['Doctrine\\ORM\\Mapping\\OneToMany', 'Doctrine\\ORM\\Mapping\\ManyToMany', 'Doctrine\\ORM\\Mapping\\OneToOne', 'Doctrine\\ORM\\Mapping\\ManyToOne']); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return null; } $targetEntity = $doctrineAnnotationTagValueNode->getValue('targetEntity'); @@ -51,10 +51,10 @@ final class DoctrineDocBlockResolver } return $this->shortClassExpander->resolveFqnTargetEntity($targetEntity, $property); } - public function isInDoctrineEntityClass(\PhpParser\Node $node) : bool + public function isInDoctrineEntityClass(Node $node) : bool { - $class = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$class instanceof Class_) { return \false; } return $this->isDoctrineEntityClass($class); diff --git a/vendor/rector/rector-doctrine/src/Rector/ClassMethod/MakeEntitySetterNullabilityInSyncWithPropertyRector.php b/vendor/rector/rector-doctrine/src/Rector/ClassMethod/MakeEntitySetterNullabilityInSyncWithPropertyRector.php index b4f7611f954..b8a388d90ae 100644 --- a/vendor/rector/rector-doctrine/src/Rector/ClassMethod/MakeEntitySetterNullabilityInSyncWithPropertyRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/ClassMethod/MakeEntitySetterNullabilityInSyncWithPropertyRector.php @@ -10,14 +10,14 @@ use PhpParser\Node\Stmt\Property; use Rector\Core\Rector\AbstractRector; use Rector\Doctrine\NodeAnalyzer\SetterClassMethodAnalyzer; use Rector\Doctrine\PhpDocParser\DoctrineDocBlockResolver; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see related to maker bundle https://symfony.com/doc/current/bundles/SymfonyMakerBundle/index.html * * @see \Rector\Doctrine\Tests\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector\MakeEntitySetterNullabilityInSyncWithPropertyRectorTest */ -final class MakeEntitySetterNullabilityInSyncWithPropertyRector extends \Rector\Core\Rector\AbstractRector +final class MakeEntitySetterNullabilityInSyncWithPropertyRector extends AbstractRector { /** * @readonly @@ -29,14 +29,14 @@ final class MakeEntitySetterNullabilityInSyncWithPropertyRector extends \Rector\ * @var \Rector\Doctrine\PhpDocParser\DoctrineDocBlockResolver */ private $doctrineDocBlockResolver; - public function __construct(\Rector\Doctrine\NodeAnalyzer\SetterClassMethodAnalyzer $setterClassMethodAnalyzer, \Rector\Doctrine\PhpDocParser\DoctrineDocBlockResolver $doctrineDocBlockResolver) + public function __construct(SetterClassMethodAnalyzer $setterClassMethodAnalyzer, DoctrineDocBlockResolver $doctrineDocBlockResolver) { $this->setterClassMethodAnalyzer = $setterClassMethodAnalyzer; $this->doctrineDocBlockResolver = $doctrineDocBlockResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Make nullability in setter class method with respect to property', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Make nullability in setter class method with respect to property', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\ORM\Mapping as ORM; /** @@ -81,19 +81,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { // is setter in doctrine? if (!$this->doctrineDocBlockResolver->isInDoctrineEntityClass($node)) { return null; } $property = $this->setterClassMethodAnalyzer->matchNullalbeClassMethodProperty($node); - if (!$property instanceof \PhpParser\Node\Stmt\Property) { + if (!$property instanceof Property) { return null; } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); diff --git a/vendor/rector/rector-doctrine/src/Rector/ClassMethod/ServiceEntityRepositoryParentCallToDIRector.php b/vendor/rector/rector-doctrine/src/Rector/ClassMethod/ServiceEntityRepositoryParentCallToDIRector.php index 5557e666f4a..dcfdae3a1be 100644 --- a/vendor/rector/rector-doctrine/src/Rector/ClassMethod/ServiceEntityRepositoryParentCallToDIRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/ClassMethod/ServiceEntityRepositoryParentCallToDIRector.php @@ -19,15 +19,15 @@ use Rector\Doctrine\Type\RepositoryTypeFactory; use Rector\Naming\Naming\PropertyNaming; use Rector\PostRector\Collector\PropertyToAddCollector; use Rector\PostRector\ValueObject\PropertyMetadata; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://tomasvotruba.com/blog/2017/10/16/how-to-use-repository-with-doctrine-as-service-in-symfony/ * @see https://getrector.org/blog/2021/02/08/how-to-instantly-decouple-symfony-doctrine-repository-inheritance-to-clean-composition * * @see \Rector\Doctrine\Tests\Rector\ClassMethod\ServiceEntityRepositoryParentCallToDIRector\ServiceEntityRepositoryParentCallToDIRectorTest */ -final class ServiceEntityRepositoryParentCallToDIRector extends \Rector\Core\Rector\AbstractRector +final class ServiceEntityRepositoryParentCallToDIRector extends AbstractRector { /** * @readonly @@ -59,7 +59,7 @@ final class ServiceEntityRepositoryParentCallToDIRector extends \Rector\Core\Rec * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Doctrine\NodeFactory\RepositoryNodeFactory $repositoryNodeFactory, \Rector\Doctrine\Type\RepositoryTypeFactory $repositoryTypeFactory, \Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector, \Rector\Core\NodeManipulator\ClassDependencyManipulator $classDependencyManipulator, \Rector\Naming\Naming\PropertyNaming $propertyNaming, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(RepositoryNodeFactory $repositoryNodeFactory, RepositoryTypeFactory $repositoryTypeFactory, PropertyToAddCollector $propertyToAddCollector, ClassDependencyManipulator $classDependencyManipulator, PropertyNaming $propertyNaming, ReflectionResolver $reflectionResolver) { $this->repositoryNodeFactory = $repositoryNodeFactory; $this->repositoryTypeFactory = $repositoryTypeFactory; @@ -68,9 +68,9 @@ final class ServiceEntityRepositoryParentCallToDIRector extends \Rector\Core\Rec $this->propertyNaming = $propertyNaming; $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change ServiceEntityRepository to dependency injection, with repository property', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change ServiceEntityRepository to dependency injection, with repository property', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; @@ -112,7 +112,7 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node @@ -121,50 +121,50 @@ CODE_SAMPLE * - Doctrine\Common\Persistence\ManagerRegistry * - Doctrine\Persistence\ManagerRegistry */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkipClassMethod($node)) { return null; } - $class = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$class instanceof Class_) { return null; } // 1. remove parent::__construct() $entityReferenceExpr = $this->removeParentConstructAndCollectEntityReference($node); - if (!$entityReferenceExpr instanceof \PhpParser\Node\Expr) { + if (!$entityReferenceExpr instanceof Expr) { return null; } // 2. remove params $node->params = []; // 3. add $entityManager->getRepository() fetch assign $repositoryAssign = $this->repositoryNodeFactory->createRepositoryAssign($entityReferenceExpr); - $entityManagerObjectType = new \PHPStan\Type\ObjectType('Doctrine\\ORM\\EntityManagerInterface'); + $entityManagerObjectType = new ObjectType('Doctrine\\ORM\\EntityManagerInterface'); $this->classDependencyManipulator->addConstructorDependencyWithCustomAssign($class, 'entityManager', $entityManagerObjectType, $repositoryAssign); $this->addRepositoryProperty($class, $entityReferenceExpr); // 5. add param + add property, dependency $propertyName = $this->propertyNaming->fqnToVariableName($entityManagerObjectType); - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($propertyName, $entityManagerObjectType, \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $propertyMetadata = new PropertyMetadata($propertyName, $entityManagerObjectType, Class_::MODIFIER_PRIVATE); $this->propertyToAddCollector->addPropertyToClass($class, $propertyMetadata); return $node; } - private function shouldSkipClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkipClassMethod(ClassMethod $classMethod) : bool { - if (!$this->isName($classMethod, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if (!$this->isName($classMethod, MethodName::CONSTRUCT)) { return \true; } $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { // fresh node or possibly trait/interface return \true; } return !$classReflection->isSubclassOf('Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository'); } - private function removeParentConstructAndCollectEntityReference(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Expr + private function removeParentConstructAndCollectEntityReference(ClassMethod $classMethod) : ?Expr { $entityReferenceExpr = null; - $this->traverseNodesWithCallable((array) $classMethod->stmts, function (\PhpParser\Node $node) use(&$entityReferenceExpr) { - if (!$node instanceof \PhpParser\Node\Expr\StaticCall) { + $this->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) use(&$entityReferenceExpr) { + if (!$node instanceof StaticCall) { return null; } if (!$this->isName($node->class, 'parent')) { @@ -175,7 +175,7 @@ CODE_SAMPLE }); return $entityReferenceExpr; } - private function addRepositoryProperty(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Expr $entityReferenceExpr) : void + private function addRepositoryProperty(Class_ $class, Expr $entityReferenceExpr) : void { $genericObjectType = $this->repositoryTypeFactory->createRepositoryPropertyType($entityReferenceExpr); $this->propertyToAddCollector->addPropertyWithoutConstructorToClass('repository', $genericObjectType, $class); diff --git a/vendor/rector/rector-doctrine/src/Rector/Class_/AddEntityIdByConditionRector.php b/vendor/rector/rector-doctrine/src/Rector/Class_/AddEntityIdByConditionRector.php index a4ec6503eac..0f682d35020 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Class_/AddEntityIdByConditionRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Class_/AddEntityIdByConditionRector.php @@ -11,13 +11,13 @@ use Rector\Core\NodeAnalyzer\ClassAnalyzer; use Rector\Core\NodeManipulator\ClassInsertManipulator; use Rector\Core\Rector\AbstractRector; use Rector\Doctrine\NodeFactory\EntityIdNodeFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Doctrine\Tests\Rector\Class_\AddEntityIdByConditionRector\AddEntityIdByConditionRectorTest */ -final class AddEntityIdByConditionRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class AddEntityIdByConditionRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var string @@ -47,16 +47,16 @@ final class AddEntityIdByConditionRector extends \Rector\Core\Rector\AbstractRec * @var \Rector\Core\NodeAnalyzer\ClassAnalyzer */ private $classAnalyzer; - public function __construct(\Rector\Doctrine\NodeFactory\EntityIdNodeFactory $entityIdNodeFactory, \Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer) + public function __construct(EntityIdNodeFactory $entityIdNodeFactory, ClassInsertManipulator $classInsertManipulator, ReflectionProvider $reflectionProvider, ClassAnalyzer $classAnalyzer) { $this->entityIdNodeFactory = $entityIdNodeFactory; $this->classInsertManipulator = $classInsertManipulator; $this->reflectionProvider = $reflectionProvider; $this->classAnalyzer = $classAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add entity id with annotations when meets condition', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add entity id with annotations when meets condition', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { use SomeTrait; @@ -89,12 +89,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -109,11 +109,11 @@ CODE_SAMPLE public function configure(array $configuration) : void { $detectTraits = $configuration[self::DETECTED_TRAITS] ?? $configuration; - \RectorPrefix20220607\Webmozart\Assert\Assert::isArray($detectTraits); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($detectTraits); + Assert::isArray($detectTraits); + Assert::allString($detectTraits); $this->detectedTraits = $detectTraits; } - private function shouldSkip(\PhpParser\Node\Stmt\Class_ $class) : bool + private function shouldSkip(Class_ $class) : bool { if ($this->classAnalyzer->isAnonymousClass($class)) { return \true; @@ -123,7 +123,7 @@ CODE_SAMPLE } return (bool) $class->getProperty('id'); } - private function isTraitMatch(\PhpParser\Node\Stmt\Class_ $class) : bool + private function isTraitMatch(Class_ $class) : bool { $className = $this->getName($class); if ($className === null) { diff --git a/vendor/rector/rector-doctrine/src/Rector/Class_/BlameableBehaviorRector.php b/vendor/rector/rector-doctrine/src/Rector/Class_/BlameableBehaviorRector.php index e5a23380487..7446e33c237 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Class_/BlameableBehaviorRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Class_/BlameableBehaviorRector.php @@ -8,28 +8,28 @@ use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\Stmt\Class_; use Rector\Core\NodeManipulator\ClassInsertManipulator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/Atlantic18/DoctrineExtensions/blob/v2.4.x/doc/blameable.md * @see https://github.com/KnpLabs/DoctrineBehaviors/blob/2cf2585710a9f23d0c8362a7b52f45bf89dc0d3a/docs/blameable.md * * @see \Rector\Doctrine\Tests\Rector\Class_\BlameableBehaviorRector\BlameableBehaviorRectorTest */ -final class BlameableBehaviorRector extends \Rector\Core\Rector\AbstractRector +final class BlameableBehaviorRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeManipulator\ClassInsertManipulator */ private $classInsertManipulator; - public function __construct(\Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator) + public function __construct(ClassInsertManipulator $classInsertManipulator) { $this->classInsertManipulator = $classInsertManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change Blameable from gedmo/doctrine-extensions to knplabs/doctrine-behaviors', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change Blameable from gedmo/doctrine-extensions to knplabs/doctrine-behaviors', [new CodeSample(<<<'CODE_SAMPLE' use Gedmo\Mapping\Annotation as Gedmo; use Doctrine\ORM\Mapping as ORM; @@ -89,22 +89,22 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isGedmoBlameableClass($node)) { return null; } $this->removeBlameablePropertiesAndMethods($node); $this->classInsertManipulator->addAsFirstTrait($node, 'Knp\\DoctrineBehaviors\\Model\\Blameable\\BlameableTrait'); - $node->implements[] = new \PhpParser\Node\Name\FullyQualified('Knp\\DoctrineBehaviors\\Contract\\Entity\\BlameableInterface'); + $node->implements[] = new FullyQualified('Knp\\DoctrineBehaviors\\Contract\\Entity\\BlameableInterface'); return $node; } - private function isGedmoBlameableClass(\PhpParser\Node\Stmt\Class_ $class) : bool + private function isGedmoBlameableClass(Class_ $class) : bool { foreach ($class->getProperties() as $property) { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); @@ -114,7 +114,7 @@ CODE_SAMPLE } return \false; } - private function removeBlameablePropertiesAndMethods(\PhpParser\Node\Stmt\Class_ $class) : void + private function removeBlameablePropertiesAndMethods(Class_ $class) : void { $removedPropertyNames = []; foreach ($class->getProperties() as $property) { @@ -132,7 +132,7 @@ CODE_SAMPLE /** * @param string[] $removedPropertyNames */ - private function removeSetterAndGetterByPropertyNames(\PhpParser\Node\Stmt\Class_ $class, array $removedPropertyNames) : void + private function removeSetterAndGetterByPropertyNames(Class_ $class, array $removedPropertyNames) : void { foreach ($class->getMethods() as $classMethod) { foreach ($removedPropertyNames as $removedPropertyName) { diff --git a/vendor/rector/rector-doctrine/src/Rector/Class_/ClassAnnotationToNamedArgumentConstructorRector.php b/vendor/rector/rector-doctrine/src/Rector/Class_/ClassAnnotationToNamedArgumentConstructorRector.php index 2f3448033b3..66f9f2a7595 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Class_/ClassAnnotationToNamedArgumentConstructorRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Class_/ClassAnnotationToNamedArgumentConstructorRector.php @@ -21,14 +21,14 @@ use Rector\Doctrine\NodeFactory\ConstructorClassMethodAssignFactory; use Rector\Doctrine\NodeFactory\ParamFactory; use Rector\Doctrine\NodeManipulator\IssetDimFetchCleaner; use Rector\Doctrine\ValueObject\AssignToPropertyFetch; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/doctrine/annotations/blob/1.13.x/docs/en/custom.rst#optional-constructors-with-named-parameters * * @see \Rector\Doctrine\Tests\Rector\Class_\ClassAnnotationToNamedArgumentConstructorRector\ClassAnnotationToNamedArgumentConstructorRectorTest */ -final class ClassAnnotationToNamedArgumentConstructorRector extends \Rector\Core\Rector\AbstractRector +final class ClassAnnotationToNamedArgumentConstructorRector extends AbstractRector { /** * @readonly @@ -60,7 +60,7 @@ final class ClassAnnotationToNamedArgumentConstructorRector extends \Rector\Core * @var \Rector\Doctrine\NodeFactory\ConstructorClassMethodAssignFactory */ private $constructorClassMethodAssignFactory; - public function __construct(\Rector\Doctrine\NodeFactory\ParamFactory $paramFactory, \Rector\Doctrine\NodeFactory\ConstructClassMethodFactory $constructClassMethodFactory, \Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator, \Rector\Doctrine\NodeAnalyzer\AssignPropertyFetchAnalyzer $assignPropertyFetchAnalyzer, \Rector\Doctrine\NodeManipulator\IssetDimFetchCleaner $issetDimFetchCleaner, \Rector\Doctrine\NodeFactory\ConstructorClassMethodAssignFactory $constructorClassMethodAssignFactory) + public function __construct(ParamFactory $paramFactory, ConstructClassMethodFactory $constructClassMethodFactory, ClassInsertManipulator $classInsertManipulator, AssignPropertyFetchAnalyzer $assignPropertyFetchAnalyzer, IssetDimFetchCleaner $issetDimFetchCleaner, ConstructorClassMethodAssignFactory $constructorClassMethodAssignFactory) { $this->paramFactory = $paramFactory; $this->constructClassMethodFactory = $constructClassMethodFactory; @@ -69,9 +69,9 @@ final class ClassAnnotationToNamedArgumentConstructorRector extends \Rector\Core $this->issetDimFetchCleaner = $issetDimFetchCleaner; $this->constructorClassMethodAssignFactory = $constructorClassMethodAssignFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Decorate classic array-based class annotation with named parameters', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Decorate classic array-based class annotation with named parameters', [new CodeSample(<<<'CODE_SAMPLE' /** * @Annotation */ @@ -115,24 +115,24 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); - if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$phpDocInfo instanceof PhpDocInfo) { return null; } if ($this->shouldSkipPhpDocInfo($phpDocInfo)) { return null; } - $doctrineAnnotationTagValueNode = new \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode(new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('Doctrine\\Common\\Annotations\\Annotation\\NamedArgumentConstructor')); + $doctrineAnnotationTagValueNode = new DoctrineAnnotationTagValueNode(new IdentifierTypeNode('Doctrine\\Common\\Annotations\\Annotation\\NamedArgumentConstructor')); $phpDocInfo->addTagValueNode($doctrineAnnotationTagValueNode); - $classMethod = $node->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $node->getMethod(MethodName::CONSTRUCT); + if (!$classMethod instanceof ClassMethod) { return $this->decorateClassWithAssignClassMethod($node); } if (!$this->hasSingleArrayParam($classMethod)) { @@ -153,26 +153,26 @@ CODE_SAMPLE } return $node; } - private function shouldSkipPhpDocInfo(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : bool + private function shouldSkipPhpDocInfo(PhpDocInfo $phpDocInfo) : bool { if (!$phpDocInfo->hasByNames(['annotation', 'Annotation'])) { return \true; } return $phpDocInfo->hasByAnnotationClass('Doctrine\\Common\\Annotations\\Annotation\\NamedArgumentConstructor'); } - private function hasSingleArrayParam(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function hasSingleArrayParam(ClassMethod $classMethod) : bool { if (\count($classMethod->params) !== 1) { return \false; } $onlyParam = $classMethod->params[0]; // change array to properites - if (!$onlyParam->type instanceof \PhpParser\Node) { + if (!$onlyParam->type instanceof Node) { return \false; } $paramType = $this->nodeTypeResolver->getType($onlyParam); // we have a match - return $paramType instanceof \PHPStan\Type\ArrayType; + return $paramType instanceof ArrayType; } /** * @param AssignToPropertyFetch[] $assignsToPropertyFetch @@ -181,17 +181,17 @@ CODE_SAMPLE { foreach ($assignsToPropertyFetch as $assignToPropertyFetch) { $assign = $assignToPropertyFetch->getAssign(); - $assign->expr = new \PhpParser\Node\Expr\Variable($assignToPropertyFetch->getPropertyName()); + $assign->expr = new Variable($assignToPropertyFetch->getPropertyName()); } } /** * @return \PhpParser\Node\Stmt\Class_|null */ - private function decorateClassWithAssignClassMethod(\PhpParser\Node\Stmt\Class_ $class) + private function decorateClassWithAssignClassMethod(Class_ $class) { // complete public properties $constructClassMethod = $this->constructClassMethodFactory->createFromPublicClassProperties($class); - if (!$constructClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$constructClassMethod instanceof ClassMethod) { return null; } $this->classInsertManipulator->addAsFirstMethod($class, $constructClassMethod); diff --git a/vendor/rector/rector-doctrine/src/Rector/Class_/InitializeDefaultEntityCollectionRector.php b/vendor/rector/rector-doctrine/src/Rector/Class_/InitializeDefaultEntityCollectionRector.php index fbf852951a5..9ada9512169 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Class_/InitializeDefaultEntityCollectionRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Class_/InitializeDefaultEntityCollectionRector.php @@ -11,14 +11,14 @@ use Rector\Core\Rector\AbstractRector; use Rector\Doctrine\NodeAnalyzer\AttrinationFinder; use Rector\Doctrine\NodeFactory\ArrayCollectionAssignFactory; use Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/best-practices.html#initialize-collections-in-the-constructor * * @see \Rector\Doctrine\Tests\Rector\Class_\InitializeDefaultEntityCollectionRector\InitializeDefaultEntityCollectionRectorTest */ -final class InitializeDefaultEntityCollectionRector extends \Rector\Core\Rector\AbstractRector +final class InitializeDefaultEntityCollectionRector extends AbstractRector { /** * @var class-string[] @@ -44,16 +44,16 @@ final class InitializeDefaultEntityCollectionRector extends \Rector\Core\Rector\ * @var \Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector */ private $constructorAssignDetector; - public function __construct(\Rector\Core\NodeManipulator\ClassDependencyManipulator $classDependencyManipulator, \Rector\Doctrine\NodeFactory\ArrayCollectionAssignFactory $arrayCollectionAssignFactory, \Rector\Doctrine\NodeAnalyzer\AttrinationFinder $attrinationFinder, \Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector $constructorAssignDetector) + public function __construct(ClassDependencyManipulator $classDependencyManipulator, ArrayCollectionAssignFactory $arrayCollectionAssignFactory, AttrinationFinder $attrinationFinder, ConstructorAssignDetector $constructorAssignDetector) { $this->classDependencyManipulator = $classDependencyManipulator; $this->arrayCollectionAssignFactory = $arrayCollectionAssignFactory; $this->attrinationFinder = $attrinationFinder; $this->constructorAssignDetector = $constructorAssignDetector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Initialize collection property in Entity constructor', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Initialize collection property in Entity constructor', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\ORM\Mapping as ORM; /** @@ -93,12 +93,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->attrinationFinder->hasByOne($node, 'Doctrine\\ORM\\Mapping\\Entity')) { return null; @@ -108,7 +108,7 @@ CODE_SAMPLE /** * @return string[] */ - private function resolveToManyPropertyNames(\PhpParser\Node\Stmt\Class_ $class) : array + private function resolveToManyPropertyNames(Class_ $class) : array { $collectionPropertyNames = []; foreach ($class->getProperties() as $property) { @@ -142,7 +142,7 @@ CODE_SAMPLE /** * @return \PhpParser\Node\Stmt\Class_|null */ - private function refactorClass(\PhpParser\Node\Stmt\Class_ $class) + private function refactorClass(Class_ $class) { $toManyPropertyNames = $this->resolveToManyPropertyNames($class); if ($toManyPropertyNames === []) { diff --git a/vendor/rector/rector-doctrine/src/Rector/Class_/LoggableBehaviorRector.php b/vendor/rector/rector-doctrine/src/Rector/Class_/LoggableBehaviorRector.php index 29582ab11c7..48c762f5bac 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Class_/LoggableBehaviorRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Class_/LoggableBehaviorRector.php @@ -12,28 +12,28 @@ use Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode; use Rector\Core\NodeManipulator\ClassInsertManipulator; use Rector\Core\Rector\AbstractRector; use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/Atlantic18/DoctrineExtensions/blob/v2.4.x/doc/loggable.md * @see https://github.com/KnpLabs/DoctrineBehaviors/blob/4e0677379dd4adf84178f662d08454a9627781a8/docs/loggable.md * * @see \Rector\Doctrine\Tests\Rector\Class_\LoggableBehaviorRector\LoggableBehaviorRectorTest */ -final class LoggableBehaviorRector extends \Rector\Core\Rector\AbstractRector +final class LoggableBehaviorRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeManipulator\ClassInsertManipulator */ private $classInsertManipulator; - public function __construct(\Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator) + public function __construct(ClassInsertManipulator $classInsertManipulator) { $this->classInsertManipulator = $classInsertManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change Loggable from gedmo/doctrine-extensions to knplabs/doctrine-behaviors', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change Loggable from gedmo/doctrine-extensions to knplabs/doctrine-behaviors', [new CodeSample(<<<'CODE_SAMPLE' use Gedmo\Mapping\Annotation as Gedmo; use Doctrine\ORM\Mapping as ORM; @@ -75,14 +75,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class, \PhpParser\Node\Stmt\Property::class]; + return [Class_::class, Property::class]; } /** * @param Class_|Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Stmt\Class_) { + if ($node instanceof Class_) { return $this->refactorClass($node); } return $this->refactorProperty($node); @@ -90,17 +90,17 @@ CODE_SAMPLE /** * @return \PhpParser\Node\Stmt\Class_|null */ - private function refactorClass(\PhpParser\Node\Stmt\Class_ $class) + private function refactorClass(Class_ $class) { // change the node $classPhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($class); $hasLoggableAnnotation = \false; - $phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser(); + $phpDocNodeTraverser = new PhpDocNodeTraverser(); $phpDocNodeTraverser->traverseWithCallable($classPhpDocInfo->getPhpDocNode(), '', function ($node) use(&$hasLoggableAnnotation) { - if (!$node instanceof \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode) { + if (!$node instanceof SpacelessPhpDocTagNode) { return null; } - if (!$node->value instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$node->value instanceof DoctrineAnnotationTagValueNode) { return null; } $doctrineAnnotationTagValueNode = $node->value; @@ -108,7 +108,7 @@ CODE_SAMPLE return null; } $hasLoggableAnnotation = \true; - return \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser::NODE_REMOVE; + return PhpDocNodeTraverser::NODE_REMOVE; }); if (!$hasLoggableAnnotation) { return null; @@ -116,20 +116,20 @@ CODE_SAMPLE // invoke phpdoc re-print as annotation was removed $classPhpDocInfo->markAsChanged(); $this->classInsertManipulator->addAsFirstTrait($class, 'Knp\\DoctrineBehaviors\\Model\\Loggable\\LoggableTrait'); - $class->implements[] = new \PhpParser\Node\Name\FullyQualified('Knp\\DoctrineBehaviors\\Contract\\Entity\\LoggableInterface'); + $class->implements[] = new FullyQualified('Knp\\DoctrineBehaviors\\Contract\\Entity\\LoggableInterface'); return $class; } - private function refactorProperty(\PhpParser\Node\Stmt\Property $property) : ?\PhpParser\Node\Stmt\Property + private function refactorProperty(Property $property) : ?Property { // remove tag from properties $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); $hasChanged = \false; - $phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser(); + $phpDocNodeTraverser = new PhpDocNodeTraverser(); $phpDocNodeTraverser->traverseWithCallable($phpDocInfo->getPhpDocNode(), '', function ($node) use($phpDocInfo, &$hasChanged) { - if (!$node instanceof \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode) { + if (!$node instanceof SpacelessPhpDocTagNode) { return null; } - if (!$node->value instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$node->value instanceof DoctrineAnnotationTagValueNode) { return null; } if (!$node->value->hasClassName('Gedmo\\Mapping\\Annotation\\Versioned')) { @@ -137,7 +137,7 @@ CODE_SAMPLE } $phpDocInfo->markAsChanged(); $hasChanged = \true; - return \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser::NODE_REMOVE; + return PhpDocNodeTraverser::NODE_REMOVE; }); if (!$hasChanged) { return null; diff --git a/vendor/rector/rector-doctrine/src/Rector/Class_/ManagerRegistryGetManagerToEntityManagerRector.php b/vendor/rector/rector-doctrine/src/Rector/Class_/ManagerRegistryGetManagerToEntityManagerRector.php index 7b22a8a9941..adebc1f9128 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Class_/ManagerRegistryGetManagerToEntityManagerRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Class_/ManagerRegistryGetManagerToEntityManagerRector.php @@ -22,12 +22,12 @@ use Rector\Doctrine\NodeManipulator\DependencyRemover; use Rector\PostRector\Collector\PropertyToAddCollector; use Rector\PostRector\ValueObject\PropertyMetadata; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Doctrine\Tests\Rector\Class_\ManagerRegistryGetManagerToEntityManagerRector\ManagerRegistryGetManagerToEntityManagerRectorTest */ -final class ManagerRegistryGetManagerToEntityManagerRector extends \Rector\Core\Rector\AbstractRector +final class ManagerRegistryGetManagerToEntityManagerRector extends AbstractRector { /** * @var string @@ -57,16 +57,16 @@ final class ManagerRegistryGetManagerToEntityManagerRector extends \Rector\Core\ * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Doctrine\NodeAnalyzer\MethodCallNameOnTypeResolver $methodCallNameOnTypeResolver, \Rector\Doctrine\NodeManipulator\DependencyRemover $dependencyRemover, \Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(MethodCallNameOnTypeResolver $methodCallNameOnTypeResolver, DependencyRemover $dependencyRemover, PropertyToAddCollector $propertyToAddCollector, PhpVersionProvider $phpVersionProvider) { $this->methodCallNameOnTypeResolver = $methodCallNameOnTypeResolver; $this->dependencyRemover = $dependencyRemover; $this->propertyToAddCollector = $propertyToAddCollector; $this->phpVersionProvider = $phpVersionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes ManagerRegistry intermediate calls directly to EntityManager calls', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes ManagerRegistry intermediate calls directly to EntityManager calls', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\Common\Persistence\ManagerRegistry; class CustomRepository @@ -116,25 +116,25 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $constructorClassMethod = $node->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$constructorClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $constructorClassMethod = $node->getMethod(MethodName::CONSTRUCT); + if (!$constructorClassMethod instanceof ClassMethod) { return null; } // collect on registry method calls, so we know if the manager registry is needed - $registryCalledMethods = $this->methodCallNameOnTypeResolver->resolve($node, new \PHPStan\Type\ObjectType('Doctrine\\Common\\Persistence\\ManagerRegistry')); + $registryCalledMethods = $this->methodCallNameOnTypeResolver->resolve($node, new ObjectType('Doctrine\\Common\\Persistence\\ManagerRegistry')); if (!\in_array(self::GET_MANAGER, $registryCalledMethods, \true)) { return null; } $managerRegistryParam = $this->resolveManagerRegistryParam($constructorClassMethod); // no registry manager in the constructor - if (!$managerRegistryParam instanceof \PhpParser\Node\Param) { + if (!$managerRegistryParam instanceof Param) { return null; } if ($registryCalledMethods === [self::GET_MANAGER]) { @@ -144,10 +144,10 @@ CODE_SAMPLE $this->replaceEntityRegistryVariableWithEntityManagerProperty($node); $this->removeAssignGetRepositoryCalls($node); // add entity manager via constructor - $this->addConstructorDependencyWithProperty($node, $constructorClassMethod, self::ENTITY_MANAGER, new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType('Doctrine\\ORM\\EntityManagerInterface')); + $this->addConstructorDependencyWithProperty($node, $constructorClassMethod, self::ENTITY_MANAGER, new FullyQualifiedObjectType('Doctrine\\ORM\\EntityManagerInterface')); return $node; } - private function resolveManagerRegistryParam(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Param + private function resolveManagerRegistryParam(ClassMethod $classMethod) : ?Param { foreach ($classMethod->params as $param) { if ($param->type === null) { @@ -160,7 +160,7 @@ CODE_SAMPLE } return null; } - private function removeManagerRegistryDependency(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Param $registryParam) : void + private function removeManagerRegistryDependency(Class_ $class, ClassMethod $classMethod, Param $registryParam) : void { // remove constructor param: $managerRegistry foreach ($classMethod->params as $key => $param) { @@ -179,22 +179,22 @@ CODE_SAMPLE * * After: $this->entityManager-> */ - private function replaceEntityRegistryVariableWithEntityManagerProperty(\PhpParser\Node\Stmt\Class_ $class) : void + private function replaceEntityRegistryVariableWithEntityManagerProperty(Class_ $class) : void { - $this->traverseNodesWithCallable($class->stmts, function (\PhpParser\Node $node) : ?PropertyFetch { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + $this->traverseNodesWithCallable($class->stmts, function (Node $node) : ?PropertyFetch { + if (!$node instanceof Variable) { return null; } - if (!$this->isObjectType($node, new \PHPStan\Type\ObjectType('Doctrine\\Common\\Persistence\\ObjectManager'))) { + if (!$this->isObjectType($node, new ObjectType('Doctrine\\Common\\Persistence\\ObjectManager'))) { return null; } - return new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable('this'), self::ENTITY_MANAGER); + return new PropertyFetch(new Variable('this'), self::ENTITY_MANAGER); }); } - private function removeAssignGetRepositoryCalls(\PhpParser\Node\Stmt\Class_ $class) : void + private function removeAssignGetRepositoryCalls(Class_ $class) : void { - $this->traverseNodesWithCallable($class->stmts, function (\PhpParser\Node $node) { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + $this->traverseNodesWithCallable($class->stmts, function (Node $node) { + if (!$node instanceof Assign) { return null; } if (!$this->isRegistryGetManagerMethodCall($node)) { @@ -203,21 +203,21 @@ CODE_SAMPLE $this->removeNode($node); }); } - private function addConstructorDependencyWithProperty(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\ClassMethod $classMethod, string $name, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : void + private function addConstructorDependencyWithProperty(Class_ $class, ClassMethod $classMethod, string $name, FullyQualifiedObjectType $fullyQualifiedObjectType) : void { - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::PROPERTY_PROMOTION)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::PROPERTY_PROMOTION)) { $assign = $this->nodeFactory->createPropertyAssignment($name); - $classMethod->stmts[] = new \PhpParser\Node\Stmt\Expression($assign); + $classMethod->stmts[] = new Expression($assign); } - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($name, $fullyQualifiedObjectType, \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $propertyMetadata = new PropertyMetadata($name, $fullyQualifiedObjectType, Class_::MODIFIER_PRIVATE); $this->propertyToAddCollector->addPropertyToClass($class, $propertyMetadata); } - private function isRegistryGetManagerMethodCall(\PhpParser\Node\Expr\Assign $assign) : bool + private function isRegistryGetManagerMethodCall(Assign $assign) : bool { - if (!$assign->expr instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$assign->expr instanceof MethodCall) { return \false; } - if (!$this->isObjectType($assign->expr->var, new \PHPStan\Type\ObjectType('Doctrine\\Common\\Persistence\\ManagerRegistry'))) { + if (!$this->isObjectType($assign->expr->var, new ObjectType('Doctrine\\Common\\Persistence\\ManagerRegistry'))) { return \false; } return $this->isName($assign->expr->name, self::GET_MANAGER); diff --git a/vendor/rector/rector-doctrine/src/Rector/Class_/MoveCurrentDateTimeDefaultInEntityToConstructorRector.php b/vendor/rector/rector-doctrine/src/Rector/Class_/MoveCurrentDateTimeDefaultInEntityToConstructorRector.php index b6dc448b705..019ca74a90c 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Class_/MoveCurrentDateTimeDefaultInEntityToConstructorRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Class_/MoveCurrentDateTimeDefaultInEntityToConstructorRector.php @@ -13,14 +13,14 @@ use Rector\Core\Rector\AbstractRector; use Rector\Doctrine\NodeAnalyzer\ConstructorAssignPropertyAnalyzer; use Rector\Doctrine\NodeFactory\ValueAssignFactory; use Rector\Doctrine\NodeManipulator\ConstructorManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://stackoverflow.com/a/7698687/1348344 * * @see \Rector\Doctrine\Tests\Rector\Class_\MoveCurrentDateTimeDefaultInEntityToConstructorRector\MoveCurrentDateTimeDefaultInEntityToConstructorRectorTest */ -final class MoveCurrentDateTimeDefaultInEntityToConstructorRector extends \Rector\Core\Rector\AbstractRector +final class MoveCurrentDateTimeDefaultInEntityToConstructorRector extends AbstractRector { /** * @readonly @@ -37,15 +37,15 @@ final class MoveCurrentDateTimeDefaultInEntityToConstructorRector extends \Recto * @var \Rector\Doctrine\NodeAnalyzer\ConstructorAssignPropertyAnalyzer */ private $constructorAssignPropertyAnalyzer; - public function __construct(\Rector\Doctrine\NodeManipulator\ConstructorManipulator $constructorManipulator, \Rector\Doctrine\NodeFactory\ValueAssignFactory $valueAssignFactory, \Rector\Doctrine\NodeAnalyzer\ConstructorAssignPropertyAnalyzer $constructorAssignPropertyAnalyzer) + public function __construct(ConstructorManipulator $constructorManipulator, ValueAssignFactory $valueAssignFactory, ConstructorAssignPropertyAnalyzer $constructorAssignPropertyAnalyzer) { $this->constructorManipulator = $constructorManipulator; $this->valueAssignFactory = $valueAssignFactory; $this->constructorAssignPropertyAnalyzer = $constructorAssignPropertyAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Move default value for entity property to constructor, the safest place', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Move default value for entity property to constructor, the safest place', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\ORM\Mapping as ORM; /** @@ -89,23 +89,23 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($node->getProperties() as $property) { $this->refactorProperty($property, $node); } return $node; } - private function refactorProperty(\PhpParser\Node\Stmt\Property $property, \PhpParser\Node\Stmt\Class_ $class) : ?\PhpParser\Node\Stmt\Property + private function refactorProperty(Property $property, Class_ $class) : ?Property { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); $doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass('Doctrine\\ORM\\Mapping\\Column'); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return null; } $type = $doctrineAnnotationTagValueNode->getValueWithoutQuotes('type'); @@ -119,7 +119,7 @@ CODE_SAMPLE } // 1. remove default options from database level $options = $doctrineAnnotationTagValueNode->getValue('options'); - if ($options instanceof \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode) { + if ($options instanceof CurlyListNode) { $options->removeValue('default'); // if empty, remove it completely if ($options->getValues() === []) { @@ -133,13 +133,13 @@ CODE_SAMPLE $onlyProperty->default = null; return $property; } - private function refactorClass(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\Property $property) : void + private function refactorClass(Class_ $class, Property $property) : void { /** @var string $propertyName */ $propertyName = $this->getName($property); $onlyProperty = $property->props[0]; $defaultExpr = $onlyProperty->default; - if (!$defaultExpr instanceof \PhpParser\Node\Expr) { + if (!$defaultExpr instanceof Expr) { return; } if ($this->valueResolver->isNull($defaultExpr)) { diff --git a/vendor/rector/rector-doctrine/src/Rector/Class_/MoveRepositoryFromParentToConstructorRector.php b/vendor/rector/rector-doctrine/src/Rector/Class_/MoveRepositoryFromParentToConstructorRector.php index 7c60f1d5c69..a7ee618c24b 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Class_/MoveRepositoryFromParentToConstructorRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Class_/MoveRepositoryFromParentToConstructorRector.php @@ -12,12 +12,12 @@ use Rector\Core\NodeManipulator\ClassInsertManipulator; use Rector\Core\Rector\AbstractRector; use Rector\Doctrine\NodeAnalyzer\EntityObjectTypeResolver; use Rector\Doctrine\NodeFactory\RepositoryAssignFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Doctrine\Tests\Set\DoctrineRepositoryAsServiceSet\DoctrineRepositoryAsServiceSetTest */ -final class MoveRepositoryFromParentToConstructorRector extends \Rector\Core\Rector\AbstractRector +final class MoveRepositoryFromParentToConstructorRector extends AbstractRector { /** * @readonly @@ -39,16 +39,16 @@ final class MoveRepositoryFromParentToConstructorRector extends \Rector\Core\Rec * @var \Rector\Doctrine\NodeAnalyzer\EntityObjectTypeResolver */ private $entityObjectTypeResolver; - public function __construct(\Rector\Core\NodeManipulator\ClassDependencyManipulator $classDependencyManipulator, \Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator, \Rector\Doctrine\NodeFactory\RepositoryAssignFactory $repositoryAssignFactory, \Rector\Doctrine\NodeAnalyzer\EntityObjectTypeResolver $entityObjectTypeResolver) + public function __construct(ClassDependencyManipulator $classDependencyManipulator, ClassInsertManipulator $classInsertManipulator, RepositoryAssignFactory $repositoryAssignFactory, EntityObjectTypeResolver $entityObjectTypeResolver) { $this->classDependencyManipulator = $classDependencyManipulator; $this->classInsertManipulator = $classInsertManipulator; $this->repositoryAssignFactory = $repositoryAssignFactory; $this->entityObjectTypeResolver = $entityObjectTypeResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns parent EntityRepository class to constructor dependency', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns parent EntityRepository class to constructor dependency', [new CodeSample(<<<'CODE_SAMPLE' namespace App\Repository; use Doctrine\ORM\EntityRepository; @@ -84,14 +84,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node, new \PHPStan\Type\ObjectType('Doctrine\\ORM\\EntityRepository'))) { + if (!$this->isObjectType($node, new ObjectType('Doctrine\\ORM\\EntityRepository'))) { return null; } if ($node->extends === null) { @@ -100,12 +100,12 @@ CODE_SAMPLE // remove parent class $node->extends = null; $entityObjectType = $this->entityObjectTypeResolver->resolveFromRepositoryClass($node); - $genericObjectType = new \PHPStan\Type\Generic\GenericObjectType('Doctrine\\ORM\\EntityRepository', [$entityObjectType]); + $genericObjectType = new GenericObjectType('Doctrine\\ORM\\EntityRepository', [$entityObjectType]); // add $repository property $this->classInsertManipulator->addPropertyToClass($node, 'repository', $genericObjectType); // add $entityManager and assign to constuctor $repositoryAssign = $this->repositoryAssignFactory->create($node); - $this->classDependencyManipulator->addConstructorDependencyWithCustomAssign($node, 'entityManager', new \PHPStan\Type\ObjectType('Doctrine\\ORM\\EntityManagerInterface'), $repositoryAssign); + $this->classDependencyManipulator->addConstructorDependencyWithCustomAssign($node, 'entityManager', new ObjectType('Doctrine\\ORM\\EntityManagerInterface'), $repositoryAssign); return $node; } } diff --git a/vendor/rector/rector-doctrine/src/Rector/Class_/RemoveRedundantDefaultClassAnnotationValuesRector.php b/vendor/rector/rector-doctrine/src/Rector/Class_/RemoveRedundantDefaultClassAnnotationValuesRector.php index cba2ed8b182..5e6a5d9a97c 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Class_/RemoveRedundantDefaultClassAnnotationValuesRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Class_/RemoveRedundantDefaultClassAnnotationValuesRector.php @@ -8,25 +8,25 @@ use PhpParser\Node\Stmt\Class_; use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode; use Rector\Core\Rector\AbstractRector; use Rector\Doctrine\NodeManipulator\DoctrineItemDefaultValueManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Doctrine\Tests\Rector\Class_\RemoveRedundantDefaultClassAnnotationValuesRector\RemoveRedundantDefaultClassAnnotationValuesRectorTest */ -final class RemoveRedundantDefaultClassAnnotationValuesRector extends \Rector\Core\Rector\AbstractRector +final class RemoveRedundantDefaultClassAnnotationValuesRector extends AbstractRector { /** * @readonly * @var \Rector\Doctrine\NodeManipulator\DoctrineItemDefaultValueManipulator */ private $doctrineItemDefaultValueManipulator; - public function __construct(\Rector\Doctrine\NodeManipulator\DoctrineItemDefaultValueManipulator $doctrineItemDefaultValueManipulator) + public function __construct(DoctrineItemDefaultValueManipulator $doctrineItemDefaultValueManipulator) { $this->doctrineItemDefaultValueManipulator = $doctrineItemDefaultValueManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Removes redundant default values from Doctrine ORM annotations on class level', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Removes redundant default values from Doctrine ORM annotations on class level', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\ORM\Mapping as ORM; /** @@ -53,25 +53,25 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $this->refactorClassAnnotations($node); return $node; } - private function refactorClassAnnotations(\PhpParser\Node\Stmt\Class_ $class) : void + private function refactorClassAnnotations(Class_ $class) : void { $this->refactorEntityAnnotation($class); } - private function refactorEntityAnnotation(\PhpParser\Node\Stmt\Class_ $class) : void + private function refactorEntityAnnotation(Class_ $class) : void { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($class); $doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass('Doctrine\\ORM\\Mapping\\Entity'); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return; } $this->doctrineItemDefaultValueManipulator->remove($phpDocInfo, $doctrineAnnotationTagValueNode, 'readOnly', \false); diff --git a/vendor/rector/rector-doctrine/src/Rector/Class_/RemoveRepositoryFromEntityAnnotationRector.php b/vendor/rector/rector-doctrine/src/Rector/Class_/RemoveRepositoryFromEntityAnnotationRector.php index d19fb4a3567..75f349a63b4 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Class_/RemoveRepositoryFromEntityAnnotationRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Class_/RemoveRepositoryFromEntityAnnotationRector.php @@ -7,16 +7,16 @@ use PhpParser\Node; use PhpParser\Node\Stmt\Class_; use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Doctrine\Tests\Rector\Class_\RemoveRepositoryFromEntityAnnotationRector\RemoveRepositoryFromEntityAnnotationRectorTest */ -final class RemoveRepositoryFromEntityAnnotationRector extends \Rector\Core\Rector\AbstractRector +final class RemoveRepositoryFromEntityAnnotationRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Removes repository class from @Entity annotation', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Removes repository class from @Entity annotation', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\ORM\Mapping as ORM; /** @@ -43,16 +43,16 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass('Doctrine\\ORM\\Mapping\\Entity'); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return null; } $repositoryClass = $doctrineAnnotationTagValueNode->getValue('repositoryClass'); diff --git a/vendor/rector/rector-doctrine/src/Rector/Class_/SluggableBehaviorRector.php b/vendor/rector/rector-doctrine/src/Rector/Class_/SluggableBehaviorRector.php index 9097eaac0e1..52e55208b36 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Class_/SluggableBehaviorRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Class_/SluggableBehaviorRector.php @@ -17,15 +17,15 @@ use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNod use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\NodeManipulator\ClassInsertManipulator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/Atlantic18/DoctrineExtensions/blob/v2.4.x/doc/sluggable.md * @see https://github.com/KnpLabs/DoctrineBehaviors/blob/4e0677379dd4adf84178f662d08454a9627781a8/docs/sluggable.md * * @see \Rector\Doctrine\Tests\Rector\Class_\SluggableBehaviorRector\SluggableBehaviorRectorTest */ -final class SluggableBehaviorRector extends \Rector\Core\Rector\AbstractRector +final class SluggableBehaviorRector extends AbstractRector { /** * @readonly @@ -37,14 +37,14 @@ final class SluggableBehaviorRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger */ private $phpDocTypeChanger; - public function __construct(\Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger) + public function __construct(ClassInsertManipulator $classInsertManipulator, PhpDocTypeChanger $phpDocTypeChanger) { $this->classInsertManipulator = $classInsertManipulator; $this->phpDocTypeChanger = $phpDocTypeChanger; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change Sluggable from gedmo/doctrine-extensions to knplabs/doctrine-behaviors', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change Sluggable from gedmo/doctrine-extensions to knplabs/doctrine-behaviors', [new CodeSample(<<<'CODE_SAMPLE' use Gedmo\Mapping\Annotation as Gedmo; class SomeClass @@ -90,23 +90,23 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $slugFields = []; $matchedProperty = null; foreach ($node->getProperties() as $property) { $propertyPhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); $doctrineAnnotationTagValueNode = $propertyPhpDocInfo->getByAnnotationClass('Gedmo\\Mapping\\Annotation\\Slug'); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { continue; } $slugFields = $doctrineAnnotationTagValueNode->getValue('fields'); - if ($slugFields instanceof \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode) { + if ($slugFields instanceof CurlyListNode) { $slugFields = $slugFields->getValuesWithExplicitSilentAndWithoutQuotes(); } $this->removeNode($property); @@ -123,9 +123,9 @@ CODE_SAMPLE $this->removeNode($classMethod); } $this->classInsertManipulator->addAsFirstTrait($node, 'Knp\\DoctrineBehaviors\\Model\\Sluggable\\SluggableTrait'); - $node->implements[] = new \PhpParser\Node\Name\FullyQualified('Knp\\DoctrineBehaviors\\Contract\\Entity\\SluggableInterface'); + $node->implements[] = new FullyQualified('Knp\\DoctrineBehaviors\\Contract\\Entity\\SluggableInterface'); if (!\is_array($slugFields)) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $this->addGetSluggableFieldsClassMethod($node, $slugFields); return $node; @@ -133,12 +133,12 @@ CODE_SAMPLE /** * @param string[] $slugFields */ - private function addGetSluggableFieldsClassMethod(\PhpParser\Node\Stmt\Class_ $class, array $slugFields) : void + private function addGetSluggableFieldsClassMethod(Class_ $class, array $slugFields) : void { $classMethod = $this->nodeFactory->createPublicMethod('getSluggableFields'); - $classMethod->returnType = new \PhpParser\Node\Identifier('array'); - $classMethod->stmts[] = new \PhpParser\Node\Stmt\Return_($this->nodeFactory->createArray($slugFields)); - $returnType = new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\StringType()); + $classMethod->returnType = new Identifier('array'); + $classMethod->stmts[] = new Return_($this->nodeFactory->createArray($slugFields)); + $returnType = new ArrayType(new MixedType(), new StringType()); $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); $this->phpDocTypeChanger->changeReturnType($phpDocInfo, $returnType); $this->classInsertManipulator->addAsFirstMethod($class, $classMethod); diff --git a/vendor/rector/rector-doctrine/src/Rector/Class_/SoftDeletableBehaviorRector.php b/vendor/rector/rector-doctrine/src/Rector/Class_/SoftDeletableBehaviorRector.php index 9640ef8378e..9d59ab62e51 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Class_/SoftDeletableBehaviorRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Class_/SoftDeletableBehaviorRector.php @@ -10,15 +10,15 @@ use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode; use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover; use Rector\Core\NodeManipulator\ClassInsertManipulator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/Atlantic18/DoctrineExtensions/blob/v2.4.x/doc/softdeleteable.md * @see https://github.com/KnpLabs/DoctrineBehaviors/blob/4e0677379dd4adf84178f662d08454a9627781a8/docs/soft-deletable.md * * @see \Rector\Doctrine\Tests\Rector\Class_\SoftDeletableBehaviorRector\SoftDeletableBehaviorRectorTest */ -final class SoftDeletableBehaviorRector extends \Rector\Core\Rector\AbstractRector +final class SoftDeletableBehaviorRector extends AbstractRector { /** * @readonly @@ -30,14 +30,14 @@ final class SoftDeletableBehaviorRector extends \Rector\Core\Rector\AbstractRect * @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover */ private $phpDocTagRemover; - public function __construct(\Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover $phpDocTagRemover) + public function __construct(ClassInsertManipulator $classInsertManipulator, PhpDocTagRemover $phpDocTagRemover) { $this->classInsertManipulator = $classInsertManipulator; $this->phpDocTagRemover = $phpDocTagRemover; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change SoftDeletable from gedmo/doctrine-extensions to knplabs/doctrine-behaviors', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change SoftDeletable from gedmo/doctrine-extensions to knplabs/doctrine-behaviors', [new CodeSample(<<<'CODE_SAMPLE' use Gedmo\Mapping\Annotation as Gedmo; /** @@ -77,16 +77,16 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass('Gedmo\\Mapping\\Annotation\\SoftDeleteable'); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return null; } $fieldName = $doctrineAnnotationTagValueNode->getValueWithoutQuotes('fieldName'); @@ -95,11 +95,11 @@ CODE_SAMPLE } $this->removePropertyAndClassMethods($node, $fieldName); $this->classInsertManipulator->addAsFirstTrait($node, 'Knp\\DoctrineBehaviors\\Model\\SoftDeletable\\SoftDeletableTrait'); - $node->implements[] = new \PhpParser\Node\Name\FullyQualified('Knp\\DoctrineBehaviors\\Contract\\Entity\\SoftDeletableInterface'); + $node->implements[] = new FullyQualified('Knp\\DoctrineBehaviors\\Contract\\Entity\\SoftDeletableInterface'); $this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $doctrineAnnotationTagValueNode); return $node; } - private function removePropertyAndClassMethods(\PhpParser\Node\Stmt\Class_ $class, string $fieldName) : void + private function removePropertyAndClassMethods(Class_ $class, string $fieldName) : void { // remove property foreach ($class->getProperties() as $property) { diff --git a/vendor/rector/rector-doctrine/src/Rector/Class_/TimestampableBehaviorRector.php b/vendor/rector/rector-doctrine/src/Rector/Class_/TimestampableBehaviorRector.php index 44f43357eb3..efd660c4249 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Class_/TimestampableBehaviorRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Class_/TimestampableBehaviorRector.php @@ -8,28 +8,28 @@ use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\Stmt\Class_; use Rector\Core\NodeManipulator\ClassManipulator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/Atlantic18/DoctrineExtensions/blob/v2.4.x/doc/timestampable.md * @see https://github.com/KnpLabs/DoctrineBehaviors/blob/4e0677379dd4adf84178f662d08454a9627781a8/docs/timestampable.md * * @see \Rector\Doctrine\Tests\Rector\Class_\TimestampableBehaviorRector\TimestampableBehaviorRectorTest */ -final class TimestampableBehaviorRector extends \Rector\Core\Rector\AbstractRector +final class TimestampableBehaviorRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeManipulator\ClassManipulator */ private $classManipulator; - public function __construct(\Rector\Core\NodeManipulator\ClassManipulator $classManipulator) + public function __construct(ClassManipulator $classManipulator) { $this->classManipulator = $classManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change Timestampable from gedmo/doctrine-extensions to knplabs/doctrine-behaviors', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change Timestampable from gedmo/doctrine-extensions to knplabs/doctrine-behaviors', [new CodeSample(<<<'CODE_SAMPLE' use Gedmo\Timestampable\Traits\TimestampableEntity; class SomeClass @@ -53,18 +53,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->classManipulator->hasTrait($node, 'Gedmo\\Timestampable\\Traits\\TimestampableEntity')) { return null; } $this->classManipulator->replaceTrait($node, 'Gedmo\\Timestampable\\Traits\\TimestampableEntity', 'Knp\\DoctrineBehaviors\\Model\\Timestampable\\TimestampableTrait'); - $node->implements[] = new \PhpParser\Node\Name\FullyQualified('Knp\\DoctrineBehaviors\\Contract\\Entity\\TimestampableInterface'); + $node->implements[] = new FullyQualified('Knp\\DoctrineBehaviors\\Contract\\Entity\\TimestampableInterface'); return $node; } } diff --git a/vendor/rector/rector-doctrine/src/Rector/Class_/TranslationBehaviorRector.php b/vendor/rector/rector-doctrine/src/Rector/Class_/TranslationBehaviorRector.php index 233a362f308..eb1b3f3e1dc 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Class_/TranslationBehaviorRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Class_/TranslationBehaviorRector.php @@ -18,8 +18,8 @@ use Rector\Doctrine\NodeFactory\TranslationClassNodeFactory; use Rector\Doctrine\ValueObject\PropertyNamesAndPhpDocInfos; use Rector\FileSystemRector\ValueObject\AddedFileWithNodes; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/Atlantic18/DoctrineExtensions/blob/v2.4.x/doc/translatable.md * @see https://github.com/KnpLabs/DoctrineBehaviors/blob/4e0677379dd4adf84178f662d08454a9627781a8/docs/translatable.md @@ -28,7 +28,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @see \Rector\Doctrine\Tests\Rector\Class_\TranslationBehaviorRector\TranslationBehaviorRectorTest */ -final class TranslationBehaviorRector extends \Rector\Core\Rector\AbstractRector +final class TranslationBehaviorRector extends AbstractRector { /** * @readonly @@ -55,7 +55,7 @@ final class TranslationBehaviorRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector */ private $removedAndAddedFilesCollector; - public function __construct(\Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator, \Rector\Core\NodeManipulator\ClassManipulator $classManipulator, \Rector\Doctrine\NodeFactory\TranslationClassNodeFactory $translationClassNodeFactory, \Rector\Doctrine\NodeAnalyzer\TranslatablePropertyCollectorAndRemover $translatablePropertyCollectorAndRemover, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector) + public function __construct(ClassInsertManipulator $classInsertManipulator, ClassManipulator $classManipulator, TranslationClassNodeFactory $translationClassNodeFactory, TranslatablePropertyCollectorAndRemover $translatablePropertyCollectorAndRemover, RemovedAndAddedFilesCollector $removedAndAddedFilesCollector) { $this->classInsertManipulator = $classInsertManipulator; $this->classManipulator = $classManipulator; @@ -63,9 +63,9 @@ final class TranslationBehaviorRector extends \Rector\Core\Rector\AbstractRector $this->translatablePropertyCollectorAndRemover = $translatablePropertyCollectorAndRemover; $this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change Translation from gedmo/doctrine-extensions to knplabs/doctrine-behaviors', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change Translation from gedmo/doctrine-extensions to knplabs/doctrine-behaviors', [new CodeSample(<<<'CODE_SAMPLE' use Gedmo\Mapping\Annotation as Gedmo; use Doctrine\ORM\Mapping as ORM; use Gedmo\Translatable\Translatable; @@ -132,15 +132,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $classType = $this->nodeTypeResolver->getType($node); - $translatableObjectType = new \PHPStan\Type\ObjectType('Gedmo\\Translatable\\Translatable'); + $translatableObjectType = new ObjectType('Gedmo\\Translatable\\Translatable'); if (!$translatableObjectType->isSuperTypeOf($classType)->yes()) { return null; } @@ -149,7 +149,7 @@ CODE_SAMPLE } $this->classManipulator->removeInterface($node, 'Gedmo\\Translatable\\Translatable'); $this->classInsertManipulator->addAsFirstTrait($node, 'Knp\\DoctrineBehaviors\\Model\\Translatable\\TranslatableTrait'); - $node->implements[] = new \PhpParser\Node\Name\FullyQualified('Knp\\DoctrineBehaviors\\Contract\\Entity\\TranslatableInterface'); + $node->implements[] = new FullyQualified('Knp\\DoctrineBehaviors\\Contract\\Entity\\TranslatableInterface'); $propertyNamesAndPhpDocInfos = $this->translatablePropertyCollectorAndRemover->processClass($node); $this->removeSetAndGetMethods($node, $propertyNamesAndPhpDocInfos->getPropertyNames()); $this->dumpEntityTranslation($node, $propertyNamesAndPhpDocInfos); @@ -158,7 +158,7 @@ CODE_SAMPLE /** * @param string[] $removedPropertyNames */ - private function removeSetAndGetMethods(\PhpParser\Node\Stmt\Class_ $class, array $removedPropertyNames) : void + private function removeSetAndGetMethods(Class_ $class, array $removedPropertyNames) : void { foreach ($removedPropertyNames as $removedPropertyName) { foreach ($class->getMethods() as $classMethod) { @@ -174,27 +174,27 @@ CODE_SAMPLE } } } - private function dumpEntityTranslation(\PhpParser\Node\Stmt\Class_ $class, \Rector\Doctrine\ValueObject\PropertyNamesAndPhpDocInfos $propertyNamesAndPhpDocInfos) : void + private function dumpEntityTranslation(Class_ $class, PropertyNamesAndPhpDocInfos $propertyNamesAndPhpDocInfos) : void { $smartFileInfo = $this->file->getSmartFileInfo(); $classShortName = $class->name . 'Translation'; $filePath = \dirname($smartFileInfo->getRealPath()) . \DIRECTORY_SEPARATOR . $classShortName . '.php'; - $namespace = $class->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$namespace instanceof \PhpParser\Node\Stmt\Namespace_) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $namespace = $class->getAttribute(AttributeKey::PARENT_NODE); + if (!$namespace instanceof Namespace_) { + throw new ShouldNotHappenException(); } - $namespace = new \PhpParser\Node\Stmt\Namespace_($namespace->name); + $namespace = new Namespace_($namespace->name); $class = $this->translationClassNodeFactory->create($classShortName); foreach ($propertyNamesAndPhpDocInfos->all() as $propertyNameAndPhpDocInfo) { $property = $this->nodeFactory->createPrivateProperty($propertyNameAndPhpDocInfo->getPropertyName()); - $property->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $propertyNameAndPhpDocInfo->getPhpDocInfo()); + $property->setAttribute(AttributeKey::PHP_DOC_INFO, $propertyNameAndPhpDocInfo->getPhpDocInfo()); $class->stmts[] = $property; } $namespace->stmts[] = $class; - $addedFileWithNodes = new \Rector\FileSystemRector\ValueObject\AddedFileWithNodes($filePath, [$namespace]); + $addedFileWithNodes = new AddedFileWithNodes($filePath, [$namespace]); $this->removedAndAddedFilesCollector->addAddedFile($addedFileWithNodes); } - private function hasImplements(\PhpParser\Node\Stmt\Class_ $class) : bool + private function hasImplements(Class_ $class) : bool { foreach ($class->implements as $implement) { if ($this->isName($implement, 'Gedmo\\Translatable\\Translatable')) { diff --git a/vendor/rector/rector-doctrine/src/Rector/Class_/TreeBehaviorRector.php b/vendor/rector/rector-doctrine/src/Rector/Class_/TreeBehaviorRector.php index 1bafcd13936..3a4c26f0e0d 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Class_/TreeBehaviorRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Class_/TreeBehaviorRector.php @@ -11,15 +11,15 @@ use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode; use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover; use Rector\Core\NodeManipulator\ClassInsertManipulator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/Atlantic18/DoctrineExtensions/blob/v2.4.x/doc/tree.md * @see https://github.com/KnpLabs/DoctrineBehaviors/blob/4e0677379dd4adf84178f662d08454a9627781a8/docs/tree.md * * @see \Rector\Doctrine\Tests\Rector\Class_\TreeBehaviorRector\TreeBehaviorRectorTest */ -final class TreeBehaviorRector extends \Rector\Core\Rector\AbstractRector +final class TreeBehaviorRector extends AbstractRector { /** * @readonly @@ -31,14 +31,14 @@ final class TreeBehaviorRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover */ private $phpDocTagRemover; - public function __construct(\Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover $phpDocTagRemover) + public function __construct(ClassInsertManipulator $classInsertManipulator, PhpDocTagRemover $phpDocTagRemover) { $this->classInsertManipulator = $classInsertManipulator; $this->phpDocTagRemover = $phpDocTagRemover; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change Tree from gedmo/doctrine-extensions to knplabs/doctrine-behaviors', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change Tree from gedmo/doctrine-extensions to knplabs/doctrine-behaviors', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\Common\Collections\Collection; use Gedmo\Mapping\Annotation as Gedmo; @@ -122,21 +122,21 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $propertyPhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $doctrineAnnotationTagValueNode = $propertyPhpDocInfo->getByAnnotationClass('Gedmo\\Mapping\\Annotation\\Tree'); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return null; } // we're in a tree entity $this->phpDocTagRemover->removeTagValueFromNode($propertyPhpDocInfo, $doctrineAnnotationTagValueNode); - $node->implements[] = new \PhpParser\Node\Name\FullyQualified('Knp\\DoctrineBehaviors\\Contract\\Entity\\TreeNodeInterface'); + $node->implements[] = new FullyQualified('Knp\\DoctrineBehaviors\\Contract\\Entity\\TreeNodeInterface'); $this->classInsertManipulator->addAsFirstTrait($node, 'Knp\\DoctrineBehaviors\\Model\\Tree\\TreeNodeTrait'); // remove all tree-related properties and their getters and setters - it's handled by behavior trait $removedPropertyNames = []; @@ -152,7 +152,7 @@ CODE_SAMPLE $this->removeClassMethodsForProperties($node, $removedPropertyNames); return $node; } - private function shouldRemoveProperty(\PhpParser\Node\Stmt\Property $property) : bool + private function shouldRemoveProperty(Property $property) : bool { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); return $phpDocInfo->hasByAnnotationClasses(['Gedmo\\Mapping\\Annotation\\TreeLeft', 'Gedmo\\Mapping\\Annotation\\TreeRight', 'Gedmo\\Mapping\\Annotation\\TreeRoot', 'Gedmo\\Mapping\\Annotation\\TreeParent', 'Gedmo\\Mapping\\Annotation\\TreeLevel']); @@ -160,7 +160,7 @@ CODE_SAMPLE /** * @param string[] $removedPropertyNames */ - private function removeClassMethodsForProperties(\PhpParser\Node\Stmt\Class_ $class, array $removedPropertyNames) : void + private function removeClassMethodsForProperties(Class_ $class, array $removedPropertyNames) : void { foreach ($removedPropertyNames as $removedPropertyName) { foreach ($class->getMethods() as $classMethod) { diff --git a/vendor/rector/rector-doctrine/src/Rector/MethodCall/ChangeSetParametersArrayToArrayCollectionRector.php b/vendor/rector/rector-doctrine/src/Rector/MethodCall/ChangeSetParametersArrayToArrayCollectionRector.php index 9216cbc8668..ac9e1ff36f1 100644 --- a/vendor/rector/rector-doctrine/src/Rector/MethodCall/ChangeSetParametersArrayToArrayCollectionRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/MethodCall/ChangeSetParametersArrayToArrayCollectionRector.php @@ -17,13 +17,13 @@ use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Rector\AbstractRector; use Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer; use Rector\NodeTypeResolver\TypeAnalyzer\ArrayTypeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/doctrine/orm/blob/2.7/UPGRADE.md#query-querybuilder-and-nativequery-parameters-bc-break * @see \Rector\Doctrine\Tests\Rector\MethodCall\ChangeSetParametersArrayToArrayCollectionRector\ChangeSetParametersArrayToArrayCollectionRectorTest */ -final class ChangeSetParametersArrayToArrayCollectionRector extends \Rector\Core\Rector\AbstractRector +final class ChangeSetParametersArrayToArrayCollectionRector extends AbstractRector { /** * @readonly @@ -35,7 +35,7 @@ final class ChangeSetParametersArrayToArrayCollectionRector extends \Rector\Core * @var \Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer */ private $fluentChainMethodCallNodeAnalyzer; - public function __construct(\Rector\NodeTypeResolver\TypeAnalyzer\ArrayTypeAnalyzer $arrayTypeAnalyzer, \Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer $fluentChainMethodCallNodeAnalyzer) + public function __construct(ArrayTypeAnalyzer $arrayTypeAnalyzer, FluentChainMethodCallNodeAnalyzer $fluentChainMethodCallNodeAnalyzer) { $this->arrayTypeAnalyzer = $arrayTypeAnalyzer; $this->fluentChainMethodCallNodeAnalyzer = $fluentChainMethodCallNodeAnalyzer; @@ -45,12 +45,12 @@ final class ChangeSetParametersArrayToArrayCollectionRector extends \Rector\Core */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkipMethodCall($node)) { return null; @@ -66,12 +66,12 @@ final class ChangeSetParametersArrayToArrayCollectionRector extends \Rector\Core } unset($node->args); $new = $this->getNewArrayCollectionFromSetParametersArgument($firstArgument); - $node->args = [new \PhpParser\Node\Arg($new)]; + $node->args = [new Arg($new)]; return $node; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change array to ArrayCollection in setParameters method of query builder', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change array to ArrayCollection in setParameters method of query builder', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\ORM\EntityRepository; class SomeRepository extends EntityRepository @@ -115,14 +115,14 @@ class SomeRepository extends EntityRepository CODE_SAMPLE )]); } - private function shouldSkipMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + private function shouldSkipMethodCall(MethodCall $methodCall) : bool { - $classLike = $this->betterNodeFinder->findParentType($methodCall, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($methodCall, ClassLike::class); + if (!$classLike instanceof ClassLike) { return \true; } // one of the cases when we are in the repo and it's extended from EntityRepository - if (!$this->isObjectType($classLike, new \PHPStan\Type\ObjectType('Doctrine\\ORM\\EntityRepository'))) { + if (!$this->isObjectType($classLike, new ObjectType('Doctrine\\ORM\\EntityRepository'))) { return \true; } if (!$this->isName($methodCall->name, 'setParameters')) { @@ -130,12 +130,12 @@ CODE_SAMPLE } // compare root variable $rootExpr = $this->fluentChainMethodCallNodeAnalyzer->resolveRootMethodCall($methodCall); - if (!$rootExpr instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$rootExpr instanceof MethodCall) { return \true; } - return !$this->isObjectType($rootExpr, new \PHPStan\Type\ObjectType('Doctrine\\ORM\\QueryBuilder')); + return !$this->isObjectType($rootExpr, new ObjectType('Doctrine\\ORM\\QueryBuilder')); } - private function getNewArrayCollectionFromSetParametersArgument(\PhpParser\Node\Arg $arg) : \PhpParser\Node\Expr\New_ + private function getNewArrayCollectionFromSetParametersArgument(Arg $arg) : New_ { /** @var Array_ $arrayExpression */ $arrayExpression = $arg->value; @@ -143,15 +143,15 @@ CODE_SAMPLE $firstArgumentArrayItems = $arrayExpression->items; $arrayCollectionArrayArguments = []; foreach ($firstArgumentArrayItems as $firstArgumentArrayItem) { - if (!$firstArgumentArrayItem->key instanceof \PhpParser\Node\Scalar\String_ || !$firstArgumentArrayItem->value instanceof \PhpParser\Node\Scalar\String_) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$firstArgumentArrayItem->key instanceof String_ || !$firstArgumentArrayItem->value instanceof String_) { + throw new ShouldNotHappenException(); } - $queryParameter = new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name\FullyQualified('Doctrine\\ORM\\Query\\Parameter')); - $queryParameter->args = [new \PhpParser\Node\Arg($firstArgumentArrayItem->key), new \PhpParser\Node\Arg($firstArgumentArrayItem->value)]; - $arrayCollectionArrayArguments[] = new \PhpParser\Node\Expr\ArrayItem($queryParameter); + $queryParameter = new New_(new FullyQualified('Doctrine\\ORM\\Query\\Parameter')); + $queryParameter->args = [new Arg($firstArgumentArrayItem->key), new Arg($firstArgumentArrayItem->value)]; + $arrayCollectionArrayArguments[] = new ArrayItem($queryParameter); } - $arrayCollection = new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name\FullyQualified('Doctrine\\Common\\Collections\\ArrayCollection')); - $arrayCollection->args = [new \PhpParser\Node\Arg(new \PhpParser\Node\Expr\Array_($arrayCollectionArrayArguments))]; + $arrayCollection = new New_(new FullyQualified('Doctrine\\Common\\Collections\\ArrayCollection')); + $arrayCollection->args = [new Arg(new Array_($arrayCollectionArrayArguments))]; return $arrayCollection; } } diff --git a/vendor/rector/rector-doctrine/src/Rector/MethodCall/EntityAliasToClassConstantReferenceRector.php b/vendor/rector/rector-doctrine/src/Rector/MethodCall/EntityAliasToClassConstantReferenceRector.php index d55092c7705..e4ba70c1263 100644 --- a/vendor/rector/rector-doctrine/src/Rector/MethodCall/EntityAliasToClassConstantReferenceRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/MethodCall/EntityAliasToClassConstantReferenceRector.php @@ -9,13 +9,13 @@ use PhpParser\Node\Scalar\String_; use PHPStan\Type\ObjectType; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Doctrine\Tests\Rector\MethodCall\EntityAliasToClassConstantReferenceRector\EntityAliasToClassConstantReferenceRectorTest */ -final class EntityAliasToClassConstantReferenceRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class EntityAliasToClassConstantReferenceRector extends AbstractRector implements ConfigurableRectorInterface { /** * @api @@ -32,11 +32,11 @@ final class EntityAliasToClassConstantReferenceRector extends \Rector\Core\Recto private $aliasesToNamespaces = []; public function __construct() { - $this->doctrineManagerRegistryObjectTypes = [new \PHPStan\Type\ObjectType('Doctrine\\ORM\\EntityManagerInterface'), new \PHPStan\Type\ObjectType('Doctrine\\Persistence\\ObjectManager'), new \PHPStan\Type\ObjectType('Doctrine\\Common\\Persistence\\ObjectManager'), new \PHPStan\Type\ObjectType('Doctrine\\Persistence\\ManagerRegistry'), new \PHPStan\Type\ObjectType('Doctrine\\Common\\Persistence\\ManagerRegistry')]; + $this->doctrineManagerRegistryObjectTypes = [new ObjectType('Doctrine\\ORM\\EntityManagerInterface'), new ObjectType('Doctrine\\Persistence\\ObjectManager'), new ObjectType('Doctrine\\Common\\Persistence\\ObjectManager'), new ObjectType('Doctrine\\Persistence\\ManagerRegistry'), new ObjectType('Doctrine\\Common\\Persistence\\ManagerRegistry')]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replaces doctrine alias with class.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replaces doctrine alias with class.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' $entityManager = new Doctrine\ORM\EntityManager(); $entityManager->getRepository("AppBundle:Post"); CODE_SAMPLE @@ -51,12 +51,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->nodeTypeResolver->isObjectTypes($node->var, $this->doctrineManagerRegistryObjectTypes)) { return null; @@ -67,7 +67,7 @@ CODE_SAMPLE if (!isset($node->args[0])) { return null; } - if (!$node->args[0]->value instanceof \PhpParser\Node\Scalar\String_) { + if (!$node->args[0]->value instanceof String_) { return null; } /** @var String_ $stringNode */ @@ -84,9 +84,9 @@ CODE_SAMPLE public function configure(array $configuration) : void { $aliasesToNamespaces = $configuration[self::ALIASES_TO_NAMESPACES] ?? $configuration; - \RectorPrefix20220607\Webmozart\Assert\Assert::isArray($aliasesToNamespaces); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString(\array_keys($aliasesToNamespaces)); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($aliasesToNamespaces); + Assert::isArray($aliasesToNamespaces); + Assert::allString(\array_keys($aliasesToNamespaces)); + Assert::allString($aliasesToNamespaces); $this->aliasesToNamespaces = $aliasesToNamespaces; } private function isAliasWithConfiguredEntity(string $name) : bool diff --git a/vendor/rector/rector-doctrine/src/Rector/MethodCall/ReplaceParentRepositoryCallsByRepositoryPropertyRector.php b/vendor/rector/rector-doctrine/src/Rector/MethodCall/ReplaceParentRepositoryCallsByRepositoryPropertyRector.php index b6d6d4fa819..79e7bf3a831 100644 --- a/vendor/rector/rector-doctrine/src/Rector/MethodCall/ReplaceParentRepositoryCallsByRepositoryPropertyRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/MethodCall/ReplaceParentRepositoryCallsByRepositoryPropertyRector.php @@ -14,12 +14,12 @@ use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Rector\AbstractRector; use Rector\PostRector\Collector\PropertyToAddCollector; use Rector\PostRector\ValueObject\PropertyMetadata; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Doctrine\Tests\Set\DoctrineRepositoryAsServiceSet\DoctrineRepositoryAsServiceSetTest */ -final class ReplaceParentRepositoryCallsByRepositoryPropertyRector extends \Rector\Core\Rector\AbstractRector +final class ReplaceParentRepositoryCallsByRepositoryPropertyRector extends AbstractRector { /** * @var string[] @@ -30,13 +30,13 @@ final class ReplaceParentRepositoryCallsByRepositoryPropertyRector extends \Rect * @var \Rector\PostRector\Collector\PropertyToAddCollector */ private $propertyToAddCollector; - public function __construct(\Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector) + public function __construct(PropertyToAddCollector $propertyToAddCollector) { $this->propertyToAddCollector = $propertyToAddCollector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Handles method calls in child of Doctrine EntityRepository and moves them to $this->repository property.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Handles method calls in child of Doctrine EntityRepository and moves them to $this->repository property.', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\ORM\EntityRepository; class SomeRepository extends EntityRepository @@ -65,65 +65,65 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Doctrine\\ORM\\EntityRepository'))) { + if (!$this->isObjectType($node->var, new ObjectType('Doctrine\\ORM\\EntityRepository'))) { return null; } if (!$this->isNames($node->name, self::ENTITY_REPOSITORY_PUBLIC_METHODS)) { return null; } // is it getRepository(), replace it with DI property - if ($node->var instanceof \PhpParser\Node\Expr\MethodCall && $this->isName($node->var->name, 'getRepository')) { + if ($node->var instanceof MethodCall && $this->isName($node->var->name, 'getRepository')) { return $this->refactorGetRepositoryMethodCall($node); } $node->var = $this->nodeFactory->createPropertyFetch('this', 'repository'); return $node; } - private function resolveRepositoryName(\PhpParser\Node\Expr $expr) : string + private function resolveRepositoryName(Expr $expr) : string { $entityReferenceName = $this->valueResolver->getValue($expr); if (!\is_string($entityReferenceName)) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } - $lastNamePart = (string) \RectorPrefix20220607\Nette\Utils\Strings::after($entityReferenceName, '\\', -1); + $lastNamePart = (string) Strings::after($entityReferenceName, '\\', -1); return \lcfirst($lastNamePart) . 'Repository'; } - private function guessRepositoryType(\PhpParser\Node\Expr $expr) : string + private function guessRepositoryType(Expr $expr) : string { - if ($expr instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if ($expr instanceof ClassConstFetch) { $entityClass = $this->getName($expr->class); if ($entityClass === null) { return 'Unknown_Repository_Class'; } - $entityClassNamespace = (string) \RectorPrefix20220607\Nette\Utils\Strings::before($entityClass, '\\', -2); - $lastNamePart = (string) \RectorPrefix20220607\Nette\Utils\Strings::after($entityClass, '\\', -1); + $entityClassNamespace = (string) Strings::before($entityClass, '\\', -2); + $lastNamePart = (string) Strings::after($entityClass, '\\', -1); return $entityClassNamespace . '\\Repository\\' . $lastNamePart . 'Repository'; } return 'Unknown_Repository_Class'; } - private function refactorGetRepositoryMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node\Expr\MethodCall + private function refactorGetRepositoryMethodCall(MethodCall $methodCall) : ?MethodCall { /** @var MethodCall $parentMethodCall */ $parentMethodCall = $methodCall->var; if (\count($parentMethodCall->args) === 1) { - $class = $this->betterNodeFinder->findParentType($methodCall, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($methodCall, Class_::class); + if (!$class instanceof Class_) { return null; } - if ($this->isObjectType($class, new \PHPStan\Type\ObjectType('Doctrine\\ORM\\EntityRepository'))) { + if ($this->isObjectType($class, new ObjectType('Doctrine\\ORM\\EntityRepository'))) { return null; } $firstArgValue = $parentMethodCall->args[0]->value; $repositoryPropertyName = $this->resolveRepositoryName($firstArgValue); $repositoryType = $this->guessRepositoryType($firstArgValue); - $objectType = new \PHPStan\Type\ObjectType($repositoryType); - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($repositoryPropertyName, $objectType, \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $objectType = new ObjectType($repositoryType); + $propertyMetadata = new PropertyMetadata($repositoryPropertyName, $objectType, Class_::MODIFIER_PRIVATE); $this->propertyToAddCollector->addPropertyToClass($class, $propertyMetadata); $methodCall->var = $this->nodeFactory->createPropertyFetch('this', $repositoryPropertyName); return $methodCall; diff --git a/vendor/rector/rector-doctrine/src/Rector/Property/ChangeBigIntEntityPropertyToIntTypeRector.php b/vendor/rector/rector-doctrine/src/Rector/Property/ChangeBigIntEntityPropertyToIntTypeRector.php index d137d9ae886..8fb434d2585 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Property/ChangeBigIntEntityPropertyToIntTypeRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Property/ChangeBigIntEntityPropertyToIntTypeRector.php @@ -14,27 +14,27 @@ use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockClassRenamer; use Rector\NodeTypeResolver\ValueObject\OldToNewType; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://www.doctrine-project.org/projects/doctrine-dbal/en/2.10/reference/types.html#bigint * * @see \Rector\Doctrine\Tests\Rector\Property\ChangeBigIntEntityPropertyToIntTypeRector\ChangeBigIntEntityPropertyToIntTypeRectorTest */ -final class ChangeBigIntEntityPropertyToIntTypeRector extends \Rector\Core\Rector\AbstractRector +final class ChangeBigIntEntityPropertyToIntTypeRector extends AbstractRector { /** * @readonly * @var \Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockClassRenamer */ private $docBlockClassRenamer; - public function __construct(\Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockClassRenamer $docBlockClassRenamer) + public function __construct(DocBlockClassRenamer $docBlockClassRenamer) { $this->docBlockClassRenamer = $docBlockClassRenamer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change database type "bigint" for @var/type declaration to string', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change database type "bigint" for @var/type declaration to string', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\ORM\Mapping as ORM; /** @@ -71,16 +71,16 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass('Doctrine\\ORM\\Mapping\\Column'); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return null; } $type = $doctrineAnnotationTagValueNode->getValueWithoutQuotes('type'); @@ -88,10 +88,10 @@ CODE_SAMPLE return null; } $varTagValueNode = $phpDocInfo->getVarTagValueNode(); - if (!$varTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) { + if (!$varTagValueNode instanceof VarTagValueNode) { return null; } - $oldToNewTypes = [new \Rector\NodeTypeResolver\ValueObject\OldToNewType(new \PHPStan\Type\IntegerType(), new \PHPStan\Type\StringType()), new \Rector\NodeTypeResolver\ValueObject\OldToNewType(new \PHPStan\Type\FloatType(), new \PHPStan\Type\StringType()), new \Rector\NodeTypeResolver\ValueObject\OldToNewType(new \PHPStan\Type\BooleanType(), new \PHPStan\Type\StringType())]; + $oldToNewTypes = [new OldToNewType(new IntegerType(), new StringType()), new OldToNewType(new FloatType(), new StringType()), new OldToNewType(new BooleanType(), new StringType())]; $this->docBlockClassRenamer->renamePhpDocType($phpDocInfo, $oldToNewTypes); return $node; } diff --git a/vendor/rector/rector-doctrine/src/Rector/Property/CorrectDefaultTypesOnEntityPropertyRector.php b/vendor/rector/rector-doctrine/src/Rector/Property/CorrectDefaultTypesOnEntityPropertyRector.php index 0d7d8b10075..f88896fc3e1 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Property/CorrectDefaultTypesOnEntityPropertyRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Property/CorrectDefaultTypesOnEntityPropertyRector.php @@ -14,16 +14,16 @@ use PhpParser\Node\Stmt\PropertyProperty; use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode; use Rector\Core\Exception\NotImplementedYetException; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Doctrine\Tests\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector\CorrectDefaultTypesOnEntityPropertyRectorTest */ -final class CorrectDefaultTypesOnEntityPropertyRector extends \Rector\Core\Rector\AbstractRector +final class CorrectDefaultTypesOnEntityPropertyRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change default value types to match Doctrine annotation type', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change default value types to match Doctrine annotation type', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\ORM\Mapping as ORM; /** @@ -58,21 +58,21 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass('Doctrine\\ORM\\Mapping\\Column'); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return null; } $onlyProperty = $node->props[0]; $defaultValue = $onlyProperty->default; - if (!$defaultValue instanceof \PhpParser\Node\Expr) { + if (!$defaultValue instanceof Expr) { return null; } $type = $doctrineAnnotationTagValueNode->getValueWithoutQuotes('type'); @@ -84,33 +84,33 @@ CODE_SAMPLE } return null; } - private function refactorToBoolType(\PhpParser\Node\Stmt\PropertyProperty $propertyProperty, \PhpParser\Node\Stmt\Property $property) : ?\PhpParser\Node\Stmt\Property + private function refactorToBoolType(PropertyProperty $propertyProperty, Property $property) : ?Property { if ($propertyProperty->default === null) { return null; } $defaultExpr = $propertyProperty->default; - if ($defaultExpr instanceof \PhpParser\Node\Scalar\String_) { + if ($defaultExpr instanceof String_) { $propertyProperty->default = \boolval($defaultExpr->value) ? $this->nodeFactory->createTrue() : $this->nodeFactory->createFalse(); return $property; } - if ($defaultExpr instanceof \PhpParser\Node\Expr\ConstFetch || $defaultExpr instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if ($defaultExpr instanceof ConstFetch || $defaultExpr instanceof ClassConstFetch) { // already ok return null; } - throw new \Rector\Core\Exception\NotImplementedYetException(); + throw new NotImplementedYetException(); } - private function refactorToIntType(\PhpParser\Node\Stmt\PropertyProperty $propertyProperty, \PhpParser\Node\Stmt\Property $property) : ?\PhpParser\Node\Stmt\Property + private function refactorToIntType(PropertyProperty $propertyProperty, Property $property) : ?Property { if ($propertyProperty->default === null) { return null; } $defaultExpr = $propertyProperty->default; - if ($defaultExpr instanceof \PhpParser\Node\Scalar\String_) { - $propertyProperty->default = new \PhpParser\Node\Scalar\LNumber((int) $defaultExpr->value); + if ($defaultExpr instanceof String_) { + $propertyProperty->default = new LNumber((int) $defaultExpr->value); return $property; } - if ($defaultExpr instanceof \PhpParser\Node\Scalar\LNumber) { + if ($defaultExpr instanceof LNumber) { // already correct return null; } @@ -118,6 +118,6 @@ CODE_SAMPLE if ($this->valueResolver->isNull($defaultExpr)) { return null; } - throw new \Rector\Core\Exception\NotImplementedYetException(); + throw new NotImplementedYetException(); } } diff --git a/vendor/rector/rector-doctrine/src/Rector/Property/DoctrineTargetEntityStringToClassConstantRector.php b/vendor/rector/rector-doctrine/src/Rector/Property/DoctrineTargetEntityStringToClassConstantRector.php index 3e8ea1a48b1..18bd7148dc1 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Property/DoctrineTargetEntityStringToClassConstantRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Property/DoctrineTargetEntityStringToClassConstantRector.php @@ -17,12 +17,12 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher; use Rector\Core\Rector\AbstractRector; use Rector\Doctrine\NodeAnalyzer\AttributeFinder; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Doctrine\Tests\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\DoctrineTargetEntityStringToClassConstantRectorTest */ -final class DoctrineTargetEntityStringToClassConstantRector extends \Rector\Core\Rector\AbstractRector +final class DoctrineTargetEntityStringToClassConstantRector extends AbstractRector { private const ATTRIBUTE_NAME__TARGET_ENTITY = 'targetEntity'; private const ATTRIBUTE_NAME__CLASS = 'class'; @@ -40,14 +40,14 @@ final class DoctrineTargetEntityStringToClassConstantRector extends \Rector\Core * @var \Rector\Doctrine\NodeAnalyzer\AttributeFinder */ private $attributeFinder; - public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher $classAnnotationMatcher, \Rector\Doctrine\NodeAnalyzer\AttributeFinder $attributeFinder) + public function __construct(ClassAnnotationMatcher $classAnnotationMatcher, AttributeFinder $attributeFinder) { $this->classAnnotationMatcher = $classAnnotationMatcher; $this->attributeFinder = $attributeFinder; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Convert targetEntities defined as String to ::class Constants in Doctrine Entities.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Convert targetEntities defined as String to ::class Constants in Doctrine Entities.', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { /** @@ -75,12 +75,12 @@ CODE_SAMPLE } public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $hasChanged = \false; $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); @@ -90,16 +90,16 @@ CODE_SAMPLE } return $this->changeTypeInAttributeTypes($node, $hasChanged); } - private function changeTypeInAttributeTypes(\PhpParser\Node\Stmt\Property $property, bool $hasChanged) : ?\PhpParser\Node\Stmt\Property + private function changeTypeInAttributeTypes(Property $property, bool $hasChanged) : ?Property { $attribute = $this->attributeFinder->findAttributeByClasses($property, $this->getAttributeClasses()); - if (!$attribute instanceof \PhpParser\Node\Attribute) { + if (!$attribute instanceof Attribute) { return $hasChanged ? $property : null; } $attributeName = $this->getAttributeName($attribute); foreach ($attribute->args as $arg) { $argName = $arg->name; - if (!$argName instanceof \PhpParser\Node\Identifier) { + if (!$argName instanceof Identifier) { continue; } if (!$this->isName($argName, $attributeName)) { @@ -116,15 +116,15 @@ CODE_SAMPLE } return $hasChanged ? $property : null; } - private function changeTypeInAnnotationTypes(\PhpParser\Node\Stmt\Property $property, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : ?\PhpParser\Node\Stmt\Property + private function changeTypeInAnnotationTypes(Property $property, PhpDocInfo $phpDocInfo) : ?Property { $doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClasses($this->getAttributeClasses()); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return null; } return $this->processDoctrineToMany($doctrineAnnotationTagValueNode, $property); } - private function processDoctrineToMany(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, \PhpParser\Node\Stmt\Property $property) : ?\PhpParser\Node\Stmt\Property + private function processDoctrineToMany(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, Property $property) : ?Property { $key = $doctrineAnnotationTagValueNode->hasClassName('Doctrine\\ORM\\Mapping\\Embedded') ? self::ATTRIBUTE_NAME__CLASS : self::ATTRIBUTE_NAME__TARGET_ENTITY; /** @var ?string $targetEntity */ @@ -148,7 +148,7 @@ CODE_SAMPLE { return \array_keys(self::VALID_DOCTRINE_CLASSES); } - private function getAttributeName(\PhpParser\Node\Attribute $attribute) : string + private function getAttributeName(Attribute $attribute) : string { return self::VALID_DOCTRINE_CLASSES[$attribute->name->toString()]; } diff --git a/vendor/rector/rector-doctrine/src/Rector/Property/ImproveDoctrineCollectionDocTypeInEntityRector.php b/vendor/rector/rector-doctrine/src/Rector/Property/ImproveDoctrineCollectionDocTypeInEntityRector.php index d27a5de3748..0a45bece9dd 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Property/ImproveDoctrineCollectionDocTypeInEntityRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Property/ImproveDoctrineCollectionDocTypeInEntityRector.php @@ -23,12 +23,12 @@ use Rector\Doctrine\TypeAnalyzer\CollectionTypeFactory; use Rector\Doctrine\TypeAnalyzer\CollectionTypeResolver; use Rector\Doctrine\TypeAnalyzer\CollectionVarTagValueNodeResolver; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Doctrine\Tests\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\ImproveDoctrineCollectionDocTypeInEntityRectorTest */ -final class ImproveDoctrineCollectionDocTypeInEntityRector extends \Rector\Core\Rector\AbstractRector +final class ImproveDoctrineCollectionDocTypeInEntityRector extends AbstractRector { /** * @readonly @@ -75,7 +75,7 @@ final class ImproveDoctrineCollectionDocTypeInEntityRector extends \Rector\Core\ * @var \Rector\Doctrine\NodeAnalyzer\TargetEntityResolver */ private $targetEntityResolver; - public function __construct(\Rector\Doctrine\TypeAnalyzer\CollectionTypeFactory $collectionTypeFactory, \Rector\Core\NodeManipulator\AssignManipulator $assignManipulator, \Rector\Doctrine\TypeAnalyzer\CollectionTypeResolver $collectionTypeResolver, \Rector\Doctrine\TypeAnalyzer\CollectionVarTagValueNodeResolver $collectionVarTagValueNodeResolver, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\Doctrine\PhpDocParser\DoctrineDocBlockResolver $doctrineDocBlockResolver, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\Doctrine\NodeAnalyzer\AttributeFinder $attributeFinder, \Rector\Doctrine\NodeAnalyzer\TargetEntityResolver $targetEntityResolver) + public function __construct(CollectionTypeFactory $collectionTypeFactory, AssignManipulator $assignManipulator, CollectionTypeResolver $collectionTypeResolver, CollectionVarTagValueNodeResolver $collectionVarTagValueNodeResolver, PhpDocTypeChanger $phpDocTypeChanger, DoctrineDocBlockResolver $doctrineDocBlockResolver, ReflectionResolver $reflectionResolver, AttributeFinder $attributeFinder, TargetEntityResolver $targetEntityResolver) { $this->collectionTypeFactory = $collectionTypeFactory; $this->assignManipulator = $assignManipulator; @@ -87,9 +87,9 @@ final class ImproveDoctrineCollectionDocTypeInEntityRector extends \Rector\Core\ $this->attributeFinder = $attributeFinder; $this->targetEntityResolver = $targetEntityResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Improve @var, @param and @return types for Doctrine collections to make them useful both for PHPStan and PHPStorm', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Improve @var, @param and @return types for Doctrine collections to make them useful both for PHPStan and PHPStorm', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; @@ -128,31 +128,31 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class, \PhpParser\Node\Stmt\ClassMethod::class]; + return [Property::class, ClassMethod::class]; } /** * @param Property|ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Stmt\Property) { + if ($node instanceof Property) { return $this->refactorProperty($node); } return $this->refactorClassMethod($node); } - private function refactorProperty(\PhpParser\Node\Stmt\Property $property) : ?\PhpParser\Node\Stmt\Property + private function refactorProperty(Property $property) : ?Property { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); if ($phpDocInfo->hasByAnnotationClass('Doctrine\\ORM\\Mapping\\OneToMany')) { return $this->refactorPropertyPhpDocInfo($property, $phpDocInfo); } $targetEntityExpr = $this->attributeFinder->findAttributeByClassArgByName($property, 'Doctrine\\ORM\\Mapping\\OneToMany', 'targetEntity'); - if (!$targetEntityExpr instanceof \PhpParser\Node\Expr) { + if (!$targetEntityExpr instanceof Expr) { return null; } return $this->refactorAttribute($targetEntityExpr, $phpDocInfo, $property); } - private function refactorClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Stmt\ClassMethod + private function refactorClassMethod(ClassMethod $classMethod) : ?ClassMethod { if (!$this->doctrineDocBlockResolver->isInDoctrineEntityClass($classMethod)) { return null; @@ -161,7 +161,7 @@ CODE_SAMPLE return null; } $collectionObjectType = $this->resolveCollectionSetterAssignType($classMethod); - if (!$collectionObjectType instanceof \PHPStan\Type\Type) { + if (!$collectionObjectType instanceof Type) { return null; } if (\count($classMethod->params) !== 1) { @@ -169,7 +169,7 @@ CODE_SAMPLE } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); $param = $classMethod->params[0]; - if ($param->type instanceof \PhpParser\Node) { + if ($param->type instanceof Node) { return null; } /** @var string $parameterName */ @@ -177,44 +177,44 @@ CODE_SAMPLE $this->phpDocTypeChanger->changeParamType($phpDocInfo, $collectionObjectType, $param, $parameterName); return $classMethod; } - private function resolveCollectionSetterAssignType(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PHPStan\Type\Type + private function resolveCollectionSetterAssignType(ClassMethod $classMethod) : ?Type { $propertyFetches = $this->assignManipulator->resolveAssignsToLocalPropertyFetches($classMethod); if (\count($propertyFetches) !== 1) { return null; } $phpPropertyReflection = $this->reflectionResolver->resolvePropertyReflectionFromPropertyFetch($propertyFetches[0]); - if (!$phpPropertyReflection instanceof \PHPStan\Reflection\Php\PhpPropertyReflection) { + if (!$phpPropertyReflection instanceof PhpPropertyReflection) { return null; } - $classLike = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($classMethod, ClassLike::class); + if (!$classLike instanceof ClassLike) { return null; } $propertyName = (string) $this->nodeNameResolver->getName($propertyFetches[0]); $property = $classLike->getProperty($propertyName); - if (!$property instanceof \PhpParser\Node\Stmt\Property) { + if (!$property instanceof Property) { return null; } $varTagValueNode = $this->collectionVarTagValueNodeResolver->resolve($property); - if (!$varTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) { + if (!$varTagValueNode instanceof VarTagValueNode) { return null; } return $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($varTagValueNode->type, $property); } - private function refactorPropertyPhpDocInfo(\PhpParser\Node\Stmt\Property $property, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : ?\PhpParser\Node\Stmt\Property + private function refactorPropertyPhpDocInfo(Property $property, PhpDocInfo $phpDocInfo) : ?Property { $varTagValueNode = $this->collectionVarTagValueNodeResolver->resolve($property); if ($varTagValueNode !== null) { $collectionObjectType = $this->collectionTypeResolver->resolveFromTypeNode($varTagValueNode->type, $property); - if (!$collectionObjectType instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) { + if (!$collectionObjectType instanceof FullyQualifiedObjectType) { return null; } $newVarType = $this->collectionTypeFactory->createType($collectionObjectType); $this->phpDocTypeChanger->changeVarType($phpDocInfo, $newVarType); } else { $collectionObjectType = $this->collectionTypeResolver->resolveFromOneToManyProperty($property); - if (!$collectionObjectType instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) { + if (!$collectionObjectType instanceof FullyQualifiedObjectType) { return null; } $newVarType = $this->collectionTypeFactory->createType($collectionObjectType); @@ -222,18 +222,18 @@ CODE_SAMPLE } return $property; } - private function refactorAttribute(\PhpParser\Node\Expr $expr, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\Stmt\Property $property) : ?\PhpParser\Node\Stmt\Property + private function refactorAttribute(Expr $expr, PhpDocInfo $phpDocInfo, Property $property) : ?Property { $phpDocVarTagValueNode = $phpDocInfo->getVarTagValueNode(); $phpDocCollectionVarTagValueNode = $this->collectionVarTagValueNodeResolver->resolve($property); - if ($phpDocVarTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode && !$phpDocCollectionVarTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) { + if ($phpDocVarTagValueNode instanceof VarTagValueNode && !$phpDocCollectionVarTagValueNode instanceof VarTagValueNode) { return null; } $targetEntityClassName = $this->targetEntityResolver->resolveFromExpr($expr); if ($targetEntityClassName === null) { return null; } - $fullyQualifiedObjectType = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($targetEntityClassName); + $fullyQualifiedObjectType = new FullyQualifiedObjectType($targetEntityClassName); $newVarType = $this->collectionTypeFactory->createType($fullyQualifiedObjectType); $this->phpDocTypeChanger->changeVarType($phpDocInfo, $newVarType); return $property; diff --git a/vendor/rector/rector-doctrine/src/Rector/Property/MakeEntityDateTimePropertyDateTimeInterfaceRector.php b/vendor/rector/rector-doctrine/src/Rector/Property/MakeEntityDateTimePropertyDateTimeInterfaceRector.php index d6b8dce70a2..482dbee3332 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Property/MakeEntityDateTimePropertyDateTimeInterfaceRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Property/MakeEntityDateTimePropertyDateTimeInterfaceRector.php @@ -11,27 +11,27 @@ use PHPStan\Type\UnionType; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\Core\Rector\AbstractRector; use Rector\Doctrine\NodeManipulator\PropertyTypeManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see related to maker bundle https://symfony.com/doc/current/bundles/SymfonyMakerBundle/index.html * * @see \Rector\Doctrine\Tests\Rector\Property\MakeEntityDateTimePropertyDateTimeInterfaceRector\MakeEntityDateTimePropertyDateTimeInterfaceRectorTest */ -final class MakeEntityDateTimePropertyDateTimeInterfaceRector extends \Rector\Core\Rector\AbstractRector +final class MakeEntityDateTimePropertyDateTimeInterfaceRector extends AbstractRector { /** * @readonly * @var \Rector\Doctrine\NodeManipulator\PropertyTypeManipulator */ private $propertyTypeManipulator; - public function __construct(\Rector\Doctrine\NodeManipulator\PropertyTypeManipulator $propertyTypeManipulator) + public function __construct(PropertyTypeManipulator $propertyTypeManipulator) { $this->propertyTypeManipulator = $propertyTypeManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Make maker bundle generate DateTime property accept DateTimeInterface too', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Make maker bundle generate DateTime property accept DateTimeInterface too', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\ORM\Mapping as ORM; /** @@ -76,20 +76,20 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); - if ($phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if ($phpDocInfo instanceof PhpDocInfo) { $varType = $phpDocInfo->getVarType(); - if ($varType instanceof \PHPStan\Type\UnionType) { - $varType = \PHPStan\Type\TypeCombinator::removeNull($varType); + if ($varType instanceof UnionType) { + $varType = TypeCombinator::removeNull($varType); } - if (!$varType->equals(new \PHPStan\Type\ObjectType('DateTime'))) { + if (!$varType->equals(new ObjectType('DateTime'))) { return null; } $this->propertyTypeManipulator->changePropertyType($node, 'DateTime', 'DateTimeInterface'); diff --git a/vendor/rector/rector-doctrine/src/Rector/Property/RemoveRedundantDefaultPropertyAnnotationValuesRector.php b/vendor/rector/rector-doctrine/src/Rector/Property/RemoveRedundantDefaultPropertyAnnotationValuesRector.php index fd6bec718e3..547513b46b2 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Property/RemoveRedundantDefaultPropertyAnnotationValuesRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Property/RemoveRedundantDefaultPropertyAnnotationValuesRector.php @@ -14,14 +14,14 @@ use Rector\Doctrine\NodeAnalyzer\AttributeFinder; use Rector\Doctrine\NodeManipulator\DoctrineItemDefaultValueManipulator; use Rector\Doctrine\ValueObject\ArgName; use Rector\Doctrine\ValueObject\DefaultAnnotationArgValue; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Doctrine\Tests\Rector\Property\RemoveRedundantDefaultPropertyAnnotationValuesRector\RemoveRedundantDefaultPropertyAnnotationValuesRectorTest * * @changelog https://www.doctrine-project.org/projects/doctrine-orm/en/2.8/reference/basic-mapping.html#property-mapping */ -final class RemoveRedundantDefaultPropertyAnnotationValuesRector extends \Rector\Core\Rector\AbstractRector +final class RemoveRedundantDefaultPropertyAnnotationValuesRector extends AbstractRector { /** * @var DefaultAnnotationArgValue[] @@ -42,16 +42,16 @@ final class RemoveRedundantDefaultPropertyAnnotationValuesRector extends \Rector * @var \Rector\Doctrine\NodeAnalyzer\AttributeCleaner */ private $attributeCleaner; - public function __construct(\Rector\Doctrine\NodeManipulator\DoctrineItemDefaultValueManipulator $doctrineItemDefaultValueManipulator, \Rector\Doctrine\NodeAnalyzer\AttributeFinder $attributeFinder, \Rector\Doctrine\NodeAnalyzer\AttributeCleaner $attributeCleaner) + public function __construct(DoctrineItemDefaultValueManipulator $doctrineItemDefaultValueManipulator, AttributeFinder $attributeFinder, AttributeCleaner $attributeCleaner) { $this->doctrineItemDefaultValueManipulator = $doctrineItemDefaultValueManipulator; $this->attributeFinder = $attributeFinder; $this->attributeCleaner = $attributeCleaner; - $this->defaultAnnotationArgValues = [new \Rector\Doctrine\ValueObject\DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\Column', 'nullable', \false), new \Rector\Doctrine\ValueObject\DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\Column', 'unique', \false), new \Rector\Doctrine\ValueObject\DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\Column', 'precision', 0), new \Rector\Doctrine\ValueObject\DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\Column', 'scale', 0), new \Rector\Doctrine\ValueObject\DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\GeneratedValue', 'strategy', 'AUTO'), new \Rector\Doctrine\ValueObject\DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\JoinColumn', 'unique', \false), new \Rector\Doctrine\ValueObject\DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\JoinColumn', 'nullable', \true), new \Rector\Doctrine\ValueObject\DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\JoinColumn', 'referencedColumnName', 'id'), new \Rector\Doctrine\ValueObject\DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\ManyToMany', \Rector\Doctrine\ValueObject\ArgName::ORPHAN_REMOVAL, \false), new \Rector\Doctrine\ValueObject\DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\ManyToMany', \Rector\Doctrine\ValueObject\ArgName::FETCH, \Rector\Doctrine\ValueObject\ArgName::LAZY), new \Rector\Doctrine\ValueObject\DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\ManyToOne', \Rector\Doctrine\ValueObject\ArgName::FETCH, \Rector\Doctrine\ValueObject\ArgName::LAZY), new \Rector\Doctrine\ValueObject\DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\OneToMany', \Rector\Doctrine\ValueObject\ArgName::ORPHAN_REMOVAL, \false), new \Rector\Doctrine\ValueObject\DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\OneToMany', \Rector\Doctrine\ValueObject\ArgName::FETCH, \Rector\Doctrine\ValueObject\ArgName::LAZY), new \Rector\Doctrine\ValueObject\DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\OneToOne', \Rector\Doctrine\ValueObject\ArgName::ORPHAN_REMOVAL, \false), new \Rector\Doctrine\ValueObject\DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\OneToOne', \Rector\Doctrine\ValueObject\ArgName::FETCH, \Rector\Doctrine\ValueObject\ArgName::LAZY)]; + $this->defaultAnnotationArgValues = [new DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\Column', 'nullable', \false), new DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\Column', 'unique', \false), new DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\Column', 'precision', 0), new DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\Column', 'scale', 0), new DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\GeneratedValue', 'strategy', 'AUTO'), new DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\JoinColumn', 'unique', \false), new DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\JoinColumn', 'nullable', \true), new DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\JoinColumn', 'referencedColumnName', 'id'), new DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\ManyToMany', ArgName::ORPHAN_REMOVAL, \false), new DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\ManyToMany', ArgName::FETCH, ArgName::LAZY), new DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\ManyToOne', ArgName::FETCH, ArgName::LAZY), new DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\OneToMany', ArgName::ORPHAN_REMOVAL, \false), new DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\OneToMany', ArgName::FETCH, ArgName::LAZY), new DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\OneToOne', ArgName::ORPHAN_REMOVAL, \false), new DefaultAnnotationArgValue('Doctrine\\ORM\\Mapping\\OneToOne', ArgName::FETCH, ArgName::LAZY)]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Removes redundant default values from Doctrine ORM annotations/attributes properties', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Removes redundant default values from Doctrine ORM annotations/attributes properties', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\ORM\Mapping as ORM; /** @@ -88,17 +88,17 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $this->refactorPropertyAnnotations($node); foreach ($this->defaultAnnotationArgValues as $defaultAnnotationArgValue) { $argExpr = $this->attributeFinder->findAttributeByClassArgByName($node, $defaultAnnotationArgValue->getAnnotationClass(), $defaultAnnotationArgValue->getArgName()); - if (!$argExpr instanceof \PhpParser\Node\Expr) { + if (!$argExpr instanceof Expr) { continue; } if (!$this->valueResolver->isValue($argExpr, $defaultAnnotationArgValue->getDefaultValue())) { @@ -108,10 +108,10 @@ CODE_SAMPLE } return $node; } - private function refactorPropertyAnnotations(\PhpParser\Node\Stmt\Property $property) : void + private function refactorPropertyAnnotations(Property $property) : void { $phpDocInfo = $this->phpDocInfoFactory->createFromNode($property); - if ($phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if ($phpDocInfo instanceof PhpDocInfo) { foreach ($this->defaultAnnotationArgValues as $defaultAnnotationArgValue) { $this->refactorAnnotation($phpDocInfo, $defaultAnnotationArgValue->getAnnotationClass(), $defaultAnnotationArgValue->getArgName(), $defaultAnnotationArgValue->getDefaultValue()); } @@ -121,10 +121,10 @@ CODE_SAMPLE * @param class-string $annotationClass * @param string|bool|int $defaultValue */ - private function refactorAnnotation(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, string $annotationClass, string $argName, $defaultValue) : void + private function refactorAnnotation(PhpDocInfo $phpDocInfo, string $annotationClass, string $argName, $defaultValue) : void { $doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass($annotationClass); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return; } $this->doctrineItemDefaultValueManipulator->remove($phpDocInfo, $doctrineAnnotationTagValueNode, $argName, $defaultValue); diff --git a/vendor/rector/rector-doctrine/src/Rector/Property/TypedPropertyFromColumnTypeRector.php b/vendor/rector/rector-doctrine/src/Rector/Property/TypedPropertyFromColumnTypeRector.php index 0a710662960..4b51178ba71 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Property/TypedPropertyFromColumnTypeRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Property/TypedPropertyFromColumnTypeRector.php @@ -17,12 +17,12 @@ use Rector\Doctrine\NodeManipulator\ColumnPropertyTypeResolver; use Rector\Doctrine\NodeManipulator\NullabilityColumnPropertyTypeResolver; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\TypeDeclaration\NodeTypeAnalyzer\PropertyTypeDecorator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Doctrine\Tests\Rector\Property\TypedPropertyFromColumnTypeRector\TypedPropertyFromColumnTypeRectorTest */ -final class TypedPropertyFromColumnTypeRector extends \Rector\Core\Rector\AbstractRector +final class TypedPropertyFromColumnTypeRector extends AbstractRector { /** * @readonly @@ -49,7 +49,7 @@ final class TypedPropertyFromColumnTypeRector extends \Rector\Core\Rector\Abstra * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\TypeDeclaration\NodeTypeAnalyzer\PropertyTypeDecorator $propertyTypeDecorator, \Rector\Doctrine\NodeManipulator\ColumnPropertyTypeResolver $columnPropertyTypeResolver, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\Doctrine\NodeManipulator\NullabilityColumnPropertyTypeResolver $nullabilityColumnPropertyTypeResolver, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PropertyTypeDecorator $propertyTypeDecorator, ColumnPropertyTypeResolver $columnPropertyTypeResolver, PhpDocTypeChanger $phpDocTypeChanger, NullabilityColumnPropertyTypeResolver $nullabilityColumnPropertyTypeResolver, PhpVersionProvider $phpVersionProvider) { $this->propertyTypeDecorator = $propertyTypeDecorator; $this->columnPropertyTypeResolver = $columnPropertyTypeResolver; @@ -57,9 +57,9 @@ final class TypedPropertyFromColumnTypeRector extends \Rector\Core\Rector\Abstra $this->nullabilityColumnPropertyTypeResolver = $nullabilityColumnPropertyTypeResolver; $this->phpVersionProvider = $phpVersionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Complete @var annotations or types based on @ORM\\Column', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Complete @var annotations or types based on @ORM\\Column', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\ORM\Mapping as ORM; class SimpleColumn @@ -88,33 +88,33 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node * @return \PhpParser\Node\Stmt\Property|null */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { if ($node->type !== null) { return null; } $isNullable = $this->nullabilityColumnPropertyTypeResolver->isNullable($node); $propertyType = $this->columnPropertyTypeResolver->resolve($node, $isNullable); - if (!$propertyType instanceof \PHPStan\Type\Type || $propertyType instanceof \PHPStan\Type\MixedType) { + if (!$propertyType instanceof Type || $propertyType instanceof MixedType) { return null; } // add default null if missing - if ($isNullable && !\PHPStan\Type\TypeCombinator::containsNull($propertyType)) { - $propertyType = \PHPStan\Type\TypeCombinator::addNull($propertyType); + if ($isNullable && !TypeCombinator::containsNull($propertyType)) { + $propertyType = TypeCombinator::addNull($propertyType); } - $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY); + $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, TypeKind::PROPERTY); if ($typeNode === null) { return null; } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_74)) { - if ($propertyType instanceof \PHPStan\Type\UnionType) { + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersion::PHP_74)) { + if ($propertyType instanceof UnionType) { $this->propertyTypeDecorator->decoratePropertyUnionType($propertyType, $typeNode, $node, $phpDocInfo); return $node; } diff --git a/vendor/rector/rector-doctrine/src/Rector/Property/TypedPropertyFromToManyRelationTypeRector.php b/vendor/rector/rector-doctrine/src/Rector/Property/TypedPropertyFromToManyRelationTypeRector.php index ffc1e428f79..e22fe9873dd 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Property/TypedPropertyFromToManyRelationTypeRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Property/TypedPropertyFromToManyRelationTypeRector.php @@ -15,12 +15,12 @@ use Rector\Core\ValueObject\PhpVersion; use Rector\Doctrine\NodeManipulator\ToManyRelationPropertyTypeResolver; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\TypeDeclaration\NodeTypeAnalyzer\PropertyTypeDecorator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Doctrine\Tests\Rector\Property\TypedPropertyFromToManyRelationTypeRector\TypedPropertyFromToManyRelationTypeRectorTest */ -final class TypedPropertyFromToManyRelationTypeRector extends \Rector\Core\Rector\AbstractRector +final class TypedPropertyFromToManyRelationTypeRector extends AbstractRector { /** * @readonly @@ -42,16 +42,16 @@ final class TypedPropertyFromToManyRelationTypeRector extends \Rector\Core\Recto * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\TypeDeclaration\NodeTypeAnalyzer\PropertyTypeDecorator $propertyTypeDecorator, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\Doctrine\NodeManipulator\ToManyRelationPropertyTypeResolver $toManyRelationPropertyTypeResolver, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PropertyTypeDecorator $propertyTypeDecorator, PhpDocTypeChanger $phpDocTypeChanger, ToManyRelationPropertyTypeResolver $toManyRelationPropertyTypeResolver, PhpVersionProvider $phpVersionProvider) { $this->propertyTypeDecorator = $propertyTypeDecorator; $this->phpDocTypeChanger = $phpDocTypeChanger; $this->toManyRelationPropertyTypeResolver = $toManyRelationPropertyTypeResolver; $this->phpVersionProvider = $phpVersionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Complete @var annotations or types based on @ORM\\*toMany annotations or attributes', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Complete @var annotations or types based on @ORM\\*toMany annotations or attributes', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\ORM\Mapping as ORM; class SimpleColumn @@ -81,30 +81,30 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node * @return \PhpParser\Node\Stmt\Property|null */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { if ($node->type !== null) { return null; } $propertyType = $this->toManyRelationPropertyTypeResolver->resolve($node); - if (!$propertyType instanceof \PHPStan\Type\Type || $propertyType instanceof \PHPStan\Type\MixedType) { + if (!$propertyType instanceof Type || $propertyType instanceof MixedType) { return null; } - $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY); + $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, TypeKind::PROPERTY); if ($typeNode === null) { return null; } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); // always decorate with collection generic type $this->phpDocTypeChanger->changeVarType($phpDocInfo, $propertyType); - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_74)) { - if ($propertyType instanceof \PHPStan\Type\UnionType) { + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersion::PHP_74)) { + if ($propertyType instanceof UnionType) { $this->propertyTypeDecorator->decoratePropertyUnionType($propertyType, $typeNode, $node, $phpDocInfo); return $node; } diff --git a/vendor/rector/rector-doctrine/src/Rector/Property/TypedPropertyFromToOneRelationTypeRector.php b/vendor/rector/rector-doctrine/src/Rector/Property/TypedPropertyFromToOneRelationTypeRector.php index ebed364707c..e8f7ceff385 100644 --- a/vendor/rector/rector-doctrine/src/Rector/Property/TypedPropertyFromToOneRelationTypeRector.php +++ b/vendor/rector/rector-doctrine/src/Rector/Property/TypedPropertyFromToOneRelationTypeRector.php @@ -17,12 +17,12 @@ use Rector\Core\ValueObject\PhpVersion; use Rector\Doctrine\NodeManipulator\ToOneRelationPropertyTypeResolver; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\TypeDeclaration\NodeTypeAnalyzer\PropertyTypeDecorator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Doctrine\Tests\Rector\Property\TypedPropertyFromToOneRelationTypeRector\TypedPropertyFromToOneRelationTypeRectorTest */ -final class TypedPropertyFromToOneRelationTypeRector extends \Rector\Core\Rector\AbstractRector +final class TypedPropertyFromToOneRelationTypeRector extends AbstractRector { /** * @readonly @@ -44,16 +44,16 @@ final class TypedPropertyFromToOneRelationTypeRector extends \Rector\Core\Rector * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\TypeDeclaration\NodeTypeAnalyzer\PropertyTypeDecorator $propertyTypeDecorator, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\Doctrine\NodeManipulator\ToOneRelationPropertyTypeResolver $toOneRelationPropertyTypeResolver, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PropertyTypeDecorator $propertyTypeDecorator, PhpDocTypeChanger $phpDocTypeChanger, ToOneRelationPropertyTypeResolver $toOneRelationPropertyTypeResolver, PhpVersionProvider $phpVersionProvider) { $this->propertyTypeDecorator = $propertyTypeDecorator; $this->phpDocTypeChanger = $phpDocTypeChanger; $this->toOneRelationPropertyTypeResolver = $toOneRelationPropertyTypeResolver; $this->phpVersionProvider = $phpVersionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Complete @var annotations or types based on @ORM\\*toOne annotations or attributes', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Complete @var annotations or types based on @ORM\\*toOne annotations or attributes', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\ORM\Mapping as ORM; class SimpleColumn @@ -82,25 +82,25 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node * @return \PhpParser\Node\Stmt\Property|null */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { if ($node->type !== null) { return null; } $propertyType = $this->toOneRelationPropertyTypeResolver->resolve($node); - if (!$propertyType instanceof \PHPStan\Type\Type) { + if (!$propertyType instanceof Type) { return null; } - if ($propertyType instanceof \PHPStan\Type\MixedType) { + if ($propertyType instanceof MixedType) { return null; } - $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY); + $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, TypeKind::PROPERTY); if ($typeNode === null) { return null; } @@ -110,11 +110,11 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Name|\PhpParser\Node\ComplexType $typeNode */ - private function completePropertyTypeOrVarDoc(\PHPStan\Type\Type $propertyType, $typeNode, \PhpParser\Node\Stmt\Property $property) : void + private function completePropertyTypeOrVarDoc(Type $propertyType, $typeNode, Property $property) : void { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_74)) { - if ($propertyType instanceof \PHPStan\Type\UnionType) { + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersion::PHP_74)) { + if ($propertyType instanceof UnionType) { $this->propertyTypeDecorator->decoratePropertyUnionType($propertyType, $typeNode, $property, $phpDocInfo); return; } diff --git a/vendor/rector/rector-doctrine/src/Set/DoctrineSetList.php b/vendor/rector/rector-doctrine/src/Set/DoctrineSetList.php index 1ed5a58d745..756c677d1f1 100644 --- a/vendor/rector/rector-doctrine/src/Set/DoctrineSetList.php +++ b/vendor/rector/rector-doctrine/src/Set/DoctrineSetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Doctrine\Set; use Rector\Set\Contract\SetListInterface; -final class DoctrineSetList implements \Rector\Set\Contract\SetListInterface +final class DoctrineSetList implements SetListInterface { /** * @var string diff --git a/vendor/rector/rector-doctrine/src/Type/RepositoryTypeFactory.php b/vendor/rector/rector-doctrine/src/Type/RepositoryTypeFactory.php index aac479b81d1..385d7d2b263 100644 --- a/vendor/rector/rector-doctrine/src/Type/RepositoryTypeFactory.php +++ b/vendor/rector/rector-doctrine/src/Type/RepositoryTypeFactory.php @@ -16,17 +16,17 @@ final class RepositoryTypeFactory * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } - public function createRepositoryPropertyType(\PhpParser\Node\Expr $entityReferenceExpr) : \PHPStan\Type\Generic\GenericObjectType + public function createRepositoryPropertyType(Expr $entityReferenceExpr) : GenericObjectType { - if (!$entityReferenceExpr instanceof \PhpParser\Node\Expr\ClassConstFetch) { - throw new \Rector\Core\Exception\NotImplementedYetException(); + if (!$entityReferenceExpr instanceof ClassConstFetch) { + throw new NotImplementedYetException(); } /** @var string $className */ $className = $this->nodeNameResolver->getName($entityReferenceExpr->class); - return new \PHPStan\Type\Generic\GenericObjectType('Doctrine\\ORM\\EntityRepository', [new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($className)]); + return new GenericObjectType('Doctrine\\ORM\\EntityRepository', [new FullyQualifiedObjectType($className)]); } } diff --git a/vendor/rector/rector-doctrine/src/TypeAnalyzer/CollectionTypeFactory.php b/vendor/rector/rector-doctrine/src/TypeAnalyzer/CollectionTypeFactory.php index b90f1b15883..016371bf2df 100644 --- a/vendor/rector/rector-doctrine/src/TypeAnalyzer/CollectionTypeFactory.php +++ b/vendor/rector/rector-doctrine/src/TypeAnalyzer/CollectionTypeFactory.php @@ -11,15 +11,15 @@ use PHPStan\Type\UnionType; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; final class CollectionTypeFactory { - public function createType(\Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : \PHPStan\Type\UnionType + public function createType(FullyQualifiedObjectType $fullyQualifiedObjectType) : UnionType { $genericObjectType = $this->createGenericObjectType($fullyQualifiedObjectType); - $arrayType = new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), $fullyQualifiedObjectType); - return new \PHPStan\Type\UnionType([$genericObjectType, $arrayType]); + $arrayType = new ArrayType(new MixedType(), $fullyQualifiedObjectType); + return new UnionType([$genericObjectType, $arrayType]); } - private function createGenericObjectType(\Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : \PHPStan\Type\Generic\GenericObjectType + private function createGenericObjectType(FullyQualifiedObjectType $fullyQualifiedObjectType) : GenericObjectType { - $genericTypes = [new \PHPStan\Type\IntegerType(), $fullyQualifiedObjectType]; - return new \PHPStan\Type\Generic\GenericObjectType('Doctrine\\Common\\Collections\\Collection', $genericTypes); + $genericTypes = [new IntegerType(), $fullyQualifiedObjectType]; + return new GenericObjectType('Doctrine\\Common\\Collections\\Collection', $genericTypes); } } diff --git a/vendor/rector/rector-doctrine/src/TypeAnalyzer/CollectionTypeResolver.php b/vendor/rector/rector-doctrine/src/TypeAnalyzer/CollectionTypeResolver.php index 86b71f2b32f..9a86ad91d86 100644 --- a/vendor/rector/rector-doctrine/src/TypeAnalyzer/CollectionTypeResolver.php +++ b/vendor/rector/rector-doctrine/src/TypeAnalyzer/CollectionTypeResolver.php @@ -32,15 +32,15 @@ final class CollectionTypeResolver * @var \Rector\Doctrine\PhpDoc\ShortClassExpander */ private $shortClassExpander; - public function __construct(\Rector\StaticTypeMapper\Naming\NameScopeFactory $nameScopeFactory, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Doctrine\PhpDoc\ShortClassExpander $shortClassExpander) + public function __construct(NameScopeFactory $nameScopeFactory, PhpDocInfoFactory $phpDocInfoFactory, ShortClassExpander $shortClassExpander) { $this->nameScopeFactory = $nameScopeFactory; $this->phpDocInfoFactory = $phpDocInfoFactory; $this->shortClassExpander = $shortClassExpander; } - public function resolveFromTypeNode(\PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode, \PhpParser\Node $node) : ?\Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType + public function resolveFromTypeNode(TypeNode $typeNode, Node $node) : ?FullyQualifiedObjectType { - if ($typeNode instanceof \PHPStan\PhpDocParser\Ast\Type\UnionTypeNode) { + if ($typeNode instanceof UnionTypeNode) { foreach ($typeNode->types as $unionedTypeNode) { $resolvedUnionedType = $this->resolveFromTypeNode($unionedTypeNode, $node); if ($resolvedUnionedType !== null) { @@ -48,25 +48,25 @@ final class CollectionTypeResolver } } } - if ($typeNode instanceof \PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode && $typeNode->type instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode) { + if ($typeNode instanceof ArrayTypeNode && $typeNode->type instanceof IdentifierTypeNode) { $nameScope = $this->nameScopeFactory->createNameScopeFromNode($node); $fullyQualifiedName = $nameScope->resolveStringName($typeNode->type->name); - return new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($fullyQualifiedName); + return new FullyQualifiedObjectType($fullyQualifiedName); } return null; } - public function resolveFromOneToManyProperty(\PhpParser\Node\Stmt\Property $property) : ?\Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType + public function resolveFromOneToManyProperty(Property $property) : ?FullyQualifiedObjectType { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); $doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass('Doctrine\\ORM\\Mapping\\OneToMany'); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return null; } $targetEntity = $doctrineAnnotationTagValueNode->getValueWithoutQuotes('targetEntity'); if (!\is_string($targetEntity)) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $fullyQualifiedTargetEntity = $this->shortClassExpander->resolveFqnTargetEntity($targetEntity, $property); - return new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($fullyQualifiedTargetEntity); + return new FullyQualifiedObjectType($fullyQualifiedTargetEntity); } } diff --git a/vendor/rector/rector-doctrine/src/TypeAnalyzer/CollectionVarTagValueNodeResolver.php b/vendor/rector/rector-doctrine/src/TypeAnalyzer/CollectionVarTagValueNodeResolver.php index 30b6b9b8f39..ce2c7357933 100644 --- a/vendor/rector/rector-doctrine/src/TypeAnalyzer/CollectionVarTagValueNodeResolver.php +++ b/vendor/rector/rector-doctrine/src/TypeAnalyzer/CollectionVarTagValueNodeResolver.php @@ -13,11 +13,11 @@ final class CollectionVarTagValueNodeResolver * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory */ private $phpDocInfoFactory; - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory) { $this->phpDocInfoFactory = $phpDocInfoFactory; } - public function resolve(\PhpParser\Node\Stmt\Property $property) : ?\PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode + public function resolve(Property $property) : ?VarTagValueNode { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); if (!$phpDocInfo->hasByAnnotationClass('Doctrine\\ORM\\Mapping\\OneToMany')) { diff --git a/vendor/rector/rector-doctrine/src/TypeAnalyzer/TypeFinder.php b/vendor/rector/rector-doctrine/src/TypeAnalyzer/TypeFinder.php index c04eda73d75..55fcb79377b 100644 --- a/vendor/rector/rector-doctrine/src/TypeAnalyzer/TypeFinder.php +++ b/vendor/rector/rector-doctrine/src/TypeAnalyzer/TypeFinder.php @@ -14,34 +14,34 @@ final class TypeFinder * @template TType as Type * @param class-string $desiredTypeClass */ - public function find(\PHPStan\Type\Type $type, string $desiredTypeClass) : \PHPStan\Type\Type + public function find(Type $type, string $desiredTypeClass) : Type { if (\is_a($type, $desiredTypeClass, \true)) { return $type; } - if ($type instanceof \PHPStan\Type\ArrayType && \is_a($type->getItemType(), $desiredTypeClass, \true)) { + if ($type instanceof ArrayType && \is_a($type->getItemType(), $desiredTypeClass, \true)) { return $type->getItemType(); } - if ($type instanceof \PHPStan\Type\UnionType) { + if ($type instanceof UnionType) { return $this->findInJoinedType($type, $desiredTypeClass); } - if ($type instanceof \PHPStan\Type\IntersectionType) { + if ($type instanceof IntersectionType) { return $this->findInJoinedType($type, $desiredTypeClass); } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } /** * @param class-string $desiredTypeClass * @param \PHPStan\Type\UnionType|\PHPStan\Type\IntersectionType $compoundType */ - private function findInJoinedType($compoundType, string $desiredTypeClass) : \PHPStan\Type\Type + private function findInJoinedType($compoundType, string $desiredTypeClass) : Type { foreach ($compoundType->getTypes() as $joinedType) { $foundType = $this->find($joinedType, $desiredTypeClass); - if (!$foundType instanceof \PHPStan\Type\MixedType) { + if (!$foundType instanceof MixedType) { return $foundType; } } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } } diff --git a/vendor/rector/rector-doctrine/src/ValueObject/AssignToPropertyFetch.php b/vendor/rector/rector-doctrine/src/ValueObject/AssignToPropertyFetch.php index 380f53eff00..8973ee3fcf5 100644 --- a/vendor/rector/rector-doctrine/src/ValueObject/AssignToPropertyFetch.php +++ b/vendor/rector/rector-doctrine/src/ValueObject/AssignToPropertyFetch.php @@ -22,17 +22,17 @@ final class AssignToPropertyFetch * @var string */ private $propertyName; - public function __construct(\PhpParser\Node\Expr\Assign $assign, \PhpParser\Node\Expr\PropertyFetch $propertyFetch, string $propertyName) + public function __construct(Assign $assign, PropertyFetch $propertyFetch, string $propertyName) { $this->assign = $assign; $this->propertyFetch = $propertyFetch; $this->propertyName = $propertyName; } - public function getAssign() : \PhpParser\Node\Expr\Assign + public function getAssign() : Assign { return $this->assign; } - public function getPropertyFetch() : \PhpParser\Node\Expr\PropertyFetch + public function getPropertyFetch() : PropertyFetch { return $this->propertyFetch; } diff --git a/vendor/rector/rector-doctrine/src/ValueObject/PropertyNameAndPhpDocInfo.php b/vendor/rector/rector-doctrine/src/ValueObject/PropertyNameAndPhpDocInfo.php index de89c0c1e5c..e0c0eaeb74f 100644 --- a/vendor/rector/rector-doctrine/src/ValueObject/PropertyNameAndPhpDocInfo.php +++ b/vendor/rector/rector-doctrine/src/ValueObject/PropertyNameAndPhpDocInfo.php @@ -16,7 +16,7 @@ final class PropertyNameAndPhpDocInfo * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo */ private $phpDocInfo; - public function __construct(string $propertyName, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) + public function __construct(string $propertyName, PhpDocInfo $phpDocInfo) { $this->propertyName = $propertyName; $this->phpDocInfo = $phpDocInfo; @@ -25,7 +25,7 @@ final class PropertyNameAndPhpDocInfo { return $this->propertyName; } - public function getPhpDocInfo() : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo + public function getPhpDocInfo() : PhpDocInfo { return $this->phpDocInfo; } diff --git a/vendor/rector/rector-generator/config/config.php b/vendor/rector/rector-generator/config/config.php index 68ea8943818..04675ae73ec 100644 --- a/vendor/rector/rector-generator/config/config.php +++ b/vendor/rector/rector-generator/config/config.php @@ -7,7 +7,7 @@ use PhpParser\Parser; use PhpParser\ParserFactory; use PhpParser\PrettyPrinter\Standard; use RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use function RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service; use RectorPrefix20220607\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory; use RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor; @@ -16,23 +16,23 @@ use RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemGuard; use RectorPrefix20220607\Symplify\SmartFileSystem\Finder\FinderSanitizer; use RectorPrefix20220607\Symplify\SmartFileSystem\Json\JsonFileSystem; use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem; -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +return static function (ContainerConfigurator $containerConfigurator) : void { $services = $containerConfigurator->services(); $services->defaults()->public()->autowire()->autoconfigure(); $services->load('Rector\\RectorGenerator\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/ValueObject', __DIR__ . '/../src/Enum']); // console - $services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory::class); - $services->set(\RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\RectorPrefix20220607\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory::class), 'create']); + $services->set(SymfonyStyleFactory::class); + $services->set(SymfonyStyle::class)->factory([service(SymfonyStyleFactory::class), 'create']); // filesystem - $services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\Json\JsonFileSystem::class); - $services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem::class); - $services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\Finder\FinderSanitizer::class); - $services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemGuard::class); + $services->set(JsonFileSystem::class); + $services->set(SmartFileSystem::class); + $services->set(FinderSanitizer::class); + $services->set(FileSystemGuard::class); // privates - $services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller::class); - $services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor::class); + $services->set(PrivatesCaller::class); + $services->set(PrivatesAccessor::class); // php-parser - $services->set(\PhpParser\PrettyPrinter\Standard::class)->arg('$options', ['shortArraySyntax' => \true]); - $services->set(\PhpParser\ParserFactory::class); - $services->set(\PhpParser\Parser::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\PhpParser\ParserFactory::class), 'create'])->arg('$kind', \PhpParser\ParserFactory::PREFER_PHP7); + $services->set(Standard::class)->arg('$options', ['shortArraySyntax' => \true]); + $services->set(ParserFactory::class); + $services->set(Parser::class)->factory([service(ParserFactory::class), 'create'])->arg('$kind', ParserFactory::PREFER_PHP7); }; diff --git a/vendor/rector/rector-generator/monorepo-builder.php b/vendor/rector/rector-generator/monorepo-builder.php index add4c2a823d..e88fd1336d6 100644 --- a/vendor/rector/rector-generator/monorepo-builder.php +++ b/vendor/rector/rector-generator/monorepo-builder.php @@ -3,13 +3,13 @@ declare (strict_types=1); namespace RectorPrefix20220607; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\PushTagReleaseWorker; use RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\TagVersionReleaseWorker; -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +return static function (ContainerConfigurator $containerConfigurator) : void { $services = $containerConfigurator->services(); $services->defaults()->autowire(); // @see https://github.com/symplify/monorepo-builder#6-release-flow - $services->set(\RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\TagVersionReleaseWorker::class); - $services->set(\RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\PushTagReleaseWorker::class); + $services->set(TagVersionReleaseWorker::class); + $services->set(PushTagReleaseWorker::class); }; diff --git a/vendor/rector/rector-generator/src/Command/GenerateCommand.php b/vendor/rector/rector-generator/src/Command/GenerateCommand.php index c5ef4d2b30d..1abcbdc5ce7 100644 --- a/vendor/rector/rector-generator/src/Command/GenerateCommand.php +++ b/vendor/rector/rector-generator/src/Command/GenerateCommand.php @@ -13,11 +13,11 @@ use RectorPrefix20220607\Symfony\Component\Console\Command\Command; use RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface; use RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; use RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; /** * @see \Rector\RectorGenerator\Tests\RectorGenerator\GenerateCommandInteractiveModeTest */ -final class GenerateCommand extends \RectorPrefix20220607\Symfony\Component\Console\Command\Command +final class GenerateCommand extends Command { /** * @readonly @@ -44,7 +44,7 @@ final class GenerateCommand extends \RectorPrefix20220607\Symfony\Component\Cons * @var \Rector\RectorGenerator\Generator\RectorGenerator */ private $rectorGenerator; - public function __construct(\Rector\RectorGenerator\FileSystem\ConfigFilesystem $configFilesystem, \RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle, \Rector\RectorGenerator\TemplateVariablesFactory $templateVariablesFactory, \Rector\RectorGenerator\Provider\RectorRecipeProvider $rectorRecipeProvider, \Rector\RectorGenerator\Generator\RectorGenerator $rectorGenerator) + public function __construct(ConfigFilesystem $configFilesystem, SymfonyStyle $symfonyStyle, TemplateVariablesFactory $templateVariablesFactory, RectorRecipeProvider $rectorRecipeProvider, RectorGenerator $rectorGenerator) { $this->configFilesystem = $configFilesystem; $this->symfonyStyle = $symfonyStyle; @@ -58,7 +58,7 @@ final class GenerateCommand extends \RectorPrefix20220607\Symfony\Component\Cons $this->setName('generate'); $this->setDescription('[DEV] Create a new Rector, in a proper location, with new tests'); } - protected function execute(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : int + protected function execute(InputInterface $input, OutputInterface $output) : int { $rectorRecipe = $this->rectorRecipeProvider->provide(); $targetDirectory = \getcwd(); @@ -70,7 +70,7 @@ final class GenerateCommand extends \RectorPrefix20220607\Symfony\Component\Cons $setFilePath = $rectorRecipe->getSetFilePath(); if ($setFilePath !== null) { $templateVariables = $this->templateVariablesFactory->createFromRectorRecipe($rectorRecipe); - $this->configFilesystem->appendRectorServiceToSet($setFilePath, $templateVariables, \Rector\RectorGenerator\ValueObject\NamePattern::RECTOR_FQN_NAME_PATTERN); + $this->configFilesystem->appendRectorServiceToSet($setFilePath, $templateVariables, NamePattern::RECTOR_FQN_NAME_PATTERN); } $testCaseDirectoryPath = $this->resolveTestCaseDirectoryPath($generatedFilePaths); $this->printSuccess($rectorRecipe->getName(), $generatedFilePaths, $testCaseDirectoryPath); @@ -85,10 +85,10 @@ final class GenerateCommand extends \RectorPrefix20220607\Symfony\Component\Cons if (!$this->isGeneratedFilePathTestCase($generatedFilePath)) { continue; } - $generatedFileInfo = new \Symplify\SmartFileSystem\SmartFileInfo($generatedFilePath); + $generatedFileInfo = new SmartFileInfo($generatedFilePath); return \dirname($generatedFileInfo->getRelativeFilePathFromCwd()); } - throw new \Rector\RectorGenerator\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } /** * @param string[] $generatedFilePaths @@ -99,7 +99,7 @@ final class GenerateCommand extends \RectorPrefix20220607\Symfony\Component\Cons $this->symfonyStyle->title($message); \sort($generatedFilePaths); foreach ($generatedFilePaths as $generatedFilePath) { - $fileInfo = new \Symplify\SmartFileSystem\SmartFileInfo($generatedFilePath); + $fileInfo = new SmartFileInfo($generatedFilePath); $relativeFilePath = $fileInfo->getRelativeFilePathFromCwd(); $this->symfonyStyle->writeln(' * ' . $relativeFilePath); } diff --git a/vendor/rector/rector-generator/src/Command/InitRecipeCommand.php b/vendor/rector/rector-generator/src/Command/InitRecipeCommand.php index 90fa34b9dba..3fb725b5400 100644 --- a/vendor/rector/rector-generator/src/Command/InitRecipeCommand.php +++ b/vendor/rector/rector-generator/src/Command/InitRecipeCommand.php @@ -7,14 +7,14 @@ use Rector\RectorGenerator\TemplateInitializer; use RectorPrefix20220607\Symfony\Component\Console\Command\Command; use RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface; use RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; -final class InitRecipeCommand extends \RectorPrefix20220607\Symfony\Component\Console\Command\Command +final class InitRecipeCommand extends Command { /** * @readonly * @var \Rector\RectorGenerator\TemplateInitializer */ private $templateInitializer; - public function __construct(\Rector\RectorGenerator\TemplateInitializer $templateInitializer) + public function __construct(TemplateInitializer $templateInitializer) { $this->templateInitializer = $templateInitializer; parent::__construct(); @@ -24,7 +24,7 @@ final class InitRecipeCommand extends \RectorPrefix20220607\Symfony\Component\Co $this->setName('init-recipe'); $this->setDescription('[DEV] Initialize "rector-recipe.php" config'); } - protected function execute(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : int + protected function execute(InputInterface $input, OutputInterface $output) : int { $this->templateInitializer->initialize(__DIR__ . '/../../templates/rector-recipe.php', 'rector-recipe.php'); return self::SUCCESS; diff --git a/vendor/rector/rector-generator/src/Exception/ConfigurationException.php b/vendor/rector/rector-generator/src/Exception/ConfigurationException.php index ab5c1115975..556cf2349e1 100644 --- a/vendor/rector/rector-generator/src/Exception/ConfigurationException.php +++ b/vendor/rector/rector-generator/src/Exception/ConfigurationException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace Rector\RectorGenerator\Exception; use Exception; -final class ConfigurationException extends \Exception +final class ConfigurationException extends Exception { } diff --git a/vendor/rector/rector-generator/src/Exception/ShouldNotHappenException.php b/vendor/rector/rector-generator/src/Exception/ShouldNotHappenException.php index 063f5302400..acb1862a15c 100644 --- a/vendor/rector/rector-generator/src/Exception/ShouldNotHappenException.php +++ b/vendor/rector/rector-generator/src/Exception/ShouldNotHappenException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace Rector\RectorGenerator\Exception; use Exception; -final class ShouldNotHappenException extends \Exception +final class ShouldNotHappenException extends Exception { } diff --git a/vendor/rector/rector-generator/src/FileSystem/ConfigFilesystem.php b/vendor/rector/rector-generator/src/FileSystem/ConfigFilesystem.php index b4e98ca4b39..a8ce2a25d7b 100644 --- a/vendor/rector/rector-generator/src/FileSystem/ConfigFilesystem.php +++ b/vendor/rector/rector-generator/src/FileSystem/ConfigFilesystem.php @@ -27,7 +27,7 @@ final class ConfigFilesystem * @var \Rector\RectorGenerator\TemplateFactory */ private $templateFactory; - public function __construct(\RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \Rector\RectorGenerator\TemplateFactory $templateFactory) + public function __construct(SmartFileSystem $smartFileSystem, TemplateFactory $templateFactory) { $this->smartFileSystem = $smartFileSystem; $this->templateFactory = $templateFactory; @@ -45,7 +45,7 @@ final class ConfigFilesystem return; } $registerServiceLine = \sprintf(';' . \PHP_EOL . ' $rectorConfig->rule(\\%s::class);' . \PHP_EOL . '};', $servicesFullyQualifiedName); - $setFileContents = \RectorPrefix20220607\Nette\Utils\Strings::replace($setFileContents, self::LAST_ITEM_REGEX, $registerServiceLine); + $setFileContents = Strings::replace($setFileContents, self::LAST_ITEM_REGEX, $registerServiceLine); // 3. print the content back to file $this->smartFileSystem->dumpFile($setFilePath, $setFileContents); } @@ -59,6 +59,6 @@ final class ConfigFilesystem return; } $message = \sprintf('Template variables for "%s" keys are missing', \implode('", "', $missingKeys)); - throw new \Rector\RectorGenerator\Exception\ShouldNotHappenException($message); + throw new ShouldNotHappenException($message); } } diff --git a/vendor/rector/rector-generator/src/FileSystem/TemplateFileSystem.php b/vendor/rector/rector-generator/src/FileSystem/TemplateFileSystem.php index d3abd680c3c..6d22386800b 100644 --- a/vendor/rector/rector-generator/src/FileSystem/TemplateFileSystem.php +++ b/vendor/rector/rector-generator/src/FileSystem/TemplateFileSystem.php @@ -8,7 +8,7 @@ use Rector\RectorGenerator\Enum\Packages; use Rector\RectorGenerator\Finder\TemplateFinder; use Rector\RectorGenerator\TemplateFactory; use Rector\RectorGenerator\ValueObject\RectorRecipe; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class TemplateFileSystem { /** @@ -36,29 +36,29 @@ final class TemplateFileSystem * @var \Rector\RectorGenerator\TemplateFactory */ private $templateFactory; - public function __construct(\Rector\RectorGenerator\TemplateFactory $templateFactory) + public function __construct(TemplateFactory $templateFactory) { $this->templateFactory = $templateFactory; } /** * @param array $templateVariables */ - public function resolveDestination(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo, array $templateVariables, \Rector\RectorGenerator\ValueObject\RectorRecipe $rectorRecipe, string $targetDirectory) : string + public function resolveDestination(SmartFileInfo $smartFileInfo, array $templateVariables, RectorRecipe $rectorRecipe, string $targetDirectory) : string { - $destination = $smartFileInfo->getRelativeFilePathFromDirectory(\Rector\RectorGenerator\Finder\TemplateFinder::TEMPLATES_DIRECTORY); + $destination = $smartFileInfo->getRelativeFilePathFromDirectory(TemplateFinder::TEMPLATES_DIRECTORY); $destination = $this->changeRootPathForRootPackage($rectorRecipe, $destination); // normalize core package if (!$rectorRecipe->isRectorRepository()) { // special keyword for 3rd party Rectors, not for core Github contribution - $destination = \RectorPrefix20220607\Nette\Utils\Strings::replace($destination, self::PACKAGE_RULES_PATH_REGEX, 'utils/rector/src'); - $destination = \RectorPrefix20220607\Nette\Utils\Strings::replace($destination, self::PACKAGE_RULES_TESTS_PATH_REGEX, 'utils/rector/tests'); + $destination = Strings::replace($destination, self::PACKAGE_RULES_PATH_REGEX, 'utils/rector/src'); + $destination = Strings::replace($destination, self::PACKAGE_RULES_TESTS_PATH_REGEX, 'utils/rector/tests'); } // remove _Configured|_Extra prefix $destination = $this->templateFactory->create($destination, $templateVariables); - $destination = \RectorPrefix20220607\Nette\Utils\Strings::replace($destination, self::CONFIGURED_OR_EXTRA_REGEX, ''); + $destination = Strings::replace($destination, self::CONFIGURED_OR_EXTRA_REGEX, ''); // remove ".inc" protection from PHPUnit if not a test case if ($this->isNonFixtureFileWithIncSuffix($destination)) { - $destination = \RectorPrefix20220607\Nette\Utils\Strings::before($destination, '.inc'); + $destination = Strings::before($destination, '.inc'); } // special hack for tests, so PHPUnit doesn't load the generated file as a test case /** @var string $destination */ @@ -69,15 +69,15 @@ final class TemplateFileSystem } private function isNonFixtureFileWithIncSuffix(string $filePath) : bool { - if (\RectorPrefix20220607\Nette\Utils\Strings::match($filePath, self::FIXTURE_SHORT_REGEX) !== null) { + if (Strings::match($filePath, self::FIXTURE_SHORT_REGEX) !== null) { return \false; } return \substr_compare($filePath, '.inc', -\strlen('.inc')) === 0; } - private function changeRootPathForRootPackage(\Rector\RectorGenerator\ValueObject\RectorRecipe $rectorRecipe, string $destination) : string + private function changeRootPathForRootPackage(RectorRecipe $rectorRecipe, string $destination) : string { // rector split package? path are in the root directory - if (!\in_array($rectorRecipe->getPackage(), \Rector\RectorGenerator\Enum\Packages::RECTOR_CORE, \true)) { + if (!\in_array($rectorRecipe->getPackage(), Packages::RECTOR_CORE, \true)) { return $destination; } $destination = \str_replace('rules/__Package__', 'src', $destination); diff --git a/vendor/rector/rector-generator/src/Finder/TemplateFinder.php b/vendor/rector/rector-generator/src/Finder/TemplateFinder.php index f45ee9aaee1..800e503d205 100644 --- a/vendor/rector/rector-generator/src/Finder/TemplateFinder.php +++ b/vendor/rector/rector-generator/src/Finder/TemplateFinder.php @@ -6,7 +6,7 @@ namespace Rector\RectorGenerator\Finder; use Rector\RectorGenerator\ValueObject\RectorRecipe; use RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemGuard; use RectorPrefix20220607\Symplify\SmartFileSystem\Finder\FinderSanitizer; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class TemplateFinder { /** @@ -23,7 +23,7 @@ final class TemplateFinder * @var \Symplify\SmartFileSystem\FileSystemGuard */ private $fileSystemGuard; - public function __construct(\RectorPrefix20220607\Symplify\SmartFileSystem\Finder\FinderSanitizer $finderSanitizer, \RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemGuard $fileSystemGuard) + public function __construct(FinderSanitizer $finderSanitizer, FileSystemGuard $fileSystemGuard) { $this->finderSanitizer = $finderSanitizer; $this->fileSystemGuard = $fileSystemGuard; @@ -31,7 +31,7 @@ final class TemplateFinder /** * @return SmartFileInfo[] */ - public function find(\Rector\RectorGenerator\ValueObject\RectorRecipe $rectorRecipe) : array + public function find(RectorRecipe $rectorRecipe) : array { $filePaths = []; $filePaths = $this->addRuleAndTestCase($rectorRecipe, $filePaths); @@ -45,7 +45,7 @@ final class TemplateFinder * * @note the ".inc" suffix is needed, so PHPUnit doens't load it as a test case */ - private function addRuleAndTestCase(\Rector\RectorGenerator\ValueObject\RectorRecipe $rectorRecipe, array $filePaths) : array + private function addRuleAndTestCase(RectorRecipe $rectorRecipe, array $filePaths) : array { if ($rectorRecipe->getConfiguration() !== []) { $filePaths[] = __DIR__ . '/../../templates/rules-tests/__Package__/Rector/__Category__/__Name__/config/__Configuredconfigured_rule.php'; diff --git a/vendor/rector/rector-generator/src/Generator/FileGenerator.php b/vendor/rector/rector-generator/src/Generator/FileGenerator.php index df826a69dbd..98efcdfd134 100644 --- a/vendor/rector/rector-generator/src/Generator/FileGenerator.php +++ b/vendor/rector/rector-generator/src/Generator/FileGenerator.php @@ -8,7 +8,7 @@ use Rector\RectorGenerator\Enum\Packages; use Rector\RectorGenerator\FileSystem\TemplateFileSystem; use Rector\RectorGenerator\TemplateFactory; use Rector\RectorGenerator\ValueObject\RectorRecipe; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem; final class FileGenerator { @@ -37,7 +37,7 @@ final class FileGenerator * @var \Rector\RectorGenerator\FileSystem\TemplateFileSystem */ private $templateFileSystem; - public function __construct(\RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \Rector\RectorGenerator\TemplateFactory $templateFactory, \Rector\RectorGenerator\FileSystem\TemplateFileSystem $templateFileSystem) + public function __construct(SmartFileSystem $smartFileSystem, TemplateFactory $templateFactory, TemplateFileSystem $templateFileSystem) { $this->smartFileSystem = $smartFileSystem; $this->templateFactory = $templateFactory; @@ -48,7 +48,7 @@ final class FileGenerator * @param array $templateVariables * @return string[] */ - public function generateFiles(array $templateFileInfos, array $templateVariables, \Rector\RectorGenerator\ValueObject\RectorRecipe $rectorRecipe, string $destinationDirectory) : array + public function generateFiles(array $templateFileInfos, array $templateVariables, RectorRecipe $rectorRecipe, string $destinationDirectory) : array { $generatedFilePaths = []; foreach ($templateFileInfos as $templateFileInfo) { @@ -59,18 +59,18 @@ final class FileGenerator /** * @param array $templateVariables */ - private function generateFileInfoWithTemplateVariables(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo, array $templateVariables, \Rector\RectorGenerator\ValueObject\RectorRecipe $rectorRecipe, string $targetDirectory) : string + private function generateFileInfoWithTemplateVariables(SmartFileInfo $smartFileInfo, array $templateVariables, RectorRecipe $rectorRecipe, string $targetDirectory) : string { $targetFilePath = $this->templateFileSystem->resolveDestination($smartFileInfo, $templateVariables, $rectorRecipe, $targetDirectory); $content = $this->templateFactory->create($smartFileInfo->getContents(), $templateVariables); // replace "Rector\Utils\" with "Utils\Rector\" for 3rd party packages if (!$rectorRecipe->isRectorRepository()) { - $content = \RectorPrefix20220607\Nette\Utils\Strings::replace($content, self::RECTOR_UTILS_REGEX, 'Utils\\Rector'); - $content = \RectorPrefix20220607\Nette\Utils\Strings::replace($content, self::RECTOR_UTILS_TESTS_REGEX, 'Utils\\Rector\\Tests'); + $content = Strings::replace($content, self::RECTOR_UTILS_REGEX, 'Utils\\Rector'); + $content = Strings::replace($content, self::RECTOR_UTILS_TESTS_REGEX, 'Utils\\Rector\\Tests'); } // correct tests PSR-4 namespace for core rector packages - if (\in_array($rectorRecipe->getPackage(), \Rector\RectorGenerator\Enum\Packages::RECTOR_CORE, \true)) { - $content = \RectorPrefix20220607\Nette\Utils\Strings::replace($content, '#namespace Rector\\\\Tests\\\\' . $rectorRecipe->getPackage() . '#', 'namespace Rector\\' . $rectorRecipe->getPackage() . '\\Tests'); + if (\in_array($rectorRecipe->getPackage(), Packages::RECTOR_CORE, \true)) { + $content = Strings::replace($content, '#namespace Rector\\\\Tests\\\\' . $rectorRecipe->getPackage() . '#', 'namespace Rector\\' . $rectorRecipe->getPackage() . '\\Tests'); // add core package main config if (\substr_compare($targetFilePath, 'configured_rule.php', -\strlen('configured_rule.php')) === 0) { $rectorConfigLine = 'return static function (RectorConfig $rectorConfig): void {'; diff --git a/vendor/rector/rector-generator/src/Generator/RectorGenerator.php b/vendor/rector/rector-generator/src/Generator/RectorGenerator.php index ffa37ea216f..fe9df404053 100644 --- a/vendor/rector/rector-generator/src/Generator/RectorGenerator.php +++ b/vendor/rector/rector-generator/src/Generator/RectorGenerator.php @@ -38,7 +38,7 @@ final class RectorGenerator * @var \Symfony\Component\Console\Style\SymfonyStyle */ private $symfonyStyle; - public function __construct(\Rector\RectorGenerator\Finder\TemplateFinder $templateFinder, \Rector\RectorGenerator\TemplateVariablesFactory $templateVariablesFactory, \Rector\RectorGenerator\Generator\FileGenerator $fileGenerator, \Rector\RectorGenerator\Guard\OverrideGuard $overrideGuard, \RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle) + public function __construct(TemplateFinder $templateFinder, TemplateVariablesFactory $templateVariablesFactory, \Rector\RectorGenerator\Generator\FileGenerator $fileGenerator, OverrideGuard $overrideGuard, SymfonyStyle $symfonyStyle) { $this->templateFinder = $templateFinder; $this->templateVariablesFactory = $templateVariablesFactory; @@ -49,7 +49,7 @@ final class RectorGenerator /** * @return string[] */ - public function generate(\Rector\RectorGenerator\ValueObject\RectorRecipe $rectorRecipe, string $destinationDirectory) : array + public function generate(RectorRecipe $rectorRecipe, string $destinationDirectory) : array { // generate and compare $templateFileInfos = $this->templateFinder->find($rectorRecipe); diff --git a/vendor/rector/rector-generator/src/Guard/OverrideGuard.php b/vendor/rector/rector-generator/src/Guard/OverrideGuard.php index 2ac0cd2105d..783c5e64532 100644 --- a/vendor/rector/rector-generator/src/Guard/OverrideGuard.php +++ b/vendor/rector/rector-generator/src/Guard/OverrideGuard.php @@ -6,7 +6,7 @@ namespace Rector\RectorGenerator\Guard; use Rector\RectorGenerator\FileSystem\TemplateFileSystem; use Rector\RectorGenerator\ValueObject\RectorRecipe; use RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class OverrideGuard { /** @@ -19,7 +19,7 @@ final class OverrideGuard * @var \Rector\RectorGenerator\FileSystem\TemplateFileSystem */ private $templateFileSystem; - public function __construct(\RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle, \Rector\RectorGenerator\FileSystem\TemplateFileSystem $templateFileSystem) + public function __construct(SymfonyStyle $symfonyStyle, TemplateFileSystem $templateFileSystem) { $this->symfonyStyle = $symfonyStyle; $this->templateFileSystem = $templateFileSystem; @@ -28,7 +28,7 @@ final class OverrideGuard * @param array $templateVariables * @param SmartFileInfo[] $templateFileInfos */ - public function isUnwantedOverride(array $templateFileInfos, array $templateVariables, \Rector\RectorGenerator\ValueObject\RectorRecipe $rectorRecipe, string $targetDirectory) : bool + public function isUnwantedOverride(array $templateFileInfos, array $templateVariables, RectorRecipe $rectorRecipe, string $targetDirectory) : bool { $message = \sprintf('Files for "%s" rule already exist. Should we override them?', $rectorRecipe->getName()); foreach ($templateFileInfos as $templateFileInfo) { @@ -42,7 +42,7 @@ final class OverrideGuard /** * @param array $templateVariables */ - private function doesFileInfoAlreadyExist(array $templateVariables, \Rector\RectorGenerator\ValueObject\RectorRecipe $rectorRecipe, \Symplify\SmartFileSystem\SmartFileInfo $templateFileInfo, string $targetDirectory) : bool + private function doesFileInfoAlreadyExist(array $templateVariables, RectorRecipe $rectorRecipe, SmartFileInfo $templateFileInfo, string $targetDirectory) : bool { $destination = $this->templateFileSystem->resolveDestination($templateFileInfo, $templateVariables, $rectorRecipe, $targetDirectory); return \file_exists($destination); diff --git a/vendor/rector/rector-generator/src/NodeFactory/ConfigurationNodeFactory.php b/vendor/rector/rector-generator/src/NodeFactory/ConfigurationNodeFactory.php index 5c59e99fb64..1adfd708372 100644 --- a/vendor/rector/rector-generator/src/NodeFactory/ConfigurationNodeFactory.php +++ b/vendor/rector/rector-generator/src/NodeFactory/ConfigurationNodeFactory.php @@ -25,7 +25,7 @@ final class ConfigurationNodeFactory $properties = []; foreach (\array_keys($ruleConfiguration) as $privatePropertyName) { $property = $this->nodeFactory->createPrivateArrayProperty($privatePropertyName); - $property->props[0]->default = new \PhpParser\Node\Expr\Array_([]); + $property->props[0]->default = new Array_([]); $properties[] = $property; } return $properties; diff --git a/vendor/rector/rector-generator/src/NodeFactory/ConfigureClassMethodFactory.php b/vendor/rector/rector-generator/src/NodeFactory/ConfigureClassMethodFactory.php index d0c1cd98923..2253e6914f3 100644 --- a/vendor/rector/rector-generator/src/NodeFactory/ConfigureClassMethodFactory.php +++ b/vendor/rector/rector-generator/src/NodeFactory/ConfigureClassMethodFactory.php @@ -23,18 +23,18 @@ final class ConfigureClassMethodFactory /** * @param array $ruleConfiguration */ - public function create(array $ruleConfiguration) : \PhpParser\Node\Stmt\ClassMethod + public function create(array $ruleConfiguration) : ClassMethod { $classMethod = $this->nodeFactory->createPublicMethod('configure'); - $classMethod->returnType = new \PhpParser\Node\Identifier('void'); - $configurationVariable = new \PhpParser\Node\Expr\Variable('configuration'); - $configurationParam = new \PhpParser\Node\Param($configurationVariable); - $configurationParam->type = new \PhpParser\Node\Identifier('array'); + $classMethod->returnType = new Identifier('void'); + $configurationVariable = new Variable('configuration'); + $configurationParam = new Param($configurationVariable); + $configurationParam->type = new Identifier('array'); $classMethod->params[] = $configurationParam; $assigns = []; foreach (\array_keys($ruleConfiguration) as $propertyName) { $assign = $this->nodeFactory->createPropertyAssign($propertyName, $configurationVariable); - $assigns[] = new \PhpParser\Node\Stmt\Expression($assign); + $assigns[] = new Expression($assign); } $classMethod->stmts = $assigns; $paramDoc = <<<'CODE_SAMPLE' @@ -42,7 +42,7 @@ final class ConfigureClassMethodFactory * @param mixed[] $configuration */ CODE_SAMPLE; - $classMethod->setDocComment(new \PhpParser\Comment\Doc($paramDoc)); + $classMethod->setDocComment(new Doc($paramDoc)); return $classMethod; } } diff --git a/vendor/rector/rector-generator/src/NodeFactory/NodeFactory.php b/vendor/rector/rector-generator/src/NodeFactory/NodeFactory.php index 84fbef08230..60ee4a81e80 100644 --- a/vendor/rector/rector-generator/src/NodeFactory/NodeFactory.php +++ b/vendor/rector/rector-generator/src/NodeFactory/NodeFactory.php @@ -21,38 +21,38 @@ final class NodeFactory /** * @param array $values */ - public function createArray(array $values) : \PhpParser\Node\Expr\Array_ + public function createArray(array $values) : Array_ { $arrayItems = []; foreach ($values as $key => $value) { // natural key, no need for value if (\is_int($key)) { - $arrayItems[] = new \PhpParser\Node\Expr\ArrayItem(\PhpParser\BuilderHelpers::normalizeValue($value)); + $arrayItems[] = new ArrayItem(BuilderHelpers::normalizeValue($value)); } else { - $arrayItems[] = new \PhpParser\Node\Expr\ArrayItem(\PhpParser\BuilderHelpers::normalizeValue($value), \PhpParser\BuilderHelpers::normalizeValue($key)); + $arrayItems[] = new ArrayItem(BuilderHelpers::normalizeValue($value), BuilderHelpers::normalizeValue($key)); } } - return new \PhpParser\Node\Expr\Array_($arrayItems); + return new Array_($arrayItems); } - public function createClassConstReference(string $class) : \PhpParser\Node\Expr\ClassConstFetch + public function createClassConstReference(string $class) : ClassConstFetch { - $fullyQualified = new \PhpParser\Node\Name\FullyQualified($class); - return new \PhpParser\Node\Expr\ClassConstFetch($fullyQualified, 'class'); + $fullyQualified = new FullyQualified($class); + return new ClassConstFetch($fullyQualified, 'class'); } - public function createPropertyAssign(string $propertyName, \PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr\Assign + public function createPropertyAssign(string $propertyName, Expr $expr) : Assign { - $propertyFetch = new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable('this'), $propertyName); - return new \PhpParser\Node\Expr\Assign($propertyFetch, $expr); + $propertyFetch = new PropertyFetch(new Variable('this'), $propertyName); + return new Assign($propertyFetch, $expr); } - public function createPublicMethod(string $methodName) : \PhpParser\Node\Stmt\ClassMethod + public function createPublicMethod(string $methodName) : ClassMethod { - $methodBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\MethodBuilder($methodName); + $methodBuilder = new MethodBuilder($methodName); $methodBuilder->makePublic(); return $methodBuilder->getNode(); } - public function createPrivateArrayProperty(string $propertyName) : \PhpParser\Node\Stmt\Property + public function createPrivateArrayProperty(string $propertyName) : Property { - $propertyBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\PropertyBuilder($propertyName); + $propertyBuilder = new PropertyBuilder($propertyName); $propertyBuilder->makePrivate(); $docContent = <<<'CODE_SAMPLE' /** diff --git a/vendor/rector/rector-generator/src/Provider/RectorRecipeProvider.php b/vendor/rector/rector-generator/src/Provider/RectorRecipeProvider.php index 5b7f0caa557..b3ee62b5456 100644 --- a/vendor/rector/rector-generator/src/Provider/RectorRecipeProvider.php +++ b/vendor/rector/rector-generator/src/Provider/RectorRecipeProvider.php @@ -23,23 +23,23 @@ final class RectorRecipeProvider if ($rectorRecipeConfiguration === []) { return; } - $rectorRecipe = new \Rector\RectorGenerator\ValueObject\RectorRecipe($rectorRecipeConfiguration[\Rector\RectorGenerator\ValueObject\Option::PACKAGE], $rectorRecipeConfiguration[\Rector\RectorGenerator\ValueObject\Option::NAME], $rectorRecipeConfiguration[\Rector\RectorGenerator\ValueObject\Option::NODE_TYPES], $rectorRecipeConfiguration[\Rector\RectorGenerator\ValueObject\Option::DESCRIPTION], $rectorRecipeConfiguration[\Rector\RectorGenerator\ValueObject\Option::CODE_BEFORE], $rectorRecipeConfiguration[\Rector\RectorGenerator\ValueObject\Option::CODE_AFTER]); + $rectorRecipe = new RectorRecipe($rectorRecipeConfiguration[Option::PACKAGE], $rectorRecipeConfiguration[Option::NAME], $rectorRecipeConfiguration[Option::NODE_TYPES], $rectorRecipeConfiguration[Option::DESCRIPTION], $rectorRecipeConfiguration[Option::CODE_BEFORE], $rectorRecipeConfiguration[Option::CODE_AFTER]); // optional parameters - if (isset($rectorRecipeConfiguration[\Rector\RectorGenerator\ValueObject\Option::CONFIGURATION])) { - $rectorRecipe->setConfiguration($rectorRecipeConfiguration[\Rector\RectorGenerator\ValueObject\Option::CONFIGURATION]); + if (isset($rectorRecipeConfiguration[Option::CONFIGURATION])) { + $rectorRecipe->setConfiguration($rectorRecipeConfiguration[Option::CONFIGURATION]); } - if (isset($rectorRecipeConfiguration[\Rector\RectorGenerator\ValueObject\Option::RESOURCES])) { - $rectorRecipe->setResources($rectorRecipeConfiguration[\Rector\RectorGenerator\ValueObject\Option::RESOURCES]); + if (isset($rectorRecipeConfiguration[Option::RESOURCES])) { + $rectorRecipe->setResources($rectorRecipeConfiguration[Option::RESOURCES]); } - if (isset($rectorRecipeConfiguration[\Rector\RectorGenerator\ValueObject\Option::SET_FILE_PATH])) { - $rectorRecipe->setSetFilePath($rectorRecipeConfiguration[\Rector\RectorGenerator\ValueObject\Option::SET_FILE_PATH]); + if (isset($rectorRecipeConfiguration[Option::SET_FILE_PATH])) { + $rectorRecipe->setSetFilePath($rectorRecipeConfiguration[Option::SET_FILE_PATH]); } $this->rectorRecipe = $rectorRecipe; } - public function provide() : \Rector\RectorGenerator\ValueObject\RectorRecipe + public function provide() : RectorRecipe { - if (!$this->rectorRecipe instanceof \Rector\RectorGenerator\ValueObject\RectorRecipe) { - throw new \Rector\RectorGenerator\Exception\ConfigurationException('Make sure the "rector-recipe.php" config file is imported and parameter set. Are you sure its in your main config?'); + if (!$this->rectorRecipe instanceof RectorRecipe) { + throw new ConfigurationException('Make sure the "rector-recipe.php" config file is imported and parameter set. Are you sure its in your main config?'); } return $this->rectorRecipe; } diff --git a/vendor/rector/rector-generator/src/TemplateInitializer.php b/vendor/rector/rector-generator/src/TemplateInitializer.php index 9e3fbb8395c..35be138e6eb 100644 --- a/vendor/rector/rector-generator/src/TemplateInitializer.php +++ b/vendor/rector/rector-generator/src/TemplateInitializer.php @@ -23,7 +23,7 @@ final class TemplateInitializer * @var \Symplify\SmartFileSystem\FileSystemGuard */ private $fileSystemGuard; - public function __construct(\RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle, \RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemGuard $fileSystemGuard) + public function __construct(SymfonyStyle $symfonyStyle, SmartFileSystem $smartFileSystem, FileSystemGuard $fileSystemGuard) { $this->symfonyStyle = $symfonyStyle; $this->smartFileSystem = $smartFileSystem; diff --git a/vendor/rector/rector-generator/src/TemplateVariablesFactory.php b/vendor/rector/rector-generator/src/TemplateVariablesFactory.php index 7ca640e3450..56a03fdbe31 100644 --- a/vendor/rector/rector-generator/src/TemplateVariablesFactory.php +++ b/vendor/rector/rector-generator/src/TemplateVariablesFactory.php @@ -34,7 +34,7 @@ final class TemplateVariablesFactory * @var \Rector\RectorGenerator\NodeFactory\NodeFactory */ private $nodeFactory; - public function __construct(\PhpParser\PrettyPrinter\Standard $standard, \Rector\RectorGenerator\NodeFactory\ConfigurationNodeFactory $configurationNodeFactory, \Rector\RectorGenerator\NodeFactory\ConfigureClassMethodFactory $configureClassMethodFactory, \Rector\RectorGenerator\NodeFactory\NodeFactory $nodeFactory) + public function __construct(Standard $standard, ConfigurationNodeFactory $configurationNodeFactory, ConfigureClassMethodFactory $configureClassMethodFactory, NodeFactory $nodeFactory) { $this->standard = $standard; $this->configurationNodeFactory = $configurationNodeFactory; @@ -44,9 +44,9 @@ final class TemplateVariablesFactory /** * @return array */ - public function createFromRectorRecipe(\Rector\RectorGenerator\ValueObject\RectorRecipe $rectorRecipe) : array + public function createFromRectorRecipe(RectorRecipe $rectorRecipe) : array { - $data = [\Rector\RectorGenerator\ValueObject\Placeholder::PACKAGE => $rectorRecipe->getPackage(), \Rector\RectorGenerator\ValueObject\Placeholder::CATEGORY => $rectorRecipe->getCategory(), \Rector\RectorGenerator\ValueObject\Placeholder::DESCRIPTION => $rectorRecipe->getDescription(), \Rector\RectorGenerator\ValueObject\Placeholder::NAME => $rectorRecipe->getName(), \Rector\RectorGenerator\ValueObject\Placeholder::CODE_BEFORE => \trim($rectorRecipe->getCodeBefore()) . \PHP_EOL, \Rector\RectorGenerator\ValueObject\Placeholder::CODE_BEFORE_EXAMPLE => $this->createCodeForDefinition($rectorRecipe->getCodeBefore()), \Rector\RectorGenerator\ValueObject\Placeholder::CODE_AFTER => \trim($rectorRecipe->getCodeAfter()) . \PHP_EOL, \Rector\RectorGenerator\ValueObject\Placeholder::CODE_AFTER_EXAMPLE => $this->createCodeForDefinition($rectorRecipe->getCodeAfter()), \Rector\RectorGenerator\ValueObject\Placeholder::RESOURCES => $this->createSourceDocBlock($rectorRecipe->getResources())]; + $data = [Placeholder::PACKAGE => $rectorRecipe->getPackage(), Placeholder::CATEGORY => $rectorRecipe->getCategory(), Placeholder::DESCRIPTION => $rectorRecipe->getDescription(), Placeholder::NAME => $rectorRecipe->getName(), Placeholder::CODE_BEFORE => \trim($rectorRecipe->getCodeBefore()) . \PHP_EOL, Placeholder::CODE_BEFORE_EXAMPLE => $this->createCodeForDefinition($rectorRecipe->getCodeBefore()), Placeholder::CODE_AFTER => \trim($rectorRecipe->getCodeAfter()) . \PHP_EOL, Placeholder::CODE_AFTER_EXAMPLE => $this->createCodeForDefinition($rectorRecipe->getCodeAfter()), Placeholder::RESOURCES => $this->createSourceDocBlock($rectorRecipe->getResources())]; if ($rectorRecipe->getConfiguration() !== []) { $configurationData = $this->createConfigurationData($rectorRecipe); $data = \array_merge($data, $configurationData); @@ -86,10 +86,10 @@ final class TemplateVariablesFactory { $arrayItems = []; foreach ($configuration as $mainConfiguration) { - $mainConfiguration = \PhpParser\BuilderHelpers::normalizeValue($mainConfiguration); - $arrayItems[] = new \PhpParser\Node\Expr\ArrayItem($mainConfiguration); + $mainConfiguration = BuilderHelpers::normalizeValue($mainConfiguration); + $arrayItems[] = new ArrayItem($mainConfiguration); } - $array = new \PhpParser\Node\Expr\Array_($arrayItems); + $array = new Array_($arrayItems); return $this->standard->prettyPrintExpr($array); } /** @@ -108,7 +108,7 @@ final class TemplateVariablesFactory $classMethod = $this->configureClassMethodFactory->create($ruleConfiguration); return $this->standard->prettyPrint([$classMethod]); } - private function createNodeTypePhp(\Rector\RectorGenerator\ValueObject\RectorRecipe $rectorRecipe) : string + private function createNodeTypePhp(RectorRecipe $rectorRecipe) : string { $referencingClassConsts = []; foreach ($rectorRecipe->getNodeTypes() as $nodeType) { @@ -120,7 +120,7 @@ final class TemplateVariablesFactory /** * @return array */ - private function createConfigurationData(\Rector\RectorGenerator\ValueObject\RectorRecipe $rectorRecipe) : array + private function createConfigurationData(RectorRecipe $rectorRecipe) : array { $configurationData = []; $configurationData['__TestRuleConfiguration__'] = $this->createRuleConfiguration($rectorRecipe->getConfiguration()); @@ -136,7 +136,7 @@ final class TemplateVariablesFactory private function createMainConfiguration(array $ruleConfiguration) : string { $firstItem = \array_pop($ruleConfiguration); - $valueExpr = \PhpParser\BuilderHelpers::normalizeValue($firstItem); + $valueExpr = BuilderHelpers::normalizeValue($firstItem); return $this->standard->prettyPrintExpr($valueExpr); } } diff --git a/vendor/rector/rector-generator/src/ValueObject/RectorRecipe.php b/vendor/rector/rector-generator/src/ValueObject/RectorRecipe.php index 84548f6c0cd..b320d5961ee 100644 --- a/vendor/rector/rector-generator/src/ValueObject/RectorRecipe.php +++ b/vendor/rector/rector-generator/src/ValueObject/RectorRecipe.php @@ -73,7 +73,7 @@ final class RectorRecipe $this->setName($name); $this->setNodeTypes($nodeTypes); if ($codeBefore === $codeAfter) { - throw new \Rector\RectorGenerator\Exception\ConfigurationException('Code before and after are identical. They have to be different'); + throw new ConfigurationException('Code before and after are identical. They have to be different'); } $this->setCodeBefore($codeBefore); $this->setCodeAfter($codeAfter); @@ -170,7 +170,7 @@ final class RectorRecipe { if (\is_file($package)) { $message = \sprintf('The "%s()" method only accepts package name, file path "%s" given', __METHOD__, $package); - throw new \Rector\RectorGenerator\Exception\ShouldNotHappenException($message); + throw new ShouldNotHappenException($message); } $this->package = $package; } @@ -178,7 +178,7 @@ final class RectorRecipe { if (\substr_compare($name, 'Rector', -\strlen('Rector')) !== 0) { $message = \sprintf('Rector name "%s" must end with "Rector"', $name); - throw new \Rector\RectorGenerator\Exception\ConfigurationException($message); + throw new ConfigurationException($message); } $this->name = $name; } @@ -188,15 +188,15 @@ final class RectorRecipe private function setNodeTypes(array $nodeTypes) : void { foreach ($nodeTypes as $nodeType) { - if (\is_a($nodeType, \PhpParser\Node::class, \true)) { + if (\is_a($nodeType, Node::class, \true)) { continue; } - $message = \sprintf('Node type "%s" does not exist, implement "%s" interface or is not imported in "rector-recipe.php"', $nodeType, \PhpParser\Node::class); - throw new \Rector\RectorGenerator\Exception\ShouldNotHappenException($message); + $message = \sprintf('Node type "%s" does not exist, implement "%s" interface or is not imported in "rector-recipe.php"', $nodeType, Node::class); + throw new ShouldNotHappenException($message); } if (\count($nodeTypes) < 1) { - $message = \sprintf('"$nodeTypes" argument requires at least one item, e.g. "%s"', \PhpParser\Node\Expr\FuncCall::class); - throw new \Rector\RectorGenerator\Exception\ConfigurationException($message); + $message = \sprintf('"$nodeTypes" argument requires at least one item, e.g. "%s"', FuncCall::class); + throw new ConfigurationException($message); } $this->nodeTypes = $nodeTypes; } @@ -213,7 +213,7 @@ final class RectorRecipe */ private function resolveCategory(array $nodeTypes) : void { - $this->category = (string) \RectorPrefix20220607\Nette\Utils\Strings::after($nodeTypes[0], '\\', -1); + $this->category = (string) Strings::after($nodeTypes[0], '\\', -1); } private function normalizeCode(string $code) : string { @@ -233,7 +233,7 @@ final class RectorRecipe if ($composerJsonContent === \false) { continue; } - $composerJson = \RectorPrefix20220607\Nette\Utils\Json::decode($composerJsonContent, \RectorPrefix20220607\Nette\Utils\Json::FORCE_ARRAY); + $composerJson = Json::decode($composerJsonContent, Json::FORCE_ARRAY); if (!isset($composerJson['name'])) { continue; } diff --git a/vendor/rector/rector-generator/templates/rector-recipe.php b/vendor/rector/rector-generator/templates/rector-recipe.php index 3f1f29fc09d..e02c2ef3904 100644 --- a/vendor/rector/rector-generator/templates/rector-recipe.php +++ b/vendor/rector/rector-generator/templates/rector-recipe.php @@ -6,25 +6,25 @@ namespace RectorPrefix20220607; use PhpParser\Node\Expr\MethodCall; use Rector\RectorGenerator\Provider\RectorRecipeProvider; use Rector\RectorGenerator\ValueObject\Option; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; // run "bin/rector generate" to a new Rector basic schema + tests from this config -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +return static function (ContainerConfigurator $containerConfigurator) : void { $services = $containerConfigurator->services(); // [REQUIRED] $rectorRecipeConfiguration = [ // [RECTOR CORE CONTRIBUTION - REQUIRED] // package name, basically namespace part in `rules//src`, use PascalCase - \Rector\RectorGenerator\ValueObject\Option::PACKAGE => 'Naming', + Option::PACKAGE => 'Naming', // name, basically short class name; use PascalCase - \Rector\RectorGenerator\ValueObject\Option::NAME => 'RenameMethodCallRector', + Option::NAME => 'RenameMethodCallRector', // 1+ node types to change, pick from classes here https://github.com/nikic/PHP-Parser/tree/master/lib/PhpParser/Node // the best practise is to have just 1 type here if possible, and make separated rule for other node types - \Rector\RectorGenerator\ValueObject\Option::NODE_TYPES => [\PhpParser\Node\Expr\MethodCall::class], + Option::NODE_TYPES => [MethodCall::class], // describe what the rule does - \Rector\RectorGenerator\ValueObject\Option::DESCRIPTION => '"something()" will be renamed to "somethingElse()"', + Option::DESCRIPTION => '"something()" will be renamed to "somethingElse()"', // code before change // this is used for documentation and first test fixture - \Rector\RectorGenerator\ValueObject\Option::CODE_BEFORE => <<<'CODE_SAMPLE' + Option::CODE_BEFORE => <<<'CODE_SAMPLE' class SomeClass { public function run() @@ -35,7 +35,7 @@ class SomeClass CODE_SAMPLE , // code after change - \Rector\RectorGenerator\ValueObject\Option::CODE_AFTER => <<<'CODE_SAMPLE' + Option::CODE_AFTER => <<<'CODE_SAMPLE' class SomeClass { public function run() @@ -46,5 +46,5 @@ class SomeClass CODE_SAMPLE , ]; - $services->set(\Rector\RectorGenerator\Provider\RectorRecipeProvider::class)->arg('$rectorRecipeConfiguration', $rectorRecipeConfiguration); + $services->set(RectorRecipeProvider::class)->arg('$rectorRecipeConfiguration', $rectorRecipeConfiguration); }; diff --git a/vendor/rector/rector-generator/templates/rules-tests/__Package__/Rector/__Category__/__Name__/config/__Configuredconfigured_rule.php b/vendor/rector/rector-generator/templates/rules-tests/__Package__/Rector/__Category__/__Name__/config/__Configuredconfigured_rule.php index bba60feca86..f0aee5cce3a 100644 --- a/vendor/rector/rector-generator/templates/rules-tests/__Package__/Rector/__Category__/__Name__/config/__Configuredconfigured_rule.php +++ b/vendor/rector/rector-generator/templates/rules-tests/__Package__/Rector/__Category__/__Name__/config/__Configuredconfigured_rule.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace RectorPrefix20220607; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\__Package__\Rector\__Category__\__Name__::class, \__MainConfiguration__); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(\Rector\__Package__\Rector\__Category__\__Name__::class, \RectorPrefix20220607\__MainConfiguration__); }; diff --git a/vendor/rector/rector-generator/templates/rules-tests/__Package__/Rector/__Category__/__Name__/config/configured_rule.php b/vendor/rector/rector-generator/templates/rules-tests/__Package__/Rector/__Category__/__Name__/config/configured_rule.php index c89c0502a00..9c54101ff25 100644 --- a/vendor/rector/rector-generator/templates/rules-tests/__Package__/Rector/__Category__/__Name__/config/configured_rule.php +++ b/vendor/rector/rector-generator/templates/rules-tests/__Package__/Rector/__Category__/__Name__/config/configured_rule.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace RectorPrefix20220607; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $rectorConfig->rule(\Rector\__Package__\Rector\__Category__\__Name__::class); }; diff --git a/vendor/rector/rector-generator/templates/rules/__Package__/Rector/__Category__/__Name__.php b/vendor/rector/rector-generator/templates/rules/__Package__/Rector/__Category__/__Name__.php index 7bdc36d445f..a8f24a58d28 100644 --- a/vendor/rector/rector-generator/templates/rules/__Package__/Rector/__Category__/__Name__.php +++ b/vendor/rector/rector-generator/templates/rules/__Package__/Rector/__Category__/__Name__.php @@ -5,17 +5,17 @@ namespace Rector\__Package__\Rector\__Category__; use PhpParser\Node; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** __Resources__ * @see \Rector\Tests\__Package__\Rector\__Category__\__Name__\__Name__Test */ -final class __Name__ extends \Rector\Core\Rector\AbstractRector +final class __Name__ extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('__Description__', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(__CodeBeforeExample__, __CodeAfterExample__)]); + return new RuleDefinition('__Description__', [new CodeSample(__CodeBeforeExample__, __CodeAfterExample__)]); } /** * @return array> @@ -27,7 +27,7 @@ final class __Name__ extends \Rector\Core\Rector\AbstractRector /** * @param __NodeTypesDoc__ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { // change the node return $node; diff --git a/vendor/rector/rector-laravel/config/config.php b/vendor/rector/rector-laravel/config/config.php index 230bf41c21a..41730bee766 100644 --- a/vendor/rector/rector-laravel/config/config.php +++ b/vendor/rector/rector-laravel/config/config.php @@ -5,9 +5,9 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Core\NonPhpFile\Rector\RenameClassNonPhpRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $services = $rectorConfig->services(); $services->defaults()->public()->autowire()->autoconfigure(); $services->load('Rector\\Laravel\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/{Rector,ValueObject}']); - $services->set(\Rector\Core\NonPhpFile\Rector\RenameClassNonPhpRector::class); + $services->set(RenameClassNonPhpRector::class); }; diff --git a/vendor/rector/rector-laravel/config/sets/laravel-array-str-functions-to-static-call.php b/vendor/rector/rector-laravel/config/sets/laravel-array-str-functions-to-static-call.php index e4d5d83b4d7..966e4ac89e3 100644 --- a/vendor/rector/rector-laravel/config/sets/laravel-array-str-functions-to-static-call.php +++ b/vendor/rector/rector-laravel/config/sets/laravel-array-str-functions-to-static-call.php @@ -8,6 +8,6 @@ use Rector\Transform\Rector\FuncCall\FuncCallToStaticCallRector; use Rector\Transform\ValueObject\FuncCallToStaticCall; // @see https://medium.freecodecamp.org/moving-away-from-magic-or-why-i-dont-want-to-use-laravel-anymore-2ce098c979bd // @see https://laravel.com/docs/5.7/facades#facades-vs-dependency-injection -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\FuncCall\FuncCallToStaticCallRector::class, [new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_add', 'Illuminate\\Support\\Arr', 'add'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_collapse', 'Illuminate\\Support\\Arr', 'collapse'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_divide', 'Illuminate\\Support\\Arr', 'divide'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_dot', 'Illuminate\\Support\\Arr', 'dot'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_except', 'Illuminate\\Support\\Arr', 'except'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_first', 'Illuminate\\Support\\Arr', 'first'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_flatten', 'Illuminate\\Support\\Arr', 'flatten'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_forget', 'Illuminate\\Support\\Arr', 'forget'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_get', 'Illuminate\\Support\\Arr', 'get'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_has', 'Illuminate\\Support\\Arr', 'has'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_last', 'Illuminate\\Support\\Arr', 'last'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_only', 'Illuminate\\Support\\Arr', 'only'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_pluck', 'Illuminate\\Support\\Arr', 'pluck'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_prepend', 'Illuminate\\Support\\Arr', 'prepend'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_pull', 'Illuminate\\Support\\Arr', 'pull'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_random', 'Illuminate\\Support\\Arr', 'random'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_sort', 'Illuminate\\Support\\Arr', 'sort'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_sort_recursive', 'Illuminate\\Support\\Arr', 'sortRecursive'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_where', 'Illuminate\\Support\\Arr', 'where'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_wrap', 'Illuminate\\Support\\Arr', 'wrap'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('array_set', 'Illuminate\\Support\\Arr', 'set'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('camel_case', 'Illuminate\\Support\\Str', 'camel'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('ends_with', 'Illuminate\\Support\\Str', 'endsWith'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('kebab_case', 'Illuminate\\Support\\Str', 'kebab'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('snake_case', 'Illuminate\\Support\\Str', 'snake'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('starts_with', 'Illuminate\\Support\\Str', 'startsWith'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('str_after', 'Illuminate\\Support\\Str', 'after'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('str_before', 'Illuminate\\Support\\Str', 'before'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('str_contains', 'Illuminate\\Support\\Str', 'contains'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('str_finish', 'Illuminate\\Support\\Str', 'finish'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('str_is', 'Illuminate\\Support\\Str', 'is'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('str_limit', 'Illuminate\\Support\\Str', 'limit'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('str_plural', 'Illuminate\\Support\\Str', 'plural'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('str_random', 'Illuminate\\Support\\Str', 'random'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('str_replace_array', 'Illuminate\\Support\\Str', 'replaceArray'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('str_replace_first', 'Illuminate\\Support\\Str', 'replaceFirst'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('str_replace_last', 'Illuminate\\Support\\Str', 'replaceLast'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('str_singular', 'Illuminate\\Support\\Str', 'singular'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('str_slug', 'Illuminate\\Support\\Str', 'slug'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('str_start', 'Illuminate\\Support\\Str', 'start'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('studly_case', 'Illuminate\\Support\\Str', 'studly'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('title_case', 'Illuminate\\Support\\Str', 'title')]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(FuncCallToStaticCallRector::class, [new FuncCallToStaticCall('array_add', 'Illuminate\\Support\\Arr', 'add'), new FuncCallToStaticCall('array_collapse', 'Illuminate\\Support\\Arr', 'collapse'), new FuncCallToStaticCall('array_divide', 'Illuminate\\Support\\Arr', 'divide'), new FuncCallToStaticCall('array_dot', 'Illuminate\\Support\\Arr', 'dot'), new FuncCallToStaticCall('array_except', 'Illuminate\\Support\\Arr', 'except'), new FuncCallToStaticCall('array_first', 'Illuminate\\Support\\Arr', 'first'), new FuncCallToStaticCall('array_flatten', 'Illuminate\\Support\\Arr', 'flatten'), new FuncCallToStaticCall('array_forget', 'Illuminate\\Support\\Arr', 'forget'), new FuncCallToStaticCall('array_get', 'Illuminate\\Support\\Arr', 'get'), new FuncCallToStaticCall('array_has', 'Illuminate\\Support\\Arr', 'has'), new FuncCallToStaticCall('array_last', 'Illuminate\\Support\\Arr', 'last'), new FuncCallToStaticCall('array_only', 'Illuminate\\Support\\Arr', 'only'), new FuncCallToStaticCall('array_pluck', 'Illuminate\\Support\\Arr', 'pluck'), new FuncCallToStaticCall('array_prepend', 'Illuminate\\Support\\Arr', 'prepend'), new FuncCallToStaticCall('array_pull', 'Illuminate\\Support\\Arr', 'pull'), new FuncCallToStaticCall('array_random', 'Illuminate\\Support\\Arr', 'random'), new FuncCallToStaticCall('array_sort', 'Illuminate\\Support\\Arr', 'sort'), new FuncCallToStaticCall('array_sort_recursive', 'Illuminate\\Support\\Arr', 'sortRecursive'), new FuncCallToStaticCall('array_where', 'Illuminate\\Support\\Arr', 'where'), new FuncCallToStaticCall('array_wrap', 'Illuminate\\Support\\Arr', 'wrap'), new FuncCallToStaticCall('array_set', 'Illuminate\\Support\\Arr', 'set'), new FuncCallToStaticCall('camel_case', 'Illuminate\\Support\\Str', 'camel'), new FuncCallToStaticCall('ends_with', 'Illuminate\\Support\\Str', 'endsWith'), new FuncCallToStaticCall('kebab_case', 'Illuminate\\Support\\Str', 'kebab'), new FuncCallToStaticCall('snake_case', 'Illuminate\\Support\\Str', 'snake'), new FuncCallToStaticCall('starts_with', 'Illuminate\\Support\\Str', 'startsWith'), new FuncCallToStaticCall('str_after', 'Illuminate\\Support\\Str', 'after'), new FuncCallToStaticCall('str_before', 'Illuminate\\Support\\Str', 'before'), new FuncCallToStaticCall('str_contains', 'Illuminate\\Support\\Str', 'contains'), new FuncCallToStaticCall('str_finish', 'Illuminate\\Support\\Str', 'finish'), new FuncCallToStaticCall('str_is', 'Illuminate\\Support\\Str', 'is'), new FuncCallToStaticCall('str_limit', 'Illuminate\\Support\\Str', 'limit'), new FuncCallToStaticCall('str_plural', 'Illuminate\\Support\\Str', 'plural'), new FuncCallToStaticCall('str_random', 'Illuminate\\Support\\Str', 'random'), new FuncCallToStaticCall('str_replace_array', 'Illuminate\\Support\\Str', 'replaceArray'), new FuncCallToStaticCall('str_replace_first', 'Illuminate\\Support\\Str', 'replaceFirst'), new FuncCallToStaticCall('str_replace_last', 'Illuminate\\Support\\Str', 'replaceLast'), new FuncCallToStaticCall('str_singular', 'Illuminate\\Support\\Str', 'singular'), new FuncCallToStaticCall('str_slug', 'Illuminate\\Support\\Str', 'slug'), new FuncCallToStaticCall('str_start', 'Illuminate\\Support\\Str', 'start'), new FuncCallToStaticCall('studly_case', 'Illuminate\\Support\\Str', 'studly'), new FuncCallToStaticCall('title_case', 'Illuminate\\Support\\Str', 'title')]); }; diff --git a/vendor/rector/rector-laravel/config/sets/laravel-code-quality.php b/vendor/rector/rector-laravel/config/sets/laravel-code-quality.php index f869649ad2f..bcb035add40 100644 --- a/vendor/rector/rector-laravel/config/sets/laravel-code-quality.php +++ b/vendor/rector/rector-laravel/config/sets/laravel-code-quality.php @@ -5,6 +5,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Laravel\Rector\Assign\CallOnAppArrayAccessToStandaloneAssignRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Laravel\Rector\Assign\CallOnAppArrayAccessToStandaloneAssignRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(CallOnAppArrayAccessToStandaloneAssignRector::class); }; diff --git a/vendor/rector/rector-laravel/config/sets/laravel-legacy-factories-to-classes.php b/vendor/rector/rector-laravel/config/sets/laravel-legacy-factories-to-classes.php index d895ad5ac99..283fec9d6cc 100644 --- a/vendor/rector/rector-laravel/config/sets/laravel-legacy-factories-to-classes.php +++ b/vendor/rector/rector-laravel/config/sets/laravel-legacy-factories-to-classes.php @@ -7,12 +7,12 @@ use Rector\Config\RectorConfig; use Rector\Laravel\Rector\FuncCall\FactoryFuncCallToStaticCallRector; use Rector\Laravel\Rector\MethodCall\FactoryApplyingStatesRector; use Rector\Laravel\Rector\Namespace_\FactoryDefinitionRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { // https://laravel.com/docs/7.x/database-testing#writing-factories // https://laravel.com/docs/8.x/database-testing#defining-model-factories - $rectorConfig->rule(\Rector\Laravel\Rector\Namespace_\FactoryDefinitionRector::class); + $rectorConfig->rule(FactoryDefinitionRector::class); // https://laravel.com/docs/7.x/database-testing#using-factories // https://laravel.com/docs/8.x/database-testing#creating-models-using-factories - $rectorConfig->rule(\Rector\Laravel\Rector\MethodCall\FactoryApplyingStatesRector::class); - $rectorConfig->rule(\Rector\Laravel\Rector\FuncCall\FactoryFuncCallToStaticCallRector::class); + $rectorConfig->rule(FactoryApplyingStatesRector::class); + $rectorConfig->rule(FactoryFuncCallToStaticCallRector::class); }; diff --git a/vendor/rector/rector-laravel/config/sets/laravel-static-to-injection.php b/vendor/rector/rector-laravel/config/sets/laravel-static-to-injection.php index 81cce23c543..2de02660239 100644 --- a/vendor/rector/rector-laravel/config/sets/laravel-static-to-injection.php +++ b/vendor/rector/rector-laravel/config/sets/laravel-static-to-injection.php @@ -18,43 +18,43 @@ use Rector\Transform\ValueObject\StaticCallToMethodCall; * @see https://tomasvotruba.com/blog/2019/03/04/how-to-turn-laravel-from-static-to-dependency-injection-in-one-day/ * @see https://laravel.com/docs/5.7/facades#facades-vs-dependency-injection */ -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $rectorConfig->import(__DIR__ . '/laravel-array-str-functions-to-static-call.php'); - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\StaticCall\StaticCallToMethodCallRector::class, [new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\App', '*', 'Illuminate\\Foundation\\Application', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Artisan', '*', 'Illuminate\\Contracts\\Console\\Kernel', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Auth', '*', 'Illuminate\\Auth\\AuthManager', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Blade', '*', 'Illuminate\\View\\Compilers\\BladeCompiler', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Broadcast', '*', 'Illuminate\\Contracts\\Broadcasting\\Factory', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Bus', '*', 'Illuminate\\Contracts\\Bus\\Dispatcher', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Cache', '*', 'Illuminate\\Cache\\CacheManager', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Config', '*', 'Illuminate\\Config\\Repository', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Cookie', '*', 'Illuminate\\Cookie\\CookieJar', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Crypt', '*', 'Illuminate\\Encryption\\Encrypter', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\DB', '*', 'Illuminate\\Database\\DatabaseManager', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Event', '*', 'Illuminate\\Events\\Dispatcher', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\File', '*', 'Illuminate\\Filesystem\\Filesystem', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Gate', '*', 'Illuminate\\Contracts\\Auth\\Access\\Gate', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Hash', '*', 'Illuminate\\Contracts\\Hashing\\Hasher', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Lang', '*', 'Illuminate\\Translation\\Translator', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Log', '*', 'Illuminate\\Log\\LogManager', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Mail', '*', 'Illuminate\\Mail\\Mailer', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Notification', '*', 'Illuminate\\Notifications\\ChannelManager', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Password', '*', 'Illuminate\\Auth\\Passwords\\PasswordBrokerManager', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Queue', '*', 'Illuminate\\Queue\\QueueManager', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Redirect', '*', 'Illuminate\\Routing\\Redirector', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Redis', '*', 'Illuminate\\Redis\\RedisManager', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Request', '*', 'Illuminate\\Http\\Request', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Response', '*', 'Illuminate\\Contracts\\Routing\\ResponseFactory', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Route', '*', 'Illuminate\\Routing\\Router', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Schema', '*', 'Illuminate\\Database\\Schema\\Builder', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Session', '*', 'Illuminate\\Session\\SessionManager', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Storage', '*', 'Illuminate\\Filesystem\\FilesystemManager', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\URL', '*', 'Illuminate\\Routing\\UrlGenerator', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\Validator', '*', 'Illuminate\\Validation\\Factory', '*'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Illuminate\\Support\\Facades\\View', '*', 'Illuminate\\View\\Factory', '*')]); - $rectorConfig->rule(\Rector\Laravel\Rector\StaticCall\RequestStaticValidateToInjectRector::class); + $rectorConfig->ruleWithConfiguration(StaticCallToMethodCallRector::class, [new StaticCallToMethodCall('Illuminate\\Support\\Facades\\App', '*', 'Illuminate\\Foundation\\Application', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Artisan', '*', 'Illuminate\\Contracts\\Console\\Kernel', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Auth', '*', 'Illuminate\\Auth\\AuthManager', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Blade', '*', 'Illuminate\\View\\Compilers\\BladeCompiler', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Broadcast', '*', 'Illuminate\\Contracts\\Broadcasting\\Factory', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Bus', '*', 'Illuminate\\Contracts\\Bus\\Dispatcher', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Cache', '*', 'Illuminate\\Cache\\CacheManager', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Config', '*', 'Illuminate\\Config\\Repository', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Cookie', '*', 'Illuminate\\Cookie\\CookieJar', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Crypt', '*', 'Illuminate\\Encryption\\Encrypter', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\DB', '*', 'Illuminate\\Database\\DatabaseManager', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Event', '*', 'Illuminate\\Events\\Dispatcher', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\File', '*', 'Illuminate\\Filesystem\\Filesystem', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Gate', '*', 'Illuminate\\Contracts\\Auth\\Access\\Gate', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Hash', '*', 'Illuminate\\Contracts\\Hashing\\Hasher', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Lang', '*', 'Illuminate\\Translation\\Translator', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Log', '*', 'Illuminate\\Log\\LogManager', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Mail', '*', 'Illuminate\\Mail\\Mailer', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Notification', '*', 'Illuminate\\Notifications\\ChannelManager', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Password', '*', 'Illuminate\\Auth\\Passwords\\PasswordBrokerManager', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Queue', '*', 'Illuminate\\Queue\\QueueManager', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Redirect', '*', 'Illuminate\\Routing\\Redirector', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Redis', '*', 'Illuminate\\Redis\\RedisManager', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Request', '*', 'Illuminate\\Http\\Request', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Response', '*', 'Illuminate\\Contracts\\Routing\\ResponseFactory', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Route', '*', 'Illuminate\\Routing\\Router', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Schema', '*', 'Illuminate\\Database\\Schema\\Builder', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Session', '*', 'Illuminate\\Session\\SessionManager', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Storage', '*', 'Illuminate\\Filesystem\\FilesystemManager', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\URL', '*', 'Illuminate\\Routing\\UrlGenerator', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\Validator', '*', 'Illuminate\\Validation\\Factory', '*'), new StaticCallToMethodCall('Illuminate\\Support\\Facades\\View', '*', 'Illuminate\\View\\Factory', '*')]); + $rectorConfig->rule(RequestStaticValidateToInjectRector::class); // @see https://github.com/laravel/framework/blob/78828bc779e410e03cc6465f002b834eadf160d2/src/Illuminate/Foundation/helpers.php#L959 // @see https://gist.github.com/barryvdh/bb6ffc5d11e0a75dba67 - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\FuncCall\ArgumentFuncCallToMethodCallRector::class, [ - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('auth', 'Illuminate\\Contracts\\Auth\\Guard'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('policy', 'Illuminate\\Contracts\\Auth\\Access\\Gate', 'getPolicyFor'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('cookie', 'Illuminate\\Contracts\\Cookie\\Factory', 'make'), + $rectorConfig->ruleWithConfiguration(ArgumentFuncCallToMethodCallRector::class, [ + new ArgumentFuncCallToMethodCall('auth', 'Illuminate\\Contracts\\Auth\\Guard'), + new ArgumentFuncCallToMethodCall('policy', 'Illuminate\\Contracts\\Auth\\Access\\Gate', 'getPolicyFor'), + new ArgumentFuncCallToMethodCall('cookie', 'Illuminate\\Contracts\\Cookie\\Factory', 'make'), // router - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('put', 'Illuminate\\Routing\\Router', 'put'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('get', 'Illuminate\\Routing\\Router', 'get'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('post', 'Illuminate\\Routing\\Router', 'post'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('patch', 'Illuminate\\Routing\\Router', 'patch'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('delete', 'Illuminate\\Routing\\Router', 'delete'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('resource', 'Illuminate\\Routing\\Router', 'resource'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('response', 'Illuminate\\Contracts\\Routing\\ResponseFactory', 'make'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('info', 'Illuminate\\Log\\Writer', 'info'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('view', 'Illuminate\\Contracts\\View\\Factory', 'make'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('bcrypt', 'Illuminate\\Hashing\\BcryptHasher', 'make'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('redirect', 'Illuminate\\Routing\\Redirector', 'to'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('broadcast', 'Illuminate\\Contracts\\Broadcasting\\Factory', 'event'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('event', 'Illuminate\\Events\\Dispatcher', 'dispatch'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('dispatch', 'Illuminate\\Events\\Dispatcher', 'dispatch'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('route', 'Illuminate\\Routing\\UrlGenerator', 'route'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('asset', 'Illuminate\\Routing\\UrlGenerator', 'asset'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('url', 'Illuminate\\Contracts\\Routing\\UrlGenerator', 'to'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('action', 'Illuminate\\Routing\\UrlGenerator', 'action'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('trans', 'Illuminate\\Translation\\Translator', 'trans'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('trans_choice', 'Illuminate\\Translation\\Translator', 'transChoice'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('logger', 'Illuminate\\Log\\Writer', 'debug'), - new \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall('back', 'Illuminate\\Routing\\Redirector', 'back', 'back'), - new \Rector\Transform\ValueObject\ArrayFuncCallToMethodCall('config', 'Illuminate\\Contracts\\Config\\Repository', 'set', 'get'), - new \Rector\Transform\ValueObject\ArrayFuncCallToMethodCall('session', 'Illuminate\\Session\\SessionManager', 'put', 'get'), + new ArgumentFuncCallToMethodCall('put', 'Illuminate\\Routing\\Router', 'put'), + new ArgumentFuncCallToMethodCall('get', 'Illuminate\\Routing\\Router', 'get'), + new ArgumentFuncCallToMethodCall('post', 'Illuminate\\Routing\\Router', 'post'), + new ArgumentFuncCallToMethodCall('patch', 'Illuminate\\Routing\\Router', 'patch'), + new ArgumentFuncCallToMethodCall('delete', 'Illuminate\\Routing\\Router', 'delete'), + new ArgumentFuncCallToMethodCall('resource', 'Illuminate\\Routing\\Router', 'resource'), + new ArgumentFuncCallToMethodCall('response', 'Illuminate\\Contracts\\Routing\\ResponseFactory', 'make'), + new ArgumentFuncCallToMethodCall('info', 'Illuminate\\Log\\Writer', 'info'), + new ArgumentFuncCallToMethodCall('view', 'Illuminate\\Contracts\\View\\Factory', 'make'), + new ArgumentFuncCallToMethodCall('bcrypt', 'Illuminate\\Hashing\\BcryptHasher', 'make'), + new ArgumentFuncCallToMethodCall('redirect', 'Illuminate\\Routing\\Redirector', 'to'), + new ArgumentFuncCallToMethodCall('broadcast', 'Illuminate\\Contracts\\Broadcasting\\Factory', 'event'), + new ArgumentFuncCallToMethodCall('event', 'Illuminate\\Events\\Dispatcher', 'dispatch'), + new ArgumentFuncCallToMethodCall('dispatch', 'Illuminate\\Events\\Dispatcher', 'dispatch'), + new ArgumentFuncCallToMethodCall('route', 'Illuminate\\Routing\\UrlGenerator', 'route'), + new ArgumentFuncCallToMethodCall('asset', 'Illuminate\\Routing\\UrlGenerator', 'asset'), + new ArgumentFuncCallToMethodCall('url', 'Illuminate\\Contracts\\Routing\\UrlGenerator', 'to'), + new ArgumentFuncCallToMethodCall('action', 'Illuminate\\Routing\\UrlGenerator', 'action'), + new ArgumentFuncCallToMethodCall('trans', 'Illuminate\\Translation\\Translator', 'trans'), + new ArgumentFuncCallToMethodCall('trans_choice', 'Illuminate\\Translation\\Translator', 'transChoice'), + new ArgumentFuncCallToMethodCall('logger', 'Illuminate\\Log\\Writer', 'debug'), + new ArgumentFuncCallToMethodCall('back', 'Illuminate\\Routing\\Redirector', 'back', 'back'), + new ArrayFuncCallToMethodCall('config', 'Illuminate\\Contracts\\Config\\Repository', 'set', 'get'), + new ArrayFuncCallToMethodCall('session', 'Illuminate\\Session\\SessionManager', 'put', 'get'), ]); - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\FuncCall\FuncCallToNewRector::class, ['collect' => 'Illuminate\\Support\\Collection']); - $rectorConfig->rule(\Rector\Laravel\Rector\FuncCall\HelperFuncCallToFacadeClassRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['App' => 'Illuminate\\Support\\Facades\\App', 'Artisan' => 'Illuminate\\Support\\Facades\\Artisan', 'Auth' => 'Illuminate\\Support\\Facades\\Auth', 'Blade' => 'Illuminate\\Support\\Facades\\Blade', 'Broadcast' => 'Illuminate\\Support\\Facades\\Broadcast', 'Bus' => 'Illuminate\\Support\\Facades\\Bus', 'Cache' => 'Illuminate\\Support\\Facades\\Cache', 'Config' => 'Illuminate\\Support\\Facades\\Config', 'Cookie' => 'Illuminate\\Support\\Facades\\Cookie', 'Crypt' => 'Illuminate\\Support\\Facades\\Crypt', 'DB' => 'Illuminate\\Support\\Facades\\DB', 'Date' => 'Illuminate\\Support\\Facades\\Date', 'Event' => 'Illuminate\\Support\\Facades\\Event', 'Facade' => 'Illuminate\\Support\\Facades\\Facade', 'File' => 'Illuminate\\Support\\Facades\\File', 'Gate' => 'Illuminate\\Support\\Facades\\Gate', 'Hash' => 'Illuminate\\Support\\Facades\\Hash', 'Http' => 'Illuminate\\Support\\Facades\\Http', 'Lang' => 'Illuminate\\Support\\Facades\\Lang', 'Log' => 'Illuminate\\Support\\Facades\\Log', 'Mail' => 'Illuminate\\Support\\Facades\\Mail', 'Notification' => 'Illuminate\\Support\\Facades\\Notification', 'Password' => 'Illuminate\\Support\\Facades\\Password', 'Queue' => 'Illuminate\\Support\\Facades\\Queue', 'RateLimiter' => 'Illuminate\\Support\\Facades\\RateLimiter', 'Redirect' => 'Illuminate\\Support\\Facades\\Redirect', 'Redis' => 'Illuminate\\Support\\Facades\\Redis', 'Request' => 'Illuminate\\Http\\Request', 'Response' => 'Illuminate\\Support\\Facades\\Response', 'Route' => 'Illuminate\\Support\\Facades\\Route', 'Schema' => 'Illuminate\\Support\\Facades\\Schema', 'Session' => 'Illuminate\\Support\\Facades\\Session', 'Storage' => 'Illuminate\\Support\\Facades\\Storage', 'URL' => 'Illuminate\\Support\\Facades\\URL', 'Validator' => 'Illuminate\\Support\\Facades\\Validator', 'View' => 'Illuminate\\Support\\Facades\\View']); + $rectorConfig->ruleWithConfiguration(FuncCallToNewRector::class, ['collect' => 'Illuminate\\Support\\Collection']); + $rectorConfig->rule(HelperFuncCallToFacadeClassRector::class); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['App' => 'Illuminate\\Support\\Facades\\App', 'Artisan' => 'Illuminate\\Support\\Facades\\Artisan', 'Auth' => 'Illuminate\\Support\\Facades\\Auth', 'Blade' => 'Illuminate\\Support\\Facades\\Blade', 'Broadcast' => 'Illuminate\\Support\\Facades\\Broadcast', 'Bus' => 'Illuminate\\Support\\Facades\\Bus', 'Cache' => 'Illuminate\\Support\\Facades\\Cache', 'Config' => 'Illuminate\\Support\\Facades\\Config', 'Cookie' => 'Illuminate\\Support\\Facades\\Cookie', 'Crypt' => 'Illuminate\\Support\\Facades\\Crypt', 'DB' => 'Illuminate\\Support\\Facades\\DB', 'Date' => 'Illuminate\\Support\\Facades\\Date', 'Event' => 'Illuminate\\Support\\Facades\\Event', 'Facade' => 'Illuminate\\Support\\Facades\\Facade', 'File' => 'Illuminate\\Support\\Facades\\File', 'Gate' => 'Illuminate\\Support\\Facades\\Gate', 'Hash' => 'Illuminate\\Support\\Facades\\Hash', 'Http' => 'Illuminate\\Support\\Facades\\Http', 'Lang' => 'Illuminate\\Support\\Facades\\Lang', 'Log' => 'Illuminate\\Support\\Facades\\Log', 'Mail' => 'Illuminate\\Support\\Facades\\Mail', 'Notification' => 'Illuminate\\Support\\Facades\\Notification', 'Password' => 'Illuminate\\Support\\Facades\\Password', 'Queue' => 'Illuminate\\Support\\Facades\\Queue', 'RateLimiter' => 'Illuminate\\Support\\Facades\\RateLimiter', 'Redirect' => 'Illuminate\\Support\\Facades\\Redirect', 'Redis' => 'Illuminate\\Support\\Facades\\Redis', 'Request' => 'Illuminate\\Http\\Request', 'Response' => 'Illuminate\\Support\\Facades\\Response', 'Route' => 'Illuminate\\Support\\Facades\\Route', 'Schema' => 'Illuminate\\Support\\Facades\\Schema', 'Session' => 'Illuminate\\Support\\Facades\\Session', 'Storage' => 'Illuminate\\Support\\Facades\\Storage', 'URL' => 'Illuminate\\Support\\Facades\\URL', 'Validator' => 'Illuminate\\Support\\Facades\\Validator', 'View' => 'Illuminate\\Support\\Facades\\View']); }; diff --git a/vendor/rector/rector-laravel/config/sets/laravel50.php b/vendor/rector/rector-laravel/config/sets/laravel50.php index 439ec54e221..cc7b14ccba0 100644 --- a/vendor/rector/rector-laravel/config/sets/laravel50.php +++ b/vendor/rector/rector-laravel/config/sets/laravel50.php @@ -8,8 +8,8 @@ use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Renaming\ValueObject\MethodCallRename; # see: https://laravel.com/docs/5.0/upgrade -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { # https://stackoverflow.com/a/24949656/1348344 - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Illuminate\\Cache\\CacheManager' => 'Illuminate\\Contracts\\Cache\\Repository', 'Illuminate\\Database\\Eloquent\\SoftDeletingTrait' => 'Illuminate\\Database\\Eloquent\\SoftDeletes']); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Contracts\\Pagination\\Paginator', 'links', 'render'), new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Contracts\\Pagination\\Paginator', 'getFrom', 'firstItem'), new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Contracts\\Pagination\\Paginator', 'getTo', 'lastItem'), new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Contracts\\Pagination\\Paginator', 'getPerPage', 'perPage'), new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Contracts\\Pagination\\Paginator', 'getCurrentPage', 'currentPage'), new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Contracts\\Pagination\\Paginator', 'getLastPage', 'lastPage'), new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Contracts\\Pagination\\Paginator', 'getTotal', 'total')]); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Illuminate\\Cache\\CacheManager' => 'Illuminate\\Contracts\\Cache\\Repository', 'Illuminate\\Database\\Eloquent\\SoftDeletingTrait' => 'Illuminate\\Database\\Eloquent\\SoftDeletes']); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Illuminate\\Contracts\\Pagination\\Paginator', 'links', 'render'), new MethodCallRename('Illuminate\\Contracts\\Pagination\\Paginator', 'getFrom', 'firstItem'), new MethodCallRename('Illuminate\\Contracts\\Pagination\\Paginator', 'getTo', 'lastItem'), new MethodCallRename('Illuminate\\Contracts\\Pagination\\Paginator', 'getPerPage', 'perPage'), new MethodCallRename('Illuminate\\Contracts\\Pagination\\Paginator', 'getCurrentPage', 'currentPage'), new MethodCallRename('Illuminate\\Contracts\\Pagination\\Paginator', 'getLastPage', 'lastPage'), new MethodCallRename('Illuminate\\Contracts\\Pagination\\Paginator', 'getTotal', 'total')]); }; diff --git a/vendor/rector/rector-laravel/config/sets/laravel51.php b/vendor/rector/rector-laravel/config/sets/laravel51.php index fdd4ddfad68..f628c73b123 100644 --- a/vendor/rector/rector-laravel/config/sets/laravel51.php +++ b/vendor/rector/rector-laravel/config/sets/laravel51.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Renaming\Rector\Name\RenameClassRector; # see: https://laravel.com/docs/5.1/upgrade -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Illuminate\\Validation\\Validator' => 'Illuminate\\Contracts\\Validation\\Validator']); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Illuminate\\Validation\\Validator' => 'Illuminate\\Contracts\\Validation\\Validator']); }; diff --git a/vendor/rector/rector-laravel/config/sets/laravel52.php b/vendor/rector/rector-laravel/config/sets/laravel52.php index 43a0cfb6610..408cbe99767 100644 --- a/vendor/rector/rector-laravel/config/sets/laravel52.php +++ b/vendor/rector/rector-laravel/config/sets/laravel52.php @@ -8,7 +8,7 @@ use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Transform\Rector\String_\StringToClassConstantRector; use Rector\Transform\ValueObject\StringToClassConstant; # see: https://laravel.com/docs/5.2/upgrade -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Illuminate\\Auth\\Access\\UnauthorizedException' => 'Illuminate\\Auth\\Access\\AuthorizationException', 'Illuminate\\Http\\Exception\\HttpResponseException' => 'Illuminate\\Foundation\\Validation\\ValidationException', 'Illuminate\\Foundation\\Composer' => 'Illuminate\\Support\\Composer']); - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\String_\StringToClassConstantRector::class, [new \Rector\Transform\ValueObject\StringToClassConstant('artisan.start', 'Illuminate\\Console\\Events\\ArtisanStarting', 'class'), new \Rector\Transform\ValueObject\StringToClassConstant('auth.attempting', 'Illuminate\\Auth\\Events\\Attempting', 'class'), new \Rector\Transform\ValueObject\StringToClassConstant('auth.login', 'Illuminate\\Auth\\Events\\Login', 'class'), new \Rector\Transform\ValueObject\StringToClassConstant('auth.logout', 'Illuminate\\Auth\\Events\\Logout', 'class'), new \Rector\Transform\ValueObject\StringToClassConstant('cache.missed', 'Illuminate\\Cache\\Events\\CacheMissed', 'class'), new \Rector\Transform\ValueObject\StringToClassConstant('cache.hit', 'Illuminate\\Cache\\Events\\CacheHit', 'class'), new \Rector\Transform\ValueObject\StringToClassConstant('cache.write', 'Illuminate\\Cache\\Events\\KeyWritten', 'class'), new \Rector\Transform\ValueObject\StringToClassConstant('cache.delete', 'Illuminate\\Cache\\Events\\KeyForgotten', 'class'), new \Rector\Transform\ValueObject\StringToClassConstant('illuminate.query', 'Illuminate\\Database\\Events\\QueryExecuted', 'class'), new \Rector\Transform\ValueObject\StringToClassConstant('illuminate.queue.before', 'Illuminate\\Queue\\Events\\JobProcessing', 'class'), new \Rector\Transform\ValueObject\StringToClassConstant('illuminate.queue.after', 'Illuminate\\Queue\\Events\\JobProcessed', 'class'), new \Rector\Transform\ValueObject\StringToClassConstant('illuminate.queue.failed', 'Illuminate\\Queue\\Events\\JobFailed', 'class'), new \Rector\Transform\ValueObject\StringToClassConstant('illuminate.queue.stopping', 'Illuminate\\Queue\\Events\\WorkerStopping', 'class'), new \Rector\Transform\ValueObject\StringToClassConstant('mailer.sending', 'Illuminate\\Mail\\Events\\MessageSending', 'class'), new \Rector\Transform\ValueObject\StringToClassConstant('router.matched', 'Illuminate\\Routing\\Events\\RouteMatched', 'class')]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Illuminate\\Auth\\Access\\UnauthorizedException' => 'Illuminate\\Auth\\Access\\AuthorizationException', 'Illuminate\\Http\\Exception\\HttpResponseException' => 'Illuminate\\Foundation\\Validation\\ValidationException', 'Illuminate\\Foundation\\Composer' => 'Illuminate\\Support\\Composer']); + $rectorConfig->ruleWithConfiguration(StringToClassConstantRector::class, [new StringToClassConstant('artisan.start', 'Illuminate\\Console\\Events\\ArtisanStarting', 'class'), new StringToClassConstant('auth.attempting', 'Illuminate\\Auth\\Events\\Attempting', 'class'), new StringToClassConstant('auth.login', 'Illuminate\\Auth\\Events\\Login', 'class'), new StringToClassConstant('auth.logout', 'Illuminate\\Auth\\Events\\Logout', 'class'), new StringToClassConstant('cache.missed', 'Illuminate\\Cache\\Events\\CacheMissed', 'class'), new StringToClassConstant('cache.hit', 'Illuminate\\Cache\\Events\\CacheHit', 'class'), new StringToClassConstant('cache.write', 'Illuminate\\Cache\\Events\\KeyWritten', 'class'), new StringToClassConstant('cache.delete', 'Illuminate\\Cache\\Events\\KeyForgotten', 'class'), new StringToClassConstant('illuminate.query', 'Illuminate\\Database\\Events\\QueryExecuted', 'class'), new StringToClassConstant('illuminate.queue.before', 'Illuminate\\Queue\\Events\\JobProcessing', 'class'), new StringToClassConstant('illuminate.queue.after', 'Illuminate\\Queue\\Events\\JobProcessed', 'class'), new StringToClassConstant('illuminate.queue.failed', 'Illuminate\\Queue\\Events\\JobFailed', 'class'), new StringToClassConstant('illuminate.queue.stopping', 'Illuminate\\Queue\\Events\\WorkerStopping', 'class'), new StringToClassConstant('mailer.sending', 'Illuminate\\Mail\\Events\\MessageSending', 'class'), new StringToClassConstant('router.matched', 'Illuminate\\Routing\\Events\\RouteMatched', 'class')]); }; diff --git a/vendor/rector/rector-laravel/config/sets/laravel53.php b/vendor/rector/rector-laravel/config/sets/laravel53.php index 71e945dbc79..67173870a90 100644 --- a/vendor/rector/rector-laravel/config/sets/laravel53.php +++ b/vendor/rector/rector-laravel/config/sets/laravel53.php @@ -5,8 +5,8 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Removing\Rector\Class_\RemoveTraitUseRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Removing\Rector\Class_\RemoveTraitUseRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RemoveTraitUseRector::class, [ # see https://laravel.com/docs/5.3/upgrade 'Illuminate\\Foundation\\Auth\\Access\\AuthorizesResources', ]); diff --git a/vendor/rector/rector-laravel/config/sets/laravel54.php b/vendor/rector/rector-laravel/config/sets/laravel54.php index 9b5932966be..151f0ddf116 100644 --- a/vendor/rector/rector-laravel/config/sets/laravel54.php +++ b/vendor/rector/rector-laravel/config/sets/laravel54.php @@ -10,29 +10,29 @@ use Rector\Renaming\ValueObject\MethodCallRename; use Rector\Transform\Rector\String_\StringToClassConstantRector; use Rector\Transform\ValueObject\StringToClassConstant; # see: https://laravel.com/docs/5.4/upgrade -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\String_\StringToClassConstantRector::class, [new \Rector\Transform\ValueObject\StringToClassConstant('kernel.handled', 'Illuminate\\Foundation\\Http\\Events\\RequestHandled', 'class'), new \Rector\Transform\ValueObject\StringToClassConstant('locale.changed', 'Illuminate\\Foundation\\Events\\LocaleUpdated', 'class'), new \Rector\Transform\ValueObject\StringToClassConstant('illuminate.log', 'Illuminate\\Log\\Events\\MessageLogged', 'class')]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Illuminate\\Console\\AppNamespaceDetectorTrait' => 'Illuminate\\Console\\DetectsApplicationNamespace', 'Illuminate\\Http\\Exception\\HttpResponseException' => 'Illuminate\\Http\\Exceptions\\HttpResponseException', 'Illuminate\\Http\\Exception\\PostTooLargeException' => 'Illuminate\\Http\\Exceptions\\PostTooLargeException', 'Illuminate\\Foundation\\Http\\Middleware\\VerifyPostSize' => 'Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize', 'Symfony\\Component\\HttpFoundation\\Session\\SessionInterface' => 'Illuminate\\Contracts\\Session\\Session']); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [ - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Support\\Collection', 'every', 'nth'), - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany', 'setJoin', 'performJoin'), - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany', 'getRelatedIds', 'allRelatedIds'), - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Routing\\Router', 'middleware', 'aliasMiddleware'), - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Routing\\Route', 'getPath', 'uri'), - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Routing\\Route', 'getUri', 'uri'), - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Routing\\Route', 'getMethods', 'methods'), - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Routing\\Route', 'getParameter', 'parameter'), - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Contracts\\Session\\Session', 'set', 'put'), - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Contracts\\Session\\Session', 'getToken', 'token'), - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Support\\Facades\\Request', 'setSession', 'setLaravelSession'), - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Http\\Request', 'setSession', 'setLaravelSession'), - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Routing\\UrlGenerator', 'forceSchema', 'forceScheme'), - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Validation\\Validator', 'addError', 'addFailure'), - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Validation\\Validator', 'doReplacements', 'makeReplacements'), +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(StringToClassConstantRector::class, [new StringToClassConstant('kernel.handled', 'Illuminate\\Foundation\\Http\\Events\\RequestHandled', 'class'), new StringToClassConstant('locale.changed', 'Illuminate\\Foundation\\Events\\LocaleUpdated', 'class'), new StringToClassConstant('illuminate.log', 'Illuminate\\Log\\Events\\MessageLogged', 'class')]); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Illuminate\\Console\\AppNamespaceDetectorTrait' => 'Illuminate\\Console\\DetectsApplicationNamespace', 'Illuminate\\Http\\Exception\\HttpResponseException' => 'Illuminate\\Http\\Exceptions\\HttpResponseException', 'Illuminate\\Http\\Exception\\PostTooLargeException' => 'Illuminate\\Http\\Exceptions\\PostTooLargeException', 'Illuminate\\Foundation\\Http\\Middleware\\VerifyPostSize' => 'Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize', 'Symfony\\Component\\HttpFoundation\\Session\\SessionInterface' => 'Illuminate\\Contracts\\Session\\Session']); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ + new MethodCallRename('Illuminate\\Support\\Collection', 'every', 'nth'), + new MethodCallRename('Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany', 'setJoin', 'performJoin'), + new MethodCallRename('Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany', 'getRelatedIds', 'allRelatedIds'), + new MethodCallRename('Illuminate\\Routing\\Router', 'middleware', 'aliasMiddleware'), + new MethodCallRename('Illuminate\\Routing\\Route', 'getPath', 'uri'), + new MethodCallRename('Illuminate\\Routing\\Route', 'getUri', 'uri'), + new MethodCallRename('Illuminate\\Routing\\Route', 'getMethods', 'methods'), + new MethodCallRename('Illuminate\\Routing\\Route', 'getParameter', 'parameter'), + new MethodCallRename('Illuminate\\Contracts\\Session\\Session', 'set', 'put'), + new MethodCallRename('Illuminate\\Contracts\\Session\\Session', 'getToken', 'token'), + new MethodCallRename('Illuminate\\Support\\Facades\\Request', 'setSession', 'setLaravelSession'), + new MethodCallRename('Illuminate\\Http\\Request', 'setSession', 'setLaravelSession'), + new MethodCallRename('Illuminate\\Routing\\UrlGenerator', 'forceSchema', 'forceScheme'), + new MethodCallRename('Illuminate\\Validation\\Validator', 'addError', 'addFailure'), + new MethodCallRename('Illuminate\\Validation\\Validator', 'doReplacements', 'makeReplacements'), # https://github.com/laravel/framework/commit/f23ac640fa403ca8d4131c36367b53e123b6b852 - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Foundation\\Testing\\Concerns\\InteractsWithDatabase', 'seeInDatabase', 'assertDatabaseHas'), - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Foundation\\Testing\\Concerns\\InteractsWithDatabase', 'missingFromDatabase', 'assertDatabaseMissing'), - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Foundation\\Testing\\Concerns\\InteractsWithDatabase', 'dontSeeInDatabase', 'assertDatabaseMissing'), - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Foundation\\Testing\\Concerns\\InteractsWithDatabase', 'notSeeInDatabase', 'assertDatabaseMissing'), + new MethodCallRename('Illuminate\\Foundation\\Testing\\Concerns\\InteractsWithDatabase', 'seeInDatabase', 'assertDatabaseHas'), + new MethodCallRename('Illuminate\\Foundation\\Testing\\Concerns\\InteractsWithDatabase', 'missingFromDatabase', 'assertDatabaseMissing'), + new MethodCallRename('Illuminate\\Foundation\\Testing\\Concerns\\InteractsWithDatabase', 'dontSeeInDatabase', 'assertDatabaseMissing'), + new MethodCallRename('Illuminate\\Foundation\\Testing\\Concerns\\InteractsWithDatabase', 'notSeeInDatabase', 'assertDatabaseMissing'), ]); }; diff --git a/vendor/rector/rector-laravel/config/sets/laravel55.php b/vendor/rector/rector-laravel/config/sets/laravel55.php index 1fbb3295101..4a799b9e2ec 100644 --- a/vendor/rector/rector-laravel/config/sets/laravel55.php +++ b/vendor/rector/rector-laravel/config/sets/laravel55.php @@ -10,8 +10,8 @@ use Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector; use Rector\Renaming\ValueObject\MethodCallRename; use Rector\Renaming\ValueObject\RenameProperty; # see: https://laravel.com/docs/5.5/upgrade -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Console\\Command', 'fire', 'handle')]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector::class, [new \Rector\Renaming\ValueObject\RenameProperty('Illuminate\\Database\\Eloquent\\Concerns\\HasEvents', 'events', 'dispatchesEvents'), new \Rector\Renaming\ValueObject\RenameProperty('Illuminate\\Database\\Eloquent\\Relations\\Pivot', 'parent', 'pivotParent')]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Illuminate\\Translation\\LoaderInterface' => 'Illuminate\\Contracts\\Translation\\Loader']); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Illuminate\\Console\\Command', 'fire', 'handle')]); + $rectorConfig->ruleWithConfiguration(RenamePropertyRector::class, [new RenameProperty('Illuminate\\Database\\Eloquent\\Concerns\\HasEvents', 'events', 'dispatchesEvents'), new RenameProperty('Illuminate\\Database\\Eloquent\\Relations\\Pivot', 'parent', 'pivotParent')]); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Illuminate\\Translation\\LoaderInterface' => 'Illuminate\\Contracts\\Translation\\Loader']); }; diff --git a/vendor/rector/rector-laravel/config/sets/laravel56.php b/vendor/rector/rector-laravel/config/sets/laravel56.php index 91ba2fc3a9d..87cd3a193d1 100644 --- a/vendor/rector/rector-laravel/config/sets/laravel56.php +++ b/vendor/rector/rector-laravel/config/sets/laravel56.php @@ -10,7 +10,7 @@ use Rector\Renaming\ValueObject\MethodCallRename; use Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector; use Rector\Visibility\ValueObject\ChangeMethodVisibility; # see: https://laravel.com/docs/5.6/upgrade -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Validation\\ValidatesWhenResolvedTrait', 'validate', 'validateResolved'), new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Contracts\\Validation\\ValidatesWhenResolved', 'validate', 'validateResolved')]); - $rectorConfig->ruleWithConfiguration(\Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector::class, [new \Rector\Visibility\ValueObject\ChangeMethodVisibility('Illuminate\\Routing\\Router', 'addRoute', \Rector\Core\ValueObject\Visibility::PUBLIC), new \Rector\Visibility\ValueObject\ChangeMethodVisibility('Illuminate\\Contracts\\Auth\\Access\\Gate', 'raw', \Rector\Core\ValueObject\Visibility::PUBLIC), new \Rector\Visibility\ValueObject\ChangeMethodVisibility('Illuminate\\Database\\Grammar', 'getDateFormat', \Rector\Core\ValueObject\Visibility::PUBLIC)]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Illuminate\\Validation\\ValidatesWhenResolvedTrait', 'validate', 'validateResolved'), new MethodCallRename('Illuminate\\Contracts\\Validation\\ValidatesWhenResolved', 'validate', 'validateResolved')]); + $rectorConfig->ruleWithConfiguration(ChangeMethodVisibilityRector::class, [new ChangeMethodVisibility('Illuminate\\Routing\\Router', 'addRoute', Visibility::PUBLIC), new ChangeMethodVisibility('Illuminate\\Contracts\\Auth\\Access\\Gate', 'raw', Visibility::PUBLIC), new ChangeMethodVisibility('Illuminate\\Database\\Grammar', 'getDateFormat', Visibility::PUBLIC)]); }; diff --git a/vendor/rector/rector-laravel/config/sets/laravel57.php b/vendor/rector/rector-laravel/config/sets/laravel57.php index 9398bfce074..3e18d4a9e38 100644 --- a/vendor/rector/rector-laravel/config/sets/laravel57.php +++ b/vendor/rector/rector-laravel/config/sets/laravel57.php @@ -18,13 +18,13 @@ use Rector\Removing\ValueObject\ArgumentRemover; use Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector; use Rector\Visibility\ValueObject\ChangeMethodVisibility; # see: https://laravel.com/docs/5.7/upgrade -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector::class, [new \Rector\Visibility\ValueObject\ChangeMethodVisibility('Illuminate\\Routing\\Router', 'addRoute', \Rector\Core\ValueObject\Visibility::PUBLIC), new \Rector\Visibility\ValueObject\ChangeMethodVisibility('Illuminate\\Contracts\\Auth\\Access\\Gate', 'raw', \Rector\Core\ValueObject\Visibility::PUBLIC)]); - $rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class, [new \Rector\Arguments\ValueObject\ArgumentAdder('Illuminate\\Auth\\Middleware\\Authenticate', 'authenticate', 0, 'request'), new \Rector\Arguments\ValueObject\ArgumentAdder('Illuminate\\Foundation\\Auth\\ResetsPasswords', 'sendResetResponse', 0, 'request', null, new \PHPStan\Type\ObjectType('Illuminate\\Http\\Illuminate\\Http')), new \Rector\Arguments\ValueObject\ArgumentAdder('Illuminate\\Foundation\\Auth\\SendsPasswordResetEmails', 'sendResetLinkResponse', 0, 'request', null, new \PHPStan\Type\ObjectType('Illuminate\\Http\\Illuminate\\Http')), new \Rector\Arguments\ValueObject\ArgumentAdder('Illuminate\\Database\\ConnectionInterface', 'select', 2, 'useReadPdo', \true), new \Rector\Arguments\ValueObject\ArgumentAdder('Illuminate\\Database\\ConnectionInterface', 'selectOne', 2, 'useReadPdo', \true)]); - $rectorConfig->rule(\Rector\Laravel\Rector\StaticCall\Redirect301ToPermanentRedirectRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Removing\Rector\ClassMethod\ArgumentRemoverRector::class, [new \Rector\Removing\ValueObject\ArgumentRemover('Illuminate\\Foundation\\Application', 'register', 1, ['name' => 'options'])]); - $rectorConfig->rule(\Rector\Laravel\Rector\ClassMethod\AddParentBootToModelClassMethodRector::class); - $rectorConfig->rule(\Rector\Laravel\Rector\MethodCall\ChangeQueryWhereDateValueWithCarbonRector::class); - $rectorConfig->rule(\Rector\Laravel\Rector\Class_\AddMockConsoleOutputFalseToConsoleTestsRector::class); - $rectorConfig->rule(\Rector\Laravel\Rector\New_\AddGuardToLoginEventRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(ChangeMethodVisibilityRector::class, [new ChangeMethodVisibility('Illuminate\\Routing\\Router', 'addRoute', Visibility::PUBLIC), new ChangeMethodVisibility('Illuminate\\Contracts\\Auth\\Access\\Gate', 'raw', Visibility::PUBLIC)]); + $rectorConfig->ruleWithConfiguration(ArgumentAdderRector::class, [new ArgumentAdder('Illuminate\\Auth\\Middleware\\Authenticate', 'authenticate', 0, 'request'), new ArgumentAdder('Illuminate\\Foundation\\Auth\\ResetsPasswords', 'sendResetResponse', 0, 'request', null, new ObjectType('Illuminate\\Http\\Illuminate\\Http')), new ArgumentAdder('Illuminate\\Foundation\\Auth\\SendsPasswordResetEmails', 'sendResetLinkResponse', 0, 'request', null, new ObjectType('Illuminate\\Http\\Illuminate\\Http')), new ArgumentAdder('Illuminate\\Database\\ConnectionInterface', 'select', 2, 'useReadPdo', \true), new ArgumentAdder('Illuminate\\Database\\ConnectionInterface', 'selectOne', 2, 'useReadPdo', \true)]); + $rectorConfig->rule(Redirect301ToPermanentRedirectRector::class); + $rectorConfig->ruleWithConfiguration(ArgumentRemoverRector::class, [new ArgumentRemover('Illuminate\\Foundation\\Application', 'register', 1, ['name' => 'options'])]); + $rectorConfig->rule(AddParentBootToModelClassMethodRector::class); + $rectorConfig->rule(ChangeQueryWhereDateValueWithCarbonRector::class); + $rectorConfig->rule(AddMockConsoleOutputFalseToConsoleTestsRector::class); + $rectorConfig->rule(AddGuardToLoginEventRector::class); }; diff --git a/vendor/rector/rector-laravel/config/sets/laravel58.php b/vendor/rector/rector-laravel/config/sets/laravel58.php index 2632860fbfe..6da3e30c863 100644 --- a/vendor/rector/rector-laravel/config/sets/laravel58.php +++ b/vendor/rector/rector-laravel/config/sets/laravel58.php @@ -14,10 +14,10 @@ use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration; # https://laravel-news.com/laravel-5-8-deprecates-string-and-array-helpers # https://github.com/laravel/framework/pull/26898 # see: https://laravel.com/docs/5.8/upgrade -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $rectorConfig->import(__DIR__ . '/laravel-array-str-functions-to-static-call.php'); - $rectorConfig->rule(\Rector\Laravel\Rector\StaticCall\MinutesToSecondsInCacheRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::class, [new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Illuminate\\Contracts\\Cache\\Repository', 'put', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Illuminate\\Contracts\\Cache\\Repository', 'forever', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Illuminate\\Contracts\\Cache\\Store', 'put', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Illuminate\\Contracts\\Cache\\Store', 'putMany', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Illuminate\\Contracts\\Cache\\Store', 'forever', new \PHPStan\Type\BooleanType())]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector::class, [new \Rector\Renaming\ValueObject\RenameProperty('Illuminate\\Routing\\UrlGenerator', 'cachedSchema', 'cachedScheme')]); - $rectorConfig->rule(\Rector\Laravel\Rector\Class_\PropertyDeferToDeferrableProviderToRector::class); + $rectorConfig->rule(MinutesToSecondsInCacheRector::class); + $rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [new AddReturnTypeDeclaration('Illuminate\\Contracts\\Cache\\Repository', 'put', new BooleanType()), new AddReturnTypeDeclaration('Illuminate\\Contracts\\Cache\\Repository', 'forever', new BooleanType()), new AddReturnTypeDeclaration('Illuminate\\Contracts\\Cache\\Store', 'put', new BooleanType()), new AddReturnTypeDeclaration('Illuminate\\Contracts\\Cache\\Store', 'putMany', new BooleanType()), new AddReturnTypeDeclaration('Illuminate\\Contracts\\Cache\\Store', 'forever', new BooleanType())]); + $rectorConfig->ruleWithConfiguration(RenamePropertyRector::class, [new RenameProperty('Illuminate\\Routing\\UrlGenerator', 'cachedSchema', 'cachedScheme')]); + $rectorConfig->rule(PropertyDeferToDeferrableProviderToRector::class); }; diff --git a/vendor/rector/rector-laravel/config/sets/laravel60.php b/vendor/rector/rector-laravel/config/sets/laravel60.php index f9144c9a15d..d2b9597a8e3 100644 --- a/vendor/rector/rector-laravel/config/sets/laravel60.php +++ b/vendor/rector/rector-laravel/config/sets/laravel60.php @@ -17,36 +17,36 @@ use Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector; use Rector\Visibility\ValueObject\ChangeMethodVisibility; # see https://laravel.com/docs/6.x/upgrade # https://github.com/laravel/docs/pull/5531/files -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { # https://github.com/laravel/framework/commit/67a38ba0fa2acfbd1f4af4bf7d462bb4419cc091 - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename( + $rectorConfig->rule(ParamTypeDeclarationRector::class); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename( 'Illuminate\\Auth\\Access\\Gate', # https://github.com/laravel/framework/commit/69de466ddc25966a0f6551f48acab1afa7bb9424 'access', 'inspect' - ), new \Rector\Renaming\ValueObject\MethodCallRename( + ), new MethodCallRename( 'Illuminate\\Support\\Facades\\Lang', # https://github.com/laravel/framework/commit/efbe23c4116f86846ad6edc0d95cd56f4175a446 'trans', 'get' - ), new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Support\\Facades\\Lang', 'transChoice', 'choice'), new \Rector\Renaming\ValueObject\MethodCallRename( + ), new MethodCallRename('Illuminate\\Support\\Facades\\Lang', 'transChoice', 'choice'), new MethodCallRename( 'Illuminate\\Translation\\Translator', # https://github.com/laravel/framework/commit/697b898a1c89881c91af83ecc4493fa681e2aa38 'getFromJson', 'get' )]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\StaticCall\RenameStaticMethodRector::class, [ + $rectorConfig->ruleWithConfiguration(RenameStaticMethodRector::class, [ // https://github.com/laravel/framework/commit/55785d3514a8149d4858acef40c56a31b6b2ccd1 - new \Rector\Renaming\ValueObject\RenameStaticMethod('Illuminate\\Support\\Facades\\Input', 'get', 'Illuminate\\Support\\Facades\\Request', 'input'), + new RenameStaticMethod('Illuminate\\Support\\Facades\\Input', 'get', 'Illuminate\\Support\\Facades\\Request', 'input'), ]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Illuminate\\Support\\Facades\\Input' => 'Illuminate\\Support\\Facades\\Request']); - $rectorConfig->ruleWithConfiguration(\Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector::class, [new \Rector\Visibility\ValueObject\ChangeMethodVisibility('Illuminate\\Foundation\\Http\\FormRequest', 'validationData', \Rector\Core\ValueObject\Visibility::PUBLIC)]); - $rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class, [ + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Illuminate\\Support\\Facades\\Input' => 'Illuminate\\Support\\Facades\\Request']); + $rectorConfig->ruleWithConfiguration(ChangeMethodVisibilityRector::class, [new ChangeMethodVisibility('Illuminate\\Foundation\\Http\\FormRequest', 'validationData', Visibility::PUBLIC)]); + $rectorConfig->ruleWithConfiguration(ArgumentAdderRector::class, [ // https://github.com/laravel/framework/commit/6c1e014943a508afb2c10869c3175f7783a004e1 - new \Rector\Arguments\ValueObject\ArgumentAdder('Illuminate\\Database\\Capsule\\Manager', 'table', 1, 'as', null), - new \Rector\Arguments\ValueObject\ArgumentAdder('Illuminate\\Database\\Connection', 'table', 1, 'as', null), - new \Rector\Arguments\ValueObject\ArgumentAdder('Illuminate\\Database\\ConnectionInterface', 'table', 1, 'as', null), - new \Rector\Arguments\ValueObject\ArgumentAdder('Illuminate\\Database\\Query\\Builder', 'from', 1, 'as', null), + new ArgumentAdder('Illuminate\\Database\\Capsule\\Manager', 'table', 1, 'as', null), + new ArgumentAdder('Illuminate\\Database\\Connection', 'table', 1, 'as', null), + new ArgumentAdder('Illuminate\\Database\\ConnectionInterface', 'table', 1, 'as', null), + new ArgumentAdder('Illuminate\\Database\\Query\\Builder', 'from', 1, 'as', null), ]); }; diff --git a/vendor/rector/rector-laravel/config/sets/laravel70.php b/vendor/rector/rector-laravel/config/sets/laravel70.php index 6a5d4de8b08..3a0d6745235 100644 --- a/vendor/rector/rector-laravel/config/sets/laravel70.php +++ b/vendor/rector/rector-laravel/config/sets/laravel70.php @@ -13,20 +13,20 @@ use Rector\Renaming\ValueObject\MethodCallRename; use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector; use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration; # see https://laravel.com/docs/7.x/upgrade -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { # https://github.com/laravel/framework/pull/30610/files - $rectorConfig->ruleWithConfiguration(\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::class, [new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Illuminate\\Contracts\\Debug\\ExceptionHandler', 'report', 0, new \PHPStan\Type\ObjectType('Throwable')), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Illuminate\\Contracts\\Debug\\ExceptionHandler', 'shouldReport', 0, new \PHPStan\Type\ObjectType('Throwable')), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Illuminate\\Contracts\\Debug\\ExceptionHandler', 'render', 1, new \PHPStan\Type\ObjectType('Throwable')), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Illuminate\\Contracts\\Debug\\ExceptionHandler', 'renderForConsole', 1, new \PHPStan\Type\ObjectType('Throwable'))]); + $rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [new AddParamTypeDeclaration('Illuminate\\Contracts\\Debug\\ExceptionHandler', 'report', 0, new ObjectType('Throwable')), new AddParamTypeDeclaration('Illuminate\\Contracts\\Debug\\ExceptionHandler', 'shouldReport', 0, new ObjectType('Throwable')), new AddParamTypeDeclaration('Illuminate\\Contracts\\Debug\\ExceptionHandler', 'render', 1, new ObjectType('Throwable')), new AddParamTypeDeclaration('Illuminate\\Contracts\\Debug\\ExceptionHandler', 'renderForConsole', 1, new ObjectType('Throwable'))]); # https://github.com/laravel/framework/pull/30471/files - $rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class, [new \Rector\Arguments\ValueObject\ArgumentAdder('Illuminate\\Contracts\\Routing\\UrlRoutable', 'resolveRouteBinding', 1, 'field', null)]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [ + $rectorConfig->ruleWithConfiguration(ArgumentAdderRector::class, [new ArgumentAdder('Illuminate\\Contracts\\Routing\\UrlRoutable', 'resolveRouteBinding', 1, 'field', null)]); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ # https://github.com/laravel/framework/commit/aece7d78f3d28b2cdb63185dcc4a9b6092841310 - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Support\\Facades\\Blade', 'component', 'aliasComponent'), + new MethodCallRename('Illuminate\\Support\\Facades\\Blade', 'component', 'aliasComponent'), # https://github.com/laravel/framework/pull/31463/files - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Database\\Eloquent\\Concerns\\HidesAttributes', 'addHidden', 'makeHidden'), + new MethodCallRename('Illuminate\\Database\\Eloquent\\Concerns\\HidesAttributes', 'addHidden', 'makeHidden'), # https://github.com/laravel/framework/pull/30348/files - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Database\\Eloquent\\Concerns\\HidesAttributes', 'addVisible', 'makeVisible'), + new MethodCallRename('Illuminate\\Database\\Eloquent\\Concerns\\HidesAttributes', 'addVisible', 'makeVisible'), ]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, [ + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ # https://github.com/laravel/framework/pull/30619/files 'Illuminate\\Http\\Resources\\Json\\Resource' => 'Illuminate\\Http\\Resources\\Json\\JsonResource', # https://github.com/laravel/framework/pull/31050/files diff --git a/vendor/rector/rector-laravel/config/sets/laravel80.php b/vendor/rector/rector-laravel/config/sets/laravel80.php index e038f79d5da..ef720b87e62 100644 --- a/vendor/rector/rector-laravel/config/sets/laravel80.php +++ b/vendor/rector/rector-laravel/config/sets/laravel80.php @@ -17,41 +17,41 @@ use Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector; use Rector\Renaming\ValueObject\MethodCallRename; use Rector\Renaming\ValueObject\RenameProperty; # see https://laravel.com/docs/8.x/upgrade -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { # https://github.com/laravel/framework/commit/4d228d6e9dbcbd4d97c45665980d8b8c685b27e6 - $rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class, [new \Rector\Arguments\ValueObject\ArgumentAdder( + $rectorConfig->ruleWithConfiguration(ArgumentAdderRector::class, [new ArgumentAdder( 'Illuminate\\Contracts\\Database\\Eloquent\\Castable', 'castUsing', 0, 'arguments', [], // TODO: Add argument without default value - new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()) + new ArrayType(new MixedType(), new MixedType()) )]); # https://github.com/laravel/framework/commit/46084d946cdcd1ae1f32fc87a4f1cc9e3a5bccf6 - $rectorConfig->ruleWithConfiguration(\Rector\Laravel\Rector\ClassMethod\AddArgumentDefaultValueRector::class, [new \Rector\Laravel\ValueObject\AddArgumentDefaultValue('Illuminate\\Contracts\\Events\\Dispatcher', 'listen', 1, null)]); + $rectorConfig->ruleWithConfiguration(AddArgumentDefaultValueRector::class, [new AddArgumentDefaultValue('Illuminate\\Contracts\\Events\\Dispatcher', 'listen', 1, null)]); # https://github.com/laravel/framework/commit/f1289515b27e93248c09f04e3011bb7ce21b2737 - $rectorConfig->rule(\Rector\Laravel\Rector\ClassMethod\AddParentRegisterToEventServiceProviderRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector::class, [ + $rectorConfig->rule(AddParentRegisterToEventServiceProviderRector::class); + $rectorConfig->ruleWithConfiguration(RenamePropertyRector::class, [ # https://github.com/laravel/framework/pull/32092/files - new \Rector\Renaming\ValueObject\RenameProperty('Illuminate\\Support\\Manager', 'app', 'container'), + new RenameProperty('Illuminate\\Support\\Manager', 'app', 'container'), # https://github.com/laravel/framework/commit/4656c2cf012ac62739ab5ea2bce006e1e9fe8f09 - new \Rector\Renaming\ValueObject\RenameProperty('Illuminate\\Contracts\\Queue\\ShouldQueue', 'retryAfter', 'backoff'), + new RenameProperty('Illuminate\\Contracts\\Queue\\ShouldQueue', 'retryAfter', 'backoff'), # https://github.com/laravel/framework/commit/12c35e57c0a6da96f36ad77f88f083e96f927205 - new \Rector\Renaming\ValueObject\RenameProperty('Illuminate\\Contracts\\Queue\\ShouldQueue', 'timeoutAt', 'retryUntil'), + new RenameProperty('Illuminate\\Contracts\\Queue\\ShouldQueue', 'timeoutAt', 'retryUntil'), ]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [ + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ # https://github.com/laravel/framework/pull/32092/files - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Mail\\PendingMail', 'sendNow', 'send'), + new MethodCallRename('Illuminate\\Mail\\PendingMail', 'sendNow', 'send'), # https://github.com/laravel/framework/commit/4656c2cf012ac62739ab5ea2bce006e1e9fe8f09 - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Contracts\\Queue\\ShouldQueue', 'retryAfter', 'backoff'), + new MethodCallRename('Illuminate\\Contracts\\Queue\\ShouldQueue', 'retryAfter', 'backoff'), # https://github.com/laravel/framework/commit/12c35e57c0a6da96f36ad77f88f083e96f927205 - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Contracts\\Queue\\ShouldQueue', 'timeoutAt', 'retryUntil'), + new MethodCallRename('Illuminate\\Contracts\\Queue\\ShouldQueue', 'timeoutAt', 'retryUntil'), # https://github.com/laravel/framework/commit/f9374fa5fb0450721fb2f90e96adef9d409b112c - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Testing\\TestResponse', 'decodeResponseJson', 'json'), + new MethodCallRename('Illuminate\\Testing\\TestResponse', 'decodeResponseJson', 'json'), # https://github.com/laravel/framework/commit/fd662d4699776a94e7ead2a42e82c340363fc5a6 - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Testing\\TestResponse', 'assertExactJson', 'assertSimilarJson'), + new MethodCallRename('Illuminate\\Testing\\TestResponse', 'assertExactJson', 'assertSimilarJson'), ]); # https://github.com/laravel/framework/commit/de662daf75207a8dd69565ed3630def74bc538d3 - $rectorConfig->rule(\Rector\Laravel\Rector\MethodCall\RemoveAllOnDispatchingMethodsWithJobChainingRector::class); + $rectorConfig->rule(RemoveAllOnDispatchingMethodsWithJobChainingRector::class); }; diff --git a/vendor/rector/rector-laravel/config/sets/laravel90.php b/vendor/rector/rector-laravel/config/sets/laravel90.php index ff772e122c8..ab685d85bd1 100644 --- a/vendor/rector/rector-laravel/config/sets/laravel90.php +++ b/vendor/rector/rector-laravel/config/sets/laravel90.php @@ -12,38 +12,38 @@ use Rector\Renaming\ValueObject\MethodCallRename; use Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector; use Rector\Visibility\ValueObject\ChangeMethodVisibility; # see https://laravel.com/docs/9.x/upgrade -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { // https://github.com/laravel/framework/commit/8f9ddea4481717943ed4ecff96d86b703c81a87d - $rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class, [new \Rector\Arguments\ValueObject\ArgumentAdder('Illuminate\\Contracts\\Foundation\\Application', 'storagePath', 0, 'path', '')]); + $rectorConfig->ruleWithConfiguration(ArgumentAdderRector::class, [new ArgumentAdder('Illuminate\\Contracts\\Foundation\\Application', 'storagePath', 0, 'path', '')]); // https://github.com/laravel/framework/commit/e6c8aaea886d35cc55bd3469f1a95ad56d53e474 - $rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class, [new \Rector\Arguments\ValueObject\ArgumentAdder('Illuminate\\Foundation\\Application', 'langPath', 0, 'path', '')]); + $rectorConfig->ruleWithConfiguration(ArgumentAdderRector::class, [new ArgumentAdder('Illuminate\\Foundation\\Application', 'langPath', 0, 'path', '')]); // https://github.com/laravel/framework/commit/e095ac0e928b5620f33c9b60816fde5ece867d32 - $rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class, [new \Rector\Arguments\ValueObject\ArgumentAdder('Illuminate\\Database\\Eloquent\\Model', 'touch', 0, 'attribute')]); + $rectorConfig->ruleWithConfiguration(ArgumentAdderRector::class, [new ArgumentAdder('Illuminate\\Database\\Eloquent\\Model', 'touch', 0, 'attribute')]); // https://github.com/laravel/framework/commit/6daecf43dd931dc503e410645ff4a7d611e3371f - $rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class, [new \Rector\Arguments\ValueObject\ArgumentAdder('Illuminate\\Queue\\Failed\\FailedJobProviderInterface', 'flush', 0, 'hours')]); + $rectorConfig->ruleWithConfiguration(ArgumentAdderRector::class, [new ArgumentAdder('Illuminate\\Queue\\Failed\\FailedJobProviderInterface', 'flush', 0, 'hours')]); // https://github.com/laravel/framework/commit/8b40e8b7cba2fbf8337dfc05e3c6a62ae457e889 - $rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class, [new \Rector\Arguments\ValueObject\ArgumentAdder('Illuminate\\Foundation\\Http\\FormRequest', 'validated', 0, 'key'), new \Rector\Arguments\ValueObject\ArgumentAdder('Illuminate\\Foundation\\Http\\FormRequest', 'validated', 1, 'default')]); + $rectorConfig->ruleWithConfiguration(ArgumentAdderRector::class, [new ArgumentAdder('Illuminate\\Foundation\\Http\\FormRequest', 'validated', 0, 'key'), new ArgumentAdder('Illuminate\\Foundation\\Http\\FormRequest', 'validated', 1, 'default')]); // https://github.com/laravel/framework/commit/84c78b9f5f3dad58f92161069e6482f7267ffdb6 - $rectorConfig->ruleWithConfiguration(\Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector::class, [new \Rector\Visibility\ValueObject\ChangeMethodVisibility('Illuminate\\Foundation\\Exceptions\\Handler', 'ignore', \Rector\Core\ValueObject\Visibility::PUBLIC)]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [ + $rectorConfig->ruleWithConfiguration(ChangeMethodVisibilityRector::class, [new ChangeMethodVisibility('Illuminate\\Foundation\\Exceptions\\Handler', 'ignore', Visibility::PUBLIC)]); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ // https://github.com/laravel/framework/commit/9b4f011fb95c70444812f61d46c8e21fb5b66dd9 - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Support\\Enumerable', 'reduceWithKeys', 'reduce'), + new MethodCallRename('Illuminate\\Support\\Enumerable', 'reduceWithKeys', 'reduce'), // https://github.com/laravel/framework/commit/02365bb5ebafeeaef28b5eb659466c56b2634c65 - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Support\\Enumerable', 'reduceMany', 'reduceSpread'), + new MethodCallRename('Illuminate\\Support\\Enumerable', 'reduceMany', 'reduceSpread'), // https://github.com/laravel/framework/commit/097107ab50ce754c709313fc75a6f1f4a9389bfc - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Mail\\Message', 'getSwiftMessage', 'getSymfonyMessage'), + new MethodCallRename('Illuminate\\Mail\\Message', 'getSwiftMessage', 'getSymfonyMessage'), // https://github.com/laravel/framework/commit/097107ab50ce754c709313fc75a6f1f4a9389bfc - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Mail\\Mailable', 'withSwiftMessage', 'withSymfonyMessage'), + new MethodCallRename('Illuminate\\Mail\\Mailable', 'withSwiftMessage', 'withSymfonyMessage'), // https://github.com/laravel/framework/commit/097107ab50ce754c709313fc75a6f1f4a9389bfc - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Notifications\\Messages\\MailMessage', 'withSwiftMessage', 'withSymfonyMessage'), + new MethodCallRename('Illuminate\\Notifications\\Messages\\MailMessage', 'withSwiftMessage', 'withSymfonyMessage'), // https://github.com/laravel/framework/commit/097107ab50ce754c709313fc75a6f1f4a9389bfc - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Mail\\Mailer', 'getSwiftMailer', 'getSymfonyTransport'), + new MethodCallRename('Illuminate\\Mail\\Mailer', 'getSwiftMailer', 'getSymfonyTransport'), // https://github.com/laravel/framework/commit/097107ab50ce754c709313fc75a6f1f4a9389bfc - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Mail\\Mailer', 'setSwiftMailer', 'setSymfonyTransport'), + new MethodCallRename('Illuminate\\Mail\\Mailer', 'setSwiftMailer', 'setSymfonyTransport'), // https://github.com/laravel/framework/commit/097107ab50ce754c709313fc75a6f1f4a9389bfc - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Mail\\MailManager', 'createTransport', 'createSymfonyTransport'), + new MethodCallRename('Illuminate\\Mail\\MailManager', 'createTransport', 'createSymfonyTransport'), // https://github.com/laravel/framework/commit/59ff96c269f691bfd197090675c0235700f750b2 // https://github.com/laravel/framework/commit/9894c2c64dc70f7dfda2ac46dfdaa8769ce4596a - new \Rector\Renaming\ValueObject\MethodCallRename('Illuminate\\Testing\\TestResponse', 'assertDeleted', 'assertModelMissing'), + new MethodCallRename('Illuminate\\Testing\\TestResponse', 'assertDeleted', 'assertModelMissing'), ]); }; diff --git a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-51.php b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-51.php index f3c051c6b59..db3634408ee 100644 --- a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-51.php +++ b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-51.php @@ -5,6 +5,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Laravel\Set\LaravelSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Laravel\Set\LaravelSetList::LARAVEL_50, \Rector\Laravel\Set\LaravelSetList::LARAVEL_51]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([LaravelSetList::LARAVEL_50, LaravelSetList::LARAVEL_51]); }; diff --git a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-52.php b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-52.php index 19996ef3545..6895a650dcb 100644 --- a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-52.php +++ b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-52.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Laravel\Set\LaravelLevelSetList; use Rector\Laravel\Set\LaravelSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Laravel\Set\LaravelSetList::LARAVEL_52, \Rector\Laravel\Set\LaravelLevelSetList::UP_TO_LARAVEL_51]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([LaravelSetList::LARAVEL_52, LaravelLevelSetList::UP_TO_LARAVEL_51]); }; diff --git a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-53.php b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-53.php index 9ee825a6a8c..7d9f28cba23 100644 --- a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-53.php +++ b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-53.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Laravel\Set\LaravelLevelSetList; use Rector\Laravel\Set\LaravelSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Laravel\Set\LaravelSetList::LARAVEL_53, \Rector\Laravel\Set\LaravelLevelSetList::UP_TO_LARAVEL_52]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([LaravelSetList::LARAVEL_53, LaravelLevelSetList::UP_TO_LARAVEL_52]); }; diff --git a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-54.php b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-54.php index 6aa86fcca4e..479992f2e68 100644 --- a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-54.php +++ b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-54.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Laravel\Set\LaravelLevelSetList; use Rector\Laravel\Set\LaravelSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Laravel\Set\LaravelSetList::LARAVEL_54, \Rector\Laravel\Set\LaravelLevelSetList::UP_TO_LARAVEL_53]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([LaravelSetList::LARAVEL_54, LaravelLevelSetList::UP_TO_LARAVEL_53]); }; diff --git a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-55.php b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-55.php index 9c7b2d8e3dd..eddde9552e0 100644 --- a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-55.php +++ b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-55.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Laravel\Set\LaravelLevelSetList; use Rector\Laravel\Set\LaravelSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Laravel\Set\LaravelSetList::LARAVEL_55, \Rector\Laravel\Set\LaravelLevelSetList::UP_TO_LARAVEL_54]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([LaravelSetList::LARAVEL_55, LaravelLevelSetList::UP_TO_LARAVEL_54]); }; diff --git a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-56.php b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-56.php index 949202c0840..6a41fd00afe 100644 --- a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-56.php +++ b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-56.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Laravel\Set\LaravelLevelSetList; use Rector\Laravel\Set\LaravelSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Laravel\Set\LaravelSetList::LARAVEL_56, \Rector\Laravel\Set\LaravelLevelSetList::UP_TO_LARAVEL_55]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([LaravelSetList::LARAVEL_56, LaravelLevelSetList::UP_TO_LARAVEL_55]); }; diff --git a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-57.php b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-57.php index 90eff39d136..0c5ef7b69bf 100644 --- a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-57.php +++ b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-57.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Laravel\Set\LaravelLevelSetList; use Rector\Laravel\Set\LaravelSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Laravel\Set\LaravelSetList::LARAVEL_57, \Rector\Laravel\Set\LaravelLevelSetList::UP_TO_LARAVEL_56]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([LaravelSetList::LARAVEL_57, LaravelLevelSetList::UP_TO_LARAVEL_56]); }; diff --git a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-58.php b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-58.php index 3f941b63ce1..48f6c7ed6d5 100644 --- a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-58.php +++ b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-58.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Laravel\Set\LaravelLevelSetList; use Rector\Laravel\Set\LaravelSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Laravel\Set\LaravelSetList::LARAVEL_58, \Rector\Laravel\Set\LaravelLevelSetList::UP_TO_LARAVEL_57]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([LaravelSetList::LARAVEL_58, LaravelLevelSetList::UP_TO_LARAVEL_57]); }; diff --git a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-60.php b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-60.php index b620e842ad0..925f2371c5f 100644 --- a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-60.php +++ b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-60.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Laravel\Set\LaravelLevelSetList; use Rector\Laravel\Set\LaravelSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Laravel\Set\LaravelSetList::LARAVEL_60, \Rector\Laravel\Set\LaravelLevelSetList::UP_TO_LARAVEL_58]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([LaravelSetList::LARAVEL_60, LaravelLevelSetList::UP_TO_LARAVEL_58]); }; diff --git a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-70.php b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-70.php index 483e9f24800..73986b66241 100644 --- a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-70.php +++ b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-70.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Laravel\Set\LaravelLevelSetList; use Rector\Laravel\Set\LaravelSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Laravel\Set\LaravelSetList::LARAVEL_70, \Rector\Laravel\Set\LaravelLevelSetList::UP_TO_LARAVEL_60]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([LaravelSetList::LARAVEL_70, LaravelLevelSetList::UP_TO_LARAVEL_60]); }; diff --git a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-80.php b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-80.php index 731ecbe91d8..98604f39aa9 100644 --- a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-80.php +++ b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-80.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Laravel\Set\LaravelLevelSetList; use Rector\Laravel\Set\LaravelSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Laravel\Set\LaravelSetList::LARAVEL_80, \Rector\Laravel\Set\LaravelLevelSetList::UP_TO_LARAVEL_70]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([LaravelSetList::LARAVEL_80, LaravelLevelSetList::UP_TO_LARAVEL_70]); }; diff --git a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-90.php b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-90.php index 9b50942c8d7..b07fdadafcd 100644 --- a/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-90.php +++ b/vendor/rector/rector-laravel/config/sets/level/up-to-laravel-90.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Laravel\Set\LaravelLevelSetList; use Rector\Laravel\Set\LaravelSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Laravel\Set\LaravelSetList::LARAVEL_90, \Rector\Laravel\Set\LaravelLevelSetList::UP_TO_LARAVEL_80]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([LaravelSetList::LARAVEL_90, LaravelLevelSetList::UP_TO_LARAVEL_80]); }; diff --git a/vendor/rector/rector-laravel/monorepo-builder.php b/vendor/rector/rector-laravel/monorepo-builder.php index add4c2a823d..e88fd1336d6 100644 --- a/vendor/rector/rector-laravel/monorepo-builder.php +++ b/vendor/rector/rector-laravel/monorepo-builder.php @@ -3,13 +3,13 @@ declare (strict_types=1); namespace RectorPrefix20220607; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\PushTagReleaseWorker; use RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\TagVersionReleaseWorker; -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +return static function (ContainerConfigurator $containerConfigurator) : void { $services = $containerConfigurator->services(); $services->defaults()->autowire(); // @see https://github.com/symplify/monorepo-builder#6-release-flow - $services->set(\RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\TagVersionReleaseWorker::class); - $services->set(\RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\PushTagReleaseWorker::class); + $services->set(TagVersionReleaseWorker::class); + $services->set(PushTagReleaseWorker::class); }; diff --git a/vendor/rector/rector-laravel/rector.php b/vendor/rector/rector-laravel/rector.php index 1b91ef9806e..3d0f059da24 100644 --- a/vendor/rector/rector-laravel/rector.php +++ b/vendor/rector/rector-laravel/rector.php @@ -7,7 +7,7 @@ use Rector\Config\RectorConfig; use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $rectorConfig->importNames(); $rectorConfig->paths([__DIR__ . '/src', __DIR__ . '/tests']); $rectorConfig->skip([ @@ -16,7 +16,7 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { '*/Fixture/*', // skip for handle scoped, like in the rector-src as well // @see https://github.com/rectorphp/rector-src/blob/7f73cf017214257c170d34db3af7283eaeeab657/rector.php#L71 - \Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class, + StringClassNameToClassConstantRector::class, ]); - $rectorConfig->sets([\Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_81, \Rector\Set\ValueObject\SetList::DEAD_CODE, \Rector\Set\ValueObject\SetList::CODE_QUALITY, \Rector\Set\ValueObject\SetList::NAMING]); + $rectorConfig->sets([LevelSetList::UP_TO_PHP_81, SetList::DEAD_CODE, SetList::CODE_QUALITY, SetList::NAMING]); }; diff --git a/vendor/rector/rector-laravel/src/NodeFactory/AppAssignFactory.php b/vendor/rector/rector-laravel/src/NodeFactory/AppAssignFactory.php index cb18ca496dd..167a1351ec2 100644 --- a/vendor/rector/rector-laravel/src/NodeFactory/AppAssignFactory.php +++ b/vendor/rector/rector-laravel/src/NodeFactory/AppAssignFactory.php @@ -18,23 +18,23 @@ final class AppAssignFactory * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory */ private $phpDocInfoFactory; - public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory) + public function __construct(PhpDocInfoFactory $phpDocInfoFactory) { $this->phpDocInfoFactory = $phpDocInfoFactory; } - public function createAssignExpression(\Rector\Laravel\ValueObject\ServiceNameTypeAndVariableName $serviceNameTypeAndVariableName, \PhpParser\Node\Expr $expr) : \PhpParser\Node\Stmt\Expression + public function createAssignExpression(ServiceNameTypeAndVariableName $serviceNameTypeAndVariableName, Expr $expr) : Expression { - $variable = new \PhpParser\Node\Expr\Variable($serviceNameTypeAndVariableName->getVariableName()); - $assign = new \PhpParser\Node\Expr\Assign($variable, $expr); - $expression = new \PhpParser\Node\Stmt\Expression($assign); + $variable = new Variable($serviceNameTypeAndVariableName->getVariableName()); + $assign = new Assign($variable, $expr); + $expression = new Expression($assign); $this->decorateWithVarAnnotation($expression, $serviceNameTypeAndVariableName); return $expression; } - private function decorateWithVarAnnotation(\PhpParser\Node\Stmt\Expression $expression, \Rector\Laravel\ValueObject\ServiceNameTypeAndVariableName $serviceNameTypeAndVariableName) : void + private function decorateWithVarAnnotation(Expression $expression, ServiceNameTypeAndVariableName $serviceNameTypeAndVariableName) : void { $phpDocInfo = $this->phpDocInfoFactory->createEmpty($expression); - $fullyQualifiedIdentifierTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\FullyQualifiedIdentifierTypeNode($serviceNameTypeAndVariableName->getType()); - $varTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode($fullyQualifiedIdentifierTypeNode, '$' . $serviceNameTypeAndVariableName->getVariableName(), ''); + $fullyQualifiedIdentifierTypeNode = new FullyQualifiedIdentifierTypeNode($serviceNameTypeAndVariableName->getType()); + $varTagValueNode = new VarTagValueNode($fullyQualifiedIdentifierTypeNode, '$' . $serviceNameTypeAndVariableName->getVariableName(), ''); $phpDocInfo->addTagValueNode($varTagValueNode); $phpDocInfo->makeSingleLined(); } diff --git a/vendor/rector/rector-laravel/src/NodeFactory/ModelFactoryNodeFactory.php b/vendor/rector/rector-laravel/src/NodeFactory/ModelFactoryNodeFactory.php index a63cbf1cd00..59bdbf13bcd 100644 --- a/vendor/rector/rector-laravel/src/NodeFactory/ModelFactoryNodeFactory.php +++ b/vendor/rector/rector-laravel/src/NodeFactory/ModelFactoryNodeFactory.php @@ -49,56 +49,56 @@ final class ModelFactoryNodeFactory * @var \Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser */ private $simpleCallableNodeTraverser; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser) + public function __construct(NodeNameResolver $nodeNameResolver, NodeFactory $nodeFactory, ValueResolver $valueResolver, SimpleCallableNodeTraverser $simpleCallableNodeTraverser) { $this->nodeNameResolver = $nodeNameResolver; $this->nodeFactory = $nodeFactory; $this->valueResolver = $valueResolver; $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; } - public function createEmptyFactory(string $name, \PhpParser\Node\Expr $expr) : \PhpParser\Node\Stmt\Class_ + public function createEmptyFactory(string $name, Expr $expr) : Class_ { - $class = new \PhpParser\Node\Stmt\Class_($name . 'Factory'); - $class->extends = new \PhpParser\Node\Name\FullyQualified('Illuminate\\Database\\Eloquent\\Factories\\Factory'); - $propertyBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\PropertyBuilder('model'); + $class = new Class_($name . 'Factory'); + $class->extends = new FullyQualified('Illuminate\\Database\\Eloquent\\Factories\\Factory'); + $propertyBuilder = new PropertyBuilder('model'); $propertyBuilder->makeProtected(); $propertyBuilder->setDefault($expr); $property = $propertyBuilder->getNode(); $class->stmts[] = $property; // decorate with namespaced names - $nameResolver = new \PhpParser\NodeVisitor\NameResolver(null, ['replaceNodes' => \false, 'preserveOriginalNames' => \true]); - $nodeTraverser = new \PhpParser\NodeTraverser(); + $nameResolver = new NameResolver(null, ['replaceNodes' => \false, 'preserveOriginalNames' => \true]); + $nodeTraverser = new NodeTraverser(); $nodeTraverser->addVisitor($nameResolver); $nodeTraverser->traverse([$class]); return $class; } - public function createDefinition(\PhpParser\Node\Expr\Closure $closure) : \PhpParser\Node\Stmt\ClassMethod + public function createDefinition(Closure $closure) : ClassMethod { if (isset($closure->params[0])) { $this->fakerVariableToPropertyFetch($closure->stmts, $closure->params[0]); } return $this->createPublicMethod('definition', $closure->stmts); } - public function createStateMethod(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node\Stmt\ClassMethod + public function createStateMethod(MethodCall $methodCall) : ?ClassMethod { if (!isset($methodCall->args[2])) { return null; } - if (!$methodCall->args[2] instanceof \PhpParser\Node\Arg) { + if (!$methodCall->args[2] instanceof Arg) { return null; } $thirdArgValue = $methodCall->args[2]->value; // the third argument may be closure or array - if ($thirdArgValue instanceof \PhpParser\Node\Expr\Closure && isset($thirdArgValue->params[0])) { + if ($thirdArgValue instanceof Closure && isset($thirdArgValue->params[0])) { $this->fakerVariableToPropertyFetch($thirdArgValue->stmts, $thirdArgValue->params[0]); unset($thirdArgValue->params[0]); } $expr = $this->nodeFactory->createMethodCall(self::THIS, 'state', [$methodCall->args[2]]); - $return = new \PhpParser\Node\Stmt\Return_($expr); + $return = new Return_($expr); if (!isset($methodCall->args[1])) { return null; } - if (!$methodCall->args[1] instanceof \PhpParser\Node\Arg) { + if (!$methodCall->args[1] instanceof Arg) { return null; } $methodName = $this->valueResolver->getValue($methodCall->args[1]->value); @@ -107,15 +107,15 @@ final class ModelFactoryNodeFactory } return $this->createPublicMethod($methodName, [$return]); } - public function createEmptyConfigure() : \PhpParser\Node\Stmt\ClassMethod + public function createEmptyConfigure() : ClassMethod { - $return = new \PhpParser\Node\Stmt\Return_(new \PhpParser\Node\Expr\Variable(self::THIS)); + $return = new Return_(new Variable(self::THIS)); return $this->createPublicMethod('configure', [$return]); } - public function appendConfigure(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $name, \PhpParser\Node\Expr\Closure $closure) : void + public function appendConfigure(ClassMethod $classMethod, string $name, Closure $closure) : void { - $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (\PhpParser\Node $node) use($closure, $name) : ?Return_ { - if (!$node instanceof \PhpParser\Node\Stmt\Return_) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) use($closure, $name) : ?Return_ { + if (!$node instanceof Return_) { return null; } if ($node->expr === null) { @@ -133,10 +133,10 @@ final class ModelFactoryNodeFactory /** * @param Node\Stmt[] $stmts */ - private function fakerVariableToPropertyFetch(array $stmts, \PhpParser\Node\Param $param) : void + private function fakerVariableToPropertyFetch(array $stmts, Param $param) : void { - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmts, function (\PhpParser\Node $node) use($param) : ?PropertyFetch { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmts, function (Node $node) use($param) : ?PropertyFetch { + if (!$node instanceof Variable) { return null; } $name = $this->nodeNameResolver->getName($param->var); @@ -153,9 +153,9 @@ final class ModelFactoryNodeFactory /** * @param Node\Stmt[] $stmts */ - private function createPublicMethod(string $name, array $stmts) : \PhpParser\Node\Stmt\ClassMethod + private function createPublicMethod(string $name, array $stmts) : ClassMethod { - $methodBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\MethodBuilder($name); + $methodBuilder = new MethodBuilder($name); $methodBuilder->makePublic(); $methodBuilder->addStmts($stmts); return $methodBuilder->getNode(); diff --git a/vendor/rector/rector-laravel/src/NodeFactory/RouterRegisterNodeAnalyzer.php b/vendor/rector/rector-laravel/src/NodeFactory/RouterRegisterNodeAnalyzer.php index b6e3db3b314..689cdbdaa01 100644 --- a/vendor/rector/rector-laravel/src/NodeFactory/RouterRegisterNodeAnalyzer.php +++ b/vendor/rector/rector-laravel/src/NodeFactory/RouterRegisterNodeAnalyzer.php @@ -22,7 +22,7 @@ final class RouterRegisterNodeAnalyzer * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->nodeTypeResolver = $nodeTypeResolver; @@ -35,10 +35,10 @@ final class RouterRegisterNodeAnalyzer if (!$this->isRegisterName($node->name)) { return \false; } - if ($node instanceof \PhpParser\Node\Expr\MethodCall && $this->nodeTypeResolver->isObjectTypes($node->var, [new \PHPStan\Type\ObjectType('Illuminate\\Routing\\Router'), new \PHPStan\Type\ObjectType('Illuminate\\Routing\\RouteRegistrar')])) { + if ($node instanceof MethodCall && $this->nodeTypeResolver->isObjectTypes($node->var, [new ObjectType('Illuminate\\Routing\\Router'), new ObjectType('Illuminate\\Routing\\RouteRegistrar')])) { return \true; } - return $node instanceof \PhpParser\Node\Expr\StaticCall && $this->nodeNameResolver->isName($node->class, 'Illuminate\\Support\\Facades\\Route'); + return $node instanceof StaticCall && $this->nodeNameResolver->isName($node->class, 'Illuminate\\Support\\Facades\\Route'); } /** * @param \PhpParser\Node\Identifier|\PhpParser\Node\Expr $name diff --git a/vendor/rector/rector-laravel/src/Rector/Assign/CallOnAppArrayAccessToStandaloneAssignRector.php b/vendor/rector/rector-laravel/src/Rector/Assign/CallOnAppArrayAccessToStandaloneAssignRector.php index f7d1de4b7e8..8088391ef0b 100644 --- a/vendor/rector/rector-laravel/src/Rector/Assign/CallOnAppArrayAccessToStandaloneAssignRector.php +++ b/vendor/rector/rector-laravel/src/Rector/Assign/CallOnAppArrayAccessToStandaloneAssignRector.php @@ -13,12 +13,12 @@ use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\Laravel\NodeFactory\AppAssignFactory; use Rector\Laravel\ValueObject\ServiceNameTypeAndVariableName; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Laravel\Tests\Rector\Assign\CallOnAppArrayAccessToStandaloneAssignRector\CallOnAppArrayAccessToStandaloneAssignRectorTest */ -final class CallOnAppArrayAccessToStandaloneAssignRector extends \Rector\Core\Rector\AbstractRector +final class CallOnAppArrayAccessToStandaloneAssignRector extends AbstractRector { /** * @var ServiceNameTypeAndVariableName[] @@ -29,36 +29,36 @@ final class CallOnAppArrayAccessToStandaloneAssignRector extends \Rector\Core\Re * @var \Rector\Laravel\NodeFactory\AppAssignFactory */ private $appAssignFactory; - public function __construct(\Rector\Laravel\NodeFactory\AppAssignFactory $appAssignFactory) + public function __construct(AppAssignFactory $appAssignFactory) { $this->appAssignFactory = $appAssignFactory; - $this->serviceNameTypeAndVariableNames[] = new \Rector\Laravel\ValueObject\ServiceNameTypeAndVariableName('validator', 'Illuminate\\Validation\\Factory', 'validationFactory'); + $this->serviceNameTypeAndVariableNames[] = new ServiceNameTypeAndVariableName('validator', 'Illuminate\\Validation\\Factory', 'validationFactory'); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Assign::class]; + return [Assign::class]; } /** * @param Assign $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->expr instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$node->expr instanceof MethodCall) { return null; } $methodCall = $node->expr; - if (!$methodCall->var instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$methodCall->var instanceof ArrayDimFetch) { return null; } $arrayDimFetch = $methodCall->var; - if (!$this->isObjectType($arrayDimFetch->var, new \PHPStan\Type\ObjectType('Illuminate\\Contracts\\Foundation\\Application'))) { + if (!$this->isObjectType($arrayDimFetch->var, new ObjectType('Illuminate\\Contracts\\Foundation\\Application'))) { return null; } $arrayDimFetchDim = $methodCall->var->dim; - if (!$arrayDimFetchDim instanceof \PhpParser\Node\Expr) { + if (!$arrayDimFetchDim instanceof Expr) { return null; } foreach ($this->serviceNameTypeAndVariableNames as $serviceNameTypeAndVariableName) { @@ -67,14 +67,14 @@ final class CallOnAppArrayAccessToStandaloneAssignRector extends \Rector\Core\Re } $assignExpression = $this->appAssignFactory->createAssignExpression($serviceNameTypeAndVariableName, $methodCall->var); $this->nodesToAddCollector->addNodeBeforeNode($assignExpression, $node); - $methodCall->var = new \PhpParser\Node\Expr\Variable($serviceNameTypeAndVariableName->getVariableName()); + $methodCall->var = new Variable($serviceNameTypeAndVariableName->getVariableName()); return $node; } return null; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace magical call on $this->app["something"] to standalone type assign variable', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace magical call on $this->app["something"] to standalone type assign variable', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { /** diff --git a/vendor/rector/rector-laravel/src/Rector/ClassMethod/AddArgumentDefaultValueRector.php b/vendor/rector/rector-laravel/src/Rector/ClassMethod/AddArgumentDefaultValueRector.php index 46e8c4d45f0..65bd40d9dd1 100644 --- a/vendor/rector/rector-laravel/src/Rector/ClassMethod/AddArgumentDefaultValueRector.php +++ b/vendor/rector/rector-laravel/src/Rector/ClassMethod/AddArgumentDefaultValueRector.php @@ -10,13 +10,13 @@ use PhpParser\Node\Stmt\ClassMethod; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Laravel\ValueObject\AddArgumentDefaultValue; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Laravel\Tests\Rector\ClassMethod\AddArgumentDefaultValueRector\AddArgumentDefaultValueRectorTest */ -final class AddArgumentDefaultValueRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class AddArgumentDefaultValueRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var string @@ -26,9 +26,9 @@ final class AddArgumentDefaultValueRector extends \Rector\Core\Rector\AbstractRe * @var AddArgumentDefaultValue[] */ private $addedArguments = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Adds default value for arguments in defined methods.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Adds default value for arguments in defined methods.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function someMethod($value) @@ -44,19 +44,19 @@ class SomeClass } } CODE_SAMPLE -, [self::ADDED_ARGUMENTS => [new \Rector\Laravel\ValueObject\AddArgumentDefaultValue('SomeClass', 'someMethod', 0, \false)]])]); +, [self::ADDED_ARGUMENTS => [new AddArgumentDefaultValue('SomeClass', 'someMethod', 0, \false)]])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : \PhpParser\Node\Stmt\ClassMethod + public function refactor(Node $node) : ClassMethod { foreach ($this->addedArguments as $addedArgument) { if (!$this->nodeTypeResolver->isObjectType($node, $addedArgument->getObjectType())) { @@ -73,7 +73,7 @@ CODE_SAMPLE if ($param->default !== null) { continue; } - $node->params[$position] = new \PhpParser\Node\Param($param->var, \PhpParser\BuilderHelpers::normalizeValue($addedArgument->getDefaultValue())); + $node->params[$position] = new Param($param->var, BuilderHelpers::normalizeValue($addedArgument->getDefaultValue())); } return $node; } @@ -83,8 +83,8 @@ CODE_SAMPLE public function configure(array $configuration) : void { $addedArguments = $configuration[self::ADDED_ARGUMENTS] ?? $configuration; - \RectorPrefix20220607\Webmozart\Assert\Assert::isArray($addedArguments); - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsInstanceOf($addedArguments, \Rector\Laravel\ValueObject\AddArgumentDefaultValue::class); + Assert::isArray($addedArguments); + Assert::allIsInstanceOf($addedArguments, AddArgumentDefaultValue::class); $this->addedArguments = $addedArguments; } } diff --git a/vendor/rector/rector-laravel/src/Rector/ClassMethod/AddGenericReturnTypeToRelationsRector.php b/vendor/rector/rector-laravel/src/Rector/ClassMethod/AddGenericReturnTypeToRelationsRector.php index 19f6d04277c..737080e9474 100644 --- a/vendor/rector/rector-laravel/src/Rector/ClassMethod/AddGenericReturnTypeToRelationsRector.php +++ b/vendor/rector/rector-laravel/src/Rector/ClassMethod/AddGenericReturnTypeToRelationsRector.php @@ -18,14 +18,14 @@ use PHPStan\Type\ObjectType; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\BetterPhpDocParser\ValueObject\Type\FullyQualifiedIdentifierTypeNode; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** @see \Rector\Laravel\Tests\Rector\ClassMethod\AddGenericReturnTypeToRelationsRector\AddGenericReturnTypeToRelationsRectorTest */ -class AddGenericReturnTypeToRelationsRector extends \Rector\Core\Rector\AbstractRector +class AddGenericReturnTypeToRelationsRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add generic return type to relations in child of Illuminate\\Database\\Eloquent\\Model', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add generic return type to relations in child of Illuminate\\Database\\Eloquent\\Model', [new CodeSample(<<<'CODE_SAMPLE' use App\Account; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; @@ -59,12 +59,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkipNode($node)) { return null; @@ -77,38 +77,38 @@ CODE_SAMPLE if ($methodReturnTypeName === null) { return null; } - if (!$this->isObjectType($methodReturnType, new \PHPStan\Type\ObjectType('Illuminate\\Database\\Eloquent\\Relations\\Relation'))) { + if (!$this->isObjectType($methodReturnType, new ObjectType('Illuminate\\Database\\Eloquent\\Relations\\Relation'))) { return null; } $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); - if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$phpDocInfo instanceof PhpDocInfo) { return null; } // Return, if already has return type if ($node->getDocComment() !== null && $phpDocInfo->hasByName('return')) { return null; } - $returnStatement = $this->betterNodeFinder->findFirstInFunctionLikeScoped($node, function (\PhpParser\Node $subNode) : bool { - return $subNode instanceof \PhpParser\Node\Stmt\Return_; + $returnStatement = $this->betterNodeFinder->findFirstInFunctionLikeScoped($node, function (Node $subNode) : bool { + return $subNode instanceof Return_; }); - if (!$returnStatement instanceof \PhpParser\Node\Stmt\Return_) { + if (!$returnStatement instanceof Return_) { return null; } - $relationMethodCall = $this->betterNodeFinder->findFirstInstanceOf($returnStatement, \PhpParser\Node\Expr\MethodCall::class); - if (!$relationMethodCall instanceof \PhpParser\Node\Expr\MethodCall) { + $relationMethodCall = $this->betterNodeFinder->findFirstInstanceOf($returnStatement, MethodCall::class); + if (!$relationMethodCall instanceof MethodCall) { return null; } $relatedClass = $this->getRelatedModelClassFromMethodCall($relationMethodCall); if ($relatedClass === null) { return null; } - $phpDocInfo->addTagValueNode(new \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode(new \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode(new \Rector\BetterPhpDocParser\ValueObject\Type\FullyQualifiedIdentifierTypeNode($methodReturnTypeName), [new \Rector\BetterPhpDocParser\ValueObject\Type\FullyQualifiedIdentifierTypeNode($relatedClass)]), '')); + $phpDocInfo->addTagValueNode(new ReturnTagValueNode(new GenericTypeNode(new FullyQualifiedIdentifierTypeNode($methodReturnTypeName), [new FullyQualifiedIdentifierTypeNode($relatedClass)]), '')); return $node; } - private function getRelatedModelClassFromMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : ?string + private function getRelatedModelClassFromMethodCall(MethodCall $methodCall) : ?string { $methodName = $methodCall->name; - if (!$methodName instanceof \PhpParser\Node\Identifier) { + if (!$methodName instanceof Identifier) { return null; } // Called method should be one of the Laravel's relation methods @@ -119,29 +119,29 @@ CODE_SAMPLE return null; } $argType = $this->getType($methodCall->getArgs()[0]->value); - if ($argType instanceof \PHPStan\Type\Constant\ConstantStringType) { + if ($argType instanceof ConstantStringType) { return $argType->getValue(); } - if (!$argType instanceof \PHPStan\Type\Generic\GenericClassStringType) { + if (!$argType instanceof GenericClassStringType) { return null; } $modelType = $argType->getGenericType(); - if (!$modelType instanceof \PHPStan\Type\ObjectType) { + if (!$modelType instanceof ObjectType) { return null; } return $modelType->getClassName(); } - private function shouldSkipNode(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkipNode(ClassMethod $classMethod) : bool { if ($classMethod->stmts === null) { return \true; } - $classLike = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($classMethod, ClassLike::class); + if (!$classLike instanceof ClassLike) { return \true; } - if ($classLike instanceof \PhpParser\Node\Stmt\Class_) { - return !$this->isObjectType($classLike, new \PHPStan\Type\ObjectType('Illuminate\\Database\\Eloquent\\Model')); + if ($classLike instanceof Class_) { + return !$this->isObjectType($classLike, new ObjectType('Illuminate\\Database\\Eloquent\\Model')); } return \false; } diff --git a/vendor/rector/rector-laravel/src/Rector/ClassMethod/AddParentBootToModelClassMethodRector.php b/vendor/rector/rector-laravel/src/Rector/ClassMethod/AddParentBootToModelClassMethodRector.php index 1ebaa17f247..3d1758e9228 100644 --- a/vendor/rector/rector-laravel/src/Rector/ClassMethod/AddParentBootToModelClassMethodRector.php +++ b/vendor/rector/rector-laravel/src/Rector/ClassMethod/AddParentBootToModelClassMethodRector.php @@ -10,14 +10,14 @@ use PhpParser\Node\Stmt\Expression; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\Nette\NodeAnalyzer\StaticCallAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://laracasts.com/discuss/channels/laravel/laravel-57-upgrade-observer-problem * * @see \Rector\Laravel\Tests\Rector\ClassMethod\AddParentBootToModelClassMethodRector\AddParentBootToModelClassMethodRectorTest */ -final class AddParentBootToModelClassMethodRector extends \Rector\Core\Rector\AbstractRector +final class AddParentBootToModelClassMethodRector extends AbstractRector { /** * @var string @@ -28,13 +28,13 @@ final class AddParentBootToModelClassMethodRector extends \Rector\Core\Rector\Ab * @var \Rector\Nette\NodeAnalyzer\StaticCallAnalyzer */ private $staticCallAnalyzer; - public function __construct(\Rector\Nette\NodeAnalyzer\StaticCallAnalyzer $staticCallAnalyzer) + public function __construct(StaticCallAnalyzer $staticCallAnalyzer) { $this->staticCallAnalyzer = $staticCallAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add parent::boot(); call to boot() class method in child of Illuminate\\Database\\Eloquent\\Model', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add parent::boot(); call to boot() class method in child of Illuminate\\Database\\Eloquent\\Model', [new CodeSample(<<<'CODE_SAMPLE' use Illuminate\Database\Eloquent\Model; class Product extends Model @@ -62,25 +62,25 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($node, ClassLike::class); + if (!$classLike instanceof ClassLike) { return null; } - if (!$this->isObjectType($classLike, new \PHPStan\Type\ObjectType('Illuminate\\Database\\Eloquent\\Model'))) { + if (!$this->isObjectType($classLike, new ObjectType('Illuminate\\Database\\Eloquent\\Model'))) { return null; } if (!$this->isName($node->name, self::BOOT)) { return null; } foreach ((array) $node->stmts as $key => $classMethodStmt) { - if ($classMethodStmt instanceof \PhpParser\Node\Stmt\Expression) { + if ($classMethodStmt instanceof Expression) { $classMethodStmt = $classMethodStmt->expr; } // is in the 1st position? → only correct place @@ -96,7 +96,7 @@ CODE_SAMPLE } // missing, we need to add one $staticCall = $this->nodeFactory->createStaticCall('parent', self::BOOT); - $parentStaticCallExpression = new \PhpParser\Node\Stmt\Expression($staticCall); + $parentStaticCallExpression = new Expression($staticCall); $node->stmts = \array_merge([$parentStaticCallExpression], (array) $node->stmts); return $node; } diff --git a/vendor/rector/rector-laravel/src/Rector/ClassMethod/AddParentRegisterToEventServiceProviderRector.php b/vendor/rector/rector-laravel/src/Rector/ClassMethod/AddParentRegisterToEventServiceProviderRector.php index 31af3c2b92c..2960f3d5d71 100644 --- a/vendor/rector/rector-laravel/src/Rector/ClassMethod/AddParentRegisterToEventServiceProviderRector.php +++ b/vendor/rector/rector-laravel/src/Rector/ClassMethod/AddParentRegisterToEventServiceProviderRector.php @@ -10,14 +10,14 @@ use PhpParser\Node\Stmt\Expression; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\Nette\NodeAnalyzer\StaticCallAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://laravel.com/docs/8.x/upgrade#the-event-service-provider-class * * @see \Rector\Laravel\Tests\Rector\ClassMethod\AddParentRegisterToEventServiceProviderRector\AddParentRegisterToEventServiceProviderRectorTest */ -final class AddParentRegisterToEventServiceProviderRector extends \Rector\Core\Rector\AbstractRector +final class AddParentRegisterToEventServiceProviderRector extends AbstractRector { /** * @var string @@ -28,13 +28,13 @@ final class AddParentRegisterToEventServiceProviderRector extends \Rector\Core\R * @var \Rector\Nette\NodeAnalyzer\StaticCallAnalyzer */ private $staticCallAnalyzer; - public function __construct(\Rector\Nette\NodeAnalyzer\StaticCallAnalyzer $staticCallAnalyzer) + public function __construct(StaticCallAnalyzer $staticCallAnalyzer) { $this->staticCallAnalyzer = $staticCallAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add parent::register(); call to register() class method in child of Illuminate\\Foundation\\Support\\Providers\\EventServiceProvider', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add parent::register(); call to register() class method in child of Illuminate\\Foundation\\Support\\Providers\\EventServiceProvider', [new CodeSample(<<<'CODE_SAMPLE' use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; class EventServiceProvider extends ServiceProvider @@ -62,25 +62,25 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($node, ClassLike::class); + if (!$classLike instanceof ClassLike) { return null; } - if (!$this->isObjectType($classLike, new \PHPStan\Type\ObjectType('Illuminate\\Foundation\\Support\\Providers\\EventServiceProvider'))) { + if (!$this->isObjectType($classLike, new ObjectType('Illuminate\\Foundation\\Support\\Providers\\EventServiceProvider'))) { return null; } if (!$this->isName($node->name, self::REGISTER)) { return null; } foreach ((array) $node->stmts as $key => $classMethodStmt) { - if ($classMethodStmt instanceof \PhpParser\Node\Stmt\Expression) { + if ($classMethodStmt instanceof Expression) { $classMethodStmt = $classMethodStmt->expr; } if (!$this->staticCallAnalyzer->isParentCallNamed($classMethodStmt, self::REGISTER)) { @@ -92,7 +92,7 @@ CODE_SAMPLE unset($node->stmts[$key]); } $staticCall = $this->nodeFactory->createStaticCall('parent', self::REGISTER); - $parentStaticCallExpression = new \PhpParser\Node\Stmt\Expression($staticCall); + $parentStaticCallExpression = new Expression($staticCall); $node->stmts = \array_merge([$parentStaticCallExpression], (array) $node->stmts); return $node; } diff --git a/vendor/rector/rector-laravel/src/Rector/Class_/AddMockConsoleOutputFalseToConsoleTestsRector.php b/vendor/rector/rector-laravel/src/Rector/Class_/AddMockConsoleOutputFalseToConsoleTestsRector.php index 85a8bbbfda4..1700a319783 100644 --- a/vendor/rector/rector-laravel/src/Rector/Class_/AddMockConsoleOutputFalseToConsoleTestsRector.php +++ b/vendor/rector/rector-laravel/src/Rector/Class_/AddMockConsoleOutputFalseToConsoleTestsRector.php @@ -13,15 +13,15 @@ use PHPStan\Type\ObjectType; use Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeManipulator\SetUpClassMethodNodeManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/laravel/framework/issues/26450#issuecomment-449401202 * @see https://github.com/laravel/framework/commit/055fe52dbb7169dc51bd5d5deeb05e8da9be0470#diff-76a649cb397ea47f5613459c335f88c1b68e5f93e51d46e9fb5308ec55ded221 * * @see \Rector\Laravel\Tests\Rector\Class_\AddMockConsoleOutputFalseToConsoleTestsRector\AddMockConsoleOutputFalseToConsoleTestsRectorTest */ -final class AddMockConsoleOutputFalseToConsoleTestsRector extends \Rector\Core\Rector\AbstractRector +final class AddMockConsoleOutputFalseToConsoleTestsRector extends AbstractRector { /** * @readonly @@ -33,14 +33,14 @@ final class AddMockConsoleOutputFalseToConsoleTestsRector extends \Rector\Core\R * @var \Rector\PHPUnit\NodeManipulator\SetUpClassMethodNodeManipulator */ private $setUpClassMethodNodeManipulator; - public function __construct(\Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \Rector\PHPUnit\NodeManipulator\SetUpClassMethodNodeManipulator $setUpClassMethodNodeManipulator) + public function __construct(PropertyFetchAnalyzer $propertyFetchAnalyzer, SetUpClassMethodNodeManipulator $setUpClassMethodNodeManipulator) { $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; $this->setUpClassMethodNodeManipulator = $setUpClassMethodNodeManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add "$this->mockConsoleOutput = false"; to console tests that work with output content', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add "$this->mockConsoleOutput = false"; to console tests that work with output content', [new CodeSample(<<<'CODE_SAMPLE' use Illuminate\Support\Facades\Artisan; use Illuminate\Foundation\Testing\TestCase; @@ -78,14 +78,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node, new \PHPStan\Type\ObjectType('Illuminate\\Foundation\\Testing\\TestCase'))) { + if (!$this->isObjectType($node, new ObjectType('Illuminate\\Foundation\\Testing\\TestCase'))) { return null; } if (!$this->isTestingConsoleOutput($node)) { @@ -99,23 +99,23 @@ CODE_SAMPLE $this->setUpClassMethodNodeManipulator->decorateOrCreate($node, [$assign]); return $node; } - private function isTestingConsoleOutput(\PhpParser\Node\Stmt\Class_ $class) : bool + private function isTestingConsoleOutput(Class_ $class) : bool { - return (bool) $this->betterNodeFinder->findFirst($class->stmts, function (\PhpParser\Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Expr\StaticCall) { + return (bool) $this->betterNodeFinder->findFirst($class->stmts, function (Node $node) : bool { + if (!$node instanceof StaticCall) { return \false; } $callerType = $this->nodeTypeResolver->getType($node->class); - if (!$callerType->isSuperTypeOf(new \PHPStan\Type\ObjectType('Illuminate\\Support\\Facades\\Artisan'))->yes()) { + if (!$callerType->isSuperTypeOf(new ObjectType('Illuminate\\Support\\Facades\\Artisan'))->yes()) { return \false; } return $this->isName($node->name, 'output'); }); } - private function hasMockConsoleOutputFalse(\PhpParser\Node\Stmt\Class_ $class) : bool + private function hasMockConsoleOutputFalse(Class_ $class) : bool { - return (bool) $this->betterNodeFinder->findFirst($class, function (\PhpParser\Node $node) : bool { - if ($node instanceof \PhpParser\Node\Expr\Assign) { + return (bool) $this->betterNodeFinder->findFirst($class, function (Node $node) : bool { + if ($node instanceof Assign) { if (!$this->propertyFetchAnalyzer->isLocalPropertyFetchName($node->var, 'mockConsoleOutput')) { return \false; } @@ -124,9 +124,9 @@ CODE_SAMPLE return \false; }); } - private function createAssign() : \PhpParser\Node\Expr\Assign + private function createAssign() : Assign { - $propertyFetch = new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable('this'), 'mockConsoleOutput'); - return new \PhpParser\Node\Expr\Assign($propertyFetch, $this->nodeFactory->createFalse()); + $propertyFetch = new PropertyFetch(new Variable('this'), 'mockConsoleOutput'); + return new Assign($propertyFetch, $this->nodeFactory->createFalse()); } } diff --git a/vendor/rector/rector-laravel/src/Rector/Class_/AnonymousMigrationsRector.php b/vendor/rector/rector-laravel/src/Rector/Class_/AnonymousMigrationsRector.php index 7f9b54852bf..e22241c28b9 100644 --- a/vendor/rector/rector-laravel/src/Rector/Class_/AnonymousMigrationsRector.php +++ b/vendor/rector/rector-laravel/src/Rector/Class_/AnonymousMigrationsRector.php @@ -10,28 +10,28 @@ use PhpParser\Node\Stmt\Return_; use PHPStan\Type\ObjectType; use Rector\Core\NodeAnalyzer\ClassAnalyzer; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/laravel/framework/pull/36906 * @see https://github.com/laravel/framework/pull/37352 * * @see \Rector\Laravel\Tests\Rector\Class_\AnonymousMigrationsRector\AnonymousMigrationsRectorTest */ -final class AnonymousMigrationsRector extends \Rector\Core\Rector\AbstractRector +final class AnonymousMigrationsRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeAnalyzer\ClassAnalyzer */ private $classAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer) + public function __construct(ClassAnalyzer $classAnalyzer) { $this->classAnalyzer = $classAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Convert migrations to anonymous classes.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Convert migrations to anonymous classes.', [new CodeSample(<<<'CODE_SAMPLE' use Illuminate\Database\Migrations\Migration; class CreateUsersTable extends Migration @@ -54,19 +54,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node, new \PHPStan\Type\ObjectType('Illuminate\\Database\\Migrations\\Migration'))) { + if (!$this->isObjectType($node, new ObjectType('Illuminate\\Database\\Migrations\\Migration'))) { return null; } if ($this->classAnalyzer->isAnonymousClass($node)) { return null; } - return new \PhpParser\Node\Stmt\Return_(new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Stmt\Class_(null, ['flags' => $node->flags, 'extends' => $node->extends, 'implements' => $node->implements, 'stmts' => $node->stmts, 'attrGroups' => $node->attrGroups]))); + return new Return_(new New_(new Class_(null, ['flags' => $node->flags, 'extends' => $node->extends, 'implements' => $node->implements, 'stmts' => $node->stmts, 'attrGroups' => $node->attrGroups]))); } } diff --git a/vendor/rector/rector-laravel/src/Rector/Class_/PropertyDeferToDeferrableProviderToRector.php b/vendor/rector/rector-laravel/src/Rector/Class_/PropertyDeferToDeferrableProviderToRector.php index 1001a5a35d1..1ad3f0728a8 100644 --- a/vendor/rector/rector-laravel/src/Rector/Class_/PropertyDeferToDeferrableProviderToRector.php +++ b/vendor/rector/rector-laravel/src/Rector/Class_/PropertyDeferToDeferrableProviderToRector.php @@ -9,18 +9,18 @@ use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\Property; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://laravel.com/docs/5.8/upgrade#deferred-service-providers * * @see \Rector\Laravel\Tests\Rector\Class_\PropertyDeferToDeferrableProviderToRector\PropertyDeferToDeferrableProviderToRectorTest */ -final class PropertyDeferToDeferrableProviderToRector extends \Rector\Core\Rector\AbstractRector +final class PropertyDeferToDeferrableProviderToRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change deprecated $defer = true; to Illuminate\\Contracts\\Support\\DeferrableProvider interface', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change deprecated $defer = true; to Illuminate\\Contracts\\Support\\DeferrableProvider interface', [new CodeSample(<<<'CODE_SAMPLE' use Illuminate\Support\ServiceProvider; final class SomeServiceProvider extends ServiceProvider @@ -46,25 +46,25 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node, new \PHPStan\Type\ObjectType('Illuminate\\Support\\ServiceProvider'))) { + if (!$this->isObjectType($node, new ObjectType('Illuminate\\Support\\ServiceProvider'))) { return null; } $deferProperty = $this->matchDeferWithFalseProperty($node); - if (!$deferProperty instanceof \PhpParser\Node\Stmt\Property) { + if (!$deferProperty instanceof Property) { return null; } $this->removeNode($deferProperty); - $node->implements[] = new \PhpParser\Node\Name\FullyQualified('Illuminate\\Contracts\\Support\\DeferrableProvider'); + $node->implements[] = new FullyQualified('Illuminate\\Contracts\\Support\\DeferrableProvider'); return $node; } - private function matchDeferWithFalseProperty(\PhpParser\Node\Stmt\Class_ $class) : ?\PhpParser\Node\Stmt\Property + private function matchDeferWithFalseProperty(Class_ $class) : ?Property { foreach ($class->getProperties() as $property) { if (!$this->isName($property, 'defer')) { diff --git a/vendor/rector/rector-laravel/src/Rector/Class_/UnifyModelDatesWithCastsRector.php b/vendor/rector/rector-laravel/src/Rector/Class_/UnifyModelDatesWithCastsRector.php index eaf1c99b3ef..0bf8e951688 100644 --- a/vendor/rector/rector-laravel/src/Rector/Class_/UnifyModelDatesWithCastsRector.php +++ b/vendor/rector/rector-laravel/src/Rector/Class_/UnifyModelDatesWithCastsRector.php @@ -13,28 +13,28 @@ use PHPStan\Type\ObjectType; use Rector\Core\NodeManipulator\ClassInsertManipulator; use Rector\Core\Rector\AbstractRector; use RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\PropertyBuilder; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see https://github.com/laravel/framework/pull/32856 * * @see \Rector\Laravel\Tests\Rector\Class_\UnifyModelDatesWithCastsRector\UnifyModelDatesWithCastsRectorTest */ -final class UnifyModelDatesWithCastsRector extends \Rector\Core\Rector\AbstractRector +final class UnifyModelDatesWithCastsRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeManipulator\ClassInsertManipulator */ private $classInsertManipulator; - public function __construct(\Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator) + public function __construct(ClassInsertManipulator $classInsertManipulator) { $this->classInsertManipulator = $classInsertManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Unify Model $dates property with $casts', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Unify Model $dates property with $casts', [new CodeSample(<<<'CODE_SAMPLE' use Illuminate\Database\Eloquent\Model; class Person extends Model @@ -63,22 +63,22 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node, new \PHPStan\Type\ObjectType('Illuminate\\Database\\Eloquent\\Model'))) { + if (!$this->isObjectType($node, new ObjectType('Illuminate\\Database\\Eloquent\\Model'))) { return null; } $datesProperty = $node->getProperty('dates'); - if (!$datesProperty instanceof \PhpParser\Node\Stmt\Property) { + if (!$datesProperty instanceof Property) { return null; } $datesPropertyProperty = $datesProperty->props[0]; - if (!$datesPropertyProperty->default instanceof \PhpParser\Node\Expr\Array_) { + if (!$datesPropertyProperty->default instanceof Array_) { return null; } $dates = $this->valueResolver->getValue($datesPropertyProperty->default); @@ -90,27 +90,27 @@ CODE_SAMPLE } $castsProperty = $node->getProperty('casts'); // add property $casts if not exists - if (!$castsProperty instanceof \PhpParser\Node\Stmt\Property) { + if (!$castsProperty instanceof Property) { $castsProperty = $this->createCastsProperty(); $this->classInsertManipulator->addAsFirstMethod($node, $castsProperty); } $castsPropertyProperty = $castsProperty->props[0]; - if (!$castsPropertyProperty->default instanceof \PhpParser\Node\Expr\Array_) { + if (!$castsPropertyProperty->default instanceof Array_) { return null; } $casts = $this->valueResolver->getValue($castsPropertyProperty->default); // exclude attributes added in $casts $missingDates = \array_diff($dates, \array_keys($casts)); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($missingDates); + Assert::allString($missingDates); foreach ($missingDates as $missingDate) { - $castsPropertyProperty->default->items[] = new \PhpParser\Node\Expr\ArrayItem(new \PhpParser\Node\Scalar\String_('datetime'), new \PhpParser\Node\Scalar\String_($missingDate)); + $castsPropertyProperty->default->items[] = new ArrayItem(new String_('datetime'), new String_($missingDate)); } $this->nodeRemover->removeNode($datesProperty); return null; } - private function createCastsProperty() : \PhpParser\Node\Stmt\Property + private function createCastsProperty() : Property { - $propertyBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\PropertyBuilder('casts'); + $propertyBuilder = new PropertyBuilder('casts'); $propertyBuilder->makeProtected(); $propertyBuilder->setDefault([]); $property = $propertyBuilder->getNode(); diff --git a/vendor/rector/rector-laravel/src/Rector/FuncCall/FactoryFuncCallToStaticCallRector.php b/vendor/rector/rector-laravel/src/Rector/FuncCall/FactoryFuncCallToStaticCallRector.php index 159cc3b51bf..8e31607b69a 100644 --- a/vendor/rector/rector-laravel/src/Rector/FuncCall/FactoryFuncCallToStaticCallRector.php +++ b/vendor/rector/rector-laravel/src/Rector/FuncCall/FactoryFuncCallToStaticCallRector.php @@ -9,23 +9,23 @@ use PhpParser\Node\Expr\ClassConstFetch; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\StaticCall; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://laravel.com/docs/7.x/database-testing#creating-models * @see https://laravel.com/docs/8.x/database-testing#instantiating-models * * @see \Rector\Laravel\Tests\Rector\FuncCall\FactoryFuncCallToStaticCallRector\FactoryFuncCallToStaticCallRectorTest */ -final class FactoryFuncCallToStaticCallRector extends \Rector\Core\Rector\AbstractRector +final class FactoryFuncCallToStaticCallRector extends AbstractRector { /** * @var string */ private const FACTORY = 'factory'; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Use the static factory method instead of global factory function.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Use the static factory method instead of global factory function.', [new CodeSample(<<<'CODE_SAMPLE' factory(User::class); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -38,12 +38,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param Node\Expr\FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node->name, self::FACTORY)) { return null; @@ -51,19 +51,19 @@ CODE_SAMPLE if (!isset($node->args[0])) { return null; } - if (!$node->args[0] instanceof \PhpParser\Node\Arg) { + if (!$node->args[0] instanceof Arg) { return null; } $firstArgValue = $node->args[0]->value; - if (!$firstArgValue instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if (!$firstArgValue instanceof ClassConstFetch) { return null; } $model = $firstArgValue->class; // create model if (!isset($node->args[1])) { - return new \PhpParser\Node\Expr\StaticCall($model, self::FACTORY); + return new StaticCall($model, self::FACTORY); } // create models of a given type - return new \PhpParser\Node\Expr\StaticCall($model, self::FACTORY, [$node->args[1]]); + return new StaticCall($model, self::FACTORY, [$node->args[1]]); } } diff --git a/vendor/rector/rector-laravel/src/Rector/FuncCall/HelperFuncCallToFacadeClassRector.php b/vendor/rector/rector-laravel/src/Rector/FuncCall/HelperFuncCallToFacadeClassRector.php index 1266b71833c..7b3f3451489 100644 --- a/vendor/rector/rector-laravel/src/Rector/FuncCall/HelperFuncCallToFacadeClassRector.php +++ b/vendor/rector/rector-laravel/src/Rector/FuncCall/HelperFuncCallToFacadeClassRector.php @@ -6,19 +6,19 @@ namespace Rector\Laravel\Rector\FuncCall; use PhpParser\Node; use PhpParser\Node\Expr\FuncCall; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://laravel.com/docs/8.x/helpers#method-app * @see https://github.com/laravel/framework/blob/8.x/src/Illuminate/Foundation/helpers.php * * @see \Rector\Laravel\Tests\Rector\FuncCall\HelperFuncCallToFacadeClassRector\HelperFuncCallToFacadeClassRectorTest */ -final class HelperFuncCallToFacadeClassRector extends \Rector\Core\Rector\AbstractRector +final class HelperFuncCallToFacadeClassRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change app() func calls to facade calls', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change app() func calls to facade calls', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -43,12 +43,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node->name, 'app')) { return null; diff --git a/vendor/rector/rector-laravel/src/Rector/FuncCall/RemoveDumpDataDeadCodeRector.php b/vendor/rector/rector-laravel/src/Rector/FuncCall/RemoveDumpDataDeadCodeRector.php index fef8d43b0f7..cef4dbd5fa8 100644 --- a/vendor/rector/rector-laravel/src/Rector/FuncCall/RemoveDumpDataDeadCodeRector.php +++ b/vendor/rector/rector-laravel/src/Rector/FuncCall/RemoveDumpDataDeadCodeRector.php @@ -8,16 +8,16 @@ use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Stmt\Expression; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Laravel\Tests\Rector\FuncCall\RemoveDumpDataDeadCodeRector\RemoveDumpDataDeadCodeRectorTest */ -final class RemoveDumpDataDeadCodeRector extends \Rector\Core\Rector\AbstractRector +final class RemoveDumpDataDeadCodeRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('It will removes the dump data just like dd or dump functions from the code.`', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('It will removes the dump data just like dd or dump functions from the code.`', [new CodeSample(<<<'CODE_SAMPLE' class MyController { public function store() @@ -54,18 +54,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isNames($node->name, ['dd', 'dump'])) { return null; } - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node\Stmt\Expression) { + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof Expression) { return null; } $this->removeNode($node); diff --git a/vendor/rector/rector-laravel/src/Rector/MethodCall/ChangeQueryWhereDateValueWithCarbonRector.php b/vendor/rector/rector-laravel/src/Rector/MethodCall/ChangeQueryWhereDateValueWithCarbonRector.php index d431965660c..901aa887ecc 100644 --- a/vendor/rector/rector-laravel/src/Rector/MethodCall/ChangeQueryWhereDateValueWithCarbonRector.php +++ b/vendor/rector/rector-laravel/src/Rector/MethodCall/ChangeQueryWhereDateValueWithCarbonRector.php @@ -13,19 +13,19 @@ use PhpParser\Node\Expr\Variable; use PhpParser\Node\Scalar\String_; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/laravel/framework/pull/25315 * @see https://laracasts.com/discuss/channels/eloquent/laravel-eloquent-where-date-is-equal-or-smaller-than-datetime * * @see \Rector\Laravel\Tests\Rector\MethodCall\ChangeQueryWhereDateValueWithCarbonRector\ChangeQueryWhereDateValueWithCarbonRectorTest */ -final class ChangeQueryWhereDateValueWithCarbonRector extends \Rector\Core\Rector\AbstractRector +final class ChangeQueryWhereDateValueWithCarbonRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add parent::boot(); call to boot() class method in child of Illuminate\\Database\\Eloquent\\Model', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add parent::boot(); call to boot() class method in child of Illuminate\\Database\\Eloquent\\Model', [new CodeSample(<<<'CODE_SAMPLE' use Illuminate\Database\Query\Builder; final class SomeClass @@ -56,29 +56,29 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $argValue = $this->matchWhereDateThirdArgValue($node); - if (!$argValue instanceof \PhpParser\Node\Expr) { + if (!$argValue instanceof Expr) { return null; } // is just made with static call? - if ($argValue instanceof \PhpParser\Node\Expr\StaticCall || $argValue instanceof \PhpParser\Node\Expr\MethodCall) { + if ($argValue instanceof StaticCall || $argValue instanceof MethodCall) { // now! // 1. extract assign - $dateTimeVariable = new \PhpParser\Node\Expr\Variable('dateTime'); - $assign = new \PhpParser\Node\Expr\Assign($dateTimeVariable, $argValue); + $dateTimeVariable = new Variable('dateTime'); + $assign = new Assign($dateTimeVariable, $argValue); $this->nodesToAddCollector->addNodeBeforeNode($assign, $node); - if (!$node->args[2] instanceof \PhpParser\Node\Arg) { + if (!$node->args[2] instanceof Arg) { return null; } $node->args[2]->value = $dateTimeVariable; - if (!$node->args[1] instanceof \PhpParser\Node\Arg) { + if (!$node->args[1] instanceof Arg) { return null; } // update assign ">" → ">=" @@ -88,7 +88,7 @@ CODE_SAMPLE $this->nodesToAddCollector->addNodeAfterNode($whereTimeMethodCall, $node); return $node; } - if ($argValue instanceof \PhpParser\Node\Expr\Variable && $node->args[1] instanceof \PhpParser\Node\Arg) { + if ($argValue instanceof Variable && $node->args[1] instanceof Arg) { $dateTimeVariable = $argValue; $this->changeCompareSignExpr($node->args[1]); // 2. add "whereTime()" time call @@ -97,9 +97,9 @@ CODE_SAMPLE } return null; } - private function matchWhereDateThirdArgValue(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node\Expr + private function matchWhereDateThirdArgValue(MethodCall $methodCall) : ?Expr { - if (!$this->isObjectType($methodCall->var, new \PHPStan\Type\ObjectType('Illuminate\\Database\\Query\\Builder'))) { + if (!$this->isObjectType($methodCall->var, new ObjectType('Illuminate\\Database\\Query\\Builder'))) { return null; } if (!$this->isName($methodCall->name, 'whereDate')) { @@ -108,18 +108,18 @@ CODE_SAMPLE if (!isset($methodCall->args[2])) { return null; } - if (!$methodCall->args[2] instanceof \PhpParser\Node\Arg) { + if (!$methodCall->args[2] instanceof Arg) { return null; } $argValue = $methodCall->args[2]->value; - if (!$this->isObjectType($argValue, new \PHPStan\Type\ObjectType('DateTimeInterface'))) { + if (!$this->isObjectType($argValue, new ObjectType('DateTimeInterface'))) { return null; } // nothing to change if ($this->isCarbonTodayStaticCall($argValue)) { return null; } - if (!$methodCall->args[1] instanceof \PhpParser\Node\Arg) { + if (!$methodCall->args[1] instanceof Arg) { return null; } if ($this->valueResolver->isValues($methodCall->args[1]->value, ['>=', '<='])) { @@ -127,9 +127,9 @@ CODE_SAMPLE } return $argValue; } - private function changeCompareSignExpr(\PhpParser\Node\Arg $arg) : void + private function changeCompareSignExpr(Arg $arg) : void { - if (!$arg->value instanceof \PhpParser\Node\Scalar\String_) { + if (!$arg->value instanceof String_) { return; } $string = $arg->value; @@ -140,17 +140,17 @@ CODE_SAMPLE $string->value = '>='; } } - private function createWhereTimeMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall, \PhpParser\Node\Expr\Variable $dateTimeVariable) : \PhpParser\Node\Expr\MethodCall + private function createWhereTimeMethodCall(MethodCall $methodCall, Variable $dateTimeVariable) : MethodCall { - $whereTimeArgs = [$methodCall->args[0], $methodCall->args[1], new \PhpParser\Node\Arg($dateTimeVariable)]; - return new \PhpParser\Node\Expr\MethodCall($methodCall->var, 'whereTime', $whereTimeArgs); + $whereTimeArgs = [$methodCall->args[0], $methodCall->args[1], new Arg($dateTimeVariable)]; + return new MethodCall($methodCall->var, 'whereTime', $whereTimeArgs); } - private function isCarbonTodayStaticCall(\PhpParser\Node\Expr $expr) : bool + private function isCarbonTodayStaticCall(Expr $expr) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\StaticCall) { + if (!$expr instanceof StaticCall) { return \false; } - $carbonObjectType = new \PHPStan\Type\ObjectType('Carbon\\Carbon'); + $carbonObjectType = new ObjectType('Carbon\\Carbon'); $callerType = $this->nodeTypeResolver->getType($expr->class); if (!$carbonObjectType->isSuperTypeOf($callerType)->yes()) { return \false; diff --git a/vendor/rector/rector-laravel/src/Rector/MethodCall/FactoryApplyingStatesRector.php b/vendor/rector/rector-laravel/src/Rector/MethodCall/FactoryApplyingStatesRector.php index e867a0c1e6e..fa318ee8371 100644 --- a/vendor/rector/rector-laravel/src/Rector/MethodCall/FactoryApplyingStatesRector.php +++ b/vendor/rector/rector-laravel/src/Rector/MethodCall/FactoryApplyingStatesRector.php @@ -10,8 +10,8 @@ use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\VariadicPlaceholder; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see https://laravel.com/docs/7.x/database-testing#creating-models @@ -19,11 +19,11 @@ use RectorPrefix20220607\Webmozart\Assert\Assert; * * @see \Rector\Laravel\Tests\Rector\MethodCall\FactoryApplyingStatesRector\FactoryApplyingStatesRectorTest */ -final class FactoryApplyingStatesRector extends \Rector\Core\Rector\AbstractRector +final class FactoryApplyingStatesRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Call the state methods directly instead of specify the name of state.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Call the state methods directly instead of specify the name of state.', [new CodeSample(<<<'CODE_SAMPLE' $factory->state('delinquent'); $factory->states('premium', 'delinquent'); CODE_SAMPLE @@ -38,22 +38,22 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isNames($node->name, ['state', 'states'])) { return null; } - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Illuminate\\Database\\Eloquent\\FactoryBuilder'))) { + if (!$this->isObjectType($node->var, new ObjectType('Illuminate\\Database\\Eloquent\\FactoryBuilder'))) { return null; } $var = $node->var; $states = $this->getStatesFromArgs($node->args); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($states); + Assert::allString($states); foreach ($states as $state) { $var = $this->nodeFactory->createMethodCall($var, $state); } @@ -65,11 +65,11 @@ CODE_SAMPLE */ private function getStatesFromArgs(array $args) : array { - if (\count($args) === 1 && isset($args[0]) && $args[0] instanceof \PhpParser\Node\Arg) { + if (\count($args) === 1 && isset($args[0]) && $args[0] instanceof Arg) { return (array) $this->valueResolver->getValue($args[0]->value); } return \array_map(function ($arg) { - return $arg instanceof \PhpParser\Node\Arg ? $this->valueResolver->getValue($arg->value) : null; + return $arg instanceof Arg ? $this->valueResolver->getValue($arg->value) : null; }, $args); } } diff --git a/vendor/rector/rector-laravel/src/Rector/MethodCall/RedirectBackToBackHelperRector.php b/vendor/rector/rector-laravel/src/Rector/MethodCall/RedirectBackToBackHelperRector.php index f48501b8ed5..af25799fff7 100644 --- a/vendor/rector/rector-laravel/src/Rector/MethodCall/RedirectBackToBackHelperRector.php +++ b/vendor/rector/rector-laravel/src/Rector/MethodCall/RedirectBackToBackHelperRector.php @@ -11,25 +11,25 @@ use PhpParser\Node\Name; use Rector\Core\Rector\AbstractRector; use Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Laravel\Tests\Rector\MethodCall\RedirectBackToBackHelperRector\RedirectBackToBackHelperRectorTest */ -final class RedirectBackToBackHelperRector extends \Rector\Core\Rector\AbstractRector +final class RedirectBackToBackHelperRector extends AbstractRector { /** * @readonly * @var \Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer */ private $fluentChainMethodCallNodeAnalyzer; - public function __construct(\Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer $fluentChainMethodCallNodeAnalyzer) + public function __construct(FluentChainMethodCallNodeAnalyzer $fluentChainMethodCallNodeAnalyzer) { $this->fluentChainMethodCallNodeAnalyzer = $fluentChainMethodCallNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace `redirect()->back()` and `Redirect::back()` with `back()`', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace `redirect()->back()` and `Redirect::back()` with `back()`', [new CodeSample(<<<'CODE_SAMPLE' use Illuminate\Support\Facades\Redirect; class MyController @@ -68,29 +68,29 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node instanceof MethodCall) { return $this->updateRedirectHelperCall($node); } return $this->updateRedirectStaticCall($node); } - private function updateRedirectHelperCall(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node\Expr\MethodCall + private function updateRedirectHelperCall(MethodCall $methodCall) : ?MethodCall { if (!$this->isName($methodCall->name, 'back')) { return null; } $rootExpr = $this->fluentChainMethodCallNodeAnalyzer->resolveRootExpr($methodCall); - $parentNode = $rootExpr->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node\Expr\MethodCall) { + $parentNode = $rootExpr->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof MethodCall) { return null; } - if (!$parentNode->var instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$parentNode->var instanceof FuncCall) { return null; } if ($parentNode->var->getArgs() !== []) { @@ -100,10 +100,10 @@ CODE_SAMPLE return null; } $this->removeNode($methodCall); - $parentNode->var->name = new \PhpParser\Node\Name('back'); + $parentNode->var->name = new Name('back'); return $parentNode; } - private function updateRedirectStaticCall(\PhpParser\Node\Expr\StaticCall $staticCall) : ?\PhpParser\Node\Expr\FuncCall + private function updateRedirectStaticCall(StaticCall $staticCall) : ?FuncCall { if (!$this->isName($staticCall->class, 'Illuminate\\Support\\Facades\\Redirect')) { return null; @@ -111,6 +111,6 @@ CODE_SAMPLE if (!$this->isName($staticCall->name, 'back')) { return null; } - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('back'), $staticCall->args); + return new FuncCall(new Name('back'), $staticCall->args); } } diff --git a/vendor/rector/rector-laravel/src/Rector/MethodCall/RedirectRouteToToRouteHelperRector.php b/vendor/rector/rector-laravel/src/Rector/MethodCall/RedirectRouteToToRouteHelperRector.php index c812f899031..f52f9bea142 100644 --- a/vendor/rector/rector-laravel/src/Rector/MethodCall/RedirectRouteToToRouteHelperRector.php +++ b/vendor/rector/rector-laravel/src/Rector/MethodCall/RedirectRouteToToRouteHelperRector.php @@ -11,25 +11,25 @@ use PhpParser\Node\Name; use Rector\Core\Rector\AbstractRector; use Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Laravel\Tests\Rector\MethodCall\RedirectRouteToToRouteHelperRector\RedirectRouteToToRouteHelperRectorTest */ -final class RedirectRouteToToRouteHelperRector extends \Rector\Core\Rector\AbstractRector +final class RedirectRouteToToRouteHelperRector extends AbstractRector { /** * @readonly * @var \Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer */ private $fluentChainMethodCallNodeAnalyzer; - public function __construct(\Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer $fluentChainMethodCallNodeAnalyzer) + public function __construct(FluentChainMethodCallNodeAnalyzer $fluentChainMethodCallNodeAnalyzer) { $this->fluentChainMethodCallNodeAnalyzer = $fluentChainMethodCallNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace `redirect()->route("home")` and `Redirect::route("home")` with `to_route("home")`', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace `redirect()->route("home")` and `Redirect::route("home")` with `to_route("home")`', [new CodeSample(<<<'CODE_SAMPLE' use Illuminate\Support\Facades\Redirect; class MyController @@ -68,29 +68,29 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node instanceof MethodCall) { return $this->updateRedirectHelperCall($node); } return $this->updateRedirectStaticCall($node); } - private function updateRedirectHelperCall(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node\Expr\MethodCall + private function updateRedirectHelperCall(MethodCall $methodCall) : ?MethodCall { if (!$this->isName($methodCall->name, 'route')) { return null; } $rootExpr = $this->fluentChainMethodCallNodeAnalyzer->resolveRootExpr($methodCall); - $parentNode = $rootExpr->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node\Expr\MethodCall) { + $parentNode = $rootExpr->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof MethodCall) { return null; } - if (!$parentNode->var instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$parentNode->var instanceof FuncCall) { return null; } if ($parentNode->var->getArgs() !== []) { @@ -100,11 +100,11 @@ CODE_SAMPLE return null; } $this->removeNode($methodCall); - $parentNode->var->name = new \PhpParser\Node\Name('to_route'); + $parentNode->var->name = new Name('to_route'); $parentNode->var->args = $methodCall->getArgs(); return $parentNode; } - private function updateRedirectStaticCall(\PhpParser\Node\Expr\StaticCall $staticCall) : ?\PhpParser\Node\Expr\FuncCall + private function updateRedirectStaticCall(StaticCall $staticCall) : ?FuncCall { if (!$this->isName($staticCall->class, 'Illuminate\\Support\\Facades\\Redirect')) { return null; @@ -112,6 +112,6 @@ CODE_SAMPLE if (!$this->isName($staticCall->name, 'route')) { return null; } - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('to_route'), $staticCall->args); + return new FuncCall(new Name('to_route'), $staticCall->args); } } diff --git a/vendor/rector/rector-laravel/src/Rector/MethodCall/RemoveAllOnDispatchingMethodsWithJobChainingRector.php b/vendor/rector/rector-laravel/src/Rector/MethodCall/RemoveAllOnDispatchingMethodsWithJobChainingRector.php index a91e8d880a6..91181446311 100644 --- a/vendor/rector/rector-laravel/src/Rector/MethodCall/RemoveAllOnDispatchingMethodsWithJobChainingRector.php +++ b/vendor/rector/rector-laravel/src/Rector/MethodCall/RemoveAllOnDispatchingMethodsWithJobChainingRector.php @@ -11,12 +11,12 @@ use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Laravel\Tests\Rector\MethodCall\RemoveAllOnDispatchingMethodsWithJobChainingRector\RemoveAllOnDispatchingMethodsWithJobChainingRectorTest */ -final class RemoveAllOnDispatchingMethodsWithJobChainingRector extends \Rector\Core\Rector\AbstractRector +final class RemoveAllOnDispatchingMethodsWithJobChainingRector extends AbstractRector { /** * @var string @@ -31,13 +31,13 @@ final class RemoveAllOnDispatchingMethodsWithJobChainingRector extends \Rector\C * @var \Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer */ private $fluentChainMethodCallNodeAnalyzer; - public function __construct(\Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer $fluentChainMethodCallNodeAnalyzer) + public function __construct(FluentChainMethodCallNodeAnalyzer $fluentChainMethodCallNodeAnalyzer) { $this->fluentChainMethodCallNodeAnalyzer = $fluentChainMethodCallNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove allOnQueue() and allOnConnection() methods used with job chaining, use the onQueue() and onConnection() methods instead.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove allOnQueue() and allOnConnection() methods used with job chaining, use the onQueue() and onConnection() methods instead.', [new CodeSample(<<<'CODE_SAMPLE' Job::withChain([ new ChainJob(), ]) @@ -60,23 +60,23 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isNames($node->name, \array_keys(self::SWAPPED_METHODS))) { return null; } $rootExpr = $this->fluentChainMethodCallNodeAnalyzer->resolveRootExpr($node); - if (!$this->isObjectType($rootExpr, new \PHPStan\Type\ObjectType('Illuminate\\Foundation\\Bus\\Dispatchable'))) { + if (!$this->isObjectType($rootExpr, new ObjectType('Illuminate\\Foundation\\Bus\\Dispatchable'))) { return null; } // Note that this change only affects code using the withChain method. - $callerNode = $rootExpr->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$callerNode instanceof \PhpParser\Node\Expr\StaticCall) { + $callerNode = $rootExpr->getAttribute(AttributeKey::PARENT_NODE); + if (!$callerNode instanceof StaticCall) { return null; } if (!$this->isName($callerNode->name, 'withChain')) { @@ -89,11 +89,11 @@ CODE_SAMPLE // These methods should be called before calling the dispatch method. $end = $node->var; $current = $node->var; - while ($current instanceof \PhpParser\Node\Expr\MethodCall) { + while ($current instanceof MethodCall) { if ($this->isName($current->name, self::DISPATCH)) { $var = $current->var; $current->var = $node; - $node->name = new \PhpParser\Node\Identifier(self::SWAPPED_METHODS[$this->getName($node->name)]); + $node->name = new Identifier(self::SWAPPED_METHODS[$this->getName($node->name)]); $node->var = $var; break; } diff --git a/vendor/rector/rector-laravel/src/Rector/Namespace_/FactoryDefinitionRector.php b/vendor/rector/rector-laravel/src/Rector/Namespace_/FactoryDefinitionRector.php index a2f425859a7..db0d63788f0 100644 --- a/vendor/rector/rector-laravel/src/Rector/Namespace_/FactoryDefinitionRector.php +++ b/vendor/rector/rector-laravel/src/Rector/Namespace_/FactoryDefinitionRector.php @@ -18,28 +18,28 @@ use PhpParser\Node\Stmt\Namespace_; use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace; use Rector\Core\Rector\AbstractRector; use Rector\Laravel\NodeFactory\ModelFactoryNodeFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://laravel.com/docs/7.x/database-testing#writing-factories * @see https://laravel.com/docs/8.x/database-testing#defining-model-factories * * @see \Rector\Laravel\Tests\Rector\Namespace_\FactoryDefinitionRector\FactoryDefinitionRectorTest */ -final class FactoryDefinitionRector extends \Rector\Core\Rector\AbstractRector +final class FactoryDefinitionRector extends AbstractRector { /** * @readonly * @var \Rector\Laravel\NodeFactory\ModelFactoryNodeFactory */ private $modelFactoryNodeFactory; - public function __construct(\Rector\Laravel\NodeFactory\ModelFactoryNodeFactory $modelFactoryNodeFactory) + public function __construct(ModelFactoryNodeFactory $modelFactoryNodeFactory) { $this->modelFactoryNodeFactory = $modelFactoryNodeFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Upgrade legacy factories to support classes.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Upgrade legacy factories to support classes.', [new CodeSample(<<<'CODE_SAMPLE' use Faker\Generator as Faker; $factory->define(App\User::class, function (Faker $faker) { @@ -71,23 +71,23 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Namespace_::class, \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace::class]; + return [Namespace_::class, FileWithoutNamespace::class]; } /** * @param Namespace_|FileWithoutNamespace $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $factories = []; foreach ($node->stmts as $key => $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { continue; } // do not refactor if factory variable changed if ($this->isReAssignFactoryVariable($stmt->expr)) { return null; } - if (!$stmt->expr instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$stmt->expr instanceof MethodCall) { continue; } if ($this->shouldSkipExpression($stmt->expr)) { @@ -96,7 +96,7 @@ CODE_SAMPLE /** @var Arg $firstArg */ $firstArg = $stmt->expr->args[0]; $name = $this->getNameFromClassConstFetch($firstArg->value); - if (!$name instanceof \PhpParser\Node\Name) { + if (!$name instanceof Name) { continue; } if (!isset($factories[$name->toString()])) { @@ -111,41 +111,41 @@ CODE_SAMPLE $node->stmts = \array_merge($node->stmts, $factories); return $node; } - private function isReAssignFactoryVariable(\PhpParser\Node\Expr $expr) : bool + private function isReAssignFactoryVariable(Expr $expr) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$expr instanceof Assign) { return \false; } return $this->isName($expr->var, 'factory'); } - private function shouldSkipExpression(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + private function shouldSkipExpression(MethodCall $methodCall) : bool { if (!isset($methodCall->args[0])) { return \true; } - if (!$methodCall->args[0] instanceof \PhpParser\Node\Arg) { + if (!$methodCall->args[0] instanceof Arg) { return \true; } - if (!$methodCall->args[0]->value instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if (!$methodCall->args[0]->value instanceof ClassConstFetch) { return \true; } return !$this->isNames($methodCall->name, ['define', 'state', 'afterMaking', 'afterCreating']); } - private function getNameFromClassConstFetch(\PhpParser\Node\Expr $expr) : ?\PhpParser\Node\Name + private function getNameFromClassConstFetch(Expr $expr) : ?Name { - if (!$expr instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if (!$expr instanceof ClassConstFetch) { return null; } - if ($expr->class instanceof \PhpParser\Node\Expr) { + if ($expr->class instanceof Expr) { return null; } return $expr->class; } - private function createFactory(string $name, \PhpParser\Node\Expr $expr) : \PhpParser\Node\Stmt\Class_ + private function createFactory(string $name, Expr $expr) : Class_ { return $this->modelFactoryNodeFactory->createEmptyFactory($name, $expr); } - private function processFactoryConfiguration(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Expr\MethodCall $methodCall) : void + private function processFactoryConfiguration(Class_ $class, MethodCall $methodCall) : void { if (!$this->isName($methodCall->var, 'factory')) { return; @@ -165,42 +165,42 @@ CODE_SAMPLE } $this->appendAfterCalling($class, $methodCall, $name); } - private function addDefinition(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Expr\MethodCall $methodCall) : void + private function addDefinition(Class_ $class, MethodCall $methodCall) : void { if (!isset($methodCall->args[1])) { return; } - if (!$methodCall->args[1] instanceof \PhpParser\Node\Arg) { + if (!$methodCall->args[1] instanceof Arg) { return; } $callback = $methodCall->args[1]->value; - if (!$callback instanceof \PhpParser\Node\Expr\Closure) { + if (!$callback instanceof Closure) { return; } $class->stmts[] = $this->modelFactoryNodeFactory->createDefinition($callback); } - private function addState(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Expr\MethodCall $methodCall) : void + private function addState(Class_ $class, MethodCall $methodCall) : void { $classMethod = $this->modelFactoryNodeFactory->createStateMethod($methodCall); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$classMethod instanceof ClassMethod) { return; } $class->stmts[] = $classMethod; } - private function appendAfterCalling(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Expr\MethodCall $methodCall, string $name) : void + private function appendAfterCalling(Class_ $class, MethodCall $methodCall, string $name) : void { if (!isset($methodCall->args[1])) { return; } - if (!$methodCall->args[1] instanceof \PhpParser\Node\Arg) { + if (!$methodCall->args[1] instanceof Arg) { return; } $closure = $methodCall->args[1]->value; - if (!$closure instanceof \PhpParser\Node\Expr\Closure) { + if (!$closure instanceof Closure) { return; } $method = $class->getMethod('configure'); - if (!$method instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$method instanceof ClassMethod) { $method = $this->modelFactoryNodeFactory->createEmptyConfigure(); $class->stmts[] = $method; } diff --git a/vendor/rector/rector-laravel/src/Rector/New_/AddGuardToLoginEventRector.php b/vendor/rector/rector-laravel/src/Rector/New_/AddGuardToLoginEventRector.php index 09b4dee6158..c618759f074 100644 --- a/vendor/rector/rector-laravel/src/Rector/New_/AddGuardToLoginEventRector.php +++ b/vendor/rector/rector-laravel/src/Rector/New_/AddGuardToLoginEventRector.php @@ -10,19 +10,19 @@ use PhpParser\Node\Expr\New_; use PhpParser\Node\Expr\Variable; use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/laravel/framework/commit/f5d8c0a673aa9fc6cd94aa4858a0027fe550a22e#diff-162a49c054acde9f386ec735607b95bc4a1c0c765a6f46da8de9a8a4ef5199d3 * @see https://github.com/laravel/framework/pull/25261 * * @see \Rector\Laravel\Tests\Rector\New_\AddGuardToLoginEventRector\AddGuardToLoginEventRectorTest */ -final class AddGuardToLoginEventRector extends \Rector\Core\Rector\AbstractRector +final class AddGuardToLoginEventRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add new $guard argument to Illuminate\\Auth\\Events\\Login', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add new $guard argument to Illuminate\\Auth\\Events\\Login', [new CodeSample(<<<'CODE_SAMPLE' use Illuminate\Auth\Events\Login; final class SomeClass @@ -52,12 +52,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\New_::class]; + return [New_::class]; } /** * @param New_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node->class, 'Illuminate\\Auth\\Events\\Login')) { return null; @@ -65,15 +65,15 @@ CODE_SAMPLE if (\count($node->args) === 3) { return null; } - $guardVariable = new \PhpParser\Node\Expr\Variable('guard'); + $guardVariable = new Variable('guard'); $assign = $this->createGuardAssign($guardVariable); $this->nodesToAddCollector->addNodeBeforeNode($assign, $node); - $node->args = \array_merge([new \PhpParser\Node\Arg($guardVariable)], $node->args); + $node->args = \array_merge([new Arg($guardVariable)], $node->args); return $node; } - private function createGuardAssign(\PhpParser\Node\Expr\Variable $guardVariable) : \PhpParser\Node\Expr\Assign + private function createGuardAssign(Variable $guardVariable) : Assign { - $string = new \PhpParser\Node\Scalar\String_('auth.defaults.guard'); - return new \PhpParser\Node\Expr\Assign($guardVariable, $this->nodeFactory->createFuncCall('config', [$string])); + $string = new String_('auth.defaults.guard'); + return new Assign($guardVariable, $this->nodeFactory->createFuncCall('config', [$string])); } } diff --git a/vendor/rector/rector-laravel/src/Rector/PropertyFetch/OptionalToNullsafeOperatorRector.php b/vendor/rector/rector-laravel/src/Rector/PropertyFetch/OptionalToNullsafeOperatorRector.php index 5968e6dd816..3b2b4857958 100644 --- a/vendor/rector/rector-laravel/src/Rector/PropertyFetch/OptionalToNullsafeOperatorRector.php +++ b/vendor/rector/rector-laravel/src/Rector/PropertyFetch/OptionalToNullsafeOperatorRector.php @@ -21,8 +21,8 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersion; use Rector\VersionBonding\Contract\MinPhpVersionInterface; use RectorPrefix20220607\Symplify\PackageBuilder\Php\TypeChecker; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see https://github.com/laravel/laravel/pull/5670 @@ -31,7 +31,7 @@ use RectorPrefix20220607\Webmozart\Assert\Assert; * * @see \Rector\Laravel\Tests\Rector\PropertyFetch\OptionalToNullsafeOperatorRector\OptionalToNullsafeOperatorRectorTest */ -final class OptionalToNullsafeOperatorRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface, \Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface +final class OptionalToNullsafeOperatorRector extends AbstractRector implements MinPhpVersionInterface, AllowEmptyConfigurableRectorInterface { /** * @var string @@ -40,7 +40,7 @@ final class OptionalToNullsafeOperatorRector extends \Rector\Core\Rector\Abstrac /** * @var array> */ - private const SKIP_VALUE_TYPES = [\PhpParser\Node\Expr\ConstFetch::class, \PhpParser\Node\Scalar::class, \PhpParser\Node\Expr\Array_::class, \PhpParser\Node\Expr\ClassConstFetch::class]; + private const SKIP_VALUE_TYPES = [ConstFetch::class, Scalar::class, Array_::class, ClassConstFetch::class]; /** * @var string[] */ @@ -55,14 +55,14 @@ final class OptionalToNullsafeOperatorRector extends \Rector\Core\Rector\Abstrac * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Php\TypeChecker $typeChecker, \Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(TypeChecker $typeChecker, ArgsAnalyzer $argsAnalyzer) { $this->typeChecker = $typeChecker; $this->argsAnalyzer = $argsAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Convert simple calls to optional helper to use the nullsafe operator', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Convert simple calls to optional helper to use the nullsafe operator', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' optional($user)->getKey(); optional($user)->id; // macro methods @@ -81,21 +81,21 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\PropertyFetch::class, \PhpParser\Node\Expr\MethodCall::class]; + return [PropertyFetch::class, MethodCall::class]; } /** * @param MethodCall|PropertyFetch $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->var instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$node->var instanceof FuncCall) { return null; } if (!$this->isName($node->var->name, 'optional')) { return null; } // exclude macro methods - if ($node instanceof \PhpParser\Node\Expr\MethodCall && $this->isNames($node->name, $this->excludeMethods)) { + if ($node instanceof MethodCall && $this->isNames($node->name, $this->excludeMethods)) { return null; } if (!$this->argsAnalyzer->isArgInstanceInArgsPosition($node->var->args, 0)) { @@ -111,14 +111,14 @@ CODE_SAMPLE if ($this->typeChecker->isInstanceOf($firstArg->value, self::SKIP_VALUE_TYPES)) { return null; } - if ($node instanceof \PhpParser\Node\Expr\PropertyFetch) { - return new \PhpParser\Node\Expr\NullsafePropertyFetch($firstArg->value, $node->name); + if ($node instanceof PropertyFetch) { + return new NullsafePropertyFetch($firstArg->value, $node->name); } - return new \PhpParser\Node\Expr\NullsafeMethodCall($firstArg->value, $node->name, $node->args); + return new NullsafeMethodCall($firstArg->value, $node->name, $node->args); } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersion::PHP_80; + return PhpVersion::PHP_80; } /** * @param mixed[] $configuration @@ -126,12 +126,12 @@ CODE_SAMPLE public function configure(array $configuration) : void { $excludeMethods = $configuration[self::EXCLUDE_METHODS] ?? $configuration; - \RectorPrefix20220607\Webmozart\Assert\Assert::isArray($excludeMethods); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($excludeMethods); + Assert::isArray($excludeMethods); + Assert::allString($excludeMethods); $this->excludeMethods = $excludeMethods; } - private function hasCallback(\PhpParser\Node\Expr\FuncCall $funcCall) : bool + private function hasCallback(FuncCall $funcCall) : bool { - return isset($funcCall->args[1]) && $funcCall->args[1] instanceof \PhpParser\Node\Arg && !$this->valueResolver->isNull($funcCall->args[1]->value); + return isset($funcCall->args[1]) && $funcCall->args[1] instanceof Arg && !$this->valueResolver->isNull($funcCall->args[1]->value); } } diff --git a/vendor/rector/rector-laravel/src/Rector/StaticCall/MinutesToSecondsInCacheRector.php b/vendor/rector/rector-laravel/src/Rector/StaticCall/MinutesToSecondsInCacheRector.php index 6171d666405..5012a2aa289 100644 --- a/vendor/rector/rector-laravel/src/Rector/StaticCall/MinutesToSecondsInCacheRector.php +++ b/vendor/rector/rector-laravel/src/Rector/StaticCall/MinutesToSecondsInCacheRector.php @@ -12,15 +12,15 @@ use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Scalar\LNumber; use Rector\Core\Rector\AbstractRector; use Rector\Laravel\ValueObject\TypeToTimeMethodAndPosition; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/laravel/framework/pull/27276 * @see https://laravel.com/docs/5.8/upgrade#cache-ttl-in-seconds * * @see \Rector\Laravel\Tests\Rector\StaticCall\MinutesToSecondsInCacheRector\MinutesToSecondsInCacheRectorTest */ -final class MinutesToSecondsInCacheRector extends \Rector\Core\Rector\AbstractRector +final class MinutesToSecondsInCacheRector extends AbstractRector { /** * @var string @@ -40,11 +40,11 @@ final class MinutesToSecondsInCacheRector extends \Rector\Core\Rector\AbstractRe private $typeToTimeMethodsAndPositions = []; public function __construct() { - $this->typeToTimeMethodsAndPositions = [new \Rector\Laravel\ValueObject\TypeToTimeMethodAndPosition('Illuminate\\Support\\Facades\\Cache', self::PUT, 2), new \Rector\Laravel\ValueObject\TypeToTimeMethodAndPosition('Illuminate\\Contracts\\Cache\\Repository', self::PUT, 2), new \Rector\Laravel\ValueObject\TypeToTimeMethodAndPosition('Illuminate\\Contracts\\Cache\\Store', self::PUT, 2), new \Rector\Laravel\ValueObject\TypeToTimeMethodAndPosition('Illuminate\\Contracts\\Cache\\Repository', self::ADD, 2), new \Rector\Laravel\ValueObject\TypeToTimeMethodAndPosition('Illuminate\\Contracts\\Cache\\Store', self::ADD, 2), new \Rector\Laravel\ValueObject\TypeToTimeMethodAndPosition('Illuminate\\Support\\Facades\\Cache', self::ADD, 2), new \Rector\Laravel\ValueObject\TypeToTimeMethodAndPosition('Illuminate\\Contracts\\Cache\\Repository', self::REMEMBER, 2), new \Rector\Laravel\ValueObject\TypeToTimeMethodAndPosition('Illuminate\\Support\\Facades\\Cache', self::REMEMBER, 2), new \Rector\Laravel\ValueObject\TypeToTimeMethodAndPosition('Illuminate\\Contracts\\Cache\\Store', self::REMEMBER, 2), new \Rector\Laravel\ValueObject\TypeToTimeMethodAndPosition('Illuminate\\Contracts\\Cache\\Store', 'putMany', 1)]; + $this->typeToTimeMethodsAndPositions = [new TypeToTimeMethodAndPosition('Illuminate\\Support\\Facades\\Cache', self::PUT, 2), new TypeToTimeMethodAndPosition('Illuminate\\Contracts\\Cache\\Repository', self::PUT, 2), new TypeToTimeMethodAndPosition('Illuminate\\Contracts\\Cache\\Store', self::PUT, 2), new TypeToTimeMethodAndPosition('Illuminate\\Contracts\\Cache\\Repository', self::ADD, 2), new TypeToTimeMethodAndPosition('Illuminate\\Contracts\\Cache\\Store', self::ADD, 2), new TypeToTimeMethodAndPosition('Illuminate\\Support\\Facades\\Cache', self::ADD, 2), new TypeToTimeMethodAndPosition('Illuminate\\Contracts\\Cache\\Repository', self::REMEMBER, 2), new TypeToTimeMethodAndPosition('Illuminate\\Support\\Facades\\Cache', self::REMEMBER, 2), new TypeToTimeMethodAndPosition('Illuminate\\Contracts\\Cache\\Store', self::REMEMBER, 2), new TypeToTimeMethodAndPosition('Illuminate\\Contracts\\Cache\\Store', 'putMany', 1)]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change minutes argument to seconds in Illuminate\\Contracts\\Cache\\Store and Illuminate\\Support\\Facades\\Cache', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change minutes argument to seconds in Illuminate\\Contracts\\Cache\\Store and Illuminate\\Support\\Facades\\Cache', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -69,15 +69,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class, \PhpParser\Node\Expr\MethodCall::class]; + return [StaticCall::class, MethodCall::class]; } /** * @param StaticCall|MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach ($this->typeToTimeMethodsAndPositions as $typeToTimeMethodAndPosition) { - if (!$this->isObjectType($node instanceof \PhpParser\Node\Expr\MethodCall ? $node->var : $node->class, $typeToTimeMethodAndPosition->getObjectType())) { + if (!$this->isObjectType($node instanceof MethodCall ? $node->var : $node->class, $typeToTimeMethodAndPosition->getObjectType())) { continue; } if (!$this->isName($node->name, $typeToTimeMethodAndPosition->getMethodName())) { @@ -86,7 +86,7 @@ CODE_SAMPLE if (!isset($node->args[$typeToTimeMethodAndPosition->getPosition()])) { continue; } - if (!$node->args[$typeToTimeMethodAndPosition->getPosition()] instanceof \PhpParser\Node\Arg) { + if (!$node->args[$typeToTimeMethodAndPosition->getPosition()] instanceof Arg) { continue; } $argValue = $node->args[$typeToTimeMethodAndPosition->getPosition()]->value; @@ -98,17 +98,17 @@ CODE_SAMPLE * @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $node * @return \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall|null */ - private function processArgumentOnPosition($node, \PhpParser\Node\Expr $argExpr, int $argumentPosition) + private function processArgumentOnPosition($node, Expr $argExpr, int $argumentPosition) { if (!$this->nodeTypeResolver->isNumberType($argExpr)) { return null; } // already multiplied - if ($argExpr instanceof \PhpParser\Node\Expr\BinaryOp\Mul) { + if ($argExpr instanceof Mul) { return null; } - $mul = new \PhpParser\Node\Expr\BinaryOp\Mul($argExpr, new \PhpParser\Node\Scalar\LNumber(60)); - $node->args[$argumentPosition] = new \PhpParser\Node\Arg($mul); + $mul = new Mul($argExpr, new LNumber(60)); + $node->args[$argumentPosition] = new Arg($mul); return $node; } } diff --git a/vendor/rector/rector-laravel/src/Rector/StaticCall/Redirect301ToPermanentRedirectRector.php b/vendor/rector/rector-laravel/src/Rector/StaticCall/Redirect301ToPermanentRedirectRector.php index bd7689f0d93..89a4ab725d8 100644 --- a/vendor/rector/rector-laravel/src/Rector/StaticCall/Redirect301ToPermanentRedirectRector.php +++ b/vendor/rector/rector-laravel/src/Rector/StaticCall/Redirect301ToPermanentRedirectRector.php @@ -9,13 +9,13 @@ use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Identifier; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://laravel.com/docs/5.7/upgrade * @see \Rector\Laravel\Tests\Rector\StaticCall\Redirect301ToPermanentRedirectRector\Redirect301ToPermanentRedirectRectorTest */ -final class Redirect301ToPermanentRedirectRector extends \Rector\Core\Rector\AbstractRector +final class Redirect301ToPermanentRedirectRector extends AbstractRector { /** * @var ObjectType[] @@ -23,11 +23,11 @@ final class Redirect301ToPermanentRedirectRector extends \Rector\Core\Rector\Abs private $routerObjectTypes = []; public function __construct() { - $this->routerObjectTypes = [new \PHPStan\Type\ObjectType('Illuminate\\Support\\Facades\\Route'), new \PHPStan\Type\ObjectType('Illuminate\\Routing\\Route')]; + $this->routerObjectTypes = [new ObjectType('Illuminate\\Support\\Facades\\Route'), new ObjectType('Illuminate\\Routing\\Route')]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change "redirect" call with 301 to "permanentRedirect"', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change "redirect" call with 301 to "permanentRedirect"', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -52,12 +52,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class]; + return [StaticCall::class]; } /** * @param StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->nodeTypeResolver->isObjectTypes($node->class, $this->routerObjectTypes)) { return null; @@ -65,7 +65,7 @@ CODE_SAMPLE if (!isset($node->args[2])) { return null; } - if (!$node->args[2] instanceof \PhpParser\Node\Arg) { + if (!$node->args[2] instanceof Arg) { return null; } $is301 = $this->valueResolver->isValue($node->args[2]->value, 301); @@ -73,7 +73,7 @@ CODE_SAMPLE return null; } unset($node->args[2]); - $node->name = new \PhpParser\Node\Identifier('permanentRedirect'); + $node->name = new Identifier('permanentRedirect'); return $node; } } diff --git a/vendor/rector/rector-laravel/src/Rector/StaticCall/RequestStaticValidateToInjectRector.php b/vendor/rector/rector-laravel/src/Rector/StaticCall/RequestStaticValidateToInjectRector.php index bf40b616d35..8937a97f6ee 100644 --- a/vendor/rector/rector-laravel/src/Rector/StaticCall/RequestStaticValidateToInjectRector.php +++ b/vendor/rector/rector-laravel/src/Rector/StaticCall/RequestStaticValidateToInjectRector.php @@ -13,13 +13,13 @@ use PhpParser\Node\Stmt\Class_; use PHPStan\Type\ObjectType; use Rector\Core\NodeManipulator\ClassMethodManipulator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/laravel/framework/pull/27276 * @see \Rector\Laravel\Tests\Rector\StaticCall\RequestStaticValidateToInjectRector\RequestStaticValidateToInjectRectorTest */ -final class RequestStaticValidateToInjectRector extends \Rector\Core\Rector\AbstractRector +final class RequestStaticValidateToInjectRector extends AbstractRector { /** * @var ObjectType[] @@ -30,14 +30,14 @@ final class RequestStaticValidateToInjectRector extends \Rector\Core\Rector\Abst * @var \Rector\Core\NodeManipulator\ClassMethodManipulator */ private $classMethodManipulator; - public function __construct(\Rector\Core\NodeManipulator\ClassMethodManipulator $classMethodManipulator) + public function __construct(ClassMethodManipulator $classMethodManipulator) { $this->classMethodManipulator = $classMethodManipulator; - $this->requestObjectTypes = [new \PHPStan\Type\ObjectType('Illuminate\\Http\\Request'), new \PHPStan\Type\ObjectType('Request')]; + $this->requestObjectTypes = [new ObjectType('Illuminate\\Http\\Request'), new ObjectType('Request')]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change static validate() method to $request->validate()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change static validate() method to $request->validate()', [new CodeSample(<<<'CODE_SAMPLE' use Illuminate\Http\Request; class SomeClass @@ -66,40 +66,40 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class, \PhpParser\Node\Expr\FuncCall::class]; + return [StaticCall::class, FuncCall::class]; } /** * @param StaticCall|FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } - $requestName = $this->classMethodManipulator->addMethodParameterIfMissing($node, new \PHPStan\Type\ObjectType('Illuminate\\Http\\Request'), ['request', 'httpRequest']); - $variable = new \PhpParser\Node\Expr\Variable($requestName); + $requestName = $this->classMethodManipulator->addMethodParameterIfMissing($node, new ObjectType('Illuminate\\Http\\Request'), ['request', 'httpRequest']); + $variable = new Variable($requestName); $methodName = $this->getName($node->name); if ($methodName === null) { return null; } - if ($node instanceof \PhpParser\Node\Expr\FuncCall) { + if ($node instanceof FuncCall) { if ($node->args === []) { return $variable; } $methodName = 'input'; } - return new \PhpParser\Node\Expr\MethodCall($variable, new \PhpParser\Node\Identifier($methodName), $node->args); + return new MethodCall($variable, new Identifier($methodName), $node->args); } /** * @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\FuncCall $node */ private function shouldSkip($node) : bool { - if ($node instanceof \PhpParser\Node\Expr\StaticCall) { + if ($node instanceof StaticCall) { return !$this->nodeTypeResolver->isObjectTypes($node->class, $this->requestObjectTypes); } - $class = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$class instanceof Class_) { return \true; } return !$this->isName($node, 'request'); diff --git a/vendor/rector/rector-laravel/src/Rector/StaticCall/RouteActionCallableRector.php b/vendor/rector/rector-laravel/src/Rector/StaticCall/RouteActionCallableRector.php index 90683c0ab6c..00c77555b86 100644 --- a/vendor/rector/rector-laravel/src/Rector/StaticCall/RouteActionCallableRector.php +++ b/vendor/rector/rector-laravel/src/Rector/StaticCall/RouteActionCallableRector.php @@ -16,16 +16,16 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; use Rector\Laravel\NodeFactory\RouterRegisterNodeAnalyzer; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see https://laravel.com/docs/8.x/upgrade#automatic-controller-namespace-prefixing * * @see \Rector\Laravel\Tests\Rector\StaticCall\RouteActionCallableRector\RouteActionCallableRectorTest */ -final class RouteActionCallableRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class RouteActionCallableRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var string @@ -57,14 +57,14 @@ final class RouteActionCallableRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Laravel\NodeFactory\RouterRegisterNodeAnalyzer */ private $routerRegisterNodeAnalyzer; - public function __construct(\Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\Laravel\NodeFactory\RouterRegisterNodeAnalyzer $routerRegisterNodeAnalyzer) + public function __construct(ReflectionResolver $reflectionResolver, RouterRegisterNodeAnalyzer $routerRegisterNodeAnalyzer) { $this->reflectionResolver = $reflectionResolver; $this->routerRegisterNodeAnalyzer = $routerRegisterNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Use PHP callable syntax instead of string syntax for controller route declarations.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Use PHP callable syntax instead of string syntax for controller route declarations.', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' Route::get('/users', 'UserController@index'); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -77,12 +77,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param Node\Expr\MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->routerRegisterNodeAnalyzer->isRegisterMethodStaticCall($node)) { return null; @@ -91,7 +91,7 @@ CODE_SAMPLE if (!isset($node->args[$position])) { return null; } - if (!$node->args[$position] instanceof \PhpParser\Node\Arg) { + if (!$node->args[$position] instanceof Arg) { return null; } $arg = $node->args[$position]; @@ -100,12 +100,12 @@ CODE_SAMPLE if ($segments === null) { return null; } - $scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { + $scope = $node->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { return null; } $phpMethodReflection = $this->reflectionResolver->resolveMethodReflection($segments[0], $segments[1], $scope); - if (!$phpMethodReflection instanceof \PHPStan\Reflection\Php\PhpMethodReflection) { + if (!$phpMethodReflection instanceof PhpMethodReflection) { return null; } $node->args[$position]->value = $this->nodeFactory->createArray([$this->nodeFactory->createClassConstReference($segments[0]), $segments[1]]); @@ -117,12 +117,12 @@ CODE_SAMPLE public function configure(array $configuration) : void { $routes = $configuration[self::ROUTES] ?? []; - \RectorPrefix20220607\Webmozart\Assert\Assert::isArray($routes); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString(\array_keys($routes)); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($routes); + Assert::isArray($routes); + Assert::allString(\array_keys($routes)); + Assert::allString($routes); $this->routes = $routes; $namespace = $configuration[self::NAMESPACE] ?? self::DEFAULT_NAMESPACE; - \RectorPrefix20220607\Webmozart\Assert\Assert::string($namespace); + Assert::string($namespace); $this->namespace = $namespace; } /** @@ -169,7 +169,7 @@ CODE_SAMPLE } return \strpos($action, '@') !== \false; } - private function getNamespace(\Symplify\SmartFileSystem\SmartFileInfo $fileInfo) : string + private function getNamespace(SmartFileInfo $fileInfo) : string { $realpath = $fileInfo->getRealPath(); return $this->routes[$realpath] ?? $this->namespace; diff --git a/vendor/rector/rector-laravel/src/Set/LaravelLevelSetList.php b/vendor/rector/rector-laravel/src/Set/LaravelLevelSetList.php index 34c11a99784..882ad68b34e 100644 --- a/vendor/rector/rector-laravel/src/Set/LaravelLevelSetList.php +++ b/vendor/rector/rector-laravel/src/Set/LaravelLevelSetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Laravel\Set; use Rector\Set\Contract\SetListInterface; -final class LaravelLevelSetList implements \Rector\Set\Contract\SetListInterface +final class LaravelLevelSetList implements SetListInterface { /** * @var string diff --git a/vendor/rector/rector-laravel/src/Set/LaravelSetList.php b/vendor/rector/rector-laravel/src/Set/LaravelSetList.php index 697843a7b34..d5961a37fc4 100644 --- a/vendor/rector/rector-laravel/src/Set/LaravelSetList.php +++ b/vendor/rector/rector-laravel/src/Set/LaravelSetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Laravel\Set; use Rector\Set\Contract\SetListInterface; -final class LaravelSetList implements \Rector\Set\Contract\SetListInterface +final class LaravelSetList implements SetListInterface { /** * @var string diff --git a/vendor/rector/rector-laravel/src/ValueObject/AddArgumentDefaultValue.php b/vendor/rector/rector-laravel/src/ValueObject/AddArgumentDefaultValue.php index f902982f812..a72a43cd172 100644 --- a/vendor/rector/rector-laravel/src/ValueObject/AddArgumentDefaultValue.php +++ b/vendor/rector/rector-laravel/src/ValueObject/AddArgumentDefaultValue.php @@ -35,9 +35,9 @@ final class AddArgumentDefaultValue $this->position = $position; $this->defaultValue = $defaultValue; } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->class); + return new ObjectType($this->class); } public function getMethod() : string { diff --git a/vendor/rector/rector-laravel/src/ValueObject/TypeToTimeMethodAndPosition.php b/vendor/rector/rector-laravel/src/ValueObject/TypeToTimeMethodAndPosition.php index 7e9698b3a40..d29294e1ac8 100644 --- a/vendor/rector/rector-laravel/src/ValueObject/TypeToTimeMethodAndPosition.php +++ b/vendor/rector/rector-laravel/src/ValueObject/TypeToTimeMethodAndPosition.php @@ -27,9 +27,9 @@ final class TypeToTimeMethodAndPosition $this->methodName = $methodName; $this->position = $position; } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->type); + return new ObjectType($this->type); } public function getMethodName() : string { diff --git a/vendor/rector/rector-nette/config/config.php b/vendor/rector/rector-nette/config/config.php index 5c8c121d110..dc57031f66a 100644 --- a/vendor/rector/rector-nette/config/config.php +++ b/vendor/rector/rector-nette/config/config.php @@ -7,12 +7,12 @@ use Rector\Config\RectorConfig; use Rector\Core\NonPhpFile\Rector\RenameClassNonPhpRector; use Rector\Nette\Rector\Latte\RenameMethodLatteRector; use Rector\Nette\Rector\Neon\RenameMethodNeonRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $rectorConfig->import(__DIR__ . '/packages.php'); $services = $rectorConfig->services(); $services->defaults()->public()->autowire()->autoconfigure(); $services->load('Rector\\Nette\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/Contract', __DIR__ . '/../src/Rector', __DIR__ . '/../src/ValueObject', __DIR__ . '/../src/Kdyby/Rector', __DIR__ . '/../src/Kdyby/ValueObject']); - $rectorConfig->rule(\Rector\Core\NonPhpFile\Rector\RenameClassNonPhpRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\Neon\RenameMethodNeonRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\Latte\RenameMethodLatteRector::class); + $rectorConfig->rule(RenameClassNonPhpRector::class); + $rectorConfig->rule(RenameMethodNeonRector::class); + $rectorConfig->rule(RenameMethodLatteRector::class); }; diff --git a/vendor/rector/rector-nette/config/packages.php b/vendor/rector/rector-nette/config/packages.php index 9a18b9d2479..5bbd6d025c2 100644 --- a/vendor/rector/rector-nette/config/packages.php +++ b/vendor/rector/rector-nette/config/packages.php @@ -8,5 +8,5 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { $services = $rectorConfig->services(); $services->defaults()->public()->autowire()->autoconfigure(); $services->load('Rector\\Nette\\NeonParser\\', __DIR__ . '/../packages/NeonParser')->exclude([__DIR__ . '/../packages/NeonParser/NeonNodeTraverser.php', __DIR__ . '/../packages/NeonParser/Node']); - $services->set(\RectorPrefix20220607\Nette\Neon\Decoder::class); + $services->set(Decoder::class); }; diff --git a/vendor/rector/rector-nette/config/sets/contributte/apitte-attributes.php b/vendor/rector/rector-nette/config/sets/contributte/apitte-attributes.php index f8fdbbcbef4..b6bcc6a3dae 100644 --- a/vendor/rector/rector-nette/config/sets/contributte/apitte-attributes.php +++ b/vendor/rector/rector-nette/config/sets/contributte/apitte-attributes.php @@ -7,5 +7,5 @@ use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; use Rector\Php80\ValueObject\AnnotationToAttribute; // @see https://github.com/apitte/core/pull/161 return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class, [new \Rector\Php80\ValueObject\AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\Id'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\Method'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\Negotiation'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\OpenApi'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\Path'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\RequestBody'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\RequestParameter'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\Response'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\Tag')]); + $rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [new AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\Id'), new AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\Method'), new AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\Negotiation'), new AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\OpenApi'), new AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\Path'), new AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\RequestBody'), new AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\RequestParameter'), new AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\Response'), new AnnotationToAttribute('Apitte\\Core\\Annotation\\Controller\\Tag')]); }; diff --git a/vendor/rector/rector-nette/config/sets/kdyby/kdyby-events-to-contributte-event-dispatcher.php b/vendor/rector/rector-nette/config/sets/kdyby/kdyby-events-to-contributte-event-dispatcher.php index bec24af3485..b43cf4191fc 100644 --- a/vendor/rector/rector-nette/config/sets/kdyby/kdyby-events-to-contributte-event-dispatcher.php +++ b/vendor/rector/rector-nette/config/sets/kdyby/kdyby-events-to-contributte-event-dispatcher.php @@ -10,9 +10,9 @@ use Rector\Nette\Kdyby\Rector\MethodCall\ReplaceEventManagerWithEventSubscriberR use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector; use Rector\Visibility\ValueObject\ChangeMethodVisibility; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Nette\Kdyby\Rector\ClassMethod\ChangeNetteEventNamesInGetSubscribedEventsRector::class); - $rectorConfig->rule(\Rector\Nette\Kdyby\Rector\MethodCall\ReplaceEventManagerWithEventSubscriberRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector::class, [new \Rector\Visibility\ValueObject\ChangeMethodVisibility('Kdyby\\Events\\Subscriber', 'getSubscribedEvents', \Rector\Core\ValueObject\Visibility::STATIC)]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Kdyby\\Events\\Subscriber' => 'Symfony\\Component\\EventDispatcher\\EventSubscriberInterface', 'Kdyby\\Events\\EventManager' => 'Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface']); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(ChangeNetteEventNamesInGetSubscribedEventsRector::class); + $rectorConfig->rule(ReplaceEventManagerWithEventSubscriberRector::class); + $rectorConfig->ruleWithConfiguration(ChangeMethodVisibilityRector::class, [new ChangeMethodVisibility('Kdyby\\Events\\Subscriber', 'getSubscribedEvents', Visibility::STATIC)]); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Kdyby\\Events\\Subscriber' => 'Symfony\\Component\\EventDispatcher\\EventSubscriberInterface', 'Kdyby\\Events\\EventManager' => 'Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface']); }; diff --git a/vendor/rector/rector-nette/config/sets/kdyby/kdyby-rabbit-mq-to-symfony.php b/vendor/rector/rector-nette/config/sets/kdyby/kdyby-rabbit-mq-to-symfony.php index 349312f9e8e..7b348906487 100644 --- a/vendor/rector/rector-nette/config/sets/kdyby/kdyby-rabbit-mq-to-symfony.php +++ b/vendor/rector/rector-nette/config/sets/kdyby/kdyby-rabbit-mq-to-symfony.php @@ -7,7 +7,7 @@ use Rector\Config\RectorConfig; use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Renaming\ValueObject\MethodCallRename; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Kdyby\\RabbitMq\\IConsumer', 'process', 'execute')]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Kdyby\\RabbitMq\\IConsumer' => 'OldSound\\RabbitMqBundle\\RabbitMq\\ConsumerInterface', 'Kdyby\\RabbitMq\\IProducer' => 'OldSound\\RabbitMqBundle\\RabbitMq\\ProducerInterface']); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Kdyby\\RabbitMq\\IConsumer', 'process', 'execute')]); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Kdyby\\RabbitMq\\IConsumer' => 'OldSound\\RabbitMqBundle\\RabbitMq\\ConsumerInterface', 'Kdyby\\RabbitMq\\IProducer' => 'OldSound\\RabbitMqBundle\\RabbitMq\\ProducerInterface']); }; diff --git a/vendor/rector/rector-nette/config/sets/kdyby/kdyby-translator-to-contributte-translation.php b/vendor/rector/rector-nette/config/sets/kdyby/kdyby-translator-to-contributte-translation.php index 1c0544ebac7..e091b18a6e2 100644 --- a/vendor/rector/rector-nette/config/sets/kdyby/kdyby-translator-to-contributte-translation.php +++ b/vendor/rector/rector-nette/config/sets/kdyby/kdyby-translator-to-contributte-translation.php @@ -8,8 +8,8 @@ use Rector\Nette\Kdyby\Rector\MethodCall\WrapTransParameterNameRector; use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Renaming\ValueObject\MethodCallRename; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Kdyby\\Translation\\Translator', 'translate', 'trans')]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Kdyby\\Translation\\Translator' => 'Nette\\Localization\\ITranslator', 'Kdyby\\Translation\\DI\\ITranslationProvider' => 'Contributte\\Translation\\DI\\TranslationProviderInterface', 'Kdyby\\Translation\\Phrase' => 'Contributte\\Translation\\Wrappers\\Message']); - $rectorConfig->rule(\Rector\Nette\Kdyby\Rector\MethodCall\WrapTransParameterNameRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Kdyby\\Translation\\Translator', 'translate', 'trans')]); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Kdyby\\Translation\\Translator' => 'Nette\\Localization\\ITranslator', 'Kdyby\\Translation\\DI\\ITranslationProvider' => 'Contributte\\Translation\\DI\\TranslationProviderInterface', 'Kdyby\\Translation\\Phrase' => 'Contributte\\Translation\\Wrappers\\Message']); + $rectorConfig->rule(WrapTransParameterNameRector::class); }; diff --git a/vendor/rector/rector-nette/config/sets/nette-24.php b/vendor/rector/rector-nette/config/sets/nette-24.php index e29e7cde6b5..20fbe597c70 100644 --- a/vendor/rector/rector-nette/config/sets/nette-24.php +++ b/vendor/rector/rector-nette/config/sets/nette-24.php @@ -7,6 +7,6 @@ use Rector\Config\RectorConfig; use Rector\Transform\Rector\Class_\ParentClassToTraitsRector; use Rector\Transform\ValueObject\ParentClassToTraits; // @see https://doc.nette.org/en/2.4/migration-2-4#toc-nette-smartobject -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\Class_\ParentClassToTraitsRector::class, [new \Rector\Transform\ValueObject\ParentClassToTraits('Nette\\Object', ['Nette\\SmartObject'])]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(ParentClassToTraitsRector::class, [new ParentClassToTraits('Nette\\Object', ['Nette\\SmartObject'])]); }; diff --git a/vendor/rector/rector-nette/config/sets/nette-30.php b/vendor/rector/rector-nette/config/sets/nette-30.php index 69d5780636d..d0474c0722f 100644 --- a/vendor/rector/rector-nette/config/sets/nette-30.php +++ b/vendor/rector/rector-nette/config/sets/nette-30.php @@ -22,18 +22,18 @@ use Rector\Renaming\ValueObject\RenameClassConstFetch; use Rector\Transform\Rector\StaticCall\StaticCallToMethodCallRector; use Rector\Transform\ValueObject\StaticCallToMethodCall; use Rector\TypeDeclaration\Rector\MethodCall\FormerNullableArgumentToScalarTypedRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $rectorConfig->sets([__DIR__ . '/nette-30/nette-30-composer.php', __DIR__ . '/nette-30/nette-30-dependency-injection.php', __DIR__ . '/nette-30/nette-30-return-types.php', __DIR__ . '/nette-30/nette-30-param-types.php']); - $rectorConfig->rule(\Rector\Nette\Rector\MethodCall\AddNextrasDatePickerToDateControlRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\MethodCall\MergeDefaultsInGetConfigCompilerExtensionRector::class); + $rectorConfig->rule(AddNextrasDatePickerToDateControlRector::class); + $rectorConfig->rule(MergeDefaultsInGetConfigCompilerExtensionRector::class); // Control class has remove __construct(), e.g. https://github.com/Pixidos/GPWebPay/pull/16/files#diff-fdc8251950f85c5467c63c249df05786 - $rectorConfig->rule(\Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector::class); + $rectorConfig->rule(RemoveParentCallWithoutParentRector::class); // https://github.com/nette/utils/commit/d0041ba59f5d8bf1f5b3795fd76d43fb13ea2e15 - $rectorConfig->rule(\Rector\TypeDeclaration\Rector\MethodCall\FormerNullableArgumentToScalarTypedRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\StaticCall\StaticCallToMethodCallRector::class, [new \Rector\Transform\ValueObject\StaticCallToMethodCall('Nette\\Security\\Passwords', 'hash', 'Nette\\Security\\Passwords', 'hash'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Nette\\Security\\Passwords', 'verify', 'Nette\\Security\\Passwords', 'verify'), new \Rector\Transform\ValueObject\StaticCallToMethodCall('Nette\\Security\\Passwords', 'needsRehash', 'Nette\\Security\\Passwords', 'needsRehash')]); + $rectorConfig->rule(FormerNullableArgumentToScalarTypedRector::class); + $rectorConfig->ruleWithConfiguration(StaticCallToMethodCallRector::class, [new StaticCallToMethodCall('Nette\\Security\\Passwords', 'hash', 'Nette\\Security\\Passwords', 'hash'), new StaticCallToMethodCall('Nette\\Security\\Passwords', 'verify', 'Nette\\Security\\Passwords', 'verify'), new StaticCallToMethodCall('Nette\\Security\\Passwords', 'needsRehash', 'Nette\\Security\\Passwords', 'needsRehash')]); // https://github.com/contributte/event-dispatcher-extra/tree/v0.4.3 and higher - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector::class, [new \Rector\Renaming\ValueObject\RenameClassConstFetch('Contributte\\Events\\Extra\\Event\\Security\\LoggedInEvent', 'NAME', 'class'), new \Rector\Renaming\ValueObject\RenameClassConstFetch('Contributte\\Events\\Extra\\Event\\Security\\LoggedOutEvent', 'NAME', 'class'), new \Rector\Renaming\ValueObject\RenameClassConstFetch('Contributte\\Events\\Extra\\Event\\Application\\ShutdownEvent', 'NAME', 'class')]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, [ + $rectorConfig->ruleWithConfiguration(RenameClassConstFetchRector::class, [new RenameClassConstFetch('Contributte\\Events\\Extra\\Event\\Security\\LoggedInEvent', 'NAME', 'class'), new RenameClassConstFetch('Contributte\\Events\\Extra\\Event\\Security\\LoggedOutEvent', 'NAME', 'class'), new RenameClassConstFetch('Contributte\\Events\\Extra\\Event\\Application\\ShutdownEvent', 'NAME', 'class')]); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ # nextras/forms was split into 2 packages 'Nextras\\FormComponents\\Controls\\DatePicker' => 'Nextras\\FormComponents\\Controls\\DateControl', # @see https://github.com/nette/di/commit/a0d361192f8ac35f1d9f82aab7eb351e4be395ea @@ -41,28 +41,28 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { 'Nette\\DI\\Statement' => 'Nette\\DI\\Definitions\\Statement', 'WebChemistry\\Forms\\Controls\\Multiplier' => 'Contributte\\FormMultiplier\\Multiplier', ]); - $rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\ClassMethod\ReplaceArgumentDefaultValueRector::class, [ + $rectorConfig->ruleWithConfiguration(ReplaceArgumentDefaultValueRector::class, [ // json 2nd argument is now `int` typed - new \Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue('Nette\\Utils\\Json', 'decode', 1, \true, 'Nette\\Utils\\Json::FORCE_ARRAY'), + new ReplaceArgumentDefaultValue('Nette\\Utils\\Json', 'decode', 1, \true, 'Nette\\Utils\\Json::FORCE_ARRAY'), // @see https://github.com/nette/forms/commit/574b97f9d5e7a902a224e57d7d584e7afc9fefec - new \Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue('Nette\\Forms\\Form', 'decode', 0, \true, 'array'), + new ReplaceArgumentDefaultValue('Nette\\Forms\\Form', 'decode', 0, \true, 'array'), ]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [ + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ // see https://github.com/nette/forms/commit/b99385aa9d24d729a18f6397a414ea88eab6895a - new \Rector\Renaming\ValueObject\MethodCallRename('Nette\\Forms\\Controls\\BaseControl', 'setType', 'setHtmlType'), - new \Rector\Renaming\ValueObject\MethodCallRename('Nette\\Forms\\Controls\\BaseControl', 'setAttribute', 'setHtmlAttribute'), - new \Rector\Renaming\ValueObject\MethodCallRename( + new MethodCallRename('Nette\\Forms\\Controls\\BaseControl', 'setType', 'setHtmlType'), + new MethodCallRename('Nette\\Forms\\Controls\\BaseControl', 'setAttribute', 'setHtmlAttribute'), + new MethodCallRename( 'Nette\\DI\\Definitions\\ServiceDefinition', # see https://github.com/nette/di/commit/1705a5db431423fc610a6f339f88dead1b5dc4fb 'setClass', 'setType' ), - new \Rector\Renaming\ValueObject\MethodCallRename('Nette\\DI\\Definitions\\ServiceDefinition', 'getClass', 'getType'), - new \Rector\Renaming\ValueObject\MethodCallRename('Nette\\DI\\Definitions\\Definition', 'isAutowired', 'getAutowired'), + new MethodCallRename('Nette\\DI\\Definitions\\ServiceDefinition', 'getClass', 'getType'), + new MethodCallRename('Nette\\DI\\Definitions\\Definition', 'isAutowired', 'getAutowired'), ]); - $rectorConfig->rule(\Rector\Nette\Rector\MethodCall\MagicHtmlCallToAppendAttributeRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\MethodCall\RequestGetCookieDefaultArgumentToCoalesceRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\ClassMethod\RemoveParentAndNameFromComponentConstructorRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\Class_\MoveFinalGetUserToCheckRequirementsClassMethodRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\MethodCall\ConvertAddUploadWithThirdArgumentTrueToAddMultiUploadRector::class); + $rectorConfig->rule(MagicHtmlCallToAppendAttributeRector::class); + $rectorConfig->rule(RequestGetCookieDefaultArgumentToCoalesceRector::class); + $rectorConfig->rule(RemoveParentAndNameFromComponentConstructorRector::class); + $rectorConfig->rule(MoveFinalGetUserToCheckRequirementsClassMethodRector::class); + $rectorConfig->rule(ConvertAddUploadWithThirdArgumentTrueToAddMultiUploadRector::class); }; diff --git a/vendor/rector/rector-nette/config/sets/nette-30/nette-30-composer.php b/vendor/rector/rector-nette/config/sets/nette-30/nette-30-composer.php index 6dbabef7afd..22732c5e1dc 100644 --- a/vendor/rector/rector-nette/config/sets/nette-30/nette-30-composer.php +++ b/vendor/rector/rector-nette/config/sets/nette-30/nette-30-composer.php @@ -9,39 +9,39 @@ use Rector\Composer\Rector\ReplacePackageAndVersionComposerRector; use Rector\Composer\ValueObject\PackageAndVersion; use Rector\Composer\ValueObject\ReplacePackageAndVersion; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Composer\Rector\ChangePackageVersionComposerRector::class, [ - new \Rector\Composer\ValueObject\PackageAndVersion('nette/nette', '^3.0'), +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(ChangePackageVersionComposerRector::class, [ + new PackageAndVersion('nette/nette', '^3.0'), // https://github.com/nette/nette/blob/v2.4.0/composer.json vs https://github.com/nette/nette/blob/v3.0.0/composer.json // older versions have security issues - new \Rector\Composer\ValueObject\PackageAndVersion('nette/application', '^3.0.6'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/bootstrap', '^3.0'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/caching', '^3.0'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/component-model', '^3.0'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/database', '^3.0'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/di', '^3.0'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/finder', '^2.5'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/forms', '^3.0'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/http', '^3.0'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/mail', '^3.0'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/neon', '^3.0'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/php-generator', '^3.0'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/robot-loader', '^3.0'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/safe-stream', '^2.4'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/security', '^3.0'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/tokenizer', '^3.0'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/utils', '^3.0'), - new \Rector\Composer\ValueObject\PackageAndVersion('latte/latte', '^2.5'), - new \Rector\Composer\ValueObject\PackageAndVersion('tracy/tracy', '^2.6'), + new PackageAndVersion('nette/application', '^3.0.6'), + new PackageAndVersion('nette/bootstrap', '^3.0'), + new PackageAndVersion('nette/caching', '^3.0'), + new PackageAndVersion('nette/component-model', '^3.0'), + new PackageAndVersion('nette/database', '^3.0'), + new PackageAndVersion('nette/di', '^3.0'), + new PackageAndVersion('nette/finder', '^2.5'), + new PackageAndVersion('nette/forms', '^3.0'), + new PackageAndVersion('nette/http', '^3.0'), + new PackageAndVersion('nette/mail', '^3.0'), + new PackageAndVersion('nette/neon', '^3.0'), + new PackageAndVersion('nette/php-generator', '^3.0'), + new PackageAndVersion('nette/robot-loader', '^3.0'), + new PackageAndVersion('nette/safe-stream', '^2.4'), + new PackageAndVersion('nette/security', '^3.0'), + new PackageAndVersion('nette/tokenizer', '^3.0'), + new PackageAndVersion('nette/utils', '^3.0'), + new PackageAndVersion('latte/latte', '^2.5'), + new PackageAndVersion('tracy/tracy', '^2.6'), // contributte packages - new \Rector\Composer\ValueObject\PackageAndVersion('contributte/event-dispatcher-extra', '^0.8'), - new \Rector\Composer\ValueObject\PackageAndVersion('contributte/forms-multiplier', '3.1.x-dev'), + new PackageAndVersion('contributte/event-dispatcher-extra', '^0.8'), + new PackageAndVersion('contributte/forms-multiplier', '3.1.x-dev'), // other packages - new \Rector\Composer\ValueObject\PackageAndVersion('radekdostal/nette-datetimepicker', '^3.0'), + new PackageAndVersion('radekdostal/nette-datetimepicker', '^3.0'), ]); - $rectorConfig->ruleWithConfiguration(\Rector\Composer\Rector\RemovePackageComposerRector::class, ['nette/deprecated', 'nette/reflection']); - $rectorConfig->ruleWithConfiguration(\Rector\Composer\Rector\ReplacePackageAndVersionComposerRector::class, [ + $rectorConfig->ruleWithConfiguration(RemovePackageComposerRector::class, ['nette/deprecated', 'nette/reflection']); + $rectorConfig->ruleWithConfiguration(ReplacePackageAndVersionComposerRector::class, [ // webchemistry to contributte - new \Rector\Composer\ValueObject\ReplacePackageAndVersion('webchemistry/forms-multiplier', 'contributte/forms-multiplier', '3.1.x-dev'), + new ReplacePackageAndVersion('webchemistry/forms-multiplier', 'contributte/forms-multiplier', '3.1.x-dev'), ]); }; diff --git a/vendor/rector/rector-nette/config/sets/nette-30/nette-30-dependency-injection.php b/vendor/rector/rector-nette/config/sets/nette-30/nette-30-dependency-injection.php index 36d085a4b20..d4eaf2b01e0 100644 --- a/vendor/rector/rector-nette/config/sets/nette-30/nette-30-dependency-injection.php +++ b/vendor/rector/rector-nette/config/sets/nette-30/nette-30-dependency-injection.php @@ -6,7 +6,7 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Nette\Rector\MethodCall\BuilderExpandToHelperExpandRector; use Rector\Nette\Rector\MethodCall\SetClassWithArgumentToSetFactoryRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Nette\Rector\MethodCall\SetClassWithArgumentToSetFactoryRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\MethodCall\BuilderExpandToHelperExpandRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(SetClassWithArgumentToSetFactoryRector::class); + $rectorConfig->rule(BuilderExpandToHelperExpandRector::class); }; diff --git a/vendor/rector/rector-nette/config/sets/nette-30/nette-30-param-types.php b/vendor/rector/rector-nette/config/sets/nette-30/nette-30-param-types.php index 6e75d3d4572..80764c86bc5 100644 --- a/vendor/rector/rector-nette/config/sets/nette-30/nette-30-param-types.php +++ b/vendor/rector/rector-nette/config/sets/nette-30/nette-30-param-types.php @@ -17,10 +17,10 @@ use Rector\Core\ValueObject\MethodName; use Rector\Nette\Rector\ClassMethod\TranslateClassMethodToVariadicsRector; use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector; use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Nette\Rector\ClassMethod\TranslateClassMethodToVariadicsRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(TranslateClassMethodToVariadicsRector::class); # scalar type hints, see https://github.com/nette/component-model/commit/f69df2ca224cad7b07f1c8835679393263ea6771 # scalar param types https://github.com/nette/security/commit/84024f612fb3f55f5d6e3e3e28eef1ad0388fa56 - $iterableType = new \PHPStan\Type\IterableType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); - $rectorConfig->ruleWithConfiguration(\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::class, [new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\ComponentModel\\Component', 'lookup', 0, new \PHPStan\Type\UnionType([new \PHPStan\Type\StringType(), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\ComponentModel\\Component', 'lookup', 1, new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\ComponentModel\\Component', 'lookupPath', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\ComponentModel\\Component', 'lookupPath', 1, new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\ComponentModel\\Component', 'monitor', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\ComponentModel\\Component', 'unmonitor', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\ComponentModel\\Component', 'attached', 0, new \PHPStan\Type\ObjectType('Nette\\ComponentModel\\IComponent')), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\ComponentModel\\Component', 'detached', 0, new \PHPStan\Type\ObjectType('Nette\\ComponentModel\\IComponent')), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\ComponentModel\\Component', 'link', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\ComponentModel\\Container', 'getComponent', 1, new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\ComponentModel\\Container', 'createComponent', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\ComponentModel\\IComponent', 'setParent', 0, new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\ComponentModel\\IContainer'), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\ComponentModel\\IComponent', 'setParent', 1, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\ComponentModel\\IContainer', 'getComponents', 0, new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Forms\\Container', 'addSelect', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Forms\\Container', 'addSelect', 3, new \PHPStan\Type\IntegerType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Forms\\Container', 'addMultiSelect', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Forms\\Container', 'addMultiSelect', 3, new \PHPStan\Type\IntegerType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Forms\\Rendering\\DefaultFormRenderer', 'render', 1, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('RadekDostal\\NetteComponents\\DateTimePicker\\DateTimePicker', 'register', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Bridges\\SecurityDI\\SecurityExtension', \Rector\Core\ValueObject\MethodName::CONSTRUCT, 0, new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\IUserStorage', 'setAuthenticated', 0, new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\IUserStorage', 'setIdentity', 0, new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\Security\\IIdentity'), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\IUserStorage', 'setExpiration', 1, new \PHPStan\Type\IntegerType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Identity', \Rector\Core\ValueObject\MethodName::CONSTRUCT, 2, $iterableType), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Identity', '__set', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Identity', '&__get', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Identity', '__isset', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Passwords', 'hash', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Passwords', 'verify', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Passwords', 'verify', 1, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Passwords', 'needsRehash', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Permission', 'addRole', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Permission', 'hasRole', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Permission', 'getRoleParents', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Permission', 'removeRole', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Permission', 'addResource', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Permission', 'addResource', 1, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Permission', 'hasResource', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Permission', 'resourceInheritsFrom', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Permission', 'resourceInheritsFrom', 1, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Permission', 'resourceInheritsFrom', 2, new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Permission', 'removeResource', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Permission', 'allow', 3, new \PHPStan\Type\CallableType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Permission', 'deny', 3, new \PHPStan\Type\CallableType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Permission', 'setRule', 0, new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Permission', 'setRule', 1, new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\Permission', 'setRule', 5, new \PHPStan\Type\CallableType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\User', 'logout', 0, new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\User', 'getAuthenticator', 0, new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\User', 'isInRole', 0, new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\User', 'getAuthorizator', 0, new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Security\\User', 'getAuthorizator', 1, new \PHPStan\Type\StringType())]); + $iterableType = new IterableType(new MixedType(), new MixedType()); + $rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [new AddParamTypeDeclaration('Nette\\ComponentModel\\Component', 'lookup', 0, new UnionType([new StringType(), new NullType()])), new AddParamTypeDeclaration('Nette\\ComponentModel\\Component', 'lookup', 1, new BooleanType()), new AddParamTypeDeclaration('Nette\\ComponentModel\\Component', 'lookupPath', 0, new StringType()), new AddParamTypeDeclaration('Nette\\ComponentModel\\Component', 'lookupPath', 1, new BooleanType()), new AddParamTypeDeclaration('Nette\\ComponentModel\\Component', 'monitor', 0, new StringType()), new AddParamTypeDeclaration('Nette\\ComponentModel\\Component', 'unmonitor', 0, new StringType()), new AddParamTypeDeclaration('Nette\\ComponentModel\\Component', 'attached', 0, new ObjectType('Nette\\ComponentModel\\IComponent')), new AddParamTypeDeclaration('Nette\\ComponentModel\\Component', 'detached', 0, new ObjectType('Nette\\ComponentModel\\IComponent')), new AddParamTypeDeclaration('Nette\\ComponentModel\\Component', 'link', 0, new StringType()), new AddParamTypeDeclaration('Nette\\ComponentModel\\Container', 'getComponent', 1, new BooleanType()), new AddParamTypeDeclaration('Nette\\ComponentModel\\Container', 'createComponent', 0, new StringType()), new AddParamTypeDeclaration('Nette\\ComponentModel\\IComponent', 'setParent', 0, new UnionType([new ObjectType('Nette\\ComponentModel\\IContainer'), new NullType()])), new AddParamTypeDeclaration('Nette\\ComponentModel\\IComponent', 'setParent', 1, new StringType()), new AddParamTypeDeclaration('Nette\\ComponentModel\\IContainer', 'getComponents', 0, new BooleanType()), new AddParamTypeDeclaration('Nette\\Forms\\Container', 'addSelect', 0, new StringType()), new AddParamTypeDeclaration('Nette\\Forms\\Container', 'addSelect', 3, new IntegerType()), new AddParamTypeDeclaration('Nette\\Forms\\Container', 'addMultiSelect', 0, new StringType()), new AddParamTypeDeclaration('Nette\\Forms\\Container', 'addMultiSelect', 3, new IntegerType()), new AddParamTypeDeclaration('Nette\\Forms\\Rendering\\DefaultFormRenderer', 'render', 1, new StringType()), new AddParamTypeDeclaration('RadekDostal\\NetteComponents\\DateTimePicker\\DateTimePicker', 'register', 0, new StringType()), new AddParamTypeDeclaration('Nette\\Bridges\\SecurityDI\\SecurityExtension', MethodName::CONSTRUCT, 0, new BooleanType()), new AddParamTypeDeclaration('Nette\\Security\\IUserStorage', 'setAuthenticated', 0, new BooleanType()), new AddParamTypeDeclaration('Nette\\Security\\IUserStorage', 'setIdentity', 0, new UnionType([new ObjectType('Nette\\Security\\IIdentity'), new NullType()])), new AddParamTypeDeclaration('Nette\\Security\\IUserStorage', 'setExpiration', 1, new IntegerType()), new AddParamTypeDeclaration('Nette\\Security\\Identity', MethodName::CONSTRUCT, 2, $iterableType), new AddParamTypeDeclaration('Nette\\Security\\Identity', '__set', 0, new StringType()), new AddParamTypeDeclaration('Nette\\Security\\Identity', '&__get', 0, new StringType()), new AddParamTypeDeclaration('Nette\\Security\\Identity', '__isset', 0, new StringType()), new AddParamTypeDeclaration('Nette\\Security\\Passwords', 'hash', 0, new StringType()), new AddParamTypeDeclaration('Nette\\Security\\Passwords', 'verify', 0, new StringType()), new AddParamTypeDeclaration('Nette\\Security\\Passwords', 'verify', 1, new StringType()), new AddParamTypeDeclaration('Nette\\Security\\Passwords', 'needsRehash', 0, new StringType()), new AddParamTypeDeclaration('Nette\\Security\\Permission', 'addRole', 0, new StringType()), new AddParamTypeDeclaration('Nette\\Security\\Permission', 'hasRole', 0, new StringType()), new AddParamTypeDeclaration('Nette\\Security\\Permission', 'getRoleParents', 0, new StringType()), new AddParamTypeDeclaration('Nette\\Security\\Permission', 'removeRole', 0, new StringType()), new AddParamTypeDeclaration('Nette\\Security\\Permission', 'addResource', 0, new StringType()), new AddParamTypeDeclaration('Nette\\Security\\Permission', 'addResource', 1, new StringType()), new AddParamTypeDeclaration('Nette\\Security\\Permission', 'hasResource', 0, new StringType()), new AddParamTypeDeclaration('Nette\\Security\\Permission', 'resourceInheritsFrom', 0, new StringType()), new AddParamTypeDeclaration('Nette\\Security\\Permission', 'resourceInheritsFrom', 1, new StringType()), new AddParamTypeDeclaration('Nette\\Security\\Permission', 'resourceInheritsFrom', 2, new BooleanType()), new AddParamTypeDeclaration('Nette\\Security\\Permission', 'removeResource', 0, new StringType()), new AddParamTypeDeclaration('Nette\\Security\\Permission', 'allow', 3, new CallableType()), new AddParamTypeDeclaration('Nette\\Security\\Permission', 'deny', 3, new CallableType()), new AddParamTypeDeclaration('Nette\\Security\\Permission', 'setRule', 0, new BooleanType()), new AddParamTypeDeclaration('Nette\\Security\\Permission', 'setRule', 1, new BooleanType()), new AddParamTypeDeclaration('Nette\\Security\\Permission', 'setRule', 5, new CallableType()), new AddParamTypeDeclaration('Nette\\Security\\User', 'logout', 0, new BooleanType()), new AddParamTypeDeclaration('Nette\\Security\\User', 'getAuthenticator', 0, new BooleanType()), new AddParamTypeDeclaration('Nette\\Security\\User', 'isInRole', 0, new StringType()), new AddParamTypeDeclaration('Nette\\Security\\User', 'getAuthorizator', 0, new BooleanType()), new AddParamTypeDeclaration('Nette\\Security\\User', 'getAuthorizator', 1, new StringType())]); }; diff --git a/vendor/rector/rector-nette/config/sets/nette-30/nette-30-return-types.php b/vendor/rector/rector-nette/config/sets/nette-30/nette-30-return-types.php index 82b8729a736..67a9564c6d9 100644 --- a/vendor/rector/rector-nette/config/sets/nette-30/nette-30-return-types.php +++ b/vendor/rector/rector-nette/config/sets/nette-30/nette-30-return-types.php @@ -15,8 +15,8 @@ use PHPStan\Type\VoidType; use Rector\Config\RectorConfig; use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector; use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { # scalar type hints, see https://github.com/nette/security/commit/84024f612fb3f55f5d6e3e3e28eef1ad0388fa56 - $arrayType = new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); - $rectorConfig->ruleWithConfiguration(\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::class, [new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Mail\\Mailer', 'send', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Forms\\Rendering\\DefaultFormRenderer', 'renderControl', new \PHPStan\Type\ObjectType('Nette\\Utils\\Html')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Forms\\Container', 'addContainer', new \PHPStan\Type\ObjectType('Nette\\Forms\\Container')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Forms\\Container', 'addSelect', new \PHPStan\Type\ObjectType('Nette\\Forms\\Controls\\SelectBox')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Forms\\Container', 'addMultiSelect', new \PHPStan\Type\ObjectType('Nette\\Forms\\Controls\\MultiSelectBox')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Forms\\IFormRenderer', 'render', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Forms\\Controls\\TextBase', 'getControl', new \PHPStan\Type\ObjectType('Nette\\Utils\\Html')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('RadekDostal\\NetteComponents\\DateTimePicker\\DateTimePicker', 'register', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Caching\\Cache', 'generateKey', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Localization\\ITranslator', 'translate', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Security\\IResource', 'getResourceId', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Security\\IAuthenticator', 'authenticate', new \PHPStan\Type\ObjectType('Nette\\Security\\IIdentity')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Security\\IAuthorizator', 'isAllowed', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Security\\Identity', 'getData', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Security\\IIdentity', 'getRoles', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Security\\User', 'getStorage', new \PHPStan\Type\ObjectType('Nette\\Security\\IUserStorage')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Security\\User', 'login', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Security\\User', 'logout', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Security\\User', 'isLoggedIn', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Security\\User', 'getIdentity', new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\Security\\IIdentity'), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Security\\User', 'getAuthenticator', new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\Security\\IAuthenticator'), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Security\\User', 'getAuthorizator', new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\Security\\IAuthorizator'), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Security\\User', 'getLogoutReason', new \PHPStan\Type\UnionType([new \PHPStan\Type\IntegerType(), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Security\\User', 'getRoles', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Security\\User', 'isInRole', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Security\\User', 'isAllowed', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Security\\IUserStorage', 'isAuthenticated', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Security\\IUserStorage', 'getIdentity', new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\Security\\IIdentity'), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Security\\IUserStorage', 'getLogoutReason', new \PHPStan\Type\UnionType([new \PHPStan\Type\IntegerType(), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\ComponentModel\\Component', 'lookup', new \PHPStan\Type\ObjectType('Nette\\ComponentModel\\IComponent')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\ComponentModel\\Component', 'lookupPath', new \PHPStan\Type\UnionType([new \PHPStan\Type\StringType(), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\ComponentModel\\Component', 'monitor', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\ComponentModel\\Component', 'unmonitor', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\ComponentModel\\Component', 'attached', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\ComponentModel\\Component', 'detached', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\ComponentModel\\Component', 'getName', new \PHPStan\Type\UnionType([new \PHPStan\Type\StringType(), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\ComponentModel\\IComponent', 'getName', new \PHPStan\Type\UnionType([new \PHPStan\Type\StringType(), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\ComponentModel\\IComponent', 'getParent', new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\ComponentModel\\IContainer'), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\ComponentModel\\Container', 'removeComponent', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\ComponentModel\\Container', 'getComponent', new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\ComponentModel\\IComponent'), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\ComponentModel\\Container', 'createComponent', new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\ComponentModel\\IComponent'), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\ComponentModel\\Container', 'getComponents', new \PHPStan\Type\ObjectType('Iterator')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\ComponentModel\\Container', 'validateChildComponent', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\ComponentModel\\Container', '_isCloning', new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\ComponentModel\\IComponent'), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\ComponentModel\\IContainer', 'removeComponent', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\ComponentModel\\IContainer', 'getComponent', new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\ComponentModel\\IContainer'), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\ComponentModel\\IContainer', 'getComponents', new \PHPStan\Type\ObjectType('Iterator')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Application', 'run', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Application', 'createInitialRequest', new \PHPStan\Type\ObjectType('Nette\\Application\\Request')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Application', 'processRequest', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Application', 'processException', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Application', 'getRequests', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Application', 'getPresenter', new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\Application\\IPresenter'), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Application', 'getRouter', new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\Application\\IRouter'), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Application', 'getPresenterFactory', new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\Application\\IPresenterFactory'), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Helpers', 'splitName', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\IPresenter', 'run', new \PHPStan\Type\ObjectType('Nette\\Application\\IResponse')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\IPresenterFactory', 'getPresenterClass', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\IPresenterFactory', 'createPresenter', new \PHPStan\Type\ObjectType('Nette\\Application\\IPresenter')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\PresenterFactory', 'formatPresenterClass', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\PresenterFactory', 'unformatPresenterClass', new \PHPStan\Type\UnionType([new \PHPStan\Type\StringType(), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\IResponse', 'send', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Responses\\FileResponse', 'getFile', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Responses\\FileResponse', 'getName', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Responses\\FileResponse', 'getContentType', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Responses\\ForwardResponse', 'getRequest', new \PHPStan\Type\ObjectType('Nette\\Application\\Request')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Request', 'getPresenterName', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Request', 'getParameters', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Request', 'getFiles', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Request', 'getMethod', new \PHPStan\Type\UnionType([new \PHPStan\Type\StringType(), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Request', 'isMethod', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Request', 'hasFlag', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\RedirectResponse', 'getUrl', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\RedirectResponse', 'getCode', new \PHPStan\Type\IntegerType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\JsonResponse', 'getContentType', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\IRouter', 'match', new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\Application\\Request'), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\IRouter', 'constructUrl', new \PHPStan\Type\UnionType([new \PHPStan\Type\StringType(), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Routers\\Route', 'getMask', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Routers\\Route', 'getDefaults', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Routers\\Route', 'getFlags', new \PHPStan\Type\IntegerType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Routers\\Route', 'getTargetPresenters', new \PHPStan\Type\UnionType([$arrayType, new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Routers\\RouteList', 'warmupCache', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Routers\\RouteList', 'offsetSet', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Routers\\RouteList', 'getModule', new \PHPStan\Type\UnionType([new \PHPStan\Type\StringType(), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Routers\\CliRouter', 'getDefaults', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'getPresenter', new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Presenter'), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'getUniqueId', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'tryCall', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'checkRequirements', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'getReflection', new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\ComponentReflection')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'loadState', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'saveState', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'getParameters', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'getParameterId', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'getPersistentParams', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'signalReceived', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'formatSignalMethod', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'link', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'lazyLink', new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Link')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'isLinkCurrent', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'redirect', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'redirectPermanent', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'offsetSet', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'offsetGet', new \PHPStan\Type\ObjectType('Nette\\ComponentModel\\IComponent')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'offsetExists', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'offsetUnset', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getRequest', new \PHPStan\Type\ObjectType('Nette\\Application\\Request')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getPresenter', new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Presenter')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getUniqueId', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'checkRequirements', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'processSignal', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getSignal', new \PHPStan\Type\UnionType([$arrayType, new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'isSignalReceiver', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getAction', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'changeAction', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getView', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'sendTemplate', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'findLayoutTemplateFile', new \PHPStan\Type\UnionType([new \PHPStan\Type\StringType(), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'formatLayoutTemplateFiles', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'formatTemplateFiles', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'formatActionMethod', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'formatRenderMethod', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'createTemplate', new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\ITemplate')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getPayload', new \PHPStan\Type\ObjectType('stdClass')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'isAjax', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'sendPayload', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'sendJson', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'sendResponse', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'terminate', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'forward', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'redirectUrl', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'error', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getLastCreatedRequest', new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\Application\\Request'), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getLastCreatedRequestFlag', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'canonicalize', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'lastModified', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'createRequest', new \PHPStan\Type\UnionType([new \PHPStan\Type\StringType(), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'argsToParams', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'handleInvalidLink', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'storeRequest', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'restoreRequest', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getPersistentComponents', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getGlobalState', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'saveGlobalState', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'initGlobalParameters', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'popGlobalParameters', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getFlashKey', new \PHPStan\Type\UnionType([new \PHPStan\Type\StringType(), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'hasFlashSession', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getFlashSession', new \PHPStan\Type\ObjectType('Nette\\Http\\SessionSection')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getContext', new \PHPStan\Type\ObjectType('Nette\\DI\\Container')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getHttpRequest', new \PHPStan\Type\ObjectType('Nette\\Http\\IRequest')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getHttpResponse', new \PHPStan\Type\ObjectType('Nette\\Http\\IResponse')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getUser', new \PHPStan\Type\ObjectType('Nette\\Security\\User')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getTemplateFactory', new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\ITemplateFactory')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Exception\\BadRequestException', 'getHttpCode', new \PHPStan\Type\IntegerType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationDI\\LatteExtension', 'addMacro', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationDI\\PresenterFactoryCallback', '__invoke', new \PHPStan\Type\ObjectType('Nette\\Application\\IPresenter')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\ILatteFactory', 'create', new \PHPStan\Type\ObjectType('Latte\\Engine')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\Template', 'getLatte', new \PHPStan\Type\ObjectType('Latte\\Engine')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\Template', 'render', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\Template', '__toString', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\Template', 'getFile', new \PHPStan\Type\UnionType([new \PHPStan\Type\StringType(), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\Template', 'getParameters', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\Template', '__set', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\Template', '__unset', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\TemplateFactory', 'createTemplate', new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\ITemplate')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\UIMacros', 'initialize', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationTracy\\RoutingPanel', 'initializePanel', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationTracy\\RoutingPanel', 'getTab', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationTracy\\RoutingPanel', 'getPanel', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\UIRuntime', 'initialize', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\ComponentReflection', 'getPersistentParams', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\ComponentReflection', 'getPersistentComponents', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\ComponentReflection', 'hasCallableMethod', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\ComponentReflection', 'combineArgs', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\ComponentReflection', 'convertType', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\ComponentReflection', 'parseAnnotation', new \PHPStan\Type\UnionType([$arrayType, new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\ComponentReflection', 'getParameterType', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\ComponentReflection', 'hasAnnotation', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\ComponentReflection', 'getMethods', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Control', 'getTemplate', new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\ITemplate')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Control', 'createTemplate', new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\ITemplate')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Control', 'templatePrepareFilters', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Control', 'flashMessage', new \PHPStan\Type\ObjectType('stdClass')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Control', 'redrawControl', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Control', 'isControlInvalid', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Control', 'getSnippetId', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Form', 'getPresenter', new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Presenter'), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Form', 'signalReceived', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\IRenderable', 'redrawControl', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\IRenderable', 'isControlInvalid', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\ITemplate', 'render', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\ITemplate', 'getFile', new \PHPStan\Type\UnionType([new \PHPStan\Type\StringType(), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\ITemplateFactory', 'createTemplate', new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\ITemplate')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Link', 'getDestination', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Link', 'getParameters', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\Link', '__toString', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\MethodReflection', 'hasAnnotation', new \PHPStan\Type\BooleanType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\IStatePersistent', 'loadState', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\IStatePersistent', 'saveState', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\UI\\ISignalReceiver', 'signalReceived', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Routers\\SimpleRouter', 'match', new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\Application\\Request'), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Routers\\SimpleRouter', 'getDefaults', $arrayType), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\Routers\\SimpleRouter', 'getFlags', new \PHPStan\Type\IntegerType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\LinkGenerator', 'link', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\MicroPresenter', 'getContext', new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\DI\\Container'), new \PHPStan\Type\NullType()])), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\MicroPresenter', 'createTemplate', new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\ITemplate')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\MicroPresenter', 'redirectUrl', new \PHPStan\Type\ObjectType('Nette\\Application\\Responses\\RedirectResponse')), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\MicroPresenter', 'error', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Nette\\Application\\MicroPresenter', 'getRequest', new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\Application\\Request'), new \PHPStan\Type\NullType()]))]); + $arrayType = new ArrayType(new MixedType(), new MixedType()); + $rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [new AddReturnTypeDeclaration('Nette\\Mail\\Mailer', 'send', new VoidType()), new AddReturnTypeDeclaration('Nette\\Forms\\Rendering\\DefaultFormRenderer', 'renderControl', new ObjectType('Nette\\Utils\\Html')), new AddReturnTypeDeclaration('Nette\\Forms\\Container', 'addContainer', new ObjectType('Nette\\Forms\\Container')), new AddReturnTypeDeclaration('Nette\\Forms\\Container', 'addSelect', new ObjectType('Nette\\Forms\\Controls\\SelectBox')), new AddReturnTypeDeclaration('Nette\\Forms\\Container', 'addMultiSelect', new ObjectType('Nette\\Forms\\Controls\\MultiSelectBox')), new AddReturnTypeDeclaration('Nette\\Forms\\IFormRenderer', 'render', new StringType()), new AddReturnTypeDeclaration('Nette\\Forms\\Controls\\TextBase', 'getControl', new ObjectType('Nette\\Utils\\Html')), new AddReturnTypeDeclaration('RadekDostal\\NetteComponents\\DateTimePicker\\DateTimePicker', 'register', new VoidType()), new AddReturnTypeDeclaration('Nette\\Caching\\Cache', 'generateKey', new StringType()), new AddReturnTypeDeclaration('Nette\\Localization\\ITranslator', 'translate', new StringType()), new AddReturnTypeDeclaration('Nette\\Security\\IResource', 'getResourceId', new StringType()), new AddReturnTypeDeclaration('Nette\\Security\\IAuthenticator', 'authenticate', new ObjectType('Nette\\Security\\IIdentity')), new AddReturnTypeDeclaration('Nette\\Security\\IAuthorizator', 'isAllowed', new BooleanType()), new AddReturnTypeDeclaration('Nette\\Security\\Identity', 'getData', $arrayType), new AddReturnTypeDeclaration('Nette\\Security\\IIdentity', 'getRoles', $arrayType), new AddReturnTypeDeclaration('Nette\\Security\\User', 'getStorage', new ObjectType('Nette\\Security\\IUserStorage')), new AddReturnTypeDeclaration('Nette\\Security\\User', 'login', new VoidType()), new AddReturnTypeDeclaration('Nette\\Security\\User', 'logout', new VoidType()), new AddReturnTypeDeclaration('Nette\\Security\\User', 'isLoggedIn', new BooleanType()), new AddReturnTypeDeclaration('Nette\\Security\\User', 'getIdentity', new UnionType([new ObjectType('Nette\\Security\\IIdentity'), new NullType()])), new AddReturnTypeDeclaration('Nette\\Security\\User', 'getAuthenticator', new UnionType([new ObjectType('Nette\\Security\\IAuthenticator'), new NullType()])), new AddReturnTypeDeclaration('Nette\\Security\\User', 'getAuthorizator', new UnionType([new ObjectType('Nette\\Security\\IAuthorizator'), new NullType()])), new AddReturnTypeDeclaration('Nette\\Security\\User', 'getLogoutReason', new UnionType([new IntegerType(), new NullType()])), new AddReturnTypeDeclaration('Nette\\Security\\User', 'getRoles', $arrayType), new AddReturnTypeDeclaration('Nette\\Security\\User', 'isInRole', new BooleanType()), new AddReturnTypeDeclaration('Nette\\Security\\User', 'isAllowed', new BooleanType()), new AddReturnTypeDeclaration('Nette\\Security\\IUserStorage', 'isAuthenticated', new BooleanType()), new AddReturnTypeDeclaration('Nette\\Security\\IUserStorage', 'getIdentity', new UnionType([new ObjectType('Nette\\Security\\IIdentity'), new NullType()])), new AddReturnTypeDeclaration('Nette\\Security\\IUserStorage', 'getLogoutReason', new UnionType([new IntegerType(), new NullType()])), new AddReturnTypeDeclaration('Nette\\ComponentModel\\Component', 'lookup', new ObjectType('Nette\\ComponentModel\\IComponent')), new AddReturnTypeDeclaration('Nette\\ComponentModel\\Component', 'lookupPath', new UnionType([new StringType(), new NullType()])), new AddReturnTypeDeclaration('Nette\\ComponentModel\\Component', 'monitor', new VoidType()), new AddReturnTypeDeclaration('Nette\\ComponentModel\\Component', 'unmonitor', new VoidType()), new AddReturnTypeDeclaration('Nette\\ComponentModel\\Component', 'attached', new VoidType()), new AddReturnTypeDeclaration('Nette\\ComponentModel\\Component', 'detached', new VoidType()), new AddReturnTypeDeclaration('Nette\\ComponentModel\\Component', 'getName', new UnionType([new StringType(), new NullType()])), new AddReturnTypeDeclaration('Nette\\ComponentModel\\IComponent', 'getName', new UnionType([new StringType(), new NullType()])), new AddReturnTypeDeclaration('Nette\\ComponentModel\\IComponent', 'getParent', new UnionType([new ObjectType('Nette\\ComponentModel\\IContainer'), new NullType()])), new AddReturnTypeDeclaration('Nette\\ComponentModel\\Container', 'removeComponent', new VoidType()), new AddReturnTypeDeclaration('Nette\\ComponentModel\\Container', 'getComponent', new UnionType([new ObjectType('Nette\\ComponentModel\\IComponent'), new NullType()])), new AddReturnTypeDeclaration('Nette\\ComponentModel\\Container', 'createComponent', new UnionType([new ObjectType('Nette\\ComponentModel\\IComponent'), new NullType()])), new AddReturnTypeDeclaration('Nette\\ComponentModel\\Container', 'getComponents', new ObjectType('Iterator')), new AddReturnTypeDeclaration('Nette\\ComponentModel\\Container', 'validateChildComponent', new VoidType()), new AddReturnTypeDeclaration('Nette\\ComponentModel\\Container', '_isCloning', new UnionType([new ObjectType('Nette\\ComponentModel\\IComponent'), new NullType()])), new AddReturnTypeDeclaration('Nette\\ComponentModel\\IContainer', 'removeComponent', new VoidType()), new AddReturnTypeDeclaration('Nette\\ComponentModel\\IContainer', 'getComponent', new UnionType([new ObjectType('Nette\\ComponentModel\\IContainer'), new NullType()])), new AddReturnTypeDeclaration('Nette\\ComponentModel\\IContainer', 'getComponents', new ObjectType('Iterator')), new AddReturnTypeDeclaration('Nette\\Application\\Application', 'run', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\Application', 'createInitialRequest', new ObjectType('Nette\\Application\\Request')), new AddReturnTypeDeclaration('Nette\\Application\\Application', 'processRequest', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\Application', 'processException', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\Application', 'getRequests', $arrayType), new AddReturnTypeDeclaration('Nette\\Application\\Application', 'getPresenter', new UnionType([new ObjectType('Nette\\Application\\IPresenter'), new NullType()])), new AddReturnTypeDeclaration('Nette\\Application\\Application', 'getRouter', new UnionType([new ObjectType('Nette\\Application\\IRouter'), new NullType()])), new AddReturnTypeDeclaration('Nette\\Application\\Application', 'getPresenterFactory', new UnionType([new ObjectType('Nette\\Application\\IPresenterFactory'), new NullType()])), new AddReturnTypeDeclaration('Nette\\Application\\Helpers', 'splitName', $arrayType), new AddReturnTypeDeclaration('Nette\\Application\\IPresenter', 'run', new ObjectType('Nette\\Application\\IResponse')), new AddReturnTypeDeclaration('Nette\\Application\\IPresenterFactory', 'getPresenterClass', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\IPresenterFactory', 'createPresenter', new ObjectType('Nette\\Application\\IPresenter')), new AddReturnTypeDeclaration('Nette\\Application\\PresenterFactory', 'formatPresenterClass', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\PresenterFactory', 'unformatPresenterClass', new UnionType([new StringType(), new NullType()])), new AddReturnTypeDeclaration('Nette\\Application\\IResponse', 'send', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\Responses\\FileResponse', 'getFile', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\Responses\\FileResponse', 'getName', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\Responses\\FileResponse', 'getContentType', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\Responses\\ForwardResponse', 'getRequest', new ObjectType('Nette\\Application\\Request')), new AddReturnTypeDeclaration('Nette\\Application\\Request', 'getPresenterName', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\Request', 'getParameters', $arrayType), new AddReturnTypeDeclaration('Nette\\Application\\Request', 'getFiles', $arrayType), new AddReturnTypeDeclaration('Nette\\Application\\Request', 'getMethod', new UnionType([new StringType(), new NullType()])), new AddReturnTypeDeclaration('Nette\\Application\\Request', 'isMethod', new BooleanType()), new AddReturnTypeDeclaration('Nette\\Application\\Request', 'hasFlag', new BooleanType()), new AddReturnTypeDeclaration('Nette\\Application\\RedirectResponse', 'getUrl', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\RedirectResponse', 'getCode', new IntegerType()), new AddReturnTypeDeclaration('Nette\\Application\\JsonResponse', 'getContentType', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\IRouter', 'match', new UnionType([new ObjectType('Nette\\Application\\Request'), new NullType()])), new AddReturnTypeDeclaration('Nette\\Application\\IRouter', 'constructUrl', new UnionType([new StringType(), new NullType()])), new AddReturnTypeDeclaration('Nette\\Application\\Routers\\Route', 'getMask', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\Routers\\Route', 'getDefaults', $arrayType), new AddReturnTypeDeclaration('Nette\\Application\\Routers\\Route', 'getFlags', new IntegerType()), new AddReturnTypeDeclaration('Nette\\Application\\Routers\\Route', 'getTargetPresenters', new UnionType([$arrayType, new NullType()])), new AddReturnTypeDeclaration('Nette\\Application\\Routers\\RouteList', 'warmupCache', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\Routers\\RouteList', 'offsetSet', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\Routers\\RouteList', 'getModule', new UnionType([new StringType(), new NullType()])), new AddReturnTypeDeclaration('Nette\\Application\\Routers\\CliRouter', 'getDefaults', $arrayType), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'getPresenter', new UnionType([new ObjectType('Nette\\Application\\UI\\Presenter'), new NullType()])), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'getUniqueId', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'tryCall', new BooleanType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'checkRequirements', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'getReflection', new ObjectType('Nette\\Application\\UI\\ComponentReflection')), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'loadState', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'saveState', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'getParameters', $arrayType), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'getParameterId', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'getPersistentParams', $arrayType), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'signalReceived', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'formatSignalMethod', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'link', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'lazyLink', new ObjectType('Nette\\Application\\UI\\Link')), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'isLinkCurrent', new BooleanType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'redirect', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'redirectPermanent', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'offsetSet', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'offsetGet', new ObjectType('Nette\\ComponentModel\\IComponent')), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'offsetExists', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Component', 'offsetUnset', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getRequest', new ObjectType('Nette\\Application\\Request')), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getPresenter', new ObjectType('Nette\\Application\\UI\\Presenter')), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getUniqueId', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'checkRequirements', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'processSignal', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getSignal', new UnionType([$arrayType, new NullType()])), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'isSignalReceiver', new BooleanType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getAction', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'changeAction', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getView', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'sendTemplate', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'findLayoutTemplateFile', new UnionType([new StringType(), new NullType()])), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'formatLayoutTemplateFiles', $arrayType), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'formatTemplateFiles', $arrayType), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'formatActionMethod', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'formatRenderMethod', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'createTemplate', new ObjectType('Nette\\Application\\UI\\ITemplate')), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getPayload', new ObjectType('stdClass')), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'isAjax', new BooleanType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'sendPayload', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'sendJson', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'sendResponse', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'terminate', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'forward', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'redirectUrl', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'error', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getLastCreatedRequest', new UnionType([new ObjectType('Nette\\Application\\Request'), new NullType()])), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getLastCreatedRequestFlag', new BooleanType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'canonicalize', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'lastModified', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'createRequest', new UnionType([new StringType(), new NullType()])), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'argsToParams', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'handleInvalidLink', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'storeRequest', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'restoreRequest', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getPersistentComponents', $arrayType), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getGlobalState', $arrayType), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'saveGlobalState', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'initGlobalParameters', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'popGlobalParameters', $arrayType), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getFlashKey', new UnionType([new StringType(), new NullType()])), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'hasFlashSession', new BooleanType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getFlashSession', new ObjectType('Nette\\Http\\SessionSection')), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getContext', new ObjectType('Nette\\DI\\Container')), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getHttpRequest', new ObjectType('Nette\\Http\\IRequest')), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getHttpResponse', new ObjectType('Nette\\Http\\IResponse')), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getUser', new ObjectType('Nette\\Security\\User')), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Presenter', 'getTemplateFactory', new ObjectType('Nette\\Application\\UI\\ITemplateFactory')), new AddReturnTypeDeclaration('Nette\\Application\\Exception\\BadRequestException', 'getHttpCode', new IntegerType()), new AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationDI\\LatteExtension', 'addMacro', new VoidType()), new AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationDI\\PresenterFactoryCallback', '__invoke', new ObjectType('Nette\\Application\\IPresenter')), new AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\ILatteFactory', 'create', new ObjectType('Latte\\Engine')), new AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\Template', 'getLatte', new ObjectType('Latte\\Engine')), new AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\Template', 'render', new VoidType()), new AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\Template', '__toString', new StringType()), new AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\Template', 'getFile', new UnionType([new StringType(), new NullType()])), new AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\Template', 'getParameters', $arrayType), new AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\Template', '__set', new VoidType()), new AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\Template', '__unset', new VoidType()), new AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\TemplateFactory', 'createTemplate', new ObjectType('Nette\\Application\\UI\\ITemplate')), new AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\UIMacros', 'initialize', new VoidType()), new AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationTracy\\RoutingPanel', 'initializePanel', new VoidType()), new AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationTracy\\RoutingPanel', 'getTab', new StringType()), new AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationTracy\\RoutingPanel', 'getPanel', new StringType()), new AddReturnTypeDeclaration('Nette\\Bridges\\ApplicationLatte\\UIRuntime', 'initialize', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\ComponentReflection', 'getPersistentParams', $arrayType), new AddReturnTypeDeclaration('Nette\\Application\\UI\\ComponentReflection', 'getPersistentComponents', $arrayType), new AddReturnTypeDeclaration('Nette\\Application\\UI\\ComponentReflection', 'hasCallableMethod', new BooleanType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\ComponentReflection', 'combineArgs', $arrayType), new AddReturnTypeDeclaration('Nette\\Application\\UI\\ComponentReflection', 'convertType', new BooleanType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\ComponentReflection', 'parseAnnotation', new UnionType([$arrayType, new NullType()])), new AddReturnTypeDeclaration('Nette\\Application\\UI\\ComponentReflection', 'getParameterType', $arrayType), new AddReturnTypeDeclaration('Nette\\Application\\UI\\ComponentReflection', 'hasAnnotation', new BooleanType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\ComponentReflection', 'getMethods', $arrayType), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Control', 'getTemplate', new ObjectType('Nette\\Application\\UI\\ITemplate')), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Control', 'createTemplate', new ObjectType('Nette\\Application\\UI\\ITemplate')), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Control', 'templatePrepareFilters', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Control', 'flashMessage', new ObjectType('stdClass')), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Control', 'redrawControl', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Control', 'isControlInvalid', new BooleanType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Control', 'getSnippetId', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Form', 'getPresenter', new UnionType([new ObjectType('Nette\\Application\\UI\\Presenter'), new NullType()])), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Form', 'signalReceived', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\IRenderable', 'redrawControl', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\IRenderable', 'isControlInvalid', new BooleanType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\ITemplate', 'render', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\ITemplate', 'getFile', new UnionType([new StringType(), new NullType()])), new AddReturnTypeDeclaration('Nette\\Application\\UI\\ITemplateFactory', 'createTemplate', new ObjectType('Nette\\Application\\UI\\ITemplate')), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Link', 'getDestination', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Link', 'getParameters', $arrayType), new AddReturnTypeDeclaration('Nette\\Application\\UI\\Link', '__toString', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\MethodReflection', 'hasAnnotation', new BooleanType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\IStatePersistent', 'loadState', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\IStatePersistent', 'saveState', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\UI\\ISignalReceiver', 'signalReceived', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\Routers\\SimpleRouter', 'match', new UnionType([new ObjectType('Nette\\Application\\Request'), new NullType()])), new AddReturnTypeDeclaration('Nette\\Application\\Routers\\SimpleRouter', 'getDefaults', $arrayType), new AddReturnTypeDeclaration('Nette\\Application\\Routers\\SimpleRouter', 'getFlags', new IntegerType()), new AddReturnTypeDeclaration('Nette\\Application\\LinkGenerator', 'link', new StringType()), new AddReturnTypeDeclaration('Nette\\Application\\MicroPresenter', 'getContext', new UnionType([new ObjectType('Nette\\DI\\Container'), new NullType()])), new AddReturnTypeDeclaration('Nette\\Application\\MicroPresenter', 'createTemplate', new ObjectType('Nette\\Application\\UI\\ITemplate')), new AddReturnTypeDeclaration('Nette\\Application\\MicroPresenter', 'redirectUrl', new ObjectType('Nette\\Application\\Responses\\RedirectResponse')), new AddReturnTypeDeclaration('Nette\\Application\\MicroPresenter', 'error', new VoidType()), new AddReturnTypeDeclaration('Nette\\Application\\MicroPresenter', 'getRequest', new UnionType([new ObjectType('Nette\\Application\\Request'), new NullType()]))]); }; diff --git a/vendor/rector/rector-nette/config/sets/nette-31.php b/vendor/rector/rector-nette/config/sets/nette-31.php index 5d80c3e2d4c..321e777a310 100644 --- a/vendor/rector/rector-nette/config/sets/nette-31.php +++ b/vendor/rector/rector-nette/config/sets/nette-31.php @@ -25,16 +25,16 @@ use Rector\Transform\ValueObject\DimFetchAssignToMethodCall; use Rector\Transform\ValueObject\PropertyFetchToMethodCall; use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector; use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { // forms 3.1 - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\Assign\PropertyFetchToMethodCallRector::class, [new \Rector\Transform\ValueObject\PropertyFetchToMethodCall('Nette\\Application\\UI\\Form', 'values', 'getValues')]); + $rectorConfig->ruleWithConfiguration(PropertyFetchToMethodCallRector::class, [new PropertyFetchToMethodCall('Nette\\Application\\UI\\Form', 'values', 'getValues')]); // some attributes were added in nette 3.0, but only in one of latest patch versions; it's is safer to add them in 3.1 - $rectorConfig->sets([\Rector\Nette\Set\NetteSetList::ANNOTATIONS_TO_ATTRIBUTES]); - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\MethodCall\CallableInMethodCallToVariableRector::class, [ + $rectorConfig->sets([NetteSetList::ANNOTATIONS_TO_ATTRIBUTES]); + $rectorConfig->ruleWithConfiguration(CallableInMethodCallToVariableRector::class, [ // see https://github.com/nette/caching/commit/5ffe263752af5ccf3866a28305e7b2669ab4da82 - new \Rector\Transform\ValueObject\CallableInMethodCallToVariable('Nette\\Caching\\Cache', 'save', 1), + new CallableInMethodCallToVariable('Nette\\Caching\\Cache', 'save', 1), ]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, [ + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ 'Nette\\Bridges\\ApplicationLatte\\Template' => 'Nette\\Bridges\\ApplicationLatte\\DefaultTemplate', // https://github.com/nette/application/compare/v3.0.7...v3.1.0 'Nette\\Application\\IRouter' => 'Nette\\Routing\\Router', @@ -79,51 +79,51 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { 'Latte\\Runtime\\IHtmlString' => 'Latte\\Runtime\\HtmlStringable', 'Latte\\Runtime\\ISnippetBridge' => 'Latte\\Runtime\\SnippetBridge', ]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [ + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ // https://github.com/nette/caching/commit/60281abf366c4ab76e9436dc1bfe2e402db18b67 - new \Rector\Renaming\ValueObject\MethodCallRename('Nette\\Caching\\Cache', 'start', 'capture'), + new MethodCallRename('Nette\\Caching\\Cache', 'start', 'capture'), // https://github.com/nette/forms/commit/faaaf8b8fd3408a274a9de7ca3f342091010ad5d - new \Rector\Renaming\ValueObject\MethodCallRename('Nette\\Forms\\Container', 'addImage', 'addImageButton'), + new MethodCallRename('Nette\\Forms\\Container', 'addImage', 'addImageButton'), // https://github.com/nette/utils/commit/d0427c1811462dbb6c503143eabe5478b26685f7 - new \Rector\Renaming\ValueObject\MethodCallRename('Nette\\Utils\\Arrays', 'searchKey', 'getKeyOffset'), - new \Rector\Renaming\ValueObject\MethodCallRename('Nette\\Configurator', 'addParameters', 'addStaticParameters'), + new MethodCallRename('Nette\\Utils\\Arrays', 'searchKey', 'getKeyOffset'), + new MethodCallRename('Nette\\Configurator', 'addParameters', 'addStaticParameters'), ]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\StaticCall\RenameStaticMethodRector::class, [ + $rectorConfig->ruleWithConfiguration(RenameStaticMethodRector::class, [ // https://github.com/nette/utils/commit/8a4b795acd00f3f6754c28a73a7e776b60350c34 - new \Rector\Renaming\ValueObject\RenameStaticMethod('Nette\\Utils\\Callback', 'closure', 'Closure', 'fromCallable'), + new RenameStaticMethod('Nette\\Utils\\Callback', 'closure', 'Closure', 'fromCallable'), ]); - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\Assign\DimFetchAssignToMethodCallRector::class, [new \Rector\Transform\ValueObject\DimFetchAssignToMethodCall('Nette\\Application\\Routers\\RouteList', 'Nette\\Application\\Routers\\Route', 'addRoute')]); - $nullableTemplateType = new \PHPStan\Type\UnionType([new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Template'), new \PHPStan\Type\NullType()]); - $rectorConfig->ruleWithConfiguration(\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::class, [new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Nette\\Application\\UI\\Presenter', 'sendTemplate', 0, $nullableTemplateType)]); - $rectorConfig->rule(\Rector\Nette\Rector\MethodCall\ContextGetByTypeToConstructorInjectionRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Composer\Rector\ChangePackageVersionComposerRector::class, [ + $rectorConfig->ruleWithConfiguration(DimFetchAssignToMethodCallRector::class, [new DimFetchAssignToMethodCall('Nette\\Application\\Routers\\RouteList', 'Nette\\Application\\Routers\\Route', 'addRoute')]); + $nullableTemplateType = new UnionType([new ObjectType('Nette\\Application\\UI\\Template'), new NullType()]); + $rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [new AddParamTypeDeclaration('Nette\\Application\\UI\\Presenter', 'sendTemplate', 0, $nullableTemplateType)]); + $rectorConfig->rule(ContextGetByTypeToConstructorInjectionRector::class); + $rectorConfig->ruleWithConfiguration(ChangePackageVersionComposerRector::class, [ // meta package - new \Rector\Composer\ValueObject\PackageAndVersion('nette/nette', '^3.1'), + new PackageAndVersion('nette/nette', '^3.1'), // https://github.com/nette/nette/blob/v3.0.0/composer.json vs https://github.com/nette/nette/blob/v3.1.0/composer.json - new \Rector\Composer\ValueObject\PackageAndVersion('nette/application', '^3.1'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/bootstrap', '^3.1'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/caching', '^3.1'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/database', '^3.1'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/di', '^3.0'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/finder', '^2.5'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/forms', '^3.1'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/http', '^3.1'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/mail', '^3.1'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/php-generator', '^3.5'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/robot-loader', '^3.3'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/safe-stream', '^2.4'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/security', '^3.1'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/tokenizer', '^3.0'), - new \Rector\Composer\ValueObject\PackageAndVersion('nette/utils', '^3.2'), - new \Rector\Composer\ValueObject\PackageAndVersion('latte/latte', '^2.9'), - new \Rector\Composer\ValueObject\PackageAndVersion('tracy/tracy', '^2.8'), + new PackageAndVersion('nette/application', '^3.1'), + new PackageAndVersion('nette/bootstrap', '^3.1'), + new PackageAndVersion('nette/caching', '^3.1'), + new PackageAndVersion('nette/database', '^3.1'), + new PackageAndVersion('nette/di', '^3.0'), + new PackageAndVersion('nette/finder', '^2.5'), + new PackageAndVersion('nette/forms', '^3.1'), + new PackageAndVersion('nette/http', '^3.1'), + new PackageAndVersion('nette/mail', '^3.1'), + new PackageAndVersion('nette/php-generator', '^3.5'), + new PackageAndVersion('nette/robot-loader', '^3.3'), + new PackageAndVersion('nette/safe-stream', '^2.4'), + new PackageAndVersion('nette/security', '^3.1'), + new PackageAndVersion('nette/tokenizer', '^3.0'), + new PackageAndVersion('nette/utils', '^3.2'), + new PackageAndVersion('latte/latte', '^2.9'), + new PackageAndVersion('tracy/tracy', '^2.8'), // contributte - new \Rector\Composer\ValueObject\PackageAndVersion('contributte/console', '^0.9'), - new \Rector\Composer\ValueObject\PackageAndVersion('contributte/event-dispatcher', '^0.8'), - new \Rector\Composer\ValueObject\PackageAndVersion('contributte/event-dispatcher-extra', '^0.8'), + new PackageAndVersion('contributte/console', '^0.9'), + new PackageAndVersion('contributte/event-dispatcher', '^0.8'), + new PackageAndVersion('contributte/event-dispatcher-extra', '^0.8'), // nettrine - new \Rector\Composer\ValueObject\PackageAndVersion('nettrine/annotations', '^0.7'), - new \Rector\Composer\ValueObject\PackageAndVersion('nettrine/cache', '^0.3'), + new PackageAndVersion('nettrine/annotations', '^0.7'), + new PackageAndVersion('nettrine/cache', '^0.3'), ]); - $rectorConfig->ruleWithConfiguration(\Rector\Composer\Rector\RemovePackageComposerRector::class, ['nette/component-model', 'nette/neon']); + $rectorConfig->ruleWithConfiguration(RemovePackageComposerRector::class, ['nette/component-model', 'nette/neon']); }; diff --git a/vendor/rector/rector-nette/config/sets/nette-code-quality.php b/vendor/rector/rector-nette/config/sets/nette-code-quality.php index 0fd1c6c1682..7187cd89fc8 100644 --- a/vendor/rector/rector-nette/config/sets/nette-code-quality.php +++ b/vendor/rector/rector-nette/config/sets/nette-code-quality.php @@ -10,11 +10,11 @@ use Rector\Nette\Rector\Assign\ArrayAccessSetControlToAddComponentMethodCallRect use Rector\Nette\Rector\Assign\MakeGetComponentAssignAnnotatedRector; use Rector\Nette\Rector\ClassMethod\TemplateMagicAssignToExplicitVariableArrayRector; use Rector\Nette\Rector\Identical\SubstrMinusToStringEndsWithRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Nette\Rector\ClassMethod\TemplateMagicAssignToExplicitVariableArrayRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\Assign\MakeGetComponentAssignAnnotatedRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\ArrayDimFetch\AnnotateMagicalControlArrayAccessRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\Assign\ArrayAccessSetControlToAddComponentMethodCallRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\Assign\ArrayAccessGetControlToGetComponentMethodCallRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\Identical\SubstrMinusToStringEndsWithRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(TemplateMagicAssignToExplicitVariableArrayRector::class); + $rectorConfig->rule(MakeGetComponentAssignAnnotatedRector::class); + $rectorConfig->rule(AnnotateMagicalControlArrayAccessRector::class); + $rectorConfig->rule(ArrayAccessSetControlToAddComponentMethodCallRector::class); + $rectorConfig->rule(ArrayAccessGetControlToGetComponentMethodCallRector::class); + $rectorConfig->rule(SubstrMinusToStringEndsWithRector::class); }; diff --git a/vendor/rector/rector-nette/config/sets/nette-remove-inject.php b/vendor/rector/rector-nette/config/sets/nette-remove-inject.php index fa1a78b1a37..45ce697b05a 100644 --- a/vendor/rector/rector-nette/config/sets/nette-remove-inject.php +++ b/vendor/rector/rector-nette/config/sets/nette-remove-inject.php @@ -5,6 +5,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Nette\Rector\Property\NetteInjectToConstructorInjectionRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Nette\Rector\Property\NetteInjectToConstructorInjectionRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(NetteInjectToConstructorInjectionRector::class); }; diff --git a/vendor/rector/rector-nette/config/sets/nette-strict.php b/vendor/rector/rector-nette/config/sets/nette-strict.php index 8067ea717ba..59614b6d7df 100644 --- a/vendor/rector/rector-nette/config/sets/nette-strict.php +++ b/vendor/rector/rector-nette/config/sets/nette-strict.php @@ -5,6 +5,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Nette\Rector\ClassMethod\RenderMethodParamToTypeDeclarationRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Nette\Rector\ClassMethod\RenderMethodParamToTypeDeclarationRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(RenderMethodParamToTypeDeclarationRector::class); }; diff --git a/vendor/rector/rector-nette/config/sets/nette-utils-code-quality.php b/vendor/rector/rector-nette/config/sets/nette-utils-code-quality.php index 1e5f1741a2d..9c54753af95 100644 --- a/vendor/rector/rector-nette/config/sets/nette-utils-code-quality.php +++ b/vendor/rector/rector-nette/config/sets/nette-utils-code-quality.php @@ -16,15 +16,15 @@ use Rector\Nette\Rector\NotIdentical\StrposToStringsContainsRector; use Rector\Transform\Rector\FuncCall\FuncCallToStaticCallRector; use Rector\Transform\ValueObject\FuncCallToStaticCall; # @see https://tomasvotruba.com/blog/2018/07/30/hidden-gems-of-php-packages-nette-utils -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\FuncCall\FuncCallToStaticCallRector::class, [new \Rector\Transform\ValueObject\FuncCallToStaticCall('file_get_contents', 'Nette\\Utils\\FileSystem', 'read'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('unlink', 'Nette\\Utils\\FileSystem', 'delete'), new \Rector\Transform\ValueObject\FuncCallToStaticCall('rmdir', 'Nette\\Utils\\FileSystem', 'delete')]); - $rectorConfig->rule(\Rector\Nette\Rector\NotIdentical\StrposToStringsContainsRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\FuncCall\SubstrStrlenFunctionToNetteUtilsStringsRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\Identical\StartsWithFunctionToNetteUtilsStringsRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\FuncCall\PregMatchFunctionToNetteUtilsStringsRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\FuncCall\PregFunctionToNetteUtilsStringsRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\Identical\EndsWithFunctionToNetteUtilsStringsRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\FuncCall\JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\FuncCall\FilePutContentsToFileSystemWriteRector::class); - $rectorConfig->rule(\Rector\Nette\Rector\LNumber\ReplaceTimeNumberWithDateTimeConstantRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(FuncCallToStaticCallRector::class, [new FuncCallToStaticCall('file_get_contents', 'Nette\\Utils\\FileSystem', 'read'), new FuncCallToStaticCall('unlink', 'Nette\\Utils\\FileSystem', 'delete'), new FuncCallToStaticCall('rmdir', 'Nette\\Utils\\FileSystem', 'delete')]); + $rectorConfig->rule(StrposToStringsContainsRector::class); + $rectorConfig->rule(SubstrStrlenFunctionToNetteUtilsStringsRector::class); + $rectorConfig->rule(StartsWithFunctionToNetteUtilsStringsRector::class); + $rectorConfig->rule(PregMatchFunctionToNetteUtilsStringsRector::class); + $rectorConfig->rule(PregFunctionToNetteUtilsStringsRector::class); + $rectorConfig->rule(EndsWithFunctionToNetteUtilsStringsRector::class); + $rectorConfig->rule(JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRector::class); + $rectorConfig->rule(FilePutContentsToFileSystemWriteRector::class); + $rectorConfig->rule(ReplaceTimeNumberWithDateTimeConstantRector::class); }; diff --git a/vendor/rector/rector-nette/config/sets/nette/annotations-to-attributes.php b/vendor/rector/rector-nette/config/sets/nette/annotations-to-attributes.php index 1d6e8bd3708..6ea2bbf9e3e 100644 --- a/vendor/rector/rector-nette/config/sets/nette/annotations-to-attributes.php +++ b/vendor/rector/rector-nette/config/sets/nette/annotations-to-attributes.php @@ -6,11 +6,11 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; use Rector\Php80\ValueObject\AnnotationToAttribute; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [ // nette 3.0+, see https://github.com/nette/application/commit/d2471134ed909210de8a3e8559931902b1bee67b#diff-457507a8bdc046dd4f3a4aa1ca51794543fbb1e06f03825ab69ee864549a570c - new \Rector\Php80\ValueObject\AnnotationToAttribute('inject', 'Nette\\DI\\Attributes\\Inject'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('persistent', 'Nette\\Application\\Attributes\\Persistent'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('crossOrigin', 'Nette\\Application\\Attributes\\CrossOrigin'), + new AnnotationToAttribute('inject', 'Nette\\DI\\Attributes\\Inject'), + new AnnotationToAttribute('persistent', 'Nette\\Application\\Attributes\\Persistent'), + new AnnotationToAttribute('crossOrigin', 'Nette\\Application\\Attributes\\CrossOrigin'), ]); }; diff --git a/vendor/rector/rector-nette/monorepo-builder.php b/vendor/rector/rector-nette/monorepo-builder.php index add4c2a823d..e88fd1336d6 100644 --- a/vendor/rector/rector-nette/monorepo-builder.php +++ b/vendor/rector/rector-nette/monorepo-builder.php @@ -3,13 +3,13 @@ declare (strict_types=1); namespace RectorPrefix20220607; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\PushTagReleaseWorker; use RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\TagVersionReleaseWorker; -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +return static function (ContainerConfigurator $containerConfigurator) : void { $services = $containerConfigurator->services(); $services->defaults()->autowire(); // @see https://github.com/symplify/monorepo-builder#6-release-flow - $services->set(\RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\TagVersionReleaseWorker::class); - $services->set(\RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\PushTagReleaseWorker::class); + $services->set(TagVersionReleaseWorker::class); + $services->set(PushTagReleaseWorker::class); }; diff --git a/vendor/rector/rector-nette/packages/NeonParser/Contract/NeonNodeVisitorInterface.php b/vendor/rector/rector-nette/packages/NeonParser/Contract/NeonNodeVisitorInterface.php index a2ade5c1c0d..c03b952457b 100644 --- a/vendor/rector/rector-nette/packages/NeonParser/Contract/NeonNodeVisitorInterface.php +++ b/vendor/rector/rector-nette/packages/NeonParser/Contract/NeonNodeVisitorInterface.php @@ -9,5 +9,5 @@ interface NeonNodeVisitorInterface * @return class-string<\PhpParser\Node> */ public function getNodeType() : string; - public function enterNode(\RectorPrefix20220607\Nette\Neon\Node $node) : \RectorPrefix20220607\Nette\Neon\Node; + public function enterNode(Node $node) : Node; } diff --git a/vendor/rector/rector-nette/packages/NeonParser/Exception/NotImplementedYetException.php b/vendor/rector/rector-nette/packages/NeonParser/Exception/NotImplementedYetException.php index 729da2e28a9..21943a3f526 100644 --- a/vendor/rector/rector-nette/packages/NeonParser/Exception/NotImplementedYetException.php +++ b/vendor/rector/rector-nette/packages/NeonParser/Exception/NotImplementedYetException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace Rector\Nette\NeonParser\Exception; use Exception; -final class NotImplementedYetException extends \Exception +final class NotImplementedYetException extends Exception { } diff --git a/vendor/rector/rector-nette/packages/NeonParser/Exception/UnusedVirtualMethodException.php b/vendor/rector/rector-nette/packages/NeonParser/Exception/UnusedVirtualMethodException.php index 1d8541a0e1d..0ed2502b099 100644 --- a/vendor/rector/rector-nette/packages/NeonParser/Exception/UnusedVirtualMethodException.php +++ b/vendor/rector/rector-nette/packages/NeonParser/Exception/UnusedVirtualMethodException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace Rector\Nette\NeonParser\Exception; use Exception; -final class UnusedVirtualMethodException extends \Exception +final class UnusedVirtualMethodException extends Exception { } diff --git a/vendor/rector/rector-nette/packages/NeonParser/NeonNodeTraverser.php b/vendor/rector/rector-nette/packages/NeonParser/NeonNodeTraverser.php index 4206432c2cb..1dba0a954ee 100644 --- a/vendor/rector/rector-nette/packages/NeonParser/NeonNodeTraverser.php +++ b/vendor/rector/rector-nette/packages/NeonParser/NeonNodeTraverser.php @@ -26,16 +26,16 @@ final class NeonNodeTraverser * @var \Rector\Nette\NeonParser\NodeFactory\ServiceFactory */ private $serviceFactory; - public function __construct(\Rector\Nette\NeonParser\Services\ServiceTypeResolver $serviceTypeResolver, \Rector\Nette\NeonParser\NodeFactory\ServiceFactory $serviceFactory) + public function __construct(ServiceTypeResolver $serviceTypeResolver, ServiceFactory $serviceFactory) { $this->serviceTypeResolver = $serviceTypeResolver; $this->serviceFactory = $serviceFactory; } - public function addNeonNodeVisitor(\Rector\Nette\Contract\Rector\NeonRectorInterface $neonRector) : void + public function addNeonNodeVisitor(NeonRectorInterface $neonRector) : void { $this->neonRectors[] = $neonRector; } - public function traverse(\RectorPrefix20220607\Nette\Neon\Node $node) : \RectorPrefix20220607\Nette\Neon\Node + public function traverse(Node $node) : Node { foreach ($this->neonRectors as $neonRector) { // is service node? @@ -44,7 +44,7 @@ final class NeonNodeTraverser // create virtual node if (\is_string($serviceType)) { $service = $this->serviceFactory->create($node); - if ($service instanceof \Rector\Nette\NeonParser\Node\Service_) { + if ($service instanceof Service_) { // enter meta node $node = $service; } diff --git a/vendor/rector/rector-nette/packages/NeonParser/NeonNodeTraverserFactory.php b/vendor/rector/rector-nette/packages/NeonParser/NeonNodeTraverserFactory.php index 59a435a847d..4e0d3d34cfe 100644 --- a/vendor/rector/rector-nette/packages/NeonParser/NeonNodeTraverserFactory.php +++ b/vendor/rector/rector-nette/packages/NeonParser/NeonNodeTraverserFactory.php @@ -15,7 +15,7 @@ final class NeonNodeTraverserFactory * @var \Rector\Nette\NeonParser\NodeFactory\ServiceFactory */ private $serviceFactory; - public function __construct(\Rector\Nette\NeonParser\Services\ServiceTypeResolver $serviceTypeResolver, \Rector\Nette\NeonParser\NodeFactory\ServiceFactory $serviceFactory) + public function __construct(ServiceTypeResolver $serviceTypeResolver, ServiceFactory $serviceFactory) { $this->serviceTypeResolver = $serviceTypeResolver; $this->serviceFactory = $serviceFactory; diff --git a/vendor/rector/rector-nette/packages/NeonParser/NeonNodeVisitor/AbstractServiceNeonNodeVisitor.php b/vendor/rector/rector-nette/packages/NeonParser/NeonNodeVisitor/AbstractServiceNeonNodeVisitor.php index d3cf7ba620c..7fc00d4002d 100644 --- a/vendor/rector/rector-nette/packages/NeonParser/NeonNodeVisitor/AbstractServiceNeonNodeVisitor.php +++ b/vendor/rector/rector-nette/packages/NeonParser/NeonNodeVisitor/AbstractServiceNeonNodeVisitor.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace Rector\Nette\NeonParser\NeonNodeVisitor; use Rector\Nette\NeonParser\Contract\NeonNodeVisitorInterface; -abstract class AbstractServiceNeonNodeVisitor implements \Rector\Nette\NeonParser\Contract\NeonNodeVisitorInterface +abstract class AbstractServiceNeonNodeVisitor implements NeonNodeVisitorInterface { } diff --git a/vendor/rector/rector-nette/packages/NeonParser/NeonParser.php b/vendor/rector/rector-nette/packages/NeonParser/NeonParser.php index c8c45559173..c0d3ba091cb 100644 --- a/vendor/rector/rector-nette/packages/NeonParser/NeonParser.php +++ b/vendor/rector/rector-nette/packages/NeonParser/NeonParser.php @@ -11,11 +11,11 @@ final class NeonParser * @var \Nette\Neon\Decoder */ private $decoder; - public function __construct(\RectorPrefix20220607\Nette\Neon\Decoder $decoder) + public function __construct(Decoder $decoder) { $this->decoder = $decoder; } - public function parseString(string $neonContent) : \RectorPrefix20220607\Nette\Neon\Node + public function parseString(string $neonContent) : Node { return $this->decoder->parseToNode($neonContent); } diff --git a/vendor/rector/rector-nette/packages/NeonParser/Node/AbstractVirtualNode.php b/vendor/rector/rector-nette/packages/NeonParser/Node/AbstractVirtualNode.php index 39c82776416..3517066ba6a 100644 --- a/vendor/rector/rector-nette/packages/NeonParser/Node/AbstractVirtualNode.php +++ b/vendor/rector/rector-nette/packages/NeonParser/Node/AbstractVirtualNode.php @@ -5,7 +5,7 @@ namespace Rector\Nette\NeonParser\Node; use RectorPrefix20220607\Nette\Neon\Node; use Rector\Nette\NeonParser\Exception\UnusedVirtualMethodException; -abstract class AbstractVirtualNode extends \RectorPrefix20220607\Nette\Neon\Node +abstract class AbstractVirtualNode extends Node { /** * @return mixed @@ -13,11 +13,11 @@ abstract class AbstractVirtualNode extends \RectorPrefix20220607\Nette\Neon\Node public function toValue() { // never used, just to make parent contract happy - throw new \Rector\Nette\NeonParser\Exception\UnusedVirtualMethodException(); + throw new UnusedVirtualMethodException(); } public function toString() : string { // never used, just to make parent contract happy - throw new \Rector\Nette\NeonParser\Exception\UnusedVirtualMethodException(); + throw new UnusedVirtualMethodException(); } } diff --git a/vendor/rector/rector-nette/packages/NeonParser/Node/Service_.php b/vendor/rector/rector-nette/packages/NeonParser/Node/Service_.php index f1f94b1143a..672d54ea528 100644 --- a/vendor/rector/rector-nette/packages/NeonParser/Node/Service_.php +++ b/vendor/rector/rector-nette/packages/NeonParser/Node/Service_.php @@ -62,10 +62,10 @@ final class Service_ extends \Rector\Nette\NeonParser\Node\AbstractVirtualNode */ public function &getIterator() : \Generator { - if ($this->classLiteralNode instanceof \RectorPrefix20220607\Nette\Neon\Node\LiteralNode) { + if ($this->classLiteralNode instanceof LiteralNode) { (yield $this->classLiteralNode); } - if ($this->factoryLiteralNode instanceof \RectorPrefix20220607\Nette\Neon\Node\LiteralNode) { + if ($this->factoryLiteralNode instanceof LiteralNode) { (yield $this->factoryLiteralNode); } foreach ($this->setupMethodCalls as $setupMethodCall) { diff --git a/vendor/rector/rector-nette/packages/NeonParser/Node/Service_/SetupMethodCall.php b/vendor/rector/rector-nette/packages/NeonParser/Node/Service_/SetupMethodCall.php index 5a45f60a245..315f9208b77 100644 --- a/vendor/rector/rector-nette/packages/NeonParser/Node/Service_/SetupMethodCall.php +++ b/vendor/rector/rector-nette/packages/NeonParser/Node/Service_/SetupMethodCall.php @@ -6,7 +6,7 @@ namespace Rector\Nette\NeonParser\Node\Service_; use RectorPrefix20220607\Nette\Neon\Node\EntityNode; use RectorPrefix20220607\Nette\Neon\Node\LiteralNode; use Rector\Nette\NeonParser\Node\AbstractVirtualNode; -final class SetupMethodCall extends \Rector\Nette\NeonParser\Node\AbstractVirtualNode +final class SetupMethodCall extends AbstractVirtualNode { /** * @var string @@ -20,7 +20,7 @@ final class SetupMethodCall extends \Rector\Nette\NeonParser\Node\AbstractVirtua * @var \Nette\Neon\Node\EntityNode */ public $entityNode; - public function __construct(string $className, \RectorPrefix20220607\Nette\Neon\Node\LiteralNode $methodNameLiteralNode, \RectorPrefix20220607\Nette\Neon\Node\EntityNode $entityNode) + public function __construct(string $className, LiteralNode $methodNameLiteralNode, EntityNode $entityNode) { $this->className = $className; $this->methodNameLiteralNode = $methodNameLiteralNode; diff --git a/vendor/rector/rector-nette/packages/NeonParser/NodeFactory/ServiceFactory.php b/vendor/rector/rector-nette/packages/NeonParser/NodeFactory/ServiceFactory.php index f953890f16c..6ecaeb31546 100644 --- a/vendor/rector/rector-nette/packages/NeonParser/NodeFactory/ServiceFactory.php +++ b/vendor/rector/rector-nette/packages/NeonParser/NodeFactory/ServiceFactory.php @@ -27,9 +27,9 @@ final class ServiceFactory /** * @return \Rector\Nette\NeonParser\Node\Service_|null */ - public function create(\RectorPrefix20220607\Nette\Neon\Node $node) + public function create(Node $node) { - if (!$node instanceof \RectorPrefix20220607\Nette\Neon\Node\ArrayItemNode) { + if (!$node instanceof ArrayItemNode) { return null; } $class = $this->resolveArrayItemByKeyword($node, self::CLASS_KEYWORD); @@ -40,28 +40,28 @@ final class ServiceFactory return null; } $setupMethodCalls = $this->resolveSetupMethodCalls($className, $node); - return new \Rector\Nette\NeonParser\Node\Service_($className, $class, $factory, $setupMethodCalls); + return new Service_($className, $class, $factory, $setupMethodCalls); } /** * @return \Nette\Neon\Node\LiteralNode|null */ - private function resolveArrayItemByKeyword(\RectorPrefix20220607\Nette\Neon\Node\ArrayItemNode $arrayItemNode, string $keyword) + private function resolveArrayItemByKeyword(ArrayItemNode $arrayItemNode, string $keyword) { - if (!$arrayItemNode->value instanceof \RectorPrefix20220607\Nette\Neon\Node\ArrayNode) { + if (!$arrayItemNode->value instanceof ArrayNode) { return null; } $arrayNode = $arrayItemNode->value; foreach ($arrayNode->items as $arrayItemNode) { - if (!$arrayItemNode->key instanceof \RectorPrefix20220607\Nette\Neon\Node\LiteralNode) { + if (!$arrayItemNode->key instanceof LiteralNode) { continue; } if ($arrayItemNode->key->toString() !== $keyword) { continue; } - if ($arrayItemNode->value instanceof \RectorPrefix20220607\Nette\Neon\Node\EntityNode) { + if ($arrayItemNode->value instanceof EntityNode) { return $arrayItemNode->value->value; } - if ($arrayItemNode->value instanceof \RectorPrefix20220607\Nette\Neon\Node\LiteralNode) { + if ($arrayItemNode->value instanceof LiteralNode) { return $arrayItemNode->value; } } @@ -70,31 +70,31 @@ final class ServiceFactory /** * @return SetupMethodCall[] */ - private function resolveSetupMethodCalls(string $className, \RectorPrefix20220607\Nette\Neon\Node\ArrayItemNode $arrayItemNode) : array + private function resolveSetupMethodCalls(string $className, ArrayItemNode $arrayItemNode) : array { - if (!$arrayItemNode->value instanceof \RectorPrefix20220607\Nette\Neon\Node\ArrayNode) { + if (!$arrayItemNode->value instanceof ArrayNode) { return []; } $setupMethodCalls = []; $arrayNode = $arrayItemNode->value; foreach ($arrayNode->items as $arrayItemNode) { - if ($arrayItemNode->key instanceof \RectorPrefix20220607\Nette\Neon\Node\LiteralNode) { + if ($arrayItemNode->key instanceof LiteralNode) { if ($arrayItemNode->key->toString() !== self::SETUP_KEYWORD) { continue; } - if (!$arrayItemNode->value instanceof \RectorPrefix20220607\Nette\Neon\Node\ArrayNode) { + if (!$arrayItemNode->value instanceof ArrayNode) { continue; } foreach ($arrayItemNode->value->items as $setupArrayItemNode) { - if ($setupArrayItemNode->value instanceof \RectorPrefix20220607\Nette\Neon\Node\EntityNode) { + if ($setupArrayItemNode->value instanceof EntityNode) { // probably method call $entityNode = $setupArrayItemNode->value; - if ($entityNode->value instanceof \RectorPrefix20220607\Nette\Neon\Node\LiteralNode) { + if ($entityNode->value instanceof LiteralNode) { // not a method call - probably property assign if (\strncmp($entityNode->value->toString(), '$', \strlen('$')) === 0) { continue; } - $setupMethodCalls[] = new \Rector\Nette\NeonParser\Node\Service_\SetupMethodCall($className, $entityNode->value, $entityNode); + $setupMethodCalls[] = new SetupMethodCall($className, $entityNode->value, $entityNode); } } } diff --git a/vendor/rector/rector-nette/packages/NeonParser/Printer/FormatPreservingNeonPrinter.php b/vendor/rector/rector-nette/packages/NeonParser/Printer/FormatPreservingNeonPrinter.php index e3eb615097d..5092fa95a4b 100644 --- a/vendor/rector/rector-nette/packages/NeonParser/Printer/FormatPreservingNeonPrinter.php +++ b/vendor/rector/rector-nette/packages/NeonParser/Printer/FormatPreservingNeonPrinter.php @@ -15,20 +15,20 @@ final class FormatPreservingNeonPrinter * @var string */ private const INDENT_SPACES = 'spaces'; - public function printNode(\RectorPrefix20220607\Nette\Neon\Node $node, string $originalContenet) : string + public function printNode(Node $node, string $originalContenet) : string { $neonContent = $node->toString(); $indentType = $this->resolveIndentType($originalContenet); $neonContent = $this->formatIndent($neonContent, $indentType); // replace quotes - @todo resolve defaults - return \RectorPrefix20220607\Nette\Utils\Strings::replace($neonContent, '#\\"#', '\''); + return Strings::replace($neonContent, '#\\"#', '\''); } /** * Some files prefer tabs, some spaces. This will resolve first found space. */ private function resolveIndentType(string $neonContent) : string { - $indentMatch = \RectorPrefix20220607\Nette\Utils\Strings::match($neonContent, '#(\\t| )#ms'); + $indentMatch = Strings::match($neonContent, '#(\\t| )#ms'); if ($indentMatch[0] === "\t") { return self::INDENT_TABS; } @@ -37,7 +37,7 @@ final class FormatPreservingNeonPrinter private function formatIndent(string $neonContent, string $indentType) : string { if ($indentType === self::INDENT_SPACES) { - return \RectorPrefix20220607\Nette\Utils\Strings::replace($neonContent, '#\\t#', ' '); + return Strings::replace($neonContent, '#\\t#', ' '); } return $neonContent; } diff --git a/vendor/rector/rector-nette/packages/NeonParser/Services/ServiceTypeResolver.php b/vendor/rector/rector-nette/packages/NeonParser/Services/ServiceTypeResolver.php index 4599f59e8e4..c4eb010caa4 100644 --- a/vendor/rector/rector-nette/packages/NeonParser/Services/ServiceTypeResolver.php +++ b/vendor/rector/rector-nette/packages/NeonParser/Services/ServiceTypeResolver.php @@ -20,12 +20,12 @@ final class ServiceTypeResolver /** * @return string|null */ - public function resolve(\RectorPrefix20220607\Nette\Neon\Node $serviceNode) + public function resolve(Node $serviceNode) { - if (!$serviceNode instanceof \RectorPrefix20220607\Nette\Neon\Node\ArrayItemNode) { + if (!$serviceNode instanceof ArrayItemNode) { return null; } - if (!$serviceNode->value instanceof \RectorPrefix20220607\Nette\Neon\Node\ArrayNode) { + if (!$serviceNode->value instanceof ArrayNode) { return null; } foreach ($serviceNode->value->items as $serviceConfigurationItem) { @@ -33,13 +33,13 @@ final class ServiceTypeResolver continue; } if ($serviceConfigurationItem->key->toString() === self::FACTORY_KEYWORD) { - if ($serviceConfigurationItem->value instanceof \RectorPrefix20220607\Nette\Neon\Node\EntityNode) { + if ($serviceConfigurationItem->value instanceof EntityNode) { return $serviceConfigurationItem->value->value->toString(); } return $serviceConfigurationItem->value->toString(); } if ($serviceConfigurationItem->key->toString() === self::CLASS_KEYWORD) { - if ($serviceConfigurationItem->value instanceof \RectorPrefix20220607\Nette\Neon\Node\EntityNode) { + if ($serviceConfigurationItem->value instanceof EntityNode) { return $serviceConfigurationItem->value->value->toString(); } return $serviceConfigurationItem->value->toString(); diff --git a/vendor/rector/rector-nette/rector.php b/vendor/rector/rector-nette/rector.php index 682195d37dc..25ff3c0f199 100644 --- a/vendor/rector/rector-nette/rector.php +++ b/vendor/rector/rector-nette/rector.php @@ -7,7 +7,7 @@ use Rector\Config\RectorConfig; use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $rectorConfig->importNames(); $rectorConfig->parallel(); $rectorConfig->paths([__DIR__ . '/src', __DIR__ . '/tests']); @@ -16,7 +16,7 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { '*/Source/*', '*/Fixture/*', ]); - $rectorConfig->ruleWithConfiguration(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class, ['Nette\\*', 'Symfony\\Component\\Translation\\TranslatorInterface', 'Symfony\\Contracts\\EventDispatcher\\Event', 'Kdyby\\Events\\Subscriber']); + $rectorConfig->ruleWithConfiguration(StringClassNameToClassConstantRector::class, ['Nette\\*', 'Symfony\\Component\\Translation\\TranslatorInterface', 'Symfony\\Contracts\\EventDispatcher\\Event', 'Kdyby\\Events\\Subscriber']); // needed for DEAD_CODE list, just in split package like this - $rectorConfig->sets([__DIR__ . '/config/config.php', \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_81, \Rector\Set\ValueObject\SetList::DEAD_CODE, \Rector\Set\ValueObject\SetList::CODE_QUALITY]); + $rectorConfig->sets([__DIR__ . '/config/config.php', LevelSetList::UP_TO_PHP_81, SetList::DEAD_CODE, SetList::CODE_QUALITY]); }; diff --git a/vendor/rector/rector-nette/src/Contract/FormControlTypeResolverInterface.php b/vendor/rector/rector-nette/src/Contract/FormControlTypeResolverInterface.php index d62970129f2..4925be4e5a9 100644 --- a/vendor/rector/rector-nette/src/Contract/FormControlTypeResolverInterface.php +++ b/vendor/rector/rector-nette/src/Contract/FormControlTypeResolverInterface.php @@ -9,5 +9,5 @@ interface FormControlTypeResolverInterface /** * @return array */ - public function resolve(\PhpParser\Node $node) : array; + public function resolve(Node $node) : array; } diff --git a/vendor/rector/rector-nette/src/Contract/Rector/LatteRectorInterface.php b/vendor/rector/rector-nette/src/Contract/Rector/LatteRectorInterface.php index 0e4280264ac..4965dad1998 100644 --- a/vendor/rector/rector-nette/src/Contract/Rector/LatteRectorInterface.php +++ b/vendor/rector/rector-nette/src/Contract/Rector/LatteRectorInterface.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Nette\Contract\Rector; use Rector\Core\Contract\Rector\RectorInterface; -interface LatteRectorInterface extends \Rector\Core\Contract\Rector\RectorInterface +interface LatteRectorInterface extends RectorInterface { public function changeContent(string $content) : string; } diff --git a/vendor/rector/rector-nette/src/Contract/Rector/NeonRectorInterface.php b/vendor/rector/rector-nette/src/Contract/Rector/NeonRectorInterface.php index af7f8ee957c..5f3ee026606 100644 --- a/vendor/rector/rector-nette/src/Contract/Rector/NeonRectorInterface.php +++ b/vendor/rector/rector-nette/src/Contract/Rector/NeonRectorInterface.php @@ -8,7 +8,7 @@ use Rector\Core\Contract\Rector\RectorInterface; /** * @template TNode as Node */ -interface NeonRectorInterface extends \Rector\Core\Contract\Rector\RectorInterface +interface NeonRectorInterface extends RectorInterface { /** * @return class-string @@ -18,5 +18,5 @@ interface NeonRectorInterface extends \Rector\Core\Contract\Rector\RectorInterfa * @param TNode $node * @return \Nette\Neon\Node|null */ - public function enterNode(\RectorPrefix20220607\Nette\Neon\Node $node); + public function enterNode(Node $node); } diff --git a/vendor/rector/rector-nette/src/FileProcessor/LatteFileProcessor.php b/vendor/rector/rector-nette/src/FileProcessor/LatteFileProcessor.php index ccf652ea6cb..2a1aafabcfa 100644 --- a/vendor/rector/rector-nette/src/FileProcessor/LatteFileProcessor.php +++ b/vendor/rector/rector-nette/src/FileProcessor/LatteFileProcessor.php @@ -11,7 +11,7 @@ use Rector\Core\ValueObject\Error\SystemError; use Rector\Core\ValueObject\Reporting\FileDiff; use Rector\Nette\Contract\Rector\LatteRectorInterface; use Rector\Parallel\ValueObject\Bridge; -final class LatteFileProcessor implements \Rector\Core\Contract\Processor\FileProcessorInterface +final class LatteFileProcessor implements FileProcessorInterface { /** * @var LatteRectorInterface[] @@ -26,7 +26,7 @@ final class LatteFileProcessor implements \Rector\Core\Contract\Processor\FilePr /** * @param LatteRectorInterface[] $latteRectors */ - public function __construct(array $latteRectors, \Rector\ChangesReporting\ValueObjectFactory\FileDiffFactory $fileDiffFactory) + public function __construct(array $latteRectors, FileDiffFactory $fileDiffFactory) { $this->latteRectors = $latteRectors; $this->fileDiffFactory = $fileDiffFactory; @@ -34,9 +34,9 @@ final class LatteFileProcessor implements \Rector\Core\Contract\Processor\FilePr /** * @return array{system_errors: SystemError[], file_diffs: FileDiff[]} */ - public function process(\Rector\Core\ValueObject\Application\File $file, \Rector\Core\ValueObject\Configuration $configuration) : array + public function process(File $file, Configuration $configuration) : array { - $systemErrorsAndFileDiffs = [\Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS => [], \Rector\Parallel\ValueObject\Bridge::FILE_DIFFS => []]; + $systemErrorsAndFileDiffs = [Bridge::SYSTEM_ERRORS => [], Bridge::FILE_DIFFS => []]; $oldFileContent = $file->getFileContent(); $fileContent = $file->getFileContent(); foreach ($this->latteRectors as $latteRector) { @@ -47,10 +47,10 @@ final class LatteFileProcessor implements \Rector\Core\Contract\Processor\FilePr return $systemErrorsAndFileDiffs; } $fileDiff = $this->fileDiffFactory->createFileDiff($file, $oldFileContent, $fileContent); - $systemErrorsAndFileDiffs[\Rector\Parallel\ValueObject\Bridge::FILE_DIFFS][] = $fileDiff; + $systemErrorsAndFileDiffs[Bridge::FILE_DIFFS][] = $fileDiff; return $systemErrorsAndFileDiffs; } - public function supports(\Rector\Core\ValueObject\Application\File $file, \Rector\Core\ValueObject\Configuration $configuration) : bool + public function supports(File $file, Configuration $configuration) : bool { $fileInfo = $file->getSmartFileInfo(); return $fileInfo->hasSuffixes($this->getSupportedFileExtensions()); diff --git a/vendor/rector/rector-nette/src/FileProcessor/NeonFileProcessor.php b/vendor/rector/rector-nette/src/FileProcessor/NeonFileProcessor.php index 70fc2704e11..65fcaaf387d 100644 --- a/vendor/rector/rector-nette/src/FileProcessor/NeonFileProcessor.php +++ b/vendor/rector/rector-nette/src/FileProcessor/NeonFileProcessor.php @@ -14,7 +14,7 @@ use Rector\Nette\NeonParser\NeonNodeTraverserFactory; use Rector\Nette\NeonParser\NeonParser; use Rector\Nette\NeonParser\Printer\FormatPreservingNeonPrinter; use Rector\Parallel\ValueObject\Bridge; -final class NeonFileProcessor implements \Rector\Core\Contract\Processor\FileProcessorInterface +final class NeonFileProcessor implements FileProcessorInterface { /** * @readonly @@ -44,7 +44,7 @@ final class NeonFileProcessor implements \Rector\Core\Contract\Processor\FilePro /** * @param NeonRectorInterface[] $neonRectors */ - public function __construct(\Rector\Nette\NeonParser\NeonParser $neonParser, \Rector\Nette\NeonParser\NeonNodeTraverserFactory $neonNodeTraverserFactory, \Rector\Nette\NeonParser\Printer\FormatPreservingNeonPrinter $formatPreservingNeonPrinter, array $neonRectors, \Rector\ChangesReporting\ValueObjectFactory\FileDiffFactory $fileDiffFactory) + public function __construct(NeonParser $neonParser, NeonNodeTraverserFactory $neonNodeTraverserFactory, FormatPreservingNeonPrinter $formatPreservingNeonPrinter, array $neonRectors, FileDiffFactory $fileDiffFactory) { $this->neonParser = $neonParser; $this->neonNodeTraverserFactory = $neonNodeTraverserFactory; @@ -55,9 +55,9 @@ final class NeonFileProcessor implements \Rector\Core\Contract\Processor\FilePro /** * @return array{system_errors: SystemError[], file_diffs: FileDiff[]} */ - public function process(\Rector\Core\ValueObject\Application\File $file, \Rector\Core\ValueObject\Configuration $configuration) : array + public function process(File $file, Configuration $configuration) : array { - $systemErrorsAndFileDiffs = [\Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS => [], \Rector\Parallel\ValueObject\Bridge::FILE_DIFFS => []]; + $systemErrorsAndFileDiffs = [Bridge::SYSTEM_ERRORS => [], Bridge::FILE_DIFFS => []]; if ($this->neonRectors === []) { return $systemErrorsAndFileDiffs; } @@ -76,10 +76,10 @@ final class NeonFileProcessor implements \Rector\Core\Contract\Processor\FilePro } $file->changeFileContent($changedFileContent); $fileDiff = $this->fileDiffFactory->createFileDiff($file, $originalPrintedContent, $changedFileContent); - $systemErrorsAndFileDiffs[\Rector\Parallel\ValueObject\Bridge::FILE_DIFFS][] = $fileDiff; + $systemErrorsAndFileDiffs[Bridge::FILE_DIFFS][] = $fileDiff; return $systemErrorsAndFileDiffs; } - public function supports(\Rector\Core\ValueObject\Application\File $file, \Rector\Core\ValueObject\Configuration $configuration) : bool + public function supports(File $file, Configuration $configuration) : bool { $fileInfo = $file->getSmartFileInfo(); return $fileInfo->hasSuffixes($this->getSupportedFileExtensions()); diff --git a/vendor/rector/rector-nette/src/FormControlTypeResolver/ArrayDimFetchControlTypeResolver.php b/vendor/rector/rector-nette/src/FormControlTypeResolver/ArrayDimFetchControlTypeResolver.php index 1443d896535..54b4920f678 100644 --- a/vendor/rector/rector-nette/src/FormControlTypeResolver/ArrayDimFetchControlTypeResolver.php +++ b/vendor/rector/rector-nette/src/FormControlTypeResolver/ArrayDimFetchControlTypeResolver.php @@ -13,7 +13,7 @@ use Rector\Nette\Naming\NetteControlNaming; use Rector\Nette\NodeAnalyzer\ControlDimFetchAnalyzer; use Rector\NodeTypeResolver\NodeTypeResolver; use Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer; -final class ArrayDimFetchControlTypeResolver implements \Rector\Nette\Contract\FormControlTypeResolverInterface +final class ArrayDimFetchControlTypeResolver implements FormControlTypeResolverInterface { /** * @readonly @@ -40,7 +40,7 @@ final class ArrayDimFetchControlTypeResolver implements \Rector\Nette\Contract\F * @var \Rector\Core\PhpParser\AstResolver */ private $astResolver; - public function __construct(\Rector\Nette\NodeAnalyzer\ControlDimFetchAnalyzer $controlDimFetchAnalyzer, \Rector\Nette\Naming\NetteControlNaming $netteControlNaming, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer $returnTypeInferer, \Rector\Core\PhpParser\AstResolver $astResolver) + public function __construct(ControlDimFetchAnalyzer $controlDimFetchAnalyzer, NetteControlNaming $netteControlNaming, NodeTypeResolver $nodeTypeResolver, ReturnTypeInferer $returnTypeInferer, AstResolver $astResolver) { $this->controlDimFetchAnalyzer = $controlDimFetchAnalyzer; $this->netteControlNaming = $netteControlNaming; @@ -51,9 +51,9 @@ final class ArrayDimFetchControlTypeResolver implements \Rector\Nette\Contract\F /** * @return array */ - public function resolve(\PhpParser\Node $node) : array + public function resolve(Node $node) : array { - if (!$node instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$node instanceof ArrayDimFetch) { return []; } $controlShortName = $this->controlDimFetchAnalyzer->matchName($node); @@ -61,19 +61,19 @@ final class ArrayDimFetchControlTypeResolver implements \Rector\Nette\Contract\F return []; } $createComponentClassMethod = $this->matchCreateComponentClassMethod($node, $controlShortName); - if (!$createComponentClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$createComponentClassMethod instanceof ClassMethod) { return []; } $createComponentClassMethodReturnType = $this->returnTypeInferer->inferFunctionLike($createComponentClassMethod); - if (!$createComponentClassMethodReturnType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$createComponentClassMethodReturnType instanceof TypeWithClassName) { return []; } return [$controlShortName => $createComponentClassMethodReturnType->getClassName()]; } - private function matchCreateComponentClassMethod(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch, string $controlShortName) : ?\PhpParser\Node\Stmt\ClassMethod + private function matchCreateComponentClassMethod(ArrayDimFetch $arrayDimFetch, string $controlShortName) : ?ClassMethod { $callerType = $this->nodeTypeResolver->getType($arrayDimFetch->var); - if (!$callerType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$callerType instanceof TypeWithClassName) { return null; } $methodName = $this->netteControlNaming->createCreateComponentClassMethodName($controlShortName); diff --git a/vendor/rector/rector-nette/src/FormControlTypeResolver/AssignDimFetchFormTypeResolver.php b/vendor/rector/rector-nette/src/FormControlTypeResolver/AssignDimFetchFormTypeResolver.php index 05eccce62d2..c81c6f1a245 100644 --- a/vendor/rector/rector-nette/src/FormControlTypeResolver/AssignDimFetchFormTypeResolver.php +++ b/vendor/rector/rector-nette/src/FormControlTypeResolver/AssignDimFetchFormTypeResolver.php @@ -11,7 +11,7 @@ use PHPStan\Type\TypeWithClassName; use Rector\Core\PhpParser\Node\BetterNodeFinder; use Rector\Nette\Contract\FormControlTypeResolverInterface; use Rector\NodeTypeResolver\NodeTypeResolver; -final class AssignDimFetchFormTypeResolver implements \Rector\Nette\Contract\FormControlTypeResolverInterface +final class AssignDimFetchFormTypeResolver implements FormControlTypeResolverInterface { /** * @readonly @@ -23,7 +23,7 @@ final class AssignDimFetchFormTypeResolver implements \Rector\Nette\Contract\For * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeTypeResolver $nodeTypeResolver) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeTypeResolver = $nodeTypeResolver; @@ -31,22 +31,22 @@ final class AssignDimFetchFormTypeResolver implements \Rector\Nette\Contract\For /** * @return array */ - public function resolve(\PhpParser\Node $node) : array + public function resolve(Node $node) : array { - if (!$node instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$node instanceof ArrayDimFetch) { return []; } // traverse up and find all $this['some_name'] = $type /** @var Assign|null $formVariableAssign */ $formVariableAssign = $this->betterNodeFinder->findPreviousAssignToExpr($node); - if (!$formVariableAssign instanceof \PhpParser\Node\Expr\Assign) { + if (!$formVariableAssign instanceof Assign) { return []; } - if (!$node->dim instanceof \PhpParser\Node\Scalar\String_) { + if (!$node->dim instanceof String_) { return []; } $exprType = $this->nodeTypeResolver->getType($formVariableAssign->expr); - if (!$exprType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$exprType instanceof TypeWithClassName) { return []; } $name = $node->dim->value; diff --git a/vendor/rector/rector-nette/src/FormControlTypeResolver/AssignedVariablesMethodCallsFormTypeResolver.php b/vendor/rector/rector-nette/src/FormControlTypeResolver/AssignedVariablesMethodCallsFormTypeResolver.php index f1c8ccc6870..853750adc85 100644 --- a/vendor/rector/rector-nette/src/FormControlTypeResolver/AssignedVariablesMethodCallsFormTypeResolver.php +++ b/vendor/rector/rector-nette/src/FormControlTypeResolver/AssignedVariablesMethodCallsFormTypeResolver.php @@ -10,7 +10,7 @@ use Rector\Core\PhpParser\Node\BetterNodeFinder; use Rector\Nette\Contract\FormControlTypeResolverInterface; use Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver; use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; -final class AssignedVariablesMethodCallsFormTypeResolver implements \Rector\Nette\Contract\FormControlTypeResolverInterface +final class AssignedVariablesMethodCallsFormTypeResolver implements FormControlTypeResolverInterface { /** * @var \Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver @@ -21,27 +21,27 @@ final class AssignedVariablesMethodCallsFormTypeResolver implements \Rector\Nett * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(BetterNodeFinder $betterNodeFinder) { $this->betterNodeFinder = $betterNodeFinder; } /** * @required */ - public function autowire(\Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver $methodNamesByInputNamesResolver) : void + public function autowire(MethodNamesByInputNamesResolver $methodNamesByInputNamesResolver) : void { $this->methodNamesByInputNamesResolver = $methodNamesByInputNamesResolver; } /** * @return array */ - public function resolve(\PhpParser\Node $node) : array + public function resolve(Node $node) : array { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + if (!$node instanceof Variable) { return []; } $formVariableAssign = $this->betterNodeFinder->findPreviousAssignToExpr($node); - if (!$formVariableAssign instanceof \PhpParser\Node\Expr\Assign) { + if (!$formVariableAssign instanceof Assign) { return []; } return $this->methodNamesByInputNamesResolver->resolveExpr($formVariableAssign->expr); diff --git a/vendor/rector/rector-nette/src/FormControlTypeResolver/ClassMethodFormTypeResolver.php b/vendor/rector/rector-nette/src/FormControlTypeResolver/ClassMethodFormTypeResolver.php index e8751f78739..20e44e455a7 100644 --- a/vendor/rector/rector-nette/src/FormControlTypeResolver/ClassMethodFormTypeResolver.php +++ b/vendor/rector/rector-nette/src/FormControlTypeResolver/ClassMethodFormTypeResolver.php @@ -13,7 +13,7 @@ use Rector\Nette\Contract\FormControlTypeResolverInterface; use Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver; use Rector\NodeNameResolver\NodeNameResolver; use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; -final class ClassMethodFormTypeResolver implements \Rector\Nette\Contract\FormControlTypeResolverInterface +final class ClassMethodFormTypeResolver implements FormControlTypeResolverInterface { /** * @var \Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver @@ -29,7 +29,7 @@ final class ClassMethodFormTypeResolver implements \Rector\Nette\Contract\FormCo * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeNameResolver = $nodeNameResolver; @@ -37,26 +37,26 @@ final class ClassMethodFormTypeResolver implements \Rector\Nette\Contract\FormCo /** * @required */ - public function autowire(\Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver $methodNamesByInputNamesResolver) : void + public function autowire(MethodNamesByInputNamesResolver $methodNamesByInputNamesResolver) : void { $this->methodNamesByInputNamesResolver = $methodNamesByInputNamesResolver; } /** * @return array */ - public function resolve(\PhpParser\Node $node) : array + public function resolve(Node $node) : array { - if (!$node instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$node instanceof ClassMethod) { return []; } - if ($this->nodeNameResolver->isName($node, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if ($this->nodeNameResolver->isName($node, MethodName::CONSTRUCT)) { return []; } - $lastReturn = $this->betterNodeFinder->findLastInstanceOf((array) $node->stmts, \PhpParser\Node\Stmt\Return_::class); - if (!$lastReturn instanceof \PhpParser\Node\Stmt\Return_) { + $lastReturn = $this->betterNodeFinder->findLastInstanceOf((array) $node->stmts, Return_::class); + if (!$lastReturn instanceof Return_) { return []; } - if (!$lastReturn->expr instanceof \PhpParser\Node\Expr\Variable) { + if (!$lastReturn->expr instanceof Variable) { return []; } return $this->methodNamesByInputNamesResolver->resolveExpr($lastReturn->expr); diff --git a/vendor/rector/rector-nette/src/FormControlTypeResolver/ConstructorFormControlTypeResolver.php b/vendor/rector/rector-nette/src/FormControlTypeResolver/ConstructorFormControlTypeResolver.php index 9ba23fb4b44..44fd3fb8037 100644 --- a/vendor/rector/rector-nette/src/FormControlTypeResolver/ConstructorFormControlTypeResolver.php +++ b/vendor/rector/rector-nette/src/FormControlTypeResolver/ConstructorFormControlTypeResolver.php @@ -12,7 +12,7 @@ use Rector\Nette\Contract\FormControlTypeResolverInterface; use Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver; use Rector\NodeNameResolver\NodeNameResolver; use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; -final class ConstructorFormControlTypeResolver implements \Rector\Nette\Contract\FormControlTypeResolverInterface +final class ConstructorFormControlTypeResolver implements FormControlTypeResolverInterface { /** * @var \Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver @@ -28,7 +28,7 @@ final class ConstructorFormControlTypeResolver implements \Rector\Nette\Contract * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeNameResolver = $nodeNameResolver; @@ -36,23 +36,23 @@ final class ConstructorFormControlTypeResolver implements \Rector\Nette\Contract /** * @required */ - public function autowire(\Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver $methodNamesByInputNamesResolver) : void + public function autowire(MethodNamesByInputNamesResolver $methodNamesByInputNamesResolver) : void { $this->methodNamesByInputNamesResolver = $methodNamesByInputNamesResolver; } /** * @return array */ - public function resolve(\PhpParser\Node $node) : array + public function resolve(Node $node) : array { - if (!$node instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$node instanceof ClassMethod) { return []; } - if (!$this->nodeNameResolver->isName($node, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if (!$this->nodeNameResolver->isName($node, MethodName::CONSTRUCT)) { return []; } $thisVariable = $this->betterNodeFinder->findVariableOfName($node, 'this'); - if (!$thisVariable instanceof \PhpParser\Node\Expr\Variable) { + if (!$thisVariable instanceof Variable) { return []; } return $this->methodNamesByInputNamesResolver->resolveExpr($thisVariable); diff --git a/vendor/rector/rector-nette/src/FormControlTypeResolver/GetComponentMethodCallFormControlTypeResolver.php b/vendor/rector/rector-nette/src/FormControlTypeResolver/GetComponentMethodCallFormControlTypeResolver.php index 2f7e434cd0e..1e755a00c7e 100644 --- a/vendor/rector/rector-nette/src/FormControlTypeResolver/GetComponentMethodCallFormControlTypeResolver.php +++ b/vendor/rector/rector-nette/src/FormControlTypeResolver/GetComponentMethodCallFormControlTypeResolver.php @@ -16,7 +16,7 @@ use Rector\NodeNameResolver\NodeNameResolver; use Rector\NodeTypeResolver\NodeTypeResolver; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; -final class GetComponentMethodCallFormControlTypeResolver implements \Rector\Nette\Contract\FormControlTypeResolverInterface +final class GetComponentMethodCallFormControlTypeResolver implements FormControlTypeResolverInterface { /** * @var \Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver @@ -42,7 +42,7 @@ final class GetComponentMethodCallFormControlTypeResolver implements \Rector\Net * @var \Rector\Core\PhpParser\AstResolver */ private $astResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\Core\PhpParser\AstResolver $astResolver) + public function __construct(NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver, ValueResolver $valueResolver, AstResolver $astResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->nodeTypeResolver = $nodeTypeResolver; @@ -52,16 +52,16 @@ final class GetComponentMethodCallFormControlTypeResolver implements \Rector\Net /** * @required */ - public function autowire(\Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver $methodNamesByInputNamesResolver) : void + public function autowire(MethodNamesByInputNamesResolver $methodNamesByInputNamesResolver) : void { $this->methodNamesByInputNamesResolver = $methodNamesByInputNamesResolver; } /** * @return array */ - public function resolve(\PhpParser\Node $node) : array + public function resolve(Node $node) : array { - if (!$node instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$node instanceof MethodCall) { return []; } if (!$this->nodeNameResolver->isName($node->name, 'getComponent')) { @@ -69,17 +69,17 @@ final class GetComponentMethodCallFormControlTypeResolver implements \Rector\Net } $createComponentClassMethodName = $this->createCreateComponentMethodName($node); $staticType = $this->nodeTypeResolver->getType($node); - if (!$staticType instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType) { + if (!$staticType instanceof FullyQualifiedObjectType) { return []; } // combine constructor + method body name $constructorClassMethodData = []; - $constructorClassMethod = $this->astResolver->resolveClassMethod($staticType->getClassName(), \Rector\Core\ValueObject\MethodName::CONSTRUCT); + $constructorClassMethod = $this->astResolver->resolveClassMethod($staticType->getClassName(), MethodName::CONSTRUCT); if ($constructorClassMethod !== null) { $constructorClassMethodData = $this->methodNamesByInputNamesResolver->resolveExpr($constructorClassMethod); } $callerType = $this->nodeTypeResolver->getType($node->var); - if (!$callerType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$callerType instanceof TypeWithClassName) { return $constructorClassMethodData; } $createComponentClassMethodData = []; @@ -89,12 +89,12 @@ final class GetComponentMethodCallFormControlTypeResolver implements \Rector\Net } return \array_merge($constructorClassMethodData, $createComponentClassMethodData); } - private function createCreateComponentMethodName(\PhpParser\Node\Expr\MethodCall $methodCall) : string + private function createCreateComponentMethodName(MethodCall $methodCall) : string { $firstArgumentValue = $methodCall->args[0]->value; $componentName = $this->valueResolver->getValue($firstArgumentValue); if (!\is_string($componentName)) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } return 'createComponent' . \ucfirst($componentName); } diff --git a/vendor/rector/rector-nette/src/FormControlTypeResolver/MagicNetteFactoryInterfaceFormControlTypeResolver.php b/vendor/rector/rector-nette/src/FormControlTypeResolver/MagicNetteFactoryInterfaceFormControlTypeResolver.php index 387897a0a05..60a47db5b14 100644 --- a/vendor/rector/rector-nette/src/FormControlTypeResolver/MagicNetteFactoryInterfaceFormControlTypeResolver.php +++ b/vendor/rector/rector-nette/src/FormControlTypeResolver/MagicNetteFactoryInterfaceFormControlTypeResolver.php @@ -17,7 +17,7 @@ use Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver; use Rector\NodeNameResolver\NodeNameResolver; use Rector\NodeTypeResolver\NodeTypeResolver; use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; -final class MagicNetteFactoryInterfaceFormControlTypeResolver implements \Rector\Nette\Contract\FormControlTypeResolverInterface +final class MagicNetteFactoryInterfaceFormControlTypeResolver implements FormControlTypeResolverInterface { /** * @var \Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver @@ -43,7 +43,7 @@ final class MagicNetteFactoryInterfaceFormControlTypeResolver implements \Rector * @var \Rector\Core\PhpParser\AstResolver */ private $astResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\PhpParser\AstResolver $astResolver) + public function __construct(NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver, ReflectionProvider $reflectionProvider, AstResolver $astResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->nodeTypeResolver = $nodeTypeResolver; @@ -53,20 +53,20 @@ final class MagicNetteFactoryInterfaceFormControlTypeResolver implements \Rector /** * @required */ - public function autowire(\Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver $methodNamesByInputNamesResolver) : void + public function autowire(MethodNamesByInputNamesResolver $methodNamesByInputNamesResolver) : void { $this->methodNamesByInputNamesResolver = $methodNamesByInputNamesResolver; } /** * @return array */ - public function resolve(\PhpParser\Node $node) : array + public function resolve(Node $node) : array { - if (!$node instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$node instanceof MethodCall) { return []; } // skip constructor, handled elsewhere - if ($this->nodeNameResolver->isName($node->name, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if ($this->nodeNameResolver->isName($node->name, MethodName::CONSTRUCT)) { return []; } $methodName = $this->nodeNameResolver->getName($node->name); @@ -74,23 +74,23 @@ final class MagicNetteFactoryInterfaceFormControlTypeResolver implements \Rector return []; } $classReflection = $this->resolveClassReflectionByExpr($node->var); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return []; } $returnedType = $this->nodeTypeResolver->getType($node); - if (!$returnedType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$returnedType instanceof TypeWithClassName) { return []; } - $classMethod = $this->astResolver->resolveClassMethod($returnedType->getClassName(), \Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $this->astResolver->resolveClassMethod($returnedType->getClassName(), MethodName::CONSTRUCT); + if (!$classMethod instanceof ClassMethod) { return []; } return $this->methodNamesByInputNamesResolver->resolveExpr($classMethod); } - private function resolveClassReflectionByExpr(\PhpParser\Node\Expr $expr) : ?\PHPStan\Reflection\ClassReflection + private function resolveClassReflectionByExpr(Expr $expr) : ?ClassReflection { $staticType = $this->nodeTypeResolver->getType($expr); - if (!$staticType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$staticType instanceof TypeWithClassName) { return null; } if (!$this->reflectionProvider->hasClass($staticType->getClassName())) { diff --git a/vendor/rector/rector-nette/src/FormControlTypeResolver/NewFormControlTypeResolver.php b/vendor/rector/rector-nette/src/FormControlTypeResolver/NewFormControlTypeResolver.php index 2679140f7da..81d9fa8f477 100644 --- a/vendor/rector/rector-nette/src/FormControlTypeResolver/NewFormControlTypeResolver.php +++ b/vendor/rector/rector-nette/src/FormControlTypeResolver/NewFormControlTypeResolver.php @@ -12,7 +12,7 @@ use Rector\Nette\Contract\FormControlTypeResolverInterface; use Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver; use Rector\NodeNameResolver\NodeNameResolver; use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; -final class NewFormControlTypeResolver implements \Rector\Nette\Contract\FormControlTypeResolverInterface +final class NewFormControlTypeResolver implements FormControlTypeResolverInterface { /** * @var \Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver @@ -28,7 +28,7 @@ final class NewFormControlTypeResolver implements \Rector\Nette\Contract\FormCon * @var \Rector\Core\PhpParser\AstResolver */ private $astResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\AstResolver $astResolver) + public function __construct(NodeNameResolver $nodeNameResolver, AstResolver $astResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->astResolver = $astResolver; @@ -36,24 +36,24 @@ final class NewFormControlTypeResolver implements \Rector\Nette\Contract\FormCon /** * @required */ - public function autowire(\Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver $methodNamesByInputNamesResolver) : void + public function autowire(MethodNamesByInputNamesResolver $methodNamesByInputNamesResolver) : void { $this->methodNamesByInputNamesResolver = $methodNamesByInputNamesResolver; } /** * @return array */ - public function resolve(\PhpParser\Node $node) : array + public function resolve(Node $node) : array { - if (!$node instanceof \PhpParser\Node\Expr\New_) { + if (!$node instanceof New_) { return []; } $className = $this->nodeNameResolver->getName($node->class); if ($className === null) { return []; } - $classMethod = $this->astResolver->resolveClassMethod($className, \Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $this->astResolver->resolveClassMethod($className, MethodName::CONSTRUCT); + if (!$classMethod instanceof ClassMethod) { return []; } return $this->methodNamesByInputNamesResolver->resolveExpr($classMethod); diff --git a/vendor/rector/rector-nette/src/FormControlTypeResolver/OnVariableMethodCallsFormControlTypeResolver.php b/vendor/rector/rector-nette/src/FormControlTypeResolver/OnVariableMethodCallsFormControlTypeResolver.php index dd7cc05bb4e..db123fa0cdf 100644 --- a/vendor/rector/rector-nette/src/FormControlTypeResolver/OnVariableMethodCallsFormControlTypeResolver.php +++ b/vendor/rector/rector-nette/src/FormControlTypeResolver/OnVariableMethodCallsFormControlTypeResolver.php @@ -11,7 +11,7 @@ use Rector\Nette\Contract\FormControlTypeResolverInterface; use Rector\Nette\Enum\NetteFormMethodNameToControlType; use Rector\Nette\NodeAnalyzer\MethodCallManipulator; use Rector\NodeNameResolver\NodeNameResolver; -final class OnVariableMethodCallsFormControlTypeResolver implements \Rector\Nette\Contract\FormControlTypeResolverInterface +final class OnVariableMethodCallsFormControlTypeResolver implements FormControlTypeResolverInterface { /** * @readonly @@ -28,7 +28,7 @@ final class OnVariableMethodCallsFormControlTypeResolver implements \Rector\Nett * @var \Rector\Core\PhpParser\Node\Value\ValueResolver */ private $valueResolver; - public function __construct(\Rector\Nette\NodeAnalyzer\MethodCallManipulator $methodCallManipulator, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver) + public function __construct(MethodCallManipulator $methodCallManipulator, NodeNameResolver $nodeNameResolver, ValueResolver $valueResolver) { $this->methodCallManipulator = $methodCallManipulator; $this->nodeNameResolver = $nodeNameResolver; @@ -37,9 +37,9 @@ final class OnVariableMethodCallsFormControlTypeResolver implements \Rector\Nett /** * @return array */ - public function resolve(\PhpParser\Node $node) : array + public function resolve(Node $node) : array { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + if (!$node instanceof Variable) { return []; } $onFormMethodCalls = $this->methodCallManipulator->findMethodCallsOnVariable($node); @@ -49,7 +49,7 @@ final class OnVariableMethodCallsFormControlTypeResolver implements \Rector\Nett if ($methodName === null) { continue; } - if (!isset(\Rector\Nette\Enum\NetteFormMethodNameToControlType::METHOD_NAME_TO_CONTROL_TYPE[$methodName])) { + if (!isset(NetteFormMethodNameToControlType::METHOD_NAME_TO_CONTROL_TYPE[$methodName])) { continue; } if (!isset($onFormMethodCall->args[0])) { @@ -57,7 +57,7 @@ final class OnVariableMethodCallsFormControlTypeResolver implements \Rector\Nett } $addedInputName = $this->valueResolver->getValue($onFormMethodCall->args[0]->value); if (!\is_string($addedInputName)) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $methodNamesByInputNames[$addedInputName] = $methodName; } diff --git a/vendor/rector/rector-nette/src/FormControlTypeResolver/ReturnFormControlTypeResolver.php b/vendor/rector/rector-nette/src/FormControlTypeResolver/ReturnFormControlTypeResolver.php index ff68d1aebbd..f54e07724db 100644 --- a/vendor/rector/rector-nette/src/FormControlTypeResolver/ReturnFormControlTypeResolver.php +++ b/vendor/rector/rector-nette/src/FormControlTypeResolver/ReturnFormControlTypeResolver.php @@ -11,7 +11,7 @@ use Rector\Core\PhpParser\Node\BetterNodeFinder; use Rector\Nette\Contract\FormControlTypeResolverInterface; use Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver; use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; -final class ReturnFormControlTypeResolver implements \Rector\Nette\Contract\FormControlTypeResolverInterface +final class ReturnFormControlTypeResolver implements FormControlTypeResolverInterface { /** * @var \Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver @@ -22,30 +22,30 @@ final class ReturnFormControlTypeResolver implements \Rector\Nette\Contract\Form * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(BetterNodeFinder $betterNodeFinder) { $this->betterNodeFinder = $betterNodeFinder; } /** * @required */ - public function autowire(\Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver $methodNamesByInputNamesResolver) : void + public function autowire(MethodNamesByInputNamesResolver $methodNamesByInputNamesResolver) : void { $this->methodNamesByInputNamesResolver = $methodNamesByInputNamesResolver; } /** * @return array */ - public function resolve(\PhpParser\Node $node) : array + public function resolve(Node $node) : array { - if (!$node instanceof \PhpParser\Node\Stmt\Return_) { + if (!$node instanceof Return_) { return []; } - if (!$node->expr instanceof \PhpParser\Node\Expr\Variable) { + if (!$node->expr instanceof Variable) { return []; } $initialAssign = $this->betterNodeFinder->findPreviousAssignToExpr($node->expr); - if (!$initialAssign instanceof \PhpParser\Node\Expr\Assign) { + if (!$initialAssign instanceof Assign) { return []; } return $this->methodNamesByInputNamesResolver->resolveExpr($node); diff --git a/vendor/rector/rector-nette/src/FormControlTypeResolver/ThisVariableInAnotherMethodFormControlTypeResolver.php b/vendor/rector/rector-nette/src/FormControlTypeResolver/ThisVariableInAnotherMethodFormControlTypeResolver.php index b5c084004a7..d3ca5eb3b7f 100644 --- a/vendor/rector/rector-nette/src/FormControlTypeResolver/ThisVariableInAnotherMethodFormControlTypeResolver.php +++ b/vendor/rector/rector-nette/src/FormControlTypeResolver/ThisVariableInAnotherMethodFormControlTypeResolver.php @@ -13,7 +13,7 @@ use Rector\Nette\Contract\FormControlTypeResolverInterface; use Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver; use Rector\NodeNameResolver\NodeNameResolver; use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; -final class ThisVariableInAnotherMethodFormControlTypeResolver implements \Rector\Nette\Contract\FormControlTypeResolverInterface +final class ThisVariableInAnotherMethodFormControlTypeResolver implements FormControlTypeResolverInterface { /** * @var \Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver @@ -29,7 +29,7 @@ final class ThisVariableInAnotherMethodFormControlTypeResolver implements \Recto * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder) { $this->nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; @@ -37,32 +37,32 @@ final class ThisVariableInAnotherMethodFormControlTypeResolver implements \Recto /** * @required */ - public function autowire(\Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver $methodNamesByInputNamesResolver) : void + public function autowire(MethodNamesByInputNamesResolver $methodNamesByInputNamesResolver) : void { $this->methodNamesByInputNamesResolver = $methodNamesByInputNamesResolver; } /** * @return array */ - public function resolve(\PhpParser\Node $node) : array + public function resolve(Node $node) : array { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + if (!$node instanceof Variable) { return []; } - $classMethod = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassMethod::class); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $this->betterNodeFinder->findParentType($node, ClassMethod::class); + if (!$classMethod instanceof ClassMethod) { return []; } // handled elsewhere - if ($this->nodeNameResolver->isName($classMethod, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if ($this->nodeNameResolver->isName($classMethod, MethodName::CONSTRUCT)) { return []; } - $class = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$class instanceof Class_) { return []; } - $constructorClassMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$constructorClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $constructorClassMethod = $class->getMethod(MethodName::CONSTRUCT); + if (!$constructorClassMethod instanceof ClassMethod) { return []; } return $this->methodNamesByInputNamesResolver->resolveExpr($constructorClassMethod); diff --git a/vendor/rector/rector-nette/src/FormControlTypeResolver/VariableConstructorFormControlTypeResolver.php b/vendor/rector/rector-nette/src/FormControlTypeResolver/VariableConstructorFormControlTypeResolver.php index 6daa9f9428a..7990052375b 100644 --- a/vendor/rector/rector-nette/src/FormControlTypeResolver/VariableConstructorFormControlTypeResolver.php +++ b/vendor/rector/rector-nette/src/FormControlTypeResolver/VariableConstructorFormControlTypeResolver.php @@ -15,7 +15,7 @@ use Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver; use Rector\NodeNameResolver\NodeNameResolver; use Rector\NodeTypeResolver\NodeTypeResolver; use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; -final class VariableConstructorFormControlTypeResolver implements \Rector\Nette\Contract\FormControlTypeResolverInterface +final class VariableConstructorFormControlTypeResolver implements FormControlTypeResolverInterface { /** * @var \Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver @@ -41,7 +41,7 @@ final class VariableConstructorFormControlTypeResolver implements \Rector\Nette\ * @var \Rector\Core\PhpParser\AstResolver */ private $astResolver; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\PhpParser\AstResolver $astResolver) + public function __construct(NodeTypeResolver $nodeTypeResolver, NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider, AstResolver $astResolver) { $this->nodeTypeResolver = $nodeTypeResolver; $this->nodeNameResolver = $nodeNameResolver; @@ -51,9 +51,9 @@ final class VariableConstructorFormControlTypeResolver implements \Rector\Nette\ /** * @return array */ - public function resolve(\PhpParser\Node $node) : array + public function resolve(Node $node) : array { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + if (!$node instanceof Variable) { return []; } // handled else-where @@ -61,15 +61,15 @@ final class VariableConstructorFormControlTypeResolver implements \Rector\Nette\ return []; } $formType = $this->nodeTypeResolver->getType($node); - if (!$formType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$formType instanceof TypeWithClassName) { return []; } $formClassReflection = $this->reflectionProvider->getClass($formType->getClassName()); if (!$formClassReflection->isSubclassOf('Nette\\Application\\UI\\Form')) { return []; } - $classMethod = $this->astResolver->resolveClassMethod($formType->getClassName(), \Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $this->astResolver->resolveClassMethod($formType->getClassName(), MethodName::CONSTRUCT); + if (!$classMethod instanceof ClassMethod) { return []; } return $this->methodNamesByInputNamesResolver->resolveExpr($classMethod); @@ -77,7 +77,7 @@ final class VariableConstructorFormControlTypeResolver implements \Rector\Nette\ /** * @required */ - public function autowire(\Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver $methodNamesByInputNamesResolver) : void + public function autowire(MethodNamesByInputNamesResolver $methodNamesByInputNamesResolver) : void { $this->methodNamesByInputNamesResolver = $methodNamesByInputNamesResolver; } diff --git a/vendor/rector/rector-nette/src/Kdyby/BlueprintFactory/VariableWithTypesFactory.php b/vendor/rector/rector-nette/src/Kdyby/BlueprintFactory/VariableWithTypesFactory.php index f7f58a29634..8920b503bca 100644 --- a/vendor/rector/rector-nette/src/Kdyby/BlueprintFactory/VariableWithTypesFactory.php +++ b/vendor/rector/rector-nette/src/Kdyby/BlueprintFactory/VariableWithTypesFactory.php @@ -29,7 +29,7 @@ final class VariableWithTypesFactory * @var \Rector\Naming\Naming\VariableNaming */ private $variableNaming; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\Naming\Naming\VariableNaming $variableNaming) + public function __construct(NodeTypeResolver $nodeTypeResolver, StaticTypeMapper $staticTypeMapper, VariableNaming $variableNaming) { $this->nodeTypeResolver = $nodeTypeResolver; $this->staticTypeMapper = $staticTypeMapper; @@ -46,14 +46,14 @@ final class VariableWithTypesFactory $staticType = $this->nodeTypeResolver->getType($arg->value); $variableName = $this->variableNaming->resolveFromNodeAndType($arg, $staticType); if ($variableName === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } // compensate for static - if ($staticType instanceof \PHPStan\Type\StaticType) { - $staticType = new \PHPStan\Type\ObjectType($staticType->getClassName()); + if ($staticType instanceof StaticType) { + $staticType = new ObjectType($staticType->getClassName()); } - $phpParserTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($staticType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY); - $variablesWithTypes[] = new \Rector\Nette\Kdyby\ValueObject\VariableWithType($variableName, $staticType, $phpParserTypeNode); + $phpParserTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($staticType, TypeKind::PROPERTY); + $variablesWithTypes[] = new VariableWithType($variableName, $staticType, $phpParserTypeNode); } return $variablesWithTypes; } diff --git a/vendor/rector/rector-nette/src/Kdyby/ContributeEventClassResolver.php b/vendor/rector/rector-nette/src/Kdyby/ContributeEventClassResolver.php index 7075dd3a3e4..580ea2f71da 100644 --- a/vendor/rector/rector-nette/src/Kdyby/ContributeEventClassResolver.php +++ b/vendor/rector/rector-nette/src/Kdyby/ContributeEventClassResolver.php @@ -50,26 +50,26 @@ final class ContributeEventClassResolver * @var \Rector\Naming\Naming\VariableNaming */ private $variableNaming; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\Naming\Naming\VariableNaming $variableNaming) + public function __construct(NodeNameResolver $nodeNameResolver, StaticTypeMapper $staticTypeMapper, VariableNaming $variableNaming) { $this->nodeNameResolver = $nodeNameResolver; $this->staticTypeMapper = $staticTypeMapper; $this->variableNaming = $variableNaming; } - public function resolveGetterMethodByEventClassAndParam(string $eventClass, \PhpParser\Node\Param $param) : string + public function resolveGetterMethodByEventClassAndParam(string $eventClass, Param $param) : string { $getterMethodsWithType = self::CONTRIBUTTE_EVENT_GETTER_METHODS_WITH_TYPE[$eventClass] ?? null; $paramType = $param->type; // unwrap nullable type - if ($paramType instanceof \PhpParser\Node\NullableType) { + if ($paramType instanceof NullableType) { $paramType = $paramType->type; } - if ($paramType === null || $paramType instanceof \PhpParser\Node\Identifier) { + if ($paramType === null || $paramType instanceof Identifier) { return $this->resolveParamType($paramType, $param); } $type = $this->nodeNameResolver->getName($paramType); if ($type === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } // system contribute event if (isset($getterMethodsWithType[$type])) { @@ -78,17 +78,17 @@ final class ContributeEventClassResolver $staticType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($paramType); return $this->createGetterFromParamAndStaticType($param, $staticType); } - private function createGetterFromParamAndStaticType(\PhpParser\Node\Param $param, \PHPStan\Type\Type $type) : string + private function createGetterFromParamAndStaticType(Param $param, Type $type) : string { $variableName = $this->variableNaming->resolveFromNodeAndType($param, $type); if ($variableName === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } return 'get' . \ucfirst($variableName); } - private function resolveParamType(?\PhpParser\Node\Identifier $identifier, \PhpParser\Node\Param $param) : string + private function resolveParamType(?Identifier $identifier, Param $param) : string { - $staticType = $identifier === null ? new \PHPStan\Type\MixedType() : $this->staticTypeMapper->mapPhpParserNodePHPStanType($identifier); + $staticType = $identifier === null ? new MixedType() : $this->staticTypeMapper->mapPhpParserNodePHPStanType($identifier); return $this->createGetterFromParamAndStaticType($param, $staticType); } } diff --git a/vendor/rector/rector-nette/src/Kdyby/Naming/EventClassNaming.php b/vendor/rector/rector-nette/src/Kdyby/Naming/EventClassNaming.php index 1d58f16ea80..d7be609933d 100644 --- a/vendor/rector/rector-nette/src/Kdyby/Naming/EventClassNaming.php +++ b/vendor/rector/rector-nette/src/Kdyby/Naming/EventClassNaming.php @@ -6,7 +6,7 @@ namespace Rector\Nette\Kdyby\Naming; use RectorPrefix20220607\Nette\Utils\Strings; use Rector\CodingStyle\Naming\ClassNaming; use Rector\NodeNameResolver\NodeNameResolver; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class EventClassNaming { /** @@ -23,12 +23,12 @@ final class EventClassNaming * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\CodingStyle\Naming\ClassNaming $classNaming, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(ClassNaming $classNaming, NodeNameResolver $nodeNameResolver) { $this->classNaming = $classNaming; $this->nodeNameResolver = $nodeNameResolver; } - public function resolveEventFileLocationFromClassNameAndFileInfo(string $className, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : string + public function resolveEventFileLocationFromClassNameAndFileInfo(string $className, SmartFileInfo $smartFileInfo) : string { $shortClassName = $this->nodeNameResolver->getShortName($className); return $smartFileInfo->getPath() . \DIRECTORY_SEPARATOR . self::EVENT . \DIRECTORY_SEPARATOR . $shortClassName . '.php'; @@ -46,7 +46,7 @@ final class EventClassNaming } private function prependShortClassEventWithNamespace(string $shortEventClassName, string $orinalClassName) : string { - $namespaceAbove = \RectorPrefix20220607\Nette\Utils\Strings::before($orinalClassName, '\\', -1); + $namespaceAbove = Strings::before($orinalClassName, '\\', -1); return $namespaceAbove . '\\Event\\' . $shortEventClassName; } /** @@ -56,7 +56,7 @@ final class EventClassNaming { $shortClassName = $this->classNaming->getShortName($class); // "onMagic" => "Magic" - $shortPropertyName = \RectorPrefix20220607\Nette\Utils\Strings::substring($property, \strlen('on')); + $shortPropertyName = Strings::substring($property, \strlen('on')); return $shortClassName . $shortPropertyName . self::EVENT; } } diff --git a/vendor/rector/rector-nette/src/Kdyby/NodeAnalyzer/GetSubscribedEventsClassMethodAnalyzer.php b/vendor/rector/rector-nette/src/Kdyby/NodeAnalyzer/GetSubscribedEventsClassMethodAnalyzer.php index 2cd7cc65fb9..b209a8f69b7 100644 --- a/vendor/rector/rector-nette/src/Kdyby/NodeAnalyzer/GetSubscribedEventsClassMethodAnalyzer.php +++ b/vendor/rector/rector-nette/src/Kdyby/NodeAnalyzer/GetSubscribedEventsClassMethodAnalyzer.php @@ -26,19 +26,19 @@ final class GetSubscribedEventsClassMethodAnalyzer * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeTypeResolver $nodeTypeResolver, NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder) { $this->nodeTypeResolver = $nodeTypeResolver; $this->nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; } - public function detect(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + public function detect(ClassMethod $classMethod) : bool { - $classLike = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($classMethod, ClassLike::class); + if (!$classLike instanceof ClassLike) { return \false; } - if (!$this->nodeTypeResolver->isObjectType($classLike, new \PHPStan\Type\ObjectType('Kdyby\\Events\\Subscriber'))) { + if (!$this->nodeTypeResolver->isObjectType($classLike, new ObjectType('Kdyby\\Events\\Subscriber'))) { return \false; } return $this->nodeNameResolver->isName($classMethod, 'getSubscribedEvents'); diff --git a/vendor/rector/rector-nette/src/Kdyby/NodeFactory/EventValueObjectClassFactory.php b/vendor/rector/rector-nette/src/Kdyby/NodeFactory/EventValueObjectClassFactory.php index c22cf6433d9..322dfca8562 100644 --- a/vendor/rector/rector-nette/src/Kdyby/NodeFactory/EventValueObjectClassFactory.php +++ b/vendor/rector/rector-nette/src/Kdyby/NodeFactory/EventValueObjectClassFactory.php @@ -48,7 +48,7 @@ final class EventValueObjectClassFactory * @var \Rector\Nette\Kdyby\BlueprintFactory\VariableWithTypesFactory */ private $variableWithTypesFactory; - public function __construct(\Rector\CodingStyle\Naming\ClassNaming $classNaming, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Nette\Kdyby\BlueprintFactory\VariableWithTypesFactory $variableWithTypesFactory) + public function __construct(ClassNaming $classNaming, NodeFactory $nodeFactory, NodeNameResolver $nodeNameResolver, VariableWithTypesFactory $variableWithTypesFactory) { $this->classNaming = $classNaming; $this->nodeFactory = $nodeFactory; @@ -58,30 +58,30 @@ final class EventValueObjectClassFactory /** * @param Arg[] $args */ - public function create(string $className, array $args) : \PhpParser\Node\Stmt\Namespace_ + public function create(string $className, array $args) : Namespace_ { $classBuilder = $this->createEventClassBuilder($className); $this->decorateWithConstructorIfHasArgs($classBuilder, $args); $class = $classBuilder->getNode(); // traverse with node name resolver, to to comply with PHPStan default parser - $nameResolver = new \PhpParser\NodeVisitor\NameResolver(null, ['replaceNodes' => \false, 'preserveOriginalNames' => \true]); - $nodeTraverser = new \PhpParser\NodeTraverser(); + $nameResolver = new NameResolver(null, ['replaceNodes' => \false, 'preserveOriginalNames' => \true]); + $nodeTraverser = new NodeTraverser(); $nodeTraverser->addVisitor($nameResolver); $nodeTraverser->traverse([$class]); return $this->wrapClassToNamespace($className, $class); } - private function createEventClassBuilder(string $className) : \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\ClassBuilder + private function createEventClassBuilder(string $className) : ClassBuilder { $shortClassName = $this->classNaming->getShortName($className); - $classBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\ClassBuilder($shortClassName); + $classBuilder = new ClassBuilder($shortClassName); $classBuilder->makeFinal(); - $classBuilder->extend(new \PhpParser\Node\Name\FullyQualified('Symfony\\Contracts\\EventDispatcher\\Event')); + $classBuilder->extend(new FullyQualified('Symfony\\Contracts\\EventDispatcher\\Event')); return $classBuilder; } /** * @param Arg[] $args */ - private function decorateWithConstructorIfHasArgs(\RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\ClassBuilder $classBuilder, array $args) : void + private function decorateWithConstructorIfHasArgs(ClassBuilder $classBuilder, array $args) : void { if ($args === []) { return; @@ -101,24 +101,24 @@ final class EventValueObjectClassFactory $classBuilder->addStmt($getterClassMethod); } } - private function wrapClassToNamespace(string $className, \PhpParser\Node\Stmt\Class_ $class) : \PhpParser\Node\Stmt\Namespace_ + private function wrapClassToNamespace(string $className, Class_ $class) : Namespace_ { - $namespace = \RectorPrefix20220607\Nette\Utils\Strings::before($className, '\\', -1); - $namespaceBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\NamespaceBuilder($namespace); + $namespace = Strings::before($className, '\\', -1); + $namespaceBuilder = new NamespaceBuilder($namespace); $namespaceBuilder->addStmt($class); return $namespaceBuilder->getNode(); } /** * @param VariableWithType[] $variablesWithTypes */ - private function ensureVariablesAreUnique(array $variablesWithTypes, \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\ClassBuilder $classBuilder) : void + private function ensureVariablesAreUnique(array $variablesWithTypes, ClassBuilder $classBuilder) : void { $usedVariableNames = []; foreach ($variablesWithTypes as $variablesWithType) { if (\in_array($variablesWithType->getName(), $usedVariableNames, \true)) { $className = $this->nodeNameResolver->getName($classBuilder->getNode()); $message = \sprintf('Variable "$%s" is duplicated in to be created "%s" class', $variablesWithType->getName(), $className); - throw new \Rector\Core\Exception\ShouldNotHappenException($message); + throw new ShouldNotHappenException($message); } $usedVariableNames[] = $variablesWithType->getName(); } @@ -126,12 +126,12 @@ final class EventValueObjectClassFactory /** * @param VariableWithType[] $variableWithTypes */ - private function createConstructClassMethod(array $variableWithTypes) : \PhpParser\Node\Stmt\ClassMethod + private function createConstructClassMethod(array $variableWithTypes) : ClassMethod { - $methodBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\MethodBuilder(\Rector\Core\ValueObject\MethodName::CONSTRUCT); + $methodBuilder = new MethodBuilder(MethodName::CONSTRUCT); $methodBuilder->makePublic(); foreach ($variableWithTypes as $variableWithType) { - $param = new \PhpParser\Node\Param(new \PhpParser\Node\Expr\Variable($variableWithType->getName())); + $param = new Param(new Variable($variableWithType->getName())); if ($variableWithType->getPhpParserTypeNode() !== null) { $param->type = $variableWithType->getPhpParserTypeNode(); } diff --git a/vendor/rector/rector-nette/src/Kdyby/NodeManipulator/GetSubscribedEventsArrayManipulator.php b/vendor/rector/rector-nette/src/Kdyby/NodeManipulator/GetSubscribedEventsArrayManipulator.php index 2475474a969..e80ea97d2ff 100644 --- a/vendor/rector/rector-nette/src/Kdyby/NodeManipulator/GetSubscribedEventsArrayManipulator.php +++ b/vendor/rector/rector-nette/src/Kdyby/NodeManipulator/GetSubscribedEventsArrayManipulator.php @@ -23,28 +23,28 @@ final class GetSubscribedEventsArrayManipulator * @var \Rector\Core\PhpParser\Node\Value\ValueResolver */ private $valueResolver; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, ValueResolver $valueResolver) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->valueResolver = $valueResolver; } - public function change(\PhpParser\Node\Expr\Array_ $array) : void + public function change(Array_ $array) : void { $arrayItems = \array_filter($array->items, function ($arrayItem) : bool { return $arrayItem !== null; }); - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($arrayItems, function (\PhpParser\Node $node) : ?Node { - if (!$node instanceof \PhpParser\Node\Expr\ArrayItem) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($arrayItems, function (Node $node) : ?Node { + if (!$node instanceof ArrayItem) { return null; } - foreach (\Rector\Nette\Kdyby\ValueObject\NetteEventToContributeEventClass::PROPERTY_TO_EVENT_CLASS as $netteEventProperty => $contributeEventClass) { + foreach (NetteEventToContributeEventClass::PROPERTY_TO_EVENT_CLASS as $netteEventProperty => $contributeEventClass) { if ($node->key === null) { continue; } if (!$this->valueResolver->isValue($node->key, $netteEventProperty)) { continue; } - $node->key = new \PhpParser\Node\Expr\ClassConstFetch(new \PhpParser\Node\Name\FullyQualified($contributeEventClass), 'class'); + $node->key = new ClassConstFetch(new FullyQualified($contributeEventClass), 'class'); } return $node; }); diff --git a/vendor/rector/rector-nette/src/Kdyby/NodeManipulator/ListeningClassMethodArgumentManipulator.php b/vendor/rector/rector-nette/src/Kdyby/NodeManipulator/ListeningClassMethodArgumentManipulator.php index 285f514cae3..92139cd3665 100644 --- a/vendor/rector/rector-nette/src/Kdyby/NodeManipulator/ListeningClassMethodArgumentManipulator.php +++ b/vendor/rector/rector-nette/src/Kdyby/NodeManipulator/ListeningClassMethodArgumentManipulator.php @@ -35,7 +35,7 @@ final class ListeningClassMethodArgumentManipulator * @var \Rector\Core\NodeAnalyzer\ParamAnalyzer */ private $paramAnalyzer; - public function __construct(\Rector\CodingStyle\Naming\ClassNaming $classNaming, \Rector\Nette\Kdyby\ContributeEventClassResolver $contributeEventClassResolver, \Rector\Core\NodeAnalyzer\ParamAnalyzer $paramAnalyzer) + public function __construct(ClassNaming $classNaming, ContributeEventClassResolver $contributeEventClassResolver, ParamAnalyzer $paramAnalyzer) { $this->classNaming = $classNaming; $this->contributeEventClassResolver = $contributeEventClassResolver; @@ -62,25 +62,25 @@ final class ListeningClassMethodArgumentManipulator continue; } $eventGetterToVariableAssign = $this->createEventGetterToVariableMethodCall($eventClass, $oldParam); - $expression = new \PhpParser\Node\Stmt\Expression($eventGetterToVariableAssign); + $expression = new Expression($eventGetterToVariableAssign); $classMethod->stmts = \array_merge([$expression], (array) $classMethod->stmts); } $classMethod->setAttribute(self::EVENT_PARAMETER_REPLACED, \true); } } - private function changeClassParamToEventClass(string $eventClass, \PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function changeClassParamToEventClass(string $eventClass, ClassMethod $classMethod) : void { $paramName = $this->classNaming->getVariableName($eventClass); - $eventVariable = new \PhpParser\Node\Expr\Variable($paramName); - $param = new \PhpParser\Node\Param($eventVariable, null, new \PhpParser\Node\Name\FullyQualified($eventClass)); + $eventVariable = new Variable($paramName); + $param = new Param($eventVariable, null, new FullyQualified($eventClass)); $classMethod->params = [$param]; } - private function createEventGetterToVariableMethodCall(string $eventClass, \PhpParser\Node\Param $param) : \PhpParser\Node\Expr\Assign + private function createEventGetterToVariableMethodCall(string $eventClass, Param $param) : Assign { $paramName = $this->classNaming->getVariableName($eventClass); - $eventVariable = new \PhpParser\Node\Expr\Variable($paramName); + $eventVariable = new Variable($paramName); $getterMethod = $this->contributeEventClassResolver->resolveGetterMethodByEventClassAndParam($eventClass, $param); - $methodCall = new \PhpParser\Node\Expr\MethodCall($eventVariable, $getterMethod); - return new \PhpParser\Node\Expr\Assign($param->var, $methodCall); + $methodCall = new MethodCall($eventVariable, $getterMethod); + return new Assign($param->var, $methodCall); } } diff --git a/vendor/rector/rector-nette/src/Kdyby/NodeResolver/ListeningMethodsCollector.php b/vendor/rector/rector-nette/src/Kdyby/NodeResolver/ListeningMethodsCollector.php index 02843bc9ac4..6cbf436f9bc 100644 --- a/vendor/rector/rector-nette/src/Kdyby/NodeResolver/ListeningMethodsCollector.php +++ b/vendor/rector/rector-nette/src/Kdyby/NodeResolver/ListeningMethodsCollector.php @@ -49,7 +49,7 @@ final class ListeningMethodsCollector * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\Nette\Kdyby\Naming\EventClassNaming $eventClassNaming, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, EventClassNaming $eventClassNaming, ValueResolver $valueResolver, BetterNodeFinder $betterNodeFinder) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->eventClassNaming = $eventClassNaming; @@ -59,19 +59,19 @@ final class ListeningMethodsCollector /** * @return EventClassAndClassMethod[] */ - public function collectFromClassAndGetSubscribedEventClassMethod(\PhpParser\Node\Stmt\ClassMethod $getSubscribedEventsClassMethod, string $type) : array + public function collectFromClassAndGetSubscribedEventClassMethod(ClassMethod $getSubscribedEventsClassMethod, string $type) : array { - $class = $this->betterNodeFinder->findParentType($getSubscribedEventsClassMethod, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($getSubscribedEventsClassMethod, Class_::class); + if (!$class instanceof Class_) { return []; } $this->eventClassesAndClassMethods = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $getSubscribedEventsClassMethod->stmts, function (\PhpParser\Node $node) use($class, $type) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $getSubscribedEventsClassMethod->stmts, function (Node $node) use($class, $type) { $classMethod = $this->matchClassMethodByArrayItem($node, $class); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$classMethod instanceof ClassMethod) { return null; } - if (!$node instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$node instanceof ArrayItem) { return; } if ($node->key === null) { @@ -79,7 +79,7 @@ final class ListeningMethodsCollector } $eventClass = $this->valueResolver->getValue($node->key); if (!\is_string($eventClass)) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } if ($type === self::EVENT_TYPE_CONTRIBUTTE) { /** @var string $eventClass */ @@ -87,7 +87,7 @@ final class ListeningMethodsCollector return null; } $eventClassAndClassMethod = $this->resolveCustomClassMethodAndEventClass($node, $class, $eventClass); - if (!$eventClassAndClassMethod instanceof \Rector\Nette\Kdyby\ValueObject\EventClassAndClassMethod) { + if (!$eventClassAndClassMethod instanceof EventClassAndClassMethod) { return null; } $this->eventClassesAndClassMethods[] = $eventClassAndClassMethod; @@ -98,7 +98,7 @@ final class ListeningMethodsCollector /** * @return ClassMethod[] */ - public function classMethodsListeningToEventClass(\PhpParser\Node\Stmt\ClassMethod $getSubscribedEventsClassMethod, string $type, string $eventClassName) : array + public function classMethodsListeningToEventClass(ClassMethod $getSubscribedEventsClassMethod, string $type, string $eventClassName) : array { $eventClassesAndClassMethods = $this->collectFromClassAndGetSubscribedEventClassMethod($getSubscribedEventsClassMethod, $type); $classMethods = []; @@ -110,9 +110,9 @@ final class ListeningMethodsCollector } return $classMethods; } - private function matchClassMethodByArrayItem(\PhpParser\Node $node, \PhpParser\Node\Stmt\Class_ $class) : ?\PhpParser\Node\Stmt\ClassMethod + private function matchClassMethodByArrayItem(Node $node, Class_ $class) : ?ClassMethod { - if (!$node instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$node instanceof ArrayItem) { return null; } if ($node->key === null) { @@ -120,32 +120,32 @@ final class ListeningMethodsCollector } return $this->matchClassMethodByNodeValue($class, $node->value); } - private function resolveContributeEventClassAndSubscribedClassMethod(string $eventClass, \PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function resolveContributeEventClassAndSubscribedClassMethod(string $eventClass, ClassMethod $classMethod) : void { - $contributeEventClasses = \Rector\Nette\Kdyby\ValueObject\NetteEventToContributeEventClass::PROPERTY_TO_EVENT_CLASS; + $contributeEventClasses = NetteEventToContributeEventClass::PROPERTY_TO_EVENT_CLASS; if (!\in_array($eventClass, $contributeEventClasses, \true)) { return; } - $this->eventClassesAndClassMethods[] = new \Rector\Nette\Kdyby\ValueObject\EventClassAndClassMethod($eventClass, $classMethod); + $this->eventClassesAndClassMethods[] = new EventClassAndClassMethod($eventClass, $classMethod); } - private function resolveCustomClassMethodAndEventClass(\PhpParser\Node\Expr\ArrayItem $arrayItem, \PhpParser\Node\Stmt\Class_ $class, string $eventClass) : ?\Rector\Nette\Kdyby\ValueObject\EventClassAndClassMethod + private function resolveCustomClassMethodAndEventClass(ArrayItem $arrayItem, Class_ $class, string $eventClass) : ?EventClassAndClassMethod { // custom method name $classMethodName = $this->valueResolver->getValue($arrayItem->value); if (!\is_string($classMethodName)) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $classMethod = $class->getMethod($classMethodName); if (\strpos($eventClass, '::') !== \false) { [$dispatchingClass, $property] = \explode('::', $eventClass); $eventClass = $this->eventClassNaming->createEventClassNameFromClassAndProperty($dispatchingClass, $property); } - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$classMethod instanceof ClassMethod) { return null; } - return new \Rector\Nette\Kdyby\ValueObject\EventClassAndClassMethod($eventClass, $classMethod); + return new EventClassAndClassMethod($eventClass, $classMethod); } - private function matchClassMethodByNodeValue(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Expr $expr) : ?\PhpParser\Node\Stmt\ClassMethod + private function matchClassMethodByNodeValue(Class_ $class, Expr $expr) : ?ClassMethod { $possibleMethodName = $this->valueResolver->getValue($expr); if (!\is_string($possibleMethodName)) { diff --git a/vendor/rector/rector-nette/src/Kdyby/Rector/ClassMethod/ChangeNetteEventNamesInGetSubscribedEventsRector.php b/vendor/rector/rector-nette/src/Kdyby/Rector/ClassMethod/ChangeNetteEventNamesInGetSubscribedEventsRector.php index f1eda243477..5fd7da60827 100644 --- a/vendor/rector/rector-nette/src/Kdyby/Rector/ClassMethod/ChangeNetteEventNamesInGetSubscribedEventsRector.php +++ b/vendor/rector/rector-nette/src/Kdyby/Rector/ClassMethod/ChangeNetteEventNamesInGetSubscribedEventsRector.php @@ -18,12 +18,12 @@ use Rector\Nette\Kdyby\NodeManipulator\GetSubscribedEventsArrayManipulator; use Rector\Nette\Kdyby\NodeManipulator\ListeningClassMethodArgumentManipulator; use Rector\Nette\Kdyby\NodeResolver\ListeningMethodsCollector; use Rector\Privatization\NodeManipulator\VisibilityManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Kdyby\Rector\ClassMethod\ChangeNetteEventNamesInGetSubscribedEventsRector\ChangeNetteEventNamesInGetSubscribedEventsRectorTest */ -final class ChangeNetteEventNamesInGetSubscribedEventsRector extends \Rector\Core\Rector\AbstractRector +final class ChangeNetteEventNamesInGetSubscribedEventsRector extends AbstractRector { /** * @readonly @@ -50,7 +50,7 @@ final class ChangeNetteEventNamesInGetSubscribedEventsRector extends \Rector\Cor * @var \Rector\Privatization\NodeManipulator\VisibilityManipulator */ private $visibilityManipulator; - public function __construct(\Rector\Nette\Kdyby\NodeManipulator\GetSubscribedEventsArrayManipulator $getSubscribedEventsArrayManipulator, \Rector\Nette\Kdyby\NodeManipulator\ListeningClassMethodArgumentManipulator $listeningClassMethodArgumentManipulator, \Rector\Nette\Kdyby\NodeResolver\ListeningMethodsCollector $listeningMethodsCollector, \Rector\Nette\Kdyby\NodeAnalyzer\GetSubscribedEventsClassMethodAnalyzer $getSubscribedEventsClassMethodAnalyzer, \Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator) + public function __construct(GetSubscribedEventsArrayManipulator $getSubscribedEventsArrayManipulator, ListeningClassMethodArgumentManipulator $listeningClassMethodArgumentManipulator, ListeningMethodsCollector $listeningMethodsCollector, GetSubscribedEventsClassMethodAnalyzer $getSubscribedEventsClassMethodAnalyzer, VisibilityManipulator $visibilityManipulator) { $this->getSubscribedEventsArrayManipulator = $getSubscribedEventsArrayManipulator; $this->listeningClassMethodArgumentManipulator = $listeningClassMethodArgumentManipulator; @@ -58,9 +58,9 @@ final class ChangeNetteEventNamesInGetSubscribedEventsRector extends \Rector\Cor $this->getSubscribedEventsClassMethodAnalyzer = $getSubscribedEventsClassMethodAnalyzer; $this->visibilityManipulator = $visibilityManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change EventSubscriber from Kdyby to Contributte', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change EventSubscriber from Kdyby to Contributte', [new CodeSample(<<<'CODE_SAMPLE' use Kdyby\Events\Subscriber; use Nette\Application\Application; use Nette\Application\UI\Presenter; @@ -110,40 +110,40 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->getSubscribedEventsClassMethodAnalyzer->detect($node)) { return null; } $this->visibilityManipulator->makeStatic($node); $this->refactorEventNames($node); - $listeningClassMethods = $this->listeningMethodsCollector->collectFromClassAndGetSubscribedEventClassMethod($node, \Rector\Nette\Kdyby\NodeResolver\ListeningMethodsCollector::EVENT_TYPE_CONTRIBUTTE); + $listeningClassMethods = $this->listeningMethodsCollector->collectFromClassAndGetSubscribedEventClassMethod($node, ListeningMethodsCollector::EVENT_TYPE_CONTRIBUTTE); $this->listeningClassMethodArgumentManipulator->change($listeningClassMethods); return $node; } - private function refactorEventNames(\PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function refactorEventNames(ClassMethod $classMethod) : void { - $this->traverseNodesWithCallable((array) $classMethod->stmts, function (\PhpParser\Node $node) { - if (!$node instanceof \PhpParser\Node\Stmt\Return_) { + $this->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) { + if (!$node instanceof Return_) { return null; } if ($node->expr === null) { return null; } $returnedExpr = $node->expr; - if (!$returnedExpr instanceof \PhpParser\Node\Expr\Array_) { + if (!$returnedExpr instanceof Array_) { return null; } $this->refactorArrayWithEventTable($returnedExpr); $this->getSubscribedEventsArrayManipulator->change($returnedExpr); }); } - private function refactorArrayWithEventTable(\PhpParser\Node\Expr\Array_ $array) : void + private function refactorArrayWithEventTable(Array_ $array) : void { foreach ($array->items as $arrayItem) { if ($arrayItem === null) { @@ -154,18 +154,18 @@ CODE_SAMPLE } $methodName = $this->resolveMethodNameFromKdybyEventName($arrayItem->value); $arrayItem->key = $arrayItem->value; - $arrayItem->value = new \PhpParser\Node\Scalar\String_($methodName); + $arrayItem->value = new String_($methodName); } } - private function resolveMethodNameFromKdybyEventName(\PhpParser\Node\Expr $expr) : string + private function resolveMethodNameFromKdybyEventName(Expr $expr) : string { $kdybyEventName = $this->valueResolver->getValue($expr); if (!\is_string($kdybyEventName)) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } if (\strpos($kdybyEventName, '::') !== \false) { - return (string) \RectorPrefix20220607\Nette\Utils\Strings::after($kdybyEventName, '::', -1); + return (string) Strings::after($kdybyEventName, '::', -1); } - throw new \Rector\Core\Exception\NotImplementedYetException($kdybyEventName); + throw new NotImplementedYetException($kdybyEventName); } } diff --git a/vendor/rector/rector-nette/src/Kdyby/Rector/MethodCall/ReplaceEventManagerWithEventSubscriberRector.php b/vendor/rector/rector-nette/src/Kdyby/Rector/MethodCall/ReplaceEventManagerWithEventSubscriberRector.php index 90e6847963c..e51e400deb3 100644 --- a/vendor/rector/rector-nette/src/Kdyby/Rector/MethodCall/ReplaceEventManagerWithEventSubscriberRector.php +++ b/vendor/rector/rector-nette/src/Kdyby/Rector/MethodCall/ReplaceEventManagerWithEventSubscriberRector.php @@ -17,12 +17,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\FileSystemRector\ValueObject\AddedFileWithNodes; use Rector\Nette\Kdyby\Naming\EventClassNaming; use Rector\Nette\Kdyby\NodeFactory\EventValueObjectClassFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Kdyby\Rector\MethodCall\ReplaceEventManagerWithEventSubscriberRector\ReplaceEventManagerWithEventSubscriberRectorTest */ -final class ReplaceEventManagerWithEventSubscriberRector extends \Rector\Core\Rector\AbstractRector +final class ReplaceEventManagerWithEventSubscriberRector extends AbstractRector { /** * @readonly @@ -39,15 +39,15 @@ final class ReplaceEventManagerWithEventSubscriberRector extends \Rector\Core\Re * @var \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector */ private $removedAndAddedFilesCollector; - public function __construct(\Rector\Nette\Kdyby\Naming\EventClassNaming $eventClassNaming, \Rector\Nette\Kdyby\NodeFactory\EventValueObjectClassFactory $eventValueObjectClassFactory, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector) + public function __construct(EventClassNaming $eventClassNaming, EventValueObjectClassFactory $eventValueObjectClassFactory, RemovedAndAddedFilesCollector $removedAndAddedFilesCollector) { $this->eventClassNaming = $eventClassNaming; $this->eventValueObjectClassFactory = $eventValueObjectClassFactory; $this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change Kdyby EventManager to EventDispatcher', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change Kdyby EventManager to EventDispatcher', [new CodeSample(<<<'CODE_SAMPLE' use Kdyby\Events\EventManager; final class SomeClass @@ -98,17 +98,17 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } - $node->name = new \PhpParser\Node\Identifier('dispatch'); + $node->name = new Identifier('dispatch'); $oldArgs = $node->args; $node->args = []; $eventReference = $oldArgs[0]->value; @@ -118,19 +118,19 @@ CODE_SAMPLE } $eventClassName = $this->eventClassNaming->createEventClassNameFromClassPropertyReference($classAndStaticProperty); $args = $this->createNewArgs($oldArgs); - $new = new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name\FullyQualified($eventClassName), $args); - $node->args[] = new \PhpParser\Node\Arg($new); + $new = new New_(new FullyQualified($eventClassName), $args); + $node->args[] = new Arg($new); // 3. create new event class with args $eventClassInNamespace = $this->eventValueObjectClassFactory->create($eventClassName, $args); $fileInfo = $this->file->getSmartFileInfo(); $eventFileLocation = $this->eventClassNaming->resolveEventFileLocationFromClassNameAndFileInfo($eventClassName, $fileInfo); - $addedFileWithNodes = new \Rector\FileSystemRector\ValueObject\AddedFileWithNodes($eventFileLocation, [$eventClassInNamespace]); + $addedFileWithNodes = new AddedFileWithNodes($eventFileLocation, [$eventClassInNamespace]); $this->removedAndAddedFilesCollector->addAddedFile($addedFileWithNodes); return $node; } - private function shouldSkip(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + private function shouldSkip(MethodCall $methodCall) : bool { - if (!$this->isObjectType($methodCall->var, new \PHPStan\Type\ObjectType('Kdyby\\Events\\EventManager'))) { + if (!$this->isObjectType($methodCall->var, new ObjectType('Kdyby\\Events\\EventManager'))) { return \true; } return !$this->isName($methodCall->name, 'dispatchEvent'); @@ -142,18 +142,18 @@ CODE_SAMPLE private function createNewArgs(array $oldArgs) : array { $args = []; - if ($oldArgs[1]->value instanceof \PhpParser\Node\Expr\New_) { + if ($oldArgs[1]->value instanceof New_) { /** @var New_ $new */ $new = $oldArgs[1]->value; $array = $new->args[0]->value; - if (!$array instanceof \PhpParser\Node\Expr\Array_) { + if (!$array instanceof Array_) { return []; } foreach ($array->items as $arrayItem) { - if (!$arrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$arrayItem instanceof ArrayItem) { continue; } - $args[] = new \PhpParser\Node\Arg($arrayItem->value); + $args[] = new Arg($arrayItem->value); } } return $args; diff --git a/vendor/rector/rector-nette/src/Kdyby/Rector/MethodCall/WrapTransParameterNameRector.php b/vendor/rector/rector-nette/src/Kdyby/Rector/MethodCall/WrapTransParameterNameRector.php index a84a6d75786..84605353993 100644 --- a/vendor/rector/rector-nette/src/Kdyby/Rector/MethodCall/WrapTransParameterNameRector.php +++ b/vendor/rector/rector-nette/src/Kdyby/Rector/MethodCall/WrapTransParameterNameRector.php @@ -10,8 +10,8 @@ use PhpParser\Node\Scalar\String_; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\Core\Util\StringUtils; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://symfony.com/doc/current/components/translation/usage.html#message-placeholders * @changelog https://github.com/Kdyby/Translation/blob/master/docs/en/index.md#placeholders @@ -19,16 +19,16 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @see \Rector\Nette\Tests\Kdyby\Rector\MethodCall\WrapTransParameterNameRector\WrapTransParameterNameRectorTest */ -final class WrapTransParameterNameRector extends \Rector\Core\Rector\AbstractRector +final class WrapTransParameterNameRector extends AbstractRector { /** * @var string * @see https://regex101.com/r/b8boED/1 */ private const BETWEEN_PERCENT_CHARS_REGEX = '#%(.*?)%#'; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Adds %% to placeholder name of trans() method if missing', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Adds %% to placeholder name of trans() method if missing', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Translation\Translator; final class SomeController @@ -65,14 +65,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Symfony\\Component\\Translation\\TranslatorInterface'))) { + if (!$this->isObjectType($node->var, new ObjectType('Symfony\\Component\\Translation\\TranslatorInterface'))) { return null; } if (!$this->isName($node->name, 'trans')) { @@ -81,7 +81,7 @@ CODE_SAMPLE if (\count($node->args) < 2) { return null; } - if (!$node->args[1]->value instanceof \PhpParser\Node\Expr\Array_) { + if (!$node->args[1]->value instanceof Array_) { return null; } /** @var Array_ $parametersArrayNode */ @@ -90,13 +90,13 @@ CODE_SAMPLE if ($arrayItem === null) { continue; } - if (!$arrayItem->key instanceof \PhpParser\Node\Scalar\String_) { + if (!$arrayItem->key instanceof String_) { continue; } - if (\Rector\Core\Util\StringUtils::isMatch($arrayItem->key->value, self::BETWEEN_PERCENT_CHARS_REGEX)) { + if (StringUtils::isMatch($arrayItem->key->value, self::BETWEEN_PERCENT_CHARS_REGEX)) { continue; } - $arrayItem->key = new \PhpParser\Node\Scalar\String_('%' . $arrayItem->key->value . '%'); + $arrayItem->key = new String_('%' . $arrayItem->key->value . '%'); } return $node; } diff --git a/vendor/rector/rector-nette/src/Kdyby/ValueObject/EventClassAndClassMethod.php b/vendor/rector/rector-nette/src/Kdyby/ValueObject/EventClassAndClassMethod.php index ab3d4afbfcc..ba318f9be52 100644 --- a/vendor/rector/rector-nette/src/Kdyby/ValueObject/EventClassAndClassMethod.php +++ b/vendor/rector/rector-nette/src/Kdyby/ValueObject/EventClassAndClassMethod.php @@ -16,7 +16,7 @@ final class EventClassAndClassMethod * @var \PhpParser\Node\Stmt\ClassMethod */ private $classMethod; - public function __construct(string $eventClass, \PhpParser\Node\Stmt\ClassMethod $classMethod) + public function __construct(string $eventClass, ClassMethod $classMethod) { $this->eventClass = $eventClass; $this->classMethod = $classMethod; @@ -25,7 +25,7 @@ final class EventClassAndClassMethod { return $this->eventClass; } - public function getClassMethod() : \PhpParser\Node\Stmt\ClassMethod + public function getClassMethod() : ClassMethod { return $this->classMethod; } diff --git a/vendor/rector/rector-nette/src/Kdyby/ValueObject/VariableWithType.php b/vendor/rector/rector-nette/src/Kdyby/ValueObject/VariableWithType.php index 65b47ca7dcd..4f01115af3f 100644 --- a/vendor/rector/rector-nette/src/Kdyby/ValueObject/VariableWithType.php +++ b/vendor/rector/rector-nette/src/Kdyby/ValueObject/VariableWithType.php @@ -29,7 +29,7 @@ final class VariableWithType /** * @param ComplexType|Identifier|Name|NullableType|UnionType|null $phpParserTypeNode */ - public function __construct(string $name, \PHPStan\Type\Type $type, $phpParserTypeNode) + public function __construct(string $name, Type $type, $phpParserTypeNode) { $this->name = $name; $this->type = $type; @@ -39,14 +39,14 @@ final class VariableWithType { return $this->name; } - public function getType() : \PHPStan\Type\Type + public function getType() : Type { return $this->type; } /** * @return ComplexType|Identifier|Name|NullableType|UnionType|null */ - public function getPhpParserTypeNode() : ?\PhpParser\Node + public function getPhpParserTypeNode() : ?Node { return $this->phpParserTypeNode; } diff --git a/vendor/rector/rector-nette/src/Latte/Parser/TemplateTypeParser.php b/vendor/rector/rector-nette/src/Latte/Parser/TemplateTypeParser.php index 56fd9be4056..adf1c25645f 100644 --- a/vendor/rector/rector-nette/src/Latte/Parser/TemplateTypeParser.php +++ b/vendor/rector/rector-nette/src/Latte/Parser/TemplateTypeParser.php @@ -20,20 +20,20 @@ final class TemplateTypeParser */ public function parse(string $content) : array { - $templateTypeMatch = \RectorPrefix20220607\Nette\Utils\Strings::match($content, self::TEMPLATE_TYPE_REGEX); + $templateTypeMatch = Strings::match($content, self::TEMPLATE_TYPE_REGEX); if (!isset($templateTypeMatch['template'])) { return []; } try { - $reflectionClass = \PHPStan\BetterReflection\Reflection\ReflectionClass::createFromName($templateTypeMatch['template']); - } catch (\PHPStan\BetterReflection\Reflector\Exception\IdentifierNotFound $exception) { + $reflectionClass = ReflectionClass::createFromName($templateTypeMatch['template']); + } catch (IdentifierNotFound $exception) { return []; } $variableTypes = []; foreach ($reflectionClass->getProperties() as $property) { /** @var ReflectionNamedType $type */ $type = $property->getType(); - $variableTypes[] = new \Rector\Nette\ValueObject\LatteVariableType($property->getName(), (string) $type); + $variableTypes[] = new LatteVariableType($property->getName(), (string) $type); } return $variableTypes; } diff --git a/vendor/rector/rector-nette/src/Latte/Parser/VarTypeParser.php b/vendor/rector/rector-nette/src/Latte/Parser/VarTypeParser.php index 23227629a32..44f6fa5b1ff 100644 --- a/vendor/rector/rector-nette/src/Latte/Parser/VarTypeParser.php +++ b/vendor/rector/rector-nette/src/Latte/Parser/VarTypeParser.php @@ -17,10 +17,10 @@ final class VarTypeParser */ public function parse(string $content) : array { - $matches = \RectorPrefix20220607\Nette\Utils\Strings::matchAll($content, self::VAR_TYPE_REGEX); + $matches = Strings::matchAll($content, self::VAR_TYPE_REGEX); $variableTypes = []; foreach ($matches as $match) { - $variableTypes[] = new \Rector\Nette\ValueObject\LatteVariableType($match['variable'], $match['type']); + $variableTypes[] = new LatteVariableType($match['variable'], $match['type']); } return $variableTypes; } diff --git a/vendor/rector/rector-nette/src/Naming/NetteControlNaming.php b/vendor/rector/rector-nette/src/Naming/NetteControlNaming.php index a4539baa9da..9d85a3136e9 100644 --- a/vendor/rector/rector-nette/src/Naming/NetteControlNaming.php +++ b/vendor/rector/rector-nette/src/Naming/NetteControlNaming.php @@ -8,7 +8,7 @@ final class NetteControlNaming { public function createVariableName(string $shortName) : string { - $variableNameUnicodeString = new \RectorPrefix20220607\Symfony\Component\String\UnicodeString($shortName); + $variableNameUnicodeString = new UnicodeString($shortName); $variableName = $variableNameUnicodeString->camel()->toString(); if (\substr_compare($variableName, 'Form', -\strlen('Form')) === 0) { return $variableName; @@ -17,7 +17,7 @@ final class NetteControlNaming } public function createCreateComponentClassMethodName(string $shortName) : string { - $shortNameUnicodeString = new \RectorPrefix20220607\Symfony\Component\String\UnicodeString($shortName); + $shortNameUnicodeString = new UnicodeString($shortName); $componentName = $shortNameUnicodeString->upper()->camel()->toString(); return 'createComponent' . $componentName; } diff --git a/vendor/rector/rector-nette/src/NodeAnalyzer/ArrayDimFetchAnalyzer.php b/vendor/rector/rector-nette/src/NodeAnalyzer/ArrayDimFetchAnalyzer.php index 39f052d58a3..c0f0005e594 100644 --- a/vendor/rector/rector-nette/src/NodeAnalyzer/ArrayDimFetchAnalyzer.php +++ b/vendor/rector/rector-nette/src/NodeAnalyzer/ArrayDimFetchAnalyzer.php @@ -8,10 +8,10 @@ use PhpParser\Node\Expr\Assign; use Rector\NodeTypeResolver\Node\AttributeKey; final class ArrayDimFetchAnalyzer { - public function isBeingAssignedOrInitialized(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch) : bool + public function isBeingAssignedOrInitialized(ArrayDimFetch $arrayDimFetch) : bool { - $parent = $arrayDimFetch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\Expr\Assign) { + $parent = $arrayDimFetch->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Assign) { return \false; } if ($parent->var === $arrayDimFetch) { diff --git a/vendor/rector/rector-nette/src/NodeAnalyzer/ArrayDimFetchRenamer.php b/vendor/rector/rector-nette/src/NodeAnalyzer/ArrayDimFetchRenamer.php index 4efd4703f1a..c58526e632b 100644 --- a/vendor/rector/rector-nette/src/NodeAnalyzer/ArrayDimFetchRenamer.php +++ b/vendor/rector/rector-nette/src/NodeAnalyzer/ArrayDimFetchRenamer.php @@ -26,7 +26,7 @@ final class ArrayDimFetchRenamer * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeComparator $nodeComparator) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->nodeComparator = $nodeComparator; @@ -34,24 +34,24 @@ final class ArrayDimFetchRenamer /** * @see VariableRenamer::renameVariableInFunctionLike() */ - public function renameToVariable(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch, string $variableName) : void + public function renameToVariable(ClassMethod $classMethod, ArrayDimFetch $arrayDimFetch, string $variableName) : void { - $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (\PhpParser\Node $node) use($arrayDimFetch, $variableName) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) use($arrayDimFetch, $variableName) { // do not rename element above if ($node->getLine() <= $arrayDimFetch->getLine()) { return null; } if ($this->isScopeNesting($node)) { - return \PhpParser\NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; + return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; } if (!$this->nodeComparator->areNodesEqual($node, $arrayDimFetch)) { return null; } - return new \PhpParser\Node\Expr\Variable($variableName); + return new Variable($variableName); }); } - private function isScopeNesting(\PhpParser\Node $node) : bool + private function isScopeNesting(Node $node) : bool { - return $node instanceof \PhpParser\Node\Expr\Closure || $node instanceof \PhpParser\Node\Stmt\Function_ || $node instanceof \PhpParser\Node\Expr\ArrowFunction; + return $node instanceof Closure || $node instanceof Function_ || $node instanceof ArrowFunction; } } diff --git a/vendor/rector/rector-nette/src/NodeAnalyzer/AssignAnalyzer.php b/vendor/rector/rector-nette/src/NodeAnalyzer/AssignAnalyzer.php index ee3fcb3e37e..b6e890b223b 100644 --- a/vendor/rector/rector-nette/src/NodeAnalyzer/AssignAnalyzer.php +++ b/vendor/rector/rector-nette/src/NodeAnalyzer/AssignAnalyzer.php @@ -34,13 +34,13 @@ final class AssignAnalyzer * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\PostRector\Collector\NodesToAddCollector $nodesToAddCollector, \Rector\BetterPhpDocParser\PhpDocManipulator\VarAnnotationManipulator $varAnnotationManipulator, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodesToAddCollector $nodesToAddCollector, VarAnnotationManipulator $varAnnotationManipulator, BetterNodeFinder $betterNodeFinder) { $this->nodesToAddCollector = $nodesToAddCollector; $this->varAnnotationManipulator = $varAnnotationManipulator; $this->betterNodeFinder = $betterNodeFinder; } - public function addAssignExpressionForFirstCase(string $variableName, \PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch, \PHPStan\Type\ObjectType $controlObjectType) : void + public function addAssignExpressionForFirstCase(string $variableName, ArrayDimFetch $arrayDimFetch, ObjectType $controlObjectType) : void { if ($this->shouldSkipForAlreadyAddedInCurrentClassMethod($arrayDimFetch, $variableName)) { return; @@ -48,10 +48,10 @@ final class AssignAnalyzer $assignExpression = $this->createAnnotatedAssignExpression($variableName, $arrayDimFetch, $controlObjectType); $this->nodesToAddCollector->addNodeBeforeNode($assignExpression, $arrayDimFetch); } - private function shouldSkipForAlreadyAddedInCurrentClassMethod(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch, string $variableName) : bool + private function shouldSkipForAlreadyAddedInCurrentClassMethod(ArrayDimFetch $arrayDimFetch, string $variableName) : bool { - $classMethod = $this->betterNodeFinder->findParentType($arrayDimFetch, \PhpParser\Node\Stmt\ClassMethod::class); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $this->betterNodeFinder->findParentType($arrayDimFetch, ClassMethod::class); + if (!$classMethod instanceof ClassMethod) { return \false; } $classMethodObjectHash = \spl_object_hash($classMethod) . $variableName; @@ -61,19 +61,19 @@ final class AssignAnalyzer $this->alreadyInitializedAssignsClassMethodObjectHashes[] = $classMethodObjectHash; return \false; } - private function createAnnotatedAssignExpression(string $variableName, \PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch, \PHPStan\Type\ObjectType $controlObjectType) : \PhpParser\Node\Stmt\Expression + private function createAnnotatedAssignExpression(string $variableName, ArrayDimFetch $arrayDimFetch, ObjectType $controlObjectType) : Expression { $assignExpression = $this->createAssignExpression($variableName, $arrayDimFetch); $this->varAnnotationManipulator->decorateNodeWithInlineVarType($assignExpression, $controlObjectType, $variableName); return $assignExpression; } - private function createAssignExpression(string $variableName, \PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch) : \PhpParser\Node\Stmt\Expression + private function createAssignExpression(string $variableName, ArrayDimFetch $arrayDimFetch) : Expression { - $variable = new \PhpParser\Node\Expr\Variable($variableName); + $variable = new Variable($variableName); $assignedArrayDimFetch = clone $arrayDimFetch; - $assign = new \PhpParser\Node\Expr\Assign($variable, $assignedArrayDimFetch); - $variable->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE, $assign); - $assignedArrayDimFetch->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE, $assign); - return new \PhpParser\Node\Stmt\Expression($assign); + $assign = new Assign($variable, $assignedArrayDimFetch); + $variable->setAttribute(AttributeKey::PARENT_NODE, $assign); + $assignedArrayDimFetch->setAttribute(AttributeKey::PARENT_NODE, $assign); + return new Expression($assign); } } diff --git a/vendor/rector/rector-nette/src/NodeAnalyzer/BinaryOpAnalyzer.php b/vendor/rector/rector-nette/src/NodeAnalyzer/BinaryOpAnalyzer.php index df6837f578a..3def4f14862 100644 --- a/vendor/rector/rector-nette/src/NodeAnalyzer/BinaryOpAnalyzer.php +++ b/vendor/rector/rector-nette/src/NodeAnalyzer/BinaryOpAnalyzer.php @@ -14,23 +14,23 @@ final class BinaryOpAnalyzer * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } - public function matchFuncCallAndOtherExpr(\PhpParser\Node\Expr\BinaryOp $binaryOp, string $funcCallName) : ?\Rector\Nette\ValueObject\FuncCallAndExpr + public function matchFuncCallAndOtherExpr(BinaryOp $binaryOp, string $funcCallName) : ?FuncCallAndExpr { - if ($binaryOp->left instanceof \PhpParser\Node\Expr\FuncCall) { + if ($binaryOp->left instanceof FuncCall) { if (!$this->nodeNameResolver->isName($binaryOp->left, $funcCallName)) { return null; } - return new \Rector\Nette\ValueObject\FuncCallAndExpr($binaryOp->left, $binaryOp->right); + return new FuncCallAndExpr($binaryOp->left, $binaryOp->right); } - if ($binaryOp->right instanceof \PhpParser\Node\Expr\FuncCall) { + if ($binaryOp->right instanceof FuncCall) { if (!$this->nodeNameResolver->isName($binaryOp->right, $funcCallName)) { return null; } - return new \Rector\Nette\ValueObject\FuncCallAndExpr($binaryOp->right, $binaryOp->left); + return new FuncCallAndExpr($binaryOp->right, $binaryOp->left); } return null; } diff --git a/vendor/rector/rector-nette/src/NodeAnalyzer/ConditionalTemplateAssignReplacer.php b/vendor/rector/rector-nette/src/NodeAnalyzer/ConditionalTemplateAssignReplacer.php index 5069ff9c62c..550421d39bb 100644 --- a/vendor/rector/rector-nette/src/NodeAnalyzer/ConditionalTemplateAssignReplacer.php +++ b/vendor/rector/rector-nette/src/NodeAnalyzer/ConditionalTemplateAssignReplacer.php @@ -16,11 +16,11 @@ use Rector\Nette\ValueObject\TemplateParametersAssigns; */ final class ConditionalTemplateAssignReplacer { - public function processClassMethod(\Rector\Nette\ValueObject\TemplateParametersAssigns $templateParametersAssigns) : void + public function processClassMethod(TemplateParametersAssigns $templateParametersAssigns) : void { foreach ($templateParametersAssigns->getNonSingleParameterAssigns() as $parameterAssign) { $assign = $parameterAssign->getAssign(); - $assign->var = new \PhpParser\Node\Expr\Variable($parameterAssign->getParameterName()); + $assign->var = new Variable($parameterAssign->getParameterName()); } } } diff --git a/vendor/rector/rector-nette/src/NodeAnalyzer/ControlDimFetchAnalyzer.php b/vendor/rector/rector-nette/src/NodeAnalyzer/ControlDimFetchAnalyzer.php index 82056e8644a..6d574d8f1fe 100644 --- a/vendor/rector/rector-nette/src/NodeAnalyzer/ControlDimFetchAnalyzer.php +++ b/vendor/rector/rector-nette/src/NodeAnalyzer/ControlDimFetchAnalyzer.php @@ -17,32 +17,32 @@ final class ControlDimFetchAnalyzer * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(NodeTypeResolver $nodeTypeResolver) { $this->nodeTypeResolver = $nodeTypeResolver; } - public function matchNameOnFormOrControlVariable(\PhpParser\Node $node) : ?string + public function matchNameOnFormOrControlVariable(Node $node) : ?string { - return $this->matchNameOnVariableType($node, new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Form')); + return $this->matchNameOnVariableType($node, new ObjectType('Nette\\Application\\UI\\Form')); } - public function matchNameOnControlVariable(\PhpParser\Node $node) : ?string + public function matchNameOnControlVariable(Node $node) : ?string { - return $this->matchNameOnVariableType($node, new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Control')); + return $this->matchNameOnVariableType($node, new ObjectType('Nette\\Application\\UI\\Control')); } - public function matchName(\PhpParser\Node $node) : ?string + public function matchName(Node $node) : ?string { - if (!$node instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$node instanceof ArrayDimFetch) { return null; } - if (!$this->isVariableTypes($node->var, [new \PHPStan\Type\ObjectType('Nette\\ComponentModel\\IContainer')])) { + if (!$this->isVariableTypes($node->var, [new ObjectType('Nette\\ComponentModel\\IContainer')])) { return null; } - if (!$node->dim instanceof \PhpParser\Node\Scalar\String_) { + if (!$node->dim instanceof String_) { return null; } return $node->dim->value; } - private function matchNameOnVariableType(\PhpParser\Node $node, \PHPStan\Type\ObjectType $objectType) : ?string + private function matchNameOnVariableType(Node $node, ObjectType $objectType) : ?string { $matchedName = $this->matchName($node); if ($matchedName === null) { @@ -57,9 +57,9 @@ final class ControlDimFetchAnalyzer /** * @param ObjectType[] $objectTypes */ - private function isVariableTypes(\PhpParser\Node $node, array $objectTypes) : bool + private function isVariableTypes(Node $node, array $objectTypes) : bool { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + if (!$node instanceof Variable) { return \false; } foreach ($objectTypes as $objectType) { diff --git a/vendor/rector/rector-nette/src/NodeAnalyzer/MethodCallArgMerger.php b/vendor/rector/rector-nette/src/NodeAnalyzer/MethodCallArgMerger.php index 09c98675c5c..94f4c86db3c 100644 --- a/vendor/rector/rector-nette/src/NodeAnalyzer/MethodCallArgMerger.php +++ b/vendor/rector/rector-nette/src/NodeAnalyzer/MethodCallArgMerger.php @@ -9,16 +9,16 @@ use PhpParser\Node\Expr\MethodCall; use Rector\Core\Exception\NotImplementedYetException; final class MethodCallArgMerger { - public function mergeOrApendArray(\PhpParser\Node\Expr\MethodCall $methodCall, int $argumentPosition, \PhpParser\Node\Expr\Array_ $array) : void + public function mergeOrApendArray(MethodCall $methodCall, int $argumentPosition, Array_ $array) : void { if (!isset($methodCall->args[$argumentPosition])) { - $methodCall->args[$argumentPosition] = new \PhpParser\Node\Arg($array); + $methodCall->args[$argumentPosition] = new Arg($array); return; } $existingParameterArgValue = $methodCall->args[$argumentPosition]->value; - if (!$existingParameterArgValue instanceof \PhpParser\Node\Expr\Array_) { + if (!$existingParameterArgValue instanceof Array_) { // another parameters than array are not suported yet - throw new \Rector\Core\Exception\NotImplementedYetException(); + throw new NotImplementedYetException(); } $existingParameterArgValue->items = \array_merge($existingParameterArgValue->items, $array->items); } diff --git a/vendor/rector/rector-nette/src/NodeAnalyzer/MethodCallManipulator.php b/vendor/rector/rector-nette/src/NodeAnalyzer/MethodCallManipulator.php index f60bbdcc1d4..d1f22a1ff50 100644 --- a/vendor/rector/rector-nette/src/NodeAnalyzer/MethodCallManipulator.php +++ b/vendor/rector/rector-nette/src/NodeAnalyzer/MethodCallManipulator.php @@ -27,7 +27,7 @@ final class MethodCallManipulator * @var \Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer */ private $fluentChainMethodCallNodeAnalyzer; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Defluent\NodeAnalyzer\FluentChainMethodCallNodeAnalyzer $fluentChainMethodCallNodeAnalyzer) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver, FluentChainMethodCallNodeAnalyzer $fluentChainMethodCallNodeAnalyzer) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeNameResolver = $nodeNameResolver; @@ -36,11 +36,11 @@ final class MethodCallManipulator /** * @return MethodCall[] */ - public function findMethodCallsOnVariable(\PhpParser\Node\Expr\Variable $variable) : array + public function findMethodCallsOnVariable(Variable $variable) : array { // get scope node, e.g. parent function call, method call or anonymous function - $classMethod = $this->betterNodeFinder->findParentType($variable, \PhpParser\Node\Stmt\ClassMethod::class); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $this->betterNodeFinder->findParentType($variable, ClassMethod::class); + if (!$classMethod instanceof ClassMethod) { return []; } $variableName = $this->nodeNameResolver->getName($variable); @@ -48,11 +48,11 @@ final class MethodCallManipulator return []; } /** @var MethodCall[] $methodCalls */ - $methodCalls = $this->betterNodeFinder->findInstanceOf($classMethod, \PhpParser\Node\Expr\MethodCall::class); - return \array_filter($methodCalls, function (\PhpParser\Node\Expr\MethodCall $methodCall) use($variableName) : bool { + $methodCalls = $this->betterNodeFinder->findInstanceOf($classMethod, MethodCall::class); + return \array_filter($methodCalls, function (MethodCall $methodCall) use($variableName) : bool { // cover fluent interfaces too $callerNode = $this->fluentChainMethodCallNodeAnalyzer->resolveRootExpr($methodCall); - if (!$callerNode instanceof \PhpParser\Node\Expr\Variable) { + if (!$callerNode instanceof Variable) { return \false; } return $this->nodeNameResolver->isName($callerNode, $variableName); diff --git a/vendor/rector/rector-nette/src/NodeAnalyzer/NetteClassAnalyzer.php b/vendor/rector/rector-nette/src/NodeAnalyzer/NetteClassAnalyzer.php index d7ab67824a8..85ab92f0e68 100644 --- a/vendor/rector/rector-nette/src/NodeAnalyzer/NetteClassAnalyzer.php +++ b/vendor/rector/rector-nette/src/NodeAnalyzer/NetteClassAnalyzer.php @@ -20,20 +20,20 @@ final class NetteClassAnalyzer * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeTypeResolver $nodeTypeResolver, BetterNodeFinder $betterNodeFinder) { $this->nodeTypeResolver = $nodeTypeResolver; $this->betterNodeFinder = $betterNodeFinder; } - public function isInComponent(\PhpParser\Node $node) : bool + public function isInComponent(Node $node) : bool { - $class = $node instanceof \PhpParser\Node\Stmt\Class_ ? $node : $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $node instanceof Class_ ? $node : $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$class instanceof Class_) { return \false; } - if (!$this->nodeTypeResolver->isObjectType($class, new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Control'))) { + if (!$this->nodeTypeResolver->isObjectType($class, new ObjectType('Nette\\Application\\UI\\Control'))) { return \false; } - return !$this->nodeTypeResolver->isObjectType($class, new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Presenter')); + return !$this->nodeTypeResolver->isObjectType($class, new ObjectType('Nette\\Application\\UI\\Presenter')); } } diff --git a/vendor/rector/rector-nette/src/NodeAnalyzer/NetteInjectPropertyAnalyzer.php b/vendor/rector/rector-nette/src/NodeAnalyzer/NetteInjectPropertyAnalyzer.php index 0d132833fc3..cc828a9986b 100644 --- a/vendor/rector/rector-nette/src/NodeAnalyzer/NetteInjectPropertyAnalyzer.php +++ b/vendor/rector/rector-nette/src/NodeAnalyzer/NetteInjectPropertyAnalyzer.php @@ -23,22 +23,22 @@ final class NetteInjectPropertyAnalyzer * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer $classChildAnalyzer, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(ClassChildAnalyzer $classChildAnalyzer, ReflectionResolver $reflectionResolver) { $this->classChildAnalyzer = $classChildAnalyzer; $this->reflectionResolver = $reflectionResolver; } - public function canBeRefactored(\PhpParser\Node\Stmt\Property $property, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : bool + public function canBeRefactored(Property $property, PhpDocInfo $phpDocInfo) : bool { if (!$phpDocInfo->hasByName('inject')) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } // it needs @var tag as well, to get the type - faster, put first :) if (!$this->isKnownPropertyType($phpDocInfo, $property)) { return \false; } $classReflection = $this->reflectionResolver->resolveClassReflection($property); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } if ($classReflection->isAbstract()) { @@ -47,27 +47,27 @@ final class NetteInjectPropertyAnalyzer if ($classReflection->isAnonymous()) { return \false; } - if ($this->classChildAnalyzer->hasChildClassMethod($classReflection, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if ($this->classChildAnalyzer->hasChildClassMethod($classReflection, MethodName::CONSTRUCT)) { return \false; } return $this->hasNoOrEmptyParamParentConstructor($classReflection); } - public function hasNoOrEmptyParamParentConstructor(\PHPStan\Reflection\ClassReflection $classReflection) : bool + public function hasNoOrEmptyParamParentConstructor(ClassReflection $classReflection) : bool { - $parentClassMethods = $this->classChildAnalyzer->resolveParentClassMethods($classReflection, \Rector\Core\ValueObject\MethodName::CONSTRUCT); + $parentClassMethods = $this->classChildAnalyzer->resolveParentClassMethods($classReflection, MethodName::CONSTRUCT); if ($parentClassMethods === []) { return \true; } // are there parent ctors? - has empty constructor params? it can be refactored foreach ($parentClassMethods as $parentClassMethod) { - $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($parentClassMethod->getVariants()); + $parametersAcceptor = ParametersAcceptorSelector::selectSingle($parentClassMethod->getVariants()); if ($parametersAcceptor->getParameters() !== []) { return \false; } } return \true; } - private function isKnownPropertyType(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\Stmt\Property $property) : bool + private function isKnownPropertyType(PhpDocInfo $phpDocInfo, Property $property) : bool { if ($phpDocInfo->getVarTagValueNode() !== null) { return \true; diff --git a/vendor/rector/rector-nette/src/NodeAnalyzer/PregMatchAllAnalyzer.php b/vendor/rector/rector-nette/src/NodeAnalyzer/PregMatchAllAnalyzer.php index ab6bef1db46..34bc9fc7748 100644 --- a/vendor/rector/rector-nette/src/NodeAnalyzer/PregMatchAllAnalyzer.php +++ b/vendor/rector/rector-nette/src/NodeAnalyzer/PregMatchAllAnalyzer.php @@ -19,7 +19,7 @@ final class PregMatchAllAnalyzer * @param Arg[] $args * @return Arg[] */ - public function compensateEnforcedFlag(string $methodName, \PhpParser\Node\Expr\FuncCall $funcCall, array $args) : array + public function compensateEnforcedFlag(string $methodName, FuncCall $funcCall, array $args) : array { if ($methodName !== 'matchAll') { return $args; @@ -27,9 +27,9 @@ final class PregMatchAllAnalyzer if (\count($funcCall->args) !== 3) { return $args; } - $constFetch = new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('PREG_SET_ORDER')); - $minus = new \PhpParser\Node\Expr\BinaryOp\Minus($constFetch, new \PhpParser\Node\Scalar\LNumber(1)); - $args[] = new \PhpParser\Node\Arg($minus); + $constFetch = new ConstFetch(new Name('PREG_SET_ORDER')); + $minus = new Minus($constFetch, new LNumber(1)); + $args[] = new Arg($minus); return $args; } } diff --git a/vendor/rector/rector-nette/src/NodeAnalyzer/PropertyUsageAnalyzer.php b/vendor/rector/rector-nette/src/NodeAnalyzer/PropertyUsageAnalyzer.php index d735c9b113b..27da4b0b9c8 100644 --- a/vendor/rector/rector-nette/src/NodeAnalyzer/PropertyUsageAnalyzer.php +++ b/vendor/rector/rector-nette/src/NodeAnalyzer/PropertyUsageAnalyzer.php @@ -46,7 +46,7 @@ final class PropertyUsageAnalyzer * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer $familyRelationsAnalyzer, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\AstResolver $astResolver, \Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer $propertyFetchAnalyzer, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(BetterNodeFinder $betterNodeFinder, FamilyRelationsAnalyzer $familyRelationsAnalyzer, NodeNameResolver $nodeNameResolver, AstResolver $astResolver, PropertyFetchAnalyzer $propertyFetchAnalyzer, ReflectionResolver $reflectionResolver) { $this->betterNodeFinder = $betterNodeFinder; $this->familyRelationsAnalyzer = $familyRelationsAnalyzer; @@ -55,11 +55,11 @@ final class PropertyUsageAnalyzer $this->propertyFetchAnalyzer = $propertyFetchAnalyzer; $this->reflectionResolver = $reflectionResolver; } - public function isPropertyFetchedInChildClass(\PhpParser\Node\Stmt\Property $property) : bool + public function isPropertyFetchedInChildClass(Property $property) : bool { $classReflection = $this->reflectionResolver->resolveClassReflection($property); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$classReflection instanceof ClassReflection) { + throw new ShouldNotHappenException(); } if ($classReflection->isClass() && $classReflection->isFinal()) { return \false; @@ -68,10 +68,10 @@ final class PropertyUsageAnalyzer $childrenClassReflections = $this->familyRelationsAnalyzer->getChildrenOfClassReflection($classReflection); foreach ($childrenClassReflections as $childClassReflection) { $childClass = $this->astResolver->resolveClassFromName($childClassReflection->getName()); - if (!$childClass instanceof \PhpParser\Node\Stmt\Class_) { + if (!$childClass instanceof Class_) { continue; } - $isPropertyFetched = (bool) $this->betterNodeFinder->findFirst($childClass->stmts, function (\PhpParser\Node $node) use($propertyName) : bool { + $isPropertyFetched = (bool) $this->betterNodeFinder->findFirst($childClass->stmts, function (Node $node) use($propertyName) : bool { return $this->propertyFetchAnalyzer->isLocalPropertyFetchName($node, $propertyName); }); if ($isPropertyFetched) { diff --git a/vendor/rector/rector-nette/src/NodeAnalyzer/RenderMethodAnalyzer.php b/vendor/rector/rector-nette/src/NodeAnalyzer/RenderMethodAnalyzer.php index d407e9351ba..860ef261ade 100644 --- a/vendor/rector/rector-nette/src/NodeAnalyzer/RenderMethodAnalyzer.php +++ b/vendor/rector/rector-nette/src/NodeAnalyzer/RenderMethodAnalyzer.php @@ -19,7 +19,7 @@ final class RenderMethodAnalyzer * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeNameResolver $nodeNameResolver, BetterNodeFinder $betterNodeFinder) { $this->nodeNameResolver = $nodeNameResolver; $this->betterNodeFinder = $betterNodeFinder; @@ -27,10 +27,10 @@ final class RenderMethodAnalyzer /** * @return MethodCall[] */ - public function machRenderMethodCalls(\PhpParser\Node\Stmt\ClassMethod $classMethod) : array + public function machRenderMethodCalls(ClassMethod $classMethod) : array { /** @var MethodCall[] $methodsCalls */ - $methodsCalls = $this->betterNodeFinder->findInstanceOf((array) $classMethod->stmts, \PhpParser\Node\Expr\MethodCall::class); + $methodsCalls = $this->betterNodeFinder->findInstanceOf((array) $classMethod->stmts, MethodCall::class); $renderMethodCalls = []; foreach ($methodsCalls as $methodCall) { if ($this->nodeNameResolver->isName($methodCall->name, 'render')) { diff --git a/vendor/rector/rector-nette/src/NodeAnalyzer/ReturnAnalyzer.php b/vendor/rector/rector-nette/src/NodeAnalyzer/ReturnAnalyzer.php index 887a1e6c641..1c7ad0d4705 100644 --- a/vendor/rector/rector-nette/src/NodeAnalyzer/ReturnAnalyzer.php +++ b/vendor/rector/rector-nette/src/NodeAnalyzer/ReturnAnalyzer.php @@ -20,15 +20,15 @@ final class ReturnAnalyzer * @var \Rector\NodeNestingScope\ScopeNestingComparator */ private $scopeNestingComparator; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNestingScope\ScopeNestingComparator $scopeNestingComparator) + public function __construct(BetterNodeFinder $betterNodeFinder, ScopeNestingComparator $scopeNestingComparator) { $this->betterNodeFinder = $betterNodeFinder; $this->scopeNestingComparator = $scopeNestingComparator; } - public function findLastClassMethodReturn(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Stmt\Return_ + public function findLastClassMethodReturn(ClassMethod $classMethod) : ?Return_ { /** @var Return_[] $returns */ - $returns = $this->betterNodeFinder->findInstanceOf($classMethod, \PhpParser\Node\Stmt\Return_::class); + $returns = $this->betterNodeFinder->findInstanceOf($classMethod, Return_::class); // put the latest first $returns = \array_reverse($returns); foreach ($returns as $return) { @@ -38,9 +38,9 @@ final class ReturnAnalyzer } return null; } - public function isBeforeLastReturn(\PhpParser\Node\Expr\Assign $assign, ?\PhpParser\Node\Stmt\Return_ $lastReturn) : bool + public function isBeforeLastReturn(Assign $assign, ?Return_ $lastReturn) : bool { - if (!$lastReturn instanceof \PhpParser\Node\Stmt\Return_) { + if (!$lastReturn instanceof Return_) { return \true; } return $lastReturn->getStartTokenPos() < $assign->getStartTokenPos(); diff --git a/vendor/rector/rector-nette/src/NodeAnalyzer/StaticCallAnalyzer.php b/vendor/rector/rector-nette/src/NodeAnalyzer/StaticCallAnalyzer.php index a401eaf0746..747e96ba0cb 100644 --- a/vendor/rector/rector-nette/src/NodeAnalyzer/StaticCallAnalyzer.php +++ b/vendor/rector/rector-nette/src/NodeAnalyzer/StaticCallAnalyzer.php @@ -14,22 +14,22 @@ final class StaticCallAnalyzer * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } - public function isParentCallNamed(\PhpParser\Node $node, string $desiredMethodName) : bool + public function isParentCallNamed(Node $node, string $desiredMethodName) : bool { - if (!$node instanceof \PhpParser\Node\Expr\StaticCall) { + if (!$node instanceof StaticCall) { return \false; } - if ($node->class instanceof \PhpParser\Node\Expr) { + if ($node->class instanceof Expr) { return \false; } if (!$this->nodeNameResolver->isName($node->class, 'parent')) { return \false; } - if ($node->name instanceof \PhpParser\Node\Expr) { + if ($node->name instanceof Expr) { return \false; } return $this->nodeNameResolver->isName($node->name, $desiredMethodName); diff --git a/vendor/rector/rector-nette/src/NodeAnalyzer/StrlenEndsWithResolver.php b/vendor/rector/rector-nette/src/NodeAnalyzer/StrlenEndsWithResolver.php index 4d159e4ee68..f7a9ee161fd 100644 --- a/vendor/rector/rector-nette/src/NodeAnalyzer/StrlenEndsWithResolver.php +++ b/vendor/rector/rector-nette/src/NodeAnalyzer/StrlenEndsWithResolver.php @@ -24,7 +24,7 @@ final class StrlenEndsWithResolver * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(NodeNameResolver $nodeNameResolver, NodeComparator $nodeComparator) { $this->nodeNameResolver = $nodeNameResolver; $this->nodeComparator = $nodeComparator; @@ -32,31 +32,31 @@ final class StrlenEndsWithResolver /** * @param \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical $binaryOp */ - public function resolveBinaryOpForFunction($binaryOp) : ?\Rector\Nette\ValueObject\ContentExprAndNeedleExpr + public function resolveBinaryOpForFunction($binaryOp) : ?ContentExprAndNeedleExpr { - if ($binaryOp->left instanceof \PhpParser\Node\Expr\Variable) { + if ($binaryOp->left instanceof Variable) { return $this->matchContentExprAndNeedleExpr($binaryOp->right, $binaryOp->left); } - if ($binaryOp->right instanceof \PhpParser\Node\Expr\Variable) { + if ($binaryOp->right instanceof Variable) { return $this->matchContentExprAndNeedleExpr($binaryOp->left, $binaryOp->right); } return null; } - public function matchContentExprAndNeedleExpr(\PhpParser\Node $node, \PhpParser\Node\Expr\Variable $variable) : ?\Rector\Nette\ValueObject\ContentExprAndNeedleExpr + public function matchContentExprAndNeedleExpr(Node $node, Variable $variable) : ?ContentExprAndNeedleExpr { - if (!$node instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$node instanceof FuncCall) { return null; } if (!$this->nodeNameResolver->isName($node, 'substr')) { return null; } /** @var FuncCall $node */ - if (!$node->args[1]->value instanceof \PhpParser\Node\Expr\UnaryMinus) { + if (!$node->args[1]->value instanceof UnaryMinus) { return null; } /** @var UnaryMinus $unaryMinus */ $unaryMinus = $node->args[1]->value; - if (!$unaryMinus->expr instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$unaryMinus->expr instanceof FuncCall) { return null; } if (!$this->nodeNameResolver->isName($unaryMinus->expr, 'strlen')) { @@ -65,7 +65,7 @@ final class StrlenEndsWithResolver /** @var FuncCall $strlenFuncCall */ $strlenFuncCall = $unaryMinus->expr; if ($this->nodeComparator->areNodesEqual($strlenFuncCall->args[0]->value, $variable)) { - return new \Rector\Nette\ValueObject\ContentExprAndNeedleExpr($node->args[0]->value, $strlenFuncCall->args[0]->value); + return new ContentExprAndNeedleExpr($node->args[0]->value, $strlenFuncCall->args[0]->value); } return null; } diff --git a/vendor/rector/rector-nette/src/NodeAnalyzer/StrlenStartsWithResolver.php b/vendor/rector/rector-nette/src/NodeAnalyzer/StrlenStartsWithResolver.php index d3dd6852b0b..bd6a8705175 100644 --- a/vendor/rector/rector-nette/src/NodeAnalyzer/StrlenStartsWithResolver.php +++ b/vendor/rector/rector-nette/src/NodeAnalyzer/StrlenStartsWithResolver.php @@ -29,7 +29,7 @@ final class StrlenStartsWithResolver * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(NodeNameResolver $nodeNameResolver, ValueResolver $valueResolver, NodeComparator $nodeComparator) { $this->nodeNameResolver = $nodeNameResolver; $this->valueResolver = $valueResolver; @@ -38,19 +38,19 @@ final class StrlenStartsWithResolver /** * @param \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical $binaryOp */ - public function resolveBinaryOpForFunction($binaryOp, string $functionName) : ?\Rector\Nette\ValueObject\ContentExprAndNeedleExpr + public function resolveBinaryOpForFunction($binaryOp, string $functionName) : ?ContentExprAndNeedleExpr { - if ($binaryOp->left instanceof \PhpParser\Node\Expr\Variable) { + if ($binaryOp->left instanceof Variable) { return $this->matchContentExprAndNeedleExpr($binaryOp->right, $binaryOp->left, $functionName); } - if ($binaryOp->right instanceof \PhpParser\Node\Expr\Variable) { + if ($binaryOp->right instanceof Variable) { return $this->matchContentExprAndNeedleExpr($binaryOp->left, $binaryOp->right, $functionName); } return null; } - private function matchContentExprAndNeedleExpr(\PhpParser\Node $node, \PhpParser\Node\Expr\Variable $variable, string $functionName) : ?\Rector\Nette\ValueObject\ContentExprAndNeedleExpr + private function matchContentExprAndNeedleExpr(Node $node, Variable $variable, string $functionName) : ?ContentExprAndNeedleExpr { - if (!$node instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$node instanceof FuncCall) { return null; } if (!$this->nodeNameResolver->isName($node, $functionName)) { @@ -63,7 +63,7 @@ final class StrlenStartsWithResolver if (!isset($node->args[2])) { return null; } - if (!$node->args[2]->value instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$node->args[2]->value instanceof FuncCall) { return null; } if (!$this->nodeNameResolver->isName($node->args[2]->value, 'strlen')) { @@ -72,7 +72,7 @@ final class StrlenStartsWithResolver /** @var FuncCall $strlenFuncCall */ $strlenFuncCall = $node->args[2]->value; if ($this->nodeComparator->areNodesEqual($strlenFuncCall->args[0]->value, $variable)) { - return new \Rector\Nette\ValueObject\ContentExprAndNeedleExpr($node->args[0]->value, $strlenFuncCall->args[0]->value); + return new ContentExprAndNeedleExpr($node->args[0]->value, $strlenFuncCall->args[0]->value); } return null; } diff --git a/vendor/rector/rector-nette/src/NodeAnalyzer/TemplatePropertyAssignCollector.php b/vendor/rector/rector-nette/src/NodeAnalyzer/TemplatePropertyAssignCollector.php index 6741e647022..6f769e51fe2 100644 --- a/vendor/rector/rector-nette/src/NodeAnalyzer/TemplatePropertyAssignCollector.php +++ b/vendor/rector/rector-nette/src/NodeAnalyzer/TemplatePropertyAssignCollector.php @@ -32,16 +32,16 @@ final class TemplatePropertyAssignCollector */ private const NODE_TYPES = [ // these situations happens only if condition is met - \PhpParser\Node\Stmt\If_::class, - \PhpParser\Node\Stmt\While_::class, - \PhpParser\Node\Stmt\Do_::class, - \PhpParser\Node\Stmt\Catch_::class, - \PhpParser\Node\Stmt\Case_::class, - \PhpParser\Node\Expr\Match_::class, - \PhpParser\Node\Stmt\Switch_::class, - \PhpParser\Node\Stmt\Foreach_::class, + If_::class, + While_::class, + Do_::class, + Catch_::class, + Case_::class, + Match_::class, + Switch_::class, + Foreach_::class, // FunctionLike must be last, so we know the variable is defined in main stmt - \PhpParser\Node\FunctionLike::class, + FunctionLike::class, ]; /** * @var \PhpParser\Node\Stmt\Return_|null @@ -79,14 +79,14 @@ final class TemplatePropertyAssignCollector * @var \Rector\Nette\NodeAnalyzer\ReturnAnalyzer */ private $returnAnalyzer; - public function __construct(\Rector\NodeNestingScope\ScopeNestingComparator $scopeNestingComparator, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Nette\NodeAnalyzer\ThisTemplatePropertyFetchAnalyzer $thisTemplatePropertyFetchAnalyzer, \Rector\Nette\NodeAnalyzer\ReturnAnalyzer $returnAnalyzer) + public function __construct(ScopeNestingComparator $scopeNestingComparator, BetterNodeFinder $betterNodeFinder, \Rector\Nette\NodeAnalyzer\ThisTemplatePropertyFetchAnalyzer $thisTemplatePropertyFetchAnalyzer, \Rector\Nette\NodeAnalyzer\ReturnAnalyzer $returnAnalyzer) { $this->scopeNestingComparator = $scopeNestingComparator; $this->betterNodeFinder = $betterNodeFinder; $this->thisTemplatePropertyFetchAnalyzer = $thisTemplatePropertyFetchAnalyzer; $this->returnAnalyzer = $returnAnalyzer; } - public function collect(\PhpParser\Node\Stmt\ClassMethod $classMethod) : \Rector\Nette\ValueObject\TemplateParametersAssigns + public function collect(ClassMethod $classMethod) : TemplateParametersAssigns { $this->alwaysTemplateParameterAssigns = []; $this->conditionalTemplateParameterAssigns = []; @@ -94,21 +94,21 @@ final class TemplatePropertyAssignCollector $this->lastReturn = $this->returnAnalyzer->findLastClassMethodReturn($classMethod); $assignsOfPropertyFetches = $this->findAssignToPropertyFetches($classMethod); $this->collectVariableFromAssign($assignsOfPropertyFetches); - return new \Rector\Nette\ValueObject\TemplateParametersAssigns($this->alwaysTemplateParameterAssigns, $this->conditionalTemplateParameterAssigns, $this->defaultChangeableTemplateParameterAssigns); + return new TemplateParametersAssigns($this->alwaysTemplateParameterAssigns, $this->conditionalTemplateParameterAssigns, $this->defaultChangeableTemplateParameterAssigns); } /** * @return Node[] */ - private function getFoundParents(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : array + private function getFoundParents(PropertyFetch $propertyFetch) : array { $foundParents = []; /** @var class-string $nodeType */ foreach (self::NODE_TYPES as $nodeType) { $parentType = $this->betterNodeFinder->findParentType($propertyFetch->var, $nodeType); - if ($parentType instanceof \PhpParser\Node) { + if ($parentType instanceof Node) { $foundParents[] = $parentType; $parentParentType = $this->betterNodeFinder->findParentType($parentType, $nodeType); - if ($parentParentType instanceof \PhpParser\Node) { + if ($parentParentType instanceof Node) { $foundParents[] = $parentParentType; } } @@ -140,17 +140,17 @@ final class TemplatePropertyAssignCollector if (!isset($nodes[0])) { return \false; } - return $nodes[0] instanceof \PhpParser\Node\Stmt\ClassMethod; + return $nodes[0] instanceof ClassMethod; } - private function processAssign(\PhpParser\Node\Expr\Assign $assign, bool $isDefaultValueDefined) : void + private function processAssign(Assign $assign, bool $isDefaultValueDefined) : void { $parameterName = $this->thisTemplatePropertyFetchAnalyzer->resolveTemplateParameterNameFromAssign($assign); if ($parameterName === null) { return; } $propertyFetch = $assign->var; - if (!$propertyFetch instanceof \PhpParser\Node\Expr\PropertyFetch) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$propertyFetch instanceof PropertyFetch) { + throw new ShouldNotHappenException(); } $foundParents = $this->getFoundParents($propertyFetch); // nested conditions, unreliable, might not be defined @@ -159,12 +159,12 @@ final class TemplatePropertyAssignCollector } foreach ($foundParents as $foundParent) { if ($this->scopeNestingComparator->isInBothIfElseBranch($foundParent, $propertyFetch)) { - $this->conditionalTemplateParameterAssigns[] = new \Rector\Nette\ValueObject\ParameterAssign($assign, $parameterName); + $this->conditionalTemplateParameterAssigns[] = new ParameterAssign($assign, $parameterName); return; } - if ($foundParent instanceof \PhpParser\Node\Stmt\If_) { + if ($foundParent instanceof If_) { if ($isDefaultValueDefined) { - $this->defaultChangeableTemplateParameterAssigns[] = new \Rector\Nette\ValueObject\AlwaysTemplateParameterAssign($assign, $parameterName, new \PhpParser\Node\Expr\Variable($parameterName)); + $this->defaultChangeableTemplateParameterAssigns[] = new AlwaysTemplateParameterAssign($assign, $parameterName, new Variable($parameterName)); // remove it from always template variables foreach ($this->alwaysTemplateParameterAssigns as $key => $alwaysTemplateParameterAssigns) { if ($alwaysTemplateParameterAssigns->getParameterName() === $parameterName) { @@ -175,7 +175,7 @@ final class TemplatePropertyAssignCollector return; } // only defined in else branch, nothing we can do - if ($foundParent instanceof \PhpParser\Node\Stmt\Else_) { + if ($foundParent instanceof Else_) { return; } } @@ -183,18 +183,18 @@ final class TemplatePropertyAssignCollector if (!$this->returnAnalyzer->isBeforeLastReturn($assign, $this->lastReturn)) { return; } - $this->alwaysTemplateParameterAssigns[] = new \Rector\Nette\ValueObject\AlwaysTemplateParameterAssign($assign, $parameterName, $assign->expr); + $this->alwaysTemplateParameterAssigns[] = new AlwaysTemplateParameterAssign($assign, $parameterName, $assign->expr); } /** * @return Assign[] */ - private function findAssignToPropertyFetches(\PhpParser\Node\Stmt\ClassMethod $classMethod) : array + private function findAssignToPropertyFetches(ClassMethod $classMethod) : array { /** @var Assign[] $assigns */ - $assigns = $this->betterNodeFinder->findInstanceOf((array) $classMethod->stmts, \PhpParser\Node\Expr\Assign::class); + $assigns = $this->betterNodeFinder->findInstanceOf((array) $classMethod->stmts, Assign::class); $assignsOfPropertyFetches = []; foreach ($assigns as $assign) { - if (!$assign->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$assign->var instanceof PropertyFetch) { continue; } $assignsOfPropertyFetches[] = $assign; diff --git a/vendor/rector/rector-nette/src/NodeAnalyzer/TemplatePropertyParametersReplacer.php b/vendor/rector/rector-nette/src/NodeAnalyzer/TemplatePropertyParametersReplacer.php index ba9c1dbd0a8..0f28b588696 100644 --- a/vendor/rector/rector-nette/src/NodeAnalyzer/TemplatePropertyParametersReplacer.php +++ b/vendor/rector/rector-nette/src/NodeAnalyzer/TemplatePropertyParametersReplacer.php @@ -9,10 +9,10 @@ use PhpParser\Node\Scalar\String_; use Rector\Nette\ValueObject\TemplateParametersAssigns; final class TemplatePropertyParametersReplacer { - public function replace(\Rector\Nette\ValueObject\TemplateParametersAssigns $magicTemplateParametersAssigns, \PhpParser\Node\Expr\Variable $variable) : void + public function replace(TemplateParametersAssigns $magicTemplateParametersAssigns, Variable $variable) : void { foreach ($magicTemplateParametersAssigns->getTemplateParameterAssigns() as $alwaysTemplateParameterAssign) { - $arrayDimFetch = new \PhpParser\Node\Expr\ArrayDimFetch($variable, new \PhpParser\Node\Scalar\String_($alwaysTemplateParameterAssign->getParameterName())); + $arrayDimFetch = new ArrayDimFetch($variable, new String_($alwaysTemplateParameterAssign->getParameterName())); $assign = $alwaysTemplateParameterAssign->getAssign(); $assign->var = $arrayDimFetch; } diff --git a/vendor/rector/rector-nette/src/NodeAnalyzer/ThisTemplatePropertyFetchAnalyzer.php b/vendor/rector/rector-nette/src/NodeAnalyzer/ThisTemplatePropertyFetchAnalyzer.php index 6b46fb71540..055cec3ef29 100644 --- a/vendor/rector/rector-nette/src/NodeAnalyzer/ThisTemplatePropertyFetchAnalyzer.php +++ b/vendor/rector/rector-nette/src/NodeAnalyzer/ThisTemplatePropertyFetchAnalyzer.php @@ -15,13 +15,13 @@ final class ThisTemplatePropertyFetchAnalyzer * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } - public function resolveTemplateParameterNameFromAssign(\PhpParser\Node\Expr\Assign $assign) : ?string + public function resolveTemplateParameterNameFromAssign(Assign $assign) : ?string { - if (!$assign->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$assign->var instanceof PropertyFetch) { return null; } $propertyFetch = $assign->var; @@ -35,12 +35,12 @@ final class ThisTemplatePropertyFetchAnalyzer * * $template */ - private function isTemplatePropertyFetch(\PhpParser\Node\Expr $expr) : bool + private function isTemplatePropertyFetch(Expr $expr) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$expr instanceof PropertyFetch) { return \false; } - if (!$expr->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$expr->var instanceof Variable) { return \false; } if (!$this->nodeNameResolver->isName($expr->var, 'this')) { diff --git a/vendor/rector/rector-nette/src/NodeFactory/CheckRequirementsClassMethodFactory.php b/vendor/rector/rector-nette/src/NodeFactory/CheckRequirementsClassMethodFactory.php index 06084e7a1d5..aa86a387d1f 100644 --- a/vendor/rector/rector-nette/src/NodeFactory/CheckRequirementsClassMethodFactory.php +++ b/vendor/rector/rector-nette/src/NodeFactory/CheckRequirementsClassMethodFactory.php @@ -30,11 +30,11 @@ final class CheckRequirementsClassMethodFactory /** * @param Node[] $getUserStmts */ - public function create(array $getUserStmts) : \PhpParser\Node\Stmt\ClassMethod + public function create(array $getUserStmts) : ClassMethod { - $methodBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\MethodBuilder(self::CHECK_REQUIREMENTS_METHOD_NAME); + $methodBuilder = new MethodBuilder(self::CHECK_REQUIREMENTS_METHOD_NAME); $methodBuilder->makePublic(); - $paramBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\ParamBuilder('element'); + $paramBuilder = new ParamBuilder('element'); $methodBuilder->addParam($paramBuilder); $methodBuilder->setReturnType('void'); $parentStaticCall = $this->creatParentStaticCall(); @@ -43,9 +43,9 @@ final class CheckRequirementsClassMethodFactory $methodBuilder->addStmt($parentStaticCall); return $methodBuilder->getNode(); } - private function creatParentStaticCall() : \PhpParser\Node\Expr\StaticCall + private function creatParentStaticCall() : StaticCall { - $args = [new \PhpParser\Node\Arg(new \PhpParser\Node\Expr\Variable('element'))]; - return new \PhpParser\Node\Expr\StaticCall(new \PhpParser\Node\Name('parent'), new \PhpParser\Node\Identifier(self::CHECK_REQUIREMENTS_METHOD_NAME), $args); + $args = [new Arg(new Variable('element'))]; + return new StaticCall(new Name('parent'), new Identifier(self::CHECK_REQUIREMENTS_METHOD_NAME), $args); } } diff --git a/vendor/rector/rector-nette/src/NodeFactory/ClassWithPublicPropertiesFactory.php b/vendor/rector/rector-nette/src/NodeFactory/ClassWithPublicPropertiesFactory.php index e770e1d90b3..5198be5e654 100644 --- a/vendor/rector/rector-nette/src/NodeFactory/ClassWithPublicPropertiesFactory.php +++ b/vendor/rector/rector-nette/src/NodeFactory/ClassWithPublicPropertiesFactory.php @@ -29,22 +29,22 @@ final class ClassWithPublicPropertiesFactory $namespace = \implode('\\', $namespaceParts); $namespaceBuilder = null; if ($namespace !== '') { - $namespaceBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\NamespaceBuilder($namespace); + $namespaceBuilder = new NamespaceBuilder($namespace); } - $classBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\ClassBuilder($className); + $classBuilder = new ClassBuilder($className); if ($parent !== null && $parent !== '') { $classBuilder->extend($this->fixFullyQualifiedName($parent)); } foreach ($traits as $trait) { - $classBuilder->addStmt(new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\TraitUseBuilder($this->fixFullyQualifiedName($trait))); + $classBuilder->addStmt(new TraitUseBuilder($this->fixFullyQualifiedName($trait))); } foreach ($properties as $propertyName => $propertySettings) { $propertyType = $propertySettings['type']; $nullable = $propertySettings['nullable'] ?? \false; if ($nullable) { - $propertyType = new \PhpParser\Node\NullableType($propertyType); + $propertyType = new NullableType($propertyType); } - $propertyBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\PropertyBuilder($propertyName); + $propertyBuilder = new PropertyBuilder($propertyName); $propertyBuilder->setType($propertyType); $classBuilder->addStmt($propertyBuilder); } diff --git a/vendor/rector/rector-nette/src/NodeFactory/ParentGetterStmtsToExternalStmtsFactory.php b/vendor/rector/rector-nette/src/NodeFactory/ParentGetterStmtsToExternalStmtsFactory.php index 749335ce99e..ee51e1453ba 100644 --- a/vendor/rector/rector-nette/src/NodeFactory/ParentGetterStmtsToExternalStmtsFactory.php +++ b/vendor/rector/rector-nette/src/NodeFactory/ParentGetterStmtsToExternalStmtsFactory.php @@ -31,7 +31,7 @@ final class ParentGetterStmtsToExternalStmtsFactory * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(NodeTypeResolver $nodeTypeResolver, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeComparator $nodeComparator) { $this->nodeTypeResolver = $nodeTypeResolver; $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; @@ -45,17 +45,17 @@ final class ParentGetterStmtsToExternalStmtsFactory { $userExpression = null; foreach ($getUserStmts as $key => $getUserStmt) { - if (!$getUserStmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$getUserStmt instanceof Expression) { continue; } $getUserStmt = $getUserStmt->expr; - if (!$getUserStmt instanceof \PhpParser\Node\Expr\Assign) { + if (!$getUserStmt instanceof Assign) { continue; } - if (!$getUserStmt->expr instanceof \PhpParser\Node\Expr\StaticCall) { + if (!$getUserStmt->expr instanceof StaticCall) { continue; } - if (!$this->nodeTypeResolver->isObjectType($getUserStmt->expr, new \PHPStan\Type\ObjectType('Nette\\Security\\User'))) { + if (!$this->nodeTypeResolver->isObjectType($getUserStmt->expr, new ObjectType('Nette\\Security\\User'))) { continue; } $userExpression = $getUserStmt->var; @@ -67,11 +67,11 @@ final class ParentGetterStmtsToExternalStmtsFactory return []; } // stmts without assign - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($getUserStmts, function (\PhpParser\Node $node) use($userExpression) : ?MethodCall { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($getUserStmts, function (Node $node) use($userExpression) : ?MethodCall { if (!$this->nodeComparator->areNodesEqual($node, $userExpression)) { return null; } - return new \PhpParser\Node\Expr\MethodCall(new \PhpParser\Node\Expr\Variable('this'), 'getUser'); + return new MethodCall(new Variable('this'), 'getUser'); }); return $getUserStmts; } @@ -82,7 +82,7 @@ final class ParentGetterStmtsToExternalStmtsFactory private function removeReturn(array $stmts) : array { foreach ($stmts as $key => $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Return_) { + if (!$stmt instanceof Return_) { continue; } unset($stmts[$key]); diff --git a/vendor/rector/rector-nette/src/NodeFactory/RenderParameterArrayFactory.php b/vendor/rector/rector-nette/src/NodeFactory/RenderParameterArrayFactory.php index a4aff407f8e..f9a7b9d3fa4 100644 --- a/vendor/rector/rector-nette/src/NodeFactory/RenderParameterArrayFactory.php +++ b/vendor/rector/rector-nette/src/NodeFactory/RenderParameterArrayFactory.php @@ -10,18 +10,18 @@ use PhpParser\Node\Scalar\String_; use Rector\Nette\ValueObject\TemplateParametersAssigns; final class RenderParameterArrayFactory { - public function createArray(\Rector\Nette\ValueObject\TemplateParametersAssigns $templateParametersAssigns) : ?\PhpParser\Node\Expr\Array_ + public function createArray(TemplateParametersAssigns $templateParametersAssigns) : ?Array_ { $arrayItems = []; foreach ($templateParametersAssigns->getTemplateVariables() as $name => $expr) { - $arrayItems[] = new \PhpParser\Node\Expr\ArrayItem($expr, new \PhpParser\Node\Scalar\String_($name)); + $arrayItems[] = new ArrayItem($expr, new String_($name)); } foreach ($templateParametersAssigns->getConditionalVariableNames() as $variableName) { - $arrayItems[] = new \PhpParser\Node\Expr\ArrayItem(new \PhpParser\Node\Expr\Variable($variableName), new \PhpParser\Node\Scalar\String_($variableName)); + $arrayItems[] = new ArrayItem(new Variable($variableName), new String_($variableName)); } if ($arrayItems === []) { return null; } - return new \PhpParser\Node\Expr\Array_($arrayItems); + return new Array_($arrayItems); } } diff --git a/vendor/rector/rector-nette/src/NodeFinder/FormFieldsFinder.php b/vendor/rector/rector-nette/src/NodeFinder/FormFieldsFinder.php index 81a0139b1d4..5936dfab872 100644 --- a/vendor/rector/rector-nette/src/NodeFinder/FormFieldsFinder.php +++ b/vendor/rector/rector-nette/src/NodeFinder/FormFieldsFinder.php @@ -29,7 +29,7 @@ final class FormFieldsFinder * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeTypeResolver $nodeTypeResolver, NodeNameResolver $nodeNameResolver) { $this->nodeTypeResolver = $nodeTypeResolver; $this->nodeNameResolver = $nodeNameResolver; @@ -37,7 +37,7 @@ final class FormFieldsFinder /** * @return FormField[] */ - public function find(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Expr\Variable $form) : array + public function find(Class_ $class, Variable $form) : array { $formFields = []; foreach ($class->getMethods() as $classMethod) { @@ -46,15 +46,15 @@ final class FormFieldsFinder continue; } foreach ($stmts as $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { continue; } $methodCall = $this->findMethodCall($stmt); - if (!$methodCall instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$methodCall instanceof MethodCall) { continue; } $addFieldMethodCall = $this->findAddFieldMethodCall($methodCall); - if (!$addFieldMethodCall instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$addFieldMethodCall instanceof MethodCall) { continue; } if (!$this->isFormAddFieldMethodCall($addFieldMethodCall, $form)) { @@ -65,51 +65,51 @@ final class FormFieldsFinder } return $formFields; } - private function findMethodCall(\PhpParser\Node\Stmt\Expression $expression) : ?\PhpParser\Node\Expr\MethodCall + private function findMethodCall(Expression $expression) : ?MethodCall { $methodCall = null; - if ($expression->expr instanceof \PhpParser\Node\Expr\MethodCall) { + if ($expression->expr instanceof MethodCall) { $methodCall = $expression->expr; - } elseif ($expression->expr instanceof \PhpParser\Node\Expr\Assign && $expression->expr->expr instanceof \PhpParser\Node\Expr\MethodCall) { + } elseif ($expression->expr instanceof Assign && $expression->expr->expr instanceof MethodCall) { $methodCall = $expression->expr->expr; } return $methodCall; } - private function findAddFieldMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node\Expr\MethodCall + private function findAddFieldMethodCall(MethodCall $methodCall) : ?MethodCall { - if ($methodCall->var instanceof \PhpParser\Node\Expr\Variable) { + if ($methodCall->var instanceof Variable) { // skip submit buttons - if ($this->nodeTypeResolver->isObjectType($methodCall, new \PHPStan\Type\ObjectType('Nette\\Forms\\Controls\\SubmitButton'))) { + if ($this->nodeTypeResolver->isObjectType($methodCall, new ObjectType('Nette\\Forms\\Controls\\SubmitButton'))) { return null; } - if ($this->nodeTypeResolver->isObjectType($methodCall, new \PHPStan\Type\ObjectType('Nette\\Forms\\Container'))) { + if ($this->nodeTypeResolver->isObjectType($methodCall, new ObjectType('Nette\\Forms\\Container'))) { return $methodCall; } // skip groups, renderers, translator etc. - if ($this->nodeTypeResolver->isObjectType($methodCall, new \PHPStan\Type\ObjectType('Nette\\Forms\\Controls\\BaseControl'))) { + if ($this->nodeTypeResolver->isObjectType($methodCall, new ObjectType('Nette\\Forms\\Controls\\BaseControl'))) { return $methodCall; } return null; } - if ($methodCall->var instanceof \PhpParser\Node\Expr\MethodCall) { + if ($methodCall->var instanceof MethodCall) { return $this->findAddFieldMethodCall($methodCall->var); } return null; } - private function isFormAddFieldMethodCall(\PhpParser\Node\Expr\MethodCall $addFieldMethodCall, \PhpParser\Node\Expr\Variable $form) : bool + private function isFormAddFieldMethodCall(MethodCall $addFieldMethodCall, Variable $form) : bool { $methodCallVariable = $this->findMethodCallVariable($addFieldMethodCall); - if (!$methodCallVariable instanceof \PhpParser\Node\Expr\Variable) { + if (!$methodCallVariable instanceof Variable) { return \false; } return $methodCallVariable->name === $form->name; } - private function findMethodCallVariable(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node\Expr\Variable + private function findMethodCallVariable(MethodCall $methodCall) : ?Variable { - if ($methodCall->var instanceof \PhpParser\Node\Expr\Variable) { + if ($methodCall->var instanceof Variable) { return $methodCall->var; } - if ($methodCall->var instanceof \PhpParser\Node\Expr\MethodCall) { + if ($methodCall->var instanceof MethodCall) { return $this->findMethodCallVariable($methodCall->var); } return null; @@ -118,26 +118,26 @@ final class FormFieldsFinder * @param FormField[] $formFields * @return FormField[] */ - private function addFormField(array $formFields, \PhpParser\Node\Expr\MethodCall $addFieldMethodCall, \PhpParser\Node\Expr\MethodCall $methodCall) : array + private function addFormField(array $formFields, MethodCall $addFieldMethodCall, MethodCall $methodCall) : array { $arg = $addFieldMethodCall->args[0] ?? null; if (!$arg) { return $formFields; } $name = $arg->value; - if (!$name instanceof \PhpParser\Node\Scalar\String_) { + if (!$name instanceof String_) { return $formFields; } - $formFields[] = new \Rector\Nette\ValueObject\FormField($name->value, $this->resolveFieldType($this->nodeNameResolver->getName($addFieldMethodCall->name)), $this->isFieldRequired($methodCall)); + $formFields[] = new FormField($name->value, $this->resolveFieldType($this->nodeNameResolver->getName($addFieldMethodCall->name)), $this->isFieldRequired($methodCall)); return $formFields; } - private function isFieldRequired(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + private function isFieldRequired(MethodCall $methodCall) : bool { - if ($methodCall->name instanceof \PhpParser\Node\Identifier && $methodCall->name->name === 'setRequired') { + if ($methodCall->name instanceof Identifier && $methodCall->name->name === 'setRequired') { // TODO addRule(Form:FILLED) is also required return \true; } - if ($methodCall->var instanceof \PhpParser\Node\Expr\MethodCall) { + if ($methodCall->var instanceof MethodCall) { return $this->isFieldRequired($methodCall->var); } return \false; diff --git a/vendor/rector/rector-nette/src/NodeFinder/FormOnSuccessCallbackFinder.php b/vendor/rector/rector-nette/src/NodeFinder/FormOnSuccessCallbackFinder.php index 5cef7bdb197..77787c5162d 100644 --- a/vendor/rector/rector-nette/src/NodeFinder/FormOnSuccessCallbackFinder.php +++ b/vendor/rector/rector-nette/src/NodeFinder/FormOnSuccessCallbackFinder.php @@ -13,7 +13,7 @@ use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\Expression; final class FormOnSuccessCallbackFinder { - public function find(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Expr\Variable $form) : ?\PhpParser\Node\Expr + public function find(Class_ $class, Variable $form) : ?Expr { foreach ($class->getMethods() as $classMethod) { $stmts = $classMethod->getStmts(); @@ -21,13 +21,13 @@ final class FormOnSuccessCallbackFinder continue; } foreach ($stmts as $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { continue; } - if (!$stmt->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$stmt->expr instanceof Assign) { continue; } - if (!$stmt->expr->var instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$stmt->expr->var instanceof ArrayDimFetch) { continue; } /** @var ArrayDimFetch $arrayDimFetch */ @@ -40,18 +40,18 @@ final class FormOnSuccessCallbackFinder } return null; } - private function isFormOnSuccess(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch, \PhpParser\Node\Expr\Variable $form) : bool + private function isFormOnSuccess(ArrayDimFetch $arrayDimFetch, Variable $form) : bool { - if (!$arrayDimFetch->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$arrayDimFetch->var instanceof PropertyFetch) { return \false; } - if (!$arrayDimFetch->var->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$arrayDimFetch->var->var instanceof Variable) { return \false; } if ($arrayDimFetch->var->var->name !== $form->name) { return \false; } - if (!$arrayDimFetch->var->name instanceof \PhpParser\Node\Identifier) { + if (!$arrayDimFetch->var->name instanceof Identifier) { return \false; } return $arrayDimFetch->var->name->name === 'onSuccess'; diff --git a/vendor/rector/rector-nette/src/NodeFinder/FormOnSuccessCallbackValuesParamFinder.php b/vendor/rector/rector-nette/src/NodeFinder/FormOnSuccessCallbackValuesParamFinder.php index 3f3fc83c176..d6916169b0b 100644 --- a/vendor/rector/rector-nette/src/NodeFinder/FormOnSuccessCallbackValuesParamFinder.php +++ b/vendor/rector/rector-nette/src/NodeFinder/FormOnSuccessCallbackValuesParamFinder.php @@ -14,25 +14,25 @@ use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassMethod; final class FormOnSuccessCallbackValuesParamFinder { - public function find(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Expr $onSuccessCallback) : ?\PhpParser\Node\Param + public function find(Class_ $class, Expr $onSuccessCallback) : ?Param { - if ($onSuccessCallback instanceof \PhpParser\Node\Expr\Closure) { + if ($onSuccessCallback instanceof Closure) { return $onSuccessCallback->params[1] ?? null; } $methodName = null; - if ($onSuccessCallback instanceof \PhpParser\Node\Expr\Array_) { + if ($onSuccessCallback instanceof Array_) { $varPart = $onSuccessCallback->items[0] ?? null; $methodNamePart = $onSuccessCallback->items[1] ?? null; - if (!$varPart instanceof \PhpParser\Node\Expr\ArrayItem || !$methodNamePart instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$varPart instanceof ArrayItem || !$methodNamePart instanceof ArrayItem) { return null; } - if (!$varPart->value instanceof \PhpParser\Node\Expr\Variable) { + if (!$varPart->value instanceof Variable) { return null; } if ($varPart->value->name !== 'this') { return null; } - if (!$methodNamePart->value instanceof \PhpParser\Node\Scalar\String_) { + if (!$methodNamePart->value instanceof String_) { return null; } $methodName = $methodNamePart->value->value; @@ -41,7 +41,7 @@ final class FormOnSuccessCallbackValuesParamFinder return null; } $classMethod = $class->getMethod($methodName); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$classMethod instanceof ClassMethod) { return null; } return $classMethod->params[1] ?? null; diff --git a/vendor/rector/rector-nette/src/NodeFinder/FormVariableFinder.php b/vendor/rector/rector-nette/src/NodeFinder/FormVariableFinder.php index e249d554a0f..8ecce6c73a8 100644 --- a/vendor/rector/rector-nette/src/NodeFinder/FormVariableFinder.php +++ b/vendor/rector/rector-nette/src/NodeFinder/FormVariableFinder.php @@ -19,11 +19,11 @@ final class FormVariableFinder * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(NodeTypeResolver $nodeTypeResolver) { $this->nodeTypeResolver = $nodeTypeResolver; } - public function find(\PhpParser\Node\Stmt\Class_ $class) : ?\PhpParser\Node\Expr\Variable + public function find(Class_ $class) : ?Variable { foreach ($class->getMethods() as $classMethod) { $classMethodStmts = $classMethod->getStmts(); @@ -31,18 +31,18 @@ final class FormVariableFinder continue; } foreach ($classMethodStmts as $classMethodStmt) { - if (!$classMethodStmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$classMethodStmt instanceof Expression) { continue; } - if (!$classMethodStmt->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$classMethodStmt->expr instanceof Assign) { continue; } $var = $classMethodStmt->expr->var; $expr = $classMethodStmt->expr->expr; - if (!$var instanceof \PhpParser\Node\Expr\Variable) { + if (!$var instanceof Variable) { continue; } - if (!$this->nodeTypeResolver->isObjectType($expr, new \PHPStan\Type\ObjectType('Nette\\Forms\\Form'))) { + if (!$this->nodeTypeResolver->isObjectType($expr, new ObjectType('Nette\\Forms\\Form'))) { continue; } return $var; diff --git a/vendor/rector/rector-nette/src/NodeFinder/ParamFinder.php b/vendor/rector/rector-nette/src/NodeFinder/ParamFinder.php index 2dbedf3cb7f..6793997b6a0 100644 --- a/vendor/rector/rector-nette/src/NodeFinder/ParamFinder.php +++ b/vendor/rector/rector-nette/src/NodeFinder/ParamFinder.php @@ -21,7 +21,7 @@ final class ParamFinder * @var \Rector\Core\PhpParser\Comparing\NodeComparator */ private $nodeComparator; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeComparator $nodeComparator) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeComparator = $nodeComparator; @@ -29,12 +29,12 @@ final class ParamFinder /** * @param \PhpParser\Node|mixed[] $nodeHaystack */ - public function isInAssign($nodeHaystack, \PhpParser\Node\Param $param) : bool + public function isInAssign($nodeHaystack, Param $param) : bool { $variable = $param->var; - return (bool) $this->betterNodeFinder->find($nodeHaystack, function (\PhpParser\Node $node) use($variable) : bool { - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\Expr\Assign) { + return (bool) $this->betterNodeFinder->find($nodeHaystack, function (Node $node) use($variable) : bool { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Assign) { return \false; } return $this->nodeComparator->areNodesEqual($node, $variable); diff --git a/vendor/rector/rector-nette/src/NodeResolver/MethodNamesByInputNamesResolver.php b/vendor/rector/rector-nette/src/NodeResolver/MethodNamesByInputNamesResolver.php index ede45c53194..3315bb133f0 100644 --- a/vendor/rector/rector-nette/src/NodeResolver/MethodNamesByInputNamesResolver.php +++ b/vendor/rector/rector-nette/src/NodeResolver/MethodNamesByInputNamesResolver.php @@ -22,7 +22,7 @@ final class MethodNamesByInputNamesResolver /** * @return array */ - public function resolveExpr(\PhpParser\Node $node) : array + public function resolveExpr(Node $node) : array { $methodNamesByInputNames = []; foreach ($this->formControlTypeResolvers as $formControlTypeResolver) { diff --git a/vendor/rector/rector-nette/src/Rector/ArrayDimFetch/AnnotateMagicalControlArrayAccessRector.php b/vendor/rector/rector-nette/src/Rector/ArrayDimFetch/AnnotateMagicalControlArrayAccessRector.php index 72cf3f587ee..9933c21098d 100644 --- a/vendor/rector/rector-nette/src/Rector/ArrayDimFetch/AnnotateMagicalControlArrayAccessRector.php +++ b/vendor/rector/rector-nette/src/Rector/ArrayDimFetch/AnnotateMagicalControlArrayAccessRector.php @@ -18,12 +18,12 @@ use Rector\Nette\NodeAnalyzer\AssignAnalyzer; use Rector\Nette\NodeAnalyzer\ControlDimFetchAnalyzer; use Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Rector\ArrayDimFetch\AnnotateMagicalControlArrayAccessRector\AnnotateMagicalControlArrayAccessRectorTest */ -final class AnnotateMagicalControlArrayAccessRector extends \Rector\Core\Rector\AbstractRector +final class AnnotateMagicalControlArrayAccessRector extends AbstractRector { /** * @readonly @@ -55,7 +55,7 @@ final class AnnotateMagicalControlArrayAccessRector extends \Rector\Core\Rector\ * @var \Rector\Nette\NodeAnalyzer\AssignAnalyzer */ private $assignAnalyzer; - public function __construct(\Rector\Nette\NodeResolver\MethodNamesByInputNamesResolver $methodNamesByInputNamesResolver, \Rector\Nette\NodeAnalyzer\ArrayDimFetchRenamer $arrayDimFetchRenamer, \Rector\Nette\NodeAnalyzer\ArrayDimFetchAnalyzer $arrayDimFetchAnalyzer, \Rector\Nette\NodeAnalyzer\ControlDimFetchAnalyzer $controlDimFetchAnalyzer, \Rector\Nette\Naming\NetteControlNaming $netteControlNaming, \Rector\Nette\NodeAnalyzer\AssignAnalyzer $assignAnalyzer) + public function __construct(MethodNamesByInputNamesResolver $methodNamesByInputNamesResolver, ArrayDimFetchRenamer $arrayDimFetchRenamer, ArrayDimFetchAnalyzer $arrayDimFetchAnalyzer, ControlDimFetchAnalyzer $controlDimFetchAnalyzer, NetteControlNaming $netteControlNaming, AssignAnalyzer $assignAnalyzer) { $this->methodNamesByInputNamesResolver = $methodNamesByInputNamesResolver; $this->arrayDimFetchRenamer = $arrayDimFetchRenamer; @@ -69,11 +69,11 @@ final class AnnotateMagicalControlArrayAccessRector extends \Rector\Core\Rector\ */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\ArrayDimFetch::class]; + return [ArrayDimFetch::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change magic $this["some_component"] to variable assign with @var annotation', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change magic $this["some_component"] to variable assign with @var annotation', [new CodeSample(<<<'CODE_SAMPLE' use Nette\Application\UI\Presenter; use Nette\Application\UI\Form; @@ -116,7 +116,7 @@ CODE_SAMPLE /** * @param ArrayDimFetch $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -131,28 +131,28 @@ CODE_SAMPLE } $variableName = $this->netteControlNaming->createVariableName($controlName); $controlObjectType = $this->resolveControlType($node, $controlName); - if (!$controlObjectType instanceof \PHPStan\Type\ObjectType) { + if (!$controlObjectType instanceof ObjectType) { return null; } $this->assignAnalyzer->addAssignExpressionForFirstCase($variableName, $node, $controlObjectType); - $classMethod = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassMethod::class); - if ($classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $this->betterNodeFinder->findParentType($node, ClassMethod::class); + if ($classMethod instanceof ClassMethod) { $this->arrayDimFetchRenamer->renameToVariable($classMethod, $node, $variableName); } - return new \PhpParser\Node\Expr\Variable($variableName); + return new Variable($variableName); } - private function shouldSkip(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch) : bool + private function shouldSkip(ArrayDimFetch $arrayDimFetch) : bool { if ($this->arrayDimFetchAnalyzer->isBeingAssignedOrInitialized($arrayDimFetch)) { return \true; } - $parent = $arrayDimFetch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node\Expr\Isset_ && !$parent instanceof \PhpParser\Node\Stmt\Unset_) { + $parent = $arrayDimFetch->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Isset_ && !$parent instanceof Unset_) { return \false; } - return !$arrayDimFetch->dim instanceof \PhpParser\Node\Expr\Variable; + return !$arrayDimFetch->dim instanceof Variable; } - private function resolveControlType(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch, string $controlName) : ?\PHPStan\Type\ObjectType + private function resolveControlType(ArrayDimFetch $arrayDimFetch, string $controlName) : ?ObjectType { $controlTypes = $this->methodNamesByInputNamesResolver->resolveExpr($arrayDimFetch); if ($controlTypes === []) { @@ -161,6 +161,6 @@ CODE_SAMPLE if (!isset($controlTypes[$controlName])) { return null; } - return new \PHPStan\Type\ObjectType($controlTypes[$controlName]); + return new ObjectType($controlTypes[$controlName]); } } diff --git a/vendor/rector/rector-nette/src/Rector/Assign/ArrayAccessGetControlToGetComponentMethodCallRector.php b/vendor/rector/rector-nette/src/Rector/Assign/ArrayAccessGetControlToGetComponentMethodCallRector.php index 6ab4cb7df5d..af33d0db9c9 100644 --- a/vendor/rector/rector-nette/src/Rector/Assign/ArrayAccessGetControlToGetComponentMethodCallRector.php +++ b/vendor/rector/rector-nette/src/Rector/Assign/ArrayAccessGetControlToGetComponentMethodCallRector.php @@ -9,18 +9,18 @@ use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\MethodCall; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/nette/component-model/blob/c1fb11729423379768a71dd865ae373a3b12fa43/src/ComponentModel/Container.php#L110 * * @see \Rector\Nette\Tests\Rector\Assign\ArrayAccessGetControlToGetComponentMethodCallRector\ArrayAccessGetControlToGetComponentMethodCallRectorTest */ -final class ArrayAccessGetControlToGetComponentMethodCallRector extends \Rector\Core\Rector\AbstractRector +final class ArrayAccessGetControlToGetComponentMethodCallRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change magic arrays access get, to explicit $this->getComponent(...) method', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change magic arrays access get, to explicit $this->getComponent(...) method', [new CodeSample(<<<'CODE_SAMPLE' use Nette\Application\UI\Presenter; class SomeClass extends Presenter @@ -49,12 +49,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Assign::class]; + return [Assign::class]; } /** * @param Assign $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isFetchOfControlFromPresenterDimFetch($node)) { return null; @@ -62,15 +62,15 @@ CODE_SAMPLE /** @var ArrayDimFetch $arrayDimFetch */ $arrayDimFetch = $node->expr; $args = $this->nodeFactory->createArgs([$arrayDimFetch->dim]); - $node->expr = new \PhpParser\Node\Expr\MethodCall($arrayDimFetch->var, 'getComponent', $args); + $node->expr = new MethodCall($arrayDimFetch->var, 'getComponent', $args); return $node; } - private function isFetchOfControlFromPresenterDimFetch(\PhpParser\Node\Expr\Assign $assign) : bool + private function isFetchOfControlFromPresenterDimFetch(Assign $assign) : bool { - if (!$assign->expr instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$assign->expr instanceof ArrayDimFetch) { return \false; } $arrayDimFetch = $assign->expr; - return $this->isObjectType($arrayDimFetch->var, new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Presenter')); + return $this->isObjectType($arrayDimFetch->var, new ObjectType('Nette\\Application\\UI\\Presenter')); } } diff --git a/vendor/rector/rector-nette/src/Rector/Assign/ArrayAccessSetControlToAddComponentMethodCallRector.php b/vendor/rector/rector-nette/src/Rector/Assign/ArrayAccessSetControlToAddComponentMethodCallRector.php index 749e0d84c28..befffea2645 100644 --- a/vendor/rector/rector-nette/src/Rector/Assign/ArrayAccessSetControlToAddComponentMethodCallRector.php +++ b/vendor/rector/rector-nette/src/Rector/Assign/ArrayAccessSetControlToAddComponentMethodCallRector.php @@ -10,18 +10,18 @@ use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\Variable; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Rector\Assign\ArrayAccessSetControlToAddComponentMethodCallRector\ArrayAccessSetControlToAddComponentMethodCallRectorTest * * @see https://github.com/nette/component-model/blob/c1fb11729423379768a71dd865ae373a3b12fa43/src/ComponentModel/Container.php#L39 */ -final class ArrayAccessSetControlToAddComponentMethodCallRector extends \Rector\Core\Rector\AbstractRector +final class ArrayAccessSetControlToAddComponentMethodCallRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change magic arrays access set, to explicit $this->setComponent(...) method', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change magic arrays access set, to explicit $this->setComponent(...) method', [new CodeSample(<<<'CODE_SAMPLE' use Nette\Application\UI\Control; use Nette\Application\UI\Presenter; @@ -54,12 +54,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Assign::class]; + return [Assign::class]; } /** * @param Assign $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isAssignOfControlToPresenterDimFetch($node)) { return null; @@ -68,20 +68,20 @@ CODE_SAMPLE $arrayDimFetch = $node->var; $arguments = [$node->expr, $arrayDimFetch->dim]; $arg = $this->nodeFactory->createArgs($arguments); - return new \PhpParser\Node\Expr\MethodCall($arrayDimFetch->var, 'addComponent', $arg); + return new MethodCall($arrayDimFetch->var, 'addComponent', $arg); } - private function isAssignOfControlToPresenterDimFetch(\PhpParser\Node\Expr\Assign $assign) : bool + private function isAssignOfControlToPresenterDimFetch(Assign $assign) : bool { - if (!$assign->var instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$assign->var instanceof ArrayDimFetch) { return \false; } - if (!$this->isObjectType($assign->expr, new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Control'))) { + if (!$this->isObjectType($assign->expr, new ObjectType('Nette\\Application\\UI\\Control'))) { return \false; } $arrayDimFetch = $assign->var; - if (!$arrayDimFetch->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$arrayDimFetch->var instanceof Variable) { return \false; } - return $this->isObjectType($arrayDimFetch->var, new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Presenter')); + return $this->isObjectType($arrayDimFetch->var, new ObjectType('Nette\\Application\\UI\\Presenter')); } } diff --git a/vendor/rector/rector-nette/src/Rector/Assign/MakeGetComponentAssignAnnotatedRector.php b/vendor/rector/rector-nette/src/Rector/Assign/MakeGetComponentAssignAnnotatedRector.php index d9b5c99d4f7..e5de81cd522 100644 --- a/vendor/rector/rector-nette/src/Rector/Assign/MakeGetComponentAssignAnnotatedRector.php +++ b/vendor/rector/rector-nette/src/Rector/Assign/MakeGetComponentAssignAnnotatedRector.php @@ -20,25 +20,25 @@ use Rector\BetterPhpDocParser\PhpDocManipulator\VarAnnotationManipulator; use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Rector\Assign\MakeGetComponentAssignAnnotatedRector\MakeGetComponentAssignAnnotatedRectorTest */ -final class MakeGetComponentAssignAnnotatedRector extends \Rector\Core\Rector\AbstractRector +final class MakeGetComponentAssignAnnotatedRector extends AbstractRector { /** * @readonly * @var \Rector\BetterPhpDocParser\PhpDocManipulator\VarAnnotationManipulator */ private $varAnnotationManipulator; - public function __construct(\Rector\BetterPhpDocParser\PhpDocManipulator\VarAnnotationManipulator $varAnnotationManipulator) + public function __construct(VarAnnotationManipulator $varAnnotationManipulator) { $this->varAnnotationManipulator = $varAnnotationManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add doc type for magic $control->getComponent(...) assign', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add doc type for magic $control->getComponent(...) assign', [new CodeSample(<<<'CODE_SAMPLE' use Nette\Application\UI\Control; final class SomeClass @@ -94,17 +94,17 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\Assign::class]; + return [Assign::class]; } /** * @param Assign $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isGetComponentMethodCallOrArrayDimFetchOnControl($node->expr)) { return null; } - if (!$node->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$node->var instanceof Variable) { return null; } $variableName = $this->getName($node->var); @@ -112,22 +112,22 @@ CODE_SAMPLE return null; } $nodeVar = $this->nodeTypeResolver->getType($node->var); - if (!$nodeVar instanceof \PHPStan\Type\MixedType) { + if (!$nodeVar instanceof MixedType) { return null; } $controlType = $this->resolveControlType($node); - if (!$controlType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$controlType instanceof TypeWithClassName) { return null; } $this->varAnnotationManipulator->decorateNodeWithInlineVarType($node, $controlType, $variableName); return $node; } - private function isGetComponentMethodCallOrArrayDimFetchOnControl(\PhpParser\Node\Expr $expr) : bool + private function isGetComponentMethodCallOrArrayDimFetchOnControl(Expr $expr) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$expr instanceof MethodCall) { return $this->isArrayDimFetchStringOnControlVariable($expr); } - if (!$this->isObjectType($expr->var, new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Control'))) { + if (!$this->isObjectType($expr->var, new ObjectType('Nette\\Application\\UI\\Control'))) { return $this->isArrayDimFetchStringOnControlVariable($expr); } if (!$this->isName($expr->name, 'getComponent')) { @@ -135,78 +135,78 @@ CODE_SAMPLE } return \true; } - private function resolveControlType(\PhpParser\Node\Expr\Assign $assign) : \PHPStan\Type\Type + private function resolveControlType(Assign $assign) : Type { - if ($assign->expr instanceof \PhpParser\Node\Expr\MethodCall) { + if ($assign->expr instanceof MethodCall) { /** @var MethodCall $methodCall */ $methodCall = $assign->expr; return $this->resolveCreateComponentMethodCallReturnType($methodCall); } - if ($assign->expr instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if ($assign->expr instanceof ArrayDimFetch) { /** @var ArrayDimFetch $arrayDimFetch */ $arrayDimFetch = $assign->expr; return $this->resolveArrayDimFetchControlType($arrayDimFetch); } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } - private function isArrayDimFetchStringOnControlVariable(\PhpParser\Node\Expr $expr) : bool + private function isArrayDimFetchStringOnControlVariable(Expr $expr) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$expr instanceof ArrayDimFetch) { return \false; } - if (!$expr->dim instanceof \PhpParser\Node\Scalar\String_) { + if (!$expr->dim instanceof String_) { return \false; } $varStaticType = $this->getType($expr->var); - if (!$varStaticType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$varStaticType instanceof TypeWithClassName) { return \false; } - $controlObjecType = new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Control'); + $controlObjecType = new ObjectType('Nette\\Application\\UI\\Control'); return $controlObjecType->isSuperTypeOf($varStaticType)->yes(); } - private function resolveCreateComponentMethodCallReturnType(\PhpParser\Node\Expr\MethodCall $methodCall) : \PHPStan\Type\Type + private function resolveCreateComponentMethodCallReturnType(MethodCall $methodCall) : Type { - $scope = $methodCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { - return new \PHPStan\Type\MixedType(); + $scope = $methodCall->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { + return new MixedType(); } if (\count($methodCall->args) !== 1) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } $firstArgumentValue = $methodCall->args[0]->value; - if (!$firstArgumentValue instanceof \PhpParser\Node\Scalar\String_) { - return new \PHPStan\Type\MixedType(); + if (!$firstArgumentValue instanceof String_) { + return new MixedType(); } return $this->resolveTypeFromShortControlNameAndVariable($firstArgumentValue, $scope, $methodCall->var); } - private function resolveArrayDimFetchControlType(\PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch) : \PHPStan\Type\Type + private function resolveArrayDimFetchControlType(ArrayDimFetch $arrayDimFetch) : Type { - $scope = $arrayDimFetch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $scope = $arrayDimFetch->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { + throw new ShouldNotHappenException(); } - if (!$arrayDimFetch->dim instanceof \PhpParser\Node\Scalar\String_) { - return new \PHPStan\Type\MixedType(); + if (!$arrayDimFetch->dim instanceof String_) { + return new MixedType(); } return $this->resolveTypeFromShortControlNameAndVariable($arrayDimFetch->dim, $scope, $arrayDimFetch->var); } - private function resolveTypeFromShortControlNameAndVariable(\PhpParser\Node\Scalar\String_ $shortControlString, \PHPStan\Analyser\Scope $scope, \PhpParser\Node\Expr $expr) : \PHPStan\Type\Type + private function resolveTypeFromShortControlNameAndVariable(String_ $shortControlString, Scope $scope, Expr $expr) : Type { $componentName = $this->valueResolver->getValue($shortControlString); if (!\is_string($componentName)) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $componentName = \ucfirst($componentName); $methodName = \sprintf('createComponent%s', $componentName); $calledOnType = $scope->getType($expr); - if (!$calledOnType instanceof \PHPStan\Type\TypeWithClassName) { - return new \PHPStan\Type\MixedType(); + if (!$calledOnType instanceof TypeWithClassName) { + return new MixedType(); } if (!$calledOnType->hasMethod($methodName)->yes()) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } // has method $methodReflection = $calledOnType->getMethod($methodName, $scope); - return \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType(); + return ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType(); } } diff --git a/vendor/rector/rector-nette/src/Rector/ClassMethod/MergeTemplateSetFileToTemplateRenderRector.php b/vendor/rector/rector-nette/src/Rector/ClassMethod/MergeTemplateSetFileToTemplateRenderRector.php index e4b31007656..6e48e8b0d5d 100644 --- a/vendor/rector/rector-nette/src/Rector/ClassMethod/MergeTemplateSetFileToTemplateRenderRector.php +++ b/vendor/rector/rector-nette/src/Rector/ClassMethod/MergeTemplateSetFileToTemplateRenderRector.php @@ -9,25 +9,25 @@ use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Stmt\ClassMethod; use Rector\Core\Rector\AbstractRector; use Rector\Nette\NodeAnalyzer\NetteClassAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Rector\ClassMethod\MergeTemplateSetFileToTemplateRenderRector\MergeTemplateSetFileToTemplateRenderRectorTest */ -final class MergeTemplateSetFileToTemplateRenderRector extends \Rector\Core\Rector\AbstractRector +final class MergeTemplateSetFileToTemplateRenderRector extends AbstractRector { /** * @readonly * @var \Rector\Nette\NodeAnalyzer\NetteClassAnalyzer */ private $netteClassAnalyzer; - public function __construct(\Rector\Nette\NodeAnalyzer\NetteClassAnalyzer $netteClassAnalyzer) + public function __construct(NetteClassAnalyzer $netteClassAnalyzer) { $this->netteClassAnalyzer = $netteClassAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change $this->template->setFile() $this->template->render()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change $this->template->setFile() $this->template->render()', [new CodeSample(<<<'CODE_SAMPLE' use Nette\Application\UI\Control; final class SomeControl extends Control @@ -57,20 +57,20 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->netteClassAnalyzer->isInComponent($node)) { return null; } /** @var MethodCall[] $methodCalls */ - $methodCalls = $this->betterNodeFinder->findInstanceOf((array) $node->stmts, \PhpParser\Node\Expr\MethodCall::class); + $methodCalls = $this->betterNodeFinder->findInstanceOf((array) $node->stmts, MethodCall::class); $setFileMethodCall = $this->resolveSingleSetFileMethodCall($methodCalls); - if (!$setFileMethodCall instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$setFileMethodCall instanceof MethodCall) { return null; } foreach ($methodCalls as $methodCall) { @@ -81,7 +81,7 @@ CODE_SAMPLE continue; } $this->removeNode($setFileMethodCall); - $methodCall->args[0] = new \PhpParser\Node\Arg($setFileMethodCall->args[0]->value); + $methodCall->args[0] = new Arg($setFileMethodCall->args[0]->value); return $node; } return null; @@ -89,14 +89,14 @@ CODE_SAMPLE /** * @param MethodCall[] $methodCalls */ - private function resolveSingleSetFileMethodCall(array $methodCalls) : ?\PhpParser\Node\Expr\MethodCall + private function resolveSingleSetFileMethodCall(array $methodCalls) : ?MethodCall { $singleSetFileMethodCall = null; foreach ($methodCalls as $methodCall) { if (!$this->isName($methodCall->name, 'setFile')) { continue; } - if ($singleSetFileMethodCall instanceof \PhpParser\Node\Expr\MethodCall) { + if ($singleSetFileMethodCall instanceof MethodCall) { return null; } $singleSetFileMethodCall = $methodCall; diff --git a/vendor/rector/rector-nette/src/Rector/ClassMethod/RemoveParentAndNameFromComponentConstructorRector.php b/vendor/rector/rector-nette/src/Rector/ClassMethod/RemoveParentAndNameFromComponentConstructorRector.php index d08201edbbd..c5f512cf9fb 100644 --- a/vendor/rector/rector-nette/src/Rector/ClassMethod/RemoveParentAndNameFromComponentConstructorRector.php +++ b/vendor/rector/rector-nette/src/Rector/ClassMethod/RemoveParentAndNameFromComponentConstructorRector.php @@ -18,15 +18,15 @@ use Rector\Core\Reflection\ReflectionResolver; use Rector\Core\ValueObject\MethodName; use Rector\Nette\NodeAnalyzer\StaticCallAnalyzer; use Rector\Nette\NodeFinder\ParamFinder; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/nette/component-model/commit/1fb769f4602cf82694941530bac1111b3c5cd11b * This only applied to child of \Nette\Application\UI\Control, not Forms! Forms still need to be attached to their parents * * @see \Rector\Nette\Tests\Rector\ClassMethod\RemoveParentAndNameFromComponentConstructorRector\RemoveParentAndNameFromComponentConstructorRectorTest */ -final class RemoveParentAndNameFromComponentConstructorRector extends \Rector\Core\Rector\AbstractRector +final class RemoveParentAndNameFromComponentConstructorRector extends AbstractRector { /** * @var string @@ -56,16 +56,16 @@ final class RemoveParentAndNameFromComponentConstructorRector extends \Rector\Co * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Nette\NodeFinder\ParamFinder $paramFinder, \Rector\Nette\NodeAnalyzer\StaticCallAnalyzer $staticCallAnalyzer, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(ParamFinder $paramFinder, StaticCallAnalyzer $staticCallAnalyzer, ReflectionResolver $reflectionResolver) { $this->paramFinder = $paramFinder; $this->staticCallAnalyzer = $staticCallAnalyzer; $this->reflectionResolver = $reflectionResolver; - $this->controlObjectType = new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Control'); + $this->controlObjectType = new ObjectType('Nette\\Application\\UI\\Control'); } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove $parent and $name in control constructor', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove $parent and $name in control constructor', [new CodeSample(<<<'CODE_SAMPLE' use Nette\Application\UI\Control; class SomeControl extends Control @@ -95,46 +95,46 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Expr\StaticCall::class, \PhpParser\Node\Expr\New_::class]; + return [ClassMethod::class, StaticCall::class, New_::class]; } /** * @param ClassMethod|StaticCall|New_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Stmt\ClassMethod) { + if ($node instanceof ClassMethod) { return $this->refactorClassMethod($node); } - if ($node instanceof \PhpParser\Node\Expr\StaticCall) { + if ($node instanceof StaticCall) { return $this->refactorStaticCall($node); } - if ($this->isObjectType($node->class, new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Control'))) { + if ($this->isObjectType($node->class, new ObjectType('Nette\\Application\\UI\\Control'))) { $this->refactorNew($node); return $node; } return null; } - private function refactorClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Stmt\ClassMethod + private function refactorClassMethod(ClassMethod $classMethod) : ?ClassMethod { if (!$this->isInsideNetteComponentClass($classMethod)) { return null; } - if (!$this->isName($classMethod, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if (!$this->isName($classMethod, MethodName::CONSTRUCT)) { return null; } $this->removeClassMethodParams($classMethod); return $classMethod; } - private function refactorStaticCall(\PhpParser\Node\Expr\StaticCall $staticCall) : ?\PhpParser\Node\Expr\StaticCall + private function refactorStaticCall(StaticCall $staticCall) : ?StaticCall { if (!$this->isInsideNetteComponentClass($staticCall)) { return null; } - if (!$this->staticCallAnalyzer->isParentCallNamed($staticCall, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if (!$this->staticCallAnalyzer->isParentCallNamed($staticCall, MethodName::CONSTRUCT)) { return null; } foreach ($staticCall->args as $staticCallArg) { - if (!$staticCallArg->value instanceof \PhpParser\Node\Expr\Variable) { + if (!$staticCallArg->value instanceof Variable) { continue; } /** @var Variable $variable */ @@ -150,14 +150,14 @@ CODE_SAMPLE } return $staticCall; } - private function refactorNew(\PhpParser\Node\Expr\New_ $new) : void + private function refactorNew(New_ $new) : void { $methodReflection = $this->reflectionResolver->resolveMethodReflectionFromNew($new); - if (!$methodReflection instanceof \PHPStan\Reflection\MethodReflection) { + if (!$methodReflection instanceof MethodReflection) { return; } $parameterNames = []; - $parametersAcceptor = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); + $parametersAcceptor = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); foreach ($parametersAcceptor->getParameters() as $parameterReflection) { /** @var ParameterReflection $parameterReflection */ $parameterNames[] = $parameterReflection->getName(); @@ -174,10 +174,10 @@ CODE_SAMPLE $this->removeNode($arg); } } - private function isInsideNetteComponentClass(\PhpParser\Node $node) : bool + private function isInsideNetteComponentClass(Node $node) : bool { $classReflection = $this->reflectionResolver->resolveClassReflection($node); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } // presenter is not a component @@ -186,13 +186,13 @@ CODE_SAMPLE } return $classReflection->isSubclassOf($this->controlObjectType->getClassName()); } - private function removeClassMethodParams(\PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function removeClassMethodParams(ClassMethod $classMethod) : void { foreach ($classMethod->params as $param) { if ($this->paramFinder->isInAssign((array) $classMethod->stmts, $param)) { continue; } - if ($this->isObjectType($param, new \PHPStan\Type\ObjectType('Nette\\ComponentModel\\IContainer'))) { + if ($this->isObjectType($param, new ObjectType('Nette\\ComponentModel\\IContainer'))) { $this->removeNode($param); continue; } @@ -201,7 +201,7 @@ CODE_SAMPLE } } } - private function shouldRemoveEmptyCall(\PhpParser\Node\Expr\StaticCall $staticCall) : bool + private function shouldRemoveEmptyCall(StaticCall $staticCall) : bool { foreach ($staticCall->args as $arg) { if ($this->nodesToRemoveCollector->isNodeRemoved($arg)) { diff --git a/vendor/rector/rector-nette/src/Rector/ClassMethod/RenderMethodParamToTypeDeclarationRector.php b/vendor/rector/rector-nette/src/Rector/ClassMethod/RenderMethodParamToTypeDeclarationRector.php index 690aa07b010..17b040a69c7 100644 --- a/vendor/rector/rector-nette/src/Rector/ClassMethod/RenderMethodParamToTypeDeclarationRector.php +++ b/vendor/rector/rector-nette/src/Rector/ClassMethod/RenderMethodParamToTypeDeclarationRector.php @@ -12,12 +12,12 @@ use Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\TypeDeclaration\NodeAnalyzer\ControllerRenderMethodAnalyzer; use Rector\TypeDeclaration\TypeInferer\ParamTypeInferer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Rector\ClassMethod\RenderMethodParamToTypeDeclarationRector\RenderMethodParamToTypeDeclarationRectorTest */ -final class RenderMethodParamToTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector +final class RenderMethodParamToTypeDeclarationRector extends AbstractRector { /** * @var bool @@ -38,15 +38,15 @@ final class RenderMethodParamToTypeDeclarationRector extends \Rector\Core\Rector * @var \Rector\TypeDeclaration\NodeAnalyzer\ControllerRenderMethodAnalyzer */ private $controllerRenderMethodAnalyzer; - public function __construct(\Rector\TypeDeclaration\TypeInferer\ParamTypeInferer $paramTypeInferer, \Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover $paramTagRemover, \Rector\TypeDeclaration\NodeAnalyzer\ControllerRenderMethodAnalyzer $controllerRenderMethodAnalyzer) + public function __construct(ParamTypeInferer $paramTypeInferer, ParamTagRemover $paramTagRemover, ControllerRenderMethodAnalyzer $controllerRenderMethodAnalyzer) { $this->paramTypeInferer = $paramTypeInferer; $this->paramTagRemover = $paramTagRemover; $this->controllerRenderMethodAnalyzer = $controllerRenderMethodAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Move @param declarations on render() method in Nette components and presenter to strict type declarations', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Move @param declarations on render() method in Nette components and presenter to strict type declarations', [new CodeSample(<<<'CODE_SAMPLE' use Nette\Application\UI\Control; final class SomeControl extends Control @@ -76,15 +76,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); - if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$phpDocInfo instanceof PhpDocInfo) { return null; } if (!$this->controllerRenderMethodAnalyzer->isRenderMethod($node)) { @@ -99,14 +99,14 @@ CODE_SAMPLE } return null; } - private function refactorParam(\PhpParser\Node\Param $param, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function refactorParam(Param $param, PhpDocInfo $phpDocInfo, ClassMethod $classMethod) : void { if ($param->type !== null) { return; } $inferedType = $this->paramTypeInferer->inferParam($param); - $paramType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($inferedType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM); - if (!$paramType instanceof \PhpParser\Node) { + $paramType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($inferedType, TypeKind::PARAM); + if (!$paramType instanceof Node) { return; } $param->type = $paramType; diff --git a/vendor/rector/rector-nette/src/Rector/ClassMethod/TemplateMagicAssignToExplicitVariableArrayRector.php b/vendor/rector/rector-nette/src/Rector/ClassMethod/TemplateMagicAssignToExplicitVariableArrayRector.php index 8ac80bd7e8c..7803050a3f9 100644 --- a/vendor/rector/rector-nette/src/Rector/ClassMethod/TemplateMagicAssignToExplicitVariableArrayRector.php +++ b/vendor/rector/rector-nette/src/Rector/ClassMethod/TemplateMagicAssignToExplicitVariableArrayRector.php @@ -20,12 +20,12 @@ use Rector\Nette\NodeAnalyzer\TemplatePropertyAssignCollector; use Rector\Nette\NodeAnalyzer\TemplatePropertyParametersReplacer; use Rector\Nette\NodeFactory\RenderParameterArrayFactory; use Rector\Nette\ValueObject\TemplateParametersAssigns; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Rector\ClassMethod\TemplateMagicAssignToExplicitVariableArrayRector\TemplateMagicAssignToExplicitVariableArrayRectorTest */ -final class TemplateMagicAssignToExplicitVariableArrayRector extends \Rector\Core\Rector\AbstractRector +final class TemplateMagicAssignToExplicitVariableArrayRector extends AbstractRector { /** * @readonly @@ -62,7 +62,7 @@ final class TemplateMagicAssignToExplicitVariableArrayRector extends \Rector\Cor * @var \Rector\Nette\NodeAnalyzer\MethodCallArgMerger */ private $methodCallArgMerger; - public function __construct(\Rector\Nette\NodeAnalyzer\TemplatePropertyAssignCollector $templatePropertyAssignCollector, \Rector\Nette\NodeAnalyzer\RenderMethodAnalyzer $renderMethodAnalyzer, \Rector\Nette\NodeAnalyzer\NetteClassAnalyzer $netteClassAnalyzer, \Rector\Nette\NodeFactory\RenderParameterArrayFactory $renderParameterArrayFactory, \Rector\Nette\NodeAnalyzer\ConditionalTemplateAssignReplacer $conditionalTemplateAssignReplacer, \Rector\Nette\NodeAnalyzer\TemplatePropertyParametersReplacer $templatePropertyParametersReplacer, \Rector\Nette\NodeAnalyzer\MethodCallArgMerger $methodCallArgMerger) + public function __construct(TemplatePropertyAssignCollector $templatePropertyAssignCollector, RenderMethodAnalyzer $renderMethodAnalyzer, NetteClassAnalyzer $netteClassAnalyzer, RenderParameterArrayFactory $renderParameterArrayFactory, ConditionalTemplateAssignReplacer $conditionalTemplateAssignReplacer, TemplatePropertyParametersReplacer $templatePropertyParametersReplacer, MethodCallArgMerger $methodCallArgMerger) { $this->templatePropertyAssignCollector = $templatePropertyAssignCollector; $this->renderMethodAnalyzer = $renderMethodAnalyzer; @@ -72,9 +72,9 @@ final class TemplateMagicAssignToExplicitVariableArrayRector extends \Rector\Cor $this->templatePropertyParametersReplacer = $templatePropertyParametersReplacer; $this->methodCallArgMerger = $methodCallArgMerger; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change `$this->templates->{magic}` to `$this->template->render(..., $values)` in components', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change `$this->templates->{magic}` to `$this->template->render(..., $values)` in components', [new CodeSample(<<<'CODE_SAMPLE' use Nette\Application\UI\Control; class SomeControl extends Control @@ -104,12 +104,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -127,7 +127,7 @@ CODE_SAMPLE } return $this->refactorForSingleRenderMethodCall($node, $renderMethodCalls[0]); } - private function shouldSkip(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkip(ClassMethod $classMethod) : bool { return !$this->netteClassAnalyzer->isInComponent($classMethod); } @@ -143,15 +143,15 @@ CODE_SAMPLE } return \true; } - private function refactorForSingleRenderMethodCall(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Expr\MethodCall $renderMethodCall) : ?\PhpParser\Node\Stmt\ClassMethod + private function refactorForSingleRenderMethodCall(ClassMethod $classMethod, MethodCall $renderMethodCall) : ?ClassMethod { $templateParametersAssigns = $this->templatePropertyAssignCollector->collect($classMethod); $array = $this->renderParameterArrayFactory->createArray($templateParametersAssigns); - if (!$array instanceof \PhpParser\Node\Expr\Array_) { + if (!$array instanceof Array_) { return null; } - $this->traverseNodesWithCallable($classMethod, function (\PhpParser\Node $node) use($templateParametersAssigns) { - if (!$node instanceof \PhpParser\Node\Expr\Assign) { + $this->traverseNodesWithCallable($classMethod, function (Node $node) use($templateParametersAssigns) { + if (!$node instanceof Assign) { return null; } foreach ($templateParametersAssigns->getTemplateParameterAssigns() as $alwaysTemplateParameterAssign) { @@ -170,32 +170,32 @@ CODE_SAMPLE /** * @param MethodCall[] $renderMethodCalls */ - private function refactorForMultipleRenderMethodCalls(\PhpParser\Node\Stmt\ClassMethod $classMethod, array $renderMethodCalls) : ?\PhpParser\Node\Stmt\ClassMethod + private function refactorForMultipleRenderMethodCalls(ClassMethod $classMethod, array $renderMethodCalls) : ?ClassMethod { $magicTemplateParametersAssigns = $this->templatePropertyAssignCollector->collect($classMethod); if ($magicTemplateParametersAssigns->getTemplateParameterAssigns() === []) { return null; } - $parametersVariable = new \PhpParser\Node\Expr\Variable('parameters'); - $parametersAssign = new \PhpParser\Node\Expr\Assign($parametersVariable, new \PhpParser\Node\Expr\Array_()); - $assignExpression = new \PhpParser\Node\Stmt\Expression($parametersAssign); + $parametersVariable = new Variable('parameters'); + $parametersAssign = new Assign($parametersVariable, new Array_()); + $assignExpression = new Expression($parametersAssign); $classMethod->stmts = \array_merge([$assignExpression], (array) $classMethod->stmts); $this->templatePropertyParametersReplacer->replace($magicTemplateParametersAssigns, $parametersVariable); foreach ($renderMethodCalls as $renderMethodCall) { - $renderMethodCall->args[1] = new \PhpParser\Node\Arg($parametersVariable); + $renderMethodCall->args[1] = new Arg($parametersVariable); } return $classMethod; } /** * @return null|\PhpParser\Node\Expr\Assign */ - private function replaceThisTemplateAssignWithVariable(\Rector\Nette\ValueObject\TemplateParametersAssigns $templateParametersAssigns, \PhpParser\Node\Expr\Assign $assign) + private function replaceThisTemplateAssignWithVariable(TemplateParametersAssigns $templateParametersAssigns, Assign $assign) { foreach ($templateParametersAssigns->getDefaultChangeableTemplateParameterAssigns() as $alwaysTemplateParameterAssign) { if (!$this->nodeComparator->areNodesEqual($assign->var, $alwaysTemplateParameterAssign->getAssignVar())) { continue; } - $assign->var = new \PhpParser\Node\Expr\Variable($alwaysTemplateParameterAssign->getParameterName()); + $assign->var = new Variable($alwaysTemplateParameterAssign->getParameterName()); return $assign; } return null; diff --git a/vendor/rector/rector-nette/src/Rector/ClassMethod/TranslateClassMethodToVariadicsRector.php b/vendor/rector/rector-nette/src/Rector/ClassMethod/TranslateClassMethodToVariadicsRector.php index 58d6c88f488..b1ca1cc96ee 100644 --- a/vendor/rector/rector-nette/src/Rector/ClassMethod/TranslateClassMethodToVariadicsRector.php +++ b/vendor/rector/rector-nette/src/Rector/ClassMethod/TranslateClassMethodToVariadicsRector.php @@ -17,8 +17,8 @@ use PHPStan\Reflection\ClassReflection; use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/nette/utils/pull/178 * @changelog https://github.com/contributte/translation/commit/d374c4c05b57dff1e5b327bb9bf98c392769806c @@ -27,7 +27,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @note must be run before "composer update nette/utils:^3.0", because param contract break causes fatal error */ -final class TranslateClassMethodToVariadicsRector extends \Rector\Core\Rector\AbstractRector +final class TranslateClassMethodToVariadicsRector extends AbstractRector { /** * @var string @@ -38,13 +38,13 @@ final class TranslateClassMethodToVariadicsRector extends \Rector\Core\Rector\Ab * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(ReflectionResolver $reflectionResolver) { $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change translate() method call 2nd arg to variadic', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change translate() method call 2nd arg to variadic', [new CodeSample(<<<'CODE_SAMPLE' use Nette\Localization\ITranslator; final class SomeClass implements ITranslator @@ -74,15 +74,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $classReflection = $this->reflectionResolver->resolveClassReflection($node); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return null; } if (!$classReflection->isSubclassOf('Nette\\Localization\\ITranslator')) { @@ -95,7 +95,7 @@ CODE_SAMPLE return null; } $secondParam = $node->params[1]; - if (!$secondParam->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$secondParam->var instanceof Variable) { return null; } if ($secondParam->variadic) { @@ -104,20 +104,20 @@ CODE_SAMPLE $this->replaceSecondParamInClassMethodBody($node, $secondParam); $secondParam->default = null; $secondParam->variadic = \true; - if ($secondParam->var instanceof \PhpParser\Node\Expr\Error) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if ($secondParam->var instanceof Error) { + throw new ShouldNotHappenException(); } $secondParam->var->name = self::PARAMETERS; return $node; } - private function replaceSecondParamInClassMethodBody(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Param $param) : void + private function replaceSecondParamInClassMethodBody(ClassMethod $classMethod, Param $param) : void { $paramName = $this->getName($param->var); if ($paramName === null) { return; } - $this->traverseNodesWithCallable((array) $classMethod->stmts, function (\PhpParser\Node $node) use($paramName) : ?int { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + $this->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) use($paramName) : ?int { + if (!$node instanceof Variable) { return null; } if (!$this->isName($node, $paramName)) { @@ -126,13 +126,13 @@ CODE_SAMPLE // instantiate $assign = $this->createCoalesceAssign($node); $this->nodesToAddCollector->addNodeBeforeNode($assign, $node); - return \PhpParser\NodeTraverser::STOP_TRAVERSAL; + return NodeTraverser::STOP_TRAVERSAL; }); } - private function createCoalesceAssign(\PhpParser\Node\Expr\Variable $variable) : \PhpParser\Node\Expr\Assign + private function createCoalesceAssign(Variable $variable) : Assign { - $arrayDimFetch = new \PhpParser\Node\Expr\ArrayDimFetch(new \PhpParser\Node\Expr\Variable(self::PARAMETERS), new \PhpParser\Node\Scalar\LNumber(0)); - $coalesce = new \PhpParser\Node\Expr\BinaryOp\Coalesce($arrayDimFetch, $this->nodeFactory->createNull()); - return new \PhpParser\Node\Expr\Assign(new \PhpParser\Node\Expr\Variable($variable->name), $coalesce); + $arrayDimFetch = new ArrayDimFetch(new Variable(self::PARAMETERS), new LNumber(0)); + $coalesce = new Coalesce($arrayDimFetch, $this->nodeFactory->createNull()); + return new Assign(new Variable($variable->name), $coalesce); } } diff --git a/vendor/rector/rector-nette/src/Rector/Class_/FormDataRector.php b/vendor/rector/rector-nette/src/Rector/Class_/FormDataRector.php index 63791af1bd8..b561e995596 100644 --- a/vendor/rector/rector-nette/src/Rector/Class_/FormDataRector.php +++ b/vendor/rector/rector-nette/src/Rector/Class_/FormDataRector.php @@ -19,14 +19,14 @@ use Rector\Nette\NodeFinder\FormFieldsFinder; use Rector\Nette\NodeFinder\FormOnSuccessCallbackFinder; use Rector\Nette\NodeFinder\FormOnSuccessCallbackValuesParamFinder; use Rector\Nette\NodeFinder\FormVariableFinder; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see https://doc.nette.org/en/3.1/form-presenter#toc-mapping-to-classes * @see \Rector\Nette\Tests\Rector\Class_\FormDataRector\FormDataRectorTest */ -final class FormDataRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class FormDataRector extends AbstractRector implements ConfigurableRectorInterface { public const FORM_DATA_CLASS_PARENT = 'form_data_class_parent'; public const FORM_DATA_CLASS_TRAITS = 'form_data_class_traits'; @@ -73,7 +73,7 @@ final class FormDataRector extends \Rector\Core\Rector\AbstractRector implements * @var \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector */ private $removedAndAddedFilesCollector; - public function __construct(\Rector\Nette\NodeFinder\FormVariableFinder $formVariableFinder, \Rector\Nette\NodeFinder\FormFieldsFinder $formFieldsFinder, \Rector\Nette\NodeFinder\FormOnSuccessCallbackFinder $formOnSuccessCallbackFinder, \Rector\Nette\NodeFinder\FormOnSuccessCallbackValuesParamFinder $formOnSuccessCallbackValuesParamFinder, \Rector\Nette\NodeFactory\ClassWithPublicPropertiesFactory $classWithPublicPropertiesFactory, \Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector) + public function __construct(FormVariableFinder $formVariableFinder, FormFieldsFinder $formFieldsFinder, FormOnSuccessCallbackFinder $formOnSuccessCallbackFinder, FormOnSuccessCallbackValuesParamFinder $formOnSuccessCallbackValuesParamFinder, ClassWithPublicPropertiesFactory $classWithPublicPropertiesFactory, NodePrinterInterface $nodePrinter, RemovedAndAddedFilesCollector $removedAndAddedFilesCollector) { $this->formVariableFinder = $formVariableFinder; $this->formFieldsFinder = $formFieldsFinder; @@ -83,9 +83,9 @@ final class FormDataRector extends \Rector\Core\Rector\AbstractRector implements $this->nodePrinter = $nodePrinter; $this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Create form data class with all fields of Form', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Create form data class with all fields of Form', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class MyFormFactory { public function create() @@ -125,7 +125,7 @@ CODE_SAMPLE } public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param mixed[] $configuration @@ -134,20 +134,20 @@ CODE_SAMPLE { if (isset($configuration[self::FORM_DATA_CLASS_PARENT])) { $formDataClassParent = $configuration[self::FORM_DATA_CLASS_PARENT]; - \RectorPrefix20220607\Webmozart\Assert\Assert::string($formDataClassParent); + Assert::string($formDataClassParent); $this->formDataClassParent = $formDataClassParent; } if (isset($configuration[self::FORM_DATA_CLASS_TRAITS])) { $formDataClassTraits = $configuration[self::FORM_DATA_CLASS_TRAITS]; - \RectorPrefix20220607\Webmozart\Assert\Assert::isArray($formDataClassTraits); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($formDataClassTraits); + Assert::isArray($formDataClassTraits); + Assert::allString($formDataClassTraits); $this->formDataClassTraits = $formDataClassTraits; } } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->name === null) { return null; @@ -155,7 +155,7 @@ CODE_SAMPLE $shortClassName = $this->nodeNameResolver->getShortName($node); $fullClassName = $this->getName($node); $form = $this->formVariableFinder->find($node); - if (!$form instanceof \PhpParser\Node\Expr\Variable) { + if (!$form instanceof Variable) { return null; } $formFields = $this->formFieldsFinder->find($node, $form); @@ -172,17 +172,17 @@ CODE_SAMPLE $printedClassContent = "nodePrinter->print($formDataClass) . "\n"; $smartFileInfo = $this->file->getSmartFileInfo(); $targetFilePath = $smartFileInfo->getRealPathDirectory() . '/' . $formDataClassName . '.php'; - $addedFileWithContent = new \Rector\FileSystemRector\ValueObject\AddedFileWithContent($targetFilePath, $printedClassContent); + $addedFileWithContent = new AddedFileWithContent($targetFilePath, $printedClassContent); $this->removedAndAddedFilesCollector->addAddedFile($addedFileWithContent); $onSuccessCallback = $this->formOnSuccessCallbackFinder->find($node, $form); - if (!$onSuccessCallback instanceof \PhpParser\Node\Expr) { + if (!$onSuccessCallback instanceof Expr) { return null; } $valuesParam = $this->formOnSuccessCallbackValuesParamFinder->find($node, $onSuccessCallback); - if (!$valuesParam instanceof \PhpParser\Node\Param) { + if (!$valuesParam instanceof Param) { return null; } - $valuesParam->type = new \PhpParser\Node\Identifier($fullFormDataClassName); + $valuesParam->type = new Identifier($fullFormDataClassName); return $node; } } diff --git a/vendor/rector/rector-nette/src/Rector/Class_/LatteVarTypesBasedOnPresenterTemplateParametersRector.php b/vendor/rector/rector-nette/src/Rector/Class_/LatteVarTypesBasedOnPresenterTemplateParametersRector.php index 70202a746ed..c830f741c9c 100644 --- a/vendor/rector/rector-nette/src/Rector/Class_/LatteVarTypesBasedOnPresenterTemplateParametersRector.php +++ b/vendor/rector/rector-nette/src/Rector/Class_/LatteVarTypesBasedOnPresenterTemplateParametersRector.php @@ -15,25 +15,25 @@ use Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector; use Rector\Core\Rector\AbstractRector; use Rector\FileSystemRector\ValueObject\AddedFileWithContent; use Rector\Nette\ValueObject\LatteVariableType; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Rector\Class_\LatteVarTypesBasedOnPresenterTemplateParametersRector\LatteVarTypesBasedOnPresenterTemplateParametersRectorTest */ -final class LatteVarTypesBasedOnPresenterTemplateParametersRector extends \Rector\Core\Rector\AbstractRector +final class LatteVarTypesBasedOnPresenterTemplateParametersRector extends AbstractRector { /** * @readonly * @var \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector */ private $removedAndAddedFilesCollector; - public function __construct(\Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector) + public function __construct(RemovedAndAddedFilesCollector $removedAndAddedFilesCollector) { $this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Adds latte {varType}s based on presenter $this->template parameters', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Adds latte {varType}s based on presenter $this->template parameters', [new CodeSample(<<<'CODE_SAMPLE' // presenters/SomePresenter.php nodeTypeResolver->isObjectType($node, new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Presenter'))) { + if (!$this->nodeTypeResolver->isObjectType($node, new ObjectType('Nette\\Application\\UI\\Presenter'))) { return null; } if ($node->name === null) { @@ -112,7 +112,7 @@ CODE_SAMPLE /** * @return LatteVariableType[] */ - private function findVarTypesForAction(\PhpParser\Node\Stmt\ClassMethod $method) : array + private function findVarTypesForAction(ClassMethod $method) : array { $varTypes = []; $stmts = $method->getStmts(); @@ -120,13 +120,13 @@ CODE_SAMPLE return []; } foreach ($stmts as $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { continue; } - if (!$stmt->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$stmt->expr instanceof Assign) { continue; } - if (!$stmt->expr->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$stmt->expr->var instanceof PropertyFetch) { continue; } /** @var PropertyFetch $propertyFetch */ @@ -135,7 +135,7 @@ CODE_SAMPLE continue; } $staticType = $this->getType($stmt->expr->expr); - $varTypes[] = new \Rector\Nette\ValueObject\LatteVariableType((string) $this->getName($propertyFetch->name), $staticType->describe(\PHPStan\Type\VerbosityLevel::typeOnly())); + $varTypes[] = new LatteVariableType((string) $this->getName($propertyFetch->name), $staticType->describe(VerbosityLevel::typeOnly())); } return $varTypes; } @@ -158,7 +158,7 @@ CODE_SAMPLE $varTypeContentParts[] = '{varType ' . $varType->getType() . ' $' . $varType->getName() . '}'; } $content = \implode("\n", $varTypeContentParts) . "\n\n" . $content; - $addedFileWithContent = new \Rector\FileSystemRector\ValueObject\AddedFileWithContent($templateFilePath, $content); + $addedFileWithContent = new AddedFileWithContent($templateFilePath, $content); $this->removedAndAddedFilesCollector->addAddedFile($addedFileWithContent); } } diff --git a/vendor/rector/rector-nette/src/Rector/Class_/MoveFinalGetUserToCheckRequirementsClassMethodRector.php b/vendor/rector/rector-nette/src/Rector/Class_/MoveFinalGetUserToCheckRequirementsClassMethodRector.php index ee49b50fbc6..4a1d5e07dd0 100644 --- a/vendor/rector/rector-nette/src/Rector/Class_/MoveFinalGetUserToCheckRequirementsClassMethodRector.php +++ b/vendor/rector/rector-nette/src/Rector/Class_/MoveFinalGetUserToCheckRequirementsClassMethodRector.php @@ -11,12 +11,12 @@ use Rector\Core\Exception\NotImplementedYetException; use Rector\Core\NodeManipulator\ClassInsertManipulator; use Rector\Core\Rector\AbstractRector; use Rector\Nette\NodeFactory\CheckRequirementsClassMethodFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/nette/application/commit/a70c7256b645a2bee0b0c2c735020d7043a14558#diff-549e1fc650c1fc7e138900598027656a50d12b031605f8a63a38bd69a3985fafR1324 */ -final class MoveFinalGetUserToCheckRequirementsClassMethodRector extends \Rector\Core\Rector\AbstractRector +final class MoveFinalGetUserToCheckRequirementsClassMethodRector extends AbstractRector { /** * @readonly @@ -28,14 +28,14 @@ final class MoveFinalGetUserToCheckRequirementsClassMethodRector extends \Rector * @var \Rector\Core\NodeManipulator\ClassInsertManipulator */ private $classInsertManipulator; - public function __construct(\Rector\Nette\NodeFactory\CheckRequirementsClassMethodFactory $checkRequirementsClassMethodFactory, \Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator) + public function __construct(CheckRequirementsClassMethodFactory $checkRequirementsClassMethodFactory, ClassInsertManipulator $classInsertManipulator) { $this->checkRequirementsClassMethodFactory = $checkRequirementsClassMethodFactory; $this->classInsertManipulator = $classInsertManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Presenter method getUser() is now final, move logic to checkRequirements()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Presenter method getUser() is now final, move logic to checkRequirements()', [new CodeSample(<<<'CODE_SAMPLE' use Nette\Application\UI\Presenter; class SomeControl extends Presenter @@ -69,26 +69,26 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node, new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Presenter'))) { + if (!$this->isObjectType($node, new ObjectType('Nette\\Application\\UI\\Presenter'))) { return null; } $getUserClassMethod = $node->getMethod('getUser'); - if (!$getUserClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$getUserClassMethod instanceof ClassMethod) { return null; } $checkRequirementsClassMethod = $node->getMethod('checkRequirements'); - if (!$checkRequirementsClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$checkRequirementsClassMethod instanceof ClassMethod) { $checkRequirementsClassMethod = $this->checkRequirementsClassMethodFactory->create((array) $getUserClassMethod->stmts); $this->classInsertManipulator->addAsFirstMethod($node, $checkRequirementsClassMethod); } else { - throw new \Rector\Core\Exception\NotImplementedYetException(); + throw new NotImplementedYetException(); } $this->removeNode($getUserClassMethod); return $node; diff --git a/vendor/rector/rector-nette/src/Rector/Class_/MoveInjectToExistingConstructorRector.php b/vendor/rector/rector-nette/src/Rector/Class_/MoveInjectToExistingConstructorRector.php index e9f410c4ffa..e64c80a6b6e 100644 --- a/vendor/rector/rector-nette/src/Rector/Class_/MoveInjectToExistingConstructorRector.php +++ b/vendor/rector/rector-nette/src/Rector/Class_/MoveInjectToExistingConstructorRector.php @@ -16,12 +16,12 @@ use Rector\Nette\NodeAnalyzer\PropertyUsageAnalyzer; use Rector\PostRector\Collector\PropertyToAddCollector; use Rector\PostRector\ValueObject\PropertyMetadata; use Rector\Privatization\NodeManipulator\VisibilityManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Rector\Class_\MoveInjectToExistingConstructorRector\MoveInjectToExistingConstructorRectorTest */ -final class MoveInjectToExistingConstructorRector extends \Rector\Core\Rector\AbstractRector +final class MoveInjectToExistingConstructorRector extends AbstractRector { /** * @readonly @@ -48,7 +48,7 @@ final class MoveInjectToExistingConstructorRector extends \Rector\Core\Rector\Ab * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Nette\NodeAnalyzer\PropertyUsageAnalyzer $propertyUsageAnalyzer, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover $phpDocTagRemover, \Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector, \Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PropertyUsageAnalyzer $propertyUsageAnalyzer, PhpDocTagRemover $phpDocTagRemover, PropertyToAddCollector $propertyToAddCollector, VisibilityManipulator $visibilityManipulator, PhpVersionProvider $phpVersionProvider) { $this->propertyUsageAnalyzer = $propertyUsageAnalyzer; $this->phpDocTagRemover = $phpDocTagRemover; @@ -56,9 +56,9 @@ final class MoveInjectToExistingConstructorRector extends \Rector\Core\Rector\Ab $this->visibilityManipulator = $visibilityManipulator; $this->phpVersionProvider = $phpVersionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Move @inject properties to constructor, if there already is one', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Move @inject properties to constructor, if there already is one', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { /** @@ -105,19 +105,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $injectProperties = $this->getInjectProperties($node); if ($injectProperties === []) { return null; } - $constructClassMethod = $node->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$constructClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $constructClassMethod = $node->getMethod(MethodName::CONSTRUCT); + if (!$constructClassMethod instanceof ClassMethod) { return null; } foreach ($injectProperties as $injectProperty) { @@ -125,9 +125,9 @@ CODE_SAMPLE $this->changePropertyVisibility($injectProperty); $propertyName = $this->nodeNameResolver->getName($injectProperty); $propertyType = $this->nodeTypeResolver->getType($injectProperty); - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($propertyName, $propertyType, $injectProperty->flags); + $propertyMetadata = new PropertyMetadata($propertyName, $propertyType, $injectProperty->flags); $this->propertyToAddCollector->addPropertyToClass($node, $propertyMetadata); - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::PROPERTY_PROMOTION)) { + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::PROPERTY_PROMOTION)) { $this->removeNode($injectProperty); } } @@ -136,13 +136,13 @@ CODE_SAMPLE /** * @return Property[] */ - private function getInjectProperties(\PhpParser\Node\Stmt\Class_ $class) : array + private function getInjectProperties(Class_ $class) : array { - return \array_filter($class->getProperties(), function (\PhpParser\Node\Stmt\Property $property) : bool { + return \array_filter($class->getProperties(), function (Property $property) : bool { return $this->isInjectProperty($property); }); } - private function removeInjectAnnotation(\PhpParser\Node\Stmt\Property $property) : void + private function removeInjectAnnotation(Property $property) : void { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); $injectTagValueNode = $phpDocInfo->getByName('inject'); @@ -150,7 +150,7 @@ CODE_SAMPLE $this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $injectTagValueNode); } } - private function changePropertyVisibility(\PhpParser\Node\Stmt\Property $injectProperty) : void + private function changePropertyVisibility(Property $injectProperty) : void { if ($this->propertyUsageAnalyzer->isPropertyFetchedInChildClass($injectProperty)) { $this->visibilityManipulator->makeProtected($injectProperty); @@ -158,7 +158,7 @@ CODE_SAMPLE $this->visibilityManipulator->makePrivate($injectProperty); } } - private function isInjectProperty(\PhpParser\Node\Stmt\Property $property) : bool + private function isInjectProperty(Property $property) : bool { if (!$property->isPublic()) { return \false; diff --git a/vendor/rector/rector-nette/src/Rector/Class_/TemplateTypeBasedOnPresenterTemplateParametersRector.php b/vendor/rector/rector-nette/src/Rector/Class_/TemplateTypeBasedOnPresenterTemplateParametersRector.php index 27eb671c5b2..7be6cf65a55 100644 --- a/vendor/rector/rector-nette/src/Rector/Class_/TemplateTypeBasedOnPresenterTemplateParametersRector.php +++ b/vendor/rector/rector-nette/src/Rector/Class_/TemplateTypeBasedOnPresenterTemplateParametersRector.php @@ -19,13 +19,13 @@ use Rector\Core\Rector\AbstractRector; use Rector\FileSystemRector\ValueObject\AddedFileWithContent; use Rector\Nette\NodeFactory\ClassWithPublicPropertiesFactory; use Rector\Nette\ValueObject\LatteVariableType; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Nette\Tests\Rector\Class_\TemplateTypeBasedOnPresenterTemplateParametersRector\TemplateTypeBasedOnPresenterTemplateParametersRectorTest */ -final class TemplateTypeBasedOnPresenterTemplateParametersRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class TemplateTypeBasedOnPresenterTemplateParametersRector extends AbstractRector implements ConfigurableRectorInterface { public const TEMPLATE_CLASS_PARENT = 'template_class_parent'; public const TEMPLATE_CLASS_TRAITS = 'template_class_traits'; @@ -52,15 +52,15 @@ final class TemplateTypeBasedOnPresenterTemplateParametersRector extends \Rector * @var \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector */ private $removedAndAddedFilesCollector; - public function __construct(\Rector\Nette\NodeFactory\ClassWithPublicPropertiesFactory $classWithPublicPropertiesFactory, \Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector) + public function __construct(ClassWithPublicPropertiesFactory $classWithPublicPropertiesFactory, NodePrinterInterface $nodePrinter, RemovedAndAddedFilesCollector $removedAndAddedFilesCollector) { $this->classWithPublicPropertiesFactory = $classWithPublicPropertiesFactory; $this->nodePrinter = $nodePrinter; $this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Creates Template class and adds latte {templateType} based on presenter $this->template parameters', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Creates Template class and adds latte {templateType} based on presenter $this->template parameters', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' // presenters/SomePresenter.php templateClassParent = $templateClassParent; } if (isset($configuration[self::TEMPLATE_CLASS_TRAITS])) { $templateClassTraits = $configuration[self::TEMPLATE_CLASS_TRAITS]; - \RectorPrefix20220607\Webmozart\Assert\Assert::isArray($templateClassTraits); + Assert::isArray($templateClassTraits); $this->templateClassTraits = $templateClassTraits; } } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { - if (!$this->nodeTypeResolver->isObjectType($node, new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Presenter'))) { + if (!$this->nodeTypeResolver->isObjectType($node, new ObjectType('Nette\\Application\\UI\\Presenter'))) { return null; } if ($node->name === null) { @@ -169,7 +169,7 @@ CODE_SAMPLE /** * @return LatteVariableType[] */ - private function findVarTypesForAction(\PhpParser\Node\Stmt\ClassMethod $method) : array + private function findVarTypesForAction(ClassMethod $method) : array { $varTypes = []; $stmts = $method->getStmts(); @@ -177,13 +177,13 @@ CODE_SAMPLE return []; } foreach ($stmts as $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { continue; } - if (!$stmt->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$stmt->expr instanceof Assign) { continue; } - if (!$stmt->expr->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$stmt->expr->var instanceof PropertyFetch) { continue; } /** @var PropertyFetch $propertyFetch */ @@ -192,7 +192,7 @@ CODE_SAMPLE continue; } $staticType = $this->getType($stmt->expr->expr); - $varTypes[] = new \Rector\Nette\ValueObject\LatteVariableType((string) $this->getName($propertyFetch->name), $staticType->describe(\PHPStan\Type\VerbosityLevel::typeOnly())); + $varTypes[] = new LatteVariableType((string) $this->getName($propertyFetch->name), $staticType->describe(VerbosityLevel::typeOnly())); } return $varTypes; } @@ -212,7 +212,7 @@ CODE_SAMPLE $templateClassName = $this->createTemplateClass($presenterName, $fullPresenterName, $actionName, $varTypes); $content = \file_get_contents($templateFilePath); $content = '{templateType ' . \ltrim($templateClassName, '\\') . "}\n\n" . $content; - $addedFileWithContent = new \Rector\FileSystemRector\ValueObject\AddedFileWithContent($templateFilePath, $content); + $addedFileWithContent = new AddedFileWithContent($templateFilePath, $content); $this->removedAndAddedFilesCollector->addAddedFile($addedFileWithContent); } } @@ -228,12 +228,12 @@ CODE_SAMPLE $upperCasedActionName = \ucfirst($actionName); $templateClassName = $presenterName . $upperCasedActionName . 'Template'; $presenterPattern = '#Presenter$#'; - $fullTemplateClassName = '\\' . \RectorPrefix20220607\Nette\Utils\Strings::replace($fullPresenterName, $presenterPattern, $upperCasedActionName . 'Template'); + $fullTemplateClassName = '\\' . Strings::replace($fullPresenterName, $presenterPattern, $upperCasedActionName . 'Template'); $templateClass = $this->classWithPublicPropertiesFactory->createNode($fullTemplateClassName, $properties, $this->templateClassParent, $this->templateClassTraits); $printedClassContent = "nodePrinter->print($templateClass) . "\n"; $smartFileInfo = $this->file->getSmartFileInfo(); $targetFilePath = $smartFileInfo->getRealPathDirectory() . '/' . $templateClassName . '.php'; - $addedFileWithContent = new \Rector\FileSystemRector\ValueObject\AddedFileWithContent($targetFilePath, $printedClassContent); + $addedFileWithContent = new AddedFileWithContent($targetFilePath, $printedClassContent); $this->removedAndAddedFilesCollector->addAddedFile($addedFileWithContent); return $fullTemplateClassName; } diff --git a/vendor/rector/rector-nette/src/Rector/FuncCall/FilePutContentsToFileSystemWriteRector.php b/vendor/rector/rector-nette/src/Rector/FuncCall/FilePutContentsToFileSystemWriteRector.php index c4d11ef38f0..a90d2a59a0e 100644 --- a/vendor/rector/rector-nette/src/Rector/FuncCall/FilePutContentsToFileSystemWriteRector.php +++ b/vendor/rector/rector-nette/src/Rector/FuncCall/FilePutContentsToFileSystemWriteRector.php @@ -6,16 +6,16 @@ namespace Rector\Nette\Rector\FuncCall; use PhpParser\Node; use PhpParser\Node\Expr\FuncCall; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Rector\FuncCall\FilePutContentsToFileSystemWriteRector\FilePutContentsToFileSystemWriteRectorTest */ -final class FilePutContentsToFileSystemWriteRector extends \Rector\Core\Rector\AbstractRector +final class FilePutContentsToFileSystemWriteRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change file_put_contents() to FileSystem::write()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change file_put_contents() to FileSystem::write()', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -44,12 +44,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'file_put_contents')) { return null; diff --git a/vendor/rector/rector-nette/src/Rector/FuncCall/JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRector.php b/vendor/rector/rector-nette/src/Rector/FuncCall/JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRector.php index f0304f53255..26e1aba6476 100644 --- a/vendor/rector/rector-nette/src/Rector/FuncCall/JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRector.php +++ b/vendor/rector/rector-nette/src/Rector/FuncCall/JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRector.php @@ -8,16 +8,16 @@ use PhpParser\Node\Arg; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\StaticCall; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Rector\FuncCall\JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRector\JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRectorTest */ -final class JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRector extends \Rector\Core\Rector\AbstractRector +final class JsonDecodeEncodeToNetteUtilsJsonDecodeEncodeRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes json_encode()/json_decode() to safer and more verbose Nette\\Utils\\Json::encode()/decode() calls', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes json_encode()/json_decode() to safer and more verbose Nette\\Utils\\Json::encode()/decode() calls', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function decodeJson(string $jsonString) @@ -62,12 +62,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->isName($node, 'json_encode')) { return $this->refactorJsonEncode($node); @@ -77,19 +77,19 @@ CODE_SAMPLE } return null; } - private function refactorJsonEncode(\PhpParser\Node\Expr\FuncCall $funcCall) : \PhpParser\Node\Expr\StaticCall + private function refactorJsonEncode(FuncCall $funcCall) : StaticCall { $args = $funcCall->args; if (isset($args[1])) { $secondArgumentValue = $args[1]->value; if ($this->isName($secondArgumentValue, 'JSON_PRETTY_PRINT')) { $classConstFetch = $this->nodeFactory->createClassConstFetch('Nette\\Utils\\Json', 'PRETTY'); - $args[1] = new \PhpParser\Node\Arg($classConstFetch); + $args[1] = new Arg($classConstFetch); } } return $this->nodeFactory->createStaticCall('Nette\\Utils\\Json', 'encode', $args); } - private function refactorJsonDecode(\PhpParser\Node\Expr\FuncCall $funcCall) : \PhpParser\Node\Expr\StaticCall + private function refactorJsonDecode(FuncCall $funcCall) : StaticCall { $args = $funcCall->args; if (isset($args[1])) { @@ -98,7 +98,7 @@ CODE_SAMPLE unset($args[1]); } elseif ($this->valueResolver->isTrue($secondArgumentValue)) { $classConstFetch = $this->nodeFactory->createClassConstFetch('Nette\\Utils\\Json', 'FORCE_ARRAY'); - $args[1] = new \PhpParser\Node\Arg($classConstFetch); + $args[1] = new Arg($classConstFetch); } } return $this->nodeFactory->createStaticCall('Nette\\Utils\\Json', 'decode', $args); diff --git a/vendor/rector/rector-nette/src/Rector/FuncCall/PregFunctionToNetteUtilsStringsRector.php b/vendor/rector/rector-nette/src/Rector/FuncCall/PregFunctionToNetteUtilsStringsRector.php index cc12b138702..03f69f768b3 100644 --- a/vendor/rector/rector-nette/src/Rector/FuncCall/PregFunctionToNetteUtilsStringsRector.php +++ b/vendor/rector/rector-nette/src/Rector/FuncCall/PregFunctionToNetteUtilsStringsRector.php @@ -20,14 +20,14 @@ use PhpParser\Node\Scalar\LNumber; use PhpParser\Node\Stmt\Return_; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://tomasvotruba.com/blog/2019/02/07/what-i-learned-by-using-thecodingmachine-safe/#is-there-a-better-way * * @see \Rector\Nette\Tests\Rector\FuncCall\PregFunctionToNetteUtilsStringsRector\PregFunctionToNetteUtilsStringsRectorTest */ -final class PregFunctionToNetteUtilsStringsRector extends \Rector\Core\Rector\AbstractRector +final class PregFunctionToNetteUtilsStringsRector extends AbstractRector { /** * @var array @@ -38,9 +38,9 @@ final class PregFunctionToNetteUtilsStringsRector extends \Rector\Core\Rector\Ab * @var string */ private const SLASH_REGEX = '#[^\\\\]\\(#'; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Use Nette\\Utils\\Strings over bare preg_split() and preg_replace() functions', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Use Nette\\Utils\\Strings over bare preg_split() and preg_replace() functions', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -67,9 +67,9 @@ CODE_SAMPLE /** * @param FuncCall|Identical $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { + if ($node instanceof Identical) { return $this->refactorIdentical($node); } return $this->refactorFuncCall($node); @@ -79,24 +79,24 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Expr\BinaryOp\Identical::class]; + return [FuncCall::class, Identical::class]; } - public function refactorIdentical(\PhpParser\Node\Expr\BinaryOp\Identical $identical) : ?\PhpParser\Node\Expr\Cast\Bool_ + public function refactorIdentical(Identical $identical) : ?Bool_ { - $parent = $identical->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node) { + $parent = $identical->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Node) { return null; } - if ($identical->left instanceof \PhpParser\Node\Expr\FuncCall) { + if ($identical->left instanceof FuncCall) { $refactoredFuncCall = $this->refactorFuncCall($identical->left); if ($refactoredFuncCall !== null && $this->valueResolver->isValue($identical->right, 1)) { return $this->createBoolCast($parent, $refactoredFuncCall); } } - if ($identical->right instanceof \PhpParser\Node\Expr\FuncCall) { + if ($identical->right instanceof FuncCall) { $refactoredFuncCall = $this->refactorFuncCall($identical->right); if ($refactoredFuncCall !== null && $this->valueResolver->isValue($identical->left, 1)) { - return new \PhpParser\Node\Expr\Cast\Bool_($refactoredFuncCall); + return new Bool_($refactoredFuncCall); } } return null; @@ -104,7 +104,7 @@ CODE_SAMPLE /** * @return FuncCall|StaticCall|Assign|null */ - public function refactorFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Expr + public function refactorFuncCall(FuncCall $funcCall) : ?Expr { $methodName = $this->nodeNameResolver->matchNameFromMap($funcCall, self::FUNCTION_NAME_TO_METHOD_NAME); if ($methodName === null) { @@ -112,8 +112,8 @@ CODE_SAMPLE } $matchStaticCall = $this->createMatchStaticCall($funcCall, $methodName); // skip assigns, might be used with different return value - $parentNode = $funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentNode instanceof \PhpParser\Node\Expr\Assign) { + $parentNode = $funcCall->getAttribute(AttributeKey::PARENT_NODE); + if ($parentNode instanceof Assign) { if ($methodName === 'split') { return $this->processSplit($funcCall, $matchStaticCall); } @@ -125,21 +125,21 @@ CODE_SAMPLE $currentFunctionName = $this->getName($funcCall); // assign if (isset($funcCall->args[2]) && $currentFunctionName !== 'preg_replace') { - return new \PhpParser\Node\Expr\Assign($funcCall->args[2]->value, $matchStaticCall); + return new Assign($funcCall->args[2]->value, $matchStaticCall); } return $matchStaticCall; } /** * @param Expr $expr */ - private function createBoolCast(?\PhpParser\Node $node, \PhpParser\Node $expr) : \PhpParser\Node\Expr\Cast\Bool_ + private function createBoolCast(?Node $node, Node $expr) : Bool_ { - if ($node instanceof \PhpParser\Node\Stmt\Return_ && $expr instanceof \PhpParser\Node\Expr\Assign) { + if ($node instanceof Return_ && $expr instanceof Assign) { $expr = $expr->expr; } - return new \PhpParser\Node\Expr\Cast\Bool_($expr); + return new Bool_($expr); } - private function createMatchStaticCall(\PhpParser\Node\Expr\FuncCall $funcCall, string $methodName) : \PhpParser\Node\Expr\StaticCall + private function createMatchStaticCall(FuncCall $funcCall, string $methodName) : StaticCall { $args = []; if ($methodName === 'replace') { @@ -155,7 +155,7 @@ CODE_SAMPLE /** * @return FuncCall|StaticCall */ - private function processSplit(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr\StaticCall $matchStaticCall) : \PhpParser\Node\Expr + private function processSplit(FuncCall $funcCall, StaticCall $matchStaticCall) : Expr { $this->compensateNetteUtilsSplitDelimCapture($matchStaticCall); if (!isset($funcCall->args[2])) { @@ -172,18 +172,18 @@ CODE_SAMPLE /** * Handles https://github.com/rectorphp/rector/issues/2348 */ - private function compensateNetteUtilsSplitDelimCapture(\PhpParser\Node\Expr\StaticCall $staticCall) : void + private function compensateNetteUtilsSplitDelimCapture(StaticCall $staticCall) : void { $patternValue = $this->valueResolver->getValue($staticCall->args[1]->value); if (!\is_string($patternValue)) { return; } - $match = \RectorPrefix20220607\Nette\Utils\Strings::match($patternValue, self::SLASH_REGEX); + $match = Strings::match($patternValue, self::SLASH_REGEX); if ($match === null) { return; } - $constFetch = new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('PREG_SPLIT_DELIM_CAPTURE')); - $bitwiseAnd = new \PhpParser\Node\Expr\BinaryOp\BitwiseAnd(new \PhpParser\Node\Scalar\LNumber(0), new \PhpParser\Node\Expr\BitwiseNot($constFetch)); - $staticCall->args[2] = new \PhpParser\Node\Arg($bitwiseAnd); + $constFetch = new ConstFetch(new Name('PREG_SPLIT_DELIM_CAPTURE')); + $bitwiseAnd = new BitwiseAnd(new LNumber(0), new BitwiseNot($constFetch)); + $staticCall->args[2] = new Arg($bitwiseAnd); } } diff --git a/vendor/rector/rector-nette/src/Rector/FuncCall/PregMatchFunctionToNetteUtilsStringsRector.php b/vendor/rector/rector-nette/src/Rector/FuncCall/PregMatchFunctionToNetteUtilsStringsRector.php index 9ba6f183735..8e5d26a38cd 100644 --- a/vendor/rector/rector-nette/src/Rector/FuncCall/PregMatchFunctionToNetteUtilsStringsRector.php +++ b/vendor/rector/rector-nette/src/Rector/FuncCall/PregMatchFunctionToNetteUtilsStringsRector.php @@ -16,14 +16,14 @@ use PhpParser\Node\Stmt\Return_; use Rector\Core\Rector\AbstractRector; use Rector\Nette\NodeAnalyzer\PregMatchAllAnalyzer; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://tomasvotruba.com/blog/2019/02/07/what-i-learned-by-using-thecodingmachine-safe/#is-there-a-better-way * * @see \Rector\Nette\Tests\Rector\FuncCall\PregMatchFunctionToNetteUtilsStringsRector\PregMatchFunctionToNetteUtilsStringsRectorTest */ -final class PregMatchFunctionToNetteUtilsStringsRector extends \Rector\Core\Rector\AbstractRector +final class PregMatchFunctionToNetteUtilsStringsRector extends AbstractRector { /** * @var array @@ -34,13 +34,13 @@ final class PregMatchFunctionToNetteUtilsStringsRector extends \Rector\Core\Rect * @var \Rector\Nette\NodeAnalyzer\PregMatchAllAnalyzer */ private $pregMatchAllAnalyzer; - public function __construct(\Rector\Nette\NodeAnalyzer\PregMatchAllAnalyzer $pregMatchAllAnalyzer) + public function __construct(PregMatchAllAnalyzer $pregMatchAllAnalyzer) { $this->pregMatchAllAnalyzer = $pregMatchAllAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Use Nette\\Utils\\Strings over bare preg_match() and preg_match_all() functions', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Use Nette\\Utils\\Strings over bare preg_match() and preg_match_all() functions', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -67,9 +67,9 @@ CODE_SAMPLE /** * @param FuncCall|Identical $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { + if ($node instanceof Identical) { return $this->refactorIdentical($node); } return $this->refactorFuncCall($node); @@ -79,21 +79,21 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Expr\BinaryOp\Identical::class]; + return [FuncCall::class, Identical::class]; } - public function refactorIdentical(\PhpParser\Node\Expr\BinaryOp\Identical $identical) : ?\PhpParser\Node\Expr\Cast\Bool_ + public function refactorIdentical(Identical $identical) : ?Bool_ { - $parent = $identical->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parent instanceof \PhpParser\Node) { + $parent = $identical->getAttribute(AttributeKey::PARENT_NODE); + if (!$parent instanceof Node) { return null; } - if ($identical->left instanceof \PhpParser\Node\Expr\FuncCall) { + if ($identical->left instanceof FuncCall) { $refactoredFuncCall = $this->refactorFuncCall($identical->left); if ($refactoredFuncCall !== null && $this->valueResolver->isValue($identical->right, 1)) { return $this->createBoolCast($parent, $refactoredFuncCall); } } - if ($identical->right instanceof \PhpParser\Node\Expr\FuncCall) { + if ($identical->right instanceof FuncCall) { $refactoredFuncCall = $this->refactorFuncCall($identical->right); if ($refactoredFuncCall !== null && $this->valueResolver->isValue($identical->left, 1)) { return $this->createBoolCast($parent, $refactoredFuncCall); @@ -104,7 +104,7 @@ CODE_SAMPLE /** * @return FuncCall|StaticCall|Assign|null */ - public function refactorFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall) : ?\PhpParser\Node\Expr + public function refactorFuncCall(FuncCall $funcCall) : ?Expr { $methodName = $this->nodeNameResolver->matchNameFromMap($funcCall, self::FUNCTION_NAME_TO_METHOD_NAME); if ($methodName === null) { @@ -112,31 +112,31 @@ CODE_SAMPLE } $matchStaticCall = $this->createMatchStaticCall($funcCall, $methodName); // skip assigns, might be used with different return value - $parentNode = $funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentNode instanceof \PhpParser\Node\Expr\Assign) { + $parentNode = $funcCall->getAttribute(AttributeKey::PARENT_NODE); + if ($parentNode instanceof Assign) { if ($methodName === 'matchAll') { // use count - return new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('count'), [new \PhpParser\Node\Arg($matchStaticCall)]); + return new FuncCall(new Name('count'), [new Arg($matchStaticCall)]); } return null; } // assign if (isset($funcCall->args[2])) { - return new \PhpParser\Node\Expr\Assign($funcCall->args[2]->value, $matchStaticCall); + return new Assign($funcCall->args[2]->value, $matchStaticCall); } return $matchStaticCall; } /** * @param Expr $expr */ - private function createBoolCast(?\PhpParser\Node $node, \PhpParser\Node $expr) : \PhpParser\Node\Expr\Cast\Bool_ + private function createBoolCast(?Node $node, Node $expr) : Bool_ { - if ($node instanceof \PhpParser\Node\Stmt\Return_ && $expr instanceof \PhpParser\Node\Expr\Assign) { + if ($node instanceof Return_ && $expr instanceof Assign) { $expr = $expr->expr; } - return new \PhpParser\Node\Expr\Cast\Bool_($expr); + return new Bool_($expr); } - private function createMatchStaticCall(\PhpParser\Node\Expr\FuncCall $funcCall, string $methodName) : \PhpParser\Node\Expr\StaticCall + private function createMatchStaticCall(FuncCall $funcCall, string $methodName) : StaticCall { $args = []; $args[] = $funcCall->args[1]; diff --git a/vendor/rector/rector-nette/src/Rector/FuncCall/SubstrStrlenFunctionToNetteUtilsStringsRector.php b/vendor/rector/rector-nette/src/Rector/FuncCall/SubstrStrlenFunctionToNetteUtilsStringsRector.php index 22ff4c65aff..80720aaa0be 100644 --- a/vendor/rector/rector-nette/src/Rector/FuncCall/SubstrStrlenFunctionToNetteUtilsStringsRector.php +++ b/vendor/rector/rector-nette/src/Rector/FuncCall/SubstrStrlenFunctionToNetteUtilsStringsRector.php @@ -6,21 +6,21 @@ namespace Rector\Nette\Rector\FuncCall; use PhpParser\Node; use PhpParser\Node\Expr\FuncCall; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/nette/utils/blob/master/src/Utils/Strings.php * @see \Rector\Nette\Tests\Rector\FuncCall\SubstrStrlenFunctionToNetteUtilsStringsRector\SubstrStrlenFunctionToNetteUtilsStringsRectorTest */ -final class SubstrStrlenFunctionToNetteUtilsStringsRector extends \Rector\Core\Rector\AbstractRector +final class SubstrStrlenFunctionToNetteUtilsStringsRector extends AbstractRector { /** * @var array */ private const FUNCTION_TO_STATIC_METHOD = ['substr' => 'substring']; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Use Nette\\Utils\\Strings over bare string-functions', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Use Nette\\Utils\\Strings over bare string-functions', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -45,12 +45,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { foreach (self::FUNCTION_TO_STATIC_METHOD as $function => $staticMethod) { if (!$this->isName($node, $function)) { diff --git a/vendor/rector/rector-nette/src/Rector/Identical/EndsWithFunctionToNetteUtilsStringsRector.php b/vendor/rector/rector-nette/src/Rector/Identical/EndsWithFunctionToNetteUtilsStringsRector.php index 0714976f02b..ca8b2e49bd4 100644 --- a/vendor/rector/rector-nette/src/Rector/Identical/EndsWithFunctionToNetteUtilsStringsRector.php +++ b/vendor/rector/rector-nette/src/Rector/Identical/EndsWithFunctionToNetteUtilsStringsRector.php @@ -10,20 +10,20 @@ use PhpParser\Node\Expr\BooleanNot; use Rector\Core\Rector\AbstractRector; use Rector\Nette\NodeAnalyzer\StrlenEndsWithResolver; use Rector\Nette\ValueObject\ContentExprAndNeedleExpr; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/nette/utils/blob/master/src/Utils/Strings.php * @see \Rector\Nette\Tests\Rector\Identical\EndsWithFunctionToNetteUtilsStringsRector\EndsWithFunctionToNetteUtilsStringsRectorTest */ -final class EndsWithFunctionToNetteUtilsStringsRector extends \Rector\Core\Rector\AbstractRector +final class EndsWithFunctionToNetteUtilsStringsRector extends AbstractRector { /** * @readonly * @var \Rector\Nette\NodeAnalyzer\StrlenEndsWithResolver */ private $strlenEndsWithResolver; - public function __construct(\Rector\Nette\NodeAnalyzer\StrlenEndsWithResolver $strlenEndsWithResolver) + public function __construct(StrlenEndsWithResolver $strlenEndsWithResolver) { $this->strlenEndsWithResolver = $strlenEndsWithResolver; } @@ -32,11 +32,11 @@ final class EndsWithFunctionToNetteUtilsStringsRector extends \Rector\Core\Recto */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\Identical::class, \PhpParser\Node\Expr\BinaryOp\NotIdentical::class]; + return [Identical::class, NotIdentical::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Use Nette\\Utils\\Strings::endsWith() over bare string-functions', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Use Nette\\Utils\\Strings::endsWith() over bare string-functions', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function end($needle) @@ -64,15 +64,15 @@ CODE_SAMPLE /** * @param Identical|NotIdentical $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $contentExprAndNeedleExpr = $this->strlenEndsWithResolver->resolveBinaryOpForFunction($node); - if (!$contentExprAndNeedleExpr instanceof \Rector\Nette\ValueObject\ContentExprAndNeedleExpr) { + if (!$contentExprAndNeedleExpr instanceof ContentExprAndNeedleExpr) { return null; } $staticCall = $this->nodeFactory->createStaticCall('Nette\\Utils\\Strings', 'endsWith', [$contentExprAndNeedleExpr->getContentExpr(), $contentExprAndNeedleExpr->getNeedleExpr()]); - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\NotIdentical) { - return new \PhpParser\Node\Expr\BooleanNot($staticCall); + if ($node instanceof NotIdentical) { + return new BooleanNot($staticCall); } return $staticCall; } diff --git a/vendor/rector/rector-nette/src/Rector/Identical/StartsWithFunctionToNetteUtilsStringsRector.php b/vendor/rector/rector-nette/src/Rector/Identical/StartsWithFunctionToNetteUtilsStringsRector.php index dcc21981015..d4f1c471e50 100644 --- a/vendor/rector/rector-nette/src/Rector/Identical/StartsWithFunctionToNetteUtilsStringsRector.php +++ b/vendor/rector/rector-nette/src/Rector/Identical/StartsWithFunctionToNetteUtilsStringsRector.php @@ -10,21 +10,21 @@ use PhpParser\Node\Expr\BooleanNot; use Rector\Core\Rector\AbstractRector; use Rector\Nette\NodeAnalyzer\StrlenStartsWithResolver; use Rector\Nette\ValueObject\ContentExprAndNeedleExpr; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/nette/utils/blob/master/src/Utils/Strings.php * * @see \Rector\Nette\Tests\Rector\Identical\StartsWithFunctionToNetteUtilsStringsRector\StartsWithFunctionToNetteUtilsStringsRectorTest */ -final class StartsWithFunctionToNetteUtilsStringsRector extends \Rector\Core\Rector\AbstractRector +final class StartsWithFunctionToNetteUtilsStringsRector extends AbstractRector { /** * @readonly * @var \Rector\Nette\NodeAnalyzer\StrlenStartsWithResolver */ private $strlenStartsWithResolver; - public function __construct(\Rector\Nette\NodeAnalyzer\StrlenStartsWithResolver $strlenStartsWithResolver) + public function __construct(StrlenStartsWithResolver $strlenStartsWithResolver) { $this->strlenStartsWithResolver = $strlenStartsWithResolver; } @@ -33,11 +33,11 @@ final class StartsWithFunctionToNetteUtilsStringsRector extends \Rector\Core\Rec */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\Identical::class, \PhpParser\Node\Expr\BinaryOp\NotIdentical::class]; + return [Identical::class, NotIdentical::class]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Use Nette\\Utils\\Strings::startsWith() over bare string-functions', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Use Nette\\Utils\\Strings::startsWith() over bare string-functions', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function start($needle) @@ -64,15 +64,15 @@ CODE_SAMPLE /** * @param Identical|NotIdentical $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $contentExprAndNeedleExpr = $this->strlenStartsWithResolver->resolveBinaryOpForFunction($node, 'substr'); - if (!$contentExprAndNeedleExpr instanceof \Rector\Nette\ValueObject\ContentExprAndNeedleExpr) { + if (!$contentExprAndNeedleExpr instanceof ContentExprAndNeedleExpr) { return null; } $staticCall = $this->nodeFactory->createStaticCall('Nette\\Utils\\Strings', 'startsWith', [$contentExprAndNeedleExpr->getContentExpr(), $contentExprAndNeedleExpr->getNeedleExpr()]); - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\NotIdentical) { - return new \PhpParser\Node\Expr\BooleanNot($staticCall); + if ($node instanceof NotIdentical) { + return new BooleanNot($staticCall); } return $staticCall; } diff --git a/vendor/rector/rector-nette/src/Rector/Identical/SubstrMinusToStringEndsWithRector.php b/vendor/rector/rector-nette/src/Rector/Identical/SubstrMinusToStringEndsWithRector.php index 2de0615b658..ee1cfc4dd7c 100644 --- a/vendor/rector/rector-nette/src/Rector/Identical/SubstrMinusToStringEndsWithRector.php +++ b/vendor/rector/rector-nette/src/Rector/Identical/SubstrMinusToStringEndsWithRector.php @@ -13,12 +13,12 @@ use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; use Rector\Nette\NodeAnalyzer\BinaryOpAnalyzer; use Rector\Nette\ValueObject\FuncCallAndExpr; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Rector\Identical\SubstrMinusToStringEndsWithRector\SubstrMinusToStringEndsWithRectorTest */ -final class SubstrMinusToStringEndsWithRector extends \Rector\Core\Rector\AbstractRector +final class SubstrMinusToStringEndsWithRector extends AbstractRector { /** * @var string @@ -29,13 +29,13 @@ final class SubstrMinusToStringEndsWithRector extends \Rector\Core\Rector\Abstra * @var \Rector\Nette\NodeAnalyzer\BinaryOpAnalyzer */ private $binaryOpAnalyzer; - public function __construct(\Rector\Nette\NodeAnalyzer\BinaryOpAnalyzer $binaryOpAnalyzer) + public function __construct(BinaryOpAnalyzer $binaryOpAnalyzer) { $this->binaryOpAnalyzer = $binaryOpAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change substr function with minus to Strings::endsWith()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change substr function with minus to Strings::endsWith()', [new CodeSample(<<<'CODE_SAMPLE' substr($var, -4) !== 'Test'; substr($var, -4) === 'Test'; CODE_SAMPLE @@ -50,36 +50,36 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\Identical::class, \PhpParser\Node\Expr\BinaryOp\NotIdentical::class]; + return [Identical::class, NotIdentical::class]; } /** * @param Identical|NotIdentical $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $funcCallAndExpr = $this->binaryOpAnalyzer->matchFuncCallAndOtherExpr($node, self::SUBSTR); - if (!$funcCallAndExpr instanceof \Rector\Nette\ValueObject\FuncCallAndExpr) { + if (!$funcCallAndExpr instanceof FuncCallAndExpr) { return null; } $substrFuncCall = $funcCallAndExpr->getFuncCall(); - if (!$substrFuncCall->args[1]->value instanceof \PhpParser\Node\Expr\UnaryMinus) { + if (!$substrFuncCall->args[1]->value instanceof UnaryMinus) { return null; } /** @var UnaryMinus $unaryMinus */ $unaryMinus = $substrFuncCall->args[1]->value; - if (!$unaryMinus->expr instanceof \PhpParser\Node\Scalar\LNumber) { + if (!$unaryMinus->expr instanceof LNumber) { return null; } $string = $funcCallAndExpr->getExpr(); $wordLength = $unaryMinus->expr->value; - if ($string instanceof \PhpParser\Node\Scalar\String_ && \strlen($string->value) !== $wordLength) { + if ($string instanceof String_ && \strlen($string->value) !== $wordLength) { return null; } $arguments = [$substrFuncCall->args[0]->value, $string]; $staticCall = $this->nodeFactory->createStaticCall('Nette\\Utils\\Strings', 'endsWith', $arguments); - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { + if ($node instanceof Identical) { return $staticCall; } - return new \PhpParser\Node\Expr\BooleanNot($staticCall); + return new BooleanNot($staticCall); } } diff --git a/vendor/rector/rector-nette/src/Rector/LNumber/ReplaceTimeNumberWithDateTimeConstantRector.php b/vendor/rector/rector-nette/src/Rector/LNumber/ReplaceTimeNumberWithDateTimeConstantRector.php index f7ad1a48493..9b0133aac25 100644 --- a/vendor/rector/rector-nette/src/Rector/LNumber/ReplaceTimeNumberWithDateTimeConstantRector.php +++ b/vendor/rector/rector-nette/src/Rector/LNumber/ReplaceTimeNumberWithDateTimeConstantRector.php @@ -7,21 +7,21 @@ use RectorPrefix20220607\Nette\Utils\DateTime; use PhpParser\Node; use PhpParser\Node\Scalar\LNumber; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Rector\LNumber\ReplaceTimeNumberWithDateTimeConstantRector\ReplaceTimeNumberWithDateTimeConstantRectorTest */ -final class ReplaceTimeNumberWithDateTimeConstantRector extends \Rector\Core\Rector\AbstractRector +final class ReplaceTimeNumberWithDateTimeConstantRector extends AbstractRector { /** * @noRector * @var array */ - private const NUMBER_TO_CONSTANT_NAME = [\RectorPrefix20220607\Nette\Utils\DateTime::HOUR => 'HOUR', \RectorPrefix20220607\Nette\Utils\DateTime::DAY => 'DAY', \RectorPrefix20220607\Nette\Utils\DateTime::WEEK => 'WEEK', \RectorPrefix20220607\Nette\Utils\DateTime::MONTH => 'MONTH', \RectorPrefix20220607\Nette\Utils\DateTime::YEAR => 'YEAR']; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + private const NUMBER_TO_CONSTANT_NAME = [DateTime::HOUR => 'HOUR', DateTime::DAY => 'DAY', DateTime::WEEK => 'WEEK', DateTime::MONTH => 'MONTH', DateTime::YEAR => 'YEAR']; + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace time numbers with Nette\\Utils\\DateTime constants', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace time numbers with Nette\\Utils\\DateTime constants', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run() @@ -46,12 +46,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Scalar\LNumber::class]; + return [LNumber::class]; } /** * @param LNumber $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $number = $node->value; $constantName = self::NUMBER_TO_CONSTANT_NAME[$number] ?? null; diff --git a/vendor/rector/rector-nette/src/Rector/Latte/RenameMethodLatteRector.php b/vendor/rector/rector-nette/src/Rector/Latte/RenameMethodLatteRector.php index cdbb6fd0fba..2732139918d 100644 --- a/vendor/rector/rector-nette/src/Rector/Latte/RenameMethodLatteRector.php +++ b/vendor/rector/rector-nette/src/Rector/Latte/RenameMethodLatteRector.php @@ -7,12 +7,12 @@ use Rector\Nette\Contract\Rector\LatteRectorInterface; use Rector\Nette\Latte\Parser\TemplateTypeParser; use Rector\Nette\Latte\Parser\VarTypeParser; use Rector\Renaming\Collector\MethodCallRenameCollector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Rector\Latte\RenameMethodLatteRector\RenameMethodLatteRectorTest */ -final class RenameMethodLatteRector implements \Rector\Nette\Contract\Rector\LatteRectorInterface +final class RenameMethodLatteRector implements LatteRectorInterface { /** * @readonly @@ -29,15 +29,15 @@ final class RenameMethodLatteRector implements \Rector\Nette\Contract\Rector\Lat * @var \Rector\Nette\Latte\Parser\VarTypeParser */ private $varTypeParser; - public function __construct(\Rector\Renaming\Collector\MethodCallRenameCollector $methodCallRenameCollector, \Rector\Nette\Latte\Parser\TemplateTypeParser $templateTypeParser, \Rector\Nette\Latte\Parser\VarTypeParser $varTypeParser) + public function __construct(MethodCallRenameCollector $methodCallRenameCollector, TemplateTypeParser $templateTypeParser, VarTypeParser $varTypeParser) { $this->methodCallRenameCollector = $methodCallRenameCollector; $this->templateTypeParser = $templateTypeParser; $this->varTypeParser = $varTypeParser; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Renames method calls in LATTE templates', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Renames method calls in LATTE templates', [new CodeSample(<<<'CODE_SAMPLE' {varType SomeClass $someClass}
diff --git a/vendor/rector/rector-nette/src/Rector/MethodCall/AddNextrasDatePickerToDateControlRector.php b/vendor/rector/rector-nette/src/Rector/MethodCall/AddNextrasDatePickerToDateControlRector.php index b8e6d91d6b0..5f06e52fd36 100644 --- a/vendor/rector/rector-nette/src/Rector/MethodCall/AddNextrasDatePickerToDateControlRector.php +++ b/vendor/rector/rector-nette/src/Rector/MethodCall/AddNextrasDatePickerToDateControlRector.php @@ -15,16 +15,16 @@ use PHPStan\Type\ObjectType; use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Rector\MethodCall\AddNextrasDatePickerToDateControlRector\AddNextrasDatePickerToDateControlRectorTest */ -final class AddNextrasDatePickerToDateControlRector extends \Rector\Core\Rector\AbstractRector +final class AddNextrasDatePickerToDateControlRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Nextras/Form upgrade of addDatePicker method call to DateControl assign', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Nextras/Form upgrade of addDatePicker method call to DateControl assign', [new CodeSample(<<<'CODE_SAMPLE' use Nette\Application\UI\Form; class SomeClass @@ -55,34 +55,34 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { // 1. chain call - if ($node->var instanceof \PhpParser\Node\Expr\MethodCall) { - if (!$this->isObjectType($node->var->var, new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Form'))) { + if ($node->var instanceof MethodCall) { + if (!$this->isObjectType($node->var->var, new ObjectType('Nette\\Application\\UI\\Form'))) { return null; } if (!$this->isName($node->var->name, 'addDatePicker')) { return null; } $assign = $this->createAssign($node->var); - if (!$assign instanceof \PhpParser\Node) { + if (!$assign instanceof Node) { return null; } $controlName = $this->resolveControlName($node->var); - $node->var = new \PhpParser\Node\Expr\Variable($controlName); + $node->var = new Variable($controlName); // this fixes printing indent - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); + $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); $this->nodesToAddCollector->addNodeBeforeNode($assign, $node); return $node; } // 2. assign call - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Nette\\Application\\UI\\Form'))) { + if (!$this->isObjectType($node->var, new ObjectType('Nette\\Application\\UI\\Form'))) { return null; } if (!$this->isName($node->name, 'addDatePicker')) { @@ -90,40 +90,40 @@ CODE_SAMPLE } return $this->createAssign($node); } - private function createAssign(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node + private function createAssign(MethodCall $methodCall) : ?Node { $key = $methodCall->args[0]->value; - if (!$key instanceof \PhpParser\Node\Scalar\String_) { + if (!$key instanceof String_) { return null; } $new = $this->createDateTimeControlNew($methodCall); - $parent = $methodCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\Expr\Assign) { + $parent = $methodCall->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof Assign) { return $new; } - $arrayDimFetch = new \PhpParser\Node\Expr\ArrayDimFetch($methodCall->var, $key); - $formAssign = new \PhpParser\Node\Expr\Assign($arrayDimFetch, $new); - if ($parent instanceof \PhpParser\Node) { - $methodCalls = $this->betterNodeFinder->findInstanceOf($parent, \PhpParser\Node\Expr\MethodCall::class); + $arrayDimFetch = new ArrayDimFetch($methodCall->var, $key); + $formAssign = new Assign($arrayDimFetch, $new); + if ($parent instanceof Node) { + $methodCalls = $this->betterNodeFinder->findInstanceOf($parent, MethodCall::class); if (\count($methodCalls) > 1) { $controlName = $this->resolveControlName($methodCall); - return new \PhpParser\Node\Expr\Assign(new \PhpParser\Node\Expr\Variable($controlName), $formAssign); + return new Assign(new Variable($controlName), $formAssign); } } return $formAssign; } - private function resolveControlName(\PhpParser\Node\Expr\MethodCall $methodCall) : string + private function resolveControlName(MethodCall $methodCall) : string { $controlName = $methodCall->args[0]->value; - if (!$controlName instanceof \PhpParser\Node\Scalar\String_) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$controlName instanceof String_) { + throw new ShouldNotHappenException(); } return $controlName->value . 'DateControl'; } - private function createDateTimeControlNew(\PhpParser\Node\Expr\MethodCall $methodCall) : \PhpParser\Node\Expr\New_ + private function createDateTimeControlNew(MethodCall $methodCall) : New_ { - $fullyQualified = new \PhpParser\Node\Name\FullyQualified('Nextras\\FormComponents\\Controls\\DateControl'); - $new = new \PhpParser\Node\Expr\New_($fullyQualified); + $fullyQualified = new FullyQualified('Nextras\\FormComponents\\Controls\\DateControl'); + $new = new New_($fullyQualified); if (isset($methodCall->args[1])) { $new->args[] = $methodCall->args[1]; } diff --git a/vendor/rector/rector-nette/src/Rector/MethodCall/BuilderExpandToHelperExpandRector.php b/vendor/rector/rector-nette/src/Rector/MethodCall/BuilderExpandToHelperExpandRector.php index 79a637a40c6..194fba90952 100644 --- a/vendor/rector/rector-nette/src/Rector/MethodCall/BuilderExpandToHelperExpandRector.php +++ b/vendor/rector/rector-nette/src/Rector/MethodCall/BuilderExpandToHelperExpandRector.php @@ -12,18 +12,18 @@ use PhpParser\Node\Expr\Variable; use PhpParser\Node\Name\FullyQualified; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/Kdyby/Doctrine/commit/db80bf77c0b68af88dfe7eddb2cb2db94aedb04a#diff-ccc8ba07edfa3a425ddfe564acb50656R291 * * @see \Rector\Nette\Tests\Rector\MethodCall\BuilderExpandToHelperExpandRector\BuilderExpandToHelperExpandRectorTest */ -final class BuilderExpandToHelperExpandRector extends \Rector\Core\Rector\AbstractRector +final class BuilderExpandToHelperExpandRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change containerBuilder->expand() to static call with parameters', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change containerBuilder->expand() to static call with parameters', [new CodeSample(<<<'CODE_SAMPLE' use Nette\DI\CompilerExtension; final class SomeClass extends CompilerExtension @@ -52,23 +52,23 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Nette\\DI\\ContainerBuilder'))) { + if (!$this->isObjectType($node->var, new ObjectType('Nette\\DI\\ContainerBuilder'))) { return null; } if (!$this->isName($node->name, 'expand')) { return null; } $args = $node->args; - $getContainerBuilderMethodCall = new \PhpParser\Node\Expr\MethodCall(new \PhpParser\Node\Expr\Variable('this'), 'getContainerBuilder'); - $parametersPropertyFetch = new \PhpParser\Node\Expr\PropertyFetch($getContainerBuilderMethodCall, 'parameters'); - $args[] = new \PhpParser\Node\Arg($parametersPropertyFetch); - return new \PhpParser\Node\Expr\StaticCall(new \PhpParser\Node\Name\FullyQualified('Nette\\DI\\Helpers'), 'expand', $args); + $getContainerBuilderMethodCall = new MethodCall(new Variable('this'), 'getContainerBuilder'); + $parametersPropertyFetch = new PropertyFetch($getContainerBuilderMethodCall, 'parameters'); + $args[] = new Arg($parametersPropertyFetch); + return new StaticCall(new FullyQualified('Nette\\DI\\Helpers'), 'expand', $args); } } diff --git a/vendor/rector/rector-nette/src/Rector/MethodCall/ContextGetByTypeToConstructorInjectionRector.php b/vendor/rector/rector-nette/src/Rector/MethodCall/ContextGetByTypeToConstructorInjectionRector.php index c88cc3312fe..623e49bb7b6 100644 --- a/vendor/rector/rector-nette/src/Rector/MethodCall/ContextGetByTypeToConstructorInjectionRector.php +++ b/vendor/rector/rector-nette/src/Rector/MethodCall/ContextGetByTypeToConstructorInjectionRector.php @@ -9,12 +9,12 @@ use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\Symfony\NodeAnalyzer\DependencyInjectionMethodCallAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Rector\MethodCall\ContextGetByTypeToConstructorInjectionRector\ContextGetByTypeToConstructorInjectionRectorTest */ -final class ContextGetByTypeToConstructorInjectionRector extends \Rector\Core\Rector\AbstractRector +final class ContextGetByTypeToConstructorInjectionRector extends AbstractRector { /** * @readonly @@ -26,14 +26,14 @@ final class ContextGetByTypeToConstructorInjectionRector extends \Rector\Core\Re * @var \Rector\Symfony\NodeAnalyzer\DependencyInjectionMethodCallAnalyzer */ private $dependencyInjectionMethodCallAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer, \Rector\Symfony\NodeAnalyzer\DependencyInjectionMethodCallAnalyzer $dependencyInjectionMethodCallAnalyzer) + public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer, DependencyInjectionMethodCallAnalyzer $dependencyInjectionMethodCallAnalyzer) { $this->testsNodeAnalyzer = $testsNodeAnalyzer; $this->dependencyInjectionMethodCallAnalyzer = $dependencyInjectionMethodCallAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Move dependency get via $context->getByType() to constructor injection', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Move dependency get via $context->getByType() to constructor injection', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { /** @@ -72,18 +72,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->testsNodeAnalyzer->isInTestClass($node)) { return null; } $callerType = $this->nodeTypeResolver->getType($node->var); - $containerObjectType = new \PHPStan\Type\ObjectType('Nette\\DI\\Container'); + $containerObjectType = new ObjectType('Nette\\DI\\Container'); if (!$containerObjectType->isSuperTypeOf($callerType)->yes()) { return null; } diff --git a/vendor/rector/rector-nette/src/Rector/MethodCall/ConvertAddUploadWithThirdArgumentTrueToAddMultiUploadRector.php b/vendor/rector/rector-nette/src/Rector/MethodCall/ConvertAddUploadWithThirdArgumentTrueToAddMultiUploadRector.php index f914b5b6925..8d600ea1306 100644 --- a/vendor/rector/rector-nette/src/Rector/MethodCall/ConvertAddUploadWithThirdArgumentTrueToAddMultiUploadRector.php +++ b/vendor/rector/rector-nette/src/Rector/MethodCall/ConvertAddUploadWithThirdArgumentTrueToAddMultiUploadRector.php @@ -8,16 +8,16 @@ use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Identifier; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Rector\MethodCall\ConvertAddUploadWithThirdArgumentTrueToAddMultiUploadRector\ConvertAddUploadWithThirdArgumentTrueToAddMultiUploadRectorTest */ -final class ConvertAddUploadWithThirdArgumentTrueToAddMultiUploadRector extends \Rector\Core\Rector\AbstractRector +final class ConvertAddUploadWithThirdArgumentTrueToAddMultiUploadRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('convert addUpload() with 3rd argument true to addMultiUpload()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('convert addUpload() with 3rd argument true to addMultiUpload()', [new CodeSample(<<<'CODE_SAMPLE' $form = new Nette\Forms\Form(); $form->addUpload('...', '...', true); CODE_SAMPLE @@ -32,14 +32,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Nette\\Forms\\Form'))) { + if (!$this->isObjectType($node->var, new ObjectType('Nette\\Forms\\Form'))) { return null; } if (!$this->isName($node->name, 'addUpload')) { @@ -50,7 +50,7 @@ CODE_SAMPLE return null; } if ($this->valueResolver->isTrue($node->args[2]->value)) { - $node->name = new \PhpParser\Node\Identifier('addMultiUpload'); + $node->name = new Identifier('addMultiUpload'); unset($node->args[2]); return $node; } diff --git a/vendor/rector/rector-nette/src/Rector/MethodCall/MagicHtmlCallToAppendAttributeRector.php b/vendor/rector/rector-nette/src/Rector/MethodCall/MagicHtmlCallToAppendAttributeRector.php index 10230e3ddd0..103f6b2638d 100644 --- a/vendor/rector/rector-nette/src/Rector/MethodCall/MagicHtmlCallToAppendAttributeRector.php +++ b/vendor/rector/rector-nette/src/Rector/MethodCall/MagicHtmlCallToAppendAttributeRector.php @@ -10,19 +10,19 @@ use PhpParser\Node\Identifier; use PhpParser\Node\Scalar\String_; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/nette/utils/commit/75abe7c6aa472fd023aa49ba1a4d6c6eca0eaaa6 * @see https://github.com/nette/utils/issues/88 * * @see \Rector\Nette\Tests\Rector\MethodCall\MagicHtmlCallToAppendAttributeRector\MagicHtmlCallToAppendAttributeRectorTest */ -final class MagicHtmlCallToAppendAttributeRector extends \Rector\Core\Rector\AbstractRector +final class MagicHtmlCallToAppendAttributeRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change magic addClass() etc. calls on Html to explicit methods', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change magic addClass() etc. calls on Html to explicit methods', [new CodeSample(<<<'CODE_SAMPLE' use Nette\Utils\Html; final class SomeClass @@ -53,20 +53,20 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Nette\\Utils\\Html'))) { + if (!$this->isObjectType($node->var, new ObjectType('Nette\\Utils\\Html'))) { return null; } // @todo posibly extends by more common names if ($this->isName($node->name, 'setClass')) { - $node->name = new \PhpParser\Node\Identifier('appendAttribute'); - $args = \array_merge([new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\String_('class'))], $node->args); + $node->name = new Identifier('appendAttribute'); + $args = \array_merge([new Arg(new String_('class'))], $node->args); $node->args = $args; return $node; } diff --git a/vendor/rector/rector-nette/src/Rector/MethodCall/MergeDefaultsInGetConfigCompilerExtensionRector.php b/vendor/rector/rector-nette/src/Rector/MethodCall/MergeDefaultsInGetConfigCompilerExtensionRector.php index 701defff090..18f5383b898 100644 --- a/vendor/rector/rector-nette/src/Rector/MethodCall/MergeDefaultsInGetConfigCompilerExtensionRector.php +++ b/vendor/rector/rector-nette/src/Rector/MethodCall/MergeDefaultsInGetConfigCompilerExtensionRector.php @@ -8,16 +8,16 @@ use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\Variable; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Rector\MethodCall\MergeDefaultsInGetConfigCompilerExtensionRector\MergeDefaultsInGetConfigCompilerExtensionRectorTest */ -final class MergeDefaultsInGetConfigCompilerExtensionRector extends \Rector\Core\Rector\AbstractRector +final class MergeDefaultsInGetConfigCompilerExtensionRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change $this->getConfig($defaults) to array_merge', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change $this->getConfig($defaults) to array_merge', [new CodeSample(<<<'CODE_SAMPLE' use Nette\DI\CompilerExtension; final class SomeExtension extends CompilerExtension @@ -54,14 +54,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Nette\\DI\\CompilerExtension'))) { + if (!$this->isObjectType($node->var, new ObjectType('Nette\\DI\\CompilerExtension'))) { return null; } if (!$this->isName($node->name, 'getConfig')) { @@ -70,7 +70,7 @@ CODE_SAMPLE if (\count($node->args) !== 1) { return null; } - $getConfigMethodCall = new \PhpParser\Node\Expr\MethodCall(new \PhpParser\Node\Expr\Variable('this'), 'getConfig'); + $getConfigMethodCall = new MethodCall(new Variable('this'), 'getConfig'); $firstArgValue = $node->args[0]->value; return $this->nodeFactory->createFuncCall('array_merge', [$firstArgValue, $getConfigMethodCall]); } diff --git a/vendor/rector/rector-nette/src/Rector/MethodCall/RequestGetCookieDefaultArgumentToCoalesceRector.php b/vendor/rector/rector-nette/src/Rector/MethodCall/RequestGetCookieDefaultArgumentToCoalesceRector.php index 2b2517d62eb..a128dd378aa 100644 --- a/vendor/rector/rector-nette/src/Rector/MethodCall/RequestGetCookieDefaultArgumentToCoalesceRector.php +++ b/vendor/rector/rector-nette/src/Rector/MethodCall/RequestGetCookieDefaultArgumentToCoalesceRector.php @@ -8,16 +8,16 @@ use PhpParser\Node\Expr\BinaryOp\Coalesce; use PhpParser\Node\Expr\MethodCall; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Rector\MethodCall\RequestGetCookieDefaultArgumentToCoalesceRector\RequestGetCookieDefaultArgumentToCoalesceRectorTest */ -final class RequestGetCookieDefaultArgumentToCoalesceRector extends \Rector\Core\Rector\AbstractRector +final class RequestGetCookieDefaultArgumentToCoalesceRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add removed Nette\\Http\\Request::getCookies() default value as coalesce', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add removed Nette\\Http\\Request::getCookies() default value as coalesce', [new CodeSample(<<<'CODE_SAMPLE' use Nette\Http\Request; class SomeClass @@ -46,14 +46,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Nette\\Http\\Request'))) { + if (!$this->isObjectType($node->var, new ObjectType('Nette\\Http\\Request'))) { return null; } if (!$this->isName($node->name, 'getCookie')) { @@ -65,6 +65,6 @@ CODE_SAMPLE } $defaultValue = $node->args[1]->value; unset($node->args[1]); - return new \PhpParser\Node\Expr\BinaryOp\Coalesce($node, $defaultValue); + return new Coalesce($node, $defaultValue); } } diff --git a/vendor/rector/rector-nette/src/Rector/MethodCall/SetClassWithArgumentToSetFactoryRector.php b/vendor/rector/rector-nette/src/Rector/MethodCall/SetClassWithArgumentToSetFactoryRector.php index 4a65c27b6c8..4d27fce0df8 100644 --- a/vendor/rector/rector-nette/src/Rector/MethodCall/SetClassWithArgumentToSetFactoryRector.php +++ b/vendor/rector/rector-nette/src/Rector/MethodCall/SetClassWithArgumentToSetFactoryRector.php @@ -8,18 +8,18 @@ use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Identifier; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/nette/di/pull/146/files * * @see \Rector\Nette\Tests\Rector\MethodCall\SetClassWithArgumentToSetFactoryRector\SetClassWithArgumentToSetFactoryRectorTest */ -final class SetClassWithArgumentToSetFactoryRector extends \Rector\Core\Rector\AbstractRector +final class SetClassWithArgumentToSetFactoryRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change setClass with class and arguments to separated methods', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change setClass with class and arguments to separated methods', [new CodeSample(<<<'CODE_SAMPLE' use Nette\DI\ContainerBuilder; class SomeClass @@ -50,12 +50,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node->name, 'setClass')) { return null; @@ -63,10 +63,10 @@ CODE_SAMPLE if (\count($node->args) !== 2) { return null; } - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Nette\\DI\\Definitions\\ServiceDefinition'))) { + if (!$this->isObjectType($node->var, new ObjectType('Nette\\DI\\Definitions\\ServiceDefinition'))) { return null; } - $node->name = new \PhpParser\Node\Identifier('setFactory'); + $node->name = new Identifier('setFactory'); return $node; } } diff --git a/vendor/rector/rector-nette/src/Rector/Neon/RenameMethodNeonRector.php b/vendor/rector/rector-nette/src/Rector/Neon/RenameMethodNeonRector.php index f4bfffc74bf..a91a9131ab7 100644 --- a/vendor/rector/rector-nette/src/Rector/Neon/RenameMethodNeonRector.php +++ b/vendor/rector/rector-nette/src/Rector/Neon/RenameMethodNeonRector.php @@ -7,27 +7,27 @@ use RectorPrefix20220607\Nette\Neon\Node; use Rector\Nette\Contract\Rector\NeonRectorInterface; use Rector\Nette\NeonParser\Node\Service_\SetupMethodCall; use Rector\Renaming\Collector\MethodCallRenameCollector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Nette\Tests\Rector\Neon\RenameMethodNeonRector\RenameMethodNeonRectorTest * * @implements NeonRectorInterface */ -final class RenameMethodNeonRector implements \Rector\Nette\Contract\Rector\NeonRectorInterface +final class RenameMethodNeonRector implements NeonRectorInterface { /** * @readonly * @var \Rector\Renaming\Collector\MethodCallRenameCollector */ private $methodCallRenameCollector; - public function __construct(\Rector\Renaming\Collector\MethodCallRenameCollector $methodCallRenameCollector) + public function __construct(MethodCallRenameCollector $methodCallRenameCollector) { $this->methodCallRenameCollector = $methodCallRenameCollector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Renames method calls in NEON configs', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Renames method calls in NEON configs', [new CodeSample(<<<'CODE_SAMPLE' services: - class: SomeClass @@ -45,13 +45,13 @@ CODE_SAMPLE } public function getNodeType() : string { - return \Rector\Nette\NeonParser\Node\Service_\SetupMethodCall::class; + return SetupMethodCall::class; } /** * @param SetupMethodCall $node * @return \Nette\Neon\Node|null */ - public function enterNode(\RectorPrefix20220607\Nette\Neon\Node $node) + public function enterNode(Node $node) { foreach ($this->methodCallRenameCollector->getMethodCallRenames() as $methodCallRename) { if (!\is_a($node->className, $methodCallRename->getClass(), \true)) { diff --git a/vendor/rector/rector-nette/src/Rector/NotIdentical/StrposToStringsContainsRector.php b/vendor/rector/rector-nette/src/Rector/NotIdentical/StrposToStringsContainsRector.php index f27800405a5..b10cd256b8e 100644 --- a/vendor/rector/rector-nette/src/Rector/NotIdentical/StrposToStringsContainsRector.php +++ b/vendor/rector/rector-nette/src/Rector/NotIdentical/StrposToStringsContainsRector.php @@ -11,19 +11,19 @@ use PhpParser\Node\Expr\BinaryOp\NotIdentical; use PhpParser\Node\Expr\BooleanNot; use PhpParser\Node\Expr\FuncCall; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://3v4l.org/CubLi * @see https://github.com/nette/utils/blob/bd961f49b211997202bda1d0fbc410905be370d4/src/Utils/Strings.php#L81 * * @see \Rector\Nette\Tests\Rector\NotIdentical\StrposToStringsContainsRector\StrposToStringsContainsRectorTest */ -final class StrposToStringsContainsRector extends \Rector\Core\Rector\AbstractRector +final class StrposToStringsContainsRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Use Nette\\Utils\\Strings over bare string-functions', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Use Nette\\Utils\\Strings over bare string-functions', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -50,15 +50,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp\NotIdentical::class, \PhpParser\Node\Expr\BinaryOp\Identical::class]; + return [NotIdentical::class, Identical::class]; } /** * @param NotIdentical|Identical $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $funcCall = $this->matchStrposInComparisonToFalse($node); - if (!$funcCall instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$funcCall instanceof FuncCall) { return null; } if (isset($funcCall->args[2]) && !$this->valueResolver->isValue($funcCall->args[2]->value, 0)) { @@ -67,12 +67,12 @@ CODE_SAMPLE $containsStaticCall = $this->nodeFactory->createStaticCall('Nette\\Utils\\Strings', 'contains'); $containsStaticCall->args[0] = $funcCall->args[0]; $containsStaticCall->args[1] = $funcCall->args[1]; - if ($node instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { - return new \PhpParser\Node\Expr\BooleanNot($containsStaticCall); + if ($node instanceof Identical) { + return new BooleanNot($containsStaticCall); } return $containsStaticCall; } - private function matchStrposInComparisonToFalse(\PhpParser\Node\Expr\BinaryOp $binaryOp) : ?\PhpParser\Node\Expr + private function matchStrposInComparisonToFalse(BinaryOp $binaryOp) : ?Expr { if ($this->valueResolver->isFalse($binaryOp->left)) { $rightExpr = $binaryOp->right; @@ -88,9 +88,9 @@ CODE_SAMPLE } return null; } - private function isStrposFuncCall(\PhpParser\Node\Expr $expr) : bool + private function isStrposFuncCall(Expr $expr) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$expr instanceof FuncCall) { return \false; } return $this->isName($expr, 'strpos'); diff --git a/vendor/rector/rector-nette/src/Rector/Property/NetteInjectToConstructorInjectionRector.php b/vendor/rector/rector-nette/src/Rector/Property/NetteInjectToConstructorInjectionRector.php index eaa434bedbe..6c5bcb56162 100644 --- a/vendor/rector/rector-nette/src/Rector/Property/NetteInjectToConstructorInjectionRector.php +++ b/vendor/rector/rector-nette/src/Rector/Property/NetteInjectToConstructorInjectionRector.php @@ -17,8 +17,8 @@ use Rector\Nette\NodeAnalyzer\PropertyUsageAnalyzer; use Rector\PostRector\Collector\PropertyToAddCollector; use Rector\PostRector\ValueObject\PropertyMetadata; use Rector\Privatization\NodeManipulator\VisibilityManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * Covers these cases: * - https://doc.nette.org/en/2.4/di-usage#toc-inject-annotations @@ -26,7 +26,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @see \Rector\Nette\Tests\Rector\Property\NetteInjectToConstructorInjectionRector\NetteInjectToConstructorInjectionRectorTest */ -final class NetteInjectToConstructorInjectionRector extends \Rector\Core\Rector\AbstractRector +final class NetteInjectToConstructorInjectionRector extends AbstractRector { /** * @readonly @@ -58,7 +58,7 @@ final class NetteInjectToConstructorInjectionRector extends \Rector\Core\Rector\ * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Nette\NodeAnalyzer\PropertyUsageAnalyzer $propertyUsageAnalyzer, \Rector\Nette\NodeAnalyzer\NetteInjectPropertyAnalyzer $netteInjectPropertyAnalyzer, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover $phpDocTagRemover, \Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector, \Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(PropertyUsageAnalyzer $propertyUsageAnalyzer, NetteInjectPropertyAnalyzer $netteInjectPropertyAnalyzer, PhpDocTagRemover $phpDocTagRemover, PropertyToAddCollector $propertyToAddCollector, VisibilityManipulator $visibilityManipulator, PhpVersionProvider $phpVersionProvider) { $this->propertyUsageAnalyzer = $propertyUsageAnalyzer; $this->netteInjectPropertyAnalyzer = $netteInjectPropertyAnalyzer; @@ -67,9 +67,9 @@ final class NetteInjectToConstructorInjectionRector extends \Rector\Core\Rector\ $this->visibilityManipulator = $visibilityManipulator; $this->phpVersionProvider = $phpVersionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns properties with `@inject` to private properties and constructor injection', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns properties with `@inject` to private properties and constructor injection', [new CodeSample(<<<'CODE_SAMPLE' /** * @var SomeService * @inject @@ -94,15 +94,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); - if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$phpDocInfo instanceof PhpDocInfo) { return null; } if (!$phpDocInfo->hasByName('inject')) { @@ -113,28 +113,28 @@ CODE_SAMPLE } return $this->refactorNetteInjectProperty($phpDocInfo, $node); } - private function refactorNetteInjectProperty(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\Stmt\Property $property) : ?\PhpParser\Node\Stmt\Property + private function refactorNetteInjectProperty(PhpDocInfo $phpDocInfo, Property $property) : ?Property { $injectTagNode = $phpDocInfo->getByName('inject'); if ($injectTagNode instanceof \PHPStan\PhpDocParser\Ast\Node) { $this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $injectTagNode); } $this->changePropertyVisibility($property); - $class = $this->betterNodeFinder->findParentType($property, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $class = $this->betterNodeFinder->findParentType($property, Class_::class); + if (!$class instanceof Class_) { + throw new ShouldNotHappenException(); } $propertyName = $this->nodeNameResolver->getName($property); $propertyType = $this->nodeTypeResolver->getType($property); - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($propertyName, $propertyType, $property->flags); + $propertyMetadata = new PropertyMetadata($propertyName, $propertyType, $property->flags); $this->propertyToAddCollector->addPropertyToClass($class, $propertyMetadata); - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::PROPERTY_PROMOTION)) { + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::PROPERTY_PROMOTION)) { $this->removeNode($property); return null; } return $property; } - private function changePropertyVisibility(\PhpParser\Node\Stmt\Property $property) : void + private function changePropertyVisibility(Property $property) : void { if ($this->propertyUsageAnalyzer->isPropertyFetchedInChildClass($property)) { $this->visibilityManipulator->makeProtected($property); diff --git a/vendor/rector/rector-nette/src/Set/ContributteSetList.php b/vendor/rector/rector-nette/src/Set/ContributteSetList.php index 86f363f5538..76432e40b8d 100644 --- a/vendor/rector/rector-nette/src/Set/ContributteSetList.php +++ b/vendor/rector/rector-nette/src/Set/ContributteSetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Nette\Set; use Rector\Set\Contract\SetListInterface; -final class ContributteSetList implements \Rector\Set\Contract\SetListInterface +final class ContributteSetList implements SetListInterface { /** * @var string diff --git a/vendor/rector/rector-nette/src/Set/KdybySetList.php b/vendor/rector/rector-nette/src/Set/KdybySetList.php index 628dc5b5ccf..256b5f5a076 100644 --- a/vendor/rector/rector-nette/src/Set/KdybySetList.php +++ b/vendor/rector/rector-nette/src/Set/KdybySetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Nette\Set; use Rector\Set\Contract\SetListInterface; -final class KdybySetList implements \Rector\Set\Contract\SetListInterface +final class KdybySetList implements SetListInterface { /** * @var string diff --git a/vendor/rector/rector-nette/src/Set/NetteSetList.php b/vendor/rector/rector-nette/src/Set/NetteSetList.php index 31663806248..2eb4447bc2f 100644 --- a/vendor/rector/rector-nette/src/Set/NetteSetList.php +++ b/vendor/rector/rector-nette/src/Set/NetteSetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Nette\Set; use Rector\Set\Contract\SetListInterface; -final class NetteSetList implements \Rector\Set\Contract\SetListInterface +final class NetteSetList implements SetListInterface { /** * @var string diff --git a/vendor/rector/rector-nette/src/ValueObject/AlwaysTemplateParameterAssign.php b/vendor/rector/rector-nette/src/ValueObject/AlwaysTemplateParameterAssign.php index 61bb3a41f0b..9c447191c21 100644 --- a/vendor/rector/rector-nette/src/ValueObject/AlwaysTemplateParameterAssign.php +++ b/vendor/rector/rector-nette/src/ValueObject/AlwaysTemplateParameterAssign.php @@ -22,17 +22,17 @@ final class AlwaysTemplateParameterAssign * @var \PhpParser\Node\Expr */ private $assignedExpr; - public function __construct(\PhpParser\Node\Expr\Assign $assign, string $parameterName, \PhpParser\Node\Expr $assignedExpr) + public function __construct(Assign $assign, string $parameterName, Expr $assignedExpr) { $this->assign = $assign; $this->parameterName = $parameterName; $this->assignedExpr = $assignedExpr; } - public function getAssign() : \PhpParser\Node\Expr\Assign + public function getAssign() : Assign { return $this->assign; } - public function getAssignVar() : \PhpParser\Node\Expr + public function getAssignVar() : Expr { return $this->assign->var; } @@ -40,7 +40,7 @@ final class AlwaysTemplateParameterAssign { return $this->parameterName; } - public function getAssignedExpr() : \PhpParser\Node\Expr + public function getAssignedExpr() : Expr { return $this->assignedExpr; } diff --git a/vendor/rector/rector-nette/src/ValueObject/ContentExprAndNeedleExpr.php b/vendor/rector/rector-nette/src/ValueObject/ContentExprAndNeedleExpr.php index e9bb9923510..9468172d8e9 100644 --- a/vendor/rector/rector-nette/src/ValueObject/ContentExprAndNeedleExpr.php +++ b/vendor/rector/rector-nette/src/ValueObject/ContentExprAndNeedleExpr.php @@ -16,16 +16,16 @@ final class ContentExprAndNeedleExpr * @var \PhpParser\Node\Expr */ private $needleExpr; - public function __construct(\PhpParser\Node\Expr $contentExpr, \PhpParser\Node\Expr $needleExpr) + public function __construct(Expr $contentExpr, Expr $needleExpr) { $this->contentExpr = $contentExpr; $this->needleExpr = $needleExpr; } - public function getContentExpr() : \PhpParser\Node\Expr + public function getContentExpr() : Expr { return $this->contentExpr; } - public function getNeedleExpr() : \PhpParser\Node\Expr + public function getNeedleExpr() : Expr { return $this->needleExpr; } diff --git a/vendor/rector/rector-nette/src/ValueObject/FuncCallAndExpr.php b/vendor/rector/rector-nette/src/ValueObject/FuncCallAndExpr.php index 302783c6491..018456dbf5b 100644 --- a/vendor/rector/rector-nette/src/ValueObject/FuncCallAndExpr.php +++ b/vendor/rector/rector-nette/src/ValueObject/FuncCallAndExpr.php @@ -17,16 +17,16 @@ final class FuncCallAndExpr * @var \PhpParser\Node\Expr */ private $expr; - public function __construct(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr $expr) + public function __construct(FuncCall $funcCall, Expr $expr) { $this->funcCall = $funcCall; $this->expr = $expr; } - public function getFuncCall() : \PhpParser\Node\Expr\FuncCall + public function getFuncCall() : FuncCall { return $this->funcCall; } - public function getExpr() : \PhpParser\Node\Expr + public function getExpr() : Expr { return $this->expr; } diff --git a/vendor/rector/rector-nette/src/ValueObject/ParameterAssign.php b/vendor/rector/rector-nette/src/ValueObject/ParameterAssign.php index b08bc074043..7d31d859437 100644 --- a/vendor/rector/rector-nette/src/ValueObject/ParameterAssign.php +++ b/vendor/rector/rector-nette/src/ValueObject/ParameterAssign.php @@ -16,12 +16,12 @@ final class ParameterAssign * @var string */ private $parameterName; - public function __construct(\PhpParser\Node\Expr\Assign $assign, string $parameterName) + public function __construct(Assign $assign, string $parameterName) { $this->assign = $assign; $this->parameterName = $parameterName; } - public function getAssign() : \PhpParser\Node\Expr\Assign + public function getAssign() : Assign { return $this->assign; } diff --git a/vendor/rector/rector-phpoffice/config/config.php b/vendor/rector/rector-phpoffice/config/config.php index c40b8f9170d..5b214dda837 100644 --- a/vendor/rector/rector-phpoffice/config/config.php +++ b/vendor/rector/rector-phpoffice/config/config.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace RectorPrefix20220607; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $services = $rectorConfig->services(); $services->defaults()->public()->autowire()->autoconfigure(); $services->load('Rector\\PHPOffice\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/Set', __DIR__ . '/../src/Rector', __DIR__ . '/../src/ValueObject']); diff --git a/vendor/rector/rector-phpoffice/config/sets/phpexcel-to-phpspreadsheet.php b/vendor/rector/rector-phpoffice/config/sets/phpexcel-to-phpspreadsheet.php index 6f108420c93..2d0a4d56f5a 100644 --- a/vendor/rector/rector-phpoffice/config/sets/phpexcel-to-phpspreadsheet.php +++ b/vendor/rector/rector-phpoffice/config/sets/phpexcel-to-phpspreadsheet.php @@ -26,33 +26,33 @@ use Rector\Renaming\ValueObject\MethodCallRename; use Rector\Renaming\ValueObject\RenameStaticMethod; # see https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md # inspired https://github.com/PHPOffice/PhpSpreadsheet/blob/87f71e1930b497b36e3b9b1522117dfa87096d2b/src/PhpSpreadsheet/Helper/Migrator.php -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\PHPOffice\Rector\StaticCall\ChangeIOFactoryArgumentRector::class); - $rectorConfig->rule(\Rector\PHPOffice\Rector\StaticCall\ChangeSearchLocationToRegisterReaderRector::class); - $rectorConfig->rule(\Rector\PHPOffice\Rector\StaticCall\CellStaticToCoordinateRector::class); - $rectorConfig->rule(\Rector\PHPOffice\Rector\StaticCall\ChangeDataTypeForValueRector::class); - $rectorConfig->rule(\Rector\PHPOffice\Rector\StaticCall\ChangePdfWriterRector::class); - $rectorConfig->rule(\Rector\PHPOffice\Rector\StaticCall\ChangeChartRendererRector::class); - $rectorConfig->rule(\Rector\PHPOffice\Rector\StaticCall\AddRemovedDefaultValuesRector::class); - $rectorConfig->rule(\Rector\PHPOffice\Rector\MethodCall\ChangeConditionalReturnedCellRector::class); - $rectorConfig->rule(\Rector\PHPOffice\Rector\MethodCall\ChangeConditionalGetConditionRector::class); - $rectorConfig->rule(\Rector\PHPOffice\Rector\MethodCall\ChangeConditionalSetConditionRector::class); - $rectorConfig->rule(\Rector\PHPOffice\Rector\MethodCall\RemoveSetTempDirOnExcelWriterRector::class); - $rectorConfig->rule(\Rector\PHPOffice\Rector\MethodCall\ChangeDuplicateStyleArrayToApplyFromArrayRector::class); - $rectorConfig->rule(\Rector\PHPOffice\Rector\MethodCall\GetDefaultStyleToGetParentRector::class); - $rectorConfig->rule(\Rector\PHPOffice\Rector\MethodCall\IncreaseColumnIndexRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(ChangeIOFactoryArgumentRector::class); + $rectorConfig->rule(ChangeSearchLocationToRegisterReaderRector::class); + $rectorConfig->rule(CellStaticToCoordinateRector::class); + $rectorConfig->rule(ChangeDataTypeForValueRector::class); + $rectorConfig->rule(ChangePdfWriterRector::class); + $rectorConfig->rule(ChangeChartRendererRector::class); + $rectorConfig->rule(AddRemovedDefaultValuesRector::class); + $rectorConfig->rule(ChangeConditionalReturnedCellRector::class); + $rectorConfig->rule(ChangeConditionalGetConditionRector::class); + $rectorConfig->rule(ChangeConditionalSetConditionRector::class); + $rectorConfig->rule(RemoveSetTempDirOnExcelWriterRector::class); + $rectorConfig->rule(ChangeDuplicateStyleArrayToApplyFromArrayRector::class); + $rectorConfig->rule(GetDefaultStyleToGetParentRector::class); + $rectorConfig->rule(IncreaseColumnIndexRector::class); # beware! this can be run only once, since its circular change - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [ + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ // https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#worksheetsetsharedstyle - new \Rector\Renaming\ValueObject\MethodCallRename('PHPExcel_Worksheet', 'setSharedStyle', 'duplicateStyle'), + new MethodCallRename('PHPExcel_Worksheet', 'setSharedStyle', 'duplicateStyle'), // https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#worksheetgetselectedcell - new \Rector\Renaming\ValueObject\MethodCallRename('PHPExcel_Worksheet', 'getSelectedCell', 'getSelectedCells'), + new MethodCallRename('PHPExcel_Worksheet', 'getSelectedCell', 'getSelectedCells'), // https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#cell-caching - new \Rector\Renaming\ValueObject\MethodCallRename('PHPExcel_Worksheet', 'getCellCacheController', 'getCellCollection'), - new \Rector\Renaming\ValueObject\MethodCallRename('PHPExcel_Worksheet', 'getCellCollection', 'getCoordinates'), + new MethodCallRename('PHPExcel_Worksheet', 'getCellCacheController', 'getCellCollection'), + new MethodCallRename('PHPExcel_Worksheet', 'getCellCollection', 'getCoordinates'), ]); - $configuration = [new \Rector\Renaming\ValueObject\RenameStaticMethod('PHPExcel_Shared_Date', 'ExcelToPHP', 'PHPExcel_Shared_Date', 'excelToTimestamp'), new \Rector\Renaming\ValueObject\RenameStaticMethod('PHPExcel_Shared_Date', 'ExcelToPHPObject', 'PHPExcel_Shared_Date', 'excelToDateTimeObject'), new \Rector\Renaming\ValueObject\RenameStaticMethod('PHPExcel_Shared_Date', 'FormattedPHPToExcel', 'PHPExcel_Shared_Date', 'formattedPHPToExcel'), new \Rector\Renaming\ValueObject\RenameStaticMethod('PHPExcel_Calculation_DateTime', 'DAYOFWEEK', 'PHPExcel_Calculation_DateTime', 'WEEKDAY'), new \Rector\Renaming\ValueObject\RenameStaticMethod('PHPExcel_Calculation_DateTime', 'WEEKOFYEAR', 'PHPExcel_Calculation_DateTime', 'WEEKNUCM'), new \Rector\Renaming\ValueObject\RenameStaticMethod('PHPExcel_Calculation_DateTime', 'SECONDOFMINUTE', 'PHPExcel_Calculation_DateTime', 'SECOND'), new \Rector\Renaming\ValueObject\RenameStaticMethod('PHPExcel_Calculation_DateTime', 'MINUTEOFHOUR', 'PHPExcel_Calculation_DateTime', 'MINUTE')]; - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\StaticCall\RenameStaticMethodRector::class, $configuration); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['PHPExcel' => 'PhpOffice\\PhpSpreadsheet\\Spreadsheet', 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DggContainer\\BstoreContainer\\BSE\\Blip', 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DgContainer\\SpgrContainer\\SpContainer', 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DggContainer\\BstoreContainer\\BSE', 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DgContainer\\SpgrContainer', 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DggContainer\\BstoreContainer', 'PHPExcel_Shared_OLE_PPS_File' => 'PhpOffice\\PhpSpreadsheet\\Shared\\OLE\\PPS\\File', 'PHPExcel_Shared_OLE_PPS_Root' => 'PhpOffice\\PhpSpreadsheet\\Shared\\OLE\\PPS\\Root', 'PHPExcel_Worksheet_AutoFilter_Column_Rule' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\AutoFilter\\Column\\Rule', 'PHPExcel_Writer_OpenDocument_Cell_Comment' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Cell\\Comment', 'PHPExcel_Calculation_Token_Stack' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Token\\Stack', 'PHPExcel_Chart_Renderer_jpgraph' => 'PhpOffice\\PhpSpreadsheet\\Chart\\Renderer\\JpGraph', 'PHPExcel_Reader_Excel5_Escher' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Xls\\Escher', 'PHPExcel_Reader_Excel5_MD5' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Xls\\MD5', 'PHPExcel_Reader_Excel5_RC4' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Xls\\RC4', 'PHPExcel_Reader_Excel2007_Chart' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Xlsx\\Chart', 'PHPExcel_Reader_Excel2007_Theme' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Xlsx\\Theme', 'PHPExcel_Shared_Escher_DgContainer' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DgContainer', 'PHPExcel_Shared_Escher_DggContainer' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DggContainer', 'CholeskyDecomposition' => 'PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\CholeskyDecomposition', 'EigenvalueDecomposition' => 'PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\EigenvalueDecomposition', 'PHPExcel_Shared_JAMA_LUDecomposition' => 'PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\LUDecomposition', 'PHPExcel_Shared_JAMA_Matrix' => 'PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\Matrix', 'QRDecomposition' => 'PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\QRDecomposition', 'PHPExcel_Shared_JAMA_QRDecomposition' => 'PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\QRDecomposition', 'SingularValueDecomposition' => 'PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\SingularValueDecomposition', 'PHPExcel_Shared_OLE_ChainedBlockStream' => 'PhpOffice\\PhpSpreadsheet\\Shared\\OLE\\ChainedBlockStream', 'PHPExcel_Shared_OLE_PPS' => 'PhpOffice\\PhpSpreadsheet\\Shared\\OLE\\PPS', 'PHPExcel_Best_Fit' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\BestFit', 'PHPExcel_Exponential_Best_Fit' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\ExponentialBestFit', 'PHPExcel_Linear_Best_Fit' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\LinearBestFit', 'PHPExcel_Logarithmic_Best_Fit' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\LogarithmicBestFit', 'polynomialBestFit' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\PolynomialBestFit', 'PHPExcel_Polynomial_Best_Fit' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\PolynomialBestFit', 'powerBestFit' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\PowerBestFit', 'PHPExcel_Power_Best_Fit' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\PowerBestFit', 'trendClass' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\Trend', 'PHPExcel_Worksheet_AutoFilter_Column' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\AutoFilter\\Column', 'PHPExcel_Worksheet_Drawing_Shadow' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\Drawing\\Shadow', 'PHPExcel_Writer_OpenDocument_Content' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Content', 'PHPExcel_Writer_OpenDocument_Meta' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Meta', 'PHPExcel_Writer_OpenDocument_MetaInf' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\MetaInf', 'PHPExcel_Writer_OpenDocument_Mimetype' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Mimetype', 'PHPExcel_Writer_OpenDocument_Settings' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Settings', 'PHPExcel_Writer_OpenDocument_Styles' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Styles', 'PHPExcel_Writer_OpenDocument_Thumbnails' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Thumbnails', 'PHPExcel_Writer_OpenDocument_WriterPart' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\WriterPart', 'PHPExcel_Writer_PDF_Core' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Pdf', 'PHPExcel_Writer_PDF_DomPDF' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Pdf\\Dompdf', 'PHPExcel_Writer_PDF_mPDF' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Pdf\\Mpdf', 'PHPExcel_Writer_PDF_tcPDF' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Pdf\\Tcpdf', 'PHPExcel_Writer_Excel5_BIFFwriter' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\BIFFwriter', 'PHPExcel_Writer_Excel5_Escher' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Escher', 'PHPExcel_Writer_Excel5_Font' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Font', 'PHPExcel_Writer_Excel5_Parser' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Parser', 'PHPExcel_Writer_Excel5_Workbook' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Workbook', 'PHPExcel_Writer_Excel5_Worksheet' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Worksheet', 'PHPExcel_Writer_Excel5_Xf' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Xf', 'PHPExcel_Writer_Excel2007_Chart' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Chart', 'PHPExcel_Writer_Excel2007_Comments' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Comments', 'PHPExcel_Writer_Excel2007_ContentTypes' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\ContentTypes', 'PHPExcel_Writer_Excel2007_DocProps' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\DocProps', 'PHPExcel_Writer_Excel2007_Drawing' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Drawing', 'PHPExcel_Writer_Excel2007_Rels' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Rels', 'PHPExcel_Writer_Excel2007_RelsRibbon' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\RelsRibbon', 'PHPExcel_Writer_Excel2007_RelsVBA' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\RelsVBA', 'PHPExcel_Writer_Excel2007_StringTable' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\StringTable', 'PHPExcel_Writer_Excel2007_Style' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Style', 'PHPExcel_Writer_Excel2007_Theme' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Theme', 'PHPExcel_Writer_Excel2007_Workbook' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Workbook', 'PHPExcel_Writer_Excel2007_Worksheet' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Worksheet', 'PHPExcel_Writer_Excel2007_WriterPart' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\WriterPart', 'PHPExcel_CachedObjectStorage_CacheBase' => 'PhpOffice\\PhpSpreadsheet\\Collection\\Cells', 'PHPExcel_CalcEngine_CyclicReferenceStack' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Engine\\CyclicReferenceStack', 'PHPExcel_CalcEngine_Logger' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Engine\\Logger', 'PHPExcel_Calculation_Functions' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Functions', 'PHPExcel_Calculation_Function' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Category', 'PHPExcel_Calculation_Database' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Database', 'PHPExcel_Calculation_DateTime' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\DateTime', 'PHPExcel_Calculation_Engineering' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Engineering', 'PHPExcel_Calculation_Exception' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Exception', 'PHPExcel_Calculation_ExceptionHandler' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\ExceptionHandler', 'PHPExcel_Calculation_Financial' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Financial', 'PHPExcel_Calculation_FormulaParser' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\FormulaParser', 'PHPExcel_Calculation_FormulaToken' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\FormulaToken', 'PHPExcel_Calculation_Logical' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Logical', 'PHPExcel_Calculation_LookupRef' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\LookupRef', 'PHPExcel_Calculation_MathTrig' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\MathTrig', 'PHPExcel_Calculation_Statistical' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Statistical', 'PHPExcel_Calculation_TextData' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\TextData', 'PHPExcel_Cell_AdvancedValueBinder' => 'PhpOffice\\PhpSpreadsheet\\Cell\\AdvancedValueBinder', 'PHPExcel_Cell_DataType' => 'PhpOffice\\PhpSpreadsheet\\Cell\\DataType', 'PHPExcel_Cell_DataValidation' => 'PhpOffice\\PhpSpreadsheet\\Cell\\DataValidation', 'PHPExcel_Cell_DefaultValueBinder' => 'PhpOffice\\PhpSpreadsheet\\Cell\\DefaultValueBinder', 'PHPExcel_Cell_Hyperlink' => 'PhpOffice\\PhpSpreadsheet\\Cell\\Hyperlink', 'PHPExcel_Cell_IValueBinder' => 'PhpOffice\\PhpSpreadsheet\\Cell\\IValueBinder', 'PHPExcel_Chart_Axis' => 'PhpOffice\\PhpSpreadsheet\\Chart\\Axis', 'PHPExcel_Chart_DataSeries' => 'PhpOffice\\PhpSpreadsheet\\Chart\\DataSeries', 'PHPExcel_Chart_DataSeriesValues' => 'PhpOffice\\PhpSpreadsheet\\Chart\\DataSeriesValues', 'PHPExcel_Chart_Exception' => 'PhpOffice\\PhpSpreadsheet\\Chart\\Exception', 'PHPExcel_Chart_GridLines' => 'PhpOffice\\PhpSpreadsheet\\Chart\\GridLines', 'PHPExcel_Chart_Layout' => 'PhpOffice\\PhpSpreadsheet\\Chart\\Layout', 'PHPExcel_Chart_Legend' => 'PhpOffice\\PhpSpreadsheet\\Chart\\Legend', 'PHPExcel_Chart_PlotArea' => 'PhpOffice\\PhpSpreadsheet\\Chart\\PlotArea', 'PHPExcel_Properties' => 'PhpOffice\\PhpSpreadsheet\\Chart\\Properties', 'PHPExcel_Chart_Title' => 'PhpOffice\\PhpSpreadsheet\\Chart\\Title', 'PHPExcel_DocumentProperties' => 'PhpOffice\\PhpSpreadsheet\\Document\\Properties', 'PHPExcel_DocumentSecurity' => 'PhpOffice\\PhpSpreadsheet\\Document\\Security', 'PHPExcel_Helper_HTML' => 'PhpOffice\\PhpSpreadsheet\\Helper\\Html', 'PHPExcel_Reader_Abstract' => 'PhpOffice\\PhpSpreadsheet\\Reader\\BaseReader', 'PHPExcel_Reader_CSV' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Csv', 'PHPExcel_Reader_DefaultReadFilter' => 'PhpOffice\\PhpSpreadsheet\\Reader\\DefaultReadFilter', 'PHPExcel_Reader_Excel2003XML' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Xml', 'PHPExcel_Reader_Exception' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Exception', 'PHPExcel_Reader_Gnumeric' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Gnumeric', 'PHPExcel_Reader_HTML' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Html', 'PHPExcel_Reader_IReadFilter' => 'PhpOffice\\PhpSpreadsheet\\Reader\\IReadFilter', 'PHPExcel_Reader_IReader' => 'PhpOffice\\PhpSpreadsheet\\Reader\\IReader', 'PHPExcel_Reader_OOCalc' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Ods', 'PHPExcel_Reader_SYLK' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Slk', 'PHPExcel_Reader_Excel5' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Xls', 'PHPExcel_Reader_Excel2007' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Xlsx', 'PHPExcel_RichText_ITextElement' => 'PhpOffice\\PhpSpreadsheet\\RichText\\ITextElement', 'PHPExcel_RichText_Run' => 'PhpOffice\\PhpSpreadsheet\\RichText\\Run', 'PHPExcel_RichText_TextElement' => 'PhpOffice\\PhpSpreadsheet\\RichText\\TextElement', 'PHPExcel_Shared_CodePage' => 'PhpOffice\\PhpSpreadsheet\\Shared\\CodePage', 'PHPExcel_Shared_Date' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Date', 'PHPExcel_Shared_Drawing' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Drawing', 'PHPExcel_Shared_Escher' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Escher', 'PHPExcel_Shared_File' => 'PhpOffice\\PhpSpreadsheet\\Shared\\File', 'PHPExcel_Shared_Font' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Font', 'PHPExcel_Shared_OLE' => 'PhpOffice\\PhpSpreadsheet\\Shared\\OLE', 'PHPExcel_Shared_OLERead' => 'PhpOffice\\PhpSpreadsheet\\Shared\\OLERead', 'PHPExcel_Shared_PasswordHasher' => 'PhpOffice\\PhpSpreadsheet\\Shared\\PasswordHasher', 'PHPExcel_Shared_String' => 'PhpOffice\\PhpSpreadsheet\\Shared\\StringHelper', 'PHPExcel_Shared_TimeZone' => 'PhpOffice\\PhpSpreadsheet\\Shared\\TimeZone', 'PHPExcel_Shared_XMLWriter' => 'PhpOffice\\PhpSpreadsheet\\Shared\\XMLWriter', 'PHPExcel_Shared_Excel5' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Xls', 'PHPExcel_Style_Alignment' => 'PhpOffice\\PhpSpreadsheet\\Style\\Alignment', 'PHPExcel_Style_Border' => 'PhpOffice\\PhpSpreadsheet\\Style\\Border', 'PHPExcel_Style_Borders' => 'PhpOffice\\PhpSpreadsheet\\Style\\Borders', 'PHPExcel_Style_Color' => 'PhpOffice\\PhpSpreadsheet\\Style\\Color', 'PHPExcel_Style_Conditional' => 'PhpOffice\\PhpSpreadsheet\\Style\\Conditional', 'PHPExcel_Style_Fill' => 'PhpOffice\\PhpSpreadsheet\\Style\\Fill', 'PHPExcel_Style_Font' => 'PhpOffice\\PhpSpreadsheet\\Style\\Font', 'PHPExcel_Style_NumberFormat' => 'PhpOffice\\PhpSpreadsheet\\Style\\NumberFormat', 'PHPExcel_Style_Protection' => 'PhpOffice\\PhpSpreadsheet\\Style\\Protection', 'PHPExcel_Style_Supervisor' => 'PhpOffice\\PhpSpreadsheet\\Style\\Supervisor', 'PHPExcel_Worksheet_AutoFilter' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\AutoFilter', 'PHPExcel_Worksheet_BaseDrawing' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\BaseDrawing', 'PHPExcel_Worksheet_CellIterator' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\CellIterator', 'PHPExcel_Worksheet_Column' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\Column', 'PHPExcel_Worksheet_ColumnCellIterator' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\ColumnCellIterator', 'PHPExcel_Worksheet_ColumnDimension' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\ColumnDimension', 'PHPExcel_Worksheet_ColumnIterator' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\ColumnIterator', 'PHPExcel_Worksheet_Drawing' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\Drawing', 'PHPExcel_Worksheet_HeaderFooter' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\HeaderFooter', 'PHPExcel_Worksheet_HeaderFooterDrawing' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\HeaderFooterDrawing', 'PHPExcel_WorksheetIterator' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\Iterator', 'PHPExcel_Worksheet_MemoryDrawing' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\MemoryDrawing', 'PHPExcel_Worksheet_PageMargins' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\PageMargins', 'PHPExcel_Worksheet_PageSetup' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\PageSetup', 'PHPExcel_Worksheet_Protection' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\Protection', 'PHPExcel_Worksheet_Row' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\Row', 'PHPExcel_Worksheet_RowCellIterator' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\RowCellIterator', 'PHPExcel_Worksheet_RowDimension' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\RowDimension', 'PHPExcel_Worksheet_RowIterator' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\RowIterator', 'PHPExcel_Worksheet_SheetView' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\SheetView', 'PHPExcel_Writer_Abstract' => 'PhpOffice\\PhpSpreadsheet\\Writer\\BaseWriter', 'PHPExcel_Writer_CSV' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Csv', 'PHPExcel_Writer_Exception' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Exception', 'PHPExcel_Writer_HTML' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Html', 'PHPExcel_Writer_IWriter' => 'PhpOffice\\PhpSpreadsheet\\Writer\\IWriter', 'PHPExcel_Writer_OpenDocument' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Ods', 'PHPExcel_Writer_PDF' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Pdf', 'PHPExcel_Writer_Excel5' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xls', 'PHPExcel_Writer_Excel2007' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx', 'PHPExcel_CachedObjectStorageFactory' => 'PhpOffice\\PhpSpreadsheet\\Collection\\CellsFactory', 'PHPExcel_Calculation' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Calculation', 'PHPExcel_Cell' => 'PhpOffice\\PhpSpreadsheet\\Cell\\Cell', 'PHPExcel_Chart' => 'PhpOffice\\PhpSpreadsheet\\Chart\\Chart', 'PHPExcel_Comment' => 'PhpOffice\\PhpSpreadsheet\\Comment', 'PHPExcel_Exception' => 'PhpOffice\\PhpSpreadsheet\\Exception', 'PHPExcel_HashTable' => 'PhpOffice\\PhpSpreadsheet\\HashTable', 'PHPExcel_IComparable' => 'PhpOffice\\PhpSpreadsheet\\IComparable', 'PHPExcel_IOFactory' => 'PhpOffice\\PhpSpreadsheet\\IOFactory', 'PHPExcel_NamedRange' => 'PhpOffice\\PhpSpreadsheet\\NamedRange', 'PHPExcel_ReferenceHelper' => 'PhpOffice\\PhpSpreadsheet\\ReferenceHelper', 'PHPExcel_RichText' => 'PhpOffice\\PhpSpreadsheet\\RichText\\RichText', 'PHPExcel_Settings' => 'PhpOffice\\PhpSpreadsheet\\Settings', 'PHPExcel_Style' => 'PhpOffice\\PhpSpreadsheet\\Style\\Style', 'PHPExcel_Worksheet' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\Worksheet']); - $rectorConfig->rule(\Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector::class); + $configuration = [new RenameStaticMethod('PHPExcel_Shared_Date', 'ExcelToPHP', 'PHPExcel_Shared_Date', 'excelToTimestamp'), new RenameStaticMethod('PHPExcel_Shared_Date', 'ExcelToPHPObject', 'PHPExcel_Shared_Date', 'excelToDateTimeObject'), new RenameStaticMethod('PHPExcel_Shared_Date', 'FormattedPHPToExcel', 'PHPExcel_Shared_Date', 'formattedPHPToExcel'), new RenameStaticMethod('PHPExcel_Calculation_DateTime', 'DAYOFWEEK', 'PHPExcel_Calculation_DateTime', 'WEEKDAY'), new RenameStaticMethod('PHPExcel_Calculation_DateTime', 'WEEKOFYEAR', 'PHPExcel_Calculation_DateTime', 'WEEKNUCM'), new RenameStaticMethod('PHPExcel_Calculation_DateTime', 'SECONDOFMINUTE', 'PHPExcel_Calculation_DateTime', 'SECOND'), new RenameStaticMethod('PHPExcel_Calculation_DateTime', 'MINUTEOFHOUR', 'PHPExcel_Calculation_DateTime', 'MINUTE')]; + $rectorConfig->ruleWithConfiguration(RenameStaticMethodRector::class, $configuration); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['PHPExcel' => 'PhpOffice\\PhpSpreadsheet\\Spreadsheet', 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DggContainer\\BstoreContainer\\BSE\\Blip', 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DgContainer\\SpgrContainer\\SpContainer', 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DggContainer\\BstoreContainer\\BSE', 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DgContainer\\SpgrContainer', 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DggContainer\\BstoreContainer', 'PHPExcel_Shared_OLE_PPS_File' => 'PhpOffice\\PhpSpreadsheet\\Shared\\OLE\\PPS\\File', 'PHPExcel_Shared_OLE_PPS_Root' => 'PhpOffice\\PhpSpreadsheet\\Shared\\OLE\\PPS\\Root', 'PHPExcel_Worksheet_AutoFilter_Column_Rule' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\AutoFilter\\Column\\Rule', 'PHPExcel_Writer_OpenDocument_Cell_Comment' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Cell\\Comment', 'PHPExcel_Calculation_Token_Stack' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Token\\Stack', 'PHPExcel_Chart_Renderer_jpgraph' => 'PhpOffice\\PhpSpreadsheet\\Chart\\Renderer\\JpGraph', 'PHPExcel_Reader_Excel5_Escher' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Xls\\Escher', 'PHPExcel_Reader_Excel5_MD5' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Xls\\MD5', 'PHPExcel_Reader_Excel5_RC4' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Xls\\RC4', 'PHPExcel_Reader_Excel2007_Chart' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Xlsx\\Chart', 'PHPExcel_Reader_Excel2007_Theme' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Xlsx\\Theme', 'PHPExcel_Shared_Escher_DgContainer' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DgContainer', 'PHPExcel_Shared_Escher_DggContainer' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DggContainer', 'CholeskyDecomposition' => 'PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\CholeskyDecomposition', 'EigenvalueDecomposition' => 'PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\EigenvalueDecomposition', 'PHPExcel_Shared_JAMA_LUDecomposition' => 'PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\LUDecomposition', 'PHPExcel_Shared_JAMA_Matrix' => 'PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\Matrix', 'QRDecomposition' => 'PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\QRDecomposition', 'PHPExcel_Shared_JAMA_QRDecomposition' => 'PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\QRDecomposition', 'SingularValueDecomposition' => 'PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\SingularValueDecomposition', 'PHPExcel_Shared_OLE_ChainedBlockStream' => 'PhpOffice\\PhpSpreadsheet\\Shared\\OLE\\ChainedBlockStream', 'PHPExcel_Shared_OLE_PPS' => 'PhpOffice\\PhpSpreadsheet\\Shared\\OLE\\PPS', 'PHPExcel_Best_Fit' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\BestFit', 'PHPExcel_Exponential_Best_Fit' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\ExponentialBestFit', 'PHPExcel_Linear_Best_Fit' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\LinearBestFit', 'PHPExcel_Logarithmic_Best_Fit' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\LogarithmicBestFit', 'polynomialBestFit' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\PolynomialBestFit', 'PHPExcel_Polynomial_Best_Fit' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\PolynomialBestFit', 'powerBestFit' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\PowerBestFit', 'PHPExcel_Power_Best_Fit' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\PowerBestFit', 'trendClass' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\Trend', 'PHPExcel_Worksheet_AutoFilter_Column' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\AutoFilter\\Column', 'PHPExcel_Worksheet_Drawing_Shadow' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\Drawing\\Shadow', 'PHPExcel_Writer_OpenDocument_Content' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Content', 'PHPExcel_Writer_OpenDocument_Meta' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Meta', 'PHPExcel_Writer_OpenDocument_MetaInf' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\MetaInf', 'PHPExcel_Writer_OpenDocument_Mimetype' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Mimetype', 'PHPExcel_Writer_OpenDocument_Settings' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Settings', 'PHPExcel_Writer_OpenDocument_Styles' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Styles', 'PHPExcel_Writer_OpenDocument_Thumbnails' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Thumbnails', 'PHPExcel_Writer_OpenDocument_WriterPart' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\WriterPart', 'PHPExcel_Writer_PDF_Core' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Pdf', 'PHPExcel_Writer_PDF_DomPDF' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Pdf\\Dompdf', 'PHPExcel_Writer_PDF_mPDF' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Pdf\\Mpdf', 'PHPExcel_Writer_PDF_tcPDF' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Pdf\\Tcpdf', 'PHPExcel_Writer_Excel5_BIFFwriter' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\BIFFwriter', 'PHPExcel_Writer_Excel5_Escher' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Escher', 'PHPExcel_Writer_Excel5_Font' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Font', 'PHPExcel_Writer_Excel5_Parser' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Parser', 'PHPExcel_Writer_Excel5_Workbook' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Workbook', 'PHPExcel_Writer_Excel5_Worksheet' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Worksheet', 'PHPExcel_Writer_Excel5_Xf' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Xf', 'PHPExcel_Writer_Excel2007_Chart' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Chart', 'PHPExcel_Writer_Excel2007_Comments' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Comments', 'PHPExcel_Writer_Excel2007_ContentTypes' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\ContentTypes', 'PHPExcel_Writer_Excel2007_DocProps' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\DocProps', 'PHPExcel_Writer_Excel2007_Drawing' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Drawing', 'PHPExcel_Writer_Excel2007_Rels' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Rels', 'PHPExcel_Writer_Excel2007_RelsRibbon' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\RelsRibbon', 'PHPExcel_Writer_Excel2007_RelsVBA' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\RelsVBA', 'PHPExcel_Writer_Excel2007_StringTable' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\StringTable', 'PHPExcel_Writer_Excel2007_Style' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Style', 'PHPExcel_Writer_Excel2007_Theme' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Theme', 'PHPExcel_Writer_Excel2007_Workbook' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Workbook', 'PHPExcel_Writer_Excel2007_Worksheet' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Worksheet', 'PHPExcel_Writer_Excel2007_WriterPart' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\WriterPart', 'PHPExcel_CachedObjectStorage_CacheBase' => 'PhpOffice\\PhpSpreadsheet\\Collection\\Cells', 'PHPExcel_CalcEngine_CyclicReferenceStack' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Engine\\CyclicReferenceStack', 'PHPExcel_CalcEngine_Logger' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Engine\\Logger', 'PHPExcel_Calculation_Functions' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Functions', 'PHPExcel_Calculation_Function' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Category', 'PHPExcel_Calculation_Database' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Database', 'PHPExcel_Calculation_DateTime' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\DateTime', 'PHPExcel_Calculation_Engineering' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Engineering', 'PHPExcel_Calculation_Exception' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Exception', 'PHPExcel_Calculation_ExceptionHandler' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\ExceptionHandler', 'PHPExcel_Calculation_Financial' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Financial', 'PHPExcel_Calculation_FormulaParser' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\FormulaParser', 'PHPExcel_Calculation_FormulaToken' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\FormulaToken', 'PHPExcel_Calculation_Logical' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Logical', 'PHPExcel_Calculation_LookupRef' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\LookupRef', 'PHPExcel_Calculation_MathTrig' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\MathTrig', 'PHPExcel_Calculation_Statistical' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Statistical', 'PHPExcel_Calculation_TextData' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\TextData', 'PHPExcel_Cell_AdvancedValueBinder' => 'PhpOffice\\PhpSpreadsheet\\Cell\\AdvancedValueBinder', 'PHPExcel_Cell_DataType' => 'PhpOffice\\PhpSpreadsheet\\Cell\\DataType', 'PHPExcel_Cell_DataValidation' => 'PhpOffice\\PhpSpreadsheet\\Cell\\DataValidation', 'PHPExcel_Cell_DefaultValueBinder' => 'PhpOffice\\PhpSpreadsheet\\Cell\\DefaultValueBinder', 'PHPExcel_Cell_Hyperlink' => 'PhpOffice\\PhpSpreadsheet\\Cell\\Hyperlink', 'PHPExcel_Cell_IValueBinder' => 'PhpOffice\\PhpSpreadsheet\\Cell\\IValueBinder', 'PHPExcel_Chart_Axis' => 'PhpOffice\\PhpSpreadsheet\\Chart\\Axis', 'PHPExcel_Chart_DataSeries' => 'PhpOffice\\PhpSpreadsheet\\Chart\\DataSeries', 'PHPExcel_Chart_DataSeriesValues' => 'PhpOffice\\PhpSpreadsheet\\Chart\\DataSeriesValues', 'PHPExcel_Chart_Exception' => 'PhpOffice\\PhpSpreadsheet\\Chart\\Exception', 'PHPExcel_Chart_GridLines' => 'PhpOffice\\PhpSpreadsheet\\Chart\\GridLines', 'PHPExcel_Chart_Layout' => 'PhpOffice\\PhpSpreadsheet\\Chart\\Layout', 'PHPExcel_Chart_Legend' => 'PhpOffice\\PhpSpreadsheet\\Chart\\Legend', 'PHPExcel_Chart_PlotArea' => 'PhpOffice\\PhpSpreadsheet\\Chart\\PlotArea', 'PHPExcel_Properties' => 'PhpOffice\\PhpSpreadsheet\\Chart\\Properties', 'PHPExcel_Chart_Title' => 'PhpOffice\\PhpSpreadsheet\\Chart\\Title', 'PHPExcel_DocumentProperties' => 'PhpOffice\\PhpSpreadsheet\\Document\\Properties', 'PHPExcel_DocumentSecurity' => 'PhpOffice\\PhpSpreadsheet\\Document\\Security', 'PHPExcel_Helper_HTML' => 'PhpOffice\\PhpSpreadsheet\\Helper\\Html', 'PHPExcel_Reader_Abstract' => 'PhpOffice\\PhpSpreadsheet\\Reader\\BaseReader', 'PHPExcel_Reader_CSV' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Csv', 'PHPExcel_Reader_DefaultReadFilter' => 'PhpOffice\\PhpSpreadsheet\\Reader\\DefaultReadFilter', 'PHPExcel_Reader_Excel2003XML' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Xml', 'PHPExcel_Reader_Exception' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Exception', 'PHPExcel_Reader_Gnumeric' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Gnumeric', 'PHPExcel_Reader_HTML' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Html', 'PHPExcel_Reader_IReadFilter' => 'PhpOffice\\PhpSpreadsheet\\Reader\\IReadFilter', 'PHPExcel_Reader_IReader' => 'PhpOffice\\PhpSpreadsheet\\Reader\\IReader', 'PHPExcel_Reader_OOCalc' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Ods', 'PHPExcel_Reader_SYLK' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Slk', 'PHPExcel_Reader_Excel5' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Xls', 'PHPExcel_Reader_Excel2007' => 'PhpOffice\\PhpSpreadsheet\\Reader\\Xlsx', 'PHPExcel_RichText_ITextElement' => 'PhpOffice\\PhpSpreadsheet\\RichText\\ITextElement', 'PHPExcel_RichText_Run' => 'PhpOffice\\PhpSpreadsheet\\RichText\\Run', 'PHPExcel_RichText_TextElement' => 'PhpOffice\\PhpSpreadsheet\\RichText\\TextElement', 'PHPExcel_Shared_CodePage' => 'PhpOffice\\PhpSpreadsheet\\Shared\\CodePage', 'PHPExcel_Shared_Date' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Date', 'PHPExcel_Shared_Drawing' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Drawing', 'PHPExcel_Shared_Escher' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Escher', 'PHPExcel_Shared_File' => 'PhpOffice\\PhpSpreadsheet\\Shared\\File', 'PHPExcel_Shared_Font' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Font', 'PHPExcel_Shared_OLE' => 'PhpOffice\\PhpSpreadsheet\\Shared\\OLE', 'PHPExcel_Shared_OLERead' => 'PhpOffice\\PhpSpreadsheet\\Shared\\OLERead', 'PHPExcel_Shared_PasswordHasher' => 'PhpOffice\\PhpSpreadsheet\\Shared\\PasswordHasher', 'PHPExcel_Shared_String' => 'PhpOffice\\PhpSpreadsheet\\Shared\\StringHelper', 'PHPExcel_Shared_TimeZone' => 'PhpOffice\\PhpSpreadsheet\\Shared\\TimeZone', 'PHPExcel_Shared_XMLWriter' => 'PhpOffice\\PhpSpreadsheet\\Shared\\XMLWriter', 'PHPExcel_Shared_Excel5' => 'PhpOffice\\PhpSpreadsheet\\Shared\\Xls', 'PHPExcel_Style_Alignment' => 'PhpOffice\\PhpSpreadsheet\\Style\\Alignment', 'PHPExcel_Style_Border' => 'PhpOffice\\PhpSpreadsheet\\Style\\Border', 'PHPExcel_Style_Borders' => 'PhpOffice\\PhpSpreadsheet\\Style\\Borders', 'PHPExcel_Style_Color' => 'PhpOffice\\PhpSpreadsheet\\Style\\Color', 'PHPExcel_Style_Conditional' => 'PhpOffice\\PhpSpreadsheet\\Style\\Conditional', 'PHPExcel_Style_Fill' => 'PhpOffice\\PhpSpreadsheet\\Style\\Fill', 'PHPExcel_Style_Font' => 'PhpOffice\\PhpSpreadsheet\\Style\\Font', 'PHPExcel_Style_NumberFormat' => 'PhpOffice\\PhpSpreadsheet\\Style\\NumberFormat', 'PHPExcel_Style_Protection' => 'PhpOffice\\PhpSpreadsheet\\Style\\Protection', 'PHPExcel_Style_Supervisor' => 'PhpOffice\\PhpSpreadsheet\\Style\\Supervisor', 'PHPExcel_Worksheet_AutoFilter' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\AutoFilter', 'PHPExcel_Worksheet_BaseDrawing' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\BaseDrawing', 'PHPExcel_Worksheet_CellIterator' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\CellIterator', 'PHPExcel_Worksheet_Column' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\Column', 'PHPExcel_Worksheet_ColumnCellIterator' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\ColumnCellIterator', 'PHPExcel_Worksheet_ColumnDimension' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\ColumnDimension', 'PHPExcel_Worksheet_ColumnIterator' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\ColumnIterator', 'PHPExcel_Worksheet_Drawing' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\Drawing', 'PHPExcel_Worksheet_HeaderFooter' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\HeaderFooter', 'PHPExcel_Worksheet_HeaderFooterDrawing' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\HeaderFooterDrawing', 'PHPExcel_WorksheetIterator' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\Iterator', 'PHPExcel_Worksheet_MemoryDrawing' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\MemoryDrawing', 'PHPExcel_Worksheet_PageMargins' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\PageMargins', 'PHPExcel_Worksheet_PageSetup' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\PageSetup', 'PHPExcel_Worksheet_Protection' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\Protection', 'PHPExcel_Worksheet_Row' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\Row', 'PHPExcel_Worksheet_RowCellIterator' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\RowCellIterator', 'PHPExcel_Worksheet_RowDimension' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\RowDimension', 'PHPExcel_Worksheet_RowIterator' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\RowIterator', 'PHPExcel_Worksheet_SheetView' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\SheetView', 'PHPExcel_Writer_Abstract' => 'PhpOffice\\PhpSpreadsheet\\Writer\\BaseWriter', 'PHPExcel_Writer_CSV' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Csv', 'PHPExcel_Writer_Exception' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Exception', 'PHPExcel_Writer_HTML' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Html', 'PHPExcel_Writer_IWriter' => 'PhpOffice\\PhpSpreadsheet\\Writer\\IWriter', 'PHPExcel_Writer_OpenDocument' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Ods', 'PHPExcel_Writer_PDF' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Pdf', 'PHPExcel_Writer_Excel5' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xls', 'PHPExcel_Writer_Excel2007' => 'PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx', 'PHPExcel_CachedObjectStorageFactory' => 'PhpOffice\\PhpSpreadsheet\\Collection\\CellsFactory', 'PHPExcel_Calculation' => 'PhpOffice\\PhpSpreadsheet\\Calculation\\Calculation', 'PHPExcel_Cell' => 'PhpOffice\\PhpSpreadsheet\\Cell\\Cell', 'PHPExcel_Chart' => 'PhpOffice\\PhpSpreadsheet\\Chart\\Chart', 'PHPExcel_Comment' => 'PhpOffice\\PhpSpreadsheet\\Comment', 'PHPExcel_Exception' => 'PhpOffice\\PhpSpreadsheet\\Exception', 'PHPExcel_HashTable' => 'PhpOffice\\PhpSpreadsheet\\HashTable', 'PHPExcel_IComparable' => 'PhpOffice\\PhpSpreadsheet\\IComparable', 'PHPExcel_IOFactory' => 'PhpOffice\\PhpSpreadsheet\\IOFactory', 'PHPExcel_NamedRange' => 'PhpOffice\\PhpSpreadsheet\\NamedRange', 'PHPExcel_ReferenceHelper' => 'PhpOffice\\PhpSpreadsheet\\ReferenceHelper', 'PHPExcel_RichText' => 'PhpOffice\\PhpSpreadsheet\\RichText\\RichText', 'PHPExcel_Settings' => 'PhpOffice\\PhpSpreadsheet\\Settings', 'PHPExcel_Style' => 'PhpOffice\\PhpSpreadsheet\\Style\\Style', 'PHPExcel_Worksheet' => 'PhpOffice\\PhpSpreadsheet\\Worksheet\\Worksheet']); + $rectorConfig->rule(RemoveExtraParametersRector::class); }; diff --git a/vendor/rector/rector-phpoffice/monorepo-builder.php b/vendor/rector/rector-phpoffice/monorepo-builder.php index e4e22301995..544f64366de 100644 --- a/vendor/rector/rector-phpoffice/monorepo-builder.php +++ b/vendor/rector/rector-phpoffice/monorepo-builder.php @@ -3,12 +3,12 @@ declare (strict_types=1); namespace RectorPrefix20220607; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\PushTagReleaseWorker; use RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\TagVersionReleaseWorker; -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +return static function (ContainerConfigurator $containerConfigurator) : void { $services = $containerConfigurator->services(); // @see https://github.com/symplify/monorepo-builder#6-release-flow - $services->set(\RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\TagVersionReleaseWorker::class); - $services->set(\RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\PushTagReleaseWorker::class); + $services->set(TagVersionReleaseWorker::class); + $services->set(PushTagReleaseWorker::class); }; diff --git a/vendor/rector/rector-phpoffice/rector.php b/vendor/rector/rector-phpoffice/rector.php index 47215fbddf0..fa1a539ca88 100644 --- a/vendor/rector/rector-phpoffice/rector.php +++ b/vendor/rector/rector-phpoffice/rector.php @@ -7,10 +7,10 @@ use Rector\Config\RectorConfig; use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_81, \Rector\Set\ValueObject\SetList::CODE_QUALITY, \Rector\Set\ValueObject\SetList::DEAD_CODE, \Rector\Set\ValueObject\SetList::NAMING]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([LevelSetList::UP_TO_PHP_81, SetList::CODE_QUALITY, SetList::DEAD_CODE, SetList::NAMING]); $rectorConfig->importNames(); $rectorConfig->paths([__DIR__ . '/src', __DIR__ . '/tests']); - $rectorConfig->skip([\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class => [__DIR__ . '/config']]); + $rectorConfig->skip([StringClassNameToClassConstantRector::class => [__DIR__ . '/config']]); $rectorConfig->parallel(); }; diff --git a/vendor/rector/rector-phpoffice/src/Rector/MethodCall/ChangeConditionalGetConditionRector.php b/vendor/rector/rector-phpoffice/src/Rector/MethodCall/ChangeConditionalGetConditionRector.php index dbcf7d075c3..2a786c89418 100644 --- a/vendor/rector/rector-phpoffice/src/Rector/MethodCall/ChangeConditionalGetConditionRector.php +++ b/vendor/rector/rector-phpoffice/src/Rector/MethodCall/ChangeConditionalGetConditionRector.php @@ -12,18 +12,18 @@ use PhpParser\Node\Scalar\LNumber; use PhpParser\Node\Scalar\String_; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#conditionalgetcondition * * @see \Rector\PHPOffice\Tests\Rector\MethodCall\ChangeConditionalGetConditionRector\ChangeConditionalGetConditionRectorTest */ -final class ChangeConditionalGetConditionRector extends \Rector\Core\Rector\AbstractRector +final class ChangeConditionalGetConditionRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change argument PHPExcel_Style_Conditional->getCondition() to getConditions()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change argument PHPExcel_Style_Conditional->getCondition() to getConditions()', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run(): void @@ -50,21 +50,21 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('PHPExcel_Style_Conditional'))) { + if (!$this->isObjectType($node->var, new ObjectType('PHPExcel_Style_Conditional'))) { return null; } if (!$this->isName($node->name, 'getCondition')) { return null; } - $node->name = new \PhpParser\Node\Identifier('getConditions'); - $arrayDimFetch = new \PhpParser\Node\Expr\ArrayDimFetch($node, new \PhpParser\Node\Scalar\LNumber(0)); - return new \PhpParser\Node\Expr\BinaryOp\Coalesce($arrayDimFetch, new \PhpParser\Node\Scalar\String_('')); + $node->name = new Identifier('getConditions'); + $arrayDimFetch = new ArrayDimFetch($node, new LNumber(0)); + return new Coalesce($arrayDimFetch, new String_('')); } } diff --git a/vendor/rector/rector-phpoffice/src/Rector/MethodCall/ChangeConditionalReturnedCellRector.php b/vendor/rector/rector-phpoffice/src/Rector/MethodCall/ChangeConditionalReturnedCellRector.php index 109776b9d92..6c25284213f 100644 --- a/vendor/rector/rector-phpoffice/src/Rector/MethodCall/ChangeConditionalReturnedCellRector.php +++ b/vendor/rector/rector-phpoffice/src/Rector/MethodCall/ChangeConditionalReturnedCellRector.php @@ -9,14 +9,14 @@ use PhpParser\Node\Identifier; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\PHPOffice\ValueObject\ConditionalSetValue; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#dropped-conditionally-returned-cell * * @see \Rector\PHPOffice\Tests\Rector\MethodCall\ChangeConditionalReturnedCellRector\ChangeConditionalReturnedCellRectorTest */ -final class ChangeConditionalReturnedCellRector extends \Rector\Core\Rector\AbstractRector +final class ChangeConditionalReturnedCellRector extends AbstractRector { /** * @var ConditionalSetValue[] @@ -24,14 +24,14 @@ final class ChangeConditionalReturnedCellRector extends \Rector\Core\Rector\Abst private $conditionalSetValues = []; public function __construct() { - $this->conditionalSetValues[] = new \Rector\PHPOffice\ValueObject\ConditionalSetValue('setCellValue', 'getCell', 'setValue', 2, \false); - $this->conditionalSetValues[] = new \Rector\PHPOffice\ValueObject\ConditionalSetValue('setCellValueByColumnAndRow', 'getCellByColumnAndRow', 'setValue', 3, \true); - $this->conditionalSetValues[] = new \Rector\PHPOffice\ValueObject\ConditionalSetValue('setCellValueExplicit', 'getCell', 'setValueExplicit', 3, \false); - $this->conditionalSetValues[] = new \Rector\PHPOffice\ValueObject\ConditionalSetValue('setCellValueExplicitByColumnAndRow', 'getCellByColumnAndRow', 'setValueExplicit', 4, \true); + $this->conditionalSetValues[] = new ConditionalSetValue('setCellValue', 'getCell', 'setValue', 2, \false); + $this->conditionalSetValues[] = new ConditionalSetValue('setCellValueByColumnAndRow', 'getCellByColumnAndRow', 'setValue', 3, \true); + $this->conditionalSetValues[] = new ConditionalSetValue('setCellValueExplicit', 'getCell', 'setValueExplicit', 3, \false); + $this->conditionalSetValues[] = new ConditionalSetValue('setCellValueExplicitByColumnAndRow', 'getCellByColumnAndRow', 'setValueExplicit', 4, \true); } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change conditional call to getCell()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change conditional call to getCell()', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run(): void @@ -58,14 +58,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('PHPExcel_Worksheet'))) { + if (!$this->isObjectType($node->var, new ObjectType('PHPExcel_Worksheet'))) { return null; } foreach ($this->conditionalSetValues as $conditionalSetValue) { @@ -85,10 +85,10 @@ CODE_SAMPLE unset($args[1]); } $variable = clone $node->var; - $getCellMethodCall = new \PhpParser\Node\Expr\MethodCall($variable, $conditionalSetValue->getNewGetMethod(), $locationArgs); + $getCellMethodCall = new MethodCall($variable, $conditionalSetValue->getNewGetMethod(), $locationArgs); $node->var = $getCellMethodCall; $node->args = \array_values($args); - $node->name = new \PhpParser\Node\Identifier($conditionalSetValue->getNewSetMethod()); + $node->name = new Identifier($conditionalSetValue->getNewSetMethod()); return $node; } return null; diff --git a/vendor/rector/rector-phpoffice/src/Rector/MethodCall/ChangeConditionalSetConditionRector.php b/vendor/rector/rector-phpoffice/src/Rector/MethodCall/ChangeConditionalSetConditionRector.php index a881a426c8c..59abc5e6864 100644 --- a/vendor/rector/rector-phpoffice/src/Rector/MethodCall/ChangeConditionalSetConditionRector.php +++ b/vendor/rector/rector-phpoffice/src/Rector/MethodCall/ChangeConditionalSetConditionRector.php @@ -10,18 +10,18 @@ use PhpParser\Node\Identifier; use PHPStan\Type\ArrayType; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#conditionalsetcondition * * @see \Rector\PHPOffice\Tests\Rector\MethodCall\ChangeConditionalSetConditionRector\ChangeConditionalSetConditionRectorTest */ -final class ChangeConditionalSetConditionRector extends \Rector\Core\Rector\AbstractRector +final class ChangeConditionalSetConditionRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change argument PHPExcel_Style_Conditional->setCondition() to setConditions()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change argument PHPExcel_Style_Conditional->setCondition() to setConditions()', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run(): void @@ -48,31 +48,31 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('PHPExcel_Style_Conditional'))) { + if (!$this->isObjectType($node->var, new ObjectType('PHPExcel_Style_Conditional'))) { return null; } if (!$this->isName($node->name, 'setCondition')) { return null; } - $node->name = new \PhpParser\Node\Identifier('setConditions'); + $node->name = new Identifier('setConditions'); $this->castArgumentToArrayIfNotArrayType($node); return $node; } - private function castArgumentToArrayIfNotArrayType(\PhpParser\Node\Expr\MethodCall $methodCall) : void + private function castArgumentToArrayIfNotArrayType(MethodCall $methodCall) : void { $firstArgumentValue = $methodCall->args[0]->value; $firstArgumentStaticType = $this->getType($firstArgumentValue); - if ($firstArgumentStaticType instanceof \PHPStan\Type\ArrayType) { + if ($firstArgumentStaticType instanceof ArrayType) { return; } // cast to array if not an array - $methodCall->args[0]->value = new \PhpParser\Node\Expr\Cast\Array_($firstArgumentValue); + $methodCall->args[0]->value = new Array_($firstArgumentValue); } } diff --git a/vendor/rector/rector-phpoffice/src/Rector/MethodCall/ChangeDuplicateStyleArrayToApplyFromArrayRector.php b/vendor/rector/rector-phpoffice/src/Rector/MethodCall/ChangeDuplicateStyleArrayToApplyFromArrayRector.php index 50084bbef7d..27a3690d717 100644 --- a/vendor/rector/rector-phpoffice/src/Rector/MethodCall/ChangeDuplicateStyleArrayToApplyFromArrayRector.php +++ b/vendor/rector/rector-phpoffice/src/Rector/MethodCall/ChangeDuplicateStyleArrayToApplyFromArrayRector.php @@ -8,18 +8,18 @@ use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Identifier; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#removed-deprecated-things * * @see \Rector\PHPOffice\Tests\Rector\MethodCall\ChangeDuplicateStyleArrayToApplyFromArrayRector\ChangeDuplicateStyleArrayToApplyFromArrayRectorTest */ -final class ChangeDuplicateStyleArrayToApplyFromArrayRector extends \Rector\Core\Rector\AbstractRector +final class ChangeDuplicateStyleArrayToApplyFromArrayRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change method call duplicateStyleArray() to getStyle() + applyFromArray()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change method call duplicateStyleArray() to getStyle() + applyFromArray()', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run(): void @@ -46,14 +46,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('PHPExcel_Worksheet'))) { + if (!$this->isObjectType($node->var, new ObjectType('PHPExcel_Worksheet'))) { return null; } if (!$this->nodeNameResolver->isName($node->name, 'duplicateStyleArray')) { @@ -63,9 +63,9 @@ CODE_SAMPLE // pop out 2nd argument $secondArgument = $node->args[1]; unset($node->args[1]); - $getStyleMethodCall = new \PhpParser\Node\Expr\MethodCall($variable, 'getStyle', [$secondArgument]); + $getStyleMethodCall = new MethodCall($variable, 'getStyle', [$secondArgument]); $node->var = $getStyleMethodCall; - $node->name = new \PhpParser\Node\Identifier('applyFromArray'); + $node->name = new Identifier('applyFromArray'); return $node; } } diff --git a/vendor/rector/rector-phpoffice/src/Rector/MethodCall/GetDefaultStyleToGetParentRector.php b/vendor/rector/rector-phpoffice/src/Rector/MethodCall/GetDefaultStyleToGetParentRector.php index 166212c8027..c636f66d601 100644 --- a/vendor/rector/rector-phpoffice/src/Rector/MethodCall/GetDefaultStyleToGetParentRector.php +++ b/vendor/rector/rector-phpoffice/src/Rector/MethodCall/GetDefaultStyleToGetParentRector.php @@ -7,18 +7,18 @@ use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#dedicated-class-to-manipulate-coordinates * * @see \Rector\PHPOffice\Tests\Rector\MethodCall\GetDefaultStyleToGetParentRector\GetDefaultStyleToGetParentRectorTest */ -final class GetDefaultStyleToGetParentRector extends \Rector\Core\Rector\AbstractRector +final class GetDefaultStyleToGetParentRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Methods to (new Worksheet())->getDefaultStyle() to getParent()->getDefaultStyle()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Methods to (new Worksheet())->getDefaultStyle() to getParent()->getDefaultStyle()', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -45,21 +45,21 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('PHPExcel_Worksheet'))) { + if (!$this->isObjectType($node->var, new ObjectType('PHPExcel_Worksheet'))) { return null; } if (!$this->isName($node->name, 'getDefaultStyle')) { return null; } $variable = clone $node->var; - $getParentMethodCall = new \PhpParser\Node\Expr\MethodCall($variable, 'getParent'); + $getParentMethodCall = new MethodCall($variable, 'getParent'); $node->var = $getParentMethodCall; return $node; } diff --git a/vendor/rector/rector-phpoffice/src/Rector/MethodCall/IncreaseColumnIndexRector.php b/vendor/rector/rector-phpoffice/src/Rector/MethodCall/IncreaseColumnIndexRector.php index 755a448ba2e..c98f00d109c 100644 --- a/vendor/rector/rector-phpoffice/src/Rector/MethodCall/IncreaseColumnIndexRector.php +++ b/vendor/rector/rector-phpoffice/src/Rector/MethodCall/IncreaseColumnIndexRector.php @@ -11,14 +11,14 @@ use PhpParser\Node\Expr\Variable; use PhpParser\Node\Scalar\LNumber; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#column-index-based-on-1 * * @see \Rector\PHPOffice\Tests\Rector\MethodCall\IncreaseColumnIndexRector\IncreaseColumnIndexRectorTest */ -final class IncreaseColumnIndexRector extends \Rector\Core\Rector\AbstractRector +final class IncreaseColumnIndexRector extends AbstractRector { /** * @var string @@ -30,11 +30,11 @@ final class IncreaseColumnIndexRector extends \Rector\Core\Rector\AbstractRector private $worksheetObjectTypes = []; public function __construct() { - $this->worksheetObjectTypes = [new \PHPStan\Type\ObjectType('PHPExcel_Worksheet'), new \PHPStan\Type\ObjectType('PHPExcel_Worksheet_PageSetup')]; + $this->worksheetObjectTypes = [new ObjectType('PHPExcel_Worksheet'), new ObjectType('PHPExcel_Worksheet_PageSetup')]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Column index changed from 0 to 1 - run only ONCE! changes current value without memory', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Column index changed from 0 to 1 - run only ONCE! changes current value without memory', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run(): void @@ -61,12 +61,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->nodeTypeResolver->isObjectTypes($node->var, $this->worksheetObjectTypes)) { return null; @@ -82,24 +82,24 @@ CODE_SAMPLE // increase column value $firstArg = $node->getArgs()[0]; $firstArgumentValue = $firstArg->value; - if ($firstArgumentValue instanceof \PhpParser\Node\Scalar\LNumber) { + if ($firstArgumentValue instanceof LNumber) { ++$firstArgumentValue->value; } - if ($firstArgumentValue instanceof \PhpParser\Node\Expr\BinaryOp) { + if ($firstArgumentValue instanceof BinaryOp) { $this->refactorBinaryOp($firstArgumentValue); } - if ($firstArgumentValue instanceof \PhpParser\Node\Expr\Variable) { - $firstArg->value = new \PhpParser\Node\Expr\BinaryOp\Plus($firstArgumentValue, new \PhpParser\Node\Scalar\LNumber(1)); + if ($firstArgumentValue instanceof Variable) { + $firstArg->value = new Plus($firstArgumentValue, new LNumber(1)); } return $node; } - private function refactorBinaryOp(\PhpParser\Node\Expr\BinaryOp $binaryOp) : void + private function refactorBinaryOp(BinaryOp $binaryOp) : void { - if ($binaryOp->left instanceof \PhpParser\Node\Scalar\LNumber) { + if ($binaryOp->left instanceof LNumber) { ++$binaryOp->left->value; return; } - if ($binaryOp->right instanceof \PhpParser\Node\Scalar\LNumber) { + if ($binaryOp->right instanceof LNumber) { ++$binaryOp->right->value; } } diff --git a/vendor/rector/rector-phpoffice/src/Rector/MethodCall/RemoveSetTempDirOnExcelWriterRector.php b/vendor/rector/rector-phpoffice/src/Rector/MethodCall/RemoveSetTempDirOnExcelWriterRector.php index 6266b7c94e0..92fcb0b3b68 100644 --- a/vendor/rector/rector-phpoffice/src/Rector/MethodCall/RemoveSetTempDirOnExcelWriterRector.php +++ b/vendor/rector/rector-phpoffice/src/Rector/MethodCall/RemoveSetTempDirOnExcelWriterRector.php @@ -7,18 +7,18 @@ use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#writerxlssettempdir * * @see \Rector\PHPOffice\Tests\Rector\MethodCall\RemoveSetTempDirOnExcelWriterRector\RemoveSetTempDirOnExcelWriterRectorTest */ -final class RemoveSetTempDirOnExcelWriterRector extends \Rector\Core\Rector\AbstractRector +final class RemoveSetTempDirOnExcelWriterRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove setTempDir() on PHPExcel_Writer_Excel5', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove setTempDir() on PHPExcel_Writer_Excel5', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run(): void @@ -44,14 +44,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('PHPExcel_Writer_Excel5'))) { + if (!$this->isObjectType($node->var, new ObjectType('PHPExcel_Writer_Excel5'))) { return null; } if (!$this->isName($node->name, 'setTempDir')) { diff --git a/vendor/rector/rector-phpoffice/src/Rector/StaticCall/AddRemovedDefaultValuesRector.php b/vendor/rector/rector-phpoffice/src/Rector/StaticCall/AddRemovedDefaultValuesRector.php index 134b78d2bce..1a6af5096ab 100644 --- a/vendor/rector/rector-phpoffice/src/Rector/StaticCall/AddRemovedDefaultValuesRector.php +++ b/vendor/rector/rector-phpoffice/src/Rector/StaticCall/AddRemovedDefaultValuesRector.php @@ -10,22 +10,22 @@ use PhpParser\Node\Expr\StaticCall; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\PHPOffice\ValueObject\PHPExcelMethodDefaultValues; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/PHPOffice/PhpSpreadsheet/commit/033a4bdad56340795a5bf7ec3c8a2fde005cda24 https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#removed-default-values * * @see \Rector\PHPOffice\Tests\Rector\StaticCall\AddRemovedDefaultValuesRector\AddRemovedDefaultValuesRectorTest */ -final class AddRemovedDefaultValuesRector extends \Rector\Core\Rector\AbstractRector +final class AddRemovedDefaultValuesRector extends AbstractRector { /** * @var bool */ private $hasChanged = \false; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Complete removed default values explicitly', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Complete removed default values explicitly', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run(): void @@ -52,16 +52,16 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class, \PhpParser\Node\Expr\MethodCall::class]; + return [StaticCall::class, MethodCall::class]; } /** * @param StaticCall|MethodCall $node * @return null|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { - foreach (\Rector\PHPOffice\ValueObject\PHPExcelMethodDefaultValues::METHOD_NAMES_BY_TYPE_WITH_VALUE as $type => $defaultValuesByMethodName) { - if (!$this->isCallerObjectType($node, new \PHPStan\Type\ObjectType($type))) { + foreach (PHPExcelMethodDefaultValues::METHOD_NAMES_BY_TYPE_WITH_VALUE as $type => $defaultValuesByMethodName) { + if (!$this->isCallerObjectType($node, new ObjectType($type))) { continue; } foreach ($defaultValuesByMethodName as $methodName => $defaultValuesByPosition) { @@ -90,7 +90,7 @@ CODE_SAMPLE if (\is_string($defaultValue) && \strpos($defaultValue, '::') !== \false) { [$className, $constant] = \explode('::', $defaultValue); $classConstant = $this->nodeFactory->createClassConstFetch($className, $constant); - $arg = new \PhpParser\Node\Arg($classConstant); + $arg = new Arg($classConstant); } else { $arg = $this->nodeFactory->createArg($defaultValue); } @@ -101,9 +101,9 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $node */ - private function isCallerObjectType($node, \PHPStan\Type\ObjectType $objectType) : bool + private function isCallerObjectType($node, ObjectType $objectType) : bool { - $caller = $node instanceof \PhpParser\Node\Expr\MethodCall ? $node->var : $node->class; + $caller = $node instanceof MethodCall ? $node->var : $node->class; return $this->isObjectType($caller, $objectType); } } diff --git a/vendor/rector/rector-phpoffice/src/Rector/StaticCall/CellStaticToCoordinateRector.php b/vendor/rector/rector-phpoffice/src/Rector/StaticCall/CellStaticToCoordinateRector.php index f8e02946998..1940da5f06b 100644 --- a/vendor/rector/rector-phpoffice/src/Rector/StaticCall/CellStaticToCoordinateRector.php +++ b/vendor/rector/rector-phpoffice/src/Rector/StaticCall/CellStaticToCoordinateRector.php @@ -8,22 +8,22 @@ use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Name\FullyQualified; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#dedicated-class-to-manipulate-coordinates * * @see \Rector\PHPOffice\Tests\Rector\StaticCall\CellStaticToCoordinateRector\CellStaticToCoordinateRectorTest */ -final class CellStaticToCoordinateRector extends \Rector\Core\Rector\AbstractRector +final class CellStaticToCoordinateRector extends AbstractRector { /** * @var string[] */ private const DECOUPLED_METHODS = ['absoluteCoordinate', 'absoluteReference', 'buildRange', 'columnIndexFromString', 'coordinateFromString', 'extractAllCellReferencesInRange', 'getRangeBoundaries', 'mergeRangesInCollection', 'rangeBoundaries', 'rangeDimension', 'splitRange', 'stringFromColumnIndex']; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Methods to manipulate coordinates that used to exists in PHPExcel_Cell to PhpOffice\\PhpSpreadsheet\\Cell\\Coordinate', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Methods to manipulate coordinates that used to exists in PHPExcel_Cell to PhpOffice\\PhpSpreadsheet\\Cell\\Coordinate', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -48,20 +48,20 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class]; + return [StaticCall::class]; } /** * @param StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->class, new \PHPStan\Type\ObjectType('PHPExcel_Cell'))) { + if (!$this->isObjectType($node->class, new ObjectType('PHPExcel_Cell'))) { return null; } if (!$this->isNames($node->name, self::DECOUPLED_METHODS)) { return null; } - $node->class = new \PhpParser\Node\Name\FullyQualified('PhpOffice\\PhpSpreadsheet\\Cell\\Coordinate'); + $node->class = new FullyQualified('PhpOffice\\PhpSpreadsheet\\Cell\\Coordinate'); return $node; } } diff --git a/vendor/rector/rector-phpoffice/src/Rector/StaticCall/ChangeChartRendererRector.php b/vendor/rector/rector-phpoffice/src/Rector/StaticCall/ChangeChartRendererRector.php index fb9ae1ec9a8..17449a68096 100644 --- a/vendor/rector/rector-phpoffice/src/Rector/StaticCall/ChangeChartRendererRector.php +++ b/vendor/rector/rector-phpoffice/src/Rector/StaticCall/ChangeChartRendererRector.php @@ -8,18 +8,18 @@ use PhpParser\Node\Arg; use PhpParser\Node\Expr\StaticCall; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#rendering-charts * * @see \Rector\PHPOffice\Tests\Rector\StaticCall\ChangeChartRendererRector\ChangeChartRendererRectorTest */ -final class ChangeChartRendererRector extends \Rector\Core\Rector\AbstractRector +final class ChangeChartRendererRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change chart renderer', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change chart renderer', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run(): void @@ -44,15 +44,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class]; + return [StaticCall::class]; } /** * @param StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $callerType = $this->nodeTypeResolver->getType($node->class); - if (!$callerType->isSuperTypeOf(new \PHPStan\Type\ObjectType('PHPExcel_Settings'))->yes()) { + if (!$callerType->isSuperTypeOf(new ObjectType('PHPExcel_Settings'))->yes()) { return null; } if (!$this->nodeNameResolver->isName($node->name, 'setChartRenderer')) { @@ -61,7 +61,7 @@ CODE_SAMPLE if (\count($node->args) === 1) { return null; } - $arg = new \PhpParser\Node\Arg($this->nodeFactory->createClassConstReference('PhpOffice\\PhpSpreadsheet\\Chart\\Renderer\\JpGraph')); + $arg = new Arg($this->nodeFactory->createClassConstReference('PhpOffice\\PhpSpreadsheet\\Chart\\Renderer\\JpGraph')); $node->args = [$arg]; return $node; } diff --git a/vendor/rector/rector-phpoffice/src/Rector/StaticCall/ChangeDataTypeForValueRector.php b/vendor/rector/rector-phpoffice/src/Rector/StaticCall/ChangeDataTypeForValueRector.php index e3dbd2da592..fc018b42b2b 100644 --- a/vendor/rector/rector-phpoffice/src/Rector/StaticCall/ChangeDataTypeForValueRector.php +++ b/vendor/rector/rector-phpoffice/src/Rector/StaticCall/ChangeDataTypeForValueRector.php @@ -8,18 +8,18 @@ use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Name\FullyQualified; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#datatypedatatypeforvalue * * @see \Rector\PHPOffice\Tests\Rector\StaticCall\ChangeDataTypeForValueRector\ChangeDataTypeForValueRectorTest */ -final class ChangeDataTypeForValueRector extends \Rector\Core\Rector\AbstractRector +final class ChangeDataTypeForValueRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change argument DataType::dataTypeForValue() to DefaultValueBinder', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change argument DataType::dataTypeForValue() to DefaultValueBinder', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run(): void @@ -44,21 +44,21 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class]; + return [StaticCall::class]; } /** * @param StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $callerType = $this->nodeTypeResolver->getType($node->class); - if (!$callerType->isSuperTypeOf(new \PHPStan\Type\ObjectType('PHPExcel_Cell_DataType'))->yes()) { + if (!$callerType->isSuperTypeOf(new ObjectType('PHPExcel_Cell_DataType'))->yes()) { return null; } if (!$this->nodeNameResolver->isName($node->name, 'dataTypeForValue')) { return null; } - $node->class = new \PhpParser\Node\Name\FullyQualified('PhpOffice\\PhpSpreadsheet\\Cell\\DefaultValueBinder'); + $node->class = new FullyQualified('PhpOffice\\PhpSpreadsheet\\Cell\\DefaultValueBinder'); return $node; } } diff --git a/vendor/rector/rector-phpoffice/src/Rector/StaticCall/ChangeIOFactoryArgumentRector.php b/vendor/rector/rector-phpoffice/src/Rector/StaticCall/ChangeIOFactoryArgumentRector.php index a4794c5b371..aac149d6dfc 100644 --- a/vendor/rector/rector-phpoffice/src/Rector/StaticCall/ChangeIOFactoryArgumentRector.php +++ b/vendor/rector/rector-phpoffice/src/Rector/StaticCall/ChangeIOFactoryArgumentRector.php @@ -8,22 +8,22 @@ use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Scalar\String_; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#renamed-readers-and-writers * * @see \Rector\PHPOffice\Tests\Rector\StaticCall\ChangeIOFactoryArgumentRector\ChangeIOFactoryArgumentRectorTest */ -final class ChangeIOFactoryArgumentRector extends \Rector\Core\Rector\AbstractRector +final class ChangeIOFactoryArgumentRector extends AbstractRector { /** * @var array */ private const OLD_TO_NEW_TYPE = ['CSV' => 'Csv', 'Excel2003XML' => 'Xml', 'Excel2007' => 'Xlsx', 'Excel5' => 'Xls', 'Gnumeric' => 'Gnumeric', 'HTML' => 'Html', 'OOCalc' => 'Ods', 'OpenDocument' => 'Ods', 'PDF' => 'Pdf', 'SYLK' => 'Slk']; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change argument of PHPExcel_IOFactory::createReader(), PHPExcel_IOFactory::createWriter() and PHPExcel_IOFactory::identify()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change argument of PHPExcel_IOFactory::createReader(), PHPExcel_IOFactory::createWriter() and PHPExcel_IOFactory::identify()', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run(): void @@ -48,14 +48,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class]; + return [StaticCall::class]; } /** * @param StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->class, new \PHPStan\Type\ObjectType('PHPExcel_IOFactory'))) { + if (!$this->isObjectType($node->class, new ObjectType('PHPExcel_IOFactory'))) { return null; } if (!$this->isNames($node->name, ['createReader', 'createWriter', 'identify'])) { @@ -66,7 +66,7 @@ CODE_SAMPLE if ($newValue === null) { return null; } - $node->args[0]->value = new \PhpParser\Node\Scalar\String_($newValue); + $node->args[0]->value = new String_($newValue); return $node; } } diff --git a/vendor/rector/rector-phpoffice/src/Rector/StaticCall/ChangePdfWriterRector.php b/vendor/rector/rector-phpoffice/src/Rector/StaticCall/ChangePdfWriterRector.php index a5e989eec64..3668e42d2ad 100644 --- a/vendor/rector/rector-phpoffice/src/Rector/StaticCall/ChangePdfWriterRector.php +++ b/vendor/rector/rector-phpoffice/src/Rector/StaticCall/ChangePdfWriterRector.php @@ -11,18 +11,18 @@ use PHPStan\Type\ObjectType; use PHPStan\Type\Type; use Rector\Core\Rector\AbstractRector; use Rector\Core\Util\StringUtils; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#writing-pdf * * @see \Rector\PHPOffice\Tests\Rector\StaticCall\ChangePdfWriterRector\ChangePdfWriterRectorTest */ -final class ChangePdfWriterRector extends \Rector\Core\Rector\AbstractRector +final class ChangePdfWriterRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change init of PDF writer', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change init of PDF writer', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run(): void @@ -49,19 +49,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class]; + return [StaticCall::class]; } /** * @param StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $callerType = $this->nodeTypeResolver->getType($node->class); if ($this->isSettingsPdfRendererStaticCall($callerType, $node)) { $this->removeNode($node); return null; } - if ($callerType->isSuperTypeOf(new \PHPStan\Type\ObjectType('PHPExcel_IOFactory'))->yes() && $this->nodeNameResolver->isName($node->name, 'createWriter')) { + if ($callerType->isSuperTypeOf(new ObjectType('PHPExcel_IOFactory'))->yes() && $this->nodeNameResolver->isName($node->name, 'createWriter')) { if (!isset($node->args[1])) { return null; } @@ -69,15 +69,15 @@ CODE_SAMPLE if (!\is_string($secondArgValue)) { return null; } - if (\Rector\Core\Util\StringUtils::isMatch($secondArgValue, '#pdf#i')) { - return new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name\FullyQualified('PhpOffice\\PhpSpreadsheet\\Writer\\Pdf\\Mpdf'), [$node->args[0]]); + if (StringUtils::isMatch($secondArgValue, '#pdf#i')) { + return new New_(new FullyQualified('PhpOffice\\PhpSpreadsheet\\Writer\\Pdf\\Mpdf'), [$node->args[0]]); } } return null; } - private function isSettingsPdfRendererStaticCall(\PHPStan\Type\Type $callerType, \PhpParser\Node\Expr\StaticCall $staticCall) : bool + private function isSettingsPdfRendererStaticCall(Type $callerType, StaticCall $staticCall) : bool { - if (!$callerType->isSuperTypeOf(new \PHPStan\Type\ObjectType('PHPExcel_Settings'))->yes()) { + if (!$callerType->isSuperTypeOf(new ObjectType('PHPExcel_Settings'))->yes()) { return \false; } return $this->nodeNameResolver->isNames($staticCall->name, ['setPdfRendererName', 'setPdfRenderer']); diff --git a/vendor/rector/rector-phpoffice/src/Rector/StaticCall/ChangeSearchLocationToRegisterReaderRector.php b/vendor/rector/rector-phpoffice/src/Rector/StaticCall/ChangeSearchLocationToRegisterReaderRector.php index 5c01dd7bfe0..5f559b70eb8 100644 --- a/vendor/rector/rector-phpoffice/src/Rector/StaticCall/ChangeSearchLocationToRegisterReaderRector.php +++ b/vendor/rector/rector-phpoffice/src/Rector/StaticCall/ChangeSearchLocationToRegisterReaderRector.php @@ -9,18 +9,18 @@ use PhpParser\Node\Identifier; use PhpParser\Node\Name\FullyQualified; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md#simplified-iofactory * * @see \Rector\PHPOffice\Tests\Rector\StaticCall\ChangeSearchLocationToRegisterReaderRector\ChangeSearchLocationToRegisterReaderRectorTest */ -final class ChangeSearchLocationToRegisterReaderRector extends \Rector\Core\Rector\AbstractRector +final class ChangeSearchLocationToRegisterReaderRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change argument addSearchLocation() to registerReader()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change argument addSearchLocation() to registerReader()', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run(): void @@ -45,22 +45,22 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class]; + return [StaticCall::class]; } /** * @param StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $callerType = $this->nodeTypeResolver->getType($node->class); - if (!$callerType->isSuperTypeOf(new \PHPStan\Type\ObjectType('PHPExcel_IOFactory'))->yes()) { + if (!$callerType->isSuperTypeOf(new ObjectType('PHPExcel_IOFactory'))->yes()) { return null; } if (!$this->isName($node->name, 'addSearchLocation')) { return null; } - $node->class = new \PhpParser\Node\Name\FullyQualified('PhpOffice\\PhpSpreadsheet\\IOFactory'); - $node->name = new \PhpParser\Node\Identifier('registerReader'); + $node->class = new FullyQualified('PhpOffice\\PhpSpreadsheet\\IOFactory'); + $node->name = new Identifier('registerReader'); // remove middle argument $args = $node->args; unset($args[1]); diff --git a/vendor/rector/rector-phpoffice/src/Set/PHPOfficeSetList.php b/vendor/rector/rector-phpoffice/src/Set/PHPOfficeSetList.php index 67c431b9ddd..0c29c01b69b 100644 --- a/vendor/rector/rector-phpoffice/src/Set/PHPOfficeSetList.php +++ b/vendor/rector/rector-phpoffice/src/Set/PHPOfficeSetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\PHPOffice\Set; use Rector\Set\Contract\SetListInterface; -final class PHPOfficeSetList implements \Rector\Set\Contract\SetListInterface +final class PHPOfficeSetList implements SetListInterface { /** * @var string diff --git a/vendor/rector/rector-phpoffice/src/ValueObject/PHPExcelMethodDefaultValues.php b/vendor/rector/rector-phpoffice/src/ValueObject/PHPExcelMethodDefaultValues.php index 5fefefdc27d..00395f01e3b 100644 --- a/vendor/rector/rector-phpoffice/src/ValueObject/PHPExcelMethodDefaultValues.php +++ b/vendor/rector/rector-phpoffice/src/ValueObject/PHPExcelMethodDefaultValues.php @@ -9,5 +9,5 @@ final class PHPExcelMethodDefaultValues /** * @var array>> */ - public const METHOD_NAMES_BY_TYPE_WITH_VALUE = ['PHPExcel' => ['setHasMacros' => [\false], 'setMacrosCode' => [null], 'setMacrosCertificate' => [null], 'setRibbonXMLData' => [null, null], 'setRibbonBinObjects' => [null, null], 'getRibbonBinObjects' => ['all'], 'getSheetByCodeName' => [''], 'createSheet' => [null], 'removeSheetByIndex' => [0], 'getSheet' => [0], 'getSheetByName' => [''], 'setActiveSheetIndex' => [0], 'setActiveSheetIndexByName' => [''], 'getCellXfByIndex' => [0], 'getCellXfByHashCode' => [''], 'cellXfExists' => [null], 'removeCellXfByIndex' => [0], 'getCellStyleXfByIndex' => [0], 'getCellStyleXfByHashCode' => [''], 'removeCellStyleXfByIndex' => [0]], 'PHPExcel_CalcEngine_Logger' => ['setWriteDebugLog' => [\false], 'setEchoDebugLog' => [\false]], 'PHPExcel_Calculation' => ['setCalculationCacheEnabled' => [\true], 'setLocale' => ['en_us']], 'PHPExcel_Calculation_FormulaToken' => ['setTokenType' => ['PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN'], 'setTokenSubType' => ['PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING']], 'PHPExcel_Cell' => ['setValue' => [null], 'setValueExplicit' => [null, 'PHPExcel_Cell_DataType::TYPE_STRING'], 'setCalculatedValue' => [null], 'setDataType' => ['PHPExcel_Cell_DataType::TYPE_STRING'], 'isInRange' => ['A1:A1'], 'coordinateFromString' => ['A1'], 'absoluteReference' => ['A1'], 'absoluteCoordinate' => ['A1'], 'splitRange' => ['A1:A1'], 'rangeBoundaries' => ['A1:A1'], 'rangeDimension' => ['A1:A1'], 'getRangeBoundaries' => ['A1:A1'], 'columnIndexFromString' => ['A'], 'stringFromColumnIndex' => [0], 'extractAllCellReferencesInRange' => ['A1'], 'setXfIndex' => [0]], 'PHPExcel_Cell_DataType' => ['checkString' => [null], 'checkErrorCode' => [null]], 'PHPExcel_Cell_DataValidation' => ['setFormula1' => [''], 'setFormula2' => [''], 'setType' => ['PHPExcel_Cell_DataValidation::TYPE_NONE'], 'setErrorStyle' => ['PHPExcel_Cell_DataValidation::STYLE_STOP'], 'setOperator' => [''], 'setAllowBlank' => [\false], 'setShowDropDown' => [\false], 'setShowInputMessage' => [\false], 'setShowErrorMessage' => [\false], 'setErrorTitle' => [''], 'setError' => [''], 'setPromptTitle' => [''], 'setPrompt' => ['']], 'PHPExcel_Cell_DefaultValueBinder' => ['dataTypeForValue' => [null]], 'PHPExcel_Cell_Hyperlink' => ['setUrl' => [''], 'setTooltip' => ['']], 'PHPExcel_Chart' => ['setPlotVisibleOnly' => [\true], 'setDisplayBlanksAs' => ['0'], 'setTopLeftOffset' => [null, null], 'setBottomRightOffset' => [null, null]], 'PHPExcel_Chart_DataSeries' => ['setPlotType' => [''], 'setPlotGrouping' => [null], 'setPlotDirection' => [null], 'setPlotStyle' => [null], 'setSmoothLine' => [\true]], 'PHPExcel_Chart_DataSeriesValues' => ['setDataType' => ['PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_NUMBER'], 'setDataSource' => [null, \true], 'setPointMarker' => [null], 'setFormatCode' => [null], 'setDataValues' => [[], \true]], 'PHPExcel_Chart_Layout' => [\Rector\Core\ValueObject\MethodName::CONSTRUCT => [[]]], 'PHPExcel_Chart_Legend' => ['setPosition' => ['PHPExcel_Chart_Legend::POSITION_RIGHT'], 'setPositionXL' => ['PHPExcel_Chart_Legend::XL_LEGEND_POSITION_RIGHT'], 'setOverlay' => [\false]], 'PHPExcel_Chart_PlotArea' => [\Rector\Core\ValueObject\MethodName::CONSTRUCT => [null, []], 'setPlotSeries' => [[]]], 'PHPExcel_Chart_Title' => ['setCaption' => [null]], 'PHPExcel_Comment' => ['setAuthor' => [''], 'setWidth' => ['96pt'], 'setHeight' => ['55.5pt'], 'setMarginLeft' => ['59.25pt'], 'setMarginTop' => ['1.5pt'], 'setVisible' => [\false], 'setAlignment' => ['Style\\Alignment::HORIZONTAL_GENERAL']], 'PHPExcel_DocumentProperties' => ['setCreator' => [''], 'setLastModifiedBy' => [''], 'setCreated' => [null], 'setModified' => [null], 'setTitle' => [''], 'setDescription' => [''], 'setSubject' => [''], 'setKeywords' => [''], 'setCategory' => [''], 'setCompany' => [''], 'setManager' => ['']], 'PHPExcel_DocumentSecurity' => ['setLockRevision' => [\false], 'setLockStructure' => [\false], 'setLockWindows' => [\false], 'setRevisionsPassword' => ['', \false], 'setWorkbookPassword' => ['', \false]], 'PHPExcel_HashTable' => ['addFromSource' => [null], 'getIndexForHashCode' => [''], 'getByIndex' => [0], 'getByHashCode' => ['']], 'PHPExcel_IOFactory' => ['addSearchLocation' => ['', '', ''], 'createReader' => ['']], 'PHPExcel_NamedRange' => ['setName' => [null], 'setRange' => [null], 'setLocalOnly' => [\false]], 'PHPExcel_Reader_Abstract' => ['setReadDataOnly' => [\false], 'setReadEmptyCells' => [\true], 'setIncludeCharts' => [\false], 'setLoadSheetsOnly' => [null]], 'PHPExcel_Reader_CSV' => ['setInputEncoding' => ['UTF-8'], 'setDelimiter' => [','], 'setEnclosure' => ['\\'], 'setSheetIndex' => [0], 'setContiguous' => [\false]], 'PHPExcel_Reader_Excel2003XML' => ['parseRichText' => ['']], 'PHPExcel_Reader_Excel2007' => ['parseRichText' => [null], 'boolean' => [null]], 'PHPExcel_Reader_Excel2007_Chart' => ['parseRichText' => [null]], 'PHPExcel_Reader_Excel2007_Theme' => ['getColourByIndex' => [0]], 'PHPExcel_Reader_Excel5' => ['parseRichText' => ['']], 'PHPExcel_Reader_Gnumeric' => ['parseRichText' => ['']], 'PHPExcel_Reader_HTML' => ['setInputEncoding' => ['ANSI'], 'setSheetIndex' => [0]], 'PHPExcel_Reader_OOCalc' => ['parseRichText' => ['']], 'PHPExcel_Reader_SYLK' => ['setInputEncoding' => ['ANSI'], 'setSheetIndex' => [0]], 'PHPExcel_RichText' => ['createText' => [''], 'createTextRun' => [''], 'setRichTextElements' => [null]], 'PHPExcel_RichText_TextElement' => ['setText' => ['']], 'PHPExcel_Settings' => ['setLocale' => ['en_us'], 'setLibXmlLoaderOptions' => [null]], 'PHPExcel_Shared_CodePage' => ['numberToName' => ['1252']], 'PHPExcel_Shared_Date' => ['excelToDateTimeObject' => [0, null], 'excelToTimestamp' => [0, null], 'PHPToExcel' => [0], 'timestampToExcel' => [0], 'isDateTimeFormatCode' => [''], 'stringToExcel' => ['']], 'PHPExcel_Shared_Drawing' => ['pixelsToEMU' => [0], 'EMUToPixels' => [0], 'pixelsToPoints' => [0], 'pointsToPixels' => [0], 'degreesToAngle' => [0], 'angleToDegrees' => [0]], 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer' => ['setSpgr' => [\false], 'setStartCoordinates' => ['A1'], 'setStartOffsetX' => [0], 'setStartOffsetY' => [0], 'setEndCoordinates' => ['A1'], 'setEndOffsetX' => [0], 'setEndOffsetY' => [0]], 'PHPExcel_Shared_File' => ['setUseUploadTempDirectory' => [\false]], 'PHPExcel_Shared_Font' => ['setAutoSizeMethod' => ['PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX'], 'setTrueTypeFontPath' => [''], 'fontSizeToPixels' => ['11'], 'inchSizeToPixels' => ['1'], 'centimeterSizeToPixels' => ['1']], 'PHPExcel_Shared_OLE' => ['localDateToOLE' => [null]], 'PHPExcel_Shared_PasswordHasher' => ['hashPassword' => ['']], 'PHPExcel_Shared_String' => ['controlCharacterOOXML2PHP' => [''], 'controlCharacterPHP2OOXML' => [''], 'isUTF8' => [''], 'substring' => ['', 0, 0], 'strToUpper' => [''], 'strToLower' => [''], 'strToTitle' => [''], 'strCaseReverse' => [''], 'setDecimalSeparator' => ['.'], 'setThousandsSeparator' => [','], 'setCurrencyCode' => ['$'], 'SYLKtoUTF8' => ['']], 'PHPExcel_Style' => ['applyFromArray' => [null, \true], 'setConditionalStyles' => [null]], 'PHPExcel_Style_Alignment' => ['applyFromArray' => [null], 'setHorizontal' => ['PHPExcel_Style_Alignment::HORIZONTAL_GENERAL'], 'setVertical' => ['PHPExcel_Style_Alignment::VERTICAL_BOTTOM'], 'setTextRotation' => [0], 'setWrapText' => [\false], 'setShrinkToFit' => [\false], 'setIndent' => [0], 'setReadorder' => [0]], 'PHPExcel_Style_Border' => ['applyFromArray' => [null], 'setBorderStyle' => ['PHPExcel_Style_Border::BORDER_NONE']], 'PHPExcel_Style_Borders' => ['applyFromArray' => [null], 'setDiagonalDirection' => ['PHPExcel_Style_Borders::DIAGONAL_NONE']], 'PHPExcel_Style_Color' => ['applyFromArray' => [null], 'setARGB' => ['PHPExcel_Style_Color::COLOR_BLACK'], 'setRGB' => ['000000']], 'PHPExcel_Style_Conditional' => ['setConditionType' => ['PHPExcel_Style_Conditional::CONDITION_NONE'], 'setOperatorType' => ['PHPExcel_Style_Conditional::OPERATOR_NONE'], 'setText' => [null], 'addCondition' => ['']], 'PHPExcel_Style_Fill' => ['applyFromArray' => [null], 'setFillType' => ['PHPExcel_Style_Fill::FILL_NONE'], 'setRotation' => [0]], 'PHPExcel_Style_Font' => ['applyFromArray' => [null], 'setName' => ['Calibri'], 'setSize' => ['10'], 'setBold' => [\false], 'setItalic' => [\false], 'setSuperScript' => [\false], 'setSubScript' => [\false], 'setUnderline' => ['PHPExcel_Style_Font::UNDERLINE_NONE'], 'setStrikethrough' => [\false]], 'PHPExcel_Style_NumberFormat' => ['applyFromArray' => [null], 'setFormatCode' => ['PHPExcel_Style_NumberFormat::FORMAT_GENERAL'], 'setBuiltInFormatCode' => [0], 'toFormattedString' => ['0', 'PHPExcel_Style_NumberFormat::FORMAT_GENERAL', null]], 'PHPExcel_Style_Protection' => ['applyFromArray' => [null], 'setLocked' => ['PHPExcel_Style_Protection::PROTECTION_INHERIT'], 'setHidden' => ['PHPExcel_Style_Protection::PROTECTION_INHERIT']], 'PHPExcel_Worksheet' => ['getChartByIndex' => [null], 'getChartByName' => [''], 'setTitle' => ['Worksheet', \true], 'setSheetState' => ['PHPExcel_Worksheet::SHEETSTATE_VISIBLE'], 'setCellValue' => ['A1', null, \false], 'setCellValueByColumnAndRow' => [0, '1', null, \false], 'setCellValueExplicit' => ['A1', null, 'PHPExcel_Cell_DataType::TYPE_STRING', \false], 'setCellValueExplicitByColumnAndRow' => [0, '1', null, 'PHPExcel_Cell_DataType::TYPE_STRING', \false], 'getCell' => ['A1', \true], 'getCellByColumnAndRow' => [0, '1', \true], 'cellExists' => ['A1'], 'cellExistsByColumnAndRow' => [0, '1'], 'getRowDimension' => ['1', \true], 'getColumnDimension' => ['A', \true], 'getColumnDimensionByColumn' => [0], 'getStyle' => ['A1'], 'getConditionalStyles' => ['A1'], 'conditionalStylesExists' => ['A1'], 'removeConditionalStyles' => ['A1'], 'getStyleByColumnAndRow' => [0, '1', null, null], 'setBreak' => ['A1', 'PHPExcel_Worksheet::BREAK_NONE'], 'setBreakByColumnAndRow' => [0, '1', 'PHPExcel_Worksheet::BREAK_NONE'], 'mergeCells' => ['A1:A1'], 'mergeCellsByColumnAndRow' => [0, '1', 0, '1'], 'unmergeCells' => ['A1:A1'], 'unmergeCellsByColumnAndRow' => [0, '1', 0, '1'], 'setMergeCells' => [[]], 'protectCells' => ['A1', '', \false], 'protectCellsByColumnAndRow' => [0, '1', 0, '1', '', \false], 'unprotectCells' => ['A1'], 'unprotectCellsByColumnAndRow' => [0, '1', 0, '1', '', \false], 'setAutoFilterByColumnAndRow' => [0, '1', 0, '1'], 'freezePane' => [''], 'freezePaneByColumnAndRow' => [0, '1'], 'insertNewRowBefore' => ['1', '1'], 'insertNewColumnBefore' => ['A', '1'], 'insertNewColumnBeforeByIndex' => [0, '1'], 'removeRow' => ['1', '1'], 'removeColumn' => ['A', '1'], 'removeColumnByIndex' => [0, '1'], 'setShowGridlines' => [\false], 'setPrintGridlines' => [\false], 'setShowRowColHeaders' => [\false], 'setShowSummaryBelow' => [\true], 'setShowSummaryRight' => [\true], 'setComments' => [[]], 'getComment' => ['A1'], 'getCommentByColumnAndRow' => [0, '1'], 'setSelectedCell' => ['A1'], 'setSelectedCells' => ['A1'], 'setSelectedCellByColumnAndRow' => [0, '1'], 'setRightToLeft' => [\false], 'fromArray' => [null, null, 'A1', \false], 'rangeToArray' => ['A1', null, \true, \true, \false], 'namedRangeToArray' => ['', null, \true, \true, \false], 'getHyperlink' => ['A1'], 'setHyperlink' => ['A1', null], 'hyperlinkExists' => ['A1'], 'getDataValidation' => ['A1'], 'setDataValidation' => ['A1', null], 'dataValidationExists' => ['A1'], 'setCodeName' => [null]], 'PHPExcel_Worksheet_AutoFilter' => ['setRange' => [''], 'getColumnByOffset' => [0], 'shiftColumn' => [null, null]], 'PHPExcel_Worksheet_AutoFilter_Column' => ['setFilterType' => ['PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER'], 'setJoin' => ['PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_OR'], 'setAttributes' => [[]], 'addRule' => [1 => \true]], 'PHPExcel_Worksheet_AutoFilter_Column_Rule' => ['setRuleType' => ['PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER'], 'setValue' => [''], 'setOperator' => ['PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL'], 'setGrouping' => [null], 'setRule' => ['PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL', '', null]], 'PHPExcel_Worksheet_BaseDrawing' => ['setName' => [''], 'setDescription' => [''], 'setCoordinates' => ['A1'], 'setOffsetX' => [0], 'setOffsetY' => [0], 'setWidth' => [0], 'setHeight' => [0], 'setWidthAndHeight' => [0, 0], 'setResizeProportional' => [\true], 'setRotation' => [0]], 'PHPExcel_Worksheet_CellIterator' => ['setIterateOnlyExistingCells' => [\true]], 'PHPExcel_Worksheet_ColumnDimension' => ['setWidth' => ['-1'], 'setAutoSize' => [\false]], 'PHPExcel_Worksheet_Drawing' => ['setPath' => ['', \true]], 'PHPExcel_Worksheet_Drawing_Shadow' => ['setVisible' => [\false], 'setBlurRadius' => ['6'], 'setDistance' => ['2'], 'setDirection' => [0], 'setAlignment' => [0], 'setAlpha' => [0]], 'PHPExcel_Worksheet_HeaderFooter' => ['setDifferentOddEven' => [\false], 'setDifferentFirst' => [\false], 'setScaleWithDocument' => [\true], 'setAlignWithMargins' => [\true]], 'PHPExcel_Worksheet_HeaderFooterDrawing' => ['setName' => [''], 'setOffsetX' => [0], 'setOffsetY' => [0], 'setWidth' => [0], 'setHeight' => [0], 'setWidthAndHeight' => [0, 0], 'setResizeProportional' => [\true], 'setPath' => ['', \true]], 'PHPExcel_Worksheet_MemoryDrawing' => ['setImageResource' => [null], 'setRenderingFunction' => ['PHPExcel_Worksheet_MemoryDrawing::RENDERING_DEFAULT'], 'setMimeType' => ['PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT']], 'PHPExcel_Worksheet_PageSetup' => ['setPaperSize' => ['PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER'], 'setOrientation' => ['PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT'], 'setScale' => ['100', \true], 'setFitToPage' => [\true], 'setFitToHeight' => ['1', \true], 'setFitToWidth' => ['1', \true], 'setColumnsToRepeatAtLeft' => [null], 'setColumnsToRepeatAtLeftByStartAndEnd' => ['A', 'A'], 'setRowsToRepeatAtTop' => [null], 'setRowsToRepeatAtTopByStartAndEnd' => ['1', '1'], 'setHorizontalCentered' => [\false], 'setVerticalCentered' => [\false], 'setFirstPageNumber' => [null]], 'PHPExcel_Worksheet_Protection' => ['setSheet' => [\false], 'setObjects' => [\false], 'setScenarios' => [\false], 'setFormatCells' => [\false], 'setFormatColumns' => [\false], 'setFormatRows' => [\false], 'setInsertColumns' => [\false], 'setInsertRows' => [\false], 'setInsertHyperlinks' => [\false], 'setDeleteColumns' => [\false], 'setDeleteRows' => [\false], 'setSelectLockedCells' => [\false], 'setSort' => [\false], 'setAutoFilter' => [\false], 'setPivotTables' => [\false], 'setSelectUnlockedCells' => [\false], 'setPassword' => ['', \false]], 'PHPExcel_Worksheet_RowDimension' => ['setRowHeight' => ['-1'], 'setZeroHeight' => [\false]], 'PHPExcel_Worksheet_SheetView' => ['setZoomScale' => ['100'], 'setZoomScaleNormal' => ['100'], 'setView' => [null]], 'PHPExcel_Writer_Abstract' => ['setIncludeCharts' => [\false], 'setPreCalculateFormulas' => [\true], 'setUseDiskCaching' => [\false, null]], 'PHPExcel_Writer_CSV' => ['save' => [null], 'setDelimiter' => [','], 'setEnclosure' => ['\\'], 'setLineEnding' => [\PHP_EOL], 'setUseBOM' => [\false], 'setIncludeSeparatorLine' => [\false], 'setExcelCompatibility' => [\false], 'setSheetIndex' => [0], 'writeLine' => [null, null]], 'PHPExcel_Writer_Excel2007' => ['getWriterPart' => [''], 'save' => [null], 'setOffice2003Compatibility' => [\false]], 'PHPExcel_Writer_Excel2007_ContentTypes' => ['getImageMimeType' => ['']], 'PHPExcel_Writer_Excel2007_StringTable' => ['writeStringTable' => [null], 'flipStringTable' => [[]]], 'PHPExcel_Writer_Excel5' => ['save' => [null]], 'PHPExcel_Writer_Excel5_Workbook' => ['writeWorkbook' => [null]], 'PHPExcel_Writer_Excel5_Worksheet' => ['writeBIFF8CellRangeAddressFixed' => ['A1']], 'PHPExcel_Writer_HTML' => ['save' => [null], 'setSheetIndex' => [0], 'setGenerateSheetNavigationBlock' => [\true], 'setImagesRoot' => ['.'], 'setEmbedImages' => [\true], 'setUseInlineCss' => [\false]], 'PHPExcel_Writer_OpenDocument' => ['getWriterPart' => [''], 'save' => [null]], 'PHPExcel_Writer_PDF' => ['save' => [null]], 'PHPExcel_Writer_PDF_Core' => ['setPaperSize' => ['PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER'], 'setOrientation' => ['PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT'], 'setTempDir' => [''], 'prepareForSave' => [null]], 'PHPExcel_Writer_PDF_DomPDF' => ['save' => [null]], 'PHPExcel_Writer_PDF_mPDF' => ['save' => [null]], 'PHPExcel_Writer_PDF_tcPDF' => ['save' => [null]]]; + public const METHOD_NAMES_BY_TYPE_WITH_VALUE = ['PHPExcel' => ['setHasMacros' => [\false], 'setMacrosCode' => [null], 'setMacrosCertificate' => [null], 'setRibbonXMLData' => [null, null], 'setRibbonBinObjects' => [null, null], 'getRibbonBinObjects' => ['all'], 'getSheetByCodeName' => [''], 'createSheet' => [null], 'removeSheetByIndex' => [0], 'getSheet' => [0], 'getSheetByName' => [''], 'setActiveSheetIndex' => [0], 'setActiveSheetIndexByName' => [''], 'getCellXfByIndex' => [0], 'getCellXfByHashCode' => [''], 'cellXfExists' => [null], 'removeCellXfByIndex' => [0], 'getCellStyleXfByIndex' => [0], 'getCellStyleXfByHashCode' => [''], 'removeCellStyleXfByIndex' => [0]], 'PHPExcel_CalcEngine_Logger' => ['setWriteDebugLog' => [\false], 'setEchoDebugLog' => [\false]], 'PHPExcel_Calculation' => ['setCalculationCacheEnabled' => [\true], 'setLocale' => ['en_us']], 'PHPExcel_Calculation_FormulaToken' => ['setTokenType' => ['PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN'], 'setTokenSubType' => ['PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING']], 'PHPExcel_Cell' => ['setValue' => [null], 'setValueExplicit' => [null, 'PHPExcel_Cell_DataType::TYPE_STRING'], 'setCalculatedValue' => [null], 'setDataType' => ['PHPExcel_Cell_DataType::TYPE_STRING'], 'isInRange' => ['A1:A1'], 'coordinateFromString' => ['A1'], 'absoluteReference' => ['A1'], 'absoluteCoordinate' => ['A1'], 'splitRange' => ['A1:A1'], 'rangeBoundaries' => ['A1:A1'], 'rangeDimension' => ['A1:A1'], 'getRangeBoundaries' => ['A1:A1'], 'columnIndexFromString' => ['A'], 'stringFromColumnIndex' => [0], 'extractAllCellReferencesInRange' => ['A1'], 'setXfIndex' => [0]], 'PHPExcel_Cell_DataType' => ['checkString' => [null], 'checkErrorCode' => [null]], 'PHPExcel_Cell_DataValidation' => ['setFormula1' => [''], 'setFormula2' => [''], 'setType' => ['PHPExcel_Cell_DataValidation::TYPE_NONE'], 'setErrorStyle' => ['PHPExcel_Cell_DataValidation::STYLE_STOP'], 'setOperator' => [''], 'setAllowBlank' => [\false], 'setShowDropDown' => [\false], 'setShowInputMessage' => [\false], 'setShowErrorMessage' => [\false], 'setErrorTitle' => [''], 'setError' => [''], 'setPromptTitle' => [''], 'setPrompt' => ['']], 'PHPExcel_Cell_DefaultValueBinder' => ['dataTypeForValue' => [null]], 'PHPExcel_Cell_Hyperlink' => ['setUrl' => [''], 'setTooltip' => ['']], 'PHPExcel_Chart' => ['setPlotVisibleOnly' => [\true], 'setDisplayBlanksAs' => ['0'], 'setTopLeftOffset' => [null, null], 'setBottomRightOffset' => [null, null]], 'PHPExcel_Chart_DataSeries' => ['setPlotType' => [''], 'setPlotGrouping' => [null], 'setPlotDirection' => [null], 'setPlotStyle' => [null], 'setSmoothLine' => [\true]], 'PHPExcel_Chart_DataSeriesValues' => ['setDataType' => ['PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_NUMBER'], 'setDataSource' => [null, \true], 'setPointMarker' => [null], 'setFormatCode' => [null], 'setDataValues' => [[], \true]], 'PHPExcel_Chart_Layout' => [MethodName::CONSTRUCT => [[]]], 'PHPExcel_Chart_Legend' => ['setPosition' => ['PHPExcel_Chart_Legend::POSITION_RIGHT'], 'setPositionXL' => ['PHPExcel_Chart_Legend::XL_LEGEND_POSITION_RIGHT'], 'setOverlay' => [\false]], 'PHPExcel_Chart_PlotArea' => [MethodName::CONSTRUCT => [null, []], 'setPlotSeries' => [[]]], 'PHPExcel_Chart_Title' => ['setCaption' => [null]], 'PHPExcel_Comment' => ['setAuthor' => [''], 'setWidth' => ['96pt'], 'setHeight' => ['55.5pt'], 'setMarginLeft' => ['59.25pt'], 'setMarginTop' => ['1.5pt'], 'setVisible' => [\false], 'setAlignment' => ['Style\\Alignment::HORIZONTAL_GENERAL']], 'PHPExcel_DocumentProperties' => ['setCreator' => [''], 'setLastModifiedBy' => [''], 'setCreated' => [null], 'setModified' => [null], 'setTitle' => [''], 'setDescription' => [''], 'setSubject' => [''], 'setKeywords' => [''], 'setCategory' => [''], 'setCompany' => [''], 'setManager' => ['']], 'PHPExcel_DocumentSecurity' => ['setLockRevision' => [\false], 'setLockStructure' => [\false], 'setLockWindows' => [\false], 'setRevisionsPassword' => ['', \false], 'setWorkbookPassword' => ['', \false]], 'PHPExcel_HashTable' => ['addFromSource' => [null], 'getIndexForHashCode' => [''], 'getByIndex' => [0], 'getByHashCode' => ['']], 'PHPExcel_IOFactory' => ['addSearchLocation' => ['', '', ''], 'createReader' => ['']], 'PHPExcel_NamedRange' => ['setName' => [null], 'setRange' => [null], 'setLocalOnly' => [\false]], 'PHPExcel_Reader_Abstract' => ['setReadDataOnly' => [\false], 'setReadEmptyCells' => [\true], 'setIncludeCharts' => [\false], 'setLoadSheetsOnly' => [null]], 'PHPExcel_Reader_CSV' => ['setInputEncoding' => ['UTF-8'], 'setDelimiter' => [','], 'setEnclosure' => ['\\'], 'setSheetIndex' => [0], 'setContiguous' => [\false]], 'PHPExcel_Reader_Excel2003XML' => ['parseRichText' => ['']], 'PHPExcel_Reader_Excel2007' => ['parseRichText' => [null], 'boolean' => [null]], 'PHPExcel_Reader_Excel2007_Chart' => ['parseRichText' => [null]], 'PHPExcel_Reader_Excel2007_Theme' => ['getColourByIndex' => [0]], 'PHPExcel_Reader_Excel5' => ['parseRichText' => ['']], 'PHPExcel_Reader_Gnumeric' => ['parseRichText' => ['']], 'PHPExcel_Reader_HTML' => ['setInputEncoding' => ['ANSI'], 'setSheetIndex' => [0]], 'PHPExcel_Reader_OOCalc' => ['parseRichText' => ['']], 'PHPExcel_Reader_SYLK' => ['setInputEncoding' => ['ANSI'], 'setSheetIndex' => [0]], 'PHPExcel_RichText' => ['createText' => [''], 'createTextRun' => [''], 'setRichTextElements' => [null]], 'PHPExcel_RichText_TextElement' => ['setText' => ['']], 'PHPExcel_Settings' => ['setLocale' => ['en_us'], 'setLibXmlLoaderOptions' => [null]], 'PHPExcel_Shared_CodePage' => ['numberToName' => ['1252']], 'PHPExcel_Shared_Date' => ['excelToDateTimeObject' => [0, null], 'excelToTimestamp' => [0, null], 'PHPToExcel' => [0], 'timestampToExcel' => [0], 'isDateTimeFormatCode' => [''], 'stringToExcel' => ['']], 'PHPExcel_Shared_Drawing' => ['pixelsToEMU' => [0], 'EMUToPixels' => [0], 'pixelsToPoints' => [0], 'pointsToPixels' => [0], 'degreesToAngle' => [0], 'angleToDegrees' => [0]], 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer' => ['setSpgr' => [\false], 'setStartCoordinates' => ['A1'], 'setStartOffsetX' => [0], 'setStartOffsetY' => [0], 'setEndCoordinates' => ['A1'], 'setEndOffsetX' => [0], 'setEndOffsetY' => [0]], 'PHPExcel_Shared_File' => ['setUseUploadTempDirectory' => [\false]], 'PHPExcel_Shared_Font' => ['setAutoSizeMethod' => ['PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX'], 'setTrueTypeFontPath' => [''], 'fontSizeToPixels' => ['11'], 'inchSizeToPixels' => ['1'], 'centimeterSizeToPixels' => ['1']], 'PHPExcel_Shared_OLE' => ['localDateToOLE' => [null]], 'PHPExcel_Shared_PasswordHasher' => ['hashPassword' => ['']], 'PHPExcel_Shared_String' => ['controlCharacterOOXML2PHP' => [''], 'controlCharacterPHP2OOXML' => [''], 'isUTF8' => [''], 'substring' => ['', 0, 0], 'strToUpper' => [''], 'strToLower' => [''], 'strToTitle' => [''], 'strCaseReverse' => [''], 'setDecimalSeparator' => ['.'], 'setThousandsSeparator' => [','], 'setCurrencyCode' => ['$'], 'SYLKtoUTF8' => ['']], 'PHPExcel_Style' => ['applyFromArray' => [null, \true], 'setConditionalStyles' => [null]], 'PHPExcel_Style_Alignment' => ['applyFromArray' => [null], 'setHorizontal' => ['PHPExcel_Style_Alignment::HORIZONTAL_GENERAL'], 'setVertical' => ['PHPExcel_Style_Alignment::VERTICAL_BOTTOM'], 'setTextRotation' => [0], 'setWrapText' => [\false], 'setShrinkToFit' => [\false], 'setIndent' => [0], 'setReadorder' => [0]], 'PHPExcel_Style_Border' => ['applyFromArray' => [null], 'setBorderStyle' => ['PHPExcel_Style_Border::BORDER_NONE']], 'PHPExcel_Style_Borders' => ['applyFromArray' => [null], 'setDiagonalDirection' => ['PHPExcel_Style_Borders::DIAGONAL_NONE']], 'PHPExcel_Style_Color' => ['applyFromArray' => [null], 'setARGB' => ['PHPExcel_Style_Color::COLOR_BLACK'], 'setRGB' => ['000000']], 'PHPExcel_Style_Conditional' => ['setConditionType' => ['PHPExcel_Style_Conditional::CONDITION_NONE'], 'setOperatorType' => ['PHPExcel_Style_Conditional::OPERATOR_NONE'], 'setText' => [null], 'addCondition' => ['']], 'PHPExcel_Style_Fill' => ['applyFromArray' => [null], 'setFillType' => ['PHPExcel_Style_Fill::FILL_NONE'], 'setRotation' => [0]], 'PHPExcel_Style_Font' => ['applyFromArray' => [null], 'setName' => ['Calibri'], 'setSize' => ['10'], 'setBold' => [\false], 'setItalic' => [\false], 'setSuperScript' => [\false], 'setSubScript' => [\false], 'setUnderline' => ['PHPExcel_Style_Font::UNDERLINE_NONE'], 'setStrikethrough' => [\false]], 'PHPExcel_Style_NumberFormat' => ['applyFromArray' => [null], 'setFormatCode' => ['PHPExcel_Style_NumberFormat::FORMAT_GENERAL'], 'setBuiltInFormatCode' => [0], 'toFormattedString' => ['0', 'PHPExcel_Style_NumberFormat::FORMAT_GENERAL', null]], 'PHPExcel_Style_Protection' => ['applyFromArray' => [null], 'setLocked' => ['PHPExcel_Style_Protection::PROTECTION_INHERIT'], 'setHidden' => ['PHPExcel_Style_Protection::PROTECTION_INHERIT']], 'PHPExcel_Worksheet' => ['getChartByIndex' => [null], 'getChartByName' => [''], 'setTitle' => ['Worksheet', \true], 'setSheetState' => ['PHPExcel_Worksheet::SHEETSTATE_VISIBLE'], 'setCellValue' => ['A1', null, \false], 'setCellValueByColumnAndRow' => [0, '1', null, \false], 'setCellValueExplicit' => ['A1', null, 'PHPExcel_Cell_DataType::TYPE_STRING', \false], 'setCellValueExplicitByColumnAndRow' => [0, '1', null, 'PHPExcel_Cell_DataType::TYPE_STRING', \false], 'getCell' => ['A1', \true], 'getCellByColumnAndRow' => [0, '1', \true], 'cellExists' => ['A1'], 'cellExistsByColumnAndRow' => [0, '1'], 'getRowDimension' => ['1', \true], 'getColumnDimension' => ['A', \true], 'getColumnDimensionByColumn' => [0], 'getStyle' => ['A1'], 'getConditionalStyles' => ['A1'], 'conditionalStylesExists' => ['A1'], 'removeConditionalStyles' => ['A1'], 'getStyleByColumnAndRow' => [0, '1', null, null], 'setBreak' => ['A1', 'PHPExcel_Worksheet::BREAK_NONE'], 'setBreakByColumnAndRow' => [0, '1', 'PHPExcel_Worksheet::BREAK_NONE'], 'mergeCells' => ['A1:A1'], 'mergeCellsByColumnAndRow' => [0, '1', 0, '1'], 'unmergeCells' => ['A1:A1'], 'unmergeCellsByColumnAndRow' => [0, '1', 0, '1'], 'setMergeCells' => [[]], 'protectCells' => ['A1', '', \false], 'protectCellsByColumnAndRow' => [0, '1', 0, '1', '', \false], 'unprotectCells' => ['A1'], 'unprotectCellsByColumnAndRow' => [0, '1', 0, '1', '', \false], 'setAutoFilterByColumnAndRow' => [0, '1', 0, '1'], 'freezePane' => [''], 'freezePaneByColumnAndRow' => [0, '1'], 'insertNewRowBefore' => ['1', '1'], 'insertNewColumnBefore' => ['A', '1'], 'insertNewColumnBeforeByIndex' => [0, '1'], 'removeRow' => ['1', '1'], 'removeColumn' => ['A', '1'], 'removeColumnByIndex' => [0, '1'], 'setShowGridlines' => [\false], 'setPrintGridlines' => [\false], 'setShowRowColHeaders' => [\false], 'setShowSummaryBelow' => [\true], 'setShowSummaryRight' => [\true], 'setComments' => [[]], 'getComment' => ['A1'], 'getCommentByColumnAndRow' => [0, '1'], 'setSelectedCell' => ['A1'], 'setSelectedCells' => ['A1'], 'setSelectedCellByColumnAndRow' => [0, '1'], 'setRightToLeft' => [\false], 'fromArray' => [null, null, 'A1', \false], 'rangeToArray' => ['A1', null, \true, \true, \false], 'namedRangeToArray' => ['', null, \true, \true, \false], 'getHyperlink' => ['A1'], 'setHyperlink' => ['A1', null], 'hyperlinkExists' => ['A1'], 'getDataValidation' => ['A1'], 'setDataValidation' => ['A1', null], 'dataValidationExists' => ['A1'], 'setCodeName' => [null]], 'PHPExcel_Worksheet_AutoFilter' => ['setRange' => [''], 'getColumnByOffset' => [0], 'shiftColumn' => [null, null]], 'PHPExcel_Worksheet_AutoFilter_Column' => ['setFilterType' => ['PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER'], 'setJoin' => ['PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_OR'], 'setAttributes' => [[]], 'addRule' => [1 => \true]], 'PHPExcel_Worksheet_AutoFilter_Column_Rule' => ['setRuleType' => ['PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER'], 'setValue' => [''], 'setOperator' => ['PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL'], 'setGrouping' => [null], 'setRule' => ['PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL', '', null]], 'PHPExcel_Worksheet_BaseDrawing' => ['setName' => [''], 'setDescription' => [''], 'setCoordinates' => ['A1'], 'setOffsetX' => [0], 'setOffsetY' => [0], 'setWidth' => [0], 'setHeight' => [0], 'setWidthAndHeight' => [0, 0], 'setResizeProportional' => [\true], 'setRotation' => [0]], 'PHPExcel_Worksheet_CellIterator' => ['setIterateOnlyExistingCells' => [\true]], 'PHPExcel_Worksheet_ColumnDimension' => ['setWidth' => ['-1'], 'setAutoSize' => [\false]], 'PHPExcel_Worksheet_Drawing' => ['setPath' => ['', \true]], 'PHPExcel_Worksheet_Drawing_Shadow' => ['setVisible' => [\false], 'setBlurRadius' => ['6'], 'setDistance' => ['2'], 'setDirection' => [0], 'setAlignment' => [0], 'setAlpha' => [0]], 'PHPExcel_Worksheet_HeaderFooter' => ['setDifferentOddEven' => [\false], 'setDifferentFirst' => [\false], 'setScaleWithDocument' => [\true], 'setAlignWithMargins' => [\true]], 'PHPExcel_Worksheet_HeaderFooterDrawing' => ['setName' => [''], 'setOffsetX' => [0], 'setOffsetY' => [0], 'setWidth' => [0], 'setHeight' => [0], 'setWidthAndHeight' => [0, 0], 'setResizeProportional' => [\true], 'setPath' => ['', \true]], 'PHPExcel_Worksheet_MemoryDrawing' => ['setImageResource' => [null], 'setRenderingFunction' => ['PHPExcel_Worksheet_MemoryDrawing::RENDERING_DEFAULT'], 'setMimeType' => ['PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT']], 'PHPExcel_Worksheet_PageSetup' => ['setPaperSize' => ['PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER'], 'setOrientation' => ['PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT'], 'setScale' => ['100', \true], 'setFitToPage' => [\true], 'setFitToHeight' => ['1', \true], 'setFitToWidth' => ['1', \true], 'setColumnsToRepeatAtLeft' => [null], 'setColumnsToRepeatAtLeftByStartAndEnd' => ['A', 'A'], 'setRowsToRepeatAtTop' => [null], 'setRowsToRepeatAtTopByStartAndEnd' => ['1', '1'], 'setHorizontalCentered' => [\false], 'setVerticalCentered' => [\false], 'setFirstPageNumber' => [null]], 'PHPExcel_Worksheet_Protection' => ['setSheet' => [\false], 'setObjects' => [\false], 'setScenarios' => [\false], 'setFormatCells' => [\false], 'setFormatColumns' => [\false], 'setFormatRows' => [\false], 'setInsertColumns' => [\false], 'setInsertRows' => [\false], 'setInsertHyperlinks' => [\false], 'setDeleteColumns' => [\false], 'setDeleteRows' => [\false], 'setSelectLockedCells' => [\false], 'setSort' => [\false], 'setAutoFilter' => [\false], 'setPivotTables' => [\false], 'setSelectUnlockedCells' => [\false], 'setPassword' => ['', \false]], 'PHPExcel_Worksheet_RowDimension' => ['setRowHeight' => ['-1'], 'setZeroHeight' => [\false]], 'PHPExcel_Worksheet_SheetView' => ['setZoomScale' => ['100'], 'setZoomScaleNormal' => ['100'], 'setView' => [null]], 'PHPExcel_Writer_Abstract' => ['setIncludeCharts' => [\false], 'setPreCalculateFormulas' => [\true], 'setUseDiskCaching' => [\false, null]], 'PHPExcel_Writer_CSV' => ['save' => [null], 'setDelimiter' => [','], 'setEnclosure' => ['\\'], 'setLineEnding' => [\PHP_EOL], 'setUseBOM' => [\false], 'setIncludeSeparatorLine' => [\false], 'setExcelCompatibility' => [\false], 'setSheetIndex' => [0], 'writeLine' => [null, null]], 'PHPExcel_Writer_Excel2007' => ['getWriterPart' => [''], 'save' => [null], 'setOffice2003Compatibility' => [\false]], 'PHPExcel_Writer_Excel2007_ContentTypes' => ['getImageMimeType' => ['']], 'PHPExcel_Writer_Excel2007_StringTable' => ['writeStringTable' => [null], 'flipStringTable' => [[]]], 'PHPExcel_Writer_Excel5' => ['save' => [null]], 'PHPExcel_Writer_Excel5_Workbook' => ['writeWorkbook' => [null]], 'PHPExcel_Writer_Excel5_Worksheet' => ['writeBIFF8CellRangeAddressFixed' => ['A1']], 'PHPExcel_Writer_HTML' => ['save' => [null], 'setSheetIndex' => [0], 'setGenerateSheetNavigationBlock' => [\true], 'setImagesRoot' => ['.'], 'setEmbedImages' => [\true], 'setUseInlineCss' => [\false]], 'PHPExcel_Writer_OpenDocument' => ['getWriterPart' => [''], 'save' => [null]], 'PHPExcel_Writer_PDF' => ['save' => [null]], 'PHPExcel_Writer_PDF_Core' => ['setPaperSize' => ['PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER'], 'setOrientation' => ['PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT'], 'setTempDir' => [''], 'prepareForSave' => [null]], 'PHPExcel_Writer_PDF_DomPDF' => ['save' => [null]], 'PHPExcel_Writer_PDF_mPDF' => ['save' => [null]], 'PHPExcel_Writer_PDF_tcPDF' => ['save' => [null]]]; } diff --git a/vendor/rector/rector-phpunit/config/config.php b/vendor/rector/rector-phpunit/config/config.php index 747d64a4b19..bbfbd009f36 100644 --- a/vendor/rector/rector-phpunit/config/config.php +++ b/vendor/rector/rector-phpunit/config/config.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace RectorPrefix20220607; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $services = $rectorConfig->services(); $services->defaults()->public()->autowire()->autoconfigure(); $services->load('Rector\\PHPUnit\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/{Rector,ValueObject,PhpDoc/Node}']); diff --git a/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-100.php b/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-100.php index 9a194c2c433..2e451a654bb 100644 --- a/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-100.php +++ b/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-100.php @@ -6,7 +6,7 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\PHPUnit\Set\PHPUnitLevelSetList; use Rector\PHPUnit\Set\PHPUnitSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_91); - $rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_90); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->import(PHPUnitSetList::PHPUNIT_91); + $rectorConfig->import(PHPUnitLevelSetList::UP_TO_PHPUNIT_90); }; diff --git a/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-50.php b/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-50.php index b756ce46df5..23725f91724 100644 --- a/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-50.php +++ b/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-50.php @@ -5,6 +5,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\PHPUnit\Set\PHPUnitSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_50); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->import(PHPUnitSetList::PHPUNIT_50); }; diff --git a/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-60.php b/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-60.php index 87af0c7b68a..a6761c9335d 100644 --- a/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-60.php +++ b/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-60.php @@ -6,7 +6,7 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\PHPUnit\Set\PHPUnitLevelSetList; use Rector\PHPUnit\Set\PHPUnitSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_60); - $rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_50); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->import(PHPUnitSetList::PHPUNIT_60); + $rectorConfig->import(PHPUnitLevelSetList::UP_TO_PHPUNIT_50); }; diff --git a/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-70.php b/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-70.php index 2bd239c8ba2..3766cfcbf23 100644 --- a/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-70.php +++ b/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-70.php @@ -6,7 +6,7 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\PHPUnit\Set\PHPUnitLevelSetList; use Rector\PHPUnit\Set\PHPUnitSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_70); - $rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_60); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->import(PHPUnitSetList::PHPUNIT_70); + $rectorConfig->import(PHPUnitLevelSetList::UP_TO_PHPUNIT_60); }; diff --git a/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-80.php b/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-80.php index a00fe6d3e70..bfb0693fe28 100644 --- a/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-80.php +++ b/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-80.php @@ -6,7 +6,7 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\PHPUnit\Set\PHPUnitLevelSetList; use Rector\PHPUnit\Set\PHPUnitSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_80); - $rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_70); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->import(PHPUnitSetList::PHPUNIT_80); + $rectorConfig->import(PHPUnitLevelSetList::UP_TO_PHPUNIT_70); }; diff --git a/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-90.php b/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-90.php index 76b9f655af5..1dcd17a9e0a 100644 --- a/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-90.php +++ b/vendor/rector/rector-phpunit/config/sets/level/up-to-phpunit-90.php @@ -6,7 +6,7 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\PHPUnit\Set\PHPUnitLevelSetList; use Rector\PHPUnit\Set\PHPUnitSetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_90); - $rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_80); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->import(PHPUnitSetList::PHPUNIT_90); + $rectorConfig->import(PHPUnitLevelSetList::UP_TO_PHPUNIT_80); }; diff --git a/vendor/rector/rector-phpunit/config/sets/phpunit-code-quality.php b/vendor/rector/rector-phpunit/config/sets/phpunit-code-quality.php index e2c59c07235..94d036f302d 100644 --- a/vendor/rector/rector-phpunit/config/sets/phpunit-code-quality.php +++ b/vendor/rector/rector-phpunit/config/sets/phpunit-code-quality.php @@ -13,13 +13,13 @@ use Rector\PHPUnit\Rector\MethodCall\AssertComparisonToSpecificMethodRector; use Rector\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector; use Rector\PHPUnit\Rector\MethodCall\AssertSameTrueFalseToAssertTrueFalseRector; use Rector\PHPUnit\Rector\MethodCall\RemoveExpectAnyFromMockRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\RemoveExpectAnyFromMockRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector::class, [new \Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield('PHPUnit\\Framework\\TestCase', 'provide*'), new \Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield('PHPUnit\\Framework\\TestCase', 'dataProvider*')]); - $rectorConfig->rule(\Rector\PHPUnit\Rector\Class_\ConstructClassMethodToSetUpTestCaseRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\AssertSameTrueFalseToAssertTrueFalseRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\AssertCompareToSpecificMethodRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\AssertComparisonToSpecificMethodRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(RemoveExpectAnyFromMockRector::class); + $rectorConfig->rule(AddSeeTestAnnotationRector::class); + $rectorConfig->ruleWithConfiguration(ReturnArrayClassMethodToYieldRector::class, [new ReturnArrayClassMethodToYield('PHPUnit\\Framework\\TestCase', 'provide*'), new ReturnArrayClassMethodToYield('PHPUnit\\Framework\\TestCase', 'dataProvider*')]); + $rectorConfig->rule(ConstructClassMethodToSetUpTestCaseRector::class); + $rectorConfig->rule(AssertSameTrueFalseToAssertTrueFalseRector::class); + $rectorConfig->rule(AssertEqualsToSameRector::class); + $rectorConfig->rule(AssertCompareToSpecificMethodRector::class); + $rectorConfig->rule(AssertComparisonToSpecificMethodRector::class); }; diff --git a/vendor/rector/rector-phpunit/config/sets/phpunit-exception.php b/vendor/rector/rector-phpunit/config/sets/phpunit-exception.php index e49bf692fe1..e698b9b8010 100644 --- a/vendor/rector/rector-phpunit/config/sets/phpunit-exception.php +++ b/vendor/rector/rector-phpunit/config/sets/phpunit-exception.php @@ -8,9 +8,9 @@ use Rector\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector; use Rector\PHPUnit\Rector\MethodCall\DelegateExceptionArgumentsRector; use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\ValueObject\MethodCallRename; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { # handles 2nd and 3rd argument of setExpectedException - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\DelegateExceptionArgumentsRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('PHPUnit\\Framework\\TestClass', 'setExpectedException', 'expectedException'), new \Rector\Renaming\ValueObject\MethodCallRename('PHPUnit\\Framework\\TestClass', 'setExpectedExceptionRegExp', 'expectedException')]); + $rectorConfig->rule(DelegateExceptionArgumentsRector::class); + $rectorConfig->rule(ExceptionAnnotationRector::class); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('PHPUnit\\Framework\\TestClass', 'setExpectedException', 'expectedException'), new MethodCallRename('PHPUnit\\Framework\\TestClass', 'setExpectedExceptionRegExp', 'expectedException')]); }; diff --git a/vendor/rector/rector-phpunit/config/sets/phpunit-specific-method.php b/vendor/rector/rector-phpunit/config/sets/phpunit-specific-method.php index 7f62c366bca..41b55499384 100644 --- a/vendor/rector/rector-phpunit/config/sets/phpunit-specific-method.php +++ b/vendor/rector/rector-phpunit/config/sets/phpunit-specific-method.php @@ -16,17 +16,17 @@ use Rector\PHPUnit\Rector\MethodCall\AssertRegExpRector; use Rector\PHPUnit\Rector\MethodCall\AssertSameBoolNullToSpecificMethodRector; use Rector\PHPUnit\Rector\MethodCall\AssertTrueFalseInternalTypeToSpecificMethodRector; use Rector\PHPUnit\Rector\MethodCall\AssertTrueFalseToSpecificMethodRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\AssertNotOperatorRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\AssertComparisonToSpecificMethodRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\AssertTrueFalseToSpecificMethodRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\AssertSameBoolNullToSpecificMethodRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\AssertFalseStrposToContainsRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\AssertTrueFalseInternalTypeToSpecificMethodRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\AssertCompareToSpecificMethodRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\AssertIssetToSpecificMethodRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\AssertInstanceOfComparisonRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\AssertPropertyExistsRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\AssertRegExpRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\Foreach_\SimplifyForeachInstanceOfRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(AssertNotOperatorRector::class); + $rectorConfig->rule(AssertComparisonToSpecificMethodRector::class); + $rectorConfig->rule(AssertTrueFalseToSpecificMethodRector::class); + $rectorConfig->rule(AssertSameBoolNullToSpecificMethodRector::class); + $rectorConfig->rule(AssertFalseStrposToContainsRector::class); + $rectorConfig->rule(AssertTrueFalseInternalTypeToSpecificMethodRector::class); + $rectorConfig->rule(AssertCompareToSpecificMethodRector::class); + $rectorConfig->rule(AssertIssetToSpecificMethodRector::class); + $rectorConfig->rule(AssertInstanceOfComparisonRector::class); + $rectorConfig->rule(AssertPropertyExistsRector::class); + $rectorConfig->rule(AssertRegExpRector::class); + $rectorConfig->rule(SimplifyForeachInstanceOfRector::class); }; diff --git a/vendor/rector/rector-phpunit/config/sets/phpunit-yield-data-provider.php b/vendor/rector/rector-phpunit/config/sets/phpunit-yield-data-provider.php index 3206696ff7c..90d3ed32b2a 100644 --- a/vendor/rector/rector-phpunit/config/sets/phpunit-yield-data-provider.php +++ b/vendor/rector/rector-phpunit/config/sets/phpunit-yield-data-provider.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector; use Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector::class, [new \Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield('PHPUnit\\Framework\\TestCase', 'provide*'), new \Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield('PHPUnit\\Framework\\TestCase', 'dataProvider*')]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(ReturnArrayClassMethodToYieldRector::class, [new ReturnArrayClassMethodToYield('PHPUnit\\Framework\\TestCase', 'provide*'), new ReturnArrayClassMethodToYield('PHPUnit\\Framework\\TestCase', 'dataProvider*')]); }; diff --git a/vendor/rector/rector-phpunit/config/sets/phpunit40.php b/vendor/rector/rector-phpunit/config/sets/phpunit40.php index fa8d3037484..019be3c1a16 100644 --- a/vendor/rector/rector-phpunit/config/sets/phpunit40.php +++ b/vendor/rector/rector-phpunit/config/sets/phpunit40.php @@ -6,8 +6,8 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\ValueObject\MethodCallRename; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename( +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename( 'PHPUnit_Framework_MockObject_MockObject', # see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/137 'staticExpects', diff --git a/vendor/rector/rector-phpunit/config/sets/phpunit50.php b/vendor/rector/rector-phpunit/config/sets/phpunit50.php index 2eb81e27427..fea44f0072c 100644 --- a/vendor/rector/rector-phpunit/config/sets/phpunit50.php +++ b/vendor/rector/rector-phpunit/config/sets/phpunit50.php @@ -5,6 +5,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\PHPUnit\Rector\StaticCall\GetMockRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\PHPUnit\Rector\StaticCall\GetMockRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(GetMockRector::class); }; diff --git a/vendor/rector/rector-phpunit/config/sets/phpunit60.php b/vendor/rector/rector-phpunit/config/sets/phpunit60.php index 80eeb330fda..2f17b1f8a98 100644 --- a/vendor/rector/rector-phpunit/config/sets/phpunit60.php +++ b/vendor/rector/rector-phpunit/config/sets/phpunit60.php @@ -11,14 +11,14 @@ use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Renaming\ValueObject\MethodCallRename; use Rector\Renaming\ValueObject\PseudoNamespaceToNamespace; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $rectorConfig->import(__DIR__ . '/phpunit-exception.php'); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('PHPUnit\\Framework\\TestCase', 'createMockBuilder', 'getMockBuilder')]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['PHPUnit_Framework_MockObject_Stub' => 'PHPUnit\\Framework\\MockObject\\Stub', 'PHPUnit_Framework_MockObject_Stub_Return' => 'PHPUnit\\Framework\\MockObject\\Stub\\ReturnStub', 'PHPUnit_Framework_MockObject_Matcher_Parameters' => 'PHPUnit\\Framework\\MockObject\\Matcher\\Parameters', 'PHPUnit_Framework_MockObject_Matcher_Invocation' => 'PHPUnit\\Framework\\MockObject\\Matcher\\Invocation', 'PHPUnit_Framework_MockObject_MockObject' => 'PHPUnit\\Framework\\MockObject\\MockObject', 'PHPUnit_Framework_MockObject_Invocation_Object' => 'PHPUnit\\Framework\\MockObject\\Invocation\\ObjectInvocation']); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector::class, [ + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('PHPUnit\\Framework\\TestCase', 'createMockBuilder', 'getMockBuilder')]); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['PHPUnit_Framework_MockObject_Stub' => 'PHPUnit\\Framework\\MockObject\\Stub', 'PHPUnit_Framework_MockObject_Stub_Return' => 'PHPUnit\\Framework\\MockObject\\Stub\\ReturnStub', 'PHPUnit_Framework_MockObject_Matcher_Parameters' => 'PHPUnit\\Framework\\MockObject\\Matcher\\Parameters', 'PHPUnit_Framework_MockObject_Matcher_Invocation' => 'PHPUnit\\Framework\\MockObject\\Matcher\\Invocation', 'PHPUnit_Framework_MockObject_MockObject' => 'PHPUnit\\Framework\\MockObject\\MockObject', 'PHPUnit_Framework_MockObject_Invocation_Object' => 'PHPUnit\\Framework\\MockObject\\Invocation\\ObjectInvocation']); + $rectorConfig->ruleWithConfiguration(PseudoNamespaceToNamespaceRector::class, [ // ref. https://github.com/sebastianbergmann/phpunit/compare/5.7.9...6.0.0 - new \Rector\Renaming\ValueObject\PseudoNamespaceToNamespace('PHPUnit_', ['PHPUnit_Framework_MockObject_MockObject', 'PHPUnit_Framework_MockObject_Invocation_Object', 'PHPUnit_Framework_MockObject_Matcher_Invocation', 'PHPUnit_Framework_MockObject_Matcher_Parameters', 'PHPUnit_Framework_MockObject_Stub_Return', 'PHPUnit_Framework_MockObject_Stub']), + new PseudoNamespaceToNamespace('PHPUnit_', ['PHPUnit_Framework_MockObject_MockObject', 'PHPUnit_Framework_MockObject_Invocation_Object', 'PHPUnit_Framework_MockObject_Matcher_Invocation', 'PHPUnit_Framework_MockObject_Matcher_Parameters', 'PHPUnit_Framework_MockObject_Stub_Return', 'PHPUnit_Framework_MockObject_Stub']), ]); - $rectorConfig->rule(\Rector\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector::class); + $rectorConfig->rule(AddDoesNotPerformAssertionToNonAssertingTestRector::class); + $rectorConfig->rule(GetMockBuilderGetMockToCreateMockRector::class); }; diff --git a/vendor/rector/rector-phpunit/config/sets/phpunit70.php b/vendor/rector/rector-phpunit/config/sets/phpunit70.php index 0f738bc1a2c..bfaf01aa13d 100644 --- a/vendor/rector/rector-phpunit/config/sets/phpunit70.php +++ b/vendor/rector/rector-phpunit/config/sets/phpunit70.php @@ -7,8 +7,8 @@ use Rector\Config\RectorConfig; use Rector\PHPUnit\Rector\Class_\RemoveDataProviderTestPrefixRector; use Rector\Renaming\Rector\ClassMethod\RenameAnnotationRector; use Rector\Renaming\ValueObject\RenameAnnotationByType; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $rectorConfig->import(__DIR__ . '/phpunit-exception.php'); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\ClassMethod\RenameAnnotationRector::class, [new \Rector\Renaming\ValueObject\RenameAnnotationByType('PHPUnit\\Framework\\TestCase', 'scenario', 'test')]); - $rectorConfig->rule(\Rector\PHPUnit\Rector\Class_\RemoveDataProviderTestPrefixRector::class); + $rectorConfig->ruleWithConfiguration(RenameAnnotationRector::class, [new RenameAnnotationByType('PHPUnit\\Framework\\TestCase', 'scenario', 'test')]); + $rectorConfig->rule(RemoveDataProviderTestPrefixRector::class); }; diff --git a/vendor/rector/rector-phpunit/config/sets/phpunit80-dms.php b/vendor/rector/rector-phpunit/config/sets/phpunit80-dms.php index e2107e46a39..daedf773cdf 100644 --- a/vendor/rector/rector-phpunit/config/sets/phpunit80-dms.php +++ b/vendor/rector/rector-phpunit/config/sets/phpunit80-dms.php @@ -5,6 +5,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\PHPUnit\Rector\MethodCall\ReplaceAssertArraySubsetWithDmsPolyfillRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\ReplaceAssertArraySubsetWithDmsPolyfillRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(ReplaceAssertArraySubsetWithDmsPolyfillRector::class); }; diff --git a/vendor/rector/rector-phpunit/config/sets/phpunit80.php b/vendor/rector/rector-phpunit/config/sets/phpunit80.php index 99e551cb993..8577d8630d0 100644 --- a/vendor/rector/rector-phpunit/config/sets/phpunit80.php +++ b/vendor/rector/rector-phpunit/config/sets/phpunit80.php @@ -15,18 +15,18 @@ use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector; use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector; use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration; use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $rectorConfig->import(__DIR__ . '/phpunit-exception.php'); - $rectorConfig->ruleWithConfiguration(\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::class, [ + $rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [ // https://github.com/rectorphp/rector/issues/1024 - no type, $dataName - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('PHPUnit\\Framework\\TestCase', \Rector\Core\ValueObject\MethodName::CONSTRUCT, 2, new \PHPStan\Type\MixedType()), + new AddParamTypeDeclaration('PHPUnit\\Framework\\TestCase', MethodName::CONSTRUCT, 2, new MixedType()), ]); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\SpecificAssertContainsRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\SpecificAssertInternalTypeRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, [ + $rectorConfig->rule(SpecificAssertContainsRector::class); + $rectorConfig->rule(SpecificAssertInternalTypeRector::class); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ # https://github.com/sebastianbergmann/phpunit/issues/3123 'PHPUnit_Framework_MockObject_MockObject' => 'PHPUnit\\Framework\\MockObject\\MockObject', ]); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\AssertEqualsParameterToSpecificMethodsTypeRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::class, [new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('PHPUnit\\Framework\\TestCase', 'setUpBeforeClass', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('PHPUnit\\Framework\\TestCase', 'setUp', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('PHPUnit\\Framework\\TestCase', 'assertPreConditions', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('PHPUnit\\Framework\\TestCase', 'assertPostConditions', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('PHPUnit\\Framework\\TestCase', 'tearDown', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('PHPUnit\\Framework\\TestCase', 'tearDownAfterClass', new \PHPStan\Type\VoidType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('PHPUnit\\Framework\\TestCase', 'onNotSuccessfulTest', new \PHPStan\Type\VoidType())]); + $rectorConfig->rule(AssertEqualsParameterToSpecificMethodsTypeRector::class); + $rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [new AddReturnTypeDeclaration('PHPUnit\\Framework\\TestCase', 'setUpBeforeClass', new VoidType()), new AddReturnTypeDeclaration('PHPUnit\\Framework\\TestCase', 'setUp', new VoidType()), new AddReturnTypeDeclaration('PHPUnit\\Framework\\TestCase', 'assertPreConditions', new VoidType()), new AddReturnTypeDeclaration('PHPUnit\\Framework\\TestCase', 'assertPostConditions', new VoidType()), new AddReturnTypeDeclaration('PHPUnit\\Framework\\TestCase', 'tearDown', new VoidType()), new AddReturnTypeDeclaration('PHPUnit\\Framework\\TestCase', 'tearDownAfterClass', new VoidType()), new AddReturnTypeDeclaration('PHPUnit\\Framework\\TestCase', 'onNotSuccessfulTest', new VoidType())]); }; diff --git a/vendor/rector/rector-phpunit/config/sets/phpunit90.php b/vendor/rector/rector-phpunit/config/sets/phpunit90.php index 699a099bd1e..fe2852f4ce7 100644 --- a/vendor/rector/rector-phpunit/config/sets/phpunit90.php +++ b/vendor/rector/rector-phpunit/config/sets/phpunit90.php @@ -9,12 +9,12 @@ use Rector\PHPUnit\Rector\MethodCall\ExplicitPhpErrorApiRector; use Rector\PHPUnit\Rector\MethodCall\SpecificAssertContainsWithoutIdentityRector; use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\ValueObject\MethodCallRename; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\PHPUnit\Rector\Class_\TestListenerToHooksRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\ExplicitPhpErrorApiRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\SpecificAssertContainsWithoutIdentityRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(TestListenerToHooksRector::class); + $rectorConfig->rule(ExplicitPhpErrorApiRector::class); + $rectorConfig->rule(SpecificAssertContainsWithoutIdentityRector::class); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ // see https://github.com/sebastianbergmann/phpunit/issues/3957 - new \Rector\Renaming\ValueObject\MethodCallRename('PHPUnit\\Framework\\TestCase', 'expectExceptionMessageRegExp', 'expectExceptionMessageMatches'), + new MethodCallRename('PHPUnit\\Framework\\TestCase', 'expectExceptionMessageRegExp', 'expectExceptionMessageMatches'), ]); }; diff --git a/vendor/rector/rector-phpunit/config/sets/phpunit91.php b/vendor/rector/rector-phpunit/config/sets/phpunit91.php index eace228cfa2..fdc81c80bda 100644 --- a/vendor/rector/rector-phpunit/config/sets/phpunit91.php +++ b/vendor/rector/rector-phpunit/config/sets/phpunit91.php @@ -7,26 +7,26 @@ use Rector\Config\RectorConfig; use Rector\PHPUnit\Rector\Class_\AddProphecyTraitRector; use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\ValueObject\MethodCallRename; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\PHPUnit\Rector\Class_\AddProphecyTraitRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(AddProphecyTraitRector::class); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ // https://github.com/sebastianbergmann/phpunit/issues/4087 - new \Rector\Renaming\ValueObject\MethodCallRename('PHPUnit\\Framework\\Assert', 'assertRegExp', 'assertMatchesRegularExpression'), + new MethodCallRename('PHPUnit\\Framework\\Assert', 'assertRegExp', 'assertMatchesRegularExpression'), // https://github.com/sebastianbergmann/phpunit/issues/4090 - new \Rector\Renaming\ValueObject\MethodCallRename('PHPUnit\\Framework\\Assert', 'assertNotRegExp', 'assertDoesNotMatchRegularExpression'), + new MethodCallRename('PHPUnit\\Framework\\Assert', 'assertNotRegExp', 'assertDoesNotMatchRegularExpression'), // https://github.com/sebastianbergmann/phpunit/issues/4078 - new \Rector\Renaming\ValueObject\MethodCallRename('PHPUnit\\Framework\\Assert', 'assertFileNotExists', 'assertFileDoesNotExist'), + new MethodCallRename('PHPUnit\\Framework\\Assert', 'assertFileNotExists', 'assertFileDoesNotExist'), // https://github.com/sebastianbergmann/phpunit/issues/4081 - new \Rector\Renaming\ValueObject\MethodCallRename('PHPUnit\\Framework\\Assert', 'assertFileNotIsReadable', 'assertFileIsNotReadable'), + new MethodCallRename('PHPUnit\\Framework\\Assert', 'assertFileNotIsReadable', 'assertFileIsNotReadable'), // https://github.com/sebastianbergmann/phpunit/issues/4072 - new \Rector\Renaming\ValueObject\MethodCallRename('PHPUnit\\Framework\\Assert', 'assertDirectoryNotIsReadable', 'assertDirectoryIsNotReadable'), + new MethodCallRename('PHPUnit\\Framework\\Assert', 'assertDirectoryNotIsReadable', 'assertDirectoryIsNotReadable'), // https://github.com/sebastianbergmann/phpunit/issues/4075 - new \Rector\Renaming\ValueObject\MethodCallRename('PHPUnit\\Framework\\Assert', 'assertDirectoryNotIsWritable', 'assertDirectoryIsNotWritable'), + new MethodCallRename('PHPUnit\\Framework\\Assert', 'assertDirectoryNotIsWritable', 'assertDirectoryIsNotWritable'), // https://github.com/sebastianbergmann/phpunit/issues/4069 - new \Rector\Renaming\ValueObject\MethodCallRename('PHPUnit\\Framework\\Assert', 'assertDirectoryNotExists', 'assertDirectoryDoesNotExist'), + new MethodCallRename('PHPUnit\\Framework\\Assert', 'assertDirectoryNotExists', 'assertDirectoryDoesNotExist'), // https://github.com/sebastianbergmann/phpunit/issues/4066 - new \Rector\Renaming\ValueObject\MethodCallRename('PHPUnit\\Framework\\Assert', 'assertNotIsWritable', 'assertIsNotWritable'), + new MethodCallRename('PHPUnit\\Framework\\Assert', 'assertNotIsWritable', 'assertIsNotWritable'), // https://github.com/sebastianbergmann/phpunit/issues/4063 - new \Rector\Renaming\ValueObject\MethodCallRename('PHPUnit\\Framework\\Assert', 'assertNotIsReadable', 'assertIsNotReadable'), + new MethodCallRename('PHPUnit\\Framework\\Assert', 'assertNotIsReadable', 'assertIsNotReadable'), ]); }; diff --git a/vendor/rector/rector-phpunit/config/sets/remove-mocks.php b/vendor/rector/rector-phpunit/config/sets/remove-mocks.php index 45b6d7b3b8a..91934e63d96 100644 --- a/vendor/rector/rector-phpunit/config/sets/remove-mocks.php +++ b/vendor/rector/rector-phpunit/config/sets/remove-mocks.php @@ -19,9 +19,9 @@ use Rector\PHPUnit\Rector\MethodCall\UseSpecificWillMethodRector; * @see https://steemit.com/php/@crell/don-t-use-mocking-libraries * @see https://davegebler.com/post/php/better-php-unit-testing-avoiding-mocks */ -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\RemoveSetMethodsMethodCallRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\RemoveExpectAnyFromMockRector::class); - $rectorConfig->rule(\Rector\PHPUnit\Rector\MethodCall\UseSpecificWillMethodRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(RemoveSetMethodsMethodCallRector::class); + $rectorConfig->rule(GetMockBuilderGetMockToCreateMockRector::class); + $rectorConfig->rule(RemoveExpectAnyFromMockRector::class); + $rectorConfig->rule(UseSpecificWillMethodRector::class); }; diff --git a/vendor/rector/rector-phpunit/easy-ci.php b/vendor/rector/rector-phpunit/easy-ci.php index 5badb644f71..22ae3739e1f 100644 --- a/vendor/rector/rector-phpunit/easy-ci.php +++ b/vendor/rector/rector-phpunit/easy-ci.php @@ -6,9 +6,9 @@ namespace RectorPrefix20220607; use Rector\Core\Contract\Rector\RectorInterface; use Rector\PHPUnit\Naming\TestClassNameResolverInterface; use Rector\Set\Contract\SetListInterface; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use RectorPrefix20220607\Symplify\EasyCI\ValueObject\Option; -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +return static function (ContainerConfigurator $containerConfigurator) : void { $parameters = $containerConfigurator->parameters(); - $parameters->set(\RectorPrefix20220607\Symplify\EasyCI\ValueObject\Option::TYPES_TO_SKIP, [\Rector\PHPUnit\Naming\TestClassNameResolverInterface::class, \Rector\Core\Contract\Rector\RectorInterface::class, \Rector\Set\Contract\SetListInterface::class]); + $parameters->set(Option::TYPES_TO_SKIP, [TestClassNameResolverInterface::class, RectorInterface::class, SetListInterface::class]); }; diff --git a/vendor/rector/rector-phpunit/monorepo-builder.php b/vendor/rector/rector-phpunit/monorepo-builder.php index e4e22301995..544f64366de 100644 --- a/vendor/rector/rector-phpunit/monorepo-builder.php +++ b/vendor/rector/rector-phpunit/monorepo-builder.php @@ -3,12 +3,12 @@ declare (strict_types=1); namespace RectorPrefix20220607; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\PushTagReleaseWorker; use RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\TagVersionReleaseWorker; -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +return static function (ContainerConfigurator $containerConfigurator) : void { $services = $containerConfigurator->services(); // @see https://github.com/symplify/monorepo-builder#6-release-flow - $services->set(\RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\TagVersionReleaseWorker::class); - $services->set(\RectorPrefix20220607\Symplify\MonorepoBuilder\Release\ReleaseWorker\PushTagReleaseWorker::class); + $services->set(TagVersionReleaseWorker::class); + $services->set(PushTagReleaseWorker::class); }; diff --git a/vendor/rector/rector-phpunit/rector.php b/vendor/rector/rector-phpunit/rector.php index d305bfb855e..d48bdb3f3d1 100644 --- a/vendor/rector/rector-phpunit/rector.php +++ b/vendor/rector/rector-phpunit/rector.php @@ -8,27 +8,27 @@ use Rector\Core\Configuration\Option; use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $parameters = $rectorConfig->parameters(); - $parameters->set(\Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES, \true); - $parameters->set(\Rector\Core\Configuration\Option::PARALLEL, \true); - $parameters->set(\Rector\Core\Configuration\Option::PATHS, [__DIR__ . '/src', __DIR__ . '/tests']); - $parameters->set(\Rector\Core\Configuration\Option::SKIP, [ + $parameters->set(Option::AUTO_IMPORT_NAMES, \true); + $parameters->set(Option::PARALLEL, \true); + $parameters->set(Option::PATHS, [__DIR__ . '/src', __DIR__ . '/tests']); + $parameters->set(Option::SKIP, [ // for tests '*/Source/*', '*/Fixture/*', // object types - \Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class => [__DIR__ . '/src/Rector/MethodCall/UseSpecificWillMethodRector.php', __DIR__ . '/src/Rector/Class_/TestListenerToHooksRector.php', __DIR__ . '/src/NodeFactory/ConsecutiveAssertionFactory.php', __DIR__ . '/src/NodeAnalyzer/TestsNodeAnalyzer.php', __DIR__ . '/src/NodeFactory/DataProviderClassMethodFactory.php', __DIR__ . '/config'], + StringClassNameToClassConstantRector::class => [__DIR__ . '/src/Rector/MethodCall/UseSpecificWillMethodRector.php', __DIR__ . '/src/Rector/Class_/TestListenerToHooksRector.php', __DIR__ . '/src/NodeFactory/ConsecutiveAssertionFactory.php', __DIR__ . '/src/NodeAnalyzer/TestsNodeAnalyzer.php', __DIR__ . '/src/NodeFactory/DataProviderClassMethodFactory.php', __DIR__ . '/config'], ]); // needed for DEAD_CODE list, just in split package like this $rectorConfig->import(__DIR__ . '/config/config.php'); - $rectorConfig->import(\Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_81); - $rectorConfig->import(\Rector\Set\ValueObject\SetList::DEAD_CODE); - $rectorConfig->import(\Rector\Set\ValueObject\SetList::CODE_QUALITY); - $rectorConfig->import(\Rector\Set\ValueObject\SetList::CODING_STYLE); - $rectorConfig->import(\Rector\Set\ValueObject\SetList::EARLY_RETURN); - $rectorConfig->import(\Rector\Set\ValueObject\SetList::NAMING); - $rectorConfig->ruleWithConfiguration(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class, [ + $rectorConfig->import(LevelSetList::UP_TO_PHP_81); + $rectorConfig->import(SetList::DEAD_CODE); + $rectorConfig->import(SetList::CODE_QUALITY); + $rectorConfig->import(SetList::CODING_STYLE); + $rectorConfig->import(SetList::EARLY_RETURN); + $rectorConfig->import(SetList::NAMING); + $rectorConfig->ruleWithConfiguration(StringClassNameToClassConstantRector::class, [ // keep unprefixed to protected from downgrade 'PHPUnit\\Framework\\Assert', 'PHPUnit\\Framework\\MockObject\\*', diff --git a/vendor/rector/rector-phpunit/src/NodeAnalyzer/AssertCallAnalyzer.php b/vendor/rector/rector-phpunit/src/NodeAnalyzer/AssertCallAnalyzer.php index eea2a835da0..78cdee3bee6 100644 --- a/vendor/rector/rector-phpunit/src/NodeAnalyzer/AssertCallAnalyzer.php +++ b/vendor/rector/rector-phpunit/src/NodeAnalyzer/AssertCallAnalyzer.php @@ -54,7 +54,7 @@ final class AssertCallAnalyzer * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\Core\PhpParser\AstResolver $astResolver, \PhpParser\PrettyPrinter\Standard $printerStandard, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(AstResolver $astResolver, Standard $printerStandard, BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver) { $this->astResolver = $astResolver; $this->printerStandard = $printerStandard; @@ -66,7 +66,7 @@ final class AssertCallAnalyzer { $this->classMethodNestingLevel = 0; } - public function containsAssertCall(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + public function containsAssertCall(ClassMethod $classMethod) : bool { ++$this->classMethodNestingLevel; // probably no assert method in the end @@ -88,28 +88,28 @@ final class AssertCallAnalyzer $this->containsAssertCallByClassMethod[$cacheHash] = $hasNestedAssertCall; return $hasNestedAssertCall; } - private function hasDirectAssertCall(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function hasDirectAssertCall(ClassMethod $classMethod) : bool { - return (bool) $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (\PhpParser\Node $node) : bool { - if ($node instanceof \PhpParser\Node\Expr\MethodCall) { + return (bool) $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (Node $node) : bool { + if ($node instanceof MethodCall) { $type = $this->nodeTypeResolver->getType($node->var); - if ($type instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType && \in_array($type->getClassName(), ['PHPUnit\\Framework\\MockObject\\MockBuilder', 'Prophecy\\Prophet'], \true)) { + if ($type instanceof FullyQualifiedObjectType && \in_array($type->getClassName(), ['PHPUnit\\Framework\\MockObject\\MockBuilder', 'Prophecy\\Prophet'], \true)) { return \true; } return $this->isAssertMethodName($node); } - if ($node instanceof \PhpParser\Node\Expr\StaticCall) { + if ($node instanceof StaticCall) { return $this->isAssertMethodName($node); } return \false; }); } - private function hasNestedAssertCall(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function hasNestedAssertCall(ClassMethod $classMethod) : bool { $currentClassMethod = $classMethod; // over and over the same method :/ - return (bool) $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (\PhpParser\Node $node) use($currentClassMethod) : bool { - if (!$node instanceof \PhpParser\Node\Expr\MethodCall && !$node instanceof \PhpParser\Node\Expr\StaticCall) { + return (bool) $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (Node $node) use($currentClassMethod) : bool { + if (!$node instanceof MethodCall && !$node instanceof StaticCall) { return \false; } $classMethod = $this->resolveClassMethodFromCall($node); @@ -126,15 +126,15 @@ final class AssertCallAnalyzer /** * @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $call */ - private function resolveClassMethodFromCall($call) : ?\PhpParser\Node\Stmt\ClassMethod + private function resolveClassMethodFromCall($call) : ?ClassMethod { - if ($call instanceof \PhpParser\Node\Expr\MethodCall) { + if ($call instanceof MethodCall) { $objectType = $this->nodeTypeResolver->getType($call->var); } else { // StaticCall $objectType = $this->nodeTypeResolver->getType($call->class); } - if (!$objectType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$objectType instanceof TypeWithClassName) { return null; } $methodName = $this->nodeNameResolver->getName($call->name); diff --git a/vendor/rector/rector-phpunit/src/NodeAnalyzer/IdentifierManipulator.php b/vendor/rector/rector-phpunit/src/NodeAnalyzer/IdentifierManipulator.php index 66d48db65c6..547cfcbd2ce 100644 --- a/vendor/rector/rector-phpunit/src/NodeAnalyzer/IdentifierManipulator.php +++ b/vendor/rector/rector-phpunit/src/NodeAnalyzer/IdentifierManipulator.php @@ -24,7 +24,7 @@ final class IdentifierManipulator * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } @@ -38,7 +38,7 @@ final class IdentifierManipulator if (!\is_string($oldNodeMethodName)) { return \false; } - $node->name = new \PhpParser\Node\Identifier($renameMethodMap[$oldNodeMethodName]); + $node->name = new Identifier($renameMethodMap[$oldNodeMethodName]); return \true; } /** @@ -46,7 +46,7 @@ final class IdentifierManipulator */ private function resolveOldMethodName($node) : ?string { - if ($node instanceof \PhpParser\Node\Expr\StaticCall || $node instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node instanceof StaticCall || $node instanceof MethodCall) { return $this->nodeNameResolver->getName($node->name); } return $this->nodeNameResolver->getName($node); diff --git a/vendor/rector/rector-phpunit/src/NodeAnalyzer/MockedVariableAnalyzer.php b/vendor/rector/rector-phpunit/src/NodeAnalyzer/MockedVariableAnalyzer.php index 00a1ecae53a..2021fbd9a92 100644 --- a/vendor/rector/rector-phpunit/src/NodeAnalyzer/MockedVariableAnalyzer.php +++ b/vendor/rector/rector-phpunit/src/NodeAnalyzer/MockedVariableAnalyzer.php @@ -30,37 +30,37 @@ final class MockedVariableAnalyzer * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->nodeNameResolver = $nodeNameResolver; $this->nodeTypeResolver = $nodeTypeResolver; } - public function containsMockAsUsedVariable(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + public function containsMockAsUsedVariable(ClassMethod $classMethod) : bool { $doesContainMock = \false; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classMethod, function (\PhpParser\Node $node) use(&$doesContainMock) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classMethod, function (Node $node) use(&$doesContainMock) { if ($this->isMockeryStaticCall($node)) { $doesContainMock = \true; return null; } - if (!$node instanceof \PhpParser\Node\Expr\PropertyFetch && !$node instanceof \PhpParser\Node\Expr\Variable) { + if (!$node instanceof PropertyFetch && !$node instanceof Variable) { return null; } $variableType = $this->nodeTypeResolver->getType($node); - if ($variableType instanceof \PHPStan\Type\MixedType) { + if ($variableType instanceof MixedType) { return null; } - if ($variableType->isSuperTypeOf(new \PHPStan\Type\ObjectType('PHPUnit\\Framework\\MockObject\\MockObject'))->yes()) { + if ($variableType->isSuperTypeOf(new ObjectType('PHPUnit\\Framework\\MockObject\\MockObject'))->yes()) { $doesContainMock = \true; } return null; }); return $doesContainMock; } - private function isMockeryStaticCall(\PhpParser\Node $node) : bool + private function isMockeryStaticCall(Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Expr\StaticCall) { + if (!$node instanceof StaticCall) { return \false; } // is mockery mock diff --git a/vendor/rector/rector-phpunit/src/NodeAnalyzer/SetUpMethodDecorator.php b/vendor/rector/rector-phpunit/src/NodeAnalyzer/SetUpMethodDecorator.php index 58ea498f169..a25421582d0 100644 --- a/vendor/rector/rector-phpunit/src/NodeAnalyzer/SetUpMethodDecorator.php +++ b/vendor/rector/rector-phpunit/src/NodeAnalyzer/SetUpMethodDecorator.php @@ -17,18 +17,18 @@ final class SetUpMethodDecorator * @var \Rector\Core\PhpParser\AstResolver */ private $astResolver; - public function __construct(\Rector\Core\PhpParser\AstResolver $astResolver) + public function __construct(AstResolver $astResolver) { $this->astResolver = $astResolver; } - public function decorate(\PhpParser\Node\Stmt\ClassMethod $classMethod) : void + public function decorate(ClassMethod $classMethod) : void { // skip test run - if (\Rector\Testing\PHPUnit\StaticPHPUnitEnvironment::isPHPUnitRun()) { + if (StaticPHPUnitEnvironment::isPHPUnitRun()) { return; } - $setUpClassMethod = $this->astResolver->resolveClassMethod('PHPUnit\\Framework\\TestCase', \Rector\Core\ValueObject\MethodName::SET_UP); - if (!$setUpClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $setUpClassMethod = $this->astResolver->resolveClassMethod('PHPUnit\\Framework\\TestCase', MethodName::SET_UP); + if (!$setUpClassMethod instanceof ClassMethod) { return; } $classMethod->returnType = $setUpClassMethod->returnType; diff --git a/vendor/rector/rector-phpunit/src/NodeAnalyzer/TestsNodeAnalyzer.php b/vendor/rector/rector-phpunit/src/NodeAnalyzer/TestsNodeAnalyzer.php index b73d06b84a4..ad3d73ef174 100644 --- a/vendor/rector/rector-phpunit/src/NodeAnalyzer/TestsNodeAnalyzer.php +++ b/vendor/rector/rector-phpunit/src/NodeAnalyzer/TestsNodeAnalyzer.php @@ -39,23 +39,23 @@ final class TestsNodeAnalyzer * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(NodeTypeResolver $nodeTypeResolver, NodeNameResolver $nodeNameResolver, PhpDocInfoFactory $phpDocInfoFactory, BetterNodeFinder $betterNodeFinder) { $this->nodeTypeResolver = $nodeTypeResolver; $this->nodeNameResolver = $nodeNameResolver; $this->phpDocInfoFactory = $phpDocInfoFactory; $this->betterNodeFinder = $betterNodeFinder; - $this->testCaseObjectTypes = [new \PHPStan\Type\ObjectType('PHPUnit\\Framework\\TestCase'), new \PHPStan\Type\ObjectType('PHPUnit_Framework_TestCase')]; + $this->testCaseObjectTypes = [new ObjectType('PHPUnit\\Framework\\TestCase'), new ObjectType('PHPUnit_Framework_TestCase')]; } - public function isInTestClass(\PhpParser\Node $node) : bool + public function isInTestClass(Node $node) : bool { - $classLike = $node instanceof \PhpParser\Node\Stmt\ClassLike ? $node : $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $node instanceof ClassLike ? $node : $this->betterNodeFinder->findParentType($node, ClassLike::class); + if (!$classLike instanceof ClassLike) { return \false; } return $this->nodeTypeResolver->isObjectTypes($classLike, $this->testCaseObjectTypes); } - public function isTestClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + public function isTestClassMethod(ClassMethod $classMethod) : bool { if (!$classMethod->isPublic()) { return \false; @@ -66,23 +66,23 @@ final class TestsNodeAnalyzer $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); return $phpDocInfo->hasByName('test'); } - public function isAssertMethodCallName(\PhpParser\Node $node, string $name) : bool + public function isAssertMethodCallName(Node $node, string $name) : bool { - if ($node instanceof \PhpParser\Node\Expr\StaticCall) { + if ($node instanceof StaticCall) { $callerType = $this->nodeTypeResolver->getType($node->class); - } elseif ($node instanceof \PhpParser\Node\Expr\MethodCall) { + } elseif ($node instanceof MethodCall) { $callerType = $this->nodeTypeResolver->getType($node->var); } else { return \false; } - $assertObjectType = new \PHPStan\Type\ObjectType('PHPUnit\\Framework\\Assert'); + $assertObjectType = new ObjectType('PHPUnit\\Framework\\Assert'); if (!$assertObjectType->isSuperTypeOf($callerType)->yes()) { return \false; } /** @var StaticCall|MethodCall $node */ return $this->nodeNameResolver->isName($node->name, $name); } - public function isInPHPUnitMethodCallName(\PhpParser\Node $node, string $name) : bool + public function isInPHPUnitMethodCallName(Node $node, string $name) : bool { if (!$this->isPHPUnitTestCaseCall($node)) { return \false; @@ -93,7 +93,7 @@ final class TestsNodeAnalyzer /** * @param string[] $names */ - public function isPHPUnitMethodCallNames(\PhpParser\Node $node, array $names) : bool + public function isPHPUnitMethodCallNames(Node $node, array $names) : bool { if (!$this->isPHPUnitTestCaseCall($node)) { return \false; @@ -101,11 +101,11 @@ final class TestsNodeAnalyzer /** @var MethodCall|StaticCall $node */ return $this->nodeNameResolver->isNames($node->name, $names); } - public function isPHPUnitTestCaseCall(\PhpParser\Node $node) : bool + public function isPHPUnitTestCaseCall(Node $node) : bool { if (!$this->isInTestClass($node)) { return \false; } - return $node instanceof \PhpParser\Node\Expr\MethodCall || $node instanceof \PhpParser\Node\Expr\StaticCall; + return $node instanceof MethodCall || $node instanceof StaticCall; } } diff --git a/vendor/rector/rector-phpunit/src/NodeFactory/ArgumentShiftingFactory.php b/vendor/rector/rector-phpunit/src/NodeFactory/ArgumentShiftingFactory.php index 45e810b0a84..0632ed89b95 100644 --- a/vendor/rector/rector-phpunit/src/NodeFactory/ArgumentShiftingFactory.php +++ b/vendor/rector/rector-phpunit/src/NodeFactory/ArgumentShiftingFactory.php @@ -7,9 +7,9 @@ use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Identifier; final class ArgumentShiftingFactory { - public function removeAllButFirstArgMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall, string $methodName) : void + public function removeAllButFirstArgMethodCall(MethodCall $methodCall, string $methodName) : void { - $methodCall->name = new \PhpParser\Node\Identifier($methodName); + $methodCall->name = new Identifier($methodName); foreach (\array_keys($methodCall->args) as $i) { // keep first arg if ($i === 0) { diff --git a/vendor/rector/rector-phpunit/src/NodeFactory/AssertCallFactory.php b/vendor/rector/rector-phpunit/src/NodeFactory/AssertCallFactory.php index ec6a7afe9e5..8b54ad4a3df 100644 --- a/vendor/rector/rector-phpunit/src/NodeFactory/AssertCallFactory.php +++ b/vendor/rector/rector-phpunit/src/NodeFactory/AssertCallFactory.php @@ -13,9 +13,9 @@ final class AssertCallFactory */ public function createCallWithName($node, string $name) { - if ($node instanceof \PhpParser\Node\Expr\MethodCall) { - return new \PhpParser\Node\Expr\MethodCall($node->var, $name); + if ($node instanceof MethodCall) { + return new MethodCall($node->var, $name); } - return new \PhpParser\Node\Expr\StaticCall($node->class, $name); + return new StaticCall($node->class, $name); } } diff --git a/vendor/rector/rector-phpunit/src/NodeFactory/DataProviderClassMethodFactory.php b/vendor/rector/rector-phpunit/src/NodeFactory/DataProviderClassMethodFactory.php index 5870a1fb2c6..5db5f2adb67 100644 --- a/vendor/rector/rector-phpunit/src/NodeFactory/DataProviderClassMethodFactory.php +++ b/vendor/rector/rector-phpunit/src/NodeFactory/DataProviderClassMethodFactory.php @@ -13,29 +13,29 @@ use Rector\PHPUnit\ValueObject\DataProviderClassMethodRecipe; use RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\MethodBuilder; final class DataProviderClassMethodFactory { - public function createFromRecipe(\Rector\PHPUnit\ValueObject\DataProviderClassMethodRecipe $dataProviderClassMethodRecipe) : \PhpParser\Node\Stmt\ClassMethod + public function createFromRecipe(DataProviderClassMethodRecipe $dataProviderClassMethodRecipe) : ClassMethod { - $methodBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\MethodBuilder($dataProviderClassMethodRecipe->getMethodName()); + $methodBuilder = new MethodBuilder($dataProviderClassMethodRecipe->getMethodName()); $methodBuilder->makePublic(); $classMethod = $methodBuilder->getNode(); foreach ($dataProviderClassMethodRecipe->getArgs() as $arg) { $value = $arg->value; - if (!$value instanceof \PhpParser\Node\Expr\Array_) { + if (!$value instanceof Array_) { continue; } foreach ($value->items as $arrayItem) { - if (!$arrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$arrayItem instanceof ArrayItem) { continue; } - $returnStatement = new \PhpParser\Node\Expr\Yield_(new \PhpParser\Node\Expr\Array_([new \PhpParser\Node\Expr\ArrayItem($arrayItem->value)])); - $classMethod->stmts[] = new \PhpParser\Node\Stmt\Expression($returnStatement); + $returnStatement = new Yield_(new Array_([new ArrayItem($arrayItem->value)])); + $classMethod->stmts[] = new Expression($returnStatement); } } $this->decorateClassMethodWithReturnTypeAndTag($classMethod); return $classMethod; } - private function decorateClassMethodWithReturnTypeAndTag(\PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function decorateClassMethodWithReturnTypeAndTag(ClassMethod $classMethod) : void { - $classMethod->returnType = new \PhpParser\Node\Name\FullyQualified('Iterator'); + $classMethod->returnType = new FullyQualified('Iterator'); } } diff --git a/vendor/rector/rector-phpunit/src/NodeFactory/ExpectExceptionCodeFactory.php b/vendor/rector/rector-phpunit/src/NodeFactory/ExpectExceptionCodeFactory.php index da9381b4650..05d7412411b 100644 --- a/vendor/rector/rector-phpunit/src/NodeFactory/ExpectExceptionCodeFactory.php +++ b/vendor/rector/rector-phpunit/src/NodeFactory/ExpectExceptionCodeFactory.php @@ -24,19 +24,19 @@ final class ExpectExceptionCodeFactory * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\PHPUnit\NodeFactory\ArgumentShiftingFactory $argumentShiftingFactory, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(NodeNameResolver $nodeNameResolver, \Rector\PHPUnit\NodeFactory\ArgumentShiftingFactory $argumentShiftingFactory, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->nodeNameResolver = $nodeNameResolver; $this->argumentShiftingFactory = $argumentShiftingFactory; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function create(\PhpParser\Node\Expr\MethodCall $methodCall, \PhpParser\Node\Expr\Variable $exceptionVariable) : ?\PhpParser\Node\Expr\MethodCall + public function create(MethodCall $methodCall, Variable $exceptionVariable) : ?MethodCall { if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($methodCall, ['assertSame', 'assertEquals'])) { return null; } $secondArgument = $methodCall->args[1]->value; - if (!$secondArgument instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$secondArgument instanceof MethodCall) { return null; } // looking for "$exception->getMessage()" diff --git a/vendor/rector/rector-phpunit/src/NodeFactory/ExpectExceptionFactory.php b/vendor/rector/rector-phpunit/src/NodeFactory/ExpectExceptionFactory.php index 5646904a956..8bb7c7f8b48 100644 --- a/vendor/rector/rector-phpunit/src/NodeFactory/ExpectExceptionFactory.php +++ b/vendor/rector/rector-phpunit/src/NodeFactory/ExpectExceptionFactory.php @@ -19,12 +19,12 @@ final class ExpectExceptionFactory * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(NodeNameResolver $nodeNameResolver, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->nodeNameResolver = $nodeNameResolver; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function create(\PhpParser\Node\Expr\MethodCall $methodCall, \PhpParser\Node\Expr\Variable $variable) : ?\PhpParser\Node\Expr\MethodCall + public function create(MethodCall $methodCall, Variable $variable) : ?MethodCall { if (!$this->testsNodeAnalyzer->isInPHPUnitMethodCallName($methodCall, 'assertInstanceOf')) { return null; @@ -37,6 +37,6 @@ final class ExpectExceptionFactory if (!$this->nodeNameResolver->isName($variable, $argumentVariableName)) { return null; } - return new \PhpParser\Node\Expr\MethodCall($methodCall->var, 'expectException', [$methodCall->args[0]]); + return new MethodCall($methodCall->var, 'expectException', [$methodCall->args[0]]); } } diff --git a/vendor/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMessageFactory.php b/vendor/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMessageFactory.php index 31772f11673..2ef78ffd7d1 100644 --- a/vendor/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMessageFactory.php +++ b/vendor/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMessageFactory.php @@ -30,20 +30,20 @@ final class ExpectExceptionMessageFactory * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\PHPUnit\NodeFactory\ArgumentShiftingFactory $argumentShiftingFactory, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(NodeNameResolver $nodeNameResolver, \Rector\PHPUnit\NodeFactory\ArgumentShiftingFactory $argumentShiftingFactory, NodeComparator $nodeComparator, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->nodeNameResolver = $nodeNameResolver; $this->argumentShiftingFactory = $argumentShiftingFactory; $this->nodeComparator = $nodeComparator; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function create(\PhpParser\Node\Expr\MethodCall $methodCall, \PhpParser\Node\Expr\Variable $exceptionVariable) : ?\PhpParser\Node\Expr\MethodCall + public function create(MethodCall $methodCall, Variable $exceptionVariable) : ?MethodCall { if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($methodCall, ['assertSame', 'assertEquals'])) { return null; } $secondArgument = $methodCall->args[1]->value; - if (!$secondArgument instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$secondArgument instanceof MethodCall) { return null; } if (!$this->nodeComparator->areNodesEqual($secondArgument->var, $exceptionVariable)) { diff --git a/vendor/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMessageRegExpFactory.php b/vendor/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMessageRegExpFactory.php index a40e43d32a3..98ea2a3466c 100644 --- a/vendor/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMessageRegExpFactory.php +++ b/vendor/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMessageRegExpFactory.php @@ -31,20 +31,20 @@ final class ExpectExceptionMessageRegExpFactory * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\PHPUnit\NodeFactory\ArgumentShiftingFactory $argumentShiftingFactory, \Rector\Core\PhpParser\Comparing\NodeComparator $nodeComparator, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(NodeNameResolver $nodeNameResolver, \Rector\PHPUnit\NodeFactory\ArgumentShiftingFactory $argumentShiftingFactory, NodeComparator $nodeComparator, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->nodeNameResolver = $nodeNameResolver; $this->argumentShiftingFactory = $argumentShiftingFactory; $this->nodeComparator = $nodeComparator; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function create(\PhpParser\Node\Expr\MethodCall $methodCall, \PhpParser\Node\Expr\Variable $exceptionVariable) : ?\PhpParser\Node\Expr\MethodCall + public function create(MethodCall $methodCall, Variable $exceptionVariable) : ?MethodCall { if (!$this->testsNodeAnalyzer->isInPHPUnitMethodCallName($methodCall, 'assertContains')) { return null; } $secondArgument = $methodCall->args[1]->value; - if (!$secondArgument instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$secondArgument instanceof MethodCall) { return null; } // looking for "$exception->getMessage()" @@ -56,10 +56,10 @@ final class ExpectExceptionMessageRegExpFactory } $this->argumentShiftingFactory->removeAllButFirstArgMethodCall($methodCall, 'expectExceptionMessageRegExp'); // put regex between "#...#" to create match - if ($methodCall->args[0]->value instanceof \PhpParser\Node\Scalar\String_) { + if ($methodCall->args[0]->value instanceof String_) { /** @var String_ $oldString */ $oldString = $methodCall->args[0]->value; - $methodCall->args[0]->value = new \PhpParser\Node\Scalar\String_('#' . \preg_quote($oldString->value, '#') . '#'); + $methodCall->args[0]->value = new String_('#' . \preg_quote($oldString->value, '#') . '#'); } return $methodCall; } diff --git a/vendor/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMethodCallFactory.php b/vendor/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMethodCallFactory.php index 770f20dc907..f871bceee44 100644 --- a/vendor/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMethodCallFactory.php +++ b/vendor/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMethodCallFactory.php @@ -24,7 +24,7 @@ final class ExpectExceptionMethodCallFactory * @var \Rector\PHPUnit\PhpDoc\PhpDocValueToNodeMapper */ private $phpDocValueToNodeMapper; - public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\PHPUnit\PhpDoc\PhpDocValueToNodeMapper $phpDocValueToNodeMapper) + public function __construct(NodeFactory $nodeFactory, PhpDocValueToNodeMapper $phpDocValueToNodeMapper) { $this->nodeFactory = $nodeFactory; $this->phpDocValueToNodeMapper = $phpDocValueToNodeMapper; @@ -38,16 +38,16 @@ final class ExpectExceptionMethodCallFactory $methodCallExpressions = []; foreach ($phpDocTagNodes as $phpDocTagNode) { $methodCall = $this->createMethodCall($phpDocTagNode, $methodName); - $methodCallExpressions[] = new \PhpParser\Node\Stmt\Expression($methodCall); + $methodCallExpressions[] = new Expression($methodCall); } return $methodCallExpressions; } - private function createMethodCall(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode $phpDocTagNode, string $methodName) : \PhpParser\Node\Expr\MethodCall + private function createMethodCall(PhpDocTagNode $phpDocTagNode, string $methodName) : MethodCall { - if (!$phpDocTagNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$phpDocTagNode->value instanceof GenericTagValueNode) { + throw new ShouldNotHappenException(); } - $node = $phpDocTagNode->name === '@expectedExceptionMessage' ? new \PhpParser\Node\Scalar\String_($phpDocTagNode->value->value) : $this->phpDocValueToNodeMapper->mapGenericTagValueNode($phpDocTagNode->value); - return $this->nodeFactory->createMethodCall('this', $methodName, [new \PhpParser\Node\Arg($node)]); + $node = $phpDocTagNode->name === '@expectedExceptionMessage' ? new String_($phpDocTagNode->value->value) : $this->phpDocValueToNodeMapper->mapGenericTagValueNode($phpDocTagNode->value); + return $this->nodeFactory->createMethodCall('this', $methodName, [new Arg($node)]); } } diff --git a/vendor/rector/rector-phpunit/src/NodeFactory/SetUpClassMethodFactory.php b/vendor/rector/rector-phpunit/src/NodeFactory/SetUpClassMethodFactory.php index d9b0ee6d529..f1aacac893a 100644 --- a/vendor/rector/rector-phpunit/src/NodeFactory/SetUpClassMethodFactory.php +++ b/vendor/rector/rector-phpunit/src/NodeFactory/SetUpClassMethodFactory.php @@ -30,7 +30,7 @@ final class SetUpClassMethodFactory * @var \Rector\Core\PhpParser\Node\NodeFactory */ private $nodeFactory; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\SetUpMethodDecorator $setUpMethodDecorator, \Rector\PHPUnit\NodeManipulator\StmtManipulator $stmtManipulator, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory) + public function __construct(SetUpMethodDecorator $setUpMethodDecorator, StmtManipulator $stmtManipulator, NodeFactory $nodeFactory) { $this->setUpMethodDecorator = $setUpMethodDecorator; $this->stmtManipulator = $stmtManipulator; @@ -39,10 +39,10 @@ final class SetUpClassMethodFactory /** * @param Stmt[]|Expr[] $stmts */ - public function createSetUpMethod(array $stmts) : \PhpParser\Node\Stmt\ClassMethod + public function createSetUpMethod(array $stmts) : ClassMethod { $stmts = $this->stmtManipulator->normalizeStmts($stmts); - $classMethodBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\MethodBuilder(\Rector\Core\ValueObject\MethodName::SET_UP); + $classMethodBuilder = new MethodBuilder(MethodName::SET_UP); $classMethodBuilder->makeProtected(); $classMethodBuilder->addStmt($this->createParentStaticCall()); $classMethodBuilder->addStmts($stmts); @@ -50,9 +50,9 @@ final class SetUpClassMethodFactory $this->setUpMethodDecorator->decorate($classMethod); return $classMethod; } - public function createParentStaticCall() : \PhpParser\Node\Stmt\Expression + public function createParentStaticCall() : Expression { - $parentSetupStaticCall = $this->nodeFactory->createStaticCall(\Rector\Core\Enum\ObjectReference::PARENT, \Rector\Core\ValueObject\MethodName::SET_UP); - return new \PhpParser\Node\Stmt\Expression($parentSetupStaticCall); + $parentSetupStaticCall = $this->nodeFactory->createStaticCall(ObjectReference::PARENT, MethodName::SET_UP); + return new Expression($parentSetupStaticCall); } } diff --git a/vendor/rector/rector-phpunit/src/NodeManipulator/ParamAndArgFromArrayResolver.php b/vendor/rector/rector-phpunit/src/NodeManipulator/ParamAndArgFromArrayResolver.php index cc520879cc4..474ee32e96f 100644 --- a/vendor/rector/rector-phpunit/src/NodeManipulator/ParamAndArgFromArrayResolver.php +++ b/vendor/rector/rector-phpunit/src/NodeManipulator/ParamAndArgFromArrayResolver.php @@ -22,7 +22,7 @@ final class ParamAndArgFromArrayResolver * @var \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory */ private $typeFactory; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory) + public function __construct(NodeTypeResolver $nodeTypeResolver, TypeFactory $typeFactory) { $this->nodeTypeResolver = $nodeTypeResolver; $this->typeFactory = $typeFactory; @@ -30,7 +30,7 @@ final class ParamAndArgFromArrayResolver /** * @return ParamAndArg[] */ - public function resolve(\PhpParser\Node\Expr\Array_ $array, string $variableName) : array + public function resolve(Array_ $array, string $variableName) : array { $isNestedArray = $this->isNestedArray($array); if ($isNestedArray) { @@ -39,13 +39,13 @@ final class ParamAndArgFromArrayResolver $itemsStaticType = $this->resolveItemStaticType($array, $isNestedArray); return $this->collectParamAndArgsFromNonNestedArray($array, $variableName, $itemsStaticType); } - private function isNestedArray(\PhpParser\Node\Expr\Array_ $array) : bool + private function isNestedArray(Array_ $array) : bool { foreach ($array->items as $arrayItem) { - if (!$arrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$arrayItem instanceof ArrayItem) { continue; } - if ($arrayItem->value instanceof \PhpParser\Node\Expr\Array_) { + if ($arrayItem->value instanceof Array_) { return \true; } } @@ -54,36 +54,36 @@ final class ParamAndArgFromArrayResolver /** * @return ParamAndArg[] */ - private function collectParamAndArgsFromNestedArray(\PhpParser\Node\Expr\Array_ $array, string $variableName) : array + private function collectParamAndArgsFromNestedArray(Array_ $array, string $variableName) : array { $paramAndArgs = []; $i = 1; foreach ($array->items as $arrayItem) { - if (!$arrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$arrayItem instanceof ArrayItem) { continue; } $nestedArray = $arrayItem->value; - if (!$nestedArray instanceof \PhpParser\Node\Expr\Array_) { + if (!$nestedArray instanceof Array_) { continue; } foreach ($nestedArray->items as $nestedArrayItem) { - if (!$nestedArrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$nestedArrayItem instanceof ArrayItem) { continue; } - $variable = new \PhpParser\Node\Expr\Variable($variableName . ($i === 1 ? '' : $i)); + $variable = new Variable($variableName . ($i === 1 ? '' : $i)); $itemsStaticType = $this->nodeTypeResolver->getType($nestedArrayItem->value); - $paramAndArgs[] = new \Rector\PHPUnit\ValueObject\ParamAndArg($variable, $itemsStaticType); + $paramAndArgs[] = new ParamAndArg($variable, $itemsStaticType); ++$i; } } return $paramAndArgs; } - private function resolveItemStaticType(\PhpParser\Node\Expr\Array_ $array, bool $isNestedArray) : \PHPStan\Type\Type + private function resolveItemStaticType(Array_ $array, bool $isNestedArray) : Type { $staticTypes = []; if (!$isNestedArray) { foreach ($array->items as $arrayItem) { - if (!$arrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$arrayItem instanceof ArrayItem) { continue; } $staticTypes[] = $this->nodeTypeResolver->getType($arrayItem->value); @@ -94,18 +94,18 @@ final class ParamAndArgFromArrayResolver /** * @return ParamAndArg[] */ - private function collectParamAndArgsFromNonNestedArray(\PhpParser\Node\Expr\Array_ $array, string $variableName, \PHPStan\Type\Type $itemsStaticType) : array + private function collectParamAndArgsFromNonNestedArray(Array_ $array, string $variableName, Type $itemsStaticType) : array { $i = 1; $paramAndArgs = []; foreach ($array->items as $arrayItem) { - if (!$arrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$arrayItem instanceof ArrayItem) { continue; } - $variable = new \PhpParser\Node\Expr\Variable($variableName . ($i === 1 ? '' : $i)); - $paramAndArgs[] = new \Rector\PHPUnit\ValueObject\ParamAndArg($variable, $itemsStaticType); + $variable = new Variable($variableName . ($i === 1 ? '' : $i)); + $paramAndArgs[] = new ParamAndArg($variable, $itemsStaticType); ++$i; - if (!$arrayItem->value instanceof \PhpParser\Node\Expr\Array_) { + if (!$arrayItem->value instanceof Array_) { break; } } diff --git a/vendor/rector/rector-phpunit/src/NodeManipulator/SetUpClassMethodNodeManipulator.php b/vendor/rector/rector-phpunit/src/NodeManipulator/SetUpClassMethodNodeManipulator.php index 10c9b1d6824..bd9644c828b 100644 --- a/vendor/rector/rector-phpunit/src/NodeManipulator/SetUpClassMethodNodeManipulator.php +++ b/vendor/rector/rector-phpunit/src/NodeManipulator/SetUpClassMethodNodeManipulator.php @@ -21,7 +21,7 @@ final class SetUpClassMethodNodeManipulator * @var \Rector\PHPUnit\NodeManipulator\StmtManipulator */ private $stmtManipulator; - public function __construct(\Rector\PHPUnit\NodeFactory\SetUpClassMethodFactory $setUpClassMethodFactory, \Rector\PHPUnit\NodeManipulator\StmtManipulator $stmtManipulator) + public function __construct(SetUpClassMethodFactory $setUpClassMethodFactory, \Rector\PHPUnit\NodeManipulator\StmtManipulator $stmtManipulator) { $this->setUpClassMethodFactory = $setUpClassMethodFactory; $this->stmtManipulator = $stmtManipulator; @@ -29,11 +29,11 @@ final class SetUpClassMethodNodeManipulator /** * @param Stmt[]|Expr[] $stmts */ - public function decorateOrCreate(\PhpParser\Node\Stmt\Class_ $class, array $stmts) : void + public function decorateOrCreate(Class_ $class, array $stmts) : void { $stmts = $this->stmtManipulator->normalizeStmts($stmts); - $setUpClassMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::SET_UP); - if (!$setUpClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $setUpClassMethod = $class->getMethod(MethodName::SET_UP); + if (!$setUpClassMethod instanceof ClassMethod) { $setUpClassMethod = $this->setUpClassMethodFactory->createSetUpMethod($stmts); $class->stmts = \array_merge([$setUpClassMethod], $class->stmts); } else { diff --git a/vendor/rector/rector-phpunit/src/NodeManipulator/StmtManipulator.php b/vendor/rector/rector-phpunit/src/NodeManipulator/StmtManipulator.php index 39082a2bd7f..c6099a75b3f 100644 --- a/vendor/rector/rector-phpunit/src/NodeManipulator/StmtManipulator.php +++ b/vendor/rector/rector-phpunit/src/NodeManipulator/StmtManipulator.php @@ -16,11 +16,11 @@ final class StmtManipulator { $normalizedStmts = []; foreach ($stmts as $stmt) { - if ($stmt instanceof \PhpParser\Node\Stmt\Expression) { + if ($stmt instanceof Expression) { $normalizedStmts[] = $stmt; continue; } - $normalizedStmts[] = new \PhpParser\Node\Stmt\Expression($stmt); + $normalizedStmts[] = new Expression($stmt); } return $normalizedStmts; } diff --git a/vendor/rector/rector-phpunit/src/PhpDoc/PhpDocValueToNodeMapper.php b/vendor/rector/rector-phpunit/src/PhpDoc/PhpDocValueToNodeMapper.php index 6ced85ce064..99d4437becd 100644 --- a/vendor/rector/rector-phpunit/src/PhpDoc/PhpDocValueToNodeMapper.php +++ b/vendor/rector/rector-phpunit/src/PhpDoc/PhpDocValueToNodeMapper.php @@ -20,12 +20,12 @@ final class PhpDocValueToNodeMapper * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(NodeFactory $nodeFactory, ReflectionProvider $reflectionProvider) { $this->nodeFactory = $nodeFactory; $this->reflectionProvider = $reflectionProvider; } - public function mapGenericTagValueNode(\PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode $genericTagValueNode) : \PhpParser\Node\Expr + public function mapGenericTagValueNode(GenericTagValueNode $genericTagValueNode) : Expr { if (\strpos($genericTagValueNode->value, '::') !== \false) { [$class, $constant] = \explode('::', $genericTagValueNode->value); @@ -35,6 +35,6 @@ final class PhpDocValueToNodeMapper if ($this->reflectionProvider->hasClass($reference)) { return $this->nodeFactory->createClassConstReference($reference); } - return new \PhpParser\Node\Scalar\String_($reference); + return new String_($reference); } } diff --git a/vendor/rector/rector-phpunit/src/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector.php b/vendor/rector/rector-phpunit/src/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector.php index f28b8066e93..66d8f1e8de1 100644 --- a/vendor/rector/rector-phpunit/src/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector.php @@ -11,15 +11,15 @@ use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\AssertCallAnalyzer; use Rector\PHPUnit\NodeAnalyzer\MockedVariableAnalyzer; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://phpunit.readthedocs.io/en/7.3/annotations.html#doesnotperformassertions * @see https://github.com/sebastianbergmann/phpunit/issues/2484 * * @see \Rector\PHPUnit\Tests\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\AddDoesNotPerformAssertionToNonAssertingTestRectorTest */ -final class AddDoesNotPerformAssertionToNonAssertingTestRector extends \Rector\Core\Rector\AbstractRector +final class AddDoesNotPerformAssertionToNonAssertingTestRector extends AbstractRector { /** * @readonly @@ -36,15 +36,15 @@ final class AddDoesNotPerformAssertionToNonAssertingTestRector extends \Rector\C * @var \Rector\PHPUnit\NodeAnalyzer\MockedVariableAnalyzer */ private $mockedVariableAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer, \Rector\PHPUnit\NodeAnalyzer\AssertCallAnalyzer $assertCallAnalyzer, \Rector\PHPUnit\NodeAnalyzer\MockedVariableAnalyzer $mockedVariableAnalyzer) + public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer, AssertCallAnalyzer $assertCallAnalyzer, MockedVariableAnalyzer $mockedVariableAnalyzer) { $this->testsNodeAnalyzer = $testsNodeAnalyzer; $this->assertCallAnalyzer = $assertCallAnalyzer; $this->mockedVariableAnalyzer = $mockedVariableAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Tests without assertion will have @doesNotPerformAssertion', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Tests without assertion will have @doesNotPerformAssertion', [new CodeSample(<<<'CODE_SAMPLE' use PHPUnit\Framework\TestCase; class SomeClass extends TestCase @@ -76,12 +76,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkipClassMethod($node)) { return null; @@ -89,7 +89,7 @@ CODE_SAMPLE $this->addDoesNotPerformAssertions($node); return $node; } - private function shouldSkipClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function shouldSkipClassMethod(ClassMethod $classMethod) : bool { if (!$this->testsNodeAnalyzer->isInTestClass($classMethod)) { return \true; @@ -107,9 +107,9 @@ CODE_SAMPLE } return $this->mockedVariableAnalyzer->containsMockAsUsedVariable($classMethod); } - private function addDoesNotPerformAssertions(\PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function addDoesNotPerformAssertions(ClassMethod $classMethod) : void { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); - $phpDocInfo->addPhpDocTagNode(new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode('@doesNotPerformAssertions', new \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode(''))); + $phpDocInfo->addPhpDocTagNode(new PhpDocTagNode('@doesNotPerformAssertions', new GenericTagValueNode(''))); } } diff --git a/vendor/rector/rector-phpunit/src/Rector/ClassMethod/ExceptionAnnotationRector.php b/vendor/rector/rector-phpunit/src/Rector/ClassMethod/ExceptionAnnotationRector.php index a2eccfca1a5..ee871d05464 100644 --- a/vendor/rector/rector-phpunit/src/Rector/ClassMethod/ExceptionAnnotationRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/ClassMethod/ExceptionAnnotationRector.php @@ -9,15 +9,15 @@ use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\PHPUnit\NodeFactory\ExpectExceptionMethodCallFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://thephp.cc/news/2016/02/questioning-phpunit-best-practices * @see https://github.com/sebastianbergmann/phpunit/commit/17c09b33ac5d9cad1459ace0ae7b1f942d1e9afd * * @see \Rector\PHPUnit\Tests\Rector\ClassMethod\ExceptionAnnotationRector\ExceptionAnnotationRectorTest */ -final class ExceptionAnnotationRector extends \Rector\Core\Rector\AbstractRector +final class ExceptionAnnotationRector extends AbstractRector { /** * In reversed order, which they should be called in code. @@ -40,15 +40,15 @@ final class ExceptionAnnotationRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeFactory\ExpectExceptionMethodCallFactory $expectExceptionMethodCallFactory, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover $phpDocTagRemover, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(ExpectExceptionMethodCallFactory $expectExceptionMethodCallFactory, PhpDocTagRemover $phpDocTagRemover, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->expectExceptionMethodCallFactory = $expectExceptionMethodCallFactory; $this->phpDocTagRemover = $phpDocTagRemover; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes `@expectedException annotations to `expectException*()` methods', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes `@expectedException annotations to `expectException*()` methods', [new CodeSample(<<<'CODE_SAMPLE' /** * @expectedException Exception * @expectedExceptionMessage Message @@ -73,12 +73,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isInTestClass($node)) { return null; diff --git a/vendor/rector/rector-phpunit/src/Rector/ClassMethod/RemoveEmptyTestMethodRector.php b/vendor/rector/rector-phpunit/src/Rector/ClassMethod/RemoveEmptyTestMethodRector.php index a62c06f9c2c..963753338a6 100644 --- a/vendor/rector/rector-phpunit/src/Rector/ClassMethod/RemoveEmptyTestMethodRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/ClassMethod/RemoveEmptyTestMethodRector.php @@ -7,25 +7,25 @@ use PhpParser\Node; use PhpParser\Node\Stmt\ClassMethod; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\Rector\ClassMethod\RemoveEmptyTestMethodRector\RemoveEmptyTestMethodRectorTest */ -final class RemoveEmptyTestMethodRector extends \Rector\Core\Rector\AbstractRector +final class RemoveEmptyTestMethodRector extends AbstractRector { /** * @readonly * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer) { $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove empty test methods', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove empty test methods', [new CodeSample(<<<'CODE_SAMPLE' class SomeTest extends \PHPUnit\Framework\TestCase { /** @@ -50,12 +50,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isInTestClass($node)) { return null; diff --git a/vendor/rector/rector-phpunit/src/Rector/ClassMethod/ReplaceTestAnnotationWithPrefixedFunctionRector.php b/vendor/rector/rector-phpunit/src/Rector/ClassMethod/ReplaceTestAnnotationWithPrefixedFunctionRector.php index 0ee3a1a5d36..bb3d94f889c 100644 --- a/vendor/rector/rector-phpunit/src/Rector/ClassMethod/ReplaceTestAnnotationWithPrefixedFunctionRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/ClassMethod/ReplaceTestAnnotationWithPrefixedFunctionRector.php @@ -9,12 +9,12 @@ use PhpParser\Node\Stmt\ClassMethod; use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\Rector\ClassMethod\ReplaceTestAnnotationWithPrefixedFunctionRector\ReplaceTestAnnotationWithPrefixedFunctionRectorTest */ -final class ReplaceTestAnnotationWithPrefixedFunctionRector extends \Rector\Core\Rector\AbstractRector +final class ReplaceTestAnnotationWithPrefixedFunctionRector extends AbstractRector { /** * @readonly @@ -26,14 +26,14 @@ final class ReplaceTestAnnotationWithPrefixedFunctionRector extends \Rector\Core * @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover */ private $phpDocTagRemover; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover $phpDocTagRemover) + public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer, PhpDocTagRemover $phpDocTagRemover) { $this->testsNodeAnalyzer = $testsNodeAnalyzer; $this->phpDocTagRemover = $phpDocTagRemover; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace @test with prefixed function', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace @test with prefixed function', [new CodeSample(<<<'CODE_SAMPLE' class SomeTest extends \PHPUnit\Framework\TestCase { /** @@ -61,12 +61,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isInTestClass($node)) { return null; @@ -75,7 +75,7 @@ CODE_SAMPLE return null; } $docComment = $node->getDocComment(); - if (!$docComment instanceof \PhpParser\Comment\Doc) { + if (!$docComment instanceof Doc) { return null; } if (\strpos($docComment->getText(), '@test') === \false) { diff --git a/vendor/rector/rector-phpunit/src/Rector/ClassMethod/TryCatchToExpectExceptionRector.php b/vendor/rector/rector-phpunit/src/Rector/ClassMethod/TryCatchToExpectExceptionRector.php index d1360bd0d5f..1be9d54028b 100644 --- a/vendor/rector/rector-phpunit/src/Rector/ClassMethod/TryCatchToExpectExceptionRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/ClassMethod/TryCatchToExpectExceptionRector.php @@ -15,12 +15,12 @@ use Rector\PHPUnit\NodeFactory\ExpectExceptionCodeFactory; use Rector\PHPUnit\NodeFactory\ExpectExceptionFactory; use Rector\PHPUnit\NodeFactory\ExpectExceptionMessageFactory; use Rector\PHPUnit\NodeFactory\ExpectExceptionMessageRegExpFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\Rector\ClassMethod\TryCatchToExpectExceptionRector\TryCatchToExpectExceptionRectorTest */ -final class TryCatchToExpectExceptionRector extends \Rector\Core\Rector\AbstractRector +final class TryCatchToExpectExceptionRector extends AbstractRector { /** * @readonly @@ -47,7 +47,7 @@ final class TryCatchToExpectExceptionRector extends \Rector\Core\Rector\Abstract * @var \Rector\PHPUnit\NodeFactory\ExpectExceptionMessageFactory */ private $expectExceptionMessageFactory; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer, \Rector\PHPUnit\NodeFactory\ExpectExceptionCodeFactory $expectExceptionCodeFactory, \Rector\PHPUnit\NodeFactory\ExpectExceptionMessageRegExpFactory $expectExceptionMessageRegExpFactory, \Rector\PHPUnit\NodeFactory\ExpectExceptionFactory $expectExceptionFactory, \Rector\PHPUnit\NodeFactory\ExpectExceptionMessageFactory $expectExceptionMessageFactory) + public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer, ExpectExceptionCodeFactory $expectExceptionCodeFactory, ExpectExceptionMessageRegExpFactory $expectExceptionMessageRegExpFactory, ExpectExceptionFactory $expectExceptionFactory, ExpectExceptionMessageFactory $expectExceptionMessageFactory) { $this->testsNodeAnalyzer = $testsNodeAnalyzer; $this->expectExceptionCodeFactory = $expectExceptionCodeFactory; @@ -55,9 +55,9 @@ final class TryCatchToExpectExceptionRector extends \Rector\Core\Rector\Abstract $this->expectExceptionFactory = $expectExceptionFactory; $this->expectExceptionMessageFactory = $expectExceptionMessageFactory; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns try/catch to expectException() call', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns try/catch to expectException() call', [new CodeSample(<<<'CODE_SAMPLE' try { $someService->run(); } catch (Throwable $exception) { @@ -77,12 +77,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isInTestClass($node)) { return null; @@ -92,7 +92,7 @@ CODE_SAMPLE } $proccesed = []; foreach ($node->stmts as $key => $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\TryCatch) { + if (!$stmt instanceof TryCatch) { continue; } $proccesed = $this->processTryCatch($stmt); @@ -108,10 +108,10 @@ CODE_SAMPLE /** * @return Expression[]|null */ - private function processTryCatch(\PhpParser\Node\Stmt\TryCatch $tryCatch) : ?array + private function processTryCatch(TryCatch $tryCatch) : ?array { $exceptionVariable = $this->matchSingleExceptionVariable($tryCatch); - if (!$exceptionVariable instanceof \PhpParser\Node\Expr\Variable) { + if (!$exceptionVariable instanceof Variable) { return null; } // we look for: @@ -121,10 +121,10 @@ CODE_SAMPLE $newMethodCalls = []; foreach ($tryCatch->catches[0]->stmts as $catchedStmt) { // not a match - if (!$catchedStmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$catchedStmt instanceof Expression) { return null; } - if (!$catchedStmt->expr instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$catchedStmt->expr instanceof MethodCall) { continue; } $methodCallNode = $catchedStmt->expr; @@ -137,14 +137,14 @@ CODE_SAMPLE $newExpressions = $this->wrapInExpressions($newMethodCalls); // return all statements foreach ($tryCatch->stmts as $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { return null; } $newExpressions[] = $stmt; } return $newExpressions; } - private function matchSingleExceptionVariable(\PhpParser\Node\Stmt\TryCatch $tryCatch) : ?\PhpParser\Node\Expr\Variable + private function matchSingleExceptionVariable(TryCatch $tryCatch) : ?Variable { if (\count($tryCatch->catches) !== 1) { return null; @@ -159,7 +159,7 @@ CODE_SAMPLE { $expressions = []; foreach ($methodCalls as $methodCall) { - $expressions[] = new \PhpParser\Node\Stmt\Expression($methodCall); + $expressions[] = new Expression($methodCall); } return $expressions; } diff --git a/vendor/rector/rector-phpunit/src/Rector/Class_/AddProphecyTraitRector.php b/vendor/rector/rector-phpunit/src/Rector/Class_/AddProphecyTraitRector.php index 4b73c1aa32e..6c50d8b1190 100644 --- a/vendor/rector/rector-phpunit/src/Rector/Class_/AddProphecyTraitRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/Class_/AddProphecyTraitRector.php @@ -9,8 +9,8 @@ use Rector\Core\NodeManipulator\ClassInsertManipulator; use Rector\Core\NodeManipulator\ClassManipulator; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/sebastianbergmann/phpunit/issues/4142 * @see https://github.com/sebastianbergmann/phpunit/issues/4141 @@ -18,7 +18,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @see \Rector\PHPUnit\Tests\Rector\Class_\AddProphecyTraitRector\AddProphecyTraitRectorTest */ -final class AddProphecyTraitRector extends \Rector\Core\Rector\AbstractRector +final class AddProphecyTraitRector extends AbstractRector { /** * @var string @@ -39,15 +39,15 @@ final class AddProphecyTraitRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\Core\NodeManipulator\ClassInsertManipulator $classInsertManipulator, \Rector\Core\NodeManipulator\ClassManipulator $classManipulator, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(ClassInsertManipulator $classInsertManipulator, ClassManipulator $classManipulator, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->classInsertManipulator = $classInsertManipulator; $this->classManipulator = $classManipulator; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add Prophecy trait for method using $this->prophesize()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add Prophecy trait for method using $this->prophesize()', [new CodeSample(<<<'CODE_SAMPLE' use PHPUnit\Framework\TestCase; final class ExampleTest extends TestCase @@ -79,12 +79,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkipClass($node)) { return null; @@ -92,9 +92,9 @@ CODE_SAMPLE $this->classInsertManipulator->addAsFirstTrait($node, self::PROPHECY_TRAIT); return $node; } - private function shouldSkipClass(\PhpParser\Node\Stmt\Class_ $class) : bool + private function shouldSkipClass(Class_ $class) : bool { - $hasProphesizeMethodCall = (bool) $this->betterNodeFinder->findFirst($class, function (\PhpParser\Node $node) : bool { + $hasProphesizeMethodCall = (bool) $this->betterNodeFinder->findFirst($class, function (Node $node) : bool { return $this->testsNodeAnalyzer->isAssertMethodCallName($node, 'prophesize'); }); if (!$hasProphesizeMethodCall) { diff --git a/vendor/rector/rector-phpunit/src/Rector/Class_/AddSeeTestAnnotationRector.php b/vendor/rector/rector-phpunit/src/Rector/Class_/AddSeeTestAnnotationRector.php index 81acc7f4ce6..ac1e938803c 100644 --- a/vendor/rector/rector-phpunit/src/Rector/Class_/AddSeeTestAnnotationRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/Class_/AddSeeTestAnnotationRector.php @@ -12,12 +12,12 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\Naming\TestClassNameResolverInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\Rector\Class_\AddSeeTestAnnotationRector\AddSeeTestAnnotationRectorTest */ -final class AddSeeTestAnnotationRector extends \Rector\Core\Rector\AbstractRector +final class AddSeeTestAnnotationRector extends AbstractRector { /** * @var string @@ -38,15 +38,15 @@ final class AddSeeTestAnnotationRector extends \Rector\Core\Rector\AbstractRecto * @var \Rector\PHPUnit\Naming\TestClassNameResolverInterface */ private $testClassNameResolver; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover $phpDocTagRemover, \Rector\PHPUnit\Naming\TestClassNameResolverInterface $testClassNameResolver) + public function __construct(ReflectionProvider $reflectionProvider, PhpDocTagRemover $phpDocTagRemover, TestClassNameResolverInterface $testClassNameResolver) { $this->reflectionProvider = $reflectionProvider; $this->phpDocTagRemover = $phpDocTagRemover; $this->testClassNameResolver = $testClassNameResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add @see annotation test of the class for faster jump to test. Make it FQN, so it stays in the annotation, not in the PHP source code.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add @see annotation test of the class for faster jump to test. Make it FQN, so it stays in the annotation, not in the PHP source code.', [new CodeSample(<<<'CODE_SAMPLE' class SomeService { } @@ -78,12 +78,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $className = $this->getName($node); if ($className === null) { @@ -106,7 +106,7 @@ CODE_SAMPLE $phpDocInfo->addPhpDocTagNode($phpDocTagNode); return $node; } - private function shouldSkipClass(\PhpParser\Node\Stmt\Class_ $class) : bool + private function shouldSkipClass(Class_ $class) : bool { // we are in the test case if ($this->isName($class, '*Test')) { @@ -117,7 +117,7 @@ CODE_SAMPLE $seePhpDocTagNodes = $phpDocInfo->getTagsByName(self::SEE); // is the @see annotation already added foreach ($seePhpDocTagNodes as $seePhpDocTagNode) { - if (!$seePhpDocTagNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) { + if (!$seePhpDocTagNode->value instanceof GenericTagValueNode) { continue; } /** @var GenericTagValueNode $genericTagValueNode */ @@ -129,16 +129,16 @@ CODE_SAMPLE } return \false; } - private function createSeePhpDocTagNode(string $className) : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode + private function createSeePhpDocTagNode(string $className) : PhpDocTagNode { - return new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode('@see', new \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode('\\' . $className)); + return new PhpDocTagNode('@see', new GenericTagValueNode('\\' . $className)); } - private function hasAlreadySeeAnnotation(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, string $testCaseClassName) : bool + private function hasAlreadySeeAnnotation(PhpDocInfo $phpDocInfo, string $testCaseClassName) : bool { /** @var PhpDocTagNode[] $seePhpDocTagNodes */ $seePhpDocTagNodes = $phpDocInfo->getTagsByName(self::SEE); foreach ($seePhpDocTagNodes as $seePhpDocTagNode) { - if (!$seePhpDocTagNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) { + if (!$seePhpDocTagNode->value instanceof GenericTagValueNode) { continue; } $possibleClassName = $seePhpDocTagNode->value->value; @@ -149,12 +149,12 @@ CODE_SAMPLE } return \false; } - private function removeNonExistingClassSeeAnnotation(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void + private function removeNonExistingClassSeeAnnotation(PhpDocInfo $phpDocInfo) : void { /** @var PhpDocTagNode[] $seePhpDocTagNodes */ $seePhpDocTagNodes = $phpDocInfo->getTagsByName(self::SEE); foreach ($seePhpDocTagNodes as $seePhpDocTagNode) { - if (!$seePhpDocTagNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) { + if (!$seePhpDocTagNode->value instanceof GenericTagValueNode) { continue; } $possibleClassName = $seePhpDocTagNode->value->value; diff --git a/vendor/rector/rector-phpunit/src/Rector/Class_/ArrayArgumentToDataProviderRector.php b/vendor/rector/rector-phpunit/src/Rector/Class_/ArrayArgumentToDataProviderRector.php index e1ad3841499..13a79736d3c 100644 --- a/vendor/rector/rector-phpunit/src/Rector/Class_/ArrayArgumentToDataProviderRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/Class_/ArrayArgumentToDataProviderRector.php @@ -17,7 +17,7 @@ use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use PHPStan\Type\Type; use PHPStan\Type\UnionType; -use RectorPrefix20220607\PHPUnit\Framework\TestCase; +use PHPUnit\Framework\TestCase; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Rector\AbstractRector; @@ -28,15 +28,15 @@ use Rector\PHPUnit\NodeManipulator\ParamAndArgFromArrayResolver; use Rector\PHPUnit\ValueObject\ArrayArgumentToDataProvider; use Rector\PHPUnit\ValueObject\DataProviderClassMethodRecipe; use Rector\PHPUnit\ValueObject\ParamAndArg; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\PHPUnit\Tests\Rector\Class_\ArrayArgumentToDataProviderRector\ArrayArgumentToDataProviderRectorTest * * @see why → https://blog.martinhujer.cz/how-to-use-data-providers-in-phpunit/ */ -final class ArrayArgumentToDataProviderRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class ArrayArgumentToDataProviderRector extends AbstractRector implements ConfigurableRectorInterface { /** * @api @@ -66,15 +66,15 @@ final class ArrayArgumentToDataProviderRector extends \Rector\Core\Rector\Abstra * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeFactory\DataProviderClassMethodFactory $dataProviderClassMethodFactory, \Rector\PHPUnit\NodeManipulator\ParamAndArgFromArrayResolver $paramAndArgFromArrayResolver, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(DataProviderClassMethodFactory $dataProviderClassMethodFactory, ParamAndArgFromArrayResolver $paramAndArgFromArrayResolver, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->dataProviderClassMethodFactory = $dataProviderClassMethodFactory; $this->paramAndArgFromArrayResolver = $paramAndArgFromArrayResolver; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Move array argument from tests into data provider [configurable]', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Move array argument from tests into data provider [configurable]', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' use PHPUnit\Framework\TestCase; class SomeServiceTest extends TestCase @@ -106,26 +106,26 @@ class SomeServiceTest extends TestCase } } CODE_SAMPLE -, [self::ARRAY_ARGUMENTS_TO_DATA_PROVIDERS => [new \Rector\PHPUnit\ValueObject\ArrayArgumentToDataProvider(\RectorPrefix20220607\PHPUnit\Framework\TestCase::class, 'doTestMultiple', 'doTestSingle', 'number')]])]); +, [self::ARRAY_ARGUMENTS_TO_DATA_PROVIDERS => [new ArrayArgumentToDataProvider(TestCase::class, 'doTestMultiple', 'doTestSingle', 'number')]])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isInTestClass($node)) { return null; } $this->dataProviderClassMethodRecipes = []; - $this->traverseNodesWithCallable($node->stmts, function (\PhpParser\Node $node) { - if (!$node instanceof \PhpParser\Node\Expr\MethodCall) { + $this->traverseNodesWithCallable($node->stmts, function (Node $node) { + if (!$node instanceof MethodCall) { return null; } foreach ($this->arrayArgumentsToDataProviders as $arrayArgumentToDataProvider) { @@ -146,38 +146,38 @@ CODE_SAMPLE public function configure(array $configuration) : void { $arrayArgumentsToDataProviders = $configuration[self::ARRAY_ARGUMENTS_TO_DATA_PROVIDERS] ?? $configuration; - \RectorPrefix20220607\Webmozart\Assert\Assert::isArray($arrayArgumentsToDataProviders); - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($arrayArgumentsToDataProviders, \Rector\PHPUnit\ValueObject\ArrayArgumentToDataProvider::class); + Assert::isArray($arrayArgumentsToDataProviders); + Assert::allIsAOf($arrayArgumentsToDataProviders, ArrayArgumentToDataProvider::class); $this->arrayArgumentsToDataProviders = $arrayArgumentsToDataProviders; } - private function refactorMethodCallWithConfiguration(\PhpParser\Node\Expr\MethodCall $methodCall, \Rector\PHPUnit\ValueObject\ArrayArgumentToDataProvider $arrayArgumentToDataProvider) : void + private function refactorMethodCallWithConfiguration(MethodCall $methodCall, ArrayArgumentToDataProvider $arrayArgumentToDataProvider) : void { if (!$this->isMethodCallMatch($methodCall, $arrayArgumentToDataProvider)) { return; } if (\count($methodCall->args) !== 1) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } // resolve value types $firstArgumentValue = $methodCall->args[0]->value; - if (!$firstArgumentValue instanceof \PhpParser\Node\Expr\Array_) { + if (!$firstArgumentValue instanceof Array_) { // nothing we can do return; } // rename method to new one handling non-array input - $methodCall->name = new \PhpParser\Node\Identifier($arrayArgumentToDataProvider->getNewMethod()); + $methodCall->name = new Identifier($arrayArgumentToDataProvider->getNewMethod()); $dataProviderMethodName = $this->createDataProviderMethodName($methodCall); if ($dataProviderMethodName === null) { return; } - $this->dataProviderClassMethodRecipes[] = new \Rector\PHPUnit\ValueObject\DataProviderClassMethodRecipe($dataProviderMethodName, $methodCall->args); + $this->dataProviderClassMethodRecipes[] = new DataProviderClassMethodRecipe($dataProviderMethodName, $methodCall->args); $methodCall->args = []; $paramAndArgs = $this->paramAndArgFromArrayResolver->resolve($firstArgumentValue, $arrayArgumentToDataProvider->getVariableName()); foreach ($paramAndArgs as $paramAndArg) { - $methodCall->args[] = new \PhpParser\Node\Arg($paramAndArg->getVariable()); + $methodCall->args[] = new Arg($paramAndArg->getVariable()); } - $classMethod = $this->betterNodeFinder->findParentType($methodCall, \PhpParser\Node\Stmt\ClassMethod::class); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $this->betterNodeFinder->findParentType($methodCall, ClassMethod::class); + if (!$classMethod instanceof ClassMethod) { return; } $this->refactorTestClassMethodParams($classMethod, $paramAndArgs); @@ -198,17 +198,17 @@ CODE_SAMPLE } return $dataProviderClassMethods; } - private function isMethodCallMatch(\PhpParser\Node\Expr\MethodCall $methodCall, \Rector\PHPUnit\ValueObject\ArrayArgumentToDataProvider $arrayArgumentToDataProvider) : bool + private function isMethodCallMatch(MethodCall $methodCall, ArrayArgumentToDataProvider $arrayArgumentToDataProvider) : bool { if (!$this->isObjectType($methodCall->var, $arrayArgumentToDataProvider->getObjectType())) { return \false; } return $this->isName($methodCall->name, $arrayArgumentToDataProvider->getOldMethod()); } - private function createDataProviderMethodName(\PhpParser\Node\Expr\MethodCall $methodCall) : ?string + private function createDataProviderMethodName(MethodCall $methodCall) : ?string { - $methodNode = $this->betterNodeFinder->findParentType($methodCall, \PhpParser\Node\Stmt\ClassMethod::class); - if (!$methodNode instanceof \PhpParser\Node\Stmt\ClassMethod) { + $methodNode = $this->betterNodeFinder->findParentType($methodCall, ClassMethod::class); + if (!$methodNode instanceof ClassMethod) { return null; } $classMethodName = $this->getName($methodNode); @@ -217,26 +217,26 @@ CODE_SAMPLE /** * @param ParamAndArg[] $paramAndArgs */ - private function refactorTestClassMethodParams(\PhpParser\Node\Stmt\ClassMethod $classMethod, array $paramAndArgs) : void + private function refactorTestClassMethodParams(ClassMethod $classMethod, array $paramAndArgs) : void { $classMethod->params = $this->createParams($paramAndArgs); $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); foreach ($paramAndArgs as $paramAndArg) { $staticType = $paramAndArg->getType(); - if (!$staticType instanceof \PHPStan\Type\UnionType) { + if (!$staticType instanceof UnionType) { continue; } /** @var string $paramName */ $paramName = $this->getName($paramAndArg->getVariable()); /** @var TypeNode $staticTypeNode */ - $staticTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($staticType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM); + $staticTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($staticType, TypeKind::PARAM); $paramTagValueNode = $this->createParamTagNode($paramName, $staticTypeNode); $phpDocInfo->addTagValueNode($paramTagValueNode); } } - private function createDataProviderTagNode(string $dataProviderMethodName) : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode + private function createDataProviderTagNode(string $dataProviderMethodName) : PhpDocTagNode { - return new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode('@dataProvider', new \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode($dataProviderMethodName . '()')); + return new PhpDocTagNode('@dataProvider', new GenericTagValueNode($dataProviderMethodName . '()')); } /** * @param ParamAndArg[] $paramAndArgs @@ -246,26 +246,26 @@ CODE_SAMPLE { $params = []; foreach ($paramAndArgs as $paramAndArg) { - $param = new \PhpParser\Node\Param($paramAndArg->getVariable()); + $param = new Param($paramAndArg->getVariable()); $this->setTypeIfNotNull($paramAndArg, $param); $params[] = $param; } return $params; } - private function createParamTagNode(string $name, \PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode) : \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode + private function createParamTagNode(string $name, TypeNode $typeNode) : ParamTagValueNode { - return new \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode($typeNode, \false, '$' . $name, ''); + return new ParamTagValueNode($typeNode, \false, '$' . $name, ''); } - private function setTypeIfNotNull(\Rector\PHPUnit\ValueObject\ParamAndArg $paramAndArg, \PhpParser\Node\Param $param) : void + private function setTypeIfNotNull(ParamAndArg $paramAndArg, Param $param) : void { $staticType = $paramAndArg->getType(); - if (!$staticType instanceof \PHPStan\Type\Type) { + if (!$staticType instanceof Type) { return; } - if ($staticType instanceof \PHPStan\Type\UnionType) { + if ($staticType instanceof UnionType) { return; } - $phpNodeType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($staticType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM); + $phpNodeType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($staticType, TypeKind::PARAM); if ($phpNodeType === null) { return; } diff --git a/vendor/rector/rector-phpunit/src/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector.php b/vendor/rector/rector-phpunit/src/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector.php index 1ed72c4b4b9..cd26d18cefc 100644 --- a/vendor/rector/rector-phpunit/src/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector.php @@ -14,14 +14,14 @@ use Rector\Core\ValueObject\MethodName; use Rector\Nette\NodeAnalyzer\StaticCallAnalyzer; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\PHPUnit\NodeManipulator\SetUpClassMethodNodeManipulator; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/sebastianbergmann/phpunit/issues/3975#issuecomment-562584609 * * @see \Rector\PHPUnit\Tests\Rector\Class_\ConstructClassMethodToSetUpTestCaseRector\ConstructClassMethodToSetUpTestCaseRectorTest */ -final class ConstructClassMethodToSetUpTestCaseRector extends \Rector\Core\Rector\AbstractRector +final class ConstructClassMethodToSetUpTestCaseRector extends AbstractRector { /** * @readonly @@ -43,16 +43,16 @@ final class ConstructClassMethodToSetUpTestCaseRector extends \Rector\Core\Recto * @var \Rector\Core\NodeAnalyzer\ClassAnalyzer */ private $classAnalyzer; - public function __construct(\Rector\PHPUnit\NodeManipulator\SetUpClassMethodNodeManipulator $setUpClassMethodNodeManipulator, \Rector\Nette\NodeAnalyzer\StaticCallAnalyzer $staticCallAnalyzer, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer, \Rector\Core\NodeAnalyzer\ClassAnalyzer $classAnalyzer) + public function __construct(SetUpClassMethodNodeManipulator $setUpClassMethodNodeManipulator, StaticCallAnalyzer $staticCallAnalyzer, TestsNodeAnalyzer $testsNodeAnalyzer, ClassAnalyzer $classAnalyzer) { $this->setUpClassMethodNodeManipulator = $setUpClassMethodNodeManipulator; $this->staticCallAnalyzer = $staticCallAnalyzer; $this->testsNodeAnalyzer = $testsNodeAnalyzer; $this->classAnalyzer = $classAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change __construct() method in tests of `PHPUnit\\Framework\\TestCase` to setUp(), to prevent dangerous override', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change __construct() method in tests of `PHPUnit\\Framework\\TestCase` to setUp(), to prevent dangerous override', [new CodeSample(<<<'CODE_SAMPLE' use PHPUnit\Framework\TestCase; final class SomeTest extends TestCase @@ -88,18 +88,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isInTestClass($node)) { return null; } - $constructClassMethod = $node->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$constructClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $constructClassMethod = $node->getMethod(MethodName::CONSTRUCT); + if (!$constructClassMethod instanceof ClassMethod) { return null; } if ($this->classAnalyzer->isAnonymousClass($node)) { @@ -113,15 +113,15 @@ CODE_SAMPLE /** * @return Stmt[] */ - private function resolveStmtsToAddToSetUp(\PhpParser\Node\Stmt\ClassMethod $constructClassMethod) : array + private function resolveStmtsToAddToSetUp(ClassMethod $constructClassMethod) : array { $constructorStmts = (array) $constructClassMethod->stmts; // remove parent call foreach ($constructorStmts as $key => $constructorStmt) { - if ($constructorStmt instanceof \PhpParser\Node\Stmt\Expression) { + if ($constructorStmt instanceof Expression) { $constructorStmt = clone $constructorStmt->expr; } - if (!$this->staticCallAnalyzer->isParentCallNamed($constructorStmt, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if (!$this->staticCallAnalyzer->isParentCallNamed($constructorStmt, MethodName::CONSTRUCT)) { continue; } unset($constructorStmts[$key]); diff --git a/vendor/rector/rector-phpunit/src/Rector/Class_/RemoveDataProviderTestPrefixRector.php b/vendor/rector/rector-phpunit/src/Rector/Class_/RemoveDataProviderTestPrefixRector.php index f4180bf731f..45b6dc05cfc 100644 --- a/vendor/rector/rector-phpunit/src/Rector/Class_/RemoveDataProviderTestPrefixRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/Class_/RemoveDataProviderTestPrefixRector.php @@ -11,27 +11,27 @@ use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode; use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://stackoverflow.com/a/46693675/1348344 * * @see \Rector\PHPUnit\Tests\Rector\Class_\RemoveDataProviderTestPrefixRector\RemoveDataProviderTestPrefixRectorTest */ -final class RemoveDataProviderTestPrefixRector extends \Rector\Core\Rector\AbstractRector +final class RemoveDataProviderTestPrefixRector extends AbstractRector { /** * @readonly * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer) { $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Data provider methods cannot start with "test" prefix', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Data provider methods cannot start with "test" prefix', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass extends PHPUnit\Framework\TestCase { /** @@ -72,12 +72,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isInTestClass($node)) { return null; @@ -92,7 +92,7 @@ CODE_SAMPLE /** * @return array */ - private function renameDataProviderAnnotationsAndCollectRenamedMethods(\PhpParser\Node\Stmt\Class_ $class) : array + private function renameDataProviderAnnotationsAndCollectRenamedMethods(Class_ $class) : array { $oldToNewMethodNames = []; foreach ($class->getMethods() as $classMethod) { @@ -102,7 +102,7 @@ CODE_SAMPLE continue; } foreach ($dataProviderTagValueNodes as $dataProviderTagValueNode) { - if (!$dataProviderTagValueNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) { + if (!$dataProviderTagValueNode->value instanceof GenericTagValueNode) { continue; } $oldMethodName = $dataProviderTagValueNode->value->value; @@ -110,9 +110,9 @@ CODE_SAMPLE continue; } $newMethodName = $this->createNewMethodName($oldMethodName); - $dataProviderTagValueNode->value->value = \RectorPrefix20220607\Nette\Utils\Strings::replace($oldMethodName, '#' . \preg_quote($oldMethodName, '#') . '#', $newMethodName); + $dataProviderTagValueNode->value->value = Strings::replace($oldMethodName, '#' . \preg_quote($oldMethodName, '#') . '#', $newMethodName); // invoke reprint - $dataProviderTagValueNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, null); + $dataProviderTagValueNode->setAttribute(PhpDocAttributeKey::START_AND_END, null); $phpDocInfo->markAsChanged(); $oldMethodNameWithoutBrackets = \rtrim($oldMethodName, '()'); $newMethodWithoutBrackets = $this->createNewMethodName($oldMethodNameWithoutBrackets); @@ -124,20 +124,20 @@ CODE_SAMPLE /** * @param array $oldToNewMethodsNames */ - private function renameProviderMethods(\PhpParser\Node\Stmt\Class_ $class, array $oldToNewMethodsNames) : void + private function renameProviderMethods(Class_ $class, array $oldToNewMethodsNames) : void { foreach ($class->getMethods() as $classMethod) { foreach ($oldToNewMethodsNames as $oldName => $newName) { if (!$this->isName($classMethod, $oldName)) { continue; } - $classMethod->name = new \PhpParser\Node\Identifier($newName); + $classMethod->name = new Identifier($newName); } } } private function createNewMethodName(string $oldMethodName) : string { - $newMethodName = \RectorPrefix20220607\Nette\Utils\Strings::substring($oldMethodName, \strlen('test')); + $newMethodName = Strings::substring($oldMethodName, \strlen('test')); return \lcfirst($newMethodName); } } diff --git a/vendor/rector/rector-phpunit/src/Rector/Class_/TestListenerToHooksRector.php b/vendor/rector/rector-phpunit/src/Rector/Class_/TestListenerToHooksRector.php index d3c4f2d48c6..1b6b657c603 100644 --- a/vendor/rector/rector-phpunit/src/Rector/Class_/TestListenerToHooksRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/Class_/TestListenerToHooksRector.php @@ -10,8 +10,8 @@ use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassMethod; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/sebastianbergmann/phpunit/issues/3388 * @see https://github.com/sebastianbergmann/phpunit/commit/34a0abd8b56a4a9de83c9e56384f462541a0f939 @@ -19,7 +19,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * @see https://github.com/sebastianbergmann/phpunit/tree/master/src/Runner/Hook * @see \Rector\PHPUnit\Tests\Rector\Class_\TestListenerToHooksRector\TestListenerToHooksRectorTest */ -final class TestListenerToHooksRector extends \Rector\Core\Rector\AbstractRector +final class TestListenerToHooksRector extends AbstractRector { /** * @var array> @@ -38,9 +38,9 @@ final class TestListenerToHooksRector extends \Rector\Core\Rector\AbstractRector 'startTestSuite' => ['PHPUnit\\Runner\\BeforeFirstTestHook', 'executeBeforeFirstTest'], 'endTestSuite' => ['PHPUnit\\Runner\\AfterLastTestHook', 'executeAfterLastTest'], ]; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Refactor "*TestListener.php" to particular "*Hook.php" files', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Refactor "*TestListener.php" to particular "*Hook.php" files', [new CodeSample(<<<'CODE_SAMPLE' namespace App\Tests; use PHPUnit\Framework\TestListener; @@ -115,16 +115,16 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * Process Node of matched type * * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node, new \PHPStan\Type\ObjectType('PHPUnit\\Framework\\TestListener'))) { + if (!$this->isObjectType($node, new ObjectType('PHPUnit\\Framework\\TestListener'))) { return null; } foreach ($node->implements as $implement) { @@ -137,7 +137,7 @@ CODE_SAMPLE } return $node; } - private function processClassMethod(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function processClassMethod(Class_ $class, ClassMethod $classMethod) : void { foreach (self::LISTENER_METHOD_TO_HOOK_INTERFACES as $methodName => $hookClassAndMethod) { /** @var string $methodName */ @@ -148,8 +148,8 @@ CODE_SAMPLE if ($classMethod->stmts === [] || $classMethod->stmts === null) { $this->removeNode($classMethod); } else { - $class->implements[] = new \PhpParser\Node\Name\FullyQualified($hookClassAndMethod[0]); - $classMethod->name = new \PhpParser\Node\Identifier($hookClassAndMethod[1]); + $class->implements[] = new FullyQualified($hookClassAndMethod[0]); + $classMethod->name = new Identifier($hookClassAndMethod[1]); } } } diff --git a/vendor/rector/rector-phpunit/src/Rector/Foreach_/SimplifyForeachInstanceOfRector.php b/vendor/rector/rector-phpunit/src/Rector/Foreach_/SimplifyForeachInstanceOfRector.php index 9c6ecac432b..3eec36fa029 100644 --- a/vendor/rector/rector-phpunit/src/Rector/Foreach_/SimplifyForeachInstanceOfRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/Foreach_/SimplifyForeachInstanceOfRector.php @@ -10,25 +10,25 @@ use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Stmt\Foreach_; use Rector\Core\NodeManipulator\ForeachManipulator; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\Rector\Foreach_\SimplifyForeachInstanceOfRector\SimplifyForeachInstanceOfRectorTest */ -final class SimplifyForeachInstanceOfRector extends \Rector\Core\Rector\AbstractRector +final class SimplifyForeachInstanceOfRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeManipulator\ForeachManipulator */ private $foreachManipulator; - public function __construct(\Rector\Core\NodeManipulator\ForeachManipulator $foreachManipulator) + public function __construct(ForeachManipulator $foreachManipulator) { $this->foreachManipulator = $foreachManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Simplify unnecessary foreach check of instances', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Simplify unnecessary foreach check of instances', [new CodeSample(<<<'CODE_SAMPLE' foreach ($foos as $foo) { $this->assertInstanceOf(SplFileInfo::class, $foo); } @@ -40,16 +40,16 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Foreach_::class]; + return [Foreach_::class]; } /** * @param Foreach_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { /** @var MethodCall|StaticCall|null $matchedNode */ - $matchedNode = $this->foreachManipulator->matchOnlyStmt($node, function (\PhpParser\Node $node, \PhpParser\Node\Stmt\Foreach_ $foreach) : ?Node { - if (!$node instanceof \PhpParser\Node\Expr\MethodCall && !$node instanceof \PhpParser\Node\Expr\StaticCall) { + $matchedNode = $this->foreachManipulator->matchOnlyStmt($node, function (Node $node, Foreach_ $foreach) : ?Node { + if (!$node instanceof MethodCall && !$node instanceof StaticCall) { return null; } if (!$this->isName($node->name, 'assertInstanceOf')) { @@ -63,10 +63,10 @@ CODE_SAMPLE if ($matchedNode === null) { return null; } - $args = [$matchedNode->args[0], new \PhpParser\Node\Arg($node->expr)]; - if ($matchedNode instanceof \PhpParser\Node\Expr\StaticCall) { - return new \PhpParser\Node\Expr\StaticCall($matchedNode->class, 'assertContainsOnlyInstancesOf', $args); + $args = [$matchedNode->args[0], new Arg($node->expr)]; + if ($matchedNode instanceof StaticCall) { + return new StaticCall($matchedNode->class, 'assertContainsOnlyInstancesOf', $args); } - return new \PhpParser\Node\Expr\MethodCall($matchedNode->var, 'assertContainsOnlyInstancesOf', $args); + return new MethodCall($matchedNode->var, 'assertContainsOnlyInstancesOf', $args); } } diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertCompareToSpecificMethodRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertCompareToSpecificMethodRector.php index 34b3581c170..053b788c86f 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertCompareToSpecificMethodRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertCompareToSpecificMethodRector.php @@ -12,12 +12,12 @@ use PhpParser\Node\Identifier; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\Rector\MethodCall\AssertCompareToSpecificMethodRector\AssertCompareToSpecificMethodRectorTest */ -final class AssertCompareToSpecificMethodRector extends \Rector\Core\Rector\AbstractRector +final class AssertCompareToSpecificMethodRector extends AbstractRector { /** * @var string @@ -36,26 +36,26 @@ final class AssertCompareToSpecificMethodRector extends \Rector\Core\Rector\Abst * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer) { $this->testsNodeAnalyzer = $testsNodeAnalyzer; - $this->functionNamesWithAssertMethods = [new \Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods('count', self::ASSERT_COUNT, self::ASSERT_NOT_COUNT), new \Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods('sizeof', self::ASSERT_COUNT, self::ASSERT_NOT_COUNT), new \Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods('iterator_count', self::ASSERT_COUNT, self::ASSERT_NOT_COUNT), new \Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods('gettype', 'assertInternalType', 'assertNotInternalType'), new \Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods('get_class', 'assertInstanceOf', 'assertNotInstanceOf')]; + $this->functionNamesWithAssertMethods = [new FunctionNameWithAssertMethods('count', self::ASSERT_COUNT, self::ASSERT_NOT_COUNT), new FunctionNameWithAssertMethods('sizeof', self::ASSERT_COUNT, self::ASSERT_NOT_COUNT), new FunctionNameWithAssertMethods('iterator_count', self::ASSERT_COUNT, self::ASSERT_NOT_COUNT), new FunctionNameWithAssertMethods('gettype', 'assertInternalType', 'assertNotInternalType'), new FunctionNameWithAssertMethods('get_class', 'assertInstanceOf', 'assertNotInstanceOf')]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns vague php-only method in PHPUnit TestCase to more specific', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertSame(10, count($anything), "message");', '$this->assertCount(10, $anything, "message");'), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertNotEquals(get_class($value), stdClass::class);', '$this->assertNotInstanceOf(stdClass::class, $value);')]); + return new RuleDefinition('Turns vague php-only method in PHPUnit TestCase to more specific', [new CodeSample('$this->assertSame(10, count($anything), "message");', '$this->assertCount(10, $anything, "message");'), new CodeSample('$this->assertNotEquals(get_class($value), stdClass::class);', '$this->assertNotInstanceOf(stdClass::class, $value);')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, ['assertSame', 'assertNotSame', 'assertEquals', 'assertNotEquals'])) { return null; @@ -68,10 +68,10 @@ final class AssertCompareToSpecificMethodRector extends \Rector\Core\Rector\Abst $secondArgument = $node->args[1]; $firstArgumentValue = $firstArgument->value; $secondArgumentValue = $secondArgument->value; - if ($secondArgumentValue instanceof \PhpParser\Node\Expr\FuncCall) { + if ($secondArgumentValue instanceof FuncCall) { return $this->processFuncCallArgumentValue($node, $secondArgumentValue, $firstArgument); } - if ($firstArgumentValue instanceof \PhpParser\Node\Expr\FuncCall) { + if ($firstArgumentValue instanceof FuncCall) { return $this->processFuncCallArgumentValue($node, $firstArgumentValue, $secondArgument); } return null; @@ -80,7 +80,7 @@ final class AssertCompareToSpecificMethodRector extends \Rector\Core\Rector\Abst * @return MethodCall|StaticCall|null * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node */ - private function processFuncCallArgumentValue($node, \PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Arg $requiredArg) : ?\PhpParser\Node + private function processFuncCallArgumentValue($node, FuncCall $funcCall, Arg $requiredArg) : ?Node { foreach ($this->functionNamesWithAssertMethods as $functionNameWithAssertMethod) { if (!$this->isName($funcCall, $functionNameWithAssertMethod->getFunctionName())) { @@ -95,19 +95,19 @@ final class AssertCompareToSpecificMethodRector extends \Rector\Core\Rector\Abst /** * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node */ - private function renameMethod($node, \Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods $functionNameWithAssertMethods) : void + private function renameMethod($node, FunctionNameWithAssertMethods $functionNameWithAssertMethods) : void { if ($this->isNames($node->name, ['assertSame', 'assertEquals'])) { - $node->name = new \PhpParser\Node\Identifier($functionNameWithAssertMethods->getAssetMethodName()); + $node->name = new Identifier($functionNameWithAssertMethods->getAssetMethodName()); } elseif ($this->isNames($node->name, ['assertNotSame', 'assertNotEquals'])) { - $node->name = new \PhpParser\Node\Identifier($functionNameWithAssertMethods->getNotAssertMethodName()); + $node->name = new Identifier($functionNameWithAssertMethods->getNotAssertMethodName()); } } /** * Handles custom error messages to not be overwrite by function with multiple args. * @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $node */ - private function moveFunctionArgumentsUp($node, \PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Arg $requiredArg) : void + private function moveFunctionArgumentsUp($node, FuncCall $funcCall, Arg $requiredArg) : void { $node->args[1] = $funcCall->args[0]; $node->args[0] = $requiredArg; diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertComparisonToSpecificMethodRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertComparisonToSpecificMethodRector.php index 6105609841b..115b9a5473c 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertComparisonToSpecificMethodRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertComparisonToSpecificMethodRector.php @@ -23,12 +23,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\PHPUnit\ValueObject\BinaryOpWithAssertMethod; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\Rector\MethodCall\AssertComparisonToSpecificMethodRector\AssertComparisonToSpecificMethodRectorTest */ -final class AssertComparisonToSpecificMethodRector extends \Rector\Core\Rector\AbstractRector +final class AssertComparisonToSpecificMethodRector extends AbstractRector { /** * @var BinaryOpWithAssertMethod[] @@ -44,33 +44,33 @@ final class AssertComparisonToSpecificMethodRector extends \Rector\Core\Rector\A * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator $identifierManipulator, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(IdentifierManipulator $identifierManipulator, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->identifierManipulator = $identifierManipulator; $this->testsNodeAnalyzer = $testsNodeAnalyzer; - $this->binaryOpWithAssertMethods = [new \Rector\PHPUnit\ValueObject\BinaryOpWithAssertMethod(\PhpParser\Node\Expr\BinaryOp\Identical::class, 'assertSame', 'assertNotSame'), new \Rector\PHPUnit\ValueObject\BinaryOpWithAssertMethod(\PhpParser\Node\Expr\BinaryOp\NotIdentical::class, 'assertNotSame', 'assertSame'), new \Rector\PHPUnit\ValueObject\BinaryOpWithAssertMethod(\PhpParser\Node\Expr\BinaryOp\Equal::class, 'assertEquals', 'assertNotEquals'), new \Rector\PHPUnit\ValueObject\BinaryOpWithAssertMethod(\PhpParser\Node\Expr\BinaryOp\NotEqual::class, 'assertNotEquals', 'assertEquals'), new \Rector\PHPUnit\ValueObject\BinaryOpWithAssertMethod(\PhpParser\Node\Expr\BinaryOp\Greater::class, 'assertGreaterThan', 'assertLessThan'), new \Rector\PHPUnit\ValueObject\BinaryOpWithAssertMethod(\PhpParser\Node\Expr\BinaryOp\Smaller::class, 'assertLessThan', 'assertGreaterThan'), new \Rector\PHPUnit\ValueObject\BinaryOpWithAssertMethod(\PhpParser\Node\Expr\BinaryOp\GreaterOrEqual::class, 'assertGreaterThanOrEqual', 'assertLessThanOrEqual'), new \Rector\PHPUnit\ValueObject\BinaryOpWithAssertMethod(\PhpParser\Node\Expr\BinaryOp\SmallerOrEqual::class, 'assertLessThanOrEqual', 'assertGreaterThanOrEqual')]; + $this->binaryOpWithAssertMethods = [new BinaryOpWithAssertMethod(Identical::class, 'assertSame', 'assertNotSame'), new BinaryOpWithAssertMethod(NotIdentical::class, 'assertNotSame', 'assertSame'), new BinaryOpWithAssertMethod(Equal::class, 'assertEquals', 'assertNotEquals'), new BinaryOpWithAssertMethod(NotEqual::class, 'assertNotEquals', 'assertEquals'), new BinaryOpWithAssertMethod(Greater::class, 'assertGreaterThan', 'assertLessThan'), new BinaryOpWithAssertMethod(Smaller::class, 'assertLessThan', 'assertGreaterThan'), new BinaryOpWithAssertMethod(GreaterOrEqual::class, 'assertGreaterThanOrEqual', 'assertLessThanOrEqual'), new BinaryOpWithAssertMethod(SmallerOrEqual::class, 'assertLessThanOrEqual', 'assertGreaterThanOrEqual')]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns comparison operations to their method name alternatives in PHPUnit TestCase', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertTrue($foo === $bar, "message");', '$this->assertSame($bar, $foo, "message");'), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertFalse($foo >= $bar, "message");', '$this->assertLessThanOrEqual($bar, $foo, "message");')]); + return new RuleDefinition('Turns comparison operations to their method name alternatives in PHPUnit TestCase', [new CodeSample('$this->assertTrue($foo === $bar, "message");', '$this->assertSame($bar, $foo, "message");'), new CodeSample('$this->assertFalse($foo >= $bar, "message");', '$this->assertLessThanOrEqual($bar, $foo, "message");')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, ['assertTrue', 'assertFalse'])) { return null; } $firstArgumentValue = $node->args[0]->value; - if (!$firstArgumentValue instanceof \PhpParser\Node\Expr\BinaryOp) { + if (!$firstArgumentValue instanceof BinaryOp) { return null; } return $this->processCallWithBinaryOp($node, $firstArgumentValue); @@ -78,7 +78,7 @@ final class AssertComparisonToSpecificMethodRector extends \Rector\Core\Rector\A /** * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node */ - private function processCallWithBinaryOp($node, \PhpParser\Node\Expr\BinaryOp $binaryOp) : ?\PhpParser\Node + private function processCallWithBinaryOp($node, BinaryOp $binaryOp) : ?Node { $binaryOpClass = \get_class($binaryOp); foreach ($this->binaryOpWithAssertMethods as $binaryOpWithAssertMethod) { @@ -100,22 +100,22 @@ final class AssertComparisonToSpecificMethodRector extends \Rector\Core\Rector\A /** @var BinaryOp $expression */ $expression = $oldArguments[0]->value; if ($this->isConstantValue($expression->left)) { - $firstArgument = new \PhpParser\Node\Arg($expression->left); - $secondArgument = new \PhpParser\Node\Arg($expression->right); + $firstArgument = new Arg($expression->left); + $secondArgument = new Arg($expression->right); } else { - $firstArgument = new \PhpParser\Node\Arg($expression->right); - $secondArgument = new \PhpParser\Node\Arg($expression->left); + $firstArgument = new Arg($expression->right); + $secondArgument = new Arg($expression->left); } unset($oldArguments[0]); $newArgs = [$firstArgument, $secondArgument]; $node->args = $this->appendArgs($newArgs, $oldArguments); } - private function isConstantValue(\PhpParser\Node\Expr $expr) : bool + private function isConstantValue(Expr $expr) : bool { $staticType = $this->nodeTypeResolver->getType($expr); - if ($staticType instanceof \PHPStan\Type\ConstantScalarType) { + if ($staticType instanceof ConstantScalarType) { return \true; } - return $staticType instanceof \PHPStan\Type\Constant\ConstantArrayType; + return $staticType instanceof ConstantArrayType; } } diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector.php index 81af3be6186..d2580120d5f 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector.php @@ -9,8 +9,8 @@ use PhpParser\Node\Expr\StaticCall; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\PHPUnit\NodeFactory\AssertCallFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/sebastianbergmann/phpunit/blob/master/ChangeLog-8.0.md * @see https://github.com/sebastianbergmann/phpunit/commit/90e9e0379584bdf34220322e202617cd56d8ba65 @@ -18,7 +18,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @see \Rector\PHPUnit\Tests\Rector\MethodCall\AssertEqualsParameterToSpecificMethodsTypeRector\AssertEqualsParameterToSpecificMethodsTypeRectorTest */ -final class AssertEqualsParameterToSpecificMethodsTypeRector extends \Rector\Core\Rector\AbstractRector +final class AssertEqualsParameterToSpecificMethodsTypeRector extends AbstractRector { /** * @readonly @@ -30,14 +30,14 @@ final class AssertEqualsParameterToSpecificMethodsTypeRector extends \Rector\Cor * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeFactory\AssertCallFactory $assertCallFactory, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(AssertCallFactory $assertCallFactory, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->assertCallFactory = $assertCallFactory; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change assertEquals()/assertNotEquals() method parameters to new specific alternatives', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change assertEquals()/assertNotEquals() method parameters to new specific alternatives', [new CodeSample(<<<'CODE_SAMPLE' final class SomeTest extends \PHPUnit\Framework\TestCase { public function test() @@ -76,12 +76,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, ['assertEquals', 'assertNotEquals'])) { return null; diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertEqualsToSameRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertEqualsToSameRector.php index 07b80faa629..5b29d4bb9ab 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertEqualsToSameRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertEqualsToSameRector.php @@ -13,12 +13,12 @@ use PHPStan\Type\Type; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\Rector\MethodCall\AssertEqualsToSameRector\AssertEqualsToSameRectorTest */ -final class AssertEqualsToSameRector extends \Rector\Core\Rector\AbstractRector +final class AssertEqualsToSameRector extends AbstractRector { /** * @var array @@ -31,7 +31,7 @@ final class AssertEqualsToSameRector extends \Rector\Core\Rector\AbstractRector * * @var array> */ - private const SCALAR_TYPES = [\PHPStan\Type\FloatType::class, \PHPStan\Type\IntegerType::class, \PHPStan\Type\StringType::class]; + private const SCALAR_TYPES = [FloatType::class, IntegerType::class, StringType::class]; /** * @readonly * @var \Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator @@ -42,26 +42,26 @@ final class AssertEqualsToSameRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator $identifierManipulator, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(IdentifierManipulator $identifierManipulator, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->identifierManipulator = $identifierManipulator; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns `assertEquals()` into stricter `assertSame()` for scalar values in PHPUnit TestCase', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertEquals(2, $result);', '$this->assertSame(2, $result);')]); + return new RuleDefinition('Turns `assertEquals()` into stricter `assertSame()` for scalar values in PHPUnit TestCase', [new CodeSample('$this->assertEquals(2, $result);', '$this->assertSame(2, $result);')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isInTestClass($node)) { return null; @@ -81,7 +81,7 @@ final class AssertEqualsToSameRector extends \Rector\Core\Rector\AbstractRector $hasChanged = $this->identifierManipulator->renameNodeWithMap($node, self::RENAME_METHODS_MAP); return $hasChanged ? $node : null; } - private function isScalarType(\PHPStan\Type\Type $valueNodeType) : bool + private function isScalarType(Type $valueNodeType) : bool { foreach (self::SCALAR_TYPES as $scalarType) { if (\is_a($valueNodeType, $scalarType, \true)) { diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertFalseStrposToContainsRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertFalseStrposToContainsRector.php index 7bb2d331a6e..d8c3a8f867a 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertFalseStrposToContainsRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertFalseStrposToContainsRector.php @@ -10,12 +10,12 @@ use PhpParser\Node\Expr\StaticCall; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\Rector\MethodCall\AssertFalseStrposToContainsRector\AssertFalseStrposToContainsRectorTest */ -final class AssertFalseStrposToContainsRector extends \Rector\Core\Rector\AbstractRector +final class AssertFalseStrposToContainsRector extends AbstractRector { /** * @var array @@ -31,36 +31,36 @@ final class AssertFalseStrposToContainsRector extends \Rector\Core\Rector\Abstra * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator $identifierManipulator, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(IdentifierManipulator $identifierManipulator, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->identifierManipulator = $identifierManipulator; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns `strpos`/`stripos` comparisons to their method name alternatives in PHPUnit TestCase', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertFalse(strpos($anything, "foo"), "message");', '$this->assertNotContains("foo", $anything, "message");')]); + return new RuleDefinition('Turns `strpos`/`stripos` comparisons to their method name alternatives in PHPUnit TestCase', [new CodeSample('$this->assertFalse(strpos($anything, "foo"), "message");', '$this->assertNotContains("foo", $anything, "message");')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $oldMethodName = \array_keys(self::RENAME_METHODS_MAP); if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, $oldMethodName)) { return null; } $firstArgumentValue = $node->args[0]->value; - if ($firstArgumentValue instanceof \PhpParser\Node\Expr\StaticCall) { + if ($firstArgumentValue instanceof StaticCall) { return null; } - if ($firstArgumentValue instanceof \PhpParser\Node\Expr\MethodCall) { + if ($firstArgumentValue instanceof MethodCall) { return null; } if (!$this->isNames($firstArgumentValue, ['strpos', 'stripos'])) { @@ -77,7 +77,7 @@ final class AssertFalseStrposToContainsRector extends \Rector\Core\Rector\Abstra { $oldArguments = $node->getArgs(); $strposFuncCallNode = $oldArguments[0]->value; - if (!$strposFuncCallNode instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$strposFuncCallNode instanceof FuncCall) { return null; } $firstArgument = $strposFuncCallNode->args[1]; diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertInstanceOfComparisonRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertInstanceOfComparisonRector.php index 687ac5c2220..0cf28463b11 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertInstanceOfComparisonRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertInstanceOfComparisonRector.php @@ -12,12 +12,12 @@ use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\Rector\MethodCall\AssertInstanceOfComparisonRector\AssertInstanceOfComparisonRectorTest */ -final class AssertInstanceOfComparisonRector extends \Rector\Core\Rector\AbstractRector +final class AssertInstanceOfComparisonRector extends AbstractRector { /** * @var array @@ -33,33 +33,33 @@ final class AssertInstanceOfComparisonRector extends \Rector\Core\Rector\Abstrac * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator $identifierManipulator, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(IdentifierManipulator $identifierManipulator, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->identifierManipulator = $identifierManipulator; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns instanceof comparisons to their method name alternatives in PHPUnit TestCase', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertTrue($foo instanceof Foo, "message");', '$this->assertInstanceOf("Foo", $foo, "message");'), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertFalse($foo instanceof Foo, "message");', '$this->assertNotInstanceOf("Foo", $foo, "message");')]); + return new RuleDefinition('Turns instanceof comparisons to their method name alternatives in PHPUnit TestCase', [new CodeSample('$this->assertTrue($foo instanceof Foo, "message");', '$this->assertInstanceOf("Foo", $foo, "message");'), new CodeSample('$this->assertFalse($foo instanceof Foo, "message");', '$this->assertNotInstanceOf("Foo", $foo, "message");')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $oldMethodNames = \array_keys(self::RENAME_METHODS_MAP); if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, $oldMethodNames)) { return null; } $firstArgumentValue = $node->args[0]->value; - if (!$firstArgumentValue instanceof \PhpParser\Node\Expr\Instanceof_) { + if (!$firstArgumentValue instanceof Instanceof_) { return null; } $this->identifierManipulator->renameNodeWithMap($node, self::RENAME_METHODS_MAP); @@ -78,8 +78,8 @@ final class AssertInstanceOfComparisonRector extends \Rector\Core\Rector\Abstrac unset($oldArguments[0]); $className = $this->getName($comparison->class); if ($className === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } - $node->args = \array_merge([new \PhpParser\Node\Arg($this->nodeFactory->createClassConstReference($className)), new \PhpParser\Node\Arg($argument)], $oldArguments); + $node->args = \array_merge([new Arg($this->nodeFactory->createClassConstReference($className)), new Arg($argument)], $oldArguments); } } diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertIssetToSpecificMethodRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertIssetToSpecificMethodRector.php index ef6edd20d22..892555424fb 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertIssetToSpecificMethodRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertIssetToSpecificMethodRector.php @@ -20,12 +20,12 @@ use Rector\Core\PhpParser\AstResolver; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\Rector\MethodCall\AssertIssetToSpecificMethodRector\AssertIssetToSpecificMethodRectorTest */ -final class AssertIssetToSpecificMethodRector extends \Rector\Core\Rector\AbstractRector +final class AssertIssetToSpecificMethodRector extends AbstractRector { /** * @var string @@ -55,64 +55,64 @@ final class AssertIssetToSpecificMethodRector extends \Rector\Core\Rector\Abstra * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator $identifierManipulator, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer, \Rector\Core\PhpParser\AstResolver $astResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(IdentifierManipulator $identifierManipulator, TestsNodeAnalyzer $testsNodeAnalyzer, AstResolver $astResolver, ReflectionProvider $reflectionProvider) { $this->identifierManipulator = $identifierManipulator; $this->testsNodeAnalyzer = $testsNodeAnalyzer; $this->astResolver = $astResolver; $this->reflectionProvider = $reflectionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns isset comparisons to their method name alternatives in PHPUnit TestCase', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertTrue(isset($anything->foo));', '$this->assertObjectHasAttribute("foo", $anything);'), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertFalse(isset($anything["foo"]), "message");', '$this->assertArrayNotHasKey("foo", $anything, "message");')]); + return new RuleDefinition('Turns isset comparisons to their method name alternatives in PHPUnit TestCase', [new CodeSample('$this->assertTrue(isset($anything->foo));', '$this->assertObjectHasAttribute("foo", $anything);'), new CodeSample('$this->assertFalse(isset($anything["foo"]), "message");', '$this->assertArrayNotHasKey("foo", $anything, "message");')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, [self::ASSERT_TRUE, self::ASSERT_FALSE])) { return null; } $firstArgumentValue = $node->args[0]->value; // is property access - if (!$firstArgumentValue instanceof \PhpParser\Node\Expr\Isset_) { + if (!$firstArgumentValue instanceof Isset_) { return null; } $variableNodeClass = \get_class($firstArgumentValue->vars[0]); - if (!\in_array($variableNodeClass, [\PhpParser\Node\Expr\ArrayDimFetch::class, \PhpParser\Node\Expr\PropertyFetch::class], \true)) { + if (!\in_array($variableNodeClass, [ArrayDimFetch::class, PropertyFetch::class], \true)) { return null; } /** @var Isset_ $issetNode */ $issetNode = $node->args[0]->value; $issetNodeArg = $issetNode->vars[0]; - if ($issetNodeArg instanceof \PhpParser\Node\Expr\PropertyFetch) { + if ($issetNodeArg instanceof PropertyFetch) { if ($this->hasMagicIsset($issetNodeArg->var)) { return null; } return $this->refactorPropertyFetchNode($node, $issetNodeArg); } - if ($issetNodeArg instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if ($issetNodeArg instanceof ArrayDimFetch) { return $this->refactorArrayDimFetchNode($node, $issetNodeArg); } return $node; } - private function hasMagicIsset(\PhpParser\Node $node) : bool + private function hasMagicIsset(Node $node) : bool { $resolved = $this->nodeTypeResolver->getType($node); - if (!$resolved instanceof \PHPStan\Type\TypeWithClassName) { + if (!$resolved instanceof TypeWithClassName) { // object not found, skip - return $resolved instanceof \PHPStan\Type\ObjectWithoutClassType; + return $resolved instanceof ObjectWithoutClassType; } $classReflection = $resolved->getClassReflection(); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } if ($classReflection->hasMethod('__isset')) { @@ -122,10 +122,10 @@ final class AssertIssetToSpecificMethodRector extends \Rector\Core\Rector\Abstra // extends class not found by PHPStan $className = $classReflection->getName(); $class = $this->astResolver->resolveClassFromName($className); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + if (!$class instanceof Class_) { return \false; } - if (!$class->extends instanceof \PhpParser\Node\Name\FullyQualified) { + if (!$class->extends instanceof FullyQualified) { return \false; } // if parent class not detected by PHPStan, assume it has __isset @@ -134,7 +134,7 @@ final class AssertIssetToSpecificMethodRector extends \Rector\Core\Rector\Abstra /** * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node */ - private function refactorPropertyFetchNode($node, \PhpParser\Node\Expr\PropertyFetch $propertyFetch) : ?\PhpParser\Node + private function refactorPropertyFetchNode($node, PropertyFetch $propertyFetch) : ?Node { $name = $this->getName($propertyFetch); if ($name === null) { @@ -143,14 +143,14 @@ final class AssertIssetToSpecificMethodRector extends \Rector\Core\Rector\Abstra $this->identifierManipulator->renameNodeWithMap($node, [self::ASSERT_TRUE => 'assertObjectHasAttribute', self::ASSERT_FALSE => 'assertObjectNotHasAttribute']); $oldArgs = $node->args; unset($oldArgs[0]); - $newArgs = $this->nodeFactory->createArgs([new \PhpParser\Node\Scalar\String_($name), $propertyFetch->var]); + $newArgs = $this->nodeFactory->createArgs([new String_($name), $propertyFetch->var]); $node->args = $this->appendArgs($newArgs, $oldArgs); return $node; } /** * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node */ - private function refactorArrayDimFetchNode($node, \PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch) : \PhpParser\Node + private function refactorArrayDimFetchNode($node, ArrayDimFetch $arrayDimFetch) : Node { $this->identifierManipulator->renameNodeWithMap($node, [self::ASSERT_TRUE => 'assertArrayHasKey', self::ASSERT_FALSE => 'assertArrayNotHasKey']); $oldArgs = $node->args; diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertNotOperatorRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertNotOperatorRector.php index a441009dfb2..b384cacc248 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertNotOperatorRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertNotOperatorRector.php @@ -11,12 +11,12 @@ use PhpParser\Node\Expr\StaticCall; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\Rector\MethodCall\AssertNotOperatorRector\AssertNotOperatorRectorTest */ -final class AssertNotOperatorRector extends \Rector\Core\Rector\AbstractRector +final class AssertNotOperatorRector extends AbstractRector { /** * @var array @@ -32,33 +32,33 @@ final class AssertNotOperatorRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator $identifierManipulator, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(IdentifierManipulator $identifierManipulator, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->identifierManipulator = $identifierManipulator; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns not-operator comparisons to their method name alternatives in PHPUnit TestCase', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertTrue(!$foo, "message");', '$this->assertFalse($foo, "message");'), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertFalse(!$foo, "message");', '$this->assertTrue($foo, "message");')]); + return new RuleDefinition('Turns not-operator comparisons to their method name alternatives in PHPUnit TestCase', [new CodeSample('$this->assertTrue(!$foo, "message");', '$this->assertFalse($foo, "message");'), new CodeSample('$this->assertFalse(!$foo, "message");', '$this->assertTrue($foo, "message");')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $oldMethodNames = \array_keys(self::RENAME_METHODS_MAP); if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, $oldMethodNames)) { return null; } $firstArgumentValue = $node->args[0]->value; - if (!$firstArgumentValue instanceof \PhpParser\Node\Expr\BooleanNot) { + if (!$firstArgumentValue instanceof BooleanNot) { return null; } $this->identifierManipulator->renameNodeWithMap($node, self::RENAME_METHODS_MAP); @@ -67,7 +67,7 @@ final class AssertNotOperatorRector extends \Rector\Core\Rector\AbstractRector $negation = $oldArguments[0]->value; $expression = $negation->expr; unset($oldArguments[0]); - $node->args = \array_merge([new \PhpParser\Node\Arg($expression)], $oldArguments); + $node->args = \array_merge([new Arg($expression)], $oldArguments); return $node; } } diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertPropertyExistsRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertPropertyExistsRector.php index 33ffd9f3085..78364d6facf 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertPropertyExistsRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertPropertyExistsRector.php @@ -13,12 +13,12 @@ use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\Rector\MethodCall\AssertPropertyExistsRector\AssertPropertyExistsRectorTest */ -final class AssertPropertyExistsRector extends \Rector\Core\Rector\AbstractRector +final class AssertPropertyExistsRector extends AbstractRector { /** * @var array @@ -38,14 +38,14 @@ final class AssertPropertyExistsRector extends \Rector\Core\Rector\AbstractRecto * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator $identifierManipulator, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(IdentifierManipulator $identifierManipulator, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->identifierManipulator = $identifierManipulator; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns `property_exists` comparisons to their method name alternatives in PHPUnit TestCase', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns `property_exists` comparisons to their method name alternatives in PHPUnit TestCase', [new CodeSample(<<<'CODE_SAMPLE' $this->assertFalse(property_exists(new Class, "property")); $this->assertTrue(property_exists(new Class, "property")); CODE_SAMPLE @@ -60,39 +60,39 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, ['assertTrue', 'assertFalse'])) { return null; } $firstArgumentValue = $node->args[0]->value; - if (!$firstArgumentValue instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$firstArgumentValue instanceof FuncCall) { return null; } if (!$this->isName($firstArgumentValue, 'property_exists')) { return null; } $propertyExistsMethodCall = $node->args[0]->value; - if (!$propertyExistsMethodCall instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$propertyExistsMethodCall instanceof FuncCall) { return null; } $firstArgument = $propertyExistsMethodCall->args[0]; $secondArgument = $propertyExistsMethodCall->args[1]; - if ($firstArgument->value instanceof \PhpParser\Node\Expr\Variable) { - $secondArg = new \PhpParser\Node\Expr\Variable($firstArgument->value->name); + if ($firstArgument->value instanceof Variable) { + $secondArg = new Variable($firstArgument->value->name); $map = self::RENAME_METHODS_WITH_OBJECT_MAP; - } elseif ($firstArgument->value instanceof \PhpParser\Node\Expr\New_) { + } elseif ($firstArgument->value instanceof New_) { $secondArg = $this->getName($firstArgument->value->class); $map = self::RENAME_METHODS_WITH_CLASS_MAP; } else { return null; } - if (!$secondArgument->value instanceof \PhpParser\Node\Scalar\String_) { + if (!$secondArgument->value instanceof String_) { return null; } unset($node->args[0]); diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertRegExpRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertRegExpRector.php index eb8fa363780..70f4f2bc25f 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertRegExpRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertRegExpRector.php @@ -14,12 +14,12 @@ use PhpParser\Node\Scalar\LNumber; use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\Rector\MethodCall\AssertRegExpRector\AssertRegExpRectorTest */ -final class AssertRegExpRector extends \Rector\Core\Rector\AbstractRector +final class AssertRegExpRector extends AbstractRector { /** * @var string @@ -42,32 +42,32 @@ final class AssertRegExpRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer) { $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns `preg_match` comparisons to their method name alternatives in PHPUnit TestCase', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertSame(1, preg_match("/^Message for ".*"\\.$/", $string), $message);', '$this->assertRegExp("/^Message for ".*"\\.$/", $string, $message);'), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertEquals(false, preg_match("/^Message for ".*"\\.$/", $string), $message);', '$this->assertNotRegExp("/^Message for ".*"\\.$/", $string, $message);')]); + return new RuleDefinition('Turns `preg_match` comparisons to their method name alternatives in PHPUnit TestCase', [new CodeSample('$this->assertSame(1, preg_match("/^Message for ".*"\\.$/", $string), $message);', '$this->assertRegExp("/^Message for ".*"\\.$/", $string, $message);'), new CodeSample('$this->assertEquals(false, preg_match("/^Message for ".*"\\.$/", $string), $message);', '$this->assertNotRegExp("/^Message for ".*"\\.$/", $string, $message);')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, [self::ASSERT_SAME, self::ASSERT_EQUALS, self::ASSERT_NOT_SAME, self::ASSERT_NOT_EQUALS])) { return null; } /** @var FuncCall|Node $secondArgumentValue */ $secondArgumentValue = $node->args[1]->value; - if (!$secondArgumentValue instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$secondArgumentValue instanceof FuncCall) { return null; } if (!$this->isName($secondArgumentValue, 'preg_match')) { @@ -83,15 +83,15 @@ final class AssertRegExpRector extends \Rector\Core\Rector\AbstractRector $this->moveFunctionArgumentsUp($node); return $node; } - private function resolveOldCondition(\PhpParser\Node\Expr $expr) : int + private function resolveOldCondition(Expr $expr) : int { - if ($expr instanceof \PhpParser\Node\Scalar\LNumber) { + if ($expr instanceof LNumber) { return $expr->value; } - if ($expr instanceof \PhpParser\Node\Expr\ConstFetch) { + if ($expr instanceof ConstFetch) { return $this->valueResolver->isTrue($expr) ? 1 : 0; } - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } /** * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node @@ -99,10 +99,10 @@ final class AssertRegExpRector extends \Rector\Core\Rector\AbstractRector private function renameMethod($node, string $oldMethodName, int $oldCondition) : void { if (\in_array($oldMethodName, [self::ASSERT_SAME, self::ASSERT_EQUALS], \true) && $oldCondition === 1 || \in_array($oldMethodName, [self::ASSERT_NOT_SAME, self::ASSERT_NOT_EQUALS], \true) && $oldCondition === 0) { - $node->name = new \PhpParser\Node\Identifier('assertRegExp'); + $node->name = new Identifier('assertRegExp'); } if (\in_array($oldMethodName, [self::ASSERT_SAME, self::ASSERT_EQUALS], \true) && $oldCondition === 0 || \in_array($oldMethodName, [self::ASSERT_NOT_SAME, self::ASSERT_NOT_EQUALS], \true) && $oldCondition === 1) { - $node->name = new \PhpParser\Node\Identifier('assertNotRegExp'); + $node->name = new Identifier('assertNotRegExp'); } } /** diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertResourceToClosedResourceRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertResourceToClosedResourceRector.php index c05f906fba6..09f6ceb6689 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertResourceToClosedResourceRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertResourceToClosedResourceRector.php @@ -9,14 +9,14 @@ use PhpParser\Node\Expr\StaticCall; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @source https://github.com/sebastianbergmann/phpunit/pull/4365 * * @see \Rector\PHPUnit\Tests\Rector\MethodCall\AssertResourceToClosedResourceRector\AssertResourceToClosedResourceRectorTest */ -final class AssertResourceToClosedResourceRector extends \Rector\Core\Rector\AbstractRector +final class AssertResourceToClosedResourceRector extends AbstractRector { /** * @var array @@ -32,26 +32,26 @@ final class AssertResourceToClosedResourceRector extends \Rector\Core\Rector\Abs * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator $identifierManipulator, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(IdentifierManipulator $identifierManipulator, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->identifierManipulator = $identifierManipulator; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns `assertIsNotResource()` into stricter `assertIsClosedResource()` for resource values in PHPUnit TestCase', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertIsNotResource($aResource, "message");', '$this->assertIsClosedResource($aResource, "message");')]); + return new RuleDefinition('Turns `assertIsNotResource()` into stricter `assertIsClosedResource()` for resource values in PHPUnit TestCase', [new CodeSample('$this->assertIsNotResource($aResource, "message");', '$this->assertIsClosedResource($aResource, "message");')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isInTestClass($node)) { return null; diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertSameBoolNullToSpecificMethodRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertSameBoolNullToSpecificMethodRector.php index cf496236c41..7e61084fce1 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertSameBoolNullToSpecificMethodRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertSameBoolNullToSpecificMethodRector.php @@ -12,12 +12,12 @@ use Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\PHPUnit\NodeManipulator\ArgumentMover; use Rector\PHPUnit\ValueObject\ConstantWithAssertMethods; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\Rector\MethodCall\AssertSameBoolNullToSpecificMethodRector\AssertSameBoolNullToSpecificMethodRectorTest */ -final class AssertSameBoolNullToSpecificMethodRector extends \Rector\Core\Rector\AbstractRector +final class AssertSameBoolNullToSpecificMethodRector extends AbstractRector { /** * @var ConstantWithAssertMethods[] @@ -38,34 +38,34 @@ final class AssertSameBoolNullToSpecificMethodRector extends \Rector\Core\Rector * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator $identifierManipulator, \Rector\PHPUnit\NodeManipulator\ArgumentMover $argumentMover, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(IdentifierManipulator $identifierManipulator, ArgumentMover $argumentMover, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->identifierManipulator = $identifierManipulator; $this->argumentMover = $argumentMover; $this->testsNodeAnalyzer = $testsNodeAnalyzer; - $this->constantWithAssertMethods = [new \Rector\PHPUnit\ValueObject\ConstantWithAssertMethods('null', 'assertNull', 'assertNotNull'), new \Rector\PHPUnit\ValueObject\ConstantWithAssertMethods('true', 'assertTrue', 'assertNotTrue'), new \Rector\PHPUnit\ValueObject\ConstantWithAssertMethods('false', 'assertFalse', 'assertNotFalse')]; + $this->constantWithAssertMethods = [new ConstantWithAssertMethods('null', 'assertNull', 'assertNotNull'), new ConstantWithAssertMethods('true', 'assertTrue', 'assertNotTrue'), new ConstantWithAssertMethods('false', 'assertFalse', 'assertNotFalse')]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns same bool and null comparisons to their method name alternatives in PHPUnit TestCase', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertSame(null, $anything);', '$this->assertNull($anything);'), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertNotSame(false, $anything);', '$this->assertNotFalse($anything);')]); + return new RuleDefinition('Turns same bool and null comparisons to their method name alternatives in PHPUnit TestCase', [new CodeSample('$this->assertSame(null, $anything);', '$this->assertNull($anything);'), new CodeSample('$this->assertNotSame(false, $anything);', '$this->assertNotFalse($anything);')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, ['assertSame', 'assertNotSame'])) { return null; } $firstArgumentValue = $node->args[0]->value; - if (!$firstArgumentValue instanceof \PhpParser\Node\Expr\ConstFetch) { + if (!$firstArgumentValue instanceof ConstFetch) { return null; } foreach ($this->constantWithAssertMethods as $constantWithAssertMethod) { @@ -81,7 +81,7 @@ final class AssertSameBoolNullToSpecificMethodRector extends \Rector\Core\Rector /** * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node */ - private function renameMethod($node, \Rector\PHPUnit\ValueObject\ConstantWithAssertMethods $constantWithAssertMethods) : void + private function renameMethod($node, ConstantWithAssertMethods $constantWithAssertMethods) : void { $this->identifierManipulator->renameNodeWithMap($node, ['assertSame' => $constantWithAssertMethods->getAssetMethodName(), 'assertNotSame' => $constantWithAssertMethods->getNotAssertMethodName()]); } diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector.php index cc3d86ee972..3419c998258 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector.php @@ -9,12 +9,12 @@ use PhpParser\Node\Identifier; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\PHPUnit\NodeManipulator\ArgumentMover; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\Rector\MethodCall\AssertSameTrueFalseToAssertTrueFalseRector\AssertSameTrueFalseToAssertTrueFalseRectorTest */ -final class AssertSameTrueFalseToAssertTrueFalseRector extends \Rector\Core\Rector\AbstractRector +final class AssertSameTrueFalseToAssertTrueFalseRector extends AbstractRector { /** * @readonly @@ -26,14 +26,14 @@ final class AssertSameTrueFalseToAssertTrueFalseRector extends \Rector\Core\Rect * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeManipulator\ArgumentMover $argumentMover, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(ArgumentMover $argumentMover, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->argumentMover = $argumentMover; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change $this->assertSame(true, ...) to assertTrue()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change $this->assertSame(true, ...) to assertTrue()', [new CodeSample(<<<'CODE_SAMPLE' use PHPUnit\Framework\TestCase; final class SomeTest extends TestCase @@ -64,24 +64,24 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, ['assertSame', 'assertEqual', 'assertNotSame', 'assertNotEqual'])) { return null; } if ($this->valueResolver->isTrue($node->args[0]->value)) { $this->argumentMover->removeFirst($node); - $node->name = new \PhpParser\Node\Identifier('assertTrue'); + $node->name = new Identifier('assertTrue'); return $node; } if ($this->valueResolver->isFalse($node->args[0]->value)) { $this->argumentMover->removeFirst($node); - $node->name = new \PhpParser\Node\Identifier('assertFalse'); + $node->name = new Identifier('assertFalse'); return $node; } return null; diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector.php index 9bd97c58c26..394cb064f06 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector.php @@ -12,12 +12,12 @@ use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\Rector\MethodCall\AssertTrueFalseInternalTypeToSpecificMethodRector\AssertTrueFalseInternalTypeToSpecificMethodRectorTest */ -final class AssertTrueFalseInternalTypeToSpecificMethodRector extends \Rector\Core\Rector\AbstractRector +final class AssertTrueFalseInternalTypeToSpecificMethodRector extends AbstractRector { /** * @var array @@ -37,26 +37,26 @@ final class AssertTrueFalseInternalTypeToSpecificMethodRector extends \Rector\Co * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator $identifierManipulator, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(IdentifierManipulator $identifierManipulator, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->identifierManipulator = $identifierManipulator; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns true/false with internal type comparisons to their method name alternatives in PHPUnit TestCase', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertTrue(is_{internal_type}($anything), "message");', '$this->assertInternalType({internal_type}, $anything, "message");'), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertFalse(is_{internal_type}($anything), "message");', '$this->assertNotInternalType({internal_type}, $anything, "message");')]); + return new RuleDefinition('Turns true/false with internal type comparisons to their method name alternatives in PHPUnit TestCase', [new CodeSample('$this->assertTrue(is_{internal_type}($anything), "message");', '$this->assertInternalType({internal_type}, $anything, "message");'), new CodeSample('$this->assertFalse(is_{internal_type}($anything), "message");', '$this->assertNotInternalType({internal_type}, $anything, "message");')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $oldMethods = \array_keys(self::RENAME_METHODS_MAP); if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, $oldMethods)) { @@ -64,7 +64,7 @@ final class AssertTrueFalseInternalTypeToSpecificMethodRector extends \Rector\Co } /** @var FuncCall|Node $firstArgumentValue */ $firstArgumentValue = $node->args[0]->value; - if (!$firstArgumentValue instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$firstArgumentValue instanceof FuncCall) { return null; } $functionName = $this->getName($firstArgumentValue); @@ -77,13 +77,13 @@ final class AssertTrueFalseInternalTypeToSpecificMethodRector extends \Rector\Co /** * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node */ - private function moveFunctionArgumentsUp($node) : \PhpParser\Node + private function moveFunctionArgumentsUp($node) : Node { /** @var FuncCall $isFunctionNode */ $isFunctionNode = $node->args[0]->value; $firstArgumentValue = $isFunctionNode->args[0]->value; $isFunctionName = $this->getName($isFunctionNode); - $newArgs = [new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\String_(self::OLD_FUNCTIONS_TO_TYPES[$isFunctionName])), new \PhpParser\Node\Arg($firstArgumentValue)]; + $newArgs = [new Arg(new String_(self::OLD_FUNCTIONS_TO_TYPES[$isFunctionName])), new Arg($firstArgumentValue)]; $oldArguments = $node->args; unset($oldArguments[0]); $node->args = $this->appendArgs($newArgs, $oldArguments); diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector.php index 18b3acc7949..f7b7e353b87 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector.php @@ -13,12 +13,12 @@ use PhpParser\Node\Identifier; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\Rector\MethodCall\AssertTrueFalseToSpecificMethodRector\AssertTrueFalseToSpecificMethodRectorTest */ -final class AssertTrueFalseToSpecificMethodRector extends \Rector\Core\Rector\AbstractRector +final class AssertTrueFalseToSpecificMethodRector extends AbstractRector { /** * @var FunctionNameWithAssertMethods[] @@ -29,26 +29,26 @@ final class AssertTrueFalseToSpecificMethodRector extends \Rector\Core\Rector\Ab * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer) { $this->testsNodeAnalyzer = $testsNodeAnalyzer; - $this->functionNameWithAssertMethods = [new \Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods('is_readable', 'assertIsReadable', 'assertNotIsReadable'), new \Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods('array_key_exists', 'assertArrayHasKey', 'assertArrayNotHasKey'), new \Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods('array_search', 'assertContains', 'assertNotContains'), new \Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods('in_array', 'assertContains', 'assertNotContains'), new \Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods('empty', 'assertEmpty', 'assertNotEmpty'), new \Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods('file_exists', 'assertFileExists', 'assertFileNotExists'), new \Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods('is_dir', 'assertDirectoryExists', 'assertDirectoryNotExists'), new \Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods('is_infinite', 'assertInfinite', 'assertFinite'), new \Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods('is_null', 'assertNull', 'assertNotNull'), new \Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods('is_writable', 'assertIsWritable', 'assertNotIsWritable'), new \Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods('is_nan', 'assertNan', ''), new \Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods('is_a', 'assertInstanceOf', 'assertNotInstanceOf')]; + $this->functionNameWithAssertMethods = [new FunctionNameWithAssertMethods('is_readable', 'assertIsReadable', 'assertNotIsReadable'), new FunctionNameWithAssertMethods('array_key_exists', 'assertArrayHasKey', 'assertArrayNotHasKey'), new FunctionNameWithAssertMethods('array_search', 'assertContains', 'assertNotContains'), new FunctionNameWithAssertMethods('in_array', 'assertContains', 'assertNotContains'), new FunctionNameWithAssertMethods('empty', 'assertEmpty', 'assertNotEmpty'), new FunctionNameWithAssertMethods('file_exists', 'assertFileExists', 'assertFileNotExists'), new FunctionNameWithAssertMethods('is_dir', 'assertDirectoryExists', 'assertDirectoryNotExists'), new FunctionNameWithAssertMethods('is_infinite', 'assertInfinite', 'assertFinite'), new FunctionNameWithAssertMethods('is_null', 'assertNull', 'assertNotNull'), new FunctionNameWithAssertMethods('is_writable', 'assertIsWritable', 'assertNotIsWritable'), new FunctionNameWithAssertMethods('is_nan', 'assertNan', ''), new FunctionNameWithAssertMethods('is_a', 'assertInstanceOf', 'assertNotInstanceOf')]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns true/false comparisons to their method name alternatives in PHPUnit TestCase when possible', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->assertTrue(is_readable($readmeFile), "message");', '$this->assertIsReadable($readmeFile, "message");')]); + return new RuleDefinition('Turns true/false comparisons to their method name alternatives in PHPUnit TestCase when possible', [new CodeSample('$this->assertTrue(is_readable($readmeFile), "message");', '$this->assertIsReadable($readmeFile, "message");')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, ['assertTrue', 'assertFalse', 'assertNotTrue', 'assertNotFalse'])) { return null; @@ -57,7 +57,7 @@ final class AssertTrueFalseToSpecificMethodRector extends \Rector\Core\Rector\Ab return null; } $firstArgumentValue = $node->args[0]->value; - if (!$firstArgumentValue instanceof \PhpParser\Node\Expr\FuncCall && !$firstArgumentValue instanceof \PhpParser\Node\Expr\Empty_) { + if (!$firstArgumentValue instanceof FuncCall && !$firstArgumentValue instanceof Empty_) { return null; } foreach ($this->functionNameWithAssertMethods as $functionNameWithAssertMethod) { @@ -77,13 +77,13 @@ final class AssertTrueFalseToSpecificMethodRector extends \Rector\Core\Rector\Ab /** * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node */ - private function renameMethod($node, \Rector\PHPUnit\ValueObject\FunctionNameWithAssertMethods $functionNameWithAssertMethods) : void + private function renameMethod($node, FunctionNameWithAssertMethods $functionNameWithAssertMethods) : void { /** @var Identifier $identifierNode */ $identifierNode = $node->name; $oldMethodName = $identifierNode->toString(); if (\in_array($oldMethodName, ['assertTrue', 'assertNotFalse'], \true)) { - $node->name = new \PhpParser\Node\Identifier($functionNameWithAssertMethods->getAssetMethodName()); + $node->name = new Identifier($functionNameWithAssertMethods->getAssetMethodName()); } if ($functionNameWithAssertMethods->getNotAssertMethodName() === '') { return; @@ -91,7 +91,7 @@ final class AssertTrueFalseToSpecificMethodRector extends \Rector\Core\Rector\Ab if (!\in_array($oldMethodName, ['assertFalse', 'assertNotTrue'], \true)) { return; } - $node->name = new \PhpParser\Node\Identifier($functionNameWithAssertMethods->getNotAssertMethodName()); + $node->name = new Identifier($functionNameWithAssertMethods->getNotAssertMethodName()); } /** * Before: @@ -104,7 +104,7 @@ final class AssertTrueFalseToSpecificMethodRector extends \Rector\Core\Rector\Ab private function moveFunctionArgumentsUp($node) : void { $funcCallOrEmptyNode = $node->args[0]->value; - if ($funcCallOrEmptyNode instanceof \PhpParser\Node\Expr\FuncCall) { + if ($funcCallOrEmptyNode instanceof FuncCall) { $funcCallOrEmptyNodeName = $this->getName($funcCallOrEmptyNode); if ($funcCallOrEmptyNodeName === null) { return; @@ -114,8 +114,8 @@ final class AssertTrueFalseToSpecificMethodRector extends \Rector\Core\Rector\Ab unset($oldArguments[0]); $node->args = $this->buildNewArguments($funcCallOrEmptyNodeName, $funcCallOrEmptyNodeArgs, $oldArguments); } - if ($funcCallOrEmptyNode instanceof \PhpParser\Node\Expr\Empty_) { - $node->args[0] = new \PhpParser\Node\Arg($funcCallOrEmptyNode->expr); + if ($funcCallOrEmptyNode instanceof Empty_) { + $node->args[0] = new Arg($funcCallOrEmptyNode->expr); } } /** diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/CreateMockToCreateStubRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/CreateMockToCreateStubRector.php index 44d73dc3ce2..4e7157e34f2 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/CreateMockToCreateStubRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/CreateMockToCreateStubRector.php @@ -12,15 +12,15 @@ use Rector\Core\NodeManipulator\MethodCallManipulator; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/sebastianbergmann/phpunit/issues/3120 * "If, and only if, the expects() method is called on this stub to set up expectations then that stub becomes a mock." * * @see \Rector\PHPUnit\Tests\Rector\MethodCall\CreateMockToCreateStubRector\CreateMockToCreateStubRectorTest */ -final class CreateMockToCreateStubRector extends \Rector\Core\Rector\AbstractRector +final class CreateMockToCreateStubRector extends AbstractRector { /** * @readonly @@ -32,14 +32,14 @@ final class CreateMockToCreateStubRector extends \Rector\Core\Rector\AbstractRec * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\Core\NodeManipulator\MethodCallManipulator $methodCallManipulator, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(MethodCallManipulator $methodCallManipulator, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->methodCallManipulator = $methodCallManipulator; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replaces createMock() with createStub() when relevant', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replaces createMock() with createStub() when relevant', [new CodeSample(<<<'CODE_SAMPLE' use PHPUnit\Framework\TestCase class MyTest extends TestCase @@ -88,12 +88,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isInTestClass($node)) { return null; @@ -101,19 +101,19 @@ CODE_SAMPLE if (!$this->isName($node->name, 'createMock')) { return null; } - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if (!$parentNode instanceof \PhpParser\Node\Expr\Assign) { + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); + if (!$parentNode instanceof Assign) { return null; } $mockVariable = $parentNode->var; - if (!$mockVariable instanceof \PhpParser\Node\Expr\Variable) { + if (!$mockVariable instanceof Variable) { return null; } $methodCallNamesOnVariable = $this->methodCallManipulator->findMethodCallNamesOnVariable($mockVariable); if (\in_array('expects', $methodCallNamesOnVariable, \true)) { return null; } - $node->name = new \PhpParser\Node\Identifier('createStub'); + $node->name = new Identifier('createStub'); return $node; } } diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/DelegateExceptionArgumentsRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/DelegateExceptionArgumentsRector.php index d6fe2fb81f2..ac2d6042abf 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/DelegateExceptionArgumentsRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/DelegateExceptionArgumentsRector.php @@ -10,12 +10,12 @@ use PhpParser\Node\Identifier; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\PHPUnit\NodeFactory\AssertCallFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\PHPUnit\Tests\Rector\MethodCall\DelegateExceptionArgumentsRector\DelegateExceptionArgumentsRectorTest */ -final class DelegateExceptionArgumentsRector extends \Rector\Core\Rector\AbstractRector +final class DelegateExceptionArgumentsRector extends AbstractRector { /** * @var array @@ -31,14 +31,14 @@ final class DelegateExceptionArgumentsRector extends \Rector\Core\Rector\Abstrac * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeFactory\AssertCallFactory $assertCallFactory, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(AssertCallFactory $assertCallFactory, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->assertCallFactory = $assertCallFactory; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Takes `setExpectedException()` 2nd and next arguments to own methods in PHPUnit.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->setExpectedException(Exception::class, "Message", "CODE");', <<<'CODE_SAMPLE' + return new RuleDefinition('Takes `setExpectedException()` 2nd and next arguments to own methods in PHPUnit.', [new CodeSample('$this->setExpectedException(Exception::class, "Message", "CODE");', <<<'CODE_SAMPLE' $this->setExpectedException(Exception::class); $this->expectExceptionMessage('Message'); $this->expectExceptionCode('CODE'); @@ -50,12 +50,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $oldMethodNames = \array_keys(self::OLD_TO_NEW_METHOD); if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, $oldMethodNames)) { @@ -77,7 +77,7 @@ CODE_SAMPLE unset($node->args[2]); } } - $node->name = new \PhpParser\Node\Identifier('expectException'); + $node->name = new Identifier('expectException'); return $node; } } diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/ExplicitPhpErrorApiRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/ExplicitPhpErrorApiRector.php index ebc9f875fba..700b41db336 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/ExplicitPhpErrorApiRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/ExplicitPhpErrorApiRector.php @@ -11,15 +11,15 @@ use PhpParser\Node\Expr\StaticCall; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\PHPUnit\NodeFactory\AssertCallFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/sebastianbergmann/phpunit/blob/master/ChangeLog-9.0.md * @see https://github.com/sebastianbergmann/phpunit/commit/1ba2e3e1bb091acda3139f8a9259fa8161f3242d * * @see \Rector\PHPUnit\Tests\Rector\MethodCall\ExplicitPhpErrorApiRector\ExplicitPhpErrorApiRectorTest */ -final class ExplicitPhpErrorApiRector extends \Rector\Core\Rector\AbstractRector +final class ExplicitPhpErrorApiRector extends AbstractRector { /** * @var array @@ -35,14 +35,14 @@ final class ExplicitPhpErrorApiRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeFactory\AssertCallFactory $assertCallFactory, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(AssertCallFactory $assertCallFactory, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->assertCallFactory = $assertCallFactory; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Use explicit API for expecting PHP errors, warnings, and notices', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Use explicit API for expecting PHP errors, warnings, and notices', [new CodeSample(<<<'CODE_SAMPLE' final class SomeTest extends \PHPUnit\Framework\TestCase { public function test() @@ -73,12 +73,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, ['expectException'])) { return null; @@ -94,7 +94,7 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node */ - private function replaceExceptionWith($node, string $exceptionClass, string $explicitMethod) : ?\PhpParser\Node + private function replaceExceptionWith($node, string $exceptionClass, string $explicitMethod) : ?Node { if (!isset($node->args[0])) { return null; @@ -107,9 +107,9 @@ CODE_SAMPLE /** * Detects "SomeClass::class" */ - private function isClassConstReference(\PhpParser\Node\Expr $expr, string $className) : bool + private function isClassConstReference(Expr $expr, string $className) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if (!$expr instanceof ClassConstFetch) { return \false; } if (!$this->isName($expr->name, 'class')) { diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector.php index 7331c51d3a9..153ac783b99 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector.php @@ -6,22 +6,22 @@ namespace Rector\PHPUnit\Rector\MethodCall; use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/lmc-eu/steward/pull/187/files#diff-c7e8c65e59b8b4ff8b54325814d4ba55L80 * * @see \Rector\PHPUnit\Tests\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector\GetMockBuilderGetMockToCreateMockRectorTest */ -final class GetMockBuilderGetMockToCreateMockRector extends \Rector\Core\Rector\AbstractRector +final class GetMockBuilderGetMockToCreateMockRector extends AbstractRector { /** * @var string[] */ private const USELESS_METHOD_NAMES = ['disableOriginalConstructor', 'onlyMethods', 'setMethods', 'setMethodsExcept']; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove getMockBuilder() to createMock()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove getMockBuilder() to createMock()', [new CodeSample(<<<'CODE_SAMPLE' use PHPUnit\Framework\TestCase; final class SomeTest extends TestCase @@ -52,25 +52,25 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node->name, 'getMock')) { return null; } - if (!$node->var instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$node->var instanceof MethodCall) { return null; } // traverse up over useless methods until we reach the top one $currentMethodCall = $node->var; - while ($currentMethodCall instanceof \PhpParser\Node\Expr\MethodCall && $this->isNames($currentMethodCall->name, self::USELESS_METHOD_NAMES)) { + while ($currentMethodCall instanceof MethodCall && $this->isNames($currentMethodCall->name, self::USELESS_METHOD_NAMES)) { $currentMethodCall = $currentMethodCall->var; } - if (!$currentMethodCall instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$currentMethodCall instanceof MethodCall) { return null; } if (!$this->isName($currentMethodCall->name, 'getMockBuilder')) { @@ -78,6 +78,6 @@ CODE_SAMPLE } $args = $currentMethodCall->args; $thisVariable = $currentMethodCall->var; - return new \PhpParser\Node\Expr\MethodCall($thisVariable, 'createMock', $args); + return new MethodCall($thisVariable, 'createMock', $args); } } diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/RemoveExpectAnyFromMockRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/RemoveExpectAnyFromMockRector.php index 73191ce3d69..74c4fba9095 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/RemoveExpectAnyFromMockRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/RemoveExpectAnyFromMockRector.php @@ -8,26 +8,26 @@ use PhpParser\Node\Expr; use PhpParser\Node\Expr\MethodCall; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/symfony/symfony/pull/30813/files#r270879504 * @see \Rector\PHPUnit\Tests\Rector\MethodCall\RemoveExpectAnyFromMockRector\RemoveExpectAnyFromMockRectorTest */ -final class RemoveExpectAnyFromMockRector extends \Rector\Core\Rector\AbstractRector +final class RemoveExpectAnyFromMockRector extends AbstractRector { /** * @readonly * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer) { $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove `expect($this->any())` from mocks as it has no added value', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove `expect($this->any())` from mocks as it has no added value', [new CodeSample(<<<'CODE_SAMPLE' use PHPUnit\Framework\TestCase; class SomeClass extends TestCase @@ -61,12 +61,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isInTestClass($node)) { return null; @@ -83,9 +83,9 @@ CODE_SAMPLE } return $node->var; } - private function isMethodCallOnVariableNamed(\PhpParser\Node\Expr $expr, string $variableName, string $methodName) : bool + private function isMethodCallOnVariableNamed(Expr $expr, string $variableName, string $methodName) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$expr instanceof MethodCall) { return \false; } if (!$this->isName($expr->var, $variableName)) { diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/RemoveSetMethodsMethodCallRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/RemoveSetMethodsMethodCallRector.php index 1f768f3783e..b83458b5a6d 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/RemoveSetMethodsMethodCallRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/RemoveSetMethodsMethodCallRector.php @@ -8,8 +8,8 @@ use PhpParser\Node\Expr\MethodCall; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/sebastianbergmann/phpunit/pull/3687 * @changelog https://github.com/sebastianbergmann/phpunit/commit/d618fa3fda437421264dcfa1413a474f306f79c4 @@ -17,20 +17,20 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @see \Rector\PHPUnit\Tests\Rector\MethodCall\RemoveSetMethodsMethodCallRector\RemoveSetMethodsMethodCallRectorTest */ -final class RemoveSetMethodsMethodCallRector extends \Rector\Core\Rector\AbstractRector +final class RemoveSetMethodsMethodCallRector extends AbstractRector { /** * @readonly * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer) { $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove "setMethods()" method as never used', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove "setMethods()" method as never used', [new CodeSample(<<<'CODE_SAMPLE' use PHPUnit\Framework\TestCase; final class SomeTest extends TestCase @@ -62,12 +62,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isInTestClass($node)) { return null; @@ -75,7 +75,7 @@ CODE_SAMPLE if (!$this->isName($node->name, 'setMethods')) { return null; } - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('PHPUnit\\Framework\\MockObject\\MockBuilder'))) { + if (!$this->isObjectType($node->var, new ObjectType('PHPUnit\\Framework\\MockObject\\MockBuilder'))) { return null; } return $node->var; diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/ReplaceAssertArraySubsetWithDmsPolyfillRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/ReplaceAssertArraySubsetWithDmsPolyfillRector.php index 6321a9b36ef..b65e6bce596 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/ReplaceAssertArraySubsetWithDmsPolyfillRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/ReplaceAssertArraySubsetWithDmsPolyfillRector.php @@ -8,28 +8,28 @@ use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\StaticCall; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/sebastianbergmann/phpunit/issues/3494#issuecomment-480283612 * @see https://github.com/sebastianbergmann/phpunit/issues/3495 * * @see \Rector\PHPUnit\Tests\Rector\MethodCall\ReplaceAssertArraySubsetWithDmsPolyfillRector\ReplaceAssertArraySubsetWithDmsPolyfillRectorTest */ -final class ReplaceAssertArraySubsetWithDmsPolyfillRector extends \Rector\Core\Rector\AbstractRector +final class ReplaceAssertArraySubsetWithDmsPolyfillRector extends AbstractRector { /** * @readonly * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer) { $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change assertArraySubset() to static call of DMS\\PHPUnitExtensions\\ArraySubset\\Assert', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change assertArraySubset() to static call of DMS\\PHPUnitExtensions\\ArraySubset\\Assert', [new CodeSample(<<<'CODE_SAMPLE' use PHPUnit\Framework\TestCase; class SomeClass extends TestCase @@ -62,12 +62,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isInPHPUnitMethodCallName($node, 'assertArraySubset')) { return null; diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/SpecificAssertContainsRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/SpecificAssertContainsRector.php index 5f97a7365b3..dac6e8221d7 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/SpecificAssertContainsRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/SpecificAssertContainsRector.php @@ -12,14 +12,14 @@ use PHPStan\Type\StringType; use PHPStan\Type\UnionType; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/sebastianbergmann/phpunit/blob/master/ChangeLog-8.0.md * * @see \Rector\PHPUnit\Tests\Rector\MethodCall\SpecificAssertContainsRector\SpecificAssertContainsRectorTest */ -final class SpecificAssertContainsRector extends \Rector\Core\Rector\AbstractRector +final class SpecificAssertContainsRector extends AbstractRector { /** * @var array @@ -30,13 +30,13 @@ final class SpecificAssertContainsRector extends \Rector\Core\Rector\AbstractRec * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer) { $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change assertContains()/assertNotContains() method to new string and iterable alternatives', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change assertContains()/assertNotContains() method to new string and iterable alternatives', [new CodeSample(<<<'CODE_SAMPLE' final class SomeTest extends \PHPUnit\Framework\TestCase { public function test() @@ -63,12 +63,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, ['assertContains', 'assertNotContains'])) { return null; @@ -78,19 +78,19 @@ CODE_SAMPLE } $methodName = $this->getName($node->name); $newMethodName = self::OLD_TO_NEW_METHOD_NAMES[$methodName]; - $node->name = new \PhpParser\Node\Identifier($newMethodName); + $node->name = new Identifier($newMethodName); return $node; } - private function isPossiblyStringType(\PhpParser\Node\Expr $expr) : bool + private function isPossiblyStringType(Expr $expr) : bool { $exprType = $this->getType($expr); - if ($exprType instanceof \PHPStan\Type\UnionType) { + if ($exprType instanceof UnionType) { foreach ($exprType->getTypes() as $unionedType) { - if ($unionedType instanceof \PHPStan\Type\StringType) { + if ($unionedType instanceof StringType) { return \true; } } } - return $exprType instanceof \PHPStan\Type\StringType; + return $exprType instanceof StringType; } } diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector.php index ec9fce2e13c..b9d1e7c5235 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/SpecificAssertContainsWithoutIdentityRector.php @@ -10,13 +10,13 @@ use PhpParser\Node\Identifier; use PHPStan\Type\StringType; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/sebastianbergmann/phpunit/issues/3426 * @see \Rector\PHPUnit\Tests\Rector\MethodCall\SpecificAssertContainsWithoutIdentityRector\SpecificAssertContainsWithoutIdentityRectorTest */ -final class SpecificAssertContainsWithoutIdentityRector extends \Rector\Core\Rector\AbstractRector +final class SpecificAssertContainsWithoutIdentityRector extends AbstractRector { /** * @var array> @@ -27,13 +27,13 @@ final class SpecificAssertContainsWithoutIdentityRector extends \Rector\Core\Rec * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer) { $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change assertContains()/assertNotContains() with non-strict comparison to new specific alternatives', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change assertContains()/assertNotContains() with non-strict comparison to new specific alternatives', [new CodeSample(<<<'CODE_SAMPLE' final class SomeTest extends \PHPUnit\Framework\TestCase { public function test() @@ -62,19 +62,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, ['assertContains', 'assertNotContains'])) { return null; } // when second argument is string: do nothing $secondArgType = $this->getType($node->args[1]->value); - if ($secondArgType instanceof \PHPStan\Type\StringType) { + if ($secondArgType instanceof StringType) { return null; } //when less then 5 arguments given: do nothing @@ -90,7 +90,7 @@ CODE_SAMPLE } /* here we search for element of array without identity check and we can replace functions */ $methodName = $this->getName($node->name); - $node->name = new \PhpParser\Node\Identifier(self::OLD_METHODS_NAMES_TO_NEW_NAMES['string'][$methodName]); + $node->name = new Identifier(self::OLD_METHODS_NAMES_TO_NEW_NAMES['string'][$methodName]); unset($node->args[3], $node->args[4]); return $node; } diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/SpecificAssertInternalTypeRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/SpecificAssertInternalTypeRector.php index 8b1e2125913..382695ffd31 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/SpecificAssertInternalTypeRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/SpecificAssertInternalTypeRector.php @@ -10,14 +10,14 @@ use PhpParser\Node\Identifier; use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/sebastianbergmann/phpunit/blob/master/ChangeLog-8.0.md * @see https://github.com/sebastianbergmann/phpunit/commit/a406c85c51edd76ace29119179d8c21f590c939e * @see \Rector\PHPUnit\Tests\Rector\MethodCall\SpecificAssertInternalTypeRector\SpecificAssertInternalTypeRectorTest */ -final class SpecificAssertInternalTypeRector extends \Rector\Core\Rector\AbstractRector +final class SpecificAssertInternalTypeRector extends AbstractRector { /** * @var array @@ -28,13 +28,13 @@ final class SpecificAssertInternalTypeRector extends \Rector\Core\Rector\Abstrac * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer) { $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change assertInternalType()/assertNotInternalType() method to new specific alternatives', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change assertInternalType()/assertNotInternalType() method to new specific alternatives', [new CodeSample(<<<'CODE_SAMPLE' final class SomeTest extends \PHPUnit\Framework\TestCase { public function test() @@ -63,18 +63,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, ['assertInternalType', 'assertNotInternalType'])) { return null; } $typeNode = $node->args[0]->value; - if (!$typeNode instanceof \PhpParser\Node\Scalar\String_) { + if (!$typeNode instanceof String_) { return null; } $type = $typeNode->value; @@ -84,7 +84,7 @@ CODE_SAMPLE \array_shift($node->args); $position = $this->isName($node->name, 'assertInternalType') ? 0 : 1; $methodName = self::TYPE_TO_METHOD[$type][$position]; - $node->name = new \PhpParser\Node\Identifier($methodName); + $node->name = new Identifier($methodName); return $node; } } diff --git a/vendor/rector/rector-phpunit/src/Rector/MethodCall/UseSpecificWillMethodRector.php b/vendor/rector/rector-phpunit/src/Rector/MethodCall/UseSpecificWillMethodRector.php index c3532d46612..61ab73d920b 100644 --- a/vendor/rector/rector-phpunit/src/Rector/MethodCall/UseSpecificWillMethodRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/MethodCall/UseSpecificWillMethodRector.php @@ -10,14 +10,14 @@ use PhpParser\Node\Identifier; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/4160 * @see https://github.com/symfony/symfony/pull/29685/files * @see \Rector\PHPUnit\Tests\Rector\MethodCall\UseSpecificWillMethodRector\UseSpecificWillMethodRectorTest */ -final class UseSpecificWillMethodRector extends \Rector\Core\Rector\AbstractRector +final class UseSpecificWillMethodRector extends AbstractRector { /** * @var array @@ -28,13 +28,13 @@ final class UseSpecificWillMethodRector extends \Rector\Core\Rector\AbstractRect * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer) { $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes ->will($this->xxx()) to one specific method', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes ->will($this->xxx()) to one specific method', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass extends PHPUnit\Framework\TestCase { public function test() @@ -67,18 +67,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isInTestClass($node)) { return null; } - $callerNode = $node instanceof \PhpParser\Node\Expr\StaticCall ? $node->class : $node->var; - if (!$this->isObjectType($callerNode, new \PHPStan\Type\ObjectType('PHPUnit\\Framework\\MockObject\\Builder\\InvocationMocker'))) { + $callerNode = $node instanceof StaticCall ? $node->class : $node->var; + if (!$this->isObjectType($callerNode, new ObjectType('PHPUnit\\Framework\\MockObject\\Builder\\InvocationMocker'))) { return null; } if ($this->isName($node->name, 'with')) { @@ -93,10 +93,10 @@ CODE_SAMPLE * @return MethodCall|StaticCall * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node */ - private function processWithCall($node) : \PhpParser\Node + private function processWithCall($node) : Node { foreach ($node->args as $i => $argNode) { - if (!$argNode->value instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$argNode->value instanceof MethodCall) { continue; } $methodCall = $argNode->value; @@ -111,9 +111,9 @@ CODE_SAMPLE * @return MethodCall|StaticCall|null * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node */ - private function processWillCall($node) : ?\PhpParser\Node + private function processWillCall($node) : ?Node { - if (!$node->args[0]->value instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$node->args[0]->value instanceof MethodCall) { return null; } $nestedMethodCall = $node->args[0]->value; @@ -121,7 +121,7 @@ CODE_SAMPLE if (!$this->isName($nestedMethodCall->name, $oldMethodName)) { continue; } - $node->name = new \PhpParser\Node\Identifier($newParentMethodName); + $node->name = new Identifier($newParentMethodName); // move args up $node->args = $nestedMethodCall->args; return $node; diff --git a/vendor/rector/rector-phpunit/src/Rector/StaticCall/GetMockRector.php b/vendor/rector/rector-phpunit/src/Rector/StaticCall/GetMockRector.php index 791f07dacc9..8ef57fbc936 100644 --- a/vendor/rector/rector-phpunit/src/Rector/StaticCall/GetMockRector.php +++ b/vendor/rector/rector-phpunit/src/Rector/StaticCall/GetMockRector.php @@ -11,15 +11,15 @@ use PHPStan\Reflection\ClassReflection; use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/sebastianbergmann/phpunit/blob/5.7.0/src/Framework/TestCase.php#L1623 * @see https://github.com/sebastianbergmann/phpunit/blob/6.0.0/src/Framework/TestCase.php#L1452 * * @see \Rector\PHPUnit\Tests\Rector\StaticCall\GetMockRector\GetMockRectorTest */ -final class GetMockRector extends \Rector\Core\Rector\AbstractRector +final class GetMockRector extends AbstractRector { /** * @readonly @@ -31,14 +31,14 @@ final class GetMockRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer, ReflectionResolver $reflectionResolver) { $this->testsNodeAnalyzer = $testsNodeAnalyzer; $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns getMock*() methods to createMock()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns getMock*() methods to createMock()', [new CodeSample(<<<'CODE_SAMPLE' use PHPUnit\Framework\TestCase; final class SomeTest extends TestCase @@ -67,28 +67,28 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, ['getMock', 'getMockWithoutInvokingTheOriginalConstructor'])) { return null; } - if ($node instanceof \PhpParser\Node\Expr\MethodCall && $node->var instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node instanceof MethodCall && $node->var instanceof MethodCall) { return null; } $classReflection = $this->reflectionResolver->resolveClassReflectionSourceObject($node); - if ($classReflection instanceof \PHPStan\Reflection\ClassReflection && $classReflection->getName() !== 'PHPUnit\\Framework\\TestCase') { + if ($classReflection instanceof ClassReflection && $classReflection->getName() !== 'PHPUnit\\Framework\\TestCase') { return null; } // narrow args to one if (\count($node->args) > 1) { $node->args = [$node->args[0]]; } - $node->name = new \PhpParser\Node\Identifier('createMock'); + $node->name = new Identifier('createMock'); return $node; } } diff --git a/vendor/rector/rector-phpunit/src/Set/PHPUnitLevelSetList.php b/vendor/rector/rector-phpunit/src/Set/PHPUnitLevelSetList.php index 79c21b7f163..e6b3642e690 100644 --- a/vendor/rector/rector-phpunit/src/Set/PHPUnitLevelSetList.php +++ b/vendor/rector/rector-phpunit/src/Set/PHPUnitLevelSetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\PHPUnit\Set; use Rector\Set\Contract\SetListInterface; -final class PHPUnitLevelSetList implements \Rector\Set\Contract\SetListInterface +final class PHPUnitLevelSetList implements SetListInterface { /** * @var string diff --git a/vendor/rector/rector-phpunit/src/Set/PHPUnitSetList.php b/vendor/rector/rector-phpunit/src/Set/PHPUnitSetList.php index d8935f7b85b..efb843a355d 100644 --- a/vendor/rector/rector-phpunit/src/Set/PHPUnitSetList.php +++ b/vendor/rector/rector-phpunit/src/Set/PHPUnitSetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\PHPUnit\Set; use Rector\Set\Contract\SetListInterface; -final class PHPUnitSetList implements \Rector\Set\Contract\SetListInterface +final class PHPUnitSetList implements SetListInterface { /** * @var string diff --git a/vendor/rector/rector-phpunit/src/ValueObject/ArrayArgumentToDataProvider.php b/vendor/rector/rector-phpunit/src/ValueObject/ArrayArgumentToDataProvider.php index b65b066b37e..9c0822f8fac 100644 --- a/vendor/rector/rector-phpunit/src/ValueObject/ArrayArgumentToDataProvider.php +++ b/vendor/rector/rector-phpunit/src/ValueObject/ArrayArgumentToDataProvider.php @@ -33,9 +33,9 @@ final class ArrayArgumentToDataProvider $this->newMethod = $newMethod; $this->variableName = $variableName; } - public function getObjectType() : \PHPStan\Type\ObjectType + public function getObjectType() : ObjectType { - return new \PHPStan\Type\ObjectType($this->class); + return new ObjectType($this->class); } public function getOldMethod() : string { diff --git a/vendor/rector/rector-phpunit/src/ValueObject/ParamAndArg.php b/vendor/rector/rector-phpunit/src/ValueObject/ParamAndArg.php index f3a54489ef2..65eafa2859c 100644 --- a/vendor/rector/rector-phpunit/src/ValueObject/ParamAndArg.php +++ b/vendor/rector/rector-phpunit/src/ValueObject/ParamAndArg.php @@ -17,16 +17,16 @@ final class ParamAndArg * @var \PHPStan\Type\Type|null */ private $type; - public function __construct(\PhpParser\Node\Expr\Variable $variable, ?\PHPStan\Type\Type $type) + public function __construct(Variable $variable, ?Type $type) { $this->variable = $variable; $this->type = $type; } - public function getVariable() : \PhpParser\Node\Expr\Variable + public function getVariable() : Variable { return $this->variable; } - public function getType() : ?\PHPStan\Type\Type + public function getType() : ?Type { return $this->type; } diff --git a/vendor/rector/rector-symfony/bin/parse-missing-return-types-to-rules.php b/vendor/rector/rector-symfony/bin/parse-missing-return-types-to-rules.php index 13e3cb87145..ce20f3731e0 100644 --- a/vendor/rector/rector-symfony/bin/parse-missing-return-types-to-rules.php +++ b/vendor/rector/rector-symfony/bin/parse-missing-return-types-to-rules.php @@ -27,7 +27,7 @@ final class MissingReturnTypeParser private $symfonyStyle; public function __construct() { - $symfonyStyleFactory = new \RectorPrefix20220607\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory(); + $symfonyStyleFactory = new SymfonyStyleFactory(); $this->symfonyStyle = $symfonyStyleFactory->create(); } public function run() : void @@ -46,16 +46,16 @@ final class MissingReturnTypeParser */ private function resolveDiffFileToReturnTypeChanges(string $fileDiffPath) : array { - $diffFileContent = \RectorPrefix20220607\Nette\Utils\FileSystem::read($fileDiffPath); + $diffFileContent = FileSystem::read($fileDiffPath); $fileDiffs = \explode('diff --git', $diffFileContent); $returnTypeChanges = []; foreach ($fileDiffs as $fileDiff) { - $matches = \RectorPrefix20220607\Nette\Utils\Strings::matchAll($fileDiff, self::DIFF_LINES_REGEX); + $matches = Strings::matchAll($fileDiff, self::DIFF_LINES_REGEX); if ($matches === []) { continue; } // match file name - $filenameMatch = \RectorPrefix20220607\Nette\Utils\Strings::match($matches[0]['before'], '# a/src/(?.*?).php$#'); + $filenameMatch = Strings::match($matches[0]['before'], '# a/src/(?.*?).php$#'); if ($filenameMatch === null) { continue; } @@ -63,14 +63,13 @@ final class MissingReturnTypeParser unset($matches[0]); foreach ($matches as $match) { // match method name - $methodNameMatch = \RectorPrefix20220607\Nette\Utils\Strings::match($match['before'], '#(?\\w+)\\(#'); - $newTypeMatch = \RectorPrefix20220607\Nette\Utils\Strings::match($match['after'], '#\\): (?.*?);?$#'); - $returnTypeChanges[] = new \Rector\Symfony\Utils\ValueObject\ReturnTypeChange($className, $methodNameMatch['method_name'], $newTypeMatch['return_type']); + $methodNameMatch = Strings::match($match['before'], '#(?\\w+)\\(#'); + $newTypeMatch = Strings::match($match['after'], '#\\): (?.*?);?$#'); + $returnTypeChanges[] = new ReturnTypeChange($className, $methodNameMatch['method_name'], $newTypeMatch['return_type']); } } return $returnTypeChanges; } } -\class_alias('MissingReturnTypeParser', 'MissingReturnTypeParser', \false); -$missingReturnTypeParser = new \RectorPrefix20220607\MissingReturnTypeParser(); +$missingReturnTypeParser = new MissingReturnTypeParser(); $missingReturnTypeParser->run(); diff --git a/vendor/rector/rector-symfony/config/config.php b/vendor/rector/rector-symfony/config/config.php index 44fde335187..f35df1f525d 100644 --- a/vendor/rector/rector-symfony/config/config.php +++ b/vendor/rector/rector-symfony/config/config.php @@ -6,10 +6,10 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Core\NonPhpFile\Rector\RenameClassNonPhpRector; use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $services = $rectorConfig->services(); $services->defaults()->public()->autowire()->autoconfigure(); $services->load('Rector\\Symfony\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/Rector', __DIR__ . '/../src/ValueObject']); - $rectorConfig->rule(\Rector\Core\NonPhpFile\Rector\RenameClassNonPhpRector::class); - $services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem::class); + $rectorConfig->rule(RenameClassNonPhpRector::class); + $services->set(SmartFileSystem::class); }; diff --git a/vendor/rector/rector-symfony/config/sets/jms/annotations-to-attributes.php b/vendor/rector/rector-symfony/config/sets/jms/annotations-to-attributes.php index 8ce3de31d52..c2fca60ebf0 100644 --- a/vendor/rector/rector-symfony/config/sets/jms/annotations-to-attributes.php +++ b/vendor/rector/rector-symfony/config/sets/jms/annotations-to-attributes.php @@ -11,6 +11,6 @@ use Rector\Php80\ValueObject\AnnotationToAttribute; * @see https://github.com/schmittjoh/serializer/pull/1332 * @see https://github.com/schmittjoh/serializer/pull/1337 */ -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class, [new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\Accessor'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\AccessorOrder'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\AccessType'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\Discriminator'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\Exclude'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\ExclusionPolicy'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\Expose'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\Groups'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\Inline'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\MaxDepth'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\PostDeserialize'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\PostSerialize'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\PreSerialize'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\ReadOnly'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\ReadOnlyProperty'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\SerializedName'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\Since'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\SkipWhenEmpty'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\Type'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\Until'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\VirtualProperty'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\XmlAttributeMap'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\XmlAttribute'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\XmlDiscriminator'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\XmlElement'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\XmlKeyValuePairs'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\XmlList'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\XmlMap'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\XmlNamespace'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\XmlRoot'), new \Rector\Php80\ValueObject\AnnotationToAttribute('JMS\\Serializer\\Annotation\\XmlValue')]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [new AnnotationToAttribute('JMS\\Serializer\\Annotation\\Accessor'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\AccessorOrder'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\AccessType'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\Discriminator'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\Exclude'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\ExclusionPolicy'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\Expose'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\Groups'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\Inline'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\MaxDepth'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\PostDeserialize'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\PostSerialize'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\PreSerialize'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\ReadOnly'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\ReadOnlyProperty'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\SerializedName'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\Since'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\SkipWhenEmpty'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\Type'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\Until'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\VirtualProperty'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\XmlAttributeMap'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\XmlAttribute'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\XmlDiscriminator'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\XmlElement'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\XmlKeyValuePairs'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\XmlList'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\XmlMap'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\XmlNamespace'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\XmlRoot'), new AnnotationToAttribute('JMS\\Serializer\\Annotation\\XmlValue')]); }; diff --git a/vendor/rector/rector-symfony/config/sets/jms/remove-jms-inject.php b/vendor/rector/rector-symfony/config/sets/jms/remove-jms-inject.php index 45054857df0..cccb958e5d4 100644 --- a/vendor/rector/rector-symfony/config/sets/jms/remove-jms-inject.php +++ b/vendor/rector/rector-symfony/config/sets/jms/remove-jms-inject.php @@ -5,6 +5,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Rector\Property\JMSInjectPropertyToConstructorInjectionRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Symfony\Rector\Property\JMSInjectPropertyToConstructorInjectionRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(JMSInjectPropertyToConstructorInjectionRector::class); }; diff --git a/vendor/rector/rector-symfony/config/sets/sensiolabs/framework-extra-61.php b/vendor/rector/rector-symfony/config/sets/sensiolabs/framework-extra-61.php index 849b068aa5f..d51807fbe35 100644 --- a/vendor/rector/rector-symfony/config/sets/sensiolabs/framework-extra-61.php +++ b/vendor/rector/rector-symfony/config/sets/sensiolabs/framework-extra-61.php @@ -6,7 +6,7 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; use Rector\Php80\ValueObject\AnnotationToAttribute; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { // @see https://github.com/sensiolabs/SensioFrameworkExtraBundle/pull/707 - $rectorConfig->ruleWithConfiguration(\Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class, [new \Rector\Php80\ValueObject\AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Cache'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Entity'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\IsGranted'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\ParamConverter'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Security'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Template')]); + $rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [new AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Cache'), new AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Entity'), new AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\IsGranted'), new AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\ParamConverter'), new AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Security'), new AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Template')]); }; diff --git a/vendor/rector/rector-symfony/config/sets/swiftmailer/swiftmailer-to-symfony-mailer.php b/vendor/rector/rector-symfony/config/sets/swiftmailer/swiftmailer-to-symfony-mailer.php index c29eae68586..f26c4919172 100644 --- a/vendor/rector/rector-symfony/config/sets/swiftmailer/swiftmailer-to-symfony-mailer.php +++ b/vendor/rector/rector-symfony/config/sets/swiftmailer/swiftmailer-to-symfony-mailer.php @@ -7,9 +7,9 @@ use Rector\Config\RectorConfig; use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Symfony\Rector\MethodCall\SwiftCreateMessageToNewEmailRector; // @see https://symfony.com/blog/the-end-of-swiftmailer -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Symfony\Rector\MethodCall\SwiftCreateMessageToNewEmailRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(SwiftCreateMessageToNewEmailRector::class); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ 'Swift_Mailer' => 'Symfony\\Component\\Mailer\\MailerInterface', 'Swift_Message' => 'Symfony\\Component\\Mime\\Email', // message diff --git a/vendor/rector/rector-symfony/config/sets/swiftmailer/swiftmailer60.php b/vendor/rector/rector-symfony/config/sets/swiftmailer/swiftmailer60.php index 4358ec033d3..b5925dac9f3 100644 --- a/vendor/rector/rector-symfony/config/sets/swiftmailer/swiftmailer60.php +++ b/vendor/rector/rector-symfony/config/sets/swiftmailer/swiftmailer60.php @@ -5,8 +5,8 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Renaming\Rector\Name\RenameClassRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ # swiftmailer 60 'Swift_Mime_Message' => 'Swift_Mime_SimpleMessage', ]); diff --git a/vendor/rector/rector-symfony/config/sets/symfony/annotations-to-attributes.php b/vendor/rector/rector-symfony/config/sets/symfony/annotations-to-attributes.php index d2f9a4b7db8..7b22934f382 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/annotations-to-attributes.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/annotations-to-attributes.php @@ -8,13 +8,13 @@ use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; use Rector\Php80\ValueObject\AnnotationToAttribute; use Rector\Symfony\Set\SymfonySetList; // @see https://symfony.com/blog/new-in-symfony-5-2-constraints-as-php-attributes -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::SYMFONY_52_VALIDATOR_ATTRIBUTES]); - $rectorConfig->ruleWithConfiguration(\Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::SYMFONY_52_VALIDATOR_ATTRIBUTES]); + $rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [ // @see https://symfony.com/blog/new-in-symfony-5-2-php-8-attributes - new \Rector\Php80\ValueObject\AnnotationToAttribute('required', 'Symfony\\Contracts\\Service\\Attribute\\Required'), - new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Routing\\Annotation\\Route'), + new AnnotationToAttribute('required', 'Symfony\\Contracts\\Service\\Attribute\\Required'), + new AnnotationToAttribute('Symfony\\Component\\Routing\\Annotation\\Route'), // see Symfony 5.2+ https://github.com/symfony/doctrine-bridge/commit/02d2cf4743331e6b69ffd1d68e09b7e2dc417201#diff-1a16e2739e51eab000116d0542bd0226cea59a6d64711740ed7ce14769f95d1b - new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Bridge\\Doctrine\\Validator\\Constraints\\UniqueEntity'), + new AnnotationToAttribute('Symfony\\Bridge\\Doctrine\\Validator\\Constraints\\UniqueEntity'), ]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-26.php b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-26.php index 1c1d261f221..b9e102393c7 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-26.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-26.php @@ -5,6 +5,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Set\SymfonySetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::SYMFONY_26]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::SYMFONY_26]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-28.php b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-28.php index 42ca7bb8220..00451fd0fea 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-28.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-28.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Set\SymfonyLevelSetList; use Rector\Symfony\Set\SymfonySetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::SYMFONY_28, \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_26]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::SYMFONY_28, SymfonyLevelSetList::UP_TO_SYMFONY_26]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-30.php b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-30.php index 7a20442b89b..0f19f2a84de 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-30.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-30.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Set\SymfonyLevelSetList; use Rector\Symfony\Set\SymfonySetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::SYMFONY_30, \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_28]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::SYMFONY_30, SymfonyLevelSetList::UP_TO_SYMFONY_28]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-31.php b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-31.php index 79030065e31..0ec1199ada2 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-31.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-31.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Set\SymfonyLevelSetList; use Rector\Symfony\Set\SymfonySetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::SYMFONY_31, \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_30]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::SYMFONY_31, SymfonyLevelSetList::UP_TO_SYMFONY_30]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-32.php b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-32.php index 4e13ec5fe5b..632022a2058 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-32.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-32.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Set\SymfonyLevelSetList; use Rector\Symfony\Set\SymfonySetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::SYMFONY_32, \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_31]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::SYMFONY_32, SymfonyLevelSetList::UP_TO_SYMFONY_31]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-33.php b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-33.php index 4af6079c5ac..033a8201a52 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-33.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-33.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Set\SymfonyLevelSetList; use Rector\Symfony\Set\SymfonySetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::SYMFONY_33, \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_32]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::SYMFONY_33, SymfonyLevelSetList::UP_TO_SYMFONY_32]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-34.php b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-34.php index 4b8789429b8..00dfbc5ed52 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-34.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-34.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Set\SymfonyLevelSetList; use Rector\Symfony\Set\SymfonySetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::SYMFONY_34, \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_33]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::SYMFONY_34, SymfonyLevelSetList::UP_TO_SYMFONY_33]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-40.php b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-40.php index d7f4f377023..7d840ecf756 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-40.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-40.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Set\SymfonyLevelSetList; use Rector\Symfony\Set\SymfonySetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::SYMFONY_40, \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_34]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::SYMFONY_40, SymfonyLevelSetList::UP_TO_SYMFONY_34]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-41.php b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-41.php index 663e6f90b2a..d71664bf398 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-41.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-41.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Set\SymfonyLevelSetList; use Rector\Symfony\Set\SymfonySetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::SYMFONY_41, \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_40]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::SYMFONY_41, SymfonyLevelSetList::UP_TO_SYMFONY_40]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-42.php b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-42.php index 54b9445c7ef..3a05dc17e71 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-42.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-42.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Set\SymfonyLevelSetList; use Rector\Symfony\Set\SymfonySetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::SYMFONY_42, \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_41]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::SYMFONY_42, SymfonyLevelSetList::UP_TO_SYMFONY_41]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-43.php b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-43.php index 79b05c252c6..a4e3e165751 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-43.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-43.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Set\SymfonyLevelSetList; use Rector\Symfony\Set\SymfonySetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::SYMFONY_43, \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_42]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::SYMFONY_43, SymfonyLevelSetList::UP_TO_SYMFONY_42]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-44.php b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-44.php index 9d532ec30f8..0ca98223201 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-44.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-44.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Set\SymfonyLevelSetList; use Rector\Symfony\Set\SymfonySetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::SYMFONY_44, \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_43]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::SYMFONY_44, SymfonyLevelSetList::UP_TO_SYMFONY_43]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-50.php b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-50.php index 0d7bc804fe1..d4c59601ab0 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-50.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-50.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Set\SymfonyLevelSetList; use Rector\Symfony\Set\SymfonySetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::SYMFONY_50, \Rector\Symfony\Set\SymfonySetList::SYMFONY_50_TYPES, \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_44]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::SYMFONY_50, SymfonySetList::SYMFONY_50_TYPES, SymfonyLevelSetList::UP_TO_SYMFONY_44]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-51.php b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-51.php index c115e8b16d0..e987a2e4147 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-51.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-51.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Set\SymfonyLevelSetList; use Rector\Symfony\Set\SymfonySetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::SYMFONY_51, \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_50]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::SYMFONY_51, SymfonyLevelSetList::UP_TO_SYMFONY_50]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-52.php b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-52.php index cf7a1a3b4e0..b8c46f4b4b1 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-52.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-52.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Set\SymfonyLevelSetList; use Rector\Symfony\Set\SymfonySetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::SYMFONY_52, \Rector\Symfony\Set\SymfonySetList::SYMFONY_52_VALIDATOR_ATTRIBUTES, \Rector\Symfony\Set\SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES, \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_51]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::SYMFONY_52, SymfonySetList::SYMFONY_52_VALIDATOR_ATTRIBUTES, SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES, SymfonyLevelSetList::UP_TO_SYMFONY_51]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-53.php b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-53.php index 7ff5a78263e..66f0891b6a8 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-53.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-53.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Set\SymfonyLevelSetList; use Rector\Symfony\Set\SymfonySetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::SYMFONY_53, \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_52]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::SYMFONY_53, SymfonyLevelSetList::UP_TO_SYMFONY_52]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-54.php b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-54.php index 801491843a4..1d70383a3e2 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-54.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-54.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Set\SymfonyLevelSetList; use Rector\Symfony\Set\SymfonySetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::SYMFONY_54, \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_53]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::SYMFONY_54, SymfonyLevelSetList::UP_TO_SYMFONY_53]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-60.php b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-60.php index fee796dc5d5..bd8e6e3883c 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-60.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/level/up-to-symfony-60.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Set\SymfonyLevelSetList; use Rector\Symfony\Set\SymfonySetList; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::SYMFONY_60, \Rector\Symfony\Set\SymfonyLevelSetList::UP_TO_SYMFONY_54]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::SYMFONY_60, SymfonyLevelSetList::UP_TO_SYMFONY_54]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony-code-quality.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony-code-quality.php index 4ff7e38ec3a..ed931ac19f1 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony-code-quality.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony-code-quality.php @@ -9,13 +9,13 @@ use Rector\Symfony\Rector\Class_\EventListenerToEventSubscriberRector; use Rector\Symfony\Rector\Class_\MakeCommandLazyRector; use Rector\Symfony\Rector\ClassMethod\ResponseReturnTypeControllerActionRector; use Rector\Symfony\Rector\MethodCall\LiteralGetToRequestClassConstantRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $rectorConfig->rules([ - \Rector\Symfony\Rector\Class_\MakeCommandLazyRector::class, - \Rector\Symfony\Rector\Class_\EventListenerToEventSubscriberRector::class, - \Rector\Symfony\Rector\ClassMethod\ResponseReturnTypeControllerActionRector::class, + MakeCommandLazyRector::class, + EventListenerToEventSubscriberRector::class, + ResponseReturnTypeControllerActionRector::class, // int and string literals to const fetches - \Rector\Symfony\Rector\BinaryOp\ResponseStatusCodeRector::class, - \Rector\Symfony\Rector\MethodCall\LiteralGetToRequestClassConstantRector::class, + ResponseStatusCodeRector::class, + LiteralGetToRequestClassConstantRector::class, ]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony-constructor-injection.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony-constructor-injection.php index 3a0d8b53ea5..6de8245f31e 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony-constructor-injection.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony-constructor-injection.php @@ -7,8 +7,8 @@ use Rector\Config\RectorConfig; use Rector\Symfony\Rector\MethodCall\ContainerGetToConstructorInjectionRector; use Rector\Symfony\Rector\MethodCall\GetParameterToConstructorInjectionRector; use Rector\Symfony\Rector\MethodCall\GetToConstructorInjectionRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Symfony\Rector\MethodCall\ContainerGetToConstructorInjectionRector::class); - $rectorConfig->rule(\Rector\Symfony\Rector\MethodCall\GetParameterToConstructorInjectionRector::class); - $rectorConfig->rule(\Rector\Symfony\Rector\MethodCall\GetToConstructorInjectionRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(ContainerGetToConstructorInjectionRector::class); + $rectorConfig->rule(GetParameterToConstructorInjectionRector::class); + $rectorConfig->rule(GetToConstructorInjectionRector::class); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony-strict.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony-strict.php index 9f88fa418d1..0af9e9508d4 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony-strict.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony-strict.php @@ -5,6 +5,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Rector\ClassMethod\RenderMethodParamToTypeDeclarationRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Symfony\Rector\ClassMethod\RenderMethodParamToTypeDeclarationRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(RenderMethodParamToTypeDeclarationRector::class); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony26.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony26.php index 1f48ad40261..216a95555af 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony26.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony26.php @@ -5,6 +5,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Rector\MethodCall\RedirectToRouteRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Symfony\Rector\MethodCall\RedirectToRouteRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(RedirectToRouteRector::class); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony28.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony28.php index 1b28167994b..345ca359bec 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony28.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony28.php @@ -7,13 +7,13 @@ use Rector\Arguments\Rector\ClassMethod\ReplaceArgumentDefaultValueRector; use Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue; use Rector\Config\RectorConfig; use Rector\Symfony\Rector\StaticCall\ParseFileRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Symfony\Rector\StaticCall\ParseFileRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\ClassMethod\ReplaceArgumentDefaultValueRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(ParseFileRector::class); + $rectorConfig->ruleWithConfiguration(ReplaceArgumentDefaultValueRector::class, [ // https://github.com/symfony/symfony/commit/912fc4de8fd6de1e5397be4a94d39091423e5188 - new \Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface', 'generate', 2, \true, 'Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface::ABSOLUTE_URL'), - new \Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface', 'generate', 2, \false, 'Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface::ABSOLUTE_PATH'), - new \Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface', 'generate', 2, 'relative', 'Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface::RELATIVE_PATH'), - new \Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface', 'generate', 2, 'network', 'Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface::NETWORK_PATH'), + new ReplaceArgumentDefaultValue('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface', 'generate', 2, \true, 'Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface::ABSOLUTE_URL'), + new ReplaceArgumentDefaultValue('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface', 'generate', 2, \false, 'Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface::ABSOLUTE_PATH'), + new ReplaceArgumentDefaultValue('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface', 'generate', 2, 'relative', 'Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface::RELATIVE_PATH'), + new ReplaceArgumentDefaultValue('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface', 'generate', 2, 'network', 'Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface::NETWORK_PATH'), ]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony30.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony30.php index f125d194dfa..e99496b1729 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony30.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony30.php @@ -20,72 +20,72 @@ use Rector\Symfony\Rector\MethodCall\FormTypeInstanceToClassConstRector; use Rector\Symfony\Rector\MethodCall\OptionNameRector; use Rector\Symfony\Rector\MethodCall\ReadOnlyOptionToAttributeRector; use Rector\Symfony\Rector\MethodCall\StringFormTypeToClassRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { # resources: # - https://github.com/symfony/symfony/blob/3.4/UPGRADE-3.0.md $rectorConfig->rules([ // php - \Rector\Symfony\Rector\ClassMethod\GetRequestRector::class, - \Rector\Symfony\Rector\ClassMethod\FormTypeGetParentRector::class, - \Rector\Symfony\Rector\MethodCall\OptionNameRector::class, - \Rector\Symfony\Rector\MethodCall\ReadOnlyOptionToAttributeRector::class, + GetRequestRector::class, + FormTypeGetParentRector::class, + OptionNameRector::class, + ReadOnlyOptionToAttributeRector::class, // forms - \Rector\Symfony\Rector\MethodCall\FormTypeInstanceToClassConstRector::class, - \Rector\Symfony\Rector\Class_\FormTypeWithDependencyToOptionsRector::class, - \Rector\Symfony\Rector\MethodCall\StringFormTypeToClassRector::class, - \Rector\Symfony\Rector\MethodCall\CascadeValidationFormBuilderRector::class, - \Rector\Symfony\Rector\ClassMethod\RemoveDefaultGetBlockPrefixRector::class, + FormTypeInstanceToClassConstRector::class, + FormTypeWithDependencyToOptionsRector::class, + StringFormTypeToClassRector::class, + CascadeValidationFormBuilderRector::class, + RemoveDefaultGetBlockPrefixRector::class, // forms - collection - \Rector\Symfony\Rector\MethodCall\ChangeStringCollectionOptionToConstantRector::class, - \Rector\Symfony\Rector\MethodCall\ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector::class, + ChangeStringCollectionOptionToConstantRector::class, + ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector::class, ]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector::class, [new \Rector\Renaming\ValueObject\RenameClassConstFetch('Symfony\\Component\\Form\\FormEvents', 'PRE_BIND', 'PRE_SUBMIT'), new \Rector\Renaming\ValueObject\RenameClassConstFetch('Symfony\\Component\\Form\\FormEvents', 'BIND', 'SUBMIT'), new \Rector\Renaming\ValueObject\RenameClassConstFetch('Symfony\\Component\\Form\\FormEvents', 'POST_BIND', 'POST_SUBMIT'), new \Rector\Renaming\ValueObject\RenameClassConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer', 'ROUND_HALFEVEN', 'ROUND_HALF_EVEN'), new \Rector\Renaming\ValueObject\RenameClassConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer', 'ROUND_HALFUP', 'ROUND_HALF_UP'), new \Rector\Renaming\ValueObject\RenameClassConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer', 'ROUND_HALFDOWN', 'ROUND_HALF_DOWN')]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [ - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\ClassLoader\\UniversalClassLoader\\UniversalClassLoader', 'registerNamespaces', 'addPrefixes'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\ClassLoader\\UniversalClassLoader\\UniversalClassLoader', 'registerPrefixes', 'addPrefixes'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\ClassLoader\\UniversalClassLoader\\UniversalClassLoader', 'registerNamespace', 'addPrefix'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\ClassLoader\\UniversalClassLoader\\UniversalClassLoader', 'registerPrefix', 'addPrefix'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\ClassLoader\\UniversalClassLoader\\UniversalClassLoader', 'getNamespaces', 'getPrefixes'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\ClassLoader\\UniversalClassLoader\\UniversalClassLoader', 'getNamespaceFallbacks', 'getFallbackDirs'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\ClassLoader\\UniversalClassLoader\\UniversalClassLoader', 'getPrefixFallbacks', 'getFallbackDirs'), + $rectorConfig->ruleWithConfiguration(RenameClassConstFetchRector::class, [new RenameClassConstFetch('Symfony\\Component\\Form\\FormEvents', 'PRE_BIND', 'PRE_SUBMIT'), new RenameClassConstFetch('Symfony\\Component\\Form\\FormEvents', 'BIND', 'SUBMIT'), new RenameClassConstFetch('Symfony\\Component\\Form\\FormEvents', 'POST_BIND', 'POST_SUBMIT'), new RenameClassConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer', 'ROUND_HALFEVEN', 'ROUND_HALF_EVEN'), new RenameClassConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer', 'ROUND_HALFUP', 'ROUND_HALF_UP'), new RenameClassConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer', 'ROUND_HALFDOWN', 'ROUND_HALF_DOWN')]); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ + new MethodCallRename('Symfony\\Component\\ClassLoader\\UniversalClassLoader\\UniversalClassLoader', 'registerNamespaces', 'addPrefixes'), + new MethodCallRename('Symfony\\Component\\ClassLoader\\UniversalClassLoader\\UniversalClassLoader', 'registerPrefixes', 'addPrefixes'), + new MethodCallRename('Symfony\\Component\\ClassLoader\\UniversalClassLoader\\UniversalClassLoader', 'registerNamespace', 'addPrefix'), + new MethodCallRename('Symfony\\Component\\ClassLoader\\UniversalClassLoader\\UniversalClassLoader', 'registerPrefix', 'addPrefix'), + new MethodCallRename('Symfony\\Component\\ClassLoader\\UniversalClassLoader\\UniversalClassLoader', 'getNamespaces', 'getPrefixes'), + new MethodCallRename('Symfony\\Component\\ClassLoader\\UniversalClassLoader\\UniversalClassLoader', 'getNamespaceFallbacks', 'getFallbackDirs'), + new MethodCallRename('Symfony\\Component\\ClassLoader\\UniversalClassLoader\\UniversalClassLoader', 'getPrefixFallbacks', 'getFallbackDirs'), // form - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Form\\AbstractType', 'getName', 'getBlockPrefix'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Form\\AbstractType', 'setDefaultOptions', 'configureOptions'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Form\\FormTypeInterface', 'getName', 'getBlockPrefix'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Form\\FormTypeInterface', 'setDefaultOptions', 'configureOptions'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Form\\ResolvedFormTypeInterface', 'getName', 'getBlockPrefix'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Form\\AbstractTypeExtension', 'setDefaultOptions', 'configureOptions'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Form\\Form', 'bind', 'submit'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Form\\Form', 'isBound', 'isSubmitted'), + new MethodCallRename('Symfony\\Component\\Form\\AbstractType', 'getName', 'getBlockPrefix'), + new MethodCallRename('Symfony\\Component\\Form\\AbstractType', 'setDefaultOptions', 'configureOptions'), + new MethodCallRename('Symfony\\Component\\Form\\FormTypeInterface', 'getName', 'getBlockPrefix'), + new MethodCallRename('Symfony\\Component\\Form\\FormTypeInterface', 'setDefaultOptions', 'configureOptions'), + new MethodCallRename('Symfony\\Component\\Form\\ResolvedFormTypeInterface', 'getName', 'getBlockPrefix'), + new MethodCallRename('Symfony\\Component\\Form\\AbstractTypeExtension', 'setDefaultOptions', 'configureOptions'), + new MethodCallRename('Symfony\\Component\\Form\\Form', 'bind', 'submit'), + new MethodCallRename('Symfony\\Component\\Form\\Form', 'isBound', 'isSubmitted'), // process - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Process\\Process', 'setStdin', 'setInput'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Process\\Process', 'getStdin', 'getInput'), + new MethodCallRename('Symfony\\Component\\Process\\Process', 'setStdin', 'setInput'), + new MethodCallRename('Symfony\\Component\\Process\\Process', 'getStdin', 'getInput'), // monolog - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Bridge\\Monolog\\Logger', 'emerg', 'emergency'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Bridge\\Monolog\\Logger', 'crit', 'critical'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Bridge\\Monolog\\Logger', 'err', 'error'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Bridge\\Monolog\\Logger', 'warn', 'warning'), + new MethodCallRename('Symfony\\Bridge\\Monolog\\Logger', 'emerg', 'emergency'), + new MethodCallRename('Symfony\\Bridge\\Monolog\\Logger', 'crit', 'critical'), + new MethodCallRename('Symfony\\Bridge\\Monolog\\Logger', 'err', 'error'), + new MethodCallRename('Symfony\\Bridge\\Monolog\\Logger', 'warn', 'warning'), # http kernel - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\HttpKernel\\Log\\LoggerInterface', 'emerg', 'emergency'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\HttpKernel\\Log\\LoggerInterface', 'crit', 'critical'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\HttpKernel\\Log\\LoggerInterface', 'err', 'error'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\HttpKernel\\Log\\LoggerInterface', 'warn', 'warning'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\HttpKernel\\Log\\NullLogger', 'emerg', 'emergency'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\HttpKernel\\Log\\NullLogger', 'crit', 'critical'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\HttpKernel\\Log\\NullLogger', 'err', 'error'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\HttpKernel\\Log\\NullLogger', 'warn', 'warning'), + new MethodCallRename('Symfony\\Component\\HttpKernel\\Log\\LoggerInterface', 'emerg', 'emergency'), + new MethodCallRename('Symfony\\Component\\HttpKernel\\Log\\LoggerInterface', 'crit', 'critical'), + new MethodCallRename('Symfony\\Component\\HttpKernel\\Log\\LoggerInterface', 'err', 'error'), + new MethodCallRename('Symfony\\Component\\HttpKernel\\Log\\LoggerInterface', 'warn', 'warning'), + new MethodCallRename('Symfony\\Component\\HttpKernel\\Log\\NullLogger', 'emerg', 'emergency'), + new MethodCallRename('Symfony\\Component\\HttpKernel\\Log\\NullLogger', 'crit', 'critical'), + new MethodCallRename('Symfony\\Component\\HttpKernel\\Log\\NullLogger', 'err', 'error'), + new MethodCallRename('Symfony\\Component\\HttpKernel\\Log\\NullLogger', 'warn', 'warning'), // property access - new \Rector\Renaming\ValueObject\MethodCallRename('getPropertyAccessor', 'Symfony\\Component\\PropertyAccess\\PropertyAccess', 'createPropertyAccessor'), + new MethodCallRename('getPropertyAccessor', 'Symfony\\Component\\PropertyAccess\\PropertyAccess', 'createPropertyAccessor'), // translator - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Translation\\Dumper\\FileDumper', 'format', 'formatCatalogue'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Translation\\Translator', 'getMessages', 'getCatalogue'), + new MethodCallRename('Symfony\\Component\\Translation\\Dumper\\FileDumper', 'format', 'formatCatalogue'), + new MethodCallRename('Symfony\\Component\\Translation\\Translator', 'getMessages', 'getCatalogue'), // validator - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Validator\\ConstraintViolationInterface', 'getMessageParameters', 'getParameters'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Validator\\ConstraintViolationInterface', 'getMessagePluralization', 'getPlural'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Validator\\ConstraintViolation', 'getMessageParameters', 'getParameters'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Validator\\ConstraintViolation', 'getMessagePluralization', 'getPlural'), + new MethodCallRename('Symfony\\Component\\Validator\\ConstraintViolationInterface', 'getMessageParameters', 'getParameters'), + new MethodCallRename('Symfony\\Component\\Validator\\ConstraintViolationInterface', 'getMessagePluralization', 'getPlural'), + new MethodCallRename('Symfony\\Component\\Validator\\ConstraintViolation', 'getMessageParameters', 'getParameters'), + new MethodCallRename('Symfony\\Component\\Validator\\ConstraintViolation', 'getMessagePluralization', 'getPlural'), ]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, [ + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ # class loader # partial with method rename 'Symfony\\Component\\ClassLoader\\UniversalClassLoader\\UniversalClassLoader' => 'Symfony\\Component\\ClassLoader\\ClassLoader', diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony31.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony31.php index 0f283931fac..a7865010fd1 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony31.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony31.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Arguments\Rector\ClassMethod\ReplaceArgumentDefaultValueRector; use Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\ClassMethod\ReplaceArgumentDefaultValueRector::class, [new \Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue('Symfony\\Component\\Yaml\\Yaml', 'parse', 1, [\false, \false, \true], 'Symfony\\Component\\Yaml\\Yaml::PARSE_OBJECT_FOR_MAP'), new \Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue('Symfony\\Component\\Yaml\\Yaml', 'parse', 1, [\false, \true], 'Symfony\\Component\\Yaml\\Yaml::PARSE_OBJECT'), new \Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue('Symfony\\Component\\Yaml\\Yaml', 'parse', 1, \true, 'Symfony\\Component\\Yaml\\Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE'), new \Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue('Symfony\\Component\\Yaml\\Yaml', 'parse', 1, \false, 0), new \Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue('Symfony\\Component\\Yaml\\Yaml', 'dump', 3, [\false, \true], 'Symfony\\Component\\Yaml\\Yaml::DUMP_OBJECT'), new \Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue('Symfony\\Component\\Yaml\\Yaml', 'dump', 3, \true, 'Symfony\\Component\\Yaml\\Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE')]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(ReplaceArgumentDefaultValueRector::class, [new ReplaceArgumentDefaultValue('Symfony\\Component\\Yaml\\Yaml', 'parse', 1, [\false, \false, \true], 'Symfony\\Component\\Yaml\\Yaml::PARSE_OBJECT_FOR_MAP'), new ReplaceArgumentDefaultValue('Symfony\\Component\\Yaml\\Yaml', 'parse', 1, [\false, \true], 'Symfony\\Component\\Yaml\\Yaml::PARSE_OBJECT'), new ReplaceArgumentDefaultValue('Symfony\\Component\\Yaml\\Yaml', 'parse', 1, \true, 'Symfony\\Component\\Yaml\\Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE'), new ReplaceArgumentDefaultValue('Symfony\\Component\\Yaml\\Yaml', 'parse', 1, \false, 0), new ReplaceArgumentDefaultValue('Symfony\\Component\\Yaml\\Yaml', 'dump', 3, [\false, \true], 'Symfony\\Component\\Yaml\\Yaml::DUMP_OBJECT'), new ReplaceArgumentDefaultValue('Symfony\\Component\\Yaml\\Yaml', 'dump', 3, \true, 'Symfony\\Component\\Yaml\\Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE')]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony32.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony32.php index 55174c741b4..9daf54c25e3 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony32.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony32.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector; use Rector\Arguments\ValueObject\ArgumentAdder; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class, [new \Rector\Arguments\ValueObject\ArgumentAdder('Symfony\\Component\\DependencyInjection\\ContainerBuilder', 'addCompilerPass', 2, 'priority', 0)]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(ArgumentAdderRector::class, [new ArgumentAdder('Symfony\\Component\\DependencyInjection\\ContainerBuilder', 'addCompilerPass', 2, 'priority', 0)]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony33.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony33.php index 86b54e850db..8856e6ab985 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony33.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony33.php @@ -10,10 +10,10 @@ use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Renaming\ValueObject\MethodCallRename; use Rector\Symfony\Rector\ClassConstFetch\ConsoleExceptionToErrorEventConstantRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class, [new \Rector\Arguments\ValueObject\ArgumentAdder('Symfony\\Component\\DependencyInjection\\ContainerBuilder', 'compile', 2, '__unknown__', 0), new \Rector\Arguments\ValueObject\ArgumentAdder('Symfony\\Component\\DependencyInjection\\ContainerBuilder', 'addCompilerPass', 2, 'priority', 0), new \Rector\Arguments\ValueObject\ArgumentAdder('Symfony\\Component\\DependencyInjection\\Compiler\\ServiceReferenceGraph', 'connect', 6, 'weak', \false)]); - $rectorConfig->rule(\Rector\Symfony\Rector\ClassConstFetch\ConsoleExceptionToErrorEventConstantRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(ArgumentAdderRector::class, [new ArgumentAdder('Symfony\\Component\\DependencyInjection\\ContainerBuilder', 'compile', 2, '__unknown__', 0), new ArgumentAdder('Symfony\\Component\\DependencyInjection\\ContainerBuilder', 'addCompilerPass', 2, 'priority', 0), new ArgumentAdder('Symfony\\Component\\DependencyInjection\\Compiler\\ServiceReferenceGraph', 'connect', 6, 'weak', \false)]); + $rectorConfig->rule(ConsoleExceptionToErrorEventConstantRector::class); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ # console 'Symfony\\Component\\Console\\Event\\ConsoleExceptionEvent' => 'Symfony\\Component\\Console\\Event\\ConsoleErrorEvent', # debug @@ -29,5 +29,5 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { 'Symfony\\Bundle\\FrameworkBundle\\DependencyInjection\\Compiler\\ConfigCachePass' => 'Symfony\\Component\\Config\\DependencyInjection\\ConfigCachePass', 'Symfony\\Bundle\\FrameworkBundle\\DependencyInjection\\Compiler\\PropertyInfoPass' => 'Symfony\\Component\\PropertyInfo\\DependencyInjection\\PropertyInfoPass', ]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\DependencyInjection\\Container', 'isFrozen', 'isCompiled')]); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Symfony\\Component\\DependencyInjection\\Container', 'isFrozen', 'isCompiled')]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony34.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony34.php index 1856f069d8d..4111b7d0769 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony34.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony34.php @@ -7,7 +7,7 @@ use Rector\Config\RectorConfig; use Rector\Removing\Rector\ClassMethod\ArgumentRemoverRector; use Rector\Removing\ValueObject\ArgumentRemover; use Rector\Symfony\Rector\ClassMethod\MergeMethodAnnotationToRouteAnnotationRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Removing\Rector\ClassMethod\ArgumentRemoverRector::class, [new \Rector\Removing\ValueObject\ArgumentRemover('Symfony\\Component\\Yaml\\Yaml', 'parse', 2, ['Symfony\\Component\\Yaml\\Yaml::PARSE_KEYS_AS_STRINGS'])]); - $rectorConfig->rule(\Rector\Symfony\Rector\ClassMethod\MergeMethodAnnotationToRouteAnnotationRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(ArgumentRemoverRector::class, [new ArgumentRemover('Symfony\\Component\\Yaml\\Yaml', 'parse', 2, ['Symfony\\Component\\Yaml\\Yaml::PARSE_KEYS_AS_STRINGS'])]); + $rectorConfig->rule(MergeMethodAnnotationToRouteAnnotationRector::class); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony40.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony40.php index 9227bd95b17..5c89dfa6b07 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony40.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony40.php @@ -11,12 +11,12 @@ use Rector\Symfony\Rector\MethodCall\FormIsValidRector; use Rector\Symfony\Rector\MethodCall\ProcessBuilderGetProcessRector; use Rector\Symfony\Rector\MethodCall\VarDumperTestTraitMethodArgsRector; use Rector\Symfony\Rector\StaticCall\ProcessBuilderInstanceRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Symfony\Rector\ConstFetch\ConstraintUrlOptionRector::class); - $rectorConfig->rule(\Rector\Symfony\Rector\MethodCall\FormIsValidRector::class); - $rectorConfig->rule(\Rector\Symfony\Rector\MethodCall\VarDumperTestTraitMethodArgsRector::class); - $rectorConfig->rule(\Rector\Symfony\Rector\MethodCall\ContainerBuilderCompileEnvArgumentRector::class); - $rectorConfig->rule(\Rector\Symfony\Rector\StaticCall\ProcessBuilderInstanceRector::class); - $rectorConfig->rule(\Rector\Symfony\Rector\MethodCall\ProcessBuilderGetProcessRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Symfony\\Component\\Validator\\Tests\\Constraints\\AbstractConstraintValidatorTest' => 'Symfony\\Component\\Validator\\Test\\ConstraintValidatorTestCase', 'Symfony\\Component\\Process\\ProcessBuilder' => 'Symfony\\Component\\Process\\Process']); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(ConstraintUrlOptionRector::class); + $rectorConfig->rule(FormIsValidRector::class); + $rectorConfig->rule(VarDumperTestTraitMethodArgsRector::class); + $rectorConfig->rule(ContainerBuilderCompileEnvArgumentRector::class); + $rectorConfig->rule(ProcessBuilderInstanceRector::class); + $rectorConfig->rule(ProcessBuilderGetProcessRector::class); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Symfony\\Component\\Validator\\Tests\\Constraints\\AbstractConstraintValidatorTest' => 'Symfony\\Component\\Validator\\Test\\ConstraintValidatorTestCase', 'Symfony\\Component\\Process\\ProcessBuilder' => 'Symfony\\Component\\Process\\Process']); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony41.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony41.php index 83500b71337..25b5d728850 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony41.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony41.php @@ -9,19 +9,19 @@ use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Renaming\ValueObject\MethodCallRename; use Rector\Renaming\ValueObject\MethodCallRenameWithArrayKey; # https://github.com/symfony/symfony/blob/master/UPGRADE-4.1.md -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ # https://github.com/symfony/symfony/commit/463f986c28a497571967e37c1314e9911f1ef6ba - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Console\\Helper\\TableStyle', 'setHorizontalBorderChar', 'setHorizontalBorderChars'), + new MethodCallRename('Symfony\\Component\\Console\\Helper\\TableStyle', 'setHorizontalBorderChar', 'setHorizontalBorderChars'), # https://github.com/symfony/symfony/commit/463f986c28a497571967e37c1314e9911f1ef6ba - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Console\\Helper\\TableStyle', 'setVerticalBorderChar', 'setVerticalBorderChars'), + new MethodCallRename('Symfony\\Component\\Console\\Helper\\TableStyle', 'setVerticalBorderChar', 'setVerticalBorderChars'), # https://github.com/symfony/symfony/commit/463f986c28a497571967e37c1314e9911f1ef6ba - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Console\\Helper\\TableStyle', 'setCrossingChar', 'setDefaultCrossingChar'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\HttpFoundation\\File\\UploadedFile', 'getClientSize', 'getSize'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Workflow\\DefinitionBuilder', 'reset', 'clear'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Workflow\\DefinitionBuilder', 'add', 'addWorkflow'), + new MethodCallRename('Symfony\\Component\\Console\\Helper\\TableStyle', 'setCrossingChar', 'setDefaultCrossingChar'), + new MethodCallRename('Symfony\\Component\\HttpFoundation\\File\\UploadedFile', 'getClientSize', 'getSize'), + new MethodCallRename('Symfony\\Component\\Workflow\\DefinitionBuilder', 'reset', 'clear'), + new MethodCallRename('Symfony\\Component\\Workflow\\DefinitionBuilder', 'add', 'addWorkflow'), # https://github.com/symfony/symfony/commit/463f986c28a497571967e37c1314e9911f1ef6ba - new \Rector\Renaming\ValueObject\MethodCallRenameWithArrayKey( + new MethodCallRenameWithArrayKey( 'Symfony\\Component\\Console\\Helper\\TableStyle', 'getVerticalBorderChar', # special case to "getVerticalBorderChar" → "getBorderChars()[3]" @@ -29,9 +29,9 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { 3 ), # https://github.com/symfony/symfony/commit/463f986c28a497571967e37c1314e9911f1ef6ba - new \Rector\Renaming\ValueObject\MethodCallRenameWithArrayKey('Symfony\\Component\\Console\\Helper\\TableStyle', 'getHorizontalBorderChar', 'getBorderChars', 2), + new MethodCallRenameWithArrayKey('Symfony\\Component\\Console\\Helper\\TableStyle', 'getHorizontalBorderChar', 'getBorderChars', 2), ]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, [ + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ # https://github.com/symfony/symfony/commit/07dd09db59e2f2a86a291d00d978169d9059e307 'Symfony\\Bundle\\FrameworkBundle\\DataCollector\\RequestDataCollector' => 'Symfony\\Component\\HttpKernel\\DataCollector\\RequestDataCollector', 'Symfony\\Component\\Workflow\\SupportStrategy\\SupportStrategyInterface' => 'Symfony\\Component\\Workflow\\SupportStrategy\\WorkflowSupportStrategyInterface', diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony42.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony42.php index 8eb6c3011c9..036f3b1fa1d 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony42.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony42.php @@ -30,9 +30,9 @@ use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration; use Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector; use Rector\Visibility\ValueObject\ChangeMethodVisibility; # https://github.com/symfony/symfony/pull/28447 -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\New_\NewToStaticCallRector::class, [new \Rector\Transform\ValueObject\NewToStaticCall('Symfony\\Component\\HttpFoundation\\Cookie', 'Symfony\\Component\\HttpFoundation\\Cookie', 'create')]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(NewToStaticCallRector::class, [new NewToStaticCall('Symfony\\Component\\HttpFoundation\\Cookie', 'Symfony\\Component\\HttpFoundation\\Cookie', 'create')]); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ # https://github.com/symfony/symfony/commit/a7e319d9e1316e2e18843f8ce15b67a8693e5bf9 'Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller' => 'Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController', # https://github.com/symfony/symfony/commit/744bf0e7ac3ecf240d0bf055cc58f881bb0b3ec0 @@ -40,18 +40,18 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { 'Symfony\\Component\\Translation\\TranslatorInterface' => 'Symfony\\Contracts\\Translation\\TranslatorInterface', ]); # related to "Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand" deprecation, see https://github.com/rectorphp/rector/issues/1629 - $rectorConfig->rule(\Rector\Symfony\Rector\MethodCall\ContainerGetToConstructorInjectionRector::class); + $rectorConfig->rule(ContainerGetToConstructorInjectionRector::class); # https://symfony.com/blog/new-in-symfony-4-2-important-deprecations - $rectorConfig->rule(\Rector\Symfony\Rector\New_\StringToArrayArgumentProcessRector::class); - $rectorConfig->rule(\Rector\Symfony\Rector\New_\RootNodeTreeBuilderRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class, [new \Rector\Arguments\ValueObject\ArgumentAdder('Symfony\\Component\\DomCrawler\\Crawler', 'children', 0, null, null, null, \Rector\Arguments\NodeAnalyzer\ArgumentAddingScope::SCOPE_METHOD_CALL), new \Rector\Arguments\ValueObject\ArgumentAdder('Symfony\\Component\\Finder\\Finder', 'sortByName', 0, null, \false, null, \Rector\Arguments\NodeAnalyzer\ArgumentAddingScope::SCOPE_METHOD_CALL), new \Rector\Arguments\ValueObject\ArgumentAdder('Symfony\\Bridge\\Monolog\\Processor\\DebugProcessor', 'getLogs', 0, null, null, null, \Rector\Arguments\NodeAnalyzer\ArgumentAddingScope::SCOPE_METHOD_CALL), new \Rector\Arguments\ValueObject\ArgumentAdder('Symfony\\Bridge\\Monolog\\Processor\\DebugProcessor', 'countErrors', 0, 'default_value', null, null, \Rector\Arguments\NodeAnalyzer\ArgumentAddingScope::SCOPE_METHOD_CALL), new \Rector\Arguments\ValueObject\ArgumentAdder('Symfony\\Bridge\\Monolog\\Logger', 'getLogs', 0, 'default_value', null, null, \Rector\Arguments\NodeAnalyzer\ArgumentAddingScope::SCOPE_METHOD_CALL), new \Rector\Arguments\ValueObject\ArgumentAdder('Symfony\\Bridge\\Monolog\\Logger', 'countErrors', 0, 'default_value', null, null, \Rector\Arguments\NodeAnalyzer\ArgumentAddingScope::SCOPE_METHOD_CALL), new \Rector\Arguments\ValueObject\ArgumentAdder('Symfony\\Component\\Serializer\\Normalizer', 'handleCircularReference', 1, null, null, null, \Rector\Arguments\NodeAnalyzer\ArgumentAddingScope::SCOPE_METHOD_CALL), new \Rector\Arguments\ValueObject\ArgumentAdder('Symfony\\Component\\Serializer\\Normalizer', 'handleCircularReference', 2, null, null, null, \Rector\Arguments\NodeAnalyzer\ArgumentAddingScope::SCOPE_METHOD_CALL)]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Cache\\CacheItem', 'getPreviousTags', 'getMetadata'), new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Form\\AbstractTypeExtension', 'getExtendedType', 'getExtendedTypes')]); - $iterableType = new \PHPStan\Type\IterableType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); - $rectorConfig->ruleWithConfiguration(\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::class, [new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Form\\AbstractTypeExtension', 'getExtendedTypes', $iterableType)]); - $rectorConfig->ruleWithConfiguration(\Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector::class, [new \Rector\Visibility\ValueObject\ChangeMethodVisibility('Symfony\\Component\\Form\\AbstractTypeExtension', 'getExtendedTypes', \Rector\Core\ValueObject\Visibility::STATIC)]); - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\ClassMethod\WrapReturnRector::class, [new \Rector\Transform\ValueObject\WrapReturn('Symfony\\Component\\Form\\AbstractTypeExtension', 'getExtendedTypes', \true)]); + $rectorConfig->rule(StringToArrayArgumentProcessRector::class); + $rectorConfig->rule(RootNodeTreeBuilderRector::class); + $rectorConfig->ruleWithConfiguration(ArgumentAdderRector::class, [new ArgumentAdder('Symfony\\Component\\DomCrawler\\Crawler', 'children', 0, null, null, null, ArgumentAddingScope::SCOPE_METHOD_CALL), new ArgumentAdder('Symfony\\Component\\Finder\\Finder', 'sortByName', 0, null, \false, null, ArgumentAddingScope::SCOPE_METHOD_CALL), new ArgumentAdder('Symfony\\Bridge\\Monolog\\Processor\\DebugProcessor', 'getLogs', 0, null, null, null, ArgumentAddingScope::SCOPE_METHOD_CALL), new ArgumentAdder('Symfony\\Bridge\\Monolog\\Processor\\DebugProcessor', 'countErrors', 0, 'default_value', null, null, ArgumentAddingScope::SCOPE_METHOD_CALL), new ArgumentAdder('Symfony\\Bridge\\Monolog\\Logger', 'getLogs', 0, 'default_value', null, null, ArgumentAddingScope::SCOPE_METHOD_CALL), new ArgumentAdder('Symfony\\Bridge\\Monolog\\Logger', 'countErrors', 0, 'default_value', null, null, ArgumentAddingScope::SCOPE_METHOD_CALL), new ArgumentAdder('Symfony\\Component\\Serializer\\Normalizer', 'handleCircularReference', 1, null, null, null, ArgumentAddingScope::SCOPE_METHOD_CALL), new ArgumentAdder('Symfony\\Component\\Serializer\\Normalizer', 'handleCircularReference', 2, null, null, null, ArgumentAddingScope::SCOPE_METHOD_CALL)]); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Symfony\\Component\\Cache\\CacheItem', 'getPreviousTags', 'getMetadata'), new MethodCallRename('Symfony\\Component\\Form\\AbstractTypeExtension', 'getExtendedType', 'getExtendedTypes')]); + $iterableType = new IterableType(new MixedType(), new MixedType()); + $rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [new AddReturnTypeDeclaration('Symfony\\Component\\Form\\AbstractTypeExtension', 'getExtendedTypes', $iterableType)]); + $rectorConfig->ruleWithConfiguration(ChangeMethodVisibilityRector::class, [new ChangeMethodVisibility('Symfony\\Component\\Form\\AbstractTypeExtension', 'getExtendedTypes', Visibility::STATIC)]); + $rectorConfig->ruleWithConfiguration(WrapReturnRector::class, [new WrapReturn('Symfony\\Component\\Form\\AbstractTypeExtension', 'getExtendedTypes', \true)]); // https://github.com/symfony/symfony/commit/9493cfd5f2366dab19bbdde0d0291d0575454567 - $rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\ClassMethod\ReplaceArgumentDefaultValueRector::class, [new \Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue('Symfony\\Component\\HttpFoundation\\Cookie', \Rector\Core\ValueObject\MethodName::CONSTRUCT, 5, \false, null), new \Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue('Symfony\\Component\\HttpFoundation\\Cookie', \Rector\Core\ValueObject\MethodName::CONSTRUCT, 8, null, 'lax')]); + $rectorConfig->ruleWithConfiguration(ReplaceArgumentDefaultValueRector::class, [new ReplaceArgumentDefaultValue('Symfony\\Component\\HttpFoundation\\Cookie', MethodName::CONSTRUCT, 5, \false, null), new ReplaceArgumentDefaultValue('Symfony\\Component\\HttpFoundation\\Cookie', MethodName::CONSTRUCT, 8, null, 'lax')]); # https://github.com/symfony/symfony/commit/f5c355e1ba399a1b3512367647d902148bdaf09f - $rectorConfig->ruleWithConfiguration(\Rector\Removing\Rector\ClassMethod\ArgumentRemoverRector::class, [new \Rector\Removing\ValueObject\ArgumentRemover('Symfony\\Component\\HttpKernel\\DataCollector\\ConfigDataCollector', \Rector\Core\ValueObject\MethodName::CONSTRUCT, 0, null), new \Rector\Removing\ValueObject\ArgumentRemover('Symfony\\Component\\HttpKernel\\DataCollector\\ConfigDataCollector', \Rector\Core\ValueObject\MethodName::CONSTRUCT, 1, null)]); + $rectorConfig->ruleWithConfiguration(ArgumentRemoverRector::class, [new ArgumentRemover('Symfony\\Component\\HttpKernel\\DataCollector\\ConfigDataCollector', MethodName::CONSTRUCT, 0, null), new ArgumentRemover('Symfony\\Component\\HttpKernel\\DataCollector\\ConfigDataCollector', MethodName::CONSTRUCT, 1, null)]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony43.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony43.php index 1f0e6c2bb55..9713f3be2bf 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony43.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony43.php @@ -14,19 +14,19 @@ use Rector\Renaming\ValueObject\MethodCallRename; use Rector\Symfony\Rector\MethodCall\MakeDispatchFirstArgumentEventRector; use Rector\Symfony\Rector\MethodCall\WebTestCaseAssertResponseCodeRector; # https://github.com/symfony/symfony/blob/4.4/UPGRADE-4.3.md -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { # https://symfony.com/blog/new-in-symfony-4-3-better-test-assertions - $rectorConfig->rule(\Rector\Symfony\Rector\MethodCall\WebTestCaseAssertResponseCodeRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [ - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\BrowserKit\\Response', 'getStatus', 'getStatusCode'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Security\\Http\\Firewall', 'handleRequest', 'callListeners'), + $rectorConfig->rule(WebTestCaseAssertResponseCodeRector::class); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ + new MethodCallRename('Symfony\\Component\\BrowserKit\\Response', 'getStatus', 'getStatusCode'), + new MethodCallRename('Symfony\\Component\\Security\\Http\\Firewall', 'handleRequest', 'callListeners'), # https://github.com/symfony/http-kernel/blob/801b925e308518ddf821ba91952c41ae77c77507/Event/GetResponseForExceptionEvent.php#L55 - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent', 'getException', 'getThrowable'), + new MethodCallRename('Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent', 'getException', 'getThrowable'), # https://github.com/symfony/http-kernel/blob/801b925e308518ddf821ba91952c41ae77c77507/Event/GetResponseForExceptionEvent.php#L67 - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent', 'setException', 'setThrowable'), + new MethodCallRename('Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent', 'setException', 'setThrowable'), ]); - $rectorConfig->rule(\Rector\Symfony\Rector\MethodCall\MakeDispatchFirstArgumentEventRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, [ + $rectorConfig->rule(MakeDispatchFirstArgumentEventRector::class); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ # https://symfony.com/blog/new-in-symfony-4-3-simpler-event-dispatching # Browser Kit 'Symfony\\Component\\BrowserKit\\Client' => 'Symfony\\Component\\BrowserKit\\AbstractBrowser', @@ -71,6 +71,6 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { 'Symfony\\Component\\Security\\Core\\Encoder\\BCryptPasswordEncoder' => 'Symfony\\Component\\Security\\Core\\Encoder\\NativePasswordEncoder', ]); # https://github.com/symfony/symfony/blob/4.4/UPGRADE-4.3.md#workflow - $rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class, [new \Rector\Arguments\ValueObject\ArgumentAdder('Symfony\\Component\\Workflow\\MarkingStore\\MarkingStoreInterface', 'setMarking', 2, 'context', [])]); - $rectorConfig->ruleWithConfiguration(\Rector\DependencyInjection\Rector\ClassMethod\AddMethodParentCallRector::class, ['Symfony\\Component\\EventDispatcher\\EventDispatcher' => \Rector\Core\ValueObject\MethodName::CONSTRUCT]); + $rectorConfig->ruleWithConfiguration(ArgumentAdderRector::class, [new ArgumentAdder('Symfony\\Component\\Workflow\\MarkingStore\\MarkingStoreInterface', 'setMarking', 2, 'context', [])]); + $rectorConfig->ruleWithConfiguration(AddMethodParentCallRector::class, ['Symfony\\Component\\EventDispatcher\\EventDispatcher' => MethodName::CONSTRUCT]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony44.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony44.php index d09d4bebbe5..993b3b9e986 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony44.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony44.php @@ -7,9 +7,9 @@ use Rector\Config\RectorConfig; use Rector\Symfony\Rector\ClassMethod\ConsoleExecuteReturnIntRector; use Rector\Symfony\Rector\MethodCall\AuthorizationCheckerIsGrantedExtractorRector; # https://github.com/symfony/symfony/blob/4.4/UPGRADE-4.4.md -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { # https://github.com/symfony/symfony/pull/33775 - $rectorConfig->rule(\Rector\Symfony\Rector\ClassMethod\ConsoleExecuteReturnIntRector::class); + $rectorConfig->rule(ConsoleExecuteReturnIntRector::class); # https://github.com/symfony/symfony/blob/4.4/UPGRADE-4.4.md#security - $rectorConfig->rule(\Rector\Symfony\Rector\MethodCall\AuthorizationCheckerIsGrantedExtractorRector::class); + $rectorConfig->rule(AuthorizationCheckerIsGrantedExtractorRector::class); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony50-types.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony50-types.php index 73d699d59fb..0d4686189b3 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony50-types.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony50-types.php @@ -17,102 +17,102 @@ use Rector\Config\RectorConfig; use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector; use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration; # see https://symfony.com/blog/symfony-type-declarations-return-types-and-phpunit-compatibility -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $arrayType = new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); - $iterableType = new \PHPStan\Type\IterableType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); - $nullableStringType = new \PHPStan\Type\UnionType([new \PHPStan\Type\StringType(), new \PHPStan\Type\NullType()]); - $rectorConfig->ruleWithConfiguration(\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $arrayType = new ArrayType(new MixedType(), new MixedType()); + $iterableType = new IterableType(new MixedType(), new MixedType()); + $nullableStringType = new UnionType([new StringType(), new NullType()]); + $rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [ // see https://github.com/symfony/symfony/issues/32179 - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', 'addListener', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', 'addListener', 2, new \PHPStan\Type\IntegerType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', 'removeListener', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', 'getListeners', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', 'getListenerPriority', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', 'hasListeners', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'setCatchExceptions', 0, new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'setAutoExit', 0, new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'setName', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'setVersion', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'register', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'get', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'has', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'findNamespace', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'find', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'all', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'getAbbreviations', 0, $arrayType), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'extractNamespace', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'extractNamespace', 1, new \PHPStan\Type\IntegerType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'setDefaultCommand', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'setDefaultCommand', 1, new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'mergeApplicationDefinition', 0, new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'addArgument', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'addArgument', 1, new \PHPStan\Type\IntegerType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'addArgument', 2, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'addOption', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'addOption', 2, new \PHPStan\Type\IntegerType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'addOption', 3, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'setName', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'setProcessTitle', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'setHidden', 0, new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'setDescription', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'setHelp', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'setAliases', 0, $iterableType), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'getSynopsis', 0, new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'addUsage', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'getHelper', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\CommandLoader\\CommandLoaderInterface', 'get', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\CommandLoader\\CommandLoaderInterface', 'has', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Input\\InputInterface', 'getArgument', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Input\\InputInterface', 'setArgument', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Input\\InputInterface', 'getOption', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Input\\InputInterface', 'setOption', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Input\\InputInterface', 'hasOption', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Input\\InputInterface', 'setInteractive', 0, new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Output\\OutputInterface', 'write', 1, new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Output\\OutputInterface', 'write', 2, new \PHPStan\Type\IntegerType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Output\\OutputInterface', 'writeln', 1, new \PHPStan\Type\IntegerType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Output\\OutputInterface', 'setVerbosity', 0, new \PHPStan\Type\IntegerType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Console\\Output\\OutputInterface', 'setDecorated', 0, new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Process\\Process', 'signal', 0, new \PHPStan\Type\IntegerType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Process\\Process', 'stop', 0, new \PHPStan\Type\FloatType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Process\\Process', 'stop', 1, new \PHPStan\Type\IntegerType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Process\\Process', 'setTty', 0, new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Process\\Process', 'setPty', 0, new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Process\\Process', 'setWorkingDirectory', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Process\\Process', 'inheritEnvironmentVariables', 0, new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Process\\Process', 'updateStatus', 0, new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\EventDispatcher\\EventDispatcher', 'dispatch', 0, new \PHPStan\Type\ObjectWithoutClassType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Contracts\\Translation\\TranslatorInterface', 'setLocale', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Contracts\\Translation\\TranslatorInterface', 'trans', 0, $nullableStringType), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Contracts\\Translation\\TranslatorInterface', 'trans', 2, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Contracts\\Translation\\TranslatorInterface', 'trans', 3, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\AbstractExtension', 'getType', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\AbstractExtension', 'hasType', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\AbstractExtension', 'getTypeExtensions', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\AbstractExtension', 'hasTypeExtensions', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\DataMapperInterface', 'mapFormsToData', 0, $iterableType), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\DataMapperInterface', 'mapDataToForms', 1, $iterableType), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\Form', 'add', 1, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\Form', 'remove', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\Form', 'has', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\Form', 'get', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\FormBuilderInterface', 'add', 1, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\FormBuilderInterface', 'create', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\FormBuilderInterface', 'create', 1, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\FormBuilderInterface', 'get', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\FormBuilderInterface', 'remove', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\FormBuilderInterface', 'has', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\FormExtensionInterface', 'getTypeExtensions', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\FormExtensionInterface', 'hasTypeExtensions', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\FormFactory', 'create', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\FormFactory', 'createNamed', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\FormFactory', 'createNamed', 1, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\FormFactory', 'createForProperty', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\FormFactory', 'createForProperty', 1, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\FormFactory', 'createBuilder', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\FormFactory', 'createNamedBuilder', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\FormFactory', 'createNamedBuilder', 1, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\FormFactory', 'createBuilderForProperty', 0, new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Form\\FormFactory', 'createBuilderForProperty', 1, new \PHPStan\Type\StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', 'addListener', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', 'addListener', 2, new IntegerType()), + new AddParamTypeDeclaration('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', 'removeListener', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', 'getListeners', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', 'getListenerPriority', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', 'hasListeners', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'setCatchExceptions', 0, new BooleanType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'setAutoExit', 0, new BooleanType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'setName', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'setVersion', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'register', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'get', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'has', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'findNamespace', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'find', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'all', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'getAbbreviations', 0, $arrayType), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'extractNamespace', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'extractNamespace', 1, new IntegerType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'setDefaultCommand', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Application', 'setDefaultCommand', 1, new BooleanType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'mergeApplicationDefinition', 0, new BooleanType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'addArgument', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'addArgument', 1, new IntegerType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'addArgument', 2, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'addOption', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'addOption', 2, new IntegerType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'addOption', 3, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'setName', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'setProcessTitle', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'setHidden', 0, new BooleanType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'setDescription', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'setHelp', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'setAliases', 0, $iterableType), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'getSynopsis', 0, new BooleanType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'addUsage', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'getHelper', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\CommandLoader\\CommandLoaderInterface', 'get', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\CommandLoader\\CommandLoaderInterface', 'has', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Input\\InputInterface', 'getArgument', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Input\\InputInterface', 'setArgument', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Input\\InputInterface', 'getOption', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Input\\InputInterface', 'setOption', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Input\\InputInterface', 'hasOption', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Input\\InputInterface', 'setInteractive', 0, new BooleanType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Output\\OutputInterface', 'write', 1, new BooleanType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Output\\OutputInterface', 'write', 2, new IntegerType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Output\\OutputInterface', 'writeln', 1, new IntegerType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Output\\OutputInterface', 'setVerbosity', 0, new IntegerType()), + new AddParamTypeDeclaration('Symfony\\Component\\Console\\Output\\OutputInterface', 'setDecorated', 0, new BooleanType()), + new AddParamTypeDeclaration('Symfony\\Component\\Process\\Process', 'signal', 0, new IntegerType()), + new AddParamTypeDeclaration('Symfony\\Component\\Process\\Process', 'stop', 0, new FloatType()), + new AddParamTypeDeclaration('Symfony\\Component\\Process\\Process', 'stop', 1, new IntegerType()), + new AddParamTypeDeclaration('Symfony\\Component\\Process\\Process', 'setTty', 0, new BooleanType()), + new AddParamTypeDeclaration('Symfony\\Component\\Process\\Process', 'setPty', 0, new BooleanType()), + new AddParamTypeDeclaration('Symfony\\Component\\Process\\Process', 'setWorkingDirectory', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Process\\Process', 'inheritEnvironmentVariables', 0, new BooleanType()), + new AddParamTypeDeclaration('Symfony\\Component\\Process\\Process', 'updateStatus', 0, new BooleanType()), + new AddParamTypeDeclaration('Symfony\\Component\\EventDispatcher\\EventDispatcher', 'dispatch', 0, new ObjectWithoutClassType()), + new AddParamTypeDeclaration('Symfony\\Contracts\\Translation\\TranslatorInterface', 'setLocale', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Contracts\\Translation\\TranslatorInterface', 'trans', 0, $nullableStringType), + new AddParamTypeDeclaration('Symfony\\Contracts\\Translation\\TranslatorInterface', 'trans', 2, new StringType()), + new AddParamTypeDeclaration('Symfony\\Contracts\\Translation\\TranslatorInterface', 'trans', 3, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\AbstractExtension', 'getType', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\AbstractExtension', 'hasType', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\AbstractExtension', 'getTypeExtensions', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\AbstractExtension', 'hasTypeExtensions', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\DataMapperInterface', 'mapFormsToData', 0, $iterableType), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\DataMapperInterface', 'mapDataToForms', 1, $iterableType), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\Form', 'add', 1, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\Form', 'remove', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\Form', 'has', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\Form', 'get', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\FormBuilderInterface', 'add', 1, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\FormBuilderInterface', 'create', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\FormBuilderInterface', 'create', 1, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\FormBuilderInterface', 'get', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\FormBuilderInterface', 'remove', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\FormBuilderInterface', 'has', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\FormExtensionInterface', 'getTypeExtensions', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\FormExtensionInterface', 'hasTypeExtensions', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\FormFactory', 'create', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\FormFactory', 'createNamed', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\FormFactory', 'createNamed', 1, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\FormFactory', 'createForProperty', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\FormFactory', 'createForProperty', 1, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\FormFactory', 'createBuilder', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\FormFactory', 'createNamedBuilder', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\FormFactory', 'createNamedBuilder', 1, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\FormFactory', 'createBuilderForProperty', 0, new StringType()), + new AddParamTypeDeclaration('Symfony\\Component\\Form\\FormFactory', 'createBuilderForProperty', 1, new StringType()), ]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony50.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony50.php index 651c98d3cb3..c6ccfbdccc7 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony50.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony50.php @@ -8,8 +8,8 @@ use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Renaming\ValueObject\MethodCallRename; # https://github.com/symfony/symfony/blob/5.0/UPGRADE-5.0.md -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $rectorConfig->import(__DIR__ . '/symfony50-types.php'); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Symfony\\Component\\Debug\\Debug' => 'Symfony\\Component\\ErrorHandler\\Debug']); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Console\\Application', 'renderException', 'renderThrowable'), new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Console\\Application', 'doRenderException', 'doRenderThrowable')]); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Symfony\\Component\\Debug\\Debug' => 'Symfony\\Component\\ErrorHandler\\Debug']); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Symfony\\Component\\Console\\Application', 'renderException', 'renderThrowable'), new MethodCallRename('Symfony\\Component\\Console\\Application', 'doRenderException', 'doRenderThrowable')]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony51.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony51.php index 525619b9a7b..648eab34aca 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony51.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony51.php @@ -22,27 +22,27 @@ use Rector\Transform\ValueObject\NewArgToMethodCall; use Rector\Transform\ValueObject\StaticCallToNew; use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector; use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { // see https://github.com/symfony/symfony/pull/36243 - $rectorConfig->rule(\Rector\Symfony\Rector\Class_\LogoutHandlerToLogoutEventSubscriberRector::class); - $rectorConfig->rule(\Rector\Symfony\Rector\Class_\LogoutSuccessHandlerToLogoutEventSubscriberRector::class); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, [ + $rectorConfig->rule(LogoutHandlerToLogoutEventSubscriberRector::class); + $rectorConfig->rule(LogoutSuccessHandlerToLogoutEventSubscriberRector::class); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ 'Symfony\\Component\\EventDispatcher\\LegacyEventDispatcherProxy' => 'Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', 'Symfony\\Component\\Form\\Extension\\Validator\\Util\\ServerParams' => 'Symfony\\Component\\Form\\Util\\ServerParams', // see https://github.com/symfony/symfony/pull/35092 'Symfony\\Component\\Inflector' => 'Symfony\\Component\\String\\Inflector\\InflectorInterface', ]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Config\\Definition\\BaseNode', 'getDeprecationMessage', 'getDeprecation'), new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\DependencyInjection\\Definition', 'getDeprecationMessage', 'getDeprecation'), new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\DependencyInjection\\Alias', 'getDeprecationMessage', 'getDeprecation')]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class, ['Symfony\\Component\\DependencyInjection\\Loader\\Configuraton\\inline' => 'Symfony\\Component\\DependencyInjection\\Loader\\Configuraton\\inline_service', 'Symfony\\Component\\DependencyInjection\\Loader\\Configuraton\\ref' => 'Symfony\\Component\\DependencyInjection\\Loader\\Configuraton\\service']); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Symfony\\Component\\Config\\Definition\\BaseNode', 'getDeprecationMessage', 'getDeprecation'), new MethodCallRename('Symfony\\Component\\DependencyInjection\\Definition', 'getDeprecationMessage', 'getDeprecation'), new MethodCallRename('Symfony\\Component\\DependencyInjection\\Alias', 'getDeprecationMessage', 'getDeprecation')]); + $rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, ['Symfony\\Component\\DependencyInjection\\Loader\\Configuraton\\inline' => 'Symfony\\Component\\DependencyInjection\\Loader\\Configuraton\\inline_service', 'Symfony\\Component\\DependencyInjection\\Loader\\Configuraton\\ref' => 'Symfony\\Component\\DependencyInjection\\Loader\\Configuraton\\service']); // https://github.com/symfony/symfony/pull/35308 - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\New_\NewArgToMethodCallRector::class, [new \Rector\Transform\ValueObject\NewArgToMethodCall('Symfony\\Component\\Dotenv\\Dotenv', \true, 'usePutenv')]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector::class, [new \Rector\Renaming\ValueObject\RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_FLOOR', 'NumberFormatter', 'ROUND_FLOOR'), new \Rector\Renaming\ValueObject\RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_DOWN', 'NumberFormatter', 'ROUND_DOWN'), new \Rector\Renaming\ValueObject\RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_HALF_DOWN', 'NumberFormatter', 'ROUND_HALFDOWN'), new \Rector\Renaming\ValueObject\RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_HALF_EVEN', 'NumberFormatter', 'ROUND_HALFEVEN'), new \Rector\Renaming\ValueObject\RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_HALFUP', 'NumberFormatter', 'ROUND_HALFUP'), new \Rector\Renaming\ValueObject\RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_UP', 'NumberFormatter', 'ROUND_UP'), new \Rector\Renaming\ValueObject\RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_CEILING', 'NumberFormatter', 'ROUND_CEILING')]); + $rectorConfig->ruleWithConfiguration(NewArgToMethodCallRector::class, [new NewArgToMethodCall('Symfony\\Component\\Dotenv\\Dotenv', \true, 'usePutenv')]); + $rectorConfig->ruleWithConfiguration(RenameClassConstFetchRector::class, [new RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_FLOOR', 'NumberFormatter', 'ROUND_FLOOR'), new RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_DOWN', 'NumberFormatter', 'ROUND_DOWN'), new RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_HALF_DOWN', 'NumberFormatter', 'ROUND_HALFDOWN'), new RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_HALF_EVEN', 'NumberFormatter', 'ROUND_HALFEVEN'), new RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_HALFUP', 'NumberFormatter', 'ROUND_HALFUP'), new RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_UP', 'NumberFormatter', 'ROUND_UP'), new RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_CEILING', 'NumberFormatter', 'ROUND_CEILING')]); // see https://github.com/symfony/symfony/pull/36943 - $rectorConfig->ruleWithConfiguration(\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::class, [new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Bundle\\FrameworkBundle\\Kernel\\MicroKernelTrait', 'configureRoutes', 0, new \PHPStan\Type\ObjectType('Symfony\\Component\\Routing\\Loader\\Configurator\\RoutingConfigurator'))]); - $rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\StaticCall\StaticCallToNewRector::class, [new \Rector\Transform\ValueObject\StaticCallToNew('Symfony\\Component\\HttpFoundation\\Response', 'create'), new \Rector\Transform\ValueObject\StaticCallToNew('Symfony\\Component\\HttpFoundation\\JsonResponse', 'create'), new \Rector\Transform\ValueObject\StaticCallToNew('Symfony\\Component\\HttpFoundation\\RedirectResponse', 'create'), new \Rector\Transform\ValueObject\StaticCallToNew('Symfony\\Component\\HttpFoundation\\StreamedResponse', 'create')]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\String_\RenameStringRector::class, [ + $rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [new AddParamTypeDeclaration('Symfony\\Bundle\\FrameworkBundle\\Kernel\\MicroKernelTrait', 'configureRoutes', 0, new ObjectType('Symfony\\Component\\Routing\\Loader\\Configurator\\RoutingConfigurator'))]); + $rectorConfig->ruleWithConfiguration(StaticCallToNewRector::class, [new StaticCallToNew('Symfony\\Component\\HttpFoundation\\Response', 'create'), new StaticCallToNew('Symfony\\Component\\HttpFoundation\\JsonResponse', 'create'), new StaticCallToNew('Symfony\\Component\\HttpFoundation\\RedirectResponse', 'create'), new StaticCallToNew('Symfony\\Component\\HttpFoundation\\StreamedResponse', 'create')]); + $rectorConfig->ruleWithConfiguration(RenameStringRector::class, [ // @see https://github.com/symfony/symfony/pull/35858 'ROLE_PREVIOUS_ADMIN' => 'IS_IMPERSONATOR', ]); - $rectorConfig->rule(\Rector\Symfony\Rector\ClassMethod\RouteCollectionBuilderToRoutingConfiguratorRector::class); + $rectorConfig->rule(RouteCollectionBuilderToRoutingConfiguratorRector::class); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony52-validator-attributes.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony52-validator-attributes.php index 18ea156c113..4bdf11ebf13 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony52-validator-attributes.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony52-validator-attributes.php @@ -7,6 +7,6 @@ use Rector\Config\RectorConfig; use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; use Rector\Php80\ValueObject\AnnotationToAttribute; // @see https://symfony.com/blog/new-in-symfony-5-2-constraints-as-php-attributes -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class, [new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Bic'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Blank'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Callback'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\CardScheme'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Cascade'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Choice'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Count'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Country'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Currency'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Date'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\DateTime'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\DisableAutoMapping'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\DivisibleBy'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Email'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\EnableAutoMapping'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\EqualTo'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Expression'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\ExpressionLanguageSyntax'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\File'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\GreaterThan'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\GreaterThanOrEqual'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\GroupSequence'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\GroupSequenceProvider'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Hostname'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Iban'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\IdenticalTo'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Image'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Ip'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Isbn'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\IsFalse'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Isin'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\IsNull'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Issn'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\IsTrue'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Json'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Language'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Length'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\LessThan'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\LessThanOrEqual'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Locale'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Luhn'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Negative'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\NegativeOrZero'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\NotBlank'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\NotCompromisedPassword'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\NotEqualTo'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\NotIdenticalTo'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\NotNull'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Positive'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\PositiveOrZero'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Range'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Regex'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Time'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Timezone'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Traverse'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Type'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Ulid'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Unique'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Url'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Uuid'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Valid'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Serializer\\Annotation\\DiscriminatorMap'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Serializer\\Annotation\\Groups'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Serializer\\Annotation\\Ignore'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Serializer\\Annotation\\MaxDepth'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Serializer\\Annotation\\SerializedName')]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Bic'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Blank'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Callback'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\CardScheme'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Cascade'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Choice'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Count'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Country'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Currency'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Date'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\DateTime'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\DisableAutoMapping'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\DivisibleBy'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Email'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\EnableAutoMapping'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\EqualTo'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Expression'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\ExpressionLanguageSyntax'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\File'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\GreaterThan'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\GreaterThanOrEqual'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\GroupSequence'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\GroupSequenceProvider'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Hostname'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Iban'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\IdenticalTo'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Image'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Ip'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Isbn'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\IsFalse'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Isin'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\IsNull'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Issn'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\IsTrue'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Json'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Language'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Length'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\LessThan'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\LessThanOrEqual'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Locale'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Luhn'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Negative'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\NegativeOrZero'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\NotBlank'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\NotCompromisedPassword'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\NotEqualTo'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\NotIdenticalTo'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\NotNull'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Positive'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\PositiveOrZero'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Range'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Regex'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Time'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Timezone'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Traverse'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Type'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Ulid'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Unique'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Url'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Uuid'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Valid'), new AnnotationToAttribute('Symfony\\Component\\Serializer\\Annotation\\DiscriminatorMap'), new AnnotationToAttribute('Symfony\\Component\\Serializer\\Annotation\\Groups'), new AnnotationToAttribute('Symfony\\Component\\Serializer\\Annotation\\Ignore'), new AnnotationToAttribute('Symfony\\Component\\Serializer\\Annotation\\MaxDepth'), new AnnotationToAttribute('Symfony\\Component\\Serializer\\Annotation\\SerializedName')]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony52.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony52.php index 47fac25db49..46383c40a09 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony52.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony52.php @@ -22,31 +22,31 @@ use Rector\Symfony\Set\SymfonySetList; use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector; use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration; # https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES]); # https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#form - $rectorConfig->rule(\Rector\Symfony\Rector\New_\PropertyPathMapperToDataMapperRector::class); + $rectorConfig->rule(PropertyPathMapperToDataMapperRector::class); # https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#httpfoundation - $rectorConfig->rule(\Rector\Symfony\Rector\StaticCall\BinaryFileResponseCreateToNewInstanceRector::class); + $rectorConfig->rule(BinaryFileResponseCreateToNewInstanceRector::class); # https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#mime - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Mime\\Address', 'fromString', 'create')]); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Symfony\\Component\\Mime\\Address', 'fromString', 'create')]); # https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#propertyaccess - $rectorConfig->rule(\Rector\Symfony\Rector\New_\PropertyAccessorCreationBooleanToFlagsRector::class); + $rectorConfig->rule(PropertyAccessorCreationBooleanToFlagsRector::class); # https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#propertyinfo - $rectorConfig->rule(\Rector\Symfony\Rector\MethodCall\ReflectionExtractorEnableMagicCallExtractorRector::class); + $rectorConfig->rule(ReflectionExtractorEnableMagicCallExtractorRector::class); # https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#security - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector::class, [new \Rector\Renaming\ValueObject\RenameClassAndConstFetch('Symfony\\Component\\Security\\Http\\Firewall\\AccessListener', 'PUBLIC_ACCESS', 'Symfony\\Component\\Security\\Core\\Authorization\\Voter\\AuthenticatedVoter', 'PUBLIC_ACCESS')]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Security\\Core\\Authentication\\Token\\PreAuthenticatedToken', 'setProviderKey', 'setFirewallName'), new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Security\\Core\\Authentication\\Token\\PreAuthenticatedToken', 'getProviderKey', 'getFirewallName'), new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Security\\Core\\Authentication\\Token\\RememberMeToken', 'setProviderKey', 'setFirewallName'), new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Security\\Core\\Authentication\\Token\\RememberMeToken', 'getProviderKey', 'getFirewallName'), new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Security\\Core\\Authentication\\Token\\SwitchUserToken', 'setProviderKey', 'setFirewallName'), new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Security\\Core\\Authentication\\Token\\SwitchUserToken', 'getProviderKey', 'getFirewallName'), new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken', 'setProviderKey', 'setFirewallName'), new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken', 'getProviderKey', 'getFirewallName'), new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Security\\Http\\Authentication\\DefaultAuthenticationSuccessHandler', 'setProviderKey', 'setFirewallName'), new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Security\\Http\\Authentication\\DefaultAuthenticationSuccessHandler', 'getProviderKey', 'getFirewallName')]); + $rectorConfig->ruleWithConfiguration(RenameClassConstFetchRector::class, [new RenameClassAndConstFetch('Symfony\\Component\\Security\\Http\\Firewall\\AccessListener', 'PUBLIC_ACCESS', 'Symfony\\Component\\Security\\Core\\Authorization\\Voter\\AuthenticatedVoter', 'PUBLIC_ACCESS')]); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Symfony\\Component\\Security\\Core\\Authentication\\Token\\PreAuthenticatedToken', 'setProviderKey', 'setFirewallName'), new MethodCallRename('Symfony\\Component\\Security\\Core\\Authentication\\Token\\PreAuthenticatedToken', 'getProviderKey', 'getFirewallName'), new MethodCallRename('Symfony\\Component\\Security\\Core\\Authentication\\Token\\RememberMeToken', 'setProviderKey', 'setFirewallName'), new MethodCallRename('Symfony\\Component\\Security\\Core\\Authentication\\Token\\RememberMeToken', 'getProviderKey', 'getFirewallName'), new MethodCallRename('Symfony\\Component\\Security\\Core\\Authentication\\Token\\SwitchUserToken', 'setProviderKey', 'setFirewallName'), new MethodCallRename('Symfony\\Component\\Security\\Core\\Authentication\\Token\\SwitchUserToken', 'getProviderKey', 'getFirewallName'), new MethodCallRename('Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken', 'setProviderKey', 'setFirewallName'), new MethodCallRename('Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken', 'getProviderKey', 'getFirewallName'), new MethodCallRename('Symfony\\Component\\Security\\Http\\Authentication\\DefaultAuthenticationSuccessHandler', 'setProviderKey', 'setFirewallName'), new MethodCallRename('Symfony\\Component\\Security\\Http\\Authentication\\DefaultAuthenticationSuccessHandler', 'getProviderKey', 'getFirewallName')]); # https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#dependencyinjection - $rectorConfig->rule(\Rector\Symfony\Rector\MethodCall\DefinitionAliasSetPrivateToSetPublicRector::class); + $rectorConfig->rule(DefinitionAliasSetPrivateToSetPublicRector::class); # https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#form - $rectorConfig->rule(\Rector\Symfony\Rector\MethodCall\FormBuilderSetDataMapperRector::class); + $rectorConfig->rule(FormBuilderSetDataMapperRector::class); # https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#validator - $rectorConfig->rule(\Rector\Symfony\Rector\MethodCall\ValidatorBuilderEnableAnnotationMappingRector::class); + $rectorConfig->rule(ValidatorBuilderEnableAnnotationMappingRector::class); # https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#notifier - $rectorConfig->ruleWithConfiguration(\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::class, [new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Notifier\\NotifierInterface', 'send', 1, new \PHPStan\Type\ObjectType('Symfony\\Component\\Notifier\\Recipient\\RecipientInterface')), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Notifier\\Notifier', 'getChannels', 1, new \PHPStan\Type\ObjectType('Symfony\\Component\\Notifier\\Recipient\\RecipientInterface')), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Notifier\\Channel\\ChannelInterface', 'notify', 1, new \PHPStan\Type\ObjectType('Symfony\\Component\\Notifier\\Recipient\\RecipientInterface')), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Notifier\\Channel\\ChannelInterface', 'supports', 1, new \PHPStan\Type\ObjectType('Symfony\\Component\\Notifier\\Recipient\\RecipientInterface'))]); + $rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [new AddParamTypeDeclaration('Symfony\\Component\\Notifier\\NotifierInterface', 'send', 1, new ObjectType('Symfony\\Component\\Notifier\\Recipient\\RecipientInterface')), new AddParamTypeDeclaration('Symfony\\Component\\Notifier\\Notifier', 'getChannels', 1, new ObjectType('Symfony\\Component\\Notifier\\Recipient\\RecipientInterface')), new AddParamTypeDeclaration('Symfony\\Component\\Notifier\\Channel\\ChannelInterface', 'notify', 1, new ObjectType('Symfony\\Component\\Notifier\\Recipient\\RecipientInterface')), new AddParamTypeDeclaration('Symfony\\Component\\Notifier\\Channel\\ChannelInterface', 'supports', 1, new ObjectType('Symfony\\Component\\Notifier\\Recipient\\RecipientInterface'))]); # https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#notifier - $rectorConfig->ruleWithConfiguration(\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::class, [new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Notifier\\Notification\\ChatNotificationInterface', 'asChatMessage', 0, new \PHPStan\Type\ObjectType('Symfony\\Component\\Notifier\\Recipient\\RecipientInterface')), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Notifier\\Notification\\EmailNotificationInterface', 'asEmailMessage', 0, new \PHPStan\Type\ObjectType('Symfony\\Component\\Notifier\\Recipient\\EmailRecipientInterface')), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Notifier\\Notification\\SmsNotificationInterface', 'asSmsMessage', 0, new \PHPStan\Type\ObjectType('Symfony\\Component\\Notifier\\Recipient\\SmsRecipientInterface'))]); + $rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [new AddParamTypeDeclaration('Symfony\\Component\\Notifier\\Notification\\ChatNotificationInterface', 'asChatMessage', 0, new ObjectType('Symfony\\Component\\Notifier\\Recipient\\RecipientInterface')), new AddParamTypeDeclaration('Symfony\\Component\\Notifier\\Notification\\EmailNotificationInterface', 'asEmailMessage', 0, new ObjectType('Symfony\\Component\\Notifier\\Recipient\\EmailRecipientInterface')), new AddParamTypeDeclaration('Symfony\\Component\\Notifier\\Notification\\SmsNotificationInterface', 'asSmsMessage', 0, new ObjectType('Symfony\\Component\\Notifier\\Recipient\\SmsRecipientInterface'))]); # https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#security - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector::class, [new \Rector\Renaming\ValueObject\RenameProperty('Symfony\\Component\\Security\\Http\\RememberMe\\AbstractRememberMeServices', 'providerKey', 'firewallName')]); + $rectorConfig->ruleWithConfiguration(RenamePropertyRector::class, [new RenameProperty('Symfony\\Component\\Security\\Http\\RememberMe\\AbstractRememberMeServices', 'providerKey', 'firewallName')]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony53.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony53.php index 7f4f5ca2a38..01b38485280 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony53.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony53.php @@ -14,20 +14,20 @@ use Rector\Symfony\Set\SymfonySetList; use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector; use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration; # https://github.com/symfony/symfony/blob/5.4/UPGRADE-5.3.md -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES]); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ // @see https://github.com/symfony/symfony/pull/40536 - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\HttpFoundation\\RequestStack', 'getMasterRequest', 'getMainRequest'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Console\\Helper\\Helper', 'strlen', 'width'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Console\\Helper\\Helper', 'strlenWithoutDecoration', 'removeDecoration'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\HttpKernel\\Event\\KernelEvent', 'isMasterRequest', 'isMainRequest'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface', 'getUsername', 'getUserIdentifier'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Security\\Core\\Exception\\UsernameNotFoundException', 'getUsername', 'getUserIdentifier'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Security\\Core\\Exception\\UsernameNotFoundException', 'setUsername', 'setUserIdentifier'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Security\\Core\\Authentication\\RememberMe\\PersistentTokenInterface', 'getUsername', 'getUserIdentifier'), + new MethodCallRename('Symfony\\Component\\HttpFoundation\\RequestStack', 'getMasterRequest', 'getMainRequest'), + new MethodCallRename('Symfony\\Component\\Console\\Helper\\Helper', 'strlen', 'width'), + new MethodCallRename('Symfony\\Component\\Console\\Helper\\Helper', 'strlenWithoutDecoration', 'removeDecoration'), + new MethodCallRename('Symfony\\Component\\HttpKernel\\Event\\KernelEvent', 'isMasterRequest', 'isMainRequest'), + new MethodCallRename('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface', 'getUsername', 'getUserIdentifier'), + new MethodCallRename('Symfony\\Component\\Security\\Core\\Exception\\UsernameNotFoundException', 'getUsername', 'getUserIdentifier'), + new MethodCallRename('Symfony\\Component\\Security\\Core\\Exception\\UsernameNotFoundException', 'setUsername', 'setUserIdentifier'), + new MethodCallRename('Symfony\\Component\\Security\\Core\\Authentication\\RememberMe\\PersistentTokenInterface', 'getUsername', 'getUserIdentifier'), ]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, [ + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ 'Symfony\\Component\\Security\\Core\\Exception\\UsernameNotFoundException' => 'Symfony\\Component\\Security\\Core\\Exception\\UserNotFoundException', // @see https://github.com/symfony/symfony/pull/39802 'Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface' => 'Symfony\\Component\\PasswordHasher\\Hasher\\PasswordHasherFactoryInterface', @@ -42,10 +42,10 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { 'Symfony\\Component\\Security\\Core\\Encoder\\UserPasswordEncoder' => 'Symfony\\Component\\PasswordHasher\\Hasher\\UserPasswordHasher', 'Symfony\\Component\\Security\\Core\\Encoder\\UserPasswordEncoderInterface' => 'Symfony\\Component\\PasswordHasher\\Hasher\\UserPasswordHasherInterface', ]); - $rectorConfig->ruleWithConfiguration(\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::class, [new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Mailer\\Transport\\AbstractTransportFactory', 'getEndpoint', new \PHPStan\Type\StringType())]); + $rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [new AddReturnTypeDeclaration('Symfony\\Component\\Mailer\\Transport\\AbstractTransportFactory', 'getEndpoint', new StringType())]); // rename constant - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector::class, [ + $rectorConfig->ruleWithConfiguration(RenameClassConstFetchRector::class, [ // @see https://github.com/symfony/symfony/pull/40536 - new \Rector\Renaming\ValueObject\RenameClassConstFetch('Symfony\\Component\\HttpKernel\\HttpKernelInterface', 'MASTER_REQUEST', 'MAIN_REQUEST'), + new RenameClassConstFetch('Symfony\\Component\\HttpKernel\\HttpKernelInterface', 'MASTER_REQUEST', 'MAIN_REQUEST'), ]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony54.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony54.php index 90d955f6e23..39f33357201 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony54.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony54.php @@ -14,23 +14,23 @@ use Rector\Renaming\ValueObject\RenameClassAndConstFetch; use Rector\Renaming\ValueObject\RenameClassConstFetch; use Rector\Symfony\Set\SymfonySetList; # https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.4.md -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES]); // @see https://symfony.com/blog/new-in-symfony-5-4-nested-validation-attributes // @see https://github.com/symfony/symfony/pull/41994 - $rectorConfig->ruleWithConfiguration(\Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class, [new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\All'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Collection'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\AtLeastOneOf'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Sequentially')]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [ + $rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\All'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Collection'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\AtLeastOneOf'), new AnnotationToAttribute('Symfony\\Component\\Validator\\Constraints\\Sequentially')]); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ // @see https://github.com/symfony/symfony/pull/42582 - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Bundle\\SecurityBundle\\Security\\FirewallConfig', 'getListeners', 'getAuthenticators'), + new MethodCallRename('Symfony\\Bundle\\SecurityBundle\\Security\\FirewallConfig', 'getListeners', 'getAuthenticators'), ]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector::class, [ - new \Rector\Renaming\ValueObject\RenameClassAndConstFetch('Symfony\\Component\\Security\\Core\\AuthenticationEvents', 'AUTHENTICATION_SUCCESS', 'Symfony\\Component\\Security\\Core\\Event\\AuthenticationSuccessEvent', 'class'), - new \Rector\Renaming\ValueObject\RenameClassAndConstFetch('Symfony\\Component\\Security\\Core\\AuthenticationEvents', 'AUTHENTICATION_FAILURE', 'Symfony\\Component\\Security\\Core\\Event\\AuthenticationFailureEvent', 'class'), + $rectorConfig->ruleWithConfiguration(RenameClassConstFetchRector::class, [ + new RenameClassAndConstFetch('Symfony\\Component\\Security\\Core\\AuthenticationEvents', 'AUTHENTICATION_SUCCESS', 'Symfony\\Component\\Security\\Core\\Event\\AuthenticationSuccessEvent', 'class'), + new RenameClassAndConstFetch('Symfony\\Component\\Security\\Core\\AuthenticationEvents', 'AUTHENTICATION_FAILURE', 'Symfony\\Component\\Security\\Core\\Event\\AuthenticationFailureEvent', 'class'), // @see https://github.com/symfony/symfony/pull/42510 - new \Rector\Renaming\ValueObject\RenameClassConstFetch('Symfony\\Component\\Security\\Core\\Authorization\\Voter\\AuthenticatedVoter', 'IS_ANONYMOUS', 'PUBLIC_ACCESS'), - new \Rector\Renaming\ValueObject\RenameClassConstFetch('Symfony\\Component\\Security\\Core\\Authorization\\Voter\\AuthenticatedVoter', 'IS_AUTHENTICATED_ANONYMOUSLY', 'PUBLIC_ACCESS'), + new RenameClassConstFetch('Symfony\\Component\\Security\\Core\\Authorization\\Voter\\AuthenticatedVoter', 'IS_ANONYMOUS', 'PUBLIC_ACCESS'), + new RenameClassConstFetch('Symfony\\Component\\Security\\Core\\Authorization\\Voter\\AuthenticatedVoter', 'IS_AUTHENTICATED_ANONYMOUSLY', 'PUBLIC_ACCESS'), ]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, [ + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ // @see https://github.com/symfony/symfony/pull/42050 'Symfony\\Component\\Security\\Http\\Event\\DeauthenticatedEvent' => 'Symfony\\Component\\Security\\Http\\Event\\TokenDeauthenticatedEvent', ]); diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony6/symfony-return-types.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony6/symfony-return-types.php index 22f2a895f45..629fb6a3054 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony6/symfony-return-types.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony6/symfony-return-types.php @@ -22,147 +22,147 @@ use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration; use RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor; // https://github.com/symfony/symfony/blob/6.1/UPGRADE-6.0.md // @see https://github.com/symfony/symfony/blob/6.1/.github/expected-missing-return-types.diff -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $iterableType = new \PHPStan\Type\IterableType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); - $arrayType = new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); - $nullableStringType = new \PHPStan\Type\UnionType([new \PHPStan\Type\NullType(), new \PHPStan\Type\StringType()]); - $nullableBooleanType = new \PHPStan\Type\UnionType([new \PHPStan\Type\NullType(), new \PHPStan\Type\BooleanType()]); - $nullableArrayType = new \PHPStan\Type\UnionType([new \PHPStan\Type\NullType(), $arrayType]); - $commandType = new \PHPStan\Type\ObjectType('Symfony\\Component\\Console\\Command\\Command'); - $routeCollectionType = new \PHPStan\Type\ObjectType('Symfony\\Component\\Routing\\RouteCollection\\RouteCollection'); - $httpFoundationResponseType = new \PHPStan\Type\ObjectType('Symfony\\Component\\HttpFoundation\\Response'); - $browserKitResponseType = new \PHPStan\Type\ObjectType('Symfony\\Component\\BrowserKit\\Response'); - $typeGuessType = new \PHPStan\Type\ObjectType('Symfony\\Component\\Form\\Guess\\TypeGuess'); - $nullableValueGuessType = new \PHPStan\Type\UnionType([new \PHPStan\Type\NullType(), new \PHPStan\Type\ObjectType('Symfony\\Component\\Form\\Guess\\ValueGuess')]); - $configurationType = new \PHPStan\Type\ObjectType('Symfony\\Component\\Config\\Definition\\ConfigurationInterface'); - $scalarTypes = [$arrayType, new \PHPStan\Type\BooleanType(), new \PHPStan\Type\StringType(), new \PHPStan\Type\IntegerType(), new \PHPStan\Type\FloatType(), new \PHPStan\Type\NullType()]; - $scalarArrayObjectUnionedTypes = \array_merge($scalarTypes, [new \PHPStan\Type\ObjectType('ArrayObject')]); +return static function (RectorConfig $rectorConfig) : void { + $iterableType = new IterableType(new MixedType(), new MixedType()); + $arrayType = new ArrayType(new MixedType(), new MixedType()); + $nullableStringType = new UnionType([new NullType(), new StringType()]); + $nullableBooleanType = new UnionType([new NullType(), new BooleanType()]); + $nullableArrayType = new UnionType([new NullType(), $arrayType]); + $commandType = new ObjectType('Symfony\\Component\\Console\\Command\\Command'); + $routeCollectionType = new ObjectType('Symfony\\Component\\Routing\\RouteCollection\\RouteCollection'); + $httpFoundationResponseType = new ObjectType('Symfony\\Component\\HttpFoundation\\Response'); + $browserKitResponseType = new ObjectType('Symfony\\Component\\BrowserKit\\Response'); + $typeGuessType = new ObjectType('Symfony\\Component\\Form\\Guess\\TypeGuess'); + $nullableValueGuessType = new UnionType([new NullType(), new ObjectType('Symfony\\Component\\Form\\Guess\\ValueGuess')]); + $configurationType = new ObjectType('Symfony\\Component\\Config\\Definition\\ConfigurationInterface'); + $scalarTypes = [$arrayType, new BooleanType(), new StringType(), new IntegerType(), new FloatType(), new NullType()]; + $scalarArrayObjectUnionedTypes = \array_merge($scalarTypes, [new ObjectType('ArrayObject')]); // cannot be crated with \PHPStan\Type\UnionTypeHelper::sortTypes() as ObjectType requires a class reflection we do not have here - $unionTypeReflectionClass = new \ReflectionClass(\PHPStan\Type\UnionType::class); + $unionTypeReflectionClass = new \ReflectionClass(UnionType::class); /** @var UnionType $scalarArrayObjectUnionType */ $scalarArrayObjectUnionType = $unionTypeReflectionClass->newInstanceWithoutConstructor(); - $privatesAccessor = new \RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor(); + $privatesAccessor = new PrivatesAccessor(); $privatesAccessor->setPrivateProperty($scalarArrayObjectUnionType, 'types', $scalarArrayObjectUnionedTypes); - $rectorConfig->ruleWithConfiguration(\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::class, [ - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Config\\Loader\\LoaderInterface', 'load', new \PHPStan\Type\MixedType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Config\\Loader\\Loader', 'import', new \PHPStan\Type\MixedType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\HttpKernel\\KernelInterface', 'registerBundles', $iterableType), + $rectorConfig->ruleWithConfiguration(AddReturnTypeDeclarationRector::class, [ + new AddReturnTypeDeclaration('Symfony\\Component\\Config\\Loader\\LoaderInterface', 'load', new MixedType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Config\\Loader\\Loader', 'import', new MixedType()), + new AddReturnTypeDeclaration('Symfony\\Component\\HttpKernel\\KernelInterface', 'registerBundles', $iterableType), // @see https://wouterj.nl/2021/09/symfony-6-native-typing#when-upgrading-to-symfony-54 - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Security\\Core\\User\\UserInterface', 'getRoles', new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType())), + new AddReturnTypeDeclaration('Symfony\\Component\\Security\\Core\\User\\UserInterface', 'getRoles', new ArrayType(new MixedType(), new MixedType())), // @see https://github.com/symfony/symfony/pull/43028/files - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Console\\Helper\\HelperInterface', 'getName', new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\BrowserKit\\AbstractBrowser', 'doRequestInProcess', new \PHPStan\Type\ObjectWithoutClassType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\BrowserKit\\AbstractBrowser', 'doRequest', new \PHPStan\Type\ObjectWithoutClassType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\BrowserKit\\AbstractBrowser', 'filterRequest', new \PHPStan\Type\ObjectWithoutClassType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\BrowserKit\\AbstractBrowser', 'filterResponse', $browserKitResponseType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Config\\Definition\\ConfigurationInterface', 'getConfigTreeBuilder', new \PHPStan\Type\ObjectType('Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder')), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Config\\FileLocator', 'locate', new \PHPStan\Type\UnionType([new \PHPStan\Type\StringType(), $arrayType])), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Config\\FileLocatorInterface', 'locate', new \PHPStan\Type\UnionType([new \PHPStan\Type\StringType(), $arrayType])), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Config\\Loader\\FileLoader', 'import', new \PHPStan\Type\MixedType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Config\\Loader\\Loader', 'import', new \PHPStan\Type\MixedType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Config\\Loader\\LoaderInterface', 'load', new \PHPStan\Type\MixedType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Config\\Loader\\LoaderInterface', 'supports', new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Config\\Loader\\LoaderInterface', 'getResolver', new \PHPStan\Type\ObjectType('Symfony\\Component\\Config\\Loader\\LoaderResolverInterface')), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Config\\ResourceCheckerInterface', 'supports', new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Config\\ResourceCheckerInterface', 'isFresh', new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Console\\Application', 'doRun', new \PHPStan\Type\IntegerType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Console\\Application', 'getLongVersion', new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Console\\Application', 'add', new \PHPStan\Type\UnionType([new \PHPStan\Type\NullType(), $commandType])), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Console\\Application', 'get', $commandType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Console\\Application', 'find', $commandType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Console\\Application', 'all', $arrayType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Console\\Application', 'doRunCommand', new \PHPStan\Type\IntegerType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'isEnabled', new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'execute', new \PHPStan\Type\IntegerType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Console\\Helper\\HelperInterface', 'getName', new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Console\\Input\\InputInterface', 'getParameterOption', new \PHPStan\Type\MixedType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Console\\Input\\InputInterface', 'getArgument', new \PHPStan\Type\MixedType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Console\\Input\\InputInterface', 'getOption', new \PHPStan\Type\MixedType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\Compiler\\AbstractRecursivePass', 'processValue', new \PHPStan\Type\MixedType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\Extension\\ConfigurationExtensionInterface', 'getConfiguration', new \PHPStan\Type\UnionType([new \PHPStan\Type\NullType(), $configurationType])), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\Extension\\Extension', 'getXsdValidationBasePath', new \PHPStan\Type\UnionType([new \PHPStan\Type\StringType(), new \PHPStan\Type\Constant\ConstantBooleanType(\false)])), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\Extension\\Extension', 'getNamespace', new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\Extension\\Extension', 'getConfiguration', new \PHPStan\Type\UnionType([new \PHPStan\Type\NullType(), $configurationType])), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface', 'getNamespace', new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface', 'getXsdValidationBasePath', new \PHPStan\Type\UnionType([new \PHPStan\Type\StringType(), new \PHPStan\Type\Constant\ConstantBooleanType(\false)])), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface', 'getAlias', new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\LazyProxy\\Instantiator\\InstantiatorInterface', 'instantiateProxy', new \PHPStan\Type\ObjectWithoutClassType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\EventDispatcher\\EventSubscriberInterface', 'getSubscribedEvents', $arrayType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface', 'getFunctions', $arrayType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Form\\AbstractExtension', 'loadTypes', $arrayType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Form\\AbstractExtension', 'loadTypeGuesser', new \PHPStan\Type\UnionType([new \PHPStan\Type\NullType(), new \PHPStan\Type\ObjectType('Symfony\\Component\\Form\\FormTypeGuesserInterface')])), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Form\\AbstractRendererEngine', 'loadResourceForBlockName', new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Form\\AbstractType', 'getBlockPrefix', new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Form\\AbstractType', 'getParent', $nullableStringType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Form\\DataTransformerInterface', 'transform', new \PHPStan\Type\MixedType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Form\\DataTransformerInterface', 'reverseTransform', new \PHPStan\Type\MixedType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Form\\FormRendererEngineInterface', 'renderBlock', new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Form\\FormTypeGuesserInterface', 'guessType', new \PHPStan\Type\UnionType([new \PHPStan\Type\NullType(), $typeGuessType])), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Form\\FormTypeGuesserInterface', 'guessRequired', $nullableValueGuessType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Form\\FormTypeGuesserInterface', 'guessMaxLength', $nullableValueGuessType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Form\\FormTypeGuesserInterface', 'guessPattern', $nullableValueGuessType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Form\\FormTypeInterface', 'getBlockPrefix', new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Form\\FormTypeInterface', 'getParent', $nullableStringType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmerInterface', 'isOptional', new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\HttpKernel\\CacheWarmer\\WarmableInterface', 'warmUp', $arrayType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\HttpKernel\\DataCollector\\DataCollector', 'getCasters', $arrayType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\HttpKernel\\DataCollector\\DataCollectorInterface', 'getName', new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache', 'forward', $httpFoundationResponseType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\HttpKernel\\HttpKernelBrowser', 'doRequest', $httpFoundationResponseType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\HttpKernel\\HttpKernelBrowser', 'getScript', new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\HttpKernel\\Log\\DebugLoggerInterface', 'getLogs', $arrayType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\HttpKernel\\Log\\DebugLoggerInterface', 'countErrors', new \PHPStan\Type\IntegerType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\OptionsResolver\\OptionsResolver', 'setNormalizer', new \Rector\StaticTypeMapper\ValueObject\Type\SimpleStaticType('Symfony\\Component\\OptionsResolver\\OptionsResolver')), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\OptionsResolver\\OptionsResolver', 'setAllowedValues', new \Rector\StaticTypeMapper\ValueObject\Type\SimpleStaticType('Symfony\\Component\\OptionsResolver\\OptionsResolver')), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\OptionsResolver\\OptionsResolver', 'addAllowedValues', new \Rector\StaticTypeMapper\ValueObject\Type\SimpleStaticType('Symfony\\Component\\OptionsResolver\\OptionsResolver')), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\OptionsResolver\\OptionsResolver', 'setAllowedTypes', new \Rector\StaticTypeMapper\ValueObject\Type\SimpleStaticType('Symfony\\Component\\OptionsResolver\\OptionsResolver')), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\OptionsResolver\\OptionsResolver', 'addAllowedTypes', new \Rector\StaticTypeMapper\ValueObject\Type\SimpleStaticType('Symfony\\Component\\OptionsResolver\\OptionsResolver')), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\PropertyAccess\\PropertyPathInterface', 'getLength', new \PHPStan\Type\IntegerType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\PropertyAccess\\PropertyPathInterface', 'getParent', new \PHPStan\Type\UnionType([new \PHPStan\Type\NullType(), new \PHPStan\Type\ObjectType('Symfony\\Component\\PropertyAccess\\PropertyPathInterface')])), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\PropertyAccess\\PropertyPathInterface', 'getElements', $arrayType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\PropertyAccess\\PropertyPathInterface', 'getElement', new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\PropertyAccess\\PropertyPathInterface', 'isProperty', new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\PropertyAccess\\PropertyPathInterface', 'isIndex', new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\PropertyInfo\\PropertyAccessExtractorInterface', 'isReadable', $nullableBooleanType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\PropertyInfo\\PropertyAccessExtractorInterface', 'isWritable', $nullableBooleanType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\PropertyInfo\\PropertyListExtractorInterface', 'getProperties', $nullableArrayType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\PropertyInfo\\PropertyTypeExtractorInterface', 'getTypes', $nullableArrayType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Routing\\Loader\\AnnotationClassLoader', 'getDefaultRouteName', new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Routing\\Router', 'getRouteCollection', $routeCollectionType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Routing\\RouterInterface', 'getRouteCollection', $routeCollectionType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Security\\Core\\Authentication\\RememberMe\\TokenProviderInterface', 'loadTokenBySeries', new \PHPStan\Type\ObjectType('Symfony\\Component\\Security\\Core\\Authentication\\RememberMe\\PersistentTokenInterface')), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface', 'vote', new \PHPStan\Type\IntegerType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Security\\Core\\Exception\\AuthenticationException', 'getMessageKey', new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface', 'refreshUser', new \PHPStan\Type\ObjectType('Symfony\\Component\\Security\\Core\\User\\UserInterface')), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface', 'supportsClass', new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Security\\Http\\EntryPoint\\AuthenticationEntryPointInterface', 'start', $httpFoundationResponseType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Security\\Http\\Firewall', 'getSubscribedEvents', $arrayType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Security\\Http\\FirewallMapInterface', 'getListeners', $arrayType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Encoder\\DecoderInterface', 'decode', new \PHPStan\Type\MixedType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Encoder\\DecoderInterface', 'supportsDecoding', new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\AbstractNormalizer', 'getAllowedAttributes', new \PHPStan\Type\UnionType([$arrayType, new \PHPStan\Type\BooleanType()])), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\AbstractNormalizer', 'isAllowedAttribute', new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\AbstractNormalizer', 'instantiateObject', new \PHPStan\Type\ObjectWithoutClassType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer', 'supportsNormalization', new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer', 'instantiateObject', new \PHPStan\Type\ObjectWithoutClassType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer', 'extractAttributes', $arrayType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer', 'getAttributeValue', new \PHPStan\Type\MixedType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer', 'supportsDenormalization', new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer', 'denormalize', new \PHPStan\Type\MixedType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\DenormalizerInterface', 'denormalize', new \PHPStan\Type\MixedType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\DenormalizerInterface', 'supportsDenormalization', new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface', 'supportsNormalization', new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Templating\\Helper\\HelperInterface', 'getName', new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Translation\\Extractor\\AbstractFileExtractor', 'canBeExtracted', new \PHPStan\Type\BooleanType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Translation\\Extractor\\AbstractFileExtractor', 'extractFromDirectory', $iterableType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Validator\\Constraint', 'getDefaultOption', $nullableStringType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Validator\\Constraint', 'getRequiredOptions', $arrayType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Validator\\Constraint', 'validatedBy', new \PHPStan\Type\StringType()), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Validator\\Constraint', 'getTargets', new \PHPStan\Type\UnionType([new \PHPStan\Type\StringType(), $arrayType])), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer', 'normalize', $scalarArrayObjectUnionType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\Container', 'getParameter', new \PHPStan\Type\UnionType($scalarTypes)), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\ContainerInterface', 'getParameter', new \PHPStan\Type\UnionType($scalarTypes)), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface', 'normalize', $scalarArrayObjectUnionType), - new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Symfony\\Component\\Security\\Http\\Authenticator\\AuthenticatorInterface', 'authenticate', new \PHPStan\Type\ObjectType('Symfony\\Component\\Security\\Http\\Authenticator\\Passport\\Passport')), + new AddReturnTypeDeclaration('Symfony\\Component\\Console\\Helper\\HelperInterface', 'getName', new StringType()), + new AddReturnTypeDeclaration('Symfony\\Component\\BrowserKit\\AbstractBrowser', 'doRequestInProcess', new ObjectWithoutClassType()), + new AddReturnTypeDeclaration('Symfony\\Component\\BrowserKit\\AbstractBrowser', 'doRequest', new ObjectWithoutClassType()), + new AddReturnTypeDeclaration('Symfony\\Component\\BrowserKit\\AbstractBrowser', 'filterRequest', new ObjectWithoutClassType()), + new AddReturnTypeDeclaration('Symfony\\Component\\BrowserKit\\AbstractBrowser', 'filterResponse', $browserKitResponseType), + new AddReturnTypeDeclaration('Symfony\\Component\\Config\\Definition\\ConfigurationInterface', 'getConfigTreeBuilder', new ObjectType('Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder')), + new AddReturnTypeDeclaration('Symfony\\Component\\Config\\FileLocator', 'locate', new UnionType([new StringType(), $arrayType])), + new AddReturnTypeDeclaration('Symfony\\Component\\Config\\FileLocatorInterface', 'locate', new UnionType([new StringType(), $arrayType])), + new AddReturnTypeDeclaration('Symfony\\Component\\Config\\Loader\\FileLoader', 'import', new MixedType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Config\\Loader\\Loader', 'import', new MixedType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Config\\Loader\\LoaderInterface', 'load', new MixedType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Config\\Loader\\LoaderInterface', 'supports', new BooleanType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Config\\Loader\\LoaderInterface', 'getResolver', new ObjectType('Symfony\\Component\\Config\\Loader\\LoaderResolverInterface')), + new AddReturnTypeDeclaration('Symfony\\Component\\Config\\ResourceCheckerInterface', 'supports', new BooleanType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Config\\ResourceCheckerInterface', 'isFresh', new BooleanType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Console\\Application', 'doRun', new IntegerType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Console\\Application', 'getLongVersion', new StringType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Console\\Application', 'add', new UnionType([new NullType(), $commandType])), + new AddReturnTypeDeclaration('Symfony\\Component\\Console\\Application', 'get', $commandType), + new AddReturnTypeDeclaration('Symfony\\Component\\Console\\Application', 'find', $commandType), + new AddReturnTypeDeclaration('Symfony\\Component\\Console\\Application', 'all', $arrayType), + new AddReturnTypeDeclaration('Symfony\\Component\\Console\\Application', 'doRunCommand', new IntegerType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'isEnabled', new BooleanType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Console\\Command\\Command', 'execute', new IntegerType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Console\\Helper\\HelperInterface', 'getName', new StringType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Console\\Input\\InputInterface', 'getParameterOption', new MixedType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Console\\Input\\InputInterface', 'getArgument', new MixedType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Console\\Input\\InputInterface', 'getOption', new MixedType()), + new AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\Compiler\\AbstractRecursivePass', 'processValue', new MixedType()), + new AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\Extension\\ConfigurationExtensionInterface', 'getConfiguration', new UnionType([new NullType(), $configurationType])), + new AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\Extension\\Extension', 'getXsdValidationBasePath', new UnionType([new StringType(), new ConstantBooleanType(\false)])), + new AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\Extension\\Extension', 'getNamespace', new StringType()), + new AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\Extension\\Extension', 'getConfiguration', new UnionType([new NullType(), $configurationType])), + new AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface', 'getNamespace', new StringType()), + new AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface', 'getXsdValidationBasePath', new UnionType([new StringType(), new ConstantBooleanType(\false)])), + new AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface', 'getAlias', new StringType()), + new AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\LazyProxy\\Instantiator\\InstantiatorInterface', 'instantiateProxy', new ObjectWithoutClassType()), + new AddReturnTypeDeclaration('Symfony\\Component\\EventDispatcher\\EventSubscriberInterface', 'getSubscribedEvents', $arrayType), + new AddReturnTypeDeclaration('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface', 'getFunctions', $arrayType), + new AddReturnTypeDeclaration('Symfony\\Component\\Form\\AbstractExtension', 'loadTypes', $arrayType), + new AddReturnTypeDeclaration('Symfony\\Component\\Form\\AbstractExtension', 'loadTypeGuesser', new UnionType([new NullType(), new ObjectType('Symfony\\Component\\Form\\FormTypeGuesserInterface')])), + new AddReturnTypeDeclaration('Symfony\\Component\\Form\\AbstractRendererEngine', 'loadResourceForBlockName', new BooleanType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Form\\AbstractType', 'getBlockPrefix', new StringType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Form\\AbstractType', 'getParent', $nullableStringType), + new AddReturnTypeDeclaration('Symfony\\Component\\Form\\DataTransformerInterface', 'transform', new MixedType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Form\\DataTransformerInterface', 'reverseTransform', new MixedType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Form\\FormRendererEngineInterface', 'renderBlock', new StringType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Form\\FormTypeGuesserInterface', 'guessType', new UnionType([new NullType(), $typeGuessType])), + new AddReturnTypeDeclaration('Symfony\\Component\\Form\\FormTypeGuesserInterface', 'guessRequired', $nullableValueGuessType), + new AddReturnTypeDeclaration('Symfony\\Component\\Form\\FormTypeGuesserInterface', 'guessMaxLength', $nullableValueGuessType), + new AddReturnTypeDeclaration('Symfony\\Component\\Form\\FormTypeGuesserInterface', 'guessPattern', $nullableValueGuessType), + new AddReturnTypeDeclaration('Symfony\\Component\\Form\\FormTypeInterface', 'getBlockPrefix', new StringType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Form\\FormTypeInterface', 'getParent', $nullableStringType), + new AddReturnTypeDeclaration('Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmerInterface', 'isOptional', new BooleanType()), + new AddReturnTypeDeclaration('Symfony\\Component\\HttpKernel\\CacheWarmer\\WarmableInterface', 'warmUp', $arrayType), + new AddReturnTypeDeclaration('Symfony\\Component\\HttpKernel\\DataCollector\\DataCollector', 'getCasters', $arrayType), + new AddReturnTypeDeclaration('Symfony\\Component\\HttpKernel\\DataCollector\\DataCollectorInterface', 'getName', new StringType()), + new AddReturnTypeDeclaration('Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache', 'forward', $httpFoundationResponseType), + new AddReturnTypeDeclaration('Symfony\\Component\\HttpKernel\\HttpKernelBrowser', 'doRequest', $httpFoundationResponseType), + new AddReturnTypeDeclaration('Symfony\\Component\\HttpKernel\\HttpKernelBrowser', 'getScript', new StringType()), + new AddReturnTypeDeclaration('Symfony\\Component\\HttpKernel\\Log\\DebugLoggerInterface', 'getLogs', $arrayType), + new AddReturnTypeDeclaration('Symfony\\Component\\HttpKernel\\Log\\DebugLoggerInterface', 'countErrors', new IntegerType()), + new AddReturnTypeDeclaration('Symfony\\Component\\OptionsResolver\\OptionsResolver', 'setNormalizer', new SimpleStaticType('Symfony\\Component\\OptionsResolver\\OptionsResolver')), + new AddReturnTypeDeclaration('Symfony\\Component\\OptionsResolver\\OptionsResolver', 'setAllowedValues', new SimpleStaticType('Symfony\\Component\\OptionsResolver\\OptionsResolver')), + new AddReturnTypeDeclaration('Symfony\\Component\\OptionsResolver\\OptionsResolver', 'addAllowedValues', new SimpleStaticType('Symfony\\Component\\OptionsResolver\\OptionsResolver')), + new AddReturnTypeDeclaration('Symfony\\Component\\OptionsResolver\\OptionsResolver', 'setAllowedTypes', new SimpleStaticType('Symfony\\Component\\OptionsResolver\\OptionsResolver')), + new AddReturnTypeDeclaration('Symfony\\Component\\OptionsResolver\\OptionsResolver', 'addAllowedTypes', new SimpleStaticType('Symfony\\Component\\OptionsResolver\\OptionsResolver')), + new AddReturnTypeDeclaration('Symfony\\Component\\PropertyAccess\\PropertyPathInterface', 'getLength', new IntegerType()), + new AddReturnTypeDeclaration('Symfony\\Component\\PropertyAccess\\PropertyPathInterface', 'getParent', new UnionType([new NullType(), new ObjectType('Symfony\\Component\\PropertyAccess\\PropertyPathInterface')])), + new AddReturnTypeDeclaration('Symfony\\Component\\PropertyAccess\\PropertyPathInterface', 'getElements', $arrayType), + new AddReturnTypeDeclaration('Symfony\\Component\\PropertyAccess\\PropertyPathInterface', 'getElement', new StringType()), + new AddReturnTypeDeclaration('Symfony\\Component\\PropertyAccess\\PropertyPathInterface', 'isProperty', new BooleanType()), + new AddReturnTypeDeclaration('Symfony\\Component\\PropertyAccess\\PropertyPathInterface', 'isIndex', new BooleanType()), + new AddReturnTypeDeclaration('Symfony\\Component\\PropertyInfo\\PropertyAccessExtractorInterface', 'isReadable', $nullableBooleanType), + new AddReturnTypeDeclaration('Symfony\\Component\\PropertyInfo\\PropertyAccessExtractorInterface', 'isWritable', $nullableBooleanType), + new AddReturnTypeDeclaration('Symfony\\Component\\PropertyInfo\\PropertyListExtractorInterface', 'getProperties', $nullableArrayType), + new AddReturnTypeDeclaration('Symfony\\Component\\PropertyInfo\\PropertyTypeExtractorInterface', 'getTypes', $nullableArrayType), + new AddReturnTypeDeclaration('Symfony\\Component\\Routing\\Loader\\AnnotationClassLoader', 'getDefaultRouteName', new StringType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Routing\\Router', 'getRouteCollection', $routeCollectionType), + new AddReturnTypeDeclaration('Symfony\\Component\\Routing\\RouterInterface', 'getRouteCollection', $routeCollectionType), + new AddReturnTypeDeclaration('Symfony\\Component\\Security\\Core\\Authentication\\RememberMe\\TokenProviderInterface', 'loadTokenBySeries', new ObjectType('Symfony\\Component\\Security\\Core\\Authentication\\RememberMe\\PersistentTokenInterface')), + new AddReturnTypeDeclaration('Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface', 'vote', new IntegerType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Security\\Core\\Exception\\AuthenticationException', 'getMessageKey', new StringType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface', 'refreshUser', new ObjectType('Symfony\\Component\\Security\\Core\\User\\UserInterface')), + new AddReturnTypeDeclaration('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface', 'supportsClass', new BooleanType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Security\\Http\\EntryPoint\\AuthenticationEntryPointInterface', 'start', $httpFoundationResponseType), + new AddReturnTypeDeclaration('Symfony\\Component\\Security\\Http\\Firewall', 'getSubscribedEvents', $arrayType), + new AddReturnTypeDeclaration('Symfony\\Component\\Security\\Http\\FirewallMapInterface', 'getListeners', $arrayType), + new AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Encoder\\DecoderInterface', 'decode', new MixedType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Encoder\\DecoderInterface', 'supportsDecoding', new BooleanType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\AbstractNormalizer', 'getAllowedAttributes', new UnionType([$arrayType, new BooleanType()])), + new AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\AbstractNormalizer', 'isAllowedAttribute', new BooleanType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\AbstractNormalizer', 'instantiateObject', new ObjectWithoutClassType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer', 'supportsNormalization', new BooleanType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer', 'instantiateObject', new ObjectWithoutClassType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer', 'extractAttributes', $arrayType), + new AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer', 'getAttributeValue', new MixedType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer', 'supportsDenormalization', new BooleanType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer', 'denormalize', new MixedType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\DenormalizerInterface', 'denormalize', new MixedType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\DenormalizerInterface', 'supportsDenormalization', new BooleanType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface', 'supportsNormalization', new BooleanType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Templating\\Helper\\HelperInterface', 'getName', new StringType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Translation\\Extractor\\AbstractFileExtractor', 'canBeExtracted', new BooleanType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Translation\\Extractor\\AbstractFileExtractor', 'extractFromDirectory', $iterableType), + new AddReturnTypeDeclaration('Symfony\\Component\\Validator\\Constraint', 'getDefaultOption', $nullableStringType), + new AddReturnTypeDeclaration('Symfony\\Component\\Validator\\Constraint', 'getRequiredOptions', $arrayType), + new AddReturnTypeDeclaration('Symfony\\Component\\Validator\\Constraint', 'validatedBy', new StringType()), + new AddReturnTypeDeclaration('Symfony\\Component\\Validator\\Constraint', 'getTargets', new UnionType([new StringType(), $arrayType])), + new AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer', 'normalize', $scalarArrayObjectUnionType), + new AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\Container', 'getParameter', new UnionType($scalarTypes)), + new AddReturnTypeDeclaration('Symfony\\Component\\DependencyInjection\\ContainerInterface', 'getParameter', new UnionType($scalarTypes)), + new AddReturnTypeDeclaration('Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface', 'normalize', $scalarArrayObjectUnionType), + new AddReturnTypeDeclaration('Symfony\\Component\\Security\\Http\\Authenticator\\AuthenticatorInterface', 'authenticate', new ObjectType('Symfony\\Component\\Security\\Http\\Authenticator\\Passport\\Passport')), ]); }; diff --git a/vendor/rector/rector-symfony/config/sets/symfony/symfony60.php b/vendor/rector/rector-symfony/config/sets/symfony/symfony60.php index 10d6a3b7026..338b647a6d0 100644 --- a/vendor/rector/rector-symfony/config/sets/symfony/symfony60.php +++ b/vendor/rector/rector-symfony/config/sets/symfony/symfony60.php @@ -17,21 +17,21 @@ use Rector\Symfony\ValueObject\ReplaceServiceArgument; use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector; use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration; # https://github.com/symfony/symfony/blob/6.1/UPGRADE-6.0.md -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->sets([\Rector\Symfony\Set\SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->sets([SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES]); $rectorConfig->import(__DIR__ . '/symfony6/symfony-return-types.php'); - $rectorConfig->ruleWithConfiguration(\Rector\Symfony\Rector\FuncCall\ReplaceServiceArgumentRector::class, [new \Rector\Symfony\ValueObject\ReplaceServiceArgument('Psr\\Container\\ContainerInterface', new \PhpParser\Node\Scalar\String_('service_container')), new \Rector\Symfony\ValueObject\ReplaceServiceArgument('Symfony\\Component\\DependencyInjection\\ContainerInterface', new \PhpParser\Node\Scalar\String_('service_container'))]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, [ + $rectorConfig->ruleWithConfiguration(ReplaceServiceArgumentRector::class, [new ReplaceServiceArgument('Psr\\Container\\ContainerInterface', new String_('service_container')), new ReplaceServiceArgument('Symfony\\Component\\DependencyInjection\\ContainerInterface', new String_('service_container'))]); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ // @see https://github.com/symfony/symfony/pull/39484 'Symfony\\Contracts\\HttpClient\\HttpClientInterface\\RemoteJsonManifestVersionStrategy' => 'Symfony\\Component\\Asset\\VersionStrategy\\JsonManifestVersionStrategy', ]); - $rectorConfig->ruleWithConfiguration(\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::class, [new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Component\\Config\\Loader\\LoaderInterface', 'load', 0, new \PHPStan\Type\MixedType()), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Symfony\\Bundle\\FrameworkBundle\\Kernel\\MicroKernelTrait', 'configureRoutes', 0, new \PHPStan\Type\ObjectType('Symfony\\Component\\Routing\\Loader\\Configurator\\RoutingConfigurator'))]); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [ + $rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [new AddParamTypeDeclaration('Symfony\\Component\\Config\\Loader\\LoaderInterface', 'load', 0, new MixedType()), new AddParamTypeDeclaration('Symfony\\Bundle\\FrameworkBundle\\Kernel\\MicroKernelTrait', 'configureRoutes', 0, new ObjectType('Symfony\\Component\\Routing\\Loader\\Configurator\\RoutingConfigurator'))]); + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ // @see https://github.com/symfony/symfony/pull/40403 - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Bridge\\Doctrine\\Security\\User\\UserLoaderInterface', 'loadUserByUsername', 'loadUserByIdentifier'), - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface', 'loadUserByUsername', 'loadUserByIdentifier'), + new MethodCallRename('Symfony\\Bridge\\Doctrine\\Security\\User\\UserLoaderInterface', 'loadUserByUsername', 'loadUserByIdentifier'), + new MethodCallRename('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface', 'loadUserByUsername', 'loadUserByIdentifier'), // @see https://github.com/rectorphp/rector-symfony/issues/112 - new \Rector\Renaming\ValueObject\MethodCallRename('Symfony\\Component\\Security\\Core\\User\\UserInterface', 'getUsername', 'getUserIdentifier'), + new MethodCallRename('Symfony\\Component\\Security\\Core\\User\\UserInterface', 'getUsername', 'getUserIdentifier'), ]); - $rectorConfig->rule(\Rector\Symfony\Rector\MethodCall\GetHelperControllerToServiceRector::class); + $rectorConfig->rule(GetHelperControllerToServiceRector::class); }; diff --git a/vendor/rector/rector-symfony/config/sets/twig/twig-underscore-to-namespace.php b/vendor/rector/rector-symfony/config/sets/twig/twig-underscore-to-namespace.php index 0727e1d8f98..90f7b19295e 100644 --- a/vendor/rector/rector-symfony/config/sets/twig/twig-underscore-to-namespace.php +++ b/vendor/rector/rector-symfony/config/sets/twig/twig-underscore-to-namespace.php @@ -7,9 +7,9 @@ use Rector\Config\RectorConfig; use Rector\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector; use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Renaming\ValueObject\PseudoNamespaceToNamespace; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $renamedClasses = ['Twig_LoaderInterface' => 'Twig\\Loader\\LoaderInterface', 'Twig_Extension_StringLoader' => 'Twig\\Extension\\StringLoaderExtension', 'Twig_Extension_Optimizer' => 'Twig\\Extension\\OptimizerExtension', 'Twig_Extension_Debug' => 'Twig\\Extension\\DebugExtension', 'Twig_Extension_Sandbox' => 'Twig\\Extension\\SandboxExtension', 'Twig_Extension_Profiler' => 'Twig\\Extension\\ProfilerExtension', 'Twig_Extension_Escaper' => 'Twig\\Extension\\EscaperExtension', 'Twig_Extension_Staging' => 'Twig\\Extension\\StagingExtension', 'Twig_Extension_Core' => 'Twig\\Extension\\CoreExtension', 'Twig_Node' => 'Twig\\Node\\Node', 'Twig_NodeVisitor_Optimizer' => 'Twig\\NodeVisitor\\OptimizerNodeVisitor', 'Twig_NodeVisitor_SafeAnalysis' => 'Twig\\NodeVisitor\\SafeAnalysisNodeVisitor', 'Twig_NodeVisitor_Sandbox' => 'Twig\\NodeVisitor\\SandboxNodeVisitor', 'Twig_NodeVisitor_Escaper' => 'Twig\\NodeVisitor\\EscaperNodeVisitor', 'Twig_SimpleFunction' => 'Twig\\TwigFunction', 'Twig_Function' => 'Twig\\TwigFunction', 'Twig_Error_Syntax' => 'Twig\\Error\\SyntaxError', 'Twig_Error_Loader' => 'Twig\\Error\\LoaderError', 'Twig_Error_Runtime' => 'Twig\\Error\\RuntimeError', 'Twig_TokenParser' => 'Twig\\TokenParser\\AbstractTokenParser', 'Twig_TokenParserInterface' => 'Twig\\TokenParser\\TokenParserInterface', 'Twig_CacheInterface' => 'Twig\\Cache\\CacheInterface', 'Twig_NodeVisitorInterface' => 'Twig\\NodeVisitor\\NodeVisitorInterface', 'Twig_Profiler_NodeVisitor_Profiler' => 'Twig\\Profiler\\NodeVisitor\\ProfilerNodeVisitor', 'Twig_Profiler_Dumper_Text' => 'Twig\\Profiler\\Dumper\\TextDumper', 'Twig_Profiler_Dumper_Base' => 'Twig\\Profiler\\Dumper\\BaseDumper', 'Twig_Profiler_Dumper_Blackfire' => 'Twig\\Profiler\\Dumper\\BlackfireDumper', 'Twig_Profiler_Dumper_Html' => 'Twig\\Profiler\\Dumper\\HtmlDumper', 'Twig_Profiler_Node_LeaveProfile' => 'Twig\\Profiler\\Node\\LeaveProfileNode', 'Twig_Profiler_Node_EnterProfile' => 'Twig\\Profiler\\Node\\EnterProfileNode', 'Twig_Error' => 'Twig\\Error\\Error', 'Twig_ExistsLoaderInterface' => 'Twig\\Loader\\ExistsLoaderInterface', 'Twig_SimpleTest' => 'Twig\\TwigTest', 'Twig_Test' => 'Twig\\TwigTest', 'Twig_FactoryRuntimeLoader' => 'Twig\\RuntimeLoader\\FactoryRuntimeLoader', 'Twig_NodeOutputInterface' => 'Twig\\Node\\NodeOutputInterface', 'Twig_SimpleFilter' => 'Twig\\TwigFilter', 'Twig_Filter' => 'Twig\\TwigFilter', 'Twig_Loader_Chain' => 'Twig\\Loader\\ChainLoader', 'Twig_Loader_Array' => 'Twig\\Loader\\ArrayLoader', 'Twig_Loader_Filesystem' => 'Twig\\Loader\\FilesystemLoader', 'Twig_Cache_Null' => 'Twig\\Cache\\NullCache', 'Twig_Cache_Filesystem' => 'Twig\\Cache\\FilesystemCache', 'Twig_NodeCaptureInterface' => 'Twig\\Node\\NodeCaptureInterface', 'Twig_Extension' => 'Twig\\Extension\\AbstractExtension', 'Twig_TokenParser_Macro' => 'Twig\\TokenParser\\MacroTokenParser', 'Twig_TokenParser_Embed' => 'Twig\\TokenParser\\EmbedTokenParser', 'Twig_TokenParser_Do' => 'Twig\\TokenParser\\DoTokenParser', 'Twig_TokenParser_From' => 'Twig\\TokenParser\\FromTokenParser', 'Twig_TokenParser_Extends' => 'Twig\\TokenParser\\ExtendsTokenParser', 'Twig_TokenParser_Set' => 'Twig\\TokenParser\\SetTokenParser', 'Twig_TokenParser_Sandbox' => 'Twig\\TokenParser\\SandboxTokenParser', 'Twig_TokenParser_AutoEscape' => 'Twig\\TokenParser\\AutoEscapeTokenParser', 'Twig_TokenParser_With' => 'Twig\\TokenParser\\WithTokenParser', 'Twig_TokenParser_Include' => 'Twig\\TokenParser\\IncludeTokenParser', 'Twig_TokenParser_Block' => 'Twig\\TokenParser\\BlockTokenParser', 'Twig_TokenParser_Filter' => 'Twig\\TokenParser\\FilterTokenParser', 'Twig_TokenParser_If' => 'Twig\\TokenParser\\IfTokenParser', 'Twig_TokenParser_For' => 'Twig\\TokenParser\\ForTokenParser', 'Twig_TokenParser_Flush' => 'Twig\\TokenParser\\FlushTokenParser', 'Twig_TokenParser_Spaceless' => 'Twig\\TokenParser\\SpacelessTokenParser', 'Twig_TokenParser_Use' => 'Twig\\TokenParser\\UseTokenParser', 'Twig_TokenParser_Import' => 'Twig\\TokenParser\\ImportTokenParser', 'Twig_ContainerRuntimeLoader' => 'Twig\\RuntimeLoader\\ContainerRuntimeLoader', 'Twig_SourceContextLoaderInterface' => 'Twig\\Loader\\SourceContextLoaderInterface', 'Twig_NodeTraverser' => 'Twig\\NodeTraverser', 'Twig_ExtensionInterface' => 'Twig\\Extension\\ExtensionInterface', 'Twig_Node_Macro' => 'Twig\\Node\\MacroNode', 'Twig_Node_Embed' => 'Twig\\Node\\EmbedNode', 'Twig_Node_Do' => 'Twig\\Node\\DoNode', 'Twig_Node_Text' => 'Twig\\Node\\TextNode', 'Twig_Node_Set' => 'Twig\\Node\\SetNode', 'Twig_Node_Sandbox' => 'Twig\\Node\\SandboxNode', 'Twig_Node_AutoEscape' => 'Twig\\Node\\AutoEscapeNode', 'Twig_Node_With' => 'Twig\\Node\\WithNode', 'Twig_Node_Include' => 'Twig\\Node\\IncludeNode', 'Twig_Node_Print' => 'Twig\\Node\\PrintNode', 'Twig_Node_Block' => 'Twig\\Node\\BlockNode', 'Twig_Node_Expression_MethodCall' => 'Twig\\Node\\Expression\\MethodCallExpression', 'Twig_Node_Expression_Unary_Pos' => 'Twig\\Node\\Expression\\Unary\\PosUnary', 'Twig_Node_Expression_Unary_Not' => 'Twig\\Node\\Expression\\Unary\\NotUnary', 'Twig_Node_Expression_Unary_Neg' => 'Twig\\Node\\Expression\\Unary\\NegUnary', 'Twig_Node_Expression_GetAttr' => 'Twig\\Node\\Expression\\GetAttrExpression', 'Twig_Node_Expression_Function' => 'Twig\\Node\\Expression\\FunctionExpression', 'Twig_Node_Expression_Binary_Power' => 'Twig\\Node\\Expression\\Binary\\PowerBinary', 'Twig_Node_Expression_Binary_In' => 'Twig\\Node\\Expression\\Binary\\InBinary', 'Twig_Node_Expression_Binary_BitwiseXor' => 'Twig\\Node\\Expression\\Binary\\BitwiseXorBinary', 'Twig_Node_Expression_Binary_Concat' => 'Twig\\Node\\Expression\\Binary\\ConcatBinary', 'Twig_Node_Expression_Binary_NotEqual' => 'Twig\\Node\\Expression\\Binary\\NotEqualBinary', 'Twig_Node_Expression_Binary_Less' => 'Twig\\Node\\Expression\\Binary\\LessBinary', 'Twig_Node_Expression_Binary_And' => 'Twig\\Node\\Expression\\Binary\\AndBinary', 'Twig_Node_Expression_Binary_GreaterEqual' => 'Twig\\Node\\Expression\\Binary\\GreaterEqualBinary', 'Twig_Node_Expression_Binary_Mod' => 'Twig\\Node\\Expression\\Binary\\ModBinary', 'Twig_Node_Expression_Binary_NotIn' => 'Twig\\Node\\Expression\\Binary\\NotInBinary', 'Twig_Node_Expression_Binary_Add' => 'Twig\\Node\\Expression\\Binary\\AddBinary', 'Twig_Node_Expression_Binary_Matches' => 'Twig\\Node\\Expression\\Binary\\MatchesBinary', 'Twig_Node_Expression_Binary_EndsWith' => 'Twig\\Node\\Expression\\Binary\\EndsWithBinary', 'Twig_Node_Expression_Binary_FloorDiv' => 'Twig\\Node\\Expression\\Binary\\FloorDivBinary', 'Twig_Node_Expression_Binary_StartsWith' => 'Twig\\Node\\Expression\\Binary\\StartsWithBinary', 'Twig_Node_Expression_Binary_LessEqual' => 'Twig\\Node\\Expression\\Binary\\LessEqualBinary', 'Twig_Node_Expression_Binary_Equal' => 'Twig\\Node\\Expression\\Binary\\EqualBinary', 'Twig_Node_Expression_Binary_BitwiseAnd' => 'Twig\\Node\\Expression\\Binary\\BitwiseAndBinary', 'Twig_Node_Expression_Binary_Mul' => 'Twig\\Node\\Expression\\Binary\\MulBinary', 'Twig_Node_Expression_Binary_Range' => 'Twig\\Node\\Expression\\Binary\\RangeBinary', 'Twig_Node_Expression_Binary_Or' => 'Twig\\Node\\Expression\\Binary\\OrBinary', 'Twig_Node_Expression_Binary_Greater' => 'Twig\\Node\\Expression\\Binary\\GreaterBinary', 'Twig_Node_Expression_Binary_Div' => 'Twig\\Node\\Expression\\Binary\\DivBinary', 'Twig_Node_Expression_Binary_BitwiseOr' => 'Twig\\Node\\Expression\\Binary\\BitwiseOrBinary', 'Twig_Node_Expression_Binary_Sub' => 'Twig\\Node\\Expression\\Binary\\SubBinary', 'Twig_Node_Expression_Test_Even' => 'Twig\\Node\\Expression\\Test\\EvenTest', 'Twig_Node_Expression_Test_Defined' => 'Twig\\Node\\Expression\\Test\\DefinedTest', 'Twig_Node_Expression_Test_Sameas' => 'Twig\\Node\\Expression\\Test\\SameasTest', 'Twig_Node_Expression_Test_Odd' => 'Twig\\Node\\Expression\\Test\\OddTest', 'Twig_Node_Expression_Test_Constant' => 'Twig\\Node\\Expression\\Test\\ConstantTest', 'Twig_Node_Expression_Test_Null' => 'Twig\\Node\\Expression\\Test\\NullTest', 'Twig_Node_Expression_Test_Divisibleby' => 'Twig\\Node\\Expression\\Test\\DivisiblebyTest', 'Twig_Node_Expression_Array' => 'Twig\\Node\\Expression\\ArrayExpression', 'Twig_Node_Expression_Binary' => 'Twig\\Node\\Expression\\Binary\\AbstractBinary', 'Twig_Node_Expression_Constant' => 'Twig\\Node\\Expression\\ConstantExpression', 'Twig_Node_Expression_Parent' => 'Twig\\Node\\Expression\\ParentExpression', 'Twig_Node_Expression_Test' => 'Twig\\Node\\Expression\\TestExpression', 'Twig_Node_Expression_Filter_Default' => 'Twig\\Node\\Expression\\Filter\\DefaultFilter', 'Twig_Node_Expression_Filter' => 'Twig\\Node\\Expression\\FilterExpression', 'Twig_Node_Expression_BlockReference' => 'Twig\\Node\\Expression\\BlockReferenceExpression', 'Twig_Node_Expression_NullCoalesce' => 'Twig\\Node\\Expression\\NullCoalesceExpression', 'Twig_Node_Expression_Name' => 'Twig\\Node\\Expression\\NameExpression', 'Twig_Node_Expression_TempName' => 'Twig\\Node\\Expression\\TempNameExpression', 'Twig_Node_Expression_Call' => 'Twig\\Node\\Expression\\CallExpression', 'Twig_Node_Expression_Unary' => 'Twig\\Node\\Expression\\Unary\\AbstractUnary', 'Twig_Node_Expression_AssignName' => 'Twig\\Node\\Expression\\AssignNameExpression', 'Twig_Node_Expression_Conditional' => 'Twig\\Node\\Expression\\ConditionalExpression', 'Twig_Node_CheckSecurity' => 'Twig\\Node\\CheckSecurityNode', 'Twig_Node_Expression' => 'Twig\\Node\\Expression\\AbstractExpression', 'Twig_Node_ForLoop' => 'Twig\\Node\\ForLoopNode', 'Twig_Node_If' => 'Twig\\Node\\IfNode', 'Twig_Node_For' => 'Twig\\Node\\ForNode', 'Twig_Node_BlockReference' => 'Twig\\Node\\BlockReferenceNode', 'Twig_Node_Flush' => 'Twig\\Node\\FlushNode', 'Twig_Node_Body' => 'Twig\\Node\\BodyNode', 'Twig_Node_Spaceless' => 'Twig\\Node\\SpacelessNode', 'Twig_Node_Import' => 'Twig\\Node\\ImportNode', 'Twig_Node_SandboxedPrint' => 'Twig\\Node\\SandboxedPrintNode', 'Twig_Node_Module' => 'Twig\\Node\\ModuleNode', 'Twig_RuntimeLoaderInterface' => 'Twig\\RuntimeLoader\\RuntimeLoaderInterface', 'Twig_BaseNodeVisitor' => 'Twig\\NodeVisitor\\AbstractNodeVisitor', 'Twig_Extensions_Extension_Text' => 'Twig\\Extensions\\TextExtension', 'Twig_Extensions_Extension_Array' => 'Twig\\Extensions\\ArrayExtension', 'Twig_Extensions_Extension_Date' => 'Twig\\Extensions\\DateExtension', 'Twig_Extensions_Extension_I18n' => 'Twig\\Extensions\\I18nExtension', 'Twig_Extensions_Extension_Intl' => 'Twig\\Extensions\\IntlExtension', 'Twig_Extensions_TokenParser_Trans' => 'Twig\\Extensions\\TokenParser\\TransTokenParser', 'Twig_Extensions_Node_Trans' => 'Twig\\Extensions\\Node\\TransNode', 'Twig_TemplateWrapper' => 'Twig\\TemplateWrapper', 'Twig_NodeInterface' => 'Twig\\Node\\Node']; - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, $renamedClasses); + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, $renamedClasses); $oldClasses = \array_keys($renamedClasses); - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector::class, [new \Rector\Renaming\ValueObject\PseudoNamespaceToNamespace('Twig_', $oldClasses)]); + $rectorConfig->ruleWithConfiguration(PseudoNamespaceToNamespaceRector::class, [new PseudoNamespaceToNamespace('Twig_', $oldClasses)]); }; diff --git a/vendor/rector/rector-symfony/config/sets/twig/twig112.php b/vendor/rector/rector-symfony/config/sets/twig/twig112.php index 68fd9ad754f..b6af8c21a15 100644 --- a/vendor/rector/rector-symfony/config/sets/twig/twig112.php +++ b/vendor/rector/rector-symfony/config/sets/twig/twig112.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Renaming\Rector\Name\RenameClassRector; # see https://stackoverflow.com/a/43495506/1348344 -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, ['Twig_Function_Node' => 'Twig_SimpleFunction', 'Twig_Function' => 'Twig_SimpleFunction', 'Twig_Filter' => 'Twig_SimpleFilter', 'Twig_Test' => 'Twig_SimpleTest']); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Twig_Function_Node' => 'Twig_SimpleFunction', 'Twig_Function' => 'Twig_SimpleFunction', 'Twig_Filter' => 'Twig_SimpleFilter', 'Twig_Test' => 'Twig_SimpleTest']); }; diff --git a/vendor/rector/rector-symfony/config/sets/twig/twig127.php b/vendor/rector/rector-symfony/config/sets/twig/twig127.php index 9434e5d10c0..fc5fe5309de 100644 --- a/vendor/rector/rector-symfony/config/sets/twig/twig127.php +++ b/vendor/rector/rector-symfony/config/sets/twig/twig127.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Renaming\Rector\MethodCall\RenameMethodRector; use Rector\Renaming\ValueObject\MethodCallRename; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Twig_Node', 'getLine', 'getTemplateLine'), new \Rector\Renaming\ValueObject\MethodCallRename('Twig_Node', 'getFilename', 'getTemplateName'), new \Rector\Renaming\ValueObject\MethodCallRename('Twig_Template', 'getSource', 'getSourceContext'), new \Rector\Renaming\ValueObject\MethodCallRename('Twig_Error', 'getTemplateFile', 'getTemplateName'), new \Rector\Renaming\ValueObject\MethodCallRename('Twig_Error', 'getTemplateName', 'setTemplateName')]); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Twig_Node', 'getLine', 'getTemplateLine'), new MethodCallRename('Twig_Node', 'getFilename', 'getTemplateName'), new MethodCallRename('Twig_Template', 'getSource', 'getSourceContext'), new MethodCallRename('Twig_Error', 'getTemplateFile', 'getTemplateName'), new MethodCallRename('Twig_Error', 'getTemplateName', 'setTemplateName')]); }; diff --git a/vendor/rector/rector-symfony/config/sets/twig/twig134.php b/vendor/rector/rector-symfony/config/sets/twig/twig134.php index b86282d079f..16e1f95ca16 100644 --- a/vendor/rector/rector-symfony/config/sets/twig/twig134.php +++ b/vendor/rector/rector-symfony/config/sets/twig/twig134.php @@ -5,6 +5,6 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Symfony\Rector\Return_\SimpleFunctionAndFilterRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->rule(\Rector\Symfony\Rector\Return_\SimpleFunctionAndFilterRector::class); +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->rule(SimpleFunctionAndFilterRector::class); }; diff --git a/vendor/rector/rector-symfony/config/sets/twig/twig140.php b/vendor/rector/rector-symfony/config/sets/twig/twig140.php index e5b507dc368..93e763ebd6b 100644 --- a/vendor/rector/rector-symfony/config/sets/twig/twig140.php +++ b/vendor/rector/rector-symfony/config/sets/twig/twig140.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace RectorPrefix20220607; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $rectorConfig->import(__DIR__ . '/twig-underscore-to-namespace.php'); }; diff --git a/vendor/rector/rector-symfony/config/sets/twig/twig20.php b/vendor/rector/rector-symfony/config/sets/twig/twig20.php index 1ae5d00ba8f..c66d5c405f8 100644 --- a/vendor/rector/rector-symfony/config/sets/twig/twig20.php +++ b/vendor/rector/rector-symfony/config/sets/twig/twig20.php @@ -5,8 +5,8 @@ namespace RectorPrefix20220607; use Rector\Config\RectorConfig; use Rector\Renaming\Rector\Name\RenameClassRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { - $rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\Name\RenameClassRector::class, [ +return static function (RectorConfig $rectorConfig) : void { + $rectorConfig->ruleWithConfiguration(RenameClassRector::class, [ #filters # see https://twig.symfony.com/doc/1.x/deprecated.html 'Twig_SimpleFilter' => 'Twig_Filter', diff --git a/vendor/rector/rector-symfony/config/sets/twig/twig240.php b/vendor/rector/rector-symfony/config/sets/twig/twig240.php index e5b507dc368..93e763ebd6b 100644 --- a/vendor/rector/rector-symfony/config/sets/twig/twig240.php +++ b/vendor/rector/rector-symfony/config/sets/twig/twig240.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace RectorPrefix20220607; use Rector\Config\RectorConfig; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $rectorConfig->import(__DIR__ . '/twig-underscore-to-namespace.php'); }; diff --git a/vendor/rector/rector-symfony/easy-ci.php b/vendor/rector/rector-symfony/easy-ci.php index 32d5e462a3e..c69b267838a 100644 --- a/vendor/rector/rector-symfony/easy-ci.php +++ b/vendor/rector/rector-symfony/easy-ci.php @@ -6,8 +6,8 @@ namespace RectorPrefix20220607; use Rector\Core\Contract\Rector\RectorInterface; use Rector\Set\Contract\SetListInterface; use Rector\Symfony\Contract\Bridge\Symfony\Routing\SymfonyRoutesProviderInterface; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +return static function (ContainerConfigurator $containerConfigurator) : void { $parameters = $containerConfigurator->parameters(); - $parameters->set('types_to_skip', [\Rector\Symfony\Contract\Bridge\Symfony\Routing\SymfonyRoutesProviderInterface::class, \Rector\Set\Contract\SetListInterface::class, \Rector\Core\Contract\Rector\RectorInterface::class]); + $parameters->set('types_to_skip', [SymfonyRoutesProviderInterface::class, SetListInterface::class, RectorInterface::class]); }; diff --git a/vendor/rector/rector-symfony/rector.php b/vendor/rector/rector-symfony/rector.php index 347c4ebfbd3..83124aff327 100644 --- a/vendor/rector/rector-symfony/rector.php +++ b/vendor/rector/rector-symfony/rector.php @@ -9,7 +9,7 @@ use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; use Rector\Symfony\Set\SymfonySetList; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector; -return static function (\Rector\Config\RectorConfig $rectorConfig) : void { +return static function (RectorConfig $rectorConfig) : void { $rectorConfig->importNames(); $rectorConfig->paths([__DIR__ . '/src', __DIR__ . '/tests']); $rectorConfig->parallel(); @@ -18,15 +18,15 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { '*/Source/*', '*/Source*/*', '*/tests/*/Fixture*/Expected/*', - \Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class => [__DIR__ . '/config'], + StringClassNameToClassConstantRector::class => [__DIR__ . '/config'], \Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class => [ // "data" => "datum" false positive __DIR__ . '/src/Rector/ClassMethod/AddRouteAnnotationRector.php', ], // marked as skipped - \Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector::class => ['*/tests/*'], + ReturnNeverTypeRector::class => ['*/tests/*'], ]); - $rectorConfig->ruleWithConfiguration(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class, [ + $rectorConfig->ruleWithConfiguration(StringClassNameToClassConstantRector::class, [ 'Symfony\\*', 'Twig_*', 'Swift_*', @@ -38,5 +38,5 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void { ]); // for testing $rectorConfig->import(__DIR__ . '/config/config.php'); - $rectorConfig->sets([\Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_81, \Rector\Set\ValueObject\SetList::CODE_QUALITY, \Rector\Set\ValueObject\SetList::DEAD_CODE, \Rector\Set\ValueObject\SetList::NAMING, \Rector\Symfony\Set\SymfonySetList::SYMFONY_60]); + $rectorConfig->sets([LevelSetList::UP_TO_PHP_81, SetList::CODE_QUALITY, SetList::DEAD_CODE, SetList::NAMING, SymfonySetList::SYMFONY_60]); }; diff --git a/vendor/rector/rector-symfony/src/ApplicationMetadata/ListenerServiceDefinitionProvider.php b/vendor/rector/rector-symfony/src/ApplicationMetadata/ListenerServiceDefinitionProvider.php index 456a80c5b54..769006fd16d 100644 --- a/vendor/rector/rector-symfony/src/ApplicationMetadata/ListenerServiceDefinitionProvider.php +++ b/vendor/rector/rector-symfony/src/ApplicationMetadata/ListenerServiceDefinitionProvider.php @@ -27,7 +27,7 @@ final class ListenerServiceDefinitionProvider * @var \Rector\Symfony\DataProvider\ServiceMapProvider */ private $serviceMapProvider; - public function __construct(\Rector\Symfony\DataProvider\ServiceMapProvider $serviceMapProvider) + public function __construct(ServiceMapProvider $serviceMapProvider) { $this->serviceMapProvider = $serviceMapProvider; } @@ -43,11 +43,11 @@ final class ListenerServiceDefinitionProvider $eventListeners = $serviceMap->getServicesByTag('kernel.event_listener'); foreach ($eventListeners as $eventListener) { // skip Symfony core listeners - if (\Rector\Core\Util\StringUtils::isMatch((string) $eventListener->getClass(), self::SYMFONY_FAMILY_REGEX)) { + if (StringUtils::isMatch((string) $eventListener->getClass(), self::SYMFONY_FAMILY_REGEX)) { continue; } foreach ($eventListener->getTags() as $tag) { - if (!$tag instanceof \Rector\Symfony\ValueObject\Tag\EventListenerTag) { + if (!$tag instanceof EventListenerTag) { continue; } $eventName = $tag->getEvent(); diff --git a/vendor/rector/rector-symfony/src/Bridge/NodeAnalyzer/ControllerMethodAnalyzer.php b/vendor/rector/rector-symfony/src/Bridge/NodeAnalyzer/ControllerMethodAnalyzer.php index ed9f59cbbd8..d498af476dd 100644 --- a/vendor/rector/rector-symfony/src/Bridge/NodeAnalyzer/ControllerMethodAnalyzer.php +++ b/vendor/rector/rector-symfony/src/Bridge/NodeAnalyzer/ControllerMethodAnalyzer.php @@ -13,16 +13,16 @@ final class ControllerMethodAnalyzer * @var \Rector\Symfony\TypeAnalyzer\ControllerAnalyzer */ private $controllerAnalyzer; - public function __construct(\Rector\Symfony\TypeAnalyzer\ControllerAnalyzer $controllerAnalyzer) + public function __construct(ControllerAnalyzer $controllerAnalyzer) { $this->controllerAnalyzer = $controllerAnalyzer; } /** * Detect if is Action() in Controller */ - public function isAction(\PhpParser\Node $node) : bool + public function isAction(Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$node instanceof ClassMethod) { return \false; } if (!$this->controllerAnalyzer->isInsideController($node)) { diff --git a/vendor/rector/rector-symfony/src/Bridge/Symfony/ContainerServiceProvider.php b/vendor/rector/rector-symfony/src/Bridge/Symfony/ContainerServiceProvider.php index 55834079fe0..c79e35f2491 100644 --- a/vendor/rector/rector-symfony/src/Bridge/Symfony/ContainerServiceProvider.php +++ b/vendor/rector/rector-symfony/src/Bridge/Symfony/ContainerServiceProvider.php @@ -13,20 +13,20 @@ final class ContainerServiceProvider * @var \Rector\Core\Configuration\RectorConfigProvider */ private $rectorConfigProvider; - public function __construct(\Rector\Core\Configuration\RectorConfigProvider $rectorConfigProvider) + public function __construct(RectorConfigProvider $rectorConfigProvider) { $this->rectorConfigProvider = $rectorConfigProvider; } public function provideByName(string $serviceName) : object { $symfonyContainerPhp = $this->rectorConfigProvider->getSymfonyContainerPhp(); - \RectorPrefix20220607\Webmozart\Assert\Assert::fileExists($symfonyContainerPhp); + Assert::fileExists($symfonyContainerPhp); $container = (require_once $symfonyContainerPhp); // this allows older Symfony versions, e.g. 2.8 did not have the PSR yet - \RectorPrefix20220607\Webmozart\Assert\Assert::isInstanceOf($container, 'Symfony\\Component\\DependencyInjection\\Container'); + Assert::isInstanceOf($container, 'Symfony\\Component\\DependencyInjection\\Container'); if (!$container->has($serviceName)) { $errorMessage = \sprintf('Symfony container has no service "%s", maybe it is private', 'router'); - throw new \Rector\Core\Exception\ShouldNotHappenException($errorMessage); + throw new ShouldNotHappenException($errorMessage); } return $container->get($serviceName); } diff --git a/vendor/rector/rector-symfony/src/Bridge/Symfony/Routing/SymfonyRoutesProvider.php b/vendor/rector/rector-symfony/src/Bridge/Symfony/Routing/SymfonyRoutesProvider.php index 4c12398c2d7..7d4e5be3768 100644 --- a/vendor/rector/rector-symfony/src/Bridge/Symfony/Routing/SymfonyRoutesProvider.php +++ b/vendor/rector/rector-symfony/src/Bridge/Symfony/Routing/SymfonyRoutesProvider.php @@ -8,7 +8,7 @@ use Rector\Symfony\Contract\Bridge\Symfony\Routing\SymfonyRoutesProviderInterfac use Rector\Symfony\ValueObject\SymfonyRouteMetadata; use RectorPrefix20220607\Symfony\Component\Routing\RouterInterface; use RectorPrefix20220607\Webmozart\Assert\Assert; -final class SymfonyRoutesProvider implements \Rector\Symfony\Contract\Bridge\Symfony\Routing\SymfonyRoutesProviderInterface +final class SymfonyRoutesProvider implements SymfonyRoutesProviderInterface { /** * @var SymfonyRouteMetadata[] @@ -19,7 +19,7 @@ final class SymfonyRoutesProvider implements \Rector\Symfony\Contract\Bridge\Sym * @var \Rector\Symfony\Bridge\Symfony\ContainerServiceProvider */ private $containerServiceProvider; - public function __construct(\Rector\Symfony\Bridge\Symfony\ContainerServiceProvider $containerServiceProvider) + public function __construct(ContainerServiceProvider $containerServiceProvider) { $this->containerServiceProvider = $containerServiceProvider; } @@ -32,13 +32,13 @@ final class SymfonyRoutesProvider implements \Rector\Symfony\Contract\Bridge\Sym return $this->symfonyRouteMetadatas; } $router = $this->containerServiceProvider->provideByName('router'); - \RectorPrefix20220607\Webmozart\Assert\Assert::isInstanceOf($router, 'Symfony\\Component\\Routing\\RouterInterface'); + Assert::isInstanceOf($router, 'Symfony\\Component\\Routing\\RouterInterface'); $symfonyRoutesMetadatas = []; /** @var RouterInterface $router */ $routeCollection = $router->getRouteCollection(); // route name is hidden in the key - https://github.com/symfony/symfony/blob/4dde1619d6c65b662170a6a3cbbdc7092eeb1fa2/src/Symfony/Component/Routing/RouteCollection.php#L99 foreach ($routeCollection->all() as $routeName => $route) { - $symfonyRoutesMetadatas[] = new \Rector\Symfony\ValueObject\SymfonyRouteMetadata($routeName, $route->getPath(), $route->getDefaults(), $route->getRequirements(), $route->getHost(), $route->getSchemes(), $route->getMethods(), $route->getCondition()); + $symfonyRoutesMetadatas[] = new SymfonyRouteMetadata($routeName, $route->getPath(), $route->getDefaults(), $route->getRequirements(), $route->getHost(), $route->getSchemes(), $route->getMethods(), $route->getCondition()); } $this->symfonyRouteMetadatas = $symfonyRoutesMetadatas; return $symfonyRoutesMetadatas; diff --git a/vendor/rector/rector-symfony/src/BundleClassResolver.php b/vendor/rector/rector-symfony/src/BundleClassResolver.php index d3624c21b48..592432ec8a5 100644 --- a/vendor/rector/rector-symfony/src/BundleClassResolver.php +++ b/vendor/rector/rector-symfony/src/BundleClassResolver.php @@ -11,7 +11,7 @@ use PHPStan\Reflection\ReflectionProvider; use Rector\Core\PhpParser\Node\BetterNodeFinder; use Rector\Core\PhpParser\Parser\RectorParser; use Rector\NodeNameResolver\NodeNameResolver; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class BundleClassResolver { /** @@ -34,7 +34,7 @@ final class BundleClassResolver * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Parser\RectorParser $rectorParser, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver, RectorParser $rectorParser, ReflectionProvider $reflectionProvider) { $this->betterNodeFinder = $betterNodeFinder; $this->nodeNameResolver = $nodeNameResolver; @@ -70,11 +70,11 @@ final class BundleClassResolver } private function resolveClassNameFromFilePath(string $filePath) : ?string { - $fileInfo = new \Symplify\SmartFileSystem\SmartFileInfo($filePath); + $fileInfo = new SmartFileInfo($filePath); $nodes = $this->rectorParser->parseFile($fileInfo); $this->addFullyQualifiedNamesToNodes($nodes); $classLike = $this->betterNodeFinder->findFirstNonAnonymousClass($nodes); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + if (!$classLike instanceof ClassLike) { return null; } return $this->nodeNameResolver->getName($classLike); @@ -84,8 +84,8 @@ final class BundleClassResolver */ private function addFullyQualifiedNamesToNodes(array $nodes) : void { - $nodeTraverser = new \PhpParser\NodeTraverser(); - $nameResolver = new \PhpParser\NodeVisitor\NameResolver(); + $nodeTraverser = new NodeTraverser(); + $nameResolver = new NameResolver(); $nodeTraverser->addVisitor($nameResolver); $nodeTraverser->traverse($nodes); } diff --git a/vendor/rector/rector-symfony/src/Contract/EventReferenceToMethodNameInterface.php b/vendor/rector/rector-symfony/src/Contract/EventReferenceToMethodNameInterface.php index 99ee5d4823d..e0f5a212212 100644 --- a/vendor/rector/rector-symfony/src/Contract/EventReferenceToMethodNameInterface.php +++ b/vendor/rector/rector-symfony/src/Contract/EventReferenceToMethodNameInterface.php @@ -6,6 +6,6 @@ namespace Rector\Symfony\Contract; use PhpParser\Node\Expr\ClassConstFetch; interface EventReferenceToMethodNameInterface { - public function getClassConstFetch() : \PhpParser\Node\Expr\ClassConstFetch; + public function getClassConstFetch() : ClassConstFetch; public function getMethodName() : string; } diff --git a/vendor/rector/rector-symfony/src/DataProvider/ServiceMapProvider.php b/vendor/rector/rector-symfony/src/DataProvider/ServiceMapProvider.php index 30db1eb4881..a4e1091c5d0 100644 --- a/vendor/rector/rector-symfony/src/DataProvider/ServiceMapProvider.php +++ b/vendor/rector/rector-symfony/src/DataProvider/ServiceMapProvider.php @@ -22,14 +22,14 @@ final class ServiceMapProvider * @var \Rector\Symfony\ValueObjectFactory\ServiceMapFactory */ private $serviceMapFactory; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \Rector\Symfony\ValueObjectFactory\ServiceMapFactory $serviceMapFactory) + public function __construct(ParameterProvider $parameterProvider, ServiceMapFactory $serviceMapFactory) { $this->parameterProvider = $parameterProvider; $this->serviceMapFactory = $serviceMapFactory; } - public function provide() : \Rector\Symfony\ValueObject\ServiceMap\ServiceMap + public function provide() : ServiceMap { - $symfonyContainerXmlPath = (string) $this->parameterProvider->provideParameter(\Rector\Core\Configuration\Option::SYMFONY_CONTAINER_XML_PATH_PARAMETER); + $symfonyContainerXmlPath = (string) $this->parameterProvider->provideParameter(Option::SYMFONY_CONTAINER_XML_PATH_PARAMETER); if ($symfonyContainerXmlPath === '') { return $this->serviceMapFactory->createEmpty(); } diff --git a/vendor/rector/rector-symfony/src/Exception/InvalidConfigurationException.php b/vendor/rector/rector-symfony/src/Exception/InvalidConfigurationException.php index dc4094da868..c911ec68e02 100644 --- a/vendor/rector/rector-symfony/src/Exception/InvalidConfigurationException.php +++ b/vendor/rector/rector-symfony/src/Exception/InvalidConfigurationException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace Rector\Symfony\Exception; use Exception; -final class InvalidConfigurationException extends \Exception +final class InvalidConfigurationException extends Exception { } diff --git a/vendor/rector/rector-symfony/src/Exception/XmlContainerNotExistsException.php b/vendor/rector/rector-symfony/src/Exception/XmlContainerNotExistsException.php index 9c56bd65f0f..9ebc6e3a4ee 100644 --- a/vendor/rector/rector-symfony/src/Exception/XmlContainerNotExistsException.php +++ b/vendor/rector/rector-symfony/src/Exception/XmlContainerNotExistsException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace Rector\Symfony\Exception; use Exception; -final class XmlContainerNotExistsException extends \Exception +final class XmlContainerNotExistsException extends Exception { } diff --git a/vendor/rector/rector-symfony/src/FormHelper/FormTypeStringToTypeProvider.php b/vendor/rector/rector-symfony/src/FormHelper/FormTypeStringToTypeProvider.php index 111d049d424..5f6ca0929be 100644 --- a/vendor/rector/rector-symfony/src/FormHelper/FormTypeStringToTypeProvider.php +++ b/vendor/rector/rector-symfony/src/FormHelper/FormTypeStringToTypeProvider.php @@ -21,7 +21,7 @@ final class FormTypeStringToTypeProvider * @var \Rector\Symfony\DataProvider\ServiceMapProvider */ private $serviceMapProvider; - public function __construct(\Rector\Symfony\DataProvider\ServiceMapProvider $serviceMapProvider) + public function __construct(ServiceMapProvider $serviceMapProvider) { $this->serviceMapProvider = $serviceMapProvider; } @@ -29,7 +29,7 @@ final class FormTypeStringToTypeProvider { $nameToTypeMap = $this->getNameToTypeMap(); if (\strncmp($name, 'form.type.', \strlen('form.type.')) === 0) { - $name = \RectorPrefix20220607\Nette\Utils\Strings::substring($name, \strlen('form.type.')); + $name = Strings::substring($name, \strlen('form.type.')); } return $nameToTypeMap[$name] ?? null; } @@ -53,7 +53,7 @@ final class FormTypeStringToTypeProvider $formTypeServiceDefinitions = $serviceMap->getServicesByTag('form.type'); foreach ($formTypeServiceDefinitions as $formTypeServiceDefinition) { $formTypeTag = $formTypeServiceDefinition->getTag('form.type'); - if (!$formTypeTag instanceof \Rector\Symfony\Contract\Tag\TagInterface) { + if (!$formTypeTag instanceof TagInterface) { continue; } $alias = $formTypeTag->getData()['alias'] ?? null; diff --git a/vendor/rector/rector-symfony/src/Helper/TemplateGuesser.php b/vendor/rector/rector-symfony/src/Helper/TemplateGuesser.php index cf08914c432..5a2a8a7242d 100644 --- a/vendor/rector/rector-symfony/src/Helper/TemplateGuesser.php +++ b/vendor/rector/rector-symfony/src/Helper/TemplateGuesser.php @@ -50,24 +50,24 @@ final class TemplateGuesser * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\Symfony\BundleClassResolver $bundleClassResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(BundleClassResolver $bundleClassResolver, NodeNameResolver $nodeNameResolver) { $this->bundleClassResolver = $bundleClassResolver; $this->nodeNameResolver = $nodeNameResolver; } - public function resolveFromClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : string + public function resolveFromClassMethod(ClassMethod $classMethod) : string { - $scope = $classMethod->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$scope instanceof \PHPStan\Analyser\Scope) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $scope = $classMethod->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { + throw new ShouldNotHappenException(); } $namespace = $scope->getNamespace(); if (!\is_string($namespace)) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $className = ($getClassReflection = $scope->getClassReflection()) ? $getClassReflection->getName() : null; if (!\is_string($className)) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } /** @var string $methodName */ $methodName = $this->nodeNameResolver->getName($classMethod); @@ -80,7 +80,7 @@ final class TemplateGuesser { $bundle = $this->resolveBundle($class, $namespace); $controller = $this->resolveController($class); - $action = \RectorPrefix20220607\Nette\Utils\Strings::replace($method, self::ACTION_MATCH_REGEX, ''); + $action = Strings::replace($method, self::ACTION_MATCH_REGEX, ''); $fullPath = ''; if ($bundle !== '') { $fullPath .= $bundle . '/'; @@ -96,17 +96,17 @@ final class TemplateGuesser if ($shortBundleClass !== null) { return '@' . $shortBundleClass; } - $bundle = \RectorPrefix20220607\Nette\Utils\Strings::match($namespace, self::BUNDLE_NAME_MATCHING_REGEX)['bundle'] ?? ''; - $bundle = \RectorPrefix20220607\Nette\Utils\Strings::replace($bundle, self::BUNDLE_SUFFIX_REGEX, ''); + $bundle = Strings::match($namespace, self::BUNDLE_NAME_MATCHING_REGEX)['bundle'] ?? ''; + $bundle = Strings::replace($bundle, self::BUNDLE_SUFFIX_REGEX, ''); return $bundle !== '' ? '@' . $bundle : ''; } private function resolveController(string $class) : string { - $match = \RectorPrefix20220607\Nette\Utils\Strings::match($class, self::CONTROLLER_NAME_MATCH_REGEX); + $match = Strings::match($class, self::CONTROLLER_NAME_MATCH_REGEX); if ($match === null) { return ''; } - $controller = \RectorPrefix20220607\Nette\Utils\Strings::replace($match['class_name_without_suffix'], self::SMALL_LETTER_BIG_LETTER_REGEX, '1_\\2'); + $controller = Strings::replace($match['class_name_without_suffix'], self::SMALL_LETTER_BIG_LETTER_REGEX, '1_\\2'); return \str_replace('\\', '/', $controller); } } diff --git a/vendor/rector/rector-symfony/src/NodeAnalyzer/Annotations/ConstraintAnnotationResolver.php b/vendor/rector/rector-symfony/src/NodeAnalyzer/Annotations/ConstraintAnnotationResolver.php index edb9540041a..51d5b35258c 100644 --- a/vendor/rector/rector-symfony/src/NodeAnalyzer/Annotations/ConstraintAnnotationResolver.php +++ b/vendor/rector/rector-symfony/src/NodeAnalyzer/Annotations/ConstraintAnnotationResolver.php @@ -33,7 +33,7 @@ final class ConstraintAnnotationResolver * @var \Rector\Symfony\NodeFactory\Annotations\DoctrineAnnotationFromNewFactory */ private $doctrineAnnotationFromNewFactory; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Symfony\NodeFactory\Annotations\DoctrineAnnotationFromNewFactory $doctrineAnnotationFromNewFactory) + public function __construct(NodeNameResolver $nodeNameResolver, ValueResolver $valueResolver, BetterNodeFinder $betterNodeFinder, DoctrineAnnotationFromNewFactory $doctrineAnnotationFromNewFactory) { $this->nodeNameResolver = $nodeNameResolver; $this->valueResolver = $valueResolver; @@ -43,7 +43,7 @@ final class ConstraintAnnotationResolver /** * @return array */ - public function resolvePropertyTagValueNodes(\PhpParser\Node\Stmt\ClassMethod $classMethod) : array + public function resolvePropertyTagValueNodes(ClassMethod $classMethod) : array { $constraintsMethodCalls = $this->findMethodCallsByName($classMethod, 'addPropertyConstraint'); $annotationsToPropertyNames = []; @@ -54,7 +54,7 @@ final class ConstraintAnnotationResolver if (!\is_string($propertyName)) { continue; } - if (!$constraintsExpr instanceof \PhpParser\Node\Expr\New_) { + if (!$constraintsExpr instanceof New_) { // nothing we can do... or can we? continue; } @@ -66,7 +66,7 @@ final class ConstraintAnnotationResolver /** * @return array */ - public function resolveGetterTagValueNodes(\PhpParser\Node\Stmt\ClassMethod $classMethod) : array + public function resolveGetterTagValueNodes(ClassMethod $classMethod) : array { $constraintsMethodCalls = $this->findMethodCallsByName($classMethod, 'addGetterConstraint'); $annotationsToMethodNames = []; @@ -76,7 +76,7 @@ final class ConstraintAnnotationResolver $propertyName = $this->valueResolver->getValue($firstArgValue); $getterMethodName = 'get' . \ucfirst($propertyName); $secondArgValue = $args[1]->value; - if (!$secondArgValue instanceof \PhpParser\Node\Expr\New_) { + if (!$secondArgValue instanceof New_) { // nothing we can do... or can we? continue; } @@ -88,10 +88,10 @@ final class ConstraintAnnotationResolver /** * @return MethodCall[] */ - private function findMethodCallsByName(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $methodName) : array + private function findMethodCallsByName(ClassMethod $classMethod, string $methodName) : array { - $methodCalls = $this->betterNodeFinder->findInstanceOf($classMethod, \PhpParser\Node\Expr\MethodCall::class); - return \array_filter($methodCalls, function (\PhpParser\Node\Expr\MethodCall $methodCall) use($methodName) : bool { + $methodCalls = $this->betterNodeFinder->findInstanceOf($classMethod, MethodCall::class); + return \array_filter($methodCalls, function (MethodCall $methodCall) use($methodName) : bool { return $this->nodeNameResolver->isName($methodCall->name, $methodName); }); } diff --git a/vendor/rector/rector-symfony/src/NodeAnalyzer/DependencyInjectionMethodCallAnalyzer.php b/vendor/rector/rector-symfony/src/NodeAnalyzer/DependencyInjectionMethodCallAnalyzer.php index e1be5849dfd..66d1823a7d6 100644 --- a/vendor/rector/rector-symfony/src/NodeAnalyzer/DependencyInjectionMethodCallAnalyzer.php +++ b/vendor/rector/rector-symfony/src/NodeAnalyzer/DependencyInjectionMethodCallAnalyzer.php @@ -58,7 +58,7 @@ final class DependencyInjectionMethodCallAnalyzer * @var \Rector\Core\NodeManipulator\PropertyManipulator */ private $propertyManipulator; - public function __construct(\Rector\Naming\Naming\PropertyNaming $propertyNaming, \Rector\Symfony\NodeAnalyzer\ServiceTypeMethodCallResolver $serviceTypeMethodCallResolver, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Php80\NodeAnalyzer\PromotedPropertyResolver $promotedPropertyResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\NodeManipulator\PropertyManipulator $propertyManipulator) + public function __construct(PropertyNaming $propertyNaming, \Rector\Symfony\NodeAnalyzer\ServiceTypeMethodCallResolver $serviceTypeMethodCallResolver, NodeFactory $nodeFactory, PropertyToAddCollector $propertyToAddCollector, BetterNodeFinder $betterNodeFinder, PromotedPropertyResolver $promotedPropertyResolver, NodeNameResolver $nodeNameResolver, PropertyManipulator $propertyManipulator) { $this->propertyNaming = $propertyNaming; $this->serviceTypeMethodCallResolver = $serviceTypeMethodCallResolver; @@ -69,14 +69,14 @@ final class DependencyInjectionMethodCallAnalyzer $this->nodeNameResolver = $nodeNameResolver; $this->propertyManipulator = $propertyManipulator; } - public function replaceMethodCallWithPropertyFetchAndDependency(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node\Expr\PropertyFetch + public function replaceMethodCallWithPropertyFetchAndDependency(MethodCall $methodCall) : ?PropertyFetch { $serviceType = $this->serviceTypeMethodCallResolver->resolve($methodCall); - if (!$serviceType instanceof \PHPStan\Type\ObjectType) { + if (!$serviceType instanceof ObjectType) { return null; } - $class = $this->betterNodeFinder->findParentType($methodCall, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($methodCall, Class_::class); + if (!$class instanceof Class_) { return null; } $resolvedPropertyNameByType = $this->propertyManipulator->resolveExistingClassPropertyNameByType($class, $serviceType); @@ -86,11 +86,11 @@ final class DependencyInjectionMethodCallAnalyzer $propertyName = $this->propertyNaming->fqnToVariableName($serviceType); $propertyName = $this->resolveNewPropertyNameWhenExists($class, $propertyName, $propertyName); } - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($propertyName, $serviceType, \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $propertyMetadata = new PropertyMetadata($propertyName, $serviceType, Class_::MODIFIER_PRIVATE); $this->propertyToAddCollector->addPropertyToClass($class, $propertyMetadata); return $this->nodeFactory->createPropertyFetch('this', $propertyName); } - private function resolveNewPropertyNameWhenExists(\PhpParser\Node\Stmt\Class_ $class, string $originalPropertyName, string $propertyName, int $count = 1) : string + private function resolveNewPropertyNameWhenExists(Class_ $class, string $originalPropertyName, string $propertyName, int $count = 1) : string { $lastCount = \substr($propertyName, \strlen($originalPropertyName)); if (\is_numeric($lastCount)) { @@ -104,7 +104,7 @@ final class DependencyInjectionMethodCallAnalyzer } } $property = $class->getProperty($propertyName); - if (!$property instanceof \PhpParser\Node\Stmt\Property) { + if (!$property instanceof Property) { return $propertyName; } $propertyName = $this->resolveIncrementPropertyName($originalPropertyName, $count); diff --git a/vendor/rector/rector-symfony/src/NodeAnalyzer/FormAddMethodCallAnalyzer.php b/vendor/rector/rector-symfony/src/NodeAnalyzer/FormAddMethodCallAnalyzer.php index 4173ef8ebc9..5ecc0b58fe6 100644 --- a/vendor/rector/rector-symfony/src/NodeAnalyzer/FormAddMethodCallAnalyzer.php +++ b/vendor/rector/rector-symfony/src/NodeAnalyzer/FormAddMethodCallAnalyzer.php @@ -23,13 +23,13 @@ final class FormAddMethodCallAnalyzer * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeTypeResolver $nodeTypeResolver, NodeNameResolver $nodeNameResolver) { $this->nodeTypeResolver = $nodeTypeResolver; $this->nodeNameResolver = $nodeNameResolver; - $this->formObjectTypes = [new \PHPStan\Type\ObjectType('Symfony\\Component\\Form\\FormBuilderInterface'), new \PHPStan\Type\ObjectType('Symfony\\Component\\Form\\FormInterface')]; + $this->formObjectTypes = [new ObjectType('Symfony\\Component\\Form\\FormBuilderInterface'), new ObjectType('Symfony\\Component\\Form\\FormInterface')]; } - public function isMatching(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + public function isMatching(MethodCall $methodCall) : bool { if (!$this->nodeTypeResolver->isObjectTypes($methodCall->var, $this->formObjectTypes)) { return \false; diff --git a/vendor/rector/rector-symfony/src/NodeAnalyzer/FormCollectionAnalyzer.php b/vendor/rector/rector-symfony/src/NodeAnalyzer/FormCollectionAnalyzer.php index 317bc556922..fa3fd159d24 100644 --- a/vendor/rector/rector-symfony/src/NodeAnalyzer/FormCollectionAnalyzer.php +++ b/vendor/rector/rector-symfony/src/NodeAnalyzer/FormCollectionAnalyzer.php @@ -19,15 +19,15 @@ final class FormCollectionAnalyzer * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(ValueResolver $valueResolver, NodeNameResolver $nodeNameResolver) { $this->valueResolver = $valueResolver; $this->nodeNameResolver = $nodeNameResolver; } - public function isCollectionType(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + public function isCollectionType(MethodCall $methodCall) : bool { $typeValue = $methodCall->getArgs()[1]->value; - if (!$typeValue instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if (!$typeValue instanceof ClassConstFetch) { return $this->valueResolver->isValue($typeValue, 'collection'); } if (!$this->nodeNameResolver->isName($typeValue->class, 'Symfony\\Component\\Form\\Extension\\Core\\Type\\CollectionType')) { diff --git a/vendor/rector/rector-symfony/src/NodeAnalyzer/FormInstanceToFormClassConstFetchConverter.php b/vendor/rector/rector-symfony/src/NodeAnalyzer/FormInstanceToFormClassConstFetchConverter.php index 7a59e56182d..4aa71b86c9b 100644 --- a/vendor/rector/rector-symfony/src/NodeAnalyzer/FormInstanceToFormClassConstFetchConverter.php +++ b/vendor/rector/rector-symfony/src/NodeAnalyzer/FormInstanceToFormClassConstFetchConverter.php @@ -41,7 +41,7 @@ final class FormInstanceToFormClassConstFetchConverter * @var \Rector\NodeRemoval\NodeRemover */ private $nodeRemover; - public function __construct(\Rector\Symfony\NodeAnalyzer\FormType\CreateFormTypeOptionsArgMover $createFormTypeOptionsArgMover, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\Symfony\NodeAnalyzer\FormType\FormTypeClassResolver $formTypeClassResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeRemoval\NodeRemover $nodeRemover) + public function __construct(CreateFormTypeOptionsArgMover $createFormTypeOptionsArgMover, NodeFactory $nodeFactory, FormTypeClassResolver $formTypeClassResolver, BetterNodeFinder $betterNodeFinder, NodeRemover $nodeRemover) { $this->createFormTypeOptionsArgMover = $createFormTypeOptionsArgMover; $this->nodeFactory = $nodeFactory; @@ -49,7 +49,7 @@ final class FormInstanceToFormClassConstFetchConverter $this->betterNodeFinder = $betterNodeFinder; $this->nodeRemover = $nodeRemover; } - public function processNewInstance(\PhpParser\Node\Expr\MethodCall $methodCall, int $position, int $optionsPosition) : ?\PhpParser\Node\Expr\MethodCall + public function processNewInstance(MethodCall $methodCall, int $position, int $optionsPosition) : ?MethodCall { $args = $methodCall->getArgs(); if (!isset($args[$position])) { @@ -61,15 +61,15 @@ final class FormInstanceToFormClassConstFetchConverter return null; } $formNew = $this->resolveFormNew($argValue); - if ($formNew instanceof \PhpParser\Node\Expr\New_ && $formNew->getArgs() !== []) { + if ($formNew instanceof New_ && $formNew->getArgs() !== []) { $methodCall = $this->createFormTypeOptionsArgMover->moveArgumentsToOptions($methodCall, $position, $optionsPosition, $formClassName, $formNew->getArgs()); - if (!$methodCall instanceof \PhpParser\Node\Expr\MethodCall) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$methodCall instanceof MethodCall) { + throw new ShouldNotHappenException(); } } // remove previous assign $previousAssign = $this->betterNodeFinder->findPreviousAssignToExpr($argValue); - if ($previousAssign instanceof \PhpParser\Node\Expr\Assign) { + if ($previousAssign instanceof Assign) { $this->nodeRemover->removeNode($previousAssign); } $classConstFetch = $this->nodeFactory->createClassConstReference($formClassName); @@ -77,17 +77,17 @@ final class FormInstanceToFormClassConstFetchConverter $currentArg->value = $classConstFetch; return $methodCall; } - private function resolveFormNew(\PhpParser\Node\Expr $expr) : ?\PhpParser\Node\Expr\New_ + private function resolveFormNew(Expr $expr) : ?New_ { - if ($expr instanceof \PhpParser\Node\Expr\New_) { + if ($expr instanceof New_) { return $expr; } - if ($expr instanceof \PhpParser\Node\Expr\Variable) { + if ($expr instanceof Variable) { $previousAssign = $this->betterNodeFinder->findPreviousAssignToExpr($expr); - if (!$previousAssign instanceof \PhpParser\Node\Expr\Assign) { + if (!$previousAssign instanceof Assign) { return null; } - if ($previousAssign->expr instanceof \PhpParser\Node\Expr\New_) { + if ($previousAssign->expr instanceof New_) { return $previousAssign->expr; } } diff --git a/vendor/rector/rector-symfony/src/NodeAnalyzer/FormOptionsArrayMatcher.php b/vendor/rector/rector-symfony/src/NodeAnalyzer/FormOptionsArrayMatcher.php index 0bce1fd3f52..9b32be5707f 100644 --- a/vendor/rector/rector-symfony/src/NodeAnalyzer/FormOptionsArrayMatcher.php +++ b/vendor/rector/rector-symfony/src/NodeAnalyzer/FormOptionsArrayMatcher.php @@ -7,13 +7,13 @@ use PhpParser\Node\Expr\Array_; use PhpParser\Node\Expr\MethodCall; final class FormOptionsArrayMatcher { - public function match(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node\Expr\Array_ + public function match(MethodCall $methodCall) : ?Array_ { if (!isset($methodCall->getArgs()[2])) { return null; } $optionsArray = $methodCall->getArgs()[2]->value; - if (!$optionsArray instanceof \PhpParser\Node\Expr\Array_) { + if (!$optionsArray instanceof Array_) { return null; } return $optionsArray; diff --git a/vendor/rector/rector-symfony/src/NodeAnalyzer/FormType/CreateFormTypeOptionsArgMover.php b/vendor/rector/rector-symfony/src/NodeAnalyzer/FormType/CreateFormTypeOptionsArgMover.php index f4e19322355..ad74a0d5532 100644 --- a/vendor/rector/rector-symfony/src/NodeAnalyzer/FormType/CreateFormTypeOptionsArgMover.php +++ b/vendor/rector/rector-symfony/src/NodeAnalyzer/FormType/CreateFormTypeOptionsArgMover.php @@ -23,7 +23,7 @@ final class CreateFormTypeOptionsArgMover * @var \Rector\Core\PhpParser\Node\NodeFactory */ private $nodeFactory; - public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory) + public function __construct(ReflectionProvider $reflectionProvider, NodeFactory $nodeFactory) { $this->reflectionProvider = $reflectionProvider; $this->nodeFactory = $nodeFactory; @@ -31,20 +31,20 @@ final class CreateFormTypeOptionsArgMover /** * @param Arg[] $argNodes */ - public function moveArgumentsToOptions(\PhpParser\Node\Expr\MethodCall $methodCall, int $position, int $optionsPosition, string $className, array $argNodes) : ?\PhpParser\Node\Expr\MethodCall + public function moveArgumentsToOptions(MethodCall $methodCall, int $position, int $optionsPosition, string $className, array $argNodes) : ?MethodCall { $namesToArgs = $this->resolveNamesToArgs($className, $argNodes); // set default data in between if ($position + 1 !== $optionsPosition && !isset($methodCall->args[$position + 1])) { - $methodCall->args[$position + 1] = new \PhpParser\Node\Arg($this->nodeFactory->createNull()); + $methodCall->args[$position + 1] = new Arg($this->nodeFactory->createNull()); } // @todo decopule and name, so I know what it is if (!isset($methodCall->args[$optionsPosition])) { - $array = new \PhpParser\Node\Expr\Array_(); + $array = new Array_(); foreach ($namesToArgs as $name => $arg) { - $array->items[] = new \PhpParser\Node\Expr\ArrayItem($arg->value, new \PhpParser\Node\Scalar\String_($name)); + $array->items[] = new ArrayItem($arg->value, new String_($name)); } - $methodCall->args[$optionsPosition] = new \PhpParser\Node\Arg($array); + $methodCall->args[$optionsPosition] = new Arg($array); } if (!$this->reflectionProvider->hasClass($className)) { return null; @@ -68,7 +68,7 @@ final class CreateFormTypeOptionsArgMover $classReflection = $this->reflectionProvider->getClass($className); $nativeReflection = $classReflection->getNativeReflection(); $constructorReflectionMethod = $nativeReflection->getConstructor(); - if (!$constructorReflectionMethod instanceof \ReflectionMethod) { + if (!$constructorReflectionMethod instanceof ReflectionMethod) { return []; } return $this->createArgsByName($constructorReflectionMethod, $args); @@ -77,7 +77,7 @@ final class CreateFormTypeOptionsArgMover * @param Arg[] $args * @return array */ - private function createArgsByName(\ReflectionMethod $constructorReflectionMethod, array $args) : array + private function createArgsByName(ReflectionMethod $constructorReflectionMethod, array $args) : array { $namesToArgs = []; foreach ($constructorReflectionMethod->getParameters() as $position => $reflectionParameter) { diff --git a/vendor/rector/rector-symfony/src/NodeAnalyzer/FormType/FormTypeClassResolver.php b/vendor/rector/rector-symfony/src/NodeAnalyzer/FormType/FormTypeClassResolver.php index e0170d6c2a8..6e4443948c1 100644 --- a/vendor/rector/rector-symfony/src/NodeAnalyzer/FormType/FormTypeClassResolver.php +++ b/vendor/rector/rector-symfony/src/NodeAnalyzer/FormType/FormTypeClassResolver.php @@ -20,19 +20,19 @@ final class FormTypeClassResolver * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->nodeTypeResolver = $nodeTypeResolver; } - public function resolveFromExpr(\PhpParser\Node\Expr $expr) : ?string + public function resolveFromExpr(Expr $expr) : ?string { - if ($expr instanceof \PhpParser\Node\Expr\New_) { + if ($expr instanceof New_) { // we can only process direct name return $this->nodeNameResolver->getName($expr->class); } $exprType = $this->nodeTypeResolver->getType($expr); - if ($exprType instanceof \PHPStan\Type\TypeWithClassName) { + if ($exprType instanceof TypeWithClassName) { return $exprType->getClassName(); } return null; diff --git a/vendor/rector/rector-symfony/src/NodeAnalyzer/InvokableAnalyzer/ActiveClassElementsClassMethodResolver.php b/vendor/rector/rector-symfony/src/NodeAnalyzer/InvokableAnalyzer/ActiveClassElementsClassMethodResolver.php index 4240486055f..3877b1d85c5 100644 --- a/vendor/rector/rector-symfony/src/NodeAnalyzer/InvokableAnalyzer/ActiveClassElementsClassMethodResolver.php +++ b/vendor/rector/rector-symfony/src/NodeAnalyzer/InvokableAnalyzer/ActiveClassElementsClassMethodResolver.php @@ -23,26 +23,26 @@ final class ActiveClassElementsClassMethodResolver * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver) { $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->nodeNameResolver = $nodeNameResolver; } - public function resolve(\PhpParser\Node\Stmt\ClassMethod $actionClassMethod) : \Rector\Symfony\ValueObject\InvokableController\ActiveClassElements + public function resolve(ClassMethod $actionClassMethod) : ActiveClassElements { $usedLocalPropertyNames = $this->resolveLocalUsedPropertyNames($actionClassMethod); $usedLocalConstantNames = $this->resolveLocalUsedConstantNames($actionClassMethod); $usedLocalMethodNames = $this->resolveLocalUsedMethodNames($actionClassMethod); - return new \Rector\Symfony\ValueObject\InvokableController\ActiveClassElements($usedLocalPropertyNames, $usedLocalConstantNames, $usedLocalMethodNames); + return new ActiveClassElements($usedLocalPropertyNames, $usedLocalConstantNames, $usedLocalMethodNames); } /** * @return string[] */ - private function resolveLocalUsedPropertyNames(\PhpParser\Node\Stmt\ClassMethod $actionClassMethod) : array + private function resolveLocalUsedPropertyNames(ClassMethod $actionClassMethod) : array { $usedLocalPropertyNames = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($actionClassMethod, function (\PhpParser\Node $node) use(&$usedLocalPropertyNames) { - if (!$node instanceof \PhpParser\Node\Expr\PropertyFetch) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($actionClassMethod, function (Node $node) use(&$usedLocalPropertyNames) { + if (!$node instanceof PropertyFetch) { return null; } if (!$this->nodeNameResolver->isName($node->var, 'this')) { @@ -59,11 +59,11 @@ final class ActiveClassElementsClassMethodResolver /** * @return string[] */ - private function resolveLocalUsedConstantNames(\PhpParser\Node\Stmt\ClassMethod $actionClassMethod) : array + private function resolveLocalUsedConstantNames(ClassMethod $actionClassMethod) : array { $usedLocalConstantNames = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($actionClassMethod, function (\PhpParser\Node $node) use(&$usedLocalConstantNames) { - if (!$node instanceof \PhpParser\Node\Expr\ClassConstFetch) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($actionClassMethod, function (Node $node) use(&$usedLocalConstantNames) { + if (!$node instanceof ClassConstFetch) { return null; } if (!$this->nodeNameResolver->isName($node->class, 'self')) { @@ -80,11 +80,11 @@ final class ActiveClassElementsClassMethodResolver /** * @return string[] */ - private function resolveLocalUsedMethodNames(\PhpParser\Node\Stmt\ClassMethod $actionClassMethod) : array + private function resolveLocalUsedMethodNames(ClassMethod $actionClassMethod) : array { $usedLocalMethodNames = []; - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($actionClassMethod, function (\PhpParser\Node $node) use(&$usedLocalMethodNames) { - if (!$node instanceof \PhpParser\Node\Expr\MethodCall) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($actionClassMethod, function (Node $node) use(&$usedLocalMethodNames) { + if (!$node instanceof MethodCall) { return null; } if (!$this->nodeNameResolver->isName($node->var, 'this')) { diff --git a/vendor/rector/rector-symfony/src/NodeAnalyzer/LiteralCallLikeConstFetchReplacer.php b/vendor/rector/rector-symfony/src/NodeAnalyzer/LiteralCallLikeConstFetchReplacer.php index ee5ef0edad6..db16480b85a 100644 --- a/vendor/rector/rector-symfony/src/NodeAnalyzer/LiteralCallLikeConstFetchReplacer.php +++ b/vendor/rector/rector-symfony/src/NodeAnalyzer/LiteralCallLikeConstFetchReplacer.php @@ -17,7 +17,7 @@ final class LiteralCallLikeConstFetchReplacer * @var \Rector\Core\PhpParser\Node\NodeFactory */ private $nodeFactory; - public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory) + public function __construct(NodeFactory $nodeFactory) { $this->nodeFactory = $nodeFactory; } @@ -28,14 +28,14 @@ final class LiteralCallLikeConstFetchReplacer * @param array $constantMap * @return null|\PhpParser\Node\Expr\CallLike */ - public function replaceArgOnPosition(\PhpParser\Node\Expr\CallLike $callLike, int $argPosition, string $className, array $constantMap) + public function replaceArgOnPosition(CallLike $callLike, int $argPosition, string $className, array $constantMap) { $args = $callLike->getArgs(); if (!isset($args[$argPosition])) { return null; } $arg = $args[$argPosition]; - if (!$arg->value instanceof \PhpParser\Node\Scalar\String_ && !$arg->value instanceof \PhpParser\Node\Scalar\LNumber) { + if (!$arg->value instanceof String_ && !$arg->value instanceof LNumber) { return null; } $scalar = $arg->value; diff --git a/vendor/rector/rector-symfony/src/NodeAnalyzer/RouteRequiredParamNameToTypesResolver.php b/vendor/rector/rector-symfony/src/NodeAnalyzer/RouteRequiredParamNameToTypesResolver.php index 6153c959c7f..8d566114cdb 100644 --- a/vendor/rector/rector-symfony/src/NodeAnalyzer/RouteRequiredParamNameToTypesResolver.php +++ b/vendor/rector/rector-symfony/src/NodeAnalyzer/RouteRequiredParamNameToTypesResolver.php @@ -27,7 +27,7 @@ final class RouteRequiredParamNameToTypesResolver * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\Doctrine\NodeAnalyzer\AttrinationFinder $attrinationFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(AttrinationFinder $attrinationFinder, NodeNameResolver $nodeNameResolver) { $this->attrinationFinder = $attrinationFinder; $this->nodeNameResolver = $nodeNameResolver; @@ -35,12 +35,12 @@ final class RouteRequiredParamNameToTypesResolver /** * @return array */ - public function resolve(\PhpParser\Node\Stmt\ClassMethod $classMethod) : array + public function resolve(ClassMethod $classMethod) : array { if ($classMethod->getParams() === []) { return []; } - $routeAttrination = $this->attrinationFinder->getByOne($classMethod, \Rector\Symfony\Enum\SymfonyAnnotation::ROUTE); + $routeAttrination = $this->attrinationFinder->getByOne($classMethod, SymfonyAnnotation::ROUTE); $paramsToRegexes = $this->resolveParamsToRegexes($routeAttrination); if ($paramsToRegexes === []) { return []; @@ -48,7 +48,7 @@ final class RouteRequiredParamNameToTypesResolver $paramsToTypes = []; foreach ($paramsToRegexes as $paramName => $paramRegex) { if ($paramRegex === '\\d+') { - $paramsToTypes[$paramName] = new \PHPStan\Type\IntegerType(); + $paramsToTypes[$paramName] = new IntegerType(); } // @todo add for string/bool as well } @@ -60,10 +60,10 @@ final class RouteRequiredParamNameToTypesResolver */ private function resolveParamsToRegexes($routeAttrination) : array { - if ($routeAttrination instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if ($routeAttrination instanceof DoctrineAnnotationTagValueNode) { return $this->resolveFromAnnotation($routeAttrination); } - if ($routeAttrination instanceof \PhpParser\Node\Attribute) { + if ($routeAttrination instanceof Attribute) { return $this->resolveFromAttribute($routeAttrination); } return []; @@ -71,11 +71,11 @@ final class RouteRequiredParamNameToTypesResolver /** * @return array */ - private function resolveFromAnnotation(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : array + private function resolveFromAnnotation(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : array { $paramsToRegexes = []; $requirementsValue = $doctrineAnnotationTagValueNode->getValue('requirements'); - if (!$requirementsValue instanceof \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode) { + if (!$requirementsValue instanceof CurlyListNode) { return []; } foreach ($requirementsValue->getValuesWithExplicitSilentAndWithoutQuotes() as $paramName => $paramRegex) { @@ -89,7 +89,7 @@ final class RouteRequiredParamNameToTypesResolver /** * @return array */ - private function resolveFromAttribute(\PhpParser\Node\Attribute $attribute) : array + private function resolveFromAttribute(Attribute $attribute) : array { $paramsToRegexes = []; foreach ($attribute->args as $arg) { @@ -97,20 +97,20 @@ final class RouteRequiredParamNameToTypesResolver continue; } $requirementsArray = $arg->value; - if (!$requirementsArray instanceof \PhpParser\Node\Expr\Array_) { + if (!$requirementsArray instanceof Array_) { continue; } foreach ($requirementsArray->items as $arrayItem) { - if (!$arrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$arrayItem instanceof ArrayItem) { continue; } $arrayKey = $arrayItem->key; - if (!$arrayKey instanceof \PhpParser\Node\Scalar\String_) { + if (!$arrayKey instanceof String_) { continue; } $paramName = $arrayKey->value; $arrayValue = $arrayItem->value; - if (!$arrayValue instanceof \PhpParser\Node\Scalar\String_) { + if (!$arrayValue instanceof String_) { continue; } $paramType = $arrayValue->value; diff --git a/vendor/rector/rector-symfony/src/NodeAnalyzer/ServiceTypeMethodCallResolver.php b/vendor/rector/rector-symfony/src/NodeAnalyzer/ServiceTypeMethodCallResolver.php index 8b7f49a2f5c..7ef1234883e 100644 --- a/vendor/rector/rector-symfony/src/NodeAnalyzer/ServiceTypeMethodCallResolver.php +++ b/vendor/rector/rector-symfony/src/NodeAnalyzer/ServiceTypeMethodCallResolver.php @@ -24,25 +24,25 @@ final class ServiceTypeMethodCallResolver * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\Symfony\DataProvider\ServiceMapProvider $serviceMapProvider, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(ServiceMapProvider $serviceMapProvider, NodeNameResolver $nodeNameResolver) { $this->serviceMapProvider = $serviceMapProvider; $this->nodeNameResolver = $nodeNameResolver; } - public function resolve(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PHPStan\Type\Type + public function resolve(MethodCall $methodCall) : ?Type { if (!isset($methodCall->args[0])) { - return new \PHPStan\Type\MixedType(); + return new MixedType(); } $argument = $methodCall->getArgs()[0]->value; $serviceMap = $this->serviceMapProvider->provide(); - if ($argument instanceof \PhpParser\Node\Scalar\String_) { + if ($argument instanceof String_) { return $serviceMap->getServiceType($argument->value); } - if ($argument instanceof \PhpParser\Node\Expr\ClassConstFetch && $argument->class instanceof \PhpParser\Node\Name) { + if ($argument instanceof ClassConstFetch && $argument->class instanceof Name) { $className = $this->nodeNameResolver->getName($argument->class); - return new \PHPStan\Type\ObjectType($className); + return new ObjectType($className); } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } } diff --git a/vendor/rector/rector-symfony/src/NodeAnalyzer/SymfonyControllerFilter.php b/vendor/rector/rector-symfony/src/NodeAnalyzer/SymfonyControllerFilter.php index 7976a596446..381913b5da8 100644 --- a/vendor/rector/rector-symfony/src/NodeAnalyzer/SymfonyControllerFilter.php +++ b/vendor/rector/rector-symfony/src/NodeAnalyzer/SymfonyControllerFilter.php @@ -10,9 +10,9 @@ final class SymfonyControllerFilter /** * @return ClassMethod[] */ - public function filterActionMethods(\PhpParser\Node\Stmt\Class_ $class) : array + public function filterActionMethods(Class_ $class) : array { - return \array_filter($class->getMethods(), function (\PhpParser\Node\Stmt\ClassMethod $classMethod) { + return \array_filter($class->getMethods(), function (ClassMethod $classMethod) { if ($classMethod->isMagic()) { return \false; } diff --git a/vendor/rector/rector-symfony/src/NodeAnalyzer/SymfonyTestCaseAnalyzer.php b/vendor/rector/rector-symfony/src/NodeAnalyzer/SymfonyTestCaseAnalyzer.php index 9da91484a7c..56857ad3342 100644 --- a/vendor/rector/rector-symfony/src/NodeAnalyzer/SymfonyTestCaseAnalyzer.php +++ b/vendor/rector/rector-symfony/src/NodeAnalyzer/SymfonyTestCaseAnalyzer.php @@ -13,14 +13,14 @@ final class SymfonyTestCaseAnalyzer * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(ReflectionResolver $reflectionResolver) { $this->reflectionResolver = $reflectionResolver; } - public function isInWebTestCase(\PhpParser\Node $node) : bool + public function isInWebTestCase(Node $node) : bool { $classReflection = $this->reflectionResolver->resolveClassReflection($node); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } return $classReflection->isSubclassOf('Symfony\\Bundle\\FrameworkBundle\\Test\\WebTestCase'); diff --git a/vendor/rector/rector-symfony/src/NodeFactory/Annotations/DoctrineAnnotationFromNewFactory.php b/vendor/rector/rector-symfony/src/NodeFactory/Annotations/DoctrineAnnotationFromNewFactory.php index f1337d4470e..337d08e50a8 100644 --- a/vendor/rector/rector-symfony/src/NodeFactory/Annotations/DoctrineAnnotationFromNewFactory.php +++ b/vendor/rector/rector-symfony/src/NodeFactory/Annotations/DoctrineAnnotationFromNewFactory.php @@ -20,7 +20,7 @@ final class DoctrineAnnotationFromNewFactory { $this->doctrineAnnotationKeyToValuesResolver = $doctrineAnnotationKeyToValuesResolver; } - public function create(\PhpParser\Node\Expr\New_ $new) : \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode + public function create(New_ $new) : DoctrineAnnotationTagValueNode { $annotationName = $this->resolveAnnotationName($new); $newArgs = $new->getArgs(); @@ -30,14 +30,14 @@ final class DoctrineAnnotationFromNewFactory } else { $annotationKeyToValues = []; } - return new \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode(new \Rector\BetterPhpDocParser\ValueObject\Type\ShortenedIdentifierTypeNode($annotationName), null, $annotationKeyToValues); + return new DoctrineAnnotationTagValueNode(new ShortenedIdentifierTypeNode($annotationName), null, $annotationKeyToValues); } - private function resolveAnnotationName(\PhpParser\Node\Expr\New_ $new) : string + private function resolveAnnotationName(New_ $new) : string { $className = $new->class; - $originalName = $className->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NAME); - if (!$originalName instanceof \PhpParser\Node\Name) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + $originalName = $className->getAttribute(AttributeKey::ORIGINAL_NAME); + if (!$originalName instanceof Name) { + throw new ShouldNotHappenException(); } return $originalName->toString(); } diff --git a/vendor/rector/rector-symfony/src/NodeFactory/Annotations/DoctrineAnnotationKeyToValuesResolver.php b/vendor/rector/rector-symfony/src/NodeFactory/Annotations/DoctrineAnnotationKeyToValuesResolver.php index 0575bc7ac03..94a36b064d6 100644 --- a/vendor/rector/rector-symfony/src/NodeFactory/Annotations/DoctrineAnnotationKeyToValuesResolver.php +++ b/vendor/rector/rector-symfony/src/NodeFactory/Annotations/DoctrineAnnotationKeyToValuesResolver.php @@ -14,19 +14,19 @@ final class DoctrineAnnotationKeyToValuesResolver * @var \Rector\Core\PhpParser\Node\Value\ValueResolver */ private $valueResolver; - public function __construct(\Rector\Core\PhpParser\Node\Value\ValueResolver $valueResolver) + public function __construct(ValueResolver $valueResolver) { $this->valueResolver = $valueResolver; } /** * @return array */ - public function resolveFromExpr(\PhpParser\Node\Expr $expr) : array + public function resolveFromExpr(Expr $expr) : array { $annotationKeyToValues = []; - if ($expr instanceof \PhpParser\Node\Expr\Array_) { + if ($expr instanceof Array_) { foreach ($expr->items as $arrayItem) { - if (!$arrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$arrayItem instanceof ArrayItem) { continue; } $key = $this->resolveKey($arrayItem); @@ -39,9 +39,9 @@ final class DoctrineAnnotationKeyToValuesResolver } return $annotationKeyToValues; } - private function resolveKey(\PhpParser\Node\Expr\ArrayItem $arrayItem) : ?string + private function resolveKey(ArrayItem $arrayItem) : ?string { - if (!$arrayItem->key instanceof \PhpParser\Node\Expr) { + if (!$arrayItem->key instanceof Expr) { return null; } return $this->valueResolver->getValue($arrayItem->key); diff --git a/vendor/rector/rector-symfony/src/NodeFactory/ArrayFromCompactFactory.php b/vendor/rector/rector-symfony/src/NodeFactory/ArrayFromCompactFactory.php index 033fce09524..412438008c0 100644 --- a/vendor/rector/rector-symfony/src/NodeFactory/ArrayFromCompactFactory.php +++ b/vendor/rector/rector-symfony/src/NodeFactory/ArrayFromCompactFactory.php @@ -16,16 +16,16 @@ final class ArrayFromCompactFactory * @var \Rector\Core\NodeManipulator\FuncCallManipulator */ private $funcCallManipulator; - public function __construct(\Rector\Core\NodeManipulator\FuncCallManipulator $funcCallManipulator) + public function __construct(FuncCallManipulator $funcCallManipulator) { $this->funcCallManipulator = $funcCallManipulator; } - public function createArrayFromCompactFuncCall(\PhpParser\Node\Expr\FuncCall $compactFuncCall) : \PhpParser\Node\Expr\Array_ + public function createArrayFromCompactFuncCall(FuncCall $compactFuncCall) : Array_ { $compactVariableNames = $this->funcCallManipulator->extractArgumentsFromCompactFuncCalls([$compactFuncCall]); - $array = new \PhpParser\Node\Expr\Array_(); + $array = new Array_(); foreach ($compactVariableNames as $compactVariableName) { - $arrayItem = new \PhpParser\Node\Expr\ArrayItem(new \PhpParser\Node\Expr\Variable($compactVariableName), new \PhpParser\Node\Scalar\String_($compactVariableName)); + $arrayItem = new ArrayItem(new Variable($compactVariableName), new String_($compactVariableName)); $array->items[] = $arrayItem; } return $array; diff --git a/vendor/rector/rector-symfony/src/NodeFactory/BareLogoutClassMethodFactory.php b/vendor/rector/rector-symfony/src/NodeFactory/BareLogoutClassMethodFactory.php index 6fc9b52bf91..7a8155c7280 100644 --- a/vendor/rector/rector-symfony/src/NodeFactory/BareLogoutClassMethodFactory.php +++ b/vendor/rector/rector-symfony/src/NodeFactory/BareLogoutClassMethodFactory.php @@ -23,25 +23,25 @@ final class BareLogoutClassMethodFactory * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(NodeFactory $nodeFactory, PhpVersionProvider $phpVersionProvider) { $this->nodeFactory = $nodeFactory; $this->phpVersionProvider = $phpVersionProvider; } - public function create() : \PhpParser\Node\Stmt\ClassMethod + public function create() : ClassMethod { $classMethod = $this->nodeFactory->createPublicMethod('onLogout'); - $variable = new \PhpParser\Node\Expr\Variable('logoutEvent'); + $variable = new Variable('logoutEvent'); $classMethod->params[] = $this->createLogoutEventParam($variable); - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::VOID_TYPE)) { - $classMethod->returnType = new \PhpParser\Node\Identifier('void'); + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::VOID_TYPE)) { + $classMethod->returnType = new Identifier('void'); } return $classMethod; } - private function createLogoutEventParam(\PhpParser\Node\Expr\Variable $variable) : \PhpParser\Node\Param + private function createLogoutEventParam(Variable $variable) : Param { - $param = new \PhpParser\Node\Param($variable); - $param->type = new \PhpParser\Node\Name\FullyQualified('Symfony\\Component\\Security\\Http\\Event\\LogoutEvent'); + $param = new Param($variable); + $param->type = new FullyQualified('Symfony\\Component\\Security\\Http\\Event\\LogoutEvent'); return $param; } } diff --git a/vendor/rector/rector-symfony/src/NodeFactory/EventReferenceFactory.php b/vendor/rector/rector-symfony/src/NodeFactory/EventReferenceFactory.php index 61939ca6fe9..78d1c721762 100644 --- a/vendor/rector/rector-symfony/src/NodeFactory/EventReferenceFactory.php +++ b/vendor/rector/rector-symfony/src/NodeFactory/EventReferenceFactory.php @@ -21,7 +21,7 @@ final class EventReferenceFactory * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(NodeFactory $nodeFactory, ReflectionProvider $reflectionProvider) { $this->nodeFactory = $nodeFactory; $this->reflectionProvider = $reflectionProvider; @@ -30,7 +30,7 @@ final class EventReferenceFactory * @param EventNameToClassAndConstant[] $eventNamesToClassConstants * @return String_|ClassConstFetch */ - public function createEventName(string $eventName, array $eventNamesToClassConstants) : \PhpParser\Node + public function createEventName(string $eventName, array $eventNamesToClassConstants) : Node { if ($this->reflectionProvider->hasClass($eventName)) { return $this->nodeFactory->createClassConstReference($eventName); @@ -42,6 +42,6 @@ final class EventReferenceFactory } return $this->nodeFactory->createClassConstFetch($eventNameToClassConstant->getEventClass(), $eventNameToClassConstant->getEventConstant()); } - return new \PhpParser\Node\Scalar\String_($eventName); + return new String_($eventName); } } diff --git a/vendor/rector/rector-symfony/src/NodeFactory/FormType/BuildFormOptionAssignsFactory.php b/vendor/rector/rector-symfony/src/NodeFactory/FormType/BuildFormOptionAssignsFactory.php index fb18e437738..f707b01b6ad 100644 --- a/vendor/rector/rector-symfony/src/NodeFactory/FormType/BuildFormOptionAssignsFactory.php +++ b/vendor/rector/rector-symfony/src/NodeFactory/FormType/BuildFormOptionAssignsFactory.php @@ -18,9 +18,9 @@ final class BuildFormOptionAssignsFactory { $expressions = []; foreach ($paramNames as $paramName) { - $arrayDimFetch = new \PhpParser\Node\Expr\ArrayDimFetch(new \PhpParser\Node\Expr\Variable('options'), new \PhpParser\Node\Scalar\String_($paramName)); - $assign = new \PhpParser\Node\Expr\Assign(new \PhpParser\Node\Expr\Variable($paramName), $arrayDimFetch); - $expressions[] = new \PhpParser\Node\Stmt\Expression($assign); + $arrayDimFetch = new ArrayDimFetch(new Variable('options'), new String_($paramName)); + $assign = new Assign(new Variable($paramName), $arrayDimFetch); + $expressions[] = new Expression($assign); } return $expressions; } diff --git a/vendor/rector/rector-symfony/src/NodeFactory/GetSubscribedEventsClassMethodFactory.php b/vendor/rector/rector-symfony/src/NodeFactory/GetSubscribedEventsClassMethodFactory.php index b4a728669a7..7f47c1df001 100644 --- a/vendor/rector/rector-symfony/src/NodeFactory/GetSubscribedEventsClassMethodFactory.php +++ b/vendor/rector/rector-symfony/src/NodeFactory/GetSubscribedEventsClassMethodFactory.php @@ -64,7 +64,7 @@ final class GetSubscribedEventsClassMethodFactory * @var \Rector\Symfony\NodeFactory\EventReferenceFactory */ private $eventReferenceFactory; - public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\Privatization\NodeManipulator\VisibilityManipulator $visibilityManipulator, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\Symfony\NodeFactory\EventReferenceFactory $eventReferenceFactory) + public function __construct(NodeFactory $nodeFactory, VisibilityManipulator $visibilityManipulator, PhpVersionProvider $phpVersionProvider, PhpDocInfoFactory $phpDocInfoFactory, PhpDocTypeChanger $phpDocTypeChanger, \Rector\Symfony\NodeFactory\EventReferenceFactory $eventReferenceFactory) { $this->nodeFactory = $nodeFactory; $this->visibilityManipulator = $visibilityManipulator; @@ -76,15 +76,15 @@ final class GetSubscribedEventsClassMethodFactory /** * @param EventReferenceToMethodNameInterface[] $eventReferencesToMethodNames */ - public function create(array $eventReferencesToMethodNames) : \PhpParser\Node\Stmt\ClassMethod + public function create(array $eventReferencesToMethodNames) : ClassMethod { $getSubscribersClassMethod = $this->createClassMethod(); - $eventsToMethodsArray = new \PhpParser\Node\Expr\Array_(); + $eventsToMethodsArray = new Array_(); foreach ($eventReferencesToMethodNames as $eventReferenceToMethodName) { - $priority = $eventReferenceToMethodName instanceof \Rector\Symfony\ValueObject\EventReferenceToMethodNameWithPriority ? $eventReferenceToMethodName->getPriority() : null; + $priority = $eventReferenceToMethodName instanceof EventReferenceToMethodNameWithPriority ? $eventReferenceToMethodName->getPriority() : null; $eventsToMethodsArray->items[] = $this->createArrayItemFromMethodAndPriority($priority, $eventReferenceToMethodName->getMethodName(), $eventReferenceToMethodName->getClassConstFetch()); } - $getSubscribersClassMethod->stmts[] = new \PhpParser\Node\Stmt\Return_($eventsToMethodsArray); + $getSubscribersClassMethod->stmts[] = new Return_($eventsToMethodsArray); $this->decorateClassMethodWithReturnType($getSubscribersClassMethod); return $getSubscribersClassMethod; } @@ -92,10 +92,10 @@ final class GetSubscribedEventsClassMethodFactory * @param array $eventsToMethods * @param EventNameToClassAndConstant[] $eventNamesToClassConstants */ - public function createFromServiceDefinitionsAndEventsToMethods(array $eventsToMethods, array $eventNamesToClassConstants) : \PhpParser\Node\Stmt\ClassMethod + public function createFromServiceDefinitionsAndEventsToMethods(array $eventsToMethods, array $eventNamesToClassConstants) : ClassMethod { $getSubscribersClassMethod = $this->createClassMethod(); - $eventsToMethodsArray = new \PhpParser\Node\Expr\Array_(); + $eventsToMethodsArray = new Array_(); foreach ($eventsToMethods as $eventName => $methodNamesWithPriorities) { $eventNameExpr = $this->eventReferenceFactory->createEventName($eventName, $eventNamesToClassConstants); // just method name, without a priority @@ -108,32 +108,32 @@ final class GetSubscribedEventsClassMethodFactory $this->createMultipleMethods($methodNamesWithPriorities, $eventNameExpr, $eventsToMethodsArray, $eventName); } } - $getSubscribersClassMethod->stmts[] = new \PhpParser\Node\Stmt\Return_($eventsToMethodsArray); + $getSubscribersClassMethod->stmts[] = new Return_($eventsToMethodsArray); $this->decorateClassMethodWithReturnType($getSubscribersClassMethod); return $getSubscribersClassMethod; } - private function createClassMethod() : \PhpParser\Node\Stmt\ClassMethod + private function createClassMethod() : ClassMethod { $classMethod = $this->nodeFactory->createPublicMethod(self::GET_SUBSCRIBED_EVENTS_METHOD_NAME); $this->visibilityManipulator->makeStatic($classMethod); return $classMethod; } - private function createArrayItemFromMethodAndPriority(?int $priority, string $methodName, \PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr\ArrayItem + private function createArrayItemFromMethodAndPriority(?int $priority, string $methodName, Expr $expr) : ArrayItem { if ($priority !== null && $priority !== 0) { - $methodNameWithPriorityArray = new \PhpParser\Node\Expr\Array_(); - $methodNameWithPriorityArray->items[] = new \PhpParser\Node\Expr\ArrayItem(new \PhpParser\Node\Scalar\String_($methodName)); - $methodNameWithPriorityArray->items[] = new \PhpParser\Node\Expr\ArrayItem(new \PhpParser\Node\Scalar\LNumber($priority)); - return new \PhpParser\Node\Expr\ArrayItem($methodNameWithPriorityArray, $expr); + $methodNameWithPriorityArray = new Array_(); + $methodNameWithPriorityArray->items[] = new ArrayItem(new String_($methodName)); + $methodNameWithPriorityArray->items[] = new ArrayItem(new LNumber($priority)); + return new ArrayItem($methodNameWithPriorityArray, $expr); } - return new \PhpParser\Node\Expr\ArrayItem(new \PhpParser\Node\Scalar\String_($methodName), $expr); + return new ArrayItem(new String_($methodName), $expr); } - private function decorateClassMethodWithReturnType(\PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function decorateClassMethodWithReturnType(ClassMethod $classMethod) : void { - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::SCALAR_TYPES)) { - $classMethod->returnType = new \PhpParser\Node\Identifier('array'); + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::SCALAR_TYPES)) { + $classMethod->returnType = new Identifier('array'); } - $returnType = new \PHPStan\Type\ArrayType(new \PHPStan\Type\StringType(), new \PHPStan\Type\MixedType(\true)); + $returnType = new ArrayType(new StringType(), new MixedType(\true)); $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); $this->phpDocTypeChanger->changeReturnType($phpDocInfo, $returnType); } @@ -141,7 +141,7 @@ final class GetSubscribedEventsClassMethodFactory * @param ServiceDefinition[] $methodNamesWithPriorities * @param \PhpParser\Node\Expr\ClassConstFetch|\PhpParser\Node\Scalar\String_ $expr */ - private function createSingleMethod(array $methodNamesWithPriorities, string $eventName, $expr, \PhpParser\Node\Expr\Array_ $eventsToMethodsArray) : void + private function createSingleMethod(array $methodNamesWithPriorities, string $eventName, $expr, Array_ $eventsToMethodsArray) : void { $methodName = $this->resolveMethodName($methodNamesWithPriorities[0], $eventName); $priority = $this->resolvePriority($methodNamesWithPriorities[0], $eventName); @@ -154,13 +154,13 @@ final class GetSubscribedEventsClassMethodFactory * @param ServiceDefinition[] $methodNamesWithPriorities * @param \PhpParser\Node\Expr\ClassConstFetch|\PhpParser\Node\Scalar\String_ $expr */ - private function createMultipleMethods(array $methodNamesWithPriorities, $expr, \PhpParser\Node\Expr\Array_ $eventsToMethodsArray, string $eventName) : void + private function createMultipleMethods(array $methodNamesWithPriorities, $expr, Array_ $eventsToMethodsArray, string $eventName) : void { $eventItems = []; $alreadyUsedTags = []; foreach ($methodNamesWithPriorities as $methodNameWithPriority) { foreach ($methodNameWithPriority->getTags() as $tag) { - if (!$tag instanceof \Rector\Symfony\ValueObject\Tag\EventListenerTag) { + if (!$tag instanceof EventListenerTag) { continue; } if ($this->shouldSkip($eventName, $tag, $alreadyUsedTags)) { @@ -170,15 +170,15 @@ final class GetSubscribedEventsClassMethodFactory $alreadyUsedTags[] = $tag; } } - $multipleMethodsArray = new \PhpParser\Node\Expr\Array_($eventItems); - $eventsToMethodsArray->items[] = new \PhpParser\Node\Expr\ArrayItem($multipleMethodsArray, $expr); + $multipleMethodsArray = new Array_($eventItems); + $eventsToMethodsArray->items[] = new ArrayItem($multipleMethodsArray, $expr); } - private function resolveMethodName(\Rector\Symfony\ValueObject\ServiceDefinition $serviceDefinition, string $eventName) : ?string + private function resolveMethodName(ServiceDefinition $serviceDefinition, string $eventName) : ?string { /** @var EventListenerTag[]|Tag[] $eventTags */ $eventTags = $serviceDefinition->getTags(); foreach ($eventTags as $eventTag) { - if (!$eventTag instanceof \Rector\Symfony\ValueObject\Tag\EventListenerTag) { + if (!$eventTag instanceof EventListenerTag) { continue; } if ($eventTag->getEvent() !== $eventName) { @@ -188,12 +188,12 @@ final class GetSubscribedEventsClassMethodFactory } return null; } - private function resolvePriority(\Rector\Symfony\ValueObject\ServiceDefinition $serviceDefinition, string $eventName) : ?int + private function resolvePriority(ServiceDefinition $serviceDefinition, string $eventName) : ?int { /** @var EventListenerTag[]|Tag[] $eventTags */ $eventTags = $serviceDefinition->getTags(); foreach ($eventTags as $eventTag) { - if (!$eventTag instanceof \Rector\Symfony\ValueObject\Tag\EventListenerTag) { + if (!$eventTag instanceof EventListenerTag) { continue; } if ($eventTag->getEvent() !== $eventName) { @@ -206,21 +206,21 @@ final class GetSubscribedEventsClassMethodFactory /** * @param TagInterface[] $alreadyUsedTags */ - private function shouldSkip(string $eventName, \Rector\Symfony\ValueObject\Tag\EventListenerTag $eventListenerTag, array $alreadyUsedTags) : bool + private function shouldSkip(string $eventName, EventListenerTag $eventListenerTag, array $alreadyUsedTags) : bool { if ($eventName !== $eventListenerTag->getEvent()) { return \true; } return \in_array($eventListenerTag, $alreadyUsedTags, \true); } - private function createEventItem(\Rector\Symfony\ValueObject\Tag\EventListenerTag $eventListenerTag) : \PhpParser\Node\Expr\ArrayItem + private function createEventItem(EventListenerTag $eventListenerTag) : ArrayItem { if ($eventListenerTag->getPriority() !== 0) { - $methodNameWithPriorityArray = new \PhpParser\Node\Expr\Array_(); - $methodNameWithPriorityArray->items[] = new \PhpParser\Node\Expr\ArrayItem(new \PhpParser\Node\Scalar\String_($eventListenerTag->getMethod())); - $methodNameWithPriorityArray->items[] = new \PhpParser\Node\Expr\ArrayItem(new \PhpParser\Node\Scalar\LNumber($eventListenerTag->getPriority())); - return new \PhpParser\Node\Expr\ArrayItem($methodNameWithPriorityArray); + $methodNameWithPriorityArray = new Array_(); + $methodNameWithPriorityArray->items[] = new ArrayItem(new String_($eventListenerTag->getMethod())); + $methodNameWithPriorityArray->items[] = new ArrayItem(new LNumber($eventListenerTag->getPriority())); + return new ArrayItem($methodNameWithPriorityArray); } - return new \PhpParser\Node\Expr\ArrayItem(new \PhpParser\Node\Scalar\String_($eventListenerTag->getMethod())); + return new ArrayItem(new String_($eventListenerTag->getMethod())); } } diff --git a/vendor/rector/rector-symfony/src/NodeFactory/InvokableController/ActiveClassElementsFilter.php b/vendor/rector/rector-symfony/src/NodeFactory/InvokableController/ActiveClassElementsFilter.php index 1f58f3bb572..4a0dfd435c4 100644 --- a/vendor/rector/rector-symfony/src/NodeFactory/InvokableController/ActiveClassElementsFilter.php +++ b/vendor/rector/rector-symfony/src/NodeFactory/InvokableController/ActiveClassElementsFilter.php @@ -16,16 +16,16 @@ final class ActiveClassElementsFilter * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } /** * @return ClassConst[] */ - public function filterClassConsts(\PhpParser\Node\Stmt\Class_ $class, \Rector\Symfony\ValueObject\InvokableController\ActiveClassElements $activeClassElements) : array + public function filterClassConsts(Class_ $class, ActiveClassElements $activeClassElements) : array { - return \array_filter($class->getConstants(), function (\PhpParser\Node\Stmt\ClassConst $classConst) use($activeClassElements) { + return \array_filter($class->getConstants(), function (ClassConst $classConst) use($activeClassElements) { /** @var string $constantName */ $constantName = $this->nodeNameResolver->getName($classConst); return $activeClassElements->hasConstantName($constantName); @@ -34,9 +34,9 @@ final class ActiveClassElementsFilter /** * @return Property[] */ - public function filterProperties(\PhpParser\Node\Stmt\Class_ $class, \Rector\Symfony\ValueObject\InvokableController\ActiveClassElements $activeClassElements) : array + public function filterProperties(Class_ $class, ActiveClassElements $activeClassElements) : array { - return \array_filter($class->getProperties(), function (\PhpParser\Node\Stmt\Property $property) use($activeClassElements) { + return \array_filter($class->getProperties(), function (Property $property) use($activeClassElements) { // keep only property used in current action $propertyName = $this->nodeNameResolver->getName($property); return $activeClassElements->hasPropertyName($propertyName); @@ -45,9 +45,9 @@ final class ActiveClassElementsFilter /** * @return ClassMethod[] */ - public function filterClassMethod(\PhpParser\Node\Stmt\Class_ $class, \Rector\Symfony\ValueObject\InvokableController\ActiveClassElements $activeClassElements) : array + public function filterClassMethod(Class_ $class, ActiveClassElements $activeClassElements) : array { - return \array_filter($class->getMethods(), function (\PhpParser\Node\Stmt\ClassMethod $classMethod) use($activeClassElements) { + return \array_filter($class->getMethods(), function (ClassMethod $classMethod) use($activeClassElements) { if ($classMethod->isPublic()) { return \false; } diff --git a/vendor/rector/rector-symfony/src/NodeFactory/InvokableControllerClassFactory.php b/vendor/rector/rector-symfony/src/NodeFactory/InvokableControllerClassFactory.php index df08e973fa4..a6e0cd17e8e 100644 --- a/vendor/rector/rector-symfony/src/NodeFactory/InvokableControllerClassFactory.php +++ b/vendor/rector/rector-symfony/src/NodeFactory/InvokableControllerClassFactory.php @@ -38,31 +38,31 @@ final class InvokableControllerClassFactory * @var \Rector\Symfony\NodeFactory\InvokableController\ActiveClassElementsFilter */ private $activeClassElementsFilter; - public function __construct(\Rector\Symfony\NodeFactory\InvokableControllerNameFactory $invokableControllerNameFactory, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Symfony\NodeAnalyzer\InvokableAnalyzer\ActiveClassElementsClassMethodResolver $activeClassElementsClassMethodResolver, \Rector\Symfony\NodeFactory\InvokableController\ActiveClassElementsFilter $activeClassElementsFilter) + public function __construct(\Rector\Symfony\NodeFactory\InvokableControllerNameFactory $invokableControllerNameFactory, NodeNameResolver $nodeNameResolver, ActiveClassElementsClassMethodResolver $activeClassElementsClassMethodResolver, ActiveClassElementsFilter $activeClassElementsFilter) { $this->invokableControllerNameFactory = $invokableControllerNameFactory; $this->nodeNameResolver = $nodeNameResolver; $this->activeClassElementsClassMethodResolver = $activeClassElementsClassMethodResolver; $this->activeClassElementsFilter = $activeClassElementsFilter; } - public function createWithActionClassMethod(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\ClassMethod $actionClassMethod) : \PhpParser\Node\Stmt\Class_ + public function createWithActionClassMethod(Class_ $class, ClassMethod $actionClassMethod) : Class_ { $controllerName = $this->createControllerName($class, $actionClassMethod); - $actionClassMethod->name = new \PhpParser\Node\Identifier(\Rector\Core\ValueObject\MethodName::INVOKE); + $actionClassMethod->name = new Identifier(MethodName::INVOKE); $newClass = clone $class; $newClassStmts = $this->resolveNewClassStmts($actionClassMethod, $class); - $newClass->name = new \PhpParser\Node\Identifier($controllerName); + $newClass->name = new Identifier($controllerName); $newClass->stmts = $newClassStmts; return $newClass; } - private function createControllerName(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\ClassMethod $actionClassMethod) : string + private function createControllerName(Class_ $class, ClassMethod $actionClassMethod) : string { - if (!$class->name instanceof \PhpParser\Node\Identifier) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$class->name instanceof Identifier) { + throw new ShouldNotHappenException(); } return $this->invokableControllerNameFactory->createControllerName($class->name, $actionClassMethod->name->toString()); } - private function filterOutUnusedDependencies(\PhpParser\Node\Stmt\ClassMethod $classMethod, \Rector\Symfony\ValueObject\InvokableController\ActiveClassElements $activeClassElements) : \PhpParser\Node\Stmt\ClassMethod + private function filterOutUnusedDependencies(ClassMethod $classMethod, ActiveClassElements $activeClassElements) : ClassMethod { // to keep original method in other run untouched $classMethod = clone $classMethod; @@ -75,20 +75,20 @@ final class InvokableControllerClassFactory $this->filterOutUnusedPropertyAssigns($classMethod, $activeClassElements); return $classMethod; } - private function filterOutUnusedPropertyAssigns(\PhpParser\Node\Stmt\ClassMethod $classMethod, \Rector\Symfony\ValueObject\InvokableController\ActiveClassElements $activeClassElements) : void + private function filterOutUnusedPropertyAssigns(ClassMethod $classMethod, ActiveClassElements $activeClassElements) : void { if (!\is_array($classMethod->stmts)) { return; } foreach ($classMethod->stmts as $key => $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { continue; } $stmtExpr = $stmt->expr; - if (!$stmtExpr instanceof \PhpParser\Node\Expr\Assign) { + if (!$stmtExpr instanceof Assign) { continue; } - if (!$stmtExpr->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$stmtExpr->var instanceof PropertyFetch) { continue; } $assignPropertyFetch = $stmtExpr->var; @@ -105,7 +105,7 @@ final class InvokableControllerClassFactory /** * @return Stmt[] */ - private function resolveNewClassStmts(\PhpParser\Node\Stmt\ClassMethod $actionClassMethod, \PhpParser\Node\Stmt\Class_ $class) : array + private function resolveNewClassStmts(ClassMethod $actionClassMethod, Class_ $class) : array { $activeClassElements = $this->activeClassElementsClassMethodResolver->resolve($actionClassMethod); $activeClassConsts = $this->activeClassElementsFilter->filterClassConsts($class, $activeClassElements); @@ -114,7 +114,7 @@ final class InvokableControllerClassFactory $newClassStmts = \array_merge($activeClassConsts, $activeProperties); foreach ($class->getMethods() as $classMethod) { // avoid duplicated names - if ($this->nodeNameResolver->isName($classMethod->name, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if ($this->nodeNameResolver->isName($classMethod->name, MethodName::CONSTRUCT)) { $classMethod = $this->filterOutUnusedDependencies($classMethod, $activeClassElements); $newClassStmts[] = $classMethod; } diff --git a/vendor/rector/rector-symfony/src/NodeFactory/InvokableControllerNameFactory.php b/vendor/rector/rector-symfony/src/NodeFactory/InvokableControllerNameFactory.php index 7c6867c45b1..0f48c543fb7 100644 --- a/vendor/rector/rector-symfony/src/NodeFactory/InvokableControllerNameFactory.php +++ b/vendor/rector/rector-symfony/src/NodeFactory/InvokableControllerNameFactory.php @@ -7,16 +7,16 @@ use RectorPrefix20220607\Nette\Utils\Strings; use PhpParser\Node\Identifier; final class InvokableControllerNameFactory { - public function createControllerName(\PhpParser\Node\Identifier $controllerIdentifier, string $actionMethodName) : string + public function createControllerName(Identifier $controllerIdentifier, string $actionMethodName) : string { $oldClassName = $controllerIdentifier->toString(); if (\strncmp($actionMethodName, 'action', \strlen('action')) === 0) { - $actionMethodName = \RectorPrefix20220607\Nette\Utils\Strings::substring($actionMethodName, \strlen('Action')); + $actionMethodName = Strings::substring($actionMethodName, \strlen('Action')); } if (\substr_compare($actionMethodName, 'Action', -\strlen('Action')) === 0) { - $actionMethodName = \RectorPrefix20220607\Nette\Utils\Strings::substring($actionMethodName, 0, -\strlen('Action')); + $actionMethodName = Strings::substring($actionMethodName, 0, -\strlen('Action')); } $actionMethodName = \ucfirst($actionMethodName); - return \RectorPrefix20220607\Nette\Utils\Strings::replace($oldClassName, '#(.*?)Controller#', '$1' . $actionMethodName . 'Controller'); + return Strings::replace($oldClassName, '#(.*?)Controller#', '$1' . $actionMethodName . 'Controller'); } } diff --git a/vendor/rector/rector-symfony/src/NodeFactory/OnLogoutClassMethodFactory.php b/vendor/rector/rector-symfony/src/NodeFactory/OnLogoutClassMethodFactory.php index d123ae1c241..66a049eaf8a 100644 --- a/vendor/rector/rector-symfony/src/NodeFactory/OnLogoutClassMethodFactory.php +++ b/vendor/rector/rector-symfony/src/NodeFactory/OnLogoutClassMethodFactory.php @@ -33,13 +33,13 @@ final class OnLogoutClassMethodFactory * @var \Rector\Core\NodeAnalyzer\ParamAnalyzer */ private $paramAnalyzer; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Symfony\NodeFactory\BareLogoutClassMethodFactory $bareLogoutClassMethodFactory, \Rector\Core\NodeAnalyzer\ParamAnalyzer $paramAnalyzer) + public function __construct(NodeNameResolver $nodeNameResolver, \Rector\Symfony\NodeFactory\BareLogoutClassMethodFactory $bareLogoutClassMethodFactory, ParamAnalyzer $paramAnalyzer) { $this->nodeNameResolver = $nodeNameResolver; $this->bareLogoutClassMethodFactory = $bareLogoutClassMethodFactory; $this->paramAnalyzer = $paramAnalyzer; } - public function createFromLogoutClassMethod(\PhpParser\Node\Stmt\ClassMethod $logoutClassMethod) : \PhpParser\Node\Stmt\ClassMethod + public function createFromLogoutClassMethod(ClassMethod $logoutClassMethod) : ClassMethod { $classMethod = $this->bareLogoutClassMethodFactory->create(); $assignStmts = $this->createAssignStmtFromOldClassMethod($logoutClassMethod); @@ -49,7 +49,7 @@ final class OnLogoutClassMethodFactory /** * @return Stmt[] */ - private function createAssignStmtFromOldClassMethod(\PhpParser\Node\Stmt\ClassMethod $onLogoutSuccessClassMethod) : array + private function createAssignStmtFromOldClassMethod(ClassMethod $onLogoutSuccessClassMethod) : array { $usedParams = $this->resolveUsedParams($onLogoutSuccessClassMethod); return $this->createAssignStmts($usedParams); @@ -57,7 +57,7 @@ final class OnLogoutClassMethodFactory /** * @return Param[] */ - private function resolveUsedParams(\PhpParser\Node\Stmt\ClassMethod $logoutClassMethod) : array + private function resolveUsedParams(ClassMethod $logoutClassMethod) : array { $usedParams = []; foreach ($logoutClassMethod->params as $oldParam) { @@ -74,15 +74,15 @@ final class OnLogoutClassMethodFactory */ private function createAssignStmts(array $params) : array { - $logoutEventVariable = new \PhpParser\Node\Expr\Variable('logoutEvent'); + $logoutEventVariable = new Variable('logoutEvent'); $assignStmts = []; foreach ($params as $param) { foreach (self::PARAMETER_TO_GETTER_NAMES as $parameterName => $getterName) { if (!$this->nodeNameResolver->isName($param, $parameterName)) { continue; } - $assign = new \PhpParser\Node\Expr\Assign($param->var, new \PhpParser\Node\Expr\MethodCall($logoutEventVariable, $getterName)); - $assignStmts[] = new \PhpParser\Node\Stmt\Expression($assign); + $assign = new Assign($param->var, new MethodCall($logoutEventVariable, $getterName)); + $assignStmts[] = new Expression($assign); } } return $assignStmts; diff --git a/vendor/rector/rector-symfony/src/NodeFactory/OnSuccessLogoutClassMethodFactory.php b/vendor/rector/rector-symfony/src/NodeFactory/OnSuccessLogoutClassMethodFactory.php index b4667c70f25..dee868d484e 100644 --- a/vendor/rector/rector-symfony/src/NodeFactory/OnSuccessLogoutClassMethodFactory.php +++ b/vendor/rector/rector-symfony/src/NodeFactory/OnSuccessLogoutClassMethodFactory.php @@ -42,20 +42,20 @@ final class OnSuccessLogoutClassMethodFactory * @var \Rector\Symfony\NodeFactory\BareLogoutClassMethodFactory */ private $bareLogoutClassMethodFactory; - public function __construct(\Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\Symfony\NodeFactory\BareLogoutClassMethodFactory $bareLogoutClassMethodFactory) + public function __construct(NodeFactory $nodeFactory, NodeNameResolver $nodeNameResolver, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, \Rector\Symfony\NodeFactory\BareLogoutClassMethodFactory $bareLogoutClassMethodFactory) { $this->nodeFactory = $nodeFactory; $this->nodeNameResolver = $nodeNameResolver; $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->bareLogoutClassMethodFactory = $bareLogoutClassMethodFactory; } - public function createFromOnLogoutSuccessClassMethod(\PhpParser\Node\Stmt\ClassMethod $onLogoutSuccessClassMethod) : \PhpParser\Node\Stmt\ClassMethod + public function createFromOnLogoutSuccessClassMethod(ClassMethod $onLogoutSuccessClassMethod) : ClassMethod { $classMethod = $this->bareLogoutClassMethodFactory->create(); - $getResponseMethodCall = new \PhpParser\Node\Expr\MethodCall(new \PhpParser\Node\Expr\Variable(self::LOGOUT_EVENT), 'getResponse'); - $notIdentical = new \PhpParser\Node\Expr\BinaryOp\NotIdentical($getResponseMethodCall, $this->nodeFactory->createNull()); - $if = new \PhpParser\Node\Stmt\If_($notIdentical); - $if->stmts[] = new \PhpParser\Node\Stmt\Return_(); + $getResponseMethodCall = new MethodCall(new Variable(self::LOGOUT_EVENT), 'getResponse'); + $notIdentical = new NotIdentical($getResponseMethodCall, $this->nodeFactory->createNull()); + $if = new If_($notIdentical); + $if->stmts[] = new Return_(); // replace `return $response;` with `$logoutEvent->setResponse($response)` $this->replaceReturnResponseWithSetResponse($onLogoutSuccessClassMethod); $this->replaceRequestWithGetRequest($onLogoutSuccessClassMethod); @@ -64,34 +64,34 @@ final class OnSuccessLogoutClassMethodFactory $classMethod->stmts = $classStmts; return $classMethod; } - private function replaceReturnResponseWithSetResponse(\PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function replaceReturnResponseWithSetResponse(ClassMethod $classMethod) : void { - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classMethod, function (\PhpParser\Node $node) : ?Expression { - if (!$node instanceof \PhpParser\Node\Stmt\Return_) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classMethod, function (Node $node) : ?Expression { + if (!$node instanceof Return_) { return null; } if ($node->expr === null) { return null; } $args = $this->nodeFactory->createArgs([$node->expr]); - $methodCall = new \PhpParser\Node\Expr\MethodCall(new \PhpParser\Node\Expr\Variable(self::LOGOUT_EVENT), 'setResponse', $args); - return new \PhpParser\Node\Stmt\Expression($methodCall); + $methodCall = new MethodCall(new Variable(self::LOGOUT_EVENT), 'setResponse', $args); + return new Expression($methodCall); }); } - private function replaceRequestWithGetRequest(\PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function replaceRequestWithGetRequest(ClassMethod $classMethod) : void { - $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classMethod, function (\PhpParser\Node $node) : ?MethodCall { - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classMethod, function (Node $node) : ?MethodCall { + if (!$node instanceof Variable) { return null; } if (!$this->nodeNameResolver->isName($node, 'request')) { return null; } - $parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parent instanceof \PhpParser\Node\Param) { + $parent = $node->getAttribute(AttributeKey::PARENT_NODE); + if ($parent instanceof Param) { return null; } - return new \PhpParser\Node\Expr\MethodCall(new \PhpParser\Node\Expr\Variable(self::LOGOUT_EVENT), 'getRequest'); + return new MethodCall(new Variable(self::LOGOUT_EVENT), 'getRequest'); }); } } diff --git a/vendor/rector/rector-symfony/src/NodeFactory/ThisRenderFactory.php b/vendor/rector/rector-symfony/src/NodeFactory/ThisRenderFactory.php index 2baac197451..e43f1ad6691 100644 --- a/vendor/rector/rector-symfony/src/NodeFactory/ThisRenderFactory.php +++ b/vendor/rector/rector-symfony/src/NodeFactory/ThisRenderFactory.php @@ -47,7 +47,7 @@ final class ThisRenderFactory * @var \Rector\Symfony\Helper\TemplateGuesser */ private $templateGuesser; - public function __construct(\Rector\Symfony\NodeFactory\ArrayFromCompactFactory $arrayFromCompactFactory, \Rector\Core\PhpParser\Node\NodeFactory $nodeFactory, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver, \Rector\Symfony\Helper\TemplateGuesser $templateGuesser) + public function __construct(\Rector\Symfony\NodeFactory\ArrayFromCompactFactory $arrayFromCompactFactory, NodeFactory $nodeFactory, NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver, TemplateGuesser $templateGuesser) { $this->arrayFromCompactFactory = $arrayFromCompactFactory; $this->nodeFactory = $nodeFactory; @@ -55,7 +55,7 @@ final class ThisRenderFactory $this->nodeTypeResolver = $nodeTypeResolver; $this->templateGuesser = $templateGuesser; } - public function create(?\PhpParser\Node\Stmt\Return_ $return, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $templateDoctrineAnnotationTagValueNode, \PhpParser\Node\Stmt\ClassMethod $classMethod) : \PhpParser\Node\Expr\MethodCall + public function create(?Return_ $return, DoctrineAnnotationTagValueNode $templateDoctrineAnnotationTagValueNode, ClassMethod $classMethod) : MethodCall { $renderArguments = $this->resolveRenderArguments($return, $templateDoctrineAnnotationTagValueNode, $classMethod); return $this->nodeFactory->createMethodCall('this', 'render', $renderArguments); @@ -63,17 +63,17 @@ final class ThisRenderFactory /** * @return Arg[] */ - private function resolveRenderArguments(?\PhpParser\Node\Stmt\Return_ $return, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $templateDoctrineAnnotationTagValueNode, \PhpParser\Node\Stmt\ClassMethod $classMethod) : array + private function resolveRenderArguments(?Return_ $return, DoctrineAnnotationTagValueNode $templateDoctrineAnnotationTagValueNode, ClassMethod $classMethod) : array { $templateNameString = $this->resolveTemplateName($classMethod, $templateDoctrineAnnotationTagValueNode); $arguments = [$templateNameString]; $parametersExpr = $this->resolveParametersExpr($return, $templateDoctrineAnnotationTagValueNode); if ($parametersExpr !== null) { - $arguments[] = new \PhpParser\Node\Arg($parametersExpr); + $arguments[] = new Arg($parametersExpr); } return $this->nodeFactory->createArgs($arguments); } - private function resolveTemplateName(\PhpParser\Node\Stmt\ClassMethod $classMethod, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $templateDoctrineAnnotationTagValueNode) : string + private function resolveTemplateName(ClassMethod $classMethod, DoctrineAnnotationTagValueNode $templateDoctrineAnnotationTagValueNode) : string { $template = $this->resolveTemplate($templateDoctrineAnnotationTagValueNode); if (\is_string($template)) { @@ -81,10 +81,10 @@ final class ThisRenderFactory } return $this->templateGuesser->resolveFromClassMethod($classMethod); } - private function resolveParametersExpr(?\PhpParser\Node\Stmt\Return_ $return, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $templateDoctrineAnnotationTagValueNode) : ?\PhpParser\Node\Expr + private function resolveParametersExpr(?Return_ $return, DoctrineAnnotationTagValueNode $templateDoctrineAnnotationTagValueNode) : ?Expr { $vars = $templateDoctrineAnnotationTagValueNode->getValue('vars'); - if ($vars instanceof \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode) { + if ($vars instanceof CurlyListNode) { $vars = $vars->getValuesWithExplicitSilentAndWithoutQuotes(); } if (\is_array($vars) && $vars !== []) { @@ -93,13 +93,13 @@ final class ThisRenderFactory if ($return === null) { return null; } - if ($return->expr instanceof \PhpParser\Node\Expr\Array_ && $return->expr->items !== []) { + if ($return->expr instanceof Array_ && $return->expr->items !== []) { return $return->expr; } - if ($return->expr instanceof \PhpParser\Node\Expr\MethodCall) { + if ($return->expr instanceof MethodCall) { return $this->resolveMethodCall($return->expr); } - if ($return->expr instanceof \PhpParser\Node\Expr\FuncCall && $this->nodeNameResolver->isName($return->expr, 'compact')) { + if ($return->expr instanceof FuncCall && $this->nodeNameResolver->isName($return->expr, 'compact')) { $compactFunCall = $return->expr; return $this->arrayFromCompactFactory->createArrayFromCompactFuncCall($compactFunCall); } @@ -108,18 +108,18 @@ final class ThisRenderFactory /** * @param string[] $vars */ - private function createArrayFromVars(array $vars) : \PhpParser\Node\Expr\Array_ + private function createArrayFromVars(array $vars) : Array_ { $arrayItems = []; foreach ($vars as $var) { - $arrayItems[] = new \PhpParser\Node\Expr\ArrayItem(new \PhpParser\Node\Expr\Variable($var), new \PhpParser\Node\Scalar\String_($var)); + $arrayItems[] = new ArrayItem(new Variable($var), new String_($var)); } - return new \PhpParser\Node\Expr\Array_($arrayItems); + return new Array_($arrayItems); } - private function resolveMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node\Expr + private function resolveMethodCall(MethodCall $methodCall) : ?Expr { $returnStaticType = $this->nodeTypeResolver->getType($methodCall); - if ($returnStaticType instanceof \PHPStan\Type\ArrayType) { + if ($returnStaticType instanceof ArrayType) { return $methodCall; } return null; @@ -127,7 +127,7 @@ final class ThisRenderFactory /** * @return string|null */ - private function resolveTemplate(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) + private function resolveTemplate(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) { $templateParameter = $doctrineAnnotationTagValueNode->getValue('template'); if (\is_string($templateParameter)) { diff --git a/vendor/rector/rector-symfony/src/NodeFinder/EmptyReturnNodeFinder.php b/vendor/rector/rector-symfony/src/NodeFinder/EmptyReturnNodeFinder.php index ec4ee0d80a7..554016a8dc6 100644 --- a/vendor/rector/rector-symfony/src/NodeFinder/EmptyReturnNodeFinder.php +++ b/vendor/rector/rector-symfony/src/NodeFinder/EmptyReturnNodeFinder.php @@ -14,19 +14,19 @@ final class EmptyReturnNodeFinder * @var \Rector\Core\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder) + public function __construct(BetterNodeFinder $betterNodeFinder) { $this->betterNodeFinder = $betterNodeFinder; } - public function hasNoOrEmptyReturns(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + public function hasNoOrEmptyReturns(ClassMethod $classMethod) : bool { /** @var Return_[] $returns */ - $returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($classMethod, \PhpParser\Node\Stmt\Return_::class); + $returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($classMethod, Return_::class); if ($returns === []) { return \true; } foreach ($returns as $return) { - if ($return->expr instanceof \PhpParser\Node\Expr) { + if ($return->expr instanceof Expr) { continue; } return \true; diff --git a/vendor/rector/rector-symfony/src/NodeRemover/ConstructorDependencyRemover.php b/vendor/rector/rector-symfony/src/NodeRemover/ConstructorDependencyRemover.php index 760bc037268..69c2a288c6a 100644 --- a/vendor/rector/rector-symfony/src/NodeRemover/ConstructorDependencyRemover.php +++ b/vendor/rector/rector-symfony/src/NodeRemover/ConstructorDependencyRemover.php @@ -16,14 +16,14 @@ final class ConstructorDependencyRemover * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; - public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver) + public function __construct(NodeNameResolver $nodeNameResolver) { $this->nodeNameResolver = $nodeNameResolver; } /** * @param string[] $paramNames */ - public function removeParamsByName(\PhpParser\Node\Stmt\ClassMethod $classMethod, array $paramNames) : \PhpParser\Node\Stmt\ClassMethod + public function removeParamsByName(ClassMethod $classMethod, array $paramNames) : ClassMethod { $this->removeParams($classMethod, $paramNames); return $this->removeAssigns($classMethod, $paramNames); @@ -31,7 +31,7 @@ final class ConstructorDependencyRemover /** * @param string[] $paramNames */ - private function removeParams(\PhpParser\Node\Stmt\ClassMethod $classMethod, array $paramNames) : void + private function removeParams(ClassMethod $classMethod, array $paramNames) : void { foreach ($classMethod->params as $key => $param) { if (!$this->nodeNameResolver->isNames($param, $paramNames)) { @@ -43,21 +43,21 @@ final class ConstructorDependencyRemover /** * @param string[] $paramNames */ - private function removeAssigns(\PhpParser\Node\Stmt\ClassMethod $classMethod, array $paramNames) : \PhpParser\Node\Stmt\ClassMethod + private function removeAssigns(ClassMethod $classMethod, array $paramNames) : ClassMethod { // remove assign foreach ((array) $classMethod->stmts as $stmtKey => $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Expression) { + if (!$stmt instanceof Expression) { continue; } - if (!$stmt->expr instanceof \PhpParser\Node\Expr\Assign) { + if (!$stmt->expr instanceof Assign) { continue; } $assign = $stmt->expr; - if (!$assign->expr instanceof \PhpParser\Node\Expr\Variable) { + if (!$assign->expr instanceof Variable) { continue; } - if (!$assign->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$assign->var instanceof PropertyFetch) { continue; } if (!$this->nodeNameResolver->isNames($assign->expr, $paramNames)) { diff --git a/vendor/rector/rector-symfony/src/PhpDocNode/SymfonyRouteTagValueNodeFactory.php b/vendor/rector/rector-symfony/src/PhpDocNode/SymfonyRouteTagValueNodeFactory.php index d94a44b71d4..4657190a71d 100644 --- a/vendor/rector/rector-symfony/src/PhpDocNode/SymfonyRouteTagValueNodeFactory.php +++ b/vendor/rector/rector-symfony/src/PhpDocNode/SymfonyRouteTagValueNodeFactory.php @@ -11,8 +11,8 @@ final class SymfonyRouteTagValueNodeFactory /** * @param array $items */ - public function createFromItems(array $items) : \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode + public function createFromItems(array $items) : DoctrineAnnotationTagValueNode { - return new \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode(new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode(\Rector\Symfony\Enum\SymfonyAnnotation::ROUTE), null, $items, 'path'); + return new DoctrineAnnotationTagValueNode(new IdentifierTypeNode(SymfonyAnnotation::ROUTE), null, $items, 'path'); } } diff --git a/vendor/rector/rector-symfony/src/Printer/NeighbourClassLikePrinter.php b/vendor/rector/rector-symfony/src/Printer/NeighbourClassLikePrinter.php index d4dc0709421..fd34508cb3d 100644 --- a/vendor/rector/rector-symfony/src/Printer/NeighbourClassLikePrinter.php +++ b/vendor/rector/rector-symfony/src/Printer/NeighbourClassLikePrinter.php @@ -12,7 +12,7 @@ use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace; use Rector\Core\PhpParser\Printer\BetterStandardPrinter; use Rector\Core\ValueObject\Application\File; use Rector\FileSystemRector\ValueObject\AddedFileWithContent; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; /** * @todo re-use in https://github.com/rectorphp/rector-src/blob/main/rules/PSR4/Rector/Namespace_/MultipleClassFileToPsr4ClassesRector.php * @@ -36,7 +36,7 @@ final class NeighbourClassLikePrinter * @var \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector */ private $removedAndAddedFilesCollector; - public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\PhpParser\Printer\BetterStandardPrinter $betterStandardPrinter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector) + public function __construct(BetterNodeFinder $betterNodeFinder, BetterStandardPrinter $betterStandardPrinter, RemovedAndAddedFilesCollector $removedAndAddedFilesCollector) { $this->betterNodeFinder = $betterNodeFinder; $this->betterStandardPrinter = $betterStandardPrinter; @@ -45,10 +45,10 @@ final class NeighbourClassLikePrinter /** * @param \PhpParser\Node\Stmt\Namespace_|\Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace $mainNode */ - public function printClassLike(\PhpParser\Node\Stmt\ClassLike $classLike, $mainNode, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo, ?\Rector\Core\ValueObject\Application\File $file = null) : void + public function printClassLike(ClassLike $classLike, $mainNode, SmartFileInfo $smartFileInfo, ?File $file = null) : void { $declares = $this->resolveDeclares($mainNode); - if ($mainNode instanceof \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace) { + if ($mainNode instanceof FileWithoutNamespace) { $nodesToPrint = \array_merge($declares, [$classLike]); } else { // use new class in the namespace @@ -57,10 +57,10 @@ final class NeighbourClassLikePrinter } $fileDestination = $this->createClassLikeFileDestination($classLike, $smartFileInfo); $printedFileContent = $this->betterStandardPrinter->prettyPrintFile($nodesToPrint); - $addedFileWithContent = new \Rector\FileSystemRector\ValueObject\AddedFileWithContent($fileDestination, $printedFileContent); + $addedFileWithContent = new AddedFileWithContent($fileDestination, $printedFileContent); $this->removedAndAddedFilesCollector->addAddedFile($addedFileWithContent); } - private function createClassLikeFileDestination(\PhpParser\Node\Stmt\ClassLike $classLike, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : string + private function createClassLikeFileDestination(ClassLike $classLike, SmartFileInfo $smartFileInfo) : string { $currentDirectory = \dirname($smartFileInfo->getRealPath()); return $currentDirectory . \DIRECTORY_SEPARATOR . $classLike->name . '.php'; @@ -71,8 +71,8 @@ final class NeighbourClassLikePrinter */ private function resolveDeclares($mainNode) : array { - $declare = $this->betterNodeFinder->findFirstPreviousOfTypes($mainNode, [\PhpParser\Node\Stmt\Declare_::class]); - if ($declare instanceof \PhpParser\Node\Stmt\Declare_) { + $declare = $this->betterNodeFinder->findFirstPreviousOfTypes($mainNode, [Declare_::class]); + if ($declare instanceof Declare_) { return [$declare]; } return []; diff --git a/vendor/rector/rector-symfony/src/Rector/BinaryOp/ResponseStatusCodeRector.php b/vendor/rector/rector-symfony/src/Rector/BinaryOp/ResponseStatusCodeRector.php index 82f8dcdb608..b3018c8c026 100644 --- a/vendor/rector/rector-symfony/src/Rector/BinaryOp/ResponseStatusCodeRector.php +++ b/vendor/rector/rector-symfony/src/Rector/BinaryOp/ResponseStatusCodeRector.php @@ -15,12 +15,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\Symfony\NodeAnalyzer\LiteralCallLikeConstFetchReplacer; use Rector\Symfony\TypeAnalyzer\ControllerAnalyzer; use Rector\Symfony\ValueObject\ConstantMap\SymfonyResponseConstantMap; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\BinaryOp\ResponseStatusCodeRector\ResponseStatusCodeRectorTest */ -final class ResponseStatusCodeRector extends \Rector\Core\Rector\AbstractRector +final class ResponseStatusCodeRector extends AbstractRector { /** * @readonly @@ -37,15 +37,15 @@ final class ResponseStatusCodeRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Symfony\NodeAnalyzer\LiteralCallLikeConstFetchReplacer */ private $literalCallLikeConstFetchReplacer; - public function __construct(\Rector\Symfony\TypeAnalyzer\ControllerAnalyzer $controllerAnalyzer, \Rector\Symfony\NodeAnalyzer\LiteralCallLikeConstFetchReplacer $literalCallLikeConstFetchReplacer) + public function __construct(ControllerAnalyzer $controllerAnalyzer, LiteralCallLikeConstFetchReplacer $literalCallLikeConstFetchReplacer) { $this->controllerAnalyzer = $controllerAnalyzer; $this->literalCallLikeConstFetchReplacer = $literalCallLikeConstFetchReplacer; - $this->responseObjectType = new \PHPStan\Type\ObjectType('Symfony\\Component\\HttpFoundation\\Response'); + $this->responseObjectType = new ObjectType('Symfony\\Component\\HttpFoundation\\Response'); } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns status code numbers to constants', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns status code numbers to constants', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\HttpFoundation\Response; class SomeController @@ -82,17 +82,17 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\BinaryOp::class, \PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\New_::class]; + return [BinaryOp::class, MethodCall::class, New_::class]; } /** * @param BinaryOp|MethodCall|New_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\New_) { + if ($node instanceof New_) { return $this->processNew($node); } - if ($node instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node instanceof MethodCall) { return $this->processMethodCall($node); } return $this->processBinaryOp($node); @@ -100,7 +100,7 @@ CODE_SAMPLE /** * @return \PhpParser\Node\Expr\CallLike|null */ - private function processMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) + private function processMethodCall(MethodCall $methodCall) { if ($this->isName($methodCall->name, 'assert*')) { return $this->processAssertMethodCall($methodCall); @@ -114,26 +114,26 @@ CODE_SAMPLE if (!$this->isName($methodCall->name, 'setStatusCode')) { return null; } - return $this->literalCallLikeConstFetchReplacer->replaceArgOnPosition($methodCall, 0, 'Symfony\\Component\\HttpFoundation\\Response', \Rector\Symfony\ValueObject\ConstantMap\SymfonyResponseConstantMap::CODE_TO_CONST); + return $this->literalCallLikeConstFetchReplacer->replaceArgOnPosition($methodCall, 0, 'Symfony\\Component\\HttpFoundation\\Response', SymfonyResponseConstantMap::CODE_TO_CONST); } - private function processBinaryOp(\PhpParser\Node\Expr\BinaryOp $binaryOp) : ?\PhpParser\Node\Expr\BinaryOp + private function processBinaryOp(BinaryOp $binaryOp) : ?BinaryOp { if (!$this->isGetStatusMethod($binaryOp->left) && !$this->isGetStatusMethod($binaryOp->right)) { return null; } - if ($binaryOp->right instanceof \PhpParser\Node\Scalar\LNumber && $this->isGetStatusMethod($binaryOp->left)) { + if ($binaryOp->right instanceof LNumber && $this->isGetStatusMethod($binaryOp->left)) { $binaryOp->right = $this->convertNumberToConstant($binaryOp->right); return $binaryOp; } - if ($binaryOp->left instanceof \PhpParser\Node\Scalar\LNumber && $this->isGetStatusMethod($binaryOp->right)) { + if ($binaryOp->left instanceof LNumber && $this->isGetStatusMethod($binaryOp->right)) { $binaryOp->left = $this->convertNumberToConstant($binaryOp->left); return $binaryOp; } return null; } - private function isGetStatusMethod(\PhpParser\Node $node) : bool + private function isGetStatusMethod(Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$node instanceof MethodCall) { return \false; } if (!$this->isObjectType($node->var, $this->responseObjectType)) { @@ -144,17 +144,17 @@ CODE_SAMPLE /** * @return \PhpParser\Node\Expr\ClassConstFetch|\PhpParser\Node\Scalar\LNumber */ - private function convertNumberToConstant(\PhpParser\Node\Scalar\LNumber $lNumber) + private function convertNumberToConstant(LNumber $lNumber) { - if (!isset(\Rector\Symfony\ValueObject\ConstantMap\SymfonyResponseConstantMap::CODE_TO_CONST[$lNumber->value])) { + if (!isset(SymfonyResponseConstantMap::CODE_TO_CONST[$lNumber->value])) { return $lNumber; } - return $this->nodeFactory->createClassConstFetch($this->responseObjectType->getClassName(), \Rector\Symfony\ValueObject\ConstantMap\SymfonyResponseConstantMap::CODE_TO_CONST[$lNumber->value]); + return $this->nodeFactory->createClassConstFetch($this->responseObjectType->getClassName(), SymfonyResponseConstantMap::CODE_TO_CONST[$lNumber->value]); } /** * @return \PhpParser\Node\Expr\MethodCall|null */ - private function processAssertMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) + private function processAssertMethodCall(MethodCall $methodCall) { $args = $methodCall->getArgs(); if (!isset($args[1])) { @@ -164,26 +164,26 @@ CODE_SAMPLE if (!$this->isGetStatusMethod($secondArg->value)) { return null; } - return $this->literalCallLikeConstFetchReplacer->replaceArgOnPosition($methodCall, 0, 'Symfony\\Component\\HttpFoundation\\Response', \Rector\Symfony\ValueObject\ConstantMap\SymfonyResponseConstantMap::CODE_TO_CONST); + return $this->literalCallLikeConstFetchReplacer->replaceArgOnPosition($methodCall, 0, 'Symfony\\Component\\HttpFoundation\\Response', SymfonyResponseConstantMap::CODE_TO_CONST); } /** * @return \PhpParser\Node\Expr\MethodCall|null */ - private function processRedirectMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) + private function processRedirectMethodCall(MethodCall $methodCall) { if (!$this->controllerAnalyzer->isController($methodCall->var)) { return null; } - return $this->literalCallLikeConstFetchReplacer->replaceArgOnPosition($methodCall, 1, 'Symfony\\Component\\HttpFoundation\\Response', \Rector\Symfony\ValueObject\ConstantMap\SymfonyResponseConstantMap::CODE_TO_CONST); + return $this->literalCallLikeConstFetchReplacer->replaceArgOnPosition($methodCall, 1, 'Symfony\\Component\\HttpFoundation\\Response', SymfonyResponseConstantMap::CODE_TO_CONST); } /** * @return \PhpParser\Node\Expr\New_|null */ - private function processNew(\PhpParser\Node\Expr\New_ $new) + private function processNew(New_ $new) { if (!$this->isObjectType($new->class, $this->responseObjectType)) { return null; } - return $this->literalCallLikeConstFetchReplacer->replaceArgOnPosition($new, 1, 'Symfony\\Component\\HttpFoundation\\Response', \Rector\Symfony\ValueObject\ConstantMap\SymfonyResponseConstantMap::CODE_TO_CONST); + return $this->literalCallLikeConstFetchReplacer->replaceArgOnPosition($new, 1, 'Symfony\\Component\\HttpFoundation\\Response', SymfonyResponseConstantMap::CODE_TO_CONST); } } diff --git a/vendor/rector/rector-symfony/src/Rector/ClassConstFetch/ConsoleExceptionToErrorEventConstantRector.php b/vendor/rector/rector-symfony/src/Rector/ClassConstFetch/ConsoleExceptionToErrorEventConstantRector.php index 46c7aae8bc5..d000c41a93f 100644 --- a/vendor/rector/rector-symfony/src/Rector/ClassConstFetch/ConsoleExceptionToErrorEventConstantRector.php +++ b/vendor/rector/rector-symfony/src/Rector/ClassConstFetch/ConsoleExceptionToErrorEventConstantRector.php @@ -8,8 +8,8 @@ use PhpParser\Node\Expr\ClassConstFetch; use PhpParser\Node\Scalar\String_; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * Covers: * - https://github.com/symfony/symfony/pull/22441/files @@ -17,7 +17,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @see \Rector\Symfony\Tests\Rector\ClassConstFetch\ConsoleExceptionToErrorEventConstantRector\ConsoleExceptionToErrorEventConstantRectorTest */ -final class ConsoleExceptionToErrorEventConstantRector extends \Rector\Core\Rector\AbstractRector +final class ConsoleExceptionToErrorEventConstantRector extends AbstractRector { /** * @readonly @@ -26,28 +26,28 @@ final class ConsoleExceptionToErrorEventConstantRector extends \Rector\Core\Rect private $consoleEventsObjectType; public function __construct() { - $this->consoleEventsObjectType = new \PHPStan\Type\ObjectType('Symfony\\Component\\Console\\ConsoleEvents'); + $this->consoleEventsObjectType = new ObjectType('Symfony\\Component\\Console\\ConsoleEvents'); } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns old event name with EXCEPTION to ERROR constant in Console in Symfony', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('"console.exception"', 'Symfony\\Component\\Console\\ConsoleEvents::ERROR'), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('Symfony\\Component\\Console\\ConsoleEvents::EXCEPTION', 'Symfony\\Component\\Console\\ConsoleEvents::ERROR')]); + return new RuleDefinition('Turns old event name with EXCEPTION to ERROR constant in Console in Symfony', [new CodeSample('"console.exception"', 'Symfony\\Component\\Console\\ConsoleEvents::ERROR'), new CodeSample('Symfony\\Component\\Console\\ConsoleEvents::EXCEPTION', 'Symfony\\Component\\Console\\ConsoleEvents::ERROR')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\ClassConstFetch::class, \PhpParser\Node\Scalar\String_::class]; + return [ClassConstFetch::class, String_::class]; } /** * @param ClassConstFetch|String_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\ClassConstFetch && ($this->isObjectType($node->class, $this->consoleEventsObjectType) && $this->isName($node->name, 'EXCEPTION'))) { + if ($node instanceof ClassConstFetch && ($this->isObjectType($node->class, $this->consoleEventsObjectType) && $this->isName($node->name, 'EXCEPTION'))) { return $this->nodeFactory->createClassConstFetch($this->consoleEventsObjectType->getClassName(), 'ERROR'); } - if (!$node instanceof \PhpParser\Node\Scalar\String_) { + if (!$node instanceof String_) { return null; } if ($node->value !== 'console.exception') { diff --git a/vendor/rector/rector-symfony/src/Rector/ClassMethod/ActionSuffixRemoverRector.php b/vendor/rector/rector-symfony/src/Rector/ClassMethod/ActionSuffixRemoverRector.php index ff2e53833e5..91497c2432b 100644 --- a/vendor/rector/rector-symfony/src/Rector/ClassMethod/ActionSuffixRemoverRector.php +++ b/vendor/rector/rector-symfony/src/Rector/ClassMethod/ActionSuffixRemoverRector.php @@ -9,25 +9,25 @@ use PhpParser\Node\Identifier; use PhpParser\Node\Stmt\ClassMethod; use Rector\Core\Rector\AbstractRector; use Rector\Symfony\Bridge\NodeAnalyzer\ControllerMethodAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\ClassMethod\ActionSuffixRemoverRector\ActionSuffixRemoverRectorTest */ -final class ActionSuffixRemoverRector extends \Rector\Core\Rector\AbstractRector +final class ActionSuffixRemoverRector extends AbstractRector { /** * @readonly * @var \Rector\Symfony\Bridge\NodeAnalyzer\ControllerMethodAnalyzer */ private $controllerMethodAnalyzer; - public function __construct(\Rector\Symfony\Bridge\NodeAnalyzer\ControllerMethodAnalyzer $controllerMethodAnalyzer) + public function __construct(ControllerMethodAnalyzer $controllerMethodAnalyzer) { $this->controllerMethodAnalyzer = $controllerMethodAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Removes Action suffixes from methods in Symfony Controllers', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Removes Action suffixes from methods in Symfony Controllers', [new CodeSample(<<<'CODE_SAMPLE' class SomeController { public function indexAction() @@ -50,12 +50,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->controllerMethodAnalyzer->isAction($node)) { return null; @@ -63,10 +63,10 @@ CODE_SAMPLE $this->removeSuffix($node, 'Action'); return $node; } - private function removeSuffix(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $suffixToRemove) : void + private function removeSuffix(ClassMethod $classMethod, string $suffixToRemove) : void { $name = $this->nodeNameResolver->getName($classMethod); - $newName = \RectorPrefix20220607\Nette\Utils\Strings::replace($name, \sprintf('#%s$#', $suffixToRemove), ''); - $classMethod->name = new \PhpParser\Node\Identifier($newName); + $newName = Strings::replace($name, \sprintf('#%s$#', $suffixToRemove), ''); + $classMethod->name = new Identifier($newName); } } diff --git a/vendor/rector/rector-symfony/src/Rector/ClassMethod/AddRouteAnnotationRector.php b/vendor/rector/rector-symfony/src/Rector/ClassMethod/AddRouteAnnotationRector.php index 412d69ef086..a5372ef1c79 100644 --- a/vendor/rector/rector-symfony/src/Rector/ClassMethod/AddRouteAnnotationRector.php +++ b/vendor/rector/rector-symfony/src/Rector/ClassMethod/AddRouteAnnotationRector.php @@ -12,12 +12,12 @@ use Rector\Symfony\Contract\Bridge\Symfony\Routing\SymfonyRoutesProviderInterfac use Rector\Symfony\Enum\SymfonyAnnotation; use Rector\Symfony\PhpDocNode\SymfonyRouteTagValueNodeFactory; use Rector\Symfony\ValueObject\SymfonyRouteMetadata; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\ClassMethod\AddRouteAnnotationRector\AddRouteAnnotationRectorTest */ -final class AddRouteAnnotationRector extends \Rector\Core\Rector\AbstractRector +final class AddRouteAnnotationRector extends AbstractRector { /** * @readonly @@ -29,19 +29,19 @@ final class AddRouteAnnotationRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Symfony\PhpDocNode\SymfonyRouteTagValueNodeFactory */ private $symfonyRouteTagValueNodeFactory; - public function __construct(\Rector\Symfony\Contract\Bridge\Symfony\Routing\SymfonyRoutesProviderInterface $symfonyRoutesProvider, \Rector\Symfony\PhpDocNode\SymfonyRouteTagValueNodeFactory $symfonyRouteTagValueNodeFactory) + public function __construct(SymfonyRoutesProviderInterface $symfonyRoutesProvider, SymfonyRouteTagValueNodeFactory $symfonyRouteTagValueNodeFactory) { $this->symfonyRoutesProvider = $symfonyRoutesProvider; $this->symfonyRouteTagValueNodeFactory = $symfonyRouteTagValueNodeFactory; } public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { // only public methods can be controller routes if (!$node->isPublic()) { @@ -50,8 +50,8 @@ final class AddRouteAnnotationRector extends \Rector\Core\Rector\AbstractRector if ($node->isStatic()) { return null; } - $class = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$class instanceof Class_) { return null; } if ($this->symfonyRoutesProvider->provide() === []) { @@ -60,11 +60,11 @@ final class AddRouteAnnotationRector extends \Rector\Core\Rector\AbstractRector $controllerReference = $this->resolveControllerReference($class, $node); // is there a route for this annotation? $symfonyRouteMetadata = $this->matchSymfonyRouteMetadataByControllerReference($controllerReference); - if (!$symfonyRouteMetadata instanceof \Rector\Symfony\ValueObject\SymfonyRouteMetadata) { + if (!$symfonyRouteMetadata instanceof SymfonyRouteMetadata) { return null; } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); - $doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass(\Rector\Symfony\Enum\SymfonyAnnotation::ROUTE); + $doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass(SymfonyAnnotation::ROUTE); if ($doctrineAnnotationTagValueNode !== null) { return null; } @@ -73,9 +73,9 @@ final class AddRouteAnnotationRector extends \Rector\Core\Rector\AbstractRector $phpDocInfo->addTagValueNode($symfonyRouteTagValueNode); return $node; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Collect routes from Symfony project router and add Route annotation to controller action', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Collect routes from Symfony project router and add Route annotation to controller action', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; final class SomeController extends AbstractController @@ -101,7 +101,7 @@ final class SomeController extends AbstractController CODE_SAMPLE )]); } - private function resolveControllerReference(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Stmt\ClassMethod $classMethod) : string + private function resolveControllerReference(Class_ $class, ClassMethod $classMethod) : string { $className = $this->nodeNameResolver->getName($class); $methodName = $this->nodeNameResolver->getName($classMethod); @@ -110,9 +110,9 @@ CODE_SAMPLE /** * @param array $defaults */ - private function createDefaults(array $defaults) : \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode + private function createDefaults(array $defaults) : CurlyListNode { - return new \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode(\array_map(static function ($default) { + return new CurlyListNode(\array_map(static function ($default) { switch (\true) { case \is_string($default): return \sprintf('"%s"', $default); @@ -124,17 +124,17 @@ CODE_SAMPLE /** * @param string[] $items */ - private function createCurlyListNodeFromItems(array $items) : \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode + private function createCurlyListNodeFromItems(array $items) : CurlyListNode { $quotedItems = \array_map(static function (string $item) : string { return \sprintf('"%s"', $item); }, $items); - return new \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode($quotedItems); + return new CurlyListNode($quotedItems); } /** * @return array{path: string, name: string, defaults?: CurlyListNode, host?: string, methods?: CurlyListNode, condition?: string} */ - private function createRouteItems(\Rector\Symfony\ValueObject\SymfonyRouteMetadata $symfonyRouteMetadata) : array + private function createRouteItems(SymfonyRouteMetadata $symfonyRouteMetadata) : array { $items = ['path' => \sprintf('"%s"', $symfonyRouteMetadata->getPath()), 'name' => \sprintf('"%s"', $symfonyRouteMetadata->getName())]; $defaultsWithoutController = $symfonyRouteMetadata->getDefaultsWithoutController(); @@ -158,7 +158,7 @@ CODE_SAMPLE } return $items; } - private function matchSymfonyRouteMetadataByControllerReference(string $controllerReference) : ?\Rector\Symfony\ValueObject\SymfonyRouteMetadata + private function matchSymfonyRouteMetadataByControllerReference(string $controllerReference) : ?SymfonyRouteMetadata { foreach ($this->symfonyRoutesProvider->provide() as $symfonyRouteMetadata) { if ($symfonyRouteMetadata->getControllerReference() === $controllerReference) { diff --git a/vendor/rector/rector-symfony/src/Rector/ClassMethod/ConsoleExecuteReturnIntRector.php b/vendor/rector/rector-symfony/src/Rector/ClassMethod/ConsoleExecuteReturnIntRector.php index 3e092e79806..060b2a37731 100644 --- a/vendor/rector/rector-symfony/src/Rector/ClassMethod/ConsoleExecuteReturnIntRector.php +++ b/vendor/rector/rector-symfony/src/Rector/ClassMethod/ConsoleExecuteReturnIntRector.php @@ -19,17 +19,17 @@ use PHPStan\Type\IntegerType; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/symfony/symfony/pull/33775/files * @see \Rector\Symfony\Tests\Rector\ClassMethod\ConsoleExecuteReturnIntRector\ConsoleExecuteReturnIntRectorTest */ -final class ConsoleExecuteReturnIntRector extends \Rector\Core\Rector\AbstractRector +final class ConsoleExecuteReturnIntRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Returns int from Command::execute command', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Returns int from Command::execute command', [new CodeSample(<<<'CODE_SAMPLE' class SomeCommand extends Command { public function execute(InputInterface $input, OutputInterface $output) @@ -54,54 +54,54 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'execute')) { return null; } - $class = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$class instanceof Class_) { return null; } - if (!$this->isObjectType($class, new \PHPStan\Type\ObjectType('Symfony\\Component\\Console\\Command\\Command'))) { + if (!$this->isObjectType($class, new ObjectType('Symfony\\Component\\Console\\Command\\Command'))) { return null; } $this->refactorReturnTypeDeclaration($node); $this->addReturn0ToMethod($node); return $node; } - private function refactorReturnTypeDeclaration(\PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function refactorReturnTypeDeclaration(ClassMethod $classMethod) : void { // already set if ($classMethod->returnType !== null && $this->isName($classMethod->returnType, 'int')) { return; } - $classMethod->returnType = new \PhpParser\Node\Identifier('int'); + $classMethod->returnType = new Identifier('int'); } - private function addReturn0ToMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function addReturn0ToMethod(ClassMethod $classMethod) : void { $hasReturn = \false; - $this->traverseNodesWithCallable((array) $classMethod->getStmts(), function (\PhpParser\Node $node) use($classMethod, &$hasReturn) : ?int { - if ($node instanceof \PhpParser\Node\FunctionLike) { - return \PhpParser\NodeTraverser::DONT_TRAVERSE_CHILDREN; + $this->traverseNodesWithCallable((array) $classMethod->getStmts(), function (Node $node) use($classMethod, &$hasReturn) : ?int { + if ($node instanceof FunctionLike) { + return NodeTraverser::DONT_TRAVERSE_CHILDREN; } - $parentNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - if ($parentNode instanceof \PhpParser\Node && $this->isReturnWithExprIntEquals($parentNode, $node)) { + $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); + if ($parentNode instanceof Node && $this->isReturnWithExprIntEquals($parentNode, $node)) { $hasReturn = \true; return null; } - if (!$node instanceof \PhpParser\Node\Stmt\Return_) { + if (!$node instanceof Return_) { return null; } - if ($node->expr instanceof \PhpParser\Node\Expr\Cast\Int_) { + if ($node->expr instanceof Int_) { return null; } - if ($node->expr instanceof \PhpParser\Node\Expr\Ternary && $this->isIntegerTernaryIfElse($node->expr)) { + if ($node->expr instanceof Ternary && $this->isIntegerTernaryIfElse($node->expr)) { $hasReturn = \true; return null; } @@ -114,70 +114,70 @@ CODE_SAMPLE }); $this->processReturn0ToMethod($hasReturn, $classMethod); } - private function isIntegerTernaryIfElse(\PhpParser\Node\Expr\Ternary $ternary) : bool + private function isIntegerTernaryIfElse(Ternary $ternary) : bool { /** @var Expr|null $if */ $if = $ternary->if; - if (!$if instanceof \PhpParser\Node\Expr) { + if (!$if instanceof Expr) { $if = $ternary->cond; } /** @var Expr $else */ $else = $ternary->else; $ifType = $this->getType($if); $elseType = $this->getType($else); - return $ifType instanceof \PHPStan\Type\IntegerType && $elseType instanceof \PHPStan\Type\IntegerType; + return $ifType instanceof IntegerType && $elseType instanceof IntegerType; } - private function processReturn0ToMethod(bool $hasReturn, \PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function processReturn0ToMethod(bool $hasReturn, ClassMethod $classMethod) : void { if ($hasReturn) { return; } - $classMethod->stmts[] = new \PhpParser\Node\Stmt\Return_(new \PhpParser\Node\Scalar\LNumber(0)); + $classMethod->stmts[] = new Return_(new LNumber(0)); } - private function isReturnWithExprIntEquals(\PhpParser\Node $parentNode, \PhpParser\Node $node) : bool + private function isReturnWithExprIntEquals(Node $parentNode, Node $node) : bool { - if (!$parentNode instanceof \PhpParser\Node\Stmt\Return_) { + if (!$parentNode instanceof Return_) { return \false; } if (!$this->nodeComparator->areNodesEqual($parentNode->expr, $node)) { return \false; } - return $node instanceof \PhpParser\Node\Expr\Cast\Int_; + return $node instanceof Int_; } - private function setReturnTo0InsteadOfNull(\PhpParser\Node\Stmt\Return_ $return) : void + private function setReturnTo0InsteadOfNull(Return_ $return) : void { if ($return->expr === null) { - $return->expr = new \PhpParser\Node\Scalar\LNumber(0); + $return->expr = new LNumber(0); return; } if ($this->valueResolver->isNull($return->expr)) { - $return->expr = new \PhpParser\Node\Scalar\LNumber(0); + $return->expr = new LNumber(0); return; } - if ($return->expr instanceof \PhpParser\Node\Expr\BinaryOp\Coalesce && $this->valueResolver->isNull($return->expr->right)) { - $return->expr->right = new \PhpParser\Node\Scalar\LNumber(0); + if ($return->expr instanceof Coalesce && $this->valueResolver->isNull($return->expr->right)) { + $return->expr->right = new LNumber(0); return; } - if ($return->expr instanceof \PhpParser\Node\Expr\Ternary) { + if ($return->expr instanceof Ternary) { $hasChanged = $this->isSuccessfulRefactorTernaryReturn($return->expr); if ($hasChanged) { return; } } $staticType = $this->getType($return->expr); - if (!$staticType instanceof \PHPStan\Type\IntegerType) { - $return->expr = new \PhpParser\Node\Expr\Cast\Int_($return->expr); + if (!$staticType instanceof IntegerType) { + $return->expr = new Int_($return->expr); } } - private function isSuccessfulRefactorTernaryReturn(\PhpParser\Node\Expr\Ternary $ternary) : bool + private function isSuccessfulRefactorTernaryReturn(Ternary $ternary) : bool { $hasChanged = \false; - if ($ternary->if instanceof \PhpParser\Node\Expr && $this->valueResolver->isNull($ternary->if)) { - $ternary->if = new \PhpParser\Node\Scalar\LNumber(0); + if ($ternary->if instanceof Expr && $this->valueResolver->isNull($ternary->if)) { + $ternary->if = new LNumber(0); $hasChanged = \true; } if ($this->valueResolver->isNull($ternary->else)) { - $ternary->else = new \PhpParser\Node\Scalar\LNumber(0); + $ternary->else = new LNumber(0); $hasChanged = \true; } return $hasChanged; diff --git a/vendor/rector/rector-symfony/src/Rector/ClassMethod/FormTypeGetParentRector.php b/vendor/rector/rector-symfony/src/Rector/ClassMethod/FormTypeGetParentRector.php index e4b6604df72..7997aa760a6 100644 --- a/vendor/rector/rector-symfony/src/Rector/ClassMethod/FormTypeGetParentRector.php +++ b/vendor/rector/rector-symfony/src/Rector/ClassMethod/FormTypeGetParentRector.php @@ -11,25 +11,25 @@ use PhpParser\Node\Stmt\Return_; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\Symfony\FormHelper\FormTypeStringToTypeProvider; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\ClassMethod\FormTypeGetParentRector\FormTypeGetParentRectorTest */ -final class FormTypeGetParentRector extends \Rector\Core\Rector\AbstractRector +final class FormTypeGetParentRector extends AbstractRector { /** * @readonly * @var \Rector\Symfony\FormHelper\FormTypeStringToTypeProvider */ private $formTypeStringToTypeProvider; - public function __construct(\Rector\Symfony\FormHelper\FormTypeStringToTypeProvider $formTypeStringToTypeProvider) + public function __construct(FormTypeStringToTypeProvider $formTypeStringToTypeProvider) { $this->formTypeStringToTypeProvider = $formTypeStringToTypeProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns string Form Type references to their CONSTANT alternatives in `getParent()` and `getExtendedType()` methods in Form in Symfony', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns string Form Type references to their CONSTANT alternatives in `getParent()` and `getExtendedType()` methods in Form in Symfony', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Form\AbstractType; class SomeType extends AbstractType @@ -51,7 +51,7 @@ class SomeType extends AbstractType } } CODE_SAMPLE -), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' +), new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Form\AbstractTypeExtension; class SomeExtension extends AbstractTypeExtension @@ -80,24 +80,24 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isClassAndMethodMatch($node)) { return null; } - $this->traverseNodesWithCallable((array) $node->stmts, function (\PhpParser\Node $node) : ?Node { - if (!$node instanceof \PhpParser\Node\Stmt\Return_) { + $this->traverseNodesWithCallable((array) $node->stmts, function (Node $node) : ?Node { + if (!$node instanceof Return_) { return null; } if ($node->expr === null) { return null; } - if (!$node->expr instanceof \PhpParser\Node\Scalar\String_) { + if (!$node->expr instanceof String_) { return null; } $this->replaceStringWIthFormTypeClassConstIfFound($node->expr->value, $node); @@ -105,21 +105,21 @@ CODE_SAMPLE }); return null; } - private function isClassAndMethodMatch(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function isClassAndMethodMatch(ClassMethod $classMethod) : bool { - $class = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($classMethod, Class_::class); + if (!$class instanceof Class_) { return \false; } - if ($this->isObjectType($class, new \PHPStan\Type\ObjectType('Symfony\\Component\\Form\\AbstractType'))) { + if ($this->isObjectType($class, new ObjectType('Symfony\\Component\\Form\\AbstractType'))) { return $this->isName($classMethod->name, 'getParent'); } - if ($this->isObjectType($classMethod, new \PHPStan\Type\ObjectType('Symfony\\Component\\Form\\AbstractTypeExtension'))) { + if ($this->isObjectType($classMethod, new ObjectType('Symfony\\Component\\Form\\AbstractTypeExtension'))) { return $this->isName($classMethod->name, 'getExtendedType'); } return \false; } - private function replaceStringWIthFormTypeClassConstIfFound(string $stringValue, \PhpParser\Node\Stmt\Return_ $return) : void + private function replaceStringWIthFormTypeClassConstIfFound(string $stringValue, Return_ $return) : void { $formClass = $this->formTypeStringToTypeProvider->matchClassForNameWithPrefix($stringValue); if ($formClass === null) { diff --git a/vendor/rector/rector-symfony/src/Rector/ClassMethod/GetRequestRector.php b/vendor/rector/rector-symfony/src/Rector/ClassMethod/GetRequestRector.php index 7ca4b648408..c623e8563d8 100644 --- a/vendor/rector/rector-symfony/src/Rector/ClassMethod/GetRequestRector.php +++ b/vendor/rector/rector-symfony/src/Rector/ClassMethod/GetRequestRector.php @@ -14,12 +14,12 @@ use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Rector\AbstractRector; use Rector\Symfony\Bridge\NodeAnalyzer\ControllerMethodAnalyzer; use Rector\Symfony\TypeAnalyzer\ControllerAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\ClassMethod\GetRequestRector\GetRequestRectorTest */ -final class GetRequestRector extends \Rector\Core\Rector\AbstractRector +final class GetRequestRector extends AbstractRector { /** * @var string @@ -39,14 +39,14 @@ final class GetRequestRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Symfony\TypeAnalyzer\ControllerAnalyzer */ private $controllerAnalyzer; - public function __construct(\Rector\Symfony\Bridge\NodeAnalyzer\ControllerMethodAnalyzer $controllerMethodAnalyzer, \Rector\Symfony\TypeAnalyzer\ControllerAnalyzer $controllerAnalyzer) + public function __construct(ControllerMethodAnalyzer $controllerMethodAnalyzer, ControllerAnalyzer $controllerAnalyzer) { $this->controllerMethodAnalyzer = $controllerMethodAnalyzer; $this->controllerAnalyzer = $controllerAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns fetching of Request via `$this->getRequest()` to action injection', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns fetching of Request via `$this->getRequest()` to action injection', [new CodeSample(<<<'CODE_SAMPLE' class SomeController { public function someAction() @@ -73,25 +73,25 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Expr\MethodCall::class]; + return [ClassMethod::class, MethodCall::class]; } /** * @param ClassMethod|MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->controllerAnalyzer->isInsideController($node)) { return null; } - if ($node instanceof \PhpParser\Node\Stmt\ClassMethod) { + if ($node instanceof ClassMethod) { return $this->refactorClassMethod($node); } if ($this->isGetRequestInAction($node)) { - return new \PhpParser\Node\Expr\Variable($this->getRequestVariableAndParamName()); + return new Variable($this->getRequestVariableAndParamName()); } return null; } - private function resolveUniqueName(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $name) : string + private function resolveUniqueName(ClassMethod $classMethod, string $name) : string { $candidateNames = []; foreach ($classMethod->params as $param) { @@ -104,7 +104,7 @@ CODE_SAMPLE } return $name; } - private function isActionWithGetRequestInBody(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function isActionWithGetRequestInBody(ClassMethod $classMethod) : bool { if (!$this->controllerMethodAnalyzer->isAction($classMethod)) { return \false; @@ -114,11 +114,11 @@ CODE_SAMPLE return \true; } /** @var MethodCall[] $getMethodCalls */ - $getMethodCalls = $this->betterNodeFinder->find($classMethod, function (\PhpParser\Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Expr\MethodCall) { + $getMethodCalls = $this->betterNodeFinder->find($classMethod, function (Node $node) : bool { + if (!$node instanceof MethodCall) { return \false; } - if (!$node->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$node->var instanceof Variable) { return \false; } return $this->nodeNameResolver->isName($node->name, 'get'); @@ -130,10 +130,10 @@ CODE_SAMPLE } return \false; } - private function isGetRequestInAction(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + private function isGetRequestInAction(MethodCall $methodCall) : bool { // must be $this->getRequest() in controller - if (!$methodCall->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$methodCall->var instanceof Variable) { return \false; } if (!$this->nodeNameResolver->isName($methodCall->var, 'this')) { @@ -142,19 +142,19 @@ CODE_SAMPLE if (!$this->isName($methodCall->name, 'getRequest') && !$this->isGetMethodCallWithRequestParameters($methodCall)) { return \false; } - $classMethod = $this->betterNodeFinder->findParentType($methodCall, \PhpParser\Node\Stmt\ClassMethod::class); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $this->betterNodeFinder->findParentType($methodCall, ClassMethod::class); + if (!$classMethod instanceof ClassMethod) { return \false; } return $this->controllerMethodAnalyzer->isAction($classMethod); } - private function containsGetRequestMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function containsGetRequestMethod(ClassMethod $classMethod) : bool { - return (bool) $this->betterNodeFinder->find((array) $classMethod->stmts, function (\PhpParser\Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Expr\MethodCall) { + return (bool) $this->betterNodeFinder->find((array) $classMethod->stmts, function (Node $node) : bool { + if (!$node instanceof MethodCall) { return \false; } - if (!$node->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$node->var instanceof Variable) { return \false; } if (!$this->isName($node->var, 'this')) { @@ -163,7 +163,7 @@ CODE_SAMPLE return $this->nodeNameResolver->isName($node->name, 'getRequest'); }); } - private function isGetMethodCallWithRequestParameters(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + private function isGetMethodCallWithRequestParameters(MethodCall $methodCall) : bool { if (!$this->isName($methodCall->name, 'get')) { return \false; @@ -172,7 +172,7 @@ CODE_SAMPLE return \false; } $firstArg = $methodCall->getArgs()[0]; - if (!$firstArg->value instanceof \PhpParser\Node\Scalar\String_) { + if (!$firstArg->value instanceof String_) { return \false; } $string = $firstArg->value; @@ -181,21 +181,21 @@ CODE_SAMPLE private function getRequestVariableAndParamName() : string { if ($this->requestVariableAndParamName === null) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } return $this->requestVariableAndParamName; } /** * @return null|\PhpParser\Node\Stmt\ClassMethod */ - private function refactorClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) + private function refactorClassMethod(ClassMethod $classMethod) { $this->requestVariableAndParamName = $this->resolveUniqueName($classMethod, 'request'); if (!$this->isActionWithGetRequestInBody($classMethod)) { return null; } - $fullyQualified = new \PhpParser\Node\Name\FullyQualified(self::REQUEST_CLASS); - $classMethod->params[] = new \PhpParser\Node\Param(new \PhpParser\Node\Expr\Variable($this->getRequestVariableAndParamName()), null, $fullyQualified); + $fullyQualified = new FullyQualified(self::REQUEST_CLASS); + $classMethod->params[] = new Param(new Variable($this->getRequestVariableAndParamName()), null, $fullyQualified); return $classMethod; } } diff --git a/vendor/rector/rector-symfony/src/Rector/ClassMethod/MergeMethodAnnotationToRouteAnnotationRector.php b/vendor/rector/rector-symfony/src/Rector/ClassMethod/MergeMethodAnnotationToRouteAnnotationRector.php index b0ff9a99f2b..bdc7fcae027 100644 --- a/vendor/rector/rector-symfony/src/Rector/ClassMethod/MergeMethodAnnotationToRouteAnnotationRector.php +++ b/vendor/rector/rector-symfony/src/Rector/ClassMethod/MergeMethodAnnotationToRouteAnnotationRector.php @@ -12,15 +12,15 @@ use Rector\BetterPhpDocParser\Printer\PhpDocInfoPrinter; use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode; use Rector\Core\Rector\AbstractRector; use Rector\Symfony\Enum\SymfonyAnnotation; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/routing.html#method-annotation * @see https://stackoverflow.com/questions/51171934/how-to-fix-symfony-3-4-route-and-method-deprecation * * @see \Rector\Symfony\Tests\Rector\ClassMethod\MergeMethodAnnotationToRouteAnnotationRector\MergeMethodAnnotationToRouteAnnotationRectorTest */ -final class MergeMethodAnnotationToRouteAnnotationRector extends \Rector\Core\Rector\AbstractRector +final class MergeMethodAnnotationToRouteAnnotationRector extends AbstractRector { /** * @readonly @@ -32,14 +32,14 @@ final class MergeMethodAnnotationToRouteAnnotationRector extends \Rector\Core\Re * @var \Rector\BetterPhpDocParser\Printer\PhpDocInfoPrinter */ private $phpDocInfoPrinter; - public function __construct(\Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover $phpDocTagRemover, \Rector\BetterPhpDocParser\Printer\PhpDocInfoPrinter $phpDocInfoPrinter) + public function __construct(PhpDocTagRemover $phpDocTagRemover, PhpDocInfoPrinter $phpDocInfoPrinter) { $this->phpDocTagRemover = $phpDocTagRemover; $this->phpDocInfoPrinter = $phpDocInfoPrinter; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Merge removed @Method annotation to @Route one', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Merge removed @Method annotation to @Route one', [new CodeSample(<<<'CODE_SAMPLE' use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Symfony\Component\Routing\Annotation\Route; @@ -74,15 +74,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($node, ClassLike::class); + if (!$classLike instanceof ClassLike) { return null; } if (!$node->isPublic()) { @@ -90,11 +90,11 @@ CODE_SAMPLE } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $sensioDoctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Method'); - if (!$sensioDoctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$sensioDoctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return null; } - $symfonyDoctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass(\Rector\Symfony\Enum\SymfonyAnnotation::ROUTE); - if (!$symfonyDoctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + $symfonyDoctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass(SymfonyAnnotation::ROUTE); + if (!$symfonyDoctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return null; } $methods = $this->resolveMethods($sensioDoctrineAnnotationTagValueNode); @@ -109,20 +109,20 @@ CODE_SAMPLE /** * @return mixed[]|null|\Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode */ - private function resolveMethods(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) + private function resolveMethods(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) { $methodsParameter = $doctrineAnnotationTagValueNode->getValue('methods'); if (\is_array($methodsParameter)) { return $methodsParameter; } - if ($methodsParameter instanceof \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode) { + if ($methodsParameter instanceof CurlyListNode) { return $methodsParameter; } $silentValue = $doctrineAnnotationTagValueNode->getSilentValue(); if (\is_array($silentValue)) { return $silentValue; } - if ($silentValue instanceof \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode) { + if ($silentValue instanceof CurlyListNode) { return $silentValue; } return null; diff --git a/vendor/rector/rector-symfony/src/Rector/ClassMethod/ParamTypeFromRouteRequiredRegexRector.php b/vendor/rector/rector-symfony/src/Rector/ClassMethod/ParamTypeFromRouteRequiredRegexRector.php index bccd31214ec..09ac557e262 100644 --- a/vendor/rector/rector-symfony/src/Rector/ClassMethod/ParamTypeFromRouteRequiredRegexRector.php +++ b/vendor/rector/rector-symfony/src/Rector/ClassMethod/ParamTypeFromRouteRequiredRegexRector.php @@ -10,12 +10,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\Symfony\NodeAnalyzer\RouteRequiredParamNameToTypesResolver; use Rector\Symfony\TypeAnalyzer\ControllerAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\ClassMethod\ParamTypeFromRouteRequiredRegexRector\ParamTypeFromRouteRequiredRegexRectorTest */ -final class ParamTypeFromRouteRequiredRegexRector extends \Rector\Core\Rector\AbstractRector +final class ParamTypeFromRouteRequiredRegexRector extends AbstractRector { /** * @readonly @@ -27,14 +27,14 @@ final class ParamTypeFromRouteRequiredRegexRector extends \Rector\Core\Rector\Ab * @var \Rector\Symfony\NodeAnalyzer\RouteRequiredParamNameToTypesResolver */ private $routeRequiredParamNameToTypesResolver; - public function __construct(\Rector\Symfony\TypeAnalyzer\ControllerAnalyzer $controllerAnalyzer, \Rector\Symfony\NodeAnalyzer\RouteRequiredParamNameToTypesResolver $routeRequiredParamNameToTypesResolver) + public function __construct(ControllerAnalyzer $controllerAnalyzer, RouteRequiredParamNameToTypesResolver $routeRequiredParamNameToTypesResolver) { $this->controllerAnalyzer = $controllerAnalyzer; $this->routeRequiredParamNameToTypesResolver = $routeRequiredParamNameToTypesResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Complete strict param type declaration based on route annotation', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Complete strict param type declaration based on route annotation', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\Routing\Annotation\Route; @@ -73,12 +73,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->controllerAnalyzer->isInsideController($node)) { return null; @@ -93,13 +93,13 @@ CODE_SAMPLE $hasChanged = \false; foreach ($paramsToTypes as $paramName => $paramType) { $param = $this->findParamByName($node, $paramName); - if (!$param instanceof \PhpParser\Node\Param) { + if (!$param instanceof Param) { continue; } if ($param->type !== null) { continue; } - $paramTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($paramType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM); + $paramTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($paramType, TypeKind::PARAM); $param->type = $paramTypeNode; $hasChanged = \true; } @@ -108,7 +108,7 @@ CODE_SAMPLE } return $node; } - private function findParamByName(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $paramName) : ?\PhpParser\Node\Param + private function findParamByName(ClassMethod $classMethod, string $paramName) : ?Param { foreach ($classMethod->getParams() as $param) { if (!$this->isName($param, $paramName)) { diff --git a/vendor/rector/rector-symfony/src/Rector/ClassMethod/RemoveDefaultGetBlockPrefixRector.php b/vendor/rector/rector-symfony/src/Rector/ClassMethod/RemoveDefaultGetBlockPrefixRector.php index 9425ae9b2ff..ceb04d77333 100644 --- a/vendor/rector/rector-symfony/src/Rector/ClassMethod/RemoveDefaultGetBlockPrefixRector.php +++ b/vendor/rector/rector-symfony/src/Rector/ClassMethod/RemoveDefaultGetBlockPrefixRector.php @@ -14,18 +14,18 @@ use PHPStan\Type\ObjectType; use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Rector\AbstractRector; use RectorPrefix20220607\Symfony\Component\String\UnicodeString; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/symfony/symfony/blob/3.4/UPGRADE-3.0.md#form * * @see \Rector\Symfony\Tests\Rector\ClassMethod\RemoveDefaultGetBlockPrefixRector\RemoveDefaultGetBlockPrefixRectorTest */ -final class RemoveDefaultGetBlockPrefixRector extends \Rector\Core\Rector\AbstractRector +final class RemoveDefaultGetBlockPrefixRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Rename `getBlockPrefix()` if it returns the default value - class to underscore, e.g. UserFormType = user_form', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Rename `getBlockPrefix()` if it returns the default value - class to underscore, e.g. UserFormType = user_form', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Form\AbstractType; class TaskType extends AbstractType @@ -50,23 +50,23 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isObjectMethodNameMatch($node)) { return null; } $returnedExpr = $this->resolveOnlyStmtReturnExpr($node); - if (!$returnedExpr instanceof \PhpParser\Node\Expr) { + if (!$returnedExpr instanceof Expr) { return null; } $returnedValue = $this->valueResolver->getValue($returnedExpr); - $classLike = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->betterNodeFinder->findParentType($node, ClassLike::class); + if (!$classLike instanceof ClassLike) { return null; } $className = $this->nodeNameResolver->getName($classLike); @@ -75,9 +75,9 @@ CODE_SAMPLE } $shortClassName = $this->nodeNameResolver->getShortName($className); if (\substr_compare($shortClassName, 'Type', -\strlen('Type')) === 0) { - $shortClassName = (string) \RectorPrefix20220607\Nette\Utils\Strings::before($shortClassName, 'Type'); + $shortClassName = (string) Strings::before($shortClassName, 'Type'); } - $shortClassNameUnicodeString = new \RectorPrefix20220607\Symfony\Component\String\UnicodeString($shortClassName); + $shortClassNameUnicodeString = new UnicodeString($shortClassName); $underscoredClassShortName = $shortClassNameUnicodeString->snake()->toString(); if ($underscoredClassShortName !== $returnedValue) { return null; @@ -85,13 +85,13 @@ CODE_SAMPLE $this->removeNode($node); return null; } - private function isObjectMethodNameMatch(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function isObjectMethodNameMatch(ClassMethod $classMethod) : bool { - $class = $this->betterNodeFinder->findParentType($classMethod, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($classMethod, Class_::class); + if (!$class instanceof Class_) { return \false; } - if (!$this->isObjectType($classMethod, new \PHPStan\Type\ObjectType('Symfony\\Component\\Form\\AbstractType'))) { + if (!$this->isObjectType($classMethod, new ObjectType('Symfony\\Component\\Form\\AbstractType'))) { return \false; } return $this->isName($classMethod->name, 'getBlockPrefix'); @@ -99,16 +99,16 @@ CODE_SAMPLE /** * return <$thisValue>; */ - private function resolveOnlyStmtReturnExpr(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Expr + private function resolveOnlyStmtReturnExpr(ClassMethod $classMethod) : ?Expr { if (\count((array) $classMethod->stmts) !== 1) { return null; } if (!isset($classMethod->stmts[0])) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $onlyStmt = $classMethod->stmts[0]; - if (!$onlyStmt instanceof \PhpParser\Node\Stmt\Return_) { + if (!$onlyStmt instanceof Return_) { return null; } return $onlyStmt->expr; diff --git a/vendor/rector/rector-symfony/src/Rector/ClassMethod/RemoveServiceFromSensioRouteRector.php b/vendor/rector/rector-symfony/src/Rector/ClassMethod/RemoveServiceFromSensioRouteRector.php index fc12cbaaf75..29bf311f208 100644 --- a/vendor/rector/rector-symfony/src/Rector/ClassMethod/RemoveServiceFromSensioRouteRector.php +++ b/vendor/rector/rector-symfony/src/Rector/ClassMethod/RemoveServiceFromSensioRouteRector.php @@ -8,18 +8,18 @@ use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassMethod; use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/routing.html#route-annotation * * @see \Rector\Symfony\Tests\Rector\ClassMethod\RemoveServiceFromSensioRouteRector\RemoveServiceFromSensioRouteRectorTest */ -final class RemoveServiceFromSensioRouteRector extends \Rector\Core\Rector\AbstractRector +final class RemoveServiceFromSensioRouteRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove service from Sensio @Route', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Remove service from Sensio @Route', [new CodeSample(<<<'CODE_SAMPLE' use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; final class SomeClass @@ -52,16 +52,16 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Class_::class]; + return [ClassMethod::class, Class_::class]; } /** * @param ClassMethod|Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Route'); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return null; } $doctrineAnnotationTagValueNode->removeValue('service'); diff --git a/vendor/rector/rector-symfony/src/Rector/ClassMethod/RenderMethodParamToTypeDeclarationRector.php b/vendor/rector/rector-symfony/src/Rector/ClassMethod/RenderMethodParamToTypeDeclarationRector.php index 356f6a97a4e..199936d9d71 100644 --- a/vendor/rector/rector-symfony/src/Rector/ClassMethod/RenderMethodParamToTypeDeclarationRector.php +++ b/vendor/rector/rector-symfony/src/Rector/ClassMethod/RenderMethodParamToTypeDeclarationRector.php @@ -12,12 +12,12 @@ use Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\TypeDeclaration\NodeAnalyzer\ControllerRenderMethodAnalyzer; use Rector\TypeDeclaration\TypeInferer\ParamTypeInferer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\ClassMethod\RenderMethodParamToTypeDeclarationRector\RenderMethodParamToTypeDeclarationRectorTest */ -final class RenderMethodParamToTypeDeclarationRector extends \Rector\Core\Rector\AbstractRector +final class RenderMethodParamToTypeDeclarationRector extends AbstractRector { /** * @var bool @@ -38,15 +38,15 @@ final class RenderMethodParamToTypeDeclarationRector extends \Rector\Core\Rector * @var \Rector\TypeDeclaration\NodeAnalyzer\ControllerRenderMethodAnalyzer */ private $controllerRenderMethodAnalyzer; - public function __construct(\Rector\TypeDeclaration\TypeInferer\ParamTypeInferer $paramTypeInferer, \Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover $paramTagRemover, \Rector\TypeDeclaration\NodeAnalyzer\ControllerRenderMethodAnalyzer $controllerRenderMethodAnalyzer) + public function __construct(ParamTypeInferer $paramTypeInferer, ParamTagRemover $paramTagRemover, ControllerRenderMethodAnalyzer $controllerRenderMethodAnalyzer) { $this->paramTypeInferer = $paramTypeInferer; $this->paramTagRemover = $paramTagRemover; $this->controllerRenderMethodAnalyzer = $controllerRenderMethodAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Move @param docs on render() method in Symfony controller to strict type declaration', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Move @param docs on render() method in Symfony controller to strict type declaration', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Routing\Annotation\Route; @@ -82,15 +82,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); - if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$phpDocInfo instanceof PhpDocInfo) { return null; } if (!$this->controllerRenderMethodAnalyzer->isRenderMethod($node)) { @@ -105,14 +105,14 @@ CODE_SAMPLE } return null; } - private function refactorParam(\PhpParser\Node\Param $param, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function refactorParam(Param $param, PhpDocInfo $phpDocInfo, ClassMethod $classMethod) : void { if ($param->type !== null) { return; } $inferedType = $this->paramTypeInferer->inferParam($param); - $paramType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($inferedType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM); - if (!$paramType instanceof \PhpParser\Node) { + $paramType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($inferedType, TypeKind::PARAM); + if (!$paramType instanceof Node) { return; } $param->type = $paramType; diff --git a/vendor/rector/rector-symfony/src/Rector/ClassMethod/ReplaceSensioRouteAnnotationWithSymfonyRector.php b/vendor/rector/rector-symfony/src/Rector/ClassMethod/ReplaceSensioRouteAnnotationWithSymfonyRector.php index dcb622de30e..913f671dc90 100644 --- a/vendor/rector/rector-symfony/src/Rector/ClassMethod/ReplaceSensioRouteAnnotationWithSymfonyRector.php +++ b/vendor/rector/rector-symfony/src/Rector/ClassMethod/ReplaceSensioRouteAnnotationWithSymfonyRector.php @@ -12,15 +12,15 @@ use Rector\Core\Configuration\RenamedClassesDataCollector; use Rector\Core\Rector\AbstractRector; use Rector\Symfony\Enum\SymfonyAnnotation; use Rector\Symfony\PhpDocNode\SymfonyRouteTagValueNodeFactory; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://medium.com/@nebkam/symfony-deprecated-route-and-method-annotations-4d5e1d34556a * @see https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/routing.html#method-annotation * * @see \Rector\Symfony\Tests\Rector\ClassMethod\ReplaceSensioRouteAnnotationWithSymfonyRector\ReplaceSensioRouteAnnotationWithSymfonyRectorTest */ -final class ReplaceSensioRouteAnnotationWithSymfonyRector extends \Rector\Core\Rector\AbstractRector +final class ReplaceSensioRouteAnnotationWithSymfonyRector extends AbstractRector { /** * @readonly @@ -37,15 +37,15 @@ final class ReplaceSensioRouteAnnotationWithSymfonyRector extends \Rector\Core\R * @var \Rector\Core\Configuration\RenamedClassesDataCollector */ private $renamedClassesDataCollector; - public function __construct(\Rector\Symfony\PhpDocNode\SymfonyRouteTagValueNodeFactory $symfonyRouteTagValueNodeFactory, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover $phpDocTagRemover, \Rector\Core\Configuration\RenamedClassesDataCollector $renamedClassesDataCollector) + public function __construct(SymfonyRouteTagValueNodeFactory $symfonyRouteTagValueNodeFactory, PhpDocTagRemover $phpDocTagRemover, RenamedClassesDataCollector $renamedClassesDataCollector) { $this->symfonyRouteTagValueNodeFactory = $symfonyRouteTagValueNodeFactory; $this->phpDocTagRemover = $phpDocTagRemover; $this->renamedClassesDataCollector = $renamedClassesDataCollector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace Sensio @Route annotation with Symfony one', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace Sensio @Route annotation with Symfony one', [new CodeSample(<<<'CODE_SAMPLE' use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; final class SomeClass @@ -78,22 +78,22 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Class_::class]; + return [ClassMethod::class, Class_::class]; } /** * @param ClassMethod|Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); - if ($phpDocInfo->hasByAnnotationClass(\Rector\Symfony\Enum\SymfonyAnnotation::ROUTE)) { + if ($phpDocInfo->hasByAnnotationClass(SymfonyAnnotation::ROUTE)) { return null; } $doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Route'); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return null; } - $this->renamedClassesDataCollector->addOldToNewClasses(['Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Route' => \Rector\Symfony\Enum\SymfonyAnnotation::ROUTE]); + $this->renamedClassesDataCollector->addOldToNewClasses(['Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Route' => SymfonyAnnotation::ROUTE]); $this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $doctrineAnnotationTagValueNode); // unset service, that is deprecated $values = $doctrineAnnotationTagValueNode->getValues(); diff --git a/vendor/rector/rector-symfony/src/Rector/ClassMethod/ResponseReturnTypeControllerActionRector.php b/vendor/rector/rector-symfony/src/Rector/ClassMethod/ResponseReturnTypeControllerActionRector.php index 7cff5d3f120..fa9ec4017d7 100644 --- a/vendor/rector/rector-symfony/src/Rector/ClassMethod/ResponseReturnTypeControllerActionRector.php +++ b/vendor/rector/rector-symfony/src/Rector/ClassMethod/ResponseReturnTypeControllerActionRector.php @@ -10,12 +10,12 @@ use Rector\Core\Rector\AbstractRector; use Rector\Doctrine\NodeAnalyzer\AttrinationFinder; use Rector\Symfony\Enum\SymfonyAnnotation; use Rector\Symfony\TypeAnalyzer\ControllerAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\ClassMethod\ResponseReturnTypeControllerActionRector\ResponseReturnTypeControllerActionRectorTest */ -final class ResponseReturnTypeControllerActionRector extends \Rector\Core\Rector\AbstractRector +final class ResponseReturnTypeControllerActionRector extends AbstractRector { /** * @readonly @@ -27,14 +27,14 @@ final class ResponseReturnTypeControllerActionRector extends \Rector\Core\Rector * @var \Rector\Doctrine\NodeAnalyzer\AttrinationFinder */ private $attrinationFinder; - public function __construct(\Rector\Symfony\TypeAnalyzer\ControllerAnalyzer $controllerAnalyzer, \Rector\Doctrine\NodeAnalyzer\AttrinationFinder $attrinationFinder) + public function __construct(ControllerAnalyzer $controllerAnalyzer, AttrinationFinder $attrinationFinder) { $this->controllerAnalyzer = $controllerAnalyzer; $this->attrinationFinder = $attrinationFinder; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add Response object return type to controller actions', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add Response object return type to controller actions', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Routing\Annotation\Route; @@ -68,12 +68,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$node->isPublic()) { return null; @@ -84,10 +84,10 @@ CODE_SAMPLE if ($node->returnType !== null) { return null; } - if (!$this->attrinationFinder->hasByOne($node, \Rector\Symfony\Enum\SymfonyAnnotation::ROUTE)) { + if (!$this->attrinationFinder->hasByOne($node, SymfonyAnnotation::ROUTE)) { return null; } - $node->returnType = new \PhpParser\Node\Name\FullyQualified('Symfony\\Component\\HttpFoundation\\Response'); + $node->returnType = new FullyQualified('Symfony\\Component\\HttpFoundation\\Response'); return $node; } } diff --git a/vendor/rector/rector-symfony/src/Rector/ClassMethod/RouteCollectionBuilderToRoutingConfiguratorRector.php b/vendor/rector/rector-symfony/src/Rector/ClassMethod/RouteCollectionBuilderToRoutingConfiguratorRector.php index 840b6a23844..25cdee4848c 100644 --- a/vendor/rector/rector-symfony/src/Rector/ClassMethod/RouteCollectionBuilderToRoutingConfiguratorRector.php +++ b/vendor/rector/rector-symfony/src/Rector/ClassMethod/RouteCollectionBuilderToRoutingConfiguratorRector.php @@ -13,18 +13,18 @@ use PhpParser\Node\Stmt\ClassMethod; use Rector\Core\Exception\NotImplementedYetException; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/symfony/symfony/pull/32937/files * * @see \Rector\Symfony\Tests\Rector\ClassMethod\RouteCollectionBuilderToRoutingConfiguratorRector\RouteCollectionBuilderToRoutingConfiguratorRectorTest */ -final class RouteCollectionBuilderToRoutingConfiguratorRector extends \Rector\Core\Rector\AbstractRector +final class RouteCollectionBuilderToRoutingConfiguratorRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change RouteCollectionBuilder to RoutingConfiguratorRector', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change RouteCollectionBuilder to RoutingConfiguratorRector', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Routing\RouteCollectionBuilder; @@ -61,12 +61,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class]; + return [ClassMethod::class]; } /** * @param ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'configureRoutes')) { return null; @@ -78,30 +78,30 @@ CODE_SAMPLE if (!$this->isName($firstParam->type, 'Symfony\\Component\\Routing\\RouteCollectionBuilder')) { return null; } - $firstParam->type = new \PhpParser\Node\Name\FullyQualified('Symfony\\Component\\Routing\\Loader\\Configurator\\RoutingConfigurator'); - $node->name = new \PhpParser\Node\Identifier('configureRouting'); - $node->returnType = new \PhpParser\Node\Identifier('void'); - $this->traverseNodesWithCallable((array) $node->stmts, function (\PhpParser\Node $node) : ?MethodCall { - if (!$node instanceof \PhpParser\Node\Expr\MethodCall) { + $firstParam->type = new FullyQualified('Symfony\\Component\\Routing\\Loader\\Configurator\\RoutingConfigurator'); + $node->name = new Identifier('configureRouting'); + $node->returnType = new Identifier('void'); + $this->traverseNodesWithCallable((array) $node->stmts, function (Node $node) : ?MethodCall { + if (!$node instanceof MethodCall) { return null; } if (!$this->isName($node->name, 'add')) { return null; } // avoid nesting chain iteration infinity loop - $shouldSkip = (bool) $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::DO_NOT_CHANGE); + $shouldSkip = (bool) $node->getAttribute(AttributeKey::DO_NOT_CHANGE); if ($shouldSkip) { return null; } - $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::DO_NOT_CHANGE, \true); + $node->setAttribute(AttributeKey::DO_NOT_CHANGE, \true); $pathValue = $node->getArgs()[0]->value; $controllerValue = $node->getArgs()[1]->value; $nameValue = $node->getArgs()[2]->value ?? null; - if (!$nameValue instanceof \PhpParser\Node\Expr) { - throw new \Rector\Core\Exception\NotImplementedYetException(); + if (!$nameValue instanceof Expr) { + throw new NotImplementedYetException(); } - $node->args = [new \PhpParser\Node\Arg($nameValue), new \PhpParser\Node\Arg($pathValue)]; - return new \PhpParser\Node\Expr\MethodCall($node, 'controller', [new \PhpParser\Node\Arg($controllerValue)]); + $node->args = [new Arg($nameValue), new Arg($pathValue)]; + return new MethodCall($node, 'controller', [new Arg($controllerValue)]); }); return $node; } diff --git a/vendor/rector/rector-symfony/src/Rector/ClassMethod/TemplateAnnotationToThisRenderRector.php b/vendor/rector/rector-symfony/src/Rector/ClassMethod/TemplateAnnotationToThisRenderRector.php index e3fb8cef149..f521443749f 100644 --- a/vendor/rector/rector-symfony/src/Rector/ClassMethod/TemplateAnnotationToThisRenderRector.php +++ b/vendor/rector/rector-symfony/src/Rector/ClassMethod/TemplateAnnotationToThisRenderRector.php @@ -33,8 +33,8 @@ use Rector\Symfony\NodeFactory\ThisRenderFactory; use Rector\Symfony\NodeFinder\EmptyReturnNodeFinder; use Rector\Symfony\TypeAnalyzer\ArrayUnionResponseTypeAnalyzer; use Rector\Symfony\TypeDeclaration\ReturnTypeDeclarationUpdater; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see https://github.com/symfony/symfony-docs/pull/12387#discussion_r329551967 @@ -43,7 +43,7 @@ use RectorPrefix20220607\Webmozart\Assert\Assert; * * @see \Rector\Symfony\Tests\Rector\ClassMethod\TemplateAnnotationToThisRenderRector\TemplateAnnotationToThisRenderRectorTest */ -final class TemplateAnnotationToThisRenderRector extends \Rector\Core\Rector\AbstractRector +final class TemplateAnnotationToThisRenderRector extends AbstractRector { /** * @var class-string @@ -78,7 +78,7 @@ final class TemplateAnnotationToThisRenderRector extends \Rector\Core\Rector\Abs * @var \Rector\Symfony\NodeFinder\EmptyReturnNodeFinder */ private $emptyReturnNodeFinder; - public function __construct(\Rector\Symfony\TypeAnalyzer\ArrayUnionResponseTypeAnalyzer $arrayUnionResponseTypeAnalyzer, \Rector\Symfony\TypeDeclaration\ReturnTypeDeclarationUpdater $returnTypeDeclarationUpdater, \Rector\Symfony\NodeFactory\ThisRenderFactory $thisRenderFactory, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover $phpDocTagRemover, \Rector\Symfony\NodeFinder\EmptyReturnNodeFinder $emptyReturnNodeFinder) + public function __construct(ArrayUnionResponseTypeAnalyzer $arrayUnionResponseTypeAnalyzer, ReturnTypeDeclarationUpdater $returnTypeDeclarationUpdater, ThisRenderFactory $thisRenderFactory, PhpDocTagRemover $phpDocTagRemover, EmptyReturnNodeFinder $emptyReturnNodeFinder) { $this->arrayUnionResponseTypeAnalyzer = $arrayUnionResponseTypeAnalyzer; $this->returnTypeDeclarationUpdater = $returnTypeDeclarationUpdater; @@ -86,9 +86,9 @@ final class TemplateAnnotationToThisRenderRector extends \Rector\Core\Rector\Abs $this->phpDocTagRemover = $phpDocTagRemover; $this->emptyReturnNodeFinder = $emptyReturnNodeFinder; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns `@Template` annotation to explicit method call in Controller of FrameworkExtraBundle in Symfony', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns `@Template` annotation to explicit method call in Controller of FrameworkExtraBundle in Symfony', [new CodeSample(<<<'CODE_SAMPLE' /** * @Template() */ @@ -109,19 +109,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Class_::class]; + return [ClassMethod::class, Class_::class]; } /** * @param Class_|ClassMethod $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Stmt\Class_) { + if ($node instanceof Class_) { return $this->addAbstractControllerParentClassIfMissing($node); } return $this->replaceTemplateAnnotation($node); } - private function addAbstractControllerParentClassIfMissing(\PhpParser\Node\Stmt\Class_ $class) : ?\PhpParser\Node\Stmt\Class_ + private function addAbstractControllerParentClassIfMissing(Class_ $class) : ?Class_ { if ($class->extends !== null) { return null; @@ -129,43 +129,43 @@ CODE_SAMPLE if (!$this->hasClassMethodWithTemplateAnnotation($class)) { return null; } - $class->extends = new \PhpParser\Node\Name\FullyQualified('Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController'); + $class->extends = new FullyQualified('Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController'); return $class; } - private function replaceTemplateAnnotation(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node + private function replaceTemplateAnnotation(ClassMethod $classMethod) : ?Node { if (!$classMethod->isPublic()) { return null; } $doctrineAnnotationTagValueNode = $this->getDoctrineAnnotationTagValueNode($classMethod, self::TEMPLATE_ANNOTATION_CLASS); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return null; } $this->refactorClassMethod($classMethod, $doctrineAnnotationTagValueNode); return $classMethod; } - private function hasClassMethodWithTemplateAnnotation(\PhpParser\Node\Stmt\Class_ $class) : bool + private function hasClassMethodWithTemplateAnnotation(Class_ $class) : bool { foreach ($class->getMethods() as $classMethod) { $templateDoctrineAnnotationTagValueNode = $this->getDoctrineAnnotationTagValueNode($classMethod, self::TEMPLATE_ANNOTATION_CLASS); - if ($templateDoctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if ($templateDoctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return \true; } } return \false; } - private function refactorClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $templateDoctrineAnnotationTagValueNode) : void + private function refactorClassMethod(ClassMethod $classMethod, DoctrineAnnotationTagValueNode $templateDoctrineAnnotationTagValueNode) : void { $hasThisRenderOrReturnsResponse = $this->hasLastReturnResponse($classMethod); - $this->traverseNodesWithCallable($classMethod, function (\PhpParser\Node $node) use($templateDoctrineAnnotationTagValueNode, $hasThisRenderOrReturnsResponse, $classMethod) { + $this->traverseNodesWithCallable($classMethod, function (Node $node) use($templateDoctrineAnnotationTagValueNode, $hasThisRenderOrReturnsResponse, $classMethod) { // keep as similar type - if ($node instanceof \PhpParser\Node\Expr\Closure || $node instanceof \PhpParser\Node\Stmt\Function_) { - return \PhpParser\NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; + if ($node instanceof Closure || $node instanceof Function_) { + return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; } - if (!$node instanceof \PhpParser\Node\Stmt) { + if (!$node instanceof Stmt) { return null; } - foreach (\Rector\CodeQuality\NodeTypeGroup::STMTS_AWARE as $stmtsAwareType) { + foreach (NodeTypeGroup::STMTS_AWARE as $stmtsAwareType) { if (!\is_a($node, $stmtsAwareType, \true)) { continue; } @@ -180,20 +180,20 @@ CODE_SAMPLE $thisRenderMethodCall = $this->thisRenderFactory->create(null, $templateDoctrineAnnotationTagValueNode, $classMethod); $this->refactorNoReturn($classMethod, $thisRenderMethodCall, $templateDoctrineAnnotationTagValueNode); } - private function hasLastReturnResponse(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function hasLastReturnResponse(ClassMethod $classMethod) : bool { - $lastReturn = $this->betterNodeFinder->findLastInstanceOf((array) $classMethod->stmts, \PhpParser\Node\Stmt\Return_::class); - if (!$lastReturn instanceof \PhpParser\Node\Stmt\Return_) { + $lastReturn = $this->betterNodeFinder->findLastInstanceOf((array) $classMethod->stmts, Return_::class); + if (!$lastReturn instanceof Return_) { return \false; } if ($lastReturn->expr === null) { return \false; } - $responseObjectType = new \PHPStan\Type\ObjectType(self::RESPONSE_CLASS); + $responseObjectType = new ObjectType(self::RESPONSE_CLASS); $returnType = $this->getType($lastReturn->expr); return $responseObjectType->isSuperTypeOf($returnType)->yes(); } - private function refactorReturn(\PhpParser\Node\Stmt\Return_ $return, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $templateDoctrineAnnotationTagValueNode, bool $hasThisRenderOrReturnsResponse, \PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function refactorReturn(Return_ $return, DoctrineAnnotationTagValueNode $templateDoctrineAnnotationTagValueNode, bool $hasThisRenderOrReturnsResponse, ClassMethod $classMethod) : void { // nothing we can do if ($return->expr === null) { @@ -203,32 +203,32 @@ CODE_SAMPLE $thisRenderMethodCall = $this->thisRenderFactory->create($return, $templateDoctrineAnnotationTagValueNode, $classMethod); $this->refactorReturnWithValue($return, $hasThisRenderOrReturnsResponse, $thisRenderMethodCall, $classMethod, $templateDoctrineAnnotationTagValueNode); } - private function getDoctrineAnnotationTagValueNode(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $class) : ?\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode + private function getDoctrineAnnotationTagValueNode(ClassMethod $classMethod, string $class) : ?DoctrineAnnotationTagValueNode { $phpDocInfo = $this->phpDocInfoFactory->createFromNode($classMethod); - if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$phpDocInfo instanceof PhpDocInfo) { return null; } return $phpDocInfo->getByAnnotationClass($class); } - private function refactorNoReturn(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Expr\MethodCall $thisRenderMethodCall, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : void + private function refactorNoReturn(ClassMethod $classMethod, MethodCall $thisRenderMethodCall, DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : void { - $classMethod->stmts[] = new \PhpParser\Node\Stmt\Return_($thisRenderMethodCall); + $classMethod->stmts[] = new Return_($thisRenderMethodCall); $this->returnTypeDeclarationUpdater->updateClassMethod($classMethod, self::RESPONSE_CLASS); $this->removeDoctrineAnnotationTagValueNode($classMethod, $doctrineAnnotationTagValueNode); } - private function refactorReturnWithValue(\PhpParser\Node\Stmt\Return_ $return, bool $hasThisRenderOrReturnsResponse, \PhpParser\Node\Expr\MethodCall $thisRenderMethodCall, \PhpParser\Node\Stmt\ClassMethod $classMethod, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : void + private function refactorReturnWithValue(Return_ $return, bool $hasThisRenderOrReturnsResponse, MethodCall $thisRenderMethodCall, ClassMethod $classMethod, DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : void { /** @var Expr $lastReturnExpr */ $lastReturnExpr = $return->expr; $returnStaticType = $this->getType($lastReturnExpr); - if (!$return->expr instanceof \PhpParser\Node\Expr\MethodCall) { - if (!$hasThisRenderOrReturnsResponse || $returnStaticType instanceof \PHPStan\Type\Constant\ConstantArrayType) { + if (!$return->expr instanceof MethodCall) { + if (!$hasThisRenderOrReturnsResponse || $returnStaticType instanceof ConstantArrayType) { $return->expr = $thisRenderMethodCall; } - } elseif ($returnStaticType instanceof \PHPStan\Type\ArrayType) { + } elseif ($returnStaticType instanceof ArrayType) { $return->expr = $thisRenderMethodCall; - } elseif ($returnStaticType instanceof \PHPStan\Type\MixedType) { + } elseif ($returnStaticType instanceof MixedType) { // nothing we can do return; } @@ -240,30 +240,30 @@ CODE_SAMPLE $this->removeDoctrineAnnotationTagValueNode($classMethod, $doctrineAnnotationTagValueNode); $this->returnTypeDeclarationUpdater->updateClassMethod($classMethod, self::RESPONSE_CLASS); } - private function processIsArrayOrResponseType(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Stmt\Return_ $return, \PhpParser\Node\Expr $returnExpr, \PhpParser\Node\Expr\MethodCall $thisRenderMethodCall) : void + private function processIsArrayOrResponseType(ClassMethod $classMethod, Return_ $return, Expr $returnExpr, MethodCall $thisRenderMethodCall) : void { $this->removeNode($return); // create instance of Response → return response, or return $this->render - $responseVariable = new \PhpParser\Node\Expr\Variable('responseOrData'); - $assign = new \PhpParser\Node\Expr\Assign($responseVariable, $returnExpr); - $assignExpression = new \PhpParser\Node\Stmt\Expression($assign); - $if = new \PhpParser\Node\Stmt\If_(new \PhpParser\Node\Expr\Instanceof_($responseVariable, new \PhpParser\Node\Name\FullyQualified(self::RESPONSE_CLASS))); - $if->stmts[] = new \PhpParser\Node\Stmt\Return_($responseVariable); - $thisRenderMethodCall->args[1] = new \PhpParser\Node\Arg($responseVariable); - $returnThisRender = new \PhpParser\Node\Stmt\Return_($thisRenderMethodCall); + $responseVariable = new Variable('responseOrData'); + $assign = new Assign($responseVariable, $returnExpr); + $assignExpression = new Expression($assign); + $if = new If_(new Instanceof_($responseVariable, new FullyQualified(self::RESPONSE_CLASS))); + $if->stmts[] = new Return_($responseVariable); + $thisRenderMethodCall->args[1] = new Arg($responseVariable); + $returnThisRender = new Return_($thisRenderMethodCall); $classMethodStmts = (array) $classMethod->stmts; $classMethod->stmts = \array_merge($classMethodStmts, [$assignExpression, $if, $returnThisRender]); } - private function removeDoctrineAnnotationTagValueNode(\PhpParser\Node\Stmt\ClassMethod $classMethod, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : void + private function removeDoctrineAnnotationTagValueNode(ClassMethod $classMethod, DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : void { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); $this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $doctrineAnnotationTagValueNode); } - private function refactorStmtsAwareNode(\PhpParser\Node\Stmt $stmtsAwareStmt, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $templateDoctrineAnnotationTagValueNode, bool $hasThisRenderOrReturnsResponse, \PhpParser\Node\Stmt\ClassMethod $classMethod) : void + private function refactorStmtsAwareNode(Stmt $stmtsAwareStmt, DoctrineAnnotationTagValueNode $templateDoctrineAnnotationTagValueNode, bool $hasThisRenderOrReturnsResponse, ClassMethod $classMethod) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::propertyExists($stmtsAwareStmt, 'stmts'); + Assert::propertyExists($stmtsAwareStmt, 'stmts'); foreach ((array) $stmtsAwareStmt->stmts as $stmt) { - if (!$stmt instanceof \PhpParser\Node\Stmt\Return_) { + if (!$stmt instanceof Return_) { continue; } // just created node, skip it diff --git a/vendor/rector/rector-symfony/src/Rector/Class_/ChangeFileLoaderInExtensionAndKernelRector.php b/vendor/rector/rector-symfony/src/Rector/Class_/ChangeFileLoaderInExtensionAndKernelRector.php index 0667beb7057..94d4145fb7b 100644 --- a/vendor/rector/rector-symfony/src/Rector/Class_/ChangeFileLoaderInExtensionAndKernelRector.php +++ b/vendor/rector/rector-symfony/src/Rector/Class_/ChangeFileLoaderInExtensionAndKernelRector.php @@ -18,14 +18,14 @@ use Rector\Symfony\Exception\InvalidConfigurationException; use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\Class_\ChangeFileLoaderInExtensionAndKernelRector\ChangeFileLoaderInExtensionAndKernelRectorTest * * Works best with https://github.com/migrify/config-transformer */ -final class ChangeFileLoaderInExtensionAndKernelRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class ChangeFileLoaderInExtensionAndKernelRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var string @@ -47,9 +47,9 @@ final class ChangeFileLoaderInExtensionAndKernelRector extends \Rector\Core\Rect * @var string */ private $to; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change XML loader to YAML in Bundle Extension', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change XML loader to YAML in Bundle Extension', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; @@ -88,12 +88,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isKernelOrExtensionClass($node)) { return null; @@ -101,12 +101,12 @@ CODE_SAMPLE $this->validateConfiguration($this->from, $this->to); $oldFileLoaderClass = self::FILE_LOADERS_BY_TYPE[$this->from]; $newFileLoaderClass = self::FILE_LOADERS_BY_TYPE[$this->to]; - $this->traverseNodesWithCallable($node->stmts, function (\PhpParser\Node $node) use($oldFileLoaderClass, $newFileLoaderClass) { - if ($node instanceof \PhpParser\Node\Expr\New_) { + $this->traverseNodesWithCallable($node->stmts, function (Node $node) use($oldFileLoaderClass, $newFileLoaderClass) { + if ($node instanceof New_) { if (!$this->isName($node->class, $oldFileLoaderClass)) { return null; } - $node->class = new \PhpParser\Node\Name\FullyQualified($newFileLoaderClass); + $node->class = new FullyQualified($newFileLoaderClass); return $node; } return $this->refactorLoadMethodCall($node); @@ -118,33 +118,33 @@ CODE_SAMPLE $this->from = $configuration[self::FROM]; $this->to = $configuration[self::TO]; } - private function isKernelOrExtensionClass(\PhpParser\Node\Stmt\Class_ $class) : bool + private function isKernelOrExtensionClass(Class_ $class) : bool { - if ($this->isObjectType($class, new \PHPStan\Type\ObjectType('Symfony\\Component\\HttpKernel\\DependencyInjection\\Extension'))) { + if ($this->isObjectType($class, new ObjectType('Symfony\\Component\\HttpKernel\\DependencyInjection\\Extension'))) { return \true; } - return $this->isObjectType($class, new \PHPStan\Type\ObjectType('Symfony\\Component\\HttpKernel\\Kernel')); + return $this->isObjectType($class, new ObjectType('Symfony\\Component\\HttpKernel\\Kernel')); } private function validateConfiguration(string $from, string $to) : void { if (!isset(self::FILE_LOADERS_BY_TYPE[$from])) { $message = \sprintf('File loader "%s" format is not supported', $from); - throw new \Rector\Symfony\Exception\InvalidConfigurationException($message); + throw new InvalidConfigurationException($message); } if (!isset(self::FILE_LOADERS_BY_TYPE[$to])) { $message = \sprintf('File loader "%s" format is not supported', $to); - throw new \Rector\Symfony\Exception\InvalidConfigurationException($message); + throw new InvalidConfigurationException($message); } } - private function refactorLoadMethodCall(\PhpParser\Node $node) : ?\PhpParser\Node + private function refactorLoadMethodCall(Node $node) : ?Node { - if (!$node instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$node instanceof MethodCall) { return null; } - if (!$node->var instanceof \PhpParser\Node\Expr\Variable) { + if (!$node->var instanceof Variable) { return null; } - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Symfony\\Component\\Config\\Loader\\LoaderInterface'))) { + if (!$this->isObjectType($node->var, new ObjectType('Symfony\\Component\\Config\\Loader\\LoaderInterface'))) { return null; } if (!$this->isName($node->name, 'load')) { @@ -153,15 +153,15 @@ CODE_SAMPLE $this->replaceSuffix($node, $this->from, $this->to); return $node; } - private function replaceSuffix(\PhpParser\Node\Expr\MethodCall $methodCall, string $from, string $to) : void + private function replaceSuffix(MethodCall $methodCall, string $from, string $to) : void { // replace XML to YAML suffix in string parts $fileArgument = $methodCall->getArgs()[0]->value; - $this->traverseNodesWithCallable([$fileArgument], function (\PhpParser\Node $node) use($from, $to) : ?Node { - if (!$node instanceof \PhpParser\Node\Scalar\String_) { + $this->traverseNodesWithCallable([$fileArgument], function (Node $node) use($from, $to) : ?Node { + if (!$node instanceof String_) { return null; } - $node->value = \RectorPrefix20220607\Nette\Utils\Strings::replace($node->value, '#\\.' . $from . '$#', '.' . $to); + $node->value = Strings::replace($node->value, '#\\.' . $from . '$#', '.' . $to); return $node; }); } diff --git a/vendor/rector/rector-symfony/src/Rector/Class_/CommandPropertyToAttributeRector.php b/vendor/rector/rector-symfony/src/Rector/Class_/CommandPropertyToAttributeRector.php index 02e54950a79..662339c9c0f 100644 --- a/vendor/rector/rector-symfony/src/Rector/Class_/CommandPropertyToAttributeRector.php +++ b/vendor/rector/rector-symfony/src/Rector/Class_/CommandPropertyToAttributeRector.php @@ -16,14 +16,14 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer; use Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory; use Rector\VersionBonding\Contract\MinPhpVersionInterface; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://symfony.com/doc/current/console.html#registering-the-command * * @see \Rector\Symfony\Tests\Rector\Class_\CommandPropertyToAttributeRector\CommandPropertyToAttributeRectorTest */ -final class CommandPropertyToAttributeRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface +final class CommandPropertyToAttributeRector extends AbstractRector implements MinPhpVersionInterface { private const ATTRIBUTE = 'Symfony\\Component\\Console\\Attribute\\AsCommand'; /** @@ -41,7 +41,7 @@ final class CommandPropertyToAttributeRector extends \Rector\Core\Rector\Abstrac * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory $phpAttributeGroupFactory, \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer $phpAttributeAnalyzer, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(PhpAttributeGroupFactory $phpAttributeGroupFactory, PhpAttributeAnalyzer $phpAttributeAnalyzer, ReflectionProvider $reflectionProvider) { $this->phpAttributeGroupFactory = $phpAttributeGroupFactory; $this->phpAttributeAnalyzer = $phpAttributeAnalyzer; @@ -49,11 +49,11 @@ final class CommandPropertyToAttributeRector extends \Rector\Core\Rector\Abstrac } public function provideMinPhpVersion() : int { - return \Rector\Core\ValueObject\PhpVersionFeature::ATTRIBUTES; + return PhpVersionFeature::ATTRIBUTES; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add Symfony\\Component\\Console\\Attribute\\AsCommand to Symfony Commands and remove the deprecated properties', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add Symfony\\Component\\Console\\Attribute\\AsCommand to Symfony Commands and remove the deprecated properties', [new CodeSample(<<<'CODE_SAMPLE' class SunshineCommand extends \Symfony\Component\Console\Command\Command { /** @var string|null */ @@ -73,14 +73,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node, new \PHPStan\Type\ObjectType('Symfony\\Component\\Console\\Command\\Command'))) { + if (!$this->isObjectType($node, new ObjectType('Symfony\\Component\\Console\\Command\\Command'))) { return null; } if (!$this->reflectionProvider->hasClass(self::ATTRIBUTE)) { @@ -91,7 +91,7 @@ CODE_SAMPLE } $defaultName = null; $property = $node->getProperty('defaultName'); - if ($property instanceof \PhpParser\Node\Stmt\Property) { + if ($property instanceof Property) { $defaultName = $this->getValueFromProperty($property); if ($defaultName !== null) { $this->removeNode($property); @@ -102,7 +102,7 @@ CODE_SAMPLE } $defaultDescription = null; $property = $node->getProperty('defaultDescription'); - if ($property instanceof \PhpParser\Node\Stmt\Property) { + if ($property instanceof Property) { $defaultDescription = $this->getValueFromProperty($property); if ($defaultDescription !== null) { $this->removeNode($property); @@ -111,22 +111,22 @@ CODE_SAMPLE $node->attrGroups[] = $this->createAttributeGroup($defaultName, $defaultDescription); return $node; } - private function createAttributeGroup(string $defaultName, ?string $defaultDescription) : \PhpParser\Node\AttributeGroup + private function createAttributeGroup(string $defaultName, ?string $defaultDescription) : AttributeGroup { $attributeGroup = $this->phpAttributeGroupFactory->createFromClass(self::ATTRIBUTE); - $attributeGroup->attrs[0]->args[] = new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\String_($defaultName)); + $attributeGroup->attrs[0]->args[] = new Arg(new String_($defaultName)); if ($defaultDescription !== null) { - $attributeGroup->attrs[0]->args[] = new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\String_($defaultDescription)); + $attributeGroup->attrs[0]->args[] = new Arg(new String_($defaultDescription)); } return $attributeGroup; } - private function getValueFromProperty(\PhpParser\Node\Stmt\Property $property) : ?string + private function getValueFromProperty(Property $property) : ?string { if (\count($property->props) !== 1) { return null; } $propertyProperty = $property->props[0]; - if ($propertyProperty->default instanceof \PhpParser\Node\Scalar\String_) { + if ($propertyProperty->default instanceof String_) { return $propertyProperty->default->value; } return null; diff --git a/vendor/rector/rector-symfony/src/Rector/Class_/EventListenerToEventSubscriberRector.php b/vendor/rector/rector-symfony/src/Rector/Class_/EventListenerToEventSubscriberRector.php index 3de92acc833..c93af6def36 100644 --- a/vendor/rector/rector-symfony/src/Rector/Class_/EventListenerToEventSubscriberRector.php +++ b/vendor/rector/rector-symfony/src/Rector/Class_/EventListenerToEventSubscriberRector.php @@ -13,12 +13,12 @@ use Rector\Symfony\ApplicationMetadata\ListenerServiceDefinitionProvider; use Rector\Symfony\NodeFactory\GetSubscribedEventsClassMethodFactory; use Rector\Symfony\ValueObject\EventNameToClassAndConstant; use Rector\Symfony\ValueObject\ServiceDefinition; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\Class_\EventListenerToEventSubscriberRector\EventListenerToEventSubscriberRectorTest */ -final class EventListenerToEventSubscriberRector extends \Rector\Core\Rector\AbstractRector +final class EventListenerToEventSubscriberRector extends AbstractRector { /** * @var string @@ -51,29 +51,29 @@ final class EventListenerToEventSubscriberRector extends \Rector\Core\Rector\Abs * @var \Rector\Symfony\NodeFactory\GetSubscribedEventsClassMethodFactory */ private $getSubscribedEventsClassMethodFactory; - public function __construct(\Rector\Symfony\ApplicationMetadata\ListenerServiceDefinitionProvider $listenerServiceDefinitionProvider, \Rector\Symfony\NodeFactory\GetSubscribedEventsClassMethodFactory $getSubscribedEventsClassMethodFactory) + public function __construct(ListenerServiceDefinitionProvider $listenerServiceDefinitionProvider, GetSubscribedEventsClassMethodFactory $getSubscribedEventsClassMethodFactory) { $this->listenerServiceDefinitionProvider = $listenerServiceDefinitionProvider; $this->getSubscribedEventsClassMethodFactory = $getSubscribedEventsClassMethodFactory; $this->eventNamesToClassConstants = [ // kernel events - new \Rector\Symfony\ValueObject\EventNameToClassAndConstant('kernel.request', self::KERNEL_EVENTS_CLASS, 'REQUEST'), - new \Rector\Symfony\ValueObject\EventNameToClassAndConstant('kernel.exception', self::KERNEL_EVENTS_CLASS, 'EXCEPTION'), - new \Rector\Symfony\ValueObject\EventNameToClassAndConstant('kernel.view', self::KERNEL_EVENTS_CLASS, 'VIEW'), - new \Rector\Symfony\ValueObject\EventNameToClassAndConstant('kernel.controller', self::KERNEL_EVENTS_CLASS, 'CONTROLLER'), - new \Rector\Symfony\ValueObject\EventNameToClassAndConstant('kernel.controller_arguments', self::KERNEL_EVENTS_CLASS, 'CONTROLLER_ARGUMENTS'), - new \Rector\Symfony\ValueObject\EventNameToClassAndConstant('kernel.response', self::KERNEL_EVENTS_CLASS, 'RESPONSE'), - new \Rector\Symfony\ValueObject\EventNameToClassAndConstant('kernel.terminate', self::KERNEL_EVENTS_CLASS, 'TERMINATE'), - new \Rector\Symfony\ValueObject\EventNameToClassAndConstant('kernel.finish_request', self::KERNEL_EVENTS_CLASS, 'FINISH_REQUEST'), + new EventNameToClassAndConstant('kernel.request', self::KERNEL_EVENTS_CLASS, 'REQUEST'), + new EventNameToClassAndConstant('kernel.exception', self::KERNEL_EVENTS_CLASS, 'EXCEPTION'), + new EventNameToClassAndConstant('kernel.view', self::KERNEL_EVENTS_CLASS, 'VIEW'), + new EventNameToClassAndConstant('kernel.controller', self::KERNEL_EVENTS_CLASS, 'CONTROLLER'), + new EventNameToClassAndConstant('kernel.controller_arguments', self::KERNEL_EVENTS_CLASS, 'CONTROLLER_ARGUMENTS'), + new EventNameToClassAndConstant('kernel.response', self::KERNEL_EVENTS_CLASS, 'RESPONSE'), + new EventNameToClassAndConstant('kernel.terminate', self::KERNEL_EVENTS_CLASS, 'TERMINATE'), + new EventNameToClassAndConstant('kernel.finish_request', self::KERNEL_EVENTS_CLASS, 'FINISH_REQUEST'), // console events - new \Rector\Symfony\ValueObject\EventNameToClassAndConstant('console.command', self::CONSOLE_EVENTS_CLASS, 'COMMAND'), - new \Rector\Symfony\ValueObject\EventNameToClassAndConstant('console.terminate', self::CONSOLE_EVENTS_CLASS, 'TERMINATE'), - new \Rector\Symfony\ValueObject\EventNameToClassAndConstant('console.error', self::CONSOLE_EVENTS_CLASS, 'ERROR'), + new EventNameToClassAndConstant('console.command', self::CONSOLE_EVENTS_CLASS, 'COMMAND'), + new EventNameToClassAndConstant('console.terminate', self::CONSOLE_EVENTS_CLASS, 'TERMINATE'), + new EventNameToClassAndConstant('console.error', self::CONSOLE_EVENTS_CLASS, 'ERROR'), ]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change Symfony Event listener class to Event Subscriber based on configuration in service.yaml file', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change Symfony Event listener class to Event Subscriber based on configuration in service.yaml file', [new CodeSample(<<<'CODE_SAMPLE' class SomeListener { public function methodToBeCalled() @@ -112,12 +112,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { // anonymous class if ($node->name === null) { @@ -139,7 +139,7 @@ CODE_SAMPLE $this->changeListenerToSubscriberWithMethods($node, $listenerClassesToEventsToMethods[$className]); return $node; } - private function isAlreadyEventSubscriber(\PhpParser\Node\Stmt\Class_ $class) : bool + private function isAlreadyEventSubscriber(Class_ $class) : bool { foreach ($class->implements as $implement) { if ($this->isName($implement, 'Symfony\\Component\\EventDispatcher\\EventSubscriberInterface')) { @@ -151,13 +151,13 @@ CODE_SAMPLE /** * @param array $eventsToMethods */ - private function changeListenerToSubscriberWithMethods(\PhpParser\Node\Stmt\Class_ $class, array $eventsToMethods) : void + private function changeListenerToSubscriberWithMethods(Class_ $class, array $eventsToMethods) : void { - $class->implements[] = new \PhpParser\Node\Name\FullyQualified(self::EVENT_SUBSCRIBER_INTERFACE); + $class->implements[] = new FullyQualified(self::EVENT_SUBSCRIBER_INTERFACE); $classShortName = $this->nodeNameResolver->getShortName($class); // remove suffix - $classShortName = \RectorPrefix20220607\Nette\Utils\Strings::replace($classShortName, self::LISTENER_MATCH_REGEX, '$1'); - $class->name = new \PhpParser\Node\Identifier($classShortName . 'EventSubscriber'); + $classShortName = Strings::replace($classShortName, self::LISTENER_MATCH_REGEX, '$1'); + $class->name = new Identifier($classShortName . 'EventSubscriber'); $classMethod = $this->getSubscribedEventsClassMethodFactory->createFromServiceDefinitionsAndEventsToMethods($eventsToMethods, $this->eventNamesToClassConstants); $class->stmts[] = $classMethod; } diff --git a/vendor/rector/rector-symfony/src/Rector/Class_/FormTypeWithDependencyToOptionsRector.php b/vendor/rector/rector-symfony/src/Rector/Class_/FormTypeWithDependencyToOptionsRector.php index 01fe341c8da..89c800df379 100644 --- a/vendor/rector/rector-symfony/src/Rector/Class_/FormTypeWithDependencyToOptionsRector.php +++ b/vendor/rector/rector-symfony/src/Rector/Class_/FormTypeWithDependencyToOptionsRector.php @@ -14,14 +14,14 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\MethodName; use Rector\Symfony\NodeFactory\FormType\BuildFormOptionAssignsFactory; use Rector\Symfony\NodeRemover\ConstructorDependencyRemover; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://speakerdeck.com/webmozart/symfony-forms-101?slide=24 * * @see \Rector\Symfony\Tests\Rector\Class_\FormTypeWithDependencyToOptionsRector\FormTypeWithDependencyToOptionsRectorTest */ -final class FormTypeWithDependencyToOptionsRector extends \Rector\Core\Rector\AbstractRector +final class FormTypeWithDependencyToOptionsRector extends AbstractRector { /** * @readonly @@ -33,14 +33,14 @@ final class FormTypeWithDependencyToOptionsRector extends \Rector\Core\Rector\Ab * @var \Rector\Symfony\NodeRemover\ConstructorDependencyRemover */ private $constructorDependencyRemover; - public function __construct(\Rector\Symfony\NodeFactory\FormType\BuildFormOptionAssignsFactory $buildFormOptionAssignsFactory, \Rector\Symfony\NodeRemover\ConstructorDependencyRemover $constructorDependencyRemover) + public function __construct(BuildFormOptionAssignsFactory $buildFormOptionAssignsFactory, ConstructorDependencyRemover $constructorDependencyRemover) { $this->buildFormOptionAssignsFactory = $buildFormOptionAssignsFactory; $this->constructorDependencyRemover = $constructorDependencyRemover; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Move constructor dependency from form type class to an $options parameter', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Move constructor dependency from form type class to an $options parameter', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; @@ -86,14 +86,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $formObjectType = new \PHPStan\Type\ObjectType('Symfony\\Component\\Form\\AbstractType'); + $formObjectType = new ObjectType('Symfony\\Component\\Form\\AbstractType'); if (!$this->isObjectType($node, $formObjectType)) { return null; } @@ -101,8 +101,8 @@ CODE_SAMPLE if ($node->isAbstract()) { return null; } - $constructorClassMethod = $node->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$constructorClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $constructorClassMethod = $node->getMethod(MethodName::CONSTRUCT); + if (!$constructorClassMethod instanceof ClassMethod) { return null; } $params = $constructorClassMethod->getParams(); @@ -110,9 +110,9 @@ CODE_SAMPLE return null; } $buildFormClassMethod = $node->getMethod('buildForm'); - if (!$buildFormClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$buildFormClassMethod instanceof ClassMethod) { // form has to have some items - throw new \Rector\Core\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $paramNames = $this->nodeNameResolver->getNames($params); // 1. add assigns at start of ClassMethod @@ -135,10 +135,10 @@ CODE_SAMPLE * * @param string[] $paramNames */ - private function replacePropertyFetchesByVariables(\PhpParser\Node\Stmt\ClassMethod $classMethod, array $paramNames) : void + private function replacePropertyFetchesByVariables(ClassMethod $classMethod, array $paramNames) : void { - $this->traverseNodesWithCallable((array) $classMethod->stmts, function (\PhpParser\Node $node) use($paramNames) : ?Variable { - if (!$node instanceof \PhpParser\Node\Expr\PropertyFetch) { + $this->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) use($paramNames) : ?Variable { + if (!$node instanceof PropertyFetch) { return null; } if (!$this->nodeNameResolver->isName($node->var, 'this')) { @@ -152,7 +152,7 @@ CODE_SAMPLE if (!\is_string($variableName)) { return null; } - return new \PhpParser\Node\Expr\Variable($variableName); + return new Variable($variableName); }); } } diff --git a/vendor/rector/rector-symfony/src/Rector/Class_/InvokableControllerRector.php b/vendor/rector/rector-symfony/src/Rector/Class_/InvokableControllerRector.php index ea055586baf..69d12d9a0ed 100644 --- a/vendor/rector/rector-symfony/src/Rector/Class_/InvokableControllerRector.php +++ b/vendor/rector/rector-symfony/src/Rector/Class_/InvokableControllerRector.php @@ -18,8 +18,8 @@ use Rector\Symfony\NodeAnalyzer\SymfonyControllerFilter; use Rector\Symfony\NodeFactory\InvokableControllerClassFactory; use Rector\Symfony\Printer\NeighbourClassLikePrinter; use Rector\Symfony\TypeAnalyzer\ControllerAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://symfony.com/doc/2.8/controller/service.html#referring-to-the-service * @@ -27,7 +27,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * Inspiration @see https://github.com/rectorphp/rector-src/blob/main/rules/PSR4/Rector/Namespace_/MultipleClassFileToPsr4ClassesRector.php */ -final class InvokableControllerRector extends \Rector\Core\Rector\AbstractRector +final class InvokableControllerRector extends AbstractRector { /** * @readonly @@ -54,7 +54,7 @@ final class InvokableControllerRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector */ private $removedAndAddedFilesCollector; - public function __construct(\Rector\Symfony\TypeAnalyzer\ControllerAnalyzer $controllerAnalyzer, \Rector\Symfony\NodeAnalyzer\SymfonyControllerFilter $symfonyControllerFilter, \Rector\Symfony\Printer\NeighbourClassLikePrinter $neighbourClassLikePrinter, \Rector\Symfony\NodeFactory\InvokableControllerClassFactory $invokableControllerClassFactory, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector) + public function __construct(ControllerAnalyzer $controllerAnalyzer, SymfonyControllerFilter $symfonyControllerFilter, NeighbourClassLikePrinter $neighbourClassLikePrinter, InvokableControllerClassFactory $invokableControllerClassFactory, RemovedAndAddedFilesCollector $removedAndAddedFilesCollector) { $this->controllerAnalyzer = $controllerAnalyzer; $this->symfonyControllerFilter = $symfonyControllerFilter; @@ -62,9 +62,9 @@ final class InvokableControllerRector extends \Rector\Core\Rector\AbstractRector $this->invokableControllerClassFactory = $invokableControllerClassFactory; $this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change god controller to single-action invokable controllers', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change god controller to single-action invokable controllers', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Bundle\FrameworkBundle\Controller\Controller; final class SomeController extends Controller @@ -104,15 +104,15 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { // skip anonymous controllers - if (!$node->name instanceof \PhpParser\Node\Identifier) { + if (!$node->name instanceof Identifier) { return null; } if (!$this->controllerAnalyzer->isInsideController($node)) { @@ -130,9 +130,9 @@ CODE_SAMPLE foreach ($actionClassMethods as $actionClassMethod) { $invokableControllerClass = $this->invokableControllerClassFactory->createWithActionClassMethod($node, $actionClassMethod); /** @var Namespace_|FileWithoutNamespace|null $parentNamespace */ - $parentNamespace = $this->betterNodeFinder->findParentByTypes($node, [\PhpParser\Node\Stmt\Namespace_::class, \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace::class]); - if (!$parentNamespace instanceof \PhpParser\Node) { - throw new \Rector\Core\Exception\ShouldNotHappenException('Missing parent namespace or without namespace node'); + $parentNamespace = $this->betterNodeFinder->findParentByTypes($node, [Namespace_::class, FileWithoutNamespace::class]); + if (!$parentNamespace instanceof Node) { + throw new ShouldNotHappenException('Missing parent namespace or without namespace node'); } $this->neighbourClassLikePrinter->printClassLike($invokableControllerClass, $parentNamespace, $this->file->getSmartFileInfo(), $this->file); } @@ -141,9 +141,9 @@ CODE_SAMPLE $this->removedAndAddedFilesCollector->removeFile($smartFileInfo); return null; } - private function refactorSingleAction(\PhpParser\Node\Stmt\ClassMethod $actionClassMethod, \PhpParser\Node\Stmt\Class_ $class) : \PhpParser\Node\Stmt\Class_ + private function refactorSingleAction(ClassMethod $actionClassMethod, Class_ $class) : Class_ { - $actionClassMethod->name = new \PhpParser\Node\Identifier(\Rector\Core\ValueObject\MethodName::INVOKE); + $actionClassMethod->name = new Identifier(MethodName::INVOKE); return $class; } } diff --git a/vendor/rector/rector-symfony/src/Rector/Class_/LoadValidatorMetadataToAnnotationRector.php b/vendor/rector/rector-symfony/src/Rector/Class_/LoadValidatorMetadataToAnnotationRector.php index 47c3f9e5515..80a0c4208aa 100644 --- a/vendor/rector/rector-symfony/src/Rector/Class_/LoadValidatorMetadataToAnnotationRector.php +++ b/vendor/rector/rector-symfony/src/Rector/Class_/LoadValidatorMetadataToAnnotationRector.php @@ -9,28 +9,28 @@ use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Property; use Rector\Core\Rector\AbstractRector; use Rector\Symfony\NodeAnalyzer\Annotations\ConstraintAnnotationResolver; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://symfony.com/doc/current/components/validator/metadata.html * @changelog https://symfony.com/doc/current/validation.html#the-basics-of-validation * * @see \Rector\Symfony\Tests\Rector\Class_\LoadValidatorMetadataToAnnotationRector\LoadValidatorMetadataToAnnotationRectorTest */ -final class LoadValidatorMetadataToAnnotationRector extends \Rector\Core\Rector\AbstractRector +final class LoadValidatorMetadataToAnnotationRector extends AbstractRector { /** * @readonly * @var \Rector\Symfony\NodeAnalyzer\Annotations\ConstraintAnnotationResolver */ private $constraintAnnotationResolver; - public function __construct(\Rector\Symfony\NodeAnalyzer\Annotations\ConstraintAnnotationResolver $constraintAnnotationResolver) + public function __construct(ConstraintAnnotationResolver $constraintAnnotationResolver) { $this->constraintAnnotationResolver = $constraintAnnotationResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Move metadata from loadValidatorMetadata() to property/getter/method annotations', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Move metadata from loadValidatorMetadata() to property/getter/method annotations', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Mapping\ClassMetadata; @@ -65,22 +65,22 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $loadValidatorMetadataClassMethod = $node->getMethod('loadValidatorMetadata'); - if (!$loadValidatorMetadataClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$loadValidatorMetadataClassMethod instanceof ClassMethod) { return null; } // @todo extract annotations from loadValidatorMetadata() $annotationsToMethodNames = $this->constraintAnnotationResolver->resolveGetterTagValueNodes($loadValidatorMetadataClassMethod); foreach ($annotationsToMethodNames as $methodName => $doctrineTagValueNode) { $classMethod = $node->getMethod($methodName); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$classMethod instanceof ClassMethod) { continue; } $getterPhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); @@ -89,7 +89,7 @@ CODE_SAMPLE $annotationsToPropertyNames = $this->constraintAnnotationResolver->resolvePropertyTagValueNodes($loadValidatorMetadataClassMethod); foreach ($annotationsToPropertyNames as $propertyName => $doctrineTagValueNode) { $property = $node->getProperty($propertyName); - if (!$property instanceof \PhpParser\Node\Stmt\Property) { + if (!$property instanceof Property) { continue; } $propertyPhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); diff --git a/vendor/rector/rector-symfony/src/Rector/Class_/LogoutHandlerToLogoutEventSubscriberRector.php b/vendor/rector/rector-symfony/src/Rector/Class_/LogoutHandlerToLogoutEventSubscriberRector.php index cad9cbb48ff..1f3936eca41 100644 --- a/vendor/rector/rector-symfony/src/Rector/Class_/LogoutHandlerToLogoutEventSubscriberRector.php +++ b/vendor/rector/rector-symfony/src/Rector/Class_/LogoutHandlerToLogoutEventSubscriberRector.php @@ -12,14 +12,14 @@ use Rector\Core\Rector\AbstractRector; use Rector\Symfony\NodeFactory\GetSubscribedEventsClassMethodFactory; use Rector\Symfony\NodeFactory\OnLogoutClassMethodFactory; use Rector\Symfony\ValueObject\EventReferenceToMethodName; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/symfony/symfony/pull/36243 * * @see \Rector\Symfony\Tests\Rector\Class_\LogoutHandlerToLogoutEventSubscriberRector\LogoutHandlerToLogoutEventSubscriberRectorTest */ -final class LogoutHandlerToLogoutEventSubscriberRector extends \Rector\Core\Rector\AbstractRector +final class LogoutHandlerToLogoutEventSubscriberRector extends AbstractRector { /** * @readonly @@ -36,15 +36,15 @@ final class LogoutHandlerToLogoutEventSubscriberRector extends \Rector\Core\Rect * @var \Rector\Symfony\NodeFactory\GetSubscribedEventsClassMethodFactory */ private $getSubscribedEventsClassMethodFactory; - public function __construct(\Rector\Symfony\NodeFactory\OnLogoutClassMethodFactory $onLogoutClassMethodFactory, \Rector\Symfony\NodeFactory\GetSubscribedEventsClassMethodFactory $getSubscribedEventsClassMethodFactory) + public function __construct(OnLogoutClassMethodFactory $onLogoutClassMethodFactory, GetSubscribedEventsClassMethodFactory $getSubscribedEventsClassMethodFactory) { $this->onLogoutClassMethodFactory = $onLogoutClassMethodFactory; $this->getSubscribedEventsClassMethodFactory = $getSubscribedEventsClassMethodFactory; - $this->logoutHandlerObjectType = new \PHPStan\Type\ObjectType('Symfony\\Component\\Security\\Http\\Logout\\LogoutHandlerInterface'); + $this->logoutHandlerObjectType = new ObjectType('Symfony\\Component\\Security\\Http\\Logout\\LogoutHandlerInterface'); } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change logout handler to an event listener that listens to LogoutEvent', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change logout handler to an event listener that listens to LogoutEvent', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Security\Http\Logout\LogoutHandlerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -88,12 +88,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isObjectType($node, $this->logoutHandlerObjectType)) { return null; @@ -104,21 +104,21 @@ CODE_SAMPLE $this->refactorImplements($node); // 2. refactor logout() class method to onLogout() $logoutClassMethod = $node->getMethod('logout'); - if (!$logoutClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$logoutClassMethod instanceof ClassMethod) { return null; } $node->stmts[] = $this->onLogoutClassMethodFactory->createFromLogoutClassMethod($logoutClassMethod); $this->removeNode($logoutClassMethod); // 3. add getSubscribedEvents() class method $classConstFetch = $this->nodeFactory->createClassConstReference('Symfony\\Component\\Security\\Http\\Event\\LogoutEvent'); - $eventReferencesToMethodNames = [new \Rector\Symfony\ValueObject\EventReferenceToMethodName($classConstFetch, 'onLogout')]; + $eventReferencesToMethodNames = [new EventReferenceToMethodName($classConstFetch, 'onLogout')]; $getSubscribedEventsClassMethod = $this->getSubscribedEventsClassMethodFactory->create($eventReferencesToMethodNames); $node->stmts[] = $getSubscribedEventsClassMethod; return $node; } - private function refactorImplements(\PhpParser\Node\Stmt\Class_ $class) : void + private function refactorImplements(Class_ $class) : void { - $class->implements[] = new \PhpParser\Node\Name\FullyQualified('Symfony\\Component\\EventDispatcher\\EventSubscriberInterface'); + $class->implements[] = new FullyQualified('Symfony\\Component\\EventDispatcher\\EventSubscriberInterface'); foreach ($class->implements as $key => $implement) { if (!$this->isName($implement, $this->logoutHandlerObjectType->getClassName())) { continue; @@ -126,7 +126,7 @@ CODE_SAMPLE unset($class->implements[$key]); } } - private function hasImplements(\PhpParser\Node\Stmt\Class_ $class) : bool + private function hasImplements(Class_ $class) : bool { foreach ($class->implements as $implement) { if ($this->isName($implement, 'Symfony\\Component\\Security\\Http\\Logout\\LogoutHandlerInterface')) { diff --git a/vendor/rector/rector-symfony/src/Rector/Class_/LogoutSuccessHandlerToLogoutEventSubscriberRector.php b/vendor/rector/rector-symfony/src/Rector/Class_/LogoutSuccessHandlerToLogoutEventSubscriberRector.php index 0995944a541..084ffe8a6d5 100644 --- a/vendor/rector/rector-symfony/src/Rector/Class_/LogoutSuccessHandlerToLogoutEventSubscriberRector.php +++ b/vendor/rector/rector-symfony/src/Rector/Class_/LogoutSuccessHandlerToLogoutEventSubscriberRector.php @@ -12,14 +12,14 @@ use Rector\Core\Rector\AbstractRector; use Rector\Symfony\NodeFactory\GetSubscribedEventsClassMethodFactory; use Rector\Symfony\NodeFactory\OnSuccessLogoutClassMethodFactory; use Rector\Symfony\ValueObject\EventReferenceToMethodNameWithPriority; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/symfony/symfony/pull/36243 * * @see \Rector\Symfony\Tests\Rector\Class_\LogoutSuccessHandlerToLogoutEventSubscriberRector\LogoutSuccessHandlerToLogoutEventSubscriberRectorTest */ -final class LogoutSuccessHandlerToLogoutEventSubscriberRector extends \Rector\Core\Rector\AbstractRector +final class LogoutSuccessHandlerToLogoutEventSubscriberRector extends AbstractRector { /** * @readonly @@ -36,15 +36,15 @@ final class LogoutSuccessHandlerToLogoutEventSubscriberRector extends \Rector\Co * @var \Rector\Symfony\NodeFactory\GetSubscribedEventsClassMethodFactory */ private $getSubscribedEventsClassMethodFactory; - public function __construct(\Rector\Symfony\NodeFactory\OnSuccessLogoutClassMethodFactory $onSuccessLogoutClassMethodFactory, \Rector\Symfony\NodeFactory\GetSubscribedEventsClassMethodFactory $getSubscribedEventsClassMethodFactory) + public function __construct(OnSuccessLogoutClassMethodFactory $onSuccessLogoutClassMethodFactory, GetSubscribedEventsClassMethodFactory $getSubscribedEventsClassMethodFactory) { $this->onSuccessLogoutClassMethodFactory = $onSuccessLogoutClassMethodFactory; $this->getSubscribedEventsClassMethodFactory = $getSubscribedEventsClassMethodFactory; - $this->successHandlerObjectType = new \PHPStan\Type\ObjectType('Symfony\\Component\\Security\\Http\\Logout\\LogoutSuccessHandlerInterface'); + $this->successHandlerObjectType = new ObjectType('Symfony\\Component\\Security\\Http\\Logout\\LogoutSuccessHandlerInterface'); } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change logout success handler to an event listener that listens to LogoutEvent', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change logout success handler to an event listener that listens to LogoutEvent', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -108,12 +108,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isObjectType($node, $this->successHandlerObjectType)) { return null; @@ -124,21 +124,21 @@ CODE_SAMPLE $this->refactorImplements($node); // 2. refactor logout() class method to onLogout() $onLogoutSuccessClassMethod = $node->getMethod('onLogoutSuccess'); - if (!$onLogoutSuccessClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + if (!$onLogoutSuccessClassMethod instanceof ClassMethod) { return null; } $node->stmts[] = $this->onSuccessLogoutClassMethodFactory->createFromOnLogoutSuccessClassMethod($onLogoutSuccessClassMethod); // 3. add getSubscribedEvents() class method $classConstFetch = $this->nodeFactory->createClassConstReference('Symfony\\Component\\Security\\Http\\Event\\LogoutEvent'); - $eventReferencesToMethodNames = [new \Rector\Symfony\ValueObject\EventReferenceToMethodNameWithPriority($classConstFetch, 'onLogout', 64)]; + $eventReferencesToMethodNames = [new EventReferenceToMethodNameWithPriority($classConstFetch, 'onLogout', 64)]; $getSubscribedEventsClassMethod = $this->getSubscribedEventsClassMethodFactory->create($eventReferencesToMethodNames); $node->stmts[] = $getSubscribedEventsClassMethod; $this->removeNode($onLogoutSuccessClassMethod); return $node; } - private function refactorImplements(\PhpParser\Node\Stmt\Class_ $class) : void + private function refactorImplements(Class_ $class) : void { - $class->implements[] = new \PhpParser\Node\Name\FullyQualified('Symfony\\Component\\EventDispatcher\\EventSubscriberInterface'); + $class->implements[] = new FullyQualified('Symfony\\Component\\EventDispatcher\\EventSubscriberInterface'); foreach ($class->implements as $key => $implement) { if (!$this->isName($implement, $this->successHandlerObjectType->getClassName())) { continue; @@ -146,7 +146,7 @@ CODE_SAMPLE unset($class->implements[$key]); } } - private function hasImplements(\PhpParser\Node\Stmt\Class_ $class) : bool + private function hasImplements(Class_ $class) : bool { foreach ($class->implements as $implement) { if ($this->isName($implement, 'Symfony\\Component\\Security\\Http\\Logout\\LogoutSuccessHandlerInterface')) { diff --git a/vendor/rector/rector-symfony/src/Rector/Class_/MakeCommandLazyRector.php b/vendor/rector/rector-symfony/src/Rector/Class_/MakeCommandLazyRector.php index 47a574e16cd..b3e78fcfd79 100644 --- a/vendor/rector/rector-symfony/src/Rector/Class_/MakeCommandLazyRector.php +++ b/vendor/rector/rector-symfony/src/Rector/Class_/MakeCommandLazyRector.php @@ -21,27 +21,27 @@ use Rector\Core\NodeAnalyzer\ParamAnalyzer; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\MethodName; use RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\PropertyBuilder; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://symfony.com/doc/current/console/commands_as_services.html * * @see \Rector\Symfony\Tests\Rector\Class_\MakeCommandLazyRector\MakeCommandLazyRectorTest */ -final class MakeCommandLazyRector extends \Rector\Core\Rector\AbstractRector +final class MakeCommandLazyRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeAnalyzer\ParamAnalyzer */ private $paramAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ParamAnalyzer $paramAnalyzer) + public function __construct(ParamAnalyzer $paramAnalyzer) { $this->paramAnalyzer = $paramAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Make Symfony commands lazy', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Make Symfony commands lazy', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Console\Command\Command final class SunshineCommand extends Command @@ -70,25 +70,25 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Class_::class]; + return [Class_::class]; } /** * @param Class_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node, new \PHPStan\Type\ObjectType('Symfony\\Component\\Console\\Command\\Command'))) { + if (!$this->isObjectType($node, new ObjectType('Symfony\\Component\\Console\\Command\\Command'))) { return null; } $defaultNameProperty = $node->getProperty('defaultName'); - if ($defaultNameProperty instanceof \PhpParser\Node\Stmt\Property) { + if ($defaultNameProperty instanceof Property) { return null; } $commandName = $this->resolveCommandName($node); - if (!$commandName instanceof \PhpParser\Node) { + if (!$commandName instanceof Node) { return null; } - if (!$commandName instanceof \PhpParser\Node\Scalar\String_ && !$commandName instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if (!$commandName instanceof String_ && !$commandName instanceof ClassConstFetch) { return null; } $this->removeConstructorIfHasOnlySetNameMethodCall($node); @@ -96,30 +96,30 @@ CODE_SAMPLE $node->stmts = \array_merge([$defaultNameProperty], $node->stmts); return $node; } - private function resolveCommandName(\PhpParser\Node\Stmt\Class_ $class) : ?\PhpParser\Node + private function resolveCommandName(Class_ $class) : ?Node { $commandName = $this->resolveCommandNameFromConstructor($class); - if (!$commandName instanceof \PhpParser\Node) { + if (!$commandName instanceof Node) { return $this->resolveCommandNameFromSetName($class); } return $commandName; } - private function resolveCommandNameFromConstructor(\PhpParser\Node\Stmt\Class_ $class) : ?\PhpParser\Node + private function resolveCommandNameFromConstructor(Class_ $class) : ?Node { $commandName = null; - $this->traverseNodesWithCallable($class->stmts, function (\PhpParser\Node $node) use(&$commandName) { - if (!$node instanceof \PhpParser\Node\Expr\StaticCall) { + $this->traverseNodesWithCallable($class->stmts, function (Node $node) use(&$commandName) { + if (!$node instanceof StaticCall) { return null; } - if (!$this->isObjectType($node->class, new \PHPStan\Type\ObjectType('Symfony\\Component\\Console\\Command\\Command'))) { + if (!$this->isObjectType($node->class, new ObjectType('Symfony\\Component\\Console\\Command\\Command'))) { return null; } $commandName = $this->matchCommandNameNodeInConstruct($node); - if (!$commandName instanceof \PhpParser\Node\Expr) { + if (!$commandName instanceof Expr) { return null; } // only valid static property values for name - if (!$commandName instanceof \PhpParser\Node\Scalar\String_ && !$commandName instanceof \PhpParser\Node\Expr\ConstFetch) { + if (!$commandName instanceof String_ && !$commandName instanceof ConstFetch) { return null; } // remove if parent name is not string @@ -127,14 +127,14 @@ CODE_SAMPLE }); return $commandName; } - private function resolveCommandNameFromSetName(\PhpParser\Node\Stmt\Class_ $class) : ?\PhpParser\Node + private function resolveCommandNameFromSetName(Class_ $class) : ?Node { $commandName = null; - $this->traverseNodesWithCallable($class->stmts, function (\PhpParser\Node $node) use(&$commandName) { - if (!$node instanceof \PhpParser\Node\Expr\MethodCall) { + $this->traverseNodesWithCallable($class->stmts, function (Node $node) use(&$commandName) { + if (!$node instanceof MethodCall) { return null; } - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Symfony\\Component\\Console\\Command\\Command'))) { + if (!$this->isObjectType($node->var, new ObjectType('Symfony\\Component\\Console\\Command\\Command'))) { return null; } if (!$this->isName($node->name, 'setName')) { @@ -142,21 +142,21 @@ CODE_SAMPLE } $commandName = $node->getArgs()[0]->value; $commandNameStaticType = $this->getType($commandName); - if (!$commandNameStaticType instanceof \PHPStan\Type\StringType) { + if (!$commandNameStaticType instanceof StringType) { return null; } // is chain call? → remove by variable nulling - if ($node->var instanceof \PhpParser\Node\Expr\MethodCall) { + if ($node->var instanceof MethodCall) { return $node->var; } $this->removeNode($node); }); return $commandName; } - private function removeConstructorIfHasOnlySetNameMethodCall(\PhpParser\Node\Stmt\Class_ $class) : void + private function removeConstructorIfHasOnlySetNameMethodCall(Class_ $class) : void { - $constructClassMethod = $class->getMethod(\Rector\Core\ValueObject\MethodName::CONSTRUCT); - if (!$constructClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $constructClassMethod = $class->getMethod(MethodName::CONSTRUCT); + if (!$constructClassMethod instanceof ClassMethod) { return; } $stmts = (array) $constructClassMethod->stmts; @@ -168,17 +168,17 @@ CODE_SAMPLE return; } $onlyNode = $stmts[0]; - if ($onlyNode instanceof \PhpParser\Node\Stmt\Expression) { + if ($onlyNode instanceof Expression) { $onlyNode = $onlyNode->expr; } /** @var Expr|null $onlyNode */ if ($onlyNode === null) { return; } - if (!$onlyNode instanceof \PhpParser\Node\Expr\StaticCall) { + if (!$onlyNode instanceof StaticCall) { return; } - if (!$this->isName($onlyNode->name, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if (!$this->isName($onlyNode->name, MethodName::CONSTRUCT)) { return; } if ($onlyNode->args !== []) { @@ -186,9 +186,9 @@ CODE_SAMPLE } $this->removeNode($constructClassMethod); } - private function matchCommandNameNodeInConstruct(\PhpParser\Node\Expr\StaticCall $staticCall) : ?\PhpParser\Node\Expr + private function matchCommandNameNodeInConstruct(StaticCall $staticCall) : ?Expr { - if (!$this->isName($staticCall->name, \Rector\Core\ValueObject\MethodName::CONSTRUCT)) { + if (!$this->isName($staticCall->name, MethodName::CONSTRUCT)) { return null; } if (\count($staticCall->args) < 1) { @@ -196,14 +196,14 @@ CODE_SAMPLE } $firstArg = $staticCall->getArgs()[0]; $staticType = $this->getType($firstArg->value); - if (!$staticType instanceof \PHPStan\Type\StringType) { + if (!$staticType instanceof StringType) { return null; } return $firstArg->value; } - private function createStaticProtectedPropertyWithDefault(string $name, \PhpParser\Node $node) : \PhpParser\Node\Stmt\Property + private function createStaticProtectedPropertyWithDefault(string $name, Node $node) : Property { - $propertyBuilder = new \RectorPrefix20220607\Symplify\Astral\ValueObject\NodeBuilder\PropertyBuilder($name); + $propertyBuilder = new PropertyBuilder($name); $propertyBuilder->makeProtected(); $propertyBuilder->makeStatic(); $propertyBuilder->setDefault($node); diff --git a/vendor/rector/rector-symfony/src/Rector/ConstFetch/ConstraintUrlOptionRector.php b/vendor/rector/rector-symfony/src/Rector/ConstFetch/ConstraintUrlOptionRector.php index 8299223082d..3c96ac0cbae 100644 --- a/vendor/rector/rector-symfony/src/Rector/ConstFetch/ConstraintUrlOptionRector.php +++ b/vendor/rector/rector-symfony/src/Rector/ConstFetch/ConstraintUrlOptionRector.php @@ -10,34 +10,34 @@ use PhpParser\Node\Scalar\String_; use PHPStan\Type\TypeWithClassName; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * Ref: https://github.com/symfony/symfony/blob/master/UPGRADE-4.0.md#validator * * @see \Rector\Symfony\Tests\Rector\ConstFetch\ConstraintUrlOptionRector\ConstraintUrlOptionRectorTest */ -final class ConstraintUrlOptionRector extends \Rector\Core\Rector\AbstractRector +final class ConstraintUrlOptionRector extends AbstractRector { /** * @var string */ private const URL_CONSTRAINT_CLASS = 'Symfony\\Component\\Validator\\Constraints\\Url'; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns true value to `Url::CHECK_DNS_TYPE_ANY` in Validator in Symfony.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$constraint = new Url(["checkDNS" => true]);', '$constraint = new Url(["checkDNS" => Url::CHECK_DNS_TYPE_ANY]);')]); + return new RuleDefinition('Turns true value to `Url::CHECK_DNS_TYPE_ANY` in Validator in Symfony.', [new CodeSample('$constraint = new Url(["checkDNS" => true]);', '$constraint = new Url(["checkDNS" => Url::CHECK_DNS_TYPE_ANY]);')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\ConstFetch::class]; + return [ConstFetch::class]; } /** * @param ConstFetch $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->valueResolver->isTrue($node)) { return null; @@ -45,8 +45,8 @@ final class ConstraintUrlOptionRector extends \Rector\Core\Rector\AbstractRector if (!$this->isInsideNewUrl($node)) { return null; } - $prevNode = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_NODE); - if (!$prevNode instanceof \PhpParser\Node\Scalar\String_) { + $prevNode = $node->getAttribute(AttributeKey::PREVIOUS_NODE); + if (!$prevNode instanceof String_) { return null; } if ($prevNode->value !== 'checkDNS') { @@ -54,14 +54,14 @@ final class ConstraintUrlOptionRector extends \Rector\Core\Rector\AbstractRector } return $this->nodeFactory->createClassConstFetch(self::URL_CONSTRAINT_CLASS, 'CHECK_DNS_TYPE_ANY'); } - private function isInsideNewUrl(\PhpParser\Node\Expr\ConstFetch $constFetch) : bool + private function isInsideNewUrl(ConstFetch $constFetch) : bool { - $new = $this->betterNodeFinder->findParentType($constFetch, \PhpParser\Node\Expr\New_::class); - if (!$new instanceof \PhpParser\Node\Expr\New_) { + $new = $this->betterNodeFinder->findParentType($constFetch, New_::class); + if (!$new instanceof New_) { return \false; } $newType = $this->getType($new); - if (!$newType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$newType instanceof TypeWithClassName) { return \false; } return $newType->getClassName() === self::URL_CONSTRAINT_CLASS; diff --git a/vendor/rector/rector-symfony/src/Rector/FuncCall/ReplaceServiceArgumentRector.php b/vendor/rector/rector-symfony/src/Rector/FuncCall/ReplaceServiceArgumentRector.php index 217cb7a7bde..3250ac14c3e 100644 --- a/vendor/rector/rector-symfony/src/Rector/FuncCall/ReplaceServiceArgumentRector.php +++ b/vendor/rector/rector-symfony/src/Rector/FuncCall/ReplaceServiceArgumentRector.php @@ -10,21 +10,21 @@ use PhpParser\Node\Scalar\String_; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\Symfony\ValueObject\ReplaceServiceArgument; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix20220607\Webmozart\Assert\Assert; /** * @see \Rector\Symfony\Tests\Rector\FuncCall\ReplaceServiceArgumentRector\ReplaceServiceArgumentRectorTest */ -final class ReplaceServiceArgumentRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface +final class ReplaceServiceArgumentRector extends AbstractRector implements ConfigurableRectorInterface { /** * @var ReplaceServiceArgument[] */ private $replaceServiceArguments = []; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace defined service() argument in Symfony PHP config', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace defined service() argument in Symfony PHP config', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' use function Symfony\Component\DependencyInjection\Loader\Configurator\service; return service(ContainerInterface::class); @@ -34,32 +34,32 @@ use function Symfony\Component\DependencyInjection\Loader\Configurator\service; return service('service_container'); CODE_SAMPLE -, [new \Rector\Symfony\ValueObject\ReplaceServiceArgument('ContainerInterface', new \PhpParser\Node\Scalar\String_('service_container'))])]); +, [new ReplaceServiceArgument('ContainerInterface', new String_('service_container'))])]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\FuncCall::class]; + return [FuncCall::class]; } /** * @param FuncCall $node */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { if (!$this->isName($node, 'Symfony\\Component\\DependencyInjection\\Loader\\Configurator\\service')) { return null; } $firstArg = $node->args[0]; - if (!$firstArg instanceof \PhpParser\Node\Arg) { + if (!$firstArg instanceof Arg) { return null; } foreach ($this->replaceServiceArguments as $replaceServiceArgument) { if (!$this->valueResolver->isValue($firstArg->value, $replaceServiceArgument->getOldValue())) { continue; } - $node->args[0] = new \PhpParser\Node\Arg($replaceServiceArgument->getNewValueExpr()); + $node->args[0] = new Arg($replaceServiceArgument->getNewValueExpr()); return $node; } return null; @@ -69,7 +69,7 @@ CODE_SAMPLE */ public function configure(array $configuration) : void { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($configuration, \Rector\Symfony\ValueObject\ReplaceServiceArgument::class); + Assert::allIsAOf($configuration, ReplaceServiceArgument::class); $this->replaceServiceArguments = $configuration; } } diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/AuthorizationCheckerIsGrantedExtractorRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/AuthorizationCheckerIsGrantedExtractorRector.php index 4f7d25f22ea..f4250723123 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/AuthorizationCheckerIsGrantedExtractorRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/AuthorizationCheckerIsGrantedExtractorRector.php @@ -12,26 +12,26 @@ use PhpParser\Node\Expr\MethodCall; use PHPStan\Type\ObjectType; use Rector\Core\NodeAnalyzer\ArgsAnalyzer; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/symfony/symfony/blob/4.4/UPGRADE-4.4.md#security * @see \Rector\Symfony\Tests\Rector\MethodCall\AuthorizationCheckerIsGrantedExtractorRector\AuthorizationCheckerIsGrantedExtractorRectorTest */ -final class AuthorizationCheckerIsGrantedExtractorRector extends \Rector\Core\Rector\AbstractRector +final class AuthorizationCheckerIsGrantedExtractorRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeAnalyzer\ArgsAnalyzer */ private $argsAnalyzer; - public function __construct(\Rector\Core\NodeAnalyzer\ArgsAnalyzer $argsAnalyzer) + public function __construct(ArgsAnalyzer $argsAnalyzer) { $this->argsAnalyzer = $argsAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Extract $this->authorizationChecker->isGranted([$a, $b]) to $this->authorizationChecker->isGranted($a) || $this->authorizationChecker->isGranted($b)', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Extract $this->authorizationChecker->isGranted([$a, $b]) to $this->authorizationChecker->isGranted($a) || $this->authorizationChecker->isGranted($b)', [new CodeSample(<<<'CODE_SAMPLE' if ($this->authorizationChecker->isGranted(['ROLE_USER', 'ROLE_ADMIN'])) { } CODE_SAMPLE @@ -46,19 +46,19 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node * @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\BinaryOp\BooleanOr|null */ - public function refactor(\PhpParser\Node $node) + public function refactor(Node $node) { $objectType = $this->nodeTypeResolver->getType($node->var); - if (!$objectType instanceof \PHPStan\Type\ObjectType) { + if (!$objectType instanceof ObjectType) { return null; } - $authorizationChecker = new \PHPStan\Type\ObjectType('Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface'); + $authorizationChecker = new ObjectType('Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface'); if (!$authorizationChecker->isSuperTypeOf($objectType)->yes()) { return null; } @@ -73,7 +73,7 @@ CODE_SAMPLE return null; } $value = $args[0]->value; - if (!$value instanceof \PhpParser\Node\Expr\Array_) { + if (!$value instanceof Array_) { return null; } return $this->processExtractIsGranted($node, $value, $args); @@ -82,11 +82,11 @@ CODE_SAMPLE * @param Arg[] $args * @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\BinaryOp\BooleanOr|null */ - private function processExtractIsGranted(\PhpParser\Node\Expr\MethodCall $methodCall, \PhpParser\Node\Expr\Array_ $array, array $args) + private function processExtractIsGranted(MethodCall $methodCall, Array_ $array, array $args) { $exprs = []; foreach ($array->items as $item) { - if ($item instanceof \PhpParser\Node\Expr\ArrayItem) { + if ($item instanceof ArrayItem) { $exprs[] = $item->value; } } @@ -99,17 +99,17 @@ CODE_SAMPLE return $methodCall; } $rightMethodCall = clone $methodCall; - $rightMethodCall->args[0] = new \PhpParser\Node\Arg($exprs[1]); - $newMethodCallRight = new \PhpParser\Node\Expr\MethodCall($methodCall->var, $methodCall->name, $rightMethodCall->args, $methodCall->getAttributes()); - $booleanOr = new \PhpParser\Node\Expr\BinaryOp\BooleanOr($methodCall, $newMethodCallRight); + $rightMethodCall->args[0] = new Arg($exprs[1]); + $newMethodCallRight = new MethodCall($methodCall->var, $methodCall->name, $rightMethodCall->args, $methodCall->getAttributes()); + $booleanOr = new BooleanOr($methodCall, $newMethodCallRight); foreach ($exprs as $key => $expr) { if ($key <= 1) { continue; } $rightMethodCall = clone $methodCall; - $rightMethodCall->args[0] = new \PhpParser\Node\Arg($expr); - $newMethodCallRight = new \PhpParser\Node\Expr\MethodCall($methodCall->var, $methodCall->name, $rightMethodCall->args, $methodCall->getAttributes()); - $booleanOr = new \PhpParser\Node\Expr\BinaryOp\BooleanOr($booleanOr, $newMethodCallRight); + $rightMethodCall->args[0] = new Arg($expr); + $newMethodCallRight = new MethodCall($methodCall->var, $methodCall->name, $rightMethodCall->args, $methodCall->getAttributes()); + $booleanOr = new BooleanOr($booleanOr, $newMethodCallRight); } return $booleanOr; } diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/CascadeValidationFormBuilderRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/CascadeValidationFormBuilderRector.php index 8ea2252c874..366cf725ee9 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/CascadeValidationFormBuilderRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/CascadeValidationFormBuilderRector.php @@ -15,28 +15,28 @@ use PhpParser\Node\Scalar\String_; use Rector\Core\NodeManipulator\ArrayManipulator; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\MethodCall\CascadeValidationFormBuilderRector\CascadeValidationFormBuilderRectorTest * * @changelog https://gist.github.com/mickaelandrieu/5d27a2ffafcbdd64912f549aaf2a6df9#stuck-with-forms * @changelog https://stackoverflow.com/questions/39758392/symfony-3-validation-groups-inside-child-entity-ignored */ -final class CascadeValidationFormBuilderRector extends \Rector\Core\Rector\AbstractRector +final class CascadeValidationFormBuilderRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeManipulator\ArrayManipulator */ private $arrayManipulator; - public function __construct(\Rector\Core\NodeManipulator\ArrayManipulator $arrayManipulator) + public function __construct(ArrayManipulator $arrayManipulator) { $this->arrayManipulator = $arrayManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change "cascade_validation" option to specific node attribute', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change "cascade_validation" option to specific node attribute', [new CodeSample(<<<'CODE_SAMPLE' class SomeController { public function someMethod() @@ -77,14 +77,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\ArrayItem::class]; + return [MethodCall::class, ArrayItem::class]; } /** * @param MethodCall|ArrayItem $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\ArrayItem) { + if ($node instanceof ArrayItem) { return $this->refactorArrayItem($node); } if ($this->shouldSkipMethodCall($node)) { @@ -98,7 +98,7 @@ CODE_SAMPLE $this->addConstraintsOptionToFollowingAddMethodCalls($node); return $node; } - private function shouldSkipMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + private function shouldSkipMethodCall(MethodCall $methodCall) : bool { if (!$this->isName($methodCall->name, 'createFormBuilder')) { return \true; @@ -107,12 +107,12 @@ CODE_SAMPLE return \true; } $secondArg = $methodCall->getArgs()[1]; - return !$secondArg->value instanceof \PhpParser\Node\Expr\Array_; + return !$secondArg->value instanceof Array_; } - private function isSuccessfulRemovalCascadeValidationOption(\PhpParser\Node\Expr\MethodCall $methodCall, \PhpParser\Node\Expr\Array_ $optionsArrayNode) : bool + private function isSuccessfulRemovalCascadeValidationOption(MethodCall $methodCall, Array_ $optionsArrayNode) : bool { foreach ($optionsArrayNode->items as $key => $arrayItem) { - if (!$arrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$arrayItem instanceof ArrayItem) { continue; } if (!$this->arrayManipulator->hasKeyName($arrayItem, 'cascade_validation')) { @@ -130,32 +130,32 @@ CODE_SAMPLE } return \false; } - private function addConstraintsOptionToFollowingAddMethodCalls(\PhpParser\Node\Expr\MethodCall $methodCall) : void + private function addConstraintsOptionToFollowingAddMethodCalls(MethodCall $methodCall) : void { $array = $this->createValidConstraintsArray(); - $constraintsArrayItem = new \PhpParser\Node\Expr\ArrayItem($array, new \PhpParser\Node\Scalar\String_('constraints')); - $parentNode = $methodCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); - while ($parentNode instanceof \PhpParser\Node\Expr\MethodCall) { + $constraintsArrayItem = new ArrayItem($array, new String_('constraints')); + $parentNode = $methodCall->getAttribute(AttributeKey::PARENT_NODE); + while ($parentNode instanceof MethodCall) { if ($this->isName($parentNode->name, 'add')) { /** @var Array_ $addOptionsArrayNode */ - $addOptionsArrayNode = isset($parentNode->getArgs()[2]) ? $parentNode->getArgs()[2]->value : new \PhpParser\Node\Expr\Array_(); + $addOptionsArrayNode = isset($parentNode->getArgs()[2]) ? $parentNode->getArgs()[2]->value : new Array_(); $addOptionsArrayNode->items[] = $constraintsArrayItem; - $parentNode->args[2] = new \PhpParser\Node\Arg($addOptionsArrayNode); + $parentNode->args[2] = new Arg($addOptionsArrayNode); } - $parentNode = $parentNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); + $parentNode = $parentNode->getAttribute(AttributeKey::PARENT_NODE); } } - private function createValidConstraintsArray() : \PhpParser\Node\Expr\Array_ + private function createValidConstraintsArray() : Array_ { - $new = new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name\FullyQualified('Symfony\\Component\\Validator\\Constraints\\Valid')); - return new \PhpParser\Node\Expr\Array_([new \PhpParser\Node\Expr\ArrayItem($new)]); + $new = new New_(new FullyQualified('Symfony\\Component\\Validator\\Constraints\\Valid')); + return new Array_([new ArrayItem($new)]); } /** * @return null|\PhpParser\Node\Expr\ArrayItem */ - private function refactorArrayItem(\PhpParser\Node\Expr\ArrayItem $arrayItem) + private function refactorArrayItem(ArrayItem $arrayItem) { - if (!$arrayItem->key instanceof \PhpParser\Node\Expr) { + if (!$arrayItem->key instanceof Expr) { return null; } if (!$this->valueResolver->isValue($arrayItem->key, 'cascade_validation')) { @@ -164,7 +164,7 @@ CODE_SAMPLE if (!$this->valueResolver->isValue($arrayItem->value, \true)) { return null; } - $arrayItem->key = new \PhpParser\Node\Scalar\String_('constraints'); + $arrayItem->key = new String_('constraints'); $arrayItem->value = $this->createValidConstraintsArray(); return $arrayItem; } diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector.php index 4c19e7594d7..5032903427b 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector.php @@ -11,14 +11,14 @@ use Rector\Core\Rector\AbstractRector; use Rector\Symfony\NodeAnalyzer\FormAddMethodCallAnalyzer; use Rector\Symfony\NodeAnalyzer\FormCollectionAnalyzer; use Rector\Symfony\NodeAnalyzer\FormOptionsArrayMatcher; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/symfony/symfony/blob/2.8/UPGRADE-2.8.md#form * * @see \Rector\Symfony\Tests\Rector\MethodCall\ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector\ChangeCollectionTypeOptionNameFromTypeToEntryTypeRectorTest */ -final class ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector extends \Rector\Core\Rector\AbstractRector +final class ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector extends AbstractRector { /** * @var array @@ -39,15 +39,15 @@ final class ChangeCollectionTypeOptionNameFromTypeToEntryTypeRector extends \Rec * @var \Rector\Symfony\NodeAnalyzer\FormCollectionAnalyzer */ private $formCollectionAnalyzer; - public function __construct(\Rector\Symfony\NodeAnalyzer\FormAddMethodCallAnalyzer $formAddMethodCallAnalyzer, \Rector\Symfony\NodeAnalyzer\FormOptionsArrayMatcher $formOptionsArrayMatcher, \Rector\Symfony\NodeAnalyzer\FormCollectionAnalyzer $formCollectionAnalyzer) + public function __construct(FormAddMethodCallAnalyzer $formAddMethodCallAnalyzer, FormOptionsArrayMatcher $formOptionsArrayMatcher, FormCollectionAnalyzer $formCollectionAnalyzer) { $this->formAddMethodCallAnalyzer = $formAddMethodCallAnalyzer; $this->formOptionsArrayMatcher = $formOptionsArrayMatcher; $this->formCollectionAnalyzer = $formCollectionAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Rename `type` option to `entry_type` in CollectionType', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Rename `type` option to `entry_type` in CollectionType', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\Extension\Core\Type\CollectionType; @@ -88,12 +88,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->formAddMethodCallAnalyzer->isMatching($node)) { return null; @@ -102,13 +102,13 @@ CODE_SAMPLE return null; } $optionsArray = $this->formOptionsArrayMatcher->match($node); - if (!$optionsArray instanceof \PhpParser\Node\Expr\Array_) { + if (!$optionsArray instanceof Array_) { return null; } $this->refactorOptionsArray($optionsArray); return $node; } - private function refactorOptionsArray(\PhpParser\Node\Expr\Array_ $optionsArray) : void + private function refactorOptionsArray(Array_ $optionsArray) : void { foreach ($optionsArray->items as $arrayItem) { if ($arrayItem === null) { @@ -121,7 +121,7 @@ CODE_SAMPLE if (!$this->valueResolver->isValue($arrayItem->key, $oldName)) { continue; } - $arrayItem->key = new \PhpParser\Node\Scalar\String_($newName); + $arrayItem->key = new String_($newName); } } } diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/ChangeStringCollectionOptionToConstantRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/ChangeStringCollectionOptionToConstantRector.php index 88c91910c58..e12068c66d3 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/ChangeStringCollectionOptionToConstantRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/ChangeStringCollectionOptionToConstantRector.php @@ -12,8 +12,8 @@ use Rector\Symfony\FormHelper\FormTypeStringToTypeProvider; use Rector\Symfony\NodeAnalyzer\FormAddMethodCallAnalyzer; use Rector\Symfony\NodeAnalyzer\FormCollectionAnalyzer; use Rector\Symfony\NodeAnalyzer\FormOptionsArrayMatcher; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://symfony.com/doc/2.8/form/form_collections.html * @see https://symfony.com/doc/3.0/form/form_collections.html @@ -21,7 +21,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @see \Rector\Symfony\Tests\Rector\MethodCall\ChangeStringCollectionOptionToConstantRector\ChangeStringCollectionOptionToConstantRectorTest */ -final class ChangeStringCollectionOptionToConstantRector extends \Rector\Core\Rector\AbstractRector +final class ChangeStringCollectionOptionToConstantRector extends AbstractRector { /** * @readonly @@ -43,16 +43,16 @@ final class ChangeStringCollectionOptionToConstantRector extends \Rector\Core\Re * @var \Rector\Symfony\NodeAnalyzer\FormCollectionAnalyzer */ private $formCollectionAnalyzer; - public function __construct(\Rector\Symfony\NodeAnalyzer\FormAddMethodCallAnalyzer $formAddMethodCallAnalyzer, \Rector\Symfony\NodeAnalyzer\FormOptionsArrayMatcher $formOptionsArrayMatcher, \Rector\Symfony\FormHelper\FormTypeStringToTypeProvider $formTypeStringToTypeProvider, \Rector\Symfony\NodeAnalyzer\FormCollectionAnalyzer $formCollectionAnalyzer) + public function __construct(FormAddMethodCallAnalyzer $formAddMethodCallAnalyzer, FormOptionsArrayMatcher $formOptionsArrayMatcher, FormTypeStringToTypeProvider $formTypeStringToTypeProvider, FormCollectionAnalyzer $formCollectionAnalyzer) { $this->formAddMethodCallAnalyzer = $formAddMethodCallAnalyzer; $this->formOptionsArrayMatcher = $formOptionsArrayMatcher; $this->formTypeStringToTypeProvider = $formTypeStringToTypeProvider; $this->formCollectionAnalyzer = $formCollectionAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change type in CollectionType from alias string to class reference', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change type in CollectionType from alias string to class reference', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\Extension\Core\Type\CollectionType; @@ -97,12 +97,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->formAddMethodCallAnalyzer->isMatching($node)) { return null; @@ -111,12 +111,12 @@ CODE_SAMPLE return null; } $optionsArray = $this->formOptionsArrayMatcher->match($node); - if (!$optionsArray instanceof \PhpParser\Node\Expr\Array_) { + if (!$optionsArray instanceof Array_) { return null; } return $this->processChangeToConstant($optionsArray, $node); } - private function processChangeToConstant(\PhpParser\Node\Expr\Array_ $optionsArray, \PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node + private function processChangeToConstant(Array_ $optionsArray, MethodCall $methodCall) : ?Node { foreach ($optionsArray->items as $optionsArrayItem) { if ($optionsArrayItem === null) { @@ -129,7 +129,7 @@ CODE_SAMPLE continue; } // already ::class reference - if (!$optionsArrayItem->value instanceof \PhpParser\Node\Scalar\String_) { + if (!$optionsArrayItem->value instanceof String_) { return null; } $stringValue = $optionsArrayItem->value->value; diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/ContainerBuilderCompileEnvArgumentRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/ContainerBuilderCompileEnvArgumentRector.php index a17668189be..a063e24655e 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/ContainerBuilderCompileEnvArgumentRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/ContainerBuilderCompileEnvArgumentRector.php @@ -7,16 +7,16 @@ use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\MethodCall\ContainerBuilderCompileEnvArgumentRector\ContainerBuilderCompileEnvArgumentRectorTest */ -final class ContainerBuilderCompileEnvArgumentRector extends \Rector\Core\Rector\AbstractRector +final class ContainerBuilderCompileEnvArgumentRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns old default value to parameter in ContainerBuilder->build() method in DI in Symfony', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns old default value to parameter in ContainerBuilder->build() method in DI in Symfony', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\DependencyInjection\ContainerBuilder; $containerBuilder = new ContainerBuilder(); @@ -35,14 +35,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Symfony\\Component\\DependencyInjection\\ContainerBuilder'))) { + if (!$this->isObjectType($node->var, new ObjectType('Symfony\\Component\\DependencyInjection\\ContainerBuilder'))) { return null; } if (!$this->isName($node->name, 'compile')) { diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/ContainerGetToConstructorInjectionRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/ContainerGetToConstructorInjectionRector.php index e8a91c90541..b13bb862a86 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/ContainerGetToConstructorInjectionRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/ContainerGetToConstructorInjectionRector.php @@ -9,14 +9,14 @@ use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\Symfony\NodeAnalyzer\DependencyInjectionMethodCallAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * Ref: https://github.com/symfony/symfony/blob/master/UPGRADE-4.0.md#console * * @see \Rector\Symfony\Tests\Rector\MethodCall\ContainerGetToConstructorInjectionRector\ContainerGetToConstructorInjectionRectorTest */ -final class ContainerGetToConstructorInjectionRector extends \Rector\Core\Rector\AbstractRector +final class ContainerGetToConstructorInjectionRector extends AbstractRector { /** * @readonly @@ -28,14 +28,14 @@ final class ContainerGetToConstructorInjectionRector extends \Rector\Core\Rector * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\Symfony\NodeAnalyzer\DependencyInjectionMethodCallAnalyzer $dependencyInjectionMethodCallAnalyzer, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(DependencyInjectionMethodCallAnalyzer $dependencyInjectionMethodCallAnalyzer, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->dependencyInjectionMethodCallAnalyzer = $dependencyInjectionMethodCallAnalyzer; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns fetching of dependencies via `$container->get()` in ContainerAware to constructor injection in Command and Controller in Symfony', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns fetching of dependencies via `$container->get()` in ContainerAware to constructor injection in Command and Controller in Symfony', [new CodeSample(<<<'CODE_SAMPLE' final class SomeCommand extends ContainerAwareCommand { public function someMethod() @@ -69,14 +69,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Symfony\\Component\\DependencyInjection\\ContainerInterface'))) { + if (!$this->isObjectType($node->var, new ObjectType('Symfony\\Component\\DependencyInjection\\ContainerInterface'))) { return null; } if (!$this->isName($node->name, 'get')) { diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/DefinitionAliasSetPrivateToSetPublicRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/DefinitionAliasSetPrivateToSetPublicRector.php index 4b83e6ef282..525e0261c78 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/DefinitionAliasSetPrivateToSetPublicRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/DefinitionAliasSetPrivateToSetPublicRector.php @@ -9,13 +9,13 @@ use PhpParser\Node\Expr\ConstFetch; use PhpParser\Node\Expr\MethodCall; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#dependencyinjection * @see \Rector\Symfony\Tests\Rector\MethodCall\DefinitionAliasSetPrivateToSetPublicRector\DefinitionAliasSetPrivateToSetPublicRectorTest */ -final class DefinitionAliasSetPrivateToSetPublicRector extends \Rector\Core\Rector\AbstractRector +final class DefinitionAliasSetPrivateToSetPublicRector extends AbstractRector { /** * @var ObjectType[] @@ -23,11 +23,11 @@ final class DefinitionAliasSetPrivateToSetPublicRector extends \Rector\Core\Rect private $definitionObjectTypes = []; public function __construct() { - $this->definitionObjectTypes = [new \PHPStan\Type\ObjectType('Symfony\\Component\\DependencyInjection\\Alias'), new \PHPStan\Type\ObjectType('Symfony\\Component\\DependencyInjection\\Definition')]; + $this->definitionObjectTypes = [new ObjectType('Symfony\\Component\\DependencyInjection\\Alias'), new ObjectType('Symfony\\Component\\DependencyInjection\\Definition')]; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Migrates from deprecated Definition/Alias->setPrivate() to Definition/Alias->setPublic()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Migrates from deprecated Definition/Alias->setPrivate() to Definition/Alias->setPublic()', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Definition; @@ -66,12 +66,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->nodeTypeResolver->isObjectTypes($node->var, $this->definitionObjectTypes)) { return null; @@ -80,10 +80,10 @@ CODE_SAMPLE return null; } $argValue = $node->getArgs()[0]->value; - $argValue = $argValue instanceof \PhpParser\Node\Expr\ConstFetch ? $this->createNegationConsFetch($argValue) : new \PhpParser\Node\Expr\BooleanNot($argValue); + $argValue = $argValue instanceof ConstFetch ? $this->createNegationConsFetch($argValue) : new BooleanNot($argValue); return $this->nodeFactory->createMethodCall($node->var, 'setPublic', [$argValue]); } - private function createNegationConsFetch(\PhpParser\Node\Expr\ConstFetch $constFetch) : \PhpParser\Node\Expr\ConstFetch + private function createNegationConsFetch(ConstFetch $constFetch) : ConstFetch { if ($this->valueResolver->isFalse($constFetch)) { return $this->nodeFactory->createTrue(); diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/FormBuilderSetDataMapperRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/FormBuilderSetDataMapperRector.php index c0c490d43ea..52ca7c0aac4 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/FormBuilderSetDataMapperRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/FormBuilderSetDataMapperRector.php @@ -10,13 +10,13 @@ use PhpParser\Node\Expr\New_; use PhpParser\Node\Name\FullyQualified; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#form * @see \Rector\Symfony\Tests\Rector\MethodCall\FormBuilderSetDataMapperRector\FormBuilderSetDataMapperRectorTest */ -final class FormBuilderSetDataMapperRector extends \Rector\Core\Rector\AbstractRector +final class FormBuilderSetDataMapperRector extends AbstractRector { /** * @readonly @@ -25,11 +25,11 @@ final class FormBuilderSetDataMapperRector extends \Rector\Core\Rector\AbstractR private $dataMapperObjectType; public function __construct() { - $this->dataMapperObjectType = new \PHPStan\Type\ObjectType('Symfony\\Component\\Form\\Extension\\Core\\DataMapper\\DataMapper'); + $this->dataMapperObjectType = new ObjectType('Symfony\\Component\\Form\\Extension\\Core\\DataMapper\\DataMapper'); } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Migrates from deprecated Form Builder->setDataMapper(new PropertyPathMapper()) to Builder->setDataMapper(new DataMapper(new PropertyPathAccessor()))', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Migrates from deprecated Form Builder->setDataMapper(new PropertyPathMapper()) to Builder->setDataMapper(new DataMapper(new PropertyPathAccessor()))', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper; use Symfony\Component\Form\FormConfigBuilderInterface; @@ -62,14 +62,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Symfony\\Component\\Form\\FormConfigBuilderInterface'))) { + if (!$this->isObjectType($node->var, new ObjectType('Symfony\\Component\\Form\\FormConfigBuilderInterface'))) { return null; } if (!$this->isName($node->name, 'setDataMapper')) { @@ -79,8 +79,8 @@ CODE_SAMPLE if ($this->isObjectType($argumentValue, $this->dataMapperObjectType)) { return null; } - $propertyPathAccessor = new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name\FullyQualified('Symfony\\Component\\Form\\Extension\\Core\\DataAccessor\\PropertyPathAccessor')); - $newArgumentValue = new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name\FullyQualified($this->dataMapperObjectType->getClassName()), [new \PhpParser\Node\Arg($propertyPathAccessor)]); + $propertyPathAccessor = new New_(new FullyQualified('Symfony\\Component\\Form\\Extension\\Core\\DataAccessor\\PropertyPathAccessor')); + $newArgumentValue = new New_(new FullyQualified($this->dataMapperObjectType->getClassName()), [new Arg($propertyPathAccessor)]); $node->getArgs()[0]->value = $newArgumentValue; return $node; } diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/FormIsValidRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/FormIsValidRector.php index aad4bd96146..d6cb7299212 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/FormIsValidRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/FormIsValidRector.php @@ -11,25 +11,25 @@ use PHPStan\Type\ObjectType; use Rector\Core\NodeManipulator\MethodCallManipulator; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\MethodCall\FormIsValidRector\FormIsValidRectorTest */ -final class FormIsValidRector extends \Rector\Core\Rector\AbstractRector +final class FormIsValidRector extends AbstractRector { /** * @readonly * @var \Rector\Core\NodeManipulator\MethodCallManipulator */ private $methodCallManipulator; - public function __construct(\Rector\Core\NodeManipulator\MethodCallManipulator $methodCallManipulator) + public function __construct(MethodCallManipulator $methodCallManipulator) { $this->methodCallManipulator = $methodCallManipulator; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Adds `$form->isSubmitted()` validation to all `$form->isValid()` calls in Form in Symfony', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Adds `$form->isSubmitted()` validation to all `$form->isValid()` calls in Form in Symfony', [new CodeSample(<<<'CODE_SAMPLE' if ($form->isValid()) { } CODE_SAMPLE @@ -44,12 +44,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkipMethodCall($node)) { return null; @@ -61,29 +61,29 @@ CODE_SAMPLE } /** @var string $variableName */ $variableName = $this->getName($node->var); - return new \PhpParser\Node\Expr\BinaryOp\BooleanAnd($this->nodeFactory->createMethodCall($variableName, 'isSubmitted'), $this->nodeFactory->createMethodCall($variableName, 'isValid')); + return new BooleanAnd($this->nodeFactory->createMethodCall($variableName, 'isSubmitted'), $this->nodeFactory->createMethodCall($variableName, 'isValid')); } - private function shouldSkipMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + private function shouldSkipMethodCall(MethodCall $methodCall) : bool { - $originalNode = $methodCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE); + $originalNode = $methodCall->getAttribute(AttributeKey::ORIGINAL_NODE); // skip just added calls - if (!$originalNode instanceof \PhpParser\Node) { + if (!$originalNode instanceof Node) { return \true; } - if (!$this->isObjectType($methodCall->var, new \PHPStan\Type\ObjectType('Symfony\\Component\\Form\\Form'))) { + if (!$this->isObjectType($methodCall->var, new ObjectType('Symfony\\Component\\Form\\Form'))) { return \true; } if (!$this->isName($methodCall->name, 'isValid')) { return \true; } - $previousNode = $methodCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_NODE); + $previousNode = $methodCall->getAttribute(AttributeKey::PREVIOUS_NODE); if ($previousNode !== null) { return \true; } $variableName = $this->getName($methodCall->var); return $variableName === null; } - private function isIsSubmittedByAlreadyCalledOnVariable(\PhpParser\Node\Expr\Variable $variable) : bool + private function isIsSubmittedByAlreadyCalledOnVariable(Variable $variable) : bool { $previousMethodCallNamesOnVariable = $this->methodCallManipulator->findMethodCallNamesOnVariable($variable); // already checked by isSubmitted() diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/FormTypeInstanceToClassConstRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/FormTypeInstanceToClassConstRector.php index 2c18f1d87a1..8e387327a75 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/FormTypeInstanceToClassConstRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/FormTypeInstanceToClassConstRector.php @@ -15,8 +15,8 @@ use Rector\Symfony\NodeAnalyzer\FormCollectionAnalyzer; use Rector\Symfony\NodeAnalyzer\FormInstanceToFormClassConstFetchConverter; use Rector\Symfony\NodeAnalyzer\FormOptionsArrayMatcher; use Rector\Symfony\TypeAnalyzer\ControllerAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * Best resource with clear example: * @@ -28,7 +28,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @see \Rector\Symfony\Tests\Rector\MethodCall\FormTypeInstanceToClassConstRector\FormTypeInstanceToClassConstRectorTest */ -final class FormTypeInstanceToClassConstRector extends \Rector\Core\Rector\AbstractRector +final class FormTypeInstanceToClassConstRector extends AbstractRector { /** * @readonly @@ -55,7 +55,7 @@ final class FormTypeInstanceToClassConstRector extends \Rector\Core\Rector\Abstr * @var \Rector\Symfony\TypeAnalyzer\ControllerAnalyzer */ private $controllerAnalyzer; - public function __construct(\Rector\Symfony\NodeAnalyzer\FormInstanceToFormClassConstFetchConverter $formInstanceToFormClassConstFetchConverter, \Rector\Symfony\NodeAnalyzer\FormAddMethodCallAnalyzer $formAddMethodCallAnalyzer, \Rector\Symfony\NodeAnalyzer\FormOptionsArrayMatcher $formOptionsArrayMatcher, \Rector\Symfony\NodeAnalyzer\FormCollectionAnalyzer $formCollectionAnalyzer, \Rector\Symfony\TypeAnalyzer\ControllerAnalyzer $controllerAnalyzer) + public function __construct(FormInstanceToFormClassConstFetchConverter $formInstanceToFormClassConstFetchConverter, FormAddMethodCallAnalyzer $formAddMethodCallAnalyzer, FormOptionsArrayMatcher $formOptionsArrayMatcher, FormCollectionAnalyzer $formCollectionAnalyzer, ControllerAnalyzer $controllerAnalyzer) { $this->formInstanceToFormClassConstFetchConverter = $formInstanceToFormClassConstFetchConverter; $this->formAddMethodCallAnalyzer = $formAddMethodCallAnalyzer; @@ -63,9 +63,9 @@ final class FormTypeInstanceToClassConstRector extends \Rector\Core\Rector\Abstr $this->formCollectionAnalyzer = $formCollectionAnalyzer; $this->controllerAnalyzer = $controllerAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes createForm(new FormType), add(new FormType) to ones with "FormType::class"', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes createForm(new FormType), add(new FormType) to ones with "FormType::class"', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Bundle\FrameworkBundle\Controller\Controller; final class SomeController extends Controller @@ -94,12 +94,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->controllerAnalyzer->isController($node->var) && $this->isName($node->name, 'createForm')) { return $this->formInstanceToFormClassConstFetchConverter->processNewInstance($node, 0, 2); @@ -113,10 +113,10 @@ CODE_SAMPLE } return $this->formInstanceToFormClassConstFetchConverter->processNewInstance($node, 1, 2); } - private function refactorCollectionOptions(\PhpParser\Node\Expr\MethodCall $methodCall) : void + private function refactorCollectionOptions(MethodCall $methodCall) : void { $optionsArray = $this->formOptionsArrayMatcher->match($methodCall); - if (!$optionsArray instanceof \PhpParser\Node\Expr\Array_) { + if (!$optionsArray instanceof Array_) { return; } foreach ($optionsArray->items as $arrayItem) { @@ -129,11 +129,11 @@ CODE_SAMPLE if (!$this->valueResolver->isValues($arrayItem->key, ['entry', 'entry_type'])) { continue; } - if (!$arrayItem->value instanceof \PhpParser\Node\Expr\New_) { + if (!$arrayItem->value instanceof New_) { continue; } $newClass = $arrayItem->value->class; - if (!$newClass instanceof \PhpParser\Node\Name) { + if (!$newClass instanceof Name) { continue; } $arrayItem->value = $this->nodeFactory->createClassConstReference($newClass->toString()); diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/GetHelperControllerToServiceRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/GetHelperControllerToServiceRector.php index 304ad99a7bb..b6f28ff4daa 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/GetHelperControllerToServiceRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/GetHelperControllerToServiceRector.php @@ -15,15 +15,15 @@ use Rector\Naming\Naming\PropertyNaming; use Rector\PostRector\Collector\PropertyToAddCollector; use Rector\PostRector\ValueObject\PropertyMetadata; use Rector\Symfony\TypeAnalyzer\ControllerAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://github.com/symfony/symfony/pull/42422 * @changelog https://github.com/symfony/symfony/pull/1195 * * @see \Rector\Symfony\Tests\Rector\MethodCall\GetHelperControllerToServiceRector\GetHelperControllerToServiceRectorTest */ -final class GetHelperControllerToServiceRector extends \Rector\Core\Rector\AbstractRector +final class GetHelperControllerToServiceRector extends AbstractRector { /** * @readonly @@ -40,15 +40,15 @@ final class GetHelperControllerToServiceRector extends \Rector\Core\Rector\Abstr * @var \Rector\Naming\Naming\PropertyNaming */ private $propertyNaming; - public function __construct(\Rector\Symfony\TypeAnalyzer\ControllerAnalyzer $controllerAnalyzer, \Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector, \Rector\Naming\Naming\PropertyNaming $propertyNaming) + public function __construct(ControllerAnalyzer $controllerAnalyzer, PropertyToAddCollector $propertyToAddCollector, PropertyNaming $propertyNaming) { $this->controllerAnalyzer = $controllerAnalyzer; $this->propertyToAddCollector = $propertyToAddCollector; $this->propertyNaming = $propertyNaming; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace $this->getDoctrine() and $this->dispatchMessage() calls in AbstractController with direct service use', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace $this->getDoctrine() and $this->dispatchMessage() calls in AbstractController with direct service use', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; final class SomeController extends AbstractController @@ -83,18 +83,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->controllerAnalyzer->isController($node->var)) { return null; } - $class = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$class instanceof Class_) { return null; } if ($this->isName($node->name, 'getDoctrine')) { @@ -108,26 +108,26 @@ CODE_SAMPLE /** * @return \PhpParser\Node|\PhpParser\Node\Expr\MethodCall */ - private function refactorDispatchMessage(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\Expr\MethodCall $methodCall) + private function refactorDispatchMessage(Class_ $class, MethodCall $methodCall) { $propertyName = $this->propertyNaming->fqnToVariableName('Symfony\\Component\\Messenger\\MessageBusInterface'); // add dependency - $propertyObjectType = new \PHPStan\Type\ObjectType('Symfony\\Component\\Messenger\\MessageBusInterface'); - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($propertyName, $propertyObjectType, \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $propertyObjectType = new ObjectType('Symfony\\Component\\Messenger\\MessageBusInterface'); + $propertyMetadata = new PropertyMetadata($propertyName, $propertyObjectType, Class_::MODIFIER_PRIVATE); $this->propertyToAddCollector->addPropertyToClass($class, $propertyMetadata); - $thisVariable = new \PhpParser\Node\Expr\Variable('this'); - $methodCall->var = new \PhpParser\Node\Expr\PropertyFetch($thisVariable, $propertyName); - $methodCall->name = new \PhpParser\Node\Identifier('dispatch'); + $thisVariable = new Variable('this'); + $methodCall->var = new PropertyFetch($thisVariable, $propertyName); + $methodCall->name = new Identifier('dispatch'); return $methodCall; } - private function refactorGetDoctrine(\PhpParser\Node\Stmt\Class_ $class) : \PhpParser\Node\Expr\PropertyFetch + private function refactorGetDoctrine(Class_ $class) : PropertyFetch { $propertyName = $this->propertyNaming->fqnToVariableName('Doctrine\\Persistence\\ManagerRegistry'); // add dependency - $propertyObjectType = new \PHPStan\Type\ObjectType('Doctrine\\Persistence\\ManagerRegistry'); - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($propertyName, $propertyObjectType, \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $propertyObjectType = new ObjectType('Doctrine\\Persistence\\ManagerRegistry'); + $propertyMetadata = new PropertyMetadata($propertyName, $propertyObjectType, Class_::MODIFIER_PRIVATE); $this->propertyToAddCollector->addPropertyToClass($class, $propertyMetadata); - $thisVariable = new \PhpParser\Node\Expr\Variable('this'); - return new \PhpParser\Node\Expr\PropertyFetch($thisVariable, $propertyName); + $thisVariable = new Variable('this'); + return new PropertyFetch($thisVariable, $propertyName); } } diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/GetParameterToConstructorInjectionRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/GetParameterToConstructorInjectionRector.php index 12763786709..a6edc41812a 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/GetParameterToConstructorInjectionRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/GetParameterToConstructorInjectionRector.php @@ -15,12 +15,12 @@ use Rector\Naming\Naming\PropertyNaming; use Rector\PostRector\Collector\PropertyToAddCollector; use Rector\PostRector\ValueObject\PropertyMetadata; use Rector\Symfony\TypeAnalyzer\ControllerAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\MethodCall\GetParameterToConstructorInjectionRector\GetParameterToConstructorInjectionRectorTest */ -final class GetParameterToConstructorInjectionRector extends \Rector\Core\Rector\AbstractRector +final class GetParameterToConstructorInjectionRector extends AbstractRector { /** * @readonly @@ -37,15 +37,15 @@ final class GetParameterToConstructorInjectionRector extends \Rector\Core\Rector * @var \Rector\Symfony\TypeAnalyzer\ControllerAnalyzer */ private $controllerAnalyzer; - public function __construct(\Rector\Naming\Naming\PropertyNaming $propertyNaming, \Rector\PostRector\Collector\PropertyToAddCollector $propertyToAddCollector, \Rector\Symfony\TypeAnalyzer\ControllerAnalyzer $controllerAnalyzer) + public function __construct(PropertyNaming $propertyNaming, PropertyToAddCollector $propertyToAddCollector, ControllerAnalyzer $controllerAnalyzer) { $this->propertyNaming = $propertyNaming; $this->propertyToAddCollector = $propertyToAddCollector; $this->controllerAnalyzer = $controllerAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns fetching of parameters via `getParameter()` in ContainerAware to constructor injection in Command and Controller in Symfony', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns fetching of parameters via `getParameter()` in ContainerAware to constructor injection in Command and Controller in Symfony', [new CodeSample(<<<'CODE_SAMPLE' class MyCommand extends ContainerAwareCommand { public function someMethod() @@ -77,12 +77,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->controllerAnalyzer->isController($node->var)) { return null; @@ -91,21 +91,21 @@ CODE_SAMPLE return null; } $firstArg = $node->args[0]; - if (!$firstArg instanceof \PhpParser\Node\Arg) { + if (!$firstArg instanceof Arg) { return null; } $stringArgument = $firstArg->value; - if (!$stringArgument instanceof \PhpParser\Node\Scalar\String_) { + if (!$stringArgument instanceof String_) { return null; } $parameterName = $stringArgument->value; - $parameterName = \RectorPrefix20220607\Nette\Utils\Strings::replace($parameterName, '#\\.#', '_'); + $parameterName = Strings::replace($parameterName, '#\\.#', '_'); $propertyName = $this->propertyNaming->underscoreToName($parameterName); - $class = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($node, Class_::class); + if (!$class instanceof Class_) { return null; } - $propertyMetadata = new \Rector\PostRector\ValueObject\PropertyMetadata($propertyName, new \PHPStan\Type\StringType(), \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE); + $propertyMetadata = new PropertyMetadata($propertyName, new StringType(), Class_::MODIFIER_PRIVATE); $this->propertyToAddCollector->addPropertyToClass($class, $propertyMetadata); return $this->nodeFactory->createPropertyFetch('this', $propertyName); } diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/GetToConstructorInjectionRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/GetToConstructorInjectionRector.php index 048a6077578..1dd8df22807 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/GetToConstructorInjectionRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/GetToConstructorInjectionRector.php @@ -8,12 +8,12 @@ use PhpParser\Node\Expr\MethodCall; use Rector\Core\Rector\AbstractRector; use Rector\Symfony\NodeAnalyzer\DependencyInjectionMethodCallAnalyzer; use Rector\Symfony\TypeAnalyzer\ContainerAwareAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\MethodCall\GetToConstructorInjectionRector\GetToConstructorInjectionRectorTest */ -final class GetToConstructorInjectionRector extends \Rector\Core\Rector\AbstractRector +final class GetToConstructorInjectionRector extends AbstractRector { /** * @readonly @@ -25,14 +25,14 @@ final class GetToConstructorInjectionRector extends \Rector\Core\Rector\Abstract * @var \Rector\Symfony\TypeAnalyzer\ContainerAwareAnalyzer */ private $containerAwareAnalyzer; - public function __construct(\Rector\Symfony\NodeAnalyzer\DependencyInjectionMethodCallAnalyzer $dependencyInjectionMethodCallAnalyzer, \Rector\Symfony\TypeAnalyzer\ContainerAwareAnalyzer $containerAwareAnalyzer) + public function __construct(DependencyInjectionMethodCallAnalyzer $dependencyInjectionMethodCallAnalyzer, ContainerAwareAnalyzer $containerAwareAnalyzer) { $this->dependencyInjectionMethodCallAnalyzer = $dependencyInjectionMethodCallAnalyzer; $this->containerAwareAnalyzer = $containerAwareAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns fetching of dependencies via `$this->get()` to constructor injection in Command and Controller', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns fetching of dependencies via `$this->get()` to constructor injection in Command and Controller', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Bundle\FrameworkBundle\Controller\Controller; final class SomeController extend Controller @@ -67,12 +67,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->containerAwareAnalyzer->isGetMethodAwareType($node->var)) { return null; diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/LiteralGetToRequestClassConstantRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/LiteralGetToRequestClassConstantRector.php index 4a29f936b78..7d2da28a0c4 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/LiteralGetToRequestClassConstantRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/LiteralGetToRequestClassConstantRector.php @@ -11,12 +11,12 @@ use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\Symfony\NodeAnalyzer\LiteralCallLikeConstFetchReplacer; use Rector\Symfony\ValueObject\ConstantMap\SymfonyRequestConstantMap; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\MethodCall\LiteralGetToRequestClassConstantRector\LiteralGetToRequestClassConstantRectorTest */ -final class LiteralGetToRequestClassConstantRector extends \Rector\Core\Rector\AbstractRector +final class LiteralGetToRequestClassConstantRector extends AbstractRector { /** * @readonly @@ -28,14 +28,14 @@ final class LiteralGetToRequestClassConstantRector extends \Rector\Core\Rector\A * @var \PHPStan\Reflection\ReflectionProvider */ private $reflectionProvider; - public function __construct(\Rector\Symfony\NodeAnalyzer\LiteralCallLikeConstFetchReplacer $literalCallLikeConstFetchReplacer, \PHPStan\Reflection\ReflectionProvider $reflectionProvider) + public function __construct(LiteralCallLikeConstFetchReplacer $literalCallLikeConstFetchReplacer, ReflectionProvider $reflectionProvider) { $this->literalCallLikeConstFetchReplacer = $literalCallLikeConstFetchReplacer; $this->reflectionProvider = $reflectionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace "GET" string by Symfony Request object class constants', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replace "GET" string by Symfony Request object class constants', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Form\FormBuilderInterface; final class SomeClass @@ -64,50 +64,50 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if ($node instanceof \PhpParser\Node\Expr\StaticCall) { + if ($node instanceof StaticCall) { return $this->refactorStaticCall($node); } // for client, the transitional dependency to browser-kit might be missing and cause fatal error on PHPStan reflection // in most cases that should be skipped, @see https://github.com/rectorphp/rector/issues/7135 - if ($this->reflectionProvider->hasClass('Symfony\\Component\\BrowserKit\\AbstractBrowser') && $this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Symfony\\Component\\HttpKernel\\Client'))) { + if ($this->reflectionProvider->hasClass('Symfony\\Component\\BrowserKit\\AbstractBrowser') && $this->isObjectType($node->var, new ObjectType('Symfony\\Component\\HttpKernel\\Client'))) { return $this->refactorClientMethodCall($node); } - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Symfony\\Component\\Form\\FormBuilderInterface'))) { + if (!$this->isObjectType($node->var, new ObjectType('Symfony\\Component\\Form\\FormBuilderInterface'))) { return null; } if (!$this->isName($node->name, 'setMethod')) { return null; } - return $this->literalCallLikeConstFetchReplacer->replaceArgOnPosition($node, 0, 'Symfony\\Component\\HttpFoundation\\Request', \Rector\Symfony\ValueObject\ConstantMap\SymfonyRequestConstantMap::METHOD_TO_CONST); + return $this->literalCallLikeConstFetchReplacer->replaceArgOnPosition($node, 0, 'Symfony\\Component\\HttpFoundation\\Request', SymfonyRequestConstantMap::METHOD_TO_CONST); } /** * @return \PhpParser\Node\Expr\StaticCall|null */ - private function refactorStaticCall(\PhpParser\Node\Expr\StaticCall $staticCall) + private function refactorStaticCall(StaticCall $staticCall) { - if (!$this->isObjectType($staticCall->class, new \PHPStan\Type\ObjectType('Symfony\\Component\\HttpFoundation\\Request'))) { + if (!$this->isObjectType($staticCall->class, new ObjectType('Symfony\\Component\\HttpFoundation\\Request'))) { return null; } if (!$this->isName($staticCall->name, 'create')) { return null; } - return $this->literalCallLikeConstFetchReplacer->replaceArgOnPosition($staticCall, 1, 'Symfony\\Component\\HttpFoundation\\Request', \Rector\Symfony\ValueObject\ConstantMap\SymfonyRequestConstantMap::METHOD_TO_CONST); + return $this->literalCallLikeConstFetchReplacer->replaceArgOnPosition($staticCall, 1, 'Symfony\\Component\\HttpFoundation\\Request', SymfonyRequestConstantMap::METHOD_TO_CONST); } /** * @return \PhpParser\Node\Expr\MethodCall|null */ - private function refactorClientMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) + private function refactorClientMethodCall(MethodCall $methodCall) { if (!$this->isName($methodCall->name, 'request')) { return null; } - return $this->literalCallLikeConstFetchReplacer->replaceArgOnPosition($methodCall, 0, 'Symfony\\Component\\HttpFoundation\\Request', \Rector\Symfony\ValueObject\ConstantMap\SymfonyRequestConstantMap::METHOD_TO_CONST); + return $this->literalCallLikeConstFetchReplacer->replaceArgOnPosition($methodCall, 0, 'Symfony\\Component\\HttpFoundation\\Request', SymfonyRequestConstantMap::METHOD_TO_CONST); } } diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/MakeDispatchFirstArgumentEventRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/MakeDispatchFirstArgumentEventRector.php index 10b7c55ed76..77e723d59e2 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/MakeDispatchFirstArgumentEventRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/MakeDispatchFirstArgumentEventRector.php @@ -12,27 +12,27 @@ use PhpParser\Node\Expr\MethodCall; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\TypeAnalyzer\StringTypeAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://symfony.com/blog/new-in-symfony-4-3-simpler-event-dispatching * * @see \Rector\Symfony\Tests\Rector\MethodCall\MakeDispatchFirstArgumentEventRector\MakeDispatchFirstArgumentEventRectorTest */ -final class MakeDispatchFirstArgumentEventRector extends \Rector\Core\Rector\AbstractRector +final class MakeDispatchFirstArgumentEventRector extends AbstractRector { /** * @readonly * @var \Rector\NodeTypeResolver\TypeAnalyzer\StringTypeAnalyzer */ private $stringTypeAnalyzer; - public function __construct(\Rector\NodeTypeResolver\TypeAnalyzer\StringTypeAnalyzer $stringTypeAnalyzer) + public function __construct(StringTypeAnalyzer $stringTypeAnalyzer) { $this->stringTypeAnalyzer = $stringTypeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Make event object a first argument of dispatch() method, event name as second', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Make event object a first argument of dispatch() method, event name as second', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; class SomeClass @@ -61,18 +61,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } $firstArg = $node->args[0]; - if (!$firstArg instanceof \PhpParser\Node\Arg) { + if (!$firstArg instanceof Arg) { return null; } $firstArgumentValue = $firstArg->value; @@ -81,19 +81,19 @@ CODE_SAMPLE return $node; } $secondArg = $node->args[1]; - if (!$secondArg instanceof \PhpParser\Node\Arg) { + if (!$secondArg instanceof Arg) { return null; } $secondArgumentValue = $secondArg->value; - if ($secondArgumentValue instanceof \PhpParser\Node\Expr\FuncCall) { + if ($secondArgumentValue instanceof FuncCall) { $this->refactorGetCallFuncCall($node, $secondArgumentValue, $firstArgumentValue); return $node; } return null; } - private function shouldSkip(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + private function shouldSkip(MethodCall $methodCall) : bool { - if (!$this->isObjectType($methodCall->var, new \PHPStan\Type\ObjectType('Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface'))) { + if (!$this->isObjectType($methodCall->var, new ObjectType('Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface'))) { return \true; } if (!$this->isName($methodCall->name, 'dispatch')) { @@ -101,7 +101,7 @@ CODE_SAMPLE } return !isset($methodCall->args[1]); } - private function refactorStringArgument(\PhpParser\Node\Expr\MethodCall $methodCall) : void + private function refactorStringArgument(MethodCall $methodCall) : void { // swap arguments [$methodCall->args[0], $methodCall->args[1]] = [$methodCall->args[1], $methodCall->args[0]]; @@ -109,13 +109,13 @@ CODE_SAMPLE unset($methodCall->args[1]); } } - private function refactorGetCallFuncCall(\PhpParser\Node\Expr\MethodCall $methodCall, \PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr $expr) : void + private function refactorGetCallFuncCall(MethodCall $methodCall, FuncCall $funcCall, Expr $expr) : void { if (!$this->isName($funcCall, 'get_class')) { return; } $firstArg = $funcCall->args[0]; - if (!$firstArg instanceof \PhpParser\Node\Arg) { + if (!$firstArg instanceof Arg) { return; } $getClassArgumentValue = $firstArg->value; @@ -127,22 +127,22 @@ CODE_SAMPLE /** * Is the event name just `::class`? We can remove it */ - private function isEventNameSameAsEventObjectClass(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + private function isEventNameSameAsEventObjectClass(MethodCall $methodCall) : bool { $secondArg = $methodCall->args[1]; - if (!$secondArg instanceof \PhpParser\Node\Arg) { + if (!$secondArg instanceof Arg) { return \false; } - if (!$secondArg->value instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if (!$secondArg->value instanceof ClassConstFetch) { return \false; } $classConst = $this->valueResolver->getValue($secondArg->value); $firstArg = $methodCall->args[0]; - if (!$firstArg instanceof \PhpParser\Node\Arg) { + if (!$firstArg instanceof Arg) { return \false; } $eventStaticType = $this->getType($firstArg->value); - if (!$eventStaticType instanceof \PHPStan\Type\ObjectType) { + if (!$eventStaticType instanceof ObjectType) { return \false; } return $classConst === $eventStaticType->getClassName(); diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/OptionNameRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/OptionNameRector.php index f2d5d071c63..498d6c6a5c2 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/OptionNameRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/OptionNameRector.php @@ -10,12 +10,12 @@ use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; use Rector\Symfony\NodeAnalyzer\FormAddMethodCallAnalyzer; use Rector\Symfony\NodeAnalyzer\FormOptionsArrayMatcher; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\MethodCall\OptionNameRector\OptionNameRectorTest */ -final class OptionNameRector extends \Rector\Core\Rector\AbstractRector +final class OptionNameRector extends AbstractRector { /** * @var array @@ -31,14 +31,14 @@ final class OptionNameRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Symfony\NodeAnalyzer\FormOptionsArrayMatcher */ private $formOptionsArrayMatcher; - public function __construct(\Rector\Symfony\NodeAnalyzer\FormAddMethodCallAnalyzer $formAddMethodCallAnalyzer, \Rector\Symfony\NodeAnalyzer\FormOptionsArrayMatcher $formOptionsArrayMatcher) + public function __construct(FormAddMethodCallAnalyzer $formAddMethodCallAnalyzer, FormOptionsArrayMatcher $formOptionsArrayMatcher) { $this->formAddMethodCallAnalyzer = $formAddMethodCallAnalyzer; $this->formOptionsArrayMatcher = $formOptionsArrayMatcher; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns old option names to new ones in FormTypes in Form in Symfony', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns old option names to new ones in FormTypes in Form in Symfony', [new CodeSample(<<<'CODE_SAMPLE' $builder = new FormBuilder; $builder->add("...", ["precision" => "...", "virtual" => "..."]; CODE_SAMPLE @@ -53,32 +53,32 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->formAddMethodCallAnalyzer->isMatching($node)) { return null; } $optionsArray = $this->formOptionsArrayMatcher->match($node); - if (!$optionsArray instanceof \PhpParser\Node\Expr\Array_) { + if (!$optionsArray instanceof Array_) { return null; } foreach ($optionsArray->items as $arrayItemNode) { if ($arrayItemNode === null) { continue; } - if (!$arrayItemNode->key instanceof \PhpParser\Node\Scalar\String_) { + if (!$arrayItemNode->key instanceof String_) { continue; } $this->processStringKey($arrayItemNode->key); } return $node; } - private function processStringKey(\PhpParser\Node\Scalar\String_ $string) : void + private function processStringKey(String_ $string) : void { $currentOptionName = $string->value; $string->value = self::OLD_TO_NEW_OPTION[$currentOptionName] ?? $string->value; diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/ProcessBuilderGetProcessRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/ProcessBuilderGetProcessRector.php index 9ba2ceffa99..eef2ee43713 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/ProcessBuilderGetProcessRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/ProcessBuilderGetProcessRector.php @@ -7,16 +7,16 @@ use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\MethodCall\ProcessBuilderGetProcessRector\ProcessBuilderGetProcessRectorTest */ -final class ProcessBuilderGetProcessRector extends \Rector\Core\Rector\AbstractRector +final class ProcessBuilderGetProcessRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Removes `$processBuilder->getProcess()` calls to $processBuilder in Process in Symfony, because ProcessBuilder was removed. This is part of multi-step Rector and has very narrow focus.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Removes `$processBuilder->getProcess()` calls to $processBuilder in Process in Symfony, because ProcessBuilder was removed. This is part of multi-step Rector and has very narrow focus.', [new CodeSample(<<<'CODE_SAMPLE' $processBuilder = new Symfony\Component\Process\ProcessBuilder; $process = $processBuilder->getProcess(); $commamdLine = $processBuilder->getProcess()->getCommandLine(); @@ -33,14 +33,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Symfony\\Component\\Process\\ProcessBuilder'))) { + if (!$this->isObjectType($node->var, new ObjectType('Symfony\\Component\\Process\\ProcessBuilder'))) { return null; } if (!$this->isName($node->name, 'getProcess')) { diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/ReadOnlyOptionToAttributeRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/ReadOnlyOptionToAttributeRector.php index d9f9820a490..ec1d66e9498 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/ReadOnlyOptionToAttributeRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/ReadOnlyOptionToAttributeRector.php @@ -12,12 +12,12 @@ use Rector\Core\NodeManipulator\ArrayManipulator; use Rector\Core\Rector\AbstractRector; use Rector\Symfony\NodeAnalyzer\FormAddMethodCallAnalyzer; use Rector\Symfony\NodeAnalyzer\FormOptionsArrayMatcher; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\MethodCall\ReadOnlyOptionToAttributeRector\ReadOnlyOptionToAttributeRectorTest */ -final class ReadOnlyOptionToAttributeRector extends \Rector\Core\Rector\AbstractRector +final class ReadOnlyOptionToAttributeRector extends AbstractRector { /** * @readonly @@ -34,15 +34,15 @@ final class ReadOnlyOptionToAttributeRector extends \Rector\Core\Rector\Abstract * @var \Rector\Symfony\NodeAnalyzer\FormOptionsArrayMatcher */ private $formOptionsArrayMatcher; - public function __construct(\Rector\Core\NodeManipulator\ArrayManipulator $arrayManipulator, \Rector\Symfony\NodeAnalyzer\FormAddMethodCallAnalyzer $formAddMethodCallAnalyzer, \Rector\Symfony\NodeAnalyzer\FormOptionsArrayMatcher $formOptionsArrayMatcher) + public function __construct(ArrayManipulator $arrayManipulator, FormAddMethodCallAnalyzer $formAddMethodCallAnalyzer, FormOptionsArrayMatcher $formOptionsArrayMatcher) { $this->arrayManipulator = $arrayManipulator; $this->formAddMethodCallAnalyzer = $formAddMethodCallAnalyzer; $this->formOptionsArrayMatcher = $formOptionsArrayMatcher; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change "read_only" option in form to attribute', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change "read_only" option in form to attribute', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Form\FormBuilderInterface; function buildForm(FormBuilderInterface $builder, array $options) @@ -65,26 +65,26 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->formAddMethodCallAnalyzer->isMatching($node)) { return null; } $optionsArray = $this->formOptionsArrayMatcher->match($node); - if (!$optionsArray instanceof \PhpParser\Node\Expr\Array_) { + if (!$optionsArray instanceof Array_) { return null; } $readOnlyArrayItem = $this->arrayManipulator->findItemInInArrayByKeyAndUnset($optionsArray, 'read_only'); - if (!$readOnlyArrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$readOnlyArrayItem instanceof ArrayItem) { return null; } // rename string - $readOnlyArrayItem->key = new \PhpParser\Node\Scalar\String_('readonly'); + $readOnlyArrayItem->key = new String_('readonly'); $this->arrayManipulator->addItemToArrayUnderKey($optionsArray, $readOnlyArrayItem, 'attr'); return $node; } diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/RedirectToRouteRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/RedirectToRouteRector.php index 493b6c7d7e8..1f47939e4f5 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/RedirectToRouteRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/RedirectToRouteRector.php @@ -8,37 +8,37 @@ use PhpParser\Node\Arg; use PhpParser\Node\Expr\MethodCall; use Rector\Core\Rector\AbstractRector; use Rector\Symfony\TypeAnalyzer\ControllerAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\MethodCall\RedirectToRouteRector\RedirectToRouteRectorTest */ -final class RedirectToRouteRector extends \Rector\Core\Rector\AbstractRector +final class RedirectToRouteRector extends AbstractRector { /** * @readonly * @var \Rector\Symfony\TypeAnalyzer\ControllerAnalyzer */ private $controllerAnalyzer; - public function __construct(\Rector\Symfony\TypeAnalyzer\ControllerAnalyzer $controllerAnalyzer) + public function __construct(ControllerAnalyzer $controllerAnalyzer) { $this->controllerAnalyzer = $controllerAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns redirect to route to short helper method in Controller in Symfony', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$this->redirect($this->generateUrl("homepage"));', '$this->redirectToRoute("homepage");')]); + return new RuleDefinition('Turns redirect to route to short helper method in Controller in Symfony', [new CodeSample('$this->redirect($this->generateUrl("homepage"));', '$this->redirectToRoute("homepage");')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->controllerAnalyzer->isInsideController($node)) { return null; @@ -50,11 +50,11 @@ final class RedirectToRouteRector extends \Rector\Core\Rector\AbstractRector return null; } $firstArg = $node->args[0]; - if (!$firstArg instanceof \PhpParser\Node\Arg) { + if (!$firstArg instanceof Arg) { return null; } $argumentValue = $firstArg->value; - if (!$argumentValue instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$argumentValue instanceof MethodCall) { return null; } if (!$this->isName($argumentValue->name, 'generateUrl')) { @@ -65,14 +65,14 @@ final class RedirectToRouteRector extends \Rector\Core\Rector\AbstractRector /** * @return mixed[] */ - private function resolveArguments(\PhpParser\Node\Expr\MethodCall $methodCall) : array + private function resolveArguments(MethodCall $methodCall) : array { $firstArg = $methodCall->args[0]; - if (!$firstArg instanceof \PhpParser\Node\Arg) { + if (!$firstArg instanceof Arg) { return []; } $generateUrlNode = $firstArg->value; - if (!$generateUrlNode instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$generateUrlNode instanceof MethodCall) { return []; } $arguments = []; diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/ReflectionExtractorEnableMagicCallExtractorRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/ReflectionExtractorEnableMagicCallExtractorRector.php index 5f4b3550176..66b29da8ecb 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/ReflectionExtractorEnableMagicCallExtractorRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/ReflectionExtractorEnableMagicCallExtractorRector.php @@ -12,13 +12,13 @@ use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Scalar\String_; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#propertyinfo * @see \Rector\Symfony\Tests\Rector\MethodCall\ReflectionExtractorEnableMagicCallExtractorRector\ReflectionExtractorEnableMagicCallExtractorRectorTest */ -final class ReflectionExtractorEnableMagicCallExtractorRector extends \Rector\Core\Rector\AbstractRector +final class ReflectionExtractorEnableMagicCallExtractorRector extends AbstractRector { /** * @var string @@ -32,9 +32,9 @@ final class ReflectionExtractorEnableMagicCallExtractorRector extends \Rector\Co * @var string[] */ private const METHODS_WITH_OPTION = ['getWriteInfo', 'getReadInfo']; - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Migrates from deprecated enable_magic_call_extraction context option in ReflectionExtractor', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Migrates from deprecated enable_magic_call_extraction context option in ReflectionExtractor', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor; class SomeClass @@ -69,12 +69,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; @@ -84,19 +84,19 @@ CODE_SAMPLE return null; } $thirdArg = $node->args[2]; - if (!$thirdArg instanceof \PhpParser\Node\Arg) { + if (!$thirdArg instanceof Arg) { return null; } $contextOptions = $thirdArg->value; - if (!$contextOptions instanceof \PhpParser\Node\Expr\Array_) { + if (!$contextOptions instanceof Array_) { return null; } - $contextOptions->items[] = new \PhpParser\Node\Expr\ArrayItem($this->prepareEnableMagicMethodsExtractionFlags($contextOptionValue), new \PhpParser\Node\Scalar\String_(self::NEW_OPTION_NAME)); + $contextOptions->items[] = new ArrayItem($this->prepareEnableMagicMethodsExtractionFlags($contextOptionValue), new String_(self::NEW_OPTION_NAME)); return $node; } - private function shouldSkip(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + private function shouldSkip(MethodCall $methodCall) : bool { - $reflectionExtractorObjectType = new \PHPStan\Type\ObjectType('Symfony\\Component\\PropertyInfo\\Extractor\\ReflectionExtractor'); + $reflectionExtractorObjectType = new ObjectType('Symfony\\Component\\PropertyInfo\\Extractor\\ReflectionExtractor'); if (!$this->isObjectType($methodCall->var, $reflectionExtractorObjectType)) { return \true; } @@ -107,31 +107,31 @@ CODE_SAMPLE return \true; } $thirdArg = $methodCall->args[2]; - if (!$thirdArg instanceof \PhpParser\Node\Arg) { + if (!$thirdArg instanceof Arg) { return \true; } $contextOptions = $thirdArg->value; - if (!$contextOptions instanceof \PhpParser\Node\Expr\Array_) { + if (!$contextOptions instanceof Array_) { return \true; } return $contextOptions->items === []; } - private function getContextOptionValue(\PhpParser\Node\Expr\MethodCall $methodCall) : ?bool + private function getContextOptionValue(MethodCall $methodCall) : ?bool { $thirdArg = $methodCall->args[2]; - if (!$thirdArg instanceof \PhpParser\Node\Arg) { + if (!$thirdArg instanceof Arg) { return null; } $contextOptions = $thirdArg->value; - if (!$contextOptions instanceof \PhpParser\Node\Expr\Array_) { + if (!$contextOptions instanceof Array_) { return null; } $contextOptionValue = null; foreach ($contextOptions->items as $index => $arrayItem) { - if (!$arrayItem instanceof \PhpParser\Node\Expr\ArrayItem) { + if (!$arrayItem instanceof ArrayItem) { continue; } - if (!$arrayItem->key instanceof \PhpParser\Node\Scalar\String_) { + if (!$arrayItem->key instanceof String_) { continue; } if ($arrayItem->key->value !== self::OLD_OPTION_NAME) { @@ -142,14 +142,14 @@ CODE_SAMPLE } return $contextOptionValue; } - private function prepareEnableMagicMethodsExtractionFlags(bool $enableMagicCallExtractionValue) : \PhpParser\Node\Expr\BinaryOp\BitwiseOr + private function prepareEnableMagicMethodsExtractionFlags(bool $enableMagicCallExtractionValue) : BitwiseOr { $magicGetClassConstFetch = $this->nodeFactory->createClassConstFetch('Symfony\\Component\\PropertyInfo\\Extractor\\ReflectionExtractor', 'MAGIC_GET'); $magicSetClassConstFetch = $this->nodeFactory->createClassConstFetch('Symfony\\Component\\PropertyInfo\\Extractor\\ReflectionExtractor', 'MAGIC_SET'); if (!$enableMagicCallExtractionValue) { - return new \PhpParser\Node\Expr\BinaryOp\BitwiseOr($magicGetClassConstFetch, $magicSetClassConstFetch); + return new BitwiseOr($magicGetClassConstFetch, $magicSetClassConstFetch); } $magicCallClassConstFetch = $this->nodeFactory->createClassConstFetch('Symfony\\Component\\PropertyInfo\\Extractor\\ReflectionExtractor', 'MAGIC_CALL'); - return new \PhpParser\Node\Expr\BinaryOp\BitwiseOr(new \PhpParser\Node\Expr\BinaryOp\BitwiseOr($magicCallClassConstFetch, $magicGetClassConstFetch), $magicSetClassConstFetch); + return new BitwiseOr(new BitwiseOr($magicCallClassConstFetch, $magicGetClassConstFetch), $magicSetClassConstFetch); } } diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/StringFormTypeToClassRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/StringFormTypeToClassRector.php index 35052a1e85a..d269bdeeaf9 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/StringFormTypeToClassRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/StringFormTypeToClassRector.php @@ -10,14 +10,14 @@ use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; use Rector\Symfony\FormHelper\FormTypeStringToTypeProvider; use Rector\Symfony\NodeAnalyzer\FormAddMethodCallAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * Covers https://github.com/symfony/symfony/blob/2.8/UPGRADE-2.8.md#form * * @see \Rector\Symfony\Tests\Rector\MethodCall\StringFormTypeToClassRector\StringFormTypeToClassRectorTest */ -final class StringFormTypeToClassRector extends \Rector\Core\Rector\AbstractRector +final class StringFormTypeToClassRector extends AbstractRector { /** * @var string @@ -33,14 +33,14 @@ final class StringFormTypeToClassRector extends \Rector\Core\Rector\AbstractRect * @var \Rector\Symfony\FormHelper\FormTypeStringToTypeProvider */ private $formTypeStringToTypeProvider; - public function __construct(\Rector\Symfony\NodeAnalyzer\FormAddMethodCallAnalyzer $formAddMethodCallAnalyzer, \Rector\Symfony\FormHelper\FormTypeStringToTypeProvider $formTypeStringToTypeProvider) + public function __construct(FormAddMethodCallAnalyzer $formAddMethodCallAnalyzer, FormTypeStringToTypeProvider $formTypeStringToTypeProvider) { $this->formAddMethodCallAnalyzer = $formAddMethodCallAnalyzer; $this->formTypeStringToTypeProvider = $formTypeStringToTypeProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition(self::DESCRIPTION, [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition(self::DESCRIPTION, [new CodeSample(<<<'CODE_SAMPLE' $formBuilder = new Symfony\Component\Form\FormBuilder; $formBuilder->add('name', 'form.type.text'); CODE_SAMPLE @@ -55,22 +55,22 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->formAddMethodCallAnalyzer->isMatching($node)) { return null; } // not a string $firstArg = $node->args[1]; - if (!$firstArg instanceof \PhpParser\Node\Arg) { + if (!$firstArg instanceof Arg) { return null; } - if (!$firstArg->value instanceof \PhpParser\Node\Scalar\String_) { + if (!$firstArg->value instanceof String_) { return null; } /** @var String_ $stringNode */ diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/SwiftCreateMessageToNewEmailRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/SwiftCreateMessageToNewEmailRector.php index e00bee1ddc2..d5c597ccbf2 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/SwiftCreateMessageToNewEmailRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/SwiftCreateMessageToNewEmailRector.php @@ -12,16 +12,16 @@ use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\Property; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\MethodCall\SwiftCreateMessageToNewEmailRector\SwiftCreateMessageToNewEmailRectorTest */ -final class SwiftCreateMessageToNewEmailRector extends \Rector\Core\Rector\AbstractRector +final class SwiftCreateMessageToNewEmailRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes createMessage() into a new Symfony\\Component\\Mime\\Email', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes createMessage() into a new Symfony\\Component\\Mime\\Email', [new CodeSample(<<<'CODE_SAMPLE' $email = $this->swift->createMessage('message'); CODE_SAMPLE , <<<'CODE_SAMPLE' @@ -34,45 +34,45 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } - return new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name\FullyQualified('Symfony\\Component\\Mime\\Email')); + return new New_(new FullyQualified('Symfony\\Component\\Mime\\Email')); } - private function shouldSkip(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + private function shouldSkip(MethodCall $methodCall) : bool { if (!$this->isName($methodCall->name, 'createMessage')) { return \true; } // If there is no property with a SwiftMailer type we should skip this class $swiftMailerProperty = $this->getSwiftMailerProperty($methodCall); - if (!$swiftMailerProperty instanceof \PhpParser\Node\Stmt\Property) { + if (!$swiftMailerProperty instanceof Property) { return \true; } $var = $methodCall->var; - if (!$var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$var instanceof PropertyFetch) { return \true; } $propertyName = $this->getName($swiftMailerProperty); return !$this->isName($var, $propertyName); } - private function getSwiftMailerProperty(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node\Stmt\Property + private function getSwiftMailerProperty(MethodCall $methodCall) : ?Property { - $class = $this->betterNodeFinder->findParentType($methodCall, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->betterNodeFinder->findParentType($methodCall, Class_::class); + if (!$class instanceof Class_) { return null; } $properties = $class->getProperties(); foreach ($properties as $property) { $propertyType = $this->nodeTypeResolver->getType($property); - if (!$propertyType instanceof \PHPStan\Type\ObjectType) { + if (!$propertyType instanceof ObjectType) { continue; } if (!$propertyType->isInstanceOf('Swift_Mailer')->yes()) { diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/SwiftSetBodyToHtmlPlainMethodCallRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/SwiftSetBodyToHtmlPlainMethodCallRector.php index 113adf0c3d6..66d33be4b1c 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/SwiftSetBodyToHtmlPlainMethodCallRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/SwiftSetBodyToHtmlPlainMethodCallRector.php @@ -9,18 +9,18 @@ use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Identifier; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\MethodCall\SwiftSetBodyToHtmlPlainMethodCallRector\SwiftSetBodyToHtmlPlainMethodCallRectorTest * * @changelog https://github.com/laravel/framework/pull/38481/files#diff-2310168aa86b70a22595ba784039cbdde829bd38245c9586eedd111dfd0f806d */ -final class SwiftSetBodyToHtmlPlainMethodCallRector extends \Rector\Core\Rector\AbstractRector +final class SwiftSetBodyToHtmlPlainMethodCallRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes setBody() method call on Swift_Message into a html() or plain() based on second argument', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes setBody() method call on Swift_Message into a html() or plain() based on second argument', [new CodeSample(<<<'CODE_SAMPLE' $message = new Swift_Message(); $message->setBody('...', 'text/html'); @@ -43,14 +43,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Swift_Message'))) { + if (!$this->isObjectType($node->var, new ObjectType('Swift_Message'))) { return null; } if (!$this->isName($node->name, 'setBody')) { @@ -58,17 +58,17 @@ CODE_SAMPLE } if (\count($node->args) === 2) { $firstArg = $node->args[1]; - if (!$firstArg instanceof \PhpParser\Node\Arg) { + if (!$firstArg instanceof Arg) { return null; } $secondArgValue = $this->valueResolver->getValue($firstArg->value); if ($secondArgValue === 'text/html') { unset($node->args[1]); - $node->name = new \PhpParser\Node\Identifier('html'); + $node->name = new Identifier('html'); return $node; } } - $node->name = new \PhpParser\Node\Identifier('plain'); + $node->name = new Identifier('plain'); return $node; } } diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/ValidatorBuilderEnableAnnotationMappingRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/ValidatorBuilderEnableAnnotationMappingRector.php index 37729afb027..de6b55be0fa 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/ValidatorBuilderEnableAnnotationMappingRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/ValidatorBuilderEnableAnnotationMappingRector.php @@ -8,17 +8,17 @@ use PhpParser\Node\Arg; use PhpParser\Node\Expr\MethodCall; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#validator * @see \Rector\Symfony\Tests\Rector\MethodCall\ValidatorBuilderEnableAnnotationMappingRector\ValidatorBuilderEnableAnnotationMappingRectorTest */ -final class ValidatorBuilderEnableAnnotationMappingRector extends \Rector\Core\Rector\AbstractRector +final class ValidatorBuilderEnableAnnotationMappingRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Migrates from deprecated ValidatorBuilder->enableAnnotationMapping($reader) to ValidatorBuilder->enableAnnotationMapping(true)->setDoctrineAnnotationReader($reader)', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Migrates from deprecated ValidatorBuilder->enableAnnotationMapping($reader) to ValidatorBuilder->enableAnnotationMapping(true)->setDoctrineAnnotationReader($reader)', [new CodeSample(<<<'CODE_SAMPLE' use Doctrine\Common\Annotations\Reader; use Symfony\Component\Validator\ValidatorBuilder; @@ -49,27 +49,27 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Symfony\\Component\\Validator\\ValidatorBuilder'))) { + if (!$this->isObjectType($node->var, new ObjectType('Symfony\\Component\\Validator\\ValidatorBuilder'))) { return null; } if (!$this->isName($node->name, 'enableAnnotationMapping')) { return null; } $firstArg = $node->args[0]; - if (!$firstArg instanceof \PhpParser\Node\Arg) { + if (!$firstArg instanceof Arg) { return null; } if ($this->valueResolver->isTrueOrFalse($firstArg->value)) { return null; } - if (!$this->isObjectType($firstArg->value, new \PHPStan\Type\ObjectType('Doctrine\\Common\\Annotations\\Reader'))) { + if (!$this->isObjectType($firstArg->value, new ObjectType('Doctrine\\Common\\Annotations\\Reader'))) { return null; } $readerType = $firstArg->value; diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/VarDumperTestTraitMethodArgsRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/VarDumperTestTraitMethodArgsRector.php index 37abcb0c711..7041531164a 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/VarDumperTestTraitMethodArgsRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/VarDumperTestTraitMethodArgsRector.php @@ -10,30 +10,30 @@ use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Scalar\String_; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\MethodCall\VarDumperTestTraitMethodArgsRector\VarDumperTestTraitMethodArgsRectorTest */ -final class VarDumperTestTraitMethodArgsRector extends \Rector\Core\Rector\AbstractRector +final class VarDumperTestTraitMethodArgsRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Adds a new `$filter` argument in `VarDumperTestTrait->assertDumpEquals()` and `VarDumperTestTrait->assertDumpMatchesFormat()` in Validator in Symfony.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$varDumperTestTrait->assertDumpEquals($dump, $data, $message = "");', '$varDumperTestTrait->assertDumpEquals($dump, $data, $filter = 0, $message = "");'), new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$varDumperTestTrait->assertDumpMatchesFormat($dump, $data, $message = "");', '$varDumperTestTrait->assertDumpMatchesFormat($dump, $data, $filter = 0, $message = "");')]); + return new RuleDefinition('Adds a new `$filter` argument in `VarDumperTestTrait->assertDumpEquals()` and `VarDumperTestTrait->assertDumpMatchesFormat()` in Validator in Symfony.', [new CodeSample('$varDumperTestTrait->assertDumpEquals($dump, $data, $message = "");', '$varDumperTestTrait->assertDumpEquals($dump, $data, $filter = 0, $message = "");'), new CodeSample('$varDumperTestTrait->assertDumpMatchesFormat($dump, $data, $message = "");', '$varDumperTestTrait->assertDumpMatchesFormat($dump, $data, $filter = 0, $message = "");')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait'))) { + if (!$this->isObjectType($node->var, new ObjectType('Symfony\\Component\\VarDumper\\Test\\VarDumperTestTrait'))) { return null; } if (!$this->isNames($node->name, ['assertDumpEquals', 'assertDumpMatchesFormat'])) { @@ -43,13 +43,13 @@ final class VarDumperTestTraitMethodArgsRector extends \Rector\Core\Rector\Abstr return null; } $secondArg = $node->args[2]; - if (!$secondArg instanceof \PhpParser\Node\Arg) { + if (!$secondArg instanceof Arg) { return null; } - if ($secondArg->value instanceof \PhpParser\Node\Expr\ConstFetch) { + if ($secondArg->value instanceof ConstFetch) { return null; } - if ($secondArg->value instanceof \PhpParser\Node\Scalar\String_) { + if ($secondArg->value instanceof String_) { $node->args[3] = $node->args[2]; $node->args[2] = $this->nodeFactory->createArg(0); return $node; diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/WebTestCaseAssertIsSuccessfulRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/WebTestCaseAssertIsSuccessfulRector.php index 31398e4bcdd..45225f3654e 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/WebTestCaseAssertIsSuccessfulRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/WebTestCaseAssertIsSuccessfulRector.php @@ -10,15 +10,15 @@ use PhpParser\Node\Identifier; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\Symfony\NodeAnalyzer\SymfonyTestCaseAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://symfony.com/blog/new-in-symfony-4-3-better-test-assertions * @changelog https://github.com/symfony/symfony/pull/30813 * * @see \Rector\Symfony\Tests\Rector\MethodCall\WebTestCaseAssertIsSuccessfulRector\WebTestCaseAssertIsSuccessfulRectorTest */ -final class WebTestCaseAssertIsSuccessfulRector extends \Rector\Core\Rector\AbstractRector +final class WebTestCaseAssertIsSuccessfulRector extends AbstractRector { /** * @readonly @@ -30,14 +30,14 @@ final class WebTestCaseAssertIsSuccessfulRector extends \Rector\Core\Rector\Abst * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\Symfony\NodeAnalyzer\SymfonyTestCaseAnalyzer $symfonyTestCaseAnalyzer, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(SymfonyTestCaseAnalyzer $symfonyTestCaseAnalyzer, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->symfonyTestCaseAnalyzer = $symfonyTestCaseAnalyzer; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Simplify use of assertions in WebTestCase', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Simplify use of assertions in WebTestCase', [new CodeSample(<<<'CODE_SAMPLE' use PHPUnit\Framework\TestCase; class SomeClass extends TestCase @@ -66,12 +66,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->symfonyTestCaseAnalyzer->isInWebTestCase($node)) { return null; @@ -84,13 +84,13 @@ CODE_SAMPLE return null; } $secondArg = $args[1]->value; - if (!$secondArg instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$secondArg instanceof MethodCall) { return null; } if (!$this->isName($secondArg->name, 'getStatusCode')) { return null; } - $node->name = new \PhpParser\Node\Identifier('assertResponseIsSuccessful'); + $node->name = new Identifier('assertResponseIsSuccessful'); $node->args = []; return $node; } diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/WebTestCaseAssertResponseCodeRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/WebTestCaseAssertResponseCodeRector.php index fb9fb31e710..89fc63ec56f 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/WebTestCaseAssertResponseCodeRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/WebTestCaseAssertResponseCodeRector.php @@ -9,15 +9,15 @@ use PhpParser\Node\Expr\MethodCall; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\Symfony\NodeAnalyzer\SymfonyTestCaseAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://symfony.com/blog/new-in-symfony-4-3-better-test-assertions * @changelog https://github.com/symfony/symfony/pull/30813 * * @see \Rector\Symfony\Tests\Rector\MethodCall\WebTestCaseAssertResponseCodeRector\WebTestCaseAssertResponseCodeRectorTest */ -final class WebTestCaseAssertResponseCodeRector extends \Rector\Core\Rector\AbstractRector +final class WebTestCaseAssertResponseCodeRector extends AbstractRector { /** * @readonly @@ -29,14 +29,14 @@ final class WebTestCaseAssertResponseCodeRector extends \Rector\Core\Rector\Abst * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\Symfony\NodeAnalyzer\SymfonyTestCaseAnalyzer $symfonyTestCaseAnalyzer, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(SymfonyTestCaseAnalyzer $symfonyTestCaseAnalyzer, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->symfonyTestCaseAnalyzer = $symfonyTestCaseAnalyzer; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Simplify use of assertions in WebTestCase', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Simplify use of assertions in WebTestCase', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; final class SomeClass extends WebTestCase @@ -69,12 +69,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class]; + return [MethodCall::class]; } /** * @param MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->symfonyTestCaseAnalyzer->isInWebTestCase($node)) { return null; @@ -89,9 +89,9 @@ CODE_SAMPLE /** * We look for: "$client->getResponse()->headers->get('Location')" */ - public function isGetLocationMethodCall(\PhpParser\Node\Expr $expr) : bool + public function isGetLocationMethodCall(Expr $expr) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$expr instanceof MethodCall) { return \false; } if (!$this->isName($expr->name, 'get')) { @@ -104,14 +104,14 @@ CODE_SAMPLE $firstArg = $args[0]; return $this->valueResolver->isValue($firstArg->value, 'Location'); } - private function processAssertResponseStatusCodeSame(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node\Expr\MethodCall + private function processAssertResponseStatusCodeSame(MethodCall $methodCall) : ?MethodCall { if (!$this->isName($methodCall->name, 'assertSame')) { return null; } $args = $methodCall->getArgs(); $secondArg = $args[1]; - if (!$secondArg->value instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$secondArg->value instanceof MethodCall) { return null; } $nestedMethodCall = $secondArg->value; @@ -128,7 +128,7 @@ CODE_SAMPLE } return $this->nodeFactory->createLocalMethodCall('assertResponseStatusCodeSame', [$methodCall->args[0]]); } - private function processAssertResponseRedirects(\PhpParser\Node\Expr\MethodCall $methodCall) : ?\PhpParser\Node\Expr\MethodCall + private function processAssertResponseRedirects(MethodCall $methodCall) : ?MethodCall { if (!$this->testsNodeAnalyzer->isPHPUnitMethodCallNames($methodCall, ['assertSame'])) { return null; diff --git a/vendor/rector/rector-symfony/src/Rector/MethodCall/WebTestCaseAssertSelectorTextContainsRector.php b/vendor/rector/rector-symfony/src/Rector/MethodCall/WebTestCaseAssertSelectorTextContainsRector.php index 8c973c26b46..c826d182bd2 100644 --- a/vendor/rector/rector-symfony/src/Rector/MethodCall/WebTestCaseAssertSelectorTextContainsRector.php +++ b/vendor/rector/rector-symfony/src/Rector/MethodCall/WebTestCaseAssertSelectorTextContainsRector.php @@ -9,15 +9,15 @@ use PhpParser\Node\Expr\StaticCall; use Rector\Core\Rector\AbstractRector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; use Rector\Symfony\NodeAnalyzer\SymfonyTestCaseAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @changelog https://symfony.com/blog/new-in-symfony-4-3-better-test-assertions * @changelog https://github.com/symfony/symfony/pull/30813 * * @see \Rector\Symfony\Tests\Rector\MethodCall\WebTestCaseAssertSelectorTextContainsRector\WebTestCaseAssertSelectorTextContainsRectorTest */ -final class WebTestCaseAssertSelectorTextContainsRector extends \Rector\Core\Rector\AbstractRector +final class WebTestCaseAssertSelectorTextContainsRector extends AbstractRector { /** * @readonly @@ -29,14 +29,14 @@ final class WebTestCaseAssertSelectorTextContainsRector extends \Rector\Core\Rec * @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer */ private $testsNodeAnalyzer; - public function __construct(\Rector\Symfony\NodeAnalyzer\SymfonyTestCaseAnalyzer $symfonyTestCaseAnalyzer, \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer $testsNodeAnalyzer) + public function __construct(SymfonyTestCaseAnalyzer $symfonyTestCaseAnalyzer, TestsNodeAnalyzer $testsNodeAnalyzer) { $this->symfonyTestCaseAnalyzer = $symfonyTestCaseAnalyzer; $this->testsNodeAnalyzer = $testsNodeAnalyzer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Simplify use of assertions in WebTestCase to assertSelectorTextContains()', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Simplify use of assertions in WebTestCase to assertSelectorTextContains()', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\DomCrawler\Crawler; @@ -69,12 +69,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; + return [MethodCall::class, StaticCall::class]; } /** * @param MethodCall|StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->symfonyTestCaseAnalyzer->isInWebTestCase($node)) { return null; @@ -84,14 +84,14 @@ CODE_SAMPLE } $args = $node->getArgs(); $firstArgValue = $args[1]->value; - if (!$firstArgValue instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$firstArgValue instanceof MethodCall) { return null; } $methodCall = $firstArgValue; if (!$this->isName($methodCall->name, 'text')) { return null; } - if (!$methodCall->var instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$methodCall->var instanceof MethodCall) { return null; } $nestedMethodCall = $methodCall->var; diff --git a/vendor/rector/rector-symfony/src/Rector/New_/PropertyAccessorCreationBooleanToFlagsRector.php b/vendor/rector/rector-symfony/src/Rector/New_/PropertyAccessorCreationBooleanToFlagsRector.php index f1bb434c5fe..15c96b24913 100644 --- a/vendor/rector/rector-symfony/src/Rector/New_/PropertyAccessorCreationBooleanToFlagsRector.php +++ b/vendor/rector/rector-symfony/src/Rector/New_/PropertyAccessorCreationBooleanToFlagsRector.php @@ -9,17 +9,17 @@ use PhpParser\Node\Expr\BinaryOp\BitwiseOr; use PhpParser\Node\Expr\New_; use PhpParser\Node\Name; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#propertyaccess * @see \Rector\Symfony\Tests\Rector\New_\PropertyAccessorCreationBooleanToFlagsRector\PropertyAccessorCreationBooleanToFlagsRectorTest */ -final class PropertyAccessorCreationBooleanToFlagsRector extends \Rector\Core\Rector\AbstractRector +final class PropertyAccessorCreationBooleanToFlagsRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes first argument of PropertyAccessor::__construct() to flags from boolean', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes first argument of PropertyAccessor::__construct() to flags from boolean', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run() @@ -44,18 +44,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\New_::class]; + return [New_::class]; } /** * @param New_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } $firstArg = $node->args[0]; - if (!$firstArg instanceof \PhpParser\Node\Arg) { + if (!$firstArg instanceof Arg) { return null; } $isTrue = $this->valueResolver->isTrue($firstArg->value); @@ -63,9 +63,9 @@ CODE_SAMPLE $node->args[0] = $this->nodeFactory->createArg($bitwiseOr); return $node; } - private function shouldSkip(\PhpParser\Node\Expr\New_ $new) : bool + private function shouldSkip(New_ $new) : bool { - if (!$new->class instanceof \PhpParser\Node\Name) { + if (!$new->class instanceof Name) { return \true; } if (!$this->isName($new->class, 'Symfony\\Component\\PropertyAccess\\PropertyAccessor')) { @@ -75,19 +75,19 @@ CODE_SAMPLE return \true; } $firstArg = $new->args[0]; - if (!$firstArg instanceof \PhpParser\Node\Arg) { + if (!$firstArg instanceof Arg) { return \true; } return !$this->valueResolver->isTrueOrFalse($firstArg->value); } - private function prepareFlags(bool $currentValue) : \PhpParser\Node\Expr\BinaryOp\BitwiseOr + private function prepareFlags(bool $currentValue) : BitwiseOr { $magicGetClassConstFetch = $this->nodeFactory->createClassConstFetch('Symfony\\Component\\PropertyAccess\\PropertyAccessor', 'MAGIC_GET'); $magicSetClassConstFetch = $this->nodeFactory->createClassConstFetch('Symfony\\Component\\PropertyAccess\\PropertyAccessor', 'MAGIC_SET'); if (!$currentValue) { - return new \PhpParser\Node\Expr\BinaryOp\BitwiseOr($magicGetClassConstFetch, $magicSetClassConstFetch); + return new BitwiseOr($magicGetClassConstFetch, $magicSetClassConstFetch); } $magicCallClassConstFetch = $this->nodeFactory->createClassConstFetch('Symfony\\Component\\PropertyAccess\\PropertyAccessor', 'MAGIC_CALL'); - return new \PhpParser\Node\Expr\BinaryOp\BitwiseOr(new \PhpParser\Node\Expr\BinaryOp\BitwiseOr($magicCallClassConstFetch, $magicGetClassConstFetch), $magicSetClassConstFetch); + return new BitwiseOr(new BitwiseOr($magicCallClassConstFetch, $magicGetClassConstFetch), $magicSetClassConstFetch); } } diff --git a/vendor/rector/rector-symfony/src/Rector/New_/PropertyPathMapperToDataMapperRector.php b/vendor/rector/rector-symfony/src/Rector/New_/PropertyPathMapperToDataMapperRector.php index b7d4104764f..5cfb1908b58 100644 --- a/vendor/rector/rector-symfony/src/Rector/New_/PropertyPathMapperToDataMapperRector.php +++ b/vendor/rector/rector-symfony/src/Rector/New_/PropertyPathMapperToDataMapperRector.php @@ -8,17 +8,17 @@ use PhpParser\Node\Expr\New_; use PhpParser\Node\Name; use PhpParser\Node\Name\FullyQualified; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#form * @see \Rector\Symfony\Tests\Rector\New_\PropertyPathMapperToDataMapperRector\PropertyPathMapperToDataMapperRectorTest */ -final class PropertyPathMapperToDataMapperRector extends \Rector\Core\Rector\AbstractRector +final class PropertyPathMapperToDataMapperRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Migrate from PropertyPathMapper to DataMapper and PropertyPathAccessor', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Migrate from PropertyPathMapper to DataMapper and PropertyPathAccessor', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper; class SomeClass @@ -47,32 +47,32 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\New_::class]; + return [New_::class]; } /** * @param New_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($this->shouldSkip($node)) { return null; } return $this->generateNewInstances($node); } - private function shouldSkip(\PhpParser\Node\Expr\New_ $new) : bool + private function shouldSkip(New_ $new) : bool { - if (!$new->class instanceof \PhpParser\Node\Name) { + if (!$new->class instanceof Name) { return \true; } return !$this->isName($new->class, 'Symfony\\Component\\Form\\Extension\\Core\\DataMapper\\PropertyPathMapper'); } - private function generateNewInstances(\PhpParser\Node\Expr\New_ $new) : \PhpParser\Node\Expr\New_ + private function generateNewInstances(New_ $new) : New_ { $arguments = []; if (isset($new->args[0])) { $arguments = [$new->args[0]]; } - $new = new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name\FullyQualified('Symfony\\Component\\Form\\Extension\\Core\\DataAccessor\\PropertyPathAccessor'), $arguments); - return new \PhpParser\Node\Expr\New_(new \PhpParser\Node\Name\FullyQualified('Symfony\\Component\\Form\\Extension\\Core\\DataMapper\\DataMapper'), [$this->nodeFactory->createArg($new)]); + $new = new New_(new FullyQualified('Symfony\\Component\\Form\\Extension\\Core\\DataAccessor\\PropertyPathAccessor'), $arguments); + return new New_(new FullyQualified('Symfony\\Component\\Form\\Extension\\Core\\DataMapper\\DataMapper'), [$this->nodeFactory->createArg($new)]); } } diff --git a/vendor/rector/rector-symfony/src/Rector/New_/RootNodeTreeBuilderRector.php b/vendor/rector/rector-symfony/src/Rector/New_/RootNodeTreeBuilderRector.php index 8da749af180..eec8f3801d9 100644 --- a/vendor/rector/rector-symfony/src/Rector/New_/RootNodeTreeBuilderRector.php +++ b/vendor/rector/rector-symfony/src/Rector/New_/RootNodeTreeBuilderRector.php @@ -13,17 +13,17 @@ use PhpParser\Node\Stmt; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/symfony/symfony/pull/27476 * @see \Rector\Symfony\Tests\Rector\New_\RootNodeTreeBuilderRector\RootNodeTreeBuilderRectorTest */ -final class RootNodeTreeBuilderRector extends \Rector\Core\Rector\AbstractRector +final class RootNodeTreeBuilderRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes Process string argument to an array', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes Process string argument to an array', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Config\Definition\Builder\TreeBuilder; $treeBuilder = new TreeBuilder(); @@ -44,50 +44,50 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\New_::class]; + return [New_::class]; } /** * @param New_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$this->isObjectType($node->class, new \PHPStan\Type\ObjectType('Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder'))) { + if (!$this->isObjectType($node->class, new ObjectType('Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder'))) { return null; } if (isset($node->args[1])) { return null; } $rootMethodCallNode = $this->getRootMethodCallNode($node); - if (!$rootMethodCallNode instanceof \PhpParser\Node\Expr\MethodCall) { + if (!$rootMethodCallNode instanceof MethodCall) { return null; } $firstArg = $rootMethodCallNode->args[0]; - if (!$firstArg instanceof \PhpParser\Node\Arg) { + if (!$firstArg instanceof Arg) { return null; } $rootNameNode = $firstArg->value; - if (!$rootNameNode instanceof \PhpParser\Node\Scalar\String_) { + if (!$rootNameNode instanceof String_) { return null; } [$node->args, $rootMethodCallNode->args] = [$rootMethodCallNode->args, $node->args]; - $rootMethodCallNode->name = new \PhpParser\Node\Identifier('getRootNode'); + $rootMethodCallNode->name = new Identifier('getRootNode'); return $node; } - private function getRootMethodCallNode(\PhpParser\Node\Expr\New_ $new) : ?\PhpParser\Node + private function getRootMethodCallNode(New_ $new) : ?Node { $currentStmt = $this->betterNodeFinder->resolveCurrentStatement($new); - if (!$currentStmt instanceof \PhpParser\Node\Stmt) { + if (!$currentStmt instanceof Stmt) { return null; } - $nextExpression = $currentStmt->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE); + $nextExpression = $currentStmt->getAttribute(AttributeKey::NEXT_NODE); if ($nextExpression === null) { return null; } - return $this->betterNodeFinder->findFirst([$nextExpression], function (\PhpParser\Node $node) : bool { - if (!$node instanceof \PhpParser\Node\Expr\MethodCall) { + return $this->betterNodeFinder->findFirst([$nextExpression], function (Node $node) : bool { + if (!$node instanceof MethodCall) { return \false; } - if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder'))) { + if (!$this->isObjectType($node->var, new ObjectType('Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder'))) { return \false; } if (!$this->isName($node->name, 'root')) { diff --git a/vendor/rector/rector-symfony/src/Rector/New_/StringToArrayArgumentProcessRector.php b/vendor/rector/rector-symfony/src/Rector/New_/StringToArrayArgumentProcessRector.php index d4788b60e49..6f79514d96c 100644 --- a/vendor/rector/rector-symfony/src/Rector/New_/StringToArrayArgumentProcessRector.php +++ b/vendor/rector/rector-symfony/src/Rector/New_/StringToArrayArgumentProcessRector.php @@ -19,13 +19,13 @@ use Rector\Core\PhpParser\NodeTransformer; use Rector\Core\Rector\AbstractRector; use RectorPrefix20220607\Symfony\Component\Console\Input\StringInput; use RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/symfony/symfony/pull/27821/files * @see \Rector\Symfony\Tests\Rector\New_\StringToArrayArgumentProcessRector\StringToArrayArgumentProcessRectorTest */ -final class StringToArrayArgumentProcessRector extends \Rector\Core\Rector\AbstractRector +final class StringToArrayArgumentProcessRector extends AbstractRector { /** * @var string[] @@ -36,13 +36,13 @@ final class StringToArrayArgumentProcessRector extends \Rector\Core\Rector\Abstr * @var \Rector\Core\PhpParser\NodeTransformer */ private $nodeTransformer; - public function __construct(\Rector\Core\PhpParser\NodeTransformer $nodeTransformer) + public function __construct(NodeTransformer $nodeTransformer) { $this->nodeTransformer = $nodeTransformer; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes Process string argument to an array', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes Process string argument to an array', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Process\Process; $process = new Process('ls -l'); CODE_SAMPLE @@ -57,18 +57,18 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\New_::class, \PhpParser\Node\Expr\MethodCall::class]; + return [New_::class, MethodCall::class]; } /** * @param New_|MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - $expr = $node instanceof \PhpParser\Node\Expr\New_ ? $node->class : $node->var; - if ($this->isObjectType($expr, new \PHPStan\Type\ObjectType('Symfony\\Component\\Process\\Process'))) { + $expr = $node instanceof New_ ? $node->class : $node->var; + if ($this->isObjectType($expr, new ObjectType('Symfony\\Component\\Process\\Process'))) { return $this->processArgumentPosition($node, 0); } - if ($this->isObjectType($expr, new \PHPStan\Type\ObjectType('Symfony\\Component\\Console\\Helper\\ProcessHelper'))) { + if ($this->isObjectType($expr, new ObjectType('Symfony\\Component\\Console\\Helper\\ProcessHelper'))) { return $this->processArgumentPosition($node, 1); } return null; @@ -76,31 +76,31 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Expr\New_|\PhpParser\Node\Expr\MethodCall $node */ - private function processArgumentPosition($node, int $argumentPosition) : ?\PhpParser\Node + private function processArgumentPosition($node, int $argumentPosition) : ?Node { if (!isset($node->args[$argumentPosition])) { return null; } $activeArg = $node->args[$argumentPosition]; - if (!$activeArg instanceof \PhpParser\Node\Arg) { + if (!$activeArg instanceof Arg) { return null; } $activeArgValue = $activeArg->value; - if ($activeArgValue instanceof \PhpParser\Node\Expr\Array_) { + if ($activeArgValue instanceof Array_) { return null; } - if ($node instanceof \PhpParser\Node\Expr\MethodCall && $this->shouldSkipProcessMethodCall($node)) { + if ($node instanceof MethodCall && $this->shouldSkipProcessMethodCall($node)) { return null; } // type analyzer $activeValueType = $this->getType($activeArgValue); - if (!$activeValueType instanceof \PHPStan\Type\StringType) { + if (!$activeValueType instanceof StringType) { return null; } $this->processStringType($node, $argumentPosition, $activeArgValue); return $node; } - private function shouldSkipProcessMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall) : bool + private function shouldSkipProcessMethodCall(MethodCall $methodCall) : bool { $methodName = (string) $this->nodeNameResolver->getName($methodCall->name); return \in_array($methodName, self::EXCLUDED_PROCESS_METHOD_CALLS, \true); @@ -108,20 +108,20 @@ CODE_SAMPLE /** * @param \PhpParser\Node\Expr\New_|\PhpParser\Node\Expr\MethodCall $expr */ - private function processStringType($expr, int $argumentPosition, \PhpParser\Node\Expr $firstArgumentExpr) : void + private function processStringType($expr, int $argumentPosition, Expr $firstArgumentExpr) : void { - if ($firstArgumentExpr instanceof \PhpParser\Node\Expr\BinaryOp\Concat) { + if ($firstArgumentExpr instanceof Concat) { $arrayNode = $this->nodeTransformer->transformConcatToStringArray($firstArgumentExpr); - $expr->args[$argumentPosition] = new \PhpParser\Node\Arg($arrayNode); + $expr->args[$argumentPosition] = new Arg($arrayNode); return; } $args = $expr->getArgs(); - if ($firstArgumentExpr instanceof \PhpParser\Node\Expr\FuncCall && $this->isName($firstArgumentExpr, 'sprintf')) { + if ($firstArgumentExpr instanceof FuncCall && $this->isName($firstArgumentExpr, 'sprintf')) { $arrayNode = $this->nodeTransformer->transformSprintfToArray($firstArgumentExpr); if ($arrayNode !== null) { $args[$argumentPosition]->value = $arrayNode; } - } elseif ($firstArgumentExpr instanceof \PhpParser\Node\Scalar\String_) { + } elseif ($firstArgumentExpr instanceof String_) { $parts = $this->splitProcessCommandToItems($firstArgumentExpr->value); $args[$argumentPosition]->value = $this->nodeFactory->createArray($parts); } @@ -132,16 +132,16 @@ CODE_SAMPLE */ private function splitProcessCommandToItems(string $process) : array { - $privatesCaller = new \RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller(); - return $privatesCaller->callPrivateMethod(new \RectorPrefix20220607\Symfony\Component\Console\Input\StringInput(''), 'tokenize', [$process]); + $privatesCaller = new PrivatesCaller(); + return $privatesCaller->callPrivateMethod(new StringInput(''), 'tokenize', [$process]); } - private function processPreviousAssign(\PhpParser\Node $node, \PhpParser\Node\Expr $firstArgumentExpr) : void + private function processPreviousAssign(Node $node, Expr $firstArgumentExpr) : void { $assign = $this->findPreviousNodeAssign($node, $firstArgumentExpr); - if (!$assign instanceof \PhpParser\Node\Expr\Assign) { + if (!$assign instanceof Assign) { return; } - if (!$assign->expr instanceof \PhpParser\Node\Expr\FuncCall) { + if (!$assign->expr instanceof FuncCall) { return; } $funcCall = $assign->expr; @@ -153,11 +153,11 @@ CODE_SAMPLE $assign->expr = $arrayNode; } } - private function findPreviousNodeAssign(\PhpParser\Node $node, \PhpParser\Node\Expr $firstArgumentExpr) : ?\PhpParser\Node\Expr\Assign + private function findPreviousNodeAssign(Node $node, Expr $firstArgumentExpr) : ?Assign { /** @var Assign|null $assign */ - $assign = $this->betterNodeFinder->findFirstPrevious($node, function (\PhpParser\Node $checkedNode) use($firstArgumentExpr) : ?Assign { - if (!$checkedNode instanceof \PhpParser\Node\Expr\Assign) { + $assign = $this->betterNodeFinder->findFirstPrevious($node, function (Node $checkedNode) use($firstArgumentExpr) : ?Assign { + if (!$checkedNode instanceof Assign) { return null; } if (!$this->nodeComparator->areNodesEqual($checkedNode->var, $firstArgumentExpr)) { diff --git a/vendor/rector/rector-symfony/src/Rector/Property/JMSInjectPropertyToConstructorInjectionRector.php b/vendor/rector/rector-symfony/src/Rector/Property/JMSInjectPropertyToConstructorInjectionRector.php index f848360708f..aacad1a3716 100644 --- a/vendor/rector/rector-symfony/src/Rector/Property/JMSInjectPropertyToConstructorInjectionRector.php +++ b/vendor/rector/rector-symfony/src/Rector/Property/JMSInjectPropertyToConstructorInjectionRector.php @@ -14,8 +14,8 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\DependencyInjection\NodeManipulator\PropertyConstructorInjectionManipulator; use Rector\Symfony\TypeAnalyzer\JMSDITypeResolver; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * Can cover these cases: * - https://jmsyst.com/bundles/JMSDiExtraBundle/master/annotations @@ -23,7 +23,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; * * @see \Rector\Symfony\Tests\Rector\Property\JMSInjectPropertyToConstructorInjectionRector\JMSInjectPropertyToConstructorInjectionRectorTest */ -final class JMSInjectPropertyToConstructorInjectionRector extends \Rector\Core\Rector\AbstractRector +final class JMSInjectPropertyToConstructorInjectionRector extends AbstractRector { /** * @var string @@ -44,15 +44,15 @@ final class JMSInjectPropertyToConstructorInjectionRector extends \Rector\Core\R * @var \Rector\Core\Php\PhpVersionProvider */ private $phpVersionProvider; - public function __construct(\Rector\Symfony\TypeAnalyzer\JMSDITypeResolver $jmsDITypeResolver, \Rector\DependencyInjection\NodeManipulator\PropertyConstructorInjectionManipulator $propertyConstructorInjectionManipulator, \Rector\Core\Php\PhpVersionProvider $phpVersionProvider) + public function __construct(JMSDITypeResolver $jmsDITypeResolver, PropertyConstructorInjectionManipulator $propertyConstructorInjectionManipulator, PhpVersionProvider $phpVersionProvider) { $this->jmsDITypeResolver = $jmsDITypeResolver; $this->propertyConstructorInjectionManipulator = $propertyConstructorInjectionManipulator; $this->phpVersionProvider = $phpVersionProvider; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns properties with `@inject` to private properties and constructor injection', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Turns properties with `@inject` to private properties and constructor injection', [new CodeSample(<<<'CODE_SAMPLE' /** * @var SomeService * @inject @@ -77,36 +77,36 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Property::class]; + return [Property::class]; } /** * @param Property $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); - if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) { + if (!$phpDocInfo instanceof PhpDocInfo) { return null; } $doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass(self::INJECT_ANNOTATION_CLASS); - if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) { + if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return null; } $serviceType = $this->resolveServiceType($doctrineAnnotationTagValueNode, $phpDocInfo, $node); - if ($serviceType instanceof \PHPStan\Type\MixedType) { + if ($serviceType instanceof MixedType) { return null; } $this->propertyConstructorInjectionManipulator->refactor($node, $serviceType, $doctrineAnnotationTagValueNode); - if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::PROPERTY_PROMOTION)) { + if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::PROPERTY_PROMOTION)) { $this->removeNode($node); return null; } return $node; } - private function resolveServiceType(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\Stmt\Property $property) : \PHPStan\Type\Type + private function resolveServiceType(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, PhpDocInfo $phpDocInfo, Property $property) : Type { $serviceType = $phpDocInfo->getVarType(); - if (!$serviceType instanceof \PHPStan\Type\MixedType) { + if (!$serviceType instanceof MixedType) { return $serviceType; } return $this->jmsDITypeResolver->resolve($property, $doctrineAnnotationTagValueNode); diff --git a/vendor/rector/rector-symfony/src/Rector/Return_/SimpleFunctionAndFilterRector.php b/vendor/rector/rector-symfony/src/Rector/Return_/SimpleFunctionAndFilterRector.php index 66aa0a45947..f62f6b66b48 100644 --- a/vendor/rector/rector-symfony/src/Rector/Return_/SimpleFunctionAndFilterRector.php +++ b/vendor/rector/rector-symfony/src/Rector/Return_/SimpleFunctionAndFilterRector.php @@ -17,14 +17,14 @@ use PHPStan\Type\ObjectType; use PHPStan\Type\Type; use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * Covers https://twig.symfony.com/doc/1.x/deprecated.html#function * * @see \Rector\Symfony\Tests\Rector\Return_\SimpleFunctionAndFilterRector\SimpleFunctionAndFilterRectorTest */ -final class SimpleFunctionAndFilterRector extends \Rector\Core\Rector\AbstractRector +final class SimpleFunctionAndFilterRector extends AbstractRector { /** * @var array> @@ -35,13 +35,13 @@ final class SimpleFunctionAndFilterRector extends \Rector\Core\Rector\AbstractRe * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(ReflectionResolver $reflectionResolver) { $this->reflectionResolver = $reflectionResolver; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Changes Twig_Function_Method to Twig_SimpleFunction calls in Twig_Extension.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Changes Twig_Function_Method to Twig_SimpleFunction calls in Twig_Extension.', [new CodeSample(<<<'CODE_SAMPLE' class SomeExtension extends Twig_Extension { public function getFunctions() @@ -84,35 +84,35 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Stmt\Return_::class]; + return [Return_::class]; } /** * @param Return_ $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if ($node->expr === null) { return null; } $classReflection = $this->reflectionResolver->resolveClassReflection($node); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return null; } if (!$classReflection->isSubclassOf('Twig_Extension')) { return null; } - $classMethod = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassMethod::class); - if (!$classMethod instanceof \PhpParser\Node\Stmt\ClassMethod) { + $classMethod = $this->betterNodeFinder->findParentType($node, ClassMethod::class); + if (!$classMethod instanceof ClassMethod) { return null; } if (!$this->nodeNameResolver->isNames($classMethod, ['getFunctions', 'getFilters'])) { return null; } - $this->traverseNodesWithCallable($node->expr, function (\PhpParser\Node $node) : ?Node { - if (!$node instanceof \PhpParser\Node\Expr\ArrayItem) { + $this->traverseNodesWithCallable($node->expr, function (Node $node) : ?Node { + if (!$node instanceof ArrayItem) { return null; } - if (!$node->value instanceof \PhpParser\Node\Expr\New_) { + if (!$node->value instanceof New_) { return null; } $newObjectType = $this->nodeTypeResolver->getType($node->value); @@ -121,23 +121,23 @@ CODE_SAMPLE }); return $node; } - private function processArrayItem(\PhpParser\Node\Expr\ArrayItem $arrayItem, \PHPStan\Type\Type $newNodeType) : void + private function processArrayItem(ArrayItem $arrayItem, Type $newNodeType) : void { foreach (self::OLD_TO_NEW_CLASSES as $oldClass => $newClass) { - $oldClassObjectType = new \PHPStan\Type\ObjectType($oldClass); + $oldClassObjectType = new ObjectType($oldClass); if (!$oldClassObjectType->equals($newNodeType)) { continue; } - if (!$arrayItem->key instanceof \PhpParser\Node\Scalar\String_) { + if (!$arrayItem->key instanceof String_) { continue; } - if (!$arrayItem->value instanceof \PhpParser\Node\Expr\New_) { + if (!$arrayItem->value instanceof New_) { continue; } // match! $filterName = $this->valueResolver->getValue($arrayItem->key); $arrayItem->key = null; - $arrayItem->value->class = new \PhpParser\Node\Name\FullyQualified($newClass); + $arrayItem->value->class = new FullyQualified($newClass); $oldArguments = $arrayItem->value->getArgs(); $this->decorateArrayItem($arrayItem, $oldArguments, $filterName); break; @@ -146,21 +146,21 @@ CODE_SAMPLE /** * @param Arg[] $oldArguments */ - private function decorateArrayItem(\PhpParser\Node\Expr\ArrayItem $arrayItem, array $oldArguments, string $filterName) : void + private function decorateArrayItem(ArrayItem $arrayItem, array $oldArguments, string $filterName) : void { /** @var New_ $new */ $new = $arrayItem->value; - if ($oldArguments[0]->value instanceof \PhpParser\Node\Expr\Array_) { + if ($oldArguments[0]->value instanceof Array_) { // already array, just shift it - $new->args = \array_merge([new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\String_($filterName))], $oldArguments); + $new->args = \array_merge([new Arg(new String_($filterName))], $oldArguments); return; } // not array yet, wrap to one $arrayItems = []; foreach ($oldArguments as $oldArgument) { - $arrayItems[] = new \PhpParser\Node\Expr\ArrayItem($oldArgument->value); + $arrayItems[] = new ArrayItem($oldArgument->value); } - $new->args[0] = new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\String_($filterName)); - $new->args[1] = new \PhpParser\Node\Arg(new \PhpParser\Node\Expr\Array_($arrayItems)); + $new->args[0] = new Arg(new String_($filterName)); + $new->args[1] = new Arg(new Array_($arrayItems)); } } diff --git a/vendor/rector/rector-symfony/src/Rector/StaticCall/AddMessageToEqualsResponseCodeRector.php b/vendor/rector/rector-symfony/src/Rector/StaticCall/AddMessageToEqualsResponseCodeRector.php index 034c00fdc7b..01e29897900 100644 --- a/vendor/rector/rector-symfony/src/Rector/StaticCall/AddMessageToEqualsResponseCodeRector.php +++ b/vendor/rector/rector-symfony/src/Rector/StaticCall/AddMessageToEqualsResponseCodeRector.php @@ -12,16 +12,16 @@ use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Expr\Variable; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\StaticCall\AddMessageToEqualsResponseCodeRector\AddMessageToEqualsResponseCodeRectorTest */ -final class AddMessageToEqualsResponseCodeRector extends \Rector\Core\Rector\AbstractRector +final class AddMessageToEqualsResponseCodeRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add response content to response code assert, so it is easier to debug', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Add response content to response code assert, so it is easier to debug', [new CodeSample(<<<'CODE_SAMPLE' use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Response; @@ -59,12 +59,12 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class, \PhpParser\Node\Expr\MethodCall::class]; + return [StaticCall::class, MethodCall::class]; } /** * @param StaticCall|MethodCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node->name, 'assertEquals')) { return null; @@ -74,41 +74,41 @@ CODE_SAMPLE return null; } $firstArg = $node->args[0]; - if (!$firstArg instanceof \PhpParser\Node\Arg) { + if (!$firstArg instanceof Arg) { return null; } if (!$this->isHttpRequestArgument($firstArg->value)) { return null; } $secondArg = $node->args[1]; - if (!$secondArg instanceof \PhpParser\Node\Arg) { + if (!$secondArg instanceof Arg) { return null; } $parentVariable = $this->getParentOfGetStatusCode($secondArg->value); - if (!$parentVariable instanceof \PhpParser\Node\Expr) { + if (!$parentVariable instanceof Expr) { return null; } - $getContentMethodCall = new \PhpParser\Node\Expr\MethodCall($parentVariable, 'getContent'); - $node->args[2] = new \PhpParser\Node\Arg($getContentMethodCall); + $getContentMethodCall = new MethodCall($parentVariable, 'getContent'); + $node->args[2] = new Arg($getContentMethodCall); return $node; } /** * $this->assertX(Response::SOME_STATUS) */ - private function isHttpRequestArgument(\PhpParser\Node\Expr $expr) : bool + private function isHttpRequestArgument(Expr $expr) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\ClassConstFetch) { + if (!$expr instanceof ClassConstFetch) { return \false; } - return $this->isObjectType($expr->class, new \PHPStan\Type\ObjectType('Symfony\\Component\\HttpFoundation\\Response')); + return $this->isObjectType($expr->class, new ObjectType('Symfony\\Component\\HttpFoundation\\Response')); } /** * @return Variable|MethodCall|Expr|null */ - private function getParentOfGetStatusCode(\PhpParser\Node\Expr $expr) : ?\PhpParser\Node + private function getParentOfGetStatusCode(Expr $expr) : ?Node { $currentNode = $expr; - while ($currentNode instanceof \PhpParser\Node\Expr\MethodCall) { + while ($currentNode instanceof MethodCall) { if ($this->isName($currentNode->name, 'getStatusCode')) { return $currentNode->var; } diff --git a/vendor/rector/rector-symfony/src/Rector/StaticCall/BinaryFileResponseCreateToNewInstanceRector.php b/vendor/rector/rector-symfony/src/Rector/StaticCall/BinaryFileResponseCreateToNewInstanceRector.php index eb8968c7ac6..881d075d0b4 100644 --- a/vendor/rector/rector-symfony/src/Rector/StaticCall/BinaryFileResponseCreateToNewInstanceRector.php +++ b/vendor/rector/rector-symfony/src/Rector/StaticCall/BinaryFileResponseCreateToNewInstanceRector.php @@ -8,17 +8,17 @@ use PhpParser\Node\Expr\New_; use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Name; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see https://github.com/symfony/symfony/blob/5.x/UPGRADE-5.2.md#httpfoundation * @see \Rector\Symfony\Tests\Rector\StaticCall\BinaryFileResponseCreateToNewInstanceRector\BinaryFileResponseCreateToNewInstanceRectorTest */ -final class BinaryFileResponseCreateToNewInstanceRector extends \Rector\Core\Rector\AbstractRector +final class BinaryFileResponseCreateToNewInstanceRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change deprecated BinaryFileResponse::create() to use __construct() instead', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Change deprecated BinaryFileResponse::create() to use __construct() instead', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\HttpFoundation; class SomeClass @@ -47,14 +47,14 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class]; + return [StaticCall::class]; } /** * @param StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->class instanceof \PhpParser\Node\Name) { + if (!$node->class instanceof Name) { return null; } if (!$this->isName($node->class, 'Symfony\\Component\\HttpFoundation\\BinaryFileResponse')) { @@ -67,6 +67,6 @@ CODE_SAMPLE if ($args === []) { $args[] = $this->nodeFactory->createArg($this->nodeFactory->createNull()); } - return new \PhpParser\Node\Expr\New_($node->class, $args); + return new New_($node->class, $args); } } diff --git a/vendor/rector/rector-symfony/src/Rector/StaticCall/ParseFileRector.php b/vendor/rector/rector-symfony/src/Rector/StaticCall/ParseFileRector.php index 6110e441a0b..f256f2c69ba 100644 --- a/vendor/rector/rector-symfony/src/Rector/StaticCall/ParseFileRector.php +++ b/vendor/rector/rector-symfony/src/Rector/StaticCall/ParseFileRector.php @@ -14,12 +14,12 @@ use Rector\Core\Contract\PhpParser\NodePrinterInterface; use Rector\Core\Rector\AbstractRector; use Rector\Core\Util\StringUtils; use Rector\NodeTypeResolver\Node\AttributeKey; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\StaticCall\ParseFileRector\ParseFileRectorTest */ -final class ParseFileRector extends \Rector\Core\Rector\AbstractRector +final class ParseFileRector extends AbstractRector { /** * @var string @@ -41,13 +41,13 @@ final class ParseFileRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\Core\Contract\PhpParser\NodePrinterInterface */ private $nodePrinter; - public function __construct(\Rector\Core\Contract\PhpParser\NodePrinterInterface $nodePrinter) + public function __construct(NodePrinterInterface $nodePrinter) { $this->nodePrinter = $nodePrinter; } - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replaces deprecated Yaml::parse() of file argument with file contents', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE' + return new RuleDefinition('Replaces deprecated Yaml::parse() of file argument with file contents', [new CodeSample(<<<'CODE_SAMPLE' use Symfony\Component\Yaml\Yaml; $parsedFile = Yaml::parse('someFile.yml'); @@ -64,53 +64,53 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class]; + return [StaticCall::class]; } /** * Process Node of matched type * * @param StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { if (!$this->isName($node->name, 'parse')) { return null; } - if (!$this->isObjectType($node->class, new \PHPStan\Type\ObjectType('Symfony\\Component\\Yaml\\Yaml'))) { + if (!$this->isObjectType($node->class, new ObjectType('Symfony\\Component\\Yaml\\Yaml'))) { return null; } if (!$this->isArgumentYamlFile($node)) { return null; } $funcCall = $this->nodeFactory->createFuncCall('file_get_contents', [$node->args[0]]); - $node->args[0] = new \PhpParser\Node\Arg($funcCall); + $node->args[0] = new Arg($funcCall); return $node; } - private function isArgumentYamlFile(\PhpParser\Node\Expr\StaticCall $staticCall) : bool + private function isArgumentYamlFile(StaticCall $staticCall) : bool { $firstArg = $staticCall->args[0]; - if (!$firstArg instanceof \PhpParser\Node\Arg) { + if (!$firstArg instanceof Arg) { return \false; } $possibleFileNode = $firstArg->value; $possibleFileNodeAsString = $this->nodePrinter->print($possibleFileNode); // is yml/yaml file - if (\Rector\Core\Util\StringUtils::isMatch($possibleFileNodeAsString, self::YAML_SUFFIX_IN_QUOTE_REGEX)) { + if (StringUtils::isMatch($possibleFileNodeAsString, self::YAML_SUFFIX_IN_QUOTE_REGEX)) { return \true; } // is probably a file variable - if (\Rector\Core\Util\StringUtils::isMatch($possibleFileNodeAsString, self::FILE_SUFFIX_REGEX)) { + if (StringUtils::isMatch($possibleFileNodeAsString, self::FILE_SUFFIX_REGEX)) { return \true; } // try to detect current value - $nodeScope = $possibleFileNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); - if (!$nodeScope instanceof \PHPStan\Analyser\Scope) { + $nodeScope = $possibleFileNode->getAttribute(AttributeKey::SCOPE); + if (!$nodeScope instanceof Scope) { return \false; } $nodeType = $nodeScope->getType($possibleFileNode); - if (!$nodeType instanceof \PHPStan\Type\Constant\ConstantStringType) { + if (!$nodeType instanceof ConstantStringType) { return \false; } - return (bool) \RectorPrefix20220607\Nette\Utils\Strings::match($nodeType->getValue(), self::YAML_SUFFIX_REGEX); + return (bool) Strings::match($nodeType->getValue(), self::YAML_SUFFIX_REGEX); } } diff --git a/vendor/rector/rector-symfony/src/Rector/StaticCall/ProcessBuilderInstanceRector.php b/vendor/rector/rector-symfony/src/Rector/StaticCall/ProcessBuilderInstanceRector.php index 3ff5f66eb77..96bcae2f524 100644 --- a/vendor/rector/rector-symfony/src/Rector/StaticCall/ProcessBuilderInstanceRector.php +++ b/vendor/rector/rector-symfony/src/Rector/StaticCall/ProcessBuilderInstanceRector.php @@ -8,30 +8,30 @@ use PhpParser\Node\Expr\New_; use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Name; use Rector\Core\Rector\AbstractRector; -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; +use RectorPrefix20220607\Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Rector\StaticCall\ProcessBuilderInstanceRector\ProcessBuilderInstanceRectorTest */ -final class ProcessBuilderInstanceRector extends \Rector\Core\Rector\AbstractRector +final class ProcessBuilderInstanceRector extends AbstractRector { - public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition + public function getRuleDefinition() : RuleDefinition { - return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Turns `ProcessBuilder::instance()` to new ProcessBuilder in Process in Symfony. Part of multi-step Rector.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample('$processBuilder = Symfony\\Component\\Process\\ProcessBuilder::instance($args);', '$processBuilder = new Symfony\\Component\\Process\\ProcessBuilder($args);')]); + return new RuleDefinition('Turns `ProcessBuilder::instance()` to new ProcessBuilder in Process in Symfony. Part of multi-step Rector.', [new CodeSample('$processBuilder = Symfony\\Component\\Process\\ProcessBuilder::instance($args);', '$processBuilder = new Symfony\\Component\\Process\\ProcessBuilder($args);')]); } /** * @return array> */ public function getNodeTypes() : array { - return [\PhpParser\Node\Expr\StaticCall::class]; + return [StaticCall::class]; } /** * @param StaticCall $node */ - public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node + public function refactor(Node $node) : ?Node { - if (!$node->class instanceof \PhpParser\Node\Name) { + if (!$node->class instanceof Name) { return null; } if (!$this->isName($node->class, 'Symfony\\Component\\Process\\ProcessBuilder')) { @@ -40,6 +40,6 @@ final class ProcessBuilderInstanceRector extends \Rector\Core\Rector\AbstractRec if (!$this->isName($node->name, 'create')) { return null; } - return new \PhpParser\Node\Expr\New_($node->class, $node->args); + return new New_($node->class, $node->args); } } diff --git a/vendor/rector/rector-symfony/src/Set/JMSSetList.php b/vendor/rector/rector-symfony/src/Set/JMSSetList.php index 80a520a559b..36cd857219b 100644 --- a/vendor/rector/rector-symfony/src/Set/JMSSetList.php +++ b/vendor/rector/rector-symfony/src/Set/JMSSetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Symfony\Set; use Rector\Set\Contract\SetListInterface; -final class JMSSetList implements \Rector\Set\Contract\SetListInterface +final class JMSSetList implements SetListInterface { /** * @var string diff --git a/vendor/rector/rector-symfony/src/Set/SensiolabsSetList.php b/vendor/rector/rector-symfony/src/Set/SensiolabsSetList.php index 56e9e954b39..098a1fd601f 100644 --- a/vendor/rector/rector-symfony/src/Set/SensiolabsSetList.php +++ b/vendor/rector/rector-symfony/src/Set/SensiolabsSetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Symfony\Set; use Rector\Set\Contract\SetListInterface; -final class SensiolabsSetList implements \Rector\Set\Contract\SetListInterface +final class SensiolabsSetList implements SetListInterface { /** * @var string diff --git a/vendor/rector/rector-symfony/src/Set/SwiftmailerSetList.php b/vendor/rector/rector-symfony/src/Set/SwiftmailerSetList.php index 5a189266b7a..c4b1746ec4a 100644 --- a/vendor/rector/rector-symfony/src/Set/SwiftmailerSetList.php +++ b/vendor/rector/rector-symfony/src/Set/SwiftmailerSetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Symfony\Set; use Rector\Set\Contract\SetListInterface; -final class SwiftmailerSetList implements \Rector\Set\Contract\SetListInterface +final class SwiftmailerSetList implements SetListInterface { /** * @var string diff --git a/vendor/rector/rector-symfony/src/Set/SymfonyLevelSetList.php b/vendor/rector/rector-symfony/src/Set/SymfonyLevelSetList.php index bbe7540f8cb..e2ca95a1548 100644 --- a/vendor/rector/rector-symfony/src/Set/SymfonyLevelSetList.php +++ b/vendor/rector/rector-symfony/src/Set/SymfonyLevelSetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Symfony\Set; use Rector\Set\Contract\SetListInterface; -final class SymfonyLevelSetList implements \Rector\Set\Contract\SetListInterface +final class SymfonyLevelSetList implements SetListInterface { /** * @var string diff --git a/vendor/rector/rector-symfony/src/Set/SymfonySetList.php b/vendor/rector/rector-symfony/src/Set/SymfonySetList.php index c59a9d7fdd7..e44c10111cd 100644 --- a/vendor/rector/rector-symfony/src/Set/SymfonySetList.php +++ b/vendor/rector/rector-symfony/src/Set/SymfonySetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Symfony\Set; use Rector\Set\Contract\SetListInterface; -final class SymfonySetList implements \Rector\Set\Contract\SetListInterface +final class SymfonySetList implements SetListInterface { /** * @var string diff --git a/vendor/rector/rector-symfony/src/Set/TwigSetList.php b/vendor/rector/rector-symfony/src/Set/TwigSetList.php index f567828ffab..0c99ffdc230 100644 --- a/vendor/rector/rector-symfony/src/Set/TwigSetList.php +++ b/vendor/rector/rector-symfony/src/Set/TwigSetList.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Symfony\Set; use Rector\Set\Contract\SetListInterface; -final class TwigSetList implements \Rector\Set\Contract\SetListInterface +final class TwigSetList implements SetListInterface { /** * @var string diff --git a/vendor/rector/rector-symfony/src/TypeAnalyzer/ArrayUnionResponseTypeAnalyzer.php b/vendor/rector/rector-symfony/src/TypeAnalyzer/ArrayUnionResponseTypeAnalyzer.php index 4b8ae6d63ed..d778ea0073e 100644 --- a/vendor/rector/rector-symfony/src/TypeAnalyzer/ArrayUnionResponseTypeAnalyzer.php +++ b/vendor/rector/rector-symfony/src/TypeAnalyzer/ArrayUnionResponseTypeAnalyzer.php @@ -13,15 +13,15 @@ final class ArrayUnionResponseTypeAnalyzer /** * @param class-string $className */ - public function isArrayUnionResponseType(\PHPStan\Type\Type $type, string $className) : bool + public function isArrayUnionResponseType(Type $type, string $className) : bool { - if (!$type instanceof \PHPStan\Type\UnionType) { + if (!$type instanceof UnionType) { return \false; } $hasArrayType = \false; $hasResponseType = \false; foreach ($type->getTypes() as $unionedType) { - if ($unionedType instanceof \PHPStan\Type\ArrayType) { + if ($unionedType instanceof ArrayType) { $hasArrayType = \true; continue; } @@ -39,12 +39,12 @@ final class ArrayUnionResponseTypeAnalyzer /** * @param class-string $className */ - private function isTypeOfClassName(\PHPStan\Type\Type $type, string $className) : bool + private function isTypeOfClassName(Type $type, string $className) : bool { - if (!$type instanceof \PHPStan\Type\TypeWithClassName) { + if (!$type instanceof TypeWithClassName) { return \false; } - $objectType = new \PHPStan\Type\ObjectType($className); + $objectType = new ObjectType($className); return $objectType->isSuperTypeOf($type)->yes(); } } diff --git a/vendor/rector/rector-symfony/src/TypeAnalyzer/ContainerAwareAnalyzer.php b/vendor/rector/rector-symfony/src/TypeAnalyzer/ContainerAwareAnalyzer.php index 375478e58d4..16c098532bb 100644 --- a/vendor/rector/rector-symfony/src/TypeAnalyzer/ContainerAwareAnalyzer.php +++ b/vendor/rector/rector-symfony/src/TypeAnalyzer/ContainerAwareAnalyzer.php @@ -17,12 +17,12 @@ final class ContainerAwareAnalyzer * @var \Rector\NodeTypeResolver\NodeTypeResolver */ private $nodeTypeResolver; - public function __construct(\Rector\NodeTypeResolver\NodeTypeResolver $nodeTypeResolver) + public function __construct(NodeTypeResolver $nodeTypeResolver) { $this->nodeTypeResolver = $nodeTypeResolver; - $this->getMethodAwareObjectTypes = [new \PHPStan\Type\ObjectType('Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController'), new \PHPStan\Type\ObjectType('Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller'), new \PHPStan\Type\ObjectType('Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerTrait')]; + $this->getMethodAwareObjectTypes = [new ObjectType('Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController'), new ObjectType('Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller'), new ObjectType('Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerTrait')]; } - public function isGetMethodAwareType(\PhpParser\Node\Expr $expr) : bool + public function isGetMethodAwareType(Expr $expr) : bool { return $this->nodeTypeResolver->isObjectTypes($expr, $this->getMethodAwareObjectTypes); } diff --git a/vendor/rector/rector-symfony/src/TypeAnalyzer/ControllerAnalyzer.php b/vendor/rector/rector-symfony/src/TypeAnalyzer/ControllerAnalyzer.php index fde85713196..15bde292d04 100644 --- a/vendor/rector/rector-symfony/src/TypeAnalyzer/ControllerAnalyzer.php +++ b/vendor/rector/rector-symfony/src/TypeAnalyzer/ControllerAnalyzer.php @@ -19,42 +19,42 @@ final class ControllerAnalyzer * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; - public function __construct(\Rector\Core\Reflection\ReflectionResolver $reflectionResolver) + public function __construct(ReflectionResolver $reflectionResolver) { $this->reflectionResolver = $reflectionResolver; } - public function isController(\PhpParser\Node\Expr $expr) : bool + public function isController(Expr $expr) : bool { - $scope = $expr->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + $scope = $expr->getAttribute(AttributeKey::SCOPE); // might be missing in a trait - if (!$scope instanceof \PHPStan\Analyser\Scope) { + if (!$scope instanceof Scope) { return \false; } $nodeType = $scope->getType($expr); - if (!$nodeType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$nodeType instanceof TypeWithClassName) { return \false; } - if ($nodeType instanceof \PHPStan\Type\ThisType) { + if ($nodeType instanceof ThisType) { $nodeType = $nodeType->getStaticObjectType(); } - if (!$nodeType instanceof \PHPStan\Type\ObjectType) { + if (!$nodeType instanceof ObjectType) { return \false; } $classReflection = $nodeType->getClassReflection(); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } return $this->isControllerClassReflection($classReflection); } - public function isInsideController(\PhpParser\Node $node) : bool + public function isInsideController(Node $node) : bool { $classReflection = $this->reflectionResolver->resolveClassReflection($node); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return \false; } return $this->isControllerClassReflection($classReflection); } - private function isControllerClassReflection(\PHPStan\Reflection\ClassReflection $classReflection) : bool + private function isControllerClassReflection(ClassReflection $classReflection) : bool { if ($classReflection->isSubclassOf('Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller')) { return \true; diff --git a/vendor/rector/rector-symfony/src/TypeAnalyzer/JMSDITypeResolver.php b/vendor/rector/rector-symfony/src/TypeAnalyzer/JMSDITypeResolver.php index 7023fcf5bd6..aad97017007 100644 --- a/vendor/rector/rector-symfony/src/TypeAnalyzer/JMSDITypeResolver.php +++ b/vendor/rector/rector-symfony/src/TypeAnalyzer/JMSDITypeResolver.php @@ -43,7 +43,7 @@ final class JMSDITypeResolver * @var \Rector\Core\Provider\CurrentFileProvider */ private $currentFileProvider; - public function __construct(\Rector\Symfony\DataProvider\ServiceMapProvider $serviceMapProvider, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \PHPStan\Reflection\ReflectionProvider $reflectionProvider, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider) + public function __construct(ServiceMapProvider $serviceMapProvider, PhpDocInfoFactory $phpDocInfoFactory, ReflectionProvider $reflectionProvider, NodeNameResolver $nodeNameResolver, CurrentFileProvider $currentFileProvider) { $this->serviceMapProvider = $serviceMapProvider; $this->phpDocInfoFactory = $phpDocInfoFactory; @@ -51,23 +51,23 @@ final class JMSDITypeResolver $this->nodeNameResolver = $nodeNameResolver; $this->currentFileProvider = $currentFileProvider; } - public function resolve(\PhpParser\Node\Stmt\Property $property, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : \PHPStan\Type\Type + public function resolve(Property $property, DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : Type { $serviceMap = $this->serviceMapProvider->provide(); $serviceName = $this->resolveServiceName($doctrineAnnotationTagValueNode, $property); $serviceType = $this->resolveFromServiceName($serviceName, $serviceMap); - if (!$serviceType instanceof \PHPStan\Type\MixedType) { + if (!$serviceType instanceof MixedType) { return $serviceType; } // 3. service is in @var annotation $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); $varType = $phpDocInfo->getVarType(); - if (!$varType instanceof \PHPStan\Type\MixedType) { + if (!$varType instanceof MixedType) { return $varType; } // the @var is missing and service name was not found → report it $this->reportServiceNotFound($serviceName); - return new \PHPStan\Type\MixedType(); + return new MixedType(); } private function reportServiceNotFound(?string $serviceName) : void { @@ -75,18 +75,18 @@ final class JMSDITypeResolver return; } $file = $this->currentFileProvider->getFile(); - if (!$file instanceof \Rector\Core\ValueObject\Application\File) { - throw new \Rector\Core\Exception\ShouldNotHappenException(); + if (!$file instanceof File) { + throw new ShouldNotHappenException(); } $errorMessage = \sprintf('Service "%s" was not found in DI Container of your Symfony App.', $serviceName); - throw new \Rector\Core\Exception\ShouldNotHappenException($errorMessage); + throw new ShouldNotHappenException($errorMessage); } - private function resolveFromServiceName(string $serviceName, \Rector\Symfony\ValueObject\ServiceMap\ServiceMap $serviceMap) : \PHPStan\Type\Type + private function resolveFromServiceName(string $serviceName, ServiceMap $serviceMap) : Type { // 1. service name-type if ($this->reflectionProvider->hasClass($serviceName)) { // single class service - return new \PHPStan\Type\ObjectType($serviceName); + return new ObjectType($serviceName); } // 2. service name if ($serviceMap->hasService($serviceName)) { @@ -95,9 +95,9 @@ final class JMSDITypeResolver return $serviceType; } } - return new \PHPStan\Type\MixedType(); + return new MixedType(); } - private function resolveServiceName(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, \PhpParser\Node\Stmt\Property $property) : string + private function resolveServiceName(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, Property $property) : string { $serviceNameParameter = $doctrineAnnotationTagValueNode->getValueWithoutQuotes('serviceName'); if (\is_string($serviceNameParameter)) { diff --git a/vendor/rector/rector-symfony/src/TypeDeclaration/ReturnTypeDeclarationUpdater.php b/vendor/rector/rector-symfony/src/TypeDeclaration/ReturnTypeDeclarationUpdater.php index 985b6d204da..4ffacdfe54b 100644 --- a/vendor/rector/rector-symfony/src/TypeDeclaration/ReturnTypeDeclarationUpdater.php +++ b/vendor/rector/rector-symfony/src/TypeDeclaration/ReturnTypeDeclarationUpdater.php @@ -31,7 +31,7 @@ final class ReturnTypeDeclarationUpdater * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory */ private $phpDocInfoFactory; - public function __construct(\Rector\Core\Php\PhpVersionProvider $phpVersionProvider, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory) + public function __construct(PhpVersionProvider $phpVersionProvider, StaticTypeMapper $staticTypeMapper, PhpDocInfoFactory $phpDocInfoFactory) { $this->phpVersionProvider = $phpVersionProvider; $this->staticTypeMapper = $staticTypeMapper; @@ -40,7 +40,7 @@ final class ReturnTypeDeclarationUpdater /** * @param class-string $className */ - public function updateClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $className) : void + public function updateClassMethod(ClassMethod $classMethod, string $className) : void { $this->updatePhpDoc($classMethod, $className); $this->updatePhp($classMethod, $className); @@ -48,27 +48,27 @@ final class ReturnTypeDeclarationUpdater /** * @param class-string $className */ - private function updatePhpDoc(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $className) : void + private function updatePhpDoc(ClassMethod $classMethod, string $className) : void { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); $returnTagValueNode = $phpDocInfo->getReturnTagValue(); - if (!$returnTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode) { + if (!$returnTagValueNode instanceof ReturnTagValueNode) { return; } $returnStaticType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($returnTagValueNode->type, $classMethod); - if ($returnStaticType instanceof \PHPStan\Type\ArrayType || $returnStaticType instanceof \PHPStan\Type\UnionType) { - $returnTagValueNode->type = new \Rector\BetterPhpDocParser\ValueObject\Type\FullyQualifiedIdentifierTypeNode($className); + if ($returnStaticType instanceof ArrayType || $returnStaticType instanceof UnionType) { + $returnTagValueNode->type = new FullyQualifiedIdentifierTypeNode($className); } } /** * @param class-string $className */ - private function updatePhp(\PhpParser\Node\Stmt\ClassMethod $classMethod, string $className) : void + private function updatePhp(ClassMethod $classMethod, string $className) : void { - if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::SCALAR_TYPES)) { + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::SCALAR_TYPES)) { return; } - $objectType = new \PHPStan\Type\ObjectType($className); + $objectType = new ObjectType($className); // change return type if ($classMethod->returnType !== null) { $returnType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($classMethod->returnType); @@ -76,6 +76,6 @@ final class ReturnTypeDeclarationUpdater return; } } - $classMethod->returnType = new \PhpParser\Node\Name\FullyQualified($className); + $classMethod->returnType = new FullyQualified($className); } } diff --git a/vendor/rector/rector-symfony/src/ValueObject/EventReferenceToMethodName.php b/vendor/rector/rector-symfony/src/ValueObject/EventReferenceToMethodName.php index 3eec548ddf5..e371f9386b8 100644 --- a/vendor/rector/rector-symfony/src/ValueObject/EventReferenceToMethodName.php +++ b/vendor/rector/rector-symfony/src/ValueObject/EventReferenceToMethodName.php @@ -5,7 +5,7 @@ namespace Rector\Symfony\ValueObject; use PhpParser\Node\Expr\ClassConstFetch; use Rector\Symfony\Contract\EventReferenceToMethodNameInterface; -final class EventReferenceToMethodName implements \Rector\Symfony\Contract\EventReferenceToMethodNameInterface +final class EventReferenceToMethodName implements EventReferenceToMethodNameInterface { /** * @readonly @@ -17,12 +17,12 @@ final class EventReferenceToMethodName implements \Rector\Symfony\Contract\Event * @var string */ private $methodName; - public function __construct(\PhpParser\Node\Expr\ClassConstFetch $classConstFetch, string $methodName) + public function __construct(ClassConstFetch $classConstFetch, string $methodName) { $this->classConstFetch = $classConstFetch; $this->methodName = $methodName; } - public function getClassConstFetch() : \PhpParser\Node\Expr\ClassConstFetch + public function getClassConstFetch() : ClassConstFetch { return $this->classConstFetch; } diff --git a/vendor/rector/rector-symfony/src/ValueObject/EventReferenceToMethodNameWithPriority.php b/vendor/rector/rector-symfony/src/ValueObject/EventReferenceToMethodNameWithPriority.php index d6df8ffeeaf..14baaa54f41 100644 --- a/vendor/rector/rector-symfony/src/ValueObject/EventReferenceToMethodNameWithPriority.php +++ b/vendor/rector/rector-symfony/src/ValueObject/EventReferenceToMethodNameWithPriority.php @@ -5,7 +5,7 @@ namespace Rector\Symfony\ValueObject; use PhpParser\Node\Expr\ClassConstFetch; use Rector\Symfony\Contract\EventReferenceToMethodNameInterface; -final class EventReferenceToMethodNameWithPriority implements \Rector\Symfony\Contract\EventReferenceToMethodNameInterface +final class EventReferenceToMethodNameWithPriority implements EventReferenceToMethodNameInterface { /** * @readonly @@ -22,13 +22,13 @@ final class EventReferenceToMethodNameWithPriority implements \Rector\Symfony\Co * @var int */ private $priority; - public function __construct(\PhpParser\Node\Expr\ClassConstFetch $classConstFetch, string $methodName, int $priority) + public function __construct(ClassConstFetch $classConstFetch, string $methodName, int $priority) { $this->classConstFetch = $classConstFetch; $this->methodName = $methodName; $this->priority = $priority; } - public function getClassConstFetch() : \PhpParser\Node\Expr\ClassConstFetch + public function getClassConstFetch() : ClassConstFetch { return $this->classConstFetch; } diff --git a/vendor/rector/rector-symfony/src/ValueObject/ReplaceServiceArgument.php b/vendor/rector/rector-symfony/src/ValueObject/ReplaceServiceArgument.php index 58098910539..e8aa1783f49 100644 --- a/vendor/rector/rector-symfony/src/ValueObject/ReplaceServiceArgument.php +++ b/vendor/rector/rector-symfony/src/ValueObject/ReplaceServiceArgument.php @@ -19,7 +19,7 @@ final class ReplaceServiceArgument /** * @param mixed $oldValue */ - public function __construct($oldValue, \PhpParser\Node\Expr $newValueExpr) + public function __construct($oldValue, Expr $newValueExpr) { $this->oldValue = $oldValue; $this->newValueExpr = $newValueExpr; @@ -31,7 +31,7 @@ final class ReplaceServiceArgument { return $this->oldValue; } - public function getNewValueExpr() : \PhpParser\Node\Expr + public function getNewValueExpr() : Expr { return $this->newValueExpr; } diff --git a/vendor/rector/rector-symfony/src/ValueObject/ServiceDefinition.php b/vendor/rector/rector-symfony/src/ValueObject/ServiceDefinition.php index ab3d3053f47..9b401c59614 100644 --- a/vendor/rector/rector-symfony/src/ValueObject/ServiceDefinition.php +++ b/vendor/rector/rector-symfony/src/ValueObject/ServiceDefinition.php @@ -75,7 +75,7 @@ final class ServiceDefinition { return $this->tags; } - public function getTag(string $name) : ?\Rector\Symfony\Contract\Tag\TagInterface + public function getTag(string $name) : ?TagInterface { foreach ($this->tags as $tag) { if ($tag->getName() !== $name) { diff --git a/vendor/rector/rector-symfony/src/ValueObject/ServiceMap/ServiceMap.php b/vendor/rector/rector-symfony/src/ValueObject/ServiceMap/ServiceMap.php index 9c7ddd10ea7..d2bc5b16c45 100644 --- a/vendor/rector/rector-symfony/src/ValueObject/ServiceMap/ServiceMap.php +++ b/vendor/rector/rector-symfony/src/ValueObject/ServiceMap/ServiceMap.php @@ -24,17 +24,17 @@ final class ServiceMap { return isset($this->services[$id]); } - public function getServiceType(string $id) : ?\PHPStan\Type\Type + public function getServiceType(string $id) : ?Type { $serviceDefinition = $this->getService($id); - if (!$serviceDefinition instanceof \Rector\Symfony\ValueObject\ServiceDefinition) { + if (!$serviceDefinition instanceof ServiceDefinition) { return null; } $class = $serviceDefinition->getClass(); if ($class === null) { return null; } - return new \PHPStan\Type\ObjectType($class); + return new ObjectType($class); } /** * @return ServiceDefinition[] @@ -53,7 +53,7 @@ final class ServiceMap } return $servicesWithTag; } - private function getService(string $id) : ?\Rector\Symfony\ValueObject\ServiceDefinition + private function getService(string $id) : ?ServiceDefinition { return $this->services[$id] ?? null; } diff --git a/vendor/rector/rector-symfony/src/ValueObject/Tag.php b/vendor/rector/rector-symfony/src/ValueObject/Tag.php index 7aeba6fea83..d391fa34232 100644 --- a/vendor/rector/rector-symfony/src/ValueObject/Tag.php +++ b/vendor/rector/rector-symfony/src/ValueObject/Tag.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Symfony\ValueObject; use Rector\Symfony\Contract\Tag\TagInterface; -final class Tag implements \Rector\Symfony\Contract\Tag\TagInterface +final class Tag implements TagInterface { /** * @readonly diff --git a/vendor/rector/rector-symfony/src/ValueObject/Tag/EventListenerTag.php b/vendor/rector/rector-symfony/src/ValueObject/Tag/EventListenerTag.php index 17c5d49319d..28b64bc05cb 100644 --- a/vendor/rector/rector-symfony/src/ValueObject/Tag/EventListenerTag.php +++ b/vendor/rector/rector-symfony/src/ValueObject/Tag/EventListenerTag.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace Rector\Symfony\ValueObject\Tag; use Rector\Symfony\Contract\Tag\TagInterface; -final class EventListenerTag implements \Rector\Symfony\Contract\Tag\TagInterface +final class EventListenerTag implements TagInterface { /** * @readonly diff --git a/vendor/rector/rector-symfony/src/ValueObjectFactory/ServiceMapFactory.php b/vendor/rector/rector-symfony/src/ValueObjectFactory/ServiceMapFactory.php index 54ea60b4686..83042da463e 100644 --- a/vendor/rector/rector-symfony/src/ValueObjectFactory/ServiceMapFactory.php +++ b/vendor/rector/rector-symfony/src/ValueObjectFactory/ServiceMapFactory.php @@ -23,17 +23,17 @@ final class ServiceMapFactory * @var \Symplify\SmartFileSystem\SmartFileSystem */ private $smartFileSystem; - public function __construct(\RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem) + public function __construct(SmartFileSystem $smartFileSystem) { $this->smartFileSystem = $smartFileSystem; } - public function createFromFileContent(string $configFilePath) : \Rector\Symfony\ValueObject\ServiceMap\ServiceMap + public function createFromFileContent(string $configFilePath) : ServiceMap { $fileContents = $this->smartFileSystem->readFile($configFilePath); // "@" intentionally $xml = @\simplexml_load_string($fileContents); if ($xml === \false) { - throw new \Rector\Symfony\Exception\XmlContainerNotExistsException(\sprintf('Container "%s" cannot be parsed', $configFilePath)); + throw new XmlContainerNotExistsException(\sprintf('Container "%s" cannot be parsed', $configFilePath)); } /** @var ServiceDefinition[] $services */ $services = []; @@ -55,11 +55,11 @@ final class ServiceMapFactory } } $services = $this->createAliasServiceDefinitions($aliases, $services); - return new \Rector\Symfony\ValueObject\ServiceMap\ServiceMap($services); + return new ServiceMap($services); } - public function createEmpty() : \Rector\Symfony\ValueObject\ServiceMap\ServiceMap + public function createEmpty() : ServiceMap { - return new \Rector\Symfony\ValueObject\ServiceMap\ServiceMap([]); + return new ServiceMap([]); } /** * @param mixed[] $def @@ -81,10 +81,10 @@ final class ServiceMapFactory /** * @param mixed[] $tags */ - private function createServiceFromXmlAndTagsData(\SimpleXMLElement $attrs, array $tags) : \Rector\Symfony\ValueObject\ServiceDefinition + private function createServiceFromXmlAndTagsData(SimpleXMLElement $attrs, array $tags) : ServiceDefinition { $tags = $this->createTagsFromData($tags); - return new \Rector\Symfony\ValueObject\ServiceDefinition(\strncmp((string) $attrs->id, '.', \strlen('.')) === 0 ? \RectorPrefix20220607\Nette\Utils\Strings::substring((string) $attrs->id, 1) : (string) $attrs->id, \property_exists($attrs, 'class') && $attrs->class !== null ? (string) $attrs->class : null, !(\property_exists($attrs, 'public') && $attrs->public !== null) || (string) $attrs->public !== 'false', \property_exists($attrs, 'synthetic') && $attrs->synthetic !== null && (string) $attrs->synthetic === 'true', \property_exists($attrs, 'alias') && $attrs->alias !== null ? (string) $attrs->alias : null, $tags); + return new ServiceDefinition(\strncmp((string) $attrs->id, '.', \strlen('.')) === 0 ? Strings::substring((string) $attrs->id, 1) : (string) $attrs->id, \property_exists($attrs, 'class') && $attrs->class !== null ? (string) $attrs->class : null, !(\property_exists($attrs, 'public') && $attrs->public !== null) || (string) $attrs->public !== 'false', \property_exists($attrs, 'synthetic') && $attrs->synthetic !== null && (string) $attrs->synthetic === 'true', \property_exists($attrs, 'alias') && $attrs->alias !== null ? (string) $attrs->alias : null, $tags); } /** * @param ServiceDefinition[] $aliases @@ -102,7 +102,7 @@ final class ServiceMapFactory continue; } $id = $service->getId(); - $services[$id] = new \Rector\Symfony\ValueObject\ServiceDefinition($id, $services[$alias]->getClass(), $service->isPublic(), $service->isSynthetic(), $alias, []); + $services[$id] = new ServiceDefinition($id, $services[$alias]->getClass(), $service->isPublic(), $service->isSynthetic(), $alias, []); } return $services; } @@ -115,16 +115,16 @@ final class ServiceMapFactory $tagValueObjects = []; foreach ($tagsData as $key => $tag) { if (\is_string($tag)) { - $tagValueObjects[$key] = new \Rector\Symfony\ValueObject\Tag($tag); + $tagValueObjects[$key] = new Tag($tag); continue; } $data = $tag; $name = $data['name'] ?? ''; if ($name === 'kernel.event_listener') { - $tagValueObjects[$key] = new \Rector\Symfony\ValueObject\Tag\EventListenerTag($data['event'] ?? '', $data['method'] ?? '', (int) ($data['priority'] ?? 0)); + $tagValueObjects[$key] = new EventListenerTag($data['event'] ?? '', $data['method'] ?? '', (int) ($data['priority'] ?? 0)); } else { unset($data['name']); - $tagValueObjects[$key] = new \Rector\Symfony\ValueObject\Tag($name, $data ?? []); + $tagValueObjects[$key] = new Tag($name, $data ?? []); } } return $tagValueObjects; @@ -132,14 +132,14 @@ final class ServiceMapFactory /** * @return mixed[] */ - private function convertXmlToArray(\SimpleXMLElement $simpleXMLElement) : array + private function convertXmlToArray(SimpleXMLElement $simpleXMLElement) : array { - $data = \RectorPrefix20220607\Nette\Utils\Json::decode(\RectorPrefix20220607\Nette\Utils\Json::encode((array) $simpleXMLElement), \RectorPrefix20220607\Nette\Utils\Json::FORCE_ARRAY); + $data = Json::decode(Json::encode((array) $simpleXMLElement), Json::FORCE_ARRAY); $data = $this->unWrapAttributes($data); foreach ($data as $key => $value) { if (\is_array($value)) { $data = $this->convertedNestedArrayOrXml($value, $data, $key); - } elseif ($value instanceof \SimpleXMLElement) { + } elseif ($value instanceof SimpleXMLElement) { $data[$key] = $this->convertXmlToArray($value); } } @@ -168,7 +168,7 @@ final class ServiceMapFactory private function convertedNestedArrayOrXml(array $value, array $data, $key) : array { foreach ($value as $subKey => $subValue) { - if ($subValue instanceof \SimpleXMLElement) { + if ($subValue instanceof SimpleXMLElement) { $data[$key][$subKey] = $this->convertXmlToArray($subValue); } elseif (\is_array($subValue)) { $data[$key][$subKey] = $this->unWrapAttributes($subValue); diff --git a/vendor/scoper-autoload.php b/vendor/scoper-autoload.php index 97c288e516d..d6f3e5084f1 100644 --- a/vendor/scoper-autoload.php +++ b/vendor/scoper-autoload.php @@ -4,23 +4,11 @@ $loader = require_once __DIR__.'/autoload.php'; -// Aliases for the whitelisted classes. For more information see: -// https://github.com/humbug/php-scoper/blob/master/README.md#class-whitelisting -if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) { - spl_autoload_call('RectorPrefix20220607\AutoloadIncluder'); -} -if (!class_exists('ComposerAutoloaderInitff8fc41592b030e55c0e49764944895e', false) && !interface_exists('ComposerAutoloaderInitff8fc41592b030e55c0e49764944895e', false) && !trait_exists('ComposerAutoloaderInitff8fc41592b030e55c0e49764944895e', false)) { - spl_autoload_call('RectorPrefix20220607\ComposerAutoloaderInitff8fc41592b030e55c0e49764944895e'); -} -if (!class_exists('MissingReturnTypeParser', false) && !interface_exists('MissingReturnTypeParser', false) && !trait_exists('MissingReturnTypeParser', false)) { - spl_autoload_call('RectorPrefix20220607\MissingReturnTypeParser'); -} +// Exposed classes. For more information see: +// https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#exposing-classes if (!class_exists('Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator', false) && !interface_exists('Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator', false) && !trait_exists('Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator', false)) { spl_autoload_call('RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator'); } -if (!class_exists('Normalizer', false) && !interface_exists('Normalizer', false) && !trait_exists('Normalizer', false)) { - spl_autoload_call('RectorPrefix20220607\Normalizer'); -} if (!class_exists('Symplify\ComposerJsonManipulator\ValueObject\ComposerJson', false) && !interface_exists('Symplify\ComposerJsonManipulator\ValueObject\ComposerJson', false) && !trait_exists('Symplify\ComposerJsonManipulator\ValueObject\ComposerJson', false)) { spl_autoload_call('RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson'); } @@ -28,162 +16,12 @@ if (!class_exists('Symplify\SmartFileSystem\SmartFileInfo', false) && !interface spl_autoload_call('RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo'); } -// Functions whitelisting. For more information see: -// https://github.com/humbug/php-scoper/blob/master/README.md#functions-whitelisting -if (!function_exists('dump_with_depth')) { - function dump_with_depth() { - return \RectorPrefix20220607\dump_with_depth(...func_get_args()); - } -} -if (!function_exists('dn')) { - function dn() { - return \RectorPrefix20220607\dn(...func_get_args()); - } -} -if (!function_exists('dump_node')) { - function dump_node() { - return \RectorPrefix20220607\dump_node(...func_get_args()); - } -} -if (!function_exists('print_node')) { - function print_node() { - return \RectorPrefix20220607\print_node(...func_get_args()); - } -} -if (!function_exists('composerRequireff8fc41592b030e55c0e49764944895e')) { - function composerRequireff8fc41592b030e55c0e49764944895e() { - return \RectorPrefix20220607\composerRequireff8fc41592b030e55c0e49764944895e(...func_get_args()); - } -} -if (!function_exists('scanPath')) { - function scanPath() { - return \RectorPrefix20220607\scanPath(...func_get_args()); - } -} -if (!function_exists('lintFile')) { - function lintFile() { - return \RectorPrefix20220607\lintFile(...func_get_args()); - } -} -if (!function_exists('array_is_list')) { - function array_is_list() { - return \RectorPrefix20220607\array_is_list(...func_get_args()); - } -} -if (!function_exists('parseArgs')) { - function parseArgs() { - return \RectorPrefix20220607\parseArgs(...func_get_args()); - } -} -if (!function_exists('showHelp')) { - function showHelp() { - return \RectorPrefix20220607\showHelp(...func_get_args()); - } -} -if (!function_exists('formatErrorMessage')) { - function formatErrorMessage() { - return \RectorPrefix20220607\formatErrorMessage(...func_get_args()); - } -} -if (!function_exists('preprocessGrammar')) { - function preprocessGrammar() { - return \RectorPrefix20220607\preprocessGrammar(...func_get_args()); - } -} -if (!function_exists('resolveNodes')) { - function resolveNodes() { - return \RectorPrefix20220607\resolveNodes(...func_get_args()); - } -} -if (!function_exists('resolveMacros')) { - function resolveMacros() { - return \RectorPrefix20220607\resolveMacros(...func_get_args()); - } -} -if (!function_exists('resolveStackAccess')) { - function resolveStackAccess() { - return \RectorPrefix20220607\resolveStackAccess(...func_get_args()); - } -} -if (!function_exists('magicSplit')) { - function magicSplit() { - return \RectorPrefix20220607\magicSplit(...func_get_args()); - } -} -if (!function_exists('assertArgs')) { - function assertArgs() { - return \RectorPrefix20220607\assertArgs(...func_get_args()); - } -} -if (!function_exists('removeTrailingWhitespace')) { - function removeTrailingWhitespace() { - return \RectorPrefix20220607\removeTrailingWhitespace(...func_get_args()); - } -} -if (!function_exists('regex')) { - function regex() { - return \RectorPrefix20220607\regex(...func_get_args()); - } -} -if (!function_exists('execCmd')) { - function execCmd() { - return \RectorPrefix20220607\execCmd(...func_get_args()); - } -} -if (!function_exists('ensureDirExists')) { - function ensureDirExists() { - return \RectorPrefix20220607\ensureDirExists(...func_get_args()); - } -} -if (!function_exists('uv_signal_init')) { - function uv_signal_init() { - return \RectorPrefix20220607\uv_signal_init(...func_get_args()); - } -} -if (!function_exists('uv_signal_start')) { - function uv_signal_start() { - return \RectorPrefix20220607\uv_signal_start(...func_get_args()); - } -} -if (!function_exists('uv_poll_init_socket')) { - function uv_poll_init_socket() { - return \RectorPrefix20220607\uv_poll_init_socket(...func_get_args()); - } -} -if (!function_exists('setproctitle')) { - function setproctitle() { - return \RectorPrefix20220607\setproctitle(...func_get_args()); - } -} +// Exposed functions. For more information see: +// https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#exposing-functions if (!function_exists('trigger_deprecation')) { function trigger_deprecation() { return \RectorPrefix20220607\trigger_deprecation(...func_get_args()); } } -if (!function_exists('dump')) { - function dump() { - return \RectorPrefix20220607\dump(...func_get_args()); - } -} -if (!function_exists('dumpe')) { - function dumpe() { - return \RectorPrefix20220607\dumpe(...func_get_args()); - } -} -if (!function_exists('bdump')) { - function bdump() { - return \RectorPrefix20220607\bdump(...func_get_args()); - } -} -if (!function_exists('compressJs')) { - function compressJs() { - return \RectorPrefix20220607\compressJs(...func_get_args()); - } -} -if (!function_exists('compressCss')) { - function compressCss() { - return \RectorPrefix20220607\compressCss(...func_get_args()); - } -} return $loader; diff --git a/vendor/sebastian/diff/src/Chunk.php b/vendor/sebastian/diff/src/Chunk.php index 2da26368147..1edc95522c7 100644 --- a/vendor/sebastian/diff/src/Chunk.php +++ b/vendor/sebastian/diff/src/Chunk.php @@ -70,8 +70,8 @@ final class Chunk public function setLines(array $lines) : void { foreach ($lines as $line) { - if (!$line instanceof \RectorPrefix20220607\SebastianBergmann\Diff\Line) { - throw new \RectorPrefix20220607\SebastianBergmann\Diff\InvalidArgumentException(); + if (!$line instanceof Line) { + throw new InvalidArgumentException(); } } $this->lines = $lines; diff --git a/vendor/sebastian/diff/src/Differ.php b/vendor/sebastian/diff/src/Differ.php index 8338ecc68c6..3235dbe3bae 100644 --- a/vendor/sebastian/diff/src/Differ.php +++ b/vendor/sebastian/diff/src/Differ.php @@ -52,17 +52,17 @@ final class Differ */ public function __construct($outputBuilder = null) { - if ($outputBuilder instanceof \RectorPrefix20220607\SebastianBergmann\Diff\Output\DiffOutputBuilderInterface) { + if ($outputBuilder instanceof DiffOutputBuilderInterface) { $this->outputBuilder = $outputBuilder; } elseif (null === $outputBuilder) { - $this->outputBuilder = new \RectorPrefix20220607\SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder(); - } elseif (\is_string($outputBuilder)) { + $this->outputBuilder = new UnifiedDiffOutputBuilder(); + } elseif (is_string($outputBuilder)) { // PHPUnit 6.1.4, 6.2.0, 6.2.1, 6.2.2, and 6.2.3 support // @see https://github.com/sebastianbergmann/phpunit/issues/2734#issuecomment-314514056 // @deprecated - $this->outputBuilder = new \RectorPrefix20220607\SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder($outputBuilder); + $this->outputBuilder = new UnifiedDiffOutputBuilder($outputBuilder); } else { - throw new \RectorPrefix20220607\SebastianBergmann\Diff\InvalidArgumentException(\sprintf('Expected builder to be an instance of DiffOutputBuilderInterface, or a string, got %s.', \is_object($outputBuilder) ? 'instance of "' . \get_class($outputBuilder) . '"' : \gettype($outputBuilder) . ' "' . $outputBuilder . '"')); + throw new InvalidArgumentException(sprintf('Expected builder to be an instance of DiffOutputBuilderInterface, or a string, got %s.', is_object($outputBuilder) ? 'instance of "' . get_class($outputBuilder) . '"' : gettype($outputBuilder) . ' "' . $outputBuilder . '"')); } } /** @@ -71,7 +71,7 @@ final class Differ * @param array|string $from * @param array|string $to */ - public function diff($from, $to, \RectorPrefix20220607\SebastianBergmann\Diff\LongestCommonSubsequenceCalculator $lcs = null) : string + public function diff($from, $to, LongestCommonSubsequenceCalculator $lcs = null) : string { $diff = $this->diffToArray($this->normalizeDiffInput($from), $this->normalizeDiffInput($to), $lcs); return $this->outputBuilder->getDiff($diff); @@ -91,51 +91,51 @@ final class Differ * @param array|string $to * @param LongestCommonSubsequenceCalculator $lcs */ - public function diffToArray($from, $to, \RectorPrefix20220607\SebastianBergmann\Diff\LongestCommonSubsequenceCalculator $lcs = null) : array + public function diffToArray($from, $to, LongestCommonSubsequenceCalculator $lcs = null) : array { - if (\is_string($from)) { + if (is_string($from)) { $from = $this->splitStringByLines($from); - } elseif (!\is_array($from)) { - throw new \RectorPrefix20220607\SebastianBergmann\Diff\InvalidArgumentException('"from" must be an array or string.'); + } elseif (!is_array($from)) { + throw new InvalidArgumentException('"from" must be an array or string.'); } - if (\is_string($to)) { + if (is_string($to)) { $to = $this->splitStringByLines($to); - } elseif (!\is_array($to)) { - throw new \RectorPrefix20220607\SebastianBergmann\Diff\InvalidArgumentException('"to" must be an array or string.'); + } elseif (!is_array($to)) { + throw new InvalidArgumentException('"to" must be an array or string.'); } [$from, $to, $start, $end] = self::getArrayDiffParted($from, $to); if ($lcs === null) { $lcs = $this->selectLcsImplementation($from, $to); } - $common = $lcs->calculate(\array_values($from), \array_values($to)); + $common = $lcs->calculate(array_values($from), array_values($to)); $diff = []; foreach ($start as $token) { $diff[] = [$token, self::OLD]; } - \reset($from); - \reset($to); + reset($from); + reset($to); foreach ($common as $token) { - while (($fromToken = \reset($from)) !== $token) { - $diff[] = [\array_shift($from), self::REMOVED]; + while (($fromToken = reset($from)) !== $token) { + $diff[] = [array_shift($from), self::REMOVED]; } - while (($toToken = \reset($to)) !== $token) { - $diff[] = [\array_shift($to), self::ADDED]; + while (($toToken = reset($to)) !== $token) { + $diff[] = [array_shift($to), self::ADDED]; } $diff[] = [$token, self::OLD]; - \array_shift($from); - \array_shift($to); + array_shift($from); + array_shift($to); } - while (($token = \array_shift($from)) !== null) { + while (($token = array_shift($from)) !== null) { $diff[] = [$token, self::REMOVED]; } - while (($token = \array_shift($to)) !== null) { + while (($token = array_shift($to)) !== null) { $diff[] = [$token, self::ADDED]; } foreach ($end as $token) { $diff[] = [$token, self::OLD]; } if ($this->detectUnmatchedLineEndings($diff)) { - \array_unshift($diff, ["#Warning: Strings contain different line endings!\n", self::DIFF_LINE_END_WARNING]); + array_unshift($diff, ["#Warning: Strings contain different line endings!\n", self::DIFF_LINE_END_WARNING]); } return $diff; } @@ -146,7 +146,7 @@ final class Differ */ private function normalizeDiffInput($input) { - if (!\is_array($input) && !\is_string($input)) { + if (!is_array($input) && !is_string($input)) { return (string) $input; } return $input; @@ -156,9 +156,9 @@ final class Differ */ private function splitStringByLines(string $input) : array { - return \preg_split('/(.*\\R)/', $input, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY); + return preg_split('/(.*\\R)/', $input, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); } - private function selectLcsImplementation(array $from, array $to) : \RectorPrefix20220607\SebastianBergmann\Diff\LongestCommonSubsequenceCalculator + private function selectLcsImplementation(array $from, array $to) : LongestCommonSubsequenceCalculator { // We do not want to use the time-efficient implementation if its memory // footprint will probably exceed this value. Note that the footprint @@ -166,9 +166,9 @@ final class Differ // will typically allocate a bit more memory than this. $memoryLimit = 100 * 1024 * 1024; if ($this->calculateEstimatedFootprint($from, $to) > $memoryLimit) { - return new \RectorPrefix20220607\SebastianBergmann\Diff\MemoryEfficientLongestCommonSubsequenceCalculator(); + return new MemoryEfficientLongestCommonSubsequenceCalculator(); } - return new \RectorPrefix20220607\SebastianBergmann\Diff\TimeEfficientLongestCommonSubsequenceCalculator(); + return new TimeEfficientLongestCommonSubsequenceCalculator(); } /** * Calculates the estimated memory footprint for the DP-based method. @@ -177,8 +177,8 @@ final class Differ */ private function calculateEstimatedFootprint(array $from, array $to) { - $itemSize = \PHP_INT_SIZE === 4 ? 76 : 144; - return $itemSize * \min(\count($from), \count($to)) ** 2; + $itemSize = PHP_INT_SIZE === 4 ? 76 : 144; + return $itemSize * min(count($from), count($to)) ** 2; } /** * Returns true if line ends don't match in a diff. @@ -217,17 +217,17 @@ final class Differ } private function getLinebreak($line) : string { - if (!\is_string($line)) { + if (!is_string($line)) { return ''; } - $lc = \substr($line, -1); + $lc = substr($line, -1); if ("\r" === $lc) { return "\r"; } if ("\n" !== $lc) { return ''; } - if ("\r\n" === \substr($line, -2)) { + if ("\r\n" === substr($line, -2)) { return "\r\n"; } return "\n"; @@ -236,9 +236,9 @@ final class Differ { $start = []; $end = []; - \reset($to); + reset($to); foreach ($from as $k => $v) { - $toK = \key($to); + $toK = key($to); if ($toK === $k && $v === $to[$k]) { $start[$k] = $v; unset($from[$k], $to[$k]); @@ -246,16 +246,16 @@ final class Differ break; } } - \end($from); - \end($to); + end($from); + end($to); do { - $fromK = \key($from); - $toK = \key($to); - if (null === $fromK || null === $toK || \current($from) !== \current($to)) { + $fromK = key($from); + $toK = key($to); + if (null === $fromK || null === $toK || current($from) !== current($to)) { break; } - \prev($from); - \prev($to); + prev($from); + prev($to); $end = [$fromK => $from[$fromK]] + $end; unset($from[$fromK], $to[$toK]); } while (\true); diff --git a/vendor/sebastian/diff/src/Exception/ConfigurationException.php b/vendor/sebastian/diff/src/Exception/ConfigurationException.php index d0d162be315..a6733d7744d 100644 --- a/vendor/sebastian/diff/src/Exception/ConfigurationException.php +++ b/vendor/sebastian/diff/src/Exception/ConfigurationException.php @@ -16,10 +16,10 @@ use function gettype; use function is_object; use function sprintf; use Exception; -final class ConfigurationException extends \RectorPrefix20220607\SebastianBergmann\Diff\InvalidArgumentException +final class ConfigurationException extends InvalidArgumentException { - public function __construct(string $option, string $expected, $value, int $code = 0, \Exception $previous = null) + public function __construct(string $option, string $expected, $value, int $code = 0, Exception $previous = null) { - parent::__construct(\sprintf('Option "%s" must be %s, got "%s".', $option, $expected, \is_object($value) ? \get_class($value) : (null === $value ? '' : \gettype($value) . '#' . $value)), $code, $previous); + parent::__construct(sprintf('Option "%s" must be %s, got "%s".', $option, $expected, is_object($value) ? get_class($value) : (null === $value ? '' : gettype($value) . '#' . $value)), $code, $previous); } } diff --git a/vendor/sebastian/diff/src/Exception/Exception.php b/vendor/sebastian/diff/src/Exception/Exception.php index 873d0de185e..b02d10460b4 100644 --- a/vendor/sebastian/diff/src/Exception/Exception.php +++ b/vendor/sebastian/diff/src/Exception/Exception.php @@ -12,6 +12,6 @@ declare (strict_types=1); namespace RectorPrefix20220607\SebastianBergmann\Diff; use Throwable; -interface Exception extends \Throwable +interface Exception extends Throwable { } diff --git a/vendor/sebastian/diff/src/Exception/InvalidArgumentException.php b/vendor/sebastian/diff/src/Exception/InvalidArgumentException.php index 2813c66e8c5..4623c0cddd2 100644 --- a/vendor/sebastian/diff/src/Exception/InvalidArgumentException.php +++ b/vendor/sebastian/diff/src/Exception/InvalidArgumentException.php @@ -11,6 +11,6 @@ declare (strict_types=1); */ namespace RectorPrefix20220607\SebastianBergmann\Diff; -class InvalidArgumentException extends \InvalidArgumentException implements \RectorPrefix20220607\SebastianBergmann\Diff\Exception +class InvalidArgumentException extends \InvalidArgumentException implements Exception { } diff --git a/vendor/sebastian/diff/src/MemoryEfficientLongestCommonSubsequenceCalculator.php b/vendor/sebastian/diff/src/MemoryEfficientLongestCommonSubsequenceCalculator.php index 9cfeb827c76..0a2087495e9 100644 --- a/vendor/sebastian/diff/src/MemoryEfficientLongestCommonSubsequenceCalculator.php +++ b/vendor/sebastian/diff/src/MemoryEfficientLongestCommonSubsequenceCalculator.php @@ -18,29 +18,29 @@ use function array_slice; use function count; use function in_array; use function max; -final class MemoryEfficientLongestCommonSubsequenceCalculator implements \RectorPrefix20220607\SebastianBergmann\Diff\LongestCommonSubsequenceCalculator +final class MemoryEfficientLongestCommonSubsequenceCalculator implements LongestCommonSubsequenceCalculator { /** * {@inheritdoc} */ public function calculate(array $from, array $to) : array { - $cFrom = \count($from); - $cTo = \count($to); + $cFrom = count($from); + $cTo = count($to); if ($cFrom === 0) { return []; } if ($cFrom === 1) { - if (\in_array($from[0], $to, \true)) { + if (in_array($from[0], $to, \true)) { return [$from[0]]; } return []; } $i = (int) ($cFrom / 2); - $fromStart = \array_slice($from, 0, $i); - $fromEnd = \array_slice($from, $i); + $fromStart = array_slice($from, 0, $i); + $fromEnd = array_slice($from, $i); $llB = $this->length($fromStart, $to); - $llE = $this->length(\array_reverse($fromEnd), \array_reverse($to)); + $llE = $this->length(array_reverse($fromEnd), array_reverse($to)); $jMax = 0; $max = 0; for ($j = 0; $j <= $cTo; $j++) { @@ -50,22 +50,22 @@ final class MemoryEfficientLongestCommonSubsequenceCalculator implements \Rector $jMax = $j; } } - $toStart = \array_slice($to, 0, $jMax); - $toEnd = \array_slice($to, $jMax); - return \array_merge($this->calculate($fromStart, $toStart), $this->calculate($fromEnd, $toEnd)); + $toStart = array_slice($to, 0, $jMax); + $toEnd = array_slice($to, $jMax); + return array_merge($this->calculate($fromStart, $toStart), $this->calculate($fromEnd, $toEnd)); } private function length(array $from, array $to) : array { - $current = \array_fill(0, \count($to) + 1, 0); - $cFrom = \count($from); - $cTo = \count($to); + $current = array_fill(0, count($to) + 1, 0); + $cFrom = count($from); + $cTo = count($to); for ($i = 0; $i < $cFrom; $i++) { $prev = $current; for ($j = 0; $j < $cTo; $j++) { if ($from[$i] === $to[$j]) { $current[$j + 1] = $prev[$j] + 1; } else { - $current[$j + 1] = \max($current[$j], $prev[$j + 1]); + $current[$j + 1] = max($current[$j], $prev[$j + 1]); } } } diff --git a/vendor/sebastian/diff/src/Output/AbstractChunkOutputBuilder.php b/vendor/sebastian/diff/src/Output/AbstractChunkOutputBuilder.php index 3fafbc093f7..5cfdab9cbb1 100644 --- a/vendor/sebastian/diff/src/Output/AbstractChunkOutputBuilder.php +++ b/vendor/sebastian/diff/src/Output/AbstractChunkOutputBuilder.php @@ -12,7 +12,7 @@ declare (strict_types=1); namespace RectorPrefix20220607\SebastianBergmann\Diff\Output; use function count; -abstract class AbstractChunkOutputBuilder implements \RectorPrefix20220607\SebastianBergmann\Diff\Output\DiffOutputBuilderInterface +abstract class AbstractChunkOutputBuilder implements DiffOutputBuilderInterface { /** * Takes input of the diff array and returns the common parts. @@ -20,7 +20,7 @@ abstract class AbstractChunkOutputBuilder implements \RectorPrefix20220607\Sebas */ protected function getCommonChunks(array $diff, int $lineThreshold = 5) : array { - $diffSize = \count($diff); + $diffSize = count($diff); $capturing = \false; $chunkStart = 0; $chunkSize = 0; diff --git a/vendor/sebastian/diff/src/Output/DiffOnlyOutputBuilder.php b/vendor/sebastian/diff/src/Output/DiffOnlyOutputBuilder.php index 0ec870c1e64..ac503a50124 100644 --- a/vendor/sebastian/diff/src/Output/DiffOnlyOutputBuilder.php +++ b/vendor/sebastian/diff/src/Output/DiffOnlyOutputBuilder.php @@ -21,7 +21,7 @@ use RectorPrefix20220607\SebastianBergmann\Diff\Differ; * Builds a diff string representation in a loose unified diff format * listing only changes lines. Does not include line numbers. */ -final class DiffOnlyOutputBuilder implements \RectorPrefix20220607\SebastianBergmann\Diff\Output\DiffOutputBuilderInterface +final class DiffOnlyOutputBuilder implements DiffOutputBuilderInterface { /** * @var string @@ -33,20 +33,20 @@ final class DiffOnlyOutputBuilder implements \RectorPrefix20220607\SebastianBerg } public function getDiff(array $diff) : string { - $buffer = \fopen('php://memory', 'r+b'); + $buffer = fopen('php://memory', 'r+b'); if ('' !== $this->header) { - \fwrite($buffer, $this->header); - if ("\n" !== \substr($this->header, -1, 1)) { - \fwrite($buffer, "\n"); + fwrite($buffer, $this->header); + if ("\n" !== substr($this->header, -1, 1)) { + fwrite($buffer, "\n"); } } foreach ($diff as $diffEntry) { - if ($diffEntry[1] === \RectorPrefix20220607\SebastianBergmann\Diff\Differ::ADDED) { - \fwrite($buffer, '+' . $diffEntry[0]); - } elseif ($diffEntry[1] === \RectorPrefix20220607\SebastianBergmann\Diff\Differ::REMOVED) { - \fwrite($buffer, '-' . $diffEntry[0]); - } elseif ($diffEntry[1] === \RectorPrefix20220607\SebastianBergmann\Diff\Differ::DIFF_LINE_END_WARNING) { - \fwrite($buffer, ' ' . $diffEntry[0]); + if ($diffEntry[1] === Differ::ADDED) { + fwrite($buffer, '+' . $diffEntry[0]); + } elseif ($diffEntry[1] === Differ::REMOVED) { + fwrite($buffer, '-' . $diffEntry[0]); + } elseif ($diffEntry[1] === Differ::DIFF_LINE_END_WARNING) { + fwrite($buffer, ' ' . $diffEntry[0]); continue; // Warnings should not be tested for line break, it will always be there } else { @@ -54,14 +54,14 @@ final class DiffOnlyOutputBuilder implements \RectorPrefix20220607\SebastianBerg continue; // we didn't write the non changs line, so do not add a line break either } - $lc = \substr($diffEntry[0], -1); + $lc = substr($diffEntry[0], -1); if ($lc !== "\n" && $lc !== "\r") { - \fwrite($buffer, "\n"); + fwrite($buffer, "\n"); // \No newline at end of file } } - $diff = \stream_get_contents($buffer, -1, 0); - \fclose($buffer); + $diff = stream_get_contents($buffer, -1, 0); + fclose($buffer); return $diff; } } diff --git a/vendor/sebastian/diff/src/Output/StrictUnifiedDiffOutputBuilder.php b/vendor/sebastian/diff/src/Output/StrictUnifiedDiffOutputBuilder.php index a2cb7c5417a..d7777165497 100644 --- a/vendor/sebastian/diff/src/Output/StrictUnifiedDiffOutputBuilder.php +++ b/vendor/sebastian/diff/src/Output/StrictUnifiedDiffOutputBuilder.php @@ -32,7 +32,7 @@ use RectorPrefix20220607\SebastianBergmann\Diff\Differ; * * Generates (strict) Unified diff's (unidiffs) with hunks. */ -final class StrictUnifiedDiffOutputBuilder implements \RectorPrefix20220607\SebastianBergmann\Diff\Output\DiffOutputBuilderInterface +final class StrictUnifiedDiffOutputBuilder implements DiffOutputBuilderInterface { private static $default = [ 'collapseRanges' => \true, @@ -68,53 +68,53 @@ final class StrictUnifiedDiffOutputBuilder implements \RectorPrefix20220607\Seba private $contextLines; public function __construct(array $options = []) { - $options = \array_merge(self::$default, $options); - if (!\is_bool($options['collapseRanges'])) { - throw new \RectorPrefix20220607\SebastianBergmann\Diff\ConfigurationException('collapseRanges', 'a bool', $options['collapseRanges']); + $options = array_merge(self::$default, $options); + if (!is_bool($options['collapseRanges'])) { + throw new ConfigurationException('collapseRanges', 'a bool', $options['collapseRanges']); } - if (!\is_int($options['contextLines']) || $options['contextLines'] < 0) { - throw new \RectorPrefix20220607\SebastianBergmann\Diff\ConfigurationException('contextLines', 'an int >= 0', $options['contextLines']); + if (!is_int($options['contextLines']) || $options['contextLines'] < 0) { + throw new ConfigurationException('contextLines', 'an int >= 0', $options['contextLines']); } - if (!\is_int($options['commonLineThreshold']) || $options['commonLineThreshold'] <= 0) { - throw new \RectorPrefix20220607\SebastianBergmann\Diff\ConfigurationException('commonLineThreshold', 'an int > 0', $options['commonLineThreshold']); + if (!is_int($options['commonLineThreshold']) || $options['commonLineThreshold'] <= 0) { + throw new ConfigurationException('commonLineThreshold', 'an int > 0', $options['commonLineThreshold']); } $this->assertString($options, 'fromFile'); $this->assertString($options, 'toFile'); $this->assertStringOrNull($options, 'fromFileDate'); $this->assertStringOrNull($options, 'toFileDate'); - $this->header = \sprintf("--- %s%s\n+++ %s%s\n", $options['fromFile'], null === $options['fromFileDate'] ? '' : "\t" . $options['fromFileDate'], $options['toFile'], null === $options['toFileDate'] ? '' : "\t" . $options['toFileDate']); + $this->header = sprintf("--- %s%s\n+++ %s%s\n", $options['fromFile'], null === $options['fromFileDate'] ? '' : "\t" . $options['fromFileDate'], $options['toFile'], null === $options['toFileDate'] ? '' : "\t" . $options['toFileDate']); $this->collapseRanges = $options['collapseRanges']; $this->commonLineThreshold = $options['commonLineThreshold']; $this->contextLines = $options['contextLines']; } public function getDiff(array $diff) : string { - if (0 === \count($diff)) { + if (0 === count($diff)) { return ''; } $this->changed = \false; - $buffer = \fopen('php://memory', 'r+b'); - \fwrite($buffer, $this->header); + $buffer = fopen('php://memory', 'r+b'); + fwrite($buffer, $this->header); $this->writeDiffHunks($buffer, $diff); if (!$this->changed) { - \fclose($buffer); + fclose($buffer); return ''; } - $diff = \stream_get_contents($buffer, -1, 0); - \fclose($buffer); + $diff = stream_get_contents($buffer, -1, 0); + fclose($buffer); // If the last char is not a linebreak: add it. // This might happen when both the `from` and `to` do not have a trailing linebreak - $last = \substr($diff, -1); + $last = substr($diff, -1); return "\n" !== $last && "\r" !== $last ? $diff . "\n" : $diff; } private function writeDiffHunks($output, array $diff) : void { // detect "No newline at end of file" and insert into `$diff` if needed - $upperLimit = \count($diff); + $upperLimit = count($diff); if (0 === $diff[$upperLimit - 1][1]) { - $lc = \substr($diff[$upperLimit - 1][0], -1); + $lc = substr($diff[$upperLimit - 1][0], -1); if ("\n" !== $lc) { - \array_splice($diff, $upperLimit, 0, [["\n\\ No newline at end of file\n", \RectorPrefix20220607\SebastianBergmann\Diff\Differ::NO_LINE_END_EOF_WARNING]]); + array_splice($diff, $upperLimit, 0, [["\n\\ No newline at end of file\n", Differ::NO_LINE_END_EOF_WARNING]]); } } else { // search back for the last `+` and `-` line, @@ -123,18 +123,18 @@ final class StrictUnifiedDiffOutputBuilder implements \RectorPrefix20220607\Seba for ($i = $upperLimit - 1; $i >= 0; --$i) { if (isset($toFind[$diff[$i][1]])) { unset($toFind[$diff[$i][1]]); - $lc = \substr($diff[$i][0], -1); + $lc = substr($diff[$i][0], -1); if ("\n" !== $lc) { - \array_splice($diff, $i + 1, 0, [["\n\\ No newline at end of file\n", \RectorPrefix20220607\SebastianBergmann\Diff\Differ::NO_LINE_END_EOF_WARNING]]); + array_splice($diff, $i + 1, 0, [["\n\\ No newline at end of file\n", Differ::NO_LINE_END_EOF_WARNING]]); } - if (!\count($toFind)) { + if (!count($toFind)) { break; } } } } // write hunks to output buffer - $cutOff = \max($this->commonLineThreshold, $this->contextLines); + $cutOff = max($this->commonLineThreshold, $this->contextLines); $hunkCapture = \false; $sameCount = $toRange = $fromRange = 0; $toStart = $fromStart = 1; @@ -172,18 +172,18 @@ final class StrictUnifiedDiffOutputBuilder implements \RectorPrefix20220607\Seba continue; } $sameCount = 0; - if ($entry[1] === \RectorPrefix20220607\SebastianBergmann\Diff\Differ::NO_LINE_END_EOF_WARNING) { + if ($entry[1] === Differ::NO_LINE_END_EOF_WARNING) { continue; } $this->changed = \true; if (\false === $hunkCapture) { $hunkCapture = $i; } - if (\RectorPrefix20220607\SebastianBergmann\Diff\Differ::ADDED === $entry[1]) { + if (Differ::ADDED === $entry[1]) { // added ++$toRange; } - if (\RectorPrefix20220607\SebastianBergmann\Diff\Differ::REMOVED === $entry[1]) { + if (Differ::REMOVED === $entry[1]) { // removed ++$fromRange; } @@ -196,34 +196,34 @@ final class StrictUnifiedDiffOutputBuilder implements \RectorPrefix20220607\Seba $contextStartOffset = $hunkCapture - $this->contextLines < 0 ? $hunkCapture : $this->contextLines; // prevent trying to write out more common lines than there are in the diff _and_ // do not write more than configured through the context lines - $contextEndOffset = \min($sameCount, $this->contextLines); + $contextEndOffset = min($sameCount, $this->contextLines); $fromRange -= $sameCount; $toRange -= $sameCount; $this->writeHunk($diff, $hunkCapture - $contextStartOffset, $i - $sameCount + $contextEndOffset + 1, $fromStart - $contextStartOffset, $fromRange + $contextStartOffset + $contextEndOffset, $toStart - $contextStartOffset, $toRange + $contextStartOffset + $contextEndOffset, $output); } private function writeHunk(array $diff, int $diffStartIndex, int $diffEndIndex, int $fromStart, int $fromRange, int $toStart, int $toRange, $output) : void { - \fwrite($output, '@@ -' . $fromStart); + fwrite($output, '@@ -' . $fromStart); if (!$this->collapseRanges || 1 !== $fromRange) { - \fwrite($output, ',' . $fromRange); + fwrite($output, ',' . $fromRange); } - \fwrite($output, ' +' . $toStart); + fwrite($output, ' +' . $toStart); if (!$this->collapseRanges || 1 !== $toRange) { - \fwrite($output, ',' . $toRange); + fwrite($output, ',' . $toRange); } - \fwrite($output, " @@\n"); + fwrite($output, " @@\n"); for ($i = $diffStartIndex; $i < $diffEndIndex; ++$i) { - if ($diff[$i][1] === \RectorPrefix20220607\SebastianBergmann\Diff\Differ::ADDED) { + if ($diff[$i][1] === Differ::ADDED) { $this->changed = \true; - \fwrite($output, '+' . $diff[$i][0]); - } elseif ($diff[$i][1] === \RectorPrefix20220607\SebastianBergmann\Diff\Differ::REMOVED) { + fwrite($output, '+' . $diff[$i][0]); + } elseif ($diff[$i][1] === Differ::REMOVED) { $this->changed = \true; - \fwrite($output, '-' . $diff[$i][0]); - } elseif ($diff[$i][1] === \RectorPrefix20220607\SebastianBergmann\Diff\Differ::OLD) { - \fwrite($output, ' ' . $diff[$i][0]); - } elseif ($diff[$i][1] === \RectorPrefix20220607\SebastianBergmann\Diff\Differ::NO_LINE_END_EOF_WARNING) { + fwrite($output, '-' . $diff[$i][0]); + } elseif ($diff[$i][1] === Differ::OLD) { + fwrite($output, ' ' . $diff[$i][0]); + } elseif ($diff[$i][1] === Differ::NO_LINE_END_EOF_WARNING) { $this->changed = \true; - \fwrite($output, $diff[$i][0]); + fwrite($output, $diff[$i][0]); } //} elseif ($diff[$i][1] === Differ::DIFF_LINE_END_WARNING) { // custom comment inserted by PHPUnit/diff package // skip @@ -234,14 +234,14 @@ final class StrictUnifiedDiffOutputBuilder implements \RectorPrefix20220607\Seba } private function assertString(array $options, string $option) : void { - if (!\is_string($options[$option])) { - throw new \RectorPrefix20220607\SebastianBergmann\Diff\ConfigurationException($option, 'a string', $options[$option]); + if (!is_string($options[$option])) { + throw new ConfigurationException($option, 'a string', $options[$option]); } } private function assertStringOrNull(array $options, string $option) : void { - if (null !== $options[$option] && !\is_string($options[$option])) { - throw new \RectorPrefix20220607\SebastianBergmann\Diff\ConfigurationException($option, 'a string or ', $options[$option]); + if (null !== $options[$option] && !is_string($options[$option])) { + throw new ConfigurationException($option, 'a string or ', $options[$option]); } } } diff --git a/vendor/sebastian/diff/src/Output/UnifiedDiffOutputBuilder.php b/vendor/sebastian/diff/src/Output/UnifiedDiffOutputBuilder.php index 849514000ef..5e62604787b 100644 --- a/vendor/sebastian/diff/src/Output/UnifiedDiffOutputBuilder.php +++ b/vendor/sebastian/diff/src/Output/UnifiedDiffOutputBuilder.php @@ -25,7 +25,7 @@ use RectorPrefix20220607\SebastianBergmann\Diff\Differ; /** * Builds a diff string representation in unified diff format in chunks. */ -final class UnifiedDiffOutputBuilder extends \RectorPrefix20220607\SebastianBergmann\Diff\Output\AbstractChunkOutputBuilder +final class UnifiedDiffOutputBuilder extends AbstractChunkOutputBuilder { /** * @var bool @@ -54,31 +54,31 @@ final class UnifiedDiffOutputBuilder extends \RectorPrefix20220607\SebastianBerg } public function getDiff(array $diff) : string { - $buffer = \fopen('php://memory', 'r+b'); + $buffer = fopen('php://memory', 'r+b'); if ('' !== $this->header) { - \fwrite($buffer, $this->header); - if ("\n" !== \substr($this->header, -1, 1)) { - \fwrite($buffer, "\n"); + fwrite($buffer, $this->header); + if ("\n" !== substr($this->header, -1, 1)) { + fwrite($buffer, "\n"); } } - if (0 !== \count($diff)) { + if (0 !== count($diff)) { $this->writeDiffHunks($buffer, $diff); } - $diff = \stream_get_contents($buffer, -1, 0); - \fclose($buffer); + $diff = stream_get_contents($buffer, -1, 0); + fclose($buffer); // If the diff is non-empty and last char is not a linebreak: add it. // This might happen when both the `from` and `to` do not have a trailing linebreak - $last = \substr($diff, -1); - return 0 !== \strlen($diff) && "\n" !== $last && "\r" !== $last ? $diff . "\n" : $diff; + $last = substr($diff, -1); + return 0 !== strlen($diff) && "\n" !== $last && "\r" !== $last ? $diff . "\n" : $diff; } private function writeDiffHunks($output, array $diff) : void { // detect "No newline at end of file" and insert into `$diff` if needed - $upperLimit = \count($diff); + $upperLimit = count($diff); if (0 === $diff[$upperLimit - 1][1]) { - $lc = \substr($diff[$upperLimit - 1][0], -1); + $lc = substr($diff[$upperLimit - 1][0], -1); if ("\n" !== $lc) { - \array_splice($diff, $upperLimit, 0, [["\n\\ No newline at end of file\n", \RectorPrefix20220607\SebastianBergmann\Diff\Differ::NO_LINE_END_EOF_WARNING]]); + array_splice($diff, $upperLimit, 0, [["\n\\ No newline at end of file\n", Differ::NO_LINE_END_EOF_WARNING]]); } } else { // search back for the last `+` and `-` line, @@ -87,18 +87,18 @@ final class UnifiedDiffOutputBuilder extends \RectorPrefix20220607\SebastianBerg for ($i = $upperLimit - 1; $i >= 0; --$i) { if (isset($toFind[$diff[$i][1]])) { unset($toFind[$diff[$i][1]]); - $lc = \substr($diff[$i][0], -1); + $lc = substr($diff[$i][0], -1); if ("\n" !== $lc) { - \array_splice($diff, $i + 1, 0, [["\n\\ No newline at end of file\n", \RectorPrefix20220607\SebastianBergmann\Diff\Differ::NO_LINE_END_EOF_WARNING]]); + array_splice($diff, $i + 1, 0, [["\n\\ No newline at end of file\n", Differ::NO_LINE_END_EOF_WARNING]]); } - if (!\count($toFind)) { + if (!count($toFind)) { break; } } } } // write hunks to output buffer - $cutOff = \max($this->commonLineThreshold, $this->contextLines); + $cutOff = max($this->commonLineThreshold, $this->contextLines); $hunkCapture = \false; $sameCount = $toRange = $fromRange = 0; $toStart = $fromStart = 1; @@ -136,16 +136,16 @@ final class UnifiedDiffOutputBuilder extends \RectorPrefix20220607\SebastianBerg continue; } $sameCount = 0; - if ($entry[1] === \RectorPrefix20220607\SebastianBergmann\Diff\Differ::NO_LINE_END_EOF_WARNING) { + if ($entry[1] === Differ::NO_LINE_END_EOF_WARNING) { continue; } if (\false === $hunkCapture) { $hunkCapture = $i; } - if (\RectorPrefix20220607\SebastianBergmann\Diff\Differ::ADDED === $entry[1]) { + if (Differ::ADDED === $entry[1]) { ++$toRange; } - if (\RectorPrefix20220607\SebastianBergmann\Diff\Differ::REMOVED === $entry[1]) { + if (Differ::REMOVED === $entry[1]) { ++$fromRange; } } @@ -157,7 +157,7 @@ final class UnifiedDiffOutputBuilder extends \RectorPrefix20220607\SebastianBerg $contextStartOffset = $hunkCapture - $this->contextLines < 0 ? $hunkCapture : $this->contextLines; // prevent trying to write out more common lines than there are in the diff _and_ // do not write more than configured through the context lines - $contextEndOffset = \min($sameCount, $this->contextLines); + $contextEndOffset = min($sameCount, $this->contextLines); $fromRange -= $sameCount; $toRange -= $sameCount; $this->writeHunk($diff, $hunkCapture - $contextStartOffset, $i - $sameCount + $contextEndOffset + 1, $fromStart - $contextStartOffset, $fromRange + $contextStartOffset + $contextEndOffset, $toStart - $contextStartOffset, $toRange + $contextStartOffset + $contextEndOffset, $output); @@ -165,31 +165,31 @@ final class UnifiedDiffOutputBuilder extends \RectorPrefix20220607\SebastianBerg private function writeHunk(array $diff, int $diffStartIndex, int $diffEndIndex, int $fromStart, int $fromRange, int $toStart, int $toRange, $output) : void { if ($this->addLineNumbers) { - \fwrite($output, '@@ -' . $fromStart); + fwrite($output, '@@ -' . $fromStart); if (!$this->collapseRanges || 1 !== $fromRange) { - \fwrite($output, ',' . $fromRange); + fwrite($output, ',' . $fromRange); } - \fwrite($output, ' +' . $toStart); + fwrite($output, ' +' . $toStart); if (!$this->collapseRanges || 1 !== $toRange) { - \fwrite($output, ',' . $toRange); + fwrite($output, ',' . $toRange); } - \fwrite($output, " @@\n"); + fwrite($output, " @@\n"); } else { - \fwrite($output, "@@ @@\n"); + fwrite($output, "@@ @@\n"); } for ($i = $diffStartIndex; $i < $diffEndIndex; ++$i) { - if ($diff[$i][1] === \RectorPrefix20220607\SebastianBergmann\Diff\Differ::ADDED) { - \fwrite($output, '+' . $diff[$i][0]); - } elseif ($diff[$i][1] === \RectorPrefix20220607\SebastianBergmann\Diff\Differ::REMOVED) { - \fwrite($output, '-' . $diff[$i][0]); - } elseif ($diff[$i][1] === \RectorPrefix20220607\SebastianBergmann\Diff\Differ::OLD) { - \fwrite($output, ' ' . $diff[$i][0]); - } elseif ($diff[$i][1] === \RectorPrefix20220607\SebastianBergmann\Diff\Differ::NO_LINE_END_EOF_WARNING) { - \fwrite($output, "\n"); + if ($diff[$i][1] === Differ::ADDED) { + fwrite($output, '+' . $diff[$i][0]); + } elseif ($diff[$i][1] === Differ::REMOVED) { + fwrite($output, '-' . $diff[$i][0]); + } elseif ($diff[$i][1] === Differ::OLD) { + fwrite($output, ' ' . $diff[$i][0]); + } elseif ($diff[$i][1] === Differ::NO_LINE_END_EOF_WARNING) { + fwrite($output, "\n"); // $diff[$i][0] } else { /* Not changed (old) Differ::OLD or Warning Differ::DIFF_LINE_END_WARNING */ - \fwrite($output, ' ' . $diff[$i][0]); + fwrite($output, ' ' . $diff[$i][0]); } } } diff --git a/vendor/sebastian/diff/src/Parser.php b/vendor/sebastian/diff/src/Parser.php index 6c7d46ae3ee..54b8ab08eaa 100644 --- a/vendor/sebastian/diff/src/Parser.php +++ b/vendor/sebastian/diff/src/Parser.php @@ -26,56 +26,56 @@ final class Parser */ public function parse(string $string) : array { - $lines = \preg_split('(\\r\\n|\\r|\\n)', $string); - if (!empty($lines) && $lines[\count($lines) - 1] === '') { - \array_pop($lines); + $lines = preg_split('(\\r\\n|\\r|\\n)', $string); + if (!empty($lines) && $lines[count($lines) - 1] === '') { + array_pop($lines); } - $lineCount = \count($lines); + $lineCount = count($lines); $diffs = []; $diff = null; $collected = []; for ($i = 0; $i < $lineCount; ++$i) { - if (\preg_match('#^---\\h+"?(?P[^\\v\\t"]+)#', $lines[$i], $fromMatch) && \preg_match('#^\\+\\+\\+\\h+"?(?P[^\\v\\t"]+)#', $lines[$i + 1], $toMatch)) { + if (preg_match('#^---\\h+"?(?P[^\\v\\t"]+)#', $lines[$i], $fromMatch) && preg_match('#^\\+\\+\\+\\h+"?(?P[^\\v\\t"]+)#', $lines[$i + 1], $toMatch)) { if ($diff !== null) { $this->parseFileDiff($diff, $collected); $diffs[] = $diff; $collected = []; } - $diff = new \RectorPrefix20220607\SebastianBergmann\Diff\Diff($fromMatch['file'], $toMatch['file']); + $diff = new Diff($fromMatch['file'], $toMatch['file']); ++$i; } else { - if (\preg_match('/^(?:diff --git |index [\\da-f\\.]+|[+-]{3} [ab])/', $lines[$i])) { + if (preg_match('/^(?:diff --git |index [\\da-f\\.]+|[+-]{3} [ab])/', $lines[$i])) { continue; } $collected[] = $lines[$i]; } } - if ($diff !== null && \count($collected)) { + if ($diff !== null && count($collected)) { $this->parseFileDiff($diff, $collected); $diffs[] = $diff; } return $diffs; } - private function parseFileDiff(\RectorPrefix20220607\SebastianBergmann\Diff\Diff $diff, array $lines) : void + private function parseFileDiff(Diff $diff, array $lines) : void { $chunks = []; $chunk = null; $diffLines = []; foreach ($lines as $line) { - if (\preg_match('/^@@\\s+-(?P\\d+)(?:,\\s*(?P\\d+))?\\s+\\+(?P\\d+)(?:,\\s*(?P\\d+))?\\s+@@/', $line, $match)) { - $chunk = new \RectorPrefix20220607\SebastianBergmann\Diff\Chunk((int) $match['start'], isset($match['startrange']) ? \max(1, (int) $match['startrange']) : 1, (int) $match['end'], isset($match['endrange']) ? \max(1, (int) $match['endrange']) : 1); + if (preg_match('/^@@\\s+-(?P\\d+)(?:,\\s*(?P\\d+))?\\s+\\+(?P\\d+)(?:,\\s*(?P\\d+))?\\s+@@/', $line, $match)) { + $chunk = new Chunk((int) $match['start'], isset($match['startrange']) ? max(1, (int) $match['startrange']) : 1, (int) $match['end'], isset($match['endrange']) ? max(1, (int) $match['endrange']) : 1); $chunks[] = $chunk; $diffLines = []; continue; } - if (\preg_match('/^(?P[+ -])?(?P.*)/', $line, $match)) { - $type = \RectorPrefix20220607\SebastianBergmann\Diff\Line::UNCHANGED; + if (preg_match('/^(?P[+ -])?(?P.*)/', $line, $match)) { + $type = Line::UNCHANGED; if ($match['type'] === '+') { - $type = \RectorPrefix20220607\SebastianBergmann\Diff\Line::ADDED; + $type = Line::ADDED; } elseif ($match['type'] === '-') { - $type = \RectorPrefix20220607\SebastianBergmann\Diff\Line::REMOVED; + $type = Line::REMOVED; } - $diffLines[] = new \RectorPrefix20220607\SebastianBergmann\Diff\Line($type, $match['line']); + $diffLines[] = new Line($type, $match['line']); if (null !== $chunk) { $chunk->setLines($diffLines); } diff --git a/vendor/sebastian/diff/src/TimeEfficientLongestCommonSubsequenceCalculator.php b/vendor/sebastian/diff/src/TimeEfficientLongestCommonSubsequenceCalculator.php index 4c36f8144c2..9b6f8886ed6 100644 --- a/vendor/sebastian/diff/src/TimeEfficientLongestCommonSubsequenceCalculator.php +++ b/vendor/sebastian/diff/src/TimeEfficientLongestCommonSubsequenceCalculator.php @@ -15,7 +15,7 @@ use function array_reverse; use function count; use function max; use SplFixedArray; -final class TimeEfficientLongestCommonSubsequenceCalculator implements \RectorPrefix20220607\SebastianBergmann\Diff\LongestCommonSubsequenceCalculator +final class TimeEfficientLongestCommonSubsequenceCalculator implements LongestCommonSubsequenceCalculator { /** * {@inheritdoc} @@ -23,10 +23,10 @@ final class TimeEfficientLongestCommonSubsequenceCalculator implements \RectorPr public function calculate(array $from, array $to) : array { $common = []; - $fromLength = \count($from); - $toLength = \count($to); + $fromLength = count($from); + $toLength = count($to); $width = $fromLength + 1; - $matrix = new \SplFixedArray($width * ($toLength + 1)); + $matrix = new SplFixedArray($width * ($toLength + 1)); for ($i = 0; $i <= $fromLength; ++$i) { $matrix[$i] = 0; } @@ -36,7 +36,7 @@ final class TimeEfficientLongestCommonSubsequenceCalculator implements \RectorPr for ($i = 1; $i <= $fromLength; ++$i) { for ($j = 1; $j <= $toLength; ++$j) { $o = $j * $width + $i; - $matrix[$o] = \max($matrix[$o - 1], $matrix[$o - $width], $from[$i - 1] === $to[$j - 1] ? $matrix[$o - $width - 1] + 1 : 0); + $matrix[$o] = max($matrix[$o - 1], $matrix[$o - $width], $from[$i - 1] === $to[$j - 1] ? $matrix[$o - $width - 1] + 1 : 0); } } $i = $fromLength; @@ -55,6 +55,6 @@ final class TimeEfficientLongestCommonSubsequenceCalculator implements \RectorPr } } } - return \array_reverse($common); + return array_reverse($common); } } diff --git a/vendor/symfony/config/Builder/ClassBuilder.php b/vendor/symfony/config/Builder/ClassBuilder.php index 0e24840d926..6c7af4e7163 100644 --- a/vendor/symfony/config/Builder/ClassBuilder.php +++ b/vendor/symfony/config/Builder/ClassBuilder.php @@ -120,11 +120,11 @@ BODY } public function addMethod(string $name, string $body, array $params = []) : void { - $this->methods[] = new \RectorPrefix20220607\Symfony\Component\Config\Builder\Method(\strtr($body, ['NAME' => $this->camelCase($name)] + $params)); + $this->methods[] = new Method(\strtr($body, ['NAME' => $this->camelCase($name)] + $params)); } - public function addProperty(string $name, string $classType = null, string $defaultValue = null) : \RectorPrefix20220607\Symfony\Component\Config\Builder\Property + public function addProperty(string $name, string $classType = null, string $defaultValue = null) : Property { - $property = new \RectorPrefix20220607\Symfony\Component\Config\Builder\Property($name, '_' !== $name[0] ? $this->camelCase($name) : $name); + $property = new Property($name, '_' !== $name[0] ? $this->camelCase($name) : $name); if (null !== $classType) { $property->setType($classType); } diff --git a/vendor/symfony/config/Builder/ConfigBuilderGenerator.php b/vendor/symfony/config/Builder/ConfigBuilderGenerator.php index fc9d0cbad06..a2293520bdb 100644 --- a/vendor/symfony/config/Builder/ConfigBuilderGenerator.php +++ b/vendor/symfony/config/Builder/ConfigBuilderGenerator.php @@ -28,7 +28,7 @@ use RectorPrefix20220607\Symfony\Component\Config\Loader\ParamConfigurator; * * @author Tobias Nyholm */ -class ConfigBuilderGenerator implements \RectorPrefix20220607\Symfony\Component\Config\Builder\ConfigBuilderGeneratorInterface +class ConfigBuilderGenerator implements ConfigBuilderGeneratorInterface { /** * @var ClassBuilder[] @@ -45,17 +45,17 @@ class ConfigBuilderGenerator implements \RectorPrefix20220607\Symfony\Component\ /** * @return \Closure that will return the root config class */ - public function build(\RectorPrefix20220607\Symfony\Component\Config\Definition\ConfigurationInterface $configuration) : \Closure + public function build(ConfigurationInterface $configuration) : \Closure { $this->classes = []; $rootNode = $configuration->getConfigTreeBuilder()->buildTree(); - $rootClass = new \RectorPrefix20220607\Symfony\Component\Config\Builder\ClassBuilder('RectorPrefix20220607\\Symfony\\Config', $rootNode->getName()); + $rootClass = new ClassBuilder('RectorPrefix20220607\\Symfony\\Config', $rootNode->getName()); $path = $this->getFullPath($rootClass); if (!\is_file($path)) { // Generate the class if the file not exists $this->classes[] = $rootClass; $this->buildNode($rootNode, $rootClass, $this->getSubNamespace($rootClass)); - $rootClass->addImplements(\RectorPrefix20220607\Symfony\Component\Config\Builder\ConfigBuilderInterface::class); + $rootClass->addImplements(ConfigBuilderInterface::class); $rootClass->addMethod('getExtensionAlias', ' public function NAME(): string { @@ -69,7 +69,7 @@ public function NAME(): string return new $className(); }; } - private function getFullPath(\RectorPrefix20220607\Symfony\Component\Config\Builder\ClassBuilder $class) : string + private function getFullPath(ClassBuilder $class) : string { $directory = $this->outputDir . \DIRECTORY_SEPARATOR . $class->getDirectory(); if (!\is_dir($directory)) { @@ -90,23 +90,23 @@ public function NAME(): string } $this->classes = []; } - private function buildNode(\RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface $node, \RectorPrefix20220607\Symfony\Component\Config\Builder\ClassBuilder $class, string $namespace) : void + private function buildNode(NodeInterface $node, ClassBuilder $class, string $namespace) : void { - if (!$node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\ArrayNode) { + if (!$node instanceof ArrayNode) { throw new \LogicException('The node was expected to be an ArrayNode. This Configuration includes an edge case not supported yet.'); } foreach ($node->getChildren() as $child) { switch (\true) { - case $child instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\ScalarNode: + case $child instanceof ScalarNode: $this->handleScalarNode($child, $class); break; - case $child instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\PrototypedArrayNode: + case $child instanceof PrototypedArrayNode: $this->handlePrototypedArrayNode($child, $class, $namespace); break; - case $child instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\VariableNode: + case $child instanceof VariableNode: $this->handleVariableNode($child, $class); break; - case $child instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\ArrayNode: + case $child instanceof ArrayNode: $this->handleArrayNode($child, $class, $namespace); break; default: @@ -114,9 +114,9 @@ public function NAME(): string } } } - private function handleArrayNode(\RectorPrefix20220607\Symfony\Component\Config\Definition\ArrayNode $node, \RectorPrefix20220607\Symfony\Component\Config\Builder\ClassBuilder $class, string $namespace) : void + private function handleArrayNode(ArrayNode $node, ClassBuilder $class, string $namespace) : void { - $childClass = new \RectorPrefix20220607\Symfony\Component\Config\Builder\ClassBuilder($namespace, $node->getName()); + $childClass = new ClassBuilder($namespace, $node->getName()); $childClass->setAllowExtraKeys($node->shouldIgnoreExtraKeys()); $class->addRequire($childClass); $this->classes[] = $childClass; @@ -159,15 +159,15 @@ COMMENTpublic function NAME(array $value = []): CLASS return $this->PROPERTY; }'; - $class->addUse(\RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); + $class->addUse(InvalidConfigurationException::class); $class->addMethod($node->getName(), $body, ['COMMENT' => $comment, 'PROPERTY' => $property->getName(), 'CLASS' => $childClass->getFqcn()]); $this->buildNode($node, $childClass, $this->getSubNamespace($childClass)); } - private function handleVariableNode(\RectorPrefix20220607\Symfony\Component\Config\Definition\VariableNode $node, \RectorPrefix20220607\Symfony\Component\Config\Builder\ClassBuilder $class) : void + private function handleVariableNode(VariableNode $node, ClassBuilder $class) : void { $comment = $this->getComment($node); $property = $class->addProperty($node->getName()); - $class->addUse(\RectorPrefix20220607\Symfony\Component\Config\Loader\ParamConfigurator::class); + $class->addUse(ParamConfigurator::class); $body = ' /** COMMENT * @@ -182,15 +182,15 @@ public function NAME(mixed $valueDEFAULT): static }'; $class->addMethod($node->getName(), $body, ['PROPERTY' => $property->getName(), 'COMMENT' => $comment, 'DEFAULT' => $node->hasDefaultValue() ? ' = ' . \var_export($node->getDefaultValue(), \true) : '']); } - private function handlePrototypedArrayNode(\RectorPrefix20220607\Symfony\Component\Config\Definition\PrototypedArrayNode $node, \RectorPrefix20220607\Symfony\Component\Config\Builder\ClassBuilder $class, string $namespace) : void + private function handlePrototypedArrayNode(PrototypedArrayNode $node, ClassBuilder $class, string $namespace) : void { $name = $this->getSingularName($node); $prototype = $node->getPrototype(); $methodName = $name; $hasNormalizationClosures = $this->hasNormalizationClosures($node) || $this->hasNormalizationClosures($prototype); $parameterType = $this->getParameterType($prototype); - if (null !== $parameterType || $prototype instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\ScalarNode) { - $class->addUse(\RectorPrefix20220607\Symfony\Component\Config\Loader\ParamConfigurator::class); + if (null !== $parameterType || $prototype instanceof ScalarNode) { + $class->addUse(ParamConfigurator::class); $property = $class->addProperty($node->getName()); if (null === ($key = $node->getKeyAttribute())) { // This is an array of values; don't use singular name @@ -224,8 +224,8 @@ public function NAME(string $VAR, TYPE $VALUE): static } return; } - $childClass = new \RectorPrefix20220607\Symfony\Component\Config\Builder\ClassBuilder($namespace, $name); - if ($prototype instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\ArrayNode) { + $childClass = new ClassBuilder($namespace, $name); + if ($prototype instanceof ArrayNode) { $childClass->setAllowExtraKeys($prototype->shouldIgnoreExtraKeys()); } $class->addRequire($childClass); @@ -289,16 +289,16 @@ COMMENTpublic function NAME(string $VAR, array $VALUE = []): CLASS return $this->PROPERTY[$VAR]; }'; - $class->addUse(\RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); + $class->addUse(InvalidConfigurationException::class); $class->addMethod($methodName, $body, ['COMMENT' => $comment, 'PROPERTY' => $property->getName(), 'CLASS' => $childClass->getFqcn(), 'VAR' => '' === $key ? 'key' : $key, 'VALUE' => 'value' === $key ? 'data' : 'value']); } $this->buildNode($prototype, $childClass, $namespace . '\\' . $childClass->getName()); } - private function handleScalarNode(\RectorPrefix20220607\Symfony\Component\Config\Definition\ScalarNode $node, \RectorPrefix20220607\Symfony\Component\Config\Builder\ClassBuilder $class) : void + private function handleScalarNode(ScalarNode $node, ClassBuilder $class) : void { $comment = $this->getComment($node); $property = $class->addProperty($node->getName()); - $class->addUse(\RectorPrefix20220607\Symfony\Component\Config\Loader\ParamConfigurator::class); + $class->addUse(ParamConfigurator::class); $body = ' /** COMMENT * @return $this @@ -312,44 +312,44 @@ public function NAME($value): static }'; $class->addMethod($node->getName(), $body, ['PROPERTY' => $property->getName(), 'COMMENT' => $comment]); } - private function getParameterType(\RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface $node) : ?string + private function getParameterType(NodeInterface $node) : ?string { - if ($node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\BooleanNode) { + if ($node instanceof BooleanNode) { return 'bool'; } - if ($node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\IntegerNode) { + if ($node instanceof IntegerNode) { return 'int'; } - if ($node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\FloatNode) { + if ($node instanceof FloatNode) { return 'float'; } - if ($node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\EnumNode) { + if ($node instanceof EnumNode) { return ''; } - if ($node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\PrototypedArrayNode && $node->getPrototype() instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\ScalarNode) { + if ($node instanceof PrototypedArrayNode && $node->getPrototype() instanceof ScalarNode) { // This is just an array of variables return 'array'; } - if ($node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\VariableNode) { + if ($node instanceof VariableNode) { // mixed return ''; } return null; } - private function getComment(\RectorPrefix20220607\Symfony\Component\Config\Definition\BaseNode $node) : string + private function getComment(BaseNode $node) : string { $comment = ''; if ('' !== ($info = (string) $node->getInfo())) { $comment .= ' * ' . $info . "\n"; } - if (!$node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\ArrayNode) { + if (!$node instanceof ArrayNode) { foreach ((array) ($node->getExample() ?? []) as $example) { $comment .= ' * @example ' . $example . "\n"; } if ('' !== ($default = $node->getDefaultValue())) { $comment .= ' * @default ' . (null === $default ? 'null' : \var_export($default, \true)) . "\n"; } - if ($node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\EnumNode) { + if ($node instanceof EnumNode) { $comment .= \sprintf(' * @param ParamConfigurator|%s $value', \implode('|', \array_map(function ($a) { return \var_export($a, \true); }, $node->getValues()))) . "\n"; @@ -376,14 +376,14 @@ public function NAME($value): static /** * Pick a good singular name. */ - private function getSingularName(\RectorPrefix20220607\Symfony\Component\Config\Definition\PrototypedArrayNode $node) : string + private function getSingularName(PrototypedArrayNode $node) : string { $name = $node->getName(); if (\substr_compare($name, 's', -\strlen('s')) !== 0) { return $name; } $parent = $node->getParent(); - $mappings = $parent instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\ArrayNode ? $parent->getXmlRemappings() : []; + $mappings = $parent instanceof ArrayNode ? $parent->getXmlRemappings() : []; foreach ($mappings as $map) { if ($map[1] === $name) { $name = $map[0]; @@ -392,7 +392,7 @@ public function NAME($value): static } return $name; } - private function buildToArray(\RectorPrefix20220607\Symfony\Component\Config\Builder\ClassBuilder $class) : void + private function buildToArray(ClassBuilder $class) : void { $body = '$output = [];'; foreach ($class->getProperties() as $p) { @@ -418,7 +418,7 @@ public function NAME(): array return $output' . $extraKeys . '; }'); } - private function buildConstructor(\RectorPrefix20220607\Symfony\Component\Config\Builder\ClassBuilder $class) : void + private function buildConstructor(ClassBuilder $class) : void { $body = ''; foreach ($class->getProperties() as $p) { @@ -447,19 +447,19 @@ public function NAME(): array if ([] !== $value) { throw new InvalidConfigurationException(sprintf(\'The following keys are not supported by "%s": \', __CLASS__).implode(\', \', array_keys($value))); }'; - $class->addUse(\RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); + $class->addUse(InvalidConfigurationException::class); } $class->addMethod('__construct', ' public function __construct(array $value = []) {' . $body . ' }'); } - private function buildSetExtraKey(\RectorPrefix20220607\Symfony\Component\Config\Builder\ClassBuilder $class) : void + private function buildSetExtraKey(ClassBuilder $class) : void { if (!$class->shouldAllowExtraKeys()) { return; } - $class->addUse(\RectorPrefix20220607\Symfony\Component\Config\Loader\ParamConfigurator::class); + $class->addUse(ParamConfigurator::class); $class->addProperty('_extraKeys'); $class->addMethod('set', ' /** @@ -474,11 +474,11 @@ public function NAME(string $key, mixed $value): static return $this; }'); } - private function getSubNamespace(\RectorPrefix20220607\Symfony\Component\Config\Builder\ClassBuilder $rootClass) : string + private function getSubNamespace(ClassBuilder $rootClass) : string { return \sprintf('%s\\%s', $rootClass->getNamespace(), \substr($rootClass->getName(), 0, -6)); } - private function hasNormalizationClosures(\RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface $node) : bool + private function hasNormalizationClosures(NodeInterface $node) : bool { try { $r = new \ReflectionProperty($node, 'normalizationClosures'); diff --git a/vendor/symfony/config/Builder/ConfigBuilderGeneratorInterface.php b/vendor/symfony/config/Builder/ConfigBuilderGeneratorInterface.php index 0030d393789..2ef02f0266d 100644 --- a/vendor/symfony/config/Builder/ConfigBuilderGeneratorInterface.php +++ b/vendor/symfony/config/Builder/ConfigBuilderGeneratorInterface.php @@ -21,5 +21,5 @@ interface ConfigBuilderGeneratorInterface /** * @return \Closure that will return the root config class */ - public function build(\RectorPrefix20220607\Symfony\Component\Config\Definition\ConfigurationInterface $configuration) : \Closure; + public function build(ConfigurationInterface $configuration) : \Closure; } diff --git a/vendor/symfony/config/ConfigCache.php b/vendor/symfony/config/ConfigCache.php index 475dfddf6cd..08b8967fe72 100644 --- a/vendor/symfony/config/ConfigCache.php +++ b/vendor/symfony/config/ConfigCache.php @@ -21,7 +21,7 @@ use RectorPrefix20220607\Symfony\Component\Config\Resource\SelfCheckingResourceC * @author Fabien Potencier * @author Matthias Pigulla */ -class ConfigCache extends \RectorPrefix20220607\Symfony\Component\Config\ResourceCheckerConfigCache +class ConfigCache extends ResourceCheckerConfigCache { /** * @var bool @@ -36,7 +36,7 @@ class ConfigCache extends \RectorPrefix20220607\Symfony\Component\Config\Resourc $this->debug = $debug; $checkers = []; if (\true === $this->debug) { - $checkers = [new \RectorPrefix20220607\Symfony\Component\Config\Resource\SelfCheckingResourceChecker()]; + $checkers = [new SelfCheckingResourceChecker()]; } parent::__construct($file, $checkers); } diff --git a/vendor/symfony/config/ConfigCacheFactory.php b/vendor/symfony/config/ConfigCacheFactory.php index 74a7734b72d..add7d6e03a3 100644 --- a/vendor/symfony/config/ConfigCacheFactory.php +++ b/vendor/symfony/config/ConfigCacheFactory.php @@ -19,7 +19,7 @@ namespace RectorPrefix20220607\Symfony\Component\Config; * * @author Matthias Pigulla */ -class ConfigCacheFactory implements \RectorPrefix20220607\Symfony\Component\Config\ConfigCacheFactoryInterface +class ConfigCacheFactory implements ConfigCacheFactoryInterface { /** * @var bool @@ -35,9 +35,9 @@ class ConfigCacheFactory implements \RectorPrefix20220607\Symfony\Component\Conf /** * {@inheritdoc} */ - public function cache(string $file, callable $callback) : \RectorPrefix20220607\Symfony\Component\Config\ConfigCacheInterface + public function cache(string $file, callable $callback) : ConfigCacheInterface { - $cache = new \RectorPrefix20220607\Symfony\Component\Config\ConfigCache($file, $this->debug); + $cache = new ConfigCache($file, $this->debug); if (!$cache->isFresh()) { $callback($cache); } diff --git a/vendor/symfony/config/ConfigCacheFactoryInterface.php b/vendor/symfony/config/ConfigCacheFactoryInterface.php index d33ac8dd9ff..60b4bf70ded 100644 --- a/vendor/symfony/config/ConfigCacheFactoryInterface.php +++ b/vendor/symfony/config/ConfigCacheFactoryInterface.php @@ -25,5 +25,5 @@ interface ConfigCacheFactoryInterface * @param string $file The absolute cache file path * @param callable $callable The callable to be executed when the cache needs to be filled (i. e. is not fresh). The cache will be passed as the only parameter to this callback */ - public function cache(string $file, callable $callable) : \RectorPrefix20220607\Symfony\Component\Config\ConfigCacheInterface; + public function cache(string $file, callable $callable) : ConfigCacheInterface; } diff --git a/vendor/symfony/config/Definition/ArrayNode.php b/vendor/symfony/config/Definition/ArrayNode.php index a11cdff7feb..2f7bc645c59 100644 --- a/vendor/symfony/config/Definition/ArrayNode.php +++ b/vendor/symfony/config/Definition/ArrayNode.php @@ -18,7 +18,7 @@ use RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\UnsetKeyE * * @author Johannes M. Schmitt */ -class ArrayNode extends \RectorPrefix20220607\Symfony\Component\Config\Definition\BaseNode implements \RectorPrefix20220607\Symfony\Component\Config\Definition\PrototypeNodeInterface +class ArrayNode extends BaseNode implements PrototypeNodeInterface { protected $xmlRemappings = []; protected $children = []; @@ -170,7 +170,7 @@ class ArrayNode extends \RectorPrefix20220607\Symfony\Component\Config\Definitio * @throws \InvalidArgumentException when the child node has no name * @throws \InvalidArgumentException when the child node's name is not unique */ - public function addChild(\RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface $node) + public function addChild(NodeInterface $node) { $name = $node->getName(); if ('' === $name) { @@ -192,7 +192,7 @@ class ArrayNode extends \RectorPrefix20220607\Symfony\Component\Config\Definitio protected function finalizeValue($value) { if (\false === $value) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\UnsetKeyException(\sprintf('Unsetting key for path "%s", value: %s.', $this->getPath(), \json_encode($value))); + throw new UnsetKeyException(\sprintf('Unsetting key for path "%s", value: %s.', $this->getPath(), \json_encode($value))); } foreach ($this->children as $name => $child) { if (!\array_key_exists($name, $value)) { @@ -203,7 +203,7 @@ class ArrayNode extends \RectorPrefix20220607\Symfony\Component\Config\Definitio } else { $message .= '.'; } - $ex = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException($message); + $ex = new InvalidConfigurationException($message); $ex->setPath($this->getPath()); throw $ex; } @@ -214,11 +214,11 @@ class ArrayNode extends \RectorPrefix20220607\Symfony\Component\Config\Definitio } if ($child->isDeprecated()) { $deprecation = $child->getDeprecation($name, $this->getPath()); - trigger_deprecation($deprecation['package'], $deprecation['version'], $deprecation['message']); + \RectorPrefix20220607\trigger_deprecation($deprecation['package'], $deprecation['version'], $deprecation['message']); } try { $value[$name] = $child->finalize($value[$name]); - } catch (\RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\UnsetKeyException $exception) { + } catch (UnsetKeyException $exception) { unset($value[$name]); } } @@ -231,7 +231,7 @@ class ArrayNode extends \RectorPrefix20220607\Symfony\Component\Config\Definitio protected function validateType($value) { if (!\is_array($value) && (!$this->allowFalse || \false !== $value)) { - $ex = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidTypeException(\sprintf('Invalid type for path "%s". Expected "array", but got "%s"', $this->getPath(), \get_debug_type($value))); + $ex = new InvalidTypeException(\sprintf('Invalid type for path "%s". Expected "array", but got "%s"', $this->getPath(), \get_debug_type($value))); if ($hint = $this->getInfo()) { $ex->addHint($hint); } @@ -257,7 +257,7 @@ class ArrayNode extends \RectorPrefix20220607\Symfony\Component\Config\Definitio if (isset($this->children[$name])) { try { $normalized[$name] = $this->children[$name]->normalize($val); - } catch (\RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\UnsetKeyException $exception) { + } catch (UnsetKeyException $exception) { } unset($value[$name]); } elseif (!$this->removeExtraKeys) { @@ -286,7 +286,7 @@ class ArrayNode extends \RectorPrefix20220607\Symfony\Component\Config\Definitio } else { $msg .= \sprintf('. Available option%s %s "%s".', 1 === \count($proposals) ? '' : 's', 1 === \count($proposals) ? 'is' : 'are', \implode('", "', $proposals)); } - $ex = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException($msg); + $ex = new InvalidConfigurationException($msg); $ex->setPath($this->getPath()); throw $ex; } @@ -301,7 +301,7 @@ class ArrayNode extends \RectorPrefix20220607\Symfony\Component\Config\Definitio if (!isset($value[$singular])) { continue; } - $value[$plural] = \RectorPrefix20220607\Symfony\Component\Config\Definition\Processor::normalizeConfig($value, $singular, $plural); + $value[$plural] = Processor::normalizeConfig($value, $singular, $plural); unset($value[$singular]); } return $value; @@ -329,7 +329,7 @@ class ArrayNode extends \RectorPrefix20220607\Symfony\Component\Config\Definitio // no conflict if (!\array_key_exists($k, $leftSide)) { if (!$this->allowNewKeys) { - $ex = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException(\sprintf('You are not allowed to define new elements for path "%s". Please define all elements for this path in one config file. If you are trying to overwrite an element, make sure you redefine it with the same name.', $this->getPath())); + $ex = new InvalidConfigurationException(\sprintf('You are not allowed to define new elements for path "%s". Please define all elements for this path in one config file. If you are trying to overwrite an element, make sure you redefine it with the same name.', $this->getPath())); $ex->setPath($this->getPath()); throw $ex; } diff --git a/vendor/symfony/config/Definition/BaseNode.php b/vendor/symfony/config/Definition/BaseNode.php index 128ec6100f3..3898f2abcb3 100644 --- a/vendor/symfony/config/Definition/BaseNode.php +++ b/vendor/symfony/config/Definition/BaseNode.php @@ -20,7 +20,7 @@ use RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\UnsetKeyE * * @author Johannes M. Schmitt */ -abstract class BaseNode implements \RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface +abstract class BaseNode implements NodeInterface { public const DEFAULT_PATH_SEPARATOR = '.'; /** @@ -48,7 +48,7 @@ abstract class BaseNode implements \RectorPrefix20220607\Symfony\Component\Confi /** * @throws \InvalidArgumentException if the name contains a period */ - public function __construct(?string $name, \RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface $parent = null, string $pathSeparator = self::DEFAULT_PATH_SEPARATOR) + public function __construct(?string $name, NodeInterface $parent = null, string $pathSeparator = self::DEFAULT_PATH_SEPARATOR) { if (\strpos($name = (string) $name, $pathSeparator) !== \false) { throw new \InvalidArgumentException('The name must not contain ".' . $pathSeparator . '".'); @@ -258,7 +258,7 @@ abstract class BaseNode implements \RectorPrefix20220607\Symfony\Component\Confi public final function merge($leftSide, $rightSide) { if (!$this->allowOverwrite) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException(\sprintf('Configuration path "%s" cannot be overwritten. You have to define all options for this path, and any of its sub-paths in one configuration section.', $this->getPath())); + throw new ForbiddenOverwriteException(\sprintf('Configuration path "%s" cannot be overwritten. You have to define all options for this path, and any of its sub-paths in one configuration section.', $this->getPath())); } if ($leftSide !== ($leftPlaceholders = self::resolvePlaceholderValue($leftSide))) { foreach ($leftPlaceholders as $leftPlaceholder) { @@ -333,7 +333,7 @@ abstract class BaseNode implements \RectorPrefix20220607\Symfony\Component\Confi /** * Returns parent node for this node. */ - public function getParent() : ?\RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface + public function getParent() : ?NodeInterface { return $this->parent; } @@ -362,13 +362,13 @@ abstract class BaseNode implements \RectorPrefix20220607\Symfony\Component\Confi foreach ($this->finalValidationClosures as $closure) { try { $value = $closure($value); - } catch (\RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\Exception $e) { - if ($e instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\UnsetKeyException && null !== $this->handlingPlaceholder) { + } catch (Exception $e) { + if ($e instanceof UnsetKeyException && null !== $this->handlingPlaceholder) { continue; } throw $e; } catch (\Exception $e) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException(\sprintf('Invalid configuration for path "%s": ', $this->getPath()) . $e->getMessage(), $e->getCode(), $e); + throw new InvalidConfigurationException(\sprintf('Invalid configuration for path "%s": ', $this->getPath()) . $e->getMessage(), $e->getCode(), $e); } } return $value; @@ -444,7 +444,7 @@ abstract class BaseNode implements \RectorPrefix20220607\Symfony\Component\Confi private function doValidateType($value) : void { if (null !== $this->handlingPlaceholder && !$this->allowPlaceholders()) { - $e = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidTypeException(\sprintf('A dynamic value is not compatible with a "%s" node type at path "%s".', static::class, $this->getPath())); + $e = new InvalidTypeException(\sprintf('A dynamic value is not compatible with a "%s" node type at path "%s".', static::class, $this->getPath())); $e->setPath($this->getPath()); throw $e; } @@ -455,7 +455,7 @@ abstract class BaseNode implements \RectorPrefix20220607\Symfony\Component\Confi $knownTypes = \array_keys(self::$placeholders[$this->handlingPlaceholder]); $validTypes = $this->getValidPlaceholderTypes(); if ($validTypes && \array_diff($knownTypes, $validTypes)) { - $e = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidTypeException(\sprintf('Invalid type for path "%s". Expected %s, but got %s.', $this->getPath(), 1 === \count($validTypes) ? '"' . \reset($validTypes) . '"' : 'one of "' . \implode('", "', $validTypes) . '"', 1 === \count($knownTypes) ? '"' . \reset($knownTypes) . '"' : 'one of "' . \implode('", "', $knownTypes) . '"')); + $e = new InvalidTypeException(\sprintf('Invalid type for path "%s". Expected %s, but got %s.', $this->getPath(), 1 === \count($validTypes) ? '"' . \reset($validTypes) . '"' : 'one of "' . \implode('", "', $validTypes) . '"', 1 === \count($knownTypes) ? '"' . \reset($knownTypes) . '"' : 'one of "' . \implode('", "', $knownTypes) . '"')); if ($hint = $this->getInfo()) { $e->addHint($hint); } diff --git a/vendor/symfony/config/Definition/BooleanNode.php b/vendor/symfony/config/Definition/BooleanNode.php index 60c18372cf0..bdb6ecb51f4 100644 --- a/vendor/symfony/config/Definition/BooleanNode.php +++ b/vendor/symfony/config/Definition/BooleanNode.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidTy * * @author Johannes M. Schmitt */ -class BooleanNode extends \RectorPrefix20220607\Symfony\Component\Config\Definition\ScalarNode +class BooleanNode extends ScalarNode { /** * {@inheritdoc} @@ -25,7 +25,7 @@ class BooleanNode extends \RectorPrefix20220607\Symfony\Component\Config\Definit protected function validateType($value) { if (!\is_bool($value)) { - $ex = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidTypeException(\sprintf('Invalid type for path "%s". Expected "bool", but got "%s".', $this->getPath(), \get_debug_type($value))); + $ex = new InvalidTypeException(\sprintf('Invalid type for path "%s". Expected "bool", but got "%s".', $this->getPath(), \get_debug_type($value))); if ($hint = $this->getInfo()) { $ex->addHint($hint); } diff --git a/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php b/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php index 7d13b682a1d..f52524ae009 100644 --- a/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php +++ b/vendor/symfony/config/Definition/Builder/ArrayNodeDefinition.php @@ -19,7 +19,7 @@ use RectorPrefix20220607\Symfony\Component\Config\Definition\PrototypedArrayNode * * @author Johannes M. Schmitt */ -class ArrayNodeDefinition extends \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeDefinition implements \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\ParentNodeDefinitionInterface +class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinitionInterface { protected $performDeepMerging = \true; protected $ignoreExtraKeys = \false; @@ -37,7 +37,7 @@ class ArrayNodeDefinition extends \RectorPrefix20220607\Symfony\Component\Config /** * {@inheritdoc} */ - public function __construct(?string $name, \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeParentInterface $parent = null) + public function __construct(?string $name, NodeParentInterface $parent = null) { parent::__construct($name, $parent); $this->nullEquivalent = []; @@ -46,41 +46,41 @@ class ArrayNodeDefinition extends \RectorPrefix20220607\Symfony\Component\Config /** * {@inheritdoc} */ - public function setBuilder(\RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeBuilder $builder) + public function setBuilder(NodeBuilder $builder) { $this->nodeBuilder = $builder; } /** * {@inheritdoc} */ - public function children() : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeBuilder + public function children() : NodeBuilder { return $this->getNodeBuilder(); } /** * Sets a prototype for child nodes. */ - public function prototype(string $type) : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeDefinition + public function prototype(string $type) : NodeDefinition { return $this->prototype = $this->getNodeBuilder()->node(null, $type)->setParent($this); } - public function variablePrototype() : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\VariableNodeDefinition + public function variablePrototype() : VariableNodeDefinition { return $this->prototype('variable'); } - public function scalarPrototype() : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition + public function scalarPrototype() : ScalarNodeDefinition { return $this->prototype('scalar'); } - public function booleanPrototype() : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition + public function booleanPrototype() : BooleanNodeDefinition { return $this->prototype('boolean'); } - public function integerPrototype() : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition + public function integerPrototype() : IntegerNodeDefinition { return $this->prototype('integer'); } - public function floatPrototype() : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\FloatNodeDefinition + public function floatPrototype() : FloatNodeDefinition { return $this->prototype('float'); } @@ -88,7 +88,7 @@ class ArrayNodeDefinition extends \RectorPrefix20220607\Symfony\Component\Config { return $this->prototype('array'); } - public function enumPrototype() : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\EnumNodeDefinition + public function enumPrototype() : EnumNodeDefinition { return $this->prototype('enum'); } @@ -279,7 +279,7 @@ class ArrayNodeDefinition extends \RectorPrefix20220607\Symfony\Component\Config * {@inheritdoc} * @return $this */ - public function append(\RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeDefinition $node) + public function append(NodeDefinition $node) { $this->children[$node->name] = $node->setParent($this); return $this; @@ -287,20 +287,20 @@ class ArrayNodeDefinition extends \RectorPrefix20220607\Symfony\Component\Config /** * Returns a node builder to be used to add children and prototype. */ - protected function getNodeBuilder() : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeBuilder + protected function getNodeBuilder() : NodeBuilder { if (null === $this->nodeBuilder) { - $this->nodeBuilder = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeBuilder(); + $this->nodeBuilder = new NodeBuilder(); } return $this->nodeBuilder->setParent($this); } /** * {@inheritdoc} */ - protected function createNode() : \RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface + protected function createNode() : NodeInterface { if (null === $this->prototype) { - $node = new \RectorPrefix20220607\Symfony\Component\Config\Definition\ArrayNode($this->name, $this->parent, $this->pathSeparator); + $node = new ArrayNode($this->name, $this->parent, $this->pathSeparator); $this->validateConcreteNode($node); $node->setAddIfNotSet($this->addDefaults); foreach ($this->children as $child) { @@ -308,7 +308,7 @@ class ArrayNodeDefinition extends \RectorPrefix20220607\Symfony\Component\Config $node->addChild($child->getNode()); } } else { - $node = new \RectorPrefix20220607\Symfony\Component\Config\Definition\PrototypedArrayNode($this->name, $this->parent, $this->pathSeparator); + $node = new PrototypedArrayNode($this->name, $this->parent, $this->pathSeparator); $this->validatePrototypeNode($node); if (null !== $this->key) { $node->setKeyAttribute($this->key, $this->removeKeyItem); @@ -360,23 +360,23 @@ class ArrayNodeDefinition extends \RectorPrefix20220607\Symfony\Component\Config * * @throws InvalidDefinitionException */ - protected function validateConcreteNode(\RectorPrefix20220607\Symfony\Component\Config\Definition\ArrayNode $node) + protected function validateConcreteNode(ArrayNode $node) { $path = $node->getPath(); if (null !== $this->key) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidDefinitionException(\sprintf('->useAttributeAsKey() is not applicable to concrete nodes at path "%s".', $path)); + throw new InvalidDefinitionException(\sprintf('->useAttributeAsKey() is not applicable to concrete nodes at path "%s".', $path)); } if (\false === $this->allowEmptyValue) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidDefinitionException(\sprintf('->cannotBeEmpty() is not applicable to concrete nodes at path "%s".', $path)); + throw new InvalidDefinitionException(\sprintf('->cannotBeEmpty() is not applicable to concrete nodes at path "%s".', $path)); } if (\true === $this->atLeastOne) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidDefinitionException(\sprintf('->requiresAtLeastOneElement() is not applicable to concrete nodes at path "%s".', $path)); + throw new InvalidDefinitionException(\sprintf('->requiresAtLeastOneElement() is not applicable to concrete nodes at path "%s".', $path)); } if ($this->default) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidDefinitionException(\sprintf('->defaultValue() is not applicable to concrete nodes at path "%s".', $path)); + throw new InvalidDefinitionException(\sprintf('->defaultValue() is not applicable to concrete nodes at path "%s".', $path)); } if (\false !== $this->addDefaultChildren) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidDefinitionException(\sprintf('->addDefaultChildrenIfNoneSet() is not applicable to concrete nodes at path "%s".', $path)); + throw new InvalidDefinitionException(\sprintf('->addDefaultChildrenIfNoneSet() is not applicable to concrete nodes at path "%s".', $path)); } } /** @@ -384,21 +384,21 @@ class ArrayNodeDefinition extends \RectorPrefix20220607\Symfony\Component\Config * * @throws InvalidDefinitionException */ - protected function validatePrototypeNode(\RectorPrefix20220607\Symfony\Component\Config\Definition\PrototypedArrayNode $node) + protected function validatePrototypeNode(PrototypedArrayNode $node) { $path = $node->getPath(); if ($this->addDefaults) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidDefinitionException(\sprintf('->addDefaultsIfNotSet() is not applicable to prototype nodes at path "%s".', $path)); + throw new InvalidDefinitionException(\sprintf('->addDefaultsIfNotSet() is not applicable to prototype nodes at path "%s".', $path)); } if (\false !== $this->addDefaultChildren) { if ($this->default) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidDefinitionException(\sprintf('A default value and default children might not be used together at path "%s".', $path)); + throw new InvalidDefinitionException(\sprintf('A default value and default children might not be used together at path "%s".', $path)); } if (null !== $this->key && (null === $this->addDefaultChildren || \is_int($this->addDefaultChildren) && $this->addDefaultChildren > 0)) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidDefinitionException(\sprintf('->addDefaultChildrenIfNoneSet() should set default children names as ->useAttributeAsKey() is used at path "%s".', $path)); + throw new InvalidDefinitionException(\sprintf('->addDefaultChildrenIfNoneSet() should set default children names as ->useAttributeAsKey() is used at path "%s".', $path)); } if (null === $this->key && (\is_string($this->addDefaultChildren) || \is_array($this->addDefaultChildren))) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidDefinitionException(\sprintf('->addDefaultChildrenIfNoneSet() might not set default children names as ->useAttributeAsKey() is not used at path "%s".', $path)); + throw new InvalidDefinitionException(\sprintf('->addDefaultChildrenIfNoneSet() might not set default children names as ->useAttributeAsKey() is not used at path "%s".', $path)); } } } @@ -414,7 +414,7 @@ class ArrayNodeDefinition extends \RectorPrefix20220607\Symfony\Component\Config * * @param string $nodePath The path of the node to find. e.g "doctrine.orm.mappings" */ - public function find(string $nodePath) : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeDefinition + public function find(string $nodePath) : NodeDefinition { $firstPathSegment = \false === ($pathSeparatorPos = \strpos($nodePath, $this->pathSeparator)) ? $nodePath : \substr($nodePath, 0, $pathSeparatorPos); if (null === ($node = $this->children[$firstPathSegment] ?? null)) { diff --git a/vendor/symfony/config/Definition/Builder/BooleanNodeDefinition.php b/vendor/symfony/config/Definition/Builder/BooleanNodeDefinition.php index 72bfbebe254..28d98888196 100644 --- a/vendor/symfony/config/Definition/Builder/BooleanNodeDefinition.php +++ b/vendor/symfony/config/Definition/Builder/BooleanNodeDefinition.php @@ -17,12 +17,12 @@ use RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidDe * * @author Johannes M. Schmitt */ -class BooleanNodeDefinition extends \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition +class BooleanNodeDefinition extends ScalarNodeDefinition { /** * {@inheritdoc} */ - public function __construct(?string $name, \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeParentInterface $parent = null) + public function __construct(?string $name, NodeParentInterface $parent = null) { parent::__construct($name, $parent); $this->nullEquivalent = \true; @@ -32,7 +32,7 @@ class BooleanNodeDefinition extends \RectorPrefix20220607\Symfony\Component\Conf */ protected function instantiateNode() : \RectorPrefix20220607\Symfony\Component\Config\Definition\ScalarNode { - return new \RectorPrefix20220607\Symfony\Component\Config\Definition\BooleanNode($this->name, $this->parent, $this->pathSeparator); + return new BooleanNode($this->name, $this->parent, $this->pathSeparator); } /** * {@inheritdoc} @@ -42,6 +42,6 @@ class BooleanNodeDefinition extends \RectorPrefix20220607\Symfony\Component\Conf */ public function cannotBeEmpty() { - throw new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidDefinitionException('->cannotBeEmpty() is not applicable to BooleanNodeDefinition.'); + throw new InvalidDefinitionException('->cannotBeEmpty() is not applicable to BooleanNodeDefinition.'); } } diff --git a/vendor/symfony/config/Definition/Builder/BuilderAwareInterface.php b/vendor/symfony/config/Definition/Builder/BuilderAwareInterface.php index f505af6adf2..4bc50f52187 100644 --- a/vendor/symfony/config/Definition/Builder/BuilderAwareInterface.php +++ b/vendor/symfony/config/Definition/Builder/BuilderAwareInterface.php @@ -20,5 +20,5 @@ interface BuilderAwareInterface /** * Sets a custom children builder. */ - public function setBuilder(\RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeBuilder $builder); + public function setBuilder(NodeBuilder $builder); } diff --git a/vendor/symfony/config/Definition/Builder/EnumNodeDefinition.php b/vendor/symfony/config/Definition/Builder/EnumNodeDefinition.php index a53404fdaf7..8e769bfe10a 100644 --- a/vendor/symfony/config/Definition/Builder/EnumNodeDefinition.php +++ b/vendor/symfony/config/Definition/Builder/EnumNodeDefinition.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Symfony\Component\Config\Definition\EnumNode; * * @author Johannes M. Schmitt */ -class EnumNodeDefinition extends \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition +class EnumNodeDefinition extends ScalarNodeDefinition { /** * @var mixed[] @@ -44,6 +44,6 @@ class EnumNodeDefinition extends \RectorPrefix20220607\Symfony\Component\Config\ if (!isset($this->values)) { throw new \RuntimeException('You must call ->values() on enum nodes.'); } - return new \RectorPrefix20220607\Symfony\Component\Config\Definition\EnumNode($this->name, $this->parent, $this->values, $this->pathSeparator); + return new EnumNode($this->name, $this->parent, $this->values, $this->pathSeparator); } } diff --git a/vendor/symfony/config/Definition/Builder/ExprBuilder.php b/vendor/symfony/config/Definition/Builder/ExprBuilder.php index cc61be592c2..6b5487b0904 100644 --- a/vendor/symfony/config/Definition/Builder/ExprBuilder.php +++ b/vendor/symfony/config/Definition/Builder/ExprBuilder.php @@ -22,7 +22,7 @@ class ExprBuilder protected $node; public $ifPart; public $thenPart; - public function __construct(\RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeDefinition $node) + public function __construct(NodeDefinition $node) { $this->node = $node; } @@ -193,7 +193,7 @@ class ExprBuilder public function thenUnset() { $this->thenPart = function () { - throw new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\UnsetKeyException('Unsetting key.'); + throw new UnsetKeyException('Unsetting key.'); }; return $this; } diff --git a/vendor/symfony/config/Definition/Builder/FloatNodeDefinition.php b/vendor/symfony/config/Definition/Builder/FloatNodeDefinition.php index 4b149474483..cd926ee9a0e 100644 --- a/vendor/symfony/config/Definition/Builder/FloatNodeDefinition.php +++ b/vendor/symfony/config/Definition/Builder/FloatNodeDefinition.php @@ -16,13 +16,13 @@ use RectorPrefix20220607\Symfony\Component\Config\Definition\FloatNode; * * @author Jeanmonod David */ -class FloatNodeDefinition extends \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NumericNodeDefinition +class FloatNodeDefinition extends NumericNodeDefinition { /** * Instantiates a Node. */ protected function instantiateNode() : \RectorPrefix20220607\Symfony\Component\Config\Definition\ScalarNode { - return new \RectorPrefix20220607\Symfony\Component\Config\Definition\FloatNode($this->name, $this->parent, $this->min, $this->max, $this->pathSeparator); + return new FloatNode($this->name, $this->parent, $this->min, $this->max, $this->pathSeparator); } } diff --git a/vendor/symfony/config/Definition/Builder/IntegerNodeDefinition.php b/vendor/symfony/config/Definition/Builder/IntegerNodeDefinition.php index d37da61454b..1a62a1b0cf7 100644 --- a/vendor/symfony/config/Definition/Builder/IntegerNodeDefinition.php +++ b/vendor/symfony/config/Definition/Builder/IntegerNodeDefinition.php @@ -16,13 +16,13 @@ use RectorPrefix20220607\Symfony\Component\Config\Definition\IntegerNode; * * @author Jeanmonod David */ -class IntegerNodeDefinition extends \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NumericNodeDefinition +class IntegerNodeDefinition extends NumericNodeDefinition { /** * Instantiates a Node. */ protected function instantiateNode() : \RectorPrefix20220607\Symfony\Component\Config\Definition\ScalarNode { - return new \RectorPrefix20220607\Symfony\Component\Config\Definition\IntegerNode($this->name, $this->parent, $this->min, $this->max, $this->pathSeparator); + return new IntegerNode($this->name, $this->parent, $this->min, $this->max, $this->pathSeparator); } } diff --git a/vendor/symfony/config/Definition/Builder/MergeBuilder.php b/vendor/symfony/config/Definition/Builder/MergeBuilder.php index fc4a25b01fe..eab5afea724 100644 --- a/vendor/symfony/config/Definition/Builder/MergeBuilder.php +++ b/vendor/symfony/config/Definition/Builder/MergeBuilder.php @@ -20,7 +20,7 @@ class MergeBuilder protected $node; public $allowFalse = \false; public $allowOverwrite = \true; - public function __construct(\RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeDefinition $node) + public function __construct(NodeDefinition $node) { $this->node = $node; } diff --git a/vendor/symfony/config/Definition/Builder/NodeBuilder.php b/vendor/symfony/config/Definition/Builder/NodeBuilder.php index 5c1034c78e5..b2b0750f159 100644 --- a/vendor/symfony/config/Definition/Builder/NodeBuilder.php +++ b/vendor/symfony/config/Definition/Builder/NodeBuilder.php @@ -15,20 +15,20 @@ namespace RectorPrefix20220607\Symfony\Component\Config\Definition\Builder; * * @author Johannes M. Schmitt */ -class NodeBuilder implements \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeParentInterface +class NodeBuilder implements NodeParentInterface { protected $parent; protected $nodeMapping; public function __construct() { - $this->nodeMapping = ['variable' => \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\VariableNodeDefinition::class, 'scalar' => \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition::class, 'boolean' => \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition::class, 'integer' => \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition::class, 'float' => \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\FloatNodeDefinition::class, 'array' => \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition::class, 'enum' => \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\EnumNodeDefinition::class]; + $this->nodeMapping = ['variable' => VariableNodeDefinition::class, 'scalar' => ScalarNodeDefinition::class, 'boolean' => BooleanNodeDefinition::class, 'integer' => IntegerNodeDefinition::class, 'float' => FloatNodeDefinition::class, 'array' => ArrayNodeDefinition::class, 'enum' => EnumNodeDefinition::class]; } /** * Set the parent node. * * @return $this */ - public function setParent(\RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\ParentNodeDefinitionInterface $parent = null) + public function setParent(ParentNodeDefinitionInterface $parent = null) { $this->parent = $parent; return $this; @@ -36,49 +36,49 @@ class NodeBuilder implements \RectorPrefix20220607\Symfony\Component\Config\Defi /** * Creates a child array node. */ - public function arrayNode(string $name) : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition + public function arrayNode(string $name) : ArrayNodeDefinition { return $this->node($name, 'array'); } /** * Creates a child scalar node. */ - public function scalarNode(string $name) : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition + public function scalarNode(string $name) : ScalarNodeDefinition { return $this->node($name, 'scalar'); } /** * Creates a child Boolean node. */ - public function booleanNode(string $name) : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition + public function booleanNode(string $name) : BooleanNodeDefinition { return $this->node($name, 'boolean'); } /** * Creates a child integer node. */ - public function integerNode(string $name) : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition + public function integerNode(string $name) : IntegerNodeDefinition { return $this->node($name, 'integer'); } /** * Creates a child float node. */ - public function floatNode(string $name) : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\FloatNodeDefinition + public function floatNode(string $name) : FloatNodeDefinition { return $this->node($name, 'float'); } /** * Creates a child EnumNode. */ - public function enumNode(string $name) : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\EnumNodeDefinition + public function enumNode(string $name) : EnumNodeDefinition { return $this->node($name, 'enum'); } /** * Creates a child variable node. */ - public function variableNode(string $name) : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\VariableNodeDefinition + public function variableNode(string $name) : VariableNodeDefinition { return $this->node($name, 'variable'); } @@ -97,7 +97,7 @@ class NodeBuilder implements \RectorPrefix20220607\Symfony\Component\Config\Defi * @throws \RuntimeException When the node type is not registered * @throws \RuntimeException When the node class is not found */ - public function node(?string $name, string $type) : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeDefinition + public function node(?string $name, string $type) : NodeDefinition { $class = $this->getNodeClass($type); $node = new $class($name); @@ -119,9 +119,9 @@ class NodeBuilder implements \RectorPrefix20220607\Symfony\Component\Config\Defi * * @return $this */ - public function append(\RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeDefinition $node) + public function append(NodeDefinition $node) { - if ($node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\BuilderAwareInterface) { + if ($node instanceof BuilderAwareInterface) { $builder = clone $this; $builder->setParent(null); $node->setBuilder($builder); diff --git a/vendor/symfony/config/Definition/Builder/NodeDefinition.php b/vendor/symfony/config/Definition/Builder/NodeDefinition.php index 2ef99647215..2a30991e789 100644 --- a/vendor/symfony/config/Definition/Builder/NodeDefinition.php +++ b/vendor/symfony/config/Definition/Builder/NodeDefinition.php @@ -18,7 +18,7 @@ use RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface; * * @author Johannes M. Schmitt */ -abstract class NodeDefinition implements \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeParentInterface +abstract class NodeDefinition implements NodeParentInterface { protected $name; protected $normalization; @@ -32,10 +32,10 @@ abstract class NodeDefinition implements \RectorPrefix20220607\Symfony\Component protected $nullEquivalent; protected $trueEquivalent = \true; protected $falseEquivalent = \false; - protected $pathSeparator = \RectorPrefix20220607\Symfony\Component\Config\Definition\BaseNode::DEFAULT_PATH_SEPARATOR; + protected $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR; protected $parent; protected $attributes = []; - public function __construct(?string $name, \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeParentInterface $parent = null) + public function __construct(?string $name, NodeParentInterface $parent = null) { $this->parent = $parent; $this->name = $name; @@ -45,7 +45,7 @@ abstract class NodeDefinition implements \RectorPrefix20220607\Symfony\Component * * @return $this */ - public function setParent(\RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeParentInterface $parent) + public function setParent(NodeParentInterface $parent) { $this->parent = $parent; return $this; @@ -91,19 +91,19 @@ abstract class NodeDefinition implements \RectorPrefix20220607\Symfony\Component /** * Creates the node. */ - public function getNode(bool $forceRootNode = \false) : \RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface + public function getNode(bool $forceRootNode = \false) : NodeInterface { if ($forceRootNode) { $this->parent = null; } if (null !== $this->normalization) { - $this->normalization->before = \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\ExprBuilder::buildExpressions($this->normalization->before); + $this->normalization->before = ExprBuilder::buildExpressions($this->normalization->before); } if (null !== $this->validation) { - $this->validation->rules = \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\ExprBuilder::buildExpressions($this->validation->rules); + $this->validation->rules = ExprBuilder::buildExpressions($this->validation->rules); } $node = $this->createNode(); - if ($node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\BaseNode) { + if ($node instanceof BaseNode) { $node->setAttributes($this->attributes); } return $node; @@ -210,7 +210,7 @@ abstract class NodeDefinition implements \RectorPrefix20220607\Symfony\Component /** * Sets an expression to run before the normalization. */ - public function beforeNormalization() : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\ExprBuilder + public function beforeNormalization() : ExprBuilder { return $this->normalization()->before(); } @@ -231,7 +231,7 @@ abstract class NodeDefinition implements \RectorPrefix20220607\Symfony\Component * modify it. * An exception should be thrown when the node is not valid. */ - public function validate() : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\ExprBuilder + public function validate() : ExprBuilder { return $this->validation()->rule(); } @@ -248,30 +248,30 @@ abstract class NodeDefinition implements \RectorPrefix20220607\Symfony\Component /** * Gets the builder for validation rules. */ - protected function validation() : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\ValidationBuilder + protected function validation() : ValidationBuilder { if (null === $this->validation) { - $this->validation = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\ValidationBuilder($this); + $this->validation = new ValidationBuilder($this); } return $this->validation; } /** * Gets the builder for merging rules. */ - protected function merge() : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\MergeBuilder + protected function merge() : MergeBuilder { if (null === $this->merge) { - $this->merge = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\MergeBuilder($this); + $this->merge = new MergeBuilder($this); } return $this->merge; } /** * Gets the builder for normalization rules. */ - protected function normalization() : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NormalizationBuilder + protected function normalization() : NormalizationBuilder { if (null === $this->normalization) { - $this->normalization = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NormalizationBuilder($this); + $this->normalization = new NormalizationBuilder($this); } return $this->normalization; } @@ -280,7 +280,7 @@ abstract class NodeDefinition implements \RectorPrefix20220607\Symfony\Component * * @throws InvalidDefinitionException When the definition is invalid */ - protected abstract function createNode() : \RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface; + protected abstract function createNode() : NodeInterface; /** * Set PathSeparator to use. * @@ -288,7 +288,7 @@ abstract class NodeDefinition implements \RectorPrefix20220607\Symfony\Component */ public function setPathSeparator(string $separator) { - if ($this instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\ParentNodeDefinitionInterface) { + if ($this instanceof ParentNodeDefinitionInterface) { foreach ($this->getChildNodeDefinitions() as $child) { $child->setPathSeparator($separator); } diff --git a/vendor/symfony/config/Definition/Builder/NormalizationBuilder.php b/vendor/symfony/config/Definition/Builder/NormalizationBuilder.php index 1a143c1f760..905cda2b219 100644 --- a/vendor/symfony/config/Definition/Builder/NormalizationBuilder.php +++ b/vendor/symfony/config/Definition/Builder/NormalizationBuilder.php @@ -20,7 +20,7 @@ class NormalizationBuilder protected $node; public $before = []; public $remappings = []; - public function __construct(\RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeDefinition $node) + public function __construct(NodeDefinition $node) { $this->node = $node; } @@ -48,6 +48,6 @@ class NormalizationBuilder $this->before[] = $closure; return $this; } - return $this->before[] = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\ExprBuilder($this->node); + return $this->before[] = new ExprBuilder($this->node); } } diff --git a/vendor/symfony/config/Definition/Builder/NumericNodeDefinition.php b/vendor/symfony/config/Definition/Builder/NumericNodeDefinition.php index 75986ee34a5..d26e6cfbe41 100644 --- a/vendor/symfony/config/Definition/Builder/NumericNodeDefinition.php +++ b/vendor/symfony/config/Definition/Builder/NumericNodeDefinition.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidDe * * @author David Jeanmonod */ -abstract class NumericNodeDefinition extends \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition +abstract class NumericNodeDefinition extends ScalarNodeDefinition { protected $min; protected $max; @@ -60,6 +60,6 @@ abstract class NumericNodeDefinition extends \RectorPrefix20220607\Symfony\Compo */ public function cannotBeEmpty() { - throw new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidDefinitionException('->cannotBeEmpty() is not applicable to NumericNodeDefinition.'); + throw new InvalidDefinitionException('->cannotBeEmpty() is not applicable to NumericNodeDefinition.'); } } diff --git a/vendor/symfony/config/Definition/Builder/ParentNodeDefinitionInterface.php b/vendor/symfony/config/Definition/Builder/ParentNodeDefinitionInterface.php index 35037b1beae..7e8db9c6066 100644 --- a/vendor/symfony/config/Definition/Builder/ParentNodeDefinitionInterface.php +++ b/vendor/symfony/config/Definition/Builder/ParentNodeDefinitionInterface.php @@ -15,12 +15,12 @@ namespace RectorPrefix20220607\Symfony\Component\Config\Definition\Builder; * * @author Victor Berchet */ -interface ParentNodeDefinitionInterface extends \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\BuilderAwareInterface +interface ParentNodeDefinitionInterface extends BuilderAwareInterface { /** * Returns a builder to add children nodes. */ - public function children() : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeBuilder; + public function children() : NodeBuilder; /** * Appends a node definition. * @@ -36,7 +36,7 @@ interface ParentNodeDefinitionInterface extends \RectorPrefix20220607\Symfony\Co * * @return $this */ - public function append(\RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeDefinition $node); + public function append(NodeDefinition $node); /** * Gets the child node definitions. * diff --git a/vendor/symfony/config/Definition/Builder/ScalarNodeDefinition.php b/vendor/symfony/config/Definition/Builder/ScalarNodeDefinition.php index 4d9b07a5590..05e75ec4cab 100644 --- a/vendor/symfony/config/Definition/Builder/ScalarNodeDefinition.php +++ b/vendor/symfony/config/Definition/Builder/ScalarNodeDefinition.php @@ -16,13 +16,13 @@ use RectorPrefix20220607\Symfony\Component\Config\Definition\ScalarNode; * * @author Johannes M. Schmitt */ -class ScalarNodeDefinition extends \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\VariableNodeDefinition +class ScalarNodeDefinition extends VariableNodeDefinition { /** * Instantiate a Node. */ protected function instantiateNode() : \RectorPrefix20220607\Symfony\Component\Config\Definition\VariableNode { - return new \RectorPrefix20220607\Symfony\Component\Config\Definition\ScalarNode($this->name, $this->parent, $this->pathSeparator); + return new ScalarNode($this->name, $this->parent, $this->pathSeparator); } } diff --git a/vendor/symfony/config/Definition/Builder/TreeBuilder.php b/vendor/symfony/config/Definition/Builder/TreeBuilder.php index cdb74873dfc..01be93dd55d 100644 --- a/vendor/symfony/config/Definition/Builder/TreeBuilder.php +++ b/vendor/symfony/config/Definition/Builder/TreeBuilder.php @@ -16,13 +16,13 @@ use RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface; * * @author Johannes M. Schmitt */ -class TreeBuilder implements \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeParentInterface +class TreeBuilder implements NodeParentInterface { protected $tree; protected $root; - public function __construct(string $name, string $type = 'array', \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeBuilder $builder = null) + public function __construct(string $name, string $type = 'array', NodeBuilder $builder = null) { - $builder = $builder ?? new \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeBuilder(); + $builder = $builder ?? new NodeBuilder(); $this->root = $builder->node($name, $type)->setParent($this); } /** @@ -37,7 +37,7 @@ class TreeBuilder implements \RectorPrefix20220607\Symfony\Component\Config\Defi * * @throws \RuntimeException */ - public function buildTree() : \RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface + public function buildTree() : NodeInterface { if (null !== $this->tree) { return $this->tree; diff --git a/vendor/symfony/config/Definition/Builder/ValidationBuilder.php b/vendor/symfony/config/Definition/Builder/ValidationBuilder.php index b6e51927670..e75a05cd580 100644 --- a/vendor/symfony/config/Definition/Builder/ValidationBuilder.php +++ b/vendor/symfony/config/Definition/Builder/ValidationBuilder.php @@ -19,7 +19,7 @@ class ValidationBuilder { protected $node; public $rules = []; - public function __construct(\RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeDefinition $node) + public function __construct(NodeDefinition $node) { $this->node = $node; } @@ -34,6 +34,6 @@ class ValidationBuilder $this->rules[] = $closure; return $this; } - return $this->rules[] = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\ExprBuilder($this->node); + return $this->rules[] = new ExprBuilder($this->node); } } diff --git a/vendor/symfony/config/Definition/Builder/VariableNodeDefinition.php b/vendor/symfony/config/Definition/Builder/VariableNodeDefinition.php index 0a1fa8ecd9e..0de174e383f 100644 --- a/vendor/symfony/config/Definition/Builder/VariableNodeDefinition.php +++ b/vendor/symfony/config/Definition/Builder/VariableNodeDefinition.php @@ -17,19 +17,19 @@ use RectorPrefix20220607\Symfony\Component\Config\Definition\VariableNode; * * @author Johannes M. Schmitt */ -class VariableNodeDefinition extends \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\NodeDefinition +class VariableNodeDefinition extends NodeDefinition { /** * Instantiate a Node. */ - protected function instantiateNode() : \RectorPrefix20220607\Symfony\Component\Config\Definition\VariableNode + protected function instantiateNode() : VariableNode { - return new \RectorPrefix20220607\Symfony\Component\Config\Definition\VariableNode($this->name, $this->parent, $this->pathSeparator); + return new VariableNode($this->name, $this->parent, $this->pathSeparator); } /** * {@inheritdoc} */ - protected function createNode() : \RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface + protected function createNode() : NodeInterface { $node = $this->instantiateNode(); if (null !== $this->normalization) { diff --git a/vendor/symfony/config/Definition/ConfigurableInterface.php b/vendor/symfony/config/Definition/ConfigurableInterface.php index 82fc636e562..6370e520695 100644 --- a/vendor/symfony/config/Definition/ConfigurableInterface.php +++ b/vendor/symfony/config/Definition/ConfigurableInterface.php @@ -19,5 +19,5 @@ interface ConfigurableInterface /** * Generates the configuration tree builder. */ - public function configure(\RectorPrefix20220607\Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator $definition) : void; + public function configure(DefinitionConfigurator $definition) : void; } diff --git a/vendor/symfony/config/Definition/Configuration.php b/vendor/symfony/config/Definition/Configuration.php index e03d88bc12c..57e1ea145b7 100644 --- a/vendor/symfony/config/Definition/Configuration.php +++ b/vendor/symfony/config/Definition/Configuration.php @@ -20,7 +20,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder; * * @final */ -class Configuration implements \RectorPrefix20220607\Symfony\Component\Config\Definition\ConfigurationInterface +class Configuration implements ConfigurationInterface { /** * @var \Symfony\Component\Config\Definition\ConfigurableInterface @@ -34,18 +34,18 @@ class Configuration implements \RectorPrefix20220607\Symfony\Component\Config\De * @var string */ private $alias; - public function __construct(\RectorPrefix20220607\Symfony\Component\Config\Definition\ConfigurableInterface $subject, ?\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container, string $alias) + public function __construct(ConfigurableInterface $subject, ?ContainerBuilder $container, string $alias) { $this->subject = $subject; $this->container = $container; $this->alias = $alias; } - public function getConfigTreeBuilder() : \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\TreeBuilder + public function getConfigTreeBuilder() : TreeBuilder { - $treeBuilder = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\TreeBuilder($this->alias); + $treeBuilder = new TreeBuilder($this->alias); $file = (new \ReflectionObject($this->subject))->getFileName(); - $loader = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Loader\DefinitionFileLoader($treeBuilder, new \RectorPrefix20220607\Symfony\Component\Config\FileLocator(\dirname($file)), $this->container); - $configurator = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator($treeBuilder, $loader, $file, $file); + $loader = new DefinitionFileLoader($treeBuilder, new FileLocator(\dirname($file)), $this->container); + $configurator = new DefinitionConfigurator($treeBuilder, $loader, $file, $file); $this->subject->configure($configurator); return $treeBuilder; } diff --git a/vendor/symfony/config/Definition/Configurator/DefinitionConfigurator.php b/vendor/symfony/config/Definition/Configurator/DefinitionConfigurator.php index 96fa53341ac..98e6a1aaf1d 100644 --- a/vendor/symfony/config/Definition/Configurator/DefinitionConfigurator.php +++ b/vendor/symfony/config/Definition/Configurator/DefinitionConfigurator.php @@ -35,7 +35,7 @@ class DefinitionConfigurator * @var string */ private $file; - public function __construct(\RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\TreeBuilder $treeBuilder, \RectorPrefix20220607\Symfony\Component\Config\Definition\Loader\DefinitionFileLoader $loader, string $path, string $file) + public function __construct(TreeBuilder $treeBuilder, DefinitionFileLoader $loader, string $path, string $file) { $this->treeBuilder = $treeBuilder; $this->loader = $loader; diff --git a/vendor/symfony/config/Definition/Dumper/XmlReferenceDumper.php b/vendor/symfony/config/Definition/Dumper/XmlReferenceDumper.php index 298c43c866b..217862138a0 100644 --- a/vendor/symfony/config/Definition/Dumper/XmlReferenceDumper.php +++ b/vendor/symfony/config/Definition/Dumper/XmlReferenceDumper.php @@ -31,11 +31,11 @@ class XmlReferenceDumper * @var string|null */ private $reference; - public function dump(\RectorPrefix20220607\Symfony\Component\Config\Definition\ConfigurationInterface $configuration, string $namespace = null) + public function dump(ConfigurationInterface $configuration, string $namespace = null) { return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree(), $namespace); } - public function dumpNode(\RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface $node, string $namespace = null) + public function dumpNode(NodeInterface $node, string $namespace = null) { $this->reference = ''; $this->writeNode($node, 0, \true, $namespace); @@ -43,7 +43,7 @@ class XmlReferenceDumper $this->reference = null; return $ref; } - private function writeNode(\RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface $node, int $depth = 0, bool $root = \false, string $namespace = null) + private function writeNode(NodeInterface $node, int $depth = 0, bool $root = \false, string $namespace = null) { $rootName = $root ? 'config' : $node->getName(); $rootNamespace = $namespace ?: ($root ? 'http://example.org/schema/dic/' . $node->getName() : null); @@ -62,7 +62,7 @@ class XmlReferenceDumper $rootAttributeComments = []; $rootChildren = []; $rootComments = []; - if ($node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\ArrayNode) { + if ($node instanceof ArrayNode) { $children = $node->getChildren(); // comments about the root node if ($rootInfo = $node->getInfo()) { @@ -72,7 +72,7 @@ class XmlReferenceDumper $rootComments[] = 'Namespace: ' . $rootNamespace; } // render prototyped nodes - if ($node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\PrototypedArrayNode) { + if ($node instanceof PrototypedArrayNode) { $prototype = $node->getPrototype(); $info = 'prototype'; if (null !== $prototype->getInfo()) { @@ -82,27 +82,27 @@ class XmlReferenceDumper if ($key = $node->getKeyAttribute()) { $rootAttributes[$key] = \str_replace('-', ' ', $rootName) . ' ' . $key; } - if ($prototype instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\PrototypedArrayNode) { + if ($prototype instanceof PrototypedArrayNode) { $prototype->setName($key ?? ''); $children = [$key => $prototype]; - } elseif ($prototype instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\ArrayNode) { + } elseif ($prototype instanceof ArrayNode) { $children = $prototype->getChildren(); } else { if ($prototype->hasDefaultValue()) { $prototypeValue = $prototype->getDefaultValue(); } else { switch (\get_class($prototype)) { - case \RectorPrefix20220607\Symfony\Component\Config\Definition\ScalarNode::class: + case ScalarNode::class: $prototypeValue = 'scalar value'; break; - case \RectorPrefix20220607\Symfony\Component\Config\Definition\FloatNode::class: - case \RectorPrefix20220607\Symfony\Component\Config\Definition\IntegerNode::class: + case FloatNode::class: + case IntegerNode::class: $prototypeValue = 'numeric value'; break; - case \RectorPrefix20220607\Symfony\Component\Config\Definition\BooleanNode::class: + case BooleanNode::class: $prototypeValue = 'true|false'; break; - case \RectorPrefix20220607\Symfony\Component\Config\Definition\EnumNode::class: + case EnumNode::class: $prototypeValue = \implode('|', \array_map('json_encode', $prototype->getValues())); break; default: @@ -114,7 +114,7 @@ class XmlReferenceDumper } // get attributes and elements foreach ($children as $child) { - if ($child instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\ArrayNode) { + if ($child instanceof ArrayNode) { // get elements $rootChildren[] = $child; continue; @@ -126,20 +126,20 @@ class XmlReferenceDumper // use a string which isn't used in the normal world // comments $comments = []; - if ($child instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\BaseNode && ($info = $child->getInfo())) { + if ($child instanceof BaseNode && ($info = $child->getInfo())) { $comments[] = $info; } - if ($child instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\BaseNode && ($example = $child->getExample())) { + if ($child instanceof BaseNode && ($example = $child->getExample())) { $comments[] = 'Example: ' . $example; } if ($child->isRequired()) { $comments[] = 'Required'; } - if ($child instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\BaseNode && $child->isDeprecated()) { + if ($child instanceof BaseNode && $child->isDeprecated()) { $deprecation = $child->getDeprecation($child->getName(), $node->getPath()); $comments[] = \sprintf('Deprecated (%s)', ($deprecation['package'] || $deprecation['version'] ? "Since {$deprecation['package']} {$deprecation['version']}: " : '') . $deprecation['message']); } - if ($child instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\EnumNode) { + if ($child instanceof EnumNode) { $comments[] = 'One of ' . \implode('; ', \array_map('json_encode', $child->getValues())); } if (\count($comments)) { diff --git a/vendor/symfony/config/Definition/Dumper/YamlReferenceDumper.php b/vendor/symfony/config/Definition/Dumper/YamlReferenceDumper.php index de198fe4d32..fb2fec0e738 100644 --- a/vendor/symfony/config/Definition/Dumper/YamlReferenceDumper.php +++ b/vendor/symfony/config/Definition/Dumper/YamlReferenceDumper.php @@ -30,19 +30,19 @@ class YamlReferenceDumper * @var string|null */ private $reference; - public function dump(\RectorPrefix20220607\Symfony\Component\Config\Definition\ConfigurationInterface $configuration) + public function dump(ConfigurationInterface $configuration) { return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree()); } - public function dumpAtPath(\RectorPrefix20220607\Symfony\Component\Config\Definition\ConfigurationInterface $configuration, string $path) + public function dumpAtPath(ConfigurationInterface $configuration, string $path) { $rootNode = $node = $configuration->getConfigTreeBuilder()->buildTree(); foreach (\explode('.', $path) as $step) { - if (!$node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\ArrayNode) { + if (!$node instanceof ArrayNode) { throw new \UnexpectedValueException(\sprintf('Unable to find node at path "%s.%s".', $rootNode->getName(), $path)); } /** @var NodeInterface[] $children */ - $children = $node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\PrototypedArrayNode ? $this->getPrototypeChildren($node) : $node->getChildren(); + $children = $node instanceof PrototypedArrayNode ? $this->getPrototypeChildren($node) : $node->getChildren(); foreach ($children as $child) { if ($child->getName() === $step) { $node = $child; @@ -53,7 +53,7 @@ class YamlReferenceDumper } return $this->dumpNode($node); } - public function dumpNode(\RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface $node) + public function dumpNode(NodeInterface $node) { $this->reference = ''; $this->writeNode($node); @@ -61,20 +61,20 @@ class YamlReferenceDumper $this->reference = null; return $ref; } - private function writeNode(\RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface $node, \RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface $parentNode = null, int $depth = 0, bool $prototypedArray = \false) + private function writeNode(NodeInterface $node, NodeInterface $parentNode = null, int $depth = 0, bool $prototypedArray = \false) { $comments = []; $default = ''; $defaultArray = null; $children = null; $example = null; - if ($node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\BaseNode) { + if ($node instanceof BaseNode) { $example = $node->getExample(); } // defaults - if ($node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\ArrayNode) { + if ($node instanceof ArrayNode) { $children = $node->getChildren(); - if ($node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\PrototypedArrayNode) { + if ($node instanceof PrototypedArrayNode) { $children = $this->getPrototypeChildren($node); } if (!$children) { @@ -84,10 +84,10 @@ class YamlReferenceDumper $default = '[]'; } } - } elseif ($node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\EnumNode) { + } elseif ($node instanceof EnumNode) { $comments[] = 'One of ' . \implode('; ', \array_map('json_encode', $node->getValues())); - $default = $node->hasDefaultValue() ? \RectorPrefix20220607\Symfony\Component\Yaml\Inline::dump($node->getDefaultValue()) : '~'; - } elseif (\RectorPrefix20220607\Symfony\Component\Config\Definition\VariableNode::class === \get_class($node) && \is_array($example)) { + $default = $node->hasDefaultValue() ? Inline::dump($node->getDefaultValue()) : '~'; + } elseif (VariableNode::class === \get_class($node) && \is_array($example)) { // If there is an array example, we are sure we dont need to print a default value $default = ''; } else { @@ -101,7 +101,7 @@ class YamlReferenceDumper $default = '[]'; } } else { - $default = \RectorPrefix20220607\Symfony\Component\Yaml\Inline::dump($default); + $default = Inline::dump($default); } } } @@ -110,19 +110,19 @@ class YamlReferenceDumper $comments[] = 'Required'; } // deprecated? - if ($node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\BaseNode && $node->isDeprecated()) { + if ($node instanceof BaseNode && $node->isDeprecated()) { $deprecation = $node->getDeprecation($node->getName(), $parentNode ? $parentNode->getPath() : $node->getPath()); $comments[] = \sprintf('Deprecated (%s)', ($deprecation['package'] || $deprecation['version'] ? "Since {$deprecation['package']} {$deprecation['version']}: " : '') . $deprecation['message']); } // example if ($example && !\is_array($example)) { - $comments[] = 'Example: ' . \RectorPrefix20220607\Symfony\Component\Yaml\Inline::dump($example); + $comments[] = 'Example: ' . Inline::dump($example); } $default = '' != (string) $default ? ' ' . $default : ''; $comments = \count($comments) ? '# ' . \implode(', ', $comments) : ''; $key = $prototypedArray ? '-' : $node->getName() . ':'; $text = \rtrim(\sprintf('%-21s%s %s', $key, $default, $comments), ' '); - if ($node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\BaseNode && ($info = $node->getInfo())) { + if ($node instanceof BaseNode && ($info = $node->getInfo())) { $this->writeLine(''); // indenting multi-line info $info = \str_replace("\n", \sprintf("\n%" . $depth * 4 . 's# ', ' '), $info); @@ -140,11 +140,11 @@ class YamlReferenceDumper $this->writeLine(''); $message = \count($example) > 1 ? 'Examples' : 'Example'; $this->writeLine('# ' . $message . ':', $depth * 4 + 4); - $this->writeArray(\array_map([\RectorPrefix20220607\Symfony\Component\Yaml\Inline::class, 'dump'], $example), $depth + 1); + $this->writeArray(\array_map([Inline::class, 'dump'], $example), $depth + 1); } if ($children) { foreach ($children as $childNode) { - $this->writeNode($childNode, $node, $depth + 1, $node instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\PrototypedArrayNode && !$node->getKeyAttribute()); + $this->writeNode($childNode, $node, $depth + 1, $node instanceof PrototypedArrayNode && !$node->getKeyAttribute()); } } } @@ -160,8 +160,8 @@ class YamlReferenceDumper private function writeArray(array $array, int $depth) { $arrayIsList = function (array $array) : bool { - if (\function_exists('RectorPrefix20220607\\array_is_list')) { - return array_is_list($array); + if (\function_exists('array_is_list')) { + return \array_is_list($array); } if ($array === []) { return \true; @@ -192,18 +192,18 @@ class YamlReferenceDumper } } } - private function getPrototypeChildren(\RectorPrefix20220607\Symfony\Component\Config\Definition\PrototypedArrayNode $node) : array + private function getPrototypeChildren(PrototypedArrayNode $node) : array { $prototype = $node->getPrototype(); $key = $node->getKeyAttribute(); // Do not expand prototype if it isn't an array node nor uses attribute as key - if (!$key && !$prototype instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\ArrayNode) { + if (!$key && !$prototype instanceof ArrayNode) { return $node->getChildren(); } - if ($prototype instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\ArrayNode) { - $keyNode = new \RectorPrefix20220607\Symfony\Component\Config\Definition\ArrayNode($key, $node); + if ($prototype instanceof ArrayNode) { + $keyNode = new ArrayNode($key, $node); $children = $prototype->getChildren(); - if ($prototype instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\PrototypedArrayNode && $prototype->getKeyAttribute()) { + if ($prototype instanceof PrototypedArrayNode && $prototype->getKeyAttribute()) { $children = $this->getPrototypeChildren($prototype); } // add children @@ -211,7 +211,7 @@ class YamlReferenceDumper $keyNode->addChild($childNode); } } else { - $keyNode = new \RectorPrefix20220607\Symfony\Component\Config\Definition\ScalarNode($key, $node); + $keyNode = new ScalarNode($key, $node); } $info = 'Prototype'; if (null !== $prototype->getInfo()) { diff --git a/vendor/symfony/config/Definition/EnumNode.php b/vendor/symfony/config/Definition/EnumNode.php index a6993257f1a..97886a524ac 100644 --- a/vendor/symfony/config/Definition/EnumNode.php +++ b/vendor/symfony/config/Definition/EnumNode.php @@ -16,13 +16,13 @@ use RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidCo * * @author Johannes M. Schmitt */ -class EnumNode extends \RectorPrefix20220607\Symfony\Component\Config\Definition\ScalarNode +class EnumNode extends ScalarNode { /** * @var mixed[] */ private $values; - public function __construct(?string $name, \RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface $parent = null, array $values = [], string $pathSeparator = \RectorPrefix20220607\Symfony\Component\Config\Definition\BaseNode::DEFAULT_PATH_SEPARATOR) + public function __construct(?string $name, NodeInterface $parent = null, array $values = [], string $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR) { $values = \array_unique($values); if (empty($values)) { @@ -44,7 +44,7 @@ class EnumNode extends \RectorPrefix20220607\Symfony\Component\Config\Definition { $value = parent::finalizeValue($value); if (!\in_array($value, $this->values, \true)) { - $ex = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException(\sprintf('The value %s is not allowed for path "%s". Permissible values: %s', \json_encode($value), $this->getPath(), \implode(', ', \array_map('json_encode', $this->values)))); + $ex = new InvalidConfigurationException(\sprintf('The value %s is not allowed for path "%s". Permissible values: %s', \json_encode($value), $this->getPath(), \implode(', ', \array_map('json_encode', $this->values)))); $ex->setPath($this->getPath()); throw $ex; } diff --git a/vendor/symfony/config/Definition/Exception/DuplicateKeyException.php b/vendor/symfony/config/Definition/Exception/DuplicateKeyException.php index 0565d801be1..81da213f8bc 100644 --- a/vendor/symfony/config/Definition/Exception/DuplicateKeyException.php +++ b/vendor/symfony/config/Definition/Exception/DuplicateKeyException.php @@ -16,6 +16,6 @@ namespace RectorPrefix20220607\Symfony\Component\Config\Definition\Exception; * * @author Johannes M. Schmitt */ -class DuplicateKeyException extends \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException +class DuplicateKeyException extends InvalidConfigurationException { } diff --git a/vendor/symfony/config/Definition/Exception/ForbiddenOverwriteException.php b/vendor/symfony/config/Definition/Exception/ForbiddenOverwriteException.php index e481212b7cc..ac2a75603ad 100644 --- a/vendor/symfony/config/Definition/Exception/ForbiddenOverwriteException.php +++ b/vendor/symfony/config/Definition/Exception/ForbiddenOverwriteException.php @@ -16,6 +16,6 @@ namespace RectorPrefix20220607\Symfony\Component\Config\Definition\Exception; * * @author Johannes M. Schmitt */ -class ForbiddenOverwriteException extends \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException +class ForbiddenOverwriteException extends InvalidConfigurationException { } diff --git a/vendor/symfony/config/Definition/Exception/InvalidConfigurationException.php b/vendor/symfony/config/Definition/Exception/InvalidConfigurationException.php index 968db344a95..6792c460c35 100644 --- a/vendor/symfony/config/Definition/Exception/InvalidConfigurationException.php +++ b/vendor/symfony/config/Definition/Exception/InvalidConfigurationException.php @@ -16,7 +16,7 @@ namespace RectorPrefix20220607\Symfony\Component\Config\Definition\Exception; * * @author Johannes M. Schmitt */ -class InvalidConfigurationException extends \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\Exception +class InvalidConfigurationException extends Exception { /** * @var string|null diff --git a/vendor/symfony/config/Definition/Exception/InvalidDefinitionException.php b/vendor/symfony/config/Definition/Exception/InvalidDefinitionException.php index 3e13e95d1dd..72970337d42 100644 --- a/vendor/symfony/config/Definition/Exception/InvalidDefinitionException.php +++ b/vendor/symfony/config/Definition/Exception/InvalidDefinitionException.php @@ -15,6 +15,6 @@ namespace RectorPrefix20220607\Symfony\Component\Config\Definition\Exception; * * @author Victor Berchet */ -class InvalidDefinitionException extends \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\Exception +class InvalidDefinitionException extends Exception { } diff --git a/vendor/symfony/config/Definition/Exception/InvalidTypeException.php b/vendor/symfony/config/Definition/Exception/InvalidTypeException.php index 09ba45a56b3..e5972f1f9ce 100644 --- a/vendor/symfony/config/Definition/Exception/InvalidTypeException.php +++ b/vendor/symfony/config/Definition/Exception/InvalidTypeException.php @@ -15,6 +15,6 @@ namespace RectorPrefix20220607\Symfony\Component\Config\Definition\Exception; * * @author Johannes M. Schmitt */ -class InvalidTypeException extends \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException +class InvalidTypeException extends InvalidConfigurationException { } diff --git a/vendor/symfony/config/Definition/Exception/UnsetKeyException.php b/vendor/symfony/config/Definition/Exception/UnsetKeyException.php index 2cbf29d0988..d7792687edd 100644 --- a/vendor/symfony/config/Definition/Exception/UnsetKeyException.php +++ b/vendor/symfony/config/Definition/Exception/UnsetKeyException.php @@ -16,6 +16,6 @@ namespace RectorPrefix20220607\Symfony\Component\Config\Definition\Exception; * * @author Johannes M. Schmitt */ -class UnsetKeyException extends \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\Exception +class UnsetKeyException extends Exception { } diff --git a/vendor/symfony/config/Definition/FloatNode.php b/vendor/symfony/config/Definition/FloatNode.php index c11dc173bbd..493205c742b 100644 --- a/vendor/symfony/config/Definition/FloatNode.php +++ b/vendor/symfony/config/Definition/FloatNode.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidTy * * @author Jeanmonod David */ -class FloatNode extends \RectorPrefix20220607\Symfony\Component\Config\Definition\NumericNode +class FloatNode extends NumericNode { /** * {@inheritdoc} @@ -29,7 +29,7 @@ class FloatNode extends \RectorPrefix20220607\Symfony\Component\Config\Definitio $value = (float) $value; } if (!\is_float($value)) { - $ex = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidTypeException(\sprintf('Invalid type for path "%s". Expected "float", but got "%s".', $this->getPath(), \get_debug_type($value))); + $ex = new InvalidTypeException(\sprintf('Invalid type for path "%s". Expected "float", but got "%s".', $this->getPath(), \get_debug_type($value))); if ($hint = $this->getInfo()) { $ex->addHint($hint); } diff --git a/vendor/symfony/config/Definition/IntegerNode.php b/vendor/symfony/config/Definition/IntegerNode.php index f315f2a4ec5..907c53c7818 100644 --- a/vendor/symfony/config/Definition/IntegerNode.php +++ b/vendor/symfony/config/Definition/IntegerNode.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidTy * * @author Jeanmonod David */ -class IntegerNode extends \RectorPrefix20220607\Symfony\Component\Config\Definition\NumericNode +class IntegerNode extends NumericNode { /** * {@inheritdoc} @@ -25,7 +25,7 @@ class IntegerNode extends \RectorPrefix20220607\Symfony\Component\Config\Definit protected function validateType($value) { if (!\is_int($value)) { - $ex = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidTypeException(\sprintf('Invalid type for path "%s". Expected "int", but got "%s".', $this->getPath(), \get_debug_type($value))); + $ex = new InvalidTypeException(\sprintf('Invalid type for path "%s". Expected "int", but got "%s".', $this->getPath(), \get_debug_type($value))); if ($hint = $this->getInfo()) { $ex->addHint($hint); } diff --git a/vendor/symfony/config/Definition/Loader/DefinitionFileLoader.php b/vendor/symfony/config/Definition/Loader/DefinitionFileLoader.php index 4d1cdd0bdd7..d003e75df63 100644 --- a/vendor/symfony/config/Definition/Loader/DefinitionFileLoader.php +++ b/vendor/symfony/config/Definition/Loader/DefinitionFileLoader.php @@ -22,7 +22,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder; * * @author Yonel Ceruto */ -class DefinitionFileLoader extends \RectorPrefix20220607\Symfony\Component\Config\Loader\FileLoader +class DefinitionFileLoader extends FileLoader { /** * @var \Symfony\Component\Config\Definition\Builder\TreeBuilder @@ -32,7 +32,7 @@ class DefinitionFileLoader extends \RectorPrefix20220607\Symfony\Component\Confi * @var \Symfony\Component\DependencyInjection\ContainerBuilder|null */ private $container; - public function __construct(\RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\TreeBuilder $treeBuilder, \RectorPrefix20220607\Symfony\Component\Config\FileLocatorInterface $locator, ?\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container = null) + public function __construct(TreeBuilder $treeBuilder, FileLocatorInterface $locator, ?ContainerBuilder $container = null) { $this->treeBuilder = $treeBuilder; $this->container = $container; @@ -53,10 +53,10 @@ class DefinitionFileLoader extends \RectorPrefix20220607\Symfony\Component\Confi // the closure forbids access to the private scope in the included file $load = \Closure::bind(static function ($file) use($loader) { return include $file; - }, null, \RectorPrefix20220607\Symfony\Component\Config\Definition\Loader\ProtectedDefinitionFileLoader::class); + }, null, ProtectedDefinitionFileLoader::class); $callback = $load($path); if (\is_object($callback) && \is_callable($callback)) { - $this->executeCallback($callback, new \RectorPrefix20220607\Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator($this->treeBuilder, $this, $path, $resource), $path); + $this->executeCallback($callback, new DefinitionConfigurator($this->treeBuilder, $this, $path, $resource), $path); } return null; } @@ -74,7 +74,7 @@ class DefinitionFileLoader extends \RectorPrefix20220607\Symfony\Component\Confi } return 'php' === $type; } - private function executeCallback(callable $callback, \RectorPrefix20220607\Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator $configurator, string $path) : void + private function executeCallback(callable $callback, DefinitionConfigurator $configurator, string $path) : void { $callback = \Closure::fromCallable($callback); $arguments = []; @@ -82,16 +82,16 @@ class DefinitionFileLoader extends \RectorPrefix20220607\Symfony\Component\Confi foreach ($r->getParameters() as $parameter) { $reflectionType = $parameter->getType(); if (!$reflectionType instanceof \ReflectionNamedType) { - throw new \InvalidArgumentException(\sprintf('Could not resolve argument "$%s" for "%s". You must typehint it (for example with "%s").', $parameter->getName(), $path, \RectorPrefix20220607\Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator::class)); + throw new \InvalidArgumentException(\sprintf('Could not resolve argument "$%s" for "%s". You must typehint it (for example with "%s").', $parameter->getName(), $path, DefinitionConfigurator::class)); } switch ($reflectionType->getName()) { - case \RectorPrefix20220607\Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator::class: + case DefinitionConfigurator::class: $arguments[] = $configurator; break; - case \RectorPrefix20220607\Symfony\Component\Config\Definition\Builder\TreeBuilder::class: + case TreeBuilder::class: $arguments[] = $this->treeBuilder; break; - case \RectorPrefix20220607\Symfony\Component\Config\Loader\FileLoader::class: + case FileLoader::class: case self::class: $arguments[] = $this; break; @@ -103,6 +103,6 @@ class DefinitionFileLoader extends \RectorPrefix20220607\Symfony\Component\Confi /** * @internal */ -final class ProtectedDefinitionFileLoader extends \RectorPrefix20220607\Symfony\Component\Config\Definition\Loader\DefinitionFileLoader +final class ProtectedDefinitionFileLoader extends DefinitionFileLoader { } diff --git a/vendor/symfony/config/Definition/NumericNode.php b/vendor/symfony/config/Definition/NumericNode.php index f786280c45b..4af85e9f378 100644 --- a/vendor/symfony/config/Definition/NumericNode.php +++ b/vendor/symfony/config/Definition/NumericNode.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidCo * * @author David Jeanmonod */ -class NumericNode extends \RectorPrefix20220607\Symfony\Component\Config\Definition\ScalarNode +class NumericNode extends ScalarNode { protected $min; protected $max; @@ -24,7 +24,7 @@ class NumericNode extends \RectorPrefix20220607\Symfony\Component\Config\Definit * @param int|float $min * @param int|float $max */ - public function __construct(?string $name, \RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface $parent = null, $min = null, $max = null, string $pathSeparator = \RectorPrefix20220607\Symfony\Component\Config\Definition\BaseNode::DEFAULT_PATH_SEPARATOR) + public function __construct(?string $name, NodeInterface $parent = null, $min = null, $max = null, string $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR) { parent::__construct($name, $parent, $pathSeparator); $this->min = $min; @@ -46,7 +46,7 @@ class NumericNode extends \RectorPrefix20220607\Symfony\Component\Config\Definit $errorMsg = \sprintf('The value %s is too big for path "%s". Should be less than or equal to %s', $value, $this->getPath(), $this->max); } if (isset($errorMsg)) { - $ex = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException($errorMsg); + $ex = new InvalidConfigurationException($errorMsg); $ex->setPath($this->getPath()); throw $ex; } diff --git a/vendor/symfony/config/Definition/Processor.php b/vendor/symfony/config/Definition/Processor.php index 6dec5b21421..73dacc05701 100644 --- a/vendor/symfony/config/Definition/Processor.php +++ b/vendor/symfony/config/Definition/Processor.php @@ -24,7 +24,7 @@ class Processor * * @param array $configs An array of configuration items to process */ - public function process(\RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface $configTree, array $configs) : array + public function process(NodeInterface $configTree, array $configs) : array { $currentConfig = []; foreach ($configs as $config) { @@ -38,7 +38,7 @@ class Processor * * @param array $configs An array of configuration items to process */ - public function processConfiguration(\RectorPrefix20220607\Symfony\Component\Config\Definition\ConfigurationInterface $configuration, array $configs) : array + public function processConfiguration(ConfigurationInterface $configuration, array $configs) : array { return $this->process($configuration->getConfigTreeBuilder()->buildTree(), $configs); } diff --git a/vendor/symfony/config/Definition/PrototypeNodeInterface.php b/vendor/symfony/config/Definition/PrototypeNodeInterface.php index 592770035fe..29635dbd7d4 100644 --- a/vendor/symfony/config/Definition/PrototypeNodeInterface.php +++ b/vendor/symfony/config/Definition/PrototypeNodeInterface.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Symfony\Component\Config\Definition; * * @author Johannes M. Schmitt */ -interface PrototypeNodeInterface extends \RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface +interface PrototypeNodeInterface extends NodeInterface { /** * Sets the name of the node. diff --git a/vendor/symfony/config/Definition/PrototypedArrayNode.php b/vendor/symfony/config/Definition/PrototypedArrayNode.php index f133499e8e8..9ce6c299eb6 100644 --- a/vendor/symfony/config/Definition/PrototypedArrayNode.php +++ b/vendor/symfony/config/Definition/PrototypedArrayNode.php @@ -19,7 +19,7 @@ use RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\UnsetKeyE * * @author Johannes M. Schmitt */ -class PrototypedArrayNode extends \RectorPrefix20220607\Symfony\Component\Config\Definition\ArrayNode +class PrototypedArrayNode extends ArrayNode { protected $prototype; protected $keyAttribute; @@ -124,14 +124,14 @@ class PrototypedArrayNode extends \RectorPrefix20220607\Symfony\Component\Config /** * Sets the node prototype. */ - public function setPrototype(\RectorPrefix20220607\Symfony\Component\Config\Definition\PrototypeNodeInterface $node) + public function setPrototype(PrototypeNodeInterface $node) { $this->prototype = $node; } /** * Retrieves the prototype. */ - public function getPrototype() : \RectorPrefix20220607\Symfony\Component\Config\Definition\PrototypeNodeInterface + public function getPrototype() : PrototypeNodeInterface { return $this->prototype; } @@ -140,9 +140,9 @@ class PrototypedArrayNode extends \RectorPrefix20220607\Symfony\Component\Config * * @throws Exception */ - public function addChild(\RectorPrefix20220607\Symfony\Component\Config\Definition\NodeInterface $node) + public function addChild(NodeInterface $node) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\Exception('A prototyped array node cannot have concrete children.'); + throw new Exception('A prototyped array node cannot have concrete children.'); } /** * {@inheritdoc} @@ -152,18 +152,18 @@ class PrototypedArrayNode extends \RectorPrefix20220607\Symfony\Component\Config protected function finalizeValue($value) { if (\false === $value) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\UnsetKeyException(\sprintf('Unsetting key for path "%s", value: %s.', $this->getPath(), \json_encode($value))); + throw new UnsetKeyException(\sprintf('Unsetting key for path "%s", value: %s.', $this->getPath(), \json_encode($value))); } foreach ($value as $k => $v) { $prototype = $this->getPrototypeForChild($k); try { $value[$k] = $prototype->finalize($v); - } catch (\RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\UnsetKeyException $exception) { + } catch (UnsetKeyException $exception) { unset($value[$k]); } } if (\count($value) < $this->minNumberOfElements) { - $ex = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException(\sprintf('The path "%s" should have at least %d element(s) defined.', $this->getPath(), $this->minNumberOfElements)); + $ex = new InvalidConfigurationException(\sprintf('The path "%s" should have at least %d element(s) defined.', $this->getPath(), $this->minNumberOfElements)); $ex->setPath($this->getPath()); throw $ex; } @@ -183,8 +183,8 @@ class PrototypedArrayNode extends \RectorPrefix20220607\Symfony\Component\Config } $value = $this->remapXml($value); $arrayIsList = function (array $array) : bool { - if (\function_exists('RectorPrefix20220607\\array_is_list')) { - return array_is_list($array); + if (\function_exists('array_is_list')) { + return \array_is_list($array); } if ($array === []) { return \true; @@ -203,7 +203,7 @@ class PrototypedArrayNode extends \RectorPrefix20220607\Symfony\Component\Config foreach ($value as $k => $v) { if (null !== $this->keyAttribute && \is_array($v)) { if (!isset($v[$this->keyAttribute]) && \is_int($k) && $isList) { - $ex = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException(\sprintf('The attribute "%s" must be set for path "%s".', $this->keyAttribute, $this->getPath())); + $ex = new InvalidConfigurationException(\sprintf('The attribute "%s" must be set for path "%s".', $this->keyAttribute, $this->getPath())); $ex->setPath($this->getPath()); throw $ex; } elseif (isset($v[$this->keyAttribute])) { @@ -218,7 +218,7 @@ class PrototypedArrayNode extends \RectorPrefix20220607\Symfony\Component\Config // if only "value" is left if (\array_keys($v) === ['value']) { $v = $v['value']; - if ($this->prototype instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\ArrayNode && ($children = $this->prototype->getChildren()) && \array_key_exists('value', $children)) { + if ($this->prototype instanceof ArrayNode && ($children = $this->prototype->getChildren()) && \array_key_exists('value', $children)) { $valuePrototype = \current($this->valuePrototypes) ?: clone $children['value']; $valuePrototype->parent = $this; $originalClosures = $this->prototype->normalizationClosures; @@ -231,7 +231,7 @@ class PrototypedArrayNode extends \RectorPrefix20220607\Symfony\Component\Config } } if (\array_key_exists($k, $normalized)) { - $ex = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\DuplicateKeyException(\sprintf('Duplicate key "%s" for path "%s".', $k, $this->getPath())); + $ex = new DuplicateKeyException(\sprintf('Duplicate key "%s" for path "%s".', $k, $this->getPath())); $ex->setPath($this->getPath()); throw $ex; } @@ -262,8 +262,8 @@ class PrototypedArrayNode extends \RectorPrefix20220607\Symfony\Component\Config return $rightSide; } $arrayIsList = function (array $array) : bool { - if (\function_exists('RectorPrefix20220607\\array_is_list')) { - return array_is_list($array); + if (\function_exists('array_is_list')) { + return \array_is_list($array); } if ($array === []) { return \true; @@ -287,7 +287,7 @@ class PrototypedArrayNode extends \RectorPrefix20220607\Symfony\Component\Config // no conflict if (!\array_key_exists($k, $leftSide)) { if (!$this->allowNewKeys) { - $ex = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException(\sprintf('You are not allowed to define new elements for path "%s". Please define all elements for this path in one config file.', $this->getPath())); + $ex = new InvalidConfigurationException(\sprintf('You are not allowed to define new elements for path "%s". Please define all elements for this path in one config file.', $this->getPath())); $ex->setPath($this->getPath()); throw $ex; } diff --git a/vendor/symfony/config/Definition/ScalarNode.php b/vendor/symfony/config/Definition/ScalarNode.php index 46f025295d0..b1c800d3637 100644 --- a/vendor/symfony/config/Definition/ScalarNode.php +++ b/vendor/symfony/config/Definition/ScalarNode.php @@ -23,7 +23,7 @@ use RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidTy * * @author Johannes M. Schmitt */ -class ScalarNode extends \RectorPrefix20220607\Symfony\Component\Config\Definition\VariableNode +class ScalarNode extends VariableNode { /** * {@inheritdoc} @@ -32,7 +32,7 @@ class ScalarNode extends \RectorPrefix20220607\Symfony\Component\Config\Definiti protected function validateType($value) { if (!\is_scalar($value) && null !== $value) { - $ex = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidTypeException(\sprintf('Invalid type for path "%s". Expected "scalar", but got "%s".', $this->getPath(), \get_debug_type($value))); + $ex = new InvalidTypeException(\sprintf('Invalid type for path "%s". Expected "scalar", but got "%s".', $this->getPath(), \get_debug_type($value))); if ($hint = $this->getInfo()) { $ex->addHint($hint); } diff --git a/vendor/symfony/config/Definition/VariableNode.php b/vendor/symfony/config/Definition/VariableNode.php index 94e00aa032e..834a713b1a3 100644 --- a/vendor/symfony/config/Definition/VariableNode.php +++ b/vendor/symfony/config/Definition/VariableNode.php @@ -19,7 +19,7 @@ use RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidCo * * @author Jeremy Mikola */ -class VariableNode extends \RectorPrefix20220607\Symfony\Component\Config\Definition\BaseNode implements \RectorPrefix20220607\Symfony\Component\Config\Definition\PrototypeNodeInterface +class VariableNode extends BaseNode implements PrototypeNodeInterface { protected $defaultValueSet = \false; protected $defaultValue; @@ -81,7 +81,7 @@ class VariableNode extends \RectorPrefix20220607\Symfony\Component\Config\Defini // deny environment variables only when using custom validators // this avoids ever passing an empty value to final validation closures if (!$this->allowEmptyValue && $this->isHandlingPlaceholder() && $this->finalValidationClosures) { - $e = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException(\sprintf('The path "%s" cannot contain an environment variable when empty values are not allowed by definition and are validated.', $this->getPath())); + $e = new InvalidConfigurationException(\sprintf('The path "%s" cannot contain an environment variable when empty values are not allowed by definition and are validated.', $this->getPath())); if ($hint = $this->getInfo()) { $e->addHint($hint); } @@ -89,7 +89,7 @@ class VariableNode extends \RectorPrefix20220607\Symfony\Component\Config\Defini throw $e; } if (!$this->allowEmptyValue && $this->isValueEmpty($value)) { - $ex = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException(\sprintf('The path "%s" cannot contain an empty value, but got %s.', $this->getPath(), \json_encode($value))); + $ex = new InvalidConfigurationException(\sprintf('The path "%s" cannot contain an empty value, but got %s.', $this->getPath(), \json_encode($value))); if ($hint = $this->getInfo()) { $ex->addHint($hint); } diff --git a/vendor/symfony/config/Exception/FileLoaderImportCircularReferenceException.php b/vendor/symfony/config/Exception/FileLoaderImportCircularReferenceException.php index 74988d45eb1..e26a8e32d88 100644 --- a/vendor/symfony/config/Exception/FileLoaderImportCircularReferenceException.php +++ b/vendor/symfony/config/Exception/FileLoaderImportCircularReferenceException.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Symfony\Component\Config\Exception; * * @author Fabien Potencier */ -class FileLoaderImportCircularReferenceException extends \RectorPrefix20220607\Symfony\Component\Config\Exception\LoaderLoadException +class FileLoaderImportCircularReferenceException extends LoaderLoadException { public function __construct(array $resources, int $code = 0, \Throwable $previous = null) { diff --git a/vendor/symfony/config/FileLocator.php b/vendor/symfony/config/FileLocator.php index 7532164a3f8..f89f1678c4c 100644 --- a/vendor/symfony/config/FileLocator.php +++ b/vendor/symfony/config/FileLocator.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Symfony\Component\Config\Exception\FileLocatorFileNotFo * * @author Fabien Potencier */ -class FileLocator implements \RectorPrefix20220607\Symfony\Component\Config\FileLocatorInterface +class FileLocator implements FileLocatorInterface { protected $paths; /** @@ -36,7 +36,7 @@ class FileLocator implements \RectorPrefix20220607\Symfony\Component\Config\File } if ($this->isAbsolutePath($name)) { if (!\file_exists($name)) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Exception\FileLocatorFileNotFoundException(\sprintf('The file "%s" does not exist.', $name), 0, null, [$name]); + throw new FileLocatorFileNotFoundException(\sprintf('The file "%s" does not exist.', $name), 0, null, [$name]); } return $name; } @@ -57,7 +57,7 @@ class FileLocator implements \RectorPrefix20220607\Symfony\Component\Config\File } } if (!$filepaths) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Exception\FileLocatorFileNotFoundException(\sprintf('The file "%s" does not exist (in: "%s").', $name, \implode('", "', $paths)), 0, null, $notfound); + throw new FileLocatorFileNotFoundException(\sprintf('The file "%s" does not exist (in: "%s").', $name, \implode('", "', $paths)), 0, null, $notfound); } return $filepaths; } diff --git a/vendor/symfony/config/Loader/DelegatingLoader.php b/vendor/symfony/config/Loader/DelegatingLoader.php index 3fbe5f6e64b..768c0772ed6 100644 --- a/vendor/symfony/config/Loader/DelegatingLoader.php +++ b/vendor/symfony/config/Loader/DelegatingLoader.php @@ -19,9 +19,9 @@ use RectorPrefix20220607\Symfony\Component\Config\Exception\LoaderLoadException; * * @author Fabien Potencier */ -class DelegatingLoader extends \RectorPrefix20220607\Symfony\Component\Config\Loader\Loader +class DelegatingLoader extends Loader { - public function __construct(\RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderResolverInterface $resolver) + public function __construct(LoaderResolverInterface $resolver) { $this->resolver = $resolver; } @@ -33,7 +33,7 @@ class DelegatingLoader extends \RectorPrefix20220607\Symfony\Component\Config\Lo public function load($resource, string $type = null) { if (\false === ($loader = $this->resolver->resolve($resource, $type))) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Exception\LoaderLoadException($resource, null, 0, null, $type); + throw new LoaderLoadException($resource, null, 0, null, $type); } return $loader->load($resource, $type); } diff --git a/vendor/symfony/config/Loader/FileLoader.php b/vendor/symfony/config/Loader/FileLoader.php index eb0b7110793..0323025b4c9 100644 --- a/vendor/symfony/config/Loader/FileLoader.php +++ b/vendor/symfony/config/Loader/FileLoader.php @@ -21,7 +21,7 @@ use RectorPrefix20220607\Symfony\Component\Config\Resource\GlobResource; * * @author Fabien Potencier */ -abstract class FileLoader extends \RectorPrefix20220607\Symfony\Component\Config\Loader\Loader +abstract class FileLoader extends Loader { protected static $loading = []; protected $locator; @@ -29,7 +29,7 @@ abstract class FileLoader extends \RectorPrefix20220607\Symfony\Component\Config * @var string|null */ private $currentDir; - public function __construct(\RectorPrefix20220607\Symfony\Component\Config\FileLocatorInterface $locator, string $env = null) + public function __construct(FileLocatorInterface $locator, string $env = null) { $this->locator = $locator; parent::__construct($env); @@ -44,7 +44,7 @@ abstract class FileLoader extends \RectorPrefix20220607\Symfony\Component\Config /** * Returns the file locator used by this loader. */ - public function getLocator() : \RectorPrefix20220607\Symfony\Component\Config\FileLocatorInterface + public function getLocator() : FileLocatorInterface { return $this->locator; } @@ -105,17 +105,17 @@ abstract class FileLoader extends \RectorPrefix20220607\Symfony\Component\Config } try { $prefix = $this->locator->locate($prefix, $this->currentDir, \true); - } catch (\RectorPrefix20220607\Symfony\Component\Config\Exception\FileLocatorFileNotFoundException $e) { + } catch (FileLocatorFileNotFoundException $e) { if (!$ignoreErrors) { throw $e; } $resource = []; foreach ($e->getPaths() as $path) { - $resource[] = new \RectorPrefix20220607\Symfony\Component\Config\Resource\FileExistenceResource($path); + $resource[] = new FileExistenceResource($path); } return; } - $resource = new \RectorPrefix20220607\Symfony\Component\Config\Resource\GlobResource($prefix, $pattern, $recursive, $forExclusion, $excluded); + $resource = new GlobResource($prefix, $pattern, $recursive, $forExclusion, $excluded); yield from $resource; } /** @@ -132,7 +132,7 @@ abstract class FileLoader extends \RectorPrefix20220607\Symfony\Component\Config for ($i = 0; $i < ($resourcesCount = \count($resources)); ++$i) { if (isset(self::$loading[$resources[$i]])) { if ($i == $resourcesCount - 1) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException(\array_keys(self::$loading)); + throw new FileLoaderImportCircularReferenceException(\array_keys(self::$loading)); } } else { $resource = $resources[$i]; @@ -146,15 +146,15 @@ abstract class FileLoader extends \RectorPrefix20220607\Symfony\Component\Config unset(self::$loading[$resource]); } return $ret; - } catch (\RectorPrefix20220607\Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException $e) { + } catch (FileLoaderImportCircularReferenceException $e) { throw $e; } catch (\Exception $e) { if (!$ignoreErrors) { // prevent embedded imports from nesting multiple exceptions - if ($e instanceof \RectorPrefix20220607\Symfony\Component\Config\Exception\LoaderLoadException) { + if ($e instanceof LoaderLoadException) { throw $e; } - throw new \RectorPrefix20220607\Symfony\Component\Config\Exception\LoaderLoadException($resource, $sourceResource, 0, $e, $type); + throw new LoaderLoadException($resource, $sourceResource, 0, $e, $type); } } return null; diff --git a/vendor/symfony/config/Loader/GlobFileLoader.php b/vendor/symfony/config/Loader/GlobFileLoader.php index 234b2a3cea2..f8259275d38 100644 --- a/vendor/symfony/config/Loader/GlobFileLoader.php +++ b/vendor/symfony/config/Loader/GlobFileLoader.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Symfony\Component\Config\Loader; * * @author Fabien Potencier */ -class GlobFileLoader extends \RectorPrefix20220607\Symfony\Component\Config\Loader\FileLoader +class GlobFileLoader extends FileLoader { /** * {@inheritdoc} diff --git a/vendor/symfony/config/Loader/Loader.php b/vendor/symfony/config/Loader/Loader.php index 6a03e03f578..e15da79637d 100644 --- a/vendor/symfony/config/Loader/Loader.php +++ b/vendor/symfony/config/Loader/Loader.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Symfony\Component\Config\Exception\LoaderLoadException; * * @author Fabien Potencier */ -abstract class Loader implements \RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderInterface +abstract class Loader implements LoaderInterface { protected $resolver; protected $env; @@ -27,14 +27,14 @@ abstract class Loader implements \RectorPrefix20220607\Symfony\Component\Config\ /** * {@inheritdoc} */ - public function getResolver() : \RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderResolverInterface + public function getResolver() : LoaderResolverInterface { return $this->resolver; } /** * {@inheritdoc} */ - public function setResolver(\RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderResolverInterface $resolver) + public function setResolver(LoaderResolverInterface $resolver) { $this->resolver = $resolver; } @@ -54,14 +54,14 @@ abstract class Loader implements \RectorPrefix20220607\Symfony\Component\Config\ * @throws LoaderLoadException If no loader is found * @param mixed $resource */ - public function resolve($resource, string $type = null) : \RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderInterface + public function resolve($resource, string $type = null) : LoaderInterface { if ($this->supports($resource, $type)) { return $this; } $loader = null === $this->resolver ? \false : $this->resolver->resolve($resource, $type); if (\false === $loader) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Exception\LoaderLoadException($resource, null, 0, null, $type); + throw new LoaderLoadException($resource, null, 0, null, $type); } return $loader; } diff --git a/vendor/symfony/config/Loader/LoaderInterface.php b/vendor/symfony/config/Loader/LoaderInterface.php index 536d4eb5cbc..33a9557686e 100644 --- a/vendor/symfony/config/Loader/LoaderInterface.php +++ b/vendor/symfony/config/Loader/LoaderInterface.php @@ -43,5 +43,5 @@ interface LoaderInterface /** * Sets the loader resolver. */ - public function setResolver(\RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderResolverInterface $resolver); + public function setResolver(LoaderResolverInterface $resolver); } diff --git a/vendor/symfony/config/Loader/LoaderResolver.php b/vendor/symfony/config/Loader/LoaderResolver.php index 36f053c0ac4..21cd4ce3e8d 100644 --- a/vendor/symfony/config/Loader/LoaderResolver.php +++ b/vendor/symfony/config/Loader/LoaderResolver.php @@ -18,7 +18,7 @@ namespace RectorPrefix20220607\Symfony\Component\Config\Loader; * * @author Fabien Potencier */ -class LoaderResolver implements \RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderResolverInterface +class LoaderResolver implements LoaderResolverInterface { /** * @var LoaderInterface[] An array of LoaderInterface objects @@ -47,7 +47,7 @@ class LoaderResolver implements \RectorPrefix20220607\Symfony\Component\Config\L } return \false; } - public function addLoader(\RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderInterface $loader) + public function addLoader(LoaderInterface $loader) { $this->loaders[] = $loader; $loader->setResolver($this); diff --git a/vendor/symfony/config/Resource/ClassExistenceResource.php b/vendor/symfony/config/Resource/ClassExistenceResource.php index 08169bf62a8..60b2bca5328 100644 --- a/vendor/symfony/config/Resource/ClassExistenceResource.php +++ b/vendor/symfony/config/Resource/ClassExistenceResource.php @@ -20,7 +20,7 @@ namespace RectorPrefix20220607\Symfony\Component\Config\Resource; * * @final */ -class ClassExistenceResource implements \RectorPrefix20220607\Symfony\Component\Config\Resource\SelfCheckingResourceInterface +class ClassExistenceResource implements SelfCheckingResourceInterface { /** * @var string diff --git a/vendor/symfony/config/Resource/ComposerResource.php b/vendor/symfony/config/Resource/ComposerResource.php index f8261ee85c7..79b0e7eb638 100644 --- a/vendor/symfony/config/Resource/ComposerResource.php +++ b/vendor/symfony/config/Resource/ComposerResource.php @@ -17,7 +17,7 @@ namespace RectorPrefix20220607\Symfony\Component\Config\Resource; * * @final */ -class ComposerResource implements \RectorPrefix20220607\Symfony\Component\Config\Resource\SelfCheckingResourceInterface +class ComposerResource implements SelfCheckingResourceInterface { /** * @var mixed[] diff --git a/vendor/symfony/config/Resource/DirectoryResource.php b/vendor/symfony/config/Resource/DirectoryResource.php index d9da8eba9c1..530aa969af8 100644 --- a/vendor/symfony/config/Resource/DirectoryResource.php +++ b/vendor/symfony/config/Resource/DirectoryResource.php @@ -17,7 +17,7 @@ namespace RectorPrefix20220607\Symfony\Component\Config\Resource; * * @final */ -class DirectoryResource implements \RectorPrefix20220607\Symfony\Component\Config\Resource\SelfCheckingResourceInterface +class DirectoryResource implements SelfCheckingResourceInterface { /** * @var string diff --git a/vendor/symfony/config/Resource/FileExistenceResource.php b/vendor/symfony/config/Resource/FileExistenceResource.php index 99d2847783f..5e92616444c 100644 --- a/vendor/symfony/config/Resource/FileExistenceResource.php +++ b/vendor/symfony/config/Resource/FileExistenceResource.php @@ -20,7 +20,7 @@ namespace RectorPrefix20220607\Symfony\Component\Config\Resource; * * @final */ -class FileExistenceResource implements \RectorPrefix20220607\Symfony\Component\Config\Resource\SelfCheckingResourceInterface +class FileExistenceResource implements SelfCheckingResourceInterface { /** * @var string diff --git a/vendor/symfony/config/Resource/FileResource.php b/vendor/symfony/config/Resource/FileResource.php index 4eeaf0c0c67..891d484f77d 100644 --- a/vendor/symfony/config/Resource/FileResource.php +++ b/vendor/symfony/config/Resource/FileResource.php @@ -19,7 +19,7 @@ namespace RectorPrefix20220607\Symfony\Component\Config\Resource; * * @final */ -class FileResource implements \RectorPrefix20220607\Symfony\Component\Config\Resource\SelfCheckingResourceInterface +class FileResource implements SelfCheckingResourceInterface { /** * @var string diff --git a/vendor/symfony/config/Resource/GlobResource.php b/vendor/symfony/config/Resource/GlobResource.php index 8ea49cdafaf..63c70ce6b58 100644 --- a/vendor/symfony/config/Resource/GlobResource.php +++ b/vendor/symfony/config/Resource/GlobResource.php @@ -23,7 +23,7 @@ use RectorPrefix20220607\Symfony\Component\Finder\Glob; * * @implements \IteratorAggregate */ -class GlobResource implements \IteratorAggregate, \RectorPrefix20220607\Symfony\Component\Config\Resource\SelfCheckingResourceInterface +class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface { /** * @var string @@ -80,7 +80,7 @@ class GlobResource implements \IteratorAggregate, \RectorPrefix20220607\Symfony\ } public function __toString() : string { - return 'glob.' . $this->prefix . (int) $this->recursive . $this->pattern . (int) $this->forExclusion . \implode("\0", $this->excludedPrefixes); + return 'glob.' . $this->prefix . (int) $this->recursive . $this->pattern . (int) $this->forExclusion . \implode("\x00", $this->excludedPrefixes); } /** * {@inheritdoc} @@ -161,7 +161,7 @@ class GlobResource implements \IteratorAggregate, \RectorPrefix20220607\Symfony\ } return; } - if (!\class_exists(\RectorPrefix20220607\Symfony\Component\Finder\Finder::class)) { + if (!\class_exists(Finder::class)) { throw new \LogicException(\sprintf('Extended glob pattern "%s" cannot be used as the Finder component is not installed.', $this->pattern)); } if (\is_file($prefix = $this->prefix)) { @@ -170,12 +170,12 @@ class GlobResource implements \IteratorAggregate, \RectorPrefix20220607\Symfony\ } else { $pattern = $this->pattern; } - $regex = \RectorPrefix20220607\Symfony\Component\Finder\Glob::toRegex($pattern); + $regex = Glob::toRegex($pattern); if ($this->recursive) { $regex = \substr_replace($regex, '(/|$)', -2, 1); } $prefixLen = \strlen($prefix); - yield from (new \RectorPrefix20220607\Symfony\Component\Finder\Finder())->followLinks()->filter(function (\SplFileInfo $info) use($regex, $prefixLen, $prefix) { + yield from (new Finder())->followLinks()->filter(function (\SplFileInfo $info) use($regex, $prefixLen, $prefix) { $normalizedPath = \str_replace('\\', '/', $info->getPathname()); if (!\preg_match($regex, \substr($normalizedPath, $prefixLen)) || !$info->isFile()) { return \false; diff --git a/vendor/symfony/config/Resource/ReflectionClassResource.php b/vendor/symfony/config/Resource/ReflectionClassResource.php index f77fa266b50..66444aed11d 100644 --- a/vendor/symfony/config/Resource/ReflectionClassResource.php +++ b/vendor/symfony/config/Resource/ReflectionClassResource.php @@ -18,7 +18,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\ServiceSubscriberInterface; * * @final */ -class ReflectionClassResource implements \RectorPrefix20220607\Symfony\Component\Config\Resource\SelfCheckingResourceInterface +class ReflectionClassResource implements SelfCheckingResourceInterface { /** * @var mixed[] @@ -179,18 +179,18 @@ class ReflectionClassResource implements \RectorPrefix20220607\Symfony\Component if ($class->isAbstract() || $class->isInterface() || $class->isTrait()) { return; } - if (\interface_exists(\RectorPrefix20220607\Symfony\Component\EventDispatcher\EventSubscriberInterface::class, \false) && $class->isSubclassOf(\RectorPrefix20220607\Symfony\Component\EventDispatcher\EventSubscriberInterface::class)) { - (yield \RectorPrefix20220607\Symfony\Component\EventDispatcher\EventSubscriberInterface::class); + if (\interface_exists(EventSubscriberInterface::class, \false) && $class->isSubclassOf(EventSubscriberInterface::class)) { + (yield EventSubscriberInterface::class); (yield \print_r($class->name::getSubscribedEvents(), \true)); } - if (\interface_exists(\RectorPrefix20220607\Symfony\Component\Messenger\Handler\MessageSubscriberInterface::class, \false) && $class->isSubclassOf(\RectorPrefix20220607\Symfony\Component\Messenger\Handler\MessageSubscriberInterface::class)) { - (yield \RectorPrefix20220607\Symfony\Component\Messenger\Handler\MessageSubscriberInterface::class); + if (\interface_exists(MessageSubscriberInterface::class, \false) && $class->isSubclassOf(MessageSubscriberInterface::class)) { + (yield MessageSubscriberInterface::class); foreach ($class->name::getHandledMessages() as $key => $value) { (yield $key . \print_r($value, \true)); } } - if (\interface_exists(\RectorPrefix20220607\Symfony\Contracts\Service\ServiceSubscriberInterface::class, \false) && $class->isSubclassOf(\RectorPrefix20220607\Symfony\Contracts\Service\ServiceSubscriberInterface::class)) { - (yield \RectorPrefix20220607\Symfony\Contracts\Service\ServiceSubscriberInterface::class); + if (\interface_exists(ServiceSubscriberInterface::class, \false) && $class->isSubclassOf(ServiceSubscriberInterface::class)) { + (yield ServiceSubscriberInterface::class); (yield \print_r($class->name::getSubscribedServices(), \true)); } } diff --git a/vendor/symfony/config/Resource/SelfCheckingResourceChecker.php b/vendor/symfony/config/Resource/SelfCheckingResourceChecker.php index 050d74dc854..1134ae5a4cc 100644 --- a/vendor/symfony/config/Resource/SelfCheckingResourceChecker.php +++ b/vendor/symfony/config/Resource/SelfCheckingResourceChecker.php @@ -19,7 +19,7 @@ use RectorPrefix20220607\Symfony\Component\Config\ResourceCheckerInterface; * * @author Matthias Pigulla */ -class SelfCheckingResourceChecker implements \RectorPrefix20220607\Symfony\Component\Config\ResourceCheckerInterface +class SelfCheckingResourceChecker implements ResourceCheckerInterface { // Common shared cache, because this checker can be used in different // situations. For example, when using the full stack framework, the router @@ -29,14 +29,14 @@ class SelfCheckingResourceChecker implements \RectorPrefix20220607\Symfony\Compo * @var mixed[] */ private static $cache = []; - public function supports(\RectorPrefix20220607\Symfony\Component\Config\Resource\ResourceInterface $metadata) : bool + public function supports(ResourceInterface $metadata) : bool { - return $metadata instanceof \RectorPrefix20220607\Symfony\Component\Config\Resource\SelfCheckingResourceInterface; + return $metadata instanceof SelfCheckingResourceInterface; } /** * @param SelfCheckingResourceInterface $resource */ - public function isFresh(\RectorPrefix20220607\Symfony\Component\Config\Resource\ResourceInterface $resource, int $timestamp) : bool + public function isFresh(ResourceInterface $resource, int $timestamp) : bool { $key = "{$resource}:{$timestamp}"; return self::$cache[$key] ?? (self::$cache[$key] = $resource->isFresh($timestamp)); diff --git a/vendor/symfony/config/Resource/SelfCheckingResourceInterface.php b/vendor/symfony/config/Resource/SelfCheckingResourceInterface.php index 33eed117186..72c3a3d54a2 100644 --- a/vendor/symfony/config/Resource/SelfCheckingResourceInterface.php +++ b/vendor/symfony/config/Resource/SelfCheckingResourceInterface.php @@ -16,7 +16,7 @@ namespace RectorPrefix20220607\Symfony\Component\Config\Resource; * * @author Matthias Pigulla */ -interface SelfCheckingResourceInterface extends \RectorPrefix20220607\Symfony\Component\Config\Resource\ResourceInterface +interface SelfCheckingResourceInterface extends ResourceInterface { /** * Returns true if the resource has not been updated since the given timestamp. diff --git a/vendor/symfony/config/ResourceCheckerConfigCache.php b/vendor/symfony/config/ResourceCheckerConfigCache.php index 35751d00901..5e8887b5d2a 100644 --- a/vendor/symfony/config/ResourceCheckerConfigCache.php +++ b/vendor/symfony/config/ResourceCheckerConfigCache.php @@ -19,7 +19,7 @@ use RectorPrefix20220607\Symfony\Component\Filesystem\Filesystem; * * @author Matthias Pigulla */ -class ResourceCheckerConfigCache implements \RectorPrefix20220607\Symfony\Component\Config\ConfigCacheInterface +class ResourceCheckerConfigCache implements ConfigCacheInterface { /** * @var string @@ -104,18 +104,18 @@ class ResourceCheckerConfigCache implements \RectorPrefix20220607\Symfony\Compon { $mode = 0666; $umask = \umask(); - $filesystem = new \RectorPrefix20220607\Symfony\Component\Filesystem\Filesystem(); + $filesystem = new Filesystem(); $filesystem->dumpFile($this->file, $content); try { $filesystem->chmod($this->file, $mode, $umask); - } catch (\RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException $exception) { + } catch (IOException $exception) { // discard chmod failure (some filesystem may not support it) } if (null !== $metadata) { $filesystem->dumpFile($this->getMetaFile(), \serialize($metadata)); try { $filesystem->chmod($this->getMetaFile(), $mode, $umask); - } catch (\RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException $exception) { + } catch (IOException $exception) { // discard chmod failure (some filesystem may not support it) } } diff --git a/vendor/symfony/config/ResourceCheckerConfigCacheFactory.php b/vendor/symfony/config/ResourceCheckerConfigCacheFactory.php index 630db31c741..dd2fd7bf9fb 100644 --- a/vendor/symfony/config/ResourceCheckerConfigCacheFactory.php +++ b/vendor/symfony/config/ResourceCheckerConfigCacheFactory.php @@ -16,7 +16,7 @@ namespace RectorPrefix20220607\Symfony\Component\Config; * * @author Matthias Pigulla */ -class ResourceCheckerConfigCacheFactory implements \RectorPrefix20220607\Symfony\Component\Config\ConfigCacheFactoryInterface +class ResourceCheckerConfigCacheFactory implements ConfigCacheFactoryInterface { /** * @var mixed[] @@ -32,9 +32,9 @@ class ResourceCheckerConfigCacheFactory implements \RectorPrefix20220607\Symfony /** * {@inheritdoc} */ - public function cache(string $file, callable $callable) : \RectorPrefix20220607\Symfony\Component\Config\ConfigCacheInterface + public function cache(string $file, callable $callable) : ConfigCacheInterface { - $cache = new \RectorPrefix20220607\Symfony\Component\Config\ResourceCheckerConfigCache($file, $this->resourceCheckers); + $cache = new ResourceCheckerConfigCache($file, $this->resourceCheckers); if (!$cache->isFresh()) { $callable($cache); } diff --git a/vendor/symfony/config/ResourceCheckerInterface.php b/vendor/symfony/config/ResourceCheckerInterface.php index 91cb6fc93ef..a92a2cf657f 100644 --- a/vendor/symfony/config/ResourceCheckerInterface.php +++ b/vendor/symfony/config/ResourceCheckerInterface.php @@ -30,7 +30,7 @@ interface ResourceCheckerInterface * * @return bool */ - public function supports(\RectorPrefix20220607\Symfony\Component\Config\Resource\ResourceInterface $metadata); + public function supports(ResourceInterface $metadata); /** * Validates the resource. * @@ -38,5 +38,5 @@ interface ResourceCheckerInterface * * @return bool */ - public function isFresh(\RectorPrefix20220607\Symfony\Component\Config\Resource\ResourceInterface $resource, int $timestamp); + public function isFresh(ResourceInterface $resource, int $timestamp); } diff --git a/vendor/symfony/config/Util/Exception/InvalidXmlException.php b/vendor/symfony/config/Util/Exception/InvalidXmlException.php index 776b926ca1f..a5cc5f010d4 100644 --- a/vendor/symfony/config/Util/Exception/InvalidXmlException.php +++ b/vendor/symfony/config/Util/Exception/InvalidXmlException.php @@ -16,6 +16,6 @@ namespace RectorPrefix20220607\Symfony\Component\Config\Util\Exception; * * @author Ole Rößner */ -class InvalidXmlException extends \RectorPrefix20220607\Symfony\Component\Config\Util\Exception\XmlParsingException +class InvalidXmlException extends XmlParsingException { } diff --git a/vendor/symfony/config/Util/XmlUtils.php b/vendor/symfony/config/Util/XmlUtils.php index 434a8f206fd..e925dcbf185 100644 --- a/vendor/symfony/config/Util/XmlUtils.php +++ b/vendor/symfony/config/Util/XmlUtils.php @@ -49,13 +49,13 @@ class XmlUtils $dom = new \DOMDocument(); $dom->validateOnParse = \true; if (!$dom->loadXML($content, \LIBXML_NONET | \LIBXML_COMPACT)) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Util\Exception\XmlParsingException(\implode("\n", static::getXmlErrors($internalErrors))); + throw new XmlParsingException(\implode("\n", static::getXmlErrors($internalErrors))); } $dom->normalizeDocument(); \libxml_use_internal_errors($internalErrors); foreach ($dom->childNodes as $child) { if (\XML_DOCUMENT_TYPE_NODE === $child->nodeType) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Util\Exception\XmlParsingException('Document types are not allowed.'); + throw new XmlParsingException('Document types are not allowed.'); } } if (null !== $schemaOrCallable) { @@ -73,14 +73,14 @@ class XmlUtils $valid = @$dom->schemaValidateSource($schemaSource); } else { \libxml_use_internal_errors($internalErrors); - throw new \RectorPrefix20220607\Symfony\Component\Config\Util\Exception\XmlParsingException(\sprintf('Invalid XSD file: "%s".', $schemaOrCallable)); + throw new XmlParsingException(\sprintf('Invalid XSD file: "%s".', $schemaOrCallable)); } if (!$valid) { $messages = static::getXmlErrors($internalErrors); if (empty($messages)) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Util\Exception\InvalidXmlException('The XML is not valid.', 0, $e); + throw new InvalidXmlException('The XML is not valid.', 0, $e); } - throw new \RectorPrefix20220607\Symfony\Component\Config\Util\Exception\XmlParsingException(\implode("\n", $messages), 0, $e); + throw new XmlParsingException(\implode("\n", $messages), 0, $e); } } \libxml_clear_errors(); @@ -111,8 +111,8 @@ class XmlUtils } try { return static::parse($content, $schemaOrCallable); - } catch (\RectorPrefix20220607\Symfony\Component\Config\Util\Exception\InvalidXmlException $e) { - throw new \RectorPrefix20220607\Symfony\Component\Config\Util\Exception\XmlParsingException(\sprintf('The XML file "%s" is not valid.', $file), 0, $e->getPrevious()); + } catch (InvalidXmlException $e) { + throw new XmlParsingException(\sprintf('The XML file "%s" is not valid.', $file), 0, $e->getPrevious()); } } /** diff --git a/vendor/symfony/console/Application.php b/vendor/symfony/console/Application.php index dd2ab15431f..c2579498ea5 100644 --- a/vendor/symfony/console/Application.php +++ b/vendor/symfony/console/Application.php @@ -66,7 +66,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\ResetInterface; * * @author Fabien Potencier */ -class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\ResetInterface +class Application implements ResetInterface { /** * @var mixed[] @@ -140,28 +140,28 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res { $this->name = $name; $this->version = $version; - $this->terminal = new \RectorPrefix20220607\Symfony\Component\Console\Terminal(); + $this->terminal = new Terminal(); $this->defaultCommand = 'list'; - if (\defined('SIGINT') && \RectorPrefix20220607\Symfony\Component\Console\SignalRegistry\SignalRegistry::isSupported()) { - $this->signalRegistry = new \RectorPrefix20220607\Symfony\Component\Console\SignalRegistry\SignalRegistry(); + if (\defined('SIGINT') && SignalRegistry::isSupported()) { + $this->signalRegistry = new SignalRegistry(); $this->signalsToDispatchEvent = [\SIGINT, \SIGTERM, \SIGUSR1, \SIGUSR2]; } } /** * @final */ - public function setDispatcher(\RectorPrefix20220607\Symfony\Contracts\EventDispatcher\EventDispatcherInterface $dispatcher) + public function setDispatcher(EventDispatcherInterface $dispatcher) { $this->dispatcher = $dispatcher; } - public function setCommandLoader(\RectorPrefix20220607\Symfony\Component\Console\CommandLoader\CommandLoaderInterface $commandLoader) + public function setCommandLoader(CommandLoaderInterface $commandLoader) { $this->commandLoader = $commandLoader; } - public function getSignalRegistry() : \RectorPrefix20220607\Symfony\Component\Console\SignalRegistry\SignalRegistry + public function getSignalRegistry() : SignalRegistry { if (!$this->signalRegistry) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\RuntimeException('Signals are not supported. Make sure that the `pcntl` extension is installed and that "pcntl_*" functions are not disabled by your php.ini\'s "disable_functions" directive.'); + throw new RuntimeException('Signals are not supported. Make sure that the `pcntl` extension is installed and that "pcntl_*" functions are not disabled by your php.ini\'s "disable_functions" directive.'); } return $this->signalRegistry; } @@ -176,20 +176,20 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res * * @throws \Exception When running fails. Bypass this when {@link setCatchExceptions()}. */ - public function run(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input = null, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output = null) : int + public function run(InputInterface $input = null, OutputInterface $output = null) : int { if (\function_exists('putenv')) { @\putenv('LINES=' . $this->terminal->getHeight()); @\putenv('COLUMNS=' . $this->terminal->getWidth()); } if (null === $input) { - $input = new \RectorPrefix20220607\Symfony\Component\Console\Input\ArgvInput(); + $input = new ArgvInput(); } if (null === $output) { - $output = new \RectorPrefix20220607\Symfony\Component\Console\Output\ConsoleOutput(); + $output = new ConsoleOutput(); } $renderException = function (\Throwable $e) use($output) { - if ($output instanceof \RectorPrefix20220607\Symfony\Component\Console\Output\ConsoleOutputInterface) { + if ($output instanceof ConsoleOutputInterface) { $this->renderThrowable($e, $output->getErrorOutput()); } else { $this->renderThrowable($e, $output); @@ -197,7 +197,7 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res }; if ($phpHandler = \set_exception_handler($renderException)) { \restore_exception_handler(); - if (!\is_array($phpHandler) || !$phpHandler[0] instanceof \RectorPrefix20220607\Symfony\Component\ErrorHandler\ErrorHandler) { + if (!\is_array($phpHandler) || !$phpHandler[0] instanceof ErrorHandler) { $errorHandler = \true; } elseif ($errorHandler = $phpHandler[0]->setExceptionHandler($renderException)) { $phpHandler[0]->setExceptionHandler($errorHandler); @@ -248,7 +248,7 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res * * @return int 0 if everything went fine, or an error code */ - public function doRun(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) + public function doRun(InputInterface $input, OutputInterface $output) { if (\true === $input->hasParameterOption(['--version', '-V'], \true)) { $output->writeln($this->getLongVersion()); @@ -257,14 +257,14 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res try { // Makes ArgvInput::getFirstArgument() able to distinguish an option from an argument. $input->bind($this->getDefinition()); - } catch (\RectorPrefix20220607\Symfony\Component\Console\Exception\ExceptionInterface $exception) { + } catch (ExceptionInterface $exception) { // Errors must be ignored, full binding/validation happens later when the command is known. } $name = $this->getCommandName($input); if (\true === $input->hasParameterOption(['--help', '-h'], \true)) { if (!$name) { $name = 'help'; - $input = new \RectorPrefix20220607\Symfony\Component\Console\Input\ArrayInput(['command_name' => $this->defaultCommand]); + $input = new ArrayInput(['command_name' => $this->defaultCommand]); } else { $this->wantHelps = \true; } @@ -272,17 +272,17 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res if (!$name) { $name = $this->defaultCommand; $definition = $this->getDefinition(); - $definition->setArguments(\array_merge($definition->getArguments(), ['command' => new \RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument('command', \RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name)])); + $definition->setArguments(\array_merge($definition->getArguments(), ['command' => new InputArgument('command', InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name)])); } try { $this->runningCommand = null; // the command name MUST be the first element of the input $command = $this->find($name); } catch (\Throwable $e) { - if (!($e instanceof \RectorPrefix20220607\Symfony\Component\Console\Exception\CommandNotFoundException && !$e instanceof \RectorPrefix20220607\Symfony\Component\Console\Exception\NamespaceNotFoundException) || 1 !== \count($alternatives = $e->getAlternatives()) || !$input->isInteractive()) { + if (!($e instanceof CommandNotFoundException && !$e instanceof NamespaceNotFoundException) || 1 !== \count($alternatives = $e->getAlternatives()) || !$input->isInteractive()) { if (null !== $this->dispatcher) { - $event = new \RectorPrefix20220607\Symfony\Component\Console\Event\ConsoleErrorEvent($input, $output, $e); - $this->dispatcher->dispatch($event, \RectorPrefix20220607\Symfony\Component\Console\ConsoleEvents::ERROR); + $event = new ConsoleErrorEvent($input, $output, $e); + $this->dispatcher->dispatch($event, ConsoleEvents::ERROR); if (0 === $event->getExitCode()) { return 0; } @@ -291,19 +291,19 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res throw $e; } $alternative = $alternatives[0]; - $style = new \RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle($input, $output); + $style = new SymfonyStyle($input, $output); $style->block(\sprintf("\nCommand \"%s\" is not defined.\n", $name), null, 'error'); if (!$style->confirm(\sprintf('Do you want to run "%s" instead? ', $alternative), \false)) { if (null !== $this->dispatcher) { - $event = new \RectorPrefix20220607\Symfony\Component\Console\Event\ConsoleErrorEvent($input, $output, $e); - $this->dispatcher->dispatch($event, \RectorPrefix20220607\Symfony\Component\Console\ConsoleEvents::ERROR); + $event = new ConsoleErrorEvent($input, $output, $e); + $this->dispatcher->dispatch($event, ConsoleEvents::ERROR); return $event->getExitCode(); } return 1; } $command = $this->find($alternative); } - if ($command instanceof \RectorPrefix20220607\Symfony\Component\Console\Command\LazyCommand) { + if ($command instanceof LazyCommand) { $command = $command->getCommand(); } $this->runningCommand = $command; @@ -317,25 +317,25 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res public function reset() { } - public function setHelperSet(\RectorPrefix20220607\Symfony\Component\Console\Helper\HelperSet $helperSet) + public function setHelperSet(HelperSet $helperSet) { $this->helperSet = $helperSet; } /** * Get the helper set associated with the command. */ - public function getHelperSet() : \RectorPrefix20220607\Symfony\Component\Console\Helper\HelperSet + public function getHelperSet() : HelperSet { return $this->helperSet = $this->helperSet ?? $this->getDefaultHelperSet(); } - public function setDefinition(\RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition $definition) + public function setDefinition(InputDefinition $definition) { $this->definition = $definition; } /** * Gets the InputDefinition related to this Application. */ - public function getDefinition() : \RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition + public function getDefinition() : InputDefinition { $this->definition = $this->definition ?? $this->getDefaultInputDefinition(); if ($this->singleCommand) { @@ -348,9 +348,9 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res /** * Adds suggestions to $suggestions for the current completion input (e.g. option or argument). */ - public function complete(\RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionInput $input, \RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionSuggestions $suggestions) : void + public function complete(CompletionInput $input, CompletionSuggestions $suggestions) : void { - if (\RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionInput::TYPE_ARGUMENT_VALUE === $input->getCompletionType() && 'command' === $input->getCompletionName()) { + if (CompletionInput::TYPE_ARGUMENT_VALUE === $input->getCompletionType() && 'command' === $input->getCompletionName()) { $commandNames = []; foreach ($this->all() as $name => $command) { // skip hidden commands and aliased commands as they already get added below @@ -365,7 +365,7 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res $suggestions->suggestValues(\array_filter($commandNames)); return; } - if (\RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionInput::TYPE_OPTION_NAME === $input->getCompletionType()) { + if (CompletionInput::TYPE_OPTION_NAME === $input->getCompletionType()) { $suggestions->suggestOptions($this->getDefinition()->getOptions()); return; } @@ -451,9 +451,9 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res /** * Registers a new command. */ - public function register(string $name) : \RectorPrefix20220607\Symfony\Component\Console\Command\Command + public function register(string $name) : Command { - return $this->add(new \RectorPrefix20220607\Symfony\Component\Console\Command\Command($name)); + return $this->add(new Command($name)); } /** * Adds an array of command objects. @@ -476,7 +476,7 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res * * @return Command|null */ - public function add(\RectorPrefix20220607\Symfony\Component\Console\Command\Command $command) + public function add(Command $command) { $this->init(); $command->setApplication($this); @@ -484,12 +484,12 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res $command->setApplication(null); return null; } - if (!$command instanceof \RectorPrefix20220607\Symfony\Component\Console\Command\LazyCommand) { + if (!$command instanceof LazyCommand) { // Will throw if the command is not correctly initialized. $command->getDefinition(); } if (!$command->getName()) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException(\sprintf('The command defined in "%s" cannot have an empty name.', \get_debug_type($command))); + throw new LogicException(\sprintf('The command defined in "%s" cannot have an empty name.', \get_debug_type($command))); } $this->commands[$command->getName()] = $command; foreach ($command->getAliases() as $alias) { @@ -508,11 +508,11 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res { $this->init(); if (!$this->has($name)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\CommandNotFoundException(\sprintf('The command "%s" does not exist.', $name)); + throw new CommandNotFoundException(\sprintf('The command "%s" does not exist.', $name)); } // When the command has a different name than the one used at the command loader level if (!isset($this->commands[$name])) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\CommandNotFoundException(\sprintf('The "%s" command cannot be found because it is registered under multiple names. Make sure you don\'t set a different name via constructor or "setName()".', $name)); + throw new CommandNotFoundException(\sprintf('The "%s" command cannot be found because it is registered under multiple names. Make sure you don\'t set a different name via constructor or "setName()".', $name)); } $command = $this->commands[$name]; if ($this->wantHelps) { @@ -572,11 +572,11 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res } $message .= \implode("\n ", $alternatives); } - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\NamespaceNotFoundException($message, $alternatives); + throw new NamespaceNotFoundException($message, $alternatives); } $exact = \in_array($namespace, $namespaces, \true); if (\count($namespaces) > 1 && !$exact) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\NamespaceNotFoundException(\sprintf("The namespace \"%s\" is ambiguous.\nDid you mean one of these?\n%s.", $namespace, $this->getAbbreviationSuggestions(\array_values($namespaces))), \array_values($namespaces)); + throw new NamespaceNotFoundException(\sprintf("The namespace \"%s\" is ambiguous.\nDid you mean one of these?\n%s.", $namespace, $this->getAbbreviationSuggestions(\array_values($namespaces))), \array_values($namespaces)); } return $exact ? $namespace : \reset($namespaces); } @@ -629,13 +629,13 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res } $message .= \implode("\n ", $alternatives); } - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\CommandNotFoundException($message, \array_values($alternatives)); + throw new CommandNotFoundException($message, \array_values($alternatives)); } // filter out aliases for commands which are already on the list if (\count($commands) > 1) { $commandList = $this->commandLoader ? \array_merge(\array_flip($this->commandLoader->getNames()), $this->commands) : $this->commands; $commands = \array_unique(\array_filter($commands, function ($nameOrAlias) use(&$commandList, $commands, &$aliases) { - if (!$commandList[$nameOrAlias] instanceof \RectorPrefix20220607\Symfony\Component\Console\Command\Command) { + if (!$commandList[$nameOrAlias] instanceof Command) { $commandList[$nameOrAlias] = $this->commandLoader->get($nameOrAlias); } $commandName = $commandList[$nameOrAlias]->getName(); @@ -648,7 +648,7 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res $abbrevs = \array_values($commands); $maxLen = 0; foreach ($abbrevs as $abbrev) { - $maxLen = \max(\RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($abbrev), $maxLen); + $maxLen = \max(Helper::width($abbrev), $maxLen); } $abbrevs = \array_map(function ($cmd) use($commandList, $usableWidth, $maxLen, &$commands) { if ($commandList[$cmd]->isHidden()) { @@ -656,16 +656,16 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res return \false; } $abbrev = \str_pad($cmd, $maxLen, ' ') . ' ' . $commandList[$cmd]->getDescription(); - return \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($abbrev) > $usableWidth ? \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::substr($abbrev, 0, $usableWidth - 3) . '...' : $abbrev; + return Helper::width($abbrev) > $usableWidth ? Helper::substr($abbrev, 0, $usableWidth - 3) . '...' : $abbrev; }, \array_values($commands)); if (\count($commands) > 1) { $suggestions = $this->getAbbreviationSuggestions(\array_filter($abbrevs)); - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\CommandNotFoundException(\sprintf("Command \"%s\" is ambiguous.\nDid you mean one of these?\n%s.", $name, $suggestions), \array_values($commands)); + throw new CommandNotFoundException(\sprintf("Command \"%s\" is ambiguous.\nDid you mean one of these?\n%s.", $name, $suggestions), \array_values($commands)); } } $command = $this->get(\reset($commands)); if ($command->isHidden()) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\CommandNotFoundException(\sprintf('The command "%s" does not exist.', $name)); + throw new CommandNotFoundException(\sprintf('The command "%s" does not exist.', $name)); } return $command; } @@ -722,27 +722,27 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res } return $abbrevs; } - public function renderThrowable(\Throwable $e, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : void + public function renderThrowable(\Throwable $e, OutputInterface $output) : void { - $output->writeln('', \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_QUIET); + $output->writeln('', OutputInterface::VERBOSITY_QUIET); $this->doRenderThrowable($e, $output); if (null !== $this->runningCommand) { - $output->writeln(\sprintf('%s', \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatter::escape(\sprintf($this->runningCommand->getSynopsis(), $this->getName()))), \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_QUIET); - $output->writeln('', \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_QUIET); + $output->writeln(\sprintf('%s', OutputFormatter::escape(\sprintf($this->runningCommand->getSynopsis(), $this->getName()))), OutputInterface::VERBOSITY_QUIET); + $output->writeln('', OutputInterface::VERBOSITY_QUIET); } } - protected function doRenderThrowable(\Throwable $e, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : void + protected function doRenderThrowable(\Throwable $e, OutputInterface $output) : void { do { $message = \trim($e->getMessage()); - if ('' === $message || \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { + if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { $class = \get_debug_type($e); $title = \sprintf(' [%s%s] ', $class, 0 !== ($code = $e->getCode()) ? ' (' . $code . ')' : ''); - $len = \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($title); + $len = Helper::width($title); } else { $len = 0; } - if (\strpos($message, "@anonymous\0") !== \false) { + if (\strpos($message, "@anonymous\x00") !== \false) { $message = \preg_replace_callback('/[a-zA-Z_\\x7f-\\xff][\\\\a-zA-Z0-9_\\x7f-\\xff]*+@anonymous\\x00.*?\\.php(?:0x?|:[0-9]++\\$)[0-9a-fA-F]++/', function ($m) { return \class_exists($m[0], \false) ? ((\get_parent_class($m[0]) ?: \key(\class_implements($m[0]))) ?: 'class') . '@anonymous' : $m[0]; }, $message); @@ -752,27 +752,27 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res foreach ('' !== $message ? \preg_split('/\\r?\\n/', $message) : [] as $line) { foreach ($this->splitStringByWidth($line, $width - 4) as $line) { // pre-format lines to get the right string length - $lineLength = \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($line) + 4; + $lineLength = Helper::width($line) + 4; $lines[] = [$line, $lineLength]; $len = \max($lineLength, $len); } } $messages = []; - if (!$e instanceof \RectorPrefix20220607\Symfony\Component\Console\Exception\ExceptionInterface || \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { - $messages[] = \sprintf('%s', \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatter::escape(\sprintf('In %s line %s:', \basename($e->getFile()) ?: 'n/a', $e->getLine() ?: 'n/a'))); + if (!$e instanceof ExceptionInterface || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { + $messages[] = \sprintf('%s', OutputFormatter::escape(\sprintf('In %s line %s:', \basename($e->getFile()) ?: 'n/a', $e->getLine() ?: 'n/a'))); } $messages[] = $emptyLine = \sprintf('%s', \str_repeat(' ', $len)); - if ('' === $message || \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { - $messages[] = \sprintf('%s%s', $title, \str_repeat(' ', \max(0, $len - \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($title)))); + if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { + $messages[] = \sprintf('%s%s', $title, \str_repeat(' ', \max(0, $len - Helper::width($title)))); } foreach ($lines as $line) { - $messages[] = \sprintf(' %s %s', \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatter::escape($line[0]), \str_repeat(' ', $len - $line[1])); + $messages[] = \sprintf(' %s %s', OutputFormatter::escape($line[0]), \str_repeat(' ', $len - $line[1])); } $messages[] = $emptyLine; $messages[] = ''; - $output->writeln($messages, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_QUIET); - if (\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { - $output->writeln('Exception trace:', \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_QUIET); + $output->writeln($messages, OutputInterface::VERBOSITY_QUIET); + if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { + $output->writeln('Exception trace:', OutputInterface::VERBOSITY_QUIET); // exception related properties $trace = $e->getTrace(); \array_unshift($trace, ['function' => '', 'file' => $e->getFile() ?: 'n/a', 'line' => $e->getLine() ?: 'n/a', 'args' => []]); @@ -782,16 +782,16 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res $function = $trace[$i]['function'] ?? ''; $file = $trace[$i]['file'] ?? 'n/a'; $line = $trace[$i]['line'] ?? 'n/a'; - $output->writeln(\sprintf(' %s%s at %s:%s', $class, $function ? $type . $function . '()' : '', $file, $line), \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_QUIET); + $output->writeln(\sprintf(' %s%s at %s:%s', $class, $function ? $type . $function . '()' : '', $file, $line), OutputInterface::VERBOSITY_QUIET); } - $output->writeln('', \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_QUIET); + $output->writeln('', OutputInterface::VERBOSITY_QUIET); } } while ($e = $e->getPrevious()); } /** * Configures the input and output instances based on the user arguments and options. */ - protected function configureIO(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) + protected function configureIO(InputInterface $input, OutputInterface $output) { if (\true === $input->hasParameterOption(['--ansi'], \true)) { $output->setDecorated(\true); @@ -803,33 +803,33 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res } switch ($shellVerbosity = (int) \getenv('SHELL_VERBOSITY')) { case -1: - $output->setVerbosity(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_QUIET); + $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); break; case 1: - $output->setVerbosity(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_VERBOSE); + $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); break; case 2: - $output->setVerbosity(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_VERY_VERBOSE); + $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); break; case 3: - $output->setVerbosity(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_DEBUG); + $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); break; default: $shellVerbosity = 0; break; } if (\true === $input->hasParameterOption(['--quiet', '-q'], \true)) { - $output->setVerbosity(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_QUIET); + $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); $shellVerbosity = -1; } else { if ($input->hasParameterOption('-vvv', \true) || $input->hasParameterOption('--verbose=3', \true) || 3 === $input->getParameterOption('--verbose', \false, \true)) { - $output->setVerbosity(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_DEBUG); + $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); $shellVerbosity = 3; } elseif ($input->hasParameterOption('-vv', \true) || $input->hasParameterOption('--verbose=2', \true) || 2 === $input->getParameterOption('--verbose', \false, \true)) { - $output->setVerbosity(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_VERY_VERBOSE); + $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); $shellVerbosity = 2; } elseif ($input->hasParameterOption('-v', \true) || $input->hasParameterOption('--verbose=1', \true) || $input->hasParameterOption('--verbose', \true) || $input->getParameterOption('--verbose', \false, \true)) { - $output->setVerbosity(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_VERBOSE); + $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); $shellVerbosity = 1; } } @@ -850,18 +850,18 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res * * @return int 0 if everything went fine, or an error code */ - protected function doRunCommand(\RectorPrefix20220607\Symfony\Component\Console\Command\Command $command, \RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) + protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { foreach ($command->getHelperSet() as $helper) { - if ($helper instanceof \RectorPrefix20220607\Symfony\Component\Console\Input\InputAwareInterface) { + if ($helper instanceof InputAwareInterface) { $helper->setInput($input); } } - if ($command instanceof \RectorPrefix20220607\Symfony\Component\Console\Command\SignalableCommandInterface && ($this->signalsToDispatchEvent || $command->getSubscribedSignals())) { + if ($command instanceof SignalableCommandInterface && ($this->signalsToDispatchEvent || $command->getSubscribedSignals())) { if (!$this->signalRegistry) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\RuntimeException('Unable to subscribe to signal events. Make sure that the `pcntl` extension is installed and that "pcntl_*" functions are not disabled by your php.ini\'s "disable_functions" directive.'); + throw new RuntimeException('Unable to subscribe to signal events. Make sure that the `pcntl` extension is installed and that "pcntl_*" functions are not disabled by your php.ini\'s "disable_functions" directive.'); } - if (\RectorPrefix20220607\Symfony\Component\Console\Terminal::hasSttyAvailable()) { + if (Terminal::hasSttyAvailable()) { $sttyMode = \shell_exec('stty -g'); foreach ([\SIGINT, \SIGTERM] as $signal) { $this->signalRegistry->register($signal, static function () use($sttyMode) { @@ -871,9 +871,9 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res } if ($this->dispatcher) { foreach ($this->signalsToDispatchEvent as $signal) { - $event = new \RectorPrefix20220607\Symfony\Component\Console\Event\ConsoleSignalEvent($command, $input, $output, $signal); + $event = new ConsoleSignalEvent($command, $input, $output, $signal); $this->signalRegistry->register($signal, function ($signal, $hasNext) use($event) { - $this->dispatcher->dispatch($event, \RectorPrefix20220607\Symfony\Component\Console\ConsoleEvents::SIGNAL); + $this->dispatcher->dispatch($event, ConsoleEvents::SIGNAL); // No more handlers, we try to simulate PHP default behavior if (!$hasNext) { if (!\in_array($signal, [\SIGUSR1, \SIGUSR2], \true)) { @@ -894,28 +894,28 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res try { $command->mergeApplicationDefinition(); $input->bind($command->getDefinition()); - } catch (\RectorPrefix20220607\Symfony\Component\Console\Exception\ExceptionInterface $exception) { + } catch (ExceptionInterface $exception) { // ignore invalid options/arguments for now, to allow the event listeners to customize the InputDefinition } - $event = new \RectorPrefix20220607\Symfony\Component\Console\Event\ConsoleCommandEvent($command, $input, $output); + $event = new ConsoleCommandEvent($command, $input, $output); $e = null; try { - $this->dispatcher->dispatch($event, \RectorPrefix20220607\Symfony\Component\Console\ConsoleEvents::COMMAND); + $this->dispatcher->dispatch($event, ConsoleEvents::COMMAND); if ($event->commandShouldRun()) { $exitCode = $command->run($input, $output); } else { - $exitCode = \RectorPrefix20220607\Symfony\Component\Console\Event\ConsoleCommandEvent::RETURN_CODE_DISABLED; + $exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED; } } catch (\Throwable $e) { - $event = new \RectorPrefix20220607\Symfony\Component\Console\Event\ConsoleErrorEvent($input, $output, $e, $command); - $this->dispatcher->dispatch($event, \RectorPrefix20220607\Symfony\Component\Console\ConsoleEvents::ERROR); + $event = new ConsoleErrorEvent($input, $output, $e, $command); + $this->dispatcher->dispatch($event, ConsoleEvents::ERROR); $e = $event->getError(); if (0 === ($exitCode = $event->getExitCode())) { $e = null; } } - $event = new \RectorPrefix20220607\Symfony\Component\Console\Event\ConsoleTerminateEvent($command, $input, $output, $exitCode); - $this->dispatcher->dispatch($event, \RectorPrefix20220607\Symfony\Component\Console\ConsoleEvents::TERMINATE); + $event = new ConsoleTerminateEvent($command, $input, $output, $exitCode); + $this->dispatcher->dispatch($event, ConsoleEvents::TERMINATE); if (null !== $e) { throw $e; } @@ -924,16 +924,16 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res /** * Gets the name of the command based on input. */ - protected function getCommandName(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input) : ?string + protected function getCommandName(InputInterface $input) : ?string { return $this->singleCommand ? $this->defaultCommand : $input->getFirstArgument(); } /** * Gets the default input definition. */ - protected function getDefaultInputDefinition() : \RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition + protected function getDefaultInputDefinition() : InputDefinition { - return new \RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition([new \RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument('command', \RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument::REQUIRED, 'The command to execute'), new \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption('--help', '-h', \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Display help for the given command. When no command is given display help for the ' . $this->defaultCommand . ' command'), new \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption('--quiet', '-q', \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Do not output any message'), new \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption('--verbose', '-v|vv|vvv', \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'), new \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption('--version', '-V', \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Display this application version'), new \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption('--ansi', '', \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_NEGATABLE, 'Force (or disable --no-ansi) ANSI output', null), new \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption('--no-interaction', '-n', \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Do not ask any interactive question')]); + return new InputDefinition([new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'), new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display help for the given command. When no command is given display help for the ' . $this->defaultCommand . ' command'), new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'), new InputOption('--verbose', '-v|vv|vvv', InputOption::VALUE_NONE, 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'), new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'), new InputOption('--ansi', '', InputOption::VALUE_NEGATABLE, 'Force (or disable --no-ansi) ANSI output', null), new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question')]); } /** * Gets the default commands that should always be available. @@ -942,14 +942,14 @@ class Application implements \RectorPrefix20220607\Symfony\Contracts\Service\Res */ protected function getDefaultCommands() : array { - return [new \RectorPrefix20220607\Symfony\Component\Console\Command\HelpCommand(), new \RectorPrefix20220607\Symfony\Component\Console\Command\ListCommand(), new \RectorPrefix20220607\Symfony\Component\Console\Command\CompleteCommand(), new \RectorPrefix20220607\Symfony\Component\Console\Command\DumpCompletionCommand()]; + return [new HelpCommand(), new ListCommand(), new CompleteCommand(), new DumpCompletionCommand()]; } /** * Gets the default helper set with the helpers that should always be available. */ - protected function getDefaultHelperSet() : \RectorPrefix20220607\Symfony\Component\Console\Helper\HelperSet + protected function getDefaultHelperSet() : HelperSet { - return new \RectorPrefix20220607\Symfony\Component\Console\Helper\HelperSet([new \RectorPrefix20220607\Symfony\Component\Console\Helper\FormatterHelper(), new \RectorPrefix20220607\Symfony\Component\Console\Helper\DebugFormatterHelper(), new \RectorPrefix20220607\Symfony\Component\Console\Helper\ProcessHelper(), new \RectorPrefix20220607\Symfony\Component\Console\Helper\QuestionHelper()]); + return new HelperSet([new FormatterHelper(), new DebugFormatterHelper(), new ProcessHelper(), new QuestionHelper()]); } /** * Returns abbreviated suggestions in string format. diff --git a/vendor/symfony/console/CI/GithubActionReporter.php b/vendor/symfony/console/CI/GithubActionReporter.php index 3c76c50f284..7716aad2045 100644 --- a/vendor/symfony/console/CI/GithubActionReporter.php +++ b/vendor/symfony/console/CI/GithubActionReporter.php @@ -30,7 +30,7 @@ class GithubActionReporter * @see https://github.com/actions/toolkit/blob/5e5e1b7aacba68a53836a34db4a288c3c1c1585b/packages/core/src/command.ts#L87-L94 */ private const ESCAPED_PROPERTIES = ['%' => '%25', "\r" => '%0D', "\n" => '%0A', ':' => '%3A', ',' => '%2C']; - public function __construct(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) + public function __construct(OutputInterface $output) { $this->output = $output; } diff --git a/vendor/symfony/console/Color.php b/vendor/symfony/console/Color.php index c3e47a9117d..321df2c425b 100644 --- a/vendor/symfony/console/Color.php +++ b/vendor/symfony/console/Color.php @@ -37,7 +37,7 @@ final class Color $this->background = $this->parseColor($background, \true); foreach ($options as $option) { if (!isset(self::AVAILABLE_OPTIONS[$option])) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('Invalid option specified: "%s". Expected one of (%s).', $option, \implode(', ', \array_keys(self::AVAILABLE_OPTIONS)))); + throw new InvalidArgumentException(\sprintf('Invalid option specified: "%s". Expected one of (%s).', $option, \implode(', ', \array_keys(self::AVAILABLE_OPTIONS)))); } $this->options[$option] = self::AVAILABLE_OPTIONS[$option]; } @@ -61,7 +61,7 @@ final class Color if (0 === \count($setCodes)) { return ''; } - return \sprintf("\33[%sm", \implode(';', $setCodes)); + return \sprintf("\x1b[%sm", \implode(';', $setCodes)); } public function unset() : string { @@ -78,7 +78,7 @@ final class Color if (0 === \count($unsetCodes)) { return ''; } - return \sprintf("\33[%sm", \implode(';', $unsetCodes)); + return \sprintf("\x1b[%sm", \implode(';', $unsetCodes)); } private function parseColor(string $color, bool $background = \false) : string { @@ -91,7 +91,7 @@ final class Color $color = $color[0] . $color[0] . $color[1] . $color[1] . $color[2] . $color[2]; } if (6 !== \strlen($color)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('Invalid "%s" color.', $color)); + throw new InvalidArgumentException(\sprintf('Invalid "%s" color.', $color)); } return ($background ? '4' : '3') . $this->convertHexColorToAnsi(\hexdec($color)); } @@ -101,7 +101,7 @@ final class Color if (isset(self::BRIGHT_COLORS[$color])) { return ($background ? '10' : '9') . self::BRIGHT_COLORS[$color]; } - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('Invalid "%s" color; expected one of (%s).', $color, \implode(', ', \array_merge(\array_keys(self::COLORS), \array_keys(self::BRIGHT_COLORS))))); + throw new InvalidArgumentException(\sprintf('Invalid "%s" color; expected one of (%s).', $color, \implode(', ', \array_merge(\array_keys(self::COLORS), \array_keys(self::BRIGHT_COLORS))))); } private function convertHexColorToAnsi(int $color) : string { diff --git a/vendor/symfony/console/Command/Command.php b/vendor/symfony/console/Command/Command.php index 0f7ed451fbe..827db35ac02 100644 --- a/vendor/symfony/console/Command/Command.php +++ b/vendor/symfony/console/Command/Command.php @@ -106,27 +106,27 @@ class Command public static function getDefaultName() : ?string { $class = static::class; - if ($attribute = \method_exists(new \ReflectionClass($class), 'getAttributes') ? (new \ReflectionClass($class))->getAttributes(\RectorPrefix20220607\Symfony\Component\Console\Attribute\AsCommand::class) : []) { + if ($attribute = \method_exists(new \ReflectionClass($class), 'getAttributes') ? (new \ReflectionClass($class))->getAttributes(AsCommand::class) : []) { return $attribute[0]->newInstance()->name; } $r = new \ReflectionProperty($class, 'defaultName'); if ($class !== $r->class || null === static::$defaultName) { return null; } - trigger_deprecation('symfony/console', '6.1', 'Relying on the static property "$defaultName" for setting a command name is deprecated. Add the "%s" attribute to the "%s" class instead.', \RectorPrefix20220607\Symfony\Component\Console\Attribute\AsCommand::class, static::class); + \RectorPrefix20220607\trigger_deprecation('symfony/console', '6.1', 'Relying on the static property "$defaultName" for setting a command name is deprecated. Add the "%s" attribute to the "%s" class instead.', AsCommand::class, static::class); return static::$defaultName; } public static function getDefaultDescription() : ?string { $class = static::class; - if ($attribute = \method_exists(new \ReflectionClass($class), 'getAttributes') ? (new \ReflectionClass($class))->getAttributes(\RectorPrefix20220607\Symfony\Component\Console\Attribute\AsCommand::class) : []) { + if ($attribute = \method_exists(new \ReflectionClass($class), 'getAttributes') ? (new \ReflectionClass($class))->getAttributes(AsCommand::class) : []) { return $attribute[0]->newInstance()->description; } $r = new \ReflectionProperty($class, 'defaultDescription'); if ($class !== $r->class || null === static::$defaultDescription) { return null; } - trigger_deprecation('symfony/console', '6.1', 'Relying on the static property "$defaultDescription" for setting a command description is deprecated. Add the "%s" attribute to the "%s" class instead.', \RectorPrefix20220607\Symfony\Component\Console\Attribute\AsCommand::class, static::class); + \RectorPrefix20220607\trigger_deprecation('symfony/console', '6.1', 'Relying on the static property "$defaultDescription" for setting a command description is deprecated. Add the "%s" attribute to the "%s" class instead.', AsCommand::class, static::class); return static::$defaultDescription; } /** @@ -136,7 +136,7 @@ class Command */ public function __construct(string $name = null) { - $this->definition = new \RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition(); + $this->definition = new InputDefinition(); if (null === $name && null !== ($name = static::getDefaultName())) { $aliases = \explode('|', $name); if ('' === ($name = \array_shift($aliases))) { @@ -162,7 +162,7 @@ class Command { $this->ignoreValidationErrors = \true; } - public function setApplication(\RectorPrefix20220607\Symfony\Component\Console\Application $application = null) + public function setApplication(Application $application = null) { $this->application = $application; if ($application) { @@ -172,21 +172,21 @@ class Command } $this->fullDefinition = null; } - public function setHelperSet(\RectorPrefix20220607\Symfony\Component\Console\Helper\HelperSet $helperSet) + public function setHelperSet(HelperSet $helperSet) { $this->helperSet = $helperSet; } /** * Gets the helper set. */ - public function getHelperSet() : ?\RectorPrefix20220607\Symfony\Component\Console\Helper\HelperSet + public function getHelperSet() : ?HelperSet { return $this->helperSet; } /** * Gets the application instance for this command. */ - public function getApplication() : ?\RectorPrefix20220607\Symfony\Component\Console\Application + public function getApplication() : ?Application { return $this->application; } @@ -222,9 +222,9 @@ class Command * * @see setCode() */ - protected function execute(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException('You must override the execute() method in the concrete command class.'); + throw new LogicException('You must override the execute() method in the concrete command class.'); } /** * Interacts with the user. @@ -233,7 +233,7 @@ class Command * This means that this is the only place where the command can * interactively ask for values of missing required arguments. */ - protected function interact(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) + protected function interact(InputInterface $input, OutputInterface $output) { } /** @@ -246,7 +246,7 @@ class Command * @see InputInterface::bind() * @see InputInterface::validate() */ - protected function initialize(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) + protected function initialize(InputInterface $input, OutputInterface $output) { } /** @@ -263,14 +263,14 @@ class Command * @see setCode() * @see execute() */ - public function run(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : int + public function run(InputInterface $input, OutputInterface $output) : int { // add the application arguments and options $this->mergeApplicationDefinition(); // bind the input against the command specific arguments/options try { $input->bind($this->getDefinition()); - } catch (\RectorPrefix20220607\Symfony\Component\Console\Exception\ExceptionInterface $e) { + } catch (ExceptionInterface $e) { if (!$this->ignoreValidationErrors) { throw $e; } @@ -280,14 +280,14 @@ class Command if (\function_exists('cli_set_process_title')) { if (!@\cli_set_process_title($this->processTitle)) { if ('Darwin' === \PHP_OS) { - $output->writeln('Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.', \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_VERY_VERBOSE); + $output->writeln('Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.', OutputInterface::VERBOSITY_VERY_VERBOSE); } else { \cli_set_process_title($this->processTitle); } } } elseif (\function_exists('RectorPrefix20220607\\setproctitle')) { setproctitle($this->processTitle); - } elseif (\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) { + } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) { $output->writeln('Install the proctitle PECL to be able to change the process title.'); } } @@ -314,12 +314,12 @@ class Command /** * Adds suggestions to $suggestions for the current completion input (e.g. option or argument). */ - public function complete(\RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionInput $input, \RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionSuggestions $suggestions) : void + public function complete(CompletionInput $input, CompletionSuggestions $suggestions) : void { $definition = $this->getDefinition(); - if (\RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionInput::TYPE_OPTION_VALUE === $input->getCompletionType() && $definition->hasOption($input->getCompletionName())) { + if (CompletionInput::TYPE_OPTION_VALUE === $input->getCompletionType() && $definition->hasOption($input->getCompletionName())) { $definition->getOption($input->getCompletionName())->complete($input, $suggestions); - } elseif (\RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionInput::TYPE_ARGUMENT_VALUE === $input->getCompletionType() && $definition->hasArgument($input->getCompletionName())) { + } elseif (CompletionInput::TYPE_ARGUMENT_VALUE === $input->getCompletionType() && $definition->hasArgument($input->getCompletionName())) { $definition->getArgument($input->getCompletionName())->complete($input, $suggestions); } } @@ -372,7 +372,7 @@ class Command if (null === $this->application) { return; } - $this->fullDefinition = new \RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition(); + $this->fullDefinition = new InputDefinition(); $this->fullDefinition->setOptions($this->definition->getOptions()); $this->fullDefinition->addOptions($this->application->getDefinition()->getOptions()); if ($mergeArgs) { @@ -390,7 +390,7 @@ class Command */ public function setDefinition($definition) { - if ($definition instanceof \RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition) { + if ($definition instanceof InputDefinition) { $this->definition = $definition; } else { $this->definition->setDefinition($definition); @@ -401,7 +401,7 @@ class Command /** * Gets the InputDefinition attached to this Command. */ - public function getDefinition() : \RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition + public function getDefinition() : InputDefinition { return $this->fullDefinition ?? $this->getNativeDefinition(); } @@ -413,10 +413,10 @@ class Command * * This method is not part of public API and should not be used directly. */ - public function getNativeDefinition() : \RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition + public function getNativeDefinition() : InputDefinition { if (!isset($this->definition)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException(\sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', static::class)); + throw new LogicException(\sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', static::class)); } return $this->definition; } @@ -437,8 +437,8 @@ class Command if (!\is_array($suggestedValues) && !$suggestedValues instanceof \Closure) { throw new \TypeError(\sprintf('Argument 5 passed to "%s()" must be array or \\Closure, "%s" given.', __METHOD__, \get_debug_type($suggestedValues))); } - $this->definition->addArgument(new \RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument($name, $mode, $description, $default, $suggestedValues)); - ($fullDefinition = $this->fullDefinition) ? $fullDefinition->addArgument(new \RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument($name, $mode, $description, $default, $suggestedValues)) : null; + $this->definition->addArgument(new InputArgument($name, $mode, $description, $default, $suggestedValues)); + ($fullDefinition = $this->fullDefinition) ? $fullDefinition->addArgument(new InputArgument($name, $mode, $description, $default, $suggestedValues)) : null; return $this; } /** @@ -459,8 +459,8 @@ class Command if (!\is_array($suggestedValues) && !$suggestedValues instanceof \Closure) { throw new \TypeError(\sprintf('Argument 5 passed to "%s()" must be array or \\Closure, "%s" given.', __METHOD__, \get_debug_type($suggestedValues))); } - $this->definition->addOption(new \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption($name, $shortcut, $mode, $description, $default, $suggestedValues)); - ($fullDefinition = $this->fullDefinition) ? $fullDefinition->addOption(new \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption($name, $shortcut, $mode, $description, $default, $suggestedValues)) : null; + $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default, $suggestedValues)); + ($fullDefinition = $this->fullDefinition) ? $fullDefinition->addOption(new InputOption($name, $shortcut, $mode, $description, $default, $suggestedValues)) : null; return $this; } /** @@ -633,7 +633,7 @@ class Command public function getHelper(string $name) { if (null === $this->helperSet) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException(\sprintf('Cannot retrieve helper "%s" because there is no HelperSet defined. Did you forget to add your command to the application or to set the application on the command using the setApplication() method? You can also set the HelperSet directly using the setHelperSet() method.', $name)); + throw new LogicException(\sprintf('Cannot retrieve helper "%s" because there is no HelperSet defined. Did you forget to add your command to the application or to set the application on the command using the setApplication() method? You can also set the HelperSet directly using the setHelperSet() method.', $name)); } return $this->helperSet->get($name); } @@ -647,7 +647,7 @@ class Command private function validateName(string $name) { if (!\preg_match('/^[^\\:]++(\\:[^\\:]++)*$/', $name)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('Command name "%s" is invalid.', $name)); + throw new InvalidArgumentException(\sprintf('Command name "%s" is invalid.', $name)); } } } diff --git a/vendor/symfony/console/Command/CompleteCommand.php b/vendor/symfony/console/Command/CompleteCommand.php index 4b77a331f91..2f8f7859378 100644 --- a/vendor/symfony/console/Command/CompleteCommand.php +++ b/vendor/symfony/console/Command/CompleteCommand.php @@ -26,8 +26,8 @@ use RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; * * @author Wouter de Jong */ -#[AsCommand(name: '|_complete', description: 'Internal command to provide shell completion suggestions')] -final class CompleteCommand extends \RectorPrefix20220607\Symfony\Component\Console\Command\Command +#[\Symfony\Component\Console\Attribute\AsCommand(name: '|_complete', description: 'Internal command to provide shell completion suggestions')] +final class CompleteCommand extends Command { /** * @deprecated since Symfony 6.1 @@ -45,18 +45,18 @@ final class CompleteCommand extends \RectorPrefix20220607\Symfony\Component\Cons public function __construct(array $completionOutputs = []) { // must be set before the parent constructor, as the property value is used in configure() - $this->completionOutputs = $completionOutputs + ['bash' => \RectorPrefix20220607\Symfony\Component\Console\Completion\Output\BashCompletionOutput::class, 'fish' => \RectorPrefix20220607\Symfony\Component\Console\Completion\Output\FishCompletionOutput::class]; + $this->completionOutputs = $completionOutputs + ['bash' => BashCompletionOutput::class, 'fish' => FishCompletionOutput::class]; parent::__construct(); } protected function configure() : void { - $this->addOption('shell', 's', \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED, 'The shell type ("' . \implode('", "', \array_keys($this->completionOutputs)) . '")')->addOption('input', 'i', \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED | \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_IS_ARRAY, 'An array of input tokens (e.g. COMP_WORDS or argv)')->addOption('current', 'c', \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED, 'The index of the "input" array that the cursor is in (e.g. COMP_CWORD)')->addOption('symfony', 'S', \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED, 'The version of the completion script'); + $this->addOption('shell', 's', InputOption::VALUE_REQUIRED, 'The shell type ("' . \implode('", "', \array_keys($this->completionOutputs)) . '")')->addOption('input', 'i', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'An array of input tokens (e.g. COMP_WORDS or argv)')->addOption('current', 'c', InputOption::VALUE_REQUIRED, 'The index of the "input" array that the cursor is in (e.g. COMP_CWORD)')->addOption('symfony', 'S', InputOption::VALUE_REQUIRED, 'The version of the completion script'); } - protected function initialize(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) + protected function initialize(InputInterface $input, OutputInterface $output) { $this->isDebug = \filter_var(\getenv('SYMFONY_COMPLETION_DEBUG'), \FILTER_VALIDATE_BOOLEAN); } - protected function execute(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : int + protected function execute(InputInterface $input, OutputInterface $output) : int { try { // uncomment when a bugfix or BC break has been introduced in the shell completion scripts @@ -75,7 +75,7 @@ final class CompleteCommand extends \RectorPrefix20220607\Symfony\Component\Cons throw new \RuntimeException(\sprintf('Shell completion is not supported for your shell: "%s" (supported: "%s").', $shell, \implode('", "', \array_keys($this->completionOutputs)))); } $completionInput = $this->createCompletionInput($input); - $suggestions = new \RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionSuggestions(); + $suggestions = new CompletionSuggestions(); $this->log(['', '' . \date('Y-m-d H:i:s') . '', 'Input: ("|" indicates the cursor position)', ' ' . (string) $completionInput, 'Command:', ' ' . (string) \implode(' ', $_SERVER['argv']), 'Messages:']); $command = $this->findCommand($completionInput, $output); if (null === $command) { @@ -88,11 +88,11 @@ final class CompleteCommand extends \RectorPrefix20220607\Symfony\Component\Cons } else { $command->mergeApplicationDefinition(); $completionInput->bind($command->getDefinition()); - if (\RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionInput::TYPE_OPTION_NAME === $completionInput->getCompletionType()) { - $this->log(' Completing option names for the ' . \get_class($command instanceof \RectorPrefix20220607\Symfony\Component\Console\Command\LazyCommand ? $command->getCommand() : $command) . ' command.'); + if (CompletionInput::TYPE_OPTION_NAME === $completionInput->getCompletionType()) { + $this->log(' Completing option names for the ' . \get_class($command instanceof LazyCommand ? $command->getCommand() : $command) . ' command.'); $suggestions->suggestOptions($command->getDefinition()->getOptions()); } else { - $this->log([' Completing using the ' . \get_class($command instanceof \RectorPrefix20220607\Symfony\Component\Console\Command\LazyCommand ? $command->getCommand() : $command) . ' class.', ' Completing ' . $completionInput->getCompletionType() . ' for ' . $completionInput->getCompletionName() . '']); + $this->log([' Completing using the ' . \get_class($command instanceof LazyCommand ? $command->getCommand() : $command) . ' class.', ' Completing ' . $completionInput->getCompletionType() . ' for ' . $completionInput->getCompletionName() . '']); if (null !== ($compval = $completionInput->getCompletionValue())) { $this->log(' Current value: ' . $compval . ''); } @@ -121,20 +121,20 @@ final class CompleteCommand extends \RectorPrefix20220607\Symfony\Component\Cons } return self::SUCCESS; } - private function createCompletionInput(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input) : \RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionInput + private function createCompletionInput(InputInterface $input) : CompletionInput { $currentIndex = $input->getOption('current'); if (!$currentIndex || !\ctype_digit($currentIndex)) { throw new \RuntimeException('The "--current" option must be set and it must be an integer.'); } - $completionInput = \RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionInput::fromTokens($input->getOption('input'), (int) $currentIndex); + $completionInput = CompletionInput::fromTokens($input->getOption('input'), (int) $currentIndex); try { $completionInput->bind($this->getApplication()->getDefinition()); - } catch (\RectorPrefix20220607\Symfony\Component\Console\Exception\ExceptionInterface $exception) { + } catch (ExceptionInterface $exception) { } return $completionInput; } - private function findCommand(\RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionInput $completionInput, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : ?\RectorPrefix20220607\Symfony\Component\Console\Command\Command + private function findCommand(CompletionInput $completionInput, OutputInterface $output) : ?Command { try { $inputName = $completionInput->getFirstArgument(); @@ -142,7 +142,7 @@ final class CompleteCommand extends \RectorPrefix20220607\Symfony\Component\Cons return null; } return $this->getApplication()->find($inputName); - } catch (\RectorPrefix20220607\Symfony\Component\Console\Exception\CommandNotFoundException $exception) { + } catch (CommandNotFoundException $exception) { } return null; } diff --git a/vendor/symfony/console/Command/DumpCompletionCommand.php b/vendor/symfony/console/Command/DumpCompletionCommand.php index b85dcd07cda..dd13b32aea2 100644 --- a/vendor/symfony/console/Command/DumpCompletionCommand.php +++ b/vendor/symfony/console/Command/DumpCompletionCommand.php @@ -22,8 +22,8 @@ use RectorPrefix20220607\Symfony\Component\Process\Process; * * @author Wouter de Jong */ -#[AsCommand(name: 'completion', description: 'Dump the shell completion script')] -final class DumpCompletionCommand extends \RectorPrefix20220607\Symfony\Component\Console\Command\Command +#[\Symfony\Component\Console\Attribute\AsCommand(name: 'completion', description: 'Dump the shell completion script')] +final class DumpCompletionCommand extends Command { /** * @deprecated since Symfony 6.1 @@ -79,9 +79,9 @@ Add this to the end of your shell configuration file (e.g. "{$rcFile}") eval "\$({$fullCommand} completion {$shell})" EOH -)->addArgument('shell', \RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument::OPTIONAL, 'The shell type (e.g. "bash"), the value of the "$SHELL" env var will be used if this is not given', null, \Closure::fromCallable([$this, 'getSupportedShells']))->addOption('debug', null, \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Tail the completion debug log'); +)->addArgument('shell', InputArgument::OPTIONAL, 'The shell type (e.g. "bash"), the value of the "$SHELL" env var will be used if this is not given', null, \Closure::fromCallable([$this, 'getSupportedShells']))->addOption('debug', null, InputOption::VALUE_NONE, 'Tail the completion debug log'); } - protected function execute(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : int + protected function execute(InputInterface $input, OutputInterface $output) : int { $commandName = \basename($_SERVER['argv'][0]); if ($input->getOption('debug')) { @@ -92,7 +92,7 @@ EOH $completionFile = __DIR__ . '/../Resources/completion.' . $shell; if (!\file_exists($completionFile)) { $supportedShells = $this->getSupportedShells(); - ($output instanceof \RectorPrefix20220607\Symfony\Component\Console\Output\ConsoleOutputInterface ? $output->getErrorOutput() : $output)->writeln(\sprintf('Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").', $shell, \implode('", "', $supportedShells))); + ($output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output)->writeln(\sprintf('Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").', $shell, \implode('", "', $supportedShells))); return self::INVALID; } $output->write(\str_replace(['{{ COMMAND_NAME }}', '{{ VERSION }}'], [$commandName, $this->getApplication()->getVersion()], \file_get_contents($completionFile))); @@ -102,13 +102,13 @@ EOH { return \basename($_SERVER['SHELL'] ?? ''); } - private function tailDebugLog(string $commandName, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : void + private function tailDebugLog(string $commandName, OutputInterface $output) : void { $debugFile = \sys_get_temp_dir() . '/sf_' . $commandName . '.log'; if (!\file_exists($debugFile)) { \touch($debugFile); } - $process = new \RectorPrefix20220607\Symfony\Component\Process\Process(['tail', '-f', $debugFile], null, null, null, 0); + $process = new Process(['tail', '-f', $debugFile], null, null, null, 0); $process->run(function (string $type, string $line) use($output) : void { $output->write($line); }); diff --git a/vendor/symfony/console/Command/HelpCommand.php b/vendor/symfony/console/Command/HelpCommand.php index c4957f8adf6..af711f5b818 100644 --- a/vendor/symfony/console/Command/HelpCommand.php +++ b/vendor/symfony/console/Command/HelpCommand.php @@ -21,7 +21,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; * * @author Fabien Potencier */ -class HelpCommand extends \RectorPrefix20220607\Symfony\Component\Console\Command\Command +class HelpCommand extends Command { /** * @var \Symfony\Component\Console\Command\Command @@ -33,11 +33,11 @@ class HelpCommand extends \RectorPrefix20220607\Symfony\Component\Console\Comman protected function configure() { $this->ignoreValidationErrors(); - $this->setName('help')->setDefinition([new \RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument('command_name', \RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument::OPTIONAL, 'The command name', 'help', function () { - return \array_keys((new \RectorPrefix20220607\Symfony\Component\Console\Descriptor\ApplicationDescription($this->getApplication()))->getCommands()); - }), new \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption('format', null, \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt', function () { - return (new \RectorPrefix20220607\Symfony\Component\Console\Helper\DescriptorHelper())->getFormats(); - }), new \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption('raw', null, \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'To output raw command help')])->setDescription('Display help for a command')->setHelp(<<<'EOF' + $this->setName('help')->setDefinition([new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help', function () { + return \array_keys((new ApplicationDescription($this->getApplication()))->getCommands()); + }), new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt', function () { + return (new DescriptorHelper())->getFormats(); + }), new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help')])->setDescription('Display help for a command')->setHelp(<<<'EOF' The %command.name% command displays help for a given command: %command.full_name% list @@ -50,17 +50,17 @@ To display the list of available commands, please use the list comm EOF ); } - public function setCommand(\RectorPrefix20220607\Symfony\Component\Console\Command\Command $command) + public function setCommand(Command $command) { $this->command = $command; } /** * {@inheritdoc} */ - protected function execute(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : int + protected function execute(InputInterface $input, OutputInterface $output) : int { $this->command = $this->command ?? $this->getApplication()->find($input->getArgument('command_name')); - $helper = new \RectorPrefix20220607\Symfony\Component\Console\Helper\DescriptorHelper(); + $helper = new DescriptorHelper(); $helper->describe($output, $this->command, ['format' => $input->getOption('format'), 'raw_text' => $input->getOption('raw')]); unset($this->command); return 0; diff --git a/vendor/symfony/console/Command/LazyCommand.php b/vendor/symfony/console/Command/LazyCommand.php index 9ea38d7114b..0f669b0d16e 100644 --- a/vendor/symfony/console/Command/LazyCommand.php +++ b/vendor/symfony/console/Command/LazyCommand.php @@ -21,7 +21,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; /** * @author Nicolas Grekas */ -final class LazyCommand extends \RectorPrefix20220607\Symfony\Component\Console\Command\Command +final class LazyCommand extends Command { /** * @var \Closure|\Symfony\Component\Console\Command\Command @@ -41,14 +41,14 @@ final class LazyCommand extends \RectorPrefix20220607\Symfony\Component\Console\ { $this->getCommand()->ignoreValidationErrors(); } - public function setApplication(\RectorPrefix20220607\Symfony\Component\Console\Application $application = null) : void + public function setApplication(Application $application = null) : void { if ($this->command instanceof parent) { $this->command->setApplication($application); } parent::setApplication($application); } - public function setHelperSet(\RectorPrefix20220607\Symfony\Component\Console\Helper\HelperSet $helperSet) : void + public function setHelperSet(HelperSet $helperSet) : void { if ($this->command instanceof parent) { $this->command->setHelperSet($helperSet); @@ -59,11 +59,11 @@ final class LazyCommand extends \RectorPrefix20220607\Symfony\Component\Console\ { return $this->isEnabled ?? $this->getCommand()->isEnabled(); } - public function run(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : int + public function run(InputInterface $input, OutputInterface $output) : int { return $this->getCommand()->run($input, $output); } - public function complete(\RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionInput $input, \RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionSuggestions $suggestions) : void + public function complete(CompletionInput $input, CompletionSuggestions $suggestions) : void { $this->getCommand()->complete($input, $suggestions); } @@ -91,11 +91,11 @@ final class LazyCommand extends \RectorPrefix20220607\Symfony\Component\Console\ $this->getCommand()->setDefinition($definition); return $this; } - public function getDefinition() : \RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition + public function getDefinition() : InputDefinition { return $this->getCommand()->getDefinition(); } - public function getNativeDefinition() : \RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition + public function getNativeDefinition() : InputDefinition { return $this->getCommand()->getNativeDefinition(); } diff --git a/vendor/symfony/console/Command/ListCommand.php b/vendor/symfony/console/Command/ListCommand.php index 3bb7eca9db3..ba2185ff33d 100644 --- a/vendor/symfony/console/Command/ListCommand.php +++ b/vendor/symfony/console/Command/ListCommand.php @@ -21,18 +21,18 @@ use RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; * * @author Fabien Potencier */ -class ListCommand extends \RectorPrefix20220607\Symfony\Component\Console\Command\Command +class ListCommand extends Command { /** * {@inheritdoc} */ protected function configure() { - $this->setName('list')->setDefinition([new \RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument('namespace', \RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument::OPTIONAL, 'The namespace name', null, function () { - return \array_keys((new \RectorPrefix20220607\Symfony\Component\Console\Descriptor\ApplicationDescription($this->getApplication()))->getNamespaces()); - }), new \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption('raw', null, \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'To output raw command list'), new \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption('format', null, \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt', function () { - return (new \RectorPrefix20220607\Symfony\Component\Console\Helper\DescriptorHelper())->getFormats(); - }), new \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption('short', null, \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'To skip describing commands\' arguments')])->setDescription('List commands')->setHelp(<<<'EOF' + $this->setName('list')->setDefinition([new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name', null, function () { + return \array_keys((new ApplicationDescription($this->getApplication()))->getNamespaces()); + }), new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'), new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt', function () { + return (new DescriptorHelper())->getFormats(); + }), new InputOption('short', null, InputOption::VALUE_NONE, 'To skip describing commands\' arguments')])->setDescription('List commands')->setHelp(<<<'EOF' The %command.name% command lists all commands: %command.full_name% @@ -54,9 +54,9 @@ EOF /** * {@inheritdoc} */ - protected function execute(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : int + protected function execute(InputInterface $input, OutputInterface $output) : int { - $helper = new \RectorPrefix20220607\Symfony\Component\Console\Helper\DescriptorHelper(); + $helper = new DescriptorHelper(); $helper->describe($output, $this->getApplication(), ['format' => $input->getOption('format'), 'raw_text' => $input->getOption('raw'), 'namespace' => $input->getArgument('namespace'), 'short' => $input->getOption('short')]); return 0; } diff --git a/vendor/symfony/console/Command/LockableTrait.php b/vendor/symfony/console/Command/LockableTrait.php index be87cb28e06..5a0232a489c 100644 --- a/vendor/symfony/console/Command/LockableTrait.php +++ b/vendor/symfony/console/Command/LockableTrait.php @@ -31,18 +31,18 @@ trait LockableTrait */ private function lock(string $name = null, bool $blocking = \false) : bool { - if (!\class_exists(\RectorPrefix20220607\Symfony\Component\Lock\Store\SemaphoreStore::class)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException('To enable the locking feature you must install the symfony/lock component.'); + if (!\class_exists(SemaphoreStore::class)) { + throw new LogicException('To enable the locking feature you must install the symfony/lock component.'); } if (null !== $this->lock) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException('A lock is already in place.'); + throw new LogicException('A lock is already in place.'); } - if (\RectorPrefix20220607\Symfony\Component\Lock\Store\SemaphoreStore::isSupported()) { - $store = new \RectorPrefix20220607\Symfony\Component\Lock\Store\SemaphoreStore(); + if (SemaphoreStore::isSupported()) { + $store = new SemaphoreStore(); } else { - $store = new \RectorPrefix20220607\Symfony\Component\Lock\Store\FlockStore(); + $store = new FlockStore(); } - $this->lock = (new \RectorPrefix20220607\Symfony\Component\Lock\LockFactory($store))->createLock($name ?: $this->getName()); + $this->lock = (new LockFactory($store))->createLock($name ?: $this->getName()); if (!$this->lock->acquire($blocking)) { $this->lock = null; return \false; diff --git a/vendor/symfony/console/CommandLoader/CommandLoaderInterface.php b/vendor/symfony/console/CommandLoader/CommandLoaderInterface.php index c91d92f2400..ec8d3d78a4d 100644 --- a/vendor/symfony/console/CommandLoader/CommandLoaderInterface.php +++ b/vendor/symfony/console/CommandLoader/CommandLoaderInterface.php @@ -22,7 +22,7 @@ interface CommandLoaderInterface * * @throws CommandNotFoundException */ - public function get(string $name) : \RectorPrefix20220607\Symfony\Component\Console\Command\Command; + public function get(string $name) : Command; /** * Checks if a command exists. */ diff --git a/vendor/symfony/console/CommandLoader/ContainerCommandLoader.php b/vendor/symfony/console/CommandLoader/ContainerCommandLoader.php index 3b6ed410dd1..5792d39a7d0 100644 --- a/vendor/symfony/console/CommandLoader/ContainerCommandLoader.php +++ b/vendor/symfony/console/CommandLoader/ContainerCommandLoader.php @@ -18,7 +18,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Exception\CommandNotFoundExce * * @author Robin Chalas */ -class ContainerCommandLoader implements \RectorPrefix20220607\Symfony\Component\Console\CommandLoader\CommandLoaderInterface +class ContainerCommandLoader implements CommandLoaderInterface { /** * @var \Psr\Container\ContainerInterface @@ -31,7 +31,7 @@ class ContainerCommandLoader implements \RectorPrefix20220607\Symfony\Component\ /** * @param array $commandMap An array with command names as keys and service ids as values */ - public function __construct(\RectorPrefix20220607\Psr\Container\ContainerInterface $container, array $commandMap) + public function __construct(ContainerInterface $container, array $commandMap) { $this->container = $container; $this->commandMap = $commandMap; @@ -39,10 +39,10 @@ class ContainerCommandLoader implements \RectorPrefix20220607\Symfony\Component\ /** * {@inheritdoc} */ - public function get(string $name) : \RectorPrefix20220607\Symfony\Component\Console\Command\Command + public function get(string $name) : Command { if (!$this->has($name)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\CommandNotFoundException(\sprintf('Command "%s" does not exist.', $name)); + throw new CommandNotFoundException(\sprintf('Command "%s" does not exist.', $name)); } return $this->container->get($this->commandMap[$name]); } diff --git a/vendor/symfony/console/CommandLoader/FactoryCommandLoader.php b/vendor/symfony/console/CommandLoader/FactoryCommandLoader.php index 374696d9795..9c018d89cce 100644 --- a/vendor/symfony/console/CommandLoader/FactoryCommandLoader.php +++ b/vendor/symfony/console/CommandLoader/FactoryCommandLoader.php @@ -17,7 +17,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Exception\CommandNotFoundExce * * @author Maxime Steinhausser */ -class FactoryCommandLoader implements \RectorPrefix20220607\Symfony\Component\Console\CommandLoader\CommandLoaderInterface +class FactoryCommandLoader implements CommandLoaderInterface { /** * @var mixed[] @@ -40,10 +40,10 @@ class FactoryCommandLoader implements \RectorPrefix20220607\Symfony\Component\Co /** * {@inheritdoc} */ - public function get(string $name) : \RectorPrefix20220607\Symfony\Component\Console\Command\Command + public function get(string $name) : Command { if (!isset($this->factories[$name])) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\CommandNotFoundException(\sprintf('Command "%s" does not exist.', $name)); + throw new CommandNotFoundException(\sprintf('Command "%s" does not exist.', $name)); } $factory = $this->factories[$name]; return $factory(); diff --git a/vendor/symfony/console/Completion/CompletionInput.php b/vendor/symfony/console/Completion/CompletionInput.php index 69ebe434216..4cc58d9cb4c 100644 --- a/vendor/symfony/console/Completion/CompletionInput.php +++ b/vendor/symfony/console/Completion/CompletionInput.php @@ -22,7 +22,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Input\InputOption; * * @author Wouter de Jong */ -final class CompletionInput extends \RectorPrefix20220607\Symfony\Component\Console\Input\ArgvInput +final class CompletionInput extends ArgvInput { public const TYPE_ARGUMENT_VALUE = 'argument_value'; public const TYPE_OPTION_VALUE = 'option_value'; @@ -59,7 +59,7 @@ final class CompletionInput extends \RectorPrefix20220607\Symfony\Component\Cons /** * {@inheritdoc} */ - public function bind(\RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition $definition) : void + public function bind(InputDefinition $definition) : void { parent::bind($definition); $relevantToken = $this->getRelevantToken(); @@ -159,12 +159,12 @@ final class CompletionInput extends \RectorPrefix20220607\Symfony\Component\Cons { try { return parent::parseToken($token, $parseOptions); - } catch (\RectorPrefix20220607\Symfony\Component\Console\Exception\RuntimeException $exception) { + } catch (RuntimeException $exception) { // suppress errors, completed input is almost never valid } return $parseOptions; } - private function getOptionFromToken(string $optionToken) : ?\RectorPrefix20220607\Symfony\Component\Console\Input\InputOption + private function getOptionFromToken(string $optionToken) : ?InputOption { $optionName = \ltrim($optionToken, '-'); if (!$optionName) { diff --git a/vendor/symfony/console/Completion/CompletionSuggestions.php b/vendor/symfony/console/Completion/CompletionSuggestions.php index 709f6e00d03..8bc9954a0fd 100644 --- a/vendor/symfony/console/Completion/CompletionSuggestions.php +++ b/vendor/symfony/console/Completion/CompletionSuggestions.php @@ -28,7 +28,7 @@ final class CompletionSuggestions */ public function suggestValue($value) { - $this->valueSuggestions[] = !$value instanceof \RectorPrefix20220607\Symfony\Component\Console\Completion\Suggestion ? new \RectorPrefix20220607\Symfony\Component\Console\Completion\Suggestion($value) : $value; + $this->valueSuggestions[] = !$value instanceof Suggestion ? new Suggestion($value) : $value; return $this; } /** @@ -50,7 +50,7 @@ final class CompletionSuggestions * * @return $this */ - public function suggestOption(\RectorPrefix20220607\Symfony\Component\Console\Input\InputOption $option) + public function suggestOption(InputOption $option) { $this->optionSuggestions[] = $option; return $this; diff --git a/vendor/symfony/console/Completion/Output/BashCompletionOutput.php b/vendor/symfony/console/Completion/Output/BashCompletionOutput.php index 60ab25c952e..6522eb8c2f3 100644 --- a/vendor/symfony/console/Completion/Output/BashCompletionOutput.php +++ b/vendor/symfony/console/Completion/Output/BashCompletionOutput.php @@ -15,9 +15,9 @@ use RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; /** * @author Wouter de Jong */ -class BashCompletionOutput implements \RectorPrefix20220607\Symfony\Component\Console\Completion\Output\CompletionOutputInterface +class BashCompletionOutput implements CompletionOutputInterface { - public function write(\RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionSuggestions $suggestions, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : void + public function write(CompletionSuggestions $suggestions, OutputInterface $output) : void { $values = $suggestions->getValueSuggestions(); foreach ($suggestions->getOptionSuggestions() as $option) { diff --git a/vendor/symfony/console/Completion/Output/CompletionOutputInterface.php b/vendor/symfony/console/Completion/Output/CompletionOutputInterface.php index 3c94638f81e..294715c41d7 100644 --- a/vendor/symfony/console/Completion/Output/CompletionOutputInterface.php +++ b/vendor/symfony/console/Completion/Output/CompletionOutputInterface.php @@ -19,5 +19,5 @@ use RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; */ interface CompletionOutputInterface { - public function write(\RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionSuggestions $suggestions, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : void; + public function write(CompletionSuggestions $suggestions, OutputInterface $output) : void; } diff --git a/vendor/symfony/console/Completion/Output/FishCompletionOutput.php b/vendor/symfony/console/Completion/Output/FishCompletionOutput.php index 81faee7c78f..d26993ccc26 100644 --- a/vendor/symfony/console/Completion/Output/FishCompletionOutput.php +++ b/vendor/symfony/console/Completion/Output/FishCompletionOutput.php @@ -15,9 +15,9 @@ use RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; /** * @author Guillaume Aveline */ -class FishCompletionOutput implements \RectorPrefix20220607\Symfony\Component\Console\Completion\Output\CompletionOutputInterface +class FishCompletionOutput implements CompletionOutputInterface { - public function write(\RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionSuggestions $suggestions, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : void + public function write(CompletionSuggestions $suggestions, OutputInterface $output) : void { $values = $suggestions->getValueSuggestions(); foreach ($suggestions->getOptionSuggestions() as $option) { diff --git a/vendor/symfony/console/ConsoleEvents.php b/vendor/symfony/console/ConsoleEvents.php index a6e008fbe68..46a00eb4401 100644 --- a/vendor/symfony/console/ConsoleEvents.php +++ b/vendor/symfony/console/ConsoleEvents.php @@ -57,5 +57,5 @@ final class ConsoleEvents * * These aliases can be consumed by RegisterListenersPass. */ - public const ALIASES = [\RectorPrefix20220607\Symfony\Component\Console\Event\ConsoleCommandEvent::class => self::COMMAND, \RectorPrefix20220607\Symfony\Component\Console\Event\ConsoleErrorEvent::class => self::ERROR, \RectorPrefix20220607\Symfony\Component\Console\Event\ConsoleSignalEvent::class => self::SIGNAL, \RectorPrefix20220607\Symfony\Component\Console\Event\ConsoleTerminateEvent::class => self::TERMINATE]; + public const ALIASES = [ConsoleCommandEvent::class => self::COMMAND, ConsoleErrorEvent::class => self::ERROR, ConsoleSignalEvent::class => self::SIGNAL, ConsoleTerminateEvent::class => self::TERMINATE]; } diff --git a/vendor/symfony/console/Cursor.php b/vendor/symfony/console/Cursor.php index 4ad8454f516..06d66d4e1b3 100644 --- a/vendor/symfony/console/Cursor.php +++ b/vendor/symfony/console/Cursor.php @@ -24,7 +24,7 @@ final class Cursor /** * @param resource|null $input */ - public function __construct(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, $input = null) + public function __construct(OutputInterface $output, $input = null) { $this->output = $output; $this->input = $input ?? (\defined('STDIN') ? \STDIN : \fopen('php://input', 'r+')); @@ -34,7 +34,7 @@ final class Cursor */ public function moveUp(int $lines = 1) { - $this->output->write(\sprintf("\33[%dA", $lines)); + $this->output->write(\sprintf("\x1b[%dA", $lines)); return $this; } /** @@ -42,7 +42,7 @@ final class Cursor */ public function moveDown(int $lines = 1) { - $this->output->write(\sprintf("\33[%dB", $lines)); + $this->output->write(\sprintf("\x1b[%dB", $lines)); return $this; } /** @@ -50,7 +50,7 @@ final class Cursor */ public function moveRight(int $columns = 1) { - $this->output->write(\sprintf("\33[%dC", $columns)); + $this->output->write(\sprintf("\x1b[%dC", $columns)); return $this; } /** @@ -58,7 +58,7 @@ final class Cursor */ public function moveLeft(int $columns = 1) { - $this->output->write(\sprintf("\33[%dD", $columns)); + $this->output->write(\sprintf("\x1b[%dD", $columns)); return $this; } /** @@ -66,7 +66,7 @@ final class Cursor */ public function moveToColumn(int $column) { - $this->output->write(\sprintf("\33[%dG", $column)); + $this->output->write(\sprintf("\x1b[%dG", $column)); return $this; } /** @@ -74,7 +74,7 @@ final class Cursor */ public function moveToPosition(int $column, int $row) { - $this->output->write(\sprintf("\33[%d;%dH", $row + 1, $column)); + $this->output->write(\sprintf("\x1b[%d;%dH", $row + 1, $column)); return $this; } /** @@ -82,7 +82,7 @@ final class Cursor */ public function savePosition() { - $this->output->write("\0337"); + $this->output->write("\x1b7"); return $this; } /** @@ -90,7 +90,7 @@ final class Cursor */ public function restorePosition() { - $this->output->write("\338"); + $this->output->write("\x1b8"); return $this; } /** @@ -98,7 +98,7 @@ final class Cursor */ public function hide() { - $this->output->write("\33[?25l"); + $this->output->write("\x1b[?25l"); return $this; } /** @@ -106,7 +106,7 @@ final class Cursor */ public function show() { - $this->output->write("\33[?25h\33[?0c"); + $this->output->write("\x1b[?25h\x1b[?0c"); return $this; } /** @@ -116,7 +116,7 @@ final class Cursor */ public function clearLine() { - $this->output->write("\33[2K"); + $this->output->write("\x1b[2K"); return $this; } /** @@ -124,7 +124,7 @@ final class Cursor */ public function clearLineAfter() : self { - $this->output->write("\33[K"); + $this->output->write("\x1b[K"); return $this; } /** @@ -134,7 +134,7 @@ final class Cursor */ public function clearOutput() { - $this->output->write("\33[0J"); + $this->output->write("\x1b[0J"); return $this; } /** @@ -144,7 +144,7 @@ final class Cursor */ public function clearScreen() { - $this->output->write("\33[2J"); + $this->output->write("\x1b[2J"); return $this; } /** @@ -161,10 +161,10 @@ final class Cursor } $sttyMode = \shell_exec('stty -g'); \shell_exec('stty -icanon -echo'); - @\fwrite($this->input, "\33[6n"); + @\fwrite($this->input, "\x1b[6n"); $code = \trim(\fread($this->input, 1024)); \shell_exec(\sprintf('stty %s', $sttyMode)); - \sscanf($code, "\33[%d;%dR", $row, $col); + \sscanf($code, "\x1b[%d;%dR", $row, $col); return [$col, $row]; } } diff --git a/vendor/symfony/console/DependencyInjection/AddConsoleCommandPass.php b/vendor/symfony/console/DependencyInjection/AddConsoleCommandPass.php index db5002005ba..f735a87e201 100644 --- a/vendor/symfony/console/DependencyInjection/AddConsoleCommandPass.php +++ b/vendor/symfony/console/DependencyInjection/AddConsoleCommandPass.php @@ -25,9 +25,9 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference; * * @author Grégoire Pineau */ -class AddConsoleCommandPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +class AddConsoleCommandPass implements CompilerPassInterface { - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { $commandServices = $container->findTaggedServiceIds('console.command', \true); $lazyCommandMap = []; @@ -41,10 +41,10 @@ class AddConsoleCommandPass implements \RectorPrefix20220607\Symfony\Component\D $aliases = $tags[0]['command']; } else { if (!($r = $container->getReflectionClass($class))) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); + throw new InvalidArgumentException(\sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); } - if (!$r->isSubclassOf(\RectorPrefix20220607\Symfony\Component\Console\Command\Command::class)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, 'console.command', \RectorPrefix20220607\Symfony\Component\Console\Command\Command::class)); + if (!$r->isSubclassOf(Command::class)) { + throw new InvalidArgumentException(\sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, 'console.command', Command::class)); } $aliases = $class::getDefaultName(); } @@ -65,7 +65,7 @@ class AddConsoleCommandPass implements \RectorPrefix20220607\Symfony\Component\D $description = $tags[0]['description'] ?? null; unset($tags[0]); $lazyCommandMap[$commandName] = $id; - $lazyCommandRefs[$id] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference($id, $class); + $lazyCommandRefs[$id] = new TypedReference($id, $class); foreach ($aliases as $alias) { $lazyCommandMap[$alias] = $id; } @@ -85,20 +85,20 @@ class AddConsoleCommandPass implements \RectorPrefix20220607\Symfony\Component\D } if (!$description) { if (!($r = $container->getReflectionClass($class))) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); + throw new InvalidArgumentException(\sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); } - if (!$r->isSubclassOf(\RectorPrefix20220607\Symfony\Component\Console\Command\Command::class)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, 'console.command', \RectorPrefix20220607\Symfony\Component\Console\Command\Command::class)); + if (!$r->isSubclassOf(Command::class)) { + throw new InvalidArgumentException(\sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, 'console.command', Command::class)); } $description = $class::getDefaultDescription(); } if ($description) { $definition->addMethodCall('setDescription', [$description]); - $container->register('.' . $id . '.lazy', \RectorPrefix20220607\Symfony\Component\Console\Command\LazyCommand::class)->setArguments([$commandName, $aliases, $description, $isHidden, new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument($lazyCommandRefs[$id])]); - $lazyCommandRefs[$id] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference('.' . $id . '.lazy'); + $container->register('.' . $id . '.lazy', LazyCommand::class)->setArguments([$commandName, $aliases, $description, $isHidden, new ServiceClosureArgument($lazyCommandRefs[$id])]); + $lazyCommandRefs[$id] = new Reference('.' . $id . '.lazy'); } } - $container->register('console.command_loader', \RectorPrefix20220607\Symfony\Component\Console\CommandLoader\ContainerCommandLoader::class)->setPublic(\true)->addTag('container.no_preload')->setArguments([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass::register($container, $lazyCommandRefs), $lazyCommandMap]); + $container->register('console.command_loader', ContainerCommandLoader::class)->setPublic(\true)->addTag('container.no_preload')->setArguments([ServiceLocatorTagPass::register($container, $lazyCommandRefs), $lazyCommandMap]); $container->setParameter('console.command.ids', $serviceIds); } } diff --git a/vendor/symfony/console/Descriptor/ApplicationDescription.php b/vendor/symfony/console/Descriptor/ApplicationDescription.php index d9b9915630f..c9187dc5dbc 100644 --- a/vendor/symfony/console/Descriptor/ApplicationDescription.php +++ b/vendor/symfony/console/Descriptor/ApplicationDescription.php @@ -45,7 +45,7 @@ class ApplicationDescription * @var array */ private $aliases = []; - public function __construct(\RectorPrefix20220607\Symfony\Component\Console\Application $application, string $namespace = null, bool $showHidden = \false) + public function __construct(Application $application, string $namespace = null, bool $showHidden = \false) { $this->application = $application; $this->namespace = $namespace; @@ -71,10 +71,10 @@ class ApplicationDescription /** * @throws CommandNotFoundException */ - public function getCommand(string $name) : \RectorPrefix20220607\Symfony\Component\Console\Command\Command + public function getCommand(string $name) : Command { if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\CommandNotFoundException(\sprintf('Command "%s" does not exist.', $name)); + throw new CommandNotFoundException(\sprintf('Command "%s" does not exist.', $name)); } return $this->commands[$name] ?? $this->aliases[$name]; } diff --git a/vendor/symfony/console/Descriptor/Descriptor.php b/vendor/symfony/console/Descriptor/Descriptor.php index 9bf413e2779..cf4cee327e2 100644 --- a/vendor/symfony/console/Descriptor/Descriptor.php +++ b/vendor/symfony/console/Descriptor/Descriptor.php @@ -22,7 +22,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; * * @internal */ -abstract class Descriptor implements \RectorPrefix20220607\Symfony\Component\Console\Descriptor\DescriptorInterface +abstract class Descriptor implements DescriptorInterface { /** * @var OutputInterface @@ -31,27 +31,27 @@ abstract class Descriptor implements \RectorPrefix20220607\Symfony\Component\Con /** * {@inheritdoc} */ - public function describe(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, object $object, array $options = []) + public function describe(OutputInterface $output, object $object, array $options = []) { $this->output = $output; switch (\true) { - case $object instanceof \RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument: + case $object instanceof InputArgument: $this->describeInputArgument($object, $options); break; - case $object instanceof \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption: + case $object instanceof InputOption: $this->describeInputOption($object, $options); break; - case $object instanceof \RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition: + case $object instanceof InputDefinition: $this->describeInputDefinition($object, $options); break; - case $object instanceof \RectorPrefix20220607\Symfony\Component\Console\Command\Command: + case $object instanceof Command: $this->describeCommand($object, $options); break; - case $object instanceof \RectorPrefix20220607\Symfony\Component\Console\Application: + case $object instanceof Application: $this->describeApplication($object, $options); break; default: - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('Object of type "%s" is not describable.', \get_debug_type($object))); + throw new InvalidArgumentException(\sprintf('Object of type "%s" is not describable.', \get_debug_type($object))); } } /** @@ -59,26 +59,26 @@ abstract class Descriptor implements \RectorPrefix20220607\Symfony\Component\Con */ protected function write(string $content, bool $decorated = \false) { - $this->output->write($content, \false, $decorated ? \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::OUTPUT_NORMAL : \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::OUTPUT_RAW); + $this->output->write($content, \false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW); } /** * Describes an InputArgument instance. */ - protected abstract function describeInputArgument(\RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument $argument, array $options = []); + protected abstract function describeInputArgument(InputArgument $argument, array $options = []); /** * Describes an InputOption instance. */ - protected abstract function describeInputOption(\RectorPrefix20220607\Symfony\Component\Console\Input\InputOption $option, array $options = []); + protected abstract function describeInputOption(InputOption $option, array $options = []); /** * Describes an InputDefinition instance. */ - protected abstract function describeInputDefinition(\RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition $definition, array $options = []); + protected abstract function describeInputDefinition(InputDefinition $definition, array $options = []); /** * Describes a Command instance. */ - protected abstract function describeCommand(\RectorPrefix20220607\Symfony\Component\Console\Command\Command $command, array $options = []); + protected abstract function describeCommand(Command $command, array $options = []); /** * Describes an Application instance. */ - protected abstract function describeApplication(\RectorPrefix20220607\Symfony\Component\Console\Application $application, array $options = []); + protected abstract function describeApplication(Application $application, array $options = []); } diff --git a/vendor/symfony/console/Descriptor/DescriptorInterface.php b/vendor/symfony/console/Descriptor/DescriptorInterface.php index ee2f01a6115..3dccceac3fa 100644 --- a/vendor/symfony/console/Descriptor/DescriptorInterface.php +++ b/vendor/symfony/console/Descriptor/DescriptorInterface.php @@ -18,5 +18,5 @@ use RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; */ interface DescriptorInterface { - public function describe(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, object $object, array $options = []); + public function describe(OutputInterface $output, object $object, array $options = []); } diff --git a/vendor/symfony/console/Descriptor/JsonDescriptor.php b/vendor/symfony/console/Descriptor/JsonDescriptor.php index b3be62ac897..0ae426aa9a3 100644 --- a/vendor/symfony/console/Descriptor/JsonDescriptor.php +++ b/vendor/symfony/console/Descriptor/JsonDescriptor.php @@ -22,19 +22,19 @@ use RectorPrefix20220607\Symfony\Component\Console\Input\InputOption; * * @internal */ -class JsonDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Descriptor\Descriptor +class JsonDescriptor extends Descriptor { /** * {@inheritdoc} */ - protected function describeInputArgument(\RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument $argument, array $options = []) + protected function describeInputArgument(InputArgument $argument, array $options = []) { $this->writeData($this->getInputArgumentData($argument), $options); } /** * {@inheritdoc} */ - protected function describeInputOption(\RectorPrefix20220607\Symfony\Component\Console\Input\InputOption $option, array $options = []) + protected function describeInputOption(InputOption $option, array $options = []) { $this->writeData($this->getInputOptionData($option), $options); if ($option->isNegatable()) { @@ -44,24 +44,24 @@ class JsonDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Des /** * {@inheritdoc} */ - protected function describeInputDefinition(\RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition $definition, array $options = []) + protected function describeInputDefinition(InputDefinition $definition, array $options = []) { $this->writeData($this->getInputDefinitionData($definition), $options); } /** * {@inheritdoc} */ - protected function describeCommand(\RectorPrefix20220607\Symfony\Component\Console\Command\Command $command, array $options = []) + protected function describeCommand(Command $command, array $options = []) { $this->writeData($this->getCommandData($command, $options['short'] ?? \false), $options); } /** * {@inheritdoc} */ - protected function describeApplication(\RectorPrefix20220607\Symfony\Component\Console\Application $application, array $options = []) + protected function describeApplication(Application $application, array $options = []) { $describedNamespace = $options['namespace'] ?? null; - $description = new \RectorPrefix20220607\Symfony\Component\Console\Descriptor\ApplicationDescription($application, $describedNamespace, \true); + $description = new ApplicationDescription($application, $describedNamespace, \true); $commands = []; foreach ($description->getCommands() as $command) { $commands[] = $this->getCommandData($command, $options['short'] ?? \false); @@ -89,15 +89,15 @@ class JsonDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Des $flags = $options['json_encoding'] ?? 0; $this->write(\json_encode($data, $flags)); } - private function getInputArgumentData(\RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument $argument) : array + private function getInputArgumentData(InputArgument $argument) : array { return ['name' => $argument->getName(), 'is_required' => $argument->isRequired(), 'is_array' => $argument->isArray(), 'description' => \preg_replace('/\\s*[\\r\\n]\\s*/', ' ', $argument->getDescription()), 'default' => \INF === $argument->getDefault() ? 'INF' : $argument->getDefault()]; } - private function getInputOptionData(\RectorPrefix20220607\Symfony\Component\Console\Input\InputOption $option, bool $negated = \false) : array + private function getInputOptionData(InputOption $option, bool $negated = \false) : array { return $negated ? ['name' => '--no-' . $option->getName(), 'shortcut' => '', 'accept_value' => \false, 'is_value_required' => \false, 'is_multiple' => \false, 'description' => 'Negate the "--' . $option->getName() . '" option', 'default' => \false] : ['name' => '--' . $option->getName(), 'shortcut' => $option->getShortcut() ? '-' . \str_replace('|', '|-', $option->getShortcut()) : '', 'accept_value' => $option->acceptValue(), 'is_value_required' => $option->isValueRequired(), 'is_multiple' => $option->isArray(), 'description' => \preg_replace('/\\s*[\\r\\n]\\s*/', ' ', $option->getDescription()), 'default' => \INF === $option->getDefault() ? 'INF' : $option->getDefault()]; } - private function getInputDefinitionData(\RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition $definition) : array + private function getInputDefinitionData(InputDefinition $definition) : array { $inputArguments = []; foreach ($definition->getArguments() as $name => $argument) { @@ -112,7 +112,7 @@ class JsonDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Des } return ['arguments' => $inputArguments, 'options' => $inputOptions]; } - private function getCommandData(\RectorPrefix20220607\Symfony\Component\Console\Command\Command $command, bool $short = \false) : array + private function getCommandData(Command $command, bool $short = \false) : array { $data = ['name' => $command->getName(), 'description' => $command->getDescription()]; if ($short) { diff --git a/vendor/symfony/console/Descriptor/MarkdownDescriptor.php b/vendor/symfony/console/Descriptor/MarkdownDescriptor.php index 64d8a348f71..4692199f869 100644 --- a/vendor/symfony/console/Descriptor/MarkdownDescriptor.php +++ b/vendor/symfony/console/Descriptor/MarkdownDescriptor.php @@ -24,12 +24,12 @@ use RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; * * @internal */ -class MarkdownDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Descriptor\Descriptor +class MarkdownDescriptor extends Descriptor { /** * {@inheritdoc} */ - public function describe(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, object $object, array $options = []) + public function describe(OutputInterface $output, object $object, array $options = []) { $decorated = $output->isDecorated(); $output->setDecorated(\false); @@ -46,14 +46,14 @@ class MarkdownDescriptor extends \RectorPrefix20220607\Symfony\Component\Console /** * {@inheritdoc} */ - protected function describeInputArgument(\RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument $argument, array $options = []) + protected function describeInputArgument(InputArgument $argument, array $options = []) { $this->write('#### `' . ($argument->getName() ?: '') . "`\n\n" . ($argument->getDescription() ? \preg_replace('/\\s*[\\r\\n]\\s*/', "\n", $argument->getDescription()) . "\n\n" : '') . '* Is required: ' . ($argument->isRequired() ? 'yes' : 'no') . "\n" . '* Is array: ' . ($argument->isArray() ? 'yes' : 'no') . "\n" . '* Default: `' . \str_replace("\n", '', \var_export($argument->getDefault(), \true)) . '`'); } /** * {@inheritdoc} */ - protected function describeInputOption(\RectorPrefix20220607\Symfony\Component\Console\Input\InputOption $option, array $options = []) + protected function describeInputOption(InputOption $option, array $options = []) { $name = '--' . $option->getName(); if ($option->isNegatable()) { @@ -67,7 +67,7 @@ class MarkdownDescriptor extends \RectorPrefix20220607\Symfony\Component\Console /** * {@inheritdoc} */ - protected function describeInputDefinition(\RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition $definition, array $options = []) + protected function describeInputDefinition(InputDefinition $definition, array $options = []) { if ($showArguments = \count($definition->getArguments()) > 0) { $this->write('### Arguments'); @@ -94,16 +94,16 @@ class MarkdownDescriptor extends \RectorPrefix20220607\Symfony\Component\Console /** * {@inheritdoc} */ - protected function describeCommand(\RectorPrefix20220607\Symfony\Component\Console\Command\Command $command, array $options = []) + protected function describeCommand(Command $command, array $options = []) { if ($options['short'] ?? \false) { - $this->write('`' . $command->getName() . "`\n" . \str_repeat('-', \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($command->getName()) + 2) . "\n\n" . ($command->getDescription() ? $command->getDescription() . "\n\n" : '') . '### Usage' . "\n\n" . \array_reduce($command->getAliases(), function ($carry, $usage) { + $this->write('`' . $command->getName() . "`\n" . \str_repeat('-', Helper::width($command->getName()) + 2) . "\n\n" . ($command->getDescription() ? $command->getDescription() . "\n\n" : '') . '### Usage' . "\n\n" . \array_reduce($command->getAliases(), function ($carry, $usage) { return $carry . '* `' . $usage . '`' . "\n"; })); return; } $command->mergeApplicationDefinition(\false); - $this->write('`' . $command->getName() . "`\n" . \str_repeat('-', \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($command->getName()) + 2) . "\n\n" . ($command->getDescription() ? $command->getDescription() . "\n\n" : '') . '### Usage' . "\n\n" . \array_reduce(\array_merge([$command->getSynopsis()], $command->getAliases(), $command->getUsages()), function ($carry, $usage) { + $this->write('`' . $command->getName() . "`\n" . \str_repeat('-', Helper::width($command->getName()) + 2) . "\n\n" . ($command->getDescription() ? $command->getDescription() . "\n\n" : '') . '### Usage' . "\n\n" . \array_reduce(\array_merge([$command->getSynopsis()], $command->getAliases(), $command->getUsages()), function ($carry, $usage) { return $carry . '* `' . $usage . '`' . "\n"; })); if ($help = $command->getProcessedHelp()) { @@ -119,14 +119,14 @@ class MarkdownDescriptor extends \RectorPrefix20220607\Symfony\Component\Console /** * {@inheritdoc} */ - protected function describeApplication(\RectorPrefix20220607\Symfony\Component\Console\Application $application, array $options = []) + protected function describeApplication(Application $application, array $options = []) { $describedNamespace = $options['namespace'] ?? null; - $description = new \RectorPrefix20220607\Symfony\Component\Console\Descriptor\ApplicationDescription($application, $describedNamespace); + $description = new ApplicationDescription($application, $describedNamespace); $title = $this->getApplicationTitle($application); - $this->write($title . "\n" . \str_repeat('=', \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($title))); + $this->write($title . "\n" . \str_repeat('=', Helper::width($title))); foreach ($description->getNamespaces() as $namespace) { - if (\RectorPrefix20220607\Symfony\Component\Console\Descriptor\ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) { + if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) { $this->write("\n\n"); $this->write('**' . $namespace['id'] . ':**'); } @@ -142,7 +142,7 @@ class MarkdownDescriptor extends \RectorPrefix20220607\Symfony\Component\Console } } } - private function getApplicationTitle(\RectorPrefix20220607\Symfony\Component\Console\Application $application) : string + private function getApplicationTitle(Application $application) : string { if ('UNKNOWN' !== $application->getName()) { if ('UNKNOWN' !== $application->getVersion()) { diff --git a/vendor/symfony/console/Descriptor/TextDescriptor.php b/vendor/symfony/console/Descriptor/TextDescriptor.php index 9b95770220d..96e7eeed4c0 100644 --- a/vendor/symfony/console/Descriptor/TextDescriptor.php +++ b/vendor/symfony/console/Descriptor/TextDescriptor.php @@ -24,19 +24,19 @@ use RectorPrefix20220607\Symfony\Component\Console\Input\InputOption; * * @internal */ -class TextDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Descriptor\Descriptor +class TextDescriptor extends Descriptor { /** * {@inheritdoc} */ - protected function describeInputArgument(\RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument $argument, array $options = []) + protected function describeInputArgument(InputArgument $argument, array $options = []) { if (null !== $argument->getDefault() && (!\is_array($argument->getDefault()) || \count($argument->getDefault()))) { $default = \sprintf(' [default: %s]', $this->formatDefaultValue($argument->getDefault())); } else { $default = ''; } - $totalWidth = $options['total_width'] ?? \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($argument->getName()); + $totalWidth = $options['total_width'] ?? Helper::width($argument->getName()); $spacingWidth = $totalWidth - \strlen($argument->getName()); $this->writeText(\sprintf( ' %s %s%s%s', @@ -50,7 +50,7 @@ class TextDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Des /** * {@inheritdoc} */ - protected function describeInputOption(\RectorPrefix20220607\Symfony\Component\Console\Input\InputOption $option, array $options = []) + protected function describeInputOption(InputOption $option, array $options = []) { if ($option->acceptValue() && null !== $option->getDefault() && (!\is_array($option->getDefault()) || \count($option->getDefault()))) { $default = \sprintf(' [default: %s]', $this->formatDefaultValue($option->getDefault())); @@ -66,7 +66,7 @@ class TextDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Des } $totalWidth = $options['total_width'] ?? $this->calculateTotalWidthForOptions([$option]); $synopsis = \sprintf('%s%s', $option->getShortcut() ? \sprintf('-%s, ', $option->getShortcut()) : ' ', \sprintf($option->isNegatable() ? '--%1$s|--no-%1$s' : '--%1$s%2$s', $option->getName(), $value)); - $spacingWidth = $totalWidth - \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($synopsis); + $spacingWidth = $totalWidth - Helper::width($synopsis); $this->writeText(\sprintf( ' %s %s%s%s%s', $synopsis, @@ -80,11 +80,11 @@ class TextDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Des /** * {@inheritdoc} */ - protected function describeInputDefinition(\RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition $definition, array $options = []) + protected function describeInputDefinition(InputDefinition $definition, array $options = []) { $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions()); foreach ($definition->getArguments() as $argument) { - $totalWidth = \max($totalWidth, \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($argument->getName())); + $totalWidth = \max($totalWidth, Helper::width($argument->getName())); } if ($definition->getArguments()) { $this->writeText('Arguments:', $options); @@ -117,7 +117,7 @@ class TextDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Des /** * {@inheritdoc} */ - protected function describeCommand(\RectorPrefix20220607\Symfony\Component\Console\Command\Command $command, array $options = []) + protected function describeCommand(Command $command, array $options = []) { $command->mergeApplicationDefinition(\false); if ($description = $command->getDescription()) { @@ -129,7 +129,7 @@ class TextDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Des $this->writeText('Usage:', $options); foreach (\array_merge([$command->getSynopsis(\true)], $command->getAliases(), $command->getUsages()) as $usage) { $this->writeText("\n"); - $this->writeText(' ' . \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatter::escape($usage), $options); + $this->writeText(' ' . OutputFormatter::escape($usage), $options); } $this->writeText("\n"); $definition = $command->getDefinition(); @@ -150,10 +150,10 @@ class TextDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Des /** * {@inheritdoc} */ - protected function describeApplication(\RectorPrefix20220607\Symfony\Component\Console\Application $application, array $options = []) + protected function describeApplication(Application $application, array $options = []) { $describedNamespace = $options['namespace'] ?? null; - $description = new \RectorPrefix20220607\Symfony\Component\Console\Descriptor\ApplicationDescription($application, $describedNamespace); + $description = new ApplicationDescription($application, $describedNamespace); if (isset($options['raw_text']) && $options['raw_text']) { $width = $this->getColumnWidth($description->getCommands()); foreach ($description->getCommands() as $command) { @@ -166,7 +166,7 @@ class TextDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Des } $this->writeText("Usage:\n", $options); $this->writeText(" command [options] [arguments]\n\n", $options); - $this->describeInputDefinition(new \RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition($application->getDefinition()->getOptions()), $options); + $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options); $this->writeText("\n"); $this->writeText("\n"); $commands = $description->getCommands(); @@ -194,13 +194,13 @@ class TextDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Des if (!$namespace['commands']) { continue; } - if (!$describedNamespace && \RectorPrefix20220607\Symfony\Component\Console\Descriptor\ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) { + if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) { $this->writeText("\n"); $this->writeText(' ' . $namespace['id'] . '', $options); } foreach ($namespace['commands'] as $name) { $this->writeText("\n"); - $spacingWidth = $width - \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($name); + $spacingWidth = $width - Helper::width($name); $command = $commands[$name]; $commandAliases = $name === $command->getName() ? $this->getCommandAliasesText($command) : ''; $this->writeText(\sprintf(' %s%s%s', $name, \str_repeat(' ', $spacingWidth), $commandAliases . $command->getDescription()), $options); @@ -219,7 +219,7 @@ class TextDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Des /** * Formats command aliases to show them in the command description. */ - private function getCommandAliasesText(\RectorPrefix20220607\Symfony\Component\Console\Command\Command $command) : string + private function getCommandAliasesText(Command $command) : string { $text = ''; $aliases = $command->getAliases(); @@ -238,11 +238,11 @@ class TextDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Des return 'INF'; } if (\is_string($default)) { - $default = \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatter::escape($default); + $default = OutputFormatter::escape($default); } elseif (\is_array($default)) { foreach ($default as $key => $value) { if (\is_string($value)) { - $default[$key] = \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatter::escape($value); + $default[$key] = OutputFormatter::escape($value); } } } @@ -255,13 +255,13 @@ class TextDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Des { $widths = []; foreach ($commands as $command) { - if ($command instanceof \RectorPrefix20220607\Symfony\Component\Console\Command\Command) { - $widths[] = \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($command->getName()); + if ($command instanceof Command) { + $widths[] = Helper::width($command->getName()); foreach ($command->getAliases() as $alias) { - $widths[] = \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($alias); + $widths[] = Helper::width($alias); } } else { - $widths[] = \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($command); + $widths[] = Helper::width($command); } } return $widths ? \max($widths) + 2 : 0; @@ -274,12 +274,12 @@ class TextDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Des $totalWidth = 0; foreach ($options as $option) { // "-" + shortcut + ", --" + name - $nameLength = 1 + \max(\RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($option->getShortcut()), 1) + 4 + \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($option->getName()); + $nameLength = 1 + \max(Helper::width($option->getShortcut()), 1) + 4 + Helper::width($option->getName()); if ($option->isNegatable()) { - $nameLength += 6 + \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($option->getName()); + $nameLength += 6 + Helper::width($option->getName()); // |--no- + name } elseif ($option->acceptValue()) { - $valueLength = 1 + \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($option->getName()); + $valueLength = 1 + Helper::width($option->getName()); // = + value $valueLength += $option->isValueOptional() ? 2 : 0; // [ + ] diff --git a/vendor/symfony/console/Descriptor/XmlDescriptor.php b/vendor/symfony/console/Descriptor/XmlDescriptor.php index b65b2bcfd2c..d92ddc7db5b 100644 --- a/vendor/symfony/console/Descriptor/XmlDescriptor.php +++ b/vendor/symfony/console/Descriptor/XmlDescriptor.php @@ -22,9 +22,9 @@ use RectorPrefix20220607\Symfony\Component\Console\Input\InputOption; * * @internal */ -class XmlDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Descriptor\Descriptor +class XmlDescriptor extends Descriptor { - public function getInputDefinitionDocument(\RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition $definition) : \DOMDocument + public function getInputDefinitionDocument(InputDefinition $definition) : \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($definitionXML = $dom->createElement('definition')); @@ -38,7 +38,7 @@ class XmlDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Desc } return $dom; } - public function getCommandDocument(\RectorPrefix20220607\Symfony\Component\Console\Command\Command $command, bool $short = \false) : \DOMDocument + public function getCommandDocument(Command $command, bool $short = \false) : \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($commandXML = $dom->createElement('command')); @@ -64,7 +64,7 @@ class XmlDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Desc } return $dom; } - public function getApplicationDocument(\RectorPrefix20220607\Symfony\Component\Console\Application $application, string $namespace = null, bool $short = \false) : \DOMDocument + public function getApplicationDocument(Application $application, string $namespace = null, bool $short = \false) : \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($rootXml = $dom->createElement('symfony')); @@ -75,7 +75,7 @@ class XmlDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Desc } } $rootXml->appendChild($commandsXML = $dom->createElement('commands')); - $description = new \RectorPrefix20220607\Symfony\Component\Console\Descriptor\ApplicationDescription($application, $namespace, \true); + $description = new ApplicationDescription($application, $namespace, \true); if ($namespace) { $commandsXML->setAttribute('namespace', $namespace); } @@ -98,35 +98,35 @@ class XmlDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Desc /** * {@inheritdoc} */ - protected function describeInputArgument(\RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument $argument, array $options = []) + protected function describeInputArgument(InputArgument $argument, array $options = []) { $this->writeDocument($this->getInputArgumentDocument($argument)); } /** * {@inheritdoc} */ - protected function describeInputOption(\RectorPrefix20220607\Symfony\Component\Console\Input\InputOption $option, array $options = []) + protected function describeInputOption(InputOption $option, array $options = []) { $this->writeDocument($this->getInputOptionDocument($option)); } /** * {@inheritdoc} */ - protected function describeInputDefinition(\RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition $definition, array $options = []) + protected function describeInputDefinition(InputDefinition $definition, array $options = []) { $this->writeDocument($this->getInputDefinitionDocument($definition)); } /** * {@inheritdoc} */ - protected function describeCommand(\RectorPrefix20220607\Symfony\Component\Console\Command\Command $command, array $options = []) + protected function describeCommand(Command $command, array $options = []) { $this->writeDocument($this->getCommandDocument($command, $options['short'] ?? \false)); } /** * {@inheritdoc} */ - protected function describeApplication(\RectorPrefix20220607\Symfony\Component\Console\Application $application, array $options = []) + protected function describeApplication(Application $application, array $options = []) { $this->writeDocument($this->getApplicationDocument($application, $options['namespace'] ?? null, $options['short'] ?? \false)); } @@ -147,7 +147,7 @@ class XmlDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Desc $dom->formatOutput = \true; $this->write($dom->saveXML()); } - private function getInputArgumentDocument(\RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument $argument) : \DOMDocument + private function getInputArgumentDocument(InputArgument $argument) : \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($objectXML = $dom->createElement('argument')); @@ -164,7 +164,7 @@ class XmlDescriptor extends \RectorPrefix20220607\Symfony\Component\Console\Desc } return $dom; } - private function getInputOptionDocument(\RectorPrefix20220607\Symfony\Component\Console\Input\InputOption $option) : \DOMDocument + private function getInputOptionDocument(InputOption $option) : \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($objectXML = $dom->createElement('option')); diff --git a/vendor/symfony/console/Exception/CommandNotFoundException.php b/vendor/symfony/console/Exception/CommandNotFoundException.php index f5a5a87e416..65bc8d9ad1a 100644 --- a/vendor/symfony/console/Exception/CommandNotFoundException.php +++ b/vendor/symfony/console/Exception/CommandNotFoundException.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Symfony\Component\Console\Exception; * * @author Jérôme Tamarelle */ -class CommandNotFoundException extends \InvalidArgumentException implements \RectorPrefix20220607\Symfony\Component\Console\Exception\ExceptionInterface +class CommandNotFoundException extends \InvalidArgumentException implements ExceptionInterface { /** * @var mixed[] diff --git a/vendor/symfony/console/Exception/InvalidArgumentException.php b/vendor/symfony/console/Exception/InvalidArgumentException.php index 41f842cb2e5..21eb820b1b8 100644 --- a/vendor/symfony/console/Exception/InvalidArgumentException.php +++ b/vendor/symfony/console/Exception/InvalidArgumentException.php @@ -13,6 +13,6 @@ namespace RectorPrefix20220607\Symfony\Component\Console\Exception; /** * @author Jérôme Tamarelle */ -class InvalidArgumentException extends \InvalidArgumentException implements \RectorPrefix20220607\Symfony\Component\Console\Exception\ExceptionInterface +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { } diff --git a/vendor/symfony/console/Exception/InvalidOptionException.php b/vendor/symfony/console/Exception/InvalidOptionException.php index 9bc8564d48a..65b1a610f83 100644 --- a/vendor/symfony/console/Exception/InvalidOptionException.php +++ b/vendor/symfony/console/Exception/InvalidOptionException.php @@ -15,6 +15,6 @@ namespace RectorPrefix20220607\Symfony\Component\Console\Exception; * * @author Jérôme Tamarelle */ -class InvalidOptionException extends \InvalidArgumentException implements \RectorPrefix20220607\Symfony\Component\Console\Exception\ExceptionInterface +class InvalidOptionException extends \InvalidArgumentException implements ExceptionInterface { } diff --git a/vendor/symfony/console/Exception/LogicException.php b/vendor/symfony/console/Exception/LogicException.php index fe073e92863..b9d7055443f 100644 --- a/vendor/symfony/console/Exception/LogicException.php +++ b/vendor/symfony/console/Exception/LogicException.php @@ -13,6 +13,6 @@ namespace RectorPrefix20220607\Symfony\Component\Console\Exception; /** * @author Jérôme Tamarelle */ -class LogicException extends \LogicException implements \RectorPrefix20220607\Symfony\Component\Console\Exception\ExceptionInterface +class LogicException extends \LogicException implements ExceptionInterface { } diff --git a/vendor/symfony/console/Exception/MissingInputException.php b/vendor/symfony/console/Exception/MissingInputException.php index 810b0568451..ba3ba7dd348 100644 --- a/vendor/symfony/console/Exception/MissingInputException.php +++ b/vendor/symfony/console/Exception/MissingInputException.php @@ -15,6 +15,6 @@ namespace RectorPrefix20220607\Symfony\Component\Console\Exception; * * @author Gabriel Ostrolucký */ -class MissingInputException extends \RectorPrefix20220607\Symfony\Component\Console\Exception\RuntimeException implements \RectorPrefix20220607\Symfony\Component\Console\Exception\ExceptionInterface +class MissingInputException extends RuntimeException implements ExceptionInterface { } diff --git a/vendor/symfony/console/Exception/NamespaceNotFoundException.php b/vendor/symfony/console/Exception/NamespaceNotFoundException.php index 34cabb77a83..ce9cc28c46e 100644 --- a/vendor/symfony/console/Exception/NamespaceNotFoundException.php +++ b/vendor/symfony/console/Exception/NamespaceNotFoundException.php @@ -15,6 +15,6 @@ namespace RectorPrefix20220607\Symfony\Component\Console\Exception; * * @author Pierre du Plessis */ -class NamespaceNotFoundException extends \RectorPrefix20220607\Symfony\Component\Console\Exception\CommandNotFoundException +class NamespaceNotFoundException extends CommandNotFoundException { } diff --git a/vendor/symfony/console/Exception/RuntimeException.php b/vendor/symfony/console/Exception/RuntimeException.php index 30b58c48391..c00fb37adad 100644 --- a/vendor/symfony/console/Exception/RuntimeException.php +++ b/vendor/symfony/console/Exception/RuntimeException.php @@ -13,6 +13,6 @@ namespace RectorPrefix20220607\Symfony\Component\Console\Exception; /** * @author Jérôme Tamarelle */ -class RuntimeException extends \RuntimeException implements \RectorPrefix20220607\Symfony\Component\Console\Exception\ExceptionInterface +class RuntimeException extends \RuntimeException implements ExceptionInterface { } diff --git a/vendor/symfony/console/Formatter/NullOutputFormatter.php b/vendor/symfony/console/Formatter/NullOutputFormatter.php index 8da2e47c342..1a105dd3744 100644 --- a/vendor/symfony/console/Formatter/NullOutputFormatter.php +++ b/vendor/symfony/console/Formatter/NullOutputFormatter.php @@ -13,7 +13,7 @@ namespace RectorPrefix20220607\Symfony\Component\Console\Formatter; /** * @author Tien Xuan Vo */ -final class NullOutputFormatter implements \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInterface +final class NullOutputFormatter implements OutputFormatterInterface { /** * @var \Symfony\Component\Console\Formatter\NullOutputFormatterStyle @@ -29,10 +29,10 @@ final class NullOutputFormatter implements \RectorPrefix20220607\Symfony\Compone /** * {@inheritdoc} */ - public function getStyle(string $name) : \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyleInterface + public function getStyle(string $name) : OutputFormatterStyleInterface { // to comply with the interface we must return a OutputFormatterStyleInterface - return $this->style = $this->style ?? new \RectorPrefix20220607\Symfony\Component\Console\Formatter\NullOutputFormatterStyle(); + return $this->style = $this->style ?? new NullOutputFormatterStyle(); } /** * {@inheritdoc} @@ -58,7 +58,7 @@ final class NullOutputFormatter implements \RectorPrefix20220607\Symfony\Compone /** * {@inheritdoc} */ - public function setStyle(string $name, \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyleInterface $style) : void + public function setStyle(string $name, OutputFormatterStyleInterface $style) : void { // do nothing } diff --git a/vendor/symfony/console/Formatter/NullOutputFormatterStyle.php b/vendor/symfony/console/Formatter/NullOutputFormatterStyle.php index 9f734f43b7e..7174dc78276 100644 --- a/vendor/symfony/console/Formatter/NullOutputFormatterStyle.php +++ b/vendor/symfony/console/Formatter/NullOutputFormatterStyle.php @@ -13,7 +13,7 @@ namespace RectorPrefix20220607\Symfony\Component\Console\Formatter; /** * @author Tien Xuan Vo */ -final class NullOutputFormatterStyle implements \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyleInterface +final class NullOutputFormatterStyle implements OutputFormatterStyleInterface { /** * {@inheritdoc} diff --git a/vendor/symfony/console/Formatter/OutputFormatter.php b/vendor/symfony/console/Formatter/OutputFormatter.php index f79a5c5e1a4..2ad0d73768c 100644 --- a/vendor/symfony/console/Formatter/OutputFormatter.php +++ b/vendor/symfony/console/Formatter/OutputFormatter.php @@ -17,7 +17,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentExce * @author Konstantin Kudryashov * @author Roland Franssen */ -class OutputFormatter implements \RectorPrefix20220607\Symfony\Component\Console\Formatter\WrappableOutputFormatterInterface +class OutputFormatter implements WrappableOutputFormatterInterface { /** * @var bool @@ -56,8 +56,8 @@ class OutputFormatter implements \RectorPrefix20220607\Symfony\Component\Console if (\substr_compare($text, '\\', -\strlen('\\')) === 0) { $len = \strlen($text); $text = \rtrim($text, '\\'); - $text = \str_replace("\0", '', $text); - $text .= \str_repeat("\0", $len - \strlen($text)); + $text = \str_replace("\x00", '', $text); + $text .= \str_repeat("\x00", $len - \strlen($text)); } return $text; } @@ -69,14 +69,14 @@ class OutputFormatter implements \RectorPrefix20220607\Symfony\Component\Console public function __construct(bool $decorated = \false, array $styles = []) { $this->decorated = $decorated; - $this->setStyle('error', new \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyle('white', 'red')); - $this->setStyle('info', new \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyle('green')); - $this->setStyle('comment', new \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyle('yellow')); - $this->setStyle('question', new \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyle('black', 'cyan')); + $this->setStyle('error', new OutputFormatterStyle('white', 'red')); + $this->setStyle('info', new OutputFormatterStyle('green')); + $this->setStyle('comment', new OutputFormatterStyle('yellow')); + $this->setStyle('question', new OutputFormatterStyle('black', 'cyan')); foreach ($styles as $name => $style) { $this->setStyle($name, $style); } - $this->styleStack = new \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyleStack(); + $this->styleStack = new OutputFormatterStyleStack(); } /** * {@inheritdoc} @@ -95,7 +95,7 @@ class OutputFormatter implements \RectorPrefix20220607\Symfony\Component\Console /** * {@inheritdoc} */ - public function setStyle(string $name, \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyleInterface $style) + public function setStyle(string $name, OutputFormatterStyleInterface $style) { $this->styles[\strtolower($name)] = $style; } @@ -109,10 +109,10 @@ class OutputFormatter implements \RectorPrefix20220607\Symfony\Component\Console /** * {@inheritdoc} */ - public function getStyle(string $name) : \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyleInterface + public function getStyle(string $name) : OutputFormatterStyleInterface { if (!$this->hasStyle($name)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('Undefined style: "%s".', $name)); + throw new InvalidArgumentException(\sprintf('Undefined style: "%s".', $name)); } return $this->styles[\strtolower($name)]; } @@ -164,16 +164,16 @@ class OutputFormatter implements \RectorPrefix20220607\Symfony\Component\Console } } $output .= $this->applyCurrentStyle(\substr($message, $offset), $output, $width, $currentLineLength); - return \strtr($output, ["\0" => '\\', '\\<' => '<', '\\>' => '>']); + return \strtr($output, ["\x00" => '\\', '\\<' => '<', '\\>' => '>']); } - public function getStyleStack() : \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyleStack + public function getStyleStack() : OutputFormatterStyleStack { return $this->styleStack; } /** * Tries to create new style instance from string. */ - private function createStyleFromString(string $string) : ?\RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyleInterface + private function createStyleFromString(string $string) : ?OutputFormatterStyleInterface { if (isset($this->styles[$string])) { return $this->styles[$string]; @@ -181,7 +181,7 @@ class OutputFormatter implements \RectorPrefix20220607\Symfony\Component\Console if (!\preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, \PREG_SET_ORDER)) { return null; } - $style = new \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyle(); + $style = new OutputFormatterStyle(); foreach ($matches as $match) { \array_shift($match); $match[0] = \strtolower($match[0]); diff --git a/vendor/symfony/console/Formatter/OutputFormatterInterface.php b/vendor/symfony/console/Formatter/OutputFormatterInterface.php index a7049a065d5..2d0dd1da578 100644 --- a/vendor/symfony/console/Formatter/OutputFormatterInterface.php +++ b/vendor/symfony/console/Formatter/OutputFormatterInterface.php @@ -28,7 +28,7 @@ interface OutputFormatterInterface /** * Sets a new style. */ - public function setStyle(string $name, \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyleInterface $style); + public function setStyle(string $name, OutputFormatterStyleInterface $style); /** * Checks if output formatter has style with specified name. */ @@ -38,7 +38,7 @@ interface OutputFormatterInterface * * @throws \InvalidArgumentException When style isn't defined */ - public function getStyle(string $name) : \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyleInterface; + public function getStyle(string $name) : OutputFormatterStyleInterface; /** * Formats a message according to the given styles. */ diff --git a/vendor/symfony/console/Formatter/OutputFormatterStyle.php b/vendor/symfony/console/Formatter/OutputFormatterStyle.php index 743bedcdda4..39ca5257406 100644 --- a/vendor/symfony/console/Formatter/OutputFormatterStyle.php +++ b/vendor/symfony/console/Formatter/OutputFormatterStyle.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Color; * * @author Konstantin Kudryashov */ -class OutputFormatterStyle implements \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyleInterface +class OutputFormatterStyle implements OutputFormatterStyleInterface { /** * @var \Symfony\Component\Console\Color @@ -50,21 +50,21 @@ class OutputFormatterStyle implements \RectorPrefix20220607\Symfony\Component\Co */ public function __construct(string $foreground = null, string $background = null, array $options = []) { - $this->color = new \RectorPrefix20220607\Symfony\Component\Console\Color($this->foreground = $foreground ?: '', $this->background = $background ?: '', $this->options = $options); + $this->color = new Color($this->foreground = $foreground ?: '', $this->background = $background ?: '', $this->options = $options); } /** * {@inheritdoc} */ public function setForeground(string $color = null) { - $this->color = new \RectorPrefix20220607\Symfony\Component\Console\Color($this->foreground = $color ?: '', $this->background, $this->options); + $this->color = new Color($this->foreground = $color ?: '', $this->background, $this->options); } /** * {@inheritdoc} */ public function setBackground(string $color = null) { - $this->color = new \RectorPrefix20220607\Symfony\Component\Console\Color($this->foreground, $this->background = $color ?: '', $this->options); + $this->color = new Color($this->foreground, $this->background = $color ?: '', $this->options); } public function setHref(string $url) : void { @@ -76,7 +76,7 @@ class OutputFormatterStyle implements \RectorPrefix20220607\Symfony\Component\Co public function setOption(string $option) { $this->options[] = $option; - $this->color = new \RectorPrefix20220607\Symfony\Component\Console\Color($this->foreground, $this->background, $this->options); + $this->color = new Color($this->foreground, $this->background, $this->options); } /** * {@inheritdoc} @@ -87,14 +87,14 @@ class OutputFormatterStyle implements \RectorPrefix20220607\Symfony\Component\Co if (\false !== $pos) { unset($this->options[$pos]); } - $this->color = new \RectorPrefix20220607\Symfony\Component\Console\Color($this->foreground, $this->background, $this->options); + $this->color = new Color($this->foreground, $this->background, $this->options); } /** * {@inheritdoc} */ public function setOptions(array $options) { - $this->color = new \RectorPrefix20220607\Symfony\Component\Console\Color($this->foreground, $this->background, $this->options = $options); + $this->color = new Color($this->foreground, $this->background, $this->options = $options); } /** * {@inheritdoc} @@ -103,7 +103,7 @@ class OutputFormatterStyle implements \RectorPrefix20220607\Symfony\Component\Co { $this->handlesHrefGracefully = $this->handlesHrefGracefully ?? 'JetBrains-JediTerm' !== \getenv('TERMINAL_EMULATOR') && (!\getenv('KONSOLE_VERSION') || (int) \getenv('KONSOLE_VERSION') > 201100); if (null !== $this->href && $this->handlesHrefGracefully) { - $text = "\33]8;;{$this->href}\33\\{$text}\33]8;;\33\\"; + $text = "\x1b]8;;{$this->href}\x1b\\{$text}\x1b]8;;\x1b\\"; } return $this->color->apply($text); } diff --git a/vendor/symfony/console/Formatter/OutputFormatterStyleStack.php b/vendor/symfony/console/Formatter/OutputFormatterStyleStack.php index cb8f5c587c9..dc425de84f6 100644 --- a/vendor/symfony/console/Formatter/OutputFormatterStyleStack.php +++ b/vendor/symfony/console/Formatter/OutputFormatterStyleStack.php @@ -15,7 +15,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\ResetInterface; /** * @author Jean-François Simon */ -class OutputFormatterStyleStack implements \RectorPrefix20220607\Symfony\Contracts\Service\ResetInterface +class OutputFormatterStyleStack implements ResetInterface { /** * @var OutputFormatterStyleInterface[] @@ -25,9 +25,9 @@ class OutputFormatterStyleStack implements \RectorPrefix20220607\Symfony\Contrac * @var \Symfony\Component\Console\Formatter\OutputFormatterStyleInterface */ private $emptyStyle; - public function __construct(\RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyleInterface $emptyStyle = null) + public function __construct(OutputFormatterStyleInterface $emptyStyle = null) { - $this->emptyStyle = $emptyStyle ?? new \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyle(); + $this->emptyStyle = $emptyStyle ?? new OutputFormatterStyle(); $this->reset(); } /** @@ -40,7 +40,7 @@ class OutputFormatterStyleStack implements \RectorPrefix20220607\Symfony\Contrac /** * Pushes a style in the stack. */ - public function push(\RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyleInterface $style) + public function push(OutputFormatterStyleInterface $style) { $this->styles[] = $style; } @@ -49,7 +49,7 @@ class OutputFormatterStyleStack implements \RectorPrefix20220607\Symfony\Contrac * * @throws InvalidArgumentException When style tags incorrectly nested */ - public function pop(\RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyleInterface $style = null) : \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyleInterface + public function pop(OutputFormatterStyleInterface $style = null) : OutputFormatterStyleInterface { if (empty($this->styles)) { return $this->emptyStyle; @@ -63,12 +63,12 @@ class OutputFormatterStyleStack implements \RectorPrefix20220607\Symfony\Contrac return $stackedStyle; } } - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException('Incorrectly nested style tag found.'); + throw new InvalidArgumentException('Incorrectly nested style tag found.'); } /** * Computes current style with stacks top codes. */ - public function getCurrent() : \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyle + public function getCurrent() : OutputFormatterStyle { if (empty($this->styles)) { return $this->emptyStyle; @@ -78,12 +78,12 @@ class OutputFormatterStyleStack implements \RectorPrefix20220607\Symfony\Contrac /** * @return $this */ - public function setEmptyStyle(\RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyleInterface $emptyStyle) + public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle) { $this->emptyStyle = $emptyStyle; return $this; } - public function getEmptyStyle() : \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyleInterface + public function getEmptyStyle() : OutputFormatterStyleInterface { return $this->emptyStyle; } diff --git a/vendor/symfony/console/Formatter/WrappableOutputFormatterInterface.php b/vendor/symfony/console/Formatter/WrappableOutputFormatterInterface.php index c8b606c13f6..2215ac154e0 100644 --- a/vendor/symfony/console/Formatter/WrappableOutputFormatterInterface.php +++ b/vendor/symfony/console/Formatter/WrappableOutputFormatterInterface.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Symfony\Component\Console\Formatter; * * @author Roland Franssen */ -interface WrappableOutputFormatterInterface extends \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInterface +interface WrappableOutputFormatterInterface extends OutputFormatterInterface { /** * Formats a message according to the given styles, wrapping at `$width` (0 means no wrapping). diff --git a/vendor/symfony/console/Helper/DebugFormatterHelper.php b/vendor/symfony/console/Helper/DebugFormatterHelper.php index 42e64b45d9c..8f496a40c41 100644 --- a/vendor/symfony/console/Helper/DebugFormatterHelper.php +++ b/vendor/symfony/console/Helper/DebugFormatterHelper.php @@ -17,7 +17,7 @@ namespace RectorPrefix20220607\Symfony\Component\Console\Helper; * * @author Fabien Potencier */ -class DebugFormatterHelper extends \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper +class DebugFormatterHelper extends Helper { private const COLORS = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default']; /** diff --git a/vendor/symfony/console/Helper/DescriptorHelper.php b/vendor/symfony/console/Helper/DescriptorHelper.php index 1f5ef716345..90d819ee0cb 100644 --- a/vendor/symfony/console/Helper/DescriptorHelper.php +++ b/vendor/symfony/console/Helper/DescriptorHelper.php @@ -22,7 +22,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; * * @author Jean-François Simon */ -class DescriptorHelper extends \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper +class DescriptorHelper extends Helper { /** * @var DescriptorInterface[] @@ -30,7 +30,7 @@ class DescriptorHelper extends \RectorPrefix20220607\Symfony\Component\Console\H private $descriptors = []; public function __construct() { - $this->register('txt', new \RectorPrefix20220607\Symfony\Component\Console\Descriptor\TextDescriptor())->register('xml', new \RectorPrefix20220607\Symfony\Component\Console\Descriptor\XmlDescriptor())->register('json', new \RectorPrefix20220607\Symfony\Component\Console\Descriptor\JsonDescriptor())->register('md', new \RectorPrefix20220607\Symfony\Component\Console\Descriptor\MarkdownDescriptor()); + $this->register('txt', new TextDescriptor())->register('xml', new XmlDescriptor())->register('json', new JsonDescriptor())->register('md', new MarkdownDescriptor()); } /** * Describes an object if supported. @@ -41,11 +41,11 @@ class DescriptorHelper extends \RectorPrefix20220607\Symfony\Component\Console\H * * @throws InvalidArgumentException when the given format is not supported */ - public function describe(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, ?object $object, array $options = []) + public function describe(OutputInterface $output, ?object $object, array $options = []) { $options = \array_merge(['raw_text' => \false, 'format' => 'txt'], $options); if (!isset($this->descriptors[$options['format']])) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('Unsupported format "%s".', $options['format'])); + throw new InvalidArgumentException(\sprintf('Unsupported format "%s".', $options['format'])); } $descriptor = $this->descriptors[$options['format']]; $descriptor->describe($output, $object, $options); @@ -55,7 +55,7 @@ class DescriptorHelper extends \RectorPrefix20220607\Symfony\Component\Console\H * * @return $this */ - public function register(string $format, \RectorPrefix20220607\Symfony\Component\Console\Descriptor\DescriptorInterface $descriptor) + public function register(string $format, DescriptorInterface $descriptor) { $this->descriptors[$format] = $descriptor; return $this; diff --git a/vendor/symfony/console/Helper/Dumper.php b/vendor/symfony/console/Helper/Dumper.php index 2c72acbbb3b..d0e15c4482f 100644 --- a/vendor/symfony/console/Helper/Dumper.php +++ b/vendor/symfony/console/Helper/Dumper.php @@ -35,16 +35,16 @@ final class Dumper * @var \Closure */ private $handler; - public function __construct(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, \RectorPrefix20220607\Symfony\Component\VarDumper\Dumper\CliDumper $dumper = null, \RectorPrefix20220607\Symfony\Component\VarDumper\Cloner\ClonerInterface $cloner = null) + public function __construct(OutputInterface $output, CliDumper $dumper = null, ClonerInterface $cloner = null) { $this->output = $output; $this->dumper = $dumper; $this->cloner = $cloner; - if (\class_exists(\RectorPrefix20220607\Symfony\Component\VarDumper\Dumper\CliDumper::class)) { + if (\class_exists(CliDumper::class)) { $this->handler = function ($var) : string { - $dumper = $this->dumper = $this->dumper ?? new \RectorPrefix20220607\Symfony\Component\VarDumper\Dumper\CliDumper(null, null, \RectorPrefix20220607\Symfony\Component\VarDumper\Dumper\CliDumper::DUMP_LIGHT_ARRAY | \RectorPrefix20220607\Symfony\Component\VarDumper\Dumper\CliDumper::DUMP_COMMA_SEPARATOR); + $dumper = $this->dumper = $this->dumper ?? new CliDumper(null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR); $dumper->setColors($this->output->isDecorated()); - return \rtrim($dumper->dump(($this->cloner = $this->cloner ?? new \RectorPrefix20220607\Symfony\Component\VarDumper\Cloner\VarCloner())->cloneVar($var)->withRefHandles(\false), \true)); + return \rtrim($dumper->dump(($this->cloner = $this->cloner ?? new VarCloner())->cloneVar($var)->withRefHandles(\false), \true)); }; } else { $this->handler = function ($var) : string { diff --git a/vendor/symfony/console/Helper/FormatterHelper.php b/vendor/symfony/console/Helper/FormatterHelper.php index f16943d3dd6..8e23a37ee02 100644 --- a/vendor/symfony/console/Helper/FormatterHelper.php +++ b/vendor/symfony/console/Helper/FormatterHelper.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatter; * * @author Fabien Potencier */ -class FormatterHelper extends \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper +class FormatterHelper extends Helper { /** * Formats a message within a section. @@ -37,7 +37,7 @@ class FormatterHelper extends \RectorPrefix20220607\Symfony\Component\Console\He $len = 0; $lines = []; foreach ($messages as $message) { - $message = \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatter::escape($message); + $message = OutputFormatter::escape($message); $lines[] = \sprintf($large ? ' %s ' : ' %s ', $message); $len = \max(self::width($message) + ($large ? 4 : 2), $len); } diff --git a/vendor/symfony/console/Helper/Helper.php b/vendor/symfony/console/Helper/Helper.php index 24598d08b1d..aa7d2a12198 100644 --- a/vendor/symfony/console/Helper/Helper.php +++ b/vendor/symfony/console/Helper/Helper.php @@ -17,20 +17,20 @@ use RectorPrefix20220607\Symfony\Component\String\UnicodeString; * * @author Fabien Potencier */ -abstract class Helper implements \RectorPrefix20220607\Symfony\Component\Console\Helper\HelperInterface +abstract class Helper implements HelperInterface { protected $helperSet = null; /** * {@inheritdoc} */ - public function setHelperSet(\RectorPrefix20220607\Symfony\Component\Console\Helper\HelperSet $helperSet = null) + public function setHelperSet(HelperSet $helperSet = null) { $this->helperSet = $helperSet; } /** * {@inheritdoc} */ - public function getHelperSet() : ?\RectorPrefix20220607\Symfony\Component\Console\Helper\HelperSet + public function getHelperSet() : ?HelperSet { return $this->helperSet; } @@ -42,7 +42,7 @@ abstract class Helper implements \RectorPrefix20220607\Symfony\Component\Console { $string = $string ?? ''; if (\preg_match('//u', $string)) { - return (new \RectorPrefix20220607\Symfony\Component\String\UnicodeString($string))->width(\false); + return (new UnicodeString($string))->width(\false); } if (\false === ($encoding = \mb_detect_encoding($string, null, \true))) { return \strlen($string); @@ -57,7 +57,7 @@ abstract class Helper implements \RectorPrefix20220607\Symfony\Component\Console { $string = $string ?? ''; if (\preg_match('//u', $string)) { - return (new \RectorPrefix20220607\Symfony\Component\String\UnicodeString($string))->length(); + return (new UnicodeString($string))->length(); } if (\false === ($encoding = \mb_detect_encoding($string, null, \true))) { return \strlen($string); @@ -105,14 +105,14 @@ abstract class Helper implements \RectorPrefix20220607\Symfony\Component\Console } return \sprintf('%d B', $memory); } - public static function removeDecoration(\RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter, ?string $string) + public static function removeDecoration(OutputFormatterInterface $formatter, ?string $string) { $isDecorated = $formatter->isDecorated(); $formatter->setDecorated(\false); // remove <...> formatting $string = $formatter->format($string ?? ''); // remove already formatted characters - $string = \preg_replace("/\33\\[[^m]*m/", '', $string ?? ''); + $string = \preg_replace("/\x1b\\[[^m]*m/", '', $string ?? ''); $formatter->setDecorated($isDecorated); return $string; } diff --git a/vendor/symfony/console/Helper/HelperInterface.php b/vendor/symfony/console/Helper/HelperInterface.php index 68141cea6ee..47531d89459 100644 --- a/vendor/symfony/console/Helper/HelperInterface.php +++ b/vendor/symfony/console/Helper/HelperInterface.php @@ -20,11 +20,11 @@ interface HelperInterface /** * Sets the helper set associated with this helper. */ - public function setHelperSet(\RectorPrefix20220607\Symfony\Component\Console\Helper\HelperSet $helperSet = null); + public function setHelperSet(HelperSet $helperSet = null); /** * Gets the helper set associated with this helper. */ - public function getHelperSet() : ?\RectorPrefix20220607\Symfony\Component\Console\Helper\HelperSet; + public function getHelperSet() : ?HelperSet; /** * Returns the canonical name of this helper. * diff --git a/vendor/symfony/console/Helper/HelperSet.php b/vendor/symfony/console/Helper/HelperSet.php index bf27c155371..eac419088e7 100644 --- a/vendor/symfony/console/Helper/HelperSet.php +++ b/vendor/symfony/console/Helper/HelperSet.php @@ -31,7 +31,7 @@ class HelperSet implements \IteratorAggregate $this->set($helper, \is_int($alias) ? null : $alias); } } - public function set(\RectorPrefix20220607\Symfony\Component\Console\Helper\HelperInterface $helper, string $alias = null) + public function set(HelperInterface $helper, string $alias = null) { $this->helpers[$helper->getName()] = $helper; if (null !== $alias) { @@ -51,10 +51,10 @@ class HelperSet implements \IteratorAggregate * * @throws InvalidArgumentException if the helper is not defined */ - public function get(string $name) : \RectorPrefix20220607\Symfony\Component\Console\Helper\HelperInterface + public function get(string $name) : HelperInterface { if (!$this->has($name)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('The helper "%s" is not defined.', $name)); + throw new InvalidArgumentException(\sprintf('The helper "%s" is not defined.', $name)); } return $this->helpers[$name]; } diff --git a/vendor/symfony/console/Helper/InputAwareHelper.php b/vendor/symfony/console/Helper/InputAwareHelper.php index da996bd0348..c499d3f226c 100644 --- a/vendor/symfony/console/Helper/InputAwareHelper.php +++ b/vendor/symfony/console/Helper/InputAwareHelper.php @@ -17,13 +17,13 @@ use RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface; * * @author Wouter J */ -abstract class InputAwareHelper extends \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper implements \RectorPrefix20220607\Symfony\Component\Console\Input\InputAwareInterface +abstract class InputAwareHelper extends Helper implements InputAwareInterface { protected $input; /** * {@inheritdoc} */ - public function setInput(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input) + public function setInput(InputInterface $input) { $this->input = $input; } diff --git a/vendor/symfony/console/Helper/ProcessHelper.php b/vendor/symfony/console/Helper/ProcessHelper.php index 4098c0be908..c9010feb10d 100644 --- a/vendor/symfony/console/Helper/ProcessHelper.php +++ b/vendor/symfony/console/Helper/ProcessHelper.php @@ -21,7 +21,7 @@ use RectorPrefix20220607\Symfony\Component\Process\Process; * * @final */ -class ProcessHelper extends \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper +class ProcessHelper extends Helper { /** * Runs an external process. @@ -30,22 +30,22 @@ class ProcessHelper extends \RectorPrefix20220607\Symfony\Component\Console\Help * @param callable|null $callback A PHP callback to run whenever there is some * output available on STDOUT or STDERR */ - public function run(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, $cmd, string $error = null, callable $callback = null, int $verbosity = \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_VERY_VERBOSE) : \RectorPrefix20220607\Symfony\Component\Process\Process + public function run(OutputInterface $output, $cmd, string $error = null, callable $callback = null, int $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE) : Process { - if (!\class_exists(\RectorPrefix20220607\Symfony\Component\Process\Process::class)) { + if (!\class_exists(Process::class)) { throw new \LogicException('The ProcessHelper cannot be run as the Process component is not installed. Try running "compose require symfony/process".'); } - if ($output instanceof \RectorPrefix20220607\Symfony\Component\Console\Output\ConsoleOutputInterface) { + if ($output instanceof ConsoleOutputInterface) { $output = $output->getErrorOutput(); } $formatter = $this->getHelperSet()->get('debug_formatter'); - if ($cmd instanceof \RectorPrefix20220607\Symfony\Component\Process\Process) { + if ($cmd instanceof Process) { $cmd = [$cmd]; } if (\is_string($cmd[0] ?? null)) { - $process = new \RectorPrefix20220607\Symfony\Component\Process\Process($cmd); + $process = new Process($cmd); $cmd = []; - } elseif (($cmd[0] ?? null) instanceof \RectorPrefix20220607\Symfony\Component\Process\Process) { + } elseif (($cmd[0] ?? null) instanceof Process) { $process = $cmd[0]; unset($cmd[0]); } else { @@ -81,25 +81,25 @@ class ProcessHelper extends \RectorPrefix20220607\Symfony\Component\Console\Help * * @see run() */ - public function mustRun(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, $cmd, string $error = null, callable $callback = null) : \RectorPrefix20220607\Symfony\Component\Process\Process + public function mustRun(OutputInterface $output, $cmd, string $error = null, callable $callback = null) : Process { $process = $this->run($output, $cmd, $error, $callback); if (!$process->isSuccessful()) { - throw new \RectorPrefix20220607\Symfony\Component\Process\Exception\ProcessFailedException($process); + throw new ProcessFailedException($process); } return $process; } /** * Wraps a Process callback to add debugging output. */ - public function wrapCallback(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, \RectorPrefix20220607\Symfony\Component\Process\Process $process, callable $callback = null) : callable + public function wrapCallback(OutputInterface $output, Process $process, callable $callback = null) : callable { - if ($output instanceof \RectorPrefix20220607\Symfony\Component\Console\Output\ConsoleOutputInterface) { + if ($output instanceof ConsoleOutputInterface) { $output = $output->getErrorOutput(); } $formatter = $this->getHelperSet()->get('debug_formatter'); return function ($type, $buffer) use($output, $process, $callback, $formatter) { - $output->write($formatter->progress(\spl_object_hash($process), $this->escapeString($buffer), \RectorPrefix20220607\Symfony\Component\Process\Process::ERR === $type)); + $output->write($formatter->progress(\spl_object_hash($process), $this->escapeString($buffer), Process::ERR === $type)); if (null !== $callback) { $callback($type, $buffer); } diff --git a/vendor/symfony/console/Helper/ProgressBar.php b/vendor/symfony/console/Helper/ProgressBar.php index 4325cde1d27..7555fbebd40 100644 --- a/vendor/symfony/console/Helper/ProgressBar.php +++ b/vendor/symfony/console/Helper/ProgressBar.php @@ -135,14 +135,14 @@ final class ProgressBar /** * @param int $max Maximum steps (0 if unknown) */ - public function __construct(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, int $max = 0, float $minSecondsBetweenRedraws = 1 / 25) + public function __construct(OutputInterface $output, int $max = 0, float $minSecondsBetweenRedraws = 1 / 25) { - if ($output instanceof \RectorPrefix20220607\Symfony\Component\Console\Output\ConsoleOutputInterface) { + if ($output instanceof ConsoleOutputInterface) { $output = $output->getErrorOutput(); } $this->output = $output; $this->setMaxSteps($max); - $this->terminal = new \RectorPrefix20220607\Symfony\Component\Console\Terminal(); + $this->terminal = new Terminal(); if (0 < $minSecondsBetweenRedraws) { $this->redrawFreq = null; $this->minSecondsBetweenRedraws = $minSecondsBetweenRedraws; @@ -154,7 +154,7 @@ final class ProgressBar $this->redrawFreq = null; } $this->startTime = \time(); - $this->cursor = new \RectorPrefix20220607\Symfony\Component\Console\Cursor($output); + $this->cursor = new Cursor($output); } /** * Sets a placeholder formatter for a given name. @@ -388,7 +388,7 @@ final class ProgressBar { $this->format = null; $this->max = \max(0, $max); - $this->stepWidth = $this->max ? \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width((string) $this->max) : 4; + $this->stepWidth = $this->max ? Helper::width((string) $this->max) : 4; } /** * Finishes the progress output. @@ -409,7 +409,7 @@ final class ProgressBar */ public function display() : void { - if (\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) { + if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) { return; } if (null === $this->format) { @@ -457,11 +457,11 @@ final class ProgressBar $originalMessage = $message; if ($this->overwrite) { if (null !== $this->previousMessage) { - if ($this->output instanceof \RectorPrefix20220607\Symfony\Component\Console\Output\ConsoleSectionOutput) { + if ($this->output instanceof ConsoleSectionOutput) { $messageLines = \explode("\n", $message); $lineCount = \count($messageLines); foreach ($messageLines as $messageLine) { - $messageLineLength = \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width(\RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::removeDecoration($this->output->getFormatter(), $messageLine)); + $messageLineLength = Helper::width(Helper::removeDecoration($this->output->getFormatter(), $messageLine)); if ($messageLineLength > $this->terminal->getWidth()) { $lineCount += \floor($messageLineLength / $this->terminal->getWidth()); } @@ -488,11 +488,11 @@ final class ProgressBar private function determineBestFormat() : string { switch ($this->output->getVerbosity()) { - case \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_VERBOSE: + case OutputInterface::VERBOSITY_VERBOSE: return $this->max ? self::FORMAT_VERBOSE : self::FORMAT_VERBOSE_NOMAX; - case \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_VERY_VERBOSE: + case OutputInterface::VERBOSITY_VERY_VERBOSE: return $this->max ? self::FORMAT_VERY_VERBOSE : self::FORMAT_VERY_VERBOSE_NOMAX; - case \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_DEBUG: + case OutputInterface::VERBOSITY_DEBUG: return $this->max ? self::FORMAT_DEBUG : self::FORMAT_DEBUG_NOMAX; default: return $this->max ? self::FORMAT_NORMAL : self::FORMAT_NORMAL_NOMAX; @@ -500,28 +500,28 @@ final class ProgressBar } private static function initPlaceholderFormatters() : array { - return ['bar' => function (self $bar, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) { + return ['bar' => function (self $bar, OutputInterface $output) { $completeBars = $bar->getBarOffset(); $display = \str_repeat($bar->getBarCharacter(), $completeBars); if ($completeBars < $bar->getBarWidth()) { - $emptyBars = $bar->getBarWidth() - $completeBars - \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::length(\RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::removeDecoration($output->getFormatter(), $bar->getProgressCharacter())); + $emptyBars = $bar->getBarWidth() - $completeBars - Helper::length(Helper::removeDecoration($output->getFormatter(), $bar->getProgressCharacter())); $display .= $bar->getProgressCharacter() . \str_repeat($bar->getEmptyBarCharacter(), $emptyBars); } return $display; }, 'elapsed' => function (self $bar) { - return \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::formatTime(\time() - $bar->getStartTime()); + return Helper::formatTime(\time() - $bar->getStartTime()); }, 'remaining' => function (self $bar) { if (!$bar->getMaxSteps()) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException('Unable to display the remaining time if the maximum number of steps is not set.'); + throw new LogicException('Unable to display the remaining time if the maximum number of steps is not set.'); } - return \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::formatTime($bar->getRemaining()); + return Helper::formatTime($bar->getRemaining()); }, 'estimated' => function (self $bar) { if (!$bar->getMaxSteps()) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException('Unable to display the estimated time if the maximum number of steps is not set.'); + throw new LogicException('Unable to display the estimated time if the maximum number of steps is not set.'); } - return \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::formatTime($bar->getEstimated()); + return Helper::formatTime($bar->getEstimated()); }, 'memory' => function (self $bar) { - return \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::formatMemory(\memory_get_usage(\true)); + return Helper::formatMemory(\memory_get_usage(\true)); }, 'current' => function (self $bar) { return \str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', \STR_PAD_LEFT); }, 'max' => function (self $bar) { @@ -554,7 +554,7 @@ final class ProgressBar $line = \preg_replace_callback($regex, $callback, $this->format); // gets string length for each sub line with multiline format $linesLength = \array_map(function ($subLine) { - return \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width(\RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::removeDecoration($this->output->getFormatter(), \rtrim($subLine, "\r"))); + return Helper::width(Helper::removeDecoration($this->output->getFormatter(), \rtrim($subLine, "\r"))); }, \explode("\n", $line)); $linesWidth = \max($linesLength); $terminalWidth = $this->terminal->getWidth(); diff --git a/vendor/symfony/console/Helper/ProgressIndicator.php b/vendor/symfony/console/Helper/ProgressIndicator.php index 4adc4897263..c1fffe95581 100644 --- a/vendor/symfony/console/Helper/ProgressIndicator.php +++ b/vendor/symfony/console/Helper/ProgressIndicator.php @@ -63,7 +63,7 @@ class ProgressIndicator * @param int $indicatorChangeInterval Change interval in milliseconds * @param array|null $indicatorValues Animated indicator characters */ - public function __construct(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, string $format = null, int $indicatorChangeInterval = 100, array $indicatorValues = null) + public function __construct(OutputInterface $output, string $format = null, int $indicatorChangeInterval = 100, array $indicatorValues = null) { $this->output = $output; if (null === $format) { @@ -74,7 +74,7 @@ class ProgressIndicator } $indicatorValues = \array_values($indicatorValues); if (2 > \count($indicatorValues)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException('Must have at least 2 indicator value characters.'); + throw new InvalidArgumentException('Must have at least 2 indicator value characters.'); } $this->format = self::getFormatDefinition($format); $this->indicatorChangeInterval = $indicatorChangeInterval; @@ -95,7 +95,7 @@ class ProgressIndicator public function start(string $message) { if ($this->started) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException('Progress indicator already started.'); + throw new LogicException('Progress indicator already started.'); } $this->message = $message; $this->started = \true; @@ -110,7 +110,7 @@ class ProgressIndicator public function advance() { if (!$this->started) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException('Progress indicator has not yet been started.'); + throw new LogicException('Progress indicator has not yet been started.'); } if (!$this->output->isDecorated()) { return; @@ -131,7 +131,7 @@ class ProgressIndicator public function finish(string $message) { if (!$this->started) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException('Progress indicator has not yet been started.'); + throw new LogicException('Progress indicator has not yet been started.'); } $this->message = $message; $this->display(); @@ -165,7 +165,7 @@ class ProgressIndicator } private function display() { - if (\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) { + if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) { return; } $this->overwrite(\preg_replace_callback("{%([a-z\\-_]+)(?:\\:([^%]+))?%}i", function ($matches) { @@ -178,10 +178,10 @@ class ProgressIndicator private function determineBestFormat() : string { switch ($this->output->getVerbosity()) { - case \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_VERBOSE: + case OutputInterface::VERBOSITY_VERBOSE: return $this->output->isDecorated() ? 'verbose' : 'verbose_no_ansi'; - case \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_VERY_VERBOSE: - case \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_DEBUG: + case OutputInterface::VERBOSITY_VERY_VERBOSE: + case OutputInterface::VERBOSITY_DEBUG: return $this->output->isDecorated() ? 'very_verbose' : 'very_verbose_no_ansi'; default: return $this->output->isDecorated() ? 'normal' : 'normal_no_ansi'; @@ -193,7 +193,7 @@ class ProgressIndicator private function overwrite(string $message) { if ($this->output->isDecorated()) { - $this->output->write("\r\33[2K"); + $this->output->write("\r\x1b[2K"); $this->output->write($message); } else { $this->output->writeln($message); @@ -213,9 +213,9 @@ class ProgressIndicator }, 'message' => function (self $indicator) { return $indicator->message; }, 'elapsed' => function (self $indicator) { - return \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::formatTime(\time() - $indicator->startTime); + return Helper::formatTime(\time() - $indicator->startTime); }, 'memory' => function () { - return \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::formatMemory(\memory_get_usage(\true)); + return Helper::formatMemory(\memory_get_usage(\true)); }]; } } diff --git a/vendor/symfony/console/Helper/QuestionHelper.php b/vendor/symfony/console/Helper/QuestionHelper.php index 7b886b02847..212ecde1234 100644 --- a/vendor/symfony/console/Helper/QuestionHelper.php +++ b/vendor/symfony/console/Helper/QuestionHelper.php @@ -29,7 +29,7 @@ use function RectorPrefix20220607\Symfony\Component\String\s; * * @author Fabien Potencier */ -class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper +class QuestionHelper extends Helper { /** * @var resource|null @@ -50,15 +50,15 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel * * @throws RuntimeException If there is no data to read in the input stream */ - public function ask(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, \RectorPrefix20220607\Symfony\Component\Console\Question\Question $question) + public function ask(InputInterface $input, OutputInterface $output, Question $question) { - if ($output instanceof \RectorPrefix20220607\Symfony\Component\Console\Output\ConsoleOutputInterface) { + if ($output instanceof ConsoleOutputInterface) { $output = $output->getErrorOutput(); } if (!$input->isInteractive()) { return $this->getDefaultAnswer($question); } - if ($input instanceof \RectorPrefix20220607\Symfony\Component\Console\Input\StreamableInputInterface && ($stream = $input->getStream())) { + if ($input instanceof StreamableInputInterface && ($stream = $input->getStream())) { $this->inputStream = $stream; } try { @@ -69,7 +69,7 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel return $this->doAsk($output, $question); }; return $this->validateAttempts($interviewer, $output, $question); - } catch (\RectorPrefix20220607\Symfony\Component\Console\Exception\MissingInputException $exception) { + } catch (MissingInputException $exception) { $input->setInteractive(\false); if (null === ($fallbackOutput = $this->getDefaultAnswer($question))) { throw $exception; @@ -97,18 +97,18 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel * @throws RuntimeException In case the fallback is deactivated and the response cannot be hidden * @return mixed */ - private function doAsk(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, \RectorPrefix20220607\Symfony\Component\Console\Question\Question $question) + private function doAsk(OutputInterface $output, Question $question) { $this->writePrompt($output, $question); $inputStream = $this->inputStream ?: \STDIN; $autocomplete = $question->getAutocompleterCallback(); - if (null === $autocomplete || !self::$stty || !\RectorPrefix20220607\Symfony\Component\Console\Terminal::hasSttyAvailable()) { + if (null === $autocomplete || !self::$stty || !Terminal::hasSttyAvailable()) { $ret = \false; if ($question->isHidden()) { try { $hiddenResponse = $this->getHiddenResponse($output, $inputStream, $question->isTrimmable()); $ret = $question->isTrimmable() ? \trim($hiddenResponse) : $hiddenResponse; - } catch (\RectorPrefix20220607\Symfony\Component\Console\Exception\RuntimeException $e) { + } catch (RuntimeException $e) { if (!$question->isHiddenFallback()) { throw $e; } @@ -117,7 +117,7 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel if (\false === $ret) { $ret = $this->readInput($inputStream, $question); if (\false === $ret) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\MissingInputException('Aborted.'); + throw new MissingInputException('Aborted.'); } if ($question->isTrimmable()) { $ret = \trim($ret); @@ -127,7 +127,7 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel $autocomplete = $this->autocomplete($output, $question, $inputStream, $autocomplete); $ret = $question->isTrimmable() ? \trim($autocomplete) : $autocomplete; } - if ($output instanceof \RectorPrefix20220607\Symfony\Component\Console\Output\ConsoleSectionOutput) { + if ($output instanceof ConsoleSectionOutput) { $output->addContent($ret); } $ret = \strlen($ret) > 0 ? $ret : $question->getDefault(); @@ -139,7 +139,7 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel /** * @return mixed */ - private function getDefaultAnswer(\RectorPrefix20220607\Symfony\Component\Console\Question\Question $question) + private function getDefaultAnswer(Question $question) { $default = $question->getDefault(); if (null === $default) { @@ -147,7 +147,7 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel } if ($validator = $question->getValidator()) { return \call_user_func($question->getValidator(), $default); - } elseif ($question instanceof \RectorPrefix20220607\Symfony\Component\Console\Question\ChoiceQuestion) { + } elseif ($question instanceof ChoiceQuestion) { $choices = $question->getChoices(); if (!$question->isMultiselect()) { return $choices[$default] ?? $default; @@ -163,10 +163,10 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel /** * Outputs the question prompt. */ - protected function writePrompt(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, \RectorPrefix20220607\Symfony\Component\Console\Question\Question $question) + protected function writePrompt(OutputInterface $output, Question $question) { $message = $question->getQuestion(); - if ($question instanceof \RectorPrefix20220607\Symfony\Component\Console\Question\ChoiceQuestion) { + if ($question instanceof ChoiceQuestion) { $output->writeln(\array_merge([$question->getQuestion()], $this->formatChoiceQuestionChoices($question, 'info'))); $message = $question->getPrompt(); } @@ -175,7 +175,7 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel /** * @return string[] */ - protected function formatChoiceQuestionChoices(\RectorPrefix20220607\Symfony\Component\Console\Question\ChoiceQuestion $question, string $tag) : array + protected function formatChoiceQuestionChoices(ChoiceQuestion $question, string $tag) : array { $messages = []; $maxWidth = \max(\array_map([__CLASS__, 'width'], \array_keys($choices = $question->getChoices()))); @@ -188,7 +188,7 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel /** * Outputs an error message. */ - protected function writeError(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, \Exception $error) + protected function writeError(OutputInterface $output, \Exception $error) { if (null !== $this->getHelperSet() && $this->getHelperSet()->has('formatter')) { $message = $this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'); @@ -202,9 +202,9 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel * * @param resource $inputStream */ - private function autocomplete(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, \RectorPrefix20220607\Symfony\Component\Console\Question\Question $question, $inputStream, callable $autocomplete) : string + private function autocomplete(OutputInterface $output, Question $question, $inputStream, callable $autocomplete) : string { - $cursor = new \RectorPrefix20220607\Symfony\Component\Console\Cursor($output, $inputStream); + $cursor = new Cursor($output, $inputStream); $fullChoice = ''; $ret = ''; $i = 0; @@ -218,7 +218,7 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel // Disable icanon (so we can fread each keypress) and echo (we'll do echoing here instead) \shell_exec('stty -icanon -echo'); // Add highlighted text style - $output->getFormatter()->setStyle('hl', new \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterStyle('black', 'white')); + $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white')); // Read a keypress while (!\feof($inputStream)) { while ($isStdin && 0 === @\stream_select($r, $w, $w, 0, 100)) { @@ -229,12 +229,12 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel // as opposed to fgets(), fread() returns an empty string when the stream content is empty, not false. if (\false === $c || '' === $ret && '' === $c && null === $question->getDefault()) { \shell_exec('stty ' . $sttyMode); - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\MissingInputException('Aborted.'); + throw new MissingInputException('Aborted.'); } elseif ("" === $c) { // Backspace Character if (0 === $numMatches && 0 !== $i) { --$i; - $cursor->moveLeft(\RectorPrefix20220607\Symfony\Component\String\s($fullChoice)->slice(-1)->width(\false)); + $cursor->moveLeft(s($fullChoice)->slice(-1)->width(\false)); $fullChoice = self::substr($fullChoice, 0, $i); } if (0 === $i) { @@ -246,7 +246,7 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel } // Pop the last character off the end of our string $ret = self::substr($ret, 0, $i); - } elseif ("\33" === $c) { + } elseif ("\x1b" === $c) { // Did we read an escape sequence? $c .= \fread($inputStream, 2); // A = Up Arrow. B = Down Arrow @@ -283,15 +283,15 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel } continue; } else { - if ("€" <= $c) { - $c .= \fread($inputStream, ["À" => 1, "Ð" => 1, "à" => 2, "ð" => 3][$c & "ð"]); + if ("\x80" <= $c) { + $c .= \fread($inputStream, ["\xc0" => 1, "\xd0" => 1, "\xe0" => 2, "\xf0" => 3][$c & "\xf0"]); } $output->write($c); $ret .= $c; $fullChoice .= $c; ++$i; $tempRet = $ret; - if ($question instanceof \RectorPrefix20220607\Symfony\Component\Console\Question\ChoiceQuestion && $question->isMultiselect()) { + if ($question instanceof ChoiceQuestion && $question->isMultiselect()) { $tempRet = $this->mostRecentlyEnteredValue($fullChoice); } $numMatches = 0; @@ -308,7 +308,7 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel $cursor->savePosition(); // Write highlighted text, complete the partially entered response $charactersEntered = \strlen(\trim($this->mostRecentlyEnteredValue($fullChoice))); - $output->write('' . \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatter::escapeTrailingBackslash(\substr($matches[$ofs], $charactersEntered)) . ''); + $output->write('' . OutputFormatter::escapeTrailingBackslash(\substr($matches[$ofs], $charactersEntered)) . ''); $cursor->restorePosition(); } } @@ -336,7 +336,7 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel * * @throws RuntimeException In case the fallback is deactivated and the response cannot be hidden */ - private function getHiddenResponse(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, $inputStream, bool $trimmable = \true) : string + private function getHiddenResponse(OutputInterface $output, $inputStream, bool $trimmable = \true) : string { if ('\\' === \DIRECTORY_SEPARATOR) { $exe = __DIR__ . '/../Resources/bin/hiddeninput.exe'; @@ -354,18 +354,18 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel } return $value; } - if (self::$stty && \RectorPrefix20220607\Symfony\Component\Console\Terminal::hasSttyAvailable()) { + if (self::$stty && Terminal::hasSttyAvailable()) { $sttyMode = \shell_exec('stty -g'); \shell_exec('stty -echo'); } elseif ($this->isInteractiveInput($inputStream)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\RuntimeException('Unable to hide the response.'); + throw new RuntimeException('Unable to hide the response.'); } $value = \fgets($inputStream, 4096); - if (self::$stty && \RectorPrefix20220607\Symfony\Component\Console\Terminal::hasSttyAvailable()) { + if (self::$stty && Terminal::hasSttyAvailable()) { \shell_exec('stty ' . $sttyMode); } if (\false === $value) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\MissingInputException('Aborted.'); + throw new MissingInputException('Aborted.'); } if ($trimmable) { $value = \trim($value); @@ -381,7 +381,7 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel * @throws \Exception In case the max number of attempts has been reached and no valid response has been given * @return mixed */ - private function validateAttempts(callable $interviewer, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, \RectorPrefix20220607\Symfony\Component\Console\Question\Question $question) + private function validateAttempts(callable $interviewer, OutputInterface $output, Question $question) { $error = null; $attempts = $question->getMaxAttempts(); @@ -391,7 +391,7 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel } try { return $question->getValidator()($interviewer()); - } catch (\RectorPrefix20220607\Symfony\Component\Console\Exception\RuntimeException $e) { + } catch (RuntimeException $e) { throw $e; } catch (\Exception $error) { } @@ -425,7 +425,7 @@ class QuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Hel * @param Question $question The question being asked * @return string|true */ - private function readInput($inputStream, \RectorPrefix20220607\Symfony\Component\Console\Question\Question $question) + private function readInput($inputStream, Question $question) { if (!$question->isMultiline()) { $cp = $this->setIOCodepage(); diff --git a/vendor/symfony/console/Helper/SymfonyQuestionHelper.php b/vendor/symfony/console/Helper/SymfonyQuestionHelper.php index a5dc351408f..badd697aa1e 100644 --- a/vendor/symfony/console/Helper/SymfonyQuestionHelper.php +++ b/vendor/symfony/console/Helper/SymfonyQuestionHelper.php @@ -21,14 +21,14 @@ use RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle; * * @author Kevin Bond */ -class SymfonyQuestionHelper extends \RectorPrefix20220607\Symfony\Component\Console\Helper\QuestionHelper +class SymfonyQuestionHelper extends QuestionHelper { /** * {@inheritdoc} */ - protected function writePrompt(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, \RectorPrefix20220607\Symfony\Component\Console\Question\Question $question) + protected function writePrompt(OutputInterface $output, Question $question) { - $text = \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatter::escapeTrailingBackslash($question->getQuestion()); + $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion()); $default = $question->getDefault(); if ($question->isMultiline()) { $text .= \sprintf(' (press %s to continue)', $this->getEofShortcut()); @@ -37,27 +37,27 @@ class SymfonyQuestionHelper extends \RectorPrefix20220607\Symfony\Component\Cons case null === $default: $text = \sprintf(' %s:', $text); break; - case $question instanceof \RectorPrefix20220607\Symfony\Component\Console\Question\ConfirmationQuestion: + case $question instanceof ConfirmationQuestion: $text = \sprintf(' %s (yes/no) [%s]:', $text, $default ? 'yes' : 'no'); break; - case $question instanceof \RectorPrefix20220607\Symfony\Component\Console\Question\ChoiceQuestion && $question->isMultiselect(): + case $question instanceof ChoiceQuestion && $question->isMultiselect(): $choices = $question->getChoices(); $default = \explode(',', $default); foreach ($default as $key => $value) { $default[$key] = $choices[\trim($value)]; } - $text = \sprintf(' %s [%s]:', $text, \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatter::escape(\implode(', ', $default))); + $text = \sprintf(' %s [%s]:', $text, OutputFormatter::escape(\implode(', ', $default))); break; - case $question instanceof \RectorPrefix20220607\Symfony\Component\Console\Question\ChoiceQuestion: + case $question instanceof ChoiceQuestion: $choices = $question->getChoices(); - $text = \sprintf(' %s [%s]:', $text, \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatter::escape($choices[$default] ?? $default)); + $text = \sprintf(' %s [%s]:', $text, OutputFormatter::escape($choices[$default] ?? $default)); break; default: - $text = \sprintf(' %s [%s]:', $text, \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatter::escape($default)); + $text = \sprintf(' %s [%s]:', $text, OutputFormatter::escape($default)); } $output->writeln($text); $prompt = ' > '; - if ($question instanceof \RectorPrefix20220607\Symfony\Component\Console\Question\ChoiceQuestion) { + if ($question instanceof ChoiceQuestion) { $output->writeln($this->formatChoiceQuestionChoices($question, 'comment')); $prompt = $question->getPrompt(); } @@ -66,9 +66,9 @@ class SymfonyQuestionHelper extends \RectorPrefix20220607\Symfony\Component\Cons /** * {@inheritdoc} */ - protected function writeError(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, \Exception $error) + protected function writeError(OutputInterface $output, \Exception $error) { - if ($output instanceof \RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle) { + if ($output instanceof SymfonyStyle) { $output->newLine(); $output->error($error->getMessage()); return; diff --git a/vendor/symfony/console/Helper/Table.php b/vendor/symfony/console/Helper/Table.php index 5f7675a48f4..09c267779ec 100644 --- a/vendor/symfony/console/Helper/Table.php +++ b/vendor/symfony/console/Helper/Table.php @@ -92,7 +92,7 @@ class Table * @var mixed[] */ private static $styles; - public function __construct(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) + public function __construct(OutputInterface $output) { $this->output = $output; self::$styles = self::$styles ?? self::initStyles(); @@ -101,7 +101,7 @@ class Table /** * Sets a style definition. */ - public static function setStyleDefinition(string $name, \RectorPrefix20220607\Symfony\Component\Console\Helper\TableStyle $style) + public static function setStyleDefinition(string $name, TableStyle $style) { self::$styles = self::$styles ?? self::initStyles(); self::$styles[$name] = $style; @@ -109,11 +109,11 @@ class Table /** * Gets a style definition by name. */ - public static function getStyleDefinition(string $name) : \RectorPrefix20220607\Symfony\Component\Console\Helper\TableStyle + public static function getStyleDefinition(string $name) : TableStyle { self::$styles = self::$styles ?? self::initStyles(); if (!isset(self::$styles[$name])) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('Style "%s" is not defined.', $name)); + throw new InvalidArgumentException(\sprintf('Style "%s" is not defined.', $name)); } return self::$styles[$name]; } @@ -131,7 +131,7 @@ class Table /** * Gets the current table style. */ - public function getStyle() : \RectorPrefix20220607\Symfony\Component\Console\Helper\TableStyle + public function getStyle() : TableStyle { return $this->style; } @@ -152,7 +152,7 @@ class Table * * If style was not set, it returns the global table style. */ - public function getColumnStyle(int $columnIndex) : \RectorPrefix20220607\Symfony\Component\Console\Helper\TableStyle + public function getColumnStyle(int $columnIndex) : TableStyle { return $this->columnStyles[$columnIndex] ?? $this->getStyle(); } @@ -189,8 +189,8 @@ class Table */ public function setColumnMaxWidth(int $columnIndex, int $width) { - if (!$this->output->getFormatter() instanceof \RectorPrefix20220607\Symfony\Component\Console\Formatter\WrappableOutputFormatterInterface) { - throw new \LogicException(\sprintf('Setting a maximum column width is only supported when using a "%s" formatter, got "%s".', \RectorPrefix20220607\Symfony\Component\Console\Formatter\WrappableOutputFormatterInterface::class, \get_debug_type($this->output->getFormatter()))); + if (!$this->output->getFormatter() instanceof WrappableOutputFormatterInterface) { + throw new \LogicException(\sprintf('Setting a maximum column width is only supported when using a "%s" formatter, got "%s".', WrappableOutputFormatterInterface::class, \get_debug_type($this->output->getFormatter()))); } $this->columnMaxWidths[$columnIndex] = $width; return $this; @@ -228,7 +228,7 @@ class Table */ public function addRow($row) { - if ($row instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableSeparator) { + if ($row instanceof TableSeparator) { $this->rows[] = $row; return $this; } @@ -243,8 +243,8 @@ class Table */ public function appendRow($row) { - if (!$this->output instanceof \RectorPrefix20220607\Symfony\Component\Console\Output\ConsoleSectionOutput) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\RuntimeException(\sprintf('Output should be an instance of "%s" when calling "%s".', \RectorPrefix20220607\Symfony\Component\Console\Output\ConsoleSectionOutput::class, __METHOD__)); + if (!$this->output instanceof ConsoleSectionOutput) { + throw new RuntimeException(\sprintf('Output should be an instance of "%s" when calling "%s".', ConsoleSectionOutput::class, __METHOD__)); } if ($this->rendered) { $this->output->clear($this->calculateRowCount()); @@ -309,9 +309,9 @@ class Table */ public function render() { - $divider = new \RectorPrefix20220607\Symfony\Component\Console\Helper\TableSeparator(); + $divider = new TableSeparator(); $isCellWithColspan = static function ($cell) { - return $cell instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCell && $cell->getColspan() >= 2; + return $cell instanceof TableCell && $cell->getColspan() >= 2; }; $horizontal = self::DISPLAY_ORIENTATION_HORIZONTAL === $this->displayOrientation; $vertical = self::DISPLAY_ORIENTATION_VERTICAL === $this->displayOrientation; @@ -320,7 +320,7 @@ class Table foreach ($this->headers[0] ?? [] as $i => $header) { $rows[$i] = [$header]; foreach ($this->rows as $row) { - if ($row instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableSeparator) { + if ($row instanceof TableSeparator) { continue; } if (isset($row[$i])) { @@ -335,10 +335,10 @@ class Table } elseif ($vertical) { $formatter = $this->output->getFormatter(); $maxHeaderLength = \array_reduce($this->headers[0] ?? [], static function ($max, $header) use($formatter) { - return \max($max, \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width(\RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::removeDecoration($formatter, $header))); + return \max($max, Helper::width(Helper::removeDecoration($formatter, $header))); }, 0); foreach ($this->rows as $row) { - if ($row instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableSeparator) { + if ($row instanceof TableSeparator) { continue; } if ($rows) { @@ -378,7 +378,7 @@ class Table $isFirstRow = \true; continue; } - if ($row instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableSeparator) { + if ($row instanceof TableSeparator) { $this->renderRowSeparator(); continue; } @@ -442,12 +442,12 @@ class Table $markup .= $column === $count - 1 ? $rightChar : $midChar; } if (null !== $title) { - $titleLength = \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width(\RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::removeDecoration($formatter = $this->output->getFormatter(), $formattedTitle = \sprintf($titleFormat, $title))); - $markupLength = \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($markup); + $titleLength = Helper::width(Helper::removeDecoration($formatter = $this->output->getFormatter(), $formattedTitle = \sprintf($titleFormat, $title))); + $markupLength = Helper::width($markup); if ($titleLength > ($limit = $markupLength - 4)) { $titleLength = $limit; - $formatLength = \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width(\RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::removeDecoration($formatter, \sprintf($titleFormat, ''))); - $formattedTitle = \sprintf($titleFormat, \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::substr($title, 0, $limit - $formatLength - 3) . '...'); + $formatLength = Helper::width(Helper::removeDecoration($formatter, \sprintf($titleFormat, ''))); + $formattedTitle = \sprintf($titleFormat, Helper::substr($title, 0, $limit - $formatLength - 3) . '...'); } $titleStart = \intdiv($markupLength - $titleLength, 2); if (\false === \mb_detect_encoding($markup, null, \true)) { @@ -495,7 +495,7 @@ class Table { $cell = $row[$column] ?? ''; $width = $this->effectiveColumnWidths[$column]; - if ($cell instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCell && $cell->getColspan() > 1) { + if ($cell instanceof TableCell && $cell->getColspan() > 1) { // add the width of the following columns(numbers of colspan). foreach (\range($column + 1, $column + $cell->getColspan() - 1) as $nextColumn) { $width += $this->getColumnSeparatorWidth() + $this->effectiveColumnWidths[$nextColumn]; @@ -506,13 +506,13 @@ class Table $width += \strlen($cell) - \mb_strwidth($cell, $encoding); } $style = $this->getColumnStyle($column); - if ($cell instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableSeparator) { + if ($cell instanceof TableSeparator) { return \sprintf($style->getBorderFormat(), \str_repeat($style->getBorderChars()[2], $width)); } - $width += \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::length($cell) - \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::length(\RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::removeDecoration($this->output->getFormatter(), $cell)); + $width += Helper::length($cell) - Helper::length(Helper::removeDecoration($this->output->getFormatter(), $cell)); $content = \sprintf($style->getCellRowContentFormat(), $cell); $padType = $style->getPadType(); - if ($cell instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCell && $cell->getStyle() instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCellStyle) { + if ($cell instanceof TableCell && $cell->getStyle() instanceof TableCellStyle) { $isNotStyledByTag = !\preg_match('/^<(\\w+|(\\w+=[\\w,]+;?)*)>.+<\\/(\\w+|(\\w+=\\w+;?)*)?>$/', $cell); if ($isNotStyledByTag) { $cellFormat = $cell->getStyle()->getCellFormat(); @@ -540,14 +540,14 @@ class Table { $columns = [0]; foreach ($rows as $row) { - if ($row instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableSeparator) { + if ($row instanceof TableSeparator) { continue; } $columns[] = $this->getNumberOfColumns($row); } $this->numberOfColumns = \max($columns); } - private function buildTableRows(array $rows) : \RectorPrefix20220607\Symfony\Component\Console\Helper\TableRows + private function buildTableRows(array $rows) : TableRows { /** @var WrappableOutputFormatterInterface $formatter */ $formatter = $this->output->getFormatter(); @@ -556,19 +556,19 @@ class Table $rows = $this->fillNextRows($rows, $rowKey); // Remove any new line breaks and replace it with a new line foreach ($rows[$rowKey] as $column => $cell) { - $colspan = $cell instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCell ? $cell->getColspan() : 1; - if (isset($this->columnMaxWidths[$column]) && \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width(\RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::removeDecoration($formatter, $cell)) > $this->columnMaxWidths[$column]) { + $colspan = $cell instanceof TableCell ? $cell->getColspan() : 1; + if (isset($this->columnMaxWidths[$column]) && Helper::width(Helper::removeDecoration($formatter, $cell)) > $this->columnMaxWidths[$column]) { $cell = $formatter->formatAndWrap($cell, $this->columnMaxWidths[$column] * $colspan); } if (\strpos($cell ?? '', "\n") === \false) { continue; } - $escaped = \implode("\n", \array_map([\RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatter::class, 'escapeTrailingBackslash'], \explode("\n", $cell))); - $cell = $cell instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCell ? new \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCell($escaped, ['colspan' => $cell->getColspan()]) : $escaped; + $escaped = \implode("\n", \array_map([OutputFormatter::class, 'escapeTrailingBackslash'], \explode("\n", $cell))); + $cell = $cell instanceof TableCell ? new TableCell($escaped, ['colspan' => $cell->getColspan()]) : $escaped; $lines = \explode("\n", \str_replace("\n", "\n", $cell)); foreach ($lines as $lineKey => $line) { if ($colspan > 1) { - $line = new \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCell($line, ['colspan' => $colspan]); + $line = new TableCell($line, ['colspan' => $colspan]); } if (0 === $lineKey) { $rows[$rowKey][$column] = $line; @@ -581,12 +581,12 @@ class Table } } } - return new \RectorPrefix20220607\Symfony\Component\Console\Helper\TableRows(function () use($rows, $unmergedRows) : \Traversable { + return new TableRows(function () use($rows, $unmergedRows) : \Traversable { foreach ($rows as $rowKey => $row) { - $rowGroup = [$row instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableSeparator ? $row : $this->fillCells($row)]; + $rowGroup = [$row instanceof TableSeparator ? $row : $this->fillCells($row)]; if (isset($unmergedRows[$rowKey])) { foreach ($unmergedRows[$rowKey] as $row) { - $rowGroup[] = $row instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableSeparator ? $row : $this->fillCells($row); + $rowGroup[] = $row instanceof TableSeparator ? $row : $this->fillCells($row); } } (yield $rowGroup); @@ -595,7 +595,7 @@ class Table } private function calculateRowCount() : int { - $numberOfRows = \count(\iterator_to_array($this->buildTableRows(\array_merge($this->headers, [new \RectorPrefix20220607\Symfony\Component\Console\Helper\TableSeparator()], $this->rows)))); + $numberOfRows = \count(\iterator_to_array($this->buildTableRows(\array_merge($this->headers, [new TableSeparator()], $this->rows)))); if ($this->headers) { ++$numberOfRows; // Add row for header separator @@ -615,23 +615,23 @@ class Table { $unmergedRows = []; foreach ($rows[$line] as $column => $cell) { - if (null !== $cell && !$cell instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCell && !\is_scalar($cell) && !$cell instanceof \Stringable) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('A cell must be a TableCell, a scalar or an object implementing "__toString()", "%s" given.', \get_debug_type($cell))); + if (null !== $cell && !$cell instanceof TableCell && !\is_scalar($cell) && !$cell instanceof \Stringable) { + throw new InvalidArgumentException(\sprintf('A cell must be a TableCell, a scalar or an object implementing "__toString()", "%s" given.', \get_debug_type($cell))); } - if ($cell instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCell && $cell->getRowspan() > 1) { + if ($cell instanceof TableCell && $cell->getRowspan() > 1) { $nbLines = $cell->getRowspan() - 1; $lines = [$cell]; if (\strpos($cell, "\n") !== \false) { $lines = \explode("\n", \str_replace("\n", "\n", $cell)); $nbLines = \count($lines) > $nbLines ? \substr_count($cell, "\n") : $nbLines; - $rows[$line][$column] = new \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCell($lines[0], ['colspan' => $cell->getColspan(), 'style' => $cell->getStyle()]); + $rows[$line][$column] = new TableCell($lines[0], ['colspan' => $cell->getColspan(), 'style' => $cell->getStyle()]); unset($lines[0]); } // create a two dimensional array (rowspan x colspan) $unmergedRows = \array_replace_recursive(\array_fill($line + 1, $nbLines, []), $unmergedRows); foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) { $value = $lines[$unmergedRowKey - $line] ?? ''; - $unmergedRows[$unmergedRowKey][$column] = new \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCell($value, ['colspan' => $cell->getColspan(), 'style' => $cell->getStyle()]); + $unmergedRows[$unmergedRowKey][$column] = new TableCell($value, ['colspan' => $cell->getColspan(), 'style' => $cell->getStyle()]); if ($nbLines === $unmergedRowKey - $line) { break; } @@ -665,7 +665,7 @@ class Table $newRow = []; foreach ($row as $column => $cell) { $newRow[] = $cell; - if ($cell instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCell && $cell->getColspan() > 1) { + if ($cell instanceof TableCell && $cell->getColspan() > 1) { foreach (\range($column + 1, $column + $cell->getColspan() - 1) as $position) { // insert empty value at column position $newRow[] = ''; @@ -679,8 +679,8 @@ class Table $row = $rows[$line]; foreach ($row as $cellKey => $cellValue) { $row[$cellKey] = ''; - if ($cellValue instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCell) { - $row[$cellKey] = new \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCell('', ['colspan' => $cellValue->getColspan()]); + if ($cellValue instanceof TableCell) { + $row[$cellKey] = new TableCell('', ['colspan' => $cellValue->getColspan()]); } } return $row; @@ -692,7 +692,7 @@ class Table { $columns = \count($row); foreach ($row as $column) { - $columns += $column instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCell ? $column->getColspan() - 1 : 0; + $columns += $column instanceof TableCell ? $column->getColspan() - 1 : 0; } return $columns; } @@ -703,7 +703,7 @@ class Table { $columns = \range(0, $this->numberOfColumns - 1); foreach ($row as $cellKey => $cell) { - if ($cell instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCell && $cell->getColspan() > 1) { + if ($cell instanceof TableCell && $cell->getColspan() > 1) { // exclude grouped columns. $columns = \array_diff($columns, \range($cellKey + 1, $cellKey + $cell->getColspan() - 1)); } @@ -719,13 +719,13 @@ class Table $lengths = []; foreach ($groups as $group) { foreach ($group as $row) { - if ($row instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableSeparator) { + if ($row instanceof TableSeparator) { continue; } foreach ($row as $i => $cell) { - if ($cell instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCell) { - $textContent = \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::removeDecoration($this->output->getFormatter(), $cell); - $textLength = \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($textContent); + if ($cell instanceof TableCell) { + $textContent = Helper::removeDecoration($this->output->getFormatter(), $cell); + $textLength = Helper::width($textContent); if ($textLength > 0) { $contentColumns = \str_split($textContent, \ceil($textLength / $cell->getColspan())); foreach ($contentColumns as $position => $content) { @@ -737,19 +737,19 @@ class Table $lengths[] = $this->getCellWidth($row, $column); } } - $this->effectiveColumnWidths[$column] = \max($lengths) + \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($this->style->getCellRowContentFormat()) - 2; + $this->effectiveColumnWidths[$column] = \max($lengths) + Helper::width($this->style->getCellRowContentFormat()) - 2; } } private function getColumnSeparatorWidth() : int { - return \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width(\sprintf($this->style->getBorderFormat(), $this->style->getBorderChars()[3])); + return Helper::width(\sprintf($this->style->getBorderFormat(), $this->style->getBorderChars()[3])); } private function getCellWidth(array $row, int $column) : int { $cellWidth = 0; if (isset($row[$column])) { $cell = $row[$column]; - $cellWidth = \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width(\RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::removeDecoration($this->output->getFormatter(), $cell)); + $cellWidth = Helper::width(Helper::removeDecoration($this->output->getFormatter(), $cell)); } $columnWidth = $this->columnWidths[$column] ?? 0; $cellWidth = \max($cellWidth, $columnWidth); @@ -768,26 +768,26 @@ class Table */ private static function initStyles() : array { - $borderless = new \RectorPrefix20220607\Symfony\Component\Console\Helper\TableStyle(); + $borderless = new TableStyle(); $borderless->setHorizontalBorderChars('=')->setVerticalBorderChars(' ')->setDefaultCrossingChar(' '); - $compact = new \RectorPrefix20220607\Symfony\Component\Console\Helper\TableStyle(); + $compact = new TableStyle(); $compact->setHorizontalBorderChars('')->setVerticalBorderChars('')->setDefaultCrossingChar('')->setCellRowContentFormat('%s '); - $styleGuide = new \RectorPrefix20220607\Symfony\Component\Console\Helper\TableStyle(); + $styleGuide = new TableStyle(); $styleGuide->setHorizontalBorderChars('-')->setVerticalBorderChars(' ')->setDefaultCrossingChar(' ')->setCellHeaderFormat('%s'); - $box = (new \RectorPrefix20220607\Symfony\Component\Console\Helper\TableStyle())->setHorizontalBorderChars('─')->setVerticalBorderChars('│')->setCrossingChars('┼', '┌', '┬', 'â”', '┤', '┘', 'â”´', 'â””', '├'); - $boxDouble = (new \RectorPrefix20220607\Symfony\Component\Console\Helper\TableStyle())->setHorizontalBorderChars('â•', '─')->setVerticalBorderChars('â•‘', '│')->setCrossingChars('┼', 'â•”', '╤', 'â•—', 'â•¢', 'â•', '╧', 'â•š', 'â•Ÿ', 'â• ', '╪', 'â•£'); - return ['default' => new \RectorPrefix20220607\Symfony\Component\Console\Helper\TableStyle(), 'borderless' => $borderless, 'compact' => $compact, 'symfony-style-guide' => $styleGuide, 'box' => $box, 'box-double' => $boxDouble]; + $box = (new TableStyle())->setHorizontalBorderChars('─')->setVerticalBorderChars('│')->setCrossingChars('┼', '┌', '┬', 'â”', '┤', '┘', 'â”´', 'â””', '├'); + $boxDouble = (new TableStyle())->setHorizontalBorderChars('â•', '─')->setVerticalBorderChars('â•‘', '│')->setCrossingChars('┼', 'â•”', '╤', 'â•—', 'â•¢', 'â•', '╧', 'â•š', 'â•Ÿ', 'â• ', '╪', 'â•£'); + return ['default' => new TableStyle(), 'borderless' => $borderless, 'compact' => $compact, 'symfony-style-guide' => $styleGuide, 'box' => $box, 'box-double' => $boxDouble]; } /** * @param \Symfony\Component\Console\Helper\TableStyle|string $name */ - private function resolveStyle($name) : \RectorPrefix20220607\Symfony\Component\Console\Helper\TableStyle + private function resolveStyle($name) : TableStyle { - if ($name instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableStyle) { + if ($name instanceof TableStyle) { return $name; } if (!isset(self::$styles[$name])) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('Style "%s" is not defined.', $name)); + throw new InvalidArgumentException(\sprintf('Style "%s" is not defined.', $name)); } return self::$styles[$name]; } diff --git a/vendor/symfony/console/Helper/TableCell.php b/vendor/symfony/console/Helper/TableCell.php index ccaece84dd6..b88ab232ab4 100644 --- a/vendor/symfony/console/Helper/TableCell.php +++ b/vendor/symfony/console/Helper/TableCell.php @@ -29,10 +29,10 @@ class TableCell $this->value = $value; // check option names if ($diff = \array_diff(\array_keys($options), \array_keys($this->options))) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('The TableCell does not support the following options: \'%s\'.', \implode('\', \'', $diff))); + throw new InvalidArgumentException(\sprintf('The TableCell does not support the following options: \'%s\'.', \implode('\', \'', $diff))); } - if (isset($options['style']) && !$options['style'] instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCellStyle) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException('The style option must be an instance of "TableCellStyle".'); + if (isset($options['style']) && !$options['style'] instanceof TableCellStyle) { + throw new InvalidArgumentException('The style option must be an instance of "TableCellStyle".'); } $this->options = \array_merge($this->options, $options); } @@ -57,7 +57,7 @@ class TableCell { return (int) $this->options['rowspan']; } - public function getStyle() : ?\RectorPrefix20220607\Symfony\Component\Console\Helper\TableCellStyle + public function getStyle() : ?TableCellStyle { return $this->options['style']; } diff --git a/vendor/symfony/console/Helper/TableCellStyle.php b/vendor/symfony/console/Helper/TableCellStyle.php index 830f956c51c..580d4f570e1 100644 --- a/vendor/symfony/console/Helper/TableCellStyle.php +++ b/vendor/symfony/console/Helper/TableCellStyle.php @@ -26,10 +26,10 @@ class TableCellStyle public function __construct(array $options = []) { if ($diff = \array_diff(\array_keys($options), \array_keys($this->options))) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('The TableCellStyle does not support the following options: \'%s\'.', \implode('\', \'', $diff))); + throw new InvalidArgumentException(\sprintf('The TableCellStyle does not support the following options: \'%s\'.', \implode('\', \'', $diff))); } if (isset($options['align']) && !\array_key_exists($options['align'], self::ALIGN_MAP)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('Wrong align value. Value must be following: \'%s\'.', \implode('\', \'', \array_keys(self::ALIGN_MAP)))); + throw new InvalidArgumentException(\sprintf('Wrong align value. Value must be following: \'%s\'.', \implode('\', \'', \array_keys(self::ALIGN_MAP)))); } $this->options = \array_merge($this->options, $options); } diff --git a/vendor/symfony/console/Helper/TableSeparator.php b/vendor/symfony/console/Helper/TableSeparator.php index ec49c0cd4f2..05c40f9423b 100644 --- a/vendor/symfony/console/Helper/TableSeparator.php +++ b/vendor/symfony/console/Helper/TableSeparator.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Symfony\Component\Console\Helper; * * @author Fabien Potencier */ -class TableSeparator extends \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCell +class TableSeparator extends TableCell { public function __construct(array $options = []) { diff --git a/vendor/symfony/console/Helper/TableStyle.php b/vendor/symfony/console/Helper/TableStyle.php index 5160497c0d8..85e464cf758 100644 --- a/vendor/symfony/console/Helper/TableStyle.php +++ b/vendor/symfony/console/Helper/TableStyle.php @@ -125,7 +125,7 @@ class TableStyle public function setPaddingChar(string $paddingChar) { if (!$paddingChar) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException('The padding char must not be empty.'); + throw new LogicException('The padding char must not be empty.'); } $this->paddingChar = $paddingChar; return $this; @@ -339,7 +339,7 @@ class TableStyle public function setPadType(int $padType) { if (!\in_array($padType, [\STR_PAD_LEFT, \STR_PAD_RIGHT, \STR_PAD_BOTH], \true)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).'); + throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).'); } $this->padType = $padType; return $this; diff --git a/vendor/symfony/console/Input/ArgvInput.php b/vendor/symfony/console/Input/ArgvInput.php index bd59c17d05c..87d765196cd 100644 --- a/vendor/symfony/console/Input/ArgvInput.php +++ b/vendor/symfony/console/Input/ArgvInput.php @@ -36,7 +36,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Exception\RuntimeException; * @see http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html * @see http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html#tag_12_02 */ -class ArgvInput extends \RectorPrefix20220607\Symfony\Component\Console\Input\Input +class ArgvInput extends Input { /** * @var mixed[] @@ -46,7 +46,7 @@ class ArgvInput extends \RectorPrefix20220607\Symfony\Component\Console\Input\In * @var mixed[] */ private $parsed; - public function __construct(array $argv = null, \RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition $definition = null) + public function __construct(array $argv = null, InputDefinition $definition = null) { $argv = $argv ?? $_SERVER['argv'] ?? []; // strip the application name @@ -112,7 +112,7 @@ class ArgvInput extends \RectorPrefix20220607\Symfony\Component\Console\Input\In for ($i = 0; $i < $len; ++$i) { if (!$this->definition->hasShortcut($name[$i])) { $encoding = \mb_detect_encoding($name, null, \true); - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\RuntimeException(\sprintf('The "-%s" option does not exist.', \false === $encoding ? $name[$i] : \mb_substr($name, $i, 1, $encoding))); + throw new RuntimeException(\sprintf('The "-%s" option does not exist.', \false === $encoding ? $name[$i] : \mb_substr($name, $i, 1, $encoding))); } $option = $this->definition->getOptionForShortcut($name[$i]); if ($option->acceptValue()) { @@ -174,7 +174,7 @@ class ArgvInput extends \RectorPrefix20220607\Symfony\Component\Console\Input\In } else { $message = \sprintf('No arguments expected, got "%s".', $token); } - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\RuntimeException($message); + throw new RuntimeException($message); } } /** @@ -186,7 +186,7 @@ class ArgvInput extends \RectorPrefix20220607\Symfony\Component\Console\Input\In private function addShortOption(string $shortcut, $value) { if (!$this->definition->hasShortcut($shortcut)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\RuntimeException(\sprintf('The "-%s" option does not exist.', $shortcut)); + throw new RuntimeException(\sprintf('The "-%s" option does not exist.', $shortcut)); } $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value); } @@ -200,18 +200,18 @@ class ArgvInput extends \RectorPrefix20220607\Symfony\Component\Console\Input\In { if (!$this->definition->hasOption($name)) { if (!$this->definition->hasNegation($name)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\RuntimeException(\sprintf('The "--%s" option does not exist.', $name)); + throw new RuntimeException(\sprintf('The "--%s" option does not exist.', $name)); } $optionName = $this->definition->negationToName($name); if (null !== $value) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\RuntimeException(\sprintf('The "--%s" option does not accept a value.', $name)); + throw new RuntimeException(\sprintf('The "--%s" option does not accept a value.', $name)); } $this->options[$optionName] = \false; return; } $option = $this->definition->getOption($name); if (null !== $value && !$option->acceptValue()) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\RuntimeException(\sprintf('The "--%s" option does not accept a value.', $name)); + throw new RuntimeException(\sprintf('The "--%s" option does not accept a value.', $name)); } if (\in_array($value, ['', null], \true) && $option->acceptValue() && \count($this->parsed)) { // if option accepts an optional or mandatory argument @@ -225,7 +225,7 @@ class ArgvInput extends \RectorPrefix20220607\Symfony\Component\Console\Input\In } if (null === $value) { if ($option->isValueRequired()) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\RuntimeException(\sprintf('The "--%s" option requires a value.', $name)); + throw new RuntimeException(\sprintf('The "--%s" option requires a value.', $name)); } if (!$option->isArray() && !$option->isValueOptional()) { $value = \true; diff --git a/vendor/symfony/console/Input/ArrayInput.php b/vendor/symfony/console/Input/ArrayInput.php index e26fd9d5f88..6e6dea1cf7f 100644 --- a/vendor/symfony/console/Input/ArrayInput.php +++ b/vendor/symfony/console/Input/ArrayInput.php @@ -21,13 +21,13 @@ use RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidOptionExcept * * @author Fabien Potencier */ -class ArrayInput extends \RectorPrefix20220607\Symfony\Component\Console\Input\Input +class ArrayInput extends Input { /** * @var mixed[] */ private $parameters; - public function __construct(array $parameters, \RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition $definition = null) + public function __construct(array $parameters, InputDefinition $definition = null) { $this->parameters = $parameters; parent::__construct($definition); @@ -137,7 +137,7 @@ class ArrayInput extends \RectorPrefix20220607\Symfony\Component\Console\Input\I private function addShortOption(string $shortcut, $value) { if (!$this->definition->hasShortcut($shortcut)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidOptionException(\sprintf('The "-%s" option does not exist.', $shortcut)); + throw new InvalidOptionException(\sprintf('The "-%s" option does not exist.', $shortcut)); } $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value); } @@ -152,7 +152,7 @@ class ArrayInput extends \RectorPrefix20220607\Symfony\Component\Console\Input\I { if (!$this->definition->hasOption($name)) { if (!$this->definition->hasNegation($name)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidOptionException(\sprintf('The "--%s" option does not exist.', $name)); + throw new InvalidOptionException(\sprintf('The "--%s" option does not exist.', $name)); } $optionName = $this->definition->negationToName($name); $this->options[$optionName] = \false; @@ -161,7 +161,7 @@ class ArrayInput extends \RectorPrefix20220607\Symfony\Component\Console\Input\I $option = $this->definition->getOption($name); if (null === $value) { if ($option->isValueRequired()) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidOptionException(\sprintf('The "--%s" option requires a value.', $name)); + throw new InvalidOptionException(\sprintf('The "--%s" option requires a value.', $name)); } if (!$option->isValueOptional()) { $value = \true; @@ -179,7 +179,7 @@ class ArrayInput extends \RectorPrefix20220607\Symfony\Component\Console\Input\I private function addArgument($name, $value) { if (!$this->definition->hasArgument($name)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('The "%s" argument does not exist.', $name)); + throw new InvalidArgumentException(\sprintf('The "%s" argument does not exist.', $name)); } $this->arguments[$name] = $value; } diff --git a/vendor/symfony/console/Input/Input.php b/vendor/symfony/console/Input/Input.php index 4fcd3642ef7..a32c92b30db 100644 --- a/vendor/symfony/console/Input/Input.php +++ b/vendor/symfony/console/Input/Input.php @@ -23,17 +23,17 @@ use RectorPrefix20220607\Symfony\Component\Console\Exception\RuntimeException; * * @author Fabien Potencier */ -abstract class Input implements \RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface, \RectorPrefix20220607\Symfony\Component\Console\Input\StreamableInputInterface +abstract class Input implements InputInterface, StreamableInputInterface { protected $definition; protected $stream; protected $options = []; protected $arguments = []; protected $interactive = \true; - public function __construct(\RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition $definition = null) + public function __construct(InputDefinition $definition = null) { if (null === $definition) { - $this->definition = new \RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition(); + $this->definition = new InputDefinition(); } else { $this->bind($definition); $this->validate(); @@ -42,7 +42,7 @@ abstract class Input implements \RectorPrefix20220607\Symfony\Component\Console\ /** * {@inheritdoc} */ - public function bind(\RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition $definition) + public function bind(InputDefinition $definition) { $this->arguments = []; $this->options = []; @@ -64,7 +64,7 @@ abstract class Input implements \RectorPrefix20220607\Symfony\Component\Console\ return !\array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired(); }); if (\count($missingArguments) > 0) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\RuntimeException(\sprintf('Not enough arguments (missing: "%s").', \implode(', ', $missingArguments))); + throw new RuntimeException(\sprintf('Not enough arguments (missing: "%s").', \implode(', ', $missingArguments))); } } /** @@ -95,7 +95,7 @@ abstract class Input implements \RectorPrefix20220607\Symfony\Component\Console\ public function getArgument(string $name) { if (!$this->definition->hasArgument($name)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('The "%s" argument does not exist.', $name)); + throw new InvalidArgumentException(\sprintf('The "%s" argument does not exist.', $name)); } return $this->arguments[$name] ?? $this->definition->getArgument($name)->getDefault(); } @@ -106,7 +106,7 @@ abstract class Input implements \RectorPrefix20220607\Symfony\Component\Console\ public function setArgument(string $name, $value) { if (!$this->definition->hasArgument($name)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('The "%s" argument does not exist.', $name)); + throw new InvalidArgumentException(\sprintf('The "%s" argument does not exist.', $name)); } $this->arguments[$name] = $value; } @@ -137,7 +137,7 @@ abstract class Input implements \RectorPrefix20220607\Symfony\Component\Console\ return !$value; } if (!$this->definition->hasOption($name)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('The "%s" option does not exist.', $name)); + throw new InvalidArgumentException(\sprintf('The "%s" option does not exist.', $name)); } return \array_key_exists($name, $this->options) ? $this->options[$name] : $this->definition->getOption($name)->getDefault(); } @@ -151,7 +151,7 @@ abstract class Input implements \RectorPrefix20220607\Symfony\Component\Console\ $this->options[$this->definition->negationToName($name)] = !$value; return; } elseif (!$this->definition->hasOption($name)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('The "%s" option does not exist.', $name)); + throw new InvalidArgumentException(\sprintf('The "%s" option does not exist.', $name)); } $this->options[$name] = $value; } diff --git a/vendor/symfony/console/Input/InputArgument.php b/vendor/symfony/console/Input/InputArgument.php index de56f4fc864..5b9367103ec 100644 --- a/vendor/symfony/console/Input/InputArgument.php +++ b/vendor/symfony/console/Input/InputArgument.php @@ -60,7 +60,7 @@ class InputArgument if (null === $mode) { $mode = self::OPTIONAL; } elseif ($mode > 7 || $mode < 1) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('Argument mode "%s" is not valid.', $mode)); + throw new InvalidArgumentException(\sprintf('Argument mode "%s" is not valid.', $mode)); } $this->name = $name; $this->mode = $mode; @@ -102,13 +102,13 @@ class InputArgument public function setDefault($default = null) { if ($this->isRequired() && null !== $default) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.'); + throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.'); } if ($this->isArray()) { if (null === $default) { $default = []; } elseif (!\is_array($default)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException('A default value for an array argument must be an array.'); + throw new LogicException('A default value for an array argument must be an array.'); } } $this->default = $default; @@ -130,11 +130,11 @@ class InputArgument * * @see Command::complete() */ - public function complete(\RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionInput $input, \RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionSuggestions $suggestions) : void + public function complete(CompletionInput $input, CompletionSuggestions $suggestions) : void { $values = $this->suggestedValues; if ($values instanceof \Closure && !\is_array($values = $values($input))) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException(\sprintf('Closure for argument "%s" must return an array. Got "%s".', $this->name, \get_debug_type($values))); + throw new LogicException(\sprintf('Closure for argument "%s" must return an array. Got "%s".', $this->name, \get_debug_type($values))); } if ($values) { $suggestions->suggestValues($values); diff --git a/vendor/symfony/console/Input/InputAwareInterface.php b/vendor/symfony/console/Input/InputAwareInterface.php index 9c43df478e3..ad36ebb7904 100644 --- a/vendor/symfony/console/Input/InputAwareInterface.php +++ b/vendor/symfony/console/Input/InputAwareInterface.php @@ -21,5 +21,5 @@ interface InputAwareInterface /** * Sets the Console Input. */ - public function setInput(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input); + public function setInput(InputInterface $input); } diff --git a/vendor/symfony/console/Input/InputDefinition.php b/vendor/symfony/console/Input/InputDefinition.php index 1caff4df486..1ffbfedbfcc 100644 --- a/vendor/symfony/console/Input/InputDefinition.php +++ b/vendor/symfony/console/Input/InputDefinition.php @@ -69,7 +69,7 @@ class InputDefinition $arguments = []; $options = []; foreach ($definition as $item) { - if ($item instanceof \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption) { + if ($item instanceof InputOption) { $options[] = $item; } else { $arguments[] = $item; @@ -107,16 +107,16 @@ class InputDefinition /** * @throws LogicException When incorrect argument is given */ - public function addArgument(\RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument $argument) + public function addArgument(InputArgument $argument) { if (isset($this->arguments[$argument->getName()])) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException(\sprintf('An argument with name "%s" already exists.', $argument->getName())); + throw new LogicException(\sprintf('An argument with name "%s" already exists.', $argument->getName())); } if (null !== $this->lastArrayArgument) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException(\sprintf('Cannot add a required argument "%s" after an array argument "%s".', $argument->getName(), $this->lastArrayArgument->getName())); + throw new LogicException(\sprintf('Cannot add a required argument "%s" after an array argument "%s".', $argument->getName(), $this->lastArrayArgument->getName())); } if ($argument->isRequired() && null !== $this->lastOptionalArgument) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException(\sprintf('Cannot add a required argument "%s" after an optional one "%s".', $argument->getName(), $this->lastOptionalArgument->getName())); + throw new LogicException(\sprintf('Cannot add a required argument "%s" after an optional one "%s".', $argument->getName(), $this->lastOptionalArgument->getName())); } if ($argument->isArray()) { $this->lastArrayArgument = $argument; @@ -134,10 +134,10 @@ class InputDefinition * @throws InvalidArgumentException When argument given doesn't exist * @param string|int $name */ - public function getArgument($name) : \RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument + public function getArgument($name) : InputArgument { if (!$this->hasArgument($name)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('The "%s" argument does not exist.', $name)); + throw new InvalidArgumentException(\sprintf('The "%s" argument does not exist.', $name)); } $arguments = \is_int($name) ? \array_values($this->arguments) : $this->arguments; return $arguments[$name]; @@ -211,18 +211,18 @@ class InputDefinition /** * @throws LogicException When option given already exist */ - public function addOption(\RectorPrefix20220607\Symfony\Component\Console\Input\InputOption $option) + public function addOption(InputOption $option) { if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException(\sprintf('An option named "%s" already exists.', $option->getName())); + throw new LogicException(\sprintf('An option named "%s" already exists.', $option->getName())); } if (isset($this->negations[$option->getName()])) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException(\sprintf('An option named "%s" already exists.', $option->getName())); + throw new LogicException(\sprintf('An option named "%s" already exists.', $option->getName())); } if ($option->getShortcut()) { foreach (\explode('|', $option->getShortcut()) as $shortcut) { if (isset($this->shortcuts[$shortcut]) && !$option->equals($this->options[$this->shortcuts[$shortcut]])) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException(\sprintf('An option with shortcut "%s" already exists.', $shortcut)); + throw new LogicException(\sprintf('An option with shortcut "%s" already exists.', $shortcut)); } } } @@ -235,7 +235,7 @@ class InputDefinition if ($option->isNegatable()) { $negatedName = 'no-' . $option->getName(); if (isset($this->options[$negatedName])) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException(\sprintf('An option named "%s" already exists.', $negatedName)); + throw new LogicException(\sprintf('An option named "%s" already exists.', $negatedName)); } $this->negations[$negatedName] = $option->getName(); } @@ -245,10 +245,10 @@ class InputDefinition * * @throws InvalidArgumentException When option given doesn't exist */ - public function getOption(string $name) : \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption + public function getOption(string $name) : InputOption { if (!$this->hasOption($name)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('The "--%s" option does not exist.', $name)); + throw new InvalidArgumentException(\sprintf('The "--%s" option does not exist.', $name)); } return $this->options[$name]; } @@ -288,7 +288,7 @@ class InputDefinition /** * Gets an InputOption by shortcut. */ - public function getOptionForShortcut(string $shortcut) : \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption + public function getOptionForShortcut(string $shortcut) : InputOption { return $this->getOption($this->shortcutToName($shortcut)); } @@ -313,7 +313,7 @@ class InputDefinition public function shortcutToName(string $shortcut) : string { if (!isset($this->shortcuts[$shortcut])) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('The "-%s" option does not exist.', $shortcut)); + throw new InvalidArgumentException(\sprintf('The "-%s" option does not exist.', $shortcut)); } return $this->shortcuts[$shortcut]; } @@ -327,7 +327,7 @@ class InputDefinition public function negationToName(string $negation) : string { if (!isset($this->negations[$negation])) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('The "--%s" option does not exist.', $negation)); + throw new InvalidArgumentException(\sprintf('The "--%s" option does not exist.', $negation)); } return $this->negations[$negation]; } diff --git a/vendor/symfony/console/Input/InputInterface.php b/vendor/symfony/console/Input/InputInterface.php index 51cbf8bd43e..188c7b30343 100644 --- a/vendor/symfony/console/Input/InputInterface.php +++ b/vendor/symfony/console/Input/InputInterface.php @@ -58,7 +58,7 @@ interface InputInterface * * @throws RuntimeException */ - public function bind(\RectorPrefix20220607\Symfony\Component\Console\Input\InputDefinition $definition); + public function bind(InputDefinition $definition); /** * Validates the input. * diff --git a/vendor/symfony/console/Input/InputOption.php b/vendor/symfony/console/Input/InputOption.php index f483c7d0656..5909fcf99f5 100644 --- a/vendor/symfony/console/Input/InputOption.php +++ b/vendor/symfony/console/Input/InputOption.php @@ -81,7 +81,7 @@ class InputOption $name = \substr($name, 2); } if (empty($name)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException('An option name cannot be empty.'); + throw new InvalidArgumentException('An option name cannot be empty.'); } if (empty($shortcut)) { $shortcut = null; @@ -94,13 +94,13 @@ class InputOption $shortcuts = \array_filter($shortcuts); $shortcut = \implode('|', $shortcuts); if (empty($shortcut)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException('An option shortcut cannot be empty.'); + throw new InvalidArgumentException('An option shortcut cannot be empty.'); } } if (null === $mode) { $mode = self::VALUE_NONE; } elseif ($mode >= self::VALUE_NEGATABLE << 1 || $mode < 1) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('Option mode "%s" is not valid.', $mode)); + throw new InvalidArgumentException(\sprintf('Option mode "%s" is not valid.', $mode)); } $this->name = $name; $this->shortcut = $shortcut; @@ -108,13 +108,13 @@ class InputOption $this->description = $description; $this->suggestedValues = $suggestedValues; if ($suggestedValues && !$this->acceptValue()) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException('Cannot set suggested values if the option does not accept a value.'); + throw new LogicException('Cannot set suggested values if the option does not accept a value.'); } if ($this->isArray() && !$this->acceptValue()) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.'); + throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.'); } if ($this->isNegatable() && $this->acceptValue()) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException('Impossible to have an option mode VALUE_NEGATABLE if the option also accepts a value.'); + throw new InvalidArgumentException('Impossible to have an option mode VALUE_NEGATABLE if the option also accepts a value.'); } $this->setDefault($default); } @@ -178,13 +178,13 @@ class InputOption public function setDefault($default = null) { if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.'); + throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.'); } if ($this->isArray()) { if (null === $default) { $default = []; } elseif (!\is_array($default)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException('A default value for an array option must be an array.'); + throw new LogicException('A default value for an array option must be an array.'); } } $this->default = $this->acceptValue() || $this->isNegatable() ? $default : \false; @@ -213,11 +213,11 @@ class InputOption * * @see Command::complete() */ - public function complete(\RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionInput $input, \RectorPrefix20220607\Symfony\Component\Console\Completion\CompletionSuggestions $suggestions) : void + public function complete(CompletionInput $input, CompletionSuggestions $suggestions) : void { $values = $this->suggestedValues; if ($values instanceof \Closure && !\is_array($values = $values($input))) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException(\sprintf('Closure for option "%s" must return an array. Got "%s".', $this->name, \get_debug_type($values))); + throw new LogicException(\sprintf('Closure for option "%s" must return an array. Got "%s".', $this->name, \get_debug_type($values))); } if ($values) { $suggestions->suggestValues($values); diff --git a/vendor/symfony/console/Input/StreamableInputInterface.php b/vendor/symfony/console/Input/StreamableInputInterface.php index 8b1a06e9299..1e2d54714d8 100644 --- a/vendor/symfony/console/Input/StreamableInputInterface.php +++ b/vendor/symfony/console/Input/StreamableInputInterface.php @@ -16,7 +16,7 @@ namespace RectorPrefix20220607\Symfony\Component\Console\Input; * * @author Robin Chalas */ -interface StreamableInputInterface extends \RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface +interface StreamableInputInterface extends InputInterface { /** * Sets the input stream to read from when interacting with the user. diff --git a/vendor/symfony/console/Input/StringInput.php b/vendor/symfony/console/Input/StringInput.php index b7c443bed72..253f8bbefe4 100644 --- a/vendor/symfony/console/Input/StringInput.php +++ b/vendor/symfony/console/Input/StringInput.php @@ -20,7 +20,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentExce * * @author Fabien Potencier */ -class StringInput extends \RectorPrefix20220607\Symfony\Component\Console\Input\ArgvInput +class StringInput extends ArgvInput { /** * @deprecated since Symfony 6.1 @@ -66,7 +66,7 @@ class StringInput extends \RectorPrefix20220607\Symfony\Component\Console\Input\ $token .= $match[1]; } else { // should never happen - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('Unable to parse input near "... %s ...".', \substr($input, $cursor, 10))); + throw new InvalidArgumentException(\sprintf('Unable to parse input near "... %s ...".', \substr($input, $cursor, 10))); } $cursor += \strlen($match[0]); } diff --git a/vendor/symfony/console/Logger/ConsoleLogger.php b/vendor/symfony/console/Logger/ConsoleLogger.php index 2a0b5a02016..132abc6ab9c 100644 --- a/vendor/symfony/console/Logger/ConsoleLogger.php +++ b/vendor/symfony/console/Logger/ConsoleLogger.php @@ -22,7 +22,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; * * @see https://www.php-fig.org/psr/psr-3/ */ -class ConsoleLogger extends \RectorPrefix20220607\Psr\Log\AbstractLogger +class ConsoleLogger extends AbstractLogger { public const INFO = 'info'; public const ERROR = 'error'; @@ -33,16 +33,16 @@ class ConsoleLogger extends \RectorPrefix20220607\Psr\Log\AbstractLogger /** * @var mixed[] */ - private $verbosityLevelMap = [\RectorPrefix20220607\Psr\Log\LogLevel::EMERGENCY => \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_NORMAL, \RectorPrefix20220607\Psr\Log\LogLevel::ALERT => \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_NORMAL, \RectorPrefix20220607\Psr\Log\LogLevel::CRITICAL => \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_NORMAL, \RectorPrefix20220607\Psr\Log\LogLevel::ERROR => \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_NORMAL, \RectorPrefix20220607\Psr\Log\LogLevel::WARNING => \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_NORMAL, \RectorPrefix20220607\Psr\Log\LogLevel::NOTICE => \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_VERBOSE, \RectorPrefix20220607\Psr\Log\LogLevel::INFO => \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_VERY_VERBOSE, \RectorPrefix20220607\Psr\Log\LogLevel::DEBUG => \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_DEBUG]; + private $verbosityLevelMap = [LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL, LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL, LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL, LogLevel::ERROR => OutputInterface::VERBOSITY_NORMAL, LogLevel::WARNING => OutputInterface::VERBOSITY_NORMAL, LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE, LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE, LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG]; /** * @var mixed[] */ - private $formatLevelMap = [\RectorPrefix20220607\Psr\Log\LogLevel::EMERGENCY => self::ERROR, \RectorPrefix20220607\Psr\Log\LogLevel::ALERT => self::ERROR, \RectorPrefix20220607\Psr\Log\LogLevel::CRITICAL => self::ERROR, \RectorPrefix20220607\Psr\Log\LogLevel::ERROR => self::ERROR, \RectorPrefix20220607\Psr\Log\LogLevel::WARNING => self::INFO, \RectorPrefix20220607\Psr\Log\LogLevel::NOTICE => self::INFO, \RectorPrefix20220607\Psr\Log\LogLevel::INFO => self::INFO, \RectorPrefix20220607\Psr\Log\LogLevel::DEBUG => self::INFO]; + private $formatLevelMap = [LogLevel::EMERGENCY => self::ERROR, LogLevel::ALERT => self::ERROR, LogLevel::CRITICAL => self::ERROR, LogLevel::ERROR => self::ERROR, LogLevel::WARNING => self::INFO, LogLevel::NOTICE => self::INFO, LogLevel::INFO => self::INFO, LogLevel::DEBUG => self::INFO]; /** * @var bool */ private $errored = \false; - public function __construct(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output, array $verbosityLevelMap = [], array $formatLevelMap = []) + public function __construct(OutputInterface $output, array $verbosityLevelMap = [], array $formatLevelMap = []) { $this->output = $output; $this->verbosityLevelMap = $verbosityLevelMap + $this->verbosityLevelMap; @@ -54,12 +54,12 @@ class ConsoleLogger extends \RectorPrefix20220607\Psr\Log\AbstractLogger public function log($level, $message, array $context = []) : void { if (!isset($this->verbosityLevelMap[$level])) { - throw new \RectorPrefix20220607\Psr\Log\InvalidArgumentException(\sprintf('The log level "%s" does not exist.', $level)); + throw new InvalidArgumentException(\sprintf('The log level "%s" does not exist.', $level)); } $output = $this->output; // Write to the error output if necessary and available if (self::ERROR === $this->formatLevelMap[$level]) { - if ($this->output instanceof \RectorPrefix20220607\Symfony\Component\Console\Output\ConsoleOutputInterface) { + if ($this->output instanceof ConsoleOutputInterface) { $output = $output->getErrorOutput(); } $this->errored = \true; diff --git a/vendor/symfony/console/Output/BufferedOutput.php b/vendor/symfony/console/Output/BufferedOutput.php index ea03ac6e72b..b19abe3bdc7 100644 --- a/vendor/symfony/console/Output/BufferedOutput.php +++ b/vendor/symfony/console/Output/BufferedOutput.php @@ -13,7 +13,7 @@ namespace RectorPrefix20220607\Symfony\Component\Console\Output; /** * @author Jean-François Simon */ -class BufferedOutput extends \RectorPrefix20220607\Symfony\Component\Console\Output\Output +class BufferedOutput extends Output { /** * @var string diff --git a/vendor/symfony/console/Output/ConsoleOutput.php b/vendor/symfony/console/Output/ConsoleOutput.php index 095511f37d2..48505d951a4 100644 --- a/vendor/symfony/console/Output/ConsoleOutput.php +++ b/vendor/symfony/console/Output/ConsoleOutput.php @@ -25,7 +25,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInte * * @author Fabien Potencier */ -class ConsoleOutput extends \RectorPrefix20220607\Symfony\Component\Console\Output\StreamOutput implements \RectorPrefix20220607\Symfony\Component\Console\Output\ConsoleOutputInterface +class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface { /** * @var \Symfony\Component\Console\Output\OutputInterface @@ -40,16 +40,16 @@ class ConsoleOutput extends \RectorPrefix20220607\Symfony\Component\Console\Outp * @param bool|null $decorated Whether to decorate messages (null for auto-guessing) * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) */ - public function __construct(int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter = null) + public function __construct(int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null) { parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter); if (null === $formatter) { // for BC reasons, stdErr has it own Formatter only when user don't inject a specific formatter. - $this->stderr = new \RectorPrefix20220607\Symfony\Component\Console\Output\StreamOutput($this->openErrorStream(), $verbosity, $decorated); + $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated); return; } $actualDecorated = $this->isDecorated(); - $this->stderr = new \RectorPrefix20220607\Symfony\Component\Console\Output\StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter()); + $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter()); if (null === $decorated) { $this->setDecorated($actualDecorated && $this->stderr->isDecorated()); } @@ -57,9 +57,9 @@ class ConsoleOutput extends \RectorPrefix20220607\Symfony\Component\Console\Outp /** * Creates a new output section. */ - public function section() : \RectorPrefix20220607\Symfony\Component\Console\Output\ConsoleSectionOutput + public function section() : ConsoleSectionOutput { - return new \RectorPrefix20220607\Symfony\Component\Console\Output\ConsoleSectionOutput($this->getStream(), $this->consoleSectionOutputs, $this->getVerbosity(), $this->isDecorated(), $this->getFormatter()); + return new ConsoleSectionOutput($this->getStream(), $this->consoleSectionOutputs, $this->getVerbosity(), $this->isDecorated(), $this->getFormatter()); } /** * {@inheritdoc} @@ -72,7 +72,7 @@ class ConsoleOutput extends \RectorPrefix20220607\Symfony\Component\Console\Outp /** * {@inheritdoc} */ - public function setFormatter(\RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter) + public function setFormatter(OutputFormatterInterface $formatter) { parent::setFormatter($formatter); $this->stderr->setFormatter($formatter); @@ -88,14 +88,14 @@ class ConsoleOutput extends \RectorPrefix20220607\Symfony\Component\Console\Outp /** * {@inheritdoc} */ - public function getErrorOutput() : \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface + public function getErrorOutput() : OutputInterface { return $this->stderr; } /** * {@inheritdoc} */ - public function setErrorOutput(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $error) + public function setErrorOutput(OutputInterface $error) { $this->stderr = $error; } diff --git a/vendor/symfony/console/Output/ConsoleOutputInterface.php b/vendor/symfony/console/Output/ConsoleOutputInterface.php index 6c7b88c9022..738b4e765a3 100644 --- a/vendor/symfony/console/Output/ConsoleOutputInterface.php +++ b/vendor/symfony/console/Output/ConsoleOutputInterface.php @@ -16,12 +16,12 @@ namespace RectorPrefix20220607\Symfony\Component\Console\Output; * * @author Dariusz Górecki */ -interface ConsoleOutputInterface extends \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface +interface ConsoleOutputInterface extends OutputInterface { /** * Gets the OutputInterface for errors. */ - public function getErrorOutput() : \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; - public function setErrorOutput(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $error); - public function section() : \RectorPrefix20220607\Symfony\Component\Console\Output\ConsoleSectionOutput; + public function getErrorOutput() : OutputInterface; + public function setErrorOutput(OutputInterface $error); + public function section() : ConsoleSectionOutput; } diff --git a/vendor/symfony/console/Output/ConsoleSectionOutput.php b/vendor/symfony/console/Output/ConsoleSectionOutput.php index 9cfe348dacc..4468c883188 100644 --- a/vendor/symfony/console/Output/ConsoleSectionOutput.php +++ b/vendor/symfony/console/Output/ConsoleSectionOutput.php @@ -17,7 +17,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Terminal; * @author Pierre du Plessis * @author Gabriel Ostrolucký */ -class ConsoleSectionOutput extends \RectorPrefix20220607\Symfony\Component\Console\Output\StreamOutput +class ConsoleSectionOutput extends StreamOutput { /** * @var mixed[] @@ -39,12 +39,12 @@ class ConsoleSectionOutput extends \RectorPrefix20220607\Symfony\Component\Conso * @param resource $stream * @param ConsoleSectionOutput[] $sections */ - public function __construct($stream, array &$sections, int $verbosity, bool $decorated, \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter) + public function __construct($stream, array &$sections, int $verbosity, bool $decorated, OutputFormatterInterface $formatter) { parent::__construct($stream, $verbosity, $decorated, $formatter); \array_unshift($sections, $this); $this->sections =& $sections; - $this->terminal = new \RectorPrefix20220607\Symfony\Component\Console\Terminal(); + $this->terminal = new Terminal(); } /** * Clears previous output for this section. @@ -121,14 +121,14 @@ class ConsoleSectionOutput extends \RectorPrefix20220607\Symfony\Component\Conso } if ($numberOfLinesToClear > 0) { // move cursor up n lines - parent::doWrite(\sprintf("\33[%dA", $numberOfLinesToClear), \false); + parent::doWrite(\sprintf("\x1b[%dA", $numberOfLinesToClear), \false); // erase to end of screen - parent::doWrite("\33[0J", \false); + parent::doWrite("\x1b[0J", \false); } return \implode('', \array_reverse($erasedContent)); } private function getDisplayLength(string $text) : int { - return \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width(\RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::removeDecoration($this->getFormatter(), \str_replace("\t", ' ', $text))); + return Helper::width(Helper::removeDecoration($this->getFormatter(), \str_replace("\t", ' ', $text))); } } diff --git a/vendor/symfony/console/Output/NullOutput.php b/vendor/symfony/console/Output/NullOutput.php index ff237c3ceec..bcf9adc44fb 100644 --- a/vendor/symfony/console/Output/NullOutput.php +++ b/vendor/symfony/console/Output/NullOutput.php @@ -20,7 +20,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInte * @author Fabien Potencier * @author Tobias Schultze */ -class NullOutput implements \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface +class NullOutput implements OutputInterface { /** * @var \Symfony\Component\Console\Formatter\NullOutputFormatter @@ -29,17 +29,17 @@ class NullOutput implements \RectorPrefix20220607\Symfony\Component\Console\Outp /** * {@inheritdoc} */ - public function setFormatter(\RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter) + public function setFormatter(OutputFormatterInterface $formatter) { // do nothing } /** * {@inheritdoc} */ - public function getFormatter() : \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInterface + public function getFormatter() : OutputFormatterInterface { // to comply with the interface we must return a OutputFormatterInterface - return $this->formatter = $this->formatter ?? new \RectorPrefix20220607\Symfony\Component\Console\Formatter\NullOutputFormatter(); + return $this->formatter = $this->formatter ?? new NullOutputFormatter(); } /** * {@inheritdoc} diff --git a/vendor/symfony/console/Output/Output.php b/vendor/symfony/console/Output/Output.php index e75e115f9d7..668012464a8 100644 --- a/vendor/symfony/console/Output/Output.php +++ b/vendor/symfony/console/Output/Output.php @@ -25,7 +25,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInte * * @author Fabien Potencier */ -abstract class Output implements \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface +abstract class Output implements OutputInterface { /** * @var int @@ -40,23 +40,23 @@ abstract class Output implements \RectorPrefix20220607\Symfony\Component\Console * @param bool $decorated Whether to decorate messages * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) */ - public function __construct(?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = \false, \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter = null) + public function __construct(?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = \false, OutputFormatterInterface $formatter = null) { $this->verbosity = $verbosity ?? self::VERBOSITY_NORMAL; - $this->formatter = $formatter ?? new \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatter(); + $this->formatter = $formatter ?? new OutputFormatter(); $this->formatter->setDecorated($decorated); } /** * {@inheritdoc} */ - public function setFormatter(\RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter) + public function setFormatter(OutputFormatterInterface $formatter) { $this->formatter = $formatter; } /** * {@inheritdoc} */ - public function getFormatter() : \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInterface + public function getFormatter() : OutputFormatterInterface { return $this->formatter; } @@ -142,12 +142,12 @@ abstract class Output implements \RectorPrefix20220607\Symfony\Component\Console } foreach ($messages as $message) { switch ($type) { - case \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::OUTPUT_NORMAL: + case OutputInterface::OUTPUT_NORMAL: $message = $this->formatter->format($message); break; - case \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::OUTPUT_RAW: + case OutputInterface::OUTPUT_RAW: break; - case \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::OUTPUT_PLAIN: + case OutputInterface::OUTPUT_PLAIN: $message = \strip_tags($this->formatter->format($message)); break; } diff --git a/vendor/symfony/console/Output/OutputInterface.php b/vendor/symfony/console/Output/OutputInterface.php index 06210e57424..3ebb41b9ffa 100644 --- a/vendor/symfony/console/Output/OutputInterface.php +++ b/vendor/symfony/console/Output/OutputInterface.php @@ -71,9 +71,9 @@ interface OutputInterface * Gets the decorated flag. */ public function isDecorated() : bool; - public function setFormatter(\RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter); + public function setFormatter(OutputFormatterInterface $formatter); /** * Returns current output formatter instance. */ - public function getFormatter() : \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInterface; + public function getFormatter() : OutputFormatterInterface; } diff --git a/vendor/symfony/console/Output/StreamOutput.php b/vendor/symfony/console/Output/StreamOutput.php index 8c308cefd5e..b853809840e 100644 --- a/vendor/symfony/console/Output/StreamOutput.php +++ b/vendor/symfony/console/Output/StreamOutput.php @@ -25,7 +25,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInte * * @author Fabien Potencier */ -class StreamOutput extends \RectorPrefix20220607\Symfony\Component\Console\Output\Output +class StreamOutput extends Output { private $stream; /** @@ -36,10 +36,10 @@ class StreamOutput extends \RectorPrefix20220607\Symfony\Component\Console\Outpu * * @throws InvalidArgumentException When first argument is not a real stream */ - public function __construct($stream, int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter = null) + public function __construct($stream, int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null) { if (!\is_resource($stream) || 'stream' !== \get_resource_type($stream)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException('The StreamOutput class needs a stream as its first argument.'); + throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.'); } $this->stream = $stream; if (null === $decorated) { diff --git a/vendor/symfony/console/Output/TrimmedBufferOutput.php b/vendor/symfony/console/Output/TrimmedBufferOutput.php index 66bcfa0e359..7ad06e79dbb 100644 --- a/vendor/symfony/console/Output/TrimmedBufferOutput.php +++ b/vendor/symfony/console/Output/TrimmedBufferOutput.php @@ -17,7 +17,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInte * * @author Jérémy Derussé */ -class TrimmedBufferOutput extends \RectorPrefix20220607\Symfony\Component\Console\Output\Output +class TrimmedBufferOutput extends Output { /** * @var int @@ -27,10 +27,10 @@ class TrimmedBufferOutput extends \RectorPrefix20220607\Symfony\Component\Consol * @var string */ private $buffer = ''; - public function __construct(int $maxLength, ?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = \false, \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter = null) + public function __construct(int $maxLength, ?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = \false, OutputFormatterInterface $formatter = null) { if ($maxLength <= 0) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('"%s()" expects a strictly positive maxLength. Got %d.', __METHOD__, $maxLength)); + throw new InvalidArgumentException(\sprintf('"%s()" expects a strictly positive maxLength. Got %d.', __METHOD__, $maxLength)); } parent::__construct($verbosity, $decorated, $formatter); $this->maxLength = $maxLength; diff --git a/vendor/symfony/console/Question/ChoiceQuestion.php b/vendor/symfony/console/Question/ChoiceQuestion.php index eb59da566c8..c0f969335f7 100644 --- a/vendor/symfony/console/Question/ChoiceQuestion.php +++ b/vendor/symfony/console/Question/ChoiceQuestion.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentExce * * @author Fabien Potencier */ -class ChoiceQuestion extends \RectorPrefix20220607\Symfony\Component\Console\Question\Question +class ChoiceQuestion extends Question { /** * @var mixed[] @@ -116,7 +116,7 @@ class ChoiceQuestion extends \RectorPrefix20220607\Symfony\Component\Console\Que if ($multiselect) { // Check for a separated comma values if (!\preg_match('/^[^,]+(?:,[^,]+)*$/', (string) $selected, $matches)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf($errorMessage, $selected)); + throw new InvalidArgumentException(\sprintf($errorMessage, $selected)); } $selectedChoices = \explode(',', (string) $selected); } else { @@ -136,7 +136,7 @@ class ChoiceQuestion extends \RectorPrefix20220607\Symfony\Component\Console\Que } } if (\count($results) > 1) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf('The provided answer is ambiguous. Value should be one of "%s".', \implode('" or "', $results))); + throw new InvalidArgumentException(\sprintf('The provided answer is ambiguous. Value should be one of "%s".', \implode('" or "', $results))); } $result = \array_search($value, $choices); if (!$isAssoc) { @@ -149,7 +149,7 @@ class ChoiceQuestion extends \RectorPrefix20220607\Symfony\Component\Console\Que $result = $value; } if (\false === $result) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException(\sprintf($errorMessage, $value)); + throw new InvalidArgumentException(\sprintf($errorMessage, $value)); } // For associative choices, consistently return the key as string: $multiselectChoices[] = $isAssoc ? (string) $result : $result; diff --git a/vendor/symfony/console/Question/ConfirmationQuestion.php b/vendor/symfony/console/Question/ConfirmationQuestion.php index f3024fd2397..7a8567c94bb 100644 --- a/vendor/symfony/console/Question/ConfirmationQuestion.php +++ b/vendor/symfony/console/Question/ConfirmationQuestion.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Symfony\Component\Console\Question; * * @author Fabien Potencier */ -class ConfirmationQuestion extends \RectorPrefix20220607\Symfony\Component\Console\Question\Question +class ConfirmationQuestion extends Question { /** * @var string diff --git a/vendor/symfony/console/Question/Question.php b/vendor/symfony/console/Question/Question.php index 8ac676b7e3d..8e7c2a9f691 100644 --- a/vendor/symfony/console/Question/Question.php +++ b/vendor/symfony/console/Question/Question.php @@ -117,7 +117,7 @@ class Question public function setHidden(bool $hidden) { if ($this->autocompleterCallback) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException('A hidden question cannot use the autocompleter.'); + throw new LogicException('A hidden question cannot use the autocompleter.'); } $this->hidden = $hidden; return $this; @@ -188,7 +188,7 @@ class Question public function setAutocompleterCallback(callable $callback = null) { if ($this->hidden && null !== $callback) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\LogicException('A hidden question cannot use the autocompleter.'); + throw new LogicException('A hidden question cannot use the autocompleter.'); } $this->autocompleterCallback = null === $callback ? null : \Closure::fromCallable($callback); return $this; @@ -222,7 +222,7 @@ class Question public function setMaxAttempts(?int $attempts) { if (null !== $attempts && $attempts < 1) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException('Maximum number of attempts must be a positive value.'); + throw new InvalidArgumentException('Maximum number of attempts must be a positive value.'); } $this->attempts = $attempts; return $this; diff --git a/vendor/symfony/console/SingleCommandApplication.php b/vendor/symfony/console/SingleCommandApplication.php index e2c4ed06437..1a3590d2ca3 100644 --- a/vendor/symfony/console/SingleCommandApplication.php +++ b/vendor/symfony/console/SingleCommandApplication.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; /** * @author Grégoire Pineau */ -class SingleCommandApplication extends \RectorPrefix20220607\Symfony\Component\Console\Command\Command +class SingleCommandApplication extends Command { /** * @var string @@ -48,13 +48,13 @@ class SingleCommandApplication extends \RectorPrefix20220607\Symfony\Component\C $this->autoExit = $autoExit; return $this; } - public function run(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input = null, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output = null) : int + public function run(InputInterface $input = null, OutputInterface $output = null) : int { if ($this->running) { return parent::run($input, $output); } // We use the command name as the application name - $application = new \RectorPrefix20220607\Symfony\Component\Console\Application($this->getName() ?: 'UNKNOWN', $this->version); + $application = new Application($this->getName() ?: 'UNKNOWN', $this->version); $application->setAutoExit($this->autoExit); // Fix the usage of the command displayed with "--help" $this->setName($_SERVER['argv'][0]); diff --git a/vendor/symfony/console/Style/OutputStyle.php b/vendor/symfony/console/Style/OutputStyle.php index d67e4b0c6bb..ec53c5738a3 100644 --- a/vendor/symfony/console/Style/OutputStyle.php +++ b/vendor/symfony/console/Style/OutputStyle.php @@ -19,13 +19,13 @@ use RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface; * * @author Kevin Bond */ -abstract class OutputStyle implements \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface, \RectorPrefix20220607\Symfony\Component\Console\Style\StyleInterface +abstract class OutputStyle implements OutputInterface, StyleInterface { /** * @var \Symfony\Component\Console\Output\OutputInterface */ private $output; - public function __construct(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) + public function __construct(OutputInterface $output) { $this->output = $output; } @@ -36,9 +36,9 @@ abstract class OutputStyle implements \RectorPrefix20220607\Symfony\Component\Co { $this->output->write(\str_repeat(\PHP_EOL, $count)); } - public function createProgressBar(int $max = 0) : \RectorPrefix20220607\Symfony\Component\Console\Helper\ProgressBar + public function createProgressBar(int $max = 0) : ProgressBar { - return new \RectorPrefix20220607\Symfony\Component\Console\Helper\ProgressBar($this->output, $max); + return new ProgressBar($this->output, $max); } /** * {@inheritdoc} @@ -87,14 +87,14 @@ abstract class OutputStyle implements \RectorPrefix20220607\Symfony\Component\Co /** * {@inheritdoc} */ - public function setFormatter(\RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter) + public function setFormatter(OutputFormatterInterface $formatter) { $this->output->setFormatter($formatter); } /** * {@inheritdoc} */ - public function getFormatter() : \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatterInterface + public function getFormatter() : OutputFormatterInterface { return $this->output->getFormatter(); } @@ -128,7 +128,7 @@ abstract class OutputStyle implements \RectorPrefix20220607\Symfony\Component\Co } protected function getErrorOutput() { - if (!$this->output instanceof \RectorPrefix20220607\Symfony\Component\Console\Output\ConsoleOutputInterface) { + if (!$this->output instanceof ConsoleOutputInterface) { return $this->output; } return $this->output->getErrorOutput(); diff --git a/vendor/symfony/console/Style/SymfonyStyle.php b/vendor/symfony/console/Style/SymfonyStyle.php index 420bdc35bee..7f8766ceac3 100644 --- a/vendor/symfony/console/Style/SymfonyStyle.php +++ b/vendor/symfony/console/Style/SymfonyStyle.php @@ -32,7 +32,7 @@ use RectorPrefix20220607\Symfony\Component\Console\Terminal; * * @author Kevin Bond */ -class SymfonyStyle extends \RectorPrefix20220607\Symfony\Component\Console\Style\OutputStyle +class SymfonyStyle extends OutputStyle { public const MAX_LINE_LENGTH = 120; /** @@ -59,12 +59,12 @@ class SymfonyStyle extends \RectorPrefix20220607\Symfony\Component\Console\Style * @var \Symfony\Component\Console\Output\TrimmedBufferOutput */ private $bufferedOutput; - public function __construct(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) + public function __construct(InputInterface $input, OutputInterface $output) { $this->input = $input; - $this->bufferedOutput = new \RectorPrefix20220607\Symfony\Component\Console\Output\TrimmedBufferOutput(\DIRECTORY_SEPARATOR === '\\' ? 4 : 2, $output->getVerbosity(), \false, clone $output->getFormatter()); + $this->bufferedOutput = new TrimmedBufferOutput(\DIRECTORY_SEPARATOR === '\\' ? 4 : 2, $output->getVerbosity(), \false, clone $output->getFormatter()); // Windows cmd wraps lines as soon as the terminal width is reached, whether there are following chars or not. - $width = (new \RectorPrefix20220607\Symfony\Component\Console\Terminal())->getWidth() ?: self::MAX_LINE_LENGTH; + $width = (new Terminal())->getWidth() ?: self::MAX_LINE_LENGTH; $this->lineLength = \min($width - (int) (\DIRECTORY_SEPARATOR === '\\'), self::MAX_LINE_LENGTH); parent::__construct($this->output = $output); } @@ -85,7 +85,7 @@ class SymfonyStyle extends \RectorPrefix20220607\Symfony\Component\Console\Style public function title(string $message) { $this->autoPrependBlock(); - $this->writeln([\sprintf('%s', \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatter::escapeTrailingBackslash($message)), \sprintf('%s', \str_repeat('=', \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width(\RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::removeDecoration($this->getFormatter(), $message))))]); + $this->writeln([\sprintf('%s', OutputFormatter::escapeTrailingBackslash($message)), \sprintf('%s', \str_repeat('=', Helper::width(Helper::removeDecoration($this->getFormatter(), $message))))]); $this->newLine(); } /** @@ -94,7 +94,7 @@ class SymfonyStyle extends \RectorPrefix20220607\Symfony\Component\Console\Style public function section(string $message) { $this->autoPrependBlock(); - $this->writeln([\sprintf('%s', \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatter::escapeTrailingBackslash($message)), \sprintf('%s', \str_repeat('-', \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width(\RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::removeDecoration($this->getFormatter(), $message))))]); + $this->writeln([\sprintf('%s', OutputFormatter::escapeTrailingBackslash($message)), \sprintf('%s', \str_repeat('-', Helper::width(Helper::removeDecoration($this->getFormatter(), $message))))]); $this->newLine(); } /** @@ -207,18 +207,18 @@ class SymfonyStyle extends \RectorPrefix20220607\Symfony\Component\Console\Style $headers = []; $row = []; foreach ($list as $value) { - if ($value instanceof \RectorPrefix20220607\Symfony\Component\Console\Helper\TableSeparator) { + if ($value instanceof TableSeparator) { $headers[] = $value; $row[] = $value; continue; } if (\is_string($value)) { - $headers[] = new \RectorPrefix20220607\Symfony\Component\Console\Helper\TableCell($value, ['colspan' => 2]); + $headers[] = new TableCell($value, ['colspan' => 2]); $row[] = null; continue; } if (!\is_array($value)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\InvalidArgumentException('Value should be an array, string, or an instance of TableSeparator.'); + throw new InvalidArgumentException('Value should be an array, string, or an instance of TableSeparator.'); } $headers[] = \key($value); $row[] = \current($value); @@ -231,7 +231,7 @@ class SymfonyStyle extends \RectorPrefix20220607\Symfony\Component\Console\Style */ public function ask(string $question, string $default = null, callable $validator = null) { - $question = new \RectorPrefix20220607\Symfony\Component\Console\Question\Question($question, $default); + $question = new Question($question, $default); $question->setValidator($validator); return $this->askQuestion($question); } @@ -241,7 +241,7 @@ class SymfonyStyle extends \RectorPrefix20220607\Symfony\Component\Console\Style */ public function askHidden(string $question, callable $validator = null) { - $question = new \RectorPrefix20220607\Symfony\Component\Console\Question\Question($question); + $question = new Question($question); $question->setHidden(\true); $question->setValidator($validator); return $this->askQuestion($question); @@ -251,7 +251,7 @@ class SymfonyStyle extends \RectorPrefix20220607\Symfony\Component\Console\Style */ public function confirm(string $question, bool $default = \true) : bool { - return $this->askQuestion(new \RectorPrefix20220607\Symfony\Component\Console\Question\ConfirmationQuestion($question, $default)); + return $this->askQuestion(new ConfirmationQuestion($question, $default)); } /** * {@inheritdoc} @@ -264,7 +264,7 @@ class SymfonyStyle extends \RectorPrefix20220607\Symfony\Component\Console\Style $values = \array_flip($choices); $default = $values[$default] ?? $default; } - return $this->askQuestion(new \RectorPrefix20220607\Symfony\Component\Console\Question\ChoiceQuestion($question, $choices, $default)); + return $this->askQuestion(new ChoiceQuestion($question, $choices, $default)); } /** * {@inheritdoc} @@ -293,7 +293,7 @@ class SymfonyStyle extends \RectorPrefix20220607\Symfony\Component\Console\Style /** * {@inheritdoc} */ - public function createProgressBar(int $max = 0) : \RectorPrefix20220607\Symfony\Component\Console\Helper\ProgressBar + public function createProgressBar(int $max = 0) : ProgressBar { $progressBar = parent::createProgressBar($max); if ('\\' !== \DIRECTORY_SEPARATOR || 'Hyper' === \getenv('TERM_PROGRAM')) { @@ -316,12 +316,12 @@ class SymfonyStyle extends \RectorPrefix20220607\Symfony\Component\Console\Style /** * @return mixed */ - public function askQuestion(\RectorPrefix20220607\Symfony\Component\Console\Question\Question $question) + public function askQuestion(Question $question) { if ($this->input->isInteractive()) { $this->autoPrependBlock(); } - $this->questionHelper = $this->questionHelper ?? new \RectorPrefix20220607\Symfony\Component\Console\Helper\SymfonyQuestionHelper(); + $this->questionHelper = $this->questionHelper ?? new SymfonyQuestionHelper(); $answer = $this->questionHelper->ask($this->input, $this, $question); if ($this->input->isInteractive()) { $this->newLine(); @@ -372,17 +372,17 @@ class SymfonyStyle extends \RectorPrefix20220607\Symfony\Component\Console\Style { return new self($this->input, $this->getErrorOutput()); } - public function createTable() : \RectorPrefix20220607\Symfony\Component\Console\Helper\Table + public function createTable() : Table { - $output = $this->output instanceof \RectorPrefix20220607\Symfony\Component\Console\Output\ConsoleOutputInterface ? $this->output->section() : $this->output; - $style = clone \RectorPrefix20220607\Symfony\Component\Console\Helper\Table::getStyleDefinition('symfony-style-guide'); + $output = $this->output instanceof ConsoleOutputInterface ? $this->output->section() : $this->output; + $style = clone Table::getStyleDefinition('symfony-style-guide'); $style->setCellHeaderFormat('%s'); - return (new \RectorPrefix20220607\Symfony\Component\Console\Helper\Table($output))->setStyle($style); + return (new Table($output))->setStyle($style); } - private function getProgressBar() : \RectorPrefix20220607\Symfony\Component\Console\Helper\ProgressBar + private function getProgressBar() : ProgressBar { if (!isset($this->progressBar)) { - throw new \RectorPrefix20220607\Symfony\Component\Console\Exception\RuntimeException('The ProgressBar is not started.'); + throw new RuntimeException('The ProgressBar is not started.'); } return $this->progressBar; } @@ -413,7 +413,7 @@ class SymfonyStyle extends \RectorPrefix20220607\Symfony\Component\Console\Style private function createBlock(iterable $messages, string $type = null, string $style = null, string $prefix = ' ', bool $padding = \false, bool $escape = \false) : array { $indentLength = 0; - $prefixLength = \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width(\RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::removeDecoration($this->getFormatter(), $prefix)); + $prefixLength = Helper::width(Helper::removeDecoration($this->getFormatter(), $prefix)); $lines = []; if (null !== $type) { $type = \sprintf('[%s] ', $type); @@ -423,9 +423,9 @@ class SymfonyStyle extends \RectorPrefix20220607\Symfony\Component\Console\Style // wrap and add newlines for each element foreach ($messages as $key => $message) { if ($escape) { - $message = \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatter::escape($message); + $message = OutputFormatter::escape($message); } - $decorationLength = \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width($message) - \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width(\RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::removeDecoration($this->getFormatter(), $message)); + $decorationLength = Helper::width($message) - Helper::width(Helper::removeDecoration($this->getFormatter(), $message)); $messageLineLength = \min($this->lineLength - $prefixLength - $indentLength + $decorationLength, $this->lineLength); $messageLines = \explode(\PHP_EOL, \wordwrap($message, $messageLineLength, \PHP_EOL, \true)); foreach ($messageLines as $messageLine) { @@ -446,7 +446,7 @@ class SymfonyStyle extends \RectorPrefix20220607\Symfony\Component\Console\Style $line = $firstLineIndex === $i ? $type . $line : $lineIndentation . $line; } $line = $prefix . $line; - $line .= \str_repeat(' ', \max($this->lineLength - \RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::width(\RectorPrefix20220607\Symfony\Component\Console\Helper\Helper::removeDecoration($this->getFormatter(), $line)), 0)); + $line .= \str_repeat(' ', \max($this->lineLength - Helper::width(Helper::removeDecoration($this->getFormatter(), $line)), 0)); if ($style) { $line = \sprintf('<%s>%s', $style, $line); } diff --git a/vendor/symfony/contracts/Cache/CacheTrait.php b/vendor/symfony/contracts/Cache/CacheTrait.php index 70412f98715..2620a358c2e 100644 --- a/vendor/symfony/contracts/Cache/CacheTrait.php +++ b/vendor/symfony/contracts/Cache/CacheTrait.php @@ -14,7 +14,7 @@ use RectorPrefix20220607\Psr\Cache\CacheItemPoolInterface; use RectorPrefix20220607\Psr\Cache\InvalidArgumentException; use RectorPrefix20220607\Psr\Log\LoggerInterface; // Help opcache.preload discover always-needed symbols -\class_exists(\RectorPrefix20220607\Psr\Cache\InvalidArgumentException::class); +\class_exists(InvalidArgumentException::class); /** * An implementation of CacheInterface for PSR-6 CacheItemPoolInterface classes. * @@ -36,19 +36,19 @@ trait CacheTrait { return $this->deleteItem($key); } - private function doGet(\RectorPrefix20220607\Psr\Cache\CacheItemPoolInterface $pool, string $key, callable $callback, ?float $beta, array &$metadata = null, \RectorPrefix20220607\Psr\Log\LoggerInterface $logger = null) : mixed + private function doGet(CacheItemPoolInterface $pool, string $key, callable $callback, ?float $beta, array &$metadata = null, LoggerInterface $logger = null) : mixed { if (0 > ($beta ??= 1.0)) { - throw new class(\sprintf('Argument "$beta" provided to "%s::get()" must be a positive number, %f given.', static::class, $beta)) extends \InvalidArgumentException implements \RectorPrefix20220607\Psr\Cache\InvalidArgumentException + throw new class(\sprintf('Argument "$beta" provided to "%s::get()" must be a positive number, %f given.', static::class, $beta)) extends \InvalidArgumentException implements InvalidArgumentException { }; } $item = $pool->getItem($key); $recompute = !$item->isHit() || \INF === $beta; - $metadata = $item instanceof \RectorPrefix20220607\Symfony\Contracts\Cache\ItemInterface ? $item->getMetadata() : []; + $metadata = $item instanceof ItemInterface ? $item->getMetadata() : []; if (!$recompute && $metadata) { - $expiry = $metadata[\RectorPrefix20220607\Symfony\Contracts\Cache\ItemInterface::METADATA_EXPIRY] ?? \false; - $ctime = $metadata[\RectorPrefix20220607\Symfony\Contracts\Cache\ItemInterface::METADATA_CTIME] ?? \false; + $expiry = $metadata[ItemInterface::METADATA_EXPIRY] ?? \false; + $ctime = $metadata[ItemInterface::METADATA_CTIME] ?? \false; if ($recompute = $ctime && $expiry && $expiry <= ($now = \microtime(\true)) - $ctime / 1000 * $beta * \log(\random_int(1, \PHP_INT_MAX) / \PHP_INT_MAX)) { // force applying defaultLifetime to expiry $item->expiresAt(null); diff --git a/vendor/symfony/contracts/Cache/CallbackInterface.php b/vendor/symfony/contracts/Cache/CallbackInterface.php index d456850f449..4ff41f3012a 100644 --- a/vendor/symfony/contracts/Cache/CallbackInterface.php +++ b/vendor/symfony/contracts/Cache/CallbackInterface.php @@ -24,5 +24,5 @@ interface CallbackInterface * * @return mixed The computed value for the passed item */ - public function __invoke(\RectorPrefix20220607\Psr\Cache\CacheItemInterface $item, bool &$save) : mixed; + public function __invoke(CacheItemInterface $item, bool &$save) : mixed; } diff --git a/vendor/symfony/contracts/Cache/TagAwareCacheInterface.php b/vendor/symfony/contracts/Cache/TagAwareCacheInterface.php index a1c0c557e04..6dd9e251411 100644 --- a/vendor/symfony/contracts/Cache/TagAwareCacheInterface.php +++ b/vendor/symfony/contracts/Cache/TagAwareCacheInterface.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Psr\Cache\InvalidArgumentException; * * @author Nicolas Grekas */ -interface TagAwareCacheInterface extends \RectorPrefix20220607\Symfony\Contracts\Cache\CacheInterface +interface TagAwareCacheInterface extends CacheInterface { /** * Invalidates cached items using tags. diff --git a/vendor/symfony/contracts/EventDispatcher/Event.php b/vendor/symfony/contracts/EventDispatcher/Event.php index ae0aef67df3..fd7b7d20d86 100644 --- a/vendor/symfony/contracts/EventDispatcher/Event.php +++ b/vendor/symfony/contracts/EventDispatcher/Event.php @@ -26,7 +26,7 @@ use RectorPrefix20220607\Psr\EventDispatcher\StoppableEventInterface; * @author Bernhard Schussek * @author Nicolas Grekas */ -class Event implements \RectorPrefix20220607\Psr\EventDispatcher\StoppableEventInterface +class Event implements StoppableEventInterface { /** * @var bool diff --git a/vendor/symfony/contracts/EventDispatcher/EventDispatcherInterface.php b/vendor/symfony/contracts/EventDispatcher/EventDispatcherInterface.php index 86d6eb184cf..a13b3af17a3 100644 --- a/vendor/symfony/contracts/EventDispatcher/EventDispatcherInterface.php +++ b/vendor/symfony/contracts/EventDispatcher/EventDispatcherInterface.php @@ -14,7 +14,7 @@ use RectorPrefix20220607\Psr\EventDispatcher\EventDispatcherInterface as PsrEven /** * Allows providing hooks on domain-specific lifecycles by dispatching events. */ -interface EventDispatcherInterface extends \RectorPrefix20220607\Psr\EventDispatcher\EventDispatcherInterface +interface EventDispatcherInterface extends PsrEventDispatcherInterface { /** * Dispatches an event to all registered listeners. diff --git a/vendor/symfony/contracts/HttpClient/Exception/ClientExceptionInterface.php b/vendor/symfony/contracts/HttpClient/Exception/ClientExceptionInterface.php index 5fae89c646f..5110a0a3758 100644 --- a/vendor/symfony/contracts/HttpClient/Exception/ClientExceptionInterface.php +++ b/vendor/symfony/contracts/HttpClient/Exception/ClientExceptionInterface.php @@ -15,6 +15,6 @@ namespace RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception; * * @author Nicolas Grekas */ -interface ClientExceptionInterface extends \RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\HttpExceptionInterface +interface ClientExceptionInterface extends HttpExceptionInterface { } diff --git a/vendor/symfony/contracts/HttpClient/Exception/DecodingExceptionInterface.php b/vendor/symfony/contracts/HttpClient/Exception/DecodingExceptionInterface.php index b4b42e78d2e..6477ae74d06 100644 --- a/vendor/symfony/contracts/HttpClient/Exception/DecodingExceptionInterface.php +++ b/vendor/symfony/contracts/HttpClient/Exception/DecodingExceptionInterface.php @@ -15,6 +15,6 @@ namespace RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception; * * @author Nicolas Grekas */ -interface DecodingExceptionInterface extends \RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\ExceptionInterface +interface DecodingExceptionInterface extends ExceptionInterface { } diff --git a/vendor/symfony/contracts/HttpClient/Exception/HttpExceptionInterface.php b/vendor/symfony/contracts/HttpClient/Exception/HttpExceptionInterface.php index b462195b548..dc429641964 100644 --- a/vendor/symfony/contracts/HttpClient/Exception/HttpExceptionInterface.php +++ b/vendor/symfony/contracts/HttpClient/Exception/HttpExceptionInterface.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Symfony\Contracts\HttpClient\ResponseInterface; * * @author Anton Chernikov */ -interface HttpExceptionInterface extends \RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\ExceptionInterface +interface HttpExceptionInterface extends ExceptionInterface { - public function getResponse() : \RectorPrefix20220607\Symfony\Contracts\HttpClient\ResponseInterface; + public function getResponse() : ResponseInterface; } diff --git a/vendor/symfony/contracts/HttpClient/Exception/RedirectionExceptionInterface.php b/vendor/symfony/contracts/HttpClient/Exception/RedirectionExceptionInterface.php index f4a6c0df35a..155cc781bc9 100644 --- a/vendor/symfony/contracts/HttpClient/Exception/RedirectionExceptionInterface.php +++ b/vendor/symfony/contracts/HttpClient/Exception/RedirectionExceptionInterface.php @@ -15,6 +15,6 @@ namespace RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception; * * @author Nicolas Grekas */ -interface RedirectionExceptionInterface extends \RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\HttpExceptionInterface +interface RedirectionExceptionInterface extends HttpExceptionInterface { } diff --git a/vendor/symfony/contracts/HttpClient/Exception/ServerExceptionInterface.php b/vendor/symfony/contracts/HttpClient/Exception/ServerExceptionInterface.php index e106d8ab19a..56ffc151235 100644 --- a/vendor/symfony/contracts/HttpClient/Exception/ServerExceptionInterface.php +++ b/vendor/symfony/contracts/HttpClient/Exception/ServerExceptionInterface.php @@ -15,6 +15,6 @@ namespace RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception; * * @author Nicolas Grekas */ -interface ServerExceptionInterface extends \RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\HttpExceptionInterface +interface ServerExceptionInterface extends HttpExceptionInterface { } diff --git a/vendor/symfony/contracts/HttpClient/Exception/TimeoutExceptionInterface.php b/vendor/symfony/contracts/HttpClient/Exception/TimeoutExceptionInterface.php index 46939d8d3af..66a3aa23440 100644 --- a/vendor/symfony/contracts/HttpClient/Exception/TimeoutExceptionInterface.php +++ b/vendor/symfony/contracts/HttpClient/Exception/TimeoutExceptionInterface.php @@ -15,6 +15,6 @@ namespace RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception; * * @author Nicolas Grekas */ -interface TimeoutExceptionInterface extends \RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface +interface TimeoutExceptionInterface extends TransportExceptionInterface { } diff --git a/vendor/symfony/contracts/HttpClient/Exception/TransportExceptionInterface.php b/vendor/symfony/contracts/HttpClient/Exception/TransportExceptionInterface.php index bf022b2a0e2..a48b5cb277a 100644 --- a/vendor/symfony/contracts/HttpClient/Exception/TransportExceptionInterface.php +++ b/vendor/symfony/contracts/HttpClient/Exception/TransportExceptionInterface.php @@ -15,6 +15,6 @@ namespace RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception; * * @author Nicolas Grekas */ -interface TransportExceptionInterface extends \RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\ExceptionInterface +interface TransportExceptionInterface extends ExceptionInterface { } diff --git a/vendor/symfony/contracts/HttpClient/HttpClientInterface.php b/vendor/symfony/contracts/HttpClient/HttpClientInterface.php index 8e6e7dd343f..611c806b09e 100644 --- a/vendor/symfony/contracts/HttpClient/HttpClientInterface.php +++ b/vendor/symfony/contracts/HttpClient/HttpClientInterface.php @@ -97,14 +97,14 @@ interface HttpClientInterface * * @throws TransportExceptionInterface When an unsupported option is passed */ - public function request(string $method, string $url, array $options = []) : \RectorPrefix20220607\Symfony\Contracts\HttpClient\ResponseInterface; + public function request(string $method, string $url, array $options = []) : ResponseInterface; /** * Yields responses chunk by chunk as they complete. * * @param ResponseInterface|iterable $responses One or more responses created by the current HTTP client * @param float|null $timeout The idle timeout before yielding timeout chunks */ - public function stream($responses, float $timeout = null) : \RectorPrefix20220607\Symfony\Contracts\HttpClient\ResponseStreamInterface; + public function stream($responses, float $timeout = null) : ResponseStreamInterface; /** * Returns a new instance of the client with new default options. * @return $this diff --git a/vendor/symfony/contracts/HttpClient/ResponseStreamInterface.php b/vendor/symfony/contracts/HttpClient/ResponseStreamInterface.php index 9b4eba8a83f..637fc331255 100644 --- a/vendor/symfony/contracts/HttpClient/ResponseStreamInterface.php +++ b/vendor/symfony/contracts/HttpClient/ResponseStreamInterface.php @@ -19,6 +19,6 @@ namespace RectorPrefix20220607\Symfony\Contracts\HttpClient; */ interface ResponseStreamInterface extends \Iterator { - public function key() : \RectorPrefix20220607\Symfony\Contracts\HttpClient\ResponseInterface; - public function current() : \RectorPrefix20220607\Symfony\Contracts\HttpClient\ChunkInterface; + public function key() : ResponseInterface; + public function current() : ChunkInterface; } diff --git a/vendor/symfony/contracts/HttpClient/Test/HttpClientTestCase.php b/vendor/symfony/contracts/HttpClient/Test/HttpClientTestCase.php index beab152c9b8..4cb0434d8e7 100644 --- a/vendor/symfony/contracts/HttpClient/Test/HttpClientTestCase.php +++ b/vendor/symfony/contracts/HttpClient/Test/HttpClientTestCase.php @@ -10,7 +10,7 @@ */ namespace RectorPrefix20220607\Symfony\Contracts\HttpClient\Test; -use RectorPrefix20220607\PHPUnit\Framework\TestCase; +use PHPUnit\Framework\TestCase; use RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; use RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; use RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TimeoutExceptionInterface; @@ -19,13 +19,13 @@ use RectorPrefix20220607\Symfony\Contracts\HttpClient\HttpClientInterface; /** * A reference test suite for HttpClientInterface implementations. */ -abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framework\TestCase +abstract class HttpClientTestCase extends TestCase { public static function setUpBeforeClass() : void { - \RectorPrefix20220607\Symfony\Contracts\HttpClient\Test\TestHttpServer::start(); + TestHttpServer::start(); } - protected abstract function getHttpClient(string $testCase) : \RectorPrefix20220607\Symfony\Contracts\HttpClient\HttpClientInterface; + protected abstract function getHttpClient(string $testCase) : HttpClientInterface; public function testGetRequest() { $client = $this->getHttpClient(__FUNCTION__); @@ -50,7 +50,7 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor $this->assertSame('localhost:8057', $body['HTTP_HOST']); $this->assertSame('baR', $body['HTTP_FOO']); $response = $client->request('GET', 'http://localhost:8057/length-broken'); - $this->expectException(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class); + $this->expectException(TransportExceptionInterface::class); $response->getContent(); } public function testHeadRequest() @@ -74,7 +74,7 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor $response = $client->request('GET', 'http://localhost:8057', ['buffer' => \false, 'headers' => ['Foo' => 'baR']]); $body = $response->toArray(); $this->assertSame('baR', $body['HTTP_FOO']); - $this->expectException(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class); + $this->expectException(TransportExceptionInterface::class); $response->getContent(); } public function testBufferSink() @@ -99,7 +99,7 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor return \false; }]); $response->getContent(); - $this->expectException(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class); + $this->expectException(TransportExceptionInterface::class); $response->getContent(); } public function testReentrantBufferCallback() @@ -110,7 +110,7 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor return \true; }]); $this->assertSame(200, $response->getStatusCode()); - $this->expectException(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class); + $this->expectException(TransportExceptionInterface::class); $response->getContent(); } public function testThrowingBufferCallback() @@ -120,7 +120,7 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor throw new \Exception('Boo.'); }]); $this->assertSame(200, $response->getStatusCode()); - $this->expectException(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class); + $this->expectException(TransportExceptionInterface::class); $this->expectExceptionMessage('Boo'); $response->getContent(); } @@ -148,7 +148,7 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor $this->assertSame(['chunked'], $response->getHeaders()['transfer-encoding']); $this->assertSame('Symfony is awesome!', $response->getContent()); $response = $client->request('GET', 'http://localhost:8057/chunked-broken'); - $this->expectException(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class); + $this->expectException(TransportExceptionInterface::class); $response->getContent(); } public function testClientError() @@ -159,13 +159,13 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor $this->assertSame(404, $response->getInfo('http_code')); try { $response->getHeaders(); - $this->fail(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface::class . ' expected'); - } catch (\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface) { + $this->fail(ClientExceptionInterface::class . ' expected'); + } catch (ClientExceptionInterface) { } try { $response->getContent(); - $this->fail(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface::class . ' expected'); - } catch (\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface) { + $this->fail(ClientExceptionInterface::class . ' expected'); + } catch (ClientExceptionInterface) { } $this->assertSame(404, $response->getStatusCode()); $this->assertSame(['application/json'], $response->getHeaders(\false)['content-type']); @@ -175,8 +175,8 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor foreach ($client->stream($response) as $chunk) { $this->assertTrue($chunk->isFirst()); } - $this->fail(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface::class . ' expected'); - } catch (\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface) { + $this->fail(ClientExceptionInterface::class . ' expected'); + } catch (ClientExceptionInterface) { } } public function testIgnoreErrors() @@ -191,27 +191,27 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor $response = $client->request('GET', 'http://localhost:8057/301/bad-tld'); try { $response->getStatusCode(); - $this->fail(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class . ' expected'); - } catch (\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface) { + $this->fail(TransportExceptionInterface::class . ' expected'); + } catch (TransportExceptionInterface) { $this->addToAssertionCount(1); } try { $response->getStatusCode(); - $this->fail(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class . ' still expected'); - } catch (\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface) { + $this->fail(TransportExceptionInterface::class . ' still expected'); + } catch (TransportExceptionInterface) { $this->addToAssertionCount(1); } $response = $client->request('GET', 'http://localhost:8057/301/bad-tld'); try { foreach ($client->stream($response) as $r => $chunk) { } - $this->fail(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class . ' expected'); - } catch (\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface) { + $this->fail(TransportExceptionInterface::class . ' expected'); + } catch (TransportExceptionInterface) { $this->addToAssertionCount(1); } $this->assertSame($response, $r); $this->assertNotNull($chunk->getError()); - $this->expectException(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class); + $this->expectException(TransportExceptionInterface::class); foreach ($client->stream($response) as $chunk) { } } @@ -226,7 +226,7 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor public function testBadRequestBody() { $client = $this->getHttpClient(__FUNCTION__); - $this->expectException(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class); + $this->expectException(TransportExceptionInterface::class); $response = $client->request('POST', 'http://localhost:8057/', ['body' => function () { (yield []); }]); @@ -269,7 +269,7 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor $this->assertSame(['//?foo=bar'], $response->getHeaders(\false)['location']); $this->assertSame(0, $response->getInfo('redirect_count')); $this->assertNull($response->getInfo('redirect_url')); - $this->expectException(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface::class); + $this->expectException(RedirectionExceptionInterface::class); $response->getHeaders(); } public function testRelativeRedirects() @@ -300,8 +300,8 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor $response = $client->request('GET', 'http://localhost:8057/301', ['max_redirects' => 1, 'auth_basic' => 'foo:bar']); try { $response->getHeaders(); - $this->fail(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface::class . ' expected'); - } catch (\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface) { + $this->fail(RedirectionExceptionInterface::class . ' expected'); + } catch (RedirectionExceptionInterface) { } $this->assertSame(302, $response->getStatusCode()); $this->assertSame(1, $response->getInfo('redirect_count')); @@ -419,7 +419,7 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor $client = $this->getHttpClient(__FUNCTION__); $response = $client->request('GET', 'http://localhost:8057/timeout-header'); $response->cancel(); - $this->expectException(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class); + $this->expectException(TransportExceptionInterface::class); $response->getHeaders(); } public function testInfoOnCanceledResponse() @@ -437,7 +437,7 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor foreach ($client->stream($response) as $chunk) { $response->cancel(); } - $this->expectException(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class); + $this->expectException(TransportExceptionInterface::class); foreach ($client->stream($response) as $chunk) { } } @@ -452,12 +452,12 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor try { foreach ($client->stream([$response]) as $chunk) { } - $this->fail(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface::class . ' expected'); - } catch (\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface $e) { + $this->fail(ClientExceptionInterface::class . ' expected'); + } catch (TransportExceptionInterface $e) { $this->assertSame('Aborting the request.', $e->getPrevious()->getMessage()); } $this->assertNotNull($response->getInfo('error')); - $this->expectException(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class); + $this->expectException(TransportExceptionInterface::class); $response->getContent(); } public function testOnProgressError() @@ -476,7 +476,7 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor $this->assertSame('BUG.', $e->getMessage()); } $this->assertNotNull($response->getInfo('error')); - $this->expectException(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class); + $this->expectException(TransportExceptionInterface::class); $response->getContent(); } public function testResolve() @@ -486,7 +486,7 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor $this->assertSame(200, $response->getStatusCode()); $this->assertSame(200, $client->request('GET', 'http://symfony.com:8057/')->getStatusCode()); $response = null; - $this->expectException(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class); + $this->expectException(TransportExceptionInterface::class); $client->request('GET', 'http://symfony.com:8057/', ['timeout' => 1]); } public function testIdnResolve() @@ -508,7 +508,7 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor { $client = $this->getHttpClient(__FUNCTION__); $response = $client->request('GET', 'http://localhost:8057/timeout-header', ['timeout' => 0.1]); - $this->expectException(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class); + $this->expectException(TransportExceptionInterface::class); $response->getHeaders(); } public function testTimeoutIsNotAFatalError() @@ -519,14 +519,14 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor $response = $client->request('GET', 'http://localhost:8057/timeout-body', ['timeout' => 0.25]); try { $response->getContent(); - $this->fail(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TimeoutExceptionInterface::class . ' expected'); - } catch (\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TimeoutExceptionInterface $e) { + $this->fail(TimeoutExceptionInterface::class . ' expected'); + } catch (TimeoutExceptionInterface $e) { } for ($i = 0; $i < 10; ++$i) { try { $this->assertSame('<1><2>', $response->getContent()); break; - } catch (\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TimeoutExceptionInterface $e) { + } catch (TimeoutExceptionInterface $e) { } } if (10 === $i) { @@ -561,20 +561,20 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor $client = $this->getHttpClient(__FUNCTION__); $response = $client->request('GET', 'http://localhost:8057/timeout-body'); $chunks = $client->stream([$response], 0.1); - $this->expectException(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class); + $this->expectException(TransportExceptionInterface::class); foreach ($chunks as $r => $chunk) { } } public function testTimeoutWithActiveConcurrentStream() { - $p1 = \RectorPrefix20220607\Symfony\Contracts\HttpClient\Test\TestHttpServer::start(8067); - $p2 = \RectorPrefix20220607\Symfony\Contracts\HttpClient\Test\TestHttpServer::start(8077); + $p1 = TestHttpServer::start(8067); + $p2 = TestHttpServer::start(8077); $client = $this->getHttpClient(__FUNCTION__); $streamingResponse = $client->request('GET', 'http://localhost:8067/max-duration'); $blockingResponse = $client->request('GET', 'http://localhost:8077/timeout-body', ['timeout' => 0.25]); $this->assertSame(200, $streamingResponse->getStatusCode()); $this->assertSame(200, $blockingResponse->getStatusCode()); - $this->expectException(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class); + $this->expectException(TransportExceptionInterface::class); try { $blockingResponse->getContent(); } finally { @@ -584,8 +584,8 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor } public function testTimeoutOnInitialize() { - $p1 = \RectorPrefix20220607\Symfony\Contracts\HttpClient\Test\TestHttpServer::start(8067); - $p2 = \RectorPrefix20220607\Symfony\Contracts\HttpClient\Test\TestHttpServer::start(8077); + $p1 = TestHttpServer::start(8067); + $p2 = TestHttpServer::start(8077); $client = $this->getHttpClient(__FUNCTION__); $start = \microtime(\true); $responses = []; @@ -597,8 +597,8 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor foreach ($responses as $response) { try { $response->getContent(); - $this->fail(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class . ' expected'); - } catch (\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface) { + $this->fail(TransportExceptionInterface::class . ' expected'); + } catch (TransportExceptionInterface) { } } $responses = []; @@ -611,8 +611,8 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor } public function testTimeoutOnDestruct() { - $p1 = \RectorPrefix20220607\Symfony\Contracts\HttpClient\Test\TestHttpServer::start(8067); - $p2 = \RectorPrefix20220607\Symfony\Contracts\HttpClient\Test\TestHttpServer::start(8077); + $p1 = TestHttpServer::start(8067); + $p2 = TestHttpServer::start(8077); $client = $this->getHttpClient(__FUNCTION__); $start = \microtime(\true); $responses = []; @@ -624,8 +624,8 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor while ($response = \array_shift($responses)) { try { unset($response); - $this->fail(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class . ' expected'); - } catch (\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface) { + $this->fail(TransportExceptionInterface::class . ' expected'); + } catch (TransportExceptionInterface) { } } $duration = \microtime(\true) - $start; @@ -650,8 +650,8 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor $client = $this->getHttpClient(__FUNCTION__); try { $client->request('GET', 'http://localhost:8057/404'); - $this->fail(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface::class . ' expected'); - } catch (\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface $e) { + $this->fail(ClientExceptionInterface::class . ' expected'); + } catch (ClientExceptionInterface $e) { $this->assertSame('GET', $e->getResponse()->toArray(\false)['REQUEST_METHOD']); } } @@ -660,8 +660,8 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor $client = $this->getHttpClient(__FUNCTION__); try { $client->request('GET', 'http://localhost:8057/404-gzipped'); - $this->fail(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface::class . ' expected'); - } catch (\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface $e) { + $this->fail(ClientExceptionInterface::class . ' expected'); + } catch (ClientExceptionInterface $e) { $this->assertSame('some text', $e->getResponse()->getContent(\false)); } } @@ -764,7 +764,7 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor $this->assertSame(['Accept-Encoding'], $headers['vary']); $this->assertStringContainsString('gzip', $headers['content-encoding'][0]); $body = $response->getContent(); - $this->assertSame("\37", $body[0]); + $this->assertSame("\x1f", $body[0]); $body = \json_decode(\gzdecode($body), \true); $this->assertSame('gzip', $body['HTTP_ACCEPT_ENCODING']); } @@ -775,7 +775,7 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor { $client = $this->getHttpClient(__FUNCTION__); $response = $client->request('GET', 'http://localhost:8057/gzip-broken'); - $this->expectException(\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface::class); + $this->expectException(TransportExceptionInterface::class); $response->getContent(); } public function testMaxDuration() @@ -785,7 +785,7 @@ abstract class HttpClientTestCase extends \RectorPrefix20220607\PHPUnit\Framewor $start = \microtime(\true); try { $response->getContent(); - } catch (\RectorPrefix20220607\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface) { + } catch (TransportExceptionInterface) { $this->addToAssertionCount(1); } $duration = \microtime(\true) - $start; diff --git a/vendor/symfony/contracts/HttpClient/Test/TestHttpServer.php b/vendor/symfony/contracts/HttpClient/Test/TestHttpServer.php index 047a1863126..75e4bb895ee 100644 --- a/vendor/symfony/contracts/HttpClient/Test/TestHttpServer.php +++ b/vendor/symfony/contracts/HttpClient/Test/TestHttpServer.php @@ -15,7 +15,7 @@ use RectorPrefix20220607\Symfony\Component\Process\Process; class TestHttpServer { private static $process = []; - public static function start(int $port = 8057) : \RectorPrefix20220607\Symfony\Component\Process\Process + public static function start(int $port = 8057) : Process { if (isset(self::$process[$port])) { self::$process[$port]->stop(); @@ -24,8 +24,8 @@ class TestHttpServer self::$process[$port]->stop(); }); } - $finder = new \RectorPrefix20220607\Symfony\Component\Process\PhpExecutableFinder(); - $process = new \RectorPrefix20220607\Symfony\Component\Process\Process(\array_merge([$finder->find(\false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', '127.0.0.1:' . $port])); + $finder = new PhpExecutableFinder(); + $process = new Process(\array_merge([$finder->find(\false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', '127.0.0.1:' . $port])); $process->setWorkingDirectory(__DIR__ . '/Fixtures/web'); $process->start(); self::$process[$port] = $process; diff --git a/vendor/symfony/contracts/Service/ServiceLocatorTrait.php b/vendor/symfony/contracts/Service/ServiceLocatorTrait.php index 7a278c98486..206ddeaf891 100644 --- a/vendor/symfony/contracts/Service/ServiceLocatorTrait.php +++ b/vendor/symfony/contracts/Service/ServiceLocatorTrait.php @@ -13,8 +13,8 @@ namespace RectorPrefix20220607\Symfony\Contracts\Service; use RectorPrefix20220607\Psr\Container\ContainerExceptionInterface; use RectorPrefix20220607\Psr\Container\NotFoundExceptionInterface; // Help opcache.preload discover always-needed symbols -\class_exists(\RectorPrefix20220607\Psr\Container\ContainerExceptionInterface::class); -\class_exists(\RectorPrefix20220607\Psr\Container\NotFoundExceptionInterface::class); +\class_exists(ContainerExceptionInterface::class); +\class_exists(NotFoundExceptionInterface::class); /** * A trait to help implement ServiceProviderInterface. * @@ -89,7 +89,7 @@ trait ServiceLocatorTrait } return $this->providedTypes; } - private function createNotFoundException(string $id) : \RectorPrefix20220607\Psr\Container\NotFoundExceptionInterface + private function createNotFoundException(string $id) : NotFoundExceptionInterface { if (!($alternatives = \array_keys($this->factories))) { $message = 'is empty...'; @@ -106,13 +106,13 @@ trait ServiceLocatorTrait } else { $message = \sprintf('Service "%s" not found: the current service locator %s', $id, $message); } - return new class($message) extends \InvalidArgumentException implements \RectorPrefix20220607\Psr\Container\NotFoundExceptionInterface + return new class($message) extends \InvalidArgumentException implements NotFoundExceptionInterface { }; } - private function createCircularReferenceException(string $id, array $path) : \RectorPrefix20220607\Psr\Container\ContainerExceptionInterface + private function createCircularReferenceException(string $id, array $path) : ContainerExceptionInterface { - return new class(\sprintf('Circular reference detected for service "%s", path: "%s".', $id, \implode(' -> ', $path))) extends \RuntimeException implements \RectorPrefix20220607\Psr\Container\ContainerExceptionInterface + return new class(\sprintf('Circular reference detected for service "%s", path: "%s".', $id, \implode(' -> ', $path))) extends \RuntimeException implements ContainerExceptionInterface { }; } diff --git a/vendor/symfony/contracts/Service/ServiceProviderInterface.php b/vendor/symfony/contracts/Service/ServiceProviderInterface.php index 56e4d671ff6..d5064d30284 100644 --- a/vendor/symfony/contracts/Service/ServiceProviderInterface.php +++ b/vendor/symfony/contracts/Service/ServiceProviderInterface.php @@ -19,7 +19,7 @@ use RectorPrefix20220607\Psr\Container\ContainerInterface; * * @template T of mixed */ -interface ServiceProviderInterface extends \RectorPrefix20220607\Psr\Container\ContainerInterface +interface ServiceProviderInterface extends ContainerInterface { /** * {@inheritdoc} diff --git a/vendor/symfony/contracts/Service/ServiceSubscriberTrait.php b/vendor/symfony/contracts/Service/ServiceSubscriberTrait.php index bd6203c1743..7ab5377ef29 100644 --- a/vendor/symfony/contracts/Service/ServiceSubscriberTrait.php +++ b/vendor/symfony/contracts/Service/ServiceSubscriberTrait.php @@ -37,14 +37,14 @@ trait ServiceSubscriberTrait if (self::class !== $method->getDeclaringClass()->name) { continue; } - if (!($attribute = (\method_exists($method, 'getAttributes') ? $method->getAttributes(\RectorPrefix20220607\Symfony\Contracts\Service\Attribute\SubscribedService::class) : [])[0] ?? null)) { + if (!($attribute = (\method_exists($method, 'getAttributes') ? $method->getAttributes(SubscribedService::class) : [])[0] ?? null)) { continue; } if ($method->isStatic() || $method->isAbstract() || $method->isGenerator() || $method->isInternal() || $method->getNumberOfRequiredParameters()) { - throw new \LogicException(\sprintf('Cannot use "%s" on method "%s::%s()" (can only be used on non-static, non-abstract methods with no parameters).', \RectorPrefix20220607\Symfony\Contracts\Service\Attribute\SubscribedService::class, self::class, $method->name)); + throw new \LogicException(\sprintf('Cannot use "%s" on method "%s::%s()" (can only be used on non-static, non-abstract methods with no parameters).', SubscribedService::class, self::class, $method->name)); } if (!($returnType = $method->getReturnType())) { - throw new \LogicException(\sprintf('Cannot use "%s" on methods without a return type in "%s::%s()".', \RectorPrefix20220607\Symfony\Contracts\Service\Attribute\SubscribedService::class, $method->name, self::class)); + throw new \LogicException(\sprintf('Cannot use "%s" on methods without a return type in "%s::%s()".', SubscribedService::class, $method->name, self::class)); } $serviceId = $returnType instanceof \ReflectionNamedType ? $returnType->getName() : (string) $returnType; if ($returnType->allowsNull()) { @@ -57,7 +57,7 @@ trait ServiceSubscriberTrait /** * @required */ - public function setContainer(\RectorPrefix20220607\Psr\Container\ContainerInterface $container) : ?\RectorPrefix20220607\Psr\Container\ContainerInterface + public function setContainer(ContainerInterface $container) : ?ContainerInterface { $this->container = $container; if (\method_exists(\get_parent_class(self::class) ?: '', __FUNCTION__)) { diff --git a/vendor/symfony/contracts/Service/Test/ServiceLocatorTest.php b/vendor/symfony/contracts/Service/Test/ServiceLocatorTest.php index de566b1a6ea..e3cad5bd2e4 100644 --- a/vendor/symfony/contracts/Service/Test/ServiceLocatorTest.php +++ b/vendor/symfony/contracts/Service/Test/ServiceLocatorTest.php @@ -10,14 +10,14 @@ */ namespace RectorPrefix20220607\Symfony\Contracts\Service\Test; -use RectorPrefix20220607\PHPUnit\Framework\TestCase; +use PHPUnit\Framework\TestCase; use RectorPrefix20220607\Psr\Container\ContainerInterface; use RectorPrefix20220607\Symfony\Contracts\Service\ServiceLocatorTrait; -abstract class ServiceLocatorTest extends \RectorPrefix20220607\PHPUnit\Framework\TestCase +abstract class ServiceLocatorTest extends TestCase { - protected function getServiceLocator(array $factories) : \RectorPrefix20220607\Psr\Container\ContainerInterface + protected function getServiceLocator(array $factories) : ContainerInterface { - return new class($factories) implements \RectorPrefix20220607\Psr\Container\ContainerInterface + return new class($factories) implements ContainerInterface { use ServiceLocatorTrait; }; diff --git a/vendor/symfony/contracts/Tests/Cache/CacheTraitTest.php b/vendor/symfony/contracts/Tests/Cache/CacheTraitTest.php index e0b7fe48043..2aa144b04f7 100644 --- a/vendor/symfony/contracts/Tests/Cache/CacheTraitTest.php +++ b/vendor/symfony/contracts/Tests/Cache/CacheTraitTest.php @@ -10,67 +10,67 @@ */ namespace RectorPrefix20220607\Symfony\Contracts\Tests\Cache; -use RectorPrefix20220607\PHPUnit\Framework\TestCase; +use PHPUnit\Framework\TestCase; use RectorPrefix20220607\Psr\Cache\CacheItemInterface; use RectorPrefix20220607\Psr\Cache\CacheItemPoolInterface; use RectorPrefix20220607\Symfony\Contracts\Cache\CacheTrait; /** * @author Tobias Nyholm */ -class CacheTraitTest extends \RectorPrefix20220607\PHPUnit\Framework\TestCase +class CacheTraitTest extends TestCase { public function testSave() { - $item = $this->createMock(\RectorPrefix20220607\Psr\Cache\CacheItemInterface::class); + $item = $this->createMock(CacheItemInterface::class); $item->method('set')->willReturn($item); $item->method('isHit')->willReturn(\false); $item->expects($this->once())->method('set')->with('computed data'); - $cache = $this->getMockBuilder(\RectorPrefix20220607\Symfony\Contracts\Tests\Cache\TestPool::class)->setMethods(['getItem', 'save'])->getMock(); + $cache = $this->getMockBuilder(TestPool::class)->setMethods(['getItem', 'save'])->getMock(); $cache->expects($this->once())->method('getItem')->with('key')->willReturn($item); $cache->expects($this->once())->method('save'); - $callback = function (\RectorPrefix20220607\Psr\Cache\CacheItemInterface $item) { + $callback = function (CacheItemInterface $item) { return 'computed data'; }; $cache->get('key', $callback); } public function testNoCallbackCallOnHit() { - $item = $this->createMock(\RectorPrefix20220607\Psr\Cache\CacheItemInterface::class); + $item = $this->createMock(CacheItemInterface::class); $item->method('isHit')->willReturn(\true); $item->expects($this->never())->method('set'); - $cache = $this->getMockBuilder(\RectorPrefix20220607\Symfony\Contracts\Tests\Cache\TestPool::class)->setMethods(['getItem', 'save'])->getMock(); + $cache = $this->getMockBuilder(TestPool::class)->setMethods(['getItem', 'save'])->getMock(); $cache->expects($this->once())->method('getItem')->with('key')->willReturn($item); $cache->expects($this->never())->method('save'); - $callback = function (\RectorPrefix20220607\Psr\Cache\CacheItemInterface $item) { + $callback = function (CacheItemInterface $item) { $this->assertTrue(\false, 'This code should never be reached'); }; $cache->get('key', $callback); } public function testRecomputeOnBetaInf() { - $item = $this->createMock(\RectorPrefix20220607\Psr\Cache\CacheItemInterface::class); + $item = $this->createMock(CacheItemInterface::class); $item->method('set')->willReturn($item); $item->method('isHit')->willReturn(\true); $item->expects($this->once())->method('set')->with('computed data'); - $cache = $this->getMockBuilder(\RectorPrefix20220607\Symfony\Contracts\Tests\Cache\TestPool::class)->setMethods(['getItem', 'save'])->getMock(); + $cache = $this->getMockBuilder(TestPool::class)->setMethods(['getItem', 'save'])->getMock(); $cache->expects($this->once())->method('getItem')->with('key')->willReturn($item); $cache->expects($this->once())->method('save'); - $callback = function (\RectorPrefix20220607\Psr\Cache\CacheItemInterface $item) { + $callback = function (CacheItemInterface $item) { return 'computed data'; }; $cache->get('key', $callback, \INF); } public function testExceptionOnNegativeBeta() { - $cache = $this->getMockBuilder(\RectorPrefix20220607\Symfony\Contracts\Tests\Cache\TestPool::class)->setMethods(['getItem', 'save'])->getMock(); - $callback = function (\RectorPrefix20220607\Psr\Cache\CacheItemInterface $item) { + $cache = $this->getMockBuilder(TestPool::class)->setMethods(['getItem', 'save'])->getMock(); + $callback = function (CacheItemInterface $item) { return 'computed data'; }; $this->expectException(\InvalidArgumentException::class); $cache->get('key', $callback, -2); } } -class TestPool implements \RectorPrefix20220607\Psr\Cache\CacheItemPoolInterface +class TestPool implements CacheItemPoolInterface { use CacheTrait; public function hasItem($key) : bool @@ -82,16 +82,16 @@ class TestPool implements \RectorPrefix20220607\Psr\Cache\CacheItemPoolInterface public function deleteItems(array $keys = []) : bool { } - public function getItem($key) : \RectorPrefix20220607\Psr\Cache\CacheItemInterface + public function getItem($key) : CacheItemInterface { } public function getItems(array $key = []) : iterable { } - public function saveDeferred(\RectorPrefix20220607\Psr\Cache\CacheItemInterface $item) : bool + public function saveDeferred(CacheItemInterface $item) : bool { } - public function save(\RectorPrefix20220607\Psr\Cache\CacheItemInterface $item) : bool + public function save(CacheItemInterface $item) : bool { } public function commit() : bool diff --git a/vendor/symfony/contracts/Tests/Service/ServiceSubscriberTraitTest.php b/vendor/symfony/contracts/Tests/Service/ServiceSubscriberTraitTest.php index 00b9628396f..c22f001245d 100644 --- a/vendor/symfony/contracts/Tests/Service/ServiceSubscriberTraitTest.php +++ b/vendor/symfony/contracts/Tests/Service/ServiceSubscriberTraitTest.php @@ -10,7 +10,7 @@ */ namespace RectorPrefix20220607\Symfony\Contracts\Tests\Service; -use RectorPrefix20220607\PHPUnit\Framework\TestCase; +use PHPUnit\Framework\TestCase; use RectorPrefix20220607\Psr\Container\ContainerInterface; use RectorPrefix20220607\Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\OtherDir\Component1\Dir1\Service1; use RectorPrefix20220607\Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\OtherDir\Component1\Dir2\Service2; @@ -18,28 +18,28 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\SubscribedService; use RectorPrefix20220607\Symfony\Contracts\Service\ServiceLocatorTrait; use RectorPrefix20220607\Symfony\Contracts\Service\ServiceSubscriberInterface; use RectorPrefix20220607\Symfony\Contracts\Service\ServiceSubscriberTrait; -class ServiceSubscriberTraitTest extends \RectorPrefix20220607\PHPUnit\Framework\TestCase +class ServiceSubscriberTraitTest extends TestCase { public function testMethodsOnParentsAndChildrenAreIgnoredInGetSubscribedServices() { - $expected = [\RectorPrefix20220607\Symfony\Contracts\Tests\Service\TestService::class . '::aService' => \RectorPrefix20220607\Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\OtherDir\Component1\Dir2\Service2::class, \RectorPrefix20220607\Symfony\Contracts\Tests\Service\TestService::class . '::nullableService' => '?' . \RectorPrefix20220607\Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\OtherDir\Component1\Dir2\Service2::class]; - $this->assertEquals($expected, \RectorPrefix20220607\Symfony\Contracts\Tests\Service\ChildTestService::getSubscribedServices()); + $expected = [TestService::class . '::aService' => Service2::class, TestService::class . '::nullableService' => '?' . Service2::class]; + $this->assertEquals($expected, ChildTestService::getSubscribedServices()); } public function testSetContainerIsCalledOnParent() { - $container = new class([]) implements \RectorPrefix20220607\Psr\Container\ContainerInterface + $container = new class([]) implements ContainerInterface { use ServiceLocatorTrait; }; - $this->assertSame($container, (new \RectorPrefix20220607\Symfony\Contracts\Tests\Service\TestService())->setContainer($container)); + $this->assertSame($container, (new TestService())->setContainer($container)); } public function testParentNotCalledIfHasMagicCall() { - $container = new class([]) implements \RectorPrefix20220607\Psr\Container\ContainerInterface + $container = new class([]) implements ContainerInterface { use ServiceLocatorTrait; }; - $service = new class extends \RectorPrefix20220607\Symfony\Contracts\Tests\Service\ParentWithMagicCall + $service = new class extends ParentWithMagicCall { use ServiceSubscriberTrait; }; @@ -48,7 +48,7 @@ class ServiceSubscriberTraitTest extends \RectorPrefix20220607\PHPUnit\Framework } public function testParentNotCalledIfNoParent() { - $container = new class([]) implements \RectorPrefix20220607\Psr\Container\ContainerInterface + $container = new class([]) implements ContainerInterface { use ServiceLocatorTrait; }; @@ -62,30 +62,30 @@ class ServiceSubscriberTraitTest extends \RectorPrefix20220607\PHPUnit\Framework } class ParentTestService { - public function aParentService() : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\OtherDir\Component1\Dir1\Service1 + public function aParentService() : Service1 { } - public function setContainer(\RectorPrefix20220607\Psr\Container\ContainerInterface $container) + public function setContainer(ContainerInterface $container) { return $container; } } -class TestService extends \RectorPrefix20220607\Symfony\Contracts\Tests\Service\ParentTestService implements \RectorPrefix20220607\Symfony\Contracts\Service\ServiceSubscriberInterface +class TestService extends ParentTestService implements ServiceSubscriberInterface { use ServiceSubscriberTrait; - #[SubscribedService] - public function aService() : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\OtherDir\Component1\Dir2\Service2 + #[\Symfony\Contracts\Service\Attribute\SubscribedService] + public function aService() : Service2 { } - #[SubscribedService] - public function nullableService() : ?\RectorPrefix20220607\Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\OtherDir\Component1\Dir2\Service2 + #[\Symfony\Contracts\Service\Attribute\SubscribedService] + public function nullableService() : ?Service2 { } } -class ChildTestService extends \RectorPrefix20220607\Symfony\Contracts\Tests\Service\TestService +class ChildTestService extends TestService { - #[SubscribedService] - public function aChildService() : \RectorPrefix20220607\Symfony\Contracts\Tests\Service\Service3 + #[\Symfony\Contracts\Service\Attribute\SubscribedService] + public function aChildService() : Service3 { } } diff --git a/vendor/symfony/contracts/Translation/Test/TranslatorTest.php b/vendor/symfony/contracts/Translation/Test/TranslatorTest.php index 062e42a03da..da445f46467 100644 --- a/vendor/symfony/contracts/Translation/Test/TranslatorTest.php +++ b/vendor/symfony/contracts/Translation/Test/TranslatorTest.php @@ -10,7 +10,7 @@ */ namespace RectorPrefix20220607\Symfony\Contracts\Translation\Test; -use RectorPrefix20220607\PHPUnit\Framework\TestCase; +use PHPUnit\Framework\TestCase; use RectorPrefix20220607\Symfony\Contracts\Translation\TranslatorInterface; use RectorPrefix20220607\Symfony\Contracts\Translation\TranslatorTrait; /** @@ -26,7 +26,7 @@ use RectorPrefix20220607\Symfony\Contracts\Translation\TranslatorTrait; * * @author Clemens Tolboom clemens@build2be.nl */ -class TranslatorTest extends \RectorPrefix20220607\PHPUnit\Framework\TestCase +class TranslatorTest extends TestCase { private $defaultLocale; protected function setUp() : void @@ -38,9 +38,9 @@ class TranslatorTest extends \RectorPrefix20220607\PHPUnit\Framework\TestCase { \Locale::setDefault($this->defaultLocale); } - public function getTranslator() : \RectorPrefix20220607\Symfony\Contracts\Translation\TranslatorInterface + public function getTranslator() : TranslatorInterface { - return new class implements \RectorPrefix20220607\Symfony\Contracts\Translation\TranslatorInterface + return new class implements TranslatorInterface { use TranslatorTrait; }; diff --git a/vendor/symfony/contracts/Translation/TranslatableInterface.php b/vendor/symfony/contracts/Translation/TranslatableInterface.php index cbe09f2e5a9..0f1db5a49c8 100644 --- a/vendor/symfony/contracts/Translation/TranslatableInterface.php +++ b/vendor/symfony/contracts/Translation/TranslatableInterface.php @@ -15,5 +15,5 @@ namespace RectorPrefix20220607\Symfony\Contracts\Translation; */ interface TranslatableInterface { - public function trans(\RectorPrefix20220607\Symfony\Contracts\Translation\TranslatorInterface $translator, string $locale = null) : string; + public function trans(TranslatorInterface $translator, string $locale = null) : string; } diff --git a/vendor/symfony/contracts/Translation/TranslatorTrait.php b/vendor/symfony/contracts/Translation/TranslatorTrait.php index b32966f774a..89f2143bab4 100644 --- a/vendor/symfony/contracts/Translation/TranslatorTrait.php +++ b/vendor/symfony/contracts/Translation/TranslatorTrait.php @@ -104,8 +104,8 @@ EOF; return \strtr($standardRules[0], $parameters); } $message = \sprintf('Unable to choose a translation for "%s" with locale "%s" for value "%d". Double check that this translation has the correct plural options (e.g. "There is one apple|There are %%count%% apples").', $id, $locale, $number); - if (\class_exists(\RectorPrefix20220607\Symfony\Component\Translation\Exception\InvalidArgumentException::class)) { - throw new \RectorPrefix20220607\Symfony\Component\Translation\Exception\InvalidArgumentException($message); + if (\class_exists(InvalidArgumentException::class)) { + throw new InvalidArgumentException($message); } throw new \InvalidArgumentException($message); } diff --git a/vendor/symfony/dependency-injection/Alias.php b/vendor/symfony/dependency-injection/Alias.php index f9f24b61777..1f3862f672a 100644 --- a/vendor/symfony/dependency-injection/Alias.php +++ b/vendor/symfony/dependency-injection/Alias.php @@ -71,10 +71,10 @@ class Alias { if ('' !== $message) { if (\preg_match('#[\\r\\n]|\\*/#', $message)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('Invalid characters found in deprecation template.'); + throw new InvalidArgumentException('Invalid characters found in deprecation template.'); } if (\strpos($message, '%alias_id%') === \false) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('The deprecation template must contain the "%alias_id%" placeholder.'); + throw new InvalidArgumentException('The deprecation template must contain the "%alias_id%" placeholder.'); } } $this->deprecation = ['package' => $package, 'version' => $version, 'message' => $message ?: self::DEFAULT_DEPRECATION_TEMPLATE]; diff --git a/vendor/symfony/dependency-injection/Argument/BoundArgument.php b/vendor/symfony/dependency-injection/Argument/BoundArgument.php index e7b1b3e1b62..accc2e8f5f9 100644 --- a/vendor/symfony/dependency-injection/Argument/BoundArgument.php +++ b/vendor/symfony/dependency-injection/Argument/BoundArgument.php @@ -13,7 +13,7 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument; /** * @author Guilhem Niot */ -final class BoundArgument implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ArgumentInterface +final class BoundArgument implements ArgumentInterface { public const SERVICE_BINDING = 0; public const DEFAULTS_BINDING = 1; diff --git a/vendor/symfony/dependency-injection/Argument/IteratorArgument.php b/vendor/symfony/dependency-injection/Argument/IteratorArgument.php index cbb7570704c..b23e45b9995 100644 --- a/vendor/symfony/dependency-injection/Argument/IteratorArgument.php +++ b/vendor/symfony/dependency-injection/Argument/IteratorArgument.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument; * * @author Titouan Galopin */ -class IteratorArgument implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ArgumentInterface +class IteratorArgument implements ArgumentInterface { /** * @var mixed[] diff --git a/vendor/symfony/dependency-injection/Argument/ReferenceSetArgumentTrait.php b/vendor/symfony/dependency-injection/Argument/ReferenceSetArgumentTrait.php index 2f494fad5c1..bea736db13e 100644 --- a/vendor/symfony/dependency-injection/Argument/ReferenceSetArgumentTrait.php +++ b/vendor/symfony/dependency-injection/Argument/ReferenceSetArgumentTrait.php @@ -10,7 +10,7 @@ */ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument; -trigger_deprecation('symfony/dependency-injection', '6.1', '"%s" is deprecated.', \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ReferenceSetArgumentTrait::class); +\RectorPrefix20220607\trigger_deprecation('symfony/dependency-injection', '6.1', '"%s" is deprecated.', ReferenceSetArgumentTrait::class); use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference; /** @@ -45,8 +45,8 @@ trait ReferenceSetArgumentTrait public function setValues(array $values) { foreach ($values as $k => $v) { - if (null !== $v && !$v instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('A "%s" must hold only Reference instances, "%s" given.', __CLASS__, \get_debug_type($v))); + if (null !== $v && !$v instanceof Reference) { + throw new InvalidArgumentException(\sprintf('A "%s" must hold only Reference instances, "%s" given.', __CLASS__, \get_debug_type($v))); } } $this->values = $values; diff --git a/vendor/symfony/dependency-injection/Argument/ServiceClosureArgument.php b/vendor/symfony/dependency-injection/Argument/ServiceClosureArgument.php index e79bbc266b4..31043350a0e 100644 --- a/vendor/symfony/dependency-injection/Argument/ServiceClosureArgument.php +++ b/vendor/symfony/dependency-injection/Argument/ServiceClosureArgument.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\Invalid * * @author Nicolas Grekas */ -class ServiceClosureArgument implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ArgumentInterface +class ServiceClosureArgument implements ArgumentInterface { /** * @var mixed[] @@ -42,7 +42,7 @@ class ServiceClosureArgument implements \RectorPrefix20220607\Symfony\Component\ public function setValues(array $values) { if ([0] !== \array_keys($values)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('A ServiceClosureArgument must hold one and only one value.'); + throw new InvalidArgumentException('A ServiceClosureArgument must hold one and only one value.'); } $this->values = $values; } diff --git a/vendor/symfony/dependency-injection/Argument/ServiceLocator.php b/vendor/symfony/dependency-injection/Argument/ServiceLocator.php index 5dcc06b39bc..c02ac716861 100644 --- a/vendor/symfony/dependency-injection/Argument/ServiceLocator.php +++ b/vendor/symfony/dependency-injection/Argument/ServiceLocator.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\ServiceLocator as * * @internal */ -class ServiceLocator extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\ServiceLocator +class ServiceLocator extends BaseServiceLocator { /** * @var \Closure diff --git a/vendor/symfony/dependency-injection/Argument/ServiceLocatorArgument.php b/vendor/symfony/dependency-injection/Argument/ServiceLocatorArgument.php index ab5b446c17b..ce237a01c44 100644 --- a/vendor/symfony/dependency-injection/Argument/ServiceLocatorArgument.php +++ b/vendor/symfony/dependency-injection/Argument/ServiceLocatorArgument.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument; * * @author Nicolas Grekas */ -class ServiceLocatorArgument implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ArgumentInterface +class ServiceLocatorArgument implements ArgumentInterface { /** * @var mixed[] @@ -30,13 +30,13 @@ class ServiceLocatorArgument implements \RectorPrefix20220607\Symfony\Component\ */ public function __construct($values = []) { - if ($values instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument) { + if ($values instanceof TaggedIteratorArgument) { $this->taggedIteratorArgument = $values; $values = []; } $this->setValues($values); } - public function getTaggedIteratorArgument() : ?\RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument + public function getTaggedIteratorArgument() : ?TaggedIteratorArgument { return $this->taggedIteratorArgument; } diff --git a/vendor/symfony/dependency-injection/Argument/TaggedIteratorArgument.php b/vendor/symfony/dependency-injection/Argument/TaggedIteratorArgument.php index 54fa6a24bc8..d17872c9a14 100644 --- a/vendor/symfony/dependency-injection/Argument/TaggedIteratorArgument.php +++ b/vendor/symfony/dependency-injection/Argument/TaggedIteratorArgument.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument; * * @author Roland Franssen */ -class TaggedIteratorArgument extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\IteratorArgument +class TaggedIteratorArgument extends IteratorArgument { /** * @var string diff --git a/vendor/symfony/dependency-injection/Attribute/AsDecorator.php b/vendor/symfony/dependency-injection/Attribute/AsDecorator.php index 1938ac23e29..589a590d4f7 100644 --- a/vendor/symfony/dependency-injection/Attribute/AsDecorator.php +++ b/vendor/symfony/dependency-injection/Attribute/AsDecorator.php @@ -25,8 +25,8 @@ class AsDecorator /** * @var int */ - public $onInvalid = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; - public function __construct(string $decorates, int $priority = 0, int $onInvalid = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) + public $onInvalid = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; + public function __construct(string $decorates, int $priority = 0, int $onInvalid = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) { $this->decorates = $decorates; $this->priority = $priority; diff --git a/vendor/symfony/dependency-injection/Attribute/AutoconfigureTag.php b/vendor/symfony/dependency-injection/Attribute/AutoconfigureTag.php index 2a88b4f6b59..c3c80771f19 100644 --- a/vendor/symfony/dependency-injection/Attribute/AutoconfigureTag.php +++ b/vendor/symfony/dependency-injection/Attribute/AutoconfigureTag.php @@ -16,7 +16,7 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Attribute; * @author Nicolas Grekas */ #[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)] -class AutoconfigureTag extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Attribute\Autoconfigure +class AutoconfigureTag extends Autoconfigure { public function __construct(string $name = null, array $attributes = []) { diff --git a/vendor/symfony/dependency-injection/Attribute/Autowire.php b/vendor/symfony/dependency-injection/Attribute/Autowire.php index aa007641d42..58fc48bbaf6 100644 --- a/vendor/symfony/dependency-injection/Attribute/Autowire.php +++ b/vendor/symfony/dependency-injection/Attribute/Autowire.php @@ -36,7 +36,7 @@ class Autowire public function __construct(?string $value = null, ?string $service = null, ?string $expression = null) { if (!($service xor $expression xor null !== $value)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicException('#[Autowire] attribute must declare exactly one of $service, $expression, or $value.'); + throw new LogicException('#[Autowire] attribute must declare exactly one of $service, $expression, or $value.'); } if (null !== $value && \strncmp($value, '@', \strlen('@')) === 0) { switch (\true) { @@ -53,13 +53,13 @@ class Autowire } switch (\true) { case null !== $service: - $this->value = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($service); + $this->value = new Reference($service); break; case null !== $expression: - if (!\class_exists(\RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression::class)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed. Try running "composer require symfony/expression-language".'); + if (!\class_exists(Expression::class)) { + throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed. Try running "composer require symfony/expression-language".'); } - $this->value = new \RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression($expression); + $this->value = new Expression($expression); break; case null !== $value: $this->value = $value; diff --git a/vendor/symfony/dependency-injection/Attribute/Target.php b/vendor/symfony/dependency-injection/Attribute/Target.php index a19ec375542..bfe97ebb706 100644 --- a/vendor/symfony/dependency-injection/Attribute/Target.php +++ b/vendor/symfony/dependency-injection/Attribute/Target.php @@ -39,7 +39,7 @@ final class Target } else { $function = $function->name; } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid #[Target] name "%s" on parameter "$%s" of "%s()": the first character must be a letter.', $name, $parameter->name, $function)); + throw new InvalidArgumentException(\sprintf('Invalid #[Target] name "%s" on parameter "$%s" of "%s()": the first character must be a letter.', $name, $parameter->name, $function)); } return $name; } diff --git a/vendor/symfony/dependency-injection/ChildDefinition.php b/vendor/symfony/dependency-injection/ChildDefinition.php index bcc021315c6..faba7d2e21c 100644 --- a/vendor/symfony/dependency-injection/ChildDefinition.php +++ b/vendor/symfony/dependency-injection/ChildDefinition.php @@ -17,7 +17,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\OutOfBo * * @author Johannes M. Schmitt */ -class ChildDefinition extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition +class ChildDefinition extends Definition { /** * @var string @@ -85,7 +85,7 @@ class ChildDefinition extends \RectorPrefix20220607\Symfony\Component\Dependency } elseif (\strncmp($index, '$', \strlen('$')) === 0) { $this->arguments[$index] = $value; } else { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('The argument must be an existing index or the name of a constructor\'s parameter.'); + throw new InvalidArgumentException('The argument must be an existing index or the name of a constructor\'s parameter.'); } return $this; } diff --git a/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php b/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php index 8dbbb18950a..78489c8a7dc 100644 --- a/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php +++ b/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php @@ -22,7 +22,7 @@ use RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression; /** * @author Nicolas Grekas */ -abstract class AbstractRecursivePass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +abstract class AbstractRecursivePass implements CompilerPassInterface { /** * @var ContainerBuilder @@ -44,7 +44,7 @@ abstract class AbstractRecursivePass implements \RectorPrefix20220607\Symfony\Co /** * {@inheritdoc} */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { $this->container = $container; try { @@ -82,23 +82,23 @@ abstract class AbstractRecursivePass implements \RectorPrefix20220607\Symfony\Co $value[$k] = $processedValue; } } - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ArgumentInterface) { + } elseif ($value instanceof ArgumentInterface) { $value->setValues($this->processValue($value->getValues())); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression && $this->processExpressions) { + } elseif ($value instanceof Expression && $this->processExpressions) { $this->getExpressionLanguage()->compile((string) $value, ['this' => 'container', 'args' => 'args']); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + } elseif ($value instanceof Definition) { $value->setArguments($this->processValue($value->getArguments())); $value->setProperties($this->processValue($value->getProperties())); $value->setMethodCalls($this->processValue($value->getMethodCalls())); $changes = $value->getChanges(); if (isset($changes['factory'])) { if (\is_string($factory = $value->getFactory()) && \strncmp($factory, '@=', \strlen('@=')) === 0) { - if (!\class_exists(\RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression::class)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicException('Expressions cannot be used in service factories without the ExpressionLanguage component. Try running "composer require symfony/expression-language".'); + if (!\class_exists(Expression::class)) { + throw new LogicException('Expressions cannot be used in service factories without the ExpressionLanguage component. Try running "composer require symfony/expression-language".'); } - $factory = new \RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression(\substr($factory, 2)); + $factory = new Expression(\substr($factory, 2)); } - if (($factory = $this->processValue($factory)) instanceof \RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression) { + if (($factory = $this->processValue($factory)) instanceof Expression) { $factory = '@=' . $factory; } $value->setFactory($factory); @@ -112,7 +112,7 @@ abstract class AbstractRecursivePass implements \RectorPrefix20220607\Symfony\Co /** * @throws RuntimeException */ - protected function getConstructor(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, bool $required) : ?\ReflectionFunctionAbstract + protected function getConstructor(Definition $definition, bool $required) : ?\ReflectionFunctionAbstract { if ($definition->isSynthetic()) { return null; @@ -123,7 +123,7 @@ abstract class AbstractRecursivePass implements \RectorPrefix20220607\Symfony\Co }); } if (!\function_exists($factory)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Invalid service "%s": function "%s" does not exist.', $this->currentId, $factory)); + throw new RuntimeException(\sprintf('Invalid service "%s": function "%s" does not exist.', $this->currentId, $factory)); } $r = new \ReflectionFunction($factory); if (\false !== $r->getFileName() && \file_exists($r->getFileName())) { @@ -134,87 +134,87 @@ abstract class AbstractRecursivePass implements \RectorPrefix20220607\Symfony\Co if ($factory) { [$class, $method] = $factory; if ('__construct' === $method) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Invalid service "%s": "__construct()" cannot be used as a factory method.', $this->currentId)); + throw new RuntimeException(\sprintf('Invalid service "%s": "__construct()" cannot be used as a factory method.', $this->currentId)); } - if ($class instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + if ($class instanceof Reference) { $factoryDefinition = $this->container->findDefinition((string) $class); - while (null === ($class = $factoryDefinition->getClass()) && $factoryDefinition instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition) { + while (null === ($class = $factoryDefinition->getClass()) && $factoryDefinition instanceof ChildDefinition) { $factoryDefinition = $this->container->findDefinition($factoryDefinition->getParent()); } - } elseif ($class instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + } elseif ($class instanceof Definition) { $class = $class->getClass(); } elseif (null === $class) { $class = $definition->getClass(); } - return $this->getReflectionMethod(new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition($class), $method); + return $this->getReflectionMethod(new Definition($class), $method); } - while (null === ($class = $definition->getClass()) && $definition instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition) { + while (null === ($class = $definition->getClass()) && $definition instanceof ChildDefinition) { $definition = $this->container->findDefinition($definition->getParent()); } try { if (!($r = $this->container->getReflectionClass($class))) { if (null === $class) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Invalid service "%s": the class is not set.', $this->currentId)); + throw new RuntimeException(\sprintf('Invalid service "%s": the class is not set.', $this->currentId)); } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class)); + throw new RuntimeException(\sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class)); } } catch (\ReflectionException $e) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Invalid service "%s": ', $this->currentId) . \lcfirst($e->getMessage())); + throw new RuntimeException(\sprintf('Invalid service "%s": ', $this->currentId) . \lcfirst($e->getMessage())); } if (!($r = $r->getConstructor())) { if ($required) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Invalid service "%s": class%s has no constructor.', $this->currentId, \sprintf($class !== $this->currentId ? ' "%s"' : '', $class))); + throw new RuntimeException(\sprintf('Invalid service "%s": class%s has no constructor.', $this->currentId, \sprintf($class !== $this->currentId ? ' "%s"' : '', $class))); } } elseif (!$r->isPublic()) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Invalid service "%s": ', $this->currentId) . \sprintf($class !== $this->currentId ? 'constructor of class "%s"' : 'its constructor', $class) . ' must be public.'); + throw new RuntimeException(\sprintf('Invalid service "%s": ', $this->currentId) . \sprintf($class !== $this->currentId ? 'constructor of class "%s"' : 'its constructor', $class) . ' must be public.'); } return $r; } /** * @throws RuntimeException */ - protected function getReflectionMethod(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, string $method) : \ReflectionFunctionAbstract + protected function getReflectionMethod(Definition $definition, string $method) : \ReflectionFunctionAbstract { if ('__construct' === $method) { return $this->getConstructor($definition, \true); } - while (null === ($class = $definition->getClass()) && $definition instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition) { + while (null === ($class = $definition->getClass()) && $definition instanceof ChildDefinition) { $definition = $this->container->findDefinition($definition->getParent()); } if (null === $class) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Invalid service "%s": the class is not set.', $this->currentId)); + throw new RuntimeException(\sprintf('Invalid service "%s": the class is not set.', $this->currentId)); } if (!($r = $this->container->getReflectionClass($class))) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class)); + throw new RuntimeException(\sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class)); } if (!$r->hasMethod($method)) { if ($r->hasMethod('__call') && ($r = $r->getMethod('__call')) && $r->isPublic()) { return new \ReflectionMethod(static function (...$arguments) { }, '__invoke'); } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Invalid service "%s": method "%s()" does not exist.', $this->currentId, $class !== $this->currentId ? $class . '::' . $method : $method)); + throw new RuntimeException(\sprintf('Invalid service "%s": method "%s()" does not exist.', $this->currentId, $class !== $this->currentId ? $class . '::' . $method : $method)); } $r = $r->getMethod($method); if (!$r->isPublic()) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Invalid service "%s": method "%s()" must be public.', $this->currentId, $class !== $this->currentId ? $class . '::' . $method : $method)); + throw new RuntimeException(\sprintf('Invalid service "%s": method "%s()" must be public.', $this->currentId, $class !== $this->currentId ? $class . '::' . $method : $method)); } return $r; } - private function getExpressionLanguage() : \RectorPrefix20220607\Symfony\Component\DependencyInjection\ExpressionLanguage + private function getExpressionLanguage() : ExpressionLanguage { if (!isset($this->expressionLanguage)) { - if (!\class_exists(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ExpressionLanguage::class)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed. Try running "composer require symfony/expression-language".'); + if (!\class_exists(ExpressionLanguage::class)) { + throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed. Try running "composer require symfony/expression-language".'); } $providers = $this->container->getExpressionLanguageProviders(); - $this->expressionLanguage = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ExpressionLanguage(null, $providers, function (string $arg) : string { + $this->expressionLanguage = new ExpressionLanguage(null, $providers, function (string $arg) : string { if ('""' === \substr_replace($arg, '', 1, -1)) { $id = \stripcslashes(\substr($arg, 1, -1)); $this->inExpression = \true; - $arg = $this->processValue(new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($id)); + $arg = $this->processValue(new Reference($id)); $this->inExpression = \false; - if (!$arg instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('"%s::processValue()" must return a Reference when processing an expression, "%s" returned for service("%s").', static::class, \get_debug_type($arg), $id)); + if (!$arg instanceof Reference) { + throw new RuntimeException(\sprintf('"%s::processValue()" must return a Reference when processing an expression, "%s" returned for service("%s").', static::class, \get_debug_type($arg), $id)); } $arg = \sprintf('"%s"', $arg); } diff --git a/vendor/symfony/dependency-injection/Compiler/AliasDeprecatedPublicServicesPass.php b/vendor/symfony/dependency-injection/Compiler/AliasDeprecatedPublicServicesPass.php index f57497f692e..fd7e742d173 100644 --- a/vendor/symfony/dependency-injection/Compiler/AliasDeprecatedPublicServicesPass.php +++ b/vendor/symfony/dependency-injection/Compiler/AliasDeprecatedPublicServicesPass.php @@ -13,7 +13,7 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler; use RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder; use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference; -final class AliasDeprecatedPublicServicesPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +final class AliasDeprecatedPublicServicesPass extends AbstractRecursivePass { /** * @var mixed[] @@ -26,22 +26,22 @@ final class AliasDeprecatedPublicServicesPass extends \RectorPrefix20220607\Symf */ protected function processValue($value, bool $isRoot = \false) { - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference && isset($this->aliases[$id = (string) $value])) { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($this->aliases[$id], $value->getInvalidBehavior()); + if ($value instanceof Reference && isset($this->aliases[$id = (string) $value])) { + return new Reference($this->aliases[$id], $value->getInvalidBehavior()); } return parent::processValue($value, $isRoot); } /** * {@inheritdoc} */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { foreach ($container->findTaggedServiceIds('container.private') as $id => $tags) { if (null === ($package = $tags[0]['package'] ?? null)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The "package" attribute is mandatory for the "container.private" tag on the "%s" service.', $id)); + throw new InvalidArgumentException(\sprintf('The "package" attribute is mandatory for the "container.private" tag on the "%s" service.', $id)); } if (null === ($version = $tags[0]['version'] ?? null)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The "version" attribute is mandatory for the "container.private" tag on the "%s" service.', $id)); + throw new InvalidArgumentException(\sprintf('The "version" attribute is mandatory for the "container.private" tag on the "%s" service.', $id)); } $definition = $container->getDefinition($id); if (!$definition->isPublic() || $definition->isPrivate()) { diff --git a/vendor/symfony/dependency-injection/Compiler/AnalyzeServiceReferencesPass.php b/vendor/symfony/dependency-injection/Compiler/AnalyzeServiceReferencesPass.php index 5c13fa63596..0e0af38562e 100644 --- a/vendor/symfony/dependency-injection/Compiler/AnalyzeServiceReferencesPass.php +++ b/vendor/symfony/dependency-injection/Compiler/AnalyzeServiceReferencesPass.php @@ -28,7 +28,7 @@ use RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression; * @author Johannes M. Schmitt * @author Nicolas Grekas */ -class AnalyzeServiceReferencesPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class AnalyzeServiceReferencesPass extends AbstractRecursivePass { /** * @var \Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraph @@ -78,7 +78,7 @@ class AnalyzeServiceReferencesPass extends \RectorPrefix20220607\Symfony\Compone /** * Processes a ContainerBuilder object to populate the service reference graph. */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { $this->container = $container; $this->graph = $container->getCompiler()->getServiceReferenceGraph(); @@ -106,22 +106,22 @@ class AnalyzeServiceReferencesPass extends \RectorPrefix20220607\Symfony\Compone { $lazy = $this->lazy; $inExpression = $this->inExpression(); - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ArgumentInterface) { - $this->lazy = !$this->byFactory || !$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\IteratorArgument; + if ($value instanceof ArgumentInterface) { + $this->lazy = !$this->byFactory || !$value instanceof IteratorArgument; parent::processValue($value->getValues()); $this->lazy = $lazy; return $value; } - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + if ($value instanceof Reference) { $targetId = $this->getDefinitionId((string) $value); $targetDefinition = null !== $targetId ? $this->container->getDefinition($targetId) : null; - $this->graph->connect($this->currentId, $this->currentDefinition, $targetId, $targetDefinition, $value, $this->lazy || $this->hasProxyDumper && (($targetDefinition2 = $targetDefinition) ? $targetDefinition2->isLazy() : null), \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $value->getInvalidBehavior(), $this->byConstructor); + $this->graph->connect($this->currentId, $this->currentDefinition, $targetId, $targetDefinition, $value, $this->lazy || $this->hasProxyDumper && (($targetDefinition2 = $targetDefinition) ? $targetDefinition2->isLazy() : null), ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $value->getInvalidBehavior(), $this->byConstructor); if ($inExpression) { $this->graph->connect('.internal.reference_in_expression', null, $targetId, $targetDefinition, $value, $this->lazy || (($targetDefinition2 = $targetDefinition) ? $targetDefinition2->isLazy() : null), \true); } return $value; } - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + if (!$value instanceof Definition) { return parent::processValue($value, $isRoot); } if ($isRoot) { @@ -138,10 +138,10 @@ class AnalyzeServiceReferencesPass extends \RectorPrefix20220607\Symfony\Compone $byFactory = $this->byFactory; $this->byFactory = \true; if (\is_string($factory = $value->getFactory()) && \strncmp($factory, '@=', \strlen('@=')) === 0) { - if (!\class_exists(\RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression::class)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicException('Expressions cannot be used in service factories without the ExpressionLanguage component. Try running "composer require symfony/expression-language".'); + if (!\class_exists(Expression::class)) { + throw new LogicException('Expressions cannot be used in service factories without the ExpressionLanguage component. Try running "composer require symfony/expression-language".'); } - $factory = new \RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression(\substr($factory, 2)); + $factory = new Expression(\substr($factory, 2)); } $this->processValue($factory); $this->byFactory = $byFactory; diff --git a/vendor/symfony/dependency-injection/Compiler/AttributeAutoconfigurationPass.php b/vendor/symfony/dependency-injection/Compiler/AttributeAutoconfigurationPass.php index d6da78a4bda..eabdf96a883 100644 --- a/vendor/symfony/dependency-injection/Compiler/AttributeAutoconfigurationPass.php +++ b/vendor/symfony/dependency-injection/Compiler/AttributeAutoconfigurationPass.php @@ -18,13 +18,13 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\Runtime /** * @author Alexander M. Turek */ -final class AttributeAutoconfigurationPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +final class AttributeAutoconfigurationPass extends AbstractRecursivePass { private $classAttributeConfigurators = []; private $methodAttributeConfigurators = []; private $propertyAttributeConfigurators = []; private $parameterAttributeConfigurators = []; - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) : void + public function process(ContainerBuilder $container) : void { if (!$container->getAutoconfiguredAttributes()) { return; @@ -45,7 +45,7 @@ final class AttributeAutoconfigurationPass extends \RectorPrefix20220607\Symfony } elseif ($parameterType instanceof \ReflectionNamedType) { $types[] = $parameterType->getName(); } else { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicException(\sprintf('Argument "$%s" of attribute autoconfigurator should have a type, use one or more of "\\ReflectionClass|\\ReflectionMethod|\\ReflectionProperty|\\ReflectionParameter|\\Reflector" in "%s" on line "%d".', $reflectorParameter->getName(), $callableReflector->getFileName(), $callableReflector->getStartLine())); + throw new LogicException(\sprintf('Argument "$%s" of attribute autoconfigurator should have a type, use one or more of "\\ReflectionClass|\\ReflectionMethod|\\ReflectionProperty|\\ReflectionParameter|\\Reflector" in "%s" on line "%d".', $reflectorParameter->getName(), $callableReflector->getFileName(), $callableReflector->getStartLine())); } try { $attributeReflector = new \ReflectionClass($attributeName); @@ -60,7 +60,7 @@ final class AttributeAutoconfigurationPass extends \RectorPrefix20220607\Symfony continue; } if (!($targets & \constant('Attribute::TARGET_' . \strtoupper($symbol)))) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicException(\sprintf('Invalid type "Reflection%s" on argument "$%s": attribute "%s" cannot target a ' . $symbol . ' in "%s" on line "%d".', \ucfirst($symbol), $reflectorParameter->getName(), $attributeName, $callableReflector->getFileName(), $callableReflector->getStartLine())); + throw new LogicException(\sprintf('Invalid type "Reflection%s" on argument "$%s": attribute "%s" cannot target a ' . $symbol . ' in "%s" on line "%d".', \ucfirst($symbol), $reflectorParameter->getName(), $attributeName, $callableReflector->getFileName(), $callableReflector->getStartLine())); } } $this->{$symbol . 'AttributeConfigurators'}[$attributeName] = $callable; @@ -74,11 +74,11 @@ final class AttributeAutoconfigurationPass extends \RectorPrefix20220607\Symfony */ protected function processValue($value, bool $isRoot = \false) { - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition || !$value->isAutoconfigured() || $value->isAbstract() || $value->hasTag('container.ignore_attributes') || !($classReflector = $this->container->getReflectionClass($value->getClass(), \false))) { + if (!$value instanceof Definition || !$value->isAutoconfigured() || $value->isAbstract() || $value->hasTag('container.ignore_attributes') || !($classReflector = $this->container->getReflectionClass($value->getClass(), \false))) { return parent::processValue($value, $isRoot); } $instanceof = $value->getInstanceofConditionals(); - $conditionals = $instanceof[$classReflector->getName()] ?? new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition(''); + $conditionals = $instanceof[$classReflector->getName()] ?? new ChildDefinition(''); if ($this->classAttributeConfigurators) { foreach (\method_exists($classReflector, 'getAttributes') ? $classReflector->getAttributes() : [] as $attribute) { if ($configurator = $this->classAttributeConfigurators[$attribute->getName()] ?? null) { @@ -89,7 +89,7 @@ final class AttributeAutoconfigurationPass extends \RectorPrefix20220607\Symfony if ($this->parameterAttributeConfigurators) { try { $constructorReflector = $this->getConstructor($value, \false); - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException $exception) { + } catch (RuntimeException $exception) { $constructorReflector = null; } if ($constructorReflector) { @@ -137,7 +137,7 @@ final class AttributeAutoconfigurationPass extends \RectorPrefix20220607\Symfony } } } - if (!isset($instanceof[$classReflector->getName()]) && new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition('') != $conditionals) { + if (!isset($instanceof[$classReflector->getName()]) && new ChildDefinition('') != $conditionals) { $instanceof[$classReflector->getName()] = $conditionals; $value->setInstanceofConditionals($instanceof); } diff --git a/vendor/symfony/dependency-injection/Compiler/AutoAliasServicePass.php b/vendor/symfony/dependency-injection/Compiler/AutoAliasServicePass.php index 6c09d9430fd..de39886ec14 100644 --- a/vendor/symfony/dependency-injection/Compiler/AutoAliasServicePass.php +++ b/vendor/symfony/dependency-injection/Compiler/AutoAliasServicePass.php @@ -16,21 +16,21 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\Invalid /** * Sets a service to be an alias of another one, given a format pattern. */ -class AutoAliasServicePass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +class AutoAliasServicePass implements CompilerPassInterface { /** * {@inheritdoc} */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { foreach ($container->findTaggedServiceIds('auto_alias') as $serviceId => $tags) { foreach ($tags as $tag) { if (!isset($tag['format'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Missing tag information "format" on auto_alias service "%s".', $serviceId)); + throw new InvalidArgumentException(\sprintf('Missing tag information "format" on auto_alias service "%s".', $serviceId)); } $aliasId = $container->getParameterBag()->resolveValue($tag['format']); if ($container->hasDefinition($aliasId) || $container->hasAlias($aliasId)) { - $alias = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Alias($aliasId, $container->getDefinition($serviceId)->isPublic()); + $alias = new Alias($aliasId, $container->getDefinition($serviceId)->isPublic()); $container->setAlias($serviceId, $alias); } } diff --git a/vendor/symfony/dependency-injection/Compiler/AutowireAsDecoratorPass.php b/vendor/symfony/dependency-injection/Compiler/AutowireAsDecoratorPass.php index ea3a41be1c0..710090b5f81 100644 --- a/vendor/symfony/dependency-injection/Compiler/AutowireAsDecoratorPass.php +++ b/vendor/symfony/dependency-injection/Compiler/AutowireAsDecoratorPass.php @@ -17,12 +17,12 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition; * Reads #[AsDecorator] attributes on definitions that are autowired * and don't have the "container.ignore_attributes" tag. */ -final class AutowireAsDecoratorPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +final class AutowireAsDecoratorPass implements CompilerPassInterface { /** * {@inheritdoc} */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { foreach ($container->getDefinitions() as $definition) { if ($this->accept($definition) && ($reflectionClass = $container->getReflectionClass($definition->getClass(), \false))) { @@ -30,13 +30,13 @@ final class AutowireAsDecoratorPass implements \RectorPrefix20220607\Symfony\Com } } } - private function accept(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) : bool + private function accept(Definition $definition) : bool { return !$definition->hasTag('container.ignore_attributes') && $definition->isAutowired(); } - private function processClass(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, \ReflectionClass $reflectionClass) + private function processClass(Definition $definition, \ReflectionClass $reflectionClass) { - foreach (\method_exists($reflectionClass, 'getAttributes') ? $reflectionClass->getAttributes(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Attribute\AsDecorator::class, \ReflectionAttribute::IS_INSTANCEOF) : [] as $attribute) { + foreach (\method_exists($reflectionClass, 'getAttributes') ? $reflectionClass->getAttributes(AsDecorator::class, \ReflectionAttribute::IS_INSTANCEOF) : [] as $attribute) { $attribute = $attribute->newInstance(); $definition->setDecoratedService($attribute->decorates, null, $attribute->priority, $attribute->onInvalid); } diff --git a/vendor/symfony/dependency-injection/Compiler/AutowirePass.php b/vendor/symfony/dependency-injection/Compiler/AutowirePass.php index ba9cf8a9b53..4c19fbd9557 100644 --- a/vendor/symfony/dependency-injection/Compiler/AutowirePass.php +++ b/vendor/symfony/dependency-injection/Compiler/AutowirePass.php @@ -32,7 +32,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference; * @author Kévin Dunglas * @author Nicolas Grekas */ -class AutowirePass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class AutowirePass extends AbstractRecursivePass { /** * @var mixed[] @@ -102,7 +102,7 @@ class AutowirePass extends \RectorPrefix20220607\Symfony\Component\DependencyInj /** * {@inheritdoc} */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { $this->populateCombinedAliases($container); try { @@ -129,7 +129,7 @@ class AutowirePass extends \RectorPrefix20220607\Symfony\Component\DependencyInj { try { return $this->doProcessValue($value, $isRoot); - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\AutowiringFailedException $e) { + } catch (AutowiringFailedException $e) { if ($this->throwOnAutowiringException) { throw $e; } @@ -143,19 +143,19 @@ class AutowirePass extends \RectorPrefix20220607\Symfony\Component\DependencyInj */ private function doProcessValue($value, bool $isRoot = \false) { - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference) { + if ($value instanceof TypedReference) { if ($ref = $this->getAutowiredReference($value, \true)) { return $ref; } - if (\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE === $value->getInvalidBehavior()) { + if (ContainerBuilder::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE === $value->getInvalidBehavior()) { $message = $this->createTypeNotFoundMessageCallback($value, 'it'); // since the error message varies by referenced id and $this->currentId, so should the id of the dummy errored definition $this->container->register($id = \sprintf('.errored.%s.%s', $this->currentId, (string) $value), $value->getType())->addError($message); - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference($id, $value->getType(), $value->getInvalidBehavior(), $value->getName()); + return new TypedReference($id, $value->getType(), $value->getInvalidBehavior(), $value->getName()); } } $value = parent::processValue($value, $isRoot); - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition || !$value->isAutowired() || $value->isAbstract() || !$value->getClass()) { + if (!$value instanceof Definition || !$value->isAutowired() || $value->isAbstract() || !$value->getClass()) { return $value; } if (!($reflectionClass = $this->container->getReflectionClass($value->getClass(), \false))) { @@ -165,8 +165,8 @@ class AutowirePass extends \RectorPrefix20220607\Symfony\Component\DependencyInj $this->methodCalls = $value->getMethodCalls(); try { $constructor = $this->getConstructor($value, \false); - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException $e) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\AutowiringFailedException($this->currentId, $e->getMessage(), 0, $e); + } catch (RuntimeException $e) { + throw new AutowiringFailedException($this->currentId, $e->getMessage(), 0, $e); } if ($constructor) { \array_unshift($this->methodCalls, [$constructor, $value->getArguments()]); @@ -198,10 +198,10 @@ class AutowirePass extends \RectorPrefix20220607\Symfony\Component\DependencyInj if ($method instanceof \ReflectionFunctionAbstract) { $reflectionMethod = $method; } else { - $definition = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition($reflectionClass->name); + $definition = new Definition($reflectionClass->name); try { $reflectionMethod = $this->getReflectionMethod($definition, $method); - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException $e) { + } catch (RuntimeException $e) { if ($definition->getFactory()) { continue; } @@ -256,31 +256,31 @@ class AutowirePass extends \RectorPrefix20220607\Symfony\Component\DependencyInj if (\array_key_exists($index, $arguments) && '' !== $arguments[$index]) { continue; } - $type = \RectorPrefix20220607\Symfony\Component\DependencyInjection\LazyProxy\ProxyHelper::getTypeHint($reflectionMethod, $parameter, \true); + $type = ProxyHelper::getTypeHint($reflectionMethod, $parameter, \true); if ($checkAttributes) { foreach (\method_exists($parameter, 'getAttributes') ? $parameter->getAttributes() : [] as $attribute) { - if (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Attribute\TaggedIterator::class === $attribute->getName()) { + if (TaggedIterator::class === $attribute->getName()) { $attribute = $attribute->newInstance(); - $arguments[$index] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument($attribute->tag, $attribute->indexAttribute, $attribute->defaultIndexMethod, \false, $attribute->defaultPriorityMethod, (array) $attribute->exclude); + $arguments[$index] = new TaggedIteratorArgument($attribute->tag, $attribute->indexAttribute, $attribute->defaultIndexMethod, \false, $attribute->defaultPriorityMethod, (array) $attribute->exclude); break; } - if (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Attribute\TaggedLocator::class === $attribute->getName()) { + if (TaggedLocator::class === $attribute->getName()) { $attribute = $attribute->newInstance(); - $arguments[$index] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument(new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument($attribute->tag, $attribute->indexAttribute, $attribute->defaultIndexMethod, \true, $attribute->defaultPriorityMethod, (array) $attribute->exclude)); + $arguments[$index] = new ServiceLocatorArgument(new TaggedIteratorArgument($attribute->tag, $attribute->indexAttribute, $attribute->defaultIndexMethod, \true, $attribute->defaultPriorityMethod, (array) $attribute->exclude)); break; } - if (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Attribute\Autowire::class === $attribute->getName()) { + if (Autowire::class === $attribute->getName()) { $value = $attribute->newInstance()->value; $value = $this->container->getParameterBag()->resolveValue($value); - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference && $parameter->allowsNull()) { - $value = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($value, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::NULL_ON_INVALID_REFERENCE); + if ($value instanceof Reference && $parameter->allowsNull()) { + $value = new Reference($value, ContainerInterface::NULL_ON_INVALID_REFERENCE); } $arguments[$index] = $value; break; } - if (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Attribute\MapDecorated::class === $attribute->getName()) { + if (MapDecorated::class === $attribute->getName()) { $definition = $this->container->getDefinition($this->currentId); - $arguments[$index] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($definition->innerServiceId ?? $this->currentId . '.inner', $definition->decorationOnInvalid ?? \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::NULL_ON_INVALID_REFERENCE); + $arguments[$index] = new Reference($definition->innerServiceId ?? $this->currentId . '.inner', $definition->decorationOnInvalid ?? ContainerInterface::NULL_ON_INVALID_REFERENCE); break; } } @@ -301,9 +301,9 @@ class AutowirePass extends \RectorPrefix20220607\Symfony\Component\DependencyInj --$index; break; } - $type = \RectorPrefix20220607\Symfony\Component\DependencyInjection\LazyProxy\ProxyHelper::getTypeHint($reflectionMethod, $parameter, \false); + $type = ProxyHelper::getTypeHint($reflectionMethod, $parameter, \false); $type = $type ? \sprintf('is type-hinted "%s"', \ltrim($type, '\\')) : 'has no type-hint'; - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\AutowiringFailedException($this->currentId, \sprintf('Cannot autowire service "%s": argument "$%s" of method "%s()" %s, you should configure its value explicitly.', $this->currentId, $parameter->name, $class !== $this->currentId ? $class . '::' . $method : $method, $type)); + throw new AutowiringFailedException($this->currentId, \sprintf('Cannot autowire service "%s": argument "$%s" of method "%s()" %s, you should configure its value explicitly.', $this->currentId, $parameter->name, $class !== $this->currentId ? $class . '::' . $method : $method, $type)); } // specifically pass the default value $arguments[$index] = clone $this->defaultArgument; @@ -311,13 +311,13 @@ class AutowirePass extends \RectorPrefix20220607\Symfony\Component\DependencyInj continue; } $getValue = function () use($type, $parameter, $class, $method) { - if (!($value = $this->getAutowiredReference($ref = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference($type, $type, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder::EXCEPTION_ON_INVALID_REFERENCE, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Attribute\Target::parseName($parameter)), \true))) { + if (!($value = $this->getAutowiredReference($ref = new TypedReference($type, $type, ContainerBuilder::EXCEPTION_ON_INVALID_REFERENCE, Target::parseName($parameter)), \true))) { $failureMessage = $this->createTypeNotFoundMessageCallback($ref, \sprintf('argument "$%s" of method "%s()"', $parameter->name, $class !== $this->currentId ? $class . '::' . $method : $method)); if ($parameter->isDefaultValueAvailable()) { $value = clone $this->defaultArgument; $value->value = $parameter->getDefaultValue(); } elseif (!$parameter->allowsNull()) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\AutowiringFailedException($this->currentId, $failureMessage); + throw new AutowiringFailedException($this->currentId, $failureMessage); } } return $value; @@ -332,7 +332,7 @@ class AutowirePass extends \RectorPrefix20220607\Symfony\Component\DependencyInj $this->decoratedClass = null; // Prevent further checks } else { - $arguments[$index] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference($this->decoratedId, $this->decoratedClass); + $arguments[$index] = new TypedReference($this->decoratedId, $this->decoratedClass); $this->getPreviousValue = $getValue; $this->decoratedMethodIndex = $methodIndex; $this->decoratedMethodArgumentIndex = $index; @@ -357,7 +357,7 @@ class AutowirePass extends \RectorPrefix20220607\Symfony\Component\DependencyInj /** * Returns a reference to the service matching the given type, if any. */ - private function getAutowiredReference(\RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference $reference, bool $filterType) : ?\RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference + private function getAutowiredReference(TypedReference $reference, bool $filterType) : ?TypedReference { $this->lastFailure = null; $type = $reference->getType(); @@ -371,31 +371,31 @@ class AutowirePass extends \RectorPrefix20220607\Symfony\Component\DependencyInj } if (null !== ($name = $reference->getName())) { if ($this->container->has($alias = $type . ' $' . $name) && !$this->container->findDefinition($alias)->isAbstract()) { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference($alias, $type, $reference->getInvalidBehavior()); + return new TypedReference($alias, $type, $reference->getInvalidBehavior()); } if (null !== ($alias = $this->combinedAliases[$alias] ?? null) && !$this->container->findDefinition($alias)->isAbstract()) { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference($alias, $type, $reference->getInvalidBehavior()); + return new TypedReference($alias, $type, $reference->getInvalidBehavior()); } if ($this->container->has($name) && !$this->container->findDefinition($name)->isAbstract()) { foreach ($this->container->getAliases() + $this->combinedAliases as $id => $alias) { if ($name === (string) $alias && \strncmp($id, $type . ' $', \strlen($type . ' $')) === 0) { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference($name, $type, $reference->getInvalidBehavior()); + return new TypedReference($name, $type, $reference->getInvalidBehavior()); } } } } if ($this->container->has($type) && !$this->container->findDefinition($type)->isAbstract()) { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference($type, $type, $reference->getInvalidBehavior()); + return new TypedReference($type, $type, $reference->getInvalidBehavior()); } if (null !== ($alias = $this->combinedAliases[$type] ?? null) && !$this->container->findDefinition($alias)->isAbstract()) { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference($alias, $type, $reference->getInvalidBehavior()); + return new TypedReference($alias, $type, $reference->getInvalidBehavior()); } return null; } /** * Populates the list of available types. */ - private function populateAvailableTypes(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + private function populateAvailableTypes(ContainerBuilder $container) { $this->types = []; $this->ambiguousServiceTypes = []; @@ -410,7 +410,7 @@ class AutowirePass extends \RectorPrefix20220607\Symfony\Component\DependencyInj /** * Populates the list of available types for a given definition. */ - private function populateAvailableType(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container, string $id, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) + private function populateAvailableType(ContainerBuilder $container, string $id, Definition $definition) { // Never use abstract services if ($definition->isAbstract()) { @@ -449,10 +449,10 @@ class AutowirePass extends \RectorPrefix20220607\Symfony\Component\DependencyInj } $this->ambiguousServiceTypes[$type][] = $id; } - private function createTypeNotFoundMessageCallback(\RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference $reference, string $label) : \Closure + private function createTypeNotFoundMessageCallback(TypedReference $reference, string $label) : \Closure { if (null === $this->typesClone->container) { - $this->typesClone->container = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder($this->container->getParameterBag()); + $this->typesClone->container = new ContainerBuilder($this->container->getParameterBag()); $this->typesClone->container->setAliases($this->container->getAliases()); $this->typesClone->container->setDefinitions($this->container->getDefinitions()); $this->typesClone->container->setResourceTracking(\false); @@ -462,12 +462,12 @@ class AutowirePass extends \RectorPrefix20220607\Symfony\Component\DependencyInj return $this->createTypeNotFoundMessage($reference, $label, $currentId); })->bindTo($this->typesClone); } - private function createTypeNotFoundMessage(\RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference $reference, string $label, string $currentId) : string + private function createTypeNotFoundMessage(TypedReference $reference, string $label, string $currentId) : string { if (!($r = $this->container->getReflectionClass($type = $reference->getType(), \false))) { // either $type does not exist or a parent class does not exist try { - $resource = new \RectorPrefix20220607\Symfony\Component\Config\Resource\ClassExistenceResource($type, \false); + $resource = new ClassExistenceResource($type, \false); // isFresh() will explode ONLY if a parent class/trait does not exist $resource->isFresh(0); $parentMsg = \false; @@ -490,7 +490,7 @@ class AutowirePass extends \RectorPrefix20220607\Symfony\Component\DependencyInj } return $message; } - private function createTypeAlternatives(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container, \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference $reference) : string + private function createTypeAlternatives(ContainerBuilder $container, TypedReference $reference) : string { // try suggesting available aliases first if ($message = $this->getAliasesSuggestionForType($container, $type = $reference->getType())) { @@ -514,7 +514,7 @@ class AutowirePass extends \RectorPrefix20220607\Symfony\Component\DependencyInj } return \sprintf(' You should maybe alias this %s to %s.', \class_exists($type, \false) ? 'class' : 'interface', $message); } - private function getAliasesSuggestionForType(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container, string $type) : ?string + private function getAliasesSuggestionForType(ContainerBuilder $container, string $type) : ?string { $aliases = []; foreach (\class_parents($type) + \class_implements($type) as $parent) { @@ -546,7 +546,7 @@ class AutowirePass extends \RectorPrefix20220607\Symfony\Component\DependencyInj $this->autowiringAliases[$type][$name] = $name; } } - private function populateCombinedAliases(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) : void + private function populateCombinedAliases(ContainerBuilder $container) : void { $this->combinedAliases = []; $reverseAliases = []; diff --git a/vendor/symfony/dependency-injection/Compiler/AutowireRequiredMethodsPass.php b/vendor/symfony/dependency-injection/Compiler/AutowireRequiredMethodsPass.php index 9429f6cbd96..ffc1adf5724 100644 --- a/vendor/symfony/dependency-injection/Compiler/AutowireRequiredMethodsPass.php +++ b/vendor/symfony/dependency-injection/Compiler/AutowireRequiredMethodsPass.php @@ -17,7 +17,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; * * @author Nicolas Grekas */ -class AutowireRequiredMethodsPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class AutowireRequiredMethodsPass extends AbstractRecursivePass { /** * {@inheritdoc} @@ -27,7 +27,7 @@ class AutowireRequiredMethodsPass extends \RectorPrefix20220607\Symfony\Componen protected function processValue($value, bool $isRoot = \false) { $value = parent::processValue($value, $isRoot); - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition || !$value->isAutowired() || $value->isAbstract() || !$value->getClass()) { + if (!$value instanceof Definition || !$value->isAutowired() || $value->isAbstract() || !$value->getClass()) { return $value; } if (!($reflectionClass = $this->container->getReflectionClass($value->getClass(), \false))) { @@ -44,7 +44,7 @@ class AutowireRequiredMethodsPass extends \RectorPrefix20220607\Symfony\Componen continue; } while (\true) { - if (\method_exists($r, 'getAttributes') ? $r->getAttributes(\RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required::class) : []) { + if (\method_exists($r, 'getAttributes') ? $r->getAttributes(Required::class) : []) { if ($this->isWither($r, $r->getDocComment() ?: '')) { $withers[] = [$r->name, [], \true]; } else { diff --git a/vendor/symfony/dependency-injection/Compiler/AutowireRequiredPropertiesPass.php b/vendor/symfony/dependency-injection/Compiler/AutowireRequiredPropertiesPass.php index e2f7d4146fe..3e84a2b1b89 100644 --- a/vendor/symfony/dependency-injection/Compiler/AutowireRequiredPropertiesPass.php +++ b/vendor/symfony/dependency-injection/Compiler/AutowireRequiredPropertiesPass.php @@ -20,7 +20,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required; * @author Sebastien Morel (Plopix) * @author Nicolas Grekas */ -class AutowireRequiredPropertiesPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class AutowireRequiredPropertiesPass extends AbstractRecursivePass { /** * {@inheritdoc} @@ -30,7 +30,7 @@ class AutowireRequiredPropertiesPass extends \RectorPrefix20220607\Symfony\Compo protected function processValue($value, bool $isRoot = \false) { $value = parent::processValue($value, $isRoot); - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition || !$value->isAutowired() || $value->isAbstract() || !$value->getClass()) { + if (!$value instanceof Definition || !$value->isAutowired() || $value->isAbstract() || !$value->getClass()) { return $value; } if (!($reflectionClass = $this->container->getReflectionClass($value->getClass(), \false))) { @@ -41,14 +41,14 @@ class AutowireRequiredPropertiesPass extends \RectorPrefix20220607\Symfony\Compo if (!($type = \method_exists($reflectionProperty, 'getType') ? $reflectionProperty->getType() : null) instanceof \ReflectionNamedType) { continue; } - if (!(\method_exists($reflectionProperty, 'getAttributes') ? $reflectionProperty->getAttributes(\RectorPrefix20220607\Symfony\Contracts\Service\Attribute\Required::class) : []) && (\false === ($doc = $reflectionProperty->getDocComment()) || \false === \stripos($doc, '@required') || !\preg_match('#(?:^/\\*\\*|\\n\\s*+\\*)\\s*+@required(?:\\s|\\*/$)#i', $doc))) { + if (!(\method_exists($reflectionProperty, 'getAttributes') ? $reflectionProperty->getAttributes(Required::class) : []) && (\false === ($doc = $reflectionProperty->getDocComment()) || \false === \stripos($doc, '@required') || !\preg_match('#(?:^/\\*\\*|\\n\\s*+\\*)\\s*+@required(?:\\s|\\*/$)#i', $doc))) { continue; } if (\array_key_exists($name = $reflectionProperty->getName(), $properties)) { continue; } $type = $type->getName(); - $value->setProperty($name, new \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference($type, $type, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $name)); + $value->setProperty($name, new TypedReference($type, $type, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $name)); } return $value; } diff --git a/vendor/symfony/dependency-injection/Compiler/CheckArgumentsValidityPass.php b/vendor/symfony/dependency-injection/Compiler/CheckArgumentsValidityPass.php index 5a5fc6cb65e..35ca168992a 100644 --- a/vendor/symfony/dependency-injection/Compiler/CheckArgumentsValidityPass.php +++ b/vendor/symfony/dependency-injection/Compiler/CheckArgumentsValidityPass.php @@ -18,7 +18,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\Runtime * @author Kévin Dunglas * @author Nicolas Grekas */ -class CheckArgumentsValidityPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class CheckArgumentsValidityPass extends AbstractRecursivePass { /** * @var bool @@ -35,7 +35,7 @@ class CheckArgumentsValidityPass extends \RectorPrefix20220607\Symfony\Component */ protected function processValue($value, bool $isRoot = \false) { - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + if (!$value instanceof Definition) { return parent::processValue($value, $isRoot); } $i = 0; @@ -50,21 +50,21 @@ class CheckArgumentsValidityPass extends \RectorPrefix20220607\Symfony\Component $msg = \sprintf('Invalid constructor argument for service "%s": integer expected but found string "%s". Check your service definition.', $this->currentId, $k); $value->addError($msg); if ($this->throwExceptions) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException($msg); + throw new RuntimeException($msg); } break; } $msg = \sprintf('Invalid constructor argument %d for service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $this->currentId, $i); $value->addError($msg); if ($this->throwExceptions) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException($msg); + throw new RuntimeException($msg); } } if ($hasNamedArgs) { $msg = \sprintf('Invalid constructor argument for service "%s": cannot use positional argument after named argument. Check your service definition.', $this->currentId); $value->addError($msg); if ($this->throwExceptions) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException($msg); + throw new RuntimeException($msg); } break; } @@ -82,21 +82,21 @@ class CheckArgumentsValidityPass extends \RectorPrefix20220607\Symfony\Component $msg = \sprintf('Invalid argument for method call "%s" of service "%s": integer expected but found string "%s". Check your service definition.', $methodCall[0], $this->currentId, $k); $value->addError($msg); if ($this->throwExceptions) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException($msg); + throw new RuntimeException($msg); } break; } $msg = \sprintf('Invalid argument %d for method call "%s" of service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $methodCall[0], $this->currentId, $i); $value->addError($msg); if ($this->throwExceptions) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException($msg); + throw new RuntimeException($msg); } } if ($hasNamedArgs) { $msg = \sprintf('Invalid argument for method call "%s" of service "%s": cannot use positional argument after named argument. Check your service definition.', $methodCall[0], $this->currentId); $value->addError($msg); if ($this->throwExceptions) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException($msg); + throw new RuntimeException($msg); } break; } diff --git a/vendor/symfony/dependency-injection/Compiler/CheckCircularReferencesPass.php b/vendor/symfony/dependency-injection/Compiler/CheckCircularReferencesPass.php index 129f0a9dd20..ffcfcf1829f 100644 --- a/vendor/symfony/dependency-injection/Compiler/CheckCircularReferencesPass.php +++ b/vendor/symfony/dependency-injection/Compiler/CheckCircularReferencesPass.php @@ -22,7 +22,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\Service * * @author Johannes M. Schmitt */ -class CheckCircularReferencesPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +class CheckCircularReferencesPass implements CompilerPassInterface { /** * @var mixed[] @@ -35,7 +35,7 @@ class CheckCircularReferencesPass implements \RectorPrefix20220607\Symfony\Compo /** * Checks the ContainerBuilder object for circular references. */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { $graph = $container->getCompiler()->getServiceReferenceGraph(); $this->checkedNodes = []; @@ -62,7 +62,7 @@ class CheckCircularReferencesPass implements \RectorPrefix20220607\Symfony\Compo $searchKey = \array_search($id, $this->currentPath); $this->currentPath[] = $id; if (\false !== $searchKey) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException($id, \array_slice($this->currentPath, $searchKey)); + throw new ServiceCircularReferenceException($id, \array_slice($this->currentPath, $searchKey)); } $this->checkOutEdges($node->getOutEdges()); } diff --git a/vendor/symfony/dependency-injection/Compiler/CheckDefinitionValidityPass.php b/vendor/symfony/dependency-injection/Compiler/CheckDefinitionValidityPass.php index b7c8afcbc2c..dbf1f63006b 100644 --- a/vendor/symfony/dependency-injection/Compiler/CheckDefinitionValidityPass.php +++ b/vendor/symfony/dependency-injection/Compiler/CheckDefinitionValidityPass.php @@ -26,39 +26,39 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\FileLoader * * @author Johannes M. Schmitt */ -class CheckDefinitionValidityPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +class CheckDefinitionValidityPass implements CompilerPassInterface { /** * Processes the ContainerBuilder to validate the Definition. * * @throws RuntimeException When the Definition is invalid */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { foreach ($container->getDefinitions() as $id => $definition) { // synthetic service is public if ($definition->isSynthetic() && !$definition->isPublic()) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('A synthetic service ("%s") must be public.', $id)); + throw new RuntimeException(\sprintf('A synthetic service ("%s") must be public.', $id)); } // non-synthetic, non-abstract service has class - if (!$definition->isAbstract() && !$definition->isSynthetic() && !$definition->getClass() && !$definition->hasTag('container.service_locator') && (!$definition->getFactory() || !\preg_match(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\FileLoader::ANONYMOUS_ID_REGEXP, $id))) { + if (!$definition->isAbstract() && !$definition->isSynthetic() && !$definition->getClass() && !$definition->hasTag('container.service_locator') && (!$definition->getFactory() || !\preg_match(FileLoader::ANONYMOUS_ID_REGEXP, $id))) { if ($definition->getFactory()) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Please add the class to service "%s" even if it is constructed by a factory since we might need to add method calls based on compile-time checks.', $id)); + throw new RuntimeException(\sprintf('Please add the class to service "%s" even if it is constructed by a factory since we might need to add method calls based on compile-time checks.', $id)); } if (\class_exists($id) || \interface_exists($id, \false)) { if (\strncmp($id, '\\', \strlen('\\')) === 0 && 1 < \substr_count($id, '\\')) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('The definition for "%s" has no class attribute, and appears to reference a class or interface. Please specify the class attribute explicitly or remove the leading backslash by renaming the service to "%s" to get rid of this error.', $id, \substr($id, 1))); + throw new RuntimeException(\sprintf('The definition for "%s" has no class attribute, and appears to reference a class or interface. Please specify the class attribute explicitly or remove the leading backslash by renaming the service to "%s" to get rid of this error.', $id, \substr($id, 1))); } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('The definition for "%s" has no class attribute, and appears to reference a class or interface in the global namespace. Leaving out the "class" attribute is only allowed for namespaced classes. Please specify the class attribute explicitly to get rid of this error.', $id)); + throw new RuntimeException(\sprintf('The definition for "%s" has no class attribute, and appears to reference a class or interface in the global namespace. Leaving out the "class" attribute is only allowed for namespaced classes. Please specify the class attribute explicitly to get rid of this error.', $id)); } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('The definition for "%s" has no class. If you intend to inject this service dynamically at runtime, please mark it as synthetic=true. If this is an abstract definition solely used by child definitions, please add abstract=true, otherwise specify a class to get rid of this error.', $id)); + throw new RuntimeException(\sprintf('The definition for "%s" has no class. If you intend to inject this service dynamically at runtime, please mark it as synthetic=true. If this is an abstract definition solely used by child definitions, please add abstract=true, otherwise specify a class to get rid of this error.', $id)); } // tag attribute values must be scalars foreach ($definition->getTags() as $name => $tags) { foreach ($tags as $attributes) { foreach ($attributes as $attribute => $value) { if (!\is_scalar($value) && null !== $value) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s".', $id, $name, $attribute)); + throw new RuntimeException(\sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s".', $id, $name, $attribute)); } } } @@ -66,7 +66,7 @@ class CheckDefinitionValidityPass implements \RectorPrefix20220607\Symfony\Compo if ($definition->isPublic() && !$definition->isPrivate()) { $resolvedId = $container->resolveEnvPlaceholders($id, null, $usedEnvs); if (null !== $usedEnvs) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\EnvParameterException([$resolvedId], null, 'A service name ("%s") cannot contain dynamic values.'); + throw new EnvParameterException([$resolvedId], null, 'A service name ("%s") cannot contain dynamic values.'); } } } @@ -74,7 +74,7 @@ class CheckDefinitionValidityPass implements \RectorPrefix20220607\Symfony\Compo if ($alias->isPublic() && !$alias->isPrivate()) { $resolvedId = $container->resolveEnvPlaceholders($id, null, $usedEnvs); if (null !== $usedEnvs) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\EnvParameterException([$resolvedId], null, 'An alias name ("%s") cannot contain dynamic values.'); + throw new EnvParameterException([$resolvedId], null, 'An alias name ("%s") cannot contain dynamic values.'); } } } diff --git a/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php b/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php index bef9e6ca6c4..2e3852bd5bc 100644 --- a/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php +++ b/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php @@ -19,7 +19,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference; * * @author Johannes M. Schmitt */ -class CheckExceptionOnInvalidReferenceBehaviorPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class CheckExceptionOnInvalidReferenceBehaviorPass extends AbstractRecursivePass { /** * @var mixed[] @@ -28,7 +28,7 @@ class CheckExceptionOnInvalidReferenceBehaviorPass extends \RectorPrefix20220607 /** * {@inheritdoc} */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { $this->serviceLocatorContextIds = []; foreach ($container->findTaggedServiceIds('container.service_locator_context') as $id => $tags) { @@ -47,10 +47,10 @@ class CheckExceptionOnInvalidReferenceBehaviorPass extends \RectorPrefix20220607 */ protected function processValue($value, bool $isRoot = \false) { - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + if (!$value instanceof Reference) { return parent::processValue($value, $isRoot); } - if (\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE < $value->getInvalidBehavior() || $this->container->has($id = (string) $value)) { + if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE < $value->getInvalidBehavior() || $this->container->has($id = (string) $value)) { return $value; } $currentId = $this->currentId; @@ -63,13 +63,13 @@ class CheckExceptionOnInvalidReferenceBehaviorPass extends \RectorPrefix20220607 if ($k !== $id) { $currentId = $k . '" in the container provided to "' . $currentId; } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException($id, $currentId, null, $this->getAlternatives($id)); + throw new ServiceNotFoundException($id, $currentId, null, $this->getAlternatives($id)); } } } if ('.' === $currentId[0] && $graph->hasNode($currentId)) { foreach ($graph->getNode($currentId)->getInEdges() as $edge) { - if (!$edge->getValue() instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference || \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE < $edge->getValue()->getInvalidBehavior()) { + if (!$edge->getValue() instanceof Reference || ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE < $edge->getValue()->getInvalidBehavior()) { continue; } $sourceId = $edge->getSourceNode()->getId(); @@ -79,7 +79,7 @@ class CheckExceptionOnInvalidReferenceBehaviorPass extends \RectorPrefix20220607 } } } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException($id, $currentId, null, $this->getAlternatives($id)); + throw new ServiceNotFoundException($id, $currentId, null, $this->getAlternatives($id)); } private function getAlternatives(string $id) : array { diff --git a/vendor/symfony/dependency-injection/Compiler/CheckReferenceValidityPass.php b/vendor/symfony/dependency-injection/Compiler/CheckReferenceValidityPass.php index 057d4900b0a..23516a8a984 100644 --- a/vendor/symfony/dependency-injection/Compiler/CheckReferenceValidityPass.php +++ b/vendor/symfony/dependency-injection/Compiler/CheckReferenceValidityPass.php @@ -21,7 +21,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference; * * @author Johannes M. Schmitt */ -class CheckReferenceValidityPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class CheckReferenceValidityPass extends AbstractRecursivePass { /** * @param mixed $value @@ -29,13 +29,13 @@ class CheckReferenceValidityPass extends \RectorPrefix20220607\Symfony\Component */ protected function processValue($value, bool $isRoot = \false) { - if ($isRoot && $value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition && ($value->isSynthetic() || $value->isAbstract())) { + if ($isRoot && $value instanceof Definition && ($value->isSynthetic() || $value->isAbstract())) { return $value; } - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference && $this->container->hasDefinition((string) $value)) { + if ($value instanceof Reference && $this->container->hasDefinition((string) $value)) { $targetDefinition = $this->container->getDefinition((string) $value); if ($targetDefinition->isAbstract()) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('The definition "%s" has a reference to an abstract definition "%s". Abstract definitions cannot be the target of references.', $this->currentId, $value)); + throw new RuntimeException(\sprintf('The definition "%s" has a reference to an abstract definition "%s". Abstract definitions cannot be the target of references.', $this->currentId, $value)); } } return parent::processValue($value, $isRoot); diff --git a/vendor/symfony/dependency-injection/Compiler/CheckTypeDeclarationsPass.php b/vendor/symfony/dependency-injection/Compiler/CheckTypeDeclarationsPass.php index 5d15aab1d61..e0785dae9c0 100644 --- a/vendor/symfony/dependency-injection/Compiler/CheckTypeDeclarationsPass.php +++ b/vendor/symfony/dependency-injection/Compiler/CheckTypeDeclarationsPass.php @@ -37,7 +37,7 @@ use RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression; * @author Nicolas Grekas * @author Julien Maulny */ -final class CheckTypeDeclarationsPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +final class CheckTypeDeclarationsPass extends AbstractRecursivePass { private const SCALAR_TYPES = ['int' => \true, 'float' => \true, 'bool' => \true, 'string' => \true]; private const BUILTIN_TYPES = ['array' => \true, 'bool' => \true, 'callable' => \true, 'float' => \true, 'int' => \true, 'iterable' => \true, 'object' => \true, 'string' => \true]; @@ -73,7 +73,7 @@ final class CheckTypeDeclarationsPass extends \RectorPrefix20220607\Symfony\Comp if (isset($this->skippedIds[$this->currentId])) { return $value; } - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition || $value->hasErrors() || $value->isDeprecated()) { + if (!$value instanceof Definition || $value->hasErrors() || $value->isDeprecated()) { return parent::processValue($value, $isRoot); } if (!$this->autoload) { @@ -84,7 +84,7 @@ final class CheckTypeDeclarationsPass extends \RectorPrefix20220607\Symfony\Comp return parent::processValue($value, $isRoot); } } - if (\RectorPrefix20220607\Symfony\Component\DependencyInjection\ServiceLocator::class === $value->getClass()) { + if (ServiceLocator::class === $value->getClass()) { return parent::processValue($value, $isRoot); } if ($constructor = $this->getConstructor($value, \false)) { @@ -93,7 +93,7 @@ final class CheckTypeDeclarationsPass extends \RectorPrefix20220607\Symfony\Comp foreach ($value->getMethodCalls() as $methodCall) { try { $reflectionMethod = $this->getReflectionMethod($value, $methodCall[0]); - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException $e) { + } catch (RuntimeException $e) { if ($value->getFactory()) { continue; } @@ -106,15 +106,15 @@ final class CheckTypeDeclarationsPass extends \RectorPrefix20220607\Symfony\Comp /** * @throws InvalidArgumentException When not enough parameters are defined for the method */ - private function checkTypeDeclarations(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $checkedDefinition, \ReflectionFunctionAbstract $reflectionFunction, array $values) : void + private function checkTypeDeclarations(Definition $checkedDefinition, \ReflectionFunctionAbstract $reflectionFunction, array $values) : void { $numberOfRequiredParameters = $reflectionFunction->getNumberOfRequiredParameters(); if (\count($values) < $numberOfRequiredParameters) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid definition for service "%s": "%s::%s()" requires %d arguments, %d passed.', $this->currentId, $reflectionFunction->class, $reflectionFunction->name, $numberOfRequiredParameters, \count($values))); + throw new InvalidArgumentException(\sprintf('Invalid definition for service "%s": "%s::%s()" requires %d arguments, %d passed.', $this->currentId, $reflectionFunction->class, $reflectionFunction->name, $numberOfRequiredParameters, \count($values))); } $reflectionParameters = $reflectionFunction->getParameters(); $checksCount = \min($reflectionFunction->getNumberOfParameters(), \count($values)); - $envPlaceholderUniquePrefix = $this->container->getParameterBag() instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag ? $this->container->getParameterBag()->getEnvPlaceholderUniquePrefix() : null; + $envPlaceholderUniquePrefix = $this->container->getParameterBag() instanceof EnvPlaceholderParameterBag ? $this->container->getParameterBag()->getEnvPlaceholderUniquePrefix() : null; for ($i = 0; $i < $checksCount; ++$i) { if (!$reflectionParameters[$i]->hasType() || $reflectionParameters[$i]->isVariadic()) { continue; @@ -132,7 +132,7 @@ final class CheckTypeDeclarationsPass extends \RectorPrefix20220607\Symfony\Comp * @throws InvalidParameterTypeException When a parameter is not compatible with the declared type * @param mixed $value */ - private function checkType(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $checkedDefinition, $value, \ReflectionParameter $parameter, ?string $envPlaceholderUniquePrefix, \ReflectionType $reflectionType = null) : void + private function checkType(Definition $checkedDefinition, $value, \ReflectionParameter $parameter, ?string $envPlaceholderUniquePrefix, \ReflectionType $reflectionType = null) : void { $reflectionType = $reflectionType ?? $parameter->getType(); if ($reflectionType instanceof \ReflectionUnionType) { @@ -140,12 +140,12 @@ final class CheckTypeDeclarationsPass extends \RectorPrefix20220607\Symfony\Comp try { $this->checkType($checkedDefinition, $value, $parameter, $envPlaceholderUniquePrefix, $t); return; - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidParameterTypeException $e) { + } catch (InvalidParameterTypeException $e) { } } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidParameterTypeException($this->currentId, $e->getCode(), $parameter); + throw new InvalidParameterTypeException($this->currentId, $e->getCode(), $parameter); } - if ($reflectionType instanceof \RectorPrefix20220607\ReflectionIntersectionType) { + if ($reflectionType instanceof \ReflectionIntersectionType) { foreach ($reflectionType->getTypes() as $t) { $this->checkType($checkedDefinition, $value, $parameter, $envPlaceholderUniquePrefix, $t); } @@ -155,11 +155,11 @@ final class CheckTypeDeclarationsPass extends \RectorPrefix20220607\Symfony\Comp return; } $type = $reflectionType->getName(); - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + if ($value instanceof Reference) { if (!$this->container->has($value = (string) $value)) { return; } - if ('service_container' === $value && \is_a($type, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Container::class, \true)) { + if ('service_container' === $value && \is_a($type, Container::class, \true)) { return; } $value = $this->container->findDefinition($value); @@ -171,7 +171,7 @@ final class CheckTypeDeclarationsPass extends \RectorPrefix20220607\Symfony\Comp $type = $checkedDefinition->getClass(); } $class = null; - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + if ($value instanceof Definition) { if ($value->getFactory()) { return; } @@ -181,9 +181,9 @@ final class CheckTypeDeclarationsPass extends \RectorPrefix20220607\Symfony\Comp } elseif (!$class || !$this->autoload && !\class_exists($class, \false) && !\interface_exists($class, \false)) { return; } - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Parameter) { + } elseif ($value instanceof Parameter) { $value = $this->container->getParameter($value); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression) { + } elseif ($value instanceof Expression) { try { $value = $this->getExpressionLanguage()->evaluate($value, ['container' => $this->container]); } catch (\Exception $exception) { @@ -211,12 +211,12 @@ final class CheckTypeDeclarationsPass extends \RectorPrefix20220607\Symfony\Comp return; } if (null === $class) { - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\IteratorArgument) { - $class = \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\RewindableGenerator::class; - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument) { + if ($value instanceof IteratorArgument) { + $class = RewindableGenerator::class; + } elseif ($value instanceof ServiceClosureArgument) { $class = \Closure::class; - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument) { - $class = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ServiceLocator::class; + } elseif ($value instanceof ServiceLocatorArgument) { + $class = ServiceLocator::class; } elseif (\is_object($value)) { $class = \get_class($value); } else { @@ -233,7 +233,7 @@ final class CheckTypeDeclarationsPass extends \RectorPrefix20220607\Symfony\Comp if ('callable' === $type && (\Closure::class === $class || \method_exists($class, '__invoke'))) { return; } - if ('callable' === $type && \is_array($value) && isset($value[0]) && ($value[0] instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference || $value[0] instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition || \is_string($value[0]))) { + if ('callable' === $type && \is_array($value) && isset($value[0]) && ($value[0] instanceof Reference || $value[0] instanceof Definition || \is_string($value[0]))) { return; } if ('iterable' === $type && (\is_array($value) || 'array' === $class || \is_subclass_of($class, \Traversable::class))) { @@ -261,10 +261,10 @@ final class CheckTypeDeclarationsPass extends \RectorPrefix20220607\Symfony\Comp return; } } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidParameterTypeException($this->currentId, \is_object($value) ? $class : \get_debug_type($value), $parameter); + throw new InvalidParameterTypeException($this->currentId, \is_object($value) ? $class : \get_debug_type($value), $parameter); } - private function getExpressionLanguage() : \RectorPrefix20220607\Symfony\Component\DependencyInjection\ExpressionLanguage + private function getExpressionLanguage() : ExpressionLanguage { - return $this->expressionLanguage = $this->expressionLanguage ?? new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ExpressionLanguage(null, $this->container->getExpressionLanguageProviders()); + return $this->expressionLanguage = $this->expressionLanguage ?? new ExpressionLanguage(null, $this->container->getExpressionLanguageProviders()); } } diff --git a/vendor/symfony/dependency-injection/Compiler/Compiler.php b/vendor/symfony/dependency-injection/Compiler/Compiler.php index 73cc741a567..85c594abc40 100644 --- a/vendor/symfony/dependency-injection/Compiler/Compiler.php +++ b/vendor/symfony/dependency-injection/Compiler/Compiler.php @@ -33,25 +33,25 @@ class Compiler private $serviceReferenceGraph; public function __construct() { - $this->passConfig = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\PassConfig(); - $this->serviceReferenceGraph = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraph(); + $this->passConfig = new PassConfig(); + $this->serviceReferenceGraph = new ServiceReferenceGraph(); } - public function getPassConfig() : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\PassConfig + public function getPassConfig() : PassConfig { return $this->passConfig; } - public function getServiceReferenceGraph() : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraph + public function getServiceReferenceGraph() : ServiceReferenceGraph { return $this->serviceReferenceGraph; } - public function addPass(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface $pass, string $type = \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0) + public function addPass(CompilerPassInterface $pass, string $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0) { $this->passConfig->addPass($pass, $type, $priority); } /** * @final */ - public function log(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface $pass, string $message) + public function log(CompilerPassInterface $pass, string $message) { if (\strpos($message, "\n") !== \false) { $message = \str_replace("\n", "\n" . \get_class($pass) . ': ', \trim($message)); @@ -65,7 +65,7 @@ class Compiler /** * Run the Compiler and process all Passes. */ - public function compile(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function compile(ContainerBuilder $container) { try { foreach ($this->passConfig->getPasses() as $pass) { @@ -82,7 +82,7 @@ class Compiler } } while ($prev = $prev->getPrevious()); if ($usedEnvs) { - $e = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\EnvParameterException($usedEnvs, $e); + $e = new EnvParameterException($usedEnvs, $e); } throw $e; } finally { diff --git a/vendor/symfony/dependency-injection/Compiler/CompilerPassInterface.php b/vendor/symfony/dependency-injection/Compiler/CompilerPassInterface.php index a145573dfbd..b026f55b98f 100644 --- a/vendor/symfony/dependency-injection/Compiler/CompilerPassInterface.php +++ b/vendor/symfony/dependency-injection/Compiler/CompilerPassInterface.php @@ -21,5 +21,5 @@ interface CompilerPassInterface /** * You can modify the container here before it is dumped to PHP code. */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container); + public function process(ContainerBuilder $container); } diff --git a/vendor/symfony/dependency-injection/Compiler/DecoratorServicePass.php b/vendor/symfony/dependency-injection/Compiler/DecoratorServicePass.php index c97a0a0c701..8c21e06a1eb 100644 --- a/vendor/symfony/dependency-injection/Compiler/DecoratorServicePass.php +++ b/vendor/symfony/dependency-injection/Compiler/DecoratorServicePass.php @@ -23,9 +23,9 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference; * @author Fabien Potencier * @author Diego Saint Esteben */ -class DecoratorServicePass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class DecoratorServicePass extends AbstractRecursivePass { - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { $definitions = new \SplPriorityQueue(); $order = \PHP_INT_MAX; @@ -40,7 +40,7 @@ class DecoratorServicePass extends \RectorPrefix20220607\Symfony\Component\Depen foreach ($definitions as [$id, $definition]) { $decoratedService = $definition->getDecoratedService(); [$inner, $renamedId] = $decoratedService; - $invalidBehavior = $decoratedService[3] ?? \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; + $invalidBehavior = $decoratedService[3] ?? ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; $definition->setDecoratedService(null); if (!$renamedId) { $renamedId = $id . '.inner'; @@ -54,7 +54,7 @@ class DecoratorServicePass extends \RectorPrefix20220607\Symfony\Component\Depen if ($container->hasAlias($inner)) { $alias = $container->getAlias($inner); $public = $alias->isPublic(); - $container->setAlias($renamedId, new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Alias((string) $alias, \false)); + $container->setAlias($renamedId, new Alias((string) $alias, \false)); $decoratedDefinition = $container->findDefinition($alias); } elseif ($container->hasDefinition($inner)) { $decoratedDefinition = $container->getDefinition($inner); @@ -62,17 +62,17 @@ class DecoratorServicePass extends \RectorPrefix20220607\Symfony\Component\Depen $decoratedDefinition->setPublic(\false); $container->setDefinition($renamedId, $decoratedDefinition); $decoratingDefinitions[$inner] = $decoratedDefinition; - } elseif (\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $invalidBehavior) { + } elseif (ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $invalidBehavior) { $container->removeDefinition($id); continue; - } elseif (\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::NULL_ON_INVALID_REFERENCE === $invalidBehavior) { + } elseif (ContainerInterface::NULL_ON_INVALID_REFERENCE === $invalidBehavior) { $public = $definition->isPublic(); $decoratedDefinition = null; } else { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException($inner, $id); + throw new ServiceNotFoundException($inner, $id); } if (($decoratedDefinition2 = $decoratedDefinition) ? $decoratedDefinition2->isSynthetic() : null) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('A synthetic service cannot be decorated: service "%s" cannot decorate "%s".', $id, $inner)); + throw new InvalidArgumentException(\sprintf('A synthetic service cannot be decorated: service "%s" cannot decorate "%s".', $id, $inner)); } if (isset($decoratingDefinitions[$inner])) { $decoratingDefinition = $decoratingDefinitions[$inner]; @@ -98,8 +98,8 @@ class DecoratorServicePass extends \RectorPrefix20220607\Symfony\Component\Depen */ protected function processValue($value, bool $isRoot = \false) { - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference && '.inner' === (string) $value) { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($this->currentId, $value->getInvalidBehavior()); + if ($value instanceof Reference && '.inner' === (string) $value) { + return new Reference($this->currentId, $value->getInvalidBehavior()); } return parent::processValue($value, $isRoot); } diff --git a/vendor/symfony/dependency-injection/Compiler/DefinitionErrorExceptionPass.php b/vendor/symfony/dependency-injection/Compiler/DefinitionErrorExceptionPass.php index 878d472e1bc..85458b5b98f 100644 --- a/vendor/symfony/dependency-injection/Compiler/DefinitionErrorExceptionPass.php +++ b/vendor/symfony/dependency-injection/Compiler/DefinitionErrorExceptionPass.php @@ -19,7 +19,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference; * * @author Ryan Weaver */ -class DefinitionErrorExceptionPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class DefinitionErrorExceptionPass extends AbstractRecursivePass { /** * {@inheritdoc} @@ -28,14 +28,14 @@ class DefinitionErrorExceptionPass extends \RectorPrefix20220607\Symfony\Compone */ protected function processValue($value, bool $isRoot = \false) { - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition || !$value->hasErrors()) { + if (!$value instanceof Definition || !$value->hasErrors()) { return parent::processValue($value, $isRoot); } if ($isRoot && !$value->isPublic()) { $graph = $this->container->getCompiler()->getServiceReferenceGraph(); $runtimeException = \false; foreach ($graph->getNode($this->currentId)->getInEdges() as $edge) { - if (!$edge->getValue() instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference || \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE !== $edge->getValue()->getInvalidBehavior()) { + if (!$edge->getValue() instanceof Reference || ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE !== $edge->getValue()->getInvalidBehavior()) { $runtimeException = \false; break; } @@ -48,6 +48,6 @@ class DefinitionErrorExceptionPass extends \RectorPrefix20220607\Symfony\Compone // only show the first error so the user can focus on it $errors = $value->getErrors(); $message = \reset($errors); - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException($message); + throw new RuntimeException($message); } } diff --git a/vendor/symfony/dependency-injection/Compiler/ExtensionCompilerPass.php b/vendor/symfony/dependency-injection/Compiler/ExtensionCompilerPass.php index c9a9f548294..e5edfff4b48 100644 --- a/vendor/symfony/dependency-injection/Compiler/ExtensionCompilerPass.php +++ b/vendor/symfony/dependency-injection/Compiler/ExtensionCompilerPass.php @@ -17,15 +17,15 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder; * * @author Wouter J */ -class ExtensionCompilerPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +class ExtensionCompilerPass implements CompilerPassInterface { /** * {@inheritdoc} */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { foreach ($container->getExtensions() as $extension) { - if (!$extension instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface) { + if (!$extension instanceof CompilerPassInterface) { continue; } $extension->process($container); diff --git a/vendor/symfony/dependency-injection/Compiler/InlineServiceDefinitionsPass.php b/vendor/symfony/dependency-injection/Compiler/InlineServiceDefinitionsPass.php index b5ff8e32b4c..b023eba5f12 100644 --- a/vendor/symfony/dependency-injection/Compiler/InlineServiceDefinitionsPass.php +++ b/vendor/symfony/dependency-injection/Compiler/InlineServiceDefinitionsPass.php @@ -20,7 +20,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference; * * @author Johannes M. Schmitt */ -class InlineServiceDefinitionsPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class InlineServiceDefinitionsPass extends AbstractRecursivePass { /** * @var \Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass|null @@ -50,15 +50,15 @@ class InlineServiceDefinitionsPass extends \RectorPrefix20220607\Symfony\Compone * @var \Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraph|null */ private $graph; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass $analyzingPass = null) + public function __construct(AnalyzeServiceReferencesPass $analyzingPass = null) { $this->analyzingPass = $analyzingPass; } - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { $this->container = $container; if ($this->analyzingPass) { - $analyzedContainer = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder(); + $analyzedContainer = new ContainerBuilder(); $analyzedContainer->setAliases($container->getAliases()); $analyzedContainer->setDefinitions($container->getDefinitions()); foreach ($container->getExpressionLanguageProviders() as $provider) { @@ -122,17 +122,17 @@ class InlineServiceDefinitionsPass extends \RectorPrefix20220607\Symfony\Compone */ protected function processValue($value, bool $isRoot = \false) { - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ArgumentInterface) { + if ($value instanceof ArgumentInterface) { // References found in ArgumentInterface::getValues() are not inlineable return $value; } - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition && $this->cloningIds) { + if ($value instanceof Definition && $this->cloningIds) { if ($value->isShared()) { return $value; } $value = clone $value; } - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + if (!$value instanceof Reference) { return parent::processValue($value, $isRoot); } elseif (!$this->container->hasDefinition($id = (string) $value)) { return $value; @@ -151,7 +151,7 @@ class InlineServiceDefinitionsPass extends \RectorPrefix20220607\Symfony\Compone if (isset($this->cloningIds[$id])) { $ids = \array_keys($this->cloningIds); $ids[] = $id; - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException($id, \array_slice($ids, \array_search($id, $ids))); + throw new ServiceCircularReferenceException($id, \array_slice($ids, \array_search($id, $ids))); } $this->cloningIds[$id] = \true; try { @@ -163,7 +163,7 @@ class InlineServiceDefinitionsPass extends \RectorPrefix20220607\Symfony\Compone /** * Checks if the definition is inlineable. */ - private function isInlineableDefinition(string $id, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) : bool + private function isInlineableDefinition(string $id, Definition $definition) : bool { if ($definition->hasErrors() || $definition->isDeprecated() || $definition->isLazy() || $definition->isSynthetic() || $definition->hasTag('container.do_not_inline')) { return \false; @@ -206,7 +206,7 @@ class InlineServiceDefinitionsPass extends \RectorPrefix20220607\Symfony\Compone $this->notInlinedIds[$id] = \true; return \false; } - if ($srcCount > 1 && \is_array($factory = $definition->getFactory()) && ($factory[0] instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference || $factory[0] instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition)) { + if ($srcCount > 1 && \is_array($factory = $definition->getFactory()) && ($factory[0] instanceof Reference || $factory[0] instanceof Definition)) { return \false; } return $this->container->getDefinition($srcId)->isShared(); diff --git a/vendor/symfony/dependency-injection/Compiler/MergeExtensionConfigurationPass.php b/vendor/symfony/dependency-injection/Compiler/MergeExtensionConfigurationPass.php index af704cb133a..307c4d8f71e 100644 --- a/vendor/symfony/dependency-injection/Compiler/MergeExtensionConfigurationPass.php +++ b/vendor/symfony/dependency-injection/Compiler/MergeExtensionConfigurationPass.php @@ -25,20 +25,20 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\Para * * @author Fabien Potencier */ -class MergeExtensionConfigurationPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +class MergeExtensionConfigurationPass implements CompilerPassInterface { /** * {@inheritdoc} */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { $parameters = $container->getParameterBag()->all(); $definitions = $container->getDefinitions(); $aliases = $container->getAliases(); $exprLangProviders = $container->getExpressionLanguageProviders(); - $configAvailable = \class_exists(\RectorPrefix20220607\Symfony\Component\Config\Definition\BaseNode::class); + $configAvailable = \class_exists(BaseNode::class); foreach ($container->getExtensions() as $extension) { - if ($extension instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface) { + if ($extension instanceof PrependExtensionInterface) { $extension->prepend($container); } } @@ -48,19 +48,19 @@ class MergeExtensionConfigurationPass implements \RectorPrefix20220607\Symfony\C continue; } $resolvingBag = $container->getParameterBag(); - if ($resolvingBag instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag && $extension instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\Extension) { + if ($resolvingBag instanceof EnvPlaceholderParameterBag && $extension instanceof Extension) { // create a dedicated bag so that we can track env vars per-extension - $resolvingBag = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationParameterBag($resolvingBag); + $resolvingBag = new MergeExtensionConfigurationParameterBag($resolvingBag); if ($configAvailable) { - \RectorPrefix20220607\Symfony\Component\Config\Definition\BaseNode::setPlaceholderUniquePrefix($resolvingBag->getEnvPlaceholderUniquePrefix()); + BaseNode::setPlaceholderUniquePrefix($resolvingBag->getEnvPlaceholderUniquePrefix()); } } $config = $resolvingBag->resolveValue($config); try { - $tmpContainer = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationContainerBuilder($extension, $resolvingBag); + $tmpContainer = new MergeExtensionConfigurationContainerBuilder($extension, $resolvingBag); $tmpContainer->setResourceTracking($container->isTrackingResources()); $tmpContainer->addObjectResource($extension); - if ($extension instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface && null !== ($configuration = $extension->getConfiguration($config, $tmpContainer))) { + if ($extension instanceof ConfigurationExtensionInterface && null !== ($configuration = $extension->getConfiguration($config, $tmpContainer))) { $tmpContainer->addObjectResource($configuration); } foreach ($exprLangProviders as $provider) { @@ -68,12 +68,12 @@ class MergeExtensionConfigurationPass implements \RectorPrefix20220607\Symfony\C } $extension->load($config, $tmpContainer); } catch (\Exception $e) { - if ($resolvingBag instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationParameterBag) { + if ($resolvingBag instanceof MergeExtensionConfigurationParameterBag) { $container->getParameterBag()->mergeEnvPlaceholders($resolvingBag); } throw $e; } - if ($resolvingBag instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationParameterBag) { + if ($resolvingBag instanceof MergeExtensionConfigurationParameterBag) { // don't keep track of env vars that are *overridden* when configs are merged $resolvingBag->freezeAfterProcessing($extension, $tmpContainer); } @@ -87,7 +87,7 @@ class MergeExtensionConfigurationPass implements \RectorPrefix20220607\Symfony\C /** * @internal */ -class MergeExtensionConfigurationParameterBag extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag +class MergeExtensionConfigurationParameterBag extends EnvPlaceholderParameterBag { /** * @var mixed[] @@ -98,7 +98,7 @@ class MergeExtensionConfigurationParameterBag extends \RectorPrefix20220607\Symf parent::__construct($parameterBag->all()); $this->mergeEnvPlaceholders($parameterBag); } - public function freezeAfterProcessing(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\Extension $extension, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function freezeAfterProcessing(Extension $extension, ContainerBuilder $container) { if (!($config = $extension->getProcessedConfigs())) { // Extension::processConfiguration() wasn't called, we cannot know how configs were merged @@ -133,13 +133,13 @@ class MergeExtensionConfigurationParameterBag extends \RectorPrefix20220607\Symf * * @internal */ -class MergeExtensionConfigurationContainerBuilder extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder +class MergeExtensionConfigurationContainerBuilder extends ContainerBuilder { /** * @var string */ private $extensionClass; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\ExtensionInterface $extension, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface $parameterBag = null) + public function __construct(ExtensionInterface $extension, ParameterBagInterface $parameterBag = null) { parent::__construct($parameterBag); $this->extensionClass = \get_class($extension); @@ -148,23 +148,23 @@ class MergeExtensionConfigurationContainerBuilder extends \RectorPrefix20220607\ * {@inheritdoc} * @return $this */ - public function addCompilerPass(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface $pass, string $type = \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0) + public function addCompilerPass(CompilerPassInterface $pass, string $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicException(\sprintf('You cannot add compiler pass "%s" from extension "%s". Compiler passes must be registered before the container is compiled.', \get_debug_type($pass), $this->extensionClass)); + throw new LogicException(\sprintf('You cannot add compiler pass "%s" from extension "%s". Compiler passes must be registered before the container is compiled.', \get_debug_type($pass), $this->extensionClass)); } /** * {@inheritdoc} */ - public function registerExtension(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\ExtensionInterface $extension) + public function registerExtension(ExtensionInterface $extension) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicException(\sprintf('You cannot register extension "%s" from "%s". Extensions must be registered before the container is compiled.', \get_debug_type($extension), $this->extensionClass)); + throw new LogicException(\sprintf('You cannot register extension "%s" from "%s". Extensions must be registered before the container is compiled.', \get_debug_type($extension), $this->extensionClass)); } /** * {@inheritdoc} */ public function compile(bool $resolveEnvPlaceholders = \false) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicException(\sprintf('Cannot compile the container in extension "%s".', $this->extensionClass)); + throw new LogicException(\sprintf('Cannot compile the container in extension "%s".', $this->extensionClass)); } /** * {@inheritdoc} @@ -179,7 +179,7 @@ class MergeExtensionConfigurationContainerBuilder extends \RectorPrefix20220607\ } $bag = $this->getParameterBag(); $value = $bag->resolveValue($value); - if (!$bag instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag) { + if (!$bag instanceof EnvPlaceholderParameterBag) { return parent::resolveEnvPlaceholders($value, $format, $usedEnvs); } foreach ($bag->getEnvPlaceholders() as $env => $placeholders) { @@ -188,7 +188,7 @@ class MergeExtensionConfigurationContainerBuilder extends \RectorPrefix20220607\ } foreach ($placeholders as $placeholder) { if (\false !== \stripos($value, $placeholder)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Using a cast in "env(%s)" is incompatible with resolution at compile time in "%s". The logic in the extension should be moved to a compiler pass, or an env parameter with no cast should be used instead.', $env, $this->extensionClass)); + throw new RuntimeException(\sprintf('Using a cast in "env(%s)" is incompatible with resolution at compile time in "%s". The logic in the extension should be moved to a compiler pass, or an env parameter with no cast should be used instead.', $env, $this->extensionClass)); } } } diff --git a/vendor/symfony/dependency-injection/Compiler/PassConfig.php b/vendor/symfony/dependency-injection/Compiler/PassConfig.php index 793bd0d8939..673f9d69109 100644 --- a/vendor/symfony/dependency-injection/Compiler/PassConfig.php +++ b/vendor/symfony/dependency-injection/Compiler/PassConfig.php @@ -51,11 +51,11 @@ class PassConfig private $removingPasses; public function __construct() { - $this->mergePass = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass(); - $this->beforeOptimizationPasses = [100 => [new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ResolveClassPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\RegisterAutoconfigureAttributesPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AutowireAsDecoratorPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AttributeAutoconfigurationPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ResolveInstanceofConditionalsPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\RegisterEnvVarProcessorsPass()], -1000 => [new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ExtensionCompilerPass()]]; - $this->optimizationPasses = [[new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AutoAliasServicePass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ValidateEnvPlaceholdersPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ResolveDecoratorStackPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ResolveChildDefinitionsPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\RegisterServiceSubscribersPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ResolveParameterPlaceHoldersPass(\false, \false), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ResolveFactoryClassPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ResolveNamedArgumentsPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AutowireRequiredMethodsPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AutowireRequiredPropertiesPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ResolveBindingsPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\DecoratorServicePass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CheckDefinitionValidityPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AutowirePass(\false), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ResolveTaggedIteratorArgumentPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ResolveServiceSubscribersPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ResolveReferencesToAliasesPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ResolveInvalidReferencesPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass(\true), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CheckCircularReferencesPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CheckReferenceValidityPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CheckArgumentsValidityPass(\false)]]; - $this->removingPasses = [[new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\RemovePrivateAliasesPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\RemoveAbstractDefinitionsPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\RemoveUnusedDefinitionsPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\InlineServiceDefinitionsPass(new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass()), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\DefinitionErrorExceptionPass()]]; - $this->afterRemovingPasses = [[new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ResolveHotPathPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ResolveNoPreloadPass(), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AliasDeprecatedPublicServicesPass()]]; + $this->mergePass = new MergeExtensionConfigurationPass(); + $this->beforeOptimizationPasses = [100 => [new ResolveClassPass(), new RegisterAutoconfigureAttributesPass(), new AutowireAsDecoratorPass(), new AttributeAutoconfigurationPass(), new ResolveInstanceofConditionalsPass(), new RegisterEnvVarProcessorsPass()], -1000 => [new ExtensionCompilerPass()]]; + $this->optimizationPasses = [[new AutoAliasServicePass(), new ValidateEnvPlaceholdersPass(), new ResolveDecoratorStackPass(), new ResolveChildDefinitionsPass(), new RegisterServiceSubscribersPass(), new ResolveParameterPlaceHoldersPass(\false, \false), new ResolveFactoryClassPass(), new ResolveNamedArgumentsPass(), new AutowireRequiredMethodsPass(), new AutowireRequiredPropertiesPass(), new ResolveBindingsPass(), new ServiceLocatorTagPass(), new DecoratorServicePass(), new CheckDefinitionValidityPass(), new AutowirePass(\false), new ServiceLocatorTagPass(), new ResolveTaggedIteratorArgumentPass(), new ResolveServiceSubscribersPass(), new ResolveReferencesToAliasesPass(), new ResolveInvalidReferencesPass(), new AnalyzeServiceReferencesPass(\true), new CheckCircularReferencesPass(), new CheckReferenceValidityPass(), new CheckArgumentsValidityPass(\false)]]; + $this->removingPasses = [[new RemovePrivateAliasesPass(), new ReplaceAliasByActualDefinitionPass(), new RemoveAbstractDefinitionsPass(), new RemoveUnusedDefinitionsPass(), new AnalyzeServiceReferencesPass(), new CheckExceptionOnInvalidReferenceBehaviorPass(), new InlineServiceDefinitionsPass(new AnalyzeServiceReferencesPass()), new AnalyzeServiceReferencesPass(), new DefinitionErrorExceptionPass()]]; + $this->afterRemovingPasses = [[new ResolveHotPathPass(), new ResolveNoPreloadPass(), new AliasDeprecatedPublicServicesPass()]]; } /** * Returns all passes in order to be processed. @@ -71,11 +71,11 @@ class PassConfig * * @throws InvalidArgumentException when a pass type doesn't exist */ - public function addPass(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface $pass, string $type = self::TYPE_BEFORE_OPTIMIZATION, int $priority = 0) + public function addPass(CompilerPassInterface $pass, string $type = self::TYPE_BEFORE_OPTIMIZATION, int $priority = 0) { $property = $type . 'Passes'; if (!isset($this->{$property})) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid type "%s".', $type)); + throw new InvalidArgumentException(\sprintf('Invalid type "%s".', $type)); } $passes =& $this->{$property}; if (!isset($passes[$priority])) { @@ -131,11 +131,11 @@ class PassConfig /** * Gets the Merge pass. */ - public function getMergePass() : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface + public function getMergePass() : CompilerPassInterface { return $this->mergePass; } - public function setMergePass(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface $pass) + public function setMergePass(CompilerPassInterface $pass) { $this->mergePass = $pass; } diff --git a/vendor/symfony/dependency-injection/Compiler/PriorityTaggedServiceTrait.php b/vendor/symfony/dependency-injection/Compiler/PriorityTaggedServiceTrait.php index 1f711918171..027d2fe5a3b 100644 --- a/vendor/symfony/dependency-injection/Compiler/PriorityTaggedServiceTrait.php +++ b/vendor/symfony/dependency-injection/Compiler/PriorityTaggedServiceTrait.php @@ -36,11 +36,11 @@ trait PriorityTaggedServiceTrait * @return Reference[] * @param string|\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument $tagName */ - private function findAndSortTaggedServices($tagName, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) : array + private function findAndSortTaggedServices($tagName, ContainerBuilder $container) : array { $exclude = []; $indexAttribute = $defaultIndexMethod = $needsIndexes = $defaultPriorityMethod = null; - if ($tagName instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument) { + if ($tagName instanceof TaggedIteratorArgument) { $indexAttribute = $tagName->getIndexAttribute(); $defaultIndexMethod = $tagName->getDefaultIndexMethod(); $needsIndexes = $tagName->needsIndexes(); @@ -65,7 +65,7 @@ trait PriorityTaggedServiceTrait if (isset($attribute['priority'])) { $priority = $attribute['priority']; } elseif (null === $defaultPriority && $defaultPriorityMethod && $class) { - $defaultPriority = \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceUtil::getDefault($container, $serviceId, $class, $defaultPriorityMethod, $tagName, 'priority', $checkTaggedItem); + $defaultPriority = PriorityTaggedServiceUtil::getDefault($container, $serviceId, $class, $defaultPriorityMethod, $tagName, 'priority', $checkTaggedItem); } $priority = $priority ?? ($defaultPriority = $defaultPriority ?? 0); if (null === $indexAttribute && !$defaultIndexMethod && !$needsIndexes) { @@ -75,7 +75,7 @@ trait PriorityTaggedServiceTrait if (null !== $indexAttribute && isset($attribute[$indexAttribute])) { $index = $attribute[$indexAttribute]; } elseif (null === $defaultIndex && $defaultPriorityMethod && $class) { - $defaultIndex = \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceUtil::getDefault($container, $serviceId, $class, $defaultIndexMethod ?? 'getDefaultName', $tagName, $indexAttribute, $checkTaggedItem); + $defaultIndex = PriorityTaggedServiceUtil::getDefault($container, $serviceId, $class, $defaultIndexMethod ?? 'getDefaultName', $tagName, $indexAttribute, $checkTaggedItem); } $index = $index ?? ($defaultIndex = $defaultIndex ?? $serviceId); $services[] = [$priority, ++$i, $index, $serviceId, $class]; @@ -87,11 +87,11 @@ trait PriorityTaggedServiceTrait $refs = []; foreach ($services as [, , $index, $serviceId, $class]) { if (!$class) { - $reference = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($serviceId); + $reference = new Reference($serviceId); } elseif ($index === $serviceId) { - $reference = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference($serviceId, $class); + $reference = new TypedReference($serviceId, $class); } else { - $reference = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference($serviceId, $class, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder::EXCEPTION_ON_INVALID_REFERENCE, $index); + $reference = new TypedReference($serviceId, $class, ContainerBuilder::EXCEPTION_ON_INVALID_REFERENCE, $index); } if (null === $index) { $refs[] = $reference; @@ -110,13 +110,13 @@ class PriorityTaggedServiceUtil /** * @return string|int|null */ - public static function getDefault(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container, string $serviceId, string $class, string $defaultMethod, string $tagName, ?string $indexAttribute, bool $checkTaggedItem) + public static function getDefault(ContainerBuilder $container, string $serviceId, string $class, string $defaultMethod, string $tagName, ?string $indexAttribute, bool $checkTaggedItem) { if (!($r = $container->getReflectionClass($class)) || !$checkTaggedItem && !$r->hasMethod($defaultMethod)) { return null; } if ($checkTaggedItem && !$r->hasMethod($defaultMethod)) { - foreach (\method_exists($r, 'getAttributes') ? $r->getAttributes(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Attribute\AsTaggedItem::class) : [] as $attribute) { + foreach (\method_exists($r, 'getAttributes') ? $r->getAttributes(AsTaggedItem::class) : [] as $attribute) { return 'priority' === $indexAttribute ? $attribute->newInstance()->priority : $attribute->newInstance()->index; } return null; @@ -128,15 +128,15 @@ class PriorityTaggedServiceUtil $message = [\sprintf('Method "%s::%s()" should ', $class, $defaultMethod), '.']; } if (!($rm = $r->getMethod($defaultMethod))->isStatic()) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\implode('be static', $message)); + throw new InvalidArgumentException(\implode('be static', $message)); } if (!$rm->isPublic()) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\implode('be public', $message)); + throw new InvalidArgumentException(\implode('be public', $message)); } $default = $rm->invoke(null); if ('priority' === $indexAttribute) { if (!\is_int($default)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\implode(\sprintf('return int (got "%s")', \get_debug_type($default)), $message)); + throw new InvalidArgumentException(\implode(\sprintf('return int (got "%s")', \get_debug_type($default)), $message)); } return $default; } @@ -144,7 +144,7 @@ class PriorityTaggedServiceUtil $default = (string) $default; } if (!\is_string($default)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\implode(\sprintf('return string|int (got "%s")', \get_debug_type($default)), $message)); + throw new InvalidArgumentException(\implode(\sprintf('return string|int (got "%s")', \get_debug_type($default)), $message)); } return $default; } diff --git a/vendor/symfony/dependency-injection/Compiler/RegisterAutoconfigureAttributesPass.php b/vendor/symfony/dependency-injection/Compiler/RegisterAutoconfigureAttributesPass.php index 9df324fd7b1..ee019d1039a 100644 --- a/vendor/symfony/dependency-injection/Compiler/RegisterAutoconfigureAttributesPass.php +++ b/vendor/symfony/dependency-injection/Compiler/RegisterAutoconfigureAttributesPass.php @@ -20,13 +20,13 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\YamlFileLo * * @author Nicolas Grekas */ -final class RegisterAutoconfigureAttributesPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +final class RegisterAutoconfigureAttributesPass implements CompilerPassInterface { private static $registerForAutoconfiguration; /** * {@inheritdoc} */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { foreach ($container->getDefinitions() as $id => $definition) { if ($this->accept($definition) && ($class = $container->getReflectionClass($definition->getClass(), \false))) { @@ -34,24 +34,24 @@ final class RegisterAutoconfigureAttributesPass implements \RectorPrefix20220607 } } } - public function accept(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) : bool + public function accept(Definition $definition) : bool { return $definition->isAutoconfigured() && !$definition->hasTag('container.ignore_attributes'); } - public function processClass(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container, \ReflectionClass $class) + public function processClass(ContainerBuilder $container, \ReflectionClass $class) { - foreach (\method_exists($class, 'getAttributes') ? $class->getAttributes(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Attribute\Autoconfigure::class, \ReflectionAttribute::IS_INSTANCEOF) : [] as $attribute) { + foreach (\method_exists($class, 'getAttributes') ? $class->getAttributes(Autoconfigure::class, \ReflectionAttribute::IS_INSTANCEOF) : [] as $attribute) { self::registerForAutoconfiguration($container, $class, $attribute); } } - private static function registerForAutoconfiguration(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container, \ReflectionClass $class, \ReflectionAttribute $attribute) + private static function registerForAutoconfiguration(ContainerBuilder $container, \ReflectionClass $class, \ReflectionAttribute $attribute) { if (self::$registerForAutoconfiguration) { return (self::$registerForAutoconfiguration)($container, $class, $attribute); } - $parseDefinitions = new \ReflectionMethod(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\YamlFileLoader::class, 'parseDefinitions'); + $parseDefinitions = new \ReflectionMethod(YamlFileLoader::class, 'parseDefinitions'); $yamlLoader = $parseDefinitions->getDeclaringClass()->newInstanceWithoutConstructor(); - self::$registerForAutoconfiguration = static function (\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container, \ReflectionClass $class, \ReflectionAttribute $attribute) use($parseDefinitions, $yamlLoader) { + self::$registerForAutoconfiguration = static function (ContainerBuilder $container, \ReflectionClass $class, \ReflectionAttribute $attribute) use($parseDefinitions, $yamlLoader) { $attribute = (array) $attribute->newInstance(); foreach ($attribute['tags'] ?? [] as $i => $tag) { if (\is_array($tag) && [0] === \array_keys($tag)) { diff --git a/vendor/symfony/dependency-injection/Compiler/RegisterEnvVarProcessorsPass.php b/vendor/symfony/dependency-injection/Compiler/RegisterEnvVarProcessorsPass.php index fae5cb47e9c..938b8cc285a 100644 --- a/vendor/symfony/dependency-injection/Compiler/RegisterEnvVarProcessorsPass.php +++ b/vendor/symfony/dependency-injection/Compiler/RegisterEnvVarProcessorsPass.php @@ -21,35 +21,35 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference; * * @author Nicolas Grekas */ -class RegisterEnvVarProcessorsPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +class RegisterEnvVarProcessorsPass implements CompilerPassInterface { private const ALLOWED_TYPES = ['array', 'bool', 'float', 'int', 'string']; - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { $bag = $container->getParameterBag(); $types = []; $processors = []; foreach ($container->findTaggedServiceIds('container.env_var_processor') as $id => $tags) { if (!($r = $container->getReflectionClass($class = $container->getDefinition($id)->getClass()))) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); - } elseif (!$r->isSubclassOf(\RectorPrefix20220607\Symfony\Component\DependencyInjection\EnvVarProcessorInterface::class)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Service "%s" must implement interface "%s".', $id, \RectorPrefix20220607\Symfony\Component\DependencyInjection\EnvVarProcessorInterface::class)); + throw new InvalidArgumentException(\sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); + } elseif (!$r->isSubclassOf(EnvVarProcessorInterface::class)) { + throw new InvalidArgumentException(\sprintf('Service "%s" must implement interface "%s".', $id, EnvVarProcessorInterface::class)); } foreach ($class::getProvidedTypes() as $prefix => $type) { - $processors[$prefix] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($id); + $processors[$prefix] = new Reference($id); $types[$prefix] = self::validateProvidedTypes($type, $class); } } - if ($bag instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag) { - foreach (\RectorPrefix20220607\Symfony\Component\DependencyInjection\EnvVarProcessor::getProvidedTypes() as $prefix => $type) { + if ($bag instanceof EnvPlaceholderParameterBag) { + foreach (EnvVarProcessor::getProvidedTypes() as $prefix => $type) { if (!isset($types[$prefix])) { - $types[$prefix] = self::validateProvidedTypes($type, \RectorPrefix20220607\Symfony\Component\DependencyInjection\EnvVarProcessor::class); + $types[$prefix] = self::validateProvidedTypes($type, EnvVarProcessor::class); } } $bag->setProvidedTypes($types); } if ($processors) { - $container->setAlias('container.env_var_processors_locator', (string) \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass::register($container, $processors))->setPublic(\true); + $container->setAlias('container.env_var_processors_locator', (string) ServiceLocatorTagPass::register($container, $processors))->setPublic(\true); } } private static function validateProvidedTypes(string $types, string $class) : array @@ -57,7 +57,7 @@ class RegisterEnvVarProcessorsPass implements \RectorPrefix20220607\Symfony\Comp $types = \explode('|', $types); foreach ($types as $type) { if (!\in_array($type, self::ALLOWED_TYPES)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid type "%s" returned by "%s::getProvidedTypes()", expected one of "%s".', $type, $class, \implode('", "', self::ALLOWED_TYPES))); + throw new InvalidArgumentException(\sprintf('Invalid type "%s" returned by "%s::getProvidedTypes()", expected one of "%s".', $type, $class, \implode('", "', self::ALLOWED_TYPES))); } } return $types; diff --git a/vendor/symfony/dependency-injection/Compiler/RegisterReverseContainerPass.php b/vendor/symfony/dependency-injection/Compiler/RegisterReverseContainerPass.php index 1857e2bf5e3..35055a9dfee 100644 --- a/vendor/symfony/dependency-injection/Compiler/RegisterReverseContainerPass.php +++ b/vendor/symfony/dependency-injection/Compiler/RegisterReverseContainerPass.php @@ -18,7 +18,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference; /** * @author Nicolas Grekas */ -class RegisterReverseContainerPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +class RegisterReverseContainerPass implements CompilerPassInterface { /** * @var bool @@ -28,27 +28,27 @@ class RegisterReverseContainerPass implements \RectorPrefix20220607\Symfony\Comp { $this->beforeRemoving = $beforeRemoving; } - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { if (!$container->hasDefinition('reverse_container')) { return; } - $refType = $this->beforeRemoving ? \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE : \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; + $refType = $this->beforeRemoving ? ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE : ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; $services = []; foreach ($container->findTaggedServiceIds('container.reversible') as $id => $tags) { - $services[$id] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($id, $refType); + $services[$id] = new Reference($id, $refType); } if ($this->beforeRemoving) { // prevent inlining of the reverse container - $services['reverse_container'] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference('reverse_container', $refType); + $services['reverse_container'] = new Reference('reverse_container', $refType); } $locator = $container->getDefinition('reverse_container')->getArgument(1); - if ($locator instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + if ($locator instanceof Reference) { $locator = $container->getDefinition((string) $locator); } - if ($locator instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + if ($locator instanceof Definition) { foreach ($services as $id => $ref) { - $services[$id] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument($ref); + $services[$id] = new ServiceClosureArgument($ref); } $locator->replaceArgument(0, $services); } else { diff --git a/vendor/symfony/dependency-injection/Compiler/RegisterServiceSubscribersPass.php b/vendor/symfony/dependency-injection/Compiler/RegisterServiceSubscribersPass.php index 0485ac3913d..ebfe0b14b23 100644 --- a/vendor/symfony/dependency-injection/Compiler/RegisterServiceSubscribersPass.php +++ b/vendor/symfony/dependency-injection/Compiler/RegisterServiceSubscribersPass.php @@ -26,7 +26,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\ServiceSubscriberInterface; * * @author Nicolas Grekas */ -class RegisterServiceSubscribersPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class RegisterServiceSubscribersPass extends AbstractRecursivePass { /** * @param mixed $value @@ -34,7 +34,7 @@ class RegisterServiceSubscribersPass extends \RectorPrefix20220607\Symfony\Compo */ protected function processValue($value, bool $isRoot = \false) { - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition || $value->isAbstract() || $value->isSynthetic() || !$value->hasTag('container.service_subscriber')) { + if (!$value instanceof Definition || $value->isAbstract() || $value->isSynthetic() || !$value->hasTag('container.service_subscriber')) { return parent::processValue($value, $isRoot); } $serviceMap = []; @@ -46,10 +46,10 @@ class RegisterServiceSubscribersPass extends \RectorPrefix20220607\Symfony\Compo } \ksort($attributes); if ([] !== \array_diff(\array_keys($attributes), ['id', 'key'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The "container.service_subscriber" tag accepts only the "key" and "id" attributes, "%s" given for service "%s".', \implode('", "', \array_keys($attributes)), $this->currentId)); + throw new InvalidArgumentException(\sprintf('The "container.service_subscriber" tag accepts only the "key" and "id" attributes, "%s" given for service "%s".', \implode('", "', \array_keys($attributes)), $this->currentId)); } if (!\array_key_exists('id', $attributes)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Missing "id" attribute on "container.service_subscriber" tag with key="%s" for service "%s".', $attributes['key'], $this->currentId)); + throw new InvalidArgumentException(\sprintf('Missing "id" attribute on "container.service_subscriber" tag with key="%s" for service "%s".', $attributes['key'], $this->currentId)); } if (!\array_key_exists('key', $attributes)) { $attributes['key'] = $attributes['id']; @@ -57,26 +57,26 @@ class RegisterServiceSubscribersPass extends \RectorPrefix20220607\Symfony\Compo if (isset($serviceMap[$attributes['key']])) { continue; } - $serviceMap[$attributes['key']] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($attributes['id']); + $serviceMap[$attributes['key']] = new Reference($attributes['id']); } $class = $value->getClass(); if (!($r = $this->container->getReflectionClass($class))) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Class "%s" used for service "%s" cannot be found.', $class, $this->currentId)); + throw new InvalidArgumentException(\sprintf('Class "%s" used for service "%s" cannot be found.', $class, $this->currentId)); } - if (!$r->isSubclassOf(\RectorPrefix20220607\Symfony\Contracts\Service\ServiceSubscriberInterface::class)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Service "%s" must implement interface "%s".', $this->currentId, \RectorPrefix20220607\Symfony\Contracts\Service\ServiceSubscriberInterface::class)); + if (!$r->isSubclassOf(ServiceSubscriberInterface::class)) { + throw new InvalidArgumentException(\sprintf('Service "%s" must implement interface "%s".', $this->currentId, ServiceSubscriberInterface::class)); } $class = $r->name; // to remove when symfony/dependency-injection will stop being compatible with symfony/framework-bundle<6.0 - $replaceDeprecatedSession = $this->container->has('.session.deprecated') && $r->isSubclassOf(\RectorPrefix20220607\Symfony\Bundle\FrameworkBundle\Controller\AbstractController::class); + $replaceDeprecatedSession = $this->container->has('.session.deprecated') && $r->isSubclassOf(AbstractController::class); $subscriberMap = []; foreach ($class::getSubscribedServices() as $key => $type) { if (!\is_string($type) || !\preg_match('/(?(DEFINE)(?[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*+))(?(DEFINE)(?(?&cn)(?:\\\\(?&cn))*+))^\\??(?&fqcn)(?:(?:\\|(?&fqcn))*+|(?:&(?&fqcn))*+)$/', $type)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('"%s::getSubscribedServices()" must return valid PHP types for service "%s" key "%s", "%s" returned.', $class, $this->currentId, $key, \is_string($type) ? $type : \get_debug_type($type))); + throw new InvalidArgumentException(\sprintf('"%s::getSubscribedServices()" must return valid PHP types for service "%s" key "%s", "%s" returned.', $class, $this->currentId, $key, \is_string($type) ? $type : \get_debug_type($type))); } if ($optionalBehavior = '?' === $type[0]) { $type = \substr($type, 1); - $optionalBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_INVALID_REFERENCE; + $optionalBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE; } if (\is_int($name = $key)) { $key = $type; @@ -84,14 +84,14 @@ class RegisterServiceSubscribersPass extends \RectorPrefix20220607\Symfony\Compo } if (!isset($serviceMap[$key])) { if (!$autowire) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Service "%s" misses a "container.service_subscriber" tag with "key"/"id" attributes corresponding to entry "%s" as returned by "%s::getSubscribedServices()".', $this->currentId, $key, $class)); + throw new InvalidArgumentException(\sprintf('Service "%s" misses a "container.service_subscriber" tag with "key"/"id" attributes corresponding to entry "%s" as returned by "%s::getSubscribedServices()".', $this->currentId, $key, $class)); } - if ($replaceDeprecatedSession && \RectorPrefix20220607\Symfony\Component\HttpFoundation\Session\SessionInterface::class === $type) { + if ($replaceDeprecatedSession && SessionInterface::class === $type) { // This prevents triggering the deprecation when building the container // to remove when symfony/dependency-injection will stop being compatible with symfony/framework-bundle<6.0 $type = '.session.deprecated'; } - $serviceMap[$key] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($type); + $serviceMap[$key] = new Reference($type); } if ($name) { if (\false !== ($i = \strpos($name, '::get'))) { @@ -104,16 +104,16 @@ class RegisterServiceSubscribersPass extends \RectorPrefix20220607\Symfony\Compo $camelCaseName = \lcfirst(\str_replace(' ', '', \ucwords(\preg_replace('/[^a-zA-Z0-9\\x7f-\\xff]++/', ' ', $name)))); $name = $this->container->has($type . ' $' . $camelCaseName) ? $camelCaseName : $name; } - $subscriberMap[$key] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference((string) $serviceMap[$key], $type, $optionalBehavior ?: \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $name); + $subscriberMap[$key] = new TypedReference((string) $serviceMap[$key], $type, $optionalBehavior ?: ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $name); unset($serviceMap[$key]); } if ($serviceMap = \array_keys($serviceMap)) { $message = \sprintf(1 < \count($serviceMap) ? 'keys "%s" do' : 'key "%s" does', \str_replace('%', '%%', \implode('", "', $serviceMap))); - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Service %s not exist in the map returned by "%s::getSubscribedServices()" for service "%s".', $message, $class, $this->currentId)); + throw new InvalidArgumentException(\sprintf('Service %s not exist in the map returned by "%s::getSubscribedServices()" for service "%s".', $message, $class, $this->currentId)); } - $locatorRef = \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass::register($this->container, $subscriberMap, $this->currentId); + $locatorRef = ServiceLocatorTagPass::register($this->container, $subscriberMap, $this->currentId); $value->addTag('container.service_subscriber.locator', ['id' => (string) $locatorRef]); - $value->setBindings([\RectorPrefix20220607\Psr\Container\ContainerInterface::class => new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\BoundArgument($locatorRef, \false), \RectorPrefix20220607\Symfony\Contracts\Service\ServiceProviderInterface::class => new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\BoundArgument($locatorRef, \false)] + $value->getBindings()); + $value->setBindings([PsrContainerInterface::class => new BoundArgument($locatorRef, \false), ServiceProviderInterface::class => new BoundArgument($locatorRef, \false)] + $value->getBindings()); return parent::processValue($value); } } diff --git a/vendor/symfony/dependency-injection/Compiler/RemoveAbstractDefinitionsPass.php b/vendor/symfony/dependency-injection/Compiler/RemoveAbstractDefinitionsPass.php index dee84da4c80..5129eda84f8 100644 --- a/vendor/symfony/dependency-injection/Compiler/RemoveAbstractDefinitionsPass.php +++ b/vendor/symfony/dependency-injection/Compiler/RemoveAbstractDefinitionsPass.php @@ -14,12 +14,12 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder; /** * Removes abstract Definitions. */ -class RemoveAbstractDefinitionsPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +class RemoveAbstractDefinitionsPass implements CompilerPassInterface { /** * Removes abstract definitions from the ContainerBuilder. */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { foreach ($container->getDefinitions() as $id => $definition) { if ($definition->isAbstract()) { diff --git a/vendor/symfony/dependency-injection/Compiler/RemovePrivateAliasesPass.php b/vendor/symfony/dependency-injection/Compiler/RemovePrivateAliasesPass.php index 1dcaa0ffed8..135e89714b6 100644 --- a/vendor/symfony/dependency-injection/Compiler/RemovePrivateAliasesPass.php +++ b/vendor/symfony/dependency-injection/Compiler/RemovePrivateAliasesPass.php @@ -18,12 +18,12 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder; * * @author Johannes M. Schmitt */ -class RemovePrivateAliasesPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +class RemovePrivateAliasesPass implements CompilerPassInterface { /** * Removes private aliases from the ContainerBuilder. */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { foreach ($container->getAliases() as $id => $alias) { if ($alias->isPublic()) { diff --git a/vendor/symfony/dependency-injection/Compiler/RemoveUnusedDefinitionsPass.php b/vendor/symfony/dependency-injection/Compiler/RemoveUnusedDefinitionsPass.php index 421f8110cff..79c7b83c7f6 100644 --- a/vendor/symfony/dependency-injection/Compiler/RemoveUnusedDefinitionsPass.php +++ b/vendor/symfony/dependency-injection/Compiler/RemoveUnusedDefinitionsPass.php @@ -18,7 +18,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference; * @author Johannes M. Schmitt * @author Nicolas Grekas */ -class RemoveUnusedDefinitionsPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class RemoveUnusedDefinitionsPass extends AbstractRecursivePass { /** * @var mixed[] @@ -27,7 +27,7 @@ class RemoveUnusedDefinitionsPass extends \RectorPrefix20220607\Symfony\Componen /** * Processes the ContainerBuilder to remove unused definitions. */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { try { $this->enableExpressionProcessing(); @@ -74,10 +74,10 @@ class RemoveUnusedDefinitionsPass extends \RectorPrefix20220607\Symfony\Componen */ protected function processValue($value, bool $isRoot = \false) { - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + if (!$value instanceof Reference) { return parent::processValue($value, $isRoot); } - if (\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE !== $value->getInvalidBehavior()) { + if (ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE !== $value->getInvalidBehavior()) { $this->connectedIds[] = (string) $value; } return $value; diff --git a/vendor/symfony/dependency-injection/Compiler/ReplaceAliasByActualDefinitionPass.php b/vendor/symfony/dependency-injection/Compiler/ReplaceAliasByActualDefinitionPass.php index b9e338cb866..d90dc58226f 100644 --- a/vendor/symfony/dependency-injection/Compiler/ReplaceAliasByActualDefinitionPass.php +++ b/vendor/symfony/dependency-injection/Compiler/ReplaceAliasByActualDefinitionPass.php @@ -20,7 +20,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference; * * @author Johannes M. Schmitt */ -class ReplaceAliasByActualDefinitionPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class ReplaceAliasByActualDefinitionPass extends AbstractRecursivePass { /** * @var mixed[] @@ -31,7 +31,7 @@ class ReplaceAliasByActualDefinitionPass extends \RectorPrefix20220607\Symfony\C * * @throws InvalidArgumentException if the service definition does not exist */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { // First collect all alias targets that need to be replaced $seenAliasTargets = []; @@ -57,9 +57,9 @@ class ReplaceAliasByActualDefinitionPass extends \RectorPrefix20220607\Symfony\C $seenAliasTargets[$targetId] = \true; try { $definition = $container->getDefinition($targetId); - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException $e) { + } catch (ServiceNotFoundException $e) { if ('' !== $e->getId() && '@' === $e->getId()[0]) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException($e->getId(), $e->getSourceId(), null, [\substr($e->getId(), 1)]); + throw new ServiceNotFoundException($e->getId(), $e->getSourceId(), null, [\substr($e->getId(), 1)]); } throw $e; } @@ -86,10 +86,10 @@ class ReplaceAliasByActualDefinitionPass extends \RectorPrefix20220607\Symfony\C */ protected function processValue($value, bool $isRoot = \false) { - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference && isset($this->replacements[$referenceId = (string) $value])) { + if ($value instanceof Reference && isset($this->replacements[$referenceId = (string) $value])) { // Perform the replacement $newId = $this->replacements[$referenceId]; - $value = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($newId, $value->getInvalidBehavior()); + $value = new Reference($newId, $value->getInvalidBehavior()); $this->container->log($this, \sprintf('Changed reference of service "%s" previously pointing to "%s" to "%s".', $this->currentId, $referenceId, $newId)); } return parent::processValue($value, $isRoot); diff --git a/vendor/symfony/dependency-injection/Compiler/ResolveBindingsPass.php b/vendor/symfony/dependency-injection/Compiler/ResolveBindingsPass.php index 4e607ecd7d2..941a33ced8a 100644 --- a/vendor/symfony/dependency-injection/Compiler/ResolveBindingsPass.php +++ b/vendor/symfony/dependency-injection/Compiler/ResolveBindingsPass.php @@ -24,7 +24,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference; /** * @author Guilhem Niot */ -class ResolveBindingsPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class ResolveBindingsPass extends AbstractRecursivePass { /** * @var mixed[] @@ -41,7 +41,7 @@ class ResolveBindingsPass extends \RectorPrefix20220607\Symfony\Component\Depend /** * {@inheritdoc} */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { $this->usedBindings = $container->getRemovedBindingIds(); try { @@ -61,9 +61,9 @@ class ResolveBindingsPass extends \RectorPrefix20220607\Symfony\Component\Depend if ($argumentName) { $message .= \sprintf('named "%s" ', $argumentName); } - if (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\BoundArgument::DEFAULTS_BINDING === $bindingType) { + if (BoundArgument::DEFAULTS_BINDING === $bindingType) { $message .= 'under "_defaults"'; - } elseif (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\BoundArgument::INSTANCEOF_BINDING === $bindingType) { + } elseif (BoundArgument::INSTANCEOF_BINDING === $bindingType) { $message .= 'under "_instanceof"'; } else { $message .= \sprintf('for service "%s"', $serviceId); @@ -78,7 +78,7 @@ class ResolveBindingsPass extends \RectorPrefix20220607\Symfony\Component\Depend foreach ($this->errorMessages as $m) { $message .= "\n - " . $m; } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException($message); + throw new InvalidArgumentException($message); } } finally { $this->usedBindings = []; @@ -93,7 +93,7 @@ class ResolveBindingsPass extends \RectorPrefix20220607\Symfony\Component\Depend */ protected function processValue($value, bool $isRoot = \false) { - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference && $value->getType() === (string) $value) { + if ($value instanceof TypedReference && $value->getType() === (string) $value) { // Already checked $bindings = $this->container->getDefinition($this->currentId)->getBindings(); $name = $value->getName(); @@ -105,7 +105,7 @@ class ResolveBindingsPass extends \RectorPrefix20220607\Symfony\Component\Depend } return parent::processValue($value, $isRoot); } - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition || !($bindings = $value->getBindings())) { + if (!$value instanceof Definition || !($bindings = $value->getBindings())) { return parent::processValue($value, $isRoot); } $bindingNames = []; @@ -123,12 +123,12 @@ class ResolveBindingsPass extends \RectorPrefix20220607\Symfony\Component\Depend if (!isset($m[1])) { continue; } - if (\is_subclass_of($m[1], \RectorPrefix20220607\UnitEnum::class)) { + if (\is_subclass_of($m[1], \UnitEnum::class)) { $bindingNames[\substr($key, \strlen($m[0]))] = $binding; continue; } - if (null !== $bindingValue && !$bindingValue instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference && !$bindingValue instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition && !$bindingValue instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument && !$bindingValue instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid value for binding key "%s" for service "%s": expected "%s", "%s", "%s", "%s" or null, "%s" given.', $key, $this->currentId, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference::class, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition::class, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument::class, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument::class, \get_debug_type($bindingValue))); + if (null !== $bindingValue && !$bindingValue instanceof Reference && !$bindingValue instanceof Definition && !$bindingValue instanceof TaggedIteratorArgument && !$bindingValue instanceof ServiceLocatorArgument) { + throw new InvalidArgumentException(\sprintf('Invalid value for binding key "%s" for service "%s": expected "%s", "%s", "%s", "%s" or null, "%s" given.', $key, $this->currentId, Reference::class, Definition::class, TaggedIteratorArgument::class, ServiceLocatorArgument::class, \get_debug_type($bindingValue))); } } if ($value->isAbstract()) { @@ -139,7 +139,7 @@ class ResolveBindingsPass extends \RectorPrefix20220607\Symfony\Component\Depend if ($constructor = $this->getConstructor($value, \false)) { $calls[] = [$constructor, $value->getArguments()]; } - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException $e) { + } catch (RuntimeException $e) { $this->errorMessages[] = $e->getMessage(); $this->container->getDefinition($this->currentId)->addError($e->getMessage()); return parent::processValue($value, $isRoot); @@ -151,7 +151,7 @@ class ResolveBindingsPass extends \RectorPrefix20220607\Symfony\Component\Depend } else { try { $reflectionMethod = $this->getReflectionMethod($value, $method); - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException $e) { + } catch (RuntimeException $e) { if ($value->getFactory()) { continue; } @@ -162,8 +162,8 @@ class ResolveBindingsPass extends \RectorPrefix20220607\Symfony\Component\Depend if (\array_key_exists($key, $arguments) && '' !== $arguments[$key]) { continue; } - $typeHint = \RectorPrefix20220607\Symfony\Component\DependencyInjection\LazyProxy\ProxyHelper::getTypeHint($reflectionMethod, $parameter); - $name = \RectorPrefix20220607\Symfony\Component\DependencyInjection\Attribute\Target::parseName($parameter); + $typeHint = ProxyHelper::getTypeHint($reflectionMethod, $parameter); + $name = Target::parseName($parameter); if ($typeHint && \array_key_exists($k = \ltrim($typeHint, '\\') . ' $' . $name, $bindings)) { $arguments[$key] = $this->getBindingValue($bindings[$k]); continue; @@ -201,7 +201,7 @@ class ResolveBindingsPass extends \RectorPrefix20220607\Symfony\Component\Depend /** * @return mixed */ - private function getBindingValue(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\BoundArgument $binding) + private function getBindingValue(BoundArgument $binding) { [$bindingValue, $bindingId] = $binding->getValues(); $this->usedBindings[$bindingId] = \true; diff --git a/vendor/symfony/dependency-injection/Compiler/ResolveChildDefinitionsPass.php b/vendor/symfony/dependency-injection/Compiler/ResolveChildDefinitionsPass.php index 6d1ef44b09a..e868b144fdb 100644 --- a/vendor/symfony/dependency-injection/Compiler/ResolveChildDefinitionsPass.php +++ b/vendor/symfony/dependency-injection/Compiler/ResolveChildDefinitionsPass.php @@ -23,7 +23,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\Service * @author Johannes M. Schmitt * @author Nicolas Grekas */ -class ResolveChildDefinitionsPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class ResolveChildDefinitionsPass extends AbstractRecursivePass { /** * @var mixed[] @@ -35,7 +35,7 @@ class ResolveChildDefinitionsPass extends \RectorPrefix20220607\Symfony\Componen */ protected function processValue($value, bool $isRoot = \false) { - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + if (!$value instanceof Definition) { return parent::processValue($value, $isRoot); } if ($isRoot) { @@ -43,7 +43,7 @@ class ResolveChildDefinitionsPass extends \RectorPrefix20220607\Symfony\Componen // container to ensure we are not operating on stale data $value = $this->container->getDefinition($this->currentId); } - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition) { + if ($value instanceof ChildDefinition) { $this->currentPath = []; $value = $this->resolveDefinition($value); if ($isRoot) { @@ -57,30 +57,30 @@ class ResolveChildDefinitionsPass extends \RectorPrefix20220607\Symfony\Componen * * @throws RuntimeException When the definition is invalid */ - private function resolveDefinition(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition $definition) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition + private function resolveDefinition(ChildDefinition $definition) : Definition { try { return $this->doResolveDefinition($definition); - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException $e) { + } catch (ServiceCircularReferenceException $e) { throw $e; - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ExceptionInterface $e) { + } catch (ExceptionInterface $e) { $r = new \ReflectionProperty($e, 'message'); $r->setValue($e, \sprintf('Service "%s": %s', $this->currentId, $e->getMessage())); throw $e; } } - private function doResolveDefinition(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition $definition) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition + private function doResolveDefinition(ChildDefinition $definition) : Definition { if (!$this->container->has($parent = $definition->getParent())) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Parent definition "%s" does not exist.', $parent)); + throw new RuntimeException(\sprintf('Parent definition "%s" does not exist.', $parent)); } $searchKey = \array_search($parent, $this->currentPath); $this->currentPath[] = $parent; if (\false !== $searchKey) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException($parent, \array_slice($this->currentPath, $searchKey)); + throw new ServiceCircularReferenceException($parent, \array_slice($this->currentPath, $searchKey)); } $parentDef = $this->container->findDefinition($parent); - if ($parentDef instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition) { + if ($parentDef instanceof ChildDefinition) { $id = $this->currentId; $this->currentId = $parent; $parentDef = $this->resolveDefinition($parentDef); @@ -88,7 +88,7 @@ class ResolveChildDefinitionsPass extends \RectorPrefix20220607\Symfony\Componen $this->currentId = $id; } $this->container->log($this, \sprintf('Resolving inheritance for "%s" (parent: %s).', $this->currentId, $parent)); - $def = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition(); + $def = new Definition(); // merge in parent definition // purposely ignored attributes: abstract, shared, tags, autoconfigured $def->setClass($parentDef->getClass()); @@ -145,7 +145,7 @@ class ResolveChildDefinitionsPass extends \RectorPrefix20220607\Symfony\Componen if (null === $decoratedService) { $def->setDecoratedService($decoratedService); } else { - $def->setDecoratedService($decoratedService[0], $decoratedService[1], $decoratedService[2], $decoratedService[3] ?? \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE); + $def->setDecoratedService($decoratedService[0], $decoratedService[1], $decoratedService[2], $decoratedService[3] ?? ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE); } } // merge arguments diff --git a/vendor/symfony/dependency-injection/Compiler/ResolveClassPass.php b/vendor/symfony/dependency-injection/Compiler/ResolveClassPass.php index ec976b63555..a2d50aca03e 100644 --- a/vendor/symfony/dependency-injection/Compiler/ResolveClassPass.php +++ b/vendor/symfony/dependency-injection/Compiler/ResolveClassPass.php @@ -16,20 +16,20 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\Invalid /** * @author Nicolas Grekas */ -class ResolveClassPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +class ResolveClassPass implements CompilerPassInterface { /** * {@inheritdoc} */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { foreach ($container->getDefinitions() as $id => $definition) { if ($definition->isSynthetic() || null !== $definition->getClass()) { continue; } if (\preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*+(?:\\\\[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*+)++$/', $id)) { - if ($definition instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition && !\class_exists($id)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Service definition "%s" has a parent but no class, and its name looks like an FQCN. Either the class is missing or you want to inherit it from the parent service. To resolve this ambiguity, please rename this service to a non-FQCN (e.g. using dots), or create the missing class.', $id)); + if ($definition instanceof ChildDefinition && !\class_exists($id)) { + throw new InvalidArgumentException(\sprintf('Service definition "%s" has a parent but no class, and its name looks like an FQCN. Either the class is missing or you want to inherit it from the parent service. To resolve this ambiguity, please rename this service to a non-FQCN (e.g. using dots), or create the missing class.', $id)); } $definition->setClass($id); } diff --git a/vendor/symfony/dependency-injection/Compiler/ResolveDecoratorStackPass.php b/vendor/symfony/dependency-injection/Compiler/ResolveDecoratorStackPass.php index d87b74c47d7..6e301732e70 100644 --- a/vendor/symfony/dependency-injection/Compiler/ResolveDecoratorStackPass.php +++ b/vendor/symfony/dependency-injection/Compiler/ResolveDecoratorStackPass.php @@ -20,18 +20,18 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference; /** * @author Nicolas Grekas */ -class ResolveDecoratorStackPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +class ResolveDecoratorStackPass implements CompilerPassInterface { - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { $stacks = []; foreach ($container->findTaggedServiceIds('container.stack') as $id => $tags) { $definition = $container->getDefinition($id); - if (!$definition instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid service "%s": only definitions with a "parent" can have the "container.stack" tag.', $id)); + if (!$definition instanceof ChildDefinition) { + throw new InvalidArgumentException(\sprintf('Invalid service "%s": only definitions with a "parent" can have the "container.stack" tag.', $id)); } if (!($stack = $definition->getArguments())) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid service "%s": the stack of decorators is empty.', $id)); + throw new InvalidArgumentException(\sprintf('Invalid service "%s": the stack of decorators is empty.', $id)); } $stacks[$id] = $stack; } @@ -63,27 +63,27 @@ class ResolveDecoratorStackPass implements \RectorPrefix20220607\Symfony\Compone $id = \end($path); $prefix = '.' . $id . '.'; if (!isset($stacks[$id])) { - return [$id => new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition($id)]; + return [$id => new ChildDefinition($id)]; } if (\key($path) !== ($searchKey = \array_search($id, $path))) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException($id, \array_slice($path, $searchKey)); + throw new ServiceCircularReferenceException($id, \array_slice($path, $searchKey)); } foreach ($stacks[$id] as $k => $definition) { - if ($definition instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition && isset($stacks[$definition->getParent()])) { + if ($definition instanceof ChildDefinition && isset($stacks[$definition->getParent()])) { $path[] = $definition->getParent(); $definition = \unserialize(\serialize($definition)); // deep clone - } elseif ($definition instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + } elseif ($definition instanceof Definition) { $definitions[$decoratedId = $prefix . $k] = $definition; continue; - } elseif ($definition instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference || $definition instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Alias) { + } elseif ($definition instanceof Reference || $definition instanceof Alias) { $path[] = (string) $definition; } else { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid service "%s": unexpected value of type "%s" found in the stack of decorators.', $id, \get_debug_type($definition))); + throw new InvalidArgumentException(\sprintf('Invalid service "%s": unexpected value of type "%s" found in the stack of decorators.', $id, \get_debug_type($definition))); } $p = $prefix . $k; foreach ($this->resolveStack($stacks, $path) as $k => $v) { - $definitions[$decoratedId = $p . $k] = $definition instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition ? $definition->setParent($k) : new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition($k); + $definitions[$decoratedId = $p . $k] = $definition instanceof ChildDefinition ? $definition->setParent($k) : new ChildDefinition($k); $definition = null; } \array_pop($path); diff --git a/vendor/symfony/dependency-injection/Compiler/ResolveEnvPlaceholdersPass.php b/vendor/symfony/dependency-injection/Compiler/ResolveEnvPlaceholdersPass.php index f742022077d..54591e7eca3 100644 --- a/vendor/symfony/dependency-injection/Compiler/ResolveEnvPlaceholdersPass.php +++ b/vendor/symfony/dependency-injection/Compiler/ResolveEnvPlaceholdersPass.php @@ -14,7 +14,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition; /** * Replaces env var placeholders by their current values. */ -class ResolveEnvPlaceholdersPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class ResolveEnvPlaceholdersPass extends AbstractRecursivePass { /** * @param mixed $value @@ -25,7 +25,7 @@ class ResolveEnvPlaceholdersPass extends \RectorPrefix20220607\Symfony\Component if (\is_string($value)) { return $this->container->resolveEnvPlaceholders($value, \true); } - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + if ($value instanceof Definition) { $changes = $value->getChanges(); if (isset($changes['class'])) { $value->setClass($this->container->resolveEnvPlaceholders($value->getClass(), \true)); diff --git a/vendor/symfony/dependency-injection/Compiler/ResolveFactoryClassPass.php b/vendor/symfony/dependency-injection/Compiler/ResolveFactoryClassPass.php index 7040a8dbe9c..dad40ee9c4e 100644 --- a/vendor/symfony/dependency-injection/Compiler/ResolveFactoryClassPass.php +++ b/vendor/symfony/dependency-injection/Compiler/ResolveFactoryClassPass.php @@ -15,7 +15,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\Runtime /** * @author Maxime Steinhausser */ -class ResolveFactoryClassPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class ResolveFactoryClassPass extends AbstractRecursivePass { /** * {@inheritdoc} @@ -24,9 +24,9 @@ class ResolveFactoryClassPass extends \RectorPrefix20220607\Symfony\Component\De */ protected function processValue($value, bool $isRoot = \false) { - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition && \is_array($factory = $value->getFactory()) && null === $factory[0]) { + if ($value instanceof Definition && \is_array($factory = $value->getFactory()) && null === $factory[0]) { if (null === ($class = $value->getClass())) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('The "%s" service is defined to be created by a factory, but is missing the factory class. Did you forget to define the factory or service class?', $this->currentId)); + throw new RuntimeException(\sprintf('The "%s" service is defined to be created by a factory, but is missing the factory class. Did you forget to define the factory or service class?', $this->currentId)); } $factory[0] = $class; $value->setFactory($factory); diff --git a/vendor/symfony/dependency-injection/Compiler/ResolveHotPathPass.php b/vendor/symfony/dependency-injection/Compiler/ResolveHotPathPass.php index 1c501aa4c43..66941e92263 100644 --- a/vendor/symfony/dependency-injection/Compiler/ResolveHotPathPass.php +++ b/vendor/symfony/dependency-injection/Compiler/ResolveHotPathPass.php @@ -19,7 +19,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference; * * @author Nicolas Grekas */ -class ResolveHotPathPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class ResolveHotPathPass extends AbstractRecursivePass { /** * @var mixed[] @@ -28,7 +28,7 @@ class ResolveHotPathPass extends \RectorPrefix20220607\Symfony\Component\Depende /** * {@inheritdoc} */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { try { parent::process($container); @@ -44,10 +44,10 @@ class ResolveHotPathPass extends \RectorPrefix20220607\Symfony\Component\Depende */ protected function processValue($value, bool $isRoot = \false) { - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ArgumentInterface) { + if ($value instanceof ArgumentInterface) { return $value; } - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition && $isRoot) { + if ($value instanceof Definition && $isRoot) { if ($value->isDeprecated()) { return $value->clearTag('container.hot_path'); } @@ -56,7 +56,7 @@ class ResolveHotPathPass extends \RectorPrefix20220607\Symfony\Component\Depende return $value; } } - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference && \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE !== $value->getInvalidBehavior() && $this->container->hasDefinition($id = (string) $value)) { + if ($value instanceof Reference && ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE !== $value->getInvalidBehavior() && $this->container->hasDefinition($id = (string) $value)) { $definition = $this->container->getDefinition($id); if ($definition->isDeprecated() || $definition->hasTag('container.hot_path')) { return $value; diff --git a/vendor/symfony/dependency-injection/Compiler/ResolveInstanceofConditionalsPass.php b/vendor/symfony/dependency-injection/Compiler/ResolveInstanceofConditionalsPass.php index 38667bb98eb..314cd1c9bee 100644 --- a/vendor/symfony/dependency-injection/Compiler/ResolveInstanceofConditionalsPass.php +++ b/vendor/symfony/dependency-injection/Compiler/ResolveInstanceofConditionalsPass.php @@ -20,16 +20,16 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\Runtime * * @author Nicolas Grekas */ -class ResolveInstanceofConditionalsPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +class ResolveInstanceofConditionalsPass implements CompilerPassInterface { /** * {@inheritdoc} */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { foreach ($container->getAutoconfiguredInstanceof() as $interface => $definition) { if ($definition->getArguments()) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Autoconfigured instanceof for type "%s" defines arguments but these are not supported and should be removed.', $interface)); + throw new InvalidArgumentException(\sprintf('Autoconfigured instanceof for type "%s" defines arguments but these are not supported and should be removed.', $interface)); } } $tagsToKeep = []; @@ -43,7 +43,7 @@ class ResolveInstanceofConditionalsPass implements \RectorPrefix20220607\Symfony $container->getParameterBag()->remove('container.behavior_describing_tags'); } } - private function processDefinition(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container, string $id, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, array $tagsToKeep) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition + private function processDefinition(ContainerBuilder $container, string $id, Definition $definition, array $tagsToKeep) : Definition { $instanceofConditionals = $definition->getInstanceofConditionals(); $autoconfiguredInstanceof = $definition->isAutoconfigured() ? $container->getAutoconfiguredInstanceof() : []; @@ -60,7 +60,7 @@ class ResolveInstanceofConditionalsPass implements \RectorPrefix20220607\Symfony $instanceofCalls = []; $instanceofBindings = []; $reflectionClass = null; - $parent = $definition instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition ? $definition->getParent() : null; + $parent = $definition instanceof ChildDefinition ? $definition->getParent() : null; foreach ($conditionals as $interface => $instanceofDefs) { if ($interface !== $class && !($reflectionClass = $reflectionClass ?? ($container->getReflectionClass($class, \false) ?: \false))) { continue; @@ -92,7 +92,7 @@ class ResolveInstanceofConditionalsPass implements \RectorPrefix20220607\Symfony $abstract = $container->setDefinition('.abstract.instanceof.' . $id, $definition); $definition->setBindings([]); $definition = \serialize($definition); - if (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition::class === \get_class($abstract)) { + if (Definition::class === \get_class($abstract)) { // cast Definition to ChildDefinition $definition = \substr_replace($definition, '53', 2, 2); $definition = \substr_replace($definition, 'Child', 44, 0); @@ -124,7 +124,7 @@ class ResolveInstanceofConditionalsPass implements \RectorPrefix20220607\Symfony } return $definition; } - private function mergeConditionals(array $autoconfiguredInstanceof, array $instanceofConditionals, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) : array + private function mergeConditionals(array $autoconfiguredInstanceof, array $instanceofConditionals, ContainerBuilder $container) : array { // make each value an array of ChildDefinition $conditionals = \array_map(function ($childDef) { @@ -133,7 +133,7 @@ class ResolveInstanceofConditionalsPass implements \RectorPrefix20220607\Symfony foreach ($instanceofConditionals as $interface => $instanceofDef) { // make sure the interface/class exists (but don't validate automaticInstanceofConditionals) if (!$container->getReflectionClass($interface)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('"%s" is set as an "instanceof" conditional, but it does not exist.', $interface)); + throw new RuntimeException(\sprintf('"%s" is set as an "instanceof" conditional, but it does not exist.', $interface)); } if (!isset($autoconfiguredInstanceof[$interface])) { $conditionals[$interface] = []; diff --git a/vendor/symfony/dependency-injection/Compiler/ResolveInvalidReferencesPass.php b/vendor/symfony/dependency-injection/Compiler/ResolveInvalidReferencesPass.php index 5a37e20f2d1..e177c5ff7e2 100644 --- a/vendor/symfony/dependency-injection/Compiler/ResolveInvalidReferencesPass.php +++ b/vendor/symfony/dependency-injection/Compiler/ResolveInvalidReferencesPass.php @@ -25,7 +25,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference; * * @author Johannes M. Schmitt */ -class ResolveInvalidReferencesPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +class ResolveInvalidReferencesPass implements CompilerPassInterface { /** * @var \Symfony\Component\DependencyInjection\ContainerBuilder @@ -42,10 +42,10 @@ class ResolveInvalidReferencesPass implements \RectorPrefix20220607\Symfony\Comp /** * Process the ContainerBuilder to resolve invalid references. */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { $this->container = $container; - $this->signalingException = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException('Invalid reference.'); + $this->signalingException = new RuntimeException('Invalid reference.'); try { foreach ($container->getDefinitions() as $this->currentId => $definition) { $this->processValue($definition); @@ -63,11 +63,11 @@ class ResolveInvalidReferencesPass implements \RectorPrefix20220607\Symfony\Comp */ private function processValue($value, int $rootLevel = 0, int $level = 0) { - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument) { + if ($value instanceof ServiceClosureArgument) { $value->setValues($this->processValue($value->getValues(), 1, 1)); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ArgumentInterface) { + } elseif ($value instanceof ArgumentInterface) { $value->setValues($this->processValue($value->getValues(), $rootLevel, 1 + $level)); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + } elseif ($value instanceof Definition) { if ($value->isSynthetic() || $value->isAbstract()) { return $value; } @@ -84,7 +84,7 @@ class ResolveInvalidReferencesPass implements \RectorPrefix20220607\Symfony\Comp if ($v !== ($processedValue = $this->processValue($v, $rootLevel, 1 + $level))) { $value[$k] = $processedValue; } - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException $e) { + } catch (RuntimeException $e) { if ($rootLevel < $level || $rootLevel && !$level) { unset($value[$k]); } elseif ($rootLevel) { @@ -98,26 +98,26 @@ class ResolveInvalidReferencesPass implements \RectorPrefix20220607\Symfony\Comp if (\false !== $i) { $value = \array_values($value); } - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + } elseif ($value instanceof Reference) { if ($this->container->has($id = (string) $value)) { return $value; } $currentDefinition = $this->container->getDefinition($this->currentId); // resolve decorated service behavior depending on decorator service - if ($currentDefinition->innerServiceId === $id && \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::NULL_ON_INVALID_REFERENCE === $currentDefinition->decorationOnInvalid) { + if ($currentDefinition->innerServiceId === $id && ContainerInterface::NULL_ON_INVALID_REFERENCE === $currentDefinition->decorationOnInvalid) { return null; } $invalidBehavior = $value->getInvalidBehavior(); - if (\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior && $value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference && !$this->container->has($id)) { - $e = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException($id, $this->currentId); + if (ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior && $value instanceof TypedReference && !$this->container->has($id)) { + $e = new ServiceNotFoundException($id, $this->currentId); // since the error message varies by $id and $this->currentId, so should the id of the dummy errored definition $this->container->register($id = \sprintf('.errored.%s.%s', $this->currentId, $id), $value->getType())->addError($e->getMessage()); - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference($id, $value->getType(), $value->getInvalidBehavior()); + return new TypedReference($id, $value->getType(), $value->getInvalidBehavior()); } // resolve invalid behavior - if (\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::NULL_ON_INVALID_REFERENCE === $invalidBehavior) { + if (ContainerInterface::NULL_ON_INVALID_REFERENCE === $invalidBehavior) { $value = null; - } elseif (\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $invalidBehavior) { + } elseif (ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $invalidBehavior) { if (0 < $level || $rootLevel) { throw $this->signalingException; } diff --git a/vendor/symfony/dependency-injection/Compiler/ResolveNamedArgumentsPass.php b/vendor/symfony/dependency-injection/Compiler/ResolveNamedArgumentsPass.php index 76eabb313e8..30d8864361b 100644 --- a/vendor/symfony/dependency-injection/Compiler/ResolveNamedArgumentsPass.php +++ b/vendor/symfony/dependency-injection/Compiler/ResolveNamedArgumentsPass.php @@ -20,7 +20,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference; * * @author Kévin Dunglas */ -class ResolveNamedArgumentsPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class ResolveNamedArgumentsPass extends AbstractRecursivePass { /** * {@inheritdoc} @@ -29,10 +29,10 @@ class ResolveNamedArgumentsPass extends \RectorPrefix20220607\Symfony\Component\ */ protected function processValue($value, bool $isRoot = \false) { - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\AbstractArgument && $value->getText() . '.' === $value->getTextWithContext()) { + if ($value instanceof AbstractArgument && $value->getText() . '.' === $value->getTextWithContext()) { $value->setContext(\sprintf('A value found in service "%s"', $this->currentId)); } - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + if (!$value instanceof Definition) { return parent::processValue($value, $isRoot); } $calls = $value->getMethodCalls(); @@ -42,7 +42,7 @@ class ResolveNamedArgumentsPass extends \RectorPrefix20220607\Symfony\Component\ $parameters = null; $resolvedArguments = []; foreach ($arguments as $key => $argument) { - if ($argument instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\AbstractArgument && $argument->getText() . '.' === $argument->getTextWithContext()) { + if ($argument instanceof AbstractArgument && $argument->getText() . '.' === $argument->getTextWithContext()) { $argument->setContext(\sprintf('Argument ' . (\is_int($key) ? 1 + $key : '"%3$s"') . ' of ' . ('__construct' === $method ? 'service "%s"' : 'method call "%s::%s()"'), $this->currentId, $method, $key)); } if (\is_int($key)) { @@ -56,7 +56,7 @@ class ResolveNamedArgumentsPass extends \RectorPrefix20220607\Symfony\Component\ $parameters = $r->getParameters(); } if (isset($key[0]) && '$' !== $key[0] && !\class_exists($key) && !\interface_exists($key, \false)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid service "%s": did you forget to add the "$" prefix to argument "%s"?', $this->currentId, $key)); + throw new InvalidArgumentException(\sprintf('Invalid service "%s": did you forget to add the "$" prefix to argument "%s"?', $this->currentId, $key)); } if (isset($key[0]) && '$' === $key[0]) { foreach ($parameters as $j => $p) { @@ -71,20 +71,20 @@ class ResolveNamedArgumentsPass extends \RectorPrefix20220607\Symfony\Component\ continue 2; } } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid service "%s": method "%s()" has no argument named "%s". Check your service definition.', $this->currentId, $class !== $this->currentId ? $class . '::' . $method : $method, $key)); + throw new InvalidArgumentException(\sprintf('Invalid service "%s": method "%s()" has no argument named "%s". Check your service definition.', $this->currentId, $class !== $this->currentId ? $class . '::' . $method : $method, $key)); } - if (null !== $argument && !$argument instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference && !$argument instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid service "%s": the value of argument "%s" of method "%s()" must be null, an instance of "%s" or an instance of "%s", "%s" given.', $this->currentId, $key, $class !== $this->currentId ? $class . '::' . $method : $method, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference::class, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition::class, \get_debug_type($argument))); + if (null !== $argument && !$argument instanceof Reference && !$argument instanceof Definition) { + throw new InvalidArgumentException(\sprintf('Invalid service "%s": the value of argument "%s" of method "%s()" must be null, an instance of "%s" or an instance of "%s", "%s" given.', $this->currentId, $key, $class !== $this->currentId ? $class . '::' . $method : $method, Reference::class, Definition::class, \get_debug_type($argument))); } $typeFound = \false; foreach ($parameters as $j => $p) { - if (!\array_key_exists($j, $resolvedArguments) && \RectorPrefix20220607\Symfony\Component\DependencyInjection\LazyProxy\ProxyHelper::getTypeHint($r, $p, \true) === $key) { + if (!\array_key_exists($j, $resolvedArguments) && ProxyHelper::getTypeHint($r, $p, \true) === $key) { $resolvedArguments[$j] = $argument; $typeFound = \true; } } if (!$typeFound) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid service "%s": method "%s()" has no argument type-hinted as "%s". Check your service definition.', $this->currentId, $class !== $this->currentId ? $class . '::' . $method : $method, $key)); + throw new InvalidArgumentException(\sprintf('Invalid service "%s": method "%s()" has no argument type-hinted as "%s". Check your service definition.', $this->currentId, $class !== $this->currentId ? $class . '::' . $method : $method, $key)); } } if ($resolvedArguments !== $call[1]) { @@ -100,7 +100,7 @@ class ResolveNamedArgumentsPass extends \RectorPrefix20220607\Symfony\Component\ $value->setMethodCalls($calls); } foreach ($value->getProperties() as $key => $argument) { - if ($argument instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\AbstractArgument && $argument->getText() . '.' === $argument->getTextWithContext()) { + if ($argument instanceof AbstractArgument && $argument->getText() . '.' === $argument->getTextWithContext()) { $argument->setContext(\sprintf('Property "%s" of service "%s"', $key, $this->currentId)); } } diff --git a/vendor/symfony/dependency-injection/Compiler/ResolveNoPreloadPass.php b/vendor/symfony/dependency-injection/Compiler/ResolveNoPreloadPass.php index 7d78ba6a37c..6bbc06567d0 100644 --- a/vendor/symfony/dependency-injection/Compiler/ResolveNoPreloadPass.php +++ b/vendor/symfony/dependency-injection/Compiler/ResolveNoPreloadPass.php @@ -18,7 +18,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference; * * @author Nicolas Grekas */ -class ResolveNoPreloadPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class ResolveNoPreloadPass extends AbstractRecursivePass { private const DO_PRELOAD_TAG = '.container.do_preload'; /** @@ -28,7 +28,7 @@ class ResolveNoPreloadPass extends \RectorPrefix20220607\Symfony\Component\Depen /** * {@inheritdoc} */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { $this->container = $container; try { @@ -63,7 +63,7 @@ class ResolveNoPreloadPass extends \RectorPrefix20220607\Symfony\Component\Depen */ protected function processValue($value, bool $isRoot = \false) { - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference && \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE !== $value->getInvalidBehavior() && $this->container->hasDefinition($id = (string) $value)) { + if ($value instanceof Reference && ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE !== $value->getInvalidBehavior() && $this->container->hasDefinition($id = (string) $value)) { $definition = $this->container->getDefinition($id); if (!isset($this->resolvedIds[$id]) && (!$definition->isPublic() || $definition->isPrivate())) { $this->resolvedIds[$id] = \true; @@ -71,7 +71,7 @@ class ResolveNoPreloadPass extends \RectorPrefix20220607\Symfony\Component\Depen } return $value; } - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + if (!$value instanceof Definition) { return parent::processValue($value, $isRoot); } if ($value->hasTag('container.no_preload') || $value->isDeprecated() || $value->hasErrors()) { diff --git a/vendor/symfony/dependency-injection/Compiler/ResolveParameterPlaceHoldersPass.php b/vendor/symfony/dependency-injection/Compiler/ResolveParameterPlaceHoldersPass.php index 95292a13e78..7c8e42d255b 100644 --- a/vendor/symfony/dependency-injection/Compiler/ResolveParameterPlaceHoldersPass.php +++ b/vendor/symfony/dependency-injection/Compiler/ResolveParameterPlaceHoldersPass.php @@ -19,7 +19,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\Para * * @author Johannes M. Schmitt */ -class ResolveParameterPlaceHoldersPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class ResolveParameterPlaceHoldersPass extends AbstractRecursivePass { /** * @var \Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface @@ -43,7 +43,7 @@ class ResolveParameterPlaceHoldersPass extends \RectorPrefix20220607\Symfony\Com * * @throws ParameterNotFoundException */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { $this->bag = $container->getParameterBag(); try { @@ -54,7 +54,7 @@ class ResolveParameterPlaceHoldersPass extends \RectorPrefix20220607\Symfony\Com $aliases[$this->bag->resolveValue($name)] = $target; } $container->setAliases($aliases); - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException $e) { + } catch (ParameterNotFoundException $e) { $e->setSourceId($this->currentId); throw $e; } @@ -70,7 +70,7 @@ class ResolveParameterPlaceHoldersPass extends \RectorPrefix20220607\Symfony\Com if (\is_string($value)) { try { $v = $this->bag->resolveValue($value); - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException $e) { + } catch (ParameterNotFoundException $e) { if ($this->throwOnResolveException) { throw $e; } @@ -79,7 +79,7 @@ class ResolveParameterPlaceHoldersPass extends \RectorPrefix20220607\Symfony\Com } return $this->resolveArrays || !$v || !\is_array($v) ? $v : $value; } - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + if ($value instanceof Definition) { $value->setBindings($this->processValue($value->getBindings())); $changes = $value->getChanges(); if (isset($changes['class'])) { diff --git a/vendor/symfony/dependency-injection/Compiler/ResolveReferencesToAliasesPass.php b/vendor/symfony/dependency-injection/Compiler/ResolveReferencesToAliasesPass.php index 91773d77854..03285ba2d7e 100644 --- a/vendor/symfony/dependency-injection/Compiler/ResolveReferencesToAliasesPass.php +++ b/vendor/symfony/dependency-injection/Compiler/ResolveReferencesToAliasesPass.php @@ -18,12 +18,12 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference; * * @author Johannes M. Schmitt */ -class ResolveReferencesToAliasesPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class ResolveReferencesToAliasesPass extends AbstractRecursivePass { /** * {@inheritdoc} */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { parent::process($container); foreach ($container->getAliases() as $id => $alias) { @@ -41,13 +41,13 @@ class ResolveReferencesToAliasesPass extends \RectorPrefix20220607\Symfony\Compo */ protected function processValue($value, bool $isRoot = \false) { - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + if (!$value instanceof Reference) { return parent::processValue($value, $isRoot); } $defId = $this->getDefinitionId($id = (string) $value, $this->container); - return $defId !== $id ? new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($defId, $value->getInvalidBehavior()) : $value; + return $defId !== $id ? new Reference($defId, $value->getInvalidBehavior()) : $value; } - private function getDefinitionId(string $id, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) : string + private function getDefinitionId(string $id, ContainerBuilder $container) : string { if (!$container->hasAlias($id)) { return $id; @@ -57,13 +57,13 @@ class ResolveReferencesToAliasesPass extends \RectorPrefix20220607\Symfony\Compo $referencingDefinition = $container->hasDefinition($this->currentId) ? $container->getDefinition($this->currentId) : $container->getAlias($this->currentId); if (!$referencingDefinition->isDeprecated()) { $deprecation = $alias->getDeprecation($id); - trigger_deprecation($deprecation['package'], $deprecation['version'], \rtrim($deprecation['message'], '. ') . '. It is being referenced by the "%s" ' . ($container->hasDefinition($this->currentId) ? 'service.' : 'alias.'), $this->currentId); + \RectorPrefix20220607\trigger_deprecation($deprecation['package'], $deprecation['version'], \rtrim($deprecation['message'], '. ') . '. It is being referenced by the "%s" ' . ($container->hasDefinition($this->currentId) ? 'service.' : 'alias.'), $this->currentId); } } $seen = []; do { if (isset($seen[$id])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException($id, \array_merge(\array_keys($seen), [$id])); + throw new ServiceCircularReferenceException($id, \array_merge(\array_keys($seen), [$id])); } $seen[$id] = \true; $id = (string) $container->getAlias($id); diff --git a/vendor/symfony/dependency-injection/Compiler/ResolveServiceSubscribersPass.php b/vendor/symfony/dependency-injection/Compiler/ResolveServiceSubscribersPass.php index 4e925986222..f0e70e97507 100644 --- a/vendor/symfony/dependency-injection/Compiler/ResolveServiceSubscribersPass.php +++ b/vendor/symfony/dependency-injection/Compiler/ResolveServiceSubscribersPass.php @@ -19,7 +19,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\ServiceProviderInterface; * * @author Nicolas Grekas */ -class ResolveServiceSubscribersPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class ResolveServiceSubscribersPass extends AbstractRecursivePass { /** * @var string|null @@ -31,10 +31,10 @@ class ResolveServiceSubscribersPass extends \RectorPrefix20220607\Symfony\Compon */ protected function processValue($value, bool $isRoot = \false) { - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference && $this->serviceLocator && \in_array((string) $value, [\RectorPrefix20220607\Psr\Container\ContainerInterface::class, \RectorPrefix20220607\Symfony\Contracts\Service\ServiceProviderInterface::class], \true)) { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($this->serviceLocator); + if ($value instanceof Reference && $this->serviceLocator && \in_array((string) $value, [ContainerInterface::class, ServiceProviderInterface::class], \true)) { + return new Reference($this->serviceLocator); } - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + if (!$value instanceof Definition) { return parent::processValue($value, $isRoot); } $serviceLocator = $this->serviceLocator; diff --git a/vendor/symfony/dependency-injection/Compiler/ResolveTaggedIteratorArgumentPass.php b/vendor/symfony/dependency-injection/Compiler/ResolveTaggedIteratorArgumentPass.php index 58a6881b036..b2fb1035996 100644 --- a/vendor/symfony/dependency-injection/Compiler/ResolveTaggedIteratorArgumentPass.php +++ b/vendor/symfony/dependency-injection/Compiler/ResolveTaggedIteratorArgumentPass.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\TaggedIt * * @author Roland Franssen */ -class ResolveTaggedIteratorArgumentPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +class ResolveTaggedIteratorArgumentPass extends AbstractRecursivePass { use PriorityTaggedServiceTrait; /** @@ -26,7 +26,7 @@ class ResolveTaggedIteratorArgumentPass extends \RectorPrefix20220607\Symfony\Co */ protected function processValue($value, bool $isRoot = \false) { - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument) { + if (!$value instanceof TaggedIteratorArgument) { return parent::processValue($value, $isRoot); } $value->setValues($this->findAndSortTaggedServices($value, $this->container)); diff --git a/vendor/symfony/dependency-injection/Compiler/ServiceLocatorTagPass.php b/vendor/symfony/dependency-injection/Compiler/ServiceLocatorTagPass.php index 750abd598f7..948b95a47ef 100644 --- a/vendor/symfony/dependency-injection/Compiler/ServiceLocatorTagPass.php +++ b/vendor/symfony/dependency-injection/Compiler/ServiceLocatorTagPass.php @@ -24,7 +24,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\ServiceLocator; * * @author Nicolas Grekas */ -final class ServiceLocatorTagPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass +final class ServiceLocatorTagPass extends AbstractRecursivePass { use PriorityTaggedServiceTrait; /** @@ -33,32 +33,32 @@ final class ServiceLocatorTagPass extends \RectorPrefix20220607\Symfony\Componen */ protected function processValue($value, bool $isRoot = \false) { - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument) { + if ($value instanceof ServiceLocatorArgument) { if ($value->getTaggedIteratorArgument()) { $value->setValues($this->findAndSortTaggedServices($value->getTaggedIteratorArgument(), $this->container)); } return self::register($this->container, $value->getValues()); } - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition || !$value->hasTag('container.service_locator')) { + if (!$value instanceof Definition || !$value->hasTag('container.service_locator')) { return parent::processValue($value, $isRoot); } if (!$value->getClass()) { - $value->setClass(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ServiceLocator::class); + $value->setClass(ServiceLocator::class); } $services = $value->getArguments()[0] ?? null; - if ($services instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument) { + if ($services instanceof TaggedIteratorArgument) { $services = $this->findAndSortTaggedServices($services, $this->container); } if (!\is_array($services)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid definition for service "%s": an array of references is expected as first argument when the "container.service_locator" tag is set.', $this->currentId)); + throw new InvalidArgumentException(\sprintf('Invalid definition for service "%s": an array of references is expected as first argument when the "container.service_locator" tag is set.', $this->currentId)); } $i = 0; foreach ($services as $k => $v) { - if ($v instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument) { + if ($v instanceof ServiceClosureArgument) { continue; } if ($i === $k) { - if ($v instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + if ($v instanceof Reference) { unset($services[$k]); $k = (string) $v; } @@ -66,30 +66,30 @@ final class ServiceLocatorTagPass extends \RectorPrefix20220607\Symfony\Componen } elseif (\is_int($k)) { $i = null; } - $services[$k] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument($v); + $services[$k] = new ServiceClosureArgument($v); } \ksort($services); $value->setArgument(0, $services); - $id = '.service_locator.' . \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder::hash($value); + $id = '.service_locator.' . ContainerBuilder::hash($value); if ($isRoot) { if ($id !== $this->currentId) { - $this->container->setAlias($id, new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Alias($this->currentId, \false)); + $this->container->setAlias($id, new Alias($this->currentId, \false)); } return $value; } $this->container->setDefinition($id, $value->setPublic(\false)); - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($id); + return new Reference($id); } - public static function register(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container, array $map, string $callerId = null) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference + public static function register(ContainerBuilder $container, array $map, string $callerId = null) : Reference { foreach ($map as $k => $v) { - $map[$k] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument($v); + $map[$k] = new ServiceClosureArgument($v); } - $locator = (new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ServiceLocator::class))->addArgument($map)->addTag('container.service_locator'); + $locator = (new Definition(ServiceLocator::class))->addArgument($map)->addTag('container.service_locator'); if (null !== $callerId && $container->hasDefinition($callerId)) { $locator->setBindings($container->getDefinition($callerId)->getBindings()); } - if (!$container->hasDefinition($id = '.service_locator.' . \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder::hash($locator))) { + if (!$container->hasDefinition($id = '.service_locator.' . ContainerBuilder::hash($locator))) { $container->setDefinition($id, $locator); } if (null !== $callerId) { @@ -97,8 +97,8 @@ final class ServiceLocatorTagPass extends \RectorPrefix20220607\Symfony\Componen // Locators are shared when they hold the exact same list of factories; // to have them specialized per consumer service, we use a cloning factory // to derivate customized instances from the prototype one. - $container->register($id .= '.' . $callerId, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ServiceLocator::class)->setFactory([new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($locatorId), 'withContext'])->addTag('container.service_locator_context', ['id' => $callerId])->addArgument($callerId)->addArgument(new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference('service_container')); + $container->register($id .= '.' . $callerId, ServiceLocator::class)->setFactory([new Reference($locatorId), 'withContext'])->addTag('container.service_locator_context', ['id' => $callerId])->addArgument($callerId)->addArgument(new Reference('service_container')); } - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($id); + return new Reference($id); } } diff --git a/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraph.php b/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraph.php index 388fad54dd1..2c7e854c481 100644 --- a/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraph.php +++ b/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraph.php @@ -37,10 +37,10 @@ class ServiceReferenceGraph * * @throws InvalidArgumentException if no node matches the supplied identifier */ - public function getNode(string $id) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraphNode + public function getNode(string $id) : ServiceReferenceGraphNode { if (!isset($this->nodes[$id])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('There is no node with id "%s".', $id)); + throw new InvalidArgumentException(\sprintf('There is no node with id "%s".', $id)); } return $this->nodes[$id]; } @@ -68,25 +68,25 @@ class ServiceReferenceGraph * @param mixed $sourceValue * @param mixed $destValue */ - public function connect(?string $sourceId, $sourceValue, ?string $destId, $destValue = null, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference $reference = null, bool $lazy = \false, bool $weak = \false, bool $byConstructor = \false) + public function connect(?string $sourceId, $sourceValue, ?string $destId, $destValue = null, Reference $reference = null, bool $lazy = \false, bool $weak = \false, bool $byConstructor = \false) { if (null === $sourceId || null === $destId) { return; } $sourceNode = $this->createNode($sourceId, $sourceValue); $destNode = $this->createNode($destId, $destValue); - $edge = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraphEdge($sourceNode, $destNode, $reference, $lazy, $weak, $byConstructor); + $edge = new ServiceReferenceGraphEdge($sourceNode, $destNode, $reference, $lazy, $weak, $byConstructor); $sourceNode->addOutEdge($edge); $destNode->addInEdge($edge); } /** * @param mixed $value */ - private function createNode(string $id, $value) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraphNode + private function createNode(string $id, $value) : ServiceReferenceGraphNode { if (isset($this->nodes[$id]) && $this->nodes[$id]->getValue() === $value) { return $this->nodes[$id]; } - return $this->nodes[$id] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraphNode($id, $value); + return $this->nodes[$id] = new ServiceReferenceGraphNode($id, $value); } } diff --git a/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphEdge.php b/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphEdge.php index 5e2289f36a0..dfb868d2273 100644 --- a/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphEdge.php +++ b/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphEdge.php @@ -46,7 +46,7 @@ class ServiceReferenceGraphEdge /** * @param mixed $value */ - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraphNode $sourceNode, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraphNode $destNode, $value = null, bool $lazy = \false, bool $weak = \false, bool $byConstructor = \false) + public function __construct(ServiceReferenceGraphNode $sourceNode, ServiceReferenceGraphNode $destNode, $value = null, bool $lazy = \false, bool $weak = \false, bool $byConstructor = \false) { $this->sourceNode = $sourceNode; $this->destNode = $destNode; @@ -66,14 +66,14 @@ class ServiceReferenceGraphEdge /** * Returns the source node. */ - public function getSourceNode() : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraphNode + public function getSourceNode() : ServiceReferenceGraphNode { return $this->sourceNode; } /** * Returns the destination node. */ - public function getDestNode() : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraphNode + public function getDestNode() : ServiceReferenceGraphNode { return $this->destNode; } diff --git a/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphNode.php b/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphNode.php index f601d55b1d4..5024ea522a3 100644 --- a/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphNode.php +++ b/vendor/symfony/dependency-injection/Compiler/ServiceReferenceGraphNode.php @@ -45,11 +45,11 @@ class ServiceReferenceGraphNode $this->id = $id; $this->value = $value; } - public function addInEdge(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraphEdge $edge) + public function addInEdge(ServiceReferenceGraphEdge $edge) { $this->inEdges[] = $edge; } - public function addOutEdge(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraphEdge $edge) + public function addOutEdge(ServiceReferenceGraphEdge $edge) { $this->outEdges[] = $edge; } @@ -58,14 +58,14 @@ class ServiceReferenceGraphNode */ public function isAlias() : bool { - return $this->value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Alias; + return $this->value instanceof Alias; } /** * Checks if the value of this node is a Definition. */ public function isDefinition() : bool { - return $this->value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition; + return $this->value instanceof Definition; } /** * Returns the identifier. diff --git a/vendor/symfony/dependency-injection/Compiler/ValidateEnvPlaceholdersPass.php b/vendor/symfony/dependency-injection/Compiler/ValidateEnvPlaceholdersPass.php index d1daa0bf1d2..a93714f416c 100644 --- a/vendor/symfony/dependency-injection/Compiler/ValidateEnvPlaceholdersPass.php +++ b/vendor/symfony/dependency-injection/Compiler/ValidateEnvPlaceholdersPass.php @@ -22,7 +22,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\Para * * @author Roland Franssen */ -class ValidateEnvPlaceholdersPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +class ValidateEnvPlaceholdersPass implements CompilerPassInterface { private const TYPE_FIXTURES = ['array' => [], 'bool' => \false, 'float' => 0.0, 'int' => 0, 'string' => '']; /** @@ -32,17 +32,17 @@ class ValidateEnvPlaceholdersPass implements \RectorPrefix20220607\Symfony\Compo /** * {@inheritdoc} */ - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function process(ContainerBuilder $container) { $this->extensionConfig = []; - if (!\class_exists(\RectorPrefix20220607\Symfony\Component\Config\Definition\BaseNode::class) || !($extensions = $container->getExtensions())) { + if (!\class_exists(BaseNode::class) || !($extensions = $container->getExtensions())) { return; } $resolvingBag = $container->getParameterBag(); - if (!$resolvingBag instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag) { + if (!$resolvingBag instanceof EnvPlaceholderParameterBag) { return; } - $defaultBag = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag($resolvingBag->all()); + $defaultBag = new ParameterBag($resolvingBag->all()); $envTypes = $resolvingBag->getProvidedTypes(); foreach ($resolvingBag->getEnvPlaceholders() + $resolvingBag->getUnusedEnvPlaceholders() as $env => $placeholders) { $values = []; @@ -57,17 +57,17 @@ class ValidateEnvPlaceholdersPass implements \RectorPrefix20220607\Symfony\Compo } } foreach ($placeholders as $placeholder) { - \RectorPrefix20220607\Symfony\Component\Config\Definition\BaseNode::setPlaceholder($placeholder, $values); + BaseNode::setPlaceholder($placeholder, $values); } } - $processor = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Processor(); + $processor = new Processor(); foreach ($extensions as $name => $extension) { - if (!($extension instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface || $extension instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\ConfigurationInterface) || !($config = \array_filter($container->getExtensionConfig($name)))) { + if (!($extension instanceof ConfigurationExtensionInterface || $extension instanceof ConfigurationInterface) || !($config = \array_filter($container->getExtensionConfig($name)))) { // this extension has no semantic configuration or was not called continue; } $config = $resolvingBag->resolveValue($config); - if ($extension instanceof \RectorPrefix20220607\Symfony\Component\Config\Definition\ConfigurationInterface) { + if ($extension instanceof ConfigurationInterface) { $configuration = $extension; } elseif (null === ($configuration = $extension->getConfiguration($config, $container))) { continue; diff --git a/vendor/symfony/dependency-injection/Config/ContainerParametersResource.php b/vendor/symfony/dependency-injection/Config/ContainerParametersResource.php index ddba7fabff0..4ed8d2bd084 100644 --- a/vendor/symfony/dependency-injection/Config/ContainerParametersResource.php +++ b/vendor/symfony/dependency-injection/Config/ContainerParametersResource.php @@ -18,7 +18,7 @@ use RectorPrefix20220607\Symfony\Component\Config\Resource\ResourceInterface; * * @final */ -class ContainerParametersResource implements \RectorPrefix20220607\Symfony\Component\Config\Resource\ResourceInterface +class ContainerParametersResource implements ResourceInterface { /** * @var mixed[] diff --git a/vendor/symfony/dependency-injection/Config/ContainerParametersResourceChecker.php b/vendor/symfony/dependency-injection/Config/ContainerParametersResourceChecker.php index dd840e31af0..6572530fa11 100644 --- a/vendor/symfony/dependency-injection/Config/ContainerParametersResourceChecker.php +++ b/vendor/symfony/dependency-injection/Config/ContainerParametersResourceChecker.php @@ -16,27 +16,27 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterfac /** * @author Maxime Steinhausser */ -class ContainerParametersResourceChecker implements \RectorPrefix20220607\Symfony\Component\Config\ResourceCheckerInterface +class ContainerParametersResourceChecker implements ResourceCheckerInterface { /** * @var \Symfony\Component\DependencyInjection\ContainerInterface */ private $container; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface $container) + public function __construct(ContainerInterface $container) { $this->container = $container; } /** * {@inheritdoc} */ - public function supports(\RectorPrefix20220607\Symfony\Component\Config\Resource\ResourceInterface $metadata) : bool + public function supports(ResourceInterface $metadata) : bool { - return $metadata instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Config\ContainerParametersResource; + return $metadata instanceof ContainerParametersResource; } /** * {@inheritdoc} */ - public function isFresh(\RectorPrefix20220607\Symfony\Component\Config\Resource\ResourceInterface $resource, int $timestamp) : bool + public function isFresh(ResourceInterface $resource, int $timestamp) : bool { foreach ($resource->getParameters() as $key => $value) { if (!$this->container->hasParameter($key) || $this->container->getParameter($key) !== $value) { diff --git a/vendor/symfony/dependency-injection/Container.php b/vendor/symfony/dependency-injection/Container.php index b818b5937fb..ec1f7a512be 100644 --- a/vendor/symfony/dependency-injection/Container.php +++ b/vendor/symfony/dependency-injection/Container.php @@ -23,8 +23,8 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\Froz use RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use RectorPrefix20220607\Symfony\Contracts\Service\ResetInterface; // Help opcache.preload discover always-needed symbols -\class_exists(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\RewindableGenerator::class); -\class_exists(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocator::class); +\class_exists(RewindableGenerator::class); +\class_exists(ArgumentServiceLocator::class); /** * Container is a dependency injection container. * @@ -42,7 +42,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\ResetInterface; * @author Fabien Potencier * @author Johannes M. Schmitt */ -class Container implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface, \RectorPrefix20220607\Symfony\Contracts\Service\ResetInterface +class Container implements ContainerInterface, ResetInterface { protected $parameterBag; protected $services = []; @@ -66,9 +66,9 @@ class Container implements \RectorPrefix20220607\Symfony\Component\DependencyInj * @var \Closure */ private $getEnv; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface $parameterBag = null) + public function __construct(ParameterBagInterface $parameterBag = null) { - $this->parameterBag = $parameterBag ?? new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag(); + $this->parameterBag = $parameterBag ?? new EnvPlaceholderParameterBag(); } /** * Compiles the container. @@ -81,7 +81,7 @@ class Container implements \RectorPrefix20220607\Symfony\Component\DependencyInj public function compile() { $this->parameterBag->resolve(); - $this->parameterBag = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag($this->parameterBag->all()); + $this->parameterBag = new FrozenParameterBag($this->parameterBag->all()); $this->compiled = \true; } /** @@ -94,7 +94,7 @@ class Container implements \RectorPrefix20220607\Symfony\Component\DependencyInj /** * Gets the service container parameter bag. */ - public function getParameterBag() : \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface + public function getParameterBag() : ParameterBagInterface { return $this->parameterBag; } @@ -135,18 +135,18 @@ class Container implements \RectorPrefix20220607\Symfony\Component\DependencyInj $initialize(); } if ('service_container' === $id) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('You cannot set service "service_container".'); + throw new InvalidArgumentException('You cannot set service "service_container".'); } if (!(isset($this->fileMap[$id]) || isset($this->methodMap[$id]))) { if (isset($this->syntheticIds[$id]) || !isset($this->getRemovedIds()[$id])) { // no-op } elseif (null === $service) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The "%s" service is private, you cannot unset it.', $id)); + throw new InvalidArgumentException(\sprintf('The "%s" service is private, you cannot unset it.', $id)); } else { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The "%s" service is private, you cannot replace it.', $id)); + throw new InvalidArgumentException(\sprintf('The "%s" service is private, you cannot replace it.', $id)); } } elseif (isset($this->services[$id])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The "%s" service is already initialized, you cannot replace it.', $id)); + throw new InvalidArgumentException(\sprintf('The "%s" service is already initialized, you cannot replace it.', $id)); } if (isset($this->aliases[$id])) { unset($this->aliases[$id]); @@ -191,7 +191,7 @@ class Container implements \RectorPrefix20220607\Symfony\Component\DependencyInj private function make(string $id, int $invalidBehavior) { if (isset($this->loading[$id])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException($id, \array_merge(\array_keys($this->loading), [$id])); + throw new ServiceCircularReferenceException($id, \array_merge(\array_keys($this->loading), [$id])); } $this->loading[$id] = \true; try { @@ -208,13 +208,13 @@ class Container implements \RectorPrefix20220607\Symfony\Component\DependencyInj } if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) { if (!$id) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException($id); + throw new ServiceNotFoundException($id); } if (isset($this->syntheticIds[$id])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException($id, null, null, [], \sprintf('The "%s" service is synthetic, it needs to be set at boot time before it can be used.', $id)); + throw new ServiceNotFoundException($id, null, null, [], \sprintf('The "%s" service is synthetic, it needs to be set at boot time before it can be used.', $id)); } if (isset($this->getRemovedIds()[$id])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException($id, null, null, [], \sprintf('The "%s" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.', $id)); + throw new ServiceNotFoundException($id, null, null, [], \sprintf('The "%s" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.', $id)); } $alternatives = []; foreach ($this->getServiceIds() as $knownId) { @@ -226,7 +226,7 @@ class Container implements \RectorPrefix20220607\Symfony\Component\DependencyInj $alternatives[] = $knownId; } } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException($id, null, null, $alternatives); + throw new ServiceNotFoundException($id, null, null, $alternatives); } return null; } @@ -252,7 +252,7 @@ class Container implements \RectorPrefix20220607\Symfony\Component\DependencyInj $this->services = $this->factories = $this->privates = []; foreach ($services as $service) { try { - if ($service instanceof \RectorPrefix20220607\Symfony\Contracts\Service\ResetInterface) { + if ($service instanceof ResetInterface) { $service->reset(); } } catch (\Throwable $exception) { @@ -306,13 +306,13 @@ class Container implements \RectorPrefix20220607\Symfony\Component\DependencyInj protected function getEnv(string $name) { if (isset($this->resolving[$envName = "env({$name})"])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException(\array_keys($this->resolving)); + throw new ParameterCircularReferenceException(\array_keys($this->resolving)); } if (isset($this->envCache[$name]) || \array_key_exists($name, $this->envCache)) { return $this->envCache[$name]; } if (!$this->has($id = 'container.env_var_processors_locator')) { - $this->set($id, new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ServiceLocator([])); + $this->set($id, new ServiceLocator([])); } $this->getEnv = $this->getEnv ?? \Closure::fromCallable([$this, 'getEnv']); $processors = $this->get($id); @@ -323,7 +323,7 @@ class Container implements \RectorPrefix20220607\Symfony\Component\DependencyInj $prefix = 'string'; $localName = $name; } - $processor = $processors->has($prefix) ? $processors->get($prefix) : new \RectorPrefix20220607\Symfony\Component\DependencyInjection\EnvVarProcessor($this); + $processor = $processors->has($prefix) ? $processors->get($prefix) : new EnvVarProcessor($this); $this->resolving[$envName] = \true; try { return $this->envCache[$name] = $processor->getEnv($prefix, $localName, $this->getEnv); @@ -343,7 +343,7 @@ class Container implements \RectorPrefix20220607\Symfony\Component\DependencyInj return $this; } if (\is_string($load)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException($load); + throw new RuntimeException($load); } if (null === $method) { return \false !== $registry ? $this->{$registry}[$id] ?? null : null; diff --git a/vendor/symfony/dependency-injection/ContainerAwareInterface.php b/vendor/symfony/dependency-injection/ContainerAwareInterface.php index 0c568ce2e6a..e17e0622bf7 100644 --- a/vendor/symfony/dependency-injection/ContainerAwareInterface.php +++ b/vendor/symfony/dependency-injection/ContainerAwareInterface.php @@ -20,5 +20,5 @@ interface ContainerAwareInterface /** * Sets the container. */ - public function setContainer(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface $container = null); + public function setContainer(ContainerInterface $container = null); } diff --git a/vendor/symfony/dependency-injection/ContainerAwareTrait.php b/vendor/symfony/dependency-injection/ContainerAwareTrait.php index 70d179e97cd..f2a9e96ef0a 100644 --- a/vendor/symfony/dependency-injection/ContainerAwareTrait.php +++ b/vendor/symfony/dependency-injection/ContainerAwareTrait.php @@ -21,7 +21,7 @@ trait ContainerAwareTrait * @var ContainerInterface */ protected $container; - public function setContainer(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface $container = null) + public function setContainer(ContainerInterface $container = null) { $this->container = $container; } diff --git a/vendor/symfony/dependency-injection/ContainerBuilder.php b/vendor/symfony/dependency-injection/ContainerBuilder.php index a04e38463fb..033b1d63638 100644 --- a/vendor/symfony/dependency-injection/ContainerBuilder.php +++ b/vendor/symfony/dependency-injection/ContainerBuilder.php @@ -49,7 +49,7 @@ use RectorPrefix20220607\Symfony\Component\ExpressionLanguage\ExpressionFunction * * @author Fabien Potencier */ -class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Container implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\TaggedContainerInterface +class ContainerBuilder extends Container implements TaggedContainerInterface { /** * @var array @@ -128,11 +128,11 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc */ private $removedBindingIds = []; private const INTERNAL_TYPES = ['int' => \true, 'float' => \true, 'string' => \true, 'bool' => \true, 'resource' => \true, 'object' => \true, 'array' => \true, 'null' => \true, 'callable' => \true, 'iterable' => \true, 'mixed' => \true]; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface $parameterBag = null) + public function __construct(ParameterBagInterface $parameterBag = null) { parent::__construct($parameterBag); - $this->trackResources = \interface_exists(\RectorPrefix20220607\Symfony\Component\Config\Resource\ResourceInterface::class); - $this->setDefinition('service_container', (new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::class))->setSynthetic(\true)->setPublic(\true)); + $this->trackResources = \interface_exists(ResourceInterface::class); + $this->setDefinition('service_container', (new Definition(ContainerInterface::class))->setSynthetic(\true)->setPublic(\true)); } /** * @var array @@ -158,11 +158,11 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc /** * Sets the instantiator to be used when fetching proxies. */ - public function setProxyInstantiator(\RectorPrefix20220607\Symfony\Component\DependencyInjection\LazyProxy\Instantiator\InstantiatorInterface $proxyInstantiator) + public function setProxyInstantiator(InstantiatorInterface $proxyInstantiator) { $this->proxyInstantiator = $proxyInstantiator; } - public function registerExtension(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\ExtensionInterface $extension) + public function registerExtension(ExtensionInterface $extension) { $this->extensions[$extension->getAlias()] = $extension; if (\false !== $extension->getNamespace()) { @@ -174,7 +174,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc * * @throws LogicException if the extension is not registered */ - public function getExtension(string $name) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\ExtensionInterface + public function getExtension(string $name) : ExtensionInterface { if (isset($this->extensions[$name])) { return $this->extensions[$name]; @@ -182,7 +182,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc if (isset($this->extensionsByNs[$name])) { return $this->extensionsByNs[$name]; } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicException(\sprintf('Container extension "%s" is not registered.', $name)); + throw new LogicException(\sprintf('Container extension "%s" is not registered.', $name)); } /** * Returns all registered extensions. @@ -212,12 +212,12 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc /** * @return $this */ - public function addResource(\RectorPrefix20220607\Symfony\Component\Config\Resource\ResourceInterface $resource) + public function addResource(ResourceInterface $resource) { if (!$this->trackResources) { return $this; } - if ($resource instanceof \RectorPrefix20220607\Symfony\Component\Config\Resource\GlobResource && $this->inVendors($resource->getPrefix())) { + if ($resource instanceof GlobResource && $this->inVendors($resource->getPrefix())) { return $this; } $this->resources[(string) $resource] = $resource; @@ -295,8 +295,8 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc try { if (isset($this->classReflectors[$class])) { $classReflector = $this->classReflectors[$class]; - } elseif (\class_exists(\RectorPrefix20220607\Symfony\Component\Config\Resource\ClassExistenceResource::class)) { - $resource = new \RectorPrefix20220607\Symfony\Component\Config\Resource\ClassExistenceResource($class, \false); + } elseif (\class_exists(ClassExistenceResource::class)) { + $resource = new ClassExistenceResource($class, \false); $classReflector = $resource->isFresh(0) ? \false : new \ReflectionClass($class); } else { $classReflector = \class_exists($class) ? new \ReflectionClass($class) : \false; @@ -308,11 +308,11 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc } if ($this->trackResources) { if (!$classReflector) { - $this->addResource($resource ?? new \RectorPrefix20220607\Symfony\Component\Config\Resource\ClassExistenceResource($class, \false)); + $this->addResource($resource ?? new ClassExistenceResource($class, \false)); } elseif (!$classReflector->isInternal()) { $path = $classReflector->getFileName(); if (!$this->inVendors($path)) { - $this->addResource(new \RectorPrefix20220607\Symfony\Component\Config\Resource\ReflectionClassResource($classReflector, $this->vendors)); + $this->addResource(new ReflectionClassResource($classReflector, $this->vendors)); } } $this->classReflectors[$class] = $classReflector; @@ -335,17 +335,17 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc return $exists; } if (!$exists) { - $this->addResource(new \RectorPrefix20220607\Symfony\Component\Config\Resource\FileExistenceResource($path)); + $this->addResource(new FileExistenceResource($path)); return $exists; } if (\is_dir($path)) { if ($trackContents) { - $this->addResource(new \RectorPrefix20220607\Symfony\Component\Config\Resource\DirectoryResource($path, \is_string($trackContents) ? $trackContents : null)); + $this->addResource(new DirectoryResource($path, \is_string($trackContents) ? $trackContents : null)); } else { - $this->addResource(new \RectorPrefix20220607\Symfony\Component\Config\Resource\GlobResource($path, '/*', \false)); + $this->addResource(new GlobResource($path, '/*', \false)); } } elseif ($trackContents) { - $this->addResource(new \RectorPrefix20220607\Symfony\Component\Config\Resource\FileResource($path)); + $this->addResource(new FileResource($path)); } return $exists; } @@ -363,7 +363,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc public function loadFromExtension(string $extension, array $values = null) { if ($this->isCompiled()) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\BadMethodCallException('Cannot load from an extension on a compiled container.'); + throw new BadMethodCallException('Cannot load from an extension on a compiled container.'); } $namespace = $this->getExtension($extension)->getAlias(); $this->extensionConfigs[$namespace][] = $values ?? []; @@ -377,7 +377,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc * * @return $this */ - public function addCompilerPass(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface $pass, string $type = \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0) + public function addCompilerPass(CompilerPassInterface $pass, string $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0) { $this->getCompiler()->addPass($pass, $type, $priority); $this->addObjectResource($pass); @@ -386,16 +386,16 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc /** * Returns the compiler pass config which can then be modified. */ - public function getCompilerPassConfig() : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\PassConfig + public function getCompilerPassConfig() : PassConfig { return $this->getCompiler()->getPassConfig(); } /** * Returns the compiler. */ - public function getCompiler() : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\Compiler + public function getCompiler() : Compiler { - return $this->compiler = $this->compiler ?? new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\Compiler(); + return $this->compiler = $this->compiler ?? new Compiler(); } /** * Sets a service. @@ -406,7 +406,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc { if ($this->isCompiled() && (isset($this->definitions[$id]) && !$this->definitions[$id]->isSynthetic())) { // setting a synthetic service on a compiled container is alright - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\BadMethodCallException(\sprintf('Setting service "%s" for an unknown or non-synthetic service definition on a compiled container is not allowed.', $id)); + throw new BadMethodCallException(\sprintf('Setting service "%s" for an unknown or non-synthetic service definition on a compiled container is not allowed.', $id)); } unset($this->definitions[$id], $this->aliasDefinitions[$id], $this->removedIds[$id]); parent::set($id, $service); @@ -433,9 +433,9 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc * * @see Reference */ - public function get(string $id, int $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) : ?object + public function get(string $id, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) : ?object { - if ($this->isCompiled() && isset($this->removedIds[$id]) && \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE >= $invalidBehavior) { + if ($this->isCompiled() && isset($this->removedIds[$id]) && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE >= $invalidBehavior) { return parent::get($id); } return $this->doGet($id, $invalidBehavior); @@ -443,7 +443,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc /** * @return mixed */ - private function doGet(string $id, int $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, array &$inlineServices = null, bool $isConstructorArgument = \false) + private function doGet(string $id, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, array &$inlineServices = null, bool $isConstructorArgument = \false) { if (isset($inlineServices[$id])) { return $inlineServices[$id]; @@ -453,13 +453,13 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc $inlineServices = []; } try { - if (\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $invalidBehavior) { + if (ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $invalidBehavior) { return parent::get($id, $invalidBehavior); } - if ($service = parent::get($id, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::NULL_ON_INVALID_REFERENCE)) { + if ($service = parent::get($id, ContainerInterface::NULL_ON_INVALID_REFERENCE)) { return $service; } - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException $e) { + } catch (ServiceCircularReferenceException $e) { if ($isConstructorArgument) { throw $e; } @@ -468,20 +468,20 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc $alias = $this->aliasDefinitions[$id]; if ($alias->isDeprecated()) { $deprecation = $alias->getDeprecation($id); - trigger_deprecation($deprecation['package'], $deprecation['version'], $deprecation['message']); + \RectorPrefix20220607\trigger_deprecation($deprecation['package'], $deprecation['version'], $deprecation['message']); } return $this->doGet((string) $alias, $invalidBehavior, $inlineServices, $isConstructorArgument); } try { $definition = $this->getDefinition($id); - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException $e) { - if (\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE < $invalidBehavior) { + } catch (ServiceNotFoundException $e) { + if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE < $invalidBehavior) { return null; } throw $e; } if ($definition->hasErrors() && ($e = $definition->getErrors())) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\reset($e)); + throw new RuntimeException(\reset($e)); } if ($isConstructorArgument) { $this->loading[$id] = \true; @@ -517,7 +517,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc public function merge(self $container) { if ($this->isCompiled()) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\BadMethodCallException('Cannot merge on a compiled container.'); + throw new BadMethodCallException('Cannot merge on a compiled container.'); } $this->addDefinitions($container->getDefinitions()); $this->addAliases($container->getAliases()); @@ -533,7 +533,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc } $this->extensionConfigs[$name] = \array_merge($this->extensionConfigs[$name], $container->getExtensionConfig($name)); } - if ($this->getParameterBag() instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag && $container->getParameterBag() instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag) { + if ($this->getParameterBag() instanceof EnvPlaceholderParameterBag && $container->getParameterBag() instanceof EnvPlaceholderParameterBag) { $envPlaceholders = $container->getParameterBag()->getEnvPlaceholders(); $this->getParameterBag()->mergeEnvPlaceholders($container->getParameterBag()); } else { @@ -551,13 +551,13 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc } foreach ($container->getAutoconfiguredInstanceof() as $interface => $childDefinition) { if (isset($this->autoconfiguredInstanceof[$interface])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('"%s" has already been autoconfigured and merge() does not support merging autoconfiguration for the same class/interface.', $interface)); + throw new InvalidArgumentException(\sprintf('"%s" has already been autoconfigured and merge() does not support merging autoconfiguration for the same class/interface.', $interface)); } $this->autoconfiguredInstanceof[$interface] = $childDefinition; } foreach ($container->getAutoconfiguredAttributes() as $attribute => $configurator) { if (isset($this->autoconfiguredAttributes[$attribute])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('"%s" has already been autoconfigured and merge() does not support merging autoconfiguration for the same attribute.', $attribute)); + throw new InvalidArgumentException(\sprintf('"%s" has already been autoconfigured and merge() does not support merging autoconfiguration for the same attribute.', $attribute)); } $this->autoconfiguredAttributes[$attribute] = $configurator; } @@ -614,8 +614,8 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc } } $bag = $this->getParameterBag(); - if ($resolveEnvPlaceholders && $bag instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag) { - $compiler->addPass(new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ResolveEnvPlaceholdersPass(), \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_AFTER_REMOVING, -1000); + if ($resolveEnvPlaceholders && $bag instanceof EnvPlaceholderParameterBag) { + $compiler->addPass(new ResolveEnvPlaceholdersPass(), PassConfig::TYPE_AFTER_REMOVING, -1000); } $compiler->compile($this); foreach ($this->definitions as $id => $definition) { @@ -624,9 +624,9 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc } } $this->extensionConfigs = []; - if ($bag instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag) { + if ($bag instanceof EnvPlaceholderParameterBag) { if ($resolveEnvPlaceholders) { - $this->parameterBag = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag($this->resolveEnvPlaceholders($bag->all(), \true)); + $this->parameterBag = new ParameterBag($this->resolveEnvPlaceholders($bag->all(), \true)); } $this->envPlaceholders = $bag->getEnvPlaceholders(); } @@ -681,16 +681,16 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc * @throws InvalidArgumentException if the alias is for itself * @param string|\Symfony\Component\DependencyInjection\Alias $id */ - public function setAlias(string $alias, $id) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Alias + public function setAlias(string $alias, $id) : Alias { - if ('' === $alias || '\\' === $alias[-1] || \strlen($alias) !== \strcspn($alias, "\0\r\n'")) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid alias id: "%s".', $alias)); + if ('' === $alias || '\\' === $alias[-1] || \strlen($alias) !== \strcspn($alias, "\x00\r\n'")) { + throw new InvalidArgumentException(\sprintf('Invalid alias id: "%s".', $alias)); } if (\is_string($id)) { - $id = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Alias($id); + $id = new Alias($id); } if ($alias === (string) $id) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('An alias cannot reference itself, got a circular reference on "%s".', $alias)); + throw new InvalidArgumentException(\sprintf('An alias cannot reference itself, got a circular reference on "%s".', $alias)); } unset($this->definitions[$alias], $this->removedIds[$alias]); return $this->aliasDefinitions[$alias] = $id; @@ -716,10 +716,10 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc /** * @throws InvalidArgumentException if the alias does not exist */ - public function getAlias(string $id) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Alias + public function getAlias(string $id) : Alias { if (!isset($this->aliasDefinitions[$id])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The service alias "%s" does not exist.', $id)); + throw new InvalidArgumentException(\sprintf('The service alias "%s" does not exist.', $id)); } return $this->aliasDefinitions[$id]; } @@ -729,9 +729,9 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc * This methods allows for simple registration of service definition * with a fluid interface. */ - public function register(string $id, string $class = null) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition + public function register(string $id, string $class = null) : Definition { - return $this->setDefinition($id, new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition($class)); + return $this->setDefinition($id, new Definition($class)); } /** * Registers an autowired service definition. @@ -739,9 +739,9 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc * This method implements a shortcut for using setDefinition() with * an autowired definition. */ - public function autowire(string $id, string $class = null) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition + public function autowire(string $id, string $class = null) : Definition { - return $this->setDefinition($id, (new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition($class))->setAutowired(\true)); + return $this->setDefinition($id, (new Definition($class))->setAutowired(\true)); } /** * Adds the service definitions. @@ -778,13 +778,13 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc * * @throws BadMethodCallException When this ContainerBuilder is compiled */ - public function setDefinition(string $id, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition + public function setDefinition(string $id, Definition $definition) : Definition { if ($this->isCompiled()) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\BadMethodCallException('Adding definition to a compiled container is not allowed.'); + throw new BadMethodCallException('Adding definition to a compiled container is not allowed.'); } - if ('' === $id || '\\' === $id[-1] || \strlen($id) !== \strcspn($id, "\0\r\n'")) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid service id: "%s".', $id)); + if ('' === $id || '\\' === $id[-1] || \strlen($id) !== \strcspn($id, "\x00\r\n'")) { + throw new InvalidArgumentException(\sprintf('Invalid service id: "%s".', $id)); } unset($this->aliasDefinitions[$id], $this->removedIds[$id]); return $this->definitions[$id] = $definition; @@ -801,10 +801,10 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc * * @throws ServiceNotFoundException if the service definition does not exist */ - public function getDefinition(string $id) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition + public function getDefinition(string $id) : Definition { if (!isset($this->definitions[$id])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException($id); + throw new ServiceNotFoundException($id); } return $this->definitions[$id]; } @@ -815,7 +815,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc * * @throws ServiceNotFoundException if the service definition does not exist */ - public function findDefinition(string $id) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition + public function findDefinition(string $id) : Definition { $seen = []; while (isset($this->aliasDefinitions[$id])) { @@ -824,7 +824,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc $seen = \array_values($seen); $seen = \array_slice($seen, \array_search($id, $seen)); $seen[] = $id; - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException($id, $seen); + throw new ServiceCircularReferenceException($id, $seen); } $seen[$id] = $id; } @@ -838,22 +838,22 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc * @throws InvalidArgumentException When configure callable is not callable * @return mixed */ - private function createService(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, array &$inlineServices, bool $isConstructorArgument = \false, string $id = null, bool $tryProxy = \true) + private function createService(Definition $definition, array &$inlineServices, bool $isConstructorArgument = \false, string $id = null, bool $tryProxy = \true) { if (null === $id && isset($inlineServices[$h = \spl_object_hash($definition)])) { return $inlineServices[$h]; } - if ($definition instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Constructing service "%s" from a parent definition is not supported at build time.', $id)); + if ($definition instanceof ChildDefinition) { + throw new RuntimeException(\sprintf('Constructing service "%s" from a parent definition is not supported at build time.', $id)); } if ($definition->isSynthetic()) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('You have requested a synthetic service ("%s"). The DIC does not know how to construct this service.', $id)); + throw new RuntimeException(\sprintf('You have requested a synthetic service ("%s"). The DIC does not know how to construct this service.', $id)); } if ($definition->isDeprecated()) { $deprecation = $definition->getDeprecation($id); - trigger_deprecation($deprecation['package'], $deprecation['version'], $deprecation['message']); + \RectorPrefix20220607\trigger_deprecation($deprecation['package'], $deprecation['version'], $deprecation['message']); } - if ($tryProxy && $definition->isLazy() && !($tryProxy = !($proxy = $this->proxyInstantiator) || $proxy instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\LazyProxy\Instantiator\RealServiceInstantiator)) { + if ($tryProxy && $definition->isLazy() && !($tryProxy = !($proxy = $this->proxyInstantiator) || $proxy instanceof RealServiceInstantiator)) { $proxy = $proxy->instantiateProxy($this, $definition, $id, function () use($definition, &$inlineServices, $id) { return $this->createService($definition, $inlineServices, \true, $id, \false); }); @@ -869,12 +869,12 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc if (\is_array($factory)) { $factory = [$this->doResolveServices($parameterBag->resolveValue($factory[0]), $inlineServices, $isConstructorArgument), $factory[1]]; } elseif (!\is_string($factory)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Cannot create service "%s" because of invalid factory.', $id)); + throw new RuntimeException(\sprintf('Cannot create service "%s" because of invalid factory.', $id)); } elseif (\strncmp($factory, '@=', \strlen('@=')) === 0) { - $factory = function (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocator $arguments) use($factory) { + $factory = function (ServiceLocator $arguments) use($factory) { return $this->getExpressionLanguage()->evaluate(\substr($factory, 2), ['container' => $this, 'args' => $arguments]); }; - $arguments = [new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument($arguments)]; + $arguments = [new ServiceLocatorArgument($arguments)]; } } $arguments = $this->doResolveServices($parameterBag->unescapeValue($parameterBag->resolveValue($arguments)), $inlineServices, $isConstructorArgument); @@ -886,14 +886,14 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc if (!$definition->isDeprecated() && \is_array($factory) && \is_string($factory[0])) { $r = new \ReflectionClass($factory[0]); if (0 < \strpos($r->getDocComment(), "\n * @deprecated ")) { - trigger_deprecation('', '', 'The "%s" service relies on the deprecated "%s" factory class. It should either be deprecated or its factory upgraded.', $id, $r->name); + \RectorPrefix20220607\trigger_deprecation('', '', 'The "%s" service relies on the deprecated "%s" factory class. It should either be deprecated or its factory upgraded.', $id, $r->name); } } } else { $r = new \ReflectionClass($parameterBag->resolveValue($definition->getClass())); $service = null === $r->getConstructor() ? $r->newInstance() : $r->newInstanceArgs(\array_values($arguments)); if (!$definition->isDeprecated() && 0 < \strpos($r->getDocComment(), "\n * @deprecated ")) { - trigger_deprecation('', '', 'The "%s" service relies on the deprecated "%s" class. It should either be deprecated or its implementation upgraded.', $id, $r->name); + \RectorPrefix20220607\trigger_deprecation('', '', 'The "%s" service relies on the deprecated "%s" class. It should either be deprecated or its implementation upgraded.', $id, $r->name); } } $lastWitherIndex = null; @@ -920,14 +920,14 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc if ($callable = $definition->getConfigurator()) { if (\is_array($callable)) { $callable[0] = $parameterBag->resolveValue($callable[0]); - if ($callable[0] instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + if ($callable[0] instanceof Reference) { $callable[0] = $this->doGet((string) $callable[0], $callable[0]->getInvalidBehavior(), $inlineServices); - } elseif ($callable[0] instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + } elseif ($callable[0] instanceof Definition) { $callable[0] = $this->createService($callable[0], $inlineServices); } } if (!\is_callable($callable)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The configure callable for class "%s" is not a callable.', \get_debug_type($service))); + throw new InvalidArgumentException(\sprintf('The configure callable for class "%s" is not a callable.', \get_debug_type($service))); } $callable($service); } @@ -954,13 +954,13 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc foreach ($value as $k => $v) { $value[$k] = $this->doResolveServices($v, $inlineServices, $isConstructorArgument); } - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument) { + } elseif ($value instanceof ServiceClosureArgument) { $reference = $value->getValues()[0]; $value = function () use($reference) { return $this->resolveServices($reference); }; - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\IteratorArgument) { - $value = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\RewindableGenerator(function () use($value, &$inlineServices) { + } elseif ($value instanceof IteratorArgument) { + $value = new RewindableGenerator(function () use($value, &$inlineServices) { foreach ($value->getValues() as $k => $v) { foreach (self::getServiceConditionals($v) as $s) { if (!$this->has($s)) { @@ -968,7 +968,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc } } foreach (self::getInitializedConditionals($v) as $s) { - if (!$this->doGet($s, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE, $inlineServices)) { + if (!$this->doGet($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE, $inlineServices)) { continue 2; } } @@ -983,7 +983,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc } } foreach (self::getInitializedConditionals($v) as $s) { - if (!$this->doGet($s, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE)) { + if (!$this->doGet($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE)) { continue 2; } } @@ -991,23 +991,23 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc } return $count; }); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument) { + } elseif ($value instanceof ServiceLocatorArgument) { $refs = $types = []; foreach ($value->getValues() as $k => $v) { $refs[$k] = [$v, null]; - $types[$k] = $v instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference ? $v->getType() : '?'; + $types[$k] = $v instanceof TypedReference ? $v->getType() : '?'; } - $value = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocator(\Closure::fromCallable([$this, 'resolveServices']), $refs, $types); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + $value = new ServiceLocator(\Closure::fromCallable([$this, 'resolveServices']), $refs, $types); + } elseif ($value instanceof Reference) { $value = $this->doGet((string) $value, $value->getInvalidBehavior(), $inlineServices, $isConstructorArgument); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + } elseif ($value instanceof Definition) { $value = $this->createService($value, $inlineServices, $isConstructorArgument); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Parameter) { + } elseif ($value instanceof Parameter) { $value = $this->getParameter((string) $value); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression) { + } elseif ($value instanceof Expression) { $value = $this->getExpressionLanguage()->evaluate($value, ['container' => $this]); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\AbstractArgument) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException($value->getTextWithContext()); + } elseif ($value instanceof AbstractArgument) { + throw new RuntimeException($value->getTextWithContext()); } return $value; } @@ -1034,7 +1034,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc foreach ($this->getDefinitions() as $id => $definition) { if ($definition->hasTag($name)) { if ($throwOnAbstract && $definition->isAbstract()) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The service "%s" tagged "%s" must not be abstract.', $id, $name)); + throw new InvalidArgumentException(\sprintf('The service "%s" tagged "%s" must not be abstract.', $id, $name)); } $tags[$id] = $definition->getTag($name); } @@ -1063,7 +1063,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc { return \array_values(\array_diff($this->findTags(), $this->usedTags)); } - public function addExpressionLanguageProvider(\RectorPrefix20220607\Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface $provider) + public function addExpressionLanguageProvider(ExpressionFunctionProviderInterface $provider) { $this->expressionLanguageProviders[] = $provider; } @@ -1077,10 +1077,10 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc /** * Returns a ChildDefinition that will be used for autoconfiguring the interface/class. */ - public function registerForAutoconfiguration(string $interface) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition + public function registerForAutoconfiguration(string $interface) : ChildDefinition { if (!isset($this->autoconfiguredInstanceof[$interface])) { - $this->autoconfiguredInstanceof[$interface] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition(''); + $this->autoconfiguredInstanceof[$interface] = new ChildDefinition(''); } return $this->autoconfiguredInstanceof[$interface]; } @@ -1109,11 +1109,11 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc * "$fooBar"-named arguments with $type as type-hint. Such arguments will * receive the service $id when autowiring is used. */ - public function registerAliasForArgument(string $id, string $type, string $name = null) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Alias + public function registerAliasForArgument(string $id, string $type, string $name = null) : Alias { - $name = (new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Attribute\Target($name ?? $id))->name; + $name = (new Target($name ?? $id))->name; if (!\preg_match('/^[a-zA-Z_\\x7f-\\xff]/', $name)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid argument name "%s" for service "%s": the first character must be a letter.', $name, $id)); + throw new InvalidArgumentException(\sprintf('Invalid argument name "%s" for service "%s": the first character must be a letter.', $name, $id)); } return $this->setAlias($type . ' $' . $name, $id); } @@ -1153,7 +1153,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc if (\true === $format) { $value = $bag->resolveValue($value); } - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + if ($value instanceof Definition) { $value = (array) $value; } if (\is_array($value)) { @@ -1166,7 +1166,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc if (!\is_string($value) || 38 > \strlen($value) || !\preg_match('/env[_(]/i', $value)) { return $value; } - $envPlaceholders = $bag instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag ? $bag->getEnvPlaceholders() : $this->envPlaceholders; + $envPlaceholders = $bag instanceof EnvPlaceholderParameterBag ? $bag->getEnvPlaceholders() : $this->envPlaceholders; $completed = \false; foreach ($envPlaceholders as $env => $placeholders) { foreach ($placeholders as $placeholder) { @@ -1181,7 +1181,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc $completed = \true; } else { if (!\is_string($resolved) && !\is_numeric($resolved)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('A string value must be composed of strings and/or numbers, but found parameter "env(%s)" of type "%s" inside string value "%s".', $env, \get_debug_type($resolved), $this->resolveEnvPlaceholders($value))); + throw new RuntimeException(\sprintf('A string value must be composed of strings and/or numbers, but found parameter "env(%s)" of type "%s" inside string value "%s".', $env, \get_debug_type($resolved), $this->resolveEnvPlaceholders($value))); } $value = \str_ireplace($placeholder, $resolved, $value); } @@ -1203,7 +1203,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc public function getEnvCounters() : array { $bag = $this->getParameterBag(); - $envPlaceholders = $bag instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag ? $bag->getEnvPlaceholders() : $this->envPlaceholders; + $envPlaceholders = $bag instanceof EnvPlaceholderParameterBag ? $bag->getEnvPlaceholders() : $this->envPlaceholders; foreach ($envPlaceholders as $env => $placeholders) { if (!isset($this->envCounters[$env])) { $this->envCounters[$env] = 0; @@ -1214,7 +1214,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc /** * @final */ - public function log(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface $pass, string $message) + public function log(CompilerPassInterface $pass, string $message) { $this->getCompiler()->log($pass, $this->resolveEnvPlaceholders($message)); } @@ -1228,22 +1228,22 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc */ public static final function willBeAvailable(string $package, string $class, array $parentPackages) : bool { - if (!\class_exists(\RectorPrefix20220607\Composer\InstalledVersions::class)) { + if (!\class_exists(InstalledVersions::class)) { throw new \LogicException(\sprintf('Calling "%s" when dependencies have been installed with Composer 1 is not supported. Consider upgrading to Composer 2.', __METHOD__)); } if (!\class_exists($class) && !\interface_exists($class, \false) && !\trait_exists($class, \false)) { return \false; } - if (!\RectorPrefix20220607\Composer\InstalledVersions::isInstalled($package) || \RectorPrefix20220607\Composer\InstalledVersions::isInstalled($package, \false)) { + if (!InstalledVersions::isInstalled($package) || InstalledVersions::isInstalled($package, \false)) { return \true; } // the package is installed but in dev-mode only, check if this applies to one of the parent packages too - $rootPackage = \RectorPrefix20220607\Composer\InstalledVersions::getRootPackage()['name'] ?? ''; + $rootPackage = InstalledVersions::getRootPackage()['name'] ?? ''; if ('symfony/symfony' === $rootPackage) { return \true; } foreach ($parentPackages as $parentPackage) { - if ($rootPackage === $parentPackage || \RectorPrefix20220607\Composer\InstalledVersions::isInstalled($parentPackage) && !\RectorPrefix20220607\Composer\InstalledVersions::isInstalled($parentPackage, \false)) { + if ($rootPackage === $parentPackage || InstalledVersions::isInstalled($parentPackage) && !InstalledVersions::isInstalled($parentPackage, \false)) { return \true; } } @@ -1287,7 +1287,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc foreach ($value as $v) { $services = \array_unique(\array_merge($services, self::getServiceConditionals($v))); } - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference && \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $value->getInvalidBehavior()) { + } elseif ($value instanceof Reference && ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $value->getInvalidBehavior()) { $services[] = (string) $value; } return $services; @@ -1305,7 +1305,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc foreach ($value as $v) { $services = \array_unique(\array_merge($services, self::getInitializedConditionals($v))); } - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference && \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $value->getInvalidBehavior()) { + } elseif ($value instanceof Reference && ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $value->getInvalidBehavior()) { $services[] = (string) $value; } return $services; @@ -1327,12 +1327,12 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc { $value = parent::getEnv($name); $bag = $this->getParameterBag(); - if (!\is_string($value) || !$bag instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag) { + if (!\is_string($value) || !$bag instanceof EnvPlaceholderParameterBag) { return $value; } $envPlaceholders = $bag->getEnvPlaceholders(); if (isset($envPlaceholders[$name][$value])) { - $bag = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag($bag->all()); + $bag = new ParameterBag($bag->all()); return $bag->unescapeValue($bag->get("env({$name})")); } foreach ($envPlaceholders as $env => $placeholders) { @@ -1358,7 +1358,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc } } foreach (self::getInitializedConditionals($call[1]) as $s) { - if (!$this->doGet($s, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE, $inlineServices)) { + if (!$this->doGet($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE, $inlineServices)) { return $service; } } @@ -1368,7 +1368,7 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc /** * @param mixed $service */ - private function shareService(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, $service, ?string $id, array &$inlineServices) + private function shareService(Definition $definition, $service, ?string $id, array &$inlineServices) { $inlineServices[$id ?? \spl_object_hash($definition)] = $service; if (null !== $id && $definition->isShared()) { @@ -1376,23 +1376,23 @@ class ContainerBuilder extends \RectorPrefix20220607\Symfony\Component\Dependenc unset($this->loading[$id]); } } - private function getExpressionLanguage() : \RectorPrefix20220607\Symfony\Component\DependencyInjection\ExpressionLanguage + private function getExpressionLanguage() : ExpressionLanguage { if (!isset($this->expressionLanguage)) { - if (!\class_exists(\RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression::class)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicException('Expressions cannot be used without the ExpressionLanguage component. Try running "composer require symfony/expression-language".'); + if (!\class_exists(Expression::class)) { + throw new LogicException('Expressions cannot be used without the ExpressionLanguage component. Try running "composer require symfony/expression-language".'); } - $this->expressionLanguage = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ExpressionLanguage(null, $this->expressionLanguageProviders, null, \Closure::fromCallable([$this, 'getEnv'])); + $this->expressionLanguage = new ExpressionLanguage(null, $this->expressionLanguageProviders, null, \Closure::fromCallable([$this, 'getEnv'])); } return $this->expressionLanguage; } private function inVendors(string $path) : bool { - $this->vendors = $this->vendors ?? (new \RectorPrefix20220607\Symfony\Component\Config\Resource\ComposerResource())->getVendors(); + $this->vendors = $this->vendors ?? (new ComposerResource())->getVendors(); $path = \realpath($path) ?: $path; foreach ($this->vendors as $vendor) { if (\strncmp($path, $vendor, \strlen($vendor)) === 0 && \false !== \strpbrk(\substr($path, \strlen($vendor), 1), '/' . \DIRECTORY_SEPARATOR)) { - $this->addResource(new \RectorPrefix20220607\Symfony\Component\Config\Resource\FileResource($vendor . '/composer/installed.json')); + $this->addResource(new FileResource($vendor . '/composer/installed.json')); return \true; } } diff --git a/vendor/symfony/dependency-injection/ContainerInterface.php b/vendor/symfony/dependency-injection/ContainerInterface.php index 61119eb157f..47a9ddcf7b2 100644 --- a/vendor/symfony/dependency-injection/ContainerInterface.php +++ b/vendor/symfony/dependency-injection/ContainerInterface.php @@ -20,7 +20,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\Service * @author Fabien Potencier * @author Johannes M. Schmitt */ -interface ContainerInterface extends \RectorPrefix20220607\Psr\Container\ContainerInterface +interface ContainerInterface extends PsrContainerInterface { public const RUNTIME_EXCEPTION_ON_INVALID_REFERENCE = 0; public const EXCEPTION_ON_INVALID_REFERENCE = 1; diff --git a/vendor/symfony/dependency-injection/Definition.php b/vendor/symfony/dependency-injection/Definition.php index cfd549566ab..0a816e3e544 100644 --- a/vendor/symfony/dependency-injection/Definition.php +++ b/vendor/symfony/dependency-injection/Definition.php @@ -154,7 +154,7 @@ class Definition $this->changes['factory'] = \true; if (\is_string($factory) && \strpos($factory, '::') !== \false) { $factory = \explode('::', $factory, 2); - } elseif ($factory instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + } elseif ($factory instanceof Reference) { $factory = [$factory, '__invoke']; } $this->factory = $factory; @@ -179,17 +179,17 @@ class Definition * * @throws InvalidArgumentException in case the decorated service id and the new decorated service id are equals */ - public function setDecoratedService(?string $id, string $renamedId = null, int $priority = 0, int $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) + public function setDecoratedService(?string $id, string $renamedId = null, int $priority = 0, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) { if ($renamedId && $id === $renamedId) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The decorated service inner name for "%s" must be different than the service name itself.', $id)); + throw new InvalidArgumentException(\sprintf('The decorated service inner name for "%s" must be different than the service name itself.', $id)); } $this->changes['decorated_service'] = \true; if (null === $id) { $this->decoratedService = null; } else { $this->decoratedService = [$id, $renamedId, $priority]; - if (\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { + if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { $this->decoratedService[] = $invalidBehavior; } } @@ -283,13 +283,13 @@ class Definition public function replaceArgument($index, $argument) { if (0 === \count($this->arguments)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\OutOfBoundsException(\sprintf('Cannot replace arguments for class "%s" if none have been configured yet.', $this->class)); + throw new OutOfBoundsException(\sprintf('Cannot replace arguments for class "%s" if none have been configured yet.', $this->class)); } if (\is_int($index) && ($index < 0 || $index > \count($this->arguments) - 1)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\OutOfBoundsException(\sprintf('The index "%d" is not in the range [0, %d] of the arguments of class "%s".', $index, \count($this->arguments) - 1, $this->class)); + throw new OutOfBoundsException(\sprintf('The index "%d" is not in the range [0, %d] of the arguments of class "%s".', $index, \count($this->arguments) - 1, $this->class)); } if (!\array_key_exists($index, $this->arguments)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\OutOfBoundsException(\sprintf('The argument "%s" doesn\'t exist in class "%s".', $index, $this->class)); + throw new OutOfBoundsException(\sprintf('The argument "%s" doesn\'t exist in class "%s".', $index, $this->class)); } $this->arguments[$index] = $argument; return $this; @@ -323,7 +323,7 @@ class Definition public function getArgument($index) { if (!\array_key_exists($index, $this->arguments)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\OutOfBoundsException(\sprintf('The argument "%s" doesn\'t exist in class "%s".', $index, $this->class)); + throw new OutOfBoundsException(\sprintf('The argument "%s" doesn\'t exist in class "%s".', $index, $this->class)); } return $this->arguments[$index]; } @@ -354,7 +354,7 @@ class Definition public function addMethodCall(string $method, array $arguments = [], bool $returnsClone = \false) { if (empty($method)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('Method name cannot be empty.'); + throw new InvalidArgumentException('Method name cannot be empty.'); } $this->calls[] = $returnsClone ? [$method, $arguments, \true] : [$method, $arguments]; return $this; @@ -625,10 +625,10 @@ class Definition { if ('' !== $message) { if (\preg_match('#[\\r\\n]|\\*/#', $message)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('Invalid characters found in deprecation template.'); + throw new InvalidArgumentException('Invalid characters found in deprecation template.'); } if (\strpos($message, '%service_id%') === \false) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('The deprecation template must contain the "%service_id%" placeholder.'); + throw new InvalidArgumentException('The deprecation template must contain the "%service_id%" placeholder.'); } } $this->changes['deprecated'] = \true; @@ -662,7 +662,7 @@ class Definition $this->changes['configurator'] = \true; if (\is_string($configurator) && \strpos($configurator, '::') !== \false) { $configurator = \explode('::', $configurator, 2); - } elseif ($configurator instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + } elseif ($configurator instanceof Reference) { $configurator = [$configurator, '__invoke']; } $this->configurator = $configurator; @@ -719,8 +719,8 @@ class Definition unset($bindings[$key]); $bindings[$key = $k] = $binding; } - if (!$binding instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\BoundArgument) { - $bindings[$key] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\BoundArgument($binding); + if (!$binding instanceof BoundArgument) { + $bindings[$key] = new BoundArgument($binding); } } $this->bindings = $bindings; diff --git a/vendor/symfony/dependency-injection/Dumper/Dumper.php b/vendor/symfony/dependency-injection/Dumper/Dumper.php index e4420b1dbd9..92345d187af 100644 --- a/vendor/symfony/dependency-injection/Dumper/Dumper.php +++ b/vendor/symfony/dependency-injection/Dumper/Dumper.php @@ -16,10 +16,10 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder; * * @author Fabien Potencier */ -abstract class Dumper implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Dumper\DumperInterface +abstract class Dumper implements DumperInterface { protected $container; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function __construct(ContainerBuilder $container) { $this->container = $container; } diff --git a/vendor/symfony/dependency-injection/Dumper/GraphvizDumper.php b/vendor/symfony/dependency-injection/Dumper/GraphvizDumper.php index f272939dc80..2c75ad1c1c3 100644 --- a/vendor/symfony/dependency-injection/Dumper/GraphvizDumper.php +++ b/vendor/symfony/dependency-injection/Dumper/GraphvizDumper.php @@ -26,7 +26,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference; * * @author Fabien Potencier */ -class GraphvizDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Dumper\Dumper +class GraphvizDumper extends Dumper { /** * @var mixed[] @@ -96,12 +96,12 @@ class GraphvizDumper extends \RectorPrefix20220607\Symfony\Component\DependencyI { $edges = []; foreach ($arguments as $argument) { - if ($argument instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Parameter) { + if ($argument instanceof Parameter) { $argument = $this->container->hasParameter($argument) ? $this->container->getParameter($argument) : null; } elseif (\is_string($argument) && \preg_match('/^%([^%]+)%$/', $argument, $match)) { $argument = $this->container->hasParameter($match[1]) ? $this->container->getParameter($match[1]) : null; } - if ($argument instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + if ($argument instanceof Reference) { $lazyEdge = $lazy; if (!$this->container->has((string) $argument)) { $this->nodes[(string) $argument] = ['name' => $name, 'required' => $required, 'class' => '', 'attributes' => $this->options['node.missing']]; @@ -109,9 +109,9 @@ class GraphvizDumper extends \RectorPrefix20220607\Symfony\Component\DependencyI $lazyEdge = $lazy || $this->container->getDefinition((string) $argument)->isLazy(); } $edges[] = [['name' => $name, 'required' => $required, 'to' => $argument, 'lazy' => $lazyEdge]]; - } elseif ($argument instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ArgumentInterface) { + } elseif ($argument instanceof ArgumentInterface) { $edges[] = $this->findEdges($id, $argument->getValues(), $required, $name, \true); - } elseif ($argument instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + } elseif ($argument instanceof Definition) { $edges[] = $this->findEdges($id, $argument->getArguments(), $required, ''); $edges[] = $this->findEdges($id, $argument->getProperties(), \false, ''); foreach ($argument->getMethodCalls() as $call) { @@ -134,10 +134,10 @@ class GraphvizDumper extends \RectorPrefix20220607\Symfony\Component\DependencyI } try { $class = $this->container->getParameterBag()->resolveValue($class); - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException $exception) { + } catch (ParameterNotFoundException $exception) { } $nodes[$id] = ['class' => \str_replace('\\', '\\\\', $class), 'attributes' => \array_merge($this->options['node.definition'], ['style' => $definition->isShared() ? 'filled' : 'dotted'])]; - $container->setDefinition($id, new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition('stdClass')); + $container->setDefinition($id, new Definition('stdClass')); } foreach ($container->getServiceIds() as $id) { if (\array_key_exists($id, $container->getAliases())) { @@ -149,10 +149,10 @@ class GraphvizDumper extends \RectorPrefix20220607\Symfony\Component\DependencyI } return $nodes; } - private function cloneContainer() : \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder + private function cloneContainer() : ContainerBuilder { - $parameterBag = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag($this->container->getParameterBag()->all()); - $container = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder($parameterBag); + $parameterBag = new ParameterBag($this->container->getParameterBag()->all()); + $container = new ContainerBuilder($parameterBag); $container->setDefinitions($this->container->getDefinitions()); $container->setAliases($this->container->getAliases()); $container->setResources($this->container->getResources()); diff --git a/vendor/symfony/dependency-injection/Dumper/PhpDumper.php b/vendor/symfony/dependency-injection/Dumper/PhpDumper.php index 6f4612471f7..90187da7e53 100644 --- a/vendor/symfony/dependency-injection/Dumper/PhpDumper.php +++ b/vendor/symfony/dependency-injection/Dumper/PhpDumper.php @@ -48,7 +48,7 @@ use RectorPrefix20220607\Symfony\Component\HttpKernel\Kernel; * @author Fabien Potencier * @author Johannes M. Schmitt */ -class PhpDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Dumper\Dumper +class PhpDumper extends Dumper { /** * Characters that might appear in the generated variable name as first character. @@ -171,17 +171,17 @@ class PhpDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInject /** * {@inheritdoc} */ - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function __construct(ContainerBuilder $container) { if (!$container->isCompiled()) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicException('Cannot dump an uncompiled container.'); + throw new LogicException('Cannot dump an uncompiled container.'); } parent::__construct($container); } /** * Sets the dumper to be used when dumping proxies in the generated container. */ - public function setProxyDumper(\RectorPrefix20220607\Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface $proxyDumper) + public function setProxyDumper(ProxyDumper $proxyDumper) { $this->proxyDumper = $proxyDumper; } @@ -218,20 +218,20 @@ class PhpDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInject $baseClass = \sprintf('%s\\%s', $options['namespace'] ? '\\' . $options['namespace'] : '', $baseClass); $this->baseClass = $baseClass; } elseif ('Container' === $baseClass) { - $this->baseClass = \RectorPrefix20220607\Symfony\Component\DependencyInjection\Container::class; + $this->baseClass = Container::class; } else { $this->baseClass = $baseClass; } - $this->initializeMethodNamesMap('Container' === $baseClass ? \RectorPrefix20220607\Symfony\Component\DependencyInjection\Container::class : $baseClass); - if ($this->getProxyDumper() instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\NullDumper) { - (new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass(\true, \false))->process($this->container); + $this->initializeMethodNamesMap('Container' === $baseClass ? Container::class : $baseClass); + if ($this->getProxyDumper() instanceof NullDumper) { + (new AnalyzeServiceReferencesPass(\true, \false))->process($this->container); try { - (new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CheckCircularReferencesPass())->process($this->container); - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException $e) { + (new CheckCircularReferencesPass())->process($this->container); + } catch (ServiceCircularReferenceException $e) { $path = $e->getPath(); \end($path); $path[\key($path)] .= '". Try running "composer require symfony/proxy-manager-bridge'; - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException($e->getServiceId(), $path); + throw new ServiceCircularReferenceException($e->getServiceId(), $path); } } $this->analyzeReferences(); @@ -314,7 +314,7 @@ EOF; } } $files[$options['class'] . '.php'] = $code; - $hash = \ucfirst(\strtr(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder::hash($files), '._', 'xx')); + $hash = \ucfirst(\strtr(ContainerBuilder::hash($files), '._', 'xx')); $code = []; foreach ($files as $file => $c) { $code["Container{$hash}/{$file}"] = \substr_replace($c, "proxyDumper = $this->proxyDumper ?? new \RectorPrefix20220607\Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\NullDumper(); + return $this->proxyDumper = $this->proxyDumper ?? new NullDumper(); } private function analyzeReferences() { - (new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass(\false, !$this->getProxyDumper() instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\NullDumper))->process($this->container); + (new AnalyzeServiceReferencesPass(\false, !$this->getProxyDumper() instanceof NullDumper))->process($this->container); $checkedNodes = []; $this->circularReferences = []; $this->singleUsePrivateIds = []; foreach ($this->container->getCompiler()->getServiceReferenceGraph()->getNodes() as $id => $node) { - if (!$node->getValue() instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + if (!$node->getValue() instanceof Definition) { continue; } if ($this->isSingleUsePrivateNode($node)) { @@ -443,7 +443,7 @@ EOF; foreach ($edges as $edge) { $node = $edge->getDestNode(); $id = $node->getId(); - if ($sourceId === $id || !$node->getValue() instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition || $edge->isLazy() || $edge->isWeak()) { + if ($sourceId === $id || !$node->getValue() instanceof Definition || $edge->isLazy() || $edge->isWeak()) { continue; } if (isset($path[$id])) { @@ -546,7 +546,7 @@ EOF; $proxyClasses = []; $alreadyGenerated = []; $definitions = $this->container->getDefinitions(); - $strip = '' === $this->docStar && \method_exists(\RectorPrefix20220607\Symfony\Component\HttpKernel\Kernel::class, 'stripComments'); + $strip = '' === $this->docStar && \method_exists(Kernel::class, 'stripComments'); $proxyDumper = $this->getProxyDumper(); \ksort($definitions); foreach ($definitions as $definition) { @@ -576,7 +576,7 @@ EOF; } if ($strip) { $proxyCode = "inlineRequires ? \substr($proxyCode, \strlen($code)) : $proxyCode, 3)[1]; if ($this->asFiles || $this->namespace) { @@ -586,7 +586,7 @@ EOF; } return $proxyClasses; } - private function addServiceInclude(string $cId, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) : string + private function addServiceInclude(string $cId, Definition $definition) : string { $code = ''; if ($this->inlineRequires && (!$this->isHotPath($definition) || $this->getProxyDumper()->isProxyCandidate($definition))) { @@ -599,7 +599,7 @@ EOF; } } foreach ($this->serviceCalls as $id => [$callCount, $behavior]) { - if ('service_container' !== $id && $id !== $cId && \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE !== $behavior && $this->container->has($id) && $this->isTrivialInstance($def = $this->container->findDefinition($id))) { + if ('service_container' !== $id && $id !== $cId && ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE !== $behavior && $this->container->has($id) && $this->isTrivialInstance($def = $this->container->findDefinition($id))) { foreach ($this->getClasses($def, $cId) as $class) { $this->collectLineage($class, $lineage); } @@ -625,11 +625,11 @@ EOF; * @throws InvalidArgumentException * @throws RuntimeException */ - private function addServiceInstance(string $id, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, bool $isSimpleInstance) : string + private function addServiceInstance(string $id, Definition $definition, bool $isSimpleInstance) : string { $class = $this->dumpValue($definition->getClass()); if (\strncmp($class, "'", \strlen("'")) === 0 && \strpos($class, '$') === \false && !\preg_match('/^\'(?:\\\\{2})?[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*(?:\\\\{2}[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)*\'$/', $class)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('"%s" is not a valid class name for the "%s" service.', $class, $id)); + throw new InvalidArgumentException(\sprintf('"%s" is not a valid class name for the "%s" service.', $class, $id)); } $isProxyCandidate = $this->getProxyDumper()->isProxyCandidate($definition); $instantiation = ''; @@ -652,7 +652,7 @@ EOF; } return $this->addNewInstance($definition, ' ' . $return . $instantiation, $id); } - private function isTrivialInstance(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) : bool + private function isTrivialInstance(Definition $definition) : bool { if ($definition->hasErrors()) { return \true; @@ -664,7 +664,7 @@ EOF; return \false; } foreach ($definition->getArguments() as $arg) { - if (!$arg || $arg instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Parameter) { + if (!$arg || $arg instanceof Parameter) { continue; } if (\is_array($arg) && 3 >= \count($arg)) { @@ -672,17 +672,17 @@ EOF; if ($this->dumpValue($k) !== $this->dumpValue($k, \false)) { return \false; } - if (!$v || $v instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Parameter) { + if (!$v || $v instanceof Parameter) { continue; } - if ($v instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference && $this->container->has($id = (string) $v) && $this->container->findDefinition($id)->isSynthetic()) { + if ($v instanceof Reference && $this->container->has($id = (string) $v) && $this->container->findDefinition($id)->isSynthetic()) { continue; } if (!\is_scalar($v) || $this->dumpValue($v) !== $this->dumpValue($v, \false)) { return \false; } } - } elseif ($arg instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference && $this->container->has($id = (string) $arg) && $this->container->findDefinition($id)->isSynthetic()) { + } elseif ($arg instanceof Reference && $this->container->has($id = (string) $arg) && $this->container->findDefinition($id)->isSynthetic()) { continue; } elseif (!\is_scalar($arg) || $this->dumpValue($arg) !== $this->dumpValue($arg, \false)) { return \false; @@ -690,7 +690,7 @@ EOF; } return \true; } - private function addServiceMethodCalls(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, string $variableName, ?string $sharedNonLazyId) : string + private function addServiceMethodCalls(Definition $definition, string $variableName, ?string $sharedNonLazyId) : string { $lastWitherIndex = null; foreach ($definition->getMethodCalls() as $k => $call) { @@ -715,7 +715,7 @@ EOF; } return $calls; } - private function addServiceProperties(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, string $variableName = 'instance') : string + private function addServiceProperties(Definition $definition, string $variableName = 'instance') : string { $code = ''; foreach ($definition->getProperties() as $name => $value) { @@ -723,13 +723,13 @@ EOF; } return $code; } - private function addServiceConfigurator(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, string $variableName = 'instance') : string + private function addServiceConfigurator(Definition $definition, string $variableName = 'instance') : string { if (!($callable = $definition->getConfigurator())) { return ''; } if (\is_array($callable)) { - if ($callable[0] instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference || $callable[0] instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition && $this->definitionVariables->contains($callable[0])) { + if ($callable[0] instanceof Reference || $callable[0] instanceof Definition && $this->definitionVariables->contains($callable[0])) { return \sprintf(" %s->%s(\$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName); } $class = $this->dumpValue($callable[0]); @@ -744,23 +744,23 @@ EOF; } return \sprintf(" %s(\$%s);\n", $callable, $variableName); } - private function addService(string $id, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) : array + private function addService(string $id, Definition $definition) : array { $this->definitionVariables = new \SplObjectStorage(); $this->referenceVariables = []; $this->variableCount = 0; - $this->referenceVariables[$id] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Variable('instance'); + $this->referenceVariables[$id] = new Variable('instance'); $return = []; if ($class = $definition->getClass()) { - $class = $class instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Parameter ? '%' . $class . '%' : $this->container->resolveEnvPlaceholders($class); + $class = $class instanceof Parameter ? '%' . $class . '%' : $this->container->resolveEnvPlaceholders($class); $return[] = \sprintf(\strncmp($class, '%', \strlen('%')) === 0 ? '@return object A %1$s instance' : '@return \\%s', \ltrim($class, '\\')); } elseif ($definition->getFactory()) { $factory = $definition->getFactory(); if (\is_string($factory) && \strncmp($factory, '@=', \strlen('@=')) !== 0) { $return[] = \sprintf('@return object An instance returned by %s()', $factory); - } elseif (\is_array($factory) && (\is_string($factory[0]) || $factory[0] instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition || $factory[0] instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference)) { - $class = $factory[0] instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition ? $factory[0]->getClass() : (string) $factory[0]; - $class = $class instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Parameter ? '%' . $class . '%' : $this->container->resolveEnvPlaceholders($class); + } elseif (\is_array($factory) && (\is_string($factory[0]) || $factory[0] instanceof Definition || $factory[0] instanceof Reference)) { + $class = $factory[0] instanceof Definition ? $factory[0]->getClass() : (string) $factory[0]; + $class = $class instanceof Parameter ? '%' . $class . '%' : $this->container->resolveEnvPlaceholders($class); $return[] = \sprintf('@return object An instance returned by %s::%s()', $class, $factory[1]); } } @@ -868,21 +868,21 @@ EOF; $this->referenceVariables = $this->serviceCalls = null; return [$file, $code]; } - private function addInlineVariables(string $id, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, array $arguments, bool $forConstructor) : string + private function addInlineVariables(string $id, Definition $definition, array $arguments, bool $forConstructor) : string { $code = ''; foreach ($arguments as $argument) { if (\is_array($argument)) { $code .= $this->addInlineVariables($id, $definition, $argument, $forConstructor); - } elseif ($argument instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + } elseif ($argument instanceof Reference) { $code .= $this->addInlineReference($id, $definition, $argument, $forConstructor); - } elseif ($argument instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + } elseif ($argument instanceof Definition) { $code .= $this->addInlineService($id, $definition, $argument, $forConstructor); } } return $code; } - private function addInlineReference(string $id, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, string $targetId, bool $forConstructor) : string + private function addInlineReference(string $id, Definition $definition, string $targetId, bool $forConstructor) : string { while ($this->container->hasAlias($targetId)) { $targetId = (string) $this->container->getAlias($targetId); @@ -907,8 +907,8 @@ EOF; return $code; } $name = $this->getNextVariableName(); - $this->referenceVariables[$targetId] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Variable($name); - $reference = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE >= $behavior ? new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($targetId, $behavior) : null; + $this->referenceVariables[$targetId] = new Variable($name); + $reference = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE >= $behavior ? new Reference($targetId, $behavior) : null; $code .= \sprintf(" \$%s = %s;\n", $name, $this->getServiceCall($targetId, $reference)); if (!$hasSelfRef || !$forConstructor) { return $code; @@ -923,7 +923,7 @@ EOTXT , $this->container->getDefinition($id)->isPublic() ? 'services' : 'privates', $this->doExport($id)); return $code; } - private function addInlineService(string $id, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $inlineDef = null, bool $forConstructor = \true) : string + private function addInlineService(string $id, Definition $definition, Definition $inlineDef = null, bool $forConstructor = \true) : string { $code = ''; if ($isSimpleInstance = $isRootInstance = null === $inlineDef) { @@ -947,7 +947,7 @@ EOTXT $isSimpleInstance = \false; } else { $name = $definition === $inlineDef ? 'instance' : $this->getNextVariableName(); - $this->definitionVariables[$inlineDef] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Variable($name); + $this->definitionVariables[$inlineDef] = new Variable($name); $code .= '' !== $code ? "\n" : ''; if ('instance' === $name) { $code .= $this->addServiceInstance($id, $definition, $isSimpleInstance); @@ -1005,15 +1005,15 @@ EOTXT } } } - private function addNewInstance(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, string $return = '', string $id = null) : string + private function addNewInstance(Definition $definition, string $return = '', string $id = null) : string { $tail = $return ? ";\n" : ''; - if (\RectorPrefix20220607\Symfony\Component\DependencyInjection\ServiceLocator::class === $definition->getClass() && $definition->hasTag($this->serviceLocatorTag)) { + if (BaseServiceLocator::class === $definition->getClass() && $definition->hasTag($this->serviceLocatorTag)) { $arguments = []; foreach ($definition->getArgument(0) as $k => $argument) { $arguments[$k] = $argument->getValues()[0]; } - return $return . $this->dumpValue(new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument($arguments)) . $tail; + return $return . $this->dumpValue(new ServiceLocatorArgument($arguments)) . $tail; } $arguments = []; foreach ($definition->getArguments() as $i => $value) { @@ -1024,22 +1024,22 @@ EOTXT if (['Closure', 'fromCallable'] === $callable && [0] === \array_keys($definition->getArguments())) { $callable = $definition->getArgument(0); $arguments = ['...']; - if ($callable instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference || $callable instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + if ($callable instanceof Reference || $callable instanceof Definition) { $callable = [$callable, '__invoke']; } } if (\is_array($callable)) { if (!\preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/', $callable[1])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Cannot dump definition because of invalid factory method (%s).', $callable[1] ?: 'n/a')); + throw new RuntimeException(\sprintf('Cannot dump definition because of invalid factory method (%s).', $callable[1] ?: 'n/a')); } - if ($callable[0] instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference || $callable[0] instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition && $this->definitionVariables->contains($callable[0])) { + if ($callable[0] instanceof Reference || $callable[0] instanceof Definition && $this->definitionVariables->contains($callable[0])) { return $return . \sprintf('%s->%s(%s)', $this->dumpValue($callable[0]), $callable[1], $arguments ? \implode(', ', $arguments) : '') . $tail; } $class = $this->dumpValue($callable[0]); // If the class is a string we can optimize away if (\strncmp($class, "'", \strlen("'")) === 0 && \strpos($class, '$') === \false) { if ("''" === $class) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Cannot dump definition: "%s" service is defined to be created by a factory but is missing the service reference, did you forget to define the factory service id or class?', $id ? 'The "' . $id . '"' : 'inline')); + throw new RuntimeException(\sprintf('Cannot dump definition: "%s" service is defined to be created by a factory but is missing the service reference, did you forget to define the factory service id or class?', $id ? 'The "' . $id . '"' : 'inline')); } return $return . \sprintf('%s::%s(%s)', $this->dumpLiteralClass($class), $callable[1], $arguments ? \implode(', ', $arguments) : '') . $tail; } @@ -1049,12 +1049,12 @@ EOTXT return $return . \sprintf("[%s, '%s'](%s)", $class, $callable[1], $arguments ? \implode(', ', $arguments) : '') . $tail; } if (\is_string($callable) && \strncmp($callable, '@=', \strlen('@=')) === 0) { - return $return . \sprintf('(($args = %s) ? (%s) : null)', $this->dumpValue(new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument($definition->getArguments())), $this->getExpressionLanguage()->compile(\substr($callable, 2), ['this' => 'container', 'args' => 'args'])) . $tail; + return $return . \sprintf('(($args = %s) ? (%s) : null)', $this->dumpValue(new ServiceLocatorArgument($definition->getArguments())), $this->getExpressionLanguage()->compile(\substr($callable, 2), ['this' => 'container', 'args' => 'args'])) . $tail; } return $return . \sprintf('%s(%s)', $this->dumpLiteralClass($this->dumpValue($callable)), $arguments ? \implode(', ', $arguments) : '') . $tail; } if (null === ($class = $definition->getClass())) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException('Cannot dump definitions which have no class nor factory.'); + throw new RuntimeException('Cannot dump definitions which have no class nor factory.'); } return $return . \sprintf('new %s(%s)', $this->dumpLiteralClass($this->dumpValue($class)), \implode(', ', $arguments)) . $tail; } @@ -1094,9 +1094,9 @@ EOF; $code .= ' $this->targetDir = \\dirname($containerDir);' . "\n"; } } - if (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Container::class !== $this->baseClass) { + if (Container::class !== $this->baseClass) { $r = $this->container->getReflectionClass($this->baseClass, \false); - if (null !== $r && null !== ($constructor = $r->getConstructor()) && 0 === $constructor->getNumberOfRequiredParameters() && \RectorPrefix20220607\Symfony\Component\DependencyInjection\Container::class !== $constructor->getDeclaringClass()->name) { + if (null !== $r && null !== ($constructor = $r->getConstructor()) && 0 === $constructor->getNumberOfRequiredParameters() && Container::class !== $constructor->getDeclaringClass()->name) { $code .= " parent::__construct();\n"; $code .= " \$this->parameterBag = null;\n\n"; } @@ -1199,7 +1199,7 @@ EOF; $ids = \array_keys($ids); \sort($ids); foreach ($ids as $id) { - if (\preg_match(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\FileLoader::ANONYMOUS_ID_REGEXP, $id)) { + if (\preg_match(FileLoader::ANONYMOUS_ID_REGEXP, $id)) { continue; } $code .= ' ' . $this->doExport($id) . " => true,\n"; @@ -1336,7 +1336,7 @@ EOF; $dynamicPhp = []; foreach ($this->container->getParameterBag()->all() as $key => $value) { if ($key !== ($resolvedKey = $this->container->resolveEnvPlaceholders($key))) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Parameter name cannot use env parameters: "%s".', $resolvedKey)); + throw new InvalidArgumentException(\sprintf('Parameter name cannot use env parameters: "%s".', $resolvedKey)); } $hasEnum = \false; $export = $this->exportParameters([$value], '', 12, $hasEnum); @@ -1443,17 +1443,17 @@ EOF; foreach ($parameters as $key => $value) { if (\is_array($value)) { $value = $this->exportParameters($value, $path . '/' . $key, $indent + 4, $hasEnum); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ArgumentInterface) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('You cannot dump a container with parameters that contain special arguments. "%s" found in "%s".', \get_debug_type($value), $path . '/' . $key)); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Variable) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('You cannot dump a container with parameters that contain variable references. Variable "%s" found in "%s".', $value, $path . '/' . $key)); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('You cannot dump a container with parameters that contain service definitions. Definition for "%s" found in "%s".', $value->getClass(), $path . '/' . $key)); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('You cannot dump a container with parameters that contain references to other services (reference to service "%s" found in "%s").', $value, $path . '/' . $key)); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('You cannot dump a container with parameters that contain expressions. Expression "%s" found in "%s".', $value, $path . '/' . $key)); - } elseif ($value instanceof \RectorPrefix20220607\UnitEnum) { + } elseif ($value instanceof ArgumentInterface) { + throw new InvalidArgumentException(\sprintf('You cannot dump a container with parameters that contain special arguments. "%s" found in "%s".', \get_debug_type($value), $path . '/' . $key)); + } elseif ($value instanceof Variable) { + throw new InvalidArgumentException(\sprintf('You cannot dump a container with parameters that contain variable references. Variable "%s" found in "%s".', $value, $path . '/' . $key)); + } elseif ($value instanceof Definition) { + throw new InvalidArgumentException(\sprintf('You cannot dump a container with parameters that contain service definitions. Definition for "%s" found in "%s".', $value->getClass(), $path . '/' . $key)); + } elseif ($value instanceof Reference) { + throw new InvalidArgumentException(\sprintf('You cannot dump a container with parameters that contain references to other services (reference to service "%s" found in "%s").', $value, $path . '/' . $key)); + } elseif ($value instanceof Expression) { + throw new InvalidArgumentException(\sprintf('You cannot dump a container with parameters that contain expressions. Expression "%s" found in "%s".', $value, $path . '/' . $key)); + } elseif ($value instanceof \UnitEnum) { $hasEnum = \true; $value = \sprintf('\\%s::%s', \get_class($value), $value->name); } else { @@ -1490,13 +1490,13 @@ EOF; private function getServiceConditionals($value) : string { $conditions = []; - foreach (\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder::getInitializedConditionals($value) as $service) { + foreach (ContainerBuilder::getInitializedConditionals($value) as $service) { if (!$this->container->hasDefinition($service)) { return 'false'; } $conditions[] = \sprintf('isset($this->%s[%s])', $this->container->getDefinition($service)->isPublic() ? 'services' : 'privates', $this->doExport($service)); } - foreach (\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder::getServiceConditionals($value) as $service) { + foreach (ContainerBuilder::getServiceConditionals($value) as $service) { if ($this->container->hasDefinition($service) && !$this->container->getDefinition($service)->isPublic()) { continue; } @@ -1515,7 +1515,7 @@ EOF; foreach ($arguments as $argument) { if (\is_array($argument)) { $this->getDefinitionsFromArguments($argument, $definitions, $calls, $byConstructor); - } elseif ($argument instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + } elseif ($argument instanceof Reference) { $id = (string) $argument; while ($this->container->hasAlias($id)) { $id = (string) $this->container->getAlias($id); @@ -1526,7 +1526,7 @@ EOF; $calls[$id][1] = \min($calls[$id][1], $argument->getInvalidBehavior()); } ++$calls[$id][0]; - } elseif (!$argument instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + } elseif (!$argument instanceof Definition) { // no-op } elseif (isset($definitions[$argument])) { $definitions[$argument] = 1 + $definitions[$argument]; @@ -1555,20 +1555,20 @@ EOF; $code[] = \sprintf('%s => %s', $this->dumpValue($k, $interpolate), $this->dumpValue($v, $interpolate)); } return \sprintf('[%s]', \implode(', ', $code)); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ArgumentInterface) { + } elseif ($value instanceof ArgumentInterface) { $scope = [$this->definitionVariables, $this->referenceVariables]; $this->definitionVariables = $this->referenceVariables = null; try { - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument) { + if ($value instanceof ServiceClosureArgument) { $value = $value->getValues()[0]; $code = $this->dumpValue($value, $interpolate); $returnedType = ''; - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference) { - $returnedType = \sprintf(': %s\\%s', \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE >= $value->getInvalidBehavior() ? '' : '?', \str_replace(['|', '&'], ['|\\', '&\\'], $value->getType())); + if ($value instanceof TypedReference) { + $returnedType = \sprintf(': %s\\%s', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE >= $value->getInvalidBehavior() ? '' : '?', \str_replace(['|', '&'], ['|\\', '&\\'], $value->getType())); } $code = \sprintf('return %s;', $code); $attribute = ''; - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + if ($value instanceof Reference) { $attribute = 'name: ' . $this->dumpValue((string) $value, $interpolate); if ($this->container->hasDefinition($value) && ($class = $this->container->findDefinition($value)->getClass()) && $class !== (string) $value) { $attribute .= ', class: ' . $this->dumpValue($class, $interpolate); @@ -1577,7 +1577,7 @@ EOF; } return \sprintf("%sfunction ()%s {\n %s\n }", $attribute, $returnedType, $code); } - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\IteratorArgument) { + if ($value instanceof IteratorArgument) { $operands = [0]; $code = []; $code[] = 'new RewindableGenerator(function () {'; @@ -1601,11 +1601,11 @@ EOF; $code[] = \sprintf(' }, %s)', \count($operands) > 1 ? \implode("\n", $countCode) : $operands[0]); return \implode("\n", $code); } - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument) { + if ($value instanceof ServiceLocatorArgument) { $serviceMap = ''; $serviceTypes = ''; foreach ($value->getValues() as $k => $v) { - if (!$v instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + if (!$v instanceof Reference) { $serviceMap .= \sprintf("\n %s => [%s],", $this->export($k), $this->dumpValue($v)); $serviceTypes .= \sprintf("\n %s => '?',", $this->export($k)); continue; @@ -1616,17 +1616,17 @@ EOF; } $definition = $this->container->getDefinition($id); $load = !($definition->hasErrors() && ($e = $definition->getErrors())) ? $this->asFiles && !$this->inlineFactories && !$this->isHotPath($definition) : \reset($e); - $serviceMap .= \sprintf("\n %s => [%s, %s, %s, %s],", $this->export($k), $this->export($definition->isShared() ? $definition->isPublic() ? 'services' : 'privates' : \false), $this->doExport($id), $this->export(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE !== $v->getInvalidBehavior() && !\is_string($load) ? $this->generateMethodName($id) : null), $this->export($load)); - $serviceTypes .= \sprintf("\n %s => %s,", $this->export($k), $this->export($v instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\TypedReference ? $v->getType() : '?')); + $serviceMap .= \sprintf("\n %s => [%s, %s, %s, %s],", $this->export($k), $this->export($definition->isShared() ? $definition->isPublic() ? 'services' : 'privates' : \false), $this->doExport($id), $this->export(ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE !== $v->getInvalidBehavior() && !\is_string($load) ? $this->generateMethodName($id) : null), $this->export($load)); + $serviceTypes .= \sprintf("\n %s => %s,", $this->export($k), $this->export($v instanceof TypedReference ? $v->getType() : '?')); $this->locatedIds[$id] = \true; } $this->addGetService = \true; - return \sprintf('new \\%s($this->getService, [%s%s], [%s%s])', \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocator::class, $serviceMap, $serviceMap ? "\n " : '', $serviceTypes, $serviceTypes ? "\n " : ''); + return \sprintf('new \\%s($this->getService, [%s%s], [%s%s])', ServiceLocator::class, $serviceMap, $serviceMap ? "\n " : '', $serviceTypes, $serviceTypes ? "\n " : ''); } } finally { [$this->definitionVariables, $this->referenceVariables] = $scope; } - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + } elseif ($value instanceof Definition) { if ($value->hasErrors() && ($e = $value->getErrors())) { return \sprintf('throw new RuntimeException(%s)', $this->export(\reset($e))); } @@ -1634,18 +1634,18 @@ EOF; return $this->dumpValue($this->definitionVariables[$value], $interpolate); } if ($value->getMethodCalls()) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException('Cannot dump definitions which have method calls.'); + throw new RuntimeException('Cannot dump definitions which have method calls.'); } if ($value->getProperties()) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException('Cannot dump definitions which have properties.'); + throw new RuntimeException('Cannot dump definitions which have properties.'); } if (null !== $value->getConfigurator()) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException('Cannot dump definitions which have a configurator.'); + throw new RuntimeException('Cannot dump definitions which have a configurator.'); } return $this->addNewInstance($value); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Variable) { + } elseif ($value instanceof Variable) { return '$' . $value; - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + } elseif ($value instanceof Reference) { $id = (string) $value; while ($this->container->hasAlias($id)) { $id = (string) $this->container->getAlias($id); @@ -1654,9 +1654,9 @@ EOF; return $this->dumpValue($this->referenceVariables[$id], $interpolate); } return $this->getServiceCall($id, $value); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression) { + } elseif ($value instanceof Expression) { return $this->getExpressionLanguage()->compile((string) $value, ['this' => 'container']); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Parameter) { + } elseif ($value instanceof Parameter) { return $this->dumpParameter($value); } elseif (\true === $interpolate && \is_string($value)) { if (\preg_match('/^%([^%]+)%$/', $value, $match)) { @@ -1670,12 +1670,12 @@ EOF; $code = \str_replace('%%', '%', \preg_replace_callback('/(?export($value))); return $code; } - } elseif ($value instanceof \RectorPrefix20220607\UnitEnum) { + } elseif ($value instanceof \UnitEnum) { return \sprintf('\\%s::%s', \get_class($value), $value->name); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\AbstractArgument) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException($value->getTextWithContext()); + } elseif ($value instanceof AbstractArgument) { + throw new RuntimeException($value->getTextWithContext()); } elseif (\is_object($value) || \is_resource($value)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException('Unable to dump a service container if a parameter is an object or a resource.'); + throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.'); } return $this->export($value); } @@ -1690,7 +1690,7 @@ EOF; return \sprintf('${($_ = %s) && false ?: "_"}', $class); } if (\strncmp($class, "'", \strlen("'")) !== 0 || !\preg_match('/^\'(?:\\\\{2})?[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*(?:\\\\{2}[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)*\'$/', $class)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Cannot dump definition because of invalid class name (%s).', $class ?: 'n/a')); + throw new RuntimeException(\sprintf('Cannot dump definition because of invalid class name (%s).', $class ?: 'n/a')); } $class = \substr(\str_replace('\\\\', '\\', $class), 1, -1); return \strncmp($class, '\\', \strlen('\\')) === 0 ? $class : '\\' . $class; @@ -1709,7 +1709,7 @@ EOF; } return \sprintf('$this->getParameter(%s)', $this->doExport($name)); } - private function getServiceCall(string $id, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference $reference = null) : string + private function getServiceCall(string $id, Reference $reference = null) : string { while ($this->container->hasAlias($id)) { $id = (string) $this->container->getAlias($id); @@ -1720,7 +1720,7 @@ EOF; if ($this->container->hasDefinition($id) && ($definition = $this->container->getDefinition($id))) { if ($definition->isSynthetic()) { $code = \sprintf('$this->get(%s%s)', $this->doExport($id), null !== $reference ? ', ' . $reference->getInvalidBehavior() : ''); - } elseif (null !== $reference && \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $reference->getInvalidBehavior()) { + } elseif (null !== $reference && ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $reference->getInvalidBehavior()) { $code = 'null'; if (!$definition->isShared()) { return $code; @@ -1747,10 +1747,10 @@ EOF; } return $code; } - if (null !== $reference && \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $reference->getInvalidBehavior()) { + if (null !== $reference && ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $reference->getInvalidBehavior()) { return 'null'; } - if (null !== $reference && \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE < $reference->getInvalidBehavior()) { + if (null !== $reference && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE < $reference->getInvalidBehavior()) { $code = \sprintf('$this->get(%s, ContainerInterface::NULL_ON_INVALID_REFERENCE)', $this->doExport($id)); } else { $code = \sprintf('$this->get(%s)', $this->doExport($id)); @@ -1779,7 +1779,7 @@ EOF; return $this->serviceIdToMethodNameMap[$id]; } $i = \strrpos($id, '\\'); - $name = \RectorPrefix20220607\Symfony\Component\DependencyInjection\Container::camelize(\false !== $i && isset($id[1 + $i]) ? \substr($id, 1 + $i) : $id); + $name = Container::camelize(\false !== $i && isset($id[1 + $i]) ? \substr($id, 1 + $i) : $id); $name = \preg_replace('/[^a-zA-Z0-9_\\x7f-\\xff]/', '', $name); $methodName = 'get' . $name . 'Service'; $suffix = 1; @@ -1817,14 +1817,14 @@ EOF; return $name; } } - private function getExpressionLanguage() : \RectorPrefix20220607\Symfony\Component\DependencyInjection\ExpressionLanguage + private function getExpressionLanguage() : ExpressionLanguage { if (!isset($this->expressionLanguage)) { if (!\class_exists(\RectorPrefix20220607\Symfony\Component\ExpressionLanguage\ExpressionLanguage::class)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); + throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); } $providers = $this->container->getExpressionLanguageProviders(); - $this->expressionLanguage = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ExpressionLanguage(null, $providers, function ($arg) { + $this->expressionLanguage = new ExpressionLanguage(null, $providers, function ($arg) { $id = '""' === \substr_replace($arg, '', 1, -1) ? \stripcslashes(\substr($arg, 1, -1)) : null; if (null !== $id && ($this->container->hasAlias($id) || $this->container->hasDefinition($id))) { return $this->getServiceCall($id); @@ -1839,11 +1839,11 @@ EOF; } return $this->expressionLanguage; } - private function isHotPath(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) : bool + private function isHotPath(Definition $definition) : bool { return $this->hotPathTag && $definition->hasTag($this->hotPathTag) && !$definition->isDeprecated(); } - private function isSingleUsePrivateNode(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraphNode $node) : bool + private function isSingleUsePrivateNode(ServiceReferenceGraphNode $node) : bool { if ($node->getValue()->isPublic()) { return \false; @@ -1853,7 +1853,7 @@ EOF; if (!($value = $edge->getSourceNode()->getValue())) { continue; } - if ($edge->isLazy() || !$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition || !$value->isShared()) { + if ($edge->isLazy() || !$value instanceof Definition || !$value->isShared()) { return \false; } $ids[$edge->getSourceNode()->getId()] = \true; @@ -1943,10 +1943,10 @@ EOF; if (!\is_array($autoloader)) { continue; } - if ($autoloader[0] instanceof \RectorPrefix20220607\Symfony\Component\ErrorHandler\DebugClassLoader || $autoloader[0] instanceof \RectorPrefix20220607\Symfony\Component\Debug\DebugClassLoader) { + if ($autoloader[0] instanceof DebugClassLoader || $autoloader[0] instanceof LegacyDebugClassLoader) { $autoloader = $autoloader[0]->getClassLoader(); } - if (!\is_array($autoloader) || !$autoloader[0] instanceof \RectorPrefix20220607\Composer\Autoload\ClassLoader || !$autoloader[0]->findFile(__CLASS__)) { + if (!\is_array($autoloader) || !$autoloader[0] instanceof ClassLoader || !$autoloader[0]->findFile(__CLASS__)) { continue; } foreach (\get_declared_classes() as $class) { @@ -1960,13 +1960,13 @@ EOF; } return $file; } - private function getClasses(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, string $id) : array + private function getClasses(Definition $definition, string $id) : array { $classes = []; - while ($definition instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + while ($definition instanceof Definition) { foreach ($definition->getTag($this->preloadTags[0]) as $tag) { if (!isset($tag['class'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Missing attribute "class" on tag "%s" for service "%s".', $this->preloadTags[0], $id)); + throw new InvalidArgumentException(\sprintf('Missing attribute "class" on tag "%s" for service "%s".', $this->preloadTags[0], $id)); } $classes[] = \trim($tag['class'], '\\'); } diff --git a/vendor/symfony/dependency-injection/Dumper/Preloader.php b/vendor/symfony/dependency-injection/Dumper/Preloader.php index d4c4f3eb91b..7764adf079d 100644 --- a/vendor/symfony/dependency-injection/Dumper/Preloader.php +++ b/vendor/symfony/dependency-injection/Dumper/Preloader.php @@ -97,7 +97,7 @@ final class Preloader if (!$t) { return; } - foreach ($t instanceof \ReflectionUnionType || $t instanceof \RectorPrefix20220607\ReflectionIntersectionType ? $t->getTypes() : [$t] as $t) { + foreach ($t instanceof \ReflectionUnionType || $t instanceof \ReflectionIntersectionType ? $t->getTypes() : [$t] as $t) { if (!$t->isBuiltin()) { self::doPreload($t instanceof \ReflectionNamedType ? $t->getName() : $t, $preloaded); } diff --git a/vendor/symfony/dependency-injection/Dumper/XmlDumper.php b/vendor/symfony/dependency-injection/Dumper/XmlDumper.php index 95e71f05675..23aff7f106a 100644 --- a/vendor/symfony/dependency-injection/Dumper/XmlDumper.php +++ b/vendor/symfony/dependency-injection/Dumper/XmlDumper.php @@ -28,7 +28,7 @@ use RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression; * @author Fabien Potencier * @author Martin Hasoň */ -class XmlDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Dumper\Dumper +class XmlDumper extends Dumper { /** * @var \DOMDocument @@ -78,7 +78,7 @@ class XmlDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInject $parent->appendChild($call); } } - private function addService(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, ?string $id, \DOMElement $parent) + private function addService(Definition $definition, ?string $id, \DOMElement $parent) { $service = $this->document->createElement('service'); if (null !== $id) { @@ -105,9 +105,9 @@ class XmlDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInject if (null !== ($decoratedService = $definition->getDecoratedService())) { [$decorated, $renamedId, $priority] = $decoratedService; $service->setAttribute('decorates', $decorated); - $decorationOnInvalid = $decoratedService[3] ?? \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; - if (\in_array($decorationOnInvalid, [\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_INVALID_REFERENCE, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::NULL_ON_INVALID_REFERENCE], \true)) { - $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::NULL_ON_INVALID_REFERENCE === $decorationOnInvalid ? 'null' : 'ignore'; + $decorationOnInvalid = $decoratedService[3] ?? ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; + if (\in_array($decorationOnInvalid, [ContainerInterface::IGNORE_ON_INVALID_REFERENCE, ContainerInterface::NULL_ON_INVALID_REFERENCE], \true)) { + $invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE === $decorationOnInvalid ? 'null' : 'ignore'; $service->setAttribute('decoration-on-invalid', $invalidBehavior); } if (null !== $renamedId) { @@ -145,12 +145,12 @@ class XmlDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInject $this->addMethodCalls($definition->getMethodCalls(), $service); if ($callable = $definition->getFactory()) { $factory = $this->document->createElement('factory'); - if (\is_array($callable) && $callable[0] instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + if (\is_array($callable) && $callable[0] instanceof Definition) { $this->addService($callable[0], null, $factory); $factory->setAttribute('method', $callable[1]); } elseif (\is_array($callable)) { if (null !== $callable[0]) { - $factory->setAttribute($callable[0] instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference ? 'service' : 'class', $callable[0]); + $factory->setAttribute($callable[0] instanceof Reference ? 'service' : 'class', $callable[0]); } $factory->setAttribute('method', $callable[1]); } else { @@ -177,11 +177,11 @@ class XmlDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInject } if ($callable = $definition->getConfigurator()) { $configurator = $this->document->createElement('configurator'); - if (\is_array($callable) && $callable[0] instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + if (\is_array($callable) && $callable[0] instanceof Definition) { $this->addService($callable[0], null, $configurator); $configurator->setAttribute('method', $callable[1]); } elseif (\is_array($callable)) { - $configurator->setAttribute($callable[0] instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference ? 'service' : 'class', $callable[0]); + $configurator->setAttribute($callable[0] instanceof Reference ? 'service' : 'class', $callable[0]); $configurator->setAttribute('method', $callable[1]); } else { $configurator->setAttribute('function', $callable); @@ -190,7 +190,7 @@ class XmlDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInject } $parent->appendChild($service); } - private function addServiceAlias(string $alias, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Alias $id, \DOMElement $parent) + private function addServiceAlias(string $alias, Alias $id, \DOMElement $parent) { $service = $this->document->createElement('service'); $service->setAttribute('id', $alias); @@ -230,8 +230,8 @@ class XmlDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInject private function convertParameters(array $parameters, string $type, \DOMElement $parent, string $keyAttribute = 'key') { $arrayIsList = function (array $array) : bool { - if (\function_exists('RectorPrefix20220607\\array_is_list')) { - return array_is_list($array); + if (\function_exists('array_is_list')) { + return \array_is_list($array); } if ($array === []) { return \true; @@ -254,8 +254,8 @@ class XmlDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInject if (\is_array($tag = $value)) { $element->setAttribute('type', 'collection'); $this->convertParameters($value, $type, $element, 'key'); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument || $value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument && ($tag = $value->getTaggedIteratorArgument())) { - $element->setAttribute('type', $value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument ? 'tagged_iterator' : 'tagged_locator'); + } elseif ($value instanceof TaggedIteratorArgument || $value instanceof ServiceLocatorArgument && ($tag = $value->getTaggedIteratorArgument())) { + $element->setAttribute('type', $value instanceof TaggedIteratorArgument ? 'tagged_iterator' : 'tagged_locator'); $element->setAttribute('tag', $tag->getTag()); if (null !== $tag->getIndexAttribute()) { $element->setAttribute('index-by', $tag->getIndexAttribute()); @@ -266,34 +266,34 @@ class XmlDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInject $element->setAttribute('default-priority-method', $tag->getDefaultPriorityMethod()); } } - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\IteratorArgument) { + } elseif ($value instanceof IteratorArgument) { $element->setAttribute('type', 'iterator'); $this->convertParameters($value->getValues(), $type, $element, 'key'); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument) { + } elseif ($value instanceof ServiceLocatorArgument) { $element->setAttribute('type', 'service_locator'); $this->convertParameters($value->getValues(), $type, $element, 'key'); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument && !$value->getValues()[0] instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + } elseif ($value instanceof ServiceClosureArgument && !$value->getValues()[0] instanceof Reference) { $element->setAttribute('type', 'service_closure'); $this->convertParameters($value->getValues(), $type, $element, 'key'); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference || $value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument) { + } elseif ($value instanceof Reference || $value instanceof ServiceClosureArgument) { $element->setAttribute('type', 'service'); - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument) { + if ($value instanceof ServiceClosureArgument) { $element->setAttribute('type', 'service_closure'); $value = $value->getValues()[0]; } $element->setAttribute('id', (string) $value); $behavior = $value->getInvalidBehavior(); - if (\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::NULL_ON_INVALID_REFERENCE == $behavior) { + if (ContainerInterface::NULL_ON_INVALID_REFERENCE == $behavior) { $element->setAttribute('on-invalid', 'null'); - } elseif (\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_INVALID_REFERENCE == $behavior) { + } elseif (ContainerInterface::IGNORE_ON_INVALID_REFERENCE == $behavior) { $element->setAttribute('on-invalid', 'ignore'); - } elseif (\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE == $behavior) { + } elseif (ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE == $behavior) { $element->setAttribute('on-invalid', 'ignore_uninitialized'); } - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + } elseif ($value instanceof Definition) { $element->setAttribute('type', 'service'); $this->addService($value, null, $element); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression) { + } elseif ($value instanceof Expression) { $element->setAttribute('type', 'expression'); $text = $this->document->createTextNode(self::phpToXml((string) $value)); $element->appendChild($text); @@ -301,10 +301,10 @@ class XmlDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInject $element->setAttribute('type', 'binary'); $text = $this->document->createTextNode(self::phpToXml(\base64_encode($value))); $element->appendChild($text); - } elseif ($value instanceof \RectorPrefix20220607\UnitEnum) { + } elseif ($value instanceof \UnitEnum) { $element->setAttribute('type', 'constant'); $element->appendChild($this->document->createTextNode(self::phpToXml($value))); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\AbstractArgument) { + } elseif ($value instanceof AbstractArgument) { $element->setAttribute('type', 'abstract'); $text = $this->document->createTextNode(self::phpToXml($value->getText())); $element->appendChild($text); @@ -353,12 +353,12 @@ class XmlDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInject return 'true'; case \false === $value: return 'false'; - case $value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Parameter: + case $value instanceof Parameter: return '%' . $value . '%'; - case $value instanceof \RectorPrefix20220607\UnitEnum: + case $value instanceof \UnitEnum: return \sprintf('%s::%s', \get_class($value), $value->name); case \is_object($value) || \is_resource($value): - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException('Unable to dump a service container if a parameter is an object or a resource.'); + throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.'); default: return (string) $value; } diff --git a/vendor/symfony/dependency-injection/Dumper/YamlDumper.php b/vendor/symfony/dependency-injection/Dumper/YamlDumper.php index cf22ce0a4c3..68e20981462 100644 --- a/vendor/symfony/dependency-injection/Dumper/YamlDumper.php +++ b/vendor/symfony/dependency-injection/Dumper/YamlDumper.php @@ -33,7 +33,7 @@ use RectorPrefix20220607\Symfony\Component\Yaml\Yaml; * * @author Fabien Potencier */ -class YamlDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Dumper\Dumper +class YamlDumper extends Dumper { /** * @var YmlDumper @@ -44,13 +44,13 @@ class YamlDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInjec */ public function dump(array $options = []) : string { - if (!\class_exists(\RectorPrefix20220607\Symfony\Component\Yaml\Dumper::class)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicException('Unable to dump the container as the Symfony Yaml Component is not installed.'); + if (!\class_exists(YmlDumper::class)) { + throw new LogicException('Unable to dump the container as the Symfony Yaml Component is not installed.'); } - $this->dumper = $this->dumper ?? new \RectorPrefix20220607\Symfony\Component\Yaml\Dumper(); + $this->dumper = $this->dumper ?? new YmlDumper(); return $this->container->resolveEnvPlaceholders($this->addParameters() . "\n" . $this->addServices()); } - private function addService(string $id, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) : string + private function addService(string $id, Definition $definition) : string { $code = " {$id}:\n"; if ($class = $definition->getClass()) { @@ -123,9 +123,9 @@ class YamlDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInjec if (0 !== $priority) { $code .= \sprintf(" decoration_priority: %s\n", $priority); } - $decorationOnInvalid = $decoratedService[3] ?? \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; - if (\in_array($decorationOnInvalid, [\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_INVALID_REFERENCE, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::NULL_ON_INVALID_REFERENCE])) { - $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::NULL_ON_INVALID_REFERENCE === $decorationOnInvalid ? 'null' : 'ignore'; + $decorationOnInvalid = $decoratedService[3] ?? ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; + if (\in_array($decorationOnInvalid, [ContainerInterface::IGNORE_ON_INVALID_REFERENCE, ContainerInterface::NULL_ON_INVALID_REFERENCE])) { + $invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE === $decorationOnInvalid ? 'null' : 'ignore'; $code .= \sprintf(" decoration_on_invalid: %s\n", $invalidBehavior); } } @@ -137,7 +137,7 @@ class YamlDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInjec } return $code; } - private function addServiceAlias(string $alias, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Alias $id) : string + private function addServiceAlias(string $alias, Alias $id) : string { $deprecated = ''; if ($id->isDeprecated()) { @@ -190,7 +190,7 @@ class YamlDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInjec private function dumpCallable($callable) { if (\is_array($callable)) { - if ($callable[0] instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + if ($callable[0] instanceof Reference) { $callable = [$this->getServiceCall((string) $callable[0], $callable[0]), $callable[1]]; } else { $callable = [$callable[0], $callable[1]]; @@ -207,13 +207,13 @@ class YamlDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInjec */ private function dumpValue($value) { - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument) { + if ($value instanceof ServiceClosureArgument) { $value = $value->getValues()[0]; - return new \RectorPrefix20220607\Symfony\Component\Yaml\Tag\TaggedValue('service_closure', $this->dumpValue($value)); + return new TaggedValue('service_closure', $this->dumpValue($value)); } - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ArgumentInterface) { + if ($value instanceof ArgumentInterface) { $tag = $value; - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument || $value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument && ($tag = $value->getTaggedIteratorArgument())) { + if ($value instanceof TaggedIteratorArgument || $value instanceof ServiceLocatorArgument && ($tag = $value->getTaggedIteratorArgument())) { if (null === $tag->getIndexAttribute()) { $content = $tag->getTag(); } else { @@ -225,16 +225,16 @@ class YamlDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInjec $content['default_priority_method'] = $tag->getDefaultPriorityMethod(); } } - return new \RectorPrefix20220607\Symfony\Component\Yaml\Tag\TaggedValue($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument ? 'tagged_iterator' : 'tagged_locator', $content); + return new TaggedValue($value instanceof TaggedIteratorArgument ? 'tagged_iterator' : 'tagged_locator', $content); } - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\IteratorArgument) { + if ($value instanceof IteratorArgument) { $tag = 'iterator'; - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument) { + } elseif ($value instanceof ServiceLocatorArgument) { $tag = 'service_locator'; } else { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Unspecified Yaml tag for type "%s".', \get_debug_type($value))); + throw new RuntimeException(\sprintf('Unspecified Yaml tag for type "%s".', \get_debug_type($value))); } - return new \RectorPrefix20220607\Symfony\Component\Yaml\Tag\TaggedValue($tag, $this->dumpValue($value->getValues())); + return new TaggedValue($tag, $this->dumpValue($value->getValues())); } if (\is_array($value)) { $code = []; @@ -242,32 +242,32 @@ class YamlDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInjec $code[$k] = $this->dumpValue($v); } return $code; - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference) { + } elseif ($value instanceof Reference) { return $this->getServiceCall((string) $value, $value); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Parameter) { + } elseif ($value instanceof Parameter) { return $this->getParameterCall((string) $value); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression) { + } elseif ($value instanceof Expression) { return $this->getExpressionCall((string) $value); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { - return new \RectorPrefix20220607\Symfony\Component\Yaml\Tag\TaggedValue('service', (new \RectorPrefix20220607\Symfony\Component\Yaml\Parser())->parse("_:\n" . $this->addService('_', $value), \RectorPrefix20220607\Symfony\Component\Yaml\Yaml::PARSE_CUSTOM_TAGS)['_']['_']); - } elseif ($value instanceof \RectorPrefix20220607\UnitEnum) { - return new \RectorPrefix20220607\Symfony\Component\Yaml\Tag\TaggedValue('php/const', \sprintf('%s::%s', \get_class($value), $value->name)); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\AbstractArgument) { - return new \RectorPrefix20220607\Symfony\Component\Yaml\Tag\TaggedValue('abstract', $value->getText()); + } elseif ($value instanceof Definition) { + return new TaggedValue('service', (new Parser())->parse("_:\n" . $this->addService('_', $value), Yaml::PARSE_CUSTOM_TAGS)['_']['_']); + } elseif ($value instanceof \UnitEnum) { + return new TaggedValue('php/const', \sprintf('%s::%s', \get_class($value), $value->name)); + } elseif ($value instanceof AbstractArgument) { + return new TaggedValue('abstract', $value->getText()); } elseif (\is_object($value) || \is_resource($value)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException('Unable to dump a service container if a parameter is an object or a resource.'); + throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.'); } return $value; } - private function getServiceCall(string $id, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference $reference = null) : string + private function getServiceCall(string $id, Reference $reference = null) : string { if (null !== $reference) { switch ($reference->getInvalidBehavior()) { - case \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE: + case ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE: break; - case \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE: + case ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE: break; - case \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE: + case ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE: return \sprintf('@!%s', $id); default: return \sprintf('@?%s', $id); @@ -289,7 +289,7 @@ class YamlDumper extends \RectorPrefix20220607\Symfony\Component\DependencyInjec foreach ($parameters as $key => $value) { if (\is_array($value)) { $value = $this->prepareParameters($value, $escape); - } elseif ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference || \is_string($value) && \strncmp($value, '@', \strlen('@')) === 0) { + } elseif ($value instanceof Reference || \is_string($value) && \strncmp($value, '@', \strlen('@')) === 0) { $value = '@' . $value; } $filtered[$key] = $value; diff --git a/vendor/symfony/dependency-injection/EnvVarProcessor.php b/vendor/symfony/dependency-injection/EnvVarProcessor.php index ee9c33f0733..5597fa31bc2 100644 --- a/vendor/symfony/dependency-injection/EnvVarProcessor.php +++ b/vendor/symfony/dependency-injection/EnvVarProcessor.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\Runtime /** * @author Nicolas Grekas */ -class EnvVarProcessor implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\EnvVarProcessorInterface +class EnvVarProcessor implements EnvVarProcessorInterface { /** * @var \Symfony\Component\DependencyInjection\ContainerInterface @@ -33,7 +33,7 @@ class EnvVarProcessor implements \RectorPrefix20220607\Symfony\Component\Depende /** * @param EnvVarLoaderInterface[] $loaders */ - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface $container, \Traversable $loaders = null) + public function __construct(ContainerInterface $container, \Traversable $loaders = null) { $this->container = $container; $this->loaders = $loaders ?? new \ArrayIterator(); @@ -54,44 +54,44 @@ class EnvVarProcessor implements \RectorPrefix20220607\Symfony\Component\Depende $i = \strpos($name, ':'); if ('key' === $prefix) { if (\false === $i) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Invalid env "key:%s": a key specifier should be provided.', $name)); + throw new RuntimeException(\sprintf('Invalid env "key:%s": a key specifier should be provided.', $name)); } $next = \substr($name, $i + 1); $key = \substr($name, 0, $i); $array = $getEnv($next); if (!\is_array($array)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Resolved value of "%s" did not result in an array value.', $next)); + throw new RuntimeException(\sprintf('Resolved value of "%s" did not result in an array value.', $next)); } if (!isset($array[$key]) && !\array_key_exists($key, $array)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\EnvNotFoundException(\sprintf('Key "%s" not found in %s (resolved from "%s").', $key, \json_encode($array), $next)); + throw new EnvNotFoundException(\sprintf('Key "%s" not found in %s (resolved from "%s").', $key, \json_encode($array), $next)); } return $array[$key]; } if ('default' === $prefix) { if (\false === $i) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Invalid env "default:%s": a fallback parameter should be provided.', $name)); + throw new RuntimeException(\sprintf('Invalid env "default:%s": a fallback parameter should be provided.', $name)); } $next = \substr($name, $i + 1); $default = \substr($name, 0, $i); if ('' !== $default && !$this->container->hasParameter($default)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Invalid env fallback in "default:%s": parameter "%s" not found.', $name, $default)); + throw new RuntimeException(\sprintf('Invalid env fallback in "default:%s": parameter "%s" not found.', $name, $default)); } try { $env = $getEnv($next); if ('' !== $env && null !== $env) { return $env; } - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\EnvNotFoundException $exception) { + } catch (EnvNotFoundException $exception) { // no-op } return '' === $default ? null : $this->container->getParameter($default); } if ('file' === $prefix || 'require' === $prefix) { if (!\is_scalar($file = $getEnv($name))) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Invalid file name: env var "%s" is non-scalar.', $name)); + throw new RuntimeException(\sprintf('Invalid file name: env var "%s" is non-scalar.', $name)); } if (!\is_file($file)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\EnvNotFoundException(\sprintf('File "%s" not found (resolved from "%s").', $file, $name)); + throw new EnvNotFoundException(\sprintf('File "%s" not found (resolved from "%s").', $file, $name)); } if ('file' === $prefix) { return \file_get_contents($file); @@ -132,7 +132,7 @@ class EnvVarProcessor implements \RectorPrefix20220607\Symfony\Component\Depende if ($ended || $count === $i) { $loaders = $this->loaders; } - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException $exception) { + } catch (ParameterCircularReferenceException $exception) { // skip loaders that need an env var that is not defined } finally { $this->loaders = $loaders; @@ -140,19 +140,19 @@ class EnvVarProcessor implements \RectorPrefix20220607\Symfony\Component\Depende } if (\false === $env || null === $env) { if (!$this->container->hasParameter("env({$name})")) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\EnvNotFoundException(\sprintf('Environment variable not found: "%s".', $name)); + throw new EnvNotFoundException(\sprintf('Environment variable not found: "%s".', $name)); } $env = $this->container->getParameter("env({$name})"); } } if (null === $env) { if (!isset($this->getProvidedTypes()[$prefix])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Unsupported env var prefix "%s".', $prefix)); + throw new RuntimeException(\sprintf('Unsupported env var prefix "%s".', $prefix)); } return null; } if (!\is_scalar($env)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Non-scalar env var "%s" cannot be cast to "%s".', $name, $prefix)); + throw new RuntimeException(\sprintf('Non-scalar env var "%s" cannot be cast to "%s".', $name, $prefix)); } if ('string' === $prefix) { return (string) $env; @@ -163,19 +163,19 @@ class EnvVarProcessor implements \RectorPrefix20220607\Symfony\Component\Depende } if ('int' === $prefix) { if (\false === ($env = \filter_var($env, \FILTER_VALIDATE_INT) ?: \filter_var($env, \FILTER_VALIDATE_FLOAT))) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Non-numeric env var "%s" cannot be cast to int.', $name)); + throw new RuntimeException(\sprintf('Non-numeric env var "%s" cannot be cast to int.', $name)); } return (int) $env; } if ('float' === $prefix) { if (\false === ($env = \filter_var($env, \FILTER_VALIDATE_FLOAT))) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Non-numeric env var "%s" cannot be cast to float.', $name)); + throw new RuntimeException(\sprintf('Non-numeric env var "%s" cannot be cast to float.', $name)); } return (float) $env; } if ('const' === $prefix) { if (!\defined($env)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Env var "%s" maps to undefined constant "%s".', $name, $env)); + throw new RuntimeException(\sprintf('Env var "%s" maps to undefined constant "%s".', $name, $env)); } return \constant($env); } @@ -185,20 +185,20 @@ class EnvVarProcessor implements \RectorPrefix20220607\Symfony\Component\Depende if ('json' === $prefix) { $env = \json_decode($env, \true); if (\JSON_ERROR_NONE !== \json_last_error()) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Invalid JSON in env var "%s": ', $name) . \json_last_error_msg()); + throw new RuntimeException(\sprintf('Invalid JSON in env var "%s": ', $name) . \json_last_error_msg()); } if (null !== $env && !\is_array($env)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Invalid JSON env var "%s": array or null expected, "%s" given.', $name, \get_debug_type($env))); + throw new RuntimeException(\sprintf('Invalid JSON env var "%s": array or null expected, "%s" given.', $name, \get_debug_type($env))); } return $env; } if ('url' === $prefix) { $parsedEnv = \parse_url($env); if (\false === $parsedEnv) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Invalid URL in env var "%s".', $name)); + throw new RuntimeException(\sprintf('Invalid URL in env var "%s".', $name)); } if (!isset($parsedEnv['scheme'], $parsedEnv['host'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Invalid URL env var "%s": schema and host expected, "%s" given.', $name, $env)); + throw new RuntimeException(\sprintf('Invalid URL env var "%s": schema and host expected, "%s" given.', $name, $env)); } $parsedEnv += ['port' => null, 'user' => null, 'pass' => null, 'path' => null, 'query' => null, 'fragment' => null]; // remove the '/' separator @@ -221,7 +221,7 @@ class EnvVarProcessor implements \RectorPrefix20220607\Symfony\Component\Depende $value = $this->container->getParameter($match[1]); } if (!\is_scalar($value)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Parameter "%s" found when resolving env var "%s" must be scalar, "%s" given.', $match[1], $name, \get_debug_type($value))); + throw new RuntimeException(\sprintf('Parameter "%s" found when resolving env var "%s" must be scalar, "%s" given.', $match[1], $name, \get_debug_type($value))); } return $value; }, $env); @@ -232,6 +232,6 @@ class EnvVarProcessor implements \RectorPrefix20220607\Symfony\Component\Depende if ('trim' === $prefix) { return \trim($env); } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Unsupported env var prefix "%s" for env name "%s".', $prefix, $name)); + throw new RuntimeException(\sprintf('Unsupported env var prefix "%s" for env name "%s".', $prefix, $name)); } } diff --git a/vendor/symfony/dependency-injection/Exception/AutowiringFailedException.php b/vendor/symfony/dependency-injection/Exception/AutowiringFailedException.php index d8e2848fe54..3425362debe 100644 --- a/vendor/symfony/dependency-injection/Exception/AutowiringFailedException.php +++ b/vendor/symfony/dependency-injection/Exception/AutowiringFailedException.php @@ -13,7 +13,7 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception; /** * Thrown when a definition cannot be autowired. */ -class AutowiringFailedException extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException +class AutowiringFailedException extends RuntimeException { /** * @var string diff --git a/vendor/symfony/dependency-injection/Exception/BadMethodCallException.php b/vendor/symfony/dependency-injection/Exception/BadMethodCallException.php index 2462c5dc597..52fac309591 100644 --- a/vendor/symfony/dependency-injection/Exception/BadMethodCallException.php +++ b/vendor/symfony/dependency-injection/Exception/BadMethodCallException.php @@ -13,6 +13,6 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception; /** * Base BadMethodCallException for Dependency Injection component. */ -class BadMethodCallException extends \BadMethodCallException implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ExceptionInterface +class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface { } diff --git a/vendor/symfony/dependency-injection/Exception/EnvNotFoundException.php b/vendor/symfony/dependency-injection/Exception/EnvNotFoundException.php index 43b2d627368..ec8f7054724 100644 --- a/vendor/symfony/dependency-injection/Exception/EnvNotFoundException.php +++ b/vendor/symfony/dependency-injection/Exception/EnvNotFoundException.php @@ -15,6 +15,6 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception; * * @author Nicolas Grekas */ -class EnvNotFoundException extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException +class EnvNotFoundException extends InvalidArgumentException { } diff --git a/vendor/symfony/dependency-injection/Exception/EnvParameterException.php b/vendor/symfony/dependency-injection/Exception/EnvParameterException.php index 4a955a6773e..ecec6c7ef87 100644 --- a/vendor/symfony/dependency-injection/Exception/EnvParameterException.php +++ b/vendor/symfony/dependency-injection/Exception/EnvParameterException.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception; * * @author Nicolas Grekas */ -class EnvParameterException extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException +class EnvParameterException extends InvalidArgumentException { public function __construct(array $envs, \Throwable $previous = null, string $message = 'Incompatible use of dynamic environment variables "%s" found in parameters.') { diff --git a/vendor/symfony/dependency-injection/Exception/ExceptionInterface.php b/vendor/symfony/dependency-injection/Exception/ExceptionInterface.php index e990415880f..bf2f3c849f8 100644 --- a/vendor/symfony/dependency-injection/Exception/ExceptionInterface.php +++ b/vendor/symfony/dependency-injection/Exception/ExceptionInterface.php @@ -17,6 +17,6 @@ use RectorPrefix20220607\Psr\Container\ContainerExceptionInterface; * @author Fabien Potencier * @author Bulat Shakirzyanov */ -interface ExceptionInterface extends \RectorPrefix20220607\Psr\Container\ContainerExceptionInterface +interface ExceptionInterface extends ContainerExceptionInterface { } diff --git a/vendor/symfony/dependency-injection/Exception/InvalidArgumentException.php b/vendor/symfony/dependency-injection/Exception/InvalidArgumentException.php index 7955540d856..130000799c9 100644 --- a/vendor/symfony/dependency-injection/Exception/InvalidArgumentException.php +++ b/vendor/symfony/dependency-injection/Exception/InvalidArgumentException.php @@ -15,6 +15,6 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception; * * @author Bulat Shakirzyanov */ -class InvalidArgumentException extends \InvalidArgumentException implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ExceptionInterface +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { } diff --git a/vendor/symfony/dependency-injection/Exception/InvalidParameterTypeException.php b/vendor/symfony/dependency-injection/Exception/InvalidParameterTypeException.php index 9a89cf6a75f..343b239c8e3 100644 --- a/vendor/symfony/dependency-injection/Exception/InvalidParameterTypeException.php +++ b/vendor/symfony/dependency-injection/Exception/InvalidParameterTypeException.php @@ -16,7 +16,7 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception; * @author Nicolas Grekas * @author Julien Maulny */ -class InvalidParameterTypeException extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException +class InvalidParameterTypeException extends InvalidArgumentException { public function __construct(string $serviceId, string $type, \ReflectionParameter $parameter) { diff --git a/vendor/symfony/dependency-injection/Exception/LogicException.php b/vendor/symfony/dependency-injection/Exception/LogicException.php index 6854340a047..7dcb6ae8a81 100644 --- a/vendor/symfony/dependency-injection/Exception/LogicException.php +++ b/vendor/symfony/dependency-injection/Exception/LogicException.php @@ -13,6 +13,6 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception; /** * Base LogicException for Dependency Injection component. */ -class LogicException extends \LogicException implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ExceptionInterface +class LogicException extends \LogicException implements ExceptionInterface { } diff --git a/vendor/symfony/dependency-injection/Exception/OutOfBoundsException.php b/vendor/symfony/dependency-injection/Exception/OutOfBoundsException.php index 80928d39687..c06806e090d 100644 --- a/vendor/symfony/dependency-injection/Exception/OutOfBoundsException.php +++ b/vendor/symfony/dependency-injection/Exception/OutOfBoundsException.php @@ -13,6 +13,6 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception; /** * Base OutOfBoundsException for Dependency Injection component. */ -class OutOfBoundsException extends \OutOfBoundsException implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ExceptionInterface +class OutOfBoundsException extends \OutOfBoundsException implements ExceptionInterface { } diff --git a/vendor/symfony/dependency-injection/Exception/ParameterCircularReferenceException.php b/vendor/symfony/dependency-injection/Exception/ParameterCircularReferenceException.php index 36e3ec5a247..421ef4bd4af 100644 --- a/vendor/symfony/dependency-injection/Exception/ParameterCircularReferenceException.php +++ b/vendor/symfony/dependency-injection/Exception/ParameterCircularReferenceException.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception; * * @author Fabien Potencier */ -class ParameterCircularReferenceException extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException +class ParameterCircularReferenceException extends RuntimeException { /** * @var mixed[] diff --git a/vendor/symfony/dependency-injection/Exception/ParameterNotFoundException.php b/vendor/symfony/dependency-injection/Exception/ParameterNotFoundException.php index 01bd5d176cb..4123ce7c340 100644 --- a/vendor/symfony/dependency-injection/Exception/ParameterNotFoundException.php +++ b/vendor/symfony/dependency-injection/Exception/ParameterNotFoundException.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Psr\Container\NotFoundExceptionInterface; * * @author Fabien Potencier */ -class ParameterNotFoundException extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException implements \RectorPrefix20220607\Psr\Container\NotFoundExceptionInterface +class ParameterNotFoundException extends InvalidArgumentException implements NotFoundExceptionInterface { /** * @var string diff --git a/vendor/symfony/dependency-injection/Exception/RuntimeException.php b/vendor/symfony/dependency-injection/Exception/RuntimeException.php index 1a3b9bdfb55..06bd28a2115 100644 --- a/vendor/symfony/dependency-injection/Exception/RuntimeException.php +++ b/vendor/symfony/dependency-injection/Exception/RuntimeException.php @@ -15,6 +15,6 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception; * * @author Johannes M. Schmitt */ -class RuntimeException extends \RuntimeException implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ExceptionInterface +class RuntimeException extends \RuntimeException implements ExceptionInterface { } diff --git a/vendor/symfony/dependency-injection/Exception/ServiceCircularReferenceException.php b/vendor/symfony/dependency-injection/Exception/ServiceCircularReferenceException.php index bf546f81adf..68c4bdff7aa 100644 --- a/vendor/symfony/dependency-injection/Exception/ServiceCircularReferenceException.php +++ b/vendor/symfony/dependency-injection/Exception/ServiceCircularReferenceException.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception; * * @author Johannes M. Schmitt */ -class ServiceCircularReferenceException extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException +class ServiceCircularReferenceException extends RuntimeException { /** * @var string diff --git a/vendor/symfony/dependency-injection/Exception/ServiceNotFoundException.php b/vendor/symfony/dependency-injection/Exception/ServiceNotFoundException.php index bcebd6f449a..8d610870120 100644 --- a/vendor/symfony/dependency-injection/Exception/ServiceNotFoundException.php +++ b/vendor/symfony/dependency-injection/Exception/ServiceNotFoundException.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Psr\Container\NotFoundExceptionInterface; * * @author Johannes M. Schmitt */ -class ServiceNotFoundException extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException implements \RectorPrefix20220607\Psr\Container\NotFoundExceptionInterface +class ServiceNotFoundException extends InvalidArgumentException implements NotFoundExceptionInterface { /** * @var string diff --git a/vendor/symfony/dependency-injection/Extension/AbstractExtension.php b/vendor/symfony/dependency-injection/Extension/AbstractExtension.php index 1398b152233..4e548534047 100644 --- a/vendor/symfony/dependency-injection/Extension/AbstractExtension.php +++ b/vendor/symfony/dependency-injection/Extension/AbstractExtension.php @@ -20,33 +20,33 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurat * * @author Yonel Ceruto */ -abstract class AbstractExtension extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\Extension implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\ConfigurableExtensionInterface, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface +abstract class AbstractExtension extends Extension implements ConfigurableExtensionInterface, PrependExtensionInterface { use ExtensionTrait; - public function configure(\RectorPrefix20220607\Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator $definition) : void + public function configure(DefinitionConfigurator $definition) : void { } - public function prependExtension(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $container, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $builder) : void + public function prependExtension(ContainerConfigurator $container, ContainerBuilder $builder) : void { } - public function loadExtension(array $config, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $container, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $builder) : void + public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder) : void { } - public function getConfiguration(array $config, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) : ?\RectorPrefix20220607\Symfony\Component\Config\Definition\ConfigurationInterface + public function getConfiguration(array $config, ContainerBuilder $container) : ?ConfigurationInterface { - return new \RectorPrefix20220607\Symfony\Component\Config\Definition\Configuration($this, $container, $this->getAlias()); + return new Configuration($this, $container, $this->getAlias()); } - public final function prepend(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) : void + public final function prepend(ContainerBuilder $container) : void { - $callback = function (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $configurator) use($container) { + $callback = function (ContainerConfigurator $configurator) use($container) { $this->prependExtension($configurator, $container); }; $this->executeConfiguratorCallback($container, $callback, $this); } - public final function load(array $configs, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) : void + public final function load(array $configs, ContainerBuilder $container) : void { $config = $this->processConfiguration($this->getConfiguration([], $container), $configs); - $callback = function (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $configurator) use($config, $container) { + $callback = function (ContainerConfigurator $configurator) use($config, $container) { $this->loadExtension($config, $configurator, $container); }; $this->executeConfiguratorCallback($container, $callback, $this); diff --git a/vendor/symfony/dependency-injection/Extension/ConfigurableExtensionInterface.php b/vendor/symfony/dependency-injection/Extension/ConfigurableExtensionInterface.php index 5a024966071..c6a0d5e6ab9 100644 --- a/vendor/symfony/dependency-injection/Extension/ConfigurableExtensionInterface.php +++ b/vendor/symfony/dependency-injection/Extension/ConfigurableExtensionInterface.php @@ -16,14 +16,14 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurat /** * @author Yonel Ceruto */ -interface ConfigurableExtensionInterface extends \RectorPrefix20220607\Symfony\Component\Config\Definition\ConfigurableInterface +interface ConfigurableExtensionInterface extends ConfigurableInterface { /** * Allows an extension to prepend the extension configurations. */ - public function prependExtension(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $container, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $builder) : void; + public function prependExtension(ContainerConfigurator $container, ContainerBuilder $builder) : void; /** * Loads a specific configuration. */ - public function loadExtension(array $config, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $container, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $builder) : void; + public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder) : void; } diff --git a/vendor/symfony/dependency-injection/Extension/ConfigurationExtensionInterface.php b/vendor/symfony/dependency-injection/Extension/ConfigurationExtensionInterface.php index 1c492bfeb10..8f86a24f966 100644 --- a/vendor/symfony/dependency-injection/Extension/ConfigurationExtensionInterface.php +++ b/vendor/symfony/dependency-injection/Extension/ConfigurationExtensionInterface.php @@ -24,5 +24,5 @@ interface ConfigurationExtensionInterface * * @return ConfigurationInterface|null */ - public function getConfiguration(array $config, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container); + public function getConfiguration(array $config, ContainerBuilder $container); } diff --git a/vendor/symfony/dependency-injection/Extension/Extension.php b/vendor/symfony/dependency-injection/Extension/Extension.php index 9f9c53e7f95..5e457556c7d 100644 --- a/vendor/symfony/dependency-injection/Extension/Extension.php +++ b/vendor/symfony/dependency-injection/Extension/Extension.php @@ -22,7 +22,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicEx * * @author Fabien Potencier */ -abstract class Extension implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\ExtensionInterface, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface +abstract class Extension implements ExtensionInterface, ConfigurationExtensionInterface { /** * @var mixed[] @@ -64,18 +64,18 @@ abstract class Extension implements \RectorPrefix20220607\Symfony\Component\Depe { $className = static::class; if (\substr_compare($className, 'Extension', -\strlen('Extension')) !== 0) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\BadMethodCallException('This extension does not follow the naming convention; you must overwrite the getAlias() method.'); + throw new BadMethodCallException('This extension does not follow the naming convention; you must overwrite the getAlias() method.'); } $classBaseName = \substr(\strrchr($className, '\\'), 1, -9); - return \RectorPrefix20220607\Symfony\Component\DependencyInjection\Container::underscore($classBaseName); + return Container::underscore($classBaseName); } /** * {@inheritdoc} */ - public function getConfiguration(array $config, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function getConfiguration(array $config, ContainerBuilder $container) { $class = static::class; - if (\strpos($class, "\0") !== \false) { + if (\strpos($class, "\x00") !== \false) { return null; // ignore anonymous classes } @@ -84,17 +84,17 @@ abstract class Extension implements \RectorPrefix20220607\Symfony\Component\Depe if (!$class) { return null; } - if (!$class->implementsInterface(\RectorPrefix20220607\Symfony\Component\Config\Definition\ConfigurationInterface::class)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicException(\sprintf('The extension configuration class "%s" must implement "%s".', $class->getName(), \RectorPrefix20220607\Symfony\Component\Config\Definition\ConfigurationInterface::class)); + if (!$class->implementsInterface(ConfigurationInterface::class)) { + throw new LogicException(\sprintf('The extension configuration class "%s" must implement "%s".', $class->getName(), ConfigurationInterface::class)); } if (!($constructor = $class->getConstructor()) || !$constructor->getNumberOfRequiredParameters()) { return $class->newInstance(); } return null; } - protected final function processConfiguration(\RectorPrefix20220607\Symfony\Component\Config\Definition\ConfigurationInterface $configuration, array $configs) : array + protected final function processConfiguration(ConfigurationInterface $configuration, array $configs) : array { - $processor = new \RectorPrefix20220607\Symfony\Component\Config\Definition\Processor(); + $processor = new Processor(); return $this->processedConfigs[] = $processor->processConfiguration($configuration, $configs); } /** @@ -111,10 +111,10 @@ abstract class Extension implements \RectorPrefix20220607\Symfony\Component\Depe /** * @throws InvalidArgumentException When the config is not enableable */ - protected function isConfigEnabled(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container, array $config) : bool + protected function isConfigEnabled(ContainerBuilder $container, array $config) : bool { if (!\array_key_exists('enabled', $config)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException("The config array has no 'enabled' key."); + throw new InvalidArgumentException("The config array has no 'enabled' key."); } return (bool) $container->getParameterBag()->resolveValue($config['enabled']); } diff --git a/vendor/symfony/dependency-injection/Extension/ExtensionInterface.php b/vendor/symfony/dependency-injection/Extension/ExtensionInterface.php index a52774fa060..ed58c87e1f2 100644 --- a/vendor/symfony/dependency-injection/Extension/ExtensionInterface.php +++ b/vendor/symfony/dependency-injection/Extension/ExtensionInterface.php @@ -23,7 +23,7 @@ interface ExtensionInterface * * @throws \InvalidArgumentException When provided tag is not defined in this extension */ - public function load(array $configs, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container); + public function load(array $configs, ContainerBuilder $container); /** * Returns the namespace to be used for this extension (XML namespace). * diff --git a/vendor/symfony/dependency-injection/Extension/ExtensionTrait.php b/vendor/symfony/dependency-injection/Extension/ExtensionTrait.php index 8f6b6011be5..155f4f68166 100644 --- a/vendor/symfony/dependency-injection/Extension/ExtensionTrait.php +++ b/vendor/symfony/dependency-injection/Extension/ExtensionTrait.php @@ -28,13 +28,13 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\YamlFileLo */ trait ExtensionTrait { - private function executeConfiguratorCallback(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container, \Closure $callback, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\ConfigurableExtensionInterface $subject) : void + private function executeConfiguratorCallback(ContainerBuilder $container, \Closure $callback, ConfigurableExtensionInterface $subject) : void { $env = $container->getParameter('kernel.environment'); $loader = $this->createContainerLoader($container, $env); $file = (new \ReflectionObject($subject))->getFileName(); $bundleLoader = $loader->getResolver()->resolve($file); - if (!$bundleLoader instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\PhpFileLoader) { + if (!$bundleLoader instanceof PhpFileLoader) { throw new \LogicException('Unable to create the ContainerConfigurator.'); } $bundleLoader->setCurrentDir(\dirname($file)); @@ -42,17 +42,17 @@ trait ExtensionTrait return $this->instanceof; }, $bundleLoader, $bundleLoader)(); try { - $callback(new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator($container, $bundleLoader, $instanceof, $file, $file, $env)); + $callback(new ContainerConfigurator($container, $bundleLoader, $instanceof, $file, $file, $env)); } finally { $instanceof = []; $bundleLoader->registerAliasesForSinglyImplementedInterfaces(); } } - private function createContainerLoader(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container, string $env) : \RectorPrefix20220607\Symfony\Component\Config\Loader\DelegatingLoader + private function createContainerLoader(ContainerBuilder $container, string $env) : DelegatingLoader { $buildDir = $container->getParameter('kernel.build_dir'); - $locator = new \RectorPrefix20220607\Symfony\Component\Config\FileLocator(); - $resolver = new \RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderResolver([new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\XmlFileLoader($container, $locator, $env), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\YamlFileLoader($container, $locator, $env), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\IniFileLoader($container, $locator, $env), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\PhpFileLoader($container, $locator, $env, new \RectorPrefix20220607\Symfony\Component\Config\Builder\ConfigBuilderGenerator($buildDir)), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\GlobFileLoader($container, $locator, $env), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\DirectoryLoader($container, $locator, $env), new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\ClosureLoader($container, $env)]); - return new \RectorPrefix20220607\Symfony\Component\Config\Loader\DelegatingLoader($resolver); + $locator = new FileLocator(); + $resolver = new LoaderResolver([new XmlFileLoader($container, $locator, $env), new YamlFileLoader($container, $locator, $env), new IniFileLoader($container, $locator, $env), new PhpFileLoader($container, $locator, $env, new ConfigBuilderGenerator($buildDir)), new GlobFileLoader($container, $locator, $env), new DirectoryLoader($container, $locator, $env), new ClosureLoader($container, $env)]); + return new DelegatingLoader($resolver); } } diff --git a/vendor/symfony/dependency-injection/Extension/PrependExtensionInterface.php b/vendor/symfony/dependency-injection/Extension/PrependExtensionInterface.php index 9bc64d140cb..1c76d1d4ee0 100644 --- a/vendor/symfony/dependency-injection/Extension/PrependExtensionInterface.php +++ b/vendor/symfony/dependency-injection/Extension/PrependExtensionInterface.php @@ -16,5 +16,5 @@ interface PrependExtensionInterface /** * Allow an extension to prepend the extension configurations. */ - public function prepend(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container); + public function prepend(ContainerBuilder $container); } diff --git a/vendor/symfony/dependency-injection/LazyProxy/Instantiator/InstantiatorInterface.php b/vendor/symfony/dependency-injection/LazyProxy/Instantiator/InstantiatorInterface.php index ecff5f5109e..9ba574f641b 100644 --- a/vendor/symfony/dependency-injection/LazyProxy/Instantiator/InstantiatorInterface.php +++ b/vendor/symfony/dependency-injection/LazyProxy/Instantiator/InstantiatorInterface.php @@ -28,5 +28,5 @@ interface InstantiatorInterface * * @return object */ - public function instantiateProxy(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface $container, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, string $id, callable $realInstantiator); + public function instantiateProxy(ContainerInterface $container, Definition $definition, string $id, callable $realInstantiator); } diff --git a/vendor/symfony/dependency-injection/LazyProxy/Instantiator/RealServiceInstantiator.php b/vendor/symfony/dependency-injection/LazyProxy/Instantiator/RealServiceInstantiator.php index 5b566f6b474..401efc7aae1 100644 --- a/vendor/symfony/dependency-injection/LazyProxy/Instantiator/RealServiceInstantiator.php +++ b/vendor/symfony/dependency-injection/LazyProxy/Instantiator/RealServiceInstantiator.php @@ -19,12 +19,12 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition; * * @author Marco Pivetta */ -class RealServiceInstantiator implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\LazyProxy\Instantiator\InstantiatorInterface +class RealServiceInstantiator implements InstantiatorInterface { /** * {@inheritdoc} */ - public function instantiateProxy(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface $container, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, string $id, callable $realInstantiator) : object + public function instantiateProxy(ContainerInterface $container, Definition $definition, string $id, callable $realInstantiator) : object { return $realInstantiator(); } diff --git a/vendor/symfony/dependency-injection/LazyProxy/PhpDumper/DumperInterface.php b/vendor/symfony/dependency-injection/LazyProxy/PhpDumper/DumperInterface.php index 64e2394fbf0..064d3f25e38 100644 --- a/vendor/symfony/dependency-injection/LazyProxy/PhpDumper/DumperInterface.php +++ b/vendor/symfony/dependency-injection/LazyProxy/PhpDumper/DumperInterface.php @@ -21,13 +21,13 @@ interface DumperInterface /** * Inspects whether the given definitions should produce proxy instantiation logic in the dumped container. */ - public function isProxyCandidate(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) : bool; + public function isProxyCandidate(Definition $definition) : bool; /** * Generates the code to be used to instantiate a proxy in the dumped factory code. */ - public function getProxyFactoryCode(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, string $id, string $factoryCode) : string; + public function getProxyFactoryCode(Definition $definition, string $id, string $factoryCode) : string; /** * Generates the code for the lazy proxy. */ - public function getProxyCode(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) : string; + public function getProxyCode(Definition $definition) : string; } diff --git a/vendor/symfony/dependency-injection/LazyProxy/PhpDumper/NullDumper.php b/vendor/symfony/dependency-injection/LazyProxy/PhpDumper/NullDumper.php index 24b97e4efc7..958a13f7876 100644 --- a/vendor/symfony/dependency-injection/LazyProxy/PhpDumper/NullDumper.php +++ b/vendor/symfony/dependency-injection/LazyProxy/PhpDumper/NullDumper.php @@ -18,26 +18,26 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition; * * @final */ -class NullDumper implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface +class NullDumper implements DumperInterface { /** * {@inheritdoc} */ - public function isProxyCandidate(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) : bool + public function isProxyCandidate(Definition $definition) : bool { return \false; } /** * {@inheritdoc} */ - public function getProxyFactoryCode(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, string $id, string $factoryCode) : string + public function getProxyFactoryCode(Definition $definition, string $id, string $factoryCode) : string { return ''; } /** * {@inheritdoc} */ - public function getProxyCode(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) : string + public function getProxyCode(Definition $definition) : string { return ''; } diff --git a/vendor/symfony/dependency-injection/LazyProxy/ProxyHelper.php b/vendor/symfony/dependency-injection/LazyProxy/ProxyHelper.php index b09856386a6..bcf82288feb 100644 --- a/vendor/symfony/dependency-injection/LazyProxy/ProxyHelper.php +++ b/vendor/symfony/dependency-injection/LazyProxy/ProxyHelper.php @@ -34,7 +34,7 @@ class ProxyHelper $glue = '|'; if ($type instanceof \ReflectionUnionType) { $reflectionTypes = $type->getTypes(); - } elseif ($type instanceof \RectorPrefix20220607\ReflectionIntersectionType) { + } elseif ($type instanceof \ReflectionIntersectionType) { $reflectionTypes = $type->getTypes(); $glue = '&'; } elseif ($type instanceof \ReflectionNamedType) { diff --git a/vendor/symfony/dependency-injection/Loader/ClosureLoader.php b/vendor/symfony/dependency-injection/Loader/ClosureLoader.php index 52a71c8258a..be08520511d 100644 --- a/vendor/symfony/dependency-injection/Loader/ClosureLoader.php +++ b/vendor/symfony/dependency-injection/Loader/ClosureLoader.php @@ -19,13 +19,13 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder; * * @author Fabien Potencier */ -class ClosureLoader extends \RectorPrefix20220607\Symfony\Component\Config\Loader\Loader +class ClosureLoader extends Loader { /** * @var \Symfony\Component\DependencyInjection\ContainerBuilder */ private $container; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container, string $env = null) + public function __construct(ContainerBuilder $container, string $env = null) { $this->container = $container; parent::__construct($env); diff --git a/vendor/symfony/dependency-injection/Loader/Configurator/AbstractConfigurator.php b/vendor/symfony/dependency-injection/Loader/Configurator/AbstractConfigurator.php index 3fc37e8a546..2f5f32e447d 100644 --- a/vendor/symfony/dependency-injection/Loader/Configurator/AbstractConfigurator.php +++ b/vendor/symfony/dependency-injection/Loader/Configurator/AbstractConfigurator.php @@ -64,35 +64,35 @@ abstract class AbstractConfigurator if (self::$valuePreProcessor) { $value = (self::$valuePreProcessor)($value, $allowServices); } - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ReferenceConfigurator) { - $reference = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($value->id, $value->invalidBehavior); - return $value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ClosureReferenceConfigurator ? new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument($reference) : $reference; + if ($value instanceof ReferenceConfigurator) { + $reference = new Reference($value->id, $value->invalidBehavior); + return $value instanceof ClosureReferenceConfigurator ? new ServiceClosureArgument($reference) : $reference; } - if ($value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\InlineServiceConfigurator) { + if ($value instanceof InlineServiceConfigurator) { $def = $value->definition; $value->definition = null; return $def; } - if ($value instanceof \RectorPrefix20220607\Symfony\Component\Config\Loader\ParamConfigurator) { + if ($value instanceof ParamConfigurator) { return (string) $value; } if ($value instanceof self) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('"%s()" can be used only at the root of service configuration files.', $value::FACTORY)); + throw new InvalidArgumentException(\sprintf('"%s()" can be used only at the root of service configuration files.', $value::FACTORY)); } switch (\true) { case null === $value: case \is_scalar($value): return $value; - case $value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ArgumentInterface: - case $value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition: - case $value instanceof \RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression: - case $value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Parameter: - case $value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\AbstractArgument: - case $value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference: + case $value instanceof ArgumentInterface: + case $value instanceof Definition: + case $value instanceof Expression: + case $value instanceof Parameter: + case $value instanceof AbstractArgument: + case $value instanceof Reference: if ($allowServices) { return $value; } } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Cannot use values of type "%s" in service configuration files.', \get_debug_type($value))); + throw new InvalidArgumentException(\sprintf('Cannot use values of type "%s" in service configuration files.', \get_debug_type($value))); } } diff --git a/vendor/symfony/dependency-injection/Loader/Configurator/AbstractServiceConfigurator.php b/vendor/symfony/dependency-injection/Loader/Configurator/AbstractServiceConfigurator.php index bfe8ff21d9a..0bbefd10c91 100644 --- a/vendor/symfony/dependency-injection/Loader/Configurator/AbstractServiceConfigurator.php +++ b/vendor/symfony/dependency-injection/Loader/Configurator/AbstractServiceConfigurator.php @@ -12,7 +12,7 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Conf use RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition; use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; -abstract class AbstractServiceConfigurator extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\AbstractConfigurator +abstract class AbstractServiceConfigurator extends AbstractConfigurator { protected $parent; protected $id; @@ -20,7 +20,7 @@ abstract class AbstractServiceConfigurator extends \RectorPrefix20220607\Symfony * @var mixed[] */ private $defaultTags = []; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ServicesConfigurator $parent, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, string $id = null, array $defaultTags = []) + public function __construct(ServicesConfigurator $parent, Definition $definition, string $id = null, array $defaultTags = []) { $this->parent = $parent; $this->definition = $definition; @@ -40,7 +40,7 @@ abstract class AbstractServiceConfigurator extends \RectorPrefix20220607\Symfony /** * Registers a service. */ - public final function set(?string $id, string $class = null) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ServiceConfigurator + public final function set(?string $id, string $class = null) : ServiceConfigurator { $this->__destruct(); return $this->parent->set($id, $class); @@ -48,7 +48,7 @@ abstract class AbstractServiceConfigurator extends \RectorPrefix20220607\Symfony /** * Creates an alias. */ - public final function alias(string $id, string $referencedId) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\AliasConfigurator + public final function alias(string $id, string $referencedId) : AliasConfigurator { $this->__destruct(); return $this->parent->alias($id, $referencedId); @@ -56,7 +56,7 @@ abstract class AbstractServiceConfigurator extends \RectorPrefix20220607\Symfony /** * Registers a PSR-4 namespace using a glob pattern. */ - public final function load(string $namespace, string $resource) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\PrototypeConfigurator + public final function load(string $namespace, string $resource) : PrototypeConfigurator { $this->__destruct(); return $this->parent->load($namespace, $resource); @@ -66,7 +66,7 @@ abstract class AbstractServiceConfigurator extends \RectorPrefix20220607\Symfony * * @throws ServiceNotFoundException if the service definition does not exist */ - public final function get(string $id) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ServiceConfigurator + public final function get(string $id) : ServiceConfigurator { $this->__destruct(); return $this->parent->get($id); @@ -74,7 +74,7 @@ abstract class AbstractServiceConfigurator extends \RectorPrefix20220607\Symfony /** * Removes an already defined service definition or alias. */ - public final function remove(string $id) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ServicesConfigurator + public final function remove(string $id) : ServicesConfigurator { $this->__destruct(); return $this->parent->remove($id); @@ -84,7 +84,7 @@ abstract class AbstractServiceConfigurator extends \RectorPrefix20220607\Symfony * * @param InlineServiceConfigurator[]|ReferenceConfigurator[] $services */ - public final function stack(string $id, array $services) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\AliasConfigurator + public final function stack(string $id, array $services) : AliasConfigurator { $this->__destruct(); return $this->parent->stack($id, $services); @@ -92,7 +92,7 @@ abstract class AbstractServiceConfigurator extends \RectorPrefix20220607\Symfony /** * Registers a service. */ - public final function __invoke(string $id, string $class = null) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ServiceConfigurator + public final function __invoke(string $id, string $class = null) : ServiceConfigurator { $this->__destruct(); return $this->parent->set($id, $class); diff --git a/vendor/symfony/dependency-injection/Loader/Configurator/AliasConfigurator.php b/vendor/symfony/dependency-injection/Loader/Configurator/AliasConfigurator.php index bee2a12b616..32351bc6a09 100644 --- a/vendor/symfony/dependency-injection/Loader/Configurator/AliasConfigurator.php +++ b/vendor/symfony/dependency-injection/Loader/Configurator/AliasConfigurator.php @@ -14,12 +14,12 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Alias; /** * @author Nicolas Grekas */ -class AliasConfigurator extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\AbstractServiceConfigurator +class AliasConfigurator extends AbstractServiceConfigurator { use Traits\DeprecateTrait; use Traits\PublicTrait; public const FACTORY = 'alias'; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ServicesConfigurator $parent, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Alias $alias) + public function __construct(ServicesConfigurator $parent, Alias $alias) { $this->parent = $parent; $this->definition = $alias; diff --git a/vendor/symfony/dependency-injection/Loader/Configurator/ClosureReferenceConfigurator.php b/vendor/symfony/dependency-injection/Loader/Configurator/ClosureReferenceConfigurator.php index 14a4a401e00..bddb8f7dfe5 100644 --- a/vendor/symfony/dependency-injection/Loader/Configurator/ClosureReferenceConfigurator.php +++ b/vendor/symfony/dependency-injection/Loader/Configurator/ClosureReferenceConfigurator.php @@ -10,6 +10,6 @@ */ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator; -class ClosureReferenceConfigurator extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ReferenceConfigurator +class ClosureReferenceConfigurator extends ReferenceConfigurator { } diff --git a/vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php b/vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php index 184a80c5290..84bf5efa24f 100644 --- a/vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php +++ b/vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php @@ -24,7 +24,7 @@ use RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression; /** * @author Nicolas Grekas */ -class ContainerConfigurator extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\AbstractConfigurator +class ContainerConfigurator extends AbstractConfigurator { public const FACTORY = 'container'; /** @@ -55,7 +55,7 @@ class ContainerConfigurator extends \RectorPrefix20220607\Symfony\Component\Depe * @var string|null */ private $env; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\PhpFileLoader $loader, array &$instanceof, string $path, string $file, string $env = null) + public function __construct(ContainerBuilder $container, PhpFileLoader $loader, array &$instanceof, string $path, string $file, string $env = null) { $this->container = $container; $this->loader = $loader; @@ -67,10 +67,10 @@ class ContainerConfigurator extends \RectorPrefix20220607\Symfony\Component\Depe public final function extension(string $namespace, array $config) { if (!$this->container->hasExtension($namespace)) { - $extensions = \array_filter(\array_map(function (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\ExtensionInterface $ext) { + $extensions = \array_filter(\array_map(function (ExtensionInterface $ext) { return $ext->getAlias(); }, $this->container->getExtensions())); - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('There is no extension able to load the configuration for "%s" (in "%s"). Looked for namespace "%s", found "%s".', $namespace, $this->file, $namespace, $extensions ? \implode('", "', $extensions) : 'none')); + throw new InvalidArgumentException(\sprintf('There is no extension able to load the configuration for "%s" (in "%s"). Looked for namespace "%s", found "%s".', $namespace, $this->file, $namespace, $extensions ? \implode('", "', $extensions) : 'none')); } $this->container->loadFromExtension($namespace, static::processValue($config)); } @@ -82,13 +82,13 @@ class ContainerConfigurator extends \RectorPrefix20220607\Symfony\Component\Depe $this->loader->setCurrentDir(\dirname($this->path)); $this->loader->import($resource, $type, $ignoreErrors, $this->file); } - public final function parameters() : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ParametersConfigurator + public final function parameters() : ParametersConfigurator { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ParametersConfigurator($this->container); + return new ParametersConfigurator($this->container); } - public final function services() : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ServicesConfigurator + public final function services() : ServicesConfigurator { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ServicesConfigurator($this->container, $this->loader, $this->instanceof, $this->path, $this->anonymousCount); + return new ServicesConfigurator($this->container, $this->loader, $this->instanceof, $this->path, $this->anonymousCount); } /** * Get the current environment to be able to write conditional configuration. @@ -115,91 +115,91 @@ class ContainerConfigurator extends \RectorPrefix20220607\Symfony\Component\Depe /** * Creates a parameter. */ -function param(string $name) : \RectorPrefix20220607\Symfony\Component\Config\Loader\ParamConfigurator +function param(string $name) : ParamConfigurator { - return new \RectorPrefix20220607\Symfony\Component\Config\Loader\ParamConfigurator($name); + return new ParamConfigurator($name); } /** * Creates a reference to a service. */ -function service(string $serviceId) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ReferenceConfigurator +function service(string $serviceId) : ReferenceConfigurator { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ReferenceConfigurator($serviceId); + return new ReferenceConfigurator($serviceId); } /** * Creates an inline service. */ -function inline_service(string $class = null) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\InlineServiceConfigurator +function inline_service(string $class = null) : InlineServiceConfigurator { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\InlineServiceConfigurator(new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition($class)); + return new InlineServiceConfigurator(new Definition($class)); } /** * Creates a service locator. * * @param ReferenceConfigurator[] $values */ -function service_locator(array $values) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument +function service_locator(array $values) : ServiceLocatorArgument { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\AbstractConfigurator::processValue($values, \true)); + return new ServiceLocatorArgument(AbstractConfigurator::processValue($values, \true)); } /** * Creates a lazy iterator. * * @param ReferenceConfigurator[] $values */ -function iterator(array $values) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\IteratorArgument +function iterator(array $values) : IteratorArgument { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\IteratorArgument(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\AbstractConfigurator::processValue($values, \true)); + return new IteratorArgument(AbstractConfigurator::processValue($values, \true)); } /** * Creates a lazy iterator by tag name. * @param string|mixed[] $exclude */ -function tagged_iterator(string $tag, string $indexAttribute = null, string $defaultIndexMethod = null, string $defaultPriorityMethod = null, $exclude = []) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument +function tagged_iterator(string $tag, string $indexAttribute = null, string $defaultIndexMethod = null, string $defaultPriorityMethod = null, $exclude = []) : TaggedIteratorArgument { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument($tag, $indexAttribute, $defaultIndexMethod, \false, $defaultPriorityMethod, (array) $exclude); + return new TaggedIteratorArgument($tag, $indexAttribute, $defaultIndexMethod, \false, $defaultPriorityMethod, (array) $exclude); } /** * Creates a service locator by tag name. * @param string|mixed[] $exclude */ -function tagged_locator(string $tag, string $indexAttribute = null, string $defaultIndexMethod = null, string $defaultPriorityMethod = null, $exclude = []) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument +function tagged_locator(string $tag, string $indexAttribute = null, string $defaultIndexMethod = null, string $defaultPriorityMethod = null, $exclude = []) : ServiceLocatorArgument { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument(new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument($tag, $indexAttribute, $defaultIndexMethod, \true, $defaultPriorityMethod, (array) $exclude)); + return new ServiceLocatorArgument(new TaggedIteratorArgument($tag, $indexAttribute, $defaultIndexMethod, \true, $defaultPriorityMethod, (array) $exclude)); } /** * Creates an expression. */ -function expr(string $expression) : \RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression +function expr(string $expression) : Expression { - return new \RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression($expression); + return new Expression($expression); } /** * Creates an abstract argument. */ -function abstract_arg(string $description) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\AbstractArgument +function abstract_arg(string $description) : AbstractArgument { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\AbstractArgument($description); + return new AbstractArgument($description); } /** * Creates an environment variable reference. */ -function env(string $name) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\EnvConfigurator +function env(string $name) : EnvConfigurator { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\EnvConfigurator($name); + return new EnvConfigurator($name); } /** * Creates a closure service reference. */ -function service_closure(string $serviceId) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ClosureReferenceConfigurator +function service_closure(string $serviceId) : ClosureReferenceConfigurator { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ClosureReferenceConfigurator($serviceId); + return new ClosureReferenceConfigurator($serviceId); } /** * Creates a closure. * @param string|mixed[]|\Symfony\Component\DependencyInjection\Loader\Configurator\ReferenceConfigurator|\Symfony\Component\ExpressionLanguage\Expression $callable */ -function closure($callable) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\InlineServiceConfigurator +function closure($callable) : InlineServiceConfigurator { - return (new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\InlineServiceConfigurator(new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition('Closure')))->factory(['Closure', 'fromCallable'])->args([$callable]); + return (new InlineServiceConfigurator(new Definition('Closure')))->factory(['Closure', 'fromCallable'])->args([$callable]); } diff --git a/vendor/symfony/dependency-injection/Loader/Configurator/DefaultsConfigurator.php b/vendor/symfony/dependency-injection/Loader/Configurator/DefaultsConfigurator.php index 0d7aa8e6288..c371b37df1f 100644 --- a/vendor/symfony/dependency-injection/Loader/Configurator/DefaultsConfigurator.php +++ b/vendor/symfony/dependency-injection/Loader/Configurator/DefaultsConfigurator.php @@ -15,7 +15,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\Invalid /** * @author Nicolas Grekas */ -class DefaultsConfigurator extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\AbstractServiceConfigurator +class DefaultsConfigurator extends AbstractServiceConfigurator { use Traits\AutoconfigureTrait; use Traits\AutowireTrait; @@ -26,7 +26,7 @@ class DefaultsConfigurator extends \RectorPrefix20220607\Symfony\Component\Depen * @var string|null */ private $path; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ServicesConfigurator $parent, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, string $path = null) + public function __construct(ServicesConfigurator $parent, Definition $definition, string $path = null) { parent::__construct($parent, $definition, null, []); $this->path = $path; @@ -41,11 +41,11 @@ class DefaultsConfigurator extends \RectorPrefix20220607\Symfony\Component\Depen public final function tag(string $name, array $attributes = []) { if ('' === $name) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('The tag name in "_defaults" must be a non-empty string.'); + throw new InvalidArgumentException('The tag name in "_defaults" must be a non-empty string.'); } foreach ($attributes as $attribute => $value) { if (null !== $value && !\is_scalar($value)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type.', $name, $attribute)); + throw new InvalidArgumentException(\sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type.', $name, $attribute)); } } $this->definition->addTag($name, $attributes); @@ -54,7 +54,7 @@ class DefaultsConfigurator extends \RectorPrefix20220607\Symfony\Component\Depen /** * Defines an instanceof-conditional to be applied to following service definitions. */ - public final function instanceof(string $fqcn) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\InstanceofConfigurator + public final function instanceof(string $fqcn) : InstanceofConfigurator { return $this->parent->instanceof($fqcn); } diff --git a/vendor/symfony/dependency-injection/Loader/Configurator/EnvConfigurator.php b/vendor/symfony/dependency-injection/Loader/Configurator/EnvConfigurator.php index f8057468c25..c61ee00bbd7 100644 --- a/vendor/symfony/dependency-injection/Loader/Configurator/EnvConfigurator.php +++ b/vendor/symfony/dependency-injection/Loader/Configurator/EnvConfigurator.php @@ -11,7 +11,7 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator; use RectorPrefix20220607\Symfony\Component\Config\Loader\ParamConfigurator; -class EnvConfigurator extends \RectorPrefix20220607\Symfony\Component\Config\Loader\ParamConfigurator +class EnvConfigurator extends ParamConfigurator { /** * @var string[] diff --git a/vendor/symfony/dependency-injection/Loader/Configurator/InlineServiceConfigurator.php b/vendor/symfony/dependency-injection/Loader/Configurator/InlineServiceConfigurator.php index 1ec72bb7a80..9df6e4e0966 100644 --- a/vendor/symfony/dependency-injection/Loader/Configurator/InlineServiceConfigurator.php +++ b/vendor/symfony/dependency-injection/Loader/Configurator/InlineServiceConfigurator.php @@ -14,7 +14,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition; /** * @author Nicolas Grekas */ -class InlineServiceConfigurator extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\AbstractConfigurator +class InlineServiceConfigurator extends AbstractConfigurator { use Traits\ArgumentTrait; use Traits\AutowireTrait; @@ -40,7 +40,7 @@ class InlineServiceConfigurator extends \RectorPrefix20220607\Symfony\Component\ * @var string|null */ private $path; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) + public function __construct(Definition $definition) { $this->definition = $definition; } diff --git a/vendor/symfony/dependency-injection/Loader/Configurator/InstanceofConfigurator.php b/vendor/symfony/dependency-injection/Loader/Configurator/InstanceofConfigurator.php index 6ff3b5599dc..937f9e2ffd2 100644 --- a/vendor/symfony/dependency-injection/Loader/Configurator/InstanceofConfigurator.php +++ b/vendor/symfony/dependency-injection/Loader/Configurator/InstanceofConfigurator.php @@ -14,7 +14,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition; /** * @author Nicolas Grekas */ -class InstanceofConfigurator extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\AbstractServiceConfigurator +class InstanceofConfigurator extends AbstractServiceConfigurator { use Traits\AutowireTrait; use Traits\BindTrait; @@ -30,7 +30,7 @@ class InstanceofConfigurator extends \RectorPrefix20220607\Symfony\Component\Dep * @var string|null */ private $path; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ServicesConfigurator $parent, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, string $id, string $path = null) + public function __construct(ServicesConfigurator $parent, Definition $definition, string $id, string $path = null) { parent::__construct($parent, $definition, $id, []); $this->path = $path; diff --git a/vendor/symfony/dependency-injection/Loader/Configurator/ParametersConfigurator.php b/vendor/symfony/dependency-injection/Loader/Configurator/ParametersConfigurator.php index f394aeeabfe..aa36f814f7b 100644 --- a/vendor/symfony/dependency-injection/Loader/Configurator/ParametersConfigurator.php +++ b/vendor/symfony/dependency-injection/Loader/Configurator/ParametersConfigurator.php @@ -16,14 +16,14 @@ use RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression; /** * @author Nicolas Grekas */ -class ParametersConfigurator extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\AbstractConfigurator +class ParametersConfigurator extends AbstractConfigurator { public const FACTORY = 'parameters'; /** * @var \Symfony\Component\DependencyInjection\ContainerBuilder */ private $container; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container) + public function __construct(ContainerBuilder $container) { $this->container = $container; } @@ -33,8 +33,8 @@ class ParametersConfigurator extends \RectorPrefix20220607\Symfony\Component\Dep */ public final function set(string $name, $value) { - if ($value instanceof \RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Using an expression in parameter "%s" is not allowed.', $name)); + if ($value instanceof Expression) { + throw new InvalidArgumentException(\sprintf('Using an expression in parameter "%s" is not allowed.', $name)); } $this->container->setParameter($name, static::processValue($value, \true)); return $this; diff --git a/vendor/symfony/dependency-injection/Loader/Configurator/PrototypeConfigurator.php b/vendor/symfony/dependency-injection/Loader/Configurator/PrototypeConfigurator.php index 63e73cf8eb7..68db3fc87ad 100644 --- a/vendor/symfony/dependency-injection/Loader/Configurator/PrototypeConfigurator.php +++ b/vendor/symfony/dependency-injection/Loader/Configurator/PrototypeConfigurator.php @@ -15,7 +15,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\PhpFileLoa /** * @author Nicolas Grekas */ -class PrototypeConfigurator extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\AbstractServiceConfigurator +class PrototypeConfigurator extends AbstractServiceConfigurator { use Traits\AbstractTrait; use Traits\ArgumentTrait; @@ -49,9 +49,9 @@ class PrototypeConfigurator extends \RectorPrefix20220607\Symfony\Component\Depe * @var bool */ private $allowParent; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ServicesConfigurator $parent, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\PhpFileLoader $loader, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $defaults, string $namespace, string $resource, bool $allowParent) + public function __construct(ServicesConfigurator $parent, PhpFileLoader $loader, Definition $defaults, string $namespace, string $resource, bool $allowParent) { - $definition = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition(); + $definition = new Definition(); if (!$defaults->isPublic() || !$defaults->isPrivate()) { $definition->setPublic($defaults->isPublic()); } diff --git a/vendor/symfony/dependency-injection/Loader/Configurator/ReferenceConfigurator.php b/vendor/symfony/dependency-injection/Loader/Configurator/ReferenceConfigurator.php index 214b23829d7..1ae75468983 100644 --- a/vendor/symfony/dependency-injection/Loader/Configurator/ReferenceConfigurator.php +++ b/vendor/symfony/dependency-injection/Loader/Configurator/ReferenceConfigurator.php @@ -14,14 +14,14 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterfac /** * @author Nicolas Grekas */ -class ReferenceConfigurator extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\AbstractConfigurator +class ReferenceConfigurator extends AbstractConfigurator { /** @internal * @var string */ protected $id; /** @internal * @var int */ - protected $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; + protected $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; public function __construct(string $id) { $this->id = $id; @@ -31,7 +31,7 @@ class ReferenceConfigurator extends \RectorPrefix20220607\Symfony\Component\Depe */ public final function ignoreOnInvalid() { - $this->invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_INVALID_REFERENCE; + $this->invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE; return $this; } /** @@ -39,7 +39,7 @@ class ReferenceConfigurator extends \RectorPrefix20220607\Symfony\Component\Depe */ public final function nullOnInvalid() { - $this->invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::NULL_ON_INVALID_REFERENCE; + $this->invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE; return $this; } /** @@ -47,7 +47,7 @@ class ReferenceConfigurator extends \RectorPrefix20220607\Symfony\Component\Depe */ public final function ignoreOnUninitialized() { - $this->invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE; + $this->invalidBehavior = ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE; return $this; } public function __toString() : string diff --git a/vendor/symfony/dependency-injection/Loader/Configurator/ServiceConfigurator.php b/vendor/symfony/dependency-injection/Loader/Configurator/ServiceConfigurator.php index cddf2dc3efe..f84516b27cd 100644 --- a/vendor/symfony/dependency-injection/Loader/Configurator/ServiceConfigurator.php +++ b/vendor/symfony/dependency-injection/Loader/Configurator/ServiceConfigurator.php @@ -15,7 +15,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition; /** * @author Nicolas Grekas */ -class ServiceConfigurator extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\AbstractServiceConfigurator +class ServiceConfigurator extends AbstractServiceConfigurator { use Traits\AbstractTrait; use Traits\ArgumentTrait; @@ -57,7 +57,7 @@ class ServiceConfigurator extends \RectorPrefix20220607\Symfony\Component\Depend * @var bool */ private $destructed = \false; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container, array $instanceof, bool $allowParent, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ServicesConfigurator $parent, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, ?string $id, array $defaultTags, string $path = null) + public function __construct(ContainerBuilder $container, array $instanceof, bool $allowParent, ServicesConfigurator $parent, Definition $definition, ?string $id, array $defaultTags, string $path = null) { $this->container = $container; $this->instanceof = $instanceof; diff --git a/vendor/symfony/dependency-injection/Loader/Configurator/ServicesConfigurator.php b/vendor/symfony/dependency-injection/Loader/Configurator/ServicesConfigurator.php index dda594e906a..68aeb9b27ff 100644 --- a/vendor/symfony/dependency-injection/Loader/Configurator/ServicesConfigurator.php +++ b/vendor/symfony/dependency-injection/Loader/Configurator/ServicesConfigurator.php @@ -20,7 +20,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\PhpFileLoa /** * @author Nicolas Grekas */ -class ServicesConfigurator extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\AbstractConfigurator +class ServicesConfigurator extends AbstractConfigurator { public const FACTORY = 'services'; /** @@ -51,31 +51,31 @@ class ServicesConfigurator extends \RectorPrefix20220607\Symfony\Component\Depen * @var int */ private $anonymousCount; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\PhpFileLoader $loader, array &$instanceof, string $path = null, int &$anonymousCount = 0) + public function __construct(ContainerBuilder $container, PhpFileLoader $loader, array &$instanceof, string $path = null, int &$anonymousCount = 0) { - $this->defaults = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition(); + $this->defaults = new Definition(); $this->container = $container; $this->loader = $loader; $this->instanceof =& $instanceof; $this->path = $path; - $this->anonymousHash = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder::hash($path ?: \mt_rand()); + $this->anonymousHash = ContainerBuilder::hash($path ?: \mt_rand()); $this->anonymousCount =& $anonymousCount; $instanceof = []; } /** * Defines a set of defaults for following service definitions. */ - public final function defaults() : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\DefaultsConfigurator + public final function defaults() : DefaultsConfigurator { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\DefaultsConfigurator($this, $this->defaults = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition(), $this->path); + return new DefaultsConfigurator($this, $this->defaults = new Definition(), $this->path); } /** * Defines an instanceof-conditional to be applied to following service definitions. */ - public final function instanceof(string $fqcn) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\InstanceofConfigurator + public final function instanceof(string $fqcn) : InstanceofConfigurator { - $this->instanceof[$fqcn] = $definition = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition(''); - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\InstanceofConfigurator($this, $definition, $fqcn, $this->path); + $this->instanceof[$fqcn] = $definition = new ChildDefinition(''); + return new InstanceofConfigurator($this, $definition, $fqcn, $this->path); } /** * Registers a service. @@ -86,7 +86,7 @@ class ServicesConfigurator extends \RectorPrefix20220607\Symfony\Component\Depen public function set(?string $id, string $class = null) : \Rector\Core\DependencyInjection\Loader\Configurator\RectorServiceConfigurator { $defaults = $this->defaults; - $definition = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition(); + $definition = new Definition(); if (null === $id) { if (!$class) { throw new \LogicException('Anonymous services must have a class name.'); @@ -117,42 +117,42 @@ class ServicesConfigurator extends \RectorPrefix20220607\Symfony\Component\Depen /** * Creates an alias. */ - public final function alias(string $id, string $referencedId) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\AliasConfigurator + public final function alias(string $id, string $referencedId) : AliasConfigurator { $ref = static::processValue($referencedId, \true); - $alias = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Alias((string) $ref); + $alias = new Alias((string) $ref); if (!$this->defaults->isPublic() || !$this->defaults->isPrivate()) { $alias->setPublic($this->defaults->isPublic()); } $this->container->setAlias($id, $alias); - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\AliasConfigurator($this, $alias); + return new AliasConfigurator($this, $alias); } /** * Registers a PSR-4 namespace using a glob pattern. */ - public final function load(string $namespace, string $resource) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\PrototypeConfigurator + public final function load(string $namespace, string $resource) : PrototypeConfigurator { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\PrototypeConfigurator($this, $this->loader, $this->defaults, $namespace, $resource, \true); + return new PrototypeConfigurator($this, $this->loader, $this->defaults, $namespace, $resource, \true); } /** * Gets an already defined service definition. * * @throws ServiceNotFoundException if the service definition does not exist */ - public final function get(string $id) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ServiceConfigurator + public final function get(string $id) : ServiceConfigurator { $definition = $this->container->getDefinition($id); - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ServiceConfigurator($this->container, $definition->getInstanceofConditionals(), \true, $this, $definition, $id, []); + return new ServiceConfigurator($this->container, $definition->getInstanceofConditionals(), \true, $this, $definition, $id, []); } /** * Registers a stack of decorator services. * * @param InlineServiceConfigurator[]|ReferenceConfigurator[] $services */ - public final function stack(string $id, array $services) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\AliasConfigurator + public final function stack(string $id, array $services) : AliasConfigurator { foreach ($services as $i => $service) { - if ($service instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\InlineServiceConfigurator) { + if ($service instanceof InlineServiceConfigurator) { $definition = $service->definition->setInstanceofConditionals($this->instanceof); $changes = $definition->getChanges(); $definition->setAutowired((isset($changes['autowired']) ? $definition : $this->defaults)->isAutowired()); @@ -160,8 +160,8 @@ class ServicesConfigurator extends \RectorPrefix20220607\Symfony\Component\Depen $definition->setBindings(\array_merge($this->defaults->getBindings(), $definition->getBindings())); $definition->setChanges($changes); $services[$i] = $definition; - } elseif (!$service instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ReferenceConfigurator) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('"%s()" expects a list of definitions as returned by "%s()" or "%s()", "%s" given at index "%s" for service "%s".', __METHOD__, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\InlineServiceConfigurator::FACTORY, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ReferenceConfigurator::FACTORY, $service instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\AbstractConfigurator ? $service::FACTORY . '()' : \get_debug_type($service), $i, $id)); + } elseif (!$service instanceof ReferenceConfigurator) { + throw new InvalidArgumentException(\sprintf('"%s()" expects a list of definitions as returned by "%s()" or "%s()", "%s" given at index "%s" for service "%s".', __METHOD__, InlineServiceConfigurator::FACTORY, ReferenceConfigurator::FACTORY, $service instanceof AbstractConfigurator ? $service::FACTORY . '()' : \get_debug_type($service), $i, $id)); } } $alias = $this->alias($id, ''); @@ -171,7 +171,7 @@ class ServicesConfigurator extends \RectorPrefix20220607\Symfony\Component\Depen /** * Registers a service. */ - public final function __invoke(string $id, string $class = null) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ServiceConfigurator + public final function __invoke(string $id, string $class = null) : ServiceConfigurator { return $this->set($id, $class); } diff --git a/vendor/symfony/dependency-injection/Loader/Configurator/Traits/BindTrait.php b/vendor/symfony/dependency-injection/Loader/Configurator/Traits/BindTrait.php index 41e919b2d9e..8db00733bab 100644 --- a/vendor/symfony/dependency-injection/Loader/Configurator/Traits/BindTrait.php +++ b/vendor/symfony/dependency-injection/Loader/Configurator/Traits/BindTrait.php @@ -31,8 +31,8 @@ trait BindTrait { $valueOrRef = static::processValue($valueOrRef, \true); $bindings = $this->definition->getBindings(); - $type = $this instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\DefaultsConfigurator ? \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\BoundArgument::DEFAULTS_BINDING : ($this instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\InstanceofConfigurator ? \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\BoundArgument::INSTANCEOF_BINDING : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\BoundArgument::SERVICE_BINDING); - $bindings[$nameOrFqcn] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\BoundArgument($valueOrRef, \true, $type, $this->path ?? null); + $type = $this instanceof DefaultsConfigurator ? BoundArgument::DEFAULTS_BINDING : ($this instanceof InstanceofConfigurator ? BoundArgument::INSTANCEOF_BINDING : BoundArgument::SERVICE_BINDING); + $bindings[$nameOrFqcn] = new BoundArgument($valueOrRef, \true, $type, $this->path ?? null); $this->definition->setBindings($bindings); return $this; } diff --git a/vendor/symfony/dependency-injection/Loader/Configurator/Traits/DecorateTrait.php b/vendor/symfony/dependency-injection/Loader/Configurator/Traits/DecorateTrait.php index db3875863c7..32bf8541b30 100644 --- a/vendor/symfony/dependency-injection/Loader/Configurator/Traits/DecorateTrait.php +++ b/vendor/symfony/dependency-injection/Loader/Configurator/Traits/DecorateTrait.php @@ -23,7 +23,7 @@ trait DecorateTrait * * @throws InvalidArgumentException in case the decorated service id and the new decorated service id are equals */ - public final function decorate(?string $id, string $renamedId = null, int $priority = 0, int $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) + public final function decorate(?string $id, string $renamedId = null, int $priority = 0, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) { $this->definition->setDecoratedService($id, $renamedId, $priority, $invalidBehavior); return $this; diff --git a/vendor/symfony/dependency-injection/Loader/Configurator/Traits/FactoryTrait.php b/vendor/symfony/dependency-injection/Loader/Configurator/Traits/FactoryTrait.php index 02fa536cad9..5deec951ef2 100644 --- a/vendor/symfony/dependency-injection/Loader/Configurator/Traits/FactoryTrait.php +++ b/vendor/symfony/dependency-injection/Loader/Configurator/Traits/FactoryTrait.php @@ -25,9 +25,9 @@ trait FactoryTrait { if (\is_string($factory) && 1 === \substr_count($factory, ':')) { $factoryParts = \explode(':', $factory); - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid factory "%s": the "service:method" notation is not available when using PHP-based DI configuration. Use "[service(\'%s\'), \'%s\']" instead.', $factory, $factoryParts[0], $factoryParts[1])); + throw new InvalidArgumentException(\sprintf('Invalid factory "%s": the "service:method" notation is not available when using PHP-based DI configuration. Use "[service(\'%s\'), \'%s\']" instead.', $factory, $factoryParts[0], $factoryParts[1])); } - if ($factory instanceof \RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression) { + if ($factory instanceof Expression) { $factory = '@=' . $factory; } $this->definition->setFactory(static::processValue($factory, \true)); diff --git a/vendor/symfony/dependency-injection/Loader/Configurator/Traits/ParentTrait.php b/vendor/symfony/dependency-injection/Loader/Configurator/Traits/ParentTrait.php index bddb2b4c3ac..a95fe7524fc 100644 --- a/vendor/symfony/dependency-injection/Loader/Configurator/Traits/ParentTrait.php +++ b/vendor/symfony/dependency-injection/Loader/Configurator/Traits/ParentTrait.php @@ -24,9 +24,9 @@ trait ParentTrait public final function parent(string $parent) { if (!$this->allowParent) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('A parent cannot be defined when either "_instanceof" or "_defaults" are also defined for service prototype "%s".', $this->id)); + throw new InvalidArgumentException(\sprintf('A parent cannot be defined when either "_instanceof" or "_defaults" are also defined for service prototype "%s".', $this->id)); } - if ($this->definition instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition) { + if ($this->definition instanceof ChildDefinition) { $this->definition->setParent($parent); } else { // cast Definition to ChildDefinition diff --git a/vendor/symfony/dependency-injection/Loader/Configurator/Traits/TagTrait.php b/vendor/symfony/dependency-injection/Loader/Configurator/Traits/TagTrait.php index a899b93a2b4..44e2b0b10aa 100644 --- a/vendor/symfony/dependency-injection/Loader/Configurator/Traits/TagTrait.php +++ b/vendor/symfony/dependency-injection/Loader/Configurator/Traits/TagTrait.php @@ -21,11 +21,11 @@ trait TagTrait public final function tag(string $name, array $attributes = []) { if ('' === $name) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The tag name for service "%s" must be a non-empty string.', $this->id)); + throw new InvalidArgumentException(\sprintf('The tag name for service "%s" must be a non-empty string.', $this->id)); } foreach ($attributes as $attribute => $value) { if (!\is_scalar($value) && null !== $value) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('A tag attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s".', $this->id, $name, $attribute)); + throw new InvalidArgumentException(\sprintf('A tag attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s".', $this->id, $name, $attribute)); } } $this->definition->addTag($name, $attributes); diff --git a/vendor/symfony/dependency-injection/Loader/DirectoryLoader.php b/vendor/symfony/dependency-injection/Loader/DirectoryLoader.php index a39f397dfee..a39da017942 100644 --- a/vendor/symfony/dependency-injection/Loader/DirectoryLoader.php +++ b/vendor/symfony/dependency-injection/Loader/DirectoryLoader.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader; * * @author Sebastien Lavoie */ -class DirectoryLoader extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\FileLoader +class DirectoryLoader extends FileLoader { /** * {@inheritdoc} diff --git a/vendor/symfony/dependency-injection/Loader/FileLoader.php b/vendor/symfony/dependency-injection/Loader/FileLoader.php index ee46ec4577b..77d506792ac 100644 --- a/vendor/symfony/dependency-injection/Loader/FileLoader.php +++ b/vendor/symfony/dependency-injection/Loader/FileLoader.php @@ -27,7 +27,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\Invalid * * @author Fabien Potencier */ -abstract class FileLoader extends \RectorPrefix20220607\Symfony\Component\Config\Loader\FileLoader +abstract class FileLoader extends BaseFileLoader { public const ANONYMOUS_ID_REGEXP = '/^\\.\\d+_[^~]*+~[._a-zA-Z\\d]{7}$/'; protected $container; @@ -36,7 +36,7 @@ abstract class FileLoader extends \RectorPrefix20220607\Symfony\Component\Config protected $interfaces = []; protected $singlyImplemented = []; protected $autoRegisterAliasesForSinglyImplementedInterfaces = \true; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container, \RectorPrefix20220607\Symfony\Component\Config\FileLocatorInterface $locator, string $env = null) + public function __construct(ContainerBuilder $container, FileLocatorInterface $locator, string $env = null) { $this->container = $container; parent::__construct($locator, $env); @@ -58,12 +58,12 @@ abstract class FileLoader extends \RectorPrefix20220607\Symfony\Component\Config } try { return parent::import(...$args); - } catch (\RectorPrefix20220607\Symfony\Component\Config\Exception\LoaderLoadException $e) { - if (!$ignoreNotFound || !($prev = $e->getPrevious()) instanceof \RectorPrefix20220607\Symfony\Component\Config\Exception\FileLocatorFileNotFoundException) { + } catch (LoaderLoadException $e) { + if (!$ignoreNotFound || !($prev = $e->getPrevious()) instanceof FileLocatorFileNotFoundException) { throw $e; } foreach ($prev->getTrace() as $frame) { - if ('import' === ($frame['function'] ?? null) && \is_a($frame['class'] ?? '', \RectorPrefix20220607\Symfony\Component\Config\Loader\Loader::class, \true)) { + if ('import' === ($frame['function'] ?? null) && \is_a($frame['class'] ?? '', Loader::class, \true)) { break; } } @@ -81,15 +81,15 @@ abstract class FileLoader extends \RectorPrefix20220607\Symfony\Component\Config * @param string $resource The directory to look for classes, glob-patterns allowed * @param string|mixed[] $exclude A globbed path of files to exclude or an array of globbed paths of files to exclude */ - public function registerClasses(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $prototype, string $namespace, string $resource, $exclude = null) + public function registerClasses(Definition $prototype, string $namespace, string $resource, $exclude = null) { if (\substr_compare($namespace, '\\', -\strlen('\\')) !== 0) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Namespace prefix must end with a "\\": "%s".', $namespace)); + throw new InvalidArgumentException(\sprintf('Namespace prefix must end with a "\\": "%s".', $namespace)); } if (!\preg_match('/^(?:[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*+\\\\)++$/', $namespace)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Namespace is not a valid PSR-4 prefix: "%s".', $namespace)); + throw new InvalidArgumentException(\sprintf('Namespace is not a valid PSR-4 prefix: "%s".', $namespace)); } - $autoconfigureAttributes = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\RegisterAutoconfigureAttributesPass(); + $autoconfigureAttributes = new RegisterAutoconfigureAttributesPass(); $autoconfigureAttributes = $autoconfigureAttributes->accept($prototype) ? $autoconfigureAttributes : null; $classes = $this->findClasses($namespace, $resource, (array) $exclude, $autoconfigureAttributes); // prepare for deep cloning @@ -98,7 +98,7 @@ abstract class FileLoader extends \RectorPrefix20220607\Symfony\Component\Config if (null === $errorMessage && $autoconfigureAttributes && $this->env) { $r = $this->container->getReflectionClass($class); $attribute = null; - foreach ($r->getAttributes(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Attribute\When::class) as $attribute) { + foreach ($r->getAttributes(When::class) as $attribute) { if ($this->env === $attribute->newInstance()->env) { $attribute = null; break; @@ -137,19 +137,19 @@ abstract class FileLoader extends \RectorPrefix20220607\Symfony\Component\Config /** * Registers a definition in the container with its instanceof-conditionals. */ - protected function setDefinition(string $id, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) + protected function setDefinition(string $id, Definition $definition) { $this->container->removeBindings($id); if ($this->isLoadingInstanceof) { - if (!$definition instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid type definition "%s": ChildDefinition expected, "%s" given.', $id, \get_debug_type($definition))); + if (!$definition instanceof ChildDefinition) { + throw new InvalidArgumentException(\sprintf('Invalid type definition "%s": ChildDefinition expected, "%s" given.', $id, \get_debug_type($definition))); } $this->instanceof[$id] = $definition; } else { $this->container->setDefinition($id, $definition->setInstanceofConditionals($this->instanceof)); } } - private function findClasses(string $namespace, string $pattern, array $excludePatterns, ?\RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\RegisterAutoconfigureAttributesPass $autoconfigureAttributes) : array + private function findClasses(string $namespace, string $pattern, array $excludePatterns, ?RegisterAutoconfigureAttributesPass $autoconfigureAttributes) : array { $parameterBag = $this->container->getParameterBag(); $excludePaths = []; @@ -172,7 +172,7 @@ abstract class FileLoader extends \RectorPrefix20220607\Symfony\Component\Config if (null === $prefixLen) { $prefixLen = \strlen($resource->getPrefix()); if ($excludePrefix && \strncmp($excludePrefix, $resource->getPrefix(), \strlen($resource->getPrefix())) !== 0) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid "exclude" pattern when importing classes for "%s": make sure your "exclude" pattern (%s) is a subset of the "resource" pattern (%s).', $namespace, $excludePattern, $pattern)); + throw new InvalidArgumentException(\sprintf('Invalid "exclude" pattern when importing classes for "%s": make sure your "exclude" pattern (%s) is a subset of the "resource" pattern (%s).', $namespace, $excludePattern, $pattern)); } } if (isset($excludePaths[\str_replace('\\', '/', $path)])) { @@ -193,7 +193,7 @@ abstract class FileLoader extends \RectorPrefix20220607\Symfony\Component\Config } // check to make sure the expected class exists if (!$r) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Expected to find class "%s" in file "%s" while importing services from resource "%s", but it was not found! Check the namespace prefix used with the resource.', $class, $path, $pattern)); + throw new InvalidArgumentException(\sprintf('Expected to find class "%s" in file "%s" while importing services from resource "%s", but it was not found! Check the namespace prefix used with the resource.', $class, $path, $pattern)); } if ($r->isInstantiable() || $r->isInterface()) { $classes[$class] = null; @@ -203,7 +203,7 @@ abstract class FileLoader extends \RectorPrefix20220607\Symfony\Component\Config } } // track only for new & removed files - if ($resource instanceof \RectorPrefix20220607\Symfony\Component\Config\Resource\GlobResource) { + if ($resource instanceof GlobResource) { $this->container->addResource($resource); } else { foreach ($resource as $path) { diff --git a/vendor/symfony/dependency-injection/Loader/GlobFileLoader.php b/vendor/symfony/dependency-injection/Loader/GlobFileLoader.php index 0be9c79372f..3e186ade6b7 100644 --- a/vendor/symfony/dependency-injection/Loader/GlobFileLoader.php +++ b/vendor/symfony/dependency-injection/Loader/GlobFileLoader.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader; * * @author Nicolas Grekas */ -class GlobFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\FileLoader +class GlobFileLoader extends FileLoader { /** * {@inheritdoc} diff --git a/vendor/symfony/dependency-injection/Loader/IniFileLoader.php b/vendor/symfony/dependency-injection/Loader/IniFileLoader.php index a6b44b1758f..3e4cc4be924 100644 --- a/vendor/symfony/dependency-injection/Loader/IniFileLoader.php +++ b/vendor/symfony/dependency-injection/Loader/IniFileLoader.php @@ -17,7 +17,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\Invalid * * @author Fabien Potencier */ -class IniFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\FileLoader +class IniFileLoader extends FileLoader { /** * {@inheritdoc} @@ -31,7 +31,7 @@ class IniFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn // first pass to catch parsing errors $result = \parse_ini_file($path, \true); if (\false === $result || [] === $result) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The "%s" file is not valid.', $resource)); + throw new InvalidArgumentException(\sprintf('The "%s" file is not valid.', $resource)); } // real raw parsing $result = \parse_ini_file($path, \true, \INI_SCANNER_RAW); @@ -87,7 +87,7 @@ class IniFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn case isset($value[1]) && ("'" === $value[0] && "'" === $value[\strlen($value) - 1] || '"' === $value[0] && '"' === $value[\strlen($value) - 1]): return \substr($value, 1, -1); default: - return \RectorPrefix20220607\Symfony\Component\Config\Util\XmlUtils::phpize($value); + return XmlUtils::phpize($value); } } } diff --git a/vendor/symfony/dependency-injection/Loader/PhpFileLoader.php b/vendor/symfony/dependency-injection/Loader/PhpFileLoader.php index d5ca86ce338..a455d132514 100644 --- a/vendor/symfony/dependency-injection/Loader/PhpFileLoader.php +++ b/vendor/symfony/dependency-injection/Loader/PhpFileLoader.php @@ -20,7 +20,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder; use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface; use RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\ExtensionInterface; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; /** * PhpFileLoader loads service definitions from a PHP file. * @@ -29,14 +29,14 @@ use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigura * * @author Fabien Potencier */ -class PhpFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\FileLoader +class PhpFileLoader extends FileLoader { protected $autoRegisterAliasesForSinglyImplementedInterfaces = \false; /** * @var \Symfony\Component\Config\Builder\ConfigBuilderGeneratorInterface|null */ private $generator; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $container, \RectorPrefix20220607\Symfony\Component\Config\FileLocatorInterface $locator, string $env = null, \RectorPrefix20220607\Symfony\Component\Config\Builder\ConfigBuilderGeneratorInterface $generator = null) + public function __construct(ContainerBuilder $container, FileLocatorInterface $locator, string $env = null, ConfigBuilderGeneratorInterface $generator = null) { parent::__construct($container, $locator, $env); $this->generator = $generator; @@ -57,7 +57,7 @@ class PhpFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn // the closure forbids access to the private scope in the included file $load = \Closure::bind(function ($path, $env) use($container, $loader, $resource, $type) { return include $path; - }, $this, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\ProtectedPhpFileLoader::class); + }, $this, ProtectedPhpFileLoader::class); try { $callback = $load($path, $this->env); if (\is_object($callback) && \is_callable($callback)) { @@ -89,14 +89,14 @@ class PhpFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn /** * Resolve the parameters to the $callback and execute it. */ - private function executeCallback(callable $callback, \Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator, string $path) + private function executeCallback(callable $callback, ContainerConfigurator $containerConfigurator, string $path) { $callback = \Closure::fromCallable($callback); $arguments = []; $configBuilders = []; $r = new \ReflectionFunction($callback); $attribute = null; - foreach (\method_exists($r, 'getAttributes') ? $r->getAttributes(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Attribute\When::class) : [] as $attribute) { + foreach (\method_exists($r, 'getAttributes') ? $r->getAttributes(When::class) : [] as $attribute) { if ($this->env === $attribute->newInstance()->env) { $attribute = null; break; @@ -108,24 +108,24 @@ class PhpFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn foreach ($r->getParameters() as $parameter) { $reflectionType = $parameter->getType(); if (!$reflectionType instanceof \ReflectionNamedType) { - throw new \InvalidArgumentException(\sprintf('Could not resolve argument "$%s" for "%s". You must typehint it (for example with "%s" or "%s").', $parameter->getName(), $path, \Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator::class, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder::class)); + throw new \InvalidArgumentException(\sprintf('Could not resolve argument "$%s" for "%s". You must typehint it (for example with "%s" or "%s").', $parameter->getName(), $path, ContainerConfigurator::class, ContainerBuilder::class)); } $type = $reflectionType->getName(); - if (\is_a($type, \Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator::class, \true)) { + if (\is_a($type, ContainerConfigurator::class, \true)) { $arguments[] = $containerConfigurator; } else { switch ($type) { - case \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder::class: + case ContainerBuilder::class: $arguments[] = $this->container; break; - case \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\FileLoader::class: + case FileLoader::class: case self::class: $arguments[] = $this; break; default: try { $configBuilder = $this->configBuilder($type); - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException|\LogicException $e) { + } catch (InvalidArgumentException|\LogicException $e) { throw new \InvalidArgumentException(\sprintf('Could not resolve argument "%s" for "%s".', $type . ' $' . $parameter->getName(), $path), 0, $e); } $configBuilders[] = $configBuilder; @@ -134,7 +134,7 @@ class PhpFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn } } // Force load ContainerConfigurator to make env(), param() etc available. - \class_exists(\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator::class); + \class_exists(ContainerConfigurator::class); $callback(...$arguments); /** @var ConfigBuilderInterface $configBuilder */ foreach ($configBuilders as $configBuilder) { @@ -144,36 +144,36 @@ class PhpFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn /** * @param string $namespace FQCN string for a class implementing ConfigBuilderInterface */ - private function configBuilder(string $namespace) : \RectorPrefix20220607\Symfony\Component\Config\Builder\ConfigBuilderInterface + private function configBuilder(string $namespace) : ConfigBuilderInterface { - if (!\class_exists(\RectorPrefix20220607\Symfony\Component\Config\Builder\ConfigBuilderGenerator::class)) { + if (!\class_exists(ConfigBuilderGenerator::class)) { throw new \LogicException('You cannot use the config builder as the Config component is not installed. Try running "composer require symfony/config".'); } if (null === $this->generator) { throw new \LogicException('You cannot use the ConfigBuilders without providing a class implementing ConfigBuilderGeneratorInterface.'); } // If class exists and implements ConfigBuilderInterface - if (\class_exists($namespace) && \is_subclass_of($namespace, \RectorPrefix20220607\Symfony\Component\Config\Builder\ConfigBuilderInterface::class)) { + if (\class_exists($namespace) && \is_subclass_of($namespace, ConfigBuilderInterface::class)) { return new $namespace(); } // If it does not start with Symfony\Config\ we dont know how to handle this if (\strncmp($namespace, 'Symfony\\Config\\', \strlen('Symfony\\Config\\')) !== 0) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Could not find or generate class "%s".', $namespace)); + throw new InvalidArgumentException(\sprintf('Could not find or generate class "%s".', $namespace)); } // Try to get the extension alias - $alias = \RectorPrefix20220607\Symfony\Component\DependencyInjection\Container::underscore(\substr($namespace, 15, -6)); + $alias = Container::underscore(\substr($namespace, 15, -6)); if (\strpos($alias, '\\') !== \false) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('You can only use "root" ConfigBuilders from "Symfony\\Config\\" namespace. Nested classes like "Symfony\\Config\\Framework\\CacheConfig" cannot be used.'); + throw new InvalidArgumentException('You can only use "root" ConfigBuilders from "Symfony\\Config\\" namespace. Nested classes like "Symfony\\Config\\Framework\\CacheConfig" cannot be used.'); } if (!$this->container->hasExtension($alias)) { - $extensions = \array_filter(\array_map(function (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\ExtensionInterface $ext) { + $extensions = \array_filter(\array_map(function (ExtensionInterface $ext) { return $ext->getAlias(); }, $this->container->getExtensions())); - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('There is no extension able to load the configuration for "%s". Looked for namespace "%s", found "%s".', $namespace, $alias, $extensions ? \implode('", "', $extensions) : 'none')); + throw new InvalidArgumentException(\sprintf('There is no extension able to load the configuration for "%s". Looked for namespace "%s", found "%s".', $namespace, $alias, $extensions ? \implode('", "', $extensions) : 'none')); } $extension = $this->container->getExtension($alias); - if (!$extension instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface) { - throw new \LogicException(\sprintf('You cannot use the config builder for "%s" because the extension does not implement "%s".', $namespace, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface::class)); + if (!$extension instanceof ConfigurationExtensionInterface) { + throw new \LogicException(\sprintf('You cannot use the config builder for "%s" because the extension does not implement "%s".', $namespace, ConfigurationExtensionInterface::class)); } $configuration = $extension->getConfiguration([], $this->container); $loader = $this->generator->build($configuration); @@ -183,6 +183,6 @@ class PhpFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn /** * @internal */ -final class ProtectedPhpFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\PhpFileLoader +final class ProtectedPhpFileLoader extends PhpFileLoader { } diff --git a/vendor/symfony/dependency-injection/Loader/XmlFileLoader.php b/vendor/symfony/dependency-injection/Loader/XmlFileLoader.php index 63fb33ff44e..972ef93b6c6 100644 --- a/vendor/symfony/dependency-injection/Loader/XmlFileLoader.php +++ b/vendor/symfony/dependency-injection/Loader/XmlFileLoader.php @@ -32,7 +32,7 @@ use RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression; * * @author Fabien Potencier */ -class XmlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\FileLoader +class XmlFileLoader extends FileLoader { public const NS = 'http://symfony.com/schema/dic/services'; protected $autoRegisterAliasesForSinglyImplementedInterfaces = \false; @@ -111,10 +111,10 @@ class XmlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn $defaultDirectory = \dirname($file); foreach ($imports as $import) { $this->setCurrentDir($defaultDirectory); - $this->import($import->getAttribute('resource'), \RectorPrefix20220607\Symfony\Component\Config\Util\XmlUtils::phpize($import->getAttribute('type')) ?: null, \RectorPrefix20220607\Symfony\Component\Config\Util\XmlUtils::phpize($import->getAttribute('ignore-errors')) ?: \false, $file); + $this->import($import->getAttribute('resource'), XmlUtils::phpize($import->getAttribute('type')) ?: null, XmlUtils::phpize($import->getAttribute('ignore-errors')) ?: \false, $file); } } - private function parseDefinitions(\DOMDocument $xml, string $file, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $defaults, \DOMNode $root = null) + private function parseDefinitions(\DOMDocument $xml, string $file, Definition $defaults, \DOMNode $root = null) { $xpath = new \DOMXPath($xml); $xpath->registerNamespace('container', self::NS); @@ -126,7 +126,7 @@ class XmlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn $this->isLoadingInstanceof = \true; $instanceof = $xpath->query('.//container:services/container:instanceof', $root); foreach ($instanceof as $service) { - $this->setDefinition((string) $service->getAttribute('id'), $this->parseDefinition($service, $file, new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition())); + $this->setDefinition((string) $service->getAttribute('id'), $this->parseDefinition($service, $file, new Definition())); } $this->isLoadingInstanceof = \false; foreach ($services as $service) { @@ -140,7 +140,7 @@ class XmlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn $frame->setAttribute('id', $id . '" at index "' . $k); if ($alias = $frame->getAttribute('alias')) { $this->validateAlias($frame, $file); - $stack[$k] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($alias); + $stack[$k] = new Reference($alias); } else { $stack[$k] = $this->parseDefinition($frame, $file, $defaults)->setInstanceofConditionals($this->instanceof); } @@ -151,7 +151,7 @@ class XmlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn $excludes = \array_column($this->getChildren($service, 'exclude'), 'nodeValue'); if ($service->hasAttribute('exclude')) { if (\count($excludes) > 0) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('You cannot use both the attribute "exclude" and tags at the same time.'); + throw new InvalidArgumentException('You cannot use both the attribute "exclude" and tags at the same time.'); } $excludes = [$service->getAttribute('exclude')]; } @@ -162,26 +162,26 @@ class XmlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn } } } - private function getServiceDefaults(\DOMDocument $xml, string $file, \DOMNode $root = null) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition + private function getServiceDefaults(\DOMDocument $xml, string $file, \DOMNode $root = null) : Definition { $xpath = new \DOMXPath($xml); $xpath->registerNamespace('container', self::NS); if (null === ($defaultsNode = $xpath->query('.//container:services/container:defaults', $root)->item(0))) { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition(); + return new Definition(); } $defaultsNode->setAttribute('id', ''); - return $this->parseDefinition($defaultsNode, $file, new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition()); + return $this->parseDefinition($defaultsNode, $file, new Definition()); } /** * Parses an individual Definition. */ - private function parseDefinition(\DOMElement $service, string $file, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $defaults) : ?\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition + private function parseDefinition(\DOMElement $service, string $file, Definition $defaults) : ?Definition { if ($alias = $service->getAttribute('alias')) { $this->validateAlias($service, $file); - $this->container->setAlias($service->getAttribute('id'), $alias = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Alias($alias)); + $this->container->setAlias($service->getAttribute('id'), $alias = new Alias($alias)); if ($publicAttr = $service->getAttribute('public')) { - $alias->setPublic(\RectorPrefix20220607\Symfony\Component\Config\Util\XmlUtils::phpize($publicAttr)); + $alias->setPublic(XmlUtils::phpize($publicAttr)); } elseif ($defaults->getChanges()['public'] ?? \false) { $alias->setPublic($defaults->isPublic()); } @@ -190,21 +190,21 @@ class XmlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn $package = $deprecated[0]->getAttribute('package') ?: ''; $version = $deprecated[0]->getAttribute('version') ?: ''; if (!$deprecated[0]->hasAttribute('package')) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Missing attribute "package" at node "deprecated" in "%s".', $file)); + throw new InvalidArgumentException(\sprintf('Missing attribute "package" at node "deprecated" in "%s".', $file)); } if (!$deprecated[0]->hasAttribute('version')) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Missing attribute "version" at node "deprecated" in "%s".', $file)); + throw new InvalidArgumentException(\sprintf('Missing attribute "version" at node "deprecated" in "%s".', $file)); } $alias->setDeprecated($package, $version, $message); } return null; } if ($this->isLoadingInstanceof) { - $definition = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition(''); + $definition = new ChildDefinition(''); } elseif ($parent = $service->getAttribute('parent')) { - $definition = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition($parent); + $definition = new ChildDefinition($parent); } else { - $definition = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition(); + $definition = new Definition(); } if ($defaults->getChanges()['public'] ?? \false) { $definition->setPublic($defaults->isPublic()); @@ -215,20 +215,20 @@ class XmlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn foreach (['class', 'public', 'shared', 'synthetic', 'abstract'] as $key) { if ($value = $service->getAttribute($key)) { $method = 'set' . $key; - $definition->{$method}($value = \RectorPrefix20220607\Symfony\Component\Config\Util\XmlUtils::phpize($value)); + $definition->{$method}($value = XmlUtils::phpize($value)); } } if ($value = $service->getAttribute('lazy')) { - $definition->setLazy((bool) ($value = \RectorPrefix20220607\Symfony\Component\Config\Util\XmlUtils::phpize($value))); + $definition->setLazy((bool) ($value = XmlUtils::phpize($value))); if (\is_string($value)) { $definition->addTag('proxy', ['interface' => $value]); } } if ($value = $service->getAttribute('autowire')) { - $definition->setAutowired(\RectorPrefix20220607\Symfony\Component\Config\Util\XmlUtils::phpize($value)); + $definition->setAutowired(XmlUtils::phpize($value)); } if ($value = $service->getAttribute('autoconfigure')) { - $definition->setAutoconfigured(\RectorPrefix20220607\Symfony\Component\Config\Util\XmlUtils::phpize($value)); + $definition->setAutoconfigured(XmlUtils::phpize($value)); } if ($files = $this->getChildren($service, 'file')) { $definition->setFile($files[0]->nodeValue); @@ -238,27 +238,27 @@ class XmlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn $package = $deprecated[0]->getAttribute('package') ?: ''; $version = $deprecated[0]->getAttribute('version') ?: ''; if (!$deprecated[0]->hasAttribute('package')) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Missing attribute "package" at node "deprecated" in "%s".', $file)); + throw new InvalidArgumentException(\sprintf('Missing attribute "package" at node "deprecated" in "%s".', $file)); } if (!$deprecated[0]->hasAttribute('version')) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Missing attribute "version" at node "deprecated" in "%s".', $file)); + throw new InvalidArgumentException(\sprintf('Missing attribute "version" at node "deprecated" in "%s".', $file)); } $definition->setDeprecated($package, $version, $message); } - $definition->setArguments($this->getArgumentsAsPhp($service, 'argument', $file, $definition instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition)); + $definition->setArguments($this->getArgumentsAsPhp($service, 'argument', $file, $definition instanceof ChildDefinition)); $definition->setProperties($this->getArgumentsAsPhp($service, 'property', $file)); if ($factories = $this->getChildren($service, 'factory')) { $factory = $factories[0]; if ($function = $factory->getAttribute('function')) { $definition->setFactory($function); } elseif ($expression = $factory->getAttribute('expression')) { - if (!\class_exists(\RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression::class)) { + if (!\class_exists(Expression::class)) { throw new \LogicException('The "expression" attribute cannot be used on factories without the ExpressionLanguage component. Try running "composer require symfony/expression-language".'); } $definition->setFactory('@=' . $expression); } else { if ($childService = $factory->getAttribute('service')) { - $class = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($childService, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE); + $class = new Reference($childService, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE); } else { $class = $factory->hasAttribute('class') ? $factory->getAttribute('class') : null; } @@ -271,7 +271,7 @@ class XmlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn $definition->setConfigurator($function); } else { if ($childService = $configurator->getAttribute('service')) { - $class = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($childService, \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE); + $class = new Reference($childService, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE); } else { $class = $configurator->getAttribute('class'); } @@ -279,7 +279,7 @@ class XmlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn } } foreach ($this->getChildren($service, 'call') as $call) { - $definition->addMethodCall($call->getAttribute('method'), $this->getArgumentsAsPhp($call, 'argument', $file), \RectorPrefix20220607\Symfony\Component\Config\Util\XmlUtils::phpize($call->getAttribute('returns-clone'))); + $definition->addMethodCall($call->getAttribute('method'), $this->getArgumentsAsPhp($call, 'argument', $file), XmlUtils::phpize($call->getAttribute('returns-clone'))); } $tags = $this->getChildren($service, 'tag'); foreach ($tags as $tag) { @@ -290,21 +290,21 @@ class XmlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn continue; } if (\strpos($name, '-') !== \false && \strpos($name, '_') === \false && !\array_key_exists($normalizedName = \str_replace('-', '_', $name), $parameters)) { - $parameters[$normalizedName] = \RectorPrefix20220607\Symfony\Component\Config\Util\XmlUtils::phpize($node->nodeValue); + $parameters[$normalizedName] = XmlUtils::phpize($node->nodeValue); } // keep not normalized key - $parameters[$name] = \RectorPrefix20220607\Symfony\Component\Config\Util\XmlUtils::phpize($node->nodeValue); + $parameters[$name] = XmlUtils::phpize($node->nodeValue); } if ('' === $tagName && '' === ($tagName = $tag->getAttribute('name'))) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The tag name for service "%s" in "%s" must be a non-empty string.', $service->getAttribute('id'), $file)); + throw new InvalidArgumentException(\sprintf('The tag name for service "%s" in "%s" must be a non-empty string.', $service->getAttribute('id'), $file)); } $definition->addTag($tagName, $parameters); } $definition->setTags(\array_merge_recursive($definition->getTags(), $defaults->getTags())); $bindings = $this->getArgumentsAsPhp($service, 'bind', $file); - $bindingType = $this->isLoadingInstanceof ? \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\BoundArgument::INSTANCEOF_BINDING : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\BoundArgument::SERVICE_BINDING; + $bindingType = $this->isLoadingInstanceof ? BoundArgument::INSTANCEOF_BINDING : BoundArgument::SERVICE_BINDING; foreach ($bindings as $argument => $value) { - $bindings[$argument] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\BoundArgument($value, \true, $bindingType, $file); + $bindings[$argument] = new BoundArgument($value, \true, $bindingType, $file); } // deep clone, to avoid multiple process of the same instance in the passes $bindings = \array_merge(\unserialize(\serialize($defaults->getBindings())), $bindings); @@ -314,13 +314,13 @@ class XmlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn if ($decorates = $service->getAttribute('decorates')) { $decorationOnInvalid = $service->getAttribute('decoration-on-invalid') ?: 'exception'; if ('exception' === $decorationOnInvalid) { - $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; + $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; } elseif ('ignore' === $decorationOnInvalid) { - $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_INVALID_REFERENCE; + $invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE; } elseif ('null' === $decorationOnInvalid) { - $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::NULL_ON_INVALID_REFERENCE; + $invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE; } else { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid value "%s" for attribute "decoration-on-invalid" on service "%s". Did you mean "exception", "ignore" or "null" in "%s"?', $decorationOnInvalid, $service->getAttribute('id'), $file)); + throw new InvalidArgumentException(\sprintf('Invalid value "%s" for attribute "decoration-on-invalid" on service "%s". Did you mean "exception", "ignore" or "null" in "%s"?', $decorationOnInvalid, $service->getAttribute('id'), $file)); } $renameId = $service->hasAttribute('decoration-inner-name') ? $service->getAttribute('decoration-inner-name') : null; $priority = $service->hasAttribute('decoration-priority') ? $service->getAttribute('decoration-priority') : 0; @@ -336,9 +336,9 @@ class XmlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn private function parseFileToDOM(string $file) : \DOMDocument { try { - $dom = \RectorPrefix20220607\Symfony\Component\Config\Util\XmlUtils::loadFile($file, \Closure::fromCallable([$this, 'validateSchema'])); + $dom = XmlUtils::loadFile($file, \Closure::fromCallable([$this, 'validateSchema'])); } catch (\InvalidArgumentException $e) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Unable to parse file "%s": ', $file) . $e->getMessage(), $e->getCode(), $e); + throw new InvalidArgumentException(\sprintf('Unable to parse file "%s": ', $file) . $e->getMessage(), $e->getCode(), $e); } $this->validateExtensions($dom, $file); return $dom; @@ -350,7 +350,7 @@ class XmlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn { $definitions = []; $count = 0; - $suffix = '~' . \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder::hash($file); + $suffix = '~' . ContainerBuilder::hash($file); $xpath = new \DOMXPath($xml); $xpath->registerNamespace('container', self::NS); // anonymous services as arguments/properties @@ -372,13 +372,13 @@ class XmlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn // anonymous services "in the wild" if (\false !== ($nodes = $xpath->query('.//container:services/container:service[not(@id)]', $root))) { foreach ($nodes as $node) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Top-level services must have "id" attribute, none found in "%s" at line %d.', $file, $node->getLineNo())); + throw new InvalidArgumentException(\sprintf('Top-level services must have "id" attribute, none found in "%s" at line %d.', $file, $node->getLineNo())); } } // resolve definitions \uksort($definitions, 'strnatcmp'); foreach (\array_reverse($definitions) as $id => [$domElement, $file]) { - if (null !== ($definition = $this->parseDefinition($domElement, $file, new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition()))) { + if (null !== ($definition = $this->parseDefinition($domElement, $file, new Definition()))) { $this->setDefinition($id, $definition); } } @@ -403,74 +403,74 @@ class XmlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn $key = $arg->getAttribute('key'); } $onInvalid = $arg->getAttribute('on-invalid'); - $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; + $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; if ('ignore' == $onInvalid) { - $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_INVALID_REFERENCE; + $invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE; } elseif ('ignore_uninitialized' == $onInvalid) { - $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE; + $invalidBehavior = ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE; } elseif ('null' == $onInvalid) { - $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::NULL_ON_INVALID_REFERENCE; + $invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE; } switch ($type = $arg->getAttribute('type')) { case 'service': if ('' === $arg->getAttribute('id')) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Tag "<%s>" with type="service" has no or empty "id" attribute in "%s".', $name, $file)); + throw new InvalidArgumentException(\sprintf('Tag "<%s>" with type="service" has no or empty "id" attribute in "%s".', $name, $file)); } - $arguments[$key] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($arg->getAttribute('id'), $invalidBehavior); + $arguments[$key] = new Reference($arg->getAttribute('id'), $invalidBehavior); break; case 'expression': - if (!\class_exists(\RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression::class)) { + if (!\class_exists(Expression::class)) { throw new \LogicException('The type="expression" attribute cannot be used without the ExpressionLanguage component. Try running "composer require symfony/expression-language".'); } - $arguments[$key] = new \RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression($arg->nodeValue); + $arguments[$key] = new Expression($arg->nodeValue); break; case 'collection': $arguments[$key] = $this->getArgumentsAsPhp($arg, $name, $file); break; case 'iterator': $arg = $this->getArgumentsAsPhp($arg, $name, $file); - $arguments[$key] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\IteratorArgument($arg); + $arguments[$key] = new IteratorArgument($arg); break; case 'closure': case 'service_closure': if ('' !== $arg->getAttribute('id')) { - $arg = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($arg->getAttribute('id'), $invalidBehavior); + $arg = new Reference($arg->getAttribute('id'), $invalidBehavior); } else { $arg = $this->getArgumentsAsPhp($arg, $name, $file); } switch ($type) { case 'service_closure': - $arguments[$key] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument($arg); + $arguments[$key] = new ServiceClosureArgument($arg); break; case 'closure': - $arguments[$key] = (new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition('Closure'))->setFactory(['Closure', 'fromCallable'])->addArgument($arg); + $arguments[$key] = (new Definition('Closure'))->setFactory(['Closure', 'fromCallable'])->addArgument($arg); break; } break; case 'service_locator': $arg = $this->getArgumentsAsPhp($arg, $name, $file); - $arguments[$key] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument($arg); + $arguments[$key] = new ServiceLocatorArgument($arg); break; case 'tagged': case 'tagged_iterator': case 'tagged_locator': $forLocator = 'tagged_locator' === $type; if (!$arg->getAttribute('tag')) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Tag "<%s>" with type="%s" has no or empty "tag" attribute in "%s".', $name, $type, $file)); + throw new InvalidArgumentException(\sprintf('Tag "<%s>" with type="%s" has no or empty "tag" attribute in "%s".', $name, $type, $file)); } - $arguments[$key] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument($arg->getAttribute('tag'), $arg->getAttribute('index-by') ?: null, $arg->getAttribute('default-index-method') ?: null, $forLocator, $arg->getAttribute('default-priority-method') ?: null); + $arguments[$key] = new TaggedIteratorArgument($arg->getAttribute('tag'), $arg->getAttribute('index-by') ?: null, $arg->getAttribute('default-index-method') ?: null, $forLocator, $arg->getAttribute('default-priority-method') ?: null); if ($forLocator) { - $arguments[$key] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument($arguments[$key]); + $arguments[$key] = new ServiceLocatorArgument($arguments[$key]); } break; case 'binary': if (\false === ($value = \base64_decode($arg->nodeValue))) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Tag "<%s>" with type="binary" is not a valid base64 encoded string.', $name)); + throw new InvalidArgumentException(\sprintf('Tag "<%s>" with type="binary" is not a valid base64 encoded string.', $name)); } $arguments[$key] = $value; break; case 'abstract': - $arguments[$key] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\AbstractArgument($arg->nodeValue); + $arguments[$key] = new AbstractArgument($arg->nodeValue); break; case 'string': $arguments[$key] = $arg->nodeValue; @@ -479,7 +479,7 @@ class XmlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn $arguments[$key] = \constant(\trim($arg->nodeValue)); break; default: - $arguments[$key] = \RectorPrefix20220607\Symfony\Component\Config\Util\XmlUtils::phpize($arg->nodeValue); + $arguments[$key] = XmlUtils::phpize($arg->nodeValue); } } return $arguments; @@ -517,7 +517,7 @@ class XmlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyIn $ns = $extension->getNamespace(); $path = \str_replace([$ns, \str_replace('http://', 'https://', $ns)], \str_replace('\\', '/', $extension->getXsdValidationBasePath()) . '/', $items[$i + 1]); if (!\is_file($path)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Extension "%s" references a non-existent XSD file "%s".', \get_debug_type($extension), $path)); + throw new RuntimeException(\sprintf('Extension "%s" references a non-existent XSD file "%s".', \get_debug_type($extension), $path)); } $schemaLocations[$items[$i]] = $path; } @@ -594,7 +594,7 @@ EOF; { foreach ($alias->attributes as $name => $node) { if (!\in_array($name, ['alias', 'id', 'public'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid attribute "%s" defined for alias "%s" in "%s".', $name, $alias->getAttribute('id'), $file)); + throw new InvalidArgumentException(\sprintf('Invalid attribute "%s" defined for alias "%s" in "%s".', $name, $alias->getAttribute('id'), $file)); } } foreach ($alias->childNodes as $child) { @@ -602,7 +602,7 @@ EOF; continue; } if (!\in_array($child->localName, ['deprecated'], \true)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid child element "%s" defined for alias "%s" in "%s".', $child->localName, $alias->getAttribute('id'), $file)); + throw new InvalidArgumentException(\sprintf('Invalid child element "%s" defined for alias "%s" in "%s".', $child->localName, $alias->getAttribute('id'), $file)); } } } @@ -619,10 +619,10 @@ EOF; } // can it be handled by an extension? if (!$this->container->hasExtension($node->namespaceURI)) { - $extensionNamespaces = \array_filter(\array_map(function (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\ExtensionInterface $ext) { + $extensionNamespaces = \array_filter(\array_map(function (ExtensionInterface $ext) { return $ext->getNamespace(); }, $this->container->getExtensions())); - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('There is no extension able to load the configuration for "%s" (in "%s"). Looked for namespace "%s", found "%s".', $node->tagName, $file, $node->namespaceURI, $extensionNamespaces ? \implode('", "', $extensionNamespaces) : 'none')); + throw new InvalidArgumentException(\sprintf('There is no extension able to load the configuration for "%s" (in "%s"). Looked for namespace "%s", found "%s".', $node->tagName, $file, $node->namespaceURI, $extensionNamespaces ? \implode('", "', $extensionNamespaces) : 'none')); } } } @@ -662,6 +662,6 @@ EOF; */ public static function convertDomElementToArray(\DOMElement $element) { - return \RectorPrefix20220607\Symfony\Component\Config\Util\XmlUtils::convertDomElementToArray($element); + return XmlUtils::convertDomElementToArray($element); } } diff --git a/vendor/symfony/dependency-injection/Loader/YamlFileLoader.php b/vendor/symfony/dependency-injection/Loader/YamlFileLoader.php index cd3d6c446cb..7aba208568b 100644 --- a/vendor/symfony/dependency-injection/Loader/YamlFileLoader.php +++ b/vendor/symfony/dependency-injection/Loader/YamlFileLoader.php @@ -35,7 +35,7 @@ use RectorPrefix20220607\Symfony\Component\Yaml\Yaml; * * @author Fabien Potencier */ -class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\FileLoader +class YamlFileLoader extends FileLoader { private const SERVICE_KEYWORDS = ['alias' => 'alias', 'parent' => 'parent', 'class' => 'class', 'shared' => 'shared', 'synthetic' => 'synthetic', 'lazy' => 'lazy', 'public' => 'public', 'abstract' => 'abstract', 'deprecated' => 'deprecated', 'factory' => 'factory', 'file' => 'file', 'arguments' => 'arguments', 'properties' => 'properties', 'configurator' => 'configurator', 'calls' => 'calls', 'tags' => 'tags', 'decorates' => 'decorates', 'decoration_inner_name' => 'decoration_inner_name', 'decoration_priority' => 'decoration_priority', 'decoration_on_invalid' => 'decoration_on_invalid', 'autowire' => 'autowire', 'autoconfigure' => 'autoconfigure', 'bind' => 'bind']; private const PROTOTYPE_KEYWORDS = ['resource' => 'resource', 'namespace' => 'namespace', 'exclude' => 'exclude', 'parent' => 'parent', 'shared' => 'shared', 'lazy' => 'lazy', 'public' => 'public', 'abstract' => 'abstract', 'deprecated' => 'deprecated', 'factory' => 'factory', 'arguments' => 'arguments', 'properties' => 'properties', 'configurator' => 'configurator', 'calls' => 'calls', 'tags' => 'tags', 'autowire' => 'autowire', 'autoconfigure' => 'autoconfigure', 'bind' => 'bind']; @@ -72,7 +72,7 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI // per-env configuration if ($this->env && isset($content['when@' . $this->env])) { if (!\is_array($content['when@' . $this->env])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The "when@%s" key should contain an array in "%s". Check your YAML syntax.', $this->env, $path)); + throw new InvalidArgumentException(\sprintf('The "when@%s" key should contain an array in "%s". Check your YAML syntax.', $this->env, $path)); } $env = $this->env; $this->env = null; @@ -91,7 +91,7 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI // parameters if (isset($content['parameters'])) { if (!\is_array($content['parameters'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The "parameters" key should contain an array in "%s". Check your YAML syntax.', $path)); + throw new InvalidArgumentException(\sprintf('The "parameters" key should contain an array in "%s". Check your YAML syntax.', $path)); } foreach ($content['parameters'] as $key => $value) { $this->container->setParameter($key, $this->resolveServices($value, $path, \true)); @@ -101,7 +101,7 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI $this->loadFromExtensions($content); // services $this->anonymousServicesCount = 0; - $this->anonymousServicesSuffix = '~' . \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder::hash($path); + $this->anonymousServicesSuffix = '~' . ContainerBuilder::hash($path); $this->setCurrentDir(\dirname($path)); try { $this->parseDefinitions($content, $path); @@ -130,7 +130,7 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI return; } if (!\is_array($content['imports'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The "imports" key should contain an array in "%s". Check your YAML syntax.', $file)); + throw new InvalidArgumentException(\sprintf('The "imports" key should contain an array in "%s". Check your YAML syntax.', $file)); } $defaultDirectory = \dirname($file); foreach ($content['imports'] as $import) { @@ -138,7 +138,7 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI $import = ['resource' => $import]; } if (!isset($import['resource'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('An import should provide a resource in "%s". Check your YAML syntax.', $file)); + throw new InvalidArgumentException(\sprintf('An import should provide a resource in "%s". Check your YAML syntax.', $file)); } $this->setCurrentDir($defaultDirectory); $this->import($import['resource'], $import['type'] ?? null, $import['ignore_errors'] ?? \false, $file); @@ -150,22 +150,22 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI return; } if (!\is_array($content['services'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The "services" key should contain an array in "%s". Check your YAML syntax.', $file)); + throw new InvalidArgumentException(\sprintf('The "services" key should contain an array in "%s". Check your YAML syntax.', $file)); } if (\array_key_exists('_instanceof', $content['services'])) { $instanceof = $content['services']['_instanceof']; unset($content['services']['_instanceof']); if (!\is_array($instanceof)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Service "_instanceof" key must be an array, "%s" given in "%s".', \get_debug_type($instanceof), $file)); + throw new InvalidArgumentException(\sprintf('Service "_instanceof" key must be an array, "%s" given in "%s".', \get_debug_type($instanceof), $file)); } $this->instanceof = []; $this->isLoadingInstanceof = \true; foreach ($instanceof as $id => $service) { if (!$service || !\is_array($service)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Type definition "%s" must be a non-empty array within "_instanceof" in "%s". Check your YAML syntax.', $id, $file)); + throw new InvalidArgumentException(\sprintf('Type definition "%s" must be a non-empty array within "_instanceof" in "%s". Check your YAML syntax.', $id, $file)); } if (\is_string($service) && \strncmp($service, '@', \strlen('@')) === 0) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Type definition "%s" cannot be an alias within "_instanceof" in "%s". Check your YAML syntax.', $id, $file)); + throw new InvalidArgumentException(\sprintf('Type definition "%s" cannot be an alias within "_instanceof" in "%s". Check your YAML syntax.', $id, $file)); } $this->parseDefinition($id, $service, $file, [], \false, $trackBindings); } @@ -187,16 +187,16 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI $defaults = $content['services']['_defaults']; unset($content['services']['_defaults']); if (!\is_array($defaults)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Service "_defaults" key must be an array, "%s" given in "%s".', \get_debug_type($defaults), $file)); + throw new InvalidArgumentException(\sprintf('Service "_defaults" key must be an array, "%s" given in "%s".', \get_debug_type($defaults), $file)); } foreach ($defaults as $key => $default) { if (!isset(self::DEFAULTS_KEYWORDS[$key])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The configuration key "%s" cannot be used to define a default value in "%s". Allowed keys are "%s".', $key, $file, \implode('", "', self::DEFAULTS_KEYWORDS))); + throw new InvalidArgumentException(\sprintf('The configuration key "%s" cannot be used to define a default value in "%s". Allowed keys are "%s".', $key, $file, \implode('", "', self::DEFAULTS_KEYWORDS))); } } if (isset($defaults['tags'])) { if (!\is_array($tags = $defaults['tags'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Parameter "tags" in "_defaults" must be an array in "%s". Check your YAML syntax.', $file)); + throw new InvalidArgumentException(\sprintf('Parameter "tags" in "_defaults" must be an array in "%s". Check your YAML syntax.', $file)); } foreach ($tags as $tag) { if (!\is_array($tag)) { @@ -207,27 +207,27 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI $tag = \current($tag); } else { if (!isset($tag['name'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('A "tags" entry in "_defaults" is missing a "name" key in "%s".', $file)); + throw new InvalidArgumentException(\sprintf('A "tags" entry in "_defaults" is missing a "name" key in "%s".', $file)); } $name = $tag['name']; unset($tag['name']); } if (!\is_string($name) || '' === $name) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The tag name in "_defaults" must be a non-empty string in "%s".', $file)); + throw new InvalidArgumentException(\sprintf('The tag name in "_defaults" must be a non-empty string in "%s".', $file)); } foreach ($tag as $attribute => $value) { if (!\is_scalar($value) && null !== $value) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type in "%s". Check your YAML syntax.', $name, $attribute, $file)); + throw new InvalidArgumentException(\sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type in "%s". Check your YAML syntax.', $name, $attribute, $file)); } } } } if (isset($defaults['bind'])) { if (!\is_array($defaults['bind'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Parameter "bind" in "_defaults" must be an array in "%s". Check your YAML syntax.', $file)); + throw new InvalidArgumentException(\sprintf('Parameter "bind" in "_defaults" must be an array in "%s". Check your YAML syntax.', $file)); } foreach ($this->resolveServices($defaults['bind'], $file) as $argument => $value) { - $defaults['bind'][$argument] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\BoundArgument($value, \true, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\BoundArgument::DEFAULTS_BINDING, $file); + $defaults['bind'][$argument] = new BoundArgument($value, \true, BoundArgument::DEFAULTS_BINDING, $file); } } return $defaults; @@ -248,10 +248,10 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI private function parseDefinition(string $id, $service, string $file, array $defaults, bool $return = \false, bool $trackBindings = \true) { if (\preg_match('/^_[a-zA-Z0-9_]*$/', $id)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Service names that start with an underscore are reserved. Rename the "%s" service or define it in XML instead.', $id)); + throw new InvalidArgumentException(\sprintf('Service names that start with an underscore are reserved. Rename the "%s" service or define it in XML instead.', $id)); } if (\is_string($service) && \strncmp($service, '@', \strlen('@')) === 0) { - $alias = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Alias(\substr($service, 1)); + $alias = new Alias(\substr($service, 1)); if (isset($defaults['public'])) { $alias->setPublic($defaults['public']); } @@ -264,11 +264,11 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI $service = []; } if (!\is_array($service)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('A service definition must be an array or a string starting with "@" but "%s" found for service "%s" in "%s". Check your YAML syntax.', \get_debug_type($service), $id, $file)); + throw new InvalidArgumentException(\sprintf('A service definition must be an array or a string starting with "@" but "%s" found for service "%s" in "%s". Check your YAML syntax.', \get_debug_type($service), $id, $file)); } if (isset($service['stack'])) { if (!\is_array($service['stack'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('A stack must be an array of definitions, "%s" given for service "%s" in "%s". Check your YAML syntax.', \get_debug_type($service), $id, $file)); + throw new InvalidArgumentException(\sprintf('A stack must be an array of definitions, "%s" given for service "%s" in "%s". Check your YAML syntax.', \get_debug_type($service), $id, $file)); } $stack = []; foreach ($service['stack'] as $k => $frame) { @@ -276,24 +276,24 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI $frame = ['class' => \key($frame), 'arguments' => \current($frame)]; } if (\is_array($frame) && isset($frame['stack'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Service stack "%s" cannot contain another stack in "%s".', $id, $file)); + throw new InvalidArgumentException(\sprintf('Service stack "%s" cannot contain another stack in "%s".', $id, $file)); } $definition = $this->parseDefinition($id . '" at index "' . $k, $frame, $file, $defaults, \true); - if ($definition instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition) { + if ($definition instanceof Definition) { $definition->setInstanceofConditionals($this->instanceof); } $stack[$k] = $definition; } if ($diff = \array_diff(\array_keys($service), ['stack', 'public', 'deprecated'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid attribute "%s"; supported ones are "public" and "deprecated" for service "%s" in "%s". Check your YAML syntax.', \implode('", "', $diff), $id, $file)); + throw new InvalidArgumentException(\sprintf('Invalid attribute "%s"; supported ones are "public" and "deprecated" for service "%s" in "%s". Check your YAML syntax.', \implode('", "', $diff), $id, $file)); } $service = ['parent' => '', 'arguments' => $stack, 'tags' => ['container.stack'], 'public' => $service['public'] ?? null, 'deprecated' => $service['deprecated'] ?? null]; } - $definition = isset($service[0]) && $service[0] instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition ? \array_shift($service) : null; + $definition = isset($service[0]) && $service[0] instanceof Definition ? \array_shift($service) : null; $return = null === $definition ? $return : \true; $this->checkDefinition($id, $service, $file); if (isset($service['alias'])) { - $alias = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Alias($service['alias']); + $alias = new Alias($service['alias']); if (isset($service['public'])) { $alias->setPublic($service['public']); } elseif (isset($defaults['public'])) { @@ -301,15 +301,15 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI } foreach ($service as $key => $value) { if (!\in_array($key, ['alias', 'public', 'deprecated'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The configuration key "%s" is unsupported for the service "%s" which is defined as an alias in "%s". Allowed configuration keys for service aliases are "alias", "public" and "deprecated".', $key, $id, $file)); + throw new InvalidArgumentException(\sprintf('The configuration key "%s" is unsupported for the service "%s" which is defined as an alias in "%s". Allowed configuration keys for service aliases are "alias", "public" and "deprecated".', $key, $id, $file)); } if ('deprecated' === $key) { $deprecation = \is_array($value) ? $value : ['message' => $value]; if (!isset($deprecation['package'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Missing attribute "package" of the "deprecated" option in "%s".', $file)); + throw new InvalidArgumentException(\sprintf('Missing attribute "package" of the "deprecated" option in "%s".', $file)); } if (!isset($deprecation['version'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Missing attribute "version" of the "deprecated" option in "%s".', $file)); + throw new InvalidArgumentException(\sprintf('Missing attribute "version" of the "deprecated" option in "%s".', $file)); } $alias->setDeprecated($deprecation['package'] ?? '', $deprecation['version'] ?? '', $deprecation['message'] ?? ''); } @@ -319,14 +319,14 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI if (null !== $definition) { // no-op } elseif ($this->isLoadingInstanceof) { - $definition = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition(''); + $definition = new ChildDefinition(''); } elseif (isset($service['parent'])) { if ('' !== $service['parent'] && '@' === $service['parent'][0]) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The value of the "parent" option for the "%s" service must be the id of the service without the "@" prefix (replace "%s" with "%s").', $id, $service['parent'], \substr($service['parent'], 1))); + throw new InvalidArgumentException(\sprintf('The value of the "parent" option for the "%s" service must be the id of the service without the "@" prefix (replace "%s" with "%s").', $id, $service['parent'], \substr($service['parent'], 1))); } - $definition = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ChildDefinition($service['parent']); + $definition = new ChildDefinition($service['parent']); } else { - $definition = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition(); + $definition = new Definition(); } if (isset($defaults['public'])) { $definition->setPublic($defaults['public']); @@ -362,10 +362,10 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI if (isset($service['deprecated'])) { $deprecation = \is_array($service['deprecated']) ? $service['deprecated'] : ['message' => $service['deprecated']]; if (!isset($deprecation['package'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Missing attribute "package" of the "deprecated" option in "%s".', $file)); + throw new InvalidArgumentException(\sprintf('Missing attribute "package" of the "deprecated" option in "%s".', $file)); } if (!isset($deprecation['version'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Missing attribute "version" of the "deprecated" option in "%s".', $file)); + throw new InvalidArgumentException(\sprintf('Missing attribute "version" of the "deprecated" option in "%s".', $file)); } $definition->setDeprecated($deprecation['package'] ?? '', $deprecation['version'] ?? '', $deprecation['message'] ?? ''); } @@ -386,14 +386,14 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI } if (isset($service['calls'])) { if (!\is_array($service['calls'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Parameter "calls" must be an array for service "%s" in "%s". Check your YAML syntax.', $id, $file)); + throw new InvalidArgumentException(\sprintf('Parameter "calls" must be an array for service "%s" in "%s". Check your YAML syntax.', $id, $file)); } foreach ($service['calls'] as $k => $call) { - if (!\is_array($call) && (!\is_string($k) || !$call instanceof \RectorPrefix20220607\Symfony\Component\Yaml\Tag\TaggedValue)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid method call for service "%s": expected map or array, "%s" given in "%s".', $id, $call instanceof \RectorPrefix20220607\Symfony\Component\Yaml\Tag\TaggedValue ? '!' . $call->getTag() : \get_debug_type($call), $file)); + if (!\is_array($call) && (!\is_string($k) || !$call instanceof TaggedValue)) { + throw new InvalidArgumentException(\sprintf('Invalid method call for service "%s": expected map or array, "%s" given in "%s".', $id, $call instanceof TaggedValue ? '!' . $call->getTag() : \get_debug_type($call), $file)); } if (\is_string($k)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid method call for service "%s", did you forgot a leading dash before "%s: ..." in "%s"?', $id, $k, $file)); + throw new InvalidArgumentException(\sprintf('Invalid method call for service "%s", did you forgot a leading dash before "%s: ..." in "%s"?', $id, $k, $file)); } if (isset($call['method']) && \is_string($call['method'])) { $method = $call['method']; @@ -403,9 +403,9 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI if (1 === \count($call) && \is_string(\key($call))) { $method = \key($call); $args = $call[$method]; - if ($args instanceof \RectorPrefix20220607\Symfony\Component\Yaml\Tag\TaggedValue) { + if ($args instanceof TaggedValue) { if ('returns_clone' !== $args->getTag()) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Unsupported tag "!%s", did you mean "!returns_clone" for service "%s" in "%s"?', $args->getTag(), $id, $file)); + throw new InvalidArgumentException(\sprintf('Unsupported tag "!%s", did you mean "!returns_clone" for service "%s" in "%s"?', $args->getTag(), $id, $file)); } $returnsClone = \true; $args = $args->getValue(); @@ -413,7 +413,7 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI $returnsClone = \false; } } elseif (empty($call[0])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid call for service "%s": the method must be defined as the first index of an array or as the only key of a map in "%s".', $id, $file)); + throw new InvalidArgumentException(\sprintf('Invalid call for service "%s": the method must be defined as the first index of an array or as the only key of a map in "%s".', $id, $file)); } else { $method = $call[0]; $args = $call[1] ?? []; @@ -421,7 +421,7 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI } } if (!\is_array($args)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The second parameter for function call "%s" must be an array of its arguments for service "%s" in "%s". Check your YAML syntax.', $method, $id, $file)); + throw new InvalidArgumentException(\sprintf('The second parameter for function call "%s" must be an array of its arguments for service "%s" in "%s". Check your YAML syntax.', $method, $id, $file)); } $args = $this->resolveServices($args, $file); $definition->addMethodCall($method, $args, $returnsClone); @@ -429,7 +429,7 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI } $tags = $service['tags'] ?? []; if (!\is_array($tags)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Parameter "tags" must be an array for service "%s" in "%s". Check your YAML syntax.', $id, $file)); + throw new InvalidArgumentException(\sprintf('Parameter "tags" must be an array for service "%s" in "%s". Check your YAML syntax.', $id, $file)); } if (isset($defaults['tags'])) { $tags = \array_merge($tags, $defaults['tags']); @@ -443,36 +443,36 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI $tag = \current($tag); } else { if (!isset($tag['name'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('A "tags" entry is missing a "name" key for service "%s" in "%s".', $id, $file)); + throw new InvalidArgumentException(\sprintf('A "tags" entry is missing a "name" key for service "%s" in "%s".', $id, $file)); } $name = $tag['name']; unset($tag['name']); } if (!\is_string($name) || '' === $name) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The tag name for service "%s" in "%s" must be a non-empty string.', $id, $file)); + throw new InvalidArgumentException(\sprintf('The tag name for service "%s" in "%s" must be a non-empty string.', $id, $file)); } foreach ($tag as $attribute => $value) { if (!\is_scalar($value) && null !== $value) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s" in "%s". Check your YAML syntax.', $id, $name, $attribute, $file)); + throw new InvalidArgumentException(\sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s" in "%s". Check your YAML syntax.', $id, $name, $attribute, $file)); } } $definition->addTag($name, $tag); } if (null !== ($decorates = $service['decorates'] ?? null)) { if ('' !== $decorates && '@' === $decorates[0]) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The value of the "decorates" option for the "%s" service must be the id of the service without the "@" prefix (replace "%s" with "%s").', $id, $service['decorates'], \substr($decorates, 1))); + throw new InvalidArgumentException(\sprintf('The value of the "decorates" option for the "%s" service must be the id of the service without the "@" prefix (replace "%s" with "%s").', $id, $service['decorates'], \substr($decorates, 1))); } $decorationOnInvalid = \array_key_exists('decoration_on_invalid', $service) ? $service['decoration_on_invalid'] : 'exception'; if ('exception' === $decorationOnInvalid) { - $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; + $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; } elseif ('ignore' === $decorationOnInvalid) { - $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_INVALID_REFERENCE; + $invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE; } elseif (null === $decorationOnInvalid) { - $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::NULL_ON_INVALID_REFERENCE; + $invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE; } elseif ('null' === $decorationOnInvalid) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid value "%s" for attribute "decoration_on_invalid" on service "%s". Did you mean null (without quotes) in "%s"?', $decorationOnInvalid, $id, $file)); + throw new InvalidArgumentException(\sprintf('Invalid value "%s" for attribute "decoration_on_invalid" on service "%s". Did you mean null (without quotes) in "%s"?', $decorationOnInvalid, $id, $file)); } else { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid value "%s" for attribute "decoration_on_invalid" on service "%s". Did you mean "exception", "ignore" or null in "%s"?', $decorationOnInvalid, $id, $file)); + throw new InvalidArgumentException(\sprintf('Invalid value "%s" for attribute "decoration_on_invalid" on service "%s". Did you mean "exception", "ignore" or null in "%s"?', $decorationOnInvalid, $id, $file)); } $renameId = $service['decoration_inner_name'] ?? null; $priority = $service['decoration_priority'] ?? 0; @@ -487,13 +487,13 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI $bindings += isset($defaults['bind']) ? \unserialize(\serialize($defaults['bind'])) : []; if (isset($service['bind'])) { if (!\is_array($service['bind'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Parameter "bind" must be an array for service "%s" in "%s". Check your YAML syntax.', $id, $file)); + throw new InvalidArgumentException(\sprintf('Parameter "bind" must be an array for service "%s" in "%s". Check your YAML syntax.', $id, $file)); } $bindings = \array_merge($bindings, $this->resolveServices($service['bind'], $file)); - $bindingType = $this->isLoadingInstanceof ? \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\BoundArgument::INSTANCEOF_BINDING : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\BoundArgument::SERVICE_BINDING; + $bindingType = $this->isLoadingInstanceof ? BoundArgument::INSTANCEOF_BINDING : BoundArgument::SERVICE_BINDING; foreach ($bindings as $argument => $value) { - if (!$value instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\BoundArgument) { - $bindings[$argument] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\BoundArgument($value, $trackBindings, $bindingType, $file); + if (!$value instanceof BoundArgument) { + $bindings[$argument] = new BoundArgument($value, $trackBindings, $bindingType, $file); } } } @@ -503,17 +503,17 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI $definition->setAutoconfigured($service['autoconfigure']); } if (\array_key_exists('namespace', $service) && !\array_key_exists('resource', $service)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('A "resource" attribute must be set when the "namespace" attribute is set for service "%s" in "%s". Check your YAML syntax.', $id, $file)); + throw new InvalidArgumentException(\sprintf('A "resource" attribute must be set when the "namespace" attribute is set for service "%s" in "%s". Check your YAML syntax.', $id, $file)); } if ($return) { if (\array_key_exists('resource', $service)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid "resource" attribute found for service "%s" in "%s". Check your YAML syntax.', $id, $file)); + throw new InvalidArgumentException(\sprintf('Invalid "resource" attribute found for service "%s" in "%s". Check your YAML syntax.', $id, $file)); } return $definition; } if (\array_key_exists('resource', $service)) { if (!\is_string($service['resource'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('A "resource" attribute must be of type string for service "%s" in "%s". Check your YAML syntax.', $id, $file)); + throw new InvalidArgumentException(\sprintf('A "resource" attribute must be of type string for service "%s" in "%s". Check your YAML syntax.', $id, $file)); } $exclude = $service['exclude'] ?? null; $namespace = $service['namespace'] ?? $id; @@ -532,9 +532,9 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI if (\is_string($callable)) { if (\strncmp($callable, '@=', \strlen('@=')) === 0) { if ('factory' !== $parameter) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Using expressions in "%s" for the "%s" service is not supported in "%s".', $parameter, $id, $file)); + throw new InvalidArgumentException(\sprintf('Using expressions in "%s" for the "%s" service is not supported in "%s".', $parameter, $id, $file)); } - if (!\class_exists(\RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression::class)) { + if (!\class_exists(Expression::class)) { throw new \LogicException('The "@=" expression syntax cannot be used without the ExpressionLanguage component. Try running "composer require symfony/expression-language".'); } return $callable; @@ -543,7 +543,7 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI if (\strpos($callable, ':') === \false) { return [$this->resolveServices($callable, $file), '__invoke']; } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The value of the "%s" option for the "%s" service must be the id of the service without the "@" prefix (replace "%s" with "%s" in "%s").', $parameter, $id, $callable, \substr($callable, 1), $file)); + throw new InvalidArgumentException(\sprintf('The value of the "%s" option for the "%s" service must be the id of the service without the "@" prefix (replace "%s" with "%s" in "%s").', $parameter, $id, $callable, \substr($callable, 1), $file)); } return $callable; } @@ -554,9 +554,9 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI if ('factory' === $parameter && isset($callable[1]) && null === $callable[0]) { return $callable; } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Parameter "%s" must contain an array with two elements for service "%s" in "%s". Check your YAML syntax.', $parameter, $id, $file)); + throw new InvalidArgumentException(\sprintf('Parameter "%s" must contain an array with two elements for service "%s" in "%s". Check your YAML syntax.', $parameter, $id, $file)); } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Parameter "%s" must be a string or an array for service "%s" in "%s". Check your YAML syntax.', $parameter, $id, $file)); + throw new InvalidArgumentException(\sprintf('Parameter "%s" must be a string or an array for service "%s" in "%s". Check your YAML syntax.', $parameter, $id, $file)); } /** * Loads a YAML file. @@ -566,19 +566,19 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI protected function loadFile(string $file) : ?array { if (!\class_exists(\RectorPrefix20220607\Symfony\Component\Yaml\Parser::class)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException('Unable to load YAML config files as the Symfony Yaml Component is not installed.'); + throw new RuntimeException('Unable to load YAML config files as the Symfony Yaml Component is not installed.'); } if (!\stream_is_local($file)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('This is not a local file "%s".', $file)); + throw new InvalidArgumentException(\sprintf('This is not a local file "%s".', $file)); } if (!\is_file($file)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The file "%s" does not exist.', $file)); + throw new InvalidArgumentException(\sprintf('The file "%s" does not exist.', $file)); } - $this->yamlParser = $this->yamlParser ?? new \RectorPrefix20220607\Symfony\Component\Yaml\Parser(); + $this->yamlParser = $this->yamlParser ?? new YamlParser(); try { - $configuration = $this->yamlParser->parseFile($file, \RectorPrefix20220607\Symfony\Component\Yaml\Yaml::PARSE_CONSTANT | \RectorPrefix20220607\Symfony\Component\Yaml\Yaml::PARSE_CUSTOM_TAGS); - } catch (\RectorPrefix20220607\Symfony\Component\Yaml\Exception\ParseException $e) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The file "%s" does not contain valid YAML: ', $file) . $e->getMessage(), 0, $e); + $configuration = $this->yamlParser->parseFile($file, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS); + } catch (ParseException $e) { + throw new InvalidArgumentException(\sprintf('The file "%s" does not contain valid YAML: ', $file) . $e->getMessage(), 0, $e); } return $this->validate($configuration, $file); } @@ -594,17 +594,17 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI return $content; } if (!\is_array($content)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The service file "%s" is not valid. It should contain an array. Check your YAML syntax.', $file)); + throw new InvalidArgumentException(\sprintf('The service file "%s" is not valid. It should contain an array. Check your YAML syntax.', $file)); } foreach ($content as $namespace => $data) { if (\in_array($namespace, ['imports', 'parameters', 'services']) || \strncmp($namespace, 'when@', \strlen('when@')) === 0) { continue; } if (!$this->container->hasExtension($namespace)) { - $extensionNamespaces = \array_filter(\array_map(function (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\ExtensionInterface $ext) { + $extensionNamespaces = \array_filter(\array_map(function (ExtensionInterface $ext) { return $ext->getAlias(); }, $this->container->getExtensions())); - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('There is no extension able to load the configuration for "%s" (in "%s"). Looked for namespace "%s", found "%s".', $namespace, $file, $namespace, $extensionNamespaces ? \sprintf('"%s"', \implode('", "', $extensionNamespaces)) : 'none')); + throw new InvalidArgumentException(\sprintf('There is no extension able to load the configuration for "%s" (in "%s"). Looked for namespace "%s", found "%s".', $namespace, $file, $namespace, $extensionNamespaces ? \sprintf('"%s"', \implode('", "', $extensionNamespaces)) : 'none')); } } return $content; @@ -615,50 +615,50 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI */ private function resolveServices($value, string $file, bool $isParameter = \false) { - if ($value instanceof \RectorPrefix20220607\Symfony\Component\Yaml\Tag\TaggedValue) { + if ($value instanceof TaggedValue) { $argument = $value->getValue(); if ('closure' === $value->getTag()) { $argument = $this->resolveServices($argument, $file, $isParameter); - return (new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition('Closure'))->setFactory(['Closure', 'fromCallable'])->addArgument($argument); + return (new Definition('Closure'))->setFactory(['Closure', 'fromCallable'])->addArgument($argument); } if ('iterator' === $value->getTag()) { if (!\is_array($argument)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('"!iterator" tag only accepts sequences in "%s".', $file)); + throw new InvalidArgumentException(\sprintf('"!iterator" tag only accepts sequences in "%s".', $file)); } $argument = $this->resolveServices($argument, $file, $isParameter); - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\IteratorArgument($argument); + return new IteratorArgument($argument); } if ('service_closure' === $value->getTag()) { $argument = $this->resolveServices($argument, $file, $isParameter); - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument($argument); + return new ServiceClosureArgument($argument); } if ('service_locator' === $value->getTag()) { if (!\is_array($argument)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('"!service_locator" tag only accepts maps in "%s".', $file)); + throw new InvalidArgumentException(\sprintf('"!service_locator" tag only accepts maps in "%s".', $file)); } $argument = $this->resolveServices($argument, $file, $isParameter); - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument($argument); + return new ServiceLocatorArgument($argument); } if (\in_array($value->getTag(), ['tagged', 'tagged_iterator', 'tagged_locator'], \true)) { $forLocator = 'tagged_locator' === $value->getTag(); if (\is_array($argument) && isset($argument['tag']) && $argument['tag']) { if ($diff = \array_diff(\array_keys($argument), ['tag', 'index_by', 'default_index_method', 'default_priority_method'])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('"!%s" tag contains unsupported key "%s"; supported ones are "tag", "index_by", "default_index_method", and "default_priority_method".', $value->getTag(), \implode('", "', $diff))); + throw new InvalidArgumentException(\sprintf('"!%s" tag contains unsupported key "%s"; supported ones are "tag", "index_by", "default_index_method", and "default_priority_method".', $value->getTag(), \implode('", "', $diff))); } - $argument = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument($argument['tag'], $argument['index_by'] ?? null, $argument['default_index_method'] ?? null, $forLocator, $argument['default_priority_method'] ?? null); + $argument = new TaggedIteratorArgument($argument['tag'], $argument['index_by'] ?? null, $argument['default_index_method'] ?? null, $forLocator, $argument['default_priority_method'] ?? null); } elseif (\is_string($argument) && $argument) { - $argument = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument($argument, null, null, $forLocator); + $argument = new TaggedIteratorArgument($argument, null, null, $forLocator); } else { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('"!%s" tags only accept a non empty string or an array with a key "tag" in "%s".', $value->getTag(), $file)); + throw new InvalidArgumentException(\sprintf('"!%s" tags only accept a non empty string or an array with a key "tag" in "%s".', $value->getTag(), $file)); } if ($forLocator) { - $argument = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument($argument); + $argument = new ServiceLocatorArgument($argument); } return $argument; } if ('service' === $value->getTag()) { if ($isParameter) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Using an anonymous service in a parameter is not allowed in "%s".', $file)); + throw new InvalidArgumentException(\sprintf('Using an anonymous service in a parameter is not allowed in "%s".', $file)); } $isLoadingInstanceof = $this->isLoadingInstanceof; $this->isLoadingInstanceof = \false; @@ -667,17 +667,17 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI $id = \sprintf('.%d_%s', ++$this->anonymousServicesCount, \preg_replace('/^.*\\\\/', '', $argument['class'] ?? '') . $this->anonymousServicesSuffix); $this->parseDefinition($id, $argument, $file, []); if (!$this->container->hasDefinition($id)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Creating an alias using the tag "!service" is not allowed in "%s".', $file)); + throw new InvalidArgumentException(\sprintf('Creating an alias using the tag "!service" is not allowed in "%s".', $file)); } $this->container->getDefinition($id); $this->isLoadingInstanceof = $isLoadingInstanceof; $this->instanceof = $instanceof; - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($id); + return new Reference($id); } if ('abstract' === $value->getTag()) { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Argument\AbstractArgument($value->getValue()); + return new AbstractArgument($value->getValue()); } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Unsupported tag "!%s".', $value->getTag())); + throw new InvalidArgumentException(\sprintf('Unsupported tag "!%s".', $value->getTag())); } if (\is_array($value)) { foreach ($value as $k => $v) { @@ -685,28 +685,28 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI } } elseif (\is_string($value) && \strncmp($value, '@=', \strlen('@=')) === 0) { if ($isParameter) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Using expressions in parameters is not allowed in "%s".', $file)); + throw new InvalidArgumentException(\sprintf('Using expressions in parameters is not allowed in "%s".', $file)); } - if (!\class_exists(\RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression::class)) { + if (!\class_exists(Expression::class)) { throw new \LogicException('The "@=" expression syntax cannot be used without the ExpressionLanguage component. Try running "composer require symfony/expression-language".'); } - return new \RectorPrefix20220607\Symfony\Component\ExpressionLanguage\Expression(\substr($value, 2)); + return new Expression(\substr($value, 2)); } elseif (\is_string($value) && \strncmp($value, '@', \strlen('@')) === 0) { if (\strncmp($value, '@@', \strlen('@@')) === 0) { $value = \substr($value, 1); $invalidBehavior = null; } elseif (\strncmp($value, '@!', \strlen('@!')) === 0) { $value = \substr($value, 2); - $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE; + $invalidBehavior = ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE; } elseif (\strncmp($value, '@?', \strlen('@?')) === 0) { $value = \substr($value, 2); - $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_INVALID_REFERENCE; + $invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE; } else { $value = \substr($value, 1); - $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; + $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; } if (null !== $invalidBehavior) { - $value = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($value, $invalidBehavior); + $value = new Reference($value, $invalidBehavior); } } return $value; @@ -734,7 +734,7 @@ class YamlFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyI } foreach ($definition as $key => $value) { if (!isset($keywords[$key])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The configuration key "%s" is unsupported for definition "%s" in "%s". Allowed configuration keys are "%s".', $key, $id, $file, \implode('", "', $keywords))); + throw new InvalidArgumentException(\sprintf('The configuration key "%s" is unsupported for definition "%s" in "%s". Allowed configuration keys are "%s".', $key, $id, $file, \implode('", "', $keywords))); } } } diff --git a/vendor/symfony/dependency-injection/ParameterBag/ContainerBag.php b/vendor/symfony/dependency-injection/ParameterBag/ContainerBag.php index 7b9fd327b42..6912720bf32 100644 --- a/vendor/symfony/dependency-injection/ParameterBag/ContainerBag.php +++ b/vendor/symfony/dependency-injection/ParameterBag/ContainerBag.php @@ -14,13 +14,13 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Container; /** * @author Nicolas Grekas */ -class ContainerBag extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface +class ContainerBag extends FrozenParameterBag implements ContainerBagInterface { /** * @var \Symfony\Component\DependencyInjection\Container */ private $container; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Container $container) + public function __construct(Container $container) { $this->container = $container; } diff --git a/vendor/symfony/dependency-injection/ParameterBag/ContainerBagInterface.php b/vendor/symfony/dependency-injection/ParameterBag/ContainerBagInterface.php index baba1750baa..7f7cd279dc0 100644 --- a/vendor/symfony/dependency-injection/ParameterBag/ContainerBagInterface.php +++ b/vendor/symfony/dependency-injection/ParameterBag/ContainerBagInterface.php @@ -17,7 +17,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\Paramet * * @author Nicolas Grekas */ -interface ContainerBagInterface extends \RectorPrefix20220607\Psr\Container\ContainerInterface +interface ContainerBagInterface extends ContainerInterface { /** * Gets the service container parameters. diff --git a/vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php b/vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php index c58d762d1c6..16b1943f775 100644 --- a/vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php +++ b/vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php @@ -15,7 +15,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\Runtime /** * @author Nicolas Grekas */ -class EnvPlaceholderParameterBag extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag +class EnvPlaceholderParameterBag extends ParameterBag { /** * @var string @@ -58,10 +58,10 @@ class EnvPlaceholderParameterBag extends \RectorPrefix20220607\Symfony\Component } } if (!\preg_match('/^(?:[-.\\w]*+:)*+\\w++$/', $env)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid %s name: only "word" characters are allowed.', $name)); + throw new InvalidArgumentException(\sprintf('Invalid %s name: only "word" characters are allowed.', $name)); } if ($this->has($name) && null !== ($defaultValue = parent::get($name)) && !\is_string($defaultValue)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('The default value of an env() parameter must be a string or null, but "%s" given to "%s".', \get_debug_type($defaultValue), $name)); + throw new RuntimeException(\sprintf('The default value of an env() parameter must be a string or null, but "%s" given to "%s".', \get_debug_type($defaultValue), $name)); } $uniqueName = \md5($name . '_' . self::$counter++); $placeholder = \sprintf('%s_%s_%s', $this->getEnvPlaceholderUniquePrefix(), \strtr($env, ':-.', '___'), $uniqueName); @@ -146,7 +146,7 @@ class EnvPlaceholderParameterBag extends \RectorPrefix20220607\Symfony\Component parent::resolve(); foreach ($this->envPlaceholders as $env => $placeholders) { if ($this->has($name = "env({$env})") && null !== ($default = $this->parameters[$name]) && !\is_string($default)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('The default value of env parameter "%s" must be a string or null, "%s" given.', $env, \get_debug_type($default))); + throw new RuntimeException(\sprintf('The default value of env parameter "%s" must be a string or null, "%s" given.', $env, \get_debug_type($default))); } } } diff --git a/vendor/symfony/dependency-injection/ParameterBag/FrozenParameterBag.php b/vendor/symfony/dependency-injection/ParameterBag/FrozenParameterBag.php index 327c6eb93cc..ce40ed1b98b 100644 --- a/vendor/symfony/dependency-injection/ParameterBag/FrozenParameterBag.php +++ b/vendor/symfony/dependency-injection/ParameterBag/FrozenParameterBag.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicEx * * @author Fabien Potencier */ -class FrozenParameterBag extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag +class FrozenParameterBag extends ParameterBag { /** * For performance reasons, the constructor assumes that @@ -36,14 +36,14 @@ class FrozenParameterBag extends \RectorPrefix20220607\Symfony\Component\Depende */ public function clear() { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicException('Impossible to call clear() on a frozen ParameterBag.'); + throw new LogicException('Impossible to call clear() on a frozen ParameterBag.'); } /** * {@inheritdoc} */ public function add(array $parameters) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicException('Impossible to call add() on a frozen ParameterBag.'); + throw new LogicException('Impossible to call add() on a frozen ParameterBag.'); } /** * {@inheritdoc} @@ -51,13 +51,13 @@ class FrozenParameterBag extends \RectorPrefix20220607\Symfony\Component\Depende */ public function set(string $name, $value) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicException('Impossible to call set() on a frozen ParameterBag.'); + throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } /** * {@inheritdoc} */ public function remove(string $name) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\LogicException('Impossible to call remove() on a frozen ParameterBag.'); + throw new LogicException('Impossible to call remove() on a frozen ParameterBag.'); } } diff --git a/vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php b/vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php index 3f027fb889f..80c5eface0c 100644 --- a/vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php +++ b/vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php @@ -18,7 +18,7 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\Runtime * * @author Fabien Potencier */ -class ParameterBag implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface +class ParameterBag implements ParameterBagInterface { protected $parameters = []; protected $resolved = \false; @@ -57,7 +57,7 @@ class ParameterBag implements \RectorPrefix20220607\Symfony\Component\Dependency { if (!\array_key_exists($name, $this->parameters)) { if (!$name) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException($name); + throw new ParameterNotFoundException($name); } $alternatives = []; foreach ($this->parameters as $key => $parameterValue) { @@ -80,7 +80,7 @@ class ParameterBag implements \RectorPrefix20220607\Symfony\Component\Dependency $key = \substr($key, 0, -1 * (1 + \array_pop($namePartsLength))); } } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException($name, null, null, null, $alternatives, $nonNestedAlternative); + throw new ParameterNotFoundException($name, null, null, null, $alternatives, $nonNestedAlternative); } return $this->parameters[$name]; } @@ -119,7 +119,7 @@ class ParameterBag implements \RectorPrefix20220607\Symfony\Component\Dependency try { $value = $this->resolveValue($value); $parameters[$key] = $this->unescapeValue($value); - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException $e) { + } catch (ParameterNotFoundException $e) { $e->setSourceKey($key); throw $e; } @@ -170,7 +170,7 @@ class ParameterBag implements \RectorPrefix20220607\Symfony\Component\Dependency if (\preg_match('/^%([^%\\s]+)%$/', $value, $match)) { $key = $match[1]; if (isset($resolving[$key])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException(\array_keys($resolving)); + throw new ParameterCircularReferenceException(\array_keys($resolving)); } $resolving[$key] = \true; return $this->resolved ? $this->get($key) : $this->resolveValue($this->get($key), $resolving); @@ -182,11 +182,11 @@ class ParameterBag implements \RectorPrefix20220607\Symfony\Component\Dependency } $key = $match[1]; if (isset($resolving[$key])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException(\array_keys($resolving)); + throw new ParameterCircularReferenceException(\array_keys($resolving)); } $resolved = $this->get($key); if (!\is_string($resolved) && !\is_numeric($resolved)) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('A string value must be composed of strings and/or numbers, but found parameter "%s" of type "%s" inside string value "%s".', $key, \get_debug_type($resolved), $value)); + throw new RuntimeException(\sprintf('A string value must be composed of strings and/or numbers, but found parameter "%s" of type "%s" inside string value "%s".', $key, \get_debug_type($resolved), $value)); } $resolved = (string) $resolved; $resolving[$key] = \true; diff --git a/vendor/symfony/dependency-injection/Reference.php b/vendor/symfony/dependency-injection/Reference.php index 01f1e23933a..d0837985692 100644 --- a/vendor/symfony/dependency-injection/Reference.php +++ b/vendor/symfony/dependency-injection/Reference.php @@ -25,7 +25,7 @@ class Reference * @var int */ private $invalidBehavior; - public function __construct(string $id, int $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) + public function __construct(string $id, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) { $this->id = $id; $this->invalidBehavior = $invalidBehavior; diff --git a/vendor/symfony/dependency-injection/ReverseContainer.php b/vendor/symfony/dependency-injection/ReverseContainer.php index bfccdaa6e7b..10cf370f4ed 100644 --- a/vendor/symfony/dependency-injection/ReverseContainer.php +++ b/vendor/symfony/dependency-injection/ReverseContainer.php @@ -35,14 +35,14 @@ final class ReverseContainer * @var \Closure */ private $getServiceId; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\Container $serviceContainer, \RectorPrefix20220607\Psr\Container\ContainerInterface $reversibleLocator, string $tagName = 'container.reversible') + public function __construct(Container $serviceContainer, ContainerInterface $reversibleLocator, string $tagName = 'container.reversible') { $this->serviceContainer = $serviceContainer; $this->reversibleLocator = $reversibleLocator; $this->tagName = $tagName; $this->getServiceId = \Closure::bind(function (object $service) : ?string { return (\array_search($service, $this->services, \true) ?: \array_search($service, $this->privates, \true)) ?: null; - }, $serviceContainer, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Container::class); + }, $serviceContainer, Container::class); } /** * Returns the id of the passed object when it exists as a service. @@ -74,7 +74,7 @@ final class ReverseContainer return $this->reversibleLocator->get($id); } if (isset($this->serviceContainer->getRemovedIds()[$id])) { - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException($id, null, null, [], \sprintf('The "%s" service is private and cannot be accessed by reference. You should either make it public, or tag it as "%s".', $id, $this->tagName)); + throw new ServiceNotFoundException($id, null, null, [], \sprintf('The "%s" service is private and cannot be accessed by reference. You should either make it public, or tag it as "%s".', $id, $this->tagName)); } // will throw a ServiceNotFoundException $this->serviceContainer->get($id); diff --git a/vendor/symfony/dependency-injection/ServiceLocator.php b/vendor/symfony/dependency-injection/ServiceLocator.php index 2f343b31538..1631c97a240 100644 --- a/vendor/symfony/dependency-injection/ServiceLocator.php +++ b/vendor/symfony/dependency-injection/ServiceLocator.php @@ -22,7 +22,7 @@ use RectorPrefix20220607\Symfony\Contracts\Service\ServiceSubscriberInterface; * @author Robin Chalas * @author Nicolas Grekas */ -class ServiceLocator implements \RectorPrefix20220607\Symfony\Contracts\Service\ServiceProviderInterface, \Countable +class ServiceLocator implements ServiceProviderInterface, \Countable { use ServiceLocatorTrait { get as private doGet; @@ -46,7 +46,7 @@ class ServiceLocator implements \RectorPrefix20220607\Symfony\Contracts\Service\ } try { return $this->doGet($id); - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\RuntimeException $e) { + } catch (RuntimeException $e) { $what = \sprintf('service "%s" required by "%s"', $id, $this->externalId); $message = \preg_replace('/service "\\.service_locator\\.[^"]++"/', $what, $e->getMessage()); if ($e->getMessage() === $message) { @@ -65,7 +65,7 @@ class ServiceLocator implements \RectorPrefix20220607\Symfony\Contracts\Service\ * @internal * @return $this */ - public function withContext(string $externalId, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Container $container) + public function withContext(string $externalId, Container $container) { $locator = clone $this; $locator->externalId = $externalId; @@ -76,11 +76,11 @@ class ServiceLocator implements \RectorPrefix20220607\Symfony\Contracts\Service\ { return \count($this->getProvidedServices()); } - private function createNotFoundException(string $id) : \RectorPrefix20220607\Psr\Container\NotFoundExceptionInterface + private function createNotFoundException(string $id) : NotFoundExceptionInterface { if ($this->loading) { $msg = \sprintf('The service "%s" has a dependency on a non-existent service "%s". This locator %s', \end($this->loading), $id, $this->formatAlternatives()); - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException($id, \end($this->loading) ?: null, null, [], $msg); + return new ServiceNotFoundException($id, \end($this->loading) ?: null, null, [], $msg); } $class = \debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS, 4); $class = isset($class[3]['object']) ? \get_class($class[3]['object']) : null; @@ -95,7 +95,7 @@ class ServiceLocator implements \RectorPrefix20220607\Symfony\Contracts\Service\ try { $this->container->get($id); $class = null; - } catch (\RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException $e) { + } catch (ServiceNotFoundException $e) { if ($e->getAlternatives()) { $msg[] = \sprintf('did you mean %s? Anyway,', $this->formatAlternatives($e->getAlternatives(), 'or')); } else { @@ -110,16 +110,16 @@ class ServiceLocator implements \RectorPrefix20220607\Symfony\Contracts\Service\ } if (!$class) { // no-op - } elseif (\is_subclass_of($class, \RectorPrefix20220607\Symfony\Contracts\Service\ServiceSubscriberInterface::class)) { + } elseif (\is_subclass_of($class, ServiceSubscriberInterface::class)) { $msg[] = \sprintf('Unless you need extra laziness, try using dependency injection instead. Otherwise, you need to declare it using "%s::getSubscribedServices()".', \preg_replace('/([^\\\\]++\\\\)++/', '', $class)); } else { $msg[] = 'Try using dependency injection instead.'; } - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException($id, \end($this->loading) ?: null, null, [], \implode(' ', $msg)); + return new ServiceNotFoundException($id, \end($this->loading) ?: null, null, [], \implode(' ', $msg)); } - private function createCircularReferenceException(string $id, array $path) : \RectorPrefix20220607\Psr\Container\ContainerExceptionInterface + private function createCircularReferenceException(string $id, array $path) : ContainerExceptionInterface { - return new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException($id, $path); + return new ServiceCircularReferenceException($id, $path); } private function formatAlternatives(array $alternatives = null, string $separator = 'and') : string { diff --git a/vendor/symfony/dependency-injection/TaggedContainerInterface.php b/vendor/symfony/dependency-injection/TaggedContainerInterface.php index a5694675a52..cccb07e344f 100644 --- a/vendor/symfony/dependency-injection/TaggedContainerInterface.php +++ b/vendor/symfony/dependency-injection/TaggedContainerInterface.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection; * * @author Fabien Potencier */ -interface TaggedContainerInterface extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface +interface TaggedContainerInterface extends ContainerInterface { /** * Returns service ids for a given tag. diff --git a/vendor/symfony/dependency-injection/TypedReference.php b/vendor/symfony/dependency-injection/TypedReference.php index 66fae7a9ef2..2ebd24d7c5c 100644 --- a/vendor/symfony/dependency-injection/TypedReference.php +++ b/vendor/symfony/dependency-injection/TypedReference.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Symfony\Component\DependencyInjection; * * @author Nicolas Grekas */ -class TypedReference extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference +class TypedReference extends Reference { /** * @var string @@ -31,7 +31,7 @@ class TypedReference extends \RectorPrefix20220607\Symfony\Component\DependencyI * @param int $invalidBehavior The behavior when the service does not exist * @param string|null $name The name of the argument targeting the service */ - public function __construct(string $id, string $type, int $invalidBehavior = \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, string $name = null) + public function __construct(string $id, string $type, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, string $name = null) { $this->name = $type === $id ? $name : null; parent::__construct($id, $invalidBehavior); diff --git a/vendor/symfony/filesystem/Exception/FileNotFoundException.php b/vendor/symfony/filesystem/Exception/FileNotFoundException.php index 39d24d12b11..6c3e7521e0d 100644 --- a/vendor/symfony/filesystem/Exception/FileNotFoundException.php +++ b/vendor/symfony/filesystem/Exception/FileNotFoundException.php @@ -16,7 +16,7 @@ namespace RectorPrefix20220607\Symfony\Component\Filesystem\Exception; * @author Fabien Potencier * @author Christian Gärtner */ -class FileNotFoundException extends \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException +class FileNotFoundException extends IOException { public function __construct(string $message = null, int $code = 0, \Throwable $previous = null, string $path = null) { diff --git a/vendor/symfony/filesystem/Exception/IOException.php b/vendor/symfony/filesystem/Exception/IOException.php index de6ca33328d..f3413c6a7c7 100644 --- a/vendor/symfony/filesystem/Exception/IOException.php +++ b/vendor/symfony/filesystem/Exception/IOException.php @@ -17,7 +17,7 @@ namespace RectorPrefix20220607\Symfony\Component\Filesystem\Exception; * @author Christian Gärtner * @author Fabien Potencier */ -class IOException extends \RuntimeException implements \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOExceptionInterface +class IOException extends \RuntimeException implements IOExceptionInterface { /** * @var string|null diff --git a/vendor/symfony/filesystem/Exception/IOExceptionInterface.php b/vendor/symfony/filesystem/Exception/IOExceptionInterface.php index 01b44f1fef5..e357c823538 100644 --- a/vendor/symfony/filesystem/Exception/IOExceptionInterface.php +++ b/vendor/symfony/filesystem/Exception/IOExceptionInterface.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Symfony\Component\Filesystem\Exception; * * @author Christian Gärtner */ -interface IOExceptionInterface extends \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\ExceptionInterface +interface IOExceptionInterface extends ExceptionInterface { /** * Returns the associated path for the exception. diff --git a/vendor/symfony/filesystem/Exception/InvalidArgumentException.php b/vendor/symfony/filesystem/Exception/InvalidArgumentException.php index 44c921f5547..80848aa3b3e 100644 --- a/vendor/symfony/filesystem/Exception/InvalidArgumentException.php +++ b/vendor/symfony/filesystem/Exception/InvalidArgumentException.php @@ -13,6 +13,6 @@ namespace RectorPrefix20220607\Symfony\Component\Filesystem\Exception; /** * @author Christian Flothmann */ -class InvalidArgumentException extends \InvalidArgumentException implements \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\ExceptionInterface +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { } diff --git a/vendor/symfony/filesystem/Exception/RuntimeException.php b/vendor/symfony/filesystem/Exception/RuntimeException.php index 1214acb9168..6b1a5205447 100644 --- a/vendor/symfony/filesystem/Exception/RuntimeException.php +++ b/vendor/symfony/filesystem/Exception/RuntimeException.php @@ -13,6 +13,6 @@ namespace RectorPrefix20220607\Symfony\Component\Filesystem\Exception; /** * @author Théo Fidry */ -class RuntimeException extends \RuntimeException implements \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\ExceptionInterface +class RuntimeException extends \RuntimeException implements ExceptionInterface { } diff --git a/vendor/symfony/filesystem/Filesystem.php b/vendor/symfony/filesystem/Filesystem.php index e36af6bbe86..4e3af8eedc6 100644 --- a/vendor/symfony/filesystem/Filesystem.php +++ b/vendor/symfony/filesystem/Filesystem.php @@ -35,7 +35,7 @@ class Filesystem { $originIsLocal = \stream_is_local($originFile) || 0 === \stripos($originFile, 'file://'); if ($originIsLocal && !\is_file($originFile)) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\FileNotFoundException(\sprintf('Failed to copy "%s" because file does not exist.', $originFile), 0, null, $originFile); + throw new FileNotFoundException(\sprintf('Failed to copy "%s" because file does not exist.', $originFile), 0, null, $originFile); } $this->mkdir(\dirname($targetFile)); $doCopy = \true; @@ -45,24 +45,24 @@ class Filesystem if ($doCopy) { // https://bugs.php.net/64634 if (!($source = self::box('fopen', $originFile, 'r'))) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Failed to copy "%s" to "%s" because source file could not be opened for reading: ', $originFile, $targetFile) . self::$lastError, 0, null, $originFile); + throw new IOException(\sprintf('Failed to copy "%s" to "%s" because source file could not be opened for reading: ', $originFile, $targetFile) . self::$lastError, 0, null, $originFile); } // Stream context created to allow files overwrite when using FTP stream wrapper - disabled by default if (!($target = self::box('fopen', $targetFile, 'w', \false, \stream_context_create(['ftp' => ['overwrite' => \true]])))) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Failed to copy "%s" to "%s" because target file could not be opened for writing: ', $originFile, $targetFile) . self::$lastError, 0, null, $originFile); + throw new IOException(\sprintf('Failed to copy "%s" to "%s" because target file could not be opened for writing: ', $originFile, $targetFile) . self::$lastError, 0, null, $originFile); } $bytesCopied = \stream_copy_to_stream($source, $target); \fclose($source); \fclose($target); unset($source, $target); if (!\is_file($targetFile)) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Failed to copy "%s" to "%s".', $originFile, $targetFile), 0, null, $originFile); + throw new IOException(\sprintf('Failed to copy "%s" to "%s".', $originFile, $targetFile), 0, null, $originFile); } if ($originIsLocal) { // Like `cp`, preserve executable permission bits self::box('chmod', $targetFile, \fileperms($targetFile) | \fileperms($originFile) & 0111); if ($bytesCopied !== ($bytesOrigin = \filesize($originFile))) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Failed to copy the whole content of "%s" to "%s" (%g of %g bytes copied).', $originFile, $targetFile, $bytesCopied, $bytesOrigin), 0, null, $originFile); + throw new IOException(\sprintf('Failed to copy the whole content of "%s" to "%s" (%g of %g bytes copied).', $originFile, $targetFile, $bytesCopied, $bytesOrigin), 0, null, $originFile); } } } @@ -80,7 +80,7 @@ class Filesystem continue; } if (!self::box('mkdir', $dir, $mode, \true) && !\is_dir($dir)) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Failed to create "%s": ', $dir) . self::$lastError, 0, null, $dir); + throw new IOException(\sprintf('Failed to create "%s": ', $dir) . self::$lastError, 0, null, $dir); } } } @@ -93,7 +93,7 @@ class Filesystem $maxPathLength = \PHP_MAXPATHLEN - 2; foreach ($this->toIterable($files) as $file) { if (\strlen($file) > $maxPathLength) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Could not check if file exist because path length exceeds %d characters.', $maxPathLength), 0, null, $file); + throw new IOException(\sprintf('Could not check if file exist because path length exceeds %d characters.', $maxPathLength), 0, null, $file); } if (!\file_exists($file)) { return \false; @@ -114,7 +114,7 @@ class Filesystem { foreach ($this->toIterable($files) as $file) { if (!($time ? self::box('touch', $file, $time, $atime) : self::box('touch', $file))) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Failed to touch "%s": ', $file) . self::$lastError, 0, null, $file); + throw new IOException(\sprintf('Failed to touch "%s": ', $file) . self::$lastError, 0, null, $file); } } } @@ -140,7 +140,7 @@ class Filesystem if (\is_link($file)) { // See https://bugs.php.net/52176 if (!(self::box('unlink', $file) || '\\' !== \DIRECTORY_SEPARATOR || self::box('rmdir', $file)) && \file_exists($file)) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Failed to remove symlink "%s": ', $file) . self::$lastError); + throw new IOException(\sprintf('Failed to remove symlink "%s": ', $file) . self::$lastError); } } elseif (\is_dir($file)) { if (!$isRecursive) { @@ -148,7 +148,7 @@ class Filesystem if (\file_exists($tmpName)) { try { self::doRemove([$tmpName], \true); - } catch (\RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException $exception) { + } catch (IOException $exception) { } } if (!\file_exists($tmpName) && self::box('rename', $file, $tmpName)) { @@ -165,10 +165,10 @@ class Filesystem if (null !== $origFile && self::box('rename', $file, $origFile)) { $file = $origFile; } - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Failed to remove directory "%s": ', $file) . $lastError); + throw new IOException(\sprintf('Failed to remove directory "%s": ', $file) . $lastError); } } elseif (!self::box('unlink', $file) && (\strpos(self::$lastError, 'Permission denied') !== \false || \file_exists($file))) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Failed to remove file "%s": ', $file) . self::$lastError); + throw new IOException(\sprintf('Failed to remove file "%s": ', $file) . self::$lastError); } } } @@ -186,7 +186,7 @@ class Filesystem { foreach ($this->toIterable($files) as $file) { if (\is_int($mode) && !self::box('chmod', $file, $mode & ~$umask)) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Failed to chmod file "%s": ', $file) . self::$lastError, 0, null, $file); + throw new IOException(\sprintf('Failed to chmod file "%s": ', $file) . self::$lastError, 0, null, $file); } if ($recursive && \is_dir($file) && !\is_link($file)) { $this->chmod(new \FilesystemIterator($file), $mode, $umask, \true); @@ -210,11 +210,11 @@ class Filesystem } if (\is_link($file) && \function_exists('lchown')) { if (!self::box('lchown', $file, $user)) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Failed to chown file "%s": ', $file) . self::$lastError, 0, null, $file); + throw new IOException(\sprintf('Failed to chown file "%s": ', $file) . self::$lastError, 0, null, $file); } } else { if (!self::box('chown', $file, $user)) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Failed to chown file "%s": ', $file) . self::$lastError, 0, null, $file); + throw new IOException(\sprintf('Failed to chown file "%s": ', $file) . self::$lastError, 0, null, $file); } } } @@ -236,11 +236,11 @@ class Filesystem } if (\is_link($file) && \function_exists('lchgrp')) { if (!self::box('lchgrp', $file, $group)) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Failed to chgrp file "%s": ', $file) . self::$lastError, 0, null, $file); + throw new IOException(\sprintf('Failed to chgrp file "%s": ', $file) . self::$lastError, 0, null, $file); } } else { if (!self::box('chgrp', $file, $group)) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Failed to chgrp file "%s": ', $file) . self::$lastError, 0, null, $file); + throw new IOException(\sprintf('Failed to chgrp file "%s": ', $file) . self::$lastError, 0, null, $file); } } } @@ -255,7 +255,7 @@ class Filesystem { // we check that target does not exist if (!$overwrite && $this->isReadable($target)) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target); + throw new IOException(\sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target); } if (!self::box('rename', $origin, $target)) { if (\is_dir($origin)) { @@ -264,7 +264,7 @@ class Filesystem $this->remove($origin); return; } - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Cannot rename "%s" to "%s": ', $origin, $target) . self::$lastError, 0, null, $target); + throw new IOException(\sprintf('Cannot rename "%s" to "%s": ', $origin, $target) . self::$lastError, 0, null, $target); } } /** @@ -276,7 +276,7 @@ class Filesystem { $maxPathLength = \PHP_MAXPATHLEN - 2; if (\strlen($filename) > $maxPathLength) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Could not check if file is readable because path length exceeds %d characters.', $maxPathLength), 0, null, $filename); + throw new IOException(\sprintf('Could not check if file is readable because path length exceeds %d characters.', $maxPathLength), 0, null, $filename); } return \is_readable($filename); } @@ -319,10 +319,10 @@ class Filesystem { self::assertFunctionExists('link'); if (!$this->exists($originFile)) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\FileNotFoundException(null, 0, null, $originFile); + throw new FileNotFoundException(null, 0, null, $originFile); } if (!\is_file($originFile)) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\FileNotFoundException(\sprintf('Origin file "%s" is not a file.', $originFile)); + throw new FileNotFoundException(\sprintf('Origin file "%s" is not a file.', $originFile)); } foreach ($this->toIterable($targetFiles) as $targetFile) { if (\is_file($targetFile)) { @@ -343,10 +343,10 @@ class Filesystem { if (self::$lastError) { if ('\\' === \DIRECTORY_SEPARATOR && \strpos(self::$lastError, 'error code(1314)') !== \false) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Unable to create "%s" link due to error code 1314: \'A required privilege is not held by the client\'. Do you have the required Administrator-rights?', $linkType), 0, null, $target); + throw new IOException(\sprintf('Unable to create "%s" link due to error code 1314: \'A required privilege is not held by the client\'. Do you have the required Administrator-rights?', $linkType), 0, null, $target); } } - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Failed to create "%s" link from "%s" to "%s": ', $linkType, $origin, $target) . self::$lastError, 0, null, $target); + throw new IOException(\sprintf('Failed to create "%s" link from "%s" to "%s": ', $linkType, $origin, $target) . self::$lastError, 0, null, $target); } /** * Resolves links in paths. @@ -378,10 +378,10 @@ class Filesystem public function makePathRelative(string $endPath, string $startPath) : string { if (!$this->isAbsolutePath($startPath)) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\InvalidArgumentException(\sprintf('The start path "%s" is not absolute.', $startPath)); + throw new InvalidArgumentException(\sprintf('The start path "%s" is not absolute.', $startPath)); } if (!$this->isAbsolutePath($endPath)) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\InvalidArgumentException(\sprintf('The end path "%s" is not absolute.', $endPath)); + throw new InvalidArgumentException(\sprintf('The end path "%s" is not absolute.', $endPath)); } // Normalize separators on Windows if ('\\' === \DIRECTORY_SEPARATOR) { @@ -451,7 +451,7 @@ class Filesystem $originDir = \rtrim($originDir, '/\\'); $originDirLen = \strlen($originDir); if (!$this->exists($originDir)) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('The origin directory specified "%s" was not found.', $originDir), 0, null, $originDir); + throw new IOException(\sprintf('The origin directory specified "%s" was not found.', $originDir), 0, null, $originDir); } // Iterate in destination folder to remove obsolete entries if ($this->exists($targetDir) && isset($options['delete']) && $options['delete']) { @@ -488,7 +488,7 @@ class Filesystem } elseif (\is_file($file)) { $this->copy($file, $target, $options['override'] ?? \false); } else { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Unable to guess "%s" file type.', $file), 0, null, $file); + throw new IOException(\sprintf('Unable to guess "%s" file type.', $file), 0, null, $file); } } } @@ -520,7 +520,7 @@ class Filesystem } return $tmpFile; } - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException('A temporary file could not be created: ' . self::$lastError); + throw new IOException('A temporary file could not be created: ' . self::$lastError); } // Loop until we create a valid temp file or have reached 10 attempts for ($i = 0; $i < 10; ++$i) { @@ -535,7 +535,7 @@ class Filesystem self::box('fclose', $handle); return $tmpFile; } - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException('A temporary file could not be created: ' . self::$lastError); + throw new IOException('A temporary file could not be created: ' . self::$lastError); } /** * Atomically dumps content into a file. @@ -558,7 +558,7 @@ class Filesystem $tmpFile = $this->tempnam($dir, \basename($filename)); try { if (\false === self::box('file_put_contents', $tmpFile, $content)) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Failed to write file "%s": ', $filename) . self::$lastError, 0, null, $filename); + throw new IOException(\sprintf('Failed to write file "%s": ', $filename) . self::$lastError, 0, null, $filename); } self::box('chmod', $tmpFile, \file_exists($filename) ? \fileperms($filename) : 0666 & ~\umask()); $this->rename($tmpFile, $filename, \true); @@ -587,7 +587,7 @@ class Filesystem } $lock = \func_num_args() > 2 && \func_get_arg(2); if (\false === self::box('file_put_contents', $filename, $content, \FILE_APPEND | ($lock ? \LOCK_EX : 0))) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Failed to write file "%s": ', $filename) . self::$lastError, 0, null, $filename); + throw new IOException(\sprintf('Failed to write file "%s": ', $filename) . self::$lastError, 0, null, $filename); } } /** @@ -608,7 +608,7 @@ class Filesystem private static function assertFunctionExists(string $func) : void { if (!\function_exists($func)) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException(\sprintf('Unable to perform filesystem operation because the "%s()" function has been disabled.', $func)); + throw new IOException(\sprintf('Unable to perform filesystem operation because the "%s()" function has been disabled.', $func)); } } /** diff --git a/vendor/symfony/filesystem/Path.php b/vendor/symfony/filesystem/Path.php index 05204d6776e..8a1cc67a5f1 100644 --- a/vendor/symfony/filesystem/Path.php +++ b/vendor/symfony/filesystem/Path.php @@ -176,7 +176,7 @@ final class Path if (\getenv('HOMEDRIVE') && \getenv('HOMEPATH')) { return self::canonicalize(\getenv('HOMEDRIVE') . \getenv('HOMEPATH')); } - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\RuntimeException("Cannot find the home directory path: Your environment or operating system isn't supported."); + throw new RuntimeException("Cannot find the home directory path: Your environment or operating system isn't supported."); } /** * Returns the root directory of a path. @@ -379,10 +379,10 @@ final class Path public static function makeAbsolute(string $path, string $basePath) : string { if ('' === $basePath) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\InvalidArgumentException(\sprintf('The base path must be a non-empty string. Got: "%s".', $basePath)); + throw new InvalidArgumentException(\sprintf('The base path must be a non-empty string. Got: "%s".', $basePath)); } if (!self::isAbsolute($basePath)) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\InvalidArgumentException(\sprintf('The base path "%s" is not an absolute path.', $basePath)); + throw new InvalidArgumentException(\sprintf('The base path "%s" is not an absolute path.', $basePath)); } if (self::isAbsolute($path)) { return self::canonicalize($path); @@ -464,11 +464,11 @@ final class Path // If the passed path is absolute, but the base path is not, we // cannot generate a relative path if ('' !== $root && '' === $baseRoot) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\InvalidArgumentException(\sprintf('The absolute path "%s" cannot be made relative to the relative path "%s". You should provide an absolute base path instead.', $path, $basePath)); + throw new InvalidArgumentException(\sprintf('The absolute path "%s" cannot be made relative to the relative path "%s". You should provide an absolute base path instead.', $path, $basePath)); } // Fail if the roots of the two paths are different if ($baseRoot && $root !== $baseRoot) { - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\InvalidArgumentException(\sprintf('The path "%s" cannot be made relative to "%s", because they have different roots ("%s" and "%s").', $path, $basePath, $root, $baseRoot)); + throw new InvalidArgumentException(\sprintf('The path "%s" cannot be made relative to "%s", because they have different roots ("%s" and "%s").', $path, $basePath, $root, $baseRoot)); } if ('' === $relativeBasePath) { return $relativePath; diff --git a/vendor/symfony/finder/Comparator/DateComparator.php b/vendor/symfony/finder/Comparator/DateComparator.php index 4111237af2e..d6cc2d16c00 100644 --- a/vendor/symfony/finder/Comparator/DateComparator.php +++ b/vendor/symfony/finder/Comparator/DateComparator.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Symfony\Component\Finder\Comparator; * * @author Fabien Potencier */ -class DateComparator extends \RectorPrefix20220607\Symfony\Component\Finder\Comparator\Comparator +class DateComparator extends Comparator { /** * @param string $test A comparison string diff --git a/vendor/symfony/finder/Comparator/NumberComparator.php b/vendor/symfony/finder/Comparator/NumberComparator.php index ce19ab21a62..bc3818bc4d6 100644 --- a/vendor/symfony/finder/Comparator/NumberComparator.php +++ b/vendor/symfony/finder/Comparator/NumberComparator.php @@ -31,7 +31,7 @@ namespace RectorPrefix20220607\Symfony\Component\Finder\Comparator; * * @see http://physics.nist.gov/cuu/Units/binary.html */ -class NumberComparator extends \RectorPrefix20220607\Symfony\Component\Finder\Comparator\Comparator +class NumberComparator extends Comparator { /** * @param string|int $test A comparison string or an integer diff --git a/vendor/symfony/finder/Finder.php b/vendor/symfony/finder/Finder.php index 38ddeff97cd..c31eb3f58f9 100644 --- a/vendor/symfony/finder/Finder.php +++ b/vendor/symfony/finder/Finder.php @@ -141,7 +141,7 @@ class Finder implements \IteratorAggregate, \Countable */ public function directories() { - $this->mode = \RectorPrefix20220607\Symfony\Component\Finder\Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES; + $this->mode = Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES; return $this; } /** @@ -151,7 +151,7 @@ class Finder implements \IteratorAggregate, \Countable */ public function files() { - $this->mode = \RectorPrefix20220607\Symfony\Component\Finder\Iterator\FileTypeFilterIterator::ONLY_FILES; + $this->mode = Iterator\FileTypeFilterIterator::ONLY_FILES; return $this; } /** @@ -173,7 +173,7 @@ class Finder implements \IteratorAggregate, \Countable public function depth($levels) { foreach ((array) $levels as $level) { - $this->depths[] = new \RectorPrefix20220607\Symfony\Component\Finder\Comparator\NumberComparator($level); + $this->depths[] = new Comparator\NumberComparator($level); } return $this; } @@ -199,7 +199,7 @@ class Finder implements \IteratorAggregate, \Countable public function date($dates) { foreach ((array) $dates as $date) { - $this->dates[] = new \RectorPrefix20220607\Symfony\Component\Finder\Comparator\DateComparator($date); + $this->dates[] = new Comparator\DateComparator($date); } return $this; } @@ -340,7 +340,7 @@ class Finder implements \IteratorAggregate, \Countable public function size($sizes) { foreach ((array) $sizes as $size) { - $this->sizes[] = new \RectorPrefix20220607\Symfony\Component\Finder\Comparator\NumberComparator($size); + $this->sizes[] = new Comparator\NumberComparator($size); } return $this; } @@ -455,7 +455,7 @@ class Finder implements \IteratorAggregate, \Countable */ public function sortByName(bool $useNaturalSort = \false) { - $this->sort = $useNaturalSort ? \RectorPrefix20220607\Symfony\Component\Finder\Iterator\SortableIterator::SORT_BY_NAME_NATURAL : \RectorPrefix20220607\Symfony\Component\Finder\Iterator\SortableIterator::SORT_BY_NAME; + $this->sort = $useNaturalSort ? Iterator\SortableIterator::SORT_BY_NAME_NATURAL : Iterator\SortableIterator::SORT_BY_NAME; return $this; } /** @@ -469,7 +469,7 @@ class Finder implements \IteratorAggregate, \Countable */ public function sortByType() { - $this->sort = \RectorPrefix20220607\Symfony\Component\Finder\Iterator\SortableIterator::SORT_BY_TYPE; + $this->sort = Iterator\SortableIterator::SORT_BY_TYPE; return $this; } /** @@ -485,7 +485,7 @@ class Finder implements \IteratorAggregate, \Countable */ public function sortByAccessedTime() { - $this->sort = \RectorPrefix20220607\Symfony\Component\Finder\Iterator\SortableIterator::SORT_BY_ACCESSED_TIME; + $this->sort = Iterator\SortableIterator::SORT_BY_ACCESSED_TIME; return $this; } /** @@ -513,7 +513,7 @@ class Finder implements \IteratorAggregate, \Countable */ public function sortByChangedTime() { - $this->sort = \RectorPrefix20220607\Symfony\Component\Finder\Iterator\SortableIterator::SORT_BY_CHANGED_TIME; + $this->sort = Iterator\SortableIterator::SORT_BY_CHANGED_TIME; return $this; } /** @@ -529,7 +529,7 @@ class Finder implements \IteratorAggregate, \Countable */ public function sortByModifiedTime() { - $this->sort = \RectorPrefix20220607\Symfony\Component\Finder\Iterator\SortableIterator::SORT_BY_MODIFIED_TIME; + $this->sort = Iterator\SortableIterator::SORT_BY_MODIFIED_TIME; return $this; } /** @@ -588,7 +588,7 @@ class Finder implements \IteratorAggregate, \Countable \sort($glob); $resolvedDirs[] = \array_map(\Closure::fromCallable([$this, 'normalizeDir']), $glob); } else { - throw new \RectorPrefix20220607\Symfony\Component\Finder\Exception\DirectoryNotFoundException(\sprintf('The "%s" directory does not exist.', $dir)); + throw new DirectoryNotFoundException(\sprintf('The "%s" directory does not exist.', $dir)); } } $this->dirs = \array_merge($this->dirs, ...$resolvedDirs); @@ -611,13 +611,13 @@ class Finder implements \IteratorAggregate, \Countable if (1 === \count($this->dirs) && 0 === \count($this->iterators)) { $iterator = $this->searchInDirectory($this->dirs[0]); if ($this->sort || $this->reverseSorting) { - $iterator = (new \RectorPrefix20220607\Symfony\Component\Finder\Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator(); + $iterator = (new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator(); } return $iterator; } $iterator = new \AppendIterator(); foreach ($this->dirs as $dir) { - $iterator->append(new \IteratorIterator(new \RectorPrefix20220607\Symfony\Component\Finder\Iterator\LazyIterator(function () use($dir) { + $iterator->append(new \IteratorIterator(new LazyIterator(function () use($dir) { return $this->searchInDirectory($dir); }))); } @@ -625,7 +625,7 @@ class Finder implements \IteratorAggregate, \Countable $iterator->append($it); } if ($this->sort || $this->reverseSorting) { - $iterator = (new \RectorPrefix20220607\Symfony\Component\Finder\Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator(); + $iterator = (new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator(); } return $iterator; } @@ -707,37 +707,37 @@ class Finder implements \IteratorAggregate, \Countable if ($this->followLinks) { $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS; } - $iterator = new \RectorPrefix20220607\Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs); + $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs); if ($exclude) { - $iterator = new \RectorPrefix20220607\Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator($iterator, $exclude); + $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $exclude); } $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST); if ($minDepth > 0 || $maxDepth < \PHP_INT_MAX) { - $iterator = new \RectorPrefix20220607\Symfony\Component\Finder\Iterator\DepthRangeFilterIterator($iterator, $minDepth, $maxDepth); + $iterator = new Iterator\DepthRangeFilterIterator($iterator, $minDepth, $maxDepth); } if ($this->mode) { - $iterator = new \RectorPrefix20220607\Symfony\Component\Finder\Iterator\FileTypeFilterIterator($iterator, $this->mode); + $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode); } if ($this->names || $this->notNames) { - $iterator = new \RectorPrefix20220607\Symfony\Component\Finder\Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames); + $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames); } if ($this->contains || $this->notContains) { - $iterator = new \RectorPrefix20220607\Symfony\Component\Finder\Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains); + $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains); } if ($this->sizes) { - $iterator = new \RectorPrefix20220607\Symfony\Component\Finder\Iterator\SizeRangeFilterIterator($iterator, $this->sizes); + $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes); } if ($this->dates) { - $iterator = new \RectorPrefix20220607\Symfony\Component\Finder\Iterator\DateRangeFilterIterator($iterator, $this->dates); + $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates); } if ($this->filters) { - $iterator = new \RectorPrefix20220607\Symfony\Component\Finder\Iterator\CustomFilterIterator($iterator, $this->filters); + $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters); } if ($this->paths || $notPaths) { - $iterator = new \RectorPrefix20220607\Symfony\Component\Finder\Iterator\PathFilterIterator($iterator, $this->paths, $notPaths); + $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $notPaths); } if (static::IGNORE_VCS_IGNORED_FILES === (static::IGNORE_VCS_IGNORED_FILES & $this->ignore)) { - $iterator = new \RectorPrefix20220607\Symfony\Component\Finder\Iterator\VcsIgnoredFilterIterator($iterator, $dir); + $iterator = new Iterator\VcsIgnoredFilterIterator($iterator, $dir); } return $iterator; } diff --git a/vendor/symfony/finder/Iterator/FilecontentFilterIterator.php b/vendor/symfony/finder/Iterator/FilecontentFilterIterator.php index 40e114897a4..f70db3dff55 100644 --- a/vendor/symfony/finder/Iterator/FilecontentFilterIterator.php +++ b/vendor/symfony/finder/Iterator/FilecontentFilterIterator.php @@ -19,7 +19,7 @@ use RectorPrefix20220607\Symfony\Component\Finder\SplFileInfo; * * @extends MultiplePcreFilterIterator */ -class FilecontentFilterIterator extends \RectorPrefix20220607\Symfony\Component\Finder\Iterator\MultiplePcreFilterIterator +class FilecontentFilterIterator extends MultiplePcreFilterIterator { /** * Filters the iterator values. diff --git a/vendor/symfony/finder/Iterator/FilenameFilterIterator.php b/vendor/symfony/finder/Iterator/FilenameFilterIterator.php index 78be751c759..917d05d8d52 100644 --- a/vendor/symfony/finder/Iterator/FilenameFilterIterator.php +++ b/vendor/symfony/finder/Iterator/FilenameFilterIterator.php @@ -18,7 +18,7 @@ use RectorPrefix20220607\Symfony\Component\Finder\Glob; * * @extends MultiplePcreFilterIterator */ -class FilenameFilterIterator extends \RectorPrefix20220607\Symfony\Component\Finder\Iterator\MultiplePcreFilterIterator +class FilenameFilterIterator extends MultiplePcreFilterIterator { /** * Filters the iterator values. @@ -37,6 +37,6 @@ class FilenameFilterIterator extends \RectorPrefix20220607\Symfony\Component\Fin */ protected function toRegex(string $str) : string { - return $this->isRegex($str) ? $str : \RectorPrefix20220607\Symfony\Component\Finder\Glob::toRegex($str); + return $this->isRegex($str) ? $str : Glob::toRegex($str); } } diff --git a/vendor/symfony/finder/Iterator/PathFilterIterator.php b/vendor/symfony/finder/Iterator/PathFilterIterator.php index 807bd24b10c..2036f77b5ee 100644 --- a/vendor/symfony/finder/Iterator/PathFilterIterator.php +++ b/vendor/symfony/finder/Iterator/PathFilterIterator.php @@ -19,7 +19,7 @@ use RectorPrefix20220607\Symfony\Component\Finder\SplFileInfo; * * @extends MultiplePcreFilterIterator */ -class PathFilterIterator extends \RectorPrefix20220607\Symfony\Component\Finder\Iterator\MultiplePcreFilterIterator +class PathFilterIterator extends MultiplePcreFilterIterator { /** * Filters the iterator values. diff --git a/vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php b/vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php index 2bc89b17d45..c04c1e9df4a 100644 --- a/vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php +++ b/vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php @@ -59,7 +59,7 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator /** * Return an instance of SplFileInfo with support for relative paths. */ - public function current() : \RectorPrefix20220607\Symfony\Component\Finder\SplFileInfo + public function current() : SplFileInfo { // the logic here avoids redoing the same work in all iterations if (!isset($this->subPath)) { @@ -73,7 +73,7 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator if ('/' !== ($basePath = $this->rootPath)) { $basePath .= $this->directorySeparator; } - return new \RectorPrefix20220607\Symfony\Component\Finder\SplFileInfo($basePath . $subPathname, $this->subPath, $subPathname); + return new SplFileInfo($basePath . $subPathname, $this->subPath, $subPathname); } public function hasChildren($allowLinks = \false) : bool { @@ -105,7 +105,7 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator } return $children; } catch (\UnexpectedValueException $e) { - throw new \RectorPrefix20220607\Symfony\Component\Finder\Exception\AccessDeniedException($e->getMessage(), $e->getCode(), $e); + throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e); } } /** diff --git a/vendor/symfony/finder/Iterator/VcsIgnoredFilterIterator.php b/vendor/symfony/finder/Iterator/VcsIgnoredFilterIterator.php index 7febe4ad601..dab24c28e2b 100644 --- a/vendor/symfony/finder/Iterator/VcsIgnoredFilterIterator.php +++ b/vendor/symfony/finder/Iterator/VcsIgnoredFilterIterator.php @@ -122,7 +122,7 @@ final class VcsIgnoredFilterIterator extends \FilterIterator throw new \RuntimeException("The \"ignoreVCSIgnored\" option cannot be used by the Finder as the \"{$path}\" file is not readable."); } $gitignoreFileContent = \file_get_contents($path); - return $this->gitignoreFilesCache[$path] = [\RectorPrefix20220607\Symfony\Component\Finder\Gitignore::toRegex($gitignoreFileContent), \RectorPrefix20220607\Symfony\Component\Finder\Gitignore::toRegexMatchingNegatedPatterns($gitignoreFileContent)]; + return $this->gitignoreFilesCache[$path] = [Gitignore::toRegex($gitignoreFileContent), Gitignore::toRegexMatchingNegatedPatterns($gitignoreFileContent)]; } private function normalizePath(string $path) : string { diff --git a/vendor/symfony/polyfill-intl-normalizer/Normalizer.php b/vendor/symfony/polyfill-intl-normalizer/Normalizer.php index ca546712bf8..32d0588536b 100644 --- a/vendor/symfony/polyfill-intl-normalizer/Normalizer.php +++ b/vendor/symfony/polyfill-intl-normalizer/Normalizer.php @@ -34,8 +34,8 @@ class Normalizer private static $D; private static $KD; private static $cC; - private static $ulenMask = ["À" => 2, "Ð" => 2, "à" => 3, "ð" => 4]; - private static $ASCII = " eiasntrolud][cmp'\ng|hv.fb,:=-q10C2*yx)(L9AS/P\"EjMIk3>5T 2, "\xd0" => 2, "\xe0" => 3, "\xf0" => 4]; + private static $ASCII = " eiasntrolud][cmp'\ng|hv.fb,:=-q10C2*yx)(L9AS/P\"EjMIk3>5T= 80000) { return require __DIR__ . '/bootstrap80.php'; } if (!\function_exists('normalizer_is_normalized')) { - function normalizer_is_normalized($string, $form = \RectorPrefix20220607\Symfony\Polyfill\Intl\Normalizer\Normalizer::FORM_C) + function normalizer_is_normalized($string, $form = p\Normalizer::FORM_C) { - return \RectorPrefix20220607\Symfony\Polyfill\Intl\Normalizer\Normalizer::isNormalized($string, $form); + return p\Normalizer::isNormalized($string, $form); } } if (!\function_exists('normalizer_normalize')) { - function normalizer_normalize($string, $form = \RectorPrefix20220607\Symfony\Polyfill\Intl\Normalizer\Normalizer::FORM_C) + function normalizer_normalize($string, $form = p\Normalizer::FORM_C) { - return \RectorPrefix20220607\Symfony\Polyfill\Intl\Normalizer\Normalizer::normalize($string, $form); + return p\Normalizer::normalize($string, $form); } } diff --git a/vendor/symfony/polyfill-intl-normalizer/bootstrap80.php b/vendor/symfony/polyfill-intl-normalizer/bootstrap80.php index 3777446d072..584647d5b12 100644 --- a/vendor/symfony/polyfill-intl-normalizer/bootstrap80.php +++ b/vendor/symfony/polyfill-intl-normalizer/bootstrap80.php @@ -1,6 +1,6 @@ 2, "Ð" => 2, "à" => 3, "ð" => 4]; + static $ulenMask = ["\xc0" => 2, "\xd0" => 2, "\xe0" => 3, "\xf0" => 4]; $cnt = \floor(\count($convmap) / 4) * 4; $i = 0; $len = \strlen($s); $result = ''; while ($i < $len) { - $ulen = $s[$i] < "€" ? 1 : $ulenMask[$s[$i] & "ð"]; + $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xf0"]; $uchr = \substr($s, $i, $ulen); $i += $ulen; $c = self::mb_ord($uchr); @@ -259,11 +259,11 @@ final class Mbstring } $map = $lower; } - static $ulenMask = ["À" => 2, "Ð" => 2, "à" => 3, "ð" => 4]; + static $ulenMask = ["\xc0" => 2, "\xd0" => 2, "\xe0" => 3, "\xf0" => 4]; $i = 0; $len = \strlen($s); while ($i < $len) { - $ulen = $s[$i] < "€" ? 1 : $ulenMask[$s[$i] & "ð"]; + $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xf0"]; $uchr = \substr($s, $i, $ulen); $i += $ulen; if (isset($map[$uchr])) { diff --git a/vendor/symfony/polyfill-mbstring/bootstrap.php b/vendor/symfony/polyfill-mbstring/bootstrap.php index f918bf27a3f..52285204fd3 100644 --- a/vendor/symfony/polyfill-mbstring/bootstrap.php +++ b/vendor/symfony/polyfill-mbstring/bootstrap.php @@ -1,6 +1,6 @@ = 80000) { if (!\function_exists('mb_convert_encoding')) { function mb_convert_encoding($string, $to_encoding, $from_encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_convert_encoding($string, $to_encoding, $from_encoding); + return p\Mbstring::mb_convert_encoding($string, $to_encoding, $from_encoding); } } if (!\function_exists('mb_decode_mimeheader')) { function mb_decode_mimeheader($string) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_decode_mimeheader($string); + return p\Mbstring::mb_decode_mimeheader($string); } } if (!\function_exists('mb_encode_mimeheader')) { function mb_encode_mimeheader($string, $charset = null, $transfer_encoding = null, $newline = "\r\n", $indent = 0) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_encode_mimeheader($string, $charset, $transfer_encoding, $newline, $indent); + return p\Mbstring::mb_encode_mimeheader($string, $charset, $transfer_encoding, $newline, $indent); } } if (!\function_exists('mb_decode_numericentity')) { function mb_decode_numericentity($string, $map, $encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_decode_numericentity($string, $map, $encoding); + return p\Mbstring::mb_decode_numericentity($string, $map, $encoding); } } if (!\function_exists('mb_encode_numericentity')) { function mb_encode_numericentity($string, $map, $encoding = null, $hex = \false) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_encode_numericentity($string, $map, $encoding, $hex); + return p\Mbstring::mb_encode_numericentity($string, $map, $encoding, $hex); } } if (!\function_exists('mb_convert_case')) { function mb_convert_case($string, $mode, $encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_convert_case($string, $mode, $encoding); + return p\Mbstring::mb_convert_case($string, $mode, $encoding); } } if (!\function_exists('mb_internal_encoding')) { function mb_internal_encoding($encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_internal_encoding($encoding); + return p\Mbstring::mb_internal_encoding($encoding); } } if (!\function_exists('mb_language')) { function mb_language($language = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_language($language); + return p\Mbstring::mb_language($language); } } if (!\function_exists('mb_list_encodings')) { function mb_list_encodings() { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_list_encodings(); + return p\Mbstring::mb_list_encodings(); } } if (!\function_exists('mb_encoding_aliases')) { function mb_encoding_aliases($encoding) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_encoding_aliases($encoding); + return p\Mbstring::mb_encoding_aliases($encoding); } } if (!\function_exists('mb_check_encoding')) { function mb_check_encoding($value = null, $encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_check_encoding($value, $encoding); + return p\Mbstring::mb_check_encoding($value, $encoding); } } if (!\function_exists('mb_detect_encoding')) { function mb_detect_encoding($string, $encodings = null, $strict = \false) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_detect_encoding($string, $encodings, $strict); + return p\Mbstring::mb_detect_encoding($string, $encodings, $strict); } } if (!\function_exists('mb_detect_order')) { function mb_detect_order($encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_detect_order($encoding); + return p\Mbstring::mb_detect_order($encoding); } } if (!\function_exists('mb_parse_str')) { @@ -102,133 +102,133 @@ if (!\function_exists('mb_parse_str')) { if (!\function_exists('mb_strlen')) { function mb_strlen($string, $encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_strlen($string, $encoding); + return p\Mbstring::mb_strlen($string, $encoding); } } if (!\function_exists('mb_strpos')) { function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_strpos($haystack, $needle, $offset, $encoding); + return p\Mbstring::mb_strpos($haystack, $needle, $offset, $encoding); } } if (!\function_exists('mb_strtolower')) { function mb_strtolower($string, $encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_strtolower($string, $encoding); + return p\Mbstring::mb_strtolower($string, $encoding); } } if (!\function_exists('mb_strtoupper')) { function mb_strtoupper($string, $encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_strtoupper($string, $encoding); + return p\Mbstring::mb_strtoupper($string, $encoding); } } if (!\function_exists('mb_substitute_character')) { function mb_substitute_character($substitute_character = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_substitute_character($substitute_character); + return p\Mbstring::mb_substitute_character($substitute_character); } } if (!\function_exists('mb_substr')) { function mb_substr($string, $start, $length = 2147483647, $encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_substr($string, $start, $length, $encoding); + return p\Mbstring::mb_substr($string, $start, $length, $encoding); } } if (!\function_exists('mb_stripos')) { function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_stripos($haystack, $needle, $offset, $encoding); + return p\Mbstring::mb_stripos($haystack, $needle, $offset, $encoding); } } if (!\function_exists('mb_stristr')) { function mb_stristr($haystack, $needle, $before_needle = \false, $encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_stristr($haystack, $needle, $before_needle, $encoding); + return p\Mbstring::mb_stristr($haystack, $needle, $before_needle, $encoding); } } if (!\function_exists('mb_strrchr')) { function mb_strrchr($haystack, $needle, $before_needle = \false, $encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_strrchr($haystack, $needle, $before_needle, $encoding); + return p\Mbstring::mb_strrchr($haystack, $needle, $before_needle, $encoding); } } if (!\function_exists('mb_strrichr')) { function mb_strrichr($haystack, $needle, $before_needle = \false, $encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_strrichr($haystack, $needle, $before_needle, $encoding); + return p\Mbstring::mb_strrichr($haystack, $needle, $before_needle, $encoding); } } if (!\function_exists('mb_strripos')) { function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_strripos($haystack, $needle, $offset, $encoding); + return p\Mbstring::mb_strripos($haystack, $needle, $offset, $encoding); } } if (!\function_exists('mb_strrpos')) { function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_strrpos($haystack, $needle, $offset, $encoding); + return p\Mbstring::mb_strrpos($haystack, $needle, $offset, $encoding); } } if (!\function_exists('mb_strstr')) { function mb_strstr($haystack, $needle, $before_needle = \false, $encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_strstr($haystack, $needle, $before_needle, $encoding); + return p\Mbstring::mb_strstr($haystack, $needle, $before_needle, $encoding); } } if (!\function_exists('mb_get_info')) { function mb_get_info($type = 'all') { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_get_info($type); + return p\Mbstring::mb_get_info($type); } } if (!\function_exists('mb_http_output')) { function mb_http_output($encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_http_output($encoding); + return p\Mbstring::mb_http_output($encoding); } } if (!\function_exists('mb_strwidth')) { function mb_strwidth($string, $encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_strwidth($string, $encoding); + return p\Mbstring::mb_strwidth($string, $encoding); } } if (!\function_exists('mb_substr_count')) { function mb_substr_count($haystack, $needle, $encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_substr_count($haystack, $needle, $encoding); + return p\Mbstring::mb_substr_count($haystack, $needle, $encoding); } } if (!\function_exists('mb_output_handler')) { function mb_output_handler($string, $status) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_output_handler($string, $status); + return p\Mbstring::mb_output_handler($string, $status); } } if (!\function_exists('mb_http_input')) { function mb_http_input($type = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_http_input($type); + return p\Mbstring::mb_http_input($type); } } if (!\function_exists('mb_convert_variables')) { function mb_convert_variables($to_encoding, $from_encoding, &...$vars) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_convert_variables($to_encoding, $from_encoding, ...$vars); + return p\Mbstring::mb_convert_variables($to_encoding, $from_encoding, ...$vars); } } if (!\function_exists('mb_ord')) { function mb_ord($string, $encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_ord($string, $encoding); + return p\Mbstring::mb_ord($string, $encoding); } } if (!\function_exists('mb_chr')) { function mb_chr($codepoint, $encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_chr($codepoint, $encoding); + return p\Mbstring::mb_chr($codepoint, $encoding); } } if (!\function_exists('mb_scrub')) { @@ -241,7 +241,7 @@ if (!\function_exists('mb_scrub')) { if (!\function_exists('mb_str_split')) { function mb_str_split($string, $length = 1, $encoding = null) { - return \RectorPrefix20220607\Symfony\Polyfill\Mbstring\Mbstring::mb_str_split($string, $length, $encoding); + return p\Mbstring::mb_str_split($string, $length, $encoding); } } if (\extension_loaded('mbstring')) { diff --git a/vendor/symfony/polyfill-mbstring/bootstrap80.php b/vendor/symfony/polyfill-mbstring/bootstrap80.php index eb68a93c3f0..c5f0aba1645 100644 --- a/vendor/symfony/polyfill-mbstring/bootstrap80.php +++ b/vendor/symfony/polyfill-mbstring/bootstrap80.php @@ -1,6 +1,6 @@ $multiplier) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException(\sprintf('Multiplier must be positive, %d given.', $multiplier)); + throw new InvalidArgumentException(\sprintf('Multiplier must be positive, %d given.', $multiplier)); } $str = clone $this; $str->string = \str_repeat($str->string, $multiplier); @@ -417,17 +417,17 @@ abstract class AbstractString implements \JsonSerializable $delimiter .= 'i'; } \set_error_handler(static function ($t, $m) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException($m); + throw new InvalidArgumentException($m); }); try { if (\false === ($chunks = \preg_split($delimiter, $this->string, $limit, $flags))) { $lastError = \preg_last_error(); foreach (\get_defined_constants(\true)['pcre'] as $k => $v) { if ($lastError === $v && \substr_compare($k, '_ERROR', -\strlen('_ERROR')) === 0) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\RuntimeException('Splitting failed with ' . $k . '.'); + throw new RuntimeException('Splitting failed with ' . $k . '.'); } } - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\RuntimeException('Splitting failed with unknown error code.'); + throw new RuntimeException('Splitting failed with unknown error code.'); } } finally { \restore_error_handler(); @@ -465,21 +465,21 @@ abstract class AbstractString implements \JsonSerializable * @return $this */ public abstract function title(bool $allWords = \false); - public function toByteString(string $toEncoding = null) : \RectorPrefix20220607\Symfony\Component\String\ByteString + public function toByteString(string $toEncoding = null) : ByteString { - $b = new \RectorPrefix20220607\Symfony\Component\String\ByteString(); + $b = new ByteString(); $toEncoding = \in_array($toEncoding, ['utf8', 'utf-8', 'UTF8'], \true) ? 'UTF-8' : $toEncoding; - if (null === $toEncoding || $toEncoding === ($fromEncoding = $this instanceof \RectorPrefix20220607\Symfony\Component\String\AbstractUnicodeString || \preg_match('//u', $b->string) ? 'UTF-8' : 'Windows-1252')) { + if (null === $toEncoding || $toEncoding === ($fromEncoding = $this instanceof AbstractUnicodeString || \preg_match('//u', $b->string) ? 'UTF-8' : 'Windows-1252')) { $b->string = $this->string; return $b; } \set_error_handler(static function ($t, $m) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException($m); + throw new InvalidArgumentException($m); }); try { try { $b->string = \mb_convert_encoding($this->string, $toEncoding, 'UTF-8'); - } catch (\RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException $e) { + } catch (InvalidArgumentException $e) { if (!\function_exists('iconv')) { throw $e; } @@ -490,26 +490,26 @@ abstract class AbstractString implements \JsonSerializable } return $b; } - public function toCodePointString() : \RectorPrefix20220607\Symfony\Component\String\CodePointString + public function toCodePointString() : CodePointString { - return new \RectorPrefix20220607\Symfony\Component\String\CodePointString($this->string); + return new CodePointString($this->string); } public function toString() : string { return $this->string; } - public function toUnicodeString() : \RectorPrefix20220607\Symfony\Component\String\UnicodeString + public function toUnicodeString() : UnicodeString { - return new \RectorPrefix20220607\Symfony\Component\String\UnicodeString($this->string); + return new UnicodeString($this->string); } /** * @return $this */ - public abstract function trim(string $chars = " \t\n\r\0\v\f "); + public abstract function trim(string $chars = " \t\n\r\x00\v\f "); /** * @return $this */ - public abstract function trimEnd(string $chars = " \t\n\r\0\v\f "); + public abstract function trimEnd(string $chars = " \t\n\r\x00\v\f "); /** * @param string|string[] $prefix * @return $this @@ -540,7 +540,7 @@ abstract class AbstractString implements \JsonSerializable /** * @return $this */ - public abstract function trimStart(string $chars = " \t\n\r\0\v\f "); + public abstract function trimStart(string $chars = " \t\n\r\x00\v\f "); /** * @param string|string[] $suffix * @return $this diff --git a/vendor/symfony/string/AbstractUnicodeString.php b/vendor/symfony/string/AbstractUnicodeString.php index 661e167f130..8764f7ffb46 100644 --- a/vendor/symfony/string/AbstractUnicodeString.php +++ b/vendor/symfony/string/AbstractUnicodeString.php @@ -24,14 +24,14 @@ use RectorPrefix20220607\Symfony\Component\String\Exception\RuntimeException; * * @throws ExceptionInterface */ -abstract class AbstractUnicodeString extends \RectorPrefix20220607\Symfony\Component\String\AbstractString +abstract class AbstractUnicodeString extends AbstractString { public const NFC = \Normalizer::NFC; public const NFD = \Normalizer::NFD; public const NFKC = \Normalizer::NFKC; public const NFKD = \Normalizer::NFKD; // all ASCII letters sorted by typical frequency of occurrence - private const ASCII = " eiasntrolud][cmp'\ng|hv.fb,:=-q10C2*yx)(L9AS/P\"EjMIk3>5T5Tstring = \implode($this->string, $strings) . $tail; if (!\preg_match('//u', $str->string)) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 string.'); + throw new InvalidArgumentException('Invalid UTF-8 string.'); } return $str; } @@ -204,17 +204,17 @@ abstract class AbstractUnicodeString extends \RectorPrefix20220607\Symfony\Compo $regexp .= 'i'; } \set_error_handler(static function ($t, $m) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException($m); + throw new InvalidArgumentException($m); }); try { if (\false === $match($regexp . 'u', $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) { $lastError = \preg_last_error(); foreach (\get_defined_constants(\true)['pcre'] as $k => $v) { if ($lastError === $v && \substr_compare($k, '_ERROR', -\strlen('_ERROR')) === 0) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\RuntimeException('Matching failed with ' . $k . '.'); + throw new RuntimeException('Matching failed with ' . $k . '.'); } } - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\RuntimeException('Matching failed with unknown error code.'); + throw new RuntimeException('Matching failed with unknown error code.'); } } finally { \restore_error_handler(); @@ -227,7 +227,7 @@ abstract class AbstractUnicodeString extends \RectorPrefix20220607\Symfony\Compo public function normalize(int $form = self::NFC) { if (!\in_array($form, [self::NFC, self::NFD, self::NFKC, self::NFKD])) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Unsupported normalization form.'); + throw new InvalidArgumentException('Unsupported normalization form.'); } $str = clone $this; \normalizer_is_normalized($str->string, $form) ?: ($str->string = \normalizer_normalize($str->string, $form)); @@ -239,7 +239,7 @@ abstract class AbstractUnicodeString extends \RectorPrefix20220607\Symfony\Compo public function padBoth(int $length, string $padStr = ' ') { if ('' === $padStr || !\preg_match('//u', $padStr)) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 string.'); + throw new InvalidArgumentException('Invalid UTF-8 string.'); } $pad = clone $this; $pad->string = $padStr; @@ -251,7 +251,7 @@ abstract class AbstractUnicodeString extends \RectorPrefix20220607\Symfony\Compo public function padEnd(int $length, string $padStr = ' ') { if ('' === $padStr || !\preg_match('//u', $padStr)) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 string.'); + throw new InvalidArgumentException('Invalid UTF-8 string.'); } $pad = clone $this; $pad->string = $padStr; @@ -263,7 +263,7 @@ abstract class AbstractUnicodeString extends \RectorPrefix20220607\Symfony\Compo public function padStart(int $length, string $padStr = ' ') { if ('' === $padStr || !\preg_match('//u', $padStr)) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 string.'); + throw new InvalidArgumentException('Invalid UTF-8 string.'); } $pad = clone $this; $pad->string = $padStr; @@ -283,27 +283,27 @@ abstract class AbstractUnicodeString extends \RectorPrefix20220607\Symfony\Compo $to = static function (array $m) use($to) : string { $to = $to($m); if ('' !== $to && (!\is_string($to) || !\preg_match('//u', $to))) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Replace callback must return a valid UTF-8 string.'); + throw new InvalidArgumentException('Replace callback must return a valid UTF-8 string.'); } return $to; }; } elseif ('' !== $to && !\preg_match('//u', $to)) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 string.'); + throw new InvalidArgumentException('Invalid UTF-8 string.'); } else { $replace = 'preg_replace'; } \set_error_handler(static function ($t, $m) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException($m); + throw new InvalidArgumentException($m); }); try { if (null === ($string = $replace($fromRegexp . 'u', $to, $this->string))) { $lastError = \preg_last_error(); foreach (\get_defined_constants(\true)['pcre'] as $k => $v) { if ($lastError === $v && \substr_compare($k, '_ERROR', -\strlen('_ERROR')) === 0) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\RuntimeException('Matching failed with ' . $k . '.'); + throw new RuntimeException('Matching failed with ' . $k . '.'); } } - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\RuntimeException('Matching failed with unknown error code.'); + throw new RuntimeException('Matching failed with unknown error code.'); } } finally { \restore_error_handler(); @@ -345,10 +345,10 @@ abstract class AbstractUnicodeString extends \RectorPrefix20220607\Symfony\Compo /** * @return $this */ - public function trim(string $chars = " \t\n\r\0\v\f ") + public function trim(string $chars = " \t\n\r\x00\v\f ") { - if (" \t\n\r\0\v\f " !== $chars && !\preg_match('//u', $chars)) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 chars.'); + if (" \t\n\r\x00\v\f " !== $chars && !\preg_match('//u', $chars)) { + throw new InvalidArgumentException('Invalid UTF-8 chars.'); } $chars = \preg_quote($chars); $str = clone $this; @@ -358,10 +358,10 @@ abstract class AbstractUnicodeString extends \RectorPrefix20220607\Symfony\Compo /** * @return $this */ - public function trimEnd(string $chars = " \t\n\r\0\v\f ") + public function trimEnd(string $chars = " \t\n\r\x00\v\f ") { - if (" \t\n\r\0\v\f " !== $chars && !\preg_match('//u', $chars)) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 chars.'); + if (" \t\n\r\x00\v\f " !== $chars && !\preg_match('//u', $chars)) { + throw new InvalidArgumentException('Invalid UTF-8 chars.'); } $chars = \preg_quote($chars); $str = clone $this; @@ -389,10 +389,10 @@ abstract class AbstractUnicodeString extends \RectorPrefix20220607\Symfony\Compo /** * @return $this */ - public function trimStart(string $chars = " \t\n\r\0\v\f ") + public function trimStart(string $chars = " \t\n\r\x00\v\f ") { - if (" \t\n\r\0\v\f " !== $chars && !\preg_match('//u', $chars)) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 chars.'); + if (" \t\n\r\x00\v\f " !== $chars && !\preg_match('//u', $chars)) { + throw new InvalidArgumentException('Invalid UTF-8 chars.'); } $chars = \preg_quote($chars); $str = clone $this; @@ -429,7 +429,7 @@ abstract class AbstractUnicodeString extends \RectorPrefix20220607\Symfony\Compo public function width(bool $ignoreAnsiDecoration = \true) : int { $width = 0; - $s = \str_replace(["\0", "\5", "\7"], '', $this->string); + $s = \str_replace(["\x00", "\x05", "\x07"], '', $this->string); if (\strpos($s, "\r") !== \false) { $s = \str_replace(["\r\n", "\r"], "\n", $s); } @@ -475,7 +475,7 @@ abstract class AbstractUnicodeString extends \RectorPrefix20220607\Symfony\Compo $len = $leftLen % $padLen; return $str->prepend(\str_repeat($pad->string, \intdiv($leftLen, $padLen)) . ($len ? $pad->slice(0, $len) : '')); default: - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Invalid padding type.'); + throw new InvalidArgumentException('Invalid padding type.'); } } /** diff --git a/vendor/symfony/string/ByteString.php b/vendor/symfony/string/ByteString.php index 68669237e3a..05345c380d9 100644 --- a/vendor/symfony/string/ByteString.php +++ b/vendor/symfony/string/ByteString.php @@ -21,7 +21,7 @@ use RectorPrefix20220607\Symfony\Component\String\Exception\RuntimeException; * * @throws ExceptionInterface */ -class ByteString extends \RectorPrefix20220607\Symfony\Component\String\AbstractString +class ByteString extends AbstractString { private const ALPHABET_ALPHANUMERIC = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; public function __construct(string $string = '') @@ -40,13 +40,13 @@ class ByteString extends \RectorPrefix20220607\Symfony\Component\String\Abstract public static function fromRandom(int $length = 16, string $alphabet = null) : self { if ($length <= 0) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException(\sprintf('A strictly positive length is expected, "%d" given.', $length)); + throw new InvalidArgumentException(\sprintf('A strictly positive length is expected, "%d" given.', $length)); } $alphabet = $alphabet ?? self::ALPHABET_ALPHANUMERIC; $alphabetSize = \strlen($alphabet); $bits = (int) \ceil(\log($alphabetSize, 2.0)); if ($bits <= 0 || $bits > 56) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('The length of the alphabet must in the [2^1, 2^56] range.'); + throw new InvalidArgumentException('The length of the alphabet must in the [2^1, 2^56] range.'); } $ret = ''; while ($length > 0) { @@ -101,7 +101,7 @@ class ByteString extends \RectorPrefix20220607\Symfony\Component\String\Abstract public function chunk(int $length = 1) : array { if (1 > $length) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('The chunk length must be greater than zero.'); + throw new InvalidArgumentException('The chunk length must be greater than zero.'); } if ('' === $this->string) { return []; @@ -119,7 +119,7 @@ class ByteString extends \RectorPrefix20220607\Symfony\Component\String\Abstract */ public function endsWith($suffix) : bool { - if ($suffix instanceof \RectorPrefix20220607\Symfony\Component\String\AbstractString) { + if ($suffix instanceof AbstractString) { $suffix = $suffix->string; } elseif (!\is_string($suffix)) { return parent::endsWith($suffix); @@ -131,7 +131,7 @@ class ByteString extends \RectorPrefix20220607\Symfony\Component\String\Abstract */ public function equalsTo($string) : bool { - if ($string instanceof \RectorPrefix20220607\Symfony\Component\String\AbstractString) { + if ($string instanceof AbstractString) { $string = $string->string; } elseif (!\is_string($string)) { return parent::equalsTo($string); @@ -155,7 +155,7 @@ class ByteString extends \RectorPrefix20220607\Symfony\Component\String\Abstract */ public function indexOf($needle, int $offset = 0) : ?int { - if ($needle instanceof \RectorPrefix20220607\Symfony\Component\String\AbstractString) { + if ($needle instanceof AbstractString) { $needle = $needle->string; } elseif (!\is_string($needle)) { return parent::indexOf($needle, $offset); @@ -171,7 +171,7 @@ class ByteString extends \RectorPrefix20220607\Symfony\Component\String\Abstract */ public function indexOfLast($needle, int $offset = 0) : ?int { - if ($needle instanceof \RectorPrefix20220607\Symfony\Component\String\AbstractString) { + if ($needle instanceof AbstractString) { $needle = $needle->string; } elseif (!\is_string($needle)) { return parent::indexOfLast($needle, $offset); @@ -216,17 +216,17 @@ class ByteString extends \RectorPrefix20220607\Symfony\Component\String\Abstract $regexp .= 'i'; } \set_error_handler(static function ($t, $m) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException($m); + throw new InvalidArgumentException($m); }); try { if (\false === $match($regexp, $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) { $lastError = \preg_last_error(); foreach (\get_defined_constants(\true)['pcre'] as $k => $v) { if ($lastError === $v && \substr_compare($k, '_ERROR', -\strlen('_ERROR')) === 0) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\RuntimeException('Matching failed with ' . $k . '.'); + throw new RuntimeException('Matching failed with ' . $k . '.'); } } - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\RuntimeException('Matching failed with unknown error code.'); + throw new RuntimeException('Matching failed with unknown error code.'); } } finally { \restore_error_handler(); @@ -291,17 +291,17 @@ class ByteString extends \RectorPrefix20220607\Symfony\Component\String\Abstract } $replace = \is_array($to) || $to instanceof \Closure ? 'preg_replace_callback' : 'preg_replace'; \set_error_handler(static function ($t, $m) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException($m); + throw new InvalidArgumentException($m); }); try { if (null === ($string = $replace($fromRegexp, $to, $this->string))) { $lastError = \preg_last_error(); foreach (\get_defined_constants(\true)['pcre'] as $k => $v) { if ($lastError === $v && \substr_compare($k, '_ERROR', -\strlen('_ERROR')) === 0) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\RuntimeException('Matching failed with ' . $k . '.'); + throw new RuntimeException('Matching failed with ' . $k . '.'); } } - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\RuntimeException('Matching failed with unknown error code.'); + throw new RuntimeException('Matching failed with unknown error code.'); } } finally { \restore_error_handler(); @@ -349,10 +349,10 @@ class ByteString extends \RectorPrefix20220607\Symfony\Component\String\Abstract public function split(string $delimiter, int $limit = null, int $flags = null) : array { if (1 > ($limit = $limit ?? \PHP_INT_MAX)) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Split limit must be a positive integer.'); + throw new InvalidArgumentException('Split limit must be a positive integer.'); } if ('' === $delimiter) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Split delimiter is empty.'); + throw new InvalidArgumentException('Split delimiter is empty.'); } if (null !== $flags) { return parent::split($delimiter, $limit, $flags); @@ -370,7 +370,7 @@ class ByteString extends \RectorPrefix20220607\Symfony\Component\String\Abstract */ public function startsWith($prefix) : bool { - if ($prefix instanceof \RectorPrefix20220607\Symfony\Component\String\AbstractString) { + if ($prefix instanceof AbstractString) { $prefix = $prefix->string; } elseif (!\is_string($prefix)) { return parent::startsWith($prefix); @@ -386,24 +386,24 @@ class ByteString extends \RectorPrefix20220607\Symfony\Component\String\Abstract $str->string = $allWords ? \ucwords($str->string) : \ucfirst($str->string); return $str; } - public function toUnicodeString(string $fromEncoding = null) : \RectorPrefix20220607\Symfony\Component\String\UnicodeString + public function toUnicodeString(string $fromEncoding = null) : UnicodeString { - return new \RectorPrefix20220607\Symfony\Component\String\UnicodeString($this->toCodePointString($fromEncoding)->string); + return new UnicodeString($this->toCodePointString($fromEncoding)->string); } - public function toCodePointString(string $fromEncoding = null) : \RectorPrefix20220607\Symfony\Component\String\CodePointString + public function toCodePointString(string $fromEncoding = null) : CodePointString { - $u = new \RectorPrefix20220607\Symfony\Component\String\CodePointString(); + $u = new CodePointString(); if (\in_array($fromEncoding, [null, 'utf8', 'utf-8', 'UTF8', 'UTF-8'], \true) && \preg_match('//u', $this->string)) { $u->string = $this->string; return $u; } \set_error_handler(static function ($t, $m) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException($m); + throw new InvalidArgumentException($m); }); try { try { $validEncoding = \false !== \mb_detect_encoding($this->string, $fromEncoding ?? 'Windows-1252', \true); - } catch (\RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException $e) { + } catch (InvalidArgumentException $e) { if (!\function_exists('iconv')) { throw $e; } @@ -414,7 +414,7 @@ class ByteString extends \RectorPrefix20220607\Symfony\Component\String\Abstract \restore_error_handler(); } if (!$validEncoding) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException(\sprintf('Invalid "%s" string.', $fromEncoding ?? 'Windows-1252')); + throw new InvalidArgumentException(\sprintf('Invalid "%s" string.', $fromEncoding ?? 'Windows-1252')); } $u->string = \mb_convert_encoding($this->string, 'UTF-8', $fromEncoding ?? 'Windows-1252'); return $u; @@ -422,7 +422,7 @@ class ByteString extends \RectorPrefix20220607\Symfony\Component\String\Abstract /** * @return $this */ - public function trim(string $chars = " \t\n\r\0\v\f") + public function trim(string $chars = " \t\n\r\x00\v\f") { $str = clone $this; $str->string = \trim($str->string, $chars); @@ -431,7 +431,7 @@ class ByteString extends \RectorPrefix20220607\Symfony\Component\String\Abstract /** * @return $this */ - public function trimEnd(string $chars = " \t\n\r\0\v\f") + public function trimEnd(string $chars = " \t\n\r\x00\v\f") { $str = clone $this; $str->string = \rtrim($str->string, $chars); @@ -440,7 +440,7 @@ class ByteString extends \RectorPrefix20220607\Symfony\Component\String\Abstract /** * @return $this */ - public function trimStart(string $chars = " \t\n\r\0\v\f") + public function trimStart(string $chars = " \t\n\r\x00\v\f") { $str = clone $this; $str->string = \ltrim($str->string, $chars); @@ -458,6 +458,6 @@ class ByteString extends \RectorPrefix20220607\Symfony\Component\String\Abstract public function width(bool $ignoreAnsiDecoration = \true) : int { $string = \preg_match('//u', $this->string) ? $this->string : \preg_replace('/[\\x80-\\xFF]/', '?', $this->string); - return (new \RectorPrefix20220607\Symfony\Component\String\CodePointString($string))->width($ignoreAnsiDecoration); + return (new CodePointString($string))->width($ignoreAnsiDecoration); } } diff --git a/vendor/symfony/string/CodePointString.php b/vendor/symfony/string/CodePointString.php index f19bd78aa65..21dd69ef6e8 100644 --- a/vendor/symfony/string/CodePointString.php +++ b/vendor/symfony/string/CodePointString.php @@ -20,12 +20,12 @@ use RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentExcep * * @throws ExceptionInterface */ -class CodePointString extends \RectorPrefix20220607\Symfony\Component\String\AbstractUnicodeString +class CodePointString extends AbstractUnicodeString { public function __construct(string $string = '') { if ('' !== $string && !\preg_match('//u', $string)) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 string.'); + throw new InvalidArgumentException('Invalid UTF-8 string.'); } $this->string = $string; } @@ -37,14 +37,14 @@ class CodePointString extends \RectorPrefix20220607\Symfony\Component\String\Abs $str = clone $this; $str->string .= 1 >= \count($suffix) ? $suffix[0] ?? '' : \implode('', $suffix); if (!\preg_match('//u', $str->string)) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 string.'); + throw new InvalidArgumentException('Invalid UTF-8 string.'); } return $str; } public function chunk(int $length = 1) : array { if (1 > $length) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('The chunk length must be greater than zero.'); + throw new InvalidArgumentException('The chunk length must be greater than zero.'); } if ('' === $this->string) { return []; @@ -73,7 +73,7 @@ class CodePointString extends \RectorPrefix20220607\Symfony\Component\String\Abs */ public function endsWith($suffix) : bool { - if ($suffix instanceof \RectorPrefix20220607\Symfony\Component\String\AbstractString) { + if ($suffix instanceof AbstractString) { $suffix = $suffix->string; } elseif (!\is_string($suffix)) { return parent::endsWith($suffix); @@ -91,7 +91,7 @@ class CodePointString extends \RectorPrefix20220607\Symfony\Component\String\Abs */ public function equalsTo($string) : bool { - if ($string instanceof \RectorPrefix20220607\Symfony\Component\String\AbstractString) { + if ($string instanceof AbstractString) { $string = $string->string; } elseif (!\is_string($string)) { return parent::equalsTo($string); @@ -106,7 +106,7 @@ class CodePointString extends \RectorPrefix20220607\Symfony\Component\String\Abs */ public function indexOf($needle, int $offset = 0) : ?int { - if ($needle instanceof \RectorPrefix20220607\Symfony\Component\String\AbstractString) { + if ($needle instanceof AbstractString) { $needle = $needle->string; } elseif (!\is_string($needle)) { return parent::indexOf($needle, $offset); @@ -122,7 +122,7 @@ class CodePointString extends \RectorPrefix20220607\Symfony\Component\String\Abs */ public function indexOfLast($needle, int $offset = 0) : ?int { - if ($needle instanceof \RectorPrefix20220607\Symfony\Component\String\AbstractString) { + if ($needle instanceof AbstractString) { $needle = $needle->string; } elseif (!\is_string($needle)) { return parent::indexOfLast($needle, $offset); @@ -145,7 +145,7 @@ class CodePointString extends \RectorPrefix20220607\Symfony\Component\String\Abs $str = clone $this; $str->string = (1 >= \count($prefix) ? $prefix[0] ?? '' : \implode('', $prefix)) . $this->string; if (!\preg_match('//u', $str->string)) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 string.'); + throw new InvalidArgumentException('Invalid UTF-8 string.'); } return $str; } @@ -159,7 +159,7 @@ class CodePointString extends \RectorPrefix20220607\Symfony\Component\String\Abs return $str; } if ('' !== $to && !\preg_match('//u', $to)) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 string.'); + throw new InvalidArgumentException('Invalid UTF-8 string.'); } if ($this->ignoreCase) { $str->string = \implode($to, \preg_split('{' . \preg_quote($from) . '}iuD', $this->string)); @@ -183,7 +183,7 @@ class CodePointString extends \RectorPrefix20220607\Symfony\Component\String\Abs public function splice(string $replacement, int $start = 0, int $length = null) { if (!\preg_match('//u', $replacement)) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 string.'); + throw new InvalidArgumentException('Invalid UTF-8 string.'); } $str = clone $this; $start = $start ? \strlen(\mb_substr($this->string, 0, $start, 'UTF-8')) : 0; @@ -194,16 +194,16 @@ class CodePointString extends \RectorPrefix20220607\Symfony\Component\String\Abs public function split(string $delimiter, int $limit = null, int $flags = null) : array { if (1 > ($limit = $limit ?? \PHP_INT_MAX)) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Split limit must be a positive integer.'); + throw new InvalidArgumentException('Split limit must be a positive integer.'); } if ('' === $delimiter) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Split delimiter is empty.'); + throw new InvalidArgumentException('Split delimiter is empty.'); } if (null !== $flags) { return parent::split($delimiter . 'u', $limit, $flags); } if (!\preg_match('//u', $delimiter)) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Split delimiter is not a valid UTF-8 string.'); + throw new InvalidArgumentException('Split delimiter is not a valid UTF-8 string.'); } $str = clone $this; $chunks = $this->ignoreCase ? \preg_split('{' . \preg_quote($delimiter) . '}iuD', $this->string, $limit) : \explode($delimiter, $this->string, $limit); @@ -218,7 +218,7 @@ class CodePointString extends \RectorPrefix20220607\Symfony\Component\String\Abs */ public function startsWith($prefix) : bool { - if ($prefix instanceof \RectorPrefix20220607\Symfony\Component\String\AbstractString) { + if ($prefix instanceof AbstractString) { $prefix = $prefix->string; } elseif (!\is_string($prefix)) { return parent::startsWith($prefix); diff --git a/vendor/symfony/string/Exception/InvalidArgumentException.php b/vendor/symfony/string/Exception/InvalidArgumentException.php index 6b2711e4922..44a7c5a8b7c 100644 --- a/vendor/symfony/string/Exception/InvalidArgumentException.php +++ b/vendor/symfony/string/Exception/InvalidArgumentException.php @@ -10,6 +10,6 @@ */ namespace RectorPrefix20220607\Symfony\Component\String\Exception; -class InvalidArgumentException extends \InvalidArgumentException implements \RectorPrefix20220607\Symfony\Component\String\Exception\ExceptionInterface +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { } diff --git a/vendor/symfony/string/Exception/RuntimeException.php b/vendor/symfony/string/Exception/RuntimeException.php index 9739c58705a..c13726f6445 100644 --- a/vendor/symfony/string/Exception/RuntimeException.php +++ b/vendor/symfony/string/Exception/RuntimeException.php @@ -10,6 +10,6 @@ */ namespace RectorPrefix20220607\Symfony\Component\String\Exception; -class RuntimeException extends \RuntimeException implements \RectorPrefix20220607\Symfony\Component\String\Exception\ExceptionInterface +class RuntimeException extends \RuntimeException implements ExceptionInterface { } diff --git a/vendor/symfony/string/Inflector/EnglishInflector.php b/vendor/symfony/string/Inflector/EnglishInflector.php index 73492fec5ec..6de351e7966 100644 --- a/vendor/symfony/string/Inflector/EnglishInflector.php +++ b/vendor/symfony/string/Inflector/EnglishInflector.php @@ -10,7 +10,7 @@ */ namespace RectorPrefix20220607\Symfony\Component\String\Inflector; -final class EnglishInflector implements \RectorPrefix20220607\Symfony\Component\String\Inflector\InflectorInterface +final class EnglishInflector implements InflectorInterface { /** * Map English plural to singular suffixes. diff --git a/vendor/symfony/string/Inflector/FrenchInflector.php b/vendor/symfony/string/Inflector/FrenchInflector.php index fe593027c9f..89ca28c287a 100644 --- a/vendor/symfony/string/Inflector/FrenchInflector.php +++ b/vendor/symfony/string/Inflector/FrenchInflector.php @@ -15,7 +15,7 @@ namespace RectorPrefix20220607\Symfony\Component\String\Inflector; * * This class does only inflect nouns; not adjectives nor composed words like "soixante-dix". */ -final class FrenchInflector implements \RectorPrefix20220607\Symfony\Component\String\Inflector\InflectorInterface +final class FrenchInflector implements InflectorInterface { /** * A list of all rules for pluralise. diff --git a/vendor/symfony/string/Resources/functions.php b/vendor/symfony/string/Resources/functions.php index 4a0d8d6699d..72dc81b0014 100644 --- a/vendor/symfony/string/Resources/functions.php +++ b/vendor/symfony/string/Resources/functions.php @@ -10,25 +10,25 @@ */ namespace RectorPrefix20220607\Symfony\Component\String; -if (!\function_exists(\RectorPrefix20220607\Symfony\Component\String\u::class)) { - function u(?string $string = '') : \RectorPrefix20220607\Symfony\Component\String\UnicodeString +if (!\function_exists(u::class)) { + function u(?string $string = '') : UnicodeString { - return new \RectorPrefix20220607\Symfony\Component\String\UnicodeString($string ?? ''); + return new UnicodeString($string ?? ''); } } -if (!\function_exists(\RectorPrefix20220607\Symfony\Component\String\b::class)) { - function b(?string $string = '') : \RectorPrefix20220607\Symfony\Component\String\ByteString +if (!\function_exists(b::class)) { + function b(?string $string = '') : ByteString { - return new \RectorPrefix20220607\Symfony\Component\String\ByteString($string ?? ''); + return new ByteString($string ?? ''); } } -if (!\function_exists(\RectorPrefix20220607\Symfony\Component\String\s::class)) { +if (!\function_exists(s::class)) { /** * @return UnicodeString|ByteString */ - function s(?string $string = '') : \RectorPrefix20220607\Symfony\Component\String\AbstractString + function s(?string $string = '') : AbstractString { $string = $string ?? ''; - return \preg_match('//u', $string) ? new \RectorPrefix20220607\Symfony\Component\String\UnicodeString($string) : new \RectorPrefix20220607\Symfony\Component\String\ByteString($string); + return \preg_match('//u', $string) ? new UnicodeString($string) : new ByteString($string); } } diff --git a/vendor/symfony/string/Slugger/AsciiSlugger.php b/vendor/symfony/string/Slugger/AsciiSlugger.php index c56470e2b7f..11e114da244 100644 --- a/vendor/symfony/string/Slugger/AsciiSlugger.php +++ b/vendor/symfony/string/Slugger/AsciiSlugger.php @@ -13,13 +13,13 @@ namespace RectorPrefix20220607\Symfony\Component\String\Slugger; use RectorPrefix20220607\Symfony\Component\String\AbstractUnicodeString; use RectorPrefix20220607\Symfony\Component\String\UnicodeString; use RectorPrefix20220607\Symfony\Contracts\Translation\LocaleAwareInterface; -if (!\interface_exists(\RectorPrefix20220607\Symfony\Contracts\Translation\LocaleAwareInterface::class)) { +if (!\interface_exists(LocaleAwareInterface::class)) { throw new \LogicException('You cannot use the "Symfony\\Component\\String\\Slugger\\AsciiSlugger" as the "symfony/translation-contracts" package is not installed. Try running "composer require symfony/translation-contracts".'); } /** * @author Titouan Galopin */ -class AsciiSlugger implements \RectorPrefix20220607\Symfony\Component\String\Slugger\SluggerInterface, \RectorPrefix20220607\Symfony\Contracts\Translation\LocaleAwareInterface +class AsciiSlugger implements SluggerInterface, LocaleAwareInterface { private const LOCALE_TO_TRANSLITERATOR_ID = ['am' => 'Amharic-Latin', 'ar' => 'Arabic-Latin', 'az' => 'Azerbaijani-Latin', 'be' => 'Belarusian-Latin', 'bg' => 'Bulgarian-Latin', 'bn' => 'Bengali-Latin', 'de' => 'de-ASCII', 'el' => 'Greek-Latin', 'fa' => 'Persian-Latin', 'he' => 'Hebrew-Latin', 'hy' => 'Armenian-Latin', 'ka' => 'Georgian-Latin', 'kk' => 'Kazakh-Latin', 'ky' => 'Kirghiz-Latin', 'ko' => 'Korean-Latin', 'mk' => 'Macedonian-Latin', 'mn' => 'Mongolian-Latin', 'or' => 'Oriya-Latin', 'ps' => 'Pashto-Latin', 'ru' => 'Russian-Latin', 'sr' => 'Serbian-Latin', 'sr_Cyrl' => 'Serbian-Latin', 'th' => 'Thai-Latin', 'tk' => 'Turkmen-Latin', 'uk' => 'Ukrainian-Latin', 'uz' => 'Uzbek-Latin', 'zh' => 'Han-Latin']; /** @@ -61,7 +61,7 @@ class AsciiSlugger implements \RectorPrefix20220607\Symfony\Component\String\Slu /** * {@inheritdoc} */ - public function slug(string $string, string $separator = '-', string $locale = null) : \RectorPrefix20220607\Symfony\Component\String\AbstractUnicodeString + public function slug(string $string, string $separator = '-', string $locale = null) : AbstractUnicodeString { $locale = $locale ?? $this->defaultLocale; $transliterator = []; @@ -79,7 +79,7 @@ class AsciiSlugger implements \RectorPrefix20220607\Symfony\Component\String\Slu return $symbolsMap($s, $locale); }); } - $unicodeString = (new \RectorPrefix20220607\Symfony\Component\String\UnicodeString($string))->ascii($transliterator); + $unicodeString = (new UnicodeString($string))->ascii($transliterator); if (\is_array($this->symbolsMap)) { $map = null; if (isset($this->symbolsMap[$locale])) { diff --git a/vendor/symfony/string/Slugger/SluggerInterface.php b/vendor/symfony/string/Slugger/SluggerInterface.php index b7b595aa553..39612866408 100644 --- a/vendor/symfony/string/Slugger/SluggerInterface.php +++ b/vendor/symfony/string/Slugger/SluggerInterface.php @@ -21,5 +21,5 @@ interface SluggerInterface /** * Creates a slug for the given string and locale, using appropriate transliteration when needed. */ - public function slug(string $string, string $separator = '-', string $locale = null) : \RectorPrefix20220607\Symfony\Component\String\AbstractUnicodeString; + public function slug(string $string, string $separator = '-', string $locale = null) : AbstractUnicodeString; } diff --git a/vendor/symfony/string/UnicodeString.php b/vendor/symfony/string/UnicodeString.php index f3d7cea7b5f..b033eeac8d4 100644 --- a/vendor/symfony/string/UnicodeString.php +++ b/vendor/symfony/string/UnicodeString.php @@ -28,13 +28,13 @@ use RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentExcep * * @throws ExceptionInterface */ -class UnicodeString extends \RectorPrefix20220607\Symfony\Component\String\AbstractUnicodeString +class UnicodeString extends AbstractUnicodeString { public function __construct(string $string = '') { $this->string = \normalizer_is_normalized($string) ? $string : \normalizer_normalize($string); if (\false === $this->string) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 string.'); + throw new InvalidArgumentException('Invalid UTF-8 string.'); } } /** @@ -46,14 +46,14 @@ class UnicodeString extends \RectorPrefix20220607\Symfony\Component\String\Abstr $str->string = $this->string . (1 >= \count($suffix) ? $suffix[0] ?? '' : \implode('', $suffix)); \normalizer_is_normalized($str->string) ?: ($str->string = \normalizer_normalize($str->string)); if (\false === $str->string) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 string.'); + throw new InvalidArgumentException('Invalid UTF-8 string.'); } return $str; } public function chunk(int $length = 1) : array { if (1 > $length) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('The chunk length must be greater than zero.'); + throw new InvalidArgumentException('The chunk length must be greater than zero.'); } if ('' === $this->string) { return []; @@ -77,7 +77,7 @@ class UnicodeString extends \RectorPrefix20220607\Symfony\Component\String\Abstr */ public function endsWith($suffix) : bool { - if ($suffix instanceof \RectorPrefix20220607\Symfony\Component\String\AbstractString) { + if ($suffix instanceof AbstractString) { $suffix = $suffix->string; } elseif (!\is_string($suffix)) { return parent::endsWith($suffix); @@ -97,7 +97,7 @@ class UnicodeString extends \RectorPrefix20220607\Symfony\Component\String\Abstr */ public function equalsTo($string) : bool { - if ($string instanceof \RectorPrefix20220607\Symfony\Component\String\AbstractString) { + if ($string instanceof AbstractString) { $string = $string->string; } elseif (!\is_string($string)) { return parent::equalsTo($string); @@ -114,7 +114,7 @@ class UnicodeString extends \RectorPrefix20220607\Symfony\Component\String\Abstr */ public function indexOf($needle, int $offset = 0) : ?int { - if ($needle instanceof \RectorPrefix20220607\Symfony\Component\String\AbstractString) { + if ($needle instanceof AbstractString) { $needle = $needle->string; } elseif (!\is_string($needle)) { return parent::indexOf($needle, $offset); @@ -136,7 +136,7 @@ class UnicodeString extends \RectorPrefix20220607\Symfony\Component\String\Abstr */ public function indexOfLast($needle, int $offset = 0) : ?int { - if ($needle instanceof \RectorPrefix20220607\Symfony\Component\String\AbstractString) { + if ($needle instanceof AbstractString) { $needle = $needle->string; } elseif (!\is_string($needle)) { return parent::indexOfLast($needle, $offset); @@ -179,7 +179,7 @@ class UnicodeString extends \RectorPrefix20220607\Symfony\Component\String\Abstr if (\in_array($form, [self::NFC, self::NFKC], \true)) { \normalizer_is_normalized($str->string, $form) ?: ($str->string = \normalizer_normalize($str->string, $form)); } elseif (!\in_array($form, [self::NFD, self::NFKD], \true)) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Unsupported normalization form.'); + throw new InvalidArgumentException('Unsupported normalization form.'); } elseif (!\normalizer_is_normalized($str->string, $form)) { $str->string = \normalizer_normalize($str->string, $form); $str->ignoreCase = null; @@ -195,7 +195,7 @@ class UnicodeString extends \RectorPrefix20220607\Symfony\Component\String\Abstr $str->string = (1 >= \count($prefix) ? $prefix[0] ?? '' : \implode('', $prefix)) . $this->string; \normalizer_is_normalized($str->string) ?: ($str->string = \normalizer_normalize($str->string)); if (\false === $str->string) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 string.'); + throw new InvalidArgumentException('Invalid UTF-8 string.'); } return $str; } @@ -218,7 +218,7 @@ class UnicodeString extends \RectorPrefix20220607\Symfony\Component\String\Abstr $str->string = $result . $tail; \normalizer_is_normalized($str->string) ?: ($str->string = \normalizer_normalize($str->string)); if (\false === $str->string) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 string.'); + throw new InvalidArgumentException('Invalid UTF-8 string.'); } } return $str; @@ -253,24 +253,24 @@ class UnicodeString extends \RectorPrefix20220607\Symfony\Component\String\Abstr $str->string = \substr_replace($this->string, $replacement, $start, $length ?? 2147483647); \normalizer_is_normalized($str->string) ?: ($str->string = \normalizer_normalize($str->string)); if (\false === $str->string) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Invalid UTF-8 string.'); + throw new InvalidArgumentException('Invalid UTF-8 string.'); } return $str; } public function split(string $delimiter, int $limit = null, int $flags = null) : array { if (1 > ($limit = $limit ?? 2147483647)) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Split limit must be a positive integer.'); + throw new InvalidArgumentException('Split limit must be a positive integer.'); } if ('' === $delimiter) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Split delimiter is empty.'); + throw new InvalidArgumentException('Split delimiter is empty.'); } if (null !== $flags) { return parent::split($delimiter . 'u', $limit, $flags); } \normalizer_is_normalized($delimiter) ?: ($delimiter = \normalizer_normalize($delimiter)); if (\false === $delimiter) { - throw new \RectorPrefix20220607\Symfony\Component\String\Exception\InvalidArgumentException('Split delimiter is not a valid UTF-8 string.'); + throw new InvalidArgumentException('Split delimiter is not a valid UTF-8 string.'); } $str = clone $this; $tail = $this->string; @@ -291,7 +291,7 @@ class UnicodeString extends \RectorPrefix20220607\Symfony\Component\String\Abstr */ public function startsWith($prefix) : bool { - if ($prefix instanceof \RectorPrefix20220607\Symfony\Component\String\AbstractString) { + if ($prefix instanceof AbstractString) { $prefix = $prefix->string; } elseif (!\is_string($prefix)) { return parent::startsWith($prefix); diff --git a/vendor/symplify/astral/composer.json b/vendor/symplify/astral/composer.json index 2e2824f7ef9..6a1fb3997b6 100644 --- a/vendor/symplify/astral/composer.json +++ b/vendor/symplify/astral/composer.json @@ -7,16 +7,16 @@ "php": ">=8.0", "nette\/utils": "^3.2", "symfony\/dependency-injection": "^6.0", - "symplify\/smart-file-system": "^10.2.10", + "symplify\/smart-file-system": "^10.2.11", "phpstan\/phpstan": "^1.7.6", "phpstan\/phpdoc-parser": "^1.5.1", "symfony\/config": "^6.0", "nikic\/php-parser": "^4.14.0", - "symplify\/package-builder": "^10.2.10", - "symplify\/symplify-kernel": "^10.2.10" + "symplify\/package-builder": "^10.2.11", + "symplify\/symplify-kernel": "^10.2.11" }, "require-dev": { - "symplify\/easy-testing": "^10.2.10", + "symplify\/easy-testing": "^10.2.11", "phpunit\/phpunit": "^9.5" }, "autoload": { @@ -41,26 +41,26 @@ } }, "conflict": { - "symplify\/composer-json-manipulator": "<10.2.10", - "symplify\/easy-coding-standard": "<10.2.10", - "symplify\/phpstan-rules": "<10.2.10", - "symplify\/easy-testing": "<10.2.10", - "symplify\/rule-doc-generator-contracts": "<10.2.10", - "symplify\/php-config-printer": "<10.2.10", - "symplify\/phpstan-extensions": "<10.2.10", - "symplify\/rule-doc-generator": "<10.2.10", - "symplify\/vendor-patches": "<10.2.10", - "symplify\/skipper": "<10.2.10", + "symplify\/composer-json-manipulator": "<10.2.11", + "symplify\/easy-coding-standard": "<10.2.11", + "symplify\/phpstan-rules": "<10.2.11", + "symplify\/easy-testing": "<10.2.11", + "symplify\/rule-doc-generator-contracts": "<10.2.11", + "symplify\/php-config-printer": "<10.2.11", + "symplify\/phpstan-extensions": "<10.2.11", + "symplify\/rule-doc-generator": "<10.2.11", + "symplify\/vendor-patches": "<10.2.11", + "symplify\/skipper": "<10.2.11", "symplify\/smart-file-system": "<9.4.70", - "symplify\/symfony-static-dumper": "<10.2.10", + "symplify\/symfony-static-dumper": "<10.2.11", "symplify\/symplify-kernel": "<9.4.70", - "symplify\/monorepo-builder": "<10.2.10", - "symplify\/config-transformer": "<10.2.10", - "symplify\/easy-ci": "<10.2.10", - "symplify\/coding-standard": "<10.2.10", - "symplify\/autowire-array-parameter": "<10.2.10", - "symplify\/easy-parallel": "<10.2.10", - "symplify\/neon-config-dumper": "<10.2.10" + "symplify\/monorepo-builder": "<10.2.11", + "symplify\/config-transformer": "<10.2.11", + "symplify\/easy-ci": "<10.2.11", + "symplify\/coding-standard": "<10.2.11", + "symplify\/autowire-array-parameter": "<10.2.11", + "symplify\/easy-parallel": "<10.2.11", + "symplify\/neon-config-dumper": "<10.2.11" }, "minimum-stability": "dev", "prefer-stable": true diff --git a/vendor/symplify/astral/config/config.php b/vendor/symplify/astral/config/config.php index 5a00cbfa1ff..7ebb5c9b34d 100644 --- a/vendor/symplify/astral/config/config.php +++ b/vendor/symplify/astral/config/config.php @@ -9,22 +9,22 @@ use PHPStan\PhpDocParser\Lexer\Lexer; use PHPStan\PhpDocParser\Parser\ConstExprParser; use PHPStan\PhpDocParser\Parser\PhpDocParser; use PHPStan\PhpDocParser\Parser\TypeParser; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use RectorPrefix20220607\Symplify\Astral\PhpParser\SmartPhpParser; use RectorPrefix20220607\Symplify\Astral\PhpParser\SmartPhpParserFactory; use RectorPrefix20220607\Symplify\PackageBuilder\Php\TypeChecker; use function RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service; -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +return static function (ContainerConfigurator $containerConfigurator) : void { $services = $containerConfigurator->services(); $services->defaults()->autowire()->public(); $services->load('RectorPrefix20220607\Symplify\\Astral\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/StaticFactory', __DIR__ . '/../src/ValueObject', __DIR__ . '/../src/NodeVisitor', __DIR__ . '/../src/PhpParser/SmartPhpParser.php', __DIR__ . '/../src/PhpDocParser/PhpDocNodeVisitor/CallablePhpDocNodeVisitor.php']); - $services->set(\RectorPrefix20220607\Symplify\Astral\PhpParser\SmartPhpParser::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\RectorPrefix20220607\Symplify\Astral\PhpParser\SmartPhpParserFactory::class), 'create']); - $services->set(\PhpParser\ConstExprEvaluator::class); - $services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Php\TypeChecker::class); - $services->set(\PhpParser\NodeFinder::class); + $services->set(SmartPhpParser::class)->factory([service(SmartPhpParserFactory::class), 'create']); + $services->set(ConstExprEvaluator::class); + $services->set(TypeChecker::class); + $services->set(NodeFinder::class); // phpdoc parser - $services->set(\PHPStan\PhpDocParser\Parser\PhpDocParser::class); - $services->set(\PHPStan\PhpDocParser\Lexer\Lexer::class); - $services->set(\PHPStan\PhpDocParser\Parser\TypeParser::class); - $services->set(\PHPStan\PhpDocParser\Parser\ConstExprParser::class); + $services->set(PhpDocParser::class); + $services->set(Lexer::class); + $services->set(TypeParser::class); + $services->set(ConstExprParser::class); }; diff --git a/vendor/symplify/astral/src/Contract/NodeNameResolverInterface.php b/vendor/symplify/astral/src/Contract/NodeNameResolverInterface.php index 8943042df28..e213a7504f4 100644 --- a/vendor/symplify/astral/src/Contract/NodeNameResolverInterface.php +++ b/vendor/symplify/astral/src/Contract/NodeNameResolverInterface.php @@ -6,6 +6,6 @@ namespace RectorPrefix20220607\Symplify\Astral\Contract; use PhpParser\Node; interface NodeNameResolverInterface { - public function match(\PhpParser\Node $node) : bool; - public function resolve(\PhpParser\Node $node) : ?string; + public function match(Node $node) : bool; + public function resolve(Node $node) : ?string; } diff --git a/vendor/symplify/astral/src/Contract/NodeValueResolver/NodeValueResolverInterface.php b/vendor/symplify/astral/src/Contract/NodeValueResolver/NodeValueResolverInterface.php index a48888d2404..6c74f2782f0 100644 --- a/vendor/symplify/astral/src/Contract/NodeValueResolver/NodeValueResolverInterface.php +++ b/vendor/symplify/astral/src/Contract/NodeValueResolver/NodeValueResolverInterface.php @@ -17,5 +17,5 @@ interface NodeValueResolverInterface * @param TExpr $expr * @return mixed */ - public function resolve(\PhpParser\Node\Expr $expr, string $currentFilePath); + public function resolve(Expr $expr, string $currentFilePath); } diff --git a/vendor/symplify/astral/src/Exception/ShouldNotHappenException.php b/vendor/symplify/astral/src/Exception/ShouldNotHappenException.php index 4ec7191d731..c507e185ec3 100644 --- a/vendor/symplify/astral/src/Exception/ShouldNotHappenException.php +++ b/vendor/symplify/astral/src/Exception/ShouldNotHappenException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\Astral\Exception; use Exception; -final class ShouldNotHappenException extends \Exception +final class ShouldNotHappenException extends Exception { } diff --git a/vendor/symplify/astral/src/Naming/SimpleNameResolver.php b/vendor/symplify/astral/src/Naming/SimpleNameResolver.php index 2791560b883..53995f43503 100644 --- a/vendor/symplify/astral/src/Naming/SimpleNameResolver.php +++ b/vendor/symplify/astral/src/Naming/SimpleNameResolver.php @@ -47,14 +47,14 @@ final class SimpleNameResolver } return $nodeNameResolver->resolve($node); } - if ($node instanceof \PhpParser\Node\Expr\ClassConstFetch && $this->isName($node->name, 'class')) { + if ($node instanceof ClassConstFetch && $this->isName($node->name, 'class')) { return $this->getName($node->class); } - if ($node instanceof \PhpParser\Node\Stmt\Property) { + if ($node instanceof Property) { $propertyProperty = $node->props[0]; return $this->getName($propertyProperty->name); } - if ($node instanceof \PhpParser\Node\Expr\Variable) { + if ($node instanceof Variable) { return $this->getName($node->name); } return null; @@ -62,7 +62,7 @@ final class SimpleNameResolver /** * @param string[] $desiredNames */ - public function isNames(\PhpParser\Node $node, array $desiredNames) : bool + public function isNames(Node $node, array $desiredNames) : bool { foreach ($desiredNames as $desiredName) { if ($this->isName($node, $desiredName)) { @@ -85,7 +85,7 @@ final class SimpleNameResolver } return $name === $desiredName; } - public function areNamesEqual(\PhpParser\Node $firstNode, \PhpParser\Node $secondNode) : bool + public function areNamesEqual(Node $firstNode, Node $secondNode) : bool { $firstName = $this->getName($firstNode); if ($firstName === null) { @@ -93,19 +93,19 @@ final class SimpleNameResolver } return $this->isName($secondNode, $firstName); } - public function resolveShortNameFromNode(\PhpParser\Node\Stmt\ClassLike $classLike) : ?string + public function resolveShortNameFromNode(ClassLike $classLike) : ?string { $className = $this->getName($classLike); if ($className === null) { return null; } // anonymous class return null name - if (\RectorPrefix20220607\Nette\Utils\Strings::match($className, self::ANONYMOUS_CLASS_REGEX)) { + if (Strings::match($className, self::ANONYMOUS_CLASS_REGEX)) { return null; } return $this->resolveShortName($className); } - public function resolveShortNameFromScope(\PHPStan\Analyser\Scope $scope) : ?string + public function resolveShortNameFromScope(Scope $scope) : ?string { $className = $this->getClassNameFromScope($scope); if ($className === null) { @@ -113,34 +113,34 @@ final class SimpleNameResolver } return $this->resolveShortName($className); } - public function getClassNameFromScope(\PHPStan\Analyser\Scope $scope) : ?string + public function getClassNameFromScope(Scope $scope) : ?string { if ($scope->isInTrait()) { $traitReflection = $scope->getTraitReflection(); - if (!$traitReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$traitReflection instanceof ClassReflection) { return null; } return $traitReflection->getName(); } $classReflection = $scope->getClassReflection(); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return null; } return $classReflection->getName(); } - public function isNameMatch(\PhpParser\Node $node, string $desiredNameRegex) : bool + public function isNameMatch(Node $node, string $desiredNameRegex) : bool { $name = $this->getName($node); if ($name === null) { return \false; } - return (bool) \RectorPrefix20220607\Nette\Utils\Strings::match($name, $desiredNameRegex); + return (bool) Strings::match($name, $desiredNameRegex); } public function resolveShortName(string $className) : string { if (\strpos($className, '\\') === \false) { return $className; } - return (string) \RectorPrefix20220607\Nette\Utils\Strings::after($className, '\\', -1); + return (string) Strings::after($className, '\\', -1); } } diff --git a/vendor/symplify/astral/src/NodeAnalyzer/NetteTypeAnalyzer.php b/vendor/symplify/astral/src/NodeAnalyzer/NetteTypeAnalyzer.php index e4e16b5131a..6dd8505de85 100644 --- a/vendor/symplify/astral/src/NodeAnalyzer/NetteTypeAnalyzer.php +++ b/vendor/symplify/astral/src/NodeAnalyzer/NetteTypeAnalyzer.php @@ -26,7 +26,7 @@ final class NetteTypeAnalyzer * @var \Symplify\Astral\TypeAnalyzer\ContainsTypeAnalyser */ private $containsTypeAnalyser; - public function __construct(\RectorPrefix20220607\Symplify\Astral\Naming\SimpleNameResolver $simpleNameResolver, \RectorPrefix20220607\Symplify\Astral\TypeAnalyzer\ContainsTypeAnalyser $containsTypeAnalyser) + public function __construct(SimpleNameResolver $simpleNameResolver, ContainsTypeAnalyser $containsTypeAnalyser) { $this->simpleNameResolver = $simpleNameResolver; $this->containsTypeAnalyser = $containsTypeAnalyser; @@ -34,12 +34,12 @@ final class NetteTypeAnalyzer /** * E.g. $this->template->key */ - public function isTemplateMagicPropertyType(\PhpParser\Node\Expr $expr, \PHPStan\Analyser\Scope $scope) : bool + public function isTemplateMagicPropertyType(Expr $expr, Scope $scope) : bool { - if (!$expr instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$expr instanceof PropertyFetch) { return \false; } - if (!$expr->var instanceof \PhpParser\Node\Expr\PropertyFetch) { + if (!$expr->var instanceof PropertyFetch) { return \false; } return $this->isTemplateType($expr->var, $scope); @@ -47,14 +47,14 @@ final class NetteTypeAnalyzer /** * E.g. $this->template */ - public function isTemplateType(\PhpParser\Node\Expr $expr, \PHPStan\Analyser\Scope $scope) : bool + public function isTemplateType(Expr $expr, Scope $scope) : bool { return $this->containsTypeAnalyser->containsExprTypes($expr, $scope, self::TEMPLATE_TYPES); } /** * This type has getComponent() method */ - public function isInsideComponentContainer(\PHPStan\Analyser\Scope $scope) : bool + public function isInsideComponentContainer(Scope $scope) : bool { $className = $this->simpleNameResolver->getClassNameFromScope($scope); if ($className === null) { @@ -63,7 +63,7 @@ final class NetteTypeAnalyzer // this type has getComponent() method return \is_a($className, 'RectorPrefix20220607\\Nette\\ComponentModel\\Container', \true); } - public function isInsideControl(\PHPStan\Analyser\Scope $scope) : bool + public function isInsideControl(Scope $scope) : bool { $className = $this->simpleNameResolver->getClassNameFromScope($scope); if ($className === null) { diff --git a/vendor/symplify/astral/src/NodeFinder/SimpleNodeFinder.php b/vendor/symplify/astral/src/NodeFinder/SimpleNodeFinder.php index 6e3d2f6a128..d64b5ffa965 100644 --- a/vendor/symplify/astral/src/NodeFinder/SimpleNodeFinder.php +++ b/vendor/symplify/astral/src/NodeFinder/SimpleNodeFinder.php @@ -12,7 +12,7 @@ final class SimpleNodeFinder * @var \PhpParser\NodeFinder */ private $nodeFinder; - public function __construct(\PhpParser\NodeFinder $nodeFinder) + public function __construct(NodeFinder $nodeFinder) { $this->nodeFinder = $nodeFinder; } @@ -21,7 +21,7 @@ final class SimpleNodeFinder * @param class-string $nodeClass * @return \PhpParser\Node|null */ - public function findFirstByType(\PhpParser\Node $node, string $nodeClass) + public function findFirstByType(Node $node, string $nodeClass) { return $this->nodeFinder->findFirstInstanceOf($node, $nodeClass); } @@ -30,7 +30,7 @@ final class SimpleNodeFinder * @param class-string $nodeClass * @return T[] */ - public function findByType(\PhpParser\Node $node, string $nodeClass) : array + public function findByType(Node $node, string $nodeClass) : array { return $this->nodeFinder->findInstanceOf($node, $nodeClass); } @@ -38,7 +38,7 @@ final class SimpleNodeFinder * @template T of Node * @param array> $nodeClasses */ - public function hasByTypes(\PhpParser\Node $node, array $nodeClasses) : bool + public function hasByTypes(Node $node, array $nodeClasses) : bool { foreach ($nodeClasses as $nodeClass) { $foundNodes = $this->findByType($node, $nodeClass); @@ -55,14 +55,14 @@ final class SimpleNodeFinder * @param class-string $nodeClass * @return T|null */ - public function findFirstParentByType(\PhpParser\Node $node, string $nodeClass) : ?\PhpParser\Node + public function findFirstParentByType(Node $node, string $nodeClass) : ?Node { - $node = $node->getAttribute(\RectorPrefix20220607\Symplify\Astral\ValueObject\AttributeKey::PARENT); - while ($node instanceof \PhpParser\Node) { + $node = $node->getAttribute(AttributeKey::PARENT); + while ($node instanceof Node) { if (\is_a($node, $nodeClass, \true)) { return $node; } - $node = $node->getAttribute(\RectorPrefix20220607\Symplify\Astral\ValueObject\AttributeKey::PARENT); + $node = $node->getAttribute(AttributeKey::PARENT); } return null; } @@ -71,16 +71,16 @@ final class SimpleNodeFinder * @param array&class-string> $nodeTypes * @return T|null */ - public function findFirstParentByTypes(\PhpParser\Node $node, array $nodeTypes) : ?\PhpParser\Node + public function findFirstParentByTypes(Node $node, array $nodeTypes) : ?Node { - $node = $node->getAttribute(\RectorPrefix20220607\Symplify\Astral\ValueObject\AttributeKey::PARENT); - while ($node instanceof \PhpParser\Node) { + $node = $node->getAttribute(AttributeKey::PARENT); + while ($node instanceof Node) { foreach ($nodeTypes as $nodeType) { if (\is_a($node, $nodeType)) { return $node; } } - $node = $node->getAttribute(\RectorPrefix20220607\Symplify\Astral\ValueObject\AttributeKey::PARENT); + $node = $node->getAttribute(AttributeKey::PARENT); } return null; } diff --git a/vendor/symplify/astral/src/NodeNameResolver/ArgNodeNameResolver.php b/vendor/symplify/astral/src/NodeNameResolver/ArgNodeNameResolver.php index 42954b622bc..2ce6f274f48 100644 --- a/vendor/symplify/astral/src/NodeNameResolver/ArgNodeNameResolver.php +++ b/vendor/symplify/astral/src/NodeNameResolver/ArgNodeNameResolver.php @@ -6,16 +6,16 @@ namespace RectorPrefix20220607\Symplify\Astral\NodeNameResolver; use PhpParser\Node; use PhpParser\Node\Arg; use RectorPrefix20220607\Symplify\Astral\Contract\NodeNameResolverInterface; -final class ArgNodeNameResolver implements \RectorPrefix20220607\Symplify\Astral\Contract\NodeNameResolverInterface +final class ArgNodeNameResolver implements NodeNameResolverInterface { - public function match(\PhpParser\Node $node) : bool + public function match(Node $node) : bool { - return $node instanceof \PhpParser\Node\Arg; + return $node instanceof Arg; } /** * @param Arg $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { if ($node->name === null) { return null; diff --git a/vendor/symplify/astral/src/NodeNameResolver/AttributeNodeNameResolver.php b/vendor/symplify/astral/src/NodeNameResolver/AttributeNodeNameResolver.php index c7e143b69be..087858f2125 100644 --- a/vendor/symplify/astral/src/NodeNameResolver/AttributeNodeNameResolver.php +++ b/vendor/symplify/astral/src/NodeNameResolver/AttributeNodeNameResolver.php @@ -6,16 +6,16 @@ namespace RectorPrefix20220607\Symplify\Astral\NodeNameResolver; use PhpParser\Node; use PhpParser\Node\Attribute; use RectorPrefix20220607\Symplify\Astral\Contract\NodeNameResolverInterface; -final class AttributeNodeNameResolver implements \RectorPrefix20220607\Symplify\Astral\Contract\NodeNameResolverInterface +final class AttributeNodeNameResolver implements NodeNameResolverInterface { - public function match(\PhpParser\Node $node) : bool + public function match(Node $node) : bool { - return $node instanceof \PhpParser\Node\Attribute; + return $node instanceof Attribute; } /** * @param Attribute $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { return $node->name->toString(); } diff --git a/vendor/symplify/astral/src/NodeNameResolver/ClassLikeNodeNameResolver.php b/vendor/symplify/astral/src/NodeNameResolver/ClassLikeNodeNameResolver.php index 04808818fc5..b8614f2b176 100644 --- a/vendor/symplify/astral/src/NodeNameResolver/ClassLikeNodeNameResolver.php +++ b/vendor/symplify/astral/src/NodeNameResolver/ClassLikeNodeNameResolver.php @@ -6,16 +6,16 @@ namespace RectorPrefix20220607\Symplify\Astral\NodeNameResolver; use PhpParser\Node; use PhpParser\Node\Stmt\ClassLike; use RectorPrefix20220607\Symplify\Astral\Contract\NodeNameResolverInterface; -final class ClassLikeNodeNameResolver implements \RectorPrefix20220607\Symplify\Astral\Contract\NodeNameResolverInterface +final class ClassLikeNodeNameResolver implements NodeNameResolverInterface { - public function match(\PhpParser\Node $node) : bool + public function match(Node $node) : bool { - return $node instanceof \PhpParser\Node\Stmt\ClassLike; + return $node instanceof ClassLike; } /** * @param ClassLike $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { if (\property_exists($node, 'namespacedName')) { return (string) $node->namespacedName; diff --git a/vendor/symplify/astral/src/NodeNameResolver/ClassMethodNodeNameResolver.php b/vendor/symplify/astral/src/NodeNameResolver/ClassMethodNodeNameResolver.php index 6a96897b3c0..9672b19587d 100644 --- a/vendor/symplify/astral/src/NodeNameResolver/ClassMethodNodeNameResolver.php +++ b/vendor/symplify/astral/src/NodeNameResolver/ClassMethodNodeNameResolver.php @@ -6,16 +6,16 @@ namespace RectorPrefix20220607\Symplify\Astral\NodeNameResolver; use PhpParser\Node; use PhpParser\Node\Stmt\ClassMethod; use RectorPrefix20220607\Symplify\Astral\Contract\NodeNameResolverInterface; -final class ClassMethodNodeNameResolver implements \RectorPrefix20220607\Symplify\Astral\Contract\NodeNameResolverInterface +final class ClassMethodNodeNameResolver implements NodeNameResolverInterface { - public function match(\PhpParser\Node $node) : bool + public function match(Node $node) : bool { - return $node instanceof \PhpParser\Node\Stmt\ClassMethod; + return $node instanceof ClassMethod; } /** * @param ClassMethod $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { return $node->name->toString(); } diff --git a/vendor/symplify/astral/src/NodeNameResolver/ConstFetchNodeNameResolver.php b/vendor/symplify/astral/src/NodeNameResolver/ConstFetchNodeNameResolver.php index 82967fc7b42..a4888694c4f 100644 --- a/vendor/symplify/astral/src/NodeNameResolver/ConstFetchNodeNameResolver.php +++ b/vendor/symplify/astral/src/NodeNameResolver/ConstFetchNodeNameResolver.php @@ -6,16 +6,16 @@ namespace RectorPrefix20220607\Symplify\Astral\NodeNameResolver; use PhpParser\Node; use PhpParser\Node\Expr\ConstFetch; use RectorPrefix20220607\Symplify\Astral\Contract\NodeNameResolverInterface; -final class ConstFetchNodeNameResolver implements \RectorPrefix20220607\Symplify\Astral\Contract\NodeNameResolverInterface +final class ConstFetchNodeNameResolver implements NodeNameResolverInterface { - public function match(\PhpParser\Node $node) : bool + public function match(Node $node) : bool { - return $node instanceof \PhpParser\Node\Expr\ConstFetch; + return $node instanceof ConstFetch; } /** * @param ConstFetch $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { return $node->name->toString(); } diff --git a/vendor/symplify/astral/src/NodeNameResolver/FuncCallNodeNameResolver.php b/vendor/symplify/astral/src/NodeNameResolver/FuncCallNodeNameResolver.php index e1cd3288fea..65bf99f53e4 100644 --- a/vendor/symplify/astral/src/NodeNameResolver/FuncCallNodeNameResolver.php +++ b/vendor/symplify/astral/src/NodeNameResolver/FuncCallNodeNameResolver.php @@ -7,18 +7,18 @@ use PhpParser\Node; use PhpParser\Node\Expr; use PhpParser\Node\Expr\FuncCall; use RectorPrefix20220607\Symplify\Astral\Contract\NodeNameResolverInterface; -final class FuncCallNodeNameResolver implements \RectorPrefix20220607\Symplify\Astral\Contract\NodeNameResolverInterface +final class FuncCallNodeNameResolver implements NodeNameResolverInterface { - public function match(\PhpParser\Node $node) : bool + public function match(Node $node) : bool { - return $node instanceof \PhpParser\Node\Expr\FuncCall; + return $node instanceof FuncCall; } /** * @param FuncCall $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { - if ($node->name instanceof \PhpParser\Node\Expr) { + if ($node->name instanceof Expr) { return null; } return (string) $node->name; diff --git a/vendor/symplify/astral/src/NodeNameResolver/IdentifierNodeNameResolver.php b/vendor/symplify/astral/src/NodeNameResolver/IdentifierNodeNameResolver.php index e8371bb0d06..a2f535b81c1 100644 --- a/vendor/symplify/astral/src/NodeNameResolver/IdentifierNodeNameResolver.php +++ b/vendor/symplify/astral/src/NodeNameResolver/IdentifierNodeNameResolver.php @@ -7,19 +7,19 @@ use PhpParser\Node; use PhpParser\Node\Identifier; use PhpParser\Node\Name; use RectorPrefix20220607\Symplify\Astral\Contract\NodeNameResolverInterface; -final class IdentifierNodeNameResolver implements \RectorPrefix20220607\Symplify\Astral\Contract\NodeNameResolverInterface +final class IdentifierNodeNameResolver implements NodeNameResolverInterface { - public function match(\PhpParser\Node $node) : bool + public function match(Node $node) : bool { - if ($node instanceof \PhpParser\Node\Identifier) { + if ($node instanceof Identifier) { return \true; } - return $node instanceof \PhpParser\Node\Name; + return $node instanceof Name; } /** * @param Identifier|Name $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { return (string) $node; } diff --git a/vendor/symplify/astral/src/NodeNameResolver/NamespaceNodeNameResolver.php b/vendor/symplify/astral/src/NodeNameResolver/NamespaceNodeNameResolver.php index 10d3ac473de..69ed7eb5557 100644 --- a/vendor/symplify/astral/src/NodeNameResolver/NamespaceNodeNameResolver.php +++ b/vendor/symplify/astral/src/NodeNameResolver/NamespaceNodeNameResolver.php @@ -6,16 +6,16 @@ namespace RectorPrefix20220607\Symplify\Astral\NodeNameResolver; use PhpParser\Node; use PhpParser\Node\Stmt\Namespace_; use RectorPrefix20220607\Symplify\Astral\Contract\NodeNameResolverInterface; -final class NamespaceNodeNameResolver implements \RectorPrefix20220607\Symplify\Astral\Contract\NodeNameResolverInterface +final class NamespaceNodeNameResolver implements NodeNameResolverInterface { - public function match(\PhpParser\Node $node) : bool + public function match(Node $node) : bool { - return $node instanceof \PhpParser\Node\Stmt\Namespace_; + return $node instanceof Namespace_; } /** * @param Namespace_ $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { if ($node->name === null) { return null; diff --git a/vendor/symplify/astral/src/NodeNameResolver/ParamNodeNameResolver.php b/vendor/symplify/astral/src/NodeNameResolver/ParamNodeNameResolver.php index 3b1118b6781..a76e52d875d 100644 --- a/vendor/symplify/astral/src/NodeNameResolver/ParamNodeNameResolver.php +++ b/vendor/symplify/astral/src/NodeNameResolver/ParamNodeNameResolver.php @@ -7,19 +7,19 @@ use PhpParser\Node; use PhpParser\Node\Expr; use PhpParser\Node\Param; use RectorPrefix20220607\Symplify\Astral\Contract\NodeNameResolverInterface; -final class ParamNodeNameResolver implements \RectorPrefix20220607\Symplify\Astral\Contract\NodeNameResolverInterface +final class ParamNodeNameResolver implements NodeNameResolverInterface { - public function match(\PhpParser\Node $node) : bool + public function match(Node $node) : bool { - return $node instanceof \PhpParser\Node\Param; + return $node instanceof Param; } /** * @param Param $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { $paramName = $node->var->name; - if ($paramName instanceof \PhpParser\Node\Expr) { + if ($paramName instanceof Expr) { return null; } return $paramName; diff --git a/vendor/symplify/astral/src/NodeNameResolver/PropertyNodeNameResolver.php b/vendor/symplify/astral/src/NodeNameResolver/PropertyNodeNameResolver.php index 9c2c3f9d6f6..904d0e2cfce 100644 --- a/vendor/symplify/astral/src/NodeNameResolver/PropertyNodeNameResolver.php +++ b/vendor/symplify/astral/src/NodeNameResolver/PropertyNodeNameResolver.php @@ -6,16 +6,16 @@ namespace RectorPrefix20220607\Symplify\Astral\NodeNameResolver; use PhpParser\Node; use PhpParser\Node\Stmt\Property; use RectorPrefix20220607\Symplify\Astral\Contract\NodeNameResolverInterface; -final class PropertyNodeNameResolver implements \RectorPrefix20220607\Symplify\Astral\Contract\NodeNameResolverInterface +final class PropertyNodeNameResolver implements NodeNameResolverInterface { - public function match(\PhpParser\Node $node) : bool + public function match(Node $node) : bool { - return $node instanceof \PhpParser\Node\Stmt\Property; + return $node instanceof Property; } /** * @param Property $node */ - public function resolve(\PhpParser\Node $node) : ?string + public function resolve(Node $node) : ?string { $propertyProperty = $node->props[0]; return (string) $propertyProperty->name; diff --git a/vendor/symplify/astral/src/NodeTraverser/SimpleCallableNodeTraverser.php b/vendor/symplify/astral/src/NodeTraverser/SimpleCallableNodeTraverser.php index 145c4e6214c..31a6d45893b 100644 --- a/vendor/symplify/astral/src/NodeTraverser/SimpleCallableNodeTraverser.php +++ b/vendor/symplify/astral/src/NodeTraverser/SimpleCallableNodeTraverser.php @@ -26,8 +26,8 @@ final class SimpleCallableNodeTraverser if (!\is_array($nodes)) { $nodes = [$nodes]; } - $nodeTraverser = new \PhpParser\NodeTraverser(); - $callableNodeVisitor = new \RectorPrefix20220607\Symplify\Astral\NodeVisitor\CallableNodeVisitor($callable); + $nodeTraverser = new NodeTraverser(); + $callableNodeVisitor = new CallableNodeVisitor($callable); $nodeTraverser->addVisitor($callableNodeVisitor); $nodeTraverser->traverse($nodes); } diff --git a/vendor/symplify/astral/src/NodeValue/NodeValueResolver.php b/vendor/symplify/astral/src/NodeValue/NodeValueResolver.php index b7e78bb8a94..1224fbd907b 100644 --- a/vendor/symplify/astral/src/NodeValue/NodeValueResolver.php +++ b/vendor/symplify/astral/src/NodeValue/NodeValueResolver.php @@ -52,34 +52,34 @@ final class NodeValueResolver * @var \Symplify\PackageBuilder\Php\TypeChecker */ private $typeChecker; - public function __construct(\RectorPrefix20220607\Symplify\Astral\Naming\SimpleNameResolver $simpleNameResolver, \RectorPrefix20220607\Symplify\PackageBuilder\Php\TypeChecker $typeChecker, \RectorPrefix20220607\Symplify\Astral\NodeFinder\SimpleNodeFinder $simpleNodeFinder) + public function __construct(SimpleNameResolver $simpleNameResolver, TypeChecker $typeChecker, SimpleNodeFinder $simpleNodeFinder) { $this->simpleNameResolver = $simpleNameResolver; $this->typeChecker = $typeChecker; - $this->constExprEvaluator = new \PhpParser\ConstExprEvaluator(function (\PhpParser\Node\Expr $expr) { + $this->constExprEvaluator = new ConstExprEvaluator(function (Expr $expr) { return $this->resolveByNode($expr); }); - $this->unionTypeValueResolver = new \RectorPrefix20220607\Symplify\Astral\NodeValue\UnionTypeValueResolver(); - $this->nodeValueResolvers[] = new \RectorPrefix20220607\Symplify\Astral\NodeValue\NodeValueResolver\ClassConstFetchValueResolver($this->simpleNameResolver, $simpleNodeFinder); - $this->nodeValueResolvers[] = new \RectorPrefix20220607\Symplify\Astral\NodeValue\NodeValueResolver\ConstFetchValueResolver($this->simpleNameResolver); - $this->nodeValueResolvers[] = new \RectorPrefix20220607\Symplify\Astral\NodeValue\NodeValueResolver\MagicConstValueResolver(); - $this->nodeValueResolvers[] = new \RectorPrefix20220607\Symplify\Astral\NodeValue\NodeValueResolver\FuncCallValueResolver($this->simpleNameResolver, $this->constExprEvaluator); + $this->unionTypeValueResolver = new UnionTypeValueResolver(); + $this->nodeValueResolvers[] = new ClassConstFetchValueResolver($this->simpleNameResolver, $simpleNodeFinder); + $this->nodeValueResolvers[] = new ConstFetchValueResolver($this->simpleNameResolver); + $this->nodeValueResolvers[] = new MagicConstValueResolver(); + $this->nodeValueResolvers[] = new FuncCallValueResolver($this->simpleNameResolver, $this->constExprEvaluator); } /** * @return mixed */ - public function resolveWithScope(\PhpParser\Node\Expr $expr, \PHPStan\Analyser\Scope $scope) + public function resolveWithScope(Expr $expr, Scope $scope) { $this->currentFilePath = $scope->getFile(); try { return $this->constExprEvaluator->evaluateDirectly($expr); - } catch (\PhpParser\ConstExprEvaluationException $exception) { + } catch (ConstExprEvaluationException $exception) { } $exprType = $scope->getType($expr); - if ($exprType instanceof \PHPStan\Type\ConstantScalarType) { + if ($exprType instanceof ConstantScalarType) { return $exprType->getValue(); } - if ($exprType instanceof \PHPStan\Type\UnionType) { + if ($exprType instanceof UnionType) { return $this->unionTypeValueResolver->resolveConstantTypes($exprType); } return null; @@ -87,22 +87,22 @@ final class NodeValueResolver /** * @return mixed */ - public function resolve(\PhpParser\Node\Expr $expr, string $filePath) + public function resolve(Expr $expr, string $filePath) { $this->currentFilePath = $filePath; try { return $this->constExprEvaluator->evaluateDirectly($expr); - } catch (\PhpParser\ConstExprEvaluationException $exception) { + } catch (ConstExprEvaluationException $exception) { return null; } } /** * @return mixed */ - private function resolveByNode(\PhpParser\Node\Expr $expr) + private function resolveByNode(Expr $expr) { if ($this->currentFilePath === null) { - throw new \RectorPrefix20220607\Symplify\Astral\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } foreach ($this->nodeValueResolvers as $nodeValueResolver) { if (\is_a($expr, $nodeValueResolver->getType(), \true)) { @@ -110,8 +110,8 @@ final class NodeValueResolver } } // these values cannot be resolved in reliable way - if ($this->typeChecker->isInstanceOf($expr, [\PhpParser\Node\Expr\Variable::class, \PhpParser\Node\Expr\Cast::class, \PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\PropertyFetch::class, \PhpParser\Node\Expr\Instanceof_::class])) { - throw new \PhpParser\ConstExprEvaluationException(); + if ($this->typeChecker->isInstanceOf($expr, [Variable::class, Cast::class, MethodCall::class, PropertyFetch::class, Instanceof_::class])) { + throw new ConstExprEvaluationException(); } return null; } diff --git a/vendor/symplify/astral/src/NodeValue/NodeValueResolver/ClassConstFetchValueResolver.php b/vendor/symplify/astral/src/NodeValue/NodeValueResolver/ClassConstFetchValueResolver.php index a1594a7950b..c643907d58f 100644 --- a/vendor/symplify/astral/src/NodeValue/NodeValueResolver/ClassConstFetchValueResolver.php +++ b/vendor/symplify/astral/src/NodeValue/NodeValueResolver/ClassConstFetchValueResolver.php @@ -15,7 +15,7 @@ use RectorPrefix20220607\Symplify\Astral\NodeFinder\SimpleNodeFinder; * * @implements NodeValueResolverInterface */ -final class ClassConstFetchValueResolver implements \RectorPrefix20220607\Symplify\Astral\Contract\NodeValueResolver\NodeValueResolverInterface +final class ClassConstFetchValueResolver implements NodeValueResolverInterface { /** * @var \Symplify\Astral\Naming\SimpleNameResolver @@ -25,25 +25,25 @@ final class ClassConstFetchValueResolver implements \RectorPrefix20220607\Sympli * @var \Symplify\Astral\NodeFinder\SimpleNodeFinder */ private $simpleNodeFinder; - public function __construct(\RectorPrefix20220607\Symplify\Astral\Naming\SimpleNameResolver $simpleNameResolver, \RectorPrefix20220607\Symplify\Astral\NodeFinder\SimpleNodeFinder $simpleNodeFinder) + public function __construct(SimpleNameResolver $simpleNameResolver, SimpleNodeFinder $simpleNodeFinder) { $this->simpleNameResolver = $simpleNameResolver; $this->simpleNodeFinder = $simpleNodeFinder; } public function getType() : string { - return \PhpParser\Node\Expr\ClassConstFetch::class; + return ClassConstFetch::class; } /** * @param ClassConstFetch $expr * @return mixed */ - public function resolve(\PhpParser\Node\Expr $expr, string $currentFilePath) + public function resolve(Expr $expr, string $currentFilePath) { $className = $this->simpleNameResolver->getName($expr->class); if ($className === 'self') { - $classLike = $this->simpleNodeFinder->findFirstParentByType($expr, \PhpParser\Node\Stmt\ClassLike::class); - if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) { + $classLike = $this->simpleNodeFinder->findFirstParentByType($expr, ClassLike::class); + if (!$classLike instanceof ClassLike) { return null; } $className = $this->simpleNameResolver->getName($classLike); @@ -61,7 +61,7 @@ final class ClassConstFetchValueResolver implements \RectorPrefix20220607\Sympli if (!\class_exists($className) && !\interface_exists($className)) { return null; } - $reflectionClassConstant = new \ReflectionClassConstant($className, $constantName); + $reflectionClassConstant = new ReflectionClassConstant($className, $constantName); return $reflectionClassConstant->getValue(); } } diff --git a/vendor/symplify/astral/src/NodeValue/NodeValueResolver/ConstFetchValueResolver.php b/vendor/symplify/astral/src/NodeValue/NodeValueResolver/ConstFetchValueResolver.php index a6e7e58b024..bf4d48e26ff 100644 --- a/vendor/symplify/astral/src/NodeValue/NodeValueResolver/ConstFetchValueResolver.php +++ b/vendor/symplify/astral/src/NodeValue/NodeValueResolver/ConstFetchValueResolver.php @@ -12,25 +12,25 @@ use RectorPrefix20220607\Symplify\Astral\Naming\SimpleNameResolver; * * @implements NodeValueResolverInterface */ -final class ConstFetchValueResolver implements \RectorPrefix20220607\Symplify\Astral\Contract\NodeValueResolver\NodeValueResolverInterface +final class ConstFetchValueResolver implements NodeValueResolverInterface { /** * @var \Symplify\Astral\Naming\SimpleNameResolver */ private $simpleNameResolver; - public function __construct(\RectorPrefix20220607\Symplify\Astral\Naming\SimpleNameResolver $simpleNameResolver) + public function __construct(SimpleNameResolver $simpleNameResolver) { $this->simpleNameResolver = $simpleNameResolver; } public function getType() : string { - return \PhpParser\Node\Expr\ConstFetch::class; + return ConstFetch::class; } /** * @param ConstFetch $expr * @return mixed */ - public function resolve(\PhpParser\Node\Expr $expr, string $currentFilePath) + public function resolve(Expr $expr, string $currentFilePath) { $constFetchName = $this->simpleNameResolver->getName($expr); if ($constFetchName === null) { diff --git a/vendor/symplify/astral/src/NodeValue/NodeValueResolver/FuncCallValueResolver.php b/vendor/symplify/astral/src/NodeValue/NodeValueResolver/FuncCallValueResolver.php index 6eb4cb8b54f..92eae62f133 100644 --- a/vendor/symplify/astral/src/NodeValue/NodeValueResolver/FuncCallValueResolver.php +++ b/vendor/symplify/astral/src/NodeValue/NodeValueResolver/FuncCallValueResolver.php @@ -15,7 +15,7 @@ use RectorPrefix20220607\Symplify\Astral\Naming\SimpleNameResolver; * * @implements NodeValueResolverInterface */ -final class FuncCallValueResolver implements \RectorPrefix20220607\Symplify\Astral\Contract\NodeValueResolver\NodeValueResolverInterface +final class FuncCallValueResolver implements NodeValueResolverInterface { /** * @var string[] @@ -29,20 +29,20 @@ final class FuncCallValueResolver implements \RectorPrefix20220607\Symplify\Astr * @var \PhpParser\ConstExprEvaluator */ private $constExprEvaluator; - public function __construct(\RectorPrefix20220607\Symplify\Astral\Naming\SimpleNameResolver $simpleNameResolver, \PhpParser\ConstExprEvaluator $constExprEvaluator) + public function __construct(SimpleNameResolver $simpleNameResolver, ConstExprEvaluator $constExprEvaluator) { $this->simpleNameResolver = $simpleNameResolver; $this->constExprEvaluator = $constExprEvaluator; } public function getType() : string { - return \PhpParser\Node\Expr\FuncCall::class; + return FuncCall::class; } /** * @param FuncCall $expr * @return mixed */ - public function resolve(\PhpParser\Node\Expr $expr, string $currentFilePath) + public function resolve(Expr $expr, string $currentFilePath) { if ($this->simpleNameResolver->isName($expr, 'getcwd')) { return \dirname($currentFilePath); @@ -52,7 +52,7 @@ final class FuncCallValueResolver implements \RectorPrefix20220607\Symplify\Astr foreach ($args as $arg) { $arguments[] = $this->constExprEvaluator->evaluateDirectly($arg->value); } - if ($expr->name instanceof \PhpParser\Node\Name) { + if ($expr->name instanceof Name) { $functionName = (string) $expr->name; if (!$this->isAllowedFunctionName($functionName)) { return null; @@ -60,7 +60,7 @@ final class FuncCallValueResolver implements \RectorPrefix20220607\Symplify\Astr if (\function_exists($functionName)) { return $functionName(...$arguments); } - throw new \RectorPrefix20220607\Symplify\Astral\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } return null; } diff --git a/vendor/symplify/astral/src/NodeValue/NodeValueResolver/MagicConstValueResolver.php b/vendor/symplify/astral/src/NodeValue/NodeValueResolver/MagicConstValueResolver.php index 68f7b403404..1707c12ae8d 100644 --- a/vendor/symplify/astral/src/NodeValue/NodeValueResolver/MagicConstValueResolver.php +++ b/vendor/symplify/astral/src/NodeValue/NodeValueResolver/MagicConstValueResolver.php @@ -13,21 +13,21 @@ use RectorPrefix20220607\Symplify\Astral\Contract\NodeValueResolver\NodeValueRes * * @implements NodeValueResolverInterface */ -final class MagicConstValueResolver implements \RectorPrefix20220607\Symplify\Astral\Contract\NodeValueResolver\NodeValueResolverInterface +final class MagicConstValueResolver implements NodeValueResolverInterface { public function getType() : string { - return \PhpParser\Node\Scalar\MagicConst::class; + return MagicConst::class; } /** * @param MagicConst $expr */ - public function resolve(\PhpParser\Node\Expr $expr, string $currentFilePath) : ?string + public function resolve(Expr $expr, string $currentFilePath) : ?string { - if ($expr instanceof \PhpParser\Node\Scalar\MagicConst\Dir) { + if ($expr instanceof Dir) { return \dirname($currentFilePath); } - if ($expr instanceof \PhpParser\Node\Scalar\MagicConst\File) { + if ($expr instanceof File) { return $currentFilePath; } return null; diff --git a/vendor/symplify/astral/src/NodeValue/UnionTypeValueResolver.php b/vendor/symplify/astral/src/NodeValue/UnionTypeValueResolver.php index 6f322502ce7..45db74fe6f1 100644 --- a/vendor/symplify/astral/src/NodeValue/UnionTypeValueResolver.php +++ b/vendor/symplify/astral/src/NodeValue/UnionTypeValueResolver.php @@ -10,11 +10,11 @@ final class UnionTypeValueResolver /** * @return mixed[] */ - public function resolveConstantTypes(\PHPStan\Type\UnionType $unionType) : array + public function resolveConstantTypes(UnionType $unionType) : array { $resolvedValues = []; foreach ($unionType->getTypes() as $unionedType) { - if (!$unionedType instanceof \PHPStan\Type\ConstantScalarType) { + if (!$unionedType instanceof ConstantScalarType) { continue; } $resolvedValues[] = $unionedType->getValue(); diff --git a/vendor/symplify/astral/src/NodeVisitor/CallableNodeVisitor.php b/vendor/symplify/astral/src/NodeVisitor/CallableNodeVisitor.php index 88f192670d0..ea19d03fe84 100644 --- a/vendor/symplify/astral/src/NodeVisitor/CallableNodeVisitor.php +++ b/vendor/symplify/astral/src/NodeVisitor/CallableNodeVisitor.php @@ -8,7 +8,7 @@ use PhpParser\Node\Expr; use PhpParser\Node\Stmt; use PhpParser\Node\Stmt\Expression; use PhpParser\NodeVisitorAbstract; -final class CallableNodeVisitor extends \PhpParser\NodeVisitorAbstract +final class CallableNodeVisitor extends NodeVisitorAbstract { /** * @var callable(Node): (int|Node|null) @@ -24,14 +24,14 @@ final class CallableNodeVisitor extends \PhpParser\NodeVisitorAbstract /** * @return int|\PhpParser\Node|null */ - public function enterNode(\PhpParser\Node $node) + public function enterNode(Node $node) { $originalNode = $node; $callable = $this->callable; /** @var int|Node|null $newNode */ $newNode = $callable($node); - if ($originalNode instanceof \PhpParser\Node\Stmt && $newNode instanceof \PhpParser\Node\Expr) { - return new \PhpParser\Node\Stmt\Expression($newNode); + if ($originalNode instanceof Stmt && $newNode instanceof Expr) { + return new Expression($newNode); } return $newNode; } diff --git a/vendor/symplify/astral/src/PhpDocParser/Contract/PhpDocNodeVisitorInterface.php b/vendor/symplify/astral/src/PhpDocParser/Contract/PhpDocNodeVisitorInterface.php index ee8f89b0e47..6c74ee72264 100644 --- a/vendor/symplify/astral/src/PhpDocParser/Contract/PhpDocNodeVisitorInterface.php +++ b/vendor/symplify/astral/src/PhpDocParser/Contract/PhpDocNodeVisitorInterface.php @@ -9,14 +9,14 @@ use PHPStan\PhpDocParser\Ast\Node; */ interface PhpDocNodeVisitorInterface { - public function beforeTraverse(\PHPStan\PhpDocParser\Ast\Node $node) : void; + public function beforeTraverse(Node $node) : void; /** * @return int|\PHPStan\PhpDocParser\Ast\Node|null */ - public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node); + public function enterNode(Node $node); /** * @return int|\PhpParser\Node|mixed[]|null Replacement node (or special return) */ - public function leaveNode(\PHPStan\PhpDocParser\Ast\Node $node); - public function afterTraverse(\PHPStan\PhpDocParser\Ast\Node $node) : void; + public function leaveNode(Node $node); + public function afterTraverse(Node $node) : void; } diff --git a/vendor/symplify/astral/src/PhpDocParser/Exception/InvalidTraverseException.php b/vendor/symplify/astral/src/PhpDocParser/Exception/InvalidTraverseException.php index 23afd449923..b7959cd61b5 100644 --- a/vendor/symplify/astral/src/PhpDocParser/Exception/InvalidTraverseException.php +++ b/vendor/symplify/astral/src/PhpDocParser/Exception/InvalidTraverseException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\Astral\PhpDocParser\Exception; use Exception; -final class InvalidTraverseException extends \Exception +final class InvalidTraverseException extends Exception { } diff --git a/vendor/symplify/astral/src/PhpDocParser/PhpDocNodeTraverser.php b/vendor/symplify/astral/src/PhpDocParser/PhpDocNodeTraverser.php index 17bcf4ff184..64ccce11bca 100644 --- a/vendor/symplify/astral/src/PhpDocParser/PhpDocNodeTraverser.php +++ b/vendor/symplify/astral/src/PhpDocParser/PhpDocNodeTraverser.php @@ -62,11 +62,11 @@ final class PhpDocNodeTraverser * @var PhpDocNodeVisitorInterface[] */ private $phpDocNodeVisitors = []; - public function addPhpDocNodeVisitor(\RectorPrefix20220607\Symplify\Astral\PhpDocParser\Contract\PhpDocNodeVisitorInterface $phpDocNodeVisitor) : void + public function addPhpDocNodeVisitor(PhpDocNodeVisitorInterface $phpDocNodeVisitor) : void { $this->phpDocNodeVisitors[] = $phpDocNodeVisitor; } - public function traverse(\PHPStan\PhpDocParser\Ast\Node $node) : void + public function traverse(Node $node) : void { foreach ($this->phpDocNodeVisitors as $phpDocNodeVisitor) { $phpDocNodeVisitor->beforeTraverse($node); @@ -79,9 +79,9 @@ final class PhpDocNodeTraverser /** * @param callable(Node $node): (int|null|Node) $callable */ - public function traverseWithCallable(\PHPStan\PhpDocParser\Ast\Node $node, string $docContent, callable $callable) : \PHPStan\PhpDocParser\Ast\Node + public function traverseWithCallable(Node $node, string $docContent, callable $callable) : Node { - $callablePhpDocNodeVisitor = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\CallablePhpDocNodeVisitor($callable, $docContent); + $callablePhpDocNodeVisitor = new CallablePhpDocNodeVisitor($callable, $docContent); $this->addPhpDocNodeVisitor($callablePhpDocNodeVisitor); $this->traverse($node); return $node; @@ -91,20 +91,20 @@ final class PhpDocNodeTraverser * @param TNode $node * @return TNode */ - private function traverseNode(\PHPStan\PhpDocParser\Ast\Node $node) : \PHPStan\PhpDocParser\Ast\Node + private function traverseNode(Node $node) : Node { $subNodeNames = \array_keys(\get_object_vars($node)); foreach ($subNodeNames as $subNodeName) { $subNode =& $node->{$subNodeName}; if (\is_array($subNode)) { $subNode = $this->traverseArray($subNode); - } elseif ($subNode instanceof \PHPStan\PhpDocParser\Ast\Node) { + } elseif ($subNode instanceof Node) { $breakVisitorIndex = null; $traverseChildren = \true; foreach ($this->phpDocNodeVisitors as $visitorIndex => $phpDocNodeVisitor) { $return = $phpDocNodeVisitor->enterNode($subNode); if ($return !== null) { - if ($return instanceof \PHPStan\PhpDocParser\Ast\Node) { + if ($return instanceof Node) { $subNode = $return; } elseif ($return === self::DONT_TRAVERSE_CHILDREN) { $traverseChildren = \false; @@ -118,7 +118,7 @@ final class PhpDocNodeTraverser $subNode = null; continue 2; } else { - throw new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\Exception\InvalidTraverseException('enterNode() returned invalid value of type ' . \gettype($return)); + throw new InvalidTraverseException('enterNode() returned invalid value of type ' . \gettype($return)); } } } @@ -146,7 +146,7 @@ final class PhpDocNodeTraverser { foreach ($nodes as $key => &$node) { // can be string or something else - if (!$node instanceof \PHPStan\PhpDocParser\Ast\Node) { + if (!$node instanceof Node) { continue; } $traverseChildren = \true; @@ -154,7 +154,7 @@ final class PhpDocNodeTraverser foreach ($this->phpDocNodeVisitors as $visitorIndex => $phpDocNodeVisitor) { $return = $phpDocNodeVisitor->enterNode($node); if ($return !== null) { - if ($return instanceof \PHPStan\PhpDocParser\Ast\Node) { + if ($return instanceof Node) { $node = $return; } elseif ($return === self::DONT_TRAVERSE_CHILDREN) { $traverseChildren = \false; @@ -169,7 +169,7 @@ final class PhpDocNodeTraverser unset($nodes[$key]); continue 2; } else { - throw new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\Exception\InvalidTraverseException('enterNode() returned invalid value of type ' . \gettype($return)); + throw new InvalidTraverseException('enterNode() returned invalid value of type ' . \gettype($return)); } } } @@ -183,7 +183,7 @@ final class PhpDocNodeTraverser foreach ($this->phpDocNodeVisitors as $visitorIndex => $phpDocNodeVisitor) { $return = $phpDocNodeVisitor->leaveNode($node); if ($return !== null) { - if ($return instanceof \PHPStan\PhpDocParser\Ast\Node) { + if ($return instanceof Node) { $node = $return; } elseif (\is_array($return)) { $doNodes[] = [$key, $return]; @@ -195,7 +195,7 @@ final class PhpDocNodeTraverser $this->stopTraversal = \true; break 2; } else { - throw new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\Exception\InvalidTraverseException('leaveNode() returned invalid value of type ' . \gettype($return)); + throw new InvalidTraverseException('leaveNode() returned invalid value of type ' . \gettype($return)); } } if ($breakVisitorIndex === $visitorIndex) { diff --git a/vendor/symplify/astral/src/PhpDocParser/PhpDocNodeVisitor/AbstractPhpDocNodeVisitor.php b/vendor/symplify/astral/src/PhpDocParser/PhpDocNodeVisitor/AbstractPhpDocNodeVisitor.php index 8d6589d69cc..8f1ae1daea9 100644 --- a/vendor/symplify/astral/src/PhpDocParser/PhpDocNodeVisitor/AbstractPhpDocNodeVisitor.php +++ b/vendor/symplify/astral/src/PhpDocParser/PhpDocNodeVisitor/AbstractPhpDocNodeVisitor.php @@ -8,26 +8,26 @@ use RectorPrefix20220607\Symplify\Astral\PhpDocParser\Contract\PhpDocNodeVisitor /** * Inspired by https://github.com/nikic/PHP-Parser/blob/master/lib/PhpParser/NodeVisitorAbstract.php */ -abstract class AbstractPhpDocNodeVisitor implements \RectorPrefix20220607\Symplify\Astral\PhpDocParser\Contract\PhpDocNodeVisitorInterface +abstract class AbstractPhpDocNodeVisitor implements PhpDocNodeVisitorInterface { - public function beforeTraverse(\PHPStan\PhpDocParser\Ast\Node $node) : void + public function beforeTraverse(Node $node) : void { } /** * @return int|\PHPStan\PhpDocParser\Ast\Node|null */ - public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) + public function enterNode(Node $node) { return null; } /** * @return int|\PhpParser\Node|mixed[]|null Replacement node (or special return) */ - public function leaveNode(\PHPStan\PhpDocParser\Ast\Node $node) + public function leaveNode(Node $node) { return null; } - public function afterTraverse(\PHPStan\PhpDocParser\Ast\Node $node) : void + public function afterTraverse(Node $node) : void { } } diff --git a/vendor/symplify/astral/src/PhpDocParser/PhpDocNodeVisitor/CallablePhpDocNodeVisitor.php b/vendor/symplify/astral/src/PhpDocParser/PhpDocNodeVisitor/CallablePhpDocNodeVisitor.php index 637d469dcd5..d87f5344fea 100644 --- a/vendor/symplify/astral/src/PhpDocParser/PhpDocNodeVisitor/CallablePhpDocNodeVisitor.php +++ b/vendor/symplify/astral/src/PhpDocParser/PhpDocNodeVisitor/CallablePhpDocNodeVisitor.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor; use PHPStan\PhpDocParser\Ast\Node; -final class CallablePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor +final class CallablePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor { /** * @var callable(Node, string|null): (int|null|Node) @@ -25,7 +25,7 @@ final class CallablePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Ast /** * @return int|\PHPStan\PhpDocParser\Ast\Node|null */ - public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) + public function enterNode(Node $node) { $callable = $this->callable; return $callable($node, $this->docContent); diff --git a/vendor/symplify/astral/src/PhpDocParser/PhpDocNodeVisitor/CloningPhpDocNodeVisitor.php b/vendor/symplify/astral/src/PhpDocParser/PhpDocNodeVisitor/CloningPhpDocNodeVisitor.php index 66819292399..95dd6dad493 100644 --- a/vendor/symplify/astral/src/PhpDocParser/PhpDocNodeVisitor/CloningPhpDocNodeVisitor.php +++ b/vendor/symplify/astral/src/PhpDocParser/PhpDocNodeVisitor/CloningPhpDocNodeVisitor.php @@ -11,12 +11,12 @@ use RectorPrefix20220607\Symplify\Astral\PhpDocParser\ValueObject\PhpDocAttribut * Mirrors * https://github.com/nikic/PHP-Parser/blob/d520bc9e1d6203c35a1ba20675b79a051c821a9e/lib/PhpParser/NodeVisitor/CloningVisitor.php */ -final class CloningPhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor +final class CloningPhpDocNodeVisitor extends AbstractPhpDocNodeVisitor { - public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : \PHPStan\PhpDocParser\Ast\Node + public function enterNode(Node $node) : Node { $clonedNode = clone $node; - $clonedNode->setAttribute(\RectorPrefix20220607\Symplify\Astral\PhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE, $node); + $clonedNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, $node); return $clonedNode; } } diff --git a/vendor/symplify/astral/src/PhpDocParser/PhpDocNodeVisitor/ParentConnectingPhpDocNodeVisitor.php b/vendor/symplify/astral/src/PhpDocParser/PhpDocNodeVisitor/ParentConnectingPhpDocNodeVisitor.php index 49eb1631921..683b9ce9d9d 100644 --- a/vendor/symplify/astral/src/PhpDocParser/PhpDocNodeVisitor/ParentConnectingPhpDocNodeVisitor.php +++ b/vendor/symplify/astral/src/PhpDocParser/PhpDocNodeVisitor/ParentConnectingPhpDocNodeVisitor.php @@ -12,21 +12,21 @@ use RectorPrefix20220607\Symplify\Astral\PhpDocParser\ValueObject\PhpDocAttribut * * @see \Symplify\Astral\Tests\PhpDocParser\PhpDocNodeVisitor\ParentConnectingPhpDocNodeVisitorTest */ -final class ParentConnectingPhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor +final class ParentConnectingPhpDocNodeVisitor extends AbstractPhpDocNodeVisitor { /** * @var Node[] */ private $stack = []; - public function beforeTraverse(\PHPStan\PhpDocParser\Ast\Node $node) : void + public function beforeTraverse(Node $node) : void { $this->stack = [$node]; } - public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : \PHPStan\PhpDocParser\Ast\Node + public function enterNode(Node $node) : Node { if ($this->stack !== []) { $parentNode = $this->stack[\count($this->stack) - 1]; - $node->setAttribute(\RectorPrefix20220607\Symplify\Astral\PhpDocParser\ValueObject\PhpDocAttributeKey::PARENT, $parentNode); + $node->setAttribute(PhpDocAttributeKey::PARENT, $parentNode); } $this->stack[] = $node; return $node; @@ -34,7 +34,7 @@ final class ParentConnectingPhpDocNodeVisitor extends \RectorPrefix20220607\Symp /** * @return int|\PhpParser\Node|mixed[]|null Replacement node (or special return */ - public function leaveNode(\PHPStan\PhpDocParser\Ast\Node $node) + public function leaveNode(Node $node) { \array_pop($this->stack); return null; diff --git a/vendor/symplify/astral/src/PhpDocParser/SimplePhpDocParser.php b/vendor/symplify/astral/src/PhpDocParser/SimplePhpDocParser.php index 87b87a68bee..05955ed9217 100644 --- a/vendor/symplify/astral/src/PhpDocParser/SimplePhpDocParser.php +++ b/vendor/symplify/astral/src/PhpDocParser/SimplePhpDocParser.php @@ -22,24 +22,24 @@ final class SimplePhpDocParser * @var \PHPStan\PhpDocParser\Lexer\Lexer */ private $lexer; - public function __construct(\PHPStan\PhpDocParser\Parser\PhpDocParser $phpDocParser, \PHPStan\PhpDocParser\Lexer\Lexer $lexer) + public function __construct(PhpDocParser $phpDocParser, Lexer $lexer) { $this->phpDocParser = $phpDocParser; $this->lexer = $lexer; } - public function parseNode(\PhpParser\Node $node) : ?\RectorPrefix20220607\Symplify\Astral\PhpDocParser\ValueObject\Ast\PhpDoc\SimplePhpDocNode + public function parseNode(Node $node) : ?SimplePhpDocNode { $docComment = $node->getDocComment(); - if (!$docComment instanceof \PhpParser\Comment\Doc) { + if (!$docComment instanceof Doc) { return null; } return $this->parseDocBlock($docComment->getText()); } - public function parseDocBlock(string $docBlock) : \RectorPrefix20220607\Symplify\Astral\PhpDocParser\ValueObject\Ast\PhpDoc\SimplePhpDocNode + public function parseDocBlock(string $docBlock) : SimplePhpDocNode { $tokens = $this->lexer->tokenize($docBlock); - $tokenIterator = new \PHPStan\PhpDocParser\Parser\TokenIterator($tokens); + $tokenIterator = new TokenIterator($tokens); $phpDocNode = $this->phpDocParser->parse($tokenIterator); - return new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\ValueObject\Ast\PhpDoc\SimplePhpDocNode($phpDocNode->children); + return new SimplePhpDocNode($phpDocNode->children); } } diff --git a/vendor/symplify/astral/src/PhpDocParser/StaticFactory/SimplePhpDocParserStaticFactory.php b/vendor/symplify/astral/src/PhpDocParser/StaticFactory/SimplePhpDocParserStaticFactory.php index 5296ad186b5..488f58f9c9d 100644 --- a/vendor/symplify/astral/src/PhpDocParser/StaticFactory/SimplePhpDocParserStaticFactory.php +++ b/vendor/symplify/astral/src/PhpDocParser/StaticFactory/SimplePhpDocParserStaticFactory.php @@ -13,9 +13,9 @@ use RectorPrefix20220607\Symplify\Astral\PhpDocParser\SimplePhpDocParser; */ final class SimplePhpDocParserStaticFactory { - public static function create() : \RectorPrefix20220607\Symplify\Astral\PhpDocParser\SimplePhpDocParser + public static function create() : SimplePhpDocParser { - $phpDocParser = new \PHPStan\PhpDocParser\Parser\PhpDocParser(new \PHPStan\PhpDocParser\Parser\TypeParser(), new \PHPStan\PhpDocParser\Parser\ConstExprParser()); - return new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\SimplePhpDocParser($phpDocParser, new \PHPStan\PhpDocParser\Lexer\Lexer()); + $phpDocParser = new PhpDocParser(new TypeParser(), new ConstExprParser()); + return new SimplePhpDocParser($phpDocParser, new Lexer()); } } diff --git a/vendor/symplify/astral/src/PhpDocParser/ValueObject/Ast/PhpDoc/SimplePhpDocNode.php b/vendor/symplify/astral/src/PhpDocParser/ValueObject/Ast/PhpDoc/SimplePhpDocNode.php index 97170dce6c4..54aaddf6a2b 100644 --- a/vendor/symplify/astral/src/PhpDocParser/ValueObject/Ast/PhpDoc/SimplePhpDocNode.php +++ b/vendor/symplify/astral/src/PhpDocParser/ValueObject/Ast/PhpDoc/SimplePhpDocNode.php @@ -9,9 +9,9 @@ use PHPStan\PhpDocParser\Ast\Type\TypeNode; /** * @noRector final on purpose, so it can be extended by 3rd party */ -class SimplePhpDocNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode +class SimplePhpDocNode extends PhpDocNode { - public function getParam(string $desiredParamName) : ?\PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode + public function getParam(string $desiredParamName) : ?ParamTagValueNode { $desiredParamNameWithDollar = '$' . \ltrim($desiredParamName, '$'); foreach ($this->getParamTagValues() as $paramTagValueNode) { @@ -22,10 +22,10 @@ class SimplePhpDocNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode } return null; } - public function getParamType(string $desiredParamName) : ?\PHPStan\PhpDocParser\Ast\Type\TypeNode + public function getParamType(string $desiredParamName) : ?TypeNode { $paramTagValueNode = $this->getParam($desiredParamName); - if (!$paramTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode) { + if (!$paramTagValueNode instanceof ParamTagValueNode) { return null; } return $paramTagValueNode->type; diff --git a/vendor/symplify/astral/src/PhpParser/SmartPhpParser.php b/vendor/symplify/astral/src/PhpParser/SmartPhpParser.php index 786d117da21..10459c482f9 100644 --- a/vendor/symplify/astral/src/PhpParser/SmartPhpParser.php +++ b/vendor/symplify/astral/src/PhpParser/SmartPhpParser.php @@ -14,7 +14,7 @@ final class SmartPhpParser * @var \PHPStan\Parser\Parser */ private $parser; - public function __construct(\PHPStan\Parser\Parser $parser) + public function __construct(Parser $parser) { $this->parser = $parser; } diff --git a/vendor/symplify/astral/src/PhpParser/SmartPhpParserFactory.php b/vendor/symplify/astral/src/PhpParser/SmartPhpParserFactory.php index 4cc91116824..7b154622721 100644 --- a/vendor/symplify/astral/src/PhpParser/SmartPhpParserFactory.php +++ b/vendor/symplify/astral/src/PhpParser/SmartPhpParserFactory.php @@ -17,22 +17,22 @@ use PHPStan\Parser\SimpleParser; */ final class SmartPhpParserFactory { - public function create() : \RectorPrefix20220607\Symplify\Astral\PhpParser\SmartPhpParser + public function create() : SmartPhpParser { $nativePhpParser = $this->createNativePhpParser(); $cachedParser = $this->createPHPStanParser($nativePhpParser); - return new \RectorPrefix20220607\Symplify\Astral\PhpParser\SmartPhpParser($cachedParser); + return new SmartPhpParser($cachedParser); } - private function createNativePhpParser() : \PhpParser\Parser + private function createNativePhpParser() : Parser { - $parserFactory = new \PhpParser\ParserFactory(); - $lexerEmulative = new \PhpParser\Lexer\Emulative(); - return $parserFactory->create(\PhpParser\ParserFactory::PREFER_PHP7, $lexerEmulative); + $parserFactory = new ParserFactory(); + $lexerEmulative = new Emulative(); + return $parserFactory->create(ParserFactory::PREFER_PHP7, $lexerEmulative); } - private function createPHPStanParser(\PhpParser\Parser $parser) : \PHPStan\Parser\CachedParser + private function createPHPStanParser(Parser $parser) : CachedParser { - $nameResolver = new \PhpParser\NodeVisitor\NameResolver(); - $simpleParser = new \PHPStan\Parser\SimpleParser($parser, $nameResolver); - return new \PHPStan\Parser\CachedParser($simpleParser, 1024); + $nameResolver = new NameResolver(); + $simpleParser = new SimpleParser($parser, $nameResolver); + return new CachedParser($simpleParser, 1024); } } diff --git a/vendor/symplify/astral/src/Reflection/MethodCallParser.php b/vendor/symplify/astral/src/Reflection/MethodCallParser.php index ed5fea00e73..c5977365a9f 100644 --- a/vendor/symplify/astral/src/Reflection/MethodCallParser.php +++ b/vendor/symplify/astral/src/Reflection/MethodCallParser.php @@ -23,7 +23,7 @@ final class MethodCallParser * @var \Symplify\Astral\Reflection\ReflectionParser */ private $reflectionParser; - public function __construct(\RectorPrefix20220607\Symplify\Astral\Naming\SimpleNameResolver $simpleNameResolver, \RectorPrefix20220607\Symplify\Astral\Reflection\ReflectionParser $reflectionParser) + public function __construct(SimpleNameResolver $simpleNameResolver, ReflectionParser $reflectionParser) { $this->simpleNameResolver = $simpleNameResolver; $this->reflectionParser = $reflectionParser; @@ -31,17 +31,17 @@ final class MethodCallParser /** * @return \PhpParser\Node\Stmt\ClassMethod|null */ - public function parseMethodCall(\PhpParser\Node\Expr\MethodCall $methodCall, \PHPStan\Analyser\Scope $scope) + public function parseMethodCall(MethodCall $methodCall, Scope $scope) { $callerType = $scope->getType($methodCall->var); - if ($callerType instanceof \PHPStan\Type\ThisType) { + if ($callerType instanceof ThisType) { $callerType = $callerType->getStaticObjectType(); } - if (!$callerType instanceof \PHPStan\Type\ObjectType) { + if (!$callerType instanceof ObjectType) { return null; } $classReflection = $callerType->getClassReflection(); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + if (!$classReflection instanceof ClassReflection) { return null; } $methodName = $this->simpleNameResolver->getName($methodCall->name); diff --git a/vendor/symplify/astral/src/Reflection/ReflectionParser.php b/vendor/symplify/astral/src/Reflection/ReflectionParser.php index 8009ff48c04..5ec69e002b9 100644 --- a/vendor/symplify/astral/src/Reflection/ReflectionParser.php +++ b/vendor/symplify/astral/src/Reflection/ReflectionParser.php @@ -27,12 +27,12 @@ final class ReflectionParser * @var \PhpParser\NodeFinder */ private $nodeFinder; - public function __construct(\RectorPrefix20220607\Symplify\Astral\PhpParser\SmartPhpParser $smartPhpParser, \PhpParser\NodeFinder $nodeFinder) + public function __construct(SmartPhpParser $smartPhpParser, NodeFinder $nodeFinder) { $this->smartPhpParser = $smartPhpParser; $this->nodeFinder = $nodeFinder; } - public function parsePHPStanMethodReflection(\PHPStan\Reflection\MethodReflection $methodReflection) : ?\PhpParser\Node\Stmt\ClassMethod + public function parsePHPStanMethodReflection(MethodReflection $methodReflection) : ?ClassMethod { $classReflection = $methodReflection->getDeclaringClass(); $fileName = $classReflection->getFileName(); @@ -40,28 +40,28 @@ final class ReflectionParser return null; } $class = $this->parseFilenameToClass($fileName); - if (!$class instanceof \PhpParser\Node) { + if (!$class instanceof Node) { return null; } return $class->getMethod($methodReflection->getName()); } - public function parseMethodReflection(\ReflectionMethod $reflectionMethod) : ?\PhpParser\Node\Stmt\ClassMethod + public function parseMethodReflection(ReflectionMethod $reflectionMethod) : ?ClassMethod { $class = $this->parseNativeClassReflection($reflectionMethod->getDeclaringClass()); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + if (!$class instanceof Class_) { return null; } return $class->getMethod($reflectionMethod->getName()); } - public function parsePropertyReflection(\ReflectionProperty $reflectionProperty) : ?\PhpParser\Node\Stmt\Property + public function parsePropertyReflection(ReflectionProperty $reflectionProperty) : ?Property { $class = $this->parseNativeClassReflection($reflectionProperty->getDeclaringClass()); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + if (!$class instanceof Class_) { return null; } return $class->getProperty($reflectionProperty->getName()); } - private function parseNativeClassReflection(\ReflectionClass $reflectionClass) : ?\PhpParser\Node\Stmt\Class_ + private function parseNativeClassReflection(ReflectionClass $reflectionClass) : ?Class_ { $fileName = $reflectionClass->getFileName(); if ($fileName === \false) { @@ -76,12 +76,12 @@ final class ReflectionParser { try { $stmts = $this->smartPhpParser->parseFile($fileName); - } catch (\Throwable $exception) { + } catch (Throwable $exception) { // not reachable return null; } - $class = $this->nodeFinder->findFirstInstanceOf($stmts, \PhpParser\Node\Stmt\Class_::class); - if (!$class instanceof \PhpParser\Node\Stmt\Class_) { + $class = $this->nodeFinder->findFirstInstanceOf($stmts, Class_::class); + if (!$class instanceof Class_) { return null; } return $class; diff --git a/vendor/symplify/astral/src/StaticFactory/NodeValueResolverStaticFactory.php b/vendor/symplify/astral/src/StaticFactory/NodeValueResolverStaticFactory.php index 421972d1d3a..2fe858c0bd3 100644 --- a/vendor/symplify/astral/src/StaticFactory/NodeValueResolverStaticFactory.php +++ b/vendor/symplify/astral/src/StaticFactory/NodeValueResolverStaticFactory.php @@ -12,10 +12,10 @@ use RectorPrefix20220607\Symplify\PackageBuilder\Php\TypeChecker; */ final class NodeValueResolverStaticFactory { - public static function create() : \RectorPrefix20220607\Symplify\Astral\NodeValue\NodeValueResolver + public static function create() : NodeValueResolver { - $simpleNameResolver = \RectorPrefix20220607\Symplify\Astral\StaticFactory\SimpleNameResolverStaticFactory::create(); - $simpleNodeFinder = new \RectorPrefix20220607\Symplify\Astral\NodeFinder\SimpleNodeFinder(new \PhpParser\NodeFinder()); - return new \RectorPrefix20220607\Symplify\Astral\NodeValue\NodeValueResolver($simpleNameResolver, new \RectorPrefix20220607\Symplify\PackageBuilder\Php\TypeChecker(), $simpleNodeFinder); + $simpleNameResolver = SimpleNameResolverStaticFactory::create(); + $simpleNodeFinder = new SimpleNodeFinder(new NodeFinder()); + return new NodeValueResolver($simpleNameResolver, new TypeChecker(), $simpleNodeFinder); } } diff --git a/vendor/symplify/astral/src/StaticFactory/SimpleNameResolverStaticFactory.php b/vendor/symplify/astral/src/StaticFactory/SimpleNameResolverStaticFactory.php index e7e0404b8db..3f89be52585 100644 --- a/vendor/symplify/astral/src/StaticFactory/SimpleNameResolverStaticFactory.php +++ b/vendor/symplify/astral/src/StaticFactory/SimpleNameResolverStaticFactory.php @@ -20,9 +20,9 @@ use RectorPrefix20220607\Symplify\Astral\NodeNameResolver\PropertyNodeNameResolv */ final class SimpleNameResolverStaticFactory { - public static function create() : \RectorPrefix20220607\Symplify\Astral\Naming\SimpleNameResolver + public static function create() : SimpleNameResolver { - $nameResolvers = [new \RectorPrefix20220607\Symplify\Astral\NodeNameResolver\ArgNodeNameResolver(), new \RectorPrefix20220607\Symplify\Astral\NodeNameResolver\AttributeNodeNameResolver(), new \RectorPrefix20220607\Symplify\Astral\NodeNameResolver\ClassLikeNodeNameResolver(), new \RectorPrefix20220607\Symplify\Astral\NodeNameResolver\ClassMethodNodeNameResolver(), new \RectorPrefix20220607\Symplify\Astral\NodeNameResolver\ConstFetchNodeNameResolver(), new \RectorPrefix20220607\Symplify\Astral\NodeNameResolver\FuncCallNodeNameResolver(), new \RectorPrefix20220607\Symplify\Astral\NodeNameResolver\IdentifierNodeNameResolver(), new \RectorPrefix20220607\Symplify\Astral\NodeNameResolver\NamespaceNodeNameResolver(), new \RectorPrefix20220607\Symplify\Astral\NodeNameResolver\ParamNodeNameResolver(), new \RectorPrefix20220607\Symplify\Astral\NodeNameResolver\PropertyNodeNameResolver()]; - return new \RectorPrefix20220607\Symplify\Astral\Naming\SimpleNameResolver($nameResolvers); + $nameResolvers = [new ArgNodeNameResolver(), new AttributeNodeNameResolver(), new ClassLikeNodeNameResolver(), new ClassMethodNodeNameResolver(), new ConstFetchNodeNameResolver(), new FuncCallNodeNameResolver(), new IdentifierNodeNameResolver(), new NamespaceNodeNameResolver(), new ParamNodeNameResolver(), new PropertyNodeNameResolver()]; + return new SimpleNameResolver($nameResolvers); } } diff --git a/vendor/symplify/astral/src/TypeAnalyzer/ClassMethodReturnTypeResolver.php b/vendor/symplify/astral/src/TypeAnalyzer/ClassMethodReturnTypeResolver.php index 6c1a4e643ef..10696b25283 100644 --- a/vendor/symplify/astral/src/TypeAnalyzer/ClassMethodReturnTypeResolver.php +++ b/vendor/symplify/astral/src/TypeAnalyzer/ClassMethodReturnTypeResolver.php @@ -21,24 +21,24 @@ final class ClassMethodReturnTypeResolver * @var \Symplify\Astral\Naming\SimpleNameResolver */ private $simpleNameResolver; - public function __construct(\RectorPrefix20220607\Symplify\Astral\Naming\SimpleNameResolver $simpleNameResolver) + public function __construct(SimpleNameResolver $simpleNameResolver) { $this->simpleNameResolver = $simpleNameResolver; } - public function resolve(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PHPStan\Analyser\Scope $scope) : \PHPStan\Type\Type + public function resolve(ClassMethod $classMethod, Scope $scope) : Type { $methodName = $this->simpleNameResolver->getName($classMethod); if (!\is_string($methodName)) { - throw new \RectorPrefix20220607\Symplify\Astral\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $classReflection = $scope->getClassReflection(); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { - return new \PHPStan\Type\MixedType(); + if (!$classReflection instanceof ClassReflection) { + return new MixedType(); } $methodReflection = $classReflection->getMethod($methodName, $scope); - $functionVariant = \PHPStan\Reflection\ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); - if (!$functionVariant instanceof \PHPStan\Reflection\FunctionVariant) { - return new \PHPStan\Type\MixedType(); + $functionVariant = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); + if (!$functionVariant instanceof FunctionVariant) { + return new MixedType(); } return $functionVariant->getReturnType(); } diff --git a/vendor/symplify/astral/src/TypeAnalyzer/ContainsTypeAnalyser.php b/vendor/symplify/astral/src/TypeAnalyzer/ContainsTypeAnalyser.php index 8d5b0f3c37e..c8756c11cf4 100644 --- a/vendor/symplify/astral/src/TypeAnalyzer/ContainsTypeAnalyser.php +++ b/vendor/symplify/astral/src/TypeAnalyzer/ContainsTypeAnalyser.php @@ -15,7 +15,7 @@ final class ContainsTypeAnalyser /** * @param class-string[] $types */ - public function containsExprTypes(\PhpParser\Node\Expr $expr, \PHPStan\Analyser\Scope $scope, array $types) : bool + public function containsExprTypes(Expr $expr, Scope $scope, array $types) : bool { foreach ($types as $type) { if (!$this->containsExprType($expr, $scope, $type)) { @@ -28,7 +28,7 @@ final class ContainsTypeAnalyser /** * @param class-string[] $types */ - public function containsTypeExprTypes(\PHPStan\Type\Type $exprType, array $types) : bool + public function containsTypeExprTypes(Type $exprType, array $types) : bool { foreach ($types as $type) { if ($this->containsTypeExprType($exprType, $type)) { @@ -40,9 +40,9 @@ final class ContainsTypeAnalyser /** * @param class-string $type */ - public function containsTypeExprType(\PHPStan\Type\Type $exprType, string $type) : bool + public function containsTypeExprType(Type $exprType, string $type) : bool { - if ($exprType instanceof \PHPStan\Type\IntersectionType) { + if ($exprType instanceof IntersectionType) { $intersectionedTypes = $exprType->getTypes(); foreach ($intersectionedTypes as $intersectionedType) { if ($this->isExprTypeOfType($intersectionedType, $type)) { @@ -55,7 +55,7 @@ final class ContainsTypeAnalyser /** * @param class-string $type */ - public function containsExprType(\PhpParser\Node\Expr $expr, \PHPStan\Analyser\Scope $scope, string $type) : bool + public function containsExprType(Expr $expr, Scope $scope, string $type) : bool { $exprType = $scope->getType($expr); return $this->containsTypeExprType($exprType, $type); @@ -63,14 +63,14 @@ final class ContainsTypeAnalyser /** * @param class-string $class */ - private function isUnionTypeWithClass(\PHPStan\Type\Type $type, string $class) : bool + private function isUnionTypeWithClass(Type $type, string $class) : bool { - if (!$type instanceof \PHPStan\Type\UnionType) { + if (!$type instanceof UnionType) { return \false; } $unionedTypes = $type->getTypes(); foreach ($unionedTypes as $unionedType) { - if (!$unionedType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$unionedType instanceof TypeWithClassName) { continue; } if (\is_a($unionedType->getClassName(), $class, \true)) { @@ -82,13 +82,13 @@ final class ContainsTypeAnalyser /** * @param class-string $type */ - private function isArrayWithItemType(\PHPStan\Type\Type $propertyType, string $type) : bool + private function isArrayWithItemType(Type $propertyType, string $type) : bool { - if (!$propertyType instanceof \PHPStan\Type\ArrayType) { + if (!$propertyType instanceof ArrayType) { return \false; } $arrayItemType = $propertyType->getItemType(); - if (!$arrayItemType instanceof \PHPStan\Type\TypeWithClassName) { + if (!$arrayItemType instanceof TypeWithClassName) { return \false; } return \is_a($arrayItemType->getClassName(), $type, \true); @@ -96,9 +96,9 @@ final class ContainsTypeAnalyser /** * @param class-string $type */ - private function isExprTypeOfType(\PHPStan\Type\Type $exprType, string $type) : bool + private function isExprTypeOfType(Type $exprType, string $type) : bool { - if ($exprType instanceof \PHPStan\Type\TypeWithClassName) { + if ($exprType instanceof TypeWithClassName) { return \is_a($exprType->getClassName(), $type, \true); } if ($this->isUnionTypeWithClass($exprType, $type)) { diff --git a/vendor/symplify/astral/src/ValueObject/NodeBuilder/ClassBuilder.php b/vendor/symplify/astral/src/ValueObject/NodeBuilder/ClassBuilder.php index f0437eba300..8248e9b158d 100644 --- a/vendor/symplify/astral/src/ValueObject/NodeBuilder/ClassBuilder.php +++ b/vendor/symplify/astral/src/ValueObject/NodeBuilder/ClassBuilder.php @@ -8,6 +8,6 @@ use PhpParser\Builder\Class_; * @api * Fixed duplicated naming in php-parser and prevents confusion */ -final class ClassBuilder extends \PhpParser\Builder\Class_ +final class ClassBuilder extends Class_ { } diff --git a/vendor/symplify/astral/src/ValueObject/NodeBuilder/MethodBuilder.php b/vendor/symplify/astral/src/ValueObject/NodeBuilder/MethodBuilder.php index 3fe12044b51..07ae329d68f 100644 --- a/vendor/symplify/astral/src/ValueObject/NodeBuilder/MethodBuilder.php +++ b/vendor/symplify/astral/src/ValueObject/NodeBuilder/MethodBuilder.php @@ -8,6 +8,6 @@ use PhpParser\Builder\Method; * @api * Fixed duplicated naming in php-parser and prevents confusion */ -final class MethodBuilder extends \PhpParser\Builder\Method +final class MethodBuilder extends Method { } diff --git a/vendor/symplify/astral/src/ValueObject/NodeBuilder/NamespaceBuilder.php b/vendor/symplify/astral/src/ValueObject/NodeBuilder/NamespaceBuilder.php index 03d6a306a16..ec760acc1a3 100644 --- a/vendor/symplify/astral/src/ValueObject/NodeBuilder/NamespaceBuilder.php +++ b/vendor/symplify/astral/src/ValueObject/NodeBuilder/NamespaceBuilder.php @@ -8,6 +8,6 @@ use PhpParser\Builder\Namespace_; * @api * Fixed duplicated naming in php-parser and prevents confusion */ -final class NamespaceBuilder extends \PhpParser\Builder\Namespace_ +final class NamespaceBuilder extends Namespace_ { } diff --git a/vendor/symplify/astral/src/ValueObject/NodeBuilder/ParamBuilder.php b/vendor/symplify/astral/src/ValueObject/NodeBuilder/ParamBuilder.php index b69a7b9d605..52fbae354d5 100644 --- a/vendor/symplify/astral/src/ValueObject/NodeBuilder/ParamBuilder.php +++ b/vendor/symplify/astral/src/ValueObject/NodeBuilder/ParamBuilder.php @@ -8,6 +8,6 @@ use PhpParser\Builder\Param; * @api * Fixed duplicated naming in php-parser and prevents confusion */ -final class ParamBuilder extends \PhpParser\Builder\Param +final class ParamBuilder extends Param { } diff --git a/vendor/symplify/astral/src/ValueObject/NodeBuilder/PropertyBuilder.php b/vendor/symplify/astral/src/ValueObject/NodeBuilder/PropertyBuilder.php index 9e589bb8727..c3cf69b6e5f 100644 --- a/vendor/symplify/astral/src/ValueObject/NodeBuilder/PropertyBuilder.php +++ b/vendor/symplify/astral/src/ValueObject/NodeBuilder/PropertyBuilder.php @@ -8,6 +8,6 @@ use PhpParser\Builder\Property; * @api * Fixed duplicated naming in php-parser and prevents confusion */ -final class PropertyBuilder extends \PhpParser\Builder\Property +final class PropertyBuilder extends Property { } diff --git a/vendor/symplify/astral/src/ValueObject/NodeBuilder/TraitUseBuilder.php b/vendor/symplify/astral/src/ValueObject/NodeBuilder/TraitUseBuilder.php index b071d01ffa5..75ef2b4cb5c 100644 --- a/vendor/symplify/astral/src/ValueObject/NodeBuilder/TraitUseBuilder.php +++ b/vendor/symplify/astral/src/ValueObject/NodeBuilder/TraitUseBuilder.php @@ -8,6 +8,6 @@ use PhpParser\Builder\TraitUse; * @api * Fixed duplicated naming in php-parser and prevents confusion */ -final class TraitUseBuilder extends \PhpParser\Builder\TraitUse +final class TraitUseBuilder extends TraitUse { } diff --git a/vendor/symplify/astral/src/ValueObject/NodeBuilder/UseBuilder.php b/vendor/symplify/astral/src/ValueObject/NodeBuilder/UseBuilder.php index f6e5287bdde..1fe77cc1067 100644 --- a/vendor/symplify/astral/src/ValueObject/NodeBuilder/UseBuilder.php +++ b/vendor/symplify/astral/src/ValueObject/NodeBuilder/UseBuilder.php @@ -10,12 +10,12 @@ use PhpParser\Node\Stmt\Use_ as UseStmt; * @api * Fixed duplicated naming in php-parser and prevents confusion */ -final class UseBuilder extends \PhpParser\Builder\Use_ +final class UseBuilder extends Use_ { /** * @param \PhpParser\Node\Name|string $name */ - public function __construct($name, int $type = \PhpParser\Node\Stmt\Use_::TYPE_NORMAL) + public function __construct($name, int $type = UseStmt::TYPE_NORMAL) { parent::__construct($name, $type); } diff --git a/vendor/symplify/autowire-array-parameter/composer.json b/vendor/symplify/autowire-array-parameter/composer.json index 3004a0bd595..407ebb62f2d 100644 --- a/vendor/symplify/autowire-array-parameter/composer.json +++ b/vendor/symplify/autowire-array-parameter/composer.json @@ -6,7 +6,7 @@ "php": ">=8.0", "nette\/utils": "^3.2", "symfony\/dependency-injection": "^6.0", - "symplify\/package-builder": "^10.2.10" + "symplify\/package-builder": "^10.2.11" }, "require-dev": { "phpunit\/phpunit": "^9.5" @@ -27,26 +27,26 @@ } }, "conflict": { - "symplify\/astral": "<10.2.10", - "symplify\/composer-json-manipulator": "<10.2.10", - "symplify\/easy-coding-standard": "<10.2.10", - "symplify\/phpstan-rules": "<10.2.10", - "symplify\/easy-testing": "<10.2.10", - "symplify\/rule-doc-generator-contracts": "<10.2.10", - "symplify\/php-config-printer": "<10.2.10", - "symplify\/phpstan-extensions": "<10.2.10", - "symplify\/rule-doc-generator": "<10.2.10", - "symplify\/vendor-patches": "<10.2.10", - "symplify\/skipper": "<10.2.10", - "symplify\/smart-file-system": "<10.2.10", - "symplify\/symfony-static-dumper": "<10.2.10", - "symplify\/symplify-kernel": "<10.2.10", - "symplify\/monorepo-builder": "<10.2.10", - "symplify\/config-transformer": "<10.2.10", - "symplify\/easy-ci": "<10.2.10", - "symplify\/coding-standard": "<10.2.10", - "symplify\/easy-parallel": "<10.2.10", - "symplify\/neon-config-dumper": "<10.2.10" + "symplify\/astral": "<10.2.11", + "symplify\/composer-json-manipulator": "<10.2.11", + "symplify\/easy-coding-standard": "<10.2.11", + "symplify\/phpstan-rules": "<10.2.11", + "symplify\/easy-testing": "<10.2.11", + "symplify\/rule-doc-generator-contracts": "<10.2.11", + "symplify\/php-config-printer": "<10.2.11", + "symplify\/phpstan-extensions": "<10.2.11", + "symplify\/rule-doc-generator": "<10.2.11", + "symplify\/vendor-patches": "<10.2.11", + "symplify\/skipper": "<10.2.11", + "symplify\/smart-file-system": "<10.2.11", + "symplify\/symfony-static-dumper": "<10.2.11", + "symplify\/symplify-kernel": "<10.2.11", + "symplify\/monorepo-builder": "<10.2.11", + "symplify\/config-transformer": "<10.2.11", + "symplify\/easy-ci": "<10.2.11", + "symplify\/coding-standard": "<10.2.11", + "symplify\/easy-parallel": "<10.2.11", + "symplify\/neon-config-dumper": "<10.2.11" }, "minimum-stability": "dev", "prefer-stable": true diff --git a/vendor/symplify/autowire-array-parameter/src/DependencyInjection/CompilerPass/AutowireArrayParameterCompilerPass.php b/vendor/symplify/autowire-array-parameter/src/DependencyInjection/CompilerPass/AutowireArrayParameterCompilerPass.php index 56bd4140dfb..014ed409ead 100644 --- a/vendor/symplify/autowire-array-parameter/src/DependencyInjection/CompilerPass/AutowireArrayParameterCompilerPass.php +++ b/vendor/symplify/autowire-array-parameter/src/DependencyInjection/CompilerPass/AutowireArrayParameterCompilerPass.php @@ -19,7 +19,7 @@ use RectorPrefix20220607\Symplify\PackageBuilder\ValueObject\MethodName; * @inspiration https://github.com/nette/di/pull/178 * @see \Symplify\AutowireArrayParameter\Tests\DependencyInjection\CompilerPass\AutowireArrayParameterCompilerPassTest */ -final class AutowireArrayParameterCompilerPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +final class AutowireArrayParameterCompilerPass implements CompilerPassInterface { /** * These namespaces are already configured by their bundles/extensions. @@ -51,12 +51,12 @@ final class AutowireArrayParameterCompilerPass implements \RectorPrefix20220607\ */ public function __construct(array $excludedFatalClasses = []) { - $this->definitionFinder = new \RectorPrefix20220607\Symplify\AutowireArrayParameter\DependencyInjection\DefinitionFinder(); - $paramTypeDocBlockResolver = new \RectorPrefix20220607\Symplify\AutowireArrayParameter\DocBlock\ParamTypeDocBlockResolver(); - $this->parameterTypeResolver = new \RectorPrefix20220607\Symplify\AutowireArrayParameter\TypeResolver\ParameterTypeResolver($paramTypeDocBlockResolver); - $this->parameterSkipper = new \RectorPrefix20220607\Symplify\AutowireArrayParameter\Skipper\ParameterSkipper($this->parameterTypeResolver, $excludedFatalClasses); + $this->definitionFinder = new DefinitionFinder(); + $paramTypeDocBlockResolver = new ParamTypeDocBlockResolver(); + $this->parameterTypeResolver = new ParameterTypeResolver($paramTypeDocBlockResolver); + $this->parameterSkipper = new ParameterSkipper($this->parameterTypeResolver, $excludedFatalClasses); } - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder) : void + public function process(ContainerBuilder $containerBuilder) : void { $definitions = $containerBuilder->getDefinitions(); foreach ($definitions as $definition) { @@ -70,7 +70,7 @@ final class AutowireArrayParameterCompilerPass implements \RectorPrefix20220607\ $this->processParameters($containerBuilder, $constructorReflectionMethod, $definition); } } - private function shouldSkipDefinition(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) : bool + private function shouldSkipDefinition(ContainerBuilder $containerBuilder, Definition $definition) : bool { if ($definition->isAbstract()) { return \true; @@ -83,7 +83,7 @@ final class AutowireArrayParameterCompilerPass implements \RectorPrefix20220607\ $resolvedClassName = $parameterBag->resolveValue($definition->getClass()); // skip 3rd party classes, they're autowired by own config $excludedNamespacePattern = '#^(' . \implode('|', self::EXCLUDED_NAMESPACES) . ')\\\\#'; - if (\RectorPrefix20220607\Nette\Utils\Strings::match($resolvedClassName, $excludedNamespacePattern)) { + if (Strings::match($resolvedClassName, $excludedNamespacePattern)) { return \true; } if (\in_array($resolvedClassName, $this->excludedFatalClasses, \true)) { @@ -96,17 +96,17 @@ final class AutowireArrayParameterCompilerPass implements \RectorPrefix20220607\ return \true; } $reflectionClass = $containerBuilder->getReflectionClass($definition->getClass()); - if (!$reflectionClass instanceof \ReflectionClass) { + if (!$reflectionClass instanceof ReflectionClass) { return \true; } - if (!$reflectionClass->hasMethod(\RectorPrefix20220607\Symplify\PackageBuilder\ValueObject\MethodName::CONSTRUCTOR)) { + if (!$reflectionClass->hasMethod(MethodName::CONSTRUCTOR)) { return \true; } /** @var ReflectionMethod $constructorReflectionMethod */ $constructorReflectionMethod = $reflectionClass->getConstructor(); return !$constructorReflectionMethod->getParameters(); } - private function processParameters(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder, \ReflectionMethod $reflectionMethod, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition) : void + private function processParameters(ContainerBuilder $containerBuilder, ReflectionMethod $reflectionMethod, Definition $definition) : void { $reflectionParameters = $reflectionMethod->getParameters(); foreach ($reflectionParameters as $reflectionParameter) { @@ -147,7 +147,7 @@ final class AutowireArrayParameterCompilerPass implements \RectorPrefix20220607\ $references = []; $definitionOfTypeNames = \array_keys($definitions); foreach ($definitionOfTypeNames as $definitionOfTypeName) { - $references[] = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Reference($definitionOfTypeName); + $references[] = new Reference($definitionOfTypeName); } return $references; } diff --git a/vendor/symplify/autowire-array-parameter/src/DependencyInjection/DefinitionFinder.php b/vendor/symplify/autowire-array-parameter/src/DependencyInjection/DefinitionFinder.php index 16008b37ded..76f25545801 100644 --- a/vendor/symplify/autowire-array-parameter/src/DependencyInjection/DefinitionFinder.php +++ b/vendor/symplify/autowire-array-parameter/src/DependencyInjection/DefinitionFinder.php @@ -16,7 +16,7 @@ final class DefinitionFinder /** * @return Definition[] */ - public function findAllByType(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder, string $type) : array + public function findAllByType(ContainerBuilder $containerBuilder, string $type) : array { $definitions = []; $containerBuilderDefinitions = $containerBuilder->getDefinitions(); @@ -31,15 +31,15 @@ final class DefinitionFinder } return $definitions; } - public function getByType(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder, string $type) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition + public function getByType(ContainerBuilder $containerBuilder, string $type) : Definition { $definition = $this->getByTypeIfExists($containerBuilder, $type); if ($definition !== null) { return $definition; } - throw new \RectorPrefix20220607\Symplify\AutowireArrayParameter\Exception\DependencyInjection\DefinitionForTypeNotFoundException(\sprintf('Definition for type "%s" was not found.', $type)); + throw new DefinitionForTypeNotFoundException(\sprintf('Definition for type "%s" was not found.', $type)); } - private function getByTypeIfExists(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder, string $type) : ?\RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition + private function getByTypeIfExists(ContainerBuilder $containerBuilder, string $type) : ?Definition { $containerBuilderDefinitions = $containerBuilder->getDefinitions(); foreach ($containerBuilderDefinitions as $name => $definition) { @@ -57,7 +57,7 @@ final class DefinitionFinder { try { return \class_exists($class); - } catch (\Throwable $exception) { + } catch (Throwable $exception) { return \false; } } diff --git a/vendor/symplify/autowire-array-parameter/src/DocBlock/ParamTypeDocBlockResolver.php b/vendor/symplify/autowire-array-parameter/src/DocBlock/ParamTypeDocBlockResolver.php index 12389abdd3a..82db07ee159 100644 --- a/vendor/symplify/autowire-array-parameter/src/DocBlock/ParamTypeDocBlockResolver.php +++ b/vendor/symplify/autowire-array-parameter/src/DocBlock/ParamTypeDocBlockResolver.php @@ -38,7 +38,7 @@ final class ParamTypeDocBlockResolver { foreach (self::ARRAY_REGEXES as $arrayRegexWithPlaceholder) { $arrayRegex = \str_replace(self::NAME_PLACEHOLDER, $parameterName, $arrayRegexWithPlaceholder); - $result = \RectorPrefix20220607\Nette\Utils\Strings::match($docBlock, $arrayRegex); + $result = Strings::match($docBlock, $arrayRegex); if (isset($result[self::TYPE_PART])) { return $result[self::TYPE_PART]; } diff --git a/vendor/symplify/autowire-array-parameter/src/Exception/DependencyInjection/DefinitionForTypeNotFoundException.php b/vendor/symplify/autowire-array-parameter/src/Exception/DependencyInjection/DefinitionForTypeNotFoundException.php index 53ba9a3c0ca..40eac4a9a85 100644 --- a/vendor/symplify/autowire-array-parameter/src/Exception/DependencyInjection/DefinitionForTypeNotFoundException.php +++ b/vendor/symplify/autowire-array-parameter/src/Exception/DependencyInjection/DefinitionForTypeNotFoundException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\AutowireArrayParameter\Exception\DependencyInjection; use Exception; -final class DefinitionForTypeNotFoundException extends \Exception +final class DefinitionForTypeNotFoundException extends Exception { } diff --git a/vendor/symplify/autowire-array-parameter/src/Skipper/ParameterSkipper.php b/vendor/symplify/autowire-array-parameter/src/Skipper/ParameterSkipper.php index 9632a88a355..1e3568d584c 100644 --- a/vendor/symplify/autowire-array-parameter/src/Skipper/ParameterSkipper.php +++ b/vendor/symplify/autowire-array-parameter/src/Skipper/ParameterSkipper.php @@ -27,12 +27,12 @@ final class ParameterSkipper /** * @param string[] $excludedFatalClasses */ - public function __construct(\RectorPrefix20220607\Symplify\AutowireArrayParameter\TypeResolver\ParameterTypeResolver $parameterTypeResolver, array $excludedFatalClasses) + public function __construct(ParameterTypeResolver $parameterTypeResolver, array $excludedFatalClasses) { $this->parameterTypeResolver = $parameterTypeResolver; $this->excludedFatalClasses = \array_merge(self::DEFAULT_EXCLUDED_FATAL_CLASSES, $excludedFatalClasses); } - public function shouldSkipParameter(\ReflectionMethod $reflectionMethod, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Definition $definition, \ReflectionParameter $reflectionParameter) : bool + public function shouldSkipParameter(ReflectionMethod $reflectionMethod, Definition $definition, ReflectionParameter $reflectionParameter) : bool { if (!$this->isArrayType($reflectionParameter)) { return \true; @@ -58,13 +58,13 @@ final class ParameterSkipper } return \is_a($definition->getClass(), $parameterType, \true); } - private function isArrayType(\ReflectionParameter $reflectionParameter) : bool + private function isArrayType(ReflectionParameter $reflectionParameter) : bool { if ($reflectionParameter->getType() === null) { return \false; } $reflectionParameterType = $reflectionParameter->getType(); - if (!$reflectionParameterType instanceof \ReflectionNamedType) { + if (!$reflectionParameterType instanceof ReflectionNamedType) { return \false; } return $reflectionParameterType->getName() === 'array'; diff --git a/vendor/symplify/autowire-array-parameter/src/TypeResolver/ParameterTypeResolver.php b/vendor/symplify/autowire-array-parameter/src/TypeResolver/ParameterTypeResolver.php index c2a3ee42b65..790b1a43f99 100644 --- a/vendor/symplify/autowire-array-parameter/src/TypeResolver/ParameterTypeResolver.php +++ b/vendor/symplify/autowire-array-parameter/src/TypeResolver/ParameterTypeResolver.php @@ -16,11 +16,11 @@ final class ParameterTypeResolver * @var \Symplify\AutowireArrayParameter\DocBlock\ParamTypeDocBlockResolver */ private $paramTypeDocBlockResolver; - public function __construct(\RectorPrefix20220607\Symplify\AutowireArrayParameter\DocBlock\ParamTypeDocBlockResolver $paramTypeDocBlockResolver) + public function __construct(ParamTypeDocBlockResolver $paramTypeDocBlockResolver) { $this->paramTypeDocBlockResolver = $paramTypeDocBlockResolver; } - public function resolveParameterType(string $parameterName, \ReflectionMethod $reflectionMethod) : ?string + public function resolveParameterType(string $parameterName, ReflectionMethod $reflectionMethod) : ?string { $docComment = $reflectionMethod->getDocComment(); if ($docComment === \false) { @@ -39,7 +39,7 @@ final class ParameterTypeResolver if (\ctype_lower($resolvedType[0])) { return null; } - $resolvedClass = \RectorPrefix20220607\Nette\Utils\Reflection::expandClassName($resolvedType, $declaringReflectionClass); + $resolvedClass = Reflection::expandClassName($resolvedType, $declaringReflectionClass); $this->resolvedParameterTypesCached[$uniqueKey] = $resolvedClass; return $resolvedClass; } diff --git a/vendor/symplify/composer-json-manipulator/composer.json b/vendor/symplify/composer-json-manipulator/composer.json index 80b649c47af..8897e8f0e27 100644 --- a/vendor/symplify/composer-json-manipulator/composer.json +++ b/vendor/symplify/composer-json-manipulator/composer.json @@ -9,9 +9,9 @@ "symfony\/config": "^6.0", "symfony\/dependency-injection": "^6.0", "symfony\/filesystem": "^6.0", - "symplify\/package-builder": "^10.2.10", - "symplify\/symplify-kernel": "^10.2.10", - "symplify\/smart-file-system": "^10.2.10" + "symplify\/package-builder": "^10.2.11", + "symplify\/symplify-kernel": "^10.2.11", + "symplify\/smart-file-system": "^10.2.11" }, "require-dev": { "phpunit\/phpunit": "^9.5" @@ -32,25 +32,25 @@ } }, "conflict": { - "symplify\/astral": "<10.2.10", - "symplify\/easy-coding-standard": "<10.2.10", - "symplify\/phpstan-rules": "<10.2.10", - "symplify\/easy-testing": "<10.2.10", - "symplify\/rule-doc-generator-contracts": "<10.2.10", - "symplify\/php-config-printer": "<10.2.10", - "symplify\/autowire-array-parameter": "<10.2.10", - "symplify\/phpstan-extensions": "<10.2.10", - "symplify\/rule-doc-generator": "<10.2.10", - "symplify\/vendor-patches": "<10.2.10", - "symplify\/skipper": "<10.2.10", - "symplify\/symfony-static-dumper": "<10.2.10", + "symplify\/astral": "<10.2.11", + "symplify\/easy-coding-standard": "<10.2.11", + "symplify\/phpstan-rules": "<10.2.11", + "symplify\/easy-testing": "<10.2.11", + "symplify\/rule-doc-generator-contracts": "<10.2.11", + "symplify\/php-config-printer": "<10.2.11", + "symplify\/autowire-array-parameter": "<10.2.11", + "symplify\/phpstan-extensions": "<10.2.11", + "symplify\/rule-doc-generator": "<10.2.11", + "symplify\/vendor-patches": "<10.2.11", + "symplify\/skipper": "<10.2.11", + "symplify\/symfony-static-dumper": "<10.2.11", "symplify\/symplify-kernel": "<9.4.70", - "symplify\/monorepo-builder": "<10.2.10", - "symplify\/config-transformer": "<10.2.10", - "symplify\/easy-ci": "<10.2.10", - "symplify\/coding-standard": "<10.2.10", - "symplify\/easy-parallel": "<10.2.10", - "symplify\/neon-config-dumper": "<10.2.10" + "symplify\/monorepo-builder": "<10.2.11", + "symplify\/config-transformer": "<10.2.11", + "symplify\/easy-ci": "<10.2.11", + "symplify\/coding-standard": "<10.2.11", + "symplify\/easy-parallel": "<10.2.11", + "symplify\/neon-config-dumper": "<10.2.11" }, "minimum-stability": "dev", "prefer-stable": true diff --git a/vendor/symplify/composer-json-manipulator/config/config.php b/vendor/symplify/composer-json-manipulator/config/config.php index 4e544e8bbb8..8a72f497fbf 100644 --- a/vendor/symplify/composer-json-manipulator/config/config.php +++ b/vendor/symplify/composer-json-manipulator/config/config.php @@ -4,22 +4,22 @@ declare (strict_types=1); namespace RectorPrefix20220607; use RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\Option; use RectorPrefix20220607\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory; use RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider; use RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller; use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem; use function RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service; -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +return static function (ContainerConfigurator $containerConfigurator) : void { $parameters = $containerConfigurator->parameters(); - $parameters->set(\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\Option::INLINE_SECTIONS, ['keywords']); + $parameters->set(Option::INLINE_SECTIONS, ['keywords']); $services = $containerConfigurator->services(); $services->defaults()->public()->autowire(); $services->load('RectorPrefix20220607\Symplify\\ComposerJsonManipulator\\', __DIR__ . '/../src'); - $services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem::class); - $services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller::class); - $services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider::class)->args([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service('service_container')]); - $services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory::class); - $services->set(\RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\RectorPrefix20220607\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory::class), 'create']); + $services->set(SmartFileSystem::class); + $services->set(PrivatesCaller::class); + $services->set(ParameterProvider::class)->args([service('service_container')]); + $services->set(SymfonyStyleFactory::class); + $services->set(SymfonyStyle::class)->factory([service(SymfonyStyleFactory::class), 'create']); }; diff --git a/vendor/symplify/composer-json-manipulator/src/ComposerJsonFactory.php b/vendor/symplify/composer-json-manipulator/src/ComposerJsonFactory.php index 702999b17c8..eafa13071de 100644 --- a/vendor/symplify/composer-json-manipulator/src/ComposerJsonFactory.php +++ b/vendor/symplify/composer-json-manipulator/src/ComposerJsonFactory.php @@ -7,7 +7,7 @@ use RectorPrefix20220607\Nette\Utils\Json; use RectorPrefix20220607\Symplify\ComposerJsonManipulator\FileSystem\JsonFileManager; use RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson; use RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; /** * @api * @see \Symplify\ComposerJsonManipulator\Tests\ComposerJsonFactory\ComposerJsonFactoryTest @@ -18,111 +18,111 @@ final class ComposerJsonFactory * @var \Symplify\ComposerJsonManipulator\FileSystem\JsonFileManager */ private $jsonFileManager; - public function __construct(\RectorPrefix20220607\Symplify\ComposerJsonManipulator\FileSystem\JsonFileManager $jsonFileManager) + public function __construct(JsonFileManager $jsonFileManager) { $this->jsonFileManager = $jsonFileManager; } - public function createFromString(string $jsonString) : \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson + public function createFromString(string $jsonString) : ComposerJson { - $jsonArray = \RectorPrefix20220607\Nette\Utils\Json::decode($jsonString, \RectorPrefix20220607\Nette\Utils\Json::FORCE_ARRAY); + $jsonArray = Json::decode($jsonString, Json::FORCE_ARRAY); return $this->createFromArray($jsonArray); } - public function createFromFileInfo(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson + public function createFromFileInfo(SmartFileInfo $smartFileInfo) : ComposerJson { $jsonArray = $this->jsonFileManager->loadFromFilePath($smartFileInfo->getRealPath()); $composerJson = $this->createFromArray($jsonArray); $composerJson->setOriginalFileInfo($smartFileInfo); return $composerJson; } - public function createFromFilePath(string $filePath) : \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson + public function createFromFilePath(string $filePath) : ComposerJson { $jsonArray = $this->jsonFileManager->loadFromFilePath($filePath); $composerJson = $this->createFromArray($jsonArray); - $fileInfo = new \Symplify\SmartFileSystem\SmartFileInfo($filePath); + $fileInfo = new SmartFileInfo($filePath); $composerJson->setOriginalFileInfo($fileInfo); return $composerJson; } - public function createEmpty() : \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson + public function createEmpty() : ComposerJson { - return new \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson(); + return new ComposerJson(); } /** * @param mixed[] $jsonArray */ - public function createFromArray(array $jsonArray) : \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson + public function createFromArray(array $jsonArray) : ComposerJson { - $composerJson = new \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson(); - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::CONFIG])) { - $composerJson->setConfig($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::CONFIG]); + $composerJson = new ComposerJson(); + if (isset($jsonArray[ComposerJsonSection::CONFIG])) { + $composerJson->setConfig($jsonArray[ComposerJsonSection::CONFIG]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::NAME])) { - $composerJson->setName($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::NAME]); + if (isset($jsonArray[ComposerJsonSection::NAME])) { + $composerJson->setName($jsonArray[ComposerJsonSection::NAME]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::TYPE])) { - $composerJson->setType($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::TYPE]); + if (isset($jsonArray[ComposerJsonSection::TYPE])) { + $composerJson->setType($jsonArray[ComposerJsonSection::TYPE]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::AUTHORS])) { - $composerJson->setAuthors($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::AUTHORS]); + if (isset($jsonArray[ComposerJsonSection::AUTHORS])) { + $composerJson->setAuthors($jsonArray[ComposerJsonSection::AUTHORS]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::DESCRIPTION])) { - $composerJson->setDescription($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::DESCRIPTION]); + if (isset($jsonArray[ComposerJsonSection::DESCRIPTION])) { + $composerJson->setDescription($jsonArray[ComposerJsonSection::DESCRIPTION]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::KEYWORDS])) { - $composerJson->setKeywords($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::KEYWORDS]); + if (isset($jsonArray[ComposerJsonSection::KEYWORDS])) { + $composerJson->setKeywords($jsonArray[ComposerJsonSection::KEYWORDS]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::HOMEPAGE])) { - $composerJson->setHomepage($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::HOMEPAGE]); + if (isset($jsonArray[ComposerJsonSection::HOMEPAGE])) { + $composerJson->setHomepage($jsonArray[ComposerJsonSection::HOMEPAGE]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::LICENSE])) { - $composerJson->setLicense($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::LICENSE]); + if (isset($jsonArray[ComposerJsonSection::LICENSE])) { + $composerJson->setLicense($jsonArray[ComposerJsonSection::LICENSE]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::BIN])) { - $composerJson->setBin($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::BIN]); + if (isset($jsonArray[ComposerJsonSection::BIN])) { + $composerJson->setBin($jsonArray[ComposerJsonSection::BIN]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::REQUIRE])) { - $composerJson->setRequire($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::REQUIRE]); + if (isset($jsonArray[ComposerJsonSection::REQUIRE])) { + $composerJson->setRequire($jsonArray[ComposerJsonSection::REQUIRE]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::REQUIRE_DEV])) { - $composerJson->setRequireDev($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::REQUIRE_DEV]); + if (isset($jsonArray[ComposerJsonSection::REQUIRE_DEV])) { + $composerJson->setRequireDev($jsonArray[ComposerJsonSection::REQUIRE_DEV]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::AUTOLOAD])) { - $composerJson->setAutoload($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::AUTOLOAD]); + if (isset($jsonArray[ComposerJsonSection::AUTOLOAD])) { + $composerJson->setAutoload($jsonArray[ComposerJsonSection::AUTOLOAD]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::AUTOLOAD_DEV])) { - $composerJson->setAutoloadDev($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::AUTOLOAD_DEV]); + if (isset($jsonArray[ComposerJsonSection::AUTOLOAD_DEV])) { + $composerJson->setAutoloadDev($jsonArray[ComposerJsonSection::AUTOLOAD_DEV]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::REPLACE])) { - $composerJson->setReplace($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::REPLACE]); + if (isset($jsonArray[ComposerJsonSection::REPLACE])) { + $composerJson->setReplace($jsonArray[ComposerJsonSection::REPLACE]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::EXTRA])) { - $composerJson->setExtra($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::EXTRA]); + if (isset($jsonArray[ComposerJsonSection::EXTRA])) { + $composerJson->setExtra($jsonArray[ComposerJsonSection::EXTRA]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::SCRIPTS])) { - $composerJson->setScripts($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::SCRIPTS]); + if (isset($jsonArray[ComposerJsonSection::SCRIPTS])) { + $composerJson->setScripts($jsonArray[ComposerJsonSection::SCRIPTS]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::SCRIPTS_DESCRIPTIONS])) { - $composerJson->setScriptsDescriptions($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::SCRIPTS_DESCRIPTIONS]); + if (isset($jsonArray[ComposerJsonSection::SCRIPTS_DESCRIPTIONS])) { + $composerJson->setScriptsDescriptions($jsonArray[ComposerJsonSection::SCRIPTS_DESCRIPTIONS]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::SUGGEST])) { - $composerJson->setSuggest($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::SUGGEST]); + if (isset($jsonArray[ComposerJsonSection::SUGGEST])) { + $composerJson->setSuggest($jsonArray[ComposerJsonSection::SUGGEST]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::MINIMUM_STABILITY])) { - $composerJson->setMinimumStability($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::MINIMUM_STABILITY]); + if (isset($jsonArray[ComposerJsonSection::MINIMUM_STABILITY])) { + $composerJson->setMinimumStability($jsonArray[ComposerJsonSection::MINIMUM_STABILITY]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::PREFER_STABLE])) { - $composerJson->setPreferStable($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::PREFER_STABLE]); + if (isset($jsonArray[ComposerJsonSection::PREFER_STABLE])) { + $composerJson->setPreferStable($jsonArray[ComposerJsonSection::PREFER_STABLE]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::CONFLICT])) { - $composerJson->setConflicts($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::CONFLICT]); + if (isset($jsonArray[ComposerJsonSection::CONFLICT])) { + $composerJson->setConflicts($jsonArray[ComposerJsonSection::CONFLICT]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::REPOSITORIES])) { - $composerJson->setRepositories($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::REPOSITORIES]); + if (isset($jsonArray[ComposerJsonSection::REPOSITORIES])) { + $composerJson->setRepositories($jsonArray[ComposerJsonSection::REPOSITORIES]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::VERSION])) { - $composerJson->setVersion($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::VERSION]); + if (isset($jsonArray[ComposerJsonSection::VERSION])) { + $composerJson->setVersion($jsonArray[ComposerJsonSection::VERSION]); } - if (isset($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::PROVIDE])) { - $composerJson->setProvide($jsonArray[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::PROVIDE]); + if (isset($jsonArray[ComposerJsonSection::PROVIDE])) { + $composerJson->setProvide($jsonArray[ComposerJsonSection::PROVIDE]); } $orderedKeys = \array_keys($jsonArray); $composerJson->setOrderedKeys($orderedKeys); diff --git a/vendor/symplify/composer-json-manipulator/src/FileSystem/JsonFileManager.php b/vendor/symplify/composer-json-manipulator/src/FileSystem/JsonFileManager.php index 2e7f3b96eb8..a3fa76b29f0 100644 --- a/vendor/symplify/composer-json-manipulator/src/FileSystem/JsonFileManager.php +++ b/vendor/symplify/composer-json-manipulator/src/FileSystem/JsonFileManager.php @@ -8,7 +8,7 @@ use RectorPrefix20220607\Symplify\ComposerJsonManipulator\Json\JsonCleaner; use RectorPrefix20220607\Symplify\ComposerJsonManipulator\Json\JsonInliner; use RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson; use RectorPrefix20220607\Symplify\PackageBuilder\Configuration\StaticEolConfiguration; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem; /** * @see \Symplify\MonorepoBuilder\Tests\FileSystem\JsonFileManager\JsonFileManagerTest @@ -31,7 +31,7 @@ final class JsonFileManager * @var \Symplify\ComposerJsonManipulator\Json\JsonInliner */ private $jsonInliner; - public function __construct(\RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\Json\JsonCleaner $jsonCleaner, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\Json\JsonInliner $jsonInliner) + public function __construct(SmartFileSystem $smartFileSystem, JsonCleaner $jsonCleaner, JsonInliner $jsonInliner) { $this->smartFileSystem = $smartFileSystem; $this->jsonCleaner = $jsonCleaner; @@ -40,11 +40,11 @@ final class JsonFileManager /** * @return mixed[] */ - public function loadFromFileInfo(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : array + public function loadFromFileInfo(SmartFileInfo $smartFileInfo) : array { $realPath = $smartFileInfo->getRealPath(); if (!isset($this->cachedJSONFiles[$realPath])) { - $this->cachedJSONFiles[$realPath] = \RectorPrefix20220607\Nette\Utils\Json::decode($smartFileInfo->getContents(), \RectorPrefix20220607\Nette\Utils\Json::FORCE_ARRAY); + $this->cachedJSONFiles[$realPath] = Json::decode($smartFileInfo->getContents(), Json::FORCE_ARRAY); } return $this->cachedJSONFiles[$realPath]; } @@ -54,12 +54,12 @@ final class JsonFileManager public function loadFromFilePath(string $filePath) : array { $fileContent = $this->smartFileSystem->readFile($filePath); - return \RectorPrefix20220607\Nette\Utils\Json::decode($fileContent, \RectorPrefix20220607\Nette\Utils\Json::FORCE_ARRAY); + return Json::decode($fileContent, Json::FORCE_ARRAY); } /** * @param mixed[] $json */ - public function printJsonToFileInfo(array $json, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : string + public function printJsonToFileInfo(array $json, SmartFileInfo $smartFileInfo) : string { $jsonString = $this->encodeJsonToFileContent($json); $this->smartFileSystem->dumpFile($smartFileInfo->getPathname(), $jsonString); @@ -67,7 +67,7 @@ final class JsonFileManager unset($this->cachedJSONFiles[$realPath]); return $jsonString; } - public function printComposerJsonToFilePath(\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson $composerJson, string $filePath) : string + public function printComposerJsonToFilePath(ComposerJson $composerJson, string $filePath) : string { $jsonString = $this->encodeJsonToFileContent($composerJson->getJsonArray()); $this->smartFileSystem->dumpFile($filePath, $jsonString); @@ -80,7 +80,7 @@ final class JsonFileManager { // Empty arrays may lead to bad encoding since we can't be sure whether they need to be arrays or objects. $json = $this->jsonCleaner->removeEmptyKeysFromJsonArray($json); - $jsonContent = \RectorPrefix20220607\Nette\Utils\Json::encode($json, \RectorPrefix20220607\Nette\Utils\Json::PRETTY) . \RectorPrefix20220607\Symplify\PackageBuilder\Configuration\StaticEolConfiguration::getEolChar(); + $jsonContent = Json::encode($json, Json::PRETTY) . StaticEolConfiguration::getEolChar(); return $this->jsonInliner->inlineSections($jsonContent); } } diff --git a/vendor/symplify/composer-json-manipulator/src/Json/JsonInliner.php b/vendor/symplify/composer-json-manipulator/src/Json/JsonInliner.php index 1595a895d20..d8e3cc6d93b 100644 --- a/vendor/symplify/composer-json-manipulator/src/Json/JsonInliner.php +++ b/vendor/symplify/composer-json-manipulator/src/Json/JsonInliner.php @@ -17,20 +17,20 @@ final class JsonInliner * @var \Symplify\PackageBuilder\Parameter\ParameterProvider */ private $parameterProvider; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider) + public function __construct(ParameterProvider $parameterProvider) { $this->parameterProvider = $parameterProvider; } public function inlineSections(string $jsonContent) : string { - if (!$this->parameterProvider->hasParameter(\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\Option::INLINE_SECTIONS)) { + if (!$this->parameterProvider->hasParameter(Option::INLINE_SECTIONS)) { return $jsonContent; } - $inlineSections = $this->parameterProvider->provideArrayParameter(\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\Option::INLINE_SECTIONS); + $inlineSections = $this->parameterProvider->provideArrayParameter(Option::INLINE_SECTIONS); foreach ($inlineSections as $inlineSection) { $pattern = '#("' . \preg_quote($inlineSection, '#') . '": )\\[(.*?)\\](,)#ms'; - $jsonContent = \RectorPrefix20220607\Nette\Utils\Strings::replace($jsonContent, $pattern, function (array $match) : string { - $inlined = \RectorPrefix20220607\Nette\Utils\Strings::replace($match[2], self::SPACE_REGEX, ' '); + $jsonContent = Strings::replace($jsonContent, $pattern, function (array $match) : string { + $inlined = Strings::replace($match[2], self::SPACE_REGEX, ' '); $inlined = \trim($inlined); $inlined = '[' . $inlined . ']'; return $match[1] . $inlined . $match[3]; diff --git a/vendor/symplify/composer-json-manipulator/src/Printer/ComposerJsonPrinter.php b/vendor/symplify/composer-json-manipulator/src/Printer/ComposerJsonPrinter.php index 86444a2af14..832f132d330 100644 --- a/vendor/symplify/composer-json-manipulator/src/Printer/ComposerJsonPrinter.php +++ b/vendor/symplify/composer-json-manipulator/src/Printer/ComposerJsonPrinter.php @@ -5,7 +5,7 @@ namespace RectorPrefix20220607\Symplify\ComposerJsonManipulator\Printer; use RectorPrefix20220607\Symplify\ComposerJsonManipulator\FileSystem\JsonFileManager; use RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; /** * @api */ @@ -15,18 +15,18 @@ final class ComposerJsonPrinter * @var \Symplify\ComposerJsonManipulator\FileSystem\JsonFileManager */ private $jsonFileManager; - public function __construct(\RectorPrefix20220607\Symplify\ComposerJsonManipulator\FileSystem\JsonFileManager $jsonFileManager) + public function __construct(JsonFileManager $jsonFileManager) { $this->jsonFileManager = $jsonFileManager; } - public function printToString(\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson $composerJson) : string + public function printToString(ComposerJson $composerJson) : string { return $this->jsonFileManager->encodeJsonToFileContent($composerJson->getJsonArray()); } /** * @param string|\Symplify\SmartFileSystem\SmartFileInfo $targetFile */ - public function print(\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJson $composerJson, $targetFile) : string + public function print(ComposerJson $composerJson, $targetFile) : string { if (\is_string($targetFile)) { return $this->jsonFileManager->printComposerJsonToFilePath($composerJson, $targetFile); diff --git a/vendor/symplify/composer-json-manipulator/src/Sorter/ComposerPackageSorter.php b/vendor/symplify/composer-json-manipulator/src/Sorter/ComposerPackageSorter.php index e7f5ecffbaa..973ab2fa709 100644 --- a/vendor/symplify/composer-json-manipulator/src/Sorter/ComposerPackageSorter.php +++ b/vendor/symplify/composer-json-manipulator/src/Sorter/ComposerPackageSorter.php @@ -39,7 +39,7 @@ final class ComposerPackageSorter private function createNameWithPriority(string $requirementName) : string { if ($this->isPlatformPackage($requirementName)) { - return \RectorPrefix20220607\Nette\Utils\Strings::replace($requirementName, self::REQUIREMENT_TYPE_REGEX, function (array $match) : string { + return Strings::replace($requirementName, self::REQUIREMENT_TYPE_REGEX, function (array $match) : string { $name = $match['name']; if ($name === 'php') { return '0-' . $name; @@ -60,6 +60,6 @@ final class ComposerPackageSorter } private function isPlatformPackage(string $name) : bool { - return (bool) \RectorPrefix20220607\Nette\Utils\Strings::match($name, self::PLATFORM_PACKAGE_REGEX); + return (bool) Strings::match($name, self::PLATFORM_PACKAGE_REGEX); } } diff --git a/vendor/symplify/composer-json-manipulator/src/ValueObject/ComposerJson.php b/vendor/symplify/composer-json-manipulator/src/ValueObject/ComposerJson.php index 8790297e3cb..ec498a657ac 100644 --- a/vendor/symplify/composer-json-manipulator/src/ValueObject/ComposerJson.php +++ b/vendor/symplify/composer-json-manipulator/src/ValueObject/ComposerJson.php @@ -6,7 +6,7 @@ namespace RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject; use RectorPrefix20220607\Nette\Utils\Arrays; use RectorPrefix20220607\Nette\Utils\Strings; use RectorPrefix20220607\Symplify\ComposerJsonManipulator\Sorter\ComposerPackageSorter; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; use RectorPrefix20220607\Symplify\SymplifyKernel\Exception\ShouldNotHappenException; /** * @api @@ -132,9 +132,9 @@ final class ComposerJson private $provide = []; public function __construct() { - $this->composerPackageSorter = new \RectorPrefix20220607\Symplify\ComposerJsonManipulator\Sorter\ComposerPackageSorter(); + $this->composerPackageSorter = new ComposerPackageSorter(); } - public function setOriginalFileInfo(\Symplify\SmartFileSystem\SmartFileInfo $fileInfo) : void + public function setOriginalFileInfo(SmartFileInfo $fileInfo) : void { $this->fileInfo = $fileInfo; } @@ -213,7 +213,7 @@ final class ComposerJson public function getAbsoluteAutoloadDirectories() : array { if ($this->fileInfo === null) { - throw new \RectorPrefix20220607\Symplify\SymplifyKernel\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $autoloadDirectories = $this->getAutoloadDirectories(); $absoluteAutoloadDirectories = []; @@ -316,7 +316,7 @@ final class ComposerJson if ($this->name === null) { return null; } - return \RectorPrefix20220607\Nette\Utils\Strings::after($this->name, '/', -1); + return Strings::after($this->name, '/', -1); } /** * @return array @@ -346,14 +346,14 @@ final class ComposerJson */ public function getJsonArray() : array { - $array = \array_filter([\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::NAME => $this->name, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::DESCRIPTION => $this->description, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::KEYWORDS => $this->keywords, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::HOMEPAGE => $this->homepage, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::LICENSE => $this->license, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::AUTHORS => $this->authors, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::TYPE => $this->type, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::REQUIRE => $this->require, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::REQUIRE_DEV => $this->requireDev, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::AUTOLOAD => $this->autoload, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::AUTOLOAD_DEV => $this->autoloadDev, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::REPOSITORIES => $this->repositories, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::EXTRA => $this->extra, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::BIN => $this->bin, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::SCRIPTS => $this->scripts, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::SCRIPTS_DESCRIPTIONS => $this->scriptsDescriptions, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::SUGGEST => $this->suggest, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::CONFIG => $this->config, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::REPLACE => $this->replace, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::CONFLICT => $this->conflicts, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::PROVIDE => $this->provide, \RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::VERSION => $this->version]); + $array = \array_filter([ComposerJsonSection::NAME => $this->name, ComposerJsonSection::DESCRIPTION => $this->description, ComposerJsonSection::KEYWORDS => $this->keywords, ComposerJsonSection::HOMEPAGE => $this->homepage, ComposerJsonSection::LICENSE => $this->license, ComposerJsonSection::AUTHORS => $this->authors, ComposerJsonSection::TYPE => $this->type, ComposerJsonSection::REQUIRE => $this->require, ComposerJsonSection::REQUIRE_DEV => $this->requireDev, ComposerJsonSection::AUTOLOAD => $this->autoload, ComposerJsonSection::AUTOLOAD_DEV => $this->autoloadDev, ComposerJsonSection::REPOSITORIES => $this->repositories, ComposerJsonSection::EXTRA => $this->extra, ComposerJsonSection::BIN => $this->bin, ComposerJsonSection::SCRIPTS => $this->scripts, ComposerJsonSection::SCRIPTS_DESCRIPTIONS => $this->scriptsDescriptions, ComposerJsonSection::SUGGEST => $this->suggest, ComposerJsonSection::CONFIG => $this->config, ComposerJsonSection::REPLACE => $this->replace, ComposerJsonSection::CONFLICT => $this->conflicts, ComposerJsonSection::PROVIDE => $this->provide, ComposerJsonSection::VERSION => $this->version]); if ($this->minimumStability !== null) { - $array[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::MINIMUM_STABILITY] = $this->minimumStability; - $this->moveValueToBack(\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::MINIMUM_STABILITY); + $array[ComposerJsonSection::MINIMUM_STABILITY] = $this->minimumStability; + $this->moveValueToBack(ComposerJsonSection::MINIMUM_STABILITY); } if ($this->preferStable !== null) { - $array[\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::PREFER_STABLE] = $this->preferStable; - $this->moveValueToBack(\RectorPrefix20220607\Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection::PREFER_STABLE); + $array[ComposerJsonSection::PREFER_STABLE] = $this->preferStable; + $this->moveValueToBack(ComposerJsonSection::PREFER_STABLE); } return $this->sortItemsByOrderedListOfKeys($array, $this->orderedKeys); } @@ -507,7 +507,7 @@ final class ComposerJson $this->addRequiredDevPackage($newPackageName, $targetVersion); } } - public function getFileInfo() : ?\Symplify\SmartFileSystem\SmartFileInfo + public function getFileInfo() : ?SmartFileInfo { return $this->fileInfo; } @@ -591,7 +591,7 @@ final class ComposerJson public function getAutoloadDirectories() : array { $autoloadDirectories = \array_merge($this->getPsr4AndClassmapDirectories(), $this->getPsr4AndClassmapDevDirectories()); - return \RectorPrefix20220607\Nette\Utils\Arrays::flatten($autoloadDirectories); + return Arrays::flatten($autoloadDirectories); } /** * @return string[] @@ -694,7 +694,7 @@ final class ComposerJson private function resolveExistingAutoloadDirectory(string $autoloadDirectory) : string { if ($this->fileInfo === null) { - throw new \RectorPrefix20220607\Symplify\SymplifyKernel\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $filePathCandidates = [ $this->fileInfo->getPath() . \DIRECTORY_SEPARATOR . $autoloadDirectory, diff --git a/vendor/symplify/easy-parallel/composer.json b/vendor/symplify/easy-parallel/composer.json index 0f79f2c88d0..d9fc9c07b5e 100644 --- a/vendor/symplify/easy-parallel/composer.json +++ b/vendor/symplify/easy-parallel/composer.json @@ -9,7 +9,7 @@ "react\/event-loop": "^1.3", "react\/socket": "^1.11", "symfony\/console": "^6.0", - "symplify\/package-builder": "^10.2.10" + "symplify\/package-builder": "^10.2.11" }, "require-dev": { "phpunit\/phpunit": "^9.5" @@ -33,26 +33,26 @@ "platform-check": false }, "conflict": { - "symplify\/astral": "<10.2.10", - "symplify\/easy-coding-standard": "<10.2.10", - "symplify\/phpstan-rules": "<10.2.10", - "symplify\/easy-testing": "<10.2.10", - "symplify\/rule-doc-generator-contracts": "<10.2.10", - "symplify\/php-config-printer": "<10.2.10", - "symplify\/autowire-array-parameter": "<10.2.10", - "symplify\/phpstan-extensions": "<10.2.10", - "symplify\/rule-doc-generator": "<10.2.10", - "symplify\/vendor-patches": "<10.2.10", - "symplify\/skipper": "<10.2.10", - "symplify\/symfony-static-dumper": "<10.2.10", - "symplify\/config-transformer": "<10.2.10", - "symplify\/easy-ci": "<10.2.10", - "symplify\/coding-standard": "<10.2.10", - "symplify\/composer-json-manipulator": "<10.2.10", - "symplify\/smart-file-system": "<10.2.10", - "symplify\/monorepo-builder": "<10.2.10", - "symplify\/symplify-kernel": "<10.2.10", - "symplify\/neon-config-dumper": "<10.2.10" + "symplify\/astral": "<10.2.11", + "symplify\/easy-coding-standard": "<10.2.11", + "symplify\/phpstan-rules": "<10.2.11", + "symplify\/easy-testing": "<10.2.11", + "symplify\/rule-doc-generator-contracts": "<10.2.11", + "symplify\/php-config-printer": "<10.2.11", + "symplify\/autowire-array-parameter": "<10.2.11", + "symplify\/phpstan-extensions": "<10.2.11", + "symplify\/rule-doc-generator": "<10.2.11", + "symplify\/vendor-patches": "<10.2.11", + "symplify\/skipper": "<10.2.11", + "symplify\/symfony-static-dumper": "<10.2.11", + "symplify\/config-transformer": "<10.2.11", + "symplify\/easy-ci": "<10.2.11", + "symplify\/coding-standard": "<10.2.11", + "symplify\/composer-json-manipulator": "<10.2.11", + "symplify\/smart-file-system": "<10.2.11", + "symplify\/monorepo-builder": "<10.2.11", + "symplify\/symplify-kernel": "<10.2.11", + "symplify\/neon-config-dumper": "<10.2.11" }, "minimum-stability": "dev", "prefer-stable": true diff --git a/vendor/symplify/easy-parallel/config/config.php b/vendor/symplify/easy-parallel/config/config.php index 70cdaeafee3..ddd439dd47d 100644 --- a/vendor/symplify/easy-parallel/config/config.php +++ b/vendor/symplify/easy-parallel/config/config.php @@ -3,8 +3,8 @@ declare (strict_types=1); namespace RectorPrefix20220607; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +return static function (ContainerConfigurator $containerConfigurator) : void { $services = $containerConfigurator->services(); $services->defaults()->public()->autowire(); $services->load('RectorPrefix20220607\Symplify\\EasyParallel\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/ValueObject']); diff --git a/vendor/symplify/easy-parallel/src/CommandLine/WorkerCommandLineFactory.php b/vendor/symplify/easy-parallel/src/CommandLine/WorkerCommandLineFactory.php index 3ca08be889d..c3d49f02161 100644 --- a/vendor/symplify/easy-parallel/src/CommandLine/WorkerCommandLineFactory.php +++ b/vendor/symplify/easy-parallel/src/CommandLine/WorkerCommandLineFactory.php @@ -28,19 +28,19 @@ final class WorkerCommandLineFactory private $commandFromReflectionFactory; public function __construct() { - $this->commandFromReflectionFactory = new \RectorPrefix20220607\Symplify\EasyParallel\Reflection\CommandFromReflectionFactory(); + $this->commandFromReflectionFactory = new CommandFromReflectionFactory(); } /** * @param class-string $mainCommandClass */ - public function create(string $baseScript, string $mainCommandClass, string $workerCommandName, string $pathsOptionName, ?string $projectConfigFile, \RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, string $identifier, int $port) : string + public function create(string $baseScript, string $mainCommandClass, string $workerCommandName, string $pathsOptionName, ?string $projectConfigFile, InputInterface $input, string $identifier, int $port) : string { $commandArguments = \array_slice($_SERVER['argv'], 1); $args = \array_merge([\PHP_BINARY, $baseScript], $commandArguments); $mainCommand = $this->commandFromReflectionFactory->create($mainCommandClass); if ($mainCommand->getName() === null) { $errorMessage = \sprintf('The command name for "%s" is missing', \get_class($mainCommand)); - throw new \RectorPrefix20220607\Symplify\EasyParallel\Exception\ParallelShouldNotHappenException($errorMessage); + throw new ParallelShouldNotHappenException($errorMessage); } $mainCommandName = $mainCommand->getName(); $processCommandArray = []; @@ -80,7 +80,7 @@ final class WorkerCommandLineFactory /** * @return string[] */ - private function getCommandOptionNames(\RectorPrefix20220607\Symfony\Component\Console\Command\Command $command) : array + private function getCommandOptionNames(Command $command) : array { $inputDefinition = $command->getDefinition(); $optionNames = []; @@ -95,7 +95,7 @@ final class WorkerCommandLineFactory * @param string[] $mainCommandOptionNames * @return string[] */ - private function mirrorCommandOptions(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, array $mainCommandOptionNames) : array + private function mirrorCommandOptions(InputInterface $input, array $mainCommandOptionNames) : array { $processCommandOptions = []; foreach ($mainCommandOptionNames as $mainCommandOptionName) { @@ -124,7 +124,7 @@ final class WorkerCommandLineFactory } return $processCommandOptions; } - private function shouldSkipOption(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, string $optionName) : bool + private function shouldSkipOption(InputInterface $input, string $optionName) : bool { if (!$input->hasOption($optionName)) { return \true; diff --git a/vendor/symplify/easy-parallel/src/Contract/SerializableInterface.php b/vendor/symplify/easy-parallel/src/Contract/SerializableInterface.php index 6c3070be105..53e180e18cc 100644 --- a/vendor/symplify/easy-parallel/src/Contract/SerializableInterface.php +++ b/vendor/symplify/easy-parallel/src/Contract/SerializableInterface.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\EasyParallel\Contract; use JsonSerializable; -interface SerializableInterface extends \JsonSerializable +interface SerializableInterface extends JsonSerializable { /** * @param array $json diff --git a/vendor/symplify/easy-parallel/src/CpuCoreCountProvider.php b/vendor/symplify/easy-parallel/src/CpuCoreCountProvider.php index b1972ea2933..4d0f4908abd 100644 --- a/vendor/symplify/easy-parallel/src/CpuCoreCountProvider.php +++ b/vendor/symplify/easy-parallel/src/CpuCoreCountProvider.php @@ -56,7 +56,7 @@ final class CpuCoreCountProvider if ($cpuinfo === \false) { return null; } - $matches = \RectorPrefix20220607\Nette\Utils\Strings::matchAll($cpuinfo, self::PROCESSOR_REGEX); + $matches = Strings::matchAll($cpuinfo, self::PROCESSOR_REGEX); if ($matches === []) { return 0; } diff --git a/vendor/symplify/easy-parallel/src/Exception/ParallelShouldNotHappenException.php b/vendor/symplify/easy-parallel/src/Exception/ParallelShouldNotHappenException.php index 2b1935bd134..24dd1a74df0 100644 --- a/vendor/symplify/easy-parallel/src/Exception/ParallelShouldNotHappenException.php +++ b/vendor/symplify/easy-parallel/src/Exception/ParallelShouldNotHappenException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\EasyParallel\Exception; use Exception; -final class ParallelShouldNotHappenException extends \Exception +final class ParallelShouldNotHappenException extends Exception { } diff --git a/vendor/symplify/easy-parallel/src/FileSystem/FilePathNormalizer.php b/vendor/symplify/easy-parallel/src/FileSystem/FilePathNormalizer.php index eff4a8a6d4d..4e377ff6fb9 100644 --- a/vendor/symplify/easy-parallel/src/FileSystem/FilePathNormalizer.php +++ b/vendor/symplify/easy-parallel/src/FileSystem/FilePathNormalizer.php @@ -3,7 +3,7 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\EasyParallel\FileSystem; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class FilePathNormalizer { /** diff --git a/vendor/symplify/easy-parallel/src/Reflection/CommandFromReflectionFactory.php b/vendor/symplify/easy-parallel/src/Reflection/CommandFromReflectionFactory.php index 36e0f0c2b45..a6abd7b1acd 100644 --- a/vendor/symplify/easy-parallel/src/Reflection/CommandFromReflectionFactory.php +++ b/vendor/symplify/easy-parallel/src/Reflection/CommandFromReflectionFactory.php @@ -12,17 +12,17 @@ final class CommandFromReflectionFactory /** * @param class-string $className */ - public function create(string $className) : \RectorPrefix20220607\Symfony\Component\Console\Command\Command + public function create(string $className) : Command { - $commandReflectionClass = new \ReflectionClass($className); + $commandReflectionClass = new ReflectionClass($className); $command = $commandReflectionClass->newInstanceWithoutConstructor(); $parentClassReflection = $commandReflectionClass->getParentClass(); - if (!$parentClassReflection instanceof \ReflectionClass) { - throw new \RectorPrefix20220607\Symplify\EasyParallel\Exception\ParallelShouldNotHappenException(); + if (!$parentClassReflection instanceof ReflectionClass) { + throw new ParallelShouldNotHappenException(); } $parentConstructorReflectionMethod = $parentClassReflection->getConstructor(); - if (!$parentConstructorReflectionMethod instanceof \ReflectionMethod) { - throw new \RectorPrefix20220607\Symplify\EasyParallel\Exception\ParallelShouldNotHappenException(); + if (!$parentConstructorReflectionMethod instanceof ReflectionMethod) { + throw new ParallelShouldNotHappenException(); } $parentConstructorReflectionMethod->invoke($command); return $command; diff --git a/vendor/symplify/easy-parallel/src/ScheduleFactory.php b/vendor/symplify/easy-parallel/src/ScheduleFactory.php index 51ad1baee50..c55834eceee 100644 --- a/vendor/symplify/easy-parallel/src/ScheduleFactory.php +++ b/vendor/symplify/easy-parallel/src/ScheduleFactory.php @@ -13,11 +13,11 @@ final class ScheduleFactory /** * @param array $files */ - public function create(int $cpuCores, int $jobSize, int $maxNumberOfProcesses, array $files) : \RectorPrefix20220607\Symplify\EasyParallel\ValueObject\Schedule + public function create(int $cpuCores, int $jobSize, int $maxNumberOfProcesses, array $files) : Schedule { $jobs = \array_chunk($files, $jobSize); $numberOfProcesses = \min(\count($jobs), $cpuCores); $numberOfProcesses = \min($maxNumberOfProcesses, $numberOfProcesses); - return new \RectorPrefix20220607\Symplify\EasyParallel\ValueObject\Schedule($numberOfProcesses, $jobs); + return new Schedule($numberOfProcesses, $jobs); } } diff --git a/vendor/symplify/easy-parallel/src/ValueObject/ParallelProcess.php b/vendor/symplify/easy-parallel/src/ValueObject/ParallelProcess.php index 92eb4f3f77d..68f2190b291 100644 --- a/vendor/symplify/easy-parallel/src/ValueObject/ParallelProcess.php +++ b/vendor/symplify/easy-parallel/src/ValueObject/ParallelProcess.php @@ -56,7 +56,7 @@ final class ParallelProcess * @var int */ private $timetoutInSeconds; - public function __construct(string $command, \RectorPrefix20220607\React\EventLoop\LoopInterface $loop, int $timetoutInSeconds) + public function __construct(string $command, LoopInterface $loop, int $timetoutInSeconds) { $this->command = $command; $this->loop = $loop; @@ -71,16 +71,16 @@ final class ParallelProcess { $tmp = \tmpfile(); if ($tmp === \false) { - throw new \RectorPrefix20220607\Symplify\EasyParallel\Exception\ParallelShouldNotHappenException('Failed creating temp file.'); + throw new ParallelShouldNotHappenException('Failed creating temp file.'); } $this->stdErr = $tmp; - $this->process = new \RectorPrefix20220607\React\ChildProcess\Process($this->command, null, null, [2 => $this->stdErr]); + $this->process = new Process($this->command, null, null, [2 => $this->stdErr]); $this->process->start($this->loop); $this->onData = $onData; $this->onError = $onError; - $this->process->on(\RectorPrefix20220607\Symplify\EasyParallel\Enum\ReactEvent::EXIT, function ($exitCode) use($onExit) : void { + $this->process->on(ReactEvent::EXIT, function ($exitCode) use($onExit) : void { if ($this->stdErr === null) { - throw new \RectorPrefix20220607\Symplify\EasyParallel\Exception\ParallelShouldNotHappenException(); + throw new ParallelShouldNotHappenException(); } $this->cancelTimer(); \rewind($this->stdErr); @@ -100,7 +100,7 @@ final class ParallelProcess $this->timer = $this->loop->addTimer($this->timetoutInSeconds, function () : void { $onError = $this->onError; $errorMessage = \sprintf('Child process timed out after %d seconds', $this->timetoutInSeconds); - $onError(new \Exception($errorMessage)); + $onError(new Exception($errorMessage)); }); } public function quit() : void @@ -115,22 +115,22 @@ final class ParallelProcess $this->encoder->end(); $this->process->terminate(); } - public function bindConnection(\RectorPrefix20220607\Clue\React\NDJson\Decoder $decoder, \RectorPrefix20220607\Clue\React\NDJson\Encoder $encoder) : void + public function bindConnection(Decoder $decoder, Encoder $encoder) : void { - $decoder->on(\RectorPrefix20220607\Symplify\EasyParallel\Enum\ReactEvent::DATA, function (array $json) : void { + $decoder->on(ReactEvent::DATA, function (array $json) : void { $this->cancelTimer(); - if ($json[\RectorPrefix20220607\Symplify\EasyParallel\Enum\ReactCommand::ACTION] !== \RectorPrefix20220607\Symplify\EasyParallel\Enum\Action::RESULT) { + if ($json[ReactCommand::ACTION] !== Action::RESULT) { return; } $onData = $this->onData; - $onData($json[\RectorPrefix20220607\Symplify\EasyParallel\Enum\Content::RESULT]); + $onData($json[Content::RESULT]); }); $this->encoder = $encoder; - $decoder->on(\RectorPrefix20220607\Symplify\EasyParallel\Enum\ReactEvent::ERROR, function (\Throwable $throwable) : void { + $decoder->on(ReactEvent::ERROR, function (Throwable $throwable) : void { $onError = $this->onError; $onError($throwable); }); - $encoder->on(\RectorPrefix20220607\Symplify\EasyParallel\Enum\ReactEvent::ERROR, function (\Throwable $throwable) : void { + $encoder->on(ReactEvent::ERROR, function (Throwable $throwable) : void { $onError = $this->onError; $onError($throwable); }); diff --git a/vendor/symplify/easy-parallel/src/ValueObject/ProcessPool.php b/vendor/symplify/easy-parallel/src/ValueObject/ProcessPool.php index 4e657fc44cf..816b5837c9f 100644 --- a/vendor/symplify/easy-parallel/src/ValueObject/ProcessPool.php +++ b/vendor/symplify/easy-parallel/src/ValueObject/ProcessPool.php @@ -18,18 +18,18 @@ final class ProcessPool * @var \React\Socket\TcpServer */ private $tcpServer; - public function __construct(\RectorPrefix20220607\React\Socket\TcpServer $tcpServer) + public function __construct(TcpServer $tcpServer) { $this->tcpServer = $tcpServer; } - public function getProcess(string $identifier) : \RectorPrefix20220607\Symplify\EasyParallel\ValueObject\ParallelProcess + public function getProcess(string $identifier) : ParallelProcess { if (!\array_key_exists($identifier, $this->processes)) { - throw new \RectorPrefix20220607\Symplify\EasyParallel\Exception\ParallelShouldNotHappenException(\sprintf('Process "%s" not found.', $identifier)); + throw new ParallelShouldNotHappenException(\sprintf('Process "%s" not found.', $identifier)); } return $this->processes[$identifier]; } - public function attachProcess(string $identifier, \RectorPrefix20220607\Symplify\EasyParallel\ValueObject\ParallelProcess $parallelProcess) : void + public function attachProcess(string $identifier, ParallelProcess $parallelProcess) : void { $this->processes[$identifier] = $parallelProcess; } diff --git a/vendor/symplify/easy-testing/bin/easy-testing.php b/vendor/symplify/easy-testing/bin/easy-testing.php index 6b2d70a48a1..29bb187e87c 100644 --- a/vendor/symplify/easy-testing/bin/easy-testing.php +++ b/vendor/symplify/easy-testing/bin/easy-testing.php @@ -19,5 +19,5 @@ foreach ($possibleAutoloadPaths as $possibleAutoloadPath) { break; } } -$kernelBootAndApplicationRun = new \RectorPrefix20220607\Symplify\SymplifyKernel\ValueObject\KernelBootAndApplicationRun(\RectorPrefix20220607\Symplify\EasyTesting\Kernel\EasyTestingKernel::class); +$kernelBootAndApplicationRun = new KernelBootAndApplicationRun(EasyTestingKernel::class); $kernelBootAndApplicationRun->run(); diff --git a/vendor/symplify/easy-testing/composer.json b/vendor/symplify/easy-testing/composer.json index e0a906b7380..bc34227a8b6 100644 --- a/vendor/symplify/easy-testing/composer.json +++ b/vendor/symplify/easy-testing/composer.json @@ -12,9 +12,9 @@ "symfony\/finder": "^6.0", "symfony\/console": "^6.0", "symfony\/dependency-injection": "^6.0", - "symplify\/package-builder": "^10.2.10", - "symplify\/smart-file-system": "^10.2.10", - "symplify\/symplify-kernel": "^10.2.10" + "symplify\/package-builder": "^10.2.11", + "symplify\/smart-file-system": "^10.2.11", + "symplify\/symplify-kernel": "^10.2.11" }, "require-dev": { "phpunit\/phpunit": "^9.5" @@ -35,24 +35,24 @@ } }, "conflict": { - "symplify\/astral": "<10.2.10", - "symplify\/composer-json-manipulator": "<10.2.10", - "symplify\/easy-coding-standard": "<10.2.10", - "symplify\/phpstan-rules": "<10.2.10", - "symplify\/rule-doc-generator-contracts": "<10.2.10", - "symplify\/php-config-printer": "<10.2.10", - "symplify\/autowire-array-parameter": "<10.2.10", - "symplify\/phpstan-extensions": "<10.2.10", - "symplify\/rule-doc-generator": "<10.2.10", - "symplify\/vendor-patches": "<10.2.10", - "symplify\/skipper": "<10.2.10", - "symplify\/symfony-static-dumper": "<10.2.10", - "symplify\/monorepo-builder": "<10.2.10", - "symplify\/config-transformer": "<10.2.10", - "symplify\/easy-ci": "<10.2.10", - "symplify\/coding-standard": "<10.2.10", - "symplify\/easy-parallel": "<10.2.10", - "symplify\/neon-config-dumper": "<10.2.10" + "symplify\/astral": "<10.2.11", + "symplify\/composer-json-manipulator": "<10.2.11", + "symplify\/easy-coding-standard": "<10.2.11", + "symplify\/phpstan-rules": "<10.2.11", + "symplify\/rule-doc-generator-contracts": "<10.2.11", + "symplify\/php-config-printer": "<10.2.11", + "symplify\/autowire-array-parameter": "<10.2.11", + "symplify\/phpstan-extensions": "<10.2.11", + "symplify\/rule-doc-generator": "<10.2.11", + "symplify\/vendor-patches": "<10.2.11", + "symplify\/skipper": "<10.2.11", + "symplify\/symfony-static-dumper": "<10.2.11", + "symplify\/monorepo-builder": "<10.2.11", + "symplify\/config-transformer": "<10.2.11", + "symplify\/easy-ci": "<10.2.11", + "symplify\/coding-standard": "<10.2.11", + "symplify\/easy-parallel": "<10.2.11", + "symplify\/neon-config-dumper": "<10.2.11" }, "minimum-stability": "dev", "prefer-stable": true diff --git a/vendor/symplify/easy-testing/config/config.php b/vendor/symplify/easy-testing/config/config.php index cc388ee56a0..b112e64bada 100644 --- a/vendor/symplify/easy-testing/config/config.php +++ b/vendor/symplify/easy-testing/config/config.php @@ -4,13 +4,13 @@ declare (strict_types=1); namespace RectorPrefix20220607; use RectorPrefix20220607\Symfony\Component\Console\Application; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use RectorPrefix20220607\Symplify\EasyTesting\Command\ValidateFixtureSkipNamingCommand; use function RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service; -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +return static function (ContainerConfigurator $containerConfigurator) : void { $services = $containerConfigurator->services(); $services->defaults()->public()->autowire(); $services->load('RectorPrefix20220607\Symplify\\EasyTesting\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/DataProvider', __DIR__ . '/../src/Kernel', __DIR__ . '/../src/ValueObject']); // console - $services->set(\RectorPrefix20220607\Symfony\Component\Console\Application::class)->call('add', [\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\RectorPrefix20220607\Symplify\EasyTesting\Command\ValidateFixtureSkipNamingCommand::class)]); + $services->set(Application::class)->call('add', [service(ValidateFixtureSkipNamingCommand::class)]); }; diff --git a/vendor/symplify/easy-testing/src/Command/ValidateFixtureSkipNamingCommand.php b/vendor/symplify/easy-testing/src/Command/ValidateFixtureSkipNamingCommand.php index 28691b39eec..f9ee04bc907 100644 --- a/vendor/symplify/easy-testing/src/Command/ValidateFixtureSkipNamingCommand.php +++ b/vendor/symplify/easy-testing/src/Command/ValidateFixtureSkipNamingCommand.php @@ -10,7 +10,7 @@ use RectorPrefix20220607\Symplify\EasyTesting\Finder\FixtureFinder; use RectorPrefix20220607\Symplify\EasyTesting\MissplacedSkipPrefixResolver; use RectorPrefix20220607\Symplify\EasyTesting\ValueObject\Option; use RectorPrefix20220607\Symplify\PackageBuilder\Console\Command\AbstractSymplifyCommand; -final class ValidateFixtureSkipNamingCommand extends \RectorPrefix20220607\Symplify\PackageBuilder\Console\Command\AbstractSymplifyCommand +final class ValidateFixtureSkipNamingCommand extends AbstractSymplifyCommand { /** * @var \Symplify\EasyTesting\MissplacedSkipPrefixResolver @@ -20,7 +20,7 @@ final class ValidateFixtureSkipNamingCommand extends \RectorPrefix20220607\Sympl * @var \Symplify\EasyTesting\Finder\FixtureFinder */ private $fixtureFinder; - public function __construct(\RectorPrefix20220607\Symplify\EasyTesting\MissplacedSkipPrefixResolver $missplacedSkipPrefixResolver, \RectorPrefix20220607\Symplify\EasyTesting\Finder\FixtureFinder $fixtureFinder) + public function __construct(MissplacedSkipPrefixResolver $missplacedSkipPrefixResolver, FixtureFinder $fixtureFinder) { $this->missplacedSkipPrefixResolver = $missplacedSkipPrefixResolver; $this->fixtureFinder = $fixtureFinder; @@ -29,12 +29,12 @@ final class ValidateFixtureSkipNamingCommand extends \RectorPrefix20220607\Sympl protected function configure() : void { $this->setName('validate-fixture-skip-naming'); - $this->addArgument(\RectorPrefix20220607\Symplify\EasyTesting\ValueObject\Option::SOURCE, \RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument::REQUIRED | \RectorPrefix20220607\Symfony\Component\Console\Input\InputArgument::IS_ARRAY, 'Paths to analyse'); + $this->addArgument(Option::SOURCE, InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'Paths to analyse'); $this->setDescription('Check that skipped fixture files (without `-----` separator) have a "skip" prefix'); } - protected function execute(\RectorPrefix20220607\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface $output) : int + protected function execute(InputInterface $input, OutputInterface $output) : int { - $source = (array) $input->getArgument(\RectorPrefix20220607\Symplify\EasyTesting\ValueObject\Option::SOURCE); + $source = (array) $input->getArgument(Option::SOURCE); $fixtureFileInfos = $this->fixtureFinder->find($source); $incorrectAndMissingSkips = $this->missplacedSkipPrefixResolver->resolve($fixtureFileInfos); foreach ($incorrectAndMissingSkips->getIncorrectSkipFileInfos() as $incorrectSkipFileInfo) { diff --git a/vendor/symplify/easy-testing/src/DataProvider/StaticFixtureFinder.php b/vendor/symplify/easy-testing/src/DataProvider/StaticFixtureFinder.php index c40b05581ff..d8ed7a542ad 100644 --- a/vendor/symplify/easy-testing/src/DataProvider/StaticFixtureFinder.php +++ b/vendor/symplify/easy-testing/src/DataProvider/StaticFixtureFinder.php @@ -8,7 +8,7 @@ use RectorPrefix20220607\Nette\Utils\Strings; use RectorPrefix20220607\Symfony\Component\Finder\Finder; use RectorPrefix20220607\Symfony\Component\Finder\SplFileInfo; use RectorPrefix20220607\Symplify\SmartFileSystem\Exception\FileNotFoundException; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; use RectorPrefix20220607\Symplify\SymplifyKernel\Exception\ShouldNotHappenException; /** * @api @@ -19,7 +19,7 @@ final class StaticFixtureFinder /** * @return Iterator> */ - public static function yieldDirectory(string $directory, string $suffix = '*.php.inc') : \Iterator + public static function yieldDirectory(string $directory, string $suffix = '*.php.inc') : Iterator { $fileInfos = self::findFilesInDirectory($directory, $suffix); return self::yieldFileInfos($fileInfos); @@ -27,7 +27,7 @@ final class StaticFixtureFinder /** * @return Iterator */ - public static function yieldDirectoryExclusively(string $directory, string $suffix = '*.php.inc') : \Iterator + public static function yieldDirectoryExclusively(string $directory, string $suffix = '*.php.inc') : Iterator { $fileInfos = self::findFilesInDirectoryExclusively($directory, $suffix); return self::yieldFileInfos($fileInfos); @@ -35,7 +35,7 @@ final class StaticFixtureFinder /** * @return Iterator> */ - public static function yieldDirectoryWithRelativePathname(string $directory, string $suffix = '*.php.inc') : \Iterator + public static function yieldDirectoryWithRelativePathname(string $directory, string $suffix = '*.php.inc') : Iterator { $fileInfos = self::findFilesInDirectory($directory, $suffix); return self::yieldFileInfosWithRelativePathname($fileInfos); @@ -43,7 +43,7 @@ final class StaticFixtureFinder /** * @return Iterator> */ - public static function yieldDirectoryExclusivelyWithRelativePathname(string $directory, string $suffix = '*.php.inc') : \Iterator + public static function yieldDirectoryExclusivelyWithRelativePathname(string $directory, string $suffix = '*.php.inc') : Iterator { $fileInfos = self::findFilesInDirectoryExclusively($directory, $suffix); return self::yieldFileInfosWithRelativePathname($fileInfos); @@ -52,13 +52,13 @@ final class StaticFixtureFinder * @param SplFileInfo[] $fileInfos * @return Iterator> */ - private static function yieldFileInfos(array $fileInfos) : \Iterator + private static function yieldFileInfos(array $fileInfos) : Iterator { foreach ($fileInfos as $fileInfo) { try { - $smartFileInfo = new \Symplify\SmartFileSystem\SmartFileInfo($fileInfo->getRealPath()); + $smartFileInfo = new SmartFileInfo($fileInfo->getRealPath()); (yield [$smartFileInfo]); - } catch (\RectorPrefix20220607\Symplify\SmartFileSystem\Exception\FileNotFoundException $exception) { + } catch (FileNotFoundException $exception) { } } } @@ -66,13 +66,13 @@ final class StaticFixtureFinder * @param SplFileInfo[] $fileInfos * @return Iterator> */ - private static function yieldFileInfosWithRelativePathname(array $fileInfos) : \Iterator + private static function yieldFileInfosWithRelativePathname(array $fileInfos) : Iterator { foreach ($fileInfos as $fileInfo) { try { - $smartFileInfo = new \Symplify\SmartFileSystem\SmartFileInfo($fileInfo->getRealPath()); + $smartFileInfo = new SmartFileInfo($fileInfo->getRealPath()); (yield $fileInfo->getRelativePathname() => [$smartFileInfo]); - } catch (\RectorPrefix20220607\Symplify\SmartFileSystem\Exception\FileNotFoundException $exception) { + } catch (FileNotFoundException $exception) { } } } @@ -81,7 +81,7 @@ final class StaticFixtureFinder */ private static function findFilesInDirectory(string $directory, string $suffix) : array { - $finder = \RectorPrefix20220607\Symfony\Component\Finder\Finder::create()->in($directory)->files()->name($suffix); + $finder = Finder::create()->in($directory)->files()->name($suffix); $fileInfos = \iterator_to_array($finder); return \array_values($fileInfos); } @@ -91,22 +91,22 @@ final class StaticFixtureFinder private static function findFilesInDirectoryExclusively(string $directory, string $suffix) : array { self::ensureNoOtherFileName($directory, $suffix); - $finder = \RectorPrefix20220607\Symfony\Component\Finder\Finder::create()->in($directory)->files()->name($suffix); + $finder = Finder::create()->in($directory)->files()->name($suffix); $fileInfos = \iterator_to_array($finder->getIterator()); return \array_values($fileInfos); } private static function ensureNoOtherFileName(string $directory, string $suffix) : void { - $finder = \RectorPrefix20220607\Symfony\Component\Finder\Finder::create()->in($directory)->files()->notName($suffix); + $finder = Finder::create()->in($directory)->files()->notName($suffix); /** @var SplFileInfo[] $fileInfos */ $fileInfos = \iterator_to_array($finder->getIterator()); $relativeFilePaths = []; foreach ($fileInfos as $fileInfo) { - $relativeFilePaths[] = \RectorPrefix20220607\Nette\Utils\Strings::substring($fileInfo->getRealPath(), \strlen(\getcwd()) + 1); + $relativeFilePaths[] = Strings::substring($fileInfo->getRealPath(), \strlen(\getcwd()) + 1); } if ($relativeFilePaths === []) { return; } - throw new \RectorPrefix20220607\Symplify\SymplifyKernel\Exception\ShouldNotHappenException(\sprintf('Files "%s" have invalid suffix, use "%s" suffix instead', \implode('", ', $relativeFilePaths), $suffix)); + throw new ShouldNotHappenException(\sprintf('Files "%s" have invalid suffix, use "%s" suffix instead', \implode('", ', $relativeFilePaths), $suffix)); } } diff --git a/vendor/symplify/easy-testing/src/DataProvider/StaticFixtureUpdater.php b/vendor/symplify/easy-testing/src/DataProvider/StaticFixtureUpdater.php index eebc8f60c5f..535496555ab 100644 --- a/vendor/symplify/easy-testing/src/DataProvider/StaticFixtureUpdater.php +++ b/vendor/symplify/easy-testing/src/DataProvider/StaticFixtureUpdater.php @@ -3,7 +3,7 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\EasyTesting\DataProvider; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem; /** * @api @@ -13,7 +13,7 @@ final class StaticFixtureUpdater /** * @param \Symplify\SmartFileSystem\SmartFileInfo|string $originalFileInfo */ - public static function updateFixtureContent($originalFileInfo, string $changedContent, \Symplify\SmartFileSystem\SmartFileInfo $fixtureFileInfo) : void + public static function updateFixtureContent($originalFileInfo, string $changedContent, SmartFileInfo $fixtureFileInfo) : void { if (!\getenv('UPDATE_TESTS') && !\getenv('UT')) { return; @@ -21,23 +21,23 @@ final class StaticFixtureUpdater $newOriginalContent = self::resolveNewFixtureContent($originalFileInfo, $changedContent); self::getSmartFileSystem()->dumpFile($fixtureFileInfo->getRealPath(), $newOriginalContent); } - public static function updateExpectedFixtureContent(string $newOriginalContent, \Symplify\SmartFileSystem\SmartFileInfo $expectedFixtureFileInfo) : void + public static function updateExpectedFixtureContent(string $newOriginalContent, SmartFileInfo $expectedFixtureFileInfo) : void { if (!\getenv('UPDATE_TESTS') && !\getenv('UT')) { return; } self::getSmartFileSystem()->dumpFile($expectedFixtureFileInfo->getRealPath(), $newOriginalContent); } - private static function getSmartFileSystem() : \RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem + private static function getSmartFileSystem() : SmartFileSystem { - return new \RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem(); + return new SmartFileSystem(); } /** * @param \Symplify\SmartFileSystem\SmartFileInfo|string $originalFileInfo */ private static function resolveNewFixtureContent($originalFileInfo, string $changedContent) : string { - if ($originalFileInfo instanceof \Symplify\SmartFileSystem\SmartFileInfo) { + if ($originalFileInfo instanceof SmartFileInfo) { $originalContent = $originalFileInfo->getContents(); } else { $originalContent = $originalFileInfo; diff --git a/vendor/symplify/easy-testing/src/Finder/FixtureFinder.php b/vendor/symplify/easy-testing/src/Finder/FixtureFinder.php index 7dd7a66cb17..ffad8cf8278 100644 --- a/vendor/symplify/easy-testing/src/Finder/FixtureFinder.php +++ b/vendor/symplify/easy-testing/src/Finder/FixtureFinder.php @@ -5,14 +5,14 @@ namespace RectorPrefix20220607\Symplify\EasyTesting\Finder; use RectorPrefix20220607\Symfony\Component\Finder\Finder; use RectorPrefix20220607\Symplify\SmartFileSystem\Finder\FinderSanitizer; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class FixtureFinder { /** * @var \Symplify\SmartFileSystem\Finder\FinderSanitizer */ private $finderSanitizer; - public function __construct(\RectorPrefix20220607\Symplify\SmartFileSystem\Finder\FinderSanitizer $finderSanitizer) + public function __construct(FinderSanitizer $finderSanitizer) { $this->finderSanitizer = $finderSanitizer; } @@ -22,7 +22,7 @@ final class FixtureFinder */ public function find(array $sources) : array { - $finder = new \RectorPrefix20220607\Symfony\Component\Finder\Finder(); + $finder = new Finder(); $finder->files()->in($sources)->name('*.php.inc')->path('Fixture')->sortByName(); return $this->finderSanitizer->sanitize($finder); } diff --git a/vendor/symplify/easy-testing/src/FixtureSplitter/TrioFixtureSplitter.php b/vendor/symplify/easy-testing/src/FixtureSplitter/TrioFixtureSplitter.php index c59bf5ca00f..1fe92eff3b5 100644 --- a/vendor/symplify/easy-testing/src/FixtureSplitter/TrioFixtureSplitter.php +++ b/vendor/symplify/easy-testing/src/FixtureSplitter/TrioFixtureSplitter.php @@ -6,28 +6,28 @@ namespace RectorPrefix20220607\Symplify\EasyTesting\FixtureSplitter; use RectorPrefix20220607\Nette\Utils\Strings; use RectorPrefix20220607\Symplify\EasyTesting\ValueObject\FixtureSplit\TrioContent; use RectorPrefix20220607\Symplify\EasyTesting\ValueObject\SplitLine; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; use RectorPrefix20220607\Symplify\SymplifyKernel\Exception\ShouldNotHappenException; /** * @api */ final class TrioFixtureSplitter { - public function splitFileInfo(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : \RectorPrefix20220607\Symplify\EasyTesting\ValueObject\FixtureSplit\TrioContent + public function splitFileInfo(SmartFileInfo $smartFileInfo) : TrioContent { - $parts = \RectorPrefix20220607\Nette\Utils\Strings::split($smartFileInfo->getContents(), \RectorPrefix20220607\Symplify\EasyTesting\ValueObject\SplitLine::SPLIT_LINE_REGEX); + $parts = Strings::split($smartFileInfo->getContents(), SplitLine::SPLIT_LINE_REGEX); $this->ensureHasThreeParts($parts, $smartFileInfo); - return new \RectorPrefix20220607\Symplify\EasyTesting\ValueObject\FixtureSplit\TrioContent($parts[0], $parts[1], $parts[2]); + return new TrioContent($parts[0], $parts[1], $parts[2]); } /** * @param mixed[] $parts */ - private function ensureHasThreeParts(array $parts, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : void + private function ensureHasThreeParts(array $parts, SmartFileInfo $smartFileInfo) : void { if (\count($parts) === 3) { return; } $message = \sprintf('The fixture "%s" should have 3 parts. %d found', $smartFileInfo->getRelativeFilePathFromCwd(), \count($parts)); - throw new \RectorPrefix20220607\Symplify\SymplifyKernel\Exception\ShouldNotHappenException($message); + throw new ShouldNotHappenException($message); } } diff --git a/vendor/symplify/easy-testing/src/Kernel/EasyTestingKernel.php b/vendor/symplify/easy-testing/src/Kernel/EasyTestingKernel.php index a4bf1a361f2..58fb09664ab 100644 --- a/vendor/symplify/easy-testing/src/Kernel/EasyTestingKernel.php +++ b/vendor/symplify/easy-testing/src/Kernel/EasyTestingKernel.php @@ -6,14 +6,14 @@ namespace RectorPrefix20220607\Symplify\EasyTesting\Kernel; use RectorPrefix20220607\Psr\Container\ContainerInterface; use RectorPrefix20220607\Symplify\EasyTesting\ValueObject\EasyTestingConfig; use RectorPrefix20220607\Symplify\SymplifyKernel\HttpKernel\AbstractSymplifyKernel; -final class EasyTestingKernel extends \RectorPrefix20220607\Symplify\SymplifyKernel\HttpKernel\AbstractSymplifyKernel +final class EasyTestingKernel extends AbstractSymplifyKernel { /** * @param string[] $configFiles */ - public function createFromConfigs(array $configFiles) : \RectorPrefix20220607\Psr\Container\ContainerInterface + public function createFromConfigs(array $configFiles) : ContainerInterface { - $configFiles[] = \RectorPrefix20220607\Symplify\EasyTesting\ValueObject\EasyTestingConfig::FILE_PATH; + $configFiles[] = EasyTestingConfig::FILE_PATH; return $this->create($configFiles); } } diff --git a/vendor/symplify/easy-testing/src/MissplacedSkipPrefixResolver.php b/vendor/symplify/easy-testing/src/MissplacedSkipPrefixResolver.php index 3282cf1c6e1..93ccaf22799 100644 --- a/vendor/symplify/easy-testing/src/MissplacedSkipPrefixResolver.php +++ b/vendor/symplify/easy-testing/src/MissplacedSkipPrefixResolver.php @@ -7,7 +7,7 @@ use RectorPrefix20220607\Nette\Utils\Strings; use RectorPrefix20220607\Symplify\EasyTesting\ValueObject\IncorrectAndMissingSkips; use RectorPrefix20220607\Symplify\EasyTesting\ValueObject\Prefix; use RectorPrefix20220607\Symplify\EasyTesting\ValueObject\SplitLine; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; /** * @see \Symplify\EasyTesting\Tests\MissingSkipPrefixResolver\MissingSkipPrefixResolverTest */ @@ -16,14 +16,14 @@ final class MissplacedSkipPrefixResolver /** * @param SmartFileInfo[] $fixtureFileInfos */ - public function resolve(array $fixtureFileInfos) : \RectorPrefix20220607\Symplify\EasyTesting\ValueObject\IncorrectAndMissingSkips + public function resolve(array $fixtureFileInfos) : IncorrectAndMissingSkips { $incorrectSkips = []; $missingSkips = []; foreach ($fixtureFileInfos as $fixtureFileInfo) { $hasNameSkipStart = $this->hasNameSkipStart($fixtureFileInfo); $fileContents = $fixtureFileInfo->getContents(); - $hasSplitLine = (bool) \RectorPrefix20220607\Nette\Utils\Strings::match($fileContents, \RectorPrefix20220607\Symplify\EasyTesting\ValueObject\SplitLine::SPLIT_LINE_REGEX); + $hasSplitLine = (bool) Strings::match($fileContents, SplitLine::SPLIT_LINE_REGEX); if ($hasNameSkipStart && $hasSplitLine) { $incorrectSkips[] = $fixtureFileInfo; continue; @@ -32,10 +32,10 @@ final class MissplacedSkipPrefixResolver $missingSkips[] = $fixtureFileInfo; } } - return new \RectorPrefix20220607\Symplify\EasyTesting\ValueObject\IncorrectAndMissingSkips($incorrectSkips, $missingSkips); + return new IncorrectAndMissingSkips($incorrectSkips, $missingSkips); } - private function hasNameSkipStart(\Symplify\SmartFileSystem\SmartFileInfo $fixtureFileInfo) : bool + private function hasNameSkipStart(SmartFileInfo $fixtureFileInfo) : bool { - return (bool) \RectorPrefix20220607\Nette\Utils\Strings::match($fixtureFileInfo->getBasenameWithoutSuffix(), \RectorPrefix20220607\Symplify\EasyTesting\ValueObject\Prefix::SKIP_PREFIX_REGEX); + return (bool) Strings::match($fixtureFileInfo->getBasenameWithoutSuffix(), Prefix::SKIP_PREFIX_REGEX); } } diff --git a/vendor/symplify/easy-testing/src/PHPUnit/Behavior/DirectoryAssertableTrait.php b/vendor/symplify/easy-testing/src/PHPUnit/Behavior/DirectoryAssertableTrait.php index 83349f3760d..3d2c9a9778d 100644 --- a/vendor/symplify/easy-testing/src/PHPUnit/Behavior/DirectoryAssertableTrait.php +++ b/vendor/symplify/easy-testing/src/PHPUnit/Behavior/DirectoryAssertableTrait.php @@ -6,7 +6,7 @@ namespace RectorPrefix20220607\Symplify\EasyTesting\PHPUnit\Behavior; use RectorPrefix20220607\Symfony\Component\Finder\Finder; use RectorPrefix20220607\Symplify\EasyTesting\ValueObject\ExpectedAndOutputFileInfoPair; use RectorPrefix20220607\Symplify\SmartFileSystem\Finder\FinderSanitizer; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; /** * Use only in "\PHPUnit\Framework\TestCase" * @@ -37,9 +37,9 @@ trait DirectoryAssertableTrait */ private function findFileInfosInDirectory(string $directory) : array { - $firstDirectoryFinder = new \RectorPrefix20220607\Symfony\Component\Finder\Finder(); + $firstDirectoryFinder = new Finder(); $firstDirectoryFinder->files()->in($directory); - $finderSanitizer = new \RectorPrefix20220607\Symplify\SmartFileSystem\Finder\FinderSanitizer(); + $finderSanitizer = new FinderSanitizer(); return $finderSanitizer->sanitize($firstDirectoryFinder); } /** @@ -54,14 +54,14 @@ trait DirectoryAssertableTrait $relativeFilePath = $expectedFileInfo->getRelativeFilePathFromDirectory($expectedDirectory); // match output file info $outputFileInfo = $this->resolveFileInfoByRelativeFilePath($outputFileInfos, $outputDirectory, $relativeFilePath); - $fileInfosByRelativeFilePath[$relativeFilePath] = new \RectorPrefix20220607\Symplify\EasyTesting\ValueObject\ExpectedAndOutputFileInfoPair($expectedFileInfo, $outputFileInfo); + $fileInfosByRelativeFilePath[$relativeFilePath] = new ExpectedAndOutputFileInfoPair($expectedFileInfo, $outputFileInfo); } return $fileInfosByRelativeFilePath; } /** * @param SmartFileInfo[] $fileInfos */ - private function resolveFileInfoByRelativeFilePath(array $fileInfos, string $directory, string $desiredRelativeFilePath) : ?\Symplify\SmartFileSystem\SmartFileInfo + private function resolveFileInfoByRelativeFilePath(array $fileInfos, string $directory, string $desiredRelativeFilePath) : ?SmartFileInfo { foreach ($fileInfos as $fileInfo) { $relativeFilePath = $fileInfo->getRelativeFilePathFromDirectory($directory); diff --git a/vendor/symplify/easy-testing/src/PHPUnit/StaticPHPUnitEnvironment.php b/vendor/symplify/easy-testing/src/PHPUnit/StaticPHPUnitEnvironment.php index 1d00549cbef..5015724715b 100644 --- a/vendor/symplify/easy-testing/src/PHPUnit/StaticPHPUnitEnvironment.php +++ b/vendor/symplify/easy-testing/src/PHPUnit/StaticPHPUnitEnvironment.php @@ -13,6 +13,6 @@ final class StaticPHPUnitEnvironment */ public static function isPHPUnitRun() : bool { - return \defined('PHPUNIT_COMPOSER_INSTALL') || \defined('__PHPUNIT_PHAR__'); + return \defined('RectorPrefix20220607\\PHPUNIT_COMPOSER_INSTALL') || \defined('RectorPrefix20220607\\__PHPUNIT_PHAR__'); } } diff --git a/vendor/symplify/easy-testing/src/StaticFixtureSplitter.php b/vendor/symplify/easy-testing/src/StaticFixtureSplitter.php index 5483fe73714..5e39819e9b5 100644 --- a/vendor/symplify/easy-testing/src/StaticFixtureSplitter.php +++ b/vendor/symplify/easy-testing/src/StaticFixtureSplitter.php @@ -8,7 +8,7 @@ use RectorPrefix20220607\Symplify\EasyTesting\ValueObject\InputAndExpected; use RectorPrefix20220607\Symplify\EasyTesting\ValueObject\InputFileInfoAndExpected; use RectorPrefix20220607\Symplify\EasyTesting\ValueObject\InputFileInfoAndExpectedFileInfo; use RectorPrefix20220607\Symplify\EasyTesting\ValueObject\SplitLine; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem; /** * @api @@ -19,20 +19,20 @@ final class StaticFixtureSplitter * @var string|null */ public static $customTemporaryPath; - public static function splitFileInfoToInputAndExpected(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : \RectorPrefix20220607\Symplify\EasyTesting\ValueObject\InputAndExpected + public static function splitFileInfoToInputAndExpected(SmartFileInfo $smartFileInfo) : InputAndExpected { - $splitLineCount = \count(\RectorPrefix20220607\Nette\Utils\Strings::matchAll($smartFileInfo->getContents(), \RectorPrefix20220607\Symplify\EasyTesting\ValueObject\SplitLine::SPLIT_LINE_REGEX)); + $splitLineCount = \count(Strings::matchAll($smartFileInfo->getContents(), SplitLine::SPLIT_LINE_REGEX)); // if more or less, it could be a test cases for monorepo line in it if ($splitLineCount === 1) { // input → expected - [$input, $expected] = \RectorPrefix20220607\Nette\Utils\Strings::split($smartFileInfo->getContents(), \RectorPrefix20220607\Symplify\EasyTesting\ValueObject\SplitLine::SPLIT_LINE_REGEX); + [$input, $expected] = Strings::split($smartFileInfo->getContents(), SplitLine::SPLIT_LINE_REGEX); $expected = self::retypeExpected($expected); - return new \RectorPrefix20220607\Symplify\EasyTesting\ValueObject\InputAndExpected($input, $expected); + return new InputAndExpected($input, $expected); } // no changes - return new \RectorPrefix20220607\Symplify\EasyTesting\ValueObject\InputAndExpected($smartFileInfo->getContents(), $smartFileInfo->getContents()); + return new InputAndExpected($smartFileInfo->getContents(), $smartFileInfo->getContents()); } - public static function splitFileInfoToLocalInputAndExpectedFileInfos(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo, bool $autoloadTestFixture = \false) : \RectorPrefix20220607\Symplify\EasyTesting\ValueObject\InputFileInfoAndExpectedFileInfo + public static function splitFileInfoToLocalInputAndExpectedFileInfos(SmartFileInfo $smartFileInfo, bool $autoloadTestFixture = \false) : InputFileInfoAndExpectedFileInfo { $inputAndExpected = self::splitFileInfoToInputAndExpected($smartFileInfo); $inputFileInfo = self::createTemporaryFileInfo($smartFileInfo, 'input', $inputAndExpected->getInput()); @@ -41,7 +41,7 @@ final class StaticFixtureSplitter require_once $inputFileInfo->getRealPath(); } $expectedFileInfo = self::createTemporaryFileInfo($smartFileInfo, 'expected', $inputAndExpected->getExpected()); - return new \RectorPrefix20220607\Symplify\EasyTesting\ValueObject\InputFileInfoAndExpectedFileInfo($inputFileInfo, $expectedFileInfo); + return new InputFileInfoAndExpectedFileInfo($inputFileInfo, $expectedFileInfo); } public static function getTemporaryPath() : string { @@ -50,7 +50,7 @@ final class StaticFixtureSplitter } return \sys_get_temp_dir() . '/_temp_fixture_easy_testing'; } - public static function createTemporaryFileInfo(\Symplify\SmartFileSystem\SmartFileInfo $fixtureSmartFileInfo, string $prefix, string $fileContent) : \Symplify\SmartFileSystem\SmartFileInfo + public static function createTemporaryFileInfo(SmartFileInfo $fixtureSmartFileInfo, string $prefix, string $fileContent) : SmartFileInfo { $temporaryFilePath = self::createTemporaryPathWithPrefix($fixtureSmartFileInfo, $prefix); $dir = \dirname($temporaryFilePath); @@ -59,9 +59,9 @@ final class StaticFixtureSplitter } /** @phpstan-ignore-next-line we don't use SmartFileSystem->dump() for performance reasons */ \file_put_contents($temporaryFilePath, $fileContent); - return new \Symplify\SmartFileSystem\SmartFileInfo($temporaryFilePath); + return new SmartFileInfo($temporaryFilePath); } - public static function splitFileInfoToLocalInputAndExpected(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo, bool $autoloadTestFixture = \false) : \RectorPrefix20220607\Symplify\EasyTesting\ValueObject\InputFileInfoAndExpected + public static function splitFileInfoToLocalInputAndExpected(SmartFileInfo $smartFileInfo, bool $autoloadTestFixture = \false) : InputFileInfoAndExpected { $inputAndExpected = self::splitFileInfoToInputAndExpected($smartFileInfo); $inputFileInfo = self::createTemporaryFileInfo($smartFileInfo, 'input', $inputAndExpected->getInput()); @@ -69,11 +69,11 @@ final class StaticFixtureSplitter if ($autoloadTestFixture) { require_once $inputFileInfo->getRealPath(); } - return new \RectorPrefix20220607\Symplify\EasyTesting\ValueObject\InputFileInfoAndExpected($inputFileInfo, $inputAndExpected->getExpected()); + return new InputFileInfoAndExpected($inputFileInfo, $inputAndExpected->getExpected()); } - private static function createTemporaryPathWithPrefix(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo, string $prefix) : string + private static function createTemporaryPathWithPrefix(SmartFileInfo $smartFileInfo, string $prefix) : string { - $hash = \RectorPrefix20220607\Nette\Utils\Strings::substring(\md5($smartFileInfo->getRealPath()), -20); + $hash = Strings::substring(\md5($smartFileInfo->getRealPath()), -20); $fileBaseName = $smartFileInfo->getBasename('.inc'); return self::getTemporaryPath() . \sprintf('/%s_%s_%s', $prefix, $hash, $fileBaseName); } diff --git a/vendor/symplify/easy-testing/src/ValueObject/ExpectedAndOutputFileInfoPair.php b/vendor/symplify/easy-testing/src/ValueObject/ExpectedAndOutputFileInfoPair.php index 1392bf08db6..f8484282f80 100644 --- a/vendor/symplify/easy-testing/src/ValueObject/ExpectedAndOutputFileInfoPair.php +++ b/vendor/symplify/easy-testing/src/ValueObject/ExpectedAndOutputFileInfoPair.php @@ -3,7 +3,7 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\EasyTesting\ValueObject; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; use RectorPrefix20220607\Symplify\SymplifyKernel\Exception\ShouldNotHappenException; final class ExpectedAndOutputFileInfoPair { @@ -15,7 +15,7 @@ final class ExpectedAndOutputFileInfoPair * @var \Symplify\SmartFileSystem\SmartFileInfo|null */ private $outputFileInfo; - public function __construct(\Symplify\SmartFileSystem\SmartFileInfo $expectedFileInfo, ?\Symplify\SmartFileSystem\SmartFileInfo $outputFileInfo) + public function __construct(SmartFileInfo $expectedFileInfo, ?SmartFileInfo $outputFileInfo) { $this->expectedFileInfo = $expectedFileInfo; $this->outputFileInfo = $outputFileInfo; @@ -32,8 +32,8 @@ final class ExpectedAndOutputFileInfoPair */ public function getOutputFileContent() : string { - if (!$this->outputFileInfo instanceof \Symplify\SmartFileSystem\SmartFileInfo) { - throw new \RectorPrefix20220607\Symplify\SymplifyKernel\Exception\ShouldNotHappenException(); + if (!$this->outputFileInfo instanceof SmartFileInfo) { + throw new ShouldNotHappenException(); } return $this->outputFileInfo->getContents(); } diff --git a/vendor/symplify/easy-testing/src/ValueObject/IncorrectAndMissingSkips.php b/vendor/symplify/easy-testing/src/ValueObject/IncorrectAndMissingSkips.php index 3f654509e73..97ad0a9b345 100644 --- a/vendor/symplify/easy-testing/src/ValueObject/IncorrectAndMissingSkips.php +++ b/vendor/symplify/easy-testing/src/ValueObject/IncorrectAndMissingSkips.php @@ -3,7 +3,7 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\EasyTesting\ValueObject; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class IncorrectAndMissingSkips { /** diff --git a/vendor/symplify/easy-testing/src/ValueObject/InputFileInfoAndExpected.php b/vendor/symplify/easy-testing/src/ValueObject/InputFileInfoAndExpected.php index c7d2cc94b00..70799ff0dd1 100644 --- a/vendor/symplify/easy-testing/src/ValueObject/InputFileInfoAndExpected.php +++ b/vendor/symplify/easy-testing/src/ValueObject/InputFileInfoAndExpected.php @@ -3,7 +3,7 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\EasyTesting\ValueObject; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class InputFileInfoAndExpected { /** @@ -17,7 +17,7 @@ final class InputFileInfoAndExpected /** * @param mixed $expected */ - public function __construct(\Symplify\SmartFileSystem\SmartFileInfo $inputFileInfo, $expected) + public function __construct(SmartFileInfo $inputFileInfo, $expected) { $this->inputFileInfo = $inputFileInfo; $this->expected = $expected; @@ -26,7 +26,7 @@ final class InputFileInfoAndExpected { return $this->inputFileInfo->getContents(); } - public function getInputFileInfo() : \Symplify\SmartFileSystem\SmartFileInfo + public function getInputFileInfo() : SmartFileInfo { return $this->inputFileInfo; } diff --git a/vendor/symplify/easy-testing/src/ValueObject/InputFileInfoAndExpectedFileInfo.php b/vendor/symplify/easy-testing/src/ValueObject/InputFileInfoAndExpectedFileInfo.php index 656e3595d50..0aca5e3e713 100644 --- a/vendor/symplify/easy-testing/src/ValueObject/InputFileInfoAndExpectedFileInfo.php +++ b/vendor/symplify/easy-testing/src/ValueObject/InputFileInfoAndExpectedFileInfo.php @@ -3,7 +3,7 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\EasyTesting\ValueObject; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class InputFileInfoAndExpectedFileInfo { /** @@ -14,16 +14,16 @@ final class InputFileInfoAndExpectedFileInfo * @var \Symplify\SmartFileSystem\SmartFileInfo */ private $expectedFileInfo; - public function __construct(\Symplify\SmartFileSystem\SmartFileInfo $inputFileInfo, \Symplify\SmartFileSystem\SmartFileInfo $expectedFileInfo) + public function __construct(SmartFileInfo $inputFileInfo, SmartFileInfo $expectedFileInfo) { $this->inputFileInfo = $inputFileInfo; $this->expectedFileInfo = $expectedFileInfo; } - public function getInputFileInfo() : \Symplify\SmartFileSystem\SmartFileInfo + public function getInputFileInfo() : SmartFileInfo { return $this->inputFileInfo; } - public function getExpectedFileInfo() : \Symplify\SmartFileSystem\SmartFileInfo + public function getExpectedFileInfo() : SmartFileInfo { return $this->expectedFileInfo; } diff --git a/vendor/symplify/package-builder/composer.json b/vendor/symplify/package-builder/composer.json index 35d8067a8fc..d7f1177299b 100644 --- a/vendor/symplify/package-builder/composer.json +++ b/vendor/symplify/package-builder/composer.json @@ -10,8 +10,8 @@ "symfony\/console": "^6.0", "symfony\/dependency-injection": "^6.0", "symfony\/finder": "^6.0", - "symplify\/symplify-kernel": "^10.2.10", - "symplify\/easy-testing": "^10.2.10" + "symplify\/symplify-kernel": "^10.2.11", + "symplify\/easy-testing": "^10.2.11" }, "require-dev": { "phpunit\/phpunit": "^9.5" @@ -32,25 +32,25 @@ } }, "conflict": { - "symplify\/astral": "<10.2.10", - "symplify\/composer-json-manipulator": "<10.2.10", - "symplify\/easy-coding-standard": "<10.2.10", - "symplify\/phpstan-rules": "<10.2.10", - "symplify\/rule-doc-generator-contracts": "<10.2.10", - "symplify\/php-config-printer": "<10.2.10", - "symplify\/autowire-array-parameter": "<10.2.10", - "symplify\/phpstan-extensions": "<10.2.10", - "symplify\/rule-doc-generator": "<10.2.10", - "symplify\/vendor-patches": "<10.2.10", - "symplify\/skipper": "<10.2.10", - "symplify\/smart-file-system": "<10.2.10", - "symplify\/symfony-static-dumper": "<10.2.10", - "symplify\/monorepo-builder": "<10.2.10", - "symplify\/config-transformer": "<10.2.10", - "symplify\/easy-ci": "<10.2.10", - "symplify\/coding-standard": "<10.2.10", - "symplify\/easy-parallel": "<10.2.10", - "symplify\/neon-config-dumper": "<10.2.10" + "symplify\/astral": "<10.2.11", + "symplify\/composer-json-manipulator": "<10.2.11", + "symplify\/easy-coding-standard": "<10.2.11", + "symplify\/phpstan-rules": "<10.2.11", + "symplify\/rule-doc-generator-contracts": "<10.2.11", + "symplify\/php-config-printer": "<10.2.11", + "symplify\/autowire-array-parameter": "<10.2.11", + "symplify\/phpstan-extensions": "<10.2.11", + "symplify\/rule-doc-generator": "<10.2.11", + "symplify\/vendor-patches": "<10.2.11", + "symplify\/skipper": "<10.2.11", + "symplify\/smart-file-system": "<10.2.11", + "symplify\/symfony-static-dumper": "<10.2.11", + "symplify\/monorepo-builder": "<10.2.11", + "symplify\/config-transformer": "<10.2.11", + "symplify\/easy-ci": "<10.2.11", + "symplify\/coding-standard": "<10.2.11", + "symplify\/easy-parallel": "<10.2.11", + "symplify\/neon-config-dumper": "<10.2.11" }, "minimum-stability": "dev", "prefer-stable": true diff --git a/vendor/symplify/package-builder/config/config.php b/vendor/symplify/package-builder/config/config.php index 69da6fad715..77845557dff 100644 --- a/vendor/symplify/package-builder/config/config.php +++ b/vendor/symplify/package-builder/config/config.php @@ -4,17 +4,17 @@ declare (strict_types=1); namespace RectorPrefix20220607; use RectorPrefix20220607\SebastianBergmann\Diff\Differ; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use RectorPrefix20220607\Symplify\PackageBuilder\Console\Formatter\ColorConsoleDiffFormatter; use RectorPrefix20220607\Symplify\PackageBuilder\Console\Output\ConsoleDiffer; use RectorPrefix20220607\Symplify\PackageBuilder\Diff\Output\CompleteUnifiedDiffOutputBuilderFactory; use RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor; -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +return static function (ContainerConfigurator $containerConfigurator) : void { $services = $containerConfigurator->services(); $services->defaults()->public()->autowire(); - $services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Console\Formatter\ColorConsoleDiffFormatter::class); - $services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Console\Output\ConsoleDiffer::class); - $services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Diff\Output\CompleteUnifiedDiffOutputBuilderFactory::class); - $services->set(\RectorPrefix20220607\SebastianBergmann\Diff\Differ::class); - $services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor::class); + $services->set(ColorConsoleDiffFormatter::class); + $services->set(ConsoleDiffer::class); + $services->set(CompleteUnifiedDiffOutputBuilderFactory::class); + $services->set(Differ::class); + $services->set(PrivatesAccessor::class); }; diff --git a/vendor/symplify/package-builder/src/Composer/VendorDirProvider.php b/vendor/symplify/package-builder/src/Composer/VendorDirProvider.php index caa2eab36bc..09062858519 100644 --- a/vendor/symplify/package-builder/src/Composer/VendorDirProvider.php +++ b/vendor/symplify/package-builder/src/Composer/VendorDirProvider.php @@ -25,7 +25,7 @@ final class VendorDirProvider } private function reflectionFallback() : string { - $reflectionClass = new \ReflectionClass(\RectorPrefix20220607\Composer\Autoload\ClassLoader::class); + $reflectionClass = new ReflectionClass(ClassLoader::class); return \dirname($reflectionClass->getFileName(), 2); } } diff --git a/vendor/symplify/package-builder/src/Console/Command/AbstractSymplifyCommand.php b/vendor/symplify/package-builder/src/Console/Command/AbstractSymplifyCommand.php index e49812ef679..dd21a09e753 100644 --- a/vendor/symplify/package-builder/src/Console/Command/AbstractSymplifyCommand.php +++ b/vendor/symplify/package-builder/src/Console/Command/AbstractSymplifyCommand.php @@ -11,7 +11,7 @@ use RectorPrefix20220607\Symplify\PackageBuilder\ValueObject\Option; use RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemGuard; use RectorPrefix20220607\Symplify\SmartFileSystem\Finder\SmartFinder; use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem; -abstract class AbstractSymplifyCommand extends \RectorPrefix20220607\Symfony\Component\Console\Command\Command +abstract class AbstractSymplifyCommand extends Command { /** * @var \Symfony\Component\Console\Style\SymfonyStyle @@ -32,12 +32,12 @@ abstract class AbstractSymplifyCommand extends \RectorPrefix20220607\Symfony\Com public function __construct() { parent::__construct(); - $this->addOption(\RectorPrefix20220607\Symplify\PackageBuilder\ValueObject\Option::CONFIG, 'c', \RectorPrefix20220607\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED, 'Path to config file'); + $this->addOption(Option::CONFIG, 'c', InputOption::VALUE_REQUIRED, 'Path to config file'); } /** * @required */ - public function autowire(\RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle, \RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \RectorPrefix20220607\Symplify\SmartFileSystem\Finder\SmartFinder $smartFinder, \RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemGuard $fileSystemGuard) : void + public function autowire(SymfonyStyle $symfonyStyle, SmartFileSystem $smartFileSystem, SmartFinder $smartFinder, FileSystemGuard $fileSystemGuard) : void { $this->symfonyStyle = $symfonyStyle; $this->smartFileSystem = $smartFileSystem; diff --git a/vendor/symplify/package-builder/src/Console/Command/CommandNaming.php b/vendor/symplify/package-builder/src/Console/Command/CommandNaming.php index 9bf8f1a153c..016bbbb4483 100644 --- a/vendor/symplify/package-builder/src/Console/Command/CommandNaming.php +++ b/vendor/symplify/package-builder/src/Console/Command/CommandNaming.php @@ -21,7 +21,7 @@ final class CommandNaming * - "SomeClass\SomeSuperCommand" → "some-super" * - "SomeClass\SOMESuperCommand" → "some-super" */ - public function resolveFromCommand(\RectorPrefix20220607\Symfony\Component\Console\Command\Command $command) : string + public function resolveFromCommand(Command $command) : string { $commandClass = \get_class($command); return self::classToName($commandClass); @@ -35,7 +35,7 @@ final class CommandNaming { /** @var string $shortClassName */ $shortClassName = self::resolveShortName($class); - $rawCommandName = \RectorPrefix20220607\Nette\Utils\Strings::substring($shortClassName, 0, -\strlen('Command')); + $rawCommandName = Strings::substring($shortClassName, 0, -\strlen('Command')); // ECSCommand => ecs for ($i = 0; $i < \strlen($rawCommandName); ++$i) { if (\ctype_upper($rawCommandName[$i]) && self::isFollowedByUpperCaseLetterOrNothing($rawCommandName, $i)) { @@ -45,7 +45,7 @@ final class CommandNaming } } $lowercasedRawCommandName = \lcfirst($rawCommandName); - return \RectorPrefix20220607\Nette\Utils\Strings::replace($lowercasedRawCommandName, self::BIG_LETTER_REGEX, function (array $matches) : string { + return Strings::replace($lowercasedRawCommandName, self::BIG_LETTER_REGEX, function (array $matches) : string { return '-' . \strtolower($matches[0]); }); } diff --git a/vendor/symplify/package-builder/src/Console/Formatter/ColorConsoleDiffFormatter.php b/vendor/symplify/package-builder/src/Console/Formatter/ColorConsoleDiffFormatter.php index 2033e7bf229..33b02ce8913 100644 --- a/vendor/symplify/package-builder/src/Console/Formatter/ColorConsoleDiffFormatter.php +++ b/vendor/symplify/package-builder/src/Console/Formatter/ColorConsoleDiffFormatter.php @@ -47,8 +47,8 @@ final class ColorConsoleDiffFormatter } private function formatWithTemplate(string $diff, string $template) : string { - $escapedDiff = \RectorPrefix20220607\Symfony\Component\Console\Formatter\OutputFormatter::escape(\rtrim($diff)); - $escapedDiffLines = \RectorPrefix20220607\Nette\Utils\Strings::split($escapedDiff, self::NEWLINES_REGEX); + $escapedDiff = OutputFormatter::escape(\rtrim($diff)); + $escapedDiffLines = Strings::split($escapedDiff, self::NEWLINES_REGEX); // remove description of added + remove; obvious on diffs foreach ($escapedDiffLines as $key => $escapedDiffLine) { if ($escapedDiffLine === '--- Original') { @@ -71,14 +71,14 @@ final class ColorConsoleDiffFormatter } private function makePlusLinesGreen(string $string) : string { - return \RectorPrefix20220607\Nette\Utils\Strings::replace($string, self::PLUS_START_REGEX, '$1'); + return Strings::replace($string, self::PLUS_START_REGEX, '$1'); } private function makeMinusLinesRed(string $string) : string { - return \RectorPrefix20220607\Nette\Utils\Strings::replace($string, self::MINUT_START_REGEX, '$1'); + return Strings::replace($string, self::MINUT_START_REGEX, '$1'); } private function makeAtNoteCyan(string $string) : string { - return \RectorPrefix20220607\Nette\Utils\Strings::replace($string, self::AT_START_REGEX, '$1'); + return Strings::replace($string, self::AT_START_REGEX, '$1'); } } diff --git a/vendor/symplify/package-builder/src/Console/Input/StaticInputDetector.php b/vendor/symplify/package-builder/src/Console/Input/StaticInputDetector.php index 48ba6c64b3a..dd9ceaf0c7e 100644 --- a/vendor/symplify/package-builder/src/Console/Input/StaticInputDetector.php +++ b/vendor/symplify/package-builder/src/Console/Input/StaticInputDetector.php @@ -11,7 +11,7 @@ final class StaticInputDetector { public static function isDebug() : bool { - $argvInput = new \RectorPrefix20220607\Symfony\Component\Console\Input\ArgvInput(); + $argvInput = new ArgvInput(); return $argvInput->hasParameterOption(['--debug', '-v', '-vv', '-vvv']); } } diff --git a/vendor/symplify/package-builder/src/Console/Output/ConsoleDiffer.php b/vendor/symplify/package-builder/src/Console/Output/ConsoleDiffer.php index 4b9d2646313..eda54894c2d 100644 --- a/vendor/symplify/package-builder/src/Console/Output/ConsoleDiffer.php +++ b/vendor/symplify/package-builder/src/Console/Output/ConsoleDiffer.php @@ -18,7 +18,7 @@ final class ConsoleDiffer * @var \Symplify\PackageBuilder\Console\Formatter\ColorConsoleDiffFormatter */ private $colorConsoleDiffFormatter; - public function __construct(\RectorPrefix20220607\SebastianBergmann\Diff\Differ $differ, \RectorPrefix20220607\Symplify\PackageBuilder\Console\Formatter\ColorConsoleDiffFormatter $colorConsoleDiffFormatter) + public function __construct(Differ $differ, ColorConsoleDiffFormatter $colorConsoleDiffFormatter) { $this->differ = $differ; $this->colorConsoleDiffFormatter = $colorConsoleDiffFormatter; diff --git a/vendor/symplify/package-builder/src/Console/Style/SymfonyStyleFactory.php b/vendor/symplify/package-builder/src/Console/Style/SymfonyStyleFactory.php index fe4298aad22..00988859257 100644 --- a/vendor/symplify/package-builder/src/Console/Style/SymfonyStyleFactory.php +++ b/vendor/symplify/package-builder/src/Console/Style/SymfonyStyleFactory.php @@ -21,26 +21,26 @@ final class SymfonyStyleFactory private $privatesCaller; public function __construct() { - $this->privatesCaller = new \RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller(); + $this->privatesCaller = new PrivatesCaller(); } - public function create() : \RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle + public function create() : SymfonyStyle { // to prevent missing argv indexes if (!isset($_SERVER['argv'])) { $_SERVER['argv'] = []; } - $argvInput = new \RectorPrefix20220607\Symfony\Component\Console\Input\ArgvInput(); - $consoleOutput = new \RectorPrefix20220607\Symfony\Component\Console\Output\ConsoleOutput(); + $argvInput = new ArgvInput(); + $consoleOutput = new ConsoleOutput(); // to configure all -v, -vv, -vvv options without memory-lock to Application run() arguments - $this->privatesCaller->callPrivateMethod(new \RectorPrefix20220607\Symfony\Component\Console\Application(), 'configureIO', [$argvInput, $consoleOutput]); + $this->privatesCaller->callPrivateMethod(new Application(), 'configureIO', [$argvInput, $consoleOutput]); // --debug is called if ($argvInput->hasParameterOption('--debug')) { - $consoleOutput->setVerbosity(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_DEBUG); + $consoleOutput->setVerbosity(OutputInterface::VERBOSITY_DEBUG); } // disable output for tests - if (\RectorPrefix20220607\Symplify\EasyTesting\PHPUnit\StaticPHPUnitEnvironment::isPHPUnitRun()) { - $consoleOutput->setVerbosity(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_QUIET); + if (StaticPHPUnitEnvironment::isPHPUnitRun()) { + $consoleOutput->setVerbosity(OutputInterface::VERBOSITY_QUIET); } - return new \RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle($argvInput, $consoleOutput); + return new SymfonyStyle($argvInput, $consoleOutput); } } diff --git a/vendor/symplify/package-builder/src/DependencyInjection/CompilerPass/AutowireInterfacesCompilerPass.php b/vendor/symplify/package-builder/src/DependencyInjection/CompilerPass/AutowireInterfacesCompilerPass.php index f46d7f234e3..b4a1d529e24 100644 --- a/vendor/symplify/package-builder/src/DependencyInjection/CompilerPass/AutowireInterfacesCompilerPass.php +++ b/vendor/symplify/package-builder/src/DependencyInjection/CompilerPass/AutowireInterfacesCompilerPass.php @@ -5,7 +5,7 @@ namespace RectorPrefix20220607\Symplify\PackageBuilder\DependencyInjection\Compi use RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder; -final class AutowireInterfacesCompilerPass implements \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface +final class AutowireInterfacesCompilerPass implements CompilerPassInterface { /** * @var string[] @@ -18,7 +18,7 @@ final class AutowireInterfacesCompilerPass implements \RectorPrefix20220607\Symf { $this->typesToAutowire = $typesToAutowire; } - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder) : void + public function process(ContainerBuilder $containerBuilder) : void { $definitions = $containerBuilder->getDefinitions(); foreach ($definitions as $definition) { diff --git a/vendor/symplify/package-builder/src/DependencyInjection/FileLoader/ParameterMergingPhpFileLoader.php b/vendor/symplify/package-builder/src/DependencyInjection/FileLoader/ParameterMergingPhpFileLoader.php index cc4582e7623..adcc5fb1af6 100644 --- a/vendor/symplify/package-builder/src/DependencyInjection/FileLoader/ParameterMergingPhpFileLoader.php +++ b/vendor/symplify/package-builder/src/DependencyInjection/FileLoader/ParameterMergingPhpFileLoader.php @@ -16,15 +16,15 @@ use RectorPrefix20220607\Symplify\PackageBuilder\Yaml\ParametersMerger; * * @property ContainerBuilder $container */ -final class ParameterMergingPhpFileLoader extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\PhpFileLoader +final class ParameterMergingPhpFileLoader extends PhpFileLoader { /** * @var \Symplify\PackageBuilder\Yaml\ParametersMerger */ private $parametersMerger; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder, \RectorPrefix20220607\Symfony\Component\Config\FileLocatorInterface $fileLocator) + public function __construct(ContainerBuilder $containerBuilder, FileLocatorInterface $fileLocator) { - $this->parametersMerger = new \RectorPrefix20220607\Symplify\PackageBuilder\Yaml\ParametersMerger(); + $this->parametersMerger = new ParametersMerger(); parent::__construct($containerBuilder, $fileLocator); } /** diff --git a/vendor/symplify/package-builder/src/Diff/Output/CompleteUnifiedDiffOutputBuilderFactory.php b/vendor/symplify/package-builder/src/Diff/Output/CompleteUnifiedDiffOutputBuilderFactory.php index 29c147950b4..5bda5371280 100644 --- a/vendor/symplify/package-builder/src/Diff/Output/CompleteUnifiedDiffOutputBuilderFactory.php +++ b/vendor/symplify/package-builder/src/Diff/Output/CompleteUnifiedDiffOutputBuilderFactory.php @@ -15,16 +15,16 @@ final class CompleteUnifiedDiffOutputBuilderFactory * @var \Symplify\PackageBuilder\Reflection\PrivatesAccessor */ private $privatesAccessor; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor $privatesAccessor) + public function __construct(PrivatesAccessor $privatesAccessor) { $this->privatesAccessor = $privatesAccessor; } /** * @api */ - public function create() : \RectorPrefix20220607\SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder + public function create() : UnifiedDiffOutputBuilder { - $unifiedDiffOutputBuilder = new \RectorPrefix20220607\SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder(''); + $unifiedDiffOutputBuilder = new UnifiedDiffOutputBuilder(''); $this->privatesAccessor->setPrivateProperty($unifiedDiffOutputBuilder, 'contextLines', 10000); return $unifiedDiffOutputBuilder; } diff --git a/vendor/symplify/package-builder/src/Exception/HttpKernel/MissingInterfaceException.php b/vendor/symplify/package-builder/src/Exception/HttpKernel/MissingInterfaceException.php index 35b834e02e8..e43ad54eb37 100644 --- a/vendor/symplify/package-builder/src/Exception/HttpKernel/MissingInterfaceException.php +++ b/vendor/symplify/package-builder/src/Exception/HttpKernel/MissingInterfaceException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\PackageBuilder\Exception\HttpKernel; use Exception; -final class MissingInterfaceException extends \Exception +final class MissingInterfaceException extends Exception { } diff --git a/vendor/symplify/package-builder/src/Exception/InvalidPrivatePropertyTypeException.php b/vendor/symplify/package-builder/src/Exception/InvalidPrivatePropertyTypeException.php index 967bc0ca464..99d649bf235 100644 --- a/vendor/symplify/package-builder/src/Exception/InvalidPrivatePropertyTypeException.php +++ b/vendor/symplify/package-builder/src/Exception/InvalidPrivatePropertyTypeException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\PackageBuilder\Exception; use Exception; -final class InvalidPrivatePropertyTypeException extends \Exception +final class InvalidPrivatePropertyTypeException extends Exception { } diff --git a/vendor/symplify/package-builder/src/Exception/MissingPrivatePropertyException.php b/vendor/symplify/package-builder/src/Exception/MissingPrivatePropertyException.php index dd4b8899b7d..addefed6238 100644 --- a/vendor/symplify/package-builder/src/Exception/MissingPrivatePropertyException.php +++ b/vendor/symplify/package-builder/src/Exception/MissingPrivatePropertyException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\PackageBuilder\Exception; use Exception; -final class MissingPrivatePropertyException extends \Exception +final class MissingPrivatePropertyException extends Exception { } diff --git a/vendor/symplify/package-builder/src/Parameter/ParameterProvider.php b/vendor/symplify/package-builder/src/Parameter/ParameterProvider.php index e40416d1f4e..0e8b7226a90 100644 --- a/vendor/symplify/package-builder/src/Parameter/ParameterProvider.php +++ b/vendor/symplify/package-builder/src/Parameter/ParameterProvider.php @@ -16,7 +16,7 @@ final class ParameterProvider * @var array */ private $parameters = []; - public function __construct(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface $container) + public function __construct(ContainerInterface $container) { /** @var ParameterBag $parameterBag */ $parameterBag = $container->getParameterBag(); @@ -89,6 +89,6 @@ final class ParameterProvider if (\array_key_exists($name, $this->parameters)) { return; } - throw new \RectorPrefix20220607\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException($name); + throw new ParameterNotFoundException($name); } } diff --git a/vendor/symplify/package-builder/src/Reflection/ClassLikeExistenceChecker.php b/vendor/symplify/package-builder/src/Reflection/ClassLikeExistenceChecker.php index 67e70591200..274e561f154 100644 --- a/vendor/symplify/package-builder/src/Reflection/ClassLikeExistenceChecker.php +++ b/vendor/symplify/package-builder/src/Reflection/ClassLikeExistenceChecker.php @@ -39,7 +39,7 @@ final class ClassLikeExistenceChecker if (\in_array($classLikeName, $this->sensitiveNonExistingClasses, \true)) { return \false; } - $reflectionClass = new \ReflectionClass($classLikeName); + $reflectionClass = new ReflectionClass($classLikeName); if ($classLikeName !== $reflectionClass->getName()) { $this->sensitiveNonExistingClasses[] = $classLikeName; return \false; diff --git a/vendor/symplify/package-builder/src/Reflection/PrivatesAccessor.php b/vendor/symplify/package-builder/src/Reflection/PrivatesAccessor.php index c2cdf934b31..d44167e088d 100644 --- a/vendor/symplify/package-builder/src/Reflection/PrivatesAccessor.php +++ b/vendor/symplify/package-builder/src/Reflection/PrivatesAccessor.php @@ -25,7 +25,7 @@ final class PrivatesAccessor return $value; } $errorMessage = \sprintf('The type "%s" is required, but "%s" type given', $valueClassName, \get_class($value)); - throw new \RectorPrefix20220607\Symplify\PackageBuilder\Exception\InvalidPrivatePropertyTypeException($errorMessage); + throw new InvalidPrivatePropertyTypeException($errorMessage); } /** * @return mixed @@ -49,7 +49,7 @@ final class PrivatesAccessor return; } $errorMessage = \sprintf('The type "%s" is required, but "%s" type given', $valueClassName, \get_class($value)); - throw new \RectorPrefix20220607\Symplify\PackageBuilder\Exception\InvalidPrivatePropertyTypeException($errorMessage); + throw new InvalidPrivatePropertyTypeException($errorMessage); } /** * @param mixed $value @@ -60,16 +60,16 @@ final class PrivatesAccessor $propertyReflection->setAccessible(\true); $propertyReflection->setValue($object, $value); } - private function resolvePropertyReflection(object $object, string $propertyName) : \ReflectionProperty + private function resolvePropertyReflection(object $object, string $propertyName) : ReflectionProperty { if (\property_exists($object, $propertyName)) { - return new \ReflectionProperty($object, $propertyName); + return new ReflectionProperty($object, $propertyName); } $parentClass = \get_parent_class($object); if ($parentClass !== \false) { - return new \ReflectionProperty($parentClass, $propertyName); + return new ReflectionProperty($parentClass, $propertyName); } $errorMessage = \sprintf('Property "$%s" was not found in "%s" class', $propertyName, \get_class($object)); - throw new \RectorPrefix20220607\Symplify\PackageBuilder\Exception\MissingPrivatePropertyException($errorMessage); + throw new MissingPrivatePropertyException($errorMessage); } } diff --git a/vendor/symplify/package-builder/src/Reflection/PrivatesCaller.php b/vendor/symplify/package-builder/src/Reflection/PrivatesCaller.php index f8376014b8a..8346610cb3f 100644 --- a/vendor/symplify/package-builder/src/Reflection/PrivatesCaller.php +++ b/vendor/symplify/package-builder/src/Reflection/PrivatesCaller.php @@ -18,7 +18,7 @@ final class PrivatesCaller public function callPrivateMethod($object, string $methodName, array $arguments) { if (\is_string($object)) { - $reflectionClass = new \ReflectionClass($object); + $reflectionClass = new ReflectionClass($object); $object = $reflectionClass->newInstanceWithoutConstructor(); } $methodReflection = $this->createAccessibleMethodReflection($object, $methodName); @@ -32,16 +32,16 @@ final class PrivatesCaller public function callPrivateMethodWithReference($object, string $methodName, $argument) { if (\is_string($object)) { - $reflectionClass = new \ReflectionClass($object); + $reflectionClass = new ReflectionClass($object); $object = $reflectionClass->newInstanceWithoutConstructor(); } $methodReflection = $this->createAccessibleMethodReflection($object, $methodName); $methodReflection->invokeArgs($object, [&$argument]); return $argument; } - private function createAccessibleMethodReflection(object $object, string $methodName) : \ReflectionMethod + private function createAccessibleMethodReflection(object $object, string $methodName) : ReflectionMethod { - $reflectionMethod = new \ReflectionMethod(\get_class($object), $methodName); + $reflectionMethod = new ReflectionMethod(\get_class($object), $methodName); $reflectionMethod->setAccessible(\true); return $reflectionMethod; } diff --git a/vendor/symplify/package-builder/src/Strings/StringFormatConverter.php b/vendor/symplify/package-builder/src/Strings/StringFormatConverter.php index 8ebef8e2f33..f5fce5260a6 100644 --- a/vendor/symplify/package-builder/src/Strings/StringFormatConverter.php +++ b/vendor/symplify/package-builder/src/Strings/StringFormatConverter.php @@ -51,7 +51,7 @@ final class StringFormatConverter } private function camelCaseToGlue(string $input, string $glue) : string { - $matches = \RectorPrefix20220607\Nette\Utils\Strings::matchAll($input, self::BIG_LETTER_REGEX); + $matches = Strings::matchAll($input, self::BIG_LETTER_REGEX); $parts = []; foreach ($matches as $match) { $parts[] = $match[0] === \strtoupper($match[0]) ? \strtolower($match[0]) : \lcfirst($match[0]); diff --git a/vendor/symplify/package-builder/src/Testing/AbstractKernelTestCase.php b/vendor/symplify/package-builder/src/Testing/AbstractKernelTestCase.php index 6a0f35fa9f4..316cebc6206 100644 --- a/vendor/symplify/package-builder/src/Testing/AbstractKernelTestCase.php +++ b/vendor/symplify/package-builder/src/Testing/AbstractKernelTestCase.php @@ -1,35 +1,39 @@ $kernelClass * @param string[]|SmartFileInfo[] $configs @@ -40,12 +44,17 @@ abstract class AbstractKernelTestCase extends \RectorPrefix20220607\PHPUnit\Fram // unwrap file infos to real paths $configFilePaths = $this->resolveConfigFilePaths($configs); $configsHash = $this->resolveConfigsHash($configFilePaths); + $this->ensureKernelShutdown(); + $bootedKernel = $this->createBootedKernelFromConfigs($kernelClass, $configsHash, $configFilePaths); + static::$kernel = $bootedKernel; self::$container = $bootedKernel->getContainer(); + return $bootedKernel; } + /** * Syntax sugger to remove static from the test cases vision * @@ -53,132 +62,169 @@ abstract class AbstractKernelTestCase extends \RectorPrefix20220607\PHPUnit\Fram * @param class-string $type * @return T */ - protected function getService(string $type) : object + protected function getService(string $type): object { if (self::$container === null) { - throw new \RectorPrefix20220607\Symplify\SymplifyKernel\Exception\ShouldNotHappenException('First, create container with booKernel(KernelClass::class)'); + throw new ShouldNotHappenException('First, create container with booKernel(KernelClass::class)'); } + $service = self::$container->get($type); if ($service === null) { - $errorMessage = \sprintf('Services "%s" was not found', $type); - throw new \RectorPrefix20220607\Symplify\Astral\Exception\ShouldNotHappenException($errorMessage); + $errorMessage = sprintf('Services "%s" was not found', $type); + throw new \Symplify\Astral\Exception\ShouldNotHappenException($errorMessage); } + return $service; } + /** * @param class-string $kernelClass */ - protected function bootKernel(string $kernelClass) : void + protected function bootKernel(string $kernelClass): void { - if (\is_a($kernelClass, \RectorPrefix20220607\Symplify\SymplifyKernel\Contract\LightKernelInterface::class, \true)) { + if (is_a($kernelClass, LightKernelInterface::class, true)) { /** @var LightKernelInterface $kernel */ $kernel = new $kernelClass(); $kernel->createFromConfigs([]); + static::$kernel = $kernel; self::$container = $kernel->getContainer(); return; } + $this->ensureKernelShutdown(); - $kernel = new $kernelClass('test', \true); - if (!$kernel instanceof \RectorPrefix20220607\Symfony\Component\HttpKernel\KernelInterface) { - throw new \RectorPrefix20220607\Symplify\SymplifyKernel\Exception\ShouldNotHappenException(); + + $kernel = new $kernelClass('test', true); + if (! $kernel instanceof KernelInterface) { + throw new ShouldNotHappenException(); } + static::$kernel = $this->bootAndReturnKernel($kernel); } + /** * Shuts the kernel down if it was used in the test. */ - protected function ensureKernelShutdown() : void + protected function ensureKernelShutdown(): void { - if (static::$kernel !== null && static::$kernel instanceof \RectorPrefix20220607\Symfony\Component\HttpKernel\KernelInterface) { + if (static::$kernel !== null && static::$kernel instanceof KernelInterface) { // make sure boot() is called // @see https://github.com/symfony/symfony/pull/31202/files - $kernelReflectionClass = new \ReflectionClass(static::$kernel); + $kernelReflectionClass = new ReflectionClass(static::$kernel); + $containerReflectionProperty = $kernelReflectionClass->getProperty('container'); - $containerReflectionProperty->setAccessible(\true); + $containerReflectionProperty->setAccessible(true); + $kernel = $containerReflectionProperty->getValue(static::$kernel); if ($kernel !== null) { $container = static::$kernel->getContainer(); static::$kernel->shutdown(); - if ($container instanceof \RectorPrefix20220607\Symfony\Contracts\Service\ResetInterface) { + if ($container instanceof ResetInterface) { $container->reset(); } } } + static::$container = null; } + /** * @param string[] $configs */ - protected function resolveConfigsHash(array $configs) : string + protected function resolveConfigsHash(array $configs): string { $configsHash = ''; foreach ($configs as $config) { - $configsHash .= \md5_file($config); + $configsHash .= md5_file($config); } - return \md5($configsHash); + + return md5($configsHash); } + /** * @param string[]|SmartFileInfo[] $configs * @return string[] */ - protected function resolveConfigFilePaths(array $configs) : array + protected function resolveConfigFilePaths(array $configs): array { $configFilePaths = []; + foreach ($configs as $config) { - $configFilePaths[] = $config instanceof \Symplify\SmartFileSystem\SmartFileInfo ? $config->getRealPath() : $config; + $configFilePaths[] = $config instanceof SmartFileInfo ? $config->getRealPath() : $config; } + return $configFilePaths; } + /** * @param \Symfony\Component\HttpKernel\KernelInterface|\Symplify\SymplifyKernel\Contract\LightKernelInterface $kernel */ - private function ensureIsConfigAwareKernel($kernel) : void + private function ensureIsConfigAwareKernel($kernel): void { - if ($kernel instanceof \RectorPrefix20220607\Symplify\SymplifyKernel\Contract\LightKernelInterface) { + if ($kernel instanceof LightKernelInterface) { return; } - if ($kernel instanceof \RectorPrefix20220607\Symplify\PackageBuilder\Contract\HttpKernel\ExtraConfigAwareKernelInterface) { + + if ($kernel instanceof ExtraConfigAwareKernelInterface) { return; } - throw new \RectorPrefix20220607\Symplify\PackageBuilder\Exception\HttpKernel\MissingInterfaceException(\sprintf('"%s" is missing an "%s" interface', \get_class($kernel), \RectorPrefix20220607\Symplify\PackageBuilder\Contract\HttpKernel\ExtraConfigAwareKernelInterface::class)); + + throw new MissingInterfaceException(sprintf( + '"%s" is missing an "%s" interface', + get_class($kernel), + ExtraConfigAwareKernelInterface::class + )); } - private function bootAndReturnKernel(\RectorPrefix20220607\Symfony\Component\HttpKernel\KernelInterface $kernel) : \RectorPrefix20220607\Symfony\Component\HttpKernel\KernelInterface + + private function bootAndReturnKernel(KernelInterface $kernel): KernelInterface { $kernel->boot(); + $container = $kernel->getContainer(); + // private → public service hack? if ($container->has('test.service_container')) { $container = $container->get('test.service_container'); } - if (!$container instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface) { - throw new \RectorPrefix20220607\Symplify\SymplifyKernel\Exception\ShouldNotHappenException(); + + if (! $container instanceof ContainerInterface) { + throw new ShouldNotHappenException(); } + // has output? keep it silent out of tests - if ($container->has(\RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle::class)) { - $symfonyStyle = $container->get(\RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle::class); - $symfonyStyle->setVerbosity(\RectorPrefix20220607\Symfony\Component\Console\Output\OutputInterface::VERBOSITY_QUIET); + if ($container->has(SymfonyStyle::class)) { + $symfonyStyle = $container->get(SymfonyStyle::class); + $symfonyStyle->setVerbosity(OutputInterface::VERBOSITY_QUIET); } + static::$container = $container; + return $kernel; } + /** * @param class-string $kernelClass * @param string[] $configFilePaths * @return \Symfony\Component\HttpKernel\KernelInterface|\Symplify\SymplifyKernel\Contract\LightKernelInterface */ - private function createBootedKernelFromConfigs(string $kernelClass, string $configsHash, array $configFilePaths) - { - if (\is_a($kernelClass, \RectorPrefix20220607\Symplify\SymplifyKernel\Contract\LightKernelInterface::class, \true)) { + private function createBootedKernelFromConfigs( + string $kernelClass, + string $configsHash, + array $configFilePaths + ) { + if (is_a($kernelClass, LightKernelInterface::class, true)) { /** @var LightKernelInterface $kernel */ $kernel = new $kernelClass(); $kernel->createFromConfigs($configFilePaths); return $kernel; } - $kernel = new $kernelClass('test_' . $configsHash, \true); + + $kernel = new $kernelClass('test_' . $configsHash, true); $this->ensureIsConfigAwareKernel($kernel); + /** @var ExtraConfigAwareKernelInterface $kernel */ $kernel->setConfigs($configFilePaths); + return $this->bootAndReturnKernel($kernel); } } diff --git a/vendor/symplify/rule-doc-generator-contracts/composer.json b/vendor/symplify/rule-doc-generator-contracts/composer.json index 75372221e53..c9e321c2068 100644 --- a/vendor/symplify/rule-doc-generator-contracts/composer.json +++ b/vendor/symplify/rule-doc-generator-contracts/composer.json @@ -8,7 +8,7 @@ }, "autoload": { "psr-4": { - "Symplify\\RuleDocGenerator\\": "src" + "RectorPrefix20220607\\Symplify\\RuleDocGenerator\\": "src" } }, "extra": { @@ -17,27 +17,27 @@ } }, "conflict": { - "symplify\/astral": "<10.2.10", - "symplify\/composer-json-manipulator": "<10.2.10", - "symplify\/easy-coding-standard": "<10.2.10", - "symplify\/phpstan-rules": "<10.2.10", - "symplify\/easy-testing": "<10.2.10", - "symplify\/php-config-printer": "<10.2.10", - "symplify\/autowire-array-parameter": "<10.2.10", - "symplify\/package-builder": "<10.2.10", - "symplify\/phpstan-extensions": "<10.2.10", - "symplify\/rule-doc-generator": "<10.2.10", - "symplify\/vendor-patches": "<10.2.10", - "symplify\/skipper": "<10.2.10", - "symplify\/smart-file-system": "<10.2.10", - "symplify\/symfony-static-dumper": "<10.2.10", - "symplify\/symplify-kernel": "<10.2.10", - "symplify\/monorepo-builder": "<10.2.10", - "symplify\/config-transformer": "<10.2.10", - "symplify\/easy-ci": "<10.2.10", - "symplify\/coding-standard": "<10.2.10", - "symplify\/easy-parallel": "<10.2.10", - "symplify\/neon-config-dumper": "<10.2.10" + "symplify\/astral": "<10.2.11", + "symplify\/composer-json-manipulator": "<10.2.11", + "symplify\/easy-coding-standard": "<10.2.11", + "symplify\/phpstan-rules": "<10.2.11", + "symplify\/easy-testing": "<10.2.11", + "symplify\/php-config-printer": "<10.2.11", + "symplify\/autowire-array-parameter": "<10.2.11", + "symplify\/package-builder": "<10.2.11", + "symplify\/phpstan-extensions": "<10.2.11", + "symplify\/rule-doc-generator": "<10.2.11", + "symplify\/vendor-patches": "<10.2.11", + "symplify\/skipper": "<10.2.11", + "symplify\/smart-file-system": "<10.2.11", + "symplify\/symfony-static-dumper": "<10.2.11", + "symplify\/symplify-kernel": "<10.2.11", + "symplify\/monorepo-builder": "<10.2.11", + "symplify\/config-transformer": "<10.2.11", + "symplify\/easy-ci": "<10.2.11", + "symplify\/coding-standard": "<10.2.11", + "symplify\/easy-parallel": "<10.2.11", + "symplify\/neon-config-dumper": "<10.2.11" }, "minimum-stability": "dev", "prefer-stable": true diff --git a/vendor/symplify/rule-doc-generator-contracts/src/Contract/Category/CategoryInfererInterface.php b/vendor/symplify/rule-doc-generator-contracts/src/Contract/Category/CategoryInfererInterface.php index 225825ffa95..3718b821e6d 100644 --- a/vendor/symplify/rule-doc-generator-contracts/src/Contract/Category/CategoryInfererInterface.php +++ b/vendor/symplify/rule-doc-generator-contracts/src/Contract/Category/CategoryInfererInterface.php @@ -1,10 +1,10 @@ goodCode = $goodCode; $this->badCode = $badCode; diff --git a/vendor/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/CodeSample.php b/vendor/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/CodeSample.php index a6b97682da6..9a5ad2291b4 100644 --- a/vendor/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/CodeSample.php +++ b/vendor/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/CodeSample.php @@ -1,12 +1,12 @@ configuration = $configuration; parent::__construct($badCode, $goodCode); diff --git a/vendor/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/ExtraFileCodeSample.php b/vendor/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/ExtraFileCodeSample.php index 92c907f9738..ed5f1355f63 100644 --- a/vendor/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/ExtraFileCodeSample.php +++ b/vendor/symplify/rule-doc-generator-contracts/src/ValueObject/CodeSample/ExtraFileCodeSample.php @@ -1,10 +1,10 @@ description = $description; if ($codeSamples === []) { - throw new \Symplify\RuleDocGenerator\Exception\PoorDocumentationException('Provide at least one code sample, so people can practically see what the rule does'); + throw new PoorDocumentationException('Provide at least one code sample, so people can practically see what the rule does'); } $this->codeSamples = $codeSamples; } @@ -48,7 +48,7 @@ final class RuleDefinition public function getRuleClass() : string { if ($this->ruleClass === null) { - throw new \Symplify\RuleDocGenerator\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } return $this->ruleClass; } @@ -60,16 +60,16 @@ final class RuleDefinition public function getRuleFilePath() : string { if ($this->ruleFilePath === null) { - throw new \Symplify\RuleDocGenerator\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } return $this->ruleFilePath; } public function getRuleShortClass() : string { if ($this->ruleClass === null) { - throw new \Symplify\RuleDocGenerator\Exception\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } - return (string) \RectorPrefix20220607\Nette\Utils\Strings::after($this->ruleClass, '\\', -1); + return (string) Strings::after($this->ruleClass, '\\', -1); } /** * @return CodeSampleInterface[] @@ -81,7 +81,7 @@ final class RuleDefinition public function isConfigurable() : bool { foreach ($this->codeSamples as $codeSample) { - if ($codeSample instanceof \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample) { + if ($codeSample instanceof ConfiguredCodeSample) { return \true; } } diff --git a/vendor/symplify/skipper/composer.json b/vendor/symplify/skipper/composer.json index 61ec0a5ba2e..65c0fa21c77 100644 --- a/vendor/symplify/skipper/composer.json +++ b/vendor/symplify/skipper/composer.json @@ -9,9 +9,9 @@ "symfony\/dependency-injection": "^6.0", "symfony\/finder": "^6.0", "symfony\/filesystem": "^6.0", - "symplify\/package-builder": "^10.2.10", - "symplify\/symplify-kernel": "^10.2.10", - "symplify\/smart-file-system": "^10.2.10" + "symplify\/package-builder": "^10.2.11", + "symplify\/symplify-kernel": "^10.2.11", + "symplify\/smart-file-system": "^10.2.11" }, "require-dev": { "phpunit\/phpunit": "^9.5" @@ -32,24 +32,24 @@ } }, "conflict": { - "symplify\/astral": "<10.2.10", - "symplify\/composer-json-manipulator": "<10.2.10", - "symplify\/easy-coding-standard": "<10.2.10", - "symplify\/phpstan-rules": "<10.2.10", - "symplify\/easy-testing": "<10.2.10", - "symplify\/rule-doc-generator-contracts": "<10.2.10", - "symplify\/php-config-printer": "<10.2.10", - "symplify\/autowire-array-parameter": "<10.2.10", - "symplify\/phpstan-extensions": "<10.2.10", - "symplify\/rule-doc-generator": "<10.2.10", - "symplify\/vendor-patches": "<10.2.10", - "symplify\/symfony-static-dumper": "<10.2.10", - "symplify\/monorepo-builder": "<10.2.10", - "symplify\/config-transformer": "<10.2.10", - "symplify\/easy-ci": "<10.2.10", - "symplify\/coding-standard": "<10.2.10", - "symplify\/easy-parallel": "<10.2.10", - "symplify\/neon-config-dumper": "<10.2.10" + "symplify\/astral": "<10.2.11", + "symplify\/composer-json-manipulator": "<10.2.11", + "symplify\/easy-coding-standard": "<10.2.11", + "symplify\/phpstan-rules": "<10.2.11", + "symplify\/easy-testing": "<10.2.11", + "symplify\/rule-doc-generator-contracts": "<10.2.11", + "symplify\/php-config-printer": "<10.2.11", + "symplify\/autowire-array-parameter": "<10.2.11", + "symplify\/phpstan-extensions": "<10.2.11", + "symplify\/rule-doc-generator": "<10.2.11", + "symplify\/vendor-patches": "<10.2.11", + "symplify\/symfony-static-dumper": "<10.2.11", + "symplify\/monorepo-builder": "<10.2.11", + "symplify\/config-transformer": "<10.2.11", + "symplify\/easy-ci": "<10.2.11", + "symplify\/coding-standard": "<10.2.11", + "symplify\/easy-parallel": "<10.2.11", + "symplify\/neon-config-dumper": "<10.2.11" }, "minimum-stability": "dev", "prefer-stable": true diff --git a/vendor/symplify/skipper/config/config.php b/vendor/symplify/skipper/config/config.php index 9e05288c322..e7079546e3a 100644 --- a/vendor/symplify/skipper/config/config.php +++ b/vendor/symplify/skipper/config/config.php @@ -3,17 +3,17 @@ declare (strict_types=1); namespace RectorPrefix20220607; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use RectorPrefix20220607\Symplify\PackageBuilder\Reflection\ClassLikeExistenceChecker; use RectorPrefix20220607\Symplify\Skipper\ValueObject\Option; use RectorPrefix20220607\Symplify\SmartFileSystem\Normalizer\PathNormalizer; -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +return static function (ContainerConfigurator $containerConfigurator) : void { $parameters = $containerConfigurator->parameters(); - $parameters->set(\RectorPrefix20220607\Symplify\Skipper\ValueObject\Option::SKIP, []); - $parameters->set(\RectorPrefix20220607\Symplify\Skipper\ValueObject\Option::ONLY, []); + $parameters->set(Option::SKIP, []); + $parameters->set(Option::ONLY, []); $services = $containerConfigurator->services(); $services->defaults()->public()->autowire(); $services->load('RectorPrefix20220607\Symplify\\Skipper\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/ValueObject']); - $services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Reflection\ClassLikeExistenceChecker::class); - $services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\Normalizer\PathNormalizer::class); + $services->set(ClassLikeExistenceChecker::class); + $services->set(PathNormalizer::class); }; diff --git a/vendor/symplify/skipper/src/Contract/SkipVoterInterface.php b/vendor/symplify/skipper/src/Contract/SkipVoterInterface.php index aa5fc021c70..d89d35afc53 100644 --- a/vendor/symplify/skipper/src/Contract/SkipVoterInterface.php +++ b/vendor/symplify/skipper/src/Contract/SkipVoterInterface.php @@ -3,7 +3,7 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\Skipper\Contract; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; interface SkipVoterInterface { /** @@ -13,5 +13,5 @@ interface SkipVoterInterface /** * @param string|object $element */ - public function shouldSkip($element, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : bool; + public function shouldSkip($element, SmartFileInfo $smartFileInfo) : bool; } diff --git a/vendor/symplify/skipper/src/FileSystem/FnMatchPathNormalizer.php b/vendor/symplify/skipper/src/FileSystem/FnMatchPathNormalizer.php index 6863216c35a..c71472c9d30 100644 --- a/vendor/symplify/skipper/src/FileSystem/FnMatchPathNormalizer.php +++ b/vendor/symplify/skipper/src/FileSystem/FnMatchPathNormalizer.php @@ -22,11 +22,11 @@ final class FnMatchPathNormalizer public function normalizeForFnmatch(string $path) : string { // ends with * - if (\RectorPrefix20220607\Nette\Utils\Strings::match($path, self::ONLY_ENDS_WITH_ASTERISK_REGEX)) { + if (Strings::match($path, self::ONLY_ENDS_WITH_ASTERISK_REGEX)) { return '*' . $path; } // starts with * - if (\RectorPrefix20220607\Nette\Utils\Strings::match($path, self::ONLY_STARTS_WITH_ASTERISK_REGEX)) { + if (Strings::match($path, self::ONLY_STARTS_WITH_ASTERISK_REGEX)) { return $path . '*'; } if (\strpos($path, '..') !== \false) { diff --git a/vendor/symplify/skipper/src/Matcher/FileInfoMatcher.php b/vendor/symplify/skipper/src/Matcher/FileInfoMatcher.php index 1a4991817e4..929133a2832 100644 --- a/vendor/symplify/skipper/src/Matcher/FileInfoMatcher.php +++ b/vendor/symplify/skipper/src/Matcher/FileInfoMatcher.php @@ -4,21 +4,21 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\Skipper\Matcher; use RectorPrefix20220607\Symplify\Skipper\FileSystem\FnMatchPathNormalizer; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; final class FileInfoMatcher { /** * @var \Symplify\Skipper\FileSystem\FnMatchPathNormalizer */ private $fnMatchPathNormalizer; - public function __construct(\RectorPrefix20220607\Symplify\Skipper\FileSystem\FnMatchPathNormalizer $fnMatchPathNormalizer) + public function __construct(FnMatchPathNormalizer $fnMatchPathNormalizer) { $this->fnMatchPathNormalizer = $fnMatchPathNormalizer; } /** * @param string[] $filePatterns */ - public function doesFileInfoMatchPatterns(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo, array $filePatterns) : bool + public function doesFileInfoMatchPatterns(SmartFileInfo $smartFileInfo, array $filePatterns) : bool { foreach ($filePatterns as $filePattern) { if ($this->doesFileInfoMatchPattern($smartFileInfo, $filePattern)) { @@ -30,7 +30,7 @@ final class FileInfoMatcher /** * Supports both relative and absolute $file path. They differ for PHP-CS-Fixer and PHP_CodeSniffer. */ - private function doesFileInfoMatchPattern(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo, string $ignoredPath) : bool + private function doesFileInfoMatchPattern(SmartFileInfo $smartFileInfo, string $ignoredPath) : bool { // in ecs.php, the path can be absolute if ($smartFileInfo->getRealPath() === $ignoredPath) { diff --git a/vendor/symplify/skipper/src/SkipCriteriaResolver/SkippedClassAndCodesResolver.php b/vendor/symplify/skipper/src/SkipCriteriaResolver/SkippedClassAndCodesResolver.php index 74c4750d857..2484a044e14 100644 --- a/vendor/symplify/skipper/src/SkipCriteriaResolver/SkippedClassAndCodesResolver.php +++ b/vendor/symplify/skipper/src/SkipCriteriaResolver/SkippedClassAndCodesResolver.php @@ -15,7 +15,7 @@ final class SkippedClassAndCodesResolver * @var \Symplify\PackageBuilder\Parameter\ParameterProvider */ private $parameterProvider; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider) + public function __construct(ParameterProvider $parameterProvider) { $this->parameterProvider = $parameterProvider; } @@ -27,7 +27,7 @@ final class SkippedClassAndCodesResolver if ($this->skippedClassAndCodes !== []) { return $this->skippedClassAndCodes; } - $skip = $this->parameterProvider->provideArrayParameter(\RectorPrefix20220607\Symplify\Skipper\ValueObject\Option::SKIP); + $skip = $this->parameterProvider->provideArrayParameter(Option::SKIP); foreach ($skip as $key => $value) { // e.g. [SomeClass::class] → shift values to [SomeClass::class => null] if (\is_int($key)) { diff --git a/vendor/symplify/skipper/src/SkipCriteriaResolver/SkippedClassResolver.php b/vendor/symplify/skipper/src/SkipCriteriaResolver/SkippedClassResolver.php index 8c397688a5b..3dc41b24ed1 100644 --- a/vendor/symplify/skipper/src/SkipCriteriaResolver/SkippedClassResolver.php +++ b/vendor/symplify/skipper/src/SkipCriteriaResolver/SkippedClassResolver.php @@ -20,7 +20,7 @@ final class SkippedClassResolver * @var \Symplify\PackageBuilder\Reflection\ClassLikeExistenceChecker */ private $classLikeExistenceChecker; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \RectorPrefix20220607\Symplify\PackageBuilder\Reflection\ClassLikeExistenceChecker $classLikeExistenceChecker) + public function __construct(ParameterProvider $parameterProvider, ClassLikeExistenceChecker $classLikeExistenceChecker) { $this->parameterProvider = $parameterProvider; $this->classLikeExistenceChecker = $classLikeExistenceChecker; @@ -33,7 +33,7 @@ final class SkippedClassResolver if ($this->skippedClasses !== []) { return $this->skippedClasses; } - $skip = $this->parameterProvider->provideArrayParameter(\RectorPrefix20220607\Symplify\Skipper\ValueObject\Option::SKIP); + $skip = $this->parameterProvider->provideArrayParameter(Option::SKIP); foreach ($skip as $key => $value) { // e.g. [SomeClass::class] → shift values to [SomeClass::class => null] if (\is_int($key)) { diff --git a/vendor/symplify/skipper/src/SkipCriteriaResolver/SkippedMessagesResolver.php b/vendor/symplify/skipper/src/SkipCriteriaResolver/SkippedMessagesResolver.php index f9d34f7afb3..62983e8a07e 100644 --- a/vendor/symplify/skipper/src/SkipCriteriaResolver/SkippedMessagesResolver.php +++ b/vendor/symplify/skipper/src/SkipCriteriaResolver/SkippedMessagesResolver.php @@ -15,7 +15,7 @@ final class SkippedMessagesResolver * @var \Symplify\PackageBuilder\Parameter\ParameterProvider */ private $parameterProvider; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider) + public function __construct(ParameterProvider $parameterProvider) { $this->parameterProvider = $parameterProvider; } @@ -27,7 +27,7 @@ final class SkippedMessagesResolver if ($this->skippedMessages !== []) { return $this->skippedMessages; } - $skip = $this->parameterProvider->provideArrayParameter(\RectorPrefix20220607\Symplify\Skipper\ValueObject\Option::SKIP); + $skip = $this->parameterProvider->provideArrayParameter(Option::SKIP); foreach ($skip as $key => $value) { // e.g. [SomeClass::class] → shift values to [SomeClass::class => null] if (\is_int($key)) { diff --git a/vendor/symplify/skipper/src/SkipCriteriaResolver/SkippedPathsResolver.php b/vendor/symplify/skipper/src/SkipCriteriaResolver/SkippedPathsResolver.php index 6579c27ae20..d290351bc60 100644 --- a/vendor/symplify/skipper/src/SkipCriteriaResolver/SkippedPathsResolver.php +++ b/vendor/symplify/skipper/src/SkipCriteriaResolver/SkippedPathsResolver.php @@ -23,7 +23,7 @@ final class SkippedPathsResolver * @var \Symplify\SmartFileSystem\Normalizer\PathNormalizer */ private $pathNormalizer; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \RectorPrefix20220607\Symplify\SmartFileSystem\Normalizer\PathNormalizer $pathNormalizer) + public function __construct(ParameterProvider $parameterProvider, PathNormalizer $pathNormalizer) { $this->parameterProvider = $parameterProvider; $this->pathNormalizer = $pathNormalizer; @@ -36,7 +36,7 @@ final class SkippedPathsResolver if ($this->skippedPaths !== []) { return $this->skippedPaths; } - $skip = $this->parameterProvider->provideArrayParameter(\RectorPrefix20220607\Symplify\Skipper\ValueObject\Option::SKIP); + $skip = $this->parameterProvider->provideArrayParameter(Option::SKIP); foreach ($skip as $key => $value) { if (!\is_int($key)) { continue; diff --git a/vendor/symplify/skipper/src/SkipVoter/ClassAndCodeSkipVoter.php b/vendor/symplify/skipper/src/SkipVoter/ClassAndCodeSkipVoter.php index 758ae849639..306d78d011f 100644 --- a/vendor/symplify/skipper/src/SkipVoter/ClassAndCodeSkipVoter.php +++ b/vendor/symplify/skipper/src/SkipVoter/ClassAndCodeSkipVoter.php @@ -6,11 +6,11 @@ namespace RectorPrefix20220607\Symplify\Skipper\SkipVoter; use RectorPrefix20220607\Symplify\Skipper\Contract\SkipVoterInterface; use RectorPrefix20220607\Symplify\Skipper\Matcher\FileInfoMatcher; use RectorPrefix20220607\Symplify\Skipper\SkipCriteriaResolver\SkippedClassAndCodesResolver; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; /** * Matching class and code, e.g. App\Category\ArraySniff.SomeCode */ -final class ClassAndCodeSkipVoter implements \RectorPrefix20220607\Symplify\Skipper\Contract\SkipVoterInterface +final class ClassAndCodeSkipVoter implements SkipVoterInterface { /** * @var \Symplify\Skipper\SkipCriteriaResolver\SkippedClassAndCodesResolver @@ -20,7 +20,7 @@ final class ClassAndCodeSkipVoter implements \RectorPrefix20220607\Symplify\Skip * @var \Symplify\Skipper\Matcher\FileInfoMatcher */ private $fileInfoMatcher; - public function __construct(\RectorPrefix20220607\Symplify\Skipper\SkipCriteriaResolver\SkippedClassAndCodesResolver $skippedClassAndCodesResolver, \RectorPrefix20220607\Symplify\Skipper\Matcher\FileInfoMatcher $fileInfoMatcher) + public function __construct(SkippedClassAndCodesResolver $skippedClassAndCodesResolver, FileInfoMatcher $fileInfoMatcher) { $this->skippedClassAndCodesResolver = $skippedClassAndCodesResolver; $this->fileInfoMatcher = $fileInfoMatcher; @@ -38,7 +38,7 @@ final class ClassAndCodeSkipVoter implements \RectorPrefix20220607\Symplify\Skip /** * @param string|object $element */ - public function shouldSkip($element, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : bool + public function shouldSkip($element, SmartFileInfo $smartFileInfo) : bool { if (\is_object($element)) { return \false; diff --git a/vendor/symplify/skipper/src/SkipVoter/ClassSkipVoter.php b/vendor/symplify/skipper/src/SkipVoter/ClassSkipVoter.php index 0ecc3d7339a..54ccb74f427 100644 --- a/vendor/symplify/skipper/src/SkipVoter/ClassSkipVoter.php +++ b/vendor/symplify/skipper/src/SkipVoter/ClassSkipVoter.php @@ -10,8 +10,8 @@ use RectorPrefix20220607\Symplify\Skipper\SkipCriteriaResolver\SkippedClassResol use RectorPrefix20220607\Symplify\Skipper\Skipper\OnlySkipper; use RectorPrefix20220607\Symplify\Skipper\Skipper\SkipSkipper; use RectorPrefix20220607\Symplify\Skipper\ValueObject\Option; -use Symplify\SmartFileSystem\SmartFileInfo; -final class ClassSkipVoter implements \RectorPrefix20220607\Symplify\Skipper\Contract\SkipVoterInterface +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; +final class ClassSkipVoter implements SkipVoterInterface { /** * @var \Symplify\PackageBuilder\Reflection\ClassLikeExistenceChecker @@ -33,7 +33,7 @@ final class ClassSkipVoter implements \RectorPrefix20220607\Symplify\Skipper\Con * @var \Symplify\Skipper\SkipCriteriaResolver\SkippedClassResolver */ private $skippedClassResolver; - public function __construct(\RectorPrefix20220607\Symplify\PackageBuilder\Reflection\ClassLikeExistenceChecker $classLikeExistenceChecker, \RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \RectorPrefix20220607\Symplify\Skipper\Skipper\SkipSkipper $skipSkipper, \RectorPrefix20220607\Symplify\Skipper\Skipper\OnlySkipper $onlySkipper, \RectorPrefix20220607\Symplify\Skipper\SkipCriteriaResolver\SkippedClassResolver $skippedClassResolver) + public function __construct(ClassLikeExistenceChecker $classLikeExistenceChecker, ParameterProvider $parameterProvider, SkipSkipper $skipSkipper, OnlySkipper $onlySkipper, SkippedClassResolver $skippedClassResolver) { $this->classLikeExistenceChecker = $classLikeExistenceChecker; $this->parameterProvider = $parameterProvider; @@ -54,9 +54,9 @@ final class ClassSkipVoter implements \RectorPrefix20220607\Symplify\Skipper\Con /** * @param string|object $element */ - public function shouldSkip($element, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : bool + public function shouldSkip($element, SmartFileInfo $smartFileInfo) : bool { - $only = $this->parameterProvider->provideArrayParameter(\RectorPrefix20220607\Symplify\Skipper\ValueObject\Option::ONLY); + $only = $this->parameterProvider->provideArrayParameter(Option::ONLY); $doesMatchOnly = $this->onlySkipper->doesMatchOnly($element, $smartFileInfo, $only); if (\is_bool($doesMatchOnly)) { return $doesMatchOnly; diff --git a/vendor/symplify/skipper/src/SkipVoter/MessageSkipVoter.php b/vendor/symplify/skipper/src/SkipVoter/MessageSkipVoter.php index 346f48ec2c9..93a69039930 100644 --- a/vendor/symplify/skipper/src/SkipVoter/MessageSkipVoter.php +++ b/vendor/symplify/skipper/src/SkipVoter/MessageSkipVoter.php @@ -6,8 +6,8 @@ namespace RectorPrefix20220607\Symplify\Skipper\SkipVoter; use RectorPrefix20220607\Symplify\Skipper\Contract\SkipVoterInterface; use RectorPrefix20220607\Symplify\Skipper\Matcher\FileInfoMatcher; use RectorPrefix20220607\Symplify\Skipper\SkipCriteriaResolver\SkippedMessagesResolver; -use Symplify\SmartFileSystem\SmartFileInfo; -final class MessageSkipVoter implements \RectorPrefix20220607\Symplify\Skipper\Contract\SkipVoterInterface +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; +final class MessageSkipVoter implements SkipVoterInterface { /** * @var \Symplify\Skipper\SkipCriteriaResolver\SkippedMessagesResolver @@ -17,7 +17,7 @@ final class MessageSkipVoter implements \RectorPrefix20220607\Symplify\Skipper\C * @var \Symplify\Skipper\Matcher\FileInfoMatcher */ private $fileInfoMatcher; - public function __construct(\RectorPrefix20220607\Symplify\Skipper\SkipCriteriaResolver\SkippedMessagesResolver $skippedMessagesResolver, \RectorPrefix20220607\Symplify\Skipper\Matcher\FileInfoMatcher $fileInfoMatcher) + public function __construct(SkippedMessagesResolver $skippedMessagesResolver, FileInfoMatcher $fileInfoMatcher) { $this->skippedMessagesResolver = $skippedMessagesResolver; $this->fileInfoMatcher = $fileInfoMatcher; @@ -35,7 +35,7 @@ final class MessageSkipVoter implements \RectorPrefix20220607\Symplify\Skipper\C /** * @param string|object $element */ - public function shouldSkip($element, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : bool + public function shouldSkip($element, SmartFileInfo $smartFileInfo) : bool { if (\is_object($element)) { return \false; diff --git a/vendor/symplify/skipper/src/SkipVoter/PathSkipVoter.php b/vendor/symplify/skipper/src/SkipVoter/PathSkipVoter.php index b74144f0402..e5214a6378d 100644 --- a/vendor/symplify/skipper/src/SkipVoter/PathSkipVoter.php +++ b/vendor/symplify/skipper/src/SkipVoter/PathSkipVoter.php @@ -6,8 +6,8 @@ namespace RectorPrefix20220607\Symplify\Skipper\SkipVoter; use RectorPrefix20220607\Symplify\Skipper\Contract\SkipVoterInterface; use RectorPrefix20220607\Symplify\Skipper\Matcher\FileInfoMatcher; use RectorPrefix20220607\Symplify\Skipper\SkipCriteriaResolver\SkippedPathsResolver; -use Symplify\SmartFileSystem\SmartFileInfo; -final class PathSkipVoter implements \RectorPrefix20220607\Symplify\Skipper\Contract\SkipVoterInterface +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; +final class PathSkipVoter implements SkipVoterInterface { /** * @var \Symplify\Skipper\Matcher\FileInfoMatcher @@ -17,7 +17,7 @@ final class PathSkipVoter implements \RectorPrefix20220607\Symplify\Skipper\Cont * @var \Symplify\Skipper\SkipCriteriaResolver\SkippedPathsResolver */ private $skippedPathsResolver; - public function __construct(\RectorPrefix20220607\Symplify\Skipper\Matcher\FileInfoMatcher $fileInfoMatcher, \RectorPrefix20220607\Symplify\Skipper\SkipCriteriaResolver\SkippedPathsResolver $skippedPathsResolver) + public function __construct(FileInfoMatcher $fileInfoMatcher, SkippedPathsResolver $skippedPathsResolver) { $this->fileInfoMatcher = $fileInfoMatcher; $this->skippedPathsResolver = $skippedPathsResolver; @@ -32,7 +32,7 @@ final class PathSkipVoter implements \RectorPrefix20220607\Symplify\Skipper\Cont /** * @param string|object $element */ - public function shouldSkip($element, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : bool + public function shouldSkip($element, SmartFileInfo $smartFileInfo) : bool { $skippedPaths = $this->skippedPathsResolver->resolve(); return $this->fileInfoMatcher->doesFileInfoMatchPatterns($smartFileInfo, $skippedPaths); diff --git a/vendor/symplify/skipper/src/Skipper/OnlySkipper.php b/vendor/symplify/skipper/src/Skipper/OnlySkipper.php index e81e797ee75..4f4c3390d34 100644 --- a/vendor/symplify/skipper/src/Skipper/OnlySkipper.php +++ b/vendor/symplify/skipper/src/Skipper/OnlySkipper.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\Skipper\Skipper; use RectorPrefix20220607\Symplify\Skipper\Matcher\FileInfoMatcher; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; /** * @see \Symplify\Skipper\Tests\Skipper\Only\OnlySkipperTest */ @@ -14,7 +14,7 @@ final class OnlySkipper * @var \Symplify\Skipper\Matcher\FileInfoMatcher */ private $fileInfoMatcher; - public function __construct(\RectorPrefix20220607\Symplify\Skipper\Matcher\FileInfoMatcher $fileInfoMatcher) + public function __construct(FileInfoMatcher $fileInfoMatcher) { $this->fileInfoMatcher = $fileInfoMatcher; } @@ -22,7 +22,7 @@ final class OnlySkipper * @param mixed[] $only * @param object|string $checker */ - public function doesMatchOnly($checker, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo, array $only) : ?bool + public function doesMatchOnly($checker, SmartFileInfo $smartFileInfo, array $only) : ?bool { foreach ($only as $onlyClass => $onlyFiles) { if (\is_int($onlyClass)) { diff --git a/vendor/symplify/skipper/src/Skipper/SkipSkipper.php b/vendor/symplify/skipper/src/Skipper/SkipSkipper.php index 8eb0935c280..78274fef23c 100644 --- a/vendor/symplify/skipper/src/Skipper/SkipSkipper.php +++ b/vendor/symplify/skipper/src/Skipper/SkipSkipper.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\Skipper\Skipper; use RectorPrefix20220607\Symplify\Skipper\Matcher\FileInfoMatcher; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; /** * @see \Symplify\Skipper\Tests\Skipper\Skip\SkipSkipperTest */ @@ -14,7 +14,7 @@ final class SkipSkipper * @var \Symplify\Skipper\Matcher\FileInfoMatcher */ private $fileInfoMatcher; - public function __construct(\RectorPrefix20220607\Symplify\Skipper\Matcher\FileInfoMatcher $fileInfoMatcher) + public function __construct(FileInfoMatcher $fileInfoMatcher) { $this->fileInfoMatcher = $fileInfoMatcher; } @@ -22,7 +22,7 @@ final class SkipSkipper * @param array $skippedClasses * @param object|string $checker */ - public function doesMatchSkip($checker, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo, array $skippedClasses) : bool + public function doesMatchSkip($checker, SmartFileInfo $smartFileInfo, array $skippedClasses) : bool { foreach ($skippedClasses as $skippedClass => $skippedFiles) { if (!\is_a($checker, $skippedClass, \true)) { diff --git a/vendor/symplify/skipper/src/Skipper/Skipper.php b/vendor/symplify/skipper/src/Skipper/Skipper.php index d467ab5867c..b0bc3412b4f 100644 --- a/vendor/symplify/skipper/src/Skipper/Skipper.php +++ b/vendor/symplify/skipper/src/Skipper/Skipper.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\Skipper\Skipper; use RectorPrefix20220607\Symplify\Skipper\Contract\SkipVoterInterface; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; /** * @api * @see \Symplify\Skipper\Tests\Skipper\Skipper\SkipperTest @@ -31,17 +31,17 @@ final class Skipper */ public function shouldSkipElement($element) : bool { - $fileInfo = new \Symplify\SmartFileSystem\SmartFileInfo(__FILE__); + $fileInfo = new SmartFileInfo(__FILE__); return $this->shouldSkipElementAndFileInfo($element, $fileInfo); } - public function shouldSkipFileInfo(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : bool + public function shouldSkipFileInfo(SmartFileInfo $smartFileInfo) : bool { return $this->shouldSkipElementAndFileInfo(self::FILE_ELEMENT, $smartFileInfo); } /** * @param string|object $element */ - public function shouldSkipElementAndFileInfo($element, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : bool + public function shouldSkipElementAndFileInfo($element, SmartFileInfo $smartFileInfo) : bool { foreach ($this->skipVoters as $skipVoter) { if ($skipVoter->match($element)) { diff --git a/vendor/symplify/smart-file-system/composer.json b/vendor/symplify/smart-file-system/composer.json index 1fe8a930a85..b22842d560d 100644 --- a/vendor/symplify/smart-file-system/composer.json +++ b/vendor/symplify/smart-file-system/composer.json @@ -28,27 +28,27 @@ } }, "conflict": { - "symplify\/astral": "<10.2.10", - "symplify\/composer-json-manipulator": "<10.2.10", - "symplify\/easy-coding-standard": "<10.2.10", - "symplify\/phpstan-rules": "<10.2.10", - "symplify\/easy-testing": "<10.2.10", - "symplify\/rule-doc-generator-contracts": "<10.2.10", - "symplify\/php-config-printer": "<10.2.10", - "symplify\/autowire-array-parameter": "<10.2.10", - "symplify\/package-builder": "<10.2.10", - "symplify\/phpstan-extensions": "<10.2.10", - "symplify\/rule-doc-generator": "<10.2.10", - "symplify\/vendor-patches": "<10.2.10", - "symplify\/skipper": "<10.2.10", - "symplify\/symfony-static-dumper": "<10.2.10", - "symplify\/symplify-kernel": "<10.2.10", - "symplify\/monorepo-builder": "<10.2.10", - "symplify\/config-transformer": "<10.2.10", - "symplify\/easy-ci": "<10.2.10", - "symplify\/coding-standard": "<10.2.10", - "symplify\/easy-parallel": "<10.2.10", - "symplify\/neon-config-dumper": "<10.2.10" + "symplify\/astral": "<10.2.11", + "symplify\/composer-json-manipulator": "<10.2.11", + "symplify\/easy-coding-standard": "<10.2.11", + "symplify\/phpstan-rules": "<10.2.11", + "symplify\/easy-testing": "<10.2.11", + "symplify\/rule-doc-generator-contracts": "<10.2.11", + "symplify\/php-config-printer": "<10.2.11", + "symplify\/autowire-array-parameter": "<10.2.11", + "symplify\/package-builder": "<10.2.11", + "symplify\/phpstan-extensions": "<10.2.11", + "symplify\/rule-doc-generator": "<10.2.11", + "symplify\/vendor-patches": "<10.2.11", + "symplify\/skipper": "<10.2.11", + "symplify\/symfony-static-dumper": "<10.2.11", + "symplify\/symplify-kernel": "<10.2.11", + "symplify\/monorepo-builder": "<10.2.11", + "symplify\/config-transformer": "<10.2.11", + "symplify\/easy-ci": "<10.2.11", + "symplify\/coding-standard": "<10.2.11", + "symplify\/easy-parallel": "<10.2.11", + "symplify\/neon-config-dumper": "<10.2.11" }, "minimum-stability": "dev", "prefer-stable": true diff --git a/vendor/symplify/smart-file-system/src/Exception/DirectoryNotFoundException.php b/vendor/symplify/smart-file-system/src/Exception/DirectoryNotFoundException.php index b67d715f73c..f62a321bcbb 100644 --- a/vendor/symplify/smart-file-system/src/Exception/DirectoryNotFoundException.php +++ b/vendor/symplify/smart-file-system/src/Exception/DirectoryNotFoundException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\SmartFileSystem\Exception; use Exception; -final class DirectoryNotFoundException extends \Exception +final class DirectoryNotFoundException extends Exception { } diff --git a/vendor/symplify/smart-file-system/src/Exception/FileNotFoundException.php b/vendor/symplify/smart-file-system/src/Exception/FileNotFoundException.php index 6fd37e0d207..366eb8442f5 100644 --- a/vendor/symplify/smart-file-system/src/Exception/FileNotFoundException.php +++ b/vendor/symplify/smart-file-system/src/Exception/FileNotFoundException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\SmartFileSystem\Exception; use Exception; -final class FileNotFoundException extends \Exception +final class FileNotFoundException extends Exception { } diff --git a/vendor/symplify/smart-file-system/src/FileSystemGuard.php b/vendor/symplify/smart-file-system/src/FileSystemGuard.php index 86f88eac9dc..534fe8aa339 100644 --- a/vendor/symplify/smart-file-system/src/FileSystemGuard.php +++ b/vendor/symplify/smart-file-system/src/FileSystemGuard.php @@ -12,7 +12,7 @@ final class FileSystemGuard if (\file_exists($file)) { return; } - throw new \RectorPrefix20220607\Symplify\SmartFileSystem\Exception\FileNotFoundException(\sprintf('File "%s" not found in "%s".', $file, $location)); + throw new FileNotFoundException(\sprintf('File "%s" not found in "%s".', $file, $location)); } public function ensureDirectoryExists(string $directory, string $extraMessage) : void { @@ -23,6 +23,6 @@ final class FileSystemGuard if ($extraMessage !== '') { $message .= ' ' . $extraMessage; } - throw new \RectorPrefix20220607\Symplify\SmartFileSystem\Exception\DirectoryNotFoundException($message); + throw new DirectoryNotFoundException($message); } } diff --git a/vendor/symplify/smart-file-system/src/Finder/FinderSanitizer.php b/vendor/symplify/smart-file-system/src/Finder/FinderSanitizer.php index 04324f60f07..cbeb56c3d85 100644 --- a/vendor/symplify/smart-file-system/src/Finder/FinderSanitizer.php +++ b/vendor/symplify/smart-file-system/src/Finder/FinderSanitizer.php @@ -7,7 +7,7 @@ use RectorPrefix20220607\Nette\Utils\Finder as NetteFinder; use SplFileInfo; use RectorPrefix20220607\Symfony\Component\Finder\Finder as SymfonyFinder; use RectorPrefix20220607\Symfony\Component\Finder\SplFileInfo as SymfonySplFileInfo; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; /** * @see \Symplify\SmartFileSystem\Tests\Finder\FinderSanitizer\FinderSanitizerTest */ @@ -21,17 +21,17 @@ final class FinderSanitizer { $smartFileInfos = []; foreach ($files as $file) { - $fileInfo = \is_string($file) ? new \SplFileInfo($file) : $file; + $fileInfo = \is_string($file) ? new SplFileInfo($file) : $file; if (!$this->isFileInfoValid($fileInfo)) { continue; } /** @var string $realPath */ $realPath = $fileInfo->getRealPath(); - $smartFileInfos[] = new \Symplify\SmartFileSystem\SmartFileInfo($realPath); + $smartFileInfos[] = new SmartFileInfo($realPath); } return $smartFileInfos; } - private function isFileInfoValid(\SplFileInfo $fileInfo) : bool + private function isFileInfoValid(SplFileInfo $fileInfo) : bool { return (bool) $fileInfo->getRealPath(); } diff --git a/vendor/symplify/smart-file-system/src/Finder/SmartFinder.php b/vendor/symplify/smart-file-system/src/Finder/SmartFinder.php index d9e2030b16b..90c92820267 100644 --- a/vendor/symplify/smart-file-system/src/Finder/SmartFinder.php +++ b/vendor/symplify/smart-file-system/src/Finder/SmartFinder.php @@ -5,7 +5,7 @@ namespace RectorPrefix20220607\Symplify\SmartFileSystem\Finder; use RectorPrefix20220607\Symfony\Component\Finder\Finder; use RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemFilter; -use Symplify\SmartFileSystem\SmartFileInfo; +use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileInfo; /** * @api * @see \Symplify\SmartFileSystem\Tests\Finder\SmartFinder\SmartFinderTest @@ -20,7 +20,7 @@ final class SmartFinder * @var \Symplify\SmartFileSystem\FileSystemFilter */ private $fileSystemFilter; - public function __construct(\RectorPrefix20220607\Symplify\SmartFileSystem\Finder\FinderSanitizer $finderSanitizer, \RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemFilter $fileSystemFilter) + public function __construct(FinderSanitizer $finderSanitizer, FileSystemFilter $fileSystemFilter) { $this->finderSanitizer = $finderSanitizer; $this->fileSystemFilter = $fileSystemFilter; @@ -34,7 +34,7 @@ final class SmartFinder $directories = $this->fileSystemFilter->filterDirectories($directoriesOrFiles); $fileInfos = []; if ($directories !== []) { - $finder = new \RectorPrefix20220607\Symfony\Component\Finder\Finder(); + $finder = new Finder(); $finder->name('*')->in($directories)->path($path)->files()->sortByName(); $fileInfos = $this->finderSanitizer->sanitize($finder); } @@ -50,7 +50,7 @@ final class SmartFinder $directories = $this->fileSystemFilter->filterDirectories($directoriesOrFiles); $fileInfos = []; if ($directories !== []) { - $finder = new \RectorPrefix20220607\Symfony\Component\Finder\Finder(); + $finder = new Finder(); $finder->name($name)->in($directories)->files()->sortByName(); if ($excludedDirectories !== []) { $finder->exclude($excludedDirectories); @@ -59,7 +59,7 @@ final class SmartFinder } $files = $this->fileSystemFilter->filterFiles($directoriesOrFiles); foreach ($files as $file) { - $fileInfos[] = new \Symplify\SmartFileSystem\SmartFileInfo($file); + $fileInfos[] = new SmartFileInfo($file); } return $fileInfos; } diff --git a/vendor/symplify/smart-file-system/src/Json/JsonFileSystem.php b/vendor/symplify/smart-file-system/src/Json/JsonFileSystem.php index 74439fc0944..df746b21952 100644 --- a/vendor/symplify/smart-file-system/src/Json/JsonFileSystem.php +++ b/vendor/symplify/smart-file-system/src/Json/JsonFileSystem.php @@ -21,7 +21,7 @@ final class JsonFileSystem * @var \Symplify\SmartFileSystem\SmartFileSystem */ private $smartFileSystem; - public function __construct(\RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemGuard $fileSystemGuard, \RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem) + public function __construct(FileSystemGuard $fileSystemGuard, SmartFileSystem $smartFileSystem) { $this->fileSystemGuard = $fileSystemGuard; $this->smartFileSystem = $smartFileSystem; @@ -33,14 +33,14 @@ final class JsonFileSystem { $this->fileSystemGuard->ensureFileExists($filePath, __METHOD__); $fileContent = $this->smartFileSystem->readFile($filePath); - return \RectorPrefix20220607\Nette\Utils\Json::decode($fileContent, \RectorPrefix20220607\Nette\Utils\Json::FORCE_ARRAY); + return Json::decode($fileContent, Json::FORCE_ARRAY); } /** * @param array $jsonArray */ public function writeJsonToFilePath(array $jsonArray, string $filePath) : void { - $jsonContent = \RectorPrefix20220607\Nette\Utils\Json::encode($jsonArray, \RectorPrefix20220607\Nette\Utils\Json::PRETTY) . \PHP_EOL; + $jsonContent = Json::encode($jsonArray, Json::PRETTY) . \PHP_EOL; $this->smartFileSystem->dumpFile($filePath, $jsonContent); } /** @@ -49,7 +49,7 @@ final class JsonFileSystem public function mergeArrayToJsonFile(string $filePath, array $newJsonArray) : void { $jsonArray = $this->loadFilePathToJson($filePath); - $newComposerJsonArray = \RectorPrefix20220607\Nette\Utils\Arrays::mergeTree($jsonArray, $newJsonArray); + $newComposerJsonArray = Arrays::mergeTree($jsonArray, $newJsonArray); $this->writeJsonToFilePath($newComposerJsonArray, $filePath); } } diff --git a/vendor/symplify/smart-file-system/src/Normalizer/PathNormalizer.php b/vendor/symplify/smart-file-system/src/Normalizer/PathNormalizer.php index fa84850e394..b0b8a8a822a 100644 --- a/vendor/symplify/smart-file-system/src/Normalizer/PathNormalizer.php +++ b/vendor/symplify/smart-file-system/src/Normalizer/PathNormalizer.php @@ -32,7 +32,7 @@ final class PathNormalizer public function normalizePath(string $originalPath) : string { $directorySeparator = \DIRECTORY_SEPARATOR; - $matches = \RectorPrefix20220607\Nette\Utils\Strings::match($originalPath, self::SCHEME_PATH_REGEX); + $matches = Strings::match($originalPath, self::SCHEME_PATH_REGEX); if ($matches !== null) { [, $scheme, $path] = $matches; } else { @@ -40,7 +40,7 @@ final class PathNormalizer $path = $originalPath; } $normalizedPath = \str_replace('\\', '/', $path); - $path = \RectorPrefix20220607\Nette\Utils\Strings::replace($normalizedPath, self::TWO_AND_MORE_SLASHES_REGEX, '/'); + $path = Strings::replace($normalizedPath, self::TWO_AND_MORE_SLASHES_REGEX, '/'); $pathRoot = \strncmp($path, '/', \strlen('/')) === 0 ? $directorySeparator : ''; $pathParts = \explode('/', \trim($path, '/')); $normalizedPathParts = $this->normalizePathParts($pathParts, $scheme); diff --git a/vendor/symplify/smart-file-system/src/SmartFileInfo.php b/vendor/symplify/smart-file-system/src/SmartFileInfo.php index a14235b2941..4e13c55407c 100644 --- a/vendor/symplify/smart-file-system/src/SmartFileInfo.php +++ b/vendor/symplify/smart-file-system/src/SmartFileInfo.php @@ -12,7 +12,7 @@ use RectorPrefix20220607\Symplify\SmartFileSystem\Exception\FileNotFoundExceptio /** * @see \Symplify\SmartFileSystem\Tests\SmartFileInfo\SmartFileInfoTest */ -final class SmartFileInfo extends \RectorPrefix20220607\Symfony\Component\Finder\SplFileInfo +final class SmartFileInfo extends SplFileInfo { /** * @var string @@ -25,10 +25,10 @@ final class SmartFileInfo extends \RectorPrefix20220607\Symfony\Component\Finder private $smartFileSystem; public function __construct(string $filePath) { - $this->smartFileSystem = new \RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem(); + $this->smartFileSystem = new SmartFileSystem(); // accepts also dirs if (!\file_exists($filePath)) { - throw new \RectorPrefix20220607\Symplify\SmartFileSystem\Exception\FileNotFoundException(\sprintf('File path "%s" was not found while creating "%s" object.', $filePath, self::class)); + throw new FileNotFoundException(\sprintf('File path "%s" was not found while creating "%s" object.', $filePath, self::class)); } // real path doesn't work in PHAR: https://www.php.net/manual/en/function.realpath.php if (\strncmp($filePath, 'phar://', \strlen('phar://')) === 0) { @@ -58,7 +58,7 @@ final class SmartFileInfo extends \RectorPrefix20220607\Symfony\Component\Finder } public function getRealPathWithoutSuffix() : string { - return \RectorPrefix20220607\Nette\Utils\Strings::replace($this->getRealPath(), self::LAST_SUFFIX_REGEX, ''); + return Strings::replace($this->getRealPath(), self::LAST_SUFFIX_REGEX, ''); } public function getRelativeFilePath() : string { @@ -71,7 +71,7 @@ final class SmartFileInfo extends \RectorPrefix20220607\Symfony\Component\Finder public function getRelativeFilePathFromDirectory(string $directory) : string { if (!\file_exists($directory)) { - throw new \RectorPrefix20220607\Symplify\SmartFileSystem\Exception\DirectoryNotFoundException(\sprintf('Directory "%s" was not found in %s.', $directory, self::class)); + throw new DirectoryNotFoundException(\sprintf('Directory "%s" was not found in %s.', $directory, self::class)); } $relativeFilePath = $this->smartFileSystem->makePathRelative($this->getNormalizedRealPath(), (string) \realpath($directory)); return \rtrim($relativeFilePath, '/'); @@ -79,8 +79,8 @@ final class SmartFileInfo extends \RectorPrefix20220607\Symfony\Component\Finder public function getRelativeFilePathFromCwdInTests() : string { // special case for tests - if (\RectorPrefix20220607\Symplify\EasyTesting\PHPUnit\StaticPHPUnitEnvironment::isPHPUnitRun()) { - return $this->getRelativeFilePathFromDirectory(\RectorPrefix20220607\Symplify\EasyTesting\StaticFixtureSplitter::getTemporaryPath()); + if (StaticPHPUnitEnvironment::isPHPUnitRun()) { + return $this->getRelativeFilePathFromDirectory(StaticFixtureSplitter::getTemporaryPath()); } return $this->getRelativeFilePathFromDirectory(\getcwd()); } diff --git a/vendor/symplify/smart-file-system/src/SmartFileSystem.php b/vendor/symplify/smart-file-system/src/SmartFileSystem.php index adb7fc6168c..e49ab8882cf 100644 --- a/vendor/symplify/smart-file-system/src/SmartFileSystem.php +++ b/vendor/symplify/smart-file-system/src/SmartFileSystem.php @@ -9,7 +9,7 @@ use RectorPrefix20220607\Symfony\Component\Filesystem\Filesystem; /** * @see \Symplify\SmartFileSystem\Tests\SmartFileSystem\SmartFileSystemTest */ -final class SmartFileSystem extends \RectorPrefix20220607\Symfony\Component\Filesystem\Filesystem +final class SmartFileSystem extends Filesystem { /** * @var string @@ -24,13 +24,13 @@ final class SmartFileSystem extends \RectorPrefix20220607\Symfony\Component\File $source = @\file_get_contents($filename); if (!$source) { $message = \sprintf('Failed to read "%s" file: "%s"', $filename, $this->getLastError()); - throw new \RectorPrefix20220607\Symfony\Component\Filesystem\Exception\IOException($message, 0, null, $filename); + throw new IOException($message, 0, null, $filename); } return $source; } - public function readFileToSmartFileInfo(string $filename) : \Symplify\SmartFileSystem\SmartFileInfo + public function readFileToSmartFileInfo(string $filename) : SmartFileInfo { - return new \Symplify\SmartFileSystem\SmartFileInfo($filename); + return new SmartFileInfo($filename); } /** * Converts given HTML code to plain text @@ -63,6 +63,6 @@ final class SmartFileSystem extends \RectorPrefix20220607\Symfony\Component\File { $message = \error_get_last()['message'] ?? ''; $htmlMessage = \ini_get('html_errors') ? $this->htmlToText($message) : $message; - return \RectorPrefix20220607\Nette\Utils\Strings::replace($htmlMessage, self::BEFORE_COLLON_REGEX, ''); + return Strings::replace($htmlMessage, self::BEFORE_COLLON_REGEX, ''); } } diff --git a/vendor/symplify/symplify-kernel/composer.json b/vendor/symplify/symplify-kernel/composer.json index 4f360a8f70b..ad244bf84e1 100644 --- a/vendor/symplify/symplify-kernel/composer.json +++ b/vendor/symplify/symplify-kernel/composer.json @@ -6,10 +6,10 @@ "php": ">=8.0", "symfony\/console": "^6.0", "symfony\/dependency-injection": "^6.0", - "symplify\/smart-file-system": "^10.2.10", - "symplify\/composer-json-manipulator": "^10.2.10", - "symplify\/autowire-array-parameter": "^10.2.10", - "symplify\/package-builder": "^10.2.10", + "symplify\/smart-file-system": "^10.2.11", + "symplify\/composer-json-manipulator": "^10.2.11", + "symplify\/autowire-array-parameter": "^10.2.11", + "symplify\/package-builder": "^10.2.11", "webmozart\/assert": "^1.10" }, "require-dev": { @@ -31,23 +31,23 @@ } }, "conflict": { - "symplify\/astral": "<10.2.10", - "symplify\/easy-coding-standard": "<10.2.10", - "symplify\/phpstan-rules": "<10.2.10", - "symplify\/easy-testing": "<10.2.10", - "symplify\/rule-doc-generator-contracts": "<10.2.10", - "symplify\/php-config-printer": "<10.2.10", - "symplify\/phpstan-extensions": "<10.2.10", - "symplify\/rule-doc-generator": "<10.2.10", - "symplify\/vendor-patches": "<10.2.10", - "symplify\/skipper": "<10.2.10", - "symplify\/symfony-static-dumper": "<10.2.10", - "symplify\/monorepo-builder": "<10.2.10", - "symplify\/config-transformer": "<10.2.10", - "symplify\/easy-ci": "<10.2.10", - "symplify\/coding-standard": "<10.2.10", - "symplify\/easy-parallel": "<10.2.10", - "symplify\/neon-config-dumper": "<10.2.10" + "symplify\/astral": "<10.2.11", + "symplify\/easy-coding-standard": "<10.2.11", + "symplify\/phpstan-rules": "<10.2.11", + "symplify\/easy-testing": "<10.2.11", + "symplify\/rule-doc-generator-contracts": "<10.2.11", + "symplify\/php-config-printer": "<10.2.11", + "symplify\/phpstan-extensions": "<10.2.11", + "symplify\/rule-doc-generator": "<10.2.11", + "symplify\/vendor-patches": "<10.2.11", + "symplify\/skipper": "<10.2.11", + "symplify\/symfony-static-dumper": "<10.2.11", + "symplify\/monorepo-builder": "<10.2.11", + "symplify\/config-transformer": "<10.2.11", + "symplify\/easy-ci": "<10.2.11", + "symplify\/coding-standard": "<10.2.11", + "symplify\/easy-parallel": "<10.2.11", + "symplify\/neon-config-dumper": "<10.2.11" }, "minimum-stability": "dev", "prefer-stable": true diff --git a/vendor/symplify/symplify-kernel/config/common-config.php b/vendor/symplify/symplify-kernel/config/common-config.php index 15b7a95c8df..b04b256473d 100644 --- a/vendor/symplify/symplify-kernel/config/common-config.php +++ b/vendor/symplify/symplify-kernel/config/common-config.php @@ -4,7 +4,7 @@ declare (strict_types=1); namespace RectorPrefix20220607; use RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use RectorPrefix20220607\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory; use RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider; use RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor; @@ -14,18 +14,18 @@ use RectorPrefix20220607\Symplify\SmartFileSystem\Finder\FinderSanitizer; use RectorPrefix20220607\Symplify\SmartFileSystem\Finder\SmartFinder; use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem; use function RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service; -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +return static function (ContainerConfigurator $containerConfigurator) : void { $services = $containerConfigurator->services(); $services->defaults()->public()->autowire(); // symfony style - $services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory::class); - $services->set(\RectorPrefix20220607\Symfony\Component\Console\Style\SymfonyStyle::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\RectorPrefix20220607\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory::class), 'create']); + $services->set(SymfonyStyleFactory::class); + $services->set(SymfonyStyle::class)->factory([service(SymfonyStyleFactory::class), 'create']); // filesystem - $services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\Finder\FinderSanitizer::class); - $services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem::class); - $services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\Finder\SmartFinder::class); - $services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemGuard::class); - $services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemFilter::class); - $services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider::class)->args([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service('service_container')]); - $services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor::class); + $services->set(FinderSanitizer::class); + $services->set(SmartFileSystem::class); + $services->set(SmartFinder::class); + $services->set(FileSystemGuard::class); + $services->set(FileSystemFilter::class); + $services->set(ParameterProvider::class)->args([service('service_container')]); + $services->set(PrivatesAccessor::class); }; diff --git a/vendor/symplify/symplify-kernel/src/Config/Loader/ParameterMergingLoaderFactory.php b/vendor/symplify/symplify-kernel/src/Config/Loader/ParameterMergingLoaderFactory.php index 4700011ee88..6fd9412bda3 100644 --- a/vendor/symplify/symplify-kernel/src/Config/Loader/ParameterMergingLoaderFactory.php +++ b/vendor/symplify/symplify-kernel/src/Config/Loader/ParameterMergingLoaderFactory.php @@ -10,13 +10,13 @@ use RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderResolver; use RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder; use RectorPrefix20220607\Symplify\PackageBuilder\DependencyInjection\FileLoader\ParameterMergingPhpFileLoader; use RectorPrefix20220607\Symplify\SymplifyKernel\Contract\Config\LoaderFactoryInterface; -final class ParameterMergingLoaderFactory implements \RectorPrefix20220607\Symplify\SymplifyKernel\Contract\Config\LoaderFactoryInterface +final class ParameterMergingLoaderFactory implements LoaderFactoryInterface { - public function create(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder, string $currentWorkingDirectory) : \RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderInterface + public function create(ContainerBuilder $containerBuilder, string $currentWorkingDirectory) : \RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderInterface { - $fileLocator = new \RectorPrefix20220607\Symfony\Component\Config\FileLocator([$currentWorkingDirectory]); - $loaders = [new \RectorPrefix20220607\Symfony\Component\Config\Loader\GlobFileLoader($fileLocator), new \RectorPrefix20220607\Symplify\PackageBuilder\DependencyInjection\FileLoader\ParameterMergingPhpFileLoader($containerBuilder, $fileLocator)]; - $loaderResolver = new \RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderResolver($loaders); - return new \RectorPrefix20220607\Symfony\Component\Config\Loader\DelegatingLoader($loaderResolver); + $fileLocator = new FileLocator([$currentWorkingDirectory]); + $loaders = [new GlobFileLoader($fileLocator), new ParameterMergingPhpFileLoader($containerBuilder, $fileLocator)]; + $loaderResolver = new LoaderResolver($loaders); + return new DelegatingLoader($loaderResolver); } } diff --git a/vendor/symplify/symplify-kernel/src/ContainerBuilderFactory.php b/vendor/symplify/symplify-kernel/src/ContainerBuilderFactory.php index 80bfe6ec447..f40b8bb9041 100644 --- a/vendor/symplify/symplify-kernel/src/ContainerBuilderFactory.php +++ b/vendor/symplify/symplify-kernel/src/ContainerBuilderFactory.php @@ -18,7 +18,7 @@ final class ContainerBuilderFactory * @var \Symplify\SymplifyKernel\Contract\Config\LoaderFactoryInterface */ private $loaderFactory; - public function __construct(\RectorPrefix20220607\Symplify\SymplifyKernel\Contract\Config\LoaderFactoryInterface $loaderFactory) + public function __construct(LoaderFactoryInterface $loaderFactory) { $this->loaderFactory = $loaderFactory; } @@ -27,26 +27,26 @@ final class ContainerBuilderFactory * @param CompilerPassInterface[] $compilerPasses * @param ExtensionInterface[] $extensions */ - public function create(array $configFiles, array $compilerPasses, array $extensions) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder + public function create(array $configFiles, array $compilerPasses, array $extensions) : ContainerBuilder { - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($extensions, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Extension\ExtensionInterface::class); - \RectorPrefix20220607\Webmozart\Assert\Assert::allIsAOf($compilerPasses, \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface::class); - \RectorPrefix20220607\Webmozart\Assert\Assert::allString($configFiles); - \RectorPrefix20220607\Webmozart\Assert\Assert::allFile($configFiles); - $containerBuilder = new \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder(); + Assert::allIsAOf($extensions, ExtensionInterface::class); + Assert::allIsAOf($compilerPasses, CompilerPassInterface::class); + Assert::allString($configFiles); + Assert::allFile($configFiles); + $containerBuilder = new ContainerBuilder(); $this->registerExtensions($containerBuilder, $extensions); $this->registerConfigFiles($containerBuilder, $configFiles); $this->registerCompilerPasses($containerBuilder, $compilerPasses); // this calls load() method in every extensions // ensure these extensions are implicitly loaded $compilerPassConfig = $containerBuilder->getCompilerPassConfig(); - $compilerPassConfig->setMergePass(new \RectorPrefix20220607\Symplify\SymplifyKernel\DependencyInjection\LoadExtensionConfigsCompilerPass()); + $compilerPassConfig->setMergePass(new LoadExtensionConfigsCompilerPass()); return $containerBuilder; } /** * @param ExtensionInterface[] $extensions */ - private function registerExtensions(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder, array $extensions) : void + private function registerExtensions(ContainerBuilder $containerBuilder, array $extensions) : void { foreach ($extensions as $extension) { $containerBuilder->registerExtension($extension); @@ -55,7 +55,7 @@ final class ContainerBuilderFactory /** * @param CompilerPassInterface[] $compilerPasses */ - private function registerCompilerPasses(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder, array $compilerPasses) : void + private function registerCompilerPasses(ContainerBuilder $containerBuilder, array $compilerPasses) : void { foreach ($compilerPasses as $compilerPass) { $containerBuilder->addCompilerPass($compilerPass); @@ -64,7 +64,7 @@ final class ContainerBuilderFactory /** * @param string[] $configFiles */ - private function registerConfigFiles(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder, array $configFiles) : void + private function registerConfigFiles(ContainerBuilder $containerBuilder, array $configFiles) : void { $delegatingLoader = $this->loaderFactory->create($containerBuilder, \getcwd()); foreach ($configFiles as $configFile) { diff --git a/vendor/symplify/symplify-kernel/src/Contract/Config/LoaderFactoryInterface.php b/vendor/symplify/symplify-kernel/src/Contract/Config/LoaderFactoryInterface.php index 7b4a73e2dcd..6cf23284454 100644 --- a/vendor/symplify/symplify-kernel/src/Contract/Config/LoaderFactoryInterface.php +++ b/vendor/symplify/symplify-kernel/src/Contract/Config/LoaderFactoryInterface.php @@ -7,5 +7,5 @@ use RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderInterface; use RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder; interface LoaderFactoryInterface { - public function create(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder, string $currentWorkingDirectory) : \RectorPrefix20220607\Symfony\Component\Config\Loader\LoaderInterface; + public function create(ContainerBuilder $containerBuilder, string $currentWorkingDirectory) : LoaderInterface; } diff --git a/vendor/symplify/symplify-kernel/src/Contract/LightKernelInterface.php b/vendor/symplify/symplify-kernel/src/Contract/LightKernelInterface.php index fc39db94140..4cb5b9e63f9 100644 --- a/vendor/symplify/symplify-kernel/src/Contract/LightKernelInterface.php +++ b/vendor/symplify/symplify-kernel/src/Contract/LightKernelInterface.php @@ -12,6 +12,6 @@ interface LightKernelInterface /** * @param string[] $configFiles */ - public function createFromConfigs(array $configFiles) : \RectorPrefix20220607\Psr\Container\ContainerInterface; - public function getContainer() : \RectorPrefix20220607\Psr\Container\ContainerInterface; + public function createFromConfigs(array $configFiles) : ContainerInterface; + public function getContainer() : ContainerInterface; } diff --git a/vendor/symplify/symplify-kernel/src/DependencyInjection/LoadExtensionConfigsCompilerPass.php b/vendor/symplify/symplify-kernel/src/DependencyInjection/LoadExtensionConfigsCompilerPass.php index 804e8db88d6..a8d8acd8361 100644 --- a/vendor/symplify/symplify-kernel/src/DependencyInjection/LoadExtensionConfigsCompilerPass.php +++ b/vendor/symplify/symplify-kernel/src/DependencyInjection/LoadExtensionConfigsCompilerPass.php @@ -9,9 +9,9 @@ use RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder; * Mimics @see \Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass without dependency on * symfony/http-kernel */ -final class LoadExtensionConfigsCompilerPass extends \RectorPrefix20220607\Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass +final class LoadExtensionConfigsCompilerPass extends MergeExtensionConfigurationPass { - public function process(\RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder) : void + public function process(ContainerBuilder $containerBuilder) : void { $extensionNames = \array_keys($containerBuilder->getExtensions()); foreach ($extensionNames as $extensionName) { diff --git a/vendor/symplify/symplify-kernel/src/Exception/BootException.php b/vendor/symplify/symplify-kernel/src/Exception/BootException.php index bc84c80fb9c..610577d1f97 100644 --- a/vendor/symplify/symplify-kernel/src/Exception/BootException.php +++ b/vendor/symplify/symplify-kernel/src/Exception/BootException.php @@ -4,6 +4,6 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\SymplifyKernel\Exception; use Exception; -final class BootException extends \Exception +final class BootException extends Exception { } diff --git a/vendor/symplify/symplify-kernel/src/Exception/ShouldNotHappenException.php b/vendor/symplify/symplify-kernel/src/Exception/ShouldNotHappenException.php index b74a020b267..f979f05105e 100644 --- a/vendor/symplify/symplify-kernel/src/Exception/ShouldNotHappenException.php +++ b/vendor/symplify/symplify-kernel/src/Exception/ShouldNotHappenException.php @@ -7,6 +7,6 @@ use Exception; /** * @api */ -final class ShouldNotHappenException extends \Exception +final class ShouldNotHappenException extends Exception { } diff --git a/vendor/symplify/symplify-kernel/src/HttpKernel/AbstractSymplifyKernel.php b/vendor/symplify/symplify-kernel/src/HttpKernel/AbstractSymplifyKernel.php index fd358aa3575..8a1547fe062 100644 --- a/vendor/symplify/symplify-kernel/src/HttpKernel/AbstractSymplifyKernel.php +++ b/vendor/symplify/symplify-kernel/src/HttpKernel/AbstractSymplifyKernel.php @@ -16,7 +16,7 @@ use RectorPrefix20220607\Symplify\SymplifyKernel\ValueObject\SymplifyKernelConfi /** * @api */ -abstract class AbstractSymplifyKernel implements \RectorPrefix20220607\Symplify\SymplifyKernel\Contract\LightKernelInterface +abstract class AbstractSymplifyKernel implements LightKernelInterface { /** * @var \Symfony\Component\DependencyInjection\Container|null @@ -27,11 +27,11 @@ abstract class AbstractSymplifyKernel implements \RectorPrefix20220607\Symplify\ * @param CompilerPassInterface[] $compilerPasses * @param ExtensionInterface[] $extensions */ - public function create(array $configFiles, array $compilerPasses = [], array $extensions = []) : \RectorPrefix20220607\Symfony\Component\DependencyInjection\ContainerInterface + public function create(array $configFiles, array $compilerPasses = [], array $extensions = []) : ContainerInterface { - $containerBuilderFactory = new \RectorPrefix20220607\Symplify\SymplifyKernel\ContainerBuilderFactory(new \RectorPrefix20220607\Symplify\SymplifyKernel\Config\Loader\ParameterMergingLoaderFactory()); - $compilerPasses[] = new \RectorPrefix20220607\Symplify\AutowireArrayParameter\DependencyInjection\CompilerPass\AutowireArrayParameterCompilerPass(); - $configFiles[] = \RectorPrefix20220607\Symplify\SymplifyKernel\ValueObject\SymplifyKernelConfig::FILE_PATH; + $containerBuilderFactory = new ContainerBuilderFactory(new ParameterMergingLoaderFactory()); + $compilerPasses[] = new AutowireArrayParameterCompilerPass(); + $configFiles[] = SymplifyKernelConfig::FILE_PATH; $containerBuilder = $containerBuilderFactory->create($configFiles, $compilerPasses, $extensions); $containerBuilder->compile(); $this->container = $containerBuilder; @@ -39,8 +39,8 @@ abstract class AbstractSymplifyKernel implements \RectorPrefix20220607\Symplify\ } public function getContainer() : \RectorPrefix20220607\Psr\Container\ContainerInterface { - if (!$this->container instanceof \RectorPrefix20220607\Symfony\Component\DependencyInjection\Container) { - throw new \RectorPrefix20220607\Symplify\SymplifyKernel\Exception\ShouldNotHappenException(); + if (!$this->container instanceof Container) { + throw new ShouldNotHappenException(); } return $this->container; } diff --git a/vendor/symplify/symplify-kernel/src/ValueObject/KernelBootAndApplicationRun.php b/vendor/symplify/symplify-kernel/src/ValueObject/KernelBootAndApplicationRun.php index 3ced58f8527..57465d2624d 100644 --- a/vendor/symplify/symplify-kernel/src/ValueObject/KernelBootAndApplicationRun.php +++ b/vendor/symplify/symplify-kernel/src/ValueObject/KernelBootAndApplicationRun.php @@ -38,11 +38,11 @@ final class KernelBootAndApplicationRun { try { $this->booKernelAndRunApplication(); - } catch (\Throwable $throwable) { - $symfonyStyleFactory = new \RectorPrefix20220607\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory(); + } catch (Throwable $throwable) { + $symfonyStyleFactory = new SymfonyStyleFactory(); $symfonyStyle = $symfonyStyleFactory->create(); $symfonyStyle->error($throwable->getMessage()); - exit(\RectorPrefix20220607\Symfony\Component\Console\Command\Command::FAILURE); + exit(Command::FAILURE); } } /** @@ -52,23 +52,23 @@ final class KernelBootAndApplicationRun { // random has is needed, so cache is invalidated and changes from config are loaded $kernelClass = $this->kernelClass; - if (\is_a($kernelClass, \RectorPrefix20220607\Symplify\SymplifyKernel\Contract\LightKernelInterface::class, \true)) { + if (\is_a($kernelClass, LightKernelInterface::class, \true)) { return new $kernelClass(); } $environment = 'prod' . \random_int(1, 100000); - return new $kernelClass($environment, \RectorPrefix20220607\Symplify\PackageBuilder\Console\Input\StaticInputDetector::isDebug()); + return new $kernelClass($environment, StaticInputDetector::isDebug()); } private function booKernelAndRunApplication() : void { $kernel = $this->createKernel(); - if ($kernel instanceof \RectorPrefix20220607\Symplify\SymplifyKernel\Contract\LightKernelInterface) { + if ($kernel instanceof LightKernelInterface) { $container = $kernel->createFromConfigs($this->extraConfigs); } else { $kernel->boot(); $container = $kernel->getContainer(); } /** @var Application $application */ - $application = $container->get(\RectorPrefix20220607\Symfony\Component\Console\Application::class); + $application = $container->get(Application::class); exit($application->run()); } /** @@ -76,14 +76,14 @@ final class KernelBootAndApplicationRun */ private function validateKernelClass(string $kernelClass) : void { - if (\is_a($kernelClass, \RectorPrefix20220607\Symfony\Component\HttpKernel\KernelInterface::class, \true)) { + if (\is_a($kernelClass, KernelInterface::class, \true)) { return; } - if (\is_a($kernelClass, \RectorPrefix20220607\Symplify\SymplifyKernel\Contract\LightKernelInterface::class, \true)) { + if (\is_a($kernelClass, LightKernelInterface::class, \true)) { return; } $currentValueType = \get_debug_type($kernelClass); - $errorMessage = \sprintf('Class "%s" must by type of "%s" or "%s". "%s" given', $kernelClass, \RectorPrefix20220607\Symfony\Component\HttpKernel\KernelInterface::class, \RectorPrefix20220607\Symplify\SymplifyKernel\Contract\LightKernelInterface::class, $currentValueType); - throw new \RectorPrefix20220607\Symplify\SymplifyKernel\Exception\BootException($errorMessage); + $errorMessage = \sprintf('Class "%s" must by type of "%s" or "%s". "%s" given', $kernelClass, KernelInterface::class, LightKernelInterface::class, $currentValueType); + throw new BootException($errorMessage); } } diff --git a/vendor/symplify/symplify-kernel/tests/ContainerBuilderFactory/ContainerBuilderFactoryTest.php b/vendor/symplify/symplify-kernel/tests/ContainerBuilderFactory/ContainerBuilderFactoryTest.php index 84202ee7473..21ff6585adf 100644 --- a/vendor/symplify/symplify-kernel/tests/ContainerBuilderFactory/ContainerBuilderFactoryTest.php +++ b/vendor/symplify/symplify-kernel/tests/ContainerBuilderFactory/ContainerBuilderFactoryTest.php @@ -3,17 +3,17 @@ declare (strict_types=1); namespace RectorPrefix20220607\Symplify\SymplifyKernel\Tests\ContainerBuilderFactory; -use RectorPrefix20220607\PHPUnit\Framework\TestCase; +use PHPUnit\Framework\TestCase; use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem; use RectorPrefix20220607\Symplify\SymplifyKernel\Config\Loader\ParameterMergingLoaderFactory; use RectorPrefix20220607\Symplify\SymplifyKernel\ContainerBuilderFactory; -final class ContainerBuilderFactoryTest extends \RectorPrefix20220607\PHPUnit\Framework\TestCase +final class ContainerBuilderFactoryTest extends TestCase { public function test() : void { - $containerBuilderFactory = new \RectorPrefix20220607\Symplify\SymplifyKernel\ContainerBuilderFactory(new \RectorPrefix20220607\Symplify\SymplifyKernel\Config\Loader\ParameterMergingLoaderFactory()); + $containerBuilderFactory = new ContainerBuilderFactory(new ParameterMergingLoaderFactory()); $containerBuilder = $containerBuilderFactory->create([__DIR__ . '/config/some_services.php'], [], []); - $hasSmartFileSystemService = $containerBuilder->has(\RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem::class); + $hasSmartFileSystemService = $containerBuilder->has(SmartFileSystem::class); $this->assertTrue($hasSmartFileSystemService); } } diff --git a/vendor/symplify/symplify-kernel/tests/ContainerBuilderFactory/config/some_services.php b/vendor/symplify/symplify-kernel/tests/ContainerBuilderFactory/config/some_services.php index ea93e967908..c20a98bb8eb 100644 --- a/vendor/symplify/symplify-kernel/tests/ContainerBuilderFactory/config/some_services.php +++ b/vendor/symplify/symplify-kernel/tests/ContainerBuilderFactory/config/some_services.php @@ -3,9 +3,9 @@ declare (strict_types=1); namespace RectorPrefix20220607; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem; -return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void { +return static function (ContainerConfigurator $containerConfigurator) : void { $services = $containerConfigurator->services(); - $services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem::class); + $services->set(SmartFileSystem::class); }; diff --git a/vendor/tracy/tracy/src/Tracy/BlueScreen/BlueScreen.php b/vendor/tracy/tracy/src/Tracy/BlueScreen/BlueScreen.php index f6092fa258b..cd310c3d70b 100644 --- a/vendor/tracy/tracy/src/Tracy/BlueScreen/BlueScreen.php +++ b/vendor/tracy/tracy/src/Tracy/BlueScreen/BlueScreen.php @@ -95,9 +95,9 @@ class BlueScreen $this->renderTemplate($exception, __DIR__ . '/assets/page.phtml'); } /** @internal */ - public function renderToAjax(\Throwable $exception, \RectorPrefix20220607\Tracy\DeferredContent $defer) : void + public function renderToAjax(\Throwable $exception, DeferredContent $defer) : void { - $defer->addSetup('Tracy.BlueScreen.loadAjax', \RectorPrefix20220607\Tracy\Helpers::capture(function () use($exception) { + $defer->addSetup('Tracy.BlueScreen.loadAjax', Helpers::capture(function () use($exception) { $this->renderTemplate($exception, __DIR__ . '/assets/content.phtml'); })); } @@ -124,11 +124,11 @@ class BlueScreen { [$generators, $fibers] = $this->findGeneratorsAndFibers($exception); $headersSent = \headers_sent($headersFile, $headersLine); - $obStatus = \RectorPrefix20220607\Tracy\Debugger::$obStatus; + $obStatus = Debugger::$obStatus; $showEnvironment = $this->showEnvironment && \strpos($exception->getMessage(), 'Allowed memory size') === \false; $info = \array_filter($this->info); - $source = \RectorPrefix20220607\Tracy\Helpers::getSource(); - $title = $exception instanceof \ErrorException ? \RectorPrefix20220607\Tracy\Helpers::errorTypeToString($exception->getSeverity()) : \RectorPrefix20220607\Tracy\Helpers::getClass($exception); + $source = Helpers::getSource(); + $title = $exception instanceof \ErrorException ? Helpers::errorTypeToString($exception->getSeverity()) : Helpers::getClass($exception); $lastError = $exception instanceof \ErrorException || $exception instanceof \Error ? null : \error_get_last(); if (\function_exists('apache_request_headers')) { $httpHeaders = \apache_request_headers(); @@ -143,9 +143,9 @@ class BlueScreen $snapshot =& $this->snapshot; $snapshot = []; $dump = $this->getDumper(); - $css = \array_map('file_get_contents', \array_merge([__DIR__ . '/../assets/reset.css', __DIR__ . '/assets/bluescreen.css', __DIR__ . '/../assets/toggle.css', __DIR__ . '/../assets/table-sort.css', __DIR__ . '/../assets/tabs.css', __DIR__ . '/../Dumper/assets/dumper-light.css'], \RectorPrefix20220607\Tracy\Debugger::$customCssFiles)); - $css = \RectorPrefix20220607\Tracy\Helpers::minifyCss(\implode('', $css)); - $nonce = $toScreen ? \RectorPrefix20220607\Tracy\Helpers::getNonce() : null; + $css = \array_map('file_get_contents', \array_merge([__DIR__ . '/../assets/reset.css', __DIR__ . '/assets/bluescreen.css', __DIR__ . '/../assets/toggle.css', __DIR__ . '/../assets/table-sort.css', __DIR__ . '/../assets/tabs.css', __DIR__ . '/../Dumper/assets/dumper-light.css'], Debugger::$customCssFiles)); + $css = Helpers::minifyCss(\implode('', $css)); + $nonce = $toScreen ? Helpers::getNonce() : null; $actions = $toScreen ? $this->renderActions($exception) : []; require $template; } @@ -171,7 +171,7 @@ class BlueScreen \ob_end_clean(); } \is_callable($callback, \true, $name); - $res[] = (object) ['tab' => "Error in panel {$name}", 'panel' => \nl2br(\RectorPrefix20220607\Tracy\Helpers::escapeHtml($e))]; + $res[] = (object) ['tab' => "Error in panel {$name}", 'panel' => \nl2br(Helpers::escapeHtml($e))]; } return $res; } @@ -192,9 +192,9 @@ class BlueScreen } if (\preg_match('# ([\'"])(\\w{3,}(?:\\\\\\w{3,})+)\\1#i', $ex->getMessage(), $m)) { $class = $m[2]; - if (!\class_exists($class, \false) && !\interface_exists($class, \false) && !\trait_exists($class, \false) && ($file = \RectorPrefix20220607\Tracy\Helpers::guessClassFile($class)) && !\is_file($file)) { + if (!\class_exists($class, \false) && !\interface_exists($class, \false) && !\trait_exists($class, \false) && ($file = Helpers::guessClassFile($class)) && !\is_file($file)) { [$content, $line] = $this->generateNewFileContents($file, $class); - $actions[] = ['link' => \RectorPrefix20220607\Tracy\Helpers::editorUri($file, $line, 'create', '', $content), 'label' => 'create class']; + $actions[] = ['link' => Helpers::editorUri($file, $line, 'create', '', $content), 'label' => 'create class']; } } if (\preg_match('# ([\'"])((?:/|[a-z]:[/\\\\])\\w[^\'"]+\\.\\w{2,5})\\1#i', $ex->getMessage(), $m)) { @@ -207,11 +207,11 @@ class BlueScreen $label = 'create'; [$content, $line] = $this->generateNewFileContents($file); } - $actions[] = ['link' => \RectorPrefix20220607\Tracy\Helpers::editorUri($file, $line, $label, '', $content), 'label' => $label . ' file']; + $actions[] = ['link' => Helpers::editorUri($file, $line, $label, '', $content), 'label' => $label . ' file']; } - $query = ($ex instanceof \ErrorException ? '' : \RectorPrefix20220607\Tracy\Helpers::getClass($ex) . ' ') . \preg_replace('#\'.*\'|".*"#Us', '', $ex->getMessage()); + $query = ($ex instanceof \ErrorException ? '' : Helpers::getClass($ex) . ' ') . \preg_replace('#\'.*\'|".*"#Us', '', $ex->getMessage()); $actions[] = ['link' => 'https://www.google.com/search?sourceid=tracy&q=' . \urlencode($query), 'label' => 'search', 'external' => \true]; - if ($ex instanceof \ErrorException && !empty($ex->skippable) && \preg_match('#^https?://#', $source = \RectorPrefix20220607\Tracy\Helpers::getSource())) { + if ($ex instanceof \ErrorException && !empty($ex->skippable) && \preg_match('#^https?://#', $source = Helpers::getSource())) { $actions[] = ['link' => $source . (\strpos($source, '?') ? '&' : '?') . '_tracy_skip_error', 'label' => 'skip error']; } return $actions; @@ -227,8 +227,8 @@ class BlueScreen return null; } $source = $php ? static::highlightPhp($source, $line, $lines, $column) : '
' . static::highlightLine(\htmlspecialchars($source, \ENT_IGNORE, 'UTF-8'), $line, $lines, $column) . '
'; - if ($editor = \RectorPrefix20220607\Tracy\Helpers::editorUri($file, $line)) { - $source = \substr_replace($source, ' title="Ctrl-Click to open in editor" data-tracy-href="' . \RectorPrefix20220607\Tracy\Helpers::escapeHtml($editor) . '"', 4, 0); + if ($editor = Helpers::editorUri($file, $line)) { + $source = \substr_replace($source, ' title="Ctrl-Click to open in editor" data-tracy-href="' . Helpers::escapeHtml($editor) . '"', 4, 0); } return $source; } @@ -304,7 +304,7 @@ class BlueScreen return null; } $s = self::highlightPhp($source, $line, $lines); - $colors = ['color: ' . \ini_get('highlight.comment') => '1;30', 'color: ' . \ini_get('highlight.default') => '1;36', 'color: ' . \ini_get('highlight.html') => '1;35', 'color: ' . \ini_get('highlight.keyword') => '1;37', 'color: ' . \ini_get('highlight.string') => '1;32', 'tracy-line' => '1;30', 'tracy-line-highlight' => "1;37m\33[41"]; + $colors = ['color: ' . \ini_get('highlight.comment') => '1;30', 'color: ' . \ini_get('highlight.default') => '1;36', 'color: ' . \ini_get('highlight.html') => '1;35', 'color: ' . \ini_get('highlight.keyword') => '1;37', 'color: ' . \ini_get('highlight.string') => '1;32', 'tracy-line' => '1;30', 'tracy-line-highlight' => "1;37m\x1b[41"]; $stack = ['0']; $s = \preg_replace_callback('#<\\w+(?: (class|style)=["\'](.*?)["\'])?[^>]*>|#', function ($m) use($colors, &$stack) : string { if ($m[0][1] === '/') { @@ -312,7 +312,7 @@ class BlueScreen } else { $stack[] = isset($m[2], $colors[$m[2]]) ? $colors[$m[2]] : '0'; } - return "\33[0m\33[" . \end($stack) . 'm'; + return "\x1b[0m\x1b[" . \end($stack) . 'm'; }, $s); $s = \htmlspecialchars_decode(\strip_tags($s), \ENT_QUOTES | \ENT_HTML5); return $s; @@ -336,12 +336,12 @@ class BlueScreen public function getDumper() : \Closure { return function ($v, $k = null) : string { - return \RectorPrefix20220607\Tracy\Dumper::toHtml($v, [\RectorPrefix20220607\Tracy\Dumper::DEPTH => $this->maxDepth, \RectorPrefix20220607\Tracy\Dumper::TRUNCATE => $this->maxLength, \RectorPrefix20220607\Tracy\Dumper::ITEMS => $this->maxItems, \RectorPrefix20220607\Tracy\Dumper::SNAPSHOT => &$this->snapshot, \RectorPrefix20220607\Tracy\Dumper::LOCATION => \RectorPrefix20220607\Tracy\Dumper::LOCATION_CLASS, \RectorPrefix20220607\Tracy\Dumper::SCRUBBER => $this->scrubber, \RectorPrefix20220607\Tracy\Dumper::KEYS_TO_HIDE => $this->keysToHide], $k); + return Dumper::toHtml($v, [Dumper::DEPTH => $this->maxDepth, Dumper::TRUNCATE => $this->maxLength, Dumper::ITEMS => $this->maxItems, Dumper::SNAPSHOT => &$this->snapshot, Dumper::LOCATION => Dumper::LOCATION_CLASS, Dumper::SCRUBBER => $this->scrubber, Dumper::KEYS_TO_HIDE => $this->keysToHide], $k); }; } public function formatMessage(\Throwable $exception) : string { - $msg = \RectorPrefix20220607\Tracy\Helpers::encodeString(\trim((string) $exception->getMessage()), self::MaxMessageLength, \false); + $msg = Helpers::encodeString(\trim((string) $exception->getMessage()), self::MaxMessageLength, \false); // highlight 'string' $msg = \preg_replace('#\'\\S(?:[^\']|\\\\\')*\\S\'|"\\S(?:[^"]|\\\\")*\\S"#', '$0', $msg); // clickable class & methods @@ -354,11 +354,11 @@ class BlueScreen if (empty($r) || !$r->getFileName()) { return $m[0]; } - return '' . $m[0] . ''; + return '' . $m[0] . ''; }, $msg); // clickable file name $msg = \preg_replace_callback('#([\\w\\\\/.:-]+\\.(?:php|phpt|phtml|latte|neon))(?|:(\\d+)| on line (\\d+))?#', function ($m) { - return @\is_file($m[1]) ? '' . $m[0] . '' : $m[0]; + return @\is_file($m[1]) ? '' . $m[0] . '' : $m[0]; }, $msg); return $msg; } @@ -373,7 +373,7 @@ class BlueScreen // @ phpinfo may be disabled $info = \ob_get_clean(); if (\strpos($license, '', \RectorPrefix20220607\Tracy\Helpers::escapeHtml($info), ''; + echo '
', Helpers::escapeHtml($info), '
'; } else { $info = \str_replace('|.+\\z|
|

Configuration

#s', '', $info); @@ -422,7 +422,7 @@ class BlueScreen $generators[\spl_object_id($obj)] = $obj; } catch (\ReflectionException $e) { } - } elseif ($obj instanceof \RectorPrefix20220607\Fiber && $obj->isStarted() && !$obj->isTerminated()) { + } elseif ($obj instanceof \Fiber && $obj->isStarted() && !$obj->isTerminated()) { $fibers[\spl_object_id($obj)] = $obj; } }; @@ -430,7 +430,7 @@ class BlueScreen $add($this->fibers instanceof \WeakMap ? $k : $v); } if (\PHP_VERSION_ID >= 80000) { - \RectorPrefix20220607\Tracy\Helpers::traverseValue($object, $add); + Helpers::traverseValue($object, $add); } return [$generators, $fibers]; } diff --git a/vendor/tracy/tracy/src/Tracy/Debugger/Debugger.php b/vendor/tracy/tracy/src/Tracy/Debugger/Debugger.php index 17ba58dac5d..94835b923f4 100644 --- a/vendor/tracy/tracy/src/Tracy/Debugger/Debugger.php +++ b/vendor/tracy/tracy/src/Tracy/Debugger/Debugger.php @@ -63,7 +63,7 @@ class Debugger /** @var string|array email(s) to which send error notifications */ public static $email; /** for Debugger::log() and Debugger::fireLog() */ - public const DEBUG = \RectorPrefix20220607\Tracy\ILogger::DEBUG, INFO = \RectorPrefix20220607\Tracy\ILogger::INFO, WARNING = \RectorPrefix20220607\Tracy\ILogger::WARNING, ERROR = \RectorPrefix20220607\Tracy\ILogger::ERROR, EXCEPTION = \RectorPrefix20220607\Tracy\ILogger::EXCEPTION, CRITICAL = \RectorPrefix20220607\Tracy\ILogger::CRITICAL; + public const DEBUG = ILogger::DEBUG, INFO = ILogger::INFO, WARNING = ILogger::WARNING, ERROR = ILogger::ERROR, EXCEPTION = ILogger::EXCEPTION, CRITICAL = ILogger::CRITICAL; /********************* misc ****************d*g**/ /** @var float timestamp with microseconds of the start of the request */ public static $time; @@ -162,7 +162,7 @@ class Debugger } public static function dispatch() : void { - if (!\RectorPrefix20220607\Tracy\Helpers::isCli() && self::getStrategy()->sendAssets()) { + if (!Helpers::isCli() && self::getStrategy()->sendAssets()) { self::$showBar = \false; exit; } @@ -186,13 +186,13 @@ class Debugger { $error = \error_get_last(); if (\in_array($error['type'] ?? null, [\E_ERROR, \E_CORE_ERROR, \E_COMPILE_ERROR, \E_PARSE, \E_RECOVERABLE_ERROR, \E_USER_ERROR], \true)) { - self::exceptionHandler(\RectorPrefix20220607\Tracy\Helpers::fixStack(new \ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']))); + self::exceptionHandler(Helpers::fixStack(new ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']))); } elseif (($error['type'] ?? null) === \E_COMPILE_WARNING) { \error_clear_last(); self::errorHandler($error['type'], $error['message'], $error['file'], $error['line']); } self::$reserved = null; - if (self::$showBar && !\RectorPrefix20220607\Tracy\Helpers::isCli()) { + if (self::$showBar && !Helpers::isCli()) { try { self::getStrategy()->renderBar(); } catch (\Throwable $e) { @@ -212,7 +212,7 @@ class Debugger if (!\headers_sent()) { \http_response_code(isset($_SERVER['HTTP_USER_AGENT']) && \strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE ') !== \false ? 503 : 500); } - \RectorPrefix20220607\Tracy\Helpers::improveException($exception); + Helpers::improveException($exception); self::removeOutputBuffers(\true); self::getStrategy()->handleException($exception, $firstTime); try { @@ -244,15 +244,15 @@ class Debugger // workaround for PHP bug #80234 } if ($severity === \E_RECOVERABLE_ERROR || $severity === \E_USER_ERROR) { - if (\RectorPrefix20220607\Tracy\Helpers::findTrace(\debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS), '*::__toString')) { + if (Helpers::findTrace(\debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS), '*::__toString')) { // workaround for PHP < 7.4 $previous = isset($context['e']) && $context['e'] instanceof \Throwable ? $context['e'] : null; - $e = new \ErrorException($message, 0, $severity, $file, $line, $previous); + $e = new ErrorException($message, 0, $severity, $file, $line, $previous); $e->context = $context; self::exceptionHandler($e); exit(255); } - $e = new \ErrorException($message, 0, $severity, $file, $line); + $e = new ErrorException($message, 0, $severity, $file, $line); $e->context = $context; throw $e; } elseif ($severity & \error_reporting() || (\is_int(self::$scream) ? $severity & self::$scream : self::$scream)) { @@ -277,43 +277,43 @@ class Debugger } } /********************* services ****************d*g**/ - public static function getBlueScreen() : \RectorPrefix20220607\Tracy\BlueScreen + public static function getBlueScreen() : BlueScreen { if (!self::$blueScreen) { - self::$blueScreen = new \RectorPrefix20220607\Tracy\BlueScreen(); + self::$blueScreen = new BlueScreen(); self::$blueScreen->info = ['PHP ' . \PHP_VERSION, $_SERVER['SERVER_SOFTWARE'] ?? null, 'Tracy ' . self::VERSION]; } return self::$blueScreen; } - public static function getBar() : \RectorPrefix20220607\Tracy\Bar + public static function getBar() : Bar { if (!self::$bar) { - self::$bar = new \RectorPrefix20220607\Tracy\Bar(); - self::$bar->addPanel($info = new \RectorPrefix20220607\Tracy\DefaultBarPanel('info'), 'Tracy:info'); + self::$bar = new Bar(); + self::$bar->addPanel($info = new DefaultBarPanel('info'), 'Tracy:info'); $info->cpuUsage = self::$cpuUsage; - self::$bar->addPanel(new \RectorPrefix20220607\Tracy\DefaultBarPanel('errors'), 'Tracy:errors'); + self::$bar->addPanel(new DefaultBarPanel('errors'), 'Tracy:errors'); // filled by errorHandler() } return self::$bar; } - public static function setLogger(\RectorPrefix20220607\Tracy\ILogger $logger) : void + public static function setLogger(ILogger $logger) : void { self::$logger = $logger; } - public static function getLogger() : \RectorPrefix20220607\Tracy\ILogger + public static function getLogger() : ILogger { if (!self::$logger) { - self::$logger = new \RectorPrefix20220607\Tracy\Logger(self::$logDirectory, self::$email, self::getBlueScreen()); + self::$logger = new Logger(self::$logDirectory, self::$email, self::getBlueScreen()); self::$logger->directory =& self::$logDirectory; // back compatiblity self::$logger->email =& self::$email; } return self::$logger; } - public static function getFireLogger() : \RectorPrefix20220607\Tracy\ILogger + public static function getFireLogger() : ILogger { if (!self::$fireLogger) { - self::$fireLogger = new \RectorPrefix20220607\Tracy\FireLogger(); + self::$fireLogger = new FireLogger(); } return self::$fireLogger; } @@ -321,11 +321,11 @@ class Debugger public static function getStrategy() { if (empty(self::$strategy[self::$productionMode])) { - self::$strategy[self::$productionMode] = self::$productionMode ? new \RectorPrefix20220607\Tracy\ProductionStrategy() : new \RectorPrefix20220607\Tracy\DevelopmentStrategy(self::getBar(), self::getBlueScreen(), new \RectorPrefix20220607\Tracy\DeferredContent(self::getSessionStorage())); + self::$strategy[self::$productionMode] = self::$productionMode ? new ProductionStrategy() : new DevelopmentStrategy(self::getBar(), self::getBlueScreen(), new DeferredContent(self::getSessionStorage())); } return self::$strategy[self::$productionMode]; } - public static function setSessionStorage(\RectorPrefix20220607\Tracy\SessionStorage $storage) : void + public static function setSessionStorage(SessionStorage $storage) : void { if (self::$sessionStorage) { throw new \Exception('Storage is already set.'); @@ -333,10 +333,10 @@ class Debugger self::$sessionStorage = $storage; } /** @internal */ - public static function getSessionStorage() : \RectorPrefix20220607\Tracy\SessionStorage + public static function getSessionStorage() : SessionStorage { if (!self::$sessionStorage) { - self::$sessionStorage = @\is_dir($dir = \session_save_path()) || @\is_dir($dir = \ini_get('upload_tmp_dir')) || @\is_dir($dir = \sys_get_temp_dir()) || ($dir = self::$logDirectory) ? new \RectorPrefix20220607\Tracy\FileSession($dir) : new \RectorPrefix20220607\Tracy\NativeSession(); + self::$sessionStorage = @\is_dir($dir = \session_save_path()) || @\is_dir($dir = \ini_get('upload_tmp_dir')) || @\is_dir($dir = \sys_get_temp_dir()) || ($dir = self::$logDirectory) ? new FileSession($dir) : new NativeSession(); } return self::$sessionStorage; } @@ -351,14 +351,14 @@ class Debugger public static function dump($var, bool $return = \false) { if ($return) { - $options = [\RectorPrefix20220607\Tracy\Dumper::DEPTH => self::$maxDepth, \RectorPrefix20220607\Tracy\Dumper::TRUNCATE => self::$maxLength, \RectorPrefix20220607\Tracy\Dumper::ITEMS => self::$maxItems]; - return \RectorPrefix20220607\Tracy\Helpers::isCli() ? \RectorPrefix20220607\Tracy\Dumper::toText($var) : \RectorPrefix20220607\Tracy\Helpers::capture(function () use($var, $options) { - \RectorPrefix20220607\Tracy\Dumper::dump($var, $options); + $options = [Dumper::DEPTH => self::$maxDepth, Dumper::TRUNCATE => self::$maxLength, Dumper::ITEMS => self::$maxItems]; + return Helpers::isCli() ? Dumper::toText($var) : Helpers::capture(function () use($var, $options) { + Dumper::dump($var, $options); }); } elseif (!self::$productionMode) { - $html = \RectorPrefix20220607\Tracy\Helpers::isHtmlMode(); + $html = Helpers::isHtmlMode(); echo $html ? '' : ''; - \RectorPrefix20220607\Tracy\Dumper::dump($var, [\RectorPrefix20220607\Tracy\Dumper::DEPTH => self::$maxDepth, \RectorPrefix20220607\Tracy\Dumper::TRUNCATE => self::$maxLength, \RectorPrefix20220607\Tracy\Dumper::ITEMS => self::$maxItems, \RectorPrefix20220607\Tracy\Dumper::LOCATION => self::$showLocation, \RectorPrefix20220607\Tracy\Dumper::THEME => self::$dumpTheme, \RectorPrefix20220607\Tracy\Dumper::KEYS_TO_HIDE => self::$keysToHide]); + Dumper::dump($var, [Dumper::DEPTH => self::$maxDepth, Dumper::TRUNCATE => self::$maxLength, Dumper::ITEMS => self::$maxItems, Dumper::LOCATION => self::$showLocation, Dumper::THEME => self::$dumpTheme, Dumper::KEYS_TO_HIDE => self::$keysToHide]); echo $html ? '' : ''; } return $var; @@ -386,9 +386,9 @@ class Debugger if (!self::$productionMode) { static $panel; if (!$panel) { - self::getBar()->addPanel($panel = new \RectorPrefix20220607\Tracy\DefaultBarPanel('dumps'), 'Tracy:dumps'); + self::getBar()->addPanel($panel = new DefaultBarPanel('dumps'), 'Tracy:dumps'); } - $panel->data[] = ['title' => $title, 'dump' => \RectorPrefix20220607\Tracy\Dumper::toHtml($var, $options + [\RectorPrefix20220607\Tracy\Dumper::DEPTH => self::$maxDepth, \RectorPrefix20220607\Tracy\Dumper::TRUNCATE => self::$maxLength, \RectorPrefix20220607\Tracy\Dumper::LOCATION => self::$showLocation ?: \RectorPrefix20220607\Tracy\Dumper::LOCATION_CLASS | \RectorPrefix20220607\Tracy\Dumper::LOCATION_SOURCE, \RectorPrefix20220607\Tracy\Dumper::LAZY => \true])]; + $panel->data[] = ['title' => $title, 'dump' => Dumper::toHtml($var, $options + [Dumper::DEPTH => self::$maxDepth, Dumper::TRUNCATE => self::$maxLength, Dumper::LOCATION => self::$showLocation ?: Dumper::LOCATION_CLASS | Dumper::LOCATION_SOURCE, Dumper::LAZY => \true])]; } return $var; } @@ -397,7 +397,7 @@ class Debugger * @param mixed $message * @return mixed */ - public static function log($message, string $level = \RectorPrefix20220607\Tracy\ILogger::INFO) + public static function log($message, string $level = ILogger::INFO) { return self::getLogger()->log($message, $level); } diff --git a/vendor/tracy/tracy/src/Tracy/Debugger/DeferredContent.php b/vendor/tracy/tracy/src/Tracy/Debugger/DeferredContent.php index ad426dae460..08b6740a15a 100644 --- a/vendor/tracy/tracy/src/Tracy/Debugger/DeferredContent.php +++ b/vendor/tracy/tracy/src/Tracy/Debugger/DeferredContent.php @@ -18,10 +18,10 @@ final class DeferredContent private $requestId; /** @var bool */ private $useSession = \false; - public function __construct(\RectorPrefix20220607\Tracy\SessionStorage $sessionStorage) + public function __construct(SessionStorage $sessionStorage) { $this->sessionStorage = $sessionStorage; - $this->requestId = $_SERVER['HTTP_X_TRACY_AJAX'] ?? \RectorPrefix20220607\Tracy\Helpers::createId(); + $this->requestId = $_SERVER['HTTP_X_TRACY_AJAX'] ?? Helpers::createId(); } public function isAvailable() : bool { @@ -80,7 +80,7 @@ final class DeferredContent \flush(); return \true; } - if (\RectorPrefix20220607\Tracy\Helpers::isAjax()) { + if (Helpers::isAjax()) { \header('X-Tracy-Ajax: 1'); // session must be already locked } @@ -88,12 +88,12 @@ final class DeferredContent } private function buildJsCss() : string { - $css = \array_map('file_get_contents', \array_merge([__DIR__ . '/../assets/reset.css', __DIR__ . '/../Bar/assets/bar.css', __DIR__ . '/../assets/toggle.css', __DIR__ . '/../assets/table-sort.css', __DIR__ . '/../assets/tabs.css', __DIR__ . '/../Dumper/assets/dumper-light.css', __DIR__ . '/../Dumper/assets/dumper-dark.css', __DIR__ . '/../BlueScreen/assets/bluescreen.css'], \RectorPrefix20220607\Tracy\Debugger::$customCssFiles)); + $css = \array_map('file_get_contents', \array_merge([__DIR__ . '/../assets/reset.css', __DIR__ . '/../Bar/assets/bar.css', __DIR__ . '/../assets/toggle.css', __DIR__ . '/../assets/table-sort.css', __DIR__ . '/../assets/tabs.css', __DIR__ . '/../Dumper/assets/dumper-light.css', __DIR__ . '/../Dumper/assets/dumper-dark.css', __DIR__ . '/../BlueScreen/assets/bluescreen.css'], Debugger::$customCssFiles)); $js1 = \array_map(function ($file) { return '(function() {' . \file_get_contents($file) . '})();'; }, [__DIR__ . '/../Bar/assets/bar.js', __DIR__ . '/../assets/toggle.js', __DIR__ . '/../assets/table-sort.js', __DIR__ . '/../assets/tabs.js', __DIR__ . '/../Dumper/assets/dumper.js', __DIR__ . '/../BlueScreen/assets/bluescreen.js']); - $js2 = \array_map('file_get_contents', \RectorPrefix20220607\Tracy\Debugger::$customJsFiles); - $str = "'use strict';\n(function(){\n\tvar el = document.createElement('style');\n\tel.setAttribute('nonce', document.currentScript.getAttribute('nonce') || document.currentScript.nonce);\n\tel.className='tracy-debug';\n\tel.textContent=" . \json_encode(\RectorPrefix20220607\Tracy\Helpers::minifyCss(\implode('', $css))) . ";\n\tdocument.head.appendChild(el);})\n();\n" . \implode('', $js1) . \implode('', $js2); + $js2 = \array_map('file_get_contents', Debugger::$customJsFiles); + $str = "'use strict';\n(function(){\n\tvar el = document.createElement('style');\n\tel.setAttribute('nonce', document.currentScript.getAttribute('nonce') || document.currentScript.nonce);\n\tel.className='tracy-debug';\n\tel.textContent=" . \json_encode(Helpers::minifyCss(\implode('', $css))) . ";\n\tdocument.head.appendChild(el);})\n();\n" . \implode('', $js1) . \implode('', $js2); return $str; } public function clean() : void diff --git a/vendor/tracy/tracy/src/Tracy/Debugger/DevelopmentStrategy.php b/vendor/tracy/tracy/src/Tracy/Debugger/DevelopmentStrategy.php index e61fe5bab52..463058965b6 100644 --- a/vendor/tracy/tracy/src/Tracy/Debugger/DevelopmentStrategy.php +++ b/vendor/tracy/tracy/src/Tracy/Debugger/DevelopmentStrategy.php @@ -19,7 +19,7 @@ final class DevelopmentStrategy private $blueScreen; /** @var DeferredContent */ private $defer; - public function __construct(\RectorPrefix20220607\Tracy\Bar $bar, \RectorPrefix20220607\Tracy\BlueScreen $blueScreen, \RectorPrefix20220607\Tracy\DeferredContent $defer) + public function __construct(Bar $bar, BlueScreen $blueScreen, DeferredContent $defer) { $this->bar = $bar; $this->blueScreen = $blueScreen; @@ -30,19 +30,19 @@ final class DevelopmentStrategy } public function handleException(\Throwable $exception, bool $firstTime) : void { - if (\RectorPrefix20220607\Tracy\Helpers::isAjax() && $this->defer->isAvailable()) { + if (Helpers::isAjax() && $this->defer->isAvailable()) { $this->blueScreen->renderToAjax($exception, $this->defer); - } elseif ($firstTime && \RectorPrefix20220607\Tracy\Helpers::isHtmlMode()) { + } elseif ($firstTime && Helpers::isHtmlMode()) { $this->blueScreen->render($exception); } else { - \RectorPrefix20220607\Tracy\Debugger::fireLog($exception); + Debugger::fireLog($exception); $this->renderExceptionCli($exception); } } private function renderExceptionCli(\Throwable $exception) : void { try { - $logFile = \RectorPrefix20220607\Tracy\Debugger::log($exception, \RectorPrefix20220607\Tracy\Debugger::EXCEPTION); + $logFile = Debugger::log($exception, Debugger::EXCEPTION); } catch (\Throwable $e) { echo "{$exception}\nTracy is unable to log error: {$e->getMessage()}\n"; return; @@ -50,12 +50,12 @@ final class DevelopmentStrategy if ($logFile && !\headers_sent()) { \header("X-Tracy-Error-Log: {$logFile}", \false); } - if (\RectorPrefix20220607\Tracy\Helpers::detectColors()) { + if (Helpers::detectColors()) { echo "\n\n" . $this->blueScreen->highlightPhpCli($exception->getFile(), $exception->getLine()) . "\n"; } echo "{$exception}\n" . ($logFile ? "\n(stored in {$logFile})\n" : ''); - if ($logFile && \RectorPrefix20220607\Tracy\Debugger::$browser) { - \exec(\RectorPrefix20220607\Tracy\Debugger::$browser . ' ' . \escapeshellarg(\strtr($logFile, \RectorPrefix20220607\Tracy\Debugger::$editorMapping))); + if ($logFile && Debugger::$browser) { + \exec(Debugger::$browser . ' ' . \escapeshellarg(\strtr($logFile, Debugger::$editorMapping))); } } public function handleError(int $severity, string $message, string $file, int $line, array $context = null) : void @@ -63,19 +63,19 @@ final class DevelopmentStrategy if (\function_exists('ini_set')) { $oldDisplay = \ini_set('display_errors', '1'); } - if ((\is_bool(\RectorPrefix20220607\Tracy\Debugger::$strictMode) ? \RectorPrefix20220607\Tracy\Debugger::$strictMode : \RectorPrefix20220607\Tracy\Debugger::$strictMode & $severity) && !isset($_GET['_tracy_skip_error'])) { - $e = new \ErrorException($message, 0, $severity, $file, $line); + if ((\is_bool(Debugger::$strictMode) ? Debugger::$strictMode : Debugger::$strictMode & $severity) && !isset($_GET['_tracy_skip_error'])) { + $e = new ErrorException($message, 0, $severity, $file, $line); $e->context = $context; $e->skippable = \true; - \RectorPrefix20220607\Tracy\Debugger::exceptionHandler($e); + Debugger::exceptionHandler($e); exit(255); } - $message = 'PHP ' . \RectorPrefix20220607\Tracy\Helpers::errorTypeToString($severity) . ': ' . \RectorPrefix20220607\Tracy\Helpers::improveError($message, (array) $context); + $message = 'PHP ' . Helpers::errorTypeToString($severity) . ': ' . Helpers::improveError($message, (array) $context); $count =& $this->bar->getPanel('Tracy:errors')->data["{$file}|{$line}|{$message}"]; if (!$count++) { // not repeated error - \RectorPrefix20220607\Tracy\Debugger::fireLog(new \ErrorException($message, 0, $severity, $file, $line)); - if (!\RectorPrefix20220607\Tracy\Helpers::isHtmlMode() && !\RectorPrefix20220607\Tracy\Helpers::isAjax()) { + Debugger::fireLog(new ErrorException($message, 0, $severity, $file, $line)); + if (!Helpers::isHtmlMode() && !Helpers::isAjax()) { echo "\n{$message} in {$file} on line {$line}\n"; } } diff --git a/vendor/tracy/tracy/src/Tracy/Debugger/ProductionStrategy.php b/vendor/tracy/tracy/src/Tracy/Debugger/ProductionStrategy.php index a0f6240c9ca..d982ce3a60b 100644 --- a/vendor/tracy/tracy/src/Tracy/Debugger/ProductionStrategy.php +++ b/vendor/tracy/tracy/src/Tracy/Debugger/ProductionStrategy.php @@ -16,40 +16,40 @@ final class ProductionStrategy public function initialize() : void { if (!\function_exists('ini_set') && (\ini_get('display_errors') && \ini_get('display_errors') !== 'stderr')) { - \RectorPrefix20220607\Tracy\Debugger::exceptionHandler(new \RuntimeException("Unable to set 'display_errors' because function ini_set() is disabled.")); + Debugger::exceptionHandler(new \RuntimeException("Unable to set 'display_errors' because function ini_set() is disabled.")); } } public function handleException(\Throwable $exception, bool $firstTime) : void { try { - \RectorPrefix20220607\Tracy\Debugger::log($exception, \RectorPrefix20220607\Tracy\Debugger::EXCEPTION); + Debugger::log($exception, Debugger::EXCEPTION); } catch (\Throwable $e) { } if (!$firstTime) { // nothing - } elseif (\RectorPrefix20220607\Tracy\Helpers::isHtmlMode()) { + } elseif (Helpers::isHtmlMode()) { if (!\headers_sent()) { \header('Content-Type: text/html; charset=UTF-8'); } (function ($logged) use($exception) { - require \RectorPrefix20220607\Tracy\Debugger::$errorTemplate ?: __DIR__ . '/assets/error.500.phtml'; + require Debugger::$errorTemplate ?: __DIR__ . '/assets/error.500.phtml'; })(empty($e)); - } elseif (\RectorPrefix20220607\Tracy\Helpers::isCli()) { + } elseif (Helpers::isCli()) { // @ triggers E_NOTICE when strerr is closed since PHP 7.4 @\fwrite(\STDERR, "ERROR: {$exception->getMessage()}\n" . (isset($e) ? 'Unable to log error. You may try enable debug mode to inspect the problem.' : 'Check log to see more info.') . "\n"); } } public function handleError(int $severity, string $message, string $file, int $line, array $context = null) : void { - if ($severity & \RectorPrefix20220607\Tracy\Debugger::$logSeverity) { - $err = new \ErrorException($message, 0, $severity, $file, $line); + if ($severity & Debugger::$logSeverity) { + $err = new ErrorException($message, 0, $severity, $file, $line); $err->context = $context; - \RectorPrefix20220607\Tracy\Helpers::improveException($err); + Helpers::improveException($err); } else { - $err = 'PHP ' . \RectorPrefix20220607\Tracy\Helpers::errorTypeToString($severity) . ': ' . \RectorPrefix20220607\Tracy\Helpers::improveError($message, (array) $context) . " in {$file}:{$line}"; + $err = 'PHP ' . Helpers::errorTypeToString($severity) . ': ' . Helpers::improveError($message, (array) $context) . " in {$file}:{$line}"; } try { - \RectorPrefix20220607\Tracy\Debugger::log($err, \RectorPrefix20220607\Tracy\Debugger::ERROR); + Debugger::log($err, Debugger::ERROR); } catch (\Throwable $e) { } } diff --git a/vendor/tracy/tracy/src/Tracy/Dumper/Describer.php b/vendor/tracy/tracy/src/Tracy/Dumper/Describer.php index 938f4b68e3d..5a6ee4cdf6f 100644 --- a/vendor/tracy/tracy/src/Tracy/Dumper/Describer.php +++ b/vendor/tracy/tracy/src/Tracy/Dumper/Describer.php @@ -69,7 +69,7 @@ final class Describer */ private function describeInteger(int $num) { - return $num <= self::JsSafeInteger && $num >= -self::JsSafeInteger ? $num : new \RectorPrefix20220607\Tracy\Dumper\Value(\RectorPrefix20220607\Tracy\Dumper\Value::TYPE_NUMBER, "{$num}"); + return $num <= self::JsSafeInteger && $num >= -self::JsSafeInteger ? $num : new Value(Value::TYPE_NUMBER, "{$num}"); } /** * @return Value|float @@ -77,10 +77,10 @@ final class Describer private function describeDouble(float $num) { if (!\is_finite($num)) { - return new \RectorPrefix20220607\Tracy\Dumper\Value(\RectorPrefix20220607\Tracy\Dumper\Value::TYPE_NUMBER, (string) $num); + return new Value(Value::TYPE_NUMBER, (string) $num); } $js = \json_encode($num); - return \strpos($js, '.') ? $num : new \RectorPrefix20220607\Tracy\Dumper\Value(\RectorPrefix20220607\Tracy\Dumper\Value::TYPE_NUMBER, "{$js}.0"); + return \strpos($js, '.') ? $num : new Value(Value::TYPE_NUMBER, "{$js}.0"); // to distinct int and float in JS } /** @@ -88,13 +88,13 @@ final class Describer */ private function describeString(string $s, int $depth = 0) { - $encoded = \RectorPrefix20220607\Tracy\Helpers::encodeString($s, $depth ? $this->maxLength : null); + $encoded = Helpers::encodeString($s, $depth ? $this->maxLength : null); if ($encoded === $s) { return $encoded; - } elseif (\RectorPrefix20220607\Tracy\Helpers::isUtf8($s)) { - return new \RectorPrefix20220607\Tracy\Dumper\Value(\RectorPrefix20220607\Tracy\Dumper\Value::TYPE_STRING_HTML, $encoded, \RectorPrefix20220607\Tracy\Helpers::utf8Length($s)); + } elseif (Helpers::isUtf8($s)) { + return new Value(Value::TYPE_STRING_HTML, $encoded, Helpers::utf8Length($s)); } else { - return new \RectorPrefix20220607\Tracy\Dumper\Value(\RectorPrefix20220607\Tracy\Dumper\Value::TYPE_BINARY_HTML, $encoded, \strlen($s)); + return new Value(Value::TYPE_BINARY_HTML, $encoded, \strlen($s)); } } /** @@ -103,12 +103,12 @@ final class Describer private function describeArray(array $arr, int $depth = 0, ?int $refId = null) { if ($refId) { - $res = new \RectorPrefix20220607\Tracy\Dumper\Value(\RectorPrefix20220607\Tracy\Dumper\Value::TYPE_REF, 'p' . $refId); + $res = new Value(Value::TYPE_REF, 'p' . $refId); $value =& $this->snapshot[$res->value]; if ($value && $value->depth <= $depth) { return $res; } - $value = new \RectorPrefix20220607\Tracy\Dumper\Value(\RectorPrefix20220607\Tracy\Dumper\Value::TYPE_ARRAY); + $value = new Value(Value::TYPE_ARRAY); $value->id = $res->value; $value->depth = $depth; if ($this->maxDepth && $depth >= $this->maxDepth) { @@ -120,9 +120,9 @@ final class Describer } $items =& $value->items; } elseif ($arr && $this->maxDepth && $depth >= $this->maxDepth) { - return new \RectorPrefix20220607\Tracy\Dumper\Value(\RectorPrefix20220607\Tracy\Dumper\Value::TYPE_ARRAY, null, \count($arr)); + return new Value(Value::TYPE_ARRAY, null, \count($arr)); } elseif ($depth && $this->maxItems && \count($arr) > $this->maxItems) { - $res = new \RectorPrefix20220607\Tracy\Dumper\Value(\RectorPrefix20220607\Tracy\Dumper\Value::TYPE_ARRAY, null, \count($arr)); + $res = new Value(Value::TYPE_ARRAY, null, \count($arr)); $res->depth = $depth; $items =& $res->items; $arr = \array_slice($arr, 0, $this->maxItems, \true); @@ -130,25 +130,25 @@ final class Describer $items = []; foreach ($arr as $k => $v) { $refId = $this->getReferenceId($arr, $k); - $items[] = [$this->describeVar($k, $depth + 1), $this->isSensitive((string) $k, $v) ? new \RectorPrefix20220607\Tracy\Dumper\Value(\RectorPrefix20220607\Tracy\Dumper\Value::TYPE_TEXT, self::hideValue($v)) : $this->describeVar($v, $depth + 1, $refId)] + ($refId ? [2 => $refId] : []); + $items[] = [$this->describeVar($k, $depth + 1), $this->isSensitive((string) $k, $v) ? new Value(Value::TYPE_TEXT, self::hideValue($v)) : $this->describeVar($v, $depth + 1, $refId)] + ($refId ? [2 => $refId] : []); } return $res ?? $items; } - private function describeObject(object $obj, int $depth = 0) : \RectorPrefix20220607\Tracy\Dumper\Value + private function describeObject(object $obj, int $depth = 0) : Value { $id = \spl_object_id($obj); $value =& $this->snapshot[$id]; if ($value && $value->depth <= $depth) { - return new \RectorPrefix20220607\Tracy\Dumper\Value(\RectorPrefix20220607\Tracy\Dumper\Value::TYPE_REF, $id); + return new Value(Value::TYPE_REF, $id); } - $value = new \RectorPrefix20220607\Tracy\Dumper\Value(\RectorPrefix20220607\Tracy\Dumper\Value::TYPE_OBJECT, \RectorPrefix20220607\Tracy\Helpers::getClass($obj)); + $value = new Value(Value::TYPE_OBJECT, Helpers::getClass($obj)); $value->id = $id; $value->depth = $depth; $value->holder = $obj; // to be not released by garbage collector in collecting mode if ($this->location) { $rc = $obj instanceof \Closure ? new \ReflectionFunction($obj) : new \ReflectionClass($obj); - if ($rc->getFileName() && ($editor = \RectorPrefix20220607\Tracy\Helpers::editorUri($rc->getFileName(), $rc->getStartLine()))) { + if ($rc->getFileName() && ($editor = Helpers::editorUri($rc->getFileName(), $rc->getStartLine()))) { $value->editor = (object) ['file' => $rc->getFileName(), 'line' => $rc->getStartLine(), 'url' => $editor]; } } @@ -156,21 +156,21 @@ final class Describer $value->items = []; $props = $this->exposeObject($obj, $value); foreach ($props ?? [] as $k => $v) { - $this->addPropertyTo($value, (string) $k, $v, \RectorPrefix20220607\Tracy\Dumper\Value::PROP_VIRTUAL, $this->getReferenceId($props, $k)); + $this->addPropertyTo($value, (string) $k, $v, Value::PROP_VIRTUAL, $this->getReferenceId($props, $k)); } } - return new \RectorPrefix20220607\Tracy\Dumper\Value(\RectorPrefix20220607\Tracy\Dumper\Value::TYPE_REF, $id); + return new Value(Value::TYPE_REF, $id); } /** * @param resource $resource */ - private function describeResource($resource, int $depth = 0) : \RectorPrefix20220607\Tracy\Dumper\Value + private function describeResource($resource, int $depth = 0) : Value { $id = 'r' . (int) $resource; $value =& $this->snapshot[$id]; if (!$value) { $type = \is_resource($resource) ? \get_resource_type($resource) : 'closed'; - $value = new \RectorPrefix20220607\Tracy\Dumper\Value(\RectorPrefix20220607\Tracy\Dumper\Value::TYPE_RESOURCE, $type . ' resource'); + $value = new Value(Value::TYPE_RESOURCE, $type . ' resource'); $value->id = $id; $value->depth = $depth; $value->items = []; @@ -180,7 +180,7 @@ final class Describer } } } - return new \RectorPrefix20220607\Tracy\Dumper\Value(\RectorPrefix20220607\Tracy\Dumper\Value::TYPE_REF, $id); + return new Value(Value::TYPE_REF, $id); } /** * @return Value|string @@ -191,18 +191,18 @@ final class Describer return $key; } $value = $this->describeString($key); - return \is_string($value) ? new \RectorPrefix20220607\Tracy\Dumper\Value(\RectorPrefix20220607\Tracy\Dumper\Value::TYPE_STRING_HTML, $key, \RectorPrefix20220607\Tracy\Helpers::utf8Length($key)) : $value; + return \is_string($value) ? new Value(Value::TYPE_STRING_HTML, $key, Helpers::utf8Length($key)) : $value; } - public function addPropertyTo(\RectorPrefix20220607\Tracy\Dumper\Value $value, string $k, $v, $type = \RectorPrefix20220607\Tracy\Dumper\Value::PROP_VIRTUAL, ?int $refId = null, ?string $class = null) + public function addPropertyTo(Value $value, string $k, $v, $type = Value::PROP_VIRTUAL, ?int $refId = null, ?string $class = null) { if ($value->depth && $this->maxItems && \count($value->items ?? []) >= $this->maxItems) { $value->length = ($value->length ?? \count($value->items)) + 1; return; } $class = $class ?? $value->value; - $value->items[] = [$this->describeKey($k), $type !== \RectorPrefix20220607\Tracy\Dumper\Value::PROP_VIRTUAL && $this->isSensitive($k, $v, $class) ? new \RectorPrefix20220607\Tracy\Dumper\Value(\RectorPrefix20220607\Tracy\Dumper\Value::TYPE_TEXT, self::hideValue($v)) : $this->describeVar($v, $value->depth + 1, $refId), $type === \RectorPrefix20220607\Tracy\Dumper\Value::PROP_PRIVATE ? $class : $type] + ($refId ? [3 => $refId] : []); + $value->items[] = [$this->describeKey($k), $type !== Value::PROP_VIRTUAL && $this->isSensitive($k, $v, $class) ? new Value(Value::TYPE_TEXT, self::hideValue($v)) : $this->describeVar($v, $value->depth + 1, $refId), $type === Value::PROP_PRIVATE ? $class : $type] + ($refId ? [3 => $refId] : []); } - private function exposeObject(object $obj, \RectorPrefix20220607\Tracy\Dumper\Value $value) : ?array + private function exposeObject(object $obj, Value $value) : ?array { foreach ($this->objectExposers as $type => $dumper) { if (!$type || $obj instanceof $type) { @@ -212,7 +212,7 @@ final class Describer if ($this->debugInfo && \method_exists($obj, '__debugInfo')) { return $obj->__debugInfo(); } - \RectorPrefix20220607\Tracy\Dumper\Exposer::exposeObject($obj, $value, $this); + Exposer::exposeObject($obj, $value, $this); return null; } private function isSensitive(string $key, $val, ?string $class = null) : bool @@ -221,7 +221,7 @@ final class Describer } private static function hideValue($var) : string { - return self::HIDDEN_VALUE . ' (' . (\is_object($var) ? \RectorPrefix20220607\Tracy\Helpers::getClass($var) : \gettype($var)) . ')'; + return self::HIDDEN_VALUE . ' (' . (\is_object($var) ? Helpers::getClass($var) : \gettype($var)) . ')'; } public function getReferenceId($arr, $key) : ?int { @@ -256,7 +256,7 @@ final class Describer private static function findLocation() : ?array { foreach (\debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS) as $item) { - if (isset($item['class']) && ($item['class'] === self::class || $item['class'] === \RectorPrefix20220607\Tracy\Dumper::class)) { + if (isset($item['class']) && ($item['class'] === self::class || $item['class'] === Tracy\Dumper::class)) { $location = $item; continue; } elseif (isset($item['function'])) { diff --git a/vendor/tracy/tracy/src/Tracy/Dumper/Dumper.php b/vendor/tracy/tracy/src/Tracy/Dumper/Dumper.php index 5d7e94e4701..31d07e4e44f 100644 --- a/vendor/tracy/tracy/src/Tracy/Dumper/Dumper.php +++ b/vendor/tracy/tracy/src/Tracy/Dumper/Dumper.php @@ -20,7 +20,7 @@ class Dumper // show object and reference hashes (defaults to true) public const LOCATION_CLASS = 0b1, LOCATION_SOURCE = 0b11, LOCATION_LINK = self::LOCATION_SOURCE; // deprecated - public const HIDDEN_VALUE = \RectorPrefix20220607\Tracy\Dumper\Describer::HIDDEN_VALUE; + public const HIDDEN_VALUE = Describer::HIDDEN_VALUE; /** @var Dumper\Value[] */ public static $liveSnapshot = []; /** @var array */ @@ -28,7 +28,7 @@ class Dumper /** @var array */ public static $resources = ['stream' => 'stream_get_meta_data', 'stream-context' => 'stream_context_get_options', 'curl' => 'curl_getinfo']; /** @var array */ - public static $objectExporters = [\Closure::class => [\RectorPrefix20220607\Tracy\Dumper\Exposer::class, 'exposeClosure'], \RectorPrefix20220607\UnitEnum::class => [\RectorPrefix20220607\Tracy\Dumper\Exposer::class, 'exposeEnum'], \ArrayObject::class => [\RectorPrefix20220607\Tracy\Dumper\Exposer::class, 'exposeArrayObject'], \SplFileInfo::class => [\RectorPrefix20220607\Tracy\Dumper\Exposer::class, 'exposeSplFileInfo'], \SplObjectStorage::class => [\RectorPrefix20220607\Tracy\Dumper\Exposer::class, 'exposeSplObjectStorage'], \__PHP_Incomplete_Class::class => [\RectorPrefix20220607\Tracy\Dumper\Exposer::class, 'exposePhpIncompleteClass'], \Generator::class => [\RectorPrefix20220607\Tracy\Dumper\Exposer::class, 'exposeGenerator'], \RectorPrefix20220607\Fiber::class => [\RectorPrefix20220607\Tracy\Dumper\Exposer::class, 'exposeFiber'], \DOMNode::class => [\RectorPrefix20220607\Tracy\Dumper\Exposer::class, 'exposeDOMNode'], \DOMNodeList::class => [\RectorPrefix20220607\Tracy\Dumper\Exposer::class, 'exposeDOMNodeList'], \DOMNamedNodeMap::class => [\RectorPrefix20220607\Tracy\Dumper\Exposer::class, 'exposeDOMNodeList'], \Ds\Collection::class => [\RectorPrefix20220607\Tracy\Dumper\Exposer::class, 'exposeDsCollection'], \Ds\Map::class => [\RectorPrefix20220607\Tracy\Dumper\Exposer::class, 'exposeDsMap']]; + public static $objectExporters = [\Closure::class => [Exposer::class, 'exposeClosure'], \UnitEnum::class => [Exposer::class, 'exposeEnum'], \ArrayObject::class => [Exposer::class, 'exposeArrayObject'], \SplFileInfo::class => [Exposer::class, 'exposeSplFileInfo'], \SplObjectStorage::class => [Exposer::class, 'exposeSplObjectStorage'], \__PHP_Incomplete_Class::class => [Exposer::class, 'exposePhpIncompleteClass'], \Generator::class => [Exposer::class, 'exposeGenerator'], \Fiber::class => [Exposer::class, 'exposeFiber'], \DOMNode::class => [Exposer::class, 'exposeDOMNode'], \DOMNodeList::class => [Exposer::class, 'exposeDOMNodeList'], \DOMNamedNodeMap::class => [Exposer::class, 'exposeDOMNodeList'], Ds\Collection::class => [Exposer::class, 'exposeDsCollection'], Ds\Map::class => [Exposer::class, 'exposeDsMap']]; /** @var Describer */ private $describer; /** @var Renderer */ @@ -39,11 +39,11 @@ class Dumper */ public static function dump($var, array $options = []) { - if (\RectorPrefix20220607\Tracy\Helpers::isCli()) { - $useColors = self::$terminalColors && \RectorPrefix20220607\Tracy\Helpers::detectColors(); + if (Helpers::isCli()) { + $useColors = self::$terminalColors && Helpers::detectColors(); $dumper = new self($options); \fwrite(\STDOUT, $dumper->asTerminal($var, $useColors ? self::$terminalColors : [])); - } elseif (\RectorPrefix20220607\Tracy\Helpers::isHtmlMode()) { + } elseif (Helpers::isHtmlMode()) { $options[self::LOCATION] = $options[self::LOCATION] ?? \true; self::renderAssets(); echo self::toHtml($var, $options); @@ -79,24 +79,24 @@ class Dumper public static function renderAssets() : void { static $sent; - if (\RectorPrefix20220607\Tracy\Debugger::$productionMode === \true || $sent) { + if (Debugger::$productionMode === \true || $sent) { return; } $sent = \true; - $nonce = \RectorPrefix20220607\Tracy\Helpers::getNonce(); - $nonceAttr = $nonce ? ' nonce="' . \RectorPrefix20220607\Tracy\Helpers::escapeHtml($nonce) . '"' : ''; + $nonce = Helpers::getNonce(); + $nonceAttr = $nonce ? ' nonce="' . Helpers::escapeHtml($nonce) . '"' : ''; $s = \file_get_contents(__DIR__ . '/../assets/toggle.css') . \file_get_contents(__DIR__ . '/assets/dumper-light.css') . \file_get_contents(__DIR__ . '/assets/dumper-dark.css'); - echo "", \str_replace('\n"; - if (!\RectorPrefix20220607\Tracy\Debugger::isEnabled()) { + echo "", \str_replace('\n"; + if (!Debugger::isEnabled()) { $s = '(function(){' . \file_get_contents(__DIR__ . '/../assets/toggle.js') . '})();' . '(function(){' . \file_get_contents(__DIR__ . '/../Dumper/assets/dumper.js') . '})();'; - echo "", \str_replace(['